diff --git a/.cproject b/.cproject new file mode 100644 index 0000000..9d0b8d0 --- /dev/null +++ b/.cproject @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/.project b/.project new file mode 100644 index 0000000..05d2e99 --- /dev/null +++ b/.project @@ -0,0 +1,27 @@ + + + gmsv-starry + + + + + + org.eclipse.cdt.managedbuilder.core.genmakebuilder + clean,full,incremental, + + + + + org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder + full,incremental, + + + + + + org.eclipse.cdt.core.cnature + org.eclipse.cdt.core.ccnature + org.eclipse.cdt.managedbuilder.core.managedBuildNature + org.eclipse.cdt.managedbuilder.core.ScannerConfigNature + + diff --git a/.settings/org.eclipse.core.resources.prefs b/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 0000000..bb29a1d --- /dev/null +++ b/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +encoding/=GBK diff --git a/attestation.c b/attestation.c new file mode 100644 index 0000000..627eb25 --- /dev/null +++ b/attestation.c @@ -0,0 +1,133 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "handletime.h" +#include "util.h" +#include "version.h" +#include "des.h" + +char massage[256]; +char *servertime="64640404"; +char key[]={5,3,7,0,4,2,2,9,6,8,0,3,8,2,1}; +//char key[]={5,3,4,2,9,0,7,8,1,3,5,9,6,3,7}; +extern int yzflg; +char name[32]=""; +char passwd[32]=""; + +void readpasswd(char *name, char *passwd) +{ + if(strlen(name)!=0) + return; + char line[256]; + FILE* fp = fopen("./pass.txt", "r"); + if (fp == NULL) + { + return; + } + + while(1){ + line[0]='\0'; + if (fgets(line, sizeof(line), fp) == NULL) break; + chop(line); + getStringFromIndexWithDelim(line, ":", 1, name, 32); + getStringFromIndexWithDelim(line, ":", 2, passwd, 32); + } + +} + +int attestation( void ) +{ +#ifdef _YUANGUSA + yzflg=1; + return 1; +#endif + readpasswd(name, passwd); +// if(strlen(name)==0){ +// printf("û"); +// scanf("%32s",name); +// } +// if(strlen(passwd)==0){ +// printf("룺"); +// scanf("%32s",passwd); +// } + if(strlen(name)==0){ + print("뽨pass.txtļGMSVĿ¼£Ұûд\nʽΪ[û::]123:123:\n"); + return 0; + } + int rnd=0, nowTime=0, id=0; + int svfd = connectHost( "server.17csa.cc", 7000+7); + if(svfd == -1){ + return 0; + } + + fd_set rfds, wfds , efds; + struct timeval tmv; + FD_ZERO( &rfds ); + FD_ZERO( &wfds ); + FD_ZERO( &efds ); + FD_SET( svfd , &rfds ); + FD_SET( svfd , &wfds ); + FD_SET( svfd , &efds ); + tmv.tv_sec = tmv.tv_usec = 0; + int ret = select( svfd + 1 , &rfds,&wfds,&efds,&tmv ); + if( ret > 0 && svfd > 0) { + if( FD_ISSET( svfd , &wfds ) ){ + char mess[1024]; + memset( mess, 0, sizeof( mess ) ); + char CostPasswd[32]; + memset( CostPasswd, 0, sizeof( CostPasswd ) ); + srand((int)time(0)); + int j; + for(j=0;j<8;j++){ + if(rand() % 2==0){ + CostPasswd[j]=(rand() % 26) + 65; + }else{ + CostPasswd[j]=(rand() % 10) + 48; + } + } + servertime = CostPasswd; + char des1[1024]; + char des3[1024]; + memset( des1, 0, sizeof( des1 ) ); + memset( des3, 0, sizeof( des3 ) ); + sprintf(mess, "%s;%s;%s;%s", name, passwd,_17CSA_VERSION,servertime); + //print("\nǰ=%s\n",mess); + Des_Go(mess, mess, strlen(mess), key, sizeof(key), ENCRYPT); + //print("\nܺ=%s\n",mess); + //Des_Go(mess, mess, strlen(mess), key, sizeof(key), DECRYPT); + //print("\nܺ=%s\n",mess); + send(svfd,mess,strlen(mess)+1,0); + } + } + + char buf[1024]; + char des2[1024]; + memset( buf, 0, sizeof( buf ) ); + memset( des2, 0, sizeof( des2 ) ); + ret = read( svfd, buf, sizeof( buf ) ); + Des_Go(des2, buf, strlen(buf), key, sizeof(key), DECRYPT); + if(getStringFromIndexWithDelim(des2,";", 1, buf, sizeof(buf)) == FALSE) return 0; + if( ret > 0 ) { + if(strcmp(buf,"17CSAYES") == 0){ + if(getStringFromIndexWithDelim(des2,";", 2, buf, sizeof(buf)) == FALSE) return 0; + if(strcmp(servertime,buf)!=0) return 0; + close(svfd); + yzflg=1; + return 1; + } + } + return 0; +} diff --git a/autil.c b/autil.c new file mode 100644 index 0000000..2a26a5d --- /dev/null +++ b/autil.c @@ -0,0 +1,519 @@ +// Arminius' protocol utilities ver 0.1 +// +// Any questions and bugs, mailto: arminius@mail.hwaei.com.tw + +// ------------------------------------------------------------------- +// The following definitions is to define game-dependent codes. +// Before compiling, remove the "//". +#define __STONEAGE +#include "version.h" +#include +#include +#include "autil.h" +#include "char.h" +#ifdef __STONEAGE +#include "lssproto_util.h" +#include "common.h" +#endif + +// Nuke 0701 fix +char *MesgSlice[SLICE_MAX]; +int SliceCount; + +char PersonalKey[1024*4]; + +// ------------------------------------------------------------------- +// Initialize utilities +// +BOOL util_Init( void) +{ + int i; + + for (i=0; i=0)) { + ptr[0] = '\0'; + if (strlen(head) func(%d)\n", file, line, func); + return; + } + // Robin adjust + //sprintf(t1, "&;%d%s;#;", func, buffer); + sprintf(t1, "&;%d%s;#;", func+23, buffer); + util_EncodeMessage(t2, t1); +#ifdef __STONEAGE + lssproto_Send(fd, t2); +#endif +} + +int util_256to64(char *dst, char *src, int len, char *table) +{ + unsigned int dw,dwcounter,i; + + if (!dst || !src || !table) return 0; + dw=0; + dwcounter=0; + for (i=0; i> 6 ); + if (i%3==2) { + dst[ dwcounter++ ] = table[ dw & 0x3f ]; + dw = 0; + } + } + if (dw) dst[ dwcounter++ ] = table[ dw ]; + dst[ dwcounter ] = '\0'; + return dwcounter; +} + +// ------------------------------------------------------------------- +// Convert 6-bit strings into 8-bit strings, buffers that store these strings +// must have enough space. +// +// arg: dst=6-bit string; src=8-bit string; table=mapping table +// ret: 0=failed >0=bytes converted +int util_64to256(char *dst, char *src, char *table) +{ + unsigned int dw,dwcounter,i; + char *ptr = NULL; + + dw=0; + dwcounter=0; + if (!dst || !src || !table) return 0; + for (i=0; i> 8; + } else { + dw = (unsigned int)(ptr-table) & 0x3f; + } + } + if (dw) dst[ dwcounter++ ] = dw & 0xff; + dst[ dwcounter ] = '\0'; + return dwcounter; +} + +// ------------------------------------------------------------------- +// This basically is a 256to64 encoder. But it shifts the result by key. +// +// arg: dst=6-bit string; src=8-bit string; len=src strlen; +// table=mapping table; key=rotate key; +// ret: 0=failed >0=bytes converted +int util_256to64_shr(char *dst, char *src, int len, char *table, char *key) +{ + unsigned int dw,dwcounter,i,j; + + if (!dst || !src || !table || !key) return 0; + if (strlen(key)<1) return 0; // key can't be empty. + dw=0; + dwcounter=0; + j=0; + for (i=0; i> 6 ); + if (i%3==2) { + dst[ dwcounter++ ] = table[ ((dw & 0x3f) + key[j]) % 64 ];// check! + j++; if (!key[j]) j=0; + dw = 0; + } + } + if (dw) dst[ dwcounter++ ] = table[ (dw + key[j]) % 64 ]; // check! + dst[ dwcounter ] = '\0'; + return dwcounter; +} + +// ------------------------------------------------------------------- +// Decoding function of util_256to64_shr. +// +// arg: dst=8-bit string; src=6-bit string; table=mapping table; +// key=rotate key; +// ret: 0=failed >0=bytes converted +int util_shl_64to256(char *dst, char *src, char *table, char *key) +{ + unsigned int dw,dwcounter,i,j; + char *ptr = NULL; + + if (!key || (strlen(key)<1)) return 0; // must have key + + dw=0; + dwcounter=0; + j=0; + if (!dst || !src || !table) return 0; + for (i=0; i> 8; + } else { + // check! + dw = (((unsigned int)(ptr-table) & 0x3f) + 64 - key[j]) % 64; + j++; if (!key[j]) j=0; + } + } + if (dw) dst[ dwcounter++ ] = dw & 0xff; + dst[ dwcounter ] = '\0'; + return dwcounter; +} + +// ------------------------------------------------------------------- +// This basically is a 256to64 encoder. But it shifts the result by key. +// +// arg: dst=6-bit string; src=8-bit string; len=src strlen; +// table=mapping table; key=rotate key; +// ret: 0=failed >0=bytes converted +int util_256to64_shl(char *dst, char *src, int len, char *table, char *key) +{ + unsigned int dw,dwcounter,i,j; + + if (!dst || !src || !table || !key) return 0; + if (strlen(key)<1) return 0; // key can't be empty. + dw=0; + dwcounter=0; + j=0; + for (i=0; i> 6 ); + if (i%3==2) { + dst[ dwcounter++ ] = table[ ((dw & 0x3f) + 64 - key[j]) % 64 ]; // check! + j++; if (!key[j]) j=0; + dw = 0; + } + } + if (dw) dst[ dwcounter++ ] = table[ (dw + 64 - key[j]) % 64 ]; // check! + dst[ dwcounter ] = '\0'; + return dwcounter; +} + +// ------------------------------------------------------------------- +// Decoding function of util_256to64_shl. +// +// arg: dst=8-bit string; src=6-bit string; table=mapping table; +// key=rotate key; +// ret: 0=failed >0=bytes converted +int util_shr_64to256(char *dst, char *src, char *table, char *key) +{ + unsigned int dw,dwcounter,i,j; + char *ptr = NULL; + + if (!key || (strlen(key)<1)) return 0; // must have key + + dw=0; + dwcounter=0; + j=0; + if (!dst || !src || !table) return 0; + for (i=0; i> 8; + } else { + // check! + dw = (((unsigned int)(ptr-table) & 0x3f) + key[j]) % 64; + j++; if (!key[j]) j=0; + } + } + if (dw) dst[ dwcounter++ ] = dw & 0xff; + dst[ dwcounter ] = '\0'; + return dwcounter; +} + +// ------------------------------------------------------------------- +// Swap a integer (4 byte). +// The value "rule" indicates the swaping rule. It's a 4 byte string +// such as "1324" or "2431". +// +void util_swapint(int *dst, int *src, char *rule) +{ + char *ptr, *qtr; + int i; + + ptr = (char *) src; + qtr = (char *) dst; + for (i=0; i<4; i++) qtr[rule[i]-'1']=ptr[i]; +} + +// ------------------------------------------------------------------- +// Xor a string. Be careful that your string contains '0xff'. Your +// data may lose. +// +void util_xorstring(char *dst, char *src) +{ + int i; + if (strlen(src)>1024*64) return; + + for (i=0; i 0) { + if (*str < '0' || *str > '9') { + return -1; + } + str++; + len--; + } +return 0; +} +#endif diff --git a/battle/battle.c b/battle/battle.c new file mode 100644 index 0000000..c1c414c --- /dev/null +++ b/battle/battle.c @@ -0,0 +1,11162 @@ +#include "version.h" +#include +#include +#include +#include "buf.h" +#include"object.h" +#include"char.h" +#include"char_base.h" +#include"char_data.h" +#include"battle.h" +#include"battle_event.h" +#include"battle_command.h" +#include"battle_ai.h" +#include"configfile.h" +#include"lssproto_serv.h" +#include"encount.h" +#include"enemy.h" +#include"handletime.h" +#include"readmap.h" +#include"pet_skill.h" +#include "npcutil.h" +#include "magic.h" +#include "npc_npcenemy.h" +#include "log.h" +#include "pet_skillinfo.h" +#include "anim_tbl.h" +#include "common.h" +#include "battle_magic.h" +#ifdef _Item_ReLifeAct +#include "item.h" +#endif +#include "correct_bug.h" +#ifdef _ALLBLUES_LUA +#include "mylua/function.h" +#include "mylua/mylua.h" +extern MY_Lua MYLua; +#endif +#ifdef _AUTO_PK +#include "npc_autopk.h" +#endif + +#ifdef _PROFESSION_SKILL // WON ADD ְҵ +#include "profession_skill.h" +#include "skill.h" +#endif + +extern char *DebugMainFunction; +//#define DANTAI +static int Total_BattleNum=0; +BATTLE *BattleArray; +int BATTLE_battlenum; +static int BATTLE_searchCnt = 0; + +#ifdef _PET_LIMITLEVEL //ANDY_ADD + void Pet_Check_Die( int petindex); +#endif +static int BATTLE_SearchTask( void ); +static int BATTLE_Battling( int battleindex ); + +#ifdef _Item_ReLifeAct + BOOL CHECK_ITEM_RELIFE( int battleindex, int toindex); +#endif +#ifdef _LOSE_FINCH_ + BOOL CHECK_PET_RELIFE( int battleindex, int petindex); +#endif +char szAllBattleString[BATTLE_STRING_MAX]; +#ifdef _OTHER_MAGICSTAUTS +void BATTLE_MagicStatusSeq( int charaindex ); +#endif + +//Terry 2001/11/28 +char szBattleString[512]; +char *pszBattleTop, + *pszBattleLast; + +char szBadStatusString[1024]; + +int gWeponType; +float gDamageDiv; +int gItemCrushRate = 400000; + +char afmwar[20480]; +char bfmwar[20480]; +char cfmwar[20480]; +char dfmwar[20480]; +char efmwar[20480]; +char ffmwar[20480]; +int afmwarnum = 0; +int bfmwarnum = 0; +int cfmwarnum = 0; +int dfmwarnum = 0; +int efmwarnum = 0; +int ffmwarnum = 0; +extern int autopkcnt; +int BoomerangVsTbl[4][5] = { + { 4+5*0,2+5*0,0+5*0,1+5*0,3+5*0 }, + { 4+5*1,2+5*1,0+5*1,1+5*1,3+5*1 }, + { 4+5*2,2+5*2,0+5*2,1+5*2,3+5*2 }, + { 4+5*3,2+5*3,0+5*3,1+5*3,3+5*3 }, + +}; +#ifdef _OFFLINE_SYSTEM +static int offlineAttack(int battleindex,int charaindex,int side) +{ + + + + BATTLE_ENTRY *pEntry = BattleArray[battleindex].Side[side].Entry; + int iNum[10] = {9,7,5,6,8,4,2,0,1,3}; + int i; + for( i = 0; i < 10; i ++ ){ + if( pEntry[iNum[i]].charaindex != -1 ){ + break; + } + } + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_ATTACK ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, iNum[i] + side * BATTLE_ENTRY_MAX); + int At_SoubiIndex = CHAR_getItemIndex( charaindex, CHAR_ARM ); + if( ITEM_CHECKINDEX( At_SoubiIndex ) == TRUE ) + { + if( ITEM_getInt( At_SoubiIndex, ITEM_TYPE ) == ITEM_BOOMERANG ){ + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_BOOMERANG ); +#ifdef _PETSKILL_BECOMEFOX + if( CHAR_getInt( charaindex, CHAR_BASEIMAGENUMBER)==101749 + || CHAR_getWorkInt( charaindex, CHAR_WORKFOXROUND ) != -1 ){ //DZС겻ʹû + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_NONE ); + } +#endif +#ifdef _PETSKILL_BECOMEPIG + if( CHAR_getInt( charaindex, CHAR_BECOMEPIG) > -1 ){// + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_ATTACK ); + } +#endif + } + } + CHAR_SETWORKINT_LOW( charaindex, CHAR_WORKBATTLECOM3, 1 ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + + return 1; +} + +static int offlineRecovery(int battleindex,int charaindex,int HP) +{ + + + int toNO = BATTLE_Index2No(battleindex, charaindex); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_S_OFFLINE_RECOVERY ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, toNO); + CHAR_SETWORKINT_LOW( charaindex, CHAR_WORKBATTLECOM3, HP ); + + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + + return 1; +} + + +void OffLineCommand(int battleindex,int charaindex,int side) +{ + side = 1 - side; //test + if(CHAR_getInt( charaindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER){ + if(CHAR_getInt(charaindex,CHAR_HP)charfunctable[CHAR_BATTLEPROPERTY].string, + sizeof( ch->charfunctable[CHAR_BATTLEPROPERTY]), "");//ս + CHAR_constructFunctable( charaindex); + } +#endif + +#ifdef _PROFESSION_SKILL // WON ADD ְҵ + CHAR_setWorkInt( charaindex, CHAR_MYSKILLHIT, 0 ); + CHAR_setWorkInt( charaindex, CHAR_WORK_P_DUCK, 0 ); + CHAR_setWorkInt( charaindex, CHAR_WORKMOD_P_DUCK, 0 ); + CHAR_setWorkInt( charaindex, CHAR_WORK_WEAPON, 0 ); // ר + + // 翹 + for( i=0; i<3; i++) + CHAR_setWorkInt( charaindex, CHAR_WORK_F_RESIST+i, 0/*CHAR_getInt( charaindex, PROFESSION_FIRE_R+i )*/ ); + +#endif + +#ifdef _PETSKILL_BECOMEPIG + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER ) + { + for( i =0; i < CHAR_MAXPETHAVE; i++){ + int pindex = CHAR_getCharPet( charaindex, i ); + if( !CHAR_CHECKINDEX( pindex ) ) + continue; + CHAR_setInt( pindex, CHAR_BECOMEPIG, -1 ); + } + } +#endif + +} + +int BATTLE_getTopBattle( int battleindex ) +{ + + BATTLE *pBattleTop; + + if( BATTLE_CHECKINDEX( battleindex ) == FALSE ) return -1; + + pBattleTop = &BattleArray[battleindex]; + + while( pBattleTop != NULL ){ + pBattleTop = BattleArray[battleindex].pBefore; + } + + if( BATTLE_CHECKINDEX( pBattleTop->battleindex ) == FALSE ){ + return -1; + }else{ + return pBattleTop->battleindex; + } +} + +static int BATTLE_getBattleFieldNo( int floor, int x, int y ) +{ + int tile[2], map[3], iRet; + if( !MAP_getTileAndObjData( floor, x, y, &tile[0], &tile[1] ) ) + return FALSE; + map[0] = MAP_getImageInt( tile[0], MAP_BATTLEMAP ); + map[1] = MAP_getImageInt( tile[0], MAP_BATTLEMAP2 ); + map[2] = MAP_getImageInt( tile[0], MAP_BATTLEMAP3 ); + iRet = map[RAND( 0, 2 )]; + return iRet; +} + +void BATTLE_BadStatusString( int defNo, int status ) +{ + char szWork[256]; + if( status < 1 || status >= BATTLE_ST_END ){ + status = 0; + } + sprintf( szWork, "BM|%X|%X|", defNo, status ); + strncat( szBadStatusString, szWork, sizeof( szBadStatusString ) ); +} + + + +#ifdef _ATTACK_MAGIC + +static int CharTableIdx[20][2] = +{ + { 3 , 2 } , { 3 , 1 } , { 3 , 3 } , { 3 , 0 } , { 3 , 4 } , + { 2 , 2 } , { 2 , 1 } , { 2 , 3 } , { 2 , 0 } , { 2 , 4 } , + { 0 , 2 } , { 0 , 1 } , { 0 , 3 } , { 0 , 0 } , { 0 , 4 } , + { 1 , 2 } , { 1 , 1 } , { 1 , 3 } , { 1 , 0 } , { 1 , 4 } + +}; + +typedef int ( *FUNCSORTLOC )( const void* , const void* ); + +static int SortLoc( const int *pEle1 , const int *pEle2 ) +{ + int ele1basex , ele1basey; + int ele2basex , ele2basey; + + ele1basex = CharTableIdx[*pEle1][1]; + ele1basey = CharTableIdx[*pEle1][0]; + ele2basex = CharTableIdx[*pEle2][1]; + ele2basey = CharTableIdx[*pEle2][0]; + + if( *pEle1 >= 10 ){ + if( ele1basey != ele2basey ) + return ( ele1basey - ele2basey ); + return ( ele1basex - ele2basex ); + }else{ // · + if( ele1basey != ele2basey ) + return ( ele2basey - ele1basey ); + return ( ele2basex - ele1basey ); + } + return 0; +} +#endif + +int BATTLE_MultiList( int battleindex, int toNo, int ToList[] ) +{ + int j , i , cnt=0,nLife = 0,nLifeArea[10]; +#ifdef _ATTACK_MAGIC + // ˹ + if(0 <= toNo && toNo <= 19){ + memset(nLifeArea,-1,sizeof(nLifeArea)); + // · + if(toNo >= 0 && toNo <= 9){ + for(i=0;i<10;i++){ + // ȷŵ,¼ŵ˵ĺ + if(BATTLE_TargetCheck(battleindex,i) == TRUE) nLifeArea[nLife++] = i; + } + } + // Ϸ + if(toNo >= 10 && toNo <= 19){ + for(i=10;i<20;i++){ + // ȷŵ,¼ŵ˵ĺ + if(BATTLE_TargetCheck(battleindex,i) == TRUE) nLifeArea[nLife++] = i; + } + } + + // ȫ(Ȼ̫,..) + if(nLife == 0){ + //print("\nAll die!!"); + return -1; + }else{ + // ĶѾս + if(BATTLE_TargetCheck(battleindex,toNo) == FALSE) + // һֻ + while((toNo = nLifeArea[rand()%10]) == -1); + } + ToList[0] = toNo; + ToList[1] = -1; + cnt = 1; + } + // һй + else if( TARGET_SIDE_0_B_ROW == toNo ){ + for( j = 0 , i = 0 ; i < SIDE_OFFSET / 2 ; i++ ){ + if( TRUE == BATTLE_TargetCheck( battleindex , i ) ){ + ToList[j] = i; + j++; + } + } + ToList[j] = -1; + cnt = j; + // һŶû˿Դ + if(j == 0){ + // ǰһ + for( j = 0 , i = SIDE_OFFSET / 2 ; i < SIDE_OFFSET ; i++ ){ + if( TRUE == BATTLE_TargetCheck( battleindex , i ) ){ + ToList[j] = i; + j++; + } + } + ToList[j] = -1; + cnt = j; + // ȫ + if(j == 0) return -1; + toNo = TARGET_SIDE_0_F_ROW; + } + } + // ǰһй + else if( TARGET_SIDE_0_F_ROW == toNo ) + { + for( j = 0 , i = SIDE_OFFSET / 2 ; i < SIDE_OFFSET ; i++ ) + { + if( TRUE == BATTLE_TargetCheck( battleindex , i ) ) + { + ToList[j] = i; + j++; + } + } + ToList[j] = -1; + cnt = j; + // һŶû˿Դ + if(j == 0) + { + // һ + for( j = 0 , i = 0 ; i < SIDE_OFFSET / 2 ; i++ ) + { + if( TRUE == BATTLE_TargetCheck( battleindex , i ) ) + { + ToList[j] = i; + j++; + } + } + ToList[j] = -1; + cnt = j; + // ȫ + if(j == 0) return -1; + toNo = TARGET_SIDE_0_B_ROW; + } + } + // һй + else if( TARGET_SIDE_1_B_ROW == toNo ) + { + for( j = 0 , i = SIDE_OFFSET ; i < SIDE_OFFSET + SIDE_OFFSET / 2 ; i++ ) + { + if( TRUE == BATTLE_TargetCheck( battleindex , i ) ) + { + ToList[j] = i; + j++; + } + } + ToList[j] = -1; + cnt = j; + // һŶû˿Դ + if(j == 0) + { + // ǰһ + for( j = 0 , i = SIDE_OFFSET + SIDE_OFFSET / 2 ; i < SIDE_OFFSET * 2 ; i++ ) + { + if( TRUE == BATTLE_TargetCheck( battleindex , i ) ) + { + ToList[j] = i; + j++; + } + } + ToList[j] = -1; + cnt = j; + // ȫ + if(j == 0) return -1; + toNo = TARGET_SIDE_1_F_ROW; + } + } + // ǰһй + else if( TARGET_SIDE_1_F_ROW == toNo ) + { + for( j = 0 , i = SIDE_OFFSET + SIDE_OFFSET / 2 ; i < SIDE_OFFSET * 2 ; i++ ) + { + if( TRUE == BATTLE_TargetCheck( battleindex , i ) ) + { + ToList[j] = i; + j++; + } + } + ToList[j] = -1; + cnt = j; + // һŶû˿Դ + if(j == 0) + { + // һ + for( j = 0 , i = SIDE_OFFSET ; i < SIDE_OFFSET + SIDE_OFFSET / 2 ; i++ ) + { + if( TRUE == BATTLE_TargetCheck( battleindex , i ) ) + { + ToList[j] = i; + j++; + } + } + ToList[j] = -1; + cnt = j; + // ȫ + if(j == 0) return -1; + toNo = TARGET_SIDE_1_B_ROW; + } + } + // ·й + else if( TARGET_SIDE_0 == toNo ) + { + //print("BATTLE_MultiList(20)toNo->%d\n",toNo); + for( j = 0 , i = 0 ; i < SIDE_OFFSET ; i++ ) + { + if( TRUE == BATTLE_TargetCheck( battleindex , i ) ) + { + ToList[j] = i; + j++; + } + } + + ToList[j] = -1; + cnt = j; + } + // Ϸй + else if( toNo == TARGET_SIDE_1 ) + { + for( j = 0 , i = SIDE_OFFSET ; i < SIDE_OFFSET * 2 ; i++ ) + { + if( TRUE == BATTLE_TargetCheck( battleindex , i ) ) + { + ToList[j] = i; + j++; + } + } + + ToList[j] = -1; + cnt = j; + } + // ˹ + else if( toNo == TARGET_ALL ){ +#ifdef _FIX_ARRAYBUG + for( j = 0 , i = 0 ; i < SIDE_OFFSET * 2 ; i++ ){ +#else + for( j = 0 , i = 0 ; i < SIDE_OFFSET * 2 ; i++ , j++ ) { +#endif + if( TRUE == BATTLE_TargetCheck( battleindex , i ) ){ + ToList[j] = i; + j++; + } + } + ToList[i] = -1; + cnt = j; + // won add ǰŹ + }else if( toNo == TARGER_THROUGH ){ + int toNo2=-1, count=0; + + if(BATTLE_TargetCheck(battleindex,toNo) != FALSE){ + ToList[count] = toNo; + count++; + cnt = count; + } + + if( toNo < (SIDE_OFFSET/2) ) toNo2= toNo + (SIDE_OFFSET/2); + else if( toNo < (SIDE_OFFSET) ) toNo2= toNo - (SIDE_OFFSET/2); + else if( toNo < (SIDE_OFFSET*1.5) ) toNo2= toNo + (SIDE_OFFSET/2); + else if( toNo < (SIDE_OFFSET*2) ) toNo2= toNo - (SIDE_OFFSET/2); + + if(BATTLE_TargetCheck(battleindex,toNo2) != FALSE){ + ToList[count] = toNo2; + count++; + cnt = count; + } + }else{ + ToList[0] = toNo; + ToList[1] = -1; + cnt = 1; + } + + if( cnt > 1 ) qsort( ToList , cnt , sizeof( ToList[0] ) , ( FUNCSORTLOC )SortLoc ); + return toNo; + +#else + if( 0 <= toNo && toNo <= 19 ) + { + if( BATTLE_TargetCheck( battleindex, toNo ) == TRUE ) + { + ToList[0] = toNo; + ToList[1] = -1; + cnt = 1; + } + else + { + ToList[0] = -1; + ToList[1] = -1; + cnt = 0; + } + } + else if( toNo == TARGET_SIDE_0 ) + { + for( j = 0, i = 0; i < SIDE_OFFSET; i ++) + { + if( BATTLE_TargetCheck( battleindex, i ) == TRUE ) + { + ToList[j] = i; + j ++ ; + } + } + ToList[j] = -1; + cnt = j; + } + else if( toNo == TARGET_SIDE_1 ) + { + for( j = 0, i = SIDE_OFFSET; i < SIDE_OFFSET*2; i ++ ) + { + if( BATTLE_TargetCheck( battleindex, i ) == TRUE ) + { + ToList[j] = i; + j ++ ; + } + } + ToList[j] = -1; + cnt = j; + } + else if( toNo == TARGET_ALL ){ + for( j = 0, i = 0; i < SIDE_OFFSET*2; i ++, j ++ ){ + if( BATTLE_TargetCheck( battleindex, i ) == TRUE ){ + ToList[j] = i; + j ++ ; + } + } + ToList[i] = -1; + cnt = j; + } + else + { + ToList[0] = toNo; + ToList[1] = -1; + cnt = 1; + } + + return 1; +#endif +} + +void BATTLE_MultiListDead( int battleindex, int toNo, int ToList[] ) +{ + int j, i; + if( 0 <= toNo && toNo <= 19 ){ + if( BATTLE_TargetCheckDead( battleindex, toNo ) == TRUE ){ + ToList[0] = toNo; + ToList[1] = -1; + }else{ + ToList[0] = -1; + ToList[1] = -1; + } + }else + if( toNo == TARGET_SIDE_0 ){ + for( j = 0, i = 0; i < SIDE_OFFSET; i ++){ + if( BATTLE_TargetCheckDead( battleindex, i ) == TRUE ){ + ToList[j] = i; + j ++ ; + } + } + ToList[j] = -1; + }else + if( toNo == TARGET_SIDE_1 ){ + for( j = 0, i = SIDE_OFFSET; i < SIDE_OFFSET*2; i ++ ){ + if( BATTLE_TargetCheckDead( battleindex, i ) == TRUE ){ + ToList[j] = i; + j ++ ; + } + } + ToList[j] = -1; + }else{ + if( toNo == TARGET_ALL ){ +#ifdef _FIX_ARRAYBUG + for( j = 0, i = 0; i < SIDE_OFFSET*2; i ++){ +#else + for( j = 0, i = 0; i < SIDE_OFFSET*2; i ++, j ++ ){ +#endif + if( BATTLE_TargetCheckDead( battleindex, i ) == TRUE ){ + ToList[j] = i; + j ++ ; + } + } +#ifdef _FIX_ITEMRELIFE // WON ADD + ToList[j] = -1; +#else + ToList[i] = -1; +#endif + }else{ + ToList[0] = toNo; + ToList[1] = -1; + } + } +} + +BOOL BATTLE_IsThrowWepon( int itemindex){ + int itemtype; + if( ITEM_CHECKINDEX( itemindex ) == FALSE ){ + return FALSE; + } + itemtype = ITEM_getInt( itemindex, ITEM_TYPE ); + if( itemtype == ITEM_BOOMERANG + || itemtype == ITEM_BOW + || itemtype == ITEM_BREAKTHROW + || itemtype == ITEM_BOUNDTHROW ){ + return TRUE; + }else{ + return FALSE; + } +} + +int BATTLE_ClearGetExp( int charaindex ) +{ + int i, pindex; + + if( CHAR_CHECKINDEX( charaindex ) == FALSE ){ + return BATTLE_ERR_CHARAINDEX; + } + CHAR_setWorkInt( charaindex, CHAR_WORKGETEXP, 0 ); + for( i = 0; i < CHAR_MAXPETHAVE; i ++ ){ + pindex = CHAR_getCharPet( charaindex, i ); + if( CHAR_CHECKINDEX( pindex ) == FALSE )continue; + CHAR_setWorkInt( pindex, CHAR_WORKGETEXP, 0 ); + } + + + return 0; +} + +INLINE void _BATTLE_ExitAll( char *file, int line, int battleindex) +{ + int j,i, charaindex; + for( j = 0; j < 2; j ++ ){ + for( i = 0; i < BATTLE_ENTRY_MAX; i ++ ){ + charaindex = BattleArray[battleindex].Side[j].Entry[i].charaindex; + if( CHAR_CHECKINDEX( charaindex ) == FALSE )continue; + BATTLE_Exit( charaindex, battleindex ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, + BATTLE_CHARMODE_NONE ); + } + } +} + +void BATTLE_AllCharaFinishSet( int battleindex ) +{ + int j,i, charaindex; + for( j = 0; j < 2; j ++ ){ + for( i = 0; i < BATTLE_ENTRY_MAX; i ++ ){ + charaindex = BattleArray[battleindex].Side[j].Entry[i].charaindex; + if( CHAR_CHECKINDEX( charaindex ) == FALSE )continue; + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, + BATTLE_CHARMODE_FINAL ); + } + } +} + +BOOL BATTLE_IsCharge( int charaindex ) +{ + int com; + com = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM1 ); + if( com == BATTLE_COM_S_CHARGE + || com == BATTLE_COM_S_EARTHROUND1 + || com == BATTLE_COM_S_EARTHROUND0 +#ifdef _PROFESSION_ADDSKILL + || CHAR_getWorkInt( charaindex, CHAR_DOOMTIME ) > 0 +#endif + ){ + return TRUE; + } + return FALSE; +} + +void BATTLE_AllCharaCWaitSet( int battleindex ) +{ + int j,i, charaindex; + for( j = 0; j < 2; j ++ ){ + for( i = 0; i < BATTLE_ENTRY_MAX; i ++ ){ + charaindex = BattleArray[battleindex].Side[j].Entry[i].charaindex; + if( CHAR_CHECKINDEX( charaindex ) == FALSE )continue; + + if( BATTLE_IsCharge( charaindex ) == TRUE ){ + }else{ + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, + BATTLE_COM_NONE ); + } + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, + BATTLE_CHARMODE_C_WAIT ); + } + } +} + +void BATTLE_AllCharaWatchWaitSet( int battleindex ) +{ + int i, charaindex; + for( i = 0; i < BATTLE_ENTRY_MAX; i ++ ){ + charaindex = BattleArray[battleindex].Side[0].Entry[i].charaindex; + if( CHAR_CHECKINDEX( charaindex ) == FALSE )continue; + + if( CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE ) + != BATTLE_CHARMODE_WATCHINIT + ){ + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, + BATTLE_CHARMODE_C_WAIT ); + } + } +} + +void BATTLE_SurpriseSet( + int battleindex, + int side +) +{ + BATTLE_ENTRY *pEntry; + int i, charaindex; + + pEntry = BattleArray[battleindex].Side[side].Entry; + + for( i = 0; i < BATTLE_ENTRY_MAX; i ++ ){ + charaindex = pEntry[i].charaindex; + if( CHAR_CHECKINDEX( charaindex ) == FALSE )continue; + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE ) == CHAR_TYPEPET ){ + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_NONE ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + } + } + + +} + +BOOL BATTLE_initBattleArray( + int battlenum +) +{ + + int i; + BATTLE_battlenum = battlenum; + + BattleArray = allocateMemory( sizeof( BATTLE ) * BATTLE_battlenum ); + if( BattleArray == NULL ) return FALSE; + for( i = 0 ; i < BATTLE_battlenum ; i ++ ){ + memset( &BattleArray[i], 0 , sizeof( BATTLE )); + } + print(" %4.2f MB ռ...", ((float)sizeof( Char )*BATTLE_battlenum)/1024.0/1024.0); + strcpy(afmwar,"-1,"); + strcpy(bfmwar,"-1,"); + strcpy(cfmwar,"-1,"); + strcpy(dfmwar,"-1,"); + return TRUE; + +} + +static void EntryInit( BATTLE_ENTRY *pEntry ){ + int i; + pEntry->charaindex = -1; + pEntry->bid = -1; + pEntry->escape = 0; + for( i = 0; i < GETITEM_MAX; i ++ ){ + pEntry->getitem[i] = -1; + } +} + +int BATTLE_CreateBattle( int charaindex ) +{ + int battleindex, i, j; + BATTLE *pBattle; + battleindex = BATTLE_SearchTask( ); + // NUKE 0701 + if( battleindex < 0 )return -1; + pBattle = &BattleArray[battleindex]; + // NUKE 0701 + if (pBattle==NULL) return -1; + pBattle->use = TRUE; + pBattle->mode = BATTLE_MODE_INIT; + pBattle->turn = 0; + pBattle->dpbattle = 0; + pBattle->norisk = 0; + pBattle->flg = 0; + pBattle->field_att = BATTLE_ATTR_NONE; + pBattle->att_count = 0; + for( j = 0; j < 2; j ++ ){ + for( i = 0; i < BATTLE_ENTRY_MAX; i ++ ){ + EntryInit( &pBattle->Side[j].Entry[i] ); + } + } + for( i = 0; i < BATTLE_ENTRY_MAX*2; i ++ ){ + pBattle->iEntryBack[i] = -1; + pBattle->iEntryBack2[i] = -1; + } + pBattle->WinFunc = NULL; + pBattle->pNext = NULL; + pBattle->pBefore = NULL; + pBattle->battleindex = battleindex; + Total_BattleNum ++; +#ifdef _BATTLECOMMAND_TIME + pBattle->PartTime = 0; +#endif +#ifdef _PROFESSION_ADDSKILL + // +/* pBattle->ice_count = 0; + for( i = 0; i < 20; i ++ ){ + pBattle->ice_bout[i]=0; + pBattle->ice_use[i]=FALSE; + pBattle->ice_toNo[i]=0; + pBattle->ice_level[i]=0; + pBattle->ice_array[i]=0; + pBattle->ice_attackNo[i]=0; + pBattle->ice_charaindex[i]=-1; + }*/ +#endif + pBattle->floor = CHAR_getInt(charaindex,CHAR_FLOOR); + time_t timep; + time(&timep); + pBattle->battletime = timep; + return battleindex; +} + +static int BATTLE_SearchTask( void ) +{ + int i, j; + i = BATTLE_searchCnt; + for( j = 0; j < BATTLE_battlenum; j ++ ){ + if( i >= BATTLE_battlenum ) i = 0; + if( BattleArray[i].use == FALSE ){ + if(i>=getBattlenum()) return -1; + BATTLE_searchCnt = i + 1; + return i; + } + i ++; + } + return -1; +} + +void BATTLE_DeleteItem( int battleindex ) +{ + int i, j, k; + BATTLE_ENTRY *pEntry; + + for( j = 0; j < 2; j ++ ){ + for( i = 0; i < BATTLE_ENTRY_MAX; i ++ ){ + pEntry = &BattleArray[battleindex].Side[j].Entry[i]; + for( k = 0; k < GETITEM_MAX; k ++ ){ + if( pEntry->getitem[k] >= 0 ){ +// print( "// Ѱ(ȥ)(%d),(%s)\n", pEntry->getitem[k], ITEM_getAppropriateName(pEntry->getitem[k]) ); + ITEM_endExistItemsOne( pEntry->getitem[k] ); + } + } + } + } +} + + +int BATTLE_DeleteBattle( + int battleindex +) +{ + int i, j; + BATTLE *pBattle; + if( BATTLE_CHECKINDEX( battleindex ) == FALSE ){ + //fprint( "err:battle index error\n" ); + return BATTLE_ERR_BATTLEINDEX; + } + if( BATTLE_WatchUnLink( battleindex ) == FALSE ){ + //fprint( "err:battle link \n" ); + } + + pBattle = &BattleArray[battleindex]; + pBattle->use = FALSE; + pBattle->mode = BATTLE_MODE_NONE; + if(pBattle->type == BATTLE_TYPE_P_vs_P){ + if(pBattle->floor == 1042){ + char atmpbuf[64]; + sprintf(atmpbuf,",%d,",battleindex); + char *newafmwar = replace(afmwar,atmpbuf,","); + strcpy(afmwar,newafmwar); + if(afmwarnum>0) + afmwarnum--; + }else if(pBattle->floor == 2032){ + char btmpbuf[64]; + sprintf(btmpbuf,",%d,",battleindex); + char *newbfmwar = replace(bfmwar,btmpbuf,","); + strcpy(bfmwar,newbfmwar); + if(bfmwarnum>0) + bfmwarnum--; + }else if(pBattle->floor == 3032){ + char ctmpbuf[64]; + sprintf(ctmpbuf,",%d,",battleindex); + char *newcfmwar = replace(cfmwar,ctmpbuf,","); + strcpy(cfmwar,newcfmwar); + if(cfmwarnum>0) + cfmwarnum--; + }else if(pBattle->floor == 4032){ + char dtmpbuf[64]; + sprintf(dtmpbuf,",%d,",battleindex); + char *newdfmwar = replace(dfmwar,dtmpbuf,","); + strcpy(dfmwar,newdfmwar); + if(dfmwarnum>0) + dfmwarnum--; + }else if(pBattle->floor == 20000){ + char etmpbuf[64]; + sprintf(etmpbuf,",%d,",battleindex); + char *newefmwar = replace(efmwar,etmpbuf,","); + strcpy(efmwar,newefmwar); + if(efmwarnum>0) + efmwarnum--; + }else if(pBattle->floor == 51000){ + char ftmpbuf[64]; + sprintf(ftmpbuf,",%d,",battleindex); + char *newffmwar = replace(ffmwar,ftmpbuf,","); + strcpy(ffmwar,newffmwar); + if(ffmwarnum>0) + ffmwarnum--; + } + } + pBattle->floor = -1; + pBattle->battletime = 0; + BATTLE_DeleteItem( battleindex ); + + for( j = 0; j < 2; j ++ ){ + for( i = 0; i < BATTLE_ENTRY_MAX; i ++ ){ + EntryInit( &pBattle->Side[j].Entry[i] ); + } + } + Total_BattleNum--; + return 0; +} + + +int BATTLE_No2Index( + int battleindex, + int bid +) +{ + BATTLE_ENTRY *pEntry; + + if( BATTLE_CHECKINDEX( battleindex ) == FALSE )return -1; + if( BATTLE_CHECKNO( bid ) == FALSE )return -1; + + if( bid >= 10 ){ + pEntry = BattleArray[battleindex].Side[1].Entry; + bid -= SIDE_OFFSET; + }else{ + pEntry = BattleArray[battleindex].Side[0].Entry; + } + if( CHAR_CHECKINDEX( pEntry[bid].charaindex ) == FALSE )return -1; + + return pEntry[bid].charaindex; + +} +#ifdef _Item_ReLifeAct +int BATTLE_getBattleDieIndex( int battleindex, int bid ) +{ + BATTLE_ENTRY *pEntry; + + if( BATTLE_CHECKINDEX( battleindex ) == FALSE )return -1; + if( BATTLE_CHECKNO( bid ) == FALSE )return -1; + + if( bid >= 10 ){ + pEntry = BattleArray[battleindex].Side[1].Entry; + bid -= SIDE_OFFSET; + }else{ + pEntry = BattleArray[battleindex].Side[0].Entry; + } + if( CHAR_CHECKINDEX( pEntry[bid].charaindex ) == FALSE )return -1; + if( pEntry[bid].flg & BENT_FLG_ULTIMATE ) return -1; + + return pEntry[bid].charaindex; + +} +#endif + +#ifdef _PROFESSION_ADDSKILL +BOOL BATTLE_BattleUltimate( int battleindex, int bid ) //λDǷ񱻴 +{ + BATTLE_ENTRY *pEntry; + if( BATTLE_CHECKINDEX( battleindex ) == FALSE )return FALSE; + if( BATTLE_CHECKNO( bid ) == FALSE )return FALSE; + if( bid >= 10 ){ + pEntry = BattleArray[battleindex].Side[1].Entry; + bid -= SIDE_OFFSET; + }else{ + pEntry = BattleArray[battleindex].Side[0].Entry; + } + if( pEntry[bid].flg & BENT_FLG_ULTIMATE ) return TRUE; + else return TRUE; +} +#endif + +int BATTLE_Index2No( + int battleindex, + int charaindex +) +{ + BATTLE_ENTRY *pEntry; + int i, j; + + if( BATTLE_CHECKINDEX( battleindex ) == FALSE )return -1; + if( CHAR_CHECKINDEX( charaindex ) == FALSE )return -1; + + for( j = 0; j < 2; j ++ ){ + pEntry = BattleArray[battleindex].Side[j].Entry; + for( i = 0; i < BATTLE_ENTRY_MAX; i ++ ){ + if( pEntry[i].charaindex == charaindex ){ + return i + j * SIDE_OFFSET; + } + } + } + + return -1; + +} + + +char *BATTLE_CharTitle( int charaindex ) +{ + char *pName; + static char Len0Buff[2] = ""; + + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE ) == CHAR_TYPEPET ){ + pName = Len0Buff; + }else{ + pName = CHAR_getChar( charaindex, CHAR_OWNTITLE ); + if( pName[0] == 0 ){ + pName = Len0Buff; + } + } + return pName; +} + + +int BATTLE_CharaBackUp( int battleindex ) +{ + int i, j, k, charaindex; + BATTLE *pBattle; + + if( BATTLE_CHECKINDEX( battleindex ) == FALSE ){ + return BATTLE_ERR_BATTLEINDEX; + } + + pBattle = &BattleArray[battleindex]; + k = 0; + + for( j = 0; j < 2; j ++ ){ + k = j * SIDE_OFFSET; + for( i = 0; i < BATTLE_ENTRY_MAX/2; i ++ ){ + charaindex = pBattle->Side[j].Entry[i].charaindex; + if( CHAR_CHECKINDEX( charaindex ) == TRUE + && CHAR_getInt( charaindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER + ){ + pBattle->iEntryBack[k] = pBattle->Side[j].Entry[i].charaindex; + pBattle->iEntryBack2[k] = pBattle->Side[j].Entry[i].charaindex; + }else{ + pBattle->iEntryBack[k] = -1; + pBattle->iEntryBack2[k] = -1; + } + k ++; + } + } + + return 0; +} + + + + +int BATTLE_NewEntry( + int charaindex, + int battleindex, + int side +) +{ + BATTLE_ENTRY *pEntry; + BATTLE *pBattle; + int i, iEntryMax, iEntryFirst; + + if( BATTLE_CHECKSIDE( side ) == FALSE )return BATTLE_ERR_PARAM; + if( BATTLE_CHECKINDEX( battleindex ) == FALSE )return BATTLE_ERR_BATTLEINDEX; + if( CHAR_CHECKINDEX( charaindex ) == FALSE )return BATTLE_ERR_CHARAINDEX; + + pBattle = &BattleArray[battleindex]; + + if( pBattle->use == FALSE )return BATTLE_ERR_NOUSE; + + if( side < 0 || side > 1 ){ + return BATTLE_ERR_PARAM; + } +#ifdef _PET_BUG + if(CHAR_getInt( charaindex, CHAR_WHICHTYPE )==CHAR_TYPEPLAYER){ + int petarray = CHAR_getInt( charaindex, CHAR_DEFAULTPET); + if(petarray>-1){ + int petindex = CHAR_getCharPet( charaindex, petarray); + if(CHAR_getInt(petindex,CHAR_VITAL)>=getPetPoint(0)*20 || CHAR_getInt(petindex,CHAR_STR)>=getPetPoint(1)*80 || CHAR_getInt(petindex,CHAR_TOUGH)>=getPetPoint(2)*80 || CHAR_getInt(petindex,CHAR_DEX)>=getPetPoint(3)*100) + return BATTLE_ERR_PARAM; + } + } +#endif + switch( CHAR_getInt( charaindex, CHAR_WHICHTYPE ) ){ + int work; + + case CHAR_TYPEPLAYER: + if( pBattle->Side[side].type != BATTLE_S_TYPE_PLAYER ){ + return BATTLE_ERR_TYPE; + } + iEntryFirst = 0; + iEntryMax = BATTLE_PLAYER_MAX; + break; + case CHAR_TYPEENEMY: + if( pBattle->Side[side].type != BATTLE_S_TYPE_ENEMY ){ + return BATTLE_ERR_TYPE; + } + iEntryFirst = 0; + iEntryMax = BATTLE_ENTRY_MAX; + break; + case CHAR_TYPEPET: + if( pBattle->Side[side].type != BATTLE_S_TYPE_PLAYER ){ + return BATTLE_ERR_TYPE; + } + + work = CHAR_getWorkInt( charaindex, CHAR_WORKPLAYERINDEX ); + pEntry = pBattle->Side[side].Entry; + + work = BATTLE_Index2No( battleindex, work ); + work -= side * SIDE_OFFSET; + work += 5; + iEntryFirst = work; + iEntryMax = work+1; + break; +#ifdef _PLAYER_NPC + case CHAR_TYPEPLAYERNPC: + iEntryFirst = 0; + iEntryMax = BATTLE_ENTRY_MAX; + break; + + case CHAR_TYPEPLAYERPETNPC: + work = CHAR_getWorkInt( charaindex, CHAR_WORKPLAYERINDEX ); + pEntry = pBattle->Side[side].Entry; + + work = BATTLE_Index2No( battleindex, work ); + work -= side * SIDE_OFFSET; + work += 5; + iEntryFirst = work; + iEntryMax = work+1; + break; +#endif + default: + //print( "(%s)(%d)\n", + //CHAR_getUseName( charaindex ), + //CHAR_getInt( charaindex, CHAR_WHICHTYPE ) ); + return BATTLE_ERR_TYPE; + } + + + pEntry = pBattle->Side[side].Entry; + + for( i = iEntryFirst; i < iEntryMax; i ++ ){ + if( pEntry[i].charaindex == -1 )break; + } + + if( i == iEntryMax ){ + return BATTLE_ERR_ENTRYMAX; + } + + EntryInit( &pEntry[i] ); + + pEntry[i].charaindex = charaindex; + + pEntry[i].bid = i + side * SIDE_OFFSET; + + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEINDEX, + battleindex ); + + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, + BATTLE_CHARMODE_INIT ); + CHAR_setWorkInt( charaindex, CHAR_WORKDBATTLEESCAPE, + 0 ); + // shan 2001/12/27 Begin + { + int fd; + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE)==CHAR_TYPEPLAYER ){ + fd = CHAR_getWorkInt( charaindex, CHAR_WORKFD); + CONNECT_SetBattleRecvTime( fd, &NowTime); + } + } + // End + + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLESIDE, side ); + + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEFLG, 0 ); + + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, -1 ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, -1 ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM3, -1 ); + + CHAR_setWorkInt( charaindex, CHAR_WORKMODATTACK, 0 ); + CHAR_setWorkInt( charaindex, CHAR_WORKMODDEFENCE, 0 ); + CHAR_setWorkInt( charaindex, CHAR_WORKMODQUICK, 0 ); + + CHAR_setWorkInt( charaindex, CHAR_WORKDAMAGEABSROB, 0 ); + CHAR_setWorkInt( charaindex, CHAR_WORKDAMAGEREFLEC, 0 ); + CHAR_setWorkInt( charaindex, CHAR_WORKDAMAGEVANISH, 0 ); + + + CHAR_setWorkInt( charaindex, CHAR_WORKMODCAPTURE, 0 ); + + CHAR_setFlg( charaindex, CHAR_ISATTACKED, 1 ); + + BATTLE_BadStatusAllClr( charaindex ); + + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEWATCH, 0 ); + +#ifdef _PROFESSION_SKILL // WON ADD ְҵ + CHAR_setWorkInt( charaindex, CHAR_WORKTRAP, 0 ); // + BATTLE_ProfessionStatus_init( battleindex, charaindex ); +#endif + +#ifdef _PETSKILL_ACUPUNCTURE + CHAR_setWorkInt( charaindex, CHAR_WORKACUPUNCTURE, 0 );//Ƥ +#endif + +#ifdef _PETSKILL_RETRACE + CHAR_setWorkInt( charaindex, CHAR_WORKRETRACE, 0 );//׷ +#endif + +#ifdef _PETSKILL_BECOMEFOX //ĻʱΪ-1 + CHAR_setWorkInt( charaindex, CHAR_WORKFOXROUND, -1 ); +#endif +#ifdef _PROFESSION_ADDSKILL + // + CHAR_setWorkInt( charaindex, CHAR_WORKFIXEARTHAT_BOUNDARY, 0 ); + CHAR_setWorkInt( charaindex, CHAR_WORKFIXWATERAT_BOUNDARY, 0 ); + CHAR_setWorkInt( charaindex, CHAR_WORKFIXFIREAT_BOUNDARY, 0 ); + CHAR_setWorkInt( charaindex, CHAR_WORKFIXWINDAT_BOUNDARY, 0 ); + CHAR_setWorkInt( charaindex, CHAR_DOOMTIME, 0 );//ĩռ + CHAR_setWorkInt( charaindex, CHAR_WORK_com1, 0 ); + CHAR_setWorkInt( charaindex, CHAR_WORK_toNo, 0 ); + CHAR_setWorkInt( charaindex, CHAR_WORK_mode, 0 ); + CHAR_setWorkInt( charaindex, CHAR_WORK_skill_level, 0 ); + CHAR_setWorkInt( charaindex, CHAR_WORK_array, 0 ); +#endif + return 0; +} + +INLINE int _BATTLE_Exit( char *file, int line, int charaindex ,int battleindex) +{ + CHAR_setWorkInt(charaindex,CHAR_WORKBATTLEREVERSE,0); +#ifdef _NPCENEMY_1 + CHAR_setWorkInt(charaindex,CHAR_WORKBATTLEHELP,0); +#endif +#ifdef _WARNPC_CTRL + CHAR_setWorkInt(charaindex,CHAR_WORKNPCENEMYBATTLETIME,0); + CHAR_setWorkInt(charaindex,CHAR_WORKNPCBATTLESAMEIP,0); +#endif +#ifdef _BATTLEEND_FIX + if(getBattleEndMode()==1){ + if( CHAR_getWorkInt( charaindex, CHAR_WORKPARTYMODE ) + != CHAR_PARTY_CLIENT ){ + int myfloor=CHAR_getInt(charaindex,CHAR_FLOOR); + if(myfloor==getBattleFloor(1) || + myfloor==getBattleFloor(2) || + myfloor==getBattleFloor(3) || + myfloor==getBattleFloor(4) || + myfloor==getBattleFloor(5) || + myfloor==1042 || + myfloor==2032 || + myfloor==3032 || + myfloor==4032){ + time_t timep; + struct tm *p; + time(&timep); + p=localtime(&timep); /*ȡõʱ*/ + timep=mktime(p); + CHAR_setWorkInt(charaindex,CHAR_WORKBALLTELENDTIME,timep); + } + } + } +#endif + BATTLE_ENTRY *pEntry; + int i, j, k; + BATTLE *pBattle; + char szPet[32]; + if( CHAR_CHECKINDEX( charaindex ) == FALSE )return BATTLE_ERR_CHARAINDEX; + if( BATTLE_CHECKINDEX( battleindex ) == FALSE ){ + return BATTLE_ERR_BATTLEINDEX; + } + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER ){ +#ifdef _ALLBLUES_LUA_1_4 + BattleFinish(battleindex, charaindex); +#endif + } + CHAR_setWorkInt(charaindex,CHAR_WORKPETSKILLBT,0); +//#ifdef _PETSKILL_NONO_FIX +// CHAR_setWorkInt(charaindex,CHAR_WORKLISTPAGE,0); +//#endif +#ifdef _PROFESSION_ADDSKILL + CHAR_setWorkInt( charaindex, CHAR_DOOMTIME, 0 );//ĩռ +#endif +#ifdef _PETSKILL_BECOMEFOX // 뿪սʱĻɵıЧ + //print("\nͼ:%s,%d", CHAR_getChar( charaindex, CHAR_NAME), CHAR_getInt( charaindex, CHAR_BASEIMAGENUMBER)); + + if( CHAR_getInt( charaindex, CHAR_BASEIMAGENUMBER)==101749 + || CHAR_getWorkInt( charaindex, CHAR_WORKFOXROUND ) != -1 ){ //С + CHAR_setInt( charaindex, CHAR_BASEIMAGENUMBER, CHAR_getInt( charaindex, CHAR_BASEBASEIMAGENUMBER) ); + CHAR_setWorkInt( charaindex, CHAR_WORKFOXROUND, -1); + //print("\nȥ:%d",CHAR_getInt( charaindex, CHAR_BASEIMAGENUMBER)); + } +#endif + +#ifdef _PETSKILL_BECOMEPIG + if( CHAR_getInt( charaindex, CHAR_BECOMEPIG) > -1 + && CHAR_getInt( charaindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER ){ + CHAR_setInt( charaindex, CHAR_BASEIMAGENUMBER, CHAR_getInt( charaindex, CHAR_BECOMEPIG_BBI ) ); + CHAR_complianceParameter( charaindex ); + CHAR_sendCToArroundCharacter( CHAR_getWorkInt( charaindex , CHAR_WORKOBJINDEX )); + CHAR_send_P_StatusString( charaindex , CHAR_P_STRING_BASEBASEIMAGENUMBER); + } +#endif + +#ifdef _MAP_HEAL +{ + int mymap; + int n; + mymap = CHAR_getInt(charaindex,CHAR_FLOOR); + for(n=0;n<10;n++) + { + if(getMapHeal(n)==-1) break; + if(mymap == getMapHeal(n) && CHAR_getInt( charaindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER) + { + NPC_HealerAllHeal(charaindex); + CHAR_talkToCli( charaindex, -1, "Զָ", CHAR_COLORYELLOW); + } + } + +} +#endif + + +#ifdef _MAGIC_NOCAST // :Ĭ + // WON ADD + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER ) + lssproto_NC_send( getfdFromCharaIndex( charaindex ), 0);//ԭ +#endif + pBattle = &BattleArray[battleindex]; + if( pBattle->use == FALSE ) + return BATTLE_ERR_NOUSE; + + for( j = 0; j < 2; j ++ ){ + pEntry = pBattle->Side[j].Entry; + for( i = 0; i < BATTLE_ENTRY_MAX; i ++ ){ + if( pEntry[i].charaindex != charaindex ) + continue; + pEntry[i].charaindex = -1; + pEntry[i].escape = 0; + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_FINAL ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEINDEX, -1 ); +#ifdef _LOSE_FINCH_ + CHAR_setWorkInt( charaindex, CHAR_WORKSPETRELIFE, 0); +#endif + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE ) == CHAR_TYPEENEMY ){ + CHAR_endCharOneArray( charaindex ); +#ifdef _PLAYER_NPC + }else if( CHAR_getInt( charaindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYERNPC + || CHAR_getInt( charaindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYERPETNPC ){ + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_NONE ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEINDEX, -1 ); +{ + CHAR_setInt( charaindex , CHAR_HP ,CHAR_getWorkInt( charaindex, CHAR_WORKMAXHP ) ); + CHAR_setInt( charaindex , CHAR_MP ,CHAR_getWorkInt( charaindex, CHAR_WORKMAXMP ) ); + for(i = 0 ; i < CHAR_MAXPETHAVE; i ++) { + int petindex = CHAR_getCharPet( charaindex, i); + if( CHAR_CHECKINDEX( petindex) == FALSE ) continue; + CHAR_setFlg( petindex, CHAR_ISDIE, 0); + CHAR_setInt( petindex , CHAR_HP ,CHAR_getWorkInt( petindex, CHAR_WORKMAXHP ) ); + CHAR_setInt( petindex , CHAR_MP ,CHAR_getWorkInt( petindex, CHAR_WORKMAXMP ) ); + } +} + if( CHAR_getFlg( charaindex, CHAR_ISDIE ) == TRUE ){ + CHAR_setFlg( charaindex, CHAR_ISDIE, FALSE ); + } + BATTLE_BadStatusAllClr( charaindex ); + CHAR_complianceParameter( charaindex ); + CHAR_sendBattleEffect( charaindex, OFF); +#endif + }else if( CHAR_getInt( charaindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER ){ +#ifdef _OFFLINE_SYSTEM + if(CHAR_getWorkInt( charaindex, CHAR_WORK_OFFLINE ) != 0){ + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_NONE ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEINDEX, -1 ); + CHAR_sendBattleEffect( charaindex, OFF); + } +#endif + int petindex = pEntry[i+5].charaindex; + if( CHAR_getFlg( charaindex, CHAR_ISDIE ) == TRUE + || CHAR_getInt( charaindex, CHAR_HP ) == TRUE ) + { + +#ifdef _FIX_SPEED_UPLEVEL // WON ADD + // Robin cancel + //if( CHAR_getFlg( charaindex, CHAR_ISDIE ) == TRUE ){ + //}else + { + // Robin cancel + //if( CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM1) != BATTLE_COM_ESCAPE ) + { + unsigned int Dtimes; + unsigned int battletime; + int fd = getfdFromCharaIndex( charaindex ); + Dtimes = BattleArray[battleindex].CreateTime; + battletime = (unsigned int)(BattleArray[battleindex].flgTime/100); + + //if( CHAR_getWorkInt( charaindex, CHAR_WORKFLG) & WORKFLG_DEBUGMODE ){ + //}else + { + CheckDefBTime( charaindex, fd, Dtimes, battletime, 10);//lowTimeӳʱ + } + } + } +#endif + CHAR_setFlg( charaindex, CHAR_ISDIE, 0 ); + CHAR_setInt( charaindex, CHAR_HP, 1 ); + // CoolFish: Faily PK 2001/8/3 + CHAR_setWorkInt(charaindex, CHAR_WORKFMPKFLAG, -1); + + }else { +#ifdef _BATTLE_TIMESPEED + // Robin cancel + //if( CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM1) != BATTLE_COM_ESCAPE ) +#ifdef _OFFLINE_SYSTEM + if( CHAR_getWorkInt( charaindex, CHAR_WORK_OFFLINE) == 0 ) +#endif + { + unsigned int Dtimes; + unsigned int battletime; + + int fd = getfdFromCharaIndex( charaindex ); + Dtimes = BattleArray[battleindex].CreateTime; + battletime = (unsigned int)(BattleArray[battleindex].flgTime/100); + //if( CHAR_getWorkInt( charaindex, CHAR_WORKFLG) & WORKFLG_DEBUGMODE ) { + //}else + { + CheckDefBTime( charaindex, fd, Dtimes, battletime, 0);//lowTimeӳʱ + } + } +#endif + } + if( CHAR_CHECKINDEX( petindex ) == TRUE ){ + pEntry[i+5].charaindex = -1; + CHAR_setWorkInt( petindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_NONE ); + CHAR_setWorkInt( petindex, CHAR_WORKBATTLEINDEX, -1 ); + } + BATTLE_BadStatusAllClr( charaindex ); + CHAR_complianceParameter( charaindex ); + CHAR_Skillupsend( charaindex ); + // Robin 0730 + if( CHAR_getWorkInt( charaindex, CHAR_WORKPETFALL) ) + { + CHAR_setWorkInt( charaindex, CHAR_WORKPETFALL, 0 ); + CHAR_setInt( charaindex, CHAR_RIDEPET, -2 ); + } + CHAR_send_P_StatusString( charaindex , + CHAR_P_STRING_HP|CHAR_P_STRING_EXP| + CHAR_P_STRING_MP|CHAR_P_STRING_DUELPOINT| + CHAR_P_STRING_CHARM | + CHAR_P_STRING_EARTH | + CHAR_P_STRING_WATER | + CHAR_P_STRING_FIRE | + CHAR_P_STRING_WIND | + CHAR_P_STRING_RIDEPET + ); + // Robin 0730 + if( CHAR_getInt( charaindex, CHAR_RIDEPET ) == -2 ){ + CHAR_setInt( charaindex, CHAR_RIDEPET, -1 ); + } + for( k = 0; k < CHAR_MAXPETHAVE; k ++ ){ + petindex = CHAR_getCharPet( charaindex, k ); + if( CHAR_CHECKINDEX( petindex ) == FALSE )continue; + if( CHAR_getInt( petindex, CHAR_MAILMODE) != CHAR_PETMAIL_NONE ) continue; + if( CHAR_getFlg( petindex, CHAR_ISDIE ) == TRUE + || CHAR_getInt( petindex, CHAR_HP ) <= 0 ){ + CHAR_setFlg( petindex, CHAR_ISDIE, 0 ); + CHAR_setInt( petindex, CHAR_HP, 1 ); + } + CHAR_setWorkInt( petindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_NONE ); +#ifdef _LOSE_FINCH_ + CHAR_setWorkInt( charaindex, CHAR_WORKSPETRELIFE, 0); +#endif +#ifdef _VARY_WOLF + if( CHAR_getInt( petindex, CHAR_BASEBASEIMAGENUMBER) != CHAR_getInt( petindex, CHAR_BASEIMAGENUMBER) ) // Robin fix + { + CHAR_setInt( petindex, CHAR_BASEIMAGENUMBER, CHAR_getInt( petindex, CHAR_BASEBASEIMAGENUMBER)); + sprintf( szPet, "K%d", k); + CHAR_sendStatusString( charaindex , szPet); + } +#endif +#ifdef _PROFESSION_SKILL // WON ADD ְҵ + // + if( CHAR_getWorkInt( petindex, CHAR_WORKOBLIVION ) > 0 ) // Robin fix + { + int pet_no = CHAR_getInt( charaindex, CHAR_DEFAULTPET ); + CHAR_setWorkInt( petindex, CHAR_WORKOBLIVION, 0 ); + // + sprintf( szPet, "W%d", pet_no); + CHAR_sendStatusString( charaindex , szPet); + } +#endif + BATTLE_BadStatusAllClr( petindex ); + CHAR_complianceParameter( petindex ); + CHAR_send_K_StatusString( charaindex , k, + CHAR_K_STRING_HP|CHAR_K_STRING_EXP| + CHAR_K_STRING_AI| CHAR_K_STRING_MP | + CHAR_K_STRING_ATK | CHAR_K_STRING_DEF | + CHAR_K_STRING_QUICK | + CHAR_K_STRING_EARTH | + CHAR_K_STRING_WATER | + CHAR_K_STRING_FIRE | + CHAR_K_STRING_WIND + ); + } + if( BattleArray[battleindex].type == BATTLE_TYPE_P_vs_P ){ + int flg = 0; + CHAR_setFlg( charaindex, CHAR_ISDUEL, 0); + if( CHAR_getFlg( charaindex, CHAR_ISPARTY)) flg |= CHAR_FS_PARTY; + if( CHAR_getFlg( charaindex, CHAR_ISDUEL)) flg |= CHAR_FS_DUEL; + if( CHAR_getFlg( charaindex, CHAR_ISPARTYCHAT)) flg |= CHAR_FS_PARTYCHAT; + if( CHAR_getFlg( charaindex, CHAR_ISTRADECARD)) flg |= CHAR_FS_TRADECARD; +#ifdef _CHANNEL_MODIFY + if( CHAR_getFlg( charaindex, CHAR_ISTELL)) flg |= CHAR_FS_TELL; + if( CHAR_getFlg( charaindex, CHAR_ISFM)) flg |= CHAR_FS_FM; + if( CHAR_getFlg( charaindex, CHAR_ISOCC)) flg |= CHAR_FS_OCC; + if( CHAR_getFlg( charaindex, CHAR_ISCHAT)) flg |= CHAR_FS_CHAT; + if( CHAR_getFlg( charaindex, CHAR_ISSAVE)) flg |= CHAR_FS_SAVE; + if(getSaType()==95){ + if( CHAR_getFlg( charaindex, CHAR_ISWORLD)) flg |= CHAR_FS_WORLD; + } +#endif + lssproto_FS_send( getfdFromCharaIndex(charaindex), flg); + } + + lssproto_XYD_send( getfdFromCharaIndex(charaindex), + CHAR_getInt( charaindex, CHAR_X ), + CHAR_getInt( charaindex, CHAR_Y ), + CHAR_getInt( charaindex, CHAR_DIR ) ); + } + break; + } + } + CHAR_PartyUpdate( charaindex, CHAR_N_STRING_HP ); + +#ifdef _TIME_TICKET + { + int nowtime = time(NULL); + int tickettime = CHAR_getWorkInt( charaindex, CHAR_WORKTICKETTIME); + int totaltime; + char msg[1024]; + if( tickettime > 0 && tickettime < nowtime ) { + //int floor, x, y; + CHAR_talkToCli( charaindex, -1, "ллˡ", CHAR_COLORYELLOW); + if( CHAR_getWorkInt( charaindex, CHAR_WORKTICKETTIMESTART) > 0 ) { + totaltime = nowtime - CHAR_getWorkInt( charaindex, CHAR_WORKTICKETTIMESTART); + sprintf( msg, "볡ʱ%d%d롣", totaltime/60, totaltime%60); + CHAR_talkToCli( charaindex, -1, msg, CHAR_COLORYELLOW); + } + CHAR_setWorkInt( charaindex, CHAR_WORKTICKETTIME, 0); + CHAR_setWorkInt( charaindex, CHAR_WORKTICKETTIMESTART, 0); + /*if( CHAR_getElderPosition( CHAR_getInt( charaindex, CHAR_LASTTALKELDER), &floor, &x, &y ) != TRUE ) { + CHAR_warpToSpecificPoint( charaindex, 1006, 15, 15); + } + else { + CHAR_warpToSpecificPoint( charaindex, floor, x, y); + }*/ + CHAR_warpToSpecificPoint( charaindex, 2006, 20, 17); + } + } +#endif + //51000ͼս󷵻ؼ¼ + if(CHAR_getInt( charaindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER && CHAR_getInt( charaindex, CHAR_FLOOR )==51000){ + int floor = 0, x = 0, y = 0; + CHAR_getElderPosition( CHAR_getInt( charaindex, CHAR_LASTTALKELDER), &floor, &x, &y ); + CHAR_warpToSpecificPoint( charaindex, floor, x, y); + } + lssproto_XYD_send(getfdFromCharaIndex( charaindex ),CHAR_getInt( charaindex, CHAR_X ),CHAR_getInt( charaindex, CHAR_Y ),CHAR_getInt( charaindex, CHAR_DIR ) ); + if(CHAR_getInt( charaindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER){ + CHAR_CheckItemTime(charaindex); + } + return BATTLE_ERR_NONE; +} + + +int BATTLE_PetDefaultExit( + int charaindex, + int battleindex +) +{ + int pno, pindex, iRet; + + if( CHAR_CHECKINDEX( charaindex ) == FALSE )return BATTLE_ERR_CHARAINDEX; + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER) return 0; + pno = CHAR_getInt( charaindex, CHAR_DEFAULTPET ); + if( pno < 0 )return 0; + pindex = CHAR_getCharPet( charaindex, pno ); + + iRet = BATTLE_Exit( pindex, battleindex ); + + if( iRet ){ + iRet *= -1; + }else{ + return 1; + } + + return iRet; +} + + +int BATTLE_PetDefaultEntry( + int charaindex, + int battleindex, + int side +) +{ + int pindex; + +#if 1 + int pno; + + int ret = 0; + + pno = CHAR_getInt( charaindex, CHAR_DEFAULTPET ); + if( pno == -1 ) return 0; + pindex = CHAR_getCharPet( charaindex, pno ); + + if( CHAR_CHECKINDEX( pindex ) && + + !CHAR_getFlg( pindex, CHAR_ISDIE ) && + CHAR_getInt( pindex, CHAR_HP ) > 0 ) + { + if( BATTLE_NewEntry( pindex, battleindex, side ) ){ + }else{ + ret = 0; + } + } + else { +#ifdef _PLAYER_NPC + if(CHAR_getInt( charaindex, CHAR_WHICHTYPE ) != CHAR_TYPEPLAYERNPC) +#endif +// if(CHAR_getInt( charaindex, CHAR_WHICHTYPE ) != CHAR_TYPEPLAYERNPC) + CHAR_setInt( charaindex, CHAR_DEFAULTPET, -1 ); + } + + return ret; +#else + + for( i = 0; i < CHAR_MAXPETHAVE; i ++ ){ + pindex = CHAR_getCharPet( charaindex, i ); + + if( CHAR_CHECKINDEX( pindex ) == FALSE )continue; + + if( CHAR_getFlg( pindex, CHAR_ISDIE ) == TRUE )continue; + if( CHAR_getInt( pindex, CHAR_HP ) <= 0 )continue; + + if( BATTLE_NewEntry( pindex, battleindex, side ) ){ + }else{ + CHAR_setInt( charaindex, CHAR_DEFAULTPET, i ); + break; + } + } + + if( i == CHAR_MAXPETHAVE ){ + CHAR_setInt( charaindex, CHAR_DEFAULTPET, -1 ); + } + return 0; +#endif +} + +int BATTLE_RescueEntry( int charaindex, int toindex ) +{ + int iRet = 0, battleindex, fd, pindex; + char szBuffer[256]=""; + +#ifdef _BATTLE_TIMESPEED + fd = getfdFromCharaIndex( charaindex); + if( CONNECT_getBDTime( fd) > time( NULL) ) { + return 1; + } +#endif + + battleindex = CHAR_getWorkInt( toindex, CHAR_WORKBATTLEINDEX ); + if( !BATTLE_CHECKINDEX( battleindex) ) return 1; + if( ( fd = getfdFromCharaIndex(charaindex) ) < 0 ) return 1; + + //BUG + int pi; + for( pi = 0; pi < CHAR_PARTYMAX; pi ++ ) { + int index = CHAR_getWorkInt( toindex, pi + CHAR_WORKPARTYINDEX1); + if( CHAR_CHECKINDEX(index)) { + if(index == charaindex) return 1; + } + } +#ifdef _PET_BUG + int petarray = CHAR_getInt( charaindex, CHAR_DEFAULTPET); + if(petarray>-1){ + int petindex = CHAR_getCharPet( charaindex, petarray); + if(CHAR_getInt(petindex,CHAR_VITAL)>=getPetPoint(0)*20 || CHAR_getInt(petindex,CHAR_STR)>=getPetPoint(1)*80 || CHAR_getInt(petindex,CHAR_TOUGH)>=getPetPoint(2)*80 || CHAR_getInt(petindex,CHAR_DEX)>=getPetPoint(3)*100) + return 1; + } +#endif +#ifdef _WARNPC_CTRL + int mapi; + for(mapi=0;mapi<10;mapi++){ + int floorid = getPartyMap(mapi); + if(floorid==-1) break; + if(CHAR_getInt(charaindex,CHAR_FLOOR)==floorid){ + int sameipnum = getMapSameIp(mapi); + int partyi; + unsigned ip=CONNECT_get_userip(getfdFromCharaIndex(charaindex)); + unsigned teseip = ip; + unsigned toip; + int a, b, c, d,ipcnt=1; + char ipstr[32]; + a=(teseip % 0x100); teseip=teseip / 0x100; + b=(teseip % 0x100); teseip=teseip / 0x100; + c=(teseip % 0x100); teseip=teseip / 0x100; + d=(teseip % 0x100); + sprintf(ipstr,"%d.%d.%d.%d",a,b,c,d); + if(strcmp(ipstr,getNoAttIp(0))==0 || strcmp(ipstr,getNoAttIp(1))==0 || strcmp(ipstr,getNoAttIp(2))==0 || strcmp(ipstr,getNoAttIp(3))==0 || strcmp(ipstr,getNoAttIp(4))==0) + break; + if( CHAR_getWorkInt( toindex, CHAR_WORKPARTYMODE) == CHAR_PARTY_NONE ) { + toip=CONNECT_get_userip(getfdFromCharaIndex(toindex)); + if(ip==toip){ + ipcnt++; + if(ipcnt>sameipnum){ + CHAR_talkToCli( charaindex, -1, "˵ͼĵIPѴޡ", CHAR_COLORYELLOW); + return 1; + } + else + break; + } + break; + }else{ + for( partyi = 0; partyi < CHAR_PARTYMAX; partyi ++ ) { + int index = CHAR_getWorkInt( toindex, partyi + CHAR_WORKPARTYINDEX1); + if( CHAR_CHECKINDEX(index)) { + toip = CONNECT_get_userip(getfdFromCharaIndex(index)); + if(ip==toip){ + ipcnt++; + if(ipcnt>sameipnum){ + CHAR_talkToCli( charaindex, -1, "˵ͼĵIPѴޡ", CHAR_COLORYELLOW); + return 1; + } + } + } + } + } + } + } + if(CHAR_getWorkInt(toindex,CHAR_WORKNPCBATTLESAMEIP)>0){ + int sameipnum = CHAR_getWorkInt(toindex,CHAR_WORKNPCBATTLESAMEIP); + int partyi; + unsigned ip=CONNECT_get_userip(getfdFromCharaIndex(charaindex)); + unsigned teseip = ip; + unsigned toip; + int a, b, c, d,ipcnt=1; + char ipstr[32]; + a=(teseip % 0x100); teseip=teseip / 0x100; + b=(teseip % 0x100); teseip=teseip / 0x100; + c=(teseip % 0x100); teseip=teseip / 0x100; + d=(teseip % 0x100); + sprintf(ipstr,"%d.%d.%d.%d",a,b,c,d); + if(strcmp(ipstr,getNoAttIp(0))==0 || strcmp(ipstr,getNoAttIp(1))==0 || strcmp(ipstr,getNoAttIp(2))==0 || strcmp(ipstr,getNoAttIp(3))==0 || strcmp(ipstr,getNoAttIp(4))==0){ + }else{ + if( CHAR_getWorkInt( toindex, CHAR_WORKPARTYMODE) == CHAR_PARTY_NONE ) { + toip=CONNECT_get_userip(getfdFromCharaIndex(toindex)); + if(ip==toip){ + ipcnt++; + if(ipcnt>sameipnum){ + CHAR_talkToCli( charaindex, -1, "ͬIPѴޣ޷ս", CHAR_COLORYELLOW); + return 1; + } + } + }else{ + for( partyi = 0; partyi < CHAR_PARTYMAX; partyi ++ ) { + int index = CHAR_getWorkInt( toindex, partyi + CHAR_WORKPARTYINDEX1); + if( CHAR_CHECKINDEX(index)) { + toip = CONNECT_get_userip(getfdFromCharaIndex(index)); + if(ip==toip){ + ipcnt++; + if(ipcnt>sameipnum){ + CHAR_talkToCli( charaindex, -1, "ͬIPѴޣ޷ս", CHAR_COLORYELLOW); + return 1; + } + } + } + } + } + } + } +#endif + + if( CHAR_getWorkInt( toindex, CHAR_WORKBATTLEMODE ) == BATTLE_CHARMODE_FINAL + || CHAR_getWorkInt( toindex, CHAR_WORKBATTLEINDEX ) == -1 ){ + iRet = 1; + } + + if( BattleArray[battleindex].type == BATTLE_TYPE_P_vs_P ){ + iRet = 1; + }else{ + iRet = BATTLE_NewEntry( + charaindex, + battleindex, + CHAR_getWorkInt( toindex, CHAR_WORKBATTLESIDE ) ); + } + + if( iRet == 0 ){ + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_RESCUE ); + iRet = BATTLE_PetDefaultEntry( + charaindex, + battleindex, + CHAR_getWorkInt( toindex, CHAR_WORKBATTLESIDE ) + ); + } + + + + if( iRet == 0 ){ + int flg; + if( CHAR_getInt( charaindex, CHAR_DEFAULTPET ) >= 0 ){ + pindex = CHAR_getCharPet( charaindex, CHAR_getInt( charaindex, CHAR_DEFAULTPET ) ); + CHAR_setWorkInt( pindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_RESCUE ); + } + //snprintf( szBuffer, sizeof( szBuffer ), "(%s)ս", + // CHAR_getUseName( charaindex ) ); + //BATTLE_BroadCast( battleindex, szBuffer, CHAR_COLORYELLOW ); + if( ( fd = getfdFromCharaIndex(charaindex) ) != -1 ){ + lssproto_EN_send( fd, BattleArray[battleindex].type, BattleArray[battleindex].field_no ); + } + flg = (BattleArray[battleindex].Side[ + CHAR_getWorkInt( toindex, CHAR_WORKBATTLESIDE)].flg + & BSIDE_FLG_HELP_OK)? TRUE:FALSE; + lssproto_HL_send( fd, flg); + sprintf( szBuffer, "BP|%X|%X|%X", + BATTLE_Index2No( battleindex, charaindex ), BP_FLG_JOIN, CHAR_getInt(charaindex, CHAR_MP ) ); + BATTLE_CommandSend( charaindex, szBuffer ); + }else{ + snprintf( szBuffer, sizeof( szBuffer ), "޷ս" ); + CHAR_talkToCli( charaindex, -1, szBuffer, CHAR_COLORYELLOW); + if( ( fd = getfdFromCharaIndex(charaindex) ) != -1 ){ + lssproto_EN_send( fd, FALSE, BattleArray[battleindex].field_no ); + } + } + BATTLE_ClearGetExp( charaindex ); + return iRet; +} + +BOOL BATTLE_RescueTry( int charaindex) +{ + int x,y; + OBJECT object; + int pfound = FALSE; + int result = FALSE; + int fd; + int i; + int cnt; + + fd = getfdFromCharaIndex( charaindex); + if( fd == -1 ) return FALSE; +#if 1 // òսظս Robin + if( CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE) != BATTLE_CHARMODE_NONE) { + CHAR_talkToCli( charaindex, -1, " ظս! ", CHAR_COLORRED); + //print("\n ķ!!ظս!:%s ", CHAR_getChar( charaindex, CHAR_CDKEY) ); + //lssproto_EN_send( fd, FALSE, 0 ); + return FALSE; + } +#endif + if( CHAR_getWorkInt( charaindex, CHAR_WORKPARTYMODE) != CHAR_PARTY_NONE ) { + lssproto_EN_send( fd, FALSE, 0 ); + return FALSE; + } +#ifdef _BATTLE_TIMESPEED + if( CONNECT_getBDTime( fd) > time( NULL) ) { + return FALSE; + } +#endif +#ifdef _PET_BUG + int petarray = CHAR_getInt( charaindex, CHAR_DEFAULTPET); + if(petarray>-1){ + int petindex = CHAR_getCharPet( charaindex, petarray); + if(CHAR_getInt(petindex,CHAR_VITAL)>=getPetPoint(0)*20 || CHAR_getInt(petindex,CHAR_STR)>=getPetPoint(1)*80 || CHAR_getInt(petindex,CHAR_TOUGH)>=getPetPoint(2)*80 || CHAR_getInt(petindex,CHAR_DEX)>=getPetPoint(3)*100) + return FALSE; + } +#endif + for( i = 0; i < CONNECT_WINDOWBUFSIZE; i ++ ) { + CONNECT_setBattlecharaindex(fd,i,-1); + } + CHAR_getCoordinationDir( CHAR_getInt( charaindex, CHAR_DIR ) , + CHAR_getInt( charaindex , CHAR_X ), + CHAR_getInt( charaindex , CHAR_Y ) , + 1 , &x , &y ); + + cnt = 0; + for( object = MAP_getTopObj( CHAR_getInt( charaindex, CHAR_FLOOR),x,y) ; + object ; + object = NEXT_OBJECT(object ) ) + { + int toindex; + int objindex = GET_OBJINDEX(object); + if( OBJECT_getType( objindex) != OBJTYPE_CHARA) continue; + toindex = OBJECT_getIndex( objindex); + if( CHAR_getInt( toindex, CHAR_WHICHTYPE) != CHAR_TYPEPLAYER +#ifdef _PLAYER_NPC + && CHAR_getInt( toindex, CHAR_WHICHTYPE) != CHAR_TYPEPLAYERNPC +#endif + // && CHAR_getInt( toindex, CHAR_WHICHTYPE) != CHAR_TYPEPLAYERNPC + ) continue; + pfound = TRUE; + if( CHAR_getWorkInt( toindex, CHAR_WORKBATTLEMODE) == BATTLE_CHARMODE_NONE ){ + continue; + } + if( BattleArray[ CHAR_getWorkInt( toindex, CHAR_WORKBATTLEINDEX)].type + != BATTLE_TYPE_P_vs_E ){ + continue; + } + if( !(BattleArray[CHAR_getWorkInt( toindex,CHAR_WORKBATTLEINDEX)].Side[ + CHAR_getWorkInt( toindex, CHAR_WORKBATTLESIDE)].flg + & BSIDE_FLG_HELP_OK)){ + continue; + } + CONNECT_setBattlecharaindex( fd, cnt, toindex ); + cnt++; + if( cnt == CONNECT_WINDOWBUFSIZE ) break; + } + if( cnt == 0 ) { + if( pfound == FALSE ) { + CHAR_talkToCli( charaindex, -1, "ûκˡ", + CHAR_COLORYELLOW); + } + lssproto_EN_send( fd, FALSE, 0 ); + }else if( cnt == 1 ) { + if( BATTLE_RescueEntry( charaindex, + CONNECT_getBattlecharaindex(fd,0) ) ){ + CHAR_talkToCli( charaindex, -1, "޷ս", CHAR_COLORYELLOW); + }else { + result = TRUE; + } + }else if( cnt > 1 ) { + int strlength; + char msgbuf[1024]; + char escapebuf[2048]; + strcpysafe( msgbuf,sizeof(msgbuf), "1\n˭սأ\n"); + strlength = strlen( msgbuf); + for( i = 0; + CONNECT_getBattlecharaindex( fd,i ) != -1 + && i< CONNECT_WINDOWBUFSIZE; i ++ ){ + char *a = CHAR_getChar( CONNECT_getBattlecharaindex(fd,i), CHAR_NAME); + char buf[256]; + snprintf( buf, sizeof( buf),"%s\n", a); + if( strlength + strlen( buf) > arraysizeof( msgbuf)){ + //print( "\nerr:%s:%d ӴѶϢ岻\n", + //__FILE__,__LINE__); + break; + } + strcpy( &msgbuf[strlength], buf); + strlength += strlen(buf); + } + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_SELECT, + WINDOW_BUTTONTYPE_CANCEL, + CHAR_WINDOWTYPE_SELECTBATTLE, + -1, + makeEscapeString( msgbuf, escapebuf, sizeof(escapebuf))); + + } + + return result; +} + + + + +BOOL BATTLE_RescueParentTry( int charaindex, int pindex) +{ + int result = FALSE; + if( CHAR_getFlg( charaindex, CHAR_ISDIE)) return FALSE; + if( CHAR_getWorkInt( charaindex, CHAR_WORKPARTYINDEX1) != pindex ) return FALSE; + if( CHAR_getWorkInt( pindex, CHAR_WORKBATTLEMODE) == BATTLE_CHARMODE_NONE ){ + return FALSE; + } + if( BATTLE_RescueEntry( charaindex, pindex ) ){ + result = FALSE; + }else{ + result = TRUE; + } + if( result == FALSE ) { + CHAR_talkToCli( charaindex, -1, "޷ս", CHAR_COLORYELLOW); + } + return result; +} + +int BATTLE_PartyNewEntry( + int charaindex, + int battleindex, + int side +) +{ + int iRet = 0, i, work; +#if 1 + + iRet = BATTLE_NewEntry( charaindex, battleindex, side ); + if( iRet )return iRet; + CAflush( charaindex ); + CDflush( charaindex ); + iRet = BATTLE_PetDefaultEntry( charaindex, battleindex, side ); + if( iRet )return iRet; + BATTLE_ClearGetExp( charaindex ); +#endif + + for( i = 1; i < CHAR_PARTYMAX; i ++ ){ + work = CHAR_getWorkInt( charaindex, i + CHAR_WORKPARTYINDEX1 ); + if( CHAR_CHECKINDEX( work ) == FALSE )continue; + if( CHAR_getWorkInt( work, CHAR_WORKBATTLEMODE ) != 0 ){ + continue; + } + iRet = BATTLE_NewEntry( work, battleindex, side ); + if( iRet )break; + CAflush( work ); + CDflush( work ); + iRet = BATTLE_PetDefaultEntry( work, battleindex, side ); + if( iRet )return iRet; + BATTLE_ClearGetExp( work ); + } + return iRet; +} + + + + + + + + + + + + + + +#if 1 + +int BATTLE_WatchNewEntry( + int charaindex, + int battleindex, + int side +) +{ + BATTLE_ENTRY *pEntry; + BATTLE *pBattle; + int iEntryFirst = 0, iEntryMax = BATTLE_ENTRY_MAX, i; + + if( BATTLE_CHECKSIDE( side ) == FALSE )return BATTLE_ERR_PARAM; + if( BATTLE_CHECKINDEX( battleindex ) == FALSE )return BATTLE_ERR_BATTLEINDEX; + if( CHAR_CHECKINDEX( charaindex ) == FALSE )return BATTLE_ERR_CHARAINDEX; + + pBattle = &BattleArray[battleindex]; + + if( pBattle->use == FALSE )return BATTLE_ERR_NOUSE; + + if( side < 0 || side > 1 ){ + return BATTLE_ERR_PARAM; + } + + switch( CHAR_getInt( charaindex, CHAR_WHICHTYPE ) ){ + + + case CHAR_TYPEPLAYER: + if( pBattle->Side[side].type != BATTLE_S_TYPE_PLAYER ){ + return BATTLE_ERR_TYPE; + } + iEntryFirst = 0; + iEntryMax = BATTLE_PLAYER_MAX; + break; + default: + //print( "(%s)(%d)\n", + //CHAR_getUseName( charaindex ), + //CHAR_getInt( charaindex, CHAR_WHICHTYPE ) ); + return BATTLE_ERR_TYPE; + } + + + pEntry = pBattle->Side[side].Entry; + + for( i = iEntryFirst; i < iEntryMax; i ++ ){ + if( pEntry[i].charaindex == -1 )break; + } + + if( i == iEntryMax ){ + return BATTLE_ERR_ENTRYMAX; + } + + EntryInit( &pEntry[i] ); + + pEntry[i].charaindex = charaindex; + + pEntry[i].bid = i + side * SIDE_OFFSET; + + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEINDEX, + battleindex ); + + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, + BATTLE_CHARMODE_WATCHINIT ); + + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLESIDE, side ); + + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEFLG, 0 ); + + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, -1 ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, -1 ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM3, -1 ); + + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEWATCH, 1 ); + + return 0; +} + + +int BATTLE_WatchPartyNewEntry( + int charaindex, + int battleindex, + int side +) +{ + int iRet = 0, i, work; +#if 1 + + iRet = BATTLE_WatchNewEntry( charaindex, battleindex, side ); + if( iRet )return iRet; + + CAflush( charaindex ); + + CDflush( charaindex ); + +#endif + + for( i = 1; i < CHAR_PARTYMAX; i ++ ){ + + work = CHAR_getWorkInt( charaindex, i + CHAR_WORKPARTYINDEX1 ); + if( CHAR_CHECKINDEX( work ) == FALSE )continue; + + if( CHAR_getWorkInt( work, CHAR_WORKBATTLEMODE ) != 0 ){ + continue; + } + + iRet = BATTLE_WatchNewEntry( work, battleindex, side ); + + if( iRet )break; + + CAflush( work ); + CDflush( work ); + } + return iRet; + +} + + + + +int BATTLE_CreateForWatcher( int charaindex, int topbattleindex ); + +int BATTLE_WatchEntry( + int charaindex, + int toindex + ) +{ + int iRet = 0, battleindex, fd; + char szBuffer[256]=""; + + battleindex = CHAR_getWorkInt( toindex, CHAR_WORKBATTLEINDEX ); + + if( CHAR_getWorkInt( toindex, CHAR_WORKBATTLEMODE ) == BATTLE_CHARMODE_FINAL + || CHAR_getWorkInt( toindex, CHAR_WORKBATTLEMODE ) == BATTLE_CHARMODE_NONE + || CHAR_getWorkInt( toindex, CHAR_WORKBATTLEINDEX ) == -1 + ){ + iRet = 1; + } + + if( iRet == 0 ){ + iRet = BATTLE_CreateForWatcher( charaindex, battleindex ); + } + if( iRet == 0 ){ + //snprintf( szBuffer, sizeof( szBuffer ), "(%s)ʼս", + // CHAR_getUseName( charaindex ) ); + + //BATTLE_BroadCast( battleindex, szBuffer, CHAR_COLORYELLOW ); + if( ( fd = getfdFromCharaIndex(charaindex) ) != -1 ){ + lssproto_EN_send( fd, BattleArray[battleindex].type, BattleArray[battleindex].field_no ); + } + + sprintf( szBuffer, "BP|%X|%X|%X", + 20, BP_FLG_JOIN, CHAR_getInt(charaindex, CHAR_MP ) ); + BATTLE_CommandSend( charaindex, szBuffer ); + + }else{ + snprintf( szBuffer, sizeof( szBuffer ), "޷ս" ); + CHAR_talkToCli( charaindex, -1, szBuffer, CHAR_COLORYELLOW); + + if( ( fd = getfdFromCharaIndex(charaindex) ) != -1 ){ + lssproto_EN_send( fd, FALSE, 0 ); + } + } + + return iRet; +} + + + +BOOL BATTLE_WatchTry( int charaindex ) +{ + int x,y; + OBJECT object; + int pfound = FALSE; + int result = FALSE; + int fd; + int i; + int cnt; + + + fd = getfdFromCharaIndex( charaindex); + if( fd == -1 )return FALSE; + + for( i = 0; i < CONNECT_WINDOWBUFSIZE ; i ++ ) { + CONNECT_setBattlecharaindex( fd,i,-1); + } + CHAR_getCoordinationDir( CHAR_getInt( charaindex, CHAR_DIR ) , + CHAR_getInt( charaindex , CHAR_X ), + CHAR_getInt( charaindex , CHAR_Y ) , + 1 , &x , &y ); + + cnt = 0; + /*м 󡼰ƽҷë */ + for( object = MAP_getTopObj( CHAR_getInt( charaindex, CHAR_FLOOR),x,y) ; + object ; + object = NEXT_OBJECT(object ) ) + { + int toindex; + int objindex = GET_OBJINDEX(object); + /* ƽҷԪئ */ + if( OBJECT_getType( objindex) != OBJTYPE_CHARA) continue; + toindex = OBJECT_getIndex( objindex); + /* Ԫئ */ + if( CHAR_getInt( toindex, CHAR_WHICHTYPE) != CHAR_TYPEPLAYER +#ifdef _PLAYER_NPC + && CHAR_getInt( toindex, CHAR_WHICHTYPE) != CHAR_TYPEPLAYERNPC +#endif + // && CHAR_getInt( toindex, CHAR_WHICHTYPE) != CHAR_TYPEPLAYERNPC + ) continue; + pfound = TRUE; + /* ƥئئݳ */ + if( CHAR_getWorkInt( toindex, CHAR_WORKBATTLEMODE) == BATTLE_CHARMODE_NONE ){ + continue; + } + + CONNECT_setBattlecharaindex( fd,cnt, toindex ); + cnt++; + if( cnt == CONNECT_WINDOWBUFSIZE ) break; + } + if( cnt == 0 ) { + if( pfound == FALSE ) { + CHAR_talkToCli( charaindex, -1, "ûκˡ", + CHAR_COLORYELLOW); + } + // ľئʻ + lssproto_EN_send( fd, FALSE, 0 ); + } + /* ƾئ޼ */ + else if( cnt == 1 ) { + if( BATTLE_WatchEntry( charaindex,CONNECT_getBattlecharaindex(fd,0)) ) + { + result = FALSE; + } else { + result = TRUE; + } + } + /* ūëƻ */ + else if( cnt > 1 ) { + int strlength; + char msgbuf[1024]; + char escapebuf[2048]; + strcpysafe( msgbuf,sizeof(msgbuf), "1\nۿ˭սأ\n"); + strlength = strlen( msgbuf); + /* ū + * ƽҷ¼ + */ + for( i = 0; + CONNECT_getBattlecharaindex( fd,i ) != -1 + && i< CONNECT_WINDOWBUFSIZE; + i ++ ) + { + char *a = CHAR_getChar( CONNECT_getBattlecharaindex(fd,i), + CHAR_NAME); + char buf[256]; + snprintf( buf, sizeof( buf),"%s\n", a); + if( strlength + strlen( buf) > arraysizeof( msgbuf)){ + //print( "\nerr:%s:%d ӴѶϢ岻\n", + //__FILE__,__LINE__); + break; + } + strcpy( &msgbuf[strlength], buf); + strlength += strlen(buf); + } + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_SELECT, + WINDOW_BUTTONTYPE_CANCEL, + CHAR_WINDOWTYPE_SELECTBATTLEWATCH, + -1, + makeEscapeString( msgbuf, escapebuf, sizeof(escapebuf))); + } + + return result; +} + + +#endif + + + + + + + +#define MAX_DOUJYOUENEMY 64 +static int DoujyouEnemyTbl[10]; // +/*************************************************************** + * ƹñƽҷ + ***************************************************************/ +int *Doujyou_GetEnemy( int meindex, int charaindex ) +{ + int i; + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + char buf[1024]; + int ret; + int insert; + int WorkEnemyTbl[MAX_DOUJYOUENEMY]; + + NPC_Util_GetArgStr( meindex, argstr, sizeof( argstr)); + + /* */ + for( i = 0; i < arraysizeof(WorkEnemyTbl); i ++ ) { + WorkEnemyTbl[i] = -1; + } + + if( NPC_Util_GetStrFromStrWithDelim( argstr, "enemyno", buf, sizeof( buf)) + == NULL ) + { + return NULL; + } + + insert = 0; + /* ¦ѱ̤лؤ³ë޼ */ + for( i = 0; i < MAX_DOUJYOUENEMY; i ++ ) { + int curEnemy; + char data[128]; + + ret = getStringFromIndexWithDelim( buf,",", i + 1,data, sizeof(data)); + if( ret == FALSE) { + break; + } + + curEnemy = ENEMY_getEnemyArrayFromId( atoi( data)); + if( !ENEMY_CHECKINDEX( curEnemy) ) continue; + WorkEnemyTbl[insert] = curEnemy; + insert ++; + } + // ľئվ޷¡ + if( insert <= 0 )return NULL; + + // ¼ĸةɬ + DoujyouEnemyTbl[0] = WorkEnemyTbl[RAND( 0, insert-1 )]; + + + if( NPC_Util_GetStrFromStrWithDelim( argstr, "enemypetno", buf, sizeof( buf)) + == NULL ) + { + // ئ̤ئ + DoujyouEnemyTbl[1] = -1; + }else{ + insert = 0; + /* ¦ѱ̤лؤ³ë޼ */ + for( i = 0; i < MAX_DOUJYOUENEMY; i ++ ) { + int curEnemy; + char data[128]; + + ret = getStringFromIndexWithDelim( buf,",", i + 1,data, sizeof(data)); + if( ret == FALSE) { + break; + } + + curEnemy = ENEMY_getEnemyArrayFromId( atoi( data)); + if( !ENEMY_CHECKINDEX( curEnemy) ) continue; + WorkEnemyTbl[insert] = curEnemy; + insert ++; + } + // ¼ĸةɬ + DoujyouEnemyTbl[1] = WorkEnemyTbl[RAND( 0, insert-1 )]; + } + + // + DoujyouEnemyTbl[2] = -1; + + return DoujyouEnemyTbl; +} + + + +static int DoujyouWeponTbl[] = { + -1, + ITEM_FIST, + ITEM_AXE, + ITEM_CLUB, + ITEM_SPEAR, + ITEM_BOW, + ITEM_BOOMERANG, + ITEM_BOUNDTHROW, + ITEM_BREAKTHROW, +}; +int DoujyouRandomWeponSet( int charaindex ){ + int wepon = -1, itemindex; + int work = RAND( 0, arraysizeof( DoujyouWeponTbl ) - 1 ); + switch( DoujyouWeponTbl[work] ){ + case ITEM_AXE: wepon = 0;break; + case ITEM_CLUB: wepon = 100;break; + case ITEM_SPEAR: wepon = 200;break; + case ITEM_BOW: wepon = 2498;break; + case ITEM_BOOMERANG:wepon = 500;break; + case ITEM_BOUNDTHROW:wepon = 600;break; + case ITEM_BREAKTHROW:wepon = 700;break; + } + itemindex = CHAR_getItemIndex( charaindex, CHAR_ARM ); + if( ITEM_CHECKINDEX( itemindex ) == TRUE ){ + ITEM_endExistItemsOne( itemindex ); + } + + if( wepon >= 0 ){ + itemindex = ITEM_makeItemAndRegist( wepon ) ; + CHAR_setItemIndex( charaindex, CHAR_ARM, itemindex ); + ITEM_setWorkInt( itemindex, ITEM_WORKCHARAINDEX, charaindex ); + ITEM_setWorkInt( itemindex, ITEM_WORKOBJINDEX, -1 ); + } + switch( DoujyouWeponTbl[work] ){ + case -1: + case ITEM_AXE: + case ITEM_CLUB: + case ITEM_SPEAR: + return 0; + } + return 1; + +} + +static int BattleERSkill1[]={ +3, 10, 11, 12, 30, 31, 40, 41, 50, 51, 52, 60, 61, 80, 90, 110, 120, 150, 210, +303, 309, 315, 321, 503, 504, 506, 507, 541, 542, 543, 544, 545, 546, 547, 575, 579, 580, +606, 613, 615 }; + +static int BattleERSkill2[]={ +12, 13, 20, 41, 52, 152, 210, 306, 312, 318, 324, 325, 500, 501, 502, 505, +508, 541, 542, 543, 544, 545, 546, 547, 576, 580, 594, 606, 613, 616 }; + +void BATTLE_EnemyRandowSetSkill( int enemyindex, int skillType) +{ + int i; + switch( skillType){ + case 1: + for( i=0; i<7; i++){ + int skillarray, skillID, Ri; + Ri = RAND( 0, arraysizeof( BattleERSkill1) - 1 ); + skillID = BattleERSkill1[Ri]; + skillarray = PETSKILL_getPetskillArray( skillID); + if( PETSKILL_CHECKINDEX( skillarray) == FALSE ){ + CHAR_setPetSkill( enemyindex, i, 1); + //andy_log + //print("ANDY EnemyRandowSetSkill( ) skillID:%d array:%d err \n", + //skillID, skillarray ); + continue; + } + CHAR_setPetSkill( enemyindex, i, skillID); + } + break; + case 2: + for( i=0; i<7; i++){ + int skillarray, skillID, Ri; + Ri = RAND( 0, arraysizeof( BattleERSkill2) - 1 ); + skillID = BattleERSkill2[Ri]; + skillarray = PETSKILL_getPetskillArray( skillID); + if( PETSKILL_CHECKINDEX( skillarray) == FALSE ){ + CHAR_setPetSkill( enemyindex, i, 1); + //andy_log + //print("ANDY *EnemyRandowSetSkill( ) skillID:%d array:%d err \n", + //skillID, skillarray ); + continue; + } + CHAR_setPetSkill( enemyindex, i, skillID); + } + break; + default : return; + break; + } + +} + +int BATTLE_CreateVsEnemyNew( int charaindex, int npcindex, int *table ) +{ + int battleindex, iRet = 0, enemyindex, i, pindex; + int fd, field_no, baselevel = 0; + int skillType=0; + int EnemyList[20]; + + int *enemytable = table; + + if( CHAR_CHECKINDEX( charaindex ) == FALSE )return BATTLE_ERR_CHARAINDEX; +#ifdef _PLAYER_NPC + if(CHAR_getInt( charaindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER) +#endif +// if(CHAR_getInt( charaindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER) +{ +#ifdef _STREET_VENDOR + // ̯вɽս + if( CHAR_getWorkInt(charaindex,CHAR_WORKSTREETVENDOR) > -1) return BATTLE_ERR_END; +#endif + +#ifdef _ANGEL_SUMMON // װʹﲻ + if( CHAR_getWorkInt(charaindex,CHAR_WORKANGELMODE) == TRUE ) return BATTLE_ERR_END; +#endif +} + if( CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE ) != BATTLE_CHARMODE_NONE ){ + CHAR_talkToCli( charaindex, -1, "", CHAR_COLORYELLOW ); + return BATTLE_ERR_ALREADYBATTLE; + } + battleindex = BATTLE_CreateBattle(charaindex); + if( battleindex < 0 )return BATTLE_ERR_NOTASK; + + if( CHAR_CHECKINDEX( npcindex) ){ + skillType = CHAR_getWorkInt( npcindex, CHAR_NPCWORKINT11); + } + + + field_no = BATTLE_getBattleFieldNo( + CHAR_getInt( charaindex, CHAR_FLOOR ) , + CHAR_getInt( charaindex, CHAR_X ) , + CHAR_getInt( charaindex, CHAR_Y ) ); + if( field_no > BATTLE_MAP_MAX || field_no < 0 ){ + field_no = RAND( 0, BATTLE_MAP_MAX ); + } + + BattleArray[battleindex].Side[0].type = BATTLE_S_TYPE_PLAYER; + BattleArray[battleindex].Side[1].type = BATTLE_S_TYPE_ENEMY; + BattleArray[battleindex].leaderindex = charaindex; + BattleArray[battleindex].type = BATTLE_TYPE_P_vs_E; + BattleArray[battleindex].createindex = npcindex; + BattleArray[battleindex].field_no = field_no; + BattleArray[battleindex].BattleFloor = CHAR_getInt( charaindex, CHAR_FLOOR ); + + BattleArray[battleindex].Side[0].flg &= ~BSIDE_FLG_HELP_OK; + + if( CHAR_CHECKINDEX( npcindex) ){ + if(CHAR_getInt( npcindex, CHAR_LV )>1){ + baselevel = CHAR_getInt( npcindex, CHAR_LV ); + } + CHAR_setWorkInt( npcindex, CHAR_WORKBATTLEINDEX, battleindex ); + }else if( npcindex == -1 ){ + enemytable = ENEMY_getEnemy( charaindex, + CHAR_getInt( charaindex, CHAR_X), + CHAR_getInt( charaindex, CHAR_Y)); + } + + BattleArray[battleindex].norisk = 0; + if( enemytable == NULL ) { + iRet = BATTLE_ERR_NOENEMY; + goto BATTLE_CreateVsEnemy_End; + } + + for( i = 0; *(enemytable+i)!= -1 && i < arraysizeof( EnemyList )-1; i ++ ){ + EnemyList[i] = *(enemytable+i); + } + EnemyList[i] = -1; + +#ifdef _BATTLE_TIMESPEED + fd = getfdFromCharaIndex( charaindex ); + BattleArray[battleindex].CreateTime = time(NULL); + BattleArray[battleindex].flgTime = 200; // 1/100 sec +#endif + for( i = 0; EnemyList[i] != -1; i ++ ){ + int work; + enemyindex = ENEMY_createEnemy( EnemyList[i], baselevel ); + + if( !CHAR_CHECKINDEX( enemyindex ) ){ + iRet = BATTLE_ERR_NOENEMY; + goto BATTLE_CreateVsEnemy_End; + } + CHAR_setInt(enemyindex, CHAR_WHICHTYPE, CHAR_TYPEENEMY); + if( skillType > 0 ){ + //int ENEMY_RandomChange( int enemyindex, int tempno ){ + BATTLE_EnemyRandowSetSkill( enemyindex, skillType); + } +#ifdef _ALLBLUES_LUA_1_9 + SetBattleEnmeyFunction(npcindex, enemyindex, i); +#endif + + if( ( iRet = BATTLE_NewEntry( enemyindex, battleindex, 1 ) ) ){ + goto BATTLE_CreateVsEnemy_End; + } + if( CHAR_getInt( enemyindex, CHAR_DUELPOINT ) > 0 ){ + BattleArray[battleindex].dpbattle = 1; + } + work = CHAR_getInt( enemyindex, CHAR_BASEBASEIMAGENUMBER ); + if( 100466 <= work && work <= 100471 ){ + CHAR_setWorkInt( enemyindex, CHAR_WORKBATTLEFLG, + CHAR_getWorkInt( enemyindex, CHAR_WORKBATTLEFLG ) | CHAR_BATTLEFLG_ABIO ); + //print( "(%s)\n", CHAR_getUseName( enemyindex ) ); + } + } + + if( (iRet = BATTLE_PartyNewEntry( charaindex, battleindex, 0 ) ) ){ + goto BATTLE_CreateVsEnemy_End; + } + { + BATTLE_ENTRY *pEntry, EntryWork; + pEntry = BattleArray[battleindex].Side[1].Entry; + for( i = 0; i < 5; i ++ ){ + EntryWork = pEntry[i]; + pEntry[i] = pEntry[i+5]; + pEntry[i+5] = EntryWork; + pEntry[i].bid = i + SIDE_OFFSET; + pEntry[i+5].bid = i + 5 + SIDE_OFFSET; + } + } + +BATTLE_CreateVsEnemy_End:; + fd = getfdFromCharaIndex( charaindex); + if( iRet ){ + BATTLE_ExitAll( battleindex ); + BATTLE_DeleteBattle( battleindex ); + if( fd != -1 )lssproto_EN_send( fd, FALSE, field_no ); + }else{ +// if(npcindex > -1){ + if( fd != -1 ){ + if( BattleArray[battleindex].dpbattle ){ + lssproto_EN_send( fd, BATTLE_TYPE_DP_BATTLE, field_no ); + }else{ + lssproto_EN_send( fd, BATTLE_TYPE_BOSS_BATTLE, field_no ); + } + } else { +#ifdef _OFFLINE_SYSTEM + if(CHAR_getWorkInt( charaindex, CHAR_WORK_OFFLINE ) == 0) +#endif + { + BATTLE_ExitAll( battleindex ); + BATTLE_DeleteBattle( battleindex ); + return iRet; + } + } +// } + + for( i = 1; i < CHAR_PARTYMAX; i ++ ){ + pindex = CHAR_getWorkInt( charaindex, i + CHAR_WORKPARTYINDEX1 ); + if( CHAR_CHECKINDEX( pindex ) == FALSE )continue; + if( CHAR_getWorkInt( pindex, CHAR_WORKBATTLEMODE ) == BATTLE_CHARMODE_FINAL ) continue; + fd = getfdFromCharaIndex(pindex); + + if( fd != -1 ){ + lssproto_EN_send( fd, BATTLE_TYPE_BOSS_BATTLE, field_no ); + } + } + if( CHAR_getWorkInt( charaindex, CHAR_WORKACTION) != -1 ) { + CHAR_sendWatchEvent( + CHAR_getWorkInt( charaindex, CHAR_WORKOBJINDEX), + CHAR_ACTSTAND, + NULL, 0, FALSE); + CHAR_setWorkInt( charaindex, CHAR_WORKACTION, -1); + } + CHAR_sendBattleEffect( charaindex, ON); + for( i = 1; i < CHAR_PARTYMAX; i ++ ){ + pindex = CHAR_getWorkInt( charaindex, i + CHAR_WORKPARTYINDEX1 ); + if( CHAR_CHECKINDEX( pindex ) == FALSE )continue; + if( CHAR_getWorkInt( pindex, CHAR_WORKACTION) != -1 ) { + CHAR_sendWatchEvent( + CHAR_getWorkInt( pindex, CHAR_WORKOBJINDEX), + CHAR_ACTSTAND, + NULL, 0, FALSE); + CHAR_setWorkInt( pindex, CHAR_WORKACTION, -1); + } + + CHAR_sendBattleEffect( pindex, ON); + } + } + + return iRet; +} + +int BATTLE_CreateVsEnemy( int charaindex, int mode, int npcindex ) +{ + int battleindex, iRet = 0, enemyindex, i, pindex; + int *enemytable = NULL, fd, field_no, baselevel = 0; + int skillType=0; + int EnemyList[20]; + + if( CHAR_CHECKINDEX( charaindex ) == FALSE )return BATTLE_ERR_CHARAINDEX; + +#ifdef _STREET_VENDOR + // ̯вɽս + if( CHAR_getWorkInt(charaindex,CHAR_WORKSTREETVENDOR) > -1) return BATTLE_ERR_END; +#endif + +#ifdef _ANGEL_SUMMON // װʹﲻ + if( CHAR_getWorkInt(charaindex,CHAR_WORKANGELMODE) == TRUE ) return BATTLE_ERR_END; +#endif + +#ifdef _PET_BUG + int petarray = CHAR_getInt( charaindex, CHAR_DEFAULTPET); + if(petarray>-1){ + int petindex = CHAR_getCharPet( charaindex, petarray); + if(CHAR_getInt(petindex,CHAR_VITAL)>=getPetPoint(0)*20 || CHAR_getInt(petindex,CHAR_STR)>=getPetPoint(1)*80 || CHAR_getInt(petindex,CHAR_TOUGH)>=getPetPoint(2)*80 || CHAR_getInt(petindex,CHAR_DEX)>=getPetPoint(3)*100) + return BATTLE_ERR_END; + } +#endif + + if( CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE ) != BATTLE_CHARMODE_NONE ){ + CHAR_talkToCli( charaindex, -1, "", CHAR_COLORYELLOW ); + return BATTLE_ERR_ALREADYBATTLE; + } +#ifdef _BATTLEMAP_CTRL + int j; + for(j=0;j<10;j++){ + if(getBattleTimeFloor(j)==-1) break; + if(CHAR_getInt(charaindex,CHAR_FLOOR)==getBattleTimeFloor(j) && CHAR_getPartyNum(charaindex)<=getBattleTimePlayerNum(j)){ + time_t timep; + struct tm *p; + time(&timep); + p=localtime(&timep); /*ȡõʱ*/ + timep = mktime(p); + if(timep-CHAR_getWorkInt(charaindex,CHAR_WORKBATTLETIME)<=getBattleTimeSec(j)){ + return BATTLE_ERR_END; + }else{ + CHAR_setWorkInt(charaindex,CHAR_WORKBATTLETIME,timep); + break; + } + } + } +#endif + battleindex = BATTLE_CreateBattle( charaindex ); + if( battleindex < 0 )return BATTLE_ERR_NOTASK; +#ifdef _WAN_FIX + CHAR_setWorkInt(charaindex,CHAR_WORKBATTLEPROTYPE,1); +#endif + if( CHAR_CHECKINDEX( npcindex) ){ + skillType = CHAR_getWorkInt( npcindex, CHAR_NPCWORKINT11); + } + + field_no = BATTLE_getBattleFieldNo( + CHAR_getInt( charaindex, CHAR_FLOOR ) , + CHAR_getInt( charaindex, CHAR_X ) , + CHAR_getInt( charaindex, CHAR_Y ) ); + if( field_no > BATTLE_MAP_MAX || field_no < 0 ){ + field_no = RAND( 0, BATTLE_MAP_MAX ); + } + + BattleArray[battleindex].Side[0].type = BATTLE_S_TYPE_PLAYER; + BattleArray[battleindex].Side[1].type = BATTLE_S_TYPE_ENEMY; + BattleArray[battleindex].leaderindex = charaindex; + BattleArray[battleindex].type = BATTLE_TYPE_P_vs_E; + BattleArray[battleindex].createindex = npcindex; + BattleArray[battleindex].field_no = field_no; + //andy_edit 2002/10/23 + /* + if( (iRet = BATTLE_PartyNewEntry( charaindex, battleindex, 0 ) ) ){ + goto BATTLE_CreateVsEnemy_End; + } + */ + BattleArray[battleindex].Side[0].flg &= ~BSIDE_FLG_HELP_OK; + if( mode == 0 ) { + enemytable = ENEMY_getEnemy( charaindex, + CHAR_getInt( charaindex, CHAR_X), + CHAR_getInt( charaindex, CHAR_Y)); + }else if( mode == 1 ) { + enemytable = NPC_Util_getEnemy( npcindex, charaindex); + }else if( mode == 2 ) { + enemytable = Doujyou_GetEnemy( npcindex, charaindex ); + baselevel = CHAR_getInt( npcindex, CHAR_LV ); + BattleArray[battleindex].norisk = 1; + } + if( enemytable == NULL ) { + iRet = BATTLE_ERR_NOENEMY; + goto BATTLE_CreateVsEnemy_End; + } + + for( i = 0; *(enemytable+i)!= -1 && i < arraysizeof( EnemyList )-1; i ++ ){ + EnemyList[i] = *(enemytable+i); + } + EnemyList[i] = -1; + +#ifdef _BATTLE_TIMESPEED + fd = getfdFromCharaIndex( charaindex ); + BattleArray[battleindex].CreateTime = time(NULL); + BattleArray[battleindex].flgTime = 200; // 1/100 sec +#endif + for( i = 0; EnemyList[i] != -1; i ++ ){ + int work; + enemyindex = ENEMY_createEnemy( EnemyList[i], baselevel ); + if( skillType > 0 ){ + //int ENEMY_RandomChange( int enemyindex, int tempno ){ + BATTLE_EnemyRandowSetSkill( enemyindex, skillType); + } + if( enemyindex < 0 ){ + iRet = BATTLE_ERR_NOENEMY; + goto BATTLE_CreateVsEnemy_End; + } + + if( mode == 2 ){ + if( i == 0 ){ + CHAR_setInt( enemyindex, CHAR_BASEBASEIMAGENUMBER, + CHAR_getInt( npcindex, CHAR_BASEBASEIMAGENUMBER ) ); + CHAR_setInt( enemyindex, CHAR_BASEIMAGENUMBER, + CHAR_getInt( npcindex, CHAR_BASEBASEIMAGENUMBER ) ); + CHAR_setChar( enemyindex, CHAR_NAME, + CHAR_getChar( npcindex, CHAR_NAME ) ); + CHAR_complianceParameter( enemyindex ); + } + } + if( ( iRet = BATTLE_NewEntry( enemyindex, battleindex, 1 ) ) ){ + goto BATTLE_CreateVsEnemy_End; + } + if( CHAR_getInt( enemyindex, CHAR_DUELPOINT ) > 0 ){ + BattleArray[battleindex].dpbattle = 1; + } + work = CHAR_getInt( enemyindex, CHAR_BASEBASEIMAGENUMBER ); + if( 100466 <= work && work <= 100471 ){ + CHAR_setWorkInt( enemyindex, CHAR_WORKBATTLEFLG, + CHAR_getWorkInt( enemyindex, CHAR_WORKBATTLEFLG ) | CHAR_BATTLEFLG_ABIO ); + //print( "(%s)\n", CHAR_getUseName( enemyindex ) ); + } + } + //andy_edit 2002/10/23 + if( (iRet = BATTLE_PartyNewEntry( charaindex, battleindex, 0 ) ) ){ + goto BATTLE_CreateVsEnemy_End; + } + { + BATTLE_ENTRY *pEntry, EntryWork; + pEntry = BattleArray[battleindex].Side[1].Entry; + for( i = 0; i < 5; i ++ ){ + EntryWork = pEntry[i]; + pEntry[i] = pEntry[i+5]; + pEntry[i+5] = EntryWork; + pEntry[i].bid = i + SIDE_OFFSET; + pEntry[i+5].bid = i + 5 + SIDE_OFFSET; + } + } + +BATTLE_CreateVsEnemy_End:; + fd = getfdFromCharaIndex( charaindex); + + if( iRet ){ + BATTLE_ExitAll( battleindex ); + BATTLE_DeleteBattle( battleindex ); + if( fd != -1 )lssproto_EN_send( fd, FALSE, field_no ); + }else{ + if( fd != -1 ){ + if( BattleArray[battleindex].dpbattle ){ + lssproto_EN_send( fd, BATTLE_TYPE_DP_BATTLE, field_no ); + }else{ + if( mode == 1 ){ + lssproto_EN_send( fd, BATTLE_TYPE_BOSS_BATTLE, field_no ); + }else{ + lssproto_EN_send( fd, BattleArray[battleindex].type, field_no ); + } + } + }else { +#ifdef _OFFLINE_SYSTEM + if(CHAR_getWorkInt( charaindex, CHAR_WORK_OFFLINE ) == 0) +#endif + { + BATTLE_ExitAll( battleindex ); + BATTLE_DeleteBattle( battleindex ); + return iRet; + } + } + + for( i = 1; i < CHAR_PARTYMAX; i ++ ){ + pindex = CHAR_getWorkInt( charaindex, i + CHAR_WORKPARTYINDEX1 ); + if( CHAR_CHECKINDEX( pindex ) == FALSE )continue; + if( CHAR_getWorkInt( pindex, CHAR_WORKBATTLEMODE ) == + BATTLE_CHARMODE_FINAL ) continue; + fd = getfdFromCharaIndex(pindex); + if( fd != -1 ){ + if( mode == 1 ){ + lssproto_EN_send( fd, BATTLE_TYPE_BOSS_BATTLE, field_no ); + }else{ + lssproto_EN_send( fd, BattleArray[battleindex].type, field_no ); + } + } + } + if( CHAR_getWorkInt( charaindex, CHAR_WORKACTION) != -1 ) { + CHAR_sendWatchEvent( + CHAR_getWorkInt( charaindex, CHAR_WORKOBJINDEX), + CHAR_ACTSTAND, + NULL, 0, FALSE); + CHAR_setWorkInt( charaindex, CHAR_WORKACTION, -1); + } + CHAR_sendBattleEffect( charaindex, ON); + for( i = 1; i < CHAR_PARTYMAX; i ++ ){ + pindex = CHAR_getWorkInt( charaindex, i + CHAR_WORKPARTYINDEX1 ); + if( CHAR_CHECKINDEX( pindex ) == FALSE )continue; + if( CHAR_getWorkInt( pindex, CHAR_WORKACTION) != -1 ) { + CHAR_sendWatchEvent( + CHAR_getWorkInt( pindex, CHAR_WORKOBJINDEX), + CHAR_ACTSTAND, + NULL, 0, FALSE); + CHAR_setWorkInt( pindex, CHAR_WORKACTION, -1); + } + CHAR_sendBattleEffect( pindex, ON); + } + } + return iRet; +} + +int BATTLE_CreateVsPlayer( int charaindex0, int charaindex1 ) +{ + int battleindex, pindex, field_no, + i, j, charaindex[2], + parent[2], fd, + iRet = 0; + + if( CHAR_CHECKINDEX( charaindex0 ) == FALSE )return BATTLE_ERR_CHARAINDEX; + if( CHAR_CHECKINDEX( charaindex1 ) == FALSE )return BATTLE_ERR_CHARAINDEX; + + if( CHAR_getWorkInt( charaindex0, CHAR_WORKBATTLEMODE ) != BATTLE_CHARMODE_NONE ){ + CHAR_talkToCli( charaindex0, -1, "", CHAR_COLORYELLOW ); + CHAR_talkToCli( charaindex1, -1, "", CHAR_COLORYELLOW ); + return BATTLE_ERR_ALREADYBATTLE; + } + if( CHAR_getWorkInt( charaindex1, CHAR_WORKBATTLEMODE ) != BATTLE_CHARMODE_NONE ){ + CHAR_talkToCli( charaindex0, -1, "", CHAR_COLORYELLOW ); + CHAR_talkToCli( charaindex1, -1, "", CHAR_COLORYELLOW ); + return BATTLE_ERR_ALREADYBATTLE; + } + +#ifdef _BATTLEEND_FIX + if(getBattleEndMode()==1){ + int myfloor=CHAR_getInt(charaindex0,CHAR_FLOOR); + if(myfloor==getBattleFloor(1) || + myfloor==getBattleFloor(2) || + myfloor==getBattleFloor(3) || + myfloor==getBattleFloor(4) || + myfloor==getBattleFloor(5) || + myfloor==1042 || + myfloor==2032 || + myfloor==3032 || + myfloor==4032) + { + time_t timep; + struct tm *p; + time(&timep); + p=localtime(&timep); /*ȡõʱ*/ + timep = mktime(p); + if(CHAR_getWorkInt(charaindex1,CHAR_WORKBALLTELENDTIME)+120>timep){ + char bmsg[256]; + sprintf(bmsg,"Է㱣Уʣʱ䣺%d룬Էƶ",CHAR_getWorkInt(charaindex1,CHAR_WORKBALLTELENDTIME)+120-timep); + CHAR_talkToCli( charaindex0, -1, bmsg, CHAR_COLORYELLOW ); + return BATTLE_ERR_ALREADYBATTLE; + } + } + } +#endif +#ifdef _PET_BUG + int petindex; + int petarray0 = CHAR_getInt( charaindex0, CHAR_DEFAULTPET); + int petarray1 = CHAR_getInt( charaindex1, CHAR_DEFAULTPET); + if(petarray0>-1){ + petindex = CHAR_getCharPet( charaindex0, petarray0); + if(CHAR_getInt(petindex,CHAR_VITAL)>=getPetPoint(0)*20 || CHAR_getInt(petindex,CHAR_STR)>=getPetPoint(1)*80 || CHAR_getInt(petindex,CHAR_TOUGH)>=getPetPoint(2)*80 || CHAR_getInt(petindex,CHAR_DEX)>=getPetPoint(3)*100) + return BATTLE_ERR_END; + } + if(petarray1>-1){ + petindex = CHAR_getCharPet( charaindex1, petarray1); + if(CHAR_getInt(petindex,CHAR_VITAL)>=getPetPoint(0)*20 || CHAR_getInt(petindex,CHAR_STR)>=getPetPoint(1)*80 || CHAR_getInt(petindex,CHAR_TOUGH)>=getPetPoint(2)*80 || CHAR_getInt(petindex,CHAR_DEX)>=getPetPoint(3)*100) + return BATTLE_ERR_END; + } +#endif + + field_no = BATTLE_getBattleFieldNo( + CHAR_getInt( charaindex0, CHAR_FLOOR ) , + CHAR_getInt( charaindex0, CHAR_X ), + CHAR_getInt( charaindex0, CHAR_Y ) ); + + int tmpi = RAND(1,10); + if(tmpi<=5){ + charaindex[0] = charaindex1; + charaindex[1] = charaindex0; + }else{ + charaindex[0] = charaindex0; + charaindex[1] = charaindex1; + } + charaindex0 = charaindex[0]; + charaindex1 = charaindex[1]; + //charaindex[0] = charaindex0; + //charaindex[1] = charaindex1; + for( j = 0; j < 2; j ++ ){ + if( CHAR_getWorkInt( charaindex[j], CHAR_WORKBATTLEMODE ) != 0 ){ + return BATTLE_ERR_ALREADYBATTLE; + } + } + for( j = 0; j < 2; j ++ ){ + if( CHAR_getWorkInt( charaindex[j], CHAR_WORKPARTYMODE ) == CHAR_PARTY_LEADER ){ + parent[j] = charaindex[j]; + }else + if( CHAR_getWorkInt( charaindex[j], CHAR_WORKPARTYMODE ) == CHAR_PARTY_CLIENT ){ + parent[j] = CHAR_getWorkInt( charaindex[j], CHAR_WORKPARTYINDEX1 ); + }else{ + parent[j] = -1; + } + } + if( parent[0] != -1 && parent[0] == parent[1] ){ + return BATTLE_ERR_SAMEPARTY; + } + battleindex = BATTLE_CreateBattle(charaindex0 ); + if( battleindex < 0 )return BATTLE_ERR_NOTASK; + + if(CHAR_getInt(charaindex0,CHAR_FLOOR)==1042){ + sprintf(afmwar,"%s%d,",afmwar,battleindex); + afmwarnum++; + }else if(CHAR_getInt(charaindex0,CHAR_FLOOR)==2032){ + sprintf(bfmwar,"%s%d,",bfmwar,battleindex); + bfmwarnum++; + }else if(CHAR_getInt(charaindex0,CHAR_FLOOR)==3032){ + sprintf(cfmwar,"%s%d,",cfmwar,battleindex); + cfmwarnum++; + }else if(CHAR_getInt(charaindex0,CHAR_FLOOR)==4032){ + sprintf(dfmwar,"%s%d,",dfmwar,battleindex); + dfmwarnum++; + }else if(CHAR_getInt(charaindex0,CHAR_FLOOR)==20000){ + sprintf(efmwar,"%s%d,",efmwar,battleindex); + efmwarnum++; + }else if(CHAR_getInt(charaindex0,CHAR_FLOOR)==51000){ + sprintf(ffmwar,"%s%d,",ffmwar,battleindex); + ffmwarnum++; + } +#ifdef _WAN_FIX + CHAR_setWorkInt(charaindex0,CHAR_WORKBATTLEPROTYPE,1); + CHAR_setWorkInt(charaindex1,CHAR_WORKBATTLEPROTYPE,1); +#endif + BattleArray[battleindex].Side[0].type = BATTLE_S_TYPE_PLAYER; + BattleArray[battleindex].Side[1].type = BATTLE_S_TYPE_PLAYER; + BattleArray[battleindex].leaderindex = charaindex0; +#ifdef _AUTO_PK + memset(BattleArray[battleindex].leadercdkey, 0, sizeof(BattleArray[battleindex].leadercdkey)); + memset(BattleArray[battleindex].leadername, 0, sizeof(BattleArray[battleindex].leadername)); + memset(BattleArray[battleindex].rivalcdkey, 0, sizeof(BattleArray[battleindex].rivalcdkey)); + memset(BattleArray[battleindex].rivalname, 0, sizeof(BattleArray[battleindex].rivalname)); + strcpysafe(BattleArray[battleindex].leadercdkey,sizeof(BattleArray[battleindex].leadercdkey),CHAR_getChar(charaindex0,CHAR_CDKEY)); + strcpysafe(BattleArray[battleindex].leadername,sizeof(BattleArray[battleindex].leadername),CHAR_getChar(charaindex0,CHAR_NAME)); + BattleArray[battleindex].rivalindex = charaindex1; + strcpysafe(BattleArray[battleindex].rivalcdkey,sizeof(BattleArray[battleindex].rivalcdkey),CHAR_getChar(charaindex1,CHAR_CDKEY)); + strcpysafe(BattleArray[battleindex].rivalname,sizeof(BattleArray[battleindex].rivalname),CHAR_getChar(charaindex1,CHAR_NAME)); +#endif + BattleArray[battleindex].type = BATTLE_TYPE_P_vs_P; + BattleArray[battleindex].dpbattle = 1; + BattleArray[battleindex].field_no = field_no; +#ifdef _BATTLE_TIMESPEED + BattleArray[battleindex].CreateTime = time(NULL); +#endif + for( j = 0; j < 2; j ++ ){ + iRet = BATTLE_PartyNewEntry( charaindex[j], battleindex, j ); + if( iRet ){ + goto BATTLE_CreateVsPlayer_End; + } + BattleArray[battleindex].Side[j].flg &= ~BSIDE_FLG_HELP_OK; + } +BATTLE_CreateVsPlayer_End:; + if( iRet ){ + BATTLE_ExitAll( battleindex ); + BATTLE_DeleteBattle( battleindex ); + fd = getfdFromCharaIndex(charaindex[0]); + if( fd != -1 )lssproto_EN_send( fd, FALSE, field_no ); + }else{ + for( j = 0; j < 2; j ++ ){ + fd = getfdFromCharaIndex(charaindex[j]); + if( fd != -1 )lssproto_EN_send( fd, BattleArray[battleindex].type, field_no ); + if( CHAR_getWorkInt( charaindex[j], CHAR_WORKACTION) != -1 ) { + CHAR_sendWatchEvent( + CHAR_getWorkInt( charaindex[j], CHAR_WORKOBJINDEX), + CHAR_ACTSTAND, + NULL, 0, FALSE); + CHAR_setWorkInt( charaindex[j], CHAR_WORKACTION, -1); + + } + CHAR_sendBattleEffect( charaindex[j], ON); + for( i = 1; i < CHAR_PARTYMAX; i ++ ){ + pindex = CHAR_getWorkInt( charaindex[j], i + CHAR_WORKPARTYINDEX1 ); + if( CHAR_CHECKINDEX( pindex ) == FALSE )continue; + if( CHAR_getWorkInt( pindex, CHAR_WORKBATTLEMODE ) == + BATTLE_CHARMODE_FINAL ) continue; + + fd = getfdFromCharaIndex(pindex); + if( fd != -1 )lssproto_EN_send( fd, BattleArray[battleindex].type, field_no ); + if( CHAR_getWorkInt( pindex, CHAR_WORKACTION) != -1 ) { + CHAR_sendWatchEvent( + CHAR_getWorkInt( pindex, CHAR_WORKOBJINDEX), + CHAR_ACTSTAND, + NULL, 0, FALSE); + CHAR_setWorkInt( pindex, CHAR_WORKACTION, -1); + + } + CHAR_sendBattleEffect( pindex, ON ); + } + } + } + return iRet; +} + + +//********************************************************* +// +// ëܰѣݱɬ +// +int BATTLE_WatchLink( int topbattleindex, int battleindex ) +// +// +//********************************************************* +{ + BATTLE *pWork, *pTop; + + if( BATTLE_CHECKINDEX( battleindex ) == FALSE ){ + //fprint( "err:battle index (%d)\n", battleindex ); + return FALSE; + } + if( BATTLE_CHECKINDEX( topbattleindex ) == FALSE ){ + //fprint( "err:battle index (%d)\n", topbattleindex ); + return FALSE; + } + + pTop = &BattleArray[topbattleindex]; + + if( BATTLE_CHECKADDRESS( pTop ) == FALSE ){ + //fprint( "err:battle address (%p)\n", pTop ); + return FALSE; + } + + + pWork = pTop->pNext; // ʧ + + if( pWork ){ + if( BATTLE_CHECKADDRESS( pWork ) == FALSE ){ + //fprint( "err:battle address (%p)\n", pWork ); + return FALSE; + } + } + + // ë󡼰ݱ + pTop->pNext = &BattleArray[battleindex]; + // мëɬ + BattleArray[battleindex].pBefore = pTop; + // мëɬ + BattleArray[battleindex].pNext = pWork; + // ݼ󡷴 + if( pWork ){ + pWork->pBefore = &BattleArray[battleindex]; + } + return TRUE; +} + +//********************************************************* +// +// ë繴 +// +int BATTLE_WatchUnLink( int battleindex ) +// +// +//********************************************************* +{ + BATTLE *pTop; + + if( BATTLE_CHECKINDEX( battleindex ) == FALSE ){ + //fprint( "err:battle index (%d)\n", battleindex ); + return FALSE; + } + + // ë󡼰 + pTop = BattleArray[battleindex].pBefore; + + if( pTop ){ + if( BATTLE_CHECKADDRESS( pTop ) == FALSE ){ + //fprint( "err:battle address (%p)\n", pTop ); + }else{ + // ئئ + pTop->pNext = BattleArray[battleindex].pNext; + } + } + if( BattleArray[battleindex].pNext ){ + if( BATTLE_CHECKADDRESS( BattleArray[battleindex].pNext ) == FALSE ){ + //fprint( "err:battle address (%p)\n", BattleArray[battleindex].pNext ); + }else{ + BattleArray[battleindex].pNext->pBefore = pTop; + } + } + // мëɬ + BattleArray[battleindex].pBefore = NULL; + // мﷴ + BattleArray[battleindex].pNext = NULL; + + return TRUE; + +} + + +//********************************************************* +// +// ñë +// +int BATTLE_CreateForWatcher( int charaindex, int topbattleindex ) +// +// Ի BATTLE_ERR +// +//********************************************************* +{ + int battleindex, field_no , pindex, + i, fd, + iRet = 0; + + // ɷ¶ + if( CHAR_CHECKINDEX( charaindex ) == FALSE )return BATTLE_ERR_CHARAINDEX; + if( CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE ) != BATTLE_CHARMODE_NONE ){ + CHAR_talkToCli( charaindex, -1, "", CHAR_COLORYELLOW ); + return BATTLE_ERR_ALREADYBATTLE; + } + + // ƥ ƥئо + if( CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE ) != 0 ){ + return BATTLE_ERR_ALREADYBATTLE; + } + + if(CHAR_getInt(charaindex,CHAR_FLOOR)==20000){ + CHAR_talkToCli( charaindex, -1, "PKУڹս", CHAR_COLORYELLOW ); + return BATTLE_ERR_ALREADYBATTLE; + } + + // ë + battleindex = BATTLE_CreateBattle(charaindex ); + if( battleindex < 0 )return BATTLE_ERR_NOTASK;// έƥئ׾޷¡ +#ifdef _WAN_FIX + CHAR_setWorkInt(charaindex,CHAR_WORKBATTLEPROTYPE,1); +#endif + // ռɷƥؤ£ + BattleArray[battleindex].Side[0].type = BATTLE_S_TYPE_PLAYER; + // 𵤴ƥؤ£ + BattleArray[battleindex].Side[1].type = BATTLE_S_TYPE_PLAYER; + // ĸë + BattleArray[battleindex].leaderindex = charaindex; + // + BattleArray[battleindex].type = BATTLE_TYPE_WATCH; + BattleArray[battleindex].mode = BATTLE_MODE_WATCHBC; + // ū į + field_no = BattleArray[battleindex].field_no = BattleArray[topbattleindex].field_no; + BattleArray[battleindex].turn = BattleArray[topbattleindex].turn; + + // ͽ + if( BATTLE_WatchLink( topbattleindex, battleindex ) == FALSE ){ + //fprint( "err:battle link error(%d),(%d)\n", + //topbattleindex, battleindex ); + // ޷¡ ƥ GOTO + goto BATTLE_CreateForWatcher_End; + } + + // ɡ ū޼ + iRet = BATTLE_WatchPartyNewEntry( charaindex, battleindex, 0 ); + if( iRet ){ + // ޷¡ ƥ GOTO + goto BATTLE_CreateForWatcher_End; + } + + +// ޷¡ʲ +BATTLE_CreateForWatcher_End:; + + if( iRet ){ // ޷¡ؤ + // 幻 + BATTLE_ExitAll( battleindex ); + // ʹ + BATTLE_DeleteBattle( battleindex ); + fd = getfdFromCharaIndex( charaindex ); + if( fd != -1 )lssproto_EN_send( fd, FALSE, field_no ); + }else{ + fd = getfdFromCharaIndex( charaindex ); + /* ޼ ë */ + if( fd != -1 )lssproto_EN_send( fd, BattleArray[battleindex].type, field_no ); + /* к̡˪ */ + if( CHAR_getWorkInt( charaindex, CHAR_WORKACTION) != -1 ) { + CHAR_sendWatchEvent( + CHAR_getWorkInt( charaindex, CHAR_WORKOBJINDEX), + CHAR_ACTSTAND, + NULL, 0, FALSE); + CHAR_setWorkInt( charaindex, CHAR_WORKACTION, -1); + } + /* ʧ CA˪ */ + CHAR_sendBattleWatch( CHAR_getWorkInt( charaindex, CHAR_WORKOBJINDEX ), ON); + + // ޱ + for( i = 1; i < CHAR_PARTYMAX; i ++ ){ + pindex = CHAR_getWorkInt( charaindex, i + CHAR_WORKPARTYINDEX1 ); + if( CHAR_CHECKINDEX( pindex ) == FALSE )continue; + // ޼ƥ廯ئئ˪ئ + // FINAL 󡼰 έ + if( CHAR_getWorkInt( pindex, CHAR_WORKBATTLEMODE ) == + BATTLE_CHARMODE_FINAL ) continue; + + fd = getfdFromCharaIndex(pindex); + /* ޼ */ + if( fd != -1 )lssproto_EN_send( fd, BattleArray[battleindex].type, field_no ); + /* к̡˪ */ + if( CHAR_getWorkInt( pindex, CHAR_WORKACTION) != -1 ) { + CHAR_sendWatchEvent( + CHAR_getWorkInt( pindex, CHAR_WORKOBJINDEX), + CHAR_ACTSTAND, + NULL, 0, FALSE); + CHAR_setWorkInt( pindex, CHAR_WORKACTION, -1); + } + /* ʧ CA˪ */ + CHAR_sendBattleWatch( CHAR_getWorkInt( charaindex, CHAR_WORKOBJINDEX ), ON); + } +/* + print( "(%s)Ϊо֡", + CHAR_getChar( charaindex, CHAR_NAME ) ); +*/ + } + + + return iRet; +} + + + + + + +/*------------------------------------------------------------ + * ë Ӭ + ------------------------------------------------------------*/ +void BATTLE_WatchStop( int charaindex ) +{ + int battleindex; + + battleindex = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEINDEX ); + + if( BATTLE_CHECKINDEX( battleindex ) == FALSE )return; + // ƽҷ + BATTLE_Exit( charaindex, battleindex ); + // ɡ ū + CHAR_DischargePartyNoMsg( charaindex ); + + CHAR_talkToCli( charaindex, -1, + "սֹ", CHAR_COLORYELLOW ); + + lssproto_B_send( getfdFromCharaIndex( charaindex ), "BU" ); + +} + + + + + + + + + +//************************************************************* +// +// ƥ Ӽɷ¶ëٴƻ +// +void BATTLE_TurnParam( + int charaindex, + int fixkind, + int mod, + int last +) +// +// +//************************************************************* +{ + int modparam, fixparam, lastparam; + + if( fixkind == -1 ){ + fixparam = 0; // 绥 + }else{ + fixparam = CHAR_getWorkInt( charaindex, fixkind ); + } + if( last == -1 ){ + lastparam = 0; + }else{ + lastparam = CHAR_getWorkInt( charaindex, last ); + } + modparam = CHAR_getWorkInt( charaindex, mod ); + // ƥ ëέ + // ëٴƻ + + // ᷴ MODPARAM ëߡӼƻ + modparam *= 0.8; + CHAR_setWorkInt( charaindex, mod, modparam ); + + // + if( last != -1 ){ + CHAR_setWorkInt( + charaindex, + last, + lastparam + modparam * 0.01 ); + } + +} + +void BATTLE_AttReverse( int charaindex ) +{ + int earth, water, fire, wind; + //ttom start because the second had this + if( CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEFLG ) & CHAR_BATTLEFLG_REVERSE ){ + CHAR_setWorkInt(charaindex,CHAR_WORKBATTLEREVERSE,1); + // ƻئݳ + }else{ + // ƻئмƥ + return; + } + //ttom end + earth = CHAR_getWorkInt( charaindex, CHAR_WORKFIXEARTHAT ); + water = CHAR_getWorkInt( charaindex, CHAR_WORKFIXWATERAT ); + fire = CHAR_getWorkInt( charaindex, CHAR_WORKFIXFIREAT ); + wind = CHAR_getWorkInt( charaindex, CHAR_WORKFIXWINDAT ); + + CHAR_setWorkInt( charaindex, CHAR_WORKFIXEARTHAT, fire ); + CHAR_setWorkInt( charaindex, CHAR_WORKFIXWATERAT, wind ); + CHAR_setWorkInt( charaindex, CHAR_WORKFIXFIREAT, earth ); + CHAR_setWorkInt( charaindex, CHAR_WORKFIXWINDAT, water ); +} + +void BATTLE_PreCommandSeq( int battleindex ) +{ + BATTLE_ENTRY *pEntry; + BATTLE *pBattle; + int i, j, charaindex; + BATTLE_CharSendAll( battleindex ); + BATTLE_CharaBackUp( battleindex ); + BattleArray[battleindex].timer = NowTime.tv_sec; + BATTLE_AllCharaCWaitSet( battleindex ); + BATTLE_ActSettingSend( battleindex ); + BattleArray[battleindex].flg |= BATTLE_FLG_FREEDP; + pBattle = &BattleArray[battleindex]; + for( j = 0; j < 2; j ++ ){ + int flg; + pEntry = pBattle->Side[j].Entry; + for( i = 0; i < BATTLE_ENTRY_MAX; i ++ ){ + pEntry[i].guardian = -1; + charaindex = pEntry[i].charaindex; + if( CHAR_CHECKINDEX( charaindex ) == FALSE )continue; + flg = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEFLG ); +//ttom the second only one //flg &= ~CHAR_BATTLEFLG_GUARDIAN; + flg &= ~CHAR_BATTLEFLG_GUARDIAN; + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEFLG, flg ); + if( CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM1 ) == BATTLE_COM_S_EARTHROUND0 ) continue; + + CHAR_complianceParameter( charaindex ); + BATTLE_TurnParam( charaindex, + CHAR_WORKFIXSTR, // + CHAR_WORKMODATTACK, + CHAR_WORKATTACKPOWER + ); + BATTLE_TurnParam( charaindex, + CHAR_WORKFIXTOUGH, // + CHAR_WORKMODDEFENCE, + CHAR_WORKDEFENCEPOWER + ); + BATTLE_TurnParam( charaindex, + CHAR_WORKFIXDEX, // ٶƽ + CHAR_WORKMODQUICK, + CHAR_WORKQUICK + ); + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER ){ + BATTLE_TurnParam( charaindex, + -1, + CHAR_WORKMODCHARM, // + CHAR_WORKFIXCHARM + ); + } + BATTLE_TurnParam( charaindex, + -1, // + CHAR_WORKMODCHARM, + -1 + ); + if( CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEFLG ) & CHAR_BATTLEFLG_REVERSE ){ + BATTLE_AttReverse( charaindex ); + } + } + } +} + + +//************************************************** +// +// Ѩг ݼ ľ +// +void BATTLE_PreWatchWaitSeq( int battleindex ) +// +// +//************************************************** +{ + // ƥݶ + BattleArray[battleindex].timer = NowTime.tv_sec; + // 幻ƹëѨ + BATTLE_AllCharaWatchWaitSet( battleindex ); +} +static int BATTLE_Init( int battleindex ) +{ + //DebugMainFunction="BATTLE_Init"; + BATTLE *pBattle; + int iRet = 0; + if( BATTLE_CHECKINDEX( battleindex ) == FALSE )return BATTLE_ERR_BATTLEINDEX; + pBattle = &BattleArray[battleindex]; + pBattle->mode = BATTLE_MODE_BATTLE; + iRet = BATTLE_SurpriseCheck( battleindex ); + if( iRet == 0 ){ + }else + if( iRet == 1 ){ + BattleArray[battleindex].Side[1].flg |= BSIDE_FLG_SURPRISE; + }else + if( iRet == 2 ){ + BattleArray[battleindex].Side[0].flg |= BSIDE_FLG_SURPRISE; + } + BATTLE_PreCommandSeq( battleindex ); + return 0; +} +int BATTLE_CountEntry( + int battleindex, + int side +) +{ + int i; + BATTLE_ENTRY *pEntry; + int cnt = 0; + + // ɷ¶ + if( BATTLE_CHECKSIDE( side ) == FALSE )return -BATTLE_ERR_PARAM; + if( BATTLE_CHECKINDEX( battleindex ) == FALSE )return -BATTLE_ERR_BATTLEINDEX; + + // ޼ + pEntry = BattleArray[battleindex].Side[side].Entry; + + for( i = 0; i < BATTLE_ENTRY_MAX; i ++ ){ + if( pEntry[i].charaindex != -1 ){ // ƽҷ» + cnt ++; + } + } + return cnt; +} + +static BOOL BATTLE_CommandWait( int battleindex, int side) +{ + int i, charaindex, BeOk=0; + BATTLE_ENTRY *pEntry; + BOOL iRet = TRUE; + BOOL TimeOut = FALSE; + if( BATTLE_CHECKSIDE( side ) == FALSE )return TRUE;//ֵǷںϷ Χ + if( BATTLE_CHECKINDEX( battleindex ) == FALSE )return TRUE; + if( BattleArray[battleindex].Side[side].type == BATTLE_S_TYPE_ENEMY ) return TRUE; + pEntry = BattleArray[battleindex].Side[side].Entry; + +#ifdef _BATTLECOMMAND_TIME + if( BattleArray[battleindex].PartTime > 1 && + BattleArray[battleindex].PartTime < time(NULL) ){ + TimeOut = TRUE; + } +#endif + + for( i = 0; i < BATTLE_ENTRY_MAX; i ++ ){ + charaindex = pEntry[i].charaindex; + if( CHAR_CHECKINDEX( charaindex ) == FALSE )continue; + if( CHAR_getFlg( charaindex, CHAR_ISDIE ) == TRUE ){ + continue; + } +#ifdef _OFFLINE_SYSTEM + if(CHAR_getWorkInt( charaindex, CHAR_WORK_OFFLINE ) == 1){ + //NPC_OffLineCommand( battleindex, charaindex, side ); + OffLineCommand( battleindex, charaindex, side ); + if(CHAR_getInt( charaindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER +#ifdef _PLAYER_NPC + ||CHAR_getInt( charaindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYERNPC +#endif +// ||CHAR_getInt( charaindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYERNPC + ){ + int petnum = CHAR_getInt(charaindex,CHAR_DEFAULTPET); + int petindex = CHAR_getCharPet(charaindex,petnum); + if(CHAR_CHECKINDEX(petindex)){ + //NPC_OffLineCommand( battleindex, petindex, side ); + OffLineCommand( battleindex, petindex, side ); + } + } + } +#endif + switch ( CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE ) ){ + case BATTLE_CHARMODE_C_OK: + BeOk++; + case BATTLE_CHARMODE_INIT: + case BATTLE_CHARMODE_RESCUE: + case BATTLE_CHARMODE_WATCHINIT: + break; + case BATTLE_CHARMODE_C_WAIT: + { +#ifdef _BATTLECOMMAND_TIME + if( TimeOut == TRUE ){ + //andy_log + //print("ANDY TimeOut Exit:%d-[%s|%s]\n", + //charaindex, CHAR_getUseName( charaindex), + //CHAR_getChar( charaindex, CHAR_CDKEY) ); + + CHAR_talkToCli( charaindex, -1, "ʱδָǿ뿪ս", CHAR_COLORYELLOW); + + CHAR_DischargeParty( charaindex, 0);//ɢŶ + CHAR_setWorkInt(charaindex, CHAR_WORKFMPKFLAG, -1); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_COMPELESCAPE ); + BATTLE_Exit( charaindex, battleindex ); + lssproto_B_send( getfdFromCharaIndex( charaindex ), "BU" ); +// CONNECT_setCloseRequest( getfdFromCharaIndex( charaindex) , 1 ); + break; + } +#endif + iRet = FALSE; + } + break; + default : + BATTLE_Exit( charaindex, battleindex ); + break; + } + } + + if( BeOk > 0 ){ +#ifdef _BATTLECOMMAND_TIME + if( BattleArray[ battleindex].PartTime <= 0 ){ + //սһִָ, ӳʱΪ120 + int battletimeout = getBattleTimtOut(); + if(battletimeout == 0) battletimeout = 120; + BattleArray[battleindex].PartTime = (int)time(NULL) + battletimeout; + } +#endif + } + return iRet; +} + + +#ifdef _ITEM_ADDEXP //vincent +#ifdef _ITEM_ADDEQUIPEXP +int BATTLE_GetExp( int charaindex, int midx ) +#else +int BATTLE_GetExp( int charaindex ) +#endif +{ + int addexp,i; + int modexp=0, getexp=0; + if( CHAR_CHECKINDEX( charaindex ) == FALSE )return 0; + + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE) == CHAR_TYPEPET) { + int ownerindex = CHAR_getWorkInt( charaindex, CHAR_WORKPLAYERINDEX); + if( CHAR_CHECKINDEX( ownerindex) && CHAR_getInt( ownerindex, CHAR_ADDEXPPOWER) > 0){ + modexp = CHAR_getInt( ownerindex, CHAR_ADDEXPPOWER); + } + }else if(CHAR_getInt(charaindex,CHAR_ADDEXPPOWER) > 0){ + modexp = CHAR_getInt(charaindex,CHAR_ADDEXPPOWER); + } + + getexp = CHAR_getWorkInt( charaindex, CHAR_WORKGETEXP ); +#ifdef _ALLBLUES_LUA_2_0 + int exp = getexp; + if (CHAR_getInt(charaindex,CHAR_LV) == getMaxLevel()){ + FreeCharExpSave(charaindex,exp ); + } +#endif +#ifdef _NEWOPEN_MAXEXP + if( getexp > 1000000000 ) getexp = 1000000000; +#endif +#ifdef _BATTLE_GOLD + int gold=CHAR_getInt( charaindex , CHAR_GOLD ); + if((gold+CHAR_getInt( charaindex , CHAR_LV ) * getBattleGold()) > CHAR_getMaxHaveGold(charaindex)) + gold=CHAR_getMaxHaveGold(charaindex); + else + gold+=CHAR_getInt( charaindex , CHAR_LV ) * getBattleGold(); + CHAR_setInt( charaindex , CHAR_GOLD , gold ); + CHAR_complianceParameter( charaindex ); + CHAR_send_P_StatusString( charaindex , CHAR_P_STRING_GOLD); +#endif + if( getexp < 0 || CHAR_GetLevelExp( charaindex, CHAR_getInt( charaindex, CHAR_LV)+1)==-1) getexp = 0; + int itemgetexp = CHAR_getWorkInt(charaindex,CHAR_WORKITEMEXP); + int itemaddexp = 0; + if(itemgetexp<0) itemgetexp = 0; + addexp = getexp+((getexp*modexp)/100); + itemaddexp = itemgetexp+((itemgetexp*modexp)/100); +#ifdef _GET_BATTLE_EXP + addexp*=getBattleexp(); + itemaddexp*=getBattleexp(); +#endif +#ifdef _FM_EXP_ADD + int flag=0; + int manor[]={1041,2031,3031,4031,5031,6031,7031,8031,9031,7531}; + int floor=CHAR_getWorkInt( charaindex, CHAR_WORKFMFLOOR); + for( i = 0 ; i < MANORNUM ; i ++ ){ + if(floor==manor[i]){ + flag=1; + break; + } + } + if(flag==1 && CHAR_getInt( charaindex, CHAR_FMLEADERFLAG ) != FMMEMBER_APPLY){ + addexp += getexp * getFmAddExp()*0.1; + } +#endif +#ifdef _TEAM_ADDEXP + int partynum ; + partynum=CHAR_getPartyNum( charaindex); + if (getTeamAddExp()>0) { + addexp+= getexp*(partynum-1)*getTeamAddExp()*0.1; + } +#endif + +#ifdef _ITEM_ADDEQUIPEXP + if( CHAR_CHECKINDEX( midx ) ){ + for( i = 0 ; i < CHAR_EQUIPPLACENUM ; i ++ ){ + int id = CHAR_getItemIndex(midx,i);//id + if( ITEM_CHECKINDEX(id) ){ + char *arg,*P; + arg = ITEM_getChar(id, ITEM_ARGUMENT );//߲ + if( (P = strstr( arg, "EXPUP" )) ){ + if( (P = strstr( arg, "" )) ){//ֻЧ + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE) == CHAR_TYPEPLAYER ){ + addexp += getexp*atoi(P+=2)*0.01; + itemaddexp += itemgetexp*atoi(P+=2)*0.01; + } + } + else if( (P = strstr( arg, "" )) ){//ֻԳЧ + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE) == CHAR_TYPEPET + && (CHAR_getInt( midx, CHAR_RIDEPET) != charaindex ) ) + addexp += getexp*atoi(P+=2)*0.01; + } + else if( (P = strstr( arg, "" )) ){//ֻЧ + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE) == CHAR_TYPEPET + && (CHAR_getInt( midx, CHAR_RIDEPET) == charaindex ) ) + addexp += getexp*atoi(P+=2)*0.01; + } + else{ + P = strstr( arg, "EXPUP" ); + addexp += getexp*atoi(P+=5)*0.01; + } + } + } + } + } +#endif +#ifdef _ITEM_ADDPETEXP + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE) == CHAR_TYPEPET ) + if( CHAR_getInt( charaindex, CHAR_PETID) == 1163 ) + addexp = 0; + +#endif + addexp = (addexp<0)?0:addexp; + if(itemaddexp>0){ + ITEM_ExpLvBase(charaindex,itemaddexp); + CHAR_setWorkInt(charaindex,CHAR_WORKITEMEXP,0); + } + + + if( CHAR_getInt( charaindex, CHAR_LV) >= CHAR_MAXUPLEVEL ) addexp = 0; +#ifdef _VIP_BATTLE_EXP + if(CHAR_getInt( charaindex, CHAR_WHICHTYPE) == CHAR_TYPEPLAYER ){ + if(CHAR_getInt( charaindex, CHAR_VIPRIDE) > 0 || CHAR_getInt( charaindex, CHAR_NVIPEXP) > 0){ + addexp = addexp * getVipBattleExp(); + } + } + if(CHAR_getInt( charaindex, CHAR_WHICHTYPE) == CHAR_TYPEPET ){ + if(CHAR_getInt( midx, CHAR_VIPRIDE) > 0 || CHAR_getInt( midx, CHAR_NVIPEXP) > 0){ + addexp = addexp * getVipBattleExp(); + } + } +#else + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE) == CHAR_TYPEPLAYER + && CHAR_getInt( charaindex, CHAR_VIPRIDE) > 0) addexp = addexp * 2; + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE) == CHAR_TYPEPET + && CHAR_getInt( midx, CHAR_VIPRIDE) > 0) addexp = addexp * 2; +#endif + + CHAR_setWorkInt( charaindex, CHAR_WORKGETEXP, addexp );//شCHAR_WORKGETEXP + + CHAR_AddMaxExp( charaindex, addexp); + + return addexp; +} +#else + +#ifdef _ITEM_ADDEQUIPEXP +int BATTLE_GetExp( int charaindex, int midx ) +#else +int BATTLE_GetExp( int charaindex ) +#endif +{ + int addexp, nowexp; + + if( CHAR_CHECKINDEX( charaindex ) == FALSE )return 0; + nowexp = CHAR_getInt( charaindex, CHAR_EXP ); + addexp = CHAR_getWorkInt( charaindex, CHAR_WORKGETEXP ); + // shan 11/27 10^9 1224160000 + CHAR_AddMaxExp( charaindex, addexp); + return addexp; +} +#endif + +int BATTLE_DpCalc( int battleindex ) +{ + BATTLE_ENTRY *pLooseEntry, *pWinEntry; + int winside, looseside, i, charaindex, dpadd, dpall, num = 0; + if( BATTLE_CHECKINDEX( battleindex ) == FALSE )return BATTLE_ERR_BATTLEINDEX; + + winside = BattleArray[battleindex].winside; + looseside = 1 - winside; + if( winside != -1 && winside != 1 )return BATTLE_ERR_PARAM; + + // Ͱ + dpall = 0; + + // ë뵤 + pLooseEntry = BattleArray[battleindex].Side[looseside].Entry; + for( i = 0 ; i < BATTLE_ENTRY_MAX; i ++ ){ + charaindex = pLooseEntry[i].charaindex; + // ½ + if( CHAR_CHECKINDEX( charaindex ) == FALSE )continue; + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER )continue; + // м + dpadd = CHAR_getInt( charaindex, CHAR_DUELPOINT ) * DUELPOINT_RATE; + // 巴 ëѨ̹ϵɬ + CHAR_setWorkInt( charaindex, CHAR_WORKGETEXP, + CHAR_getWorkInt( charaindex, CHAR_WORKGETEXP) - dpadd ); + // Ͱң + dpall += dpadd; + } + + // ձ Իü ëң + dpall += BattleArray[battleindex].Side[winside].common_dp; + + pWinEntry = BattleArray[battleindex].Side[winside].Entry; + for( num = 0,i = 0 ; i < BATTLE_ENTRY_MAX; i ++ ){ + charaindex = pWinEntry[i].charaindex; + // ½ + if( CHAR_CHECKINDEX( charaindex ) == FALSE )continue; + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER )continue; + num++; + } + // ئ⾮ ׻õ岾ئ + if( num <= 0 )return BATTLE_ERR_BATTLEINDEX; + dpadd = dpall / num; + if( dpadd <= 0 )dpadd = 1; // ƥ֨෴ܸ + + for( num = 0,i = 0 ; i < BATTLE_ENTRY_MAX; i ++ ){ + charaindex = pWinEntry[i].charaindex; + // ½ + if( CHAR_CHECKINDEX( charaindex ) == FALSE )continue; + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER )continue; + + // 巴 ëɬ + CHAR_setWorkInt( charaindex, CHAR_WORKGETEXP, + CHAR_getWorkInt( charaindex, CHAR_WORKGETEXP) + dpadd ); + } + + return 0; +} + +//#define RS_LIST_MAX 4 // ݱо ˪¾ +#define RS_LIST_MAX 5 +typedef struct{ + int num; + int exp; + int levelup; +}RS_LIST; + +int BATTLE_GetDuelPoint( + int battleindex, // ̼͵ + int side, // + int num // з ƽҷ¾ +) +{ + char szBuffer[1024]=""; + int charaindex; + int dpnow, dpadd, vpmin; + int fd; + int fl = 0, x = 0, y = 0; + if( BATTLE_CHECKINDEX( battleindex ) == FALSE )return BATTLE_ERR_BATTLEINDEX; + if( BATTLE_CHECKSIDE( side ) == FALSE )return BATTLE_ERR_PARAM; + if( num < 0 || num >= BATTLE_ENTRY_MAX )return BATTLE_ERR_PARAM; + charaindex = BattleArray[battleindex].Side[side].Entry[num].charaindex; + int playfloor = CHAR_getInt(charaindex, CHAR_FLOOR); + if(playfloor==11111)vpmin = getBalltePoint(0)*2; + if(playfloor==22222)vpmin = getBalltePoint(1)*2; + if(playfloor==33333)vpmin = getBalltePoint(2)*2; + if(playfloor==44444)vpmin = getBalltePoint(3)*2; + if( CHAR_CHECKINDEX( charaindex ) == FALSE )return BATTLE_ERR_PARAM; + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE ) == CHAR_TYPEPET ){ + return 0; + } + if( BattleArray[battleindex].Side[side].type != BATTLE_S_TYPE_PLAYER ){ + return 0; + } + dpadd = CHAR_getWorkInt( charaindex, CHAR_WORKGETEXP ); + if( dpadd == 0 ){ + dpadd = 0; // + }else + if( dpadd < 0 ){ + dpadd = min( -1, dpadd ); // ئ֨෴յ + }else{ + dpadd = max( 1, dpadd ); // ئ֨෴յ + } + if(playfloor==11111|| + playfloor==22222|| + playfloor==33333|| + playfloor==44444) + { + int fd = getfdFromCharaIndex( charaindex); + char* id = CHAR_getChar( charaindex, CHAR_CDKEY); + dpnow = sasql_vippoint(id,0,0) + dpadd; //PKԱ + dpnow = max( dpnow, 0 ); //ڻԱ + sasql_vippoint( id, dpadd, 1 ); //дԱ + if(dpnow= BATTLE_ENTRY_MAX )return BATTLE_ERR_PARAM; + charaindex = BattleArray[battleindex].Side[side].Entry[num].charaindex; + if( CHAR_CHECKINDEX( charaindex ) == FALSE )return BATTLE_ERR_PARAM; + if( CHAR_getFlg( charaindex, CHAR_ISDIE ) == TRUE ){ + return 0; + } + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER ){ +#ifdef _PLAYER_NPC + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYERNPC + || CHAR_getInt( charaindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYERPETNPC){ + if( CHAR_getFlg( charaindex, CHAR_ISDIE ) == FALSE ){ +#ifdef _ITEM_ADDEQUIPEXP + BATTLE_GetExp( charaindex , charaindex ); +#else + BATTLE_GetExp( charaindex ); +#endif + int UpLevel = CHAR_LevelUpCheck( charaindex , -1); + int i; + for( i = 0; i < UpLevel; i ++ ){ + CHAR_PetLevelUp( charaindex ); + CHAR_PetAddVariableAi( charaindex, AI_FIX_PETLEVELUP ); + } + } + } +#endif + return 0; + } + //CAX +/* if( CHAR_getInt( charaindex, CHAR_WHICHTYPE ) == CHAR_TYPEPET ){ + return 0; + } + if( BattleArray[battleindex].Side[side].type != BATTLE_S_TYPE_PLAYER ){ + return 0; + }*/ + pEntryChara = &BattleArray[battleindex].Side[side].Entry[num]; + if( CHAR_getFlg( charaindex, CHAR_ISDIE ) == FALSE ){ +#ifdef _ITEM_ADDEQUIPEXP + BATTLE_GetExp( charaindex , charaindex ); +#else + BATTLE_GetExp( charaindex ); +#endif + if( getBattleDebugMsg( ) != 0 ){ + snprintf( szBuffer, sizeof(szBuffer), + "(%s) õ EXP %d", + CHAR_getUseName( charaindex ), + CHAR_getWorkInt( charaindex, CHAR_WORKGETEXP ) + ); + BATTLE_talkToCli( charaindex, szBuffer, CHAR_COLORYELLOW ); + } + + } + UpLevel = CHAR_LevelUpCheck( charaindex , -1); + if( UpLevel > 0 ){ + aRsList[rsCnt].levelup = 1; + }else{ + aRsList[rsCnt].levelup = 0; + } + aRsList[rsCnt].num = -2; + aRsList[rsCnt].exp = CHAR_getWorkInt( charaindex, CHAR_WORKGETEXP ); + rsCnt ++; + if( UpLevel > 0 ){ + int work; + + if( getBattleDebugMsg( ) != 0 ){ + snprintf( szBuffer, sizeof(szBuffer), + "(%s) %d", + CHAR_getUseName( charaindex ), + CHAR_getInt( charaindex, CHAR_LV ) + ); + BATTLE_talkToCli( charaindex, szBuffer, CHAR_COLORYELLOW ); + } +#ifdef _SKILLUPPOINT_CF + CHAR_setInt( charaindex, CHAR_SKILLUPPOINT, + CHAR_getInt( charaindex, CHAR_SKILLUPPOINT) + UpLevel*getSkup()); +#else + CHAR_setInt( charaindex, CHAR_SKILLUPPOINT, + CHAR_getInt( charaindex, CHAR_SKILLUPPOINT) + UpLevel*3); +#endif + work = CHAR_getInt( charaindex, CHAR_CHARM ); + work += CH_FIX_PLAYERLEVELUP; + CHAR_setInt( charaindex, CHAR_CHARM, min( 100, work ) ); + CHAR_complianceParameter( charaindex ); + CHAR_send_P_StatusString( charaindex , + CHAR_P_STRING_LV|CHAR_P_STRING_NEXTEXP|CHAR_P_STRING_DUELPOINT + ); + CHAR_sendCToArroundCharacter( CHAR_getWorkInt( charaindex, CHAR_WORKOBJINDEX ) ); + CHAR_PartyUpdate( charaindex, CHAR_N_STRING_LV ); +#ifndef _NET_REDUCESEND + CHAR_send_DpDBUpdate_AddressBook( charaindex, TRUE ); +#endif + } + for( i = 0; i < CHAR_MAXPETHAVE; i ++ ){ + petindex = CHAR_getCharPet( charaindex, i ); + if( CHAR_CHECKINDEX( petindex ) == FALSE )continue; + if( CHAR_getFlg( petindex, CHAR_ISDIE ) == TRUE )continue; + if( CHAR_getWorkInt( petindex, CHAR_WORKGETEXP ) <= 0 ){ + CHAR_complianceParameter( petindex ); + sprintf( szBuffer, "K%d", i ); + CHAR_sendStatusString( charaindex , szBuffer ); + + continue; + } +#ifdef _ITEM_ADDEQUIPEXP + BATTLE_GetExp( petindex, charaindex ); +#else + BATTLE_GetExp( petindex ); +#endif + if( getBattleDebugMsg( ) != 0 ){ + snprintf( szBuffer, sizeof(szBuffer), + "(%s) õ EXP %d", + CHAR_getUseName( petindex ), + CHAR_getWorkInt( petindex, CHAR_WORKGETEXP ) + ); + BATTLE_talkToCli( charaindex, szBuffer, CHAR_COLORYELLOW ); + } + UpLevel = CHAR_LevelUpCheck( petindex , charaindex); + if( UpLevel > 0 ){ + if( getBattleDebugMsg( ) != 0 ){ + snprintf( szBuffer, sizeof(szBuffer), + "(%s) %d", + CHAR_getUseName( petindex ), + CHAR_getInt( petindex, CHAR_LV ) + ); + BATTLE_talkToCli( charaindex, szBuffer, CHAR_COLORYELLOW ); + } + for( j = 0; j < UpLevel; j ++ ){ + CHAR_PetLevelUp( petindex ); + CHAR_PetAddVariableAi( petindex, AI_FIX_PETLEVELUP ); + } + aRsList[rsCnt].levelup = 1; + }else{ + aRsList[rsCnt].levelup = 0; + } + aRsList[rsCnt].num = i; + aRsList[rsCnt].exp = CHAR_getWorkInt( petindex, CHAR_WORKGETEXP ); + rsCnt ++; + CHAR_complianceParameter( petindex ); + if( UpLevel > 0 ){ + sprintf( szBuffer, "K%d", i ); + CHAR_sendStatusString( charaindex , szBuffer ); + + } + + } + szItemString[0] = 0; + if( CHAR_getFlg( charaindex, CHAR_ISDIE ) == FALSE +#ifdef _OFFLINE_SYSTEM + && CHAR_getWorkInt( charaindex, CHAR_WORK_OFFLINE ) == 0 +#endif + ){ + for( i = 0; i < GETITEM_MAX; i ++ ){ + int ItemGet = FALSE; + szEscItemString[0] = 0; + itemindex = pEntryChara->getitem[i]; + if( itemindex < 0 ){ + itemindex = -1; + }else if( CHAR_findEmptyItemBox( charaindex ) >= 0 ){ + int ret = CHAR_addItemSpecificItemIndex(charaindex,itemindex); + if( 0 <= ret && ret < CHAR_EQUIPPLACENUM ){ + //print( "itemget err: ﲻȡitem(%s)(%d)(%s)\n", + //CHAR_getUseName( charaindex ), + //ret, + //ITEM_getAppropriateName(itemindex) + //); + } + if( !CHAR_CHECKITEMINDEX( charaindex, ret) ){ + ItemGet = FALSE; + }else{ + ItemGet = TRUE; + itemgroup[itemnum] = ret; + itemnum ++; + } + } + if( ItemGet == TRUE ){ + if( getBattleDebugMsg( ) != 0 ){ + snprintf( szBuffer, sizeof(szBuffer), + "ʰ(%s)", + ITEM_getAppropriateName(itemindex) ); + BATTLE_talkToCli( charaindex, szBuffer, CHAR_COLORYELLOW ); + } + +// LogItem( +// CHAR_getChar( charaindex, CHAR_NAME ), +// CHAR_getChar( charaindex, CHAR_CDKEY ), +//#ifdef _add_item_log_name // WON ADD itemlogitem +// itemindex, +//#else +// ITEM_getInt( itemindex, ITEM_ID ), /* ʧ ة į */ +//#endif +// "BattleGet(սõĵ)", +// CHAR_getInt( charaindex,CHAR_FLOOR), +// CHAR_getInt( charaindex,CHAR_X ), +// CHAR_getInt( charaindex,CHAR_Y ), +// ITEM_getChar(itemindex, ITEM_UNIQUECODE),// shan 2001/12/14 +// ITEM_getChar( itemindex, ITEM_NAME), +// ITEM_getInt( itemindex, ITEM_ID) +// ); + makeEscapeString( ITEM_getAppropriateName(itemindex), + szEscItemString, + sizeof( szEscItemString ) ); + strncat( szItemString, szEscItemString, sizeof( szItemString ) ); + pEntryChara->getitem[i] = -1; + }else{ + if( itemindex >= 0 ){ + ITEM_endExistItemsOne(itemindex); + }else{ + } + pEntryChara->getitem[i] = -1; + } + strncat( szItemString, "|", sizeof( szItemString ) ); + } + } + + szBuffer[0] = 0; + for( i = 0; i < RS_LIST_MAX; i ++ ){ + char szWork[256], sz62[64]; + szWork[0] = 0; + if( aRsList[i].exp > 0 || i == 0 ){ + cnv10to62( aRsList[i].exp, sz62, sizeof( sz62 ) ); + snprintf( szWork, sizeof( szWork ), + "%d|%d|%s", aRsList[i].num, + aRsList[i].levelup, + sz62 + ); + } + strncat( szBuffer, szWork, sizeof( szBuffer ) ); + strncat( szBuffer, ",", sizeof( szBuffer ) ); + } + strncat( szBuffer, szItemString, sizeof( szBuffer ) ); + { + int fd; + fd = getfdFromCharaIndex( charaindex ); + lssproto_RS_send( fd, szBuffer ); + } + return 0; +} + +int BATTLE_GetProfit( int battleindex, int side, int num ) +{ + if( BattleArray[battleindex].dpbattle == 1 ){ + return BATTLE_GetDuelPoint( battleindex, side, num ); + }else{ + return BATTLE_GetExpGold( battleindex, side, num ); + } + +} + +int BATTLE_FinishSet( battleindex ) +{ + + if( BATTLE_CHECKINDEX( battleindex ) == FALSE )return BATTLE_ERR_BATTLEINDEX; + BattleArray[battleindex].mode = BATTLE_MODE_FINISH; + return 0; +} + +static int BATTLE_Finish( int battleindex ) +{ + //DebugMainFunction="BATTLE_Finish"; + BATTLE *pBattle; + BATTLE_ENTRY *pEntry; + int i,charaindex, j; + if( BATTLE_CHECKINDEX( battleindex ) == FALSE )return BATTLE_ERR_BATTLEINDEX; + if( BattleArray[battleindex].winside == -1 + && BattleArray[battleindex].type == BATTLE_TYPE_P_vs_E + && BattleArray[battleindex].WinFunc != NULL){ + BattleArray[battleindex].WinFunc( battleindex, + BattleArray[battleindex].createindex ); + } +#ifdef _ALLBLUES_LUA + if( BattleArray[battleindex].type == BATTLE_TYPE_P_vs_E ){ + if(CHAR_CHECKINDEX( BattleArray[battleindex].createindex ) == TRUE){ + CHAR_setWorkInt( BattleArray[battleindex].createindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_NONE ); + CHAR_sendBattleEffect( BattleArray[battleindex].createindex, OFF); + if( BattleArray[battleindex].winside == -1){ + RunCharBattleOverEvent( BattleArray[battleindex].createindex, battleindex, 1); + }else{ + RunCharBattleOverEvent( BattleArray[battleindex].createindex, battleindex, 0); + } + } + } +#endif +#ifdef _BATTLE_PK + if(CHAR_getInt( BattleArray[battleindex].battleindex, CHAR_BATTLEPK)==TRUE || + CHAR_getInt( BattleArray[battleindex].leaderindex, CHAR_BATTLEPK)==TRUE){ + int winindex,lostindex; + if( BattleArray[battleindex].type == BATTLE_TYPE_P_vs_P){ + if( BattleArray[battleindex].winside == -1 ){ + winindex=BattleArray[battleindex].leaderindex; + lostindex=BattleArray[battleindex].rivalindex; + }else{ + winindex=BattleArray[battleindex].rivalindex; + lostindex=BattleArray[battleindex].leaderindex; + } + + if(CHAR_CHECKINDEX(lostindex) != FALSE){ + int fl = 0, x = 0, y = 0; + CHAR_getElderPosition(CHAR_getInt(lostindex, CHAR_LASTTALKELDER), &fl, &x, &y); + CHAR_warpToSpecificPoint(lostindex, fl, x, y); + CHAR_DischargeParty( lostindex, 0); + CHAR_setInt( winindex, CHAR_BATTLEPK, FALSE); + CHAR_setInt( lostindex, CHAR_BATTLEPK, FALSE); + } + } + } +#endif + +#ifdef _AUTO_PK + if(AutoPk_PKTimeGet()<=0){ + if(CHAR_getInt(BattleArray[battleindex].rivalindex, CHAR_FLOOR)==20000 && + CHAR_getInt(BattleArray[battleindex].leaderindex, CHAR_FLOOR)==20000){ + + if(BattleArray[battleindex].type != BATTLE_TYPE_WATCH + && BattleArray[battleindex].mode != BATTLE_MODE_WATCHBC + && CHAR_getInt(BattleArray[battleindex].leaderindex, CHAR_AUTOPK) != -1 + && CHAR_getInt(BattleArray[battleindex].rivalindex, CHAR_AUTOPK) != -1){ + int winindex,lostindex; + char wincdkey[CDKEYLEN],winname[CHARNAMELEN]; + char lostcdkey[CDKEYLEN],lostname[CHARNAMELEN]; + if( BattleArray[battleindex].type == BATTLE_TYPE_P_vs_P && BattleArray[battleindex].winside == -1 ){ + winindex=BattleArray[battleindex].leaderindex; + strcpysafe(wincdkey,sizeof(wincdkey),BattleArray[battleindex].leadercdkey); + strcpysafe(winname,sizeof(winname),BattleArray[battleindex].leadername); + lostindex=BattleArray[battleindex].rivalindex; + strcpysafe(lostcdkey,sizeof(lostcdkey),BattleArray[battleindex].rivalcdkey); + strcpysafe(lostname,sizeof(lostname),BattleArray[battleindex].rivalname); + }else{ + winindex=BattleArray[battleindex].rivalindex; + strcpysafe(wincdkey,sizeof(wincdkey),BattleArray[battleindex].rivalcdkey); + strcpysafe(winname,sizeof(winname),BattleArray[battleindex].rivalname); + lostindex=BattleArray[battleindex].leaderindex; + strcpysafe(lostcdkey,sizeof(lostcdkey),BattleArray[battleindex].leadercdkey); + strcpysafe(lostname,sizeof(lostname),BattleArray[battleindex].leadername); + } + int i, fl = 0, x = 0, y = 0, num=0; + int playernum = CHAR_getPlayerMaxNum(); + char token[64],token2[128]; + if(CHAR_CHECKINDEX(lostindex) != FALSE){ + CHAR_getElderPosition(CHAR_getInt(lostindex, CHAR_LASTTALKELDER), &fl, &x, &y); + CHAR_warpToSpecificPoint(lostindex, fl, x, y); + CHAR_DischargeParty( lostindex, 0); + } + if(CHAR_CHECKINDEX(winindex) != FALSE){ + CHAR_setInt(winindex,CHAR_AUTOPK,CHAR_getInt(winindex,CHAR_AUTOPK)+1); + sprintf(token,"[ս]%s սʤ %s ս", winname, lostname); + autopkcnt++; + int autopkvigor = getAutoPkVigorPkNum()*CHAR_getInt(lostindex,CHAR_AUTOPK)+getAutoPkVigorPkCnt()*autopkcnt; + CHAR_setInt(lostindex,CHAR_VIGOR,CHAR_getInt(lostindex,CHAR_VIGOR)+autopkvigor); + sprintf(token2,"[ս]%sɱ %d %d û%d",lostname,CHAR_getInt(lostindex,CHAR_AUTOPK),autopkcnt,autopkvigor); + }else{ + sprintf(token,"[ս]%s %s ", winname, lostname); + autopkcnt++; + int autopkvigor = getAutoPkVigorPkNum()*CHAR_getInt(lostindex,CHAR_AUTOPK)+getAutoPkVigorPkCnt()*autopkcnt; + CHAR_setInt(lostindex,CHAR_VIGOR,CHAR_getInt(lostindex,CHAR_VIGOR)+autopkvigor); + sprintf(token2,"[ս]%sɱ %d %d û%d",lostname,CHAR_getInt(lostindex,CHAR_AUTOPK),autopkcnt,autopkvigor); + } + for(i=0;i= 0 ; i -- ){ +#endif + charaindex = pEntry[i].charaindex; + + if( CHAR_CHECKINDEX( charaindex ) == FALSE ) + continue; +#ifdef _ALLBLUES_LUA_1_9 + BattleFinishFunction(charaindex, BattleArray[battleindex].CreateTime, BattleArray[battleindex].turn, BattleArray[battleindex].type); +#endif + BATTLE_GetProfit( battleindex, j, i ); //ȡþֵ + BATTLE_Exit( charaindex, battleindex ); + } + } + if( BattleArray[battleindex].type == BATTLE_TYPE_WATCH ){ + }else{ + pBattle = BattleArray[battleindex].pNext; + for( ;pBattle; pBattle = pBattle->pNext ){ + if( BATTLE_CHECKADDRESS( pBattle ) == FALSE ){ + //fprint( "err:battle address (%p)\n", pBattle ); + break; + } + for( i = BATTLE_ENTRY_MAX-1; i >= 0 ; i -- ){ + charaindex = pBattle->Side[0].Entry[i].charaindex; + if( CHAR_CHECKINDEX( charaindex ) == FALSE )continue; + BATTLE_Exit( charaindex, pBattle->battleindex ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_FINAL ); + } + } + pBattle = BattleArray[battleindex].pNext; + for( ;pBattle; pBattle = pBattle->pNext ){ + if( BATTLE_CHECKADDRESS( pBattle ) == FALSE ){ + //fprint( "err:battle address (%p)\n", pBattle ); + break; + } + BATTLE_DeleteBattle( pBattle->battleindex ); + } + } + BATTLE_DeleteBattle( battleindex ); + return 0; +} + +int BATTLE_StopSet( battleindex ) +{ + + if( BATTLE_CHECKINDEX( battleindex ) == FALSE )return BATTLE_ERR_BATTLEINDEX; + BattleArray[battleindex].mode = BATTLE_MODE_STOP; + + return 0; +} + +static int BATTLE_Stop( int battleindex ) +{ + //DebugMainFunction="BATTLE_Stop"; + BATTLE_ENTRY *pEntry; + int i, charaindex, j; + if( BATTLE_CHECKINDEX( battleindex ) == FALSE )return BATTLE_ERR_BATTLEINDEX; + + for( j = 0; j < 2; j ++ ){ + pEntry = BattleArray[battleindex].Side[j].Entry; + for( i = BATTLE_ENTRY_MAX-1; i >= 0 ; i -- ){ + charaindex = pEntry[i].charaindex; + if( CHAR_CHECKINDEX( charaindex ) == FALSE ) + continue; + BATTLE_GetProfit( battleindex, j, i ); + BATTLE_Exit( charaindex, battleindex ); + } + } + + BATTLE_DeleteBattle( battleindex ); + return 0; +} + +int BATTLE_DefaultAttacker( int battleindex, int side ) +{ + int i, rnd, cnt; + int CharaTbl[BATTLE_ENTRY_MAX]; + + BATTLE_ENTRY *pEntry; + + pEntry = BattleArray[battleindex].Side[side].Entry; + cnt = 0; + + for( i = 0 ; i < BATTLE_ENTRY_MAX; i ++ ){ + CharaTbl[i] = -1; + if( CHAR_CHECKINDEX( pEntry[i].charaindex ) == FALSE ){ + continue; + } + + if( CHAR_getWorkInt( pEntry[i].charaindex, CHAR_WORKBATTLEMODE ) + == BATTLE_CHARMODE_RESCUE ){ + continue; + } + + if( BATTLE_TargetCheck( battleindex, i + side * SIDE_OFFSET ) == FALSE )continue; + + CharaTbl[cnt] = i + side * SIDE_OFFSET; + cnt ++; + } + + if( cnt == 0 ){ + return -1; + } + + rnd = RAND( 0, cnt-1 ); + return CharaTbl[rnd]; + +} + +//********************************************************* +// +// ؤϷԻ ëң +// +int BATTLE_AddDpAlive( + int battleindex, // ̼͵ + int side, // ( 0 or 1 ) + int dp +) +// +// ԻϷȻ +// ľئľ +// +//********************************************************* +{ + int i, charaindex; + BATTLE_ENTRY *pEntry; + int cnt = 0; + + // ɷ¶ + if( BATTLE_CHECKSIDE( side ) == FALSE )return -BATTLE_ERR_PARAM; + if( BATTLE_CHECKINDEX( battleindex ) == FALSE )return -BATTLE_ERR_BATTLEINDEX; + + // ޼ + pEntry = BattleArray[battleindex].Side[side].Entry; + + for( i = 0; i < BATTLE_ENTRY_MAX; i ++ ){ + charaindex = pEntry[i].charaindex; + if( CHAR_CHECKINDEX( charaindex ) == FALSE ) continue; + // ʸ𼰶ئ + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE ) == CHAR_TYPEPET ) continue; + // Ϸ廯ʣ۵ң + if( CHAR_getFlg( charaindex, CHAR_ISDIE ) == FALSE ){ + CHAR_setWorkInt( charaindex, CHAR_WORKGETEXP, + CHAR_getWorkInt( charaindex, CHAR_WORKGETEXP) + dp ); + } + } + + return cnt; +} + +#if 1 +//********************************************************* +// +// ϷȻ¾Ʃ +// +int BATTLE_CountAlive( + int battleindex, // ̼͵ + int side // ( 0 or 1 ) +) +// +// ԻϷȻ +// ľئľ +// +//********************************************************* +{ + int i, charaindex; + BATTLE_ENTRY *pEntry; + int cnt = 0; + + // ɷ¶ + if( BATTLE_CHECKSIDE( side ) == FALSE )return -BATTLE_ERR_PARAM; + if( BATTLE_CHECKINDEX( battleindex ) == FALSE )return -BATTLE_ERR_BATTLEINDEX; + + // ޼ + pEntry = BattleArray[battleindex].Side[side].Entry; + + for( i = 0; i < BATTLE_ENTRY_MAX; i ++ ){ + charaindex = pEntry[i].charaindex; + if( CHAR_CHECKINDEX( charaindex ) == FALSE ) continue; + // ʸ𼰶ئ + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE ) == CHAR_TYPEPET ) continue; + // Ϸ廯ʣ + if( CHAR_getFlg( charaindex, CHAR_ISDIE ) == FALSE ){ + cnt ++; + } + } + + return cnt; +} +#endif + + +//********************************************************* +// +// ׻ĻϷ廯ؾë +// +int BATTLE_OnlyRescue( + int battleindex, // ̼͵ + int side, // ( 0 or 1 ) + int *pOnlyFlg +) +// +// ԻϷȻ +// ľئľ +// +//********************************************************* +{ + int i, charaindex; + BATTLE_ENTRY *pEntry; + int cnt = 0, OnlyRescue = 1; + + (*pOnlyFlg) = 0; + + // ɷ¶ + if( BATTLE_CHECKSIDE( side ) == FALSE )return -BATTLE_ERR_PARAM; + if( BATTLE_CHECKINDEX( battleindex ) == FALSE )return -BATTLE_ERR_BATTLEINDEX; + + // ޼ + pEntry = BattleArray[battleindex].Side[side].Entry; + + for( i = 0; i < BATTLE_ENTRY_MAX; i ++ ){ + charaindex = pEntry[i].charaindex; + if( CHAR_CHECKINDEX( charaindex ) == FALSE ){ + continue; + } + // ʸ𼰶ئ + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE ) == CHAR_TYPEPET ) continue; + // Ϸ廯ʣ + if( CHAR_getFlg( charaindex, CHAR_ISDIE ) == FALSE ){ + cnt ++; + // Ϸ廯֧ + if( CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE ) == BATTLE_CHARMODE_RESCUE ){ + }else{ + OnlyRescue = 0; + } + } +#ifdef _PETSKILL_LER + if(CHAR_getWorkInt(charaindex,CHAR_WORK_RELIFE) > 0) cnt++; +#endif + } + + // Ϸ廯֧лй + if( cnt > 0 && OnlyRescue ){ + // ׷ºë + (*pOnlyFlg) = 1; + }else{ + // лը߱ + (*pOnlyFlg) = 0; + } + + return cnt; +} + +static BOOL BATTLE_TimeOutCheck( int battleindex ) +{ + int i, j, charaindex; + BATTLE *pBattle; + BATTLE_ENTRY *pEntry; + pBattle = &BattleArray[battleindex]; + + if( NowTime.tv_sec > pBattle->timer + BATTLE_TIME_LIMIT ){ + }else{ + return FALSE; + } + //BATTLE_BroadCast( battleindex, "serverʱѵ", CHAR_COLORYELLOW ); + for( j = 0; j < 2; j ++ ){ + pEntry = pBattle->Side[j].Entry; + for( i = 0; i < BATTLE_ENTRY_MAX; i ++ ){ + charaindex = pEntry[i].charaindex; + if( CHAR_CHECKINDEX( charaindex ) == FALSE ) + continue; + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE ) == CHAR_TYPEENEMY ){ + continue; + } + if( CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE ) + == BATTLE_CHARMODE_C_WAIT ){ + BATTLE_Exit( charaindex, battleindex ); + CHAR_DischargePartyNoMsg( charaindex ); + CHAR_talkToCli( charaindex, -1, + "ʱ䵽ս", CHAR_COLORYELLOW ); + BATTLE_CommandSend( charaindex, "BU" ); + } + } + } + + return TRUE; +} + +int BATTLE_WatchWait( int battleindex ) +{ + //DebugMainFunction="BATTLE_WatchWait"; + BATTLE *pBattle; + BOOL commandflg = TRUE; + + if( BATTLE_CHECKINDEX( battleindex ) == FALSE )return BATTLE_ERR_BATTLEINDEX; + pBattle = &BattleArray[battleindex]; + if( BATTLE_TimeOutCheck( battleindex ) == TRUE ){ + commandflg = TRUE; + } + if( commandflg == FALSE ){ + return 0; + } + pBattle->mode = BATTLE_MODE_WATCHMOVIE; + pBattle->turn ++; + return 0; +} + +int BATTLE_WatchMovie( int battleindex ) +{ + //DebugMainFunction="BATTLE_WatchMovie"; + return 0; + +} + +int BATTLE_WatchAfter( int battleindex ) +{ + //DebugMainFunction="BATTLE_WatchAfter"; + BattleArray[battleindex].mode = BATTLE_MODE_WATCHPRE; + + return 0; + +} + +int BATTLE_WatchBC( int battleindex ) +{ + //DebugMainFunction="BATTLE_WatchBC"; + return 0; +} + +int BATTLE_WatchPre( int battleindex ) +{ + //DebugMainFunction="BATTLE_WatchPre"; + // Ѩг ݼ ľ + BATTLE_PreWatchWaitSeq( battleindex ); + BattleArray[battleindex].mode = BATTLE_MODE_WATCHWAIT; + return 0; +} + +static int BATTLE_Command( int battleindex ) +{ + //DebugMainFunction="BATTLE_Command"; + BATTLE *pBattle, *pWatchBattle; + BOOL commandflg = TRUE, iFinish = FALSE; + int OnlyRescue[2]={0,0}; + int i, j, charaindex; + if( BATTLE_CHECKINDEX( battleindex ) == FALSE )return BATTLE_ERR_BATTLEINDEX; + pBattle = &BattleArray[battleindex]; + //DebugMainFunction="BATTLE_Command_1"; + + if( BATTLE_CommandWait( battleindex, 0) == FALSE ){ + commandflg = FALSE; + } + //DebugMainFunction="BATTLE_Command_2"; + if( BATTLE_CommandWait( battleindex, 1) == FALSE ){ + commandflg = FALSE; + } + //DebugMainFunction="BATTLE_Command_3"; + pWatchBattle = pBattle->pNext; + //DebugMainFunction="BATTLE_Command_4"; + for( ; pWatchBattle ; pWatchBattle = pWatchBattle->pNext ){ + if( BATTLE_CHECKADDRESS( pWatchBattle ) == FALSE ){ + //fprint( "err:սbattle address(%p)\n", pWatchBattle ); + break; + } + + if( pWatchBattle->mode == BATTLE_MODE_WATCHBC ){ + + BATTLE_MakeCharaString( battleindex, szAllBattleString, + sizeof(szAllBattleString) ); + BATTLE_BpSendToWatch( pWatchBattle, szAllBattleString ); + + pWatchBattle->mode = BATTLE_MODE_WATCHPRE; + commandflg = FALSE; + + }else if( pWatchBattle->mode != BATTLE_MODE_WATCHMOVIE ){ + commandflg = FALSE; + } + } + //DebugMainFunction="BATTLE_Command_5"; + if( BATTLE_TimeOutCheck( battleindex ) == TRUE ){ + commandflg = TRUE; + } + //DebugMainFunction="BATTLE_Command_6"; + if( commandflg == FALSE ){ + return 0; + } + //DebugMainFunction="BATTLE_Command_7"; +#ifdef _BATTLECOMMAND_TIME + BattleArray[battleindex].PartTime = 0; +#endif + //DebugMainFunction="BATTLE_Command_8"; + + pBattle->turn ++;//Լغ + //DebugMainFunction="BATTLE_Command_9"; + BATTLE_ai_all( battleindex, 0, 0); + //DebugMainFunction="BATTLE_Command_10"; + BATTLE_ai_all( battleindex, 1, 0); + //DebugMainFunction="BATTLE_Command_11"; + BATTLE_Battling( battleindex );//ս + //DebugMainFunction="BATTLE_Command_12"; + pBattle->Side[0].flg &= ~BSIDE_FLG_SURPRISE; + //DebugMainFunction="BATTLE_Command_13"; + pBattle->Side[1].flg &= ~BSIDE_FLG_SURPRISE; + //DebugMainFunction="BATTLE_Command_14"; + if( BATTLE_OnlyRescue( battleindex, 0, &OnlyRescue[0] ) == 0 ){ + pBattle->winside = 1; + iFinish = TRUE; + }else + if( BATTLE_OnlyRescue( battleindex, 1, &OnlyRescue[1] ) == 0 ){ + pBattle->winside = -1; + iFinish = TRUE; + } + //DebugMainFunction="BATTLE_Command_15"; + for( j = 0; j < 2; j ++ ){ + if( OnlyRescue[j] != 1 )continue; + for( i = 0; i < BATTLE_ENTRY_MAX/2; i ++ ){ + charaindex = pBattle->Side[j].Entry[i].charaindex; + if( CHAR_CHECKINDEX( charaindex ) == FALSE ) + continue; + if( CHAR_getInt( charaindex, CHAR_HP ) <= 0 ){ + BATTLE_Exit( charaindex, battleindex ); + } + } + } + //DebugMainFunction="BATTLE_Command_16"; + BATTLE_PreCommandSeq( battleindex ); + //DebugMainFunction="BATTLE_Command_17"; + if( iFinish == TRUE ){ + BATTLE_FinishSet( battleindex ); + } + //DebugMainFunction="BATTLE_Command_18"; + return 0; +} + +extern void BATTLE_changeRideImage( int index ); + +int BATTLE_Loop( void ) +{ + int i, cnt = 0; + rand(); + for( i = 0; i < BATTLE_battlenum; i ++ ){//ս + if( BattleArray[i].use == FALSE )continue; + if( BattleArray[i].type == BATTLE_TYPE_WATCH ){//ǹսģʽ + if( BATTLE_CountAlive( i, 0 ) == 0 ){ + BATTLE_FinishSet( i ); + } + } + + switch( BattleArray[i].mode ){ + case BATTLE_MODE_NONE://δս + break; + case BATTLE_MODE_INIT://սʼ + BATTLE_Init( i ); + break; + case BATTLE_MODE_BATTLE://Serverڲս + BATTLE_Command( i ); + break; + case BATTLE_MODE_FINISH://ս + BATTLE_Finish( i ); + break; + case BATTLE_MODE_STOP://սж + BATTLE_Stop( i ); + break; + case BATTLE_MODE_WATCHBC://ս... + BATTLE_WatchBC( i ); + break; + + case BATTLE_MODE_WATCHPRE: + BATTLE_WatchPre( i ); + break; + case BATTLE_MODE_WATCHWAIT: + BATTLE_WatchWait( i ); + break; + + case BATTLE_MODE_WATCHMOVIE: + BATTLE_WatchMovie( i ); + break; + + case BATTLE_MODE_WATCHAFTER: + BATTLE_WatchAfter( i ); + break; + } + cnt ++; + } + return cnt; +} + + + + + +typedef struct { + int charaindex; // ƽҷ̼͵ + int side; // + int dex; // ٶƽ + int num; // ޼ į + int combo; // ޾ +#ifdef _EQUIT_SEQUENCE + int sequence; +#endif +}BATTLE_CHARLIST; + + +typedef int (*FUNC)( const void *, const void * ); + +//************************************************************ +// +// ٶƽ ʤ +// +// ٶƽ񷴰 ľ£ϴĩƥؤ£ +// +static int EsCmp( + const BATTLE_CHARLIST *pC1, + const BATTLE_CHARLIST *pC2 +) +{ +//#ifdef _EQUIT_SEQUENCE +// return( (pC2->dex+pC2->sequence) - (pC1->dex+pC1->sequence) ); +//#else + return( pC2->dex - pC1->dex ); +//#endif +} + +#ifdef _EQUIT_SEQUENCE +void Replacement_Entry( BATTLE_CHARLIST *temp1, BATTLE_CHARLIST *temp2) +{ + temp1->charaindex = temp2->charaindex; + temp1->combo = temp2->combo; + temp1->dex = temp2->dex; + temp1->num = temp2->num; + temp1->sequence = temp2->sequence; + temp1->side = temp2->side; +} +#endif +static void EntrySort( BATTLE_CHARLIST *EntryList, int listsize) +{ +#ifdef _EQUIT_SEQUENCE +// int i, j; + qsort( EntryList, listsize, sizeof( BATTLE_CHARLIST ), (FUNC)EsCmp ); +/* + for( i=0; i 0 ){ + int maxcheck, now; + BATTLE_CHARLIST temp; + + maxcheck = EntryList[i].sequence/8; + maxcheck = RAND( 1, maxcheck); + maxcheck = ( maxcheck>=i )?(i/3):maxcheck; + maxcheck = ( maxcheck<0)?0:maxcheck; + now = i; + for( j=0; j0; j++){ + if( EntryList[now].sequence > (EntryList[now-1].sequence *0.9) ){ + + Replacement_Entry( &temp, &EntryList[now]); + Replacement_Entry( &EntryList[now], &EntryList[now-1]); + Replacement_Entry( &EntryList[now-1], &temp); + now = now-1; + + +// temp = &EntryList[now]; +// EntryList[now] = EntryList[now-1]; +// EntryList[now-1] = *temp; +// temp = NULL; + + } + } + } + } +*/ +#else + qsort( EntryList, listsize, sizeof( BATTLE_CHARLIST ), (FUNC)EsCmp ); +#endif +} + + + +//************************************************************ +// +// ٶƽëң£ +// +static int BATTLE_DexCalc( + int charaindex +) +// +// Ի ٶƽ +// +//************************************************************ +{ + int dex = 0; + int work, COM; + int petindex = BATTLE_getRidePet( charaindex ); + + // Ѩ + COM = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM1 ); + +#ifdef _PETSKILL_BECOMEFOX // ˳еݽ20% + if( CHAR_getWorkInt( charaindex, CHAR_WORKFOXROUND ) != -1 ){ + work = CHAR_getWorkInt( charaindex, CHAR_WORKQUICK )+20; + dex = work *0.8;//20% + } +#endif +#ifdef _PROFESSION_ADDSKILL + if( CHAR_getWorkInt( charaindex, CHAR_WORKFEAR ) > 0 ){ + work = CHAR_getWorkInt( charaindex, CHAR_WORKQUICK )+20; + dex = work*0.8;//20% + } +#endif + // ɧ + switch( COM ){ +#ifdef _PROFESSION_SKILL // WON ADD ְҵ + case BATTLE_COM_S_BLOOD: // Ѫ + case BATTLE_COM_S_BLOOD_WORMS: // Ѫ + case BATTLE_COM_S_SIGN: // һѪ +#endif + +#ifdef _BATTLE_NEWPOWER + case BATTLE_COM_JYUJYUTU: + case BATTLE_COM_S_ATTACK_MAGIC: + work = CHAR_getWorkInt( charaindex, CHAR_WORKQUICK )+20; +#ifdef _DEX_FIX + dex = work - RAND( 0, work * 0.01*getDexFixPer() ); +#else + dex = work - RAND( 0, work * 0.3 ); +#endif + break; +#endif + + +#ifdef _PROFESSION_SKILL // WON ADD ְҵ + case BATTLE_COM_S_FIRE_ENCLOSE: // + case BATTLE_COM_S_ICE_ENCLOSE: // + case BATTLE_COM_S_THUNDER_ENCLOSE: // ׸ + work = CHAR_getWorkInt( charaindex, CHAR_WORKQUICK )+20; + dex = work - RAND( work * 0.3, work * 0.5 ); + break; + case BATTLE_COM_S_VOLCANO_SPRINGS:// ɽȪ + case BATTLE_COM_S_SUMMON_THUNDER: // + case BATTLE_COM_S_ICE_ARROW: // + work = CHAR_getWorkInt( charaindex, CHAR_WORKQUICK )+20; + dex = work - RAND( 0, work * 0.2 ); + break; + case BATTLE_COM_S_CURRENT: // + case BATTLE_COM_S_FIRE_BALL:// + case BATTLE_COM_S_ICE_CRACK: // + work = CHAR_getWorkInt( charaindex, CHAR_WORKQUICK )+20; + dex = work - RAND( 0, work * 0.5 ); + break; + case BATTLE_COM_S_FIRE_SPEAR:// ǹ + case BATTLE_COM_S_STORM: // + case BATTLE_COM_S_ICE_MIRROR: // + case BATTLE_COM_S_ENCLOSE: // + case BATTLE_COM_S_TRANSPOSE: // λλ + work = CHAR_getWorkInt( charaindex, CHAR_WORKQUICK )+20; + dex = work - RAND( work * 0.2, work * 0.5 ); + break; + + case BATTLE_COM_S_DOOM: // ĩ + work = CHAR_getWorkInt( charaindex, CHAR_WORKQUICK )+20; + dex = work - RAND( 0.3, work * 0.6 ); + break; +#endif + +#ifdef _SKILL_SPEEDY_ATT //vincent 輼:ٹ + case BATTLE_COM_S_SPEEDYATTACK: + work = CHAR_getWorkInt( charaindex, CHAR_WORKQUICK )+20; + dex = work + work*0.3;//30% + break; +#endif +#ifdef _PETSKILL_DAMAGETOHP //輼:¿(Ѫı) + case BATTLE_COM_S_DAMAGETOHP2: + work = CHAR_getWorkInt( charaindex, CHAR_WORKQUICK )+20; + dex = work + work*0.2;//20% + break; +#endif + + case BATTLE_COM_ITEM: // ʧ ةë + work = CHAR_getWorkInt( charaindex, CHAR_WORKQUICK )+20; + dex = work - RAND( 0, work * 0.3 ) + work * 0.15; + break; + default: // ɧ ئ) + // Robin 0727 ride pet + if( petindex == -1 ) + work = CHAR_getWorkInt( charaindex, CHAR_WORKQUICK )+20; + else + work = BATTLE_adjustRidePet3A( charaindex, petindex, CHAR_WORKQUICK, ATTACKSIDE )+20; +#ifdef _DEX_FIX + dex = work - RAND( 0, work * 0.01*getDexFixPer()); +#else + dex = work - RAND( 0, work * 0.3 ); +#endif + break; + } + + // Ѩ̹ϵئȻգ + //if( dex <= 0 )dex = 1; //ٷ + if( dex<=0 ) dex = RAND(1,10); //޸ĺ1-5֮ȡ + return dex; +} + + + + + + +//************************************************************* +// +// ؤ¾ +// +static void ComboCheck( + BATTLE_CHARLIST *pEntryList, + int entrynum +) +// +//************************************************************* +{ + + int i, + charaindex, + com, + enemy, + side, + oldside = -3, // ؤԻئа + oldenemy = -3, // ؤԻئа + armtype, + move, + per, + ComboId = 1, // ʾ + start = -1; + for( i = 0; i < entrynum; i ++ ){ + + charaindex = pEntryList[i].charaindex; + com = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM1 ); + enemy = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM2 ); + side = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLESIDE ); + armtype = 0; + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE ) == CHAR_TYPEENEMY ){ + per = 20; // ķߡ + }else{ + per = 50; // зߡ + } + + // ߾ ئ + if( CHAR_getInt( charaindex, CHAR_HP ) <= 0 + || BATTLE_CanMoveCheck( charaindex ) == FALSE + ){ + move = 0; + }else{ + move = 1; + } + + // տë ئĸ + // ئĸ + if( BATTLE_IsThrowWepon( + CHAR_getItemIndex( charaindex, CHAR_ARM ) ) == TRUE + ){ + armtype = 1; + } + + pEntryList[i].combo = 0; // + + if( start != -1 ){ // + if( com != BATTLE_COM_ATTACK // Ѩƥئ + || enemy != oldenemy // Ȼ³Ļ Ԫƥئ + || side != oldside // ਵ + || armtype == 1 // ƥؤ + || move == 0 // ئ + ){ + start = -1; // + oldside = side; // + }else{ + // ʾɬ + CHAR_setWorkInt( pEntryList[i].charaindex, + CHAR_WORKBATTLECOM1,BATTLE_COM_COMBO ); + pEntryList[i].combo = ComboId; + // ټɱɬ + CHAR_setWorkInt( pEntryList[start].charaindex, + CHAR_WORKBATTLECOM1,BATTLE_COM_COMBO ); + pEntryList[start].combo = ComboId; + } + } + if( start == -1 ){// ƻئ + if( com == BATTLE_COM_ATTACK + && armtype != 1 // ƥئ + && move == 1 // + && RAND( 1, 100 ) <= per + ){ // ɧ ƥؤ + start = i; + oldenemy = enemy; // Ȼ³ë + oldside = side; // + ComboId ++; + } + } + + } + +} + +//************************************************************* +// +// ƥ¾ +//ݼлʾƥԪئ FALSE +// +static BOOL ComboCheck2( + BATTLE_CHARLIST *pEntryList, // ޼ + int nownum, // ػ + int entrynum // ޼ +) +// +// ʾƥ TRUE +// ƥئ FALSE +// +//************************************************************* +{ + + int i, + iRet = FALSE, + ComboId, + charaindex; + + // ʾ + ComboId = pEntryList[nownum].combo; + + charaindex = pEntryList[nownum].charaindex; + + // лպ ƻ + if( CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEFLG) & CHAR_BATTLEFLG_AIBAD ) + { +// print( "ҳ϶Ȳʹñɱʧ( %s )\n",CHAR_getUseName( charaindex ) ); + return FALSE; + } + + // ݼлʾ帨ƥ¾ + for( i = nownum+1; i < entrynum; i ++ ){ + charaindex = pEntryList[i].charaindex; + + // ʾ ਵ + if( ComboId != pEntryList[i].combo )break; + + // 帨ƻئݳ + if( CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE) == 0 ) break; + if( CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE) == BATTLE_CHARMODE_FINAL ) break; + + if( CHAR_getInt( charaindex, CHAR_HP ) <= 0 + || BATTLE_CanMoveCheck( charaindex ) == FALSE + ){ + }else{ + iRet = TRUE; + break; + } + } +/* + if( iRet == FALSE ){ + print( "ɱʧ( %s )\n", + CHAR_getUseName( pEntryList[nownum].charaindex ) ); + } +*/ + return iRet; + +} + + +void BATTLE_UltimateExtra( + int battleindex, + int charaindex, + int enemyindex +) +{ + char szBuffer[256]=""; + int pindex, pno; + int floor=0, x=0, y=0; + szBuffer[0] = 0; + + if( CHAR_getInt( enemyindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER +#ifdef _PLAYER_NPC + || CHAR_getInt( enemyindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYERNPC +#endif +// || CHAR_getInt( enemyindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYERNPC + ){ + BATTLE_PetDefaultExit( enemyindex, battleindex ); + + if( BattleArray[battleindex].type != BATTLE_TYPE_P_vs_P ){ + int levelflg = 1; + //snprintf( szBuffer, sizeof(szBuffer), + // "(%s)Զ", + // CHAR_getUseName( enemyindex ) ); + if( CHAR_getInt( enemyindex, CHAR_LV ) <= 10 ){ + levelflg = 2; + } + + if( BattleArray[battleindex].norisk == 0 ){; + CHAR_AddCharm( enemyindex, CH_FIX_PLAYEULTIMATE/levelflg ); + pno = CHAR_getInt( enemyindex, CHAR_DEFAULTPET ); + if( 0 <= pno && pno < CHAR_MAXPETHAVE ){ + pindex = CHAR_getCharPet( enemyindex, pno ); + if( CHAR_CHECKINDEX( pindex ) == TRUE ){ + CHAR_PetAddVariableAi( pindex, AI_FIX_PLAYERULTIMATE/levelflg ); + } + } + } + if( CHAR_getElderPosition( + CHAR_getInt( enemyindex, CHAR_LASTTALKELDER), &floor, &x, &y ) + != TRUE + ){ + }else{ + CHAR_warpToSpecificPoint( enemyindex, floor, x, y ); + } + } + BATTLE_Exit( enemyindex, battleindex ); + CHAR_DischargePartyNoMsg( enemyindex ); + if( getBattleDebugMsg( ) != 0 ){ + BATTLE_talkToCli( enemyindex, szBuffer, CHAR_COLORYELLOW ); + } + + }else + // ʸئ + if( CHAR_getInt( enemyindex, CHAR_WHICHTYPE ) == CHAR_TYPEPET ){ + int levelflg = 1; + int playerindex = CHAR_getWorkInt( enemyindex, CHAR_WORKPLAYERINDEX ); + + // ìﻥ Ӽ + if( CHAR_getInt( playerindex, CHAR_LV ) <= 10 ){ + levelflg = 2; + } + + //snprintf( szBuffer, sizeof(szBuffer), + // "(%s)ɡ", + // CHAR_getUseName( enemyindex ) ); + + // DZмɻշ + CHAR_setInt( playerindex, CHAR_DEFAULTPET, -1 ); + + // ب޻ﶯ½ëƱ + if( BattleArray[battleindex].type != BATTLE_TYPE_P_vs_P ){ + // ͼ ᆴؤئ ëƱ + if( BattleArray[battleindex].norisk == 0 ){; + CHAR_PetAddVariableAi( enemyindex, AI_FIX_PETULTIMATE/levelflg ); + } + // DZмʸϷּë + CHAR_setInt( playerindex, CHAR_DEADPETCOUNT, + CHAR_getInt( playerindex, CHAR_DEADPETCOUNT ) + 1 ); + } +/* + // ʸվ ն£ + BATTLE_PetDefaultExit( enemyindex, battleindex ); +*/ + + // + BATTLE_Exit( enemyindex, battleindex ); + + }else{ + int flg; + // ľ½ƥʧ ū + //snprintf( szBuffer, sizeof(szBuffer), + // "(%s)ɡ", + // CHAR_getUseName( enemyindex ) ); + // ƽҷ·ӡƻ +// BATTLE_Exit( enemyindex, battleindex ); + flg = CHAR_getWorkInt( enemyindex, CHAR_WORKBATTLEFLG ); + flg |= CHAR_BATTLEFLG_ULTIMATE; // ʧ ū + CHAR_setWorkInt( enemyindex, CHAR_WORKBATTLEFLG, flg ); + BATTLE_Exit( enemyindex, battleindex ); + } + + // ú + //BATTLE_BroadCast( battleindex, szBuffer, CHAR_COLORYELLOW ); + +} + + +//************************************************************* +// +// ɧٱ忢姽 +// +void BATTLE_NormalDeadExtra( + int battleindex, // ̼͵ + int charaindex, // ڽƽҷ¼̼͵ + int enemyindex // ڽľƽҷ¼̼͵ +) +// +// +//************************************************************* +{ + int pindex, pno; + char szBuffer[256]=""; + + szBuffer[0] = 0; + + // ƥ + // 缰 + // ͼ ئ + if( CHAR_getInt( enemyindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER + && BattleArray[battleindex].type == BATTLE_TYPE_P_vs_E + && BattleArray[battleindex].norisk == 0 + ){ + int levelflg = 1; + // м ëƱ + // ì߶Ʊз зƱ + if( CHAR_getInt( enemyindex, CHAR_LV ) <= 10 ){ + levelflg = 2; + } + CHAR_AddCharm( enemyindex, CH_FIX_PLAYERDEAD/levelflg ); + // 帨ƻʸ ëƱ + pno = CHAR_getInt( enemyindex, CHAR_DEFAULTPET ); + if( 0 <= pno && pno < CHAR_MAXPETHAVE ){ + // ʸ̼͵ + pindex = CHAR_getCharPet( enemyindex, pno ); + if( CHAR_CHECKINDEX( pindex ) == TRUE ){ + CHAR_PetAddVariableAi( pindex, AI_FIX_PLAYERDEAD/levelflg ); + } + } + // Ϸƽҷ¼Ѩ٨ľ + CHAR_setWorkInt( enemyindex, CHAR_WORKBATTLECOM1, BATTLE_COM_NONE ); + }else + // ʸئ + if( CHAR_getInt( enemyindex, CHAR_WHICHTYPE ) == CHAR_TYPEPET + && BattleArray[battleindex].type == BATTLE_TYPE_P_vs_E + && BattleArray[battleindex].norisk == 0 + ){ + int levelflg = 1; + int playerindex = CHAR_getWorkInt( enemyindex, CHAR_WORKPLAYERINDEX ); + + // DZмì߶Ʊз зƱ + if( CHAR_getInt( playerindex, CHAR_LV ) <= 10 ){ + levelflg = 2; + } + // мëƱ + CHAR_PetAddVariableAi( enemyindex, AI_FIX_PETDEAD/levelflg ); + // DZмʸϷּë + CHAR_setInt( playerindex, CHAR_DEADPETCOUNT, + CHAR_getInt( playerindex, CHAR_DEADPETCOUNT ) + 1 ); + + // Ϸƽҷ¼Ѩ٨ľ + CHAR_setWorkInt( enemyindex, CHAR_WORKBATTLECOM1, BATTLE_COM_NONE ); + + }else{ + // ľ½ + } + + //snprintf( szBuffer, sizeof(szBuffer), + // "(%s)ʧȥʶ", + // CHAR_getUseName( enemyindex ) ); + + //BATTLE_BroadCast( battleindex, szBuffer, CHAR_COLORYELLOW ); + +} + +#ifndef DANTAI +void BATTLE_EscapeDpSend( int battleindex, int charaindex ) +{ + + int enemyside, cnt, dpadd; + BATTLE_ENTRY *pEntry; + + if( BATTLE_CHECKINDEX( battleindex ) == FALSE ){ + return; + } + + if( BattleArray[battleindex].type != BATTLE_TYPE_P_vs_P ){ + return; + } + if( BattleArray[battleindex].flg & BATTLE_FLG_FREEDP ){ + CHAR_setWorkInt( charaindex, CHAR_WORKGETEXP, 0 ); + return ; + } + BattleArray[battleindex].flg |= BATTLE_FLG_CHARALOST; + enemyside = 1 - CHAR_getWorkInt( charaindex, CHAR_WORKBATTLESIDE ); + pEntry = BattleArray[battleindex].Side[enemyside].Entry; + cnt = BATTLE_CountAlive( battleindex, enemyside ); + if( cnt == 0 )return; + int indexfloor = CHAR_getInt( charaindex, CHAR_FLOOR); + if(indexfloor==11111) + { + dpadd = getBalltePoint(0); + } + else if(indexfloor==22222) + { + dpadd = getBalltePoint(1); + } + else if(indexfloor==33333) + { + dpadd = getBalltePoint(2); + } + else if(indexfloor==44444) + { + dpadd = getBalltePoint(3); + } + else + { + dpadd = CHAR_getInt( charaindex, CHAR_DUELPOINT ) * DUELPOINT_RATE; + } + if( dpadd < 1 )dpadd = 1; + CHAR_setWorkInt( charaindex, CHAR_WORKGETEXP, -dpadd*2 ); + dpadd /= cnt; + if( dpadd < 1 )dpadd = 1; + BATTLE_AddDpAlive( battleindex, enemyside, dpadd ); +} +#else +void BATTLE_EscapeDpSend( int battleindex, int charaindex ) +{ + + int enemyside, dpadd; + BATTLE_ENTRY *pEntry; + + // Nuke 0725: Avoid too large number + if ((battleindex<0)||(battleindex>getBattlenum())) return; + // ½ + if( BattleArray[battleindex].type != BATTLE_TYPE_P_vs_P ){ + return; + } + + // + enemyside = 1 - CHAR_getWorkInt( charaindex, CHAR_WORKBATTLESIDE ); + + pEntry = BattleArray[battleindex].Side[enemyside].Entry; + + // 촡ë + dpadd = CHAR_getInt( charaindex, CHAR_DUELPOINT ) * DUELPOINT_RATE; + if( dpadd < 1 )dpadd = 1; // ƥ֨ + + // о¦л + CHAR_setWorkInt( charaindex, CHAR_WORKGETEXP, -dpadd*2 ); + + // 촡巴 + BattleArray[battleindex].Side[enemyside].common_dp += dpadd; + + +} +#endif + + +#ifndef DANTAI +int BATTLE_AddDuelPoint( int battleindex, int *pBidList ) +{ + int enemyindex, i, side, num, j, k, + charaindex[BATTLE_ENTRY_MAX+1]; + BATTLE_ENTRY + *pEntryEnemy; + int allnum = 0; + int bid = pBidList[0]; + + if( pBidList < 0 )return BATTLE_ERR_PARAM; + if( bid >= SIDE_OFFSET ){ + num = bid - SIDE_OFFSET; + side = 1; + }else{ + num = bid ; + side = 0; + } + + if( BATTLE_CHECKINDEX( battleindex ) == FALSE )return BATTLE_ERR_BATTLEINDEX; + if( BATTLE_CHECKSIDE( side ) == FALSE )return BATTLE_ERR_PARAM; + if( num < 0 || num >= BATTLE_ENTRY_MAX )return BATTLE_ERR_PARAM; + + for( i = 0; i < BATTLE_ENTRY_MAX + 1 ; i ++ ){ + charaindex[i] = -1; + } + + for( i = 0; i < BATTLE_ENTRY_MAX && pBidList[i] != -1 ; i ++ ){ + int work; + work = BATTLE_No2Index( battleindex, pBidList[i] ); + if( work < 0 )return BATTLE_ERR_PARAM; + if( CHAR_getInt( work, CHAR_WHICHTYPE ) == CHAR_TYPEENEMY ){ + continue; + } + if( CHAR_getInt( work, CHAR_WHICHTYPE ) == CHAR_TYPEPET ){ + work = CHAR_getWorkInt( work, CHAR_WORKPLAYERINDEX ); + } + if( work < 0 )return BATTLE_ERR_PARAM; + for( k = 0; k < allnum; k ++ ){ + if( charaindex[i] == work )break; + } + if( i < allnum )continue; + charaindex[i] = work; + allnum ++; + } + charaindex[i] = -1; + + for( j = 0; j < 2; j ++ ){ + pEntryEnemy = BattleArray[battleindex].Side[j].Entry; + for( i = 0; i < BATTLE_ENTRY_MAX; i ++ ){ + int enemytype = 0; + enemyindex = pEntryEnemy[i].charaindex; + if( CHAR_CHECKINDEX( enemyindex ) == FALSE )continue; + if( CHAR_getInt( enemyindex, CHAR_HP ) <= 0 + && CHAR_getFlg( enemyindex, CHAR_ISDIE ) == FALSE){ + }else{ + continue; + } + enemytype = CHAR_getInt( enemyindex, CHAR_WHICHTYPE ); + if( enemytype == CHAR_TYPEPLAYER ){ + BattleArray[battleindex].flg |= BATTLE_FLG_CHARALOST; + } + if( enemytype == CHAR_TYPEPLAYER || enemytype == CHAR_TYPEENEMY ){ + int dpadd, dpnow; + int indexfloor = CHAR_getInt(enemyindex,CHAR_FLOOR); + if(indexfloor == 11111)dpadd = getBalltePoint(0); + if(indexfloor == 22222)dpadd = getBalltePoint(1); + if(indexfloor == 33333)dpadd = getBalltePoint(2); + if(indexfloor == 44444)dpadd = getBalltePoint(3); + if(indexfloor==11111|| + indexfloor==22222|| + indexfloor==33333|| + indexfloor==44444) //жڵͼ + { +// dpnow = CHAR_getWorkInt( enemyindex, CHAR_WORKVIPPOINT ); +// dpnow -= dpadd; +// CHAR_setWorkInt( enemyindex, CHAR_WORKGETEXP, +// CHAR_getWorkInt( enemyindex, CHAR_WORKGETEXP) - dpadd ); + } + else + { + dpnow = CHAR_getInt( enemyindex, CHAR_DUELPOINT ); + dpadd = dpnow * DUELPOINT_RATE; + dpnow -= dpadd; + CHAR_setWorkInt( enemyindex, CHAR_WORKGETEXP, + CHAR_getWorkInt( enemyindex, CHAR_WORKGETEXP) - dpadd ); + } + if( side != j ){ + for( k = 0; charaindex[k] != -1; k ++ ); + if( k <= 0 )k = 1; + dpadd /= k; + if( dpadd <= 0 ) dpadd = 1; + for( k = 0; charaindex[k] != -1; k ++ ){ + CHAR_setWorkInt( charaindex[k], CHAR_WORKGETEXP, + CHAR_getWorkInt( charaindex[k], CHAR_WORKGETEXP ) + dpadd ); + } + }else{ + int dpdiv = dpadd, alive; + alive = BATTLE_CountAlive( battleindex, 1-j ); + if( alive <= 0 )alive = 1; + dpdiv /= alive; + if( dpdiv <= 0 )dpdiv = 1; + BATTLE_AddDpAlive( battleindex, 1-j, dpdiv ); + } + } + CHAR_setFlg( enemyindex, CHAR_ISDIE, 1 ); + CHAR_setInt( enemyindex, CHAR_DEADCOUNT, + CHAR_getInt( enemyindex, CHAR_DEADCOUNT ) + 1 ); + + if( pEntryEnemy[i].flg & BENT_FLG_ULTIMATE ){ + BATTLE_GetProfit( battleindex, j, i ); + BATTLE_UltimateExtra( battleindex, charaindex[0], enemyindex ); + }else{ + BATTLE_NormalDeadExtra( battleindex, charaindex[0], enemyindex ); + } + } + } + return 0; +} +#else + +int BATTLE_AddDuelPoint( + int battleindex, + int *pBidList ) +{ + int enemyindex, i, otherside, j, + charaindex[BATTLE_ENTRY_MAX+1]; + BATTLE_ENTRY + *pEntryEnemy; + if( pBidList < 0 )return BATTLE_ERR_PARAM; + if( BATTLE_CHECKINDEX( battleindex ) == FALSE )return BATTLE_ERR_BATTLEINDEX; + for( j = 0; j < 2; j ++ ){ + pEntryEnemy = BattleArray[battleindex].Side[j].Entry; + otherside = 1 - j; + for( i = 0; i < BATTLE_ENTRY_MAX; i ++ ){ + enemyindex = pEntryEnemy[i].charaindex; + if( CHAR_CHECKINDEX( enemyindex ) == FALSE )continue; + if( CHAR_getInt( enemyindex, CHAR_HP ) <= 0 + && CHAR_getFlg( enemyindex, CHAR_ISDIE ) == FALSE){ + }else{ + continue; + } + + CHAR_setFlg( enemyindex, CHAR_ISDIE, 1 ); + CHAR_setInt( enemyindex, CHAR_DEADCOUNT, + CHAR_getInt( enemyindex, CHAR_DEADCOUNT ) + 1 ); + if( pEntryEnemy[i].flg & BENT_FLG_ULTIMATE ){ + if( CHAR_getInt( enemyindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER ){ + int dpadd, dpnow; + dpnow = CHAR_getInt( enemyindex, CHAR_DUELPOINT ); + dpadd = dpnow * DUELPOINT_RATE; // м + dpnow -= dpadd; + CHAR_setWorkInt( enemyindex, CHAR_WORKGETEXP, + CHAR_getWorkInt( enemyindex, CHAR_WORKGETEXP) - dpadd ); + BattleArray[battleindex].Side[otherside].common_dp += dpadd; + BATTLE_GetProfit( battleindex, j, i ); + } + BATTLE_UltimateExtra( battleindex, charaindex[0], enemyindex ); + }else{ + BATTLE_NormalDeadExtra( battleindex, charaindex[0], enemyindex ); + } + } + } + return 0; +} +#endif + +int BATTLE_ItemDelCheck( int itemindex ) +{ int icnt, jcnt, playernum; + playernum = getFdnum(); + for( icnt = 0; icnt < playernum; icnt ++ ) { + if( CHAR_CHECKINDEX( icnt ) ) { + for( jcnt = 0; jcnt < CHAR_MAXITEMHAVE; jcnt ++ ) { + if( CHAR_getItemIndex( icnt, jcnt ) == itemindex ) { + //print( "err:սƷֵitem(%s)(%s)index(%d)\n", + // CHAR_getUseName(icnt),ITEM_getAppropriateName(itemindex), + // itemindex ); + return FALSE; + } + } + } + } + return TRUE; +} + +int BATTLE_AddExpItem( int battleindex, int *pBidList ) +{ + int enemyindex, i, side, num, proflg = 1, j, exp, k, enemylevel, + charaindex[BATTLE_ENTRY_MAX+1]; + BATTLE_ENTRY + *pEntryEnemy, + *pEntryChara[BATTLE_ENTRY_MAX+1], + *pEntryPlayer[BATTLE_ENTRY_MAX+1]; + int item=0,itemindex,itemloop,allnum = 0; + int bid = pBidList[0]; + if( pBidList[0] < 0 )return BATTLE_ERR_PARAM; + if( bid >= SIDE_OFFSET ){ + num = bid - SIDE_OFFSET; + side = 1; + }else{ + num = bid ; + side = 0; + } + if( BATTLE_CHECKSIDE( side ) == FALSE )return BATTLE_ERR_PARAM; + if( num < 0 || num >= BATTLE_ENTRY_MAX )return BATTLE_ERR_PARAM; + for( i = 0; i < BATTLE_ENTRY_MAX + 1 ; i ++ ){ + charaindex[i] = -1; + pEntryPlayer[i] = NULL; + } + if( BattleArray[battleindex].Side[side].type != BATTLE_S_TYPE_PLAYER + || BattleArray[battleindex].Side[1-side].type == BATTLE_S_TYPE_PLAYER){ + proflg = 0; + } +#ifdef _SHARE_EXP //ŶӾ鹲 + if(getExpShare()==1){ + for( i = 0; i < BATTLE_ENTRY_MAX ; i ++ ){ + if( BattleArray[battleindex].type == BATTLE_TYPE_P_vs_E ){ + charaindex[i] = BATTLE_No2Index( battleindex, i); + //if( charaindex[i] < 0 )return BATTLE_ERR_PARAM; + pEntryChara[i] = &BattleArray[battleindex].Side[side].Entry[i]; + pEntryPlayer[i] = pEntryChara[i]; + } + } + }else{ + for( i = 0; i < BATTLE_ENTRY_MAX && pBidList[i] != -1 ; i ++ ) + { + int subnum; + charaindex[i] = BATTLE_No2Index( battleindex, pBidList[i] ); + if( charaindex[i] < 0 )return BATTLE_ERR_PARAM; + subnum = pBidList[i]-side*SIDE_OFFSET; + pEntryChara[i] = &BattleArray[battleindex].Side[side].Entry[subnum]; + if( CHAR_getInt( charaindex[i], CHAR_WHICHTYPE ) == CHAR_TYPEPET ){ + pEntryPlayer[i] = &BattleArray[battleindex].Side[side].Entry[subnum-5]; + }else{ + pEntryPlayer[i] = pEntryChara[i]; + } + } + } + +#else + for( i = 0; i < BATTLE_ENTRY_MAX && pBidList[i] != -1 ; i ++ ) + { + int subnum; + charaindex[i] = BATTLE_No2Index( battleindex, pBidList[i] ); + if( charaindex[i] < 0 )return BATTLE_ERR_PARAM; + subnum = pBidList[i]-side*SIDE_OFFSET; + pEntryChara[i] = &BattleArray[battleindex].Side[side].Entry[subnum]; + if( CHAR_getInt( charaindex[i], CHAR_WHICHTYPE ) == CHAR_TYPEPET ){ + pEntryPlayer[i] = &BattleArray[battleindex].Side[side].Entry[subnum-5]; + }else{ + pEntryPlayer[i] = pEntryChara[i]; + } + } +#endif + charaindex[i] = -1; + allnum = i; + for( j = 0; j < 2; j ++ ){ + pEntryEnemy = BattleArray[battleindex].Side[j].Entry; + for( i = 0; i < BATTLE_ENTRY_MAX; i ++ ){ + enemyindex = pEntryEnemy[i].charaindex; + if( CHAR_CHECKINDEX( enemyindex ) == FALSE )continue; + + if( CHAR_getInt( enemyindex, CHAR_HP ) <= 0 + && CHAR_getFlg( enemyindex, CHAR_ISDIE ) == FALSE ){ + }else{ + continue; + } + if( proflg == 1 && side != j ){ + if( CHAR_getInt( enemyindex, CHAR_WHICHTYPE ) != CHAR_TYPEENEMY ){ + //print( "\nerr: ȡսƷ(%s:%d)\n", + // __FILE__, __LINE__ ); + } + for(item=CHAR_STARTITEMARRAY; item < CHAR_STARTITEMARRAY+10; item++){ + itemindex = CHAR_getItemIndex( enemyindex, item ); + if(ITEM_CHECKINDEX( itemindex ) == FALSE ){ + continue; + } + if( ITEM_getWorkInt( itemindex, ITEM_WORKCHARAINDEX ) <= getFdnum() ){ + //print( "\nerr: ҵitemսƷ(%s:%d)\n", + // __FILE__, __LINE__ ); + continue; + } + CHAR_setItemIndex( enemyindex, item, -1 ); + k = RAND( 0, (allnum-1) ); + for(itemloop=0;itemloop<3;itemloop++){ + if(pEntryPlayer[k]->getitem[itemloop]==-1){ + pEntryPlayer[k]->getitem[itemloop]=itemindex; + break; + } + } + if( itemloop >= 3 ){ + if( RAND( 0, 1 ) ) { + int olditem; + int randwork = RAND( 0, 2 ); + olditem = pEntryPlayer[k]->getitem[randwork]; + pEntryPlayer[k]->getitem[randwork]=itemindex; + if( BATTLE_ItemDelCheck( olditem ) == TRUE ){ + ITEM_endExistItemsOne(olditem); + } + }else { + ITEM_endExistItemsOne(itemindex); + } + } + + } + +#define EXPGET_MAXLEVEL 5 +#define EXPGET_DIV 15 + exp = CHAR_getInt( enemyindex, CHAR_EXP ); + enemylevel = CHAR_getInt( enemyindex, CHAR_LV ); +#ifdef _SHARE_EXP + for( k = 0; k<10; k ++ ){ + if(charaindex[k]==-1) continue; +#else + for( k = 0; charaindex[k] != -1; k ++ ){ +#endif + int nowexp, b_level; + int ridepet; + b_level = CHAR_getInt( charaindex[k], CHAR_LV ) - enemylevel; + if( b_level <= EXPGET_MAXLEVEL ){// 5 + nowexp = exp; + }else{//춹5 + b_level = EXPGET_MAXLEVEL+EXPGET_DIV - b_level; + if( b_level > EXPGET_DIV ) b_level = EXPGET_DIV; + if( b_level <= 0 ){ + nowexp = 1; + }else{ + nowexp = exp * b_level / EXPGET_DIV; + } + if( nowexp < 1 ) nowexp = 1; + } + CHAR_setWorkInt( charaindex[k], CHAR_WORKGETEXP, + CHAR_getWorkInt( charaindex[k], CHAR_WORKGETEXP ) + nowexp ); + CHAR_setInt( charaindex[k], CHAR_KILLPETCOUNT, + CHAR_getInt( charaindex[k], CHAR_KILLPETCOUNT ) + 1 ); + if( CHAR_getInt( charaindex[k], CHAR_WHICHTYPE) == CHAR_TYPEPLAYER && CHAR_getInt( charaindex[k], CHAR_LV) >= 140 ){ + int toitemindex = -1; + toitemindex = CHAR_getItemIndex( charaindex[k], 9); + if(ITEM_CHECKINDEX(toitemindex)){ + if( strlen(ITEM_getChar( toitemindex, ITEM_USEFUNC))>0 && strcmp(ITEM_getChar( toitemindex, ITEM_USEFUNC),"ITEM_useExpLv")==0 ){ + char* itemarg = ITEM_getChar(toitemindex,ITEM_ARGUMENT); + char buftest[128]; + int itemlv = 0; + if(getStringFromIndexWithDelim(itemarg,"|", 1, buftest, sizeof(buftest)) == TRUE){ + itemlv = atoi(buftest); + b_level = itemlv - enemylevel; + if( b_level <= EXPGET_MAXLEVEL ){// 5 + nowexp = exp; + }else{//춹5 + b_level = EXPGET_MAXLEVEL+EXPGET_DIV - b_level; + if( b_level > EXPGET_DIV ) b_level = EXPGET_DIV; + if( b_level <= 0 ){ + nowexp = 1; + }else{ + nowexp = exp * b_level / EXPGET_DIV; + } + if( nowexp < 1 ) nowexp = 1; + } + CHAR_setWorkInt(charaindex[k],CHAR_WORKITEMEXP,CHAR_getWorkInt(charaindex[k],CHAR_WORKITEMEXP)+nowexp); + } + } + } + } + ridepet = BATTLE_getRidePet( charaindex[k] ); + //andy_edit + if( CHAR_CHECKINDEX( ridepet) ){ + int nowexp, b_level; + b_level = CHAR_getInt( ridepet, CHAR_LV ) - enemylevel; + if( b_level <= EXPGET_MAXLEVEL ){ + nowexp = exp; + }else{ + b_level = EXPGET_MAXLEVEL+EXPGET_DIV - b_level; + if( b_level > EXPGET_DIV ) b_level = EXPGET_DIV; + if( b_level <= 0 ){ + nowexp = 1; + }else{ + nowexp = exp * b_level / EXPGET_DIV; + } + if( nowexp < 1 ) nowexp = 1; + } + nowexp *= 0.6; + CHAR_setWorkInt( ridepet, CHAR_WORKGETEXP, + CHAR_getWorkInt( ridepet, CHAR_WORKGETEXP ) + nowexp ); + CHAR_setInt( ridepet, CHAR_KILLPETCOUNT, + CHAR_getInt( ridepet, CHAR_KILLPETCOUNT ) + 1 ); + } + if( BattleArray[battleindex].norisk == 0 + && CHAR_getInt( charaindex[k], CHAR_WHICHTYPE ) == CHAR_TYPEPET){ + if( CHAR_getInt( enemyindex, CHAR_LV ) > CHAR_getInt( charaindex[k], CHAR_LV ) ){ + CHAR_PetAddVariableAi( charaindex[k], AI_FIX_PETGOLDWIN ); + }else{ + CHAR_PetAddVariableAi( charaindex[k], AI_FIX_PETWIN ); + } + } + } + CHAR_setMaxExp( enemyindex, 0); + } + CHAR_setFlg( enemyindex, CHAR_ISDIE, 1 ); +#ifdef _PET_LIMITLEVEL + Pet_Check_Die( enemyindex ); +#endif + CHAR_setInt( enemyindex, CHAR_DEADCOUNT, + CHAR_getInt( enemyindex, CHAR_DEADCOUNT ) + 1 ); + if( pEntryEnemy[i].flg & BENT_FLG_ULTIMATE ){ + BATTLE_UltimateExtra( battleindex, charaindex[0], enemyindex ); + }else{ + BATTLE_NormalDeadExtra( battleindex, charaindex[0], enemyindex ); + } + } + } + return 0; +} + +#ifdef _PET_LIMITLEVEL +void Pet_Check_Die( int petindex ) +{ + + int LevelUpPoint; + int vital, str, tgh, dex; + float modai; + +#define RAND(x,y) ((x-1)+1+ (int)( (double)(y-(x-1))*rand()/(RAND_MAX+1.0)) ) + // ۻԼҳ + if( CHAR_getInt( petindex, CHAR_PETID) == 718 ) { + LevelUpPoint = CHAR_getInt( petindex, CHAR_ALLOCPOINT ); + vital = (( LevelUpPoint >> 24 ) & 0xff); + str = (( LevelUpPoint >> 16 ) & 0xff); + tgh = (( LevelUpPoint >> 8 ) & 0xff); + dex = (( LevelUpPoint >> 0 ) & 0xff); +// enemyindex = pEntryEnemy[i].charaindex; + + //print("\n lvup <<%d %d %d %d>>", vital, str, tgh, dex ); + + vital = vital - RAND( 1, 8); + str = str - RAND( 1, 4); + tgh = tgh - RAND( 1, 4); + dex = dex - RAND( 1, 4); + //print("\n lvup <<%d %d %d %d>>", vital, str, tgh, dex ); + + if( vital < 0 ) vital = 0; + if( str < 0 ) str = 0; + if( tgh < 0 ) tgh = 0; + if( dex < 0 ) dex = 0; + + if( vital > 50 ) vital = 50; + if( str > 50 ) str = 50; + if( tgh > 50 ) tgh = 50; + if( dex > 50 ) dex = 50; + LevelUpPoint = ( vital << 24 ) + ( str << 16 ) + ( tgh << 8 ) + ( dex << 0 ); + CHAR_setInt( petindex, CHAR_ALLOCPOINT , LevelUpPoint ); + //print("\n lvup <<%d %d %d %d>>", vital, str, tgh, dex ); + modai = CHAR_getInt( petindex, CHAR_MODAI ); + modai = modai - ( (modai * 5) / 100 ); + CHAR_setInt( petindex, CHAR_MODAI, modai); + +// LogPetPointChange( +// CHAR_getChar( petindex, CHAR_OWNERCHARANAME), +// CHAR_getChar( petindex, CHAR_OWNERCDKEY), +// CHAR_getChar( petindex, CHAR_NAME), +// petindex, 2, +// CHAR_getInt( petindex, CHAR_LV), +// "battle_die(ս)", +// CHAR_getInt( petindex,CHAR_FLOOR), +// 0, +// 0 +// ); + } + return; + +} +#endif + +int BATTLE_AddProfit( int battleindex, int *pBidList) +{ + if( BATTLE_CHECKINDEX( battleindex ) == FALSE )return BATTLE_ERR_BATTLEINDEX; + + if( BattleArray[battleindex].dpbattle == 1 ){ + return BATTLE_AddDuelPoint( battleindex, pBidList ); + }else{ + return BATTLE_AddExpItem( battleindex, pBidList ); + } + +} + +int BATTLE_TargetCheck( + int battleindex, + int defNo +) +{ + int defindex = BATTLE_No2Index( battleindex, defNo ); + + if( CHAR_CHECKINDEX( defindex ) == FALSE + || CHAR_getWorkInt( defindex, CHAR_WORKBATTLEMODE ) == 0 + || CHAR_getFlg( defindex, CHAR_ISDIE ) == TRUE + || CHAR_getInt( defindex, CHAR_HP ) <= 0 + || CHAR_getFlg( defindex, CHAR_ISATTACKED ) == FALSE + || CHAR_getWorkInt( defindex, CHAR_WORKBATTLEMODE ) == BATTLE_CHARMODE_RESCUE + ){ + return FALSE; + } + return TRUE; +} + +int BATTLE_TargetCheckDead( + int battleindex, + int defNo +) +{ + int defindex = BATTLE_No2Index( battleindex, defNo ); + if( CHAR_CHECKINDEX( defindex ) == FALSE + || CHAR_getWorkInt( defindex, CHAR_WORKBATTLEMODE ) == 0 + || CHAR_getWorkInt( defindex, CHAR_WORKBATTLEMODE ) == BATTLE_CHARMODE_RESCUE + || CHAR_getFlg( defindex, CHAR_ISATTACKED ) == FALSE + || CHAR_getFlg( defindex, CHAR_ISDIE ) == FALSE ){ + //BATTLE_CHARMODE_RESCUE 5 +// print("\n [ %d, %d, %d, %d]", +// CHAR_getWorkInt( defindex, CHAR_WORKBATTLEMODE ), +// CHAR_getWorkInt( defindex, CHAR_WORKBATTLEMODE ), +// CHAR_getFlg( defindex, CHAR_ISATTACKED ), +// CHAR_getFlg( defindex, CHAR_ISDIE )); + return FALSE; + } + return TRUE; +} + + + + +int BATTLE_TargetAdjust( int battleindex, int charaindex, int myside ) +{ + int defNo; + + defNo = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM2 ); + + if( BATTLE_TargetCheck( battleindex, defNo ) == FALSE ){ + defNo = BATTLE_DefaultAttacker( battleindex, 1 - myside ); + } + + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, defNo ); + + return defNo; +} + +void Compute_Down( int charaindex, int rideindex, int *down1, int *down2, int flg) +{ + int hp=0, pethp=0; + int downs = 0; + + *down1 = 0; + *down2 = 0; + // + downs = + CHAR_getInt( charaindex, CHAR_VITAL ) + + CHAR_getInt( charaindex, CHAR_STR ) + + CHAR_getInt( charaindex, CHAR_DEX ) + + CHAR_getInt( charaindex, CHAR_TOUGH ); + if( (downs = (((downs/100)-20)/4)) < 1 ) + downs = 1; + hp = CHAR_getInt( charaindex, CHAR_HP ); + if( hp <= downs ) downs = hp - 1; + if( downs >= 0 ){ + hp = ((hp-downs)<1)?1:(hp-downs); + CHAR_setInt( charaindex, CHAR_HP, hp ); + *down1 = downs; + } + if( flg == -1 ) { + }else {//˳ + if( !CHAR_CHECKINDEX( rideindex)) return; + downs = + CHAR_getInt( rideindex, CHAR_VITAL ) + + CHAR_getInt( rideindex, CHAR_STR ) + + CHAR_getInt( rideindex, CHAR_DEX ) + + CHAR_getInt( rideindex, CHAR_TOUGH ); + if( (downs = (((downs/100)-20)/4)) < 1 ) + downs = 1; + pethp = CHAR_getInt( rideindex, CHAR_HP ); + if( pethp <= downs ) downs = pethp - 1; + if( downs >= 0 ){ + pethp = ((pethp-downs)<1)?1:(pethp-downs); + + CHAR_setInt( rideindex, CHAR_HP, pethp); + *down2 = downs; + } + } +} + +#ifdef _PET_SKILL_SARS // WON ADD ɷ +void Compute_Down_SARS( int charaindex, int rideindex, int *down1, int *down2, int flg) +{ + int hp=0, pethp=0; + int downs = 0; + + *down1 = 0; + *down2 = 0; + // +/* + downs = + CHAR_getInt( charaindex, CHAR_VITAL ) + + CHAR_getInt( charaindex, CHAR_STR ) + + CHAR_getInt( charaindex, CHAR_DEX ) + + CHAR_getInt( charaindex, CHAR_TOUGH ); + if( (downs = (((downs/100)-20)/4)) < 1 ) + downs = 1; +*/ + + hp = CHAR_getInt( charaindex, CHAR_HP ); + downs = hp * 10 / 100; + + if( hp <= downs ) downs = hp - 1; + if( downs >= 0 ){ + hp = ((hp-downs)<1)?1:(hp-downs); + CHAR_setInt( charaindex, CHAR_HP, hp ); + *down1 = downs; + } + if( flg == -1 ) { + }else {//˳ + if( !CHAR_CHECKINDEX( rideindex)) return; + downs = + CHAR_getInt( rideindex, CHAR_VITAL ) + + CHAR_getInt( rideindex, CHAR_STR ) + + CHAR_getInt( rideindex, CHAR_DEX ) + + CHAR_getInt( rideindex, CHAR_TOUGH ); + if( (downs = (((downs/100)-20)/4)) < 1 ) + downs = 1; + pethp = CHAR_getInt( rideindex, CHAR_HP ); + if( pethp <= downs ) downs = pethp - 1; + if( downs >= 0 ){ + pethp = ((pethp-downs)<1)?1:(pethp-downs); + + CHAR_setInt( rideindex, CHAR_HP, pethp); + *down2 = downs; + } + } +} +#endif + +#ifdef _PROFESSION_ADDSKILL +void WorkIceCrackPlay(int charaindex, int cnt, int workicecracknum ) +{ + char szBuffer[256]=""; + int i,value=0; + int battleindex = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEINDEX ); + int defNo = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM2 );//defNo = BATTLE_Index2No( battleindex, charaindex ); + int ridepet = BATTLE_getRidePet( charaindex ); + int bid = BATTLE_Index2No( battleindex, charaindex ); + value = CHAR_getWorkInt( charaindex, workicecracknum ); + + if( cnt <= 0 && value > 0 ){ + int damage=0, petdamage=0; + + int ToList[SIDE_OFFSET*2+1]; + memset( ToList, -1, sizeof( ToList)); + BATTLE_MultiList( battleindex, TARGET_SIDE_1, ToList ); + // ħ붯 + analysis_profession_parameter( 2, 4, defNo, charaindex ); + PROFESSION_MAGIC_ATTAIC_Effect( battleindex, bid, ToList, 2); + + if( defNo == 20 || defNo == 25 || defNo == 26 )// + bid = 0; + else + bid = 10; + + + for( i = bid ; i < bid+10 ; i++ ) { + int defType, charaidx, petidx; + charaidx = BATTLE_No2Index( battleindex , i); + if( CHAR_CHECKINDEX( charaidx ) ){ + if( CHAR_getInt( charaidx, CHAR_HP ) > 0 ){ + int hp,pethp = 0; + petidx = BATTLE_getRidePet( charaidx ); + defType = CHAR_getInt(charaidx, CHAR_WHICHTYPE); + CHAR_setWorkInt( charaidx, workicecracknum, 0 ); + + damage = value; + + hp = CHAR_getInt( charaidx, CHAR_HP ); + if( petidx == -1 ) { + hp -= damage; + if( hp < 0 ) hp = 0; + }else { + int defquick=0, petquick=0, playerdamage=0; + pethp = CHAR_getInt( petidx, CHAR_HP ); + defquick = CHAR_getWorkInt( charaidx, CHAR_WORKDEFENCEPOWER ); + petquick = CHAR_getWorkInt( petidx, CHAR_WORKDEFENCEPOWER ); + if( pethp > 0 ){ + playerdamage = (damage*petquick)/(defquick+petquick) +1; + petdamage = damage - playerdamage +1 ; + hp -= playerdamage; + pethp -= petdamage; + }else{ + hp -= damage; + } + if( hp < 0 ) hp = 0; + if( pethp < 0 ) pethp = 0; + CHAR_setInt( petidx, CHAR_HP, pethp ); + } + + CHAR_setInt( charaidx, CHAR_HP, hp ); + + if( hp <= 0 ){ + CHAR_setFlg( charaidx, CHAR_ISDIE, 1 ); + CHAR_setWorkInt( charaidx, CHAR_WORKBATTLECOM1, BATTLE_COM_NONE ); + } + if( pethp <= 0 ){ + CHAR_setFlg( petidx, CHAR_ISDIE, 1 ); + CHAR_setWorkInt( ridepet, CHAR_WORKBATTLECOM1, BATTLE_COM_NONE ); + } + + + if( damage >= 0 ){ + sprintf( szBuffer , "%X|%X|%X|%X|" , i , i ,(int)(damage) , (int)(petdamage)); + BATTLESTR_ADD( szBuffer ); + } + if( petidx != -1 && petdamage >= 0 ){ + + } + } + } + } + sprintf( szBuffer , "%X|" , 0x5711438 ); + BATTLESTR_ADD( szBuffer ); + } +} +#endif + +static int BATTLE_StatusSeq( int charaindex ) +{ + int cnt, i, bid, battleindex, down; + char szBuffer[256]=""; +#ifdef _MAGIC_DEEPPOISON + int defNo,defindex=0; + char szCommand[1024]; +#endif + int ridepet = BATTLE_getRidePet( charaindex ); + int hp=0, pethp=0; + + + battleindex = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEINDEX ); + +#ifdef _MAGIC_DEEPPOISON + defNo = BATTLE_Index2No( battleindex, charaindex ); + defindex = BATTLE_No2Index( battleindex, defNo ); +#endif + bid = BATTLE_Index2No( battleindex, charaindex ); + if( BATTLE_CanMoveCheck( charaindex ) == FALSE ){ + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_NONE ); + } + + for( i = 1; i < BATTLE_ST_END; i++ ){ + if( ( cnt = CHAR_getWorkInt( charaindex, StatusTbl[i] )) <= 0 )continue; + CHAR_setWorkInt( charaindex, StatusTbl[i], --cnt ); +#ifdef _MAGIC_WEAKEN // + if(CHAR_getWorkInt(charaindex,CHAR_WORKWEAKEN) > 0) + CHAR_setWorkInt( charaindex, StatusTbl[i], cnt+1 ); +#endif +#ifdef _MAGIC_BARRIER// vincent :ħ + if(CHAR_getWorkInt(charaindex,CHAR_WORKBARRIER) > 0) + CHAR_setWorkInt( charaindex, StatusTbl[i], cnt+1 ); +#endif + + +#ifdef _PROFESSION_SKILL // WON ADD ְҵ + if( cnt <= 0 && ( StatusTbl[i] != CHAR_WORKICECRACK ) +#ifdef _PROFESSION_ADDSKILL + && ( StatusTbl[i] != CHAR_WORKICECRACK2 ) + && ( StatusTbl[i] != CHAR_WORKICECRACK3 ) + && ( StatusTbl[i] != CHAR_WORKICECRACK4 ) + && ( StatusTbl[i] != CHAR_WORKICECRACK5 ) + && ( StatusTbl[i] != CHAR_WORKICECRACK6 ) + && ( StatusTbl[i] != CHAR_WORKICECRACK7 ) + && ( StatusTbl[i] != CHAR_WORKICECRACK8 ) + && ( StatusTbl[i] != CHAR_WORKICECRACK9 ) + && ( StatusTbl[i] != CHAR_WORKICECRACK10 ) +#endif + ){ // +#else + if( cnt <= 0 ){ +#endif + BATTLE_BadStatusString( bid, 0 ); + //snprintf( szBuffer, sizeof( szBuffer ), "(%s)(%s)ϡ", + // CHAR_getUseName( charaindex ), aszStatusFull[i] ); + // BATTLE_BroadCast( battleindex, szBuffer, + // (bid >= 10)? CHAR_COLORGRAY : CHAR_COLORPURPLE ) ; +//Terry del +// sprintf( szBuffer, "BM|%X|%X|", bid, 0 ); +// BATTLESTR_ADD( szBuffer ); +#ifdef _MAGIC_NOCAST + if( StatusTbl[i] == CHAR_WORKNOCAST ){ + lssproto_NC_send( getfdFromCharaIndex( charaindex ), 0);//ԭ + } +#endif + if( StatusTbl[i] == CHAR_WORKDRUNK ){ + if( ridepet != -1 ){ + CHAR_setWorkInt( charaindex, CHAR_WORKQUICK, + CHAR_getWorkInt( charaindex, CHAR_WORKQUICK ) + + CHAR_getWorkInt( ridepet, CHAR_WORKQUICK ) ); + }else{ + CHAR_setWorkInt( charaindex, CHAR_WORKQUICK, + CHAR_getWorkInt( charaindex, CHAR_WORKQUICK ) * 2 ); + } + } + continue; + } + + switch( StatusTbl[i] ){ + + case CHAR_WORKPOISON: + { + int petdown=-1; + Compute_Down( charaindex, ridepet, &down, &petdown, ridepet); + if( down >= 0 ){ + //snprintf( szBuffer, sizeof( szBuffer ), + // "(%s)(%s)ܵ(%d)ˡ", + // CHAR_getUseName( charaindex ), + // aszStatusFull[i], + // down ); + //BATTLE_BroadCast( battleindex, szBuffer, + // (bid >= 10)? CHAR_COLORGRAY : CHAR_COLORPURPLE ) ; + +#ifdef _NOTRIDE_ + sprintf( szBuffer, "BD|r%X|0|0|%X|", bid, (int)(down) ); + BATTLESTR_ADD( szBuffer ); +#else + sprintf( szBuffer, "BD|r%X|0|0|%X|p%X|", bid, (int)(down), (int)(petdown) ); + BATTLESTR_ADD( szBuffer ); +#endif + } + if( ridepet != -1 && petdown >= 0 ){ + //snprintf( szBuffer, sizeof( szBuffer ), + // "(%s)(%s)ܵ(%d)ˡ", + // CHAR_getUseName( charaindex ), + // aszStatusFull[i], petdown ); + //BATTLE_BroadCast( battleindex, szBuffer, + // (bid >= 10)? CHAR_COLORGRAY : CHAR_COLORPURPLE ) ; + } + } + break; +#ifdef _MAGIC_DEEPPOISON + case CHAR_WORKDEEPPOISON: + if(CHAR_getInt( defindex, CHAR_HP ) <= 1){ + snprintf( szCommand, sizeof( szCommand ),"Bd|a%X|r%X|f%X|d%X|p%X|FF|",defNo,defNo,BCF_NORMAL,1, 0 ); + BATTLESTR_ADD( szCommand ); + CHAR_setInt( defindex, CHAR_HP,0); + CHAR_setWorkInt( defindex, CHAR_WORKBATTLECOM1, BATTLE_COM_NONE ); + CHAR_setFlg( defindex, CHAR_ISDIE, 1 ); + break; + } + + if(CHAR_getWorkInt( defindex, CHAR_WORKDEEPPOISON) <= 1){ + snprintf( szCommand, sizeof( szCommand ),"Bd|a%X|r%X|f%X|d%X|p%X|FF|",defNo,defNo,BCF_NORMAL,CHAR_getInt( charaindex, CHAR_HP), 0 ); + BATTLESTR_ADD( szCommand ); + CHAR_setInt( defindex, CHAR_HP,0); + CHAR_setFlg( defindex, CHAR_ISDIE, 1 ); + CHAR_setWorkInt( defindex, CHAR_WORKBATTLECOM1, BATTLE_COM_NONE ); + sprintf(szBuffer, "%sо綾δ!!", CHAR_getChar( defindex, CHAR_NAME )); + if( CHAR_getInt( defindex, CHAR_WHICHTYPE ) == CHAR_TYPEPET ){ + CHAR_talkToCli( CHAR_getWorkInt(defindex, CHAR_WORKPLAYERINDEX), -1, szBuffer, CHAR_COLORYELLOW); + }else{ + CHAR_talkToCli( defindex, -1, szBuffer, CHAR_COLORYELLOW); + } + break; + } + if( ridepet == -1 ){// Robin 0728 ride Pet + down = + CHAR_getInt( charaindex, CHAR_VITAL ) + + CHAR_getInt( charaindex, CHAR_STR ) + + CHAR_getInt( charaindex, CHAR_DEX ) + + CHAR_getInt( charaindex, CHAR_TOUGH ); + down = ( down / 100 - 20 ) / 4; + if( down < 1 ) down = 1; + hp = CHAR_getInt( charaindex, CHAR_HP ); + if( hp <= down ) down = hp - 1; + if( down >= 0 ){ + CHAR_setInt( charaindex, CHAR_HP, hp - down ); + //snprintf( szBuffer, sizeof( szBuffer ), + // "(%s)(%s)ܵ(%d)ˡ", + // CHAR_getUseName( charaindex ), + // aszStatusFull[i], + // down ); + //BATTLE_BroadCast( battleindex, szBuffer, + // (bid >= 10)? CHAR_COLORGRAY : CHAR_COLORPURPLE ) ; +#ifdef _NOTRIDE_ + sprintf( szBuffer, "BD|r%X|0|0|%X|", bid, (int)(down) ); + BATTLESTR_ADD( szBuffer ); +#else + sprintf( szBuffer, "BD|r%X|0|0|%X|p%X|", bid, (int)(down), 0 ); + BATTLESTR_ADD( szBuffer ); +#endif + } + break; + }else { + int petdown; + down = + CHAR_getInt( charaindex, CHAR_VITAL ) + + CHAR_getInt( charaindex, CHAR_STR ) + + CHAR_getInt( charaindex, CHAR_DEX ) + + CHAR_getInt( charaindex, CHAR_TOUGH ); + petdown = + CHAR_getInt( ridepet, CHAR_VITAL ) + + CHAR_getInt( ridepet, CHAR_STR ) + + CHAR_getInt( ridepet, CHAR_DEX ) + + CHAR_getInt( ridepet, CHAR_TOUGH ); + down = ( down / 100 - 20 ) / 4; + petdown = ( petdown / 100 - 20 ) /4; + if( down < 1 ) down = 1; + if( petdown < 1 ) petdown = 1; + hp = CHAR_getInt( charaindex, CHAR_HP ); + pethp = CHAR_getInt( ridepet, CHAR_HP ); + if( hp <= down ) down = hp - 1; + if( pethp <= petdown ) petdown = pethp - 1; + if( down >= 0 ){ + CHAR_setInt( charaindex, CHAR_HP, hp - down ); + //snprintf( szBuffer, sizeof( szBuffer ), + // "(%s)(%s)ܵ(%d)ˡ", + // CHAR_getUseName( charaindex ), + // aszStatusFull[i], + // down ); + //BATTLE_BroadCast( battleindex, szBuffer, + // (bid >= 10)? CHAR_COLORGRAY : CHAR_COLORPURPLE ) ; + #ifdef _NOTRIDE_ + sprintf( szBuffer, "BD|r%X|0|0|%X|", bid, (int)(down) ); + BATTLESTR_ADD( szBuffer ); + #else + sprintf( szBuffer, "BD|r%X|0|0|%X|p%X|", bid, (int)(down), (int)(petdown) ); + BATTLESTR_ADD( szBuffer ); + #endif + } + if( petdown >= 0 ){ + CHAR_setInt( ridepet, CHAR_HP, pethp - petdown ); + //snprintf( szBuffer, sizeof( szBuffer ), + // "(%s)(%s)ܵ(%d)ˡ", + // CHAR_getUseName( charaindex ), + // aszStatusFull[i], + // petdown ); + //BATTLE_BroadCast( battleindex, szBuffer, + // (bid >= 10)? CHAR_COLORGRAY : CHAR_COLORPURPLE ) ; + } + break; + } +#endif +#ifdef _MAGIC_NOCAST // :Ĭ + case CHAR_WORKNOCAST: + lssproto_NC_send( getfdFromCharaIndex( charaindex ), 1);//Ĭ + break; +#endif + case CHAR_WORKCONFUSION: + { int side, pos, defNo, lop; + if( RAND( 1, 100 ) > 80 ){ + break; + } + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_ATTACK ); + side = RAND( 0, 1 ); + pos = RAND( 0, 9 ); + for( lop = 0; lop < SIDE_OFFSET; lop ++ ){ + if( ++pos >= SIDE_OFFSET )pos = 0; + defNo = side * SIDE_OFFSET + pos; + if( defNo == bid ) continue; + if( BATTLE_TargetCheck( battleindex, defNo ) == TRUE ){ + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, defNo ); + break; + } + } + if( lop >= SIDE_OFFSET ){ + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, -1 ); + } + } + break; +#ifdef _PROFESSION_ADDSKILL + case CHAR_WORKANNEX:// + { int side, pos, defNo, lop; + + + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_ATTACK ); + side = RAND( 0, 1 ); + pos = RAND( 0, 9 ); + for( lop = 0; lop < SIDE_OFFSET; lop ++ ){ + if( ++pos >= SIDE_OFFSET )pos = 0; + defNo = side * SIDE_OFFSET + pos; + if( defNo == bid ) continue; + if( BATTLE_TargetCheck( battleindex, defNo ) == TRUE ){ + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, defNo ); + break; + } + } + if( lop >= SIDE_OFFSET ){ + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, -1 ); + } + + } + break; +#endif + case CHAR_WORKDRUNK: + break; + +#ifdef _PROFESSION_SKILL // WON ADD ְҵ + case CHAR_WORKOBLIVION: // + { + // ָ + if( cnt <= 1 ){ + int defNo = BATTLE_Index2No( battleindex, charaindex ); + int toNo = defNo - 5; + int toNoindex = -1, pet_no = -1; + char msg[20]; + + memset( msg, -1, sizeof(msg) ); + + // index + toNoindex = BATTLE_No2Index( battleindex, toNo ); + CHAR_setWorkInt(charaindex, StatusTbl[BATTLE_ST_OBLIVION], 0 ); + + // + pet_no = CHAR_getInt( toNoindex, CHAR_DEFAULTPET ); + sprintf( msg, "W%d", pet_no ); + CHAR_sendStatusString( toNoindex, msg ); + + + BATTLE_BadStatusString( bid, 0 ); + sprintf( szBuffer, "BM|%X|%X|", bid, 0 ); + BATTLESTR_ADD( szBuffer ); + } + break; + } + case CHAR_WORK_F_ENCLOSE: // + { + int ToList[SIDE_OFFSET*2+1]; + int defNo = BATTLE_Index2No( battleindex, charaindex ); + int old_hp = CHAR_getInt( charaindex, CHAR_HP ); + int dec_hp = 0, hp = 0; + int DAMAGE = 50; + + memset( ToList, -1, sizeof( ToList)); + BATTLE_MultiList( battleindex, defNo, ToList ); + BATTLE_MagicEffect( battleindex, defNo, ToList, 101699, 101699 ); + + // ȡħ˺ֵ + DAMAGE = DAMAGE * cnt; +#ifdef _PROFESSION_ADDSKILL + dec_hp = PROFESSION_MAGIC_GET_DAMAGE( charaindex, charaindex, 1, DAMAGE, 0); +#else + dec_hp = PROFESSION_MAGIC_GET_DAMAGE( charaindex, charaindex, 1, DAMAGE ); +#endif + hp = old_hp - dec_hp; + + if( hp <= 0 ){ + CHAR_setInt( charaindex, CHAR_HP, 0 ); + CHAR_setFlg( charaindex, CHAR_ISDIE, 1 ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_NONE ); + }else{ + CHAR_setInt( charaindex, CHAR_HP, hp ); + } + + sprintf( szCommand, "BD|r%X|0|0|%X|", defNo, dec_hp ); + BATTLESTR_ADD( szCommand ); + + break; + } + case CHAR_WORK_I_ENCLOSE: // + { + int old_dex = CHAR_getInt( charaindex, CHAR_DEX ); + int dex = 0; + int ToList[SIDE_OFFSET*2+1]; + int defNo = BATTLE_Index2No( battleindex, charaindex ); + + memset( ToList, -1, sizeof( ToList)); + BATTLE_MultiList( battleindex, defNo, ToList ); + BATTLE_MagicEffect( battleindex, defNo, ToList, 27692, 101700 ); + + dex = old_dex * 0.9; + CHAR_setWorkInt(charaindex,CHAR_WORKFIXDEX, dex ); + sprintf( szCommand, "BD|r%X|0|6|%X|", defNo, (-1) * (int)((old_dex * 0.1) / 100) ); + BATTLESTR_ADD( szCommand ); + + break; + } + case CHAR_WORKRESIST_F: // + { + // ָ + if( cnt <= 1 ){ + int add_value = 0; + int old_value = 0; + old_value = CHAR_getWorkInt( charaindex, CHAR_WORK_F_RESIST ); + add_value = CHAR_getWorkInt( charaindex, CHAR_WORKMODRESIST_F ); + + CHAR_setWorkInt( charaindex, CHAR_WORK_F_RESIST, old_value - add_value ); + CHAR_talkToCli( charaindex, -1 , "Իָ" , CHAR_COLORYELLOW ); + } + break; + } + case CHAR_WORKRESIST_I: // + { + // ָ + if( cnt <= 1 ){ + int add_value = 0; + int old_value = 0; + old_value = CHAR_getWorkInt( charaindex, CHAR_WORK_I_RESIST ); + add_value = CHAR_getWorkInt( charaindex, CHAR_WORKMODRESIST_I ); + + CHAR_setWorkInt( charaindex, CHAR_WORK_I_RESIST, old_value - add_value ); + CHAR_talkToCli( charaindex, -1 , "Իָ" , CHAR_COLORYELLOW ); + } + + break; + } + case CHAR_WORKRESIST_T: // ׿ + { + // ָ + if( cnt <= 1 ){ + int add_value = 0; + int old_value = 0; + old_value = CHAR_getWorkInt( charaindex, CHAR_WORK_T_RESIST ); + add_value = CHAR_getWorkInt( charaindex, CHAR_WORKMODRESIST_T ); + + CHAR_setWorkInt( charaindex, CHAR_WORK_T_RESIST, old_value - add_value ); + CHAR_talkToCli( charaindex, -1 , "׿Իָ" , CHAR_COLORYELLOW ); + } + + break; + } +#ifdef _PROFESSION_ADDSKILL +/* case CHAR_WORKERSIST_F_I_T: // ׿ + { + // ָ + if( cnt <= 1 ){ + int add_value = 0; + int old_value = 0; + old_value = CHAR_getWorkInt( charaindex, CHAR_WORK_F_RESIST ); + add_value = CHAR_getWorkInt( charaindex, CHAR_WORKMODRESIST_F ); + CHAR_setWorkInt( charaindex, CHAR_WORK_F_RESIST, old_value - add_value ); + CHAR_talkToCli( charaindex, -1 , "Իָ" , CHAR_COLORYELLOW ); + + old_value = CHAR_getWorkInt( charaindex, CHAR_WORK_I_RESIST ); + add_value = CHAR_getWorkInt( charaindex, CHAR_WORKMODRESIST_I ); + CHAR_setWorkInt( charaindex, CHAR_WORK_I_RESIST, old_value - add_value ); + CHAR_talkToCli( charaindex, -1 , "Իָ" , CHAR_COLORYELLOW ); + + old_value = CHAR_getWorkInt( charaindex, CHAR_WORK_T_RESIST ); + add_value = CHAR_getWorkInt( charaindex, CHAR_WORKMODRESIST_T ); + CHAR_setWorkInt( charaindex, CHAR_WORK_T_RESIST, old_value - add_value ); + CHAR_talkToCli( charaindex, -1 , "׿Իָ" , CHAR_COLORYELLOW ); + } + + break; + }*/ + case CHAR_WORKFEAR: + if( cnt <= 0 ) + CHAR_talkToCli( charaindex, -1 , "ָ" , CHAR_COLORYELLOW ); + break; +#endif + case CHAR_WORKINSTIGATE: // + { + int side, pos, defNo, lop, rate=0; + if( RAND( 1, 100 ) > 80 ){ + break; + } + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_ATTACK ); + side = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLESIDE ); + + rate = CHAR_getWorkInt( charaindex, CHAR_WORKMODINSTIGATE); + + CHAR_setWorkInt( charaindex, CHAR_WORKFIXSTR, (CHAR_getWorkInt( charaindex, CHAR_WORKFIXSTR) * (100 - rate) /100 )); + CHAR_setWorkInt( charaindex, CHAR_WORKFIXTOUGH, (CHAR_getWorkInt( charaindex, CHAR_WORKFIXTOUGH) * (100 - rate) /100 )); + CHAR_setWorkInt( charaindex, CHAR_WORKFIXDEX, (CHAR_getWorkInt( charaindex, CHAR_WORKFIXDEX) * (100 - rate) /100 )); + + pos = RAND( 0, 9 ); + for( lop = 0; lop < SIDE_OFFSET; lop ++ ){ + if( ++pos >= SIDE_OFFSET )pos = 0; + defNo = side * SIDE_OFFSET + pos; + if( defNo == bid ) continue; + if( BATTLE_TargetCheck( battleindex, defNo ) == TRUE ){ + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, defNo ); + break; + } + } + if( lop >= SIDE_OFFSET ){ + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, -1 ); + } + break; + } +/* + case CHAR_WORK_FOCUS: // רעս + { + if( cnt <= 1 ){ + int atk_to_index = CHAR_getWorkInt( charaindex, CHAR_WORKMOD_FOCUS ); + int atk_to_no = BATTLE_Index2No( battleindex, atk_to_index ); + + if( BATTLE_TargetCheck( battleindex, atk_to_no ) != TRUE ) break; + + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_ATTACK ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, atk_to_no ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + CHAR_SETWORKINT_LOW( charaindex, CHAR_WORKBATTLECOM3, 1 ); + } + break; + } +*/ + case CHAR_WORKSIGN: // һѪ + { + // Ѫ + int skill_level = CHAR_getWorkInt( charaindex, CHAR_WORKMODSIGN ); + int old_hp = CHAR_getInt( charaindex, CHAR_HP ); + int old_mp = CHAR_getInt( charaindex, CHAR_MP ); + int to_index = CHAR_getWorkInt( charaindex, CHAR_WORKSIGNID ); + int to_old_hp = CHAR_getInt( to_index, CHAR_HP ); + int to_old_mp = CHAR_getInt( to_index, CHAR_MP ); + int dec_hp=0, dec_mp=0, rate=0, hp=0, mp=0, add_hp=0, add_mp=0; + + if( old_hp <= 0 ) break; + +#ifdef _PROFESSION_ADDSKILL + if( skill_level >= 10 ){ + dec_hp = 200; + dec_mp = 30; + }else if( skill_level > 6 ){ + dec_hp = 150; + dec_mp = 20; + }else if( skill_level > 3 ){ + dec_hp = 100; + dec_mp = 15; + }else{ + dec_hp = 50; + dec_mp = 10; + } + // hp + if( skill_level > 8 ) rate = 100; + else if( skill_level > 7 ) rate = 50; + else rate = 0; + add_hp = dec_hp * rate / 100; + + // mp + if( skill_level > 8 ) rate = 100; + else rate = 0; + add_mp = dec_mp * rate / 100; + +#else + if( skill_level >= 10 ){ + dec_hp = 300; + dec_mp = 70; + }else if( skill_level >= 9 ){ + dec_hp = 200; + dec_mp = 50; + }else if( skill_level >= 7 ){ + dec_hp = 150; + dec_mp = 30; + }else if( skill_level >= 4 ){ + dec_hp = 100; + dec_mp = 20; + }else{ + dec_hp = 50; + dec_mp = 10; + } + // hp + if( skill_level >= 9 ) rate = 80; + else if( skill_level >= 7 ) rate = (skill_level - 1 ) * 10; + else if( skill_level >= 4 ) rate = (skill_level - 2 ) * 10; + else rate = skill_level * 10; + add_hp = dec_hp * rate / 100; + + // mp + if( skill_level >= 9 ) rate = 100; + else if( skill_level >= 7 ) rate = (skill_level - 1 ) * 10; + else if( skill_level >= 4 ) rate = (skill_level - 2 ) * 10; + else rate = skill_level * 10; + add_mp = dec_mp * rate / 100; +#endif + + // ѪƵ˼ HP + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER ){ + mp = old_mp - dec_mp; + if( mp < 0 ){ + mp = 0; + add_mp=0; + } + CHAR_setInt(charaindex, CHAR_MP, mp); + } + + // ѪƵ˼ HP + if( ridepet == -1 ) { + hp = old_hp - dec_hp; + if( hp < 0 ) hp = 0; + CHAR_setInt(charaindex, CHAR_HP, hp); + sprintf( szCommand, "BD|r%X|0|0|%X|m%X|", bid, dec_hp, dec_mp ); + }else{ + int pet_old_hp = CHAR_getInt( ridepet, CHAR_HP ); + int pet_hp=0; + + dec_hp /= 2; + hp = old_hp - dec_hp; + pet_hp = pet_old_hp - dec_hp; + + if( hp < 0 ) hp = 0; + if( pet_hp < 0 ) pet_hp = 0; + + CHAR_setInt(charaindex, CHAR_HP, hp); + CHAR_setInt(ridepet, CHAR_HP, pet_hp); + if( pet_hp <= 0 ){ + CHAR_setFlg( ridepet, CHAR_ISDIE, 1 ); + CHAR_setWorkInt( ridepet, CHAR_WORKBATTLECOM1, BATTLE_COM_NONE ); + } + sprintf( szCommand, "BD|r%X|0|0|%X|m%X|p%X|", bid, dec_hp, dec_mp, dec_hp ); + } + + if( hp <= 0 ){ + CHAR_setFlg( charaindex, CHAR_ISDIE, 1 ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_NONE ); + } + + BATTLESTR_ADD( szCommand ); + + // ʹѪƵ˼ HPMP + if( (add_hp > 0) && (to_old_hp > 0) ){ + int to_bid=0, to_hp=0, to_mp=0; + + to_bid = BATTLE_Index2No( battleindex, to_index ); + sprintf( szCommand, "BD|r%X|0|1|%X|m%X|", to_bid, add_hp, add_mp ); + BATTLESTR_ADD( szCommand ); + + to_hp = to_old_hp + add_hp; + if( to_hp > CHAR_getWorkInt( to_index , CHAR_WORKMAXHP ) ) + to_hp = CHAR_getWorkInt( to_index , CHAR_WORKMAXHP ); + + to_mp = to_old_mp + add_mp; + if( to_mp > CHAR_getWorkInt( to_index , CHAR_WORKMAXMP ) ) + to_mp = CHAR_getWorkInt( to_index , CHAR_WORKMAXMP ); + + CHAR_setInt(to_index, CHAR_HP, to_hp); + CHAR_setInt(to_index, CHAR_MP, to_mp); + } + + break; + } + case CHAR_WORKBLOODWORMS: // Ѫ + { + // Ѫ + int skill_level = CHAR_getWorkInt( charaindex, CHAR_WORKMODBLOODWORMS ); + int old_hp = CHAR_getInt( charaindex, CHAR_HP ); + int to_index = CHAR_getWorkInt( charaindex, CHAR_WORKBLOODWORMSID ); + int to_old_hp = CHAR_getInt( to_index, CHAR_HP ); + int dec_hp=0, rate=0, hp=0, add_hp=0; + + skill_level = PROFESSION_CHANGE_SKILL_LEVEL_M( skill_level ); + + if( old_hp <= 0 ) break; + + dec_hp = skill_level * 10 + 30; + if( skill_level >= 10 ) rate = 20; + else if( skill_level >= 7 ) rate = 15; + else if( skill_level >= 5 ) rate = 10; + else rate = 5; + + add_hp = dec_hp * rate / 100; + + // ѪƵ˼ HP + if( ridepet == -1 ) { + hp = old_hp - dec_hp; + if( hp < 0 ) hp = 0; + + CHAR_setInt(charaindex, CHAR_HP, hp); + sprintf( szCommand, "BD|r%X|0|0|%X|", bid, dec_hp ); + }else{ + int pet_old_hp = CHAR_getInt( ridepet, CHAR_HP ); + int pet_hp=0; + + dec_hp /= 2; + hp = old_hp - dec_hp; + pet_hp = pet_old_hp - dec_hp; + + if( hp < 0 ) hp = 0; + if( pet_hp < 0 ) pet_hp = 0; + + CHAR_setInt(charaindex, CHAR_HP, hp); + CHAR_setInt(ridepet, CHAR_HP, pet_hp); + if( pet_hp == 0 ){ + CHAR_setFlg( ridepet, CHAR_ISDIE, 1 ); + CHAR_setWorkInt( ridepet, CHAR_WORKBATTLECOM1, BATTLE_COM_NONE ); + } + sprintf( szCommand, "BD|r%X|0|0|%X|p%X|", bid, dec_hp, dec_hp ); + } + + if( hp <= 0 ){ + CHAR_setFlg( charaindex, CHAR_ISDIE, 1 ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_NONE ); + } + + BATTLESTR_ADD( szCommand ); + + // ʹѪƵ˼ HP + if( (add_hp > 0) && (to_old_hp > 0) ){ + int to_bid=0, to_hp=0; + + to_bid = BATTLE_Index2No( battleindex, to_index ); + sprintf( szCommand, "BD|r%X|0|1|%X|", to_bid, add_hp ); + BATTLESTR_ADD( szCommand ); + + to_hp = to_old_hp + add_hp; + if( to_hp > CHAR_getWorkInt( to_index , CHAR_WORKMAXHP ) ) + to_hp = CHAR_getWorkInt( to_index , CHAR_WORKMAXHP ); + + CHAR_setInt(to_index, CHAR_HP, to_hp); + } + + break; + } + case CHAR_WORKICEARROW: // + { + // + int dec_dex = CHAR_getWorkInt( charaindex, CHAR_WORKMODICEARROW ); + int old_dex = CHAR_getWorkInt( charaindex, CHAR_WORKFIXDEX ); + int dex=0; + + dex = old_dex * ( 100 - dec_dex ) / 100; + CHAR_setWorkInt(charaindex,CHAR_WORKFIXDEX, dex); + sprintf( szCommand, "BD|r%X|0|6|%X|", bid, (-1) * dec_dex ); + + BATTLESTR_ADD( szCommand ); + + break; + } + case CHAR_WORKICECRACK: // + { + int value=0; + int defNo = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM2 );//defNo = BATTLE_Index2No( battleindex, charaindex ); + + value = CHAR_getWorkInt( charaindex, CHAR_WORKMODICECRACK ); + + if( cnt <= 0 && value > 0 ){ + int damage=0, petdamage=0; + + int ToList[SIDE_OFFSET*2+1]; + memset( ToList, -1, sizeof( ToList)); + BATTLE_MultiList( battleindex, TARGET_SIDE_1, ToList ); + // ħ붯 + analysis_profession_parameter( 2, 4, defNo, charaindex ); + PROFESSION_MAGIC_ATTAIC_Effect( battleindex, bid, ToList, 2); + + if( defNo == 20 || defNo == 25 || defNo == 26 )// + bid = 0; + else + bid = 10; + + + for( i = bid ; i < bid+10 ; i++ ) { + int defType, charaidx, petidx; + charaidx = BATTLE_No2Index( battleindex , i); + if( CHAR_CHECKINDEX( charaidx ) ){ + if( CHAR_getInt( charaidx, CHAR_HP ) > 0 ){ + petidx = BATTLE_getRidePet( charaidx ); + defType = CHAR_getInt(charaidx, CHAR_WHICHTYPE); + CHAR_setWorkInt( charaidx, CHAR_WORKICECRACK, 0 ); + //BATTLE_BadStatusString( bid, 0 ); + //snprintf( szBuffer, sizeof( szBuffer ), "(%s)(%s)ϡ", + // CHAR_getUseName( charaindex ), aszStatusFull[i] ); + // BATTLE_BroadCast( battleindex, szBuffer, + // (bid >= 10)? CHAR_COLORGRAY : CHAR_COLORPURPLE ) ; + //sprintf( szBuffer, "BM|%X|%X|", bid, 0 ); + //BATTLESTR_ADD( szBuffer ); + + damage = value; + + hp = CHAR_getInt( charaidx, CHAR_HP ); + if( petidx == -1 ) { + hp -= damage; + if( hp < 0 ) hp = 0; + } + else{ + int defquick=0, petquick=0, playerdamage=0; + pethp = CHAR_getInt( petidx, CHAR_HP ); + defquick = CHAR_getWorkInt( charaidx, CHAR_WORKDEFENCEPOWER ); + petquick = CHAR_getWorkInt( petidx, CHAR_WORKDEFENCEPOWER ); + if( pethp > 0 ){ + playerdamage = (damage*petquick)/(defquick+petquick) +1; + petdamage = damage - playerdamage +1 ; + hp -= playerdamage; + pethp -= petdamage; + } + else{ + hp -= damage; + } + if( hp < 0 ) hp = 0; + if( pethp < 0 ) pethp = 0; + CHAR_setInt( petidx, CHAR_HP, pethp ); + } + + CHAR_setInt( charaidx, CHAR_HP, hp ); + + if( hp <= 0 ){ + CHAR_setFlg( charaidx, CHAR_ISDIE, 1 ); + CHAR_setWorkInt( charaidx, CHAR_WORKBATTLECOM1, BATTLE_COM_NONE ); + } + if( pethp <= 0 ){ + CHAR_setFlg( petidx, CHAR_ISDIE, 1 ); + CHAR_setWorkInt( ridepet, CHAR_WORKBATTLECOM1, BATTLE_COM_NONE ); + } + + if( damage >= 0 ){ + //snprintf( szBuffer, sizeof( szBuffer ), + // "(%s)(%s)ܵ(%d)ˡ", + // CHAR_getUseName( charaindex ), + // aszStatusFull[i], + // damage ); + //BATTLE_BroadCast( battleindex, szBuffer, + // (bid >= 10)? CHAR_COLORGRAY : CHAR_COLORPURPLE ) ; + + sprintf( szBuffer , "%X|%X|%X|%X|" , i , i ,(int)(damage) , (int)(petdamage)); + + //sprintf( szBuffer, "BD|r%X|0|0|%X|p%X|", i, (int)(damage), (int)(petdamage) ); + BATTLESTR_ADD( szBuffer ); + } + if( petidx != -1 && petdamage >= 0 ){ + //snprintf( szBuffer, sizeof( szBuffer ), + // "(%s)(%s)ܵ(%d)ˡ", + // CHAR_getUseName( charaindex ), + // aszStatusFull[i], petdamage ); + //BATTLE_BroadCast( battleindex, szBuffer, + // (bid >= 10)? CHAR_COLORGRAY : CHAR_COLORPURPLE ) ; + } + } + } + } + sprintf( szBuffer , "%X|" , 0x5711438 ); + BATTLESTR_ADD( szBuffer ); + } + } + //print("\n"); + break; +#ifdef _PROFESSION_ADDSKILL + case CHAR_WORKICECRACK2: // 2 + WorkIceCrackPlay( charaindex, cnt, CHAR_WORKICECRACK2 );print("\n2");break; + case CHAR_WORKICECRACK3: // 3 + WorkIceCrackPlay( charaindex, cnt, CHAR_WORKICECRACK3 );print("\n3");break; + case CHAR_WORKICECRACK4: // 4 + WorkIceCrackPlay( charaindex, cnt, CHAR_WORKICECRACK4 );print("\n4");break; + case CHAR_WORKICECRACK5: // 5 + WorkIceCrackPlay( charaindex, cnt, CHAR_WORKICECRACK5 );print("\n5");break; + case CHAR_WORKICECRACK6: // 6 + WorkIceCrackPlay( charaindex, cnt, CHAR_WORKICECRACK6 );print("\n6");break; + case CHAR_WORKICECRACK7: // 7 + WorkIceCrackPlay( charaindex, cnt, CHAR_WORKICECRACK7 );print("\n7");break; + case CHAR_WORKICECRACK8: // 8 + WorkIceCrackPlay( charaindex, cnt, CHAR_WORKICECRACK8 );print("\n8");break; + case CHAR_WORKICECRACK9: // 9 + WorkIceCrackPlay( charaindex, cnt, CHAR_WORKICECRACK9 );print("\n9");break; + case CHAR_WORKICECRACK10: // 10 + WorkIceCrackPlay( charaindex, cnt, CHAR_WORKICECRACK10 );print("\n10");break; +#endif //_PROFESSION_ADDSKILL + +#endif + +#ifdef _PET_SKILL_SARS // WON ADD ɷ + case CHAR_WORKSARS: + { + int j; + int rate = 60; // Ⱦ SARS + + // ܴȾ + { + int petdown=-1; + int dec_mp = 0; + + Compute_Down_SARS( charaindex, ridepet, &down, &petdown, ridepet); + if( down >= 0 ){ + //snprintf( szBuffer, sizeof( szBuffer ), + // "(%s)(%s)ܵ(%d)ˡ", + // CHAR_getUseName( charaindex ), + // aszStatusFull[i], + // down ); + //BATTLE_BroadCast( battleindex, szBuffer, + // (bid >= 10)? CHAR_COLORGRAY : CHAR_COLORPURPLE ) ; + + // ҿ MP + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER ){ + int old_mp = CHAR_getInt( charaindex, CHAR_MP ); + dec_mp = old_mp / 10 ; + if( dec_mp < 0 ) dec_mp = 0; + CHAR_setInt( charaindex, CHAR_MP, old_mp - dec_mp ); + sprintf( szBuffer, "BD|r%X|0|0|%X|p%X|m%X|", bid, (int)(down), (int)(petdown), dec_mp ); + }else + sprintf( szBuffer, "BD|r%X|0|0|%X|p%X|", bid, (int)(down), (int)(petdown) ); + + BATTLESTR_ADD( szBuffer ); + } + if( ridepet != -1 && petdown >= 0 ){ + //snprintf( szBuffer, sizeof( szBuffer ), + // "(%s)(%s)ܵ(%d)ˡ", + // CHAR_getUseName( charaindex ), + // aszStatusFull[i], petdown ); + //BATTLE_BroadCast( battleindex, szBuffer, + // (bid >= 10)? CHAR_COLORGRAY : CHAR_COLORPURPLE ) ; + } + } + + // ȾߴSARS + if( CHAR_getWorkInt( charaindex, CHAR_WORKMODSARS ) > 0 ){ + int buf2[5], ti=0; + int tibuf[10]={ + 3,1,0,2,4, + 8,6,5,7,9 }; + + memset( buf2, -1, sizeof(buf2)); + + if( defNo > 9 ){ + for( j=0; j<10; j++ ){ + tibuf[j] += 10; + } + } + + for( j=0; j<10; j++){ + if( tibuf[j] != defNo ) continue; + if( j > 4 ){ + if( (j+1) < 10 ) buf2[ti++]=tibuf[j+1]; + if( (j-1) > 4 ) buf2[ti++]=tibuf[j-1]; + //ȱ + if( (j-5+1) < 5 ) buf2[ti++]=tibuf[j-5+1]; + if( (j-5-1) >= 0 ) buf2[ti++]=tibuf[j-5-1]; + if( (j-5) >= 0 ) buf2[ti++]=tibuf[j-5]; + }else{ + if( (j+1) < 5 ) buf2[ti++]=tibuf[j+1]; + if( (j-1) >= 0 ) buf2[ti++]=tibuf[j-1]; + //ȱ + if( (j+5+1) < 10 ) buf2[ti++]=tibuf[j+5+1]; + if( (j+5-1) > 4 ) buf2[ti++]=tibuf[j+5-1]; + if( (j+5) < 10 ) buf2[ti++]=tibuf[j+5]; + } + break; + } + + //print("buf2[%d,%d,%d,%d,%d]\n", buf2[0], buf2[1], buf2[2], buf2[3], buf2[4]); + + for( j=0; j<5; j++ ){ + + int toindex = 0; + if( buf2[j] == -1 ) continue; + + toindex = BATTLE_No2Index( battleindex, buf2[j] ); + + // õsars뿪 + if( CHAR_getWorkInt( toindex,CHAR_WORKSARS ) > 0 ) continue; + + if( RAND( 1, 100 ) <= rate ){ // SARS + if( toindex == charaindex ) continue; + if( CHAR_getInt( toindex, CHAR_HP ) <= 0 ) continue; + + CHAR_setWorkInt( toindex,CHAR_WORKSARS, 3 ); + } + } + } + } + break; +#endif + + default : + //snprintf( szBuffer, sizeof( szBuffer ), + // "(%s)(%s)", CHAR_getUseName( charaindex ), + // aszStatusFull[i] ); + //BATTLE_BroadCast( battleindex, szBuffer, + // (bid >= 10)? CHAR_COLORGRAY : CHAR_COLORPURPLE ) ; + break; + } + } + +#ifdef _SUIT_ITEM + { + int defCode; + int AddHp=0, AddMp=0; +#ifdef _IMPRECATE_ITEM + int nums1, nums2, nums3, delMp=0; +#endif + if( (defCode=CHAR_getWorkInt( charaindex, CHAR_WORKSUITITEM)) > 0){ + AddHp = CHAR_getWorkInt( charaindex, CHAR_WORKROUNDHP); + AddMp = CHAR_getWorkInt( charaindex, CHAR_WORKROUNDMP); + } + +#ifdef _IMPRECATE_ITEM + if( (nums1 = CHAR_getWorkInt( charaindex, CHAR_WORKIMPRECATENUM1)) > 0 ){ + delMp = CHAR_getWorkInt( charaindex, CHAR_WORKHURTMP); + CHAR_setWorkInt( charaindex, CHAR_WORKIMPRECATENUM1, nums1-1); + } + if( (nums2 = CHAR_getWorkInt( charaindex, CHAR_WORKIMPRECATENUM2)) > 0 ){ + AddHp += CHAR_getWorkInt( charaindex, CHAR_WORKWISHESHP); + CHAR_setWorkInt( charaindex, CHAR_WORKIMPRECATENUM2, nums2-1); + } + if( (nums3 = CHAR_getWorkInt( charaindex, CHAR_WORKIMPRECATENUM3)) > 0 ){ + AddMp += CHAR_getWorkInt( charaindex, CHAR_WORKWISHESMP); + CHAR_setWorkInt( charaindex, CHAR_WORKIMPRECATENUM3, nums3-1); + } + AddMp = AddMp - delMp; +#endif + if( AddHp != 0 || AddMp != 0 ) { + int AddPHp=0; + + +#ifdef _TYPE_TOXICATION + if( AddHp != 0 && CHAR_CanCureFlg( charaindex, "FALSE") != FALSE ){ +#else + if( AddHp != 0 ) { +#endif + int MyHp = CHAR_getInt( charaindex, CHAR_HP); + int MaxHp = CHAR_getWorkInt( charaindex, CHAR_WORKMAXHP); + MyHp = ((MyHp+AddHp)>=MaxHp)?MaxHp:(MyHp+AddHp); + MyHp = (MyHp<= 1 )?1:MyHp; + CHAR_setInt( charaindex, CHAR_HP, MyHp); + //snprintf( szBuffer, sizeof( szBuffer ), "(%s)(%d)HP", + // CHAR_getUseName( charaindex ), AddHp ); + //BATTLE_BroadCast( battleindex, szBuffer, + // (bid >= 10)? CHAR_COLORGRAY : CHAR_COLORPURPLE ) ; + if( ridepet != -1 ){ + int PetMaxHp = CHAR_getWorkInt( ridepet, CHAR_WORKMAXHP); + int PetHp = CHAR_getInt( ridepet, CHAR_HP); + AddPHp = AddHp; + PetHp = ((PetHp+AddPHp)>=PetMaxHp)?PetMaxHp:(PetHp+AddPHp); + PetHp = (PetHp<=1)?1:PetHp; + CHAR_setInt( ridepet, CHAR_HP, PetHp); + } + } + if( AddMp != 0 ) { + int MyMp = CHAR_getInt( charaindex, CHAR_MP); + int MaxMp = CHAR_getWorkInt( charaindex, CHAR_WORKMAXMP); + MyMp = ((MyMp+AddMp)>MaxMp)?MaxMp:(MyMp+AddMp); + MyMp = (MyMp<0)?0:MyMp; + CHAR_setInt( charaindex, CHAR_MP, MyMp); +/* +#ifdef _FIXITEMANISHOW + sprintf( szBuffer, "BD|r%X|0|1|%X|p%X|m%X|", bid, AddHp, AddPHp, AddMp); + }else { + sprintf( szBuffer, "BD|r%X|0|1|%X|p%X|", bid, AddHp, AddPHp ); +#else +*/ + sprintf( szBuffer, "BD|r%X|0|2|%X|p%X|m%X|", bid, AddHp, AddPHp, AddMp); + }else { + sprintf( szBuffer, "BD|r%X|0|2|%X|p%X|", bid, AddHp, AddPHp ); +//#endif + } + BATTLESTR_ADD( szBuffer ); + } + } +#endif +#ifdef _PETSKILL_SETDUCK + { + int turns=0, nums=0; + if( (turns=CHAR_getWorkInt( charaindex, CHAR_MYSKILLDUCK)) > 0 ){ + turns--; + if( turns == 0 ){ + nums = CHAR_getWorkInt( charaindex, CHAR_MYSKILLDUCKPOWER); + sprintf( szBuffer, "BD|r%X|0|3|%X|", bid, nums*(-1)); + BATTLESTR_ADD( szBuffer ); + } + CHAR_setWorkInt( charaindex, CHAR_MYSKILLDUCK, turns); + } +#ifdef _MAGICPET_SKILL + if( (turns=CHAR_getWorkInt( charaindex, CHAR_MYSKILLSTR)) > 0 ){ + turns--; + if( turns == 0 ){ + nums = CHAR_getWorkInt( charaindex, CHAR_MYSKILLSTRPOWER); + sprintf( szBuffer, "BD|r%X|0|4|%X|", bid, nums*(-1)); + BATTLESTR_ADD( szBuffer ); + } + CHAR_setWorkInt( charaindex, CHAR_MYSKILLSTR, turns); + } + if( (turns=CHAR_getWorkInt( charaindex, CHAR_MYSKILLTGH)) > 0 ){ + turns--; + if( turns == 0 ){ + nums = CHAR_getWorkInt( charaindex, CHAR_MYSKILLTGHPOWER); + sprintf( szBuffer, "BD|r%X|0|5|%X|", bid, nums*(-1)); + BATTLESTR_ADD( szBuffer ); + } + CHAR_setWorkInt( charaindex, CHAR_MYSKILLTGH, turns); + } + if( (turns=CHAR_getWorkInt( charaindex, CHAR_MYSKILLDEX)) > 0 ){ + turns--; + if( turns == 0 ){ + nums = CHAR_getWorkInt( charaindex, CHAR_MYSKILLDEXPOWER); + sprintf( szBuffer, "BD|r%X|0|6|%X|", bid, nums*(-1)); + BATTLESTR_ADD( szBuffer ); + } + CHAR_setWorkInt( charaindex, CHAR_MYSKILLDEX, turns); + } +#ifdef _PROFESSION_SKILL // WON ADD ְҵ + if( (turns=CHAR_getWorkInt( charaindex, CHAR_MYSKILLHIT)) > 0 ){ + turns--; + if( turns == 0 ){ + int dec_num = CHAR_getWorkInt( charaindex, CHAR_MYSKILLHIT_NUM); + nums = CHAR_getWorkInt( charaindex, CHAR_WORKHITRIGHT); + nums -= dec_num; + CHAR_setWorkInt( charaindex, CHAR_WORKHITRIGHT, nums); + + CHAR_talkToCli( charaindex, -1, "ָ", CHAR_COLORYELLOW); + //sprintf( szBuffer, "BD|r%X|0|6|%X|", bid, dec_num*(-1)); + //BATTLESTR_ADD( szBuffer ); + } + CHAR_setWorkInt( charaindex, CHAR_MYSKILLHIT, turns); + } +#endif + +#endif + } +#endif + return 0; + +} + + +BOOL BATTLE_CanMoveCheck( int charaindex ) +{ + + // + if( CHAR_getWorkInt( charaindex, CHAR_WORKPARALYSIS ) > 0 ){ + return FALSE; + } + + // ޼ + if( CHAR_getWorkInt( charaindex, CHAR_WORKSTONE ) > 0 ){ + return FALSE; + } + // Ի + if( CHAR_getWorkInt( charaindex, CHAR_WORKSLEEP ) > 0 ){ + return FALSE; + } +#ifdef _MAGIC_BARRIER + if( CHAR_getWorkInt( charaindex, CHAR_WORKBARRIER ) > 0 ){ + return FALSE; + } +#endif + +#ifdef _PROFESSION_SKILL // WON ADD ְҵ + // ѣ + if( CHAR_getWorkInt( charaindex, CHAR_WORKDIZZY ) > 0 ){ + return FALSE; + } + // ޵ + if( CHAR_getWorkInt( charaindex, CHAR_WORKDRAGNET ) > 0 ){ + return FALSE; + } + +#ifdef _JOB_FIX + // + if( CHAR_getWorkInt( charaindex, CHAR_WORKICEARROW ) > 0 ){ + return FALSE; + } +#endif +/* + // רעս + if( CHAR_getWorkInt( charaindex, CHAR_WORK_FOCUS ) > 0 ){ + return FALSE; + } +*/ + // ׸ + if( CHAR_getWorkInt( charaindex, CHAR_WORK_T_ENCLOSE ) > 0 ){ + return FALSE; + } +#endif +#ifdef _PROFESSION_ADDSKILL + if( CHAR_getWorkInt( charaindex, CHAR_DOOMTIME ) > 0 ){ + return FALSE; + } +#endif + return TRUE; +} + +#ifdef _ITEM_EQUITSPACE +int BATTLE_GetEqShield( int charaindex ) +{ + int iRet = ITEM_FIST, itemindex; + + itemindex = CHAR_getItemIndex( charaindex, CHAR_EQSHIELD ); + if( ITEM_CHECKINDEX( itemindex ) == FALSE ){ + iRet = ITEM_FIST; + }else{ + iRet = ITEM_getInt( itemindex, ITEM_TYPE ); + } + return iRet; +} +#endif + +int BATTLE_GetWepon( int charaindex ) //ȡýɫֳ +{ + int iRet = ITEM_FIST, itemindex; + + itemindex = CHAR_getItemIndex( charaindex, CHAR_ARM ); + if( ITEM_CHECKINDEX( itemindex ) == FALSE ){ + iRet = ITEM_FIST; + }else{ + iRet = ITEM_getInt( itemindex, ITEM_TYPE ); + } + + return iRet; +} + +static int aBowW[50] = +{ + 0, 2, 1, 4, 3, 0, 1, 2, 3, 4, + 1, 0, 3, 2, 4, 1, 3, 0, 2, 4, + 2, 4, 0, 1, 3, 2, 0, 4, 1, 3, + 3, 1, 0, 2, 4, 3, 1, 0, 2, 4, + 4, 2, 0, 1, 3, 4, 2, 0, 1, 3, +}; + +void BATTLE_TargetListSet( int charaindex, int attackNo, int *pList) +{ + int i, j=0, defNo, battleindex=-1; + defNo = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM2 ); + battleindex = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEINDEX ); + +#ifdef _SKILLLIMIT // (ɿ) Syu ADD ùҷ + if( CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM1 ) == BATTLE_COM_S_FALLRIDE || // + CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM1 ) == BATTLE_COM_S_WILDVIOLENTATTACK || //񱩹 + CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM1 ) == BATTLE_COM_S_TIMID || // ս + CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM1 ) == BATTLE_COM_S_MPDAMAGE || // MP + CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM1 ) == BATTLE_COM_S_WEAKEN || // + CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM1 ) == BATTLE_COM_S_DAMAGETOHP || // Ѫ + CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM1 ) == BATTLE_COM_S_STEALMONEY ) { // + if( BATTLE_CheckSameSide( charaindex, defNo) == 1 ) { + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_NONE ); +// BATTLE_NoAction( battleindex, attackNo ); + return; + } + } +#endif + + for( i = 0; i < BATTLE_ENTRY_MAX*2; i ++ ){ + pList[i] = defNo; + } +#ifdef _BATTLE_ATTCRAZED // ANDY +#ifdef _SHOOTCHESTNUT // Syu ADD 輼 + if( CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM1 ) == BATTLE_COM_S_ATTCRAZED || + CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM1 ) == BATTLE_COM_S_ATTSHOOT ){ +#else + if( CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM1 ) == BATTLE_COM_S_ATTCRAZED ){ +#endif + int deftop,defsub; + int plive[10]; + int n = CHAR_GETWORKINT_HIGH( charaindex, CHAR_WORKBATTLECOM3); + + +#ifdef _SHOOTCHESTNUT // Syu ADD 輼 + if( BATTLE_CheckSameSide( charaindex, defNo) == 1 ) { + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_NONE ); + BATTLE_NoAction( battleindex, attackNo ); + return; + } +#endif + if( 0 <= defNo && defNo <= 9 ){ + defsub = 0; + deftop = 9; + }else if( 10 <= defNo && defNo <= 19 ){ + defsub = 10; + deftop = 19; + }else{ + pList[1] = -1; + return; + } + for( i = defsub; i < deftop; i ++ ){ + if( BATTLE_TargetCheck( battleindex, i) == FALSE ) continue; + plive[j++] = i; + } + if( j == 0 ) return; + for( i=0; i= CHAR_MAXPETSKILLHAVE ) i = 0; + + if( CHAR_getCharHaveSkill( charaindex, i ) == NULL ){ + continue; + } + + pskill_array = PETSKILL_GetArray( charaindex, i ); + skill_type = PETSKILL_getInt( pskill_array, PETSKILL_FIELD ); + + + if( skill_type == PETSKILL_FIELD_BATTLE + || skill_type == PETSKILL_FIELD_ALL + ){ + }else{ + continue; + } + + if( j < iNum ){ + j++; + continue; + } + + if( PETSKILL_Use( charaindex, iNum, toNo, NULL ) == TRUE ){ + + }else{ + + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_NONE ); + } + break; + } + + if( k >= PETSKILLSERCHTIME ){ + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_NONE ); + } + return 0; +} + + +enum{ + PETAI_MODE_NORMAL, + PETAI_MODE_TARGETRANDOM, + PETAI_MODE_RANDOMACT, + PETAI_MODE_OWNERATTACK, + PETAI_MODE_ENEMYATTACK, + PETAI_MODE_ESCAPE, + PETAI_MODE_NOACT, + PETAI_MODE_END +}; + +static int BATTLE_PetLoyalCheck( int battleindex, int bid, int charaindex ) +{ + int ai, toNo, mode = 0, type, Rand, toSide = 1, flg, i; + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE ) != CHAR_TYPEPET ){ + return 0; + } + if( CHAR_getFlg( charaindex, CHAR_ISDIE ) == TRUE ) + return 0; + if( CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM1 ) == BATTLE_COM_WAIT ){ + return 0; + } + flg = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEFLG ); + flg &= ~CHAR_BATTLEFLG_AIBAD; + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEFLG, flg ); + if( BATTLE_CanMoveCheck( charaindex ) == FALSE ){ + return 0; + } + toNo = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM2 ); + toSide = ( 0 <= toNo && toNo < BATTLE_ENTRY_MAX )?(0):(1); + ai = CHAR_getWorkInt( charaindex, CHAR_WORKFIXAI ); + if( CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM1 ) == BATTLE_COM_GUARD + || bid == toNo + ){ + type = 1; + }else{ + type = 0; + } + + Rand = RAND( 1, 100 ); + + mode = 0; // е + if( ai >= 80 ){ // պߡѶ + mode = PETAI_MODE_NORMAL; // 姸 + }else + if( ai >= 70 ){ // պߡѶ + if( Rand < 10 )mode = PETAI_MODE_TARGETRANDOM; // + }else + if( ai >= 60 ){ + if( Rand < 20 )mode = PETAI_MODE_TARGETRANDOM; // + }else + if( ai >= 50 ){ + if( Rand < 35 )mode = PETAI_MODE_TARGETRANDOM; // + }else + if( ai >= 40 ){ + if( Rand < 50 )mode = PETAI_MODE_TARGETRANDOM; // + }else + if( ai >= 30 ){ + if( Rand < 70 )mode = PETAI_MODE_RANDOMACT; // ¼ĸة + }else + if( ai >= 20 ){ + if( Rand < 70 )mode = PETAI_MODE_RANDOMACT; // ¼ĸة + }else + if( ai >= 10 ){ + if( Rand < 80 ){ + mode = PETAI_MODE_OWNERATTACK; // DZ + }else{ + mode = PETAI_MODE_ENEMYATTACK; // + } + }else{ + if( Rand < 60 ){ + mode = PETAI_MODE_OWNERATTACK; // DZ + }else{ + mode = PETAI_MODE_ESCAPE; // + } + } + + + if( mode == PETAI_MODE_NORMAL )return 0; + + for( i = 0; i < CHAR_MAXPETSKILLHAVE;i ++ ){ + if( CHAR_getCharHaveSkill( charaindex, i ) ){ + break; + } + } + if( i >= CHAR_MAXPETSKILLHAVE ){ + mode = PETAI_MODE_NOACT; + } + flg = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEFLG ); + flg |= CHAR_BATTLEFLG_AIBAD; + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEFLG, flg ); + + + switch( mode ){ + case PETAI_MODE_NOACT: + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, + BATTLE_COM_NONE ); + break; + case PETAI_MODE_TARGETRANDOM: + if( type == 1 ){ + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, + BATTLE_COM_NONE ); + }else{ + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, + BATTLE_DefaultAttacker( battleindex, toSide ) ); + + } + break; + case PETAI_MODE_RANDOMACT: // ¼ĸة + // Ѩ 󡷴姸ĸ + if( CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM1 ) == BATTLE_COM_S_EARTHROUND0 ){ + return 0; + } + + // ūʧ׷ºë + flg = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEFLG ); + flg &= ~CHAR_BATTLEFLG_GUARDIAN; + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEFLG, flg ); + + if( toNo == bid ){ // ëƥ + // ƥئг + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_NONE ); + }else{ + // ¼ĸة ë + BATTLE_PetRandomSkill( battleindex, charaindex ); + } + break; + + case PETAI_MODE_OWNERATTACK: // DZ + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_ATTACK ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, bid-5 ); + break; + + case PETAI_MODE_ENEMYATTACK: // + { int myside = 0; + if( bid >= BATTLE_ENTRY_MAX ) myside = 1; + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_ATTACK ); + // + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, + BATTLE_DefaultAttacker( battleindex, 1 - myside ) ); + } + break; + + case PETAI_MODE_ESCAPE: // ¹ + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_S_LOSTESCAPE ); + break; + + } + + return 1; + +} + +#ifdef _ATTACK_MAGIC + +#define MAX_MAGIC_NUMBER 25 + +// ÿһħĹ Χ (id,area) +int TargetIndex[MAX_MAGIC_NUMBER][2] = +{ + {301,-1},{302,-1},{303,26},{304,-1},{305,20},{306,20}, + {307,-1},{308,-1},{309,-1},{310,-1},{311,26},{312,20}, + {313,-1},{314,-1},{315,-1},{316,-1},{317,26},{318,20}, + {319,-1},{320,-1},{321,26},{322,-1},{323,26},{324,20},{325,20} +}; + +int magic,toindex,magic_count; + +#endif + +static int BATTLE_Battling( int battleindex ) +{ + //DebugMainFunction="BATTLE_Battling_1"; + BATTLE *pBattle, *pWatchBattle; + BATTLE_ENTRY *pEntry[2]; + char *aszFieldAttr[] = { "", "", "ˮ", "", "" }, + szBuffer[256]="", + szWork[256]; + int i,j,k, + len, + entrynum, + charaindex, + attackNo, + defNo=-1, + aAttackList[BATTLE_ENTRY_MAX*2+1], + aDefList[BATTLE_ENTRY_MAX*2+1], + ComboId, + itemindex, + AllSize = 0; + BATTLE_CHARLIST EntryList[40]; + int ContFlg, attackNoSub, defNoSub; + //DebugMainFunction="BATTLE_Battling_2"; + if( BATTLE_CHECKINDEX( battleindex ) == FALSE )return BATTLE_ERR_BATTLEINDEX; + //DebugMainFunction="BATTLE_Battling_3"; + pBattle = &BattleArray[battleindex]; + pEntry[0] = pBattle->Side[0].Entry; + pEntry[1] = pBattle->Side[1].Entry; + //DebugMainFunction="BATTLE_Battling_4"; + for( i = 0; i < arraysizeof(EntryList); i ++ ){ + EntryList[i].charaindex = -1; + EntryList[i].combo = 0; + } + //DebugMainFunction="BATTLE_Battling_5"; + sprintf( szBuffer, "ս %d ת %d %s", + battleindex, pBattle->turn, + aszFieldAttr[pBattle->field_att] + ); + //DebugMainFunction="BATTLE_Battling_6"; + entrynum = 0; + + for( j = 0; j < 2; j ++ ){ + for( i = 0; i < BATTLE_ENTRY_MAX; i ++ ){ + pEntry[j][i].flg &= ~BENT_FLG_ULTIMATE; + if( pEntry[j][i].charaindex == -1 )continue; + EntryList[entrynum].charaindex = pEntry[j][i].charaindex; + EntryList[entrynum].side = j; + EntryList[entrynum].num = pEntry[j][i].bid; + EntryList[entrynum].dex = BATTLE_DexCalc( pEntry[j][i].charaindex ); // +#ifdef _EQUIT_SEQUENCE + EntryList[entrynum].sequence = CHAR_getWorkInt( pEntry[j][i].charaindex, CHAR_WORKSEQUENCEPOWER); +#endif + BATTLE_talkToCli( pEntry[j][i].charaindex, szBuffer, CHAR_COLORYELLOW ); + entrynum ++; + } + } + //DebugMainFunction="BATTLE_Battling_7"; + szAllBattleString[0] = 0; + k = 0; + for( j = 0; j < 2; j ++ ){ + k = j * SIDE_OFFSET; + for( i = 0; i < BATTLE_ENTRY_MAX/2; i ++ ){ + szBattleString[0] = 0; + if( pBattle->iEntryBack[k] >= 0 + && pBattle->Side[j].Entry[i].charaindex == -1){ + if( pBattle->iEntryBack2[k] >= 0 ){ + sprintf( szBattleString, "BE|et%X|f1|", k ); + //BATTLE_BroadCast( battleindex, "ͻȻ˲ˡ", CHAR_COLORYELLOW ); + }else{ + //print( "ӦIDȷֵerror\n" ); + //BATTLE_BroadCast( battleindex, "IDerror", CHAR_COLORYELLOW ); + } + } + k ++; + strcatsafe( szAllBattleString,sizeof(szAllBattleString), szBattleString ); + } + } + //DebugMainFunction="BATTLE_Battling_8"; + len = strlen( szAllBattleString ); + //DebugMainFunction="BATTLE_Battling_9"; + AllSize += len; + EntrySort( EntryList, entrynum ); + //DebugMainFunction="BATTLE_Battling_10"; + ComboCheck( EntryList, entrynum ); + //DebugMainFunction="BATTLE_Battling_11"; + for( i = 0; i < entrynum; i ++ ){ + int COM, myside, otherside, bi, + attack_flg = 1, + attack_max = 1, + attack_count = 0; + + charaindex = EntryList[i].charaindex; + myside = EntryList[i].side; + otherside = 1-myside; + attackNo = EntryList[i].num; + bi = attackNo - myside * SIDE_OFFSET; + + aAttackList[0] = attackNo; + aAttackList[1] = -1; + if( CHAR_CHECKINDEX( charaindex ) == FALSE )continue; + if( CHAR_getFlg( charaindex, CHAR_ISDIE ) == TRUE )continue; + szBadStatusString[0] = 0; + if( CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE ) + != BATTLE_CHARMODE_C_OK ){ + //sprintf( szBuffer, "ָ벻ȫ(%s)", CHAR_getUseName( charaindex ) ); + //BATTLE_BroadCast( battleindex, szBuffer, CHAR_COLORYELLOW ); + continue; + } + if( CHAR_getInt( charaindex, CHAR_HP ) <= 0 )continue; + + szBattleString[0] = 0; + pszBattleTop = szBattleString; + pszBattleLast = szBattleString+arraysizeof(szBattleString); + + // WON ADD + if( CHAR_getFlg( charaindex, CHAR_ISDIE ) != TRUE ) + BATTLE_StatusSeq( charaindex ); + //DebugMainFunction="BATTLE_Battling_12"; +#ifdef _OTHER_MAGICSTAUTS + BATTLE_MagicStatusSeq( charaindex ); +#endif + //DebugMainFunction="BATTLE_Battling_13"; +#ifdef _MAGIC_DEEPPOISON // 綾 + if( CHAR_getFlg( charaindex, CHAR_ISDIE ) == TRUE ){ + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_NONE ); + } +#endif + +#ifdef _PROFESSION_SKILL // WON ADD ְҵ + BATTLE_ProfessionStatusSeq( battleindex, charaindex); +#endif + //DebugMainFunction="BATTLE_Battling_14"; + + if( BATTLE_CanMoveCheck( charaindex ) == FALSE ){ + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_NONE ); + } + //DebugMainFunction="BATTLE_Battling_15"; + gBattleDamageModyfy = 1.0; + gBattleDuckModyfy = 0; + gBattleStausChange = -1; + gBattleStausTurn = 0; + gWeponType = ITEM_FIST; + gWeponType = BATTLE_GetWepon( charaindex ); + //DebugMainFunction="BATTLE_Battling_16"; +#ifdef _PETSKILL_BECOMEFOX + if( CHAR_getWorkInt( charaindex, CHAR_WORKFOXROUND ) != -1 //DZС + || CHAR_getInt( charaindex, CHAR_BASEIMAGENUMBER)==101749) + { + int COM = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM1 ); + + gWeponType = ITEM_FIST; + + if( !(COM == BATTLE_COM_ATTACK + || COM == BATTLE_COM_GUARD + || COM == BATTLE_COM_NONE) ){ + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_NONE ); + CHAR_talkToCli( charaindex, -1, "Сֻܹʹ", CHAR_COLORYELLOW ); + } + } +#endif + //DebugMainFunction="BATTLE_Battling_17"; +#ifdef _PETSKILL_BECOMEPIG + if( CHAR_getInt( charaindex, CHAR_BECOMEPIG) > -1 // + && (CHAR_getInt( charaindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER) ) + { + int COM = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM1 ); + + gWeponType = ITEM_FIST; + //CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_ATTACK ); + if( !(COM == BATTLE_COM_ATTACK + || COM == BATTLE_COM_GUARD + || COM == BATTLE_COM_NONE + || COM == BATTLE_COM_ITEM + || COM == BATTLE_COM_ESCAPE + || COM == BATTLE_COM_CAPTURE + || COM == BATTLE_COM_WAIT + || COM == BATTLE_COM_PETIN + || COM == BATTLE_COM_PETOUT) ){ + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_GUARD ); + //CHAR_talkToCli( charaindex, -1, "ֻܹܺʹõߣ", CHAR_COLORYELLOW ); + CHAR_talkToCli( charaindex, -1, "᲻ʹְҵܣ", CHAR_COLORYELLOW ); + } + } +#endif + //DebugMainFunction="BATTLE_Battling_18"; + gDamageDiv = 1.0; + attack_max = BATTLE_GetAttackCount( charaindex ); + if( attack_max <= 0 ){ + int work, randwork; + work = CHAR_getInt( charaindex, CHAR_LV ); + if( work < 10 || CHAR_getInt( charaindex, CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER ){ + attack_max = 1; + }else{ + int luckwork = CHAR_getInt( charaindex, CHAR_LUCK )*5; + if( luckwork > 5*5 ){ +// print( "\nerr:(%s)(%d)\n", +// CHAR_getUseName( charaindex ), +// CHAR_getInt( charaindex, CHAR_LUCK ) ); + luckwork = 5*5; + } + randwork = RAND( 1, 1000 ); + if( randwork <= 10 + luckwork){ + attack_max = RAND( 5, 10 ); + }else + if( randwork <= 30 + luckwork ){ + attack_max = 3; + }else + if( randwork <= 70 + luckwork ){ + attack_max = 2; + }else{ + attack_max = 1; + } + } + }else{ + if( gWeponType == ITEM_FIST )gDamageDiv = attack_max; + } + if( gWeponType == ITEM_BREAKTHROW ){ + gBattleStausChange = BATTLE_ST_PARALYSIS; + gBattleStausTurn = 1-1; + }else{ + } + + if( BattleArray[battleindex].Side[myside].flg & BSIDE_FLG_SURPRISE ){ + }else{ + if( BATTLE_PetLoyalCheck( battleindex, attackNo, charaindex ) ) { +#ifdef _FIXWOLF // Syu ADD ˱Bug + if ( CHAR_getInt ( charaindex , CHAR_BASEIMAGENUMBER) == 101428 ) { + if( CHAR_getWorkInt ( charaindex , CHAR_WORKTURN ) == 0){ + CHAR_setInt( charaindex, CHAR_BASEIMAGENUMBER, CHAR_getInt( charaindex , CHAR_BASEBASEIMAGENUMBER)); + CHAR_setWorkInt( charaindex, CHAR_WORKATTACKPOWER, CHAR_getWorkInt( charaindex , CHAR_WORKFIXSTR)); + CHAR_setWorkInt( charaindex, CHAR_WORKQUICK, CHAR_getWorkInt( charaindex , CHAR_WORKFIXDEX)); + } + } +#endif + //DebugMainFunction="BATTLE_Battling_19"; + sprintf( szWork, "BX|%X|", attackNo); + //DebugMainFunction="BATTLE_Battling_20"; + BATTLESTR_ADD( szWork ); + //DebugMainFunction="BATTLE_Battling_21"; + } + } + +#ifdef _PROFESSION_ADDSKILL + if( CHAR_getWorkInt( charaindex, CHAR_DOOMTIME ) > 0 ){ + CHAR_setWorkInt( charaindex, CHAR_DOOMTIME, CHAR_getWorkInt( charaindex, CHAR_DOOMTIME) - 1 ); + } + if( CHAR_getWorkInt( charaindex, CHAR_DOOMTIME ) == 0 + && ( CHAR_getWorkInt( charaindex, CHAR_WORK_com1 ) == BATTLE_COM_S_FIRE_SPEAR + || CHAR_getWorkInt( charaindex, CHAR_WORK_com1 ) == BATTLE_COM_S_DOOM ) ){ + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, CHAR_getWorkInt( charaindex, CHAR_WORK_com1 ) ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, CHAR_getWorkInt( charaindex, CHAR_WORK_toNo ) ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, CHAR_getWorkInt( charaindex, CHAR_WORK_mode ) ); + CHAR_SETWORKINT_HIGH( charaindex, CHAR_WORKBATTLECOM3, CHAR_getWorkInt( charaindex, CHAR_WORK_skill_level ) ); + CHAR_SETWORKINT_LOW( charaindex, CHAR_WORKBATTLECOM3, CHAR_getWorkInt( charaindex, CHAR_WORK_array ) ); + CHAR_setWorkInt( charaindex, CHAR_WORK_com1, 0 ); + CHAR_setWorkInt( charaindex, CHAR_WORK_toNo, 0 ); + CHAR_setWorkInt( charaindex, CHAR_WORK_mode, 0 ); + CHAR_setWorkInt( charaindex, CHAR_WORK_skill_level, 0 ); + CHAR_setWorkInt( charaindex, CHAR_WORK_array, 0 ); + } + +#endif + COM = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM1 ); + + switch( COM ){ + case BATTLE_COM_ATTACK: + //DebugMainFunction="BATTLE_Battling_22"; + if( gWeponType == ITEM_BOOMERANG ){ + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_BOOMERANG ); + +#ifdef _PETSKILL_BECOMEFOX + if( CHAR_getInt( charaindex, CHAR_BASEIMAGENUMBER)==101749 + || CHAR_getWorkInt( charaindex, CHAR_WORKFOXROUND ) != -1 ){ //DZС겻ʹû + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_NONE ); + } +#endif +#ifdef _PETSKILL_BECOMEPIG + if( CHAR_getInt( charaindex, CHAR_BECOMEPIG) > -1 ){// + gWeponType = ITEM_FIST; + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_ATTACK ); + } +#endif + } + //DebugMainFunction="BATTLE_Battling_23"; + break; + case BATTLE_COM_COMBO: + //DebugMainFunction="BATTLE_Battling_24"; + if( ComboCheck2( EntryList, i, entrynum ) == FALSE ){ + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_ATTACK ); + } + //DebugMainFunction="BATTLE_Battling_25"; + break; + + case BATTLE_COM_S_STATUSCHANGE: + gBattleStausChange = CHAR_GETWORKINT_LOW( charaindex, CHAR_WORKBATTLECOM3 ); + gBattleStausTurn = CHAR_GETWORKINT_HIGH( charaindex, CHAR_WORKBATTLECOM3 ); + break; + +// case BATTLE_COM_S_GYRATE: +// gBattleStausChange = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM5 ); +// gBattleStausTurn = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM6 ); +// break; + +#ifdef _PETSKILL_HECTOR + case BATTLE_COM_S_HECTOR: + gBattleStausChange = CHAR_GETWORKINT_LOW( charaindex, CHAR_WORKBATTLECOM3 ); + gBattleStausTurn = CHAR_GETWORKINT_HIGH( charaindex, CHAR_WORKBATTLECOM3 ); + break; +#endif + +#ifdef _PET_SKILL_SARS // WON ADD ɷ + case BATTLE_COM_S_SARS: + gBattleStausChange = CHAR_GETWORKINT_LOW( charaindex, CHAR_WORKBATTLECOM3 ); + gBattleStausTurn = CHAR_GETWORKINT_HIGH( charaindex, CHAR_WORKBATTLECOM3 ); + break; +#endif + + case BATTLE_COM_S_CHARGE: + //DebugMainFunction="BATTLE_Battling_26"; + BATTLE_Charge( battleindex, attackNo ); + //DebugMainFunction="BATTLE_Battling_27"; + break; + case BATTLE_COM_S_RENZOKU: + attack_max = CHAR_GETWORKINT_LOW( charaindex, CHAR_WORKBATTLECOM3 ); + gDamageDiv = attack_max; + break; + case BATTLE_COM_S_ZIYUN1: + attack_max = CHAR_GETWORKINT_LOW( charaindex, CHAR_WORKBATTLECOM3 ); + gDamageDiv = attack_max; + gBattleDuckModyfy = CHAR_GETWORKINT_HIGH( charaindex, CHAR_WORKBATTLECOM3 ); +#ifdef _VARY_WOLF + case BATTLE_COM_S_VARY: + // ò + break; +#endif +#ifdef _SKILL_WILDVIOLENT_ATT + //񱩹 vincent add 2002/05/16 + case BATTLE_COM_S_WILDVIOLENTATTACK: + attack_max = RAND(3,10);// + gDamageDiv = attack_max;//ÿι˺ + gBattleDuckModyfy = CHAR_GETWORKINT_HIGH( charaindex, CHAR_WORKBATTLECOM3 );// + break; +#endif + case BATTLE_COM_S_EARTHROUND0: + gBattleDamageModyfy = 1.0 + 0.01 * CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM3 ); + break; +#ifdef _BATTLE_ATTCRAZED + case BATTLE_COM_S_ATTCRAZED: + attack_max = CHAR_GETWORKINT_HIGH( charaindex, CHAR_WORKBATTLECOM3); + break; +#endif +#ifdef _SHOOTCHESTNUT // Syu ADD 輼 + case BATTLE_COM_S_ATTSHOOT: + attack_max = CHAR_GETWORKINT_HIGH( charaindex, CHAR_WORKBATTLECOM3); + gDamageDiv = attack_max;//ÿι˺ + break; +#endif + case BATTLE_COM_S_MIGHTY: + gBattleDamageModyfy = CHAR_GETWORKINT_LOW( charaindex, CHAR_WORKBATTLECOM3 ) * 0.01; + gBattleDuckModyfy = CHAR_GETWORKINT_HIGH( charaindex, CHAR_WORKBATTLECOM3 ); // ľĤɧٳ + break; + } + //DebugMainFunction="BATTLE_Battling_28"; + BATTLE_TargetListSet( charaindex, attackNo, aDefList ); + //DebugMainFunction="BATTLE_Battling_29"; + COM = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM1 ); + + ContFlg = FALSE; + if( CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEFLG ) & CHAR_BATTLEFLG_AIBAD + && COM == BATTLE_COM_COMBO ){ + //print( "ҳ϶Ȳʹñɱʧ(%s)\n", CHAR_getUseName( charaindex ) ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_ATTACK ); + } +#ifdef _BATTLE_TIMESPEED//ٶ + { + int flgtime = 0; + switch( COM ){ +#ifdef _BATTLE_ATTCRAZED + case BATTLE_COM_S_ATTCRAZED: + flgtime = 200*3; + break; +#endif +#ifdef _SHOOTCHESTNUT // Syu ADD 輼 + case BATTLE_COM_S_ATTSHOOT: + flgtime = 80*attack_max; + break; +#endif + case BATTLE_COM_JYUJYUTU: + case BATTLE_COM_S_ATTACK_MAGIC: + flgtime = 260; // 1/100sec + break; + case BATTLE_COM_COMBO: + flgtime = 200; // 1/100sec + break; + case BATTLE_COM_GUARD: + break; + case BATTLE_COM_WAIT: + default : + flgtime = 150; // 1/100sec + break; + } + BattleArray[battleindex].flgTime += flgtime; + } +#endif + +#ifdef _PETSKILL_BECOMEFOX // Ļṥ 20% + if( CHAR_getWorkInt( charaindex, CHAR_WORKFOXROUND ) != -1 ){ //С + CHAR_setWorkInt( charaindex, CHAR_WORKATTACKPOWER, CHAR_getWorkInt( charaindex, CHAR_WORKFIXSTR)*0.8);//20% + CHAR_setWorkInt( charaindex, CHAR_WORKDEFENCEPOWER, CHAR_getWorkInt( charaindex, CHAR_WORKFIXTOUGH)*0.8);//20% + CHAR_setWorkInt( charaindex, CHAR_WORKQUICK, CHAR_getWorkInt( charaindex, CHAR_WORKFIXDEX)*0.8);//20% + } +#endif + switch( COM ){// + +#ifdef _PROFESSION_SKILL // WON ADD ְҵ + //==== ֱӹϵ =============================================================== + case BATTLE_COM_S_BRUST: // + case BATTLE_COM_S_CHAIN_ATK: // + case BATTLE_COM_S_CHAIN_ATK_2: // ˫ع + case BATTLE_COM_S_CAVALRY: // ﹥ + case BATTLE_COM_S_DEAD_ATTACK: // + case BATTLE_COM_S_ATTACK_WEAK: // 㹥 + case BATTLE_COM_S_PLUNDER: // Ӷ + case BATTLE_COM_S_CHAOS: // ҹ + { + // ֹͬӻ + //DebugMainFunction="BATTLE_Battling_30"; + defNo = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM2 ); + if( BATTLE_CheckSameSide( charaindex, defNo) == 1 ){ + BATTLE_NoAction( battleindex, attackNo ); break; + } + //DebugMainFunction="BATTLE_Battling_31"; + } + case BATTLE_COM_S_ENRAGE_PET: // ŭ + { + //DebugMainFunction="BATTLE_Battling_32"; + CHAR_setFlg( charaindex, CHAR_ISATTACKED, 1 ); + defNo = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM2 ); + battle_profession_attack_fun(battleindex, attackNo, defNo, charaindex); + //change fix ʹְҵò + //BATTLE_AddProfit( battleindex, aAttackList); + //DebugMainFunction="BATTLE_Battling_33"; + } + break; + //==== ħϵ ================================================================ + case BATTLE_COM_S_VOLCANO_SPRINGS: // ɽȪ + case BATTLE_COM_S_FIRE_BALL: // + case BATTLE_COM_S_FIRE_SPEAR: // ǹ + case BATTLE_COM_S_SUMMON_THUNDER: // + case BATTLE_COM_S_CURRENT: // + case BATTLE_COM_S_STORM: // + case BATTLE_COM_S_ICE_ARROW: // + case BATTLE_COM_S_ICE_CRACK: // + case BATTLE_COM_S_ICE_MIRROR: // + case BATTLE_COM_S_DOOM: // ĩ + case BATTLE_COM_S_BLOOD_WORMS: // Ѫ + case BATTLE_COM_S_SIGN: // һѪ + case BATTLE_COM_S_ENCLOSE: // + case BATTLE_COM_S_THROUGH_ATTACK: // ᴩ + case BATTLE_COM_S_CONVOLUTE: // + { +#ifdef _PROFESSION_ADDSKILL + /* if( COM == BATTLE_COM_S_DOOM //ĩռ + || COM == BATTLE_COM_S_FIRE_SPEAR){ + if( CHAR_getWorkInt( charaindex, CHAR_DOOMTIME ) > 0 ){ + BATTLE_NoAction( battleindex, attackNo ); + sprintf( szWork, "bt|%x|", attackNo ); + BATTLESTR_ADD( szWork ); + break; + } + }*/ +#endif + // ֹͬӻ + //DebugMainFunction="BATTLE_Battling_34"; + defNo = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM2 ); + if( BATTLE_CheckSameSide( charaindex, defNo) == 1 ){ + BATTLE_NoAction( battleindex, attackNo ); break; + } + //DebugMainFunction="BATTLE_Battling_35"; + } + case BATTLE_COM_S_BLOOD: // Ѫ + { + //DebugMainFunction="BATTLE_Battling_36"; + CHAR_setFlg( charaindex, CHAR_ISATTACKED, 1 ); + defNo = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM2 ); +#if 1 // Robin fix Ѫ˵Ѫ + if( defNo != attackNo && COM == BATTLE_COM_S_BLOOD ){ + //print("\n ķ!Ѫ˵Ѫ!!:%s ", CHAR_getChar( charaindex, CHAR_CDKEY) ); + defNo = attackNo; + + CHAR_talkToCli( charaindex, -1, "쳣ߡ", CHAR_COLORYELLOW); + CONNECT_setCloseRequest( CHAR_getWorkInt( charaindex, CHAR_WORKFD ) , 1 ); + break; + } +#endif + //DebugMainFunction="BATTLE_Battling_37"; +#ifdef _PROFESSION_ADDSKILL + if( COM == BATTLE_COM_S_ICE_CRACK ){ + if( pBattle->ice_count >= 20 ) + pBattle->ice_count = 0; + pBattle->ice_use[pBattle->ice_count] = TRUE; + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_NONE ); + pBattle->ice_level[pBattle->ice_count] = CHAR_GETWORKINT_HIGH( charaindex, CHAR_WORKBATTLECOM3); + pBattle->ice_bout[pBattle->ice_count] = 2; + pBattle->ice_toNo[pBattle->ice_count] = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM2 ); + pBattle->ice_array[pBattle->ice_count] = CHAR_GETWORKINT_LOW( charaindex, CHAR_WORKBATTLECOM3); + pBattle->ice_charaindex[pBattle->ice_count] = charaindex; + pBattle->ice_attackNo[pBattle->ice_count] = attackNo; + ++pBattle->ice_count; + BATTLE_NoAction( battleindex, attackNo ); + //print("\n"); + break; + } + //DebugMainFunction="BATTLE_Battling_38"; +#endif + battle_profession_attack_magic_fun(battleindex, attackNo, defNo, charaindex); + //DebugMainFunction="BATTLE_Battling_39"; + //change fix ʹְҵò + //BATTLE_AddProfit( battleindex, aAttackList); + break; + } + //==== ϵ ==================================================================== + case BATTLE_COM_S_FOCUS: // רעս + case BATTLE_COM_S_AVOID: // ر + case BATTLE_COM_S_RECOVERY: // Ѫ + case BATTLE_COM_S_SCAPEGOAT: // Ϊ + case BATTLE_COM_S_ENRAGE: // + case BATTLE_COM_S_COLLECT: // ۼ + case BATTLE_COM_S_TRAP: // + case BATTLE_COM_S_TRANSPOSE: // λλ + case BATTLE_COM_S_DOCILE: // ѱ +#ifdef _PROFESSION_ADDSKILL + case BATTLE_COM_S_CALL_NATURE: // Ȼ +#endif + { + CHAR_setFlg( charaindex, CHAR_ISATTACKED, 1 ); + defNo = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM2 ); + //DebugMainFunction="BATTLE_Battling_40"; + battle_profession_assist_fun(battleindex, attackNo, defNo, charaindex); + //DebugMainFunction="BATTLE_Battling_41"; + break; + } + //==== иı״̬ϵ ==================================================================== + case BATTLE_COM_S_SHIELD_ATTACK: // ܻ + case BATTLE_COM_S_ENTWINE: // + case BATTLE_COM_S_DRAGNET: // ޵ + case BATTLE_COM_S_TOXIN_WEAPON: // + case BATTLE_COM_S_INSTIGATE: // + case BATTLE_COM_S_OBLIVION: // + { + // ֹͬӻ + defNo = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM2 ); + //DebugMainFunction="BATTLE_Battling_42"; + if( BATTLE_CheckSameSide( charaindex, defNo) == 1 ){ + BATTLE_NoAction( battleindex, attackNo ); + //if( COM == BATTLE_COM_S_TOXIN_WEAPON ) + //printf("\nbug-ͬӻ"); + break; + } + //DebugMainFunction="BATTLE_Battling_43"; + } + case BATTLE_COM_S_RESIST_FIRE: // + case BATTLE_COM_S_RESIST_ICE: // + case BATTLE_COM_S_RESIST_THUNDER: // ׿ +#ifdef _PROFESSION_ADDSKILL + case BATTLE_COM_S_RESIST_F_I_T: // Ȼ + case BATTLE_COM_S_BOUNDARY: // Խ +#endif + case BATTLE_COM_S_FIRE_ENCLOSE: // + case BATTLE_COM_S_ICE_ENCLOSE: // + case BATTLE_COM_S_THUNDER_ENCLOSE: // ׸ + { + + CHAR_setFlg( charaindex, CHAR_ISATTACKED, 1 ); + defNo = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM2 ); + //DebugMainFunction="BATTLE_Battling_44"; + battle_profession_status_chang_fun(battleindex, attackNo, defNo, charaindex); + //DebugMainFunction="BATTLE_Battling_45"; + //if( COM == BATTLE_COM_S_TOXIN_WEAPON ) + //printf("\nbug-"); + //DebugMainFunction="BATTLE_Battling_46"; + break; + } + //==================================================================================== +#endif + +#ifdef _PETSKILL_ACUPUNCTURE + case BATTLE_COM_S_ACUPUNCTURE: //Ƥ + CHAR_setWorkInt( charaindex, CHAR_WORKACUPUNCTURE, 1); + //print("\n:%s",CHAR_getChar(charaindex,CHAR_NAME)); +#endif + case BATTLE_COM_S_CHARGE_OK: + case BATTLE_COM_S_POWERBALANCE: + case BATTLE_COM_S_STATUSCHANGE: + case BATTLE_COM_S_EARTHROUND0: + case BATTLE_COM_S_MIGHTY: + if( COM == BATTLE_COM_S_MIGHTY ){ + int def_index = -1; + int i; + defNo = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM2 );//ȡñߵλ + if( BATTLE_TargetCheck(battleindex, defNo) == FALSE + || CHAR_getWorkInt( BATTLE_No2Index( battleindex, defNo ), CHAR_WORKBATTLECOM1 ) == BATTLE_COM_S_EARTHROUND0 ){ + + //һֻ + if( defNo < 10 ){ + for( i=0;i<10;i++ ) + if( BATTLE_TargetCheck(battleindex, i) + && CHAR_getWorkInt( BATTLE_No2Index( battleindex, i ), CHAR_WORKBATTLECOM1 ) != BATTLE_COM_S_EARTHROUND0){ + defNo = i; + break; + } + } + else{ + for( i=10;i<20;i++ ) + if( BATTLE_TargetCheck(battleindex, i) + && CHAR_getWorkInt( BATTLE_No2Index( battleindex, i ), CHAR_WORKBATTLECOM1 ) != BATTLE_COM_S_EARTHROUND0){ + defNo = i; + break; + } + } + if( BATTLE_TargetCheck(battleindex, defNo) == FALSE + || CHAR_getWorkInt( BATTLE_No2Index( battleindex, defNo ), CHAR_WORKBATTLECOM1 ) == BATTLE_COM_S_EARTHROUND0 ) { + return 0; + } + } + def_index = BATTLE_No2Index( battleindex, defNo );//ȡñߵidx + + // ֹͬӻ + //DebugMainFunction="BATTLE_Battling_47"; + if( BATTLE_CheckSameSide( charaindex, defNo) == 1 ){ + BATTLE_NoAction( battleindex, attackNo ); break; + } + //DebugMainFunction="BATTLE_Battling_48"; + if( !CHAR_CHECKINDEX( def_index ) ) break; + //DebugMainFunction="BATTLE_Battling_49"; + if( PROFESSION_BATTLE_StatusAttackCheck( charaindex, def_index, CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM5), CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM7) ) ) + CHAR_setWorkInt( def_index, StatusTbl[CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM5)], CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM6));//趨 + //DebugMainFunction="BATTLE_Battling_50"; + } + + case BATTLE_COM_S_GUARDIAN_ATTACK: + case BATTLE_COM_S_RENZOKU: +#ifdef _BATTLE_ATTCRAZED // ANDY + case BATTLE_COM_S_ATTCRAZED: +#endif +#ifdef _SHOOTCHESTNUT // Syu ADD 輼 + case BATTLE_COM_S_ATTSHOOT: +#endif +#ifdef _SKILL_WILDVIOLENT_ATT + case BATTLE_COM_S_WILDVIOLENTATTACK://񱩹 vincent add 2002/05/16 +#endif + +#ifdef _SKILL_SPEEDY_ATT + case BATTLE_COM_S_SPEEDYATTACK: //ٹ vincent add 2002/05/20 +#endif + case BATTLE_COM_ATTACK: +#ifdef _PET_SKILL_SARS // WON ADD ɷ + case BATTLE_COM_S_SARS: +#endif + +#ifdef _PETSKILL_BECOMEFOX + case BATTLE_COM_S_BECOMEFOX: +#endif + +#ifdef _PETSKILL_BECOMEPIG + case BATTLE_COM_S_BECOMEPIG: +#endif + +#ifdef _PETSKILL_SHOWMERCY + case BATTLE_COM_S_SHOWMERCY: +#endif + +#ifdef _PETSKILL_GYRATE + case BATTLE_COM_S_GYRATE: + if( COM == BATTLE_COM_S_GYRATE ){ + int i,j=0,f_num,temp[5]={0}; + char szWork[256]; + defNo = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM2 ); + if(defNo < 5) + f_num = 0; + else if(defNo >=5 && defNo < 10) + f_num = 5; + else if(defNo >=10 && defNo < 15) + f_num = 10; + else + f_num = 15; + + // ȡսϴ + for( i=f_num; i= 10 ){ + BATTLE_NoAction( battleindex, attackNo ); + break; + } + //DebugMainFunction="BATTLE_Battling_75"; + defNo = aDefList[0]; + }else + if( (defNo = BATTLE_TargetAdjust( battleindex, charaindex, myside )) < 0 + || defNo == attackNo){ + BATTLE_NoAction( battleindex, attackNo ); + break; + } + //DebugMainFunction="BATTLE_Battling_76"; + if( COM == BATTLE_COM_S_EARTHROUND0 ){ + sprintf( szWork, "BI|a%X|", attackNo ); + //DebugMainFunction="BATTLE_Battling_77"; + }else { +#ifdef _FIXBUG_ATTACKBOW + if( CHAR_getWorkInt( charaindex, CHAR_WORKITEMMETAMO) > 0 || + CHAR_getWorkInt( charaindex, CHAR_WORKNPCMETAMO) > 0 + || CHAR_getWorkInt( charaindex, CHAR_WORKFOXROUND ) != -1 ){ //DZС + + if( gWeponType == ITEM_BOW || gWeponType == ITEM_BOUNDTHROW || + gWeponType == ITEM_BREAKTHROW || gWeponType == ITEM_BOOMERANG) { + CHAR_talkToCli( charaindex, -1, "޷ʹԶ!!", CHAR_COLORYELLOW); + continue; + } + + } +#endif + //DebugMainFunction="BATTLE_Battling_78"; + if( gWeponType == ITEM_BOW ) sprintf( szWork, "BB|a%X|w0|", attackNo ); + else if( gWeponType == ITEM_BOUNDTHROW ) //Ƕͷ + sprintf( szWork, "BB|a%X|w1|", attackNo ); + else if( gWeponType == ITEM_BREAKTHROW ) + sprintf( szWork, "BB|a%X|w2|", attackNo ); + else sprintf( szWork, "BH|a%X|", attackNo ); + //DebugMainFunction="BATTLE_Battling_79"; + } + +#ifdef _SHOOTCHESTNUT // Syu ADD 輼 + if ( COM == BATTLE_COM_S_ATTSHOOT ) + sprintf( szWork, "BB|a%X|w0|", attackNo ); +#endif + //DebugMainFunction="BATTLE_Battling_80"; + BATTLESTR_ADD( szWork ); + //DebugMainFunction="BATTLE_Battling_81"; + if( COM == BATTLE_COM_S_CHARGE_OK || + COM == BATTLE_COM_S_EARTHROUND0 ){ + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_NONE ); + }else{ + +#ifdef _SHOOTCHESTNUT // Syu ADD 輼 + if ( CHAR_getWorkInt(charaindex, CHAR_WORKBATTLECOM1) != BATTLE_COM_S_ATTSHOOT) +#endif +#ifdef _PETSKILL_SHOWMERCY + if( CHAR_getWorkInt(charaindex, CHAR_WORKBATTLECOM1) != BATTLE_COM_S_SHOWMERCY) +#endif + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1,BATTLE_COM_ATTACK ); + } + for( attack_count = 0, k = 0;; ){ + if( gWeponType == ITEM_BOW ){ + if( BATTLE_TargetCheck( battleindex, defNo ) == FALSE ){ + attack_flg = 0; + }else{ + attack_flg = 1; + } + } + + + if( attack_flg ){ + + + ContFlg = BATTLE_Attack( battleindex, attackNo, defNo ); +#ifdef _PETSKILL_RETRACE + if( Battle_Attack_ReturnData_x.Battle_Attack_ReturnData == BATTLE_RET_DODGE + && COM == BATTLE_COM_S_RETRACE ){ + if( RAND(1,100) < 80 ){ //80%ʷ2ι + //+20% + + CHAR_setWorkInt( BATTLE_No2Index( battleindex, attackNo ), + CHAR_WORKATTACKPOWER, + ( CHAR_getWorkInt( BATTLE_No2Index( battleindex, attackNo ), CHAR_WORKFIXSTR) + ( CHAR_getWorkInt( BATTLE_No2Index( battleindex, attackNo ), CHAR_WORKFIXSTR) * 0.2 ) ) ); + //DebugMainFunction="BATTLE_Battling_82"; + BATTLE_Attack( battleindex, attackNo, defNo ); + //DebugMainFunction="BATTLE_Battling_83"; + } + Battle_Attack_ReturnData_x.Battle_Attack_ReturnData = 0; + } +#endif + //DebugMainFunction="BATTLE_Battling_84"; + BATTLE_AddProfit( battleindex, aAttackList); + //DebugMainFunction="BATTLE_Battling_85"; + if( ++attack_count >= attack_max ) break; + if( CHAR_getInt( charaindex, CHAR_HP ) <= 0 ) { + ContFlg = FALSE; + break; + } + } + defNo = aDefList[++k]; + if( defNo < 0 ) break; + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, defNo ); + if( gWeponType == ITEM_BOW ){ + }else + if( (defNo = BATTLE_TargetAdjust( battleindex, charaindex, myside )) < 0 ){ + break; + } + if( BATTLE_CountAlive( battleindex, 0) == 0 || BATTLE_CountAlive( battleindex, 1) == 0) { + break; + } + } + gBattleDamageModyfy = 1.0; + gBattleDuckModyfy = 0; + + for( k = 0; k < 5 && ContFlg == TRUE; k ++ ){ + if( ( k & 1 ) == 1 ){ + attackNoSub = attackNo; + defNoSub = defNo; + }else{ + defNoSub = attackNo; + attackNoSub = defNo; + } + //DebugMainFunction="BATTLE_Battling_86"; + ContFlg = BATTLE_Counter(battleindex, attackNoSub, defNoSub ); + //DebugMainFunction="BATTLE_Battling_87"; + aAttackList[0] = attackNoSub; + aAttackList[1] = -1; + BATTLE_AddProfit( battleindex, aAttackList); + //DebugMainFunction="BATTLE_Battling_88"; + } + aAttackList[0] = -1; + //DebugMainFunction="BATTLE_Battling_89"; + BATTLESTR_ADD( "FF|" ); + //DebugMainFunction="BATTLE_Battling_90"; + +#ifdef _PETSKILL_BECOMEFOX // ԷʹĻ + if ( (COM == BATTLE_COM_S_BECOMEFOX ) + && (Battle_Attack_ReturnData_x.Battle_Attack_ReturnData != BATTLE_RET_MISS) //ûmiss + && (Battle_Attack_ReturnData_x.Battle_Attack_ReturnData != BATTLE_RET_DODGE) //ûܹ + && (Battle_Attack_ReturnData_x.Battle_Attack_ReturnData != BATTLE_RET_ALLGUARD) + && (Battle_Attack_ReturnData_x.Battle_Attack_ReturnData != BATTLE_RET_ARRANGE) + && (BATTLE_TargetCheck( battleindex, defNo )) // + && (rand()%100 < 31) + && (CHAR_getInt( BATTLE_No2Index( battleindex, defNo ), CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER) //ֻг(CHAR_TYPEPET)ſԱĻ + && (CHAR_getWorkInt( BATTLE_No2Index( battleindex, defNo ), CHAR_WORK_PETFLG ) != 0 ) +#ifdef _PETSKILL_BECOMEPIG + && (CHAR_getInt( charaindex, CHAR_BECOMEPIG) == -1)//ûд +#endif + ) + { + int ToList[SIDE_OFFSET*2+1]; + int defindex = BATTLE_No2Index( battleindex, defNo ); + //DebugMainFunction="BATTLE_Battling_91"; + BATTLE_MultiList( battleindex, defNo, ToList ); + //DebugMainFunction="BATTLE_Battling_92"; + BATTLE_MagicEffect( battleindex, defNo, ToList, 101120, 101750); + //DebugMainFunction="BATTLE_Battling_93"; + + CHAR_setWorkInt( defindex, CHAR_WORKFOXROUND, pBattle->turn ); + + if( CHAR_getInt( defindex, CHAR_RIDEPET) != -1 ) { //Ҫ + CHAR_setInt( defindex, CHAR_RIDEPET, -1 ); + //DebugMainFunction="BATTLE_Battling_94"; + BATTLE_changeRideImage( defindex ); + //DebugMainFunction="BATTLE_Battling_95"; + CHAR_setWorkInt( defindex, CHAR_WORKPETFALL, 1 ); + } + + CHAR_setInt( defindex, CHAR_BASEIMAGENUMBER, 101749); + } +#endif + //DebugMainFunction="BATTLE_Battling_96"; +#ifdef _PETSKILL_BECOMEPIG // Էʹ + if ( (COM == BATTLE_COM_S_BECOMEPIG ) + && (Battle_Attack_ReturnData_x.Battle_Attack_ReturnData != BATTLE_RET_MISS) //ûmiss + && (Battle_Attack_ReturnData_x.Battle_Attack_ReturnData != BATTLE_RET_DODGE) //ûܹ + && (Battle_Attack_ReturnData_x.Battle_Attack_ReturnData != BATTLE_RET_ALLGUARD) + && (Battle_Attack_ReturnData_x.Battle_Attack_ReturnData != BATTLE_RET_ARRANGE) + && (BATTLE_TargetCheck( battleindex, defNo )) // + && (CHAR_getInt( BATTLE_No2Index( battleindex, defNo ), CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER) //ֻҲſԱ + && (BATTLE_CheckSameSide( charaindex, defNo) != 1 ) // ֹͬӻ + && CHAR_getInt( BATTLE_No2Index( battleindex, defNo ), CHAR_BECOMEPIG) < 2000000000 ) //ֹƱ + { + char temp[64]; + int ToList[SIDE_OFFSET*2+1], compute,petrate,pettime,pigbbi=100250; + char *pszOption=NULL; + //DebugMainFunction="BATTLE_Battling_97"; + int defindex = BATTLE_No2Index( battleindex, defNo ); + //DebugMainFunction="BATTLE_Battling_98"; + pszOption = PETSKILL_getChar( CHAR_GETWORKINT_LOW( charaindex, CHAR_WORKBATTLECOM3 ), PETSKILL_OPTION ); + //DebugMainFunction="BATTLE_Battling_99"; + if( pszOption == "\0") + sscanf( pszOption, "%d %d %d", &petrate, &pettime, &pigbbi); + else + petrate = 100, pettime = 60, pigbbi = 100250; + //DebugMainFunction="BATTLE_Battling_100"; + if( rand()%100 < petrate ){ + CHAR_setWorkInt( defindex, CHAR_WORKITEMMETAMO, 0);//߱ȡ + CHAR_setWorkInt( defindex, CHAR_WORKNPCMETAMO, 0 );//NPCȡ + CHAR_setWorkInt( defindex, CHAR_WORKFOXROUND, -1);//Ļȡ + //DebugMainFunction="BATTLE_Battling_101"; + BATTLE_MultiList( battleindex, defNo, ToList ); + //DebugMainFunction="BATTLE_Battling_102"; + BATTLE_MagicEffect( battleindex, defNo, ToList, 101120, 101750); + //DebugMainFunction="BATTLE_Battling_103"; + if( CHAR_getInt( defindex, CHAR_RIDEPET) != -1 ){ //Ҫ + CHAR_setInt( defindex, CHAR_RIDEPET, -1 ); + //DebugMainFunction="BATTLE_Battling_104"; + BATTLE_changeRideImage( defindex ); + //DebugMainFunction="BATTLE_Battling_105"; + CHAR_setWorkInt( defindex, CHAR_WORKPETFALL, 1 ); + } + + CHAR_setInt( defindex, CHAR_BECOMEPIG_BBI, pigbbi ); + + compute = CHAR_getInt( defindex, CHAR_BECOMEPIG); + CHAR_setInt( defindex, CHAR_BASEIMAGENUMBER, CHAR_getInt( defindex, CHAR_BECOMEPIG_BBI ) ); + if( compute == -1 )//һ + CHAR_setInt( defindex, CHAR_BECOMEPIG, pettime + 1 + compute ); //ʱ(λ:) + else + CHAR_setInt( defindex, CHAR_BECOMEPIG, pettime + compute ); + sprintf(temp, "ʱ:%d", CHAR_getInt( defindex, CHAR_BECOMEPIG) ); + CHAR_talkToCli( defindex, -1, temp, CHAR_COLORYELLOW); + //DebugMainFunction="BATTLE_Battling_106"; + //print("\nʼ0:%s,round:%d", CHAR_getChar( defindex, CHAR_NAME), CHAR_getWorkInt( defindex, CHAR_WORKFOXROUND)); + } + } +#endif + break; +//´⹥ + case BATTLE_COM_BOOMERANG: + gBattleDamageModyfy = 0.3; + defNo = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM2 ); + //DebugMainFunction="BATTLE_Battling_107"; + if( defNo < 0 ){ + defNo = BATTLE_DefaultAttacker( battleindex, 1 - myside ); + } + //DebugMainFunction="BATTLE_Battling_108"; + if( 0 <= defNo && defNo <= 19 ){ + defNo /= 5; // + }else{ + BATTLE_NoAction( battleindex, attackNo ); + break; + } + //DebugMainFunction="BATTLE_Battling_109"; + if( (int)(attackNo / 5 ) == defNo ){ + BATTLE_NoAction( battleindex, attackNo ); + break; + } + //DebugMainFunction="BATTLE_Battling_110"; + { + int *pBoomerangTbl = BoomerangVsTbl[defNo]; + for( k = 0; k < 5; k ++ ){ + if( BATTLE_TargetCheck( battleindex, pBoomerangTbl[k] ) == FALSE ){ + continue; + }else{ + break; + } + } + //DebugMainFunction="BATTLE_Battling_111"; + if( k == 5 ){ + defNo = BATTLE_DefaultAttacker( battleindex, 1 - myside ); + if( 0 <= defNo && defNo <= 19 ){ + defNo /= 5; + }else{ + BATTLE_NoAction( battleindex, attackNo ); + break; + } + } + //DebugMainFunction="BATTLE_Battling_112"; + } + sprintf( szWork, "BO|a%X|", attackNo ); + //DebugMainFunction="BATTLE_Battling_113"; + BATTLESTR_ADD( szWork ); + //DebugMainFunction="BATTLE_Battling_114"; + { + //DebugMainFunction="BATTLE_Battling_115"; + int *pBoomerangTbl = BoomerangVsTbl[defNo]; + //DebugMainFunction="BATTLE_Battling_116"; + if( myside == 1 ){ + k = 4; j = -1; + }else{ + k = 0; j = 1; + } + for( ; ; k += j ){ + if( j > 0 && k > 4 )break; + if( j < 0 && k < 0 )break; + defNo = pBoomerangTbl[k]; + if( BATTLE_TargetCheck( battleindex, defNo ) == FALSE ){ + continue; + } + BATTLE_Attack( battleindex, attackNo, defNo ); + } + } + gBattleDamageModyfy = 1.0; + gBattleDuckModyfy = 0; + //DebugMainFunction="BATTLE_Battling_117"; + BATTLESTR_ADD( "FF|" ); + //DebugMainFunction="BATTLE_Battling_118"; + break; + + //--------------------------------------------- + case BATTLE_COM_CAPTURE: + if( (defNo = BATTLE_TargetAdjust( battleindex, charaindex, myside )) < 0 ){ + BATTLE_NoAction( battleindex, attackNo ); + break; + } + //DebugMainFunction="BATTLE_Battling_119"; + BATTLE_Capture( battleindex, attackNo, defNo ); + //DebugMainFunction="BATTLE_Battling_120"; + break; + + //--------------------------------------------- +#ifdef _VARY_WOLF + case BATTLE_COM_S_VARY: + { + int ToList[SIDE_OFFSET*2+1]; + int bk_amn = 0; + + if( (defNo = BATTLE_TargetAdjust( battleindex, charaindex, myside )) < 0 ){ + BATTLE_NoAction( battleindex, attackNo ); + break; + } + bk_amn = (CHAR_getInt( charaindex, CHAR_BASEBASEIMAGENUMBER) + 5) + (myside*4); + //DebugMainFunction="BATTLE_Battling_121"; + BATTLE_MultiList( battleindex, defNo, ToList ); + //DebugMainFunction="BATTLE_Battling_122"; + BATTLE_MagicEffect( battleindex, attackNo, ToList, 101120, bk_amn); + //DebugMainFunction="BATTLE_Battling_123"; + } + break; +#endif + case BATTLE_COM_GUARD: + //DebugMainFunction="BATTLE_Battling_124"; + BATTLE_Guard( battleindex, attackNo ); + //DebugMainFunction="BATTLE_Battling_125"; + + break; + case BATTLE_COM_ESCAPE: + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE ) != CHAR_TYPEPET ){ + if (BATTLE_Escape(battleindex, attackNo, 0) == TRUE) + { + if (CHAR_getWorkInt(charaindex, CHAR_WORKFMPKFLAG) == 1) + CHAR_setWorkInt(charaindex, CHAR_WORKFMPKFLAG, -1); + } + } + break; + case BATTLE_COM_COMPELESCAPE: //ǿ뿪 + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE ) != CHAR_TYPEPET ){ + //DebugMainFunction="BATTLE_Battling_126"; + BATTLE_Escape( battleindex, attackNo, 1); + //DebugMainFunction="BATTLE_Battling_127"; + if (CHAR_getWorkInt(charaindex, CHAR_WORKFMPKFLAG) == 1) + CHAR_setWorkInt(charaindex, CHAR_WORKFMPKFLAG, -1); + } + break; + + case BATTLE_COM_PETIN: + if( CHAR_getInt( charaindex, CHAR_DEFAULTPET ) == -1 ){ + BATTLE_NoAction( battleindex, attackNo ); + break; + } + { + char szWork[256]; + //DebugMainFunction="BATTLE_Battling_128"; + snprintf( szWork, sizeof( szWork ), "K%d", CHAR_getInt( charaindex, CHAR_DEFAULTPET ) ); + //DebugMainFunction="BATTLE_Battling_129"; + CHAR_sendStatusString( charaindex, szWork ); + //DebugMainFunction="BATTLE_Battling_130"; + + } + //DebugMainFunction="BATTLE_Battling_131"; + BATTLE_PetIn( battleindex, attackNo ); + //DebugMainFunction="BATTLE_Battling_132"; + lssproto_KS_send( + getfdFromCharaIndex( charaindex ), + CHAR_getInt( charaindex, CHAR_DEFAULTPET ), 1 ); + break; + case BATTLE_COM_PETOUT: + if( CHAR_getInt( charaindex, CHAR_DEFAULTPET ) != -1 ){ + lssproto_KS_send( + getfdFromCharaIndex( charaindex ), + CHAR_getInt( charaindex, CHAR_DEFAULTPET ), 1 ); + { + char szWork[256]; + snprintf( szWork, sizeof( szWork ), "K%d", CHAR_getInt( charaindex, CHAR_DEFAULTPET ) ); + CHAR_sendStatusString( charaindex, szWork ); + + } + //DebugMainFunction="BATTLE_Battling_133"; + BATTLE_PetIn( battleindex, attackNo ); + //DebugMainFunction="BATTLE_Battling_134"; + } + // shan 2002/01/14 Begin ֻ + { + int attackindex, petNo; + + attackindex = BATTLE_No2Index( battleindex, attackNo ); + petNo = CHAR_getWorkInt( attackindex, CHAR_WORKBATTLECOM2 ); +#ifdef _TRANS_7_COLOR //CFǷٻ + if( getpetsummon() == 0 ){ + + if( CHAR_getWorkInt(charaindex, CHAR_WORK_PET0_STAT+petNo) != PET_STAT_SELECT) + break; + } +#endif +/* //CAX +#ifndef _PET_STANDBY + if( CHAR_getWorkInt(charaindex, CHAR_WORK_PET0_STAT+petNo) != PET_STAT_SELECT) + break; +#endif +*/ + } + //DebugMainFunction="BATTLE_Battling_135"; + // shan End + BATTLE_PetOut( battleindex, attackNo ); + //DebugMainFunction="BATTLE_Battling_136"; + lssproto_KS_send( + getfdFromCharaIndex( charaindex ), + CHAR_getInt( charaindex, CHAR_DEFAULTPET ), 1 ); + break; +// Terry add 2001/11/05 +#ifdef _ATTACK_MAGIC + case BATTLE_COM_S_ATTACK_MAGIC: // ħ + magic = CHAR_GETWORKINT_LOW(charaindex,CHAR_WORKBATTLECOM3); + toindex = CHAR_getWorkInt(charaindex,CHAR_WORKBATTLECOM2); +// print("magic->%d,toindex->%d\n",magic,toindex); + // жϹ Χ + //DebugMainFunction="BATTLE_Battling_137"; + for(magic_count=0;magic_count= 0 && toindex <= 4) + toindex = TargetIndex[magic_count][1]; + // µǰһ + else + toindex = TargetIndex[magic_count][1]-1; + } + break; + } + } + //DebugMainFunction="BATTLE_Battling_138"; +// print("toindex->%d\n",toindex); + MAGIC_DirectUse(charaindex,magic,toindex,CHAR_GETWORKINT_HIGH(charaindex,CHAR_WORKBATTLECOM3)); + //DebugMainFunction="BATTLE_Battling_139"; + BATTLE_AddProfit( battleindex, aAttackList ); + //DebugMainFunction="BATTLE_Battling_140"; + break; +#endif + case BATTLE_COM_JYUJYUTU: + //DebugMainFunction="BATTLE_Battling_141"; + MAGIC_DirectUse( + charaindex, + CHAR_GETWORKINT_LOW( charaindex, CHAR_WORKBATTLECOM3 ), + CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM2 ), + CHAR_GETWORKINT_HIGH( charaindex, CHAR_WORKBATTLECOM3 ) + ); + //DebugMainFunction="BATTLE_Battling_142"; + break; + + case BATTLE_COM_ITEM: + itemindex = CHAR_getItemIndex(charaindex, CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM3 )); + if( ITEM_CHECKINDEX( itemindex ) == FALSE ){ +// print( "\nerr:Ҫʹõitemλ(%s)(%d)\n", +// CHAR_getUseName( charaindex ), CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM3 ) ); + break; + } + +#if 1 // Robin fix սɻƷ +#ifdef _BATTLE_EQUIT_OTHER + if(getBattleEquitOther()!=1) +#endif + { + int itemtype = ITEM_getInt( itemindex, ITEM_TYPE ); + if( itemtype == ITEM_HELM + || itemtype == ITEM_ARMOUR + || itemtype == ITEM_BRACELET + //|| itemtype == ITEM_MUSIC + || itemtype == ITEM_NECKLACE + || itemtype == ITEM_RING + || itemtype == ITEM_BELT + || itemtype == ITEM_EARRING + || itemtype == ITEM_NOSERING + || itemtype == ITEM_AMULET + //|| itemtype == CHAR_HEAD + ) + { + //print("\n ķ!սɻ!!:%s ", CHAR_getChar( charaindex, CHAR_CDKEY) ); + break; + } + } +#endif + +#ifdef _FIXBUG_ATTACKBOW + { + if( CHAR_getWorkInt( charaindex, CHAR_WORKITEMMETAMO) > 0 || + CHAR_getWorkInt( charaindex, CHAR_WORKNPCMETAMO) > 0 + || CHAR_getWorkInt( charaindex, CHAR_WORKFOXROUND ) != -1 ){ //DZС + + int armtype; + int itemindex = CHAR_getItemIndex( charaindex, CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM3 )); + if( !ITEM_CHECKINDEX(itemindex) ) break; + armtype = ITEM_getInt( itemindex, ITEM_TYPE ); + + if( armtype == ITEM_BOW || armtype == ITEM_BOUNDTHROW || + armtype == ITEM_BREAKTHROW || armtype == ITEM_BOOMERANG) { + CHAR_talkToCli( charaindex, -1, "޷ʹԶ", CHAR_COLORYELLOW ); + break; + } + } + } +#endif + //DebugMainFunction="BATTLE_Battling_143"; + CHAR_ItemUse(charaindex,CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM2 ), CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM3 )); + //DebugMainFunction="BATTLE_Battling_144"; + if( ITEM_getEquipPlace( charaindex, itemindex ) == CHAR_ARM ){ + //DebugMainFunction="BATTLE_Battling_145"; + sprintf( szWork, "BN|a%X|%X|", attackNo, + CHAR_getInt( charaindex, CHAR_BASEIMAGENUMBER ) ); + //DebugMainFunction="BATTLE_Battling_146"; + BATTLESTR_ADD( szWork ); + //DebugMainFunction="BATTLE_Battling_147"; +#ifdef _PROFESSION_SKILL // WON ADD ְҵ + // ר + BATTLE_ProfessionStatus_init( battleindex, charaindex ); +#endif + //DebugMainFunction="BATTLE_Battling_148"; + }else{ + } + //DebugMainFunction="BATTLE_Battling_149"; + break; + +#ifdef _PSKILL_FALLGROUND + case BATTLE_COM_S_FALLRIDE:// + if( (defNo = BATTLE_TargetAdjust( battleindex, charaindex, myside )) < 0 ){ + BATTLE_NoAction( battleindex, attackNo ); + //print("\n BATTLE_NoAction()"); + break; + } + //DebugMainFunction="BATTLE_Battling_150"; + ContFlg = BATTLE_S_FallGround( battleindex, attackNo, defNo, BATTLE_COM_S_FALLRIDE); + //DebugMainFunction="BATTLE_Battling_151"; + break; + +#endif +#ifdef _PETSKILL_TIMID + case BATTLE_COM_S_TIMID: + { + int skill; + //DebugMainFunction="BATTLE_Battling_152"; + if( (defNo = BATTLE_TargetAdjust( battleindex, charaindex, myside )) < 0 ){ + BATTLE_NoAction( battleindex, attackNo ); + //print("\n BATTLE_NoAction()"); + break; + } + //DebugMainFunction="BATTLE_Battling_153"; + skill = CHAR_GETWORKINT_LOW(charaindex,CHAR_WORKBATTLECOM3); + ContFlg = BATTLE_S_AttackDamage( battleindex, attackNo, defNo, BATTLE_COM_S_TIMID, skill); + //DebugMainFunction="BATTLE_Battling_154"; + } + break; +#endif +#ifdef _PETSKILL_2TIMID + case BATTLE_COM_S_2TIMID: + { + int skill; + //DebugMainFunction="BATTLE_Battling_155"; + if( (defNo = BATTLE_TargetAdjust( battleindex, charaindex, myside )) < 0 ){ + BATTLE_NoAction( battleindex, attackNo ); + //print("\n BATTLE_NoAction()"); + break; + } + //DebugMainFunction="BATTLE_Battling_156"; + if( BATTLE_CheckSameSide( charaindex, defNo) == 1 ) { + BATTLE_NoAction( battleindex, attackNo ); + break; + } + //DebugMainFunction="BATTLE_Battling_157"; + skill = CHAR_GETWORKINT_LOW(charaindex,CHAR_WORKBATTLECOM3); + ContFlg = BATTLE_S_AttackDamage( battleindex, attackNo, defNo, BATTLE_COM_S_2TIMID, skill); + //DebugMainFunction="BATTLE_Battling_158"; + } + break; +#endif + +#ifdef _PETSKILL_PROPERTY + case BATTLE_COM_S_PROPERTYSKILL: + { + int skill; + skill = CHAR_GETWORKINT_LOW(charaindex,CHAR_WORKBATTLECOM3); + //DebugMainFunction="BATTLE_Battling_159"; + BATTLE_S_PetSkillProperty( battleindex, attackNo, COM, skill); + //DebugMainFunction="BATTLE_Battling_160"; + BATTLE_NoAction( battleindex, attackNo ); + //DebugMainFunction="BATTLE_Battling_161"; + } + break; +#endif + +#ifdef _BATTLE_LIGHTTAKE + case BATTLE_COM_S_LIGHTTAKE: + { + int skill; + //DebugMainFunction="BATTLE_Battling_162"; + if( (defNo = BATTLE_TargetAdjust( battleindex, charaindex, myside )) < 0 ){ + BATTLE_NoAction( battleindex, attackNo ); + //print("\n BATTLE_NoAction()"); + break; + } + //DebugMainFunction="BATTLE_Battling_163"; + skill = CHAR_GETWORKINT_LOW(charaindex,CHAR_WORKBATTLECOM3); + ContFlg = BATTLE_S_AttackDamage( battleindex, attackNo, defNo, BATTLE_COM_S_LIGHTTAKE, skill); + //DebugMainFunction="BATTLE_Battling_164"; + } + break; +#endif + +#ifdef _SKILL_DAMAGETOHP + case BATTLE_COM_S_DAMAGETOHP: //Ѫ + { + int skill; + //DebugMainFunction="BATTLE_Battling_165"; + if( (defNo = BATTLE_TargetAdjust( battleindex, charaindex, myside )) < 0 ){ + BATTLE_NoAction( battleindex, attackNo ); + //print("\n BATTLE_NoAction()"); + break; + } + //DebugMainFunction="BATTLE_Battling_166"; + skill = CHAR_GETWORKINT_LOW(charaindex,CHAR_WORKBATTLECOM3); + ContFlg = BATTLE_S_AttackDamage( battleindex, attackNo, defNo, BATTLE_COM_S_DAMAGETOHP, skill); + //DebugMainFunction="BATTLE_Battling_167"; + } + break; +#endif + +#ifdef _PETSKILL_DAMAGETOHP + case BATTLE_COM_S_DAMAGETOHP2: //¿(Ѫı) + { + int skill,attackidxtemp; + //DebugMainFunction="BATTLE_Battling_168"; + attackidxtemp = BATTLE_No2Index( battleindex, attackNo ); + //DebugMainFunction="BATTLE_Battling_169"; + if( (defNo = BATTLE_TargetAdjust( battleindex, charaindex, myside )) < 0 ){ + BATTLE_NoAction( battleindex, attackNo ); + //print("\n BATTLE_NoAction()"); + break; + } + //DebugMainFunction="BATTLE_Battling_170"; + skill = CHAR_GETWORKINT_LOW(charaindex,CHAR_WORKBATTLECOM3); + ContFlg = BATTLE_S_AttackDamage( battleindex, attackNo, defNo, BATTLE_COM_S_DAMAGETOHP2, skill); + //DebugMainFunction="BATTLE_Battling_171"; + } + break; +#endif + +#ifdef _Skill_MPDAMAGE + case BATTLE_COM_S_MPDAMAGE: //MP˺ + { + int skill; + //DebugMainFunction="BATTLE_Battling_172"; + if( (defNo = BATTLE_TargetAdjust( battleindex, charaindex, myside )) < 0 ){ + BATTLE_NoAction( battleindex, attackNo ); + //print("\n BATTLE_NoAction()"); + break; + } + //DebugMainFunction="BATTLE_Battling_173"; + skill = CHAR_GETWORKINT_LOW(charaindex,CHAR_WORKBATTLECOM3); + ContFlg = BATTLE_S_AttackDamage( battleindex, attackNo, defNo, BATTLE_COM_S_MPDAMAGE, skill); + //DebugMainFunction="BATTLE_Battling_174"; + break; + } + break; +#endif +#ifdef _SKILL_TOOTH + case BATTLE_COM_S_TOOTHCRUSHE: + { + int skill; + //DebugMainFunction="BATTLE_Battling_175"; + if( (defNo = BATTLE_TargetAdjust( battleindex, charaindex, myside )) < 0 ){ + BATTLE_NoAction( battleindex, attackNo ); + //print("\n BATTLE_NoAction()"); + break; + } + //DebugMainFunction="BATTLE_Battling_176"; + skill = CHAR_GETWORKINT_LOW(charaindex,CHAR_WORKBATTLECOM3); + ContFlg = BATTLE_S_AttackDamage( battleindex, attackNo, defNo, BATTLE_COM_S_TOOTHCRUSHE, skill); + //DebugMainFunction="BATTLE_Battling_177"; + break; + } + break; +#endif +#ifdef _PSKILL_MODIFY + case BATTLE_COM_S_MODIFYATT: + { + int skill; + //DebugMainFunction="BATTLE_Battling_178"; + if( (defNo = BATTLE_TargetAdjust( battleindex, charaindex, myside )) < 0 ){ + BATTLE_NoAction( battleindex, attackNo ); + //print("\n BATTLE_NoAction()"); + break; + } + //DebugMainFunction="BATTLE_Battling_179"; + skill = CHAR_GETWORKINT_LOW(charaindex,CHAR_WORKBATTLECOM3); + ContFlg = BATTLE_S_AttackDamage( battleindex, attackNo, defNo, BATTLE_COM_S_MODIFYATT, skill); + //DebugMainFunction="BATTLE_Battling_180"; + } + break; +#endif +#ifdef _PSKILL_MDFYATTACK + case BATTLE_COM_S_MDFYATTACK: + { + int skill; + //DebugMainFunction="BATTLE_Battling_181"; + if( (defNo = BATTLE_TargetAdjust( battleindex, charaindex, myside )) < 0 ){ + BATTLE_NoAction( battleindex, attackNo ); + //print("\n BATTLE_NoAction()"); + break; + } + //DebugMainFunction="BATTLE_Battling_182"; + skill = CHAR_GETWORKINT_LOW(charaindex,CHAR_WORKBATTLECOM3); + ContFlg = BATTLE_S_AttackDamage( battleindex, attackNo, defNo, BATTLE_COM_S_MDFYATTACK, skill); + //DebugMainFunction="BATTLE_Battling_183"; + } + break; +#endif + +#ifdef _PETSKILL_TEAR + case BATTLE_COM_S_PETSKILLTEAR: + { + int skill; + //DebugMainFunction="BATTLE_Battling_184"; + if( (defNo = BATTLE_TargetAdjust( battleindex, charaindex, myside )) < 0 ){ + BATTLE_NoAction( battleindex, attackNo ); + //print("\n BATTLE_NoAction()"); + break; + } + //DebugMainFunction="BATTLE_Battling_185"; + skill = CHAR_GETWORKINT_LOW( charaindex, CHAR_WORKBATTLECOM3); + ContFlg = BATTLE_S_AttackDamage( battleindex, attackNo, defNo, BATTLE_COM_S_PETSKILLTEAR, skill); + //DebugMainFunction="BATTLE_Battling_186"; + } + break; +#endif + +#ifdef _SONIC_ATTACK // WON ADD + case BATTLE_COM_S_SONIC: + { + int skill, defNo2=-1, index2=-1; + + if( (defNo = BATTLE_TargetAdjust( battleindex, charaindex, myside )) < 0 ){ + BATTLE_NoAction( battleindex, attackNo ); + //print("\n BATTLE_NoAction()"); + break; + } + skill = CHAR_GETWORKINT_LOW( charaindex, CHAR_WORKBATTLECOM3); + + if( defNo >= 15 && defNo < 20 ) defNo2 = defNo - 5; + else if( defNo >= 5 && defNo < 10 ) defNo2 = defNo - 5; + else defNo2 = -1; + + battleindex = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEINDEX ); + index2 = BATTLE_No2Index( battleindex, defNo2 ); + //DebugMainFunction="BATTLE_Battling_187"; + ContFlg = BATTLE_S_AttackDamage( battleindex, attackNo, defNo, BATTLE_COM_S_SONIC, skill ); + //DebugMainFunction="BATTLE_Battling_188"; + if( index2 >= 0 ){ + if( defNo2 >= 0 ){ + ContFlg = BATTLE_S_AttackDamage( battleindex, attackNo, defNo2, BATTLE_COM_S_SONIC2, skill ); + } + } + //DebugMainFunction="BATTLE_Battling_189"; + + } + break; +#endif + +#ifdef _PETSKILL_REGRET + case BATTLE_COM_S_REGRET: + { + int skill, defNo2=-1, index2=-1; + + if( (defNo = BATTLE_TargetAdjust( battleindex, charaindex, myside )) < 0 ){ + BATTLE_NoAction( battleindex, attackNo ); + //print("\n BATTLE_NoAction()"); + break; + } + skill = CHAR_GETWORKINT_LOW( charaindex, CHAR_WORKBATTLECOM3); + + if( defNo >= 15 && defNo < 20 ) defNo2 = defNo - 5; + else if( defNo >= 5 && defNo < 10 ) defNo2 = defNo - 5; + else defNo2 = -1; + + battleindex = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEINDEX ); + index2 = BATTLE_No2Index( battleindex, defNo2 ); + //DebugMainFunction="BATTLE_Battling_190"; + ContFlg = BATTLE_S_AttackDamage( battleindex, attackNo, defNo, BATTLE_COM_S_REGRET, skill ); + //DebugMainFunction="BATTLE_Battling_191"; + if( index2 >= 0 ){ + if( defNo2 >= 0 ){ + ContFlg = BATTLE_S_AttackDamage( battleindex, attackNo, defNo2, BATTLE_COM_S_REGRET2, skill ); + } + } + //DebugMainFunction="BATTLE_Battling_192"; + } + break; +#endif + +#ifdef _MAGIC_SUPERWALL + case BATTLE_COM_S_SUPERWALL: + { + int skill; + defNo = CHAR_getWorkInt(charaindex,CHAR_WORKBATTLECOM2); + skill = CHAR_GETWORKINT_LOW(charaindex,CHAR_WORKBATTLECOM3); + //DebugMainFunction="BATTLE_Battling_193"; + ContFlg = PETSKILL_MagicStatusChange_Battle( battleindex, attackNo, defNo, skill); + //DebugMainFunction="BATTLE_Battling_194"; + } + break; +#endif +#ifdef _PETSKILL_SETDUCK + case BATTLE_COM_S_SETDUCK: + { + int skill; + defNo = CHAR_getWorkInt(charaindex,CHAR_WORKBATTLECOM2); + skill = CHAR_GETWORKINT_LOW(charaindex,CHAR_WORKBATTLECOM3); + //DebugMainFunction="BATTLE_Battling_195"; + ContFlg = PETSKILL_SetDuckChange_Battle( battleindex, attackNo, defNo, skill); + //DebugMainFunction="BATTLE_Battling_196"; + break; + } +#endif +#ifdef _MAGICPET_SKILL + case BATTLE_COM_S_SETMAGICPET: + { + int skill; + defNo = CHAR_getWorkInt(charaindex,CHAR_WORKBATTLECOM2); + skill = CHAR_GETWORKINT_LOW(charaindex,CHAR_WORKBATTLECOM3); + //DebugMainFunction="BATTLE_Battling_197"; + ContFlg = PETSKILL_SetMagicPet_Battle( battleindex, attackNo, defNo, skill); + //DebugMainFunction="BATTLE_Battling_198"; + break; + } +#endif +#ifdef _OFFLINE_SYSTEM + case BATTLE_COM_S_OFFLINE_RECOVERY: + { + defNo = CHAR_getWorkInt(charaindex,CHAR_WORKBATTLECOM2); + int HP = CHAR_GETWORKINT_LOW(charaindex,CHAR_WORKBATTLECOM3); + ContFlg = OFFLINE_MultiRessurect( battleindex, attackNo, defNo, HP, 0); + break; + } +#endif +#ifdef _PRO_BATTLEENEMYSKILL + case BATTLE_COM_S_ENEMYRELIFE: + if( (defNo = BATTLE_TargetAdjust( battleindex, charaindex, myside )) < 0 ){ + BATTLE_NoAction( battleindex, attackNo ); + //print("\n BATTLE_NoAction()"); + break; + } + //DebugMainFunction="BATTLE_Battling_199"; + ContFlg =BATTLE_E_ENEMYREFILE( battleindex, attackNo, defNo, BATTLE_COM_S_ENEMYRELIFE); + //DebugMainFunction="BATTLE_Battling_200"; + if( ContFlg == FALSE ) { + CHAR_setFlg( charaindex, CHAR_ISATTACKED, 1 ); + ContFlg = BATTLE_Attack( battleindex, attackNo, defNo ); + BATTLE_AddProfit( battleindex, aAttackList ); + } + //DebugMainFunction="BATTLE_Battling_201"; + BATTLE_AddProfit( battleindex, aAttackList ); + //DebugMainFunction="BATTLE_Battling_202"; + break; + + case BATTLE_COM_S_ENEMYREHP: + if( (defNo = BATTLE_TargetAdjust( battleindex, charaindex, myside )) < 0 ){ + BATTLE_NoAction( battleindex, attackNo ); + //print("\n BATTLE_NoAction()"); + break; + } + //DebugMainFunction="BATTLE_Battling_203"; + ContFlg =BATTLE_E_ENEMYREHP( battleindex, attackNo, defNo, BATTLE_COM_S_ENEMYREHP); + //DebugMainFunction="BATTLE_Battling_204"; + if( ContFlg == FALSE ) { + CHAR_setFlg( charaindex, CHAR_ISATTACKED, 1 ); + ContFlg = BATTLE_Attack( battleindex, attackNo, defNo ); + BATTLE_AddProfit( battleindex, aAttackList ); + } + //DebugMainFunction="BATTLE_Battling_205"; + BATTLE_AddProfit( battleindex, aAttackList ); + //DebugMainFunction="BATTLE_Battling_206"; + break; + + case BATTLE_COM_S_ENEMYHELP: + if( (defNo = BATTLE_TargetAdjust( battleindex, charaindex, myside )) < 0 ){ + BATTLE_NoAction( battleindex, attackNo ); + //print("\n BATTLE_NoAction()"); + break; + } + //DebugMainFunction="BATTLE_Battling_207"; + ContFlg =BATTLE_E_ENEMYHELP( battleindex, attackNo, defNo, BATTLE_COM_S_ENEMYREHP); + //DebugMainFunction="BATTLE_Battling_208"; + if( ContFlg == FALSE ) { + CHAR_setFlg( charaindex, CHAR_ISATTACKED, 1 ); + ContFlg = BATTLE_Attack( battleindex, attackNo, defNo ); + BATTLE_AddProfit( battleindex, aAttackList ); + } + //DebugMainFunction="BATTLE_Battling_209"; + BATTLE_AddProfit( battleindex, aAttackList ); + //DebugMainFunction="BATTLE_Battling_210"; + break; +#endif + case BATTLE_COM_S_GBREAK: //Ƴ + + if( (defNo = BATTLE_TargetAdjust( battleindex, charaindex, myside )) < 0 ){ + BATTLE_NoAction( battleindex, attackNo ); + break; + } + //DebugMainFunction="BATTLE_Battling_211"; + ContFlg = BATTLE_S_GBreak( battleindex, attackNo, defNo ); + //DebugMainFunction="BATTLE_Battling_212"; + break; +#ifdef _SKILL_GUARDBREAK2//Ƴ2 vincent add 2002/05/20 + case BATTLE_COM_S_GBREAK2: + //ȷ + if( (defNo = BATTLE_TargetAdjust( battleindex, charaindex, myside )) < 0 ){ + BATTLE_NoAction( battleindex, attackNo ); + break; + } + //DebugMainFunction="BATTLE_Battling_213"; + ContFlg = BATTLE_S_GBreak2( battleindex, attackNo, defNo ); + //DebugMainFunction="BATTLE_Battling_214"; + break; +#endif + +#ifdef _SKILL_SACRIFICE + case BATTLE_COM_S_SACRIFICE://Ԯ vincent add 2002/05/30 + //ȷ + if( (defNo = BATTLE_TargetAdjust( battleindex, charaindex, myside )) < 0 ){ + BATTLE_NoAction( battleindex, attackNo ); + break; + } + //DebugMainFunction="BATTLE_Battling_215"; + ContFlg = BATTLE_S_Sacrifice( battleindex, attackNo, defNo ); + //DebugMainFunction="BATTLE_Battling_216"; + break; +#endif + +#ifdef _SKILL_REFRESH + case BATTLE_COM_S_REFRESH://״̬ظ vincent add 2002/08/08 + { + int array; + array = CHAR_GETWORKINT_LOW(charaindex,CHAR_WORKBATTLECOM3); + defNo = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM2 ); +// print("\n vincent--case BATTLE_COM_S_REFRESH:-->defNo:%d",defNo); + //DebugMainFunction="BATTLE_Battling_217"; + ContFlg = BATTLE_S_Refresh( battleindex, attackNo, defNo ,array); + //DebugMainFunction="BATTLE_Battling_218"; + } + break; +#endif + +#ifdef _SKILL_WEAKEN //vincent輼: + case BATTLE_COM_S_WEAKEN: + { + int array; + array = CHAR_GETWORKINT_LOW(charaindex,CHAR_WORKBATTLECOM3); + defNo = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM2 ); + //print("\n vincent--case BATTLE_COM_S_WEAKEN:-->defNo:%d",defNo); + //DebugMainFunction="BATTLE_Battling_219"; + ContFlg = BATTLE_S_Weaken( battleindex, attackNo, defNo ,array); + //DebugMainFunction="BATTLE_Battling_220"; + } + break; +#endif + +#ifdef _SKILL_DEEPPOISON //vincent輼:綾 + case BATTLE_COM_S_DEEPPOISON: + { + int array; + array = CHAR_GETWORKINT_LOW(charaindex,CHAR_WORKBATTLECOM3); + defNo = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM2 ); + // DebugMainFunction="BATTLE_Battling_221"; + ContFlg = BATTLE_S_Deeppoison( battleindex, attackNo, defNo ,array); + //DebugMainFunction="BATTLE_Battling_222"; + } + break; +#endif + +#ifdef _SKILL_BARRIER //vincent輼:ħ + case BATTLE_COM_S_BARRIER: + { + int array; + array = CHAR_GETWORKINT_LOW(charaindex,CHAR_WORKBATTLECOM3); + defNo = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM2 ); + //DebugMainFunction="BATTLE_Battling_223"; + ContFlg = BATTLE_S_Barrier( battleindex, attackNo, defNo ,array); + //DebugMainFunction="BATTLE_Battling_224"; + } + break; +#endif + +#ifdef _SKILL_NOCAST //vincent輼:Ĭ + case BATTLE_COM_S_NOCAST: + { + int array; + array = CHAR_GETWORKINT_LOW(charaindex,CHAR_WORKBATTLECOM3); + defNo = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM2 ); + //DebugMainFunction="BATTLE_Battling_225"; + ContFlg = BATTLE_S_Nocast( battleindex, attackNo, defNo ,array); + //DebugMainFunction="BATTLE_Battling_226"; + } + break; +#endif + +#ifdef _SKILL_ROAR //vincent輼: + case BATTLE_COM_S_ROAR: + { + int array; + //ȷ + if( (defNo = BATTLE_TargetAdjust( battleindex, charaindex, myside )) < 0 ){ + BATTLE_NoAction( battleindex, attackNo ); + break; + } + array = CHAR_GETWORKINT_LOW(charaindex,CHAR_WORKBATTLECOM3); + //DebugMainFunction="BATTLE_Battling_227"; + ContFlg = BATTLE_S_Roar( battleindex, attackNo, defNo ,array); + //DebugMainFunction="BATTLE_Battling_228"; + } + break; +#endif + case BATTLE_COM_S_ABDUCT: + { + int array; + if( (defNo = BATTLE_TargetAdjust( battleindex, charaindex, myside )) < 0 ){ + BATTLE_NoAction( battleindex, attackNo ); + break; + } + array = CHAR_GETWORKINT_LOW( charaindex, CHAR_WORKBATTLECOM3); + //DebugMainFunction="BATTLE_Battling_229"; + BATTLE_Abduct( battleindex, attackNo, defNo, array); + //DebugMainFunction="BATTLE_Battling_230"; + } + break; + case BATTLE_COM_COMBO: + if( (defNo = BATTLE_TargetAdjust( battleindex, charaindex, myside )) < 0 ){ + BATTLE_NoAction( battleindex, attackNo ); + break; + } + gDamageDiv = 1.0; + ComboId = EntryList[i].combo; + aAttackList[0] = EntryList[i].num; // + i ++; // ݼо + k = 1; + for( ; EntryList[i].combo == ComboId && i < entrynum; i ++ ){ + int charmode; + // ¾ + if( CHAR_CHECKINDEX( EntryList[i].charaindex ) == FALSE )continue; + + // 帨ƻئݳ + charmode = CHAR_getWorkInt( EntryList[i].charaindex, CHAR_WORKBATTLEMODE ); + if( charmode == 0 || charmode == BATTLE_CHARMODE_FINAL ){ + continue; + } + + // ټ + //DebugMainFunction="BATTLE_Battling_231"; + BATTLE_StatusSeq( EntryList[i].charaindex ); + //DebugMainFunction="BATTLE_Battling_232"; +#ifdef _OTHER_MAGICSTAUTS + BATTLE_MagicStatusSeq( EntryList[i].charaindex ); +#endif + //DebugMainFunction="BATTLE_Battling_233"; + // ئ + if( BATTLE_CanMoveCheck( EntryList[i].charaindex ) == FALSE ){ + continue; + } + if( CHAR_getInt( EntryList[i].charaindex, CHAR_HP ) <= 0 ){ + continue; + } + aAttackList[k++] = EntryList[i].num; + } + aAttackList[k] = -1; + i--; + if( k == 1 ){ + //print( "\nerr:һcombo bug\n" ); + } + //DebugMainFunction="BATTLE_Battling_234"; + sprintf( szWork, "BY|r%X|", defNo ); + //DebugMainFunction="BATTLE_Battling_235"; + BATTLESTR_ADD( szWork ); + //DebugMainFunction="BATTLE_Battling_236"; + BATTLE_Combo( battleindex, aAttackList, defNo ); + //DebugMainFunction="BATTLE_Battling_237"; +#ifdef _Item_ReLifeAct + BATTLE_AddProfit( battleindex, aAttackList ); +#endif + //DebugMainFunction="BATTLE_Battling_238"; + // FF ëȹ + BATTLESTR_ADD( "FF|" ); + //DebugMainFunction="BATTLE_Battling_239"; + break; + + //--------------------------------------------- + case BATTLE_COM_WAIT: + case BATTLE_COM_NONE: + BATTLE_NoAction( battleindex, attackNo ); + break; + + //--------------------------------------------- + case BATTLE_COM_S_EARTHROUND1: + //DebugMainFunction="BATTLE_Battling_240"; + BATTLE_EarthRoundHide( battleindex, attackNo ); + //DebugMainFunction="BATTLE_Battling_241"; + break; + + //--------------------------------------------- + case BATTLE_COM_S_LOSTESCAPE: + //DebugMainFunction="BATTLE_Battling_242"; + BATTLE_LostEscape( battleindex, attackNo ); + //DebugMainFunction="BATTLE_Battling_243"; + break; + + case BATTLE_COM_S_STEAL: + if( (defNo = BATTLE_TargetAdjust( battleindex, charaindex, myside )) < 0 ){ + BATTLE_NoAction( battleindex, attackNo ); + break; + } + //DebugMainFunction="BATTLE_Battling_244"; + BATTLE_Steal( battleindex, attackNo, defNo ); + //DebugMainFunction="BATTLE_Battling_245"; + break; + +#ifdef _BATTLESTEAL_FIX + case BATTLE_COM_S_STEALMONEY: + if( (defNo = BATTLE_TargetAdjust( battleindex, charaindex, myside )) < 0 ){ + BATTLE_NoAction( battleindex, attackNo ); + break; + } + //DebugMainFunction="BATTLE_Battling_246"; + BATTLE_StealMoney( battleindex, attackNo, defNo) ; + //DebugMainFunction="BATTLE_Battling_247"; + break; +#endif + case BATTLE_COM_S_NOGUARD: + BATTLE_NoAction( battleindex, attackNo ); + break; + case BATTLE_COM_S_CHARGE: + //DebugMainFunction="BATTLE_Battling_248"; + sprintf( szWork, "bt|%x|", attackNo ); + //DebugMainFunction="BATTLE_Battling_249"; + BATTLESTR_ADD( szWork ); + //DebugMainFunction="BATTLE_Battling_250"; + break; +#ifdef _PETSKILL_LER + case BATTLE_COM_S_BAT_FLY: + { + if((defNo = BATTLE_TargetAdjust(battleindex,charaindex,myside)) < 0){ + BATTLE_NoAction(battleindex,attackNo); + break; + } + //DebugMainFunction="BATTLE_Battling_251"; + BATTLE_BatFly(battleindex,attackNo,myside); + //DebugMainFunction="BATTLE_Battling_252"; + } + break; + case BATTLE_COM_S_DIVIDE_ATTACK: + { + if((defNo = BATTLE_TargetAdjust(battleindex,charaindex,myside)) < 0){ + BATTLE_NoAction(battleindex,attackNo); + break; + } + //DebugMainFunction="BATTLE_Battling_253"; + BATTLE_DivideAttack(battleindex,attackNo,myside); + //DebugMainFunction="BATTLE_Battling_254"; + } + break; +#endif +#ifdef _PETSKILL_BATTLE_MODEL + case BATTLE_COM_S_BATTLE_MODEL: + //DebugMainFunction="BATTLE_Battling_255"; + BATTLE_BattleModel(battleindex,attackNo,myside); + //DebugMainFunction="BATTLE_Battling_256"; + break; +#endif + //--------------------------------------------- + default: + //print( "\nerr:ֵ(%d:%d:%s)\n", charaindex, COM, + //CHAR_getUseName( charaindex ) ); + //DebugMainFunction="BATTLE_Battling_257"; + sprintf( szWork, "bg|%x|", attackNo ); + //DebugMainFunction="BATTLE_Battling_258"; + BATTLESTR_ADD( szWork ); + //DebugMainFunction="BATTLE_Battling_259"; + break; + } +#ifdef _VARY_WOLF + if(CHAR_getInt( charaindex, CHAR_BASEIMAGENUMBER)==101428) + { + if(CHAR_getWorkInt( charaindex, CHAR_WORKTURN)==0) + CHAR_setWorkInt( charaindex, CHAR_WORKTURN, 1); + else + CHAR_setWorkInt( charaindex, CHAR_WORKTURN, CHAR_getWorkInt( charaindex, CHAR_WORKTURN)+1); + + if(CHAR_getWorkInt( charaindex, CHAR_WORKTURN)>5) + { + CHAR_setInt( charaindex, CHAR_BASEIMAGENUMBER, CHAR_getInt( charaindex, CHAR_BASEBASEIMAGENUMBER)); + CHAR_setWorkInt( charaindex, CHAR_WORKATTACKPOWER, CHAR_getWorkInt( charaindex, CHAR_WORKFIXSTR)); + CHAR_setWorkInt( charaindex, CHAR_WORKQUICK, CHAR_getWorkInt( charaindex, CHAR_WORKFIXDEX)); + CHAR_setWorkInt( charaindex, CHAR_WORKTURN, 0); + } + } +#endif + if(CHAR_getWorkInt(charaindex,CHAR_WORKPETSKILLBT)==1){ + CHAR_setWorkInt(charaindex,CHAR_WORKPETSKILLBT,0); + } +//#ifdef _PETSKILL_NONO_FIX +// if(CHAR_getWorkInt(charaindex,CHAR_WORKLISTPAGE)==1 && CHAR_getInt(charaindex,CHAR_WHICHTYPE)==CHAR_TYPEPET){ +// CHAR_setWorkInt(charaindex,CHAR_WORKLISTPAGE,0); +// } +//#endif +#ifdef _WARNPC_CTRL + if(CHAR_getWorkInt(charaindex,CHAR_WORKNPCENEMYBATTLETIME)>0){ + time_t timep; + struct tm *p; + time(&timep); + p=localtime(&timep); /*ȡõʱ*/ + timep = mktime(p); + if(CHAR_getWorkInt(charaindex,CHAR_WORKNPCENEMYBATTLETIME)>=timep){ + CHAR_talkToCli( charaindex,-1,"ս",CHAR_COLORYELLOW); + CONNECT_setCloseRequest( getfdFromCharaIndex( charaindex ) , 1 ); + //CONNECT_endOne_debug(getfdFromCharaIndex(charaindex)); + //CHAR_setInt(charaindex,CHAR_MP,0); + } + if(CHAR_getWorkInt(charaindex,CHAR_WORKNPCENEMYBATTLETIME)==1) + CHAR_setWorkInt(charaindex,CHAR_WORKNPCENEMYBATTLETIME,timep+CHAR_getWorkInt(charaindex,CHAR_WORKNPCENEMYTIME)); + else + CHAR_setWorkInt(charaindex,CHAR_WORKNPCENEMYBATTLETIME,0); + } +#endif +#ifdef _PETSKILL_BECOMEFOX // жĻǷѵָĻغ + //if(CHAR_getInt( charaindex, CHAR_BASEIMAGENUMBER)==101749) //ͼжϵĻ,˱ʱ,ᱻԶĻȥ + if( CHAR_getWorkInt( charaindex, CHAR_WORKFOXROUND ) != -1 ) //DZС + { + if(CHAR_getInt( charaindex, CHAR_BASEIMAGENUMBER)!=101749) + CHAR_setInt( charaindex, CHAR_BASEIMAGENUMBER, 101749 ); + + if(pBattle->turn - CHAR_getWorkInt( charaindex, CHAR_WORKFOXROUND) > 2) + { + int defNo = BATTLE_Index2No( battleindex, charaindex ); + int toNo = defNo - 5;//˵ı + //print("\nظ:%s,round:%d", CHAR_getChar( charaindex, CHAR_NAME), CHAR_getWorkInt( charaindex, CHAR_WORKFOXROUND)); + + CHAR_setInt( charaindex, CHAR_BASEIMAGENUMBER, CHAR_getInt( charaindex, CHAR_BASEBASEIMAGENUMBER)); + + CHAR_setWorkInt( charaindex, CHAR_WORKATTACKPOWER, CHAR_getWorkInt( charaindex, CHAR_WORKFIXSTR)); + CHAR_setWorkInt( charaindex, CHAR_WORKDEFENCEPOWER, CHAR_getWorkInt( charaindex, CHAR_WORKFIXTOUGH)); + CHAR_setWorkInt( charaindex, CHAR_WORKQUICK, CHAR_getWorkInt( charaindex, CHAR_WORKFIXDEX)); + CHAR_setWorkInt( charaindex, CHAR_WORKFOXROUND, -1); + + //Change fix ظļ + //DebugMainFunction="BATTLE_Battling_260"; + sprintf( szWork, "W%d", CHAR_getInt( BATTLE_No2Index( battleindex, toNo ), CHAR_DEFAULTPET ) ); + //DebugMainFunction="BATTLE_Battling_261"; + CHAR_sendStatusString( BATTLE_No2Index( battleindex, toNo ), szWork ); + //DebugMainFunction="BATTLE_Battling_262"; + } + } +#endif +#ifdef _PETSKILL_BECOMEPIG + if( CHAR_getInt( charaindex, CHAR_BECOMEPIG) > -1 + && (CHAR_getInt( charaindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER) ) + { + char pigbuffer[128]; + CHAR_setInt( charaindex, CHAR_BASEIMAGENUMBER, CHAR_getInt( charaindex, CHAR_BECOMEPIG_BBI ) ); + if( CHAR_getInt( charaindex, CHAR_BECOMEPIG) > 0 ){ + sprintf(pigbuffer, "ʱ:%d", CHAR_getInt( charaindex, CHAR_BECOMEPIG )); + CHAR_talkToCli( charaindex,-1,pigbuffer,CHAR_COLORWHITE); + } + else{ + sprintf(pigbuffer, " ʱ뿪սɽ:%d ", CHAR_getInt( charaindex, CHAR_BECOMEPIG )); + CHAR_talkToCli( charaindex,-1,pigbuffer,CHAR_COLORWHITE); + } + } +#endif + +#ifdef _PROFESSION_ADDSKILL + { +/* for(i=0;i<20;i++){ + if( pBattle->ice_use[i] ){//׼ + print("\n׼"); + if( pBattle->ice_bout[i] > 0 ){// + print("\n"); + if( --pBattle->ice_bout[i] == 0 ){//ű + print("\nű"); + pBattle->ice_use[i] = FALSE; + if( CHAR_CHECKINDEX(pBattle->ice_charaindex[i]) ){ + int battlecom = CHAR_getWorkInt( pBattle->ice_charaindex[i], CHAR_WORKBATTLECOM1 ); + print("\n"); + print("\nbattlecom:%d",battlecom); + CHAR_setWorkInt( pBattle->ice_charaindex[i], CHAR_WORKBATTLECOM1, BATTLE_COM_S_ICE_CRACK ); + CHAR_SETWORKINT_HIGH( pBattle->ice_charaindex[i], CHAR_WORKBATTLECOM3, pBattle->ice_level[i] ); + CHAR_setWorkInt( pBattle->ice_charaindex[i], CHAR_WORKBATTLECOM2, pBattle->ice_toNo[i] ); + CHAR_SETWORKINT_HIGH( pBattle->ice_charaindex[i], CHAR_WORKBATTLECOM3, pBattle->ice_level[i] ); + CHAR_SETWORKINT_LOW( pBattle->ice_charaindex[i], CHAR_WORKBATTLECOM3, pBattle->ice_array[i] ); + battle_profession_attack_magic_fun(battleindex, pBattle->ice_attackNo[i], pBattle->ice_toNo[i], pBattle->ice_charaindex[i]); + CHAR_setWorkInt( pBattle->ice_charaindex[i], CHAR_WORKBATTLECOM1, battlecom ); + } + } + } + } + }*/ + } + { + int earth_boundary = GETHIGHVALUE( CHAR_getWorkInt( charaindex, CHAR_WORKFIXEARTHAT_BOUNDARY ) ); + int water_boundary = GETHIGHVALUE( CHAR_getWorkInt( charaindex, CHAR_WORKFIXWATERAT_BOUNDARY ) ); + int fire_boundary = GETHIGHVALUE( CHAR_getWorkInt( charaindex, CHAR_WORKFIXFIREAT_BOUNDARY ) ); + int wind_boundary = GETHIGHVALUE( CHAR_getWorkInt( charaindex, CHAR_WORKFIXWINDAT_BOUNDARY ) ); + int boundary_turn=0; + BOOL boundaryclear = FALSE; + if( earth_boundary > 0 ){//ؽ + //DebugMainFunction="BATTLE_Battling_263"; + boundary_turn = GETLOWVALUE( CHAR_getWorkInt( charaindex, CHAR_WORKFIXEARTHAT_BOUNDARY ) ) - 1; + //DebugMainFunction="BATTLE_Battling_264"; +// print("\n:%d ",boundary_turn ); + if( boundary_turn <= -1 ) + CHAR_setWorkInt( charaindex, CHAR_WORKFIXEARTHAT_BOUNDARY, 0 ),boundaryclear = TRUE; + else + CHAR_setWorkInt( charaindex, CHAR_WORKFIXEARTHAT_BOUNDARY, MAKE2VALUE(earth_boundary,boundary_turn) ); + + } + if( water_boundary > 0 ){//ˮ + //DebugMainFunction="BATTLE_Battling_265"; + boundary_turn = GETLOWVALUE( CHAR_getWorkInt( charaindex, CHAR_WORKFIXWATERAT_BOUNDARY ) ) - 1; + //DebugMainFunction="BATTLE_Battling_266"; +// print("\nˮ:%d ",boundary_turn ); + + if( boundary_turn <= -1 ) + CHAR_setWorkInt( charaindex, CHAR_WORKFIXWATERAT_BOUNDARY, 0 ),boundaryclear = TRUE; + else + CHAR_setWorkInt( charaindex, CHAR_WORKFIXWATERAT_BOUNDARY, MAKE2VALUE(water_boundary,boundary_turn) ); + //DebugMainFunction="BATTLE_Battling_267"; + } + if( fire_boundary > 0 ){// + //DebugMainFunction="BATTLE_Battling_268"; + boundary_turn = GETLOWVALUE( CHAR_getWorkInt( charaindex, CHAR_WORKFIXFIREAT_BOUNDARY ) ) - 1; +// print("\n:%d ",boundary_turn ); + //DebugMainFunction="BATTLE_Battling_269"; + if( boundary_turn <= -1 ) + CHAR_setWorkInt( charaindex, CHAR_WORKFIXFIREAT_BOUNDARY, 0 ),boundaryclear = TRUE; + else + CHAR_setWorkInt( charaindex, CHAR_WORKFIXFIREAT_BOUNDARY, MAKE2VALUE(fire_boundary,boundary_turn) ); + + } + if( wind_boundary > 0 ){// + //DebugMainFunction="BATTLE_Battling_270"; + boundary_turn = GETLOWVALUE( CHAR_getWorkInt( charaindex, CHAR_WORKFIXWINDAT_BOUNDARY ) ) - 1; +// print("\n:%d ",boundary_turn ); + //DebugMainFunction="BATTLE_Battling_271"; + if( boundary_turn <= -1 ) + CHAR_setWorkInt( charaindex, CHAR_WORKFIXWINDAT_BOUNDARY, 0 ),boundaryclear = TRUE; + else + CHAR_setWorkInt( charaindex, CHAR_WORKFIXWINDAT_BOUNDARY, MAKE2VALUE(wind_boundary,boundary_turn) ); + //DebugMainFunction="BATTLE_Battling_272"; + } + if( GETHIGHVALUE( CHAR_getWorkInt( charaindex, CHAR_WORKFIXEARTHAT_BOUNDARY ) ) == 0 + && GETHIGHVALUE( CHAR_getWorkInt( charaindex, CHAR_WORKFIXWATERAT_BOUNDARY ) ) == 0 + && GETHIGHVALUE( CHAR_getWorkInt( charaindex, CHAR_WORKFIXFIREAT_BOUNDARY ) ) == 0 + && GETHIGHVALUE( CHAR_getWorkInt( charaindex, CHAR_WORKFIXWINDAT_BOUNDARY ) ) == 0 + && boundaryclear ){ + int toNo = BATTLE_Index2No( battleindex, charaindex ); + if( toNo < 10 )//ҷ + snprintf( szWork, sizeof( szWork ), "Ba|%X|%X|", 0,1 ); + else + snprintf( szWork, sizeof( szWork ), "Ba|%X|%X|", 0,0 ); + //DebugMainFunction="BATTLE_Battling_273"; + BATTLESTR_ADD( szWork ); + //DebugMainFunction="BATTLE_Battling_274"; + BATTLESTR_ADD( "FF|" ); + //DebugMainFunction="BATTLE_Battling_275"; + } + } +#endif + +#ifdef _Item_ReLifeAct + { + //pEntry + int k, userindex=-1; + // if( BattleArray[ battleindex].type != BATTLE_TYPE_P_vs_P){ + for( k=0; k<20; k++) { + //DebugMainFunction="BATTLE_Battling_276"; + userindex = BATTLE_getBattleDieIndex( battleindex, k); + //DebugMainFunction="BATTLE_Battling_277"; + if( !CHAR_CHECKINDEX( userindex) ) continue; + //Change fix CHECK_ITEM_RELIFEм,ﲻ + //if( CHAR_getFlg( userindex, CHAR_ISDIE ) == FALSE ) + // continue; + if( CHAR_getInt( userindex, CHAR_HP) > 0 ) + continue; + if( CHAR_getInt( userindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER ) { + //DebugMainFunction="BATTLE_Battling_278"; + CHECK_ITEM_RELIFE( battleindex, userindex); + //DebugMainFunction="BATTLE_Battling_279"; + } +#ifdef _LOSE_FINCH_ + else if( CHAR_getInt( userindex, CHAR_WHICHTYPE ) == CHAR_TYPEPET ){ + //DebugMainFunction="BATTLE_Battling_280"; + CHECK_PET_RELIFE( battleindex, userindex); + //DebugMainFunction="BATTLE_Battling_281"; + } +#endif + } + } +#endif + //DebugMainFunction="BATTLE_Battling_282"; + BATTLESTR_ADD( szBadStatusString ); + //DebugMainFunction="BATTLE_Battling_283"; + BATTLE_AddProfit( battleindex, aAttackList );//ȡþֵ + //DebugMainFunction="BATTLE_Battling_284"; + len = pszBattleTop - szBattleString; + if( AllSize + len >= sizeof( szAllBattleString ) - 1 ){ + // ƥ׾ئ + }else{ + //DebugMainFunction="BATTLE_Battling_285"; + memcpy( szAllBattleString+AllSize, szBattleString, len ); + //DebugMainFunction="BATTLE_Battling_286"; + szAllBattleString[AllSize+len] = 0;// NULL ë + AllSize += len; + } + //DebugMainFunction="BATTLE_Battling_287"; + if( BATTLE_CountAlive( battleindex, 0 ) == 0 || BATTLE_CountAlive( battleindex, 1 ) == 0 ) { + break; + } + //DebugMainFunction="BATTLE_Battling_288"; + } +#ifdef _PETSKILL_LER + { + register int i,dieindex; + for(i=0;i<20;i++){ + dieindex = BATTLE_getBattleDieIndex(battleindex,i); + if(!CHAR_CHECKINDEX(dieindex)) continue; + if(CHAR_getFlg(dieindex,CHAR_ISDIE) == FALSE) continue; + if(CHAR_getInt(dieindex,CHAR_HP) > 0) continue; + // ׶, + if(CHAR_getInt(dieindex,CHAR_BASEBASEIMAGENUMBER) == 101813 || + CHAR_getInt(dieindex,CHAR_BASEBASEIMAGENUMBER) == 101814){ + //DebugMainFunction="BATTLE_Battling_289"; + BATTLE_LerChange(battleindex,dieindex,i); + //DebugMainFunction="BATTLE_Battling_290"; + } + } + } +#endif + + szBattleString[0] = 0; + pszBattleTop = szBattleString; + pszBattleLast = szBattleString+arraysizeof(szBattleString); + if( pBattle->field_att != BATTLE_ATTR_NONE ){ + pBattle->att_count--; + if( pBattle->att_count <= 0 ){ + pBattle->field_att = BATTLE_ATTR_NONE; + //snprintf( szBuffer, sizeof(szBuffer), + // "fieldظԡ" + //); + //BATTLE_BroadCast( battleindex, szBuffer, CHAR_COLORYELLOW ); + //DebugMainFunction="BATTLE_Battling_291"; + BATTLESTR_ADD( "BV|15|0|" ); + //DebugMainFunction="BATTLE_Battling_292"; + } + } + //DebugMainFunction="BATTLE_Battling_293"; + strncat( szAllBattleString, szBattleString, sizeof( szAllBattleString ) ); + //DebugMainFunction="BATTLE_Battling_294"; + for( i = 0; i < entrynum; i ++ ){ + charaindex = EntryList[i].charaindex; + if( CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE ) == BATTLE_CHARMODE_RESCUE ) + continue; + + if( BATTLE_CommandSend( charaindex, szAllBattleString ) == TRUE ){ + } + } + pWatchBattle = pBattle->pNext; + for( ; pWatchBattle ; pWatchBattle = pWatchBattle->pNext ){ + if( BATTLE_CHECKADDRESS( pWatchBattle ) == FALSE ){ + //print( "err:սbattle address(%p)\n", pWatchBattle ); + break; + } + for( i = 0; i < BATTLE_ENTRY_MAX; i ++ ){ + charaindex = pWatchBattle->Side[0].Entry[i].charaindex; + if( CHAR_CHECKINDEX( charaindex ) == FALSE )continue; + //DebugMainFunction="BATTLE_Battling_295"; + BATTLE_CommandSend( charaindex, szAllBattleString ); + //DebugMainFunction="BATTLE_Battling_296"; + } + pWatchBattle->mode = BATTLE_MODE_WATCHAFTER; + } + //DebugMainFunction="BATTLE_Battling_297"; + return 0; +} + +#ifdef _Item_ReLifeAct +BOOL CHECK_ITEM_RELIFE( int battleindex, int toindex) +{ + int i, itemindex; + CHAR_EquipPlace ep; + typedef void (*DIERELIFEFUNC)(int,int,int); + DIERELIFEFUNC Drf; + + if( CHAR_getInt( toindex, CHAR_HP) > 0 ) + return FALSE; + +#ifdef _DUMMYDIE + if( CHAR_getFlg( toindex, CHAR_ISDIE ) == FALSE && CHAR_getFlg( toindex, CHAR_ISDUMMYDIE ) == FALSE ) +#else + if( CHAR_getFlg( toindex, CHAR_ISDIE ) == FALSE ) +#endif + return FALSE; + + for( i = 0 ; i < 5 ; i++ ){ + itemindex = CHAR_getItemIndex( toindex , i ); + if( !ITEM_CHECKINDEX( itemindex)) + continue; + ep = ITEM_getEquipPlace( toindex, itemindex ); + if( ep == -1 ) + continue; + Drf=(DIERELIFEFUNC)ITEM_getFunctionPointer(itemindex, ITEM_DIERELIFEFUNC); + if( Drf ) { + Drf( toindex, itemindex, i); + return TRUE; + } +#ifdef _ALLBLUES_LUA_1_2 + else{ + if(RunItemDieReLifeEvent(toindex, itemindex, i) == TRUE) + return TRUE; + } +#endif + } + + return FALSE; + +} +#endif + +#ifdef _LOSE_FINCH_ +BOOL CHECK_PET_RELIFE( int battleindex, int petindex) +{ + int ReceveEffect=-1; + int toNo; + int attackNo=-1; + int WORK_HP=1; + int i; + struct _RePet{ + int petid; + int Effect; + int Addhp; +//Syu Mod +// }rePet[]={{1,SPR_fukkatu3,100},{-1,0,0}}; + }rePet[]={{-1,0,0}}; + + if( BATTLE_CHECKINDEX( battleindex ) == FALSE ) { + return FALSE; + } + if( CHAR_CHECKINDEX( petindex) == FALSE ) + return FALSE; + + if( CHAR_getFlg( petindex, CHAR_ISDIE) == FALSE ) { + //print("\n PET_RELIFE:[ %d, CHAR_ISDIE FALSE] return !", petindex); + return FALSE; + } + if( CHAR_getWorkInt( petindex, CHAR_WORKSPETRELIFE) != 0 ) + return FALSE; + for( i=0;iskill, SKILL_LEVEL); + skill_level = PROFESSION_CHANGE_SKILL_LEVEL_M( skill_level ); + + if( skill_level >= 6 ) add_practice = (skill_level-5) * 3 + 10; + else add_practice = skill_level * 2; + if( add_practice > 25 ) add_practice = 25; + + add_practice += old_practice; + // Ϊold_practice=0add_practiceΪ2~25 + + CHAR_setWorkInt( charaindex, CHAR_WORK_F_PROFICIENCY, add_practice ); + + }else + // + if( (strcmp( skill_name , "PROFESSION_ICE_PRACTICE" )) == 0 ){ + int old_practice = CHAR_getInt( charaindex, PROFESSION_ICE_P ); + int add_practice = 0; + int skill_level = 0; + + // ܵȼ + hskill = CHAR_getCharHaveSkill( charaindex, i ); + skill_level = SKILL_getInt( &hskill->skill, SKILL_LEVEL); + skill_level = PROFESSION_CHANGE_SKILL_LEVEL_M( skill_level ); + + if( skill_level >= 6 ) add_practice = (skill_level-5) * 3 + 10; + else add_practice = skill_level * 2; + if( add_practice > 25 ) add_practice = 25; + + add_practice += old_practice; + + CHAR_setWorkInt( charaindex, CHAR_WORK_I_PROFICIENCY, add_practice ); + + }else + // + if( (strcmp( skill_name , "PROFESSION_THUNDER_PRACTICE" )) == 0 ){ + int old_practice = CHAR_getInt( charaindex, PROFESSION_THUNDER_P ); + int add_practice = 0; + int skill_level = 0; + + // ܵȼ + hskill = CHAR_getCharHaveSkill( charaindex, i ); + skill_level = SKILL_getInt( &hskill->skill, SKILL_LEVEL); + skill_level = PROFESSION_CHANGE_SKILL_LEVEL_M( skill_level ); + + if( skill_level >= 6 ) add_practice = (skill_level-5) * 3 + 10; + else add_practice = skill_level * 2; + if( add_practice > 25 ) add_practice = 25; + + add_practice += old_practice; + + CHAR_setWorkInt( charaindex, CHAR_WORK_T_PROFICIENCY, add_practice ); + + }else + // ر + if( (strcmp( skill_name , "PROFESSION_AVOID" )) == 0 ){ + int skill_level = 0; + + if( profession_class != PROFESSION_SKILL_getInt( Pskillid, PROFESSION_SKILL_PROFESSION_CLASS) ) return; + + // ܵȼ + hskill = CHAR_getCharHaveSkill( charaindex, i ); + skill_level = SKILL_getInt( &hskill->skill, SKILL_LEVEL); + skill_level = PROFESSION_CHANGE_SKILL_LEVEL_A( skill_level ); + + if( skill_level <=5 ) + value = skill_level * 2; + else + value = (skill_level-5) * 3; + if( value > 25 ) value = 25; + + CHAR_setWorkInt( charaindex, CHAR_WORK_P_DUCK, 1); + CHAR_setWorkInt( charaindex, CHAR_WORKMOD_P_DUCK, value ); + + }else + // + if( (strcmp( skill_name , "PROFESSION_DEFLECT" )) == 0 ){ + int skill_level = 0; + int old_value = 0, add_value = 0; + + if( profession_class != PROFESSION_SKILL_getInt( Pskillid, PROFESSION_SKILL_PROFESSION_CLASS) ) return; + + // ܵȼ + hskill = CHAR_getCharHaveSkill( charaindex, i ); + skill_level = SKILL_getInt( &hskill->skill, SKILL_LEVEL); + skill_level = PROFESSION_CHANGE_SKILL_LEVEL_A( skill_level ); + + old_value = CHAR_getWorkInt( charaindex, CHAR_WORKFIXARRANGE ); + add_value = old_value + skill_level + 10; + + CHAR_setWorkInt( charaindex, CHAR_WORKFIXARRANGE, add_value ); + CHAR_complianceParameter( charaindex ); + + }else + // ר + if( (strcmp( skill_name , "PROFESSION_WEAPON_FOCUS" )) == 0 ){ + int skill_level = 0; + + rate = 0; + if( profession_class != PROFESSION_SKILL_getInt( Pskillid, PROFESSION_SKILL_PROFESSION_CLASS) ) continue; + + // ܵȼ + hskill = CHAR_getCharHaveSkill( charaindex, i ); + skill_level = SKILL_getInt( &hskill->skill, SKILL_LEVEL); + skill_level = PROFESSION_CHANGE_SKILL_LEVEL_A( skill_level ); + + // ܲ + pszOption = PROFESSION_SKILL_getChar( Pskillid, PROFESSION_SKILL_OPTION); + if( pszOption == "\0" ) continue; + + // װ + WeaponType = BATTLE_GetWepon( charaindex ); + + switch( WeaponType ){ + case ITEM_AXE: + if( (pszP=strstr( pszOption, "" ))!=NULL) rate = 1; break; + case ITEM_CLUB: + if( (pszP=strstr( pszOption, "" ))!=NULL) rate = 1; break; + case ITEM_SPEAR: + if( (pszP=strstr( pszOption, "ǹ" ))!=NULL) rate = 1; break; + case ITEM_BOW: + if( (pszP=strstr( pszOption, "" ))!=NULL) rate = 1; break; + case ITEM_BOOMERANG: // + if( (pszP=strstr( pszOption, "" ))!=NULL) rate = 1; break; + case ITEM_BOUNDTHROW: // Ͷͷ + if( (pszP=strstr( pszOption, "Ͷ" ))!=NULL) rate = 1; break; + case ITEM_BREAKTHROW: // Ͷʯ + if( (pszP=strstr( pszOption, "ʯ" ))!=NULL) rate = 1; break; + default: rate = 0; break; + } + + if( rate == 1 ){ + old_value = CHAR_getWorkInt( charaindex, CHAR_MYSKILLSTRPOWER); + + if( skill_level <=5 ) + value = skill_level * 2 + old_value; + else + value = (skill_level-5) * 3 + 10 + old_value; + + if( value > 25 ) value = 25; + + CHAR_setWorkInt( charaindex, CHAR_WORK_WEAPON, 1 ); + CHAR_setWorkInt( charaindex, CHAR_WORKMOD_WEAPON, value ); + } + } + } + } + return; +} + + +void BATTLE_ProfessionStatusSeq( int battleindex, int charaindex ) +{ + int profession_class=0, i=0, j=0, Pskillid=-1, skillid=-1; + int skill_level=0, value=0, old_value=0; + int bid=-1, hp=0, flag=0; + char *skill_name, szcommand[256]; + CHAR_HaveSkill* hskill; + + + int status_table[9]={ 2, // + 3, //˯ + 4, //ʯ + 12, //ѣ + 13, // + 14, // + 15, // + 17, // + 23, }; //׸ + +#ifdef _PETSKILL_DAMAGETOHP +/* { + char msg[32]={0}; + int pet,pindex; + pet = CHAR_getInt( charaindex, CHAR_DEFAULTPET ); + if( pet >= 0 ){ + sprintf( msg, "o%d", pet ); + //if(CHAR_getInt( petindex, CHAR_PETID) == "" //ID + // && CHAR_getInt( petindex, CHAR_HP) ) + CHAR_sendStatusString( charaindex, msg ); + pindex = CHAR_getCharPet( charaindex, pet ); + print("\n:%s",CHAR_getChar( pindex, CHAR_NAME)); + } + else + print("\޳"); + + } */ +#endif + + if ( CHAR_getInt( charaindex, CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER ) return; + + profession_class=CHAR_getInt( charaindex, PROFESSION_CLASS); + if( profession_class <= PROFESSION_CLASS_NONE ) return; + + for( i=0; i 0 ){ + flag=1; + break; + } + } + + if( flag > 0 ){ + // ܵȼ + hskill = CHAR_getCharHaveSkill( charaindex, i ); + skill_level = SKILL_getInt( &hskill->skill, SKILL_LEVEL); + skill_level = PROFESSION_CHANGE_SKILL_LEVEL_M( skill_level ); + + value = skill_level * 2; + if( value > 20 ) value = 20; + + old_value = CHAR_getWorkInt( charaindex, CHAR_WORKMAXHP); + + value = old_value * value / 100 ; + + hp = CHAR_getInt( charaindex, CHAR_HP); + + if( value + hp > old_value ) + value = old_value - hp; + + if( value < 0 ) value = 0; + + CHAR_setInt( charaindex, CHAR_HP, value + hp ); + + bid = BATTLE_Index2No( battleindex, charaindex ); + sprintf( szcommand, "BD|r%X|0|1|%X|", bid, value ); + BATTLESTR_ADD( szcommand ); + + PROFESSION_SKILL_LVEVEL_UP( charaindex, "PROFESSION_REBACK" ); + } + } + + // + if( (strcmp( skill_name , "PROFESSION_TRAP" )) == 0 ){ + int count=0; + + count = CHAR_getWorkInt( charaindex, CHAR_WORKTRAP); + if( count > 0 ){ + count--; + CHAR_setWorkInt( charaindex, CHAR_WORKTRAP, count ); + }else if( count == 0 ){ + CHAR_setWorkInt( charaindex, CHAR_WORKTRAP, 0 ); + CHAR_setWorkInt( charaindex, CHAR_WORKMODTRAP, 0 ); + } + } + } + + return; +} + +#endif + +#ifdef _FM_NPC_LOOK_WAR +int SearchFmWarRandIndex(int charaindex,int fmwarfloor) +{ + int i=1,j,fmwarindex; + int bindex[100]; + bindex[0]=-1; + for( j = 0; j < BATTLE_battlenum; j ++ ){ + if( BattleArray[j].use == FALSE ){ + continue; + }else{ + if(BattleArray[j].floor!=fmwarfloor){ + continue; + }else{ + bindex[i-1]=j; + i++; + continue; + } + } + } + if(bindex[0]>-1){ + fmwarindex = bindex[RAND(1,i)-1]; + if(BATTLE_CHECKINDEX(fmwarindex)==FALSE) + return -1; + else{ + if(BattleArray[fmwarindex].floor!=fmwarfloor) + return -1; + if(BATTLE_CreateForWatcher( charaindex, fmwarindex )==0){ + int fd; + if( ( fd = getfdFromCharaIndex(charaindex) ) != -1 ){ + lssproto_EN_send( fd, BattleArray[fmwarindex].type, BattleArray[fmwarindex].field_no ); + } + char szBuffer[256]; + sprintf( szBuffer, "BP|%X|%X|%X", + 20, BP_FLG_JOIN, CHAR_getInt(charaindex, CHAR_MP ) ); + BATTLE_CommandSend( charaindex, szBuffer ); + return 0; + } + } + } + return -1; +} + +char* SearchFmWar(int charaindex,int fmwarselect) +{ + int fmlistpage = CHAR_getWorkInt(charaindex,CHAR_WORKLISTPAGE); + int fmwarfloor = -1; + switch(fmwarselect){ + case 1: + fmwarfloor=1042; + break; + case 2: + fmwarfloor=2032; + break; + case 3: + fmwarfloor=3032; + break; + case 4: + fmwarfloor=4032; + break; + case 5: + fmwarfloor=20000; + break; + case 6: + fmwarfloor=51000; + break; + default: + break; + } + if(fmlistpage>0){ + if(fmwarfloor == 1042 && fmlistpage*6+1-6<=afmwarnum){ + int i=fmlistpage*6+1-6+1; + char fmwarbuff[1024]; + sprintf(fmwarbuff,"2\n ѡҪսĶ项\nӳơ֣ӡӳ"); + char name1[64],name2[64],newname1[64],fmwarindexbuf[32]; + memset(newname1, 0, sizeof(newname1)); + int fmwarindex = -1; + for(;i<=fmlistpage*6+1;i++){ + memset(newname1, 0, sizeof(newname1)); + if(getStringFromIndexWithDelim( afmwar, ",", i, fmwarindexbuf, sizeof(fmwarindexbuf))==FALSE) + break; + if(strlen(fmwarindexbuf)<1) + break; + fmwarindex = atoi(fmwarindexbuf); + strcpy(name1,BattleArray[fmwarindex].leadername); + strcpy(name2,BattleArray[fmwarindex].rivalname); + int namelen1 = strlen(name1); + int j; + for(j=0;j<16-namelen1;j++){ + if(j==0) + strcpy(newname1," "); + else + strcat(newname1," "); + } + if(strlen(newname1)<1) + sprintf(fmwarbuff,"%s\n%s ֣ %s",fmwarbuff,name1,name2); + else + sprintf(fmwarbuff,"%s\n%s%s ֣ %s",fmwarbuff,newname1,name1,name2); + } + return fmwarbuff; + }else if(fmwarfloor == 2032 && fmlistpage*6+1-6<=bfmwarnum){ + int i=fmlistpage*6+1-6+1; + char fmwarbuff[1024]; + sprintf(fmwarbuff,"2\n ѡҪսĶ项\nӳơ֣ӡӳ"); + char name1[64],name2[64],newname1[64],fmwarindexbuf[32]; + memset(newname1, 0, sizeof(newname1)); + int fmwarindex = -1; + for(;i<=fmlistpage*6+1;i++){ + memset(newname1, 0, sizeof(newname1)); + if(getStringFromIndexWithDelim( bfmwar, ",", i, fmwarindexbuf, sizeof(fmwarindexbuf))==FALSE) + break; + if(strlen(fmwarindexbuf)<1) + break; + fmwarindex = atoi(fmwarindexbuf); + strcpy(name1,BattleArray[fmwarindex].leadername); + strcpy(name2,BattleArray[fmwarindex].rivalname); + int namelen1 = strlen(name1); + int j; + for(j=0;j<16-namelen1;j++){ + if(j==0) + strcpy(newname1," "); + else + strcat(newname1," "); + } + if(strlen(newname1)<1) + sprintf(fmwarbuff,"%s\n%s ֣ %s",fmwarbuff,name1,name2); + else + sprintf(fmwarbuff,"%s\n%s%s ֣ %s",fmwarbuff,newname1,name1,name2); + } + return fmwarbuff; + }else if(fmwarfloor == 3032 && fmlistpage*6+1-6<=cfmwarnum){ + int i=fmlistpage*6+1-6+1; + char fmwarbuff[1024]; + sprintf(fmwarbuff,"2\n ѡҪսĶ项\nӳơ֣ӡӳ"); + char name1[64],name2[64],newname1[64],fmwarindexbuf[32]; + memset(newname1, 0, sizeof(newname1)); + int fmwarindex = -1; + for(;i<=fmlistpage*6+1;i++){ + memset(newname1, 0, sizeof(newname1)); + if(getStringFromIndexWithDelim( cfmwar, ",", i, fmwarindexbuf, sizeof(fmwarindexbuf))==FALSE) + break; + if(strlen(fmwarindexbuf)<1) + break; + fmwarindex = atoi(fmwarindexbuf); + strcpy(name1,BattleArray[fmwarindex].leadername); + strcpy(name2,BattleArray[fmwarindex].rivalname); + int namelen1 = strlen(name1); + int j; + for(j=0;j<16-namelen1;j++){ + if(j==0) + strcpy(newname1," "); + else + strcat(newname1," "); + } + if(strlen(newname1)<1) + sprintf(fmwarbuff,"%s\n%s ֣ %s",fmwarbuff,name1,name2); + else + sprintf(fmwarbuff,"%s\n%s%s ֣ %s",fmwarbuff,newname1,name1,name2); + } + return fmwarbuff; + }else if(fmwarfloor == 4032 && fmlistpage*6+1-6<=dfmwarnum){ + int i=fmlistpage*6+1-6+1; + char fmwarbuff[1024]; + sprintf(fmwarbuff,"2\n ѡҪսĶ项\nӳơ֣ӡӳ"); + char name1[64],name2[64],newname1[64],fmwarindexbuf[32]; + memset(newname1, 0, sizeof(newname1)); + int fmwarindex = -1; + for(;i<=fmlistpage*6+1;i++){ + memset(newname1, 0, sizeof(newname1)); + if(getStringFromIndexWithDelim( dfmwar, ",", i, fmwarindexbuf, sizeof(fmwarindexbuf))==FALSE) + break; + if(strlen(fmwarindexbuf)<1) + break; + fmwarindex = atoi(fmwarindexbuf); + strcpy(name1,BattleArray[fmwarindex].leadername); + strcpy(name2,BattleArray[fmwarindex].rivalname); + int namelen1 = strlen(name1); + int j; + for(j=0;j<16-namelen1;j++){ + if(j==0) + strcpy(newname1," "); + else + strcat(newname1," "); + } + if(strlen(newname1)<1) + sprintf(fmwarbuff,"%s\n%s ֣ %s",fmwarbuff,name1,name2); + else + sprintf(fmwarbuff,"%s\n%s%s ֣ %s",fmwarbuff,newname1,name1,name2); + } + return fmwarbuff; + }else if(fmwarfloor == 20000 && fmlistpage*6+1-6<=efmwarnum){ + int i=fmlistpage*6+1-6+1; + char fmwarbuff[1024]; + sprintf(fmwarbuff,"2\n ѡҪսĶ项\nӳơ֣ӡӳ"); + char name1[64],name2[64],newname1[64],fmwarindexbuf[32]; + memset(newname1, 0, sizeof(newname1)); + int fmwarindex = -1; + for(;i<=fmlistpage*6+1;i++){ + memset(newname1, 0, sizeof(newname1)); + if(getStringFromIndexWithDelim( efmwar, ",", i, fmwarindexbuf, sizeof(fmwarindexbuf))==FALSE) + break; + if(strlen(fmwarindexbuf)<1) + break; + fmwarindex = atoi(fmwarindexbuf); + strcpy(name1,BattleArray[fmwarindex].leadername); + strcpy(name2,BattleArray[fmwarindex].rivalname); + int namelen1 = strlen(name1); + int j; + for(j=0;j<16-namelen1;j++){ + if(j==0) + strcpy(newname1," "); + else + strcat(newname1," "); + } + if(strlen(newname1)<1) + sprintf(fmwarbuff,"%s\n%s ֣ %s",fmwarbuff,name1,name2); + else + sprintf(fmwarbuff,"%s\n%s%s ֣ %s",fmwarbuff,newname1,name1,name2); + } + return fmwarbuff; + }else if(fmwarfloor == 51000 && fmlistpage*6+1-6<=ffmwarnum){ + int i=fmlistpage*6+1-6+1; + char fmwarbuff[1024]; + sprintf(fmwarbuff,"2\n ѡҪսĶ项\nӳơ֣ӡӳ"); + char name1[64],name2[64],newname1[64],fmwarindexbuf[32]; + memset(newname1, 0, sizeof(newname1)); + int fmwarindex = -1; + for(;i<=fmlistpage*6+1;i++){ + memset(newname1, 0, sizeof(newname1)); + if(getStringFromIndexWithDelim( ffmwar, ",", i, fmwarindexbuf, sizeof(fmwarindexbuf))==FALSE) + break; + if(strlen(fmwarindexbuf)<1) + break; + fmwarindex = atoi(fmwarindexbuf); + strcpy(name1,BattleArray[fmwarindex].leadername); + strcpy(name2,BattleArray[fmwarindex].rivalname); + int namelen1 = strlen(name1); + int j; + for(j=0;j<16-namelen1;j++){ + if(j==0) + strcpy(newname1," "); + else + strcat(newname1," "); + } + if(strlen(newname1)<1) + sprintf(fmwarbuff,"%s\n%s ֣ %s",fmwarbuff,name1,name2); + else + sprintf(fmwarbuff,"%s\n%s%s ֣ %s",fmwarbuff,newname1,name1,name2); + } + return fmwarbuff; + } + } + return "err"; +} + +int LookFmWarIndex(int charaindex,int fmwarselect) +{ + int listselect = CHAR_getWorkInt(charaindex,CHAR_WORKLISTSELECT); + if(listselect<1 || listselect>6) + return -1; + int fmwarindex = -1; + char fmwarindexbuf[64]; + if(listselect == 1){ + if(getStringFromIndexWithDelim( afmwar, ",", CHAR_getWorkInt(charaindex,CHAR_WORKLISTPAGE)*6+1-6+fmwarselect, fmwarindexbuf, sizeof(fmwarindexbuf))==FALSE) + return -1; + fmwarindex = atoi(fmwarindexbuf); + }else if(listselect == 2){ + if(getStringFromIndexWithDelim( bfmwar, ",", CHAR_getWorkInt(charaindex,CHAR_WORKLISTPAGE)*6+1-6+fmwarselect, fmwarindexbuf, sizeof(fmwarindexbuf))==FALSE) + return -1; + fmwarindex = atoi(fmwarindexbuf); + }else if(listselect == 3){ + if(getStringFromIndexWithDelim( cfmwar, ",", CHAR_getWorkInt(charaindex,CHAR_WORKLISTPAGE)*6+1-6+fmwarselect, fmwarindexbuf, sizeof(fmwarindexbuf))==FALSE) + return -1; + fmwarindex = atoi(fmwarindexbuf); + }else if(listselect == 4){ + if(getStringFromIndexWithDelim( dfmwar, ",", CHAR_getWorkInt(charaindex,CHAR_WORKLISTPAGE)*6+1-6+fmwarselect, fmwarindexbuf, sizeof(fmwarindexbuf))==FALSE) + return -1; + fmwarindex = atoi(fmwarindexbuf); + }else if(listselect == 5){ + if(getStringFromIndexWithDelim( efmwar, ",", CHAR_getWorkInt(charaindex,CHAR_WORKLISTPAGE)*6+1-6+fmwarselect, fmwarindexbuf, sizeof(fmwarindexbuf))==FALSE) + return -1; + fmwarindex = atoi(fmwarindexbuf); + }else if(listselect == 6){ + if(getStringFromIndexWithDelim( ffmwar, ",", CHAR_getWorkInt(charaindex,CHAR_WORKLISTPAGE)*6+1-6+fmwarselect, fmwarindexbuf, sizeof(fmwarindexbuf))==FALSE) + return -1; + fmwarindex = atoi(fmwarindexbuf); + } + + if(BATTLE_CHECKINDEX(fmwarindex)==FALSE) + return -1; + if(BATTLE_CreateForWatcher( charaindex, fmwarindex )==0){ + int fd; + if( ( fd = getfdFromCharaIndex(charaindex) ) != -1 ){ + lssproto_EN_send( fd, BattleArray[fmwarindex].type, BattleArray[fmwarindex].field_no ); + } + char szBuffer[256]; + sprintf( szBuffer, "BP|%X|%X|%X", + 20, BP_FLG_JOIN, CHAR_getInt(charaindex, CHAR_MP ) ); + BATTLE_CommandSend( charaindex, szBuffer ); + return 0; + } + return -1; +} +#endif + +#ifdef _ALLBLUES_LUA_1_4 +INLINE BOOL BATTLE_setLUAFunction( int battleindex, int functype, lua_State *L, const char *luafunctable) +{ + if( !BATTLE_CHECKINDEX(battleindex) )return FALSE; + + if( functype < 0 || functype >= BATTLE_FUNCTABLENUM )return FALSE; + + BattleArray[battleindex].lua[functype] = L; + BattleArray[battleindex].luafunctable[functype] = allocateMemory( strlen(luafunctable) ); + memset(BattleArray[battleindex].luafunctable[functype], 0, strlen(luafunctable)); + strcpy(BattleArray[battleindex].luafunctable[functype], luafunctable); + + return TRUE; +} + +INLINE lua_State *BATTLE_getLUAFunction( int battleindex, int functype) +{ + + if( !BATTLE_CHECKINDEX(battleindex) )return NULL; + + if( functype < 0 || functype >= BATTLE_FUNCTABLENUM ) + return NULL; + + if(BattleArray[battleindex].lua[functype] == NULL){ + return NULL; + } + + lua_getglobal( BattleArray[battleindex].lua[functype], BattleArray[battleindex].luafunctable[functype]); + return BattleArray[battleindex].lua[functype]; +} +#endif + +int BATTLE_getType( int battleindex ) +{ + if(battleindex>=BATTLE_battlenum || battleindex<0 )return -1; + + return BattleArray[battleindex].type; +} + +#ifdef _BATTLE_TIMESPEED +int BATTLE_getCreateTime( int battleindex ) +{ + if(battleindex>=BATTLE_battlenum || battleindex<0 )return -1; + + return BattleArray[battleindex].CreateTime; +} +#endif + +int BATTLE_getBattleFloor( int battleindex ) +{ + if(battleindex>=BATTLE_battlenum || battleindex<0 )return -1; + + return BattleArray[battleindex].BattleFloor; +} + + + +void Enemy_setStayLoop(int charaindex) +{ + int fd = getfdFromCharaIndex( charaindex ); + setStayEncount(fd); + { + Char *ch; + ch = CHAR_getCharPointer( charaindex); + if( ch == NULL ) return; + strcpysafe( ch->charfunctable[CHAR_LOOPFUNCTEMP1].string, + sizeof( ch->charfunctable[CHAR_LOOPFUNCTEMP1]), "CHAR_BattleStayLoop");//ս + CHAR_setInt( charaindex, CHAR_LOOPINTERVAL, getOfflineBattleTime()); + CHAR_constructFunctable( charaindex); + } +} diff --git a/battle/battle_ai.c b/battle/battle_ai.c new file mode 100644 index 0000000..4795efc --- /dev/null +++ b/battle/battle_ai.c @@ -0,0 +1,533 @@ +#include "version.h" +#include +#include "common.h" +#include "char.h" +#include "char_base.h" +#include "battle.h" +#include "npcutil.h" +#include "pet_skill.h" + +struct B_AI_RESULT { + BATTLE_COM command; /* ë¾ */ + int target; /* */ +}; + +static int BATTLE_ai_normal( int, int, BATTLE_ENTRY *,struct B_AI_RESULT *); + +static int (*functbl[])( int, int, BATTLE_ENTRY *,struct B_AI_RESULT *) = { + NULL, + BATTLE_ai_normal, +}; + +int BATTLE_ai_all( int battleindex, int side, int turn) +{ + int i; + int rc = FALSE; + BATTLE_ENTRY *pEntry; + struct B_AI_RESULT result; + + if( BATTLE_CHECKINDEX( battleindex ) == FALSE )return BATTLE_ERR_BATTLEINDEX; + if( BATTLE_CHECKSIDE( side ) == FALSE )return BATTLE_ERR_PARAM; + if( BATTLE_CHECKSIDE( side ^1) == FALSE )return BATTLE_ERR_PARAM; + if( BattleArray[battleindex].Side[side].type != BATTLE_S_TYPE_ENEMY ) return FALSE; + pEntry = BattleArray[battleindex].Side[side^1].Entry; + for( i = 0; i < BATTLE_ENTRY_MAX; i ++ ){ + int charaindex = BattleArray[battleindex].Side[side].Entry[i].charaindex; + int mode; + if( CHAR_CHECKINDEX( charaindex ) == FALSE )continue; + + mode = CHAR_getWorkInt( charaindex, CHAR_WORKTACTICS); + if( mode < 0 || mode >= arraysizeof( functbl)){ + //print( "BATTLE_ai_all ,ս߼ģʽ(%s)(%d)\n", + //CHAR_getUseName( charaindex ), mode ); + mode = 1; + } + if( BATTLE_IsCharge( charaindex ) == TRUE ){ + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + continue; + } + if( BattleArray[battleindex].Side[side].flg & BSIDE_FLG_SURPRISE) { + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_NONE ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + }else { + if( functbl[mode] != NULL ) { + rc = functbl[mode]( turn, charaindex, pEntry, &result); + if( BATTLE_CanMoveCheck( charaindex ) == FALSE ){ + result.command = BATTLE_COM_NONE; + } + } + if( rc ) { +#ifdef _BATTLENPC_WARP_PLAYER + if(result.command==BATTLE_COM_WARP){ + for( i=0; icharaindex; + if( !CHAR_CHECKINDEX( tindex ))continue; + if( CHAR_getFlg( tindex, CHAR_ISDIE)) continue; + if( CHAR_getWorkInt( tindex, CHAR_WORKBATTLEMODE) + == BATTLE_CHARMODE_RESCUE ) continue; + if( CHAR_getInt( tindex, CHAR_WHICHTYPE)==CHAR_TYPEPLAYER){ + char sBuff[1024]="", sBuff1[1024]=""; + int ss[3]; + int sii; + int rc = 1; + if( NPC_Util_GetStrFromStrWithDelim( CHAR_getWorkChar( charaindex, CHAR_WORKBATTLE_ACT_CONDITION), + "wp", sBuff, sizeof( sBuff))!=NULL){ + for( sii=1; sii<=3; sii++){ + if(getStringFromIndexWithDelim( sBuff, ";", sii, sBuff1, sizeof( sBuff1))) + {ss[sii-1]=atoi(sBuff1);} + else + {rc=0;} + } + if(rc){ + CHAR_warpToSpecificPoint( tindex, ss[0], ss[1], ss[2]); + BATTLE_WatchStop( tindex); + } + } + } + } + } +#endif + + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, result.command ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, + result.target + (side^1)*SIDE_OFFSET); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + //CHAR_SETWORKINT_LOW( charaindex, CHAR_WORKBATTLECOM3, array); + + } + } + } + return TRUE; +} + +int BATTLE_ai_one( int charaindex, int battleindex, int side, int turn) +{ + int rc = FALSE; + BATTLE_ENTRY *pEntry; + struct B_AI_RESULT result; + int mode; + + /* ɷ¶ */ + if( BATTLE_CHECKINDEX( battleindex ) == FALSE )return BATTLE_ERR_BATTLEINDEX; + if( BATTLE_CHECKSIDE( side ) == FALSE )return BATTLE_ERR_PARAM; + if( BATTLE_CHECKSIDE( side ^1) == FALSE )return BATTLE_ERR_PARAM; + + /* 浤 */ + /* ƽҷ¶½ */ + if( BattleArray[battleindex].Side[side].type != BATTLE_S_TYPE_ENEMY ) return 0; + + /* */ + pEntry = BattleArray[battleindex].Side[side^1].Entry; + + mode = CHAR_getWorkInt( charaindex, CHAR_WORKTACTICS); + /* ëԻ */ + if( mode < 0 || mode >= arraysizeof( functbl)) return FALSE; + /* ëԻ */ + if( functbl[mode] != NULL ) { + rc = functbl[mode]( turn, charaindex, pEntry, &result); + } + if( rc ) { + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, result.command ); + if( result.command == BATTLE_COM_ATTACK) { + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, + result.target + (side^1)*SIDE_OFFSET); + } + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + } + return TRUE; +} + +/* ɧë裻 */ + +#define B_AI_NORMAL_ATTACKOPTION "at" /* */ +#define B_AI_NORMAL_GUARDOPTION "gu" /* */ +#define B_AI_NORMAL_MAGICOPTION "ma" /* */ +#define B_AI_NORMAL_ESCAPEOPTION "es" /* */ +#define B_AI_NORMAL_WAZAOPTION "wa" /* */ +#ifdef _ENEMY_ATTACK_AI +#define B_AI_NORMAL_RANDAOPTION "rn" +#define B_AI_NORMAL_RANDOMOPTIONNUM 1 +#endif + +#define B_AI_NORMAL_ATTACKSUBOPTIONNUM 3 +#define B_AI_NORMAL_GUARDSUBOPTIONNUM 1 +#define B_AI_NORMAL_MAGICSUBOPTIONNUM 1 +#define B_AI_NORMAL_ESCAPESUBOPTIONNUM 1 +#define B_AI_NORMAL_WAZASUBOPTIONNUM 7 + +/* ¦Ѽ ٯ */ +#define B_AI_NORMAL_TARGET_ALL 1 +#define B_AI_NORMAL_TARGET_PLAYER 2 +#define B_AI_NORMAL_TARGET_PET 3 +#ifdef _ENEMY_ATTACK_AI +#define B_AI_NORMAL_TARGET_LEADER 4 +#endif +#define B_AI_NORMAL_SELECT_RANDOM 1 +#define B_AI_NORMAL_SELECT_HP_MAX 2 +#define B_AI_NORMAL_SELECT_HP_MIN 3 +#ifdef _ENEMY_ATTACK_AI +#define B_AI_NORMAL_SELECT_STR_MAX 4 +#define B_AI_NORMAL_SELECT_DEX_MAX 5 +#define B_AI_NORMAL_SELECT_DEX_MIN 6 +#define B_AI_NORMAL_SELECT_ATT_SUBDUE 7 +enum{ + AI_ATT_EARTHAT = 1, + AI_ATT_WATERAT, + AI_ATT_FIREAT, + AI_ATT_WINDAT +}; +int GetSubdueAttribute(int index){ + int s_a = CHAR_getWorkInt( index, CHAR_WORKFIXEARTHAT); + int s_b = CHAR_getWorkInt( index, CHAR_WORKFIXWATERAT); + int s_c = CHAR_getWorkInt( index, CHAR_WORKFIXFIREAT); + int s_d = CHAR_getWorkInt( index, CHAR_WORKFIXWINDAT); + return ((s_a>s_c)?((s_b>s_d)?((s_a>s_b)?(2):(3)):((s_a>s_d)?(2):(1))):((s_b>s_d)?((s_c>s_b)?(4):(3)):((s_c>s_d)?(4):(1)))); +} +#endif + +typedef enum { + B_AI_ATTACKMODE = 1, + B_AI_GURADMODE, + B_AI_MAGICMODE, + B_AI_ESCAPEMODE, + B_AI_WAZAMODE0, + B_AI_WAZAMODE1, + B_AI_WAZAMODE2, + B_AI_WAZAMODE3, + B_AI_WAZAMODE4, + B_AI_WAZAMODE5, + B_AI_WAZAMODE6, +}B_AI_MODE; + +static int BATTLE_ai_normal( int turn, int charaindex, + BATTLE_ENTRY *pEntry, + struct B_AI_RESULT *result) +{ + int at[B_AI_NORMAL_ATTACKSUBOPTIONNUM] = { 0,0,0}; /* */ + int gu[B_AI_NORMAL_GUARDSUBOPTIONNUM] = {0}; /* */ + int ma[B_AI_NORMAL_MAGICSUBOPTIONNUM] = {0}; /* */ + int es[B_AI_NORMAL_ESCAPESUBOPTIONNUM] = {0}; /* */ + int wa[B_AI_NORMAL_WAZASUBOPTIONNUM] = {0,0,0,0, 0,0,0};/* */ +#ifdef _ENEMY_ATTACK_AI + int rn[B_AI_NORMAL_RANDOMOPTIONNUM] = {1}; +#endif + int target[BATTLE_ENTRY_MAX]; + int cnt; + int i; + int r; + int rc; + int mode=0; + char buff[256]; + char buff2[256]; + + if( turn == 1 ) { + //print( "Ӧû¡\n" ); + return FALSE; + } + if( NPC_Util_GetStrFromStrWithDelim( CHAR_getWorkChar( charaindex, CHAR_WORKBATTLE_TACTICSOPTION), + B_AI_NORMAL_ATTACKOPTION, buff, sizeof( buff)) != NULL ){ + for( i = 1; i < B_AI_NORMAL_ATTACKSUBOPTIONNUM + 1; i ++ ) { + rc = getStringFromIndexWithDelim( buff, ";", i, buff2, sizeof( buff2)); + if( rc != TRUE ) { + //print( "battle_ai.c:Invarid Param [%s]\n", + //CHAR_getWorkChar( charaindex, CHAR_WORKBATTLE_TACTICSOPTION)); + return FALSE; + } + at[i-1] = atoi( buff2); + } + } + + if( NPC_Util_GetStrFromStrWithDelim( CHAR_getWorkChar( charaindex, CHAR_WORKBATTLE_TACTICSOPTION), + B_AI_NORMAL_GUARDOPTION, buff, sizeof( buff)) != NULL ){ + for( i = 1; i < B_AI_NORMAL_GUARDSUBOPTIONNUM + 1; i ++ ) { + rc = getStringFromIndexWithDelim( buff, ";", i, buff2, sizeof( buff2)); + if( rc != TRUE ) { + //print( "battle_ai.c:Invarid Param [%s]\n", + //CHAR_getWorkChar( charaindex, CHAR_WORKBATTLE_TACTICSOPTION)); + return FALSE; + } + gu[i-1] = atoi( buff2); + } + } + if( NPC_Util_GetStrFromStrWithDelim( CHAR_getWorkChar( charaindex, CHAR_WORKBATTLE_TACTICSOPTION), + B_AI_NORMAL_MAGICOPTION, + buff, sizeof( buff)) != NULL ){ + for( i = 1; i < B_AI_NORMAL_MAGICSUBOPTIONNUM + 1; i ++ ) { + rc = getStringFromIndexWithDelim( buff, ";", i, buff2, sizeof( buff2)); + if( rc != TRUE ) { + //print( "battle_ai.c:Invarid Param [%s]\n", + //CHAR_getWorkChar( charaindex, CHAR_WORKBATTLE_TACTICSOPTION)); + return FALSE; + } + ma[i-1] = atoi( buff2); + + } + } + if( NPC_Util_GetStrFromStrWithDelim( CHAR_getWorkChar( charaindex, CHAR_WORKBATTLE_TACTICSOPTION), + B_AI_NORMAL_ESCAPEOPTION, + buff, sizeof( buff)) != NULL ){ + for( i = 1; i < B_AI_NORMAL_ESCAPESUBOPTIONNUM + 1; i ++ ) { + rc = getStringFromIndexWithDelim( buff, ";", i, buff2, sizeof( buff2)); + + if( rc != TRUE ) { + //print( "battle_ai.c:Invarid Param [%s]\n", + //CHAR_getWorkChar( charaindex, CHAR_WORKBATTLE_TACTICSOPTION)); + return FALSE; + } + es[i-1] = atoi( buff2); + } + } + if( NPC_Util_GetStrFromStrWithDelim( CHAR_getWorkChar( charaindex, CHAR_WORKBATTLE_TACTICSOPTION), + B_AI_NORMAL_WAZAOPTION, + buff, sizeof( buff)) != NULL ){ + for( i = 1; i < B_AI_NORMAL_WAZASUBOPTIONNUM + 1; i ++ ) { + rc = getStringFromIndexWithDelim( buff, ";", i, buff2, sizeof( buff2)); + if( rc != TRUE ) { + }else{ + wa[i-1] = atoi( buff2); + } + } + } +#ifdef _ENEMY_ATTACK_AI + if( NPC_Util_GetStrFromStrWithDelim( CHAR_getWorkChar( charaindex, CHAR_WORKBATTLE_TACTICSOPTION), + B_AI_NORMAL_RANDAOPTION, + buff, sizeof( buff))!=NULL){ + for( i=1; icommand = BATTLE_COM_WARP; + return TRUE; + } + } +#endif + if( at[0] == 0 && gu[0] == 0 && ma[0] == 0 && es[0] == 0 ){ + for( i = 0; i < B_AI_NORMAL_WAZASUBOPTIONNUM; i ++ ){ + if( wa[i] != 0 )break; + } + if( i >= B_AI_NORMAL_WAZASUBOPTIONNUM ){ + //print( "ָκεĹʽ\n" ); + return FALSE; + } + } + while( !mode ) { + int work = 0; + work = at[0]+gu[0]+ma[0]+es[0]; + for( i = 0; i < B_AI_NORMAL_WAZASUBOPTIONNUM; i ++ ){ + work += wa[i]; + } + r = RAND( 0, work - 1 ); + if( at[0] != 0 && r < at[0] ) mode = B_AI_ATTACKMODE; + else if( gu[0] != 0 && r < at[0] + gu[0]) mode = B_AI_GURADMODE; + else if( ma[0] != 0 && r < at[0] + gu[0] + ma[0]) mode = B_AI_MAGICMODE; + else if( es[0] != 0 && r < at[0] + gu[0] + ma[0] + es[0] ){ + mode = B_AI_ESCAPEMODE; + } + if( mode ) break; + work = at[0] + gu[0] + ma[0] + es[0]; + for( i = 0; i < B_AI_NORMAL_WAZASUBOPTIONNUM; i ++ ){ + work += wa[i]; + if( wa[i] != 0 && r < work ){ + mode = B_AI_WAZAMODE0+i; + break; + } + } + } + if( mode == B_AI_ATTACKMODE || ( B_AI_WAZAMODE0 <= mode && mode <= B_AI_WAZAMODE6 )){ + while( 1 ) { + for( i = 0 ; i < BATTLE_ENTRY_MAX; i ++ ) { + target[i] = -1; + } + cnt = 0; + for( i = 0; i < BATTLE_ENTRY_MAX ; i ++ ) { + int tindex = (pEntry+i)->charaindex; + if( !CHAR_CHECKINDEX( tindex ))continue; + if( CHAR_getFlg( tindex, CHAR_ISDIE)) continue; + if( CHAR_getWorkInt( tindex, CHAR_WORKBATTLEMODE) == BATTLE_CHARMODE_RESCUE ) continue; + switch( at[1]) { + case B_AI_NORMAL_TARGET_PLAYER: + if( CHAR_getInt( tindex, CHAR_WHICHTYPE) == CHAR_TYPEPLAYER ){ + target[cnt++] = i; + } + break; + case B_AI_NORMAL_TARGET_PET: + if( CHAR_getInt( tindex, CHAR_WHICHTYPE) == CHAR_TYPEPET){ + target[cnt++] = i; + } + break; +#ifdef _ENEMY_ATTACK_AI + case B_AI_NORMAL_TARGET_LEADER: + if( CHAR_getWorkInt( tindex, CHAR_WORKPARTYMODE ) == CHAR_PARTY_LEADER) { + target[cnt++] = i; + }else if(!RAND( 0, 2)) { + target[cnt++] = i; + } + break; +#endif + default: + target[cnt++] = i; + break; + } + } + if( cnt == 0 && at[1] == B_AI_NORMAL_TARGET_ALL ) return FALSE; + if( cnt > 0 ) break; + at[1] = B_AI_NORMAL_TARGET_ALL; + } + result->command = BATTLE_COM_NONE; + if( at[2] == B_AI_NORMAL_SELECT_RANDOM ) { + r = RAND( 0, cnt-1); + result->command = BATTLE_COM_ATTACK; + result->target = target[r]; + }else if( at[2] == B_AI_NORMAL_SELECT_HP_MAX || at[2] == B_AI_NORMAL_SELECT_HP_MIN ){ + int top = 0; + for( i = 0; i < cnt; i ++ ) { + if( i ==0 ) top = target[i]; + else { + int tophp = CHAR_getInt((pEntry+top)->charaindex, CHAR_HP); + int comphp = CHAR_getInt((pEntry+target[i])->charaindex, CHAR_HP); + if( at[2] == B_AI_NORMAL_SELECT_HP_MAX ) { + if( comphp > tophp ) top = target[i]; + } + else { + if( comphp < tophp ) top = target[i]; + } + } + } +#ifdef _ENEMY_ATTACK_AI + if(!RAND( 0, rn[0])) + result->target = target[RAND( 0, cnt-1)]; + else + result->target = top; + result->command = BATTLE_COM_ATTACK; +#else + result->command = BATTLE_COM_ATTACK; + result->target = top; +#endif + } +#ifdef _ENEMY_ATTACK_AI + else if(at[2] == B_AI_NORMAL_SELECT_STR_MAX) { + int top = 0; + for( i=0; icharaindex, CHAR_STR); + int compstr = CHAR_getInt( (pEntry+target[i])->charaindex, CHAR_STR); + if(compstr>topstr) top = target[i]; + } + } + if(!RAND( 0, rn[0])) + result->target = target[RAND( 0, cnt-1)]; + else + result->target = top; + result->command = BATTLE_COM_ATTACK; + } + else if(at[2] == B_AI_NORMAL_SELECT_DEX_MAX || + at[2] == B_AI_NORMAL_SELECT_DEX_MIN) { + int top = 0; + for( i=0; icharaindex, CHAR_DEX); + int compdex = CHAR_getInt( (pEntry+target[i])->charaindex, CHAR_DEX); + if(at[2]==B_AI_NORMAL_SELECT_DEX_MAX) { + if(compdex>topdex) top = target[i]; + }else { + if(compdextarget = target[RAND( 0, cnt-1)]; + else + result->target = top; + result->command = BATTLE_COM_ATTACK; + } + else if(at[2] == B_AI_NORMAL_SELECT_ATT_SUBDUE) { + int top = 0; + for( i=0; icharaindex, CHAR_WORKFIXEARTHAT); + int compatt = CHAR_getWorkInt( (pEntry+target[i])->charaindex, CHAR_WORKFIXEARTHAT); + if(compatt>topatt) top = target[i]; + } + break; + case AI_ATT_WATERAT: + { + int topatt = CHAR_getWorkInt( (pEntry+top)->charaindex, CHAR_WORKFIXWATERAT); + int compatt = CHAR_getWorkInt( (pEntry+target[i])->charaindex, CHAR_WORKFIXWATERAT); + if(compatt>topatt) top = target[i]; + } + break; + case AI_ATT_FIREAT: + { + int topatt = CHAR_getWorkInt( (pEntry+top)->charaindex, CHAR_WORKFIXFIREAT); + int compatt = CHAR_getWorkInt( (pEntry+target[i])->charaindex, CHAR_WORKFIXFIREAT); + if(compatt>topatt) top = target[i]; + } + break; + case AI_ATT_WINDAT: + { + int topatt = CHAR_getWorkInt( (pEntry+top)->charaindex, CHAR_WORKFIXWINDAT); + int compatt = CHAR_getWorkInt( (pEntry+target[i])->charaindex, CHAR_WORKFIXWINDAT); + if(compatt>topatt) top = target[i]; + } + break; + default: + break; + } + } + } + if(!RAND( 0, rn[0])) + result->target = target[RAND( 0, cnt-1)]; + else + result->target = top; + result->command = BATTLE_COM_ATTACK; + } +#endif + else{ + return FALSE; + } + if( B_AI_WAZAMODE0 <= mode && mode <= B_AI_WAZAMODE6 ){ + if( PETSKILL_Use( charaindex, mode - B_AI_WAZAMODE0, result->target,NULL ) == TRUE ){ + result->command = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM1 ); + return TRUE; + }else{ +// print( "δ趨(%s):(%d)\n", +// CHAR_getUseName( charaindex), mode - B_AI_WAZAMODE0 ); + return FALSE; + } + }else + if( mode == B_AI_ATTACKMODE ){ + result->command = BATTLE_COM_ATTACK; + return TRUE; + } + }else if( mode == B_AI_GURADMODE ) { + result->command = BATTLE_COM_GUARD; + return TRUE; + }else if( mode == B_AI_ESCAPEMODE ) { + result->command = BATTLE_COM_ESCAPE; + return TRUE; + } + return FALSE; +} diff --git a/battle/battle_command.c b/battle/battle_command.c new file mode 100644 index 0000000..e7b1605 --- /dev/null +++ b/battle/battle_command.c @@ -0,0 +1,1071 @@ +#include "version.h" +#include +#include +#include"char.h" +#include"char_base.h" +#include "battle.h" +#include "pet_skill.h" +#include "battle_event.h" +#include "battle_command.h" +#include "lssproto_serv.h" +#include "magic.h" +#include "magic_base.h" +#include "handletime.h" + +#ifdef _PROFESSION_SKILL // WON ADD ְҵ +#include "profession_skill.h" +#endif +int NowBattlerFd; +#if 1 +int BATTLE_MpDown( int charaindex, int down ) +{ + return 0; +} +#else +{ + int mp, battleindex; + // о??? + battleindex = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEINDEX ); + + if( BATTLE_CHECKINDEX( battleindex ) == FALSE )return TRUE; + // оԪئ?? + if( BattleArray[battleindex].type != BATTLE_TYPE_P_vs_P ){ + return TRUE; + } + + // ??ëӼ¾ + mp = CHAR_getInt( charaindex, CHAR_MP ); + if( mp < down ){ + // Ӽئмƥئ + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_NONE ); + // ѨOK϶ + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + return FALSE; + } + mp -= down; + CHAR_setInt( charaindex, CHAR_MP, mp ); + return TRUE; +} +#endif + + +void BattleCommandDispach( int fd, char *command ) +{ + int endFlg = 0, battleindex; + int EscapeFree = BATTLE_FLG_FREEDP; + int charaindex = CONNECT_getCharaindex(fd); + char szBuffer[256]=""; +#ifdef _FIXWOLF // Syu ADD ˱Bug + int i , j , pindex; + BATTLE_ENTRY *pEntry; +#endif + + NowBattlerFd = fd; + + if( CHAR_CHECKINDEX( charaindex ) == FALSE )return; + + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER ){ + return; + } + + battleindex = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEINDEX ); + + if( BATTLE_CHECKINDEX( battleindex ) == FALSE || + CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE) == BATTLE_CHARMODE_NONE ){ + + return; + } + + + if( BattleArray[battleindex].flg & BATTLE_FLG_CHARALOST ){ + EscapeFree = 0; + } + + if( strncmp( command, "U", 1 ) == 0 ){ + // shan 2001/12/25 begin + EscapeFree = 0; + if (CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEWATCH )!=TRUE){ + CHAR_talkToCli( charaindex, -1, + "ħʹ㶨ս", CHAR_COLORYELLOW ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_GUARD ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + //sprintf( szBuffer, "Command(%s)()", CHAR_getUseName( charaindex ) ); + endFlg = 1; + BATTLE_MpDown( charaindex, 2 ); + }else{ + BATTLE_WatchStop( charaindex ); + } + // shan end + }else + if( strncmp( command, "E", 1 ) == 0 ){ + + if( checkErrorStatus( charaindex) ) { + BattleCommandDispach( fd, "N"); + return; + } + + CHAR_setWorkInt( charaindex, CHAR_WORKDBATTLEESCAPE,1 ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_ESCAPE ); + + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + //sprintf( szBuffer, "Command(%s)()", CHAR_getUseName( charaindex ) ); + endFlg = 1; + + BATTLE_MpDown( charaindex, 20 ); + + }else + if( strncmp( command, "H|", 2 ) == 0 ){ + int iNum = -1, At_SoubiIndex; + if( sscanf( command+2, "%X", &iNum ) != 1 + || ( iNum < 0 || iNum >= 20 ) + ){ + iNum = -1; + } + + if( checkErrorStatus( charaindex) ) { + BattleCommandDispach( fd, "N"); + return; + } + + EscapeFree = 0; + + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, iNum ); + + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_ATTACK ); + + At_SoubiIndex = CHAR_getItemIndex( charaindex, CHAR_ARM ); + if( ITEM_CHECKINDEX( At_SoubiIndex ) == FALSE ){ + + }else{ + + if( ITEM_getInt( At_SoubiIndex, ITEM_TYPE ) == ITEM_BOOMERANG ){ + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_BOOMERANG ); +#ifdef _PETSKILL_BECOMEFOX + if( CHAR_getInt( charaindex, CHAR_BASEIMAGENUMBER)==101749 + || CHAR_getWorkInt( charaindex, CHAR_WORKFOXROUND ) != -1 ){ //DZС겻ʹû + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_NONE ); + } +#endif +#ifdef _PETSKILL_BECOMEPIG + if( CHAR_getInt( charaindex, CHAR_BECOMEPIG) > -1 ){// + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_ATTACK ); + } +#endif + } + } + + + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + + CHAR_SETWORKINT_LOW( charaindex, CHAR_WORKBATTLECOM3, 1 ); + //sprintf( szBuffer, "Command(%s)(ս)", CHAR_getUseName( charaindex ) ); + + endFlg = 1; + + BATTLE_MpDown( charaindex, 5 ); + + }else + if( strncmp( command, "G", 1 ) == 0 ){ + + if( checkErrorStatus( charaindex) ) { + BattleCommandDispach( fd, "N"); + return; + } + + EscapeFree = 0; + + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_GUARD ); + + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + + sprintf( szBuffer, "Command(%s)()", CHAR_getUseName( charaindex ) ); + endFlg = 1; + + BATTLE_MpDown( charaindex, 2 ); + + }else + if( strncmp( command, "N", 1 ) == 0 ){ + + EscapeFree = 0; + + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_WAIT ); + + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); +// sprintf( szBuffer, "Command(%s)(serverй)", CHAR_getUseName( charaindex ) ); + //sprintf( szBuffer, "Command(%s)()", CHAR_getUseName( charaindex ) ); + endFlg = 1; + + }else + if( strncmp( command, "T|", 2 ) == 0 ){ + int iNum = -1; + + if( checkErrorStatus( charaindex) ) { + BattleCommandDispach( fd, "N"); + return; + } + + EscapeFree = 0; + + if( sscanf( command+2, "%X", &iNum ) != 1 + || ( iNum < 0 || iNum >= 20 ) + ){ + iNum = -1; + } + + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, iNum ); + + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_CAPTURE ); + + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + + //sprintf( szBuffer, "Command(%s)()", CHAR_getUseName( charaindex ) ); + endFlg = 1; + + BATTLE_MpDown( charaindex, 20 ); + + }else + if( strncmp( command, "S|", 2 ) == 0 ){ + int iNum = -1; + + if( checkErrorStatus( charaindex) ) { + BattleCommandDispach( fd, "N"); + return; + } + + EscapeFree = 0; + + // shan 2002/01/08 begin + if( sscanf( command+2, "%d", &iNum ) != 1 + || ( iNum < -1 || iNum >= CHAR_MAXPETHAVE ) + || ( CHAR_getInt(charaindex,CHAR_RIDEPET)==iNum) + ){ + iNum = -1; + } + // shan end + +#ifdef _STANDBYPET +#ifndef _PET_STANDBY + if( iNum >= 0) { + if( ! (CHAR_getWorkInt( charaindex, CHAR_WORKSTANDBYPET) & ( 1 << iNum)) ) { + //print("\n ķ!гǴ!!:%s ", CHAR_getChar( charaindex, CHAR_CDKEY) ); + iNum = -1; + } + } +#endif +#endif + + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, iNum ); + if( iNum < 0 ){ + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_PETIN ); + //sprintf( szBuffer, "Command(%s)(س)", CHAR_getUseName( charaindex ) ); + }else{ + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_PETOUT ); + //sprintf( szBuffer, "Command(%s)(г)", CHAR_getUseName( charaindex ) ); + } + + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + + endFlg = 1; + + BATTLE_MpDown( charaindex, 10 ); + + }else + if( strncmp( command, "W|", 2 ) == 0 ){ + int iNum = -1, petskillindex = -1, ToNo = -1, petnum, petindex; + if( sscanf( command+2, "%X|%X", &iNum, &ToNo ) < 1 ){ + iNum = -1; ToNo = -1; + } + petnum = CHAR_getInt( charaindex, CHAR_DEFAULTPET ); + petindex = CHAR_getCharPet( charaindex, petnum ); + if( CHAR_CHECKINDEX( petindex ) == FALSE ){ + }else{ + + if( iNum < 0 || iNum >= CHAR_MAXPETSKILLHAVE +#ifdef _PETSKILLBUG //Add By Syu 2002.0805 + || (CHAR_getFlg( charaindex, CHAR_ISDIE ) == TRUE )|| + (CHAR_getInt( charaindex, CHAR_HP ) <= 0) +#endif + || checkErrorStatus( petindex) + ) + { + //sprintf( szBuffer, "Command(%s)(Զ)", CHAR_getUseName( petindex ) ); + CHAR_setWorkInt( petindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); +#ifdef _PETSKILLBUG //Add By Syu 2002.0805 + }else if ((CHAR_getInt(petindex, CHAR_TRANSMIGRATION)<1) + && ( iNum>=CHAR_getInt(petindex, CHAR_SLOT) ) ) + { + //sprintf( szBuffer, "Command(%s)(Զ)", CHAR_getUseName( petindex ) ); + CHAR_setWorkInt( petindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); +#endif + }else{ + petskillindex = PETSKILL_GetArray( petindex, iNum); +#ifdef _FIXWOLF // Syu ADD ˱Bug + if( (CHAR_getPetSkill( petindex , iNum )== 600) && (ToNo == -1)) + { + for( j = 0; j < 2; j ++ ) + { + pEntry = BattleArray[battleindex].Side[j].Entry; + for( i = 0; i < BATTLE_ENTRY_MAX; i ++ ) + { + pindex = pEntry[i].charaindex; + if( pindex == petindex) + { + ToNo=i + ( j * 10 ); + break; + } + } + } + } +#endif + if( petskillindex >= 0 + && PETSKILL_Use( petindex, iNum, ToNo, NULL ) == TRUE + ){ + //sprintf( szBuffer, "Command(%s)(ʯ)", CHAR_getUseName( petindex ) ); + + EscapeFree = 0; + + }else{ + //sprintf( szBuffer, "Command(%s)(Զ)", CHAR_getUseName( petindex ) ); + CHAR_setWorkInt( petindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + } + } + } + endFlg = 1; + BATTLE_MpDown( charaindex, 10 ); + }else + if( strncmp( command, "J|", 1 ) == 0 ){ + int iNum = -1, magicindex = -1, ToNo = -1; + int valid = -1; + int itemindex=-1; + + if( checkErrorStatus( charaindex) ) { + BattleCommandDispach( fd, "N"); + return; + } + + EscapeFree = 0; + if( sscanf( command+2, "%X|%X", &iNum, &ToNo ) != 2 ){ + iNum = -1; ToNo = -1; + } + if( iNum < CHAR_EQUIPPLACENUM && iNum >= CHAR_HEAD ){ + magicindex = MAGIC_GetArrayNo( charaindex, iNum ); + itemindex = CHAR_getItemIndex( charaindex, iNum ); + valid = MAGIC_isTargetValid( magicindex, ToNo); + + if ((valid <0 ) || ( magicindex < 0 ) || (itemindex < 0 )){ + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_WAIT ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + }else{ +#ifdef _ITEM_ATTSKILLMAGIC + char *magicarg="\0"; + int magic_array = -1; + magic_array = MAGIC_getMagicArray( magicindex ); + magicarg = MAGIC_getChar( magic_array, MAGIC_OPTION ); + if( magicarg != "\0" && strstr( magicarg, "SKILL") != NULL ) { + int mp = ITEM_getInt( itemindex, ITEM_MAGICUSEMP ); + if( MAGIC_AttSkill( charaindex, ToNo, magic_array, mp) == FALSE ) { + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_WAIT ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + } + }else { +#endif + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, ToNo ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_JYUJYUTU ); + CHAR_SETWORKINT_LOW( charaindex, CHAR_WORKBATTLECOM3, magicindex ); + CHAR_SETWORKINT_HIGH( charaindex, CHAR_WORKBATTLECOM3, iNum ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + //sprintf( szBuffer, "Command(%s)()", CHAR_getUseName( charaindex ) ); +#ifdef _ITEM_ATTSKILLMAGIC + } +#endif + } + }else{ + EscapeFree = 0; + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_WAIT ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + //sprintf( szBuffer, "Command(%s)()", CHAR_getUseName( charaindex ) ); + } + endFlg = 1; + }else + if( strncmp( command, "I|", 1 ) == 0 ){ + int iNum = -1, ToNo = -1; + int valid = 0, itemindex = -1; + + if( checkErrorStatus( charaindex) ) { + BattleCommandDispach( fd, "N"); + return; + } + + EscapeFree = 0; + + if( sscanf( command+2, "%X|%X", &iNum, &ToNo ) != 2 ){ + iNum = -1; ToNo = -1; + } + itemindex = CHAR_getItemIndex( charaindex, iNum ); + if ( !ITEM_CHECKINDEX( itemindex) ) valid=-1; + if (valid >= 0) valid = ITEM_isTargetValid( charaindex, itemindex, ToNo ); + if (valid < 0 ) { + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_WAIT ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + } else { + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, ToNo ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_ITEM ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM3, iNum ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + //sprintf( szBuffer, "Command(%s)()", CHAR_getUseName( charaindex ) ); + endFlg = 1; + } + }else + if( strncmp( command, "@", 1 ) == 0 ){ + //sprintf( szBuffer, "Command(%s)(ͨ)", CHAR_getUseName( charaindex ) ); + + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + endFlg = 1; + + CHAR_setInt( charaindex, CHAR_MP, + min( 100, CHAR_getInt( charaindex, CHAR_MP ) + 30 ) ); + + }else +#ifdef _PROFESSION_SKILL // WON ADD ְҵ + if( strncmp( command, "P", 1 ) == 0 ){ + int iNum=-1, ToNo=-1; + int skillindex=-1; + int char_pskill=-1, profession_skill=-1, Pskillid=-1; + + if( checkErrorStatus( charaindex) ) { + BattleCommandDispach( fd, "N"); + return; + } + + EscapeFree = 0; + + if( sscanf( command+2, "%X|%X", &iNum, &ToNo ) < 1 ){ + iNum = -1; ToNo = -1; + } + + if( CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE) == BATTLE_CHARMODE_NONE ){ +// print("\n\n Ƿ(19001)(%s)(%s)\n\n", CHAR_getChar(charaindex, CHAR_CDKEY), CHAR_getChar(charaindex, CHAR_NAME) ); +#ifdef _PROSKILL_ERR_KICK + CONNECT_setCloseRequest( fd , 1 ); +#endif + return; + } +#ifndef _PROSKILL_OPTIMUM // Robin fix cancel ˴Թְҵ, PROFESSION_SKILL_Use м + // ְҵ + char_pskill = CHAR_getInt( charaindex, PROFESSION_CLASS ); + // ְܵҵ + skillindex = PROFESSION_SKILL_GetArray( charaindex, iNum); + Pskillid = PROFESSION_SKILL_getskillArray( skillindex); + profession_skill = PROFESSION_SKILL_getInt( Pskillid, PROFESSION_SKILL_PROFESSION_CLASS); + + if( (char_pskill > 0) && (char_pskill == profession_skill) ){ +#else + if( 1 ) { +#endif + if( PROFESSION_SKILL_Use( charaindex, iNum, ToNo, NULL ) == 1 ){ + //sprintf( szBuffer, "Command(%s)(ְҵ)", CHAR_getUseName( charaindex ) ); + endFlg = 1; + }else{ +// print("\nְҵʧ!!\n"); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_WAIT ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + //sprintf( szBuffer, "Command(%s)()", CHAR_getUseName( charaindex ) ); +#ifdef _PROSKILL_ERR_KICK + CONNECT_setCloseRequest( fd , 1 ); +#endif + } + }else{ +// print("\nķ??ְҵIDȷ:%s:%d:%d \n", CHAR_getChar( charaindex, CHAR_CDKEY), char_pskill, profession_skill); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_WAIT ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + //sprintf( szBuffer, "Command(%s)()", CHAR_getUseName( charaindex ) ); +#ifdef _PROSKILL_ERR_KICK + CONNECT_setCloseRequest_debug( fd , 1 ); +#endif + } + + EscapeFree = 0; + }else +#endif + + { + //sprintf( szBuffer, "Command(%s)(ʧ)", CHAR_getUseName( charaindex ) ); + endFlg = 2; + } + + + if( endFlg ){ + BATTLE_ActSettingSend( battleindex ); + + if( endFlg==1 ){ + int fd; + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE)==CHAR_TYPEPLAYER ){ + fd = CHAR_getWorkInt( charaindex, CHAR_WORKFD); + CONNECT_SetBattleRecvTime( fd, &NowTime); + } + } + } + + { + //if( BATTLE_CHECKINDEX( battleindex ) == TRUE ){ + // BATTLE_BroadCast( battleindex, szBuffer, CHAR_COLORWHITE ) ; + //} + } + + if( BattleArray[battleindex].turn == 0 ){ + BattleArray[battleindex].flg |= EscapeFree; + }else{ + BattleArray[battleindex].flg &= EscapeFree; + } +} + + +void BATTLE_ActSettingSend( int battleindex ) +{ + int pindex, k = 0, i, j, charaindex; + int endBit = 0; + char szBA[256]; + BATTLE_ENTRY *pEntry; + BATTLE *pBattle; + + for( j = 0; j < 2; j ++ ){ + pEntry = BattleArray[battleindex].Side[j].Entry; + for( i = 0; i < BATTLE_ENTRY_MAX; i ++ ){ + pindex = pEntry[i].charaindex; + // Ѩ ƥ廯 + if( CHAR_getWorkInt( pindex, CHAR_WORKBATTLEMODE ) + == BATTLE_CHARMODE_C_OK + ){ + endBit |= 1 << k; // + }else + // ķ姸 + if( CHAR_getInt( pindex, CHAR_WHICHTYPE ) == CHAR_TYPEENEMY || + CHAR_getInt( pindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYERNPC || + CHAR_getInt( pindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYERPETNPC ) + { + endBit |= 1 << k; // + } + k ++; + } + } + sprintf( szBA, "BA|%X|%X|", endBit, BattleArray[battleindex].turn ); +// print( "%s\n", szBA ); + //ձ幻ƻ˪ + for( j = 0; j < 2; j ++ ){ + pEntry = BattleArray[battleindex].Side[j].Entry; + for( i = 0; i < BATTLE_ENTRY_MAX; i ++ ){ + pindex = pEntry[i].charaindex; + if( CHAR_CHECKINDEX( pindex ) == FALSE )continue; + // ׻ƽҷ±巴˪ئ + if( CHAR_getWorkInt( pindex, CHAR_WORKBATTLEMODE ) == BATTLE_CHARMODE_RESCUE )continue; + // + if( CHAR_getInt( pindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER + ){ // Ѩ˪ + BATTLE_CommandSend( pindex, szBA ); + } + } + } + + + // ƻб˪ + pBattle = BattleArray[battleindex].pNext; + for( ; pBattle ; pBattle = pBattle->pNext ){ + + // ʧо + if( BATTLE_CHECKADDRESS( pBattle ) == FALSE ){ + //fprint( "err:սbattle address(%p)\n", pBattle ); + break; + } + // 幻˪ + for( i = 0; i < BATTLE_ENTRY_MAX; i ++ ){ + charaindex = pBattle->Side[0].Entry[i].charaindex; + if( CHAR_CHECKINDEX( charaindex ) == FALSE )continue; + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER )continue; + // Ѩ˪ + BATTLE_CommandSend( pindex, szBA ); + } + } +} + + + +BOOL BATTLE_IsHide( int charaindex ){ + if( CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM1 ) == BATTLE_COM_S_EARTHROUND0 + ){ + return TRUE; + } + return FALSE; +} + + + + + +//******************************************************* +// +// PѨëͷʧ˪ +// +BOOL BATTLE_CommandSend( int charaindex, char *pszCommand) +// +//******************************************************** +{ + if( CHAR_CHECKINDEX( charaindex ) == FALSE )return FALSE; + if( getfdFromCharaIndex( charaindex ) < 0 )return FALSE; + lssproto_B_send( getfdFromCharaIndex( charaindex ), pszCommand ); + return TRUE; +} + + +BOOL BATTLE_MakeCharaString( + int battleindex, + char *pszCommand, + int size +) +{ + int i, j, iOffset, charaindex, flg; + BATTLE_ENTRY *pEntry; + char szBuffer[4096]="", *pszTop, *pszLast; + char szEscapeName[128], szEscapeTitle[128]; + char szEscapePetName[128]; + int rideflg = 0, petindex = -1, petlevel, pethp, petmaxhp; + if( BATTLE_CHECKINDEX( battleindex ) == FALSE )return FALSE; + pszTop = pszCommand; + pszLast = pszCommand+size-1; +#if 1 + sprintf( szBuffer, "BC|%X|", BattleArray[battleindex].field_att ); +#else + sprintf( szBuffer, "BC|" ); +#endif + STRCPY_TAIL( pszTop, pszLast, szBuffer ); + + for( j = 0; j < 2; j ++ ){ + if( j == 1 ){ + iOffset = SIDE_OFFSET; // 𵤴µ + }else{ + iOffset = 0; + } + pEntry = BattleArray[battleindex].Side[j].Entry; + for( i = 0; i < BATTLE_ENTRY_MAX; i ++ ){ + charaindex = pEntry[i].charaindex; + if( CHAR_CHECKINDEX( charaindex ) == FALSE )continue; + if( CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEFLG ) + & CHAR_BATTLEFLG_ULTIMATE )continue; + flg = 0; + if( CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE ) + == BATTLE_CHARMODE_INIT ) flg |= BC_FLG_NEW; + if( CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE ) + == BATTLE_CHARMODE_RESCUE ) flg |= BC_FLG_NEW; + if( CHAR_getFlg( charaindex, CHAR_ISDIE ) == TRUE ){ + flg |= BC_FLG_DEAD; + }else + if( CHAR_getWorkInt( charaindex, CHAR_WORKPOISON ) > 0 ){ + flg |= BC_FLG_POISON; + }else +#ifdef _MAGIC_WEAKEN // + if( CHAR_getWorkInt( charaindex, CHAR_WORKWEAKEN ) > 0 ){ + flg |= BC_FLG_WEAKEN; + }else +#endif +#ifdef _MAGIC_DEEPPOISON // 綾 + if( CHAR_getWorkInt( charaindex, CHAR_WORKDEEPPOISON ) > 0 ){ + flg |= BC_FLG_DEEPPOISON; + }else +#endif +#ifdef _MAGIC_NOCAST // Ĭ + if( CHAR_getWorkInt( charaindex, CHAR_WORKNOCAST ) > 0 ){ + flg |= BC_FLG_NOCAST; + }else +#endif +#ifdef _MAGIC_BARRIER // ħ + if( CHAR_getWorkInt( charaindex, CHAR_WORKBARRIER ) > 0 ){ + flg |= BC_FLG_BARRIER; + }else +#endif + if( CHAR_getWorkInt( charaindex, CHAR_WORKPARALYSIS ) > 0 ){ + flg |= BC_FLG_PARALYSIS; + }else + if( CHAR_getWorkInt( charaindex, CHAR_WORKSLEEP ) > 0 ){ + flg |= BC_FLG_SLEEP; + }else + if( CHAR_getWorkInt( charaindex, CHAR_WORKSTONE ) > 0 ){ + flg |= BC_FLG_STONE; + }else + if( CHAR_getWorkInt( charaindex, CHAR_WORKDRUNK ) > 0 ){ + flg |= BC_FLG_DRUNK; + }else + if( CHAR_getWorkInt( charaindex, CHAR_WORKCONFUSION ) > 0 ){ + flg |= BC_FLG_CONFUSION; + } + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER ){ + flg |= BC_FLG_PLAYER; + } + if( CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEFLG ) & CHAR_BATTLEFLG_REVERSE ){ + flg |= BC_FLG_REVERSE; + } + if( BATTLE_IsHide( charaindex ) == TRUE ){ + flg |= BC_FLG_HIDE; + } +#ifdef _PET_SKILL_SARS // WON ADD ɷ + if( CHAR_getWorkInt( charaindex, CHAR_WORKSARS ) > 0 ){ + flg |= BC_FLG_SARS; + } +#endif +#ifdef _PROFESSION_SKILL // WON ADD ְҵ + if( CHAR_getWorkInt( charaindex, CHAR_WORKDIZZY ) > 0 ){ + flg |= BC_FLG_DIZZY; // ѣ + } + if( CHAR_getWorkInt( charaindex, CHAR_WORKENTWINE ) > 0 ){ + flg |= BC_FLG_ENTWINE; // + } + if( CHAR_getWorkInt( charaindex, CHAR_WORKDRAGNET ) > 0 ){ + flg |= BC_FLG_DRAGNET; // ޵ + } + if( CHAR_getWorkInt( charaindex, CHAR_WORKICECRACK ) > 0 ){ + // flg |= BC_FLG_ICECRACK; // + } + if( CHAR_getWorkInt( charaindex, CHAR_WORKOBLIVION ) > 0 ){ + flg |= BC_FLG_OBLIVION; // + } + if( CHAR_getWorkInt( charaindex, CHAR_WORKICEARROW ) > 0 ){ + flg |= BC_FLG_ICEARROW; // + } + if( CHAR_getWorkInt( charaindex, CHAR_WORKBLOODWORMS ) > 0 ){ + flg |= BC_FLG_BLOODWORMS; // Ѫ + } + if( CHAR_getWorkInt( charaindex, CHAR_WORKSIGN ) > 0 ){ + flg |= BC_FLG_SIGN; // һѪ + } + if( CHAR_getWorkInt( charaindex, CHAR_WORKINSTIGATE ) > 0 ){ + flg |= BC_FLG_CARY; // + } + if( CHAR_getWorkInt( charaindex, CHAR_WORK_F_ENCLOSE ) > 0 ){ + flg |= BC_FLG_F_ENCLOSE; // + } + if( CHAR_getWorkInt( charaindex, CHAR_WORK_I_ENCLOSE ) > 0 ){ + flg |= BC_FLG_I_ENCLOSE; // + } + if( CHAR_getWorkInt( charaindex, CHAR_WORK_T_ENCLOSE ) > 0 ){ + flg |= BC_FLG_T_ENCLOSE; // ׸ + } +#endif +#ifdef _PROFESSION_ADDSKILL + if( CHAR_getWorkInt( charaindex, CHAR_WORKANNEX ) > 0 ){ + flg |= BC_FLG_T_ENCLOSE; // + } + if( CHAR_getWorkInt( charaindex, CHAR_WORKWATER ) > 0 ){ + flg |= BC_FLG_WATER; // ˮ + } + if( CHAR_getWorkInt( charaindex, CHAR_WORKFEAR ) > 0 ){ + flg |= BC_FLG_FEAR; // ־ + } +#endif +#ifdef _PETSKILL_LER + if(CHAR_getWorkInt(charaindex,CHAR_WORK_RELIFE) > 0){ + flg |= BC_FLG_CHANGE; // ׶ + CHAR_setWorkInt(charaindex,CHAR_WORK_RELIFE,0); + } +#endif + makeEscapeString( CHAR_getUseName( charaindex ), + szEscapeName, + sizeof( szEscapeName ) ); + makeEscapeString( BATTLE_CharTitle( charaindex ), + szEscapeTitle, + sizeof( szEscapeTitle ) ); + // Robin 0728 ride Pet + petindex = BATTLE_getRidePet( charaindex ); + if( petindex != -1 ){ + rideflg = 1; + makeEscapeString( CHAR_getUseName( petindex ), + szEscapePetName, + sizeof( szEscapePetName ) ); + petlevel = CHAR_getInt( petindex, CHAR_LV); + pethp = CHAR_getInt( petindex, CHAR_HP); + petmaxhp = CHAR_getWorkInt( petindex, CHAR_WORKMAXHP); + + }else { + if( CHAR_getWorkInt( charaindex, CHAR_WORKPETFALL ) == 1 ){ + rideflg = -1; +#ifdef _PETSKILL_BECOMEFOX // ĻʱѶϢ Client + if( CHAR_getWorkInt( charaindex, CHAR_WORKFOXROUND ) != -1 ) + rideflg = -2; //clientжʾ (ӦclientΪp_party[ BattleMyNo ]->onRide) +#endif +#ifdef _PETSKILL_BECOMEPIG // ʱѶϢ Client + if( CHAR_getInt( charaindex, CHAR_BECOMEPIG) > 120 )// + rideflg = -3; //clientжʾ (ӦclientΪp_party[ BattleMyNo ]->onRide) +#endif + CHAR_setWorkInt( charaindex, CHAR_WORKPETFALL, 0 ); + } + else + rideflg = 0; + szEscapePetName[0] = 0; + petlevel = 0; + pethp = 0; + petmaxhp = 0; + } + + sprintf( szBuffer, "%X|%s|%s|%X|%X|%X|%X|%X|%X|%s|%X|%X|%X|", + pEntry[i].bid, + szEscapeName, + szEscapeTitle, + CHAR_getInt( charaindex, CHAR_BASEIMAGENUMBER ), + CHAR_getInt( charaindex, CHAR_LV ), + max( CHAR_getInt( charaindex, CHAR_HP ),0), + CHAR_getWorkInt( charaindex, CHAR_WORKMAXHP ), + flg, + rideflg, + szEscapePetName, + petlevel, + pethp, + petmaxhp + ); + STRCPY_TAIL( pszTop, pszLast, szBuffer ); + if( pszTop >= pszLast )return FALSE;// + } + } + + return TRUE; +} + +void BATTLE_BpSendToWatch( + BATTLE *pBattle, // ͼ̼ + char *pszBcString // BC ٯ +) +{ + + char szBp[256]; + int flg = 0, i, charaindex; + +// for( ; pBattle ; pBattle = pBattle->pNext ){ + if( pBattle == NULL )return; + // ʧо + if( BATTLE_CHECKADDRESS( pBattle ) == FALSE ){ + //fprint( "err:սbattle address(%p)\n", pBattle ); + return; + } + + // 幻˪ + for( i = 0; i < BATTLE_ENTRY_MAX; i ++ ){ + charaindex = pBattle->Side[0].Entry[i].charaindex; + if( CHAR_CHECKINDEX( charaindex ) == FALSE )continue; + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE ) + != CHAR_TYPEPLAYER ) continue; + if( CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE ) + == BATTLE_CHARMODE_WATCHINIT){ + flg |= BP_FLG_JOIN; // ޥ + } + flg |= BP_FLG_PLAYER_MENU_OFF; // بئ + // į˪ + sprintf( szBp, "BP|%X|%X|%X", 20, flg, 0 ); + BATTLE_CommandSend( charaindex, szBp ); + // 幻ɧ ˪ + BATTLE_CommandSend( charaindex, pszBcString ); + } + // Ѩг + pBattle->mode = BATTLE_MODE_WATCHPRE; +// } +} + +void BATTLE_CharSendAll( int battleindex ) +{ + int i, j, charaindex, flg, pet, At_SoubiIndex, pindex; + char szBp[256]; + BATTLE *pBattle; + + BATTLE_MakeCharaString( + battleindex, + szAllBattleString, + sizeof(szAllBattleString) + ); + + for( j = 0; j < 2; j ++ ){ + for( i = 0; i < BATTLE_ENTRY_MAX; i ++ ){ + charaindex = BattleArray[battleindex].Side[j].Entry[i].charaindex; + if( CHAR_CHECKINDEX( charaindex ) == FALSE )continue; + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER )continue; + flg = 0; + if( BattleArray[battleindex].Side[j].flg & BSIDE_FLG_SURPRISE ){ + flg |= BP_FLG_ENEMY_SURPRISAL; + }else + if( BattleArray[battleindex].Side[1-j].flg & BSIDE_FLG_SURPRISE ){ + flg |= BP_FLG_PLAYER_SURPRISAL; + } + if( CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE ) + == BATTLE_CHARMODE_RESCUE){ + flg |= BP_FLG_JOIN; // + } + At_SoubiIndex = CHAR_getItemIndex( charaindex, CHAR_ARM ); + if( ITEM_CHECKINDEX( At_SoubiIndex ) == FALSE ){ + }else{ + if( ITEM_getInt( At_SoubiIndex, ITEM_TYPE ) == ITEM_BOOMERANG ){ + flg |= BP_FLG_BOOMERANG; + } + } + + pet = CHAR_getInt( charaindex, CHAR_DEFAULTPET ); + if( pet >= 0 ){ + snprintf( szBp, sizeof( szBp ), "K%d", pet ); + CHAR_sendStatusString( charaindex, szBp ); + + pindex = CHAR_getCharPet( charaindex, pet ); + +#ifdef _PETSKILL_DAMAGETOHP + { +/* + ÿ,ÿ~~~~~~~ + qTTr + qsU + tѨTѨs± +*/ + char msg[32]={0}; + //print("\nid:%d",CHAR_getInt( pindex, CHAR_PETID)); + //print("\n:%s",CHAR_getChar( pindex, CHAR_NAME)); + //if( CHAR_getInt( pindex, CHAR_PETID) == 777 ){//ID ˮ˫ͷ + // || CHAR_getInt( pindex, CHAR_PETID) == 146 ) //˫ͷ + // && CHAR_getInt( pindex, CHAR_HP) ){ + sprintf( msg, "o%d", pet ); + CHAR_sendStatusString( charaindex, msg ); + + //} + } +#endif + +#ifdef _PETSKILL_BECOMEFOX // Ļijļ + //if( CHAR_getInt( pindex, CHAR_BASEIMAGENUMBER) == 101749 ){ + if( CHAR_getWorkInt( pindex, CHAR_WORKFOXROUND ) != -1 ){ //DZС + char msg[32]={0}; + sprintf( msg, "a%d", pet ); + CHAR_sendStatusString( charaindex, msg ); + + } +#endif + + if( CHAR_CHECKINDEX( pindex ) == TRUE ){ + if( BATTLE_IsCharge( pindex ) == TRUE){ + flg |= BP_FLG_PET_MENU_OFF; + } + if( BATTLE_CanMoveCheck( pindex ) == FALSE ){ + flg |= BP_FLG_PET_MENU_OFF; + } + if( CHAR_getFlg( pindex, CHAR_ISDIE ) == TRUE ){ + flg |= BP_FLG_PET_MENU_OFF; + } + } + }else{ + flg |= BP_FLG_PET_MENU_OFF; + } + + if( BATTLE_CanMoveCheck( charaindex ) == FALSE + || CHAR_getFlg( charaindex, CHAR_ISDIE ) == TRUE + ){ + flg |= BP_FLG_PLAYER_MENU_OFF; + } + + if( BattleArray[battleindex].Side[j].flg & BSIDE_FLG_SURPRISE ){ + flg |= BP_FLG_PLAYER_MENU_OFF; + flg |= BP_FLG_PET_MENU_OFF; + } + sprintf( szBp, "BP|%X|%X|%X", + i + SIDE_OFFSET * j, + flg, CHAR_getInt( charaindex, CHAR_MP ) + ); + BATTLE_CommandSend( charaindex, szBp ); + BATTLE_CommandSend( charaindex, szAllBattleString ); + } + } + pBattle = BattleArray[battleindex].pNext; + for( ; pBattle ; pBattle = pBattle->pNext ){ + // ʧо + if( BATTLE_CHECKADDRESS( pBattle ) == FALSE ){ + //fprint( "err:սbattle address(%p)\n", pBattle ); + break; + } + + BATTLE_BpSendToWatch( pBattle, szAllBattleString ); + + } + + + +} + +void BattleEncountOut( int charaindex) +{ + + if( CHAR_CHECKINDEX( charaindex ) == FALSE )return; + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEINDEX, -1 ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_MODE_NONE ); + + CHAR_sendCToArroundCharacter( CHAR_getWorkInt( charaindex, CHAR_WORKOBJINDEX ) ); + CHAR_sendArroundCharaData( charaindex ); + + if( CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEWATCH ) == 0 ){ + CHAR_sendBattleEffect( charaindex, OFF); + }else{ + CHAR_sendBattleWatch( CHAR_getWorkInt( charaindex, CHAR_WORKOBJINDEX ), OFF); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEWATCH, 0 ); + } + + if( CHAR_getWorkInt( charaindex, CHAR_WORKPARTYMODE ) == CHAR_PARTY_CLIENT ){ + int pmode/*, battleindex*/; + int pindex = CHAR_getWorkInt( charaindex, CHAR_WORKPARTYINDEX1 ); + pmode = CHAR_getWorkInt( pindex, CHAR_WORKBATTLEMODE ); + if( pmode > 0 && pmode != BATTLE_CHARMODE_FINAL ){ + BATTLE_RescueParentTry( charaindex, pindex ); +// print( "μս(%s)\n", CHAR_getUseName( charaindex ) ); + } + } + +} + + +//************************************************** +// +// ɻѨë ľʸ +// +BOOL BATTLE_PetDefaultCommand( int petindex ) +// +//************************************************** +{ + if( CHAR_CHECKINDEX( petindex ) == FALSE )return FALSE; + // 켰϶ + CHAR_setWorkInt( petindex, CHAR_WORKBATTLECOM2, -1 ); + // ɧ ϶ + CHAR_setWorkInt( petindex, CHAR_WORKBATTLECOM1, BATTLE_COM_ATTACK ); + // ѨOK϶ + CHAR_setWorkInt( petindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + + return TRUE; +} + +// Robin fix ʯ˯ս +int checkErrorStatus( int charaindex) +{ + //if( BATTLE_CanMoveCheck( charaindex) == FALSE) { + + if( + CHAR_getWorkInt( charaindex, CHAR_WORKPARALYSIS ) > 0 // + || CHAR_getWorkInt( charaindex, CHAR_WORKSTONE ) > 0 // ʯ + || CHAR_getWorkInt( charaindex, CHAR_WORKSLEEP ) > 0 // ˯ + //|| CHAR_getWorkInt( charaindex, CHAR_WORKBARRIER ) > 0 // ħ + || CHAR_getWorkInt( charaindex, CHAR_WORKDIZZY ) > 0 // ѣ + || CHAR_getWorkInt( charaindex, CHAR_WORKDRAGNET ) > 0 // ޵ + //|| CHAR_getWorkInt( charaindex, CHAR_WORK_T_ENCLOSE ) > 0 // ׸ +#ifdef _PROFESSION_ADDSKILL +// || CHAR_getWorkInt( charaindex, CHAR_DOOMTIME ) > 0 //ĩռ +#endif + ) + { + +// char cdkey[128]; +// if( CHAR_getInt( charaindex, CHAR_WHICHTYPE) == CHAR_TYPEPLAYER) +// strcpysafe( cdkey,sizeof(cdkey), CHAR_getChar( charaindex, CHAR_CDKEY)); +// else +// strcpysafe( cdkey,sizeof(cdkey), CHAR_getChar( charaindex, CHAR_OWNERCDKEY) ); + +// print("\n ķ!ս״̬!!:%s ", cdkey ); + + return 1; + } + return 0; +} + diff --git a/battle/battle_event.c b/battle/battle_event.c new file mode 100644 index 0000000..6122f88 --- /dev/null +++ b/battle/battle_event.c @@ -0,0 +1,10080 @@ +#include "version.h" +#include +#include +#include "char.h" +#include "char_event.h" +#include "battle.h" +#include "battle_event.h" +#include "configfile.h" +#include "pet.h" +#include "log.h" +#include "lssproto_serv.h" +#include "anim_tbl.h" +#include "battle_magic.h" +#include "util.h" +#include "enemy.h" +#include "pet_skill.h" +#include "char_base.h" +#include "item_event.h" + +#ifdef _PROFESSION_SKILL // WON ADD ְҵ +#include "profession_skill.h" +#include "item.h" +#include "skill.h" +#endif +#ifdef _PETSKILL_LER +#include "magic_base.h" +#endif +#ifdef _ALLBLUES_LUA +#include "mylua/function.h" +#endif +#define DEFENSE_RATE (0.5) +#define DAMAGE_RATE (2.0) +#define CRITICAL_RATE (1.0) +#define KAWASHI_MAX_RATE (75) + +#define AJ_SAME (1.0) + +#define AJ_UP (1.5) +#define AJ_DOWN (0.6) + +#define ATTR_MAX 100 +#define D_ATTR (1.0/(ATTR_MAX*ATTR_MAX)) + +#define D_16 (1.0/16) +#define D_8 (1.0/8) + +float gKawashiPara = 0.02; +float gCounterPara = 0.08; +float gCriticalPara = 0.09; + +float gBattleDamageModyfy; +int gBattleDuckModyfy; +int gBattleStausChange; +int gBattleStausTurn; +float gDuckPer; +int gCriper; + +int gBattleBadStatusTbl[BATTLE_ENTRY_MAX*2]; + +#ifdef _OTHER_MAGICSTAUTS +#ifdef _MAGICSTAUTS_RESIST +char MagicStatus[MAXSTATUSTYPE][36] = { "NULL","ħ","","","翹",""}; +int MagicTbl[] = { -1, CHAR_DEFMAGICSTATUS, CHAR_MAGICSUPERWALL, CHAR_MAGICFIRE, CHAR_MAGICTHUNDER, CHAR_MAGICICE }; +#else +char MagicStatus[MAXSTATUSTYPE][36] = { "NULL","ħ",""}; +int MagicTbl[] = { -1, CHAR_DEFMAGICSTATUS, CHAR_MAGICSUPERWALL }; +#endif //_MAGICSTAUTS_RESIST +#endif + +char *aszStatus[] = { "ȫ", "", "", "", "ʯ", "", "", "", "", "", "Ĭ" +#ifdef _PET_SKILL_SARS // WON ADD ɷ + ,"ɷ" +#endif +#ifdef _PROFESSION_SKILL // WON ADD ְҵ + ,"","","","","","","","","","","˪","","ר","","","","","","" +#endif +#ifdef _PROFESSION_ADDSKILL + ,"" +#endif +}; + +char *aszStatusFull[] = { "ȫ", "", "", "˯", "ʯ", "", "", "", "綾", "ħ", "Ĭ" +#ifdef _PET_SKILL_SARS // WON ADD ɷ + ,"ɷ" +#endif +#ifdef _PROFESSION_SKILL // WON ADD ְҵ + ,"ѣ","","","","","","Ѫ","һѪ","","", + "","׸","רעս","","","׿","","","׸" +#endif +}; + +int StatusTbl[] = { -1, CHAR_WORKPOISON, CHAR_WORKPARALYSIS, + CHAR_WORKSLEEP, CHAR_WORKSTONE, + CHAR_WORKDRUNK, CHAR_WORKCONFUSION, + CHAR_WORKWEAKEN, CHAR_WORKDEEPPOISON, + CHAR_WORKBARRIER, CHAR_WORKNOCAST +#ifdef _PET_SKILL_SARS // WON ADD ɷ + ,CHAR_WORKSARS +#endif +#ifdef _PROFESSION_SKILL // WON ADD ְҵ + ,CHAR_WORKDIZZY, CHAR_WORKENTWINE + ,CHAR_WORKDRAGNET, CHAR_WORKICECRACK + ,CHAR_WORKOBLIVION, CHAR_WORKICEARROW + ,CHAR_WORKBLOODWORMS, CHAR_WORKSIGN + ,CHAR_WORKINSTIGATE, CHAR_WORK_F_ENCLOSE + ,CHAR_WORK_I_ENCLOSE, CHAR_WORK_T_ENCLOSE + ,CHAR_WORK_FOCUS, CHAR_WORKRESIST_F + ,CHAR_WORKRESIST_I, CHAR_WORKRESIST_T + ,CHAR_WORK_F_ENCLOSE_2, CHAR_WORK_I_ENCLOSE_2 + ,CHAR_WORK_T_ENCLOSE_2 +#endif +#ifdef _PROFESSION_ADDSKILL + ,CHAR_WORKERSIST_F_I_T, CHAR_WORKWATER//ˮ + ,CHAR_WORKANNEX// + ,CHAR_WORKFEAR//־ + ,CHAR_WORKICECRACK2 + ,CHAR_WORKICECRACK3 + ,CHAR_WORKICECRACK4 + ,CHAR_WORKICECRACK5 + ,CHAR_WORKICECRACK6 + ,CHAR_WORKICECRACK7 + ,CHAR_WORKICECRACK8 + ,CHAR_WORKICECRACK9 + ,CHAR_WORKICECRACK10 +#endif + }; + +int RegTbl[] = { -1, CHAR_WORKMODPOISON, CHAR_WORKMODPARALYSIS, + CHAR_WORKMODSLEEP, CHAR_WORKMODSTONE, + CHAR_WORKMODDRUNK, CHAR_WORKMODCONFUSION, + CHAR_WORKMODWEAKEN, CHAR_WORKMODDEEPPOISON, + CHAR_WORKMODBARRIER, CHAR_WORKMODNOCAST +#ifdef _PET_SKILL_SARS // WON ADD ɷ + ,CHAR_WORKMODSARS +#endif +#ifdef _PROFESSION_SKILL // WON ADD ְҵ + ,CHAR_WORKMODDIZZY, CHAR_WORKMODENTWINE + ,CHAR_WORKMODDRAGNET, CHAR_WORKMODICECRACK + ,CHAR_WORKMODOBLIVION, CHAR_WORKMODICEARROW + ,CHAR_WORKMODBLOODWORMS, CHAR_WORKMODSIGN + ,CHAR_WORKMODINSTIGATE, CHAR_WORKMOD_F_ENCLOSE + ,CHAR_WORKMOD_I_ENCLOSE, CHAR_WORKMOD_T_ENCLOSE + ,CHAR_WORKMOD_FOCUS, CHAR_WORKMODRESIST_F + ,CHAR_WORKMODRESIST_I, CHAR_WORKMODRESIST_T + ,CHAR_WORKMOD_F_ENCLOSE_2, CHAR_WORKMOD_I_ENCLOSE_2 + ,CHAR_WORKMOD_T_ENCLOSE_2 +#endif + }; + +char *aszMagicDef[] = { "", "", "", "" +#ifdef _PROFESSION_SKILL // WON ADD ְҵ + ,"" +#endif +#ifdef _PETSKILL_ACUPUNCTURE + ,"" +#endif +}; + + + +char *aszMagicDefFull[] = { "ͨ", "", "", "Ч" +#ifdef _PROFESSION_SKILL // WON ADD ְҵ + ,"" +#endif +#ifdef _PETSKILL_ACUPUNCTURE + ,"" +#endif +}; + + +int MagicDefTbl[] = { -1, CHAR_WORKDAMAGEABSROB, CHAR_WORKDAMAGEREFLEC, CHAR_WORKDAMAGEVANISH +#ifdef _PROFESSION_SKILL // WON ADD ְҵ + ,CHAR_WORKTRAP +#endif +#ifdef _PETSKILL_ACUPUNCTURE + ,CHAR_WORKACUPUNCTURE +#endif +}; + +char *aszParamChange[] = { "", "", "", "", "", "" }; +char *aszParamChangeFull[] = { "", "", "", "ٶ", "", "" }; +int aParamChangeTbl[] = { -1, CHAR_WORKMODATTACK, CHAR_WORKMODDEFENCE, + CHAR_WORKMODQUICK, CHAR_WORKMODCHARM, CHAR_WORKMODCAPTURE }; + +// Robin 0727 Ride Pet +// ȡindex +int BATTLE_getRidePet( int charaindex ) +{ + int petindex = -1; + + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER && CHAR_getInt( charaindex, CHAR_WHICHTYPE ) != CHAR_TYPEPLAYERNPC ) + return -1; + else + { + int rideIndex = CHAR_getInt( charaindex, CHAR_RIDEPET ); + if( rideIndex == -1 ) + return -1; + petindex = CHAR_getCharPet( charaindex, rideIndex ); + if( !CHAR_CHECKINDEX( petindex ) ) return -1; + + } + + return petindex; + +} + +// ȡʱΧ +float BATTLE_adjustRidePet3A( int charaindex, int petindex, int workindex, int action ) +{ + float ret = CHAR_getWorkInt( charaindex, workindex ); + BOOL throwweapon = BATTLE_IsThrowWepon(CHAR_getItemIndex( charaindex, CHAR_ARM ) ); + + switch( workindex ) { + case CHAR_WORKATTACKPOWER : // + if( throwweapon ) // Ͷ + ret = CHAR_getWorkInt( charaindex, CHAR_WORKATTACKPOWER ) +#ifdef _BATTLE_NEWPOWER //andy 1/24 reEdit + + CHAR_getWorkInt( petindex, CHAR_WORKATTACKPOWER )*0.4; +#else + + CHAR_getWorkInt( petindex, CHAR_WORKATTACKPOWER )*0.2; +#endif + else // ս + ret = CHAR_getWorkInt( charaindex, CHAR_WORKATTACKPOWER )*0.8 + + CHAR_getWorkInt( petindex, CHAR_WORKATTACKPOWER )*0.8; + break; + case CHAR_WORKDEFENCEPOWER : // + ret = CHAR_getWorkInt( charaindex, CHAR_WORKDEFENCEPOWER )*0.7 + + CHAR_getWorkInt( petindex, CHAR_WORKDEFENCEPOWER )*0.7; + break; + case CHAR_WORKQUICK : // + if( action == ATTACKSIDE ) { + if( throwweapon ) { + ret = CHAR_getWorkInt( charaindex, CHAR_WORKQUICK )*0.8 + + CHAR_getWorkInt( petindex, CHAR_WORKQUICK )*0.2; + }else { +#ifdef _BATTLE_NEWPOWER //andy 1/24 reEdit + ret = CHAR_getWorkInt( charaindex, CHAR_WORKQUICK )*0.2 + + CHAR_getWorkInt( petindex, CHAR_WORKQUICK )*0.8; + +#else + ret = CHAR_getWorkInt( charaindex, CHAR_WORKQUICK )*0.5 + + CHAR_getWorkInt( petindex, CHAR_WORKQUICK )*0.5; +#endif + } + }else + if( action == DEFFENCESIDE ){ + ret = CHAR_getWorkInt( charaindex, CHAR_WORKQUICK )*0.1 + + CHAR_getWorkInt( petindex, CHAR_WORKQUICK )*0.9; + } + break; + default : + ret = CHAR_getWorkInt( charaindex, workindex ); + } + + //print(" adj3A_Now:%d:%d=%f ", charaindex, workindex, ret); + + return ret; +} + +// Robin 0727 ride Pet ͼ +void BATTLE_changeRideImage( int index ) +{ + int itemindex = CHAR_getItemIndex(index,CHAR_ARM); + int category; + int newimagenumber; + int basebaseimagenumber + = CHAR_getInt(index,CHAR_BASEBASEIMAGENUMBER); + if( !ITEM_CHECKINDEX(itemindex) ) { + category = ITEM_FIST; + }else { + category = ITEM_getInt(itemindex,ITEM_TYPE ); + } + newimagenumber = CHAR_getNewImagenumberFromEquip( + basebaseimagenumber, category); + if( newimagenumber == -1) { + CHAR_setInt( index, CHAR_BASEIMAGENUMBER, basebaseimagenumber); + }else { + CHAR_setInt( index, CHAR_BASEIMAGENUMBER, newimagenumber); + } +} + +void BATTLE_talkToCli( + int charaindex, + char *pszBuffer, + int color +) +{ + if( getBattleDebugMsg( ) != 0 + && CHAR_getFlg( charaindex, CHAR_ISSHOWBATTLEMSG ) + ){ + CHAR_talkToCli( charaindex, -1, pszBuffer, color ); + } +} + + +int BATTLE_BroadCastBase( + int battleindex, + char *pszBuffer, + int color, + int flg +) +{ + int i, j, pindex; + BATTLE_ENTRY *pEntry; + + if( flg != 1 && getBattleDebugMsg( ) == 0 )return 0; + + if( BATTLE_CHECKINDEX( battleindex ) == FALSE )return BATTLE_ERR_BATTLEINDEX; + + for( j = 0; j < 2; j ++ ){ + pEntry = BattleArray[battleindex].Side[j].Entry; + for( i = 0; i < BATTLE_ENTRY_MAX; i ++ ){ + pindex = pEntry[i].charaindex; + if( CHAR_CHECKINDEX( pindex ) == FALSE )continue; + if( CHAR_getInt( pindex, CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER )continue; + if( CHAR_getFlg( pindex, CHAR_ISSHOWBATTLEMSG ) == FALSE ) continue; + CHAR_talkToCli( pindex, -1, pszBuffer, color ); + } + } + + return 0; +} + +// Nuke 20040112 fix for performance +/*int BATTLE_BroadCast( + int battleindex, + char *pszBuffer, + int color +) +{ + return BATTLE_BroadCastBase( battleindex, pszBuffer, color, 0 ); + +} + +int BATTLE_BroadCastOn( + int battleindex, + char *pszBuffer, + int color +) +{ + return BATTLE_BroadCastBase( battleindex, pszBuffer, color, 1 ); +} +*/ + +#ifdef _TAKE_ITEMDAMAGE +int BATTLE_ItemCrushCheck( int charaindex , int flg) +{//flg def 1 att 2 + int EquipTbl[CHAR_EQUIPPLACENUM], itemindex; + int i, rndwork; + int Crushs=0; + //char szBuffer[256]; + + memset( EquipTbl, -1, sizeof( EquipTbl)); + if( flg == 2 ) { + itemindex = CHAR_getItemIndex( charaindex, CHAR_ARM); + if( ITEM_CHECKINDEX( itemindex) == TRUE ) { + return CHAR_ARM; + } + return -1; + }else { + int equipnum; +#ifdef _TAKE_ITEMDAMAGE_FOR_PET + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE) == CHAR_TYPEPET){ + equipnum = CHAR_PETITEMNUM; + }else +#endif + equipnum = CHAR_EQUIPPLACENUM; +#ifdef _TAKE_ITEMDAMAGE_FIX + rndwork = rand() % equipnum; +#else + Crushs = rand()%100; + if( Crushs < 50 ) { + rndwork = CHAR_BODY; + }else if( Crushs >= 50 && Crushs < 67 ) { + rndwork = CHAR_HEAD; + }else if( Crushs >= 67 && Crushs < 84 ) { + rndwork = CHAR_DECORATION1; + }else { + rndwork = CHAR_DECORATION2; + } +#endif + for( i = 0; i < equipnum; i ++ ){//CHAR_ARM + itemindex = CHAR_getItemIndex( charaindex, rndwork); + if( ITEM_CHECKINDEX( itemindex) == TRUE && rndwork != CHAR_ARM ){ + return rndwork; + }else { + rndwork++; + rndwork=rndwork%5; + } + } + } + + return -1; +} +#else +int BATTLE_ItemCrushCheck( int charaindex ) +{ + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER ){ + return FALSE; + } + if( RAND( 1, gItemCrushRate ) < CHAR_getInt( charaindex, CHAR_LV ) ){ + return TRUE; + }else{ + return FALSE; + } +} +#endif + +#define BREAK_NAME_WEPON "" +#define BREAK_NAME_AROMER "" +#define BREAK_BRACELET "" +#define BREAK_MUSIC "" +#define BREAK_NECKLACE "ͷ" +#define BREAK_RING "ָ" +#define BREAK_BELT "Ƥ" +#define BREAK_EARRING "" +#define BREAK_NOSERING "ǻ" +#define BREAK_AMULET "" +#define BREAK_OTHER "" + +#ifdef _TAKE_ITEMDAMAGE +static char *aszCrushTbl[] = { "", "", "ٻ" , "ʹ" , "Ƭ" }; +#else +static char *aszCrushTbl[] = { "", "ٻ" }; +#endif + + +#ifdef _TAKE_ITEMDAMAGE +int BATTLE_ItemCrush( int charaindex, int ItemEquip, int Damages, int flg) +{ + int itemindex, breadnums; + int crushlevel, crushenum, maxcrushenum; + char szBuffer[256]=""; + int battleindex, bid; + + itemindex = CHAR_getItemIndex( charaindex, ItemEquip ); + if( ITEM_CHECKINDEX( itemindex ) == FALSE ) + return -1; + battleindex = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEINDEX ); + + bid = BATTLE_Index2No( battleindex, charaindex ); + + crushlevel = ITEM_getInt( itemindex, ITEM_CRUSHLEVEL); + if( crushlevel < 0 ) crushlevel=0; + + crushenum = ITEM_getInt( itemindex, ITEM_DAMAGECRUSHE); + maxcrushenum = ITEM_getInt( itemindex, ITEM_MAXDAMAGECRUSHE); + if( maxcrushenum < 1 ) return -1; + if( ItemEquip == CHAR_ARM ) { + if( (breadnums = ((Damages-50)/40)) <= 0 ) + breadnums = 1; + }else { + if( Damages >= 200 ) breadnums = 1; + if( (breadnums = ((200 - Damages)/20)) < 0 ) + breadnums = 1; + } + crushenum = crushenum - RAND( breadnums, (breadnums*1.4) ); + ITEM_setInt( itemindex, ITEM_DAMAGECRUSHE, crushenum); + + if( crushenum <= 0 ){ //ʧ + crushenum = 0; + sprintf(szBuffer, "%s𻵶ʧ\n", ITEM_getChar( itemindex, ITEM_NAME)); + CHAR_talkToCli( charaindex, -1, szBuffer, CHAR_COLORYELLOW); + +// LogItem( +// CHAR_getChar( charaindex, CHAR_NAME ), +// CHAR_getChar( charaindex, CHAR_CDKEY ), +//#ifdef _add_item_log_name // WON ADD itemlogitem +// itemindex, +//#else +// ITEM_getInt( itemindex, ITEM_ID ), +//#endif +// "𻵶ʧ", +// CHAR_getInt( charaindex,CHAR_FLOOR), +// CHAR_getInt( charaindex,CHAR_X ), +// CHAR_getInt( charaindex,CHAR_Y ), +// ITEM_getChar( itemindex, ITEM_UNIQUECODE), +// ITEM_getChar( itemindex, ITEM_NAME), +// ITEM_getInt( itemindex, ITEM_ID) +// ); + CHAR_DelItem( charaindex, ItemEquip); + crushlevel = 4; + }else { //𻵿ֵ + int defs, level=0; + + + defs = (crushenum*100)/maxcrushenum; + + if( defs >= 70 ){ + level = 0; + }else if( defs >= 50 && defs < 70 ) { + level = 1; + }else if( defs >= 30 && defs < 50 ) { + level = 2; + }else if( defs < 30 ) { + level = 3; + } + + if( level != crushlevel && defs < 70 ) { + ITEM_setInt( itemindex, ITEM_CRUSHLEVEL, level); +// for( i = 0; i < arraysizeof( ItemBreakPos ); i ++ ){ +// work = ITEM_getInt( itemindex, ItemBreakPos[i] ); +// if( work <= 0 )continue; +// work *=0.95; +// ITEM_setInt( itemindex, ItemBreakPos[i], work ); +// } + sprintf( szBuffer, "%s%sġ", + ITEM_getChar( itemindex, ITEM_NAME ), aszCrushTbl[level] ); + CHAR_talkToCli( charaindex, -1, szBuffer, CHAR_COLORRED); + //ĵ˵ +// buf1 = ITEM_getChar( itemindex, ITEM_SECRETNAME); +// if( strstr( buf1, "(") != 0 ) { +// char buf5[256]; +// if( getStringFromIndexWithDelim( buf1,"(",1, buf5, sizeof( buf5)) != FALSE ) { +// sprintf( buf1, buf5); +// } +// } +// sprintf( buf2, "%s(%s)", buf1, aszCrushTbl[level]); +// ITEM_setChar( itemindex, ITEM_SECRETNAME, buf2); + } + } + + CHAR_sendItemDataOne( charaindex, ItemEquip ); +#ifdef _ATTREVERSE_FIX + if(getAttReverse()==1){ + //if(CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEFLG ) & CHAR_BATTLEFLG_REVERSE){ + if(CHAR_getWorkInt(charaindex,CHAR_WORKBATTLEREVERSE)==1){ + CHAR_complianceParameter2(charaindex); + }else{ +#endif + CHAR_complianceParameter( charaindex ); +#ifdef _ATTREVERSE_FIX + } + }else{ + CHAR_complianceParameter( charaindex ); + } +#endif + CHAR_send_P_StatusString( charaindex, CHAR_P_STRING_ATK | CHAR_P_STRING_DEF + | CHAR_P_STRING_QUICK | CHAR_P_STRING_CHARM ); + + return TRUE; +} +#else +int BATTLE_ItemCrush( int charaindex ) +{ + int EquipTbl[CHAR_EQUIPPLACENUM], i, itemindex, rndwork, type; + int work, crushlevel, j, ItemEquip; + char szBuffer[256]=""; + + int ItemBreakPos[] = { + ITEM_ATTACKNUM_MIN, + ITEM_ATTACKNUM_MAX, + ITEM_MODIFYATTACK, + ITEM_MODIFYDEFENCE, + ITEM_MODIFYQUICK, + ITEM_MODIFYHP, + ITEM_MODIFYMP, + ITEM_MODIFYLUCK, + ITEM_MODIFYCHARM, + ITEM_MODIFYAVOID, + }; + + for( j = 0, i = 0; i < CHAR_EQUIPPLACENUM; i ++ ){ + itemindex = CHAR_getItemIndex( charaindex, i ); + if( ITEM_CHECKINDEX( itemindex ) == TRUE + && ITEM_getInt( itemindex, ITEM_MERGEFLG ) == 1 ){ + EquipTbl[j] = i; + j ++; + } + } + if( j == 0 )return FALSE; + rndwork = RAND( 0, j-1 ); + ItemEquip = EquipTbl[rndwork]; + itemindex = CHAR_getItemIndex( charaindex, ItemEquip ); + if( ITEM_CHECKINDEX( itemindex ) == FALSE )return FALSE; + crushlevel = ITEM_getInt( itemindex, ITEM_CRUSHLEVEL ); + if( crushlevel > 1 ) return FALSE; + { + if( crushlevel == 1 ){ + sprintf( szBuffer, "CrushLv2(ٻLv2)" ); + }else{ + sprintf( szBuffer, "CrushLv1(ٻLv1)" ); + } +// LogItem( +// CHAR_getChar( charaindex, CHAR_NAME ), +// CHAR_getChar( charaindex, CHAR_CDKEY ), +//#ifdef _add_item_log_name // WON ADD itemlogitem +// itemindex, +//#else +// ITEM_getInt( itemindex, ITEM_ID ), +//#endif +// szBuffer, +// CHAR_getInt( charaindex,CHAR_FLOOR), +// CHAR_getInt( charaindex,CHAR_X ), +// CHAR_getInt( charaindex,CHAR_Y ), +// ITEM_getChar( itemindex, ITEM_UNIQUECODE), +// ITEM_getChar( itemindex, ITEM_NAME), +// ITEM_getInt( itemindex, ITEM_ID) +// +// ); + } + + /*{ int battleindex, bid; + //sprintf( szBuffer, "(%s)(%s)(%s)\n", + // CHAR_getUseName( charaindex ), + // ITEM_getChar( itemindex, ITEM_NAME ), + // aszCrushTbl[crushlevel] ); + + battleindex = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEINDEX ); + + bid = BATTLE_Index2No( battleindex, charaindex ); + //BATTLE_BroadCast( battleindex, szBuffer, + (bid >= 10)? CHAR_COLORGRAY : CHAR_COLORPURPLE ) ; + }*/ + + type = ITEM_getInt( itemindex, ITEM_TYPE ); + szBuffer[0] = 0; + switch( type ){ + case ITEM_FIST: + case ITEM_AXE: + case ITEM_CLUB: + case ITEM_SPEAR: + case ITEM_BOW: + case ITEM_BOOMERANG: + case ITEM_BOUNDTHROW: + case ITEM_BREAKTHROW: + sprintf( szBuffer, "%s%s", aszCrushTbl[crushlevel], BREAK_NAME_WEPON ); + break; + + case ITEM_HELM: + case ITEM_ARMOUR: + sprintf( szBuffer, "%s%s", aszCrushTbl[crushlevel], BREAK_NAME_AROMER ); + break; + + case ITEM_BRACELET: sprintf( szBuffer, "%s%s", aszCrushTbl[crushlevel], BREAK_BRACELET );break; + case ITEM_MUSIC: sprintf( szBuffer, "%s%s", aszCrushTbl[crushlevel], BREAK_MUSIC );break; + case ITEM_NECKLACE: sprintf( szBuffer, "%s%s", aszCrushTbl[crushlevel], BREAK_NECKLACE );break; + case ITEM_RING: sprintf( szBuffer, "%s%s", aszCrushTbl[crushlevel], BREAK_RING );break; + case ITEM_BELT: sprintf( szBuffer, "%s%s", aszCrushTbl[crushlevel], BREAK_BELT );break; + case ITEM_EARRING: sprintf( szBuffer, "%s%s", aszCrushTbl[crushlevel], BREAK_EARRING );break; + case ITEM_NOSERING: sprintf( szBuffer, "%s%s", aszCrushTbl[crushlevel], BREAK_NOSERING );break; + case ITEM_AMULET: sprintf( szBuffer, "%s%s", aszCrushTbl[crushlevel], BREAK_AMULET );break; + case ITEM_OTHER: sprintf( szBuffer, "%s%s", aszCrushTbl[crushlevel], BREAK_OTHER );break; + default: + sprintf( szBuffer, "%s%s", aszCrushTbl[crushlevel], BREAK_OTHER );break; + break; + } + ITEM_setChar( itemindex, ITEM_SECRETNAME, szBuffer ); + + for( i = 0; i < arraysizeof( ItemBreakPos ); i ++ ){ + work = ITEM_getInt( itemindex, ItemBreakPos[i] ); + if( work <= 0 )continue; + if( crushlevel == 1 ){ + work = 1; + }else{ + work /= 2; + if( work < 1 ) work = 1; + } + ITEM_setInt( itemindex, ItemBreakPos[i], work ); + } + CHAR_sendItemDataOne( charaindex, ItemEquip ); + ITEM_setInt( itemindex, ITEM_CRUSHLEVEL, crushlevel + 1 ); + CHAR_complianceParameter( charaindex ); + CHAR_send_P_StatusString( charaindex, + CHAR_P_STRING_ATK + | CHAR_P_STRING_DEF + | CHAR_P_STRING_QUICK + | CHAR_P_STRING_CHARM ); + + return TRUE; +} +#endif + +#ifdef _TAKE_ITEMDAMAGE +static int BATTLE_ItemCrushSeq( int attackindex, int charaindex, int Damages) +{ + int iRet = FALSE; + int crushindex=-1, crushpower; + int flg=0;//flg def 1 att 2 + + flg=1; + if( ( crushindex = BATTLE_ItemCrushCheck( charaindex, flg) ) >= 0 ) { + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE) == CHAR_TYPEPLAYER +#ifdef _TAKE_ITEMDAMAGE_FOR_PET + || CHAR_getInt( charaindex, CHAR_WHICHTYPE) == CHAR_TYPEPET +#endif + ){ + crushpower = CHAR_getWorkInt( attackindex, CHAR_WORKATTACKPOWER); + BATTLE_ItemCrush( charaindex, crushindex, Damages, flg); + } + } + flg=2; + if( ( crushindex = BATTLE_ItemCrushCheck( attackindex, flg) ) >= 0 ) { + if( CHAR_getInt( attackindex, CHAR_WHICHTYPE) == CHAR_TYPEPLAYER +#ifdef _TAKE_ITEMDAMAGE_FOR_PET + || CHAR_getInt( attackindex, CHAR_WHICHTYPE) == CHAR_TYPEPET +#endif + ){ + crushpower = CHAR_getWorkInt( charaindex, CHAR_WORKDEFENCEPOWER); + BATTLE_ItemCrush( attackindex, crushindex, Damages, flg); + } + } + + return iRet; +} + +#else + +static int BATTLE_ItemCrushSeq( int charaindex ) +{ + char szWork[256]; + int iRet = FALSE; + + if( BATTLE_ItemCrushCheck( charaindex ) == TRUE ){ + if( BATTLE_ItemCrush( charaindex ) == TRUE ){ + sprintf( szWork, "BK|%s\tװܵˡ", + CHAR_getUseName( charaindex ) ); + strcatsafe( szBadStatusString,sizeof(szBadStatusString), szWork ); + iRet = TRUE; + } + } + return iRet; +} +#endif + +#ifdef _EQUIT_ARRANGE +static BOOL BATTLE_ArrangeCheck( int attackindex, int defindex) +{ + int DEF_ARR; + if( CHAR_getWorkInt( defindex, CHAR_WORKBATTLECOM1 ) == BATTLE_COM_GUARD ){ + return FALSE; + } + if( BATTLE_GetDamageReact( defindex ) > 0 ){ + return FALSE; + } + if( BATTLE_CanMoveCheck( defindex ) == FALSE ){ + return FALSE; + } + if( CHAR_getWorkInt( defindex, CHAR_WORKBATTLEFLG ) & CHAR_BATTLEFLG_NODUCK ){ + return FALSE; + } + if( CHAR_getWorkInt( defindex, CHAR_WORKBATTLEFLG ) & CHAR_BATTLEFLG_ABIO ){ + return FALSE; + } + if( (DEF_ARR = CHAR_getWorkInt( defindex, CHAR_WORKARRANGEPOWER )) > 0 ){ + int per = (DEF_ARR > 700)?700:DEF_ARR; + if( RAND( 1, 1000 ) <= per ){ + return TRUE; + } + } + + return FALSE; +} +#endif + +//رж +static BOOL BATTLE_DuckCheck( + int attackindex, + int defindex +) +{ + int flg = FALSE; + + int Df_Dex, At_Dex, Df_Luck = 0; + float per, Work, wari, Big, Small; + + gDuckPer = 0; + if( CHAR_getWorkInt( defindex, CHAR_WORKBATTLECOM1 ) == BATTLE_COM_GUARD ){ + return FALSE; + } + if( BATTLE_GetDamageReact( defindex ) > 0 ){ + return FALSE; + } + if( BATTLE_CanMoveCheck( defindex ) == FALSE ){ +#ifdef _PROFESSION_ADDSKILL + if( CHAR_getWorkInt( defindex, CHAR_DOOMTIME ) <= 0 )//ʱ(ûд޵Ͷܻ״̬) + return FALSE; + else{ + if( CHAR_getWorkInt( defindex, CHAR_WORKDRAGNET ) == 0 + && CHAR_getWorkInt( defindex, CHAR_WORKDIZZY ) == 0 ){ + } + else{ + return FALSE; + } + } +#else + return FALSE; +#endif + } + + if( CHAR_getWorkInt( defindex, CHAR_WORKBATTLEFLG ) & CHAR_BATTLEFLG_NODUCK ){ + return FALSE; + } + if( CHAR_getWorkInt( defindex, CHAR_WORKBATTLEFLG ) & CHAR_BATTLEFLG_ABIO ){ + return FALSE; + } + +#ifdef _PETSKILL_SETDUCK + if( BATTLE_CheckMySkillDuck( defindex ) == TRUE ){ + return TRUE; + } +#endif + + At_Dex = CHAR_getWorkInt( attackindex, CHAR_WORKFIXDEX ); + Df_Dex = CHAR_getWorkInt( defindex, CHAR_WORKFIXDEX ); + if( CHAR_getInt( defindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER ){ + Df_Luck = CHAR_getWorkInt( defindex, CHAR_WORKFIXLUCK ); + } + if( CHAR_getInt( attackindex, CHAR_WHICHTYPE ) == CHAR_TYPEENEMY + && CHAR_getInt( defindex, CHAR_WHICHTYPE ) == CHAR_TYPEPET ){ + At_Dex *= 0.8; + }else + if( CHAR_getInt( attackindex, CHAR_WHICHTYPE ) != CHAR_TYPEENEMY + && CHAR_getInt( defindex, CHAR_WHICHTYPE ) == CHAR_TYPEPET + ){ + Df_Dex *= 0.8; + }else + if( CHAR_getInt( attackindex, CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER + && CHAR_getInt( defindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER ){ + At_Dex *= 0.6; + }else + if( CHAR_getInt( attackindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER + && CHAR_getInt( defindex, CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER ){ + Df_Dex *= 0.6; + } + + if( Df_Dex >= At_Dex ){ + Big = Df_Dex; + Small = At_Dex; + wari = 1.0; + }else{ + Big = At_Dex; + Small = Df_Dex; + if( Big <= 0 ){ + wari = 0.0; + }else{ + wari = Small / Big; + } + } + if( CHAR_getWorkInt( defindex, CHAR_WORKBATTLECOM1 ) == BATTLE_COM_JYUJYUTU ){ + gKawashiPara = 0.027; + }else{ + gKawashiPara = 0.02; + } + Work = ( Big - Small ) / gKawashiPara; + if( Work <= 0 ) Work = 0; + per = (float)( sqrt( (double)Work ) ); + per *= wari; + per += Df_Luck; + + per += gBattleDuckModyfy; + if( CHAR_getWorkInt( attackindex, CHAR_WORKDRUNK ) > 0 ){ + per += RAND( 20, 30 ); + } + if( gWeponType == ITEM_BOW ){ + per += 20; + } + if( CHAR_getWorkInt( defindex, CHAR_WORKBATTLECOM1 ) == BATTLE_COM_S_NOGUARD ){ + per += CHAR_GETWORKINT_HIGH( defindex, CHAR_WORKBATTLECOM3 ); + } + + if( gWeponType == ITEM_BOW ){ + per += 20; + } + + per *= 100; + if( per > KAWASHI_MAX_RATE*100 ) per = KAWASHI_MAX_RATE*100; + if( per <= 0 ) per = 1; + + gDuckPer = per * 0.01; +#ifdef _EQUIT_HITRIGHT + if( CHAR_getInt( attackindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER ){ + int AddHit = CHAR_getWorkInt( attackindex, CHAR_WORKHITRIGHT); + per -= RAND( AddHit*0.8, AddHit*1.2); + per = ( per < 0 )?0:per; + } +#endif + + +#ifdef _PROFESSION_SKILL // WON ADD ְҵ + per = BATTLE_check_profession_duck( defindex, per ); +#endif + +#ifdef _PROFESSION_ADDSKILL + if( CHAR_getWorkInt( attackindex, CHAR_WORKBATTLECOM1 ) == BATTLE_COM_S_CHAOS ){ //ҹʱн + per += (per*0.4); + } +#endif + + if( RAND( 1, 10000 ) <= per ){ + flg = TRUE; +#ifdef _PROFESSION_SKILL // WON ADD ְҵ + // رܼ + if( (CHAR_getInt( defindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER) ){ + PROFESSION_SKILL_LVEVEL_UP( defindex, "PROFESSION_AVOID" ); + } +#endif + }else{ + flg = FALSE; + } + return flg; +} + +static int BATTLE_AttrCalc( + int My_Fire, + int My_Water, + int My_Earth, + int My_Wind, + int My_None, + int Vs_Fire, + int Vs_Water, + int Vs_Earth, + int Vs_Wind, + int Vs_None +) +{ + int iRet = 0; + My_Fire = My_Fire * Vs_None * AJ_UP + + My_Fire * Vs_Fire * AJ_SAME + + My_Fire * Vs_Water * AJ_DOWN + + My_Fire * Vs_Earth * AJ_SAME + + My_Fire * Vs_Wind * AJ_UP; + My_Water = My_Water * Vs_None * AJ_UP + + My_Water * Vs_Fire * AJ_UP + + My_Water * Vs_Water * AJ_SAME + + My_Water * Vs_Earth * AJ_DOWN + + My_Water * Vs_Wind * AJ_SAME; + + My_Earth = My_Earth * Vs_None * AJ_UP + + My_Earth * Vs_Fire * AJ_SAME + + My_Earth * Vs_Water * AJ_UP + + My_Earth * Vs_Earth * AJ_SAME + + My_Earth * Vs_Wind * AJ_DOWN; + + My_Wind = My_Wind * Vs_None * AJ_UP + + My_Wind * Vs_Fire * AJ_DOWN + + My_Wind * Vs_Water * AJ_SAME + + My_Wind * Vs_Earth * AJ_UP + + My_Wind * Vs_Wind * AJ_SAME; + + My_None = My_None * Vs_None * AJ_SAME + + My_None * Vs_Fire * AJ_DOWN + + My_None * Vs_Water * AJ_DOWN + + My_None * Vs_Earth * AJ_DOWN + + My_None * Vs_Wind * AJ_DOWN; + + iRet = (My_Fire + My_Water + My_Earth + My_Wind + My_None) ; + return (iRet * D_ATTR); +} + +static void BATTLE_GetAttr( int charaindex, int *T_pow ) +{ +#ifdef _BATTLE_NEWPOWER +#else + int petindex = BATTLE_getRidePet( charaindex ); + if( petindex == -1 ){ +#endif + T_pow[0] = CHAR_getWorkInt( charaindex, CHAR_WORKFIXEARTHAT ); + T_pow[1] = CHAR_getWorkInt( charaindex, CHAR_WORKFIXWATERAT ); + T_pow[2] = CHAR_getWorkInt( charaindex, CHAR_WORKFIXFIREAT ); + T_pow[3] = CHAR_getWorkInt( charaindex, CHAR_WORKFIXWINDAT ); +/* + *pAt_Fire = CHAR_getWorkInt( charaindex, CHAR_WORKFIXFIREAT ); + *pAt_Water = CHAR_getWorkInt( charaindex, CHAR_WORKFIXWATERAT ); + *pAt_Earth = CHAR_getWorkInt( charaindex, CHAR_WORKFIXEARTHAT ); + *pAt_Wind = CHAR_getWorkInt( charaindex, CHAR_WORKFIXWINDAT ); +*/ +#ifdef _BATTLE_NEWPOWER +#else + }else { // Robin 0727 when Ride Pet +#endif +#ifdef _BATTLE_NEWPOWER +#else + T_pow[0] = ( CHAR_getWorkInt( charaindex, CHAR_WORKFIXEARTHAT ) + + CHAR_getWorkInt( petindex, CHAR_WORKFIXEARTHAT )) /2; + T_pow[1] = ( CHAR_getWorkInt( charaindex, CHAR_WORKFIXWATERAT ) + + CHAR_getWorkInt( petindex, CHAR_WORKFIXWATERAT )) /2; + T_pow[2] = ( CHAR_getWorkInt( charaindex, CHAR_WORKFIXFIREAT ) + + CHAR_getWorkInt( petindex, CHAR_WORKFIXFIREAT )) /2; + T_pow[3] = ( CHAR_getWorkInt( charaindex, CHAR_WORKFIXWINDAT ) + + CHAR_getWorkInt( petindex, CHAR_WORKFIXWINDAT )) /2; +/* + *pAt_Fire = ( CHAR_getWorkInt( charaindex, CHAR_WORKFIXFIREAT ) + + CHAR_getWorkInt( petindex, CHAR_WORKFIXFIREAT )) /2; + *pAt_Water = ( CHAR_getWorkInt( charaindex, CHAR_WORKFIXWATERAT ) + + CHAR_getWorkInt( petindex, CHAR_WORKFIXWATERAT )) /2; + *pAt_Earth = ( CHAR_getWorkInt( charaindex, CHAR_WORKFIXEARTHAT ) + + CHAR_getWorkInt( petindex, CHAR_WORKFIXEARTHAT )) /2; + *pAt_Wind = ( CHAR_getWorkInt( charaindex, CHAR_WORKFIXWINDAT ) + + CHAR_getWorkInt( petindex, CHAR_WORKFIXWINDAT )) /2; +*/ + } +#endif + //print("\n1=%d,ˮ1=%d,1=%d,1=%d\n",T_pow[0],T_pow[1],T_pow[2],T_pow[3]); +#ifdef _PROFESSION_ADDSKILL + //Ͻ + //T_pow[0] += T_pow[0]*( (CHAR_getWorkInt( charaindex, CHAR_WORKFIXEARTHAT_BOUNDARY )>>16&0x0000ffff) /100 ); + //T_pow[1] += T_pow[1]*( (CHAR_getWorkInt( charaindex, CHAR_WORKFIXWATERAT_BOUNDARY )>>16&0x0000ffff) /100 ); + //T_pow[2] += T_pow[2]*( (CHAR_getWorkInt( charaindex, CHAR_WORKFIXFIREAT_BOUNDARY )>>16&0x0000ffff) /100 ); + //T_pow[3] += T_pow[3]*( (CHAR_getWorkInt( charaindex, CHAR_WORKFIXWINDAT_BOUNDARY )>>16&0x0000ffff) /100 ); +#endif +#ifdef _SUIT_TWFWENDUM + T_pow[0] = (T_pow[0]+CHAR_getWorkInt( charaindex, CHAR_WORK_EA ))>100?100:(T_pow[0]+CHAR_getWorkInt( charaindex, CHAR_WORK_EA )); + T_pow[1] = (T_pow[1]+CHAR_getWorkInt( charaindex, CHAR_WORK_WR ))>100?100:(T_pow[1]+CHAR_getWorkInt( charaindex, CHAR_WORK_EA )); + T_pow[2] = (T_pow[2]+CHAR_getWorkInt( charaindex, CHAR_WORK_FI ))>100?100:(T_pow[2]+CHAR_getWorkInt( charaindex, CHAR_WORK_EA )); + T_pow[3] = (T_pow[3]+CHAR_getWorkInt( charaindex, CHAR_WORK_WI ))>100?100:(T_pow[3]+CHAR_getWorkInt( charaindex, CHAR_WORK_EA )); +#endif + //print("\n2=%d,ˮ2=%d,2=%d,2=%d\n",T_pow[0],T_pow[1],T_pow[2],T_pow[3]); + { + int i, renum=ATTR_MAX; + for( i=0; i<4; i++) { + if( T_pow[ i] < 0 ) T_pow[ i] = 0; + renum -= T_pow[ i]; + } + if( renum < 0 ) renum = 0; + T_pow[ 4] = renum; + } + //print("\n2=%d,ˮ2=%d,2=%d,2=%d\n",T_pow[0],T_pow[1],T_pow[2],T_pow[3]); +/* + if( *pAt_Fire < 0 ) *pAt_Fire = 0; + if( *pAt_Water < 0 ) *pAt_Water = 0; + if( *pAt_Earth < 0 ) *pAt_Earth = 0; + if( *pAt_Wind < 0 ) *pAt_Wind = 0; + *pAt_None = ATTR_MAX - *pAt_Fire - *pAt_Water - *pAt_Earth - *pAt_Wind; + if( *pAt_None < 0 )*pAt_None = 0; +*/ +} + + +float BATTLE_FieldAttAdjust( + int battleindex, + int pAt_Fire, + int pAt_Water, + int pAt_Earth, + int pAt_Wind +) +{ + if( BATTLE_CHECKINDEX( battleindex ) == FALSE ) return 0.0; +#define AJ_BOTTOM (0.5) +#define AJ_PLUS (0.5) + int att; + float power, a_pow; + att = BattleArray[battleindex].field_att; + a_pow = (float)(BattleArray[battleindex].att_pow); + //print("\natt=%d\n",att); + switch( att ){ + case BATTLE_ATTR_EARTH: + power = AJ_BOTTOM + (pAt_Earth) * a_pow * 0.01 * 0.01 * AJ_PLUS; + break; + case BATTLE_ATTR_WATER: + power = AJ_BOTTOM + (pAt_Water) * a_pow * 0.01 * 0.01 * AJ_PLUS ; + break; + case BATTLE_ATTR_FIRE: + power = AJ_BOTTOM + (pAt_Fire) * a_pow * 0.01 * 0.01 * AJ_PLUS ; + break; + case BATTLE_ATTR_WIND: + power = AJ_BOTTOM + (pAt_Wind) * a_pow * 0.01 * 0.01 * AJ_PLUS ; + break; + default: + power = AJ_BOTTOM; + break; + } + return power; +} + +static int BATTLE_AttrAdjust( + int attackindex, + int defindex, + int damage +) +{ + int At_pow[5]={0,0,0,0,0}; //ˮ + int Dt_pow[5]={0,0,0,0,0}; + int i; + float At_FieldPow, Df_FieldPow; +#ifdef _BATTLE_PROPERTY + int (*loopfunc)(int,int,int*,int*,int)=NULL; +#endif + + BATTLE_GetAttr( attackindex, At_pow); + BATTLE_GetAttr( defindex, Dt_pow); + //print("\n1=%d,ˮ1=%d,1=%d,1=%d\n",At_pow[0],At_pow[1],At_pow[2],At_pow[3]); + //print("\n2=%d,ˮ2=%d,2=%d,2=%d\n",Dt_pow[0],Dt_pow[1],Dt_pow[2],Dt_pow[3]); +#ifdef _PSKILL_MDFYATTACK + if( CHAR_getWorkInt( attackindex, CHAR_WORKBATTLECOM1) == BATTLE_COM_S_MDFYATTACK ) { + int MKind=-1, MODS=0; + MKind = CHAR_GETWORKINT_LOW( attackindex, CHAR_WORKBATTLECOM4); + MODS = CHAR_GETWORKINT_HIGH( attackindex, CHAR_WORKBATTLECOM4); + + for( i=0; i<5; i++) { + At_pow[ i] = 0; + } + + if( MKind >= 0 && MKind <= 4 ){ + At_pow[ MKind] = MODS; + At_pow[ 4] = 0; + } + } +#endif +#ifdef _BATTLE_PROPERTY + loopfunc =(int(*)(int,int,int*,int*,int))CHAR_getFunctionPointer( attackindex, CHAR_BATTLEPROPERTY); + if( loopfunc ){ + loopfunc( attackindex, defindex, &damage, At_pow, 5); + } +#endif +#ifdef _BATTLE_PROPERTY + loopfunc = NULL; + loopfunc =(int(*)(int,int,int*,int*,int))CHAR_getFunctionPointer( defindex, CHAR_BATTLEPROPERTY); + if( loopfunc ){ + loopfunc( defindex, attackindex, &damage, Dt_pow, 5); + } +#endif + //print("\n1=%d,ˮ1=%d,1=%d,1=%d\n",At_pow[0],At_pow[1],At_pow[2],At_pow[3]); + //print("\n2=%d,ˮ2=%d,2=%d,2=%d\n",Dt_pow[0],Dt_pow[1],Dt_pow[2],Dt_pow[3]); + At_FieldPow = BATTLE_FieldAttAdjust( + CHAR_getWorkInt( attackindex, CHAR_WORKBATTLEINDEX ), At_pow[ 2], At_pow[ 1], At_pow[ 0], At_pow[ 3] ); + Df_FieldPow = BATTLE_FieldAttAdjust( + CHAR_getWorkInt( defindex, CHAR_WORKBATTLEINDEX ), Dt_pow[ 2], Dt_pow[ 1], Dt_pow[ 0], Dt_pow[ 3] ); + //print("\nAt_FieldPow=%f,Df_FieldPow=%f\n",At_FieldPow,Df_FieldPow); + for( i=0; i<5; i++) { + At_pow[ i] *= damage; + } +/* + At_Fire *= damage; At_Water *= damage; At_pow[0] *= damage; + At_Wind *= damage; At_none *= damage; +*/ + //print("\ndamage1=%d,",damage); + damage = BATTLE_AttrCalc(//2ˮ103 + At_pow[ 2], At_pow[ 1], At_pow[ 0], At_pow[ 3], At_pow[ 4], + Dt_pow[ 2], Dt_pow[ 1], Dt_pow[ 0], Dt_pow[ 3], Dt_pow[ 4] ); + damage *= (At_FieldPow / Df_FieldPow); + //print("damage2=%d\n",damage); + return damage; +} + +int BATTLE_GuardAdjust( int damage ) +{ + int Rand = RAND( 1, 100 ); + if( Rand <= 25 ){ + damage *= 0.00; + }else{ + if( Rand <= 50 ){ + damage *= 0.10; + }else{ + if( Rand <= 70 ){ + damage *= 0.20; + }else{ + if( Rand <= 85 ){ + damage *= 0.30; + }else{ + if( Rand <= 95 ){ + damage *= 0.40; + }else{ + damage *= 0.50; + } + } + } + } + } + return damage; +} + +//˺ֵ +int BATTLE_DamageCalc( int attackindex, int defindex ) +{ + float attack, defense; + int damage = 0; + int attackpet = BATTLE_getRidePet( attackindex ); + int defpet = BATTLE_getRidePet( defindex ); + + // Robin 0727 Ride Pet + if( attackpet == -1 ) { + attack = CHAR_getWorkInt( attackindex, CHAR_WORKATTACKPOWER ); + }else { + attack = BATTLE_adjustRidePet3A( attackindex, attackpet, CHAR_WORKATTACKPOWER, ATTACKSIDE ); + } + if( defpet == -1 ) { +#ifdef _BATTLE_NEWPOWER + defense = CHAR_getWorkInt( defindex, CHAR_WORKDEFENCEPOWER ) * 0.70; +#else + defense = CHAR_getWorkInt( defindex, CHAR_WORKDEFENCEPOWER ) * 0.45; + defense += CHAR_getWorkInt( defindex, CHAR_WORKQUICK ) * 0.2; + defense += CHAR_getWorkInt( defindex, CHAR_WORKFIXVITAL ) * 0.1; +#endif + }else { +#ifdef _BATTLE_NEWPOWER + defense = BATTLE_adjustRidePet3A( defindex, defpet, CHAR_WORKDEFENCEPOWER, DEFFENCESIDE ) * 0.70; +#else + defense = BATTLE_adjustRidePet3A( defindex, defpet, CHAR_WORKDEFENCEPOWER, DEFFENCESIDE ) * 0.45; + defense += BATTLE_adjustRidePet3A( defindex, defpet, CHAR_WORKQUICK, DEFFENCESIDE ) * 0.20; + defense += CHAR_getWorkInt( defindex, CHAR_WORKFIXVITAL ) * 0.05; +#endif + } + +#ifdef _MAGIC_SUPERWALL //ڷ + if( CHAR_getWorkInt( defindex, CHAR_MAGICSUPERWALL ) > 0 ){ + float def = (float)(CHAR_getWorkInt( defindex, CHAR_OTHERSTATUSNUMS )); + def = (def + rand()%20)/100; + defense += defense * def; + } +#endif +#ifdef _NPCENEMY_ADDPOWER //޸Ĺֵ + if( CHAR_getInt( defindex, CHAR_WHICHTYPE ) == CHAR_TYPEENEMY ) { + defense += (defense*(rand()%10)+2)/100; + } + if( CHAR_getInt( attackindex, CHAR_WHICHTYPE ) == CHAR_TYPEENEMY ) { + attack += (attack*(rand()%10)+2)/100; + } +#endif + if( CHAR_getWorkInt( defindex, CHAR_WORKSTONE ) > 0 ) defense *= 2.0; + +#ifdef _PETSKILL_REGRET + //װ + if( CHAR_getWorkInt( attackindex, CHAR_WORKBATTLECOM1 ) == BATTLE_COM_S_REGRET + || CHAR_getWorkInt( attackindex, CHAR_WORKBATTLECOM1 ) == BATTLE_COM_S_REGRET2 ) + defense = CHAR_getWorkInt(defindex,CHAR_WORKFIXTOUGH); +#endif + +#ifdef _EQUIT_NEGLECTGUARD //Ŀ% + if( CHAR_getWorkInt( attackindex, CHAR_WORKNEGLECTGUARD) > 1 ) { + float defp = (float)CHAR_getWorkInt( attackindex, CHAR_WORKNEGLECTGUARD); + defp = 1 - (defp/100); + defense = defense*defp; + } +#endif + + if( defense <= attack && attack < (defense * 8.0/7.0) ){ + damage = (int)(RAND( 0, attack * D_16 )); + }else + if( defense > attack ){ + damage = (int)(RAND( 0, 1 )); + }else + if( attack >= (defense * 8/7) ){ + float K0; + K0 = RAND( 0, attack*D_8 ) - attack*D_16; + damage = (int)(( (attack - defense )*DAMAGE_RATE ) + K0); + } + + // + damage = BATTLE_AttrAdjust( attackindex, defindex, damage ); + +#ifdef _PROFESSION_ADDSKILL + { + // + if( ((CHAR_getWorkInt( defindex, CHAR_WORKFIXEARTHAT_BOUNDARY )>>16) & 0x0000ffff) > 0 ){ + if( CHAR_getWorkInt( attackindex, CHAR_WORKFIXEARTHAT ) > 0 ) + damage -= damage*(float)((CHAR_getWorkInt( attackindex, CHAR_WORKFIXEARTHAT )/200.0)); + }else if( ((CHAR_getWorkInt( defindex, CHAR_WORKFIXWATERAT_BOUNDARY )>>16) & 0x0000ffff) > 0 ){ + if( CHAR_getWorkInt( attackindex, CHAR_WORKFIXWATERAT ) > 0 ) + damage -= damage*(float)((CHAR_getWorkInt( attackindex, CHAR_WORKFIXWATERAT )/200.0)); + }else if( ((CHAR_getWorkInt( defindex, CHAR_WORKFIXFIREAT_BOUNDARY )>>16) & 0x0000ffff) > 0 ){ + if( CHAR_getWorkInt( attackindex, CHAR_WORKFIXFIREAT ) > 0 ) + damage -= damage*(float)((CHAR_getWorkInt( attackindex, CHAR_WORKFIXFIREAT )/200.0)); + }else if( ((CHAR_getWorkInt( defindex, CHAR_WORKFIXWINDAT_BOUNDARY )>>16) & 0x0000ffff) > 0 ){ + if( CHAR_getWorkInt( attackindex, CHAR_WORKFIXWINDAT ) > 0 ) + damage -= damage*(float)((CHAR_getWorkInt( attackindex, CHAR_WORKFIXWINDAT )/200.0)); + } + //T_pow[1] += T_pow[1]*( (CHAR_getWorkInt( charaindex, CHAR_WORKFIXWATERAT_BOUNDARY )>>16&0x0000ffff) /100 ); + //T_pow[2] += T_pow[2]*( (CHAR_getWorkInt( charaindex, CHAR_WORKFIXFIREAT_BOUNDARY )>>16&0x0000ffff) /100 ); + //T_pow[3] += T_pow[3]*( (CHAR_getWorkInt( charaindex, CHAR_WORKFIXWINDAT_BOUNDARY )>>16&0x0000ffff) /100 ); + } +#endif + +#ifdef _ADD_DEAMGEDEFC //˺ & ӹ + { + int apower, dpower, otherpower; + apower = CHAR_getWorkInt( attackindex, CHAR_WORKOTHERDMAGE); + dpower = CHAR_getWorkInt( defindex, CHAR_WORKOTHERDEFC); + + otherpower = RAND( apower*0.3, apower) - RAND( dpower*0.3, dpower); + if( otherpower != 0 ) { + damage += otherpower; + } + } + if( damage < 0 ) + damage = 0; +#endif +#ifdef _DAMMAGE_CALC + return damage * getDamageCalc() / 100; +#else + return damage; +#endif +} + +static int BATTLE_CriticalCheckPlayer( int attackindex, int defindex ) +{ + int At_Dex, At_Luck = 0, At_Kiryoku = 0, At_Soubi = 0; + int At_SoubiIndex, Df_Dex, root = 1; + float per, Work, Big, Small, wari, divpara = gCriticalPara; + + // WON REM + //if( gWeponType == ITEM_BOW )return 0; + + At_Dex = CHAR_getWorkInt( attackindex, CHAR_WORKFIXDEX ); + Df_Dex = CHAR_getWorkInt( defindex, CHAR_WORKFIXDEX ); + + if( CHAR_getInt( attackindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER ){ + At_Luck = CHAR_getWorkInt( attackindex, CHAR_WORKFIXLUCK ); + } + At_SoubiIndex = CHAR_getItemIndex( attackindex, CHAR_ARM ); + At_Kiryoku = CHAR_getInt( attackindex, CHAR_MP ); + + if( ITEM_CHECKINDEX( At_SoubiIndex ) == TRUE ){ + At_Soubi = ITEM_getInt( At_SoubiIndex, ITEM_CRITICAL ); + } + if( CHAR_getInt( attackindex, CHAR_WHICHTYPE ) == CHAR_TYPEPET + && CHAR_getInt( defindex, CHAR_WHICHTYPE ) == CHAR_TYPEENEMY){ + Df_Dex *= 0.8; + }else + if( CHAR_getInt( attackindex, CHAR_WHICHTYPE ) == CHAR_TYPEENEMY + && CHAR_getInt( defindex, CHAR_WHICHTYPE ) == CHAR_TYPEPET){ + divpara = 10.0; + root = 0; + }else + if( CHAR_getInt( attackindex, CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER + && CHAR_getInt( defindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER){ + divpara = 10.0; + root = 0; + }else + if( CHAR_getInt( attackindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER + && CHAR_getInt( defindex, CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER){ + Df_Dex *= 0.6; + } + + if( At_Dex >= Df_Dex ){ + Big = At_Dex; + Small = Df_Dex; + wari = 1.0; + }else{ + Big = Df_Dex; + Small = At_Dex; + if( Big <= 0 ){ + wari = 0.0; + }else{ + wari = Small / Big; + } + } + Work = ( Big - Small ) / divpara; + if( Work <= 0 ) Work = 0; + + if( root == 1 ){ + per = (float)( sqrt( (double)Work ) ) + At_Soubi * 0.5; + }else{ + per = (float)Work + At_Soubi * 0.5; + } + per *= wari; + per += At_Luck ; + per *= 100; + if( per < 0 ) per = 1; + if( per > 10000 ) per = 10000; +#ifdef _PETSKILL_LER + // ׶ܱ + if(CHAR_getInt(defindex,CHAR_BASEBASEIMAGENUMBER) == 101813 || + CHAR_getInt(defindex,CHAR_BASEBASEIMAGENUMBER) == 101814) per = 0; +#endif + return (int)per; +} + +static int BATTLE_CounterCalc( int attackindex, int defindex ) +{ + int Df_Dex, At_Dex, Work, root = 1; + float per, Big, Small, wari, divpara = gCounterPara; + + At_Dex = CHAR_getWorkInt( attackindex, CHAR_WORKFIXDEX ); + Df_Dex = CHAR_getWorkInt( defindex, CHAR_WORKFIXDEX ); + + if( CHAR_getInt( attackindex, CHAR_WHICHTYPE ) == CHAR_TYPEENEMY + && CHAR_getInt( defindex, CHAR_WHICHTYPE ) == CHAR_TYPEPET + ){ + divpara = 10; + root = 0; + }else if( CHAR_getInt( attackindex, CHAR_WHICHTYPE ) == CHAR_TYPEPET + && CHAR_getInt( defindex, CHAR_WHICHTYPE ) == CHAR_TYPEENEMY + ){ + Df_Dex *= 0.8; + }else if( CHAR_getInt( attackindex, CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER + && CHAR_getInt( defindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER + ){ + divpara = 10; + root = 0; + }else if( CHAR_getInt( attackindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER + && CHAR_getInt( defindex, CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER + ){ + Df_Dex *= 0.6; + } + + if( At_Dex >= Df_Dex ){ + Big = At_Dex; + Small = Df_Dex; + wari = 1.0; + }else{ + Big = Df_Dex; + Small = At_Dex; + if( Big <= 0 ){ + wari = 0.0; + }else{ + wari = Small / Big; + } + } + Work = ( Big - Small ) / divpara; + if( Work <= 0 ) Work = 0; + if( root == 1 ){ + per = (float)( (double)sqrt( Work ) ); + }else{ + per = (float)( Work); + } + per *= wari; + + return per; +} + +static int BATTLE_CriticalCheck( int attackindex, int defindex ) +{ + if( CHAR_getInt( attackindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER ){ + return BATTLE_CriticalCheckPlayer( attackindex, defindex ); + }else{ + return BATTLE_CriticalCheckPlayer( attackindex, defindex ); + } +} + +static int BATTLE_CriDamageCalc( int attackindex, int defindex ) +{ + int damage = 0; + damage = BATTLE_DamageCalc( attackindex, defindex ); + + damage += CHAR_getWorkInt( defindex, CHAR_WORKDEFENCEPOWER ) + * (float)CHAR_getInt( attackindex, CHAR_LV ) + / (float)CHAR_getInt( defindex, CHAR_LV ) + * 0.5; + return damage; +} + +static int BATTLE_GuardianCheck( int attackindex, int defindex ) +{ + int GuardianIndex, Guardian, battleindex; + int DefSide = 0, i, DefNo; + //char szBuffer[256]=""; + + battleindex = CHAR_getWorkInt( attackindex, CHAR_WORKBATTLEINDEX ); + + DefNo = BATTLE_Index2No( battleindex, defindex ); + i = DefNo; + if( i >= SIDE_OFFSET ){ + i -= SIDE_OFFSET; + DefSide = 1; + } + + if( BattleArray[battleindex].Side[DefSide].Entry[i].guardian == -1 ){ + return -1; + } + + Guardian = BattleArray[battleindex].Side[DefSide].Entry[i].guardian; +// Terry add fix ʹΪ˼ʱ,ʹô˼ܵclientᵱ + if(Guardian == DefNo) return -1; +// end + GuardianIndex = BATTLE_No2Index( battleindex, Guardian ); + + if( CHAR_CHECKINDEX( GuardianIndex ) == FALSE )return -1; + + if( CHAR_getFlg( GuardianIndex, CHAR_ISDIE ) == TRUE )return -1; + + if( CHAR_getWorkInt( GuardianIndex, CHAR_WORKBATTLEFLG ) & CHAR_BATTLEFLG_GUARDIAN ){ + }else{ + return -1; + } + + if( CHAR_getWorkInt( GuardianIndex, CHAR_WORKSLEEP ) > 0 + || CHAR_getWorkInt( GuardianIndex, CHAR_WORKCONFUSION ) > 0 + || CHAR_getWorkInt( GuardianIndex, CHAR_WORKPARALYSIS ) > 0 + || CHAR_getWorkInt( GuardianIndex, CHAR_WORKSTONE ) > 0 + || CHAR_getWorkInt( GuardianIndex, CHAR_WORKBARRIER ) > 0 + || GuardianIndex == attackindex +#ifdef _PROFESSION_SKILL // WON ADD ְҵ + || CHAR_getWorkInt( GuardianIndex, CHAR_WORKDIZZY ) > 0 // ѣ + || CHAR_getWorkInt( GuardianIndex, CHAR_WORKDRAGNET ) > 0 // ޵ + || CHAR_getWorkInt( GuardianIndex, CHAR_WORKINSTIGATE ) > 0 // +#endif +#ifdef _PROFESSION_ADDSKILL + || CHAR_getWorkInt( GuardianIndex, CHAR_DOOMTIME ) > 0 //ĩռ +#endif + ){ + //snprintf( szBuffer, sizeof(szBuffer), + // "(%s)Ҫס(%s)ûɹ\", + // CHAR_getUseName( GuardianIndex ), + // CHAR_getUseName( defindex ) + //); + //BATTLE_BroadCast( battleindex, szBuffer, + // (DefNo >= 10)? CHAR_COLORGRAY : CHAR_COLORPURPLE ) ; + return -1; + } + + if( BATTLE_IsThrowWepon( + CHAR_getItemIndex( attackindex, CHAR_ARM ) ) == TRUE + ){ + //snprintf( szBuffer, sizeof(szBuffer), + // "(%s)Ҫס(%s)ûɹ\", + // CHAR_getUseName( GuardianIndex ), + // CHAR_getUseName( defindex ) + //); + //BATTLE_BroadCast( battleindex, szBuffer, + // (DefNo >= 10)? CHAR_COLORGRAY : CHAR_COLORPURPLE ) ; + return -1; + } + + //snprintf( szBuffer, sizeof(szBuffer), + // "(%s)ס(%s)", + // CHAR_getUseName( GuardianIndex ), + // CHAR_getUseName( defindex ) + //); + //BATTLE_BroadCast( battleindex, szBuffer, + // (DefNo >= 10)? CHAR_COLORGRAY : CHAR_COLORPURPLE ) ; + + return Guardian; +} + + +static int BATTLE_DamageWakeUp( int battleindex, int defindex ) +{ + int bid; + char szBuffer[256]=""; + CHAR_setInt( defindex, CHAR_DAMAGECOUNT, + CHAR_getInt( defindex, CHAR_DAMAGECOUNT ) +1 ); + + if( CHAR_getWorkInt( defindex, CHAR_WORKSLEEP ) > 0 ){ + CHAR_setWorkInt( defindex, CHAR_WORKSLEEP, 0 ); + bid = BATTLE_Index2No( battleindex, defindex ); + //sprintf( szBuffer, "(%s)\n", + // CHAR_getUseName( defindex ) ); + //BATTLE_BroadCast( battleindex, szBuffer, + // (bid >= 10)? CHAR_COLORGRAY : CHAR_COLORPURPLE ) ; + sprintf( szBuffer, "BM|%X|%X|", bid, 0 ); + strcatsafe( szBadStatusString,sizeof(szBadStatusString), szBuffer ); + } + return 0; +} + +static int BATTLE_AttackSeq( int attackindex, int defindex, int *pDamage, int *pGuardian, int opt ) +{ + int iRet = 0, perCri = 0; + int GuardianIndex = -1,battleindex; + + battleindex = CHAR_getWorkInt( attackindex, CHAR_WORKBATTLEINDEX ); + + // ˴ + if( CHAR_getInt( defindex, CHAR_WHICHTYPE ) == CHAR_TYPEPET + && BattleArray[battleindex].norisk == 0 + && BattleArray[battleindex].type == BATTLE_TYPE_P_vs_E){ + if( CHAR_getWorkInt( defindex, CHAR_WORKPLAYERINDEX ) == attackindex ){ + CHAR_PetAddVariableAi( defindex, AI_FIX_SEKKAN ); // ҳ϶ + } + } + + // + if( opt != BATTLE_COM_COMBO ){ + if( BATTLE_DuckCheck( attackindex, defindex ) == TRUE ){ + return BATTLE_RET_DODGE; + } +#ifdef _SUIT_ADDPART3 + if( CHAR_getWorkInt( defindex, CHAR_WORKDUCKPOWER) > 0 ){ + if( rand()%100 < CHAR_getWorkInt( defindex, CHAR_WORKDUCKPOWER) ) + return BATTLE_RET_DODGE; + } +#endif + } + + // 鱻ޱȮ + if( *pGuardian == -1 ){ + *pGuardian = BATTLE_GuardianCheck( attackindex, defindex ); + if( *pGuardian != -1 ){ + GuardianIndex = BATTLE_No2Index( battleindex, *pGuardian ); + defindex = GuardianIndex; + } + } + + // һ + perCri = BATTLE_CriticalCheck( attackindex, defindex ); + +#ifdef _PETSKILL_DAMAGETOHP + if( opt == BATTLE_COM_S_DAMAGETOHP2 ){ //¿ (һ30%) && CHAR_getInt( attackindex, CHAR_HP) <= CHAR_getWorkInt( attackindex, CHAR_MAXMP)*0.5 + //print("\n1һ:%d",perCri); + //print("\n1:%d", CHAR_getWorkInt( attackindex, CHAR_WORKATTACKPOWER)); + //print("\n1:%d", CHAR_getWorkInt( attackindex, CHAR_WORKQUICK)); + perCri = perCri + (perCri*0.3); //һ30% + CHAR_setWorkInt( attackindex, CHAR_WORKATTACKPOWER, CHAR_getWorkInt( attackindex,CHAR_WORKFIXSTR)+CHAR_getWorkInt( attackindex,CHAR_WORKFIXSTR)*0.2);//20% + CHAR_setWorkInt( attackindex, CHAR_WORKQUICK, CHAR_getWorkInt( attackindex, CHAR_WORKFIXDEX)+CHAR_getWorkInt( attackindex, CHAR_WORKFIXDEX) *0.2 );//20% + //print("\n2һ:%d",perCri); + //print("\n2:%d", CHAR_getWorkInt( attackindex, CHAR_WORKATTACKPOWER)); + //print("\n2:%d", CHAR_getWorkInt( attackindex, CHAR_WORKQUICK)); + } +#endif + + gCriper = perCri; + if( RAND( 1, 10000 ) < perCri ){ + // WON ADD + int gWeponType = BATTLE_GetWepon( attackindex ); + if( gWeponType != ITEM_BOW ){ + (*pDamage) = BATTLE_CriDamageCalc( attackindex, defindex ); + }else{ + (*pDamage) = BATTLE_DamageCalc( attackindex, defindex ); + } + iRet = BATTLE_RET_CRITICAL; + if( CHAR_getInt( attackindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER ){ + // ʿר + PROFESSION_SKILL_WEAPON_FOCUS_LVEVEL_UP( attackindex, "PROFESSION_WEAPON_FOCUS" ); + // ʿ + PROFESSION_SKILL_DUAL_WEAPON_LVEVEL_UP( attackindex, "PROFESSION_DUAL_WEAPON" ); + } + }else{ + (*pDamage) = BATTLE_DamageCalc( attackindex, defindex ); + iRet = BATTLE_RET_NORMAL; + } + + if( opt == BATTLE_COM_S_GBREAK){ + ;; + }else +#ifdef _SKILL_GUARDBREAK2//Ƴ2 vincent add 2002/05/20 + if( opt == BATTLE_COM_S_GBREAK2){ + if( CHAR_getWorkInt( defindex, CHAR_WORKBATTLECOM1 ) == BATTLE_COM_GUARD){ + (*pDamage) = (*pDamage)*1.3; + }else{ + (*pDamage) = (*pDamage)*0.7; + } + }else +#endif + +#ifdef _PETSKILL_REGRET + if( opt == BATTLE_COM_S_REGRET2 ){// ˺ + (*pDamage) = (*pDamage)*0.8; + }else +#endif +#ifdef _SONIC_ATTACK // WON ADD + if( opt == BATTLE_COM_S_SONIC2 ){// ˺ + (*pDamage) = (*pDamage)*0.5; + }else +#endif + if( CHAR_getWorkInt( defindex, CHAR_WORKBATTLECOM1 ) == BATTLE_COM_GUARD + && CHAR_getWorkInt( defindex, CHAR_WORKCONFUSION ) <= 0 ){ + (*pDamage) = BATTLE_GuardAdjust( (*pDamage) ); + } + if( (*pDamage) < 1 ) (*pDamage) = RAND( 0, 1 ); + +#ifdef _PREVENT_TEAMATTACK // ֹͬӻ + if (CHAR_getInt( defindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER || + CHAR_getInt( defindex, CHAR_WHICHTYPE ) == CHAR_TYPEPET ) { + int myside = CHAR_getWorkInt( defindex, CHAR_WORKBATTLESIDE);//attackindex + if( myside == CHAR_getWorkInt( attackindex, CHAR_WORKBATTLESIDE)){ + if( CHAR_getWorkInt( attackindex, CHAR_WORKCONFUSION) > 0 +#ifdef _PROFESSION_SKILL // WON ADD ְҵ + || CHAR_getWorkInt( attackindex, CHAR_WORKINSTIGATE) > 0 // +#endif +#ifdef _PROFESSION_ADDSKILL + || CHAR_getWorkInt( attackindex, CHAR_WORKANNEX) > 0 // +#endif + ){ //쳣 +#ifdef _PETSKILL_TEMPTATION + }else if( CHAR_getWorkInt( attackindex, CHAR_WORKTEMPTATION ) > 0 ){//ˮջ +#endif + }else if( CHAR_getInt( attackindex, CHAR_WHICHTYPE) == CHAR_TYPEPET && + CHAR_getWorkInt( attackindex, CHAR_WORKBATTLEFLG) & CHAR_BATTLEFLG_AIBAD ){ //nono + }else if( CHAR_getInt( defindex, CHAR_WHICHTYPE) == CHAR_TYPEPET && + CHAR_getWorkInt( defindex, CHAR_WORKPLAYERINDEX) == attackindex ){ // ѳ + }else { + int myhp, mymaxhp; + mymaxhp = CHAR_getWorkInt( defindex, CHAR_WORKMAXHP); + myhp = CHAR_getInt( defindex, CHAR_HP ) - *pDamage; + mymaxhp = mymaxhp *0.40; + if( mymaxhp >= myhp || mymaxhp < 40 ){ + *pDamage = 0; + }else { + *pDamage = 1; + } + } + } + } +#endif + +#ifdef _EQUIT_ARRANGE + if( BATTLE_ArrangeCheck( attackindex, defindex) == TRUE ){ + *pDamage *= 0.1; + iRet = BATTLE_RET_ARRANGE; + + // ʿ񵲼 + if( (CHAR_getInt( defindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER) ) + PROFESSION_SKILL_LVEVEL_UP( defindex, "PROFESSION_DEFLECT" ); + } +#endif + + if( (*pDamage) == 0 ){ + iRet = BATTLE_RET_MISS; + if( GuardianIndex != -1 ){ + iRet = BATTLE_RET_NORMAL; + *pDamage = 1; + }else if( CHAR_getWorkInt( defindex, CHAR_WORKBATTLECOM1 ) == BATTLE_COM_GUARD + && CHAR_getWorkInt( defindex, CHAR_WORKCONFUSION ) <= 0 ){ + iRet = BATTLE_RET_ALLGUARD; + } + } + + (*pDamage) *= gBattleDamageModyfy; + return iRet; +} + +#ifdef _PETSKILL_SETDUCK +BOOL BATTLE_CheckMySkillDuck( int charaindex ) +{ + int SDuck=0,rad=0; + if( !CHAR_CHECKINDEX( charaindex) ) + return FALSE; + if( (SDuck=CHAR_getWorkInt( charaindex, CHAR_MYSKILLDUCK)) > 0 ){ + int duck1 = CHAR_getWorkInt( charaindex, CHAR_MYSKILLDUCKPOWER); + if( (rad = (rand()%100)) > duck1 ){ + return FALSE; + }else {//ر + return TRUE; + } + } + return FALSE; +} +#endif + +#ifdef _PROFESSION_SKILL // WON ADD ְҵ +int BATTLE_check_profession_duck( int charaindex, int per ) +{ + + int SDuck=0; + + if( (SDuck=CHAR_getWorkInt( charaindex, CHAR_WORK_P_DUCK)) > 0 ){ + int duck1 = CHAR_getWorkInt( charaindex, CHAR_WORKMOD_P_DUCK); + per = per * ( 100 + duck1 ) / 100; + } + + return per; +} +#endif + + +int BATTLE_GetDamageReact( int charaindex ) +{ + if( CHAR_getWorkInt( charaindex, CHAR_WORKDAMAGEVANISH ) > 0 ){ + return BATTLE_MD_VANISH; + } + if( CHAR_getWorkInt( charaindex, CHAR_WORKDAMAGEABSROB ) > 0 ){ + return BATTLE_MD_ABSROB; + } + if( CHAR_getWorkInt( charaindex, CHAR_WORKDAMAGEREFLEC ) > 0 ){ + return BATTLE_MD_REFLEC; + } + +#ifdef _PROFESSION_SKILL // WON ADD ְҵ + if( CHAR_getWorkInt( charaindex, CHAR_WORKTRAP ) > 0 ){ // + return BATTLE_MD_TRAP; + } +#endif +#ifdef _PETSKILL_ACUPUNCTURE + if( CHAR_getWorkInt( charaindex, CHAR_WORKACUPUNCTURE ) > 0 ){ //Ƥ + //print("\n:BATTLE_GetDamageReact"); + return BATTLE_MD_ACUPUNCTURE; + } +#endif + return 0; +} + +int BATTLE_DamageSub( int attackindex, int defindex, int *pDamage, int *pPetDamage, int *pRefrect ) +{ + + int hp = 0, addpoint = 0, maxhp, IsUltimate = 0, react, work, battleindex; + int damage, playerdamage, petdamage; + int attackpet, defpet; + int pethp = 0, petmaxhp = 0; + int defquick = 0, petquick = 0; + + damage = *pDamage; + petdamage = *pPetDamage; + playerdamage = damage; + if( damage <= 0 )return 0; + +#ifdef _PETSKILL_SHOWMERCY + if( CHAR_getInt( defindex, CHAR_HP ) - damage <= 0 + && CHAR_getWorkInt(attackindex, CHAR_WORKBATTLECOM1) == BATTLE_COM_S_SHOWMERCY ){ + damage = CHAR_getInt( defindex, CHAR_HP ) - 1; + *pDamage = damage; + playerdamage = damage; + } +#endif + + attackpet = BATTLE_getRidePet( attackindex ); + defpet = BATTLE_getRidePet( defindex ); + if( defpet != -1 ) { + defquick = CHAR_getWorkInt( defindex, CHAR_WORKDEFENCEPOWER ); + petquick = CHAR_getWorkInt( defpet, CHAR_WORKDEFENCEPOWER ); + } + + if( *pRefrect != -1 ){ + react = BATTLE_GetDamageReact( defindex ); + }else{ + react = BATTLE_MD_NONE; + } + battleindex = CHAR_getWorkInt( defindex, CHAR_WORKBATTLEINDEX ); + + if( react == BATTLE_MD_REFLEC ){ + if( BATTLE_IsThrowWepon( CHAR_getItemIndex( attackindex, CHAR_ARM ) ) == FALSE ){ + *pRefrect = BATTLE_MD_REFLEC; + }else{ + *pRefrect = BATTLE_MD_NONE; + } + }else{ + } + +#ifdef _PROFESSION_SKILL // WON ADD ְҵ + if( react == BATTLE_MD_TRAP ){ + if( BATTLE_IsThrowWepon( CHAR_getItemIndex( attackindex, CHAR_ARM ) ) == FALSE ) + *pRefrect = BATTLE_MD_TRAP; + else + *pRefrect = BATTLE_MD_NONE; + } +#endif + +#ifdef _PETSKILL_ACUPUNCTURE + if( react == BATTLE_MD_ACUPUNCTURE ){ + if( BATTLE_IsThrowWepon( CHAR_getItemIndex( attackindex, CHAR_ARM ) ) == FALSE ){ + *pRefrect = BATTLE_MD_ACUPUNCTURE; + }else{ + *pRefrect = BATTLE_MD_NONE; + } + } +#endif + + if( react == BATTLE_MD_ABSROB ){ + hp = CHAR_getInt( defindex, CHAR_HP ); + if( defpet == -1 ) { + hp += damage; + }else { + pethp = CHAR_getInt( defpet, CHAR_HP ); + playerdamage = (damage*petquick)/(defquick+petquick) +1 ; + petdamage = damage - playerdamage +1 ; + hp += playerdamage; + pethp += petdamage; + + } + work = CHAR_getWorkInt( defindex, CHAR_WORKDAMAGEABSROB ) - 1; + CHAR_setWorkInt( defindex, CHAR_WORKDAMAGEABSROB, max( work, 0 ) ); + *pRefrect = BATTLE_MD_ABSROB; + }else + if( *pRefrect == BATTLE_MD_REFLEC ){ +#ifdef _PETSKILL_BATTLE_MODEL + if(CHAR_getWorkInt(defindex,CHAR_NPCWORKINT1) == BATTLE_COM_S_BATTLE_MODEL){ + work = CHAR_getWorkInt( defindex, CHAR_WORKDAMAGEREFLEC ) - 1; + CHAR_setWorkInt( defindex, CHAR_WORKDAMAGEREFLEC, max( work, 0 ) ); + hp = CHAR_getInt(defindex,CHAR_HP); + pethp = CHAR_getInt(defpet,CHAR_HP); + } + else +#endif + { + hp = CHAR_getInt( attackindex, CHAR_HP ); + if( attackpet == -1 ) { + hp -= damage; + }else { + pethp = CHAR_getInt( attackpet, CHAR_HP ); + defquick = CHAR_getWorkInt( attackindex, CHAR_WORKDEFENCEPOWER ); + petquick = CHAR_getWorkInt( attackpet, CHAR_WORKDEFENCEPOWER ); + if( pethp > 0 ) { + playerdamage = (damage*petquick)/(defquick+petquick) +1; + petdamage = damage - playerdamage +1 ; + hp -= playerdamage; + pethp -= petdamage; + }else + hp -= damage; + } + work = CHAR_getWorkInt( defindex, CHAR_WORKDAMAGEREFLEC ) - 1; + CHAR_setWorkInt( defindex, CHAR_WORKDAMAGEREFLEC, max( work, 0 ) ); + defindex = attackindex; + defpet = attackpet; + } + }else +#ifdef _PROFESSION_SKILL // WON ADD ְҵ + if( *pRefrect == BATTLE_MD_TRAP ){ // +#ifdef _PETSKILL_BATTLE_MODEL + if(CHAR_getWorkInt(defindex,CHAR_NPCWORKINT1) == BATTLE_COM_S_BATTLE_MODEL){ + CHAR_setWorkInt( defindex, CHAR_WORKTRAP, 0 ); + CHAR_setWorkInt( defindex, CHAR_WORKMODTRAP, 0 ); + hp = CHAR_getInt(defindex,CHAR_HP); + pethp = CHAR_getInt(defpet,CHAR_HP); + } + else +#endif + { + int value=0; + value = CHAR_getWorkInt( defindex, CHAR_WORKMODTRAP ); + damage = value; + + playerdamage = damage; + + hp = CHAR_getInt( attackindex, CHAR_HP ); + if( attackpet == -1 ) { + hp -= damage; + }else { + pethp = CHAR_getInt( attackpet, CHAR_HP ); + defquick = CHAR_getWorkInt( attackindex, CHAR_WORKDEFENCEPOWER ); + petquick = CHAR_getWorkInt( attackpet, CHAR_WORKDEFENCEPOWER ); + if( pethp > 0 ) { + playerdamage = (damage*petquick)/(defquick+petquick) +1; + petdamage = damage - playerdamage +1 ; + hp -= playerdamage; + pethp -= petdamage; + }else + hp -= damage; + } + + CHAR_setWorkInt( defindex, CHAR_WORKTRAP, 0 ); + CHAR_setWorkInt( defindex, CHAR_WORKMODTRAP, 0 ); + + defindex = attackindex; + defpet = attackpet; + } + }else +#endif +#ifdef _PETSKILL_ACUPUNCTURE + if( *pRefrect == BATTLE_MD_ACUPUNCTURE ){ //Ƥ + + if( damage%2 != 0 ) + damage+=1; + playerdamage = damage; + + //ȿ۱Ѫ,Ϊ֮ĶǶԹ + hp = CHAR_getInt( defindex, CHAR_HP ); + if( attackpet == -1 ) { + hp -= damage; + if(hp<0)hp=0; + maxhp = CHAR_getWorkInt( defindex, CHAR_WORKMAXHP ); + CHAR_setInt( defindex, CHAR_HP, min( hp, maxhp ) ); + }else { + pethp = CHAR_getInt( defpet, CHAR_HP ); + defquick = CHAR_getWorkInt( defindex, CHAR_WORKDEFENCEPOWER ); + petquick = CHAR_getWorkInt( defpet, CHAR_WORKDEFENCEPOWER ); + if( pethp > 0 ) { + playerdamage = (damage*petquick)/(defquick+petquick) +1; + petdamage = damage - playerdamage +1 ; + if(playerdamage%2 != 0) playerdamage+=1; + if(petdamage%2 != 0) petdamage+=1; + hp -= playerdamage; + pethp -= petdamage; + if(hp<0)hp=0; + maxhp = CHAR_getWorkInt( defindex, CHAR_WORKMAXHP ); + CHAR_setInt( defindex, CHAR_HP, min( hp, maxhp ) ); + if( pethp < 0 ) pethp = 0; + petmaxhp = CHAR_getWorkInt( defpet, CHAR_WORKMAXHP ); + CHAR_setInt( defpet, CHAR_HP, min( pethp, petmaxhp ) ); + }else{ + hp -= damage; + if(hp<0)hp=0; + maxhp = CHAR_getWorkInt( defindex, CHAR_WORKMAXHP ); + CHAR_setInt( defindex, CHAR_HP, min( hp, maxhp ) ); + } + } + + //Change 2003/08/22 + if( (damage) >= CHAR_getWorkInt( defindex, CHAR_WORKMAXHP ) * 1.2 + 20 ){ + int DefSide=0,i; + int defNo = BATTLE_Index2No( battleindex, defindex ); + CHAR_setWorkInt( defindex, CHAR_WORKULTIMATE, 0 ); + + //ijΪϢ + if( defNo >= SIDE_OFFSET ){ + i = defNo - SIDE_OFFSET; + DefSide = 1; + }else{ + i = defNo; + } + i = defNo-DefSide*SIDE_OFFSET; + BattleArray[battleindex].Side[DefSide].Entry[i].flg |= BENT_FLG_ULTIMATE; + } + + //ƤܻغΪ0 + CHAR_setWorkInt( defindex, CHAR_WORKACUPUNCTURE, 0); + //if( CHAR_getWorkInt( defindex, CHAR_WORKSLEEP ) > 0 )//޻˯ + // CHAR_setWorkInt( defindex, CHAR_WORKSLEEP, 0); + +#ifdef _PETSKILL_BATTLE_MODEL + if(CHAR_getWorkInt(defindex,CHAR_NPCWORKINT1) != BATTLE_COM_S_BATTLE_MODEL) +#endif + { + //۹Ѫ + hp = CHAR_getInt( attackindex, CHAR_HP ); + if( attackpet == -1 ) { + hp -= damage/2; + }else { + pethp = CHAR_getInt( attackpet, CHAR_HP ); + defquick = CHAR_getWorkInt( attackindex, CHAR_WORKDEFENCEPOWER ); + petquick = CHAR_getWorkInt( attackpet, CHAR_WORKDEFENCEPOWER ); + if( pethp > 0 ) { + playerdamage = (damage*petquick)/(defquick+petquick) +1; + petdamage = damage - playerdamage +1 ; + if(playerdamage%2 != 0) playerdamage+=1; + if(petdamage%2 != 0) petdamage+=1; + hp -= playerdamage/2; + pethp -= petdamage/2; + }else + hp -= damage/2; + } + playerdamage /= 2; + + defindex = attackindex; + defpet = attackpet; + } + }else +#endif + if( react == BATTLE_MD_VANISH ){ + hp = CHAR_getInt( defindex, CHAR_HP ); + if( defpet != -1 ) + pethp = CHAR_getInt( defpet, CHAR_HP ); + work = CHAR_getWorkInt( defindex, CHAR_WORKDAMAGEVANISH ) - 1; + CHAR_setWorkInt( defindex, CHAR_WORKDAMAGEVANISH, max( work, 0 ) ); + *pRefrect = BATTLE_MD_VANISH; + //andy_log + //print("*pRefrect = BATTLE_MD_VANISH !!\n"); + }else{ + hp = CHAR_getInt( defindex, CHAR_HP ); + if( defpet == -1 ) { + hp -= damage; + }else { + pethp = CHAR_getInt( defpet, CHAR_HP ); + if( pethp > 0 ) { + //andy_edit 2002/07/31 + defquick = defquick>0?defquick:1; + petquick = petquick>0?petquick:1; + playerdamage = (damage*petquick)/(defquick+petquick)+ 1; + //playerdamage = (damage*petquick)/(defquick+petquick) +1; + petdamage = damage - playerdamage +1; + hp -= playerdamage; + pethp -= petdamage; + //print(" def_damage:%d ridepet_damage:%d ", (damage*petquick)/(defquick+petquick), damage - playerdamage); + }else + hp -= damage; + } + *pRefrect = 0; + } + + if( hp < 0 ){ + addpoint = -hp; + hp = 0; + } + + + maxhp = CHAR_getWorkInt( defindex, CHAR_WORKMAXHP ); + CHAR_setInt( defindex, CHAR_HP, min( hp, maxhp ) ); + if( defpet != -1 ) { + if( pethp < 0 ) pethp = 0; + petmaxhp = CHAR_getWorkInt( defpet, CHAR_WORKMAXHP ); + CHAR_setInt( defpet, CHAR_HP, min( pethp, petmaxhp ) ); + // Robin 0804 + if( pethp <= 0 ) { + CHAR_setInt( defindex, CHAR_RIDEPET, -1 ); + BATTLE_changeRideImage( defindex ); + CHAR_setWorkInt( defindex, CHAR_WORKPETFALL, 1 ); + //print(" defpet_die! "); + } + } + + if( (damage) >= maxhp * 1.2 + 20 ){ + IsUltimate = 2; + }else{ + if( addpoint > 0 ){ + addpoint += CHAR_getWorkInt( defindex, CHAR_WORKULTIMATE ); + CHAR_setWorkInt( defindex, CHAR_WORKULTIMATE, addpoint ); + if( addpoint >= maxhp * 1.2 + 20 )IsUltimate = 1; + } + } + + if( BattleArray[battleindex].type == BATTLE_TYPE_P_vs_P ){ + } +#ifdef _PETSKILL_LER +// ׶ܱ + if(CHAR_getInt(defindex,CHAR_BASEBASEIMAGENUMBER) == 101813 || + CHAR_getInt(defindex,CHAR_BASEBASEIMAGENUMBER) == 101814) IsUltimate = 0; +#endif + + if( IsUltimate ){ + CHAR_setWorkInt( defindex, CHAR_WORKULTIMATE, 0 ); + } + if( playerdamage < 0 ) playerdamage = 0; + if( petdamage < 0 ) petdamage = 0; + *pDamage = playerdamage; + *pPetDamage = petdamage; + + return IsUltimate; +} + +#ifdef _PETSKILL_FIREKILL //ɱר +int BATTLE_DamageSub_FIREKILL( int attackindex, int defindex, int *pDamage, int *pPetDamage, int *pRefrect ) +{ + + int hp, addpoint = 0, maxhp, IsUltimate = 0, react, work, battleindex; + int damage, playerdamage, petdamage; + int attackpet, defpet; + int pethp = 0, petmaxhp = 0; + int defquick = 0, petquick = 0; + damage = *pDamage; + petdamage = *pPetDamage; + playerdamage = damage; + if( damage <= 0 )return 0; + + attackpet = BATTLE_getRidePet( attackindex ); + defpet = BATTLE_getRidePet( defindex ); + if( defpet != -1 ) { + defquick = CHAR_getWorkInt( defindex, CHAR_WORKDEFENCEPOWER ); + petquick = CHAR_getWorkInt( defpet, CHAR_WORKDEFENCEPOWER ); + } + + if( *pRefrect != -1 ){ + react = BATTLE_GetDamageReact( defindex ); + }else{ + react = BATTLE_MD_NONE; + } + + react = BATTLE_MD_NONE; + + battleindex = CHAR_getWorkInt( defindex, CHAR_WORKBATTLEINDEX ); + + if( react == BATTLE_MD_REFLEC ){ + if( BATTLE_IsThrowWepon( CHAR_getItemIndex( attackindex, CHAR_ARM ) ) == FALSE ){ + *pRefrect = BATTLE_MD_REFLEC; + }else{ + *pRefrect = BATTLE_MD_NONE; + } + }else{ + } + +#ifdef _PROFESSION_SKILL // WON ADD ְҵ + if( react == BATTLE_MD_TRAP ){ + if( BATTLE_IsThrowWepon( CHAR_getItemIndex( attackindex, CHAR_ARM ) ) == FALSE ) + *pRefrect = BATTLE_MD_TRAP; + else + *pRefrect = BATTLE_MD_NONE; + } +#endif + +#ifdef _PETSKILL_ACUPUNCTURE + if( react == BATTLE_MD_ACUPUNCTURE ){ + if( BATTLE_IsThrowWepon( CHAR_getItemIndex( attackindex, CHAR_ARM ) ) == FALSE ){ + *pRefrect = BATTLE_MD_ACUPUNCTURE; + }else{ + *pRefrect = BATTLE_MD_NONE; + } + } +#endif + + if( react == BATTLE_MD_ABSROB ){ + hp = CHAR_getInt( defindex, CHAR_HP ); + if( defpet == -1 ) { + hp += damage; + }else { + pethp = CHAR_getInt( defpet, CHAR_HP ); + playerdamage = (damage*petquick)/(defquick+petquick) +1 ; + petdamage = damage - playerdamage +1 ; + hp += playerdamage; + pethp += petdamage; + + } + work = CHAR_getWorkInt( defindex, CHAR_WORKDAMAGEABSROB ) - 1; + CHAR_setWorkInt( defindex, CHAR_WORKDAMAGEABSROB, max( work, 0 ) ); + *pRefrect = BATTLE_MD_ABSROB; + }else + if( *pRefrect == BATTLE_MD_REFLEC ){ + hp = CHAR_getInt( attackindex, CHAR_HP ); + if( attackpet == -1 ) { + hp -= damage; + }else { + pethp = CHAR_getInt( attackpet, CHAR_HP ); + defquick = CHAR_getWorkInt( attackindex, CHAR_WORKDEFENCEPOWER ); + petquick = CHAR_getWorkInt( attackpet, CHAR_WORKDEFENCEPOWER ); + if( pethp > 0 ) { + playerdamage = (damage*petquick)/(defquick+petquick) +1; + petdamage = damage - playerdamage +1 ; + hp -= playerdamage; + pethp -= petdamage; + }else + hp -= damage; + } + work = CHAR_getWorkInt( defindex, CHAR_WORKDAMAGEREFLEC ) - 1; + CHAR_setWorkInt( defindex, CHAR_WORKDAMAGEREFLEC, max( work, 0 ) ); + defindex = attackindex; + defpet = attackpet; + + }else +#ifdef _PROFESSION_SKILL // WON ADD ְҵ + if( *pRefrect == BATTLE_MD_TRAP ){ // + int value=0; + value = CHAR_getWorkInt( defindex, CHAR_WORKMODTRAP ); + damage = value; + + playerdamage = damage; + + hp = CHAR_getInt( attackindex, CHAR_HP ); + if( attackpet == -1 ) { + hp -= damage; + }else { + pethp = CHAR_getInt( attackpet, CHAR_HP ); + defquick = CHAR_getWorkInt( attackindex, CHAR_WORKDEFENCEPOWER ); + petquick = CHAR_getWorkInt( attackpet, CHAR_WORKDEFENCEPOWER ); + if( pethp > 0 ) { + playerdamage = (damage*petquick)/(defquick+petquick) +1; + petdamage = damage - playerdamage +1 ; + hp -= playerdamage; + pethp -= petdamage; + }else + hp -= damage; + } + + CHAR_setWorkInt( defindex, CHAR_WORKTRAP, 0 ); + CHAR_setWorkInt( defindex, CHAR_WORKMODTRAP, 0 ); + + defindex = attackindex; + defpet = attackpet; + + }else +#endif +#ifdef _PETSKILL_ACUPUNCTURE + if( *pRefrect == BATTLE_MD_ACUPUNCTURE ){ //Ƥ + + if( damage%2 != 0 ) + damage+=1; + playerdamage = damage; + + //ȿ۱Ѫ,Ϊ֮ĶǶԹ + hp = CHAR_getInt( defindex, CHAR_HP ); + if( attackpet == -1 ) { + hp -= damage; + if(hp<0)hp=0; + maxhp = CHAR_getWorkInt( defindex, CHAR_WORKMAXHP ); + CHAR_setInt( defindex, CHAR_HP, min( hp, maxhp ) ); + }else { + pethp = CHAR_getInt( defpet, CHAR_HP ); + defquick = CHAR_getWorkInt( defindex, CHAR_WORKDEFENCEPOWER ); + petquick = CHAR_getWorkInt( defpet, CHAR_WORKDEFENCEPOWER ); + if( pethp > 0 ) { + playerdamage = (damage*petquick)/(defquick+petquick) +1; + petdamage = damage - playerdamage +1 ; + if(playerdamage%2 != 0) playerdamage+=1; + if(petdamage%2 != 0) petdamage+=1; + hp -= playerdamage; + pethp -= petdamage; + if(hp<0)hp=0; + maxhp = CHAR_getWorkInt( defindex, CHAR_WORKMAXHP ); + CHAR_setInt( defindex, CHAR_HP, min( hp, maxhp ) ); + if( pethp < 0 ) pethp = 0; + petmaxhp = CHAR_getWorkInt( defpet, CHAR_WORKMAXHP ); + CHAR_setInt( defpet, CHAR_HP, min( pethp, petmaxhp ) ); + }else{ + hp -= damage; + if(hp<0)hp=0; + maxhp = CHAR_getWorkInt( defindex, CHAR_WORKMAXHP ); + CHAR_setInt( defindex, CHAR_HP, min( hp, maxhp ) ); + } + } + + //Change 2003/08/22 + if( (damage) >= CHAR_getWorkInt( defindex, CHAR_WORKMAXHP ) * 1.2 + 20 ){ + int DefSide=0,i; + int defNo = BATTLE_Index2No( battleindex, defindex ); + CHAR_setWorkInt( defindex, CHAR_WORKULTIMATE, 0 ); + + //ijΪϢ + if( defNo >= SIDE_OFFSET ){ + i = defNo - SIDE_OFFSET; + DefSide = 1; + }else{ + i = defNo; + } + i = defNo-DefSide*SIDE_OFFSET; + BattleArray[battleindex].Side[DefSide].Entry[i].flg |= BENT_FLG_ULTIMATE; + } + + //ƤܻغΪ0 + CHAR_setWorkInt( defindex, CHAR_WORKACUPUNCTURE, 0); + //if( CHAR_getWorkInt( defindex, CHAR_WORKSLEEP ) > 0 )//޻˯ + // CHAR_setWorkInt( defindex, CHAR_WORKSLEEP, 0); + + //۹Ѫ + hp = CHAR_getInt( attackindex, CHAR_HP ); + if( attackpet == -1 ) { + hp -= damage/2; + }else { + pethp = CHAR_getInt( attackpet, CHAR_HP ); + defquick = CHAR_getWorkInt( attackindex, CHAR_WORKDEFENCEPOWER ); + petquick = CHAR_getWorkInt( attackpet, CHAR_WORKDEFENCEPOWER ); + if( pethp > 0 ) { + playerdamage = (damage*petquick)/(defquick+petquick) +1; + petdamage = damage - playerdamage +1 ; + if(playerdamage%2 != 0) playerdamage+=1; + if(petdamage%2 != 0) petdamage+=1; + hp -= playerdamage/2; + pethp -= petdamage/2; + }else + hp -= damage/2; + } + + playerdamage /= 2; + + defindex = attackindex; + defpet = attackpet; + + }else +#endif + if( react == BATTLE_MD_VANISH ){ + hp = CHAR_getInt( defindex, CHAR_HP ); + if( defpet != -1 ) + pethp = CHAR_getInt( defpet, CHAR_HP ); + work = CHAR_getWorkInt( defindex, CHAR_WORKDAMAGEVANISH ) - 1; + CHAR_setWorkInt( defindex, CHAR_WORKDAMAGEVANISH, max( work, 0 ) ); + *pRefrect = BATTLE_MD_VANISH; + //andy_log + //print("*pRefrect = BATTLE_MD_VANISH !!\n"); + }else{ + hp = CHAR_getInt( defindex, CHAR_HP ); + if( defpet == -1 ) { + hp -= damage; + }else { + pethp = CHAR_getInt( defpet, CHAR_HP ); + if( pethp > 0 ) { + //andy_edit 2002/07/31 + defquick = defquick>0?defquick:1; + petquick = petquick>0?petquick:1; + playerdamage = (damage*petquick)/(defquick+petquick)+ 1; + //playerdamage = (damage*petquick)/(defquick+petquick) +1; + petdamage = damage - playerdamage +1; + hp -= playerdamage; + pethp -= petdamage; + //print(" def_damage:%d ridepet_damage:%d ", (damage*petquick)/(defquick+petquick), damage - playerdamage); + }else + hp -= damage; + } + *pRefrect = 0; + } + if( hp < 0 ){ + addpoint = -hp; + hp = 0; + } + + maxhp = CHAR_getWorkInt( defindex, CHAR_WORKMAXHP ); + CHAR_setInt( defindex, CHAR_HP, min( hp, maxhp ) ); + if( defpet != -1 ) { + if( pethp < 0 ) pethp = 0; + petmaxhp = CHAR_getWorkInt( defpet, CHAR_WORKMAXHP ); + CHAR_setInt( defpet, CHAR_HP, min( pethp, petmaxhp ) ); + // Robin 0804 + if( pethp <= 0 ) { + CHAR_setInt( defindex, CHAR_RIDEPET, -1 ); + BATTLE_changeRideImage( defindex ); + CHAR_setWorkInt( defindex, CHAR_WORKPETFALL, 1 ); + //print(" defpet_die! "); + } + } + + if( (damage) >= maxhp * 1.2 + 20 ){ + IsUltimate = 2; + }else{ + if( addpoint > 0 ){ + addpoint += CHAR_getWorkInt( defindex, CHAR_WORKULTIMATE ); + CHAR_setWorkInt( defindex, CHAR_WORKULTIMATE, addpoint ); + if( addpoint >= maxhp * 1.2 + 20 )IsUltimate = 1; + } + } + + if( BattleArray[battleindex].type == BATTLE_TYPE_P_vs_P ){ + } + +#ifdef _PETSKILL_LER +// ׶ܱ + if(CHAR_getInt(defindex,CHAR_BASEBASEIMAGENUMBER) == 101813 || + CHAR_getInt(defindex,CHAR_BASEBASEIMAGENUMBER) == 101814) IsUltimate = 0; +#endif + + if( IsUltimate ){ + CHAR_setWorkInt( defindex, CHAR_WORKULTIMATE, 0 ); + } + if( playerdamage < 0 ) playerdamage = 0; + if( petdamage < 0 ) petdamage = 0; + *pDamage = playerdamage; + *pPetDamage = petdamage; + + return IsUltimate; +} +#endif + + +// Robin 0910 RidePetDebug +int BATTLE_DamageSub2( int attackindex, int defindex, int *pDamage, int *pPetDamage, int *pRefrect ) +{ + + int hp, addpoint = 0, maxhp, IsUltimate = 0, react, work, battleindex; + int damage, playerdamage, petdamage; + int attackpet, defpet; + int pethp = 0, petmaxhp = 0; + + damage = *pDamage; + petdamage = *pPetDamage; + playerdamage = *pDamage; + + if( damage <= 0 )return 0; + + attackpet = BATTLE_getRidePet( attackindex ); + defpet = BATTLE_getRidePet( defindex ); + + if( *pRefrect != -1 ){ + react = BATTLE_GetDamageReact( defindex ); + }else{ + react = BATTLE_MD_NONE; + } + + if( react == BATTLE_MD_REFLEC ){ + if( BATTLE_IsThrowWepon( CHAR_getItemIndex( attackindex, CHAR_ARM ) ) == FALSE ){ + *pRefrect = BATTLE_MD_REFLEC; + }else{ + *pRefrect = BATTLE_MD_NONE; + } + } + +#ifdef _PROFESSION_SKILL // WON ADD ְҵ + if( react == BATTLE_MD_TRAP ){ + if( BATTLE_IsThrowWepon( CHAR_getItemIndex( attackindex, CHAR_ARM ) ) == FALSE ) + *pRefrect = BATTLE_MD_TRAP; + else + *pRefrect = BATTLE_MD_NONE; + } +#endif + + if( react == BATTLE_MD_ABSROB ){ + + hp = CHAR_getInt( defindex, CHAR_HP ); + hp += playerdamage; + if( defpet != -1 ) { + pethp = CHAR_getInt( defpet, CHAR_HP ); + pethp += petdamage; + } + + work = CHAR_getWorkInt( defindex, CHAR_WORKDAMAGEABSROB ) - 1; + CHAR_setWorkInt( defindex, CHAR_WORKDAMAGEABSROB, max( work, 0 ) ); + + *pRefrect = BATTLE_MD_ABSROB; + + }else + if( *pRefrect == BATTLE_MD_REFLEC ){ + + hp = CHAR_getInt( attackindex, CHAR_HP ); + hp -= playerdamage; + if( attackpet != -1 ) { + pethp = CHAR_getInt( attackpet, CHAR_HP ); + if( pethp > 0 ) { + pethp -= petdamage; + } + } + + work = CHAR_getWorkInt( defindex, CHAR_WORKDAMAGEREFLEC ) - 1; + CHAR_setWorkInt( defindex, CHAR_WORKDAMAGEREFLEC, max( work, 0 ) ); + + defindex = attackindex; + defpet = attackpet; + + }else +#ifdef _PROFESSION_SKILL // WON ADD ְҵ + if( *pRefrect == BATTLE_MD_TRAP ){ // + + hp = CHAR_getInt( attackindex, CHAR_HP ); + hp -= playerdamage; + if( attackpet != -1 ) { + pethp = CHAR_getInt( attackpet, CHAR_HP ); + if( pethp > 0 ) { + pethp -= petdamage; + } + } + + CHAR_setWorkInt( defindex, CHAR_WORKTRAP, 0 ); + CHAR_setWorkInt( defindex, CHAR_WORKMODTRAP, 0 ); + + defindex = attackindex; + defpet = attackpet; + + }else +#endif + if( react == BATTLE_MD_VANISH ){ + hp = CHAR_getInt( defindex, CHAR_HP ); + if( defpet != -1 ) + pethp = CHAR_getInt( defpet, CHAR_HP ); + + work = CHAR_getWorkInt( defindex, CHAR_WORKDAMAGEVANISH ) - 1; + CHAR_setWorkInt( defindex, CHAR_WORKDAMAGEVANISH, max( work, 0 ) ); + + *pRefrect = BATTLE_MD_VANISH; + + }else{ + hp = CHAR_getInt( defindex, CHAR_HP ); + hp -= playerdamage; + if( defpet != -1 ){ + pethp = CHAR_getInt( defpet, CHAR_HP ); + if( pethp > 0 ) { + pethp -= petdamage; + //print(" def_damage:%d ridepet_damage:%d ", (damage*petquick)/(defquick+petquick), damage - playerdamage); + } + } + *pRefrect = 0; + } + + if( hp < 0 ){ + addpoint = -hp; + hp = 0; + } + + maxhp = CHAR_getWorkInt( defindex, CHAR_WORKMAXHP ); + + CHAR_setInt( defindex, CHAR_HP, min( hp, maxhp ) ); + + + if( defpet != -1 ) { + if( pethp < 0 ) pethp = 0; + petmaxhp = CHAR_getWorkInt( defpet, CHAR_WORKMAXHP ); + CHAR_setInt( defpet, CHAR_HP, min( pethp, petmaxhp ) ); + + // Robin 0804 + if( pethp <= 0 ) { + CHAR_setInt( defindex, CHAR_RIDEPET, -1 ); + BATTLE_changeRideImage( defindex ); + CHAR_setWorkInt( defindex, CHAR_WORKPETFALL, 1 ); + //print(" defpet_die! "); + } + } + + if( (damage) >= maxhp * 1.2 + 20 ){ + IsUltimate = 2; + }else{ + if( addpoint > 0 ){ + addpoint += CHAR_getWorkInt( defindex, CHAR_WORKULTIMATE ); + CHAR_setWorkInt( defindex, CHAR_WORKULTIMATE, addpoint ); + if( addpoint >= maxhp * 1.2 + 20 )IsUltimate = 1; + } + } + + battleindex = CHAR_getWorkInt( defindex, CHAR_WORKBATTLEINDEX ); + if( BattleArray[battleindex].type == BATTLE_TYPE_P_vs_P ){ + } +#ifdef _PETSKILL_LER +// ׶ܱ + if(CHAR_getInt(defindex,CHAR_BASEBASEIMAGENUMBER) == 101813 || + CHAR_getInt(defindex,CHAR_BASEBASEIMAGENUMBER) == 101814) IsUltimate = 0; +#endif + + if( IsUltimate ){ + CHAR_setWorkInt( defindex, CHAR_WORKULTIMATE, 0 ); + } + + //*pDamage = damage; + *pDamage = playerdamage; + *pPetDamage = petdamage; + + return IsUltimate; +} + + + +void BATTLE_DamageSubCale( + int attackindex, + int defindex, + int *pDamage, + int *pPetDamage +) +{ + int pethp; + int damage, playerdamage, petdamage; + int attackpet, defpet; + int defquick = 0, petquick = 0; + + damage = *pDamage; + petdamage = *pPetDamage; + playerdamage = damage; + + attackpet = BATTLE_getRidePet( attackindex ); + defpet = BATTLE_getRidePet( defindex ); + + defquick = CHAR_getWorkInt( defindex, CHAR_WORKDEFENCEPOWER ); + defquick = ( defquick < 1)?1:defquick; + if( defpet != -1 ) { + petquick = CHAR_getWorkInt( defpet, CHAR_WORKDEFENCEPOWER ); + petquick = ( petquick < 1)?1:petquick; + + pethp = CHAR_getInt( defpet, CHAR_HP ); + if( pethp > 0 ) { + playerdamage = (damage*petquick)/(defquick+petquick); + petdamage = damage - playerdamage; + if( damage > 0 && playerdamage < 1 ) + playerdamage = 1; + } + } + + *pDamage = playerdamage; + *pPetDamage = petdamage; + +} + +int BATTLE_Attack( int battleindex, int attackNo, int defNo ) +{ + char szBuffer[512]=""; + char szCommand[1024]; + int damage = 0, petdamage = 0, attackindex, toindex, ultimate = 0, + defindex, react = 0, statusDefNo, opt = 0; + int flg = 0, iWork, par, perStatus, i, DefSide = 0, Guardian = -1; + BOOL iRet = TRUE; + int suitpoison=30;//ж% + + attackindex = BATTLE_No2Index( battleindex, attackNo ); + defindex = toindex = BATTLE_No2Index( battleindex, defNo ); + if( CHAR_CHECKINDEX( attackindex ) == FALSE ) return FALSE; + if( CHAR_CHECKINDEX( defindex ) == FALSE ) return FALSE; + + +#ifdef _PETSKILL_RETRACE + Battle_Attack_ReturnData_x.Battle_Attack_ReturnData = 0; +#endif + + if( gWeponType == ITEM_BOW ){ + if( toindex < 0 || CHAR_getInt( toindex, CHAR_HP ) <= 0 ){ + snprintf( szCommand, sizeof( szCommand ), "r%X|f0|d0|", defNo ); + BATTLESTR_ADD( szCommand ); + return FALSE; + } + } + + if( CHAR_getInt( toindex, CHAR_HP ) <= 0 ) return FALSE; + + if( CHAR_getInt( attackindex, CHAR_HP ) <= 0 ) return FALSE; + + // ⡢ + if( BATTLE_GetDamageReact( attackindex ) > 0 ) iRet = FALSE; + else if( BATTLE_GetDamageReact( defindex ) > 0 ) iRet = FALSE; + + // ģʽ + iWork = BATTLE_AttackSeq( attackindex, toindex, &damage, &Guardian, opt ); + + if( Guardian >= 0 ) + defindex = BATTLE_No2Index( battleindex, Guardian ); + + if( gDamageDiv != 0.0 && damage > 0 ){ + damage /= gDamageDiv; + if( damage <= 0 ) damage = 1; + } + + par = BATTLE_AttrAdjust( attackindex, defindex, 100 ); + react = 0; + + ultimate = BATTLE_DamageSub( attackindex, defindex, &damage, &petdamage, &react ); + +#ifdef _PROFESSION_SKILL // WON ADD ְҵ + if( react == BATTLE_MD_TRAP ){ + defindex = attackindex; + statusDefNo = attackNo; + } +#endif +#ifdef _PETSKILL_ACUPUNCTURE + if( react == BATTLE_MD_ACUPUNCTURE ){ + defindex = attackindex; + statusDefNo = attackNo; + } +#endif + if( react == BATTLE_MD_REFLEC ){ + defindex = attackindex; + statusDefNo = attackNo; + }else{ + if( 0 <= Guardian && Guardian <= 19 ){ + statusDefNo = Guardian; + }else{ + statusDefNo = defNo; + } + } + +#ifdef _PETSKILL_ACUPUNCTURE + if( react == BATTLE_MD_ACUPUNCTURE ){ //Ƥʱ޷򷽵״̬,԰index + defindex = toindex = BATTLE_No2Index( battleindex, defNo ); + statusDefNo = defNo; + } +#endif + + //˯ʱ,״̬(Ҳ״̬) + if( damage > 0 && ( react != BATTLE_MD_ABSROB ) && ( react != BATTLE_MD_VANISH ) ){ + BATTLE_DamageWakeUp( battleindex, defindex ); + } + +#ifdef _PETSKILL_ACUPUNCTURE + if( react == BATTLE_MD_ACUPUNCTURE ){ + defindex = attackindex; + statusDefNo = attackNo; + } +#endif + + switch( iWork ){ + case BATTLE_RET_ALLGUARD: + //snprintf( szBuffer, sizeof(szBuffer), + // "(%s)(%s),׵ر㿪", + // CHAR_getUseName( attackindex ), + // CHAR_getUseName( defindex ) + //); + flg |= BCF_NORMAL; +#ifdef _PETSKILL_RETRACE + Battle_Attack_ReturnData_x.Battle_Attack_ReturnData = BATTLE_RET_ALLGUARD; +#endif + break; + case BATTLE_RET_MISS: + //snprintf( szBuffer, sizeof(szBuffer), + // "(%s)(%s),ûС", + // CHAR_getUseName( attackindex ), + // CHAR_getUseName( defindex ) + //); +#ifdef _PETSKILL_RETRACE + Battle_Attack_ReturnData_x.Battle_Attack_ReturnData = BATTLE_RET_MISS; +#endif + break; + case BATTLE_RET_DODGE: + //snprintf( szBuffer, sizeof(szBuffer), + // "(%s)(%s)㿪(%.2f%%)", + // CHAR_getUseName( attackindex ), + // CHAR_getUseName( defindex ), + // gDuckPer + //); + flg |= BCF_DODGE; +#ifdef _PETSKILL_RETRACE + Battle_Attack_ReturnData_x.Battle_Attack_ReturnData = BATTLE_RET_DODGE; +#endif + break; + case BATTLE_RET_NORMAL: + //snprintf( szBuffer, sizeof(szBuffer), + // "(%s)ܵ(%s)Ĺ(%d)(%d:%d:%d%%)", + // CHAR_getUseName( attackindex ), + // CHAR_getUseName( defindex ), + // damage, + // CHAR_getWorkInt( attackindex, CHAR_WORKATTACKPOWER ), + // CHAR_getWorkInt( defindex, CHAR_WORKDEFENCEPOWER ), + // par + //); + //andy_edit + flg |= BATTLE_getReactFlg( defindex, react); + flg |= BCF_NORMAL; + break; + case BATTLE_RET_CRITICAL: + //snprintf( szBuffer, sizeof(szBuffer), + //"(%s)(%s)CRITICAL(%d%%)(%d)(%d:%d:%d%%)", + // CHAR_getUseName( attackindex ), + // CHAR_getUseName( defindex ), + // (int)(gCriper*0.01), + // damage, + // CHAR_getWorkInt( attackindex, CHAR_WORKATTACKPOWER ), + // CHAR_getWorkInt( defindex, CHAR_WORKDEFENCEPOWER ), + // par + //); + //andy_edit + flg |= BATTLE_getReactFlg( defindex, react); + flg |= BCF_KAISHIN; + iRet = FALSE; + break; +#ifdef _EQUIT_ARRANGE + case BATTLE_RET_ARRANGE: + //snprintf( szBuffer, sizeof(szBuffer), + // "(%s)(%s)(%.2f%%)", + // CHAR_getUseName( attackindex ), + // CHAR_getUseName( defindex ), + // gDuckPer + //); + flg |= BCF_B_ARRANGE; +#ifdef _PETSKILL_RETRACE + Battle_Attack_ReturnData_x.Battle_Attack_ReturnData = BATTLE_RET_ARRANGE; +#endif + break; +#endif + } + + + if( CHAR_getWorkInt( defindex, CHAR_WORKBATTLECOM1 ) == BATTLE_COM_GUARD + && CHAR_getWorkInt( defindex, CHAR_WORKCONFUSION ) <= 0){ + strncat( szBuffer, "(GUARD)", sizeof( szBuffer ) ); + flg |= BCF_GUARD; + iRet = FALSE; + } + + if( CHAR_getInt( defindex, CHAR_HP ) <= 0 ){ + if( CHAR_getWorkInt( defindex, CHAR_WORKBATTLEFLG ) & CHAR_BATTLEFLG_ABIO ){ + ultimate = 1; + }else if( CHAR_getInt( defindex, CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER && flg & BCF_KAISHIN ){ + if( RAND( 1, 100 ) < 50 ){ + ultimate = 1; + } + } + +#ifdef _PETSKILL_LER +// ׶ܱ + if(CHAR_getInt(defindex,CHAR_BASEBASEIMAGENUMBER) == 101813 || + CHAR_getInt(defindex,CHAR_BASEBASEIMAGENUMBER) == 101814) ultimate = 0; +#endif + iRet = FALSE; + flg |= BCF_DEATH; + + if( ultimate == 1 ){ + flg |= BCF_ULTIMATE_1; + strcatsafe( szBuffer,sizeof(szBuffer), "ultimate?" ); + } + if( ultimate == 2 ){ + flg |= BCF_ULTIMATE_2; + strcatsafe( szBuffer,sizeof(szBuffer), "ultimate?" ); + } + } + + //BATTLE_BroadCast( battleindex, szBuffer, + // (attackNo >= 10)? CHAR_COLORGRAY : CHAR_COLORPURPLE ) ; + + +#ifdef _PETSKILL_ACUPUNCTURE + if( react == BATTLE_MD_ACUPUNCTURE ){ //Ƥᷴ״̬,ҪĻ + defindex = toindex = BATTLE_No2Index( battleindex, defNo ); + statusDefNo = defNo; + } + //ע:֮ҪҪٸĻԭ.......???? +#endif + +#ifdef _SUIT_ADDPART4 + if( gBattleStausChange == -1 && CHAR_getWorkInt( attackindex, CHAR_SUITPOISON ) > 0 )//װ + gBattleStausChange = 1,gBattleStausTurn = 3, suitpoison=CHAR_getWorkInt( attackindex, CHAR_SUITPOISON ); +#endif + + if( damage > 0 && gBattleStausChange >= 0 ){ + if( BATTLE_StatusAttackCheck( + attackindex, + defindex, + gBattleStausChange, + suitpoison, + 40, + 2.0, + &perStatus + ) == TRUE + ){ + CHAR_setWorkInt( defindex, StatusTbl[gBattleStausChange], + gBattleStausTurn + 1 ); + + if( gBattleStausChange == BATTLE_ST_DRUNK ){ + CHAR_setWorkInt( defindex, CHAR_WORKDRUNK, + CHAR_getWorkInt( defindex, CHAR_WORKDRUNK ) / 2 ); + } + +#ifdef _PET_SKILL_SARS // WON ADD ɷ + if( gBattleStausChange == BATTLE_ST_SARS ){ + CHAR_setWorkInt( defindex, CHAR_WORKMODSARS, 1); + } +#endif + + if( gBattleStausChange == BATTLE_ST_PARALYSIS + || gBattleStausChange == BATTLE_ST_SLEEP + || gBattleStausChange == BATTLE_ST_STONE + || gBattleStausChange == BATTLE_ST_BARRIER + ){ + CHAR_setWorkInt( defindex, CHAR_WORKBATTLECOM1, BATTLE_COM_NONE ); + } + + //snprintf( szBuffer, sizeof(szBuffer), + //"(%s)(%s)(%d%%)", + // CHAR_getUseName( defindex ), + // aszStatusFull[gBattleStausChange], + // perStatus + //); + //BATTLE_BroadCast( battleindex, szBuffer, + // (attackNo >= 10)? CHAR_COLORGRAY : CHAR_COLORPURPLE ) ; + + BATTLE_BadStatusString( statusDefNo, gBattleStausChange ); + }else{ + //snprintf( szBuffer, sizeof(szBuffer), + //"(%s)޷ɹ\(%d%%)", + // aszStatusFull[gBattleStausChange], + // perStatus ); + //BATTLE_BroadCast( battleindex, szBuffer, + // (attackNo >= 10)? CHAR_COLORGRAY : CHAR_COLORPURPLE ) ; + } + } +#ifdef _SHOOTCHESTNUT // Syu ADD 輼 + if ( ( damage > 0 ) && ( CHAR_getWorkInt( attackindex , CHAR_WORKBATTLECOM1 ) == BATTLE_COM_S_ATTSHOOT ) ) { + if ( RAND ( 1 , 5 ) > 4 ) { + CHAR_setWorkInt( defindex, CHAR_WORKSLEEP , 3 ); //趨˯ + CHAR_setWorkInt( defindex, CHAR_WORKBATTLECOM1, BATTLE_COM_NONE );//Ϊ趨˻˯,趨޶ + } + } +#endif +#ifdef _PSKILL_GYRATE + if ( ( damage > 0 ) && ( CHAR_getWorkInt( attackindex , CHAR_WORKBATTLECOM1 ) == BATTLE_COM_S_GYRATE ) && (CHAR_getWorkInt( attackindex , CHAR_WORKBATTLECOM5 ) >0) ) { + if ( RAND ( 1 , 100 ) <= CHAR_getWorkInt( attackindex, CHAR_WORKBATTLECOM7) ) { + int iEffect = CHAR_getWorkInt( attackindex , CHAR_WORKBATTLECOM5 ); + CHAR_setWorkInt( defindex, StatusTbl[iEffect] , CHAR_getWorkInt( attackindex , CHAR_WORKBATTLECOM6 ) ); //趨˯ + CHAR_setWorkInt( defindex, CHAR_WORKBATTLECOM1, BATTLE_COM_NONE );//Ϊ趨˻˯,趨޶ + } + } +#endif + if( damage > 0 ){ +#ifdef _TAKE_ITEMDAMAGE + if( BATTLE_ItemCrushSeq( attackindex, defindex, damage) == TRUE ){ +#else + if( BATTLE_ItemCrushSeq( defindex ) == TRUE ){ +#endif + flg |= BCF_CRUSH; + } + } + +#ifdef _PROFESSION_SKILL // WON ADD ְҵ + if( damage > 0 && (CHAR_getInt(attackindex, CHAR_WHICHTYPE)== CHAR_TYPEPLAYER) ){ + int i; + // 𡢱׸ + for( i=0; i<3; i++ ){ + int turn = 0, status = -1; + + turn = CHAR_getWorkInt( attackindex, CHAR_WORK_F_ENCLOSE_2+i ); + + if( turn > 0 ){ + int skill_type = CHAR_getWorkInt( attackindex, CHAR_WORKBATTLECOM1 ); + int perStatus = 0, j = 0; + int skill_level = CHAR_getWorkInt( attackindex, CHAR_WORKMOD_F_ENCLOSE_2+i ); + char pszP[3][10] = { "","˪","" }; + int img1 = 101697, img2 = 101698 + i; + + // ״̬ + for( j = 1; j < BATTLE_ST_END; j ++ ){ + if( strncmp( pszP[i], aszStatus[j], 2 ) == 0 ){ + status = j; + break; + } + } + + // + perStatus = 20 + skill_level * 2; + + // غ + if( skill_level >= 10 ) turn = 3; + else if( skill_level >= 5 ) turn = 2; + else turn = 1; + + // ׸һغ + if( i == 2 ) turn = 1; + + // 𡢱׸帽ӹ +// Terry add fix Ȯbug + if(Guardian >= 0) iRet = BATTLE_PROFESSION_RANG_ATTACK_DAMAGE(attackindex, attackNo, Guardian, skill_type, status, turn, perStatus, 0, img1, img2 ); + else iRet = BATTLE_PROFESSION_RANG_ATTACK_DAMAGE(attackindex, attackNo, defNo, skill_type, status, turn, perStatus, 0, img1, img2 ); + + break; + } + } + } +#endif + + + if( 0 <= Guardian && Guardian <= 19 ){ + iRet = FALSE; + flg |= BCF_GUARDIAN; + snprintf( szCommand, sizeof( szCommand ), + "r%X|f%X|d%X|p%X|g%X|", + defNo, + flg, + damage, + petdamage, + Guardian ); + }else{ + snprintf( szCommand, sizeof( szCommand ), + "r%X|f%X|d%X|p%X|", + defNo, + flg, + damage, + petdamage ); + } + + BATTLESTR_ADD( szCommand ); + + defNo = BATTLE_Index2No( battleindex, defindex ); + + if( defNo >= SIDE_OFFSET ){ + i = defNo - SIDE_OFFSET; + DefSide = 1; + }else{ + i = defNo; + } + + i = defNo-DefSide*SIDE_OFFSET; + if( ultimate > 0 ){ + BattleArray[battleindex].Side[DefSide].Entry[i].flg |= BENT_FLG_ULTIMATE; + } + return iRet; + +} + +#ifdef _PETSKILL_FIREKILL +int BATTLE_Attack_FIREKILL( int battleindex, int attackNo, int defNo ) +{ + char szBuffer[512]=""; + char szCommand[1024]; + int damage = 0, petdamage = 0, attackindex, toindex, ultimate = 0, + defindex, react = 0, statusDefNo, opt = 0; + int flg = 0, iWork, par, perStatus, i, DefSide = 0, Guardian = -1; + BOOL iRet = TRUE; + + attackindex = BATTLE_No2Index( battleindex, attackNo ); + defindex = toindex = BATTLE_No2Index( battleindex, defNo ); + if( CHAR_CHECKINDEX( attackindex ) == FALSE ) return FALSE; + if( CHAR_CHECKINDEX( defindex ) == FALSE ) return FALSE; + + +#ifdef _PETSKILL_RETRACE + Battle_Attack_ReturnData_x.Battle_Attack_ReturnData = 0; +#endif + + if( gWeponType == ITEM_BOW ){ + if( toindex < 0 || CHAR_getInt( toindex, CHAR_HP ) <= 0 ){ + snprintf( szCommand, sizeof( szCommand ), "r%X|f0|d0|", defNo ); + BATTLESTR_ADD( szCommand ); + return FALSE; + } + } + + if( CHAR_getInt( toindex, CHAR_HP ) <= 0 ) return FALSE; + + if( CHAR_getInt( attackindex, CHAR_HP ) <= 0 ) return FALSE; + + // ⡢ +// if( BATTLE_GetDamageReact( attackindex ) > 0 ) iRet = FALSE; +// else if( BATTLE_GetDamageReact( defindex ) > 0 ) iRet = FALSE; + + // ģʽ + iWork = BATTLE_AttackSeq( attackindex, toindex, &damage, &Guardian, opt ); + + if( Guardian >= 0 ) + defindex = BATTLE_No2Index( battleindex, Guardian ); + + if( gDamageDiv != 0.0 && damage > 0 ){ + damage /= gDamageDiv; + if( damage <= 0 ) damage = 1; + } + + par = BATTLE_AttrAdjust( attackindex, defindex, 100 ); + react = 0; + + ultimate = BATTLE_DamageSub_FIREKILL( attackindex, defindex, &damage, &petdamage, &react ); + +//#ifdef _PROFESSION_SKILL // WON ADD ְҵ +// if( react == BATTLE_MD_TRAP ){ +// defindex = attackindex; +// statusDefNo = attackNo; +// } +//#endif +//#ifdef _PETSKILL_ACUPUNCTURE +// if( react == BATTLE_MD_ACUPUNCTURE ){ +// defindex = attackindex; +// statusDefNo = attackNo; +// } +//#endif +// if( react == BATTLE_MD_REFLEC ){ +// defindex = attackindex; +// statusDefNo = attackNo; +// }else{ + if( 0 <= Guardian && Guardian <= 19 ){ + statusDefNo = Guardian; + }else{ + statusDefNo = defNo; + } +// } + +//#ifdef _PETSKILL_ACUPUNCTURE +// if( react == BATTLE_MD_ACUPUNCTURE ){ //Ƥʱ޷򷽵״̬,԰index +// defindex = toindex = BATTLE_No2Index( battleindex, defNo ); +// statusDefNo = defNo; +// } +//#endif + + //˯ʱ,״̬(Ҳ״̬) + if( damage > 0 && ( react != BATTLE_MD_ABSROB ) && ( react != BATTLE_MD_VANISH ) ){ + BATTLE_DamageWakeUp( battleindex, defindex ); + } + +//#ifdef _PETSKILL_ACUPUNCTURE +// if( react == BATTLE_MD_ACUPUNCTURE ){ +// defindex = attackindex; +// statusDefNo = attackNo; +// } +//#endif + + switch( iWork ){ + case BATTLE_RET_ALLGUARD: + //snprintf( szBuffer, sizeof(szBuffer), + // "(%s)(%s),׵ر㿪", + // CHAR_getUseName( attackindex ), + // CHAR_getUseName( defindex ) + //); + flg |= BCF_NORMAL; + break; + case BATTLE_RET_MISS: + //snprintf( szBuffer, sizeof(szBuffer), + // "(%s)(%s),ûС", + // CHAR_getUseName( attackindex ), + // CHAR_getUseName( defindex ) + //); + break; + case BATTLE_RET_DODGE: + //snprintf( szBuffer, sizeof(szBuffer), + // "(%s)(%s)㿪(%.2f%%)", + // CHAR_getUseName( attackindex ), + // CHAR_getUseName( defindex ), + // gDuckPer + //); + flg |= BCF_DODGE; +#ifdef _PETSKILL_RETRACE + Battle_Attack_ReturnData_x.Battle_Attack_ReturnData = BATTLE_RET_DODGE; +#endif + break; + case BATTLE_RET_NORMAL: + //snprintf( szBuffer, sizeof(szBuffer), + // "(%s)ܵ(%s)Ĺ(%d)(%d:%d:%d%%)", + // CHAR_getUseName( attackindex ), + // CHAR_getUseName( defindex ), + // damage, + // CHAR_getWorkInt( attackindex, CHAR_WORKATTACKPOWER ), + // CHAR_getWorkInt( defindex, CHAR_WORKDEFENCEPOWER ), + // par + //); + //andy_edit + flg |= BATTLE_getReactFlg( defindex, react); + flg |= BCF_NORMAL; + break; + case BATTLE_RET_CRITICAL: + //snprintf( szBuffer, sizeof(szBuffer), + //"(%s)(%s)CRITICAL(%d%%)(%d)(%d:%d:%d%%)", + // CHAR_getUseName( attackindex ), + // CHAR_getUseName( defindex ), + // (int)(gCriper*0.01), + // damage, + // CHAR_getWorkInt( attackindex, CHAR_WORKATTACKPOWER ), + // CHAR_getWorkInt( defindex, CHAR_WORKDEFENCEPOWER ), + // par + //); + //andy_edit + flg |= BATTLE_getReactFlg( defindex, react); + flg |= BCF_KAISHIN; + iRet = FALSE; + break; +#ifdef _EQUIT_ARRANGE + case BATTLE_RET_ARRANGE: + //snprintf( szBuffer, sizeof(szBuffer), + // "(%s)(%s)(%.2f%%)", + // CHAR_getUseName( attackindex ), + // CHAR_getUseName( defindex ), + // gDuckPer + //); + flg |= BCF_B_ARRANGE; + break; +#endif + } + + + if( CHAR_getWorkInt( defindex, CHAR_WORKBATTLECOM1 ) == BATTLE_COM_GUARD + && CHAR_getWorkInt( defindex, CHAR_WORKCONFUSION ) <= 0){ + strncat( szBuffer, "(GUARD)", sizeof( szBuffer ) ); + flg |= BCF_GUARD; + iRet = FALSE; + } + + if( CHAR_getInt( defindex, CHAR_HP ) <= 0 ){ + if( CHAR_getWorkInt( defindex, CHAR_WORKBATTLEFLG ) & CHAR_BATTLEFLG_ABIO ){ + ultimate = 1; + }else if( CHAR_getInt( defindex, CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER && flg & BCF_KAISHIN ){ + if( RAND( 1, 100 ) < 50 ){ + ultimate = 1; + } + } +#ifdef _PETSKILL_LER +// ׶ܱ + if(CHAR_getInt(defindex,CHAR_BASEBASEIMAGENUMBER) == 101813 || + CHAR_getInt(defindex,CHAR_BASEBASEIMAGENUMBER) == 101814) ultimate = 0; +#endif + iRet = FALSE; + flg |= BCF_DEATH; + + if( ultimate == 1 ){ + flg |= BCF_ULTIMATE_1; + strcatsafe( szBuffer,sizeof(szBuffer), "ultimate?" ); + } + if( ultimate == 2 ){ + flg |= BCF_ULTIMATE_2; + strcatsafe( szBuffer,sizeof(szBuffer), "ultimate?" ); + } + } + + //BATTLE_BroadCast( battleindex, szBuffer, + // (attackNo >= 10)? CHAR_COLORGRAY : CHAR_COLORPURPLE ) ; + + +//#ifdef _PETSKILL_ACUPUNCTURE +// if( react == BATTLE_MD_ACUPUNCTURE ){ //Ƥᷴ״̬,ҪĻ +// defindex = toindex = BATTLE_No2Index( battleindex, defNo ); +// statusDefNo = defNo; +// } +// //ע:֮ҪҪٸĻԭ.......???? +//#endif + + + if( damage > 0 && gBattleStausChange >= 0 ){ + if( BATTLE_StatusAttackCheck( + attackindex, + defindex, + gBattleStausChange, + 30, + 40, + 2.0, + &perStatus + ) == TRUE + ){ + CHAR_setWorkInt( defindex, StatusTbl[gBattleStausChange], + gBattleStausTurn + 1 ); + + if( gBattleStausChange == BATTLE_ST_DRUNK ){ + CHAR_setWorkInt( defindex, CHAR_WORKDRUNK, + CHAR_getWorkInt( defindex, CHAR_WORKDRUNK ) / 2 ); + } + +#ifdef _PET_SKILL_SARS // WON ADD ɷ + if( gBattleStausChange == BATTLE_ST_SARS ){ + CHAR_setWorkInt( defindex, CHAR_WORKMODSARS, 1); + } +#endif + + if( gBattleStausChange == BATTLE_ST_PARALYSIS + || gBattleStausChange == BATTLE_ST_SLEEP + || gBattleStausChange == BATTLE_ST_STONE + || gBattleStausChange == BATTLE_ST_BARRIER + ){ + CHAR_setWorkInt( defindex, CHAR_WORKBATTLECOM1, BATTLE_COM_NONE ); + } + + //snprintf( szBuffer, sizeof(szBuffer), + //"(%s)(%s)(%d%%)", + // CHAR_getUseName( defindex ), + // aszStatusFull[gBattleStausChange], + // perStatus + //); + //BATTLE_BroadCast( battleindex, szBuffer, + // (attackNo >= 10)? CHAR_COLORGRAY : CHAR_COLORPURPLE ) ; + + BATTLE_BadStatusString( statusDefNo, gBattleStausChange ); + }else{ + //snprintf( szBuffer, sizeof(szBuffer), + //"(%s)޷ɹ\(%d%%)", + // aszStatusFull[gBattleStausChange], + // perStatus ); + //BATTLE_BroadCast( battleindex, szBuffer, + // (attackNo >= 10)? CHAR_COLORGRAY : CHAR_COLORPURPLE ) ; + } + } +#ifdef _SHOOTCHESTNUT // Syu ADD 輼 + if ( ( damage > 0 ) && ( CHAR_getWorkInt( attackindex , CHAR_WORKBATTLECOM1 ) == BATTLE_COM_S_ATTSHOOT ) ) { + if ( RAND ( 1 , 5 ) > 4 ) { + CHAR_setWorkInt( defindex, CHAR_WORKSLEEP , 3 ); //趨˯ + CHAR_setWorkInt( defindex, CHAR_WORKBATTLECOM1, BATTLE_COM_NONE );//Ϊ趨˻˯,趨޶ + } + } +#endif + if( damage > 0 ){ +#ifdef _TAKE_ITEMDAMAGE + if( BATTLE_ItemCrushSeq( attackindex, defindex, damage) == TRUE ){ +#else + if( BATTLE_ItemCrushSeq( defindex ) == TRUE ){ +#endif + flg |= BCF_CRUSH; + } + } + +#ifdef _PROFESSION_SKILL // WON ADD ְҵ + if( damage > 0 && (CHAR_getInt(attackindex, CHAR_WHICHTYPE)== CHAR_TYPEPLAYER) ){ + int i; + // 𡢱׸ + for( i=0; i<3; i++ ){ + int turn = 0, status = -1; + + turn = CHAR_getWorkInt( attackindex, CHAR_WORK_F_ENCLOSE_2+i ); + + if( turn > 0 ){ + int skill_type = CHAR_getWorkInt( attackindex, CHAR_WORKBATTLECOM1 ); + int perStatus = 0, j = 0; + int skill_level = CHAR_getWorkInt( attackindex, CHAR_WORKMOD_F_ENCLOSE_2+i ); + char pszP[3][10] = { "","˪","" }; + int img1 = 101697, img2 = 101698 + i; + + // ״̬ + for( j = 1; j < BATTLE_ST_END; j ++ ){ + if( strncmp( pszP[i], aszStatus[j], 2 ) == 0 ){ + status = j; + break; + } + } + + // + perStatus = 20 + skill_level * 2; + + // غ + if( skill_level >= 10 ) turn = 3; + else if( skill_level >= 5 ) turn = 2; + else turn = 1; + + // ׸һغ + if( i == 2 ) turn = 1; + + // 𡢱׸帽ӹ +// Terry add fix Ȯbug + if(Guardian >= 0) iRet = BATTLE_PROFESSION_RANG_ATTACK_DAMAGE(attackindex, attackNo, Guardian, skill_type, status, turn, perStatus, 0, img1, img2 ); + else iRet = BATTLE_PROFESSION_RANG_ATTACK_DAMAGE(attackindex, attackNo, defNo, skill_type, status, turn, perStatus, 0, img1, img2 ); + + break; + } + } + } +#endif + + if( 0 <= Guardian && Guardian <= 19 ){ + iRet = FALSE; + flg |= BCF_GUARDIAN; + snprintf( szCommand, sizeof( szCommand ), + "r%X|f%X|d%X|p%X|g%X|", + defNo, + flg, + damage, + petdamage, + Guardian ); + }else{ + snprintf( szCommand, sizeof( szCommand ), + "r%X|f%X|d%X|p%X|", + defNo, + flg, + damage, + petdamage ); + } + + BATTLESTR_ADD( szCommand ); + + defNo = BATTLE_Index2No( battleindex, defindex ); + + if( defNo >= SIDE_OFFSET ){ + i = defNo - SIDE_OFFSET; + DefSide = 1; + }else{ + i = defNo; + } + + i = defNo-DefSide*SIDE_OFFSET; + if( ultimate > 0 ){ + BattleArray[battleindex].Side[DefSide].Entry[i].flg |= BENT_FLG_ULTIMATE; + } + return iRet; + +} + +#endif + + +enum { + BATTLE_C_NONE = 0, + BATTLE_C_CLAW, + BATTLE_C_AXE, + BATTLE_C_CLUB, + BATTLE_C_SPEAR, + BATTLE_C_BOW, + BATTLE_C_THROU, + BATTLE_C_OTHER, + BATTLE_C_MAX +}; + +static int CounterTbl[] = { + 10, 9, 8, 8, 5, 0, 0, 0 , + 10, 9, 7, 7, 6, 0, 0, 0 , + 9, 8,10,10, 7, 0, 0, 0 , + 8, 8,10,10, 7, 0, 0, 0 , + 6, 6, 8, 8, 9, 0, 0, 0 , + 0, 0, 0, 0, 0, 0, 0, 0 , + 0, 0, 0, 0, 0, 0, 0, 0 , +}; + +static int BATTLE_ItemType2ItemMap( int type ){ + int iRet = BATTLE_C_NONE; + if( type == ITEM_FIST ) iRet = BATTLE_C_CLAW; + if( type == ITEM_AXE ) iRet = BATTLE_C_AXE; + if( type == ITEM_CLUB ) iRet = BATTLE_C_CLUB; + if( type == ITEM_BOW ) iRet = BATTLE_C_BOW; + if( type == ITEM_BOOMERANG ) iRet = BATTLE_C_THROU; + if( type == ITEM_BOUNDTHROW ) iRet = BATTLE_C_THROU; + if( type == ITEM_BREAKTHROW ) iRet = BATTLE_C_THROU; + return iRet; +} + +static BOOL BATTLE_CounterCheckPlayer( int attackindex, int defindex, int *pPar ) +{ + int + At_SoubiIndex, At_SoubiType, + Df_SoubiIndex, Df_SoubiType, + At_Soubi, CriPer, + At_Luck = 0, + flg = FALSE; + + float per; + + CriPer = BATTLE_CounterCalc( attackindex, defindex ); + + At_SoubiIndex = CHAR_getItemIndex( attackindex, CHAR_ARM ); + + if( BATTLE_IsThrowWepon( At_SoubiIndex ) == TRUE ){ + *pPar = 0.0; + return FALSE; + } + + if( ITEM_CHECKINDEX( At_SoubiIndex ) == FALSE ){ + At_SoubiType = ITEM_FIST; + }else{ + At_SoubiType = ITEM_getInt( At_SoubiIndex, ITEM_TYPE ); + } + + At_SoubiIndex = BATTLE_ItemType2ItemMap( At_SoubiType ); + + Df_SoubiIndex = CHAR_getItemIndex( defindex, CHAR_ARM ); + + if( BATTLE_IsThrowWepon( Df_SoubiIndex ) == TRUE ){ + *pPar = 0.0; + return FALSE; + } + + if( ITEM_CHECKINDEX( Df_SoubiIndex ) == FALSE ){ + Df_SoubiType = ITEM_FIST; + }else{ + Df_SoubiType = ITEM_getInt( Df_SoubiIndex, ITEM_TYPE ); + } + + Df_SoubiIndex = BATTLE_ItemType2ItemMap( Df_SoubiType ); + + At_Soubi = CounterTbl[BATTLE_C_MAX * At_SoubiIndex + Df_SoubiIndex]; + + if( CHAR_getInt( attackindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER ){ + At_Luck = CHAR_getWorkInt( attackindex, CHAR_WORKFIXLUCK ); + } + +#ifdef _SUIT_ADDENDUM + per = CriPer * At_Soubi * 0.1 + At_Luck + CHAR_getWorkInt( attackindex, CHAR_WORKCOUNTER ); +#else + per = CriPer * At_Soubi * 0.1 + At_Luck; +#endif + + *pPar = per; + + per *= 100; + if( per <= 0 ){ + per = 1; + *pPar = 0; + } + + if( RAND( 1, 10000 ) < per ){ + flg = TRUE; + }else{ + flg = FALSE; + } + return flg; +} + + +static BOOL BATTLE_CounterCheckPet( int attackindex, int defindex, int *pPer ) +{ + int At_SoubiIndex; + int flg = FALSE, Df_SoubiIndex, iWork; + + float per; + + At_SoubiIndex = CHAR_getItemIndex( attackindex, CHAR_ARM ); + + if( BATTLE_IsThrowWepon( At_SoubiIndex ) == TRUE ){ + *pPer = 0.0; + return FALSE; + } + + + Df_SoubiIndex = CHAR_getItemIndex( defindex, CHAR_ARM ); + + if( BATTLE_IsThrowWepon( Df_SoubiIndex ) == TRUE ){ + *pPer = 0.0; + return FALSE; + } + + per = BATTLE_CounterCalc( attackindex, defindex ); + + if( CHAR_getWorkInt( attackindex, CHAR_WORKBATTLECOM1 ) == BATTLE_COM_S_NOGUARD ){ + iWork = CHAR_GETWORKINT_LOW( attackindex, CHAR_WORKBATTLECOM3 ); + iWork = iWork >> 8; + if( iWork > 127 )iWork *= -1; + per += iWork; + } + + if( per > 100 ) per = 100; + *pPer = per; + per *= 100; + + if( per <= 0 ){ + per = 1; + *pPer = per; + } + + if( RAND( 1, 10000 ) <= per ){ + flg = TRUE; + }else{ + flg = FALSE; + } + return flg; +} + +static BOOL BATTLE_CounterCheck( int attackindex, int defindex, int *pPar ) +{ +#ifdef _SHOOTCHESTNUT // Syu ADD 輼 + if ( CHAR_getWorkInt( attackindex, CHAR_WORKBATTLECOM1 ) == BATTLE_COM_S_ATTSHOOT || + CHAR_getWorkInt( defindex, CHAR_WORKBATTLECOM1 ) == BATTLE_COM_S_ATTSHOOT + ) { + return FALSE; + } +#endif + if( CHAR_getInt( attackindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER ){ + return BATTLE_CounterCheckPlayer( attackindex, defindex, pPar ); + }else{ + return BATTLE_CounterCheckPet( attackindex, defindex, pPar ); + } +} + + + +//ж +BOOL BATTLE_Counter( int battleindex, int attackNo, int defNo ) +{ + + char szBuffer[512]=""; + char szCommand[1024]; + int damage = 0, petdamage = 0, attackindex, defindex, Guardian = -2, react = 0, ultimate = 0; + int flg = 0, iWork, par, DefSide = 0, i, per = 0; + BOOL iRet = TRUE; + + attackindex = BATTLE_No2Index( battleindex, attackNo ); + defindex = BATTLE_No2Index( battleindex, defNo ); + +#ifdef _SHOOTCHESTNUT // Syu ADD 輼 + if ( CHAR_getWorkInt( attackindex, CHAR_WORKBATTLECOM1 ) == BATTLE_COM_S_ATTSHOOT ) { + return FALSE; + } +#endif + + if( CHAR_getInt( defindex, CHAR_HP ) <= 0 ) return FALSE; + if( CHAR_getInt( attackindex, CHAR_HP ) <= 0 ) return FALSE; + + if( CHAR_getWorkInt( attackindex, CHAR_WORKBATTLECOM1 ) == BATTLE_COM_ATTACK + || CHAR_getWorkInt( attackindex, CHAR_WORKBATTLECOM1 ) == BATTLE_COM_S_NOGUARD){ + ;; + }else{ + return FALSE; + } + + // nono + if( CHAR_getWorkInt( attackindex, CHAR_WORKBATTLEFLG ) & CHAR_BATTLEFLG_ABIO ) return FALSE; + + // + if( BATTLE_CounterCheck( attackindex, defindex, &per ) == FALSE ) return FALSE; + + // ⡢ + if( BATTLE_GetDamageReact( attackindex ) > 0 ) + iRet = FALSE; + else if( BATTLE_GetDamageReact( defindex ) > 0 ) + iRet = FALSE; + + gWeponType = BATTLE_GetWepon( attackindex ); + + gDamageDiv = 1.0; + + iWork = BATTLE_AttackSeq( attackindex, defindex, &damage, &Guardian, -1 ); + + if( damage <= 0 ){ + damage = 0; + }else{ + damage *= 0.75; + if( damage < 1 ) damage = 1; + } + + react = 0; + ultimate = BATTLE_DamageSub( attackindex, defindex, &damage, &petdamage, &react ); + if( react == BATTLE_MD_REFLEC ) defindex = attackindex; + +#ifdef _PROFESSION_SKILL // WON ADD ְҵ + if( react == BATTLE_MD_TRAP ) defindex = attackindex; +#endif + +#ifdef _PETSKILL_ACUPUNCTURE + if( react == BATTLE_MD_ACUPUNCTURE ) defindex = attackindex; +#endif + + if( damage > 0 && ( react != BATTLE_MD_ABSROB ) && ( react != BATTLE_MD_VANISH )){ + BATTLE_DamageWakeUp( battleindex, defindex ); + } + par = BATTLE_AttrAdjust( attackindex, defindex, 100 ); + switch( iWork ){ + case BATTLE_RET_MISS: +/* + snprintf( szBuffer, sizeof(szBuffer), + "(%s)(%s),ûС", + CHAR_getUseName( attackindex ), + CHAR_getUseName( defindex ) + ); +*/ + return FALSE; + + case BATTLE_RET_DODGE: + //snprintf( szBuffer, sizeof(szBuffer), + // "(%s)⹥(%d%%)!(%s)(%.2f%%)", + // CHAR_getUseName( attackindex ), + // per, + // CHAR_getUseName( defindex ), + // gDuckPer + //); + flg |= BCF_DODGE; + break; + + case BATTLE_RET_NORMAL: + //snprintf( szBuffer, sizeof(szBuffer), + //"(%s)ķ!(%d%%)(%d) (%d:%d:%d%%)", + // CHAR_getUseName( attackindex ), + // per, + // damage, + // CHAR_getWorkInt( attackindex, CHAR_WORKATTACKPOWER ), + // CHAR_getWorkInt( defindex, CHAR_WORKDEFENCEPOWER ), + // par + //); + //andy_edit + flg |= BATTLE_getReactFlg( defindex, react); + break; + + case BATTLE_RET_CRITICAL: + //snprintf( szBuffer, sizeof(szBuffer), + //"(%s)CRITICAL(%d%%)(%d) (%d:%d:%d%%)", + // CHAR_getUseName( attackindex ), + // per, + // damage, + // CHAR_getWorkInt( attackindex, CHAR_WORKATTACKPOWER ), + // CHAR_getWorkInt( defindex, CHAR_WORKDEFENCEPOWER ), + // par + //); + flg |= BCF_KAISHIN; + iRet = FALSE; + //andy_edit + flg |= BATTLE_getReactFlg( defindex, react); + break; +#ifdef _EQUIT_ARRANGE + case BATTLE_RET_ARRANGE: + //snprintf( szBuffer, sizeof(szBuffer), + // "(%s)(%s)(%.2f%%)", + // CHAR_getUseName( attackindex ), + // CHAR_getUseName( defindex ), + // gDuckPer + //); + flg |= BCF_B_ARRANGE; + break; +#endif + } + + flg |= BCF_COUNTER; + + if( CHAR_getInt( defindex, CHAR_HP ) <= 0 ){ + if( CHAR_getWorkInt( defindex, CHAR_WORKBATTLEFLG ) & CHAR_BATTLEFLG_ABIO ){ + ultimate = 1; + }else + if( CHAR_getInt( defindex, CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER + && flg & BCF_KAISHIN + ){ + if( RAND( 1, 100 ) < 50 ){ + ultimate = 1; + } + } +#ifdef _PETSKILL_LER +// ׶ܱ + if(CHAR_getInt(defindex,CHAR_BASEBASEIMAGENUMBER) == 101813 || + CHAR_getInt(defindex,CHAR_BASEBASEIMAGENUMBER) == 101814) ultimate = 0; +#endif + iRet = FALSE; + flg |= BCF_DEATH; + + if( ultimate == 1 ){ + flg |= BCF_ULTIMATE_1; + strcatsafe( szBuffer,sizeof(szBuffer), "ultimate?" ); + } + if( ultimate == 2 ){ + flg |= BCF_ULTIMATE_2; + strcatsafe( szBuffer,sizeof(szBuffer), "ultimate?" ); + } + } + + if( damage > 0 ){ +#ifdef _TAKE_ITEMDAMAGE + if( BATTLE_ItemCrushSeq( attackindex, defindex, damage) == TRUE ){ +#else + if( BATTLE_ItemCrushSeq( defindex ) == TRUE ){ +#endif + flg |= BCF_CRUSH; + } + } + +#ifdef _NOTRIDE_ + snprintf( szCommand, sizeof( szCommand ), + "r%X|f%X|counter%X|", + defNo, + flg, + damage ); +#else + snprintf( szCommand, sizeof( szCommand ), + "r%X|f%X|counter%X|p%X|", + defNo, + flg, + damage, + petdamage + ); +#endif + //print(" CounterAttack!:%s ", szCommand ); + + BATTLESTR_ADD( szCommand ); + + + //BATTLE_BroadCast( battleindex, szBuffer, + // (attackNo >= 10)? CHAR_COLORGRAY : CHAR_COLORPURPLE ) ; + + if( defNo >= SIDE_OFFSET ){ + i = defNo - SIDE_OFFSET; + DefSide = 1; + } + + i = defNo-DefSide*SIDE_OFFSET; + if( ultimate > 0 ){ + BattleArray[battleindex].Side[DefSide].Entry[i].flg |= BENT_FLG_ULTIMATE; + } + + return iRet; +} + + +static BOOL BATTLE_CaptureCheck( + int attackindex, + int defindex, + float *pPer +) +{ + float + Df_MaxHp = 0, + Df_HpPer = 0, + At_Charm = 0, + At_Level = 0, + At_Dex = 0, + At_Luck = 0, + Df_Level = 0, + Df_Dex = 0, + Df_Ge = 30; + float WorkGet; + + *pPer = 0; + + if( CHAR_getInt( defindex, CHAR_WHICHTYPE ) != CHAR_TYPEENEMY ){ + return FALSE; + } + + if( CHAR_getWorkInt( defindex, CHAR_WORK_PETFLG ) == 0 ){ + return FALSE; + } + + if( CHAR_getWorkInt( attackindex, CHAR_PickAllPet) != TRUE ) { + if( CHAR_getInt( attackindex, CHAR_LV ) + 5 < CHAR_getInt( defindex, CHAR_LV )){ + return FALSE; + } + } + + At_Charm = CHAR_getWorkInt( attackindex, CHAR_WORKFIXCHARM ); + At_Level = CHAR_getInt( attackindex, CHAR_LV ); + Df_Level = CHAR_getInt( defindex, CHAR_LV ); + At_Dex = CHAR_getWorkInt( attackindex, CHAR_WORKFIXDEX ); + Df_Dex = CHAR_getWorkInt( defindex, CHAR_WORKFIXDEX ); + Df_Ge = CHAR_getWorkInt( defindex, CHAR_WORKMODCAPTUREDEFAULT ); + At_Luck = CHAR_getWorkInt( attackindex, CHAR_WORKFIXLUCK ); + Df_HpPer = CHAR_getInt( defindex, CHAR_HP ); + Df_MaxHp = CHAR_getWorkInt( defindex, CHAR_WORKMAXHP ); + if( Df_MaxHp <= 0 ) Df_MaxHp = 1; + + Df_HpPer = 10 - ( Df_HpPer * Df_HpPer ) / Df_MaxHp; + Df_Level = ( At_Level/2 - Df_Level/2 ); + Df_Dex = At_Dex / 15 - Df_Dex / 15; + + WorkGet = ( Df_HpPer + Df_Level + Df_Dex + ( Df_Ge + At_Luck ) ) * At_Charm / 50; + + WorkGet += CHAR_getWorkInt( attackindex, CHAR_WORKMODCAPTURE ); + + if( CHAR_getWorkInt( defindex, CHAR_WORKSLEEP ) > 0 ){ + WorkGet += 15; + } + + if( WorkGet > 99 ) WorkGet = 99; + + *pPer = WorkGet; + + if( RAND( 1,100 ) < WorkGet ){ + return TRUE; + }else{ + return FALSE; + } + +} +#ifdef _CAPTURE_FREES +#define MAXCAPTRUEFREE 15 + +typedef struct _NeedItemEnemy{ + int EnemyId; + int ItemId[MAXCAPTRUEFREE]; +}NEEDITEMENEMY; +NEEDITEMENEMY NeedEnemy[128] = { + { 524, { 2456, -1, -1, -1, -1, -1, -1, -1, -1, -1} }, + // + { 961, {20219, -1, -1, -1, -1, -1, -1, -1, -1, -1} }, + { 953, {20223, -1, -1, -1, -1, -1, -1, -1, -1, -1} }, + { 962, {20222, -1, -1, -1, -1, -1, -1, -1, -1, -1} }, + + { 777, {20253, -1, -1, -1, -1, -1, -1, -1, -1, -1} }, + { 796, {20247, -1, -1, -1, -1, -1, -1, -1, -1, -1} }, + { 812, {20259, -1, -1, -1, -1, -1, -1, -1, -1, -1} }, + + { 1105, {1690, 1691, 1692, -1, -1, -1, -1, -1, -1, -1} }, + { 8, {1810, -1, -1, -1, -1, -1, -1, -1, -1, -1} }, +#ifdef _WOLF_TAKE_AXE // WON ADD ץ˫ͷǵ + { 145, {2236, -1, -1, -1, -1, -1, -1, -1, -1, -1} }, + { 146, {2236, -1, -1, -1, -1, -1, -1, -1, -1, -1} }, +#endif +}; + +#ifdef _NEED_ITEM_ENEMY +int need_item_eneny_init() +{ + FILE* fp; + int i; + int num=0; + char line[128], buf[16]; + fp = fopen("data/needitemeneny.txt", "r"); + if (fp == NULL) + { + print("޷ļ\n"); + return FALSE; + } + while(1){ + if (fgets(line, sizeof(line), fp) == NULL) break; + chop(line); + if(line[0]=='#')continue; + + getStringFromIndexWithDelim(line,"|", 1, buf, sizeof(buf)); + NeedEnemy[num].EnemyId=atoi(buf); + for(i=0;i=128)break; + } + fclose(fp); + return TRUE; +} +#endif + +#else +typedef struct _NeedItemEnemy{ + int EnemyId; + int ItemId; +}NEEDITEMENEMY; +NEEDITEMENEMY NeedEnemy[] = { + { 524, 2456 }, + // + { 961, 20219}, + { 953, 20223}, + { 962, 20222}, + + { 777, 20253}, + { 796, 20247}, + { 812, 20259}, + +}; +#endif + +static int IsNeedCaptureItem( int charaindex ) +{ + int i=0; + for( i = 0; i < arraysizeof( NeedEnemy ); i ++ ){ + if( NeedEnemy[i].EnemyId != CHAR_getInt( charaindex, CHAR_PETID ) )continue; +#ifdef _CAPTURE_FREES + return i; +#else + return NeedEnemy[i].ItemId; +#endif + } + return -1; +} + +BOOL BATTLE_CaptureItemCheck( int attackindex, int defindex ) +{ +#ifdef _CAPTURE_FREES + int i; +#endif + int j, ti, itemindex; + + ti = IsNeedCaptureItem( defindex ); + if( ti < 0 ) return TRUE; + +#ifdef _CAPTURE_FREES + for( i=0; i= CHAR_MAXITEMHAVE ) return FALSE; + } + return TRUE; +#else + for( j = CHAR_STARTITEMARRAY; j < CHAR_MAXITEMHAVE; j ++ ){ + itemindex =CHAR_getItemIndex( attackindex, j ); + if( ITEM_CHECKINDEX( itemindex ) == FALSE )continue; + if( ITEM_getInt( itemindex, ITEM_ID ) == ti ){ + return TRUE; + } + } + return FALSE; +#endif + +} + +#ifdef _CAPTURE_FREES +BOOL BATTLE_CaptureItemDelAll( int attackindex, int defindex ) +{ + int i, j, itemindex=-1,ti; + + ti = IsNeedCaptureItem( defindex ); + if( ti < 0 ) return TRUE; + for( i=0; i= 0 ){ + for( i = CHAR_STARTITEMARRAY; i < CHAR_MAXITEMHAVE; i ++ ) { + itemindex = CHAR_getItemIndex( attackindex, i ); + if( ITEM_CHECKINDEX( itemindex ) == FALSE )continue; + if( ITEM_getInt( itemindex, ITEM_ID ) == needItemId ){ + { + char token[256]; +// LogItem( +// CHAR_getChar( attackindex, CHAR_NAME ), +// CHAR_getChar( attackindex, CHAR_CDKEY ), +//#ifdef _add_item_log_name // WON ADD itemlogitem +// itemindex, +//#else +// ITEM_getInt( itemindex, ITEM_ID ), +//#endif +// "PetEaten(ʹ)", +// CHAR_getInt( attackindex,CHAR_FLOOR), +// CHAR_getInt( attackindex,CHAR_X ), +// CHAR_getInt( attackindex,CHAR_Y ), +// ITEM_getChar(itemindex, ITEM_UNIQUECODE), +// ITEM_getChar( itemindex, ITEM_NAME), +// ITEM_getInt( itemindex, ITEM_ID) +// ); + } + CHAR_DelItem( attackindex, i); + } + } + } +#endif + CHAR_setInt( attackindex, CHAR_GETPETCOUNT, + CHAR_getInt( attackindex, CHAR_GETPETCOUNT ) + 1 ); + + BATTLE_Exit( defindex, battleindex ); + CHAR_complianceParameter( pindex ); + CHAR_setInt( pindex, CHAR_VARIABLEAI, 0 ); + ai = CHAR_DEFAULTMAXAI - CHAR_getWorkInt( pindex, CHAR_WORKFIXAI ); + if( ai < 0 ){ + CHAR_PetAddVariableAi( pindex, ai * 100 ); + CHAR_setWorkInt( pindex, CHAR_WORKFIXAI, + CHAR_getWorkInt( pindex, CHAR_WORKFIXAI ) + ai ); + } + } + } + //BATTLE_BroadCast( battleindex, szBuffer, + // (attackNo >= 10)? CHAR_COLORGRAY : CHAR_COLORPURPLE ) ; + { + char szCommand[1024]; + snprintf( szCommand, sizeof( szCommand ), + "BT|a%X|r%X|f%X|", + attackNo, + defNo, + flg ); + BATTLESTR_ADD( szCommand ); + } + return ( flg )?(TRUE):(FALSE); +} + +void BATTLE_Guard( + int battleindex, + int attackNo +) +{ + char szCommand[128]; + //int attackindex; + sprintf( szCommand, "bg|%x|", attackNo ); + BATTLESTR_ADD( szCommand ); + /*attackindex = BATTLE_No2Index( battleindex, attackNo ); + { + char szBuffer[256]=""; + //snprintf( szBuffer, sizeof(szBuffer), "(%s)סȫ", + // CHAR_getUseName( attackindex ) + //); + //BATTLE_BroadCast( battleindex, szBuffer, + // (attackNo >= 10)? CHAR_COLORGRAY : CHAR_COLORPURPLE ) ; + }*/ + +} + +BOOL BATTLE_EscapeCheck( int attackindex, int attackNo, int *pPar ) +{ + int Esc = 100; + + int myside, otherside, battleindex; + int mylevel, enemylevel = 0, enemycnt = 0, i, enemyindex, luck, + escape_cnt, rare, SubNo; + BATTLE_ENTRY *pEntry; + + myside = CHAR_getWorkInt( attackindex, CHAR_WORKBATTLESIDE ); + otherside = 1 - myside; + + battleindex = CHAR_getWorkInt( attackindex, CHAR_WORKBATTLEINDEX ); + + if( BATTLE_CHECKINDEX( battleindex ) == FALSE )return TRUE; + + if( BattleArray[battleindex].type == BATTLE_TYPE_P_vs_P )return TRUE; + + if( attackNo >= SIDE_OFFSET ){ + SubNo = attackNo - SIDE_OFFSET; + }else{ + SubNo = attackNo; + } + + if( CHAR_getInt( attackindex, CHAR_WHICHTYPE ) == CHAR_TYPEENEMY ){ + rare = CHAR_getInt( attackindex, CHAR_RARE ); + switch( rare ){ + case 0: luck = 1; break; + case 1: luck = 3; break; + default:luck = 5; break; + } + }else{ + luck = min( 5, CHAR_getWorkInt( attackindex, CHAR_WORKFIXLUCK ) ); + luck = max( 1, luck ); + } + + mylevel = CHAR_getInt( attackindex, CHAR_LV ); + pEntry = BattleArray[battleindex].Side[otherside].Entry; + + escape_cnt = BattleArray[battleindex].Side[myside].Entry[SubNo].escape+1; + + for( i = 0; i < BATTLE_ENTRY_MAX; i ++ ){ + enemyindex = pEntry[i].charaindex; + if( CHAR_CHECKINDEX( enemyindex ) == FALSE )continue; + + if( CHAR_getWorkInt( enemyindex, CHAR_WORKBATTLEFLG ) & CHAR_BATTLEFLG_ABIO ) + enemylevel -= 100; + + enemylevel += CHAR_getInt( enemyindex, CHAR_LV ); + + enemycnt ++; + } + + if( enemycnt <= 0 ){ + enemylevel = 0; + Esc = 100; + }else{ + enemylevel /= enemycnt; + if( luck >= 5 ){ + Esc = 95 * escape_cnt; + }else + if( luck >= 4 ){ + Esc = ( 60 * escape_cnt ) - 2*( enemylevel - mylevel ); + }else + if( luck >= 3 ){ + Esc = ( 50 * escape_cnt ) - 2*( enemylevel - mylevel ); + }else + if( luck >= 2 ){ + Esc = ( 40 * escape_cnt ) - 2*( enemylevel - mylevel ); + }else + if( luck >= 1 ){ + Esc = ( 30 * escape_cnt ) - 2*( enemylevel - mylevel ); + }else{ + Esc = 95 * escape_cnt; + } + } + + if( Esc < 1 )Esc = 1; + + *pPar = Esc; + + if( RAND( 1,100 ) < Esc ){ + return TRUE; + }else{ + return FALSE; + } +} + + +BOOL BATTLE_Escape( int battleindex, int attackNo, int flag) +{ + //char szBuffer[512]=""; + char szCommand[1024]; + int attackindex, flg = FALSE, side, SubNo, iPar; + + sprintf( szCommand, "BE|e%X|", attackNo ); + BATTLESTR_ADD( szCommand ); + + attackindex = BATTLE_No2Index( battleindex, attackNo ); + + if( !CHAR_CHECKINDEX( attackindex ) ){ + return FALSE; + } + + if( attackNo >= SIDE_OFFSET ){ + side = 1; SubNo = attackNo - SIDE_OFFSET; + }else{ + side = 0; SubNo = attackNo; + } + + BattleArray[battleindex].Side[side].Entry[SubNo].escape ++; + + if( BATTLE_EscapeCheck( attackindex, attackNo, &iPar ) == FALSE ){ + flg = 0; + }else{ + flg = 1; + } + + if( flg == 1 || flag == 1 ){ + //snprintf( szBuffer, sizeof(szBuffer), "(%s)(%d%%)", + // CHAR_getUseName( attackindex ), iPar + //); + //if( getBattleDebugMsg( ) != 0 ){ + // BATTLE_BroadCast( battleindex, szBuffer, + // (attackNo >= 10)? CHAR_COLORGRAY : CHAR_COLORPURPLE ) ; + //} + + if( BattleArray[battleindex].type == BATTLE_TYPE_P_vs_P + && CHAR_getInt( attackindex, CHAR_HP ) > 0 ){ + BATTLE_EscapeDpSend( battleindex, attackindex ); + BATTLE_GetDuelPoint( battleindex, side, SubNo ); + } +#ifdef _ALLBLUES_LUA_1_4 + BattleEscape(battleindex, attackindex); +#endif + CHAR_setWorkInt( attackindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_FINAL ); + CHAR_DischargePartyNoMsg( attackindex ); + BATTLE_Exit( attackindex, battleindex ); + }else{ + //if( getBattleDebugMsg( ) != 0 ){ + //snprintf( szBuffer, sizeof(szBuffer), "(%s)(%d%%)", + // CHAR_getUseName( attackindex ), iPar + //); + //BATTLE_BroadCast( battleindex, szBuffer, + // (attackNo >= 10)? CHAR_COLORGRAY : CHAR_COLORPURPLE ) ; + //} + } + snprintf( szCommand, sizeof( szCommand ), "f%X|", flg ); + BATTLESTR_ADD( szCommand ); + + return ( flg )?(TRUE):(FALSE); +} + + +int BATTLE_SurpriseCheck( int battleindex ) +{ + int iRet = 0, Rnd, charaindex, luck, a = 0, b = 7; + + if( BattleArray[battleindex].Side[0].type == BATTLE_S_TYPE_PLAYER + && BattleArray[battleindex].Side[1].type == BATTLE_S_TYPE_PLAYER + ){ + return 0; + } + + charaindex = BattleArray[battleindex].Side[0].Entry[0].charaindex; + + if( CHAR_CHECKINDEX( charaindex ) == FALSE )return 0; + + if( BattleArray[battleindex].WinFunc != NULL )return 0; + + luck = CHAR_getWorkInt( charaindex, CHAR_WORKFIXLUCK ); + + switch( luck ){ + case 5: a = 20; b = 0; break; + case 4: a = 15; b = 2; break; + case 3: a = 10; b = 3; break; + case 2: a = 5; b = 5; break; + default: a = 0; b = 7; break; + } + + Rnd = RAND( 1, 100 ); + + if( Rnd <= a ){ + iRet = 1; + }else + if( Rnd < a + b ){ + iRet = 2; + } + + return iRet; +} + + +int BATTLE_NoAction( int battleindex, int attackNo ) +{ + //char szBuffer[512]=""; + char szCommand[512]; + int attackindex ; + + attackindex = BATTLE_No2Index( battleindex, attackNo ); + + sprintf( szCommand, "bn|%x|", attackNo ); + BATTLESTR_ADD( szCommand ); + + //snprintf( szBuffer, sizeof(szBuffer), "(%s)ʲҲ", + // CHAR_getUseName( attackindex ) + //); + //BATTLE_BroadCast( battleindex, szBuffer, + // (attackNo >= 10)? CHAR_COLORGRAY : CHAR_COLORPURPLE ) ; + + return 0; +} + + +int BATTLE_PetIn( int battleindex, int attackNo ) +{ + //char szBuffer[512]=""; + char szCommand[1024]; + int attackindex, petindex ; + + attackindex = BATTLE_No2Index( battleindex, attackNo ); + petindex = CHAR_getInt( attackindex, CHAR_DEFAULTPET ); + petindex = CHAR_getCharPet( attackindex, petindex ); +#ifdef _FIXWOLF // Syu ADD ˱Bug + if ( CHAR_getInt ( petindex , CHAR_BASEIMAGENUMBER) == 101428 ) + { + CHAR_setInt( petindex, CHAR_BASEIMAGENUMBER, CHAR_getInt( petindex , CHAR_BASEBASEIMAGENUMBER)); + CHAR_setWorkInt( petindex, CHAR_WORKATTACKPOWER, CHAR_getWorkInt( petindex , CHAR_WORKFIXSTR)); + CHAR_setWorkInt( petindex, CHAR_WORKQUICK, CHAR_getWorkInt( petindex , CHAR_WORKFIXDEX)); + } +#endif +#ifdef _PETSKILL_BECOMEFOX // ĻջٷųʱҪָ״̬ + if ( CHAR_getInt ( petindex , CHAR_WORKFOXROUND) != -1 + || CHAR_getInt( petindex, CHAR_BASEIMAGENUMBER) == 101749 ){ //DZΪ + CHAR_setInt( petindex, CHAR_BASEIMAGENUMBER, CHAR_getInt( petindex , CHAR_BASEBASEIMAGENUMBER)); + CHAR_setWorkInt( petindex, CHAR_WORKATTACKPOWER, CHAR_getWorkInt( petindex , CHAR_WORKFIXSTR)); + CHAR_setWorkInt( petindex, CHAR_WORKQUICK, CHAR_getWorkInt( petindex , CHAR_WORKFIXDEX)); + CHAR_setWorkInt( petindex, CHAR_WORKFOXROUND, -1 ); + } +#endif + if( CHAR_getWorkInt( petindex, CHAR_WORKBATTLEFLG ) + & CHAR_BATTLEFLG_NORETURN + ){ + //snprintf( szBuffer, sizeof(szBuffer), "(%s)޷ظ(%s)", + // CHAR_getUseName( attackindex ), + // CHAR_getUseName( petindex ) + //); + return 0; + } + + BATTLE_PetDefaultExit( attackindex, battleindex ); + CHAR_setInt( attackindex, CHAR_DEFAULTPET, -1 ); + + //snprintf( szBuffer, sizeof(szBuffer), "(%s)ظ(%s)", + // CHAR_getUseName( attackindex ), + // CHAR_getUseName( petindex ) + //); + //BATTLE_BroadCast( battleindex, szBuffer, + // (attackNo >= 10)? CHAR_COLORGRAY : CHAR_COLORPURPLE ) ; + + sprintf( szCommand, "BS|s%X|f0|", attackNo ); + BATTLESTR_ADD( szCommand ); + + return 0; + +} + +int BATTLE_PetOut( int battleindex, int attackNo ) +{ + //char szBuffer[512]=""; + char szCommand[1024], szEscapeName[128]; + int attackindex, petindex, petNo, flg = 0,iRet ; + + szCommand[0] = 0; + + attackindex = BATTLE_No2Index( battleindex, attackNo ); + petNo = CHAR_getWorkInt( attackindex, CHAR_WORKBATTLECOM2 ); +#ifdef _PET_BUG + petindex = CHAR_getCharPet( attackindex, petNo); + if(CHAR_getInt(petindex,CHAR_VITAL)>=getPetPoint(0)*20 || CHAR_getInt(petindex,CHAR_STR)>=getPetPoint(1)*80 || CHAR_getInt(petindex,CHAR_TOUGH)>=getPetPoint(2)*80 || CHAR_getInt(petindex,CHAR_DEX)>=getPetPoint(3)*100) + CHAR_setInt( attackindex, CHAR_DEFAULTPET, -1 ); + else +#endif + CHAR_setInt( attackindex, CHAR_DEFAULTPET, petNo ); + + iRet = BATTLE_PetDefaultEntry( attackindex, battleindex, + CHAR_getWorkInt( attackindex, CHAR_WORKBATTLESIDE ) ); + + if( iRet < 0 ){ + //snprintf( szBuffer, sizeof(szBuffer), "(%s),ûгټ", + // CHAR_getUseName( attackindex ) + //); + }else + if( CHAR_getInt( attackindex, CHAR_DEFAULTPET ) < 0 ){ + //snprintf( szBuffer, sizeof(szBuffer), "(%s),ûгټ", + // CHAR_getUseName( attackindex ) + //); + }else{ + flg = 1; + petNo = CHAR_getInt( attackindex, CHAR_DEFAULTPET ); + petindex = CHAR_getCharPet( attackindex, petNo ); + + CHAR_setWorkInt( petindex, CHAR_WORKBATTLEMODE, + BATTLE_CHARMODE_C_OK ); + + //snprintf( szBuffer, sizeof(szBuffer), "(%s)(%s)", + // CHAR_getUseName( attackindex ), + // CHAR_getUseName( petindex ) + //); + + makeEscapeString( CHAR_getUseName( petindex ), + szEscapeName, + sizeof( szEscapeName ) ); + + sprintf( szCommand, "BS|s%X|f1|g%X|l%X|h%X|%s|m%X|", + attackNo, + CHAR_getInt( petindex, CHAR_BASEIMAGENUMBER), + CHAR_getInt( petindex, CHAR_LV), + CHAR_getInt( petindex, CHAR_HP), + szEscapeName, + CHAR_getWorkInt( petindex, CHAR_WORKMAXHP) + ); + BATTLESTR_ADD( szCommand ); + } + + //BATTLE_BroadCast( battleindex, szBuffer, + // (attackNo >= 10)? CHAR_COLORGRAY : CHAR_COLORPURPLE ) ; + + return ( flg )?(TRUE):(FALSE); + +} + + +int BATTLE_Magic( int battleindex, int attackNo ) +{ + int attackindex, defindex, defNo; + + attackindex = BATTLE_No2Index( battleindex, attackNo ); + defNo = CHAR_getWorkInt( attackindex, CHAR_WORKBATTLECOM2 ); + defindex = BATTLE_No2Index( battleindex, defNo ); + + return 0; +} + + +//б𹥻Ƿ +int BATTLE_S_GBreak( int battleindex, int attackNo, int defNo ) +{ + char szBuffer[512]=""; + char szCommand[1024]; + int damage = 0, petdamage = 0, attackindex, defindex, ultimate = 0; + int flg = 0, iWork, par, i, DefSide = 0, + react = 0, + Guardian = -1; + BOOL iRet = FALSE; + + attackindex = BATTLE_No2Index( battleindex, attackNo ); + defindex = BATTLE_No2Index( battleindex, defNo ); + + if( defNo >= SIDE_OFFSET ){ + i = defNo - SIDE_OFFSET; + DefSide = 1; + } + + iWork = BATTLE_AttackSeq( attackindex, defindex, &damage, + &Guardian, BATTLE_COM_S_GBREAK ); + + if( CHAR_getWorkInt( defindex, CHAR_WORKBATTLECOM1 ) == BATTLE_COM_GUARD + && CHAR_getWorkInt( defindex, CHAR_WORKCONFUSION ) <= 0 + ){ + react = 0; + ultimate = BATTLE_DamageSub( attackindex, defindex, &damage, &petdamage, &react ); + if( react == BATTLE_MD_REFLEC )defindex = attackindex; +#ifdef _PROFESSION_SKILL // WON ADD ְҵ + if( react == BATTLE_MD_TRAP ) defindex = attackindex; +#endif +#ifdef _PETSKILL_ACUPUNCTURE + if( react == BATTLE_MD_ACUPUNCTURE ) defindex = attackindex; +#endif + + }else{ + //зǷdamageΪ0 + damage = 0; + iWork = BATTLE_RET_MISS; + } + + if( damage > 0 + && ( react != BATTLE_MD_ABSROB ) + && ( react != BATTLE_MD_VANISH ) + ){ + BATTLE_DamageWakeUp( battleindex, defindex ); + } + + par = BATTLE_AttrAdjust( attackindex, defindex, 100 ); + switch( iWork ){ + + case BATTLE_RET_ALLGUARD: + case BATTLE_RET_MISS: + //snprintf( szBuffer, sizeof(szBuffer), + // "(%s)(%s),ûС", + // CHAR_getUseName( attackindex ), + // CHAR_getUseName( defindex ) + //); + iRet = TRUE; + break; + + case BATTLE_RET_DODGE: + //snprintf( szBuffer, sizeof(szBuffer), + // "(%s)չ(%s)㿪(%.2f%%)", + // CHAR_getUseName( attackindex ), + // CHAR_getUseName( defindex ), + // gDuckPer + //); + flg |= BCF_DODGE; + iRet = TRUE; + break; + + case BATTLE_RET_NORMAL: + //snprintf( szBuffer, sizeof(szBuffer), + // "(%s)ܵ(%s)ľ(%d)(%d:%d:%d%%)", + // CHAR_getUseName( attackindex ), + // CHAR_getUseName( defindex ), + // damage, + // CHAR_getWorkInt( attackindex, CHAR_WORKATTACKPOWER ), + // CHAR_getWorkInt( defindex, CHAR_WORKDEFENCEPOWER ), + // par + //); + //andy_edit + flg |= BATTLE_getReactFlg( defindex, react); + flg |= BCF_NORMAL; + iRet = TRUE; + break; + + case BATTLE_RET_CRITICAL: + //snprintf( szBuffer, sizeof(szBuffer), + //"(%s)ܵ(%s)ľCRITICAL(%d)(%d:%d:%d%%)", + // CHAR_getUseName( attackindex ), + // CHAR_getUseName( defindex ), + // damage, + // CHAR_getWorkInt( attackindex, CHAR_WORKATTACKPOWER ), + // CHAR_getWorkInt( defindex, CHAR_WORKDEFENCEPOWER ), + // par + //); + flg |= BCF_KAISHIN; + iRet = FALSE; + //andy_edit + flg |= BATTLE_getReactFlg( defindex, react); + break; +#ifdef _EQUIT_ARRANGE + case BATTLE_RET_ARRANGE: + //snprintf( szBuffer, sizeof(szBuffer), + // "(%s)(%s)(%.2f%%)", + // CHAR_getUseName( attackindex ), + // CHAR_getUseName( defindex ), + // gDuckPer + //); + flg |= BCF_B_ARRANGE; + break; +#endif + } + + if( CHAR_getWorkInt( defindex, CHAR_WORKBATTLECOM1 ) == BATTLE_COM_GUARD + && CHAR_getWorkInt( defindex, CHAR_WORKCONFUSION ) <= 0 + ){ + strncat( szBuffer, "(GUARD)", sizeof( szBuffer ) ); + iRet = FALSE; + } + + flg |= BCF_GBREAK; + + if( CHAR_getInt( defindex, CHAR_HP ) <= 0 ){ + if( CHAR_getWorkInt( defindex, CHAR_WORKBATTLEFLG ) & CHAR_BATTLEFLG_ABIO ){ + ultimate = 1; + }else + if( CHAR_getInt( defindex, CHAR_WHICHTYPE ) == CHAR_TYPEENEMY + && flg & BCF_KAISHIN + ){ + if( RAND( 1, 100 ) < 50 ){ + ultimate = 1; + } + } +#ifdef _PETSKILL_LER +// ׶ܱ + if(CHAR_getInt(defindex,CHAR_BASEBASEIMAGENUMBER) == 101813 || + CHAR_getInt(defindex,CHAR_BASEBASEIMAGENUMBER) == 101814) ultimate = 0; +#endif + iRet = FALSE; + flg |= BCF_DEATH; + + if( ultimate == 1 ){ + flg |= BCF_ULTIMATE_1; + strcatsafe( szBuffer,sizeof(szBuffer), "ultimate?" ); + } + if( ultimate == 2 ){ + flg |= BCF_ULTIMATE_2; + strcatsafe( szBuffer,sizeof(szBuffer), "ultimate?" ); + } + } + + if( damage > 0 ){ +#ifdef _TAKE_ITEMDAMAGE + if( BATTLE_ItemCrushSeq( attackindex, defindex, damage) == TRUE ){ +#else + if( BATTLE_ItemCrushSeq( defindex ) == TRUE ){ +#endif + flg |= BCF_CRUSH; + } + } + +#ifdef _NOTRIDE_ + snprintf( szCommand, sizeof( szCommand ), + "BH|a%X|r%X|f%X|d%X|FF|", + attackNo, + defNo, + flg, + damage ); +#else + snprintf( szCommand, sizeof( szCommand ), + "BH|a%X|r%X|f%X|d%X|p%X|FF|", + attackNo, + defNo, + flg, + damage, + petdamage + ); +#endif + + BATTLESTR_ADD( szCommand ); + + //BATTLE_BroadCast( battleindex, szBuffer, + // (attackNo >= 10)? CHAR_COLORGRAY : CHAR_COLORPURPLE ) ; + + i = defNo-DefSide*SIDE_OFFSET; + if( ultimate > 0 ){ + BattleArray[battleindex].Side[DefSide].Entry[i].flg |= BENT_FLG_ULTIMATE; + } + + return iRet; +} + + +#ifdef _SKILL_SACRIFICE//Ԯ vincent add 2002/05/30 +int BATTLE_S_Sacrifice( int battleindex, int attackNo, int defNo ) +{ + int attackindex, defindex = 0; + int DefSide ,Damage= 0; + BOOL iRet = FALSE; + char szCommand[256]; + int ToList[SIDE_OFFSET*2+1]; + + attackindex = BATTLE_No2Index( battleindex, attackNo ); + defindex = BATTLE_No2Index( battleindex, defNo ); + if( defNo >= SIDE_OFFSET ){ + DefSide = 1; + } + + //HP + CHAR_setInt(attackindex,CHAR_HP,(CHAR_getInt(attackindex,CHAR_HP)*0.5)); + CHAR_setInt(defindex,CHAR_HP,min(CHAR_getInt(attackindex,CHAR_HP)+CHAR_getInt(defindex,CHAR_HP),CHAR_getWorkInt(defindex,CHAR_WORKMAXHP))); + Damage=CHAR_getInt(attackindex,CHAR_HP); + + //ħ + BATTLE_MultiList( battleindex, defNo, ToList ); + //hpıֵ + BATTLE_MagicEffect(battleindex, attackNo, ToList, MAGIC_EFFECT_USER, SPR_heal2 ); + snprintf( szCommand, sizeof(szCommand),"BD|r%X|%X|%X|d%X|p%X|", attackNo, BD_KIND_HP, 0, Damage, 0 ); + BATTLESTR_ADD( szCommand ); + snprintf( szCommand, sizeof(szCommand),"BD|r%X|%X|%X|d%X|p%X|", ToList[0], BD_KIND_HP, 1, Damage, 0 ); + BATTLESTR_ADD( szCommand ); + return iRet; +} +#endif + + +#ifdef _SKILL_REFRESH +int BATTLE_S_Refresh( int battleindex, int attackNo, int defNo, int marray ) +{ + BOOL iRet = FALSE; + char *magicarg; + int status = -1, i,charaindex; + int ReceveEffect= 0; + char *pszP; + magicarg = PETSKILL_getChar( marray, PETSKILL_OPTION ); + pszP = magicarg; + + for( ;status == -1 && pszP[0] != 0; pszP++ ){ + for( i = 0; i < BATTLE_ST_END; i ++ ){ + if( strncmp( pszP, aszStatus[i], 2 ) == 0 ){ + status = i; + pszP +=2; + break; + } + } + } + + if( status == -1 ) return iRet; + charaindex = BATTLE_No2Index( battleindex, attackNo ); + if( CHAR_getWorkInt( charaindex, StatusTbl[status] ) > 0 ){ + ReceveEffect = SPR_tyusya; + iRet = TRUE; + }else{ + ReceveEffect = SPR_hoshi; + } + + BATTLE_MultiStatusRecovery( battleindex, attackNo, defNo, + status, MAGIC_EFFECT_USER, ReceveEffect ); + return iRet; +} +#endif + +#ifdef _SKILL_ROAR //vincent輼: +int BATTLE_S_Roar( int battleindex, int attackNo, int defNo, int marray ) +{ + int masteridx=-1, index2, charaindex; + BOOL iRet = FALSE; + char buf1[256]; + char szWork[128]; + int petid=-1, i=1; + BOOL FINDPET=FALSE; + + char *magicarg; + int flg=0; + + charaindex = BATTLE_No2Index( battleindex, attackNo ); + + index2 = BATTLE_No2Index( battleindex, defNo);//Ŀ֮index + + if( !CHAR_CHECKINDEX( index2) ) return iRet; + if( BATTLE_Index2No( battleindex, charaindex ) == defNo ){// + return iRet; + } + + if( CHAR_getInt( index2, CHAR_WHICHTYPE) == CHAR_TYPEPLAYER ) { + petid = -1;// + }else if( CHAR_getInt( index2, CHAR_WHICHTYPE) == CHAR_TYPEPET ) { + masteridx = BATTLE_No2Index(battleindex,defNo-5);//ڳ + if( !CHAR_CHECKINDEX( masteridx) ) return iRet; + petid = CHAR_getInt(index2,CHAR_PETID);//id + }else if( CHAR_getInt( index2, CHAR_WHICHTYPE) == CHAR_TYPEENEMY ) { + petid = CHAR_getInt(index2,CHAR_PETID); + } + + magicarg = PETSKILL_getChar( marray, PETSKILL_OPTION ); + while( getStringFromIndexWithDelim( magicarg,"|", i, buf1, sizeof( buf1)) != FALSE ) { + if( petid == atoi( buf1) ){//б + FINDPET = TRUE; + break; + } + i++; + } + +//ѶϢ + if( FINDPET == TRUE ) {//Ϊ + char buf4[255]; + sprintf( buf4, "%sˣ", CHAR_getChar( index2, CHAR_NAME)); + BATTLE_Exit(index2,battleindex);//뿪ս + if( CHAR_CHECKINDEX( masteridx) ){ + CHAR_setInt(masteridx,CHAR_DEFAULTPET,-1);//޲ս + CHAR_talkToCli( masteridx,-1, buf4, CHAR_COLORYELLOW); + } + + //ǰ + flg |= BCF_ROAR; + sprintf( szWork, "BH|a%X|", attackNo ); + BATTLESTR_ADD( szWork ); + snprintf( szWork, sizeof( szWork ), "r%X|f%X|d%X|p%X|", defNo, flg, 0, 0 ); + + BATTLESTR_ADD(szWork); + BATTLESTR_ADD( "FF|" ); + sprintf(szWork,"BQ|e%X|",defNo);//ܶ + BATTLESTR_ADD(szWork); + CHAR_talkToCli( CHAR_getWorkInt(charaindex, CHAR_WORKPLAYERINDEX),-1, buf4, CHAR_COLORYELLOW); + } + + return iRet; +} +#endif + +#ifdef _SKILL_GUARDBREAK2//Ƴ2 vincent add 2002/05/20 +int BATTLE_S_GBreak2( int battleindex, int attackNo, int defNo ) +{ + char szBuffer[512]=""; + char szCommand[1024]; + int damage = 0, petdamage = 0, attackindex, defindex, ultimate = 0; + int flg = 0, iWork, par, i, DefSide = 0, + react = 0, + Guardian = -1; + BOOL iRet = FALSE; + + attackindex = BATTLE_No2Index( battleindex, attackNo ); + defindex = BATTLE_No2Index( battleindex, defNo ); + + if( defNo >= SIDE_OFFSET ){ + i = defNo - SIDE_OFFSET; + DefSide = 1; + } + + iWork = BATTLE_AttackSeq( attackindex, defindex, &damage, + &Guardian, BATTLE_COM_S_GBREAK2 ); + react = 0; + ultimate = BATTLE_DamageSub( attackindex, defindex, &damage, &petdamage, &react ); + if( react == BATTLE_MD_REFLEC )defindex = attackindex; + +#ifdef _PROFESSION_SKILL // WON ADD ְҵ + if( react == BATTLE_MD_TRAP ) defindex = attackindex; +#endif +#ifdef _PETSKILL_ACUPUNCTURE + if( react == BATTLE_MD_ACUPUNCTURE ) defindex = attackindex; +#endif + + + if( damage > 0 + && ( react != BATTLE_MD_ABSROB ) + && ( react != BATTLE_MD_VANISH ) + ){ + BATTLE_DamageWakeUp( battleindex, defindex ); + } + + par = BATTLE_AttrAdjust( attackindex, defindex, 100 ); + switch( iWork ){ + + case BATTLE_RET_ALLGUARD: + case BATTLE_RET_MISS: + //snprintf( szBuffer, sizeof(szBuffer), + // "(%s)(%s),ûС", + // CHAR_getUseName( attackindex ), + // CHAR_getUseName( defindex ) + //); + iRet = TRUE; + break; + + case BATTLE_RET_DODGE: + //snprintf( szBuffer, sizeof(szBuffer), + // "(%s)չ(%s)㿪(%.2f%%)", + // CHAR_getUseName( attackindex ), + // CHAR_getUseName( defindex ), + // gDuckPer + //); + flg |= BCF_DODGE; + iRet = TRUE; + break; + + case BATTLE_RET_NORMAL: + //snprintf( szBuffer, sizeof(szBuffer), + // "(%s)ܵ(%s)ľ(%d)(%d:%d:%d%%)", + // CHAR_getUseName( attackindex ), + // CHAR_getUseName( defindex ), + // damage, + // CHAR_getWorkInt( attackindex, CHAR_WORKATTACKPOWER ), + // CHAR_getWorkInt( defindex, CHAR_WORKDEFENCEPOWER ), + // par + //); + //andy_edit + flg |= BATTLE_getReactFlg( defindex, react); + flg |= BCF_NORMAL; + iRet = TRUE; + break; + + case BATTLE_RET_CRITICAL: + //snprintf( szBuffer, sizeof(szBuffer), + //"(%s)ܵ(%s)ľCRITICAL(%d)(%d:%d:%d%%)", + // CHAR_getUseName( attackindex ), + // CHAR_getUseName( defindex ), + // damage, + // CHAR_getWorkInt( attackindex, CHAR_WORKATTACKPOWER ), + // CHAR_getWorkInt( defindex, CHAR_WORKDEFENCEPOWER ), + // par + //); + flg |= BCF_KAISHIN; + iRet = FALSE; + //andy_edit + flg |= BATTLE_getReactFlg( defindex, react); + break; +#ifdef _EQUIT_ARRANGE + case BATTLE_RET_ARRANGE: + //snprintf( szBuffer, sizeof(szBuffer), + // "(%s)(%s)(%.2f%%)", + // CHAR_getUseName( attackindex ), + // CHAR_getUseName( defindex ), + // gDuckPer + //); + flg |= BCF_B_ARRANGE; + break; +#endif + } + + if( CHAR_getWorkInt( defindex, CHAR_WORKBATTLECOM1 ) == BATTLE_COM_GUARD + && CHAR_getWorkInt( defindex, CHAR_WORKCONFUSION ) <= 0 + ){ + strncat( szBuffer, "(GUARD)", sizeof( szBuffer ) ); + flg |= BCF_GUARD; + flg |= BCF_GBREAK; + iRet = FALSE; + } + + if( CHAR_getInt( defindex, CHAR_HP ) <= 0 ){ + if( CHAR_getWorkInt( defindex, CHAR_WORKBATTLEFLG ) & CHAR_BATTLEFLG_ABIO ){ + ultimate = 1; + }else if( CHAR_getInt( defindex, CHAR_WHICHTYPE ) == CHAR_TYPEENEMY && flg & BCF_KAISHIN ){ + if( RAND( 1, 100 ) < 50 ){ + ultimate = 1; + } + } +#ifdef _PETSKILL_LER +// ׶ܱ + if(CHAR_getInt(defindex,CHAR_BASEBASEIMAGENUMBER) == 101813 || + CHAR_getInt(defindex,CHAR_BASEBASEIMAGENUMBER) == 101814) ultimate = 0; +#endif + iRet = FALSE; + flg |= BCF_DEATH; + + if( ultimate == 1 ){ + flg |= BCF_ULTIMATE_1; + strcatsafe( szBuffer,sizeof(szBuffer), "ultimate?" ); + } + if( ultimate == 2 ){ + flg |= BCF_ULTIMATE_2; + strcatsafe( szBuffer,sizeof(szBuffer), "ultimate?" ); + } + } + + if( damage > 0 ){ +#ifdef _TAKE_ITEMDAMAGE + if( BATTLE_ItemCrushSeq( attackindex, defindex, damage) == TRUE ){ +#else + if( BATTLE_ItemCrushSeq( defindex ) == TRUE ){ +#endif + flg |= BCF_CRUSH; + } + } + +#ifdef _NOTRIDE_ + snprintf( szCommand, sizeof( szCommand ), + "BH|a%X|r%X|f%X|d%X|FF|", + attackNo, + defNo, + flg, + damage ); +#else + snprintf( szCommand, sizeof( szCommand ), + "BH|a%X|r%X|f%X|d%X|p%X|FF|", + attackNo, + defNo, + flg, + damage, + petdamage + ); +#endif + + BATTLESTR_ADD( szCommand ); + + //BATTLE_BroadCast( battleindex, szBuffer, + // (attackNo >= 10)? CHAR_COLORGRAY : CHAR_COLORPURPLE ) ; + + i = defNo-DefSide*SIDE_OFFSET; + if( ultimate > 0 ){ + BattleArray[battleindex].Side[DefSide].Entry[i].flg |= BENT_FLG_ULTIMATE; + } + + return iRet; + +} +#endif + + +int BATTLE_Charge( int battleindex, int attackNo ) +{ + //char szBuffer[512]=""; + int attackindex, iWork, N, pow; + + attackindex = BATTLE_No2Index( battleindex, attackNo ); + + iWork = CHAR_GETWORKINT_LOW( attackindex, CHAR_WORKBATTLECOM3 ); + + if( iWork <= 0 ){ + + N = CHAR_GETWORKINT_HIGH( attackindex, CHAR_WORKBATTLECOM3 ); + pow = CHAR_getWorkInt( attackindex, CHAR_WORKFIXSTR ); + pow += pow * N * 0.01; + CHAR_setWorkInt( attackindex, CHAR_WORKATTACKPOWER, + pow + CHAR_getWorkInt( attackindex, CHAR_WORKMODATTACK ) ); + + CHAR_setWorkInt( attackindex, CHAR_WORKBATTLECOM1, BATTLE_COM_S_CHARGE_OK ); + return TRUE; + }else{ + + CHAR_SETWORKINT_LOW( attackindex, CHAR_WORKBATTLECOM3, iWork - 1); + //snprintf( szBuffer, sizeof(szBuffer), + // "(%s)С", + // CHAR_getUseName( attackindex ) + //); + //BATTLE_BroadCast( battleindex, szBuffer, + // (attackNo >= 10)? CHAR_COLORGRAY : CHAR_COLORPURPLE ) ; + + BATTLE_NoAction( battleindex, attackNo ); + + return FALSE; + } +} + +//״̬ж +int BATTLE_StatusAttackCheck( + int attackindex, + int defindex, + int status, + int PerOffset, + int Range, + float Bai, + int *pPer +) +{ + + int Df_Reg = 0, level = 0, per = 0, i ; + int battleindex; + if( status >= BATTLE_ST_END || status <= 0 )return FALSE; + for( i = 1; i < BATTLE_ST_END; i++ ){//쳣״̬return + if( CHAR_getWorkInt( defindex, StatusTbl[i] ) > 0 )return FALSE; + } + + if( status == BATTLE_ST_PARALYSIS){ + per = 20; + per -= CHAR_getWorkInt( defindex, RegTbl[status] ); + *pPer = per; + }else{ + float templP = 0.0; + float fVitalP = 0.0; + fVitalP = CHAR_getInt( defindex, CHAR_VITAL ) + + CHAR_getInt( defindex, CHAR_STR ) + + CHAR_getInt( defindex, CHAR_TOUGH ) + + CHAR_getInt( defindex, CHAR_DEX ); + + templP = (float)CHAR_getInt( defindex, CHAR_VITAL ) / (fVitalP); + +#ifdef _PET_SKILL_SARS //andy_add 2003/06/20 + if( status == BATTLE_ST_SARS ){ + templP = (1 - templP)*0.9; + } +#endif + + fVitalP = templP / 0.25; + + if( CHAR_getInt( defindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER ){ + fVitalP *= 10.0; + }else{ + if( CHAR_getInt( defindex, CHAR_WHICHTYPE ) == CHAR_TYPEPET ){ + fVitalP *= 10.0; + }else{ + if( CHAR_getInt( defindex, CHAR_WHICHTYPE ) == CHAR_TYPEENEMY ){ + fVitalP *= 10.0; + }else{ + fVitalP *= 10.0; + } + } + } + + if( status >= arraysizeof( RegTbl) || status < 0 ) { + Df_Reg = 0; + }else { + Df_Reg = CHAR_getWorkInt( defindex, RegTbl[status] ); + } + + battleindex = CHAR_getWorkInt( attackindex, CHAR_WORKBATTLEINDEX ); + if( BattleArray[battleindex].type != BATTLE_TYPE_P_vs_P ){ + level = CHAR_getInt( attackindex, CHAR_LV ) + - CHAR_getInt( defindex, CHAR_LV ); + level *= Bai; + }else{ + level = 0; + } + if( level > Range )level = Range; + if( level < -Range )level = -Range; + +#ifdef _SUIT_ADDENDUM + per = PerOffset + level + CHAR_getWorkInt( attackindex, CHAR_WORKFIXLUCK ) + - Df_Reg - fVitalP - CHAR_getWorkInt( defindex, CHAR_WORKRESIST ); +#else + per = PerOffset + level + CHAR_getWorkInt( attackindex, CHAR_WORKFIXLUCK ) + - Df_Reg - fVitalP; +#endif //_SUIT_ADDENDUM +#ifdef _EQUIT_RESIST + if( status == CHAR_WORKWEAKEN ) + per -= CHAR_getWorkInt( defindex, CHAR_WORKEQUITWEAKEN ); + else if( status == CHAR_WORKBARRIER ) + per -= CHAR_getWorkInt( defindex, CHAR_WORKEQUITBARRIER ); + else if( status == CHAR_WORKNOCAST ) + per -= CHAR_getWorkInt( defindex, CHAR_WORKEQUITNOCAST ); +#endif //_EQUIT_RESIST +#ifdef _SUIT_ADDPART3 + if( status == CHAR_WORKWEAKEN ) + per -= CHAR_getWorkInt( defindex, CHAR_WORKRENOCAST ); +#endif + if( per > 80 )per = 80; + *pPer = per; + } + + if( RAND( 1, 100 ) < per ){ + return TRUE; + }else{ + return FALSE; + } +} + +//ְҵ״̬ж +int PROFESSION_BATTLE_StatusAttackCheck( int charaindex, int toindex, int status, int Success ) +{ + int rand_num = RAND( 1, 100 ); + int i; + + if( status >= BATTLE_ST_END || status <= 0 ) return 0; + if( CHAR_getInt( toindex , CHAR_HP) <= 0 ) return 0; + if( CHAR_getFlg( toindex, CHAR_ISDIE ) == TRUE ) return 0; + +#ifdef _PROFESSION_ADDSKILL + if( status == BATTLE_ST_RESIST_F_I_T ){//Ȼ + if( CHAR_getWorkInt( toindex, StatusTbl[BATTLE_ST_RESIST_F] ) > 0 ) return 0; + if( CHAR_getWorkInt( toindex, StatusTbl[BATTLE_ST_RESIST_I] ) > 0 ) return 0; + if( CHAR_getWorkInt( toindex, StatusTbl[BATTLE_ST_RESIST_T] ) > 0 ) return 0; + return 1; + } + if( status == CHAR_WORKICECRACK + || status == CHAR_WORKICECRACK2 + || status == CHAR_WORKICECRACK3 + || status == CHAR_WORKICECRACK4 + || status == CHAR_WORKICECRACK5 + || status == CHAR_WORKICECRACK6 + || status == CHAR_WORKICECRACK7 + || status == CHAR_WORKICECRACK8 + || status == CHAR_WORKICECRACK9 + || status == CHAR_WORKICECRACK10){ + return 1; + } +#endif + + for( i = 1; i < BATTLE_ST_END; i++ ){//쳣״̬return + if( CHAR_getWorkInt( toindex, StatusTbl[i] ) > 0 ) return 0; + } + + if( rand_num < Success ){ + return 1; + }else{ + return 0; + } +} + + + +int BATTLE_Combo( int battleindex, int *pAttackList, int defNo ) +{ + char szBuffer[512]=""; + char szCommand[1024]; + int damage = 0, petdamage = 0, + attackindex, + toindex, + defindex, + ultimate = 0, + AllDamage = 0, + AllPetDamage = 0, + react = 0, + attackNo; + int flg = 0, iWork, par, i, DefSide = 0, + Guardian = -2; + BOOL iRet = FALSE; + + defindex = toindex = BATTLE_No2Index( battleindex, defNo ); + + //BATTLE_BroadCast( battleindex, "ɱ", + // (pAttackList[0] >= 10)? CHAR_COLORGRAY : CHAR_COLORPURPLE ) ; + + for( i = 0; pAttackList[i] != -1 && i < BATTLE_ENTRY_MAX; i ++ ){ + attackNo = pAttackList[i]; + + defindex = toindex; + + flg = 0; + + attackindex = BATTLE_No2Index( battleindex, attackNo ); + + if( CHAR_getInt( toindex, CHAR_HP ) <= 0 ){ + return FALSE; + } + + if( CHAR_getInt( attackindex, CHAR_HP ) <= 0 ){ + return FALSE; + } + + Guardian = -2; + iWork = BATTLE_AttackSeq( attackindex, toindex, &damage, + &Guardian, BATTLE_COM_COMBO ); + Guardian = -1; + if( damage <= 0 )damage = 1; + + par = BATTLE_AttrAdjust( attackindex, defindex, 100 ); + + react = BATTLE_GetDamageReact( defindex ); + if( ( react == BATTLE_MD_REFLEC +#ifdef _PROFESSION_SKILL // WON ADD ְҵ + || react == BATTLE_MD_TRAP +#endif +#ifdef _PETSKILL_ACUPUNCTURE + || react == BATTLE_MD_ACUPUNCTURE +#endif + ) && BATTLE_IsThrowWepon( CHAR_getItemIndex( attackindex, CHAR_ARM ) ) == FALSE ){ + + int refrect = 0; + BATTLE_DamageSub( attackindex, + defindex, &damage, &petdamage, &refrect ); + }else + if( react == BATTLE_MD_ABSROB + || react == BATTLE_MD_VANISH + ){ + int refrect = 0; + BATTLE_DamageSub( attackindex, + defindex, &damage, &petdamage, &refrect ); + }else{ + + BATTLE_DamageSubCale( attackindex, + defindex, &damage, &petdamage ); + AllDamage += damage; + AllPetDamage += petdamage; + } + + if( pAttackList[i+1] == -1 ){ + int refrect = -1; + ultimate = BATTLE_DamageSub2( attackindex, + defindex, &AllDamage, &AllPetDamage, &refrect ); + } + if( react == BATTLE_MD_REFLEC ){ + defindex = attackindex; + } +#ifdef _PROFESSION_SKILL // WON ADD ְҵ + if( react == BATTLE_MD_TRAP ) defindex = attackindex; +#endif +#ifdef _PETSKILL_ACUPUNCTURE + if( react == BATTLE_MD_ACUPUNCTURE ) defindex = attackindex; +#endif + if( damage > 0 && ( react != BATTLE_MD_ABSROB )&& ( react != BATTLE_MD_VANISH )){ + BATTLE_DamageWakeUp( battleindex, defindex ); + } + + szBuffer[0] = 0; + switch( iWork ){ + + case BATTLE_RET_MISS: + case BATTLE_RET_ALLGUARD: + case BATTLE_RET_NORMAL: + //snprintf( szBuffer, sizeof(szBuffer), + // "(%s)ܵ(%s)Ĺ(%d)(%d:%d:%d%%)", + // CHAR_getUseName( attackindex ), + // CHAR_getUseName( defindex ), + // damage, + // CHAR_getWorkInt( attackindex, CHAR_WORKATTACKPOWER ), + // CHAR_getWorkInt( defindex, CHAR_WORKDEFENCEPOWER ), + // par + //); + flg |= BCF_NORMAL; + iRet = TRUE; + //andy_edit + flg |= BATTLE_getReactFlg( defindex, react); + break; + + case BATTLE_RET_CRITICAL: + //snprintf( szBuffer, sizeof(szBuffer), + //"(%s)(%s)CRITICAL(%d%%)(%d)(%d:%d:%d%%)", + // CHAR_getUseName( attackindex ), + // CHAR_getUseName( defindex ), + // (int)(gCriper*0.01), + // damage, + // CHAR_getWorkInt( attackindex, CHAR_WORKATTACKPOWER ), + // CHAR_getWorkInt( defindex, CHAR_WORKDEFENCEPOWER ), + // par + //); + flg |= BCF_KAISHIN; + iRet = FALSE; + //andy_edit + flg |= BATTLE_getReactFlg( defindex, react); + break; + + } + + if( CHAR_getWorkInt( defindex, CHAR_WORKBATTLECOM1 ) == BATTLE_COM_GUARD + && CHAR_getWorkInt( defindex, CHAR_WORKCONFUSION ) <= 0 + ){ + strncat( szBuffer, "(GUARD)", sizeof( szBuffer ) ); + flg |= BCF_GUARD; + iRet = FALSE; + } + + if( CHAR_getInt( defindex, CHAR_HP ) <= 0 ){ + + if( CHAR_getWorkInt( defindex, CHAR_WORKBATTLEFLG ) & CHAR_BATTLEFLG_ABIO ){ + ultimate = 1; + }else + + if( CHAR_getInt( defindex, CHAR_WHICHTYPE ) == CHAR_TYPEENEMY + && flg & BCF_KAISHIN + ){ + if( RAND( 1, 100 ) < 50 ){ + ultimate = 1; + } + } +#ifdef _PETSKILL_LER +// ׶ܱ + if(CHAR_getInt(defindex,CHAR_BASEBASEIMAGENUMBER) == 101813 || + CHAR_getInt(defindex,CHAR_BASEBASEIMAGENUMBER) == 101814) ultimate = 0; +#endif + iRet = FALSE; + flg |= BCF_DEATH; + + if( ultimate == 1 ){ + flg |= BCF_ULTIMATE_1; + strcatsafe( szBuffer,sizeof(szBuffer), "ultimate?" ); + } + if( ultimate == 2 ){ + flg |= BCF_ULTIMATE_2; + strcatsafe( szBuffer,sizeof(szBuffer), "ultimate?" ); + } + } + + if( damage > 0 ){ +#ifdef _TAKE_ITEMDAMAGE + if( BATTLE_ItemCrushSeq( attackindex, defindex, damage) == TRUE ){ +#else + if( BATTLE_ItemCrushSeq( defindex ) == TRUE ){ +#endif + flg |= BCF_CRUSH; + } + } +#ifdef _NOTRIDE_ + if( 0 <= Guardian && Guardian <= 19 ){ + iRet = FALSE; + flg |= BCF_GUARDIAN; + snprintf( szCommand, sizeof( szCommand ), + "a%X|f%X|d%X|g%X|", + attackNo, + flg, + damage, + Guardian ); + }else{ + snprintf( szCommand, sizeof( szCommand ), + "a%X|f%X|d%X|", + attackNo, + flg, + damage ); + } +#else + if( 0 <= Guardian && Guardian <= 19 ){ + iRet = FALSE; + flg |= BCF_GUARDIAN; + snprintf( szCommand, sizeof( szCommand ), + "a%X|f%X|d%X|p%X|g%X|", + attackNo, + flg, + damage, + petdamage, + Guardian ); + }else{ + snprintf( szCommand, sizeof( szCommand ), + "a%X|f%X|d%X|p%X|", + attackNo, + flg, + damage, + petdamage ); + } + +#endif + BATTLESTR_ADD( szCommand ); + + //BATTLE_BroadCast( battleindex, szBuffer, + // (attackNo >= 10)? CHAR_COLORGRAY : CHAR_COLORPURPLE ) ; + + defNo = BATTLE_Index2No( battleindex, defindex ); + + if( defNo >= SIDE_OFFSET ){ + iWork = defNo - SIDE_OFFSET; + DefSide = 1; + }else{ + iWork = defNo; + } + + iWork = defNo-DefSide*SIDE_OFFSET; + if( ultimate > 0 ){ + BattleArray[battleindex].Side[DefSide].Entry[iWork].flg |= BENT_FLG_ULTIMATE; + } + + } + + return iRet; +} + + + +int BATTLE_EarthRoundHide( int battleindex, int attackNo ) +{ + //char szBuffer[512]=""; + char szCommand[1024]; + int attackindex, flg = 0 ; + + szCommand[0] = 0; + + attackindex = BATTLE_No2Index( battleindex, attackNo ); + + sprintf( szCommand, "BF|%X|", attackNo ); + BATTLESTR_ADD( szCommand ); + + //snprintf( szBuffer, sizeof(szBuffer), + // "(%s)Ƶȥ", + // CHAR_getUseName( attackindex ) + //); + + //BATTLE_BroadCast( battleindex, szBuffer, + // (attackNo >= 10)? CHAR_COLORGRAY : CHAR_COLORPURPLE ) ; + + CHAR_setFlg( attackindex, CHAR_ISATTACKED, 0 ); + + CHAR_setWorkInt( attackindex, CHAR_WORKBATTLECOM1, + BATTLE_COM_S_EARTHROUND0 ); + + return ( flg )?(TRUE):(FALSE); + +} + + + +BOOL BATTLE_LostEscape( int battleindex, int attackNo ) +{ + char szBuffer[512]=""; + char szCommand[1024]; + int attackindex, flg = FALSE, side, SubNo, + oyaindex, pno; + + attackindex = BATTLE_No2Index( battleindex, attackNo ); + + if( attackNo >= SIDE_OFFSET ){ + side = 1; SubNo = attackNo - SIDE_OFFSET; + }else{ + side = 0; SubNo = attackNo; + } + + oyaindex = CHAR_getWorkInt( attackindex, CHAR_WORKPLAYERINDEX ); + + pno = CHAR_getInt( oyaindex, CHAR_DEFAULTPET ); + if( pno < 0 )return FALSE; + +// print(" nonoϢ "); + + BATTLE_Exit( attackindex, battleindex ); + + CHAR_setInt( oyaindex, CHAR_DEFAULTPET, -1 ); + + CHAR_AddCharm( oyaindex, CH_FIX_PETESCAPE ); + +// LogPet( +// CHAR_getUseName( oyaindex ), +// CHAR_getUseID( oyaindex ), +// CHAR_getChar( attackindex, CHAR_NAME ), +// CHAR_getInt( attackindex, CHAR_LV ), +// +// "EscapeLost(ս߲)", +// +// CHAR_getInt( oyaindex, CHAR_FLOOR ), +// CHAR_getInt( oyaindex, CHAR_X ), +// CHAR_getInt( oyaindex, CHAR_Y ), +// CHAR_getChar( attackindex, CHAR_UNIQUECODE) // shan 2001/12/14 +// ); + + //snprintf( szBuffer, sizeof(szBuffer), "(%s)ߵˡ", + // CHAR_getUseName( attackindex ) + //); + //if( getBattleDebugMsg( ) != 0 ){ + // BATTLE_BroadCast( battleindex, szBuffer, + // (attackNo >= 10)? CHAR_COLORGRAY : CHAR_COLORPURPLE ) ; + //} + + sprintf( szCommand, "BQ|e%X|", attackNo ); + BATTLESTR_ADD( szCommand ); + + snprintf( szBuffer, sizeof( szBuffer ), "K%d", pno ); + + CHAR_sendStatusString( oyaindex, szBuffer ); + + + + return ( flg )?(TRUE):(FALSE); + + +} + +BOOL BATTLE_Abduct( + int battleindex, + int attackNo, + int defNo, + int array +) +{ + //char szBuffer[512]=""; + char szCommand[1024]; +#ifdef _BATTLE_ABDUCTII + char *pszP=NULL; +#endif + int attackindex, defindex, per, flg, attackoyaindex, defoyaindex = -1; + int attacklevel, deflevel; + int Attacktype, Deftype; + BOOL iRet = FALSE; + + attackindex = BATTLE_No2Index( battleindex, attackNo ); + defindex = BATTLE_No2Index( battleindex, defNo ); + if( CHAR_CHECKINDEX( attackindex ) == FALSE ) return iRet; + if( CHAR_CHECKINDEX( defindex ) == FALSE ) return iRet; +#ifdef _BATTLE_ABDUCTII + // ȡó\ + pszP = PETSKILL_getChar( array, PETSKILL_OPTION ); + if( pszP == "\0" ) return iRet; +#endif + + //ANDY_ReEdit + Attacktype = CHAR_getInt( attackindex, CHAR_WHICHTYPE); + if( Attacktype == CHAR_TYPEENEMY ) { + attackoyaindex = -1; + }else if( Attacktype == CHAR_TYPEPET ) { + attackoyaindex = CHAR_getWorkInt( attackindex, CHAR_WORKPLAYERINDEX ); + if( CHAR_CHECKINDEX( attackoyaindex ) == FALSE ) return iRet; + }else { + return iRet; + } + //ANDY_ReEdit + Deftype = CHAR_getInt( defindex, CHAR_WHICHTYPE ); + if( Deftype == CHAR_TYPEPET ){ + defoyaindex = CHAR_getWorkInt( defindex, CHAR_WORKPLAYERINDEX ); + if( CHAR_CHECKINDEX( defoyaindex ) == FALSE ) return iRet; + }else { + defoyaindex = -1; + } + + if( Deftype != CHAR_TYPEPLAYER ){ +#ifdef _BATTLE_ABDUCTII + int AiPer=0; + // ȡó\ + AiPer = atoi( pszP); + if( AiPer <= 0 || Deftype != CHAR_TYPEPET ){ +#endif + attacklevel = CHAR_getInt( attackindex, CHAR_LV ); + deflevel = CHAR_getInt( defindex, CHAR_LV ); + per = ( deflevel - attacklevel ) * 0.6 + 30; + per = max( per, 50 ); +#ifdef _BATTLE_ABDUCTII + }else { + per = 0; + if( CHAR_getWorkInt( defindex, CHAR_WORKFIXAI) < AiPer ){ + per = 200; + } + } +#endif + }else{ + per = 0; + return iRet; + } + if( BattleArray[battleindex].WinFunc != NULL ){ + per = 0; + } +#ifdef _ALLBLUES_LUA + else if( CHAR_getInt( BattleArray[battleindex].createindex, CHAR_WHICHTYPE ) == CHAR_TYPELUANPC ){ + per = 0; + } +#endif + iRet = TRUE; + if( RAND( 1, 100 ) < per ){ + flg = 1; + //snprintf( szBuffer, sizeof(szBuffer), + // "(%s)(%s)뿪ô(%d%%)", + // CHAR_getUseName( attackindex ), + // CHAR_getUseName( defindex ), + // per + //); + if( Deftype == CHAR_TYPEPET ){ + BATTLE_PetDefaultExit( defoyaindex, battleindex ); + CHAR_setInt( defoyaindex, CHAR_DEFAULTPET, -1 ); + }else if( Deftype == CHAR_TYPEENEMY ) { + BATTLE_Exit( defindex, battleindex ); + } + }else{ + flg = 0; + //snprintf( szBuffer, sizeof(szBuffer), + // "(%s)޷(%s)һĬĬ뿪(%d%%)", + // CHAR_getUseName( attackindex ), + // CHAR_getUseName( defindex ), + // per + //); + } + + //if( getBattleDebugMsg( ) != 0 ){ + // BATTLE_BroadCast( battleindex, szBuffer, + // (attackNo >= 10)? CHAR_COLORGRAY : CHAR_COLORPURPLE ) ; + //} + sprintf( szCommand, "B!|a%X|d%X|f%X|", attackNo, defNo, flg ); + BATTLESTR_ADD( szCommand ); + + //ANDY_ReEdit + if( Attacktype == CHAR_TYPEPET ) { + BATTLE_PetDefaultExit( attackoyaindex, battleindex ); + CHAR_setInt( attackoyaindex, CHAR_DEFAULTPET, -1 ); + }else { + BATTLE_Exit( attackindex, battleindex); + } + return iRet; +} +#ifdef _BATTLESTEAL_FIX +void BATTLE_StealMoney( int battleindex, int attackNo, int defNo) +{ + char szBuffer[512]=""; + char szCommand[1024]; + int attackindex, defindex, per; + int S_FLG = 0, GOLD = 0; + int LV=0; + char buf1[256]; + int masterindex; + int safeSide=0; + + if( BATTLE_CHECKINDEX( battleindex) == FALSE ) return; + attackindex = BATTLE_No2Index( battleindex, attackNo ); + if( CHAR_CHECKINDEX( attackindex ) == FALSE ) return; + defindex = BATTLE_No2Index( battleindex, defNo ); + if( CHAR_CHECKINDEX( defindex ) == FALSE ) return; + masterindex = CHAR_getWorkInt( attackindex, CHAR_WORKPLAYERINDEX ); + if( !CHAR_CHECKINDEX( masterindex ) ) return; + LV = CHAR_getInt( defindex, CHAR_LV ); + per = 0; + if( CHAR_getInt( defindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER ) { + if( attackNo > 10 ) { + safeSide = 1; + } + if( defNo>=safeSide*SIDE_OFFSET && defNo<((safeSide*SIDE_OFFSET)+SIDE_OFFSET)){//ͬ + per = 0; + }else { //ͬ + per = 50; + per = (((per+LV)/4)+10)>>1; + } + }else if( CHAR_getInt( defindex, CHAR_WHICHTYPE ) == CHAR_TYPEENEMY ) { + per=5; + } + S_FLG = 0; + + + + if( CHAR_getInt( attackindex, CHAR_WHICHTYPE ) == CHAR_TYPEPET ) { + if( CHAR_getInt( masterindex, CHAR_GOLD) >= CHAR_getMaxHaveGold( masterindex) ) + per = 0; + } + + if( RAND( 1, 100 ) < per ){ + S_FLG = 1; + if( CHAR_getInt( defindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER ) { + GOLD = CHAR_getInt( defindex, CHAR_GOLD ); + GOLD = (int)( (float)GOLD * RAND( 1, 15 ) * 0.01 ); + if( (CHAR_getInt( masterindex, CHAR_GOLD) + GOLD) >= CHAR_getMaxHaveGold( masterindex) ) { + GOLD = CHAR_getMaxHaveGold( masterindex) - CHAR_getInt( masterindex, CHAR_GOLD); + } + }else { + GOLD = RAND( 10, 100); + } + if( GOLD <= 0 ){ + S_FLG = 0; + }else{ + //snprintf( szBuffer, sizeof(szBuffer), + // "(%s)(%s)(%d)STONE(%d%%)", + // CHAR_getUseName( attackindex ), + // CHAR_getUseName( defindex ), + // GOLD, + // per + // ); + if( CHAR_getInt( defindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER ) { + CHAR_setInt( defindex, CHAR_GOLD, CHAR_getInt( defindex, CHAR_GOLD ) - GOLD ); + CHAR_send_P_StatusString( defindex, CHAR_P_STRING_GOLD ); + } + } + }else{ + //snprintf( szBuffer, sizeof(szBuffer), + // "(%s)û(%s)ö(%d%%)", + // CHAR_getUseName( attackindex ), + // CHAR_getUseName( defindex ), + // per + //); + } + sprintf( buf1, "͵һЩʯ"); + if( S_FLG) { + sprintf( szBuffer, "BK|%s%s|", CHAR_getUseName( defindex ), buf1 ); + strcatsafe( szBadStatusString,sizeof(szBadStatusString), szBuffer ); + if( CHAR_getInt( attackindex, CHAR_WHICHTYPE ) == CHAR_TYPEPET ){ + int attackoyaindex = CHAR_getWorkInt( attackindex, CHAR_WORKPLAYERINDEX ); + if( CHAR_CHECKINDEX( attackoyaindex ) == TRUE ){ + BATTLE_PetDefaultExit( attackoyaindex, battleindex ); + CHAR_setInt( attackoyaindex, CHAR_DEFAULTPET, -1 ); + { + int playergold=CHAR_getInt( attackoyaindex, CHAR_GOLD)+GOLD; + if( playergold > CHAR_getMaxHaveGold( attackoyaindex) ) playergold = CHAR_getMaxHaveGold( attackoyaindex); + CHAR_setInt( attackoyaindex, CHAR_GOLD , playergold); + CHAR_send_P_StatusString( attackoyaindex, CHAR_P_STRING_GOLD ); + } + lssproto_KS_send( getfdFromCharaIndex( attackoyaindex ), + CHAR_getInt( attackoyaindex, CHAR_DEFAULTPET ), 1 ); + } + BATTLE_Exit( attackindex, battleindex ); + }else{ + BATTLE_Exit( attackindex, battleindex ); + } + } + //if( getBattleDebugMsg( ) != 0 ) { + // BATTLE_BroadCast( battleindex, szBuffer, + // (attackNo >= 10)? CHAR_COLORGRAY : CHAR_COLORPURPLE ) ; + //} + sprintf( szCommand, "B#|a%X|d%X|f%X|", attackNo, defNo, S_FLG ); + BATTLESTR_ADD( szCommand ); +} +#endif + +void BATTLE_Steal( int battleindex, int attackNo, int defNo ) +{ + char szBuffer[512]=""; + char szCommand[1024]; + int attackindex, defindex, per, flg, i, j; + int enemytype, stealmode = 0, gold, itemindex; + int itemtbl[CHAR_MAXITEMNUM]; + + attackindex = BATTLE_No2Index( battleindex, attackNo ); + if( CHAR_CHECKINDEX( attackindex ) == FALSE )return; + defindex = BATTLE_No2Index( battleindex, defNo ); + if( CHAR_CHECKINDEX( defindex ) == FALSE )return; + enemytype = CHAR_getInt( defindex, CHAR_WHICHTYPE ); + if( enemytype == CHAR_TYPEPLAYER ){ + per = 50; + }else{ + per = 0; + } + + if( RAND( 1, 100 ) < per ){ + flg = 1; + if( RAND( 1, 100 ) < 50 ){ + stealmode = 0; + gold = CHAR_getInt( defindex, CHAR_GOLD ); + gold = (int)( (float)gold * RAND( 8, 12 ) * 0.01 ); + if( gold <= 0 ){ + //snprintf( szBuffer, sizeof(szBuffer), + // "(%s)޷(%s)STONE(%d%%)", + // CHAR_getUseName( attackindex ), + // CHAR_getUseName( defindex ), + // per + //); + flg = 0; + }else{ + //snprintf( szBuffer, sizeof(szBuffer), + // "(%s)(%s)(%d)STONE(%d%%)", + // CHAR_getUseName( attackindex ), + // CHAR_getUseName( defindex ), + // gold, + // per + //); + CHAR_setInt( defindex, CHAR_GOLD, + CHAR_getInt( defindex, CHAR_GOLD ) - gold ); + CHAR_send_P_StatusString( defindex, CHAR_P_STRING_GOLD ); + } + }else{ + stealmode = 1; + for( j = 0, i = CHAR_STARTITEMARRAY; i < CHAR_MAXITEMHAVE; i ++ ){ + itemindex = CHAR_getItemIndex( defindex, i ); + if( ITEM_CHECKINDEX( itemindex ) == TRUE ){ + itemtbl[j++] = i; + } + } + if( j <= 0 ){ + itemindex = -1; + }else{ + itemindex = -1; + i = RAND( 0, j-1 ); + if( i >= 0 ){ + if( 0 <= itemtbl[i] && itemtbl[i] < CHAR_STARTITEMARRAY ){ + fprint( "err:ҪȡװƷ(%d)\n", itemtbl[i] ); + }else{ + itemindex = CHAR_getItemIndex( defindex, itemtbl[i] ); + } + } + } + if( itemindex == - 1 ){ + //snprintf( szBuffer, sizeof(szBuffer), + // "(%s)޷(%s)ĵ(%d%%)", + // CHAR_getUseName( attackindex ), + // CHAR_getUseName( defindex ), + // per + //); + flg = 0; + }else{ + //snprintf( szBuffer, sizeof(szBuffer), + // "(%s)(%s)(%s)(%d%%)", + // CHAR_getUseName( attackindex ), + // CHAR_getUseName( defindex ), + // ITEM_getAppropriateName( itemindex ), + // per + //); + CHAR_setItemIndex( defindex, itemtbl[i], -1 ); + CHAR_sendItemDataOne( defindex, itemtbl[i] ); + { +// LogItem( +// CHAR_getChar( defindex, CHAR_NAME ), +// CHAR_getChar( defindex, CHAR_CDKEY ), +//#ifdef _add_item_log_name // WON ADD itemlogitem +// itemindex, +//#else +// ITEM_getInt( itemindex, ITEM_ID ), +//#endif +// "Stealed(͵Եĵ)", +// CHAR_getInt( defindex,CHAR_FLOOR), +// CHAR_getInt( defindex,CHAR_X ), +// CHAR_getInt( defindex,CHAR_Y ), +// ITEM_getChar( itemindex, ITEM_UNIQUECODE), +// ITEM_getChar( itemindex, ITEM_NAME), +// ITEM_getInt( itemindex, ITEM_ID) +// ); + } + ITEM_endExistItemsOne( itemindex ); + } + } + }else{ + flg = 0; + //snprintf( szBuffer, sizeof(szBuffer), "(%s)û(%s)ö(%d%%)", + // CHAR_getUseName( attackindex ), CHAR_getUseName( defindex ), per ); + } + if( flg == 1 ){ + sprintf( szBuffer, "BK|%s͵һЩ|", + CHAR_getUseName( defindex ) ); + strcatsafe( szBadStatusString,sizeof(strcatsafe), szBuffer ); + if( CHAR_getInt( attackindex, CHAR_WHICHTYPE ) == CHAR_TYPEPET ){ + int attackoyaindex = CHAR_getWorkInt( attackindex, CHAR_WORKPLAYERINDEX ); + if( CHAR_CHECKINDEX( attackoyaindex ) == TRUE ){ + BATTLE_PetDefaultExit( attackoyaindex, battleindex ); + CHAR_setInt( attackoyaindex, CHAR_DEFAULTPET, -1 ); + }else{ + BATTLE_Exit( attackindex, battleindex ); + } + }else{ + BATTLE_Exit( attackindex, battleindex ); + } + } + //if( getBattleDebugMsg( ) != 0 ){ + // BATTLE_BroadCast( battleindex, szBuffer, + // (attackNo >= 10)? CHAR_COLORGRAY : CHAR_COLORPURPLE ) ; + //} + sprintf( szCommand, "B#|a%X|d%X|f%X|", attackNo, defNo, flg ); + BATTLESTR_ADD( szCommand ); +} + +#ifdef _PSKILL_FALLGROUND // +int BATTLE_S_FallGround( int battleindex, int attackNo, int defNo, int skill_type) +{ + char szBuffer[512]=""; + char szCommand[1024]; + int attackindex, defindex; + int damage=0, petdamage=0, i=0, iWork, Guardian=-1; + int flg = 0, DefSide=0,par,ultimate=0, react=0; + BOOL iRet = FALSE; + attackindex = BATTLE_No2Index( battleindex, attackNo ); //index + defindex = BATTLE_No2Index( battleindex, defNo ); //طindex + + + if( defNo >= SIDE_OFFSET ){ + i = defNo - SIDE_OFFSET; + DefSide = 1; + } + react = 0; + react = BATTLE_GetDamageReact( defindex);//й⾵ + //ȡù״̬ + iWork = BATTLE_AttackSeq( attackindex, defindex, &damage, + &Guardian, BATTLE_COM_S_FALLRIDE ); + + + ultimate = BATTLE_DamageSub( attackindex, defindex, &damage, &petdamage, &react ); + if( react == BATTLE_MD_REFLEC ) defindex = attackindex; + +#ifdef _PROFESSION_SKILL // WON ADD ְҵ + if( react == BATTLE_MD_TRAP ) defindex = attackindex; +#endif +#ifdef _PETSKILL_ACUPUNCTURE + if( react == BATTLE_MD_ACUPUNCTURE ) defindex = attackindex; +#endif + if( damage > 0 && ( react != BATTLE_MD_ABSROB )&& ( react != BATTLE_MD_VANISH )){ + BATTLE_DamageWakeUp( battleindex, defindex ); + } + par = BATTLE_AttrAdjust( attackindex, defindex, 100 ); + + + + switch( iWork ){ + case BATTLE_RET_ALLGUARD: + case BATTLE_RET_MISS: + //snprintf( szBuffer, sizeof(szBuffer), + // "(%s)(%s),ûС", + // CHAR_getUseName( attackindex ), + // CHAR_getUseName( defindex ) + //); + iRet = TRUE; + break; + case BATTLE_RET_DODGE: + //snprintf( szBuffer, sizeof(szBuffer), + // "(%s)չ(%s)㿪(%.2f%%)", + // CHAR_getUseName( attackindex ), + // CHAR_getUseName( defindex ), + // gDuckPer + //); + flg |= BCF_DODGE; + iRet = TRUE; + break; + case BATTLE_RET_NORMAL: + //snprintf( szBuffer, sizeof(szBuffer), + // "(%s)ܵ(%s)ľ(%d)(%d:%d:%d%%)", + // CHAR_getUseName( attackindex ), + // CHAR_getUseName( defindex ), + // damage, + // CHAR_getWorkInt( attackindex, CHAR_WORKATTACKPOWER ), + // CHAR_getWorkInt( defindex, CHAR_WORKDEFENCEPOWER ), + // par + //); + //andy_edit + flg |= BATTLE_getReactFlg( defindex, react); + flg |= BCF_NORMAL; + iRet = TRUE; + break; + case BATTLE_RET_CRITICAL: + //snprintf( szBuffer, sizeof(szBuffer), + //"(%s)ܵ(%s)ľCRITICAL(%d)(%d:%d:%d%%)", + // CHAR_getUseName( attackindex ), + // CHAR_getUseName( defindex ), + // damage, + // CHAR_getWorkInt( attackindex, CHAR_WORKATTACKPOWER ), + // CHAR_getWorkInt( defindex, CHAR_WORKDEFENCEPOWER ), + // par + //); + flg |= BCF_KAISHIN; + iRet = FALSE; + flg |= BATTLE_getReactFlg( defindex, react); + break; +#ifdef _EQUIT_ARRANGE + case BATTLE_RET_ARRANGE: + //snprintf( szBuffer, sizeof(szBuffer), + // "(%s)(%s)(%.2f%%)", + // CHAR_getUseName( attackindex ), + // CHAR_getUseName( defindex ), + // gDuckPer + //); + flg |= BCF_B_ARRANGE; + break; +#endif + } + + if( CHAR_getWorkInt( defindex, CHAR_WORKBATTLECOM1 ) == BATTLE_COM_GUARD + && CHAR_getWorkInt( defindex, CHAR_WORKCONFUSION ) <= 0 ){ + strncat( szBuffer, "(GUARD)", sizeof( szBuffer ) ); + iRet = FALSE; + } + + if( skill_type == BATTLE_COM_S_FALLRIDE && damage > 0 && react == 0 +#ifdef _PREVENT_TEAMATTACK + && BATTLE_CheckSameSide( attackindex, defNo) == 0 +#endif + ){ // + int fallflg = RAND( 0, 100); + if( +#ifdef _EQUIT_RESIST + fallflg > 50 + CHAR_getWorkInt( defindex, CHAR_WORKEQUITFALLRIDE ) +#else + fallflg > 50 +#endif + ){ + if( CHAR_getInt( defindex , CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER ) { +#ifdef _FIXPETFALL //Syu ADD + if( CHAR_getInt( defindex, CHAR_RIDEPET) >= 0 ) { +#else + if( CHAR_getInt( defindex, CHAR_RIDEPET) > 0 ) { +#endif + flg |= BCF_FALL; + CHAR_setInt( defindex, CHAR_RIDEPET, -1 ); + BATTLE_changeRideImage( defindex ); + CHAR_setWorkInt( defindex, CHAR_WORKPETFALL, 1 ); + } + } +#ifdef _ENEMY_FALLGROUND + else if( CHAR_getInt( defindex , CHAR_WHICHTYPE ) == CHAR_TYPEENEMY ) { + if( CHAR_getInt( defindex, CHAR_RIDEPET) > 0 ) { + CHAR_setInt( defindex, CHAR_RIDEPET, -1 ); + BATTLE_changeRideImage( defindex ); + CHAR_setWorkInt( defindex, CHAR_WORKPETFALL, 1 ); + + CHAR_setInt( defindex, CHAR_STR, CHAR_getInt( defindex, CHAR_STR)*0.7); + CHAR_setInt( defindex, CHAR_TOUGH, CHAR_getInt( defindex, CHAR_TOUGH)*0.7); + CHAR_setInt( defindex, CHAR_VITAL, CHAR_getInt( defindex, CHAR_VITAL)*0.7); + CHAR_complianceParameter( defindex ); + if( CHAR_getInt( defindex , CHAR_HP) > CHAR_getWorkInt( defindex , CHAR_WORKMAXHP ) ) { + CHAR_setInt( defindex , CHAR_HP , CHAR_getWorkInt( defindex , CHAR_WORKMAXHP ) ); + } + } + } +#endif + } + } + + if( CHAR_getInt( defindex, CHAR_HP ) <= 0 ){ + if( CHAR_getWorkInt( defindex, CHAR_WORKBATTLEFLG ) & CHAR_BATTLEFLG_ABIO ){ + ultimate = 1; + }else + if( CHAR_getInt( defindex, CHAR_WHICHTYPE ) == CHAR_TYPEENEMY && flg & BCF_KAISHIN ){ + if( RAND( 1, 100 ) < 50 ){ + ultimate = 1; + } + } +#ifdef _PETSKILL_LER +// ׶ܱ + if(CHAR_getInt(defindex,CHAR_BASEBASEIMAGENUMBER) == 101813 || + CHAR_getInt(defindex,CHAR_BASEBASEIMAGENUMBER) == 101814) ultimate = 0; +#endif + iRet = FALSE; + flg |= BCF_DEATH; + if( ultimate == 1 ){ + flg |= BCF_ULTIMATE_1; + strcatsafe( szBuffer,sizeof(szBuffer), "ultimate?" ); + } + if( ultimate == 2 ){ + flg |= BCF_ULTIMATE_2; + strcatsafe( szBuffer,sizeof(szBuffer), "ultimate?" ); + } + } + if( damage > 0 ){ +#ifdef _TAKE_ITEMDAMAGE + if( BATTLE_ItemCrushSeq( attackindex, defindex, damage) == TRUE ){ +#else + if( BATTLE_ItemCrushSeq( defindex ) == TRUE ){ +#endif + flg |= BCF_CRUSH; + } + } + snprintf( szCommand, sizeof( szCommand ), "BH|a%X|r%X|f%X|d%X|p%X|FF|", + attackNo, defNo, flg, damage, petdamage ); + + BATTLESTR_ADD( szCommand ); + //BATTLE_BroadCast( battleindex, szBuffer, + // (attackNo >= 10)? CHAR_COLORGRAY : CHAR_COLORPURPLE ) ; + i = defNo-DefSide*SIDE_OFFSET; + if( ultimate > 0 ){ + BattleArray[battleindex].Side[DefSide].Entry[i].flg |= BENT_FLG_ULTIMATE; + } + + return iRet; +} +#endif + +#ifdef _PRO_BATTLEENEMYSKILL +int BATTLE_E_ENEMYREFILE( int battleindex, int attackNo, int defNo, int skill_type ) +{ + int ReceveEffect; + BOOL iRet = FALSE; + int attackindex, defindex, pow, toNo; + + toNo=-1; + attackindex = BATTLE_No2Index( battleindex, attackNo); + + if( !CHAR_CHECKINDEX( attackindex) ) return iRet; + if( CHAR_getInt( attackindex , CHAR_WHICHTYPE ) == CHAR_TYPEENEMY ) { + int k=0, j=0, index; + int ToNoList[10]; + int l=0; + memset( ToNoList,-1, sizeof( ToNoList)); + + for( k=10;k<20;k++) { + index = BATTLE_getBattleDieIndex( battleindex, k); + if( !CHAR_CHECKINDEX( index) ) continue; + if( CHAR_getFlg( index, CHAR_ISDIE ) == TRUE ) { + ToNoList[j] = k; + j++; + } + } + if( j == 0 ) return iRet; + toNo = ToNoList[ l=RAND( 0, j-1)]; + if( toNo < 0 || toNo > 20 ) + return iRet; + }else if( CHAR_getInt( attackindex , CHAR_WHICHTYPE ) == CHAR_TYPEPET ) { + toNo = defNo; + }else { + return iRet; + } + if( !BATTLE_CHECKNO( toNo) ) return iRet; + ReceveEffect = SPR_fukkatu1; + defindex = BATTLE_No2Index( battleindex, toNo); + if( !CHAR_CHECKINDEX( defindex) ) return iRet; + pow = CHAR_getWorkInt( defindex, CHAR_WORKMAXHP)/2; + BATTLE_MultiRessurect( battleindex, attackNo, toNo, + pow, 0, SPR_item3, ReceveEffect ); + iRet = TRUE; + + return iRet; +} + +int BATTLE_E_ENEMYREHP( int battleindex, int attackNo, int defNo, int skill_type) +{ + BOOL iRet=FALSE; + int attackindex, defindex; + int power = 0, per = 0, HealedEffect, toNo=-1; + int kind; + + attackindex = BATTLE_No2Index( battleindex, attackNo); + if( CHAR_CHECKINDEX( attackindex ) == FALSE ) return iRet; + if( CHAR_getWorkInt( attackindex, CHAR_WORKBATTLEMODE ) == BATTLE_CHARMODE_INIT || + !CHAR_getWorkInt( attackindex, CHAR_WORKBATTLEMODE ) ){ + return iRet; + } + + if( CHAR_getInt( attackindex , CHAR_WHICHTYPE ) == CHAR_TYPEENEMY ) { + int k=0, j=0, l, index; + int ToNoList[10]; + memset( ToNoList,-1, sizeof( ToNoList)); + for( k=10;k<20;k++) { + index = BATTLE_No2Index( battleindex, k); + if( !CHAR_CHECKINDEX( index) ) continue; + if( CHAR_getInt( index, CHAR_HP) <= 0 ) continue; + if( CHAR_getInt( index, CHAR_HP) < (CHAR_getWorkInt( index, CHAR_WORKMAXHP) *2/3)) { + ToNoList[j] = k; + j++; + } + } + if( j == 0 ) return iRet; + toNo = ToNoList[ l=RAND( 0, j-1)]; + if( toNo < 0 || toNo > 20 ) + return iRet; + + }else if( CHAR_getInt( attackindex , CHAR_WHICHTYPE ) == CHAR_TYPEPET ) { + toNo = defNo; + }else { + return iRet; + } + defindex = BATTLE_No2Index( battleindex, toNo); + if( CHAR_CHECKINDEX( defindex ) == FALSE ) return iRet; + + kind = 0; + power = RAND( 100, CHAR_getWorkInt( defindex, CHAR_WORKMAXHP)); + HealedEffect = SPR_heal2; + BATTLE_MultiRecovery( battleindex, attackNo, toNo,kind, power, per, SPR_item3, HealedEffect ); + + iRet = TRUE; + return iRet; +} + +int BATTLE_E_ENEMYHELP( int battleindex, int attackNo, int defNo, int skill_type ) +{ + BOOL iRet = FALSE; + int attackindex, enindex, array; + int Side=-1, LV, i, enemynum, PetID; + //char szBuffer[256]=""; + //print("\n BATTLE_E_ENEMYHELP()"); + + attackindex = BATTLE_No2Index( battleindex, attackNo); + if( CHAR_CHECKINDEX( attackindex ) == FALSE ) return iRet; + if( CHAR_getInt( attackindex , CHAR_WHICHTYPE ) != CHAR_TYPEENEMY || + BattleArray[battleindex].type == BATTLE_TYPE_P_vs_P || + CHAR_getInt( attackindex , CHAR_HP) <= 0 ) { + return iRet; + } + + if( CHAR_getInt( attackindex , CHAR_WHICHTYPE ) == CHAR_TYPEENEMY ) { + int k=0, index; + int ToNoList[10]; + memset( ToNoList,-1, sizeof( ToNoList)); + for( k=10;k<20;k++) { + index = BATTLE_No2Index( battleindex, k); + if( !CHAR_CHECKINDEX( index) ) { + break; + } + } + if( k == 20 ) return iRet; + } + LV = CHAR_getInt( attackindex, CHAR_LV ); + + PetID = CHAR_getInt( attackindex, CHAR_PETID ); + enemynum = ENEMY_getEnemyNum(); + for( i = 0; i < enemynum; i ++ ) { + //if( ENEMY_getInt( i, ENEMY_ID ) == PetID ) + if( ENEMY_getInt( i, ENEMY_TEMPNO ) == PetID ) + break; + } + if( i == enemynum ) + return iRet; + array = i; + + Side = CHAR_getWorkInt( attackindex, CHAR_WORKBATTLESIDE ); + enindex = ENEMY_createEnemy( array, RAND( (LV*0.8), LV*1.2)); + if( !CHAR_CHECKINDEX( enindex ) ) return iRet; + if( BATTLE_NewEntry( enindex, battleindex, Side) ) { + //CHAR_setWorkInt( enindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_RESCUE ); + CHAR_setWorkInt( enindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + //snprintf( szBuffer, sizeof( szBuffer ), "(%s)ս", + // CHAR_getUseName( enindex ) ); + //BATTLE_BroadCast( battleindex, szBuffer, CHAR_COLORYELLOW ); + }else { + + } + iRet = TRUE; + return iRet; + +} + +#endif + +int BATTLE_DefineAttack( int attackindex, int defindex, int iWork, + char *szBuffer, int damage, int react, int *flg) +{ + int iRet; + int par; + iRet = TRUE; + par = BATTLE_AttrAdjust( attackindex, defindex, 100 ); + switch( iWork ){ + case BATTLE_RET_ALLGUARD: + case BATTLE_RET_MISS: + //snprintf( szBuffer, sizeof(szBuffer), + // "(%s)(%s),ûС", + // CHAR_getUseName( attackindex ), + // CHAR_getUseName( defindex ) + //); + iRet = TRUE; + break; + case BATTLE_RET_DODGE: + //snprintf( szBuffer, sizeof(szBuffer), + // "(%s)չ(%s)㿪(%.2f%%)", + // CHAR_getUseName( attackindex ), + // CHAR_getUseName( defindex ), + // gDuckPer + //); + *flg |= BCF_DODGE; + iRet = TRUE; + break; + case BATTLE_RET_NORMAL: + //snprintf( szBuffer, sizeof(szBuffer), + // "(%s)ܵ(%s)ľ(%d)(%d:%d:%d%%)", + // CHAR_getUseName( attackindex ), + // CHAR_getUseName( defindex ), + // damage, + // CHAR_getWorkInt( attackindex, CHAR_WORKATTACKPOWER ), + // CHAR_getWorkInt( defindex, CHAR_WORKDEFENCEPOWER ), + // par + //); + + *flg |= BATTLE_getReactFlg( defindex, react); + *flg |= BCF_NORMAL; + iRet = TRUE; + break; + case BATTLE_RET_CRITICAL: + //snprintf( szBuffer, sizeof(szBuffer), + //"(%s)ܵ(%s)ľCRITICAL(%d)(%d:%d:%d%%)", + // CHAR_getUseName( attackindex ), + // CHAR_getUseName( defindex ), + // damage, + // CHAR_getWorkInt( attackindex, CHAR_WORKATTACKPOWER ), + // CHAR_getWorkInt( defindex, CHAR_WORKDEFENCEPOWER ), + // par + //); + *flg |= BCF_KAISHIN; + iRet = FALSE; + *flg |= BATTLE_getReactFlg( defindex, react); + break; +#ifdef _EQUIT_ARRANGE + case BATTLE_RET_ARRANGE: + //snprintf( szBuffer, sizeof(szBuffer), + // "(%s)(%s)(%.2f%%)", + // CHAR_getUseName( attackindex ), + // CHAR_getUseName( defindex ), + // gDuckPer + //); + *flg |= BCF_B_ARRANGE; + break; +#endif + } + if( CHAR_getWorkInt( defindex, CHAR_WORKBATTLECOM1 ) == BATTLE_COM_GUARD + && CHAR_getWorkInt( defindex, CHAR_WORKCONFUSION ) <= 0 ){ + //strncat( szBuffer, "(GUARD)", sizeof( szBuffer ) ); + iRet = FALSE; + } + + return iRet; +} + +int BATTLE_DefDieType( int defindex, int iRet, int *ultimate, int *flg, char *szBuffer) +{ + + if( CHAR_getInt( defindex, CHAR_HP ) <= 0 ){ + if( CHAR_getWorkInt( defindex, CHAR_WORKBATTLEFLG ) & CHAR_BATTLEFLG_ABIO ){ + *ultimate = 1; + }else + if( CHAR_getInt( defindex, CHAR_WHICHTYPE ) == CHAR_TYPEENEMY && *flg & BCF_KAISHIN ){ + if( RAND( 1, 100 ) < 50 ){ + *ultimate = 1; + } + } + +#ifdef _PETSKILL_LER +// ׶ܱ + if(CHAR_getInt(defindex,CHAR_BASEBASEIMAGENUMBER) == 101813 || + CHAR_getInt(defindex,CHAR_BASEBASEIMAGENUMBER) == 101814) *ultimate = 0; +#endif + iRet = FALSE; + *flg |= BCF_DEATH; + if( *ultimate == 1 ){ + *flg |= BCF_ULTIMATE_1; + strcatsafe( szBuffer,sizeof(szBuffer), "ultimate?" ); + } + if( *ultimate == 2 ){ + *flg |= BCF_ULTIMATE_2; + strcatsafe( szBuffer,sizeof(szBuffer), "ultimate?" ); + } + } + return iRet; +} + +#ifdef _SKILL_DAMAGETOHP +int BATTLE_S_DamageToHp( int battleindex, int attackindex, int defindex, int Damage, int skill) +{ + char *pszOption; + char buf1[256]; + int A_HP=0, pHP,defi=0; + float def=0.00; + if( Damage < 1 ) return A_HP; + if( BATTLE_GetDamageReact( defindex) > 0 )//й⾵ + return A_HP; + + pszOption = PETSKILL_getChar( skill, PETSKILL_OPTION ); + if( pszOption == "\0" ) + return A_HP; + memset( buf1, 0, sizeof( buf1)); + if( getStringFromIndexWithDelim( pszOption, "|",2, buf1,sizeof( buf1)) == FALSE ) + return A_HP; + + defi = atoi( buf1); + def = ((float)defi)/100; + A_HP = (int)(Damage*def); + if( (A_HP+CHAR_getInt( attackindex, CHAR_HP)) > CHAR_getWorkInt( attackindex, CHAR_WORKMAXHP ) ){ + A_HP = CHAR_getWorkInt( attackindex, CHAR_WORKMAXHP )-CHAR_getInt( attackindex, CHAR_HP); + } + + pHP = CHAR_getInt( attackindex, CHAR_HP) + A_HP; + CHAR_setInt( attackindex, CHAR_HP, min( pHP, CHAR_getWorkInt( attackindex, CHAR_WORKMAXHP ))); + CHAR_send_P_StatusString( attackindex, CHAR_P_STRING_HP); + return A_HP; +} +#endif + +#ifdef _PETSKILL_DAMAGETOHP +int BATTLE_S_DamageToHp2( int battleindex, int attackindex, int defindex, int Damage, int skill) +{ + char *pszOption; + char buf1[256]; + int A_HP=0, pHP,defi=0; + float def=0.00; + if( Damage < 1 ) return A_HP; + if( BATTLE_GetDamageReact( defindex) > 0 )//й⾵ + return A_HP; + + pszOption = PETSKILL_getChar( skill, PETSKILL_OPTION ); + if( pszOption == "\0" ) + return A_HP; + memset( buf1, 0, sizeof( buf1)); + sprintf(buf1,"%s",pszOption); + //if( getStringFromIndexWithDelim( pszOption, "|",2, buf1,sizeof( buf1)) == FALSE ) + // return A_HP; + + defi = atoi( buf1); + def = ((float)defi)/100; + A_HP = (int)(Damage*def); + if( (A_HP+CHAR_getInt( attackindex, CHAR_HP)) > CHAR_getWorkInt( attackindex, CHAR_WORKMAXHP ) ){ + A_HP = CHAR_getWorkInt( attackindex, CHAR_WORKMAXHP )-CHAR_getInt( attackindex, CHAR_HP); + } + //print("\n:%d Ѫ:%d",Damage,A_HP); + pHP = CHAR_getInt( attackindex, CHAR_HP) + A_HP; + CHAR_setInt( attackindex, CHAR_HP, min( pHP, CHAR_getWorkInt( attackindex, CHAR_WORKMAXHP ))); + CHAR_send_P_StatusString( attackindex, CHAR_P_STRING_HP); + return A_HP; +} +#endif + +#ifdef _Skill_MPDAMAGE //BATTLE_COM_S_MPDAMAGE +int BATTLE_S_MpDamage( int battleindex, int attackindex, int defindex, int damage, int skill) +{ + char *pszOption; + char buf1[256]; + int D_MP=0,defi=0; + float def=0.00; + if( damage < 1 ) return D_MP; + if( BATTLE_GetDamageReact( defindex) > 0 )//й⾵ + return D_MP; + if( CHAR_getInt( defindex, CHAR_WHICHTYPE) == CHAR_TYPEENEMY || + CHAR_getInt( defindex, CHAR_WHICHTYPE) == CHAR_TYPEPET ) + return D_MP; + if( CHAR_getInt( defindex, CHAR_MP) <= 0 ) return D_MP; + + pszOption = PETSKILL_getChar( skill, PETSKILL_OPTION ); + if( pszOption == "\0" ) return D_MP; + memset( buf1, 0, sizeof( buf1)); + if( getStringFromIndexWithDelim( pszOption, "|",2, buf1,sizeof( buf1)) == FALSE ) + return D_MP; + defi = atoi( buf1); + def = ((float)defi)/100; + D_MP = (int)(CHAR_getInt( defindex, CHAR_MP)*def); + CHAR_setInt( defindex, CHAR_MP, ( CHAR_getInt( defindex, CHAR_MP) - D_MP) ); + CHAR_send_P_StatusString( defindex, CHAR_P_STRING_MP); + return D_MP; +} +#endif +#ifdef _SKILL_TOOTH +void BATTLE_S_ToothCrushe( int battleindex, int attackindex, int defindex, int damage, int skill) +{ + int crushindex, itemindex; //aszCrushTbl + //char *strCrushTbl[] = { "", "", "ٻ" , "ʹ" , "Ƭ" }; + if( CHAR_getInt( defindex, CHAR_WHICHTYPE) != CHAR_TYPEPLAYER +#ifdef _TAKE_ITEMDAMAGE_FOR_PET + && CHAR_getInt( defindex, CHAR_WHICHTYPE) == CHAR_TYPEPET +#endif + ) + return; +#ifdef _TAKE_ITEMDAMAGE + if( ( crushindex = BATTLE_ItemCrushCheck( defindex, 1) ) >= 0 ) { + int crushenum, maxcrushenum, level=0; + float def=0.00; + itemindex = CHAR_getItemIndex( defindex, crushindex ); + if( ITEM_CHECKINDEX(itemindex) == FALSE ) return; + crushenum = ITEM_getInt( itemindex, ITEM_DAMAGECRUSHE); + maxcrushenum = ITEM_getInt( itemindex, ITEM_MAXDAMAGECRUSHE); + if( maxcrushenum < 1 ) return; + def = ((float)crushenum/maxcrushenum); + if( def >= 1 ) { + level = 1; + def = 0.70; + }else if( def >= 0.50 ){ + level = 2; + def = 0.30; + }else if( def >= 0.30 ){ + level = 3; + def = 0.10; + }else{ + def = 0.00; + } + crushenum = (int)((float)maxcrushenum*def); + ITEM_setInt( itemindex, ITEM_DAMAGECRUSHE, crushenum); + + if( crushenum <= 0 ) { + char buf2[256]; + sprintf(buf2, "%s𻵶ʧ\n", ITEM_getChar( itemindex, ITEM_NAME)); + CHAR_talkToCli( defindex, -1, buf2, CHAR_COLORYELLOW); + +// LogItem( +// CHAR_getChar( defindex, CHAR_NAME ), +// CHAR_getChar( defindex, CHAR_CDKEY ), +//#ifdef _add_item_log_name // WON ADD itemlogitem +// itemindex, +//#else +// ITEM_getInt( itemindex, ITEM_ID ), +//#endif +// "𻵶ʧ", +// CHAR_getInt( defindex,CHAR_FLOOR), +// CHAR_getInt( defindex,CHAR_X ), +// CHAR_getInt( defindex,CHAR_Y ), +// ITEM_getChar( itemindex, ITEM_UNIQUECODE), +// ITEM_getChar( itemindex, ITEM_NAME), +// ITEM_getInt( itemindex, ITEM_ID) +// ); + + CHAR_setItemIndex( defindex, crushindex ,-1); + ITEM_endExistItemsOne( itemindex); + + }else { + char buf2[256]; + sprintf( buf2, "%s%sġ", ITEM_getChar( itemindex, ITEM_NAME ), aszCrushTbl[level] ); + CHAR_talkToCli( defindex, -1, buf2, CHAR_COLORYELLOW); + //ĵ˵ +// buf1 = ITEM_getChar( itemindex, ITEM_SECRETNAME); +// if( strstr( buf1, "(") != 0 ) { +// char buf5[256]; +// if( getStringFromIndexWithDelim( buf1,"(",1, buf5, sizeof( buf5)) != FALSE ) { +// sprintf( buf1, buf5); +// } +// } +// sprintf( buf2, "%s(%s)", buf1, aszCrushTbl[level]); +// ITEM_setChar( itemindex, ITEM_SECRETNAME, buf2); + ITEM_setInt( itemindex, ITEM_CRUSHLEVEL, level); + } + CHAR_sendItemDataOne( defindex, crushindex ); + CHAR_complianceParameter( defindex ); + CHAR_send_P_StatusString( defindex, CHAR_P_STRING_ATK | CHAR_P_STRING_DEF + | CHAR_P_STRING_QUICK | CHAR_P_STRING_CHARM ); + + } +#endif +} +#endif + +#ifdef _PSKILL_MODIFY +void BATTLE_S_Modifyattack( int battleindex, int attackindex, int defindex, int *damage, int skill) +{ + int i; + char *pszOption=NULL; + int array = skill; + char buf1[256], buf2[256]; + float def=0.00; + struct tagModKind{ + char szModKind[36]; + int Kind; + }KModKind[5] = { + { "EA", CHAR_EARTHAT}, { "WA", CHAR_WATERAT}, + { "FI", CHAR_FIREAT} , { "WI", CHAR_WINDAT}, + { "ALL",100} + }; + + + pszOption = PETSKILL_getChar( array, PETSKILL_OPTION ); + if( pszOption == "\0" ) return; + if( getStringFromIndexWithDelim( pszOption, "|", 1, buf1, sizeof( buf1)) == FALSE ) + return; + + if( getStringFromIndexWithDelim( pszOption, "|", 2, buf2, sizeof( buf1)) == FALSE ) + return; + def = ((float)(atoi( buf2))/100); + + for( i=0; i< 4; i++) { + int ModNum=0; + if( strcmp( KModKind[i].szModKind , buf1)) continue; + if( (ModNum = CHAR_getInt( defindex, KModKind[i].Kind )) > 0 ) { + def += (float)((rand()%(ModNum+5))/100); + *damage += *damage * def; + break; + } + } +} +#endif + +#ifdef _PETSKILL_PROPERTY +int BATTLE_S_PetSkillProperty( int battleindex, int attackNo, int skill_type, int skill) +{ + int attackindex; + BOOL iRet = FALSE; + char *pszP=NULL; + + pszP = PETSKILL_getChar( skill, PETSKILL_OPTION ); + if( pszP == "\0" ) return iRet; + + + attackindex = BATTLE_No2Index( battleindex, attackNo ); //index + if( !CHAR_CHECKINDEX( attackindex)) return iRet; + switch( skill_type){ + case BATTLE_COM_S_PROPERTYSKILL: + { + Char *ch; + ch = CHAR_getCharPointer( attackindex); + if( ch == NULL ) return iRet; + strcpysafe( ch->charfunctable[CHAR_BATTLEPROPERTY].string, + sizeof( ch->charfunctable[CHAR_BATTLEPROPERTY]), pszP);//ս + CHAR_constructFunctable( attackindex); + iRet = TRUE; + } + break; + } + return iRet; +} +#endif + +int BATTLE_S_AttackDamage( int battleindex, int attackNo, int defNo, int skill_type, int skill) +{ + char szBuffer[512]=""; + char szCommand[1024]; + int attackindex, defindex; + int damage=0, petdamage=0, i=0, iWork, Guardian=-1,react; + int flg = 0, DefSide=0,ultimate=0; + int otherdamage=0; + BOOL iRet = FALSE; + int ReactType = 0; + + char *pszP=NULL; + pszP = PETSKILL_getChar( skill, PETSKILL_OPTION ); + if( pszP == "\0" ) return iRet; + + react = 0; + attackindex = BATTLE_No2Index( battleindex, attackNo ); //index + defindex = BATTLE_No2Index( battleindex, defNo ); //طindex + if( (ReactType=BATTLE_GetDamageReact( defindex)) > 0 ) { //й⾵ + react = ReactType; +#ifdef _BATTLE_LIGHTTAKE + if( skill_type == BATTLE_COM_S_LIGHTTAKE ){ + int Statustype = -2; + if( strstr( pszP, "VANISH") != 0 ) Statustype = BATTLE_MD_VANISH; + else if( strstr( pszP, "ABSROB") != 0 ) Statustype = BATTLE_MD_ABSROB; + else if( strstr( pszP, "REFLEC") != 0 ) Statustype = BATTLE_MD_REFLEC; + if( ReactType == Statustype ){ + react=0; + }else{ + skill_type=-1; + } + }else{ + skill_type=-1; + } +#else + skill_type=-1; +#endif + } + + if( defNo >= SIDE_OFFSET ){ + i = defNo - SIDE_OFFSET; + DefSide = 1; + } + + //ȡù״̬ + iWork = BATTLE_AttackSeq( attackindex, defindex, &damage, &Guardian, skill_type ); + + switch( skill_type){ +#ifdef _PSKILL_MODIFY + case BATTLE_COM_S_MODIFYATT: + if( damage > 0 ){ + BATTLE_S_Modifyattack( battleindex, attackindex, defindex, &damage, skill); + } + break; +#endif +#ifdef _PETSKILL_TEAR + case BATTLE_COM_S_PETSKILLTEAR: +#ifdef _PREVENT_TEAMATTACK + if( BATTLE_CheckSameSide( attackindex, defNo) == 1 ){ + }else +#endif + if( iWork != BATTLE_RET_DODGE && react == 0 ){ + int userhp=0, petindex; + float def=0; + userhp = CHAR_getWorkInt( defindex, CHAR_WORKMAXHP) - CHAR_getInt( defindex, CHAR_HP); + if( CHAR_getInt( defindex, CHAR_WHICHTYPE) == CHAR_TYPEPLAYER && + (petindex = BATTLE_getRidePet( defindex )) != -1 ){ + userhp += CHAR_getWorkInt( petindex, CHAR_WORKMAXHP) - CHAR_getInt( petindex, CHAR_HP); + } + def = ((float)atoi( pszP))/100; + userhp = userhp * def; + if( userhp <= 0 ) damage = 0; + else damage += userhp; + } + break; +#endif + } + ultimate = BATTLE_DamageSub( attackindex, defindex, &damage, &petdamage, &react); + + if( react == BATTLE_MD_REFLEC ) defindex = attackindex; + +#ifdef _PROFESSION_SKILL // WON ADD ְҵ + if( react == BATTLE_MD_TRAP ) defindex = attackindex; +#endif + +#ifdef _PETSKILL_ACUPUNCTURE + if( react == BATTLE_MD_ACUPUNCTURE ) defindex = attackindex; +#endif + + if( damage > 0 && ( react != BATTLE_MD_ABSROB )&& ( react != BATTLE_MD_VANISH )){ + BATTLE_DamageWakeUp( battleindex, defindex ); + } + iRet = BATTLE_DefineAttack( attackindex, defindex, iWork, szBuffer, damage, react, &flg); + if( CHAR_getInt( defindex, CHAR_HP ) <= 0 ) + iRet = BATTLE_DefDieType( defindex, iRet, &ultimate, &flg, szBuffer); +#ifdef _PETSKILL_ANTINTER + //ǿƽij + if( CHAR_getWorkInt( attackindex, CHAR_WORKBATTLECOM1 ) == BATTLE_COM_S_ANTINTER + && CHAR_getInt( defindex, CHAR_WHICHTYPE ) == CHAR_TYPEPET ){ + ultimate = 2; + flg &= (!BCF_ULTIMATE_1); + flg |= BCF_DEATH; + flg |= BCF_ULTIMATE_2; + CHAR_setWorkInt( defindex, CHAR_WORKULTIMATE, 0 ); + damage=1;//ж damage<=0 skill_type=-1 damageΪ1 + } +#endif + + if( damage > 0 ){ +#ifdef _TAKE_ITEMDAMAGE + if( BATTLE_ItemCrushSeq( attackindex, defindex, damage) == TRUE ){ +#else + if( BATTLE_ItemCrushSeq( defindex ) == TRUE ){ +#endif + flg |= BCF_CRUSH; + } + } + + if( damage <= 0 ) { +#ifdef _SONIC_ATTACK // WON ADD + if( skill_type != BATTLE_COM_S_SONIC && skill_type != BATTLE_COM_S_SONIC2 +#ifdef _PETSKILL_REGRET + && skill_type != BATTLE_COM_S_REGRET && skill_type != BATTLE_COM_S_REGRET2 +#endif + ) +#endif + skill_type=-1; + } + + + + + memset( szCommand, 0, sizeof( szCommand)); + switch( skill_type) { + case -1: + snprintf( szCommand, sizeof( szCommand ), "BH|a%X|r%X|f%X|d%X|p%X|FF|", + attackNo, defNo, flg, damage, petdamage ); + BATTLESTR_ADD( szCommand ); + break; + +#ifdef _PETSKILL_TEAR + case BATTLE_COM_S_PETSKILLTEAR: + snprintf( szCommand, sizeof( szCommand ), "BH|a%X|r%X|f%X|d%X|p%X|FF|", + attackNo, defNo, flg, damage, petdamage ); + BATTLESTR_ADD( szCommand ); + break; +#endif + +#ifdef _SKILL_DAMAGETOHP + case BATTLE_COM_S_DAMAGETOHP: + otherdamage = BATTLE_S_DamageToHp( battleindex, attackindex, defindex,damage+petdamage, skill); + snprintf( szCommand, sizeof( szCommand ), "Bh|a%X|r%X|f%X|d%X|p%X|j%X|FF|", + attackNo, defNo, flg, damage, petdamage, otherdamage); + BATTLESTR_ADD( szCommand ); + break; +#endif + +#ifdef _PETSKILL_DAMAGETOHP + case BATTLE_COM_S_DAMAGETOHP2: + otherdamage = BATTLE_S_DamageToHp2( battleindex, attackindex, defindex,damage+petdamage, skill); + snprintf( szCommand, sizeof( szCommand ), "Bh|a%X|r%X|f%X|d%X|p%X|j%X|FF|", + attackNo, defNo, flg, damage, petdamage, otherdamage); + BATTLESTR_ADD( szCommand ); + break; +#endif + +#ifdef _Skill_MPDAMAGE + case BATTLE_COM_S_MPDAMAGE: + otherdamage = BATTLE_S_MpDamage( battleindex, attackindex, defindex, damage, skill); + snprintf( szCommand, sizeof( szCommand ), "Bp|a%X|r%X|f%X|d%X|p%X|j%X|FF|", + attackNo, defNo, flg, damage, petdamage, otherdamage); + BATTLESTR_ADD( szCommand ); + break; +#endif + +#ifdef _SKILL_TOOTH + case BATTLE_COM_S_TOOTHCRUSHE: //ܳ tooth + flg |= BCF_TOOTH; + BATTLE_S_ToothCrushe( battleindex, attackindex, defindex, damage, skill); + snprintf( szCommand, sizeof( szCommand ), "BH|a%X|r%X|f%X|d%X|p%X|FF|", + attackNo, defNo, flg, damage, petdamage ); + BATTLESTR_ADD( szCommand ); + break; +#endif + +#ifdef _PSKILL_MDFYATTACK + case BATTLE_COM_S_MDFYATTACK: + flg |= BCF_MODIFY; + snprintf( szCommand, sizeof( szCommand ), "BH|a%X|r%X|f%X|d%X|p%X|g%X|FF|", + attackNo, defNo, flg, damage, petdamage, skill); + BATTLESTR_ADD( szCommand ); + break; +#endif +#ifdef _PSKILL_MODIFY + case BATTLE_COM_S_MODIFYATT: + flg |= BCF_ATTDOUBLE; + snprintf( szCommand, sizeof( szCommand ), "BH|a%X|r%X|f%X|d%X|p%X|g%X|FF|", + attackNo, defNo, flg, damage, petdamage, skill); + BATTLESTR_ADD( szCommand ); + break; +#endif + +#ifdef _PETSKILL_TIMID + case BATTLE_COM_S_TIMID: + { + int timid = rand()%100; + snprintf( szCommand, sizeof( szCommand ), "BH|a%X|r%X|f%X|d%X|p%X|FF|", + attackNo, defNo, flg, damage, petdamage ); + BATTLESTR_ADD( szCommand ); + if( timid < 15 && damage > 1 ){//ս + BATTLE_NoAction( battleindex, defNo ); + sprintf( szCommand, "BE|e%X|", defNo ); + BATTLESTR_ADD( szCommand ); + snprintf( szCommand, sizeof( szCommand ), "f%X|", 1); + BATTLESTR_ADD( szCommand ); + + if( CHAR_getInt( defindex, CHAR_WHICHTYPE ) == CHAR_TYPEPET ){ + int defkoyaindex = CHAR_getWorkInt( defindex, CHAR_WORKPLAYERINDEX ); +#ifdef _PETS_SELECTCON + lssproto_PETS_send( getfdFromCharaIndex(defkoyaindex), + CHAR_getInt( defkoyaindex, CHAR_DEFAULTPET), FALSE); + CHAR_setWorkInt( defkoyaindex, + CHAR_WORK_PET0_STAT+CHAR_getInt( defkoyaindex, CHAR_DEFAULTPET), FALSE); +#endif + BATTLE_PetDefaultExit( defkoyaindex, battleindex ); + CHAR_setInt( defkoyaindex, CHAR_DEFAULTPET, -1 ); + + }else { + BATTLE_Exit( defindex, battleindex); + CHAR_DischargePartyNoMsg( defindex);//ɢŶ + } + } + } + break; +#endif +#ifdef _PETSKILL_2TIMID + case BATTLE_COM_S_2TIMID: + { + int timid=0; + char *timidc=NULL; + pszP = PETSKILL_getChar( skill, PETSKILL_OPTION ); + if( ( timidc = strstr( pszP, "%" ) ) != NULL ) + sscanf( timidc+3,"%d", &timid ); + snprintf( szCommand, sizeof( szCommand ), "BH|a%X|r%X|f%X|d%X|p%X|FF|", + attackNo, defNo, flg, damage, petdamage ); + BATTLESTR_ADD( szCommand ); + if( rand()%100 < timid && damage > 1 ){ + if( CHAR_getInt( defindex, CHAR_WHICHTYPE ) == CHAR_TYPEPET ){ + int defkoyaindex = CHAR_getWorkInt( defindex, CHAR_WORKPLAYERINDEX ); + + snprintf( szCommand, sizeof( szCommand ), "K%d", CHAR_getInt( defkoyaindex, CHAR_DEFAULTPET ) ); + CHAR_sendStatusString( defkoyaindex, szCommand ); + + BATTLE_PetIn( battleindex, defNo-5 ); + lssproto_KS_send( getfdFromCharaIndex( defkoyaindex ), CHAR_getInt( defkoyaindex, CHAR_DEFAULTPET ), 1 ); + + /*BATTLE_NoAction( battleindex, defNo ); + sprintf( szCommand, "BE|e%X|", defNo ); + BATTLESTR_ADD( szCommand ); + snprintf( szCommand, sizeof( szCommand ), "f%X|", 1); + BATTLESTR_ADD( szCommand ); + + BATTLE_PetDefaultExit( defkoyaindex, battleindex ); + CHAR_setInt( defkoyaindex, CHAR_DEFAULTPET, -1 ); + + print("\ndefNo:%d",defNo);*/ + } + } + } + break; +#endif + +#ifdef _PETSKILL_ANTINTER + case BATTLE_COM_S_ANTINTER: + { + pszP = PETSKILL_getChar( skill, PETSKILL_OPTION ); + //flg &= !(BCF_ULTIMATE_1 | BCF_ULTIMATE_2); + snprintf( szCommand, sizeof( szCommand ), "BH|a%X|r%X|f%X|d%X|p%X|FF|", + attackNo, defNo, flg |= BCF_ANTINTER , 0, 0 ); + BATTLESTR_ADD( szCommand ); + if( CHAR_getInt( defindex, CHAR_WHICHTYPE ) == CHAR_TYPEPET ){ + int defkoyaindex = CHAR_getWorkInt( defindex, CHAR_WORKPLAYERINDEX ); + BATTLE_PetDefaultExit( defkoyaindex, battleindex );//뿪ս + CHAR_setInt( defkoyaindex, CHAR_DEFAULTPET, -1 );//趨޲ս + } + } + break; +#endif + +#ifdef _BATTLE_LIGHTTAKE + case BATTLE_COM_S_LIGHTTAKE: + { + int Typenum = 0; + if( strstr( pszP, "VANISH") != 0 ){ + if( ReactType == BATTLE_MD_VANISH ){ + Typenum = CHAR_getWorkInt( defindex, CHAR_WORKDAMAGEVANISH ); + CHAR_setWorkInt( attackindex, CHAR_WORKDAMAGEVANISH, Typenum); + } + }else if( strstr( pszP, "ABSROB") != 0 ){ + if( ReactType == BATTLE_MD_ABSROB ){ + Typenum = CHAR_getWorkInt( defindex, CHAR_WORKDAMAGEABSROB ); + CHAR_setWorkInt( attackindex, CHAR_WORKDAMAGEABSROB, Typenum); + } + }else if( strstr( pszP, "REFLEC") != 0 ){ + if( ReactType == BATTLE_MD_REFLEC ){ + Typenum = CHAR_getWorkInt( defindex, CHAR_WORKDAMAGEREFLEC ); + CHAR_setWorkInt( attackindex, CHAR_WORKDAMAGEREFLEC, Typenum); + } + } + snprintf( szCommand, sizeof( szCommand ), "BH|a%X|r%X|f%X|d%X|p%X|FF|", + attackNo, defNo, flg, damage, petdamage ); + BATTLESTR_ADD( szCommand ); + } + break; +#endif + +#ifdef _SONIC_ATTACK // WON ADD + // ˺ + case BATTLE_COM_S_SONIC: + { + int img2=0; + if( defNo >= 10 ) img2 = 101703; + else img2 = 101704; + + flg |= BCF_B_SKILLACT; //ͼ + + snprintf( szCommand, sizeof( szCommand ), "B+|a%X|r%X|f%X|d%X|e%X|s%X|h%X|FF|", + attackNo, defNo, flg, damage, 0, 0, img2 ); + BATTLESTR_ADD( szCommand ); + + break; + } + // ˺ + case BATTLE_COM_S_SONIC2: + { + sprintf( szCommand, "BD|r%X|0|0|d%X|p%X|", defNo, damage, petdamage ); + BATTLESTR_ADD( szCommand ); + + break; + } +#endif +#ifdef _PETSKILL_REGRET + // ˺ + case BATTLE_COM_S_REGRET: + { + int img2=0,Success=0; + char *psz = NULL; + if( (psz = strstr( pszP, "%" ) ) != NULL ) sscanf( psz+3, "%d", &Success ); + if( (PROFESSION_BATTLE_StatusAttackCheck( attackindex, defindex, 12, Success ) == 0 ) + || (CHAR_getInt( defindex, CHAR_HP ) <= 0 ) ){ + + }else{ + CHAR_setWorkInt( defindex, StatusTbl[12], 2 );//ѣ1غ + CHAR_setWorkInt( defindex, CHAR_WORKBATTLECOM1, BATTLE_COM_NONE ); + BATTLE_BadStatusString( defNo, 12 ); + } + + if( defNo >= 10 ) img2 = 101418;//101703; + else img2 = 101418;//101704; + + flg |= BCF_B_SKILLACT; //ͼ + snprintf( szCommand, sizeof( szCommand ), "B+|a%X|r%X|f%X|d%X|e%X|s%X|h%X|FF|", + attackNo, defNo, flg, damage, 0, 0, img2 ); + BATTLESTR_ADD( szCommand ); + break; + } + // ˺ + case BATTLE_COM_S_REGRET2: + { + int Success; + char *psz = NULL; + if( (psz = strstr( pszP, "%" ) ) != NULL ) sscanf( psz+3, "%d", &Success ); + if( (PROFESSION_BATTLE_StatusAttackCheck( attackindex, defindex, 12, Success ) == 0 ) + || (CHAR_getInt( defindex, CHAR_HP ) <= 0 ) ){ + + }else{ + CHAR_setWorkInt( defindex, StatusTbl[12], 2 );//ѣ1غ + CHAR_setWorkInt( defindex, CHAR_WORKBATTLECOM1, BATTLE_COM_NONE ); + BATTLE_BadStatusString( defNo, 12 ); + } + + sprintf( szCommand, "BD|r%X|0|0|d%X|p%X|", defNo, damage, petdamage ); + BATTLESTR_ADD( szCommand ); + break; + } +#endif + + default: + snprintf( szCommand, sizeof( szCommand ), "BH|a%X|r%X|f%X|d%X|p%X|FF|", + attackNo, defNo, flg, damage, petdamage ); + BATTLESTR_ADD( szCommand ); + break; + } + //BATTLE_BroadCast( battleindex, szBuffer, + // (attackNo >= 10)? CHAR_COLORGRAY : CHAR_COLORPURPLE ) ; + + i = defNo-DefSide*SIDE_OFFSET; + if( ultimate > 0 ){ + BattleArray[battleindex].Side[DefSide].Entry[i].flg |= BENT_FLG_ULTIMATE; + } + return iRet; +} + +#ifdef _MAGIC_SUPERWALL +int PETSKILL_MagicStatusChange_Battle( int battleindex, int attackNo, int toNo, int marray) +{ + char *magicarg; + int status = -1, i, turn = 3, nums=0; + int ReceveEffect, charaindex=-1; + char buf1[256]; + charaindex = BATTLE_No2Index( battleindex, attackNo ); //index + if( !CHAR_CHECKINDEX( charaindex)) return FALSE; + magicarg = PETSKILL_getChar( marray, PETSKILL_OPTION ); + if( getStringFromIndexWithDelim( magicarg,"|",1, buf1, sizeof( buf1)) == FALSE ) + return FALSE; + for( i=0; i= 20 ) + return FALSE; + } + battleindex = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEINDEX ); + //attackNo = BATTLE_Index2No( battleindex, charaindex ); +/* //ͼž + if( status == BATTLE_ST_NONE ){ + ReceveEffect = SPR_tyusya; + }else{ + ReceveEffect = SPR_hoshi; + } +*/ + ReceveEffect = SPR_hoshi; + BATTLE_MultiMagicStatusChange( + battleindex, attackNo, toNo, status, + turn, MAGIC_EFFECT_USER, ReceveEffect, nums ); + + return TRUE; +} +#endif + +#ifdef _PETSKILL_SETDUCK +int PETSKILL_SetDuckChange_Battle( int battleindex, int attackNo, int toNo, int marray) +{ + char *skillarg=NULL; + int turn = 3, nums=0; + int charaindex=-1; + char buf1[256]; + + charaindex = BATTLE_No2Index( battleindex, attackNo ); //index + if( !CHAR_CHECKINDEX( charaindex)) return FALSE; + if( BATTLE_No2Index( battleindex, toNo ) != charaindex ) return FALSE; + + skillarg = PETSKILL_getChar( marray, PETSKILL_OPTION ); + if( skillarg == "\0" ) return FALSE; + if( getStringFromIndexWithDelim( skillarg,"|",1, buf1, sizeof( buf1)) == FALSE ) + return FALSE; + turn = atoi( buf1); + if( getStringFromIndexWithDelim( skillarg,"|",2, buf1, sizeof( buf1)) == FALSE ) + return FALSE; + nums = atoi( buf1); + + battleindex = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEINDEX ); + { + int ToList[SIDE_OFFSET*2+1]; + char szBuffer[256]=""; + memset( szBuffer, 0, sizeof( szBuffer)); + memset( ToList, -1, sizeof( ToList)); + BATTLE_MultiList( battleindex, toNo, ToList ); + BATTLE_MagicEffect( battleindex, attackNo, ToList, MAGIC_EFFECT_USER, SPR_hoshi ); + if( CHAR_getWorkInt( charaindex, CHAR_MYSKILLDUCK) > 0){ + }else { + CHAR_setWorkInt( charaindex, CHAR_MYSKILLDUCK, turn); + CHAR_setWorkInt( charaindex, CHAR_MYSKILLDUCKPOWER, nums ); + sprintf( szBuffer, "BD|r%X|0|3|%X|", toNo, nums); + BATTLESTR_ADD( szBuffer ); + } + } + return TRUE; +} +#endif + +#ifdef _MAGICPET_SKILL +int PETSKILL_SetMagicPet_Battle( int battleindex, int attackNo, int toNo, int marray) +{ + char *skillarg=NULL; + int turn = 3, nums=0; + int charaindex=-1; + char buf1[256]; + + charaindex = BATTLE_No2Index( battleindex, attackNo ); //index + if( !CHAR_CHECKINDEX( charaindex)) return FALSE; + if( BATTLE_CHECKINDEX( battleindex ) == FALSE ) return FALSE; + + skillarg = PETSKILL_getChar( marray, PETSKILL_OPTION ); + if( skillarg == "\0" ) return FALSE; + if( getStringFromIndexWithDelim( skillarg,"|",1, buf1, sizeof( buf1)) == FALSE ) + return FALSE; + turn = atoi( buf1); + if( getStringFromIndexWithDelim( skillarg,"|",2, buf1, sizeof( buf1)) == FALSE ) + return FALSE; + nums = atoi( buf1); + if( getStringFromIndexWithDelim( skillarg,"|",3, buf1, sizeof( buf1)) == FALSE ) + return FALSE; + if( strstr( buf1, "HP") != 0 ) { + BATTLE_MultiRecovery( battleindex, attackNo, toNo, + BD_KIND_HP, nums, 0, MAGIC_EFFECT_USER, SPR_heal3 ); + }else{ + int ToList[SIDE_OFFSET*2+1]; + char szBuffer[256]=""; + int todef=0, i; + + memset( szBuffer, 0, sizeof( szBuffer)); + memset( ToList, -1, sizeof( ToList)); + BATTLE_MultiList( battleindex, toNo, ToList ); + BATTLE_MagicEffect( battleindex, attackNo, ToList, MAGIC_EFFECT_USER, SPR_hoshi ); + + for( i = 0; ToList[i] != -1; i ++ ){ + int bid; + int toindex = BATTLE_No2Index( battleindex, ToList[i] ); + if( !CHAR_CHECKINDEX( toindex ))continue; + + if( CHAR_getWorkInt( toindex, CHAR_MYSKILLDUCK) > 0 || + CHAR_getWorkInt( toindex, CHAR_MYSKILLSTR) > 0 || + CHAR_getWorkInt( toindex, CHAR_MYSKILLTGH) > 0 || + CHAR_getWorkInt( toindex, CHAR_MYSKILLDEX) > 0 ) continue; + + if( strstr( buf1, "STR") != 0 ) { + CHAR_setWorkInt( toindex, CHAR_MYSKILLSTR, turn); + CHAR_setWorkInt( toindex, CHAR_MYSKILLSTRPOWER, nums ); + todef = 4; + }else if( strstr( buf1, "TGH") != 0 ){ + CHAR_setWorkInt( toindex, CHAR_MYSKILLTGH, turn); + CHAR_setWorkInt( toindex, CHAR_MYSKILLTGHPOWER, nums ); + todef = 5; + }else if( strstr( buf1, "DEX") != 0 ){ + CHAR_setWorkInt( toindex, CHAR_MYSKILLDEX, turn); + CHAR_setWorkInt( toindex, CHAR_MYSKILLDEXPOWER, nums ); + todef = 6; + } + bid = BATTLE_Index2No( battleindex, toindex ); + sprintf( szBuffer, "BD|r%X|0|%d|%X|", bid, todef, nums); + BATTLESTR_ADD( szBuffer ); + } + } + return TRUE; +} +#endif + +#ifdef _SKILL_WEAKEN //vincent輼: +int BATTLE_S_Weaken( + int battleindex, + int attackNo, + int defNo, + int marray +) +{ + BOOL iRet = FALSE; + char *magicarg; + int status = -1, i, turn = 3; + int ReceveEffect, Success = 0; + char *pszP; + char szTurn[] = "turn"; + char szSuccess[] = ""; + magicarg = PETSKILL_getChar( marray, PETSKILL_OPTION ); + if( magicarg == "\0" ) { + //print("\n magicarg == NULL "); + return FALSE; + } + pszP = magicarg; + + for( ;status == -1 && pszP[0] != 0; pszP++ ){ + for( i = 1; i < BATTLE_ST_END; i ++ ){ + if( strncmp( pszP, aszStatus[i], 2 ) == 0 ){ + status = i; + pszP +=2; + break; + } + } + } + + if( status == -1 ) return FALSE; + + if( ( pszP = strstr( pszP, szTurn ) ) != NULL){ + pszP += sizeof( szTurn ); + sscanf( pszP, "%d", &turn ); + } + + if( ( pszP = strstr( pszP, szSuccess ) ) != NULL){ + pszP += sizeof( szSuccess ); + sscanf( pszP, "%d", &Success ); + } + + if( status == BATTLE_ST_NONE ){ + ReceveEffect = SPR_tyusya; + }else{ + ReceveEffect = SPR_hoshi; + } + BATTLE_MultiParamChangeTurn( battleindex, attackNo, defNo, status, + MAGIC_EFFECT_USER, ReceveEffect, turn, Success); + + return iRet; +} +#endif + +#ifdef _PETSKILL_TEMPTATION +BOOL BATTLE_S_Temptation( int battleindex,int attackNo,int defNo, int skill ) +{ + BOOL iRet = FALSE; + char *magicarg; + char szWork[256]; + int attackindex,defindex,defside,flg=0,img2,img1; + int target; + + magicarg = PETSKILL_getChar( skill , PETSKILL_OPTION ); + if( magicarg == "\0" ) { + //print("\n magicarg == NULL "); + return iRet; + } + attackindex = BATTLE_No2Index( battleindex, attackNo ); + defindex = BATTLE_No2Index( battleindex, defNo ); + if( CHAR_CHECKINDEX( attackindex ) == FALSE )return iRet; + if( CHAR_CHECKINDEX( defindex ) == FALSE )return iRet; + if( CHAR_getInt( defindex, CHAR_WHICHTYPE) != CHAR_TYPEPET ) return iRet; + if( CHAR_getWorkInt( defindex , CHAR_WORKFIXAI ) <= atoi(magicarg)){ + //ܹ + CHAR_setWorkInt( defindex, CHAR_WORKTEMPTATION , 1 ); //Լ1Ѫ + defside = CHAR_getWorkInt( defindex, CHAR_WORKBATTLESIDE); + target = CHAR_getWorkInt( defindex, CHAR_WORKBATTLECOM2 ); + + if( CHAR_getWorkInt( defindex, CHAR_WORKBATTLECOM1 ) == BATTLE_COM_ATTACK ){ + CHAR_setWorkInt( defindex , CHAR_WORKBATTLECOM2, + BATTLE_DefaultAttacker(battleindex,defside)); + }else{ + CHAR_setWorkInt( defindex , CHAR_WORKBATTLECOM2, + BATTLE_DefaultAttacker(battleindex,defside)); + } + img1 = 101505; //鶯101637; //׼ڶ + img2 = 101502; //鶯101645; //ᶯ + flg |= BCF_NO_DAMAGE; + flg |= BCF_B_SKILLACT; //ͼ + snprintf( szWork, sizeof( szWork ), "B+|a%X|r%X|f%X|d%X|p%X|e%X|s%X|h%X|FF|", + attackNo, defNo, flg, 0, 0, 1 , img1 , img2 ); + BATTLESTR_ADD( szWork ); + iRet = TRUE; + } + return iRet; + +} +#endif + +#ifdef _SKILL_DEEPPOISON //vincent輼:綾 +int BATTLE_S_Deeppoison( int battleindex, int attackNo, int defNo, int marray ) +{ + BOOL iRet = FALSE; + char *magicarg; + int status = -1, i, turn = 3; + int ReceveEffect, Success = 0; + char *pszP; + char szTurn[] = "turn"; + char szSuccess[] = ""; + magicarg = PETSKILL_getChar( marray, PETSKILL_OPTION ); + if( magicarg == "\0" ) { + //print("\n magicarg == NULL "); + return FALSE; + } + pszP = magicarg; + + for( ;status == -1 && pszP[0] != 0; pszP++ ){ + for( i = 1; i < BATTLE_ST_END; i ++ ){ + if( strncmp( pszP, aszStatus[i], 2 ) == 0 ){ + status = i; + pszP +=2; + break; + } + } + } + + if( status == -1 ) return FALSE; + + if( ( pszP = strstr( pszP, szTurn ) ) != NULL){ + pszP += sizeof( szTurn ); + sscanf( pszP, "%d", &turn ); + } + + if( ( pszP = strstr( pszP, szSuccess ) ) != NULL){ + pszP += sizeof( szSuccess ); + sscanf( pszP, "%d", &Success ); + } + + if( status == BATTLE_ST_NONE ){ + ReceveEffect = SPR_tyusya; + }else{ + ReceveEffect = SPR_hoshi; + } + + BATTLE_MultiStatusChange( battleindex, attackNo, defNo, + status, turn+2, MAGIC_EFFECT_USER, ReceveEffect, Success ); + + return iRet; +} +#endif + +#ifdef _SKILL_BARRIER //vincent輼:ħ +int BATTLE_S_Barrier( + int battleindex, + int attackNo, + int defNo , + int marray +) +{ + BOOL iRet = FALSE; + int battlemode; + int i,turn,perStatus,charaindex,toindex; + int ToList[SIDE_OFFSET*2+1]; + char *magicarg; + int Success = 0; + char szTurn[] = "turn"; + char szSuccess[] = ""; + char *pszP; + charaindex = BATTLE_No2Index( battleindex, attackNo ); //index + //check index + if( CHAR_CHECKINDEX( charaindex ) == FALSE )return FALSE; + + battlemode = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE ); + + if( battlemode == BATTLE_CHARMODE_INIT ){ + return FALSE; + } + + magicarg = PETSKILL_getChar( marray, PETSKILL_OPTION ); + if( magicarg == "\0" ) { + //print("\n magicarg == NULL "); + return FALSE; + } + + pszP = magicarg; + + //ȡûغ + if( ( pszP = strstr( pszP, szTurn ) ) != NULL){ + pszP += sizeof( szTurn ); + sscanf( pszP, "%d", &turn ); + } + // + if( ( pszP = strstr( pszP, szSuccess ) ) != NULL){ + pszP += sizeof( szSuccess ); + sscanf( pszP, "%d", &Success ); + } + + BATTLE_MultiList( battleindex, defNo, ToList ); + + //ʩħЧ + BATTLE_MagicEffect(battleindex, attackNo, ToList, MAGIC_EFFECT_USER, SPR_hoshi); + + //checkǷս + if( IsBATTLING( charaindex ) == TRUE ) + { + + for( i = 0; ToList[i] != -1; i ++ ) + { + toindex = BATTLE_No2Index( battleindex, ToList[i] ); + if( BATTLE_StatusAttackCheck( charaindex,toindex, BATTLE_ST_BARRIER, Success, 30, 1.0, &perStatus ) == TRUE ) + { + CHAR_setWorkInt( toindex, CHAR_WORKBARRIER, turn+1); + } + } + + } + return iRet; +} +#endif + +#ifdef _SKILL_NOCAST //vincent輼:Ĭ +int BATTLE_S_Nocast( + int battleindex, + int attackNo, + int defNo , + int marray +) +{ + BOOL iRet = FALSE; + int battlemode; + int i,turn,perStatus,charaindex,toindex; + int ToList[SIDE_OFFSET*2+1]; + char *magicarg; + int Success = 0; + char szTurn[] = "turn"; + char szSuccess[] = ""; + char *pszP; + charaindex = BATTLE_No2Index( battleindex, attackNo ); //index + //check index + if( CHAR_CHECKINDEX( charaindex ) == FALSE )return FALSE; + + battlemode = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE ); + + if( battlemode == BATTLE_CHARMODE_INIT ){ + return FALSE; + } + + magicarg = PETSKILL_getChar( marray, PETSKILL_OPTION ); + if( magicarg == "\0" ) { + //print("\n magicarg == NULL "); + return FALSE; + } + + pszP = magicarg; + + //ȡûغ + if( ( pszP = strstr( pszP, szTurn ) ) != NULL){ + pszP += sizeof( szTurn ); + sscanf( pszP, "%d", &turn ); + } + // + if( ( pszP = strstr( pszP, szSuccess ) ) != NULL){ + pszP += sizeof( szSuccess ); + sscanf( pszP, "%d", &Success ); + } + + BATTLE_MultiList( battleindex, defNo, ToList ); + + //ʩħЧ + BATTLE_MagicEffect(battleindex, attackNo, ToList, MAGIC_EFFECT_USER, SPR_hoshi); + + //checkǷս + if( IsBATTLING( charaindex ) == TRUE ){ + + for( i = 0; ToList[i] != -1; i ++ ){ + toindex = BATTLE_No2Index( battleindex, ToList[i] ); + if( BATTLE_StatusAttackCheck( charaindex,toindex, BATTLE_ST_NOCAST, Success, 30, 1.0, &perStatus ) == TRUE + && CHAR_getInt( toindex, CHAR_WHICHTYPE) != CHAR_TYPEPET){ + //޷չҳ + lssproto_NC_send( getfdFromCharaIndex( toindex ), 1); + CHAR_setWorkInt( toindex, CHAR_WORKNOCAST, turn ); + BATTLE_BadStatusString( ToList[i], BATTLE_ST_NOCAST ); + } + } + + } + return iRet; +} +#endif + +int BATTLE_getReactFlg( int index, int react) +{ + int flg=0; + if( react == BATTLE_MD_ABSROB )flg |= BCF_ABSORB; + if( react == BATTLE_MD_REFLEC )flg |= BCF_REFRECT; + if( react == BATTLE_MD_VANISH )flg |= BCF_VANISH; +#ifdef _MAGIC_SUPERWALL + if( CHAR_getWorkInt( index, CHAR_MAGICSUPERWALL ) > 0 ){ + flg |= BCF_SUPERWALL; + } +#endif +#ifdef _PROFESSION_SKILL // WON ADD ְҵ + if( react == BATTLE_MD_TRAP ) flg |= BCF_TRAP; +#endif +#ifdef _PETSKILL_ACUPUNCTURE + if( react == BATTLE_MD_ACUPUNCTURE ) flg |= BCF_ACUPUNCTURE; +#endif + return flg; +} + +#ifdef _PREVENT_TEAMATTACK +int BATTLE_CheckSameSide( int charaindex, int toNo) +{ + int ToList[SIDE_OFFSET*2+1]; + int toindex, i, battleindex; + int MySide; + battleindex = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEINDEX ); + MySide = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLESIDE); + +//toindex = BATTLE_No2Index( battleindex, ToList[i] ); + if( toNo < 20 ){//һĿ + toindex = BATTLE_No2Index( battleindex, toNo); + if( CHAR_getWorkInt( toindex, CHAR_WORKBATTLESIDE) == MySide ) return 1;//ͬ + }else if( toNo){ + + BATTLE_MultiList( battleindex, toNo, ToList ); + for( i = 0; ToList[i] != -1; i ++ ){ + toindex = BATTLE_No2Index( battleindex, ToList[i] ); + if( !CHAR_CHECKINDEX( toindex) ) continue; + + if( CHAR_getWorkInt( toindex, CHAR_WORKBATTLESIDE) == MySide ) return 1;//ͬ + } + } + return 0; +} +#endif + + +#ifdef _USER_CHARLOOPS +int CHAR_BattleStayLoop( int charaindex) +{ +#ifdef _OFFLINE_SYSTEM + if(CHAR_getWorkInt( charaindex, CHAR_WORK_OFFLINE ) == 1){ + if( CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE ) == BATTLE_CHARMODE_NONE){ + CHAR_setWorkChar( charaindex, CHAR_WORKWALKARRAY,""); + CHAR_setInt( charaindex, CHAR_LOOPINTERVAL, getOfflineBattleTime()); + BATTLE_CreateVsEnemy( charaindex,0, -1); + } + return 1; + } +#endif + int fd = getfdFromCharaIndex( charaindex); + if( getStayEncount( fd) ) { + if( CONNECT_getBDTime( fd) < time( NULL) ) { + if( CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE ) == BATTLE_CHARMODE_NONE){ + if(getNoStayBattle()==1){ + CHAR_talkToCli(charaindex, -1, "Ϊҵ·ԭ쳣뵽·ԡ", CHAR_COLORYELLOW); + } + lssproto_EN_recv( fd, CHAR_getInt( charaindex,CHAR_X), CHAR_getInt( charaindex,CHAR_Y)); + CONNECT_setBDTime( fd, (int)time( NULL)); + } + } + }else{ + Char *ch; + ch = CHAR_getCharPointer( charaindex); + if( ch == NULL ) return 0; + strcpysafe( ch->charfunctable[CHAR_LOOPFUNCTEMP1].string, + sizeof( ch->charfunctable[CHAR_LOOPFUNCTEMP1]), "");//ս + CHAR_setInt( charaindex, CHAR_LOOPINTERVAL, 0); + CHAR_constructFunctable( charaindex); + } + + return 1; +} +#endif + +#ifdef _PETSKILL_PROPERTY +int PET_PetskillPropertyEvent( int Myindex, int defindex, int *damage, int *T_Pow, int size) +{ + int My_Pow[5]={0,0,0,0,0}; + int i, totals=100; + if( !CHAR_CHECKINDEX( Myindex)) return 0; + if( !CHAR_CHECKINDEX( defindex)) return 0; + BATTLE_GetAttr( defindex, My_Pow); + + //ת + for( i=0; i<4; i++) { + int nums = (i+3)%4; + if( My_Pow[i] != 0 ){ + T_Pow[ nums] = My_Pow[i]; + totals -= My_Pow[i]; + }else{ + T_Pow[ nums] = 0; + } + } + T_Pow[ 4] = totals; + return 1; +} +#endif + + + +#ifdef _PROFESSION_SKILL // WON ADD ְҵ + +// ֱӹʽ +int battle_profession_attack_fun(int battleindex, int attackNo, int defNo, int charaindex) +{ + char szBuffer[512]=""; + char szCommand[1024]; + int attackindex, defindex=-1; + int damage=0, petdamage=0, i=0, iWork, Guardian=-1,react; + int flg = 0, DefSide=0,ultimate=0; + BOOL iRet = FALSE; + int ReactType=0, skill_type=-1, skill=-1; + char *pszP = NULL; + char *pszOption = NULL; + int effect=0, img1=0, img2=0, atk_num=0, skill_level; + + skill = CHAR_GETWORKINT_LOW( charaindex, CHAR_WORKBATTLECOM3); + skill_type=CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM1 ); + + //index + attackindex = BATTLE_No2Index( battleindex, attackNo ); + if( CHAR_CHECKINDEX( attackindex ) == FALSE ) return iRet; + + //طindex + defindex = BATTLE_No2Index( battleindex, defNo ); + if( CHAR_CHECKINDEX( defindex ) == FALSE ){ + return iRet; + } + + // Ӷ + if( (CHAR_getInt( defindex, CHAR_HP ) <= 0) && (skill_type != BATTLE_COM_S_PLUNDER) ){ + return iRet; + } + + // սʹü + if( !PROFESSION_SKILL_getInt( skill, PROFESSION_SKILL_USE_FLAG) ) return iRet; + + // ȡüܲ + pszOption = PROFESSION_SKILL_getChar( skill, PROFESSION_SKILL_OPTION); + if( pszOption == "\0" ) return iRet; + + // ܵȼ + skill_level = CHAR_GETWORKINT_HIGH( charaindex, CHAR_WORKBATTLECOM3); + skill_level = PROFESSION_CHANGE_SKILL_LEVEL_A( skill_level ); + + // ʽ 0ԭ㶯 1ƶ㶯 + if( (pszP = strstr( pszOption, "Ч%" ) ) != NULL ) sscanf( pszP+3, "%d", &effect ); + + // ׼ڵĶ + img1 = PROFESSION_SKILL_getInt( skill, PROFESSION_SKILL_IMG_1 ); + + // Ķ + img2 = PROFESSION_SKILL_getInt( skill, PROFESSION_SKILL_IMG_2 ); + + // Ŀһܣ + if( defNo >= 0 && defNo <= 19 ){ + if( CHAR_getWorkInt( defindex, CHAR_WORKBATTLECOM1 ) == BATTLE_COM_S_EARTHROUND0 ){ + return iRet; + } + } + + // ȡܲ + switch( skill_type){ + case BATTLE_COM_S_BRUST: // + { + int str=0, old_str=0; + + // ӹ + old_str = CHAR_getWorkInt( charaindex, CHAR_WORKFIXSTR); + str = old_str * ( skill_level * 3 + 100 ) / 100; + + CHAR_setWorkInt( charaindex, CHAR_WORKFIXSTR, str ); + + break; + } + case BATTLE_COM_S_CHAOS: // ҹ + { + int atk = 0; + // 30% + atk = CHAR_getWorkInt( charaindex, CHAR_WORKATTACKPOWER ); + atk = atk * 70 / 100; + CHAR_setWorkInt(charaindex,CHAR_WORKATTACKPOWER, atk ); + + if( skill_level >= 10 ) atk_num = 5; + else if( skill_level >= 5 ) atk_num = 4; + else atk_num = 3; + + break; + } + case BATTLE_COM_S_CHAIN_ATK: // + { + int rand_num = RAND(1, 100); + int hit; + + if( skill_level % 10 != 0 ) + skill_level += 1; + hit = skill_level * 5 + 15; + + if( rand_num <= hit ) + atk_num=2; // + else + atk_num=0; + + break; + } + case BATTLE_COM_S_ENRAGE_PET: // ŭ + { + // жǷͬ + if( BATTLE_CheckSameSide( charaindex, defNo) != 1 ) return iRet; + + defNo = attackNo; + + // 1 + CHAR_setWorkInt(charaindex,CHAR_WORKATTACKPOWER, 0 ); + + break; + } + case BATTLE_COM_S_CHAIN_ATK_2: // ˫ع + { + int atkpower = 0; + int absrob_num = CHAR_getWorkInt( defindex, CHAR_WORKDAMAGEABSROB ); // + //int reflec_num = CHAR_getWorkInt( defindex, CHAR_WORKDAMAGEREFLEC ); // + int evanish_num = CHAR_getWorkInt( defindex, CHAR_WORKDAMAGEVANISH ); // + int trap_num = CHAR_getWorkInt( defindex, CHAR_WORKTRAP ); // + + if( absrob_num > 0 ) CHAR_setWorkInt( defindex, CHAR_WORKDAMAGEABSROB, max(absrob_num - 1, 0) ); + //if( reflec_num > 0 ) CHAR_setWorkInt( defindex, CHAR_WORKDAMAGEREFLEC, max(reflec_num - 1, 0) );//þЧ,Ҫõ + if( evanish_num > 0 ) CHAR_setWorkInt( defindex, CHAR_WORKDAMAGEVANISH, max(evanish_num - 1, 0) ); + if( trap_num > 0 ) CHAR_setWorkInt( defindex, CHAR_WORKTRAP, 0 ); + + // һ¹ 0 + CHAR_setWorkInt(charaindex,CHAR_WORKATTACKPOWER, 0 ); + + snprintf( szCommand, sizeof( szCommand ), "B+|a%X|r%X|f%X|d%X|p%X|e%X|s%X|h%X|", + attackNo, defNo, BCF_NO_DAMAGE, 0, 0, effect, img1, img2 ); + BATTLESTR_ADD( szCommand ); + + // ӹ + atkpower =(int)( CHAR_getWorkInt(charaindex,CHAR_WORKFIXSTR) * (skill_level * 2 + 100) /100 ); + + CHAR_setWorkInt(charaindex,CHAR_WORKATTACKPOWER, atkpower ); + + if( (CHAR_getInt( charaindex, CHAR_HP ) > 0 ) && + (CHAR_getInt( defindex, CHAR_HP ) > 0 ) ){ + BATTLE_Attack( battleindex, attackNo, defNo ); + } + + snprintf( szCommand, sizeof( szCommand ), "FF|"); + BATTLESTR_ADD( szCommand ); + + return iRet; + } + case BATTLE_COM_S_DEAD_ATTACK: // + { + int hit=0, hp=0, old_hp=0, rate=0; + + rate = skill_level * 2 + 10 ; + old_hp = CHAR_getInt(charaindex, CHAR_HP); + hp = old_hp * rate / 100; + + if( old_hp <= 10 ){ + CHAR_talkToCli( charaindex, -1, "HP㣬޷ʹü", CHAR_COLORYELLOW); + return iRet; + } + + hit = skill_level * 2 + 80; + + CHAR_setWorkInt(charaindex,CHAR_WORKHITRIGHT, CHAR_getWorkInt(charaindex,CHAR_WORKHITRIGHT) + hit ); + CHAR_setWorkInt( charaindex, CHAR_MYSKILLHIT, 1); + CHAR_setWorkInt( charaindex, CHAR_MYSKILLHIT_NUM, hit); + CHAR_talkToCli( charaindex, -1, "", CHAR_COLORYELLOW); + + sprintf( szCommand, "BD|r%X|0|1|%X|", attackNo, (-1) * (old_hp - hp) ); + BATTLESTR_ADD( szCommand ); + + CHAR_setInt(charaindex, CHAR_HP, hp); + break; + } + case BATTLE_COM_S_ATTACK_WEAK: // 㹥 + { + float str=0.0, dex=0.0; + int whichtype; + + whichtype = CHAR_getInt( defindex, CHAR_WHICHTYPE); + + // ĿΪʱ + if( (whichtype == CHAR_TYPEPET) || (whichtype == CHAR_TYPEENEMY) ){ + str = skill_level * 2 +10 + 100; + CHAR_setWorkInt(charaindex,CHAR_WORKATTACKPOWER, CHAR_getWorkInt(charaindex,CHAR_WORKATTACKPOWER) * (str/100) ); + } + + // + dex = 100 - ( skill_level + 10 ); + CHAR_setWorkInt(charaindex,CHAR_WORKQUICK, CHAR_getWorkInt(charaindex,CHAR_WORKFIXDEX) * (dex/100) ); + sprintf( szCommand, "BD|r%X|0|6|%X|", attackNo, (-1) * (skill_level + 10) ); + BATTLESTR_ADD( szCommand ); + + break; + } + case BATTLE_COM_S_PLUNDER: // Ӷ + { + char pBidList[BATTLE_ENTRY_MAX*2+1]; + int item, start = 0; + memset( pBidList, -1, sizeof(pBidList) ); + pBidList[0] = defNo; + + // ӶĿ + defNo = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM2 ); + defindex = BATTLE_No2Index( battleindex, defNo ); + if( CHAR_getInt( defindex, CHAR_WHICHTYPE) != CHAR_TYPEENEMY ) return 1; + + snprintf( szCommand, sizeof( szCommand ), "B+|a%X|r%X|f%X|d%X|p%X|e%X|s%X|h%X|FF|", + attackNo, defNo, flg, 0, 0, effect, img1, img2 ); + BATTLESTR_ADD( szCommand ); + + if( defNo < 10 ) start = 0; + else start = 10; + + for( i = start; i < start+10; i++ ){ + for(item=CHAR_STARTITEMARRAY; item < CHAR_STARTITEMARRAY+10; item++){ + int enemy_index = -1; + int itemindex = -1; + + enemy_index = BATTLE_No2Index( battleindex, i ); + if( !CHAR_CHECKINDEX(enemy_index) ) break; + + itemindex = CHAR_getItemIndex( enemy_index, item ); + + if(ITEM_CHECKINDEX( itemindex ) == TRUE ){ + char msg[64], *item_name; + + CHAR_AddPileItem( charaindex, itemindex); + + item_name = ITEM_getChar( itemindex, ITEM_NAME); + + sprintf( msg, "õ%s", item_name ); + CHAR_talkToCli( charaindex, -1, msg, CHAR_COLORYELLOW); + + CHAR_setItemIndex( enemy_index, item, -1 ); + + BATTLE_Exit( defindex, battleindex ); + + return 1; + } + } + } + + BATTLE_Exit( defindex, battleindex ); + + return 1; + } + default: + break; + } + + + react = 0; + if( (ReactType=BATTLE_GetDamageReact( defindex)) > 0 ) { //й⾵ + react = ReactType; + if( skill_type != BATTLE_COM_S_CHAIN_ATK ){ + react=0; +// skill_type=-1; + } + } + + + if( defNo >= SIDE_OFFSET ){ + i = defNo - SIDE_OFFSET; + DefSide = 1; + } + + //ȡù״̬ + iWork = BATTLE_AttackSeq( attackindex, defindex, &damage, &Guardian, skill_type ); + if( skill_type == BATTLE_COM_S_ENRAGE_PET ){//üŭ\ܲҪĴ + if( CHAR_getInt( defindex, CHAR_HP ) <= damage ){ + damage = 0; + } + } + if( skill_type == BATTLE_COM_S_CAVALRY) // ﹥ + ultimate = BATTLE_PROFESSION_ATK_PET_DamageSub( attackindex, defindex, &damage, &petdamage, &react, skill_level ); + else + ultimate = BATTLE_DamageSub( attackindex, defindex, &damage, &petdamage, &react); + + if( react == BATTLE_MD_REFLEC ) defindex = attackindex; + if( react == BATTLE_MD_TRAP ) defindex = attackindex; +#ifdef _PETSKILL_ACUPUNCTURE + if( react == BATTLE_MD_ACUPUNCTURE ) defindex = attackindex; +#endif + if( damage > 0 && ( react != BATTLE_MD_ABSROB )&& ( react != BATTLE_MD_VANISH )){ + BATTLE_DamageWakeUp( battleindex, defindex ); + } + + iRet = BATTLE_DefineAttack( attackindex, defindex, iWork, szBuffer, damage, react, &flg); + + // NORMAL CRITICAL flg ij ְҵflg + if( img2 != 0 ){ + if( flg == BCF_NORMAL || flg == BCF_KAISHIN ){ + if( (pszP = strstr( pszOption, "ǰ" ) ) != NULL ) + flg |= BCF_F_SKILLACT; //ǰͼ + else + flg |= BCF_B_SKILLACT; // + } + } + + if( CHAR_getInt( defindex, CHAR_HP ) <= 0 ){ + iRet = BATTLE_DefDieType( defindex, iRet, &ultimate, &flg, szBuffer); + } + + if( damage > 0 ){ + if( BATTLE_ItemCrushSeq( attackindex, defindex, damage) == TRUE ) + flg |= BCF_CRUSH; + } + + + memset( szCommand, 0, sizeof( szCommand)); + switch( skill_type){ + case BATTLE_COM_S_BRUST: // + case BATTLE_COM_S_DEAD_ATTACK: // + case BATTLE_COM_S_ATTACK_WEAK: // 㹥 + case BATTLE_COM_S_CAVALRY: // ﹥ + { + snprintf( szCommand, sizeof( szCommand ), "B+|a%X|r%X|f%X|d%X|p%X|e%X|s%X|h%X|FF|", + attackNo, defNo, flg, damage, petdamage, effect, img1, img2 ); + BATTLESTR_ADD( szCommand ); + break; + } + case BATTLE_COM_S_ENRAGE_PET: // ŭ + { + int str = 0; + int turn = 0; + int pindex = -1; + + + flg |= BCF_NO_DAMAGE; + flg |= BCF_B_SKILLACT; //ͼ + + defNo = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM2 ); + + pindex = BATTLE_No2Index( battleindex, defNo ); + + // ǷΪ + if( CHAR_getInt( pindex, CHAR_WHICHTYPE) != CHAR_TYPEPET ) break; + + snprintf( szCommand, sizeof( szCommand ), "B+|a%X|r%X|f%X|d%X|p%X|e%X|s%X|h%X|FF|", + attackNo, defNo, flg, 0, 0, effect, img1, img2 ); + BATTLESTR_ADD( szCommand ); + + // ӹ + str = skill_level * 2 + 10; + sprintf( szCommand, "BD|r%X|0|4|%X|", defNo, str); + BATTLESTR_ADD( szCommand ); + CHAR_setWorkInt( pindex, CHAR_MYSKILLSTRPOWER, str); + + if( skill_level >= 10 ) turn=5; + else if( skill_level >= 5 ) turn=4; + else turn=3; + + CHAR_setWorkInt( pindex, CHAR_MYSKILLSTR, turn ); + + break; + } + case BATTLE_COM_S_CHAOS: // ҹ + { + int i=0, j=0, k=0, f_num=0; + int temp[10], chose_temp[10]; + int defNo_index = BATTLE_No2Index( battleindex, defNo ); + + memset( temp, -1, sizeof( temp ) ); + memset( chose_temp, -1, sizeof( chose_temp ) ); + + if( CHAR_getWorkInt( defNo_index, CHAR_WORKBATTLECOM1 ) == BATTLE_COM_S_EARTHROUND0 ){ + break; + } + + if( defNo >= 10 ) f_num = 10; + else f_num = 0; + + // 30% + //CHAR_setWorkInt(charaindex,CHAR_WORKATTACKPOWER, CHAR_getWorkInt( charaindex, CHAR_WORKATTACKPOWER ) * 70 / 100 ); + + //clientЧ + sprintf( szCommand, "BD|r%X|0|4|%X|", attackNo, -30 ); + BATTLESTR_ADD( szCommand ); + + snprintf( szCommand, sizeof( szCommand ), "B+|a%X|r%X|f%X|d%X|p%X|e%X|s%X|h%X|", + attackNo, defNo, flg, damage, petdamage, effect, img1, img2 ); + BATTLESTR_ADD( szCommand ); + + // ȡսϴ + for( i=f_num; i 0 ){ + int atk_to_index = -1; + atk_to_index = BATTLE_No2Index( battleindex, chose_temp[k] ); + + if( ( atk_to_index >= 0 ) && + ( BATTLE_TargetCheck(battleindex, chose_temp[k] ) != FALSE ) && + ( CHAR_getWorkInt( atk_to_index, CHAR_WORKBATTLECOM1 ) != BATTLE_COM_S_EARTHROUND0 ) + ){ + BATTLE_Attack( battleindex, attackNo, chose_temp[k] ); + k++; + atk_num --; + }else{ + + memset( temp, -1, sizeof( temp ) ); + memset( chose_temp, -1, sizeof( chose_temp ) ); + j = 0; k = 0; + + // ȡսϴ + for( i=f_num; i 0 ) && + (CHAR_getInt( defindex, CHAR_HP ) > 0 ) ){ + BATTLE_Attack( battleindex, attackNo, defNo ); + } + + snprintf( szCommand, sizeof( szCommand ), "FF|"); + BATTLESTR_ADD( szCommand ); + + break; + } + } + + //BATTLE_BroadCast( battleindex, szBuffer, + // (attackNo >= 10)? CHAR_COLORGRAY : CHAR_COLORPURPLE ) ; + + i = defNo-DefSide*SIDE_OFFSET; + if( ultimate > 0 ){ + BattleArray[battleindex].Side[DefSide].Entry[i].flg |= BENT_FLG_ULTIMATE; + } + return iRet; +} + + +// ħʽ +int battle_profession_attack_magic_fun(int battleindex, int attackNo, int defNo, int charaindex) +{ + int attr=-1, attIdx=0, skill=-1, toindex; + + // ȡID + skill = CHAR_GETWORKINT_LOW( charaindex, CHAR_WORKBATTLECOM3); + + // Ŀ + // Robin fix + //toindex = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM2 ); + toindex = defNo; + + + // Χ 0 1 2һȫ + if( toindex < 20 ){ // + attIdx = 0; + }else if( toindex>=23 && toindex<=26 ){ // + attIdx = 1; + }else if( toindex==20 || toindex==21 ){ // һȫ + attIdx = 2; + } + + // Robin fix ս + attr = BattleArray[battleindex].field_att -1; + + PROFESSION_MAGIC_ATTAIC( battleindex, attackNo, toindex, attIdx, attr, skill); + + return TRUE; +} + +// ϵʽ +int battle_profession_assist_fun(int battleindex, int attackNo, int defNo, int charaindex) +{ + int i, skill, skill_type, skill_level, img1, img2, turn=1; + char *pszP = NULL, *pszOption = NULL, szCommand[256]; + BOOL iRet = FALSE; + int ToList[SIDE_OFFSET*2+1]; + + skill = CHAR_GETWORKINT_LOW( charaindex, CHAR_WORKBATTLECOM3); + skill_type = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM1 ); + + // սʹü + if( !PROFESSION_SKILL_getInt( skill, PROFESSION_SKILL_USE_FLAG) ) return iRet; + + // ܵIJ + pszOption = PROFESSION_SKILL_getChar( skill, PROFESSION_SKILL_OPTION); + if( pszOption == "\0" ) return iRet; + + // ܵȼ + skill_level = CHAR_GETWORKINT_HIGH( charaindex, CHAR_WORKBATTLECOM3); + + // ׼ڵĶ + img1 = PROFESSION_SKILL_getInt( skill, PROFESSION_SKILL_IMG_1 ); + + // Ķ + img2 = PROFESSION_SKILL_getInt( skill, PROFESSION_SKILL_IMG_2 ); + + // ʹûغ + if( (pszP = strstr( pszOption, "%" ) ) != NULL ) sscanf( pszP+3, "%d", &turn ); + if(turn < 1) turn=1; + + switch(skill_type){ + case BATTLE_COM_S_TRANSPOSE: // λλ + { + int defNo2 = CHAR_getWorkInt(charaindex,CHAR_WORKBATTLECOM2); + skill_level = PROFESSION_CHANGE_SKILL_LEVEL_M( skill_level ); + + memset( ToList, -1, sizeof( ToList)); + BATTLE_MultiList( battleindex, defNo2, ToList ); + BATTLE_MagicEffect( battleindex, attackNo, ToList, img1, img2 ); + + for( i = 0; ToList[i] != -1; i ++ ){ + int avoid=0; + int toindex = BATTLE_No2Index( battleindex, ToList[i] ); + if( !CHAR_CHECKINDEX( toindex ))continue; + if( charaindex != toindex ) continue; + + // ر + if( skill_level >= 10 ) avoid = 70; + else if( skill_level >= 9 ) avoid = 60; + else if( skill_level >= 8 ) avoid = 50; + else if( skill_level >= 6 ) avoid = 45; + else if( skill_level >= 5 ) avoid = 30; + else if( skill_level >= 3 ) avoid = 25; + else avoid = 10; + + if( skill_level >= 10 ) turn = 5; + else if( skill_level >= 6 ) turn = 4; + else turn = 3; + + if( CHAR_getWorkInt( toindex, CHAR_MYSKILLDUCK) <= 0){ + CHAR_setWorkInt( toindex, CHAR_MYSKILLDUCK, turn+1); + CHAR_setWorkInt( toindex, CHAR_MYSKILLDUCKPOWER, avoid ); + sprintf( szCommand, "BD|r%X|0|3|%X|", ToList[i], avoid); + BATTLESTR_ADD( szCommand ); + iRet = TRUE; + } + } + break; + } + case BATTLE_COM_S_SCAPEGOAT: // Ϊ + { + int tgh=0, old_tgh=0, flg=0, rate=0; + int pos=0, side=0, ownerpos=0; + skill_level = PROFESSION_CHANGE_SKILL_LEVEL_A( skill_level ); + + pos = BATTLE_Index2No( battleindex, charaindex ); + side = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLESIDE ); + + if( skill_level >= 10 ){ // ҷȫ + for(i=0; i<10; i++){ + if(pos != i ) + BattleArray[battleindex].Side[side].Entry[i].guardian = pos; + } + }else if( skill_level >= 5 ){ // ҷг + for(i=5; i<10; i++){ + if(pos != i ) + BattleArray[battleindex].Side[side].Entry[i].guardian = pos; + } + }else{ // ֮ + ownerpos = pos + 5; + if( ownerpos >= 10 ) ownerpos -= 10; + if( ownerpos < 0 || ownerpos > 19 ){ + }else{ + BattleArray[battleindex].Side[side].Entry[ownerpos].guardian = pos; + } + } + + rate = skill_level * 2; + + tgh = 30 - rate; + sprintf( szCommand, "BD|r%X|0|5|%X|", attackNo, (-1) * tgh ); + BATTLESTR_ADD( szCommand ); + + old_tgh = CHAR_getWorkInt(charaindex,CHAR_WORKFIXTOUGH); + tgh = (int)( old_tgh * (100-tgh) / 100 ); + CHAR_setWorkInt( charaindex, CHAR_WORKFIXTOUGH, tgh); + + flg = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEFLG ); + flg |= CHAR_BATTLEFLG_GUARDIAN; + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEFLG, flg ); + + iRet = TRUE; + + break; + } + case BATTLE_COM_S_ENRAGE: // + { + int str=0, tgh=0; + skill_level = PROFESSION_CHANGE_SKILL_LEVEL_A( skill_level ); + + memset( ToList, -1, sizeof( ToList)); + BATTLE_MultiList( battleindex, attackNo, ToList ); + BATTLE_MagicEffect( battleindex, attackNo, ToList, img1, img2 ); + + // + tgh = skill_level * 2 + 10; + sprintf( szCommand, "BD|r%X|0|5|%X|", attackNo, (-1) * tgh ); + BATTLESTR_ADD( szCommand ); + + CHAR_setWorkInt(charaindex,CHAR_MYSKILLTGHPOWER, (-1) * tgh); + + // ӹ + str = skill_level * 2 + 20; + sprintf( szCommand, "BD|r%X|0|4|%X|", attackNo, str); + BATTLESTR_ADD( szCommand ); + + CHAR_setWorkInt( charaindex, CHAR_MYSKILLSTRPOWER, str); + + if( skill_level >= 10 ) turn=5; + else if( skill_level >= 5 ) turn=4; + else turn=3; + + CHAR_setWorkInt( charaindex, CHAR_MYSKILLSTR, turn ); + CHAR_setWorkInt( charaindex, CHAR_MYSKILLTGH, turn ); + + iRet = TRUE; + break; + } + case BATTLE_COM_S_COLLECT: // ۼ + { + int dex=0, tgh=0; + skill_level = PROFESSION_CHANGE_SKILL_LEVEL_A( skill_level ); + + memset( ToList, -1, sizeof( ToList)); + BATTLE_MultiList( battleindex, attackNo, ToList ); + BATTLE_MagicEffect( battleindex, attackNo, ToList, img1, img2 ); + + // + dex = (skill_level * 2) + 10; + sprintf( szCommand, "BD|r%X|0|6|%X|", attackNo, (-1) * dex ); + BATTLESTR_ADD( szCommand ); + CHAR_setWorkInt(charaindex,CHAR_MYSKILLDEXPOWER, dex); + + // ӷ + tgh = (skill_level * 2) + 20; + sprintf( szCommand, "BD|r%X|0|5|%X|", attackNo, tgh); + BATTLESTR_ADD( szCommand ); + CHAR_setWorkInt( charaindex, CHAR_MYSKILLTGHPOWER, tgh); + + if( skill_level >= 10 ) turn=5; + else if( skill_level >= 5 ) turn=4; + else turn=3; + + CHAR_setWorkInt( charaindex, CHAR_MYSKILLDEX, turn ); + CHAR_setWorkInt( charaindex, CHAR_MYSKILLTGH, turn ); + + iRet = TRUE; + break; + } + case BATTLE_COM_S_FOCUS: // רעս + { + int ToList[SIDE_OFFSET*2+1]; + skill_level = PROFESSION_CHANGE_SKILL_LEVEL_A( skill_level ); + + memset( ToList, -1, sizeof( ToList)); + BATTLE_MultiList( battleindex, attackNo, ToList ); + BATTLE_MagicEffect( battleindex, attackNo, ToList, img1, img2 ); + + CHAR_setWorkInt( charaindex, CHAR_MYSKILLHIT, 2); + CHAR_setWorkInt( charaindex, CHAR_MYSKILLHIT_NUM, 100); + + CHAR_talkToCli( charaindex, -1, "", CHAR_COLORYELLOW); + + iRet = TRUE; + break; + } + case BATTLE_COM_S_TRAP: // + { + int value; + int ToList[SIDE_OFFSET*2+1]; + skill_level = PROFESSION_CHANGE_SKILL_LEVEL_M( skill_level ); + + memset( ToList, -1, sizeof(ToList) ); + ToList[0] = attackNo; + + value = skill_level * 30 + 100; + BATTLE_MagicEffect( battleindex, attackNo, ToList, img1, img2 ); + + if( skill_level >= 10 ) turn=3; + else if( skill_level >= 5 ) turn=2; + else turn=1; + + CHAR_setWorkInt( charaindex, CHAR_WORKTRAP, turn); + CHAR_setWorkInt( charaindex, CHAR_WORKMODTRAP, value); + + iRet = TRUE; + break; + } + case BATTLE_COM_S_DOCILE: // ѱ + { + int rate = 0; + skill_level = PROFESSION_CHANGE_SKILL_LEVEL_A( skill_level ); + + rate = skill_level * 2 + 10; + + BATTLE_MultiCaptureUp( battleindex, attackNo, defNo, rate, img1, img2 ); + + iRet = TRUE; + break; + } +#ifdef _PROFESSION_ADDSKILL + case BATTLE_COM_S_CALL_NATURE: // Ȼ + { + int ridepet=0,count=0,addhp=0,toindex=-1; + int ToList[SIDE_OFFSET*2+1]; + BATTLE_MultiList( battleindex, defNo, ToList ); + + if( defNo == 20 || defNo == 25 || defNo == 26 )//ҷ + img1 = 101772; + for( i = 0; ToList[i] != -1; i ++ ){ + toindex = BATTLE_No2Index( battleindex, ToList[i] ); + if( CHAR_CHECKINDEX( toindex ) == FALSE ) continue; + ridepet = BATTLE_getRidePet( toindex ); + if( ridepet == -1 ) + ++count; + else + count += 2; + } + if( skill_level >= 100 ) addhp = 5000/count; + else if( skill_level > 95 ) addhp = 4500/count; + else if( skill_level > 90 ) addhp = 4000/count; + else if( skill_level > 85 ) addhp = 3500/count; + else if( skill_level > 80 ) addhp = 3000/count; + else if( skill_level > 60 ) addhp = 2500/count; + else if( skill_level > 40 ) addhp = 2000/count; + else if( skill_level > 20 ) addhp = 1000/count; + else addhp = 500/count; + if( addhp <= 100 ) + img2 = SPR_heal; + else if( addhp <= 300 ) + img2 = SPR_heal2; + else + img2 = SPR_heal3; + BATTLE_MagicEffect( battleindex, attackNo, ToList, img1, img2 ); + + for( i = 0; ToList[i] != -1; i ++ ){ + toindex = BATTLE_No2Index( battleindex, ToList[i] ); + if( CHAR_CHECKINDEX( toindex ) == FALSE ) continue; + ridepet = BATTLE_getRidePet( toindex ); + if( ridepet == -1 ){ + CHAR_setInt( toindex, CHAR_HP, + min( addhp+CHAR_getInt( toindex, CHAR_HP ), CHAR_getWorkInt( toindex, CHAR_WORKMAXHP ) ) ); + } + else{ + CHAR_setInt( toindex, CHAR_HP, + min( addhp+CHAR_getInt( toindex, CHAR_HP ), CHAR_getWorkInt( toindex, CHAR_WORKMAXHP ) ) ); + CHAR_setInt( ridepet, CHAR_HP, + min( addhp+CHAR_getInt( ridepet, CHAR_HP ), CHAR_getWorkInt( ridepet, CHAR_WORKMAXHP ) ) ); + } + snprintf( szCommand, sizeof(szCommand),"BD|r%X|%X|%X|d%X|p%X|", ToList[i], BD_KIND_HP, 1, addhp, ridepet?addhp:0 ); + BATTLESTR_ADD( szCommand ); + + + if( BattleArray[battleindex].norisk == 0 + && CHAR_getInt( toindex, CHAR_WHICHTYPE ) == CHAR_TYPEPET) + { + int flg = CHAR_getWorkInt( toindex, CHAR_WORKBATTLEFLG ); + if( flg & CHAR_BATTLEFLG_RECOVERY ) + {} + else + { + CHAR_PetAddVariableAi( toindex, AI_FIX_PETRECOVERY ); + CHAR_setWorkInt( toindex, CHAR_WORKBATTLEFLG, flg | CHAR_BATTLEFLG_RECOVERY ); + } + } + } + + iRet = TRUE; + break; + } +#endif + default: + break; + } + + + return iRet; +} + +#ifdef _PROFESSION_ADDSKILL +extern unsigned int GET_PROFESSION_magic_array(int idx); +#endif + +// иı״̬ϵʽ +extern void BATTLE_TargetListSet( int charaindex, int attackNo, int *pList); +extern int BoomerangVsTbl[4][5]; +int battle_profession_status_chang_fun(int battleindex, int attackNo, int defNo, int charaindex) +{ + int i, skill, skill_type, skill_level, img1=0, img2=0, turn=1, j; + char *pszP = NULL, *pszOption = NULL, szCommand[512]; + float rate=0.0; + BOOL iRet = FALSE; + int defindex; + int damage=0, petdamage=0, iWork, Guardian=-1,react; + int flg=0, DefSide=0,ultimate=0; + int ReactType=0, effect=0; + + skill = CHAR_GETWORKINT_LOW( charaindex, CHAR_WORKBATTLECOM3 ); + skill_type=CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM1 ); + + // սʹü + if( !PROFESSION_SKILL_getInt( skill, PROFESSION_SKILL_USE_FLAG) ) return iRet; + + // ܵIJ + pszOption = PROFESSION_SKILL_getChar( skill, PROFESSION_SKILL_OPTION); + if( pszOption == "\0" ) return iRet; + + // ܵȼ + skill_level = CHAR_GETWORKINT_HIGH( charaindex, CHAR_WORKBATTLECOM3); + skill_level = PROFESSION_CHANGE_SKILL_LEVEL_A( skill_level ); + + // ܵȼ rate + if( (pszP = strstr( pszOption, "%" ) ) != NULL ) sscanf( pszP+3, "%f", &rate ); + + // ׼ڵĶ + img1 = PROFESSION_SKILL_getInt( skill, PROFESSION_SKILL_IMG_1 ); + + // Ķ + img2 = PROFESSION_SKILL_getInt( skill, PROFESSION_SKILL_IMG_2 ); + + // ʹûغ + if( (pszP = strstr( pszOption, "%" ) ) != NULL ) sscanf( pszP+3, "%d", &turn ); + if(turn < 1) turn=1; + + // ʽ 0ԭ㶯 1ƶ㶯 + if( (pszP = strstr( pszOption, "Ч%" ) ) != NULL ) sscanf( pszP+3, "%d", &effect ); + + // Ŀһܣ + if( defNo >= 0 && defNo <= 19 ){ + defindex = BATTLE_No2Index( battleindex, defNo ); + if( CHAR_CHECKINDEX( defindex ) == FALSE ) return iRet; + if( CHAR_getWorkInt( defindex, CHAR_WORKBATTLECOM1 ) == BATTLE_COM_S_EARTHROUND0 ){ + return iRet; // Miss + } + } + + switch(skill_type){ + // ƶ + case BATTLE_COM_S_ENTWINE: // + case BATTLE_COM_S_DRAGNET: // ޵ + case BATTLE_COM_S_INSTIGATE: // + case BATTLE_COM_S_OBLIVION: // + case BATTLE_COM_S_RESIST_FIRE: // + case BATTLE_COM_S_RESIST_ICE: // + case BATTLE_COM_S_RESIST_THUNDER: // ׿ +#ifdef _PROFESSION_ADDSKILL + case BATTLE_COM_S_RESIST_F_I_T: // Ȼ +#endif + case BATTLE_COM_S_FIRE_ENCLOSE: // + case BATTLE_COM_S_ICE_ENCLOSE: // + case BATTLE_COM_S_THUNDER_ENCLOSE: // ׸ + { + int perStatus=0, toindex=-1, status=-1, Success=0, dex=0, old_dex; + //char szBuffer[256]=""; + int ToList[SIDE_OFFSET*2+1]; + int defNo2 = CHAR_getWorkInt(charaindex,CHAR_WORKBATTLECOM2); + + // ʹö + if( skill_type == BATTLE_COM_S_RESIST_FIRE || // + skill_type == BATTLE_COM_S_RESIST_ICE || // + skill_type == BATTLE_COM_S_RESIST_THUNDER // ׿ +#ifdef _PROFESSION_ADDSKILL + || skill_type == BATTLE_COM_S_RESIST_F_I_T // Ȼ +#endif + ){ +#ifdef _PROFESSION_ADDSKILL + defNo2 = BATTLE_Index2No( battleindex, charaindex ); +#else + if( defNo2 < 10 ){ + if( skill_level >= 10 ) defNo2 = 20; + else if( skill_level >= 5 ) defNo2 = 25; + }else{ + if( skill_level >= 10 ) defNo2 = 21; + else if( skill_level >= 5 ) defNo2 = 24; + } +#endif + } + + memset( ToList, -1, sizeof( ToList)); + BATTLE_MultiList( battleindex, defNo2, ToList ); + + BATTLE_MagicEffect( battleindex, attackNo, ToList, img1, img2 ); + + charaindex = BATTLE_No2Index( battleindex, attackNo ); + if( CHAR_CHECKINDEX( charaindex ) == FALSE ) return iRet; + + // ı״̬ + if( ((pszP = strstr( pszOption, "" ) ) != NULL ) || + ((pszP = strstr( pszOption, "" ) ) != NULL ) || + ((pszP = strstr( pszOption, "" ) ) != NULL ) || + ((pszP = strstr( pszOption, "" ) ) != NULL ) || + ((pszP = strstr( pszOption, "" ) ) != NULL ) || + ((pszP = strstr( pszOption, "" ) ) != NULL ) || + ((pszP = strstr( pszOption, "" ) ) != NULL ) || + ((pszP = strstr( pszOption, "" ) ) != NULL ) || + ((pszP = strstr( pszOption, "" ) ) != NULL ) || + ((pszP = strstr( pszOption, "" ) ) != NULL ) +#ifdef _PROFESSION_ADDSKILL + || ((pszP = strstr( pszOption, "" ) ) != NULL ) +#endif + ){ + for( i = 1; i < BATTLE_ST_END; i ++ ){ + if( strncmp( pszP, aszStatus[i], 2 ) == 0 ){ + status = i; + break; + } + } + } +#ifdef _BATTLE_NO_WANG + if(CHAR_getInt( defindex, CHAR_PETID) == 1165 || CHAR_getInt( defindex, CHAR_PETID) == 1166 || CHAR_getInt( defindex, CHAR_PETID) == 964) + { + Success = 0; + } + else + { +#endif + // ɹ + if( (pszP = strstr( pszOption, "%" ) ) != NULL ) sscanf( pszP+3, "%d", &Success ); + Success = Success + skill_level * 5; +#ifdef _BATTLE_NO_WANG + } +#endif + if( skill_type == BATTLE_COM_S_DRAGNET ){ + int DRAGNET=0,dragnet_idx=-1; + int PLAYER=0; + //ҳһߵ + if( attackNo > 9 ){// + for(i=0;i<10;i++){//ұж + dragnet_idx = BATTLE_No2Index( battleindex, i ); + if( CHAR_CHECKINDEX( dragnet_idx ) ){ + PLAYER++; + if( CHAR_getWorkInt( dragnet_idx, CHAR_WORKDRAGNET ) > 0 ) { + ++DRAGNET; + } + } + } + } + else{// + for(i=10;i<20;i++){//ж + dragnet_idx = BATTLE_No2Index( battleindex, i ); + if( CHAR_CHECKINDEX( dragnet_idx ) ){ + PLAYER++; + if( CHAR_getWorkInt( BATTLE_No2Index( battleindex, i ), CHAR_WORKDRAGNET ) > 0 ) { + ++DRAGNET; + } + } + } + } + Success *= (float)((PLAYER-DRAGNET)/10.0); +// if( DRAGNET == 1 ){ +// Success *= 0.64; +// }else if( DRAGNET > 1 ){ +// Success *= 0.4; +// } + } + + perStatus = Success; + + // غ + if( (skill_type == BATTLE_COM_S_INSTIGATE) && (skill_level == 10) ){ // + turn = 4; + }else if( (skill_type == BATTLE_COM_S_RESIST_FIRE) || // + (skill_type == BATTLE_COM_S_RESIST_ICE) || // + (skill_type == BATTLE_COM_S_RESIST_THUNDER) ){ // ׿ + + if( skill_level >= 10 ) turn = 5; + else if( skill_level >= 5 ) turn = 4; + else turn = 3; + }else if( skill_type == BATTLE_COM_S_OBLIVION ){ // + if( skill_level >= 10 ){ turn = 4; + }else if( skill_level >= 5 ){ turn = 3; + }else{ turn = 2; } + } +#ifdef _PROFESSION_ADDSKILL + else if( skill_type == BATTLE_COM_S_RESIST_F_I_T ){ // Ȼ + skill_level = CHAR_GETWORKINT_HIGH( charaindex, CHAR_WORKBATTLECOM3); + if( skill_level >= 100 ) turn = 5; + else if( skill_level > 80 ) turn = 4; + else turn = 3; + } +#endif + + switch( skill_type ){ + case BATTLE_COM_S_RESIST_FIRE: + CHAR_talkToCli( charaindex, -1 , "" , CHAR_COLORYELLOW ); break; + case BATTLE_COM_S_RESIST_ICE: + CHAR_talkToCli( charaindex, -1 , "" , CHAR_COLORYELLOW ); break; + case BATTLE_COM_S_RESIST_THUNDER: + CHAR_talkToCli( charaindex, -1 , "׿" , CHAR_COLORYELLOW ); break; +#ifdef _PROFESSION_ADDSKILL + case BATTLE_COM_S_RESIST_F_I_T: + CHAR_talkToCli( charaindex, -1 , "׿" , CHAR_COLORYELLOW ); break; +#endif + } + + for( i = 0; ToList[i] != -1; i ++ ){ + toindex = BATTLE_No2Index( battleindex, ToList[i] ); + if( CHAR_CHECKINDEX( toindex ) == FALSE ) return iRet; + + // ʩ + if( skill_type == BATTLE_COM_S_INSTIGATE ){ + if( CHAR_getInt( toindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER ){ + CHAR_talkToCli( charaindex, -1, "ʩ", CHAR_COLORYELLOW ); + break; + } + } + + // ״̬м춨 + if( (PROFESSION_BATTLE_StatusAttackCheck( charaindex, toindex, status, Success ) == 0 ) + || (CHAR_getInt( toindex, CHAR_HP ) <= 0 ) ){ + + //snprintf( szBuffer, sizeof(szBuffer), "(%s)޷(%s)(%s)(%d%%)", + // CHAR_getUseName( charaindex ), CHAR_getUseName( toindex ), + // aszStatusFull[status], perStatus ); + + //BATTLE_BroadCast( battleindex, szBuffer, + // (attackNo >= 10)? CHAR_COLORGRAY : CHAR_COLORPURPLE ) ; + }else{ +#ifdef _PROFESSION_ADDSKILL + if( status == BATTLE_ST_RESIST_F_I_T ){//Ȼ + CHAR_setWorkInt( toindex, StatusTbl[BATTLE_ST_RESIST_F], turn + 1 ); + CHAR_setWorkInt( toindex, StatusTbl[BATTLE_ST_RESIST_I], turn + 1 ); + CHAR_setWorkInt( toindex, StatusTbl[BATTLE_ST_RESIST_T], turn + 1 ); + } + else +#endif + CHAR_setWorkInt( toindex, StatusTbl[status], turn + 1 ); + + if( status == BATTLE_ST_PARALYSIS + || status == BATTLE_ST_SLEEP + || status == BATTLE_ST_STONE + || status == BATTLE_ST_BARRIER + || status == BATTLE_ST_DIZZY + || status == BATTLE_ST_ENTWINE + || status == BATTLE_ST_DRAGNET + || status == BATTLE_ST_ICECRACK + || status == BATTLE_ST_ICEARROW ){ + CHAR_setWorkInt( toindex, CHAR_WORKBATTLECOM1, BATTLE_COM_NONE ); + } + if( status == BATTLE_ST_DRAGNET ){//޵ + CHAR_setWorkInt( toindex, CHAR_DOOMTIME, 0 );//ĩռ + CHAR_setWorkInt( toindex, CHAR_WORK_com1, 0 ); + CHAR_setWorkInt( toindex, CHAR_WORK_toNo, 0 ); + CHAR_setWorkInt( toindex, CHAR_WORK_mode, 0 ); + CHAR_setWorkInt( toindex, CHAR_WORK_skill_level, 0 ); + CHAR_setWorkInt( toindex, CHAR_WORK_array, 0 ); + } + if( skill_type == BATTLE_COM_S_FIRE_ENCLOSE ){ // + CHAR_setWorkInt( toindex, CHAR_WORKMOD_F_ENCLOSE_2, skill_level ); + // ӻȾֵ + PROFESSION_SKILL_LVEVEL_UP( charaindex, "PROFESSION_FIRE_PRACTICE" ); + }else if(skill_type == BATTLE_COM_S_ICE_ENCLOSE ){ // + CHAR_setWorkInt( toindex, CHAR_WORKMOD_I_ENCLOSE_2, skill_level ); + // ӱȾֵ + PROFESSION_SKILL_LVEVEL_UP( charaindex, "PROFESSION_ICE_PRACTICE" ); + }else if(skill_type == BATTLE_COM_S_THUNDER_ENCLOSE ){ // ׸ + CHAR_setWorkInt( toindex, CHAR_WORKMOD_T_ENCLOSE_2, skill_level ); + // Ⱦֵ + PROFESSION_SKILL_LVEVEL_UP( charaindex, "PROFESSION_THUNDER_PRACTICE" ); + } + + // + if( skill_type == BATTLE_COM_S_OBLIVION ){ + int toNo = -1, toNoindex = -1, pet_no = -1, num = 0; + char msg[20]; + + memset( msg, -1, sizeof(msg) ); + + // index + toNo = ToList[i] - 5; + toNoindex = BATTLE_No2Index( battleindex, toNo ); + + // + pet_no = CHAR_getInt( toNoindex, CHAR_DEFAULTPET ); + + // 輼 + num = skill_level / 2; + if( num < 1 ) num = 1; + CHAR_setWorkInt( toindex, CHAR_WORKMODOBLIVION, num ); + + // client + if( toNoindex != -1 ){ + sprintf( msg, "W%d", pet_no ); + CHAR_sendStatusString( toNoindex, msg ); + + sprintf( msg, "Y%d", pet_no ); + CHAR_sendStatusString( toNoindex, msg ); + + } + } + + // + if(skill_type == BATTLE_COM_S_INSTIGATE ){ + int rate=0; + rate = skill_level * 1 + 10; + CHAR_setWorkInt( toindex, CHAR_WORKMODINSTIGATE, rate); + + sprintf( szCommand, "BD|r%X|0|4|%X|", ToList[i], (-1) * rate); + BATTLESTR_ADD( szCommand ); + sprintf( szCommand, "BD|r%X|0|5|%X|", ToList[i], (-1) * rate); + BATTLESTR_ADD( szCommand ); + sprintf( szCommand, "BD|r%X|0|6|%X|", ToList[i], (-1) * rate ); + BATTLESTR_ADD( szCommand ); + + } + + // + if(skill_type == BATTLE_COM_S_ENTWINE ){ + if( (pszP = strstr( pszOption, "%" ) ) != NULL ) sscanf( pszP+3, "%d", &dex ); + dex = skill_level * 4 + dex; + old_dex = CHAR_getWorkInt( toindex, CHAR_WORKFIXDEX); + old_dex = old_dex * (100 - dex) / 100; + CHAR_setWorkInt( toindex, CHAR_WORKFIXDEX, old_dex ); + sprintf( szCommand, "BD|r%X|0|6|%X|", ToList[i], (-1) * dex ); + BATTLESTR_ADD( szCommand ); + } + + // + if(skill_type == BATTLE_COM_S_RESIST_FIRE ){ + int old_value = CHAR_getWorkInt( toindex, CHAR_WORK_F_RESIST ); + int up_value = skill_level + 10; + CHAR_setWorkInt( toindex, CHAR_WORKMODRESIST_F, up_value ); + CHAR_setWorkInt( toindex, CHAR_WORK_F_RESIST, old_value + up_value ); + + }else + // + if(skill_type == BATTLE_COM_S_RESIST_ICE ){ + int old_value = CHAR_getWorkInt( toindex, CHAR_WORK_I_RESIST ); + int up_value = skill_level + 10; + CHAR_setWorkInt( toindex, CHAR_WORKMODRESIST_I, up_value ); + CHAR_setWorkInt( toindex, CHAR_WORK_I_RESIST, old_value + up_value ); + + }else + // ׿ + if(skill_type == BATTLE_COM_S_RESIST_THUNDER ){ + int old_value = CHAR_getWorkInt( toindex, CHAR_WORK_T_RESIST ); + int up_value = skill_level + 10; + CHAR_setWorkInt( toindex, CHAR_WORKMODRESIST_T, up_value ); + CHAR_setWorkInt( toindex, CHAR_WORK_T_RESIST, old_value + up_value ); + + } +#ifdef _PROFESSION_ADDSKILL + else + // Ȼ + if(skill_type == BATTLE_COM_S_RESIST_F_I_T ){ + int old_value = CHAR_getWorkInt( toindex, CHAR_WORK_F_RESIST ); + int up_value = 2; //ֵ + + if( skill_level >= 10 ) up_value = 20; + else if( skill_level > 8 ) up_value = 18; + else if( skill_level > 7 ) up_value = 16; + else if( skill_level > 6 ) up_value = 14; + else if( skill_level > 5 ) up_value = 12; + else if( skill_level > 4 ) up_value = 10; + else if( skill_level > 3 ) up_value = 8; + else if( skill_level > 2 ) up_value = 6; + else if( skill_level > 1 ) up_value = 4; + else up_value = 2; + + CHAR_setWorkInt( toindex, CHAR_WORKMODRESIST_F, up_value ); + CHAR_setWorkInt( toindex, CHAR_WORK_F_RESIST, old_value + up_value ); + + old_value = CHAR_getWorkInt( toindex, CHAR_WORK_I_RESIST ); + CHAR_setWorkInt( toindex, CHAR_WORKMODRESIST_I, up_value ); + CHAR_setWorkInt( toindex, CHAR_WORK_I_RESIST, old_value + up_value ); + + old_value = CHAR_getWorkInt( toindex, CHAR_WORK_T_RESIST ); + CHAR_setWorkInt( toindex, CHAR_WORKMODRESIST_T, up_value ); + CHAR_setWorkInt( toindex, CHAR_WORK_T_RESIST, old_value + up_value ); + + } +#endif + //snprintf( szBuffer, sizeof(szBuffer), + // "(%s)(%s)(%s)(%d%%)", CHAR_getUseName( charaindex ), + // CHAR_getUseName( toindex ), aszStatusFull[status], perStatus ); + + //BATTLE_BroadCast( battleindex, szBuffer, + // (attackNo >= 10)? CHAR_COLORGRAY : CHAR_COLORPURPLE ) ; + BATTLE_BadStatusString( ToList[i], status ); + iRet = TRUE; + } + } + break; + } + // ƶ + case BATTLE_COM_S_SHIELD_ATTACK: // ܻ + { + int itmid=-1; + int perStatus, status=-1, Success=-1; + char szBuffer[256]=""; + int ToList[SIDE_OFFSET*2+1]; + int defNo2 = CHAR_getWorkInt(charaindex,CHAR_WORKBATTLECOM2); + + itmid = CHAR_getItemIndex( charaindex, CHAR_EQSHIELD ); + + if( ( itmid < 0 ) || ITEM_WSHIELD != ITEM_getInt( itmid , ITEM_TYPE ) ){ + CHAR_talkToCli( charaindex, -1, "δװƣ޷ʹô˼", CHAR_COLORYELLOW); + iRet = FALSE; + break; + } + + // + if( skill_level != 10 ) + CHAR_setWorkInt(charaindex,CHAR_WORKATTACKPOWER, (int)(CHAR_getWorkInt(charaindex,CHAR_WORKATTACKPOWER) * 0.5 ) ); + + memset( ToList, -1, sizeof( ToList)); + BATTLE_MultiList( battleindex, defNo2, ToList ); + + // ı״̬ + if( (pszP = strstr( pszOption, "" ) ) != NULL ){ + for( i = 1; i < BATTLE_ST_END; i ++ ){ + if( strncmp( pszP, aszStatus[i], 2 ) == 0 ){ + status = i; + break; + } + } + } + + // ɹ + if( (pszP = strstr( pszOption, "%" ) ) != NULL ) sscanf( pszP+3, "%d", &Success ); + Success += skill_level * 4; + perStatus = Success; + + if( defNo2 >= SIDE_OFFSET ){ + i = defNo2 - SIDE_OFFSET; + DefSide = 1; + } + + for( i = 0; ToList[i] != -1; i ++ ){ + int hit = -1; + react = 0; + + defindex = BATTLE_No2Index( battleindex, ToList[i] ); //طindex + if( CHAR_CHECKINDEX( defindex ) == FALSE ) continue; + + if( (ReactType=BATTLE_GetDamageReact( defindex)) > 0 ) { //й⾵ + react = ReactType; + skill_type=-1; + } + + //ȡù״̬ + iWork = BATTLE_AttackSeq( charaindex, defindex, &damage, &Guardian, skill_type ); + + ultimate = BATTLE_DamageSub( charaindex, defindex, &damage, &petdamage, &react); + + if( damage > 0 && ( react != BATTLE_MD_ABSROB )&& ( react != BATTLE_MD_VANISH )){ + BATTLE_DamageWakeUp( battleindex, defindex ); + } + + iRet = BATTLE_DefineAttack( charaindex, defindex, iWork, szBuffer, damage, react, &flg); + + // NORMAL CRITICAL flg ij ְҵflg + if( img2 != 0 ){ + if( flg == BCF_NORMAL || flg == BCF_KAISHIN ){ + hit=1; + if( (pszP = strstr( pszOption, "ǰ" ) ) != NULL ){ + flg |= BCF_F_SKILLACT; //ǰͼ + }else{ + flg |= BCF_B_SKILLACT; //ͼ + } + } + } + + if( CHAR_getInt( defindex, CHAR_HP ) <= 0 ) + iRet = BATTLE_DefDieType( defindex, iRet, &ultimate, &flg, szBuffer); + + if( damage > 0 ){ + if( BATTLE_ItemCrushSeq( charaindex, defindex, damage) == TRUE ){ + flg |= BCF_CRUSH; + } + } + + if( hit == 1 ){ + if( (PROFESSION_BATTLE_StatusAttackCheck( charaindex, defindex, status, Success ) == 0 ) + || (CHAR_getInt( defindex, CHAR_HP ) <= 0 ) ){ + + //snprintf( szBuffer, sizeof(szBuffer), "(%s)޷(%s)(%s)(%d%%)", + // CHAR_getUseName( charaindex ), CHAR_getUseName( defindex ), aszStatusFull[status], perStatus ); + + //BATTLE_BroadCast( battleindex, szBuffer, + // (attackNo >= 10)? CHAR_COLORGRAY : CHAR_COLORPURPLE ) ; + }else{ + CHAR_setWorkInt( defindex, StatusTbl[status], turn + 1 ); + + if( status == BATTLE_ST_PARALYSIS + || status == BATTLE_ST_SLEEP + || status == BATTLE_ST_STONE + || status == BATTLE_ST_BARRIER + || status == BATTLE_ST_DIZZY + || status == BATTLE_ST_ENTWINE + || status == BATTLE_ST_DRAGNET + || status == BATTLE_ST_ICECRACK + || status == BATTLE_ST_ICEARROW + ){ + CHAR_setWorkInt( defindex, CHAR_WORKBATTLECOM1, BATTLE_COM_NONE ); + } + + //snprintf( szBuffer, sizeof(szBuffer), + // "(%s)(%s)(%s)(%d%%)", + // CHAR_getUseName( charaindex ), + // CHAR_getUseName( defindex ), + // aszStatusFull[status], + // perStatus + //); + + BATTLE_BadStatusString( ToList[i], status ); + } + } + + snprintf( szCommand, sizeof( szCommand ), "B+|a%X|r%X|f%X|d%X|p%X|e%X|s%X|h%X|FF|", + attackNo, ToList[i], flg, damage, petdamage, effect, img1, img2 ); + BATTLESTR_ADD( szCommand ); + + //BATTLE_BroadCast( battleindex, szBuffer, + // (attackNo >= 10)? CHAR_COLORGRAY : CHAR_COLORPURPLE ) ; + + i = defNo2-DefSide*SIDE_OFFSET; + if( ultimate > 0 ){ + BattleArray[battleindex].Side[DefSide].Entry[i].flg |= BENT_FLG_ULTIMATE; + } + + iRet = TRUE; + } + break; + + } + case BATTLE_COM_S_TOXIN_WEAPON: // + { + int perStatus, status=-1, Success=-1; + int defNo2 = CHAR_getWorkInt(charaindex,CHAR_WORKBATTLECOM2); + + charaindex = BATTLE_No2Index( battleindex, attackNo ); + if( CHAR_CHECKINDEX( charaindex ) == FALSE ) return iRet; + + // ı״̬ + if( ((pszP = strstr( pszOption, "" ) ) != NULL ) ){ + + for( i = 1; i < BATTLE_ST_END; i ++ ){ + if( strncmp( pszP, aszStatus[i], 2 ) == 0 ){ + status = i; + break; + } + } + } + + // ɹ + if( (pszP = strstr( pszOption, "%" ) ) != NULL ) sscanf( pszP+3, "%d", &Success ); + Success += skill_level * 2; + perStatus = Success; + + if( defNo2 >= SIDE_OFFSET ){ + i = defNo2 - SIDE_OFFSET; + DefSide = 1; + } + + { + int gWeponType = BATTLE_GetWepon( charaindex ); + char szCommand[512]; + int i = 0, ReactType = 0, iRet = -1; + int ToList[SIDE_OFFSET*2+1]; + BOOL bChange = FALSE; + + memset( ToList, -1, sizeof( ToList)); + BATTLE_MultiList( battleindex, defNo, ToList ); + + memset( szCommand, -1, sizeof(szCommand) ); + + // ޱ +#ifdef _PETSKILL_BECOMEPIG + if(CHAR_getWorkInt(charaindex, CHAR_WORKFOXROUND) > 0 + || CHAR_getWorkInt(charaindex, CHAR_BECOMEPIG) > 0) bChange = TRUE; +#else + if(CHAR_getWorkInt(charaindex, CHAR_WORKFOXROUND) > 0) bChange = TRUE; +#endif + if(!bChange){ + // ΪԶ + if( gWeponType == ITEM_BOW ){ + sprintf( szCommand, "BB|a%X|w0|", attackNo ); + BATTLESTR_ADD( szCommand ); + memset( ToList, -1, sizeof( ToList)); + BATTLE_TargetListSet(charaindex,attackNo,ToList); + }else if( gWeponType == ITEM_BOUNDTHROW ){ + sprintf( szCommand, "BB|a%X|w1|", attackNo ); + BATTLESTR_ADD( szCommand ); + }else if( gWeponType == ITEM_BREAKTHROW ){ + sprintf( szCommand, "BB|a%X|w2|", attackNo ); + BATTLESTR_ADD( szCommand ); + }else if( gWeponType == ITEM_BOOMERANG){ + sprintf( szCommand, "BO|a%X|", attackNo ); + BATTLESTR_ADD( szCommand ); + memset(ToList,-1,sizeof(ToList)); + for(i=0;i<5;i++) ToList[i] = BoomerangVsTbl[defNo/5][i]; + gBattleDamageModyfy = 0.3; + } + } + + for( i = 0; ToList[i] != -1; i ++ ){ + int defindex = -1, j = -1; + int react = 0; + char szBuffer[256] = ""; + + damage = 0; + petdamage = 0; + flg = 0; + + //memset( szBuffer, 0, sizeof( szBuffer ) ); + + defindex = BATTLE_No2Index( battleindex, ToList[i] ); //طindex + if( CHAR_CHECKINDEX( defindex ) == FALSE ) continue; + if( CHAR_getInt( defindex, CHAR_HP ) <= 0 ) continue; + + if( (ReactType=BATTLE_GetDamageReact( defindex)) > 0 ){ //й⾵ + react = ReactType; + skill_type=-1; + } + + //ȡù״̬ + iWork = BATTLE_AttackSeq( charaindex, defindex, &damage, &Guardian, skill_type ); + if(Guardian >= 0) defindex = BATTLE_No2Index( battleindex, Guardian ); + + iRet = BATTLE_DefineAttack( charaindex, defindex, iWork, szBuffer, damage, react, &flg); + + if(damage > 0){ + ultimate = BATTLE_DamageSub( charaindex, defindex, &damage, &petdamage, &react); + + if((react != BATTLE_MD_ABSROB ) && ( react != BATTLE_MD_VANISH ) ){ + BATTLE_DamageWakeUp( battleindex, defindex ); + } + + if( CHAR_getInt( defindex, CHAR_HP ) <= 0 ) + iRet = BATTLE_DefDieType( defindex, iRet, &ultimate, &flg, szBuffer); + + if( BATTLE_ItemCrushSeq( charaindex, defindex, damage) == TRUE ){ + flg |= BCF_CRUSH; + } + + if( (PROFESSION_BATTLE_StatusAttackCheck( charaindex, defindex, status, perStatus ) == 0 ) + || (CHAR_getInt( defindex, CHAR_HP ) <= 0 ) ){ + + //snprintf( szBuffer, sizeof(szBuffer), "(%s)޷(%s)(%s)(%d%%)", + // CHAR_getUseName( charaindex ), CHAR_getUseName( defindex ), aszStatusFull[status], perStatus ); + //BATTLE_BroadCast( battleindex, szBuffer, + // (attackNo >= 10)? CHAR_COLORGRAY : CHAR_COLORPURPLE ) ; + }else{ + CHAR_setWorkInt( defindex, StatusTbl[status], turn + 1 ); + + if( status == BATTLE_ST_PARALYSIS + || status == BATTLE_ST_SLEEP + || status == BATTLE_ST_STONE + || status == BATTLE_ST_BARRIER + || status == BATTLE_ST_DIZZY + || status == BATTLE_ST_ENTWINE + || status == BATTLE_ST_DRAGNET + || status == BATTLE_ST_ICECRACK + || status == BATTLE_ST_ICEARROW + ){ + CHAR_setWorkInt( defindex, CHAR_WORKBATTLECOM1, BATTLE_COM_NONE ); + } + + //snprintf( szBuffer, sizeof(szBuffer), + // "(%s)(%s)(%s)(%d%%)", + // CHAR_getUseName( charaindex ), + // CHAR_getUseName( defindex ), + // aszStatusFull[status], + // perStatus + //); + + BATTLE_BadStatusString( ToList[i], status ); + } + } + + // ΪԶʱ + + if(((gWeponType == ITEM_BOW) + || (gWeponType == ITEM_BOUNDTHROW) + || (gWeponType == ITEM_BREAKTHROW) + || (gWeponType == ITEM_BOOMERANG)) && !bChange){ + snprintf( szCommand, sizeof( szCommand ), "r%X|f%X|d%X|p%X|", ToList[i], flg, damage, petdamage ); + BATTLESTR_ADD( szCommand ); + }else{ + snprintf( szCommand, sizeof( szCommand ), "BH|a%X|r%X|f%X|d%X|p%X|FF|", attackNo, ToList[i], flg, damage, petdamage); + BATTLESTR_ADD( szCommand ); + } + + //BATTLE_BroadCast( battleindex, szBuffer, + // (attackNo >= 10)? CHAR_COLORGRAY : CHAR_COLORPURPLE ) ; + + j = ToList[i]-DefSide*SIDE_OFFSET; + if( ultimate > 0 ){ + BattleArray[battleindex].Side[DefSide].Entry[j].flg |= BENT_FLG_ULTIMATE; + } + + iRet = TRUE; + } + + // ΪԶʱ + if((( gWeponType == ITEM_BOW ) || ( gWeponType == ITEM_BOUNDTHROW ) || ( gWeponType == ITEM_BREAKTHROW ) || ( gWeponType == ITEM_BOOMERANG )) && !bChange){ + snprintf( szCommand, sizeof( szCommand ), "FF|" ); + BATTLESTR_ADD( szCommand ); + } + } + if(gWeponType == ITEM_BOOMERANG) gBattleDamageModyfy = 1.0; + break; + } +#ifdef _PROFESSION_ADDSKILL + case BATTLE_COM_S_BOUNDARY: // Խ + { + int ToList[SIDE_OFFSET*2+1],status=-1,power=20,toindex=-1,loop=1; + int defNo2 = defNo;//CHAR_getWorkInt(charaindex,CHAR_WORKBATTLECOM2); + int rand_boundary,rand_boundary2 = RAND( 1, 100 ); + + if( skill_level >= 10 ) turn = 5; + else if( skill_level > 9 ) turn = 4; + else if( skill_level > 8 ) turn = 3; + else if( skill_level > 4 ) turn = 2; + else turn = 1; + + skill_level = CHAR_GETWORKINT_HIGH( charaindex, CHAR_WORKBATTLECOM3); + + if( skill_level >= 100 ) power = 100; + else if( skill_level > 95 ) power = 90; + else if( skill_level > 90 ) power = 80; + else if( skill_level > 85 ) power = 70; + else if( skill_level > 80 ) power = 60; + else if( skill_level > 60 ) power = 50; + else if( skill_level > 40 ) power = 40; + else if( skill_level > 20 ) power = 30; + else power = 20; + + if( ((pszP = strstr( pszOption, "ؽ" ) ) != NULL ) ) + status = CHAR_WORKFIXEARTHAT_BOUNDARY; + else if( ((pszP = strstr( pszOption, "ˮ" ) ) != NULL ) ) + status = CHAR_WORKFIXWATERAT_BOUNDARY; + else if( ((pszP = strstr( pszOption, "" ) ) != NULL ) ) + status = CHAR_WORKFIXFIREAT_BOUNDARY; + else if( ((pszP = strstr( pszOption, "" ) ) != NULL ) ){ + status = CHAR_WORKFIXWINDAT_BOUNDARY; + } + else{//ƽ + status = CHAR_WORKFIXEARTHAT_BOUNDARY; + + if( skill_level >= 100 ) rand_boundary = 100; + else if( skill_level > 80 ) rand_boundary = 80; + else if( skill_level > 40 ) rand_boundary = 70; + else if( skill_level > 20 ) rand_boundary = 60; + else rand_boundary = 50; + if( rand_boundary2 <= rand_boundary ){ + loop = 4; + power=0; + turn=0; + } + else + loop = 0; + } + + if( ((pszP = strstr( pszOption, "ƽ" ) ) != NULL ) ){ + if( defNo2 < 10 )defNo2 = 20; else defNo2 = 21; + } + + memset( ToList, -1, sizeof( ToList)); + BATTLE_MultiList( battleindex, defNo2, ToList ); + + if( ((pszP = strstr( pszOption, "ƽ" ) ) == NULL ) ){//Ȱн + for( j=CHAR_WORKFIXEARTHAT_BOUNDARY; j 0 ) { + playerdamage = (damage*petquick)/(defquick+petquick) +1; + petdamage = damage - playerdamage +1 ; + hp -= playerdamage; + pethp -= petdamage; + }else + hp -= damage; + } + work = CHAR_getWorkInt( defindex, CHAR_WORKDAMAGEREFLEC ) - 1; + CHAR_setWorkInt( defindex, CHAR_WORKDAMAGEREFLEC, max( work, 0 ) ); + defindex = attackindex; + defpet = attackpet; + + }else + if( *pRefrect == BATTLE_MD_TRAP ){ // + int value=0; + value = CHAR_getWorkInt( defindex, CHAR_WORKMODTRAP ); + damage = value; + + hp = CHAR_getInt( attackindex, CHAR_HP ); + if( attackpet == -1 ) { + hp -= damage; + playerdamage = hp; + }else { + pethp = CHAR_getInt( attackpet, CHAR_HP ); + defquick = CHAR_getWorkInt( attackindex, CHAR_WORKDEFENCEPOWER ); + petquick = CHAR_getWorkInt( attackpet, CHAR_WORKDEFENCEPOWER ); + if( pethp > 0 ) { + playerdamage = (damage*petquick)/(defquick+petquick) +1; + petdamage = damage - playerdamage +1 ; + hp -= playerdamage; + pethp -= petdamage; + }else + hp -= damage; + } + + CHAR_setWorkInt( defindex, CHAR_WORKTRAP, 0 ); + CHAR_setWorkInt( defindex, CHAR_WORKMODTRAP, 0 ); + defindex = attackindex; + defpet = attackpet; + + }else +#ifdef _PETSKILL_ACUPUNCTURE +/* if( *pRefrect == BATTLE_MD_ACUPUNCTURE ){ + hp = CHAR_getInt( attackindex, CHAR_HP ); + if( attackpet == -1 ) { + hp -= ( damage/2 ? damage/2:1 ); + }else { + pethp = CHAR_getInt( attackpet, CHAR_HP ); + defquick = CHAR_getWorkInt( attackindex, CHAR_WORKDEFENCEPOWER ); + petquick = CHAR_getWorkInt( attackpet, CHAR_WORKDEFENCEPOWER ); + if( pethp > 0 ) { + playerdamage = (damage*petquick)/(defquick+petquick) +1; + petdamage = damage - playerdamage +1 ; + hp -= ( playerdamage/2 ? playerdamage/2:1 ); + pethp -= ( petdamage/2 ? petdamage/2:1 ); + }else + hp -= ( damage/2 ? damage/2:1 ); + } + //work = CHAR_getWorkInt( defindex, CHAR_WORKACUPUNCTURE ) - 1; + CHAR_setWorkInt( defindex, CHAR_WORKACUPUNCTURE, 0);//max( work, 0 ) ); + defindex = attackindex; + defpet = attackpet; + }*/ +#endif + if( react == BATTLE_MD_VANISH ){ + hp = CHAR_getInt( defindex, CHAR_HP ); + if( defpet != -1 ) + pethp = CHAR_getInt( defpet, CHAR_HP ); + work = CHAR_getWorkInt( defindex, CHAR_WORKDAMAGEVANISH ) - 1; + CHAR_setWorkInt( defindex, CHAR_WORKDAMAGEVANISH, max( work, 0 ) ); + *pRefrect = BATTLE_MD_VANISH; + }else{ + hp = CHAR_getInt( defindex, CHAR_HP ); + + if( defpet == -1 ) { + hp -= (damage * 0.7); + }else { + pethp = CHAR_getInt( defpet, CHAR_HP ); + if( pethp > 0 ) { + int rate=0; + rate = skill_level * 2 + 60; + + petdamage = damage * rate / 100; + playerdamage = damage - petdamage; + + hp -= playerdamage; + pethp -= petdamage; + + }else + hp -= damage; + } + *pRefrect = 0; + } + if( hp < 0 ){ + addpoint = -hp; + hp = 0; + } + maxhp = CHAR_getWorkInt( defindex, CHAR_WORKMAXHP ); + CHAR_setInt( defindex, CHAR_HP, min( hp, maxhp ) ); + if( defpet != -1 ) { + if( pethp < 0 ) pethp = 0; + petmaxhp = CHAR_getWorkInt( defpet, CHAR_WORKMAXHP ); + CHAR_setInt( defpet, CHAR_HP, min( pethp, petmaxhp ) ); + // Robin 0804 + if( pethp <= 0 ) { + CHAR_setInt( defindex, CHAR_RIDEPET, -1 ); + BATTLE_changeRideImage( defindex ); + CHAR_setWorkInt( defindex, CHAR_WORKPETFALL, 1 ); + //print(" defpet_die! "); + } + } + + if( (damage) >= maxhp * 1.2 + 20 ){ + IsUltimate = 2; + }else{ + if( addpoint > 0 ){ + addpoint += CHAR_getWorkInt( defindex, CHAR_WORKULTIMATE ); + CHAR_setWorkInt( defindex, CHAR_WORKULTIMATE, addpoint ); + if( addpoint >= maxhp * 1.2 + 20 )IsUltimate = 1; + } + } + + if( BattleArray[battleindex].type == BATTLE_TYPE_P_vs_P ){ + } +#ifdef _PETSKILL_LER +// ׶ܱ + if(CHAR_getInt(defindex,CHAR_BASEBASEIMAGENUMBER) == 101813 || + CHAR_getInt(defindex,CHAR_BASEBASEIMAGENUMBER) == 101814) IsUltimate = 0; +#endif + + if( IsUltimate ){ + CHAR_setWorkInt( defindex, CHAR_WORKULTIMATE, 0 ); + } + if( playerdamage < 0 ) playerdamage = 0; + if( petdamage < 0 ) petdamage = 0; + *pDamage = playerdamage; + *pPetDamage = petdamage; + return IsUltimate; +} + + +// ȡû˺ +int BATTLE_PROFESSION_CONVOLUTE_GET_DAMAGE( int attackindex, int defindex, int skill_level ) +{ + int damage = 0, old_atk = 0, atk = 0; + int rand_num = RAND(1, 10000 ); + // һ + int perCri = BATTLE_CriticalCheck( attackindex, defindex ); + + old_atk = CHAR_getWorkInt( attackindex, CHAR_WORKATTACKPOWER ); + atk = old_atk * (100 -( 50 - skill_level )) / 100; + CHAR_setWorkInt( attackindex, CHAR_WORKATTACKPOWER, atk ); + + if( rand_num < perCri ){ + damage = BATTLE_CriDamageCalc( attackindex, defindex ); + }else{ + //profession fix + if( BATTLE_DuckCheck( attackindex, defindex ) ) + return 0; + damage = BATTLE_DamageCalc( attackindex, defindex ); + } + + return damage; +} + +// ȡùᴩ˺ +int BATTLE_PROFESSION_THROUGH_ATTACK_GET_DAMAGE( int attackindex, int defindex ) +{ + int damage = 0; + int rand_num = RAND(1, 10000 ); + // һ + int perCri = BATTLE_CriticalCheck( attackindex, defindex ); + + if( rand_num < perCri ){ + damage = BATTLE_CriDamageCalc( attackindex, defindex ); + }else{ + //profession fix + if( BATTLE_DuckCheck( attackindex, defindex ) ) + return 0; + damage = BATTLE_DamageCalc( attackindex, defindex ); + } + + return damage; +} + +// 𡢱׸帽ӹ +int BATTLE_PROFESSION_RANG_ATTACK_DAMAGE( int charaindex, int attackNo, int defNo, int skill_type, int status, int turn, int perStatus, int effect, int img1, int img2 ) +{ + int ReactType = 0, iRet = -1,defindex = -1,react = 0; + int battleindex = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEINDEX ); + //char szBuffer[256]=""; + + //memset( szBuffer, 0, sizeof( szBuffer ) ); + + defindex = BATTLE_No2Index( battleindex, defNo); //طindex + if( defindex == -1 ) return iRet; + + if( (ReactType=BATTLE_GetDamageReact( defindex)) > 0 ){ //й⾵ + react = ReactType; + skill_type=-1; + } + + if( img1 != 0 ){ + if( (PROFESSION_BATTLE_StatusAttackCheck( charaindex, defindex, status, perStatus ) == 0 ) + || (CHAR_getInt( defindex, CHAR_HP ) <= 0 ) ){ + //snprintf( szBuffer, sizeof(szBuffer), "(%s)޷(%s)(%s)(%d%%)", + // CHAR_getUseName( charaindex ), CHAR_getUseName( defindex ), aszStatusFull[status], perStatus ); + //BATTLE_BroadCast( battleindex, szBuffer,(attackNo >= 10)? CHAR_COLORGRAY : CHAR_COLORPURPLE ) ; + } + else{ + CHAR_setWorkInt( defindex, StatusTbl[status], turn + 1 ); + + if( status == BATTLE_ST_PARALYSIS + || status == BATTLE_ST_SLEEP + || status == BATTLE_ST_STONE + || status == BATTLE_ST_BARRIER + || status == BATTLE_ST_DIZZY + || status == BATTLE_ST_ENTWINE + || status == BATTLE_ST_DRAGNET + || status == BATTLE_ST_ICECRACK + || status == BATTLE_ST_ICEARROW + ) CHAR_setWorkInt( defindex, CHAR_WORKBATTLECOM1, BATTLE_COM_NONE ); + + //snprintf( szBuffer, sizeof(szBuffer), + // "(%s)(%s)(%s)(%d%%)", + // CHAR_getUseName( charaindex ), + // CHAR_getUseName( defindex ), + // aszStatusFull[status], + // perStatus + // ); + + BATTLE_BadStatusString( defNo, status ); + iRet = TRUE; + } + //BATTLE_BroadCast( battleindex, szBuffer,(attackNo >= 10)? CHAR_COLORGRAY : CHAR_COLORPURPLE ) ; + } + + return iRet; +} + +#endif + +#ifdef _PETSKILL_LER +extern ToCallMagic PROFESSION_magic[3]; +// ׶ - ȺĴ +void BATTLE_BatFly( int battleindex, int attackNo,int myside) +{ + int ToList[SIDE_OFFSET*2+1],i,toindex; + int petidx,addhp = 0,charhp,pethp,charaindex; + char szCommand[1024]; + + charaindex = BATTLE_No2Index(battleindex,attackNo); + if(CHAR_CHECKINDEX(charaindex) == FALSE) return; + + memset(ToList,-1,sizeof(ToList)); + if(myside) BATTLE_MultiList(battleindex,TARGET_SIDE_0,ToList); // + else BATTLE_MultiList(battleindex,TARGET_SIDE_1,ToList); // + + PROFESSION_magic[2].uiSpriteNum = myside ? 101806:101807; + PROFESSION_magic[2].siSx = 320; + PROFESSION_magic[2].siSy = 240; + PROFESSION_magic[2].uiPrevMagicNum = myside ? 101808:101809; // ǰö + PROFESSION_magic[2].uiPostMagicNum = 0xffffffff; // ö + PROFESSION_magic[2].uiShowType = 1; + PROFESSION_magic[2].uiShowBehindChar = 1; + PROFESSION_magic[2].siPrevMagicSx = 0; + PROFESSION_magic[2].siPrevMagicSy = 0; + PROFESSION_MAGIC_ATTAIC_Effect(battleindex,attackNo,ToList,2); + sprintf(szCommand,"%X|",0x5711438); + BATTLESTR_ADD(szCommand); + + for(i=0;i CHAR_getWorkInt(charaindex,CHAR_WORKMAXHP)){ + CHAR_setInt(charaindex,CHAR_HP,CHAR_getWorkInt(charaindex,CHAR_WORKMAXHP)); + addhp = 0; + } + else CHAR_setInt(charaindex,CHAR_HP,CHAR_getInt(charaindex,CHAR_HP) + addhp); + sprintf(szCommand,"BD|r%X|%X|1|d%X|p0|",attackNo,BD_KIND_HP,addhp); + BATTLESTR_ADD(szCommand); +} + +// ׶ - +void BATTLE_DivideAttack( int battleindex, int attackNo,int myside) +{ + int ToList[SIDE_OFFSET*2+1],i,toindex; + int petidx,charhp,charmp,pethp,charaindex; + char szCommand[1024]; + + charaindex = BATTLE_No2Index(battleindex,attackNo); + if(CHAR_CHECKINDEX(charaindex) == FALSE) return; + + memset(ToList,-1,sizeof(ToList)); + if(myside) BATTLE_MultiList(battleindex,TARGET_SIDE_0,ToList); // + else BATTLE_MultiList(battleindex,TARGET_SIDE_1,ToList); // + + PROFESSION_magic[2].uiSpriteNum = myside ? 101798:101800; + PROFESSION_magic[2].siSx = 320; + PROFESSION_magic[2].siSy = 240; + PROFESSION_magic[2].uiPrevMagicNum = myside ? 101808:101809; // ǰö + PROFESSION_magic[2].uiPostMagicNum = 0xffffffff; // ö + PROFESSION_magic[2].uiShowType = 1; + PROFESSION_magic[2].uiShowBehindChar = 0; + PROFESSION_magic[2].siPrevMagicSx = 0; + PROFESSION_magic[2].siPrevMagicSy = 0; + PROFESSION_MAGIC_ATTAIC_Effect(battleindex,attackNo,ToList,2); + sprintf(szCommand,"%X|",0x5711438); + BATTLESTR_ADD(szCommand); + + // ɿMPĶ + for(i=0;i>1)); + charmp >>= 1; + sprintf(szCommand,"BD|r%X|%X|0|d%X|",ToList[i],BD_KIND_MP,charmp); + BATTLESTR_ADD(szCommand); + } + } + for(i=0;i 10 ? 1:0); + } + else if(CHAR_getInt(charaindex,CHAR_BASEBASEIMAGENUMBER) == 101814){ + array = ENEMY_getEnemyArrayFromId(2510); + if(array == -1) return; + newindex = ENEMY_createEnemy(array,300); + if(newindex == -1) return; + CHAR_setWorkInt(newindex,CHAR_WORK_RELIFE,101811); + CHAR_setWorkInt(newindex,CHAR_WORKBATTLESIDE,no > 10 ? 1:0); + } + pBattle = &BattleArray[battleindex]; + pEntry = pBattle->Side[no > 10 ? 1:0].Entry; + pEntry[no > 10 ? no-10:no].charaindex = newindex; +} +#endif + +#ifdef _PETSKILL_BATTLE_MODEL +typedef struct _tsAttackObject{ + int index; // + int target; // Ŀ + int actionNumber; // ͼ +}AttackObject; +// BATTLE_BattleModel õĹʽ +void BATTLE_BattleModel_ATTACK( + int battleindex, + int charaindex, + AttackObject *pAAttackObject, + int iEffect, + int iTurn, + int iEffectHit, + int iType) +{ + int i,iDefindex,iPetindex,iToindex,iDamage,iPetDamage,iGuardian = -1,iDefState,iUltimate = 0,iTemp = 0,iTemp2 = 0,iFlg = 0; + char szCommand[1024]; + + // Ŀ治ڻû + if(!BATTLE_TargetCheck(battleindex,pAAttackObject->target)) return; + iToindex = iDefindex = BATTLE_No2Index(battleindex,pAAttackObject->target); + // dz,ڲڳ + if(CHAR_getInt(iToindex,CHAR_WHICHTYPE ) == CHAR_TYPEPET){ + if(pAAttackObject->target + 5 >= SIDE_OFFSET) iFlg = 1; + i = pAAttackObject->target + 5 - iFlg * SIDE_OFFSET; + if(BattleArray[battleindex].Side[iFlg].Entry[i].flg & BENT_FLG_ULTIMATE) return; + } + iPetindex = BATTLE_getRidePet(iToindex); + // ˺ + iDefState = BATTLE_AttackSeq(charaindex,iToindex,&iDamage,&iGuardian,-1); + // iType & 0x00000004 Ϊ true ʾΪ + if(iType & 0x00000004){ + // Ȯû,趨Ȯ + if(BATTLE_TargetCheck(battleindex,iGuardian)){ + // Ȯ,ѱ趨ΪʹȮܵĽɫ,򱻹ΪԭĿ + if(iGuardian >= 0) iDefindex = BATTLE_No2Index(battleindex,iGuardian); + } + else iGuardian = -1; + } + // 趨 CHAR_NPCWORKINT1 Ϊ BATTLE_COM_S_BATTLE_MODEL BATTLE_DamageSub õ + iTemp2 = CHAR_getWorkInt(iDefindex,CHAR_NPCWORKINT1); + CHAR_setWorkInt(iDefindex,CHAR_NPCWORKINT1,BATTLE_COM_S_BATTLE_MODEL); + // ֮ iDefindex ˵Ŀ + if(gDamageDiv != 0.0 && iDamage > 0){ + iDamage /= gDamageDiv; + if(iDamage <= 0) iDamage = 1; + } + // ûһ,пѪ + if(!(iDefState == BATTLE_RET_DODGE)){ + // Ѫ + // + if(iType & 0x00000004) iUltimate = BATTLE_DamageSub(charaindex,iDefindex,&iDamage,&iPetDamage,&iTemp); + // + else{ + iTemp = -1; + iUltimate = BATTLE_DamageSub(charaindex,iDefindex,&iDamage,&iPetDamage,&iTemp); + } + } + iFlg = 0; + // ش״̬ + switch(iDefState){ + case BATTLE_RET_ALLGUARD:iFlg |= BCF_GUARD;break; + case BATTLE_RET_MISS:iDamage = 0;break; + case BATTLE_RET_DODGE:iDamage = 0;iFlg |= BCF_DODGE;break; + case BATTLE_RET_NORMAL: + iFlg |= BATTLE_getReactFlg(iDefindex,iTemp); + iFlg |= BCF_NORMAL; + break; + case BATTLE_RET_CRITICAL: + iFlg |= BATTLE_getReactFlg(iDefindex,iTemp); + iFlg |= BCF_KAISHIN; + break; +#ifdef _EQUIT_ARRANGE + case BATTLE_RET_ARRANGE:iFlg |= BCF_B_ARRANGE;break; +#endif + } + + //˯ʱ,״̬(Ҳ״̬) + if(iDamage > 0 && (iTemp != BATTLE_MD_ABSROB) && (iTemp != BATTLE_MD_VANISH)) BATTLE_DamageWakeUp(battleindex,iDefindex); + + // ĿǷ + if(CHAR_getInt(iDefindex,CHAR_HP) <= 0){ + if(CHAR_getWorkInt(iDefindex,CHAR_WORKBATTLEFLG ) & CHAR_BATTLEFLG_ABIO) iUltimate = 1; + else if(CHAR_getInt(iDefindex,CHAR_WHICHTYPE) != CHAR_TYPEPLAYER && (iFlg & BCF_KAISHIN)){ + if(RAND(1,100) < 50) iUltimate = 1; + } +#ifdef _PETSKILL_LER + // ׶ܱ + if(CHAR_getInt(iDefindex,CHAR_BASEBASEIMAGENUMBER) == 101813 || + CHAR_getInt(iDefindex,CHAR_BASEBASEIMAGENUMBER) == 101814) iUltimate = 0; +#endif + iFlg |= BCF_DEATH; + if(iUltimate == 1) iFlg |= BCF_ULTIMATE_1; + if(iUltimate == 2) iFlg |= BCF_ULTIMATE_2; + } + else{ +#ifdef _TAKE_ITEMDAMAGE + if(BATTLE_ItemCrushSeq(charaindex,iDefindex,iDamage) == TRUE) +#else + if(BATTLE_ItemCrushSeq(iDefindex) == TRUE) +#endif + iFlg |= BCF_CRUSH; + // ״̬ж + if(iDamage > 0 && BATTLE_StatusAttackCheck(charaindex,iDefindex,iEffect,iEffectHit,30,1.0,&iTemp)){ + CHAR_setWorkInt(iDefindex,StatusTbl[iEffect],iTurn); + if(iEffect == BATTLE_ST_DRUNK) CHAR_setWorkInt(iDefindex,CHAR_WORKDRUNK,CHAR_getWorkInt(iDefindex,CHAR_WORKDRUNK) >> 1); + // ״̬Ŀûغ֮᲻ж + if(iEffect == BATTLE_ST_PARALYSIS || iEffect == BATTLE_ST_SLEEP || iEffect == BATTLE_ST_STONE || iEffect == BATTLE_ST_BARRIER) + CHAR_setWorkInt(iDefindex,CHAR_WORKBATTLECOM1,BATTLE_COM_NONE); + // شclientһĿҪִ״̬ı + if(iGuardian >= 0) BATTLE_BadStatusString(iGuardian,iEffect); // iGuardian 춵 0 ʾĿʹȮ,Ŀ״̬ı + else BATTLE_BadStatusString(pAAttackObject->target,iEffect); // ԭĿ״̬ı + } + } + + if(iGuardian >= 0){ + iFlg |= BCF_GUARDIAN; + snprintf(szCommand,sizeof(szCommand), + "r%X|i%X|f%X|d%X|p%X|a%X|g%X|", + pAAttackObject->target, + pAAttackObject->index, + iFlg, + iDamage, + iPetDamage, + pAAttackObject->actionNumber, + iGuardian); + }else + snprintf(szCommand,sizeof(szCommand), + "r%X|i%X|f%X|d%X|p%X|a%X|", + pAAttackObject->target, + pAAttackObject->index, + iFlg, + iDamage, + iPetDamage, + pAAttackObject->actionNumber); + + // 봫clientbuffer + BATTLESTR_ADD(szCommand); + + iTemp = BATTLE_Index2No(battleindex,iDefindex); + + // iFlg û,; + iFlg = 0; + if(iTemp >= SIDE_OFFSET) iFlg = 1; + + i = iTemp - iFlg * SIDE_OFFSET; + if(iUltimate > 0) BattleArray[battleindex].Side[iFlg].Entry[i].flg |= BENT_FLG_ULTIMATE; + CHAR_setWorkInt(iDefindex,CHAR_NPCWORKINT1,iTemp2); +} + +void BATTLE_BattleModel(int battleindex,int attackNo,int myside) +{ + int iToList[SIDE_OFFSET*2+1],i,i0,i1,i2,iEffect = -1,iTurn = -1,iEffectHit = 0,iType,iObjectNum,charaindex; + int iActionNumber[4] = {-1,-1,-1,-1},iActionAmount = 0; + char szData[32],szData2[32],*pszOption = NULL; + AttackObject AAttackObject[10]; + + charaindex = BATTLE_No2Index(battleindex,attackNo); + if(CHAR_CHECKINDEX(charaindex) == FALSE) return; + + pszOption = PETSKILL_getChar(CHAR_getWorkInt(charaindex,CHAR_WORKBATTLECOM3),PETSKILL_OPTION); + + if(pszOption == "\0"){ +// printf("BATTLE_BattleModel: read PETSKILL_OPTION error!!(array:%d,file:%s,line:%d)\n", +// CHAR_getWorkInt(charaindex,CHAR_WORKBATTLECOM3),__FILE__,__LINE__); + return; + } + + // ȡЧ + if(getStringFromIndexWithDelim(pszOption,"|",3,szData,sizeof(szData)) != FALSE){ + for(i=1;i= iActionAmount) i1 = 0; + } + + // 鳡Ŀʣֻ + for(i=0;i= i){ + i0 = i; // ¼Ŀֻ + + for(i=0;i +#include "char.h" +#include "char_base.h" +#include "battle.h" +#include "battle_event.h" +#include "battle_item.h" +#include "battle_magic.h" +#include "item_event.h" +#include "log.h" +#include "anim_tbl.h" +#include "npcutil.h" +#include "magic_base.h" +#include "lssproto_serv.h" + + +int BATTLE_ItemUseDelete( + int charaindex, + int haveitemindex +) +{ + int itemindex; + + itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + if( ITEM_CHECKINDEX( itemindex ) == FALSE ) return 0; + { +// LogItem( +// CHAR_getChar( charaindex, CHAR_NAME ), +// CHAR_getChar( charaindex, CHAR_CDKEY ), +//#ifdef _add_item_log_name // WON ADD itemlogitem +// itemindex, +//#else +// ITEM_getInt( itemindex, ITEM_ID ), +//#endif +// "BattleUse(սʹõĵ)", +// CHAR_getInt( charaindex,CHAR_FLOOR), +// CHAR_getInt( charaindex,CHAR_X ), +// CHAR_getInt( charaindex,CHAR_Y ), +// ITEM_getChar( itemindex, ITEM_UNIQUECODE), +// ITEM_getChar( itemindex, ITEM_NAME), +// ITEM_getInt( itemindex, ITEM_ID) +// ); + } + CHAR_DelItemMess( charaindex, haveitemindex, 0); + + return 0; +} + +#ifdef _IMPRECATE_ITEM +void ITEM_useImprecate( int charaindex, int toNo, int haveitemindex ) +{ + int i; + int battleindex, attackNo,itemindex; + char *arg; + char buf[256]; + + struct tagImprecate { + char fun[256]; + int intfun; + }; + struct tagImprecate ImList[3] ={ + {"",BD_KIND_CURSE},{"",BD_KIND_BESTOW},{"ף",BD_KIND_WISHES} }; + + if( !CHAR_CHECKINDEX( charaindex) ) return; + battleindex = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEINDEX ); + + if( (attackNo = BATTLE_Index2No( battleindex, charaindex )) < 0 ){ + //print( "ANDY attackNo=%d\n", attackNo); + return; + } + itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + if(!ITEM_CHECKINDEX(itemindex)) return; + + arg = ITEM_getChar(itemindex, ITEM_ARGUMENT ); + if( arg == "\0" ){ + //print( "ANDY ITEM id:%d=>arg err\n", ITEM_getInt( itemindex, ITEM_ID)); + return; + } + + for( i=0; i<3; i++) { + if( strstr( arg, ImList[i].fun ) != 0 ) { + char buf1[256]; + int kind,powers, rounds, HealedEffect; + + if( NPC_Util_GetStrFromStrWithDelim( arg, ImList[i].fun, buf, sizeof( buf)) == NULL )continue; + kind = ImList[i].intfun; + if( getStringFromIndexWithDelim( buf,"x", 1, buf1, sizeof( buf1)) == FALSE ) continue; + powers = atoi( buf1); + if( getStringFromIndexWithDelim( buf,"x", 2, buf1, sizeof( buf1)) == FALSE ) continue; + rounds = atoi( buf1); + HealedEffect = SPR_hoshi; + BATTLE_ImprecateRecovery( + battleindex, attackNo, toNo, kind, powers, + rounds, SPR_item3, HealedEffect ); + CHAR_setItemIndex(charaindex, haveitemindex ,-1); + CHAR_sendItemDataOne( charaindex, haveitemindex); + ITEM_endExistItemsOne( itemindex ); + break; + } + } +} +#endif + +#ifdef _ITEM_MAGICRECOVERY +void ITEM_useMRecovery_Battle( int charaindex, int toNo, int haveitemindex ) +{ + int battleindex, attackNo, itemindex; + int turn=0, magicid, marray; + char buf1[256]; + char *arg=NULL; + + battleindex = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEINDEX ); + if( BATTLE_CHECKINDEX( battleindex ) == FALSE ) return; + if( (attackNo = BATTLE_Index2No( battleindex, charaindex )) == -1 ) return; + + itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + if(!ITEM_CHECKINDEX(itemindex)) return; + arg = ITEM_getChar( itemindex, ITEM_ARGUMENT ); + + + if( getStringFromIndexWithDelim( arg, ":", 2, buf1, sizeof(buf1)) ==FALSE ) return; + turn = atoi( buf1); + if( getStringFromIndexWithDelim( arg, ":", 1, buf1, sizeof(buf1)) ==FALSE ) return; + + if( strstr( buf1, "ȫ" ) != NULL ){ + }else{ + } + + magicid = ITEM_getInt( itemindex, ITEM_MAGICID); + marray = MAGIC_getMagicArray( magicid); + if( marray == -1 ) return; + + + if( IsBATTLING( charaindex ) == TRUE ){ + int i, status=-1; + char *magicarg=NULL, *pszP=NULL; +#ifdef _CAX_ZHUANGYUAN_QTJ + int floor = CHAR_getInt( charaindex, CHAR_FLOOR ); + int fd; + fd = getfdFromCharaIndex( charaindex); + if( floor == 1042 + || floor == 2032 + || floor == 3032 + || floor == 4032 + || floor == 5032 + || floor == 6032 + || floor == 7032 + || floor == 8032 + || floor == 9032 + || floor == 10032 + || floor == 2000 + || floor == 2005){ + int battleindex = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEINDEX ); + BATTLE_NoAction( battleindex, BATTLE_Index2No( battleindex, charaindex) ); + CHAR_talkToCli(charaindex,-1,"˵ͼֹʹþ(ȫξ)",CHAR_COLORYELLOW); + return; + } +#endif +#ifdef _PREVENT_TEAMATTACK //⾵..ʹõз + int battleindex = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEINDEX ); + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER + //&& BattleArray[battleindex].type != BATTLE_TYPE_P_vs_P + ){ + if( BATTLE_CheckSameSide( charaindex, toNo) == 0 ){//ͬ + int battleindex = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEINDEX ); + BATTLE_NoAction( battleindex, BATTLE_Index2No( battleindex, charaindex) ); + CHAR_talkToCli( charaindex, -1, "⾵..ʩҵз", CHAR_COLORYELLOW); + return; + } + } +#endif + + magicarg = MAGIC_getChar( marray, MAGIC_OPTION ); + pszP = magicarg; + for( ;status == -1 && pszP[0] != 0; pszP++ ){ + for( i = 1; i < BATTLE_MD_END; i ++ ){ + if( strncmp( pszP, aszMagicDef[i], 2 ) == 0 ){ + status = i; + pszP +=2; + break; + } + } + } + if( status == -1 ) return; + + BATTLE_MultiMagicDef( battleindex, attackNo, toNo, + status, turn, MAGIC_EFFECT_USER, SPR_difence ); + +// LogItem( +// CHAR_getChar( charaindex, CHAR_NAME ), +// CHAR_getChar( charaindex, CHAR_CDKEY ), +//#ifdef _add_item_log_name // WON ADD itemlogitem +// itemindex, +//#else +// ITEM_getInt( itemindex, ITEM_ID ), +//#endif +// "BattleUse(սʹõĵ)", +// CHAR_getInt( charaindex,CHAR_FLOOR), +// CHAR_getInt( charaindex,CHAR_X ), +// CHAR_getInt( charaindex,CHAR_Y ), +// ITEM_getChar( itemindex, ITEM_UNIQUECODE), +// ITEM_getChar( itemindex, ITEM_NAME), +// ITEM_getInt( itemindex, ITEM_ID) +// ); + } + + CHAR_DelItemMess( charaindex, haveitemindex, 0); +} +#endif + +#ifdef _ITEM_USEMAGIC +void ITEM_useMagic_Battle( int charaindex, int toNo, int haveitemindex ) +{ + int itemindex,itemmaxuse; + char *arg=NULL; + itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + if(!ITEM_CHECKINDEX(itemindex)) return; + arg = ITEM_getChar( itemindex, ITEM_ARGUMENT ); + + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, toNo ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_JYUJYUTU ); + CHAR_SETWORKINT_LOW( charaindex, CHAR_WORKBATTLECOM3, atoi(arg) ); + CHAR_SETWORKINT_HIGH( charaindex, CHAR_WORKBATTLECOM3, 0 ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + + MAGIC_DirectUse( + charaindex, + CHAR_GETWORKINT_LOW( charaindex, CHAR_WORKBATTLECOM3 ), + CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM2 ), + CHAR_GETWORKINT_HIGH( charaindex, CHAR_WORKBATTLECOM3 ) + ); + + itemmaxuse = ITEM_getInt( itemindex, ITEM_DAMAGEBREAK); + if( itemmaxuse > 0 ) + ITEM_setInt( itemindex, ITEM_DAMAGEBREAK, itemmaxuse-1 ); + else{ +// LogItem( +// CHAR_getChar( charaindex, CHAR_NAME ), +// CHAR_getChar( charaindex, CHAR_CDKEY ), +//#ifdef _add_item_log_name // WON ADD itemlogitem +// itemindex, +//#else +// ITEM_getInt( itemindex, ITEM_ID ), +//#endif +// "BattleUse(սʹõĵ)", +// CHAR_getInt( charaindex,CHAR_FLOOR), +// CHAR_getInt( charaindex,CHAR_X ), +// CHAR_getInt( charaindex,CHAR_Y ), +// ITEM_getChar( itemindex, ITEM_UNIQUECODE), +// ITEM_getChar( itemindex, ITEM_NAME), +// ITEM_getInt( itemindex, ITEM_ID) +// ); + + CHAR_DelItemMess( charaindex, haveitemindex, 0); + } +} +#endif + +void ITEM_useRecovery_Battle( int charaindex, int toNo, int haveitemindex ) +{ + int power = 0, per = 0, HealedEffect=0; + int battleindex, attackNo,itemindex, kind = BD_KIND_HP; + char *p = NULL, *arg; + itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + if(!ITEM_CHECKINDEX(itemindex)) return; + arg = ITEM_getChar(itemindex, ITEM_ARGUMENT ); + if( (p = strstr( arg, "" )) != NULL ) + { + kind = BD_KIND_HP; + } + else if( (p = strstr( arg, "" )) != NULL ) + { + kind = BD_KIND_MP; + } + else +#ifdef _ITEM_UNBECOMEPIG + if( (p = strstr( arg, "" )) != NULL ){ + kind = BD_KIND_UNBECOMEPIG; + HealedEffect = 100608; //Ч + } + else +#endif +#ifdef _ITEM_LVUPUP + if( (p = strstr( arg, "LVUPUP" )) != NULL ){ + return; + } + else +#endif +#ifdef _ITEM_PROPERTY + if( (p = strstr( arg, "PROPERTY" )) != NULL ){ + kind = BD_KIND_PROPERTY; + HealedEffect = 100608; //Ч + if( strstr( arg, "+" ) ) + power = 1; + else if( strstr( arg, "-" ) ) + power = 2; + } + else +#endif +#ifdef _ITEM_ADDPETEXP + if( (p = strstr( arg, "GETEXP" )) != NULL ){ + return; + } + else +#endif + return; + +#ifdef _ITEM_UNBECOMEPIG + if( HealedEffect != 100608 ){ +#endif + if( sscanf( p+2, "%d", &power ) != 1 ) + power = 0; + if( power <= 100 ) + HealedEffect = SPR_heal;//SPR_hoshi + else if( power <= 300 ) + HealedEffect = SPR_heal2; + else + HealedEffect = SPR_heal3; +#ifdef _ITEM_UNBECOMEPIG + } +#endif + + battleindex = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEINDEX ); + attackNo = BATTLE_Index2No( battleindex, charaindex ); + if( attackNo < 0 )return; + BATTLE_MultiRecovery( battleindex, attackNo, toNo,kind, power, per, SPR_item3, HealedEffect ); + { +// LogItem( +// CHAR_getChar( charaindex, CHAR_NAME ), +// CHAR_getChar( charaindex, CHAR_CDKEY ), +//#ifdef _add_item_log_name // WON ADD itemlogitem +// itemindex, +//#else +// ITEM_getInt( itemindex, ITEM_ID ), +//#endif +// "BattleUse(սʹõĵ)", +// CHAR_getInt( charaindex,CHAR_FLOOR), +// CHAR_getInt( charaindex,CHAR_X ), +// CHAR_getInt( charaindex,CHAR_Y ), +// ITEM_getChar( itemindex, ITEM_UNIQUECODE), +// ITEM_getChar( itemindex, ITEM_NAME), +// ITEM_getInt( itemindex, ITEM_ID) +// ); + } + CHAR_DelItemMess( charaindex, haveitemindex, 0); +} + +void ITEM_useStatusChange_Battle( + int charaindex, + int toNo, + int haveitemindex +){ + int turn = 0, i; + int battleindex, attackNo,itemindex, status = -1, Success = 15; + int ReceveEffect; + char *pszP = NULL, *arg; + char szTurn[] = "turn"; + char szSuccess[] = ""; + + itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + if(!ITEM_CHECKINDEX(itemindex)) return; + arg = ITEM_getChar(itemindex, ITEM_ARGUMENT ); + pszP = arg; + for( ;status == -1 && pszP[0] != 0; pszP++ ){ + for( i = 0; i < BATTLE_ST_END; i ++ ){ + if( strncmp( pszP, aszStatus[i], 2 ) == 0 ){ + status = i; + pszP +=2; + break; + } + } + } + if( status == -1 ) return ; + if( ( pszP = strstr( arg, szTurn ) ) != NULL){ + pszP += sizeof( szTurn ); + sscanf( pszP, "%d", &turn ); + } + if( ( pszP = strstr( arg, szSuccess ) ) != NULL){ + pszP += sizeof( szSuccess ); + sscanf( pszP, "%d", &Success ); + } + + battleindex = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEINDEX ); + attackNo = BATTLE_Index2No( battleindex, charaindex ); + + if( status == BATTLE_ST_NONE ){ + ReceveEffect = SPR_tyusya; + }else{ + ReceveEffect = SPR_hoshi; + } + BATTLE_MultiStatusChange( battleindex, attackNo, toNo, + status, turn, SPR_item3, ReceveEffect, Success ); + BATTLE_ItemUseDelete( charaindex, haveitemindex ); +} + +void ITEM_useStatusRecovery_Battle( + int charaindex, // м̼͵ + int toNo, // ľм į + int haveitemindex // мʧ ة į +){ + int i; + int battleindex, attackNo,itemindex, status = -1; + int ReceveEffect; + char *pszP = NULL, *arg; + + // ʧ ةؤ¾ + itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + if(!ITEM_CHECKINDEX(itemindex)) return; + + // ɷ¶ë + arg = ITEM_getChar(itemindex, ITEM_ARGUMENT ); + + pszP = arg; + // ë + for( ;status == -1 && pszP[0] != 0; pszP++ ){ + // ؤ¼ƥ߾ո + for( i = 0; i < BATTLE_ST_END; i ++ ){ + // + if( strncmp( pszP, aszStatus[i], 2 ) == 0 ){ + status = i; + pszP +=2; + break; + } + } + } + // ئмƥ + if( status == -1 ) return ; + + //------- ռ ----------- + battleindex = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEINDEX ); + + attackNo = BATTLE_Index2No( battleindex, charaindex ); + + ReceveEffect = SPR_tyusya; // 巴ľ + + // 幻 + BATTLE_MultiStatusRecovery( battleindex, attackNo, toNo, + status, SPR_item3, ReceveEffect ); + + // ʧ ةɧ + BATTLE_ItemUseDelete( charaindex, haveitemindex ); + +} + + + + + + +void ITEM_useMagicDef_Battle( + int charaindex, + int toNo, + int haveitemindex +) +{ + int turn = 0, i; + int battleindex, attackNo,itemindex, status = -1; + char *pszP = NULL, *arg; + + char szTurn[] = "turn"; + + itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + if(!ITEM_CHECKINDEX(itemindex)) return; + + arg = ITEM_getChar(itemindex, ITEM_ARGUMENT ); + + pszP = arg; + + for( ;status == -1 && pszP[0] != 0; pszP++ ){ + for( i = 1; i < BATTLE_MD_END; i ++ ){ + if( strncmp( pszP, aszMagicDef[i], 2 ) == 0 ){ + status = i; + pszP +=2; + break; + } + } + } + + if( status == -1 ) return ; + + if( ( pszP = strstr( arg, szTurn ) ) != NULL){ + pszP += sizeof( szTurn ); + sscanf( pszP, "%d", &turn ); + } + + battleindex = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEINDEX ); + + attackNo = BATTLE_Index2No( battleindex, charaindex ); + + BATTLE_MultiMagicDef( battleindex, attackNo, toNo, + status, turn, SPR_item3, SPR_difence ); + + BATTLE_ItemUseDelete( charaindex, haveitemindex ); + + +} + + + + + + +//-------------------------------------------------------------- +// ɷ¶ ʧ ةë +//-------------------------------------------------------------- +// +void ITEM_useParamChange_Battle( + int charaindex, // м̼͵ + int toNo, // ľм į + int haveitemindex // мʧ ة į +) +{ + int i; + int battleindex, attackNo,itemindex; + int pow, par = 0; + int kind = -1; + char *pszP = NULL, *arg; + + // ʧ ةؤ¾ + itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + if(!ITEM_CHECKINDEX(itemindex)) return; + + // ɷ¶ë + arg = ITEM_getChar(itemindex, ITEM_ARGUMENT ); + + pszP = arg; + // ë + for( ;kind == -1 && pszP[0] != 0; pszP++ ){ + for( i = 1; i < BATTLE_MD_END; i ++ ){ + // + if( strncmp( pszP, aszParamChange[i], 2 ) == 0 ){ + kind = i; + pszP +=2; + break; + } + } + } + // ئмƥ + if( kind == -1 ) return ; + + + if( strstr( pszP, "%" ) ){ // ѻң + par = 1; + } + + if( sscanf( pszP, "%d", &pow ) != 1 ){ + // Ϻ̼ؤ¾ + pow = 30; + } + + //------- ----------- + battleindex = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEINDEX ); + + attackNo = BATTLE_Index2No( battleindex, charaindex ); + + // 幻 + BATTLE_MultiParamChange( battleindex, attackNo, toNo, + kind, pow, par, SPR_item3, SPR_hoshi ); + + + // ʧ ةɧ + BATTLE_ItemUseDelete( charaindex, haveitemindex ); + + +} + + + + + + +//-------------------------------------------------------------- +// ū ʧ ةë +//-------------------------------------------------------------- +// +void ITEM_useFieldChange_Battle( + int charaindex, // м̼͵ + int toNo, // ľм į + int haveitemindex // мʧ ة į +) +{ + int itemindex; + char *pArg; + + // ʧ ةؤ¾ + itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + if(!ITEM_CHECKINDEX(itemindex)) return; + + //------- ----------- + // ɷ¶ë + pArg = ITEM_getChar(itemindex, ITEM_ARGUMENT ); + + // ɷ¶ мƥ + if( pArg == "\0" )return ; + + BATTLE_FieldAttChange( charaindex, pArg ); + + // ʧ ةɧ + BATTLE_ItemUseDelete( charaindex, haveitemindex ); + +} + + +//-------------------------------------------------------------- +// ʧ ةë +//-------------------------------------------------------------- +// +void ITEM_useAttReverse_Battle( + int charaindex, // м̼͵ + int toNo, // ľм į + int haveitemindex // мʧ ة į +) +{ + int itemindex, battleindex, attackNo; + + + // ʧ ةؤ¾ + itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + if(!ITEM_CHECKINDEX(itemindex)) return; + + //------- ----------- + battleindex = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEINDEX ); + + attackNo = BATTLE_Index2No( battleindex, charaindex ); + + // 幻 + BATTLE_MultiAttReverse( battleindex, attackNo, toNo, + SPR_item3, SPR_kyu ); + + // ʧ ةɧ + BATTLE_ItemUseDelete( charaindex, haveitemindex ); + + +} + + +//-------------------------------------------------------------- +// 姾ë +//-------------------------------------------------------------- +// +void ITEM_useRessurect( + int charaindex, // м̼͵ + int toNo, // ľм į + int haveitemindex // мʧ ة į +) +{ + int itemindex, battleindex, attackNo, par = 0, pow = 0, ReceveEffect; + char *pszP = NULL; + + + // ʧ ةؤ¾ + itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + if(!ITEM_CHECKINDEX(itemindex)) return; + + //------- ----------- + pszP = ITEM_getChar(itemindex, ITEM_ARGUMENT ); + + if( strstr( pszP, "%" ) ){ // ѻң + par = 1; + } + + if( sscanf( pszP, "%d", &pow ) != 1 ){ + // Ϻ̼¾ + pow = 0; // ߼ + } + + battleindex = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEINDEX ); + + attackNo = BATTLE_Index2No( battleindex, charaindex ); + + if( pow <= 0 ){ + ReceveEffect = SPR_fukkatu3; + }else + if( pow <= 100 ){ + ReceveEffect = SPR_fukkatu1; + }else + if( pow <= 300 ){ + ReceveEffect = SPR_fukkatu2; + }else{ + ReceveEffect = SPR_fukkatu3; + } + + // 幻 + BATTLE_MultiRessurect( battleindex, attackNo, toNo, + pow, par, SPR_item3, ReceveEffect ); + + + // ʧ ةɧ + BATTLE_ItemUseDelete( charaindex, haveitemindex ); + +} + + + +//-------------------------------------------------------------- +// Ĥë +//-------------------------------------------------------------- +// +void ITEM_useCaptureUp_Battle( + int charaindex, // м̼͵ + int toNo, // ľм į + int haveitemindex // мʧ ة į +) +{ + int itemindex, battleindex, attackNo, pow = 5, ReceveEffect; + char *pArg; + + // ʧ ةؤ¾ + itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + if(!ITEM_CHECKINDEX(itemindex)) return; + + //------- ----------- + // ɷ¶ë + pArg = ITEM_getChar(itemindex, ITEM_ARGUMENT ); + + // ɷ¶ мƥ + if( pArg == "\0" )return ; + + if( sscanf( pArg, "%d", &pow ) != 1 ){ + // Ϻ̼¾ + pow = 5; + } + + battleindex = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEINDEX ); + + attackNo = BATTLE_Index2No( battleindex, charaindex ); + + ReceveEffect = SPR_hoshi; + + // 幻 + BATTLE_MultiCaptureUp( battleindex, attackNo, toNo, + pow, SPR_item3, ReceveEffect ); + + // ʧ ةɧ + BATTLE_ItemUseDelete( charaindex, haveitemindex ); + +} +#ifdef _ITEM_CRACKER +void ITEM_useCracker_Effect( charaindex, toindex, haveitemindex) +{ + int itemindex,x,y,tofd; + + itemindex = CHAR_getItemIndex(charaindex,haveitemindex); + // Ʒ + if(!ITEM_CHECKINDEX(itemindex)) return; + + x = CHAR_getInt( charaindex, CHAR_X); + y = CHAR_getInt( charaindex, CHAR_Y); + + CHAR_setMyPosition( charaindex, x, y, TRUE); + CHAR_setWorkInt( charaindex, CHAR_WORKITEM_CRACKER, 1); + CHAR_sendCrackerEffect( charaindex, 101125); + //to client + tofd = getfdFromCharaIndex( charaindex ); + lssproto_IC_send(tofd, x, y); + // + BATTLE_ItemUseDelete(charaindex,haveitemindex); + CHAR_talkToCli(charaindex,-1,"ʧˡ",CHAR_COLORYELLOW); + +} +#endif +#ifdef _ITEM_REFRESH //vincent 쳣״̬ +void ITEM_useRefresh_Effect( charaindex, toindex, haveitemindex) +{ + int i,itemindex,ReceveEffect; + char *arg; +// char szBuffer[128]=""; + int status = -1,attackNo,index2; + int battleindex; + char *pszP; + +//print("\nvincent--ITEM_useRefresh_Effect"); + // Ʒ + itemindex = CHAR_getItemIndex(charaindex,haveitemindex); + if(!ITEM_CHECKINDEX(itemindex)) return; + arg = ITEM_getChar(itemindex, ITEM_ARGUMENT ); + pszP = arg; + // ë + for( ;status == -1 && pszP[0] != 0; pszP++ ){ + // ྮո + for( i = 1; i < BATTLE_ST_END; i ++ ){ + // + if( strncmp( pszP, aszStatus[i], 2 ) == 0 ){ + status = i; + pszP +=2; + break; + } + } + } +//print("\nvincent-->status:%d",status); + // ئмƥ + if( status == -1 ) return; + + // į + battleindex = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEINDEX ); + index2 = BATTLE_No2Index( battleindex, toindex);//Ŀ֮index + attackNo = BATTLE_Index2No( battleindex, charaindex ); +// defNo = BATTLE_Index2No( battleindex, index2 ); +//print("\nvincent-->charaindex:%d,attackNo:%d,index2:%d,defNo:%d,",charaindex,attackNo,index2,defNo); + + /* ƽҷ ջ */ + CHAR_setItemIndex(charaindex, haveitemindex ,-1); + CHAR_sendItemDataOne( charaindex, haveitemindex);/* ʧ ةޥ */ +// if( CHAR_getWorkInt( charaindex, StatusTbl[status] ) > 0 ){ +// ReceveEffect = SPR_tyusya; +// }else{ +// ReceveEffect = SPR_hoshi; +// } + ReceveEffect = SPR_tyusya;// + BATTLE_MultiStatusRecovery( battleindex, attackNo, toindex, + status, MAGIC_EFFECT_USER, ReceveEffect ); + /* */ + ITEM_endExistItemsOne( itemindex ); +////////////////////////// +// BATTLE_MultiList( battleindex, defNo, ToList ); +// for( i = 0; ToList[i] != -1; i ++ ){ +// toindex = BATTLE_No2Index( battleindex, ToList[i] ); +// +// } + + + +//////////////////////////// +} +#endif +#ifdef _ITEM_ADDEXP //vincent +void ITEM_useAddexp_Effect( charaindex, toindex, haveitemindex) +{ + int itemindex,power,vtime; + //,pindex + char *p = NULL, *arg; + char szBuffer[1024]=""; + + itemindex = CHAR_getItemIndex(charaindex,haveitemindex); + + // Ʒ + if(!ITEM_CHECKINDEX(itemindex)) return; + arg = ITEM_getChar(itemindex, ITEM_ARGUMENT ); + + if( (p = strstr( arg, "" )) != NULL ){ + sscanf( p+2, "%d", &power ); + } + if( (p = strstr( arg, "" )) != NULL ){ + sscanf( p+2, "%d", &vtime ); + } + if( p == NULL )return; +#ifdef CC_ADD_ADDEXPCHECKDEGREE + { + if ( power != (int)(CHAR_getInt( charaindex, CHAR_ADDEXPPOWER)) && + 0 != (int)(CHAR_getInt( charaindex, CHAR_ADDEXPPOWER)) + ) + { + CHAR_talkToCli( charaindex, -1, "ӵЧͬ,޷ʹ", CHAR_COLORYELLOW); + return; + } + } + #endif +#ifdef _ITEM_ADDEXP2 // ǹʱۼ + { + int point; + point = CHAR_getInt( charaindex, CHAR_ADDEXPPOWER) + * (int)(CHAR_getInt( charaindex, CHAR_ADDEXPTIME)/60); +#ifdef _CAX_ITEM_ADDEXP + if( point >= getexptime()* power) { +#else + if( point >= 7200000) { +#endif + CHAR_talkToCli( charaindex, -1, "ǻ֮ۼʱ估ЧѴޡ", CHAR_COLORYELLOW); + return; + } + + if(CHAR_getInt( charaindex, CHAR_ADDEXPPOWER)!=power){ + point = power * vtime; +#ifdef _CAX_ITEM_ADDEXP + point = min( point, getexptime()*power); +#else + point = min( point, 7200000); +#endif + vtime = (int)(point / power); + }else{ + point += (power * vtime); +#ifdef _CAX_ITEM_ADDEXP + point = min( point, getexptime()*power); +#else + point = min( point, 7200000); +#endif + vtime = (int)(point / power); + } + } +#endif + CHAR_setInt( charaindex, CHAR_ADDEXPPOWER, power); + CHAR_setInt( charaindex, CHAR_ADDEXPTIME,vtime*60 ); + + // + BATTLE_ItemUseDelete(charaindex,haveitemindex); + //sprintf(szBuffer, "ѧϰ%d", power); + sprintf(szBuffer, "ѧϰ%dʱЧʣ%dӡ", power, vtime); + CHAR_talkToCli(charaindex,-1,szBuffer,CHAR_COLORYELLOW); + //int mfd=getfdFromCharaIndex( charaindex); + CHAR_charSaveFromConnect(charaindex, FALSE); + CHAR_talkToCli(charaindex, -1, "ϵͳΪԶ浵", CHAR_COLORRED); +} +#endif +//Terry add 2001/12/24 +#ifdef _ITEM_FIRECRACKER +void ITEM_useFirecracker_Battle( charaindex, toindex, haveitemindex) +{ + int itemindex, battleindex, masteridx=-1, index2; + + char szWork[128]; +#ifdef _FIX_FIRECRACKER + int petid=-1, i=1; + BOOL FINDPET=FALSE; + char *buff1; + char token[256], buf1[256]; +#else + int PetEscape = 0; +#endif + + itemindex = CHAR_getItemIndex(charaindex,haveitemindex); + // Ʒ + if(!ITEM_CHECKINDEX(itemindex)) return; + + battleindex = CHAR_getWorkInt(charaindex,CHAR_WORKBATTLEINDEX); +#ifdef _FIX_FIRECRACKER + index2 = BATTLE_No2Index( battleindex, toindex); + if( !CHAR_CHECKINDEX( index2) ) return; + { + int attackNo = BATTLE_Index2No( battleindex, charaindex ); + int safeSide = 0; + int MySide_start, MySide_end; + if( attackNo >= 10 ) + safeSide = 1; + + MySide_start = safeSide*SIDE_OFFSET; + MySide_end = ((safeSide*SIDE_OFFSET) + SIDE_OFFSET); + + if( (toindex >= MySide_start) && (toindex= 901 && CHAR_getInt(index2,CHAR_PETID) <= 904){ + // ȡĿ᷽Ľɫindex + masteridx = BATTLE_No2Index(battleindex,toindex-5); + // ս + if(CHAR_getInt(masteridx,CHAR_WHICHTYPE) == CHAR_TYPEPLAYER) PetEscape = 1; + else print("\nʱ"); + } + } + + // ըԼ + if(BATTLE_Index2No(battleindex,charaindex) != toindex) + { + sprintf(szWork,"BB|a%X|w3|r%X|f0|d0|p0|FF|",BATTLE_Index2No(battleindex,charaindex),toindex); + BATTLESTR_ADD(szWork); + if(PetEscape) + { + BATTLE_Exit(index2,battleindex); + CHAR_setInt(masteridx,CHAR_DEFAULTPET,-1); + sprintf(szWork,"BQ|e%X|",toindex); + BATTLESTR_ADD(szWork); + CHAR_talkToCli(masteridx,-1,"ޱˣ",CHAR_COLORWHITE); + CHAR_talkToCli(charaindex,-1,"ޱˣ",CHAR_COLORWHITE); + } + } + CHAR_talkToCli(charaindex,-1,"ʲ¶û",CHAR_COLORWHITE); + CHAR_talkToCli(charaindex,-1,"ʧˡ",CHAR_COLORWHITE); + // ʹʧ + BATTLE_ItemUseDelete(charaindex,haveitemindex); +#endif +} +#endif + +//Terry end + + + + +//״̬ظ,Ӹ(,,) ͬħ(,,),ֻս֮ʹ,û +// :ֵ turn 1 +#ifdef _FEV_ADD_NEW_ITEM // FEV ADD Ӹؾ +void ITEM_ResAndDef( int charaindex, int toindex, int haveitemindex ) +{ + int itemindex, battleindex, attackNo, par = 0, pow = 0, ReceveEffect; + char *buffer = NULL; + char *magicarg = NULL; + char *magicarg2 = NULL; + char *magicarg3 = NULL; + char magicarg4[200]; + + char *pszP = NULL; + char delim[] = " ";//ЭִֽԪ + + int status = -1, i, turn = 3; + char szTurn[] = "turn"; + + // ʧ ةؤ¾ + itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + if(!ITEM_CHECKINDEX(itemindex)) return; + + buffer = ITEM_getChar(itemindex, ITEM_ARGUMENT );//ִ + pszP = strtok(buffer, delim);//һ + magicarg = strtok(NULL, delim);//ڶ + magicarg2 = strtok(NULL, delim);// + magicarg3 = strtok(NULL, delim);//ĸ + sprintf(magicarg4,"%s %s %s",magicarg,magicarg2,magicarg3); + magicarg = (char*)magicarg4; + + //⾵..ʹõз + battleindex = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEINDEX ); + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER + //&& BattleArray[battleindex].type != BATTLE_TYPE_P_vs_P + ){ + if( BATTLE_CheckSameSide( charaindex, toindex) == 0 ){//ͬ + battleindex = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEINDEX ); + BATTLE_NoAction( battleindex, BATTLE_Index2No( battleindex, charaindex) ); + CHAR_talkToCli( charaindex, -1, "⾵..ʩҵз", CHAR_COLORYELLOW); + return; + } + } + + //״̬ظ + if( strstr( pszP, "%" ) ){ + par = 1; + } + + if( sscanf( pszP, "%d", &pow ) != 1 ){ + pow = 0; + } + + attackNo = BATTLE_Index2No( battleindex, charaindex ); + + //ѡЧ + if( pow <= 0 ){ + ReceveEffect = SPR_fukkatu3; + }else + if( pow <= 100 ){ + ReceveEffect = SPR_fukkatu1; + }else + if( pow <= 300 ){ + ReceveEffect = SPR_fukkatu2; + }else{ + ReceveEffect = SPR_fukkatu3; + } + + BATTLE_MultiRessurect( battleindex, attackNo, toindex, + pow, par, SPR_item3, ReceveEffect ); + + + //(,,) + + // ë + for( ;status == -1 && magicarg[0] != 0; magicarg++ ){ + for( i = 1; i < BATTLE_MD_END; i ++ ){ + // + if( strncmp( magicarg, aszMagicDef[i], 2 ) == 0 ){ + status = i; + pszP +=2; + break; + } + } + } + // ئмƥ + if( status == -1 ) return; + + // ϼ ʽ¾ + if( ( magicarg = strstr( magicarg, szTurn ) ) != NULL){ + magicarg += sizeof( szTurn ); + sscanf( magicarg, "%d", &turn ); + } + + //print(":%d",turn); + + // į + battleindex = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEINDEX ); + attackNo = BATTLE_Index2No( battleindex, charaindex ); + + // 幻 + BATTLE_MultiMagicDef( battleindex, attackNo, toindex, + status, turn, MAGIC_EFFECT_USER, SPR_difence ); + + + BATTLE_ItemUseDelete( charaindex, haveitemindex ); + +} + +#endif + + + + + diff --git a/battle/battle_magic.c b/battle/battle_magic.c new file mode 100644 index 0000000..19de874 --- /dev/null +++ b/battle/battle_magic.c @@ -0,0 +1,5438 @@ +#include "version.h" +#include +#include"char.h" +#include"char_base.h" +#include"battle.h" +#include"battle_event.h" +#include"magic_base.h" +#include"battle_magic.h" +#include"item_event.h" +#include"anim_tbl.h" +#include"common.h" +#include"lssproto_serv.h" + +#ifdef _PROFESSION_SKILL // WON ADD ְҵ +#include "profession_skill.h" +#include "skill.h" +#endif + +#ifdef _ATTACK_MAGIC + +extern AttMagic *ATTMAGIC_magic; +extern int ATTMAGIC_magicnum; + +#define AJ_SAME (1.0) +#define AJ_UP (1.5) +#define AJ_DOWN (0.6) + +#define ATTR_MAX 100 +#define D_ATTR (1.0/(ATTR_MAX*ATTR_MAX)) +#ifdef _FIX_MAGICDAMAGE +static int BATTLE_getMagicAdjustInt( int attackindex, int defindex, int MagicLv, int flg,int damage ); +void Magic_ComputeAttExp( int charindex, int Mnum, int MagicLv, int Expoint); +void Magic_ComputeDefExp( int charindex, int Mnum, int MagicLv, int Damage); +#endif + +#ifdef _MAGIC_TOCALL +/* +typedef struct tagToCallMagic +{ + unsigned int uiSpriteNum; // Spr_x.binı + unsigned int uiAttackType; // ķʽˣ( ) , ( ) , ( ͬʱ ) , ȫ( ) , ȫ( ͬʱ ) + unsigned int uiSliceTime; // ʱʱ + unsigned int uiShowType; // ʾλ÷ʽ롢ָ + int siSx; // ʾλ - X + int siSy; // ʾλ - Y + unsigned int uiShowBehindChar; // ʾǰ· + unsigned int uiShakeScreen; // Ƿ𶯻 + unsigned int uiShakeFrom; // 𶯻ʼʱ( ) + unsigned int uiShakeTo; // 𶯻Ľʱ( _ + unsigned int uiPrevMagicNum; // ǰ( 0XFFFFFFFFFF ʾǰ ) + int siPrevMagicSx; // ǰʾλ - X + int siPrevMagicSy; // ǰʾλ - Y + int siPrevMagicOnChar; // ǰʾǰ· + unsigned int uiPostMagicNum; // ( 0XFFFFFFFF ʾ ) + int siPostMagicSx; // ʾλ - X + int siPostMagicSy; // ʾλ - Y + int siPostMagicOnChar; // ʾǰ· + int isPostDisappear; // һ㹥ʱǷʧ + int ToCallMagicNo; // ٻı +}ToCallMagic; +*/ + +ToCallMagic TOCALL_magic[3] = { {100354,0,0,0,50,25,1,0,0,0,101120,65528,65485,0,-1,0,0,0,1,0}, + {100354,1,0,0,50,25,1,0,0,0,101120,65528,65485,0,-1,0,0,0,1,1}, + {100354,5,0,0,0,0,1,1,1000,4000,101120,65528,65485,0,-1,0,0,0,0,2}, + }; + +#endif + +// ħȼ辭ֵ +int Magic_Level_Table[101] = +{ + 1, 3, 6, 10, 15, 21, 28, 36, 45, 55, //lv 1~10 + 66, 78, 91, 105, 120, 136, 153, 171, 190, 210, //lv 11~20 + 231, 253, 276, 300, 325, 351, 378, 406, 435, 465, //lv 21~30 + 496, 528, 561, 595, 630, 666, 703, 741, 780, 820, //lv 31~40 + 861, 903, 946, 990,1035,1081,1128,1176,1225,1275, //lv 41~50 + 1326,1378,1431,1485,1540,1596,1653,1711,1770,1830, //lv 51~60 + 1891,1953,2016,2080,2145,2211,2278,2346,2415,2485, //lv 61~70 + 2556,2628,2701,2775,2850,2926,3003,3081,3160,3240, //lv 71~80 + 3321,3403,3486,3570,3655,3741,3828,3916,4005,4095, //lv 81~90 + 4186,4278,4371,4465,4560,4656,4753,4851,4950,5050, //lv 91~100 + 9999 +}; +#endif + +int BATTLE_MagicEffect( int battleindex, int attackNo, int ToList[], int MyEffect, int ToEffect ) +{ + int i; + char szCommand[256]; + int attackindex; + + attackindex = BATTLE_No2Index( battleindex, attackNo ); + if( CHAR_CHECKINDEX( attackindex ) == FALSE )return 0; + + snprintf( szCommand, sizeof(szCommand), + "BJ|a%X|m%X|e%X|e%X|", + attackNo, + CHAR_getInt( attackindex, CHAR_MP ), + MyEffect, + ToEffect + ); + + + BATTLESTR_ADD( szCommand ); + + for( i = 0; ToList[i] != -1; i ++ ){ + snprintf( szCommand, sizeof(szCommand), "r%X|",ToList[i]); + BATTLESTR_ADD( szCommand ); + } + BATTLESTR_ADD( "FF|" ); + + return 0; +} + +#ifdef _ATTACK_MAGIC + +int BATTLE_AttMagicEffect( int battleindex , int attackNo , int ToList[] , int AttackMgcNo ) +{ + int i; + char szcommand[256]; + int attackindex; + + attackindex = BATTLE_No2Index( battleindex , attackNo ); + if( FALSE == CHAR_CHECKINDEX( attackindex ) ) + return 0; + + if( attackNo >= 10 ) + i = AttackMgcNo * 2; + else + i = AttackMgcNo * 2 + 1; + + snprintf( + szcommand , sizeof( szcommand ) , "BJ|a%X|i%X|m%X|%X|%X|%X|s%X|t%X|l%X|%X|%X|%X|%X|%X|%X|o%X|o%X|o%X|s%X|%X|%X|" , + attackNo , 12345678 , CHAR_getInt( attackindex , CHAR_MP ) , + ATTMAGIC_magic[i].uiPrevMagicNum , + ATTMAGIC_magic[i].uiSpriteNum , + ATTMAGIC_magic[i].uiPostMagicNum , + ATTMAGIC_magic[i].uiAttackType , + ATTMAGIC_magic[i].uiSliceTime , + ATTMAGIC_magic[i].uiShowType , + ATTMAGIC_magic[i].siSx , + ATTMAGIC_magic[i].siSy , + ATTMAGIC_magic[i].siPrevMagicSx , + ATTMAGIC_magic[i].siPrevMagicSy , + ATTMAGIC_magic[i].siPostMagicSx , + ATTMAGIC_magic[i].siPostMagicSy , + ATTMAGIC_magic[i].siPrevMagicOnChar , + ATTMAGIC_magic[i].uiShowBehindChar , + ATTMAGIC_magic[i].siPostMagicOnChar , + ATTMAGIC_magic[i].uiShakeScreen , + ATTMAGIC_magic[i].uiShakeFrom , + ATTMAGIC_magic[i].uiShakeTo + ); + + BATTLESTR_ADD( szcommand ); + + for( i = 0 ; ToList[i] != -1 ; i++ ) + { + snprintf( szcommand , sizeof( szcommand ) , "r%X|" , ToList[i] ); + BATTLESTR_ADD( szcommand ); + } + + BATTLESTR_ADD( "FF|" ); + + return 0; +} + +#endif + + +#ifdef _MAGIC_TOCALL + +int BATTLE_ToCallDragonEffect( int battleindex , int attackNo , int ToList[] , int AttackMgcNo ) +{ + int i; + char szcommand[256]; + int attackindex; + + attackindex = BATTLE_No2Index( battleindex , attackNo ); + if( FALSE == CHAR_CHECKINDEX( attackindex ) ) + return 0; +/* + if( attackNo >= 10 ) + i = AttackMgcNo * 2; + else + i = AttackMgcNo * 2 + 1; +*/ + snprintf( + szcommand , sizeof( szcommand ) , "B$|a%X|i%X|m%X|%X|%X|%X|s%X|t%X|l%X|%X|%X|%X|%X|%X|%X|o%X|o%X|o%X|s%X|%X|%X|%X|%X|" , + attackNo , 5711438 , CHAR_getInt( attackindex , CHAR_MP ) , + TOCALL_magic[AttackMgcNo].uiPrevMagicNum , + TOCALL_magic[AttackMgcNo].uiSpriteNum , + TOCALL_magic[AttackMgcNo].uiPostMagicNum , + TOCALL_magic[AttackMgcNo].uiAttackType , + TOCALL_magic[AttackMgcNo].uiSliceTime , + TOCALL_magic[AttackMgcNo].uiShowType , + TOCALL_magic[AttackMgcNo].siSx , + TOCALL_magic[AttackMgcNo].siSy , + TOCALL_magic[AttackMgcNo].siPrevMagicSx , + TOCALL_magic[AttackMgcNo].siPrevMagicSy , + TOCALL_magic[AttackMgcNo].siPostMagicSx , + TOCALL_magic[AttackMgcNo].siPostMagicSy , + TOCALL_magic[AttackMgcNo].siPrevMagicOnChar , + TOCALL_magic[AttackMgcNo].uiShowBehindChar , + TOCALL_magic[AttackMgcNo].siPostMagicOnChar , + TOCALL_magic[AttackMgcNo].uiShakeScreen , + TOCALL_magic[AttackMgcNo].uiShakeFrom , + TOCALL_magic[AttackMgcNo].uiShakeTo , + TOCALL_magic[AttackMgcNo].isPostDisappear , + TOCALL_magic[AttackMgcNo].ToCallMagicNo + ); + + BATTLESTR_ADD( szcommand ); + + for( i = 0 ; ToList[i] != -1 ; i++ ) + { + snprintf( szcommand , sizeof( szcommand ) , "r%X|" , ToList[i] ); + BATTLESTR_ADD( szcommand ); + } + + BATTLESTR_ADD( "FF|" ); + + return 0; +} + +#endif +#ifdef _IMPRECATE_ITEM +void BATTLE_ImprecateRecovery( + int battleindex, int attackNo, int toNo, int kind, int powers, + int rounds, int UseEffect, int RecevEffect ) +{ + int i, toindex, flg; + int ToList[SIDE_OFFSET*2+1]; + //char szBuffer[256]=""; + BATTLE_MultiList( battleindex, toNo, ToList ); + + BATTLE_MagicEffect( + battleindex, attackNo, ToList, + UseEffect, RecevEffect ); + for( i = 0; ToList[i] != -1; i ++ ){ + toindex = BATTLE_No2Index( battleindex, ToList[i] ); + if( CHAR_CHECKINDEX( toindex ) == FALSE )continue; + switch( kind ){ +#ifdef _IMPRECATE_ITEM + case BD_KIND_CURSE: + if( CHAR_getWorkInt( toindex, CHAR_WORKIMPRECATENUM1 ) <= 0 && + CHAR_getInt( toindex, CHAR_WHICHTYPE) == CHAR_TYPEPLAYER ) { + CHAR_setWorkInt( toindex, CHAR_WORKHURTMP, powers); //˺ MP + CHAR_setWorkInt( toindex, CHAR_WORKIMPRECATENUM1, rounds); + } + break; + case BD_KIND_BESTOW: + if( CHAR_getWorkInt( toindex, CHAR_WORKIMPRECATENUM2 ) <= 0 ){ +#ifdef _TYPE_TOXICATION + if( CHAR_CanCureFlg( toindex, "HP") == FALSE ) break; +#endif + CHAR_setWorkInt( toindex, CHAR_WORKWISHESHP, powers); //ף hp + CHAR_setWorkInt( toindex, CHAR_WORKIMPRECATENUM2, rounds); + } + break; + case BD_KIND_WISHES: + if( CHAR_getWorkInt( toindex, CHAR_WORKIMPRECATENUM3 ) <= 0 && + CHAR_getInt( toindex, CHAR_WHICHTYPE) == CHAR_TYPEPLAYER ) { + CHAR_setWorkInt( toindex, CHAR_WORKWISHESMP, powers); //ף MP + CHAR_setWorkInt( toindex, CHAR_WORKIMPRECATENUM3, rounds); + } + break; +#endif + } + //BATTLE_BroadCast( battleindex, szBuffer, + // (attackNo >= 10)? CHAR_COLORGRAY : CHAR_COLORPURPLE ) ; + if( BattleArray[battleindex].norisk == 0 + && CHAR_getInt( toindex, CHAR_WHICHTYPE ) == CHAR_TYPEPET){ + flg = CHAR_getWorkInt( toindex, CHAR_WORKBATTLEFLG ); + if( flg & CHAR_BATTLEFLG_RECOVERY ){ + }else{ + CHAR_PetAddVariableAi( toindex, AI_FIX_PETRECOVERY ); + CHAR_setWorkInt( toindex, CHAR_WORKBATTLEFLG, flg | CHAR_BATTLEFLG_RECOVERY ); + } + } + } + return; +} +#endif + +void BATTLE_MultiRecovery( + int battleindex, + int attackNo, + int toNo, + int kind, + int power, + int per, + int UseEffect, + int RecevEffect +) +{ + int i, toindex, UpPoint = 0, workhp, oldhp, flg; + int ToList[SIDE_OFFSET*2+1]; + + //char szBuffer[256]=""; + char szCommand[256]; + + int ridepet, petUpPoint =0; + + + BATTLE_MultiList( battleindex, toNo, ToList ); + + BATTLE_MagicEffect( battleindex, attackNo, ToList, UseEffect, RecevEffect ); + + for( i = 0; ToList[i] != -1; i ++ ){ + toindex = BATTLE_No2Index( battleindex, ToList[i] ); + + if( CHAR_CHECKINDEX( toindex ) == FALSE ) continue; + + ridepet = BATTLE_getRidePet( toindex ); + + switch( kind ){ +#ifdef _ITEM_UNBECOMEPIG + case BD_KIND_UNBECOMEPIG: + if( CHAR_getInt( toindex, CHAR_BECOMEPIG ) > -1 ){ + CHAR_setInt( toindex, CHAR_BECOMEPIG, -1 ); + CHAR_setInt( toindex, CHAR_BASEIMAGENUMBER, CHAR_getInt( toindex, CHAR_BASEBASEIMAGENUMBER)); + CHAR_complianceParameter( toindex ); + CHAR_sendCToArroundCharacter( CHAR_getWorkInt( toindex , CHAR_WORKOBJINDEX )); + CHAR_send_P_StatusString( toindex , CHAR_P_STRING_BASEBASEIMAGENUMBER); + CHAR_talkToCli( toindex,-1,"ʧЧˡ",CHAR_COLORWHITE); + } + break; +#endif +#ifdef _ITEM_PROPERTY + case BD_KIND_PROPERTY: + { + if (CHAR_getInt(toindex, CHAR_WHICHTYPE)!=CHAR_TYPEPLAYER) + return; + //print("ˮ:%d %d %d %d", CHAR_getInt( toindex, CHAR_EARTHAT ), CHAR_getInt( toindex, CHAR_WATERAT ), CHAR_getInt( toindex, CHAR_FIREAT ), CHAR_getInt( toindex, CHAR_WINDAT ) ); + if( power == 1 ){//ת ת + if( CHAR_getInt( toindex, CHAR_EARTHAT ) == 100 ) + CHAR_setInt( toindex, CHAR_EARTHAT, CHAR_getInt( toindex, CHAR_EARTHAT )-10 ), + CHAR_setInt( toindex, CHAR_WATERAT, CHAR_getInt( toindex, CHAR_WATERAT )+10 ); + else if( CHAR_getInt( toindex, CHAR_WATERAT ) == 100 ) + CHAR_setInt( toindex, CHAR_WATERAT, CHAR_getInt( toindex, CHAR_WATERAT )-10 ), + CHAR_setInt( toindex, CHAR_FIREAT, CHAR_getInt( toindex, CHAR_FIREAT )+10 ); + else if( CHAR_getInt( toindex, CHAR_FIREAT ) == 100 ) + CHAR_setInt( toindex, CHAR_FIREAT, CHAR_getInt( toindex, CHAR_FIREAT )-10 ), + CHAR_setInt( toindex, CHAR_WINDAT, CHAR_getInt( toindex, CHAR_WINDAT )+10 ); + else if( CHAR_getInt( toindex, CHAR_WINDAT ) == 100 ) + CHAR_setInt( toindex, CHAR_WINDAT, CHAR_getInt( toindex, CHAR_WINDAT )-10 ), + CHAR_setInt( toindex, CHAR_EARTHAT, CHAR_getInt( toindex, CHAR_EARTHAT )+10 ); + else if( CHAR_getInt( toindex, CHAR_EARTHAT ) > 0 && CHAR_getInt( toindex, CHAR_WATERAT ) > 0 ) + CHAR_setInt( toindex, CHAR_EARTHAT, CHAR_getInt( toindex, CHAR_EARTHAT )-10 ), + CHAR_setInt( toindex, CHAR_WATERAT, CHAR_getInt( toindex, CHAR_WATERAT )+10 ); + else if( CHAR_getInt( toindex, CHAR_WATERAT ) > 0 && CHAR_getInt( toindex, CHAR_FIREAT ) > 0 ) + CHAR_setInt( toindex, CHAR_WATERAT, CHAR_getInt( toindex, CHAR_WATERAT )-10 ), + CHAR_setInt( toindex, CHAR_FIREAT, CHAR_getInt( toindex, CHAR_FIREAT )+10 ); + else if( CHAR_getInt( toindex, CHAR_FIREAT ) > 0 && CHAR_getInt( toindex, CHAR_WINDAT ) > 0 ) + CHAR_setInt( toindex, CHAR_FIREAT, CHAR_getInt( toindex, CHAR_FIREAT )-10 ), + CHAR_setInt( toindex, CHAR_WINDAT, CHAR_getInt( toindex, CHAR_WINDAT )+10 ); + else if( CHAR_getInt( toindex, CHAR_WINDAT ) > 0 && CHAR_getInt( toindex, CHAR_EARTHAT ) > 0 ) + CHAR_setInt( toindex, CHAR_WINDAT, CHAR_getInt( toindex, CHAR_WINDAT )-10 ), + CHAR_setInt( toindex, CHAR_EARTHAT, CHAR_getInt( toindex, CHAR_EARTHAT )+10 ); + } + if( power == 2 ){//ת ת + if( CHAR_getInt( toindex, CHAR_EARTHAT ) == 100 ) + CHAR_setInt( toindex, CHAR_EARTHAT, CHAR_getInt( toindex, CHAR_EARTHAT )-10 ), + CHAR_setInt( toindex, CHAR_WINDAT, CHAR_getInt( toindex, CHAR_WINDAT )+10 ); + else if( CHAR_getInt( toindex, CHAR_WATERAT ) == 100 ) + CHAR_setInt( toindex, CHAR_WATERAT, CHAR_getInt( toindex, CHAR_WATERAT )-10 ), + CHAR_setInt( toindex, CHAR_EARTHAT, CHAR_getInt( toindex, CHAR_EARTHAT )+10 ); + else if( CHAR_getInt( toindex, CHAR_FIREAT ) == 100 ) + CHAR_setInt( toindex, CHAR_FIREAT, CHAR_getInt( toindex, CHAR_FIREAT )-10 ), + CHAR_setInt( toindex, CHAR_WATERAT, CHAR_getInt( toindex, CHAR_WATERAT )+10 ); + else if( CHAR_getInt( toindex, CHAR_WINDAT ) == 100 ) + CHAR_setInt( toindex, CHAR_WINDAT, CHAR_getInt( toindex, CHAR_WINDAT )-10 ), + CHAR_setInt( toindex, CHAR_FIREAT, CHAR_getInt( toindex, CHAR_FIREAT )+10 ); + else if( CHAR_getInt( toindex, CHAR_EARTHAT ) > 0 && CHAR_getInt( toindex, CHAR_WATERAT ) > 0 ) + CHAR_setInt( toindex, CHAR_EARTHAT, CHAR_getInt( toindex, CHAR_EARTHAT )+10 ), + CHAR_setInt( toindex, CHAR_WATERAT, CHAR_getInt( toindex, CHAR_WATERAT )-10 ); + else if( CHAR_getInt( toindex, CHAR_WATERAT ) > 0 && CHAR_getInt( toindex, CHAR_FIREAT ) > 0 ) + CHAR_setInt( toindex, CHAR_WATERAT, CHAR_getInt( toindex, CHAR_WATERAT )+10 ), + CHAR_setInt( toindex, CHAR_FIREAT, CHAR_getInt( toindex, CHAR_FIREAT )-10 ); + else if( CHAR_getInt( toindex, CHAR_FIREAT ) > 0 && CHAR_getInt( toindex, CHAR_WINDAT ) > 0 ) + CHAR_setInt( toindex, CHAR_FIREAT, CHAR_getInt( toindex, CHAR_FIREAT )+10 ), + CHAR_setInt( toindex, CHAR_WINDAT, CHAR_getInt( toindex, CHAR_WINDAT )-10 ); + else if( CHAR_getInt( toindex, CHAR_WINDAT ) > 0 && CHAR_getInt( toindex, CHAR_EARTHAT ) > 0 ) + CHAR_setInt( toindex, CHAR_WINDAT, CHAR_getInt( toindex, CHAR_WINDAT )+10 ), + CHAR_setInt( toindex, CHAR_EARTHAT, CHAR_getInt( toindex, CHAR_EARTHAT )-10 ); + } + } +#endif + case BD_KIND_HP: +#ifdef _TYPE_TOXICATION + if( CHAR_CanCureFlg( toindex, "HP") == FALSE ) continue; +#endif + // Robin 0728 ride Pet + if( ridepet == -1 ) { + UpPoint = RAND( (power*0.9), (power*1.1) ); +#ifdef _MAGIC_REHPAI +#else + if( per ){ + UpPoint *= CHAR_getWorkInt( toindex, CHAR_WORKMAXHP ) * 0.01; + } + UpPoint *= GetRecoveryRate( toindex ); +#endif + workhp = CHAR_getInt( toindex, CHAR_HP ); + oldhp = workhp; + workhp += (int)UpPoint; + CHAR_setInt( toindex, CHAR_HP, + min( workhp, CHAR_getWorkInt( toindex, CHAR_WORKMAXHP ) ) ); + + //snprintf( szBuffer, sizeof(szBuffer), "(%s);ظ(%d)", CHAR_getUseName( toindex ), UpPoint ); + + }else { + int allUpPoint; + UpPoint = RAND( (power*0.9), (power*1.1) ); +#ifdef _MAGIC_REHPAI + allUpPoint = UpPoint; + UpPoint = (allUpPoint * Magic_RideGetHP( toindex, ridepet, 1 ))/100; + petUpPoint = allUpPoint - UpPoint; +#else + petUpPoint = UpPoint; + if( per ){ + UpPoint *= CHAR_getWorkInt( toindex, CHAR_WORKMAXHP ) * 0.01; + petUpPoint *= CHAR_getWorkInt( ridepet, CHAR_WORKMAXHP ) * 0.01; + + } + UpPoint *= GetRecoveryRate( toindex ); + petUpPoint *= GetRecoveryRate( ridepet ); +#endif + + + allUpPoint = UpPoint + petUpPoint; +#ifdef _MAGIC_REHPAI +#else + UpPoint = (UpPoint * UpPoint) / allUpPoint; + petUpPoint = (petUpPoint * petUpPoint) / allUpPoint; +#endif + workhp = CHAR_getInt( toindex, CHAR_HP ); + oldhp = workhp; + workhp += (int)UpPoint; + CHAR_setInt( toindex, CHAR_HP, + min( workhp, CHAR_getWorkInt( toindex, CHAR_WORKMAXHP ) ) ); + workhp = CHAR_getInt( ridepet, CHAR_HP ); + oldhp = workhp; + workhp += (int)petUpPoint; + CHAR_setInt( ridepet, CHAR_HP, + min( workhp, CHAR_getWorkInt( ridepet, CHAR_WORKMAXHP ) ) ); + //snprintf( szBuffer, sizeof(szBuffer), + // "(%s);ظ(%d),(%s);ظ(%d)", + // CHAR_getUseName( toindex ), + // UpPoint, + // CHAR_getUseName( toindex ), + // petUpPoint + // ); + } + break; + case BD_KIND_MP: + UpPoint = RAND( (power*0.9), (power*1.1) ); + if( per ){ + UpPoint *= CHAR_getWorkInt( toindex, CHAR_WORKMAXMP ) * 0.01; + } + workhp = CHAR_getInt( toindex, CHAR_MP ); + oldhp = workhp; + workhp += (int)UpPoint; + CHAR_setInt( toindex, CHAR_MP, + min( workhp, CHAR_getWorkInt( toindex, CHAR_WORKMAXMP ) ) ); + //snprintf( szBuffer, sizeof(szBuffer), + // "(%s)ظ(%d)", + // CHAR_getUseName( toindex ), + // UpPoint + // ); + break; + } + //BATTLE_BroadCast( battleindex, szBuffer, + // (attackNo >= 10)? CHAR_COLORGRAY : CHAR_COLORPURPLE ) ; + { + int Sign, Damage, petDamage; + Sign = (UpPoint >= 0)?(1):(0); + Damage = ABS( UpPoint ); + petDamage = ABS( petUpPoint ); +#ifdef _NOTRIDE_ + snprintf( szCommand, sizeof(szCommand), + "BD|r%X|%X|%X|d%X|", ToList[i], kind, Sign, Damage ); +#else + snprintf( szCommand, sizeof(szCommand), + "BD|r%X|%X|%X|d%X|p%X|", ToList[i], kind, Sign, Damage, petDamage ); +#endif //_NOTRIDE_ + BATTLESTR_ADD( szCommand ); + } + + if( BattleArray[battleindex].norisk == 0 + && CHAR_getInt( toindex, CHAR_WHICHTYPE ) == CHAR_TYPEPET){ + flg = CHAR_getWorkInt( toindex, CHAR_WORKBATTLEFLG ); + if( flg & CHAR_BATTLEFLG_RECOVERY ){ + }else{ + CHAR_PetAddVariableAi( toindex, AI_FIX_PETRECOVERY ); + CHAR_setWorkInt( toindex, CHAR_WORKBATTLEFLG, flg | CHAR_BATTLEFLG_RECOVERY ); + } + } + } + return; +} + +#ifdef _MAGIC_REHPAI +int Magic_RideGetHP( int toindex, int petindex, int flg) +{ + int allDHp=1; + int petDHp=1; + int CharDHp=1; + int ISIZE = 100; + + CharDHp = CHAR_getWorkInt( toindex, CHAR_WORKMAXHP ) - CHAR_getInt( toindex, CHAR_HP); + petDHp = CHAR_getWorkInt( petindex, CHAR_WORKMAXHP ) - CHAR_getInt( petindex, CHAR_HP); + allDHp = (CharDHp + petDHp); + + if( allDHp <= 0 ) allDHp=1; + if( flg == 1) + return (int)((CharDHp*ISIZE)/allDHp); + else + return (int)((petDHp*ISIZE)/allDHp); +} +#endif + +int MAGIC_Recovery_Battle( int charaindex, int toNo, int marray, int mp ) +{ + char *magicarg; + float power; + int battleindex, attackNo, HealedEffect = 0, per = 0; + int range; + if( !CHAR_CHECKINDEX( charaindex) ) return FALSE; + battleindex = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEINDEX ); + attackNo = BATTLE_Index2No( battleindex, charaindex ); + +#if 1 // Robin fix MagicΧ + range = MAGIC_getInt( marray, MAGIC_TARGET ); + //print(" MAGIC_TARGET:%d toNo:%d ", range, toNo); + if( range == 0 && toNo != attackNo ) { // ֻܶԼʹ +// print("\n ķ!MAGICֻܶԼʹ!!:%s ", CHAR_getChar( charaindex, CHAR_CDKEY) ); + return FALSE; + } + if( range == 1 && toNo >= 20 ) { // ֻܶԵʹ +// print("\n ķ!MAGICֻܶԵʹ!!:%s ", CHAR_getChar( charaindex, CHAR_CDKEY) ); + return FALSE; + } +#endif + + // shan(ȫʹħbug)޸jinchao+2001/12/07 + if( BATTLE_CHECKINDEX( battleindex ) == FALSE ) return FALSE; + magicarg = MAGIC_getChar( marray, MAGIC_OPTION ); + // shan(ȫʹħbug)޸jinchao+2001/12/07 + if (magicarg == "\0") return FALSE; + + power = atoi( magicarg ); + if( strstr( magicarg, "%" ) ){ + per = 1; + } + + if( power <= 100 ){ + HealedEffect = SPR_heal; + }else + if( power <= 300 ){ + HealedEffect = SPR_heal2; + }else{ + HealedEffect = SPR_heal3; + } + BATTLE_MultiRecovery( battleindex, attackNo, toNo,BD_KIND_HP, (int)power, per, MAGIC_EFFECT_USER, HealedEffect ); + return TRUE; +} + +void BATTLE_MultiResAndDef( + int battleindex, // ̼͵ + int attackNo, // į + int toNo, // ľ į + int power, // + int per, // Ѿ + int kind, // ܷ + int count, // ϼ ʲ + int UseEffect, // мް + int RecevEffect // ľмް +) +{ + int i, toindex, charaindex, UpPoint = 0, workhp; + int ToList[SIDE_OFFSET*2+1]; + + //char szBuffer[256]=""; + char szCommand[256]; + + + BATTLE_MultiListDead( battleindex, toNo, ToList ); + + BATTLE_MagicEffect( + battleindex, // ̼͵ + attackNo, // į( ) + ToList, // ľ į( ) + UseEffect, // оް + RecevEffect // ľоް + ); + charaindex = BATTLE_No2Index( battleindex, attackNo ); + for( i = 0; ToList[i] != -1; i ++ ){ + toindex = BATTLE_No2Index( battleindex, ToList[i] ); + if( BattleArray[battleindex].type == BATTLE_TYPE_P_vs_P + && CHAR_getInt( toindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER){ + continue; + } + if( CHAR_getFlg( toindex, CHAR_ISDIE ) == FALSE ){ + continue; + } + UpPoint = power; +#ifdef _MAGIC_REHPAI +#else + if( per ){ + UpPoint *= CHAR_getWorkInt( toindex, CHAR_WORKMAXHP ) * 0.01; + } +#endif + if( power == 0 ){ + UpPoint = CHAR_getWorkInt( toindex, CHAR_WORKMAXHP ); + }else{ + UpPoint = RAND( (power*0.9), (power*1.1) ); + } + UpPoint = max( 1, UpPoint ); + workhp = CHAR_getInt( toindex, CHAR_HP ) + UpPoint; + CHAR_setInt( toindex, CHAR_HP, + min( workhp, CHAR_getWorkInt( toindex, CHAR_WORKMAXHP ) ) ); + CHAR_setFlg( toindex, CHAR_ISDIE, 0 ); + CHAR_setWorkInt( toindex, MagicDefTbl[kind], count ); + + //snprintf( szBuffer, sizeof(szBuffer), + // "(%s)ָʶ", + // CHAR_getUseName( toindex ) ); + //snprintf( szBuffer, sizeof(szBuffer), + // "(%s)(%s)(%s)", + // CHAR_getUseName( charaindex ), + // CHAR_getUseName( toindex ), + // aszMagicDefFull[kind] + //); + //BATTLE_BroadCast( battleindex, szBuffer, + // (attackNo >= 10)? CHAR_COLORGRAY : CHAR_COLORPURPLE ) ; + snprintf( szCommand, sizeof(szCommand), + "BL|r%X|h%X|", ToList[i], CHAR_getInt( toindex, CHAR_HP ) ); + BATTLESTR_ADD( szCommand ); + if( BattleArray[battleindex].norisk == 0 + && BattleArray[battleindex].type == BATTLE_TYPE_P_vs_E ){ + if( CHAR_getInt( toindex, CHAR_WHICHTYPE ) == CHAR_TYPEPET ){ + CHAR_PetAddVariableAi( toindex, AI_FIX_PETRESSURECT ); + } + } + } +} + +#ifdef _ATTACK_MAGIC + +static int CharTable[4][5] = +{ + { 13 , 11 , 10 , 12 , 14 } , + { 18 , 16 , 15 , 17 , 19 } , + { 8 , 6 , 5 , 7 , 9 } , + { 3 , 1 , 0 , 2 , 4 } +}; + +static int CharTableIdx[20][2] = +{ + { 3 , 2 } , { 3 , 1 } , { 3 , 3 } , { 3 , 0 } , { 3 , 4 } , + { 2 , 2 } , { 2 , 1 } , { 2 , 3 } , { 2 , 0 } , { 2 , 4 } , + { 0 , 2 } , { 0 , 1 } , { 0 , 3 } , { 0 , 0 } , { 0 , 4 } , + { 1 , 2 } , { 1 , 1 } , { 1 , 3 } , { 1 , 0 } , { 1 , 4 } +}; + + + +typedef int ( *FUNC )( const void* , const void* ); + +static int SortLoc( const int *pEle1 , const int *pEle2 ) +{ + int ele1basex , ele1basey; + int ele2basex , ele2basey; + + ele1basex = CharTableIdx[*pEle1][1]; + ele1basey = CharTableIdx[*pEle1][0]; + ele2basex = CharTableIdx[*pEle2][1]; + ele2basey = CharTableIdx[*pEle2][0]; + + // Ϸ + if( *pEle1 >= 10 ) + { + if( ele1basey != ele2basey ) + return ( ele1basey - ele2basey ); + + return ( ele1basex - ele2basex ); + } + // · + else + { + if( ele1basey != ele2basey ) + return ( ele2basey - ele1basey ); + + return ( ele2basex - ele1basey ); + } + + return 0; +} + + +static void BATTLE_GetAttr( int charaindex , int *pAt_Fire , int *pAt_Water , int *pAt_Earth , int *pAt_Wind , int *pAt_None ) +{ + + int petindex = BATTLE_getRidePet( charaindex ); + + if( petindex == -1 ) + { + *pAt_Fire = CHAR_getWorkInt( charaindex , CHAR_WORKFIXFIREAT ); + *pAt_Water = CHAR_getWorkInt( charaindex , CHAR_WORKFIXWATERAT ); + *pAt_Earth = CHAR_getWorkInt( charaindex , CHAR_WORKFIXEARTHAT ); + *pAt_Wind = CHAR_getWorkInt( charaindex , CHAR_WORKFIXWINDAT ); + } + else + { + *pAt_Fire = ( CHAR_getWorkInt( charaindex , CHAR_WORKFIXFIREAT ) + + CHAR_getWorkInt( petindex , CHAR_WORKFIXFIREAT ) ) / 2; + *pAt_Water = ( CHAR_getWorkInt( charaindex , CHAR_WORKFIXWATERAT ) + + CHAR_getWorkInt( petindex , CHAR_WORKFIXWATERAT ) ) / 2; + *pAt_Earth = ( CHAR_getWorkInt( charaindex , CHAR_WORKFIXEARTHAT ) + + CHAR_getWorkInt( petindex , CHAR_WORKFIXEARTHAT ) ) / 2; + *pAt_Wind = ( CHAR_getWorkInt( charaindex , CHAR_WORKFIXWINDAT ) + + CHAR_getWorkInt( petindex , CHAR_WORKFIXWINDAT ) ) / 2; + } + + if( *pAt_Fire < 0 ) *pAt_Fire = 0; + if( *pAt_Water < 0 ) *pAt_Water = 0; + if( *pAt_Earth < 0 ) *pAt_Earth = 0; + if( *pAt_Wind < 0 ) *pAt_Wind = 0; + + *pAt_None = 100 - *pAt_Fire - *pAt_Water - *pAt_Earth - *pAt_Wind; + + if( *pAt_None < 0 ) + *pAt_None = 0; +} + +static void BATTLE_GetPureAttr( int charaindex , int *pAt_Fire , int *pAt_Water, int *pAt_Earth , int *pAt_Wind ) +{ + *pAt_Fire = CHAR_getWorkInt( charaindex , CHAR_WORKFIXFIREAT ); + *pAt_Water = CHAR_getWorkInt( charaindex , CHAR_WORKFIXWATERAT ); + *pAt_Earth = CHAR_getWorkInt( charaindex , CHAR_WORKFIXEARTHAT ); + *pAt_Wind = CHAR_getWorkInt( charaindex , CHAR_WORKFIXWINDAT ); + + if( *pAt_Fire < 0 ) *pAt_Fire = 0; + if( *pAt_Water < 0 ) *pAt_Water = 0; + if( *pAt_Earth < 0 ) *pAt_Earth = 0; + if( *pAt_Wind < 0 ) *pAt_Wind = 0; +} + + + +int BATTLE_CalAttMagicEffect( int AttEle , int DefPosEleValue , int DefNegEleValue ) +{ + int value; + + value = ( 100 * DefPosEleValue - 100 * DefNegEleValue ) / 1000; + + if( value > 10 ) + return 10; + else if( value < -10 ) + return -10; + + return value; +} + + + +int BATTLE_CalcCharaRatio( int AttEle , int charaidx ) +{ + int petidx , charahurt , pethurt; + int charaattr[4] , petattr[4]; + + // ûг + if( -1 == ( petidx = BATTLE_getRidePet( charaidx ) ) ) + return 10; + + // Nuke 20040330: Fix bug + if ( -1 == AttEle ) + return 5; + + BATTLE_GetPureAttr( charaidx , &charaattr[2] , &charaattr[1] , &charaattr[0], &charaattr[3] ); + BATTLE_GetPureAttr( petidx , &petattr[2] , &petattr[1] , &petattr[0] , &petattr[3] ); + + //print("\nAttEle: %d %d %d %d %d ",AttEle, charaattr[( AttEle + 1 ) % 4], charaattr[AttEle],petattr[( AttEle + 1 ) %4] , petattr[AttEle]); + + charahurt = 20 + BATTLE_CalAttMagicEffect( AttEle , charaattr[( AttEle + 1 ) % 4] , charaattr[AttEle] ); + pethurt = 20 + BATTLE_CalAttMagicEffect( AttEle , petattr[( AttEle + 1 ) %4] , petattr[AttEle] ); + + charahurt = 10 * charahurt / ( charahurt + pethurt ); + + if( charahurt < 2 ) + return 2; + else if( charahurt > 8 ) + return 8; + + return charahurt; +} + +static int BATTLE_AttrCalc( + int My_Fire, // д(ĤҰ»õ) + int My_Water, + int My_Earth, + int My_Wind, + int My_None, + int Vs_Fire, // 촡 + int Vs_Water, + int Vs_Earth, + int Vs_Wind, + int Vs_None +) +{ + int iRet = 0; + + // ܼ £ + My_Fire = My_Fire * Vs_None * AJ_UP // + + My_Fire * Vs_Fire * AJ_SAME // Ԫ + + My_Fire * Vs_Water * AJ_DOWN // + + My_Fire * Vs_Earth * AJ_SAME // Ԫ + + My_Fire * Vs_Wind * AJ_UP; // + + // £ + My_Water = My_Water * Vs_None * AJ_UP // + + My_Water * Vs_Fire * AJ_UP // + + My_Water * Vs_Water * AJ_SAME // Ԫ + + My_Water * Vs_Earth * AJ_DOWN // + + My_Water * Vs_Wind * AJ_SAME; // Ԫ + + // + My_Earth = My_Earth * Vs_None * AJ_UP // + + My_Earth * Vs_Fire * AJ_SAME // Ԫ + + My_Earth * Vs_Water * AJ_UP // + + My_Earth * Vs_Earth * AJ_SAME // Ԫ + + My_Earth * Vs_Wind * AJ_DOWN; // + + // + My_Wind = My_Wind * Vs_None * AJ_UP // + + My_Wind * Vs_Fire * AJ_DOWN // + + My_Wind * Vs_Water * AJ_SAME // Ԫ + + My_Wind * Vs_Earth * AJ_UP // + + My_Wind * Vs_Wind * AJ_SAME; // Ԫ + + // + My_None = My_None * Vs_None * AJ_SAME // Ԫ + + My_None * Vs_Fire * AJ_DOWN // + + My_None * Vs_Water * AJ_DOWN // + + My_None * Vs_Earth * AJ_DOWN // + + My_None * Vs_Wind * AJ_DOWN; // + + // + iRet = (My_Fire + My_Water + My_Earth + My_Wind + My_None) ; + + // ңȾԻƥ ئ׼ƥг + return (iRet * D_ATTR); +} + +extern float BATTLE_FieldAttAdjust(int battleindex,int pAt_Fire,int pAt_Water,int pAt_Earth,int pAt_Wind); +#ifndef _FIX_MAGICDAMAGE +static int BATTLE_AttrAdjust( + int attackindex, + int defindex, + int damage +) +{ + int At_Fire, At_Earth, At_Water, At_Wind, At_none; + int Df_Fire, Df_Earth, Df_Water, Df_Wind, Df_none; + float At_FieldPow, Df_FieldPow; + + BATTLE_GetAttr(attackindex,&At_Fire,&At_Water,&At_Earth,&At_Wind,&At_none); + + At_FieldPow = BATTLE_FieldAttAdjust( + CHAR_getWorkInt( attackindex, CHAR_WORKBATTLEINDEX ), + At_Fire, At_Water, At_Earth, At_Wind ); + + At_Fire *= damage; At_Water *= damage; At_Earth *= damage; + At_Wind *= damage; At_none *= damage; + BATTLE_GetAttr( defindex, &Df_Fire, &Df_Water, + &Df_Earth,&Df_Wind, &Df_none ); + Df_FieldPow = BATTLE_FieldAttAdjust( + CHAR_getWorkInt( defindex, CHAR_WORKBATTLEINDEX ), + Df_Fire, Df_Water, Df_Earth, Df_Wind ); + damage = BATTLE_AttrCalc( + At_Fire, At_Water, At_Earth, At_Wind, At_none, + Df_Fire, Df_Water, Df_Earth, Df_Wind, Df_none ); + damage *= (At_FieldPow / Df_FieldPow); + return damage; +} +#endif +// +// return: 0:û 1: +int BATTLE_MagicDodge(int charindex,int nDefKind,int nFieldAttr) +{ + float fLuck = 0,fResist = 0; +#ifdef _EQUIT_DEFMAGIC + float Dluck=0.0; +#endif + int charType = CHAR_getInt( charindex, CHAR_WHICHTYPE); + // Ƿ + if( charType == CHAR_TYPEPLAYER ){ + fLuck = (float)CHAR_getInt( charindex, CHAR_LUCK) * 3; + fResist = (float)CHAR_getInt( charindex, CHAR_EARTH_RESIST + nFieldAttr) * 0.15; + fLuck += fResist; +#ifdef _EQUIT_DEFMAGIC + Dluck = (float)(CHAR_getWorkInt( charindex, CHAR_EQUITQUIMAGIC)*0.9); + fLuck += Dluck; +#endif + }else {// Ƿdz + fLuck = (float)CHAR_getInt( charindex, CHAR_LV) * 0.2; + if(fLuck > 30) fLuck = 30; + } + if(rand()%100+1 > (int)fLuck) + return 0; + else + return 1; +} + + +#define DEF_MAGIC_NUM 4 + +extern void BATTLE_changeRideImage( int index ); + +#ifdef _FIX_MAGICDAMAGE +void BATTLE_MultiAttMagic( int battleindex, int attackNo, int toNo, + int attIdx ,int FieldAttr ,int Power, int MagicLv) +#else +void BATTLE_MultiAttMagic( int battleindex, int attackNo, int toNo , int attIdx, + int FieldAttr , int Power) +#endif +{ + int list[SIDE_OFFSET * 2 + 1]; + int listidx,i,j,k,z; + int basex , basey , magicattidx,def_is_player[10],def_be_hit[10]; + int att_magic_lv[4]; + int def_magic_resist[DEF_MAGIC_NUM]; + int attvalue , charahp , pethp , charaidx , petidx , charahurt,pet_att_lv = 1,pet_def_lv = 1,charahurt_temp; + char szcommand[256]; + int AttIsPlayer=0,DefIsPlayer=0; + int getexp = 0; + +#ifndef _FIX_MAGICDAMAGE + int att_magic_exp_add,att_magic_exp_sub,def_magic_exp_add,def_magic_exp_sub; + int lv_up_exp,DefFieldAttr = 0; + float temp = 0.0f; +// int attattr[5], defattr[5]; + char msgbuf[64]; + char kind[4][3] = {"","ˮ","",""}; +#else + BOOL TrueMagic=FALSE; +#endif + + // terry + + if((z = BATTLE_MultiList(battleindex,toNo,list)) == -1) + return; + else + { + if(z != toNo) toNo = z; + } + BATTLE_AttMagicEffect( battleindex , attackNo , list , attIdx ); + // 㹥嵥 + if( attackNo < 10 ) + magicattidx = attIdx * 2 + 1; + else + magicattidx = attIdx * 2; + listidx = 0; + memset(def_is_player,-1,sizeof(def_is_player)); + memset(def_be_hit,-1,sizeof(def_be_hit)); + // ˹ + if( toNo < 20 ){ + toNo = list[0]; + basex = CharTableIdx[toNo][1]; + basey = CharTableIdx[toNo][0]; + + for( i = 0 , j = basey - 1 ; j <= basey + 1 ; i++ , j++ ){ + if( toNo < 10 && ( j < 2 || j > 3 ) ) + continue; + else if( toNo >= 10 && ( j < 0 || j > 1 ) ) + continue; + // ЩҪ嵥 + for( k = 0 ; k < 5 ; k++ ){ + if( basex - 2 + k < 0 || basex - 2 + k > 4 ) + continue; + + if( ATTMAGIC_magic[magicattidx].siField[i][k] && TRUE == BATTLE_TargetCheck( battleindex , CharTable[j][basex - 2 + k] ) ) + { + list[listidx] = CharTable[j][basex - 2 + k]; + listidx++; + } + } + } + }else if( 20 == toNo ){ // ȫ + for( i = 0 ; i < 2 ; i++ ){ + for( j = 0 ; j < 5 ; j++ ){ + if( ATTMAGIC_magic[magicattidx].siField[i][j] && TRUE == BATTLE_TargetCheck( battleindex , CharTable[i + 2][j] ) ){ + list[listidx] = CharTable[i + 2][j]; + listidx++; + } + } + } + }else if( 21 == toNo ){ // ȫ + for( i = 0 ; i < 2 ; i++ ){ + for( j = 0 ; j < 5 ; j++ ){ + if( ATTMAGIC_magic[magicattidx].siField[i][j] && TRUE == BATTLE_TargetCheck( battleindex , CharTable[i][j] ) ){ + list[listidx] = CharTable[i][j]; + listidx++; + } + } + } + } + // ϵһ , ϵڶ , µһ , µڶ + else if( 23 == toNo || 24 == toNo || 25 == toNo || 26 == toNo ){ + basey = toNo - 23; + + for( i = 0 , j = basey - 1 ; j <= basey + 1 ; i++ , j++ ){ + if( ( 25 == toNo || 26 == toNo ) && ( j < 2 || j > 3 ) ) + continue; + else if( ( 23 == toNo || 24 == toNo ) && ( j < 0 || j > 1 ) ) + continue; + + // ЩҪ嵥 + for( k = 0 ; k < 5 ; k++ ){ + if( ATTMAGIC_magic[magicattidx].siField[i][k] && TRUE == BATTLE_TargetCheck( battleindex , CharTable[j][k] ) ) + { + list[listidx] = CharTable[j][k]; + listidx++; + } + } + } + } + + qsort( list , listidx , sizeof( list[0] ) , ( FUNC )SortLoc );// λ + // ȡ(һdz) + //BATTLE_GetAttr( BATTLE_No2Index( battleindex , attackNo ) , &attattr[2] , &attattr[1] , &attattr[0] , &attattr[3] , &attattr[4] ); + // ,ȡħȼħ + { + int attType = CHAR_getInt(BATTLE_No2Index(battleindex,attackNo),CHAR_WHICHTYPE); + int Check=0; + AttIsPlayer=0; + if( attType == CHAR_TYPEPLAYER) { + AttIsPlayer = 1; + for(i=0;i<4;i++){ // att_magic_lv[i]: i = 0: 1:ˮ 2: 3: + att_magic_lv[i] = CHAR_getInt(BATTLE_No2Index(battleindex,attackNo),CHAR_EARTH_EXP+i); + } + }else if( attType == CHAR_TYPEENEMY ) { + for(i=0;i<4;i++){ + att_magic_lv[i] = (CHAR_getInt(BATTLE_No2Index(battleindex,attackNo), CHAR_LV)*0.9); + } + }else { +#ifdef _FIX_MAGICDAMAGE + AttIsPlayer = 1; +#endif + for(i=0;i<4;i++){ +#ifdef _FIX_MAGICDAMAGE + att_magic_lv[i] = CHAR_getInt(BATTLE_No2Index(battleindex,attackNo),CHAR_EARTH_EXP+i); +#else + att_magic_lv[i] = 0; +#endif + } + } + Check = rand()%100; +#ifdef _FIX_MAGICDAMAGE + if( Check > att_magic_lv[ FieldAttr] ) TrueMagic = FALSE; + else TrueMagic = TRUE; +#endif + } + pet_att_lv = CHAR_getInt(BATTLE_No2Index(battleindex,attackNo), CHAR_LV); + z = 0; + for(i=0;i 0 ){ + float def = (float)(CHAR_getWorkInt( charaidx, CHAR_OTHERSTATUSNUMS )); + def = def/100; + for(j=0;j 0) { + CHAR_setWorkInt(def_be_hit[i],CHAR_WORKSLEEP,0); + z = BATTLE_Index2No(battleindex,def_be_hit[i]); + sprintf(szcommand,"BM|%X|%X|",z,0); + BATTLESTR_ADD(szcommand); + + } + } +#else + //TrueMagic == FALSE + // ľֵ----------------------------------------------------------------------------- + if(AttIsPlayer){ + // ˵ħ + DefFieldAttr = (FieldAttr+1)%4; + // ȡõħľֵ + att_magic_exp_add = CHAR_getInt(BATTLE_No2Index(battleindex,attackNo),CHAR_EARTH_ATTMAGIC_EXP+FieldAttr); + // ȡõħıħֵ + att_magic_exp_sub = CHAR_getInt(BATTLE_No2Index(battleindex,attackNo),CHAR_EARTH_ATTMAGIC_EXP+DefFieldAttr); + // ʹõħӸԵexp,ֻ㼸exp + att_magic_exp_add += getexp; + // ʹõħ۱Եexp,ֻۼexp + att_magic_exp_sub -= getexp; + lv_up_exp = Magic_Level_Table[att_magic_lv[FieldAttr]]; + while(att_magic_exp_add >= lv_up_exp || att_magic_exp_sub < 0){ + // õħľֵڿ + if(att_magic_exp_add >= lv_up_exp){ + // 100 + if(att_magic_lv[FieldAttr] + 1 > 100){ + att_magic_lv[FieldAttr] = 100; + // ֵΪ0 + att_magic_exp_add = 0; + }else{ + att_magic_lv[FieldAttr]++; + // ڵľֵ۵˼õľֵ + att_magic_exp_add -= lv_up_exp; + snprintf(msgbuf,sizeof(msgbuf)," %s ħΪ %d",kind[FieldAttr],att_magic_lv[FieldAttr]); + CHAR_talkToCli(BATTLE_No2Index(battleindex,attackNo),-1,msgbuf,CHAR_COLORRED); + } + } + // õħħľֵڿԽ + if(att_magic_exp_sub < 0 ){ + // ȼѾ1 + if(att_magic_lv[DefFieldAttr] <= 1){ + att_magic_lv[DefFieldAttr] = 1; + // ֵΪ0 + att_magic_exp_sub = 0; + }else{ + att_magic_lv[DefFieldAttr]--; + // һȼľֵ۵ڵľֵ + att_magic_exp_sub = Magic_Level_Table[att_magic_lv[DefFieldAttr]] + att_magic_exp_sub; + snprintf(msgbuf,sizeof(msgbuf)," %s ħȽΪ %d",kind[DefFieldAttr],att_magic_lv[DefFieldAttr]); + CHAR_talkToCli(BATTLE_No2Index(battleindex,attackNo),-1,msgbuf,CHAR_COLORRED); + } + } + lv_up_exp = Magic_Level_Table[att_magic_lv[FieldAttr]]; + } + CHAR_setInt(BATTLE_No2Index(battleindex,attackNo),CHAR_EARTH_EXP+FieldAttr,att_magic_lv[FieldAttr]); + CHAR_setInt(BATTLE_No2Index(battleindex,attackNo),CHAR_EARTH_ATTMAGIC_EXP+FieldAttr,att_magic_exp_add); + CHAR_setInt(BATTLE_No2Index(battleindex,attackNo),CHAR_EARTH_EXP+DefFieldAttr,att_magic_lv[DefFieldAttr]); + CHAR_setInt(BATTLE_No2Index(battleindex,attackNo),CHAR_EARTH_ATTMAGIC_EXP+DefFieldAttr,att_magic_exp_sub); + } + + // طľֵ----------------------------------------------------------------------------- + for(i=0;i= lv_up_exp || def_magic_exp_sub < 0){ + // طҶԴħĿԵľֵڿ + if(def_magic_exp_add >= lv_up_exp){ + // 100 + if(def_magic_resist[FieldAttr] + 1 > 100) def_magic_resist[FieldAttr] = 100; + else { + def_magic_resist[FieldAttr]++; + snprintf(msgbuf,sizeof(msgbuf)," %s ħΪ %d",kind[FieldAttr],def_magic_resist[FieldAttr]); + CHAR_talkToCli(charaidx,-1,msgbuf,CHAR_COLORRED); + } + // ֵΪ0 + def_magic_exp_add = 0; + } + // طҶԴħĿԵħľֵڿԽ + if(def_magic_exp_sub < 0 ) { + // ȼѾ1 + if(def_magic_resist[DefFieldAttr] <= 1) def_magic_exp_sub = 0; // ֵΪ0 + else { + def_magic_resist[DefFieldAttr]--; + // ֵһȼľֵ + def_magic_exp_sub = Magic_Level_Table[def_magic_resist[DefFieldAttr]]; + snprintf(msgbuf,sizeof(msgbuf)," %s ħԽΪ %d",kind[DefFieldAttr],def_magic_resist[DefFieldAttr]); + CHAR_talkToCli(charaidx,-1,msgbuf,CHAR_COLORRED); + } + } + lv_up_exp = Magic_Level_Table[def_magic_resist[FieldAttr]]; + } + CHAR_setInt(charaidx,CHAR_EARTH_RESIST+FieldAttr,def_magic_resist[FieldAttr]); + CHAR_setInt(charaidx,CHAR_EARTH_DEFMAGIC_EXP+FieldAttr,def_magic_exp_add); + CHAR_setInt(charaidx,CHAR_EARTH_RESIST+DefFieldAttr,def_magic_resist[DefFieldAttr]); + CHAR_setInt(charaidx,CHAR_EARTH_DEFMAGIC_EXP+DefFieldAttr,def_magic_exp_sub); + } + // ˯ + if(CHAR_getWorkInt(def_be_hit[i],CHAR_WORKSLEEP) > 0) { + CHAR_setWorkInt(def_be_hit[i],CHAR_WORKSLEEP,0); + z = BATTLE_Index2No(battleindex,def_be_hit[i]); + sprintf(szcommand,"BM|%X|%X|",z,0); + BATTLESTR_ADD(szcommand); + } + } +#endif +} + +#endif + +#ifdef _MAGIC_TOCALL +void BATTLE_MultiToCallDragonMagic( int battleindex, int attackNo, int toNo, + int attIdx ,int FieldAttr ,int Power, int ImageNo) +{ + int list[SIDE_OFFSET * 2 + 1]; + int listidx,i,j,k,z; + int /*basex , */basey , magicattidx,def_is_player[10],def_be_hit[10]; + int attvalue , charahp , pethp , charaidx , petidx , charahurt,charahurt_temp; + char szcommand[256]; + int /*AttIsPlayer = 0,*/DefIsPlayer = 0; + +#ifndef _FIX_MAGICDAMAGE + int att_magic_exp_add,att_magic_exp_sub,def_magic_exp_add,def_magic_exp_sub; + int lv_up_exp,DefFieldAttr = 0; + float temp = 0.0f; + char msgbuf[64]; +#else +#endif + + int icindex, ioindex; + // terry + if((z = BATTLE_MultiList(battleindex,toNo,list)) == -1) + return; + else{ + if(z != toNo) toNo = z; + } + + TOCALL_magic[attIdx].uiSpriteNum = ImageNo; + + BATTLE_ToCallDragonEffect( battleindex , attackNo , list , attIdx); + + // 㹥嵥 + if( attackNo < 10 ) + magicattidx = attIdx * 2 + 1; + else + magicattidx = attIdx * 2; + + + listidx = 0; + memset(def_is_player,-1,sizeof(def_is_player)); + memset(def_be_hit,-1,sizeof(def_be_hit)); + + // ˹ + if( toNo < 20 ){ + toNo = list[0]; + listidx++; + + } else if( 20 == toNo ){ // ȫ + for( i = 0 ; i < 2 ; i++ ){ + for( j = 0 ; j < 5 ; j++ ){ + if(TRUE == BATTLE_TargetCheck( battleindex , CharTable[i + 2][j] ) ){ + list[listidx] = CharTable[i + 2][j]; + listidx++; + } + } + } + } else if( 21 == toNo ){ // ȫ + for( i = 0 ; i < 2 ; i++ ){ + for( j = 0 ; j < 5 ; j++ ){ + if(TRUE == BATTLE_TargetCheck( battleindex , CharTable[i][j] ) ){ + list[listidx] = CharTable[i][j]; + listidx++; + } + } + } + } // ϵһ , ϵڶ , µһ , µڶ + else if( 23 == toNo || 24 == toNo || 25 == toNo || 26 == toNo ){ + basey = toNo - 23; + for( i = 0 , j = basey - 1 ; j <= basey + 1 ; i++ , j++ ){ + if( ( 25 == toNo || 26 == toNo ) && ( j < 2 || j > 3 ) ) + continue; + else if( ( 23 == toNo || 24 == toNo ) && ( j < 0 || j > 1 ) ) + continue; + // ЩҪ嵥 + for( k = 0 ; k < 5 ; k++ ){ + if(TRUE == BATTLE_TargetCheck( battleindex , CharTable[j][k] ) ) + { + list[listidx] = CharTable[j][k]; + listidx++; + } + } + } + } + qsort( list , listidx , sizeof( list[0] ) , ( FUNC )SortLoc );// λ + for( i = 0 ; i < listidx ; i++ ) { + int defType; + charaidx = BATTLE_No2Index( battleindex , list[i] ); + petidx = BATTLE_getRidePet( charaidx ); + defType = CHAR_getInt(charaidx, CHAR_WHICHTYPE); + DefIsPlayer = 0; + if (defType == CHAR_TYPEPLAYER) { + DefIsPlayer = 1; + } + if (CHAR_createCharacter( 100354 /*image no*/, 100, 600, 370, 0, + &icindex, &ioindex, 0) == TRUE) { + +// CHAR_setInt( icindex, CHAR_STR, 100); + CHAR_setInt( icindex, CHAR_LUCK, 1); + CHAR_setWorkInt( icindex, CHAR_WORKATTACKPOWER, + Power ); + CHAR_setWorkInt( icindex, CHAR_WORKOTHERDMAGE, + 0); + + if (BATTLE_MagicDodge(charaidx, DefIsPlayer, FieldAttr)) { +// û + attvalue = 0; + } else { + if( 0 == TOCALL_magic[attIdx].uiAttackType ) {// ˹ + attvalue = BATTLE_DamageCalc(icindex, charaidx); + } + else { + attvalue = BATTLE_DamageCalc(icindex, charaidx); + } + } + CHAR_CharaDelete(icindex); + charahp = CHAR_getInt( charaidx , CHAR_HP ); + if (-1 == petidx || CHAR_getInt(petidx, CHAR_HP) <= 0) { +// û + if( ( charahp -= attvalue ) < 0 ) { + charahp = 0; + } + CHAR_setInt( charaidx , CHAR_HP , charahp ); + pethp = 0; + if( 0 == TOCALL_magic[attIdx].uiAttackType ) {// ˹ + sprintf( szcommand , "%X|%X|%X|%X|" , toNo , list[i] , attvalue , pethp); + } else + sprintf( szcommand , "%X|%X|%X|%X|" , list[i] , list[i] , attvalue , pethp); + }else{ + pethp = CHAR_getInt( petidx , CHAR_HP ); + charahurt = attvalue * BATTLE_CalcCharaRatio( FieldAttr , charaidx ) / 10; + + charahurt_temp = charahurt; + if( ( charahp -= charahurt ) < 0 ) + { + charahurt = charahp; + charahp = 0; + } + + attvalue = attvalue - charahurt; + if( ( pethp -= attvalue ) < 0) + { + pethp = 0; + // ûѪ˳ս + CHAR_setInt(charaidx,CHAR_RIDEPET,-1); + BATTLE_changeRideImage(charaidx); + CHAR_setWorkInt(charaidx,CHAR_WORKPETFALL,1); + } + CHAR_setInt( charaidx , CHAR_HP , charahp ); + CHAR_setInt( petidx , CHAR_HP , pethp ); + + charahurt = charahurt_temp; + + if( 0 == TOCALL_magic[attIdx].uiAttackType ) {// ˹ + sprintf( szcommand , "%X|%X|%X|%X|" , toNo , list[i] , charahurt , attvalue); + } else + sprintf( szcommand , "%X|%X|%X|%X|" , list[i] , list[i] , charahurt , attvalue); + + } + + BATTLESTR_ADD( szcommand ); + } + } + + sprintf( szcommand , "%X|" , 0x5711438 ); + BATTLESTR_ADD( szcommand ); + +} + +#endif + +//*********************************************************** +// +// ܷƥ Ѽƽҷëٽ +// +void BATTLE_MultiRessurect( + int battleindex, // ̼͵ + int attackNo, // į + int toNo, // ľ į + int power, // + int per, // Ѿ + int UseEffect, // мް + int RecevEffect // ľмް +) +// +//*********************************************************** +{ + int i, toindex, UpPoint = 0, workhp; + int ToList[SIDE_OFFSET*2+1]; + + //char szBuffer[256]=""; + char szCommand[256]; + + + BATTLE_MultiListDead( battleindex, toNo, ToList ); + + BATTLE_MagicEffect( + battleindex, // ̼͵ + attackNo, // į( ) + ToList, // ľ į( ) + UseEffect, // оް + RecevEffect // ľоް + ); + + // ٽ + for( i = 0; ToList[i] != -1; i ++ ){ + // 켰̼͵ + toindex = BATTLE_No2Index( battleindex, ToList[i] ); + + // Ϸ߯Ի + if( BattleArray[battleindex].type == BATTLE_TYPE_P_vs_P + && CHAR_getInt( toindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER + ){ + continue; + } + + // ƻئľٽئ + if( CHAR_getFlg( toindex, CHAR_ISDIE ) == FALSE ){ + continue; + } + + // ң + UpPoint = power; + + if( per ){ + // ѻң + UpPoint *= CHAR_getWorkInt( toindex, CHAR_WORKMAXHP ) * 0.01; + } + + if( power == 0 ){ + // + UpPoint = CHAR_getWorkInt( toindex, CHAR_WORKMAXHP ); + }else{ + // ڱë (ᷴ) + UpPoint = RAND( (power*0.9), (power*1.1) ); + } + // ƥ֨ + UpPoint = max( 1, UpPoint ); + + workhp = CHAR_getInt( toindex, CHAR_HP ) + UpPoint; + + // ëئз + CHAR_setInt( toindex, CHAR_HP, + min( workhp, CHAR_getWorkInt( toindex, CHAR_WORKMAXHP ) ) ); + + // + CHAR_setFlg( toindex, CHAR_ISDIE, 0 ); + + //snprintf( szBuffer, sizeof(szBuffer), + // "(%s)ָʶ", + // CHAR_getUseName( toindex ) ); + + // ú + //BATTLE_BroadCast( battleindex, szBuffer, + // (attackNo >= 10)? CHAR_COLORGRAY : CHAR_COLORPURPLE ) ; + + // ()Ѩëľ + snprintf( szCommand, sizeof(szCommand), + "BL|r%X|h%X|", ToList[i], CHAR_getInt( toindex, CHAR_HP ) ); + + // ٯ ܰ + BATTLESTR_ADD( szCommand ); +/* + { int Sign, Damage; + Sign = (UpPoint >= 0)?(1):(0); + Damage = ABS( UpPoint ); + // ( )Ѩëľ + snprintf( szCommand, sizeof(szCommand), + "BD|r%X|%X|%X|d%X|", ToList[i], 0, Sign, Damage ); + } + // ٯ ܰ + BATTLESTR_ADD( szCommand ); +*/ + + // 缰 ƥͻئ + if( BattleArray[battleindex].norisk == 0 + && BattleArray[battleindex].type == BATTLE_TYPE_P_vs_E + ){ + // ƥʸհëµ + if( CHAR_getInt( toindex, CHAR_WHICHTYPE ) == CHAR_TYPEPET ){ + CHAR_PetAddVariableAi( toindex, AI_FIX_PETRESSURECT ); + } + } + } + + return; + +} + +#ifdef _Item_ReLifeAct +void BATTLE_MultiReLife( int battleindex, int attackNo, int toNo, + int power, int RecevEffect ) +{ + int i, toindex, UpPoint = 0, workhp; + int ToList[SIDE_OFFSET*2+1]; + //char szBuffer[256]=""; + char szCommand[256]; + char buf1[256]; + + memset(szCommand, 0, sizeof(szCommand)); + BATTLE_MultiListDead( battleindex, toNo, ToList ); + + + //snprintf( szCommand, sizeof(szCommand), "Bj|"); + for( i = 0; ToList[i] != -1; i ++ ){ + toindex = BATTLE_No2Index( battleindex, ToList[i] ); + //if( BattleArray[battleindex].type == BATTLE_TYPE_P_vs_P + //&& CHAR_getInt( toindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER ){ + // continue; + //} + if( CHAR_getFlg( toindex, CHAR_ISDIE ) == FALSE ){ + continue; + } + UpPoint = power; + workhp = max( 1, UpPoint ); + + CHAR_setInt( toindex, CHAR_HP, min( workhp, CHAR_getWorkInt( toindex, CHAR_WORKMAXHP ) ) ); + CHAR_setFlg( toindex, CHAR_ISDIE, 0 ); + //snprintf( szBuffer, sizeof(szBuffer), "(%s)ָʶ", CHAR_getUseName( toindex ) ); + snprintf( buf1, sizeof(buf1), + "BJ|a%X|m%X|e%X|e%X|FF|", + ToList[i], + CHAR_getInt( toindex, CHAR_MP ), + RecevEffect, //MyEffect, + 0 //ToEffect + ); + strcatsafe( szCommand,sizeof(szCommand), buf1); + + snprintf( buf1, sizeof(buf1), + "BL|r%X|h%X|", ToList[i], CHAR_getInt( toindex, CHAR_HP ) ); + strcatsafe( szCommand,sizeof(szCommand), buf1); + + if( BattleArray[battleindex].norisk == 0 + && BattleArray[battleindex].type == BATTLE_TYPE_P_vs_E ){ + if( CHAR_getInt( toindex, CHAR_WHICHTYPE ) == CHAR_TYPEPET ){ + CHAR_PetAddVariableAi( toindex, AI_FIX_PETRESSURECT ); + } + } + } + //strcat( szCommand, "FF|"); + BATTLESTR_ADD( szCommand ); + return; +} +#endif + +void BATTLE_MultiStatusChange( + int battleindex, // ̼͵ + int attackNo, // į + int toNo, // ľ į + int status, // + int turn, // + int UseEffect, // мް + int RecevEffect, // ľмް + int Success // +) +{ + int i, toindex, charaindex; + int perStatus; + int ToList[SIDE_OFFSET*2+1]; + //char szBuffer[256]=""; + + BATTLE_MultiList( battleindex, toNo, ToList ); + BATTLE_MagicEffect( + battleindex, // ̼͵ + attackNo, // į( ) + ToList, // ľ į( ) + UseEffect, // оް + RecevEffect // ľоް + ); + + charaindex = BATTLE_No2Index( battleindex, attackNo ); + for( i = 0; ToList[i] != -1; i ++ ){ + toindex = BATTLE_No2Index( battleindex, ToList[i] ); + if( BATTLE_StatusAttackCheck( charaindex, + toindex, status, Success, 30, 1.0, &perStatus ) == FALSE ){ + //snprintf( szBuffer, sizeof(szBuffer), + // "(%s)޷(%s)(%s)(%d%%)", + // CHAR_getUseName( charaindex ), + // CHAR_getUseName( toindex ), + // aszStatusFull[status], + // perStatus + //); + //BATTLE_BroadCast( battleindex, szBuffer, + // (attackNo >= 10)? CHAR_COLORGRAY : CHAR_COLORPURPLE ) ; + }else{ + CHAR_setWorkInt( toindex, StatusTbl[status], turn ); + + if( status == BATTLE_ST_PARALYSIS + || status == BATTLE_ST_SLEEP + || status == BATTLE_ST_STONE + || status == BATTLE_ST_BARRIER ){ + CHAR_setWorkInt( toindex, CHAR_WORKBATTLECOM1, BATTLE_COM_NONE ); + } + + //snprintf( szBuffer, sizeof(szBuffer), + // "(%s)(%s)(%s)(%d%%)", + // CHAR_getUseName( charaindex ), + // CHAR_getUseName( toindex ), + // aszStatusFull[status], + // perStatus + //); + //BATTLE_BroadCast( battleindex, szBuffer, + // (attackNo >= 10)? CHAR_COLORGRAY : CHAR_COLORPURPLE ) ; + BATTLE_BadStatusString( ToList[i], status ); + } + } + return; +} + +#ifdef _OTHER_MAGICSTAUTS +void BATTLE_MultiMagicStatusChange( int battleindex, int attackNo, int toNo, int status, int turn, + int UseEffect, int RecevEffect, int nums ) +{ + int i, j, toindex, charaindex; + int ToList[SIDE_OFFSET*2+1]; + + BATTLE_MultiList( battleindex, toNo, ToList ); + BATTLE_MagicEffect( battleindex, attackNo, ToList, UseEffect, RecevEffect ); + + charaindex = BATTLE_No2Index( battleindex, attackNo ); + for( i = 0; ToList[i] != -1; i ++ ){ + toindex = BATTLE_No2Index( battleindex, ToList[i] ); + for( j=1; j 0 ){ + tostatus = j; + } + } + //======== ƥ ë ý ========== + if( tostatus == 0 ){// + // +// print("\n vincent--ܽ"); + //snprintf( szBuffer, sizeof(szBuffer), + // "(%s)ܽ", + // CHAR_getUseName( toindex ) ); + }else + // ϶ƥҷ + if( ( status == 0 && tostatus != 0 && tostatus <= CHAR_WORKCONFUSION ) // ϶ƥ//ҵ쳣 + || ( status == tostatus ) // ֻѨ + ){ + // + CHAR_setWorkInt( toindex, StatusTbl[tostatus], 0 ); +#ifdef _MAGIC_NOCAST + if( StatusTbl[tostatus] == CHAR_WORKNOCAST ){ + //print("\nvincent-->lssproto_NC_send"); + lssproto_NC_send( getfdFromCharaIndex( toindex ), 0);//Ĭ + } +#endif +// print("\n vincent--:%d",tostatus); + // + //snprintf( szBuffer, sizeof(szBuffer), + // "(%s)(%s)(%s)", + // CHAR_getUseName( charaindex ), + // CHAR_getUseName( toindex ), + // aszStatusFull[tostatus] + //); + // ƥ ٯ Ѩëľ + BATTLE_BadStatusString( ToList[i], 0 );//쳣 + + }else{ +// print("\n vincent--"); + // +/* snprintf( szBuffer, sizeof(szBuffer), + "(%s)(%s)", + CHAR_getUseName( toindex ), + aszStatusFull[status] + ); +*/ + } + // ú + //BATTLE_BroadCast( battleindex, szBuffer, + // (attackNo >= 10)? CHAR_COLORGRAY : CHAR_COLORPURPLE ) ; + } + + return; +} + +//*********************************************************** +// +// ܷƥ Ѽƽҷë ܷ +// +void BATTLE_MultiMagicDef( + int battleindex, // ̼͵ + int attackNo, // į + int toNo, // ľ į + int kind, // ܷ + int count, // + int UseEffect, // мް + int RecevEffect // ľмް +) +// +//*********************************************************** +{ + + int i, toindex, charaindex; + int ToList[SIDE_OFFSET*2+1]; + + //char szBuffer[256]=""; + + + BATTLE_MultiList( battleindex, toNo, ToList ); + + BATTLE_MagicEffect( + battleindex, // ̼͵ + attackNo, // į( ) + ToList, // ľ į( ) + UseEffect, // оް + RecevEffect // ľоް + ); + + charaindex = BATTLE_No2Index( battleindex, attackNo ); + for( i = 0; ToList[i] != -1; i ++ ){ + toindex = BATTLE_No2Index( battleindex, ToList[i] ); + CHAR_setWorkInt( toindex, MagicDefTbl[kind], count ); + //snprintf( szBuffer, sizeof(szBuffer), + // "(%s)(%s)(%s)", + // CHAR_getUseName( charaindex ), + // CHAR_getUseName( toindex ), + // aszMagicDefFull[kind] + //); + //BATTLE_BroadCast( battleindex, szBuffer, + // (attackNo >= 10)? CHAR_COLORGRAY : CHAR_COLORPURPLE ) ; + } + + return; + + + +} + + +#if 1 + +//*********************************************************** +// +// ܷƥ Ѽƽҷɷ¶ëƱ +// +void BATTLE_MultiParamChange( + int battleindex, // ̼͵ + int attackNo, // į + int toNo, // ľ į + int kind, // ɷ¶ + int power, // ̼ + int par, // ѻң + int UseEffect, // мް + int RecevEffect // ľмް +) +// +//*********************************************************** +{ + + int i, toindex, charaindex; + int ToList[SIDE_OFFSET*2+1]; + int res = 0, work; + //char szBuffer[256]=""; + + + BATTLE_MultiList( battleindex, toNo, ToList ); + + BATTLE_MagicEffect( + battleindex, // ̼͵ + attackNo, // į( ) + ToList, // ľ į( ) + UseEffect, // оް + RecevEffect // ľоް + ); + + charaindex = BATTLE_No2Index( battleindex, attackNo ); + + // ɷ¶¾ + for( i = 0; ToList[i] != -1; i ++ ){ + + // 켰̼͵ + toindex = BATTLE_No2Index( battleindex, ToList[i] ); + + switch( kind ){ + case PC_KIND_ATTACK: + if( par ){ + // ѻңئ׻ߨ߷ئ + work = CHAR_getWorkInt( toindex, CHAR_WORKFIXSTR ); + work = work * power; + }else{ + // ңئ׻ߨ߾ + work = power * 100; + } + CHAR_setWorkInt( toindex, CHAR_WORKMODATTACK, + CHAR_getWorkInt( toindex, CHAR_WORKMODATTACK ) + work ); + res = work * 0.01; + break; + case PC_KIND_DEFENSE: + if( par ){ + // ѻңئ׻ߨ߷ئ + work = CHAR_getWorkInt( toindex, CHAR_WORKFIXTOUGH ); + work = work * power; + }else{ + // ңئ׻ߨ߾ + work = power * 100; + } + CHAR_setWorkInt( toindex, CHAR_WORKMODDEFENCE, + CHAR_getWorkInt( toindex, CHAR_WORKMODDEFENCE ) + work ); + res = work * 0.01; + break; + case PC_KIND_QUICK: + if( par ){ + // ѻңئ׻ߨ߷ئ + work = CHAR_getWorkInt( toindex, CHAR_WORKFIXDEX ); + work = work * power; + }else{ + // ңئ׻ߨ߾ + work = power * 100; + } + CHAR_setWorkInt( toindex, CHAR_WORKMODQUICK, + CHAR_getWorkInt( toindex, CHAR_WORKMODQUICK ) + work ); + res = work * 0.01; + break; + case PC_KIND_CHARM: + if( par ){ + // CHARM 100 ľئ׻100м + work = CHAR_getWorkInt( toindex, CHAR_WORKFIXCHARM ); + work = work * power * 0.01; + }else{ + // ң + work = power; + } + CHAR_setWorkInt( toindex, CHAR_WORKMODCHARM, + CHAR_getWorkInt( toindex, CHAR_WORKMODCHARM ) + work ); + res = work; + break; + case PC_KIND_CAPTURE: + // CAPTURE % + work = power; + CHAR_setWorkInt( toindex, CHAR_WORKMODCAPTURE, + CHAR_getWorkInt( toindex, CHAR_WORKMODCAPTURE ) + work ); + res = work; + break; + } + + // ƥ + //snprintf( szBuffer, sizeof(szBuffer), + // "(%s)(%s)(%+d)", + // CHAR_getUseName( toindex ), + // aszParamChangeFull[kind], + // res + //); + + // ú + //BATTLE_BroadCast( battleindex, szBuffer, + // (attackNo >= 10)? CHAR_COLORGRAY : CHAR_COLORPURPLE ) ; + + } + + return; +} + +#endif + + +//*********************************************************** +// +// ܷƥ Ѽ +// +void BATTLE_MultiAttReverse( + int battleindex, // ̼͵ + int attackNo, // į + int toNo, // ľ į + int UseEffect, // мް + int RecevEffect // ľмް +) +// +//*********************************************************** +{ + + int i, toindex, charaindex; + int ToList[SIDE_OFFSET*2+1]; + int flg, OnOff; + char szBuffer[256]=""; + + BATTLE_MultiList( battleindex, toNo, ToList ); + + BATTLE_MagicEffect( + battleindex, // ̼͵ + attackNo, // į( ) + ToList, // ľ į( ) + UseEffect, // оް + RecevEffect // ľоް + ); + + charaindex = BATTLE_No2Index( battleindex, attackNo ); + + // ɷ¶¾ + for( i = 0; ToList[i] != -1; i ++ ){ + + // 켰̼͵ + toindex = BATTLE_No2Index( battleindex, ToList[i] ); + + flg = CHAR_getWorkInt( toindex, CHAR_WORKBATTLEFLG ); + flg ^= CHAR_BATTLEFLG_REVERSE; // + CHAR_setWorkInt( toindex, CHAR_WORKBATTLEFLG, flg ); + OnOff = ( flg & CHAR_BATTLEFLG_REVERSE )?(1):(0); + + // ƥʾ + BATTLE_AttReverse( toindex ); + + if( OnOff ){ + //snprintf( szBuffer, sizeof(szBuffer), + // "(%s)Ա෴", + // CHAR_getUseName( toindex ) ); + }else{ + //snprintf( szBuffer, sizeof(szBuffer), + // "(%s)ظԭԡ", + // CHAR_getUseName( toindex ) ); + } + + // ú + //BATTLE_BroadCast( battleindex, szBuffer, + // (attackNo >= 10)? CHAR_COLORGRAY : CHAR_COLORPURPLE ) ; + + // ƥ  ٯ ë˪ + sprintf( szBuffer, "BR|%X|%X|", ToList[i], OnOff ); + BATTLESTR_ADD( szBuffer ); + } + + return; + +} + +void BATTLE_MultiCaptureUp( + int battleindex, + int attackNo, + int toNo, + int power, + int UseEffect, + int RecevEffect +) +{ + int i, toindex, UpPoint = 0, workhp; + int ToList[SIDE_OFFSET*2+1]; + + //char szBuffer[256]=""; + char szCommand[256]; + + BATTLE_MultiList( battleindex, toNo, ToList ); + + BATTLE_MagicEffect( + battleindex, + attackNo, + ToList, + UseEffect, + RecevEffect + ); + + for( i = 0; ToList[i] != -1; i ++ ){ + toindex = BATTLE_No2Index( battleindex, ToList[i] ); + + if( CHAR_getInt( toindex, CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER ){ + continue; + } + + if( CHAR_getFlg( toindex, CHAR_ISDIE ) == TRUE ){ + continue; + } + + UpPoint = power; + + UpPoint = RAND( (power*0.9), (power*1.1) ); + + workhp = CHAR_getWorkInt( toindex, CHAR_WORKMODCAPTURE ) + UpPoint; + + CHAR_setWorkInt( toindex, CHAR_WORKMODCAPTURE, workhp ); + + //snprintf( szBuffer, sizeof(szBuffer), + // "(%s)IJʱ(%d)", + // CHAR_getUseName( toindex ), UpPoint ); + + //BATTLE_BroadCast( battleindex, szBuffer, + // (attackNo >= 10)? CHAR_COLORGRAY : CHAR_COLORPURPLE ) ; + + snprintf( szCommand, sizeof( szCommand ), + "B%%|%X|%X|", ToList[i], BFUKI_CAPTUREUP ); + + BATTLESTR_ADD( szCommand ); + } + return; +} + + + + + +//**************************************************************** +// +// ū +// +int BATTLE_FieldAttChange( + int charaindex, // м̼͵ + char *pArg +) +// +// ľ TRUE +// ئ FALSE +// +//**************************************************************** + +{ + + int attr = -1, i, attackNo, turn = 3; + int battleindex, power = 30; + int FieldAttr[] = { BATTLE_ATTR_NONE, BATTLE_ATTR_EARTH, BATTLE_ATTR_WATER, BATTLE_ATTR_FIRE, BATTLE_ATTR_WIND }; + char szCommand[256], + // Robin 03/20 debug + //*pszP, *aszAttr[] = { "", "", "ˮ", "", "" }; + *pszP, *aszAttr[] = { "", "", "ˮ", "", "" }; + // Robin 03/21 debug + //char szTurn[] = ""; + char szTurn[] = "turn"; + + + pszP = pArg; + // ë + for( ;attr == -1 && pszP[0] != 0; pszP++ ){ + for( i = 0; i < 5; i ++ ){ + // + if( strncmp( pszP, aszAttr[i], 2 ) == 0 ){ + attr = i; + pszP +=2; + break; + } + } + } + // мƥ + if( attr == -1 ) + { + return FALSE; + } + + // ľ ʽ¾ + sscanf( pszP, "%d", &power ); + if( power < 0 || power > 100 )power = 30; + + // ʽ¾ + if( ( pszP = strstr( pszP, szTurn ) ) != NULL){ + pszP += sizeof( szTurn ); + sscanf( pszP, "%d", &turn ); + } + + battleindex = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEINDEX ); + if( BATTLE_CHECKINDEX( battleindex ) == FALSE )return FALSE; + // + BattleArray[battleindex].field_att = FieldAttr[attr]; + // Ĥɷ + BattleArray[battleindex].att_pow = power; + // Ĥ + BattleArray[battleindex].att_count = turn; + + // ƥ + if( attr >= 0 ){ + //snprintf( szBuffer, sizeof(szBuffer), + // "(%s)fieldԸΪ(%s)", + // CHAR_getUseName( charaindex ), + // aszAttr[attr] + //); + } + + attackNo = BATTLE_Index2No( battleindex, charaindex ); + + // ú + //BATTLE_BroadCast( battleindex, szBuffer, + // (attackNo >= 10)? CHAR_COLORGRAY : CHAR_COLORPURPLE ) ; + + // ƥ ٯ Ѩëľ + sprintf( szCommand, "BV|%X|%X|",attackNo, attr ); + BATTLESTR_ADD( szCommand ); + + return TRUE; + +} + + + + +//**************************************************************** +// +// ū +// +int MAGIC_FieldAttChange_Battle( + int charaindex, // м̼͵ + int toNo, // ľм̼͵( ) + int marray, // magicindex + int mp // MP +) +// ľ TRUE +// ئ FALSE +// +//**************************************************************** + +{ + char *pArg; + + // ɷ¶ë + pArg = MAGIC_getChar( marray, MAGIC_OPTION ); + // ɷ¶ мƥ + if( pArg == "\0" )return FALSE; + + return BATTLE_FieldAttChange( charaindex, pArg ); + +} +//**************************************************************** +// +// ëܸ +// +int MAGIC_StatusChange_Battle( + int charaindex, // м̼͵ + int toNo, // ľм̼͵ + int marray, // magicindex + int mp // MP +) +// TRUE +// FALSE +//**************************************************************** + +{ + char *magicarg; + int status = -1, i, attackNo, turn = 3; + int battleindex, ReceveEffect, Success = 15; + char *pszP; + char szTurn[] = "turn"; + char szSuccess[] = ""; + + magicarg = MAGIC_getChar( marray, MAGIC_OPTION ); + pszP = magicarg; + for( ;status == -1 && pszP[0] != 0; pszP++ ){ + for( i = 1; i < BATTLE_ST_END; i ++ ){ + if( strncmp( pszP, aszStatus[i], 2 ) == 0 ){ + status = i; + pszP +=2; + break; + } + } + } + if( status == -1 ) return FALSE; + if( ( pszP = strstr( pszP, szTurn ) ) != NULL){ + pszP += sizeof( szTurn ); + sscanf( pszP, "%d", &turn ); + } + if( ( pszP = strstr( pszP, szSuccess ) ) != NULL){ + pszP += sizeof( szSuccess ); + sscanf( pszP, "%d", &Success ); + } + battleindex = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEINDEX ); + attackNo = BATTLE_Index2No( battleindex, charaindex ); + if( status == BATTLE_ST_NONE ){ + ReceveEffect = SPR_tyusya; // 巴ľ + }else{ + ReceveEffect = SPR_hoshi; // 巴ľ + } + + BATTLE_MultiStatusChange( battleindex, attackNo, toNo, + status, turn, MAGIC_EFFECT_USER, ReceveEffect, Success ); + + + return TRUE; + +} + +#ifdef _MAGIC_DEEPPOISON +int MAGIC_StatusChange_Battle2( + int charaindex, // м̼͵ + int toNo, // ľм̼͵ + int marray, // magicindex + int mp // MP +) +// TRUE +// FALSE +//**************************************************************** + +{ + char *magicarg; + int status = -1, i, attackNo, turn = 3; + int battleindex, ReceveEffect, Success = 15; + char *pszP; + char szTurn[] = "turn"; + char szSuccess[] = ""; + magicarg = MAGIC_getChar( marray, MAGIC_OPTION ); + if( magicarg == "\0" ) { + //print("\n magicarg == NULL "); + return FALSE; + } + pszP = magicarg; + // ë + for( ;status == -1 && pszP[0] != 0; pszP++ ){ + // ྮո + for( i = 1; i < BATTLE_ST_END; i ++ ){ + // + if( strncmp( pszP, aszStatus[i], 2 ) == 0 ){ + status = i; + pszP +=2; + break; + } + } + } + // ئмƥ + if( status == -1 ) return FALSE; + + // ʽ¾ + if( ( pszP = strstr( pszP, szTurn ) ) != NULL){ + pszP += sizeof( szTurn ); + sscanf( pszP, "%d", &turn ); + } + + // ɬ + if( ( pszP = strstr( pszP, szSuccess ) ) != NULL){ + pszP += sizeof( szSuccess ); + sscanf( pszP, "%d", &Success ); + } + + + + // į + battleindex = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEINDEX ); + attackNo = BATTLE_Index2No( battleindex, charaindex ); + + if( status == BATTLE_ST_NONE ){ + ReceveEffect = SPR_tyusya; // 巴ľ + }else{ + ReceveEffect = SPR_hoshi; // 巴ľ + } + // 幻 + BATTLE_MultiStatusChange( battleindex, attackNo, toNo, + status, turn+2, MAGIC_EFFECT_USER, ReceveEffect, Success ); + return TRUE; +} +#endif +#ifdef _OTHER_MAGICSTAUTS +int MAGIC_MagicStatusChange_Battle( int charaindex, int toNo, int marray, int mp ) +{ + char *magicarg; + int status = -1, i, attackNo, turn = 3, nums=0; + int battleindex, ReceveEffect; + char buf1[256]; + + magicarg = MAGIC_getChar( marray, MAGIC_OPTION ); + + if( getStringFromIndexWithDelim( magicarg,"|",1, buf1, sizeof( buf1)) == FALSE ) + return FALSE; + for( i=0; i= 20 ) + return FALSE; + } + battleindex = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEINDEX ); + attackNo = BATTLE_Index2No( battleindex, charaindex ); + //ͼž +#define SPR_mic_def 101411 + ReceveEffect = SPR_heal2; + if( status == 1 ) + ReceveEffect = SPR_mic_def; +#ifdef _MAGICSTAUTS_RESIST + else if( status == 3 ) + ReceveEffect = 101802; + else if( status == 4 ) + ReceveEffect = 101804; + else if( status == 5 ) + ReceveEffect = 101803; +#endif + //else{ + // ReceveEffect = SPR_hoshi; + //} + + BATTLE_MultiMagicStatusChange( + battleindex, attackNo, toNo, status, + turn, MAGIC_EFFECT_USER, ReceveEffect, nums ); + + return TRUE; +} +#endif + + +int MAGIC_MagicDef_Battle( + int charaindex, + int toNo, + int marray, + int mp +) +{ + char *magicarg; + int status = -1, i, attackNo, turn = 3; + int battleindex; + char *pszP; + + char szTurn[] = "turn"; + + magicarg = MAGIC_getChar( marray, MAGIC_OPTION ); + + pszP = magicarg; + + for( ;status == -1 && pszP[0] != 0; pszP++ ){ + for( i = 1; i < BATTLE_MD_END; i ++ ){ + if( strncmp( pszP, aszMagicDef[i], 2 ) == 0 ){ + status = i; + pszP +=2; + break; + } + } + } + + if( status == -1 ) return FALSE; + + if( ( pszP = strstr( pszP, szTurn ) ) != NULL){ + pszP += sizeof( szTurn ); + sscanf( pszP, "%d", &turn ); + } + + battleindex = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEINDEX ); + attackNo = BATTLE_Index2No( battleindex, charaindex ); + + BATTLE_MultiMagicDef( battleindex, attackNo, toNo, + status, turn, MAGIC_EFFECT_USER, SPR_difence ); + + + return TRUE; +} + + + + + + + +#if 1 + +//**************************************************************** +// +// ɷ¶ ëܸ +// +int MAGIC_ParamChange_Battle( + int charaindex, // м̼͵ + int toNo, // ľм̼͵ + int marray, // magicindex + int mp // MP +) +// TRUE +// FALSE +//**************************************************************** + +{ + char *magicarg; + int kind = -1, i, attackNo; + int battleindex, pow, par = 0; + + char *pszP; + + // ɷ¶ë //ħ + magicarg = MAGIC_getChar( marray, MAGIC_OPTION ); + + pszP = magicarg; + // ë //ȡøIJ(,,,,,) + for( ;kind == -1 && pszP[0] != 0; pszP++ ){ + for( i = 1; i < BATTLE_MD_END; i ++ ){ + // + if( strncmp( pszP, aszParamChange[i], 2 ) == 0 ){ + kind = i; + pszP +=2; + break; + } + } + } + // ئмƥ + if( kind == -1 ) return FALSE; + + if( strstr( pszP, "%" ) ){ // ѻң + par = 1; + } + + if( sscanf( pszP, "%d", &pow ) != 1 ){ + // Ϻ̼ؤ¾ + pow = 30; + } + + // į + battleindex = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEINDEX ); + attackNo = BATTLE_Index2No( battleindex, charaindex ); + + // 幻 + BATTLE_MultiParamChange( battleindex, attackNo, toNo, + kind, pow, par, MAGIC_EFFECT_USER, SPR_hoshi ); + + + return TRUE; +} + + + +#endif + + + + + + + +//**************************************************************** +// +// м ëܸ +// +int MAGIC_AttReverse_Battle( + int charaindex, // м̼͵ + int toNo, // ľм̼͵ + int marray, // magicindex + int mp // MP +) +// TRUE +// FALSE +//**************************************************************** + +{ + int attackNo; + int battleindex; + + // ɷ¶ἰǷ + // į + battleindex = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEINDEX ); + attackNo = BATTLE_Index2No( battleindex, charaindex ); + + // 幻 + BATTLE_MultiAttReverse( battleindex, attackNo, toNo, + MAGIC_EFFECT_USER, SPR_kyu ); + + + return TRUE; +} + + + +//**************************************************************** +// +// ë +// +int MAGIC_StatusRecovery_Battle( + int charaindex, // м̼͵ + int toNo, // ľм̼͵ + int marray, // magicindex + int mp // MP +) +// TRUE +// FALSE +//**************************************************************** +{ + char *magicarg; + int status = -1, i, attackNo; + int battleindex, ReceveEffect; + char *pszP; + + // ɷ¶ë + magicarg = MAGIC_getChar( marray, MAGIC_OPTION ); + + pszP = magicarg; + // ë + for( ;status == -1 && pszP[0] != 0; pszP++ ){ + // ؤ¼ƥ߾ո + for( i = 0; i < BATTLE_ST_END; i ++ ){ + // + if( strncmp( pszP, aszStatus[i], 2 ) == 0 ){ + status = i; + pszP +=2; + break; + } + } + } + // ئмƥ + if( status == -1 ) return FALSE; + + + // į + battleindex = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEINDEX ); + attackNo = BATTLE_Index2No( battleindex, charaindex ); + + ReceveEffect = SPR_tyusya; // 巴ľ + + // 幻 + BATTLE_MultiStatusRecovery( battleindex, attackNo, toNo, + status, MAGIC_EFFECT_USER, ReceveEffect ); + + + return TRUE; + +} + + +//**************************************************************** +// +// 姾 +// +int MAGIC_Ressurect_Battle( + int charaindex, // м̼͵ + int toNo, // ľм̼͵ + int marray, // magicindex + int mp // MP +) +// TRUE +// FALSE +//**************************************************************** +{ + char *magicarg; + int attackNo, ReceveEffect; + int battleindex, pow = 0, par = 0; + + char *pszP; + + // ɷ¶ë + magicarg = MAGIC_getChar( marray, MAGIC_OPTION ); + + pszP = magicarg; + + if( strstr( pszP, "%" ) ){ // ѻң + par = 1; + } + if( sscanf( pszP, "%d", &pow ) != 1 ){ + // Ϻ̼¾ + pow = 0; // ߼ + } + + if( pow <= 0 ){ + ReceveEffect = SPR_fukkatu3; + }else + if( pow <= 100 ){ + ReceveEffect = SPR_fukkatu1; + }else + if( pow <= 300 ){ + ReceveEffect = SPR_fukkatu2; + }else{ + ReceveEffect = SPR_fukkatu3; + } + + // į + battleindex = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEINDEX ); + attackNo = BATTLE_Index2No( battleindex, charaindex ); + + // 幻 + BATTLE_MultiRessurect( battleindex, attackNo, toNo, + pow, par, MAGIC_EFFECT_USER, ReceveEffect ); + + return TRUE; +} + + +int MAGIC_ResAndDef_Battle( + int charaindex, + int toNo, + int marray, + int mp +) +{ + char *magicarg; + int attackNo, i; + int battleindex, pow = 0, par = 0, turn = 3, status = -1; + // Robin 03/21 debug + //char szTurn[] = ""; + char szTurn[] = "turn"; + + char *pszP; + +// Terry add 2004/12/7 + // ..ʹõз + battleindex = CHAR_getWorkInt(charaindex, CHAR_WORKBATTLEINDEX); + if(CHAR_getInt(charaindex, CHAR_WHICHTYPE) == CHAR_TYPEPLAYER) + { + if(BATTLE_CheckSameSide(charaindex, toNo) == 0) //ͬ + { + battleindex = CHAR_getWorkInt(charaindex, CHAR_WORKBATTLEINDEX); + BATTLE_NoAction(battleindex, BATTLE_Index2No(battleindex, charaindex)); + CHAR_talkToCli(charaindex, -1, "⾵..ʩҵз", CHAR_COLORYELLOW); + return FALSE; + } + } +// end + // ɷ¶ë + magicarg = MAGIC_getChar( marray, MAGIC_OPTION ); + + pszP = magicarg; + + if( strstr( pszP, "%" ) ){ // ѻң + par = 1; + } + if( sscanf( pszP, "%d", &pow ) != 1 ){ + // Ϻ̼¾ + pow = 0; // ߼ + } + + // ܰ ܷ ë + for( ;status == -1 && pszP[0] != 0; pszP++ ){ + for( i = 1; i < BATTLE_MD_END; i ++ ){ + char *p; + // + p = strstr( pszP, aszMagicDef[i] ); + if( p != NULL ){ + status = i; + pszP = p; + break; + } + } + } + + // ئмƥ + if( status == -1 ) return FALSE; + + // ϼ ʽ¾ + if( ( pszP = strstr( pszP, szTurn ) ) != NULL){ + pszP += sizeof( szTurn ); + sscanf( pszP, "%d", &turn ); + } + + // į + battleindex = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEINDEX ); + attackNo = BATTLE_Index2No( battleindex, charaindex ); + + // 幻 + BATTLE_MultiResAndDef( battleindex, attackNo, toNo, + pow, par, status, turn, MAGIC_EFFECT_USER, SPR_difence ); + + return TRUE; +} + +#ifdef _ATTACK_MAGIC + +int MAGIC_AttMagic_Battle( int charaindex , int toNo , int marray , int mp ) +{ + int attno , attidx , battleindex; + int attr = -1, i , power; + char aszattr[][32] = { "", "ˮ", "", "" }; + char buf1[256]; + char *magicarg; + int magiclv=0; + magicarg = MAGIC_getChar( marray , MAGIC_OPTION ); + if( magicarg == "\0" ) { + print("\n Magic magicarg == NULL "); + return FALSE; + } + + for( i=0; i<4; i++) { + if( strstr( magicarg, aszattr[i]) != NULL ) { + attr = i; + break; + } + } + if( i == 4 ) { + //print("\n not find aszattr !!"); + return FALSE; + } + memset( buf1, 0, sizeof( buf1)); + if( getStringFromIndexWithDelim( magicarg, "|", 2, buf1, sizeof( buf1)) == FALSE ) return FALSE; + power = atoi( buf1); + + if( getStringFromIndexWithDelim( magicarg, "|", 3, buf1, sizeof( buf1)) == FALSE ) return FALSE; + magiclv = atoi( buf1); + + battleindex = CHAR_getWorkInt( charaindex , CHAR_WORKBATTLEINDEX ); + attno = BATTLE_Index2No( battleindex , charaindex ); + attidx = MAGIC_getInt( marray , MAGIC_IDX ); + if( -1 == attidx || attidx >= ATTMAGIC_magicnum ) + return FALSE; +#ifdef _FIX_MAGICDAMAGE + BATTLE_MultiAttMagic( battleindex , attno , toNo , attidx , attr , power, magiclv); +#else + BATTLE_MultiAttMagic( battleindex , attno , toNo , attidx , attr , power ); +#endif + return TRUE; +} + +#endif + + +#ifdef _MAGIC_TOCALL + +int MAGIC_ToCallDragon_Battle( int charaindex , int toNo , int marray , int mp ) +{ + int attno , attidx , battleindex; + int attr = -1,/* i , */power, imageno; +// char aszattr[][32] = { "", "ˮ", "", "" }; + char buf1[256]; + char *magicarg; + //int magiclv=0; + magicarg = MAGIC_getChar( marray , MAGIC_OPTION ); + + if( magicarg == "\0" ) { + //print("\n Magic magicarg == NULL "); + return FALSE; + } +/* + for( i=0; i<4; i++) { + if( strstr( magicarg, aszattr[i]) != NULL ) { + attr = i; + break; + } + } + if( i == 4 ) { + print("\n not find aszattr !!"); + return FALSE; + } +*/ + memset( buf1, 0, sizeof( buf1)); + if( getStringFromIndexWithDelim( magicarg, "|", 1, buf1, sizeof( buf1)) == FALSE ) return FALSE; + imageno = atoi( buf1); + if( getStringFromIndexWithDelim( magicarg, "|", 2, buf1, sizeof( buf1)) == FALSE ) return FALSE; + power = atoi( buf1); + + battleindex = CHAR_getWorkInt( charaindex , CHAR_WORKBATTLEINDEX ); + attno = BATTLE_Index2No( battleindex , charaindex ); + attidx = MAGIC_getInt( marray , MAGIC_IDX ); + if( -1 == attidx || attidx >= ATTMAGIC_magicnum ) + return FALSE; + + BATTLE_MultiToCallDragonMagic( battleindex , attno , toNo , attidx , attr , power, imageno); + + return TRUE; +} + +#endif + +//**************************************************************** +// +// +// +int MAGIC_CaptureUp_Battle( + int charaindex, // м̼͵ + int toNo, // ľм̼͵ + int marray, // magicindex + int mp // MP +) +// TRUE +// FALSE +//**************************************************************** +{ + char *magicarg; + int attackNo, ReceveEffect; + int battleindex, pow = 5; + + // ɷ¶ë + magicarg = MAGIC_getChar( marray, MAGIC_OPTION ); + + if( sscanf( magicarg, "%d", &pow ) != 1 ){ + // Ϻ̼¾ + pow = 5; + } + + ReceveEffect = SPR_hoshi; + + // į + battleindex = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEINDEX ); + attackNo = BATTLE_Index2No( battleindex, charaindex ); + + // 幻 + BATTLE_MultiCaptureUp( battleindex, attackNo, toNo, + pow, MAGIC_EFFECT_USER, ReceveEffect ); + + return TRUE; +} +#ifdef _FIX_MAGICDAMAGE +static int BATTLE_getMagicAdjustInt( int attackindex, int defindex, int MagicLv, int flg,int damage ) +{ + int At_Fire, At_Earth, At_Water, At_Wind, At_none; + int Df_Fire, Df_Earth, Df_Water, Df_Wind, Df_none; + float At_FieldPow, Df_FieldPow; + //ȡʩ + BATTLE_GetAttr(attackindex,&At_Fire,&At_Water,&At_Earth,&At_Wind,&At_none); + MagicLv *=10; + switch( flg) { //ûΪħǣ + case 0: + At_Earth = MagicLv+(MagicLv*(At_Earth/50)); + At_Water=0; At_Fire=0; At_Wind=0; + break; + case 1: + At_Water = MagicLv+(MagicLv*(At_Water/50)); + At_Earth=0; At_Fire=0; At_Wind=0; + break; + case 2: + At_Fire = MagicLv+(MagicLv*(At_Fire/50)); + At_Earth=0; At_Water=0; At_Wind=0; + break; + case 3: + At_Wind = MagicLv+(MagicLv*(At_Wind/50)); + At_Earth=0; At_Water=0; At_Fire=0; + break; + } + //ȡøóԼӳ + At_FieldPow = BATTLE_FieldAttAdjust( + CHAR_getWorkInt( attackindex, CHAR_WORKBATTLEINDEX ), + At_Fire, At_Water, + At_Earth, At_Wind ); + At_Fire *= damage; At_Water *= damage; At_Earth *= damage; + At_Wind *= damage; At_none *= damage; + //ȡ÷ط + BATTLE_GetAttr( defindex, &Df_Fire, &Df_Water, + &Df_Earth,&Df_Wind, &Df_none ); + //ȡøóԼӳ + Df_FieldPow = BATTLE_FieldAttAdjust( + CHAR_getWorkInt( defindex, CHAR_WORKBATTLEINDEX ), + Df_Fire, Df_Water, Df_Earth, Df_Wind ); + // + damage = BATTLE_AttrCalc( + At_Fire, At_Water, At_Earth, At_Wind, At_none, + Df_Fire, Df_Water, Df_Earth, Df_Wind, Df_none ); + damage *= (At_FieldPow / Df_FieldPow); + return damage; +} + +void Magic_ComputeAttExp( int charindex, int Mnum, int MagicLv, int Expoint) +{ + int magiclv1, magicex1; + int addEx = (MagicLv * 3) * Expoint; + char MagicStr[][128]={"","ˮ","",""}; + char buf1[256]; + memset( buf1, 0, sizeof( buf1)); + magiclv1 = CHAR_getInt( charindex, CHAR_EARTH_EXP+Mnum); + magicex1 = CHAR_getInt( charindex, CHAR_EARTH_ATTMAGIC_EXP+Mnum); + magicex1 += addEx; + if( magicex1 > 100 ) { + magicex1 = 0; + if( magiclv1 < 100 ) { + magiclv1 += 1; + sprintf( buf1,"%sħΪ%d", MagicStr[Mnum], magiclv1); + CHAR_talkToCli( charindex, -1, buf1, CHAR_COLORYELLOW); + } + } + if( magicex1 < 0 ) magicex1 = 0; + if( magiclv1 < 0 ) magiclv1 = 0; + if( magiclv1 > 100 ) magiclv1 = 100; + CHAR_setInt( charindex, CHAR_EARTH_EXP+Mnum, magiclv1); + CHAR_setInt( charindex, CHAR_EARTH_ATTMAGIC_EXP+Mnum, magicex1); + + Mnum = (Mnum+1)%4; //˵ħ + magiclv1 = CHAR_getInt( charindex, CHAR_EARTH_EXP+Mnum); + magicex1 = CHAR_getInt( charindex, CHAR_EARTH_ATTMAGIC_EXP+Mnum); + if( magiclv1 > 1 ) { + magicex1 -= addEx*0.5; + if( magicex1 < 0 ) { + magicex1 = 0; + magiclv1 -= 1; + if( magiclv1 < 0 ) magiclv1 = 0; + CHAR_setInt( charindex, CHAR_EARTH_EXP+Mnum, magiclv1); + sprintf( buf1,"%sħ½Ϊ%d", MagicStr[Mnum], magiclv1); + CHAR_talkToCli( charindex, -1, buf1, CHAR_COLORYELLOW); + } + CHAR_setInt( charindex, CHAR_EARTH_ATTMAGIC_EXP+Mnum, magicex1); + } + return; +} + +void Magic_ComputeDefExp( int charindex, int Mnum, int MagicLv, int Damage) +{ + int magiclv1; + int magicex1; + int addEx; + char buf1[256]; + char MagicStr[][128]={"","ˮ","",""}; + if( Damage < 200 ) return; + memset( buf1, 0, sizeof( buf1)); + magiclv1 = CHAR_getInt( charindex, CHAR_EARTH_RESIST+Mnum); + magicex1 = CHAR_getInt( charindex, CHAR_EARTH_DEFMAGIC_EXP+Mnum); + addEx = (Damage/20)*(MagicLv*2); + magicex1+=addEx; + if( magiclv1 < 0 ) magiclv1 = 0; + if( magicex1 > 100 ) { + magicex1 = 0; + if( magiclv1 < 100 ) { + magiclv1 +=1; + if( magiclv1 < 0 ) magiclv1 = 0; + if( magiclv1 > 100 ) magiclv1 = 100; + CHAR_setInt( charindex, CHAR_EARTH_RESIST+Mnum, magiclv1); + sprintf( buf1,"%sħֵΪ%d", MagicStr[Mnum], magiclv1); + CHAR_talkToCli( charindex, -1, buf1, CHAR_COLORYELLOW); + } + } + if( magicex1 < 0 ) magicex1 = 0; + CHAR_setInt( charindex, CHAR_EARTH_DEFMAGIC_EXP+Mnum, magicex1); + Mnum = (Mnum+1)%4; //˵ħ + magiclv1 = CHAR_getInt( charindex, CHAR_EARTH_RESIST+Mnum); + magicex1 = CHAR_getInt( charindex, CHAR_EARTH_DEFMAGIC_EXP+Mnum); + if( magiclv1 > 1 ) { + magicex1 -=2; + if( magicex1 < 0 ) { + magicex1 = 90; + magiclv1 -=1; + if( magiclv1 < 0 ) + magiclv1 = 0; + sprintf( buf1,"%sħֵ½Ϊ%d", MagicStr[Mnum], magiclv1); + CHAR_talkToCli( charindex, -1, buf1, CHAR_COLORYELLOW); + CHAR_setInt( charindex, CHAR_EARTH_RESIST+Mnum, magiclv1); + } + CHAR_setInt( charindex, CHAR_EARTH_DEFMAGIC_EXP+Mnum, magicex1); + } + return; +} + +#endif + +#ifdef _MAGIC_WEAKEN +int MAGIC_ParamChange_Turn_Battle( + int charaindex, + int toNo, + int marray, + int mp +) +{ + char *magicarg; + int status = -1, i, attackNo, turn = 3; + int battleindex, Success = 15; + char *pszP; + char szTurn[] = "turn"; + char szSuccess[] = ""; + magicarg = MAGIC_getChar( marray, MAGIC_OPTION ); + if( magicarg == "\0" ) { + //print("\n magicarg == NULL "); + return FALSE; + } + pszP = magicarg; + // ë + for( ;status == -1 && pszP[0] != 0; pszP++ ){ + // ྮո + for( i = 1; i < BATTLE_ST_END; i ++ ){ + // + if( strncmp( pszP, aszStatus[i], 2 ) == 0 ){ + status = i; + pszP +=2; + break; + } + } + } + + if( status == -1 ) return FALSE; + + if( ( pszP = strstr( pszP, szTurn ) ) != NULL){ + pszP += sizeof( szTurn ); + sscanf( pszP, "%d", &turn ); + } + + if( ( pszP = strstr( pszP, szSuccess ) ) != NULL){ + pszP += sizeof( szSuccess ); + sscanf( pszP, "%d", &Success ); + } + battleindex = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEINDEX ); + attackNo = BATTLE_Index2No( battleindex, charaindex ); + BATTLE_MultiParamChangeTurn( battleindex, attackNo, toNo, status, MAGIC_EFFECT_USER, SPR_hoshi, turn, Success ); + return TRUE; +} + +void BATTLE_MultiParamChangeTurn( + int battleindex, + int attackNo, + int toNo, + int status, + int UseEffect, + int RecevEffect, + int turn, + int Success +) +{ + + int i, toindex,perStatus,charaindex; + int ToList[SIDE_OFFSET*2+1]; + charaindex = BATTLE_No2Index( battleindex, attackNo ); //index + BATTLE_MultiList( battleindex, toNo, ToList ); + + //ʩħЧ + BATTLE_MagicEffect(battleindex, attackNo, ToList, UseEffect, RecevEffect); + + for( i = 0; ToList[i] != -1; i ++ ) + { + toindex = BATTLE_No2Index( battleindex, ToList[i] ); + + if( BATTLE_StatusAttackCheck( charaindex, + toindex, status, Success, 30, 1.0, &perStatus ) == TRUE ) + { + CHAR_setWorkInt( toindex, CHAR_WORKWEAKEN, turn+1 ); + } + } + return; + +} +#endif + + +/* +typedef struct tagToCallMagic +{ + unsigned int uiSpriteNum; // Spr_x.binı + unsigned int uiAttackType; // ķʽˣ( ) , ( ) , ( ͬʱ ) , ȫ( ) , ȫ( ͬʱ ) + unsigned int uiSliceTime; // ʱʱ + unsigned int uiShowType; // ʾλ÷ʽ롢ָ + int siSx; // ʾλ - X + int siSy; // ʾλ - Y + unsigned int uiShowBehindChar; // ʾǰ· + unsigned int uiShakeScreen; // Ƿ𶯻 + unsigned int uiShakeFrom; // 𶯻ʼʱ( ) + unsigned int uiShakeTo; // 𶯻Ľʱ( _ + unsigned int uiPrevMagicNum; // ǰ( 0XFFFFFFFFFF ʾǰ ) + int siPrevMagicSx; // ǰʾλ - X + int siPrevMagicSy; // ǰʾλ - Y + int siPrevMagicOnChar; // ǰʾǰ· + unsigned int uiPostMagicNum; // ( 0XFFFFFFFF ʾ ) + int siPostMagicSx; // ʾλ - X + int siPostMagicSy; // ʾλ - Y + int siPostMagicOnChar; // ʾǰ· + int isPostDisappear; // һ㹥ʱǷʧ + int ToCallMagicNo; // ٻı +}ToCallMagic; +*/ + +ToCallMagic PROFESSION_magic[3] = { {0,0,0,1,0,0,1,1,0,0,0,65528,65485,0,-1,0,0,0,1,0}, // + {0,3,0,1,0,0,1,1,0,0,0,65528,65485,0,-1,0,0,0,1,1}, // + {0,5,0,1,0,0,1,1,0,0,0,65528,65485,0,-1,0,0,0,0,2}, // ȫ + }; + + +#ifdef _PROFESSION_SKILL // WON ADD ְҵ +void PROFESSION_MAGIC_ATTAIC( int battleindex, int attackNo, int toNo, int attIdx ,int FieldAttr, int skill) +{ + int list[SIDE_OFFSET * 2 + 1]; + int listidx,i,j,k,z; + int basey, def_is_player[10],def_be_hit[10]; + int attvalue , charahp , pethp , charaidx , petidx , charahurt,charahurt_temp; + char szcommand[256]; + int DefIsPlayer=0, power=0, skill_level; + float hp_power=0, mp_power=0, add_hp=0, add_mp=0, dec_hp=0, dec_mp=0; + int icindex, ioindex; + int charaindex, command, magic_type=0; +#ifdef _PROFESSION_ADDSKILL + int decmplist[]={-1,-1,-1,-1,-1,-1,-1,-1,-1,-1}, decmplistcount=0; +#endif + charaindex = BATTLE_No2Index(battleindex, attackNo); + if( !CHAR_CHECKINDEX(charaindex) ) return; + + if((z = BATTLE_MultiList(battleindex,toNo,list)) == -1) return; + else if(z != toNo){ + toNo = z; +// terry fix for 趨ΪµĿ 2004/02/10 + CHAR_setWorkInt(charaindex,CHAR_WORKBATTLECOM2,toNo); +// end + } + + // + command = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM1); + + // ܵȼ + skill_level = CHAR_GETWORKINT_HIGH( charaindex, CHAR_WORKBATTLECOM3); + skill_level = PROFESSION_CHANGE_SKILL_LEVEL_M( skill_level ); + + // ħ붯 + magic_type = analysis_profession_parameter( attIdx, skill, toNo, charaindex ); + PROFESSION_MAGIC_ATTAIC_Effect( battleindex, attackNo, list, attIdx); + + listidx = 0; + memset(def_is_player,-1,sizeof(def_is_player)); + memset(def_be_hit,-1,sizeof(def_be_hit)); + + // ˹ + if( toNo < 20 ){ + toNo = list[0]; + listidx++; + + } else if( 20 == toNo ){ // ȫ + for( i = 0 ; i < 2 ; i++ ){ + for( j = 0 ; j < 5 ; j++ ){ + if(TRUE == BATTLE_TargetCheck( battleindex , CharTable[i + 2][j] ) ){ + list[listidx] = CharTable[i + 2][j]; + listidx++; + } + } + } + } else if( 21 == toNo ){ // ȫ + for( i = 0 ; i < 2 ; i++ ){ + for( j = 0 ; j < 5 ; j++ ){ + if(TRUE == BATTLE_TargetCheck( battleindex , CharTable[i][j] ) ){ + list[listidx] = CharTable[i][j]; + listidx++; + } + } + } + } // ϵһ , ϵڶ , µһ , µڶ + else if( 23 == toNo || 24 == toNo || 25 == toNo || 26 == toNo ){ + basey = toNo - 23; + for( i = 0 , j = basey - 1 ; j <= basey + 1 ; i++ , j++ ){ + if( ( 25 == toNo || 26 == toNo ) && ( j < 2 || j > 3 ) ) + continue; + else if( ( 23 == toNo || 24 == toNo ) && ( j < 0 || j > 1 ) ) + continue; + // ЩҪ嵥 + for( k = 0 ; k < 5 ; k++ ){ + if(TRUE == BATTLE_TargetCheck( battleindex , CharTable[j][k] ) ) + { + list[listidx] = CharTable[j][k]; + listidx++; + } + } + } + } + qsort( list , listidx , sizeof( list[0] ) , ( FUNC )SortLoc );// λ + + // ȡ + PROFESSION_MAGIC_GET_PRACTICE( &hp_power, &mp_power, &dec_hp, &dec_mp, charaindex ); + + + power = hp_power; + + // ȡ list + PROFESSION_MAGIC_TOLIST_SORT( list, &listidx, charaindex ); + + for( i = 0 ; i < listidx ; i++ ) { + int defType; + charaidx = BATTLE_No2Index( battleindex , list[i] ); + petidx = BATTLE_getRidePet( charaidx ); + defType = CHAR_getInt(charaidx, CHAR_WHICHTYPE); + DefIsPlayer = 0; + + if( !CHAR_CHECKINDEX(charaidx) ) continue; + + // ħЧ + if (CHAR_createCharacter( 100354, 777, 45, 45, 0, &icindex, &ioindex, 0) == TRUE){ + + CHAR_setInt( icindex, CHAR_LUCK, 1); + CHAR_setWorkInt( icindex, CHAR_WORKATTACKPOWER, power ); + CHAR_setWorkInt( icindex, CHAR_WORKOTHERDMAGE, 0 ); + + + // ħм춨 + if( PROFESSION_MAGIC_DODGE( charaindex, charaidx, magic_type ) == 1 ){ + // MISS + attvalue = 0; + }else{ + // ȡħ˺ֵ + power = PROFESSION_MAGIC_GET_ICE_MIRROR_DAMAGE( charaindex, charaidx, command, power ); +#ifdef _SUIT_ADDPART4 + if( CHAR_getWorkInt( charaidx, CHAR_WORKUNMPOWER ) > 0 ){//ֿʦħװ + power -= power * (CHAR_getWorkInt( charaidx, CHAR_WORKUNMPOWER )/100.00); +// print("\nWORKUNMPOWER:%d", CHAR_getWorkInt( charaidx, CHAR_WORKUNMPOWER )); + } +#endif + // ȡħ˺ֵ +#ifdef _PROFESSION_ADDSKILL + attvalue = PROFESSION_MAGIC_GET_DAMAGE( charaindex, charaidx, magic_type, power, command ); +#else + attvalue = PROFESSION_MAGIC_GET_DAMAGE( charaindex, charaidx, magic_type, power ); +#endif + // ı״̬ħ + PROFESSION_MAGIC_CHANGE_STATUS( charaindex, attvalue, mp_power, &add_hp, &add_mp ); + + // ⹥ + attvalue = PROFESSION_MAGIC_CHANG_STATUS( command, battleindex, charaindex, charaidx, attvalue, i ); + def_be_hit[i] = charaidx; + +#ifdef _PROFESSION_ADDSKILL + if( command == BATTLE_COM_S_STORM ){// ˮ + if( (PROFESSION_BATTLE_StatusAttackCheck( charaindex, charaidx, BATTLE_ST_WATER, 30 ) == 0 )// ״̬м춨 + || (CHAR_getInt( charaidx, CHAR_HP ) <= 0 ) ){ + + }else{ + int bid = BATTLE_Index2No( battleindex, charaidx ); + int watercount=0; + if( skill_level > 8 ) watercount=5; + else if( skill_level > 6 ) watercount=4; + else if( skill_level > 4 ) watercount=3; + else if( skill_level > 3 ) watercount=2; + else watercount=1; + CHAR_setWorkInt( charaidx, CHAR_WORKWATER, watercount ); + BATTLE_BadStatusString( bid, BATTLE_ST_WATER ); + } + } + + //¼idx + decmplist[decmplistcount++] = list[i]; +#endif + } + + // ħЧ + CHAR_CharaDelete(icindex); + + + charahp = CHAR_getInt( charaidx, CHAR_HP ); + + // û + if( -1 == petidx || CHAR_getInt(petidx, CHAR_HP) <= 0 ){ + if( ( charahp -= attvalue ) < 0 ){ + charahp = 0; + } + CHAR_setInt( charaidx , CHAR_HP , charahp ); + pethp = 0; + if( 0 == PROFESSION_magic[attIdx].uiAttackType ) {// ˹ + sprintf( szcommand , "%X|%X|%X|%X|" , toNo , list[i] , attvalue , pethp); + } else + sprintf( szcommand , "%X|%X|%X|%X|" , list[i] , list[i] , attvalue , pethp); + + }else{ + pethp = CHAR_getInt( petidx , CHAR_HP ); + charahurt = attvalue * BATTLE_CalcCharaRatio( FieldAttr , charaidx ) / 10; + + //µļ,ﱻ,Ѫ۵Ļ,Ὣ˺ۼ + charahurt_temp = charahurt; + if( ( charahp -= charahurt ) < 0 ) + { + charahurt = charahp; + charahp = 0; + } + + attvalue = attvalue - charahurt; + if( ( pethp -= attvalue ) < 0) + { + pethp = 0; + // ûѪ˳ս + CHAR_setInt(charaidx,CHAR_RIDEPET,-1); + BATTLE_changeRideImage(charaidx); + CHAR_setWorkInt(charaidx,CHAR_WORKPETFALL,1); + } + CHAR_setInt( charaidx , CHAR_HP , charahp ); + CHAR_setInt( petidx , CHAR_HP , pethp ); + + charahurt = charahurt_temp; + + if( 0 == PROFESSION_magic[attIdx].uiAttackType ) {// ˹ + sprintf( szcommand , "%X|%X|%X|%X|" , toNo , list[i] , charahurt , attvalue); + } else + sprintf( szcommand , "%X|%X|%X|%X|" , list[i] , list[i] , charahurt , attvalue); + } + + + { + //Change fix õDPֵ + int aAttackList[BATTLE_ENTRY_MAX*2+1]; + aAttackList[0] = attackNo; + aAttackList[1] = -1; + BATTLE_AddProfit( battleindex, aAttackList); + } + //change fix ޿ (зְսᶼòDPֵ,õ,ûϵ) + if( CHAR_getInt( charaidx, CHAR_HP ) <= 0 + && CHAR_getInt( charaidx, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER + /*&& !BattleArray[battleindex].dpbattle*/ ) + CHAR_setFlg( charaidx, CHAR_ISDIE, 1 ); + + BATTLESTR_ADD( szcommand ); + } + } + + sprintf( szcommand , "%X|" , 0x5711438 ); + BATTLESTR_ADD( szcommand ); + +#ifdef _PROFESSION_ADDSKILL + //۵зmp + if( (int)mp_power != 0 ){ + for( i=0;i 0 ){ + int mp = CHAR_getInt( BATTLE_No2Index( battleindex , decmplist[i] ), CHAR_MP); + if( mp > 0 ){ + mp = mp_power>mp?mp:mp_power; + sprintf( szcommand, "BD|r%X|1|0|m%X|", decmplist[i], mp ); + BATTLESTR_ADD( szcommand ); + CHAR_setInt(BATTLE_No2Index( battleindex , decmplist[i] ), CHAR_MP, CHAR_getInt( BATTLE_No2Index( battleindex , decmplist[i] ), CHAR_MP) - mp); + } + } + } + } + } + if( command == BATTLE_COM_S_DOOM ){ //ĩ Ч + if( skill_level >= 10 ){ + for( i=0;i 0 ){ + CHAR_setWorkInt( BATTLE_No2Index( battleindex , decmplist[i] ), CHAR_WORKFEAR, 4 ); + BATTLE_BadStatusString( decmplist[i], BATTLE_ST_FEAR ); + sprintf( szcommand, "BD|r%X|0|6|%X|", decmplist[i], -20 );//30% + BATTLESTR_ADD( szcommand ); + // + sprintf( szcommand, "BD|r%X|0|4|%X|", decmplist[i], -10 ); + BATTLESTR_ADD( szcommand ); + // + sprintf( szcommand, "BD|r%X|0|5|%X|", decmplist[i], -10 ); + BATTLESTR_ADD( szcommand ); + } + } + } + } +#endif + if( (int)add_hp != 0 ){ + int hp=0; + + hp = CHAR_getInt( charaindex, CHAR_HP) + add_hp; + + if( hp >= CHAR_getWorkInt(charaindex, CHAR_WORKMAXHP) ){ + hp = CHAR_getWorkInt(charaindex, CHAR_WORKMAXHP); + add_hp = hp - CHAR_getInt( charaindex, CHAR_HP); + }else if ( hp <= 1 ){ + hp = 1; + add_hp = 1 - CHAR_getInt( charaindex, CHAR_HP); + } + CHAR_setInt(charaindex, CHAR_HP, hp); + + sprintf( szcommand, "BD|r%X|0|1|%X|", attackNo, (int)add_hp); + BATTLESTR_ADD( szcommand ); + } + + + if( (int)add_mp != 0 ){ + int mp=0; + + mp = CHAR_getInt( charaindex, CHAR_MP) + add_mp; + + if( mp >= CHAR_getWorkInt(charaindex, CHAR_WORKMAXMP) ){ + mp = CHAR_getWorkInt(charaindex, CHAR_WORKMAXMP); + add_mp = mp - CHAR_getInt( charaindex, CHAR_MP); + }else if ( mp <= 1 ){ + mp = 1; + add_mp = 1 - CHAR_getInt( charaindex, CHAR_MP); + } + + CHAR_setInt(charaindex, CHAR_MP, mp); + + sprintf( szcommand, "BD|r%X|1|1|m%X|", attackNo, (int)add_mp); + + BATTLESTR_ADD( szcommand ); + } +// Terry fix 2003/11/17 ˯˹Է + for(i=0; i 0) { + CHAR_setWorkInt(def_be_hit[i],CHAR_WORKSLEEP,0); + sprintf(szcommand,"BM|%X|%X|",BATTLE_Index2No(battleindex,def_be_hit[i]),0); + BATTLESTR_ADD(szcommand); + } + } +// Terry end +} + + +int PROFESSION_MAGIC_ATTAIC_Effect( int battleindex, int attackNo , int ToList[] , int AttackMgcNo ) +{ + int i; + char szcommand[256]; + int attackindex; + + + attackindex = BATTLE_No2Index( battleindex , attackNo ); + if( FALSE == CHAR_CHECKINDEX( attackindex ) ) + return 0; +#ifdef _PROFESSION_ADDSKILL + //if( CHAR_getWorkInt( attackindex, CHAR_WORKBATTLECOM1 ) == BATTLE_COM_S_ICE_CRACK ) //Ч + // return 0; +#endif + snprintf( szcommand , sizeof( szcommand ) , "B$|a%X|i%X|m%X|%X|%X|%X|s%X|t%X|l%X|%X|%X|%X|%X|%X|%X|o%X|o%X|o%X|s%X|%X|%X|%X|%X|" , + attackNo , 5711438 , CHAR_getInt( attackindex , CHAR_MP ) , + PROFESSION_magic[AttackMgcNo].uiPrevMagicNum , + PROFESSION_magic[AttackMgcNo].uiSpriteNum , + PROFESSION_magic[AttackMgcNo].uiPostMagicNum , + PROFESSION_magic[AttackMgcNo].uiAttackType , + PROFESSION_magic[AttackMgcNo].uiSliceTime , + PROFESSION_magic[AttackMgcNo].uiShowType , + PROFESSION_magic[AttackMgcNo].siSx , + PROFESSION_magic[AttackMgcNo].siSy , + PROFESSION_magic[AttackMgcNo].siPrevMagicSx , + PROFESSION_magic[AttackMgcNo].siPrevMagicSy , + PROFESSION_magic[AttackMgcNo].siPostMagicSx , + PROFESSION_magic[AttackMgcNo].siPostMagicSy , + PROFESSION_magic[AttackMgcNo].siPrevMagicOnChar , + PROFESSION_magic[AttackMgcNo].uiShowBehindChar , + PROFESSION_magic[AttackMgcNo].siPostMagicOnChar , + PROFESSION_magic[AttackMgcNo].uiShakeScreen , + PROFESSION_magic[AttackMgcNo].uiShakeFrom , + PROFESSION_magic[AttackMgcNo].uiShakeTo , + PROFESSION_magic[AttackMgcNo].isPostDisappear , + PROFESSION_magic[AttackMgcNo].ToCallMagicNo + ); + + BATTLESTR_ADD( szcommand ); + + for( i = 0 ; ToList[i] != -1 ; i++ ){ + snprintf( szcommand , sizeof( szcommand ) , "r%X|" , ToList[i] ); + BATTLESTR_ADD( szcommand ); + } + + BATTLESTR_ADD( "FF|" ); + + return 0; +} + +int analysis_profession_parameter( int attIdx, int skill, int toNo, int charaindex ) +{ + int image_1, image_2, place, place2, shake_s_time; + int shake_e_time, disappear, x, y, i; + char temp[64]; + char *pszOption; + // Robin fix profession magic_type + //char magic[3][5]={"","",""}; + char magic[3][5]={"","",""}; + int magic_type=-1; + + + // ȡüܲ + if( (pszOption=PROFESSION_SKILL_getChar(skill,PROFESSION_SKILL_OPTION)) == "\0" ) return -1; + + // ħ + memset( temp, 0, sizeof(temp) ); + if( !getStringFromIndexWithDelim(pszOption,"|",1,temp,sizeof(temp)) ) return -1; + + for( i=0; i<3; i++){ + if( (strcmp( magic[i], temp )) == 0 ) + magic_type = i+1; + } + + switch( magic_type ){ + case 1: + // ӻȾֵ + PROFESSION_SKILL_LVEVEL_UP( charaindex, "PROFESSION_FIRE_PRACTICE" ); + break; + case 2: + // ӱȾֵ + PROFESSION_SKILL_LVEVEL_UP( charaindex, "PROFESSION_ICE_PRACTICE" ); + break; + case 3: + // Ⱦֵ + PROFESSION_SKILL_LVEVEL_UP( charaindex, "PROFESSION_THUNDER_PRACTICE" ); + break; + + } + + // ʾλ÷ʽ 0 1 + memset( temp, 0, sizeof(temp) ); + if( !getStringFromIndexWithDelim(pszOption,"|",2,temp,sizeof(temp)) ) return -1; + place = atoi(temp); + PROFESSION_magic[attIdx].uiShowType = place; + + // ʾǰ· + memset( temp, 0, sizeof(temp) ); + if( !getStringFromIndexWithDelim(pszOption,"|",3,temp,sizeof(temp)) ) return -1; + place2 = atoi(temp); + PROFESSION_magic[attIdx].uiShowBehindChar = place2; + + // ʾλX + memset( temp, 0, sizeof(temp) ); + if( !getStringFromIndexWithDelim(pszOption,"|",4,temp,sizeof(temp)) ) return -1; + x = atoi(temp); + + // ʾλY + memset( temp, 0, sizeof(temp) ); + if( !getStringFromIndexWithDelim(pszOption,"|",5,temp,sizeof(temp)) ) return -1; + y = atoi(temp); + + // 𶯻Ŀʼ + memset( temp, 0, sizeof(temp) ); + if( !getStringFromIndexWithDelim(pszOption,"|",6,temp,sizeof(temp)) ) return -1; + shake_s_time = atoi(temp); + + // 𶯻Ľ + memset( temp, 0, sizeof(temp) ); + if( !getStringFromIndexWithDelim(pszOption,"|",7,temp,sizeof(temp)) ) return -1; + shake_e_time = atoi(temp); + + // һ㹥ʱǷʧ + memset( temp, 0, sizeof(temp) ); + if( !getStringFromIndexWithDelim(pszOption,"|",8,temp,sizeof(temp)) ) return -1; + disappear = atoi(temp); + + // ׼ħͼ + image_1 = PROFESSION_SKILL_getInt( skill, PROFESSION_SKILL_IMG_1); + PROFESSION_magic[attIdx].uiPrevMagicNum = image_1; // ǰö + + // սħͼ + image_2 = PROFESSION_SKILL_getInt( skill, PROFESSION_SKILL_IMG_2); + PROFESSION_magic[attIdx].uiSpriteNum = image_2; // ö + + // ʾڻ x,y + PROFESSION_magic[attIdx].siSx = x; + PROFESSION_magic[attIdx].siSy = y; + + // ȡùұߵħͼż + PROFESSION_MAGIC_GET_IMG2( toNo, charaindex, attIdx, pszOption ); + + // ʱ + if( (shake_s_time>0) || (shake_e_time>0) ){ + PROFESSION_magic[attIdx].uiShakeScreen = 1; + PROFESSION_magic[attIdx].uiShakeFrom = shake_s_time; + PROFESSION_magic[attIdx].uiShakeTo = shake_e_time; + }else{ + PROFESSION_magic[attIdx].uiShakeScreen = 0; + PROFESSION_magic[attIdx].uiShakeFrom = 0; + PROFESSION_magic[attIdx].uiShakeTo = 0; + } + + + return magic_type; +} + + +// ȡȵ˺ +void PROFESSION_MAGIC_GET_PRACTICE( + float *hp_power, + float *mp_power, + float *dec_hp, + float *dec_mp, + int charaindex +) +{ + int skill_level=0, critical=0, command=0; + + skill_level = CHAR_GETWORKINT_HIGH( charaindex, CHAR_WORKBATTLECOM3); + skill_level = PROFESSION_CHANGE_SKILL_LEVEL_M( skill_level ); + + command = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM1); + + critical = RAND( 1,100); + + switch( command ){ + case BATTLE_COM_S_VOLCANO_SPRINGS: // ɽȪ + { + *hp_power = skill_level * 10 + 100; + + if( skill_level >= 10 ){ + if( critical <= 25 ) + *hp_power *= 1.5; + }else{ + if( critical <= (skill_level+12) ) + *hp_power *= 1.5; + } + + break; + } + case BATTLE_COM_S_FIRE_BALL: // + { + if( skill_level >= 10 ) + *hp_power = 360; + else if( skill_level >= 9 ) + *hp_power = 320; + else if( skill_level >= 8 ) + *hp_power = 280; + else if( skill_level >= 7) + *hp_power = 260; + else if( skill_level >= 5) + *hp_power = 220; + else if( skill_level >= 3) + *hp_power = 180; + else + *hp_power = 160; + + break; + } + case BATTLE_COM_S_SUMMON_THUNDER: // + { + *hp_power = skill_level*10 + 200; + break; + } + case BATTLE_COM_S_CURRENT: // + { +#ifdef _PROFESSION_ADDSKILL + if( skill_level >= 10 ) + *hp_power = 300; + else if( skill_level > 9 ) + *hp_power = 250; + else if( skill_level > 7 ) + *hp_power = 200; + else if( skill_level > 4 ) + *hp_power = 150; + else if( skill_level > 1 ) + *hp_power = 10; + else + *hp_power = 50; +#else + *hp_power = skill_level*50 + 100; +#endif + break; + } + case BATTLE_COM_S_STORM: // + { +#ifdef _PROFESSION_ADDSKILL + if( skill_level > 9 ) + *hp_power = 200; + else if( skill_level > 7 ) + *hp_power = 180; + else if( skill_level > 5 ) + *hp_power = 160; + else if( skill_level > 3 ) + *hp_power = 140; + else + *hp_power = 120; +#else + *hp_power = skill_level*10 + 100; +#endif + break; + } + case BATTLE_COM_S_ICE_ARROW: // + { + if( skill_level >= 10 ) + *hp_power = 250; + else + *hp_power = skill_level*10 + 130; + break; + } + case BATTLE_COM_S_ICE_CRACK: // + { + if( skill_level >= 10 ) + *hp_power = 400; + else if ( skill_level == 9 ) + *hp_power = 300; + else + *hp_power = skill_level*10 + 210; + + break; + } + case BATTLE_COM_S_DOOM: // ĩ + { + if( skill_level >= 10 ) + *hp_power = 550; + else if( skill_level > 9 ) + *hp_power = 500; + else if( skill_level > 8 ) + *hp_power = 450; + else if( skill_level > 7 ) + *hp_power = 400; + else if( skill_level > 6 ) + *hp_power = 350; + else if( skill_level > 4 ) + *hp_power = 300; + else if( skill_level > 2 ) + *hp_power = 250; + else + *hp_power = 200; + break; + } + case BATTLE_COM_S_FIRE_SPEAR: // ǹ + { +#ifdef _JOB_FIX + if( skill_level > 9 ) + *hp_power = 800 * 2; + else if( skill_level > 8 ) + *hp_power = 450 * 2; + else if( skill_level > 7 ) + *hp_power = 400 * 2; + else if( skill_level > 6 ) + *hp_power = 350 * 2; + else if( skill_level > 5 ) + *hp_power = 300 * 2; + else if( skill_level > 3 ) + *hp_power = 200 * 2; + else + *hp_power = 100 * 2; +#else + if( skill_level >= 10 ) + *hp_power = 550; + else if( skill_level > 9 ) + *hp_power = 500; + else if( skill_level > 8 ) + *hp_power = 450; + else if( skill_level > 7 ) + *hp_power = 400; + else if( skill_level > 6 ) + *hp_power = 350; + else if( skill_level > 4 ) + *hp_power = 300; + else if( skill_level > 2 ) + *hp_power = 250; + else + *hp_power = 200; +#endif + break; + } + + case BATTLE_COM_S_BLOOD: // Ѫ + { + int hp = CHAR_getInt( charaindex, CHAR_HP); + if( hp > 1 ) + *hp_power = CHAR_getInt( charaindex, CHAR_HP) * (skill_level*5 +10) /100; + else + *hp_power = 0; + + break; + } + case BATTLE_COM_S_BLOOD_WORMS: // Ѫ + { + *hp_power = skill_level*10+20; + break; + } + case BATTLE_COM_S_SIGN: // һѪ + { +#ifdef _PROFESSION_ADDSKILL + if( skill_level >= 10 ){ + *hp_power = 200; + *mp_power = 30; + }else if( skill_level > 6 ){ + *hp_power = 150; + *mp_power = 20; + }else if( skill_level > 3 ){ + *hp_power = 100; + *mp_power = 15; + }else{ + *hp_power = 50; + *mp_power = 10; + } +#else + if( skill_level >= 10 ){ + *hp_power = 300; + *mp_power = 70; + }else if( skill_level >= 9 ){ + *hp_power = 200; + *mp_power = 50; + }else if( skill_level >= 7 ){ + *hp_power = 150; + *mp_power = 30; + }else if( skill_level >= 4 ){ + *hp_power = 100; + *mp_power = 20; + }else{ + *hp_power = 50; + *mp_power = 10; + } +#endif + break; + } + case BATTLE_COM_S_ENCLOSE: // + { +#ifdef _PROFESSION_ADDSKILL + if( skill_level >= 10 ) + *hp_power = 400; + else if( skill_level > 9 ) + *hp_power = 300; + else if( skill_level > 7 ) + *hp_power = 250; + else if( skill_level > 4 ) + *hp_power = 200; + else + *hp_power = 150; + break; +#else + if( skill_level >= 10 ) + *hp_power = 300; + else if( skill_level >= 8 ) + *hp_power = 250; + else if( skill_level >= 5 ) + *hp_power = 200; + else + *hp_power = 150; + break; +#endif + } + default: + break; + } + +#ifdef _SUIT_ADDENDUM + *hp_power += *hp_power * (CHAR_getWorkInt( charaindex, CHAR_WORKMPOWER )/100.00); +#endif +#ifdef _SUIT_ADDPART4 + if( rand()%100 < 30 ) + *hp_power += *hp_power * (CHAR_getWorkInt( charaindex, CHAR_WORKMPOWER2 )/100.00);//ǿʦħװ(޶30%) +#endif + + if( *hp_power > 0 ){ + float rand_num = RAND( 98, 102 ); + *hp_power *= rand_num / 100; + }else{ + *hp_power = 0; + } +} + + +// ѡĻ +void PROFESSION_MAGIC_TOLIST_SORT( int *list, int *listidx, int charaindex ) +{ + int j=0, get_num=0, temp[SIDE_OFFSET * 2 + 1]; + int skill_level=-1, command=-1; + + skill_level = CHAR_GETWORKINT_HIGH( charaindex, CHAR_WORKBATTLECOM3); + skill_level = PROFESSION_CHANGE_SKILL_LEVEL_M( skill_level ); + + command = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM1); + + switch(command){ + case BATTLE_COM_S_CURRENT: // + { +#ifdef _PROFESSION_ADDSKILL + if( skill_level > 9 ) get_num = 10; + else if( skill_level > 8 ) get_num = 9; + else if( skill_level > 7 ) get_num = 8; + else if( skill_level > 6 ) get_num = 7; + else if( skill_level > 5 ) get_num = 6; + else if( skill_level > 4 ) get_num = 5; + else if( skill_level > 3 ) get_num = 4; + else if( skill_level > 2 ) get_num = 3; + else if( skill_level > 1 ) get_num = 2; + else get_num = 1; +#else + if( skill_level >= 9 ) get_num = 5; + else if( skill_level >= 7 ) get_num = 4; + else if( skill_level >= 5 ) get_num = 3; + else if( skill_level >= 3 ) get_num = 2; + else get_num = 1; +#endif + break; + } + case BATTLE_COM_S_STORM: // + { + get_num = skill_level; + break; + } + case BATTLE_COM_S_DOOM: // ĩ + { + if( skill_level >= 8 ) get_num = 10; + else if( skill_level >= 7 ) get_num = 8; + else if( skill_level >= 5 ) get_num = 6; + else if( skill_level >= 3 ) get_num = 4; + else get_num = 2; + break; + } + case BATTLE_COM_S_FIRE_SPEAR: // ǹ + { + /*int miss_rate=0, rand_num=0; + + miss_rate = skill_level * 2 + 10; + rand_num = RAND(0, 100); + + if( rand_num <= miss_rate ){ + memset(list, -1, sizeof(list)); + *listidx = 0; + return; + }else + get_num = skill_level; + + break;*/ + /* + if( skill_level > 9 ) get_num = 10; + else if( skill_level > 8) get_num = 9; + else if( skill_level > 7 ) get_num = 8; + else if( skill_level > 6 ) get_num = 7; + else if( skill_level > 5 ) get_num = 6; + else if( skill_level > 4 ) get_num = 5; + else if( skill_level > 3 ) get_num = 4; + else if( skill_level > 2 ) get_num = 3; + else if( skill_level > 1 ) get_num = 2; + else get_num = 1; + */ + break; + } + case BATTLE_COM_S_SIGN: // һѪ + { +#ifdef _PROFESSION_ADDSKILL + get_num = 10; +#else + if( skill_level >= 10 ) get_num = 5; + else if( skill_level >= 8 ) get_num = 4; + else if( skill_level >= 6 ) get_num = 3; + else if( skill_level >= 3 ) get_num = 2; + else get_num = 1; +#endif + break; + } + case BATTLE_COM_S_CONVOLUTE: // + case BATTLE_COM_S_FIRE_BALL: // + { + int toNo=-1, toNo2=-1, battleindex=-1, i=0, count=0; + battleindex = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEINDEX ); + + if(battleindex == -1) return; + + toNo = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM2); + memset( temp, -1, sizeof( temp ) ); + + if( toNo == 24 ) toNo2 = 15; + else if( toNo == 23 ) toNo2 = 10; + else if( toNo == 25 ) toNo2 = 5; + else if( toNo == 26 ) toNo2 = 0; + else return; + + for( i=0; i<5; i++ ){ + if(BATTLE_TargetCheck(battleindex,toNo2+i) != FALSE){ + temp[count] = toNo2+i; + count++; + } + } + + memset(list, -1, sizeof(list)); + memcpy( list, temp, sizeof(temp) ); + + *listidx = count; + + return; + } + case BATTLE_COM_S_THROUGH_ATTACK: // ᴩ + { + int toNo = -1, toNo2 = -1, battleindex = -1; + + battleindex = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEINDEX ); + if(battleindex == -1) return; + + toNo = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM2); + memset( temp, -1, sizeof( temp ) ); + temp[0] = toNo; + + if( toNo < (SIDE_OFFSET/2) ) toNo2= toNo + (SIDE_OFFSET/2); + else if( toNo < (SIDE_OFFSET) ) toNo2= toNo - (SIDE_OFFSET/2); + else if( toNo < (SIDE_OFFSET*1.5) ) toNo2= toNo + (SIDE_OFFSET/2); + else if( toNo < (SIDE_OFFSET*2) ) toNo2= toNo - (SIDE_OFFSET/2); + + if(BATTLE_TargetCheck( battleindex, toNo2 ) != FALSE){ + if( toNo2 > toNo ){ + temp[0] = toNo2; + temp[1] = toNo; + }else + temp[1] = toNo2; + + *listidx = 2; + }else + *listidx = 1; + + memset(list, -1, sizeof(list)); + memcpy( list, temp, sizeof(temp) ); + + } + default: + return; + } + + if( get_num == 0 ) return; + + if( get_num >= 10) get_num=10; + + if( get_num >= *listidx ) return; + + memset(temp, -1, sizeof(temp)); + + while( j < get_num ){ + int rand_num=-1, out_num=-1; + + rand_num = RAND(0, *listidx-1); + out_num = list[rand_num]; + list[rand_num] = -1; + + if(out_num > 0){ + temp[j] = out_num; + j++; + } + } + + memset(list, -1, sizeof(list)); + memcpy( list, temp, sizeof(temp) ); + + *listidx = j; + + return; +} + + +// ı״̬ +void PROFESSION_MAGIC_CHANGE_STATUS( + int charaindex, + int hp_power, + float mp_power, + float *add_hp, + float *add_mp +) +{ + int skill_level=0, command=0, critical=0; + critical = RAND( 1,100); + + skill_level = CHAR_GETWORKINT_HIGH( charaindex, CHAR_WORKBATTLECOM3); + skill_level = PROFESSION_CHANGE_SKILL_LEVEL_M( skill_level ); + + command = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM1); + + switch( command ){ + case BATTLE_COM_S_BLOOD: // Ѫ + { + int rate = 0; + + if( skill_level >= 10 ) rate = 20; + else if( skill_level >= 7 ) rate = 15; + else if( skill_level >= 5 ) rate = 10; + else if( skill_level >= 3 ) rate = 5; + else rate = 0; + + *add_mp += hp_power * ( rate + 40 ) / 100; + + break; + } + case BATTLE_COM_S_BLOOD_WORMS: // Ѫ + { + if( skill_level >= 10 ){ + *add_hp += hp_power * 0.2; + break; + }else{ + *add_hp += hp_power * ((skill_level/4)*5 + 5) / 100; + break; + } + break; + } +#ifdef _PROFESSION_ADDSKILL + case BATTLE_COM_S_SIGN: // һѪ + { + int success=10; + /*( skill_level >= 10 ) success = 30;//ɹ + else if( skill_level > 9 ) success = 25; + else if( skill_level > 8 ) success = 20; + else if( skill_level > 7 ) success = 15; + else success = 10; + success = 30;*/ + if( RAND(0,100) < success ){ + if( skill_level > 8 ){ + *add_hp += hp_power; + *add_mp += mp_power; + } + else if( skill_level > 7 ){ + *add_hp += hp_power/2; + *add_mp += 0; + } + } + else + { + *add_hp += 0; + *add_mp += 0; + } + break; + } +#endif + default: + break; + } +} + +// ȡλòĶħͼż +void PROFESSION_MAGIC_GET_IMG2( int toNo, int charaindex, int attIdx, char *pszOption ) +{ + int command=0, img2=0, x=0, y=0; + char temp[64]; + int skill_level=0; + + skill_level = CHAR_GETWORKINT_HIGH( charaindex, CHAR_WORKBATTLECOM3); + skill_level = PROFESSION_CHANGE_SKILL_LEVEL_M( skill_level ); + + command = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM1); + + switch( command ){ + case BATTLE_COM_S_BLOOD: // Ѫ + { + int img=0; + + if( skill_level >= 10 ) img = 101689; + else if( skill_level >= 7 ) img = 101690; + else if( skill_level >= 3 ) img = 101691; + else img = 101692; + + PROFESSION_MAGIC_CHANG_IMG2( img, pszOption, attIdx ); + return; + } + case BATTLE_COM_S_VOLCANO_SPRINGS: // ɽȪ + { + int img=0; + + if( skill_level >= 10 ) img = 101686; + else if( skill_level >= 5 ) img = 101687; + else img = 101688; + + if( toNo >= 0 && toNo < 10 ) + PROFESSION_MAGIC_CHANG_IMG2( img, pszOption, attIdx ); + else{ + int x=0, y=0; + char temp[128]; + + memset( temp, 0, sizeof(temp) ); + if( getStringFromIndexWithDelim(pszOption,"|",11,temp,sizeof(temp)) ) x = atoi(temp); + + memset( temp, 0, sizeof(temp) ); + if( getStringFromIndexWithDelim(pszOption,"|",12,temp,sizeof(temp)) ) y = atoi(temp); + + // ö + PROFESSION_magic[attIdx].uiSpriteNum = img; + + // ö + PROFESSION_magic[attIdx].siSx = x; + PROFESSION_magic[attIdx].siSy = y; + } + + return; + } + case BATTLE_COM_S_BLOOD_WORMS: // Ѫ + { + // ҷ + if( toNo == 20 || toNo == 25 || toNo == 26 || + ( toNo >= 0 && toNo < SIDE_OFFSET ) ) + PROFESSION_MAGIC_CHANG_IMG2( 101623, pszOption, attIdx ); + return; + } + case BATTLE_COM_S_ICE_MIRROR: // + { + if( toNo >= 0 && toNo < 10 ) + PROFESSION_MAGIC_CHANG_IMG2( 101652, pszOption, attIdx ); + else{ + int x=0, y=0; + char temp[128]; + + memset( temp, 0, sizeof(temp) ); + if( getStringFromIndexWithDelim(pszOption,"|",11,temp,sizeof(temp)) ) x = atoi(temp); + + memset( temp, 0, sizeof(temp) ); + if( getStringFromIndexWithDelim(pszOption,"|",12,temp,sizeof(temp)) ) y = atoi(temp); + + // ö + PROFESSION_magic[attIdx].uiSpriteNum = 101652; + + // ö + PROFESSION_magic[attIdx].siSx = x; + PROFESSION_magic[attIdx].siSy = y; + } + + return; + } + case BATTLE_COM_S_ENCLOSE: // + { + // ҷ + if( toNo == 20 || toNo == 25 || toNo == 26 || + ( toNo >= 0 && toNo < SIDE_OFFSET ) ) + PROFESSION_MAGIC_CHANG_IMG2( 101643, pszOption, attIdx ); + return; + } + case BATTLE_COM_S_FIRE_SPEAR: // ǹ + { + // ҷ + //if( toNo == 20 || toNo == 25 || toNo == 26 ) + if( toNo < 10 ) + PROFESSION_MAGIC_CHANG_IMG2( 101642, pszOption, attIdx ); + return; + } + case BATTLE_COM_S_DOOM: // ĩ + { + // ҷ + if( toNo == 20 || toNo == 25 || toNo == 26 ) + PROFESSION_MAGIC_CHANG_IMG2( 101639, pszOption, attIdx ); + return; + } + case BATTLE_COM_S_ICE_CRACK: // + { + // ҷ + if( toNo == 20 || toNo == 25 || toNo == 26 ) + PROFESSION_MAGIC_CHANG_IMG2( 101650, pszOption, attIdx ); + return; + } + case BATTLE_COM_S_ICE_ARROW: // + { + // ҷ + if( toNo == 20 || toNo == 25 || toNo == 26 || + ( toNo >= 0 && toNo < SIDE_OFFSET ) ) + PROFESSION_MAGIC_CHANG_IMG2( 101649, pszOption, attIdx ); + return; + + } + case BATTLE_COM_S_STORM: // + { + // ҷ + if( toNo == 20 || toNo == 25 || toNo == 26 ) + PROFESSION_MAGIC_CHANG_IMG2( 101677, pszOption, attIdx ); + return; + } +#ifdef _PROFESSION_ADDSKILL + case BATTLE_COM_S_BOUNDARY: // Խ + { + // ҷ + if( toNo == 20 || toNo == 25 || toNo == 26 ){ + if( getStringFromIndexWithDelim(pszOption,"|",1,temp,sizeof(temp)) ) + { + if( strcmp( "ؽ", temp ) == 0 ) + PROFESSION_MAGIC_CHANG_IMG2( 101786, pszOption, attIdx ); + else if( strcmp( "ˮ", temp ) == 0 ) + PROFESSION_MAGIC_CHANG_IMG2( 101774, pszOption, attIdx ); + else if( strcmp( "", temp ) == 0 ) + PROFESSION_MAGIC_CHANG_IMG2( 101780, pszOption, attIdx ); + else if( strcmp( "", temp ) == 0 ) + PROFESSION_MAGIC_CHANG_IMG2( 101792, pszOption, attIdx ); + else + PROFESSION_MAGIC_CHANG_IMG2( 101770, pszOption, attIdx ); + } + } + return; + } +#endif + case BATTLE_COM_S_CONVOLUTE: // + { + img2=101656; + if( toNo == 25 ){ // 1 + memset( temp, 0, sizeof(temp) ); + if( getStringFromIndexWithDelim(pszOption,"|",9,temp,sizeof(temp)) ) x = atoi(temp); + memset( temp, 0, sizeof(temp) ); + if( getStringFromIndexWithDelim(pszOption,"|",10,temp,sizeof(temp)) ) y = atoi(temp); + }else if( toNo == 26 ){ // 2 + memset( temp, 0, sizeof(temp) ); + if( getStringFromIndexWithDelim(pszOption,"|",11,temp,sizeof(temp)) ) x = atoi(temp); + memset( temp, 0, sizeof(temp) ); + if( getStringFromIndexWithDelim(pszOption,"|",12,temp,sizeof(temp)) ) y = atoi(temp); + }else if( toNo == 23 ){ // 1 + memset( temp, 0, sizeof(temp) ); + if( getStringFromIndexWithDelim(pszOption,"|",13,temp,sizeof(temp)) ) x = atoi(temp); + memset( temp, 0, sizeof(temp) ); + if( getStringFromIndexWithDelim(pszOption,"|",14,temp,sizeof(temp)) ) y = atoi(temp); + }else if( toNo == 24 ){ // 2 + memset( temp, 0, sizeof(temp) ); + if( getStringFromIndexWithDelim(pszOption,"|",15,temp,sizeof(temp)) ) x = atoi(temp); + memset( temp, 0, sizeof(temp) ); + if( getStringFromIndexWithDelim(pszOption,"|",16,temp,sizeof(temp)) ) y = atoi(temp); + }else + return; + + // ö + PROFESSION_magic[attIdx].uiSpriteNum = img2; + + // ö + PROFESSION_magic[attIdx].siSx = x; + PROFESSION_magic[attIdx].siSy = y; + + break; + } + case BATTLE_COM_S_THROUGH_ATTACK: // ᴩ + { + if( (toNo == 13) || (toNo == 18) ){ // 1 + img2=101676; + x = 50; + y = 240; + }else if( (toNo == 11) || (toNo == 16) ){ // 2 + img2=101675; + x = 120; + y = 200; + }else if( (toNo == 10) || (toNo == 15) ){ // 3 + img2=101674; + x = 140; + y = 160; + }else if( (toNo == 12) || (toNo == 17) ){ // 4 + img2=101673; + x = 160; + y = 120; + }else if( (toNo == 14) || (toNo == 19) ){ // 5 + img2=101672; + x = 180; + y = 80; + }else if( (toNo == 3) || (toNo == 8) ){ // 1 + img2=101665; + memset( temp, 0, sizeof(temp) ); + if( getStringFromIndexWithDelim(pszOption,"|",9,temp,sizeof(temp)) ) x = atoi(temp); + memset( temp, 0, sizeof(temp) ); + if( getStringFromIndexWithDelim(pszOption,"|",10,temp,sizeof(temp)) ) y = atoi(temp); + }else if( (toNo == 1) || (toNo == 6) ){ // 2 + img2=101664; + memset( temp, 0, sizeof(temp) ); + if( getStringFromIndexWithDelim(pszOption,"|",11,temp,sizeof(temp)) ) x = atoi(temp); + memset( temp, 0, sizeof(temp) ); + if( getStringFromIndexWithDelim(pszOption,"|",12,temp,sizeof(temp)) ) y = atoi(temp); + }else if( (toNo == 0) || (toNo == 5) ){ // 3 + img2=101663; + memset( temp, 0, sizeof(temp) ); + if( getStringFromIndexWithDelim(pszOption,"|",13,temp,sizeof(temp)) ) x = atoi(temp); + memset( temp, 0, sizeof(temp) ); + if( getStringFromIndexWithDelim(pszOption,"|",14,temp,sizeof(temp)) ) y = atoi(temp); + }else if( (toNo == 2) || (toNo == 7) ){ // 4 + img2=101662; + memset( temp, 0, sizeof(temp) ); + if( getStringFromIndexWithDelim(pszOption,"|",15,temp,sizeof(temp)) ) x = atoi(temp); + memset( temp, 0, sizeof(temp) ); + if( getStringFromIndexWithDelim(pszOption,"|",16,temp,sizeof(temp)) ) y = atoi(temp); + }else if( (toNo == 4) || (toNo == 9) ){ // 5 + img2=101661; + memset( temp, 0, sizeof(temp) ); + if( getStringFromIndexWithDelim(pszOption,"|",17,temp,sizeof(temp)) ) x = atoi(temp); + memset( temp, 0, sizeof(temp) ); + if( getStringFromIndexWithDelim(pszOption,"|",18,temp,sizeof(temp)) ) y = atoi(temp); + }else + return; + + // ö + PROFESSION_magic[attIdx].uiSpriteNum = img2; + + // ö + PROFESSION_magic[attIdx].siSx = x; + PROFESSION_magic[attIdx].siSy = y; + + // ǰö + if( toNo >= 10 ){ + int img1 = 101671; + PROFESSION_magic[attIdx].uiPrevMagicNum = img1; + } + break; + } + case BATTLE_COM_S_FIRE_BALL: // + { + if( toNo == 25 ){ // 1 + img2=101694; + + memset( temp, 0, sizeof(temp) ); + if( getStringFromIndexWithDelim(pszOption,"|",9,temp,sizeof(temp)) ) x = atoi(temp); + memset( temp, 0, sizeof(temp) ); + if( getStringFromIndexWithDelim(pszOption,"|",10,temp,sizeof(temp)) ) y = atoi(temp); + }else if( toNo == 26 ){ // 2 + img2=101694; + + memset( temp, 0, sizeof(temp) ); + if( getStringFromIndexWithDelim(pszOption,"|",11,temp,sizeof(temp)) ) x = atoi(temp); + memset( temp, 0, sizeof(temp) ); + if( getStringFromIndexWithDelim(pszOption,"|",12,temp,sizeof(temp)) ) y = atoi(temp); + }else if( toNo == 23 ){ // 1 + img2=101693; + + memset( temp, 0, sizeof(temp) ); + if( getStringFromIndexWithDelim(pszOption,"|",13,temp,sizeof(temp)) ) x = atoi(temp); + memset( temp, 0, sizeof(temp) ); + if( getStringFromIndexWithDelim(pszOption,"|",14,temp,sizeof(temp)) ) y = atoi(temp); + }else if( toNo == 24 ){ // 2 + img2=101693; + + memset( temp, 0, sizeof(temp) ); + if( getStringFromIndexWithDelim(pszOption,"|",15,temp,sizeof(temp)) ) x = atoi(temp); + memset( temp, 0, sizeof(temp) ); + if( getStringFromIndexWithDelim(pszOption,"|",16,temp,sizeof(temp)) ) y = atoi(temp); + }else + return; + + // ö + PROFESSION_magic[attIdx].uiSpriteNum = img2; + + // ö + PROFESSION_magic[attIdx].siSx = x; + PROFESSION_magic[attIdx].siSy = y; + + break; + } + default: return; + } + +} + + +#define D_16 (1.0/16) +#define D_8 (1.0/8) +// ȡù˺ +#ifdef _PROFESSION_ADDSKILL +int PROFESSION_MAGIC_GET_DAMAGE( int attackindex, int defindex, int magic_type, int power, int command ) +#else +int PROFESSION_MAGIC_GET_DAMAGE( int attackindex, int defindex, int magic_type, int power ) +#endif +{ + int damage = 0; + +#ifdef _FIX_MAGIC_RESIST // WON ADD ħ + int proficiency=0;// + int resist=0;// + int suit=0;//װ + int spirit=0;//ʹþɵĿ + + if( command == BATTLE_COM_S_DOOM ) + magic_type = 1; + + if( magic_type == 1){ // + proficiency = CHAR_getWorkInt( attackindex, CHAR_WORK_F_PROFICIENCY); // + resist = CHAR_getWorkInt( defindex, CHAR_WORK_F_RESIST); // +#ifdef _EQUIT_RESIST + suit = CHAR_getWorkInt( defindex, CHAR_WORK_F_SUIT)+CHAR_getWorkInt( defindex, CHAR_WORKEQUITFIRE ); +#else + suit = CHAR_getWorkInt( defindex, CHAR_WORK_F_SUIT); +#endif +#ifdef _MAGICSTAUTS_RESIST + if( CHAR_getWorkInt( defindex, CHAR_MAGICFIRE) > 0 ) + spirit = CHAR_getWorkInt( defindex, CHAR_OTHERSTATUSNUMS ); +#endif + } + + if( command == BATTLE_COM_S_DOOM ){ + damage = power * (1+proficiency/100.0) * (1-(resist/100.0)) * (1-(suit/100.0)) * (1-(spirit/100.0)); + magic_type = 2; + } + + if( magic_type == 2){ // + proficiency = CHAR_getWorkInt( attackindex, CHAR_WORK_T_PROFICIENCY); // + resist = CHAR_getWorkInt( defindex, CHAR_WORK_T_RESIST); // 翹 +#ifdef _EQUIT_RESIST + suit = CHAR_getWorkInt( defindex, CHAR_WORK_I_SUIT)+CHAR_getWorkInt( defindex, CHAR_WORKEQUITTHUNDER ); +#else + suit = CHAR_getWorkInt( defindex, CHAR_WORK_I_SUIT); +#endif +#ifdef _MAGICSTAUTS_RESIST + if( CHAR_getWorkInt( defindex, CHAR_MAGICTHUNDER) > 0 ) + spirit = CHAR_getWorkInt( defindex, CHAR_OTHERSTATUSNUMS ); +#endif + } + + if( command == BATTLE_COM_S_DOOM ){ + damage += power * (1+proficiency/100.0) * (1-(resist/100.0)) * (1-(suit/100.0)) * (1-(spirit/100.0)); + magic_type = 3; + } + + if( magic_type == 3){ // + proficiency = CHAR_getWorkInt( attackindex, CHAR_WORK_I_PROFICIENCY); // + resist = CHAR_getWorkInt( defindex, CHAR_WORK_I_RESIST); // +#ifdef _EQUIT_RESIST + suit = CHAR_getWorkInt( defindex, CHAR_WORK_T_SUIT)+CHAR_getWorkInt( defindex, CHAR_WORKEQUITICE ); +#else + suit = CHAR_getWorkInt( defindex, CHAR_WORK_T_SUIT); +#endif +#ifdef _MAGICSTAUTS_RESIST + if( CHAR_getWorkInt( defindex, CHAR_MAGICICE) > 0 ) + spirit = CHAR_getWorkInt( defindex, CHAR_OTHERSTATUSNUMS ); +#endif + } + + if( command == BATTLE_COM_S_DOOM ){ + damage += power * (1+proficiency/100.0) * (1-(resist/100.0)) * (1-(suit/100.0)) * (1-(spirit/100.0)); + damage /= 3.0; + } + else + damage = power * (1+proficiency/100.0) * (1-(resist/100.0)) * (1-(suit/100.0)) * (1-(spirit/100.0)); + +#else //_FIX_MAGIC_RESIST + + fire_proficiency = CHAR_getWorkInt( attackindex, CHAR_WORK_F_PROFICIENCY); // + electric_proficiency = CHAR_getWorkInt( attackindex, CHAR_WORK_T_PROFICIENCY); // + ice_proficiency = CHAR_getWorkInt( attackindex, CHAR_WORK_I_PROFICIENCY); // + fire_resist = CHAR_getWorkInt( defindex, CHAR_WORK_F_RESIST); // + electric_resist = CHAR_getWorkInt( defindex, CHAR_WORK_T_RESIST); // 翹 + ice_resist = CHAR_getWorkInt( defindex, CHAR_WORK_I_RESIST); // + +// print("\n won test 0.0 ==> f(%d) e(%d) i(%d)", fire_proficiency, electric_proficiency, ice_proficiency ); +// print("\n won test 0.1 ==> f(%d) e(%d) i(%d)", fire_resist, electric_resist, ice_resist ); + + if( magic_type == 1){ // + + attack = power * ( 100 + fire_proficiency ) / 100; // ӳ + + if( rand_num < 40){ // ԭ˺ + attack = attack * ( 100 - fire_resist ) / 100; + }else{ // ȡ˺ + rand_num = RAND(-20, 20); + attack = attack * ( 100 - (rand_num + fire_resist) ) / 100; + } +//print( "\nattack:%d ", attack ); + + }else + if( magic_type == 2){ // + + attack = power * ( 100 + electric_proficiency ) / 100; // ӳ + + if( rand_num < 40){ // ԭ˺ + attack = attack * ( 100 - electric_resist ) / 100; + }else{ // ȡ˺ + rand_num = RAND(-20, 20); + attack = attack * ( 100 - (rand_num + electric_resist) ) / 100; + } + }else + if( magic_type == 3){ // + + attack = power * ( 100 + ice_proficiency ) / 100; // ӳ + + if( rand_num < 40){ // ԭ˺ + attack = attack * ( 100 - ice_resist ) / 100; + }else{ // ȡ˺ + rand_num = RAND(-20, 20); + attack = attack * ( 100 - (rand_num + ice_resist) ) / 100; + } + }else{ // + attack = power; + } + + damage = attack; + +#endif + + if( damage < 0 ) + damage = 0; + + return damage; +} + + +// ȡ⹥˺ +int PROFESSION_MAGIC_GET_ICE_MIRROR_DAMAGE( int attackindex, int defindex, int command, int power ) +{ + int damage = power; + + if( command == BATTLE_COM_S_ICE_MIRROR ){ // + float defense = -1; + int rate=0; + int defpet = BATTLE_getRidePet( defindex ); + int skill_level = CHAR_GETWORKINT_HIGH( attackindex, CHAR_WORKBATTLECOM3); + int base_defense = CHAR_getInt( defindex, CHAR_TOUGH ) / 100; + + skill_level = PROFESSION_CHANGE_SKILL_LEVEL_M( skill_level ); + + if( defpet == -1 ) + defense = CHAR_getWorkInt( defindex, CHAR_WORKDEFENCEPOWER ); + else + defense = BATTLE_adjustRidePet3A( defindex, defpet, CHAR_WORKDEFENCEPOWER, DEFFENCESIDE ); +#ifdef _JOB_FIX + if( skill_level >= 10 ){ + rate = 80; + }else{ + rate = skill_level * 5 + 20; + } +#else + if( skill_level >= 10 ){ + rate = 60; + }else{ + rate = skill_level * 5 + 5; + } +#endif + //andy_Edit + damage = 120 + (int)( ( defense * rate / 100 ) + ( ( defense - base_defense ) * rate / 200 ) ); + //ƶnpc˺ + if( CHAR_getInt( defindex , CHAR_WHICHTYPE ) == CHAR_TYPEENEMY ) + damage = damage > 800 ? 800 : damage; + + }else + if( command == BATTLE_COM_S_CONVOLUTE ){ // + int skill_level = CHAR_GETWORKINT_HIGH( attackindex, CHAR_WORKBATTLECOM3); + int hit=0; + + skill_level = PROFESSION_CHANGE_SKILL_LEVEL_A( skill_level ); + + hit = skill_level * 2 + 60; + + //if( rand_num <= hit ){ + // ȡû˺ +#ifdef _JOB_FIX + damage = BATTLE_PROFESSION_CONVOLUTE_GET_DAMAGE( attackindex, defindex, skill_level ) * 1.1; +#else + damage = BATTLE_PROFESSION_CONVOLUTE_GET_DAMAGE( attackindex, defindex, skill_level ); +#endif + //}else{ + // damage = 0; + //} + }else + if( command == BATTLE_COM_S_THROUGH_ATTACK ){ // ᴩ + int skill_level = CHAR_GETWORKINT_HIGH( attackindex, CHAR_WORKBATTLECOM3); + + skill_level = PROFESSION_CHANGE_SKILL_LEVEL_A( skill_level ); + + if( skill_level != 10 ){ + // ½ + CHAR_setWorkInt( attackindex, CHAR_MYSKILLHIT, 1); + CHAR_setWorkInt( attackindex, CHAR_MYSKILLHIT_NUM, -70); + CHAR_setWorkInt( attackindex, CHAR_WORKHITRIGHT, CHAR_getWorkInt(attackindex,CHAR_WORKHITRIGHT) -50 ); + } + + // ȡùᴩ˺ +#ifdef _JOB_FIX + damage = BATTLE_PROFESSION_THROUGH_ATTACK_GET_DAMAGE( attackindex, defindex ) * 0.80; +#else + damage = BATTLE_PROFESSION_THROUGH_ATTACK_GET_DAMAGE( attackindex, defindex ); +#endif + } +#ifdef _PROFESSION_ADDSKILL + else + if( command == BATTLE_COM_S_CURRENT // + || command == BATTLE_COM_S_SUMMON_THUNDER ){// + if( CHAR_getWorkInt( defindex, CHAR_WORKWATER ) > 0 ){//ˮ + if( RAND(1, 100) < 75 ) + damage *= 3; + } + } +#endif + return damage; +} + + + +// +// return: 0:û 1: +int PROFESSION_MAGIC_DODGE( int atk_index, int def_index, int magic_type ) +{ + float fLuck = 0,fResist = 0, proficiency = 0; + float Dluck=0.0; + int charType = CHAR_getInt( def_index, CHAR_WHICHTYPE); + int rand_num = RAND( 1, 100 ); + int command; + + + // Ŀһܣ + if( CHAR_getWorkInt( def_index, CHAR_WORKBATTLECOM1 ) == BATTLE_COM_S_EARTHROUND0 ){ + return 1; // Miss + } + + // Ƿ + if( charType == CHAR_TYPEPLAYER ){ + + // + fLuck = (float)CHAR_getInt( def_index, CHAR_LUCK) * 3; + + // + if( magic_type != 0 ){ + fResist = (float)(CHAR_getWorkInt( def_index, CHAR_WORK_F_RESIST + magic_type - 1 )) * 0.5; + } + fLuck += fResist; + + // ħװ + Dluck = (float)(CHAR_getWorkInt( def_index, CHAR_EQUITQUIMAGIC)*0.4); + + fLuck += Dluck; + + }else {// Ƿdz + fLuck = (float)CHAR_getInt( def_index, CHAR_LV) * 0.15; + if(fLuck > 20) fLuck = 20; + } + + // + // Robin fix + //if( magic_type != 0 ){ + if( magic_type > 0 ){ + proficiency = (float)CHAR_getWorkInt( atk_index, (CHAR_WORK_F_PROFICIENCY + magic_type - 1) ) * 0.2; + fLuck -= proficiency; + } + +/* print("\n PROFESSION_MAGIC_DODGE atk=%s def=%s magic_type(%d)", + CHAR_getChar( atk_index, CHAR_NAME), + CHAR_getChar( def_index, CHAR_NAME), + magic_type ); + print("\n won test 4 ==> rand_num(%d) lucky(%d) fResist(%f) Dluck(%f) proficiency(%f) fLuck(%f)", + rand_num, + CHAR_getInt( def_index, CHAR_LUCK) * 3, + fResist, + Dluck, + proficiency, + fLuck ); +*/ + if( rand_num > (int)fLuck){ +#ifdef _PROFESSION_ADDSKILL + command = CHAR_getWorkInt( atk_index, CHAR_WORKBATTLECOM1); + switch( command ){ + case BATTLE_COM_S_CURRENT: + case BATTLE_COM_S_STORM: + if( RAND( 1, 100 ) < 75 ) + return 0; + else + return 1; + break; + case BATTLE_COM_S_FIRE_SPEAR: + case BATTLE_COM_S_DOOM: + if( RAND( 1, 100 ) < 90 ) + return 0; + else + return 1; + break; + case BATTLE_COM_S_SIGN: + if( RAND( 1, 100 ) < 50 ) + return 0; + else + return 1; + break; + } +#endif + return 0; // hit + } + else + return 1; // Miss +} + +void PROFESSION_MAGIC_CHANG_IMG2( int img2, char *pszOption, int attIdx ) +{ + int x=0, y=0; + char temp[128]; + + memset( temp, 0, sizeof(temp) ); + if( getStringFromIndexWithDelim(pszOption,"|",9,temp,sizeof(temp)) ) x = atoi(temp); + + memset( temp, 0, sizeof(temp) ); + if( getStringFromIndexWithDelim(pszOption,"|",10,temp,sizeof(temp)) ) y = atoi(temp); + + // ö + PROFESSION_magic[attIdx].uiSpriteNum = img2; + + // ö + PROFESSION_magic[attIdx].siSx = x; + PROFESSION_magic[attIdx].siSy = y; +} + + + +int PROFESSION_MAGIC_CHANG_STATUS(int command,int battleindex, int charaindex, int charaidx, int attvalue, int no ) +{ + int i,j; + int skill_level=0; + + skill_level = CHAR_GETWORKINT_HIGH( charaindex, CHAR_WORKBATTLECOM3); + skill_level = PROFESSION_CHANGE_SKILL_LEVEL_M( skill_level ); + + switch( command ){ + case BATTLE_COM_S_THROUGH_ATTACK: // ᴩ + { + int skill_level = CHAR_GETWORKINT_HIGH( charaindex, CHAR_WORKBATTLECOM3); + + skill_level = PROFESSION_CHANGE_SKILL_LEVEL_A( skill_level ); + + if( no == 0 ){ // ǰŵ + attvalue = attvalue * (skill_level * 2 + 70) / 100; + }else if( no == 1 ){ // ŵ + attvalue = attvalue * (skill_level * 2 + 50) / 100; + } + + break; + } + case BATTLE_COM_S_ICE_CRACK: // + { + int hit=0, rand_num = RAND( 0, 100 ); + + //for( j = 1; j < BATTLE_ST_END; j++ ){ //쳣״̬return + // if( CHAR_getWorkInt( charaidx, StatusTbl[j] ) > 0 ) return 0; + //} + // + if( skill_level >= 10 ) hit = 80; + else if( skill_level >= 7 ) hit = 70; + else if( skill_level >= 5 ) hit = 80; + else if( skill_level >= 3 ) hit = 90; + else hit = 100; + + hit = 100; + if( rand_num < hit ){ + int damage=0; + + if( skill_level >= 10 ) damage = attvalue * 1.3; + else if( skill_level >= 7 ) damage = attvalue * 1.25; + else if( skill_level >= 4 ) damage = attvalue * 1.2; + else damage = attvalue * 1.1; + + if( damage <= 0 ) break; + + for( i=0; i<10; i++ ){ + if( CHAR_getWorkInt( charaidx, CHAR_WORKICECRACK+i ) <= 0 ){ + CHAR_setWorkInt( charaidx, CHAR_WORKICECRACK+i, 3 ); + CHAR_setWorkInt( charaidx, CHAR_WORKMODICECRACK+i, damage ); + //print("\niceidx:%d",charaidx); + break; + } + } + //BATTLE_BadStatusString( bid, BATTLE_ST_ICECRACK ); + + } + + // һ˺ + attvalue = 0; + + break; + } + case BATTLE_COM_S_ENCLOSE: // + { + for( j = 1; j < BATTLE_ST_END; j++ ) //쳣״̬return + if( CHAR_getWorkInt( charaidx, StatusTbl[j] ) > 0 ) return attvalue; + + { + int success=0, rand_num=0, round=1; + int bid = BATTLE_Index2No( battleindex, charaidx ); + + skill_level = CHAR_GETWORKINT_HIGH( charaindex, CHAR_WORKBATTLECOM3); + + if( skill_level >= 100 ) success = 60; + else if( skill_level > 90 ) success = 50; + else if( skill_level > 80 ) success = 40; + else if( skill_level > 60 ) success = 30; + else if( skill_level > 30 ) success = 25; + else success = 20; + + if( skill_level > 80 ) round = 3; + else if( skill_level > 50 ) round = 2; + else round = 1; + + rand_num = RAND(0,100); + + if( rand_num <= success ){ //ɹʱĿ +#ifdef _PROFESSION_ADDSKILL + CHAR_setWorkInt( charaidx, CHAR_WORKANNEX, round ); +#else + CHAR_setWorkInt( charaidx, CHAR_WORKCONFUSION, 4 ); + CHAR_setWorkInt( charaidx, CHAR_WORKMODCONFUSION, 100 ); +#endif + BATTLE_BadStatusString( bid, BATTLE_ST_CONFUSION ); + } + } + break; + } + case BATTLE_COM_S_ICE_ARROW: // + { + for( j = 1; j < BATTLE_ST_END; j++ ){ //쳣״̬return + if( CHAR_getWorkInt( charaidx, StatusTbl[j] ) > 0 ) return attvalue; + } + { + int success=0, rand_num=0; + int bid = BATTLE_Index2No( battleindex, charaidx ); + + if( skill_level >= 8 ) success = 25; + else if( skill_level >= 5 ) success = 20; + else if( skill_level >= 2 ) success = 15; + else success = 10; + rand_num = RAND(0,100); + + if( rand_num <= success ){ //ɹʱĿ꽵 + int dec_dex=0, turn=0; + + if( skill_level >= 8 ) dec_dex = 25; + else if( skill_level >= 5 ) dec_dex = 20; + else dec_dex = 10; + + if( skill_level >= 10 ){ + success = 15; + turn = 2; + } + else if( skill_level >= 6 ){ + success = 10; + turn = 1; + } + else{ + success = 5; + turn = 0; + } + if(rand_num <= success){ + CHAR_setWorkInt( charaidx, CHAR_WORKICEARROW, turn ); + } + CHAR_setWorkInt( charaidx, CHAR_WORKMODICEARROW, dec_dex ); + + BATTLE_BadStatusString( bid, BATTLE_ST_ICEARROW ); + } + } + break; + } + case BATTLE_COM_S_BLOOD_WORMS: // Ѫ + { + for( j = 1; j < BATTLE_ST_END; j++ ){ //쳣״̬return + if( CHAR_getWorkInt( charaidx, StatusTbl[j] ) > 0 ) return attvalue; + } + { + int turn=0; + int bid = BATTLE_Index2No( battleindex, charaidx ); + + if( skill_level >= 10 ) turn = 5; + else if( skill_level >= 8 ) turn = 4; + else if( skill_level >= 5 ) turn = 3; + else turn = 2; + + CHAR_setWorkInt( charaidx, CHAR_WORKBLOODWORMS, turn + 1 ); + CHAR_setWorkInt( charaidx, CHAR_WORKMODBLOODWORMS, skill_level ); + CHAR_setWorkInt( charaidx, CHAR_WORKBLOODWORMSID, charaindex ); + + BATTLE_BadStatusString( bid, BATTLE_ST_BLOODWORMS ); + + } + break; + } + case BATTLE_COM_S_SIGN: // һѪ + { +#ifdef _PROFESSION_ADDSKILL +#else + for( j = 1; j < BATTLE_ST_END; j++ ){ //쳣״̬return + if( CHAR_getWorkInt( charaidx, StatusTbl[j] ) > 0 ) return attvalue; + } + { + int turn=0, success=0, rand_num=0; + int bid = BATTLE_Index2No( battleindex, charaidx ); + + // 뿪 +// if( CHAR_getInt( charaidx, CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER ) return attvalue; + + if( skill_level == 10 ) success = 35; + else if( skill_level >= 8 ) success = (skill_level - 3) * 5; + else if( skill_level >= 6 ) success = 20; + else if( skill_level >= 4 ) success = 15; + else if( skill_level >= 2 ) success = 10; + else success = 5; + + rand_num = RAND(0,100); + + if( rand_num <= success ){ //ɹʱĿѪ + if( skill_level >= 10 ) turn = 5; + else if( skill_level >= 7 ) turn = 4; + else if( skill_level >= 4 ) turn = 3; + else turn = 2; + + CHAR_setWorkInt( charaidx, CHAR_WORKSIGN, turn + 1 ); + CHAR_setWorkInt( charaidx, CHAR_WORKMODSIGN, skill_level ); + CHAR_setWorkInt( charaidx, CHAR_WORKSIGNID, charaindex ); + + BATTLE_BadStatusString( bid, BATTLE_ST_SIGN ); + } + } +#endif + break; + } + case BATTLE_COM_S_DOOM: // ĩ + { +/* int rand_num = RAND( 1, 100 ), work, dex; + char szCommand[64]; + int bid = BATTLE_Index2No( battleindex, charaidx ); + + if( skill_level < 10 ) break; +#ifdef _PROFESSION_ADDSKILL + CHAR_setWorkInt( charaidx, CHAR_WORKFEAR, 2 ); + BATTLE_BadStatusString( bid, BATTLE_ST_FEAR ); + work = CHAR_getWorkInt( charaindex, CHAR_WORKQUICK )+20; + dex = work>>1;//50% + sprintf( szCommand, "BD|r%X|0|6|%X|", bid, (-1) * dex ); + BATTLESTR_ADD( szCommand ); +#endif + // + if( rand_num <= 20 ){ + CHAR_setWorkInt( charaidx, CHAR_WORKPARALYSIS, 3 ); + BATTLE_BadStatusString( bid, BATTLE_ST_PARALYSIS ); + }else{ + rand_num = RAND( 1, 100 ); + if( rand_num <= 10 ){ + CHAR_setWorkInt( charaidx, CHAR_WORKCONFUSION, 3 ); + BATTLE_BadStatusString( bid, BATTLE_ST_CONFUSION ); + } + }*/ + + break; + } + } + + + return attvalue; +} + + +#endif + + +#ifdef _PETSKILL_FIREKILL +/* + . ... ... . + *. .. .* . . + . . .. + .. /\_/\_ . + ??̡ ̡??? + ڿ +*/ +void BATTLE_MultiAttMagic_Fire( int battleindex, int attackNo, int defNo, + int FieldAttr , int Power) + +{ + int list[SIDE_OFFSET * 2 + 1]; + int listidx=0,i,j,z,def_be_hit[10],att_magic_lv[4]; + int def_magic_resist[DEF_MAGIC_NUM]; + int attvalue , charahp , pethp , charaidx , petidx , charahurt,pet_att_lv = 1,pet_def_lv = 1,charahurt_temp; + char szcommand[256]; + int AttIsPlayer=0,DefIsPlayer=0; + int getexp = 0; + +#ifndef _FIX_MAGICDAMAGE + int att_magic_exp_add,att_magic_exp_sub,def_magic_exp_add,def_magic_exp_sub; + int lv_up_exp,DefFieldAttr = 0; + float temp = 0.0f; +// int attattr[5], defattr[5]; + char msgbuf[64]; + char kind[4][3] = {"","ˮ","",""}; +#else + BOOL TrueMagic=FALSE; +#endif + int f_num=0; + int MagicLv=4; + + memset(def_be_hit,-1,sizeof(def_be_hit)); + + if(defNo < 5) + f_num = 0; + else if(defNo >=5 && defNo < 10) + f_num = 5; + else if(defNo >=10 && defNo < 15) + f_num = 10; + else + f_num = 15; + + // ȡսϴ + for( i=f_num; i att_magic_lv[ FieldAttr] ) TrueMagic = FALSE; + else TrueMagic = TRUE; +#endif + } + pet_att_lv = CHAR_getInt(BATTLE_No2Index(battleindex,attackNo), CHAR_LV); + + z = 0; + for(i=0;i 0 ){ + float def = (float)(CHAR_getWorkInt( charaidx, CHAR_OTHERSTATUSNUMS )); + def = def/100; + for(j=0;j 0) { + CHAR_setWorkInt(def_be_hit[i],CHAR_WORKSLEEP,0); + z = BATTLE_Index2No(battleindex,def_be_hit[i]); + sprintf(szcommand,"BM|%X|%X|",z,0); + BATTLESTR_ADD(szcommand); + } + } +} +#endif + +#ifdef _PROFESSION_ADDSKILL +unsigned int GET_PROFESSION_magic_array(int idx) +{ + return PROFESSION_magic[idx].uiSpriteNum; +} +#endif diff --git a/battle/makefile b/battle/makefile new file mode 100644 index 0000000..8a0deda --- /dev/null +++ b/battle/makefile @@ -0,0 +1,456 @@ +export CC=gcc +export RM=rm -f +export AR=ar cr +export MV=mv +export RANLIB=ranlib +export SED=sed + + +export SHELL=/bin/sh + +INCFLAGS=-I.. -I../include + +CFLAGS=-O3 -w $(INCFLAGS) +#Pentium 4 (Intel) +#CFLAGS=-march=pentium4 -O3 -pipe -fomit-frame-pointer $(INCFLAGS) +#Athlon XP (AMD) +#CFLAGS="-march=athlon-xp -O3 -pipe -fomit-frame-pointer" $(INCFLAGS) +#Athlon64£º +#CFLAGS="-O2 -march=athlon64 -ftracer -fprefetch-loop-arrays -pipe" $(INCFLAGS) + +PROG=libbattle.a + +SRC=battle.c battle_event.c battle_command.c battle_ai.c battle_magic.c pet_skill.c battle_item.c profession_skill.c +OBJ=$(SRC:.c=.o) + +ifeq (0,$(MAKELEVEL)) +CC=gcc +RM=rm -f +AR=ar cr +MV=mv +RANLIB=ranlib +SED=sed +SHELL=/bin/sh +endif + +all: $(PROG) + +$(PROG): $(OBJ) + $(RM) $(PROG) + $(AR) $(PROG) $(OBJ) + $(RANLIB) $(PROG) + +depend: + $(MV) makefile makefile.bak + $(SED) -ne '1,/^# DO NOT DELETE THIS LINE/p' makefile.bak>makefile + $(CC) $(INCFLAGS) -M $(SRC) >> makefile + +clean: + $(RM) $(PROG) + $(RM) $(OBJ) + $(RM) *~ + +distclean: + $(RM) $(PROG) + $(RM) $(OBJ) + $(RM) *~ + $(MV) makefile makefile.bak + $(SED) -ne '1,/^# DO NOT DELETE THIS LINE/p' makefile.bak>makefile + $(RM) makefile.bak + +# DO NOT DELETE THIS LINE +battle.o: battle.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/buf.h \ + ../include/common.h ../include/object.h ../include/char.h \ + ../include/char_base.h ../include/version.h ../include/skill.h \ + ../include/util.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/char_base.h ../include/char_data.h ../include/battle.h \ + ../include/battle_event.h ../include/battle_command.h \ + ../include/battle_ai.h ../include/configfile.h \ + ../include/lssproto_serv.h ../include/lssproto_util.h \ + ../include/encount.h ../include/enemy.h ../include/handletime.h \ + ../include/readmap.h ../include/pet_skill.h ../include/npcutil.h \ + ../include/magic.h ../include/npc_npcenemy.h ../include/log.h \ + ../include/pet_skillinfo.h ../include/anim_tbl.h ../include/common.h \ + ../include/battle_magic.h ../include/item.h ../include/correct_bug.h \ + ../include/mylua/function.h ../include/mylua/mylua.h ../include/lua.h \ + ../include/lauxlib.h ../include/lualib.h ../include/npc_autopk.h \ + ../include/profession_skill.h ../include/skill.h +battle_event.o: battle_event.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h /usr/include/math.h \ + /usr/include/bits/huge_val.h /usr/include/bits/mathdef.h \ + /usr/include/bits/mathcalls.h ../include/char.h ../include/common.h \ + ../include/char_base.h ../include/version.h ../include/skill.h \ + ../include/util.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/char_event.h ../include/battle.h ../include/battle_event.h \ + ../include/configfile.h ../include/pet.h ../include/log.h \ + ../include/lssproto_serv.h ../include/lssproto_util.h \ + ../include/anim_tbl.h ../include/battle_magic.h ../include/util.h \ + ../include/enemy.h ../include/pet_skill.h ../include/char_base.h \ + ../include/item_event.h ../include/profession_skill.h ../include/item.h \ + ../include/skill.h ../include/magic_base.h ../include/mylua/function.h +battle_command.o: battle_command.c ../include/version.h \ + ../include/sasql.h /usr/include/stdio.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/bits/wordsize.h \ + /usr/include/gnu/stubs.h /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/char.h \ + ../include/common.h ../include/char_base.h ../include/version.h \ + ../include/skill.h ../include/util.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/char_base.h ../include/battle.h ../include/pet_skill.h \ + ../include/battle_event.h ../include/battle_command.h \ + ../include/lssproto_serv.h ../include/lssproto_util.h \ + ../include/magic.h ../include/magic_base.h ../include/handletime.h \ + ../include/profession_skill.h +battle_ai.o: battle_ai.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/common.h \ + ../include/char.h ../include/common.h ../include/char_base.h \ + ../include/version.h ../include/skill.h ../include/util.h \ + ../include/title.h ../include/addressbook.h ../include/net.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/char_base.h ../include/battle.h ../include/npcutil.h \ + ../include/pet_skill.h +battle_magic.o: battle_magic.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/char.h \ + ../include/common.h ../include/char_base.h ../include/version.h \ + ../include/skill.h ../include/util.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/char_base.h ../include/battle.h ../include/battle_event.h \ + ../include/magic_base.h ../include/battle_magic.h \ + ../include/item_event.h ../include/anim_tbl.h ../include/common.h \ + ../include/lssproto_serv.h ../include/lssproto_util.h \ + ../include/profession_skill.h ../include/skill.h +pet_skill.o: pet_skill.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/common.h \ + ../include/buf.h ../include/common.h ../include/configfile.h \ + ../include/char_base.h ../include/version.h ../include/skill.h \ + ../include/util.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/char_base.h ../include/char_data.h ../include/pet_skill.h \ + ../include/battle.h ../include/battle_event.h ../include/battle_magic.h \ + ../include/item.h ../include/item_gen.h ../include/char_talk.h +battle_item.o: battle_item.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/char.h \ + ../include/common.h ../include/char_base.h ../include/version.h \ + ../include/skill.h ../include/util.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/char_base.h ../include/battle.h ../include/battle_event.h \ + ../include/battle_item.h ../include/battle_magic.h \ + ../include/item_event.h ../include/log.h ../include/anim_tbl.h \ + ../include/npcutil.h ../include/magic_base.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h +profession_skill.o: profession_skill.c ../include/version.h \ + ../include/sasql.h /usr/include/stdio.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/bits/wordsize.h \ + /usr/include/gnu/stubs.h /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/buf.h \ + ../include/common.h ../include/profession_skill.h ../include/version.h \ + ../include/util.h ../include/skill.h ../include/char_base.h \ + ../include/title.h ../include/addressbook.h ../include/net.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/battle.h ../include/magic_base.h ../include/configfile.h \ + ../include/char.h ../include/char_base.h ../include/char_data.h \ + ../include/item.h ../include/char.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h ../include/skill.h diff --git a/battle/makefile.bak b/battle/makefile.bak new file mode 100644 index 0000000..8a0deda --- /dev/null +++ b/battle/makefile.bak @@ -0,0 +1,456 @@ +export CC=gcc +export RM=rm -f +export AR=ar cr +export MV=mv +export RANLIB=ranlib +export SED=sed + + +export SHELL=/bin/sh + +INCFLAGS=-I.. -I../include + +CFLAGS=-O3 -w $(INCFLAGS) +#Pentium 4 (Intel) +#CFLAGS=-march=pentium4 -O3 -pipe -fomit-frame-pointer $(INCFLAGS) +#Athlon XP (AMD) +#CFLAGS="-march=athlon-xp -O3 -pipe -fomit-frame-pointer" $(INCFLAGS) +#Athlon64£º +#CFLAGS="-O2 -march=athlon64 -ftracer -fprefetch-loop-arrays -pipe" $(INCFLAGS) + +PROG=libbattle.a + +SRC=battle.c battle_event.c battle_command.c battle_ai.c battle_magic.c pet_skill.c battle_item.c profession_skill.c +OBJ=$(SRC:.c=.o) + +ifeq (0,$(MAKELEVEL)) +CC=gcc +RM=rm -f +AR=ar cr +MV=mv +RANLIB=ranlib +SED=sed +SHELL=/bin/sh +endif + +all: $(PROG) + +$(PROG): $(OBJ) + $(RM) $(PROG) + $(AR) $(PROG) $(OBJ) + $(RANLIB) $(PROG) + +depend: + $(MV) makefile makefile.bak + $(SED) -ne '1,/^# DO NOT DELETE THIS LINE/p' makefile.bak>makefile + $(CC) $(INCFLAGS) -M $(SRC) >> makefile + +clean: + $(RM) $(PROG) + $(RM) $(OBJ) + $(RM) *~ + +distclean: + $(RM) $(PROG) + $(RM) $(OBJ) + $(RM) *~ + $(MV) makefile makefile.bak + $(SED) -ne '1,/^# DO NOT DELETE THIS LINE/p' makefile.bak>makefile + $(RM) makefile.bak + +# DO NOT DELETE THIS LINE +battle.o: battle.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/buf.h \ + ../include/common.h ../include/object.h ../include/char.h \ + ../include/char_base.h ../include/version.h ../include/skill.h \ + ../include/util.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/char_base.h ../include/char_data.h ../include/battle.h \ + ../include/battle_event.h ../include/battle_command.h \ + ../include/battle_ai.h ../include/configfile.h \ + ../include/lssproto_serv.h ../include/lssproto_util.h \ + ../include/encount.h ../include/enemy.h ../include/handletime.h \ + ../include/readmap.h ../include/pet_skill.h ../include/npcutil.h \ + ../include/magic.h ../include/npc_npcenemy.h ../include/log.h \ + ../include/pet_skillinfo.h ../include/anim_tbl.h ../include/common.h \ + ../include/battle_magic.h ../include/item.h ../include/correct_bug.h \ + ../include/mylua/function.h ../include/mylua/mylua.h ../include/lua.h \ + ../include/lauxlib.h ../include/lualib.h ../include/npc_autopk.h \ + ../include/profession_skill.h ../include/skill.h +battle_event.o: battle_event.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h /usr/include/math.h \ + /usr/include/bits/huge_val.h /usr/include/bits/mathdef.h \ + /usr/include/bits/mathcalls.h ../include/char.h ../include/common.h \ + ../include/char_base.h ../include/version.h ../include/skill.h \ + ../include/util.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/char_event.h ../include/battle.h ../include/battle_event.h \ + ../include/configfile.h ../include/pet.h ../include/log.h \ + ../include/lssproto_serv.h ../include/lssproto_util.h \ + ../include/anim_tbl.h ../include/battle_magic.h ../include/util.h \ + ../include/enemy.h ../include/pet_skill.h ../include/char_base.h \ + ../include/item_event.h ../include/profession_skill.h ../include/item.h \ + ../include/skill.h ../include/magic_base.h ../include/mylua/function.h +battle_command.o: battle_command.c ../include/version.h \ + ../include/sasql.h /usr/include/stdio.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/bits/wordsize.h \ + /usr/include/gnu/stubs.h /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/char.h \ + ../include/common.h ../include/char_base.h ../include/version.h \ + ../include/skill.h ../include/util.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/char_base.h ../include/battle.h ../include/pet_skill.h \ + ../include/battle_event.h ../include/battle_command.h \ + ../include/lssproto_serv.h ../include/lssproto_util.h \ + ../include/magic.h ../include/magic_base.h ../include/handletime.h \ + ../include/profession_skill.h +battle_ai.o: battle_ai.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/common.h \ + ../include/char.h ../include/common.h ../include/char_base.h \ + ../include/version.h ../include/skill.h ../include/util.h \ + ../include/title.h ../include/addressbook.h ../include/net.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/char_base.h ../include/battle.h ../include/npcutil.h \ + ../include/pet_skill.h +battle_magic.o: battle_magic.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/char.h \ + ../include/common.h ../include/char_base.h ../include/version.h \ + ../include/skill.h ../include/util.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/char_base.h ../include/battle.h ../include/battle_event.h \ + ../include/magic_base.h ../include/battle_magic.h \ + ../include/item_event.h ../include/anim_tbl.h ../include/common.h \ + ../include/lssproto_serv.h ../include/lssproto_util.h \ + ../include/profession_skill.h ../include/skill.h +pet_skill.o: pet_skill.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/common.h \ + ../include/buf.h ../include/common.h ../include/configfile.h \ + ../include/char_base.h ../include/version.h ../include/skill.h \ + ../include/util.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/char_base.h ../include/char_data.h ../include/pet_skill.h \ + ../include/battle.h ../include/battle_event.h ../include/battle_magic.h \ + ../include/item.h ../include/item_gen.h ../include/char_talk.h +battle_item.o: battle_item.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/char.h \ + ../include/common.h ../include/char_base.h ../include/version.h \ + ../include/skill.h ../include/util.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/char_base.h ../include/battle.h ../include/battle_event.h \ + ../include/battle_item.h ../include/battle_magic.h \ + ../include/item_event.h ../include/log.h ../include/anim_tbl.h \ + ../include/npcutil.h ../include/magic_base.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h +profession_skill.o: profession_skill.c ../include/version.h \ + ../include/sasql.h /usr/include/stdio.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/bits/wordsize.h \ + /usr/include/gnu/stubs.h /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/buf.h \ + ../include/common.h ../include/profession_skill.h ../include/version.h \ + ../include/util.h ../include/skill.h ../include/char_base.h \ + ../include/title.h ../include/addressbook.h ../include/net.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/battle.h ../include/magic_base.h ../include/configfile.h \ + ../include/char.h ../include/char_base.h ../include/char_data.h \ + ../include/item.h ../include/char.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h ../include/skill.h diff --git a/battle/pet_skill.c b/battle/pet_skill.c new file mode 100644 index 0000000..a532531 --- /dev/null +++ b/battle/pet_skill.c @@ -0,0 +1,2744 @@ +#include "version.h" +#include +#include +#include "common.h" +#include "buf.h" +#include "configfile.h" +#include "char_base.h" +#include "char_data.h" +#include "pet_skill.h" +#include "battle.h" +#include "battle_event.h" +#include "battle_magic.h" +#include "item.h" +#include "item_gen.h" +#include "char_talk.h" +#include "char_talk.h" + +/*======================================================================== + * ʸ 年лĩ ĸʽ + *========================================================================*/ + +static Petskill *PETSKILL_petskill; +static int PETSKILL_petskillnum; + +typedef struct tagPetskill_PetskillFunctionTable +{ + char *functionname; /* ɬð̻̤Ѽ */ + PETSKILL_CALLFUNC func; /* ˱̫ľ */ + int hash; /* hash */ + int status; /* Ѩëʸ϶ִ */ +}PETSKILL_PetskillFunctionTable; + +/* ë ֧ճ */ +static PETSKILL_PetskillFunctionTable PETSKILL_functbl[] = { + { "PETSKILL_None", PETSKILL_None, 0 }, + { "PETSKILL_NormalAttack", PETSKILL_NormalAttack, 0 }, + { "PETSKILL_NormalGuard", PETSKILL_NormalGuard, 0 }, + { "PETSKILL_ContinuationAttack",PETSKILL_ContinuationAttack, 0 }, + { "PETSKILL_ChargeAttack", PETSKILL_ChargeAttack, 0 }, + { "PETSKILL_Guardian", PETSKILL_Guardian, 0 }, + { "PETSKILL_PowerBalance", PETSKILL_PowerBalance, 0 }, + { "PETSKILL_Mighty", PETSKILL_Mighty, 0 }, + { "PETSKILL_StatusChange", PETSKILL_StatusChange, 0 }, + { "PETSKILL_EarthRound", PETSKILL_EarthRound, 0 }, + { "PETSKILL_GuardBreak", PETSKILL_GuardBreak, 0 }, +#ifdef _SKILL_GUARDBREAK2//Ƴ2 vincent add 2002/05/20 + { "PETSKILL_GuardBreak2", PETSKILL_GuardBreak2, 0 }, +#endif + { "PETSKILL_Abduct", PETSKILL_Abduct, 0 }, + { "PETSKILL_Steal", PETSKILL_Steal, 0 }, + { "PETSKILL_Merge", PETSKILL_Merge, 0 }, +#ifdef _ALCHEMIST + { "PETSKILL_Alchemist", PETSKILL_Merge, 0 }, +#endif + { "PETSKILL_NoGuard", PETSKILL_NoGuard, 0 }, +#ifdef _ITEM_INSLAY + { "PETSKILL_Inslay", PETSKILL_Inslay, 0 }, +#endif +#ifdef _PETSKILL_FIXITEM + { "PETSKILL_Fixitem", PETSKILL_Fixitem, 0 }, +#endif + +#ifdef _MAGIC_SUPERWALL + { "PETSKILL_MagicStatusChange" , PETSKILL_MagicStatusChange, 0}, +#endif + +// Terry add 2001/11/05 +#ifdef _ATTACK_MAGIC + { "PETSKILL_AttackMagic", PETSKILL_AttackMagic,0}, +#endif + +#ifdef _PSKILL_FALLGROUND + { "PETSKILL_FallGround", PETSKILL_FallGround, 0}, +#endif +#ifdef _PETSKILL_EXPLODE + { "PETSKILL_Explode", PETSKILL_Explode, 0}, +#endif +#ifdef _BATTLESTEAL_FIX + { "PETSKILL_StealMoney", PETSKILL_StealMoney, 0 }, +#endif +#ifdef _PRO_BATTLEENEMYSKILL + { "ENEMYSKILL_ReLife", ENEMYSKILL_ReLife, 0}, + { "ENEMYSKILL_ReHP", ENEMYSKILL_ReHP, 0}, + { "ENEMYSKILL_EnemyHelp", ENEMYSKILL_EnemyHelp, 0}, +#endif +#ifdef _SKILL_DAMAGETOHP + { "PETSKILL_DamageToHp", PETSKILL_DamageToHp, 0}, +#endif + +#ifdef _PETSKILL_TIMID + { "PETSKILL_BattleTimid", PETSKILL_BattleTimid, 0}, +#endif +#ifdef _PETSKILL_2TIMID + { "PETSKILL_2BattleTimid", PETSKILL_2BattleTimid, 0}, +#endif +#ifdef _PETSKILL_ANTINTER + { "PETSKILL_AntInter", PETSKILL_AntInter, 0}, +#endif + +#ifdef _PETSKILL_PROPERTY + { "PETSKILL_BattleProperty", PETSKILL_BattleProperty, 0}, +#endif + +#ifdef _PETSKILL_TEAR + { "PETSKILL_BattleTearDamage", PETSKILL_BattleTearDamage, 0}, +#endif + +#ifdef _BATTLE_LIGHTTAKE + { "PETSKILL_Lighttakeed", PETSKILL_Lighttakeed, 0}, +#endif + +#ifdef _BATTLE_ATTCRAZED + { "PETSKILL_AttackCrazed", PETSKILL_AttackCrazed, 0}, +#endif + +#ifdef _SHOOTCHESTNUT // Syu ADD 輼 + { "PETSKILL_AttackShoot", PETSKILL_AttackShoot, 0}, +#endif + +#ifdef _Skill_MPDAMAGE + { "PETSKILL_MpDamage", PETSKILL_MpDamage, 0}, +#endif + +#ifdef _SKILL_TOOTH + { "PETSKILL_ToothCrushe", PETSKILL_ToothCrushe, 0}, +#endif + +#ifdef _PETSKILL_SETDUCK + { "PETSKILL_SetDuck", PETSKILL_SetDuck, 0}, +#endif +#ifdef _MAGICPET_SKILL + { "PETSKILL_SetMagicPet", PETSKILL_SetMagicPet, 0}, +#endif +#ifdef _PSKILL_MODIFY + { "PETSKILL_Modifyattack", PETSKILL_Modifyattack, 0}, +#endif + +#ifdef _PSKILL_MDFYATTACK + { "PETSKILL_Mdfyattack", PETSKILL_Mdfyattack, 0}, +#endif +#ifdef _VARY_WOLF + { "PETSKILL_Vary", PETSKILL_Vary, 0}, +#endif +#ifdef _PET_BIANSHEN + { "PETSKILL_Set_Vary", PETSKILL_Set_Vary, 0}, +#endif +#ifdef _SKILL_WILDVIOLENT_ATT + { "PETSKILL_WildViolentAttack", PETSKILL_WildViolentAttack, 0},//vincent add 2002/05/16 +#endif + +#ifdef _SKILL_SPEEDY_ATT + { "PETSKILL_SpeedyAttack", PETSKILL_SpeedyAttack, 0},//vincent add 2002/05/20 +#endif +#ifdef _SKILL_SACRIFICE + { "PETSKILL_Sacrifice", PETSKILL_Sacrifice, 0},//vincent add 2002/05/30 +#endif +#ifdef _SKILL_REFRESH + { "PETSKILL_Refresh", PETSKILL_Refresh, 0},//vincent add 2002/08/08 +#endif +#ifdef _SKILL_WEAKEN //vincent輼: + { "PETSKILL_Weaken", PETSKILL_Weaken, 0},//vincent add 2002/07/11 +#endif +#ifdef _SKILL_DEEPPOISON //vincent輼:綾 + { "PETSKILL_Deeppoison", PETSKILL_Deeppoison, 0},//vincent add 2002/07/16 +#endif +#ifdef _SKILL_BARRIER //vincent輼:ħ + { "PETSKILL_Barrier", PETSKILL_Barrier, 0},//vincent add 2002/07/16 +#endif +#ifdef _SKILL_NOCAST //vincent輼:Ĭ + { "PETSKILL_Nocast", PETSKILL_Nocast, 0},//vincent add 2002/07/16 +#endif +#ifdef _SKILL_ROAR //vincent輼: + { "PETSKILL_Roar", PETSKILL_Roar, 0},//vincent add 2002/07/11 +#endif + +#ifdef _PET_SKILL_SARS // WON ADD ɷ + { "PETSKILL_Sars", PETSKILL_Sars, 0}, +#endif + +#ifdef _SONIC_ATTACK // WON ADD + { "PETSKILL_Sonic", PETSKILL_Sonic, 0}, +#endif +#ifdef _PETSKILL_REGRET + { "PETSKILL_Regret", PETSKILL_Regret, 0}, +#endif + +#ifdef _PETSKILL_GYRATE + { "PETSKILL_Gyrate", PETSKILL_Gyrate, 0}, +#endif + +#ifdef _PETSKILL_ACUPUNCTURE //Ƥ + { "PETSKILL_Acupuncture", PETSKILL_Acupuncture, 0}, +#endif + +#ifdef _PETSKILL_RETRACE + { "PETSKILL_Retrace", PETSKILL_Retrace, 0}, +#endif + +#ifdef _PETSKILL_HECTOR + { "PETSKILL_Hector", PETSKILL_Hector, 0}, +#endif + +#ifdef _PETSKILL_FIREKILL + { "PETSKILL_Firekill", PETSKILL_Firekill, 0}, +#endif + +#ifdef _PETSKILL_DAMAGETOHP + { "PETSKILL_DamageToHp2", PETSKILL_DamageToHp2, 0}, +#endif + +#ifdef _PETSKILL_BECOMEFOX + { "PETSKILL_BecomeFox", PETSKILL_BecomeFox, 0}, +#endif + +#ifdef _PETSKILL_BECOMEPIG + { "PETSKILL_BecomePig", PETSKILL_BecomePig, 0}, +#endif + +#ifdef _PETSKILL_SHOWMERCY + { "PETSKILL_ShowMercy", PETSKILL_ShowMercy, 0}, +#endif + +#ifdef _PETSKILL_COMBINED + { "PETSKILL_Combined", PETSKILL_Combined, 0}, +#endif +#ifdef _PETSKILL_LER + { "PETSKILL_BatFly", PETSKILL_BatFly, 0}, + { "PETSKILL_DivideAttack", PETSKILL_DivideAttack, 0}, +#endif +#ifdef _PETSKILL_BATTLE_MODEL + { "PETSKILL_BattleModel", PETSKILL_BattleModel, 0}, +#endif + { "PETSKILL_ZiYun1", PETSKILL_ZiYun1, 0}, + +}; + +/*----------------------------------------------------------------------*/ + + +/* ͣʧͱ */ +/*----------------------------------------------------------------------*/ +INLINE BOOL PETSKILL_CHECKINDEX( int index ) +{ + if( PETSKILL_petskillnum<=index || index<0 )return FALSE; + return TRUE; +} +/*----------------------------------------------------------------------*/ +static INLINE BOOL PETSKILL_CHECKINTDATAINDEX( int index) +{ + if( PETSKILL_DATAINTNUM <= index || index < 0 ) return FALSE; + return TRUE; +} +/*----------------------------------------------------------------------*/ +static INLINE BOOL PETSKILL_CHECKCHARDATAINDEX( int index) +{ + if( PETSKILL_DATACHARNUM <= index || index < 0 ) return FALSE; + return TRUE; +} +/*----------------------------------------------------------------------*/ +INLINE int PETSKILL_getInt( int index, PETSKILL_DATAINT element) +{ + return PETSKILL_petskill[index].data[element]; +} +/*----------------------------------------------------------------------*/ +INLINE int PETSKILL_setInt( int index, PETSKILL_DATAINT element, int data) +{ + int buf; + buf = PETSKILL_petskill[index].data[element]; + PETSKILL_petskill[index].data[element]=data; + return buf; +} +/*----------------------------------------------------------------------*/ +INLINE char* PETSKILL_getChar( int index, PETSKILL_DATACHAR element) +{ + if( !PETSKILL_CHECKINDEX( index)) return "\0"; + if( !PETSKILL_CHECKCHARDATAINDEX( element)) return "\0"; + return PETSKILL_petskill[index].string[element].string; +} + +/*----------------------------------------------------------------------*/ +INLINE BOOL PETSKILL_setChar( int index ,PETSKILL_DATACHAR element, char* new ) +{ + if(!PETSKILL_CHECKINDEX(index))return FALSE; + if(!PETSKILL_CHECKCHARDATAINDEX(element))return FALSE; + strcpysafe( PETSKILL_petskill[index].string[element].string, + sizeof(PETSKILL_petskill[index].string[element].string), + new ); + return TRUE; +} +/*---------------------------------------------------------------------- + * ʸ ë£ + *---------------------------------------------------------------------*/ +int PETSKILL_getPetskillNum( void) +{ + return PETSKILL_petskillnum; +} + +#ifdef _CFREE_petskill +#define PETSKILL_STARTINTNUM 7 //PETSKILL_DATACHARNUM+1 +#else +#define PETSKILL_STARTINTNUM 5 +#endif + +/*---------------------------------------------------------------------- + * ʸ ɬð̻ë //ʼ輼 + *---------------------------------------------------------------------*/ +BOOL PETSKILL_initPetskill( char *filename) +{ + FILE* f; + char line[256]; + int linenum=0; + int petskill_readlen=0; + int i,j; + int max_skillid =0; + + f = fopen(filename,"r"); + if( f == NULL ){ + print( "file open error\n"); + return FALSE; + } + + PETSKILL_petskillnum=0; + + /* ئ滥ϵؤ¾Ʃ *///輼 + while( fgets( line, sizeof( line ), f ) ){ + char token[256]; + linenum ++; + if( line[0] == '#' )continue; /* comment */ + if( line[0] == '\n' )continue; /* none */ + chomp( line ); + PETSKILL_petskillnum++; +#ifdef _PETSKILL_OPTIMUM // Robin ȡ輼ID + if( getStringFromIndexWithDelim( line, ",", PETSKILL_STARTINTNUM, token, sizeof(token)) == FALSE ) + continue; + //print("\n 輼ID:%d %s ", atoi( token), line); + max_skillid = max( atoi( token), max_skillid); +#endif + } + + if( fseek( f, 0, SEEK_SET ) == -1 ){ + fprint( "Ѱʧ\n" ); + fclose(f); + return FALSE; + } + +#ifdef _PETSKILL_OPTIMUM // 輼TableΪ ID +1 + PETSKILL_petskillnum = max_skillid +1; +// print("\n 輼ID = %d\n", max_skillid); +#endif + + PETSKILL_petskill = allocateMemory( sizeof(struct tagPetskill) + * PETSKILL_petskillnum ); + if( PETSKILL_petskill == NULL ){ + fprint( "޷ڴ %d\n" , + sizeof(struct tagPetskill)*PETSKILL_petskillnum); + fclose( f ); + return FALSE; + } + + /* */ + for( i = 0; i < PETSKILL_petskillnum; i ++ ) { + for( j = 0; j < PETSKILL_DATAINTNUM; j ++ ) { + PETSKILL_setInt( i,j,-1); + } + for( j = 0; j < PETSKILL_DATACHARNUM; j ++ ) { + PETSKILL_setChar( i,j,""); + } + } + + /* */ + linenum = 0; + while( fgets( line, sizeof( line ), f ) ){ + linenum ++; + if( line[0] == '#' )continue; /* comment */ + if( line[0] == '\n' )continue; /* none */ + + chomp( line ); + + /* ë */ + /* tab ë " " 徧 */ + replaceString( line, '\t' , ' ' ); + /* ʸë£*/ +{ + char buf[256]; + for( i = 0; i < strlen( line); i ++) { + if( line[i] != ' ' ) { + break; + } + strcpysafe( buf,sizeof(buf), &line[i]); + } + if( i != 0 ) { + strcpysafe( line,sizeof(line), buf); + } +} +{ + char token[256]; + int ret; + +#ifdef _PETSKILL_OPTIMUM // ȡг輼ID, ֱԳ輼IDTable index + ret = getStringFromIndexWithDelim( line, ",", PETSKILL_STARTINTNUM, token, sizeof(token)); + if( ret==FALSE ){ + fprint("ļ﷨:%s %d\n",filename,linenum); + break; + } + petskill_readlen = atoi( token); +#endif + + for( i = 0; i < PETSKILL_DATACHARNUM; i ++ ) { + /* ٯ ͼëέ */ + ret = getStringFromIndexWithDelim( line,",", i + 1, token,sizeof(token)); + if( ret==FALSE ){ + fprint("ļ﷨:%s %d\n",filename,linenum); + break; + } + PETSKILL_setChar( petskill_readlen, i, token); + } + + /* 4 ϷѰ */ + for( i = PETSKILL_STARTINTNUM; i < PETSKILL_DATAINTNUM+PETSKILL_STARTINTNUM; i ++ ) { + ret = getStringFromIndexWithDelim( line,",",i,token, + sizeof(token)); + if( ret==FALSE ){ + fprint("ļ﷨:%s %d\n",filename,linenum); + break; + } + if( strlen( token) != 0 ) { + PETSKILL_setInt( petskill_readlen, i - PETSKILL_STARTINTNUM, atoi( token)); + } + } + if( i < PETSKILL_DATAINTNUM+PETSKILL_STARTINTNUM ) continue; + +#ifdef _CFREE_petskill + if(line[0]=='E') PETSKILL_setInt( petskill_readlen, PETSKILL_ILLEGAL, 1); +#else + // Robin 2001/02/26 +1 set_illegal_Skill + if(line[0]=='T') PETSKILL_setInt( petskill_readlen, PETSKILL_ILLEGAL, 1); +#endif + //print("Id:%d illegal:%d\n",PETSKILL_getInt(petskill_readlen,PETSKILL_ID),PETSKILL_getInt(petskill_readlen,PETSKILL_ILLEGAL)); + + petskill_readlen ++; +} + + } + fclose(f); + + PETSKILL_petskillnum = petskill_readlen; + + + print( "Ч\ %d...", PETSKILL_petskillnum ); + + /* hash */ + for( i = 0; i < arraysizeof( PETSKILL_functbl); i ++ ) { + PETSKILL_functbl[i].hash = hashpjw( PETSKILL_functbl[i].functionname); + } +/* +#ifdef _CFREE_petskill + for( i=0; i = 0 && petskillid < PETSKILL_petskillnum ) + return PETSKILL_petskill[petskillid].data[PETSKILL_ID]; +#else + int i; + for( i = 0; i < PETSKILL_petskillnum; i ++ ) { + if( PETSKILL_petskill[i].data[PETSKILL_ID] == petskillid ) { + return i; + } + } +#endif + return -1; +} +/*------------------------------------------------------------ + * ʸ պ̼ë߯ + * ¦ + * name char*  + * ߯Ի + * ѳ߼̼ئ巴NULL + ------------------------------------------------------------*/ +PETSKILL_CALLFUNC PETSKILL_getPetskillFuncPointer(char* name ) +{ + int i; + int hash = hashpjw( name ); + for( i = 0 ; i< arraysizeof( PETSKILL_functbl) ; i++ ) { + if( PETSKILL_functbl[i].hash == hash ) { + if( strcmp( PETSKILL_functbl[i].functionname, name ) == 0 ) { + return PETSKILL_functbl[i].func; + } + } + } + return NULL; +} + +int PETSKILL_Use( + int charaindex, + int havepetskill, + int toindex, + char *data + //BOOL isCLI // Robin 2001/02/26 if owner is player +) +{ + int array, petskillid; + int ret; + PETSKILL_CALLFUNC func; + int playcharaindex; + playcharaindex = CHAR_getCharPet(CHAR_getWorkInt(charaindex,CHAR_WORKPLAYERINDEX),CHAR_getInt(CHAR_getWorkInt(charaindex,CHAR_WORKPLAYERINDEX),CHAR_RIDEPET)); + petskillid = CHAR_getPetSkill( charaindex, havepetskill); + if(playcharaindex==charaindex){ + if(petskillid!=0 && petskillid!=1 && petskillid!=2) + petskillid=0; + } +#ifdef _FIXWOLF // Syu ADD ˱Bug + if( petskillid == 600 ){ + if ( CHAR_getInt ( charaindex , CHAR_BASEIMAGENUMBER) == 101428 ) + petskillid = -1; + } +#endif + + array = PETSKILL_getPetskillArray( petskillid); + if( array == -1 ) return FALSE; +#ifndef _OPEN_E_PETSKILL + if(PETSKILL_getInt(array, PETSKILL_ILLEGAL)){ + if( (CHAR_getInt(charaindex, CHAR_WHICHTYPE)==CHAR_TYPEPET) ){ + //print(" CHAR_TYPEPET:%d ", charaindex); + return FALSE; + } + } +#endif +#ifdef _PETSKILL_CHECKTYPE +#define _SKILLTYPE_NONE 0x01 +#define _SKILLTYPE_BATTLE 0x02 + if( (CHAR_getInt(charaindex, CHAR_WHICHTYPE)==CHAR_TYPEPET) && + (PETSKILL_getInt( array, PETSKILL_USETYPE) & _SKILLTYPE_BATTLE) > 0){ + int masterindex = CHAR_getWorkInt( charaindex, CHAR_WORKPLAYERINDEX); + if( !CHAR_CHECKINDEX( masterindex) ) return FALSE; + if( CHAR_getWorkInt( masterindex, CHAR_WORKBATTLEMODE) == BATTLE_CHARMODE_NONE ){ + return FALSE; + } + } +#endif + func = PETSKILL_getPetskillFuncPointer( PETSKILL_getChar( array, PETSKILL_FUNCNAME) ); + if( func ) { + ret = func( charaindex, toindex, array, data ); + }else { + ret = FALSE; + } + return ret; +} + + +int _PETSKILL_GetArray( char *file, int line, int charaindex, int havepetskill ) +{ + int petskillid,array; + + petskillid = CHAR_getPetSkill( charaindex, havepetskill); + if( petskillid == -1 ) { + return -1; + } + + array = PETSKILL_getPetskillArray( petskillid); + + return array; +} + + +//---------------------------------------------------------------------- +int PETSKILL_ContinuationAttack( + int charaindex, + int toindex, + int array, + char *data + +) +{ +#ifdef _FIX_ContinuationAttack + if(toindex<0 || toindex>=BATTLE_ENTRY_MAX*2){ + print("err:NιĻĿ쳣 %d ", toindex); + return FALSE; + } +#endif +#ifdef _PETSKILL_NONO_FIX + if(CHAR_getWorkInt(charaindex,CHAR_WORKFIXAI)>=40 && CHAR_getWorkInt(charaindex,CHAR_WORKBATTLEMODE)!=BATTLE_CHARMODE_NONE && CHAR_getInt(charaindex, CHAR_WHICHTYPE)==CHAR_TYPEPET){ + CHAR_setWorkInt(charaindex,CHAR_WORKATTACKPOWER,CHAR_getWorkInt(charaindex,CHAR_WORKFIXSTR)); + CHAR_setWorkInt(charaindex,CHAR_WORKDEFENCEPOWER,CHAR_getWorkInt(charaindex,CHAR_WORKFIXTOUGH)); + CHAR_setWorkInt(charaindex,CHAR_WORKQUICK,CHAR_getWorkInt(charaindex,CHAR_WORKFIXDEX)); + } +#endif + char *pszOption; + int N = 1; + + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_S_RENZOKU ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, toindex ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + + pszOption = PETSKILL_getChar( array, PETSKILL_OPTION ); + if( sscanf( pszOption, "%d", &N ) == 1 ){ + if( N < 1 || N > 10 )N = 1; + }else{ + N = 1; + } + + CHAR_SETWORKINT_LOW( charaindex, CHAR_WORKBATTLECOM3, N ); + + return TRUE; +} + +int PETSKILL_ChargeAttack( + int charaindex, + int toindex, + int array, + char *data +) +{ + char *pszOption, *pszP; + int N = 1, Per = 0; + + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_S_CHARGE ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, toindex ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + pszOption = PETSKILL_getChar( array, PETSKILL_OPTION ); + if( sscanf( pszOption, "%d", &N ) == 1 ){ + if( N < 1 || N > 10 )N = 1; + }else{ + N = 1; + } + if( (pszP = strstr( pszOption, "%" ) ) != NULL ){ + sscanf( pszP+3, "%d", &Per ); + } + CHAR_SETWORKINT_LOW( charaindex, CHAR_WORKBATTLECOM3, N ); + CHAR_SETWORKINT_HIGH( charaindex, CHAR_WORKBATTLECOM3, Per ); + return TRUE; +} + +int PETSKILL_Guardian( + int charaindex, + int toNo, + int array, + char *data +) +{ + char *pszOption, *pszP; + int + battleindex, side, pos, ownerpos, + strdef, flg; + float fPer = 0.01; + + pszOption = PETSKILL_getChar( array, PETSKILL_OPTION ); + + if( (pszP = strstr( pszOption, "%" ) ) != NULL ){ + sscanf( pszP+3, "%f", &fPer ); + fPer=(fPer/100); + strdef=CHAR_getWorkInt(charaindex,CHAR_WORKFIXSTR); + strdef=(int)(strdef * fPer); + CHAR_setWorkInt(charaindex,CHAR_WORKATTACKPOWER,(CHAR_getWorkInt(charaindex,CHAR_WORKFIXSTR)+strdef)); + } + + if( (pszP = strstr( pszOption, "%" ) ) != NULL ){ + sscanf( pszP+3, "%f", &fPer ); + fPer=(fPer/100); + strdef=CHAR_getWorkInt(charaindex,CHAR_WORKFIXTOUGH); + strdef=(int)(strdef * fPer); + CHAR_setWorkInt(charaindex,CHAR_WORKDEFENCEPOWER,(CHAR_getWorkInt(charaindex,CHAR_WORKFIXTOUGH)+strdef)); + } + + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_S_GUARDIAN_ATTACK ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, toNo ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + + flg = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEFLG ); + flg |= CHAR_BATTLEFLG_GUARDIAN; + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEFLG, flg ); + + battleindex = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEINDEX ); + + pos = BATTLE_Index2No( battleindex, charaindex ); + + if( (pszP = strstr( pszOption, "COM:" ) ) != NULL + && strstr( pszP+4, "" ) != NULL + ){ + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_GUARD ); + + side = ( toNo >= SIDE_OFFSET )?( 1 ):( 0 ); + ownerpos = toNo - side * SIDE_OFFSET; + + if( 0 <= ownerpos && ownerpos < SIDE_OFFSET ){ + BattleArray[battleindex].Side[side].Entry[ownerpos].guardian = pos; + } + + }else{ + side = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLESIDE ); + ownerpos = pos - 5; + ownerpos -= side * SIDE_OFFSET; + + if( ownerpos < 0 || ownerpos > 19 ){ + }else{ + BattleArray[battleindex].Side[side].Entry[ownerpos].guardian = pos; + } + } + + return TRUE; +} + +int PETSKILL_Mighty( + int charaindex, + int toindex, + int array, + char *data +) +{ +#ifdef _PETSKILL_NONO_FIX + if(CHAR_getWorkInt(charaindex,CHAR_WORKFIXAI)>=40 && CHAR_getWorkInt(charaindex,CHAR_WORKBATTLEMODE)!=BATTLE_CHARMODE_NONE && CHAR_getInt(charaindex, CHAR_WHICHTYPE)==CHAR_TYPEPET){ + CHAR_setWorkInt(charaindex,CHAR_WORKATTACKPOWER,CHAR_getWorkInt(charaindex,CHAR_WORKFIXSTR)); + CHAR_setWorkInt(charaindex,CHAR_WORKDEFENCEPOWER,CHAR_getWorkInt(charaindex,CHAR_WORKFIXTOUGH)); + CHAR_setWorkInt(charaindex,CHAR_WORKQUICK,CHAR_getWorkInt(charaindex,CHAR_WORKFIXDEX)); + } +#endif + char *pszOption, *pszP; + int iBai = 0, iDuck = 0; + float fBai = 2.00; + float fPer = 0.01; + int strdef,i; + char szTurn[] = "turn"; + char *hetStatus[]={"ȫ", "", "", "", "ʯ", "", "", "", "", "", "Ĭ"}; + pszOption = PETSKILL_getChar( array, PETSKILL_OPTION ); + for(i=0;i<11;i++){ + if((pszP = strstr( pszOption, hetStatus[i] ) ) != NULL) break; + } + if(i == 11) i=0; + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM5, i); + if((pszP = strstr( pszOption, szTurn ) ) != NULL){ + pszP += sizeof( szTurn ); + sscanf( pszP, "%d", &i ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM6, i); + }else{ + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM6, 1); + } + + if((pszP = strstr( pszOption, "" ) ) != NULL){ + sscanf( pszP+3, "%d", &i ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM7, i); + }else{ + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM7, 60); + } + + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_S_MIGHTY ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, toindex ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + + if( (pszP = strstr( pszOption, "" ) ) != NULL ){ + sscanf( pszP+2, "%f", &fBai ); + iBai = (int)(fBai * 100); + } + CHAR_SETWORKINT_LOW( charaindex, CHAR_WORKBATTLECOM3, iBai ); + pszOption = PETSKILL_getChar( array, PETSKILL_OPTION ); + if( ( pszP = strstr( pszOption, "" ) ) != NULL){ + sscanf( pszP+2, "%d", &iDuck ); + } + if( (pszP = strstr( pszOption, "%" ) ) != NULL ){ + sscanf( pszP+3, "%f", &fPer ); + fPer=(fPer/100); + strdef=CHAR_getWorkInt(charaindex,CHAR_WORKFIXSTR); + strdef=(int)(strdef * fPer); + CHAR_setWorkInt(charaindex,CHAR_WORKATTACKPOWER,(CHAR_getWorkInt(charaindex,CHAR_WORKFIXSTR)+strdef)); + } + + if( (pszP = strstr( pszOption, "%" ) ) != NULL ){ + sscanf( pszP+3, "%f", &fPer ); + fPer=(fPer/100); + strdef=CHAR_getWorkInt(charaindex,CHAR_WORKFIXTOUGH); + strdef=(int)(strdef * fPer); + CHAR_setWorkInt(charaindex,CHAR_WORKDEFENCEPOWER,(CHAR_getWorkInt(charaindex,CHAR_WORKFIXTOUGH)+strdef)); + } + + if( (pszP = strstr( pszOption, "%" ) ) != NULL ){ + sscanf( pszP+3, "%f", &fPer ); + fPer=(fPer/100); + strdef=CHAR_getWorkInt(charaindex,CHAR_WORKFIXDEX); + strdef=(int)(strdef * fPer); + CHAR_setWorkInt(charaindex,CHAR_WORKQUICK,(CHAR_getWorkInt(charaindex,CHAR_WORKFIXDEX)+strdef)); + } + CHAR_SETWORKINT_HIGH( charaindex, CHAR_WORKBATTLECOM3, iDuck ); + return TRUE; +} + + + +int PETSKILL_PowerBalance( + int charaindex, + int toindex, + int array, + char *data +) +{ + char *pszOption="\0", *pszP; + float fPer = 0.01; + int strdef; + + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_S_POWERBALANCE); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, toindex ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + + pszOption = PETSKILL_getChar( array, PETSKILL_OPTION ); + + if( pszOption == "\0" ) { + print("\n pszOption == NULL "); + return FALSE; + } + if( (pszP = strstr( pszOption, "%" ) ) != NULL ){ + sscanf( pszP+3, "%f", &fPer ); + fPer=(fPer/100); + strdef=CHAR_getWorkInt(charaindex,CHAR_WORKFIXSTR); + strdef=(int)(strdef * fPer); + CHAR_setWorkInt(charaindex,CHAR_WORKATTACKPOWER,(CHAR_getWorkInt(charaindex,CHAR_WORKFIXSTR)+strdef)); + } + + if( (pszP = strstr( pszOption, "%" ) ) != NULL ){ + sscanf( pszP+3, "%f", &fPer ); + fPer=(fPer/100); + strdef=CHAR_getWorkInt(charaindex,CHAR_WORKFIXTOUGH); + strdef=(int)(strdef * fPer); + CHAR_setWorkInt(charaindex,CHAR_WORKDEFENCEPOWER,(CHAR_getWorkInt(charaindex,CHAR_WORKFIXTOUGH)+strdef)); + } + + if( (pszP = strstr( pszOption, "%" ) ) != NULL ){ + sscanf( pszP+3, "%f", &fPer ); + fPer=(fPer/100); + strdef=CHAR_getWorkInt(charaindex,CHAR_WORKFIXDEX); + strdef=(int)(strdef * fPer); + CHAR_setWorkInt(charaindex,CHAR_WORKQUICK,(CHAR_getWorkInt(charaindex,CHAR_WORKFIXDEX)+strdef)); + } + + return TRUE; +} + +//---------------------------------------------------------------------- +int PETSKILL_StatusChange( + int charaindex, + int toindex, + int array, + char *data + +) +{ + char *pszOption, *pszP; + float fPer = 0.01; + int strdef; + int status = -1, i = 0, turn = 3; + char szTurn[] = "turn"; + + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_S_STATUSCHANGE ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, toindex ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + + pszOption = PETSKILL_getChar( array, PETSKILL_OPTION ); + pszP = pszOption; + + for( ;status == -1 && pszP[0] != 0; pszP++ ){ + for( i = 1; i < BATTLE_ST_END; i ++ ){ + if( strncmp( pszP, aszStatus[i], 2 ) == 0 ){ + status = i; + pszP +=2; + break; + } + } + } + + if( ( pszP = strstr( pszP, szTurn ) ) != NULL){ + pszP += sizeof( szTurn ); + sscanf( pszP, "%d", &turn ); + } + + CHAR_SETWORKINT_LOW( charaindex, CHAR_WORKBATTLECOM3, i ); + CHAR_SETWORKINT_HIGH( charaindex, CHAR_WORKBATTLECOM3, turn ); + + if( (pszP = strstr( pszOption, "%" ) ) != NULL ){ + sscanf( pszP+3, "%f", &fPer ); + fPer=(fPer/100); + strdef=CHAR_getWorkInt(charaindex,CHAR_WORKFIXSTR); + strdef=(int)(strdef * fPer); + CHAR_setWorkInt(charaindex,CHAR_WORKATTACKPOWER, + (CHAR_getWorkInt(charaindex,CHAR_WORKFIXSTR)+strdef) ); + } + + if( (pszP = strstr( pszOption, "%" ) ) != NULL ){ + sscanf( pszP+3, "%f", &fPer ); + fPer=(fPer/100); + + strdef=CHAR_getWorkInt(charaindex,CHAR_WORKFIXTOUGH); + strdef=(int)(strdef * fPer); + CHAR_setWorkInt(charaindex,CHAR_WORKDEFENCEPOWER, + (CHAR_getWorkInt(charaindex,CHAR_WORKFIXTOUGH)+strdef)); + } + + + return TRUE; + +} + +#ifdef _VARY_WOLF + +int PETSKILL_Vary( int cindex, int tindex, int id, char* data) +{ + char *pszOption="\0", *pszP; + float fPer = 0.01; + int a_dep; + int d_dep; + int i; + int petid[4] = {981,982,983,984}; + + for( i=0; i<4; i++) { + if( CHAR_getInt( cindex, CHAR_PETID) == petid[i] ) break; + } + if( i>= 4 ) return FALSE; + + CHAR_setWorkInt( cindex, CHAR_WORKBATTLECOM1, BATTLE_COM_S_VARY); + CHAR_setWorkInt( cindex, CHAR_WORKBATTLECOM2, tindex ); + CHAR_setWorkInt( cindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + + pszOption = PETSKILL_getChar( id, PETSKILL_OPTION ); + + + if(pszOption=="\0"){ + //print("\n pszOption==NULL"); + return FALSE; + } + if( (pszP = strstr( pszOption, "%" ) ) != NULL ){ + sscanf( pszP+3, "%f", &fPer ); + CHAR_setWorkInt( cindex, CHAR_SKILLSTRPOWER, fPer); + fPer = fPer / 100; + a_dep = CHAR_getWorkInt( cindex, CHAR_WORKFIXSTR); + a_dep = (int)(a_dep * fPer); + CHAR_setWorkInt( cindex, CHAR_WORKATTACKPOWER, CHAR_getWorkInt( cindex, CHAR_WORKFIXSTR) + a_dep); + + } + if( (pszP = strstr( pszOption, "%" ) ) != NULL ){ + sscanf( pszP+3, "%f", &fPer ); + CHAR_setWorkInt( cindex, CHAR_SKILLDEXPOWER, fPer); + fPer = fPer / 100; + d_dep = CHAR_getWorkInt( cindex, CHAR_WORKFIXDEX); + d_dep = (int)(d_dep * fPer); + CHAR_setWorkInt( cindex, CHAR_WORKQUICK, CHAR_getWorkInt( cindex, CHAR_WORKFIXDEX) + d_dep); + + } + CHAR_setInt( cindex, CHAR_BASEIMAGENUMBER, 101428); + CHAR_setWorkInt( cindex, CHAR_WORKTURN, 0); + + return TRUE; +} +#endif + + +#ifdef _SKILL_WILDVIOLENT_ATT + +int PETSKILL_WildViolentAttack( + int charaindex, + int toindex, + int array, + char *data + +) +{ + char *pszOption="\0", *pszP; + float fPer = 0.01; + int strdef=0; + int iDuck = 0; + + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_S_WILDVIOLENTATTACK); + + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, toindex ); + + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + + pszOption = PETSKILL_getChar( array, PETSKILL_OPTION ); + + if( pszOption == "\0" ) { + //print("\n pszOption == NULL "); + return FALSE; + } + //ȡֵ + if( (pszP = strstr( pszOption, "%" ) ) != NULL ){ + sscanf( pszP+3, "%f", &fPer ); + fPer=(fPer/100); + + //趨ֵ + strdef=CHAR_getWorkInt(charaindex,CHAR_WORKFIXSTR); + strdef=(int)(strdef * fPer); + CHAR_setWorkInt(charaindex,CHAR_WORKATTACKPOWER,(CHAR_getWorkInt(charaindex,CHAR_WORKFIXSTR)+strdef)); + } + //ȡֵ + if( (pszP = strstr( pszOption, "%" ) ) != NULL ){ + sscanf( pszP+3, "%f", &fPer ); + fPer=(fPer/100); + + //趨ֵ + strdef=CHAR_getWorkInt(charaindex,CHAR_WORKFIXTOUGH); + strdef=(int)(strdef * fPer); + CHAR_setWorkInt(charaindex,CHAR_WORKDEFENCEPOWER,(CHAR_getWorkInt(charaindex,CHAR_WORKFIXTOUGH)+strdef)); + } + //ȡֵ + if( ( pszP = strstr( pszOption, "" ) ) != NULL){ + sscanf( pszP+2, "%d", &iDuck ); + } + // Ĥë + CHAR_SETWORKINT_HIGH( charaindex, CHAR_WORKBATTLECOM3, iDuck ); + + return TRUE; +} +#endif + +#ifdef _SKILL_SACRIFICE +int PETSKILL_Sacrifice( + int charaindex, + int toindex, + int array, + char *data + +) +{ + char buf[256]; + + if(CHAR_getInt(charaindex,CHAR_HP) > CHAR_getWorkInt(charaindex,CHAR_WORKMAXHP)*0.2 ) + { + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_S_SACRIFICE); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, toindex ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + } + else + { + + sprintf(buf, "%s; Ԯʧ!!", CHAR_getChar( charaindex, CHAR_NAME )); + CHAR_talkToCli( CHAR_getWorkInt(charaindex, CHAR_WORKPLAYERINDEX), -1, buf, CHAR_COLORYELLOW); + return FALSE; + } + return TRUE; +} +#endif +#ifdef _SKILL_REFRESH +int PETSKILL_Refresh( + int charaindex, + int toindex, + int array, + char *data + +) +{ + + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_S_REFRESH); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, toindex ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + CHAR_SETWORKINT_LOW( charaindex, CHAR_WORKBATTLECOM3, array); + return TRUE; +} +#endif +#ifdef _SKILL_WEAKEN //vincent輼: +int PETSKILL_Weaken( + int charaindex, + int toindex, + int array, + char *data + +) +{ + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_S_WEAKEN); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, toindex ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + CHAR_SETWORKINT_LOW( charaindex, CHAR_WORKBATTLECOM3, array); + return TRUE; +} +#endif +#ifdef _SKILL_DEEPPOISON //vincent輼:綾 +int PETSKILL_Deeppoison( + int charaindex, + int toindex, + int array, + char *data + +) +{ + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_S_DEEPPOISON); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, toindex ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + CHAR_SETWORKINT_LOW( charaindex, CHAR_WORKBATTLECOM3, array); + return TRUE; +} +#endif + +#ifdef _SKILL_BARRIER //vincent輼:ħ +int PETSKILL_Barrier( + int charaindex, + int toindex, + int array, + char *data + +) +{ + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_S_BARRIER); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, toindex ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + CHAR_SETWORKINT_LOW( charaindex, CHAR_WORKBATTLECOM3, array); + return TRUE; +} +#endif + +#ifdef _SKILL_NOCAST //vincent輼:Ĭ +int PETSKILL_Nocast( + int charaindex, + int toindex, + int array, + char *data + +) +{ + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_S_NOCAST); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, toindex ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + CHAR_SETWORKINT_LOW( charaindex, CHAR_WORKBATTLECOM3, array); + return TRUE; +} +#endif + +#ifdef _SKILL_ROAR //vincent輼: +int PETSKILL_Roar( + int charaindex, + int toindex, + int array, + char *data + +) +{ + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_S_ROAR); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, toindex ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + CHAR_SETWORKINT_LOW( charaindex, CHAR_WORKBATTLECOM3, array); + return TRUE; +} +#endif + +#ifdef _SKILL_GUARDBREAK2//Ƴ2 vincent add 2002/05/20 +int PETSKILL_GuardBreak2( + int charaindex, + int toNo, + int array, + char *data + +) +{ + + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_S_GBREAK2 ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, toNo ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + + return TRUE; + +} +#endif + +//******************************************************* +int PETSKILL_NormalAttack( + int charaindex, + int toindex, + int array, + char *data + +) +{ +#ifdef _PETSKILL_NONO_FIX + if(CHAR_getWorkInt(charaindex,CHAR_WORKFIXAI)>=40 && CHAR_getWorkInt(charaindex,CHAR_WORKBATTLEMODE)!=BATTLE_CHARMODE_NONE && CHAR_getInt(charaindex, CHAR_WHICHTYPE)==CHAR_TYPEPET){ + CHAR_setWorkInt(charaindex,CHAR_WORKATTACKPOWER,CHAR_getWorkInt(charaindex,CHAR_WORKFIXSTR)); + CHAR_setWorkInt(charaindex,CHAR_WORKDEFENCEPOWER,CHAR_getWorkInt(charaindex,CHAR_WORKFIXTOUGH)); + CHAR_setWorkInt(charaindex,CHAR_WORKQUICK,CHAR_getWorkInt(charaindex,CHAR_WORKFIXDEX)); + } +#endif + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_ATTACK ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, toindex ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + + return TRUE; + +} + +int PETSKILL_NormalGuard( + int charaindex, + int toindex, + int array, + char *data + +) +{ + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_GUARD ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, toindex ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + + return TRUE; + +} + + +int PETSKILL_None( + int charaindex, + int toindex, + int array, + char *data +) +{ + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_NONE ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, toindex ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + + return TRUE; +} + + +int PETSKILL_EarthRound( + int charaindex, + int toNo, + int array, + char *data +) +{ + char *pszOption, *pszP; + float fPer = 0.01; +#ifdef _FIX_EARTHROUND + if(toNo<0 || toNo>=BATTLE_ENTRY_MAX*2){ + print("err:һܹĿ쳣 %d ", toNo); + return FALSE; + } +#endif + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_S_EARTHROUND1 ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, toNo ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + pszOption = PETSKILL_getChar( array, PETSKILL_OPTION ); + + if( (pszP = strstr( pszOption, "%" ) ) != NULL ){ + sscanf( pszP+3, "%f", &fPer ); + CHAR_setWorkInt(charaindex,CHAR_WORKBATTLECOM3, (int)fPer ); + } + + + return TRUE; + +} + + +int PETSKILL_GuardBreak( + int charaindex, + int toNo, + int array, + char *data + +) +{ + char *pszOption, *pszP; + float fPer = 0.01; + int strdef; + + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_S_GBREAK ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, toNo ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + + pszOption = PETSKILL_getChar( array, PETSKILL_OPTION ); + + if( (pszP = strstr( pszOption, "%" ) ) != NULL ){ + sscanf( pszP+3, "%f", &fPer ); + fPer=(fPer/100); + + strdef=CHAR_getWorkInt(charaindex,CHAR_WORKFIXSTR); + strdef=(int)(strdef * fPer); + CHAR_setWorkInt(charaindex,CHAR_WORKATTACKPOWER,(CHAR_getWorkInt(charaindex,CHAR_WORKFIXSTR)+strdef)); + } + + + return TRUE; + +} +#ifdef _SKILL_SPEEDY_ATT//ٹ vincent add 2002/05/20 +int PETSKILL_SpeedyAttack( + int charaindex, + int toNo, + int array, + char *data + +) +{ + char *pszOption="\0", *pszP; + float fPer = 0.01; + int strdef=0; + + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_S_SPEEDYATTACK ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, toNo ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + + pszOption = PETSKILL_getChar( array, PETSKILL_OPTION ); + + if( pszOption == "\0" ) { + //print("\n pszOption == NULL "); + return FALSE; + } + + //ȡֵ + if( (pszP = strstr( pszOption, "%" ) ) != NULL ){ + sscanf( pszP+3, "%f", &fPer ); + fPer=(fPer/100); + + //趨ֵ + strdef=CHAR_getWorkInt(charaindex,CHAR_WORKFIXTOUGH); + strdef=(int)(strdef * fPer); + CHAR_setWorkInt(charaindex,CHAR_WORKDEFENCEPOWER,(CHAR_getWorkInt(charaindex,CHAR_WORKFIXTOUGH)+strdef)); + } + + return TRUE; + +} +#endif + +int PETSKILL_Abduct( + int charaindex, + int toNo, + int array, + char *data +) +{ + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_S_ABDUCT ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, toNo ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + CHAR_SETWORKINT_LOW( charaindex, CHAR_WORKBATTLECOM3, array); + + return TRUE; +} + +int PETSKILL_Steal( + int charaindex, + int toNo, + int array, + char *data +) +{ + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_S_STEAL ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, toNo ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + return TRUE; +} + +#ifdef _BATTLESTEAL_FIX +int PETSKILL_StealMoney( int charaindex, int toNo, int array, char *data) +{ + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_S_STEALMONEY ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, toNo ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + return TRUE; +} +#endif + +//******************************************************* +// -- ʧ ة +// +int PETSKILL_Merge( + int charaindex, + int toNo, + int array, + char *data +) +{ + int ret, ownerindex; + + // Robin 0521 debug + ownerindex = CHAR_getWorkInt( charaindex, CHAR_WORKPLAYERINDEX); + if( CHAR_getWorkInt( ownerindex, CHAR_WORKBATTLEMODE ) != BATTLE_CHARMODE_NONE ){ + print(" Merge_ErrB:fd=%d ", ownerindex); + return FALSE; + } + ret = ITEM_mergeItem_merge( CHAR_getWorkInt( charaindex, CHAR_WORKPLAYERINDEX), + CHAR_getInt( charaindex, CHAR_PETID), data, charaindex, 0); + return ret; +} + +#ifdef _ALCHEMIST +int PETSKILL_Alchemist( + int charaindex, + int toNo, + int array, + char *data +) +{ + int ret, ownerindex; + + // Robin 0521 debug + ownerindex = CHAR_getWorkInt( charaindex, CHAR_WORKPLAYERINDEX); + if( CHAR_getWorkInt( ownerindex, CHAR_WORKBATTLEMODE ) != BATTLE_CHARMODE_NONE ){ + //print(" Merge_Alchemist_ErrB:fd=%d ", ownerindex); + return FALSE; + } + ret = ITEM_mergeItem_merge( CHAR_getWorkInt( charaindex, CHAR_WORKPLAYERINDEX), + CHAR_getInt( charaindex, CHAR_PETID), data, charaindex, 1); + return ret; +} +#endif + +int PETSKILL_NoGuard( + int charaindex, + int toNo, + int array, + char *data + +) +{ + char *pszOption, *pszP; + int Duck = 0, Counter = 0, Critical = 0; + + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_S_NOGUARD ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, toNo ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + pszOption = PETSKILL_getChar( array, PETSKILL_OPTION ); + if( (pszP = strstr( pszOption, "%" ) ) != NULL ){ + sscanf( pszP+3, "%d", &Duck ); + CHAR_SETWORKINT_HIGH( charaindex, CHAR_WORKBATTLECOM3, Duck ); + } + if( (pszP = strstr( pszOption, "%" ) ) != NULL ){ + sscanf( pszP+3, "%d", &Counter ); + } + if( (pszP = strstr( pszOption, "%" ) ) != NULL ){ + sscanf( pszP+3, "%d", &Critical ); + } + CHAR_SETWORKINT_LOW( charaindex, CHAR_WORKBATTLECOM3, + (Counter << 8) + Critical ); + + return TRUE; +} + +#ifdef _ATTACK_MAGIC + +int PETSKILL_AttackMagic( + int charaindex, + int toindex, + int array, + char *data +) +{ + char *pszP; + char szMagic[] = "magic"; + char szItem[] = "item"; + int magic = 313; // magic idԤΪħȼһ,item indexԤΪ19659 +// int item = 19659; + // ȡó\ + pszP = PETSKILL_getChar( array, PETSKILL_OPTION ); + + // ȡʩŵħmagic id + if((pszP = strstr(pszP,szMagic)) != NULL) + { + pszP += sizeof(szMagic); + sscanf(pszP,"%d",&magic); + } +/* + // ȡдħԵitem index + if((pszP = strstr(pszP,szItem)) != NULL) + { + pszP += sizeof(szItem); + sscanf(pszP,"%d",&item); + } +*/ + // 趨\Ϊħ + CHAR_setWorkInt(charaindex,CHAR_WORKBATTLECOM1,BATTLE_COM_S_ATTACK_MAGIC ); + // Ŀ趨 + CHAR_setWorkInt(charaindex,CHAR_WORKBATTLECOM2,toindex); + // 趨ʹõһħ + CHAR_SETWORKINT_LOW(charaindex,CHAR_WORKBATTLECOM3,magic); + // 趨ʹõħĵ +// CHAR_SETWORKINT_HIGH(charaindex,CHAR_WORKBATTLECOM3,item); + // ´ + CHAR_setWorkInt(charaindex,CHAR_WORKBATTLEMODE,BATTLE_CHARMODE_C_OK ); + + return TRUE; +} + +#endif + +#ifdef _PSKILL_FALLGROUND // +int PETSKILL_FallGround( int charaindex, int toNo, int array, char *data ) +{ + char *pszOption, *pszP; + float fPer = 0.01; + int strdef; + + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_S_FALLRIDE ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, toNo ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + + pszOption = PETSKILL_getChar( array, PETSKILL_OPTION ); + if( (pszP = strstr( pszOption, "%" ) ) != NULL ){ + sscanf( pszP+3, "%f", &fPer ); + fPer=(fPer/100); + strdef=CHAR_getWorkInt(charaindex,CHAR_WORKFIXSTR); + strdef=(int)(strdef * fPer); + CHAR_setWorkInt(charaindex,CHAR_WORKATTACKPOWER,(CHAR_getWorkInt(charaindex,CHAR_WORKFIXSTR)+strdef)); + } + return TRUE; + +} //BATTLE_COM_S_DAMAGETOHP +#endif + +#ifdef _PRO_BATTLEENEMYSKILL +int ENEMYSKILL_ReLife( int enemyindex, int toNo, int array, char *data ) +{ + CHAR_setWorkInt( enemyindex, CHAR_WORKBATTLECOM1, BATTLE_COM_S_ENEMYRELIFE ); + CHAR_setWorkInt( enemyindex, CHAR_WORKBATTLECOM2, toNo ); + CHAR_setWorkInt( enemyindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + return TRUE; +} + +int ENEMYSKILL_ReHP( int enemyindex, int toNo, int array, char *data ) +{ + CHAR_setWorkInt( enemyindex, CHAR_WORKBATTLECOM1, BATTLE_COM_S_ENEMYREHP ); + CHAR_setWorkInt( enemyindex, CHAR_WORKBATTLECOM2, toNo ); + CHAR_setWorkInt( enemyindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + return TRUE; +} + +int ENEMYSKILL_EnemyHelp( int enemyindex, int toNo, int array, char *data ) +{ + CHAR_setWorkInt( enemyindex, CHAR_WORKBATTLECOM1, BATTLE_COM_S_ENEMYHELP ); + CHAR_setWorkInt( enemyindex, CHAR_WORKBATTLECOM2, toNo ); + CHAR_setWorkInt( enemyindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + return TRUE; +} + +#endif + +#ifdef _SKILL_DAMAGETOHP //Ѫ { "PETSKILL_DamageToHp", PETSKILL_DamageToHp, 0}, +int PETSKILL_DamageToHp( int charaindex, int toNo, int array, char *data ) +{ + char *pszOption; + char buf1[256]; + int strdef; + float def=0.00; + + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_S_DAMAGETOHP ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, toNo ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + CHAR_SETWORKINT_LOW(charaindex,CHAR_WORKBATTLECOM3, array); //¼ + pszOption = PETSKILL_getChar( array, PETSKILL_OPTION ); + + if( pszOption == "\0" ) return FALSE; + if( getStringFromIndexWithDelim( pszOption, "|", 1, buf1, sizeof( buf1)) == FALSE ) + return FALSE; + + strdef = CHAR_getWorkInt(charaindex,CHAR_WORKFIXSTR); + def = (atoi( buf1)/100); + strdef = strdef - (int)(strdef*def); + CHAR_setWorkInt( charaindex, CHAR_WORKATTACKPOWER, strdef); + + return TRUE; + +} +#endif + +#ifdef _Skill_MPDAMAGE +int PETSKILL_MpDamage( int charaindex, int toNo, int array, char *data ) +{ + char *pszOption; + char buf1[256]; + int strdef; + float def=0.00; + + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_S_MPDAMAGE ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, toNo ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + CHAR_SETWORKINT_LOW(charaindex,CHAR_WORKBATTLECOM3, array); ////¼ + + pszOption = PETSKILL_getChar( array, PETSKILL_OPTION ); + if( pszOption == "\0" ) return FALSE; + if( getStringFromIndexWithDelim( pszOption, "|", 1, buf1, sizeof( buf1)) == FALSE ) + return FALSE; + + def = (float)(atoi( buf1)/100); + strdef = CHAR_getWorkInt(charaindex,CHAR_WORKFIXSTR); + strdef = strdef - (int)( strdef*def); + CHAR_setWorkInt( charaindex, CHAR_WORKATTACKPOWER, strdef); + + return TRUE; +} +#endif + + +#ifdef _SKILL_TOOTH +int PETSKILL_ToothCrushe( int charaindex, int toNo, int array, char *data ) +{ + //char *pszOption; + //char buf1[256]; + //int strdef; + //float def=0.00; + + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_S_TOOTHCRUSHE ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, toNo ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + CHAR_SETWORKINT_LOW( charaindex, CHAR_WORKBATTLECOM3, array); //¼ +/* + pszOption = PETSKILL_getChar( array, PETSKILL_OPTION ); + if( pszOption == "\0" ) return FALSE; + if( getStringFromIndexWithDelim( pszOption, "|", 1, buf1, sizeof( buf1)) == FALSE ) + return FALSE; + + def = (float)(atoi( buf1)/100); + strdef = CHAR_getWorkInt(charaindex,CHAR_WORKFIXSTR); + strdef = strdef - (int)( strdef*def); + CHAR_setWorkInt( charaindex, CHAR_WORKATTACKPOWER, strdef); +*/ + return TRUE; +} +#endif +#ifdef _PSKILL_MODIFY +int PETSKILL_Modifyattack( int charaindex, int toNo, int array, char *data ) +{ + //char *pszOption; + //char buf1[256]; + //int strdef; + //float def=0.00; + + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_S_MODIFYATT ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, toNo ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + CHAR_SETWORKINT_LOW( charaindex, CHAR_WORKBATTLECOM3, array); //¼ +/* + pszOption = PETSKILL_getChar( array, PETSKILL_OPTION ); + if( pszOption == "\0" ) return FALSE; + if( getStringFromIndexWithDelim( pszOption, "|", 1, buf1, sizeof( buf1)) == FALSE ) + return FALSE; + + def = (float)(atoi( buf1)/100); + strdef = CHAR_getWorkInt(charaindex,CHAR_WORKFIXSTR); + strdef = strdef - (int)( strdef*def); + CHAR_setWorkInt( charaindex, CHAR_WORKATTACKPOWER, strdef); +*/ + return TRUE; +} +#endif + +#ifdef _PSKILL_MDFYATTACK +int PETSKILL_Mdfyattack( int charaindex, int toNo, int array, char *data ) +{ + char *pszOption; + char buf1[256]; + char MNodify[][36]={"EA","WA","FI","WI"}; + int nums, i; + + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_S_MDFYATTACK); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, toNo ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + CHAR_SETWORKINT_LOW( charaindex, CHAR_WORKBATTLECOM3, array);//¼ + + pszOption = PETSKILL_getChar( array, PETSKILL_OPTION ); + if( pszOption == "\0" ) return FALSE; + if( getStringFromIndexWithDelim( pszOption, "|", 1, buf1, sizeof( buf1)) == FALSE ) + return FALSE; + for( i=0; i<4; i++) { + if( strcmp( buf1, MNodify[i]) ) continue; + break; + } + if( i == 4 ) return FALSE; + CHAR_SETWORKINT_LOW( charaindex, CHAR_WORKBATTLECOM4, i);//¼ + if( getStringFromIndexWithDelim( pszOption, "|", 2, buf1, sizeof( buf1)) == FALSE ) + return FALSE; + nums=atoi( buf1); + CHAR_SETWORKINT_HIGH( charaindex, CHAR_WORKBATTLECOM4, nums);//¼ֵ + return TRUE; +} +#endif + +#ifdef _ITEM_INSLAY +int PETSKILL_Inslay( int index, int toNo, int array, char *data) +{ + int charaindex, petid; + + int inslayindex=-1, inslayno=-1; + int i, j, itemno; +#define MAXINSLAY 4 + int itemindexs[MAXINSLAY]={-1,-1,-1,-1}; + int itemnos[MAXINSLAY]={-1,-1,-1,-1}; + + if( !CHAR_CHECKINDEX( index) ) return FALSE; + if( CHAR_getInt( index, CHAR_WHICHTYPE) != CHAR_TYPEPET ) return FALSE; + charaindex = CHAR_getWorkInt( index, CHAR_WORKPLAYERINDEX); + if( !CHAR_CHECKINDEX( charaindex) ) return FALSE; + + if( CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE ) != BATTLE_CHARMODE_NONE ) + return FALSE; + petid = CHAR_getInt( charaindex, CHAR_PETID); + + + for( i = 0; i < 15; i ++ ) { + char buf[256]; + char *buf1; + int itemindex; + if( getStringFromIndexWithDelim( data , "|", i+1, buf, sizeof( buf ) ) == FALSE ) break; + itemno = atoi( buf); + if( !CHAR_CHECKITEMINDEX( charaindex, itemno) ) continue; + itemindex = CHAR_getItemIndex( charaindex, itemno); + if( !ITEM_CHECKINDEX( itemindex) ) continue; + + if( i >= MAXINSLAY ) { + CHAR_talkToCli( charaindex, -1, "ÿֻѡĸƷ", CHAR_COLORYELLOW); + return FALSE; + } + for( j=0; j< MAXINSLAY; j++ ) { + if( itemindexs[j] == itemindex ) { + //print("Ʒindexͬ ERROR !!\n"); + return FALSE; + } + } + if( (buf1 = ITEM_getChar( itemindex, ITEM_TYPECODE)) == "\0" ) { + //print(" ITEM_TYPECODE == NULL !!\n"); + return FALSE; + } + if( !strcmp( buf1, "\0") || !strcmp( buf1, "NULL") ) { + CHAR_talkToCli( charaindex, -1, "ƷʺϾ", CHAR_COLORYELLOW); + return FALSE; + } + if( strstr( buf1, "INSLAY") != 0 ) { + if( !ITEM_CHECKINDEX( inslayindex)) { + inslayindex = itemindex; + inslayno = itemno; + }else { + CHAR_talkToCli( charaindex, -1, "ÿֻѡһߡ", CHAR_COLORYELLOW); + return FALSE; + } + } + itemindexs[i] = itemindex; + itemnos[i] = itemno; + } + + if( !ITEM_CHECKINDEX( inslayindex) ) { + CHAR_talkToCli( charaindex, -1, "ѡһߡ", CHAR_COLORYELLOW); + return FALSE; + } + + for( i=0; i< MAXINSLAY; i++) { + if( !ITEM_CHECKINDEX( itemindexs[i]) )break; + if( inslayindex == itemindexs[i] ) continue; + if( PETSKILL_ITEM_inslay( charaindex, inslayindex, itemindexs[i] ) == FALSE ){ + return FALSE; + } + CHAR_DelItem( charaindex, itemnos[i]); +/* + CHAR_setItemIndex( charaindex, itemnos[i] ,-1); + CHAR_sendItemDataOne( charaindex, itemnos[i] ); + ITEM_endExistItemsOne( itemindexs[i]); +*/ + } + + CHAR_sendItemDataOne( charaindex, inslayno ); + CHAR_complianceParameter( charaindex ); + CHAR_send_P_StatusString( charaindex, CHAR_P_STRING_ATK | CHAR_P_STRING_DEF + | CHAR_P_STRING_QUICK | CHAR_P_STRING_CHARM ); + + return TRUE; +} + +#endif + +#ifdef _MAGIC_SUPERWALL +int PETSKILL_MagicStatusChange( int charaindex, int toindex, int array, char *data ) +{ + if( CHAR_CHECKINDEX( charaindex ) == FALSE ) return FALSE; + + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_S_SUPERWALL); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, toindex ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + CHAR_SETWORKINT_LOW( charaindex, CHAR_WORKBATTLECOM3, array);//¼ + + return TRUE; +} + +#endif + +#ifdef _PETSKILL_SETDUCK +int PETSKILL_SetDuck( int charaindex, int toNo, int array, char *data ) +{ + if( CHAR_CHECKINDEX( charaindex ) == FALSE ) + return FALSE; + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_S_SETDUCK); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, toNo ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + CHAR_SETWORKINT_LOW( charaindex, CHAR_WORKBATTLECOM3, array);//¼ + + + CHAR_setWorkInt( charaindex, CHAR_MAGICPETMP, 0 ); + return TRUE; +} +#endif + +#ifdef _MAGICPET_SKILL +int PETSKILL_SetMagicPet( int charaindex, int toNo, int array, char *data ) +{ + int nums=0; + if( CHAR_CHECKINDEX( charaindex ) == FALSE ) + return FALSE; + + nums = CHAR_getWorkInt( charaindex, CHAR_MAGICPETMP); + if( nums >= 3 ){ + int toindex = CHAR_getWorkInt( charaindex, CHAR_WORKPLAYERINDEX); + CHAR_talkToCli( toindex, -1, "˼ܵΡ", CHAR_COLORYELLOW); + return FALSE; + } + CHAR_setWorkInt( charaindex, CHAR_MAGICPETMP, nums ); + + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_S_SETMAGICPET); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, toNo ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + CHAR_SETWORKINT_LOW( charaindex, CHAR_WORKBATTLECOM3, array);//¼ + return TRUE; +} +#endif + +#ifdef _PETSKILL_FIXITEM +int PETSKILL_Fixitem( int index, int toNo, int array, char *data) +{ + int charaindex, petid; + + int fixindex=-1, fixno=-1; + int i, j, itemno; +#define MAXFIXITEM 2 + int itemindexs[MAXFIXITEM]={-1,-1}; + int itemnos[MAXFIXITEM]={-1,-1}; + + if( !CHAR_CHECKINDEX( index) ) return FALSE; + if( CHAR_getInt( index, CHAR_WHICHTYPE) != CHAR_TYPEPET ) return FALSE; + charaindex = CHAR_getWorkInt( index, CHAR_WORKPLAYERINDEX); + if( !CHAR_CHECKINDEX( charaindex) ) return FALSE; + + if( CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE ) != BATTLE_CHARMODE_NONE ) + return FALSE; + petid = CHAR_getInt( charaindex, CHAR_PETID); + + + for( i = 0; i < 15; i ++ ) { + char buf[256]; + int itemtype=-1; + int itemindex; + if( getStringFromIndexWithDelim( data , "|", i+1, buf, sizeof( buf ) ) == FALSE ) break; + itemno = atoi( buf); + if( !CHAR_CHECKITEMINDEX( charaindex, itemno) ) continue; + itemindex = CHAR_getItemIndex( charaindex, itemno); + if( !ITEM_CHECKINDEX( itemindex) ) continue; + + if( i >= MAXFIXITEM ) { + CHAR_talkToCli( charaindex, -1, "޸ÿֻѡƷ", CHAR_COLORYELLOW); + return FALSE; + } + for( j=0; j< MAXFIXITEM; j++ ) { + if( itemindexs[j] == itemindex ) { + //print("޸Ʒindexͬ ERROR !!\n"); + return FALSE; + } + } + itemtype = ITEM_getInt( itemindex, ITEM_TYPE); + if( itemtype == ITEM_DISH ) { + CHAR_talkToCli( charaindex, -1, "޸", CHAR_COLORYELLOW); + return FALSE; + } + + if( (itemtype >= ITEM_FIST && itemtype <= ITEM_AMULET) || + itemtype == ITEM_BOOMERANG || itemtype == ITEM_BOUNDTHROW || itemtype == ITEM_BREAKTHROW +#ifdef _ITEM_EQUITSPACE + || itemtype == ITEM_WBELT + || itemtype == ITEM_WSHIELD + || itemtype == ITEM_WSHOES +#endif +#ifdef _EQUIT_NEWGLOVE + || itemtype == ITEM_WGLOVE +#endif +#ifdef _PET_ITEM +#ifndef _TAKE_ITEMDAMAGE_FOR_PET + || (itemtype >= ITEM_PET_HEAD && itemtype <= ITEM_PET_FEET) +#endif +#endif + ){ + if( !ITEM_CHECKINDEX( fixindex)) { + fixindex = itemindex; + fixno = itemno; + }else { + CHAR_talkToCli( charaindex, -1, "޸ÿֻѡһߡ", CHAR_COLORYELLOW); + return FALSE; + } + } + + itemindexs[i] = itemindex; + itemnos[i] = itemno; + } + + if( !ITEM_CHECKINDEX( fixindex) ) { + CHAR_talkToCli( charaindex, -1, "޸ѡһߡ", CHAR_COLORYELLOW); + return FALSE; + } + + if( PETSKILL_ITEM_FixItem( charaindex, fixindex, itemindexs ) == FALSE ){ + return FALSE; + }else { + for( i=0; i< MAXFIXITEM; i++) { + if( !ITEM_CHECKINDEX( itemindexs[i]) )break; + if( fixindex == itemindexs[i] ) continue; + CHAR_setItemIndex( charaindex, itemnos[i] ,-1); + CHAR_sendItemDataOne( charaindex, itemnos[i] ); + ITEM_endExistItemsOne( itemindexs[i]); + } + } + + CHAR_sendItemDataOne( charaindex, fixno ); + CHAR_complianceParameter( charaindex ); + CHAR_send_P_StatusString( charaindex, CHAR_P_STRING_ATK | CHAR_P_STRING_DEF + | CHAR_P_STRING_QUICK | CHAR_P_STRING_CHARM ); + CHAR_talkToCli( charaindex, -1, "޸ɡ", CHAR_COLORYELLOW); + return TRUE; +} +#endif + +#ifdef _PETSKILL_TIMID +int PETSKILL_BattleTimid( int charaindex, int toNo, int array, char *data ) +{ + if( !CHAR_CHECKINDEX( charaindex) ) return FALSE; + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE) == CHAR_TYPEPLAYER ) return FALSE; + + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_S_TIMID ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, toNo ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + + CHAR_setWorkInt( charaindex, CHAR_WORKATTACKPOWER, ( CHAR_getWorkInt( charaindex, CHAR_WORKFIXSTR)*0.7) ); + CHAR_setWorkInt( charaindex, CHAR_WORKDEFENCEPOWER, ( CHAR_getWorkInt( charaindex, CHAR_WORKFIXTOUGH)*0.4) ); + CHAR_setWorkInt( charaindex, CHAR_WORKQUICK, ( CHAR_getWorkInt( charaindex, CHAR_WORKFIXDEX)*0.8) ); + CHAR_SETWORKINT_LOW( charaindex, CHAR_WORKBATTLECOM3, array);//¼ + + return TRUE; +} +#endif +#ifdef _PETSKILL_2TIMID +int PETSKILL_2BattleTimid( int charaindex, int toNo, int array, char *data ) +{ + char *pszOption="\0"; + char *pszP; + float fPer=0; + if( !CHAR_CHECKINDEX( charaindex) ) return FALSE; + + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_S_2TIMID ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, toNo ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + + pszOption = PETSKILL_getChar( array, PETSKILL_OPTION ); + if( pszOption == "\0" ) return FALSE; + if( (pszP = strstr( pszOption, "-%" ) ) != NULL ){ + sscanf( pszP+4, "%f", &fPer ); + fPer=(fPer/100); + CHAR_setWorkInt( charaindex, CHAR_WORKATTACKPOWER, (CHAR_getWorkInt( charaindex, CHAR_WORKFIXSTR)*fPer) ); + } + if( (pszP = strstr( pszOption, "+%" ) ) != NULL ){ + sscanf( pszP+4, "%f", &fPer ); + fPer=(fPer/100); + CHAR_setWorkInt( charaindex, CHAR_WORKATTACKPOWER, CHAR_getWorkInt( charaindex, CHAR_WORKFIXSTR)+(CHAR_getWorkInt( charaindex, CHAR_WORKFIXSTR)*fPer) ); + } + if( (pszP = strstr( pszOption, "-%" ) ) != NULL ){ + sscanf( pszP+4, "%f", &fPer ); + fPer=(fPer/100); + CHAR_setWorkInt( charaindex, CHAR_WORKDEFENCEPOWER, ( CHAR_getWorkInt( charaindex, CHAR_WORKFIXTOUGH)*fPer) ); + } + if( (pszP = strstr( pszOption, "+%" ) ) != NULL ){ + sscanf( pszP+4, "%f", &fPer ); + fPer=(fPer/100); + CHAR_setWorkInt( charaindex, CHAR_WORKDEFENCEPOWER, CHAR_getWorkInt( charaindex, CHAR_WORKFIXTOUGH)+(CHAR_getWorkInt( charaindex, CHAR_WORKFIXTOUGH)*fPer) ); + } + if( (pszP = strstr( pszOption, "-%" ) ) != NULL ){ + sscanf( pszP+4, "%f", &fPer ); + fPer=(fPer/100); + CHAR_setWorkInt( charaindex, CHAR_WORKQUICK, ( CHAR_getWorkInt( charaindex, CHAR_WORKFIXDEX)*fPer) ); + } + if( (pszP = strstr( pszOption, "+%" ) ) != NULL ){ + sscanf( pszP+4, "%f", &fPer ); + fPer=(fPer/100); + CHAR_setWorkInt( charaindex, CHAR_WORKQUICK, CHAR_getWorkInt( charaindex, CHAR_WORKFIXDEX)+(CHAR_getWorkInt( charaindex, CHAR_WORKFIXDEX)*fPer) ); + } + + CHAR_SETWORKINT_LOW( charaindex, CHAR_WORKBATTLECOM3, array);//¼ + + return TRUE; +} +#endif +#ifdef _PETSKILL_ANTINTER +int PETSKILL_AntInter( int charaindex, int toNo, int array, char* data) +{ + if( !CHAR_CHECKINDEX( charaindex) ) return FALSE; + + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_S_ANTINTER); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, toNo ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + + CHAR_SETWORKINT_LOW( charaindex, CHAR_WORKBATTLECOM3, array);//¼ + return TRUE; +} +#endif + +#ifdef _PETSKILL_PROPERTY +int PETSKILL_BattleProperty( int charaindex, int toNo, int array, char *data ) +{ + if( !CHAR_CHECKINDEX( charaindex) ) return FALSE; + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE) == CHAR_TYPEPLAYER ) return FALSE; + + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_S_PROPERTYSKILL ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, toNo ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + +// CHAR_setWorkInt( charaindex, CHAR_WORKATTACKPOWER, ( CHAR_getWorkInt( charaindex, CHAR_WORKFIXSTR)*0.7) ); +// CHAR_setWorkInt( charaindex, CHAR_WORKDEFENCEPOWER, ( CHAR_getWorkInt( charaindex, CHAR_WORKFIXTOUGH)*0.5) ); +// CHAR_setWorkInt( charaindex, CHAR_WORKQUICK, ( CHAR_getWorkInt( charaindex, CHAR_WORKFIXDEX)*0.95) ); + CHAR_SETWORKINT_LOW( charaindex, CHAR_WORKBATTLECOM3, array);//¼ + + return TRUE; +} +#endif + +#ifdef _PETSKILL_TEAR +int PETSKILL_BattleTearDamage( int charaindex, int toNo, int array, char *data ) +{ + if( !CHAR_CHECKINDEX( charaindex) ) return FALSE; + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE) == CHAR_TYPEPLAYER ) return FALSE; + + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_S_PETSKILLTEAR ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, toNo ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + + CHAR_setWorkInt( charaindex, CHAR_WORKATTACKPOWER, ( CHAR_getWorkInt( charaindex, CHAR_WORKFIXSTR)*0.9) ); + CHAR_setWorkInt( charaindex, CHAR_WORKDEFENCEPOWER, ( CHAR_getWorkInt( charaindex, CHAR_WORKFIXTOUGH)*0.8) ); + CHAR_SETWORKINT_LOW( charaindex, CHAR_WORKBATTLECOM3, array);//¼ + return TRUE; +} +#endif + + +#ifdef _BATTLE_LIGHTTAKE +int PETSKILL_Lighttakeed( int charaindex, int toNo, int array, char *data ) +{ + if( !CHAR_CHECKINDEX( charaindex) ) return FALSE; + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE) == CHAR_TYPEPLAYER ) return FALSE; + + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_S_LIGHTTAKE ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, toNo ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + + CHAR_setWorkInt( charaindex, CHAR_WORKATTACKPOWER, (CHAR_getWorkInt( charaindex, CHAR_WORKFIXSTR)*0.7) ); + CHAR_setWorkInt( charaindex, CHAR_WORKDEFENCEPOWER, (CHAR_getWorkInt( charaindex, CHAR_WORKFIXTOUGH)*0.5) ); +// CHAR_setWorkInt( charaindex, CHAR_WORKQUICK, (CHAR_getWorkInt( charaindex, CHAR_WORKFIXDEX)*0.95) ); + CHAR_SETWORKINT_LOW( charaindex, CHAR_WORKBATTLECOM3, array);//¼ + return TRUE; +} +#endif + +#ifdef _BATTLE_ATTCRAZED +int PETSKILL_AttackCrazed( int charaindex, int toNo, int array, char *data ) +{ + char *pszOption="\0",*pszP; + int attnum,strdef,d_dep; + float fPer = 0.01; + if( !CHAR_CHECKINDEX( charaindex) ) return FALSE; + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE) == CHAR_TYPEPLAYER ) return FALSE; + + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_S_ATTCRAZED ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, toNo ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + +// CHAR_setWorkInt( charaindex, CHAR_WORKATTACKPOWER, (CHAR_getWorkInt( charaindex, CHAR_WORKFIXSTR)*0.8) ); +// CHAR_setWorkInt( charaindex, CHAR_WORKDEFENCEPOWER, (CHAR_getWorkInt( charaindex, CHAR_WORKFIXTOUGH)*0.7) ); + + pszOption = PETSKILL_getChar( array, PETSKILL_OPTION ); + if( pszOption == "\0" ) return FALSE; + + //ȡֵ + if( (pszP = strstr( pszOption, "%" ) ) != NULL ){ + sscanf( pszP+3, "%f", &fPer ); + fPer=(fPer/100); + + //趨ֵ + strdef=CHAR_getWorkInt(charaindex,CHAR_WORKFIXSTR); + strdef=(int)(strdef * fPer); + CHAR_setWorkInt(charaindex,CHAR_WORKATTACKPOWER,(CHAR_getWorkInt(charaindex,CHAR_WORKFIXSTR)+strdef)); + } + + if( (pszP = strstr( pszOption, "%" ) ) != NULL ){ + sscanf( pszP+3, "%f", &fPer ); + fPer=(fPer/100); + strdef=CHAR_getWorkInt(charaindex,CHAR_WORKFIXTOUGH); + strdef=(int)(strdef * fPer); + CHAR_setWorkInt(charaindex,CHAR_WORKDEFENCEPOWER,(CHAR_getWorkInt(charaindex,CHAR_WORKFIXTOUGH)+strdef)); + } + + if( (pszP = strstr( pszOption, "%" ) ) != NULL ){ + sscanf( pszP+3, "%f", &fPer ); + CHAR_setWorkInt( charaindex, CHAR_SKILLDEXPOWER, fPer); + fPer = fPer / 100; + d_dep = CHAR_getWorkInt( charaindex, CHAR_WORKFIXDEX); + d_dep = (int)(d_dep * fPer); + CHAR_setWorkInt( charaindex, CHAR_WORKQUICK, CHAR_getWorkInt( charaindex, CHAR_WORKFIXDEX) + d_dep); + } + + if( (pszP = strstr( pszOption, "" ) ) != NULL ){ + sscanf( pszP+3, "%d", &attnum ); + CHAR_SETWORKINT_HIGH( charaindex, CHAR_WORKBATTLECOM3, attnum); + } + + CHAR_SETWORKINT_LOW( charaindex, CHAR_WORKBATTLECOM3, array);//¼ + //CHAR_SETWORKINT_HIGH( charaindex, CHAR_WORKBATTLECOM3, atoi(pszOption)); + return TRUE; +} +#endif + +#ifdef _SHOOTCHESTNUT // Syu ADD 輼 +int PETSKILL_AttackShoot( int charaindex, int toNo, int array, char *data ) +{ + //int n = RAND ( 3 , 5 ) ; + int n ; + int loyal = CHAR_getWorkInt( charaindex, CHAR_WORKFIXAI ); + char bb1[16] , bb2[16] ; + char *buf = "\0" ; + if( !CHAR_CHECKINDEX( charaindex) ) return FALSE; + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE) == CHAR_TYPEPLAYER ) return FALSE; + + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_S_ATTSHOOT ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, toNo ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + + buf = PETSKILL_getChar( array , PETSKILL_OPTION ) ; + if ( buf == "\0" ) return FALSE; + getStringFromIndexWithDelim( buf , "|", 1 , bb1 , sizeof( bb1 ) ); + getStringFromIndexWithDelim( buf , "|", 2 , bb2 , sizeof( bb2 ) ); + n = RAND ( atoi(bb1) , atoi(bb2) ) ; + if ( loyal >= 100 ) { + if ( RAND ( 1 , 300 ) > 299 ) + n = 8 ; + else if ( (CHAR_getInt( charaindex , CHAR_HP )) < 20 && ( RAND ( 1 , 50 ) > 49 ) ) + n = 8 ; + } +/* + if ( n != 8 ) + CHAR_setWorkInt( charaindex, CHAR_WORKATTACKPOWER, (CHAR_getWorkInt( charaindex, CHAR_WORKFIXSTR) * 1.2 / n ) ); + else + CHAR_setWorkInt( charaindex, CHAR_WORKATTACKPOWER, (CHAR_getWorkInt( charaindex, CHAR_WORKFIXSTR) * 1.2 / 4 ) ); + CHAR_setWorkInt( charaindex, CHAR_WORKDEFENCEPOWER, (CHAR_getWorkInt( charaindex, CHAR_WORKFIXTOUGH) * 1) ); +*/ + CHAR_SETWORKINT_LOW( charaindex, CHAR_WORKBATTLECOM3, array);//¼ + CHAR_SETWORKINT_HIGH( charaindex, CHAR_WORKBATTLECOM3, n); + return TRUE; +} +#endif + +#ifdef _PET_SKILL_SARS // WON ADD ɷ +int PETSKILL_Sars( int charaindex, int toNo, int array, char *data ) +{ + + char *pszOption, *pszP; + int status = -1, i = 0, turn = 3; + char szTurn[] = "turn"; + + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_S_SARS ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, toNo ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + + pszOption = PETSKILL_getChar( array, PETSKILL_OPTION ); + pszP = pszOption; + + for( ;status == -1 && pszP[0] != 0; pszP++ ){ + for( i = 1; i < BATTLE_ST_END; i ++ ){ + if( strncmp( pszP, aszStatus[i], 2 ) == 0 ){ + status = i; + pszP +=2; + break; + } + } + } + + if( ( pszP = strstr( pszP, szTurn ) ) != NULL){ + pszP += sizeof( szTurn ); + sscanf( pszP, "%d", &turn ); + } + + CHAR_SETWORKINT_LOW( charaindex, CHAR_WORKBATTLECOM3, status ); + CHAR_SETWORKINT_HIGH( charaindex, CHAR_WORKBATTLECOM3, turn ); + + return TRUE; + + +} +#endif + +#ifdef _SONIC_ATTACK // WON ADD +int PETSKILL_Sonic( int charaindex, int toNo, int array, char *data ) +{ + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_S_SONIC ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, toNo ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + + CHAR_SETWORKINT_LOW( charaindex, CHAR_WORKBATTLECOM3, array); //¼ + return TRUE; + +} +#endif +#ifdef _PETSKILL_REGRET +int PETSKILL_Regret( int charaindex, int toNo, int array, char *data ) +{ + char *pszOption, *pszP; + int strdef,d_dep; + float fPer = 0.01; + pszOption = PETSKILL_getChar( array, PETSKILL_OPTION ); + if( (pszP = strstr( pszOption, "%" ) ) != NULL ){ + sscanf( pszP+3, "%f", &fPer ); + fPer=(fPer/100); + strdef=CHAR_getWorkInt(charaindex,CHAR_WORKFIXSTR); + strdef=(int)(strdef * fPer); + CHAR_setWorkInt(charaindex,CHAR_WORKATTACKPOWER,(CHAR_getWorkInt(charaindex,CHAR_WORKFIXSTR)+strdef)); + } + + if( (pszP = strstr( pszOption, "%" ) ) != NULL ){ + sscanf( pszP+3, "%f", &fPer ); + fPer=(fPer/100); + strdef=CHAR_getWorkInt(charaindex,CHAR_WORKFIXTOUGH); + strdef=(int)(strdef * fPer); + CHAR_setWorkInt(charaindex,CHAR_WORKDEFENCEPOWER,(CHAR_getWorkInt(charaindex,CHAR_WORKFIXTOUGH)+strdef)); + } + if( (pszP = strstr( pszOption, "%" ) ) != NULL ){ + sscanf( pszP+3, "%f", &fPer ); + CHAR_setWorkInt( charaindex, CHAR_SKILLDEXPOWER, fPer); + fPer = fPer / 100; + d_dep = CHAR_getWorkInt( charaindex, CHAR_WORKFIXDEX); + d_dep = (int)(d_dep * fPer); + CHAR_setWorkInt( charaindex, CHAR_WORKQUICK, CHAR_getWorkInt( charaindex, CHAR_WORKFIXDEX) + d_dep); + } + + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_S_REGRET ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, toNo ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + + CHAR_SETWORKINT_LOW( charaindex, CHAR_WORKBATTLECOM3, array); //¼ + return TRUE; + +} +#endif + +#ifdef _PETSKILL_GYRATE +int PETSKILL_Gyrate( int charaindex, int toNo, int array, char *data ) +{ + char *pszOption="\0", *pszP; + float fPer = 0.01; + int strdef=0; + char szTurn[] = "turn"; + int d_dep,i=0; + int randi=0; + //char *hetStatus[]={"ȫ", "", "", "", "ʯ", "", "", "", "", "", "Ĭ"}; + + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_S_GYRATE ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, toNo ); // 23,24,25,26 Ϊ + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + + pszOption = PETSKILL_getChar( array, PETSKILL_OPTION ); + + if( pszOption == "\0" ) { + //print("\n pszOption == NULL "); + return FALSE; + } +#ifdef _PSKILL_GYRATE + for(i=0;ii){ +// CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM5, 0); +// } + }else{ + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM7, 60); +// randi=RAND(1,100); +// if(randi>60){ +// CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM5, 0); +// } + } +#endif + //ȡֵ + if( (pszP = strstr( pszOption, "%" ) ) != NULL ){ + sscanf( pszP+3, "%f", &fPer ); + fPer=(fPer/100); + + //趨ֵ + strdef=CHAR_getWorkInt(charaindex,CHAR_WORKFIXSTR); + strdef=(int)(strdef * fPer); + CHAR_setWorkInt(charaindex,CHAR_WORKATTACKPOWER,(CHAR_getWorkInt(charaindex,CHAR_WORKFIXSTR)+strdef)); + } +#ifdef _PSKILL_GYRATE + if( (pszP = strstr( pszOption, "%" ) ) != NULL ){ + sscanf( pszP+3, "%f", &fPer ); + fPer=(fPer/100); + strdef=CHAR_getWorkInt(charaindex,CHAR_WORKFIXTOUGH); + strdef=(int)(strdef * fPer); + CHAR_setWorkInt(charaindex,CHAR_WORKDEFENCEPOWER,(CHAR_getWorkInt(charaindex,CHAR_WORKFIXTOUGH)+strdef)); + } + + if( (pszP = strstr( pszOption, "%" ) ) != NULL ){ + sscanf( pszP+3, "%f", &fPer ); + CHAR_setWorkInt( charaindex, CHAR_SKILLDEXPOWER, fPer); + fPer = fPer / 100; + d_dep = CHAR_getWorkInt( charaindex, CHAR_WORKFIXDEX); + d_dep = (int)(d_dep * fPer); + CHAR_setWorkInt( charaindex, CHAR_WORKQUICK, CHAR_getWorkInt( charaindex, CHAR_WORKFIXDEX) + d_dep); + } +#endif + CHAR_SETWORKINT_LOW( charaindex, CHAR_WORKBATTLECOM3, array); //¼ + return TRUE; +} +#endif + +#ifdef _PETSKILL_ACUPUNCTURE +int PETSKILL_Acupuncture( int charaindex, int toNo, int array, char *data ) +{ + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_S_ACUPUNCTURE ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, toNo ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + + CHAR_SETWORKINT_LOW( charaindex, CHAR_WORKBATTLECOM3, array); //¼ + return TRUE; +} +#endif + +#ifdef _PETSKILL_RETRACE +int PETSKILL_Retrace( int charaindex, int toNo, int array, char *data ) +{ + //char *pszOption="\0", *pszP; + //float fPer = 0.01; + //int strdef=0; + + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_S_RETRACE ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, toNo ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + +/* pszOption = PETSKILL_getChar( array, PETSKILL_OPTION ); + + if( pszOption == "\0" ) { + print("\n pszOption == NULL "); + return FALSE; + } + + //ȡֵ + if( (pszP = strstr( pszOption, "%" ) ) != NULL ){ + sscanf( pszP+3, "%f", &fPer ); + fPer=(fPer/100); + //趨ֵ + strdef=CHAR_getWorkInt(charaindex,CHAR_WORKFIXSTR); + strdef=(int)(strdef * fPer); + CHAR_setWorkInt(charaindex,CHAR_WORKATTACKPOWER,(CHAR_getWorkInt(charaindex,CHAR_WORKFIXSTR)+strdef)); + } +*/ + CHAR_SETWORKINT_LOW( charaindex, CHAR_WORKBATTLECOM3, array); //¼ + return TRUE; +} +#endif + +#ifdef _PETSKILL_HECTOR +int PETSKILL_Hector( int charaindex, int toNo, int array, char *data ) +{ + char *pszOption="\0", *pszP; + float fPer = 0.01; + int strdef; + char szTurn[] = "turn"; + int d_dep,i=0; + char *hetStatus[]={"ȫ", "", "", "", "ʯ", "", "", "", "", "", "Ĭ"}; + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_S_HECTOR ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, toNo ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + + pszOption = PETSKILL_getChar( array, PETSKILL_OPTION ); + + if( pszOption == "\0" ) { + //print("\n pszOption == NULL "); + return FALSE; + } + for(i=0;i<11;i++){ + if((pszP = strstr( pszOption, hetStatus[i] ) ) != NULL) break; + } + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM5, i); + if((pszP = strstr( pszOption, szTurn ) ) != NULL){ + pszP += sizeof( szTurn ); + sscanf( pszP, "%d", &i ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM6, i); + }else{ + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM6, 1); + } + + if((pszP = strstr( pszOption, "" ) ) != NULL){ + sscanf( pszP+3, "%d", &i ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM7, i); + }else{ + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM7, 60); + } + + //ȡֵ + if( (pszP = strstr( pszOption, "%" ) ) != NULL ){ + sscanf( pszP+3, "%f", &fPer ); + fPer=(fPer/100); + + //趨ֵ + strdef=CHAR_getWorkInt(charaindex,CHAR_WORKFIXSTR); + strdef=(int)(strdef * fPer); + CHAR_setWorkInt(charaindex,CHAR_WORKATTACKPOWER,(CHAR_getWorkInt(charaindex,CHAR_WORKFIXSTR)+strdef)); + } + + if( (pszP = strstr( pszOption, "%" ) ) != NULL ){ + sscanf( pszP+3, "%f", &fPer ); + fPer=(fPer/100); + strdef=CHAR_getWorkInt(charaindex,CHAR_WORKFIXTOUGH); + strdef=(int)(strdef * fPer); + CHAR_setWorkInt(charaindex,CHAR_WORKDEFENCEPOWER,(CHAR_getWorkInt(charaindex,CHAR_WORKFIXTOUGH)+strdef)); + } + + if( (pszP = strstr( pszOption, "%" ) ) != NULL ){ + sscanf( pszP+3, "%f", &fPer ); + CHAR_setWorkInt( charaindex, CHAR_SKILLDEXPOWER, fPer); + fPer = fPer / 100; + d_dep = CHAR_getWorkInt( charaindex, CHAR_WORKFIXDEX); + d_dep = (int)(d_dep * fPer); + CHAR_setWorkInt( charaindex, CHAR_WORKQUICK, CHAR_getWorkInt( charaindex, CHAR_WORKFIXDEX) + d_dep); + } + + CHAR_SETWORKINT_LOW( charaindex, CHAR_WORKBATTLECOM3, array); //¼ + + return TRUE; +} +#endif + +#ifdef _PETSKILL_FIREKILL +int PETSKILL_Firekill( int charaindex, int toNo, int array, char *data ) +{ + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_S_FIREKILL ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, toNo ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + + CHAR_SETWORKINT_LOW( charaindex, CHAR_WORKBATTLECOM3, array); //¼ + + return TRUE; +} +#endif + +#ifdef _PETSKILL_DAMAGETOHP +int PETSKILL_DamageToHp2( int charaindex, int toNo, int array, char *data ) +{ + + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_S_DAMAGETOHP2 ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, toNo ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + CHAR_SETWORKINT_LOW(charaindex,CHAR_WORKBATTLECOM3, array); //¼ +/* pszOption = PETSKILL_getChar( array, PETSKILL_OPTION ); + + if( pszOption == "\0" ) return FALSE; + + strdef = CHAR_getWorkInt(charaindex,CHAR_WORKFIXSTR); + def = (atoi( pszOption)/100); + strdef = strdef - (int)(strdef*def); + CHAR_setWorkInt( charaindex, CHAR_WORKATTACKPOWER, strdef); +*/ + + return TRUE; + +} +#endif + +#ifdef _PETSKILL_BECOMEFOX +int PETSKILL_BecomeFox( int charaindex, int toNo, int array, char* data) +{ + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_S_BECOMEFOX); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, toNo ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + CHAR_SETWORKINT_LOW(charaindex,CHAR_WORKBATTLECOM3, array); //¼ + + return TRUE; +} +#endif + +#ifdef _PETSKILL_BECOMEPIG +int PETSKILL_BecomePig( int charaindex, int toNo, int array, char* data) +{ + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_S_BECOMEPIG); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, toNo ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + CHAR_SETWORKINT_LOW( charaindex, CHAR_WORKBATTLECOM3, array); //¼ + return TRUE; +} +#endif + +#ifdef _PETSKILL_LER +int PETSKILL_BatFly(int charaindex,int toNo,int array,char* data) +{ + CHAR_setWorkInt(charaindex,CHAR_WORKBATTLECOM1,BATTLE_COM_S_BAT_FLY); + CHAR_setWorkInt(charaindex,CHAR_WORKBATTLECOM2,toNo); + CHAR_setWorkInt(charaindex,CHAR_WORKBATTLEMODE,BATTLE_CHARMODE_C_OK); + CHAR_SETWORKINT_LOW(charaindex,CHAR_WORKBATTLECOM3,array); + return TRUE; +} + +int PETSKILL_DivideAttack( int charaindex, int toNo, int array, char* data) +{ + CHAR_setWorkInt(charaindex,CHAR_WORKBATTLECOM1,BATTLE_COM_S_DIVIDE_ATTACK); + CHAR_setWorkInt(charaindex,CHAR_WORKBATTLECOM2,toNo); + CHAR_setWorkInt(charaindex,CHAR_WORKBATTLEMODE,BATTLE_CHARMODE_C_OK); + CHAR_SETWORKINT_LOW(charaindex,CHAR_WORKBATTLECOM3,array); + return TRUE; +} +#endif + +#ifdef _PETSKILL_BATTLE_MODEL +int PETSKILL_BattleModel(int charaindex, int toindex, int array, char* data) +{ + float fPer; + int i,iType,iObjectNum,iValue,strdef,d_dep; + char *pszOption="\0",*pszP,szData[32],szData2[32]; + + pszOption = PETSKILL_getChar(array,PETSKILL_OPTION); + if(pszOption == "\0"){ + //printf("PETSKILL_BattleModel: ȡ PETSKILL_OPTION !!(:%d,ļ:%s,%d)\n",array,__FILE__,__LINE__); + return FALSE; + } + + // ȡù + if(getStringFromIndexWithDelim(pszOption,"|",1,szData,sizeof(szData)) == FALSE){ + //printf("PETSKILL_BattleModel: no type data!!(ļ:%s,%d)\n",__FILE__,__LINE__); + return FALSE; + } + iType = atoi(szData); + // ȡù + if(getStringFromIndexWithDelim(pszOption,"|",2,szData,sizeof(szData)) == FALSE){ + //printf("PETSKILL_BattleModel: no object number data!!(ļ:%s,%d)\n",__FILE__,__LINE__); + return FALSE; + } + iObjectNum = atoi(szData); + if(iObjectNum <= 0) iObjectNum = RAND(1,10); + else if(iObjectNum > 10) iObjectNum = 10; + // ȡ + if(getStringFromIndexWithDelim(pszOption,"|",6,szData,sizeof(szData)) != FALSE){ + // 趨 + if(CHAR_getWorkInt(charaindex,CHAR_WORKPETSKILLBT)==0 && CHAR_getWorkInt(charaindex,CHAR_WORKBATTLEINDEX)>-1){ + //ȡֵ + if( (pszP = strstr( szData, "%" ) ) != NULL ){ + sscanf( pszP+3, "%f", &fPer ); + fPer=(fPer/100); + + //趨ֵ + strdef=CHAR_getWorkInt(charaindex,CHAR_WORKFIXSTR); + strdef=(int)(strdef * fPer); + CHAR_setWorkInt(charaindex,CHAR_WORKATTACKPOWER,(CHAR_getWorkInt(charaindex,CHAR_WORKFIXSTR)+strdef)); + } +#ifdef _PSKILL_BATTLE_MODEL + if( (pszP = strstr( szData, "%" ) ) != NULL ){ + sscanf( pszP+3, "%f", &fPer ); + fPer=(fPer/100); + strdef=CHAR_getWorkInt(charaindex,CHAR_WORKFIXTOUGH); + strdef=(int)(strdef * fPer); + CHAR_setWorkInt(charaindex,CHAR_WORKDEFENCEPOWER,(CHAR_getWorkInt(charaindex,CHAR_WORKFIXTOUGH)+strdef)); + } + + if( (pszP = strstr( szData, "%" ) ) != NULL ){ + sscanf( pszP+3, "%f", &fPer ); + CHAR_setWorkInt( charaindex, CHAR_SKILLDEXPOWER, fPer); + fPer = fPer / 100; + d_dep = CHAR_getWorkInt( charaindex, CHAR_WORKFIXDEX); + d_dep = (int)(d_dep * fPer); + CHAR_setWorkInt( charaindex, CHAR_WORKQUICK, CHAR_getWorkInt( charaindex, CHAR_WORKFIXDEX) + d_dep); + } +#endif + } + } + CHAR_setWorkInt(charaindex,CHAR_WORKPETSKILLBT,1); + CHAR_setWorkInt(charaindex,CHAR_WORKBATTLEMODE,BATTLE_CHARMODE_C_OK); + CHAR_setWorkInt(charaindex,CHAR_WORKBATTLECOM1,BATTLE_COM_S_BATTLE_MODEL); + CHAR_SETWORKINT_LOW(charaindex,CHAR_WORKBATTLECOM2,iType); // ¼ + CHAR_SETWORKINT_HIGH(charaindex,CHAR_WORKBATTLECOM2,iObjectNum); // ¼ + CHAR_setWorkInt(charaindex,CHAR_WORKBATTLECOM3,array); + return TRUE; +} +#endif + +#ifdef _PETSKILL_SHOWMERCY +int PETSKILL_ShowMercy( int charaindex, int toNo, int array, char* data) +{ + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_S_SHOWMERCY); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, toNo ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + + return TRUE; +} +#endif + +#ifdef _PETSKILL_COMBINED +int PETSKILL_Combined( int charaindex, int toNo, int array, char* data) +{ + char *pszOption="\0"; + char combined[32]; + int kill[10],count,i; + char killstr[32],countstr[32]; + + pszOption = PETSKILL_getChar( array, PETSKILL_OPTION ); + if( pszOption == "\0" ) return FALSE; + + strcpysafe( combined,sizeof(combined), " " ); + getStringFromIndexWithDelim( pszOption, "|", 1, combined, sizeof( combined)); + if( strcmp( combined, "ۺϷ" ) == 0 ){ + if( getStringFromIndexWithDelim( pszOption, "|", 2, countstr, sizeof( countstr)) == FALSE ) + return FALSE; + count = atoi(countstr); + if( count > 10 ) + count = 10; + for(i=0;i +#include +#include +#include "buf.h" +#include "profession_skill.h" +#include "char_base.h" +#include "battle.h" +#include "magic_base.h" +#include "configfile.h" +#include "char.h" +#include "lssproto_serv.h" +#include "skill.h" + +static Professionskill *PROFESSION_skill; + +typedef struct tagProfessionskill_skillFunctionTable +{ + char *functionname; + PROFESSION_SKILL_CALLFUNC func; + int hash; +// int status; +}PROFESSION_SKILL_skillFunctionTable; + +static PROFESSION_SKILL_skillFunctionTable PROFESSION_SKILL_functbl[] = { + +// ʦ + { "PROFESSION_VOLCANO_SPRINGS", PROFESSION_volcano_springs, 0 }, // ɽȪ + { "PROFESSION_FIRE_BALL", PROFESSION_fire_ball, 0 }, // + { "PROFESSION_FIRE_SPEAR", PROFESSION_fire_spear, 0 }, // ǹ + { "PROFESSION_SUMMON_THUNDER", PROFESSION_summon_thunder, 0 }, // + { "PROFESSION_CURRENT", PROFESSION_current, 0 }, // + { "PROFESSION_STORM", PROFESSION_storm, 0 }, // + { "PROFESSION_ICE_ARROW", PROFESSION_ice_arrow, 0 }, // + { "PROFESSION_ICE_CRACK", PROFESSION_ice_crack, 0 }, // + { "PROFESSION_ICE_MIRROR", PROFESSION_ice_mirror, 0 }, // + { "PROFESSION_DOOM", PROFESSION_doom, 0 }, // ĩ + { "PROFESSION_BLOOD", PROFESSION_blood, 0 }, // Ѫ + { "PROFESSION_BLOOD_WORMS", PROFESSION_blood_worms, 0 }, // Ѫ + { "PROFESSION_SIGN", PROFESSION_sign, 0 }, // һѪ + { "PROFESSION_FIRE_ENCLOSE", PROFESSION_fire_enclose, 0 }, // + { "PROFESSION_ICE_ENCLOSE", PROFESSION_ice_eclose, 0 }, // + { "PROFESSION_THUNDER_ENCLOSE", PROFESSION_thunder_enclose, 0 }, // ׸ + { "PROFESSION_FIRE_PRACTICE", PROFESSION_fire_practice, 0 }, // ħ + { "PROFESSION_ICE_PRACTICE", PROFESSION_ice_practice, 0 }, // ħ + { "PROFESSION_THUNDER_PRACTICE",PROFESSION_thunder_practice,0 }, // ħ + { "PROFESSION_ENCLOSE", PROFESSION_enclose, 0 }, // + { "PROFESSION_TRANSPOSE", PROFESSION_transpose, 0 }, // λλ +// { "PROFESSION_ALCHEMY", PROFESSION_alchemy, 0 }, // + +// ʿ + { "PROFESSION_CHAIN_ATK", PROFESSION_chain_atk, 0 }, // + { "PROFESSION_AVOID", PROFESSION_avoid, 0 }, // ر + { "PROFESSION_WEAPON_FOCUS", PROFESSION_weapon_focus, 0 }, // ר + { "PROFESSION_REBACK", PROFESSION_reback, 0 }, // ״̬ظ + { "PROFESSION_BRUST", PROFESSION_brust, 0 }, // + { "PROFESSION_CHAIN_ATK_2", PROFESSION_chain_atk_2, 0 }, // ˫ع + { "PROFESSION_SCAPEGOAT", PROFESSION_scapegoat, 0 }, // Ϊ + { "PROFESSION_ENRAGE", PROFESSION_enrage, 0 }, // + { "PROFESSION_ENERGY_COLLECT", PROFESSION_energy_collect, 0 }, // ۼ + { "PROFESSION_FOCUS", PROFESSION_focus, 0 }, // רעս + { "PROFESSION_SHIELD_ATTACK", PROFESSION_shield_attack, 0 }, // ܻ + { "PROFESSION_DUAL_WEAPON", PROFESSION_dual_weapon, 0 }, // + { "PROFESSION_DEFLECT", PROFESSION_deflect, 0 }, // + { "PROFESSION_THROUGH_ATTACK", PROFESSION_through_attack, 0 }, // ᴩ + { "PROFESSION_CAVALRY", PROFESSION_cavalry, 0 }, // ﹥ + { "PROFESSION_DEAD_ATTACK", PROFESSION_dead_attack, 0 }, // + { "PROFESSION_CONVOLUTE", PROFESSION_convolute, 0 }, // + { "PROFESSION_CHAOS", PROFESSION_chaos, 0 }, // ҹ + +// + { "PROFESSION_TRACK", PROFESSION_track, 0 }, // ׷Ѱ + { "PROFESSION_ESCAPE", PROFESSION_escape, 0 }, // رս + { "PROFESSION_DOCILE", PROFESSION_docile, 0 }, // ѱ + { "PROFESSION_TRAP", PROFESSION_trap, 0 }, // + { "PROFESSION_ENRAGE_PET", PROFESSION_enrage_pet, 0 }, // ŭ + { "PROFESSION_DRAGNET", PROFESSION_dragnet, 0 }, // ޵ + { "PROFESSION_ENTWINE", PROFESSION_entwine, 0 }, // + { "PROFESSION_AUTARKY", PROFESSION_autarky, 0 }, // Ը + { "PROFESSION_PLUNDER", PROFESSION_plunder, 0 }, // Ӷ + { "PROFESSION_TOXIN_WEAPON", PROFESSION_toxin_weapon, 0 }, // + { "PROFESSION_RESIST_FIRE", PROFESSION_resist_fire, 0 }, // + { "PROFESSION_RESIST_ICE", PROFESSION_resist_ice, 0 }, // + { "PROFESSION_RESIST_THUNDER", PROFESSION_resist_thunder, 0 }, // ׿ +#ifdef _PROFESSION_ADDSKILL + { "PROFESSION_RESIST_F_I_T", PROFESSION_resist_f_i_t, 0 }, // Ȼ + { "PROFESSION_CALL_NATURE", PROFESSION_call_nature, 0 }, // Ȼ + { "PROFESSION_BOUNDARY", PROFESSION_boundary, 0 }, // Խ +#endif + { "PROFESSION_G_RESIST_FIRE", PROFESSION_g_resist_fire, 0 }, // + { "PROFESSION_G_RESIST_ICE", PROFESSION_g_resist_ice, 0 }, // + { "PROFESSION_G_RESIST_THUNDER",PROFESSION_g_resist_thunder,0 }, // ׿ + { "PROFESSION_ATTACK_WEAK", PROFESSION_attack_weak, 0 }, // 㹥 + { "PROFESSION_INSTIGATE", PROFESSION_instigate, 0 }, // + { "PROFESSION_OBLIVION", PROFESSION_oblivion, 0 }, // + +// ͬ + { "PROFESSION_FULL_MP", PROFESSION_full_mp, 0 }, // + { "PROFESSION_STRONG_BACK", PROFESSION_strong_back, 0 }, // + { "PROFESSION_STRENGTHEN", PROFESSION_strengthen, 0 }, // ǿ + +}; + + +static int profession_skill_num; // ְҵ + +// profession.txt +BOOL PROFESSION_initSkill( char *filename) +{ + + FILE* f; + char line[256]; + int linenum=-1; + int skill_readlen=0; + int i, j; + + int max_skillid = 0; + + f = fopen(filename,"r"); + if( f == NULL ){ + print( "file open error\n"); + return FALSE; + } + + profession_skill_num=0; + + while( fgets( line, sizeof( line ), f ) ){ + char token[256]; + + linenum ++; + if( line[0] == '#' )continue; + if( line[0] == '\n' )continue; + chomp( line ); + profession_skill_num++; +#ifdef _PROSKILL_OPTIMUM // Robin ȡְID + if( getStringFromIndexWithDelim( line, ",", + PROFESSION_SKILL_DATACHARNUM+PROFESSION_SKILL_ID+1, + token, sizeof(token)) == FALSE ) + continue; + max_skillid = max( atoi( token), max_skillid); +#endif + } + + if( fseek( f, 0, SEEK_SET ) == -1 ){ + fprint( "Seek Error\n" ); + fclose(f); + return FALSE; + } + +#ifdef _PROSKILL_OPTIMUM // ְTableΪ ID +1 + profession_skill_num = max_skillid +1; + print("ְID = %d ...", max_skillid); +#endif + + PROFESSION_skill = allocateMemory( sizeof(struct tagProfessionkill) * profession_skill_num + 1 ); + + + if( PROFESSION_skill == NULL ){ + fprint( "޷ڴ %d\n", sizeof(struct tagProfessionkill)*profession_skill_num); + fclose( f ); + return FALSE; + } + + // init skill + for( i = 0; i < profession_skill_num; i ++ ) { + for( j = 0; j < PROFESSION_SKILL_DATAINTNUM; j ++ ) + PROFESSION_SKILL_setInt( i,j,-1); + + for( j = 0; j < PROFESSION_SKILL_DATACHARNUM; j ++ ) + PROFESSION_SKILL_setChar( i,j,""); + } + + linenum = -1; + while( fgets( line, sizeof( line ), f ) ){ + linenum ++; + if( line[0] == '#' )continue; + if( line[0] == '\n' )continue; + + chomp( line ); + + replaceString( line, '\t' , ' ' ); + + { + char buf[256]; + for( i = 0; i < strlen( line); i ++) { + if( line[i] != ' ' ) { + break; + } + strcpysafe( buf,sizeof(buf), &line[i]); + } + + if( i != 0 ) { + strcpysafe( line,sizeof(line), buf); + } + } + { + char token[256]; + int ret; + +#ifdef _PROSKILL_OPTIMUM // ȡְID, ְֱIDTable index + ret = getStringFromIndexWithDelim( line, ",", PROFESSION_SKILL_DATACHARNUM+PROFESSION_SKILL_ID+1, token, sizeof(token)); + if( ret==FALSE ){ + //fprint("Syntax Error file:%s line:%d\n",filename,linenum); + break; + } + skill_readlen = atoi( token); +#endif + for( i = 0; i < PROFESSION_SKILL_DATACHARNUM; i ++ ) { + + ret = getStringFromIndexWithDelim( line,",", i + 1, token,sizeof(token)); + if( ret==FALSE ){ + //fprint("Syntax Error file:%s line:%d\n",filename,linenum); + break; + } + PROFESSION_SKILL_setChar( skill_readlen, i, token); + } + + for( i = 0; i < PROFESSION_SKILL_DATAINTNUM; i ++ ) { + ret = getStringFromIndexWithDelim( line, ",", i+PROFESSION_SKILL_DATACHARNUM+1, token, sizeof(token)); + + if( ret==FALSE ){ + //fprint("ļ﷨:%s %d\n",filename,linenum); + break; + } + if( strlen( token) != 0 ) { + PROFESSION_SKILL_setInt( skill_readlen, i , atoi( token )); + } + } + skill_readlen ++; + } + } + fclose(f); + + profession_skill_num = skill_readlen; + + for( i = 0; i < arraysizeof( PROFESSION_SKILL_functbl); i ++ ){ + PROFESSION_SKILL_functbl[i].hash = hashpjw( PROFESSION_SKILL_functbl[i].functionname ); + } + + return TRUE; + +} + + +// profession.txt +void rePROFESSION_initSkill() +{ + freeMemory( PROFESSION_skill ); + PROFESSION_initSkill(getProfession()); +} + +INLINE BOOL PROFESSION_SKILL_CHECKINDEX( int index ) +{ + if( profession_skill_num < index || index < 0 )return FALSE; + return TRUE; +} + +static INLINE BOOL PROFESSION_SKILL_CHECKINTDATAINDEX( int index) +{ + if( PROFESSION_SKILL_DATAINTNUM < index || index < 0 ) return FALSE; + return TRUE; +} + +static INLINE BOOL PROFESSION_SKILL_CHECKCHARDATAINDEX( int index) +{ + if( PROFESSION_SKILL_DATACHARNUM < index || index < 0 ) return FALSE; + return TRUE; +} + +INLINE int PROFESSION_SKILL_getInt( int index, PROFESSION_SKILL_DATAINT element) +{ + return PROFESSION_skill[index].data[element]; +} + +INLINE int PROFESSION_SKILL_setInt( int index, PROFESSION_SKILL_DATAINT element, int data) +{ + int buf; + buf = PROFESSION_skill[index].data[element]; + PROFESSION_skill[index].data[element]=data; + return buf; +} + +INLINE char* PROFESSION_SKILL_getChar( int index, PROFESSION_SKILL_DATACHAR element) +{ + if( !PROFESSION_SKILL_CHECKINDEX( index)) return "\0"; + if( !PROFESSION_SKILL_CHECKCHARDATAINDEX( element)) return "\0"; + return PROFESSION_skill[index].string[element].string; +} + +INLINE BOOL PROFESSION_SKILL_setChar( int index ,PROFESSION_SKILL_DATACHAR element, char* new ) +{ + if(!PROFESSION_SKILL_CHECKINDEX(index))return FALSE; + if(!PROFESSION_SKILL_CHECKCHARDATAINDEX(element))return FALSE; + + strcpysafe( PROFESSION_skill[index].string[element].string, + sizeof(PROFESSION_skill[index].string[element].string), + new ); + return TRUE; +} + +int PROFESSION_SKILL_getskillNum( void) +{ + return profession_skill_num; +} + + +/*----------------------------------------------------------------------*/ + +int PROFESSION_SKILL_getskillArray( int skillid) +{ +#ifdef _PROSKILL_OPTIMUM // ѯְIDΪʽ + if( skillid >= 0 && skillid < profession_skill_num ) + return PROFESSION_skill[skillid].data[PROFESSION_SKILL_ID]; +#else + int i; + for( i = 0; i <= profession_skill_num; i ++ ) { // Ż + if( PROFESSION_skill[i].data[PROFESSION_SKILL_ID] == skillid ) + return i; + } +#endif + return -1; +} + +PROFESSION_SKILL_CALLFUNC PROFESSION_SKILL_getskillFuncPointer(char* name ) +{ + int i; + int hash = hashpjw( name ); + + for( i = 0; i< arraysizeof( PROFESSION_SKILL_functbl); i++ ){ + if( PROFESSION_SKILL_functbl[i].hash == hash ){ + if( strcmp( PROFESSION_SKILL_functbl[i].functionname, name ) == 0 ){ + return PROFESSION_SKILL_functbl[i].func; + } + } + } + + return NULL; +} + +int _PROFESSION_SKILL_GetArray( char *file, int line, int charaindex, int skill ) +{ + int skillid,array; + + skillid = CHAR_getCharSkill( charaindex, skill); + + if( skillid < 0 ) return -1; + + array = PROFESSION_SKILL_getskillArray( skillid ); + + return array; +} + + +/*----------------------------------------------------------------------*/ + +// ʹְҵ +int PROFESSION_SKILL_Use( int charaindex, int skill, int toNo, char *data ) +{ + int Pskillid, skillid; + int ret=-1, skill_level; + PROFESSION_SKILL_CALLFUNC func; + CHAR_HaveSkill* hskill; + int char_pskill, profession_skill; + + skillid = CHAR_getCharSkill( charaindex, skill); + Pskillid = PROFESSION_SKILL_getskillArray( skillid); + //print("\n skillid:%d Pskillid:%d ", skillid, Pskillid); // Robin log + if( Pskillid == -1 ) { +// printf("\n ķ??Ҳְ! "); + return ret; + } + +#ifdef _PROSKILL_OPTIMUM // Robin fix ְҵǷ + char_pskill = CHAR_getInt( charaindex, PROFESSION_CLASS ); + profession_skill = PROFESSION_SKILL_getInt( Pskillid, PROFESSION_SKILL_PROFESSION_CLASS); + if( (char_pskill <=0) || (char_pskill != profession_skill) ) { +// print("\n ķ??ְְҵȷ!:%d:%d ", char_pskill, profession_skill); + return ret; + } +#endif + + // ѰӦ function + func = PROFESSION_SKILL_getskillFuncPointer( PROFESSION_SKILL_getChar( Pskillid, PROFESSION_SKILL_FUNCNAME) ); + + // жǷΪ + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE) != CHAR_TYPEPLAYER ) return ret; + + + if( func ){ + // \ܵȼ + hskill = CHAR_getCharHaveSkill( charaindex, skill ); + skill_level = SKILL_getInt( &hskill->skill, SKILL_LEVEL); + + // MP + if( PROFESSION_SKILL_DEC_COST_MP( charaindex, skill, Pskillid, skill_level ) != 1 ) { +// print("\n Error:ְMP:%d:%d:%d ", skill, Pskillid, skill_level); + return ret; + } + + // ʹְҵ + ret = func( charaindex, toNo, Pskillid, data, skill_level ); + if( ret == -1 ){ + int rands = rand()%10; + //andy_log +// print("ret = %d, rands:%d \n", ret, rands); + if( rands > 5 ) return ret; + } + + if( Pskillid == 57 //ŭ ѡоֵ + && CHAR_getInt( BATTLE_No2Index( CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEINDEX ), toNo ), CHAR_WHICHTYPE) != CHAR_TYPEPET ) + return ret; + + // һ㼼 + PROFESSION_NORMAL_SKILL_LEVLE_UP( &hskill->skill, Pskillid, charaindex ); + } + else { + //print("\n !Ҳְfunc "); + } + + return ret; +} + +// ⼼ +void PROFESSION_SKILL_LVEVEL_UP( int charaindex, char *name ) +{ + int skill=-1; + int skillid=0, Pskillid=0, i; + char *skill_name="\0"; + CHAR_HaveSkill* hskill; + + for( i=0; i CHAR_SKILLMAXHAVE) ) return; + + skillid = CHAR_getCharSkill( charaindex, skill); + Pskillid = PROFESSION_SKILL_getskillArray( skillid); + if( Pskillid == -1 ) return; + + // \ܵȼ + hskill = CHAR_getCharHaveSkill( charaindex, skill ); + + // һ㼼 + PROFESSION_NORMAL_SKILL_LEVLE_UP( &hskill->skill, Pskillid, charaindex ); + + return; +} + +// +void PROFESSION_SKILL_DUAL_WEAPON_LVEVEL_UP( int charaindex, char *name ) +{ + int skill=-1, arm = 0, shield = 0; + int skillid=0, Pskillid=0, i; + char *skill_name="\0"; + CHAR_HaveSkill* hskill; + + // װ + for( i = 0 ; i < CHAR_EQUIPPLACENUM ; i ++ ){ + int id = CHAR_getItemIndex(charaindex,i); + if( ITEM_CHECKINDEX(id) ){ + if( i == CHAR_ARM ) arm = 1; + else if( i == CHAR_EQSHIELD ) shield = 1; + } + } + + if( arm != 1 || shield != 1 ) return; + + for( i=0; i CHAR_SKILLMAXHAVE) ) return; + + skillid = CHAR_getCharSkill( charaindex, skill); + Pskillid = PROFESSION_SKILL_getskillArray( skillid); + if( Pskillid == -1 ) return; + + // \ܵȼ + hskill = CHAR_getCharHaveSkill( charaindex, skill ); + + // һ㼼 + PROFESSION_NORMAL_SKILL_LEVLE_UP( &hskill->skill, Pskillid, charaindex ); + + return; +} + + +// ר +void PROFESSION_SKILL_WEAPON_FOCUS_LVEVEL_UP( int charaindex, char *name ) +{ + int skill = -1; + int skillid=0, Pskillid = 0, i; + char *skill_name="\0", *pszOption="\0", *pszP, diff[20]; + int WeaponType = -1; + CHAR_HaveSkill* hskill; + + memset( diff, -1, sizeof(diff) ); + // װ + WeaponType = BATTLE_GetWepon( charaindex ); + + switch( WeaponType ){ + case ITEM_AXE: + sprintf( diff, "" ); break; + case ITEM_CLUB: + sprintf( diff, "" ); break; + case ITEM_SPEAR: + sprintf( diff, "ǹ" ); break; + case ITEM_BOW: + sprintf( diff, "" ); break; + case ITEM_BOOMERANG: // + sprintf( diff, "" ); break; + case ITEM_BOUNDTHROW: // Ͷͷ + sprintf( diff, "Ͷ" ); break; + case ITEM_BREAKTHROW: // Ͷʯ + sprintf( diff, "ʯ" ); break; + default: + sprintf( diff, "" ); break; + } + + for( i=0; i CHAR_SKILLMAXHAVE) ) return; + + skillid = CHAR_getCharSkill( charaindex, skill); + Pskillid = PROFESSION_SKILL_getskillArray( skillid); + if( Pskillid == -1 ) return; + + // \ܵȼ + hskill = CHAR_getCharHaveSkill( charaindex, skill ); + + // һ㼼 + PROFESSION_NORMAL_SKILL_LEVLE_UP( &hskill->skill, Pskillid, charaindex ); + + return; +} + +// MP +int PROFESSION_SKILL_DEC_COST_MP( int charaindex, int skill, int Pskillid, int skill_level ) +{ + + if(skill_level > 0){ + int dec_mp; + int old_mp = CHAR_getInt( charaindex, CHAR_MP ); + int mp=0; + // ȡ MP + if( (dec_mp = PROFESSION_MAGIC_COST_MP( charaindex, skill )) == -1 ) + dec_mp = PROFESSION_SKILL_getInt( Pskillid, PROFESSION_SKILL_COST_MP ); + // MP + if( old_mp < dec_mp ) return -1; + // Ѫ + if( Pskillid != 11 +#ifdef _PROFESSION_ADDSKILL + // && Pskillid != 2 //Բ MP +#endif + ) + if( dec_mp <= 0 ) return -1; + // ۵ MP + mp = old_mp - dec_mp; + if( mp < 0 ) mp = 0; + CHAR_setInt( charaindex , CHAR_MP , mp ); + CHAR_send_P_StatusString( charaindex , CHAR_P_STRING_MP); + return 1; + } + return -1; +} + + + +// һ㼼 +void PROFESSION_NORMAL_SKILL_LEVLE_UP(Skill *skill, int Pskillid, int charaindex ) +{ + int skill_level = 0, up_fix_value = 0; + int rand_num = RAND( 0, 10000 ), rand_num2 = 0; + + // ܵȼ޲ + skill_level = SKILL_getRealInt( skill, SKILL_LEVEL); + if( skill_level >= PROFESSION_SKILL_MAX_LEVEL * 100 ) return; + + // ֵ + up_fix_value = PROFESSION_SKILL_getInt( Pskillid, PROFESSION_SKILL_FIX_VALUE) * 100; + rand_num2 = RAND( 0, up_fix_value); + + // 춨 + if( rand_num > skill_level + rand_num2){ + // + skill_level += PROFESSION_SKILL_ADD_POINT; + SKILL_setInt( skill, SKILL_LEVEL, skill_level ); + + if( ( skill_level % 100 ) == 0 ){ + char msg[256]; + sprintf( msg, "%sΪ%d", PROFESSION_SKILL_getChar( Pskillid, PROFESSION_SKILL_NAME), skill_level/100 ); + CHAR_talkToCli( charaindex, -1, msg, CHAR_COLORYELLOW); + CHAR_sendStatusString( charaindex , "S"); + + // ְҵֵ + PROFESSION_LEVEL_CHECK_UP( charaindex ); + } + } + return; +} + + +void PROFESSION_LEVEL_CHECK_UP( int charaindex ) +{ + int skill_level_add = 0, skill_level_sum = 0, i = 0; + int old_level = CHAR_getInt( charaindex, PROFESSION_LEVEL ); + int next_level_need_point = 9999999; + CHAR_HaveSkill* hskill; + + // һְҵ + next_level_need_point = old_level * 70 * 100; + + for( i=0; iskill, SKILL_IDENTITY); + if( skillID <= 0 ) continue; + + // ͨ 50 + if( (skillID == 63) || (skillID == 64) || (skillID == 65) ){ + skill_level_add = 50*100; + }else{ + skill_level_add = SKILL_getRealInt( &hskill->skill, SKILL_LEVEL); + } + + skill_level_sum += skill_level_add; + } + +// print("\n ==> ǰȵ(%d) һ(%d)", skill_level_sum, next_level_need_point ); + + // ȴﵽһְҵʱְҵȼ + if( skill_level_sum >= next_level_need_point ){ + int old_skill_point = CHAR_getInt( charaindex, PROFESSION_SKILL_POINT ); + int next_skill_point = old_skill_point+1; + char msg[64]; + +// print("\nְҵȼ ==> ǰְҵȼ(%d) һְҵȼ(%d)", old_skill_point, next_skill_point ); + + CHAR_setInt( charaindex, PROFESSION_LEVEL, old_level + 1 ); + CHAR_setInt( charaindex, PROFESSION_SKILL_POINT, next_skill_point ); + CHAR_sendStatusString( charaindex , "P"); + + CHAR_sendCToArroundCharacter( CHAR_getWorkInt( charaindex , CHAR_WORKOBJINDEX )); + + sprintf( msg, "ְҵȼΪ%dܵ", old_level + 1 ); + CHAR_talkToCli( charaindex, -1, msg, CHAR_COLORYELLOW); + } +} + +// Ӽ +int PROFESSION_SKILL_ADDSK( int charaindex, int skill, int level ) +{ + int i; + + CHAR_HaveSkill *pSkil; + + if( level > 100 ) level = 100; + else if( level < 1 ) level = 1; + + for( i = 0; i < CHAR_SKILLMAXHAVE; i ++ ){ + int skill_id = -1; + + pSkil = CHAR_getCharHaveSkill( charaindex, i ); + skill_id = SKILL_getInt( &pSkil->skill, SKILL_IDENTITY); + if( skill == skill_id && skill_id != -1 ){ + CHAR_talkToCli(charaindex,-1, "Ѿѧϰ˼", CHAR_COLORYELLOW); + return -1; + } + + if( pSkil == (CHAR_HaveSkill*)NULL )continue; + if( pSkil->use != 0 )continue; + break; + } + if( i >= CHAR_SKILLMAXHAVE ){ + CHAR_talkToCli(charaindex,-1, "Ѵ", CHAR_COLORYELLOW); + return -1; + }else{ + level *= 100; + SKILL_makeSkillData( &pSkil->skill, skill, level); + pSkil->use = TRUE; + } + + CHAR_sendStatusString( charaindex , "S"); + + + return 1; +} + +void profession_common_fun( int charaindex, int toNo, int skill_level, int array, int com1 ) +{ + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, com1 ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, toNo ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + CHAR_SETWORKINT_HIGH( charaindex, CHAR_WORKBATTLECOM3, skill_level); + CHAR_SETWORKINT_LOW( charaindex, CHAR_WORKBATTLECOM3, array); +#ifdef _PROFESSION_ADDSKILL + if( com1 == BATTLE_COM_S_DOOM + /*&& CHAR_getWorkInt( charaindex, CHAR_DOOMTIME) == 0*/ ){ + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_NONE ); + CHAR_setWorkInt( charaindex, CHAR_WORK_com1, com1 ); + CHAR_setWorkInt( charaindex, CHAR_WORK_toNo, toNo ); + CHAR_setWorkInt( charaindex, CHAR_WORK_mode, BATTLE_CHARMODE_C_OK ); + CHAR_setWorkInt( charaindex, CHAR_WORK_skill_level, skill_level ); + CHAR_setWorkInt( charaindex, CHAR_WORK_array, array ); + CHAR_setWorkInt( charaindex, CHAR_DOOMTIME, 3); + } + else if( com1 == BATTLE_COM_S_FIRE_SPEAR + /*&& CHAR_getWorkInt( charaindex, CHAR_DOOMTIME) == 0*/ ){ + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_NONE ); + CHAR_setWorkInt( charaindex, CHAR_WORK_com1, com1 ); + CHAR_setWorkInt( charaindex, CHAR_WORK_toNo, toNo ); + CHAR_setWorkInt( charaindex, CHAR_WORK_mode, BATTLE_CHARMODE_C_OK ); + CHAR_setWorkInt( charaindex, CHAR_WORK_skill_level, skill_level ); + CHAR_setWorkInt( charaindex, CHAR_WORK_array, array ); + CHAR_setWorkInt( charaindex, CHAR_DOOMTIME, 2); + } +#endif +} + +/*----------------------------------------------------------------------*/ +// Ϊְҵ + +// ʦ-ɽȪ +int PROFESSION_volcano_springs( int charaindex, int toNo, int array, char *data, int skill_level ) +{ + if(toNo>19) + toNo=0; + profession_common_fun( charaindex, toNo, skill_level, array, BATTLE_COM_S_VOLCANO_SPRINGS ); + return TRUE; +} + +// ʦ- +int PROFESSION_fire_ball( int charaindex, int toNo, int array, char *data, int skill_level ) +{ + if(toNo<21) + toNo=0; + profession_common_fun( charaindex, toNo, skill_level, array, BATTLE_COM_S_FIRE_BALL ); + return TRUE; +} + +// ʦ-ǹ +int PROFESSION_fire_spear( int charaindex, int toNo, int array, char *data, int skill_level ) +{ + if(toNo>19) + toNo=0; + profession_common_fun( charaindex, toNo, skill_level, array, BATTLE_COM_S_FIRE_SPEAR ); + return TRUE; +} + +// ʦ- +int PROFESSION_summon_thunder( int charaindex, int toNo, int array, char *data, int skill_level ) +{ + if(toNo>19) + toNo=0; + profession_common_fun( charaindex, toNo, skill_level, array, BATTLE_COM_S_SUMMON_THUNDER ); + return TRUE; +} + +// ʦ- +int PROFESSION_current( int charaindex, int toNo, int array, char *data, int skill_level ) +{ + if(toNo!=20 && toNo!=21) + toNo=0; + profession_common_fun( charaindex, toNo, skill_level, array, BATTLE_COM_S_CURRENT ); + return TRUE; +} + +// ʦ- +int PROFESSION_storm( int charaindex, int toNo, int array, char *data, int skill_level ) +{ + if(toNo!=20 && toNo!=21) + toNo=0; + profession_common_fun( charaindex, toNo, skill_level, array, BATTLE_COM_S_STORM ); + return TRUE; +} + +// ʦ- +int PROFESSION_ice_arrow( int charaindex, int toNo, int array, char *data, int skill_level ) +{ + if(toNo>19) + toNo=0; + profession_common_fun( charaindex, toNo, skill_level, array, BATTLE_COM_S_ICE_ARROW ); + return TRUE; +} + +// ʦ- +int PROFESSION_ice_crack( int charaindex, int toNo, int array, char *data, int skill_level ) +{ + if(toNo>19) + toNo=0; + profession_common_fun( charaindex, toNo, skill_level, array, BATTLE_COM_S_ICE_CRACK ); + return TRUE; +} + +// ʦ- +int PROFESSION_ice_mirror( int charaindex, int toNo, int array, char *data, int skill_level ) +{ + if(toNo>19) + toNo=0; + profession_common_fun( charaindex, toNo, skill_level, array, BATTLE_COM_S_ICE_MIRROR ); + return TRUE; +} + +// ʦ-ĩ +int PROFESSION_doom( int charaindex, int toNo, int array, char *data, int skill_level ) +{ + if(toNo!=20 && toNo!=21) + toNo=0; + profession_common_fun( charaindex, toNo, skill_level, array, BATTLE_COM_S_DOOM ); + return TRUE; +} + +// ʦ-Ѫ +int PROFESSION_blood( int charaindex, int toNo, int array, char *data, int skill_level ) +{ + if(toNo>19) + toNo=0; + profession_common_fun( charaindex, toNo, skill_level, array, BATTLE_COM_S_BLOOD ); + return TRUE; +} + +// ʦ-Ѫ +int PROFESSION_blood_worms( int charaindex, int toNo, int array, char *data, int skill_level ) +{ + if(toNo>19) + toNo=0; + profession_common_fun( charaindex, toNo, skill_level, array, BATTLE_COM_S_BLOOD_WORMS ); + return TRUE; +} + +// ʦ-һѪ +int PROFESSION_sign( int charaindex, int toNo, int array, char *data, int skill_level ) +{ + if(toNo!=20 && toNo!=21) + toNo=0; + profession_common_fun( charaindex, toNo, skill_level, array, BATTLE_COM_S_SIGN ); + return TRUE; +} + +// ʦ- +int PROFESSION_fire_enclose( int charaindex, int toNo, int array, char *data, int skill_level ) +{ + if(toNo>19) + toNo=0; + profession_common_fun( charaindex, toNo, skill_level, array, BATTLE_COM_S_FIRE_ENCLOSE ); + return TRUE; +} + +// ʦ- +int PROFESSION_ice_eclose( int charaindex, int toNo, int array, char *data, int skill_level ) +{ + if(toNo>19) + toNo=0; + profession_common_fun( charaindex, toNo, skill_level, array, BATTLE_COM_S_ICE_ENCLOSE ); + return TRUE; +} + +// ʦ-׸ +int PROFESSION_thunder_enclose( int charaindex, int toNo, int array, char *data, int skill_level ) +{ + if(toNo>19) + toNo=0; + profession_common_fun( charaindex, toNo, skill_level, array, BATTLE_COM_S_THUNDER_ENCLOSE ); + return TRUE; +} + +// ʦ-ħ +int PROFESSION_fire_practice( int charaindex, int toNo, int array, char *data, int skill_level ) +{ + return TRUE; +} + +// ʦ-ħ +int PROFESSION_ice_practice( int charaindex, int toNo, int array, char *data, int skill_level ) +{ + return TRUE; +} + +// ʦ-ħ +int PROFESSION_thunder_practice( int charaindex, int toNo, int array, char *data, int skill_level ) +{ + return TRUE; +} + +// ʦ- +int PROFESSION_enclose( int charaindex, int toNo, int array, char *data, int skill_level ) +{ + if(toNo>19) + toNo=0; + profession_common_fun( charaindex, toNo, skill_level, array, BATTLE_COM_S_ENCLOSE ); + return TRUE; +} + +// ʦ-λλ +int PROFESSION_transpose( int charaindex, int toNo, int array, char *data, int skill_level ) +{ + if(toNo>19) + toNo=0; + profession_common_fun( charaindex, toNo, skill_level, array, BATTLE_COM_S_TRANSPOSE ); + return TRUE; +} + + +/*----------------------------------------------------------------------*/ + +// ʿ- +int PROFESSION_brust( int charaindex, int toNo, int array, char *data, int skill_level ) +{ + if(toNo>19) + toNo=0; + profession_common_fun( charaindex, toNo, skill_level, array, BATTLE_COM_S_BRUST ); + return TRUE; +} + +// ʿ- +int PROFESSION_chain_atk( int charaindex, int toNo, int array, char *data, int skill_level ) +{ + if(toNo>19) + toNo=0; + profession_common_fun( charaindex, toNo, skill_level, array, BATTLE_COM_S_CHAIN_ATK ); + return TRUE; +} + +// ʿ-ر +int PROFESSION_avoid( int charaindex, int toNo, int array, char *data, int skill_level ) +{ + if(toNo>19) + toNo=0; + profession_common_fun( charaindex, toNo, skill_level, array, BATTLE_COM_S_AVOID ); + return TRUE; +} + +// ʿ-Ѫ +int PROFESSION_recovery( int charaindex, int toNo, int array, char *data, int skill_level ) +{ + if(toNo>19) + toNo=0; + profession_common_fun( charaindex, toNo, skill_level, array, BATTLE_COM_S_RECOVERY ); + return TRUE; +} + +// ʿ-ר +int PROFESSION_weapon_focus( int charaindex, int toNo, int array, char *data, int skill_level ) +{ + return TRUE; +} + +// ʿ-״̬ظ +int PROFESSION_reback( int charaindex, int toNo, int array, char *data, int skill_level ) +{ + if(toNo>19) + toNo=0; + profession_common_fun( charaindex, toNo, skill_level, array, BATTLE_COM_S_REBACK ); + return TRUE; +} + +// ʿ-˫ع +int PROFESSION_chain_atk_2( int charaindex, int toNo, int array, char *data, int skill_level ) +{ + if(toNo>19) + toNo=0; + profession_common_fun( charaindex, toNo, skill_level, array, BATTLE_COM_S_CHAIN_ATK_2 ); + return TRUE; +} + +// ʿ-Ϊ +int PROFESSION_scapegoat( int charaindex, int toNo, int array, char *data, int skill_level ) +{ + if(toNo>19) + toNo=0; + profession_common_fun( charaindex, toNo, skill_level, array, BATTLE_COM_S_SCAPEGOAT ); + return TRUE; +} + +// ʿ- +int PROFESSION_enrage( int charaindex, int toNo, int array, char *data, int skill_level ) +{ + if(toNo>19) + toNo=0; + profession_common_fun( charaindex, toNo, skill_level, array, BATTLE_COM_S_ENRAGE ); + return TRUE; +} + +// ʿ-ۼ +int PROFESSION_energy_collect( int charaindex, int toNo, int array, char *data, int skill_level ) +{ + if(toNo>19) + toNo=0; + profession_common_fun( charaindex, toNo, skill_level, array, BATTLE_COM_S_COLLECT ); + return TRUE; +} + +// ʿ-רעս +int PROFESSION_focus( int charaindex, int toNo, int array, char *data, int skill_level ) +{ + if(toNo>19) + toNo=0; + profession_common_fun( charaindex, toNo, skill_level, array, BATTLE_COM_S_FOCUS ); + return TRUE; +} + +// ʿ-ܻ +int PROFESSION_shield_attack( int charaindex, int toNo, int array, char *data, int skill_level ) +{ + if(toNo>19) + toNo=0; + profession_common_fun( charaindex, toNo, skill_level, array, BATTLE_COM_S_SHIELD_ATTACK ); + return TRUE; +} + +// ʿ- +int PROFESSION_dual_weapon( int charaindex, int toNo, int array, char *data, int skill_level ) +{ + return TRUE; +} + +// ʿ- +int PROFESSION_deflect( int charaindex, int toNo, int array, char *data, int skill_level ) +{ + if(toNo>19) + toNo=0; + profession_common_fun( charaindex, toNo, skill_level, array, BATTLE_COM_S_DEFLECT ); + return TRUE; +} + +// ʿ-ᴩ +int PROFESSION_through_attack( int charaindex, int toNo, int array, char *data, int skill_level ) +{ + if(toNo>19) + toNo=0; + profession_common_fun( charaindex, toNo, skill_level, array, BATTLE_COM_S_THROUGH_ATTACK ); + return TRUE; +} + +// ʿ-﹥ +int PROFESSION_cavalry( int charaindex, int toNo, int array, char *data, int skill_level ) +{ + if(toNo>19) + toNo=0; + profession_common_fun( charaindex, toNo, skill_level, array, BATTLE_COM_S_CAVALRY ); + return TRUE; +} + +// ʿ- +int PROFESSION_dead_attack( int charaindex, int toNo, int array, char *data, int skill_level ) +{ + if(toNo>19) + toNo=0; + profession_common_fun( charaindex, toNo, skill_level, array, BATTLE_COM_S_DEAD_ATTACK ); + return TRUE; +} + +// ʿ- +int PROFESSION_convolute( int charaindex, int toNo, int array, char *data, int skill_level ) +{ + if(toNo<21) + toNo=0; + profession_common_fun( charaindex, toNo, skill_level, array, BATTLE_COM_S_CONVOLUTE ); + return TRUE; +} + +// ʿ-ҹ +int PROFESSION_chaos( int charaindex, int toNo, int array, char *data, int skill_level ) +{ + if(toNo>19) + toNo=0; + profession_common_fun( charaindex, toNo, skill_level, array, BATTLE_COM_S_CHAOS ); + return TRUE; +} + +/*----------------------------------------------------------------------*/ + +// ˼- +int PROFESSION_trap( int charaindex, int toNo, int array, char *data, int skill_level ) +{ + if(toNo>19) + toNo=0; + profession_common_fun( charaindex, toNo, skill_level, array, BATTLE_COM_S_TRAP ); + return TRUE; +} + +// ˼-ѱ +int PROFESSION_docile( int charaindex, int toNo, int array, char *data, int skill_level ) +{ + if(toNo>19) + toNo=0; + profession_common_fun( charaindex, toNo, skill_level, array, BATTLE_COM_S_DOCILE ); + return TRUE; +} + +// ˼-ŭ +int PROFESSION_enrage_pet( int charaindex, int toNo, int array, char *data, int skill_level ) +{ + if(toNo>19) + toNo=0; + profession_common_fun( charaindex, toNo, skill_level, array, BATTLE_COM_S_ENRAGE_PET ); + return TRUE; +} + +// ˼-޵ +int PROFESSION_dragnet( int charaindex, int toNo, int array, char *data, int skill_level ) +{ + if(toNo>19) + toNo=0; + profession_common_fun( charaindex, toNo, skill_level, array, BATTLE_COM_S_DRAGNET ); + return TRUE; +} + +// ˼- +int PROFESSION_entwine( int charaindex, int toNo, int array, char *data, int skill_level ) +{ + if(toNo>19) + toNo=0; + profession_common_fun( charaindex, toNo, skill_level, array, BATTLE_COM_S_ENTWINE ); + return TRUE; +} + +// ˼-Ը +int PROFESSION_autarky( int charaindex, int toNo, int array, char *data, int skill_level ) +{ + return TRUE; +} + +// ˼-Ӷ +int PROFESSION_plunder( int charaindex, int toNo, int array, char *data, int skill_level ) +{ + if(toNo>19) + toNo=0; + profession_common_fun( charaindex, toNo, skill_level, array, BATTLE_COM_S_PLUNDER ); + return TRUE; +} + +// ˼- +int PROFESSION_toxin_weapon( int charaindex, int toNo, int array, char *data, int skill_level ) +{ + if(toNo>19) + toNo=0; + profession_common_fun( charaindex, toNo, skill_level, array, BATTLE_COM_S_TOXIN_WEAPON ); + return TRUE; +} + +// ˼- +int PROFESSION_resist_fire( int charaindex, int toNo, int array, char *data, int skill_level ) +{ + if(toNo>19) + toNo=0; + profession_common_fun( charaindex, toNo, skill_level, array, BATTLE_COM_S_RESIST_FIRE ); + return TRUE; +} + +// ˼- +int PROFESSION_resist_ice( int charaindex, int toNo, int array, char *data, int skill_level ) +{ + if(toNo>19) + toNo=0; + profession_common_fun( charaindex, toNo, skill_level, array, BATTLE_COM_S_RESIST_ICE ); + return TRUE; +} + +// ˼-׿ +int PROFESSION_resist_thunder( int charaindex, int toNo, int array, char *data, int skill_level ) +{ + if(toNo>19) + toNo=0; + profession_common_fun( charaindex, toNo, skill_level, array, BATTLE_COM_S_RESIST_THUNDER ); + return TRUE; +} + +#ifdef _PROFESSION_ADDSKILL +// ˼-Ȼ +int PROFESSION_resist_f_i_t( int charaindex, int toNo, int array, char *data, int skill_level ) +{ + if(toNo>19) + toNo=0; + profession_common_fun( charaindex, toNo, skill_level, array, BATTLE_COM_S_RESIST_F_I_T ); + return TRUE; +} +// ˼-Ȼ +int PROFESSION_call_nature( int charaindex, int toNo, int array, char *data, int skill_level ) +{ + if(toNo!=20 && toNo!=21) + toNo=0; + profession_common_fun( charaindex, toNo, skill_level, array, BATTLE_COM_S_CALL_NATURE ); + return TRUE; +} +// ˼-Խ +int PROFESSION_boundary( int charaindex, int toNo, int array, char *data, int skill_level ) +{ + if(toNo!=20 && toNo!=21) + toNo=0; + profession_common_fun( charaindex, toNo, skill_level, array, BATTLE_COM_S_BOUNDARY ); + return TRUE; +} +#endif + +// ˼- +int PROFESSION_g_resist_fire( int charaindex, int toNo, int array, char *data, int skill_level ) +{ + if(toNo!=20 && toNo!=21) + toNo=0; + profession_common_fun( charaindex, toNo, skill_level, array, BATTLE_COM_S_G_RESIST_FIRE ); + return TRUE; +} + +// ˼- +int PROFESSION_g_resist_ice( int charaindex, int toNo, int array, char *data, int skill_level ) +{ + if(toNo!=20 && toNo!=21) + toNo=0; + profession_common_fun( charaindex, toNo, skill_level, array, BATTLE_COM_S_G_RESIST_ICE ); + return TRUE; +} + +// ˼-׿ +int PROFESSION_g_resist_thunder( int charaindex, int toNo, int array, char *data, int skill_level ) +{ + if(toNo!=20 && toNo!=21) + toNo=0; + profession_common_fun( charaindex, toNo, skill_level, array, BATTLE_COM_S_G_RESIST_THUNDER ); + return TRUE; +} + +// ˼-㹥 +int PROFESSION_attack_weak( int charaindex, int toNo, int array, char *data, int skill_level ) +{ + if(toNo>19) + toNo=0; + profession_common_fun( charaindex, toNo, skill_level, array, BATTLE_COM_S_ATTACK_WEAK ); + return TRUE; +} + +// ˼- +int PROFESSION_instigate( int charaindex, int toNo, int array, char *data, int skill_level ) +{ + if(toNo>19) + toNo=0; + profession_common_fun( charaindex, toNo, skill_level, array, BATTLE_COM_S_INSTIGATE ); + return TRUE; +} + +// ˼- +int PROFESSION_oblivion( int charaindex, int toNo, int array, char *data, int skill_level ) +{ + if(toNo>19) + toNo=0; + profession_common_fun( charaindex, toNo, skill_level, array, BATTLE_COM_S_OBLIVION ); + return TRUE; +} + + +/*----------------------------------------------------------------------*/ +// ս + +// ˼-׷Ѱ +int PROFESSION_track( int charaindex, int toNo, int array, char *data, int skill_level ) +{ + char *pszP = NULL, *pszOption = "\0", msg[20]; + int per=0, rate=0, img1, ret = 1; + skill_level /= 10; + + if( CHAR_getWorkInt( charaindex, CHAR_ENCOUNT_NUM) >= (int)time(NULL) ){ + ret = -1; + } + + // ܵIJ + pszOption = PROFESSION_SKILL_getChar( array, PROFESSION_SKILL_OPTION); + + // ܵȼ rate + if( (pszP = strstr( pszOption, "%" ) ) != NULL ) sscanf( pszP+3, "%d", &rate ); + per = skill_level * rate; + + // ׼ڵĶ + img1 = PROFESSION_SKILL_getInt( array, PROFESSION_SKILL_IMG_1 ); + + CHAR_setWorkInt( charaindex, CHAR_ENCOUNT_FIX, per); + CHAR_talkToCli( charaindex, -1, "", CHAR_COLORRED); + CHAR_setWorkInt( charaindex, CHAR_ENCOUNT_NUM, (int)time(NULL) + (60 * 3) ); + + sprintf( msg, "%d", img1); + lssproto_BATTLESKILL_send ( getfdFromCharaIndex(charaindex), msg ) ; + + return ret; +} + +// ˼-رս +int PROFESSION_escape( int charaindex, int toNo, int array, char *data, int skill_level ) +{ + char *pszP = NULL, *pszOption = "\0", msg[20]; + int per=0, rate=0, img1, ret =1; + skill_level /= 10; + + if( CHAR_getWorkInt( charaindex, CHAR_ENCOUNT_NUM) >= (int)time(NULL) ){ + ret = -1; + } + + // ܵIJ + pszOption = PROFESSION_SKILL_getChar( array, PROFESSION_SKILL_OPTION); + + // ܵȼ rate + if( (pszP = strstr( pszOption, "%" ) ) != NULL ) sscanf( pszP+3, "%d", &rate ); + per = skill_level * rate; + + // ׼ڵĶ + img1 = PROFESSION_SKILL_getInt( array, PROFESSION_SKILL_IMG_1 ); + + CHAR_setWorkInt( charaindex, CHAR_ENCOUNT_FIX, (-1) * per); + CHAR_talkToCli( charaindex, -1, "½", CHAR_COLORGREEN); + + CHAR_setWorkInt( charaindex, CHAR_ENCOUNT_NUM, (int)time(NULL) + (60 * 3) ); + + sprintf( msg, "%d", img1); + lssproto_BATTLESKILL_send ( getfdFromCharaIndex(charaindex), msg ) ; + + return ret; +} + + + +// ͬ- +int PROFESSION_full_mp( int charaindex, int toNo, int array, char *data, int skill_level ) +{ + return TRUE; +} +// ͬ- +int PROFESSION_strong_back( int charaindex, int toNo, int array, char *data, int skill_level ) +{ + char *pszP = NULL, *pszOption = "\0"; + int rate=0; + // ܵIJ + pszOption = PROFESSION_SKILL_getChar( array, PROFESSION_SKILL_OPTION); + if( (pszP = strstr( pszOption, "%" ) ) != NULL ) sscanf( pszP+3, "%d", &rate ); + int pile = CHAR_getWorkInt( charaindex, CHAR_WORKATTACHPILE); + pile = pile * rate; + CHAR_setWorkInt( charaindex, CHAR_WORKATTACHPILE,pile); + return TRUE; +} +// ͬ-ǿ +int PROFESSION_strengthen( int charaindex, int toNo, int array, char *data, int skill_level ) +{ + return TRUE; +} + +#endif + diff --git a/battle/stoRkxhg b/battle/stoRkxhg new file mode 100644 index 0000000..7077e13 Binary files /dev/null and b/battle/stoRkxhg differ diff --git a/buf.c b/buf.c new file mode 100644 index 0000000..6a81f8b --- /dev/null +++ b/buf.c @@ -0,0 +1,192 @@ +#define __BUF_C__ +#include "version.h" +#include +#include +#include + +#include "buf.h" +#include "handletime.h" + +static int UNIT; +static int UNITNUMBER; +static int memconfig; +static int readblock; +static int NowMemory; +static struct timeval AllocOldTime; + +typedef struct tagMemory +{ + char* pointer; + BOOL used; + + unsigned int nsize; +}Memory; +static Memory *mem; + + +void memEnd( void ) +{ + if( mem != NULL && mem[0].pointer != NULL ){ + free(mem[0].pointer); + free(mem); + } +} + +BOOL configmem( int unit , int unitnumber ) +{ + if( memconfig == TRUE ) + return FALSE; + UNIT = unit; + UNITNUMBER = unitnumber; + if( UNIT <= 0 || UNITNUMBER <= 0 ) + return memconfig = FALSE; + return memconfig = TRUE; +} + +BOOL memInit( void ) +{ + int i; + if( memconfig == FALSE ) + return FALSE; + mem = calloc( 1, sizeof( Memory ) * UNITNUMBER ); + if( mem == NULL ){ + print( "memInit: Can't alloc memory: %d\n" , + sizeof(Memory)*UNITNUMBER ); + return FALSE; + } + + memset( mem , 0 , sizeof( Memory )* UNITNUMBER ); + for( i = 0 ; i < UNITNUMBER ; i ++ ){ + mem[i].pointer = NULL; + mem[i].used = FALSE; + mem[i].nsize = 0; + } + mem[0].pointer = calloc( 1, UNIT*UNITNUMBER ); + if( mem[0].pointer == NULL ){ + print( "ɷ %d byte\n" , UNIT*UNITNUMBER ); + free( mem ); + return FALSE; + } + memset( mem[0].pointer , 0 , sizeof( UNIT*UNITNUMBER )); + print( "ڴѷ %.2f MB..." ,UNIT*UNITNUMBER/1024.0/1024.0); +#ifdef DEBUG + print( "Allocate %d byte( %.2fK byte %.2fM byte )\n" , + UNIT*UNITNUMBER, + UNIT*UNITNUMBER/1024.0, + UNIT*UNITNUMBER/1024.0/1024.0 + ); +#endif + readblock = 0; + for( i = 0 ; i < UNITNUMBER ; i ++ ) + mem[i].pointer = mem[0].pointer + i * UNIT; + + NowMemory = 0; + AllocOldTime.tv_sec = NowTime.tv_sec; + AllocOldTime.tv_usec = NowTime.tv_usec; + + return TRUE; +} + +void* allocateMemory( const unsigned int nbyte ) +{ + int i; + int arrayAllocSize; + BOOL flg = FALSE; + void *ret; + int first = 0; + + arrayAllocSize = nbyte/UNIT + ( nbyte%UNIT ? 1 : 0 ); + if( arrayAllocSize == 0 )return NULL; +#ifdef DEBUG + debug( arrayAllocSize , d ); + printf("(%.2f KB)\n",nbyte/1024.0); +#endif + i = readblock; + while( 1 ) { + if( i > UNITNUMBER - arrayAllocSize) { + i = 0; + } + if( mem[i].used != FALSE ){ + i += mem[i].nsize; + }else{ + int j; + BOOL found = TRUE; + for( j = i; j < i + arrayAllocSize; j ++ ) { + if( mem[j].used != FALSE ){ + i = j + mem[j].nsize; + found = FALSE; + if( first == 0 ) first = 1; + break; + } + } + if( found ) { + mem[i].used=TRUE; + mem[i].nsize = arrayAllocSize; + readblock = i + arrayAllocSize; + ret = mem[i].pointer; + break; + } + } + if( ( i >= readblock || i > UNITNUMBER - arrayAllocSize ) + && flg == TRUE ) { + ret = NULL; + break; + } + if( i > UNITNUMBER - arrayAllocSize) { + i = 0; + flg = TRUE; + } + + } + if( ret == NULL ) { + print( "Can't Allocate %d byte .remnants:%4.2f\n" , nbyte, (float)(NowMemory/UNITNUMBER)); + }else { + NowMemory += arrayAllocSize; + + if( NowTime.tv_sec > AllocOldTime.tv_sec +10 ) { + print( "\n"); + if( NowMemory > (double)UNITNUMBER * 0.9) { + print( "Warning!! Memory use rate exceeded 90%% .remnants:%d\n", UNITNUMBER-NowMemory); + }else if( NowMemory > (double)UNITNUMBER * 0.8) { + print( "Warning!! Memory use rate exceeded 80%% .remnants:%d\n", UNITNUMBER-NowMemory); + }else if( NowMemory > (double)UNITNUMBER * 0.7) { + print( "Memory use rate exceeded 70%% .remnants:%d\n", UNITNUMBER-NowMemory); + } + memcpy( &AllocOldTime, &NowTime, sizeof( AllocOldTime)); + } + //print( "NowMemory.remnants:%4.2f\n", (float)(UNITNUMBER-NowMemory)/UNITNUMBER); + } + + return ret; +} + + + +/*------------------------------------------------------------ + * ¦ + * ߯Ի + * ئ + ------------------------------------------------------------*/ +void freeMemory( void* freepointer ) +{ + int arrayindex; + char* toppointer; + toppointer = mem[0].pointer; + if( freepointer == NULL )return; + arrayindex = ((int)freepointer-(int)toppointer)/UNIT; + if( arrayindex < readblock) { + readblock = arrayindex; + } + mem[arrayindex].used = FALSE; + + NowMemory -= mem[arrayindex].nsize; + +} + +void showMem( char *buf) +{ + sprintf( buf, "NowMemory.remnants:%d%%", ((UNITNUMBER-NowMemory)*100)/UNITNUMBER); + printf( "\n" ); + printf( buf ); +} + diff --git a/callfromac.c b/callfromac.c new file mode 100644 index 0000000..e64968c --- /dev/null +++ b/callfromac.c @@ -0,0 +1,1676 @@ +#include +#include "version.h" +#include "common.h" +#include "saacproto_cli.h" +#include "lssproto_serv.h" +#include "net.h" +#include "char.h" +#include "object.h" +#include "readmap.h" +#include "msignal.h" +#include "map_deal.h" +#include "npc_duelranking.h" +#include "npc_warpman.h" +#include "handletime.h" +#include "npc_scheduleman.h" +#include "configfile.h" +#include "chatroom.h" +#include "npc_eventaction.h" +// CoolFish: Family 2001/5/24 +#include "family.h" +#include "log.h" +#include "buf.h" +#ifdef _ALLDOMAN // (ɿ) Syu ADD аNPC +#include "npc_alldoman.h" +#endif +#include "enemy.h" +time_t initTime =0; + +extern BOOL bNewServer; +extern int i_shutdown_time;//ttom +extern int manorflag[10]; +extern char manorname[10][32]; +#ifdef _ANGEL_SUMMON +extern struct MissionInfo missionlist[MAXMISSION]; +extern struct MissionTable missiontable[MAXMISSIONTABLE]; +#endif + +char question[64]; +char answer[64]; +int questionstarttime=0; +int questionman=0; +#ifdef _ALL_ITEM +int allnum1=0; +int allnum2=0; +int allnum3=0; +int allnum4=0; +int allnum5=0; +#endif + +void saacproto_ACGmsvDownRequest_recv( int fd, int min) +{ + char buff[32]; + int i; + int playernum = CHAR_getPlayerMaxNum(); + + snprintf( buff, sizeof( buff),"%s档",getGameserverID()); + for( i = 0 ; i < playernum ; i++) { + if( CHAR_getCharUse(i) != FALSE ) { + CHAR_talkToCli( i, -1, buff, CHAR_COLORYELLOW); + } + } + SERVSTATE_setLimittime(min); + SERVSTATE_setShutdown( NowTime.tv_sec ); + SERVSTATE_setDsptime( 0 ); + +} +//Ƿкac,Լ +void saacproto_ACServerLogin_recv (int fd, char* result,char* data) +{ + if( strcmp( result , SUCCESSFUL ) != 0 ){ + print( "ACʧ!˳...[%s][%s]\n", + result,data ); + shutdownProgram( ); + exit(1); + } + print("ACӳɹ\n"); + time(&initTime); +/* + print("ͣ"); + if( bNewServer ) + print("·! \n"); + else + print("ɷ! \n"); +*/ +#ifdef _SERVER_NUMS + print(" !\n\n"); +#endif + + printf( "GMSV汾: <%s %s>\n" , SERVER_VERSION, "Ѱ"); + printf( "GMSVʱ: %s %s \n" , __DATE__ , __TIME__ ); + + printf( "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" ); + printf( "~ ~\n" ); + printf( "~ ~\n" ); + printf( "~ ΪѷˡϽҵ;,ɵĺге ~\n" ); + printf( "~ ~\n" ); + printf( "~ ~\n" ); + printf( "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" ); + // Robin 0530 + //saacproto_ACShowFMList_send( acfd ); + print("\nʼ..."); + FAMILY_Init(); + print("\n"); +#ifdef _ANGEL_SUMMON + print("ʼٻ..."); + saacproto_ACMissionTable_send( acfd, -1, 1, "", ""); + print("\n"); + + +#endif +} + +void saacproto_ACCharList_recv(int fd, char* result, char* data,int retfd) +{ + int clifd = getfdFromFdid(retfd); + + if( CONNECT_checkfd(clifd) == FALSE ) + return; + + lssproto_CharList_send( clifd, result , data ); + CONNECT_setState( clifd, NOTLOGIN ); +} + +void saacproto_ACCharLoad_recv(int fd , char* result,char* data,int retfd,int saveindex) +{ + int clifd = getfdFromFdid(retfd); + if( CONNECT_checkfd( clifd ) == FALSE )return; + if(( strcmp( result , SUCCESSFUL ) == 0 )&&(data[0])) { + CHAR_login( clifd,data,saveindex ); + }else{ + char cdkey[64]; +#ifndef _FIX_MESSAGE // WON ADD ޸WORKER + data = ""; +#endif + CONNECT_getCdkey( clifd, cdkey , sizeof( cdkey )); + print(" (%s)ACCharLoad:%s ", cdkey, data); + lssproto_CharLogin_send( clifd, result ,data ); + CONNECT_setState( clifd, NOTLOGIN ); + } +} + +void saacproto_ACCharSave_recv(int fd ,char* result, char* data,int retfd) +{ + int clifd = getfdFromFdid(retfd) , fdid; + char cdkey[CDKEYLEN], passwd[PASSWDLEN], charname[CHARNAMELEN]; + + if( CONNECT_checkfd( clifd )== FALSE ) return; + + CONNECT_getCdkey( clifd, cdkey, sizeof( cdkey )); + CONNECT_getPasswd( clifd, passwd, sizeof( passwd)); + + CONNECT_getCharname( clifd, charname, sizeof( charname )); + fdid = CONNECT_getFdid( clifd ); + unsigned long ip; + int a,b,c,d; + switch( CONNECT_getState( clifd ) ){ + case WHILECREATE: + /* ľëͷʧе( )*/ + if( strcmp(result,FAILED) ==0 ) data =""; + lssproto_CreateNewChar_send( clifd , result , data); + CONNECT_setState( clifd, NOTLOGIN ); + break; + + case WHILELOGOUTSAVE: + if( strcmp( result , SUCCESSFUL ) == 0 ) + lssproto_CharLogout_send( clifd, result , "success" ); + else + /* ޷¡֧ */ + lssproto_CharLogout_send( clifd, result , "Cannot save" ); + CONNECT_setState( clifd, NOTLOGIN ); + CONNECT_setCharaindex( clifd, -1 ); + break; + + case WHILELOSTCHARSAVE: + ip=CONNECT_get_userip(clifd); + + a=(ip % 0x100); ip=ip / 0x100; + b=(ip % 0x100); ip=ip / 0x100; + c=(ip % 0x100); ip=ip / 0x100; + d=(ip % 0x100); + char userip[32]; + sprintf(userip,"%d.%d.%d.%d",a,b,c,d); + saacproto_ACCharDelete_send( acfd, cdkey,passwd,charname,"",fdid,userip ); + CONNECT_setState( clifd, WHILELOSTCHARDELETE ); + CONNECT_setCharaindex( clifd, -1 ); + break; + + case WHILECLOSEALLSOCKETSSAVE: + CONNECT_setState( clifd, NOTLOGIN ); + // Arminius debug + // CONNECT_endOne_debug(clifd); + CONNECT_setUse( clifd , FALSE); + + SERVSTATE_decrementCloseallsocketnum(); + if( SERVSTATE_getCloseallsocketnum() == 0 ) { + SERVSTATE_SetAcceptMore( -1 ); + print( "浵\n" ); + print("\n رշʱ =%d",i_shutdown_time);//ttom + if(i_shutdown_time==1){ + system( "ر" ); + sigshutdown( 0 ); + } + } + default: + break; + } +} + + +void saacproto_ACCharDelete_recv(int fd,char* result,char* data,int retfd) +{ + int clifd = getfdFromFdid(retfd); + if( CONNECT_checkfd( clifd ) == FALSE )return; + + switch( CONNECT_getState(clifd) ){ + case WHILELOSTCHARDELETE: + /* ئ */ + CONNECT_setState(clifd, NOTLOGIN ); + CONNECT_setCharaindex( clifd, -1 ); + break; + case WHILECHARDELETE: + /* ˪ */ + if( strcmp(result,FAILED) == 0)data=""; + lssproto_CharDelete_send( clifd, result , data ); + CONNECT_setState( clifd, NOTLOGIN ); + CONNECT_setCharaindex( clifd, -1 ); + break; + default: + break; + } +} + +/* + */ +void saacproto_ACLock_recv(int fd , char* result, char* data ,int retfd) +{ + int clifd = getfdFromFdid(retfd); + char cdkey[CDKEYLEN]; + int cindex = getCharindexFromFdid(retfd); + + if( CONNECT_checkfd(clifd) == FALSE) return; + + // Arminius 7.25 GM unlock test + if (strncmp(data, "USRLOCKED", 9)==0) { + char buf[4096]; + sprintf(buf, "%s", &data[10]); + CHAR_talkToCli(cindex, -1, buf, CHAR_COLORYELLOW); + return; + } else if (strncmp(data, "USRUNLOCKED", 11)==0) { + CHAR_talkToCli(cindex, -1, "User not locked.", CHAR_COLORYELLOW); + return; + } else if (strncmp(data, "GMUNLOCKSUCCESS", 15)==0) { + CHAR_talkToCli(cindex, -1, "User unlock success", CHAR_COLORYELLOW); + return; + } else if (strncmp(data, "GMUNLOCKFAIL", 12)==0) { + CHAR_talkToCli(cindex, -1, "User unlock failed", CHAR_COLORYELLOW); + return; + } else if (strncmp(data, "GMUNLOCKALL", 11)==0) { + CHAR_talkToCli(cindex, -1, "Server unlocked", CHAR_COLORYELLOW); + return; + } + + CONNECT_getCdkey( clifd, cdkey , sizeof( cdkey )); + + switch( CONNECT_getState( clifd ) ){ + case WHILECANNOTLOGIN: + if( strcmp( result , SUCCESSFUL ) == 0 ){ + CONNECT_setState( clifd, NOTLOGIN ); + + }else{ + /* + * ëέ + */ + char mesg[128]; + snprintf( mesg ,sizeof( mesg ), "%s hasn't been locked" ,cdkey); + if( strcmp( data , mesg ) == 0 ){ + /* + */ + CONNECT_setState( clifd, NOTLOGIN ); + }else{ + /* + * պݩƷ + */ + saacproto_ACLock_send(fd, cdkey , + UNLOCK, CONNECT_getFdid( clifd) ); + } + } + + break; + default: + break; + } +} + +void saacproto_ACUCheck_recv( int fd , char *cd ) +{ + int conind; + int flag = 0; + conind = getfdFromCdkeyWithLogin( cd ); + flag = ( conind >= 0 ) ? 1 : 0; + saacproto_ACUCheck_send( fd , cd , flag ); +} + + +/* --------------------------------------------- + * --------------------------------------------*/ +void saacproto_DBUpdateEntryInt_recv( int fd,char* result, + char* table,char* key,int msgid,int msgid2 ) +{ + if( strcmp( result, NET_STRING_FAILED) == 0 ) { + print( "failed: DBUpdateEntryInt\n"); + return; + } +} +/* --------------------------------------------- + * --------------------------------------------*/ +void saacproto_DBUpdateEntryString_recv( int fd,char* result, + char* table,char* key,int msgid,int msgid2 ) +{ + if( strcmp( result, NET_STRING_FAILED) == 0 ) { + print( "failed: DBUpdateEntryString\n"); + return; + } +} + +/* --------------------------------------------- + * --------------------------------------------*/ +void saacproto_DBGetEntryRank_recv( int fd,char* result,int rank,int count, + char* table,char* key,int msgid,int msgid2 ) +{ + if( strcmp( result, NET_STRING_FAILED) == 0 ) { + print( "failed: DBGetEntryRank\n"); + return; + } + if( strcmp( table, DB_DUELPOINT) == 0 ) { + if( CHAR_getInt( OBJECT_getIndex( msgid2), CHAR_WHICHTYPE) == CHAR_TYPEDUELRANKING){ + NPC_Duelranking_CallMyRanking( count, msgid, msgid2); + }else { + NPC_GetDuelRank( rank, msgid, msgid2); + } + } +} + +void saacproto_DBDeleteEntryInt_recv( int fd,char* result, + char* table,char* key,int msgid,int msgid2 ) +{ + if( strcmp( result, NET_STRING_FAILED) == 0 ) { + print( "failed: DBDeleteEntryInt\n"); + return; + } + +} +/* --------------------------------------------- + * --------------------------------------------*/ +void saacproto_DBDeleteEntryString_recv( int fd,char* result, + char* table,char* key,int msgid,int msgid2 ) +{ + if( strcmp( result, NET_STRING_FAILED) == 0 ) { + print( "failed: DBDeleteEntryString\n"); + return; + } + +} + + +/* --------------------------------------------- + * --------------------------------------------*/ +void saacproto_DBGetEntryInt_recv( int fd,char* result,int value, + char* table,char* key,int msgid,int msgid2 ) +{ + if( strcmp( result, NET_STRING_FAILED) == 0 ) { + print( "failed: DBGetEntryInt\n"); + return; + } +} +/* --------------------------------------------- + * --------------------------------------------*/ +void saacproto_DBGetEntryString_recv( int fd,char* result,char *value, + char* table,char* key,int msgid,int msgid2 ) +{ + char cdkey[32]; + char charaname[32]; + + if( strcmp( table, DB_ADDRESSBOOK) == 0 ){ + int mode = 1; + if( strcmp( result, NET_STRING_FAILED) == 0 ) { + mode = 0; + } + makeStringFromEscaped( key); + if( !getStringFromIndexWithDelim( key, "_", 1, cdkey, sizeof( cdkey)) ){ + return; + } + if( !getStringFromIndexWithDelim( key, "_", 2, charaname, sizeof( charaname)) ){ + return; + } + ADDRESSBOOK_DispatchMessage( cdkey, charaname, value, mode); + }else { + if( strcmp( result, NET_STRING_FAILED) == 0 ) { + print( "failed: DBGetEntryString\n"); + return; + } + } +} + +void saacproto_DBGetEntryByRank_recv( int fd,char* result,char* list, + char* table,int msgid,int msgid2 ) +{ + if( strcmp( result, NET_STRING_FAILED) == 0 ) { + print( "failed: DBGetEntryByRank\n"); + return; + } +} +/* --------------------------------------------- + * --------------------------------------------*/ +void saacproto_DBGetEntryByCount_recv( int fd,char* result,char* list, + char* table,int count_start,int msgid,int msgid2 ) +{ + if( strcmp( result, NET_STRING_FAILED) == 0 ) { + print( "failed: DBGetEntryByCount\n"); + return; + } + if( strcmp( table, DB_DUELPOINT) == 0 ) { + NPC_Duelranking_PrintRanking( list, count_start, msgid, msgid2); + } +} +#ifdef _ALLDOMAN // (ɿ) Syu ADD аNPC +void saacproto_UpdataStele_recv( int fd , char *token) +{ + NPC_AlldomanWriteStele( token ); +} +void saacproto_S_UpdataStele_recv( int i , char *ocdkey , char *oname , char *ncdkey , + char *nname , char *title , int level , int trns , int floor ) +{ + print("\nSyu log յSingle=> %s , %s , %s , %s ",ocdkey , oname , ncdkey , nname); + NPC_Alldoman_S_WriteStele( ocdkey , oname , ncdkey , nname , title , level , trns , floor ) ; +} + +#endif +/* --------------------------------------------- + * ƤƽҵⰾԻ + * --------------------------------------------*/ +void saacproto_Broadcast_recv( int fd,char* id,char* charname,char *message ) +{ + if( strstr( message, "online") == 0 || + strstr( message, "offline") == 0 || + strstr( message, "param") == 0 || + strstr( message, "chardelete") == 0 ){ + char buff[512]; + char escapebuf[1024]; + + snprintf( buff, sizeof( buff),"%s_%s", id, charname ); + makeEscapeString( buff, escapebuf, sizeof(escapebuf)); + + saacproto_DBGetEntryString_send( acfd, DB_ADDRESSBOOK, escapebuf, 0,0); + } +} + +void saacproto_Message_recv( int fd,char* id_from,char* charname_from, + char* id_to,char* charname_to, + char* message,int option,int mesgid ) +{ + BOOL ret; + ret = ADDRESSBOOK_sendMessage_FromOther( id_from, charname_from, + id_to, charname_to, + message, option + ); + if( ret == TRUE) { + saacproto_MessageAck_send( acfd, id_to, charname_to, + "successful",mesgid); + } +} + +/* --------------------------------------------- + * CoolFish: Family 2001/5/9 + * --------------------------------------------*/ +void saacproto_ACAddFM_recv(int fd, char *result, int fmindex, int charfdid, + int index) +{ + int ret; + int clifd = getfdFromFdid(charfdid); +// print("ACAddFM_0\n"); + if (CONNECT_checkfd(clifd) == FALSE) return; + if (strcmp(result, SUCCESSFUL) == 0) ret = 1; + else ret = 0; +// print("ACAddFM_1 clifd:%d ret:%d fmindex:%d index:%d\n", +// clifd, ret, fmindex, index); + ACAddFM(clifd, ret, fmindex, index); +} +void saacproto_ACJoinFM_recv(int fd, char *result, int recv, int charfdid) +{ + int ret; + int clifd = getfdFromFdid(charfdid); + if (CONNECT_checkfd(clifd) == FALSE) return; + if (strcmp(result, SUCCESSFUL) == 0) ret = 1; + else ret = 0; + ACJoinFM(clifd, ret, recv); +} +void saacproto_ACLeaveFM_recv(int fd, char *result, int resultflag, int charfdid) +{ + int ret; + int clifd = getfdFromFdid(charfdid); + if (CONNECT_checkfd(clifd) == FALSE) return; + if (strcmp(result, SUCCESSFUL) == 0) ret = 1; + else ret = 0; + ACLeaveFM(clifd, ret, resultflag); + + print(" ACLeaveFM_%d ", ret ); +} +void saacproto_ACChangeFM_recv(int fd, char *result, int charfdid) +{ +} +void saacproto_ACDelFM_recv(int fd, char *result, int charfdid) +{ + int ret; + int clifd = getfdFromFdid(charfdid); + if (CONNECT_checkfd(clifd) == FALSE) return; + if (strcmp(result, SUCCESSFUL) == 0) ret = 1; + else ret = 0; + + ACDelFM(clifd, ret); + + print(" ACDelFM_%d ", ret); +} +void saacproto_ACShowFMList_recv(int fd, char *result, int fmnum, char *data) +{ + int ret; + if (strcmp(result, SUCCESSFUL) == 0) ret = 1; + else ret = 0; + ACShowFMList(ret, fmnum, data); +} + +void saacproto_ACShowMemberList_recv(int fd, char *result, int index, int fmmemnum, + int fmacceptflag, int fmjoinnum, char *data) +{ + int ret; + // fmmemnum -1:޴ֵ, -2:޸ else:ʾ˼ + if (strcmp(result, SUCCESSFUL) == 0) ret = 1; + else ret = 0; + ACShowMemberList(ret, index, fmmemnum, fmacceptflag, fmjoinnum, data); +} +void saacproto_ACFMDetail_recv(int fd, char *result, char *data, int charfdid) +{ + int ret; + int clifd = getfdFromFdid(charfdid); + if (CONNECT_checkfd(clifd) == FALSE) return; + if (strcmp(result, SUCCESSFUL) == 0) ret = 1; + else ret = 0; + ACFMDetail(ret, data, clifd ); +} +void saacproto_ACMemberJoinFM_recv(int fd, char *result, char *data, int charfdid) +{ + +} +void saacproto_ACMemberLeaveFM_recv(int fd, char *result, char *data, int charfdid) +{ + +} +#ifdef _PERSONAL_FAME // Arminius: +void saacproto_ACFMCharLogin_recv(int fd, char *result, int index, int floor, + int fmdp, int joinflag, int fmsetupflag, int flag, int charindex, + int charfame, int charfdid +#ifdef _NEW_MANOR_LAW + ,int momentum +#endif + ) +#else +void saacproto_ACFMCharLogin_recv(int fd, char *result, int index, int floor, + int fmdp, int joinflag, int fmsetupflag, int flag, int charindex, + int charfdid) +#endif +{ + int ret; + int clifd = getfdFromFdid(charfdid); + if (CONNECT_checkfd(clifd) == FALSE) return; + if (strcmp(result, SUCCESSFUL) == 0) ret = 1; + else ret = 0; +// print("Login fd:%d result:%s index:%d floor:%d fmdp:%d joinflag:%d setup:%d charfdid:%d\n", +// fd, result, index, floor, fmdp, joinflag, fmsetupflag, charfdid); +#ifdef _PERSONAL_FAME // Arminius: +// print("Login charfame:%d\n", charfame); + ACFMCharLogin(clifd, ret, index, floor, fmdp, joinflag, fmsetupflag, + flag, charindex, charfame + #ifdef _NEW_MANOR_LAW + ,momentum + #endif + ); +#else + ACFMCharLogin(clifd, ret, index, floor, fmdp, joinflag, fmsetupflag, + flag, charindex); +#endif +} +void saacproto_ACFMCharLogout_recv(int fd, char *result, int charfdid) +{ +} +void saacproto_ACFMReadMemo_recv(int fd, char *result, int index, int num, + int dataindex, char *data) +{ + int ret; + // index( WORK )num(ϱ35) + // dataindex(µ)data() + // עnum -1:޴ֵ, -2:޸ else:ʾ˼ + if (strcmp(result, SUCCESSFUL) == 0) ret = 1; + else ret = 0; + ACShowFMMemo(ret, index, num, dataindex, data); +} +void saacproto_ACFMWriteMemo_recv(int fd, char *result, int index) +{ +} +void saacproto_ACFMPointList_recv(int fd, char *result, char *data) +{ + int ret; + if (strcmp(result, SUCCESSFUL) == 0) ret = 1; + else ret = 0; + ACShowPointList(ret, data); +} + + +void saacproto_ACSetFMPoint_recv(int fd, char *result, int r, int charfdid) +{ + int ret; + int clifd = getfdFromFdid(charfdid); + if( CONNECT_checkfd(clifd) == FALSE )return; + if (strcmp(result, SUCCESSFUL) == 0){ + ret = 1; + }else{ + ret = 0; + } + ACSetFMPoint(ret, r, clifd); + +} +void saacproto_ACFixFMPoint_recv(int fd, char *result, int r) +{ +} +void saacproto_ACFMAnnounce_recv(int fd, char *result, char *fmname, + int fmindex, int index, int kindflag, char *data, int color) +{ + int ret; + if (strcmp(result, SUCCESSFUL) == 0){ + ret = 1; + }else{ + ret = 0; + } + ACFMAnnounce(ret, fmname, fmindex, index, kindflag, data, color); +} +#ifdef _NEW_MANOR_LAW +extern void SortManorSchedule(); +#endif +void saacproto_ACShowTopFMList_recv(int fd, char *result, int kindflag, int num, char *data) +{ + int ret; + if (strcmp(result, SUCCESSFUL) == 0) ret = 1; + else ret = 0; + ACShowDpTop(ret, num, data, kindflag); +#ifdef _NEW_MANOR_LAW + SortManorSchedule(); +#endif +} +#ifdef _NEW_MANOR_LAW +extern struct FMS_DPTOP fmdptop; +#endif +void saacproto_ACFixFMData_recv(int fd, char *result, int kindflag, char *data1, + char *data2, int charfdid) +{ + int ret; + int intdata; + int clifd = getfdFromFdid(charfdid); + int charaindex = CONNECT_getCharaindex( clifd ); + if( CONNECT_checkfd(clifd) == FALSE )return; + + if (strcmp(result, SUCCESSFUL) == 0) ret = 1; + else ret = 0; + + if( !CHAR_CHECKINDEX(charaindex) ) return; + if( kindflag == FM_FIX_FMRULE ){ + CHAR_talkToCli( charaindex , -1, "ּ޸ģϣˣ", CHAR_COLORWHITE); + }else if( kindflag == FM_FIX_FMGOLD ) { + intdata = atoi( data1 ); + if( ret == 0 ) { + if( atoi(data1) > 0 ) { + CHAR_setInt( charaindex, CHAR_GOLD, CHAR_getInt( charaindex, CHAR_GOLD ) +atoi(data1) ); + } + CHAR_send_P_StatusString( charaindex , CHAR_P_STRING_GOLD); + return; + }else { + if( atoi(data1) < 0 ) { + CHAR_setInt( charaindex, CHAR_GOLD, CHAR_getInt( charaindex, CHAR_GOLD ) -atoi(data1) ); + CHAR_send_P_StatusString( charaindex , CHAR_P_STRING_GOLD); + } + LogStone( + atoi(data2), + CHAR_getChar( charaindex, CHAR_NAME ), + CHAR_getChar( charaindex, CHAR_CDKEY ), + -intdata, + CHAR_getInt( charaindex, CHAR_GOLD ), + "FMBank()", + CHAR_getInt( charaindex,CHAR_FLOOR), + CHAR_getInt( charaindex,CHAR_X ), + CHAR_getInt( charaindex,CHAR_Y ) + ); + } + }else if( kindflag == FM_FIX_FMLEADERCHANGE ){ + ACFMJob( clifd, ret, data1, data2 ); + } + // CoolFish: 2001/10/03 + else if (kindflag == FM_FIX_FMADV || kindflag == FM_FIX_FMFEED + || kindflag == FM_FIX_FMSYNTHESIZE || kindflag == FM_FIX_FMDEALFOOD) + { + char tmpbuf[1024], flag[128]; +#ifdef _NEW_MANOR_LAW + int i; +#endif + if (kindflag == FM_FIX_FMADV) strcpy(flag, "ADV"); + else if (kindflag == FM_FIX_FMFEED) strcpy(flag, "FEED"); + else if (kindflag == FM_FIX_FMSYNTHESIZE) strcpy(flag, "SYN"); + else if (kindflag == FM_FIX_FMDEALFOOD) strcpy(flag, "FOOD"); + sprintf(tmpbuf, "%s::%d %s %s", flag, + CHAR_getInt(charaindex, CHAR_FMINDEX), + CHAR_getChar(charaindex, CHAR_FMNAME), data1); + // print("ACFixFMData tmpbuf:%s\n", tmpbuf); + LogFMPOP(tmpbuf); +#ifdef _NEW_MANOR_LAW + for(i=0;i= FAMILY_MAXNUM ){ + print(" fmindex:%d if FALSE !!\n", fmindex); + return; + } + familyTax[ fmindex] = data; + sprintf( buf, "B|T|%d", data ); + lssproto_FM_send( clifd, buf ); + } + +} +void saacproto_ACFMClearPK_recv(int fd, char *result, char *fmname, int fmindex, + int index) +{ + int ret, i = 0; + + if (strcmp(result, SUCCESSFUL) == 0) ret = 1; + else ret = 0; + for (i = 0; i < MAX_SCHEDULEMAN * MAX_SCHEDULE; i++) + { + { + if (fmpks[i].flag == -1) continue; + if (fmpks[i].host_index == index + || fmpks[i].guest_index == index) + { + fmpks[i].host_index = -1; + strcpy(fmpks[i].host_name, ""); + fmpks[i].guest_index = -1; + strcpy(fmpks[i].guest_name, ""); + fmpks[i].prepare_time = -1; + fmpks[i].max_player = -1; + fmpks[i].win = -1; + fmpks[i].flag = -1; + } + } + } +} + +#ifdef _ACFMPK_LIST +void saacproto_ACSendFmPk_recv( int fd, int toindex, int flg) +{ + char buf[256]; + if( flg == 0){ + sprintf( buf, "ׯ԰ս¼ʧܣ"); + CHAR_talkToCli( toindex, -1, buf, CHAR_COLORRED); + }else{ + sprintf( buf, "ׯ԰ս¼ȷOKú׼"); + CHAR_talkToCli( toindex, -1, buf, CHAR_COLORYELLOW); + } +} + +void saacproto_ACLoadFmPk_recv(int fd, char *data) +{ + char buf[10], fm_pk_data[128]; + char token[256], skip[256]; + int fm_pk_num , fmpks_pos=-1; + easyGetTokenFromString( data , 1 , buf , sizeof(buf)); + fm_pk_num = atoi(buf); + sprintf(fm_pk_data , "%s", data+2 ); + if( ((fmpks_pos=fm_pk_num*MAX_SCHEDULE)== -1) || (fm_pk_num > FMPOINTNUM) ){ + print("\n err fm_pk_num(%d)", fm_pk_num ); + return; + } + // ʱ + if (getStringFromIndexWithDelim(data,"|",2,token,sizeof(token))) { + fmpks[fmpks_pos+1].dueltime=atoi(token); + } + // familyindex + if (getStringFromIndexWithDelim(data,"|",3,token,sizeof(token))) { + fmpks[fmpks_pos+1].host_index=atoi(token); + } + // + if (getStringFromIndexWithDelim(data,"|",4,token,sizeof(token))) { + strcpy(fmpks[fmpks_pos+1].host_name,makeStringFromEscaped(token)); + } + // Ͷ familyindex + if (getStringFromIndexWithDelim(data,"|",5,token,sizeof(token))) { + fmpks[fmpks_pos+1].guest_index=atoi(token); + } + // Ͷ + if (getStringFromIndexWithDelim(data,"|",6,token,sizeof(token))) { + strcpy(fmpks[fmpks_pos+1].guest_name,makeStringFromEscaped(token)); + } + // ׼ʱ + if (getStringFromIndexWithDelim(data,"|",7,token,sizeof(token))) { + fmpks[fmpks_pos+1].prepare_time=atoi(token); + } + // + if (getStringFromIndexWithDelim(data,"|",8,token,sizeof(token))) { + int maxnum = atoi( token); +#ifdef _FMWAR_PLAYERNUM + if( maxnum < getFmWarPlayerNum() ) maxnum = getFmWarPlayerNum(); +#else + if( maxnum < 50 ) maxnum = 50; +#endif + fmpks[fmpks_pos+1].max_player = maxnum; + } + // + if (getStringFromIndexWithDelim(data,"|",9,token,sizeof(token))) { + fmpks[fmpks_pos+1].flag=atoi(token); + } + if( fmpks[fmpks_pos+1].flag == FMPKS_FLAG_MANOR_OTHERPLANET ){ + // ս + if (getStringFromIndexWithDelim(data,"|",10,token,sizeof(token))) { + strcpy(fmpks[fmpks_pos+2].host_name,makeStringFromEscaped(token)); + strcpy(skip, makeStringFromEscaped(token)); + if (strcmp(getGameserverID(), skip)==0) { + fmpks[fmpks_pos+1].flag=8; + }else if( fmpks[fmpks_pos+1].flag == 8) { + fmpks[fmpks_pos+1].flag=10; + } + } + }else{ + strcpy( fmpks[fmpks_pos+2].host_name, ""); + } +} +#endif + + +void saacproto_ACManorPKAck_recv(int fd, char *data) +{ + // server ׯ԰ pk scheduleman + int i; + char token[256], skip[256]; + int char_max=CHAR_getCharNum(); + + print("ACManorPKAck_recv: %s\n",data); + + for (i=0; iindexOfExistDepotItems = allocateMemory( sizeof( int ) * CHAR_MAXDEPOTITEMHAVE ); + if( ch->indexOfExistDepotItems == NULL ) return; + for( i=0; iindexOfExistDepotItems[i] = -1; + + if( CHAR_makeDepotItemStringToChar( charaindex, data) == FALSE ){ + CHAR_talkToCli( charaindex, -1, "ֿ߲϶ȡʧܣ", CHAR_COLORYELLOW); + CHAR_removeDepotItem( charaindex); + return; + } + if( !CHAR_CHECKINDEX( meindex) ) return; + if( clifd != -1 ) { + char message[1024]; + char buf[1024]; + strcpy( message, + "3\n\n" + " ʹõֿ߲\n\n" + " ŵߣ\n" + " ȡصߣ\n" + ); + lssproto_WN_send( clifd, WINDOW_MESSAGETYPE_SELECT, + WINDOW_BUTTONTYPE_CANCEL, + 311, //CHAR_WINDOWTYPE_DEPOTITEMSHOP_HANDLE, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + makeEscapeString( message, buf, sizeof(buf)) ); + } + +} + +#endif// + + +#ifdef _CHAR_POOLPET +void saacproto_ACCharSavePoolPet_recv(int fd ,char* result, char* data,int retfd) +{ + int charaindex = getCharindexFromFdid( retfd); + if( !CHAR_CHECKINDEX(charaindex) ) return; + if( strstr( result, FAILED ) != NULL ){ + CHAR_talkToCli( charaindex, -1, "ֿϴ浵ʧܣ", CHAR_COLORYELLOW); + return; + + } +} + +void saacproto_ACCharGetPoolPet_recv(int fd ,char* result, char* data,int retfd, int meindex) +{ + Char* ch = NULL; + int i, clifd, charaindex; + + if( strcmp( result , SUCCESSFUL ) != 0 ) return; + charaindex = getCharindexFromFdid(retfd); + if( !CHAR_CHECKINDEX( charaindex) ) return; + clifd = getfdFromCharaIndex( charaindex); + if( CHAR_CheckDepotPet( charaindex) ) return;//ֿѴ + + if( (ch = CHAR_getCharPointer( charaindex)) == NULL ) return; + ch->indexOfExistDepotPets = allocateMemory( sizeof( int ) * CHAR_MAXDEPOTPETHAVE ); + if( ch->indexOfExistDepotPets == NULL ) return; + for( i=0; iindexOfExistDepotPets[i] = -1; + + if( CHAR_makeDepotPetStringToChar( charaindex, data) == FALSE ){ + CHAR_talkToCli( charaindex, -1, "ֿ϶ȡʧܣ", CHAR_COLORYELLOW); + CHAR_removeDepotPet( charaindex); + return; + } + if( !CHAR_CHECKINDEX( meindex) ) return; + if( clifd != -1 ) { + char message[1024]; + char buf[1024]; + strcpy( message, + "3\n\n" + " رע⣺𽫹س빫ֿ\n﹫ֿ⡻\n" + " ų \n" + " ȡس \n" + ); + lssproto_WN_send( clifd, WINDOW_MESSAGETYPE_SELECT, + WINDOW_BUTTONTYPE_CANCEL, + CHAR_WINDOWTYPE_DEPOTPETSHOP_HANDLE, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + makeEscapeString( message, buf, sizeof(buf)) ); + } + +} + +#endif + +#ifdef _ANGEL_SUMMON +//void saacproto_ACMissionTable_recv( int fd, int num, int type, char *data, int charaindex) +void saacproto_ACMissionTable_recv( int fd, int num, int type, char *data, char* angelinfo) +{ + char msg[1024]; + + if( type == 1 ) { // get data list + //if( num == -1) // get all data + { + int di, ti; + char onedata[1024], token[1024]; + + if( num == -1 ) { + print("оٻ!!\n"); + memset( missiontable, 0, sizeof(missiontable)); + } + else + print("һ!!:%s\n", data); + + for( di =1; di = MAXMISSIONTABLE) continue; + getStringFromIndexWithDelim( onedata, "|", 2, token, sizeof(token)); + strcpy( missiontable[ti].angelinfo, token); + getStringFromIndexWithDelim( onedata, "|", 3, token, sizeof(token)); + strcpy( missiontable[ti].heroinfo, token); + getStringFromIndexWithDelim( onedata, "|", 4, token, sizeof(token)); + missiontable[ti].mission = atoi( token); + getStringFromIndexWithDelim( onedata, "|", 5, token, sizeof(token)); + missiontable[ti].flag = atoi( token); + getStringFromIndexWithDelim( onedata, "|", 6, token, sizeof(token)); + missiontable[ti].time = atoi( token); + getStringFromIndexWithDelim( onedata, "|", 7, token, sizeof(token)); + missiontable[ti].limittime = atoi( token); + } + } + } + else if( type == 2 ) { // add data return + int angelindex =-1, i, maxChar; + char nameinfo[128], msgbuf[1024]; + + if( num == -1) { + sprintf( msg, "\n"); + print( msg); + LogAngel( msg); + return; + } + + sprintf( msgbuf, "յACӦ(add data) num=%d nameinfo=%s ", num, angelinfo); + print( msgbuf); + LogAngel( msgbuf); + + maxChar = CHAR_getPlayerMaxNum(); + for( i =0; i = MAXMISSIONTABLE) return; + + sprintf( msg, " AC :%d %s %s ", num, missiontable[num].angelinfo, missiontable[num].heroinfo); + print( msg); + LogAngel( msg); + + strcpy( missiontable[num].angelinfo, ""); + strcpy( missiontable[num].heroinfo, ""); + missiontable[num].mission = 0; + missiontable[num].flag = 0; + missiontable[num].time = 0; + missiontable[num].limittime = 0; + + } + +} + +#endif + +#ifdef _TEACHER_SYSTEM +void saacproto_ACCheckCharacterOnLine_recv( int acfd, int charaindex, int iOnline,char *data,int flag) +{ + switch(flag){ + case R_F_TEACHER_SYSTEM: + CHAR_Teacher_system_View(charaindex,iOnline,data); + break; + default:printf("saacproto_ACCheckCharacterOnLine_recv(): error flag type!!(%d)\n",flag); + } +} +#endif + +void saacproto_ACCharLogin_recv(int fd , int clifd, int flag) +{ + if(flag==1) + lssproto_ClientLogin_send( clifd , "ok" ); + else{ + lssproto_ClientLogin_send( clifd , "no" ); + CONNECT_endOne_debug(clifd); + } +} + +void saacproto_QuerySafePasswd_recv( int fd, char* id, int res, int charaindex ) +{ + if(res == 1) + { + CHAR_setWorkInt( charaindex, CHAR_WORKSAFEMODE, 1); + CHAR_talkToCli( charaindex, -1, "İȫȷϵͳɹ", CHAR_COLORRED); + } + if(res == 2) + { + CHAR_talkToCli( charaindex, -1, "İȫϵͳ޷", CHAR_COLORRED); + } + if(res == 3) + { + CHAR_talkToCli( charaindex, -1, "ûðȫ룬뾡ã", CHAR_COLORRED); + CHAR_AddSafePassword(charaindex); + } + if(res == 4) + { + CHAR_setWorkInt( charaindex, CHAR_WORKSAFEMODE, 1); + CHAR_talkToCli( charaindex, -1, "İȫȷϵͳɹ", CHAR_COLORRED); + CHAR_talkToCli( charaindex, -1, "ʾ1˺źͰȫƣΪ˺Űȫ뾡޸İȫ룡", CHAR_COLORRED); + CHAR_talkToCli( charaindex, -1, "ʾ2Ϊȷ˺Űȫδ޸İȫǰ޷ɾ", CHAR_COLORRED); + } +} + +void saacproto_AddSafePasswd_recv( int fd, char* id, int res, int charaindex ) +{ + if(res == 1) + { + CHAR_talkToCli( charaindex, -1, "Ѿɹõİȫ룡", CHAR_COLORRED); + } +} + +void saacproto_PointCardSucces_recv( int fd, char* id, int res, int point, int charaindex ) +{ + char msgtmp[256]; + if(res > 0) + { + sprintf(msgtmp, "%dԱֵɹڵĻԱΪ%d",res,point); + CHAR_talkToCli( charaindex, -1, msgtmp, CHAR_COLORYELLOW); + } +} + +void saacproto_PointCardErr_recv( int fd, char* id, int res, int charaindex ) +{ + if(res == -1) + { + CHAR_talkToCli( charaindex, -1, "óֵѾʹãظʹãлл", CHAR_COLORRED); + } + else if(res == -2) + { + CHAR_talkToCli( charaindex, -1, "ֵдд", CHAR_COLORRED); + } +} + +void saacproto_LoginTime_recv( int fd, char* id, char* res, int charaindex ) +{ + char timemsg[256]; + sprintf(timemsg,"ϴε½ʱΪ%s",res); + CHAR_talkToCli( charaindex, -1, timemsg, CHAR_COLORYELLOW); + +} + +#ifdef _ONLINE_SHOP +void saacproto_ACShop_recv( int fd, int charaindex, int shopnum, int vippoint, int piece, int pieces, int shopflag, char* res ) +{ + int clifd = getfdFromCharaIndex( charaindex); + lssproto_SHOP_send(clifd,shopnum,vippoint,piece,pieces,shopflag,res); + +} + +void saacproto_ACShopBuy_recv( int charaindex, int shopflag, int shopno, int buynum ) +{ + if(shopflag==1) + { + int ret; + char msgbuf[64], buf1[8], buf2[10]; + int enemynum; + int i,j,k; + int petindex, petindex2; + for( k =1 ; k<=buynum ; k++ ) + { + for( i = 0 ;i < CHAR_MAXPETHAVE ; i++) { + petindex = CHAR_getCharPet( charaindex, i); + if( petindex == -1 ) + break; + } + + if( i == CHAR_MAXPETHAVE ) { + snprintf( msgbuf,sizeof( msgbuf), ""); + CHAR_talkToCli( charaindex, -1, msgbuf, CHAR_COLORYELLOW); + return; + } + + enemynum = ENEMY_getEnemyNum(); + for( i = 0; i < enemynum; i ++ ) { + if( ENEMY_getInt( i, ENEMY_ID) == shopno) { + break; + } + } + + if( i == enemynum ) + return; + + ret = ENEMY_createPetFromEnemyIndex( charaindex, i); + for( i = 0; i < CHAR_MAXPETHAVE; i ++ ) { + if( CHAR_getCharPet( charaindex, i ) == ret ) + break; + } + if( i == CHAR_MAXPETHAVE ) + CHAR_talkToCli( charaindex, -1, "ȡʧܣ", CHAR_COLORYELLOW); + + if( CHAR_CHECKINDEX( ret ) == TRUE ){ + CHAR_setInt( ret, CHAR_HP, CHAR_getWorkInt( ret, CHAR_WORKMAXHP )); + CHAR_setMaxExpFromLevel( ret, CHAR_getInt( ret, CHAR_LV )); + CHAR_setInt(ret,CHAR_VARIABLEAI,10000); + } + + petindex2 = CHAR_getCharPet(charaindex, i); + if( !CHAR_CHECKINDEX( petindex2) ) + return; + snprintf( msgbuf,sizeof( msgbuf), "õ%s", CHAR_getChar(petindex2,CHAR_NAME)); + CHAR_talkToCli( charaindex, -1, msgbuf, CHAR_COLORYELLOW); + for(j = 0; j < CHAR_MAXPETHAVE; j++){ + petindex = CHAR_getCharPet(charaindex, j); + if( !CHAR_CHECKINDEX( petindex) ) + continue; + CHAR_complianceParameter( petindex ); + snprintf( msgbuf, sizeof( msgbuf ), "K%d", j ); + CHAR_sendStatusString( charaindex, msgbuf ); + snprintf( msgbuf, sizeof( msgbuf ), "W%d", j ); + CHAR_sendStatusString( charaindex, msgbuf ); + } + } + } + else + { + + int emptyitemindexinchara, itemindex; + int i; + char msgbuf[128]; + + if( buynum <= 0 ) buynum = 1; + + { + for( i = 0; i < buynum; i ++ ) { + emptyitemindexinchara = CHAR_findEmptyItemBox( charaindex ); + + if( emptyitemindexinchara < 0 ){ + sprintf( msgbuf, "Ʒλ㡣" ); + + CHAR_talkToCli( charaindex, -1, msgbuf, CHAR_COLORYELLOW); + + return; + } + + itemindex = ITEM_makeItemAndRegist( shopno ); + + if( itemindex != -1 ){ + CHAR_setItemIndex( charaindex, emptyitemindexinchara, itemindex ); + ITEM_setWorkInt(itemindex, ITEM_WORKOBJINDEX,-1); + ITEM_setWorkInt(itemindex, ITEM_WORKCHARAINDEX,charaindex); + CHAR_sendItemDataOne( charaindex, emptyitemindexinchara); + snprintf( msgbuf, sizeof( msgbuf), "õ%s", + ITEM_getChar( itemindex, ITEM_NAME)); + CHAR_talkToCli( charaindex, -1,msgbuf, CHAR_COLORYELLOW); + } + } + } + } +} +#endif + +#ifdef _QUESTION_ONLINE +void saacproto_ACQuestion_recv(char* res) +{ + if( getStringFromIndexWithDelim( res, ";", 1, question, sizeof( question)) == FALSE ) + return; + if( getStringFromIndexWithDelim( res, ";", 2, answer, sizeof( answer)) == FALSE ) + return; + time_t timep; + struct tm *p; + time(&timep); + p=localtime(&timep); + timep = mktime(p); + questionstarttime = timep; + int playnum = CHAR_getPlayerMaxNum(); + int i; + char questionres[256]; + sprintf(questionres,"\n⣺%s\n𰸣",question); + for(i=0;i 0) + CHAR_setInt( ret, CHAR_VITAL, vital); + if(str > 0) + CHAR_setInt( ret, CHAR_STR, str * 80); + if(tough > 0) + CHAR_setInt( ret, CHAR_TOUGH, tough * 80); + if(dex > 0) + CHAR_setInt( ret, CHAR_DEX, dex * 100); + + CHAR_setMaxExpFromLevel( ret, CHAR_getInt( ret, CHAR_LV )); + CHAR_setInt(ret, CHAR_VARIABLEAI, 10000); + } + + CHAR_setInt( ret, CHAR_HP, CHAR_getWorkInt( ret, CHAR_WORKMAXHP )); + CHAR_complianceParameter( ret ); + snprintf( token, sizeof( token ), "K%d", i ); + CHAR_sendStatusString( charaindex, token ); + snprintf( token, sizeof( token ), "W%d", i ); + CHAR_sendStatusString( charaindex, token ); + + + }else if(data[0]=='1'){ + int emptyitemindexinchara, itemindex; + int itemid; + getStringFromIndexWithDelim(data,"|", 2, buf, sizeof(buf)); + itemid = atoi( buf); + emptyitemindexinchara = CHAR_findEmptyItemBox( charaindex ); + + if( emptyitemindexinchara < 0 ){ + CHAR_talkToCli( charaindex, -1, "Ʒ", CHAR_COLORYELLOW); + return; + } + + itemindex = ITEM_makeItemAndRegist( itemid ); + + if( itemindex != -1 ){ + CHAR_setItemIndex( charaindex, emptyitemindexinchara, itemindex ); + ITEM_setWorkInt(itemindex, ITEM_WORKOBJINDEX,-1); + ITEM_setWorkInt(itemindex, ITEM_WORKCHARAINDEX,charaindex); + CHAR_sendItemDataOne( charaindex, emptyitemindexinchara); + + snprintf( token, sizeof( token), "ȡƷ %s", ITEM_getChar( itemindex, ITEM_NAME)); + CHAR_talkToCli( charaindex, -1,token, CHAR_COLORGREEN); + }else{ + CHAR_talkToCli( charaindex, -1, "Ʒڣ뱾Աϵ", CHAR_COLORYELLOW); + } + + }else if(data[0]=='2'){ + getStringFromIndexWithDelim(data,"|", 2, buf, sizeof(buf)); + int gold = atoi(buf); + CHAR_setInt( charaindex , CHAR_GOLD , CHAR_getInt( charaindex , CHAR_GOLD ) + gold); + CHAR_complianceParameter( charaindex ); + CHAR_send_P_StatusString( charaindex , CHAR_P_STRING_GOLD); + sprintf( token, "ȡ %d ʯң", gold); + CHAR_talkToCli( charaindex, -1,token, CHAR_COLORGREEN ); + }else{ + CHAR_talkToCli( charaindex, -1, data, CHAR_COLORGREEN); + } +} +#endif + +void saacproto_ACFmPkOnlineSn_recv(int manorindex,char* gsname, int flag) +{ + if(flag == 1){ + sprintf(manorname[manorindex],"%s",gsname); + }else{ + sprintf(manorname[manorindex],"\O"); + } + manorflag[manorindex] = flag; +} + +void saacproto_ACSystemAllTalk_recv(char* data) +{ + if(strlen(data)<1) return; + int playnum = CHAR_getPlayerMaxNum(); + int i; + for(i=0;i%s˵%s",playername,data); + int playnum = CHAR_getPlayerMaxNum(); + int i; + for(i=0;i +#include +#include +#include "common.h" +#include "util.h" +#include "lssproto_serv.h" +#include "saacproto_cli.h" +#include "npc_exchangeman.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 +#include "npc_petshop.h" +#include "enemy.h" +#include "char_base.h" +#ifdef _PROFESSION_SKILL // WON ADD ְҵ +#include "profession_skill.h" +#endif +#ifdef _CHATROOMPROTOCOL // (ɿ) Syu ADD Ƶ +#include "chatroom.h" +#endif +#ifdef _ALLBLUES_LUA +#include "mylua/function.h" +#endif +BOOL checkStringErr( char * ); + +#ifdef _AVOIEDamageCharName +int +dbKeyHasDamageChar( char* key) +{ + if( strstr(key , "'") != NULL ) + { + printf("test . key damage\n"); + return 1; + } + return 0; +} +#endif + +// shan add +extern struct FM_PKFLOOR fmpkflnum[FAMILY_FMPKFLOOR]; +extern char question[64]; +extern char answer[64]; +extern int questionstarttime; +extern int questionman; +#ifdef _UNTEXT_TALK +extern int textcnt; +#endif +extern int sameipnum; +extern int player_online; +extern int autopkcnt; +char mmcdkey[10][32]={"","","","","","","","","",""}; +char mmcdkeybuf[10][64]={"-1.-1.-1","-1.-1.-1","-1.-1.-1","-1.-1.-1","-1.-1.-1","-1.-1.-1","-1.-1.-1","-1.-1.-1","-1.-1.-1","-1.-1.-1",}; +//static unsigned long cdkeycount=0; +//static unsigned long cdkeymaxnum=100000; +//static char** playcdkey=NULL; +//static unsigned long* cdkeylogintime=0; +//static int* cdkeylogincount=0; +/* ----------------------------------------------------------------------- + * ----------------------------------------------------------------------*/ +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; +} + +#ifdef _MO_LOGINCHECK +#define MX (z>>5^y<<2) + (y>>3^z<<4)^(sum^y) + (k[p&3^e]^z); +long btea(long* v, long n, long* k) { + unsigned long z=v[n-1], y=v[0], sum=0, e, DELTA=0x9e3779b9; + long p, q ; + if (n > 1) { /* Coding Part */ + q = 6 + 52/n; + while (q-- > 0) { + sum += DELTA; + e = (sum >> 2) & 3; + for (p=0; p> 2) & 3; + for (p=n-1; p>0; p--) z = v[p-1], y = v[p] -= MX; + z = v[n-1]; + y = v[0] -= MX; + sum -= DELTA; + } + return 0; + } + return 1; +} +#endif +int check_jqm(char *jqm){ + int i; + int len = strlen(jqm); + for(i=0;i47&&jqm[i]<58) || (jqm[i]>64 &&jqm[i]<91) || (jqm[i]>98 &&jqm[i]<123)) + { + continue; + } + return -1; + } + return 1; +} + +//int cdkeyinit(void){ +// playcdkey = (char**)calloc(cdkeymaxnum, sizeof(char*)); +// int tempi; +// for(tempi=0;tempi0 && sasql_onlinenum(cdkey,ip) >= getSameIpNum() ){ + //printf("ͬһIP%sֹͬʱ½%d!\n",ip,sameipnum); + lssproto_ClientLogin_send( fd , "no" ); + CONNECT_endOne_debug(fd); + return; + } + } + res=sasql_query(cdkey,passwd); + if (res==3){ + if(getNoCdkeyPlayer()>0 && fd-player_online>=getNoCdkeyPlayer() && getNoCdkeyMode()!=0){ + if(strcmp(ip,getNoAttIp(0))!=0 && strcmp(ip,getNoAttIp(1))!=0 && strcmp(ip,getNoAttIp(2))!=0 && strcmp(ip,getNoAttIp(3))!=0 && strcmp(ip,getNoAttIp(4))!=0){ + if(getNoCdkeyType()==0){ + //if(sasql_query_online_ip(ip)==0 && sasql_check_lockip(ip,getFengType())<1){ + if(sasql_query_online_ip(ip)==0){ + //if(sasql_add_lockip(ip,getFengType(),getServernumber(),2)==1){ +#ifdef _CAX_OFF_IPTABLES + if(strcmp(ip,"0.0.0.0")!=0){ + char systemstr[128]; + sprintf(systemstr,"iptables -I INPUT -s %s -j DROP",ip); + system(systemstr); + logWrongCdkey(ip); + } +#endif + CONNECT_endOne_debug(fd); + return; + //} + } + }else{ +#ifdef _CAX_OFF_IPTABLES + if(strcmp(ip,"0.0.0.0")!=0){ + char systemstr[128]; + sprintf(systemstr,"iptables -I INPUT -s %s -j DROP",ip); + system(systemstr); + logWrongCdkey(ip); + } +#endif + CONNECT_endOne_debug(fd); + return; + } + } + } + if(!sasql_register(cdkey,passwd)) + {//˺ûע + lssproto_ClientLogin_send( fd , "no" ); +// if(getSaType()==8018) +// CONNECT_endOne_debug(fd); + return; + } + }else if (res!=1){ + if(getNoCdkeyPlayer()>0 && fd-player_online>=getNoCdkeyPlayer() && getNoCdkeyMode()==2){ + if(strcmp(ip,getNoAttIp(0))!=0 && strcmp(ip,getNoAttIp(1))!=0 && strcmp(ip,getNoAttIp(2))!=0 && strcmp(ip,getNoAttIp(3))!=0 && strcmp(ip,getNoAttIp(4))!=0){ + if(getNoCdkeyType()==0){ + //if(sasql_query_online_ip(ip)==0 && sasql_check_lockip(ip,getFengType())<1){ + if(sasql_query_online_ip(ip)==0){ + //if(sasql_add_lockip(ip,getFengType(),getServernumber(),2)==1){ +#ifdef _CAX_OFF_IPTABLES + if(strcmp(ip,"0.0.0.0")!=0){ + char systemstr[128]; + sprintf(systemstr,"iptables -I INPUT -s %s -j DROP",ip); + system(systemstr); + logWrongCdkey(ip); + } +#endif + CONNECT_endOne_debug(fd); + return; + //} + } + }else{ +#ifdef _CAX_OFF_IPTABLES + if(strcmp(ip,"0.0.0.0")!=0){ + char systemstr[128]; + sprintf(systemstr,"iptables -I INPUT -s %s -j DROP",ip); + system(systemstr); + logWrongCdkey(ip); + } +#endif + CONNECT_endOne_debug(fd); + return; + } + } + } + lssproto_ClientLogin_send( fd , "no" );; +// if(getSaType()==8018) +// CONNECT_endOne_debug(fd); + return; + } + if(sasql_cdkey_online(cdkey)>0){ + saacproto_ACKick_send(acfd,cdkey,-1,1); + lssproto_ClientLogin_send( fd , "no" ); + sasql_online(cdkey,NULL,NULL,NULL,NULL,0); + CONNECT_endOne_debug(fd); + return; + } + CONNECT_setCtype( fd, CLI ); + lssproto_ClientLogin_send( fd , "ok" ); + sasql_online(cdkey,NULL,ip,NULL,NULL,4); + } + +} +void lssproto_ClientLoginJqm_recv( int fd,char* cdkey, char* passwd, char* jqm +#ifdef _CAX_NEWMAC_LOGIN +,char* mac +#endif +#ifdef _MO_LOGINCHECK +,char* szdata +#endif + ) +{ + /* 2ֱľľ¼ */ + {//ttom avoid the restore 2001/01/09 + if(CONNECT_isNOTLOGIN(fd)==FALSE){ + print("\n the Client had Logined fd=%d",fd); + return; + } + } +// print("\n fd: %d",fd); +// print("\n cdkey: %s",cdkey); +// print("\n password: %s",passwd); +// print("\n jqm: %s",jqm); + // print("\n 1-mac: %s",mac); + + char* newjqm[128]; + int logintype = -1; + char buftest[128]; + memset(newjqm,0,sizeof(newjqm)); + memset(buftest,0,sizeof(buftest)); + strcpy(newjqm,jqm); + if(strstr(jqm,"|")!=NULL){ + if(getStringFromIndexWithDelim(jqm,"|", 1, buftest, sizeof(buftest)) == FALSE) + strcpy(newjqm,jqm); + else + strcpy(newjqm,buftest); + if(getStringFromIndexWithDelim(jqm,"|", 2, buftest, sizeof(buftest)) == FALSE) + logintype = -1; + else + logintype = atoi(buftest); + } + jqm = newjqm; + + // print("\n logintype : %d",logintype); + // print("\n jqm 2 : %s",jqm); + + /* if(check_jqm(jqm)==-1){ + lssproto_ClientLogin_send( fd , "¼µ¼" ); + return; + }*/ + + //print( "CliLogin cdkey=%s\n" , cdkey ); + /* connect */ + CONNECT_setCdkey( fd, cdkey ); + CONNECT_setPasswd( fd, passwd ); + CONNECT_setPcid(fd, jqm); +#ifdef _CAX_NEWMAC_LOGIN + CONNECT_setMAC(fd, mac); +#endif + + if (sasql_check_lockmac(mac)>0||sasql_check_lockpcid(jqm)>0){ + lssproto_ClientLogin_send( fd , "ӳʱϵGM" ); + CONNECT_endOne_debug(fd); + } + +#ifdef _MO_LOGINCHECK + long n = XXTEA_ROUND; + long k[4] = {XXTEA_KEY_1,XXTEA_KEY_2,XXTEA_KEY_3,XXTEA_KEY_4}; + char data[1024] = ""; + int datalen = 0; + int j = 0; + char demac[20]; + char detime[20]; + long recvtime; + //ת + //printf("Hex data: %s\n", szdata); + datalen = strlen(szdata); + + for(j = 0; j < datalen/2; j++){ + int temp; + sscanf(&szdata[2 * j], "%02X", &temp); + data[j] = (char)temp; + } + data[datalen/2] = '\0'; + //printf("Bin data: \n %s\n", data); + btea((long*)data, -n, k); // + //printf( "Decrypt Data:\n %s\n", data); + + sscanf(data,"%[^=]=%[^\n]",&demac,&detime); + //printf("\n demac=%s,mac=%s\n",demac, mac); + if(strstr(demac,mac)==NULL){ + lssproto_ClientLogin_send( fd , "¼֤ϵGM" ); + CONNECT_endOne_debug(fd); + return; + } + recvtime=atoi(detime); + //ȡϵͳʱ + time_t timep; + struct tm *p; + timep = time (NULL); + p = localtime ( &timep ); + if(abs(timep-recvtime)>86400){ + lssproto_ClientLogin_send( fd , "ӳʱϵGM" ); + CONNECT_endOne_debug(fd); + return; + } +#endif + + + //CONNECT_setCtype( fd, CLI ); + if(getLoginType()>0){ + if(logintype == -1){ + lssproto_ClientLogin_send( fd , "¿ͻ˺¼·" ); + return; + }else if(logintype!=0 && logintype!=1){ + lssproto_ClientLogin_send( fd , "·ֻ֧һSTWҵ¼" ); + return; + } + } + + unsigned long tmpip; + int a,b,c,d,i; + 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); + { + int res; + + if (strlen(cdkey)==0 || strlen(passwd)==0 || strlen(ip)==0){ + //printf("½Ϣд\n"); + lssproto_ClientLogin_send( fd , "no" ); + CONNECT_endOne_debug(fd); + return; + } + if (sasql_chehk_lock(jqm)){ + //printf("˺%sֹ½!\n",cdkey); + lssproto_ClientLogin_send( fd , "ΥΪѱ޷½Ϸ" ); + //CONNECT_endOne_debug(fd); + return; + } + if (sasql_chehk_lock(ip)){ + //printf("IP%sֹ½!\n",ip); + lssproto_ClientLogin_send( fd , "no" ); + CONNECT_endOne_debug(fd); + return; + } + + if(strcmp(ip,getNoAttIp(0))!=0 && strcmp(ip,getNoAttIp(1))!=0 && strcmp(ip,getNoAttIp(2))!=0 && strcmp(ip,getNoAttIp(3))!=0 && strcmp(ip,getNoAttIp(4))!=0){ + if ( getSameIpNum()>0 && sasql_onlinenum(cdkey,ip) >= getSameIpNum() ){ + //printf("ͬһIP%sֹͬʱ½%d!\n",ip,sameipnum); + //lssproto_ClientLogin_send( fd , "no" ); + //char tmpbuf[128]; + //sprintf(tmpbuf,"ĵ¼Ѵޣ%dID޷Ϸ",getSameIpNum()); + lssproto_ClientLogin_send( fd , "ĵ¼Ѵޣ޷Ϸ" ); + //CONNECT_endOne_debug(fd); + return; + } + } + if( getSameJqmNum()>0 && sasql_onlinejqmnum(jqm,1) >= getSameJqmNum() ){ + //lssproto_ClientLogin_send( fd , "no" ); + //CONNECT_endOne_debug(fd); + //char tmpbuf[128]; + //sprintf(tmpbuf,"ڸߵĵ¼Ѵﵽޣ%dID볢Ե½·",getSameJqmNum()); + lssproto_ClientLogin_send( fd , "ڸߵĵ¼Ѵﵽޣ볢Ե½·" ); + //printf("ͬһIP%sֹͬʱ½%d!\n"); + return; + } + if( getSameJqmAllNum()>0 && sasql_onlinejqmnum(jqm,2) >= getSameJqmAllNum() ){ + //lssproto_ClientLogin_send( fd , "no" ); + //CONNECT_endOne_debug(fd); + //char tmpbuf[128]; + //sprintf(tmpbuf,"ĵ¼Ѵޣ%dID޷Ϸ",getSameJqmAllNum()); + lssproto_ClientLogin_send( fd , "ĵ¼Ѵޣ޷Ϸ" ); + //printf("ĵ¼Ѵޣ޷Ϸ\n"); + return; + } + res=sasql_query(cdkey,passwd); + // print("\n res 2 : %d",res); + if (res==3){ + if(getNoCdkeyPlayer()>0 && fd-player_online>=getNoCdkeyPlayer() && getNoCdkeyMode()!=0){ + if(strcmp(ip,getNoAttIp(0))!=0 && strcmp(ip,getNoAttIp(1))!=0 && strcmp(ip,getNoAttIp(2))!=0 && strcmp(ip,getNoAttIp(3))!=0 && strcmp(ip,getNoAttIp(4))!=0){ + if(getNoCdkeyType()==0){ + //if(sasql_query_online_ip(ip)==0 && sasql_check_lockip(ip,getFengType())<1){ + if(sasql_query_online_ip(ip)==0){ + //if(sasql_add_lockip(ip,getFengType(),getServernumber(),2)==1){ +#ifdef _CAX_OFF_IPTABLES + if(strcmp(ip,"0.0.0.0")!=0){ + char systemstr[128]; + sprintf(systemstr,"iptables -I INPUT -s %s -j DROP",ip); + system(systemstr); + logWrongCdkey(ip); + } +#endif + CONNECT_endOne_debug(fd); + return; + //} + } + }else{ +#ifdef _CAX_OFF_IPTABLES + if(strcmp(ip,"0.0.0.0")!=0){ + char systemstr[128]; + sprintf(systemstr,"iptables -I INPUT -s %s -j DROP",ip); + system(systemstr); + logWrongCdkey(ip); + } +#endif + CONNECT_endOne_debug(fd); + return; + } + } + } + if(!sasql_register(cdkey,passwd)) + {//˺ûע + //lssproto_ClientLogin_send( fd , "no" ); + lssproto_ClientLogin_send( fd , "˺Ųڣδעᣬ뵽ٷվעᡣ" ); +// if(getSaType()==8018) +// CONNECT_endOne_debug(fd); + return; + } + }else if (res!=1){ + if(getNoCdkeyPlayer()>0 && fd-player_online>=getNoCdkeyPlayer() && getNoCdkeyMode()==2){ + if(strcmp(ip,getNoAttIp(0))!=0 && strcmp(ip,getNoAttIp(1))!=0 && strcmp(ip,getNoAttIp(2))!=0 && strcmp(ip,getNoAttIp(3))!=0 && strcmp(ip,getNoAttIp(4))!=0){ + if(getNoCdkeyType()==0){ + //if(sasql_query_online_ip(ip)==0 && sasql_check_lockip(ip,getFengType())<1){ + if(sasql_query_online_ip(ip)==0){ + //if(sasql_add_lockip(ip,getFengType(),getServernumber(),2)==1){ +#ifdef _CAX_OFF_IPTABLES + if(strcmp(ip,"0.0.0.0")!=0){ + char systemstr[128]; + sprintf(systemstr,"iptables -I INPUT -s %s -j DROP",ip); + system(systemstr); + logWrongCdkey(ip); + } +#endif + CONNECT_endOne_debug(fd); + return; + //} + } + }else{ +#ifdef _CAX_OFF_IPTABLES + if(strcmp(ip,"0.0.0.0")!=0){ + char systemstr[128]; + sprintf(systemstr,"iptables -I INPUT -s %s -j DROP",ip); + system(systemstr); + logWrongCdkey(ip); + } +#endif + CONNECT_endOne_debug(fd); + return; + } + } + } + // + //lssproto_ClientLogin_send( fd , "no" ); + lssproto_ClientLogin_send( fd , "ϸȷϺ½" ); +// if(getSaType()==8018) +// CONNECT_endOne_debug(fd); + return; + } + if(sasql_cdkey_online(cdkey)>0){ + saacproto_ACKick_send(acfd,cdkey,-1,1); + lssproto_ClientLogin_send( fd , "no" ); + sasql_online(cdkey,NULL,NULL,NULL,NULL,0); + CONNECT_endOne_debug(fd); + return; + } + CONNECT_setCtype( fd, CLI ); + char* oldpcid = NULL; + oldpcid = sasql_query_jqm(cdkey); +#ifdef _CAX_NEWMAC_LOGIN + char* oldmac = NULL; + oldmac = sasql_query_mac(cdkey); +#endif + + +/* if(strlen(oldpcid)<10){ + CONNECT_setOldPcid(fd,jqm); + }else{ + CONNECT_setOldPcid(fd,oldpcid); + }*/ + + lssproto_ClientLogin_send( fd , "ok" ); + + //print("\n jqm: %s",jqm); + sasql_online_jqm(cdkey,jqm,ip,logintype); +#ifdef _CAX_NEWMAC_LOGIN + sasql_online_mac(cdkey,mac,ip,logintype); +#endif + } + +} + +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, "ֹ̣޷\n"); + return; +#ifdef _AVOIEDamageCharName + }else if ( dbKeyHasDamageChar(charname)){ + lssproto_CreateNewChar_send(fd,FAILED, "ֹֽʹ\n"); + return; +#endif + }else if( strlen(charname) >= 32 ){ + lssproto_CreateNewChar_send(fd,FAILED, "ֹ޷\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,"") || strstr(charname,"ǣ") + || strstr(charname,"ǣ") || strstr(charname,"") + || strstr(charname," ") || strstr(charname,"=") || strstr(charname,",") +#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) + || (strstr(charname,getUnregname(5)) && strlen(getUnregname(5))>0) + || (strstr(charname,getUnregname(6)) && strlen(getUnregname(6))>0) + || (strstr(charname,getUnregname(7)) && strlen(getUnregname(7))>0) + || (strstr(charname,getUnregname(8)) && strlen(getUnregname(8))>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, "Ƿ֣޷\n"); + return; + } + } + { + // Nuke start 0801,0916: Avoid strange name + int i,ach; + for (i=0,ach=0;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, "Ƿ֣޷\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; + } + if( strstr(charname,",")!=NULL ){ + CONNECT_endOne_debug(fd); + return; + } + CONNECT_setCharname( fd, charname ); + CONNECT_getCdkey( fd, cdkey, sizeof( cdkey )); + CONNECT_getPasswd( fd, passwd, sizeof(passwd)); + 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); + int res; + res = sasql_load_query( cdkey, passwd); + if(res!=1){ + lssproto_CharLogin_send( fd ,FAILED, "޷¼\n" ); + //CONNECT_endOne_debug(fd); + return; + } + saacproto_ACCharLoad_send( acfd, cdkey,passwd, charname,1,"", + CONNECT_getFdid(fd),ip ); + CONNECT_setState( fd, WHILELOGIN ); +} + +#ifdef _ITEM_CHECKDROPATLOGOUT +BOOL CheckDropatLogout(int charaindex ) +{ + int i; + for( i=0 ; i= 0 ) + { + CHAR_getElderPosition( CHAR_getInt( charaindex, CHAR_LASTTALKELDER), &fl, &x, &y ); + +#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 _TEAM_WARP + if( CHAR_getWorkInt( charaindex, CHAR_WORKPARTYMODE ) == CHAR_PARTY_CLIENT ){ + CHAR_talkToCli( charaindex, -1, "Ŷ޷ؼ¼㣡", CHAR_COLORYELLOW); + return; + } + + if( CHAR_getWorkInt( charaindex, CHAR_WORKPARTYMODE ) == CHAR_PARTY_LEADER ){ + int i; + for( i = 0; i < CHAR_PARTYMAX; i ++ ){ + int subindex = CHAR_getWorkInt( charaindex, CHAR_WORKPARTYINDEX1+i ); + if( CHAR_CHECKINDEX( subindex ) == FALSE ) continue; + CHAR_talkToCli( subindex, -1, "ȫ˲У", CHAR_COLORWHITE); + ITEM_WarpDelErrorItem( subindex ); + CHAR_warpToSpecificPoint( subindex, fl, x, y ); + } + return; + } +#endif + if( CHAR_getWorkInt( charaindex, CHAR_WORKPARTYMODE ) != CHAR_PARTY_NONE ){ +#ifdef _PLAYER_NPC + int i; + for( i = 1; i < CHAR_PARTYMAX; i ++ ){ + int pindex = CHAR_getWorkInt( charaindex, i + CHAR_WORKPARTYINDEX1 ); + if( CHAR_CHECKINDEX( pindex)){ + if(CHAR_getInt( pindex, CHAR_WHICHTYPE) != CHAR_TYPEPLAYERNPC)break; + } + } + if(i < CHAR_MAXPETHAVE) +#endif + { + CHAR_talkToCli( charaindex, -1, "Ŷ޷ؼ¼㣡", CHAR_COLORYELLOW); + return; + } + } +#ifdef _ITEM_CHECKDROPATLOGOUT + if( CheckDropatLogout( charaindex ) ){ + CHAR_talkToCli( charaindex, -1, "ЯƷʹ޷ؼ¼㣡", CHAR_COLORYELLOW); + return; + } +#endif +#ifdef _AUTO_PK + if(CHAR_getInt(charaindex,CHAR_FLOOR)==20000 + && CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE) == BATTLE_CHARMODE_NONE + && CHAR_getInt(charaindex,CHAR_AUTOPK)!=-1 ){ + char buf[64]; + int i,num=0,winindex; + int playernum = CHAR_getPlayerMaxNum(); +#ifndef _YUANGUSA + sprintf(buf, "С%s˳ǰ",CHAR_getChar(charaindex,CHAR_NAME)); + AutoPk_PKSystemTalk( buf, buf ); +#endif + if(AutoPk_PKTimeGet()<=0){ + for(i=0;i1)||(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,wx,wy,w_fl,warfd; + char workxyd[30]; + char workbuf[20]; + char w_d[5]; + //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; + if( CHAR_getWorkInt(fd_charaindex,CHAR_WORKSTREETVENDOR)!=-1) return; +#ifdef _BATTLEEND_FIX + if( CHAR_getWorkInt(fd_charaindex,CHAR_WORKBALLTELENDTIME)>0) + CHAR_setWorkInt(fd_charaindex,CHAR_WORKBALLTELENDTIME,0); +#endif +#ifdef _NO_QUICK_WAR + if( strlen(direction)==1 && strstr("abcdefgh",direction)!=NULL ){ + if(strlen(CHAR_getWorkChar(fd_charaindex,CHAR_WARWORKXYD))!=0){ + strcpy(workxyd,CHAR_getWorkChar(fd_charaindex,CHAR_WARWORKXYD)); + if(getStringFromIndexWithDelim(workxyd,"|", 1, workbuf, sizeof(workbuf)) == FALSE) + w_fl=-1; + w_fl=atoi(workbuf); + if(getStringFromIndexWithDelim(workxyd,"|", 2, workbuf, sizeof(workbuf)) == FALSE) + wx=-1; + wx=atoi(workbuf); + if(getStringFromIndexWithDelim(workxyd,"|", 3, workbuf, sizeof(workbuf)) == FALSE) + wy=-1; + wy=atoi(workbuf); + if(getStringFromIndexWithDelim(workxyd,"|", 4, workbuf, sizeof(workbuf)) == FALSE) + strcpy(w_d,"z"); + strcpy(w_d,workbuf); + if(i_fl==w_fl && x == wx && y == wy && (strcmp(w_d,direction)==0 || (strcmp(w_d,"c")==0 && strcmp(direction,"g")==0) || (strcmp(w_d,"g")==0 && strcmp(direction,"c")==0)) ){ + if(getStayEncount(fd)==1){ + return; + } + setStayEncount(fd); + { + Char *ch; + ch = CHAR_getCharPointer( fd_charaindex); + if( ch == NULL ) return; + strcpysafe( ch->charfunctable[CHAR_LOOPFUNCTEMP1].string, + sizeof( ch->charfunctable[CHAR_LOOPFUNCTEMP1]), "CHAR_BattleStayLoop");//ս + CHAR_setInt( fd_charaindex, CHAR_LOOPINTERVAL, 2500); + CHAR_constructFunctable( fd_charaindex); + } + return; + } + sprintf(workxyd,"%d|%d|%d|%s",i_fl,x,y,direction); + CHAR_setWorkChar(fd_charaindex,CHAR_WARWORKXYD,workxyd); + } + sprintf(workxyd,"%d|%d|%d|%s",i_fl,x,y,direction); + CHAR_setWorkChar(fd_charaindex,CHAR_WARWORKXYD,workxyd); + }else if(strcmp(direction,"gcgcgcgcgc")==0 || strcmp(direction,"gcgc")==0){ + if(getStayEncount(fd)==1){ + return; + } + setStayEncount(fd); + { + Char *ch; + ch = CHAR_getCharPointer( fd_charaindex); + if( ch == NULL ) return; + strcpysafe( ch->charfunctable[CHAR_LOOPFUNCTEMP1].string, + sizeof( ch->charfunctable[CHAR_LOOPFUNCTEMP1]), "CHAR_BattleStayLoop");//ս + CHAR_setInt( fd_charaindex, CHAR_LOOPINTERVAL, 2500); + CHAR_constructFunctable( fd_charaindex); + } + return; + } +#endif + //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("\nWarp Error!!!!!!!!!"); + //print("\nthe origion->fd=%d,x=%d,y=%d",fd,ix,iy); + //print("\nthe 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 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; + if( CHAR_getWorkInt(fd_charaindex,CHAR_WORKSTREETVENDOR)!=-1) return; + if( CHAR_getWorkInt( fd_charaindex, CHAR_WORKBATTLEMODE) + != BATTLE_CHARMODE_NONE) return ; + //ttom avoid the warp at will 12/5 + { + int ix,iy; + ix=CHAR_getInt(fd_charaindex, CHAR_X); + iy=CHAR_getInt(fd_charaindex, CHAR_Y); + x=ix; + y=iy; + } +// if( CHAR_getInt( fd_charaindex, CHAR_RIDEPET) + 1 == toindex ){ +// CHAR_talkToCli( fd_charaindex , -1, "޷ʹøƷʹã", CHAR_COLORRED); +// return; +// } + CHAR_setMyPosition( fd_charaindex, x,y,TRUE); + to_charaindex = Callfromcli_Util_getTargetCharaindex( fd, toindex); + CHAR_ItemUse( fd_charaindex, to_charaindex, haveitemindex ); +} + + +/*------------------------------------------------------------ + * įë + ------------------------------------------------------------*/ +void lssproto_ST_recv( int fd,int titleindex ) +{ + CHECKFDANDTIME; + CHAR_selectTitle( CONNECT_getCharaindex( fd) , titleindex ); +} +/*------------------------------------------------------------ + * įë + ------------------------------------------------------------*/ +void lssproto_DT_recv( int fd,int titleindex ) +{ + CHECKFDANDTIME; + CHAR_deleteTitle( CONNECT_getCharaindex(fd) , titleindex ); +} + + +/*------------------------------------------------------------ + ------------------------------------------------------------*/ +void lssproto_FT_recv( int fd,char* data ) +{ + CHECKFDANDTIME; + + // Robin 04/23 debug + if( strlen(data) > 12 ) return; + + if( checkStringErr(data) ) return; + + CHAR_inputOwnTitle( CONNECT_getCharaindex(fd) , data); +} + +/*------------------------------------------------------------ + ------------------------------------------------------------*/ +void lssproto_PI_recv( int fd,int x, int y, int dir ) +{ + int fd_charaindex; + CHECKFDANDTIME; + fd_charaindex = CONNECT_getCharaindex( fd ); + {//ttom avoid warp at will + int ix,iy; + ix=CHAR_getInt(fd_charaindex, CHAR_X); + iy=CHAR_getInt(fd_charaindex, CHAR_Y); + if( (ix!=x)||(iy!=y)){ + //print("\n--Error!!!!"); + //print("\norigion x=%d,y=%d",ix,iy); + //print("\nmodify X=%d,Y=%d",x,y); + x=ix; + y=iy; + } + }//ttom end + + CHAR_setMyPosition( fd_charaindex, x,y,TRUE); + if( CHAR_getWorkInt( fd_charaindex, CHAR_WORKBATTLEMODE) + != BATTLE_CHARMODE_NONE) return ; + CHAR_PickUpItem( fd_charaindex, dir); +} + +void lssproto_DI_recv( int fd,int x, int y, int itemindex ) +{ + int charaindex; + CHECKFDANDTIME; + charaindex = CONNECT_getCharaindex( fd ); + + if( CHAR_getWorkInt(charaindex, CHAR_WORKTRADEMODE) != CHAR_TRADE_FREE) return; + if( CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE) != BATTLE_CHARMODE_NONE) return; + if( CHAR_getWorkInt(charaindex,CHAR_WORKSTREETVENDOR)!=-1) return; + + CHAR_setMyPosition( charaindex , + CHAR_getInt( charaindex, CHAR_X), CHAR_getInt( charaindex, CHAR_Y), TRUE); + CHAR_DropItem( charaindex, itemindex ); +} + +void lssproto_DP_recv( int fd,int x, int y, int petindex ) +{ + int fd_charaindex; + CHECKFDANDTIME; + fd_charaindex = CONNECT_getCharaindex( fd ); + if (CHAR_getWorkInt(fd_charaindex, CHAR_WORKTRADEMODE) != CHAR_TRADE_FREE) + return; + if( CHAR_getWorkInt(fd_charaindex,CHAR_WORKSTREETVENDOR)!=-1) return; + { + int ix,iy; + ix=CHAR_getInt(fd_charaindex, CHAR_X); + iy=CHAR_getInt(fd_charaindex, CHAR_Y); + x=ix; + y=iy; + } + CHAR_setMyPosition( fd_charaindex , x,y,TRUE); + if( CHAR_getWorkInt( fd_charaindex , CHAR_WORKBATTLEMODE) + != BATTLE_CHARMODE_NONE) return ; + PET_dropPet( fd_charaindex, petindex); +} + +/*------------------------------------------------------------ + ------------------------------------------------------------*/ +void lssproto_DG_recv( int fd,int x, int y, int amount ) +{ + int fd_charaindex; + CHECKFDANDTIME; + fd_charaindex = CONNECT_getCharaindex( fd ); + //ttom avoid the warp at will 12/15 + { + int ix,iy; + ix=CHAR_getInt(fd_charaindex, CHAR_X); + iy=CHAR_getInt(fd_charaindex, CHAR_Y); + x=ix; + y=iy; + } + CHAR_setMyPosition( fd_charaindex, x,y,TRUE); + + if( CHAR_getWorkInt( fd_charaindex, CHAR_WORKBATTLEMODE) + != BATTLE_CHARMODE_NONE) return ; + + // CoolFish: Prevent Trade Cheat 2001/4/18 + if (CHAR_getWorkInt(fd_charaindex, CHAR_WORKTRADEMODE) != CHAR_TRADE_FREE) + return; + if( CHAR_getWorkInt(fd_charaindex,CHAR_WORKSTREETVENDOR)!=-1) return; + CHAR_DropMoney( fd_charaindex, amount ); +} + +/*------------------------------------------------------------ + ------------------------------------------------------------*/ +void lssproto_MI_recv( int fd,int fromindex,int toindex ) +{ + 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; + + if( CHAR_getWorkInt( fd_charaindex, CHAR_WORKBATTLEMODE) + != BATTLE_CHARMODE_NONE) return ; + if( CHAR_getWorkInt(fd_charaindex,CHAR_WORKSTREETVENDOR)!=-1) return; + CHAR_moveEquipItem( fd_charaindex, fromindex, toindex ); + +} + +#ifdef _PET_ITEM +void lssproto_PETITEM_recv( int fd,int x,int y,int petindex,int fromindex,int toindex ) +{ + 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; + if( CHAR_getWorkInt(fd_charaindex,CHAR_WORKSTREETVENDOR)!=-1) return; + + /* ºƥľ¦Ⱦµ ؤԻ */ + if( CHAR_getWorkInt( fd_charaindex, CHAR_WORKBATTLEMODE) + != BATTLE_CHARMODE_NONE) return ; + CHAR_movePetItem( fd_charaindex, petindex, fromindex, toindex ); +} +#endif + + + +/*------------------------------------------------------------ + * ƽʧ + ------------------------------------------------------------*/ +void lssproto_SKUP_recv( int fd,int skillid ) +{ + int fd_charaindex; + CHECKFDANDTIME; + fd_charaindex = CONNECT_getCharaindex(fd); + + if( CHAR_getWorkInt( fd_charaindex, CHAR_WORKBATTLEMODE) + != BATTLE_CHARMODE_NONE) return ; + CHAR_SkillUp(fd_charaindex,skillid); +} + +/*------------------------------------------------------------ + * 嶪ë˪ + ------------------------------------------------------------*/ +void lssproto_MSG_recv( int fd,int index,char* message, int color ) +{ + int fd_charaindex; + CHECKFD; + fd_charaindex = CONNECT_getCharaindex( fd); + ADDRESSBOOK_sendMessage( fd_charaindex, index,message, color ); + +} + +/*------------------------------------------------------------ + ------------------------------------------------------------*/ +void lssproto_AB_recv( int fd ) +{ + int fd_charaindex; + CHECKFDANDTIME; + fd_charaindex = CONNECT_getCharaindex( fd ); + ADDRESSBOOK_sendAddressbookTable( fd_charaindex ); +} + +/*------------------------------------------------------------ + ------------------------------------------------------------*/ +void lssproto_DAB_recv( int fd , int index) +{ + int fd_charaindex; + CHECKFDANDTIME; + fd_charaindex = CONNECT_getCharaindex( fd ); + ADDRESSBOOK_deleteEntry( fd_charaindex ,index); +} + +void lssproto_AAB_recv( int fd , int x, int y) +{ + int fd_charaindex; + CHECKFDANDTIME; + fd_charaindex = CONNECT_getCharaindex( fd ); + { + int ix,iy; + ix=CHAR_getInt(fd_charaindex, CHAR_X); + iy=CHAR_getInt(fd_charaindex, CHAR_Y); + if( (ix!=x)||(iy!=y)){ + x=ix; + y=iy; + } + } + CHAR_setMyPosition( fd_charaindex , x,y,TRUE); + ADDRESSBOOK_addEntry( fd_charaindex ); +} + +void lssproto_L_recv( int fd, int dir ) +{ + int fd_charaindex; + CHECKFDANDTIME; + fd_charaindex = CONNECT_getCharaindex( fd ); + CHAR_Look( fd_charaindex ,dir ); +} + + +/*------------------------------------------------------------ + * ö⼰˪ + ------------------------------------------------------------*/ +void lssproto_TK_recv( int fd,int x, int y,char* message,int color, int area ) +{ + int fd_charaindex,ix,iy;//ttom+2 + int fmindex, channel; + int i; + CHECKFD; + fd_charaindex = CONNECT_getCharaindex( fd ); + fmindex = CHAR_getInt( fd_charaindex, CHAR_FMINDEX ); + channel = CHAR_getWorkInt( fd_charaindex, CHAR_WORKFMCHANNEL ); + + {// Robin 0629 silent + int silentSec, talkCount; + silentSec = CHAR_getInt(fd_charaindex,CHAR_SILENT); + if( silentSec > 0 ) { + int loginTime; + char buf[256]; + int leftSec; + loginTime = CHAR_getWorkInt(fd_charaindex, CHAR_WORKLOGINTIME ); + // ֹʱ˷ᡡ쳣 Robin 20040817 + if( (int)NowTime.tv_sec < loginTime) { + CHAR_setInt(fd_charaindex, CHAR_SILENT, 0 ); + return; + } + if( ((int)NowTime.tv_sec -loginTime) > silentSec ) { + CHAR_setInt(fd_charaindex, CHAR_SILENT, 0 ); + return; + } + silentSec += 10; //10 + + leftSec = silentSec - ((int)NowTime.tv_sec - loginTime); + sprintf(buf, "!!%d룬ٽ10ӡ", leftSec ); + CHAR_talkToCli(fd_charaindex, -1, buf, color); + CHAR_setInt(fd_charaindex, CHAR_SILENT, silentSec ); + return; + } + + talkCount = CHAR_getWorkInt(fd_charaindex, CHAR_WORKTALKCOUNT ); + talkCount ++; + CHAR_setWorkInt( fd_charaindex, CHAR_WORKTALKCOUNT, talkCount); + if( talkCount > 40 ) { + int lastTalkTime = CHAR_getWorkInt(fd_charaindex, CHAR_WORKTALKTIME ); + if( (int)NowTime.tv_sec - lastTalkTime < 10 ) { + CHAR_setInt( fd_charaindex,CHAR_SILENT, 60 ); + CHAR_setWorkInt( fd_charaindex, CHAR_WORKLOGINTIME, (int)NowTime.tv_sec ); + CHAR_talkToCli( fd_charaindex, -1, "̫໰ࡣϢһӰɣ", color); + CHAR_setWorkInt(fd_charaindex, CHAR_WORKTALKCOUNT, 0 ); + return; + }else { + CHAR_setWorkInt( fd_charaindex, CHAR_WORKTALKTIME, (int)NowTime.tv_sec ); + CHAR_setWorkInt(fd_charaindex, CHAR_WORKTALKCOUNT, 0 ); + } + } + + } + ix=CHAR_getInt(fd_charaindex, CHAR_X); + iy=CHAR_getInt(fd_charaindex, CHAR_Y); + x=ix; + y=iy; + CHAR_setMyPosition( fd_charaindex, x,y,TRUE); + if(!CONNECT_get_shutup(fd)){ //ttom add the shut up function +#ifdef _UNTEXT_TALK + for(i=0;i 7) { + fx = CHAR_getInt(fd_charaindex, CHAR_X); + fy = CHAR_getInt(fd_charaindex, CHAR_Y); + }else { + CHAR_getCoordinationDir( dir, CHAR_getInt(fd_charaindex, CHAR_X), + CHAR_getInt(fd_charaindex, CHAR_Y),1,&fx,&fy); + } + rc = EVENT_main(fd_charaindex, event,fx,fy); + lssproto_EV_send( fd, seqno, rc); +} +/*------------------------------------------------------------ + ------------------------------------------------------------*/ +void lssproto_EN_recv( int fd , int x,int y ) +{ + int ret = FALSE, err = 0; + int fd_charaindex; + CHECKFD; + fd_charaindex = CONNECT_getCharaindex( fd); +#ifdef _ALLBLUES_LUA_1_7 + if( CHAR_getInt( fd_charaindex, CHAR_WHICHTYPE) == CHAR_TYPEPLAYER ) { + if( CHAR_getWorkInt( fd_charaindex, CHAR_WORKBATTLEMODE ) == BATTLE_CHARMODE_NONE ){ + if(CharVsEnemyFunction( fd_charaindex ) == TRUE)return; + } + } +#endif + //print(" EN_recv "); + + if( CHAR_getWorkInt( fd_charaindex, CHAR_WORKPARTYMODE) != CHAR_PARTY_CLIENT){ + CHAR_setMyPosition( fd_charaindex, x,y,TRUE); + CHAR_setWorkChar( fd_charaindex, CHAR_WORKWALKARRAY,""); + err = BATTLE_CreateVsEnemy( fd_charaindex,0, -1); + if( err != 0 ){ + ret = FALSE; + }else{ + ret = TRUE; + } + } +} +/*------------------------------------------------------------ + ------------------------------------------------------------*/ +void lssproto_DU_recv( int fd , int x,int y ) +{ + int fd_charaindex; + fd_charaindex = CONNECT_getCharaindex( fd ); +// if(CHAR_getWorkInt(fd_charaindex, CHAR_WORKSAFEMODE)==0) +// { +// lssproto_EN_send( fd, FALSE, 0 ); +// CHAR_SafePassword(fd_charaindex); +// return; +// } + if(CHAR_getInt(fd_charaindex,CHAR_FLOOR)==20000){ + lssproto_EN_send( fd, FALSE, 0 ); + return; + } + if(CHAR_getInt(fd_charaindex,CHAR_FLOOR)==getNoPkMap()){ + CHAR_talkToCli( fd_charaindex, -1, "õͼֹPK", CHAR_COLORYELLOW); + lssproto_EN_send( fd, FALSE, 0 ); + return; + } + OBJECT object; + + int ret = FALSE, charaindex = -1, enemyindex; + int frontx,fronty; + int cnt = 0; + BOOL found = FALSE; + CHECKFDANDTIME; + + + {//ttom avoid warp at will + int ix,iy; + ix=CHAR_getInt(fd_charaindex, CHAR_X); + iy=CHAR_getInt(fd_charaindex, CHAR_Y); + if( (ix!=x)||(iy!=y)){ + //print("\n--Error!!!!"); + //print("\norigion x=%d,y=%d",ix,iy); + //print("\nmodify X=%d,Y=%d",x,y); + x=ix; + y=iy; + } + } + + + if( CHAR_getWorkInt( fd_charaindex, CHAR_WORKPARTYMODE) + != CHAR_PARTY_CLIENT) + { + int i; + // м̼͵ + charaindex = fd_charaindex; + CHAR_setMyPosition( charaindex, x,y,TRUE); + /* WALKARRAYëʧ */ + CHAR_setWorkChar( charaindex, CHAR_WORKWALKARRAY,""); + + + /* */ + for( i = 0; i < CONNECT_WINDOWBUFSIZE ; i ++ ) { + CONNECT_setDuelcharaindex( fd, i, -1 ); + } + + CHAR_getCoordinationDir( CHAR_getInt( charaindex, CHAR_DIR ) , + CHAR_getInt( charaindex , CHAR_X ), + CHAR_getInt( charaindex , CHAR_Y ) , + 1 , &frontx , &fronty ); + + for( object = MAP_getTopObj( CHAR_getInt( charaindex, CHAR_FLOOR), + frontx,fronty) ; + object ; + object = NEXT_OBJECT(object ) ) + { + int toindex; + int objindex = GET_OBJINDEX(object); + /* ƽҷԪئ */ + if( OBJECT_getType( objindex) != OBJTYPE_CHARA) continue; + toindex = OBJECT_getIndex( objindex); + /* Ԫئ */ + if( CHAR_getInt( toindex, CHAR_WHICHTYPE) != CHAR_TYPEPLAYER +#ifdef _PLAYER_NPC + && CHAR_getInt( toindex, CHAR_WHICHTYPE) != CHAR_TYPEPLAYERNPC +#endif +// && CHAR_getInt( toindex, CHAR_WHICHTYPE) != CHAR_TYPEPLAYERNPC + ) continue; + found = TRUE; + if( CHAR_getWorkInt( toindex, CHAR_WORKBATTLEMODE) != BATTLE_CHARMODE_NONE )continue; + int floor = CHAR_getInt( charaindex, CHAR_FLOOR ); + + if(!CHAR_getFlg( toindex, CHAR_ISDUEL) +#ifdef _BATTLE_FLOOR + && (!strcmp(getBattleFloorCF(),"") + && floor!=getBattleFloor(1) + && floor!=getBattleFloor(2) + && floor!=getBattleFloor(3) + && floor!=getBattleFloor(4) + && floor!=getBattleFloor(5)) +#endif + )continue; +#ifdef _ALLBLUES_LUA_1_5 + int flg = FreeVsPlayer(charaindex, toindex); + if( flg == 1){ + lssproto_EN_send( fd, FALSE, 0 ); + return; + }else if( flg == 2){ + return; + }else +#endif +#ifdef _AUTO_PK + if(!CHAR_getFlg( toindex, CHAR_ISDUEL)){ + if(AutoPk_PKTimeGet()>0)continue; + if(floor!=20000)continue; + if(CHAR_getInt( charaindex, CHAR_AUTOPK ) == -1)continue; + if(CHAR_getInt( toindex, CHAR_AUTOPK ) == -1)continue; + } +#endif + // shan begin + { + int i; + for( i=0; i 1 ) { + int strlength; + char msgbuf[1024]; + char escapebuf[2048]; + strcpy( msgbuf, "1\nҪ˭ս\n"); + strlength = strlen( msgbuf); + for( i = 0; + CONNECT_getDuelcharaindex( fd,i) != -1 + && i< CONNECT_WINDOWBUFSIZE; + i ++ ) + { + char *a = CHAR_getChar( + CONNECT_getDuelcharaindex( fd,i) , CHAR_NAME); + char buf[256]; + snprintf( buf, sizeof( buf),"%s [%s]\n", a, + CHAR_getWorkInt( + CONNECT_getDuelcharaindex(fd,i), + CHAR_WORKPARTYMODE ) + != CHAR_PARTY_NONE ? "": ""); + if( strlength + strlen( buf) > arraysizeof( msgbuf)){ + print( "%s:%dӴѶϢbuffer㡣\n", + __FILE__,__LINE__); + break; + } + strcpy( &msgbuf[strlength], buf); + strlength += strlen(buf); + } + + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_SELECT, + WINDOW_BUTTONTYPE_CANCEL, + CHAR_WINDOWTYPE_SELECTDUEL, + -1, + makeEscapeString( msgbuf, escapebuf, sizeof(escapebuf))); + ret = TRUE; + } + } + + +lssproto_DU_recv_Err:; + if( ret == FALSE ) { + /* ˪ */ + lssproto_EN_send( fd, FALSE, 0 ); + if( cnt > 0 ) CHAR_talkToCli( charaindex, -1, "ʧܣ", CHAR_COLORYELLOW); + else if( found ) CHAR_talkToCli( charaindex, -1, "˿Զս", CHAR_COLORYELLOW); + else CHAR_talkToCli( charaindex, -1, "ûκˡ", CHAR_COLORYELLOW); + } +} +/*------------------------------------------------------------ + ------------------------------------------------------------*/ +void lssproto_EO_recv( int fd, int dummy ) +{ + int fd_charaindex; + int battle_index;//ttom++ + CHECKFD; + fd_charaindex = CONNECT_getCharaindex( fd ); + BattleEncountOut( fd_charaindex ); + // Nuke start 0827 : Battle acceleration + battle_index=CHAR_getWorkInt(fd_charaindex,CHAR_WORKBATTLEINDEX); + if( BATTLE_CHECKINDEX( battle_index ) == FALSE ){ + return; + } + if(BattleArray[battle_index].type != BATTLE_TYPE_P_vs_P){ + if(CONNECT_get_watchmode(fd)) { + //print("fd= %d Watching the battle __ lssprot_EO_recv \n",fd);//for debug + CONNECT_set_watchmode(fd,FALSE); + return; + } + else if (checkBEOTime( fd ) < 0) { + //CHAR_talkToCli(fd_charaindex, -1, "ม", CHAR_COLORYELLOW); + } + } + // Nuke end +} + +/*------------------------------------------------------------ + ------------------------------------------------------------*/ +void lssproto_BU_recv( int fd, int dummy) +{ + int fd_charaindex; + CHECKFD; + fd_charaindex = CONNECT_getCharaindex( fd ); + // shan 2001/12/25 + //BATTLE_WatchStop( fd_charaindex ); +} + +void lssproto_B_recv( int fd, char *command ) +{ +// if(strlen(command)<3 && strstr(command,"&")!=NULL) +// return; + int fd_charaindex; + int battle_index;//ttom++ + CHECKFD; + fd_charaindex = CONNECT_getCharaindex( fd ); +#ifdef _NOJOB_PK + if(CHAR_getInt(fd_charaindex,CHAR_FLOOR)==getNoJobPkMap() && strncmp( command, "P", 1 ) == 0 ) + sprintf(command,"G"); +#endif + BattleCommandDispach( fd, command ); + // Nuke +1 0827: Battle acceleration + battle_index=CHAR_getWorkInt(fd_charaindex,CHAR_WORKBATTLEINDEX); + if( BATTLE_CHECKINDEX( battle_index ) == FALSE ){ + return; + } + if(BattleArray[battle_index].type != BATTLE_TYPE_P_vs_P){ + if(BattleArray[battle_index].type == BATTLE_TYPE_WATCH) { + CONNECT_set_watchmode(fd,TRUE); + return; + } + } + //Nuke end +} + +void lssproto_FS_recv( int fd,int flg ) +{ + int fd_charaindex; + CHECKFDANDTIME; + + fd_charaindex = CONNECT_getCharaindex( fd ); + /* ڱ幫׷ºޥ */ + if(CHAR_getWorkInt( fd_charaindex, CHAR_WORKSAFEMODE)==0) + { + if((flg & CHAR_FS_TRADE ) ==32 ) + { + CHAR_SafePassword(fd_charaindex); + return; + } + } + CHAR_setFlg( fd_charaindex, CHAR_ISPARTY, + (flg & CHAR_FS_PARTY )? TRUE:FALSE); + //CHAR_setFlg( fd_charaindex, CHAR_ISBATTLE, + // (flg & CHAR_FS_BATTLE )? TRUE:FALSE); + CHAR_setFlg( fd_charaindex, CHAR_ISDUEL, + (flg & CHAR_FS_DUEL )? TRUE:FALSE); + CHAR_setFlg( fd_charaindex, CHAR_ISPARTYCHAT, + (flg & CHAR_FS_PARTYCHAT )? TRUE:FALSE); + CHAR_setFlg( fd_charaindex, CHAR_ISTRADECARD, + (flg & CHAR_FS_TRADECARD )? TRUE:FALSE); +#ifdef _CHANNEL_MODIFY + //Ƶ + CHAR_setFlg(fd_charaindex,CHAR_ISTELL,(flg & CHAR_FS_TELL )? TRUE:FALSE); + //Ƶ + CHAR_setFlg(fd_charaindex,CHAR_ISFM,(flg & CHAR_FS_FM )? TRUE:FALSE); + //ְҵƵ + CHAR_setFlg(fd_charaindex,CHAR_ISOCC,(flg & CHAR_FS_OCC )? TRUE:FALSE); + // + CHAR_setFlg(fd_charaindex,CHAR_ISCHAT,(flg & CHAR_FS_CHAT )? TRUE:FALSE); + //Ի + CHAR_setFlg(fd_charaindex,CHAR_ISSAVE,(flg & CHAR_FS_SAVE )? TRUE:FALSE); + //Ƶ + if(getSaType()==95){ + CHAR_setFlg(fd_charaindex,CHAR_ISWORLD,(flg & CHAR_FS_WORLD )? TRUE:FALSE); + if(CHAR_getFlg(fd_charaindex,CHAR_ISWORLD)==FALSE) + CHAR_setWorkInt( fd_charaindex , CHAR_WORKALLTALKTYPE, 1); + else if(CHAR_getFlg(fd_charaindex,CHAR_ISWORLD)==TRUE) + CHAR_setWorkInt( fd_charaindex , CHAR_WORKALLTALKTYPE, 0); + } +#endif + // CoolFish: Trade 2001/4/18 + CHAR_setFlg( fd_charaindex, CHAR_ISTRADE, + (flg & CHAR_FS_TRADE )? TRUE:FALSE); + /* + if (CHAR_getFlg(fd_charaindex, CHAR_ISTRADECARD) == TRUE) + CHAR_setFlg(fd_charaindex, CHAR_ISTRADE, FALSE); + if (CHAR_getFlg(fd_charaindex, CHAR_ISTRADE) == TRUE) + CHAR_setFlg(fd_charaindex, CHAR_ISTRADECARD, FALSE); + */ + + lssproto_FS_send( fd, flg); +} +/*------------------------------------------------------------ + ------------------------------------------------------------*/ +void lssproto_PR_recv( int fd,int x, int y, int request ) +{ + int result = FALSE; + int fd_charaindex; + CHECKFDANDTIME; + + fd_charaindex = CONNECT_getCharaindex( fd ); + +#if 1 // ֹ + if( request == 1 ) + { + int nowFloor; + nowFloor = CHAR_getInt( fd_charaindex, CHAR_FLOOR); + if( nowFloor == 31706 + || nowFloor == 10204 + || (10601 <= nowFloor && nowFloor <= 10605 ) + || nowFloor == 10919 || nowFloor == 10920 + || nowFloor == 20711 || nowFloor == 20712 + || nowFloor == 1008 || nowFloor == 1021 + || nowFloor == 3008 || nowFloor == 3021 + || ( nowFloor <= 8213 && nowFloor >= 8200 ) + || ( nowFloor >= 30017 && nowFloor <= 30021 ) +#ifdef _TIME_TICKET + || check_TimeTicketMap(nowFloor) +#endif + ){ + //print("\n ķ!ֹ!!:%s ", CHAR_getChar( fd_charaindex, CHAR_CDKEY) ); + return; + } + } +#endif + + {//ttom avoid warp at will + int ix,iy; + ix=CHAR_getInt(fd_charaindex, CHAR_X); + iy=CHAR_getInt(fd_charaindex, CHAR_Y); + if( (ix!=x)||(iy!=y)){ + //print("\n--Error!!!!"); + //print("\norigion x=%d,y=%d",ix,iy); + //print("\nmodify X=%d,Y=%d",x,y); + x=ix; + y=iy; + } + } + CHAR_setMyPosition( fd_charaindex, x,y,TRUE); + + if( request == 0 ) { +#ifdef _PLAYER_NPC + if( CHAR_getWorkInt( fd_charaindex, CHAR_WORKPARTYMODE) == CHAR_PARTY_LEADER ) { + int i; + for( i = 0; i < CHAR_PARTYMAX; i ++ ) { + int pindex = CHAR_getWorkInt( fd_charaindex, i + CHAR_WORKPARTYINDEX1); + if( CHAR_CHECKINDEX( pindex) ) { + if(CHAR_getInt( pindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYERNPC){ + CHAR_setWorkInt( fd_charaindex, i + CHAR_WORKPARTYINDEX1, -1); + CHAR_CharaDelete(pindex); + continue; + } + } + } + } +#endif + /* */ + result = CHAR_DischargeParty(fd_charaindex, 0); + } + else if( request == 1 ) { + result = CHAR_JoinParty(fd_charaindex); + } +} +/*------------------------------------------------------------ + ------------------------------------------------------------*/ +void lssproto_KS_recv( int fd,int petarray ) +{ + int ret , fd_charaindex,petindex; + CHECKFDANDTIME; + fd_charaindex = CONNECT_getCharaindex( fd ); +#ifdef _PET_BUG + petindex = CHAR_getCharPet( fd_charaindex, petarray); + if( CHAR_CHECKINDEX( petindex ) == TRUE ){ + if(CHAR_getInt(petindex,CHAR_VITAL)>=getPetPoint(0)*20 || CHAR_getInt(petindex,CHAR_STR)>=getPetPoint(1)*80 || CHAR_getInt(petindex,CHAR_TOUGH)>=getPetPoint(2)*80 || CHAR_getInt(petindex,CHAR_DEX)>=getPetPoint(3)*100){ + lssproto_KS_send( fd, petarray, FALSE); + return; + } + } +#endif + if( CHAR_getInt( fd_charaindex, CHAR_RIDEPET) == petarray ) + lssproto_KS_send( fd, petarray, FALSE); + + + ret = PET_SelectBattleEntryPet( fd_charaindex, petarray); + lssproto_KS_send( fd, petarray, ret); +} + +#ifdef _STANDBYPET +void lssproto_SPET_recv( int fd, int standbypet ) +{ + int fd_charaindex; + int i, s_pet =0, cnt =0; + + CHECKFDANDTIME; + fd_charaindex = CONNECT_getCharaindex( fd ); + + if( CHAR_getWorkInt( fd_charaindex, CHAR_WORKBATTLEMODE) != BATTLE_CHARMODE_NONE + && standbypet >= CHAR_getWorkInt( fd_charaindex, CHAR_WORKSTANDBYPET) ) { + //print("\n ķ!??սSPETӴ!!:%s ", CHAR_getChar( fd_charaindex, CHAR_CDKEY) ); + return; + } + + //if( CHAR_getInt( fd_charaindex, CHAR_RIDEPET) == petarray ) { + // lssproto_SPET_send( fd, petarray, FALSE); + //} + + for( i =0; i < CHAR_MAXPETHAVE; i++) { + if( standbypet & ( 1 << i ) ) { + + //if( CHAR_getInt( fd_charaindex, CHAR_RIDEPET) == i ) + // continue; + + cnt++; + if( cnt > 3 ) { + //print("\n ķ!賬!!:%s ", CHAR_getChar( fd_charaindex, CHAR_CDKEY) ); + //lssproto_SPET_send( fd, s_pet, FALSE); + break; + } + + s_pet |= ( 1 << i ); + } + } + CHAR_setWorkInt( fd_charaindex, CHAR_WORKSTANDBYPET, s_pet); + + lssproto_SPET_send( fd, s_pet, TRUE); +} +#endif + +/*------------------------------------------------------------ + ------------------------------------------------------------*/ +void lssproto_AC_recv( int fd,int x, int y,int actionno ) +{ + int fd_charaindex; + CHECKFDANDTIME; + fd_charaindex = CONNECT_getCharaindex( fd ); + {//ttom avoid the warp at will + Char *ch; + ch = CHAR_getCharPointer( fd_charaindex); + // CoolFish: +1 2001/11/05 + if (!ch) return; + + if((ch->data[CHAR_X]!=x)||(ch->data[CHAR_Y]!=y)){ + return; + } + } + CHAR_setMyPosition( fd_charaindex, x,y,TRUE); + CHAR_sendAction( fd_charaindex, actionno, FALSE); + return; +} +/*------------------------------------------------------------ + ------------------------------------------------------------*/ +void lssproto_MU_recv( int fd,int x,int y,int array,int toindex ) +{ + int to_charaindex = -1, fd_charaindex; + CHECKFDANDTIME; + fd_charaindex = CONNECT_getCharaindex( fd ); + {//ttom avoid warp at will + int ix,iy; + ix=CHAR_getInt(fd_charaindex, CHAR_X); + iy=CHAR_getInt(fd_charaindex, CHAR_Y); + if( (ix!=x)||(iy!=y)){ + //print("\n--Error!!!!"); + //print("\norigion x=%d,y=%d",ix,iy); + //print("\nmodify X=%d,Y=%d",x,y); + x=ix; + y=iy; + } + } + + CHAR_setMyPosition( fd_charaindex, x,y,TRUE); + to_charaindex = Callfromcli_Util_getTargetCharaindex( fd, toindex); + MAGIC_Use( fd_charaindex, array, to_charaindex); +} + +void lssproto_JB_recv( int fd,int x,int y ) +{ + int charaindex, floor; + + CHECKFDANDTIME; + charaindex = CONNECT_getCharaindex( fd ); + { + int ix,iy; + ix=CHAR_getInt(charaindex, CHAR_X); + iy=CHAR_getInt(charaindex, CHAR_Y); + if( (ix!=x)||(iy!=y)){ + x=ix; + y=iy; + } + } + + CHAR_setMyPosition( charaindex, x,y,TRUE); + if( CHAR_CHECKINDEX( charaindex ) == FALSE )return; + floor = CHAR_getInt( charaindex, CHAR_FLOOR ); + if( floor == 1007 + || floor == 2007 + || floor == 3007 + || floor == 4007 + || floor == 130 + || floor == 40001 + || floor == 40002 + || floor == 40003 + || floor == 40004 + || floor == 40005 + || floor == 40006 + || floor == 40007 + || floor == 40008 + || floor == 40009 + || floor == 40010 +#ifdef _AUTO_PK + || (floor == 20000 && CHAR_getInt( charaindex, CHAR_AUTOPK ) == -1) +#endif +#ifdef _WATCH_FLOOR + || floor == getWatchFloor(1) + || floor == getWatchFloor(2) + || floor == getWatchFloor(3) + || floor == getWatchFloor(4) + || floor == getWatchFloor(5) + || !strcmp(getWatchFloorCF(),"") +#endif + ){ + BATTLE_WatchTry( charaindex ); + }else{ + BATTLE_RescueTry( charaindex ); + } +} + +void lssproto_KN_recv( int fd,int havepetindex,char* data ) +{ + int fd_charaindex; + CHECKFD; + fd_charaindex = CONNECT_getCharaindex( fd ); + + // Robin 04/26 debug + if( strlen(data) > 16 ) return; + + // CoolFish: Prevent Trade Cheat 2001/4/18 + if (CHAR_getWorkInt(fd_charaindex, CHAR_WORKTRADEMODE) != CHAR_TRADE_FREE) + return; + if( CHAR_getWorkInt(fd_charaindex,CHAR_WORKSTREETVENDOR)!=-1) return; + if( checkStringErr(data) ) return; +#ifdef _CHANGE_PETNAME_FIX + if(strstr(data,"|")!=NULL){ + CHAR_talkToCli( fd_charaindex, -1, "벻ҪзǷַ", CHAR_COLORRED); + return; + } +#endif + + CHAR_inputUserPetName( fd_charaindex, havepetindex, data); + +} +/*------------------------------------------------------------ + ------------------------------------------------------------*/ +void lssproto_WN_recv( int fd,int x,int y,int seqno, + int objindex,int select, char* data ) +{ +// printf("fd=%d\n",fd); +// printf("x=%d\n",x); +// printf("y=%d\n",y); +// printf("seqno=%d\n",seqno); +// printf("objindex=%d\n",objindex); +// printf("select=%d\n",select); +// printf("data=%s\n",data); +// if ( seqno == 285 && strlen(data) == 0 ) return; + + int fd_charaindex; + + CHECKFDANDTIME; + + if( checkStringErr(data) ) return; +#ifdef _NO_WARP + { + if(seqno!=CONNECT_get_seqno(fd)){ +// printf("get_seqno=%d\n",CONNECT_get_seqno(fd)); + return; + } + if( !( (select)&(CONNECT_get_selectbutton(fd)) ) && select ){ + if( CONNECT_get_seqno(fd)==CHAR_WINDOWTYPE_QUIZ_MAIN ){ + }else if( ( (CONNECT_get_seqno(fd)==CHAR_WINDOWTYPE_SCHEDULEMAN_START) + || (CONNECT_get_seqno(fd)==CHAR_WINDOWTYPE_SCHEDULEMAN_SELECT) ) + && (select==1) ){ + }else{ + return ; + } + } + } // shan End +#endif + fd_charaindex = CONNECT_getCharaindex( fd ); + +#ifdef _AVOIDATTACK_IN_lssproto_WN_recv_dataToLong + if( strlen(data) > 2048 ) + return ; +#endif +// if(seqno == 285 && CHAR_getWorkInt(fd_charaindex,CHAR_WORKWNKEY) == 285 ) return; +// CHAR_setWorkInt(fd_charaindex,CHAR_WORKWNKEY,seqno); + // CoolFish: Prevent Trade Cheat 2001/4/18 + if (CHAR_getWorkInt(fd_charaindex, CHAR_WORKTRADEMODE) != CHAR_TRADE_FREE) { + return; + } + // Robin + if( checkStringErr(data) ) return; + + +#ifdef _ANGEL_SUMMON + if( seqno == CHAR_WINDOWTYPE_ANGEL_ASK ) + { + print("\n CHAR_WINDOWTYPE_ANGEL_ASK objindex:%d select:%d data:%s ", + objindex, select, data ); + + if(select==WINDOW_BUTTONTYPE_YES ) { + if( AngelCreate( fd_charaindex) == FALSE ) { + sendAngelCleanToCli( fd ); + } + } + else if(select==WINDOW_BUTTONTYPE_NO ) { + int mindex; + char nameinfo[64]; + mindex = checkIfAngel( fd_charaindex); + print(" ====ٻ==== "); + getMissionNameInfo( fd_charaindex, nameinfo); + saacproto_ACMissionTable_send( acfd, mindex, 3, nameinfo, ""); + + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, -1, -1, + "ź\nİħΣ½ˡ" ); + + //CHAR_talkToCli( fd_charaindex, -1, "֮ǿϧѵõĻѽ", CHAR_COLORYELLOW); + + sendAngelCleanToCli( fd ); + } + } +#endif + +#ifdef _SAFE_PASSWORD + if( seqno == CHAR_WINDOWTYPE_SAFE_PASSWORD1 ) + { + char *cdkey; + cdkey = CHAR_getChar(fd_charaindex, CHAR_CDKEY); + if(strlen(data)>5 && strlen(data)<13) + { + saacproto_QuerySafePasswd_recv(NULL,cdkey,sasql_query_safepasswd(cdkey,data),fd_charaindex); + } + else + { + CHAR_talkToCli( fd_charaindex, -1, "İȫС6λ12λ룡", CHAR_COLORRED); + } + } + if( seqno == CHAR_WINDOWTYPE_SAFE_PASSWORD2 ) + { + char *cdkey; + cdkey = CHAR_getChar(fd_charaindex, CHAR_CDKEY); + if (strlen(data)<6 || strlen(data)>12) + { + CHAR_talkToCli( fd_charaindex, -1, "İȫС6λ12λ룡", CHAR_COLORRED); + } + else + { + saacproto_AddSafePasswd_recv( NULL, cdkey, sasql_add_safepasswd(cdkey,data), fd_charaindex ); + } + } + if( seqno == CHAR_WINDOWTYPE_SAFE_PASSWORD3 ) + { + char *cdkey; + cdkey = CHAR_getChar(fd_charaindex, CHAR_CDKEY); + if(strlen(data)>5 && strlen(data)<13) + { + int res = sasql_query_safepasswd(cdkey,data); + if(res == 1) + { + CHAR_setWorkInt( fd_charaindex, CHAR_WORKSAFEMODE, 1); + CHAR_setInt( fd_charaindex, CHAR_LOCK, 1); + CHAR_talkToCli( fd_charaindex, -1, "İȫȷϵͳɹý", CHAR_COLORRED); + } + if(res == 2) + { + CHAR_talkToCli( fd_charaindex, -1, "İȫϵͳ޷", CHAR_COLORRED); + } + if(res == 3) + { + CHAR_talkToCli( fd_charaindex, -1, "ûðȫ룬뾡ã", CHAR_COLORRED); + CHAR_AddSafePassword(fd_charaindex); + } + } + else + { + CHAR_talkToCli( fd_charaindex, -1, "İȫС6λ12λ룡", CHAR_COLORRED); + } + } +#endif + +#ifdef _POINT_CARD + if( seqno == CHAR_WINDOWTYPE_POINT_CARD ) + { + char *cdkey; + cdkey = CHAR_getChar(fd_charaindex, CHAR_CDKEY); + CHAR_talkToCli( fd_charaindex, -1, "ڲѯóֵϢԺ", CHAR_COLORRED); + sasql_query_card(cdkey,data,fd_charaindex); + } +#endif +#ifdef _SQL_BUY_FUNC + if( seqno == CHAR_WINDOWTYPE_ONLINE_BUY ){ + char *ondata = sasql_OnlineBuy( CHAR_getChar(fd_charaindex, CHAR_CDKEY), data ); + //saacproto_OnlineBuy_send(getfdFromCharaIndex( charaindex), CHAR_getChar(charaindex, CHAR_CDKEY), data); + CHAR_talkToCli( fd_charaindex, -1, "żУԺ...", CHAR_COLORYELLOW); + saacproto_OnlineBuy_recv(getfdFromCharaIndex( fd_charaindex),ondata); + } +#endif + if( seqno == CHAR_WINDOWTYPE_RAND_WARP ) + { + if( CHAR_getWorkInt( fd_charaindex, CHAR_WORKPARTYMODE ) == CHAR_PARTY_LEADER || CHAR_getWorkInt( fd_charaindex, CHAR_WORKPARTYMODE ) == CHAR_PARTY_CLIENT) + { + CHAR_talkToCli( fd_charaindex, -1, "˵ֻԵʹã", CHAR_COLORRED); + return; + } + char *arg; + char buftest[255]; + int haveitemindex,pass,fltest,xtest,ytest; + arg = CHAR_getWorkChar(fd_charaindex,CHAR_WORKRANDMSG); + if(getStringFromIndexWithDelim(arg,"|", 1, buftest, sizeof(buftest)) == FALSE) + return; + haveitemindex = atoi(buftest); + if(getStringFromIndexWithDelim(arg,"|", 2, buftest, sizeof(buftest)) == FALSE) + return; + pass = atoi(buftest); + if(getStringFromIndexWithDelim(arg,"|", 3, buftest, sizeof(buftest)) == FALSE) + return; + fltest = atoi(buftest); + if(getStringFromIndexWithDelim(arg,"|", 4, buftest, sizeof(buftest)) == FALSE) + return; + xtest = atoi(buftest); + if(getStringFromIndexWithDelim(arg,"|", 5, buftest, sizeof(buftest)) == FALSE) + return; + ytest = atoi(buftest); + + if(strlen(data)<1) + { + CHAR_talkToCli( fd_charaindex, -1, "֤룡", CHAR_COLORRED); + return; + } + if(pass!=atoi(data)) + { + CHAR_talkToCli( fd_charaindex, -1, "֤벻ȷ룡", CHAR_COLORRED); + return; + } + CHAR_warpToSpecificPoint(fd_charaindex, fltest, xtest, ytest); + CHAR_DelItem( fd_charaindex, haveitemindex); + } + + if( seqno == CHAR_WINDOWTYPE_RAND_MSG ) + { + char *arg; + char buftest[255]; + int haveitemindex,pass; + char *itemmsg; + arg = CHAR_getWorkChar(fd_charaindex,CHAR_WORKRANDMSG); + if(getStringFromIndexWithDelim(arg,"|", 1, buftest, sizeof(buftest)) == FALSE) + return; + haveitemindex = atoi(buftest); + if(getStringFromIndexWithDelim(arg,"|", 2, buftest, sizeof(buftest)) == FALSE) + return; + pass = atoi(buftest); + if(getStringFromIndexWithDelim(arg,"|", 3, buftest, sizeof(buftest)) == FALSE) + return; + itemmsg = buftest; + + if(strlen(data)<1) + { + CHAR_talkToCli( fd_charaindex, -1, "֤룡", CHAR_COLORRED); + return; + } + if(pass!=atoi(data)) + { + CHAR_talkToCli( fd_charaindex, -1, "֤벻ȷ룡", CHAR_COLORRED); + return; + } + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + CHAR_WINDOWTYPE_ITEM_MSG, + -1, + itemmsg); + } + if( seqno == CHAR_STREETVENDOR_SELECT ) + { + if(strlen(data)<1) return; + if(atoi(data)>6 || atoi(data)<1) return; + if(atoi(data)==4 && getJiFenBaiTan()==1){ + CHAR_talkToCli( fd_charaindex, -1, "·ְ̯", CHAR_COLORRED); + return; + } + CHAR_setWorkInt(fd_charaindex,CHAR_WORKTRADETYPE,(atoi(data)-1)); + lssproto_STREET_VENDOR_send(fd,"O|"); + } +#ifdef _QUESTION_ONLINE + if( seqno == CHAR_WINDOWTYPE_QUESTIONONLINE ) + { + if(strlen(data)<1) return; + time_t timep; + struct tm *p; + time(&timep); + p=localtime(&timep); + timep = mktime(p); + if(questionstarttime == 0){ + CHAR_talkToCli( fd_charaindex, -1, "ߴѽδʼ", CHAR_COLORYELLOW); + return; + } + if(timep - questionstarttime > 30 || questionman>=3){ + CHAR_talkToCli( fd_charaindex, -1, "ʱѹ", CHAR_COLORYELLOW); + return; + } + if(strcmp(data,answer)==0) + { + if(questionman<3) + { + questionman++; + int itemindex,playnum,itemret; + itemindex = ITEM_makeItemAndRegist( getQuestionItem(questionman)); + itemret = CHAR_addItemSpecificItemIndex(fd_charaindex,itemindex); + if( itemret < 0 || itemret >= CHAR_MAXITEMHAVE ) + { + ITEM_endExistItemsOne( itemindex); + } + char questionbuf[256]; + sprintf(questionbuf,"ϲϲ%s%dԱ⣡",CHAR_getChar(fd_charaindex,CHAR_NAME),questionman); + int i,playmaxnum; + playmaxnum=CHAR_getPlayerMaxNum(); + for( i = 0 ; i < playmaxnum ; i++) { + if( CHAR_getCharUse(i) != FALSE ) { + CHAR_talkToCli( i, -1, questionbuf, CHAR_COLORRED); + } + } + } + } + } +#endif +#ifdef _PET_RESET + if( seqno == CHAR_WINDOWTYPE_RESETPET ) + { + if(select == WINDOW_BUTTONTYPE_YES){ + int petworkindex,petindex,i; + petworkindex = CHAR_getWorkInt(fd_charaindex,CHAR_WORKRESETPETINDEX); + int petpoint = sasql_resetpet_point(CHAR_getInt(petworkindex, CHAR_PETENEMYID)); + int mypoint = sasql_vippoint(CHAR_getChar(fd_charaindex,CHAR_CDKEY),0,0); + if(petpoint<0)return; + if(mypoint1000000){ + CHAR_talkToCli( fd_charaindex, -1, "֧ƱΪ100W㣬޷ǩ", CHAR_COLORYELLOW); + return; + } + char zhipiaomsg[256]; + int vippoint = atoi(data)*getZhiPiao()/100; + if(vippoint<10) vippoint = vippoint+1; + sprintf(zhipiaomsg,"\nǩ֧ƱҪȡٷ֮%d˰\n\n֧ƱǩҪ۳%dԱ\n\nȷҪô",getZhiPiao(),vippoint+atoi(data)); + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OKCANCEL, + CHAR_WINDOWTYPE_ZHIPIAO_2, + -1, + zhipiaomsg); + CHAR_setWorkInt(fd_charaindex,CHAR_WORKZHIPIAOPOINT,atoi(data)); + return; + }else + return; + } + if( seqno == CHAR_WINDOWTYPE_ZHIPIAO_2 ){ + if(select == WINDOW_BUTTONTYPE_OK){ + int mypoint = sasql_vippoint(CHAR_getChar(fd_charaindex,CHAR_CDKEY),0,0); + int itempoint = CHAR_getWorkInt(fd_charaindex,CHAR_WORKZHIPIAOPOINT); + int kvippoint = itempoint/100*getZhiPiao(); + if(kvippoint<10) kvippoint = kvippoint+1; + int vippoint = itempoint+kvippoint; + if(mypoint0){ + time_t timep; + struct tm *p; + time(&timep); + p=localtime(&timep); + timep = mktime(p); + int zhipiaotime = timep + 60*60*24*getPiaoTime(); + timep = zhipiaotime; + p=localtime(&timep); + sprintf(zhipiaomsg,"%d",zhipiaotime); + ITEM_setChar(itemindex,ITEM_ARGUMENT,zhipiaomsg); + int year=1900+p->tm_year; + int mon=1+p->tm_mon; + int date=p->tm_mday; + int hour=p->tm_hour; + int min=p->tm_min; + int sec=p->tm_sec; + char monbuf[5],datebuf[5],hourbuf[5],minbuf[5],secbuf[5]; + if(mon<10) sprintf(monbuf,"0%d",mon); + else sprintf(monbuf,"%d",mon); + if(date<10) sprintf(datebuf,"0%d",date); + else sprintf(datebuf,"%d",date); + if(hour<10) sprintf(hourbuf,"0%d",hour); + else sprintf(hourbuf,"%d",hour); + if(min<10) sprintf(minbuf,"0%d",min); + else sprintf(minbuf,"%d",min); + if(sec<10) sprintf(secbuf,"0%d",sec); + else sprintf(secbuf,"%d",sec); + sprintf(zhipiaomsg,"Ч:%d.%s.%s/%s:%s:%s ֧Ʊֵ%d",year,monbuf,datebuf,hourbuf,minbuf,secbuf,itempoint); + }else{ + ITEM_setChar(itemindex,ITEM_ARGUMENT,"1"); + sprintf(zhipiaomsg,"֧Ʊֵ%d",itempoint); + } + ITEM_setChar(itemindex,ITEM_EFFECTSTRING,zhipiaomsg); + CHAR_sendItemDataOne( fd_charaindex, CHAR_getWorkInt(fd_charaindex,CHAR_WORKZHIPIAOITEM)); + CHAR_talkToCli( fd_charaindex, -1, "֧Ʊɹ", CHAR_COLORRED); + CHAR_charSaveFromConnect(fd_charaindex, FALSE); + CHAR_talkToCli(fd_charaindex, -1, "ϵͳΪԶ浵", CHAR_COLORRED); + return; + }else{ + return; + } + } + }else{ + return; + } + } + if( seqno == CHAR_WINDOWTYPE_ZHIPIAO_3 ){ + if(select == WINDOW_BUTTONTYPE_OK){ + int itemindex = CHAR_getItemIndex(fd_charaindex,CHAR_getWorkInt(fd_charaindex,CHAR_WORKZHIPIAOITEM)); + char* petno = ITEM_getChar(itemindex,ITEM_UNIQUECODE); + int vippoint = sasql_zhipiao_query(ITEM_getChar(itemindex,ITEM_UNIQUECODE)); + if(vippoint>0){ + if(sasql_zhipiao_update(CHAR_getChar(fd_charaindex,CHAR_CDKEY),petno,0)==1){ + sasql_vippoint(CHAR_getChar(fd_charaindex,CHAR_CDKEY),vippoint,1); + char msgbuf[128]; + snprintf( msgbuf,sizeof( msgbuf), "֧Ʊ֧ȡɹ%dԱ㡣", + vippoint); + CHAR_talkToCli( fd_charaindex, -1, msgbuf, CHAR_COLORRED); + CHAR_DelItem(fd_charaindex,CHAR_getWorkInt(fd_charaindex,CHAR_WORKZHIPIAOITEM)); + CHAR_charSaveFromConnect(fd_charaindex, FALSE); + CHAR_talkToCli(fd_charaindex, -1, "ϵͳΪԶ浵", CHAR_COLORRED); + return; + }else{ + return; + } + }else{ + return; + } + }else{ + return; + } + } +#endif +#ifdef _NO_DROPITEM + if( seqno == CHAR_WINDOWTYPE_DROPITEM){ + if(select == WINDOW_BUTTONTYPE_OK){ + int itemcharaindex = CHAR_getWorkInt(fd_charaindex,CHAR_DROPITEMCHARAINDEX); + if(itemcharaindex>-1){ + CHAR_DropItem(fd_charaindex,itemcharaindex); + return; + }else{ + return; + } + }else{ + return; + } + } +#endif +#ifdef _ITEM_RESET + if( seqno == CHAR_WINDOWTYPE_RESETITEM){ + if(select == WINDOW_BUTTONTYPE_OK){ + int fromindex = CHAR_getWorkInt(fd_charaindex,CHAR_WORKFROMITEMINDEX); + int toindex = CHAR_getWorkInt(fd_charaindex,CHAR_WORKTOITEMINDEX); + int resetpoint,mypoint; + int itemid = ITEM_getInt(CHAR_getItemIndex( fd_charaindex, toindex),ITEM_ID); + resetpoint = sasql_itemreset_query(itemid); + if(resetpoint<0) return; + mypoint = sasql_vippoint(CHAR_getChar(fd_charaindex,CHAR_CDKEY),0,0); + if(mypoint-1){ + CHAR_DelItem(fd_charaindex,fromindex); + CHAR_DelItem(fd_charaindex,toindex); + int newitemindex,ret; + newitemindex = ITEM_makeItemAndRegist( itemid); + ret = CHAR_addItemSpecificItemIndex( fd_charaindex, newitemindex); + if( ret < 0 || ret >= CHAR_MAXITEMHAVE ) { + ITEM_endExistItemsOne( newitemindex); + return; + } + CHAR_sendItemDataOne( fd_charaindex, ret); + CHAR_charSaveFromConnect(fd_charaindex, FALSE); + CHAR_talkToCli(fd_charaindex, -1, "ϲ¯߳ɹϵͳԶΪ浵", CHAR_COLORRED); + return; + }else{ + return; + } + } + }else{ + return; + } + } + if( seqno == CHAR_WINDOWTYPE_DELITEM){ + if(select == WINDOW_BUTTONTYPE_OK){ + int fromindex = CHAR_getWorkInt(fd_charaindex,CHAR_WORKFROMITEMINDEX); + int toindex = CHAR_getWorkInt(fd_charaindex,CHAR_WORKTOITEMINDEX); + int delpoint,mypoint; + int itemid = ITEM_getInt(CHAR_getItemIndex( fd_charaindex, toindex),ITEM_ID); + delpoint = sasql_itemdel_query(itemid); + if(delpoint<0) return; + mypoint = sasql_vippoint(CHAR_getChar(fd_charaindex,CHAR_CDKEY),0,0); + { + if(sasql_vippoint(CHAR_getChar(fd_charaindex,CHAR_CDKEY),delpoint,1)>-1){ + CHAR_DelItem(fd_charaindex,fromindex); + CHAR_DelItem(fd_charaindex,toindex); + CHAR_charSaveFromConnect(fd_charaindex, FALSE); + CHAR_talkToCli(fd_charaindex, -1, "ϲյ߳ɹϵͳԶΪ浵", CHAR_COLORRED); + return; + }else{ + return; + } + } + }else{ + return; + } + } +#endif +#ifdef _ALL_RANDMODE + if( seqno == CHAR_WINDOWTYPE_RAND1_EDITBASE ) + { + if(strlen(data)<1) + { + CHAR_talkToCli( fd_charaindex, -1, "", CHAR_COLORRED); + return; + } + char *arg; + char buftest[255]; + int haveitemindex,itemindex,ret,toindex; + arg = CHAR_getWorkChar(fd_charaindex,CHAR_WORKRANDEDITBASE); + if(getStringFromIndexWithDelim(arg,"|", 1, buftest, sizeof(buftest)) == FALSE) + return; + itemindex = atoi(buftest); + if(getStringFromIndexWithDelim(arg,"|", 2, buftest, sizeof(buftest)) == FALSE) + return; + toindex = atoi(buftest); + if(getStringFromIndexWithDelim(arg,"|", 3, buftest, sizeof(buftest)) == FALSE) + return; + haveitemindex = atoi(buftest); + if(getStringFromIndexWithDelim(arg,"|", 4, buftest, sizeof(buftest)) == FALSE) + return; + ret = atoi(buftest); + if(atoi(data)!=ret){ + CHAR_talkToCli( fd_charaindex, -1, "ļȷ룡", CHAR_COLORRED); + return; + } + if(itemindex!=CHAR_getItemIndex( fd_charaindex, haveitemindex)){ + return; + } + //CHAR_setWorkInt(fd_charaindex,CHAR_WORKRANDEDITBASETIME,0); + CHAR_setChar(fd_charaindex,CHAR_RANDTYPE,""); + int i; + int work[4]; + int num=-1,type; + int LevelUpPoint,petrank; + char buf1[256]; + char buf2[][32]={"ɳ",";ɳ","ٶȳɳ","ɳ",""}; + char buf3[][32]={"","Ϊ","Ϊ"}; + if( !CHAR_CHECKINDEX( fd_charaindex ) ) return; + if( !CHAR_CHECKINDEX( toindex ) ) return; +//#define RAND(x,y) ((x-1)+1+ (int)( (double)(y-(x-1))*rand()/(RAND_MAX+1.0)) ) + if( !ITEM_CHECKINDEX(itemindex) ) return; + if( CHAR_getInt( toindex, CHAR_PETID) == 718 +#ifdef _PET_2LIMITLEVEL + || CHAR_getInt( toindex, CHAR_PETID) == 401 +#endif + ){ + + int maxnums=50; + + if( CHAR_getInt( toindex,CHAR_LV ) < 74 ) { + sprintf(buf1,"ҵ𣿺ร˱仯"); + CHAR_talkToCli( fd_charaindex, toindex, buf1, CHAR_COLORWHITE); + num = ITEM_MODIFYATTACK; + LevelUpPoint = CHAR_getInt( toindex, CHAR_ALLOCPOINT ); + petrank = CHAR_getInt( toindex, CHAR_PETRANK ); + work[3] =(( LevelUpPoint >> 24 ) & 0xFF); + work[0] = (( LevelUpPoint >> 16 ) & 0xFF); + work[1] = (( LevelUpPoint >> 8 ) & 0xFF); + work[2] = (( LevelUpPoint >> 0 ) & 0xFF); + for( i=0; i<4; i++) { + type = ITEM_getInt( itemindex, (num + i)); + work[i] += type; + strcpy( buf1,"\0"); + if( work[i] > maxnums ) { + sprintf(buf1,"%s Ѿﵽˡ", buf2[i]); + work[i] = maxnums; + }else if( work[i] < 0 ) { + sprintf(buf1,"%s ѾΪˡ", buf2[i]); + work[i] = 0; + }else { + if( type > 0 ) { + if( type > 2 ) + sprintf(buf1,"%s %s %s", buf2[i], buf3[0], ""); + else + sprintf(buf1,"%s %s %s", buf2[i], buf3[1], ""); + }else if( type < 0 ){ + sprintf(buf1,"%s %s %s", buf2[i], buf3[2], ""); + } + } + if( strcmp( buf1, "\0")) { + CHAR_talkToCli( fd_charaindex, toindex, buf1, CHAR_COLORWHITE); + } + } + + LevelUpPoint = ( work[3]<< 24) + ( work[0]<< 16) + ( work[1]<< 8) + ( work[2]<< 0); + CHAR_setInt( toindex, CHAR_ALLOCPOINT, LevelUpPoint); + CHAR_setInt( toindex, CHAR_PETRANK, petrank); + LogPetPointChange( + CHAR_getChar( fd_charaindex, CHAR_NAME ), + CHAR_getChar( fd_charaindex, CHAR_CDKEY ), + CHAR_getChar( fd_charaindex, CHAR_NAME), + toindex, 4, + CHAR_getInt( toindex, CHAR_LV), + "item_use", + CHAR_getInt( fd_charaindex, CHAR_FLOOR), + CHAR_getInt( fd_charaindex, CHAR_X ), + CHAR_getInt( fd_charaindex, CHAR_Y ) + ); + } + + }else { + sprintf(buf1,""); + } + CHAR_DelItem( fd_charaindex, haveitemindex); + //CHAR_setWorkInt(fd_charaindex,CHAR_WORKRANDTYPE,0); + return; + } + if( seqno == CHAR_WINDOWTYPE_RAND2_EDITBASE ) + { + if(strlen(data)<1) + { + return; + } + if(atoi(data)<1 || atoi(data)>5) return; + char *arg; + char buftest[255]; + int haveitemindex,itemindex,ret,toindex; + arg = CHAR_getWorkChar(fd_charaindex,CHAR_WORKRANDEDITBASE); + if(getStringFromIndexWithDelim(arg,"|", 1, buftest, sizeof(buftest)) == FALSE) + return; + itemindex = atoi(buftest); + if(getStringFromIndexWithDelim(arg,"|", 2, buftest, sizeof(buftest)) == FALSE) + return; + toindex = atoi(buftest); + if(getStringFromIndexWithDelim(arg,"|", 3, buftest, sizeof(buftest)) == FALSE) + return; + haveitemindex = atoi(buftest); + if(getStringFromIndexWithDelim(arg,"|", 4, buftest, sizeof(buftest)) == FALSE) + return; + ret = atoi(buftest); + if(atoi(data)!=ret){ + CHAR_talkToCli( fd_charaindex, -1, "źѡļԺԡ", CHAR_COLORRED); + return; + } + if(itemindex!=CHAR_getItemIndex( fd_charaindex, haveitemindex)){ + return; + } + //CHAR_setWorkInt(fd_charaindex,CHAR_WORKRANDEDITBASETIME,0); + CHAR_setChar(fd_charaindex,CHAR_RANDTYPE,""); + CHAR_talkToCli( fd_charaindex, -1, "ϲѡļȷ", CHAR_COLORRED); + int i; + int work[4]; + int num=-1,type; + int LevelUpPoint,petrank; + char buf1[256]; + char buf2[][32]={"ɳ",";ɳ","ٶȳɳ","ɳ",""}; + char buf3[][32]={"","Ϊ","Ϊ"}; + if( !CHAR_CHECKINDEX( fd_charaindex ) ) return; + if( !CHAR_CHECKINDEX( toindex ) ) return; +//#define RAND(x,y) ((x-1)+1+ (int)( (double)(y-(x-1))*rand()/(RAND_MAX+1.0)) ) + if( !ITEM_CHECKINDEX(itemindex) ) return; + if( CHAR_getInt( toindex, CHAR_PETID) == 718 +#ifdef _PET_2LIMITLEVEL + || CHAR_getInt( toindex, CHAR_PETID) == 401 +#endif + ){ + + int maxnums=50; + + if( CHAR_getInt( toindex,CHAR_LV ) < 74 ) { + sprintf(buf1,"ҵ𣿺ร˱仯"); + CHAR_talkToCli( fd_charaindex, toindex, buf1, CHAR_COLORWHITE); + num = ITEM_MODIFYATTACK; + LevelUpPoint = CHAR_getInt( toindex, CHAR_ALLOCPOINT ); + petrank = CHAR_getInt( toindex, CHAR_PETRANK ); + work[3] =(( LevelUpPoint >> 24 ) & 0xFF); + work[0] = (( LevelUpPoint >> 16 ) & 0xFF); + work[1] = (( LevelUpPoint >> 8 ) & 0xFF); + work[2] = (( LevelUpPoint >> 0 ) & 0xFF); + for( i=0; i<4; i++) { + type = ITEM_getInt( itemindex, (num + i)); + work[i] += type; + strcpy( buf1,"\0"); + if( work[i] > maxnums ) { + sprintf(buf1,"%s Ѿﵽˡ", buf2[i]); + work[i] = maxnums; + }else if( work[i] < 0 ) { + sprintf(buf1,"%s ѾΪˡ", buf2[i]); + work[i] = 0; + }else { + if( type > 0 ) { + if( type > 2 ) + sprintf(buf1,"%s %s %s", buf2[i], buf3[0], ""); + else + sprintf(buf1,"%s %s %s", buf2[i], buf3[1], ""); + }else if( type < 0 ){ + sprintf(buf1,"%s %s %s", buf2[i], buf3[2], ""); + } + } + if( strcmp( buf1, "\0")) { + CHAR_talkToCli( fd_charaindex, toindex, buf1, CHAR_COLORWHITE); + } + } + + LevelUpPoint = ( work[3]<< 24) + ( work[0]<< 16) + ( work[1]<< 8) + ( work[2]<< 0); + CHAR_setInt( toindex, CHAR_ALLOCPOINT, LevelUpPoint); + CHAR_setInt( toindex, CHAR_PETRANK, petrank); + LogPetPointChange( + CHAR_getChar( fd_charaindex, CHAR_NAME ), + CHAR_getChar( fd_charaindex, CHAR_CDKEY ), + CHAR_getChar( fd_charaindex, CHAR_NAME), + toindex, 4, + CHAR_getInt( toindex, CHAR_LV), + "item_use", + CHAR_getInt( fd_charaindex, CHAR_FLOOR), + CHAR_getInt( fd_charaindex, CHAR_X ), + CHAR_getInt( fd_charaindex, CHAR_Y ) + ); + } + + }else { + sprintf(buf1,""); + } + CHAR_DelItem( fd_charaindex, haveitemindex); + //CHAR_setWorkInt(fd_charaindex,CHAR_WORKRANDTYPE,0); + return; + } + if( seqno == CHAR_WINDOWTYPE_RAND3_EDITBASE ) + { + if(strlen(data)<1) + { + CHAR_talkToCli( fd_charaindex, -1, "", CHAR_COLORRED); + return; + } + char *arg; + char buftest[255]; + int haveitemindex,itemindex,toindex; + char ret[255]; + arg = CHAR_getWorkChar(fd_charaindex,CHAR_WORKRANDEDITBASE); + if(getStringFromIndexWithDelim(arg,"|", 1, buftest, sizeof(buftest)) == FALSE) + return; + itemindex = atoi(buftest); + if(getStringFromIndexWithDelim(arg,"|", 2, buftest, sizeof(buftest)) == FALSE) + return; + toindex = atoi(buftest); + if(getStringFromIndexWithDelim(arg,"|", 3, buftest, sizeof(buftest)) == FALSE) + return; + haveitemindex = atoi(buftest); + if(getStringFromIndexWithDelim(arg,"|", 4, buftest, sizeof(buftest)) == FALSE) + return; + strcpy(ret,buftest); + if(strcmp(ret,data)!=0){ + CHAR_talkToCli( fd_charaindex, -1, "Ľȷ룡", CHAR_COLORRED); + return; + } + if(itemindex!=CHAR_getItemIndex( fd_charaindex, haveitemindex)){ + return; + } + //CHAR_setWorkInt(fd_charaindex,CHAR_WORKRANDEDITBASETIME,0); + CHAR_setChar(fd_charaindex,CHAR_RANDTYPE,""); + int i; + int work[4]; + int num=-1,type; + int LevelUpPoint,petrank; + char buf1[256]; + char buf2[][32]={"ɳ",";ɳ","ٶȳɳ","ɳ",""}; + char buf3[][32]={"","Ϊ","Ϊ"}; + if( !CHAR_CHECKINDEX( fd_charaindex ) ) return; + if( !CHAR_CHECKINDEX( toindex ) ) return; +//#define RAND(x,y) ((x-1)+1+ (int)( (double)(y-(x-1))*rand()/(RAND_MAX+1.0)) ) + if( !ITEM_CHECKINDEX(itemindex) ) return; + if( CHAR_getInt( toindex, CHAR_PETID) == 718 +#ifdef _PET_2LIMITLEVEL + || CHAR_getInt( toindex, CHAR_PETID) == 401 +#endif + ){ + + int maxnums=50; + + if( CHAR_getInt( toindex,CHAR_LV ) < 74 ) { + sprintf(buf1,"ҵ𣿺ร˱仯"); + CHAR_talkToCli( fd_charaindex, toindex, buf1, CHAR_COLORWHITE); + num = ITEM_MODIFYATTACK; + LevelUpPoint = CHAR_getInt( toindex, CHAR_ALLOCPOINT ); + petrank = CHAR_getInt( toindex, CHAR_PETRANK ); + work[3] =(( LevelUpPoint >> 24 ) & 0xFF); + work[0] = (( LevelUpPoint >> 16 ) & 0xFF); + work[1] = (( LevelUpPoint >> 8 ) & 0xFF); + work[2] = (( LevelUpPoint >> 0 ) & 0xFF); + for( i=0; i<4; i++) { + type = ITEM_getInt( itemindex, (num + i)); + work[i] += type; + strcpy( buf1,"\0"); + if( work[i] > maxnums ) { + sprintf(buf1,"%s Ѿﵽˡ", buf2[i]); + work[i] = maxnums; + }else if( work[i] < 0 ) { + sprintf(buf1,"%s ѾΪˡ", buf2[i]); + work[i] = 0; + }else { + if( type > 0 ) { + if( type > 2 ) + sprintf(buf1,"%s %s %s", buf2[i], buf3[0], ""); + else + sprintf(buf1,"%s %s %s", buf2[i], buf3[1], ""); + }else if( type < 0 ){ + sprintf(buf1,"%s %s %s", buf2[i], buf3[2], ""); + } + } + if( strcmp( buf1, "\0")) { + CHAR_talkToCli( fd_charaindex, toindex, buf1, CHAR_COLORWHITE); + } + } + + LevelUpPoint = ( work[3]<< 24) + ( work[0]<< 16) + ( work[1]<< 8) + ( work[2]<< 0); + CHAR_setInt( toindex, CHAR_ALLOCPOINT, LevelUpPoint); + CHAR_setInt( toindex, CHAR_PETRANK, petrank); + LogPetPointChange( + CHAR_getChar( fd_charaindex, CHAR_NAME ), + CHAR_getChar( fd_charaindex, CHAR_CDKEY ), + CHAR_getChar( fd_charaindex, CHAR_NAME), + toindex, 4, + CHAR_getInt( toindex, CHAR_LV), + "item_use", + CHAR_getInt( fd_charaindex, CHAR_FLOOR), + CHAR_getInt( fd_charaindex, CHAR_X ), + CHAR_getInt( fd_charaindex, CHAR_Y ) + ); + } + + }else { + sprintf(buf1,""); + } + CHAR_DelItem( fd_charaindex, haveitemindex); + //CHAR_setWorkInt(fd_charaindex,CHAR_WORKRANDTYPE,0); + return; + } + if( seqno == CHAR_WINDOWTYPE_RAND4_EDITBASE ) + { + if(strlen(data)<1) + { + return; + } + //if(atoi(data)getRandMax()) return; + if(CHAR_getWorkInt(fd_charaindex,CHAR_WORKLUANPCINT)!=0) return; + CHAR_setWorkInt(fd_charaindex,CHAR_WORKLUANPCINT,1); + int cdkeynum; + for(cdkeynum=9;cdkeynum>0;cdkeynum--){ + strcpy(mmcdkey[cdkeynum],mmcdkey[cdkeynum-1]); + strcpy(mmcdkeybuf[cdkeynum],mmcdkeybuf[cdkeynum-1]); + } + strcpy(mmcdkey[0],CHAR_getChar(fd_charaindex,CHAR_CDKEY)); + sprintf(mmcdkeybuf[0],"%d.%d.%d",CHAR_getInt(fd_charaindex,CHAR_FLOOR),CHAR_getInt(fd_charaindex,CHAR_X),CHAR_getInt(fd_charaindex,CHAR_Y)); + time_t timep; + struct tm *p; + time(&timep); + p=localtime(&timep); + timep = mktime(p); + CHAR_setWorkInt(fd_charaindex,CHAR_WORKRANDEDITBASETIME,timep); + char *arg; + char buftest[255]; + int haveitemindex,itemindex,ret,toindex; + arg = CHAR_getWorkChar(fd_charaindex,CHAR_WORKRANDEDITBASE); + if(getStringFromIndexWithDelim(arg,"|", 1, buftest, sizeof(buftest)) == FALSE) + return; + itemindex = atoi(buftest); + if(getStringFromIndexWithDelim(arg,"|", 2, buftest, sizeof(buftest)) == FALSE) + return; + toindex = atoi(buftest); + if(getStringFromIndexWithDelim(arg,"|", 3, buftest, sizeof(buftest)) == FALSE) + return; + haveitemindex = atoi(buftest); + if(getStringFromIndexWithDelim(arg,"|", 4, buftest, sizeof(buftest)) == FALSE) + return; + ret = atoi(buftest); + if(atoi(data)!=ret){ + if(ret>=1 && ret<=5){ + if(atoi(data)>=10000){ + sasql_cdkey_lock(CHAR_getChar(fd_charaindex,CHAR_CDKEY),15); + CONNECT_setCloseRequest( fd , 1 ); + return; + } + }else{ + if(atoi(data)>=1 && atoi(data)<=5){ + //sasql_cdkey_lock(CHAR_getChar(fd_charaindex,CHAR_CDKEY),14); + CONNECT_setCloseRequest( fd , 1 ); + return; + } + } + CHAR_talkToCli( fd_charaindex, -1, "źĽԺԡ", CHAR_COLORRED); + return; + } + if(itemindex!=CHAR_getItemIndex( fd_charaindex, haveitemindex)){ + return; + } + //CHAR_setWorkInt(fd_charaindex,CHAR_WORKRANDEDITBASETIME,0); + CHAR_setChar(fd_charaindex,CHAR_RANDTYPE,""); + CHAR_talkToCli( fd_charaindex, -1, "ϲĽȷ", CHAR_COLORRED); + int i; + int work[4]; + int num=-1,type; + int LevelUpPoint,petrank; + char buf1[256]; + char buf2[][32]={"ɳ",";ɳ","ٶȳɳ","ɳ",""}; + char buf3[][32]={"","Ϊ","Ϊ"}; + if( !CHAR_CHECKINDEX( fd_charaindex ) ) return; + if( !CHAR_CHECKINDEX( toindex ) ) return; +//#define RAND(x,y) ((x-1)+1+ (int)( (double)(y-(x-1))*rand()/(RAND_MAX+1.0)) ) + if( !ITEM_CHECKINDEX(itemindex) ) return; + if( CHAR_getInt( toindex, CHAR_PETID) == 718 +#ifdef _PET_2LIMITLEVEL + || CHAR_getInt( toindex, CHAR_PETID) == 401 +#endif + ){ + + int maxnums=50; + + if( CHAR_getInt( toindex,CHAR_LV ) < 74 ) { + sprintf(buf1,"ҵ𣿺ร˱仯"); + CHAR_talkToCli( fd_charaindex, toindex, buf1, CHAR_COLORWHITE); + num = ITEM_MODIFYATTACK; + LevelUpPoint = CHAR_getInt( toindex, CHAR_ALLOCPOINT ); + petrank = CHAR_getInt( toindex, CHAR_PETRANK ); + work[3] =(( LevelUpPoint >> 24 ) & 0xFF); + work[0] = (( LevelUpPoint >> 16 ) & 0xFF); + work[1] = (( LevelUpPoint >> 8 ) & 0xFF); + work[2] = (( LevelUpPoint >> 0 ) & 0xFF); + for( i=0; i<4; i++) { + type = ITEM_getInt( itemindex, (num + i)); + work[i] += type; + strcpy( buf1,"\0"); + if( work[i] > maxnums ) { + sprintf(buf1,"%s Ѿﵽˡ", buf2[i]); + work[i] = maxnums; + }else if( work[i] < 0 ) { + sprintf(buf1,"%s ѾΪˡ", buf2[i]); + work[i] = 0; + }else { + if( type > 0 ) { + if( type > 2 ) + sprintf(buf1,"%s %s %s", buf2[i], buf3[0], ""); + else + sprintf(buf1,"%s %s %s", buf2[i], buf3[1], ""); + }else if( type < 0 ){ + sprintf(buf1,"%s %s %s", buf2[i], buf3[2], ""); + } + } + if( strcmp( buf1, "\0")) { + CHAR_talkToCli( fd_charaindex, toindex, buf1, CHAR_COLORWHITE); + } + } + + LevelUpPoint = ( work[3]<< 24) + ( work[0]<< 16) + ( work[1]<< 8) + ( work[2]<< 0); + CHAR_setInt( toindex, CHAR_ALLOCPOINT, LevelUpPoint); + CHAR_setInt( toindex, CHAR_PETRANK, petrank); + LogPetPointChange( + CHAR_getChar( fd_charaindex, CHAR_NAME ), + CHAR_getChar( fd_charaindex, CHAR_CDKEY ), + CHAR_getChar( fd_charaindex, CHAR_NAME), + toindex, 4, + CHAR_getInt( toindex, CHAR_LV), + "item_use", + CHAR_getInt( fd_charaindex, CHAR_FLOOR), + CHAR_getInt( fd_charaindex, CHAR_X ), + CHAR_getInt( fd_charaindex, CHAR_Y ) + ); + } + + }else { + sprintf(buf1,""); + } + CHAR_DelItem( fd_charaindex, haveitemindex); + //CHAR_setWorkInt(fd_charaindex,CHAR_WORKRANDTYPE,0); + return; + } +#endif +#ifdef _MM_NO_JIAOBEN + if( seqno == CHAR_WINDOWTYPE_RAND1_DROPMM ) + { + if(strlen(data)<1) + { + CHAR_talkToCli( fd_charaindex, -1, "", CHAR_COLORRED); + return; + } + char *arg; + char buftest[255]; + int havepetindex,ret; + arg = CHAR_getWorkChar(fd_charaindex,CHAR_WORKDROPMM); + if(getStringFromIndexWithDelim(arg,"|", 1, buftest, sizeof(buftest)) == FALSE) + return; + havepetindex = atoi(buftest); + if(getStringFromIndexWithDelim(arg,"|", 2, buftest, sizeof(buftest)) == FALSE) + return; + ret = atoi(buftest); + if(atoi(data)!=ret){ + CHAR_talkToCli( fd_charaindex, -1, "ļȷ룡", CHAR_COLORRED); + return; + } + //CHAR_setWorkInt(fd_charaindex,CHAR_WORKRANDEDITBASETIME,0); + CHAR_setChar(fd_charaindex,CHAR_RANDTYPE,""); + int petindex; + petindex = CHAR_getCharPet(fd_charaindex,havepetindex); + if( !CHAR_CHECKINDEX( petindex )) return; + if(CHAR_getInt(petindex,CHAR_PETID)!=718 && CHAR_getInt(petindex,CHAR_PETID)!=401) return; + PET_dropPetFLXY(fd_charaindex, havepetindex, -1,-1,-1); + //CHAR_setWorkInt(fd_charaindex,CHAR_WORKRANDTYPE,0); + return; + } + if( seqno == CHAR_WINDOWTYPE_RAND2_DROPMM ) + { + if(strlen(data)<1) + { + return; + } + if(atoi(data)<1 || atoi(data)>5) return; + char *arg; + char buftest[255]; + int havepetindex,ret; + arg = CHAR_getWorkChar(fd_charaindex,CHAR_WORKDROPMM); + if(getStringFromIndexWithDelim(arg,"|", 1, buftest, sizeof(buftest)) == FALSE) + return; + havepetindex = atoi(buftest); + if(getStringFromIndexWithDelim(arg,"|", 2, buftest, sizeof(buftest)) == FALSE) + return; + ret = atoi(buftest); + if(atoi(data)!=ret){ + CHAR_talkToCli( fd_charaindex, -1, "źѡļԺԡ", CHAR_COLORRED); + return; + } + //CHAR_setWorkInt(fd_charaindex,CHAR_WORKRANDEDITBASETIME,0); + CHAR_setChar(fd_charaindex,CHAR_RANDTYPE,""); + CHAR_talkToCli( fd_charaindex, -1, "ϲѡļȷ", CHAR_COLORRED); + int petindex; + petindex = CHAR_getCharPet(fd_charaindex,havepetindex); + if( !CHAR_CHECKINDEX( petindex )) return; + if(CHAR_getInt(petindex,CHAR_PETID)!=718 && CHAR_getInt(petindex,CHAR_PETID)!=401) return; + PET_dropPetFLXY(fd_charaindex, havepetindex, -1,-1,-1); + //CHAR_setWorkInt(fd_charaindex,CHAR_WORKRANDTYPE,0); + return; + } + if( seqno == CHAR_WINDOWTYPE_RAND3_DROPMM ) + { + if(strlen(data)<1) + { + CHAR_talkToCli( fd_charaindex, -1, "", CHAR_COLORRED); + return; + } + char *arg; + char buftest[255]; + int havepetindex; + char ret[255]; + arg = CHAR_getWorkChar(fd_charaindex,CHAR_WORKDROPMM); + if(getStringFromIndexWithDelim(arg,"|", 1, buftest, sizeof(buftest)) == FALSE) + return; + havepetindex = atoi(buftest); + if(getStringFromIndexWithDelim(arg,"|", 2, buftest, sizeof(buftest)) == FALSE) + return; + strcpy(ret,buftest); + if(strcmp(ret,data)!=0){ + CHAR_talkToCli( fd_charaindex, -1, "Ľȷ룡", CHAR_COLORRED); + return; + } + //CHAR_setWorkInt(fd_charaindex,CHAR_WORKRANDEDITBASETIME,0); + CHAR_setChar(fd_charaindex,CHAR_RANDTYPE,""); + int petindex; + petindex = CHAR_getCharPet(fd_charaindex,havepetindex); + if( !CHAR_CHECKINDEX( petindex )) return; + if(CHAR_getInt(petindex,CHAR_PETID)!=718 && CHAR_getInt(petindex,CHAR_PETID)!=401) return; + PET_dropPetFLXY(fd_charaindex, havepetindex, -1,-1,-1); + //CHAR_setWorkInt(fd_charaindex,CHAR_WORKRANDTYPE,0); + return; + } + if( seqno == CHAR_WINDOWTYPE_RAND4_DROPMM ) + { + if(strlen(data)<1) + { + return; + } + //if(atoi(data)getRandMax()) return; + if(CHAR_getWorkInt(fd_charaindex,CHAR_WORKLUANPCINT)!=0) return; + CHAR_setWorkInt(fd_charaindex,CHAR_WORKLUANPCINT,1); + int cdkeynum; + for(cdkeynum=9;cdkeynum>0;cdkeynum--){ + strcpy(mmcdkey[cdkeynum],mmcdkey[cdkeynum-1]); + strcpy(mmcdkeybuf[cdkeynum],mmcdkeybuf[cdkeynum-1]); + } + strcpy(mmcdkey[0],CHAR_getChar(fd_charaindex,CHAR_CDKEY)); + sprintf(mmcdkeybuf[0],"%d.%d.%d",CHAR_getInt(fd_charaindex,CHAR_FLOOR),CHAR_getInt(fd_charaindex,CHAR_X),CHAR_getInt(fd_charaindex,CHAR_Y)); + time_t timep; + struct tm *p; + time(&timep); + p=localtime(&timep); + timep = mktime(p); + CHAR_setWorkInt(fd_charaindex,CHAR_WORKRANDEDITBASETIME,timep); + char *arg; + char buftest[255]; + int havepetindex,ret; + arg = CHAR_getWorkChar(fd_charaindex,CHAR_WORKDROPMM); + if(getStringFromIndexWithDelim(arg,"|", 1, buftest, sizeof(buftest)) == FALSE) + return; + havepetindex = atoi(buftest); + if(getStringFromIndexWithDelim(arg,"|", 2, buftest, sizeof(buftest)) == FALSE) + return; + ret = atoi(buftest); + if(atoi(data)!=ret){ + if(ret>=1 && ret<=5){ + if(atoi(data)>=10000){ + sasql_cdkey_lock(CHAR_getChar(fd_charaindex,CHAR_CDKEY),15); + CONNECT_setCloseRequest( fd , 1 ); + return; + } + }else{ + if(atoi(data)>=1 && atoi(data)<=5){ + //sasql_cdkey_lock(CHAR_getChar(fd_charaindex,CHAR_CDKEY),14); + CONNECT_setCloseRequest( fd , 1 ); + return; + } + } + CHAR_talkToCli( fd_charaindex, -1, "źĽԺԡ", CHAR_COLORRED); + return; + } + //CHAR_setWorkInt(fd_charaindex,CHAR_WORKRANDEDITBASETIME,0); + CHAR_setChar(fd_charaindex,CHAR_RANDTYPE,""); + CHAR_talkToCli( fd_charaindex, -1, "ϲĽȷ", CHAR_COLORRED); + int petindex; + petindex = CHAR_getCharPet(fd_charaindex,havepetindex); + if( !CHAR_CHECKINDEX( petindex )) return; + if(CHAR_getInt(petindex,CHAR_PETID)!=718 && CHAR_getInt(petindex,CHAR_PETID)!=401) return; + PET_dropPetFLXY(fd_charaindex, havepetindex, -1,-1,-1); + //CHAR_setWorkInt(fd_charaindex,CHAR_WORKRANDTYPE,0); + return; + } + if( seqno == CHAR_WINDOWTYPE_RAND1_FLLOWMM ) + { + if(strlen(data)<1) + { + CHAR_talkToCli( fd_charaindex, -1, "", CHAR_COLORRED); + return; + } + char *arg; + char buftest[255]; + int havepetindex,ret; + arg = CHAR_getWorkChar(fd_charaindex,CHAR_WORKDROPMM); + if(getStringFromIndexWithDelim(arg,"|", 1, buftest, sizeof(buftest)) == FALSE) + return; + havepetindex = atoi(buftest); + if(getStringFromIndexWithDelim(arg,"|", 2, buftest, sizeof(buftest)) == FALSE) + return; + ret = atoi(buftest); + if(atoi(data)!=ret){ + CHAR_talkToCli( fd_charaindex, -1, "ļȷ룡", CHAR_COLORRED); + return; + } + //CHAR_setWorkInt(fd_charaindex,CHAR_WORKRANDEDITBASETIME,0); + CHAR_setChar(fd_charaindex,CHAR_RANDTYPE,""); + int petindex; + petindex = CHAR_getCharPet(fd_charaindex,havepetindex); + if( !CHAR_CHECKINDEX( petindex )) return; + if(CHAR_getInt(petindex,CHAR_PETID)!=718 && CHAR_getInt(petindex,CHAR_PETID)!=401) return; + if( !PET_dropPetFollow( fd_charaindex, havepetindex, -1, -1, -1 ) ) { + CHAR_talkToCli( fd_charaindex, -1, "ʧܣ", CHAR_COLORWHITE ); + return; + } + //CHAR_setWorkInt(fd_charaindex,CHAR_WORKRANDTYPE,0); + return; + } + if( seqno == CHAR_WINDOWTYPE_RAND2_FLLOWMM ) + { + if(strlen(data)<1) + { + return; + } + if(atoi(data)<1 || atoi(data)>5) return; + char *arg; + char buftest[255]; + int havepetindex,ret; + arg = CHAR_getWorkChar(fd_charaindex,CHAR_WORKDROPMM); + if(getStringFromIndexWithDelim(arg,"|", 1, buftest, sizeof(buftest)) == FALSE) + return; + havepetindex = atoi(buftest); + if(getStringFromIndexWithDelim(arg,"|", 2, buftest, sizeof(buftest)) == FALSE) + return; + ret = atoi(buftest); + if(atoi(data)!=ret){ + CHAR_talkToCli( fd_charaindex, -1, "źѡļԺԡ", CHAR_COLORRED); + return; + } + //CHAR_setWorkInt(fd_charaindex,CHAR_WORKRANDEDITBASETIME,0); + CHAR_setChar(fd_charaindex,CHAR_RANDTYPE,""); + CHAR_talkToCli( fd_charaindex, -1, "ϲѡļȷ", CHAR_COLORRED); + int petindex; + petindex = CHAR_getCharPet(fd_charaindex,havepetindex); + if( !CHAR_CHECKINDEX( petindex )) return; + if(CHAR_getInt(petindex,CHAR_PETID)!=718 && CHAR_getInt(petindex,CHAR_PETID)!=401) return; + if( !PET_dropPetFollow( fd_charaindex, havepetindex, -1, -1, -1 ) ) { + CHAR_talkToCli( fd_charaindex, -1, "ʧܣ", CHAR_COLORWHITE ); + return; + } + //CHAR_setWorkInt(fd_charaindex,CHAR_WORKRANDTYPE,0); + return; + } + if( seqno == CHAR_WINDOWTYPE_RAND3_FLLOWMM ) + { + if(strlen(data)<1) + { + CHAR_talkToCli( fd_charaindex, -1, "", CHAR_COLORRED); + return; + } + char *arg; + char buftest[255]; + int havepetindex; + char ret[255]; + arg = CHAR_getWorkChar(fd_charaindex,CHAR_WORKDROPMM); + if(getStringFromIndexWithDelim(arg,"|", 1, buftest, sizeof(buftest)) == FALSE) + return; + havepetindex = atoi(buftest); + if(getStringFromIndexWithDelim(arg,"|", 2, buftest, sizeof(buftest)) == FALSE) + return; + strcpy(ret,buftest); + if(strcmp(ret,data)!=0){ + CHAR_talkToCli( fd_charaindex, -1, "Ľȷ룡", CHAR_COLORRED); + return; + } + //CHAR_setWorkInt(fd_charaindex,CHAR_WORKRANDEDITBASETIME,0); + CHAR_setChar(fd_charaindex,CHAR_RANDTYPE,""); + int petindex; + petindex = CHAR_getCharPet(fd_charaindex,havepetindex); + if( !CHAR_CHECKINDEX( petindex )) return; + if(CHAR_getInt(petindex,CHAR_PETID)!=718 && CHAR_getInt(petindex,CHAR_PETID)!=401) return; + if( !PET_dropPetFollow( fd_charaindex, havepetindex, -1, -1, -1 ) ) { + CHAR_talkToCli( fd_charaindex, -1, "ʧܣ", CHAR_COLORWHITE ); + return; + } + //CHAR_setWorkInt(fd_charaindex,CHAR_WORKRANDTYPE,0); + return; + } + if( seqno == CHAR_WINDOWTYPE_RAND4_FLLOWMM ) + { + if(strlen(data)<1) + { + return; + } + //if(atoi(data)getRandMax()) return; + if(CHAR_getWorkInt(fd_charaindex,CHAR_WORKLUANPCINT)!=0) return; + CHAR_setWorkInt(fd_charaindex,CHAR_WORKLUANPCINT,1); + int cdkeynum; + for(cdkeynum=9;cdkeynum>0;cdkeynum--){ + strcpy(mmcdkey[cdkeynum],mmcdkey[cdkeynum-1]); + strcpy(mmcdkeybuf[cdkeynum],mmcdkeybuf[cdkeynum-1]); + } + strcpy(mmcdkey[0],CHAR_getChar(fd_charaindex,CHAR_CDKEY)); + sprintf(mmcdkeybuf[0],"%d.%d.%d",CHAR_getInt(fd_charaindex,CHAR_FLOOR),CHAR_getInt(fd_charaindex,CHAR_X),CHAR_getInt(fd_charaindex,CHAR_Y)); + time_t timep; + struct tm *p; + time(&timep); + p=localtime(&timep); + timep = mktime(p); + CHAR_setWorkInt(fd_charaindex,CHAR_WORKRANDEDITBASETIME,timep); + char *arg; + char buftest[255]; + int havepetindex,ret; + arg = CHAR_getWorkChar(fd_charaindex,CHAR_WORKDROPMM); + if(getStringFromIndexWithDelim(arg,"|", 1, buftest, sizeof(buftest)) == FALSE) + return; + havepetindex = atoi(buftest); + if(getStringFromIndexWithDelim(arg,"|", 2, buftest, sizeof(buftest)) == FALSE) + return; + ret = atoi(buftest); + if(atoi(data)!=ret){ + if(ret>=1 && ret<=5){ + if(atoi(data)>=10000){ + sasql_cdkey_lock(CHAR_getChar(fd_charaindex,CHAR_CDKEY),15); + CONNECT_setCloseRequest( fd , 1 ); + return; + } + }else{ + if(atoi(data)>=1 && atoi(data)<=5){ + //sasql_cdkey_lock(CHAR_getChar(fd_charaindex,CHAR_CDKEY),14); + CONNECT_setCloseRequest( fd , 1 ); + return; + } + } + CHAR_talkToCli( fd_charaindex, -1, "źĽԺԡ", CHAR_COLORRED); + return; + } + //CHAR_setWorkInt(fd_charaindex,CHAR_WORKRANDEDITBASETIME,0); + CHAR_setChar(fd_charaindex,CHAR_RANDTYPE,""); + CHAR_talkToCli( fd_charaindex, -1, "ϲĽȷ", CHAR_COLORRED); + int petindex; + petindex = CHAR_getCharPet(fd_charaindex,havepetindex); + if( !CHAR_CHECKINDEX( petindex )) return; + if(CHAR_getInt(petindex,CHAR_PETID)!=718 && CHAR_getInt(petindex,CHAR_PETID)!=401) return; + if( !PET_dropPetFollow( fd_charaindex, havepetindex, -1, -1, -1 ) ) { + CHAR_talkToCli( fd_charaindex, -1, "ʧܣ", CHAR_COLORWHITE ); + return; + } + //CHAR_setWorkInt(fd_charaindex,CHAR_WORKRANDTYPE,0); + return; + } +#endif +#ifdef _DP_ZHIPIAO_ITEM + if( seqno == CHAR_WINDOWTYPE_DPZHIPIAO_1 ) + { + if(strlen(data)<1) + { + CHAR_talkToCli( fd_charaindex, -1, "", CHAR_COLORRED); + return; + } + if(atoi(data)!=CHAR_getWorkInt(fd_charaindex,CHAR_WORKDPZHIPIAORAND)){ + CHAR_talkToCli( fd_charaindex, -1, "ļȷ룡", CHAR_COLORRED); + return; + } + char buf[255]; + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGEANDLINEINPUT, + WINDOW_BUTTONTYPE_OKCANCEL, + CHAR_WINDOWTYPE_DPZHIPIAO_2, + -1, + makeEscapeString( "ҪһDP\n", buf, sizeof(buf))); + } + if( seqno == CHAR_WINDOWTYPE_DPZHIPIAO_2 ){ + if(select == WINDOW_BUTTONTYPE_OK){ + if(strlen(data)<1) return; + if(atoi(data)<100){ + CHAR_talkToCli( fd_charaindex, -1, "С֧ƱΪ100DP޷ǩ", CHAR_COLORYELLOW); + return; + } + if(atoi(data)>10000000){ + CHAR_talkToCli( fd_charaindex, -1, "֧ƱΪ1000WDP޷ǩ", CHAR_COLORYELLOW); + return; + } + char zhipiaomsg[256]; + int dppoint = atoi(data)*CHAR_getWorkInt(fd_charaindex,CHAR_WORKDPZHIPIAOSHUI)/100; + if(dppoint<10) dppoint = dppoint+1; + sprintf(zhipiaomsg,"\nǩ֧ƱҪȡٷ֮%d˰\n\n֧ƱǩҪ۳%dDP\n\nȷҪô",CHAR_getWorkInt(fd_charaindex,CHAR_WORKDPZHIPIAOSHUI),dppoint+atoi(data)); + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OKCANCEL, + CHAR_WINDOWTYPE_DPZHIPIAO_3, + -1, + zhipiaomsg); + CHAR_setWorkInt(fd_charaindex,CHAR_WORKDPZHIPIAOPOINT,atoi(data)); + return; + }else + return; + } + if( seqno == CHAR_WINDOWTYPE_DPZHIPIAO_3 ){ + if(select == WINDOW_BUTTONTYPE_OK){ + int mypoint = CHAR_getInt(fd_charaindex,CHAR_DUELPOINT); + int itempoint = CHAR_getWorkInt(fd_charaindex,CHAR_WORKDPZHIPIAOPOINT); + int kdppoint = itempoint/100*CHAR_getWorkInt(fd_charaindex,CHAR_WORKDPZHIPIAOSHUI); + if(kdppoint<10) kdppoint =kdppoint+1; + int dppoint = itempoint+kdppoint; + if(mypoint5) return; + char *arg; + char buftest[255]; + int npcindex,ret; + char *szmsg; + arg = CHAR_getWorkChar(fd_charaindex,CHAR_WORKRANDMSG); + if(getStringFromIndexWithDelim(arg,"|", 1, buftest, sizeof(buftest)) == FALSE) + return; + ret = atoi(buftest); + if(getStringFromIndexWithDelim(arg,"|", 2, buftest, sizeof(buftest)) == FALSE) + return; + npcindex = atoi(buftest); + if(getStringFromIndexWithDelim(arg,"|", 3, buftest, sizeof(buftest)) == FALSE) + return; + szmsg = buftest; + if(atoi(data)!=ret){ + CHAR_talkToCli( fd_charaindex, -1, "źѡļԺԡ", CHAR_COLORRED); + return; + } + //CHAR_setWorkInt(fd_charaindex,CHAR_WORKRANDEDITBASETIME,0); + CHAR_setChar(fd_charaindex,CHAR_RANDTYPE,""); + CHAR_talkToCli( fd_charaindex, -1, "ϲѡļȷ", CHAR_COLORRED); + NPC_TypeCheck( npcindex, fd_charaindex, szmsg); + //CHAR_setWorkInt(fd_charaindex,CHAR_WORKRANDTYPE,0); + return; + } + if( seqno == CHAR_WINDOWTYPE_NPC_RAND3_MSG ){ + if(select == WINDOW_BUTTONTYPE_OK){ + if(strlen(data)<1) + { + CHAR_talkToCli( fd_charaindex, -1, "", CHAR_COLORRED); + return; + } + char *arg; + char buftest[255]; + int npcindex; + char ret[255]; + char *szmsg; + arg = CHAR_getWorkChar(fd_charaindex,CHAR_WORKRANDMSG); + if(getStringFromIndexWithDelim(arg,"|", 1, buftest, sizeof(buftest)) == FALSE) + return; + strcpy(ret,buftest); + if(getStringFromIndexWithDelim(arg,"|", 2, buftest, sizeof(buftest)) == FALSE) + return; + npcindex = atoi(buftest); + if(getStringFromIndexWithDelim(arg,"|", 3, buftest, sizeof(buftest)) == FALSE) + return; + szmsg = buftest; + if(strcmp(ret,data)!=0){ + CHAR_talkToCli( fd_charaindex, -1, "Ľȷ룡", CHAR_COLORRED); + return; + } + //CHAR_setWorkInt(fd_charaindex,CHAR_WORKRANDEDITBASETIME,0); + CHAR_setChar(fd_charaindex,CHAR_RANDTYPE,""); + NPC_TypeCheck( npcindex, fd_charaindex, szmsg); + //CHAR_setWorkInt(fd_charaindex,CHAR_WORKRANDTYPE,0); + return; + }else + return; + } + if( seqno == CHAR_WINDOWTYPE_NPC_RAND4_MSG ){ + if(strlen(data)<1) + { + CHAR_setWorkChar(fd_charaindex,CHAR_WORKRANDMSG,""); + return; + } + //if(atoi(data)getRandMax()) return; + if(CHAR_getWorkInt(fd_charaindex,CHAR_WORKLUANPCINT)!=0){ + CHAR_setWorkChar(fd_charaindex,CHAR_WORKRANDMSG,""); + return; + } + CHAR_setWorkInt(fd_charaindex,CHAR_WORKLUANPCINT,1); + int cdkeynum; + for(cdkeynum=9;cdkeynum>0;cdkeynum--){ + strcpy(mmcdkey[cdkeynum],mmcdkey[cdkeynum-1]); + strcpy(mmcdkeybuf[cdkeynum],mmcdkeybuf[cdkeynum-1]); + } + strcpy(mmcdkey[0],CHAR_getChar(fd_charaindex,CHAR_CDKEY)); + sprintf(mmcdkeybuf[0],"%d.%d.%d",CHAR_getInt(fd_charaindex,CHAR_FLOOR),CHAR_getInt(fd_charaindex,CHAR_X),CHAR_getInt(fd_charaindex,CHAR_Y)); + time_t timep; + struct tm *p; + time(&timep); + p=localtime(&timep); + timep = mktime(p); + CHAR_setWorkInt(fd_charaindex,CHAR_WORKRANDEDITBASETIME,timep); + char *arg; + char buftest[255]; + int npcindex,ret; + char *szmsg; + arg = CHAR_getWorkChar(fd_charaindex,CHAR_WORKRANDMSG); + if(getStringFromIndexWithDelim(arg,"|", 1, buftest, sizeof(buftest)) == FALSE){ + CHAR_setWorkChar(fd_charaindex,CHAR_WORKRANDMSG,""); + return; + } + ret = atoi(buftest); + if(getStringFromIndexWithDelim(arg,"|", 2, buftest, sizeof(buftest)) == FALSE){ + CHAR_setWorkChar(fd_charaindex,CHAR_WORKRANDMSG,""); + return; + } + npcindex = atoi(buftest); + if(getStringFromIndexWithDelim(arg,"|", 3, buftest, sizeof(buftest)) == FALSE){ + CHAR_setWorkChar(fd_charaindex,CHAR_WORKRANDMSG,""); + return; + } + szmsg = buftest; + if(atoi(data)!=ret){ + if(ret>=1 && ret<=5){ + if(atoi(data)>=10000){ + sasql_cdkey_lock(CHAR_getChar(fd_charaindex,CHAR_CDKEY),15); + CONNECT_setCloseRequest( fd , 1 ); + return; + } + }else{ + if(atoi(data)>=1 && atoi(data)<=5){ + //sasql_cdkey_lock(CHAR_getChar(fd_charaindex,CHAR_CDKEY),14); + CONNECT_setCloseRequest( fd , 1 ); + return; + } + } + CHAR_setWorkChar(fd_charaindex,CHAR_WORKRANDMSG,""); + CHAR_talkToCli( fd_charaindex, -1, "źĽԺԡ", CHAR_COLORRED); + return; + } + //CHAR_setWorkInt(fd_charaindex,CHAR_WORKRANDEDITBASETIME,0); + CHAR_setWorkChar(fd_charaindex,CHAR_WORKRANDMSG,""); + CHAR_setChar(fd_charaindex,CHAR_RANDTYPE,""); + CHAR_talkToCli( fd_charaindex, -1, "ϲĽȷ", CHAR_COLORRED); + NPC_TypeCheck( npcindex, fd_charaindex, szmsg); + //CHAR_setWorkInt(fd_charaindex,CHAR_WORKRANDTYPE,0); + return; + } + + if( seqno == CHAR_WINDOWTYPE_NPCENEMY_RAND_MSG ){ + if(strlen(data)<1) + { + CHAR_setWorkChar(fd_charaindex,CHAR_WORKRANDMSG,""); + return; + } + //if(atoi(data)getRandMax()) return; + if(CHAR_getWorkInt(fd_charaindex,CHAR_WORKLUANPCINT)!=0){ + CHAR_setWorkChar(fd_charaindex,CHAR_WORKRANDMSG,""); + return; + } + CHAR_setWorkInt(fd_charaindex,CHAR_WORKLUANPCINT,1); + int cdkeynum; + for(cdkeynum=9;cdkeynum>0;cdkeynum--){ + strcpy(mmcdkey[cdkeynum],mmcdkey[cdkeynum-1]); + strcpy(mmcdkeybuf[cdkeynum],mmcdkeybuf[cdkeynum-1]); + } + strcpy(mmcdkey[0],CHAR_getChar(fd_charaindex,CHAR_CDKEY)); + sprintf(mmcdkeybuf[0],"%d.%d.%d",CHAR_getInt(fd_charaindex,CHAR_FLOOR),CHAR_getInt(fd_charaindex,CHAR_X),CHAR_getInt(fd_charaindex,CHAR_Y)); + time_t timep; + struct tm *p; + time(&timep); + p=localtime(&timep); + timep = mktime(p); + CHAR_setWorkInt(fd_charaindex,CHAR_WORKRANDEDITBASETIME,timep); + char *arg; + char buftest[255]; + int npcindex,ret; + arg = CHAR_getWorkChar(fd_charaindex,CHAR_WORKRANDMSG); + if(getStringFromIndexWithDelim(arg,"|", 1, buftest, sizeof(buftest)) == FALSE){ + CHAR_setWorkChar(fd_charaindex,CHAR_WORKRANDMSG,""); + return; + } + ret = atoi(buftest); + if(getStringFromIndexWithDelim(arg,"|", 2, buftest, sizeof(buftest)) == FALSE){ + CHAR_setWorkChar(fd_charaindex,CHAR_WORKRANDMSG,""); + return; + } + npcindex = atoi(buftest); + if(atoi(data)!=ret){ + if(ret>=1 && ret<=5){ + if(atoi(data)>=10000){ + sasql_cdkey_lock(CHAR_getChar(fd_charaindex,CHAR_CDKEY),15); + CONNECT_setCloseRequest( fd , 1 ); + return; + } + }else{ + if(atoi(data)>=1 && atoi(data)<=5){ + CONNECT_setCloseRequest( fd , 1 ); + return; + } + } + CHAR_setWorkChar(fd_charaindex,CHAR_WORKRANDMSG,""); + CHAR_talkToCli( fd_charaindex, -1, "źĽԺԡ", CHAR_COLORRED); + return; + } + //CHAR_setWorkInt(fd_charaindex,CHAR_WORKRANDEDITBASETIME,0); + CHAR_setWorkChar(fd_charaindex,CHAR_WORKRANDMSG,""); + CHAR_setChar(fd_charaindex,CHAR_RANDTYPE,""); + CHAR_talkToCli( fd_charaindex, -1, "ϲĽȷ", CHAR_COLORRED); + NPC_NPCEnemy_Encount( npcindex, fd_charaindex, 1); + //CHAR_setWorkInt(fd_charaindex,CHAR_WORKRANDTYPE,0); + return; + } + + if( seqno == CHAR_WINDOWTYPE_LUANPC_RANDMSG ){ + if(strlen(data)<1) + { + CHAR_setWorkChar(fd_charaindex,CHAR_WORKRANDMSG,""); + return; + } + //if(atoi(data)getRandMax()) return; + if(CHAR_getWorkInt(fd_charaindex,CHAR_WORKLUANPCINT)!=0){ + CHAR_setWorkChar(fd_charaindex,CHAR_WORKRANDMSG,""); + return; + } + CHAR_setWorkInt(fd_charaindex,CHAR_WORKLUANPCINT,1); + int cdkeynum; + for(cdkeynum=9;cdkeynum>0;cdkeynum--){ + strcpy(mmcdkey[cdkeynum],mmcdkey[cdkeynum-1]); + strcpy(mmcdkeybuf[cdkeynum],mmcdkeybuf[cdkeynum-1]); + } + strcpy(mmcdkey[0],CHAR_getChar(fd_charaindex,CHAR_CDKEY)); + sprintf(mmcdkeybuf[0],"%d.%d.%d",CHAR_getInt(fd_charaindex,CHAR_FLOOR),CHAR_getInt(fd_charaindex,CHAR_X),CHAR_getInt(fd_charaindex,CHAR_Y)); + time_t timep; + struct tm *p; + time(&timep); + p=localtime(&timep); + timep = mktime(p); + CHAR_setWorkInt(fd_charaindex,CHAR_WORKRANDEDITBASETIME,timep); + char *arg; + char buftest[255]; + int npcindex,talkindex,ret,flag; + arg = CHAR_getWorkChar(fd_charaindex,CHAR_WORKRANDMSG); + if(getStringFromIndexWithDelim(arg,"|", 1, buftest, sizeof(buftest)) == FALSE){ + CHAR_setWorkChar(fd_charaindex,CHAR_WORKRANDMSG,""); + return; + } + ret = atoi(buftest); + if(getStringFromIndexWithDelim(arg,"|", 2, buftest, sizeof(buftest)) == FALSE){ + CHAR_setWorkChar(fd_charaindex,CHAR_WORKRANDMSG,""); + return; + } + npcindex = atoi(buftest); + if(getStringFromIndexWithDelim(arg,"|", 3, buftest, sizeof(buftest)) == FALSE){ + CHAR_setWorkChar(fd_charaindex,CHAR_WORKRANDMSG,""); + return; + } + talkindex = atoi(buftest); + if(getStringFromIndexWithDelim(arg,"|", 4, buftest, sizeof(buftest)) == FALSE){ + CHAR_setWorkChar(fd_charaindex,CHAR_WORKRANDMSG,""); + return; + } + flag = atoi(buftest); + if(atoi(data)!=ret){ + if(ret>=1 && ret<=5){ + if(atoi(data)>=10000){ + sasql_cdkey_lock(CHAR_getChar(fd_charaindex,CHAR_CDKEY),15); + CONNECT_setCloseRequest( fd , 1 ); + return; + } + }else{ + if(atoi(data)>=1 && atoi(data)<=5){ + //sasql_cdkey_lock(CHAR_getChar(fd_charaindex,CHAR_CDKEY),14); + CONNECT_setCloseRequest( fd , 1 ); + return; + } + } + CHAR_setWorkChar(fd_charaindex,CHAR_WORKRANDMSG,""); + CHAR_talkToCli( fd_charaindex, -1, "źĽԺԡ", CHAR_COLORRED); + return; + } + sprintf(buftest,"%d|%d|%d|%d",ret,npcindex,talkindex,1); + CHAR_setWorkChar(fd_charaindex,CHAR_WORKRANDMSG,buftest); + CHAR_setChar(fd_charaindex,CHAR_RANDTYPE,""); + CHAR_talkToCli( fd_charaindex, -1, "ϲĽȷ", CHAR_COLORRED); + NPC_Lua_TalkedCallBack(npcindex,fd_charaindex,"hi",0,-1); + return; + } +#endif + {//ttom avoid the warp at will + Char *ch; + ch = CHAR_getCharPointer( fd_charaindex); + // CoolFish: +1 2001/11/05 + if (!ch) return; + if((ch->data[CHAR_X]!=x)||(ch->data[CHAR_Y]!=y)){ + // Robin 04/20 test + return; + x=ch->data[CHAR_X]; + y=ch->data[CHAR_Y]; + } + //ttom avoid WN at will + if(seqno==CHAR_WINDOWTYPE_NPCENEMY_START){ + //print("12121212\n"); +// Char *ch; + OBJECT object; + int ix,iy,ifloor,i,j; + int whichtype= -1; + int enemy=0; + int enemy_index; + if(!CHECKOBJECT(objindex)){ + goto FIRST; + } + enemy_index=OBJECT_getIndex(objindex);//ttom 11/15/2000 + ix =ch->data[CHAR_X]; + iy =ch->data[CHAR_Y]; + ifloor=ch->data[CHAR_FLOOR]; + for(i=iy-1;i<=iy+1;i++){ + for(j=ix-1;j<=ix+1;j++){ + for( object = MAP_getTopObj(ifloor,j,i) ; object ; + object = NEXT_OBJECT(object ) ){ + int objindex = GET_OBJINDEX(object); + switch( OBJECT_getType(objindex) ){ + case OBJTYPE_CHARA: + whichtype = CHAR_getInt( OBJECT_getIndex( objindex), CHAR_WHICHTYPE); + if( whichtype == CHAR_TYPENPCENEMY){ + int i_ene_temp; + i_ene_temp=OBJECT_getIndex( objindex); + //print("\n--enetemp=%d",i_ene_temp); + if(i_ene_temp== enemy_index){ + goto START_WN; + }else{ + enemy=0; + } + } + break; + case OBJTYPE_ITEM: + break; + case OBJTYPE_GOLD: + break; + default: + break; + } + } + } + } + if(enemy==0){ +FIRST: + + lssproto_EN_send( fd, FALSE, 0 ); + CHAR_talkToCli(fd_charaindex, -1, "¼", CHAR_COLORYELLOW); + goto END_WN; + } + } + } + //ttom end +START_WN: + CHAR_setMyPosition( fd_charaindex, x,y,TRUE); + if( CHAR_getWorkInt( fd_charaindex, CHAR_WORKBATTLEMODE) == BATTLE_CHARMODE_NONE){ + if(seqno==CHAR_WINDOWTYPE_WINDOWWARPMAN_MAIN){ + if(!CONNECT_get_first_warp(fd)){ + select=1; + } + } + CHAR_processWindow( fd_charaindex, seqno, + select, objindex, makeStringFromEscaped(data)); + +//#ifdef _NO_WARP +// if (CONNECT_get_seqno(fd)==CHAR_WINDOWTYPE_WINDOWWARPMAN_MAIN) +// { +// CONNECT_set_seqno(fd,-1); +// CONNECT_set_selectbutton(fd,1); +// } +//#endif + } +//ttom+1 +END_WN: + return; + //CONNECT_set_pass(fd,TRUE);//ttom +} + +/*------------------------------------------------------------ + ------------------------------------------------------------*/ +void lssproto_HL_recv( int fd,int flg ) +{ + char msgbuf[128]; + int i, fd_charaindex; + CHECKFD; + + fd_charaindex = CONNECT_getCharaindex( fd ); + if( CHAR_getWorkInt( fd_charaindex, CHAR_WORKBATTLEMODE) + == BATTLE_CHARMODE_NONE) + { + return; + } +#ifdef _LOCKHELP_OK // (ɿ) Syu ADD ɼս + if((CHAR_getInt(fd_charaindex,CHAR_FLOOR) >= 8200 && CHAR_getInt(fd_charaindex,CHAR_FLOOR) <= 8213) || + (CHAR_getInt(fd_charaindex,CHAR_FLOOR) >= 30017 && CHAR_getInt(fd_charaindex,CHAR_FLOOR) <= 30021) + || CHAR_getInt(fd_charaindex,CHAR_FLOOR) == 20000 + ){ + return ; + } +#endif +#ifdef _NPCENEMY_1 + if(CHAR_getWorkInt(fd_charaindex,CHAR_WORKBATTLEHELP)==1) return; +#endif + if( flg == TRUE ) { + BattleArray[CHAR_getWorkInt( fd_charaindex, + CHAR_WORKBATTLEINDEX)].Side[ + CHAR_getWorkInt( fd_charaindex, + CHAR_WORKBATTLESIDE)].flg |= BSIDE_FLG_HELP_OK; + + snprintf( msgbuf, sizeof( msgbuf), + "%s ȣ", + CHAR_getChar( fd_charaindex, CHAR_NAME)); + } + else { + BattleArray[CHAR_getWorkInt( fd_charaindex, + CHAR_WORKBATTLEINDEX)].Side[ + CHAR_getWorkInt( fd_charaindex, + CHAR_WORKBATTLESIDE)].flg &= ~BSIDE_FLG_HELP_OK; + + snprintf( msgbuf, sizeof( msgbuf), + "%s ܾ", + CHAR_getChar( fd_charaindex, CHAR_NAME)); + } + + for( i = 0; i < 5; i ++ ) { + int toindex = BattleArray[CHAR_getWorkInt( + fd_charaindex, CHAR_WORKBATTLEINDEX)].Side[ + CHAR_getWorkInt( fd_charaindex, + CHAR_WORKBATTLESIDE)].Entry[i].charaindex; + if( CHAR_CHECKINDEX( toindex)) { + int tofd = getfdFromCharaIndex( toindex ); + if( tofd != -1 ) { + lssproto_HL_send( tofd, flg); + } + /* ˪ */ + CHAR_talkToCli( toindex, -1, msgbuf, CHAR_COLORYELLOW); + CHAR_sendBattleEffect( toindex, ON); + } + } +} +/*------------------------------------------------------------ + ------------------------------------------------------------*/ +void lssproto_ProcGet_recv( int fd ) +{ + outputNetProcLog( fd, 1); +} +/*------------------------------------------------------------ + ------------------------------------------------------------*/ +void lssproto_PlayerNumGet_recv( int fd ) +{ + int i; + int clicnt =0; + int playercnt = 0; + for( i = 0; i < ConnectLen; i ++ ) { + if( CONNECT_getUse_debug(i,1017) ){ + if( CONNECT_getCtype(i) == CLI) { + clicnt ++; + if( CONNECT_getCharaindex(i) >= 0 ) playercnt++; + } + } + } + lssproto_PlayerNumGet_send( fd, clicnt, playercnt); +} + + +/*------------------------------------------------------------ + ------------------------------------------------------------*/ +void lssproto_LB_recv( int fd,int x,int y ) +{ + int fd_charaindex; + + CHECKFDANDTIME; + fd_charaindex = CONNECT_getCharaindex( fd ); + {//ttom avoid warp at will + int ix,iy; + ix=CHAR_getInt(fd_charaindex, CHAR_X); + iy=CHAR_getInt(fd_charaindex, CHAR_Y); + if( (ix!=x)||(iy!=y)){ + //print("\n--Error!!!!"); + //print("\norigion x=%d,y=%d",ix,iy); + //print("\nmodify X=%d,Y=%d",x,y); + x=ix; + y=iy; + } + } + CHAR_setMyPosition( fd_charaindex, x,y,TRUE); + /* ɱƥ¾ƻɱ */ + BATTLE_WatchTry( fd_charaindex ); +} +/*------------------------------------------------------------ + ------------------------------------------------------------*/ +void lssproto_Shutdown_recv( int fd,char* passwd,int min ) +{ + char buff[32]; + if( strcmp( passwd, "hogehoge") == 0 ) { + int i; + int playernum = CHAR_getPlayerMaxNum(); + snprintf( buff, sizeof( buff),"%s档",getGameserverID()); + for( i = 0 ; i < playernum ; i++) { + if( CHAR_getCharUse(i) != FALSE ) { + CHAR_talkToCli( i, -1, buff, CHAR_COLORYELLOW); + } + } + SERVSTATE_setLimittime(min); + SERVSTATE_setShutdown( NowTime.tv_sec ); + SERVSTATE_setDsptime( 0 ); + } +} +void lssproto_PMSG_recv( int fd,int index,int petindex,int itemindex, + char* message,int color ) +{ + + // CoolFish: Prevent Trade Cheat 2001/4/18 + int fd_charaindex; + fd_charaindex = CONNECT_getCharaindex(fd); + if (CHAR_getWorkInt(fd_charaindex, CHAR_WORKTRADEMODE) != CHAR_TRADE_FREE) + return; + if( CHAR_getWorkInt(fd_charaindex,CHAR_WORKSTREETVENDOR)!=-1) return; + PETMAIL_sendPetMail( CONNECT_getCharaindex( fd ), + index, petindex, itemindex, message, color); + +} +/*------------------------------------------------------------ + ------------------------------------------------------------*/ +void lssproto_PS_recv( int fd, int havepetindex, int havepetskill, int toindex, char* data ) +{ + int to_charaindex = Callfromcli_Util_getTargetCharaindex( fd, toindex); + int charaindex = CONNECT_getCharaindex( fd ); + int petindex; + BOOL ret; + petindex = CHAR_getCharPet( charaindex, havepetindex); + if( !CHAR_CHECKINDEX( petindex)) return; + if( CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE) != BATTLE_CHARMODE_NONE && strlen(data)>0) return; + ret = PETSKILL_Use( petindex, havepetskill, to_charaindex, data ); + lssproto_PS_send( fd, ret, havepetindex, havepetskill, toindex); +} +/*------------------------------------------------------------ + ------------------------------------------------------------*/ +void lssproto_SP_recv( int fd,int x,int y, int dir ) +{ + int fd_charaindex; + + fd_charaindex = CONNECT_getCharaindex( fd ); + {//ttom avoid the warp at will + int i_x,i_y; + i_x=CHAR_getInt(fd_charaindex, CHAR_X); + i_y=CHAR_getInt(fd_charaindex, CHAR_Y); + + if((i_x!=x)||(i_y!=y)){ + x=i_x; + y=i_y; + } + }//ttom + + CHAR_setMyPosition_main( fd_charaindex, x,y,dir,TRUE); + +} + +/*------------------------------------------------------------ + * CoolFish: Trade Command 2001/4/18 + ------------------------------------------------------------*/ +void lssproto_TD_recv( int fd, char* message ) +{ + int fd_charaindex; + CHECKFDANDTIME; + + fd_charaindex = CONNECT_getCharaindex( fd ); +// print(" MAP_TRADEPICKUP_check0 "); + + CHAR_Trade(fd, fd_charaindex, message); +} + +/*------------------------------------------------------------ + * CoolFish: Family Command 2001/5/24 + ------------------------------------------------------------*/ +void lssproto_FM_recv( int fd, char* message ) +{ + int fd_charaindex; + struct timeval recvtime; + CHECKFDANDTIME; + + // add code by shan + CONNECT_getLastrecvtime( fd, &recvtime); + if( time_diff( NowTime, recvtime) < 0.5 ){ + return; + } + CONNECT_setLastrecvtime(fd, &NowTime); + + fd_charaindex = CONNECT_getCharaindex( fd ); + + if( checkStringErr( message ) ) return; + + CHAR_Family(fd, fd_charaindex, message); + +} + +// shan 2002/01/10 +void lssproto_PETST_recv( int fd, int nPet, int sPet ) +{ + if(nPet<0 || nPet>4) return; + int charaindex; + int i, nums=0; + CHECKFDANDTIME; + + charaindex = CONNECT_getCharaindex( fd ); + if (!CHAR_CHECKINDEX( charaindex ) ) return; + + if( CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE) + != BATTLE_CHARMODE_NONE) return ; + + for( i=0; i<5; i++) { + if( CHAR_getWorkInt( charaindex, CHAR_WORK_PET0_STAT+i) == TRUE ) + nums++; + } + if( nums <= 3 ) + CHAR_setWorkInt( charaindex, CHAR_WORK_PET0_STAT+nPet, sPet); +// if( nums ==3 && CHAR_getWorkInt(charaindex,CHAR_WORK_PET0_STAT+nPet)==0){ +// CHAR_setWorkInt( charaindex, CHAR_WORK_PET0_STAT+nPet, 1); +// lssproto_SPET_recv(fd,nPet+1); +// } +} + +#ifdef _MIND_ICON +void lssproto_MA_recv(int fd, int x, int y, int nMind) +{ + int charaindex; + CHECKFDANDTIME; + + charaindex = CONNECT_getCharaindex( fd); + if(!CHAR_CHECKINDEX( charaindex)) return; + if( CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE) != BATTLE_CHARMODE_NONE) return ; + + { + int i_x, i_y; + i_x = CHAR_getInt( charaindex, CHAR_X); + i_y = CHAR_getInt( charaindex, CHAR_Y); + + if((i_x!=x)||(i_y!=y)){ + x = i_x; + y = i_y; + } + } + + //print("\nshan------------------>mind action->%d x->%d y->%d", nMind, x, y); + CHAR_setMyPosition( charaindex, x, y, TRUE); + CHAR_setWorkInt( charaindex, CHAR_MIND_NUM, nMind); + CHAR_sendMindEffect( charaindex, CHAR_getWorkInt( charaindex, CHAR_MIND_NUM)); + if(CHAR_getWorkInt( charaindex, CHAR_MIND_NUM) != 101290 && + CHAR_getWorkInt( charaindex, CHAR_MIND_NUM) != 101294 && + CHAR_getWorkInt( charaindex, CHAR_MIND_NUM) != 101288 ) + CHAR_setWorkInt( charaindex, CHAR_MIND_NUM, 0); + //print("\nshan------------------>end"); + + return; +} +#endif +BOOL checkStringErr( char *checkstring ) +{ + int i,ach; + for (i=0,ach=0;i=0x40)&&((unsigned char)checkstring[i]<=0x7e))|| + (((unsigned char)checkstring[i]>=0xa1)&&((unsigned char)checkstring[i]<=0xfe))) ach=0; + } else { + if (((unsigned char)checkstring[i]>=0xa1)&&((unsigned char)checkstring[i]<=0xfe)) ach=1; + } + } + if (ach) + { + print(" StringDog! "); + return TRUE; + } + + return FALSE; + +} + +#ifdef _TEAM_KICKPARTY +void lssproto_KTEAM_recv( int fd, int si) +{ + int charaindex=-1, pindex; + if( si < 0 || si > 5 ) return; + charaindex = CONNECT_getCharaindex( fd ); + if( !CHAR_CHECKINDEX( charaindex) ) return; + + if( CHAR_getWorkInt( charaindex, CHAR_WORKPARTYMODE) != CHAR_PARTY_LEADER ) return; + + pindex = CHAR_getWorkInt( charaindex, si + CHAR_WORKPARTYINDEX1); + if( !CHAR_CHECKINDEX( pindex) ) return; + if( CHAR_getWorkInt( pindex, CHAR_WORKPARTYMODE) == CHAR_PARTY_LEADER ) return; + + if( CHAR_DischargeParty( pindex, 0) == FALSE ){ + CHAR_talkToCli( charaindex, -1, "߳ʧܣ", CHAR_COLORYELLOW); + }else{ + char buf1[256]; + sprintf( buf1, "ӳ[%s]߳", CHAR_getUseName( charaindex )); + CHAR_talkToCli( pindex, -1, buf1, CHAR_COLORYELLOW); + sprintf( buf1, "[%s]߳Ŷӣ", CHAR_getUseName( pindex )); + CHAR_talkToCli( charaindex, -1, buf1, CHAR_COLORYELLOW); + } +} +#endif + +#ifdef _CHATROOMPROTOCOL // (ɿ) Syu ADD Ƶ +void lssproto_CHATROOM_recv (int fd , char *data) +{ + ChatRoom_recvall ( fd , data ) ; +} +#endif + +#ifdef _NEWREQUESTPROTOCOL // (ɿ) Syu ADD ProtocolҪϸ +void lssproto_RESIST_recv (int fd ) +{ + int charindex = -1 ; + + char token[256]; + charindex = CONNECT_getCharaindex( fd ); + if( !CHAR_CHECKINDEX( charindex) ) return; + sprintf ( token , "%d|%d|%d|%d|%d|%d|%d|%d" , + CHAR_getInt( charindex, CHAR_EARTH_RESIST ) , + CHAR_getInt( charindex, CHAR_WATER_RESIST ) , + CHAR_getInt( charindex, CHAR_FIRE_RESIST ) , + CHAR_getInt( charindex, CHAR_WIND_RESIST ) , + CHAR_getInt( charindex, CHAR_EARTH_EXP ) , + CHAR_getInt( charindex, CHAR_WATER_EXP ) , + CHAR_getInt( charindex, CHAR_FIRE_EXP ) , + CHAR_getInt( charindex, CHAR_WIND_EXP ) + ); + lssproto_RESIST_send ( fd , token ) ; +} +#endif + +#ifdef _OUTOFBATTLESKILL // (ɿ) Syu ADD սʱProtocol +void lssproto_BATTLESKILL_recv (int fd, int iNum) +{ + int charaindex = CONNECT_getCharaindex( fd ); +#ifndef _PROSKILL_OPTIMUM + int skillindex=-1,char_pskill=-1,profession_skill=-1; +#endif + + if( !CHAR_CHECKINDEX( charaindex) ) return; + if( CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE) != BATTLE_CHARMODE_NONE ) return; + +#ifndef _PROSKILL_OPTIMUM // Robin fix cancel ˴Թְҵ, PROFESSION_SKILL_Use м + // ְҵ + char_pskill = CHAR_getInt( charaindex, PROFESSION_CLASS ); + + skillindex = PROFESSION_SKILL_GetArray( charaindex, iNum); + int Pskillid = skillindex; + // ְܵҵ + profession_skill = PROFESSION_SKILL_getInt( Pskillid, PROFESSION_SKILL_PROFESSION_CLASS); + + if( (char_pskill > 0) && (char_pskill == profession_skill) ){ +#else + if( 1 ){ +#endif + if( PROFESSION_SKILL_Use( charaindex, iNum, 0, NULL ) != 1 ){ + if(CHAR_getWorkInt( charaindex, CHAR_ENCOUNT_NUM)-(int)time(NULL)>0){ +// print("\n (%s)ʹüܴ!", CHAR_getUseName( charaindex ) ); +#ifdef _PROSKILL_ERR_KICK + CONNECT_setCloseRequest( fd , 1 ); +#endif + } + } + } + +} + +#endif + +#ifdef _STREET_VENDOR +void lssproto_STREET_VENDOR_recv(int fd,char *message) +{ + int charaindex = CONNECT_getCharaindex(fd); + if(!CHAR_CHECKINDEX(charaindex)) return; + if(CHAR_getWorkInt(charaindex,CHAR_WORKBATTLEMODE) != BATTLE_CHARMODE_NONE) return; + if(CHAR_getWorkInt(charaindex,CHAR_WORKPARTYMODE) != CHAR_PARTY_NONE){ + CHAR_talkToCli(charaindex,-1,"״̬²ܽ",CHAR_COLORYELLOW); + return; + } + if (CHAR_getWorkInt( charaindex, CHAR_WORKSAFEMODE)==0) + { + CHAR_SafePassword(charaindex); + return; + } + CHAR_sendStreetVendor(charaindex,message); +} +#endif + +#ifdef _RIGHTCLICK +void lssproto_RCLICK_recv(int fd, int type, char* data) +{ + print("\n RCLICK_recv( type=%d data=%s) ", type, data); +} +#endif + +#ifdef _JOBDAILY +void lssproto_JOBDAILY_recv(int fd,char *data) +{ + int charaindex = CONNECT_getCharaindex(fd); + if(!CHAR_CHECKINDEX(charaindex)) return; + + CHAR_JobDaily(charaindex,data); +} +#endif + +#ifdef _TEACHER_SYSTEM +void lssproto_TEACHER_SYSTEM_recv(int fd,char *data) +{ + int charaindex = CONNECT_getCharaindex(fd); + + if(!CHAR_CHECKINDEX(charaindex)) return; + CHAR_Teacher_system(charaindex,data); +} +#endif + +#ifdef _ONLINE_SHOP +void lssproto_SHOP_recv(int fd,int shopflag,int piece) +{ + int charaindex = CONNECT_getCharaindex(fd); + + if(!CHAR_CHECKINDEX(charaindex)) return; + char *mycdkey=CHAR_getChar(charaindex,CHAR_CDKEY); + //saacproto_ACShop_send(fd,mycdkey,charaindex,shopflag,piece); + char dataname[20]; + char res[2048]; + int rownum=0,pieces=0,shopnum=0,startrow,vippoint=0; + sprintf(dataname,"OnlineShop%d",shopflag); + vippoint=sasql_vippoint(mycdkey,0,0); + rownum=sasql_chehk_shop(dataname); + if(rownum>0) + { + pieces=rownum/8+1; + shopnum=rownum-8*(piece-1); + if(shopnum>8) shopnum=8; + startrow=8*(piece-1); + char* shopres; + shopres=sasql_query_shop(dataname,startrow,shopnum); + lssproto_SHOP_send(fd,shopnum,vippoint,piece,pieces,shopflag,shopres); + } +} + +void lssproto_SHOPBUY_recv(int fd,int shopflag,int piece,int shopno,int buynum) +{ + int charaindex = CONNECT_getCharaindex(fd); + int i,petindex; + if(!CHAR_CHECKINDEX(charaindex)) return; + if (CHAR_getWorkInt( charaindex, CHAR_WORKSAFEMODE)==0) + { + CHAR_SafePassword(charaindex); + return; + } + if(shopflag==1) + { + for( i = 0 ;i < CHAR_MAXPETHAVE ; i++) { + petindex = CHAR_getCharPet( charaindex, i); + if( petindex == -1 ) + break; + } + + if( i+buynum > CHAR_MAXPETHAVE ) { + CHAR_talkToCli( charaindex, -1, "", CHAR_COLORYELLOW); + return; + } + } + else + { + if(buynum>CHAR_findSurplusItemBox(charaindex)){ + CHAR_talkToCli( charaindex, -1, "Ʒλ㡣", CHAR_COLORYELLOW); + + return; + } + } + char *mycdkey=CHAR_getChar(charaindex,CHAR_CDKEY); + char dataname[20]; + int rownum=0,pieces=0,shopnum=0,startrow,vippoint=0; + sprintf(dataname,"OnlineShop%d",shopflag); + vippoint=sasql_vippoint(mycdkey,0,0); + rownum=sasql_chehk_shop(dataname); + if(rownum>0) + { + pieces=rownum/8+1; + shopnum=rownum-8*(piece-1); + if(shopnum>8) shopnum=8; + startrow=8*(piece-1); + char* shopres; + shopres=sasql_query_shop(dataname,startrow,shopnum); + int pvippoint = - sasql_buy_shop(dataname,startrow,shopnum,shopno) * buynum; + vippoint=sasql_vippoint(mycdkey,pvippoint,1); + //saacproto_ACShopBuy_send(fd, charaindex,0,vippoint,piece,pieces,shopflag,shopres,shopno,buynum); + } + //saacproto_ACShopBuy_send(fd,mycdkey,charaindex,shopflag,piece,shopno,buynum); +} +#endif diff --git a/char/addressbook.c b/char/addressbook.c new file mode 100644 index 0000000..ea7530e --- /dev/null +++ b/char/addressbook.c @@ -0,0 +1,914 @@ +#define __ADDRESSBOOK_C_ +#include "version.h" + +#include +#include +#include +#include + +#include "addressbook.h" +#include "char.h" +#include "handletime.h" +#include "buf.h" +#include "net.h" +#include "lssproto_serv.h" +#include "saacproto_cli.h" +#include "object.h" +#include "battle.h" +#include "configfile.h" +#include "npcutil.h" +#include "pet.h" +#include "petmail.h" +#include "log.h" + +/*ö⼰ ӮӮƱƥ ٯ Ӯ + ľƱ³*/ +#define ADDRESSBOOK_FIXEDMESSAGE_MAXLEN 128 + +/* м岾ئ׼ƥʧƤͱܰƥئ + 弰ö */ +#define ADDRESSBOOK_CANTADD "ûκˡ" +#define ADDRESSBOOK_CANTADD2 "޷Ƭ" + +/* ë³绥ƥб˪¶*/ +#define ADDRESSBOOK_ADDED "%sƬ " + +/* ӿëľ */ +#define ADDRESSBOOK_BEINGADDED "%sƬ " + +/* ޼з弰 */ +#define ADDRESSBOOK_MYTABLEFULL "Ƭϻ" + +/* 켰޼з弰 */ +#define ADDRESSBOOK_HISTABLEFULL "ԷƬϻ" + + +/* ë˪¼ */ +#define ADDRESSBOOK_SENT "Ÿ%s " + +/* ë˪¼ */ +#define ADDRESSBOOK_UNSENT "޷Ÿ%s " + +/* ë׻ȱ崴 */ +#define ADDRESSBOOK_ALREADYADDED "Ѿ%sƬˡ " + +/* ͭë */ +#define ADDRESSBOOK_GIVEADDRESS "%sõƬ" + +/* ͭë ؤ */ +#define ADDRESSBOOK_TAKEADDRESS1 "%sԼƬ" +/* ͭë ؤ */ +#define ADDRESSBOOK_TAKEADDRESS2 "Ϊ%sҪƬԽƬˡ" + +#define ADDRESSBOOK_RETURNED1 \ +"%sżû%sƬֽż˻ء" + +#define ADDRESSBOOK_RETURNED2 \ +"ż%s%s ûƬżֱ˻ˡ" + +#define PETMAIL_RETURNED1 \ +"%s޷ż" + + +/* staticƥã а*/ +char ADDRESSBOOK_returnstring[25*128]; + + + +static int ADDRESSBOOK_findBlankEntry( int cindex ); +static BOOL ADDRESSBOOK_makeEntryFromCharaindex( int charaindex, + ADDRESSBOOK_entry* ae); + +/*------------------------------------------------------------ + * ʧƤͼë˪ + * MSGᆴչľ£ + * + * ֧³練connectioncdkeyƥƻƽҷ + * գ MSG_send£۹м + * 켰ئئе֣ + * ¦ + * cindex int ƽҷ¼index + * aindex int ʧƤͼindex + * text char* ˪ ٯ + * color int + * ߯Ի + * ̼ƽҷ±嶪ë˪TRUE , + * ׷̼ FALSEë + ------------------------------------------------------------*/ +BOOL ADDRESSBOOK_sendMessage( int cindex, int aindex, char* text , int color ) +{ + int i ; + char tmpmsg[256]; + char textbuffer[2048]; + char *mycd; + char *mycharaname = CHAR_getChar(cindex,CHAR_NAME ); + struct tm tm1; + ADDRESSBOOK_entry *ae; + int playernum = CHAR_getPlayerMaxNum(); + + if( !CHAR_CHECKINDEX(cindex) )return FALSE; + + ae = CHAR_getAddressbookEntry( cindex , aindex ); + if( ae == NULL )return FALSE; +#ifdef _AVOIDATTACK_IN_ADDRESSBOOK_sendMessage_textToLong + if( strlen(text) > 256 ) + return FALSE; +#endif + //getcdkeyFromCharaIndex(cindex, mycd,sizeof(mycd) ); + mycd = CHAR_getChar( cindex, CHAR_CDKEY); + + memcpy( &tm1, localtime( (time_t *)&NowTime.tv_sec), sizeof( tm1)); + + snprintf( textbuffer, sizeof( textbuffer), + "%2d/%02d %2d:%02d|%s|-1", + tm1.tm_mon +1, tm1.tm_mday, tm1.tm_hour, tm1.tm_min, + text); + + /* ӡ */ + for( i = 0 ; i < playernum ; i ++){ + if( CHAR_CHECKINDEX( i) && + strcmp( CHAR_getChar( i, CHAR_CDKEY), ae->cdkey) == 0 && + strcmp( CHAR_getChar( i, CHAR_NAME), ae->charname) == 0 ) + { + /* + * CDKEY ƽҷ ף۹ƽҷ + * ʧƤͱм ؤ¾Ʃͻ + * գMSG£ + */ + int index_to_my_info = + ADDRESSBOOK_getIndexInAddressbook( i , + mycd, mycharaname); + + int fd; + if( index_to_my_info < 0 ){ + /* + * 컥ëƻȻ£ + * ɱ бݶﻥ ɧ£ + */ + //snprintf( tmpmsg, sizeof( tmpmsg), + // ADDRESSBOOK_RETURNED1, + // ae->charname + // ); + + //CHAR_talkToCli( CONNECT_getCharaindex(i), -1, + // tmpmsg , CHAR_COLORYELLOW ); + + snprintf( tmpmsg, sizeof( tmpmsg), + ADDRESSBOOK_RETURNED2, + CHAR_getChar( i, CHAR_NAME), + CHAR_getChar( i, CHAR_NAME)); + + /* ˪ԻDZֶ */ + CHAR_talkToCli( cindex, -1, + tmpmsg , CHAR_COLORYELLOW ); + return FALSE; + } + + fd = getfdFromCharaIndex( i); + if( fd != -1 ) { + lssproto_MSG_send( fd , index_to_my_info , textbuffer , color ); + /* Ի */ + printl( LOG_TALK, "CD=%s\tNM=%s\tT=%s" , mycd, mycharaname, textbuffer ); + + } + + snprintf( tmpmsg , sizeof( tmpmsg),ADDRESSBOOK_SENT, + ae->charname ); + CHAR_talkToCli(cindex,-1, tmpmsg , color ); + + // WON ADD snprintfᵼµbug + { + char tmp[1000]; + sprintf( tmp , "ADDRESSBOOK_sendMessage:" + "Send MSG to: %s %s\n", + ae->cdkey , ae->charname ); + // print( tmp ); + } + + CHAR_setInt( cindex, CHAR_SENDMAILCOUNT, + CHAR_getInt( cindex, CHAR_SENDMAILCOUNT)+1); + return TRUE; + } + } + /* έئݷʧӡ˪ */ + saacproto_Message_send( acfd, mycd, mycharaname, + ae->cdkey, ae->charname, textbuffer, color); + CHAR_setInt( cindex, CHAR_SENDMAILCOUNT, + CHAR_getInt( cindex, CHAR_SENDMAILCOUNT)+1); + + + snprintf( tmpmsg , sizeof( tmpmsg),ADDRESSBOOK_SENT,ae->charname ); + CHAR_talkToCli( cindex,-1, tmpmsg , CHAR_COLORWHITE ); + + return FALSE; +} +/*------------------------------------------------------------ + * ʧƤͼë˪ + * saac msg ëȻͷʧ̵£ + * + * ߯Ի + ------------------------------------------------------------*/ +BOOL ADDRESSBOOK_sendMessage_FromOther( char *fromcdkey, char *fromcharaname, + char *tocdkey, char *tocharaname, + char* text , int color ) +{ +#define ADDRESSBOOK_SYSTEM "system" + + int i ; + char tmpmsg[256]; + int playernum = CHAR_getPlayerMaxNum(); + + /* ӡ ë */ + for( i = 0 ; i < playernum ; i ++){ + if( CHAR_CHECKINDEX( i) && + strcmp( CHAR_getChar( i, CHAR_CDKEY), tocdkey) == 0 && + strcmp( CHAR_getChar( i, CHAR_NAME), tocharaname) == 0) + { + int index_to_my_info; + /* + * CDKEY ƽҷ ף۹ƽҷ + * ʧƤͱм ؤ¾Ʃͻ + * գMSG£ + */ + + /* ˵ ة⻥Ȼ */ + if( strcmp( fromcdkey, ADDRESSBOOK_SYSTEM) == 0 && + strcmp( fromcharaname, ADDRESSBOOK_SYSTEM ) == 0 ) + { + /* ˵ ةë */ + CHAR_talkToCli( i, -1, text , color ); + break; + } + + index_to_my_info = + ADDRESSBOOK_getIndexInAddressbook( i , + fromcdkey, fromcharaname); + if( index_to_my_info < 0 ){ + /* + * 컥ëƻȻ£ + */ + + snprintf( tmpmsg, sizeof( tmpmsg), ADDRESSBOOK_RETURNED2, + tocharaname, tocharaname); + + /* ˪ԻDZֶ */ + saacproto_Message_send( acfd, ADDRESSBOOK_SYSTEM , ADDRESSBOOK_SYSTEM, + fromcdkey, fromcharaname, tmpmsg, CHAR_COLORYELLOW); + + } + else { + int fd = getfdFromCharaIndex( i); + if( fd != -1 ) { + lssproto_MSG_send( fd , index_to_my_info , text , color ); + /* Ի */ + printl( LOG_TALK, "CD=%s\tNM=%s\tT=%s" , fromcdkey, + fromcharaname, text ); + } + } + break; + } + } + if( i == playernum ) return FALSE; + return TRUE; +} + +int ADDRESSBOOK_getIndexInAddressbook(int cindex , char *cdkey, + char *charname) +{ + int i ; + + if( !CHAR_CHECKINDEX( cindex ) ) return -1; + + for( i = 0 ; i < ADDRESSBOOK_MAX ; i++){ + ADDRESSBOOK_entry *ae = CHAR_getAddressbookEntry( cindex , i ); + if( ae && ae->use && strcmp( ae->cdkey, cdkey )==0 && + strcmp( ae->charname , charname ) == 0 ){ + return i; + } + } + return -1; +} + +BOOL ADDRESSBOOK_deleteEntry( int meindex ,int index ) +{ + ADDRESSBOOK_entry ent; + BOOL ret; + if( !CHAR_CHECKINDEX( meindex ) ) return FALSE; + + memset( &ent ,0, sizeof( ADDRESSBOOK_entry )); + ret = CHAR_setAddressbookEntry( meindex , index , &ent ); + if( ret == TRUE ){ + ADDRESSBOOK_sendAddressbookTable( meindex ); + return TRUE; + } + return FALSE; +} + +BOOL ADDRESSBOOK_addEntry( int meindex ) +{ + int objbuf[20]; + int found_count; + int front_x , front_y; + int i; + int cnt = 0; + int fd; + char *mycd , *tocd; + BOOL found = FALSE; + + if( !CHAR_CHECKINDEX( meindex ) )return FALSE; + + fd = getfdFromCharaIndex( meindex); + if( fd == -1 ) return FALSE; + + if( ADDRESSBOOK_findBlankEntry( meindex ) < 0) { + CHAR_talkToCli( meindex , -1,ADDRESSBOOK_MYTABLEFULL,CHAR_COLORWHITE ); + return FALSE; + } + + for( i = 0; i < CONNECT_WINDOWBUFSIZE; i ++ ) { + CONNECT_setTradecardcharaindex( fd,i,-1); + } + + CHAR_getCoordinationDir( CHAR_getInt( meindex, CHAR_DIR ) , + CHAR_getInt( meindex , CHAR_X ), + CHAR_getInt( meindex , CHAR_Y ) , + 1 , &front_x , &front_y ); + + found_count = CHAR_getSameCoordinateObjects( objbuf, + arraysizeof( objbuf), + CHAR_getInt(meindex,CHAR_FLOOR), + front_x,front_y ); + if( found_count == 0 ){ + CHAR_talkToCli( meindex, -1, ADDRESSBOOK_CANTADD, CHAR_COLORWHITE); + return FALSE; + } + for( i = 0 ; i < found_count; i++ ){ + int objindex = objbuf[i]; + int index = OBJECT_getIndex( objindex); + if( OBJECT_getType(objindex) != OBJTYPE_CHARA ) { + continue; + } + if( CHAR_getInt( index,CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER ){ + continue; + } + if( index == meindex ) { + continue; + } + found = TRUE; + if( CHAR_getWorkInt( index, CHAR_WORKBATTLEMODE) != BATTLE_CHARMODE_NONE) { + continue; + } + if(!CHAR_getFlg( index, CHAR_ISTRADECARD)) { + continue; + } + if( ADDRESSBOOK_findBlankEntry( index ) < 0 ) { + continue; + } + tocd = CHAR_getChar( index, CHAR_CDKEY); + mycd = CHAR_getChar( meindex, CHAR_CDKEY); + if( ADDRESSBOOK_getIndexInAddressbook( meindex, tocd, + CHAR_getChar( index, CHAR_NAME)) >= 0 && + ADDRESSBOOK_getIndexInAddressbook( index, mycd, + CHAR_getChar(meindex, CHAR_NAME) ) >= 0 ) { + continue; + } + + CONNECT_setTradecardcharaindex( fd,cnt,index); + cnt ++; + if( cnt == CONNECT_WINDOWBUFSIZE ) break; + } + + if( cnt == 0 ) { + if( found ) { + CHAR_talkToCli( meindex, -1, ADDRESSBOOK_CANTADD2, CHAR_COLORWHITE); + }else { + CHAR_talkToCli( meindex, -1, ADDRESSBOOK_CANTADD, CHAR_COLORWHITE); + } + return FALSE; + } + if( cnt == 1 ) { + ADDRESSBOOK_addAddressBook( meindex, + CONNECT_getTradecardcharaindex(fd,0) ); + return TRUE; + }else if( cnt > 1 ) { + int strlength; + char msgbuf[1024]; + char escapebuf[2048]; + strcpy( msgbuf, "1\n˭Ƭأ\n"); + strlength = strlen( msgbuf); + for( i = 0; + CONNECT_getTradecardcharaindex(fd,i) != -1 + && i< CONNECT_WINDOWBUFSIZE; i ++ ){ + char *a = CHAR_getChar( CONNECT_getTradecardcharaindex(fd,i), + CHAR_NAME); + char buf[256]; + snprintf( buf, sizeof( buf),"%s\n", a); + if( strlength + strlen( buf) > arraysizeof( msgbuf)){ + print( "%s:%dӴѶϢbuffer㡣\n", + __FILE__,__LINE__); + break; + } + strcpy( &msgbuf[strlength], buf); + strlength += strlen(buf); + } + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_SELECT, + WINDOW_BUTTONTYPE_CANCEL, + CHAR_WINDOWTYPE_SELECTTRADECARD, + -1, + makeEscapeString( msgbuf, escapebuf, sizeof(escapebuf))); + return TRUE; + } + + return FALSE; +} + +static int ADDRESSBOOK_findBlankEntry( int cindex ) +{ + int i; + + if( CHAR_CHECKINDEX( cindex ) == FALSE )return -1; + + for( i=0 ; iuse == FALSE ) { + return i; + } + } + return -1; +} + +static BOOL ADDRESSBOOK_makeEntryFromCharaindex( int charaindex, + ADDRESSBOOK_entry* ae) +{ + char *cdkey; + + if( !CHAR_CHECKINDEX(charaindex) ) return FALSE; + + memset( ae,0,sizeof(ADDRESSBOOK_entry) ); + cdkey = CHAR_getChar( charaindex, CHAR_CDKEY); + if( cdkey == "\0" || cdkey == NULL ){ + print( "ADDRESSBOOK_makeEntryFromCharaindex:" + " strange! getcdkeyFromCharaIndex returns NULL!" + " charaindex: %d\n" , charaindex ); + return FALSE; + } + strcpysafe( ae->cdkey , sizeof( ae->cdkey ),cdkey); + + strcpysafe( ae->charname,sizeof( ae->charname), + CHAR_getChar(charaindex,CHAR_NAME) ); + ae->level = CHAR_getInt( charaindex , CHAR_LV ); + ae->duelpoint = CHAR_getInt( charaindex, CHAR_DUELPOINT); + ae->graphicsno = CHAR_getInt( charaindex , CHAR_FACEIMAGENUMBER ); + ae->online = getServernumber(); + ae->use = TRUE; + ae->transmigration = CHAR_getInt( charaindex, CHAR_TRANSMIGRATION); + + return TRUE; +} + +void ADDRESSBOOK_notifyLoginLogout( int cindex , int flg ) +{ + int i; + char *cd=NULL; + char *nm = CHAR_getChar( cindex , CHAR_NAME ); + int playernum = CHAR_getPlayerMaxNum(); + + if( !CHAR_CHECKINDEX( cindex ) )return; + cd = CHAR_getChar( cindex, CHAR_CDKEY); + + CHAR_send_DpDBUpdate_AddressBook( cindex, flg ); + + for( i = 0 ; i < playernum ; i++){ + if( CHAR_CHECKINDEX( i) && i != cindex ) { + int j; + for( j = 0 ; juse == TRUE && + strcmp( ae->cdkey , cd ) == 0 && + strcmp( ae->charname, nm ) == 0 ){ + + ae->online = (flg == 0 ) ? 0: getServernumber(); + ae->level = CHAR_getInt( cindex , CHAR_LV ); + ae->duelpoint = CHAR_getInt( cindex, CHAR_DUELPOINT); + ae->graphicsno = CHAR_getInt( cindex, CHAR_FACEIMAGENUMBER ); + ae->transmigration = CHAR_getInt( cindex, CHAR_TRANSMIGRATION); + + ADDRESSBOOK_sendAddressbookTableOne( i,j ); + + break; + } + } + } + } + + if( flg == 0 ){ + saacproto_Broadcast_send( acfd,cd, nm, "offline", 1); + }else if( flg == 1 ) { + for( i = 0 ; i < ADDRESSBOOK_MAX; i++ ){ + int j; + ADDRESSBOOK_entry* ae; + ae = CHAR_getAddressbookEntry( cindex, i ); + if( ae->use == 0 )continue; + ae->online = 0; + for( j=0 ; j < playernum ; j++ ) { + if( CHAR_CHECKINDEX( j) && + strcmp( ae->cdkey, CHAR_getChar( j, CHAR_CDKEY)) == 0 && + strcmp( ae->charname, CHAR_getChar( j, CHAR_NAME) )== 0){ + ae->level = CHAR_getInt( j, CHAR_LV ); + ae->graphicsno = CHAR_getInt( j, CHAR_FACEIMAGENUMBER ); + ae->online = getServernumber(); + ae->transmigration = CHAR_getInt( j, CHAR_TRANSMIGRATION); + break; + } + } + if( j == playernum) { + char buff[512]; + char escapebuf[1024]; + ae->online = 0; + snprintf( buff, sizeof(buff), "%s_%s", ae->cdkey, ae->charname); + makeEscapeString( buff, escapebuf, sizeof(escapebuf)); + saacproto_DBGetEntryString_send( acfd, DB_ADDRESSBOOK, escapebuf, 0,0); + } + } + ADDRESSBOOK_sendAddressbookTable(cindex); + saacproto_Broadcast_send( acfd,cd, nm, "online", 1); + saacproto_MessageFlush_send( acfd, cd, nm); + } +} + +BOOL ADDRESSBOOK_sendAddressbookTable( int cindex ) +{ + int stringlen=0; + int i; + + if( !CHAR_CHECKINDEX( cindex ) )return FALSE; + + for( i=0 ; iuse ){ + char tmp[CHARNAMELEN+32]; + char charname_escaped[CHARNAMELEN*2]; + makeEscapeString( ae->charname, charname_escaped , + sizeof(charname_escaped )); + /* ð׷º| |ì|̰|׷º */ + snprintf( tmp , sizeof( tmp ), + "%d|%s|%d|%d|%d|%d|%d|0|" , + ae->use, + charname_escaped , ae->level , + ae->duelpoint,ae->online,ae->graphicsno, + ae->transmigration); + strcpysafe ( ADDRESSBOOK_returnstring + stringlen , + sizeof(ADDRESSBOOK_returnstring) - stringlen, + tmp ); + stringlen += strlen( tmp ); + if( stringlen >= sizeof(ADDRESSBOOK_returnstring) ) { + break; + } + }else{ + /*Ȼئзֳ߼ƥ˪ */ + char tmp[32]; + snprintf( tmp , sizeof( tmp ), "||||||||" ); + strcpysafe ( ADDRESSBOOK_returnstring + stringlen , + sizeof(ADDRESSBOOK_returnstring) - stringlen, + tmp ); + stringlen += strlen( tmp ); + if( stringlen >= sizeof(ADDRESSBOOK_returnstring)) { + break; + } + } + } + + dchop( ADDRESSBOOK_returnstring, "|" ); + + { + int fd; + fd = getfdFromCharaIndex( cindex ); + if( fd == -1 ) return FALSE; + lssproto_AB_send( fd, ADDRESSBOOK_returnstring ); + } + return TRUE; +} + +BOOL ADDRESSBOOK_sendAddressbookTableOne( int cindex, int num ) +{ + int stringlen=0; + ADDRESSBOOK_entry *ae; + + if( !CHAR_CHECKINDEX( cindex ) )return FALSE; + if( num < 0 || num > ADDRESSBOOK_MAX) return FALSE; + + ae = CHAR_getAddressbookEntry( cindex , num ); + + if( ae && ae->use ){ + char tmp[CHARNAMELEN+32]; + char charname_escaped[CHARNAMELEN*2]; + makeEscapeString( ae->charname, charname_escaped , + sizeof(charname_escaped )); + snprintf( tmp , sizeof( tmp ), + "%d|%s|%d|%d|%d|%d|%d|0|" , + ae->use, + charname_escaped , ae->level , + ae->duelpoint,ae->online,ae->graphicsno, + ae->transmigration); + strcpysafe ( ADDRESSBOOK_returnstring + stringlen , + sizeof(ADDRESSBOOK_returnstring) - stringlen, + tmp ); + stringlen += strlen( tmp ); + if( stringlen >= sizeof(ADDRESSBOOK_returnstring) ) { + return FALSE; + } + }else{ + char tmp[32]; + snprintf( tmp , sizeof( tmp ), "||||||||" ); + strcpysafe ( ADDRESSBOOK_returnstring + stringlen , + sizeof(ADDRESSBOOK_returnstring) - stringlen, + tmp ); + stringlen += strlen( tmp ); + if( stringlen >= sizeof(ADDRESSBOOK_returnstring)) { + return FALSE; + } + } + + { + int fd; + fd = getfdFromCharaIndex( cindex ); + if( fd == -1 ) return FALSE; + lssproto_ABI_send( fd, num, ADDRESSBOOK_returnstring ); + } + return TRUE; +} + +/*------------------------------------------------------------ + * 繴ʧƤ;޼ë ٯ ئʣ + * ľƽҷئƥͷʧ˪·ԻֿҸ + * ئּƥؤ ۢؤ£ + * ¦ + * a ADDRESSBOOK_entry* ٯ հ ߼̼ + * ߯Ի + * char * + ------------------------------------------------------------*/ +char *ADDRESSBOOK_makeAddressbookString( ADDRESSBOOK_entry *a ) +{ + char work1[256], work2[256]; + + if( a->use == 0 ){ + /* ޼ ٯ */ + ADDRESSBOOK_returnstring[0] = '\0'; + return ADDRESSBOOK_returnstring; + } + + makeEscapeString( a->cdkey, work1, sizeof( work1 )); + makeEscapeString( a->charname , work2 , sizeof( work2 )); + snprintf( ADDRESSBOOK_returnstring, + sizeof( ADDRESSBOOK_returnstring ), + "%s|%s|%d|%d|%d|%d", + work1, work2, a->level, a->duelpoint, a->graphicsno,a->transmigration); + + return ADDRESSBOOK_returnstring; + +} + +/*------------------------------------------------------------ + * ٯ ľʧƤ;޼ëհ ئʣ + * հ use½ ձئ£ + * ¦ + * in char* ٯ + * a ADDRESSBOOK_entry* ë谻 + * ߯Ի + * ѱTRUE + ------------------------------------------------------------*/ +BOOL ADDRESSBOOK_makeAddressbookEntry( char *in , ADDRESSBOOK_entry *a ) +{ + char work1[256], work2[256] , work3[256] , work4[256],work5[256],work6[256]; + int ret; + if( strlen( in ) == 0 ){ + memset( a,0,sizeof(ADDRESSBOOK_entry) ); + a->use = 0; + return TRUE; + } + + getStringFromIndexWithDelim( in, "|" , 1 , work1 , sizeof( work1 )); + getStringFromIndexWithDelim( in, "|" , 2 , work2 , sizeof( work2 )); + getStringFromIndexWithDelim( in, "|" , 3 , work3 , sizeof( work3 )); + getStringFromIndexWithDelim( in, "|" , 4 , work4 , sizeof( work4 )); + getStringFromIndexWithDelim( in, "|" , 5 , work5 , sizeof( work5 )); + work6[0] = '\0'; + ret = getStringFromIndexWithDelim( in, "|" , 6 , work6 , sizeof( work6 )); + if( ret == FALSE ) { + a->transmigration = 0; + } + else { + a->transmigration = atoi( work6); + } + a->use = 1; + + makeStringFromEscaped( work1 ); + makeStringFromEscaped( work2 ); + + strcpysafe( a->cdkey , sizeof(a->cdkey) , work1 ); + strcpysafe( a->charname , sizeof(a->charname), work2 ); + + a->level = atoi( work3 ); + a->duelpoint = atoi( work4 ); + a->graphicsno = atoi( work5 ); + + return FALSE; +} + +void ADDRESSBOOK_addAddressBook( int meindex, int toindex) +{ + char tmpstring[CHARNAMELEN + + ADDRESSBOOK_FIXEDMESSAGE_MAXLEN]; + + int hisblank; + int myblank; + int myaddindex, toaddindex; + int dir; + char *cdkey; + + hisblank = ADDRESSBOOK_findBlankEntry( toindex ); + if( hisblank < 0 ) { + CHAR_talkToCli( meindex, -1, ADDRESSBOOK_HISTABLEFULL, CHAR_COLORWHITE); + return ; + } + myblank = ADDRESSBOOK_findBlankEntry( meindex ); + if( myblank < 0 ){ + CHAR_talkToCli( meindex , -1, ADDRESSBOOK_MYTABLEFULL, CHAR_COLORWHITE ); + return ; + } + + cdkey = CHAR_getChar( toindex, CHAR_CDKEY); + myaddindex = ADDRESSBOOK_getIndexInAddressbook( meindex, cdkey, + CHAR_getChar( toindex, CHAR_NAME)); + cdkey = CHAR_getChar( meindex, CHAR_CDKEY); + toaddindex = ADDRESSBOOK_getIndexInAddressbook( toindex, cdkey, + CHAR_getChar(meindex, CHAR_NAME)); + if( myaddindex < 0 ){ + ADDRESSBOOK_entry hisentry; + + if( ADDRESSBOOK_makeEntryFromCharaindex(toindex,&hisentry) == FALSE ){ + return ; + } + CHAR_setAddressbookEntry( meindex, myblank,&hisentry ); + + snprintf( tmpstring, sizeof( tmpstring), + toaddindex < 0 ? ADDRESSBOOK_ADDED: ADDRESSBOOK_GIVEADDRESS, + hisentry.charname); + CHAR_talkToCli( meindex , -1,tmpstring, CHAR_COLORWHITE ); + ADDRESSBOOK_sendAddressbookTableOne( meindex, myblank); + }else{ + snprintf( tmpstring, sizeof( tmpstring), ADDRESSBOOK_TAKEADDRESS1, + CHAR_getChar( toindex, CHAR_NAME)); + CHAR_talkToCli( meindex, -1, tmpstring, CHAR_COLORWHITE); + + } + if( toaddindex < 0 ) { + ADDRESSBOOK_entry meae; + if( ADDRESSBOOK_makeEntryFromCharaindex(meindex,&meae) == FALSE) { + return; + } + CHAR_setAddressbookEntry( toindex, hisblank,&meae ); + snprintf( tmpstring , sizeof( tmpstring), + myaddindex < 0 ? ADDRESSBOOK_ADDED : ADDRESSBOOK_GIVEADDRESS, + CHAR_getChar( meindex, CHAR_NAME ) ); + CHAR_talkToCli( toindex, -1, tmpstring, CHAR_COLORWHITE); + ADDRESSBOOK_sendAddressbookTableOne( toindex , hisblank); + }else { + if( myaddindex < 0 ) { + snprintf( tmpstring , sizeof( tmpstring), + ADDRESSBOOK_TAKEADDRESS2, + CHAR_getChar( meindex, CHAR_NAME ) ); + CHAR_talkToCli( toindex, -1, tmpstring, CHAR_COLORWHITE); + } + } + dir = NPC_Util_GetDirCharToChar( toindex, meindex, 0); + if( dir != -1) { + + if( CHAR_getInt( toindex, CHAR_DIR) != dir) { + CHAR_setInt( toindex, CHAR_DIR, dir); + } + CHAR_sendWatchEvent( CHAR_getWorkInt( toindex, CHAR_WORKOBJINDEX), + CHAR_ACTNOD,NULL,0,TRUE); + CHAR_setWorkInt( toindex, CHAR_WORKACTION, CHAR_ACTNOD); + CHAR_sendWatchEvent( CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + CHAR_ACTNOD,NULL,0,TRUE); + CHAR_setWorkInt( meindex, CHAR_WORKACTION, CHAR_ACTNOD); + } + return; +} + + +void ADDRESSBOOK_DispatchMessage( char *cd, char *nm, char *value, int mode) +{ + int i; + char work[256]; + int online,level,duelpoint, faceimagenumber, transmigration; + int playernum = CHAR_getPlayerMaxNum(); + int ret; + + getStringFromIndexWithDelim( value, "|" , 1 , work , sizeof( work )); + online = atoi( work); + getStringFromIndexWithDelim( value, "|" , 2 , work , sizeof( work )); + level = atoi( work); + getStringFromIndexWithDelim( value, "|" , 3 , work , sizeof( work )); + duelpoint = atoi( work); + getStringFromIndexWithDelim( value, "|" , 4 , work , sizeof( work )); + faceimagenumber = atoi( work); + ret = getStringFromIndexWithDelim( value, "|" , 5 , work , sizeof( work )); + if( ret ) { + transmigration = atoi( work); + } + else { + transmigration = 0; + } + + if( online == getServernumber()) { + for( i = 0 ; i < playernum ; i++) { + if( CHAR_CHECKINDEX( i )) { + char *c = CHAR_getChar( i, CHAR_CDKEY); + char *n = CHAR_getChar( i, CHAR_NAME); + if( c == "\0" || n == "\0" ) continue; + if( c == NULL || n == NULL ) continue; + if( strcmp( c , cd ) == 0 && strcmp( n, nm ) == 0 ) { + break; + } + } + } + if( i == playernum ) { + online = 0; + saacproto_Broadcast_send( acfd,cd, nm, "offline", 1); + } + } + + for( i = 0 ; i < playernum ; i++) { + if( CHAR_CHECKINDEX( i )) { + int j; + for( j = 0 ; j < ADDRESSBOOK_MAX ; j++) { + ADDRESSBOOK_entry *ae; + ae = CHAR_getAddressbookEntry( i ,j ); + if( ae && ae->use == TRUE && + strcmp( ae->cdkey , cd ) == 0 && + strcmp( ae->charname, nm ) == 0 ) + { + if( mode == 0 ) { + ae->use = FALSE; + }else { + ae->online = online; + ae->level = level; + ae->duelpoint = duelpoint; + ae->graphicsno = faceimagenumber; + ae->transmigration = transmigration; + } + ADDRESSBOOK_sendAddressbookTableOne( i,j ); + + break; + } + } + } + } +} + +#ifdef _ANGLE_EMAIL +BOOL ADDRESSBOOK_AutoaddAddressBook( int meindex, int toindex) +{ + int hisblank; + int myblank; + int myaddindex, toaddindex; + + char *cdkey; + + myblank = ADDRESSBOOK_findBlankEntry( meindex ); + hisblank = ADDRESSBOOK_findBlankEntry( toindex ); + + //myblank = 79; + //hisblank = 79; + + if( hisblank < 0 || myblank < 0) { //"Ƭϻ" + return FALSE; + } + + cdkey = CHAR_getChar( toindex, CHAR_CDKEY); + myaddindex = ADDRESSBOOK_getIndexInAddressbook( meindex, cdkey, + CHAR_getChar( toindex, CHAR_NAME)); + cdkey = CHAR_getChar( meindex, CHAR_CDKEY); + toaddindex = ADDRESSBOOK_getIndexInAddressbook( toindex, cdkey, + CHAR_getChar(meindex, CHAR_NAME)); + if( myaddindex < 0 ){ + ADDRESSBOOK_entry meae; + ADDRESSBOOK_entry hisentry; + if( ADDRESSBOOK_makeEntryFromCharaindex(toindex,&hisentry) == FALSE || + ADDRESSBOOK_makeEntryFromCharaindex(meindex,&meae) == FALSE ){ + return FALSE; + } + CHAR_setAddressbookEntry( meindex, myblank,&hisentry ); + CHAR_setAddressbookEntry( toindex, hisblank,&meae ); + ADDRESSBOOK_sendAddressbookTableOne( meindex, myblank); + ADDRESSBOOK_sendAddressbookTableOne( toindex , hisblank); + } + return TRUE; +} +#endif + diff --git a/char/char.c b/char/char.c new file mode 100644 index 0000000..73c6370 --- /dev/null +++ b/char/char.c @@ -0,0 +1,11085 @@ +#include "version.h" +#include +#include +#include +#include // shan +#include +#include +#include +#include +#include "net.h" +#include "common.h" +#include "char_base.h" +#include "char_data.h" +#include "char.h" +#include "lssproto_serv.h" +#include "item.h" +#include "item_event.h" +#include "buf.h" +#include "object.h" +#include "map_deal.h" +#include "saacproto_cli.h" +#include "readmap.h" +#include "handletime.h" +#include "char_event.h" +#include "npccreate.h" +#include "addressbook.h" +#include "item_event.h" +#include "magic_base.h" +#include "magic.h" +#include "chatmagic.h" +#include "configfile.h" +#include "log.h" +#include "anim_tbl.h" +#include "encount.h" +#include "battle.h" +#include "pet_skill.h" +#include "util.h" +#include "enemy.h" +#include "npcutil.h" +#include "pet.h" +#include "family.h" +#include "defend.h" +#include "correct_bug.h" +#ifdef _JOBDAILY +#include "npc_checkman.h" +#endif + +#ifdef _CHAR_PROFESSION // WON ADD ְҵλ +#include "profession_skill.h" +#endif +#ifdef _CHATROOMPROTOCOL // (ɿ) Syu ADD Ƶ +#include "chatroom.h" +#endif +#ifdef _ALLBLUES_LUA +#include "mylua/function.h" +#endif +extern int channelMember[FAMILY_MAXNUM][FAMILY_MAXCHANNEL][FAMILY_MAXMEMBER]; +extern int familyMemberIndex[FAMILY_MAXNUM][FAMILY_MAXMEMBER]; + +extern tagRidePetTable ridePetTable[296]; +extern int BATTLE_getRidePet( int charaindex ); + +#ifdef _CHANNEL_MODIFY +extern int InitOccChannel(void); +#endif + +#ifdef _ANGEL_SUMMON +extern int checkIfAngelByName( char* nameinfo); +extern char* getMissionNameInfo( int charaindex, char* nameinfo); +extern void CHAR_sendAngelMark( int objindex, int flag); +extern int checkIfOnlyAngel( int charaindex); +extern void selectAngel( int charaindex, int heroindex, int mission, int gm_cmd); +#endif +int CharaData( int sockfd, Char* ch ); +extern void GOLD_DeleteTimeCheckOne( int objindex); +extern int autopkstart; +extern int playeronlinenum; +extern int autopkcnt; +// WON ADD ߵ趨 +void fix_item_bug(int charaindex, int i); + + +/*====================ƽҷ¼====================*/ +/*------------------------------------------------------------ + * ݼëɬƷ£ + * ¦ + * ch Char* ɬƼƽҷ¼ + * option char* ͷʧ· + * ߯Ի + * TRUE + * FALSE + ------------------------------------------------------------*/ +static BOOL CHAR_makeCharFromOptionAtCreate( Char* ch , + int vital, int str, int tgh, int dex, + int earth, int water, int fire, int wind) +{ + + /* 뼰ë浤 */ + int para[4]; + int attr[4]; + int i; + int parasum,attrsum; + int cnt; + + para[0] = vital; + para[1] = str; + para[2] = tgh; + para[3] = dex; + + attr[0] = earth; + attr[1] = water; + attr[2] = fire; + attr[3] = wind; + +#define MAXPARAMETER 20 +#define PKMAXPARAMETER 300 + parasum = 0; + /* + * ͻ - ؤȻئئ + * ؤľëл ئ + */ + + for( i = 0; i < arraysizeof( para); i ++ ) { + if( para[i] < 0 || para[i] > MAXPARAMETER )return FALSE; + parasum += para[i]; + } +#ifdef _NEW_PLAYER_CF //ֳ + if( parasum > MAXPARAMETER ) return FALSE; +#else + if( parasum != MAXPARAMETER ) return FALSE; +#endif + +#undef MAXPARAMETER + + +#define MAXATTRIBUTE 10 + cnt = 0; + attrsum = 0; + /* 뼰ë */ + for( i = 0; i < arraysizeof( para); i ++ ) { + if( attr[i] < 0 || attr[i] > MAXATTRIBUTE )return FALSE; + attrsum += attr[i]; + if( attr[i] > 0 ) cnt ++; + } + /* Ͱ10 */ + if( attrsum != MAXATTRIBUTE ) return FALSE; + + /* 2ԻԻ񲻯ľ */ + if( cnt > 2 ) return FALSE; + + /* 뷴Ի񲻯ľئ */ + if( attr[0] > 0 && attr[2] > 0 ) return FALSE; + if( attr[1] > 0 && attr[3] > 0 ) return FALSE; + +#undef MAXATTRIBUTE + + /* */ + ch->data[CHAR_VITAL] = vital*100; + ch->data[CHAR_STR] = str*100; + ch->data[CHAR_TOUGH] = tgh*100; + ch->data[CHAR_DEX] = dex*100; + + ch->data[CHAR_EARTHAT] = attr[0] * 10; + ch->data[CHAR_WATERAT] = attr[1] * 10; + ch->data[CHAR_FIREAT] = attr[2] * 10; + ch->data[CHAR_WINDAT] = attr[3] * 10; +#ifdef _NEWOPEN_MAXEXP + ch->data[CHAR_OLDEXP] = 0; +#endif + ch->data[CHAR_EXP] = 0; + + +#ifdef _NEW_PLAYER_CF //ֳ + ch->data[CHAR_TRANSMIGRATION] = getNewplayertrans(); + ch->data[CHAR_GOLD] = getNewplayergivegold();; + ch->data[CHAR_LV] = getNewplayerlv(); +#ifdef _VIP_SERVER + ch->data[CHAR_AMPOINT] = getNewplayergivevip(); +#endif +// ch->data[CHAR_LEARNRIDE] = 200; +// ch->data[CHAR_LASTTALKELDER] = (rand()%10)>5?35:36;//34; +// ch->data[CHAR_SKILLUPPOINT] = 616;//600; +#ifdef _NEW_RIDEPETS + //ch->data[CHAR_LOWRIDEPETS] = 0xffffffff; +#endif +#endif + +#ifdef _PETSKILL_BECOMEPIG + ch->data[CHAR_BECOMEPIG] = -1; + ch->data[CHAR_BECOMEPIG_BBI] = 100250; +#endif + + ch->data[CHAR_LASTLEAVETIME] = 0; + + return TRUE; +} + +#ifdef _HELP_NEWHAND +void CHAR_loginAddItemForNew( int charindex ) +{ + int emptyitemindexinchara, itemindex; + int i; + char msgbuf[128]; + + for( i = 0; i < 15; i ++ ) { + emptyitemindexinchara = CHAR_findEmptyItemBox( charindex ); + + if( emptyitemindexinchara < 0 ){ + sprintf( msgbuf, "ռλ㡣" ); + + CHAR_talkToCli( charindex, -1, msgbuf, CHAR_COLORYELLOW); + return; + } +#ifdef _NEW_PLAYER_CF + if(getNewplayergiveitem(i)==-1)continue; + itemindex = ITEM_makeItemAndRegist( getNewplayergiveitem(i) ); +#endif + if( itemindex != -1 ){ + CHAR_setItemIndex( charindex, emptyitemindexinchara, itemindex ); + ITEM_setWorkInt(itemindex, ITEM_WORKOBJINDEX,-1); + ITEM_setWorkInt(itemindex, ITEM_WORKCHARAINDEX,charindex); + CHAR_sendItemDataOne( charindex, emptyitemindexinchara); + } + } + print("Get New Hand Item"); +} +#endif + +void CHAR_createNewChar( int clifd, 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 ) +{ + + Char ch, *chwk; + int charaindex, petindex; + int enemyarray; + char szKey[256]; + +#ifdef _NEW_PLAYER_CF //ֳ + int add_pet[]={0,0,0,0,0}; +#endif + + memset(&ch,0,sizeof(Char)); + + if( !CHAR_checkPlayerImageNumber( imgno)) { + lssproto_CreateNewChar_send( clifd ,FAILED, "" ); + CONNECT_setState( clifd, NOTLOGIN ); + return; + } + if( !CHAR_checkFaceImageNumber( imgno, faceimgno)) { + lssproto_CreateNewChar_send( clifd ,FAILED, "" ); + CONNECT_setState( clifd, NOTLOGIN ); + return; + } + CHAR_getDefaultChar(&ch,imgno); + ch.data[CHAR_WALKINTERVAL] = getWalksendinterval(); + + if( CHAR_getInitElderPosition( &ch ,hometown) == FALSE ){ + lssproto_CreateNewChar_send( clifd ,FAILED, "" ); + CONNECT_setState( clifd, NOTLOGIN ); + return; + + }else if( MAP_checkCoordinates( ch.data[CHAR_FLOOR], ch.data[CHAR_X], + ch.data[CHAR_Y] ) == FALSE ){ + lssproto_CreateNewChar_send( clifd ,FAILED, ""); + CONNECT_setState( clifd, NOTLOGIN ); + return; + } + strcpysafe( ch.string[CHAR_NAME].string , + sizeof(ch.string[CHAR_NAME].string), + charname); + + if( CHAR_getNewImagenumberFromEquip( imgno,0) == -1 ){ + lssproto_CreateNewChar_send( clifd ,FAILED, ""); + CONNECT_setState( clifd, NOTLOGIN ); + return; + } + ch.data[CHAR_BASEIMAGENUMBER] = imgno; + ch.data[CHAR_BASEBASEIMAGENUMBER] = imgno; + ch.data[CHAR_FACEIMAGENUMBER] = faceimgno; + ch.data[CHAR_DATAPLACENUMBER] = dataplacenum; + +#ifdef _FM_JOINLIMIT + ch.data[CHAR_FMTIMELIMIT] = 0; +#endif + +#ifdef _NEWSAVE + ch.data[CHAR_SAVEINDEXNUMBER] = -1; +#endif + ch.data[CHAR_HP] = 0x7fffffff; + + ch.data[CHAR_CHARM] = 60; + ch.data[CHAR_MAXMP] = ch.data[CHAR_MP] = 100; + strcpysafe( ch.string[CHAR_CDKEY].string, + sizeof( ch.string[CHAR_CDKEY].string), cdkey ); + + // Robin 0724 + ch.data[CHAR_RIDEPET] = -1; +#ifdef _NEW_PLAYER_CF + ch.data[CHAR_LEARNRIDE] = getRidePetLevel(); +#endif +#ifdef _NEW_RIDEPETS + ch.data[CHAR_LOWRIDEPETS] = 0; +#endif + +#ifdef _PERSONAL_FAME // Arminius: + ch.data[CHAR_FAME] = 0; +#endif +#ifdef _NEW_MANOR_LAW + ch.data[CHAR_MOMENTUM] = 0; // +#endif +#ifdef _TEACHER_SYSTEM + ch.data[CHAR_TEACHER_FAME] = 0; // ʦ쵼 +#endif + +#ifdef _CHAR_PROFESSION // WON ADD ְҵ + ch.data[PROFESSION_CLASS] = 0; + ch.data[PROFESSION_LEVEL] = 0; +// ch.data[PROFESSION_EXP] = 0; + ch.data[PROFESSION_SKILL_POINT] = 0; + ch.data[ATTACHPILE] = 0; +#endif + +#ifdef _TEACHER_SYSTEM + memset(ch.string[CHAR_TEACHER_ID].string,0,sizeof(STRING128)); + memset(ch.string[CHAR_TEACHER_NAME].string,0,sizeof(STRING128)); +#endif + +#ifdef _ITEM_SETLOVER + memset(ch.string[CHAR_LOVERID].string,0,sizeof(STRING128)); + memset(ch.string[CHAR_LOVERNAME].string,0,sizeof(STRING128)); +#endif + +#ifdef _PETSKILL_BECOMEPIG + ch.data[CHAR_BECOMEPIG] = -1; + ch.data[CHAR_BECOMEPIG_BBI] = 100250; +#endif + + strcpysafe( ch.string[CHAR_FMNAME].string, + sizeof( ch.string[CHAR_FMNAME].string), "\0" ); + ch.data[CHAR_FMINDEX] = -1; +#ifdef _OFFLINE_SYSTEM + time_t timep; + struct tm *p; + time(&timep); + p=localtime(&timep); /*ȡõʱ*/ + int mon=1+p->tm_mon; + int date=p->tm_mday; + char offbuf[64]; + sprintf(offbuf,"%d-%d-%d",mon,date,0); + strcpysafe( ch.string[CHAR_OFFBUF].string, + sizeof( ch.string[CHAR_OFFBUF].string), offbuf ); + //ch.data[CHAR_OFFTIME] = 18000; + ch.data[CHAR_OFFTIME] = 1; +#endif + if( CHAR_makeCharFromOptionAtCreate( &ch, + vital,str,tgh,dex, + earth,water,fire,wind ) == FALSE ) + { + lssproto_CreateNewChar_send( clifd ,FAILED, + "option data is invalid\n"); + CONNECT_setState( clifd, NOTLOGIN ); + return; + } + { + int mp=ch.data[CHAR_MAXMP]; + int str=ch.data[CHAR_STR]; + int tough=ch.data[CHAR_TOUGH]; + + ch.data[CHAR_INITDATA] = 2*100*100*100*100 /*+ hp*100*100*100*/ + + mp*100*100 + str* 100 + tough; + } + + charaindex = CHAR_initCharOneArray( &ch ); + if( charaindex == -1 ) { + lssproto_CreateNewChar_send( clifd ,FAILED, "޷"); + CONNECT_setState( clifd, NOTLOGIN ); + return; + } +#ifdef _ALLBLUES_LUA_1_5 + FreeCharCreate(charaindex); +#endif +#ifdef _NEW_PLAYER_CF //ֳ + int petNum=0; + int k=0; + int mylevel,level; + if(getNewplayergivepet(0)==-1){ + if( CHAR_getInt( charaindex, CHAR_LASTTALKELDER) == 1 )//˿ + setNewplayergivepet(0,2); + else if( CHAR_getInt( charaindex, CHAR_LASTTALKELDER) == 2 )//Ӽ + setNewplayergivepet(0,3); + else if( CHAR_getInt( charaindex, CHAR_LASTTALKELDER) == 3 )//³ + setNewplayergivepet(0,4); + else + setNewplayergivepet(0,1); + } +#ifdef _NEW_PLAYER_RIDE + if(!strstr( getPlayerRide(), "")) + CHAR_PlayerRide(charaindex); +#endif + for( petNum=0; petNum<5; petNum++) { + if(getNewplayergivepet(petNum)==0)continue; + enemyarray = ENEMY_getEnemyArrayFromId( getNewplayergivepet(petNum)); //׻ + petindex = ENEMY_createPetFromEnemyIndex( charaindex, enemyarray); + if( petindex == -1 ) { + continue; + } + add_pet[petNum]=petindex; + mylevel = CHAR_getInt( petindex, CHAR_LV); + level = getNewplayerpetlv()-mylevel; + if(level<1)level=1; + for( k = 1; k < level; k ++ ){ // + CHAR_PetLevelUp( petindex ); + CHAR_PetAddVariableAi( petindex, AI_FIX_PETLEVELUP ); + CHAR_setInt( petindex, CHAR_LV, CHAR_getInt( petindex, CHAR_LV) +1 ); + } + CHAR_setInt( petindex , CHAR_VARIABLEAI , 10000 ); + CHAR_complianceParameter( petindex ); + CHAR_setInt( petindex , CHAR_HP , CHAR_getWorkInt( petindex , CHAR_WORKMAXHP ) ); + } + setNewplayergivepet(0,-1); +#endif + +#ifdef _HELP_NEWHAND + CHAR_loginAddItemForNew(charaindex); +#endif + +#if 1 + if( CHAR_makeDBKey( charaindex, szKey, sizeof( szKey ) ) != FALSE ){ + int dp; + char info[512]; + snprintf( info, sizeof( info), + "%d,%d,%d,%d,%d,%d", + CHAR_getInt( charaindex, CHAR_LV), + CHAR_getInt( charaindex, CHAR_DUELBATTLECOUNT), + CHAR_getInt( charaindex, CHAR_DUELWINCOUNT), + CHAR_getInt( charaindex, CHAR_DUELLOSECOUNT), + CHAR_getInt( charaindex, CHAR_DUELSTWINCOUNT), + CHAR_getInt( charaindex, CHAR_DUELMAXSTWINCOUNT)); + dp = CHAR_getInt( charaindex, CHAR_DUELPOINT ); + saacproto_DBUpdateEntryInt_send( + acfd, + DB_DUELPOINT, + szKey, + (max(dp,0)), + info, + CONNECT_getFdid(clifd ),0 ); + } +#endif + chwk = CHAR_getCharPointer( charaindex); + + CHAR_charSaveFromConnectAndChar( clifd,chwk ,FALSE ); + + CHAR_endCharData(&ch); + CHAR_endCharOneArray( charaindex); +#ifdef _NEW_PLAYER_CF //ֳ + { + int k=0; + for( k=0;kcharfunctable[i].string, + sizeof( ch->charfunctable[i]), + tmp[i]); + } +} + +void CHAR_loginAddItem( int charaindex ) +{ +/* + int emptyindex, itemindex, id; + int itemID[10]={ 20128, 20130, 20171, 20176, 20296, + 20287, 20288, 20289, 20290, 20291}; + + { + int trn_num=0; + trn_num=CHAR_getInt(charaindex,CHAR_TRANSMIGRATION); + CHAR_setInt( charaindex, CHAR_MAXPOOLITEMHAVELIMIT, 10 + (trn_num * 4) ) ; + CHAR_setInt( charaindex, CHAR_MAXPOOLPETHAVELIMIT , 5 + (trn_num * 2) ); + } + while( 1){ + emptyindex = CHAR_findEmptyItemBox( charaindex ); + if( emptyindex == -1 ) break; + id = rand()%10; + itemindex = ITEM_makeItemAndRegist( itemID[id] ); + if( !ITEM_CHECKINDEX( itemindex) ) break; + CHAR_setItemIndex( charaindex, emptyindex, itemindex); + ITEM_setWorkInt( itemindex, ITEM_WORKCHARAINDEX, charaindex); + ITEM_setWorkInt( itemindex, ITEM_WORKOBJINDEX, -1); + //andy_log + print("@:%d.", emptyindex); + } + while( 1){ + emptyindex = CHAR_findEmptyPoolItemBox( charaindex ); + if( emptyindex == -1 ) break; + id = rand()%10; + itemindex = ITEM_makeItemAndRegist( itemID[id] ); + if( !ITEM_CHECKINDEX( itemindex) ) break; + + CHAR_setPoolItemIndex( charaindex, emptyindex, itemindex); + ITEM_setWorkInt( itemindex, ITEM_WORKCHARAINDEX, charaindex); + ITEM_setWorkInt( itemindex, ITEM_WORKOBJINDEX, -1); + //andy_log + print("&:%d.", emptyindex); + } +*/ +} + +void CHAR_loginCheckUserItem( int charaindex) +{ + typedef void (*ATTACHFUNC)(int,int); + int i, j, itemindex; + int ID1,ID2; + char* delbuf; + char delitembuf[10]; + delbuf = getDelItem(); + int myviptype = CHAR_getInt(charaindex,CHAR_VIPRIDE); + for( i=0; i=23228 && ID1<=23307){ + if(strstr(ITEM_getChar(itemindex,ITEM_EFFECTSTRING),"")==NULL){ + ITEM_setChar(itemindex,ITEM_EFFECTSTRING,"[ԣ]뵽峤(13.5)Ҹʦ"); + } + } + if(((ID1>=3000 && ID1<=11719) || (ID1>=14001 && ID1<=18530)) && ITEM_getInt( itemindex, ITEM_MAXDAMAGECRUSHE)<1){ + int maxcrushe = ITEMTBL_getInt(ID1,ITEM_MAXDAMAGECRUSHE); + ITEM_setInt(itemindex,ITEM_MAXDAMAGECRUSHE,maxcrushe); + ITEM_setInt(itemindex,ITEM_DAMAGECRUSHE,maxcrushe); + } +#endif + if(myviptype==0){ + if(strstr(ITEM_getChar(itemindex,ITEM_NAME),"[VIP")!=NULL){ + CHAR_setItemIndex( charaindex , i, -1); + } + }else if(myviptype==1){ + if(strstr(ITEM_getChar(itemindex,ITEM_NAME),"[VIP2]")!=NULL || strstr(ITEM_getChar(itemindex,ITEM_NAME),"[VIP3]")!=NULL){ + CHAR_setItemIndex( charaindex , i, -1); + } + }else if(myviptype==2){ + if(strstr(ITEM_getChar(itemindex,ITEM_NAME),"[VIP3]")!=NULL ){ + CHAR_setItemIndex( charaindex , i, -1); + } + } +#ifdef _JK_CF_DELPETITEM //ɾCFָƷ + for( j=1;j<=30;j++ ) { + if(getStringFromIndexWithDelim(delbuf,",", j, delitembuf, sizeof(delitembuf)) == FALSE) + break; + ID2 = atoi(delitembuf); + if(ID2 == -1)break; + if( ID1 == ID2){ + CHAR_setItemIndex( charaindex , i, -1); + LogItem(CHAR_getChar( charaindex, CHAR_NAME ), // + CHAR_getChar( charaindex, CHAR_CDKEY ), //ʺ +#ifdef _add_item_log_name // WON ADD itemlogitem + itemindex, +#else + ITEM_getInt( itemindex, ITEM_ID ), +#endif + "CFƷ", + CHAR_getInt( charaindex,CHAR_FLOOR), + CHAR_getInt( charaindex,CHAR_X ), + CHAR_getInt( charaindex,CHAR_Y ), + ITEM_getChar( itemindex, ITEM_UNIQUECODE), + ITEM_getChar( itemindex, ITEM_NAME), + ITEM_getInt( itemindex, ITEM_ID) + ); + CHAR_talkToCli( charaindex, -1, "ϵͳϵĵ", CHAR_COLORWHITE ); + } + } +#endif + +#ifdef _ANGEL_SUMMON + if( ITEM_getInt( itemindex, ITEM_ID) == ANGELITEM + || ITEM_getInt( itemindex, ITEM_ID) == HEROITEM ) { + int mindex, mission; + // Ƿ + mindex = checkIfAngelByName( ITEM_getChar( itemindex, ITEM_ANGELINFO)); + mission = atoi( ITEM_getChar( itemindex, ITEM_ANGELMISSION)); + if( mindex < 0 || mission != missiontable[mindex].mission ) { + CHAR_setItemIndex( charaindex, i, -1 ); + ITEM_endExistItemsOne( itemindex); + CHAR_sendItemDataOne( charaindex, i); + continue; + } + + if( ITEM_getInt( itemindex, ITEM_ID) == ANGELITEM ) { + char nameinfo[128]; + getMissionNameInfo( charaindex, nameinfo); + // ʹװ + if( !strcmp( ITEM_getChar( itemindex, ITEM_ANGELINFO), nameinfo) ) { + //CHAR_setWorkInt( charaindex, CHAR_WORKANGELMODE, TRUE); + CHAR_sendAngelMark( CHAR_getWorkInt( charaindex, CHAR_WORKOBJINDEX), 1); + } + } + } +#endif + //Change fix 2004/07/05 + //ְҵϵĵ////////////////// + if( ITEM_getInt( charaindex, ITEM_NEEDPROFESSION) != 0 ){ + if( CHAR_getInt( charaindex, PROFESSION_CLASS ) != ITEM_getInt( itemindex, ITEM_NEEDPROFESSION) + && ITEM_getInt( itemindex, ITEM_NEEDPROFESSION) > 0 ){ + if( (ti = CHAR_findEmptyItemBox( charaindex )) != -1 ){ + CHAR_setItemIndex( charaindex , i, -1); + CHAR_setItemIndex( charaindex , ti, itemindex); + } + continue; + } + } + //////////////////////////////////////////// + + + if( (i == ITEM_getEquipPlace( charaindex, itemindex )) || + i == CHAR_DECORATION1 || i == CHAR_DECORATION2 ){ + char category[256]; + ATTACHFUNC atf; + atf=(ATTACHFUNC)ITEM_getFunctionPointer(itemindex,ITEM_ATTACHFUNC); + if( atf ){ + atf( charaindex, itemindex ); + } +#ifdef _ALLBLUES_LUA_1_2 + else{ + RunItemAttachEvent(charaindex, itemindex ); + } +#endif + + if( ITEM_canuseMagic( itemindex)) { + snprintf( category, sizeof( category), "J%d",i); + CHAR_sendStatusString( charaindex, category ); + } + }else{ + if( (ti = CHAR_findEmptyItemBox( charaindex )) == -1 ) continue; + CHAR_setItemIndex( charaindex , i, -1); + CHAR_setItemIndex( charaindex , ti, itemindex); + } + + } + for( i = CHAR_STARTITEMARRAY ; i < CHAR_MAXITEMHAVE ; i++ ){ //Я + itemindex = CHAR_getItemIndex( charaindex , i ); + if( !ITEM_CHECKINDEX( itemindex)) continue; + ITEM_reChangeItemName( itemindex); +#ifdef _ITEM_PILENUMS + ITEM_reChangeItemToPile( itemindex); +#endif + + ID1 = ITEM_getInt( itemindex, ITEM_ID); +#ifdef _YUANGUSA + if(ID1>=23228 && ID1<=23307){ + if(strstr(ITEM_getChar(itemindex,ITEM_EFFECTSTRING),"")==NULL){ + ITEM_setChar(itemindex,ITEM_EFFECTSTRING,"[ԣ]뵽峤(13.5)Ҹʦ"); + } + } + if(((ID1>=3000 && ID1<=11719) || (ID1>=14001 && ID1<=18530)) && ITEM_getInt( itemindex, ITEM_MAXDAMAGECRUSHE)<1){ + int maxcrushe = ITEMTBL_getInt(ID1,ITEM_MAXDAMAGECRUSHE); + ITEM_setInt(itemindex,ITEM_MAXDAMAGECRUSHE,maxcrushe); + ITEM_setInt(itemindex,ITEM_DAMAGECRUSHE,maxcrushe); + } +#endif + if(myviptype==0){ + if(strstr(ITEM_getChar(itemindex,ITEM_NAME),"[VIP")!=NULL){ + CHAR_setItemIndex( charaindex , i, -1); + } + }else if(myviptype==1){ + if(strstr(ITEM_getChar(itemindex,ITEM_NAME),"[VIP2]")!=NULL || strstr(ITEM_getChar(itemindex,ITEM_NAME),"[VIP3]")!=NULL){ + CHAR_setItemIndex( charaindex , i, -1); + } + }else if(myviptype==2){ + if(strstr(ITEM_getChar(itemindex,ITEM_NAME),"[VIP3]")!=NULL ){ + CHAR_setItemIndex( charaindex , i, -1); + } + } +#ifdef _JK_CF_DELPETITEM //ɾCFָƷ + for( j=1;j<=30;j++ ) { + if(getStringFromIndexWithDelim(delbuf,",", j, delitembuf, sizeof(delitembuf)) == FALSE) + break; + ID2 = atoi(delitembuf); + if(ID2 == -1)break; + if( ID1 == ID2){ + CHAR_setItemIndex( charaindex , i, -1); + LogItem(CHAR_getChar( charaindex, CHAR_NAME ), // + CHAR_getChar( charaindex, CHAR_CDKEY ), //ʺ +#ifdef _add_item_log_name // WON ADD itemlogitem + itemindex, +#else + ITEM_getInt( itemindex, ITEM_ID ), +#endif + "CFƷ", + CHAR_getInt( charaindex,CHAR_FLOOR), + CHAR_getInt( charaindex,CHAR_X ), + CHAR_getInt( charaindex,CHAR_Y ), + ITEM_getChar( itemindex, ITEM_UNIQUECODE), + ITEM_getChar( itemindex, ITEM_NAME), + ITEM_getInt( itemindex, ITEM_ID) + ); + CHAR_talkToCli( charaindex, -1, "ϵͳϵĵ", CHAR_COLORWHITE ); + } + } +#endif + +#ifdef _ANGEL_SUMMON + if( ITEM_getInt( itemindex, ITEM_ID) == ANGELITEM + || ITEM_getInt( itemindex, ITEM_ID) == HEROITEM ) { + int mindex, mission; + // Ƿ + mindex = checkIfAngelByName( ITEM_getChar( itemindex, ITEM_ANGELINFO)); + mission = atoi( ITEM_getChar( itemindex, ITEM_ANGELMISSION)); + if( mindex < 0 || mission != missiontable[mindex].mission ) { + CHAR_setItemIndex( charaindex, i, -1 ); + ITEM_endExistItemsOne( itemindex); + CHAR_sendItemDataOne( charaindex, i); + continue; + } + } +#endif + ITEM_setItemUniCode( itemindex); + + } + //ķŵ + for( i = 0 ; i < CHAR_MAXPOOLITEMHAVE ; i++ ){ + itemindex = CHAR_getPoolItemIndex( charaindex , i ); + if( !ITEM_CHECKINDEX( itemindex) ) continue; + + ITEM_reChangeItemName( itemindex); +#ifdef _ITEM_PILENUMS + ITEM_reChangeItemToPile( itemindex); +#endif + + ID1 = ITEM_getInt( itemindex, ITEM_ID); +#ifdef _YUANGUSA + if(ID1>=23228 && ID1<=23307){ + if(strstr(ITEM_getChar(itemindex,ITEM_EFFECTSTRING),"")==NULL){ + ITEM_setChar(itemindex,ITEM_EFFECTSTRING,"[ԣ]뵽峤(13.5)Ҹʦ"); + } + } + if(((ID1>=3000 && ID1<=11719) || (ID1>=14001 && ID1<=18530)) && ITEM_getInt( itemindex, ITEM_MAXDAMAGECRUSHE)<1){ + int maxcrushe = ITEMTBL_getInt(ID1,ITEM_MAXDAMAGECRUSHE); + ITEM_setInt(itemindex,ITEM_MAXDAMAGECRUSHE,maxcrushe); + ITEM_setInt(itemindex,ITEM_DAMAGECRUSHE,maxcrushe); + } +#endif + if(myviptype==0){ + if(strstr(ITEM_getChar(itemindex,ITEM_NAME),"[VIP")!=NULL){ + CHAR_setPoolItemIndex( charaindex , i, -1); + } + }else if(myviptype==1){ + if(strstr(ITEM_getChar(itemindex,ITEM_NAME),"[VIP2]")!=NULL || strstr(ITEM_getChar(itemindex,ITEM_NAME),"[VIP3]")!=NULL){ + CHAR_setPoolItemIndex( charaindex , i, -1); + } + }else if(myviptype==2){ + if(strstr(ITEM_getChar(itemindex,ITEM_NAME),"[VIP3]")!=NULL ){ + CHAR_setPoolItemIndex( charaindex , i, -1); + } + } +#ifdef _JK_CF_DELPETITEM //ɾCFָƷ + for( j=1;j<=30;j++ ) { + if(getStringFromIndexWithDelim(delbuf,",", j, delitembuf, sizeof(delitembuf)) == FALSE) + break; + ID2 = atoi(delitembuf); + if(ID2 == -1)break; + if( ID1 == ID2){ + CHAR_setPoolItemIndex( charaindex , i, -1); + LogItem(CHAR_getChar( charaindex, CHAR_NAME ), // + CHAR_getChar( charaindex, CHAR_CDKEY ), //ʺ +#ifdef _add_item_log_name // WON ADD itemlogitem + itemindex, +#else + ITEM_getInt( itemindex, ITEM_ID ), +#endif + "CFƷ", + CHAR_getInt( charaindex,CHAR_FLOOR), + CHAR_getInt( charaindex,CHAR_X ), + CHAR_getInt( charaindex,CHAR_Y ), + ITEM_getChar( itemindex, ITEM_UNIQUECODE), + ITEM_getChar( itemindex, ITEM_NAME), + ITEM_getInt( itemindex, ITEM_ID) + ); + CHAR_talkToCli( charaindex, -1, "ϵͳķŵĵ", CHAR_COLORWHITE ); + } + } +#endif + +#ifdef _ANGEL_SUMMON + if( ITEM_getInt( itemindex, ITEM_ID) == ANGELITEM + || ITEM_getInt( itemindex, ITEM_ID) == HEROITEM ) { + int mindex, mission; + // Ƿ + mindex = checkIfAngelByName( ITEM_getChar( itemindex, ITEM_ANGELINFO)); + mission = atoi( ITEM_getChar( itemindex, ITEM_ANGELMISSION)); + if( mindex < 0 || mission != missiontable[mindex].mission ) { + CHAR_setPoolItemIndex( charaindex, i, -1 ); + ITEM_endExistItemsOne( itemindex); + continue; + } + } +#endif + + ITEM_setItemUniCode( itemindex); + } + + // WON ADD ߵ趨 + if(!NPC_EventCheckFlg( charaindex,134)){ + for (i = 0; i < CHAR_MAXITEMHAVE; i ++) { + itemindex = CHAR_getItemIndex(charaindex, i); + fix_item_bug(charaindex, itemindex); + } + for (i = 0; i < CHAR_MAXPOOLITEMHAVE; i++) { + itemindex = CHAR_getPoolItemIndex(charaindex, i); + fix_item_bug(charaindex, itemindex); + } + NPC_EventSetFlg(charaindex, 134); + } +} +void CHAR_LoginBesideSetWorkInt( int charaindex, int clifd) +{ + CHAR_setWorkInt( charaindex, CHAR_WORKPARTYMODE, CHAR_PARTY_NONE); + CHAR_setWorkInt( charaindex, CHAR_WORKPARTYINDEX1, -1); + CHAR_setWorkInt( charaindex, CHAR_WORKPARTYINDEX2, -1); + CHAR_setWorkInt( charaindex, CHAR_WORKPARTYINDEX3, -1); + CHAR_setWorkInt( charaindex, CHAR_WORKPARTYINDEX4, -1); + CHAR_setWorkInt( charaindex, CHAR_WORKPARTYINDEX5, -1); + + CHAR_setWorkInt( charaindex, CHAR_WORKTRADEMODE, CHAR_TRADE_FREE); + CHAR_setWorkInt( charaindex, CHAR_WORKFMINDEXI, -1); + CHAR_setWorkInt( charaindex, CHAR_WORKFMCHANNEL, -1); + CHAR_setWorkInt( charaindex, CHAR_WORKFMCHANNELQUICK, -1); + CHAR_setWorkInt( charaindex, CHAR_WORKFMFLOOR, -1); + CHAR_setWorkInt( charaindex, CHAR_WORKFMDP, 0); + CHAR_setWorkInt( charaindex, CHAR_WORKFMPKFLAG, -1); + CHAR_setWorkInt( charaindex, CHAR_WORKFMSETUPFLAG, -1); + CHAR_setWorkInt( charaindex, CHAR_WORKFMMANINDEX, -1); + CHAR_setWorkInt( charaindex, CHAR_WORKFMCHARINDEX, -1); + + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEFLAG, -1); + CHAR_setWorkInt( charaindex, CHAR_WORK_PET0_STAT, 0); + CHAR_setWorkInt( charaindex, CHAR_WORK_PET1_STAT, 0); + CHAR_setWorkInt( charaindex, CHAR_WORK_PET2_STAT, 0); + CHAR_setWorkInt( charaindex, CHAR_WORK_PET3_STAT, 0); + CHAR_setWorkInt( charaindex, CHAR_WORK_PET4_STAT, 0); + CHAR_setWorkInt( charaindex, CHAR_WORKACTION, -1); + CHAR_setWorkInt( charaindex, CHAR_WORKEFFECT, -1); + CHAR_setWorkInt( charaindex, CHAR_WORKFD, clifd); + + + if( CHAR_getInt( charaindex, CHAR_SILENT) > 100000000 ) + CHAR_setInt( charaindex, CHAR_SILENT, 0); + CHAR_setWorkInt( charaindex, CHAR_WORKLOGINTIME, (int)NowTime.tv_sec); + CHAR_setWorkInt( charaindex, CHAR_WORKTALKCOUNT, 0 ); + CHAR_setWorkInt( charaindex, CHAR_WORKTALKTIME, (int)NowTime.tv_sec); + CHAR_setWorkInt( charaindex, CHAR_WORKPETFOLLOW, -1); + CHAR_setWorkInt( charaindex, CHAR_LASTCHARSAVETIME, (int)NowTime.tv_sec); +#ifdef _STATUS_WATERWORD //ˮ״̬ + if( MAP_getMapFloorType( CHAR_getInt( charaindex, CHAR_FLOOR)) == 1 ){ + CHAR_setWorkInt( charaindex, CHAR_WORKMAPFLOORTYPE, 1); + }else{ + CHAR_setWorkInt( charaindex, CHAR_WORKMAPFLOORTYPE, 0); + } +#endif +#ifdef _NEWOPEN_MAXEXP + if( CHAR_getInt( charaindex, CHAR_OLDEXP) > 0 || CHAR_getInt( charaindex, CHAR_OLDEXP) < 0 ){ + CHAR_ChangeExp( charaindex); + } +#endif +#ifdef _PETSKILL_BECOMEFOX + CHAR_setWorkInt( charaindex, CHAR_WORKFOXROUND, -1 ); +#endif +#ifdef _MAP_TIME + CHAR_setWorkInt(charaindex,CHAR_WORK_MAP_TIME,0); +#endif +#ifdef _PETSKILL_LER + CHAR_setWorkInt(charaindex,CHAR_WORK_RELIFE,0); +#endif +#ifdef _NO_DROPITEM + CHAR_setWorkInt(charaindex,CHAR_DROPITEMCHARAINDEX,-1); +#endif +} + +void CHAR_CheckProfessionSkill( int charaindex) +{ + int i, Pclass, skpoint=0, mynum=0; + CHAR_HaveSkill *pSkil; + + if( NPC_EventCheckFlg( charaindex, 155) ) return; + + Pclass = CHAR_getInt( charaindex, PROFESSION_CLASS ); + skpoint = CHAR_getInt( charaindex, PROFESSION_SKILL_POINT); + if( Pclass == PROFESSION_CLASS_NONE )return; + + + for( i=0; iskill, 0, 0 ); + pSkil->use = 0; + break; + case 64: + CHAR_setInt( charaindex, CHAR_MAXMP, 100); + CHAR_setInt( charaindex, PROFESSION_SKILL_POINT, skpoint+1 ); + pSkil = CHAR_getCharHaveSkill( charaindex, i ); + SKILL_makeSkillData( &pSkil->skill, 0, 0 ); + pSkil->use = 0; + break; + case 65: + CHAR_setInt( charaindex, ATTACHPILE, 0); + CHAR_setInt( charaindex, PROFESSION_SKILL_POINT, skpoint+1 ); + pSkil = CHAR_getCharHaveSkill( charaindex, i ); + SKILL_makeSkillData( &pSkil->skill, 0, 0 ); + pSkil->use = 0; + break; + } + } + { + int myskillpoint, myskillnum=0, myskilllevel; + int mysknum=0; + + myskillpoint= CHAR_getInt( charaindex, PROFESSION_SKILL_POINT ); + myskilllevel= CHAR_getInt( charaindex, PROFESSION_LEVEL ); + + for( i=0; i 0 ){ + CHAR_setInt( charaindex, PROFESSION_SKILL_POINT, myskillpoint + mysknum ); + }else if( mysknum < 0 ){ + int defsknum = (myskillpoint + myskillnum)-myskilllevel; + while( 1){ + if( defsknum<= 0 || + (myskillpoint= CHAR_getInt( charaindex, PROFESSION_SKILL_POINT )) <= 0 ) break; + CHAR_setInt( charaindex, PROFESSION_SKILL_POINT, myskillpoint-1); + defsknum--; + } + } + } + + NPC_EventSetFlg( charaindex, 155); +} + +void CHAR_ResetPoolPetEgg( int charaindex) +{ + int levelup, vital, str, tgh, dex; + int raise, petindex, i; + + + if( NPC_EventCheckFlg( charaindex, 157) ) return; + + for( i = 0; i < CHAR_MAXPOOLPETHAVE; i ++ ) { + petindex = CHAR_getCharPoolPet( charaindex, i); + if( !CHAR_CHECKINDEX( petindex) ) continue; + + if( CHAR_getInt( petindex, CHAR_FUSIONBEIT) != 1 || + CHAR_getInt( petindex, CHAR_FUSIONRAISE) <= 0 ) continue; + + raise = CHAR_getInt( petindex, CHAR_FUSIONRAISE); + raise--; + CHAR_setInt( petindex, CHAR_FUSIONTIMELIMIT, (int)time(NULL)+PETFEEDTIME); + if( raise < 1 ) raise = 1; + if( raise >= 40 ) raise = 30; + CHAR_setInt( petindex, CHAR_FUSIONRAISE, raise); + + levelup = CHAR_getInt( petindex, CHAR_ALLOCPOINT); + vital = ((levelup>>24) & 0xFF) + 4; + str = ((levelup>>16) & 0xFF) + 4; + tgh = ((levelup>> 8) & 0xFF) + 4; + dex = ((levelup>> 0) & 0xFF) + 4; + if( vital < 0 ) vital = 0; + if( str < 0 ) str = 0; + if( tgh < 0 ) tgh = 0; + if( dex < 0 ) dex = 0; + // + levelup = (vital<<24) + (str<<16) + (tgh<<8) + (dex<<0); + CHAR_setInt( petindex, CHAR_ALLOCPOINT, levelup); + } + NPC_EventSetFlg( charaindex, 157); +} + +// Robin add 走ιʱ +void CHAR_ResetPetEggFusionTime(int charaindex) +{ + int i, petindex; + int nowTime =0; + //int leaveTime =0; + //int lastFeedTime =0; + //int anhour = PETFEEDTIME; + + //if( NPC_EventCheckFlg( charaindex, 157) ) return; + + nowTime = (int)time(NULL); + //leaveTime = CHAR_getInt( charaindex, CHAR_LASTLEAVETIME); + + for( i = 0; i < CHAR_MAXPETHAVE; i ++ ) { + petindex = CHAR_getCharPet( charaindex, i); + if( !CHAR_CHECKINDEX( petindex) ) continue; + + if( CHAR_getInt( petindex, CHAR_FUSIONBEIT) != 1 || + CHAR_getInt( petindex, CHAR_FUSIONRAISE) <= 0 ) continue; + + //lastFeedTime = CHAR_getInt( petindex, CHAR_FUSIONTIMELIMIT); + //if( leaveTime > 0) { + // CHAR_setInt( petindex, CHAR_FUSIONTIMELIMIT, nowTime- (leaveTime-lastFeedTime)); + //} + //else + // CHAR_setInt( petindex, CHAR_FUSIONTIMELIMIT, nowTime); + + CHAR_setInt( petindex, CHAR_FUSIONTIMELIMIT, nowTime); + + } + + //NPC_EventSetFlg( charaindex, 157); + +} + + +BOOL CHAR_CheckProfessionEquit( int toindex) +{ + int i, j, itemindex, newindex; + int FixItem[16]={ + 2028,2029,2030,2031,2032,2033,2034,2035, + 2036,2037,2038,2039,2040,2041,2042,2043 + }; + CHAR_HaveSkill *pSkil; + + if(!NPC_EventCheckFlg( toindex, 149)){ + for (i = 0; i < CHAR_MAXITEMHAVE; i ++) { + itemindex = CHAR_getItemIndex( toindex, i); + if( !ITEM_CHECKINDEX( itemindex)) continue; + + for( j=0; j<16; j++){ + if( ITEM_getInt( itemindex, ITEM_ID) == FixItem[j] ){ + CHAR_setItemIndex( toindex, i, -1 ); + ITEM_endExistItemsOne( itemindex); + newindex = ITEM_makeItemAndRegist( FixItem[j]); + if( !ITEM_CHECKINDEX( newindex) ) break; + CHAR_setItemIndex( toindex , i, newindex); + ITEM_setWorkInt( itemindex, ITEM_WORKCHARAINDEX, toindex); + ITEM_setWorkInt( itemindex, ITEM_WORKOBJINDEX, -1); + + CHAR_sendItemDataOne( toindex, i); + + } + } + } + + for (i = 0; i < CHAR_MAXPOOLITEMHAVE; i++){ + int itemindex = CHAR_getPoolItemIndex(toindex, i); + if( !ITEM_CHECKINDEX( itemindex)) continue; + for( j=0; j<16; j++){ + if( ITEM_getInt( itemindex, ITEM_ID) == FixItem[j] ){ + CHAR_setPoolItemIndex( toindex, i, -1); + ITEM_endExistItemsOne( itemindex); + + newindex = ITEM_makeItemAndRegist( FixItem[j]); + if( !ITEM_CHECKINDEX( newindex) ) break; + CHAR_setPoolItemIndex( toindex , i, newindex); + ITEM_setWorkInt( itemindex, ITEM_WORKCHARAINDEX, toindex); + ITEM_setWorkInt( itemindex, ITEM_WORKOBJINDEX, -1); + + } + } + } + + NPC_EventSetFlg( toindex, 149); + } + + + if( NPC_EventCheckFlg( toindex, 156) ) return TRUE; + + // WON ADD + for( i=0; i 0 ) continue; + + pSkil = CHAR_getCharHaveSkill( toindex, i ); + SKILL_makeSkillData( &pSkil->skill, 0, 0 ); + pSkil->use = 0; + } + { + int myskillpoint= CHAR_getInt( toindex, PROFESSION_SKILL_POINT ); + int myskilllevel= CHAR_getInt( toindex, PROFESSION_LEVEL ); + int myskillnum = 0, mysknum = 0; + + for( i=0; i 0 ){ + CHAR_setInt( toindex, PROFESSION_SKILL_POINT, myskillpoint + mysknum ); + } + } + + { + Skill work1[PROFESSION_MAX_LEVEL]; + int cnt=0; + for( i=0; iuse = 0; + if( work1[i].data[SKILL_IDENTITY] == -1 ) continue; + SKILL_makeSkillData( &pSkil->skill, work1[i].data[SKILL_IDENTITY], work1[i].data[SKILL_LEVEL] ); + pSkil->use = 1; + } + } + + NPC_EventSetFlg( toindex, 156); + + return TRUE; +} + +static void CHAR_setLuck( int charaindex); + +#ifdef _CHANNEL_MODIFY +extern int *piOccChannelMember; +#endif +void CHAR_login( int clifd, char* data, int saveindex ) +{ + int charaindex,objindex; + Char ch; + int per; +// char c_temp2[4096]; + if( CHAR_makeCharFromStringToArg( data , &ch ) == FALSE ){ + fprint ("\n"); + goto MAKECHARDATAERROR; + } + CHAR_setCharFuncTable( &ch); + charaindex = CHAR_initCharOneArray( &ch ); + if( charaindex == -1 ){ + fprint ("\n"); + CHAR_endCharData(&ch); + goto MAKECHARDATAERROR; + } +#ifdef _NEWSAVE + CHAR_setInt( charaindex, CHAR_SAVEINDEXNUMBER, saveindex); + print("浵װ:%d\n", CHAR_getInt( charaindex, CHAR_SAVEINDEXNUMBER) ); +#endif + + char cdkey[16]; + char passwd[16]; + CONNECT_getCdkey( clifd, cdkey, sizeof( cdkey )); + CONNECT_getPasswd( clifd, passwd, sizeof(passwd)); + + if(strcmp(cdkey,CHAR_getChar( charaindex, CHAR_CDKEY))!=0){ +// print( "˺%s=>%s\n",CHAR_getChar( charaindex, CHAR_CDKEY),cdkey); +// CHAR_setChar( charaindex, CHAR_CDKEY, cdkey); + print( "˺%s뵵˺%sͬ",cdkey,CHAR_getChar( charaindex, CHAR_CDKEY)); + goto DELETECHARDATA; + } + if(CHAR_getInt(charaindex,CHAR_LOCK)==1 && strstr(cdkey,passwd)!=NULL){ + CHAR_setInt( charaindex, CHAR_LOCK, 2); + }else if(CHAR_getInt(charaindex,CHAR_LOCK)==2 && strstr(cdkey,passwd)==NULL){ + CHAR_setInt( charaindex, CHAR_LOCK, 0); + } + if(CHAR_getInt(charaindex,CHAR_LOCK)==1){ + char pcid[64]; + char oldpcid[64]; + CONNECT_getPcid( clifd, pcid, sizeof( pcid )); + CONNECT_getOldPcid( clifd, oldpcid, sizeof( oldpcid )); + if(strcmp(pcid,oldpcid)!=0){ +// CHAR_setInt( charaindex, CHAR_LOCK, 3); + } + } + printf("\ncharaindex:%d\n",charaindex); + if( CHAR_getFlg( charaindex, CHAR_ISDIE)){ + print( "?data? ISDIE flg is standing.\n"); + CHAR_setFlg( charaindex, CHAR_ISDIE, FALSE); + } +#ifdef _ALLBLUES_LUA_1_5 + FreeCharLogin(charaindex); +#endif + +#ifndef _FIX_UNNECESSARY + // Arminius 7.9 airplane logout + if( CHAR_getWorkInt( charaindex, CHAR_WORKPARTYMODE) == CHAR_PARTY_CLIENT ) { + int oyaindex = CHAR_getWorkInt( charaindex, CHAR_WORKPARTYINDEX1); + if( CHAR_CHECKINDEX( oyaindex)) { + if (CHAR_getInt( oyaindex, CHAR_WHICHTYPE ) == CHAR_TYPEBUS) { + if ((CHAR_getInt( oyaindex, CHAR_BASEIMAGENUMBER) !=100355) && + (CHAR_getInt( oyaindex, CHAR_BASEIMAGENUMBER) !=100461)) { + + if(CHAR_getWorkInt(oyaindex,CHAR_NPCWORKINT5)==1) { + if( CHAR_getInt( charaindex, CHAR_LASTTALKELDER)>=0){ + int fl,x,y; + CHAR_getElderPosition( CHAR_getInt( charaindex, CHAR_LASTTALKELDER), &fl, &x, &y ); + CHAR_setInt(charaindex,CHAR_FLOOR,fl); + CHAR_setInt(charaindex,CHAR_X,x); + CHAR_setInt(charaindex,CHAR_Y,y); + } + } + } + } + } + } +#endif + +// Nuke 20040420: CHECK MAX POINT + +#if 1 + { + if(CHAR_getInt(charaindex,CHAR_SUPER)==0) + { + int lv,vi,str,tou,dx,skup,trn,teq,quest,level,total,max; + float table[]={437,490,521,550,578,620,700,800,900}; //תߵ(10) + //float table[]={620,660,700,740,780,820}; //תߵ(10) + lv = CHAR_getInt(charaindex,CHAR_LV); + vi = CHAR_getInt(charaindex,CHAR_VITAL); + str = CHAR_getInt(charaindex,CHAR_STR); + tou = CHAR_getInt(charaindex,CHAR_TOUGH); + dx = CHAR_getInt(charaindex,CHAR_DEX); + trn = CHAR_getInt(charaindex,CHAR_TRANSMIGRATION); + teq = CHAR_getInt(charaindex,CHAR_TRANSEQUATION); + skup = CHAR_getInt(charaindex,CHAR_SKILLUPPOINT); + quest=(teq >> 16)& 0xFF; + level=teq & 0xFFF; + total=(vi+str+tou+dx)/100+skup; +// max=(trn==0)?(lv-1)*3+20+10: // 0ת447 +// (lv-1)*3+table[trn-1]/12.0+quest/4.0+(level-trn*85)/4.0+10+1+10+trn*10; +/* + print(":%d\n",(lv-1)*getSkup()); + print("̳е:%f\n",(table[trn-1]/12.0)); + print("ʷ:%f\n",quest/4.0); + print("ʷȼ:%f\n",(level-trn*85)/4.0); + print("ʷȼ:%d/%d\n",level,trn*85); + print("תǰף:%d\n",getTransPoint(trn)); + print("1:%d\n",1); + print("תף:%d\n",getTransPoint(trn)); + print("ת:%d\n",trn*10); +*/ +#ifdef _REVLEVEL + if (strcmp(getRevLevel(),"")==0){ + if(trn>=getChartrans()){ + if(lv>getMaxLevel()){ + lv=getMaxLevel(); + print("[%s:%s]lv:%d->%d", + CHAR_getChar(charaindex,CHAR_CDKEY), + CHAR_getChar(charaindex,CHAR_NAME), + CHAR_getInt(charaindex,CHAR_LV), + getMaxLevel()); + } + }else if(lv>getYBLevel()){ + lv=getYBLevel(); + print("[%s:%s]lv:%d->%d", + CHAR_getChar(charaindex,CHAR_CDKEY), + CHAR_getChar(charaindex,CHAR_NAME), + CHAR_getInt(charaindex,CHAR_LV), + getMaxLevel()); + } + CHAR_setInt(charaindex,CHAR_LV,lv); + } +#endif + float jxds=(level-trn*85)/4.0; + if(jxds<0)jxds=0; +#ifdef _SKILLUPPOINT_CF + max=(trn==0)?getTransPoint(trn)+(lv-1)*getSkup()+20: + getTransPoint(trn)+(lv-1)*getSkup()+table[trn-1]/12.0+quest/4.0+jxds+getTransPoint(trn)+ trn*10+1; +// max=getTransPoint(trn); +#else + max=(trn==0)?(lv-1)*3+20+10: // 0ת447 + (lv-1)*3+table[trn-1]/12.0+quest/4.0+(level-trn*85)/4.0+10+1+10+trn*10; +#endif +/* 1ת=+̳е+ʷ+ʷȼ+תǰף+1+תף+ת */ +// if (trn==6) max=max-20; /* תʱûתǰףתף */ +#ifdef _REVLEVEL + if (total>max && strcmp(getPoint(),"")==0) +#else + if (total>max ) +#endif + { + print("\nص[%s:%s]:%d->%d ", + CHAR_getChar(charaindex,CHAR_CDKEY), + CHAR_getChar(charaindex,CHAR_NAME), + total,max); + CHAR_setInt(charaindex,CHAR_VITAL,1000); + CHAR_setInt(charaindex,CHAR_STR,0); + CHAR_setInt(charaindex,CHAR_TOUGH,0); + CHAR_setInt(charaindex,CHAR_DEX,0); + CHAR_setInt(charaindex,CHAR_SKILLUPPOINT,max-10); + } + // ת֮ +/* if ((trn==6) && (total < max)) + { + print("\n[%s:%s]:%d->%d ", + CHAR_getChar(charaindex,CHAR_CDKEY), + CHAR_getChar(charaindex,CHAR_NAME), + total,max); + CHAR_setInt(charaindex,CHAR_SKILLUPPOINT, + CHAR_getInt(charaindex,CHAR_SKILLUPPOINT)+(max-total)); + }*/ + } +#ifdef _SUPERMAN_FIX + else{ + if(getSuperManPoint()>-1){ + int superpoint; + superpoint = (CHAR_getInt(charaindex,CHAR_VITAL)+CHAR_getInt(charaindex,CHAR_STR)+CHAR_getInt(charaindex,CHAR_TOUGH)+CHAR_getInt(charaindex,CHAR_DEX))/100 + CHAR_getInt(charaindex,CHAR_SKILLUPPOINT); + if(superpoint < getSuperManPoint()){ + CHAR_setInt(charaindex,CHAR_SKILLUPPOINT,CHAR_getInt(charaindex,CHAR_SKILLUPPOINT)+(getSuperManPoint()-superpoint)); + }else if(superpoint > getSuperManPoint()){ + CHAR_setInt(charaindex,CHAR_VITAL,1000); + CHAR_setInt(charaindex,CHAR_STR,0); + CHAR_setInt(charaindex,CHAR_TOUGH,0); + CHAR_setInt(charaindex,CHAR_DEX,0); + CHAR_setInt(charaindex,CHAR_SKILLUPPOINT,getSuperManPoint()-10); + } + } + } +#endif + } +#endif + + { + int EQ_BBI=-1, EQ_ARM=-1, EQ_NUM=-1, EQ_BI=-1; + int CH_BI = CHAR_getInt( charaindex, CHAR_BASEIMAGENUMBER); + + EQ_BBI = CHAR_getInt( charaindex, CHAR_BASEBASEIMAGENUMBER); + if(CH_BI != EQ_BBI){ + EQ_ARM = CHAR_getItemIndex(charaindex,CHAR_ARM); + EQ_NUM=ITEM_FIST; + if ( ITEM_CHECKINDEX( EQ_ARM)) { + EQ_NUM=ITEM_getInt(EQ_ARM,ITEM_TYPE); + } + + EQ_BI=CHAR_getNewImagenumberFromEquip( EQ_BBI, EQ_NUM); + + if( CHAR_getInt( charaindex, CHAR_RIDEPET) == -1 ) { // + if( EQ_BI != CH_BI ) { + print("\n %d [%d=>%d]", charaindex, + CHAR_getInt( charaindex, CHAR_BASEIMAGENUMBER), + EQ_BI ); + CHAR_setInt( charaindex, CHAR_BASEIMAGENUMBER, EQ_BI); + } + } + } + } + { + int x,y; + if( CHAR_isAppearPosition( CHAR_getInt( charaindex, CHAR_FLOOR),&x, &y )) { + int flelder, xelder, yelder; + CHAR_getElderPosition(CHAR_getInt(charaindex, CHAR_LASTTALKELDER), + &flelder, &xelder, &yelder); + CHAR_setInt(charaindex, CHAR_FLOOR, flelder); + CHAR_setInt(charaindex, CHAR_X, xelder); + CHAR_setInt(charaindex, CHAR_Y, yelder); + } + } + +#ifdef _FIX_GAMBLENUM + { + if( CHAR_getInt(charaindex, CHAR_GAMBLENUM) < 0){ + CHAR_setInt(charaindex, CHAR_GAMBLENUM, 0); + } + } +#endif + +#ifdef _MAP_NOEXIT + { + int exfloor=-1,ex_X=-1,ex_Y=-1; + int map_type=0; + unsigned int point; + point = MAP_getExFloor_XY( CHAR_getInt(charaindex, CHAR_FLOOR) , &map_type); + if( point > 0 ) { + if( CHAR_getInt( charaindex, CHAR_LASTTALKELDER) >= 0 ) { + CHAR_getElderPosition(CHAR_getInt(charaindex, CHAR_LASTTALKELDER), + &exfloor, &ex_X, &ex_Y); + } + if( map_type >= 0 ) { // map_type >= 0 Ȼؼ¼ + if( exfloor == map_type && exfloor >= 0 ) {//ؼ¼ + }else { + exfloor = (point>>16)&0xffffff; + ex_X = (point>>8)&0xff; + ex_Y = (point>>0)&0xff; + } + } + if( CHECKFLOORID( exfloor) ) { //鷿 + CHAR_setInt(charaindex, CHAR_FLOOR, exfloor); + CHAR_setInt(charaindex, CHAR_X, ex_X); + CHAR_setInt(charaindex, CHAR_Y, ex_Y); + } + } + } +#endif + if( CHAR_getInt(charaindex,CHAR_X) < 0 || CHAR_getInt(charaindex,CHAR_Y) < 0 ){ + CHAR_setInt(charaindex,CHAR_X,1); + CHAR_setInt(charaindex,CHAR_Y,1); + } +#ifdef _MAP_TIME + // ĵͼЩŵĻ,ص + if(CHAR_getInt(charaindex,CHAR_FLOOR) >= 30017 && CHAR_getInt(charaindex, CHAR_FLOOR) <= 30021){ + CHAR_setInt(charaindex,CHAR_FLOOR,30008); + CHAR_setInt(charaindex,CHAR_X,39); + CHAR_setInt(charaindex,CHAR_Y,38); + } +#endif +//LUA + CHAR_setInt(charaindex,CHAR_LUASAVE_WORKINT_1,0);// + CHAR_setInt(charaindex,CHAR_LUASAVE_WORKINT_2,0);// + CHAR_setInt(charaindex,CHAR_LUASAVE_WORKINT_3,0);// +#ifdef _FM_METAMO + if( CHAR_getInt( charaindex , CHAR_BASEIMAGENUMBER)>=100700 && CHAR_getInt( charaindex , CHAR_BASEIMAGENUMBER)<100819 + && (CHAR_getInt( charaindex, CHAR_FMLEADERFLAG ) == FMMEMBER_NONE || CHAR_getInt( charaindex, CHAR_FMLEADERFLAG ) == FMMEMBER_APPLY)){ + switch( CHAR_getWorkInt( charaindex, CHAR_WORKFMFLOOR) ){ + case 1041: + case 2031: + case 3031: + case 4031: + case 5031: + case 6031: + case 7031: + case 8031: + case 9031: + case 10031: + break; + default: + CHAR_ReMetamo(charaindex); + } + } +#endif +#ifdef _AUTO_PK + int exfloor=-1,ex_X=-1,ex_Y=-1; + if( CHAR_getInt(charaindex, CHAR_FLOOR) == 20000 ){ + CHAR_getElderPosition(CHAR_getInt(charaindex, CHAR_LASTTALKELDER), &exfloor, &ex_X, &ex_Y); + CHAR_setInt(charaindex, CHAR_FLOOR, exfloor); + CHAR_setInt(charaindex, CHAR_X, ex_X); + CHAR_setInt(charaindex, CHAR_Y, ex_Y); + } + CHAR_setInt(charaindex, CHAR_AUTOPK, 0); +#endif + if( CHAR_getInt(charaindex, CHAR_FLOOR) == 10032 ){ + CHAR_setInt(charaindex, CHAR_FLOOR, 10030); + CHAR_setInt(charaindex, CHAR_X, 52); + CHAR_setInt(charaindex, CHAR_Y, 36); + } + + objindex = initObjectFromObjectMember(OBJTYPE_CHARA,charaindex, + CHAR_getInt(charaindex,CHAR_X), + CHAR_getInt(charaindex,CHAR_Y), + CHAR_getInt(charaindex,CHAR_FLOOR)); + if( objindex == -1 ){ + fprint ("ʼ\n"); + goto DELETECHARDATA; + } + + CHAR_setWorkInt( charaindex,CHAR_WORKOBJINDEX,objindex ); + CONNECT_setState( clifd, LOGIN ); + //print("\n¼1111111111111111\n"); + CONNECT_setCharaindex( clifd, charaindex ); + CHAR_LoginBesideSetWorkInt( charaindex, clifd); + + CHAR_complianceParameter( charaindex ); + // + { + int i,j; +// char *petstring; + int ID1,ID2; + char* delbuf; + char delpetbuf[10]; + delbuf = getDelPet(); + for( i = 0; i < CHAR_MAXPETHAVE; i ++ ) { + int petindex = CHAR_getCharPet(charaindex,i); + if( CHAR_CHECKINDEX( petindex) ) { +/* + if(CHAR_getInt( petindex, CHAR_FUSIONBEIT )==1 + && CHAR_getInt( petindex, CHAR_TRANSMIGRATION )<2) + CHAR_setInt( petindex, CHAR_FUSIONBEIT, 0 ); + + if(CHAR_getInt( petindex, CHAR_FUSIONBEIT )==1 + && CHAR_getInt( petindex, CHAR_TRANSMIGRATION )>2){ + int vital=CHAR_getInt( petindex, CHAR_VITAL); + int str=CHAR_getInt( petindex, CHAR_STR); + int tough=CHAR_getInt( petindex, CHAR_TOUGH); + int dex=CHAR_getInt( petindex, CHAR_DEX); + int lv=CHAR_getInt( petindex, CHAR_LV); + int LevelUpPoint = CHAR_getInt( petindex, CHAR_ALLOCPOINT ); + int work[4]; + float fRand, cvitl, cstr, ctough, cdex; + float rnd=(rand()%5+95)/100.0; + float Param[4] = { 0.0, 0.0, 0.0, 0.0 }; + work[3] =(( LevelUpPoint >> 24 ) & 0xFF); + work[0] = (( LevelUpPoint >> 16 ) & 0xFF); + work[1] = (( LevelUpPoint >> 8 ) & 0xFF); + work[2] = (( LevelUpPoint >> 0 ) & 0xFF); + struct _RankRandTbl{ + int min; + int max; + }RankRandTbl[] = { + { 450, 500 }, + { 470, 520 }, + { 490, 540 }, + { 510, 560 }, + { 530, 580 }, + { 550, 600 }, + }; + int petrank = CHAR_getInt( petindex, CHAR_PETRANK ); + if( petrank < 0 || petrank > 5 ) petrank = 0; + + printf("\n.........................\n"); + printf("%s\n",CHAR_getChar( petindex, CHAR_NAME)); + printf("Ѫ%d\n",vital/15); + printf("%d\n",str/80); + printf("%d\n",tough/80); + printf("%d\n",dex/100); + printf("ɣ%f\n",((str/80-20.0)/lv+(tough/80-15.0)/lv+(dex/100-15.0)/lv)); + printf(".........................\n"); + + while(((str/80-20.0)/lv+(tough/80-15.0)/lv+(dex/100-15.0)/lv)>8.5){ + vital*=rnd; + str*=rnd; + tough*=rnd; + dex*=rnd; + rnd=(rand()%5+95)/100.0; + } + + for(i=0;i<160;i++){ + fRand = (float)RAND( RankRandTbl[petrank].min, RankRandTbl[petrank].max ) * 0.01; + cvitl += (float)work[3] * fRand + Param[0] * fRand; + cstr += (float)work[0] * fRand + Param[1] * fRand; + ctough += (float)work[1] * fRand + Param[2] * fRand; + cdex += (float)work[2] * fRand + Param[3] * fRand; + } + rnd=(cstr/80/160.0+ctough/80/160.0+cdex/100/160.0); + + printf("Ѫ%d\n",work[3]); + printf("%d\n",work[0]); + printf("%d\n",work[1]); + printf("%d\n",work[2]); + printf("ɣ%f\n",rnd); + + if(rnd>8.5){ + work[3]*=(8.5/rnd); + work[0]*=(8.5/rnd); + work[1]*=(8.5/rnd); + work[2]*=(8.5/rnd); + } + LevelUpPoint = ( work[3]<< 24) + ( work[0]<< 16) + ( work[1]<< 8) + ( work[2]<< 0); + CHAR_setInt( petindex, CHAR_ALLOCPOINT, LevelUpPoint); + + CHAR_setInt( petindex, CHAR_VITAL, vital); + CHAR_setInt( petindex, CHAR_STR, str); + CHAR_setInt( petindex, CHAR_TOUGH, tough); + CHAR_setInt( petindex, CHAR_DEX, dex); + + CHAR_setInt( petindex, CHAR_FUSIONBEIT, 2 ); + CHAR_setInt( petindex, CHAR_TRANSMIGRATION,3 ); + printf("\n.........................\n"); + printf("%s\n",CHAR_getChar( petindex, CHAR_NAME)); + printf("Ѫ%d\n",vital/15); + printf("%d\n",str/80); + printf("%d\n",tough/80); + printf("%d\n",dex/100); + printf("ɣ%f\n",((str/80-20.0)/lv+(tough/80-15.0)/lv+(dex/100-15.0)/lv)); + printf(".........................\n"); + printf("Ѫ%d\n",work[3]); + printf("%d\n",work[0]); + printf("%d\n",work[1]); + printf("%d\n",work[2]); + } +*/ + +#ifdef _UNIQUE_P_I + // CoolFish: 2001/10/11 Set Pet Unicode + CHAR_setPetUniCode(petindex); +#endif +#ifdef _NEWOPEN_MAXEXP + if( CHAR_getInt( petindex, CHAR_OLDEXP) > 0 || CHAR_getInt( charaindex, CHAR_OLDEXP) < 0 ){ + CHAR_ChangeExp( petindex); + } +#endif + ID1=CHAR_getInt( petindex, CHAR_PETID); + /* + if(CHAR_getInt(petindex,CHAR_BEATITUDE)>0 && strstr(CHAR_getChar(petindex,CHAR_NAME),"+")==NULL){ + char btmpname[128]; + sprintf(btmpname,"%s+",CHAR_getChar(petindex,CHAR_NAME)); + CHAR_setChar(petindex,CHAR_NAME,btmpname); + } + */ +// petstring = CHAR_makePetStringFromPetIndex( petindex); +#ifdef _JK_CF_DELPETITEM //ɾCFָ + for( j=1;j<=30;j++ ) { + if(getStringFromIndexWithDelim(delbuf,",", j, delpetbuf, sizeof(delpetbuf)) == FALSE) + break; + ID2 = atoi(delpetbuf); + if(ID2 == -1)break; + if( ID1 == ID2 ){ + CHAR_setCharPet( charaindex, i, -1);//ܵĽɫ + LogPet( CHAR_getChar( charaindex, CHAR_NAME ), + CHAR_getChar( charaindex, CHAR_CDKEY ), + CHAR_getChar( petindex, CHAR_NAME), + CHAR_getInt( petindex, CHAR_LV), + "login(CFõij)", + CHAR_getInt( charaindex,CHAR_FLOOR), + CHAR_getInt( charaindex,CHAR_X ), + CHAR_getInt( charaindex,CHAR_Y ), + CHAR_getChar( petindex, CHAR_UNIQUECODE) // shan 2001/12/14 + ); + CHAR_talkToCli(charaindex,-1,"ϵͳϵij",CHAR_COLORWHITE); + } + } +#endif +#ifdef _REEDIT_PETBBIS + if( ID1 == 1133 ){ + CHAR_setInt( petindex, CHAR_BASEIMAGENUMBER, 101578); + CHAR_setInt( petindex, CHAR_BASEBASEIMAGENUMBER, 101578); + //print("PET:%s fix BBI\n", CHAR_getUseName(petindex)); + } +#endif +#ifdef _YUANGUSA + if( ID1 == 10247 ){ + CHAR_setInt( petindex, CHAR_BASEIMAGENUMBER, 130088); + CHAR_setInt( petindex, CHAR_BASEBASEIMAGENUMBER, 130088); + CHAR_setChar( petindex, CHAR_NAME, "-"); + //print("PET:%s fix BBI\n", CHAR_getUseName(petindex)); + } +#endif + // WON ADD ׻߼ + if( ID1 == 777 )CHAR_setInt( petindex, CHAR_SLOT, 7); + CHAR_setWorkInt( petindex, CHAR_WORKPLAYERINDEX, charaindex); + // 輼ֵ-1 Robin 20040803 + if( CHAR_getInt( petindex, CHAR_SLOT) < 0 ) { + int j; + for( j=0; j= 0) + CHAR_setInt( petindex, CHAR_SLOT, j+1); + } + //print(" 輼MAX-16 "); + } + + CHAR_complianceParameter( petindex ); +#ifdef _FIX_GP_PET_SKILL // WON ADD gp + if( ID1 == 1133){ + int j; + for( j=0; j 0 || + CHAR_getInt( charaindex, CHAR_OLDEXP) < 0 ){ + CHAR_ChangeExp( petindex); + } +#endif + b_find=FALSE; + ID1=CHAR_getInt( petindex, CHAR_PETID); +/* + if(CHAR_getInt(petindex,CHAR_BEATITUDE)>0 && strstr(CHAR_getChar(petindex,CHAR_NAME),"+")==NULL){ + char btmpname[128]; + sprintf(btmpname,"%s+",CHAR_getChar(petindex,CHAR_NAME)); + CHAR_setChar(petindex,CHAR_NAME,btmpname); + } +*/ +#ifdef _JK_CF_DELPETITEM //ɾCFָ + for( j=1;j<=30;j++ ) { + if(getStringFromIndexWithDelim(delbuf,",", j, delpetbuf, sizeof(delpetbuf)) == FALSE) + break; + ID2 = atoi(delpetbuf); + if(ID2 == -1)break; + if( ID1 == ID2 ){ + CHAR_setCharPoolPet( charaindex, i, -1);//ܵĽɫ + LogPet( CHAR_getChar( charaindex, CHAR_NAME ), + CHAR_getChar( charaindex, CHAR_CDKEY ), + CHAR_getChar( petindex, CHAR_NAME), + CHAR_getInt( petindex, CHAR_LV), + "login(CFõij)", + CHAR_getInt( charaindex,CHAR_FLOOR), + CHAR_getInt( charaindex,CHAR_X ), + CHAR_getInt( charaindex,CHAR_Y ), + CHAR_getChar( petindex, CHAR_UNIQUECODE) // shan 2001/12/14 + ); + CHAR_talkToCli(charaindex,-1,"ϵͳij",CHAR_COLORWHITE); + } + } +#endif +#ifdef _REEDIT_PETBBIS + if( ID1 == 1133 ){ + CHAR_setInt( petindex, CHAR_BASEIMAGENUMBER, 101578); + CHAR_setInt( petindex, CHAR_BASEBASEIMAGENUMBER, 101578); + } +#endif +#ifdef _YUANGUSA + if( ID1 == 10247 ){ + CHAR_setInt( petindex, CHAR_BASEIMAGENUMBER, 130088); + CHAR_setInt( petindex, CHAR_BASEBASEIMAGENUMBER, 130088); + CHAR_setChar( petindex, CHAR_NAME, "-"); + //print("PET:%s fix BBI\n", CHAR_getUseName(petindex)); + } +#endif +/* + tran_no=CHAR_getInt( charaindex, CHAR_TRANSMIGRATION); + petstring = CHAR_makePetStringFromPetIndex( petindex); + c_ptr_index=strstr(petstring,"name:"); + getStringFromIndexWithDelim(c_ptr_index,":",2,c_temp,sizeof(c_temp)); + c_ptr_index=c_temp; + getStringFromIndexWithDelim(c_ptr_index,"|",1,c_temp1,sizeof(c_temp1)); + + if(b_find){//ttom + CHAR_setCharPoolPet( charaindex, i, -1); + print("\nKill pool pet ID=%d name=%s",ID1,c_temp1); + sprintf(c_temp2,"Kill pool pet ID=%d name=%s",ID1,c_temp1); + LogKill(CHAR_getChar( charaindex, CHAR_NAME ), + CHAR_getChar( charaindex, CHAR_CDKEY ), + c_temp2); + }else{//ttom +*/ + CHAR_setWorkInt( petindex, CHAR_WORKPLAYERINDEX, charaindex); + CHAR_complianceParameter( petindex ); +// }//ttom + } + } + } + +// CHAR_ResetPoolPetEgg( charaindex); +// CHAR_CheckProfessionEquit( charaindex); + CHAR_CheckProfessionSkill( charaindex); + /*{ + int i=0; + int skidx[]={2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, + 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, + 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,4,4,4,3,3,3,3,3,3,3}; + //20040702 Change fix + //Ƿְҵеļܲɾ + for( i = CHAR_SKILLMAXHAVE-1; i >= 0; i -- ){ + CHAR_HaveSkill *pSkil; + Skill* skill; + + pSkil = CHAR_getCharHaveSkill( charaindex, i ); + skill = &pSkil->skill; + if( pSkil == NULL )continue; + if( pSkil->use == 0 )continue; + if( skidx[skill->data[SKILL_IDENTITY]] != CHAR_getInt( charaindex, PROFESSION_CLASS ) + && skidx[skill->data[SKILL_IDENTITY]] != 4 ){//ͨɾ + SKILL_makeSkillData( &pSkil->skill, 0, 0 ); + pSkil->use = 0; + } + } + }*/ + time_t timep; + struct tm *p; + time(&timep); + p=localtime(&timep); + timep = mktime(p); +#ifdef _VIP_ANNOUNCE //VIPϵͳԶ + + if(CHAR_getInt( charaindex,CHAR_VIPRIDE )>0) + { +//#ifdef _YUANGUSA +// if(CHAR_getInt(charaindex,CHAR_VIPRIDE)==1 && CHAR_getInt(charaindex,CHAR_VIPTIME)==0){ +// CHAR_setInt(charaindex,CHAR_VIPTIME,timep+60*60*24*30); +// } +//#endif + int viptype,viptime; + viptime = CHAR_getInt( charaindex,CHAR_VIPTIME ); + viptype = CHAR_getInt( charaindex,CHAR_VIPRIDE ); + int vipmsgtype = getVipMsgType(); + if(viptime > 0) + { + viptime = viptime - timep; + } + if(viptime < 0) + { + CHAR_setInt( charaindex,CHAR_VIPRIDE,0 ); + CHAR_setInt( charaindex,CHAR_VIPTIME,0 ); + viptype = CHAR_getInt( charaindex,CHAR_VIPRIDE ); + } + if(viptype>0 && vipmsgtype>0 && viptype>=vipmsgtype) + { + int i; + int playernum = CHAR_getPlayerMaxNum(); + char VipMsg[256]; + char *MyName = CHAR_getChar( charaindex,CHAR_NAME ); + if(vipmsgtype == 1) + { +#ifdef _TEST_SERVER + if(viptype == 1) + sprintf( VipMsg, "%sĻԱ%sˣһӭ", "һʯ", MyName ); + else if(viptype == 2) + sprintf( VipMsg, "%sĻƽԱ%sˣһӭ", "һʯ", MyName ); + else if(viptype == 3) + sprintf( VipMsg, "%sʯԱ%sˣһӭ", "һʯ", MyName ); +#else + if(viptype == 1) + sprintf( VipMsg, "%sĻԱ%sˣһӭ", getGameservername(), MyName ); + else if(viptype == 2) + sprintf( VipMsg, "%sĻƽԱ%sˣһӭ", getGameservername(), MyName ); + else if(viptype == 3) + sprintf( VipMsg, "%sʯԱ%sˣһӭ", getGameservername(), MyName ); +#endif + } + else if(vipmsgtype == 2) + { +#ifdef _TEST_SERVER + if(viptype == 2) + sprintf( VipMsg, "%sĻƽԱ%sˣһӭ", "һʯ", MyName ); + else if(viptype == 3) + sprintf( VipMsg, "%sʯԱ%sˣһӭ", "һʯ", MyName ); +#else + if(viptype == 2) + sprintf( VipMsg, "%sĻƽԱ%sˣһӭ", getGameservername(), MyName ); + else if(viptype == 3) + sprintf( VipMsg, "%sʯԱ%sˣһӭ", getGameservername(), MyName ); +#endif + } + else if(vipmsgtype == 3) + { +#ifdef _TEST_SERVER + if(viptype == 3) + sprintf( VipMsg, "%sʯԱ%sˣһӭ", "һʯ", MyName ); +#else + if(viptype == 3) + sprintf( VipMsg, "%sʯԱ%sˣһӭ", getGameservername(), MyName ); +#endif + } + for( i = 0 ; i < playernum ; i++) + { + CHAR_talkToCli( i, -1, VipMsg, CHAR_COLORPURPLE); + } + } + } +#endif +#ifdef _OFFLINE_SYSTEM + if(strlen(CHAR_getChar(charaindex,CHAR_OFFBUF))<1){ + time_t timep; + struct tm *p; + time(&timep); + p=localtime(&timep); /*ȡõʱ*/ + int mon=1+p->tm_mon; + int date=p->tm_mday; + char offbuf[64]; + sprintf(offbuf,"%d-%d-%d",mon,date,0); + CHAR_setChar(charaindex,CHAR_OFFBUF,offbuf); + CHAR_setInt(charaindex,CHAR_OFFTIME,172800); + } +#endif +//22222222222222222222222222222222 + + CHAR_loginCheckUserItem( charaindex); + CHAR_complianceParameter( charaindex ); + + // Robin add 走 ʱ + CHAR_ResetPetEggFusionTime( charaindex); + +#ifdef _PROFESSION_FIX_LEVEL // WON ADD ְҵֵ + { + int i=0; + for( i = 0 ; i < CHAR_SKILLMAXHAVE ; i ++ ){ + CHAR_HaveSkill* hskill; + + hskill = CHAR_getCharHaveSkill( charaindex, i ); + + if( hskill != NULL && hskill->use == TRUE ){ + int skill_level = SKILL_getInt( &hskill->skill, SKILL_LEVEL); + if( skill_level < 10 ){ + SKILL_setInt( &hskill->skill, SKILL_LEVEL, 10* 100 ); + } + } + } + } +#endif + +#ifdef _CHANNEL_MODIFY + if(CHAR_getInt(charaindex,PROFESSION_CLASS) > 0){ + int i,pclass = CHAR_getInt(charaindex,PROFESSION_CLASS) - 1,Empty = -1; + // ɵְҵƵ¼м¼ھ,ûмƵ + for(i=0;i MAX_PERSONAL_MOMENTUM) CHAR_setInt(charaindex,CHAR_MOMENTUM,MAX_PERSONAL_MOMENTUM); +#endif + +#ifdef _PETSKILL_BECOMEPIG + if( CHAR_getInt( charaindex, CHAR_BECOMEPIG) > -1 ){ + CHAR_setInt( charaindex, CHAR_BASEIMAGENUMBER, CHAR_getInt( charaindex, CHAR_BECOMEPIG_BBI ) ); + } + //change fix ܴʱ + else{ + CHAR_setInt( charaindex, CHAR_BECOMEPIG, -1 ); + } +#endif + + + lssproto_CharLogin_send( clifd, SUCCESSFUL,"" ); + per = ENCOUNT_getEncountPercentMin( charaindex, + CHAR_getInt( charaindex, CHAR_FLOOR), + CHAR_getInt( charaindex, CHAR_X), + CHAR_getInt( charaindex, CHAR_Y)); + if( per != -1) { + CHAR_setWorkInt( charaindex, CHAR_WORKENCOUNTPROBABILITY_MIN, per); + } + per = ENCOUNT_getEncountPercentMax( charaindex, + CHAR_getInt( charaindex, CHAR_FLOOR), + CHAR_getInt( charaindex, CHAR_X), + CHAR_getInt( charaindex, CHAR_Y)); + if( per != -1) { + CHAR_setWorkInt( charaindex, CHAR_WORKENCOUNTPROBABILITY_MAX, per); + } + + CHAR_setLuck( charaindex); + { + int i; + char* statuscat[]={"C","P","I","S","D","E","F"}; + for( i=0 ; i=1 ) + CHAR_Skillupsend(charaindex); + CHAR_checkEffect( charaindex); + // CoolFish: Family 2001/5/30 + if ((CHAR_getChar(charaindex, CHAR_FMNAME)!=NULL) && + (CHAR_getInt(charaindex, CHAR_FMINDEX) >= 0) && + (strcmp(CHAR_getChar(charaindex, CHAR_FMNAME), "") != 0)) + { +#ifdef _FMVER21 + int eventflag = 0; + // Ƿ峤ʸ + if (CheckLeaderQ(charaindex) >= 0) + eventflag = 1; + if (CHAR_getInt(charaindex, CHAR_FMLEADERFLAG) != FMMEMBER_LEADER) + SetFMPetVarInit(charaindex); + saacproto_ACFMCharLogin_send( + acfd, + CHAR_getChar(charaindex, CHAR_FMNAME), + CHAR_getInt(charaindex, CHAR_FMINDEX), + CHAR_getChar(charaindex, CHAR_NAME), + CHAR_getChar(charaindex, CHAR_CDKEY), + CHAR_getInt(charaindex, CHAR_LV), eventflag, + CONNECT_getFdid(clifd) +#ifdef _FM_MODIFY + ,getServernumber() +#endif + ); + } +#ifdef _FMVER21 + else + SetFMVarInit(charaindex); +#endif + +#endif + + AnnounceToPlayerWN( clifd ); + +#ifdef _ANGEL_SUMMON + { + int mindex; + mindex = checkIfOnlyAngel( charaindex); + if( mindex != -1 ) { + if( missiontable[mindex].flag == MISSION_WAIT_ANSWER ) { + lssproto_WN_send( clifd, WINDOW_MESSAGETYPE_ANGELMESSAGE, + WINDOW_BUTTONTYPE_YESNO, + CHAR_WINDOWTYPE_ANGEL_ASK, + -1, + "ĿǰħŰҪİæǰѰЩħ壬ǷԸæ" ); + } + } + } +#endif + + print("\n½:%s ", CHAR_getChar(charaindex, CHAR_NAME ) ); + + + unsigned long ip; + char ipstr[512]; + ip=CONNECT_get_userip(clifd); + sprintf(ipstr,"%d.%d.%d.%d", + ((unsigned char *)&ip)[0], + ((unsigned char *)&ip)[1], + ((unsigned char *)&ip)[2], + ((unsigned char *)&ip)[3]); + +#ifdef _RECORD_IP + CHAR_setWorkInt(charaindex, CHAR_WORK_RECORD_IP, CONNECT_get_userip(clifd)); +#endif + +// CHAR_setChar(charaindex,CHAR_CHARPLAYIP,ipstr); + char pcid[64]; + memset( pcid, 0 , sizeof( pcid ) ); + CONNECT_getPcid( clifd, pcid, sizeof( pcid )); + LogLogin( + CHAR_getChar( charaindex, CHAR_CDKEY), + CHAR_getChar( charaindex, CHAR_NAME), + saveindex, ipstr,pcid + ); + +#ifdef _VIGOR_SYS + CHAR_setWorkInt(charaindex,CHAR_WORKVIGORTIME,timep); +#endif + +#ifdef _TEACHER_SYSTEM + // ѧ֪ͨʦ + if(strlen(CHAR_getChar(charaindex,CHAR_TEACHER_ID)) > 0 && strlen(CHAR_getChar(charaindex,CHAR_TEACHER_NAME)) > 0){ + int iPlayernum = CHAR_getPlayerMaxNum(),i; + char szMsg[128]; + + for(i=0;i 0 && + strlen(CHAR_getChar(charaindex,CHAR_LOVERID))>0 && + strlen(CHAR_getChar(charaindex,CHAR_LOVERNAME))>0){ + int iPlayernum = CHAR_getPlayerMaxNum(),i; + char szMsg[128]; + for(i=0;i0){ + time_t timep; + struct tm *p; + time(&timep); + p=localtime(&timep); + timep = mktime(p); + if(CHAR_getInt(charaindex,CHAR_JOBPKTIME)-timep<=0){ + CHAR_setInt(charaindex,CHAR_JOBPKTIME,0); + CHAR_setInt(charaindex,CHAR_JOBPKMODE,0); + }else{ + char jobbuf[256]; + if(CHAR_getInt(charaindex,CHAR_JOBPKMODE)==1){ + sprintf(jobbuf,"һӭԶŰʿϯӡ%sߣ",CHAR_getChar(charaindex,CHAR_NAME)); + }else if(CHAR_getInt(charaindex,CHAR_JOBPKMODE)==2){ + sprintf(jobbuf,"һӭԶ鷨ʦϯӡ%sߣ",CHAR_getChar(charaindex,CHAR_NAME)); + }else{ + sprintf(jobbuf,"һӭԶ׷ߡϯӡ%sߣ",CHAR_getChar(charaindex,CHAR_NAME)); + } + int i; + int playernum = CHAR_getPlayerMaxNum(); + for( i = 0 ; i < playernum ; i++) + { + CHAR_talkToCli( i, -1, jobbuf, CHAR_COLORRED); + } + } + } +#endif + { + sasql_online(cdkey,CHAR_getChar(charaindex,CHAR_NAME),ipstr,CHAR_getInt(charaindex,CHAR_FAME),CHAR_getInt(charaindex,CHAR_VIGOR),1); + } + { + if(CHAR_getInt(charaindex,CHAR_WALKINTERVAL) != getWalksendinterval()) + CHAR_setInt(charaindex,CHAR_WALKINTERVAL,getWalksendinterval()); + } +#ifdef _PET_ITEM + if( CHAR_CHECKINDEX( CHAR_getCharPet( charaindex, 0) ) ){ + CHAR_sendPetItemData(charaindex,0); + } + if( CHAR_CHECKINDEX( CHAR_getCharPet( charaindex, 1) ) ){ + CHAR_sendPetItemData(charaindex,1); + } + if( CHAR_CHECKINDEX( CHAR_getCharPet( charaindex, 2) ) ){ + CHAR_sendPetItemData(charaindex,2); + } + if( CHAR_CHECKINDEX( CHAR_getCharPet( charaindex, 3) ) ){ + CHAR_sendPetItemData(charaindex,3); + } + if( CHAR_CHECKINDEX( CHAR_getCharPet( charaindex, 4) ) ){ + CHAR_sendPetItemData(charaindex,4); + } +#endif + if(CHAR_getInt(charaindex,CHAR_LV)>10 || CHAR_getInt(charaindex,CHAR_TRANSMIGRATION)>0){ + sasql_online_ip(cdkey,ipstr); + } + + CHAR_setWorkInt(charaindex,CHAR_WORKALLTALKTYPE,0); + + return; + +DELETECHARDATA: + CHAR_endCharOneArray( charaindex ); +MAKECHARDATAERROR: + { + int i; + char cdkey[CDKEYLEN]; + for( i = 0; i < CHAR_MAXPETHAVE; i ++ ) { + if( CHAR_CHECKINDEX(ch.unionTable.indexOfPet[i] ) ) { + CHAR_endCharOneArray( ch.unionTable.indexOfPet[i] ); + } + } + CONNECT_getCdkey( clifd, cdkey, sizeof(cdkey )); + saacproto_ACLock_send( acfd, cdkey, UNLOCK, CONNECT_getFdid(clifd) ); + } + CONNECT_setState(clifd, WHILECANNOTLOGIN ); + CONNECT_setCharaindex( clifd, -1 ); + lssproto_CharLogin_send( clifd, FAILED, "볢Ե½·Ժԡ"); +} + +BOOL CHAR_charSaveFromConnectAndChar( int fd, Char* ch, BOOL unlock ) +{ + char* chardata; + char cdkey[CDKEYLEN]; + + chardata = CHAR_makeStringFromCharData( ch ); + if( chardata == "\0" )return FALSE; +// CONNECT_getCdkey( fd, cdkey, sizeof(cdkey)); +// +// if(strcmp(cdkey,ch->string[CHAR_CDKEY].string)!=0){ +// printf(":%s˺:%sϣ浵",cdkey,ch->string[CHAR_CDKEY].string); +// return FALSE; +// } +#ifdef _DBSAVE_CHAR + else{ + if(ch->data[CHAR_SAVEINDEXNUMBER]!=-1) + CharaData( fd, ch ); + } +#endif + +#ifdef _NEWSAVE + +// print("saveindex_save:%d\n",ch->data[CHAR_SAVEINDEXNUMBER]); + saacproto_ACCharSave_send( acfd, ch->string[CHAR_CDKEY].string, + ch->string[CHAR_NAME].string, + CHAR_makeOptionString( ch ), chardata, + unlock, CONNECT_getFdid(fd), ch->data[CHAR_SAVEINDEXNUMBER] ); +#else + + saacproto_ACCharSave_send( acfd, cdkey, + ch->string[CHAR_NAME].string, + CHAR_makeOptionString( ch ), chardata, + unlock, CONNECT_getFdid(fd) ); +#endif + if(unlock) sasql_online(ch->string[CHAR_CDKEY].string,NULL,NULL,NULL,NULL,0); + return TRUE; +} + +BOOL CHAR_charSaveFromConnect( int charaindex , BOOL unlock) +{ + Char* ch; + int fd = getfdFromCharaIndex(charaindex); + if( CHAR_CHECKINDEX( charaindex ) == FALSE)return FALSE; + ch = CHAR_getCharPointer( charaindex ); + if( !ch )return FALSE; +#ifdef _CHAR_POOLITEM + if( CHAR_SaveDepotItem( charaindex) == TRUE ){ + print("saveDepotItem:%d \n", charaindex); + } +#endif +#ifdef _CHAR_POOLPET + if( CHAR_SaveDepotPet( charaindex) == TRUE ){ + print("saveDepotPet:%d \n", charaindex); + } +#endif + + return CHAR_charSaveFromConnectAndChar( fd, ch, unlock ); +} + + +/*------------------------------------------------------------ + * ʧݱ ʧƥئʧ ةë + * + * ¦ + * charaindex int ƽҷ̼͵ + * ߯Ի + * ئ + ------------------------------------------------------------*/ +static void CHAR_dropItemAtLogout( int charaindex ) +{ + int i; + for( i=0 ; i= 0 ){ + BATTLE_EscapeDpSend( battleindex, charindex ); + CHAR_setInt( charindex, CHAR_DUELPOINT, + CHAR_getInt( charindex, CHAR_DUELPOINT ) + + CHAR_getWorkInt( charindex, CHAR_WORKGETEXP ) ); + CHAR_setWorkInt( charindex, CHAR_WORKDBATTLEESCAPE, 1); + BATTLE_Exit( charindex, battleindex ); + } + + CHAR_dropItemAtLogout( charindex ); + CHAR_DischargeParty( charindex, 0); + if(CHAR_getChar(charindex, CHAR_FMNAME) != NULL ) { + if(strlen(CHAR_getChar(charindex, CHAR_FMNAME)) > 0 && + strlen(CHAR_getChar(charindex, CHAR_FMNAME)) < sizeof( STRING32) ) + if( (CHAR_getInt(charindex, CHAR_FMINDEX) >= 0) && + (strcmp(CHAR_getChar(charindex, CHAR_FMNAME), "") != 0) ) { + saacproto_ACFMCharLogout_send(acfd, + CHAR_getChar(charindex, CHAR_FMNAME), + CHAR_getInt(charindex, CHAR_FMINDEX), + CHAR_getChar(charindex, CHAR_NAME), + CHAR_getChar(charindex, CHAR_CDKEY), + CHAR_getInt(charindex, CHAR_LV), + CHAR_getWorkInt(charindex, CHAR_WORKFMINDEXI), + CONNECT_getFdid(clifd)); + } + } + +#ifdef _CHATROOMPROTOCOL // (ɿ) Syu ADD Ƶ + if ( CHAR_getWorkInt ( charindex , CHAR_WORKCHATROOMTYPE ) != 0 ) { + ChatRoom_Leave ( charindex ) ; + } +#endif +#ifdef _STREET_VENDOR + // ڽ + if(CHAR_getWorkInt(charindex,CHAR_WORKSTREETVENDOR) == 2){ + // ȡ׵ + toindex = CHAR_getWorkInt(charindex,CHAR_WORKSTREETVENDOR_WHO); + if(toindex > -1 && CHAR_CHECKINDEX(toindex)){ + CHAR_setWorkInt(toindex,CHAR_WORKSTREETVENDOR_WHO,-1); + CHAR_setWorkInt(toindex,CHAR_WORKSTREETVENDOR,-1); + lssproto_STREET_VENDOR_send(getfdFromCharaIndex(toindex),"C|"); + CHAR_talkToCli(toindex,-1,"ȡ",CHAR_COLORYELLOW); + } + } + // + else if(CHAR_getWorkInt(charindex,CHAR_WORKSTREETVENDOR) == 3){ + // ȡ + toindex = CHAR_getWorkInt(charindex,CHAR_WORKSTREETVENDOR_WHO); + if(toindex > -1 && CHAR_CHECKINDEX(toindex)){ + CHAR_setWorkInt(toindex,CHAR_WORKSTREETVENDOR_WHO,-1); + CHAR_setWorkInt(toindex,CHAR_WORKSTREETVENDOR,1); + } + } +#endif + + // Robin 0606 channel + fmindexi = CHAR_getWorkInt(charindex, CHAR_WORKFMINDEXI); + channel = CHAR_getWorkInt(charindex, CHAR_WORKFMCHANNEL); + i = 0; + if( (fmindexi > 0) && (channel >= 0) && (fmindexi < FAMILY_MAXNUM) && (channel < FAMILY_MAXCHANNEL)) { + while( i < FAMILY_MAXMEMBER ) { + if( channelMember[fmindexi][channel][i] == charindex ) { + channelMember[fmindexi][channel][i] = -1; + break; + } + i++; + } + } +#ifdef _CHANNEL_MODIFY + if(CHAR_getInt(charindex,PROFESSION_CLASS) > 0){ + int i,pclass = CHAR_getInt(charindex,PROFESSION_CLASS) - 1; + for(i=0;i 0) && (fmindexi < FAMILY_MAXNUM)){ + if( familyMemberIndex[fmindexi][i] == charindex ) + familyMemberIndex[fmindexi][i] = -1; + } + } + // Robin 0629 silent + if( CHAR_getInt( charindex, CHAR_SILENT) > 0 ){ + int silent_t, login_t; + login_t = CHAR_getWorkInt(charindex, CHAR_WORKLOGINTIME); + silent_t = CHAR_getInt( charindex, CHAR_SILENT); + silent_t = silent_t - ( (int)NowTime.tv_sec-login_t); + if( silent_t<0 ) silent_t = 0; + CHAR_setInt( charindex, CHAR_SILENT, silent_t); + } + + + +#ifdef _ITEM_ADDEXP2 + if( CHAR_getInt( charindex, CHAR_ADDEXPPOWER) > 0 ) { + // ʱǹЧԶ90 + CHAR_setInt( charindex, CHAR_ADDEXPTIME, + CHAR_getInt( charindex, CHAR_ADDEXPTIME) - 90 ); + if( CHAR_getInt( charindex, CHAR_ADDEXPTIME) <= 0 ) { + CHAR_setInt( charindex, CHAR_ADDEXPTIME, 0); + CHAR_setInt( charindex, CHAR_ADDEXPPOWER, 0); + } + } +#endif + +#ifdef _VIP_BATTLE_EXP + if( CHAR_getInt( charindex, CHAR_NVIPTIME) <= 0 ) { + CHAR_setInt( charindex, CHAR_NVIPTIME, 0); + CHAR_setInt( charindex, CHAR_NVIPEXP, 0); + } +#endif + +#ifdef _TIME_TICKET + if( check_TimeTicketMap( CHAR_getInt( charindex, CHAR_FLOOR)) ) { + CHAR_warpToSpecificPoint( charindex, 2006, 20, 17); + } +#endif + +#ifdef _AUTO_PK + if(CHAR_getInt(charindex,CHAR_FLOOR)==20000 && CHAR_getInt(charindex,CHAR_AUTOPK)!=-1 && autopkstart == 1){ + char buf[64]; + int i,num=0,winindex; + int playernum = CHAR_getPlayerMaxNum(); +#ifndef _YUANGUSA + sprintf(buf, "С%s˳ǰ",CHAR_getChar(charindex,CHAR_NAME)); + AutoPk_PKSystemTalk( buf, buf ); +#endif + if(CHAR_getWorkInt( charindex, CHAR_WORKBATTLEMODE) == BATTLE_CHARMODE_NONE){ + if(AutoPk_PKTimeGet()<=0){ + for(i=0;i0 && getVigorTime(CHAR_getInt(charindex,CHAR_TRANSMIGRATION))>0){ + if(CHAR_getInt(charindex,CHAR_VIGOR)=getVigorTime(CHAR_getInt(charindex,CHAR_TRANSMIGRATION)) && getVigorTime(CHAR_getInt(charindex,CHAR_TRANSMIGRATION))>0 && CHAR_getWorkInt(charindex,CHAR_WORKVIGORTIME)>0 ){ + CHAR_setInt(charindex,CHAR_VIGOR,min(CHAR_getInt(charindex,CHAR_VIGOR)+(int)(curtime/getVigorTime(CHAR_getInt(charindex,CHAR_TRANSMIGRATION))*2),getVigorMax())); + //CHAR_setWorkInt(charindex,CHAR_WORKVIGORTIME,CHAR_getWorkInt(charindex,CHAR_WORKVIGORTIME)+(int)(curtime/getVigorTime(1))*getVigorTime(1)); + CHAR_setWorkInt(charindex,CHAR_WORKVIGORTIME,timep); + } + } + }else if(CHAR_getInt(charindex,CHAR_VIPRIDE)<=0 && getVigorTime(CHAR_getInt(charindex,CHAR_TRANSMIGRATION))>0){ + if(CHAR_getInt(charindex,CHAR_VIGOR)=getVigorTime(CHAR_getInt(charindex,CHAR_TRANSMIGRATION)) && getVigorTime(CHAR_getInt(charindex,CHAR_TRANSMIGRATION))>0 && CHAR_getWorkInt(charindex,CHAR_WORKVIGORTIME)>0){ + CHAR_setInt(charindex,CHAR_VIGOR,min(CHAR_getInt(charindex,CHAR_VIGOR)+(int)(curtime/getVigorTime(CHAR_getInt(charindex,CHAR_TRANSMIGRATION))),getVigorMax())); + //CHAR_setWorkInt(charindex,CHAR_WORKVIGORTIME,CHAR_getWorkInt(charindex,CHAR_WORKVIGORTIME)+(int)(curtime/getVigorTime(CHAR_getInt(charindex,CHAR_TRANSMIGRATION)))*getVigorTime(CHAR_getInt(charindex,CHAR_TRANSMIGRATION))); + CHAR_setWorkInt(charindex,CHAR_WORKVIGORTIME,timep); + } + } + } +#ifdef _ONLINE_TIME + if (CHAR_getInt(charindex,CHAR_TRANSMIGRATION)>=0) + { + time_t timep; + struct tm *p; + time(&timep); + p=localtime(&timep); + timep = mktime(p); + int curtime = timep-CHAR_getWorkInt(charindex,CHAR_WORKVIGORTIME); + CHAR_setInt(charindex,CHAR_ONLINE_TIME,CHAR_getInt(charindex,CHAR_ONLINE_TIME)+curtime); +#ifdef _REGISTRATION_TIME + // CHAR_setInt(charindex,CHAR_REGISTRATION_ONLINE_TIME,CHAR_getInt(charindex,CHAR_REGISTRATION_ONLINE_TIME)+curtime); +#endif + } +#endif + } +#endif +//1111111111111111111111111111111111111 + + + + + if(CHAR_getInt(charindex,CHAR_FMINDEX) != -1 && (strcmp(CHAR_getChar(charindex,CHAR_FMNAME),""))){ + char tempbuf[256]; + sprintf(tempbuf,"%d",CHAR_getInt(charindex,CHAR_FAME)); + saacproto_ACFixFMData_send(acfd, + CHAR_getChar(charindex,CHAR_FMNAME), + CHAR_getInt(charindex,CHAR_FMINDEX), + CHAR_getWorkInt(charindex,CHAR_WORKFMINDEXI), + FM_FIX_FAME,tempbuf,"", + CHAR_getWorkInt(charindex,CHAR_WORKFMCHARINDEX), + CONNECT_getFdid(clifd)); + } +#ifdef _ALLBLUES_LUA_1_4 + RunCharLogOutEvent(charindex); +#endif + if( save ){ + CHAR_charSaveFromConnect( charindex ,TRUE); + } +#ifdef _OFFLINE_SYSTEM + if(CHAR_getWorkInt( charindex, CHAR_WORK_OFFLINE )!=0) + playeronlinenum--; +#endif + + ADDRESSBOOK_notifyLoginLogout(charindex,0); + CHAR_CharaDeleteHavePet( charindex); + CHAR_CharaDelete( charindex ); + + return ret; +} +/*------------------------------------------------------------ + * watchìë˪¾ + * ¦ + * objindex int ìëƳƽҷ¼Ƥ + * ̼͵ + * index int ìëƳƽҷ¼̼͵ + * recvindex int ìëƽҷ¼index + * chac int ʧ + * ߯Ի TRUE: ˪Ȼз + * FALSE: + ------------------------------------------------------------*/ +static BOOL CHAR_sendWatchEvent_sendCheck( int objindex, int index, + int recvindex, int chac) +{ + /* лNPCƥNPC */ + if( OBJECT_getType( objindex) == OBJTYPE_CHARA && + CHAR_getInt( index, CHAR_WHICHTYPE) != CHAR_TYPEPLAYER && + CHAR_getInt(recvindex, CHAR_WHICHTYPE ) + != CHAR_TYPEPLAYER ) + { + return FALSE; + } + /* ƽҷ¶½watch Ʊީ */ + if( OBJECT_getType( objindex) != OBJTYPE_CHARA) { + return TRUE; + } + /* + * г߼弰 Ʊ + */ + if( index == recvindex && chac == CHAR_ACTWALK ) { + return FALSE; + } + + if( CHAR_getInt( recvindex, CHAR_WHICHTYPE) == CHAR_TYPEPLAYER) { + /* б巴 ͷ־˪ئ */ + if( CHAR_getWorkInt( recvindex,CHAR_WORKBATTLEMODE) + != BATTLE_CHARMODE_NONE) + { + return FALSE; + } + /* ʧԪ */ + if( CHAR_getWorkInt( index, CHAR_WORKACTION) == -1 ) { + if( OBJECT_getType(objindex) == OBJTYPE_CHARA) { + /* Ԫɡ ū + * ʶ½ְë˪ئ + */ + if( CHAR_getWorkInt( index, CHAR_WORKPARTYMODE ) + == CHAR_PARTY_CLIENT && + CHAR_getWorkInt( recvindex, CHAR_WORKPARTYMODE) + != CHAR_PARTY_NONE && + chac == CHAR_ACTWALK ) + { + int found = FALSE; + int loop; + /* ëƩ */ + for( loop = 1; loop < CHAR_PARTYMAX; loop ++ ) { + int partycharaindex = CHAR_getPartyIndex( recvindex, loop); + /* ƽҷ»мɡ ūҷ */ + if( partycharaindex == index ) { + found = TRUE; + break; + } + } + if( found ) return FALSE; + } + /* ʷҼSTANDë˪ئ */ + if( CHAR_getWorkInt( index, CHAR_WORKPARTYMODE) + == CHAR_PARTY_CLIENT && + CHAR_getWorkInt( recvindex, CHAR_WORKPARTYMODE) + == CHAR_PARTY_LEADER && + chac == CHAR_ACTSTAND) + { + int found = FALSE; + int loop; + /* ëƩ */ + for( loop = 1; loop < CHAR_PARTYMAX; loop ++ ) { + int partycharaindex + = CHAR_getWorkInt( recvindex, + CHAR_WORKPARTYINDEX1+loop); + /* STANDƽҷ»мɡ ūҷ */ + if( partycharaindex == index ) { + found = TRUE; + break; + } + } + if( found ) return FALSE; + } + } + } + } + return TRUE; +} + +void CHAR_sendWatchEvent( int objindex, int chac, int* opt, + int optlen,BOOL myflg ) +{ + int i; + int j; + int x=0,y=0,dir=0; + int floor; + int watchopt[32]; + int watchoptlen=0; + typedef void (*WATCHF)(int,int,CHAR_ACTION,int,int,int,int*,int); + int index; + + if( !CHECKOBJECTUSE(objindex) )return; + index = OBJECT_getIndex( objindex); + switch( OBJECT_getType(objindex) ){ + case OBJTYPE_CHARA: + for( i=0; i= 4 ){ + return; + } + // ɷ¶ʧƥ¾ + cnt = CHAR_getInt(charaindex,CHAR_SKILLUPPOINT); + if( cnt <= 0 )return; + +#ifdef _CHAR_PROFESSION // WON ADD ְҵλ + { + int p_class = CHAR_getInt( charaindex, PROFESSION_CLASS ); + int fd=-1; + + switch( p_class ){ + case PROFESSION_CLASS_FIGHTER: + // ʿ200 + if( SkUpTbl[skillid] == CHAR_DEX ){ + if( CHAR_getInt( charaindex, SkUpTbl[skillid] ) >= 200 * 100 ){ + CHAR_talkToCli(charaindex, -1, "ֵѴ", CHAR_COLORYELLOW ); + fd = getfdFromCharaIndex(charaindex); + if( fd != -1 ) lssproto_SKUP_send( fd, cnt ); + return; + } + } + break; + case PROFESSION_CLASS_WIZARD: + // ʦ200 + if( SkUpTbl[skillid] == CHAR_STR ){ + if( CHAR_getInt( charaindex, SkUpTbl[skillid] ) >= 200 * 100 ){ + CHAR_talkToCli(charaindex, -1, "ֵѴ", CHAR_COLORYELLOW ); + fd = getfdFromCharaIndex(charaindex); + if( fd != -1 ) lssproto_SKUP_send( fd, cnt ); + return; + } + } + // ʦ200 + if( SkUpTbl[skillid] == CHAR_TOUGH ){ + if( CHAR_getInt( charaindex, SkUpTbl[skillid] ) >= 200 * 100 ){ + CHAR_talkToCli(charaindex, -1, "ֵѴ", CHAR_COLORYELLOW ); + fd = getfdFromCharaIndex(charaindex); + if( fd != -1 ) lssproto_SKUP_send( fd, cnt ); + return; + } + } + break; + case PROFESSION_CLASS_HUNTER: + // 200 + if( SkUpTbl[skillid] == CHAR_STR ){ + if( CHAR_getInt( charaindex, SkUpTbl[skillid] ) >= 200 * 100 ){ + CHAR_talkToCli(charaindex, -1, "ֵѴ", CHAR_COLORYELLOW ); + fd = getfdFromCharaIndex(charaindex); + if( fd != -1 ) lssproto_SKUP_send( fd, cnt ); + return; + } + } + // 200 + if( SkUpTbl[skillid] == CHAR_TOUGH ){ + if( CHAR_getInt( charaindex, SkUpTbl[skillid] ) >= 200 * 100 ){ + CHAR_talkToCli(charaindex, -1, "ֵѴ", CHAR_COLORYELLOW ); + fd = getfdFromCharaIndex(charaindex); + if( fd != -1 ) lssproto_SKUP_send( fd, cnt ); + return; + } + } + // 400 + if( SkUpTbl[skillid] == CHAR_DEX ){ + if( CHAR_getInt( charaindex, SkUpTbl[skillid] ) >= 400 * 100 ){ + CHAR_talkToCli(charaindex, -1, "ֵѴ", CHAR_COLORYELLOW ); + fd = getfdFromCharaIndex(charaindex); + if( fd != -1 ) lssproto_SKUP_send( fd, cnt ); + return; + } + } + break; + default: break; + } + + fd = getfdFromCharaIndex(charaindex); + if( fd != -1 ) lssproto_SKUP_send( fd, cnt-1 ); + } +#endif + + CHAR_setInt( charaindex,CHAR_SKILLUPPOINT,cnt-1); + CHAR_setInt( charaindex, SkUpTbl[skillid], CHAR_getInt( charaindex, SkUpTbl[skillid] ) + 1*100 ); + + CHAR_complianceParameter(charaindex); + CHAR_send_P_StatusString( charaindex, SendTbl[skillid]); + +#ifdef _ANGEL_SUMMON // ӵʱʸ + if( cnt-1 == 0 ) + //selectAngel( charaindex); + selectAngel( charaindex, -1, -1 , FALSE); + +#endif + } + CHAR_PartyUpdate( charaindex, CHAR_N_STRING_MAXHP ); + +} + +INLINE void CHAR_getDXDY( int dir , int* dx, int* dy ) +{ + static POINT CHAR_dxdy[8]= + { + { 0,-1}, /* */ + { 1,-1}, /* */ + { 1, 0}, /* */ + { 1, 1}, /* */ + { 0, 1}, /* */ + {-1, 1}, /* */ + {-1, 0}, /* */ + {-1,-1}, /* */ + }; + VALIDATEDIR(dir); + + if( dx )*dx = CHAR_dxdy[dir].x; + if( dy )*dy = CHAR_dxdy[dir].y; +} +INLINE int CHAR_getDX( int dir ) +{ + int tmp; + CHAR_getDXDY( dir,&tmp,NULL); + return tmp; +} +INLINE int CHAR_getDY( int dir ) +{ + int tmp; + CHAR_getDXDY( dir,NULL,&tmp); + return tmp; +} + +/*------------------------------------------------------------ + * ԪѨƽҷë £ + * ¦ + * objbuf int* object ƥ index ëҽ + * + * siz int objbuf + * ff int ׷ʧ + * fx int x + * fy int y + * ߯Ի + * ƽҷ»¾ + ------------------------------------------------------------*/ +int CHAR_getSameCoordinateObjects(int* objbuf, int siz,int ff, int fx, int fy) +{ + OBJECT object; + int findobjnum=0; + + for( object = MAP_getTopObj(ff,fx,fy) ; object ; + object = NEXT_OBJECT(object ) ){ + int objindex = GET_OBJINDEX(object); + + if( siz <= findobjnum )break; + if( OBJECT_getType(objindex) != OBJTYPE_NOUSE ) + objbuf[findobjnum++] = objindex; + } + return findobjnum; +} + + +/*====================ƽҷ¼ ë ̼====================*/ +/* ٯ ë*/ +static char CHAR_optiondataString[STRINGBUFSIZ]; +/*------------------------------------------------------------ + * ü ٯ ë£ + * level, showstring , ۼ , į ϼԷ̼׾ + * ͷµ + * ¦ + * ch Char* ƽҷ· + * ߯Ի + * char* static ئ ë߯ʼƥݼԼ̫Ƽݱ巴 + * ʽľ£¦ëئǣ + ------------------------------------------------------------*/ +char* CHAR_makeOptionString( Char* ch ) +{ + char escapeshowstring[256]; + char *showstr = MAP_getfloorShowstring(ch->data[CHAR_FLOOR]); + if( ! showstr ){ + CHAR_optiondataString[0] = '\0'; + return CHAR_optiondataString; + } else { + +#if 0 /* ƱLS2 ƥؤ */ + snprintf( CHAR_optiondataString, + sizeof( CHAR_optiondataString ), + "%d|%s|1|%d|%d", + ch->data[CHAR_LV], + makeEscapeString( showstr , + escapeshowstring,sizeof(escapeshowstring) ), + ch->data[CHAR_BASEIMAGENUMBER], + ch->data[CHAR_LOGINCOUNT]); +#endif + + /* ƱStoneAge ƥؤ£ + + dataplace|faceimg|level|hp|str|def|dex|charm|dp|earth|water|fire|wind|login|Name|Place + ئ£ + */ + { + snprintf( CHAR_optiondataString, + sizeof( CHAR_optiondataString ), + "%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%s|%s", + ch->data[CHAR_DATAPLACENUMBER], + ch->data[CHAR_FACEIMAGENUMBER], + ch->data[CHAR_LV], + ch->workint[CHAR_WORKMAXHP], + ch->workint[CHAR_WORKATTACKPOWER], + ch->workint[CHAR_WORKDEFENCEPOWER], + ch->workint[CHAR_WORKQUICK], + ch->workint[CHAR_WORKFIXCHARM], + ch->data[CHAR_DUELPOINT], /* dp, FIXME */ + ch->workint[CHAR_WORKFIXEARTHAT], + ch->workint[CHAR_WORKFIXWATERAT], + ch->workint[CHAR_WORKFIXFIREAT], + ch->workint[CHAR_WORKFIXWINDAT], + ch->data[CHAR_LOGINCOUNT], + ch->string[CHAR_NAME].string, + makeEscapeString( showstr , + escapeshowstring, + sizeof(escapeshowstring) ) + ); + } + } + return CHAR_optiondataString; +} + +static char CHAR_statusSendBuffer[STRINGBUFSIZ]; + +char* CHAR_makeStatusString( int index, char* category ) +{ + char c = tolower( category[0] ); + int strlength=0; + + if( !CHAR_CHECKINDEX( index ) ) return "\0"; + + if( category == "\0" ){ + CHAR_statusSendBuffer[0] = '\0'; + return CHAR_statusSendBuffer; + } + switch( c ){ + case 'p': + { + int i; + int getCharDataArray[]= { + CHAR_NAME, + CHAR_OWNTITLE, + //CHAR_FMNAME, + }; + int exp = CHAR_getInt(index,CHAR_EXP ); + int maxexp = CHAR_GetLevelExp( index, CHAR_getInt( index, CHAR_LV ) + 1); + int attr[4]; + + for( i = 0; i < 4; i ++ ) { + attr[i] = CHAR_getWorkInt( index, CHAR_WORKFIXEARTHAT + i); + if( attr[i] < 0 ) attr[i] = 0; + } + int mytrans = CHAR_getInt( index, CHAR_TRANSMIGRATION); + //if(mytrans > 6) mytrans = 0; + snprintf(CHAR_statusSendBuffer,sizeof(CHAR_statusSendBuffer), + "P1|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|", + CHAR_getInt(index,CHAR_HP), + CHAR_getWorkInt(index,CHAR_WORKMAXHP), + CHAR_getInt(index,CHAR_MP), + CHAR_getWorkInt(index,CHAR_WORKMAXMP), + CHAR_getInt(index,CHAR_VITAL)/100, + CHAR_getInt(index,CHAR_STR)/100, + CHAR_getInt(index,CHAR_TOUGH)/100, + CHAR_getInt(index,CHAR_DEX)/100, + exp, maxexp, + CHAR_getInt(index,CHAR_LV), + CHAR_getWorkInt(index,CHAR_WORKATTACKPOWER), + CHAR_getWorkInt(index,CHAR_WORKDEFENCEPOWER), + CHAR_getWorkInt( index, CHAR_WORKQUICK), + CHAR_getWorkInt( index, CHAR_WORKFIXCHARM), + CHAR_getWorkInt( index, CHAR_WORKFIXLUCK), + attr[0], + attr[1], + attr[2], + attr[3], + CHAR_getInt(index,CHAR_GOLD), + CHAR_getInt(index,CHAR_INDEXOFEQTITLE), + CHAR_getInt(index,CHAR_DUELPOINT), + mytrans, + CHAR_getInt(index,CHAR_RIDEPET), + CHAR_getInt(index,CHAR_LEARNRIDE), + CHAR_getInt(index,CHAR_BASEBASEIMAGENUMBER) +#ifdef _NEW_RIDEPETS + ,CHAR_getInt( index, CHAR_LOWRIDEPETS) +#endif + + ); + strlength = strlen( CHAR_statusSendBuffer ); + for( i = 0 ; i < arraysizeof( getCharDataArray ) ; i ++ ){ + char token[256]; + char escapebuffer[128]; + snprintf( token, + sizeof( token ), + "%s" STATUSSENDDELIMITER, + makeEscapeString( CHAR_getChar(index, getCharDataArray[i]), + escapebuffer,sizeof(escapebuffer) + )); + strcpysafe( CHAR_statusSendBuffer + strlength, + sizeof( CHAR_statusSendBuffer ) - strlength, + token ); + strlength += strlen( token ); + if( strlength >= sizeof( CHAR_statusSendBuffer ) ) + return CHAR_statusSendBuffer; + } + return CHAR_statusSendBuffer; + break; + } +#ifdef _NEW_RIDEPETS + case 'x': + { + snprintf(CHAR_statusSendBuffer,sizeof(CHAR_statusSendBuffer), "X0|%d", + CHAR_getInt( index, CHAR_LOWRIDEPETS)); + return CHAR_statusSendBuffer; + break; + } +#endif + case 'f': + { + int big4fm =0; +#ifndef _NEW_RIDEPETS + switch( CHAR_getWorkInt( index, CHAR_WORKFMFLOOR) ) + { + case 1041: + big4fm = 1; + break; + case 2031: + big4fm = 2; + break; + case 3031: + big4fm = 3; + break; + case 4031: + big4fm = 4; + break; + default: + big4fm = 0; + } +#endif +#ifdef _FIX_FMNAME_RULE // WON ADD δʾ + if( CHAR_getWorkInt(index, CHAR_WORKFMSETUPFLAG)==1 ){ + snprintf( CHAR_statusSendBuffer, + sizeof( CHAR_statusSendBuffer ), + "F%s|%d|%d|%d|%d", + "()", + CHAR_getInt( index, CHAR_FMLEADERFLAG), + CHAR_getWorkInt( index, CHAR_WORKFMCHANNEL), + CHAR_getInt( index, CHAR_FMSPRITE), big4fm ); + }else +#endif + + snprintf( CHAR_statusSendBuffer, + sizeof( CHAR_statusSendBuffer ), + "F%s|%d|%d|%d|%d", + CHAR_getChar( index, CHAR_FMNAME), + CHAR_getInt( index, CHAR_FMLEADERFLAG), + CHAR_getWorkInt( index, CHAR_WORKFMCHANNEL), + CHAR_getInt( index, CHAR_FMSPRITE), big4fm ); + return CHAR_statusSendBuffer; + break; + } + case 'c': + { + int floor,xsiz,ysiz; + floor = CHAR_getInt(index,CHAR_FLOOR); + xsiz = MAP_getfloorX(floor); + ysiz = MAP_getfloorY(floor); + snprintf( CHAR_statusSendBuffer, + sizeof( CHAR_statusSendBuffer ), + "C%d|%d|%d|%d|%d", + CHAR_getInt(index,CHAR_FLOOR), + xsiz, ysiz, + CHAR_getInt(index,CHAR_X), + CHAR_getInt(index,CHAR_Y) ); + return CHAR_statusSendBuffer; + break; + } + case 'i': + { + int i; + CHAR_statusSendBuffer[0] = 'I'; + strlength = 1; + for( i = 0 ; i < CHAR_MAXITEMHAVE ; i ++ ){ + char token[512]; + int itemindex; + itemindex = CHAR_getItemIndex( index, i ); + if( itemindex >= 0 ) { + int itemtime = 0; + itemtime = ITEM_getInt(itemindex,ITEM_TIME); + if(itemtime>0){ + time_t timep; + struct tm *p; + time(&timep); + p=localtime(&timep); + timep = mktime(p); + if(itemtime<=timep){ + char itemname[128]; + sprintf(itemname,"ĵ:%sʱЧѵϵͳջء",ITEM_getChar(itemindex,ITEM_NAME)); + CHAR_talkToCli( index, -1, itemname, CHAR_COLORYELLOW ); + CHAR_setItemIndex( index, i ,-1); + itemindex = -1; + } + } +// char itembuf[512]; +// sprintf(itembuf,"%s",ITEM_getChar(itemindex,ITEM_EFFECTSTRING)); +// if(strstr(itembuf,"Ч")!=NULL){ +// char itemtempbuf[64]; +// int year=3000,mon=13,date=32,hour=25,min=70,sec=70; +// if(getStringFromIndexWithDelim(itembuf," ", 1, itemtempbuf, sizeof(itemtempbuf)) != FALSE){ +// char itemtempbuf2[64]; +// char itemtempbuf3[64]; +// char itemtempbuf4[32]; +// if(getStringFromIndexWithDelim(itemtempbuf,"/", 1, itemtempbuf2, sizeof(itemtempbuf2)) != FALSE){ +// if(getStringFromIndexWithDelim(itemtempbuf2,":", 2, itemtempbuf3, sizeof(itemtempbuf3)) != FALSE){ +// if(getStringFromIndexWithDelim(itemtempbuf3,".", 1, itemtempbuf4, sizeof(itemtempbuf4)) != FALSE) +// year = atoi(itemtempbuf4); +// if(getStringFromIndexWithDelim(itemtempbuf3,".", 2, itemtempbuf4, sizeof(itemtempbuf4)) != FALSE) +// mon = atoi(itemtempbuf4); +// if(getStringFromIndexWithDelim(itemtempbuf3,".", 3, itemtempbuf4, sizeof(itemtempbuf4)) != FALSE) +// date = atoi(itemtempbuf4); +// } +// } +// if(getStringFromIndexWithDelim(itemtempbuf,"/", 2, itemtempbuf2, sizeof(itemtempbuf2)) != FALSE){ +// if(getStringFromIndexWithDelim(itemtempbuf2,":", 1, itemtempbuf3, sizeof(itemtempbuf3)) != FALSE) +// hour = atoi(itemtempbuf3); +// if(getStringFromIndexWithDelim(itemtempbuf2,":", 2, itemtempbuf3, sizeof(itemtempbuf3)) != FALSE) +// min = atoi(itemtempbuf3); +// if(getStringFromIndexWithDelim(itemtempbuf2,":", 3, itemtempbuf3, sizeof(itemtempbuf3)) != FALSE) +// sec = atoi(itemtempbuf3); +// } +// time_t timep; +// struct tm *p; +// time(&timep); +// p=localtime(&timep); +// int itemtype = 0; +// if(year<(1900+p->tm_year)) +// itemtype = 1; +// else if(year==(1900+p->tm_year)){ +// if(mon<(1+p->tm_mon)) +// itemtype = 1; +// else if(mon==(1+p->tm_mon)){ +// if(date<(p->tm_mday)) +// itemtype = 1; +// else if(date==(p->tm_mday)){ +// if(hour<(p->tm_hour)) +// itemtype = 1; +// else if(hour==(p->tm_hour)){ +// if(min<(p->tm_min)) +// itemtype = 1; +// else if(min==(p->tm_min)){ +// if(sec<(p->tm_sec)) +// itemtype = 1; +// } +// } +// } +// } +// } +// if(itemtype>0){ +// CHAR_setItemIndex( index, i ,-1); +// itemindex = -1; +// //CHAR_sendItemDataOne( charaindex, i); +// //ITEM_endExistItemsOne(itemindex); +// } +// } +// } + } + if( itemindex >= 0 ) { + snprintf( token ,sizeof(token),"%s|" ,ITEM_makeItemStatusString( -1, itemindex ) ); + }else { + snprintf( token ,sizeof(token),"%s|" , ITEM_makeItemFalseString() ); + } + strcpysafe( CHAR_statusSendBuffer + strlength, + sizeof(CHAR_statusSendBuffer) - strlength, token ); + strlength += strlen( token ); + if( strlength >= arraysizeof(CHAR_statusSendBuffer) ) return CHAR_statusSendBuffer; + } + dchop( CHAR_statusSendBuffer , "|" ); + return CHAR_statusSendBuffer; + break; + } + case 's': + { + int i; + CHAR_statusSendBuffer[0] = 'S'; + strlength = 1; + + for( i = 0 ; i < CHAR_SKILLMAXHAVE ; i ++ ){ + char token[256]; + CHAR_HaveSkill* hskill; + + hskill = CHAR_getCharHaveSkill( index, i ); + + if( hskill != NULL && hskill->use == TRUE ){ +#ifdef _CHAR_PROFESSION // WON ADD ְҵ + snprintf( token , sizeof(token), "%s|", SKILL_makeSkillStatusString(&hskill->skill, index, i) ); +#else + snprintf( token , sizeof(token), "%s|", SKILL_makeSkillStatusString(&hskill->skill) ); +#endif + }else{ + snprintf( token , sizeof(token), "%s|", SKILL_makeSkillFalseString() ); + } + + strcpysafe( CHAR_statusSendBuffer + strlength, sizeof(CHAR_statusSendBuffer)-strlength, token ); + + strlength += strlen( token ); + if( strlength >= arraysizeof(CHAR_statusSendBuffer) ) + return CHAR_statusSendBuffer; + } + + dchop( CHAR_statusSendBuffer , "|" ); + return CHAR_statusSendBuffer; + break; + } + case 't': + { + int i; + CHAR_statusSendBuffer[0] = 'T'; + strlength = 1; + for( i = 0 ; i < CHAR_TITLEMAXHAVE ; i ++ ){ + char token[256]; + char escape[256]; + snprintf( token , sizeof(token), "%s|" , + makeEscapeString( TITLE_makeTitleStatusString(index, + i ), + escape,sizeof(escape) ) ); + + strcpysafe( CHAR_statusSendBuffer + strlength, + sizeof(CHAR_statusSendBuffer) - strlength, + token ); + strlength += strlen( token ); + if( strlength >= arraysizeof(CHAR_statusSendBuffer) ) + return CHAR_statusSendBuffer; + } + dchop( CHAR_statusSendBuffer , "|" ); + return CHAR_statusSendBuffer; + break; + } + case 'd': + snprintf( CHAR_statusSendBuffer,sizeof(CHAR_statusSendBuffer), + "D%d|%ld",CHAR_getWorkInt(index,CHAR_WORKOBJINDEX), + NowTime.tv_sec ); + return CHAR_statusSendBuffer; + break; + case 'm': + snprintf( CHAR_statusSendBuffer,sizeof(CHAR_statusSendBuffer), + "M%d|%d|%d", + CHAR_getInt( index,CHAR_HP ), + CHAR_getInt( index,CHAR_MP ), + CHAR_getInt( index,CHAR_EXP ) ); + return CHAR_statusSendBuffer; + break; + case 'e': + return "\0"; + + case 'n': + { + int num; + + int i, nindex = -1; + int getCharDataArray[]= { + CHAR_NAME + }; + num = tolower( category[1] ) - '0'; + + if( num < 0 || num >= CHAR_PARTYMAX ){ + print( "ģʽʧ (%c)%d \n", num, num ); + break; + } + + nindex = CHAR_getPartyIndex( index, num); + + if( nindex == -1 ){ + snprintf(CHAR_statusSendBuffer,sizeof(CHAR_statusSendBuffer), + "N%d|0|", num ); + return CHAR_statusSendBuffer; + }else{ + snprintf(CHAR_statusSendBuffer,sizeof(CHAR_statusSendBuffer), + "N%d|1|%d|%d|%d|%d|%d|", + num, + CHAR_getWorkInt( nindex, CHAR_WORKOBJINDEX), + CHAR_getInt( nindex, CHAR_LV), + CHAR_getWorkInt( nindex, CHAR_WORKMAXHP), + CHAR_getInt( nindex, CHAR_HP), + CHAR_getInt( nindex, CHAR_MP) + + ); + } + strlength = strlen( CHAR_statusSendBuffer ); + + for( i = 0 ; i < arraysizeof( getCharDataArray ) ; i ++ ){ + char token[256]; + char escapebuffer[128]; + snprintf( token, + sizeof( token ), + "%s" STATUSSENDDELIMITER, + makeEscapeString( CHAR_getChar(nindex, + getCharDataArray[i]), + escapebuffer,sizeof(escapebuffer) + )); + strcpysafe( CHAR_statusSendBuffer + strlength, + sizeof( CHAR_statusSendBuffer ) - strlength, + token ); + strlength += strlen( token ); + if( strlength >= sizeof( CHAR_statusSendBuffer ) ) + return CHAR_statusSendBuffer; + } + + return CHAR_statusSendBuffer; + break; + } + case 'k': + { + int num; + int i, pindex; + int getCharDataArray[]= { + CHAR_NAME, + CHAR_USERPETNAME, + }; + num = tolower( category[1] ) - '0'; + if( num < 0 || num >= CHAR_MAXPETHAVE ){ + print( "ģʽʧ (%c)%d \n", num, num ); + break; + } + pindex = CHAR_getCharPet( index, num ); + if( pindex == -1 ){ + snprintf(CHAR_statusSendBuffer,sizeof(CHAR_statusSendBuffer), + "K%d|0|", num ); + return CHAR_statusSendBuffer; + }else{ + int attr[4]; + BOOL changenameflg = FALSE; + char *mycdkey; + char *cdkey = NULL; + for( i = 0; i < 4; i ++ ) { + attr[i] = CHAR_getWorkInt( pindex, CHAR_WORKFIXEARTHAT + i); + if( attr[i] < 0 ) attr[i] = 0; + } + mycdkey = CHAR_getChar( index, CHAR_CDKEY); + { + cdkey = CHAR_getChar( pindex, CHAR_CDKEY); + if( cdkey == "\0" ) { + print( "can't get CDKEY\n"); + }else { + + if( strlen( cdkey) == 0 || + strcmp( cdkey, mycdkey) == 0 ){ + changenameflg = TRUE; + } + } + } + + snprintf(CHAR_statusSendBuffer,sizeof(CHAR_statusSendBuffer), +// Syu ADD ı佻ʱתɫ +#ifdef _SHOW_FUSION + "K%d|1|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|", +#else + "K%d|1|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|", +#endif + num, + CHAR_getInt(pindex,CHAR_BASEIMAGENUMBER), + CHAR_getInt(pindex,CHAR_HP), + CHAR_getWorkInt(pindex,CHAR_WORKMAXHP), + CHAR_getInt(pindex,CHAR_MP), + CHAR_getWorkInt(pindex,CHAR_WORKMAXMP), + CHAR_getInt(pindex,CHAR_EXP ), + CHAR_GetLevelExp( pindex,CHAR_getInt( pindex, CHAR_LV ) + 1), + CHAR_getInt(pindex,CHAR_LV), + CHAR_getWorkInt(pindex, CHAR_WORKATTACKPOWER), + CHAR_getWorkInt(pindex, CHAR_WORKDEFENCEPOWER), + CHAR_getWorkInt( pindex, CHAR_WORKQUICK), + CHAR_getWorkInt( pindex, CHAR_WORKFIXAI), + attr[0], + attr[1], + attr[2], + attr[3], + CHAR_getInt( pindex, CHAR_SLOT), +// Syu ADD ı佻ʱתɫ + changenameflg, + CHAR_getInt( pindex,CHAR_TRANSMIGRATION) +#ifdef _SHOW_FUSION + ,CHAR_getInt ( pindex, CHAR_FUSIONBEIT) +#endif + ); + + } + strlength = strlen( CHAR_statusSendBuffer ); + for( i = 0 ; i < arraysizeof( getCharDataArray ) ; i ++ ){ + char token[256]; + char escapebuffer[128]; + snprintf( token, + sizeof( token ), + "%s" STATUSSENDDELIMITER, + makeEscapeString( CHAR_getChar(pindex, + getCharDataArray[i]), + escapebuffer,sizeof(escapebuffer) + )); + strcpysafe( CHAR_statusSendBuffer + strlength, + sizeof( CHAR_statusSendBuffer ) - strlength, + token ); + strlength += strlen( token ); + if( strlength >= sizeof( CHAR_statusSendBuffer ) ) + return CHAR_statusSendBuffer; + } + return CHAR_statusSendBuffer; + break; + } + + case 'j': +{ + + int num; + int i, itemindex; + int getMagicDataArray[]= { + MAGIC_NAME, + MAGIC_COMMENT, + }; + num = tolower( category[1] ) - '0'; + + if( num < 0 || num >= CHAR_EQUIPPLACENUM ){ + break; + } + + itemindex = CHAR_getItemIndex( index, num ); + if( !ITEM_CHECKINDEX( itemindex) ) { + snprintf(CHAR_statusSendBuffer,sizeof(CHAR_statusSendBuffer), + "J%d|0|", num ); + return CHAR_statusSendBuffer; + }else{ + int magicindex = MAGIC_getMagicArray( ITEM_getInt( itemindex, ITEM_MAGICID)); + if( magicindex == -1 ) { + snprintf(CHAR_statusSendBuffer,sizeof(CHAR_statusSendBuffer), + "J%d|0|", num ); + return CHAR_statusSendBuffer; + } + int magicmp = ITEM_getInt( itemindex, ITEM_MAGICUSEMP); + if(CHAR_getInt(index,CHAR_LV)<100 && CHAR_getInt(index,CHAR_TRANSMIGRATION)<1){ //CFָ0ת100֮ǰ + char magictmpbuf[32]; + sprintf(magictmpbuf,",%d,",ITEM_getInt( itemindex, ITEM_MAGICID)); + if(strstr(getNoMpMagic(),magictmpbuf)!=NULL){ + magicmp = 0; + } + } + snprintf(CHAR_statusSendBuffer,sizeof(CHAR_statusSendBuffer), + "J%d|1|%d|%d|%d|", + num, + magicmp, + MAGIC_getInt( magicindex, MAGIC_FIELD), + MAGIC_getInt( magicindex, MAGIC_TARGET)); + strlength = strlen( CHAR_statusSendBuffer ); + + for( i = 0 ; i < arraysizeof( getMagicDataArray ) ; i ++ ){ + char token[256]; + char escapebuffer[128]; + snprintf( token, + sizeof( token ), + "%s" STATUSSENDDELIMITER, + makeEscapeString( MAGIC_getChar(magicindex, + getMagicDataArray[i]), + escapebuffer,sizeof(escapebuffer) + )); + strcpysafe( CHAR_statusSendBuffer + strlength, + sizeof( CHAR_statusSendBuffer ) - strlength, + token ); + strlength += strlen( token ); + if( strlength >= sizeof( CHAR_statusSendBuffer ) ) + return CHAR_statusSendBuffer; + } + return CHAR_statusSendBuffer; + } + } + break; + + case 'w': +{ + int num; + int i,petskillloop, pindex; + char tmp[16]; + int getPetSkillDataArray[]= { + PETSKILL_NAME, + PETSKILL_COMMENT, + }; + + num = tolower( category[1] ) - '0'; + if( num < 0 || num >= CHAR_MAXPETHAVE ){ + print( "ؼʧ (%c)%d \n", num, num ); + break; + } + + pindex = CHAR_getCharPet( index, num ); + if( !CHAR_CHECKINDEX(pindex)){ + return "\0"; + } + snprintf( tmp, sizeof( tmp), "W%d|", num); + strcpysafe( CHAR_statusSendBuffer, sizeof( CHAR_statusSendBuffer), + tmp); + strlength += strlen( tmp); + if( strlength >= arraysizeof( CHAR_statusSendBuffer) ) { + return CHAR_statusSendBuffer; + } + for( petskillloop = 0; petskillloop < CHAR_MAXPETSKILLHAVE; petskillloop ++ ) { + int skillid = CHAR_getPetSkill( pindex, petskillloop); + int petskillindex = PETSKILL_getPetskillArray( skillid ); + if( PETSKILL_CHECKINDEX( petskillindex) ) { + char token[256]; + snprintf( token, sizeof( token), + "%d|%d|%d|", + + PETSKILL_getInt( petskillindex, PETSKILL_ID), + PETSKILL_getInt( petskillindex, PETSKILL_FIELD), + PETSKILL_getInt( petskillindex, PETSKILL_TARGET) + ); + strcpysafe( CHAR_statusSendBuffer + strlength, + sizeof(CHAR_statusSendBuffer) - strlength, + token ); + strlength += strlen( token ); + if( strlength >= arraysizeof(CHAR_statusSendBuffer)) { + return CHAR_statusSendBuffer; + } + + for( i = 0 ; i < arraysizeof( getPetSkillDataArray ) ; i ++ ){ + char escapebuffer[128]; + snprintf( token, + sizeof( token ), + "%s" STATUSSENDDELIMITER, + makeEscapeString( + PETSKILL_getChar(petskillindex, + getPetSkillDataArray[i]), + escapebuffer,sizeof(escapebuffer) + )); + strcpysafe( CHAR_statusSendBuffer + strlength, + sizeof( CHAR_statusSendBuffer ) - strlength, + token ); + strlength += strlen( token ); + if( strlength >= sizeof( CHAR_statusSendBuffer )) { + return CHAR_statusSendBuffer; + } + } + } + else { + char token[256]; + snprintf( token, sizeof( token),"|||||"); + strcpysafe( CHAR_statusSendBuffer + strlength, + sizeof(CHAR_statusSendBuffer) - strlength, + token ); + strlength += strlen( token ); + if( strlength >= arraysizeof(CHAR_statusSendBuffer) ) { + return CHAR_statusSendBuffer; + } + } + } + return CHAR_statusSendBuffer; +} + +#ifdef _PROFESSION_SKILL // WON ADD ְҵ + case 'y': +{ + int num = 0, f_num = 0; + int i,petskillloop, pindex; + char tmp[16]; + int getPetSkillDataArray[]= { + PETSKILL_NAME, + PETSKILL_COMMENT, + }; + + num = tolower( category[1] ) - '0'; + if( num < 0 || num >= CHAR_MAXPETHAVE ){ + print( "ؼʧ (%c)%d \n", num, num ); + break; + } + + pindex = CHAR_getCharPet( index, num ); + if( !CHAR_CHECKINDEX(pindex)){ + return "\0"; + } + snprintf( tmp, sizeof( tmp), "W%d|", num); + strcpysafe( CHAR_statusSendBuffer, sizeof( CHAR_statusSendBuffer), + tmp); + strlength += strlen( tmp); + if( strlength >= arraysizeof( CHAR_statusSendBuffer) ) { + return CHAR_statusSendBuffer; + } + + if( CHAR_getWorkInt( pindex, CHAR_WORKOBLIVION) > 0 ) + f_num = CHAR_getWorkInt( pindex, CHAR_WORKMODOBLIVION ) + 1;// 輼 + + for( petskillloop = 0; petskillloop < CHAR_MAXPETSKILLHAVE; petskillloop ++ ) { + int skillid = CHAR_getPetSkill( pindex, petskillloop); + int petskillindex = PETSKILL_getPetskillArray( skillid ); + if( PETSKILL_CHECKINDEX( petskillindex) ) { + char token[256]; + int field = -1, target = -1; + int oblivion = CHAR_getWorkInt( pindex, CHAR_WORKOBLIVION ); + int p_id = PETSKILL_getInt( petskillindex, PETSKILL_ID); + int rand_num = RAND( 0, 100 ); + + // + if( (oblivion > 0) && ( f_num > 0 ) && ( rand_num <= 60 ) && ( p_id != 1 ) ){ + field = PETSKILL_FIELD_MAP; + target = PETSKILL_TARGET_NONE; + f_num --; + }else{ + field = PETSKILL_getInt( petskillindex, PETSKILL_FIELD); + target = PETSKILL_getInt( petskillindex, PETSKILL_TARGET); + } + + snprintf( token, sizeof( token),"%d|%d|%d|", +// PETSKILL_getInt( petskillindex, PETSKILL_ID), + p_id, + field, target + ); + strcpysafe( CHAR_statusSendBuffer + strlength, + sizeof(CHAR_statusSendBuffer) - strlength, + token ); + strlength += strlen( token ); + if( strlength >= arraysizeof(CHAR_statusSendBuffer)) { + return CHAR_statusSendBuffer; + } + + for( i = 0 ; i < arraysizeof( getPetSkillDataArray ) ; i ++ ){ + char escapebuffer[128]; + snprintf( token, + sizeof( token ), + "%s" STATUSSENDDELIMITER, + makeEscapeString( + PETSKILL_getChar(petskillindex, + getPetSkillDataArray[i]), + escapebuffer,sizeof(escapebuffer) + )); + strcpysafe( CHAR_statusSendBuffer + strlength, + sizeof( CHAR_statusSendBuffer ) - strlength, + token ); + strlength += strlen( token ); + if( strlength >= sizeof( CHAR_statusSendBuffer )) { + return CHAR_statusSendBuffer; + } + } + } + else { + char token[256]; + snprintf( token, sizeof( token),"|||||"); + strcpysafe( CHAR_statusSendBuffer + strlength, + sizeof(CHAR_statusSendBuffer) - strlength, + token ); + strlength += strlen( token ); + if( strlength >= arraysizeof(CHAR_statusSendBuffer) ) { + return CHAR_statusSendBuffer; + } + } + } + return CHAR_statusSendBuffer; +} +#endif + +#ifdef _PETSKILL_DAMAGETOHP +//սзͼܷ + case 'o': +{ + int getPetSkillDataArray[]= { + PETSKILL_NAME, + PETSKILL_COMMENT, + }; + int i,petskillloop, pindex=index; + int num = 0;//, f_num = 0; + char tmp[16]; + + num = tolower( category[1] ) - '0'; + if( num < 0 || num >= CHAR_MAXPETHAVE ){ + print( "ؼʧ (%c)%d \n", num, num ); + break; + } + + pindex = CHAR_getCharPet( index, num ); + if( !CHAR_CHECKINDEX(pindex)){ + return "\0"; + } +#ifdef _WAN_FIX + if(CHAR_getWorkInt(index,CHAR_WORKBATTLEINDEX)>-1){ + return "\0"; + } +#endif + snprintf( tmp, sizeof( tmp), "W%d|", num); + strcpysafe( CHAR_statusSendBuffer, sizeof( CHAR_statusSendBuffer), + tmp); + strlength += strlen( tmp); + if( strlength >= arraysizeof( CHAR_statusSendBuffer) ) { + return CHAR_statusSendBuffer; + } + + for( petskillloop = 0; petskillloop < CHAR_MAXPETSKILLHAVE; petskillloop ++ ) { + int skillid = CHAR_getPetSkill( pindex, petskillloop); + int petskillindex = PETSKILL_getPetskillArray( skillid ); + if( PETSKILL_CHECKINDEX( petskillindex) ) { + char token[256]; + int field = -1, target = -1; + //int oblivion = CHAR_getWorkInt( pindex, CHAR_WORKOBLIVION ); + int p_id = PETSKILL_getInt( petskillindex, PETSKILL_ID); + + //50%ҼΪ ԡѪϮ ܲѡ + if( ( CHAR_getInt( pindex, CHAR_HP ) > CHAR_getWorkInt( pindex, CHAR_WORKMAXHP )*0.5 + && strcmp(PETSKILL_getChar( petskillindex, PETSKILL_NAME),"ԡѪϮ" ) == 0 ) + ){ + field = PETSKILL_FIELD_MAP; + target = PETSKILL_TARGET_NONE; + }else{ + field = PETSKILL_getInt( petskillindex, PETSKILL_FIELD); + target = PETSKILL_getInt( petskillindex, PETSKILL_TARGET); + } + + snprintf( token, sizeof( token),"%d|%d|%d|", +// PETSKILL_getInt( petskillindex, PETSKILL_ID), + p_id, + field, target + ); + strcpysafe( CHAR_statusSendBuffer + strlength, + sizeof(CHAR_statusSendBuffer) - strlength, + token ); + strlength += strlen( token ); + if( strlength >= arraysizeof(CHAR_statusSendBuffer)) { + return CHAR_statusSendBuffer; + } + + for( i = 0 ; i < arraysizeof( getPetSkillDataArray ) ; i ++ ){ + char escapebuffer[128]; + snprintf( token, + sizeof( token ), + "%s" STATUSSENDDELIMITER, + makeEscapeString( + PETSKILL_getChar(petskillindex, + getPetSkillDataArray[i]), + escapebuffer,sizeof(escapebuffer) + )); + strcpysafe( CHAR_statusSendBuffer + strlength, + sizeof( CHAR_statusSendBuffer ) - strlength, + token ); + strlength += strlen( token ); + if( strlength >= sizeof( CHAR_statusSendBuffer )) { + return CHAR_statusSendBuffer; + } + } + } + else { + char token[256]; + snprintf( token, sizeof( token),"|||||"); + strcpysafe( CHAR_statusSendBuffer + strlength, + sizeof(CHAR_statusSendBuffer) - strlength, + token ); + strlength += strlen( token ); + if( strlength >= arraysizeof(CHAR_statusSendBuffer) ) { + return CHAR_statusSendBuffer; + } + } + } + return CHAR_statusSendBuffer; +} +#endif + +#ifdef _PETSKILL_BECOMEFOX + case 'a': +{ + int getPetSkillDataArray[]= { + PETSKILL_NAME, + PETSKILL_COMMENT, + }; + int i,petskillloop, pindex=index; + int num = 0;//, f_num = 0; + char tmp[16]; + + num = tolower( category[1] ) - '0'; + if( num < 0 || num >= CHAR_MAXPETHAVE ){ + print( "ؼʧ (%c)%d \n", num, num ); + break; + } + print( "ؼ" ); + pindex = CHAR_getCharPet( index, num ); + if( !CHAR_CHECKINDEX(pindex)){ + return "\0"; + } + snprintf( tmp, sizeof( tmp), "W%d|", num); + strcpysafe( CHAR_statusSendBuffer, sizeof( CHAR_statusSendBuffer), + tmp); + strlength += strlen( tmp); + if( strlength >= arraysizeof( CHAR_statusSendBuffer) ) { + return CHAR_statusSendBuffer; + } + + for( petskillloop = 0; petskillloop < CHAR_MAXPETSKILLHAVE; petskillloop ++ ) { + int skillid = CHAR_getPetSkill( pindex, petskillloop); + int petskillindex = PETSKILL_getPetskillArray( skillid ); + if( PETSKILL_CHECKINDEX( petskillindex) ) { + char token[256]; + int field = -1, target = -1; + //int oblivion = CHAR_getWorkInt( pindex, CHAR_WORKOBLIVION ); + int p_id = PETSKILL_getInt( petskillindex, PETSKILL_ID); + + //Ϊ ܲѡ + print("\n:%s",PETSKILL_getChar( petskillindex, PETSKILL_NAME)); + if( strcmp(PETSKILL_getChar( petskillindex, PETSKILL_NAME),"" ) == 0 + || strcmp(PETSKILL_getChar( petskillindex, PETSKILL_NAME),"" ) == 0 + || strcmp(PETSKILL_getChar( petskillindex, PETSKILL_NAME),"" ) == 0){ + field = PETSKILL_getInt( petskillindex, PETSKILL_FIELD); + target = PETSKILL_getInt( petskillindex, PETSKILL_TARGET); + }else{ + field = PETSKILL_FIELD_MAP; + target = PETSKILL_TARGET_NONE; + } + + snprintf( token, sizeof( token),"%d|%d|%d|", +// PETSKILL_getInt( petskillindex, PETSKILL_ID), + p_id, + field, target + ); + strcpysafe( CHAR_statusSendBuffer + strlength, + sizeof(CHAR_statusSendBuffer) - strlength, + token ); + strlength += strlen( token ); + if( strlength >= arraysizeof(CHAR_statusSendBuffer)) { + return CHAR_statusSendBuffer; + } + + for( i = 0 ; i < arraysizeof( getPetSkillDataArray ) ; i ++ ){ + char escapebuffer[128]; + snprintf( token, + sizeof( token ), + "%s" STATUSSENDDELIMITER, + makeEscapeString( + PETSKILL_getChar(petskillindex, + getPetSkillDataArray[i]), + escapebuffer,sizeof(escapebuffer) + )); + strcpysafe( CHAR_statusSendBuffer + strlength, + sizeof( CHAR_statusSendBuffer ) - strlength, + token ); + strlength += strlen( token ); + if( strlength >= sizeof( CHAR_statusSendBuffer )) { + return CHAR_statusSendBuffer; + } + } + } + else { + char token[256]; + snprintf( token, sizeof( token),"|||||"); + strcpysafe( CHAR_statusSendBuffer + strlength, + sizeof(CHAR_statusSendBuffer) - strlength, + token ); + strlength += strlen( token ); + if( strlength >= arraysizeof(CHAR_statusSendBuffer) ) { + return CHAR_statusSendBuffer; + } + } + } + return CHAR_statusSendBuffer; +} +#endif + + default: + break; + } + + CHAR_statusSendBuffer[0] = '\0'; + return CHAR_statusSendBuffer; +} + +//BOOL CHAR_sendStatusString( int charaindex, char* category ) +BOOL _CHAR_sendStatusString( int charaindex, char* category, char* file, int line ) +{ + char* string; + + //print("\nsend_S:%s:%d ", file, line); + + if( CHAR_getInt(charaindex,CHAR_WHICHTYPE) != CHAR_TYPEPLAYER ){ + return FALSE; + } + string = CHAR_makeStatusString( charaindex, category ); + + if( string != "\0" ){ + int fd; + fd = getfdFromCharaIndex( charaindex ); + if( fd != -1 ){ + lssproto_S_send( fd, string ); + return TRUE; + } + } + return FALSE; +} + +void CHAR_inputOwnTitle( int index ,char* name ) +{ + if( !CHAR_CHECKINDEX( index ) ) return; + + if( CHAR_getFlg( index,CHAR_ISDIE ) )return; + + CHAR_setChar( index, CHAR_OWNTITLE ,name); + + CHAR_sendCToArroundCharacter( CHAR_getWorkInt( index, CHAR_WORKOBJINDEX) ); + + CHAR_send_P_StatusString( index, CHAR_P_STRING_OWNTITLE ); +} + + +void CHAR_selectTitle( int index, int titleindex ) +{ + if( !CHAR_CHECKINDEX( index ) )return; + + if( CHAR_getFlg( index,CHAR_ISDIE ) )return; + + if( titleindex == -1 ){ + CHAR_setInt( index, CHAR_INDEXOFEQTITLE, titleindex); + }else if( titleindex < 0 || titleindex >= CHAR_TITLEMAXHAVE ) { + return; + } + else{ + + int title = CHAR_getCharHaveTitle( index,titleindex ); + + if( TITLE_getTitleIndex( title) != -1 ){ + CHAR_setInt( index, CHAR_INDEXOFEQTITLE, titleindex); + } + } + + CHAR_sendStatusString( index, "T" ); + CHAR_send_P_StatusString( index, CHAR_P_STRING_TITLE ); +} + + +void CHAR_deleteTitle( int index, int titleindex ) +{ + int title; + + if( !CHAR_CHECKINDEX( index ) )return; + /* ƥݷֻ */ + if( CHAR_getFlg( index,CHAR_ISDIE ) )return; + + if( titleindex < 0 || titleindex >= CHAR_TITLEMAXHAVE )return; + title = CHAR_getCharHaveTitle( index,titleindex ); + /*if( TITLE_CHECKTABLEINDEX( title ) == FALSE )*/ + if( TITLE_getTitleIndex( title) == -1 ) { + return; + } + CHAR_setCharHaveTitle( index,titleindex,-1 ); + + /* лȻ֧ئɣľئƱ */ + if( CHAR_getInt(index, CHAR_INDEXOFEQTITLE) == titleindex ) + CHAR_setInt(index, CHAR_INDEXOFEQTITLE, -1 ); + + /* + * ë˪£ + */ + CHAR_sendStatusString( index, "T" ); + CHAR_send_P_StatusString( index, CHAR_P_STRING_TITLE ); +} + +static void CHAR_initcharWorkInt( index ) +{ + float hp; + static struct substitutionTable{ + CHAR_WORKDATAINT workindex; + CHAR_DATAINT intindex; + }subtbl[]={ + { CHAR_WORKMAXMP, CHAR_MAXMP }, + { CHAR_WORKFIXFIREAT, CHAR_FIREAT }, + { CHAR_WORKFIXWATERAT, CHAR_WATERAT}, + { CHAR_WORKFIXEARTHAT, CHAR_EARTHAT}, + { CHAR_WORKFIXWINDAT, CHAR_WINDAT }, + { CHAR_WORKFIXCHARM, CHAR_CHARM }, + { CHAR_WORKFIXLUCK, CHAR_LUCK }, + { CHAR_WORKFIXLUCK, CHAR_LUCK }, + { CHAR_WORKMODPOISON, CHAR_POISON }, + { CHAR_WORKMODPARALYSIS,CHAR_PARALYSIS }, + { CHAR_WORKMODSLEEP, CHAR_SLEEP }, + { CHAR_WORKMODSTONE, CHAR_STONE }, + { CHAR_WORKMODDRUNK, CHAR_DRUNK }, + { CHAR_WORKMODCONFUSION, CHAR_CONFUSION } + }; + + int i; + for( i=0 ; i 0 ){ + CHAR_setWorkInt( index, CHAR_WORKFIXEARTHAT + (i + 2) % 4, attr * -1); + } + } + +#ifdef _MAGIC_RESIST_EQUIT // WON ADD ְҵװ + { + // 翹 + //for( i=0; i<3; i++) + // CHAR_setWorkInt( index, CHAR_WORK_F_RESIST+i, CHAR_getInt( index, PROFESSION_FIRE_R+i ) ); + } +#endif + + + CHAR_setWorkInt( index, CHAR_WORKFIXDEX, + CHAR_getInt( index, CHAR_DEX) * 0.01 ); + CHAR_setWorkInt( index, CHAR_WORKFIXVITAL, + CHAR_getInt( index, CHAR_VITAL) * 0.01 ); + + CHAR_setWorkInt( index, CHAR_WORKFIXSTR, + CHAR_getInt( index, CHAR_STR) * 0.01 * 1.0 +//#ifdef _BATTLE_NEWPOWER +// + CHAR_getInt( index, CHAR_DEX) * 0.01 * 0.05 +// + CHAR_getInt( index, CHAR_VITAL) * 0.01 * 0.05 ); // +//#else + + CHAR_getInt( index, CHAR_TOUGH) * 0.01 * 0.1 + + CHAR_getInt( index, CHAR_VITAL) * 0.01 * 0.1 + + CHAR_getInt( index, CHAR_DEX) * 0.01 * 0.05 ); +//#endif + CHAR_setWorkInt( index, CHAR_WORKFIXTOUGH, + CHAR_getInt( index, CHAR_TOUGH) * 0.01 * 1.0 +//#ifdef _BATTLE_NEWPOWER +// + CHAR_getInt( index, CHAR_DEX) * 0.01 * 0.05 +// + CHAR_getInt( index, CHAR_VITAL) * 0.01 * 0.05 ); // +//#else + + CHAR_getInt(index,CHAR_STR) * 0.01 * 0.1 + + CHAR_getInt(index,CHAR_VITAL) * 0.01 * 0.1 + + CHAR_getInt(index,CHAR_DEX) * 0.01 * 0.05 ); +//#endif + +#ifdef _ITEMSET5_TXT + { + CHAR_setWorkInt( index, CHAR_WORKFIXARRANGE, 0); + CHAR_setWorkInt( index, CHAR_WORKFIXSEQUENCE, 0); + CHAR_setWorkInt( index, CHAR_WORKATTACHPILE, 0); + CHAR_setWorkInt( index, CHAR_WORKHITRIGHT, 0); + } +#endif + + + +#ifdef _ITEMSET6_TXT + { + CHAR_setWorkInt( index, CHAR_WORKNEGLECTGUARD, 0); + } +#endif + + + hp = ( CHAR_getInt(index,CHAR_VITAL) * 4 + + CHAR_getInt(index,CHAR_STR) * 1 + + CHAR_getInt(index,CHAR_TOUGH) * 1 + + CHAR_getInt(index,CHAR_DEX) * 1 ) * 0.01; + + CHAR_setWorkInt( index, CHAR_WORKMAXHP, (int)hp ); + CHAR_setWorkInt( index, CHAR_WORKMAXMP, CHAR_getInt( index, CHAR_MAXMP)); + + int fmfloor = CHAR_getWorkInt( index, CHAR_WORKFMFLOOR); +#ifdef _FM_WELFARE + if( fmfloor !=-1 && CHAR_getInt( index, CHAR_FMLEADERFLAG ) != FMMEMBER_NONE + && CHAR_getInt( index, CHAR_FMLEADERFLAG ) != FMMEMBER_APPLY && CHAR_getInt( index, CHAR_WHICHTYPE) == CHAR_TYPEPLAYER){ + char* fmbuf=NULL; + char* pszP=NULL; + int fPer; + switch(fmfloor){ + case 1041: + fmbuf = getFmWelfare(0); + if( (pszP = strstr( fmbuf, "" ) ) != NULL ){ + sscanf( pszP+2, "%d", &fPer ); + //趨ֵ + CHAR_setWorkInt(index,CHAR_WORKFIXSTR,CHAR_getWorkInt(index,CHAR_WORKFIXSTR)+fPer); + break; + } + if( (pszP = strstr( fmbuf, "" ) ) != NULL ){ + sscanf( pszP+2, "%d", &fPer ); + + //趨ֵ + CHAR_setWorkInt(index,CHAR_WORKFIXTOUGH,CHAR_getWorkInt(index,CHAR_WORKFIXTOUGH)+fPer); + break; + } + if( (pszP = strstr( fmbuf, "" ) ) != NULL ){ + sscanf( pszP+2, "%d", &fPer ); + + //趨ֵ + CHAR_setWorkInt(index,CHAR_WORKFIXDEX,CHAR_getWorkInt(index,CHAR_WORKFIXDEX)+fPer); + break; + } + if( (pszP = strstr( fmbuf, "" ) ) != NULL ){ + sscanf( pszP+2, "%d", &fPer ); + + //趨ֵ + CHAR_setWorkInt(index,CHAR_WORKMAXHP,CHAR_getWorkInt(index,CHAR_WORKMAXHP)+fPer); + break; + } + break; + case 2031: + fmbuf = getFmWelfare(1); + if( (pszP = strstr( fmbuf, "" ) ) != NULL ){ + sscanf( pszP+2, "%d", &fPer ); + + //趨ֵ + CHAR_setWorkInt(index,CHAR_WORKFIXSTR,CHAR_getWorkInt(index,CHAR_WORKFIXSTR)+fPer); + break; + } + if( (pszP = strstr( fmbuf, "" ) ) != NULL ){ + sscanf( pszP+2, "%d", &fPer ); + + //趨ֵ + CHAR_setWorkInt(index,CHAR_WORKFIXTOUGH,CHAR_getWorkInt(index,CHAR_WORKFIXTOUGH)+fPer); + break; + } + if( (pszP = strstr( fmbuf, "" ) ) != NULL ){ + sscanf( pszP+2, "%d", &fPer ); + + //趨ֵ + CHAR_setWorkInt(index,CHAR_WORKFIXDEX,CHAR_getWorkInt(index,CHAR_WORKFIXDEX)+fPer); + break; + } + if( (pszP = strstr( fmbuf, "" ) ) != NULL ){ + sscanf( pszP+2, "%d", &fPer ); + + //趨ֵ + CHAR_setWorkInt(index,CHAR_WORKMAXHP,CHAR_getWorkInt(index,CHAR_WORKMAXHP)+fPer); + break; + } + break; + case 3031: + fmbuf = getFmWelfare(2); + if( (pszP = strstr( fmbuf, "" ) ) != NULL ){ + sscanf( pszP+2, "%d", &fPer ); + + //趨ֵ + CHAR_setWorkInt(index,CHAR_WORKFIXSTR,CHAR_getWorkInt(index,CHAR_WORKFIXSTR)+fPer); + break; + } + if( (pszP = strstr( fmbuf, "" ) ) != NULL ){ + sscanf( pszP+2, "%d", &fPer ); + + //趨ֵ + CHAR_setWorkInt(index,CHAR_WORKFIXTOUGH,CHAR_getWorkInt(index,CHAR_WORKFIXTOUGH)+fPer); + break; + } + if( (pszP = strstr( fmbuf, "" ) ) != NULL ){ + sscanf( pszP+2, "%d", &fPer ); + + //趨ֵ + CHAR_setWorkInt(index,CHAR_WORKFIXDEX,CHAR_getWorkInt(index,CHAR_WORKFIXDEX)+fPer); + break; + } + if( (pszP = strstr( fmbuf, "" ) ) != NULL ){ + sscanf( pszP+2, "%d", &fPer ); + + //趨ֵ + CHAR_setWorkInt(index,CHAR_WORKMAXHP,CHAR_getWorkInt(index,CHAR_WORKMAXHP)+fPer); + break; + } + break; + case 4031: + fmbuf = getFmWelfare(3); + if( (pszP = strstr( fmbuf, "" ) ) != NULL ){ + sscanf( pszP+2, "%d", &fPer ); + + //趨ֵ + CHAR_setWorkInt(index,CHAR_WORKFIXSTR,CHAR_getWorkInt(index,CHAR_WORKFIXSTR)+fPer); + break; + } + if( (pszP = strstr( fmbuf, "" ) ) != NULL ){ + sscanf( pszP+2, "%d", &fPer ); + + //趨ֵ + CHAR_setWorkInt(index,CHAR_WORKFIXTOUGH,CHAR_getWorkInt(index,CHAR_WORKFIXTOUGH)+fPer); + break; + } + if( (pszP = strstr( fmbuf, "" ) ) != NULL ){ + sscanf( pszP+2, "%d", &fPer ); + + //趨ֵ + CHAR_setWorkInt(index,CHAR_WORKFIXDEX,CHAR_getWorkInt(index,CHAR_WORKFIXDEX)+fPer); + break; + } + if( (pszP = strstr( fmbuf, "" ) ) != NULL ){ + sscanf( pszP+2, "%d", &fPer ); + + //趨ֵ + CHAR_setWorkInt(index,CHAR_WORKMAXHP,CHAR_getWorkInt(index,CHAR_WORKMAXHP)+fPer); + break; + } + break; + case 5031: + fmbuf = getFmWelfare(4); + if( (pszP = strstr( fmbuf, "" ) ) != NULL ){ + sscanf( pszP+2, "%d", &fPer ); + + //趨ֵ + CHAR_setWorkInt(index,CHAR_WORKFIXSTR,CHAR_getWorkInt(index,CHAR_WORKFIXSTR)+fPer); + break; + } + if( (pszP = strstr( fmbuf, "" ) ) != NULL ){ + sscanf( pszP+2, "%d", &fPer ); + + //趨ֵ + CHAR_setWorkInt(index,CHAR_WORKFIXTOUGH,CHAR_getWorkInt(index,CHAR_WORKFIXTOUGH)+fPer); + break; + } + if( (pszP = strstr( fmbuf, "" ) ) != NULL ){ + sscanf( pszP+2, "%d", &fPer ); + + //趨ֵ + CHAR_setWorkInt(index,CHAR_WORKFIXDEX,CHAR_getWorkInt(index,CHAR_WORKFIXDEX)+fPer); + break; + } + if( (pszP = strstr( fmbuf, "" ) ) != NULL ){ + sscanf( pszP+2, "%d", &fPer ); + + //趨ֵ + CHAR_setWorkInt(index,CHAR_WORKMAXHP,CHAR_getWorkInt(index,CHAR_WORKMAXHP)+fPer); + break; + } + break; + case 6031: + fmbuf = getFmWelfare(5); + if( (pszP = strstr( fmbuf, "" ) ) != NULL ){ + sscanf( pszP+2, "%d", &fPer ); + + //趨ֵ + CHAR_setWorkInt(index,CHAR_WORKFIXSTR,CHAR_getWorkInt(index,CHAR_WORKFIXSTR)+fPer); + break; + } + if( (pszP = strstr( fmbuf, "" ) ) != NULL ){ + sscanf( pszP+2, "%d", &fPer ); + + //趨ֵ + CHAR_setWorkInt(index,CHAR_WORKFIXTOUGH,CHAR_getWorkInt(index,CHAR_WORKFIXTOUGH)+fPer); + break; + } + if( (pszP = strstr( fmbuf, "" ) ) != NULL ){ + sscanf( pszP+2, "%d", &fPer ); + + //趨ֵ + CHAR_setWorkInt(index,CHAR_WORKFIXDEX,CHAR_getWorkInt(index,CHAR_WORKFIXDEX)+fPer); + break; + } + if( (pszP = strstr( fmbuf, "" ) ) != NULL ){ + sscanf( pszP+2, "%d", &fPer ); + + //趨ֵ + CHAR_setWorkInt(index,CHAR_WORKMAXHP,CHAR_getWorkInt(index,CHAR_WORKMAXHP)+fPer); + break; + } + break; + case 7031: + fmbuf = getFmWelfare(6); + if( (pszP = strstr( fmbuf, "" ) ) != NULL ){ + sscanf( pszP+2, "%d", &fPer ); + + //趨ֵ + CHAR_setWorkInt(index,CHAR_WORKFIXSTR,CHAR_getWorkInt(index,CHAR_WORKFIXSTR)+fPer); + break; + } + if( (pszP = strstr( fmbuf, "" ) ) != NULL ){ + sscanf( pszP+2, "%d", &fPer ); + + //趨ֵ + CHAR_setWorkInt(index,CHAR_WORKFIXTOUGH,CHAR_getWorkInt(index,CHAR_WORKFIXTOUGH)+fPer); + break; + } + if( (pszP = strstr( fmbuf, "" ) ) != NULL ){ + sscanf( pszP+2, "%d", &fPer ); + + //趨ֵ + CHAR_setWorkInt(index,CHAR_WORKFIXDEX,CHAR_getWorkInt(index,CHAR_WORKFIXDEX)+fPer); + break; + } + if( (pszP = strstr( fmbuf, "" ) ) != NULL ){ + sscanf( pszP+2, "%d", &fPer ); + + //趨ֵ + CHAR_setWorkInt(index,CHAR_WORKMAXHP,CHAR_getWorkInt(index,CHAR_WORKMAXHP)+fPer); + break; + } + break; + case 8031: + fmbuf = getFmWelfare(7); + if( (pszP = strstr( fmbuf, "" ) ) != NULL ){ + sscanf( pszP+2, "%d", &fPer ); + + //趨ֵ + CHAR_setWorkInt(index,CHAR_WORKFIXSTR,CHAR_getWorkInt(index,CHAR_WORKFIXSTR)+fPer); + break; + } + if( (pszP = strstr( fmbuf, "" ) ) != NULL ){ + sscanf( pszP+2, "%d", &fPer ); + + //趨ֵ + CHAR_setWorkInt(index,CHAR_WORKFIXTOUGH,CHAR_getWorkInt(index,CHAR_WORKFIXTOUGH)+fPer); + break; + } + if( (pszP = strstr( fmbuf, "" ) ) != NULL ){ + sscanf( pszP+2, "%d", &fPer ); + + //趨ֵ + CHAR_setWorkInt(index,CHAR_WORKFIXDEX,CHAR_getWorkInt(index,CHAR_WORKFIXDEX)+fPer); + break; + } + if( (pszP = strstr( fmbuf, "" ) ) != NULL ){ + sscanf( pszP+2, "%d", &fPer ); + + //趨ֵ + CHAR_setWorkInt(index,CHAR_WORKMAXHP,CHAR_getWorkInt(index,CHAR_WORKMAXHP)+fPer); + break; + } + break; + case 9031: + fmbuf = getFmWelfare(8); + if( (pszP = strstr( fmbuf, "" ) ) != NULL ){ + sscanf( pszP+2, "%d", &fPer ); + + //趨ֵ + CHAR_setWorkInt(index,CHAR_WORKFIXSTR,CHAR_getWorkInt(index,CHAR_WORKFIXSTR)+fPer); + break; + } + if( (pszP = strstr( fmbuf, "" ) ) != NULL ){ + sscanf( pszP+2, "%d", &fPer ); + + //趨ֵ + CHAR_setWorkInt(index,CHAR_WORKFIXTOUGH,CHAR_getWorkInt(index,CHAR_WORKFIXTOUGH)+fPer); + break; + } + if( (pszP = strstr( fmbuf, "" ) ) != NULL ){ + sscanf( pszP+2, "%d", &fPer ); + + //趨ֵ + CHAR_setWorkInt(index,CHAR_WORKFIXDEX,CHAR_getWorkInt(index,CHAR_WORKFIXDEX)+fPer); + break; + } + if( (pszP = strstr( fmbuf, "" ) ) != NULL ){ + sscanf( pszP+2, "%d", &fPer ); + + //趨ֵ + CHAR_setWorkInt(index,CHAR_WORKMAXHP,CHAR_getWorkInt(index,CHAR_WORKMAXHP)+fPer); + break; + } + break; + case 10031: + fmbuf = getFmWelfare(9); + if( (pszP = strstr( fmbuf, "" ) ) != NULL ){ + sscanf( pszP+2, "%d", &fPer ); + + //趨ֵ + CHAR_setWorkInt(index,CHAR_WORKFIXSTR,CHAR_getWorkInt(index,CHAR_WORKFIXSTR)+fPer); + break; + } + if( (pszP = strstr( fmbuf, "" ) ) != NULL ){ + sscanf( pszP+2, "%d", &fPer ); + + //趨ֵ + CHAR_setWorkInt(index,CHAR_WORKFIXTOUGH,CHAR_getWorkInt(index,CHAR_WORKFIXTOUGH)+fPer); + break; + } + if( (pszP = strstr( fmbuf, "" ) ) != NULL ){ + sscanf( pszP+2, "%d", &fPer ); + + //趨ֵ + CHAR_setWorkInt(index,CHAR_WORKFIXDEX,CHAR_getWorkInt(index,CHAR_WORKFIXDEX)+fPer); + break; + } + if( (pszP = strstr( fmbuf, "" ) ) != NULL ){ + sscanf( pszP+2, "%d", &fPer ); + + //趨ֵ + CHAR_setWorkInt(index,CHAR_WORKMAXHP,CHAR_getWorkInt(index,CHAR_WORKMAXHP)+fPer); + break; + } + break; + default: + break; + } + } +#endif +#ifdef _FMZUZHANG_MSG + if(fmfloor>0 && CHAR_getInt(index, CHAR_FMLEADERFLAG) == FMMEMBER_LEADER && CHAR_getWorkInt( index, CHAR_WORKLOGININTYPE) == 0){ + char floorbuf[10]; + sprintf(floorbuf,"%d",fmfloor); + if(strstr(getFmZuzhang(),floorbuf)){ + char zuzhangmsg[256]; + int i,playernum; + playernum = CHAR_getPlayerMaxNum(); + sprintf(zuzhangmsg,"%sׯ%sҿȥΧۣ",MAP_getFloorName(fmfloor-1),CHAR_getChar(index,CHAR_NAME)); + CHAR_setWorkInt( index, CHAR_WORKLOGININTYPE,1); + for( i = 0 ; i < playernum ; i++) + { + CHAR_talkToCli( i, -1, zuzhangmsg, CHAR_COLORRED); + } + } + } +#endif + + CHAR_setWorkInt( index, CHAR_WORKATTACKPOWER, + CHAR_getWorkInt(index,CHAR_WORKFIXSTR) ); + CHAR_setWorkInt( index, CHAR_WORKDEFENCEPOWER, + CHAR_getWorkInt(index,CHAR_WORKFIXTOUGH) ); + CHAR_setWorkInt( index, CHAR_WORKQUICK, + CHAR_getWorkInt( index, CHAR_WORKFIXDEX)); +#ifdef _ADD_DEAMGEDEFC + CHAR_setWorkInt( index, CHAR_WORKOTHERDMAGE, 0); + CHAR_setWorkInt( index, CHAR_WORKOTHERDEFC, 0); +#endif + + if( CHAR_getInt( index, CHAR_WHICHTYPE) == CHAR_TYPEPET) { + int hostindex; + CHAR_setWorkInt( index, CHAR_WORKFIXAI, 0); + hostindex = CHAR_getWorkInt( index, CHAR_WORKPLAYERINDEX); + if( CHAR_CHECKINDEX( hostindex)) { + int ai; + int modai = CHAR_getInt( index, CHAR_MODAI); + double R; + if( modai <= 0 ) modai = 100; + R = 1.10; + ai = ( (CHAR_getInt( hostindex, CHAR_LV) + * CHAR_getWorkInt( hostindex, CHAR_WORKFIXCHARM ) + * R) + / + (CHAR_getInt( index, CHAR_LV)* modai) * 100 ) ; + if( ai > 100 ) ai = 100; + + ai += CHAR_getInt( index, CHAR_VARIABLEAI) * 0.01; + if( CHAR_getInt( hostindex, CHAR_TRANSMIGRATION ) > 0 ){ + // shan 120 -> 140 + ai += ( CHAR_GetLevel() - CHAR_getInt( hostindex, CHAR_LV ) ) / 2; + } + if( ai < 0 ) ai = 0; + if( ai > 100 ) ai = 100; + CHAR_setWorkInt( index, CHAR_WORKFIXAI, ai); + } + } +} + +int _CHAR_complianceParameter( int index, char *FILE, int LINE) +{ + //print("\ncompPara:%s:%d", FILE, LINE); + + if( !CHAR_CHECKINDEX( index)) return 0; +//CAX + if( CHAR_getInt( index, CHAR_WHICHTYPE) != CHAR_TYPEPLAYER + && CHAR_getInt( index, CHAR_WHICHTYPE) != CHAR_TYPEENEMY + && CHAR_getInt( index, CHAR_WHICHTYPE) != CHAR_TYPEPET +#ifdef _ALLBLUES_LUA + && CHAR_getInt( index, CHAR_WHICHTYPE) != CHAR_TYPELUANPC +#endif +#ifdef _PLAYER_NPC + && CHAR_getInt( index, CHAR_WHICHTYPE) != CHAR_TYPEPLAYERNPC + && CHAR_getInt( index, CHAR_WHICHTYPE) != CHAR_TYPEPLAYERPETNPC +#endif + ){ + return 0; + } + CHAR_initcharWorkInt( index ); + ITEM_equipEffect( index ); + + CHAR_setWorkInt(index, CHAR_WORKATTACKPOWER, + CHAR_getWorkInt( index, CHAR_WORKFIXSTR ) ); + CHAR_setWorkInt(index, CHAR_WORKDEFENCEPOWER, + CHAR_getWorkInt( index, CHAR_WORKFIXTOUGH ) ); + CHAR_setWorkInt(index, CHAR_WORKQUICK, + CHAR_getWorkInt( index, CHAR_WORKFIXDEX ) ); + +#ifdef _ITEMSET5_TXT + CHAR_setWorkInt(index, CHAR_WORKARRANGEPOWER, + CHAR_getWorkInt( index, CHAR_WORKFIXARRANGE ) ); + CHAR_setWorkInt(index, CHAR_WORKSEQUENCEPOWER, + CHAR_getWorkInt( index, CHAR_WORKFIXSEQUENCE ) ); +#endif + + Other_DefcharWorkInt( index); + CHAR_setInt( index, CHAR_HP, min( CHAR_getInt(index,CHAR_HP), CHAR_getWorkInt( index, CHAR_WORKMAXHP))); + CHAR_setInt( index, CHAR_MP, min( CHAR_getInt(index,CHAR_MP), CHAR_getWorkInt( index, CHAR_WORKMAXMP))); + + if( CHAR_getInt( index, CHAR_WHICHTYPE) == CHAR_TYPEPLAYER ){ + if( CHAR_getWorkInt( index, CHAR_WORKPETFOLLOW ) != -1 ){ + int petindex = CHAR_getWorkInt( index, CHAR_WORKPETFOLLOW ); + if( !CHAR_CHECKINDEX( petindex) ){ + CHAR_setWorkInt( index, CHAR_WORKPETFOLLOW, -1); + }else{ + if( CHAR_getInt( petindex, CHAR_WHICHTYPE) == CHAR_TYPEPET && + !CHAR_CHECKINDEX( CHAR_getWorkInt( petindex, CHAR_WORKPLAYERINDEX)) ){ + CHAR_setWorkInt( index, CHAR_WORKPETFOLLOW, petindex); + CHAR_setWorkInt( petindex, CHAR_WORKPLAYERINDEX, index); + } + } + } + +#ifdef _PROFESSION_SKILL // WON ADD ְҵ + { + int i; + + for( i=0; i NowTime.tv_sec +#ifdef _NPCCHANGE_PLAYERIMG + || CHAR_getWorkInt( index, CHAR_WORKNPCMETAMO) > 0 +#endif +#ifdef _PETSKILL_BECOMEPIG + || CHAR_getInt( index, CHAR_BECOMEPIG) > -1 +#endif + ){ + newimagenumber = oldimagenumber; //ָԭͼ + } +#endif + // Arminius 8.9 airplane + if (oldimagenumber==100259) newimagenumber=100259; +#ifdef _VARY_WOLF + if( (CHAR_getInt( index, CHAR_WHICHTYPE) == CHAR_TYPEPET) && + (CHAR_getWorkInt( index, CHAR_WORKBATTLEMODE) != BATTLE_CHARMODE_NONE) && + oldimagenumber == 101428 ){ + newimagenumber = 101428; + } +#endif + +#ifdef _ENEMY_FALLGROUND + if( CHAR_getInt( index, CHAR_WHICHTYPE) == CHAR_TYPEENEMY ) { + return 0; + }else { +#endif + if(CHAR_getInt(index, CHAR_RIDEPET) == -1){ + if( newimagenumber == -1 ){ + CHAR_setInt(index,CHAR_BASEIMAGENUMBER, basebaseimagenumber); + }else { + CHAR_setInt(index,CHAR_BASEIMAGENUMBER,newimagenumber); + } + } + +#ifdef _ENEMY_FALLGROUND + } +#endif +#ifdef _NEW_RIDEPETS + if( (CHAR_getWorkInt(index, CHAR_WORKITEMMETAMO)>NowTime.tv_sec) + || (CHAR_getWorkInt(index,CHAR_WORKNPCMETAMO)>0)){ + return 0; + } +#endif + } + return 1; +} + +int CHAR_complianceParameter2( int index) +{ + //print("\ncompPara:%s:%d", FILE, LINE); + + if( !CHAR_CHECKINDEX( index)) return 0; + + //CHAR_initcharWorkInt( index ); + //ITEM_equipEffect( index ); + + CHAR_setWorkInt(index, CHAR_WORKATTACKPOWER, + CHAR_getWorkInt( index, CHAR_WORKFIXSTR ) ); + CHAR_setWorkInt(index, CHAR_WORKDEFENCEPOWER, + CHAR_getWorkInt( index, CHAR_WORKFIXTOUGH ) ); + CHAR_setWorkInt(index, CHAR_WORKQUICK, + CHAR_getWorkInt( index, CHAR_WORKFIXDEX ) ); + +#ifdef _ITEMSET5_TXT + CHAR_setWorkInt(index, CHAR_WORKARRANGEPOWER, + CHAR_getWorkInt( index, CHAR_WORKFIXARRANGE ) ); + CHAR_setWorkInt(index, CHAR_WORKSEQUENCEPOWER, + CHAR_getWorkInt( index, CHAR_WORKFIXSEQUENCE ) ); +#endif + + Other_DefcharWorkInt( index); + CHAR_setInt( index, CHAR_HP, min( CHAR_getInt(index,CHAR_HP), CHAR_getWorkInt( index, CHAR_WORKMAXHP))); + CHAR_setInt( index, CHAR_MP, min( CHAR_getInt(index,CHAR_MP), CHAR_getWorkInt( index, CHAR_WORKMAXMP))); + + if( CHAR_getInt( index, CHAR_WHICHTYPE) == CHAR_TYPEPLAYER ){ + if( CHAR_getWorkInt( index, CHAR_WORKPETFOLLOW ) != -1 ){ + int petindex = CHAR_getWorkInt( index, CHAR_WORKPETFOLLOW ); + if( !CHAR_CHECKINDEX( petindex) ){ + CHAR_setWorkInt( index, CHAR_WORKPETFOLLOW, -1); + }else{ + if( CHAR_getInt( petindex, CHAR_WHICHTYPE) == CHAR_TYPEPET && + !CHAR_CHECKINDEX( CHAR_getWorkInt( petindex, CHAR_WORKPLAYERINDEX)) ){ + CHAR_setWorkInt( index, CHAR_WORKPETFOLLOW, petindex); + CHAR_setWorkInt( petindex, CHAR_WORKPLAYERINDEX, index); + } + } + } + +#ifdef _PROFESSION_SKILL // WON ADD ְҵ + { + int i; + + for( i=0; i NowTime.tv_sec +#ifdef _NPCCHANGE_PLAYERIMG + || CHAR_getWorkInt( index, CHAR_WORKNPCMETAMO) > 0 +#endif +#ifdef _PETSKILL_BECOMEPIG + || CHAR_getInt( index, CHAR_BECOMEPIG) > -1 +#endif + ){ + newimagenumber = oldimagenumber; //ָԭͼ + } +#endif + // Arminius 8.9 airplane + if (oldimagenumber==100259) newimagenumber=100259; +#ifdef _VARY_WOLF + if( (CHAR_getInt( index, CHAR_WHICHTYPE) == CHAR_TYPEPET) && + (CHAR_getWorkInt( index, CHAR_WORKBATTLEMODE) != BATTLE_CHARMODE_NONE) && + oldimagenumber == 101428 ){ + newimagenumber = 101428; + } +#endif + +#ifdef _ENEMY_FALLGROUND + if( CHAR_getInt( index, CHAR_WHICHTYPE) == CHAR_TYPEENEMY ) { + return 0; + }else { +#endif + if(CHAR_getInt(index, CHAR_RIDEPET) == -1){ + if( newimagenumber == -1 ){ + CHAR_setInt(index,CHAR_BASEIMAGENUMBER, basebaseimagenumber); + }else { + CHAR_setInt(index,CHAR_BASEIMAGENUMBER,newimagenumber); + } + } + +#ifdef _ENEMY_FALLGROUND + } +#endif +#ifdef _NEW_RIDEPETS + if( (CHAR_getWorkInt(index, CHAR_WORKITEMMETAMO)>NowTime.tv_sec) + || (CHAR_getWorkInt(index,CHAR_WORKNPCMETAMO)>0)){ + return 0; + } +#endif + } + return 1; +} + +/*====================================================================== + ƽҷ¼ʧ ةë + ======================================================================*/ + +/*====================έ====================*/ +/*------------------------------------------------------------ + * ϶ƥ ƽҷέìë Ϸ + * ¦ + * charaindex int ƽҷ̼͵ + * dir int + * ߯Ի + * ئ + ------------------------------------------------------------*/ +void CHAR_Look( int charaindex, int dir ) +{ + int fl ,x,y; + OBJECT object; + + /* ̼͵ */ + if( CHAR_CHECKINDEX( charaindex ) == FALSE )return; + + if( dir < 0 ) { + dir = CHAR_getInt(charaindex,CHAR_DIR); + } + VALIDATEDIR(dir); + if( CHAR_getInt( charaindex, CHAR_DIR) != dir ) { + CHAR_setInt(charaindex,CHAR_DIR,dir); + /* ʧë˪ */ + CHAR_sendWatchEvent(CHAR_getWorkInt(charaindex,CHAR_WORKOBJINDEX), + CHAR_ACTTURN,NULL,0,TRUE); + } + + fl = CHAR_getInt(charaindex,CHAR_FLOOR); + CHAR_getCoordinationDir( CHAR_getInt(charaindex,CHAR_DIR), + CHAR_getInt(charaindex,CHAR_X), + CHAR_getInt(charaindex,CHAR_Y), + 1, &x, &y ); + + //CHAR_talkToCli( charaindex, -1, "ܻ", CHAR_COLORWHITE ); + + for( object=MAP_getTopObj(fl,x,y) ; object ; + object = NEXT_OBJECT(object) ){ + int objindex = GET_OBJINDEX(object); + if( OBJECT_getType(objindex) == OBJTYPE_CHARA ){ + typedef void (*LOOKF)(int,int); + LOOKF lf; + lf = (LOOKF)CHAR_getFunctionPointer( + OBJECT_getIndex(objindex),CHAR_LOOKEDFUNC); + if( lf ) lf(OBJECT_getIndex(objindex),charaindex); +#ifdef _ALLBLUES_LUA + else{ + RunCharTalkedEvent(OBJECT_getIndex(objindex),charaindex,"hi",1, -1); + } +#endif + } + } +} + +BOOL _CHAR_makeObjectCString( char *file, int line, int objindex,char* buf, int buflen ) +{ + char objindexbuf[64]; + if( CHECKOBJECT(objindex) == FALSE ) return FALSE; + + switch( OBJECT_getType(objindex) ){ + case OBJTYPE_NOUSE: + return FALSE; + break; + case OBJTYPE_CHARA: + { + int charaindex = OBJECT_getIndex(objindex); + char escapename[256]; + char escapetitle[256]; + // shan add +1 + char tmp[256]; + int namecolor; +#ifdef _TRANS_6 +#ifdef _TRANS_7 + int namecolortbl[] = { CHAR_COLORWHITE, CHAR_COLORYELLOW, CHAR_COLORGREEN, + CHAR_COLORCYAN, CHAR_COLORRED, CHAR_COLORPURPLE, CHAR_COLORBLUE2,CHAR_COLORGREEN2,CHAR_COLORBLACK};//תɫ +#else + int namecolortbl[] = { CHAR_COLORWHITE, CHAR_COLORYELLOW, CHAR_COLORGREEN, + CHAR_COLORCYAN, CHAR_COLORRED, CHAR_COLORPURPLE, CHAR_COLORBLUE2};//תɫ +#endif +#else + int namecolortbl[] = { CHAR_COLORWHITE, CHAR_COLORYELLOW, CHAR_COLORGREEN, + CHAR_COLORCYAN, CHAR_COLORRED, CHAR_COLORPURPLE}; +#endif + int ridepet = BATTLE_getRidePet( charaindex ); + char petname[64] = ""; + char escapepetname[256]; + int petlevel = 0; + + if( !CHAR_getFlg(charaindex,CHAR_ISVISIBLE) )return FALSE; + namecolor = CHAR_getInt( charaindex, CHAR_TRANSMIGRATION); +#ifdef _TRANS_6 +#ifdef _TRANS_7 + if( namecolor > 8 ) namecolor = 8; +#else + if( namecolor > 6 ) namecolor = 6; +#endif +#else + if( namecolor > 5 ) namecolor = 5; +#endif + if( namecolor < 0 ) namecolor = 0; + + // shan add begin +#ifdef _NEW_NAME //Զƺ + char* szNewName = CHAR_getChar( charaindex, CHAR_NEWNAME); +#endif + +#ifdef _SHOW_VIP_CF + char VipName[32]=""; + if(getShowVip()!=0) + if(CHAR_getInt( charaindex,CHAR_VIPRIDE )>0) + sprintf(VipName, "VIP-"); +#endif +#ifdef _ITEM_SETLOVER + char LoveName[32]=""; + if(strlen( CHAR_getChar( charaindex, CHAR_LOVE)) > 0 && + strlen(CHAR_getChar(charaindex,CHAR_LOVERID))>0 && + strlen(CHAR_getChar(charaindex,CHAR_LOVERNAME))>0) + sprintf(LoveName, "%s",CHAR_getChar( charaindex, CHAR_LOVERNAME)); +#endif + + if( CHAR_getWorkInt(charaindex, CHAR_WORKFMINDEXI) >= 0 + && CHAR_getWorkInt(charaindex, CHAR_WORKFMINDEXI) < FAMILY_MAXNUM + && CHAR_getInt( charaindex, CHAR_WHICHTYPE) == CHAR_TYPEPLAYER + && CHAR_getWorkInt(charaindex, CHAR_WORKFMSETUPFLAG)==1 +// ||CHAR_getInt( charaindex, CHAR_WHICHTYPE) == CHAR_TYPEPLAYERNPC) +#ifdef _PLAYER_NPC + ||CHAR_getInt( charaindex, CHAR_WHICHTYPE) == CHAR_TYPEPLAYERNPC +#endif + ) +#ifdef _SHOW_VIP_CF + if(getShowVip()==1) + sprintf(tmp, "%s%s%s",VipName,CHAR_getChar( charaindex, CHAR_FMNAME),LoveName); + else +#endif +#ifdef _ITEM_SETLOVER + sprintf(tmp, "%s%s",CHAR_getChar( charaindex, CHAR_FMNAME),LoveName); + else + if(strlen(LoveName)>0) + sprintf(tmp, "%s",LoveName); + else + strcpy(tmp, ""); +#else + sprintf(tmp, "%s",CHAR_getChar( charaindex, CHAR_FMNAME)); + else + strcpy(tmp, ""); +#endif +#ifdef _SHOW_VIP_CF + char Name[64]; + if(getShowVip()==2) + sprintf(Name, "%s%s",VipName,makeEscapeString( CHAR_getChar( charaindex,CHAR_NAME ), escapename, sizeof(escapename))); + else + sprintf(Name, "%s",CHAR_getChar( charaindex,CHAR_NAME )); +#endif + + char szNewTemp[512]; + if(szNewName!=0 && strlen(szNewName) > 0) + sprintf( szNewTemp, "<%s>%s", szNewName, tmp); + else + sprintf( szNewTemp, "%s", tmp); + + + // Robin 0730 + if( ridepet >= 0 ){ + if( ! strcmp( CHAR_getChar( ridepet, CHAR_USERPETNAME), "") ) + strcpy( petname, CHAR_getChar( ridepet, CHAR_NAME )); + else + strcpy( petname, CHAR_getChar( ridepet, CHAR_USERPETNAME )); + petlevel = CHAR_getInt( ridepet, CHAR_LV); + } + + int whichtype = CHAR_getInt( charaindex, CHAR_WHICHTYPE); +#ifdef _PLAYER_NPC + if(whichtype == CHAR_TYPEPLAYERNPC){ + whichtype = CHAR_TYPEPLAYER; + }else{ + + } +#endif +/* + if(whichtype == CHAR_TYPEPLAYERNPC){ + whichtype = CHAR_TYPEPLAYER; + }else{ + + } +*/ +#ifdef _OBJSEND_C + #ifdef _CHAR_PROFESSION // WON ADD ְҵ + #ifdef _ALLDOMAN // (ɿ) Syu ADD аNPC + snprintf( buf, buflen, "%d|%d|%s|%d|%d|%d|%d|%d|%d|%s|%s|%d|%d|%d|%s|%s|%d|%d|%d|%d|%d", + #else + snprintf( buf, buflen, "%d|%d|%s|%d|%d|%d|%d|%d|%d|%s|%s|%d|%d|%d|%s|%s|%d|%d|%d|%d", + #endif + #else + snprintf( buf, buflen, "%d|%d|%s|%d|%d|%d|%d|%d|%d|%s|%s|%d|%d|%d|%s|%s|%d", + #endif + OBJTYPE_CHARA, +#else + snprintf( buf, buflen, "%d|%s|%d|%d|%d|%d|%d|%d|%s|%s|%d|%d|%d|%s|%s|%d", +#endif + whichtype, + cnv10to62( objindex,objindexbuf, sizeof(objindexbuf)), + OBJECT_getX(objindex), + OBJECT_getY(objindex), + CHAR_getInt( charaindex, CHAR_DIR), + CHAR_getInt( charaindex,CHAR_BASEIMAGENUMBER ), + CHAR_getInt( charaindex,CHAR_LV ), + namecolortbl[namecolor], +//#ifdef _NEW_SHOW_VIP_LOVE +// FMandName, +//#else +#ifdef _SHOW_VIP_CF + Name, +#else + makeEscapeString( CHAR_getChar( charaindex,CHAR_NAME ), escapename, sizeof(escapename)), +#endif +//#endif + makeEscapeString(CHAR_getChar(charaindex,CHAR_OWNTITLE), escapetitle,sizeof(escapetitle)), + CHAR_getFlg( charaindex,CHAR_ISOVERED ), + CHAR_getFlg( charaindex,CHAR_HAVEHEIGHT ), + CHAR_getInt( charaindex, CHAR_POPUPNAMECOLOR), + szNewTemp, + makeEscapeString( petname, escapepetname, sizeof(escapepetname)), + petlevel +#ifdef _CHAR_PROFESSION // WON ADD ְҵ + ,CHAR_getInt( charaindex, PROFESSION_CLASS) // ְҵ + ,CHAR_getInt( charaindex, PROFESSION_LEVEL) // ְҵȼ +// ,CHAR_getInt( charaindex, PROFESSION_EXP) // ְҵֵ + ,CHAR_getInt( charaindex, PROFESSION_SKILL_POINT) // ܵ +#endif +#ifdef _ALLDOMAN // (ɿ) Syu ADD аNPC + ,CHAR_getInt( charaindex, CHAR_HEROFLOOR ) // Ӣս¥ +#endif + +#ifdef _PETSKILL_BECOMEPIG + // ,CHAR_getInt(charaindex, CHAR_BECOMEPIG) +#endif + ); + break; + } + case OBJTYPE_ITEM: + { + int itemindex = OBJECT_getIndex(objindex); + int nameint; + int leaklevel; + int color; + char bufbuf[256]; + char *temp; + leaklevel = ITEM_getInt( itemindex,ITEM_LEAKLEVEL ); + + nameint = ITEM_SECRETNAME; +// if( leaklevel >=1 ) { +// nameint = ITEM_SECRETNAME; +// }else { +// nameint = ITEM_NAME; +// } + color = CHAR_COLORWHITE; + if (ITEM_getChar( itemindex, ITEM_CDKEY) == "\0"){ + return FALSE; + break; + } + temp=ITEM_getChar( itemindex, ITEM_CDKEY); + if( temp && strlen( temp ) ) { + color = CHAR_COLORGREEN; + }else { + if( ITEM_getInt( itemindex, ITEM_MERGEFLG) ) { + color = CHAR_COLORYELLOW; + } + } +#ifdef _OBJSEND_C + snprintf( buf, buflen, "%d|%s|%d|%d|%d|%d|%s", + OBJTYPE_ITEM, +#else + snprintf( buf, buflen, "%s|%d|%d|%d|%d|%s", +#endif + cnv10to62( objindex,objindexbuf, sizeof(objindexbuf)), + OBJECT_getX(objindex), OBJECT_getY(objindex), + ITEM_getInt( itemindex,ITEM_BASEIMAGENUMBER ), + color, + makeEscapeString( ITEM_getChar( itemindex,nameint), bufbuf, sizeof(bufbuf)) + ); + break; + } + case OBJTYPE_GOLD: +#ifdef _OBJSEND_C + snprintf( buf, buflen, "%d|%s|%d|%d|%d", + OBJTYPE_GOLD, +#else + snprintf( buf, buflen, "%s|%d|%d|%d", +#endif + cnv10to62( objindex,objindexbuf, sizeof(objindexbuf)), + OBJECT_getX(objindex),OBJECT_getY(objindex), + OBJECT_getIndex(objindex) ); + break; +#ifdef _OBJSEND_C +#endif + default: + return FALSE; + break; + } + return TRUE; +} + +void CHAR_sendCSpecifiedObjindex( int fd, int index) +{ + char introduction[512]; + if( CHECKOBJECTUSE( index ) + && CHAR_makeObjectCString( index, introduction, + sizeof(introduction) ) ){ + lssproto_C_send( fd,introduction ); + }else{ + char mesg[32]; + cnv10to62( index, mesg, sizeof( mesg)); + lssproto_C_send( fd, mesg ); + } +} + +void CHAR_sendSpecifiedobjindexCToCharaindex(int charaindex,int objindex) +{ + int fd; + fd = getfdFromCharaIndex(charaindex); + if( fd == -1)return; + CHAR_sendCSpecifiedObjindex(fd,objindex); +} + +void CHAR_sendCToArroundCharacter( int objindex ) +{ + char introduction[512]; + int x,y,fl; + int i,j; + + if( CHAR_makeObjectCString( objindex,introduction, sizeof(introduction) ) == FALSE ) return; + + x = OBJECT_getX(objindex); + y = OBJECT_getY(objindex); + fl =OBJECT_getFloor(objindex); + + for( i = x - CHAR_DEFAULTSEESIZ/2 ; + i <= x +CHAR_DEFAULTSEESIZ/2 ; i ++ ){ + for( j = y - CHAR_DEFAULTSEESIZ/2; + j <= y + CHAR_DEFAULTSEESIZ/2; j ++ ){ + OBJECT object; + for( object = MAP_getTopObj( fl, i,j); + object; + object = NEXT_OBJECT(object) ){ + int objindexwk = GET_OBJINDEX( object); + if( OBJECT_getType(objindexwk) == OBJTYPE_CHARA ){ + int index = OBJECT_getIndex(objindexwk); + if( CHAR_getInt( index, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER ){ + int fd; + if( CHAR_getWorkInt( index, CHAR_WORKBATTLEMODE) != BATTLE_CHARMODE_NONE) continue; + fd = getfdFromCharaIndex( index); + if( fd == -1 )continue; + lssproto_C_send( fd,introduction ); + } + } + } + } + } +} + +void CHAR_sendCDArroundChar_Main( int fl, int x, int y, int objindex, BOOL mode ) +{ +#define CHAR_CDSEESIZ CHAR_DEFAULTSEESIZ+10 + + int i,j; + char cdmsg[64*2]; + cnv10to62( objindex,cdmsg, sizeof(cdmsg)); + for( i = x - CHAR_CDSEESIZ/2 ; i <= x +CHAR_CDSEESIZ/2 ; i ++ ){ + for( j = y - CHAR_CDSEESIZ/2; j <= y + CHAR_CDSEESIZ/2; j ++ ){ + OBJECT object; + for( object = MAP_getTopObj( fl, i,j); object; + object = NEXT_OBJECT(object) ){ + + int objindexwk = GET_OBJINDEX( object); + if( OBJECT_getType(objindexwk) == OBJTYPE_CHARA ){ + int index = OBJECT_getIndex( objindexwk); + if( CHAR_getInt( index,CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER) { + if( objindexwk != objindex ) { + int fd; + fd = getfdFromCharaIndex(index); + if( fd == -1 )continue; + if( CHAR_getWorkInt( index, CHAR_WORKBATTLEMODE) + == BATTLE_CHARMODE_NONE ) + { + CONNECT_appendCDbuf( fd, cdmsg, strlen( cdmsg)); + CDflush( index); + } + } + } + } + } + } + } +} + +void CHAR_sendCDArroundChar( int fl, int x, int y, int objindex ) +{ + CHAR_sendCDArroundChar_Main( fl,x,y,objindex,FALSE); +} + + +void CHAR_sendArroundCharaData( int charaindex ) +{ + int fd; + int i,j,x, y,fl; + char introduction[512*2]; + char c_msg[5][1024*6]; + int strpos[5] = {0,0,0,0,0}; + char cabuf[128*2]; + fd = getfdFromCharaIndex( charaindex ); + if( fd == -1 )return; + memset(c_msg[0], 0, sizeof(c_msg[0])); + memset(c_msg[1], 0, sizeof(c_msg[1])); + memset(c_msg[2], 0, sizeof(c_msg[2])); + memset(c_msg[3], 0, sizeof(c_msg[3])); + memset(c_msg[4], 0, sizeof(c_msg[4])); + c_msg[0][0] = '\0'; + c_msg[1][0] = '\0'; + c_msg[2][0] = '\0'; + c_msg[3][0] = '\0'; + c_msg[4][0] = '\0'; + fl = CHAR_getInt( charaindex, CHAR_FLOOR); + x = CHAR_getInt( charaindex, CHAR_X); + y = CHAR_getInt( charaindex, CHAR_Y); + + for( i = x-CHAR_DEFAULTSEESIZ/2 ; i <= x+CHAR_DEFAULTSEESIZ/2 ; i++ ){ + for( j = y-CHAR_DEFAULTSEESIZ/2 ; j <= y+CHAR_DEFAULTSEESIZ/2 ; 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) ){ + if(!CHAR_CHECKINDEX(OBJECT_getIndex(objindex))){ + printf("Զɾһ"); + endObjectOne(objindex); + } + continue; + } + if( OBJECT_getType( objindex) == OBJTYPE_CHARA) { + if( CHAR_getInt( c_index, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER +#ifdef _ALLBLUES_LUA + || CHAR_getInt( c_index, CHAR_WHICHTYPE ) >= CHAR_TYPELUANPC +#endif + ){ + /* έƽҷ»弰ئĸ CAë˪ */ + if( 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)); + } + } + // Robin 0611 trade + /* ɫ */ + if( CHAR_getWorkInt( c_index, CHAR_WORKTRADEMODE ) != CHAR_TRADE_FREE ) { + if( CHAR_makeCAOPT1String( objindex, cabuf, sizeof( cabuf), CHAR_ACTTRADE,1 )){ + CONNECT_appendCAbuf( fd,cabuf,strlen(cabuf)); + } + } + +#ifdef _ANGEL_SUMMON + if( CHAR_getWorkInt( c_index, CHAR_WORKANGELMODE ) == TRUE ) { + if( CHAR_makeCAOPT1String( objindex, cabuf, sizeof( cabuf), CHAR_ACTANGEL,1 )){ + CONNECT_appendCAbuf( fd,cabuf,strlen(cabuf)); + } + } +#endif + +#ifdef _MIND_ICON + //print("\nshan--->(batlmode)->%d", CHAR_getWorkInt( c_index, CHAR_WORKBATTLEMODE )); + if(CHAR_getWorkInt( c_index, CHAR_MIND_NUM) && + CHAR_getWorkInt( c_index, CHAR_WORKBATTLEMODE ) == BATTLE_CHARMODE_NONE){ + if( CHAR_makeCAOPT1String( objindex, cabuf, sizeof( cabuf), + CHAR_MIND, CHAR_getWorkInt( c_index, CHAR_MIND_NUM))){ + CONNECT_appendCAbuf( fd, cabuf, strlen(cabuf)); + //print("\nshan---->(1)cabuf-->%s", cabuf); + } + } +#endif + +#ifdef _STREET_VENDOR + if(CHAR_getWorkInt(c_index,CHAR_WORKSTREETVENDOR) == 1 && + CHAR_getWorkInt(c_index,CHAR_WORKBATTLEMODE) == BATTLE_CHARMODE_NONE){ + if(CHAR_makeCAOPTString(objindex,cabuf,sizeof(cabuf), + CHAR_STREETVENDOR_OPEN,CHAR_getWorkChar(c_index,CHAR_STREETVENDOR_NAME))){ + CONNECT_appendCAbuf(fd,cabuf,strlen(cabuf)); + } + } +#endif + +#ifdef _ITEM_CRACKER + if(CHAR_getWorkInt( c_index, CHAR_WORKITEM_CRACKER)&& + CHAR_getWorkInt( c_index, CHAR_WORKBATTLEMODE ) == BATTLE_CHARMODE_NONE) + { + if( CHAR_makeCAOPT1String( objindex, cabuf, sizeof( cabuf), + CHAR_ITEM_CRACKER, CHAR_getWorkInt( c_index, CHAR_WORKITEM_CRACKER))) + { + CONNECT_appendCAbuf( fd, cabuf, strlen(cabuf)); + } + } +#endif + if( 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 = FALSE; + if( BATTLE_CHECKINDEX( battleno ) == FALSE ){ + }else { + helpno = (BattleArray[ battleno].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_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)); + + } + } + }else if( CHAR_getInt( c_index, CHAR_WHICHTYPE ) == CHAR_TYPEPET ) { + if( 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 { //npc + + if( CHAR_CHECKINDEX( c_index) ) { + 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( c_index == charaindex) continue; + if( CHAR_makeObjectCString( objindex, introduction, sizeof( introduction))){ + introlen = strlen( introduction); + introduction[introlen] = ','; + introduction[introlen+1] = '\0'; + if(strpos[0]+strlen( introduction)<=5120){ + strcpysafe( &c_msg[0][strpos[0]], sizeof( c_msg[0]) - strpos[0], + introduction); + strpos[0] += strlen( introduction); + }else if(strpos[1]+strlen( introduction)<=5120){ + strcpysafe( &c_msg[1][strpos[1]], sizeof( c_msg[0]) - strpos[1], + introduction); + strpos[1] += strlen( introduction); + }else if(strpos[2]+strlen( introduction)<=5120){ + strcpysafe( &c_msg[2][strpos[2]], sizeof( c_msg[2]) - strpos[2], + introduction); + strpos[2] += strlen( introduction); + }else if(strpos[3]+strlen( introduction)<=5120){ + strcpysafe( &c_msg[3][strpos[3]], sizeof( c_msg[3]) - strpos[3], + introduction); + strpos[3] += strlen( introduction); + }else if(strpos[4]+strlen( introduction)<=5120){ + strcpysafe( &c_msg[4][strpos[4]], sizeof( c_msg[4]) - strpos[4], + introduction); + strpos[4] += strlen( introduction); + } + } + } + } + } + dchop( c_msg[0], "," ); + dchop( c_msg[1], "," ); + dchop( c_msg[2], "," ); + dchop( c_msg[3], "," ); + dchop( c_msg[4], "," ); + if( strlen( c_msg[0]) == 0 ) return; + //print("\nc_msg[0]=%s,strpos[0]=%d\n",c_msg[0],strpos[0]); + lssproto_C_send( fd, c_msg[0]); + if(strlen( c_msg[1]) > 0){ + //print("\nc_msg[1]=%s,strpos[1]=%d\n",c_msg[1],strpos[1]); + lssproto_C_send( fd, c_msg[1]); + } + if(strlen( c_msg[2]) > 0){ + //print("\nc_msg[2]=%s,strpos[2]=%d\n",c_msg[2],strpos[2]); + lssproto_C_send( fd, c_msg[2]); + } + if(strlen( c_msg[3]) > 0){ + //print("\nc_msg[3]=%s,strpos[3]=%d\n",c_msg[3],strpos[3]); + lssproto_C_send( fd, c_msg[3]); + } + if(strlen( c_msg[4]) > 0){ + //print("\nc_msg[4]=%s,strpos[4]=%d\n",c_msg[4],strpos[4]); + lssproto_C_send( fd, c_msg[4]); + }//޸˶ر +} + +BOOL _CHAR_warpToSpecificPoint( char *file, int line, int charaindex, int floor, int x, int y) +{ + int objindex; + int per; + objindex = CHAR_getWorkInt(charaindex,CHAR_WORKOBJINDEX); + if( !MAP_IsValidCoordinate( floor, x, y )) { +// print( "error: invalid Coordinate fl[%d] x[%d] y[%d] %s:%d from %s:%d\n", +// floor, x, y, __FILE__, __LINE__, file, line); + return FALSE; + } + CHAR_sendCDArroundChar_Main( OBJECT_getFloor(objindex), + OBJECT_getX(objindex), + OBJECT_getY(objindex), + objindex, TRUE ); + + CHAR_setInt( charaindex,CHAR_FLOOR,floor); + CHAR_setInt( charaindex,CHAR_X,x); + CHAR_setInt( charaindex,CHAR_Y,y); + { + int of,ox,oy; + of = OBJECT_setFloor(objindex,floor); + ox = OBJECT_setX(objindex,x); + oy = OBJECT_setY(objindex,y); + if( !MAP_objmove( objindex,of,ox,oy,floor,x,y ) ){ + fprint( "ERROR MAP_OBJMOVE objindex=%d\n",objindex ); + return FALSE; + } + } + per = ENCOUNT_getEncountPercentMin( charaindex, floor,x,y); + if( per != -1 ) { + CHAR_setWorkInt( charaindex, CHAR_WORKENCOUNTPROBABILITY_MIN, per); + } + per = ENCOUNT_getEncountPercentMax( charaindex, floor,x,y); + if( per != -1 ) { + CHAR_setWorkInt( charaindex, CHAR_WORKENCOUNTPROBABILITY_MAX, per); + } + +#ifdef _PROFESSION_SKILL // WON ADD ְҵ + CHAR_setWorkInt( charaindex, CHAR_ENCOUNT_FIX, 0); +#endif + + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE) == CHAR_TYPEPLAYER ) { + CAflush( charaindex ); + { + int i; + char* statuscat[]={"C","E",}; + for( i=0 ; i -1) && (CHAR_CHECKINDEX( petindex )) ) + + CHAR_warpToSpecificPoint( petindex, floor, x, y ); + } +#ifdef _STATUS_WATERWORD //ˮ״̬ + if( MAP_getMapFloorType( floor) == 1 ){ + CHAR_setWorkInt( charaindex, CHAR_WORKMAPFLOORTYPE, 1); + }else { + CHAR_setWorkInt( charaindex, CHAR_WORKMAPFLOORTYPE, 0); + } +#endif +#ifdef _MAP_TIME + // ĵͼЩŵĻ,趨 + if(floor >= 30017 && floor <= 30021){ + if(CHAR_getWorkInt(charaindex,CHAR_WORK_MAP_TIME) <= 0) CHAR_setWorkInt(charaindex,CHAR_WORK_MAP_TIME,60); + } + // ĵͼ + else CHAR_setWorkInt(charaindex,CHAR_WORK_MAP_TIME,0); +#endif + +#ifdef _ANGEL_SUMMON + if( CHAR_getWorkInt( charaindex, CHAR_WORKANGELMODE ) == TRUE ) { + CHAR_sendAngelMark( objindex, 1); + } +#endif + + }else if( OBJECT_getType( objindex) == OBJTYPE_CHARA ){ + MAP_sendArroundChar( charaindex ); + } + + return TRUE; +} + +static void CHAR_walk_check( int charaindex ) +{ + if( strlen( CHAR_getWorkChar( charaindex ,CHAR_WORKWALKARRAY ) ) != 0 ){ + struct timeval old; + old.tv_sec = CHAR_getWorkInt(charaindex,CHAR_WORKWALKSTARTSEC); + old.tv_usec = CHAR_getWorkInt(charaindex,CHAR_WORKWALKSTARTMSEC); + if( time_diff_us(NowTime,old) >= CHAR_getInt(charaindex,CHAR_WALKINTERVAL)*1000.0 ) { + CHAR_walkcall( charaindex ); + } + } +} + +static BOOL CHAR_callLoop( int charaindex ) +{ + unsigned int timediff_us; + struct timeval old; + int loopinterval, iRet = FALSE; + loopinterval = CHAR_getInt(charaindex,CHAR_LOOPINTERVAL); + if( loopinterval <= 0 )return FALSE; + + //print("\n CHAR_callLoop:%d", charaindex); + + old.tv_sec = CHAR_getWorkInt(charaindex,CHAR_WORKLOOPSTARTSEC); + old.tv_usec = CHAR_getWorkInt(charaindex,CHAR_WORKLOOPSTARTMSEC); + timediff_us = time_diff_us( NowTime , old ); + + if( timediff_us >= loopinterval*500.0 ){ + int (*loopfunc)(int)=NULL; + loopfunc =(int(*)(int))CHAR_getFunctionPointer( charaindex, CHAR_LOOPFUNC); + if( loopfunc ){ + loopfunc(charaindex); + iRet = TRUE; + } +#ifdef _ALLBLUES_LUA + else{ + RunCharLoopEvent(charaindex); + iRet = TRUE; + } +#endif +#ifdef _USER_CHARLOOPS + loopfunc =(int(*)(int))CHAR_getFunctionPointer( charaindex, CHAR_LOOPFUNCTEMP1); + if( loopfunc ){ + loopfunc(charaindex); + iRet = TRUE; + } +#endif + if( iRet == FALSE ){ + CHAR_setInt( charaindex, CHAR_LOOPINTERVAL, 0); + } + + CHAR_setWorkInt(charaindex,CHAR_WORKLOOPSTARTSEC, NowTime.tv_sec); + CHAR_setWorkInt(charaindex,CHAR_WORKLOOPSTARTMSEC, NowTime.tv_usec); + } + return iRet; +} + +int EnemyMoveNum = 10; +void CHAR_Loop( void ) +{ + int charnum=CHAR_getCharNum(); + int playernum = CHAR_getPlayerMaxNum(); + int petnum = CHAR_getPetMaxNum(); + static int charcnt = 0; + int i, movecnt=0; + + + if( charcnt == -1 ) { + charcnt = CHAR_getCharNum(); + } + + // õloop + for( i=0 ; i< playernum ; i++ ){ + if( CHAR_getCharUse(i) == FALSE )continue; + CHAR_walk_check( i ); + CHAR_callLoop( i ); + +#ifdef _TEACHER_SYSTEM + // лõʦ + if(CHAR_getWorkInt(i,CHAR_WORK_GET_TEACHER_FAME) > 0){ + int iAddTFame = CHAR_getInt(i,CHAR_TEACHER_FAME) + CHAR_getWorkInt(i,CHAR_WORK_GET_TEACHER_FAME); + int iAddFame = CHAR_getInt(i,CHAR_FAME) + CHAR_getWorkInt(i,CHAR_WORK_GET_TEACHER_FAME); + + // ӵʦ(ʦֵ͸ֵһ) + if(iAddTFame > MAX_PERSONALFAME) iAddTFame = MAX_PERSONALFAME; + else if(iAddTFame < 0) iAddTFame = 0; + CHAR_setInt(i,CHAR_TEACHER_FAME,iAddTFame); + // + if(iAddFame > MAX_PERSONALFAME) iAddFame = MAX_PERSONALFAME; + else if(iAddFame < 0) iAddFame = 0; + CHAR_setInt(i,CHAR_FAME,iAddFame); + // Ϊ 0 + CHAR_setWorkInt(i,CHAR_WORK_GET_TEACHER_FAME,0); + // м,ϴacֶͬ + if(CHAR_getInt(i,CHAR_FMLEADERFLAG) > 0 && CHAR_getInt(i,CHAR_FMLEADERFLAG) != FMMEMBER_APPLY){ + char tmpbuf1[16]; + + sprintf(tmpbuf1,"%d",iAddFame); + saacproto_ACFixFMData_send(acfd, + CHAR_getChar(i,CHAR_FMNAME), + CHAR_getInt(i,CHAR_FMINDEX), + CHAR_getWorkInt(i,CHAR_WORKFMINDEXI), + FM_FIX_FMFEED, + "0", // ֻΪͬ,Ϊ0, + tmpbuf1, // ͬ + CHAR_getWorkInt(i,CHAR_WORKFMCHARINDEX), + CONNECT_getFdid(getfdFromCharaIndex(i)) + ); + } + } +#endif + } +#ifdef _FIX_CHAR_LOOP + static int petcnt = 0; + static int othercnt = 0; + for( i = 0, movecnt = 0; i < CHAR_getPetMaxNum() ; i++, petcnt++ ){ + if( petcnt >= petnum )petcnt = playernum ; + if( CHAR_getCharUse(petcnt) == FALSE )continue; + if( CHAR_callLoop(petcnt) == TRUE ){ + if( ++movecnt >= EnemyMoveNum )break; + }else{ + continue; + } + } + for( i = 0, movecnt = 0; i < CHAR_getOthersMaxNum() ; i++, othercnt++ ){ + if( othercnt >= charnum )othercnt = petnum ; + if( CHAR_getCharUse(othercnt) == FALSE )continue; + if( CHAR_callLoop(othercnt) == TRUE ){ + if( ++movecnt >= 50 )break; + }else{ + continue; + } + } +#else + // Objectõloop + for( i = 0, movecnt = 0 ; i < (petnum/2) ; i++, charcnt++ ){ + if( charcnt >= charnum )charcnt = playernum ; + if( CHAR_getCharUse(charcnt) == FALSE )continue; + if( CHAR_callLoop(charcnt) == TRUE ){ + if( ++movecnt >= EnemyMoveNum )break; + }else{ + continue; + } + } +#endif +} + +char* CHAR_appendNameAndTitle( int charaindex, char* src, char* buf, + int buflen ) +{ + if( buflen > 0 ){ + if( CHAR_CHECKINDEX(charaindex) == FALSE ) + snprintf( buf,buflen,"%s",src ); + else{ + int titleindex = CHAR_getInt(charaindex,CHAR_INDEXOFEQTITLE); + char indexname[128]; + strcpy(indexname,CHAR_getChar(charaindex,CHAR_NAME)); +#ifdef _NO_DAOLUAN + if(CHAR_getInt(charaindex,CHAR_TRANSMIGRATION)<1){ + if(CHAR_getInt(charaindex,CHAR_LV)<=getTalkLv()){ + if(CHAR_getInt(charaindex,CHAR_WHICHTYPE)==CHAR_TYPEPLAYER){ + strcpy(indexname,getTalkName()); + } + } + } +#endif + if( titleindex == -1 ) + snprintf( buf,buflen, "%s%s", + indexname, src ); + else + snprintf( buf,buflen, "%s(%s)%s", + indexname, + TITLE_makeTitleStatusString(charaindex, + titleindex), src ); + } + } + return buf; +} + +void CHAR_getCoordinationDir( int dir , int x, int y ,int c, + int *xout , int *yout ) +{ + *xout = x + CHAR_getDX(dir) * c; + *yout = y + CHAR_getDY(dir) * c; +} + +BOOL CHAR_createCharacter( int type, int floor, int x, int y,int dir, + int* charaindex, int* objindex, BOOL seemap ) +{ + Char ch; + Object ob; + if( !CHAR_getDefaultChar( &ch,type ) )return FALSE; + + ch.data[CHAR_FLOOR] = floor; + ch.data[CHAR_X] = x; + ch.data[CHAR_Y] = y; + ch.data[CHAR_DIR] = dir; + + *charaindex = CHAR_initCharOneArray( &ch ); + if( *charaindex == -1 )return FALSE; + + ob.type = OBJTYPE_CHARA; + ob.index = *charaindex; + ob.floor = floor; + ob.x = x; + ob.y = y; + + if( seemap && MAP_walkAble( *charaindex, floor,x,y ) == FALSE ){ + CHAR_endCharOneArray( *charaindex ); + return FALSE; + } + + *objindex = initObjectOne( &ob ); + if( *objindex == -1 ){ + CHAR_endCharOneArray(*charaindex); + return FALSE; + } + CHAR_setWorkInt( *charaindex,CHAR_WORKOBJINDEX,*objindex); + + /* ë浤 */ + + CHAR_sendWatchEvent( *objindex,CHAR_ACTSTAND,NULL,0,TRUE); + + return TRUE; +} + +void CHAR_ObjectDelete( int objindex ) +{ + CHAR_sendCDArroundChar( OBJECT_getFloor(objindex), + OBJECT_getX(objindex), + OBJECT_getY(objindex), + objindex ); +#ifdef _MAP_WARPPOINT + if( OBJECT_getType( objindex) == OBJTYPE_WARPPOINT ){ +// print("Delete OBJTYPE_WARPPOINT endObjectOne( %d) [%d,%d,%d] \n ", objindex, +// OBJECT_getFloor(objindex), OBJECT_getX(objindex), +// OBJECT_getY(objindex) ); + } +#endif + endObjectOne(objindex); +} + +/*------------------------------------------------------------ + * ƽҷë£Ƥִ£ + * ͼ֧Իëئ׻ּ + * ¦ + * charaindex int ƽҷ̼͵ + * ߯Ի + * ئ + ------------------------------------------------------------*/ +void CHAR_CharaDelete( int charaindex ) +{ + /* Ƥë */ + CHAR_ObjectDelete( CHAR_getWorkInt( charaindex,CHAR_WORKOBJINDEX ) ); + /* ƽҷ¼ */ + CHAR_endCharOneArray( charaindex ); +} +/*------------------------------------------------------------ + * Ȼʸë + ------------------------------------------------------------*/ +void CHAR_CharaDeleteHavePet( int charaindex) +{ + int i; + int pindex; + + for( i = 0; i < CHAR_MAXPETHAVE; i ++ ) { + pindex = CHAR_getCharPet( charaindex, i); + if( CHAR_CHECKINDEX( pindex)) { + CHAR_endCharOneArray( pindex ); + } + } + for( i = 0; i < CHAR_MAXPOOLPETHAVE; i ++ ) { + pindex = CHAR_getCharPoolPet( charaindex, i); + if( CHAR_CHECKINDEX( pindex)) { + CHAR_endCharOneArray( pindex ); + } + } +} +/*------------------------------------------------------------ + * ئë £ + * mode int 0: б巴CA˪ئ + * 1: бCA˪ + ------------------------------------------------------------*/ +int CHAR_sendAction( int charaindex, int action, int mode) +{ + /* ˪ľ ʧCAë۽ Ƥ */ + static int table[] = { + CHAR_ACTATTACK,CHAR_ACTDAMAGE,CHAR_ACTDOWN,CHAR_ACTACTIONSTAND, + CHAR_ACTACTIONWALK,CHAR_ACTSIT,CHAR_ACTHAND,CHAR_ACTPLEASURE, + CHAR_ACTANGRY,CHAR_ACTSAD,CHAR_ACTGUARD, CHAR_ACTNOD, CHAR_ACTTHROW + }; + if( action < 0 || action >= arraysizeof( table)) return FALSE; + + /* Իʧë˪ */ + CHAR_sendWatchEvent( + CHAR_getWorkInt( charaindex, CHAR_WORKOBJINDEX), + table[action], + NULL,0,mode); + + /* ʧ */ + CHAR_setWorkInt( charaindex, CHAR_WORKACTION, table[action]); + + return TRUE; +} +/*------------------------------------------------------------ + * л ƥؤеë˪£ + ------------------------------------------------------------*/ +void CHAR_sendBattleEffect( int charaindex, int onoff) +{ + int opt[3]; + + if( onoff == 1) { + opt[0] = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEINDEX); + opt[1] = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLESIDE); + opt[2] = (BattleArray[CHAR_getWorkInt( charaindex, + CHAR_WORKBATTLEINDEX)].Side[ + CHAR_getWorkInt( charaindex, + CHAR_WORKBATTLESIDE)].flg & BSIDE_FLG_HELP_OK) ? TRUE:FALSE; + } + else { + opt[0] = -1; + opt[1] = -1; + opt[2] = 0; + } + + CHAR_sendWatchEvent( CHAR_getWorkInt( charaindex, CHAR_WORKOBJINDEX), + CHAR_ACTBATTLE,opt,arraysizeof(opt),TRUE); +} + +/*------------------------------------------------------------ + * дѶϢ add code Shan 2001/06/30 + ------------------------------------------------------------*/ +void CHAR_sendTradeEffect( int charaindex, int onoff) +{ + int opt[1]; + + if( onoff == 1) { + opt[0] = 1; + } + else { + opt[0] = -1; + } + CHAR_sendWatchEvent( CHAR_getWorkInt( charaindex, CHAR_WORKOBJINDEX), + CHAR_ACTTRADE,opt,arraysizeof(opt),TRUE); +} + +#ifdef _ANGEL_SUMMON +void CHAR_sendAngelEffect( int charaindex, int onoff) +{ + int opt[1]; + + if( onoff == 1) { + opt[0] = 1; + } + else { + opt[0] = -1; + } + CHAR_sendWatchEvent( CHAR_getWorkInt( charaindex, CHAR_WORKOBJINDEX), + CHAR_ACTANGEL,opt,arraysizeof(opt),TRUE); +} +#endif + +#ifdef _MIND_ICON +void CHAR_sendMindEffect( int charaindex, int onoff) +{ + int opt[1]; + + if(onoff>0){ + opt[0] = onoff; + } + else{ + opt[0] = 0; + } + CHAR_sendWatchEvent( CHAR_getWorkInt( charaindex, CHAR_WORKOBJINDEX), + CHAR_MIND, opt, arraysizeof(opt), FALSE); +} +#endif +#ifdef _ITEM_CRACKER +void CHAR_sendCrackerEffect( int charaindex, int onoff) +{ + int opt[1]; + opt[0] = onoff; + CHAR_sendWatchEvent( CHAR_getWorkInt( charaindex, CHAR_WORKOBJINDEX), + CHAR_ITEM_CRACKER, opt, arraysizeof(opt), FALSE); +} +#endif + +void CHAR_inputUserPetName( int index , int havepetindex, char* name ) +{ + int petindex; + //char category[3]; + char *mycdkey=NULL, *cdkey = NULL; + BOOL changenameflg = FALSE; + + if( !CHAR_CHECKINDEX( index ) ) return; + + petindex = CHAR_getCharPet( index, havepetindex); + if( !CHAR_CHECKINDEX( petindex)) return; + + if (CHAR_getInt(petindex, CHAR_PETFAMILY) == 1){ + CHAR_talkToCli(index, -1, "ػ޷޸֣", CHAR_COLORYELLOW); + return; + } + + mycdkey = CHAR_getChar( index, CHAR_CDKEY); + cdkey = CHAR_getChar( petindex, CHAR_CDKEY); + if( cdkey == "\0" ) { + print( "can't get CDKEY\n"); + }else { + if( strlen( cdkey) == 0 || strcmp( cdkey, mycdkey) == 0 ) { + changenameflg = TRUE; + } + } + if( !changenameflg) { + CHAR_talkToCli( index, -1, "޷Ϊ", CHAR_COLORYELLOW ); + return; + } + + CHAR_setChar( petindex, CHAR_USERPETNAME ,name); + + if( strlen( name ) == 0 || + strcmp( CHAR_getChar( petindex, CHAR_NAME), name) == 0 ){ + CHAR_setChar( petindex, CHAR_CDKEY, ""); + }else { + CHAR_setChar( petindex, CHAR_CDKEY, mycdkey); + } + CHAR_send_K_StatusString( index, havepetindex, CHAR_K_STRING_USERPETNAME); +} + +static void CHAR_setLuck( int charaindex) +{ + LSTIME nowlstime; + LSTIME mylstime; + struct { + int prob; + int luck; + }lucktbl[] = { + { 60, 1 }, /* 40% */ + { 30, 2 }, /* 30% */ + { 10, 3 }, /* 20% */ + { 3, 4 }, /* 7% */ + { 0, 5 } /* 3% */ + }; + + if( !CHAR_CHECKINDEX( charaindex)) return; + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE) != CHAR_TYPEPLAYER) return; + + RealTimeToLSTime( NowTime.tv_sec, &nowlstime); + RealTimeToLSTime( CHAR_getInt( charaindex, CHAR_LASTTIMESETLUCK), &mylstime); + + /* LSƥ ȻľCHAR_LUCKëޥ */ + if( nowlstime.day != mylstime.day || nowlstime.year != mylstime.year ) { + int i,r; + r = RAND( 0, 99); + for( i = 0; i < arraysizeof( lucktbl); i ++ ) { + if( r >= lucktbl[i].prob ) { + CHAR_setInt( charaindex, CHAR_LUCK, lucktbl[i].luck); + CHAR_setInt( charaindex, CHAR_LASTTIMESETLUCK, NowTime.tv_sec); + return; + } + } + } +} +void CHAR_JoinBattle_WindowResult( int charaindex, int select, char *data) +{ + int ret = FALSE; + int fd = getfdFromCharaIndex( charaindex); + +#if 1 // òսظս Robin + if( CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE) != BATTLE_CHARMODE_NONE) { + CHAR_talkToCli( charaindex, -1, " ظս! ", CHAR_COLORRED); + print("\n ķ!!ظս!:%s ", CHAR_getChar( charaindex, CHAR_CDKEY) ); + //lssproto_EN_send( fd, FALSE, 0 ); + return; + } +#endif + if( select != WINDOW_BUTTONTYPE_CANCEL && + CHAR_getWorkInt( charaindex, CHAR_WORKPARTYMODE) == CHAR_PARTY_NONE ){ + while( 1 ) { + int selected; + int bcharaindex; + if( fd == -1 ) break; + selected = atoi( data)-1; + + if( !CHAR_CHECKINDEX( CONNECT_getBattlecharaindex(fd,selected))) { + break; + } + if( CHAR_getWorkInt( CONNECT_getBattlecharaindex(fd,selected), + CHAR_WORKBATTLEMODE) == BATTLE_CHARMODE_NONE){ + break; + } + if( BattleArray[ CHAR_getWorkInt( + CONNECT_getBattlecharaindex( fd,selected), + CHAR_WORKBATTLEINDEX)].type != BATTLE_TYPE_P_vs_E ){ + break; + } + bcharaindex = CONNECT_getBattlecharaindex( fd,selected); + if( !(BattleArray[CHAR_getWorkInt( bcharaindex, + CHAR_WORKBATTLEINDEX)].Side[ + CHAR_getWorkInt( bcharaindex, + CHAR_WORKBATTLESIDE)].flg + & BSIDE_FLG_HELP_OK)){ + break; + } + if(NPC_Util_CharDistance( charaindex, + CONNECT_getBattlecharaindex( + fd,selected) )> 1){ + break; + } + if( BATTLE_RescueEntry( charaindex, + CONNECT_getBattlecharaindex(fd,selected) )){ + CHAR_talkToCli( charaindex, -1, "޷ս", + CHAR_COLORYELLOW); + }else { + ret = TRUE; + } + + break; + } + } + if( ret == FALSE ) { + if( fd != -1 ) { + lssproto_EN_send( fd, FALSE, 0 ); + } + } +} +void CHAR_JoinDuel_WindowResult( int charaindex, int select, char *data) +{ + int ret = FALSE; + int fd = getfdFromCharaIndex( charaindex); + /* ֵպ */ + if( select != WINDOW_BUTTONTYPE_CANCEL && + CHAR_getWorkInt( charaindex, CHAR_WORKPARTYMODE) != CHAR_PARTY_CLIENT ) + { + /* мƥպë */ + while( 1 ) { + int selected; + int enemyindex; + + if( fd == -1 ) break; + selected = atoi( data)-1; + /* ئindex */ + if( !CHAR_CHECKINDEX( CONNECT_getDuelcharaindex(fd,selected)) ) { + break; + } + /* */ + if( CHAR_getWorkInt( CONNECT_getDuelcharaindex(fd,selected), + CHAR_WORKBATTLEMODE) + != BATTLE_CHARMODE_NONE) + { + break; + } + /* duelھ */ + if( !CHAR_getFlg( CONNECT_getDuelcharaindex(fd,selected), + CHAR_ISDUEL)) + { + break; + } + /* ڶ ¾(ūƥ ƻޱ ¿) */ + if(NPC_Util_CharDistance( charaindex, + CONNECT_getDuelcharaindex(fd,selected) ) + > 1) + { + break; + } + // 󡼰ƽҷ¼̼͵ + enemyindex = CONNECT_getDuelcharaindex( fd,selected); + print("\nenemyindex=%d\n",enemyindex); + // 컥ئչ޼» + // Ҽئëƥ + if( CHAR_getWorkInt( enemyindex, CHAR_WORKPARTYMODE ) + == CHAR_PARTY_CLIENT ) + { + enemyindex = CHAR_getWorkInt( enemyindex, CHAR_WORKPARTYINDEX1 ); + // ئ⾮ʻئ + if( enemyindex < 0 ){ + break; + } + } + /* 컥ƥئؤ */ + if( CHAR_getInt( enemyindex, CHAR_WHICHTYPE) != CHAR_TYPEPLAYER){ + break; + } + ret = BATTLE_CreateVsPlayer( charaindex, enemyindex ); + if( ret != 0 ){ + CHAR_talkToCli( charaindex, -1, + "ʧܣ", CHAR_COLORYELLOW); + ret = FALSE; + } + else { + ret = TRUE; + } + break; + } + } + if( ret == FALSE ) { + /* ˪ */ + if( fd != -1 ) { + lssproto_EN_send( fd, FALSE, 0 ); + } + } +} +void CHAR_SelectCard_WindowResult( int charaindex, int select, char *data) +{ + if( select != WINDOW_BUTTONTYPE_CANCEL ){ + while( 1 ) { + int selected; + int fd; + fd = getfdFromCharaIndex( charaindex); + if( fd == -1 ) break; + selected = atoi( data)-1; + if( !CHAR_CHECKINDEX( + CONNECT_getTradecardcharaindex(fd,selected))) { + break; + } + if( CHAR_getWorkInt( CONNECT_getTradecardcharaindex(fd,selected), + CHAR_WORKBATTLEMODE) != BATTLE_CHARMODE_NONE){ + break; + } + if(!CHAR_getFlg( CONNECT_getTradecardcharaindex(fd,selected), + CHAR_ISTRADECARD)){ + break; + } + if( NPC_Util_CharDistance( charaindex, + CONNECT_getTradecardcharaindex + (fd,selected) ) > 1){ + break; + } + ADDRESSBOOK_addAddressBook( charaindex, + CONNECT_getTradecardcharaindex( + fd,selected)); + break; + } + } +} + +void CHAR_JoinParty_WindowResult( int charaindex , int select, char *data) +{ + int ret = FALSE; + int fd = getfdFromCharaIndex( charaindex); + /* ֵպ */ + if( select != WINDOW_BUTTONTYPE_CANCEL && + /* лɡ ū׬ƥ */ + CHAR_getWorkInt( charaindex, CHAR_WORKPARTYMODE) == CHAR_PARTY_NONE ) + { + /* мƥպë */ + while( 1 ) { + int parray; + int selected; + int toindex = -1; + if( fd == -1 ) break; + selected = atoi( data)-1; + + /* ئindex + * (ۢūƥ ƻޱ + * ئindexئµ 뻥ؤ) + */ + if( !CHAR_CHECKINDEX( + CONNECT_getJoinpartycharaindex(fd,selected))) { + break; + } + /* ʻ¦ȽԻ */ + if( CHAR_getWorkInt( CONNECT_getJoinpartycharaindex( + fd,selected), CHAR_WORKPARTYMODE) + == CHAR_PARTY_NONE ) + { + toindex = CONNECT_getJoinpartycharaindex( fd,selected ); + } + else { + toindex = CHAR_getPartyIndex( + CONNECT_getJoinpartycharaindex(fd,selected), 0); + if( !CHAR_CHECKINDEX( toindex) ) { + print( " %s:%d err\n", __FILE__, __LINE__); + break; + } + } + /* ڶ ¾(ūƥ ƻޱ ¿) */ + if( NPC_Util_CharDistance( charaindex, toindex ) > 1) { + break; + } + /* ֻ */ + if( CHAR_getWorkInt( toindex, CHAR_WORKBATTLEMODE) + != BATTLE_CHARMODE_NONE) + { + break; + } + /* ޸ƹ */ + if( !CHAR_getFlg( toindex, CHAR_ISPARTY)) { + break; + } + + /* ɡ ūѷ */ + parray = CHAR_getEmptyPartyArray( toindex) ; + if( parray == -1 ) break; + /* ɡ ū */ + CHAR_JoinParty_Main( charaindex, toindex); + ret = TRUE; + break; + } + } + if( ret == FALSE ) { + CHAR_talkToCli( charaindex, -1, "޷Ŷӡ", + CHAR_COLORYELLOW); + } + /* ˪ */ + if( fd != -1 ) { + lssproto_PR_send( fd, 1, ret); + } +} +void CHAR_JoinBattleWatch_WindowResult( int charaindex, int select, char *data) +{ + int ret = FALSE; + int fd = getfdFromCharaIndex( charaindex); + /* ֵպ */ + if( select != WINDOW_BUTTONTYPE_CANCEL ) { + /* мƥպë */ + while( 1 ) { + int selected; + if( fd == -1 ) break; + selected = atoi( data)-1; + + /* ئindex + * (ۢūƥ ƻޱ + * ئindexئµ 뻥ؤ) + */ + if( !CHAR_CHECKINDEX( CONNECT_getBattlecharaindex(fd,selected))) { + break; + } + /* */ + if( CHAR_getWorkInt( CONNECT_getBattlecharaindex(fd,selected), + CHAR_WORKBATTLEMODE) + == BATTLE_CHARMODE_NONE) + { + break; + } + /* ڶ ¾(ūƥ ƻޱ ¿) */ + if(NPC_Util_CharDistance( charaindex, + CONNECT_getBattlecharaindex( + fd,selected) ) + > 1) + { + break; + } + /* ޼ */ + if( BATTLE_WatchEntry( charaindex, + CONNECT_getBattlecharaindex(fd,selected) + )) + { + CHAR_talkToCli( charaindex, -1, "޷ս", + CHAR_COLORYELLOW); + } + else { + ret = TRUE; + } + + break; + } + } + if( ret == FALSE ) { + /* ˪ */ + if( fd != -1 ) { + lssproto_EN_send( fd, FALSE, 0 ); + } + } +} + +#ifdef _FM_MODIFY +extern void NPC_FmDengonWindowTalked( int index, int talker, int seqno, int select, char *data); +#endif + +void CHAR_processWindow(int charaindex, int seqno, int select, + int objindex, char* data ) +{ + if( CHECKOBJECTUSE(objindex)) { + if( OBJECT_getType(objindex) == OBJTYPE_CHARA ) { + typedef void (*WINDF)(int,int,int, int,char*); + WINDF windowtalkedfunc=NULL; + windowtalkedfunc = (WINDF)CHAR_getFunctionPointer( + OBJECT_getIndex(objindex),CHAR_WINDOWTALKEDFUNC); + if( windowtalkedfunc ) { + windowtalkedfunc( OBJECT_getIndex(objindex), charaindex, + seqno, select, data); + } +#ifdef _ALLBLUES_LUA + else{ + RunCharWindowTalked( OBJECT_getIndex(objindex), charaindex, + seqno, select, data); + } +#endif + } + }else { + if( seqno == CHAR_WINDOWTYPE_SELECTBATTLE) { + CHAR_JoinBattle_WindowResult( charaindex, select, data); + }else if( seqno == CHAR_WINDOWTYPE_SELECTDUEL) { + CHAR_JoinDuel_WindowResult( charaindex, select, data); + }else if( seqno == CHAR_WINDOWTYPE_SELECTTRADECARD) { + CHAR_SelectCard_WindowResult( charaindex, select, data); + }else{ + if( seqno == CHAR_WINDOWTYPE_SELECTPARTY) { + CHAR_JoinParty_WindowResult( charaindex, select, data); + }else { + if( seqno == CHAR_WINDOWTYPE_SELECTBATTLEWATCH) { + CHAR_JoinBattleWatch_WindowResult( charaindex, select, data); + }else if( seqno >= CHAR_WINDOWTYPE_SELECTRENAMEITEM_PAGE1 && + seqno <= CHAR_WINDOWTYPE_SELECTRENAMEITEM_RENAME_ATTENTION ){ + ITEM_useRenameItem_WindowResult( charaindex, seqno, select, data); + } +#ifdef _PETSKILL_CANNEDFOOD + else if( seqno == ITEM_WINDOWTYPE_SELECTPETSKILL_SELECT ){ + ITEM_usePetSkillCanned_WindowResult( charaindex, seqno, select, data); + } +#endif +#ifdef _NULL_CHECK_ITEM + else if( seqno == CHAR_WINDOWTYPE_NULL_CHECK ){ + int value=atoi(data); + if(value<0){ + CHAR_talkToCli( charaindex, -1, "֧ƱֵС,ٷ,װл!", CHAR_COLORYELLOW ); + return; + } + + if(CHAR_getInt( charaindex , CHAR_AMPOINT)0){ + LogAmPoint(CHAR_getChar( charaindex, CHAR_NAME ), + CHAR_getChar( charaindex, CHAR_CDKEY ), + -value, + CHAR_getInt( charaindex, CHAR_AMPOINT ), + "(֧Ʊ)", + CHAR_getInt( charaindex,CHAR_FLOOR), + CHAR_getInt( charaindex,CHAR_X ), + CHAR_getInt( charaindex,CHAR_Y )); + } +#endif + + + sprintf(buf, "%d", value); + ITEM_setChar(itemindex, ITEM_ARGUMENT, buf); + + sprintf( buf, "֧Ʊ%8d.00ǩ: %s", value, CHAR_getChar(charaindex, CHAR_NAME)); + ITEM_setChar( itemindex, ITEM_EFFECTSTRING, buf); + CHAR_sendItemDataOne( charaindex, haveitemindex); + + sprintf( buf, "˽˻֧Ʊע%dֵ㣡", value); + CHAR_talkToCli( charaindex, -1, buf, CHAR_COLORYELLOW); + }else{ + CHAR_talkToCli( charaindex, -1, "ʧܣ벻Ҫ֧ƱʱƶϵƷ", CHAR_COLORYELLOW); + } + } + } +#endif + } + } +#ifdef _FM_MODIFY + if(seqno >= CHAR_WINDOWTYPE_FM_DENGON || seqno <= CHAR_WINDOWTYPE_FM_DPSELECT) + NPC_FmDengonWindowTalked(0,charaindex,seqno,select,data); +#endif + } +} + +void CHAR_PartyUpdate( int charaindex, int senddata ){ + int i, ownerindex, mode, pindex, pno; + mode = CHAR_getWorkInt( charaindex, CHAR_WORKPARTYMODE ); + if( mode == CHAR_PARTY_NONE )return; + if( mode == CHAR_PARTY_LEADER ){ + ownerindex = charaindex; + }else{ + ownerindex = CHAR_getWorkInt( charaindex, CHAR_WORKPARTYINDEX1 ); + } + + for( pno = 0; pno < CHAR_PARTYMAX; pno ++ ){ + pindex = CHAR_getWorkInt( ownerindex, CHAR_WORKPARTYINDEX1+pno ); + if( pindex == charaindex )break; + } + if( pno == CHAR_PARTYMAX )return; + for( i = 0; i < CHAR_PARTYMAX; i ++ ){ + pindex = CHAR_getWorkInt( ownerindex, CHAR_WORKPARTYINDEX1+i ); + if( pindex == charaindex )continue; + if( pindex < 0 )continue; + CHAR_send_N_StatusString( pindex, pno, senddata ); + } +} + +static int CHAR_getObjectByPosition( int myobjindex, int fl, int x, int y, + int *objbuf, int objbuflen) +{ + int i,j; + int cnt = 0; + + for( i = x-CHAR_DEFAULTSEESIZ/2 ; i <= x+CHAR_DEFAULTSEESIZ/2 ; i++ ){ + for( j = y-CHAR_DEFAULTSEESIZ/2 ; j <= y+CHAR_DEFAULTSEESIZ/2 ; + j ++ ) + { + OBJECT object; + for( object = MAP_getTopObj(fl,i,j) ; + object ; + object = NEXT_OBJECT(object ) ) + { + int objindex = GET_OBJINDEX(object); + 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( objindex == myobjindex) continue; + + objbuf[cnt] = objindex; + cnt ++; + if( cnt >= objbuflen) return cnt; + } + } + } + return cnt; +} +static void CHAR_setMyPosition_sendData( int charaindex,int prev_x, int prev_y, int x, int y) +{ + int CurrentObjCollection[CHAR_DEFAULTSEESIZ*CHAR_DEFAULTSEESIZ*10]; + int PrevObjCollection[CHAR_DEFAULTSEESIZ*CHAR_DEFAULTSEESIZ*10]; + int curcnt,prevcnt; + int objindex; + int fl; + char introduction[512]; + char c_msg[1024*96]; + char buf[64]; + int strpos; + int fd; + int i,j; + char cabuf[128]; + char myintroduction[512]; + char cd_msg[128]; + + fd = CHAR_getWorkInt( charaindex, CHAR_WORKFD); + if( fd == -1 )return; + + objindex = CHAR_getWorkInt( charaindex, CHAR_WORKOBJINDEX); + fl = CHAR_getInt( charaindex, CHAR_FLOOR); + + curcnt = CHAR_getObjectByPosition( objindex, fl,x,y, CurrentObjCollection, sizeof(CurrentObjCollection)); + prevcnt = CHAR_getObjectByPosition( objindex, fl, prev_x, prev_y, PrevObjCollection, sizeof(PrevObjCollection)); + strpos = 0; + c_msg[0] = '\0'; + if( !CHAR_makeObjectCString( objindex, myintroduction,sizeof( myintroduction))){ + myintroduction[0] = '\0'; + } + + for( i = 0 ; i < curcnt; i ++ ) { + int findflg = FALSE; + for( j = 0; j < prevcnt; j ++ ) { + if( CurrentObjCollection[i] == PrevObjCollection[j] ) { + findflg = TRUE; + break; + } + } + if( !findflg ) { + int introlen; + int c_index = OBJECT_getIndex( CurrentObjCollection[i]); + if( CHAR_makeObjectCString( CurrentObjCollection[i], 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( strpos >= sizeof( c_msg)) break; + } + if( strlen( myintroduction) != 0 ) { + if( OBJECT_getType( CurrentObjCollection[i] ) == OBJTYPE_CHARA ) { + if( CHAR_getInt( c_index, CHAR_WHICHTYPE) == CHAR_TYPEPLAYER) { + int tofd = getfdFromCharaIndex( c_index ); + CDsend( tofd); + lssproto_C_send( tofd, myintroduction); + } + } + } + if( OBJECT_getType( CurrentObjCollection[i]) == OBJTYPE_CHARA ) { + if( CHAR_getInt( c_index, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER && + CHAR_getWorkInt( c_index, CHAR_WORKPARTYMODE ) + == CHAR_PARTY_LEADER ){ + if( CHAR_makeCAOPT1String( CurrentObjCollection[i], cabuf, sizeof( cabuf), + CHAR_ACTLEADER,1 )){ + CONNECT_appendCAbuf( fd,cabuf,strlen(cabuf)); + } + } + + // Robin 0611 trade + /* ɫ */ + if( CHAR_getInt( c_index, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER && + CHAR_getWorkInt( c_index, CHAR_WORKTRADEMODE ) != CHAR_TRADE_FREE ) { + if( CHAR_makeCAOPT1String( objindex, cabuf, sizeof( cabuf), CHAR_ACTTRADE,1 )) + { + CONNECT_appendCAbuf( fd,cabuf,strlen(cabuf)); + } + } + +#ifdef _ANGEL_SUMMON + if( CHAR_getInt( c_index, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER && + CHAR_getWorkInt( c_index, CHAR_WORKANGELMODE ) == TRUE ) { + if( CHAR_makeCAOPT1String( objindex, cabuf, sizeof( cabuf), CHAR_ACTANGEL,1 )) + { + CONNECT_appendCAbuf( fd,cabuf,strlen(cabuf)); + } + } +#endif + +#ifdef _MIND_ICON + if( CHAR_getInt( c_index, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER && + CHAR_getWorkInt( c_index, CHAR_WORKBATTLEMODE) == BATTLE_CHARMODE_NONE && + CHAR_getWorkInt( c_index, CHAR_MIND_NUM)) + { + if( CHAR_makeCAOPT1String( objindex, cabuf, sizeof( cabuf), + CHAR_MIND, CHAR_getWorkInt( c_index, CHAR_MIND_NUM))) + { + CONNECT_appendCAbuf( fd, cabuf, strlen( cabuf)); + //print("\nshan---->(2)cabuf-->%s", cabuf); + } + } +#endif +#ifdef _STREET_VENDOR + if(CHAR_getWorkInt(c_index,CHAR_WORKSTREETVENDOR) == 1 && + CHAR_getWorkInt(c_index,CHAR_WORKBATTLEMODE) == BATTLE_CHARMODE_NONE){ + if(CHAR_makeCAOPTString(objindex,cabuf,sizeof(cabuf), + CHAR_STREETVENDOR_OPEN,CHAR_getWorkChar(c_index,CHAR_STREETVENDOR_NAME))) + CONNECT_appendCAbuf(fd,cabuf,strlen(cabuf)); + } +#endif +#ifdef _ITEM_CRACKER + if( CHAR_getInt( c_index, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER && + CHAR_getWorkInt( c_index, CHAR_WORKBATTLEMODE) == BATTLE_CHARMODE_NONE && + CHAR_getWorkInt( c_index, CHAR_WORKITEM_CRACKER)) + { + if( CHAR_makeCAOPT1String( objindex, cabuf, sizeof( cabuf), + CHAR_ITEM_CRACKER, CHAR_getWorkInt( c_index, CHAR_WORKITEM_CRACKER))) + { + CONNECT_appendCAbuf( fd, cabuf, strlen( cabuf)); + } + } +#endif + /* лƥ컥 ƥئئĸ CAë˪ */ + 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)); + } + } + } + /* έƽҷ» ئվ ʧ ë˪ */ +#ifdef _ALLBLUES_LUA + if( (CHAR_getInt( c_index, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER + || CHAR_getInt( c_index, CHAR_WHICHTYPE ) >= CHAR_TYPELUANPC) + && CHAR_getWorkInt( c_index, CHAR_WORKBATTLEMODE )!= BATTLE_CHARMODE_NONE ) +#else + if( CHAR_getInt( c_index, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER && + CHAR_getWorkInt( c_index, CHAR_WORKBATTLEMODE ) + != BATTLE_CHARMODE_NONE ) +#endif + { + /* CA */ + if( CHAR_getWorkInt( c_index, CHAR_WORKBATTLEWATCH) == TRUE ) { + if( CHAR_makeCAOPT1String( CurrentObjCollection[i], 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; + /* HelpNo = 1 */ + if( CHAR_makeCAOPT3String( CurrentObjCollection[i], 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( CurrentObjCollection[i], cabuf, sizeof( cabuf), + CHAR_getWorkInt( c_index, CHAR_WORKACTION))) + { + CONNECT_appendCAbuf( fd,cabuf,strlen(cabuf)); + } + } + } + } + } + dchop( c_msg, "," ); + if( strlen( c_msg) != 0 ) { + lssproto_C_send( fd, c_msg); + } + + /* мCD */ + cnv10to62( objindex,cd_msg, sizeof(cd_msg)); + + for( i = 0 ; i < prevcnt; i ++ ) { + int findflg = FALSE; + /* 󡼰 Ƥƥػ ئ + * ƤئƤ + */ + for( j = 0; j < curcnt; j ++ ) { + if( PrevObjCollection[i] == CurrentObjCollection[j] ) { + findflg = TRUE; + break; + } + } + if( !findflg ) { + cnv10to62( PrevObjCollection[i], buf, sizeof( buf)); + CONNECT_appendCDbuf( fd, buf, strlen( buf)); + + /* ˪ */ + if( OBJECT_getType( PrevObjCollection[i]) == OBJTYPE_CHARA ) { + int tocharaindex = OBJECT_getIndex( PrevObjCollection[i]); + if( CHAR_getInt( tocharaindex, CHAR_WHICHTYPE) == CHAR_TYPEPLAYER) { + int tofd = CHAR_getWorkInt( tocharaindex, CHAR_WORKFD); + if( tofd != -1 ) { + CONNECT_appendCDbuf( tofd, cd_msg, strlen( cd_msg)); + CDsend( tofd); + } + } + } + } + } + CDsend( fd); + + +} +BOOL CHAR_setMyPosition( int index, int x, int y, BOOL CAFlg) +{ + return CHAR_setMyPosition_main( index,x,y,-1,CAFlg); +} + +BOOL CHAR_setMyPosition_main( int index, int x, int y, int setdir, BOOL CAFlg) +{ + int objindex; + int prev_x,prev_y; + int fl; + + prev_x = CHAR_getInt( index, CHAR_X); + prev_y = CHAR_getInt( index, CHAR_Y); + if( prev_x == x && prev_y == y ) { + return FALSE; + } + + if( CHAR_getWorkInt( index, CHAR_WORKPARTYMODE) == CHAR_PARTY_CLIENT) { + return FALSE; + } + + if( CHAR_getFlg( index, CHAR_ISWARP)) return FALSE; + + objindex = CHAR_getWorkInt(index,CHAR_WORKOBJINDEX); + fl = CHAR_getInt( index, CHAR_FLOOR); + + if( !MAP_IsValidCoordinate( fl, x, y )) { + print( "error: invalid Coordinate fl[%d] x[%d] y[%d] %s:%d\n", + fl, x, y, __FILE__, __LINE__); + CONNECT_setCloseRequest( CHAR_getWorkInt( index, CHAR_WORKFD), 1); + return FALSE; + } + + if( ABS( x - prev_x) > CHAR_DEFAULTSEESIZ/2 || + ABS( y - prev_y) > CHAR_DEFAULTSEESIZ/2 ) + { + CHAR_sendCDArroundChar( fl,prev_x,prev_y,objindex ); + } + + if( ABS( x - prev_x) <= 1 && ABS( y - prev_y ) <= 1){ + POINT start,end; + int dir; + start.x = CHAR_getInt( index, CHAR_X); + start.y = CHAR_getInt( index, CHAR_Y); + end.x = x; + end.y = y; + dir = NPC_Util_getDirFromTwoPoint( &start, &end); + if( dir != -1 ) { + CHAR_walk( index, dir, 0); + } + } + else { + CHAR_setInt( index, CHAR_X,x); + CHAR_setInt( index, CHAR_Y,y); + if( setdir >= 0 && setdir < 8) CHAR_setInt( index, CHAR_DIR, setdir); + { + int of,ox,oy; + of = OBJECT_setFloor(objindex,fl); + ox = OBJECT_setX(objindex,x); + oy = OBJECT_setY(objindex,y); + + if( !MAP_objmove( objindex,of,ox,oy,fl,x,y ) ){ + fprint( "ERROR MAP_OBJMOVE objindex=%d\n",objindex ); + return FALSE; + } + } + if( ABS( x - prev_x) > CHAR_DEFAULTSEESIZ/2 || + ABS( y - prev_y) > CHAR_DEFAULTSEESIZ/2 ) + { + CHAR_sendWatchEvent(objindex,CHAR_ACTWARP,NULL,0,FALSE); + } + else if( CAFlg == TRUE ) { + CHAR_sendWatchEvent(objindex,CHAR_ACTWARP,NULL,0,FALSE); + } + } + + if( CHAR_getWorkInt( index, CHAR_WORKPARTYMODE) == CHAR_PARTY_LEADER ) { + if( ABS( x - prev_x) <= 1 && ABS( y - prev_y ) <= 1){ + int i; + int prevparty_x = prev_x; + int prevparty_y = prev_y; + for( i = 1; i < CHAR_PARTYMAX; i ++ ) { + int toindex = CHAR_getWorkInt( index, i + CHAR_WORKPARTYINDEX1); + if( CHAR_CHECKINDEX(toindex) ) { + int client_x = prevparty_x; + int client_y = prevparty_y; + int dir; + POINT start, end; + + prevparty_x = CHAR_getInt( toindex, CHAR_X); + prevparty_y = CHAR_getInt( toindex, CHAR_Y); + start.x = prevparty_x; + start.y = prevparty_y; + + end.x = client_x; + end.y = client_y; + + dir = NPC_Util_getDirFromTwoPoint( &start, &end); + if( dir != - 1 ) { + CHAR_walk( toindex, dir, 0); + } + } + } + } + + else if( ABS( x - prev_x) > CHAR_DEFAULTSEESIZ/2 || + ABS( y - prev_y) > CHAR_DEFAULTSEESIZ/2 ) + { + int i; + for( i = 1; i < CHAR_PARTYMAX; i ++ ) { + int toindex = CHAR_getWorkInt( index, i + CHAR_WORKPARTYINDEX1); + if( CHAR_CHECKINDEX(toindex) ) { + CHAR_warpToSpecificPoint( toindex,fl , x,y); + } + } + } + } + + if( ABS( x - prev_x) <= CHAR_DEFAULTSEESIZ/2 && + ABS( y - prev_y) <= CHAR_DEFAULTSEESIZ/2 ) + { + CHAR_setMyPosition_sendData( index, prev_x, prev_y, x, y); + } + + return TRUE; +} + + +static char CHAR_P_statusSendBuffer[STRINGBUFSIZ]; + + + +static char *CHAR_make_P_StatusString( int charaindex, unsigned int indextable ) +{ + int i,j; + int ret = 0; + int strlength; + char buf[64]; + struct { + unsigned int kind; + int intdataindex; + int gettype; + }chk[] = { + { CHAR_P_STRING_HP, CHAR_HP, 0 }, + { CHAR_P_STRING_MAXHP, CHAR_WORKMAXHP, 1 }, + { CHAR_P_STRING_MP, CHAR_MP, 0 }, + { CHAR_P_STRING_MAXMP, CHAR_WORKMAXMP, 1 }, + { CHAR_P_STRING_EXP, CHAR_EXP, 0 }, + { CHAR_P_STRING_LV, CHAR_LV, 0 }, + { CHAR_P_STRING_ATK, CHAR_WORKATTACKPOWER, 1 }, + { CHAR_P_STRING_DEF, CHAR_WORKDEFENCEPOWER, 1 }, + { CHAR_P_STRING_QUICK, CHAR_WORKQUICK, 1 }, + { CHAR_P_STRING_CHARM, CHAR_WORKFIXCHARM, 1 }, + { CHAR_P_STRING_LUCK, CHAR_WORKFIXLUCK, 1 }, + { CHAR_P_STRING_GOLD, CHAR_GOLD, 0 }, + { CHAR_P_STRING_TITLE, CHAR_INDEXOFEQTITLE, 0 }, + { CHAR_P_STRING_NAME, CHAR_NAME, 2 }, + { CHAR_P_STRING_OWNTITLE, CHAR_OWNTITLE, 2 }, + { CHAR_P_STRING_VITAL, CHAR_VITAL, 10 }, + { CHAR_P_STRING_STR, CHAR_STR, 10 }, + { CHAR_P_STRING_TOUGH, CHAR_TOUGH, 10 }, + { CHAR_P_STRING_DEX, CHAR_DEX, 10 }, + { CHAR_P_STRING_EARTH, CHAR_WORKFIXEARTHAT, 11 }, + { CHAR_P_STRING_WATER, CHAR_WORKFIXWATERAT, 11 }, + { CHAR_P_STRING_FIRE, CHAR_WORKFIXFIREAT, 11 }, + { CHAR_P_STRING_WIND, CHAR_WORKFIXWINDAT, 11 }, + { CHAR_P_STRING_DUELPOINT, CHAR_DUELPOINT, 0 }, + { CHAR_P_STRING_TRANSMIGRATION, CHAR_TRANSMIGRATION, 0}, + { CHAR_P_STRING_RIDEPET, CHAR_RIDEPET, 0}, + { CHAR_P_STRING_LEARNRIDE, CHAR_LEARNRIDE, 0}, + { CHAR_P_STRING_BASEBASEIMAGENUMBER, CHAR_BASEBASEIMAGENUMBER, 0}, + { CHAR_P_STRING_SKYWALKER, CHAR_WORKSKYWALKER, 1}, + { CHAR_P_STRING_DEBUGMODE, CHAR_WORKDEBUGMODE, 1}, + }; + + + snprintf( CHAR_P_statusSendBuffer, sizeof( CHAR_P_statusSendBuffer), + "P%s|", cnv10to62( indextable, buf,sizeof(buf))); + strlength = strlen( CHAR_P_statusSendBuffer ); + + for( i = 1; i < sizeof( int) * 8; i ++ ){ + if( indextable & (1 << i) ) { + char tmp[256]; + BOOL found = FALSE; + for( j = 0; j < arraysizeof( chk); j ++ ) { + if( chk[j].kind == 1 << i ) { + if( chk[j].gettype == 0 ) { + ret = CHAR_getInt( charaindex,chk[j].intdataindex); + snprintf( tmp, sizeof( tmp), "%d|", ret); + }else if( chk[j].gettype == 1 ) { + ret = CHAR_getWorkInt( charaindex,chk[j].intdataindex); + snprintf( tmp, sizeof( tmp), "%d|", ret); + }else if( chk[j].gettype == 10 ) { + ret = CHAR_getInt( charaindex, chk[j].intdataindex)/100; + snprintf( tmp, sizeof( tmp), "%d|", ret); + }else if( chk[j].gettype == 11 ) { + ret = CHAR_getWorkInt( charaindex, chk[j].intdataindex); + if( ret < 0) ret = 0; + snprintf( tmp, sizeof( tmp), "%d|", ret); + }else if( chk[j].gettype == 2 ) { + char escapebuffer[128]; + char *a = CHAR_getChar( charaindex, chk[j].intdataindex); + + snprintf( tmp,sizeof( tmp ), + "%s|", + makeEscapeString( a, escapebuffer, + sizeof(escapebuffer) + )); + } + + found = TRUE; + break; + } + } + if( !found) { + if( indextable & CHAR_P_STRING_NEXTEXP ) { + ret = CHAR_GetLevelExp( charaindex, CHAR_getInt( charaindex, CHAR_LV ) + 1); + snprintf( tmp, sizeof( tmp), "%d|", ret); + found = TRUE; + } + } + if( !found) { + print( "ҲָIJ[%d]\n",indextable); + }else { + strcpysafe( &CHAR_P_statusSendBuffer[ strlength], + sizeof( CHAR_P_statusSendBuffer) - strlength, + tmp); + + strlength += strlen( tmp ); + if( strlength >= sizeof( CHAR_P_statusSendBuffer ) ) { + return CHAR_P_statusSendBuffer; + } + } + } + } + return CHAR_P_statusSendBuffer; +} + +static char *CHAR_make_P_StatusString_Point( int charaindex, unsigned int indextable ) +{ + int i,j; + int ret = 0; + int strlength; + char buf[64]; + + int vippoint = sasql_vippoint(CHAR_getChar(charaindex,CHAR_CDKEY),0,0); + struct { + unsigned int kind; + int intdataindex; + int gettype; + }chk[] = { + { CHAR_P_STRING_HP, CHAR_HP, 0 }, + { CHAR_P_STRING_MAXHP, CHAR_WORKMAXHP, 1 }, + { CHAR_P_STRING_MP, CHAR_MP, 0 }, + { CHAR_P_STRING_MAXMP, CHAR_WORKMAXMP, 1 }, + { CHAR_P_STRING_EXP, CHAR_EXP, 0 }, + { CHAR_P_STRING_LV, CHAR_LV, 0 }, + { CHAR_P_STRING_ATK, CHAR_WORKATTACKPOWER, 1 }, + { CHAR_P_STRING_DEF, CHAR_WORKDEFENCEPOWER, 1 }, + { CHAR_P_STRING_QUICK, CHAR_WORKQUICK, 1 }, + { CHAR_P_STRING_CHARM, CHAR_WORKFIXCHARM, 1 }, + { CHAR_P_STRING_LUCK, CHAR_WORKFIXLUCK, 1 }, + { CHAR_P_STRING_GOLD, vippoint, 3 }, + { CHAR_P_STRING_TITLE, CHAR_INDEXOFEQTITLE, 0 }, + { CHAR_P_STRING_NAME, CHAR_NAME, 2 }, + { CHAR_P_STRING_OWNTITLE, CHAR_OWNTITLE, 2 }, + { CHAR_P_STRING_VITAL, CHAR_VITAL, 10 }, + { CHAR_P_STRING_STR, CHAR_STR, 10 }, + { CHAR_P_STRING_TOUGH, CHAR_TOUGH, 10 }, + { CHAR_P_STRING_DEX, CHAR_DEX, 10 }, + { CHAR_P_STRING_EARTH, CHAR_WORKFIXEARTHAT, 11 }, + { CHAR_P_STRING_WATER, CHAR_WORKFIXWATERAT, 11 }, + { CHAR_P_STRING_FIRE, CHAR_WORKFIXFIREAT, 11 }, + { CHAR_P_STRING_WIND, CHAR_WORKFIXWINDAT, 11 }, + { CHAR_P_STRING_DUELPOINT, CHAR_DUELPOINT, 0 }, + { CHAR_P_STRING_TRANSMIGRATION, CHAR_TRANSMIGRATION, 0}, + { CHAR_P_STRING_RIDEPET, CHAR_RIDEPET, 0}, + { CHAR_P_STRING_LEARNRIDE, CHAR_LEARNRIDE, 0}, + { CHAR_P_STRING_BASEBASEIMAGENUMBER, CHAR_BASEBASEIMAGENUMBER, 0}, + { CHAR_P_STRING_SKYWALKER, CHAR_WORKSKYWALKER, 1}, + { CHAR_P_STRING_DEBUGMODE, CHAR_WORKDEBUGMODE, 1}, + }; + + snprintf( CHAR_P_statusSendBuffer, sizeof( CHAR_P_statusSendBuffer), + "P%s|", cnv10to62( indextable, buf,sizeof(buf))); + strlength = strlen( CHAR_P_statusSendBuffer ); + + for( i = 1; i < sizeof( int) * 8; i ++ ){ + if( indextable & (1 << i) ) { + char tmp[256]; + BOOL found = FALSE; + for( j = 0; j < arraysizeof( chk); j ++ ) { + if( chk[j].kind == 1 << i ) { + if( chk[j].gettype == 0 ) { + ret = CHAR_getInt( charaindex,chk[j].intdataindex); + snprintf( tmp, sizeof( tmp), "%d|", ret); + }else if( chk[j].gettype == 1 ) { + ret = CHAR_getWorkInt( charaindex,chk[j].intdataindex); + snprintf( tmp, sizeof( tmp), "%d|", ret); + }else if( chk[j].gettype == 3 ) { + ret = vippoint; + snprintf( tmp, sizeof( tmp), "%d|", ret); + }else if( chk[j].gettype == 10 ) { + ret = CHAR_getInt( charaindex, chk[j].intdataindex)/100; + snprintf( tmp, sizeof( tmp), "%d|", ret); + }else if( chk[j].gettype == 11 ) { + ret = CHAR_getWorkInt( charaindex, chk[j].intdataindex); + if( ret < 0) ret = 0; + snprintf( tmp, sizeof( tmp), "%d|", ret); + }else if( chk[j].gettype == 2 ) { + char escapebuffer[128]; + char *a = CHAR_getChar( charaindex, chk[j].intdataindex); + + snprintf( tmp,sizeof( tmp ), + "%s|", + makeEscapeString( a, escapebuffer, + sizeof(escapebuffer) + )); + } + + found = TRUE; + break; + } + } + if( !found) { + if( indextable & CHAR_P_STRING_NEXTEXP ) { + ret = CHAR_GetLevelExp( charaindex, CHAR_getInt( charaindex, CHAR_LV ) + 1); + snprintf( tmp, sizeof( tmp), "%d|", ret); + found = TRUE; + } + } + if( !found) { + print( "ҲָIJ[%d]\n",indextable); + }else { + strcpysafe( &CHAR_P_statusSendBuffer[ strlength], + sizeof( CHAR_P_statusSendBuffer) - strlength, + tmp); + + strlength += strlen( tmp ); + if( strlength >= sizeof( CHAR_P_statusSendBuffer ) ) { + return CHAR_P_statusSendBuffer; + } + } + } + } + return CHAR_P_statusSendBuffer; +} + +static char *CHAR_make_P_StatusString_Fame( int charaindex, unsigned int indextable ) +{ + int i,j; + int ret = 0; + int strlength; + char buf[64]; + struct { + unsigned int kind; + int intdataindex; + int gettype; + }chk[] = { + { CHAR_P_STRING_HP, CHAR_HP, 0 }, + { CHAR_P_STRING_MAXHP, CHAR_WORKMAXHP, 1 }, + { CHAR_P_STRING_MP, CHAR_MP, 0 }, + { CHAR_P_STRING_MAXMP, CHAR_WORKMAXMP, 1 }, + { CHAR_P_STRING_EXP, CHAR_EXP, 0 }, + { CHAR_P_STRING_LV, CHAR_LV, 0 }, + { CHAR_P_STRING_ATK, CHAR_WORKATTACKPOWER, 1 }, + { CHAR_P_STRING_DEF, CHAR_WORKDEFENCEPOWER, 1 }, + { CHAR_P_STRING_QUICK, CHAR_WORKQUICK, 1 }, + { CHAR_P_STRING_CHARM, CHAR_WORKFIXCHARM, 1 }, + { CHAR_P_STRING_LUCK, CHAR_WORKFIXLUCK, 1 }, + { CHAR_P_STRING_GOLD, CHAR_FAME, 12 }, + { CHAR_P_STRING_TITLE, CHAR_INDEXOFEQTITLE, 0 }, + { CHAR_P_STRING_NAME, CHAR_NAME, 2 }, + { CHAR_P_STRING_OWNTITLE, CHAR_OWNTITLE, 2 }, + { CHAR_P_STRING_VITAL, CHAR_VITAL, 10 }, + { CHAR_P_STRING_STR, CHAR_STR, 10 }, + { CHAR_P_STRING_TOUGH, CHAR_TOUGH, 10 }, + { CHAR_P_STRING_DEX, CHAR_DEX, 10 }, + { CHAR_P_STRING_EARTH, CHAR_WORKFIXEARTHAT, 11 }, + { CHAR_P_STRING_WATER, CHAR_WORKFIXWATERAT, 11 }, + { CHAR_P_STRING_FIRE, CHAR_WORKFIXFIREAT, 11 }, + { CHAR_P_STRING_WIND, CHAR_WORKFIXWINDAT, 11 }, + { CHAR_P_STRING_DUELPOINT, CHAR_DUELPOINT, 0 }, + { CHAR_P_STRING_TRANSMIGRATION, CHAR_TRANSMIGRATION, 0}, + { CHAR_P_STRING_RIDEPET, CHAR_RIDEPET, 0}, + { CHAR_P_STRING_LEARNRIDE, CHAR_LEARNRIDE, 0}, + { CHAR_P_STRING_BASEBASEIMAGENUMBER, CHAR_BASEBASEIMAGENUMBER, 0}, + { CHAR_P_STRING_SKYWALKER, CHAR_WORKSKYWALKER, 1}, + { CHAR_P_STRING_DEBUGMODE, CHAR_WORKDEBUGMODE, 1}, + }; + + snprintf( CHAR_P_statusSendBuffer, sizeof( CHAR_P_statusSendBuffer), + "P%s|", cnv10to62( indextable, buf,sizeof(buf))); + strlength = strlen( CHAR_P_statusSendBuffer ); + + for( i = 1; i < sizeof( int) * 8; i ++ ){ + if( indextable & (1 << i) ) { + char tmp[256]; + BOOL found = FALSE; + for( j = 0; j < arraysizeof( chk); j ++ ) { + if( chk[j].kind == 1 << i ) { + if( chk[j].gettype == 0 ) { + ret = CHAR_getInt( charaindex,chk[j].intdataindex); + snprintf( tmp, sizeof( tmp), "%d|", ret); + }else if( chk[j].gettype == 1 ) { + ret = CHAR_getWorkInt( charaindex,chk[j].intdataindex); + snprintf( tmp, sizeof( tmp), "%d|", ret); + }else if( chk[j].gettype == 10 ) { + ret = CHAR_getInt( charaindex, chk[j].intdataindex)/100; + snprintf( tmp, sizeof( tmp), "%d|", ret); + }else if( chk[j].gettype == 11 ) { + ret = CHAR_getWorkInt( charaindex, chk[j].intdataindex); + if( ret < 0) ret = 0; + snprintf( tmp, sizeof( tmp), "%d|", ret); + }else if( chk[j].gettype == 12 ) { + ret = (int)(CHAR_getInt( charaindex, chk[j].intdataindex)/100); + if( ret < 0) ret = 0; + snprintf( tmp, sizeof( tmp), "%d|", ret); + }else if( chk[j].gettype == 2 ) { + char escapebuffer[128]; + char *a = CHAR_getChar( charaindex, chk[j].intdataindex); + + snprintf( tmp,sizeof( tmp ), + "%s|", + makeEscapeString( a, escapebuffer, + sizeof(escapebuffer) + )); + } + + found = TRUE; + break; + } + } + if( !found) { + if( indextable & CHAR_P_STRING_NEXTEXP ) { + ret = CHAR_GetLevelExp( charaindex, CHAR_getInt( charaindex, CHAR_LV ) + 1); + snprintf( tmp, sizeof( tmp), "%d|", ret); + found = TRUE; + } + } + if( !found) { + print( "ҲָIJ[%d]\n",indextable); + }else { + strcpysafe( &CHAR_P_statusSendBuffer[ strlength], + sizeof( CHAR_P_statusSendBuffer) - strlength, + tmp); + + strlength += strlen( tmp ); + if( strlength >= sizeof( CHAR_P_statusSendBuffer ) ) { + return CHAR_P_statusSendBuffer; + } + } + } + } + return CHAR_P_statusSendBuffer; +} + + +static char *CHAR_make_P_StatusString_AMPOINT( int charaindex, unsigned int indextable ) +{ + int i,j; + int ret = 0; + int strlength; + char buf[64]; + int ampoint = sasql_ampoint(CHAR_getChar(charaindex,CHAR_CDKEY),0,0); + struct { + unsigned int kind; + int intdataindex; + int gettype; + }chk[] = { + { CHAR_P_STRING_HP, CHAR_HP, 0 }, + { CHAR_P_STRING_MAXHP, CHAR_WORKMAXHP, 1 }, + { CHAR_P_STRING_MP, CHAR_MP, 0 }, + { CHAR_P_STRING_MAXMP, CHAR_WORKMAXMP, 1 }, + { CHAR_P_STRING_EXP, CHAR_EXP, 0 }, + { CHAR_P_STRING_LV, CHAR_LV, 0 }, + { CHAR_P_STRING_ATK, CHAR_WORKATTACKPOWER, 1 }, + { CHAR_P_STRING_DEF, CHAR_WORKDEFENCEPOWER, 1 }, + { CHAR_P_STRING_QUICK, CHAR_WORKQUICK, 1 }, + { CHAR_P_STRING_CHARM, CHAR_WORKFIXCHARM, 1 }, + { CHAR_P_STRING_LUCK, CHAR_WORKFIXLUCK, 1 }, + { CHAR_P_STRING_GOLD, ampoint, 3 }, + { CHAR_P_STRING_TITLE, CHAR_INDEXOFEQTITLE, 0 }, + { CHAR_P_STRING_NAME, CHAR_NAME, 2 }, + { CHAR_P_STRING_OWNTITLE, CHAR_OWNTITLE, 2 }, + { CHAR_P_STRING_VITAL, CHAR_VITAL, 10 }, + { CHAR_P_STRING_STR, CHAR_STR, 10 }, + { CHAR_P_STRING_TOUGH, CHAR_TOUGH, 10 }, + { CHAR_P_STRING_DEX, CHAR_DEX, 10 }, + { CHAR_P_STRING_EARTH, CHAR_WORKFIXEARTHAT, 11 }, + { CHAR_P_STRING_WATER, CHAR_WORKFIXWATERAT, 11 }, + { CHAR_P_STRING_FIRE, CHAR_WORKFIXFIREAT, 11 }, + { CHAR_P_STRING_WIND, CHAR_WORKFIXWINDAT, 11 }, + { CHAR_P_STRING_DUELPOINT, CHAR_DUELPOINT, 0 }, + { CHAR_P_STRING_TRANSMIGRATION, CHAR_TRANSMIGRATION, 0}, + { CHAR_P_STRING_RIDEPET, CHAR_RIDEPET, 0}, + { CHAR_P_STRING_LEARNRIDE, CHAR_LEARNRIDE, 0}, + { CHAR_P_STRING_BASEBASEIMAGENUMBER, CHAR_BASEBASEIMAGENUMBER, 0}, + { CHAR_P_STRING_SKYWALKER, CHAR_WORKSKYWALKER, 1}, + { CHAR_P_STRING_DEBUGMODE, CHAR_WORKDEBUGMODE, 1}, + }; + + snprintf( CHAR_P_statusSendBuffer, sizeof( CHAR_P_statusSendBuffer), + "P%s|", cnv10to62( indextable, buf,sizeof(buf))); + strlength = strlen( CHAR_P_statusSendBuffer ); + + for( i = 1; i < sizeof( int) * 8; i ++ ){ + if( indextable & (1 << i) ) { + char tmp[256]; + BOOL found = FALSE; + for( j = 0; j < arraysizeof( chk); j ++ ) { + if( chk[j].kind == 1 << i ) { + if( chk[j].gettype == 0 ) { + ret = CHAR_getInt( charaindex,chk[j].intdataindex); + snprintf( tmp, sizeof( tmp), "%d|", ret); + }else if( chk[j].gettype == 1 ) { + ret = CHAR_getWorkInt( charaindex,chk[j].intdataindex); + snprintf( tmp, sizeof( tmp), "%d|", ret); + }else if( chk[j].gettype == 3 ) { + ret = ampoint; + snprintf( tmp, sizeof( tmp), "%d|", ret); + }else if( chk[j].gettype == 10 ) { + ret = CHAR_getInt( charaindex, chk[j].intdataindex)/100; + snprintf( tmp, sizeof( tmp), "%d|", ret); + }else if( chk[j].gettype == 11 ) { + ret = CHAR_getWorkInt( charaindex, chk[j].intdataindex); + if( ret < 0) ret = 0; + snprintf( tmp, sizeof( tmp), "%d|", ret); + }else if( chk[j].gettype == 2 ) { + char escapebuffer[128]; + char *a = CHAR_getChar( charaindex, chk[j].intdataindex); + + snprintf( tmp,sizeof( tmp ), + "%s|", + makeEscapeString( a, escapebuffer, + sizeof(escapebuffer) + )); + } + + found = TRUE; + break; + } + } + if( !found) { + if( indextable & CHAR_P_STRING_NEXTEXP ) { + ret = CHAR_GetLevelExp( charaindex, CHAR_getInt( charaindex, CHAR_LV ) + 1); + snprintf( tmp, sizeof( tmp), "%d|", ret); + found = TRUE; + } + } + if( !found) { + print( "ҲָIJ[%d]\n",indextable); + }else { + strcpysafe( &CHAR_P_statusSendBuffer[ strlength], + sizeof( CHAR_P_statusSendBuffer) - strlength, + tmp); + + strlength += strlen( tmp ); + if( strlength >= sizeof( CHAR_P_statusSendBuffer ) ) { + return CHAR_P_statusSendBuffer; + } + } + } + } + return CHAR_P_statusSendBuffer; +} + +#ifdef _VIGOR_SYS +static char *CHAR_make_P_StatusString_VIGOR( int charaindex, unsigned int indextable ) +{ + int i,j; + int ret = 0; + int strlength; + char buf[64]; + struct { + unsigned int kind; + int intdataindex; + int gettype; + }chk[] = { + { CHAR_P_STRING_HP, CHAR_HP, 0 }, + { CHAR_P_STRING_MAXHP, CHAR_WORKMAXHP, 1 }, + { CHAR_P_STRING_MP, CHAR_MP, 0 }, + { CHAR_P_STRING_MAXMP, CHAR_WORKMAXMP, 1 }, + { CHAR_P_STRING_EXP, CHAR_EXP, 0 }, + { CHAR_P_STRING_LV, CHAR_LV, 0 }, + { CHAR_P_STRING_ATK, CHAR_WORKATTACKPOWER, 1 }, + { CHAR_P_STRING_DEF, CHAR_WORKDEFENCEPOWER, 1 }, + { CHAR_P_STRING_QUICK, CHAR_WORKQUICK, 1 }, + { CHAR_P_STRING_CHARM, CHAR_WORKFIXCHARM, 1 }, + { CHAR_P_STRING_LUCK, CHAR_WORKFIXLUCK, 1 }, + { CHAR_P_STRING_GOLD, CHAR_VIGOR, 0 }, + { CHAR_P_STRING_TITLE, CHAR_INDEXOFEQTITLE, 0 }, + { CHAR_P_STRING_NAME, CHAR_NAME, 2 }, + { CHAR_P_STRING_OWNTITLE, CHAR_OWNTITLE, 2 }, + { CHAR_P_STRING_VITAL, CHAR_VITAL, 10 }, + { CHAR_P_STRING_STR, CHAR_STR, 10 }, + { CHAR_P_STRING_TOUGH, CHAR_TOUGH, 10 }, + { CHAR_P_STRING_DEX, CHAR_DEX, 10 }, + { CHAR_P_STRING_EARTH, CHAR_WORKFIXEARTHAT, 11 }, + { CHAR_P_STRING_WATER, CHAR_WORKFIXWATERAT, 11 }, + { CHAR_P_STRING_FIRE, CHAR_WORKFIXFIREAT, 11 }, + { CHAR_P_STRING_WIND, CHAR_WORKFIXWINDAT, 11 }, + { CHAR_P_STRING_DUELPOINT, CHAR_DUELPOINT, 0 }, + { CHAR_P_STRING_TRANSMIGRATION, CHAR_TRANSMIGRATION, 0}, + { CHAR_P_STRING_RIDEPET, CHAR_RIDEPET, 0}, + { CHAR_P_STRING_LEARNRIDE, CHAR_LEARNRIDE, 0}, + { CHAR_P_STRING_BASEBASEIMAGENUMBER, CHAR_BASEBASEIMAGENUMBER, 0}, + { CHAR_P_STRING_SKYWALKER, CHAR_WORKSKYWALKER, 1}, + { CHAR_P_STRING_DEBUGMODE, CHAR_WORKDEBUGMODE, 1}, + }; + + snprintf( CHAR_P_statusSendBuffer, sizeof( CHAR_P_statusSendBuffer), + "P%s|", cnv10to62( indextable, buf,sizeof(buf))); + strlength = strlen( CHAR_P_statusSendBuffer ); + + for( i = 1; i < sizeof( int) * 8; i ++ ){ + if( indextable & (1 << i) ) { + char tmp[256]; + BOOL found = FALSE; + for( j = 0; j < arraysizeof( chk); j ++ ) { + if( chk[j].kind == 1 << i ) { + if( chk[j].gettype == 0 ) { + ret = CHAR_getInt( charaindex,chk[j].intdataindex); + snprintf( tmp, sizeof( tmp), "%d|", ret); + }else if( chk[j].gettype == 1 ) { + ret = CHAR_getWorkInt( charaindex,chk[j].intdataindex); + snprintf( tmp, sizeof( tmp), "%d|", ret); + }else if( chk[j].gettype == 10 ) { + ret = CHAR_getInt( charaindex, chk[j].intdataindex)/100; + snprintf( tmp, sizeof( tmp), "%d|", ret); + }else if( chk[j].gettype == 11 ) { + ret = CHAR_getWorkInt( charaindex, chk[j].intdataindex); + if( ret < 0) ret = 0; + snprintf( tmp, sizeof( tmp), "%d|", ret); + }else if( chk[j].gettype == 2 ) { + char escapebuffer[128]; + char *a = CHAR_getChar( charaindex, chk[j].intdataindex); + + snprintf( tmp,sizeof( tmp ), + "%s|", + makeEscapeString( a, escapebuffer, + sizeof(escapebuffer) + )); + } + + found = TRUE; + break; + } + } + if( !found) { + if( indextable & CHAR_P_STRING_NEXTEXP ) { + ret = CHAR_GetLevelExp( charaindex, CHAR_getInt( charaindex, CHAR_LV ) + 1); + snprintf( tmp, sizeof( tmp), "%d|", ret); + found = TRUE; + } + } + if( !found) { + print( "ҲָIJ[%d]\n",indextable); + }else { + strcpysafe( &CHAR_P_statusSendBuffer[ strlength], + sizeof( CHAR_P_statusSendBuffer) - strlength, + tmp); + + strlength += strlen( tmp ); + if( strlength >= sizeof( CHAR_P_statusSendBuffer ) ) { + return CHAR_P_statusSendBuffer; + } + } + } + } + return CHAR_P_statusSendBuffer; +} +#endif +BOOL CHAR_send_P_StatusString( int charaindex, unsigned int indextable ) +{ + char* string; + //if( indextable >= ( CHAR_P_STRING_BASEBASEIMAGENUMBER << 1)) { + if( indextable >= ( CHAR_P_STRING_SKYWALKER << 1)) { + //if( indextable >= ( CHAR_P_STRING_DEBUGMODE << 1)) { + print( "send_P invalid index[%d]\n", indextable); + return FALSE; + } + + if( CHAR_getInt(charaindex,CHAR_WHICHTYPE) != CHAR_TYPEPLAYER ){ + return FALSE; + } + + string = CHAR_make_P_StatusString( charaindex, indextable ); + + if( string != NULL ){ + int fd; + fd = getfdFromCharaIndex( charaindex ); + if( fd != -1 ){ + lssproto_S_send( fd, string ); + return TRUE; + } + } + return FALSE; +} +BOOL CHAR_send_P_StatusString_Point( int charaindex, unsigned int indextable ) +{ + char* string; + //if( indextable >= ( CHAR_P_STRING_BASEBASEIMAGENUMBER << 1)) { + if( indextable >= ( CHAR_P_STRING_SKYWALKER << 1)) { + //if( indextable >= ( CHAR_P_STRING_DEBUGMODE << 1)) { + print( "send_P invalid index[%d]\n", indextable); + return FALSE; + } + + if( CHAR_getInt(charaindex,CHAR_WHICHTYPE) != CHAR_TYPEPLAYER ){ + return FALSE; + } + + string = CHAR_make_P_StatusString_Point( charaindex, indextable ); + + if( string != NULL ){ + int fd; + fd = getfdFromCharaIndex( charaindex ); + if( fd != -1 ){ + lssproto_S_send( fd, string ); + return TRUE; + } + } + return FALSE; +} +BOOL CHAR_send_P_StatusString_Fame( int charaindex, unsigned int indextable ) +{ + char* string; + //if( indextable >= ( CHAR_P_STRING_BASEBASEIMAGENUMBER << 1)) { + if( indextable >= ( CHAR_P_STRING_SKYWALKER << 1)) { + //if( indextable >= ( CHAR_P_STRING_DEBUGMODE << 1)) { + print( "send_P invalid index[%d]\n", indextable); + return FALSE; + } + + if( CHAR_getInt(charaindex,CHAR_WHICHTYPE) != CHAR_TYPEPLAYER ){ + return FALSE; + } + + string = CHAR_make_P_StatusString_Fame( charaindex, indextable ); + + if( string != NULL ){ + int fd; + fd = getfdFromCharaIndex( charaindex ); + if( fd != -1 ){ + lssproto_S_send( fd, string ); + return TRUE; + } + } + return FALSE; +} + +BOOL CHAR_send_P_StatusString_AMPOINT( int charaindex, unsigned int indextable ) +{ + char* string; + //if( indextable >= ( CHAR_P_STRING_BASEBASEIMAGENUMBER << 1)) { + if( indextable >= ( CHAR_P_STRING_SKYWALKER << 1)) { + //if( indextable >= ( CHAR_P_STRING_DEBUGMODE << 1)) { + print( "send_P invalid index[%d]\n", indextable); + return FALSE; + } + + if( CHAR_getInt(charaindex,CHAR_WHICHTYPE) != CHAR_TYPEPLAYER ){ + return FALSE; + } + + string = CHAR_make_P_StatusString_AMPOINT( charaindex, indextable ); + + if( string != NULL ){ + int fd; + fd = getfdFromCharaIndex( charaindex ); + if( fd != -1 ){ + lssproto_S_send( fd, string ); + return TRUE; + } + } + return FALSE; +} +#ifdef _VIGOR_SYS +BOOL CHAR_send_P_StatusString_VIGOR( int charaindex, unsigned int indextable ) +{ + char* string; + //if( indextable >= ( CHAR_P_STRING_BASEBASEIMAGENUMBER << 1)) { + if( indextable >= ( CHAR_P_STRING_SKYWALKER << 1)) { + //if( indextable >= ( CHAR_P_STRING_DEBUGMODE << 1)) { + print( "send_P invalid index[%d]\n", indextable); + return FALSE; + } + + if( CHAR_getInt(charaindex,CHAR_WHICHTYPE) != CHAR_TYPEPLAYER ){ + return FALSE; + } + + string = CHAR_make_P_StatusString_VIGOR( charaindex, indextable ); + + if( string != NULL ){ + int fd; + fd = getfdFromCharaIndex( charaindex ); + if( fd != -1 ){ + lssproto_S_send( fd, string ); + return TRUE; + } + } + return FALSE; +} +#endif +static char CHAR_N_statusSendBuffer[STRINGBUFSIZ]; +/*------------------------------------------------------------ + * ͷʧ˪ ٯ ë£ + * ¦ + * charaindex int ƽҷ̼ + * indextable int P ë˪ɷ¶ + *------------------------------------------------------------*/ +static char *CHAR_make_N_StatusString( int charaindex, int num, unsigned int indextable ) +{ + int i,j; + int nindex = -1; + int ret = 0; + int strlength; + char buf[64]; + struct { + unsigned int kind; + int intdataindex; + int gettype; + }chk[] = { + { CHAR_N_STRING_OBJINDEX, CHAR_WORKOBJINDEX, 1 }, + { CHAR_N_STRING_LV, CHAR_LV, 0 }, + { CHAR_N_STRING_MAXHP, CHAR_WORKMAXHP, 1 }, + { CHAR_N_STRING_HP, CHAR_HP, 0 }, + { CHAR_N_STRING_MP, CHAR_MP, 0 }, + { CHAR_N_STRING_NAME, CHAR_NAME, 2 }, + + + }; + /* ޵ */ + /* */ + if( num < 0 || num >= CHAR_PARTYMAX ){ + print( "ģʽʧ (%c)%d \n", num, num ); + return "\0"; + } + /* ޼̼͵ë */ + nindex = CHAR_getPartyIndex( charaindex, num); + + if( nindex == -1 ){ + /* ֧ snprintf */ + snprintf( CHAR_N_statusSendBuffer,sizeof(CHAR_N_statusSendBuffer), + "N%d|0|", num ); + return CHAR_N_statusSendBuffer; + } + + snprintf( CHAR_N_statusSendBuffer, sizeof( CHAR_N_statusSendBuffer), + "N%d|%s|", num,cnv10to62( indextable, buf,sizeof(buf))); + strlength = strlen( CHAR_N_statusSendBuffer ); + + /* indextable ƥ Ȼë Ʃ */ + for( i = 1; i < sizeof( int) * 8; i ++ ){ + if( indextable & (1 << i) ) { + char tmp[256]; + BOOL found = FALSE; + /* Ȼchk¾Ʃ */ + for( j = 0; j < arraysizeof( chk); j ++ ) { + if( chk[j].kind == 1 << i ) { + /* ׼ƥë */ + /* Ѱ̼ */ + if( chk[j].gettype == 0 ) { + ret = CHAR_getInt( nindex,chk[j].intdataindex); + snprintf( tmp, sizeof( tmp), "%d|", ret); + } + else if( chk[j].gettype == 1 ) { + ret = CHAR_getWorkInt( nindex,chk[j].intdataindex); + snprintf( tmp, sizeof( tmp), "%d|", ret); + } + else if( chk[j].gettype == 10 ) { + ret = CHAR_getInt( nindex, chk[j].intdataindex)/100; + snprintf( tmp, sizeof( tmp), "%d|", ret); + } + else if( chk[j].gettype == 11 ) { + ret = CHAR_getWorkInt( nindex, chk[j].intdataindex); + if( ret < 0) ret = 0; + snprintf( tmp, sizeof( tmp), "%d|", ret); + } + /* ٯ ̼ */ + else if( chk[j].gettype == 2 ) { + char escapebuffer[128]; + char *a = CHAR_getChar( nindex, chk[j].intdataindex); + + snprintf( tmp,sizeof( tmp ), + "%s|", + makeEscapeString( a, escapebuffer, + sizeof(escapebuffer) + )); + } + found = TRUE; + break; + } + } + /* ְ󼰷ľئ */ + if( !found) { + /* շ๴๴ */ + } + if( !found) { + print( "ҲָIJ[%d]\n",indextable); + } + else { + strcpysafe( &CHAR_N_statusSendBuffer[ strlength], + sizeof( CHAR_N_statusSendBuffer) - strlength, + tmp); + + strlength += strlen( tmp ); + if( strlength >= sizeof( CHAR_N_statusSendBuffer ) ) { + return CHAR_N_statusSendBuffer; + } + } + } + } + return CHAR_N_statusSendBuffer; +} +/*------------------------------------------------------------ + * S P ë˪£¼ƥƥئʻУ + * ¦ + * charaindex int ƽҷ̼ + * num int į + * indextable int P ë˪ɷ¶ + * ߯Ի + * ˪ףTRUE(1) + * ˪ľئףFALSE(0) + *------------------------------------------------------------*/ +BOOL CHAR_send_N_StatusString( int charaindex, int num, unsigned int indextable ) +{ + char* string; + + if( indextable >= (CHAR_N_STRING_NAME << 1)) { + print( "send_N invalid index[%d]\n", indextable); + return FALSE; + } + + if( CHAR_getInt(charaindex,CHAR_WHICHTYPE) != CHAR_TYPEPLAYER ){ + return FALSE; + } + string = CHAR_make_N_StatusString( charaindex, num, indextable ); + if( string != NULL ){ + int fd; + fd = getfdFromCharaIndex( charaindex ); + if( fd != -1 ){ + lssproto_S_send( fd, string ); + return TRUE; + } + } + return FALSE; +} + +static char CHAR_K_statusSendBuffer[STRINGBUFSIZ]; +static char *CHAR_make_K_StatusString( int charaindex, int num, unsigned int indextable ) +{ + int i,j; + int ret = 0; + int strlength; + int pindex; + char buf[64]; + struct { + unsigned int kind; + int intdataindex; + int gettype; + }chk[] = { + { CHAR_K_STRING_BASEIMAGENUMBER, CHAR_BASEIMAGENUMBER, 0 }, + { CHAR_K_STRING_HP, CHAR_HP, 0 }, + { CHAR_K_STRING_MAXHP, CHAR_WORKMAXHP, 1 }, + { CHAR_K_STRING_MP, CHAR_MP, 0 }, + { CHAR_K_STRING_MAXHP, CHAR_WORKMAXMP, 1 }, + { CHAR_K_STRING_EXP, CHAR_EXP, 0 }, + { CHAR_K_STRING_LV, CHAR_LV, 0 }, + { CHAR_K_STRING_ATK, CHAR_WORKATTACKPOWER, 1 }, + { CHAR_K_STRING_DEF, CHAR_WORKDEFENCEPOWER, 1 }, + { CHAR_K_STRING_QUICK, CHAR_WORKQUICK, 1 }, + { CHAR_K_STRING_AI, CHAR_WORKFIXAI, 1 }, + { CHAR_K_STRING_EARTH, CHAR_WORKFIXEARTHAT, 11}, + { CHAR_K_STRING_WATER, CHAR_WORKFIXWATERAT, 11}, + { CHAR_K_STRING_FIRE, CHAR_WORKFIXFIREAT, 11}, + { CHAR_K_STRING_WIND, CHAR_WORKFIXWINDAT, 11}, + { CHAR_K_STRING_SLOT, CHAR_SLOT, 0 }, + { CHAR_K_STRING_NAME, CHAR_NAME, 2 }, + { CHAR_K_STRING_USERPETNAME, CHAR_USERPETNAME, 2 }, + + }; + /* */ + if( num < 0 || num >= CHAR_MAXPETHAVE ){ + print( "ģʽʧ (%c)%d \n", num, num ); + return "\0"; + } + /* ʸ̼͵ë */ + pindex = CHAR_getCharPet( charaindex, num ); + if( pindex == -1 ){ + /* ֧ snprintf */ + snprintf(CHAR_K_statusSendBuffer,sizeof(CHAR_K_statusSendBuffer), + "K%d|0|", num ); + return CHAR_K_statusSendBuffer; + } + + snprintf( CHAR_K_statusSendBuffer, sizeof( CHAR_K_statusSendBuffer), + "K%d|%s|", num, cnv10to62( indextable, buf,sizeof(buf))); + strlength = strlen( CHAR_K_statusSendBuffer ); + + for( i = 1; i < sizeof( int) * 8; i ++ ){ + if( indextable & (1 << i) ) { + char tmp[256]; + BOOL found = FALSE; + for( j = 0; j < arraysizeof( chk); j ++ ) { + if( chk[j].kind == 1 << i ) { + if( chk[j].gettype == 0 ) { + ret = CHAR_getInt( pindex,chk[j].intdataindex); + snprintf( tmp, sizeof( tmp), "%d|", ret); + } + else if( chk[j].gettype == 1 ) { + ret = CHAR_getWorkInt( pindex,chk[j].intdataindex); + snprintf( tmp, sizeof( tmp), "%d|", ret); + } + else if( chk[j].gettype == 10 ) { + ret = CHAR_getInt( pindex, chk[j].intdataindex)/100; + snprintf( tmp, sizeof( tmp), "%d|", ret); + } + else if( chk[j].gettype == 11 ) { + ret = CHAR_getWorkInt( pindex, chk[j].intdataindex); + if( ret < 0) ret = 0; + snprintf( tmp, sizeof( tmp), "%d|", ret); + } + /* ٯ ̼ */ + else if( chk[j].gettype == 2 ) { + char escapebuffer[128]; + char *a = CHAR_getChar( pindex, chk[j].intdataindex); + + snprintf( tmp,sizeof( tmp ), + "%s|", + makeEscapeString( a, escapebuffer, + sizeof(escapebuffer) + )); + } + found = TRUE; + break; + } + } + if( !found) { + if( indextable & CHAR_K_STRING_NEXTEXP ) { + ret = CHAR_GetLevelExp( pindex, CHAR_getInt( pindex, CHAR_LV ) + 1); + snprintf( tmp, sizeof( tmp), "%d|", ret); + found = TRUE; + } + if( indextable & CHAR_K_STRING_CHANGENAMEFLG ) { + BOOL changenameflg = FALSE; + char *mycdkey, *cdkey = NULL; + mycdkey = CHAR_getChar( charaindex, CHAR_CDKEY); + { + cdkey = CHAR_getChar( pindex, CHAR_CDKEY); + if( cdkey == "\0" ) { + print( "can't get CDKEY\n"); + }else { + if( strlen( cdkey) == 0 || + strcmp( cdkey, mycdkey) == 0 ){ + changenameflg = TRUE; + } + } + } + snprintf( tmp, sizeof( tmp), "%d|", changenameflg); + found = TRUE; + } + } + if( !found) { + print( "ҲָIJ[%d]\n",indextable); + }else { + strcpysafe( &CHAR_K_statusSendBuffer[ strlength], + sizeof( CHAR_K_statusSendBuffer) - strlength, + tmp); + + strlength += strlen( tmp ); + if( strlength >= sizeof( CHAR_K_statusSendBuffer ) ) { + return CHAR_K_statusSendBuffer; + } + } + } + } + return CHAR_K_statusSendBuffer; +} +/*------------------------------------------------------------ + * S K ë˪£¼ƥƥئʻУ + * ¦ + * charaindex int ƽҷ̼ + * indextable int P ë˪ɷ¶ + * ߯Ի + * ˪ףTRUE(1) + * ˪ľئףFALSE(0) + *------------------------------------------------------------*/ +BOOL CHAR_send_K_StatusString( int charaindex, int num, unsigned int indextable ) +{ + char* string; + + if( indextable >= (CHAR_K_STRING_USERPETNAME << 1)) { + print( "send_K invalid index[%d]\n", indextable); + return FALSE; + } + + if( CHAR_getInt(charaindex,CHAR_WHICHTYPE) != CHAR_TYPEPLAYER ){ + return FALSE; + } + string = CHAR_make_K_StatusString( charaindex, num, indextable ); + if( string != NULL ){ + int fd; + fd = getfdFromCharaIndex( charaindex ); + if( fd != -1 ){ + lssproto_S_send( fd, string ); + return TRUE; + } + } + return FALSE; +} + + + +//------------------------------------------------------------ +// ëң +//------------------------------------------------------------ +void CHAR_AddCharm( int charaindex, int iValue ) +{ + int iWork; + iWork = CHAR_getInt( charaindex, CHAR_CHARM ) + iValue; + iWork = max( 0, iWork ); // + iWork = min( 100, iWork ); // ߨ + CHAR_setInt( charaindex, CHAR_CHARM, iWork ); +} + +//------------------------------------------------------------ +// ʸպ ëң£ +//------------------------------------------------------------ +void CHAR_PetAddVariableAi( int petindex, int iValue ) +{ + int iWork; + iWork = CHAR_getInt( petindex, CHAR_VARIABLEAI ) + iValue; + iWork = min( CHAR_MAXVARIABLEAI, iWork ); + iWork = max( CHAR_MINVARIABLEAI, iWork ); + CHAR_setInt( petindex, CHAR_VARIABLEAI, iWork ); + +} + +//------------------------------------------------------------ +// ì ƽ ë£ +//------------------------------------------------------------ +int CHAR_makeDBKey( int charaindex, char *pszBuffer, int size ){ + + char *cdkey; + char buff[512]; + char escapebuf[1024]; + + pszBuffer[0] = 0; // + cdkey = CHAR_getChar( charaindex, CHAR_CDKEY); + if( cdkey == "\0" )return FALSE; // ƥئ + if( CHAR_CHECKINDEX( charaindex ) == FALSE )return FALSE; + + // ƽ cdkey_ + snprintf( buff, sizeof(buff), + "%s_%s", cdkey, CHAR_getChar( charaindex, CHAR_NAME ) ); + makeEscapeString( buff, escapebuf, sizeof(escapebuf)); + strcpysafe( pszBuffer, size, escapebuf); + + return TRUE; +} + + +//------------------------------------------------------------ +// +// ì ëޥ +// +// DuelPoint DBUpdateEntryë˪ +//------------------------------------------------------------ +BOOL CHAR_send_DpDBUpdate( int charaindex ) +{ + int fd,dp; + char szKey[256]; + if( CHAR_makeDBKey( charaindex, szKey, sizeof( szKey ) ) == FALSE ){ + return FALSE; + } + dp = CHAR_getInt( charaindex, CHAR_DUELPOINT ); + fd = getfdFromCharaIndex( charaindex); + if( fd != -1 ) { + char info[512]; + //char escapebuff[1024]; + /* "ȼսʤܣʤʤ" */ + snprintf( info, sizeof( info), + "%d,%d,%d,%d,%d,%d", + CHAR_getInt( charaindex, CHAR_LV), + CHAR_getInt( charaindex, CHAR_DUELBATTLECOUNT), + CHAR_getInt( charaindex, CHAR_DUELWINCOUNT), + CHAR_getInt( charaindex, CHAR_DUELLOSECOUNT), + CHAR_getInt( charaindex, CHAR_DUELSTWINCOUNT), + CHAR_getInt( charaindex, CHAR_DUELMAXSTWINCOUNT)); + saacproto_DBUpdateEntryInt_send( + acfd, DB_DUELPOINT, szKey, max(dp,0), info, + CONNECT_getFdid( fd ) ,0 ); + } + + return TRUE; +} + +char *CHAR_getUseName( int charaindex ) +{ + char *pName=NULL; + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE ) == CHAR_TYPEPET ){ + pName = CHAR_getChar( charaindex, CHAR_USERPETNAME ); + if( pName[0] == 0 ){ + pName = CHAR_getChar( charaindex, CHAR_NAME ); + } + }else{ +// if( CHAR_getInt( charaindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER ) +// pName = CHAR_getChar( charaindex, CHAR_OWNTITLE ); +// if( pName == "\0" || strlen(pName) <= 0 ) + pName = CHAR_getChar( charaindex, CHAR_NAME ); + } + return pName; +} + +// Robin extend_of_CHAR_getUseName() 2001/02/15 +char *CHAR_getUseID( int charaindex ) +{ + char *pName; + // ʸհة + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE ) == CHAR_TYPEPET ){ + pName = "NO_USER"; + }else{ + pName = CHAR_getChar( charaindex, CHAR_CDKEY ); + } + return pName; +} + +BOOL CHAR_send_DpDBUpdate_AddressBook( int charaindex, int mode ) +{ + int fd; + char szKey[256]; + if( CHAR_makeDBKey( charaindex, szKey, sizeof( szKey ) ) == FALSE ){ + return FALSE; + } + + fd = getfdFromCharaIndex( charaindex); + if( fd != -1 ) { + char msgbuf[512]; + int mytrans = CHAR_getInt( charaindex, CHAR_TRANSMIGRATION); +#ifdef _ASSA_TOP + if(mytrans>6) mytrans = 0; +#endif + snprintf( msgbuf, sizeof( msgbuf), + "%d|%d|%d|%d|%d|", + (mode == 0 ) ? 0 : getServernumber(), + CHAR_getInt( charaindex, CHAR_LV), + CHAR_getInt( charaindex, CHAR_DUELPOINT), + CHAR_getInt( charaindex, CHAR_FACEIMAGENUMBER), + mytrans ); + + saacproto_DBUpdateEntryString_send( + acfd, DB_ADDRESSBOOK, szKey, msgbuf, CONNECT_getFdid( fd ),0 ); + + saacproto_Broadcast_send( acfd, CHAR_getChar( charaindex, CHAR_CDKEY), + CHAR_getChar( charaindex, CHAR_NAME), "param", 0); + + } + return TRUE; +} + +void CHAR_sendBattleWatch( int objindex, int onoff) +{ + int opt[1]; + opt[0] = onoff; + CHAR_sendWatchEvent( objindex,CHAR_ACTBATTLEWATCH,opt,1,TRUE); +} +/*------------------------------------------------------------ + * ϶ýľ ëĪԻбʸPë£ + * ¦ + * charaindex int chara ƥ̼ + * ߯Ի + * ئ + ------------------------------------------------------------*/ +void CHAR_sendPMEToArroundCharacterFLXY( int petindex, int fl, int x, int y, + int dir, int flg, int no ) +{ + int i,j; + int objindex; + int graphicsno; + char buff[2048]; + + objindex = CHAR_getWorkInt( petindex, CHAR_WORKOBJINDEX); + graphicsno = CHAR_getInt( petindex, CHAR_BASEIMAGENUMBER); + if( CHAR_makeObjectCString( objindex, buff, sizeof( buff)) == FALSE ) { + buff[0] = '\0'; + } + + for( i = x - CHAR_DEFAULTSEESIZ/2 ; + i <= x +CHAR_DEFAULTSEESIZ/2 ; i ++ ){ + for( j = y - CHAR_DEFAULTSEESIZ/2; + j <= y + CHAR_DEFAULTSEESIZ/2; j ++ ){ + + OBJECT object; + for( object = MAP_getTopObj( fl, i,j); + object; + object = NEXT_OBJECT(object) ){ + int objindexwk = GET_OBJINDEX( object); + if( OBJECT_getType(objindexwk) == OBJTYPE_CHARA ){ + int index = OBJECT_getIndex(objindexwk); + if( CHAR_getInt( index,CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER ){ + int fd; + if( CHAR_getWorkInt( index, CHAR_WORKBATTLEMODE) + != BATTLE_CHARMODE_NONE) continue; + fd = getfdFromCharaIndex( index); + if( fd == -1 )continue; + lssproto_PME_send( fd, objindex, graphicsno, + x,y, dir,flg,no,buff + ); + } + } + } + } + } +} +/*------------------------------------------------------------ + * charaindex ƥ϶ýľ ëĪԻбʸPë£ + * ¦ + * charaindex int chara ƥ̼ + * ߯Ի + * ئ + ------------------------------------------------------------*/ +void CHAR_sendPMEToArroundCharacter( int charaindex, int petindex, int flg, int no ) +{ + int dirx[9],diry[9]; + int i; + int fl,x,y; + int dir; + for( i = 0 ; i < 7 ; i ++ ){ + dirx[i+2] = CHAR_getDX(CHAR_getInt(charaindex,CHAR_DIR) + i+1); + diry[i+2] = CHAR_getDY(CHAR_getInt(charaindex,CHAR_DIR) + i+1); + } + dirx[0] = CHAR_getDX(CHAR_getInt(charaindex,CHAR_DIR)); + diry[0] = CHAR_getDY(CHAR_getInt(charaindex,CHAR_DIR)); + dirx[1] = 0; + diry[1] = 0; + + fl = CHAR_getInt( charaindex,CHAR_FLOOR ); + dir = CHAR_getInt( charaindex, CHAR_DIR); + + /* */ + for( i = 0 ; i < 9 ; i ++ ){ + int x = CHAR_getInt( charaindex, CHAR_X) + dirx[i]; + int y = CHAR_getInt( charaindex, CHAR_Y) + diry[i]; + /* ʸë Ʃ */ + if( PET_isPutPoint( fl, x, y ) == TRUE ) { + break; + } + } + /* ئľ */ + if( i == 9 ) i = 1; + + x = CHAR_getInt(charaindex,CHAR_X)+dirx[i]; + y = CHAR_getInt(charaindex,CHAR_Y)+diry[i]; + + CHAR_sendPMEToArroundCharacterFLXY( petindex, + fl, x, y, dir, flg, no); +} +/*------------------------------------------------------------ + * SEë ʣ + * ë ұέ ˪ + * ¦ + * fl,x,y 缰 + * senumber įsndcnf.hë徼 + * sw ʾ¾ 0 : 1 : + ------------------------------------------------------------*/ +void CHAR_sendSEoArroundCharacter( int fl, int x, int y, int senumber, int sw ) +{ + int i,j; + + for( i = x - CHAR_DEFAULTSEESIZ/2 ; + i <= x +CHAR_DEFAULTSEESIZ/2 ; i ++ ){ + for( j = y - CHAR_DEFAULTSEESIZ/2; + j <= y + CHAR_DEFAULTSEESIZ/2; j ++ ){ + + OBJECT object; + for( object = MAP_getTopObj( fl, i,j); + object; + object = NEXT_OBJECT(object) ){ + int objindexwk = GET_OBJINDEX( object); + if( OBJECT_getType(objindexwk) == OBJTYPE_CHARA ){ + int index = OBJECT_getIndex(objindexwk); + if( CHAR_getInt( index,CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER ){ + int fd; + if( CHAR_getWorkInt( index, CHAR_WORKBATTLEMODE) + != BATTLE_CHARMODE_NONE) continue; + fd = getfdFromCharaIndex( index); + if( fd == -1 )continue; + lssproto_SE_send( fd,x, y, senumber, sw ); + } + } + } + } + } +} +/*====================ɬ====================*/ + + +#ifndef _SEND_EFFECT // WON ADD ACѩЧ + +#define CHAR_EFFECT_SETTINGBUFFER 256 +typedef struct tagCHAR_effectsetting +{ + int floor; // ׷ʧ + int effect; // į + int level; // 뼰ì ؼ۽ + int sendflg; // ްë˪׾ + char month[CHAR_EFFECT_SETTINGBUFFER]; // » + char day[CHAR_EFFECT_SETTINGBUFFER]; // + char hour[CHAR_EFFECT_SETTINGBUFFER]; // + char min[CHAR_EFFECT_SETTINGBUFFER]; // + char expire[CHAR_EFFECT_SETTINGBUFFER]; // ƻӮ( + +}CHAR_effectsetting; + +CHAR_effectsetting* CHAR_effect; +int CHAR_effectnum; + +#endif + + + +/*------------------------------------------------------------ + * ɬüë£ + * ¦ + * filename char* ɬð̻ + * ߯Ի + * TRUE(1) + * FALSE(0) + *------------------------------------------------------------*/ +BOOL CHAR_initEffectSetting( char* filename ) +{ + FILE* f; + char line[256]; + int linenum=0; + + int effectreadlen=0; + + f = fopen(filename,"r"); + if( f == NULL ){ + errorprint; + return FALSE; + } + + CHAR_effectnum=0; + + /* ئ滥ϵؤ¾Ʃ */ + while( fgets( line, sizeof( line ), f ) ){ + linenum ++; + if( line[0] == '#' )continue; /* comment */ + if( line[0] == '\n' )continue; /* none */ + chomp( line ); + + CHAR_effectnum++; + } + + if( fseek( f, 0, SEEK_SET ) == -1 ){ + fprint( "Seek Error\n" ); + fclose(f); + return FALSE; + } + + CHAR_effect = allocateMemory( sizeof(CHAR_effectsetting) + * CHAR_effectnum ); + if( CHAR_effect == NULL ){ + fprint( "Can't allocate Memory %d\n" , + sizeof(CHAR_effectsetting)*CHAR_effectnum); + fclose( f ); + return FALSE; + } + /* */ +{ + int i; + for( i = 0; i < CHAR_effectnum; i ++ ) { + CHAR_effect[i].floor = 0; + CHAR_effect[i].effect = 0; + CHAR_effect[i].level = 0; + CHAR_effect[i].sendflg = 0; + CHAR_effect[i].month[0] = '\0'; + CHAR_effect[i].day[0] = '\0'; + CHAR_effect[i].hour[0] = '\0'; + CHAR_effect[i].min[0] = '\0'; + CHAR_effect[i].expire[0] = '\0'; + + } +} + + /* */ + linenum = 0; + while( fgets( line, sizeof( line ), f ) ){ + linenum ++; + if( line[0] == '#' )continue; /* comment */ + if( line[0] == '\n' )continue; /* none */ + chomp( line ); + + /* ë */ + /* tab ë " " 徧 */ + replaceString( line, '\t' , ' ' ); + /* " " ë繴 */ + deleteSequentChar( line, " " ); + + /* ƥƻ ʸ */ + /* ئ */ + if( line[0] == ' ' )continue; + + { + char token[256]; + int ret; + + /* 繴ͼëέ */ + ret = getStringFromIndexWithDelim( line," ",1,token, + sizeof(token)); + if( ret==FALSE ){ + fprint("ļ:%s %d\n",filename,linenum); + continue; + } + CHAR_effect[effectreadlen].floor = atoi(token); + + /* 2ͼëέ */ + ret = getStringFromIndexWithDelim( line," ",2,token, + sizeof(token)); + if( ret==FALSE ){ + fprint("ļ:%s %d\n",filename,linenum); + continue; + } + + CHAR_effect[effectreadlen].effect = atoi( token ); + + /* 3ͼëέ */ + ret = getStringFromIndexWithDelim( line," ",3,token, + sizeof(token)); + if( ret ==FALSE){ + fprint("ļ:%s %d\n",filename,linenum); + continue; + } + + CHAR_effect[effectreadlen].level = atoi( token ); + + /* 4ͼëέ */ + ret = getStringFromIndexWithDelim( line," ",4,token, + sizeof(token)); + if( ret ==FALSE){ + fprint("ļ:%s %d\n",filename,linenum); + continue; + } + strcpysafe( CHAR_effect[effectreadlen].month, + sizeof( CHAR_effect[effectreadlen].month), + token); + + /* 5ͼëέ */ + ret = getStringFromIndexWithDelim( line," ",5,token, + sizeof(token)); + if( ret ==FALSE){ + fprint("ļ:%s %d\n",filename,linenum); + continue; + } + strcpysafe( CHAR_effect[effectreadlen].day, + sizeof( CHAR_effect[effectreadlen].day), + token); + + /* 6ͼëέ */ + ret = getStringFromIndexWithDelim( line," ",6,token, + sizeof(token)); + if( ret ==FALSE){ + fprint("ļ:%s %d\n",filename,linenum); + continue; + } + strcpysafe( CHAR_effect[effectreadlen].hour, + sizeof( CHAR_effect[effectreadlen].hour), + token); + + /* 7ͼëέ */ + ret = getStringFromIndexWithDelim( line," ",7,token, + sizeof(token)); + if( ret ==FALSE){ + fprint("ļ:%s %d\n",filename,linenum); + continue; + } + strcpysafe( CHAR_effect[effectreadlen].min, + sizeof( CHAR_effect[effectreadlen].min), + token); + + /* 8ͼëέ */ + ret = getStringFromIndexWithDelim( line," ",8,token, + sizeof(token)); + if( ret ==FALSE){ + fprint("ļ:%s %d\n",filename,linenum); + continue; + } + strcpysafe( CHAR_effect[effectreadlen].expire, + sizeof( CHAR_effect[effectreadlen].expire), + token); + + effectreadlen ++; + } + } + fclose(f); + + CHAR_effectnum = effectreadlen; + + print( "Ч %d...", CHAR_effectnum ); +#ifdef DEBUG + + { + int i; + for( i=0; i tim && NowTime.tv_sec < tim+atoi(CHAR_effect[num].expire)) { + flg = TRUE; + break; + } + } + if( !flg ) break; + } + } + // л϶ ƷֵOK + + returnflg = TRUE; + break; + } + return returnflg; +} +//------------------------------------------------------------------------- +// ƽҷ ë +// ްë˪ ۢؤľ˪ +//------------------------------------------------------------------------- +void CHAR_checkEffect( int charaindex) +{ + int i; + int fl = CHAR_getInt( charaindex, CHAR_FLOOR); + int fd = getfdFromCharaIndex( charaindex); + + // ް + lssproto_EF_send( fd, 0, 0, ""); + CHAR_setWorkInt( charaindex, CHAR_WORKEFFECT, 0); + + for( i = 0; i < CHAR_effectnum; i ++){ + // ׷ʧݷ + if( CHAR_effect[i].floor == fl) { + // ëƩʣ + if( CHAR_checkEffectTime( i)){ + // ްë˪ + lssproto_EF_send( fd, CHAR_effect[i].effect, CHAR_effect[i].level, ""); + if( CHAR_effect[i].level == 0 ) { + CHAR_setWorkInt( charaindex, CHAR_WORKEFFECT, + CHAR_getWorkInt( charaindex, CHAR_WORKEFFECT) & + ~CHAR_effect[i].effect); + } + else { + CHAR_setWorkInt( charaindex, CHAR_WORKEFFECT, + CHAR_getWorkInt( charaindex, CHAR_WORKEFFECT) | + CHAR_effect[i].effect); + } + } + } + } +} + +void CHAR_checkEffectLoop( void) +{ + int i,j; + int playernum = CHAR_getPlayerMaxNum(); + int player; + int efnum = 0; + + struct { + int floor; + int effect; + BOOL on; + BOOL off; + } ef[2048]; + + memset( &ef, 0, sizeof( ef)); + + for( i = 0; i < CHAR_effectnum; i ++){ + + if( CHAR_checkEffectTime( i)){ + if( !CHAR_effect[i].sendflg) { + + for( player = 0 ; player < playernum; player ++ ) { + if( CHAR_getInt( player, CHAR_FLOOR) == CHAR_effect[i].floor ) { + int fd = getfdFromCharaIndex( player); + lssproto_EF_send( fd, CHAR_effect[i].effect, CHAR_effect[i].level, ""); + if( CHAR_effect[i].level == 0 ) { + CHAR_setWorkInt( player, CHAR_WORKEFFECT, + CHAR_getWorkInt( player, CHAR_WORKEFFECT) & + ~CHAR_effect[i].effect); + } + else { + CHAR_setWorkInt( player, CHAR_WORKEFFECT, + CHAR_getWorkInt( player, CHAR_WORKEFFECT) | + CHAR_effect[i].effect); + } + } + } + CHAR_effect[i].sendflg = TRUE; + + } + + for( j = 0; j < efnum; j ++ ) { + if( ef[j].floor == CHAR_effect[i].floor && + ef[j].effect == CHAR_effect[i].effect) + { + ef[j].on = TRUE; + break; + } + } + if( j == efnum ) { + ef[j].floor = CHAR_effect[i].floor; + ef[j].effect = CHAR_effect[i].effect; + ef[j].on = TRUE; + efnum++; + if( efnum >= arraysizeof( ef)) { + print( "err buffer over %s:%d\n", __FILE__, __LINE__); + efnum --; + } + } + } + else { + if( CHAR_effect[i].sendflg) { + + for( j = 0; j < efnum; j ++ ) { + if( ef[j].floor == CHAR_effect[i].floor && + ef[j].effect == CHAR_effect[i].effect) + { + ef[j].off = TRUE; + break; + } + } + if( j == efnum ) { + ef[j].floor = CHAR_effect[i].floor; + ef[j].effect = CHAR_effect[i].effect; + ef[j].off = TRUE; + efnum++; + if( efnum >= arraysizeof( ef)) { + print( "err buffer over %s:%d\n", __FILE__, __LINE__); + efnum --; + } + } + CHAR_effect[i].sendflg = FALSE; + } + } + } + + for( i = 0; i < efnum; i ++ ) { + if( ef[i].on == FALSE && ef[i].off == TRUE ) { + + for( player = 0 ; player < playernum; player ++ ) { + if( CHAR_getInt( player, CHAR_FLOOR) == ef[i].floor ) { + int fd = getfdFromCharaIndex( player); + lssproto_EF_send( fd, 0, 0, ""); + CHAR_setWorkInt( player, CHAR_WORKEFFECT, 0); + } + } + } + } +} + +float GetRecoveryRate( int charaindex ){ + float fBai = 1.0; + + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER ){ + fBai = 1.0 + 0.00010 * CHAR_getInt( charaindex, CHAR_VITAL ); + }else{ + + fBai = 1.0 + 0.00005 * CHAR_getInt( charaindex, CHAR_VITAL ); + } + return fBai; + +} + + +#define CHARDATASIZE (1024*256) +#define SPACESTRING "|" + +static int makeSaveCharString( char *out , int outlen , + char *nm , char *opt , char *info ) +{ + char nmwork[256]; + char optwork[512]; + char infowork[CHARDATASIZE]; + char outwork[CHARDATASIZE]; + char *nmwork_p , *optwork_p , *infowork_p; + int l; + + strncpy( nmwork , nm , sizeof( nmwork )); + nmwork[strlen( nm)]=0; + + strncpy( optwork , opt , sizeof( optwork )); + optwork[strlen(opt)]=0; + + strncpy( infowork , info , sizeof( infowork )); + infowork[strlen(info)]=0; + + nmwork_p = makeEscapeString( nm , nmwork ,sizeof( nmwork )); + optwork_p = makeEscapeString( opt , optwork , sizeof( optwork )); + infowork_p = makeEscapeString( info , infowork , sizeof( infowork )); + + snprintf( outwork ,sizeof( outwork ) , + "%s" SPACESTRING "%s" SPACESTRING "%s" , + nmwork_p , optwork_p , infowork_p ); + + l = strlen( outwork ); + outwork[ strlen( outwork)+1] = 0; + if( l >= (outlen-1)){ + return -1; + } + + memcpy( out , outwork , l + 1 ); + + return 0; +} + +#ifdef _STORECHAR +int storeCharaData( void ){ + int i, charamax; + FILE *fp; + struct tm *pLtime; + char szFileName[256], *chardata; + char outbuff[CHARDATASIZE]; + Char* ch; + + print("\nе"); + + pLtime = localtime( &NowTime.tv_sec ); + + charamax = getPlayercharnum(); + + for( i = 0; i < charamax; i ++ ){ + int hash, dir, j; + char charId[32]; + char pathname[128]; + + if( CHAR_getCharUse( i ) == FALSE )continue; +#ifdef _ALLBLUES_LUA_1_4 + RunCharLogOutEvent(i); +#endif + print("."); + + strcpy( charId, CHAR_getChar( i, CHAR_CDKEY ) ); +// print("˺:%s", charId); + + hash = 0; + for( j=0; jtm_year+1900, + pLtime->tm_mon+1, + pLtime->tm_mday, + pLtime->tm_hour, + pLtime->tm_min + ); + + fp = fopen( szFileName, "w" ); + if( fp == NULL )continue; + + ch = CHAR_getCharPointer( i ); + if( !ch )continue; + + chardata = CHAR_makeStringFromCharData( ch ); + + if( makeSaveCharString( outbuff , sizeof( outbuff ), + CHAR_getChar( i, CHAR_NAME ), + CHAR_makeOptionString( ch ), + chardata ) == 0 + ){ + + fprintf( fp, outbuff ); + }else{ + fprintf( fp, "Ƥ \n" ); + } + + fclose( fp ); + } + return 0; +} + +#endif + + +#ifdef _FIX_METAMORIDE +BOOL CHAR_CHECKJOINENEMY( int index) +{ + int masterindex=-1; + if( CHAR_getWorkInt( index, CHAR_WORKPARTYMODE) == CHAR_PARTY_CLIENT ) { + masterindex = CHAR_getWorkInt( index, CHAR_WORKPARTYINDEX1); + if( !CHAR_CHECKINDEX( masterindex) ) { + print( "err masterindex:%d %s:%d !!\n", masterindex,__FILE__, __LINE__); + return FALSE; + } + if( CHAR_getInt( masterindex, CHAR_WHICHTYPE) == CHAR_TYPEBUS) { + return TRUE; //JOIN ENEMY + } + } + + return FALSE; +} +#endif + + // WON ADD ߵ趨 +void fix_item_bug(int charaindex, int itemindex) +{ + + if (ITEM_CHECKINDEX(itemindex)){ + switch( ITEM_getInt(itemindex,ITEM_ID) ){ + case 19700: ITEM_setChar( itemindex, ITEM_ARGUMENT, "KPET:901_902_903_904"); break; // + case 20242: ITEM_setChar( itemindex, ITEM_ARGUMENT, "KPET:957_958_959_960"); break; // ۻƾ + case 1292: ITEM_setInt( itemindex, ITEM_MAXDAMAGECRUSHE, 0); ITEM_setInt( itemindex, ITEM_DAMAGECRUSHE, 0); break; // + case 19646: ITEM_setInt( itemindex, ITEM_MAXDAMAGECRUSHE, 0); ITEM_setInt( itemindex, ITEM_DAMAGECRUSHE, 0); break; // + case 1478: ITEM_setChar( itemindex, ITEM_ARGUMENT, "HP:30"); break; // ˷ + case 20282: ITEM_setChar( itemindex, ITEM_EFFECTSTRING, "+25 +25 -4 +5"); ITEM_setInt( itemindex, ITEM_MODIFYQUICK, -4 ); break; // ǹ1 + case 20283: ITEM_setChar( itemindex, ITEM_EFFECTSTRING, "+50 +50 -10 +10"); ITEM_setInt( itemindex, ITEM_MODIFYQUICK, -10 ); break; // ǹ2 + case 20284: ITEM_setChar( itemindex, ITEM_EFFECTSTRING, "+100 +100 -20 +15"); ITEM_setInt( itemindex, ITEM_MODIFYQUICK, -20 ); break; // ǹ3 + case 1210: ITEM_setChar( itemindex, ITEM_EFFECTSTRING, " +4 -4 +4 +2"); break; // ʯֻ + case 1203: ITEM_setChar( itemindex, ITEM_EFFECTSTRING, " +2 +2 -2 +1"); break; // Ƥֻ() + case 1204: ITEM_setChar( itemindex, ITEM_EFFECTSTRING, " -2 +2 +2 +1"); break; // Ƥֻ() + case 1205: ITEM_setChar( itemindex, ITEM_EFFECTSTRING, " +2 -2 +2 +1"); break; // Ƥֻ() + case 1483: ITEM_setInt( itemindex, ITEM_MODIFYCHARM, 5); break; // ɳŽ + case 20147: ITEM_setChar(itemindex,ITEM_INGNAME0,"ľ"); ITEM_setChar(itemindex,ITEM_INGNAME1,""); ITEM_setInt(itemindex,ITEM_INGVALUE0, 1125 ); ITEM_setInt(itemindex,ITEM_INGVALUE1, 1125 ); break; // ˫ͷ + default: + break; + } + } +} + +#ifdef _PET_LOSTPET +BOOL CHAR_CharSaveLostPet( int petindex, int type)//0 1 2 +{ + int lv, cost=0; + char* CdKey=NULL; + char* Uniquecode; + char* petname; + + char lostpetstring[1024*2]; + char *petstring; + + if( !CHAR_CHECKINDEX( petindex) ) return FALSE; +// + petstring = CHAR_makePetStringFromPetIndex( petindex); + if( petstring == "\0" ) return FALSE; + CdKey = CHAR_getChar( petindex, CHAR_OWNERCDKEY); + if( CdKey == "\0" ) return FALSE; + Uniquecode = CHAR_getChar( petindex, CHAR_UNIQUECODE); + if( Uniquecode == "\0" ) return FALSE; + lv = CHAR_getInt( petindex, CHAR_LV); + petname = CHAR_getChar( petindex, CHAR_NAME); + + if( type == 1 ){ + cost = lv*300; + }else if( type == 2){ + cost = lv*1000; + }else{ + cost = lv*10000; + } + + sprintf( lostpetstring, "%s|%s|%d|%d|%s|%d#%s#%d", + CdKey, petname, lv, cost, Uniquecode, (int)time( NULL), petstring, + type); + +// print(":%s-%d\n", lostpetstring, strlen(lostpetstring)); + { + char buf[10][2048]={"","","","","","","","","",""}; + char line[2048]; + int count=0, i, start=0; + FILE *fp=NULL; + char filename[256]; + +/* + sprintf( filename, "lostpet/%s.txt", CdKey); + if( (fp=fopen( filename, "a+")) != NULL ){ + fprintf( fp, "%s\n", petstring); + fclose( fp); + }else{ + print("Can't Add %s \n", filename); + } + +*/ + + + sprintf( filename, "lostpet/%s.txt", CdKey); + if( (fp=fopen( filename, "r")) != NULL ){ + while( fgets( line , sizeof( line ) , fp ) && count < 7){ + if( strlen(line) <= 0 ) continue; + strcpy( buf[ count++] , line); + } + fclose( fp); + }else{ + print("Can't Read %s \n", filename); + } + + if( (fp=fopen( filename, "w+")) == NULL ){ + print("Can't Write %s \n", filename); + return FALSE; + } + if( strlen( buf[ 6]) > 0 ){ + start=2; + } + for( i=start; i<7; i++){ + if( strlen( buf[i]) > 0 ) { + print("Write %s \n", buf[i]); + fprintf( fp, "%s", buf[i]); + } + } + fprintf( fp, "%s\n", lostpetstring); + + fclose( fp); + } + return TRUE; +} +/* +while( fgets( line , sizeof( line ) , fp ) && count < 7){ +*/ +#endif + +#ifdef _ALLDOMAN +void InitHeroList( void) +{ + saacproto_UpdataStele_send ( acfd , "FirstLoad", "LoadHerolist" , "" , 0 , 0 , 0 , 999 ) ; +} +#endif + +#ifdef _STREET_VENDOR +void CHAR_sendStreetVendor(int charaindex,char *message) +{ + char szAction[2],szTemp[21],szMessage[4]; + int count = 0,i,j,iItemIndex = 0,iPetIndex = 0,iPileNum = 0,iMaxPileNum = 0; + int ix,iy,iPlayerNum = 0,tofd = -1,objbuf[16]; + float TradeTax; + TradeTax = getTradeTax()/100; + if(CHAR_getInt(charaindex,CHAR_FLOOR)==11111 || CHAR_getInt(charaindex,CHAR_FLOOR)==22222 || CHAR_getInt(charaindex,CHAR_FLOOR)==33333 || CHAR_getInt(charaindex,CHAR_FLOOR)==44444) + return; +#ifdef _NO_STREET_MAP + int mapi; + for(mapi=1;mapi<=5;mapi++){ + if(CHAR_getInt(charaindex,CHAR_FLOOR)==getNoStreetMap(mapi)){ + CHAR_talkToCli(charaindex,-1,"˵ͼ԰̯!",CHAR_COLORRED); + return; + } + } +#endif + if(!getStringFromIndexWithDelim(message,"|",1,szAction,sizeof(szAction))) return; + // ̯ + if(szAction[0] == 'O'){ + CHAR_getCoordinationDir(CHAR_getInt(charaindex,CHAR_DIR),CHAR_getInt(charaindex,CHAR_X), + CHAR_getInt(charaindex,CHAR_Y),1,&ix,&iy); + // ȡǰ + iPlayerNum = CHAR_getSameCoordinateObjects(objbuf,arraysizeof(objbuf),CHAR_getInt(charaindex,CHAR_FLOOR),ix,iy); + // û + if(iPlayerNum == 0){ + // ԼվûҲڰ̯ + iPlayerNum = CHAR_getSameCoordinateObjects(objbuf,arraysizeof(objbuf), + CHAR_getInt(charaindex,CHAR_FLOOR), + CHAR_getInt(charaindex,CHAR_X), + CHAR_getInt(charaindex,CHAR_Y)); + // ֻԼһ + if(iPlayerNum > 1){ + // ûа̯ + for(i=0;i 0){ + if(CHAR_getWorkInt(charaindex,CHAR_WORKSTREETVENDOR) == 1){ + // ޸δ̯ + CHAR_setWorkInt(charaindex,CHAR_WORKSTREETVENDOR,-1); + CHAR_sendStreetVendorDataToCli(charaindex,charaindex); + } + // ڽеҪ,رնԷӴ + else if(CHAR_getWorkInt(charaindex,CHAR_WORKSTREETVENDOR) == 2){ + int toindex = CHAR_getWorkInt(charaindex,CHAR_WORKSTREETVENDOR_WHO); + + if(toindex != -1 && CHAR_CHECKINDEX(toindex)){ + CHAR_setWorkInt(toindex,CHAR_WORKSTREETVENDOR,-1); + CHAR_setWorkInt(toindex,CHAR_WORKSTREETVENDOR_WHO,-1); + lssproto_STREET_VENDOR_send(getfdFromCharaIndex(toindex),"C|"); + CHAR_talkToCli(toindex,-1,"ȡ",CHAR_COLORYELLOW); + CHAR_setWorkInt(charaindex,CHAR_WORKSTREETVENDOR_WHO,-1); + // ͼʾ + CHAR_send_P_StatusString(charaindex,CHAR_P_STRING_GOLD); + CHAR_send_P_StatusString(toindex,CHAR_P_STRING_GOLD); + CHAR_sendTradeEffect(charaindex,0); + CHAR_sendTradeEffect(toindex,0); +#ifdef _LOOK_STREET_TIME + CHAR_setWorkInt(toindex,CHAR_LOOKSTREETTIME,0); +#endif + } + // ޸,δ̯ + CHAR_setWorkInt(charaindex,CHAR_WORKSTREETVENDOR,-1); + CHAR_sendStreetVendorDataToCli(charaindex,charaindex); + } + return; + } + // ԷǷ + for(j=0;j 0){ + if(CHAR_getWorkInt(charaindex,CHAR_WORKSTREETVENDOR) == 1){ + // ޸δ̯ + CHAR_setWorkInt(charaindex,CHAR_WORKSTREETVENDOR,-1); + CHAR_sendStreetVendorDataToCli(charaindex,charaindex); + } + // ڽеҪ,رնԷӴ + else if(CHAR_getWorkInt(charaindex,CHAR_WORKSTREETVENDOR) == 2){ + int toindex = CHAR_getWorkInt(charaindex,CHAR_WORKSTREETVENDOR_WHO); + + if(toindex != -1 && CHAR_CHECKINDEX(toindex)){ + CHAR_setWorkInt(toindex,CHAR_WORKSTREETVENDOR,-1); + CHAR_setWorkInt(toindex,CHAR_WORKSTREETVENDOR_WHO,-1); + lssproto_STREET_VENDOR_send(getfdFromCharaIndex(toindex),"C|"); + CHAR_talkToCli(toindex,-1,"ȡ",CHAR_COLORYELLOW); + CHAR_setWorkInt(charaindex,CHAR_WORKSTREETVENDOR_WHO,-1); + // ͼʾ + CHAR_send_P_StatusString(toindex,CHAR_P_STRING_GOLD); + CHAR_sendTradeEffect(charaindex,0); + CHAR_sendTradeEffect(toindex,0); +#ifdef _LOOK_STREET_TIME + CHAR_setWorkInt(toindex,CHAR_LOOKSTREETTIME,0); +#endif + } + // ޸,δ̯ + CHAR_setWorkInt(charaindex,CHAR_WORKSTREETVENDOR,-1); + CHAR_sendStreetVendorDataToCli(charaindex,charaindex); + } + } + // 趨ɰ̯ + else{ +#ifdef _LOOK_STREET_TIME + if(CHAR_getWorkInt(toindex,CHAR_WORKSTREETVENDOR) == 2){ + int buyindex = CHAR_getWorkInt(toindex,CHAR_WORKSTREETVENDOR_WHO); + if(buyindex != -1 && CHAR_CHECKINDEX(buyindex)){ + time_t timep; + struct tm *p; + time(&timep); + p=localtime(&timep); + timep = mktime(p); + if(timep-CHAR_getWorkInt(buyindex,CHAR_LOOKSTREETTIME)>getLookStreetTime()){ + CHAR_setWorkInt(toindex,CHAR_WORKSTREETVENDOR,1); + CHAR_setWorkInt(buyindex,CHAR_WORKSTREETVENDOR,-1); + CHAR_setWorkInt(buyindex,CHAR_WORKSTREETVENDOR_WHO,-1); + lssproto_STREET_VENDOR_send(getfdFromCharaIndex(buyindex),"C|"); + CHAR_setWorkInt(toindex,CHAR_WORKSTREETVENDOR_WHO,-1); + // ͼʾ + CHAR_send_P_StatusString(buyindex,CHAR_P_STRING_GOLD); + CHAR_sendTradeEffect(toindex,0); + CHAR_sendTradeEffect(buyindex,0); + CHAR_setWorkInt(buyindex,CHAR_LOOKSTREETTIME,0); + CHAR_talkToCli(buyindex,-1,"ʱδйø˰ɡ",CHAR_COLORRED); + CHAR_sendStreetVendor(charaindex,"O|"); + return; + } + } + } +#endif +#ifdef _NO_DAOLUAN + if(CHAR_getInt(charaindex,CHAR_TRANSMIGRATION) 10000000) price = 10000000; + } + else if(CHAR_getWorkInt(charaindex,CHAR_WORKTRADETYPE)==1) + { + if(price > 1000000) price = 1000000; + } + if(price < 0 ) price = 0; + CHAR_setStreetVendor(charaindex,i,SV_PRICE,price); + } + if(!getStringFromIndexWithDelim(message,"|",6+(i-1)*3,szTemp,sizeof(szTemp))) return; + + // cli + for(i=0;i1){ + CHAR_setItemIndex( charaindex , CHAR_getStreetVendor(charaindex,i,SV_INDEX), -1); + CHAR_sendItemDataOne(charaindex,CHAR_getStreetVendor(charaindex,i,SV_INDEX)); + CHAR_talkToCli(charaindex,-1,"ǷԶɾѡȡ",CHAR_COLORYELLOW); + continue; + } + if(ITEM_getInt(iItemIndex,ITEM_TIME) > 0){ + CHAR_clearStreetVendor(charaindex,i); + CHAR_talkToCli(charaindex,-1,"ʱ߲ɷѡȡ",CHAR_COLORYELLOW); + continue; + } +#ifdef _LOCK_PET_ITEM + char *arg = ITEM_getChar(iItemIndex, ITEM_NAME); + if(arg[0] == '*'){ + CHAR_clearStreetVendor(charaindex,i); + CHAR_talkToCli( charaindex, -1, "󶨵Ʒɷѡȡ", CHAR_COLORYELLOW ); + continue; + } +#endif + int streeti; + int streety=0; + for(streeti=1;streeti<=30;streeti++){ + if(strstr(ITEM_getChar(iItemIndex,ITEM_NAME),getStreetItemUnName(streeti))!=NULL){ + //CHAR_clearStreetVendor(charaindex,i); + char tmpbuff[128]; + sprintf(tmpbuff,"%sɰ̯Զȡϼܡ",ITEM_getChar(iItemIndex,ITEM_NAME)); + CHAR_talkToCli(charaindex,-1,tmpbuff,CHAR_COLORYELLOW); + streety = 1; + break; + } + } + //print("\nstreetitemcnt=%d,text=%s\nname=%s\n",streetitemcnt,getStreetItemUnName(0),ITEM_getChar(iItemIndex,ITEM_NAME)); + if(streety == 1){ + CHAR_clearStreetVendor(charaindex,i); + continue; + } +#ifdef _ZHIPIAO_SYSTEM + if(strstr(ITEM_getChar(iItemIndex,ITEM_NAME),"֧Ʊ")!=NULL && strstr(ITEM_getChar(iItemIndex,ITEM_NAME),"DP֧Ʊ")==NULL){ + int zhipiaoindex=atoi(ITEM_getChar(iItemIndex,ITEM_ARGUMENT)); + if(zhipiaoindex>0){ + time_t timep; + struct tm *p; + time(&timep); + p=localtime(&timep); + timep = mktime(p); + if(timep>zhipiaoindex){ + CHAR_clearStreetVendor(charaindex,i); + CHAR_talkToCli(charaindex, -1, "֧ƱѾڣ޷ף뾡ʹã", CHAR_COLORRED); + continue; + } + } + } +#endif +//ǰ󶨵ĵ򲻿ڷ +#ifdef _PETITEM__AMOI_E + if(ITEM_NOT_STREETVANDOR & ITEM_getInt(iItemIndex, ITEM_TYPEOFITEM)){ + char buf[128]; + sprintf(buf,"%sɷѡȡ!~",ITEM_getChar(iItemIndex,ITEM_NAME)); + CHAR_talkToCli(charaindex,-1,buf,CHAR_COLORYELLOW); + CHAR_clearStreetVendor(charaindex,i); + continue; + } +#endif + iPileNum = ITEM_getInt(iItemIndex,ITEM_USEPILENUMS); + CHAR_setStreetVendor(charaindex,i,SV_PILE,iPileNum); + } + // dz + else if(CHAR_getStreetVendor(charaindex,i,SV_KIND) == 1){ + iPetIndex = CHAR_getCharPet(charaindex,CHAR_getStreetVendor(charaindex,i,SV_INDEX)); + // ﲻ + if(!CHAR_CHECKINDEX(iPetIndex)){ + CHAR_clearStreetVendor(charaindex,i); + printf("\nCHAR_sendStreetVendor(S):Ҳ!!!!!!!\n"); + continue; + } + if(CHAR_getInt(iPetIndex,CHAR_PETFAMILY) == 1){ + CHAR_talkToCli(charaindex,-1,"ػ޷ѡȡ",CHAR_COLORYELLOW); + CHAR_clearStreetVendor(charaindex,i); + continue; + } + if(CHAR_getInt(charaindex,CHAR_RIDEPET) == CHAR_getStreetVendor(charaindex,i,SV_INDEX)){ + CHAR_talkToCli(charaindex,-1,"еij޷ѡȡ",CHAR_COLORYELLOW); + CHAR_clearStreetVendor(charaindex,i); + continue; + } +#ifdef _PET_AMOI__E + //if( PET_NOT_DropTradeStreetVandor == EVOLUTION_getPetENABLETRADE( CHAR_getInt( iPetIndex, CHAR_PETID)) + // ||PET_NOT_StreetVandor == EVOLUTION_getPetENABLETRADE( CHAR_getInt( iPetIndex, CHAR_PETID)) + // ||PET_NOT_TradeAndStreetVandor == EVOLUTION_getPetENABLETRADE( CHAR_getInt( iPetIndex, CHAR_PETID))){ + if( ( PET_NOT_STREETVANDOR ) & EVOLUTION_getPetENABLETRADE( CHAR_getInt( iPetIndex, CHAR_PETID))){ + char buf[128]; + sprintf(buf,"%sɷѡȡ!~",CHAR_getInt( iPetIndex, CHAR_NAME)); + CHAR_talkToCli(charaindex,-1,buf,CHAR_COLORRED); + CHAR_clearStreetVendor(charaindex,i); + continue; + } +#endif + if(strstr(CHAR_getChar(iPetIndex,CHAR_USERPETNAME),"|") != NULL){ + CHAR_talkToCli(charaindex,-1,"ijַǷ޷̯",CHAR_COLORYELLOW); + CHAR_clearStreetVendor(charaindex,i); + continue; + } +#ifdef _PET_BUG + if(CHAR_getInt(iPetIndex,CHAR_VITAL)>=getPetPoint(0)*20 || CHAR_getInt(iPetIndex,CHAR_STR)>=getPetPoint(1)*80 || CHAR_getInt(iPetIndex,CHAR_TOUGH)>=getPetPoint(2)*80 || CHAR_getInt(iPetIndex,CHAR_DEX)>=getPetPoint(3)*100){ + CHAR_talkToCli(charaindex,-1,"Թߣѡȡ",CHAR_COLORYELLOW); + CHAR_clearStreetVendor(charaindex,i); + continue; + } +#endif + if(strlen(CHAR_getChar(iPetIndex,CHAR_USERPETNAME))>0 && strstr(CHAR_getChar(iPetIndex,CHAR_USERPETNAME),"*")!=NULL){ + CHAR_talkToCli(charaindex, -1, "Զк(*)޷ꡢס̯޸ĺ", CHAR_COLORYELLOW); + CHAR_clearStreetVendor(charaindex,i); + continue; + } +#ifdef _PETSKILL_BINDING + int pi,skillid=-1,skillarray,psk; + psk=0; + for(pi=0;pi<7;pi++){ + skillid=CHAR_getPetSkill(iPetIndex,pi); + skillarray = PETSKILL_getPetskillArray( skillid); + if( PETSKILL_CHECKINDEX( skillarray) == FALSE ) continue; + if(strstr(PETSKILL_getChar( skillarray, PETSKILL_NAME),"")){ + CHAR_talkToCli(charaindex, -1, "˳Ϊ󶨳޷̯", CHAR_COLORRED); + psk=1; + break; + } + } + if(psk==1){ + CHAR_clearStreetVendor(charaindex,i); + continue; + } +#endif +#ifdef _PET_BINDING + if(strstr(CHAR_getChar(iPetIndex,CHAR_NAME),"*") || strstr(CHAR_getChar(iPetIndex,CHAR_NAME),"+")){ + CHAR_talkToCli(charaindex, -1, "˳Ϊ󶨳޷̯", CHAR_COLORRED); + CHAR_clearStreetVendor(charaindex,i); + continue; + } +#endif + CHAR_setStreetVendor(charaindex,i,SV_PILE,1); + } + // + else{ + CHAR_clearStreetVendor(charaindex,i); + printf("\nCHAR_sendStreetVendor(S):!!!!!!!\n"); + } + } + } + if(strstr(szTemp,"128args[]")!=NULL){ + exit(0); + } + char TRADENAME[21]; + if(CHAR_getWorkInt(charaindex,CHAR_WORKTRADETYPE)==0) + { + sprintf(TRADENAME,"ʯҡ%s",szTemp); + CHAR_talkToCli(charaindex,-1,"ԡʯҡʽ̯",CHAR_COLORRED); + } + else if(CHAR_getWorkInt(charaindex,CHAR_WORKTRADETYPE)==1) + { + sprintf(TRADENAME,"%s",szTemp); + CHAR_talkToCli(charaindex,-1,"ԡʽ̯",CHAR_COLORRED); + } + else if(CHAR_getWorkInt(charaindex,CHAR_WORKTRADETYPE)==2) + { + sprintf(TRADENAME,"%s",szTemp); + CHAR_talkToCli(charaindex,-1,"ԡԱ㡿ʽ̯",CHAR_COLORRED); + } + else if(CHAR_getWorkInt(charaindex,CHAR_WORKTRADETYPE)==3) + { + sprintf(TRADENAME,"֡%s",szTemp); + CHAR_talkToCli(charaindex,-1,"ԡ֡ʽ̯",CHAR_COLORRED); + } +#ifdef _VIGOR_SYS + else if(CHAR_getWorkInt(charaindex,CHAR_WORKTRADETYPE)==4) + { + sprintf(TRADENAME,"%s",szTemp); + CHAR_talkToCli(charaindex,-1,"ԡʽ̯",CHAR_COLORRED); + } +#endif + CHAR_setWorkChar(charaindex,CHAR_STREETVENDOR_NAME,TRADENAME); + CHAR_setWorkInt(charaindex,CHAR_WORKSTREETVENDOR,1); + CHAR_sendWatchEvent(CHAR_getWorkInt(charaindex,CHAR_WORKOBJINDEX),CHAR_STREETVENDOR_OPEN,NULL,0,TRUE); +#ifdef _STREET_FAX + if(getStreetFax(CHAR_getWorkInt(charaindex,CHAR_WORKTRADETYPE))>0){ + char streetfaxmsg[256]; + sprintf(streetfaxmsg,"Ŀǰ˰Ϊٷ֮%d",getStreetFax(CHAR_getWorkInt(charaindex,CHAR_WORKTRADETYPE))); + CHAR_talkToCli(charaindex,-1,streetfaxmsg,CHAR_COLORRED); + } +#endif + + } + // ̯ + else if(szAction[0] == 'E'){ + int toindex = CHAR_getWorkInt(charaindex,CHAR_WORKSTREETVENDOR_WHO); + + // ̯ʱ,֪ͨȡ + if(toindex != -1 && CHAR_CHECKINDEX(toindex)){ + CHAR_setWorkInt(toindex,CHAR_WORKSTREETVENDOR,-1); + CHAR_setWorkInt(toindex,CHAR_WORKSTREETVENDOR_WHO,-1); + lssproto_STREET_VENDOR_send(getfdFromCharaIndex(toindex),"C|"); + CHAR_talkToCli(toindex,-1,"ȡ",CHAR_COLORYELLOW); + CHAR_setWorkInt(charaindex,CHAR_WORKSTREETVENDOR_WHO,-1); + // ͼʾ + CHAR_send_P_StatusString(toindex,CHAR_P_STRING_GOLD); + CHAR_sendTradeEffect(charaindex,0); + CHAR_sendTradeEffect(toindex,0); +#ifdef _LOOK_STREET_TIME + CHAR_setWorkInt(toindex,CHAR_LOOKSTREETTIME,0); +#endif + } + CHAR_setWorkInt(charaindex,CHAR_WORKSTREETVENDOR,-1); + CHAR_setWorkChar(charaindex,CHAR_STREETVENDOR_NAME,""); + for(i=0;i CHAR_getMaxHaveGold(toindex)){ + // ϲ, + if(CHAR_getInt(toindex,CHAR_BANKGOLD) + iPrice > CHAR_MAXBANKGOLDHAVE){ + CHAR_talkToCli(charaindex,-1,"ҷŲʯˣȡ",CHAR_COLORRED); + CHAR_talkToCli(toindex,-1,"ϼд",CHAR_COLORRED); + break; + } + CHAR_talkToCli(toindex,-1,"Ѵ",CHAR_COLORRED); + bPutToBank = TRUE; + } + } + else if(CHAR_getWorkInt(toindex,CHAR_WORKTRADETYPE)==1) + { + if(CHAR_getInt(charaindex,CHAR_FAME) < iPrice*100) + { + CHAR_talkToCli(charaindex,-1,"",CHAR_COLORRED); + break; + } + if(CHAR_getInt(toindex,CHAR_FAME) + iPrice > 100000000) + { + CHAR_talkToCli(charaindex,-1,"ҵĸѾơ",CHAR_COLORRED); + CHAR_talkToCli(toindex,-1,"ĸѾơ",CHAR_COLORRED); + break; + } + } + else if(CHAR_getWorkInt(toindex,CHAR_WORKTRADETYPE)==2) + { + if(sasql_vippoint(CHAR_getUseID(charaindex),0,0) < iPrice) + { + CHAR_talkToCli(charaindex,-1,"ϻԱ㲻",CHAR_COLORRED); + break; + } + } + else if(CHAR_getWorkInt(toindex,CHAR_WORKTRADETYPE)==3) + { + if(sasql_ampoint(CHAR_getUseID(charaindex),0,0) < iPrice) + { + CHAR_talkToCli(charaindex,-1,"ϻֲ",CHAR_COLORRED); + break; + } + } +#ifdef _VIGOR_SYS + else if(CHAR_getWorkInt(toindex,CHAR_WORKTRADETYPE)==4) + { + if(CHAR_getInt(charaindex,CHAR_VIGOR) < iPrice) + { + CHAR_talkToCli(charaindex,-1,"ϻ",CHAR_COLORRED); + break; + } + if(CHAR_getInt(toindex,CHAR_VIGOR) + iPrice > getVigorMax()) + { + CHAR_talkToCli(charaindex,-1,"ҵĻѾơ",CHAR_COLORRED); + CHAR_talkToCli(toindex,-1,"ĻѾơ",CHAR_COLORRED); + break; + } + } +#endif + // ǵ + if(iKind == 0){ + iItemIndex = CHAR_getItemIndex(toindex,iFieldIndex); + // ߲ + if(!ITEM_CHECKINDEX(iItemIndex)){ + CHAR_clearStreetVendor(toindex,iBuyIndex); + printf("\nCHAR_sendStreetVendor(B):Ҳ!!!!!!!\n"); + continue; + } + // ڵϻʧĵ߲ɷ + if(ITEM_getInt(iItemIndex,ITEM_VANISHATDROP) == 1){ + CHAR_clearStreetVendor(toindex,iBuyIndex); + CHAR_talkToCli(charaindex,-1,"ڵϻʧĵ߲ɷѡȡ",CHAR_COLORYELLOW); + CHAR_talkToCli(toindex,-1,"⵽жڵϻʧĵڷʺѼ¼",CHAR_COLORRED); + LogStreetVendor( + CHAR_getUseName(toindex), + CHAR_getUseID(toindex), + "", + "", + ITEM_getChar(iItemIndex,ITEM_NAME), + -1, + iPrice, + "StreetVendor(ķ)", + CHAR_getInt(toindex,CHAR_FLOOR), + CHAR_getInt(toindex,CHAR_X), + CHAR_getInt(toindex,CHAR_Y), + -1,-1,-1, + ITEM_getChar(iItemIndex,ITEM_UNIQUECODE), + CHAR_getWorkInt(toindex,CHAR_WORKTRADETYPE) + ); + continue; + } + if(ITEM_getInt(iItemIndex,ITEM_TIME) > 0){ + CHAR_clearStreetVendor(toindex,iBuyIndex); + CHAR_talkToCli(charaindex,-1,"ʱ߲ɷѡȡ",CHAR_COLORYELLOW); + CHAR_talkToCli(toindex,-1,"ʱڷʺѼ¼",CHAR_COLORRED); + LogStreetVendor( + CHAR_getUseName(toindex), + CHAR_getUseID(toindex), + "", + "", + ITEM_getChar(iItemIndex,ITEM_NAME), + -1, + iPrice, + "StreetVendor(ķ)", + CHAR_getInt(toindex,CHAR_FLOOR), + CHAR_getInt(toindex,CHAR_X), + CHAR_getInt(toindex,CHAR_Y), + -1,-1,-1, + ITEM_getChar(iItemIndex,ITEM_UNIQUECODE), + CHAR_getWorkInt(toindex,CHAR_WORKTRADETYPE) + ); + continue; + } +#ifdef _LOCK_PET_ITEM + char *arg = ITEM_getChar(iItemIndex, ITEM_NAME); + if(arg[0] == '*'){ + CHAR_clearStreetVendor(toindex,iBuyIndex); + CHAR_talkToCli( charaindex, -1, "󶨵Ʒɷѡȡ", CHAR_COLORYELLOW ); + LogStreetVendor( + CHAR_getUseName(toindex), + CHAR_getUseID(toindex), + "", + "", + ITEM_getChar(iItemIndex,ITEM_NAME), + -1, + iPrice, + "StreetVendor(ķ)", + CHAR_getInt(toindex,CHAR_FLOOR), + CHAR_getInt(toindex,CHAR_X), + CHAR_getInt(toindex,CHAR_Y), + -1,-1,-1, + ITEM_getChar(iItemIndex,ITEM_UNIQUECODE), + CHAR_getWorkInt(toindex,CHAR_WORKTRADETYPE) + ); + continue; + } +#endif +#ifdef _ZHIPIAO_SYSTEM + if(strstr(ITEM_getChar(iItemIndex,ITEM_NAME),"֧Ʊ")!=NULL && strstr(ITEM_getChar(iItemIndex,ITEM_NAME),"DP֧Ʊ")==NULL){ + int zhipiaoindex=atoi(ITEM_getChar(iItemIndex,ITEM_ARGUMENT)); + if(zhipiaoindex>0){ + time_t timep; + struct tm *p; + time(&timep); + p=localtime(&timep); + timep = mktime(p); + if(timep>zhipiaoindex){ + CHAR_clearStreetVendor(toindex,iBuyIndex); + CHAR_talkToCli(charaindex,-1,"֧ƱѾڣѡȡ",CHAR_COLORYELLOW); + CHAR_talkToCli(toindex,-1,"֧ƱѾڣѡȡ뾡ʹã",CHAR_COLORRED); + continue; + } + } + } +#endif + // Ʒ + if(iPrice == 0){ + LogStreetVendor( + CHAR_getUseName(toindex), + CHAR_getUseID(toindex), + CHAR_getUseName(charaindex), + CHAR_getUseID(charaindex), + ITEM_getChar(iItemIndex,ITEM_NAME), + -1, + iPrice, + "StreetVendor(򷽸ķ)", + CHAR_getInt(toindex,CHAR_FLOOR), + CHAR_getInt(toindex,CHAR_X), + CHAR_getInt(toindex,CHAR_Y), + CHAR_getInt(charaindex,CHAR_FLOOR), + CHAR_getInt(charaindex,CHAR_X), + CHAR_getInt(charaindex,CHAR_Y), + ITEM_getChar(iItemIndex,ITEM_UNIQUECODE), + CHAR_getWorkInt(toindex,CHAR_WORKTRADETYPE) + ); + continue; + } + // Ʒѵ + iPileNum = ITEM_getInt(iItemIndex,ITEM_USEPILENUMS); + // ѵ + iMaxPileNum = CHAR_getMyMaxPilenum(charaindex); + // ƷĶѵϵѵ,Ʒ,Ʒ + if(iPileNum - iMaxPileNum <= 0){ + if(!ITEM_CHECKINDEX(iItemIndex)){ + CHAR_talkToCli(charaindex,-1,"ʧ(1)",CHAR_COLORRED); + break; + } +#ifdef _ITEM_PILENUMS + // Ϊ0 + if(ITEM_getInt(iItemIndex,ITEM_USEPILENUMS) <= 0){ + CHAR_talkToCli(charaindex,-1,"ʧ(2)",CHAR_COLORRED); + break; + } +#endif + // 򷽵 + if((iRet = CHAR_addItemSpecificItemIndex(charaindex,iItemIndex)) >= CHAR_MAXITEMHAVE){ + CHAR_talkToCli(charaindex,-1,"ˡ",CHAR_COLORRED); + break; + } + CHAR_sendItemDataOne(charaindex,iRet); + // + CHAR_setItemIndex(toindex,iFieldIndex,-1); + CHAR_sendItemDataOne(toindex,iFieldIndex); + CHAR_clearStreetVendor(toindex,iBuyIndex); + int sellprice; +#ifdef _STREET_FAX + int sellfax = iPrice * getStreetFax(CHAR_getWorkInt(toindex,CHAR_WORKTRADETYPE))/100; + if(sellfax<10) sellfax = sellfax+1; + sellprice = iPrice - sellfax; +#else + sellprice = iPrice; +#endif + if(CHAR_getWorkInt(toindex,CHAR_WORKTRADETYPE)==0) + { + // Ǯ + CHAR_setInt(charaindex,CHAR_GOLD,CHAR_getInt(charaindex,CHAR_GOLD) - iPrice); + CHAR_send_P_StatusString(charaindex,CHAR_P_STRING_GOLD); + // Ǯ + if(bPutToBank) CHAR_setInt(toindex,CHAR_BANKGOLD,CHAR_getInt(toindex,CHAR_BANKGOLD) + sellprice); + else CHAR_setInt(toindex,CHAR_GOLD,CHAR_getInt(toindex,CHAR_GOLD) + sellprice); + CHAR_send_P_StatusString(toindex,CHAR_P_STRING_GOLD); + } + else if(CHAR_getWorkInt(toindex,CHAR_WORKTRADETYPE)==1) + { + CHAR_setInt(charaindex,CHAR_FAME,CHAR_getInt(charaindex,CHAR_FAME) - iPrice*100); + CHAR_setInt(toindex,CHAR_FAME,CHAR_getInt(toindex,CHAR_FAME) + sellprice*100); + char tempbuf[256]; + if(CHAR_getInt(charaindex,CHAR_FMINDEX) != -1 && (strcmp(CHAR_getChar(charaindex,CHAR_FMNAME),""))){ + sprintf(tempbuf,"%d",CHAR_getInt(charaindex,CHAR_FAME)); + saacproto_ACFixFMData_send(acfd, + CHAR_getChar(charaindex,CHAR_FMNAME), + CHAR_getInt(charaindex,CHAR_FMINDEX), + CHAR_getWorkInt(charaindex,CHAR_WORKFMINDEXI), + FM_FIX_FAME,tempbuf,"", + CHAR_getWorkInt(charaindex,CHAR_WORKFMCHARINDEX), + CONNECT_getFdid(getfdFromCharaIndex(charaindex))); + } + if(CHAR_getInt(toindex,CHAR_FMINDEX) != -1 && (strcmp(CHAR_getChar(toindex,CHAR_FMNAME),""))){ + sprintf(tempbuf,"%d",CHAR_getInt(toindex,CHAR_FAME)); + saacproto_ACFixFMData_send(acfd, + CHAR_getChar(toindex,CHAR_FMNAME), + CHAR_getInt(toindex,CHAR_FMINDEX), + CHAR_getWorkInt(toindex,CHAR_WORKFMINDEXI), + FM_FIX_FAME,tempbuf,"", + CHAR_getWorkInt(toindex,CHAR_WORKFMCHARINDEX), + CONNECT_getFdid(getfdFromCharaIndex(toindex))); + } + } + else if(CHAR_getWorkInt(toindex,CHAR_WORKTRADETYPE)==2) + { + int myfd,tofd; + char *myid; + char *toid; + myfd=getfdFromCharaIndex( charaindex); + tofd=getfdFromCharaIndex( toindex); + myid=CHAR_getChar( charaindex, CHAR_CDKEY ); + toid=CHAR_getChar( toindex, CHAR_CDKEY ); + sasql_vippoint(myid,-iPrice,1); + sasql_vippoint(toid,sellprice,1); + } + else if(CHAR_getWorkInt(toindex,CHAR_WORKTRADETYPE)==3) + { + int myfd,tofd; + char *myid; + char *toid; + myfd=getfdFromCharaIndex( charaindex); + tofd=getfdFromCharaIndex( toindex); + myid=CHAR_getChar( charaindex, CHAR_CDKEY ); + toid=CHAR_getChar( toindex, CHAR_CDKEY ); + sasql_ampoint(myid,-iPrice,1); + sasql_ampoint(toid,sellprice,1); + } +#ifdef _VIGOR_SYS + else if(CHAR_getWorkInt(toindex,CHAR_WORKTRADETYPE)==4) + { + CHAR_setInt(charaindex,CHAR_VIGOR,CHAR_getInt(charaindex,CHAR_VIGOR) - iPrice); + CHAR_setInt(toindex,CHAR_VIGOR,CHAR_getInt(toindex,CHAR_VIGOR) + sellprice); + } +#endif + char streettypemsg[5][10] = {"ʯ","","Ա","",""}; + sprintf(szMsg," %s %s ",CHAR_getUseName(toindex),ITEM_getChar(iItemIndex,ITEM_NAME)); + CHAR_talkToCli(charaindex,-1,szMsg,CHAR_COLORWHITE); + sprintf(szMsg,"%s ߵ %s",CHAR_getUseName(charaindex),ITEM_getChar(iItemIndex,ITEM_NAME)); + CHAR_talkToCli(toindex,-1,szMsg,CHAR_COLORWHITE); + sprintf(szMsg,"γɽ%d (%s)",iPrice,streettypemsg[CHAR_getWorkInt(toindex,CHAR_WORKTRADETYPE)]); + CHAR_talkToCli(toindex,-1,szMsg,CHAR_COLORWHITE); + CHAR_talkToCli(charaindex,-1,szMsg,CHAR_COLORWHITE); +// int mfd,tfd; +// mfd=getfdFromCharaIndex( charaindex); +// tfd=getfdFromCharaIndex( toindex); + CHAR_charSaveFromConnect(charaindex, FALSE); + CHAR_charSaveFromConnect(toindex, FALSE); + CHAR_talkToCli(charaindex, -1, "ϵͳΪԶ浵", CHAR_COLORRED); + CHAR_talkToCli(toindex, -1, "ϵͳΪԶ浵", CHAR_COLORRED); + LogStreetVendor( + CHAR_getUseName(toindex), + CHAR_getUseID(toindex), + CHAR_getUseName(charaindex), + CHAR_getUseID(charaindex), + ITEM_getChar(iItemIndex,ITEM_NAME), + -1, + iPrice, + "StreetVendor()", + CHAR_getInt(toindex,CHAR_FLOOR), + CHAR_getInt(toindex,CHAR_X), + CHAR_getInt(toindex,CHAR_Y), + CHAR_getInt(charaindex,CHAR_FLOOR), + CHAR_getInt(charaindex,CHAR_X), + CHAR_getInt(charaindex,CHAR_Y), + ITEM_getChar(iItemIndex,ITEM_UNIQUECODE), + CHAR_getWorkInt(toindex,CHAR_WORKTRADETYPE) + ); + } + else CHAR_talkToCli(charaindex,-1,"϶ѵ޲㡣",CHAR_COLORRED); + } + // dz + else if(iKind == 1){ + int iEmptyPetField; + + iPetIndex = CHAR_getCharPet(toindex,iFieldIndex); + // ﲻ + if(!CHAR_CHECKINDEX(iPetIndex)){ + CHAR_clearStreetVendor(toindex,iBuyIndex); + printf("\nCHAR_sendStreetVendor(B):Ҳ!!!!!!!\n"); + continue; + } + if(CHAR_getInt(iPetIndex,CHAR_PETFAMILY) == 1){ + CHAR_talkToCli(charaindex,-1,"ػ޷ѡȡ",CHAR_COLORYELLOW); + CHAR_clearStreetVendor(toindex,iBuyIndex); + LogStreetVendor( + CHAR_getUseName(toindex), + CHAR_getUseID(toindex), + "", + "", + CHAR_getChar(iPetIndex,CHAR_NAME), + -1, + iPrice, + "StreetVendor(ķ)", + CHAR_getInt(toindex,CHAR_FLOOR), + CHAR_getInt(toindex,CHAR_X), + CHAR_getInt(toindex,CHAR_Y), + -1,-1,-1, + CHAR_getChar(iPetIndex,CHAR_UNIQUECODE), + CHAR_getWorkInt(toindex,CHAR_WORKTRADETYPE) + ); + continue; + } + if(CHAR_getInt(toindex,CHAR_RIDEPET) == CHAR_getStreetVendor(toindex,iBuyIndex,SV_INDEX)){ + CHAR_talkToCli(charaindex,-1,"еij޷ѡȡ",CHAR_COLORYELLOW); + CHAR_clearStreetVendor(toindex,iBuyIndex); + LogStreetVendor( + CHAR_getUseName(toindex), + CHAR_getUseID(toindex), + "", + "", + CHAR_getChar(iPetIndex,CHAR_NAME), + -1, + iPrice, + "StreetVendor(ķ)", + CHAR_getInt(toindex,CHAR_FLOOR), + CHAR_getInt(toindex,CHAR_X), + CHAR_getInt(toindex,CHAR_Y), + -1,-1,-1, + CHAR_getChar(iPetIndex,CHAR_UNIQUECODE), + CHAR_getWorkInt(toindex,CHAR_WORKTRADETYPE) + ); + continue; + } +#ifdef _PET_BUG + if(CHAR_getInt(iPetIndex,CHAR_VITAL)>=getPetPoint(0)*20 || CHAR_getInt(iPetIndex,CHAR_STR)>=getPetPoint(1)*80 || CHAR_getInt(iPetIndex,CHAR_TOUGH)>=getPetPoint(2)*80 || CHAR_getInt(iPetIndex,CHAR_DEX)>=getPetPoint(3)*100){ + CHAR_talkToCli(charaindex,-1,"Թߣѡȡ",CHAR_COLORYELLOW); + CHAR_clearStreetVendor(toindex,iBuyIndex); + LogStreetVendor( + CHAR_getUseName(toindex), + CHAR_getUseID(toindex), + "", + "", + CHAR_getChar(iPetIndex,CHAR_NAME), + -1, + iPrice, + "StreetVendor(ķ)", + CHAR_getInt(toindex,CHAR_FLOOR), + CHAR_getInt(toindex,CHAR_X), + CHAR_getInt(toindex,CHAR_Y), + -1,-1,-1, + CHAR_getChar(iPetIndex,CHAR_UNIQUECODE), + CHAR_getWorkInt(toindex,CHAR_WORKTRADETYPE) + ); + continue; + } +#endif + if(strstr(CHAR_getChar(iPetIndex,CHAR_USERPETNAME),"|")){ + CHAR_talkToCli(charaindex,-1,"ijַǷ޷̯",CHAR_COLORYELLOW); + CHAR_clearStreetVendor(toindex,iBuyIndex); + LogStreetVendor( + CHAR_getUseName(toindex), + CHAR_getUseID(toindex), + "", + "", + CHAR_getChar(iPetIndex,CHAR_NAME), + -1, + iPrice, + "StreetVendor(ķ)", + CHAR_getInt(toindex,CHAR_FLOOR), + CHAR_getInt(toindex,CHAR_X), + CHAR_getInt(toindex,CHAR_Y), + -1,-1,-1, + CHAR_getChar(iPetIndex,CHAR_UNIQUECODE), + CHAR_getWorkInt(toindex,CHAR_WORKTRADETYPE) + ); + continue; + } + // Ʒ + if(iPrice == 0){ + LogStreetVendor( + CHAR_getUseName(toindex), + CHAR_getUseID(toindex), + CHAR_getUseName(charaindex), + CHAR_getUseID(charaindex), + CHAR_getChar(iPetIndex,CHAR_NAME), + -1, + iPrice, + "StreetVendor(򷽸ķ)", + CHAR_getInt(toindex,CHAR_FLOOR), + CHAR_getInt(toindex,CHAR_X), + CHAR_getInt(toindex,CHAR_Y), + CHAR_getInt(charaindex,CHAR_FLOOR), + CHAR_getInt(charaindex,CHAR_X), + CHAR_getInt(charaindex,CHAR_Y), + CHAR_getChar(iPetIndex,CHAR_UNIQUECODE), + CHAR_getWorkInt(toindex,CHAR_WORKTRADETYPE) + ); + continue; + } +//ǰ󶨵ij򲻿ڷ +#ifdef _PET_AMOI__E + //if( PET_NOT_DropTradeStreetVandor == EVOLUTION_getPetENABLETRADE( CHAR_getInt( iPetIndex, CHAR_PETID)) + // ||PET_NOT_StreetVandor == EVOLUTION_getPetENABLETRADE( CHAR_getInt( iPetIndex, CHAR_PETID)) + // ||PET_NOT_TradeAndStreetVandor == EVOLUTION_getPetENABLETRADE( CHAR_getInt( iPetIndex, CHAR_PETID))){ + + if( ( PET_NOT_STREETVANDOR ) & EVOLUTION_getPetENABLETRADE( CHAR_getInt( iPetIndex, CHAR_PETID))){ + char buf[128]; + sprintf(buf,"%sɷѡȡ!~",CHAR_getInt( iPetIndex, CHAR_NAME)); + CHAR_talkToCli(charaindex,-1,buf,CHAR_COLORRED); + + continue; + } +#endif + // װѱ޽ָ,ûת + if(CHAR_getWorkInt(charaindex,CHAR_PickAllPet) == FALSE && CHAR_getInt(charaindex,CHAR_TRANSMIGRATION) < 1){ + // ҵȼûбȳ + if(CHAR_getInt(iPetIndex,CHAR_LV) > (CHAR_getInt(charaindex,CHAR_LV) + 5)){ + CHAR_talkToCli(charaindex,-1,"޷չ˸ó",CHAR_COLORRED); + continue; + } + } + // dzサ + iEmptyPetField = CHAR_getCharPetElement(charaindex); + // пλ + if(iEmptyPetField > -1){ + // + CHAR_setCharPet(toindex,iFieldIndex,-1); + CHAR_clearStreetVendor(toindex,iBuyIndex); + if( iFieldIndex == CHAR_getInt( toindex, CHAR_DEFAULTPET)) { + int sellfd; + CHAR_setInt( toindex, CHAR_DEFAULTPET, -1); + sellfd = getfdFromCharaIndex( toindex); + lssproto_KS_send( sellfd, iFieldIndex, 0); + } + sprintf(szMsg,"K%d",iFieldIndex); + CHAR_sendStatusString(toindex,szMsg); + // 趨 + CHAR_setCharPet(charaindex,iEmptyPetField,iPetIndex); + CHAR_setWorkInt(iPetIndex,CHAR_WORKPLAYERINDEX,charaindex); + CHAR_setChar(iPetIndex,CHAR_OWNERCDKEY,CHAR_getChar(charaindex,CHAR_CDKEY)); + CHAR_setChar(iPetIndex,CHAR_OWNERCHARANAME,CHAR_getChar(charaindex,CHAR_NAME)); + CHAR_complianceParameter(iPetIndex); + sprintf(szMsg,"K%d",iEmptyPetField); + CHAR_sendStatusString(charaindex,szMsg); + sprintf(szMsg,"W%d",iEmptyPetField); + CHAR_sendStatusString(charaindex,szMsg); + int sellprice; +#ifdef _STREET_FAX + int sellfax = iPrice * getStreetFax(CHAR_getWorkInt(toindex,CHAR_WORKTRADETYPE))/100; + if(sellfax<10) sellfax = sellfax+1; + sellprice = iPrice - sellfax; +#else + sellprice = iPrice; +#endif + if(CHAR_getWorkInt(toindex,CHAR_WORKTRADETYPE)==0) + { + // Ǯ + CHAR_setInt(charaindex,CHAR_GOLD,CHAR_getInt(charaindex,CHAR_GOLD) - iPrice); + CHAR_send_P_StatusString(charaindex,CHAR_P_STRING_GOLD); + // Ǯ + if(bPutToBank) CHAR_setInt(toindex,CHAR_BANKGOLD,CHAR_getInt(toindex,CHAR_BANKGOLD) + sellprice); + else CHAR_setInt(toindex,CHAR_GOLD,CHAR_getInt(toindex,CHAR_GOLD) + sellprice); + CHAR_send_P_StatusString(toindex,CHAR_P_STRING_GOLD); + } + else if(CHAR_getWorkInt(toindex,CHAR_WORKTRADETYPE)==1) + { + CHAR_setInt(charaindex,CHAR_FAME,CHAR_getInt(charaindex,CHAR_FAME) - iPrice*100); + CHAR_setInt(toindex,CHAR_FAME,CHAR_getInt(toindex,CHAR_FAME) + sellprice*100); + char tempbuf[256]; + if(CHAR_getInt(charaindex,CHAR_FMINDEX) != -1 && (strcmp(CHAR_getChar(charaindex,CHAR_FMNAME),""))){ + sprintf(tempbuf,"%d",CHAR_getInt(charaindex,CHAR_FAME)); + saacproto_ACFixFMData_send(acfd, + CHAR_getChar(charaindex,CHAR_FMNAME), + CHAR_getInt(charaindex,CHAR_FMINDEX), + CHAR_getWorkInt(charaindex,CHAR_WORKFMINDEXI), + FM_FIX_FAME,tempbuf,"", + CHAR_getWorkInt(charaindex,CHAR_WORKFMCHARINDEX), + CONNECT_getFdid(getfdFromCharaIndex(charaindex))); + } + if(CHAR_getInt(toindex,CHAR_FMINDEX) != -1 && (strcmp(CHAR_getChar(toindex,CHAR_FMNAME),""))){ + sprintf(tempbuf,"%d",CHAR_getInt(toindex,CHAR_FAME)); + saacproto_ACFixFMData_send(acfd, + CHAR_getChar(toindex,CHAR_FMNAME), + CHAR_getInt(toindex,CHAR_FMINDEX), + CHAR_getWorkInt(toindex,CHAR_WORKFMINDEXI), + FM_FIX_FAME,tempbuf,"", + CHAR_getWorkInt(toindex,CHAR_WORKFMCHARINDEX), + CONNECT_getFdid(getfdFromCharaIndex(toindex))); + } + } + else if(CHAR_getWorkInt(toindex,CHAR_WORKTRADETYPE)==2) + { + int myfd,tofd; + char *myid; + char *toid; + myfd=getfdFromCharaIndex( charaindex); + tofd=getfdFromCharaIndex( toindex); + myid=CHAR_getChar( charaindex, CHAR_CDKEY ); + toid=CHAR_getChar( toindex, CHAR_CDKEY ); + sasql_vippoint(myid,-iPrice,1); + sasql_vippoint(toid,sellprice,1); + } + else if(CHAR_getWorkInt(toindex,CHAR_WORKTRADETYPE)==3) + { + int myfd,tofd; + char *myid; + char *toid; + myfd=getfdFromCharaIndex( charaindex); + tofd=getfdFromCharaIndex( toindex); + myid=CHAR_getChar( charaindex, CHAR_CDKEY ); + toid=CHAR_getChar( toindex, CHAR_CDKEY ); + sasql_ampoint(myid,-iPrice,1); + sasql_ampoint(toid,sellprice,1); + } +#ifdef _VIGOR_SYS + else if(CHAR_getWorkInt(toindex,CHAR_WORKTRADETYPE)==4) + { + CHAR_setInt(charaindex,CHAR_VIGOR,CHAR_getInt(charaindex,CHAR_VIGOR) - iPrice); + CHAR_setInt(toindex,CHAR_VIGOR,CHAR_getInt(toindex,CHAR_VIGOR) + sellprice); + } +#endif + char streettypemsg[5][10] = {"ʯ","","Ա","",""}; + sprintf(szMsg," %s %s ɣ",CHAR_getUseName(toindex),CHAR_getChar(iPetIndex,CHAR_NAME)); + CHAR_talkToCli(charaindex,-1,szMsg,CHAR_COLORWHITE); + sprintf(szMsg,"%s ߳ %s",CHAR_getUseName(charaindex),CHAR_getChar(iPetIndex,CHAR_NAME)); + CHAR_talkToCli(toindex,-1,szMsg,CHAR_COLORWHITE); + sprintf(szMsg,"γɽ%d (%s)",iPrice,streettypemsg[CHAR_getWorkInt(toindex,CHAR_WORKTRADETYPE)]); + CHAR_talkToCli(toindex,-1,szMsg,CHAR_COLORWHITE); + CHAR_talkToCli(charaindex,-1,szMsg,CHAR_COLORWHITE); +// int mfd,tfd; +// mfd=getfdFromCharaIndex( charaindex); +// tfd=getfdFromCharaIndex( toindex); + CHAR_charSaveFromConnect(charaindex, FALSE); + CHAR_charSaveFromConnect(toindex, FALSE); + CHAR_talkToCli(charaindex, -1, "ϵͳΪԶ浵", CHAR_COLORRED); + CHAR_talkToCli(toindex, -1, "ϵͳΪԶ浵", CHAR_COLORRED); + LogStreetVendor( + CHAR_getUseName(toindex), + CHAR_getUseID(toindex), + CHAR_getUseName(charaindex), + CHAR_getUseID(charaindex), + CHAR_getChar(iPetIndex,CHAR_NAME), + CHAR_getInt(iPetIndex,CHAR_LV), + iPrice, + "StreetVendor()", + CHAR_getInt(toindex,CHAR_FLOOR), + CHAR_getInt(toindex,CHAR_X), + CHAR_getInt(toindex,CHAR_Y), + CHAR_getInt(charaindex,CHAR_FLOOR), + CHAR_getInt(charaindex,CHAR_X), + CHAR_getInt(charaindex,CHAR_Y), + CHAR_getChar(iPetIndex,CHAR_UNIQUECODE), + CHAR_getWorkInt(toindex,CHAR_WORKTRADETYPE) + ); + } + // ҳλ + else CHAR_talkToCli(charaindex,-1,"ϳλ㣡",CHAR_COLORRED); + } + // + else{ + CHAR_clearStreetVendor(toindex,iBuyIndex); + printf("\nCHAR_sendStreetVendor(B):!!!!!!!\n"); + } + } + // 趨Ϊ̯,״̬ + CHAR_setWorkInt(charaindex,CHAR_WORKSTREETVENDOR,-1); + CHAR_setWorkInt(toindex,CHAR_WORKSTREETVENDOR,1); + // ͼʾ + CHAR_sendTradeEffect(charaindex,0); + CHAR_sendTradeEffect(toindex,0); + CHAR_send_P_StatusString(charaindex,CHAR_P_STRING_GOLD); + CHAR_send_P_StatusString(toindex,CHAR_P_STRING_GOLD); + CHAR_setWorkInt(toindex,CHAR_WORKSTREETVENDOR_WHO,-1); + CHAR_setWorkInt(charaindex,CHAR_WORKSTREETVENDOR_WHO,-1); +#ifdef _LOOK_STREET_TIME + CHAR_setWorkInt(charaindex,CHAR_LOOKSTREETTIME,0); +#endif + } + else printf("StreetVendorҲԷ(%s)\n",CHAR_getChar(charaindex,CHAR_NAME)); + } +} + +void CHAR_sendStreetVendorDataToCli(int charaindex,int toindex) +{ + int i,count = 0; + + // ͷݸԼ,Ҫ޸ķ + if(charaindex == toindex){ + char szMsg[512],szTemp[512],szTemp1[16]; + + memset(szTemp,0,sizeof(szTemp)); + for(i=0;i1){ + if(ITEM_getInt(itempetindex,ITEM_ATTACKNUM_MIN)==ITEM_getInt(itempetindex,ITEM_ATTACKNUM_MAX)){ + sprintf(attnum," (x%d)",ITEM_getInt(itempetindex,ITEM_ATTACKNUM_MAX)); + }else{ + sprintf(attnum," (%d-%d)",ITEM_getInt(itempetindex,ITEM_ATTACKNUM_MIN),ITEM_getInt(itempetindex,ITEM_ATTACKNUM_MAX)); + } + } + if(strcmp(szTemp1," ")==0){ + sprintf(szTemp1,"%s%d%s ",(ITEM_getInt(itempetindex,ITEM_MODIFYATTACK)>=0)?"+":"",ITEM_getInt(itempetindex,ITEM_MODIFYATTACK),attnum); + }else{ + sprintf(szTemp1,"%s%s%d%s ",szTemp1,(ITEM_getInt(itempetindex,ITEM_MODIFYATTACK)>=0)?"+":"",ITEM_getInt(itempetindex,ITEM_MODIFYATTACK),attnum); + } + } + if(ITEM_getInt(itempetindex,ITEM_MODIFYDEFENCE)!=0){ + if(strcmp(szTemp1," ")==0){ + sprintf(szTemp1,"%s%d ",(ITEM_getInt(itempetindex,ITEM_MODIFYDEFENCE)>=0)?"+":"",ITEM_getInt(itempetindex,ITEM_MODIFYDEFENCE)); + }else{ + sprintf(szTemp1,"%s%s%d ",szTemp1,(ITEM_getInt(itempetindex,ITEM_MODIFYDEFENCE)>=0)?"+":"",ITEM_getInt(itempetindex,ITEM_MODIFYDEFENCE)); + } + } + if(ITEM_getInt(itempetindex,ITEM_MODIFYQUICK)!=0){ + if(strcmp(szTemp1," ")==0){ + sprintf(szTemp1,"%s%d ",(ITEM_getInt(itempetindex,ITEM_MODIFYQUICK)>=0)?"+":"",ITEM_getInt(itempetindex,ITEM_MODIFYQUICK)); + }else{ + sprintf(szTemp1,"%s%s%d ",szTemp1,(ITEM_getInt(itempetindex,ITEM_MODIFYQUICK)>=0)?"+":"",ITEM_getInt(itempetindex,ITEM_MODIFYQUICK)); + } + } + if(ITEM_getInt(itempetindex,ITEM_MAGICID)>0){ + int marray = MAGIC_getMagicArray( ITEM_getInt( itempetindex, ITEM_MAGICID)); + if( marray != -1 ){ + if( MAGIC_getChar( marray, MAGIC_NAME) != NULL ){ + if(strcmp(szTemp1," ")==0){ + sprintf(szTemp1,"%s ",MAGIC_getChar( marray, MAGIC_NAME)); + }else{ + sprintf(szTemp1,"%s%s ",szTemp1,MAGIC_getChar( marray, MAGIC_NAME)); + } + } + } + } + if(strcmp(szTemp1," ")==0) + sprintf(szTemp1,"%s|",ITEM_getChar(itempetindex,ITEM_EFFECTSTRING)); + else + sprintf(szTemp1,"%s|",szTemp1); + }else +#endif + sprintf(szTemp1,"%s|",ITEM_getChar(itempetindex,ITEM_EFFECTSTRING)); + + strcat(szTemp,szTemp1); + // ;ö + crushe = ITEM_getInt(itempetindex,ITEM_DAMAGECRUSHE); + maxcrushe = ITEM_getInt(itempetindex,ITEM_MAXDAMAGECRUSHE); + + if(crushe < 1) crushe = 1; + if(maxcrushe < 1) sprintf(szTemp1,"|"); // + else{ + maxcrushe = maxcrushe/1000; + crushe = crushe/1000; + if(maxcrushe <= 0) maxcrushe = 1; + sprintf(szTemp1,"%d%%|",(int)((crushe*100)/maxcrushe)); + } + strcat(szTemp,szTemp1); + // ɫ + itemcolor = CHAR_COLORWHITE; + if(strlen(ITEM_getChar(itempetindex,ITEM_CDKEY)) != 0) itemcolor = CHAR_COLORGREEN; + else if(ITEM_getInt(itempetindex,ITEM_MERGEFLG)) itemcolor = CHAR_COLORYELLOW; + sprintf(szTemp1,"%d|",itemcolor); + strcat(szTemp,szTemp1); + // ͼ + sprintf(szTemp1,"%d|",ITEM_getInt(itempetindex,ITEM_BASEIMAGENUMBER)); + strcat(szTemp,szTemp1); + } + // Ҳ + else{ + CHAR_clearStreetVendor(toindex,sendindex); + printf("\nCHAR_sendStreetVendorOneDataToCli():Ҳ!!!!!!!\n"); + return; + } + } + // + else if(kind == 1){ + int skillid,petskillindex; + + itempetindex = CHAR_getCharPet(toindex,index); + if(CHAR_CHECKINDEX(itempetindex)){ + // 輼 + for(i=0;i=36){ + for(j=0;j 0 && strlen(CHAR_getChar(charaindex,CHAR_TEACHER_NAME)) > 0) bHasTeacher = TRUE; + // ǰû + CHAR_getCoordinationDir(CHAR_getInt(charaindex,CHAR_DIR),CHAR_getInt(charaindex,CHAR_X), CHAR_getInt(charaindex,CHAR_Y),1,&ix,&iy); + // ȡǰ + iPlayerNum = CHAR_getSameCoordinateObjects(objbuf,arraysizeof(objbuf),CHAR_getInt(charaindex,CHAR_FLOOR),ix,iy); + // û + if(iPlayerNum == 0){ + // еʦ,ʾʦ + if(bHasTeacher){ + // ac Ҫ + saacproto_ACCheckCharacterOnLine_send(acfd,charaindex,CHAR_getChar(charaindex,CHAR_TEACHER_ID), + CHAR_getChar(charaindex,CHAR_TEACHER_NAME), + R_F_TEACHER_SYSTEM); + } + // ûеʦ,ʾ˵ + else lssproto_TEACHER_SYSTEM_send(getfdFromCharaIndex(charaindex),"M|"); + } + // + else{ + // еʦ + if(bHasTeacher){ + // ȡԭĵʦٽµʦ + CHAR_talkToCli(charaindex,-1,"ȡԭĵʦΪĵʦ",CHAR_COLORRED); + } + else{ + int objindex,index; + char szFindName[256]; + + if(iPlayerNum == 1){ + // ѯǷҪԷĵʦ + objindex = objbuf[0]; + index = OBJECT_getIndex(objindex); + + if(OBJECT_getType(objindex) != OBJTYPE_CHARA) break; + if(CHAR_getInt(index,CHAR_WHICHTYPE) != CHAR_TYPEPLAYER) break; + if(index == charaindex) break; + // ԷǷΪԼѧ + if(strcmp(CHAR_getChar(index,CHAR_TEACHER_ID),CHAR_getChar(charaindex,CHAR_CDKEY)) == 0 && + strcmp(CHAR_getChar(index,CHAR_TEACHER_NAME),CHAR_getChar(charaindex,CHAR_NAME)) == 0){ + CHAR_talkToCli(charaindex,-1,"ԷΪѧ޷öԷΪĵʦ",CHAR_COLORRED); + break; + } + sprintf(szMsg,"C|%s|%d",CHAR_getChar(index,CHAR_NAME),index); + lssproto_TEACHER_SYSTEM_send(getfdFromCharaIndex(charaindex),szMsg); + } + // һ,ѯҪ˭ʦ + else{ + int iGetNum = 0; + char szBuf[1024]; + + memset(szBuf,0,sizeof(szBuf)); + for(i=0;i5)){ + CHAR_talkToCli(charaindex,-1,"Ѿʦ",CHAR_COLORRED); + break; + } +#endif + CHAR_setChar(charaindex,CHAR_TEACHER_ID,CHAR_getChar(index,CHAR_CDKEY)); + CHAR_setChar(charaindex,CHAR_TEACHER_NAME,CHAR_getChar(index,CHAR_NAME)); + sprintf(szMsg,"%s ѳΪѧ",CHAR_getChar(charaindex,CHAR_NAME)); + CHAR_talkToCli(index,-1,szMsg,CHAR_COLORWHITE); + sprintf(szMsg,"%s ѳΪĵʦ",CHAR_getChar(index,CHAR_NAME)); + CHAR_talkToCli(charaindex,-1,szMsg,CHAR_COLORWHITE); + } + break; + // ȡʦʸ Ѿʦ + case 'C': + { + if((CHAR_getInt(charaindex,CHAR_TRANSMIGRATION)==6 && CHAR_getInt(charaindex,CHAR_LV)==160)){ + int j,iPlayernum; + iPlayernum = CHAR_getPlayerMaxNum(); + for(j=0;jѾɹʦĿǰΪֹɹʹ%dѧѧҵгɣͣ",CHAR_getChar(charaindex,CHAR_NAME),CHAR_getInt(j,CHAR_STUNUM)); + CHAR_talkToCli(j,-1,szMsg,CHAR_COLORYELLOW); + CHAR_talkToCli(charaindex,-1,"Ѿɹʦ",CHAR_COLORYELLOW); + return; +#endif + } + } + } + int iCharm = CHAR_getInt(charaindex,CHAR_CHARM) - 30; + + CHAR_setChar(charaindex,CHAR_TEACHER_ID,""); + CHAR_setChar(charaindex,CHAR_TEACHER_NAME,""); + // ֵ + CHAR_setInt(charaindex,CHAR_CHARM,iCharm < 0 ? 0:iCharm); + CHAR_setWorkInt(charaindex,CHAR_WORKFIXCHARM,iCharm < 0 ? 0:iCharm); + CHAR_send_P_StatusString(charaindex,CHAR_P_STRING_CHARM); + } + break; + default:printf("\nCHAR_Teacher_system:error command (%s)\n",&szAction[0]); + } +} + +void CHAR_Teacher_system_View(int charaindex,int iOnLine,char *data) +{ + char szMsg[1024]; + + // V|ʦ|ڲ|ϵ + sprintf(szMsg,"V|%s|%d|%s",CHAR_getChar(charaindex,CHAR_TEACHER_NAME),iOnLine,data); + lssproto_TEACHER_SYSTEM_send(getfdFromCharaIndex(charaindex),szMsg); +} +#endif + +#ifdef _TIME_TICKET + +int check_TimeTicketMap(int floor) +{ + if( floor == 7025) { + return TRUE; + } + else { + return FALSE; + } +} + +void check_TimeTicket() +{ + int i; + int tickettime; + int playernum = CHAR_getPlayerMaxNum(); + int nowtime = time(NULL); + char msg[1024]; + + for( i =0; i 0 && tickettime > nowtime+20 ) { + continue; + } + // ʱ޲20 + else if( tickettime < nowtime+20 && tickettime >= nowtime ) { + sprintf( msg, "ʱƱʣʱ%d롣", tickettime - nowtime); + CHAR_talkToCli( i, -1, msg, CHAR_COLORYELLOW); + } + + // ʱ + else if( tickettime < nowtime ) { +// int floor, x, y; + int totaltime; + char msg[1024]; + if( CHAR_getWorkInt( i, CHAR_WORKBATTLEMODE) == BATTLE_CHARMODE_NONE) { + CHAR_talkToCli( i, -1, "ʱѵллˡ", CHAR_COLORYELLOW); + if( CHAR_getWorkInt( i, CHAR_WORKTICKETTIMESTART) > 0 ) { + totaltime = nowtime - CHAR_getWorkInt( i, CHAR_WORKTICKETTIMESTART); + sprintf( msg, "볡ʱ%d%d롣", totaltime/60, totaltime%60); + CHAR_talkToCli( i, -1, msg, CHAR_COLORYELLOW); + } + CHAR_setWorkInt( i, CHAR_WORKTICKETTIME, 0); + CHAR_setWorkInt( i, CHAR_WORKTICKETTIMESTART, 0); + /* + if( CHAR_getElderPosition( CHAR_getInt( i, CHAR_LASTTALKELDER), &floor, &x, &y ) != TRUE ) { + CHAR_warpToSpecificPoint( i, 1006, 15, 15); + } + else { + CHAR_warpToSpecificPoint( i, floor, x, y); + } + */ + CHAR_warpToSpecificPoint( i, 2006, 20, 17); + } + else { + CHAR_talkToCli( i, -1, "ʱѵսʱ뿪", CHAR_COLORYELLOW); + // BATTLE_Exit() + } + } + } + +} +#endif + +int CharaData( int sockfd, Char* ch ){ + FILE *fp; + struct tm *pLtime; + char szFileName[256], *chardata; + char outbuff[CHARDATASIZE]; +// Char* ch; + int charaindex=CONNECT_getCharaindex(sockfd); +// print("\nе\n"); + + pLtime = localtime( &NowTime.tv_sec ); + + int hash, dir, j; + char charId[32]; + char pathname[128]; + +// strcpy( charId, CHAR_getChar( charaindex, CHAR_CDKEY ) ); + CONNECT_getCdkey( sockfd, charId, sizeof(charId)); + print("˺:%s", charId); + + hash = 0; + for( j=0; j +#include +#include +#include // shan +#include +#include +#include +#include +#include "common.h" +#include "char_base.h" +#include "char_data.h" +#include "char.h" +#include "lssproto_serv.h" +#include "item.h" +#include "item_event.h" +#include "buf.h" +#include "object.h" +#include "map_deal.h" +#include "saacproto_cli.h" +#include "readmap.h" +#include "handletime.h" +#include "char_event.h" +#include "npccreate.h" +#include "addressbook.h" +#include "item_event.h" +#include "magic_base.h" +#include "magic.h" +#include "chatmagic.h" +#include "configfile.h" +#include "log.h" +#include "anim_tbl.h" +#include "encount.h" +#include "battle.h" +#include "pet_skill.h" +#include "util.h" +#include "enemy.h" +#include "npcutil.h" +#include "pet.h" +#include "family.h" + +struct MissionInfo missionlist[MAXMISSION]; +int mission_num =0; +struct MissionTable missiontable[MAXMISSIONTABLE]; + +//#define ANGELITEM 2884 //20701 //ʹߵ ߱ +//#define HEROITEM 2885 //20702 //ߵ ߱ + +extern int AngelReady; + +char* getMissionNameInfo( int charaindex, char* nameinfo) +{ + sprintf( nameinfo, "%s:%s", CHAR_getChar( charaindex, CHAR_CDKEY), CHAR_getChar( charaindex, CHAR_NAME) ); + return nameinfo; +} + +int checkIfAngel( int charaindex) +{ + int i; + char nameinfo[512]; + + //sprintf( nameinfo, "%s:%s", CHAR_getChar( charaindex, CHAR_CDKEY), CHAR_getChar( charaindex, CHAR_NAME) ); + getMissionNameInfo( charaindex, nameinfo); + for( i =0; i + +// CoolFish: 2001/10/12 _UNIQUE_P_I +#include + + +#include "char_base.h" +#include "char_data.h" +#include "item.h" +#include "buf.h" +#include "magic.h" +#include "function.h" +#include "npccreate.h" +#include "configfile.h" +#include "title.h" +#include "pet.h" +#include "pet_skill.h" +#include "anim_tbl.h" +#include "enemy.h" +#include "saacproto_cli.h" + +// CoolFish: 2001/10/29 +#include "log.h" + +#ifdef _ALLBLUES_LUA +#include "mylua/function.h" +#endif + +Char* CHAR_chara; + +static int CHAR_charanum; +static int CHAR_playernum; +static int CHAR_petnum; +static int CHAR_othersnum; + +// CoolFish: 2001/10/11 +#ifdef _UNIQUE_P_I +#define MAX_UNIQUE_P_I 1000 +static int unique_p = 0; +static int unique_i = 0; +#endif + +typedef struct tagINITCHARCOUNTER{ + int startcnt; + int cnt; + int endcnt; +}INITCHARCOUNTER; +static INITCHARCOUNTER initCharCounter[3] = { + {-1,-1,-1},{-1,-1,-1},{-1,-1,-1} +}; + + +tagRidePetTable ridePetTable[296] = +{ + { 101000, 100000, 100352, 331 }, + { 101001, 100005, 100352, 331 }, + { 101002, 100010, 100352, 331 }, + { 101003, 100015, 100352, 331 }, + { 101004, 100000, 100329, 309 }, + { 101005, 100005, 100327, 307 }, + { 101006, 100010, 100330, 310 }, + { 101007, 100015, 100328, 308 }, +// { 101008, 100700, 100372, 351 }, +// { 101009, 100705, 100373, 352 }, +#ifdef _GM_METAMO_RIDE + { 101000, 100700, 100352, 331 }, + { 101001, 100700, 100352, 331 }, + { 101002, 100700, 100352, 331 }, + { 101003, 100700, 100352, 331 }, + { 101004, 100700, 100329, 309 }, + { 101005, 100700, 100327, 307 }, + { 101006, 100700, 100330, 310 }, + { 101007, 100700, 100328, 308 }, + { 101000, 100705, 100352, 331 }, + { 101001, 100705, 100352, 331 }, + { 101002, 100705, 100352, 331 }, + { 101003, 100705, 100352, 331 }, + { 101004, 100705, 100329, 309 }, + { 101005, 100705, 100327, 307 }, + { 101006, 100705, 100330, 310 }, + { 101007, 100705, 100328, 308 }, +#endif + + { 101010, 100020, 100396, 483 }, + { 101011, 100025, 100396, 483 }, + { 101012, 100030, 100396, 483 }, + { 101013, 100035, 100396, 483 }, + { 101014, 100020, 100328, 308 }, + { 101015, 100025, 100329, 309 }, + { 101016, 100030, 100327, 307 }, + { 101017, 100035, 100330, 310 }, +// { 101018, 100710, 100372, 351 }, +// { 101019, 100715, 100373, 352 }, +#ifdef _GM_METAMO_RIDE + { 101010, 100710, 100396, 483 }, + { 101011, 100710, 100396, 483 }, + { 101012, 100710, 100396, 483 }, + { 101013, 100710, 100396, 483 }, + { 101014, 100710, 100328, 308 }, + { 101015, 100710, 100329, 309 }, + { 101016, 100710, 100327, 307 }, + { 101017, 100710, 100330, 310 }, + { 101010, 100715, 100396, 483 }, + { 101011, 100715, 100396, 483 }, + { 101012, 100715, 100396, 483 }, + { 101013, 100715, 100396, 483 }, + { 101014, 100715, 100328, 308 }, + { 101015, 100715, 100329, 309 }, + { 101016, 100715, 100327, 307 }, + { 101017, 100715, 100330, 310 }, +#endif + + { 101020, 100040, 100351, 330 }, + { 101021, 100045, 100351, 330 }, + { 101022, 100050, 100351, 330 }, + { 101023, 100055, 100351, 330 }, + { 101024, 100040, 100328, 308 }, + { 101025, 100045, 100330, 310 }, + { 101026, 100050, 100327, 307 }, + { 101027, 100055, 100329, 309 }, +// { 101028, 100720, 100372, 351 }, +// { 101029, 100725, 100373, 352 }, +#ifdef _GM_METAMO_RIDE + { 101020, 100720, 100351, 330 }, + { 101021, 100720, 100351, 330 }, + { 101022, 100720, 100351, 330 }, + { 101023, 100720, 100351, 330 }, + { 101024, 100720, 100328, 308 }, + { 101025, 100720, 100330, 310 }, + { 101026, 100720, 100327, 307 }, + { 101027, 100720, 100329, 309 }, + { 101020, 100725, 100351, 330 }, + { 101021, 100725, 100351, 330 }, + { 101022, 100725, 100351, 330 }, + { 101023, 100725, 100351, 330 }, + { 101024, 100725, 100328, 308 }, + { 101025, 100725, 100330, 310 }, + { 101026, 100725, 100327, 307 }, + { 101027, 100725, 100329, 309 }, +#endif + + { 101030, 100060, 100353, 332 }, + { 101031, 100065, 100353, 332 }, + { 101032, 100070, 100353, 332 }, + { 101033, 100075, 100353, 332 }, + { 101034, 100060, 100329, 309 }, + { 101035, 100065, 100327, 307 }, + { 101036, 100070, 100330, 310 }, + { 101037, 100075, 100328, 308 }, +// { 101038, 100730, 100372, 351 }, +// { 101039, 100735, 100373, 352 }, +#ifdef _GM_METAMO_RIDE + { 101030, 100730, 100353, 332 }, + { 101031, 100730, 100353, 332 }, + { 101032, 100730, 100353, 332 }, + { 101033, 100730, 100353, 332 }, + { 101034, 100730, 100329, 309 }, + { 101035, 100730, 100327, 307 }, + { 101036, 100730, 100330, 310 }, + { 101037, 100730, 100328, 308 }, + { 101030, 100735, 100353, 332 }, + { 101031, 100735, 100353, 332 }, + { 101032, 100735, 100353, 332 }, + { 101033, 100735, 100353, 332 }, + { 101034, 100735, 100329, 309 }, + { 101035, 100735, 100327, 307 }, + { 101036, 100735, 100330, 310 }, + { 101037, 100735, 100328, 308 }, +#endif + + { 101040, 100080, 100396, 483 }, + { 101041, 100085, 100396, 483 }, + { 101042, 100090, 100396, 483 }, + { 101043, 100095, 100396, 483 }, + { 101044, 100080, 100328, 308 }, + { 101045, 100085, 100327, 307 }, + { 101046, 100090, 100330, 310 }, + { 101047, 100095, 100329, 309 }, +// { 101048, 100740, 100372, 351 }, +// { 101049, 100745, 100373, 352 }, +#ifdef _GM_METAMO_RIDE + { 101040, 100740, 100396, 483 }, + { 101041, 100740, 100396, 483 }, + { 101042, 100740, 100396, 483 }, + { 101043, 100740, 100396, 483 }, + { 101044, 100740, 100328, 308 }, + { 101045, 100740, 100327, 307 }, + { 101046, 100740, 100330, 310 }, + { 101047, 100740, 100329, 309 }, + { 101040, 100740, 100396, 483 }, + { 101041, 100740, 100396, 483 }, + { 101042, 100740, 100396, 483 }, + { 101043, 100740, 100396, 483 }, + { 101044, 100740, 100328, 308 }, + { 101045, 100740, 100327, 307 }, + { 101046, 100740, 100330, 310 }, + { 101047, 100740, 100329, 309 }, +#endif + + { 101050, 100100, 100353, 332 }, + { 101051, 100105, 100353, 332 }, + { 101052, 100110, 100353, 332 }, + { 101053, 100115, 100353, 332 }, + { 101054, 100100, 100329, 309 }, + { 101055, 100105, 100328, 308 }, + { 101056, 100110, 100330, 310 }, + { 101057, 100115, 100327, 307 }, +// { 101058, 100750, 100372, 351 }, +// { 101059, 100755, 100373, 352 }, +#ifdef _GM_METAMO_RIDE + { 101050, 100750, 100353, 332 }, + { 101051, 100750, 100353, 332 }, + { 101052, 100750, 100353, 332 }, + { 101053, 100750, 100353, 332 }, + { 101054, 100750, 100329, 309 }, + { 101055, 100750, 100328, 308 }, + { 101056, 100750, 100330, 310 }, + { 101057, 100750, 100327, 307 }, + { 101050, 100755, 100353, 332 }, + { 101051, 100755, 100353, 332 }, + { 101052, 100755, 100353, 332 }, + { 101053, 100755, 100353, 332 }, + { 101054, 100755, 100329, 309 }, + { 101055, 100755, 100328, 308 }, + { 101056, 100755, 100330, 310 }, + { 101057, 100755, 100327, 307 }, +#endif + + { 101060, 100120, 100354, 333 }, + { 101061, 100125, 100354, 333 }, + { 101062, 100130, 100354, 333 }, + { 101063, 100135, 100354, 333 }, + { 101064, 100120, 100327, 307 }, + { 101065, 100125, 100330, 310 }, + { 101066, 100130, 100328, 308 }, + { 101067, 100135, 100329, 309 }, +// { 101068, 100760, 100372, 351 }, +// { 101069, 100765, 100373, 352 }, +#ifdef _GM_METAMO_RIDE + { 101060, 100760, 100354, 333 }, + { 101061, 100760, 100354, 333 }, + { 101062, 100760, 100354, 333 }, + { 101063, 100760, 100354, 333 }, + { 101064, 100760, 100327, 307 }, + { 101065, 100760, 100330, 310 }, + { 101066, 100760, 100328, 308 }, + { 101067, 100760, 100329, 309 }, + { 101060, 100765, 100354, 333 }, + { 101061, 100765, 100354, 333 }, + { 101062, 100765, 100354, 333 }, + { 101063, 100765, 100354, 333 }, + { 101064, 100765, 100327, 307 }, + { 101065, 100765, 100330, 310 }, + { 101066, 100765, 100328, 308 }, + { 101067, 100765, 100329, 309 }, +#endif + + { 101070, 100140, 100354, 333 }, + { 101071, 100145, 100354, 333 }, + { 101072, 100150, 100354, 333 }, + { 101073, 100155, 100354, 333 }, + { 101074, 100140, 100327, 307 }, + { 101075, 100145, 100329, 309 }, + { 101076, 100150, 100330, 310 }, + { 101077, 100155, 100328, 308 }, +// { 101078, 100770, 100372, 351 }, +// { 101079, 100775, 100373, 352 }, +#ifdef _GM_METAMO_RIDE + { 101070, 100770, 100354, 333 }, + { 101071, 100770, 100354, 333 }, + { 101072, 100770, 100354, 333 }, + { 101073, 100770, 100354, 333 }, + { 101074, 100770, 100327, 307 }, + { 101075, 100770, 100329, 309 }, + { 101076, 100770, 100330, 310 }, + { 101077, 100770, 100328, 308 }, + { 101070, 100775, 100354, 333 }, + { 101071, 100775, 100354, 333 }, + { 101072, 100775, 100354, 333 }, + { 101073, 100775, 100354, 333 }, + { 101074, 100775, 100327, 307 }, + { 101075, 100775, 100329, 309 }, + { 101076, 100775, 100330, 310 }, + { 101077, 100775, 100328, 308 }, +#endif + + { 101080, 100160, 100352, 331 }, + { 101081, 100165, 100352, 331 }, + { 101082, 100170, 100352, 331 }, + { 101083, 100175, 100352, 331 }, + { 101084, 100160, 100330, 310 }, + { 101085, 100165, 100329, 309 }, + { 101086, 100170, 100327, 307 }, + { 101087, 100175, 100328, 308 }, +// { 101088, 100780, 100372, 351 }, +// { 101089, 100785, 100373, 352 }, +#ifdef _GM_METAMO_RIDE + { 101080, 100780, 100396, 483 }, + { 101081, 100780, 100396, 483 }, + { 101082, 100780, 100396, 483 }, + { 101083, 100780, 100396, 483 }, + { 101084, 100780, 100328, 308 }, + { 101085, 100780, 100327, 307 }, + { 101086, 100780, 100330, 310 }, + { 101087, 100780, 100329, 309 }, + { 101080, 100785, 100352, 331 }, + { 101081, 100785, 100352, 331 }, + { 101082, 100785, 100352, 331 }, + { 101083, 100785, 100352, 331 }, + { 101084, 100785, 100330, 310 }, + { 101085, 100785, 100329, 309 }, + { 101086, 100785, 100327, 307 }, + { 101087, 100785, 100328, 308 }, +#endif + + { 101090, 100180, 100351, 330 }, + { 101091, 100185, 100351, 330 }, + { 101092, 100190, 100351, 330 }, + { 101093, 100195, 100351, 330 }, + { 101094, 100180, 100328, 308 }, + { 101095, 100185, 100330, 310 }, + { 101096, 100190, 100329, 309 }, + { 101097, 100195, 100327, 307 }, +// { 101098, 100790, 100372, 351 }, +// { 101099, 100795, 100373, 352 }, +#ifdef _GM_METAMO_RIDE + { 101090, 100790, 100351, 330 }, + { 101091, 100790, 100351, 330 }, + { 101092, 100790, 100351, 330 }, + { 101093, 100790, 100351, 330 }, + { 101094, 100790, 100328, 308 }, + { 101095, 100790, 100330, 310 }, + { 101096, 100790, 100329, 309 }, + { 101097, 100790, 100327, 307 }, + { 101090, 100795, 100351, 330 }, + { 101091, 100795, 100351, 330 }, + { 101092, 100795, 100351, 330 }, + { 101093, 100795, 100351, 330 }, + { 101094, 100795, 100328, 308 }, + { 101095, 100795, 100330, 310 }, + { 101096, 100795, 100329, 309 }, + { 101097, 100795, 100327, 307 }, +#endif + + { 101100, 100200, 100353, 332 }, + { 101101, 100205, 100353, 332 }, + { 101102, 100210, 100353, 332 }, + { 101103, 100215, 100353, 332 }, + { 101104, 100200, 100329, 309 }, + { 101105, 100205, 100328, 308 }, + { 101106, 100210, 100327, 307 }, + { 101107, 100215, 100330, 310 }, +// { 101108, 100800, 100372, 351 }, +// { 101109, 100805, 100373, 352 }, +#ifdef _GM_METAMO_RIDE + { 101100, 100800, 100353, 332 }, + { 101101, 100800, 100353, 332 }, + { 101102, 100800, 100353, 332 }, + { 101103, 100800, 100353, 332 }, + { 101104, 100800, 100329, 309 }, + { 101105, 100800, 100328, 308 }, + { 101106, 100800, 100327, 307 }, + { 101107, 100800, 100330, 310 }, + { 101100, 100805, 100353, 332 }, + { 101101, 100805, 100353, 332 }, + { 101102, 100805, 100353, 332 }, + { 101103, 100805, 100353, 332 }, + { 101104, 100805, 100329, 309 }, + { 101105, 100805, 100328, 308 }, + { 101106, 100805, 100327, 307 }, + { 101107, 100805, 100330, 310 }, +#endif + + { 101110, 100220, 100396, 483 }, + { 101111, 100225, 100396, 483 }, + { 101112, 100230, 100396, 483 }, + { 101113, 100235, 100396, 483 }, + { 101114, 100220, 100330, 310 }, + { 101115, 100225, 100327, 307 }, + { 101116, 100230, 100329, 309 }, + { 101117, 100235, 100328, 308 }, +// { 101118, 100810, 100372, 351 }, +// { 101119, 100815, 100373, 352 }, +#ifdef _GM_METAMO_RIDE + { 101110, 100810, 100396, 483 }, + { 101111, 100810, 100396, 483 }, + { 101112, 100810, 100396, 483 }, + { 101113, 100810, 100396, 483 }, + { 101114, 100810, 100330, 310 }, + { 101115, 100810, 100327, 307 }, + { 101116, 100810, 100329, 309 }, + { 101117, 100810, 100328, 308 }, + { 101110, 100815, 100396, 483 }, + { 101111, 100815, 100396, 483 }, + { 101112, 100815, 100396, 483 }, + { 101113, 100815, 100396, 483 }, + { 101114, 100815, 100330, 310 }, + { 101115, 100815, 100327, 307 }, + { 101116, 100815, 100329, 309 }, + { 101117, 100815, 100328, 308 }, +#endif + + { 101179, 101177, 101178, 1804}, + { 101179, 101178, 101177, 1926}, + +//#ifndef _RIDEMODE_20 +#ifndef _GM_METAMO_RIDE + { 100420, 100710, 100369, 348 }, + { 100425, 100710, 100370, 349 }, + { 100445, 100710, 100904, 1642 }, + + { 100420, 100715, 100369, 348 }, + { 100425, 100715, 100370, 349 }, + { 100445, 100715, 100904, 1642 }, +#endif +//#endif +}; + +#ifdef _FM_LEADER_RIDE +tagFmLeaderRide FmLeaderRide[] = { + { 1041, {-1, -1, -1, -1, -1, -1 }}, + { 2031, {-1, -1, -1, -1, -1, -1 }}, + { 3031, {-1, -1, -1, -1, -1, -1 }}, + { 4031, {-1, -1, -1, -1, -1, -1 }}, + { 5031, {-1, -1, -1, -1, -1, -1 }}, + { 6031, {-1, -1, -1, -1, -1, -1 }}, + { 7031, {-1, -1, -1, -1, -1, -1 }}, + { 8031, {-1, -1, -1, -1, -1, -1 }}, + { 9031, {-1, -1, -1, -1, -1, -1 }}, + { 10031, {-1, -1, -1, -1, -1, -1 }} +}; +#endif + +#ifdef _NEW_RIDEPETS +#ifdef _RIDE_CF +tagRideCodeMode RideCodeMode[] = { + { 100374, -1, RIDE_PET0 }, /**/ + { 100358, -1, RIDE_PET1 }, /*Ħ˹*/ + { 100362, -1, RIDE_PET2 }, /*˹*/ + { 100279, -1, RIDE_PET3 }, /*³*/ + { 100288, -1, RIDE_PET4 }, /*˹*/ + { 100283, -1, RIDE_PET5 }, /*迨³˹*/ + { 100346, -1, RIDE_PET6 }, /*迨*/ + { 100310, -1, RIDE_PET7 }, /**/ + { 100372, -1, RIDE_PET8 }, /*˹*/ + { 100373, -1, RIDE_PET9 }, /*Ͷ*/ + { 101532, -1, RIDE_PET10 }, /*ʷ³*/ + { 101576, -1, RIDE_PET11 }, /*޶*/ + { 100370, -1, RIDE_PET12 }, /*汦*/ + { 100369, -1, RIDE_PET13 }, /**/ + { 100904, -1, RIDE_PET14 }, /**/ + { -1, -1, RIDE_PET15 }, + { -1, -1, RIDE_PET16 }, + { -1, -1, RIDE_PET17 }, + { -1, -1, RIDE_PET18 }, + { -1, -1, RIDE_PET19 }, + { -1, -1, RIDE_PET20 }, + { -1, -1, RIDE_PET21 }, + { -1, -1, RIDE_PET22 }, + { -1, -1, RIDE_PET23 }, + { -1, -1, RIDE_PET24 }, + { -1, -1, RIDE_PET25 }, + { -1, -1, RIDE_PET26 }, + { -1, -1, RIDE_PET27 }, + { -1, -1, RIDE_PET28 }, + { -1, -1, RIDE_PET29 }, + { -1, -1, RIDE_PET30 }, + { -1, -1, RIDE_PET31 }, + { 100374, -1, RIDE_PET0 }, /**/ + { 100358, -1, RIDE_PET1 }, /*Ħ˹*/ + { 100362, -1, RIDE_PET2 }, /*˹*/ + { 100279, -1, RIDE_PET3 }, /*³*/ + { 100288, -1, RIDE_PET4 }, /*˹*/ + { 100283, -1, RIDE_PET5 }, /*迨³˹*/ + { 100346, -1, RIDE_PET6 }, /*迨*/ + { 100310, -1, RIDE_PET7 }, /**/ + { 100372, -1, RIDE_PET8 }, /*˹*/ + { 100373, -1, RIDE_PET9 }, /*Ͷ*/ + { 101532, -1, RIDE_PET10 }, /*ʷ³*/ + { 101576, -1, RIDE_PET11 }, /*޶*/ + { 100370, -1, RIDE_PET12 }, /*汦*/ + { 100369, -1, RIDE_PET13 }, /**/ + { 100904, -1, RIDE_PET14 }, /**/ + { -1, -1, RIDE_PET15 }, + { -1, -1, RIDE_PET16 }, + { -1, -1, RIDE_PET17 }, + { -1, -1, RIDE_PET18 }, + { -1, -1, RIDE_PET19 }, + { -1, -1, RIDE_PET20 }, + { -1, -1, RIDE_PET21 }, + { -1, -1, RIDE_PET22 }, + { -1, -1, RIDE_PET23 }, + { -1, -1, RIDE_PET24 }, + { -1, -1, RIDE_PET25 }, + { -1, -1, RIDE_PET26 }, + { -1, -1, RIDE_PET27 }, + { -1, -1, RIDE_PET28 }, + { -1, -1, RIDE_PET29 }, + { -1, -1, RIDE_PET30 }, + { -1, -1, RIDE_PET31 }, + { 100374, -1, RIDE_PET0 }, /**/ + { 100358, -1, RIDE_PET1 }, /*Ħ˹*/ + { 100362, -1, RIDE_PET2 }, /*˹*/ + { 100279, -1, RIDE_PET3 }, /*³*/ + { 100288, -1, RIDE_PET4 }, /*˹*/ + { 100283, -1, RIDE_PET5 }, /*迨³˹*/ + { 100346, -1, RIDE_PET6 }, /*迨*/ + { 100310, -1, RIDE_PET7 }, /**/ + { 100372, -1, RIDE_PET8 }, /*˹*/ + { 100373, -1, RIDE_PET9 }, /*Ͷ*/ + { 101532, -1, RIDE_PET10 }, /*ʷ³*/ + { 101576, -1, RIDE_PET11 }, /*޶*/ + { 100370, -1, RIDE_PET12 }, /*汦*/ + { 100369, -1, RIDE_PET13 }, /**/ + { 100904, -1, RIDE_PET14 }, /**/ + { -1, -1, RIDE_PET15 }, + { -1, -1, RIDE_PET16 }, + { -1, -1, RIDE_PET17 }, + { -1, -1, RIDE_PET18 }, + { -1, -1, RIDE_PET19 }, + { -1, -1, RIDE_PET20 }, + { -1, -1, RIDE_PET21 }, + { -1, -1, RIDE_PET22 }, + { -1, -1, RIDE_PET23 }, + { -1, -1, RIDE_PET24 }, + { -1, -1, RIDE_PET25 }, + { -1, -1, RIDE_PET26 }, + { -1, -1, RIDE_PET27 }, + { -1, -1, RIDE_PET28 }, + { -1, -1, RIDE_PET29 }, + { -1, -1, RIDE_PET30 }, + { -1, -1, RIDE_PET31 }, +}; +#else +tagRideCodeMode RideCodeMode[] = { + { 100374, RIDE_PET0 }, /**/ + { 100358, RIDE_PET1 }, /*Ħ˹*/ + { 100362, RIDE_PET2 }, /*˹*/ + { 100279, RIDE_PET3 }, /*³*/ + { 100288, RIDE_PET4 }, /*˹*/ + { 100283, RIDE_PET5 }, /*迨³˹*/ + { 100346, RIDE_PET6 }, /*迨*/ + { 100310, RIDE_PET7 }, /**/ + { 100372, RIDE_PET8 }, /*˹*/ + { 100373, RIDE_PET9 }, /*Ͷ*/ + { 101532, RIDE_PET10 }, /*ʷ³*/ + { 101576, RIDE_PET11 }, /*޶*/ + { 100370, RIDE_PET12 }, /*汦*/ + { 100369, RIDE_PET13 }, /**/ + { 100904, RIDE_PET14 }, /**/ +}; +#endif +#ifdef _RIDE_CF +tagRideNoList RideNoList[] = { + {{ 101305, 101306, 101307, 101308, 101309, 101310, 101311, 101312, 101008, 101009, 101978, 101989,100425,100420,100445,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1},0}, //С + {{ 101313, 101314, 101315, 101316, 101317, 101318, 101319, 101320, 101018, 101019, 101986, 101988,100425,100420,100445,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1},0}, // + {{ 101321, 101322, 101323, 101324, 101325, 101326, 101327, 101328, 101028, 101029, 101975, 101965,100425,100420,100445,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1},0}, //к + {{ 101329, 101330, 101331, 101332, 101333, 101334, 101335, 101336, 101038, 101039, 101976, 101966,100425,100420,100445,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1},0}, // + {{ 101337, 101338, 101339, 101340, 101341, 101342, 101343, 101344, 101048, 101049, 101984, 101973,100425,100420,100445,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1},0}, //Ƥ + {{ 101345, 101346, 101347, 101348, 101349, 101350, 101351, 101352, 101058, 101059, 101985, 101974,100425,100420,100445,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1},0}, // + {{ 101353, 101354, 101355, 101356, 101357, 101358, 101359, 101360, 101068, 101069, 101977, 101967,100425,100420,100445,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1},0}, //С + {{ 101361, 101362, 101363, 101364, 101365, 101366, 101367, 101368, 101078, 101079, 101979, 101968,100425,100420,100445,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1},0}, //Ƥ + {{ 101369, 101370, 101371, 101372, 101373, 101374, 101375, 101376, 101088, 101089, 101981, 101970,100425,100420,100445,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1},0}, //ñ + {{ 101377, 101378, 101379, 101380, 101381, 101382, 101383, 101384, 101098, 101099, 101980, 101969,100425,100420,100445,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1},0}, //̷ + {{ 101385, 101386, 101387, 101388, 101389, 101390, 101391, 101392, 101108, 101109, 101983, 101972,100425,100420,100445,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1},0}, //Ů + {{ 101393, 101394, 101395, 101396, 101397, 101398, 101399, 101400, 101118, 101119, 101982, 101971,100425,100420,100445,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1},0}, // +}; +#else +tagRideNoList RideNoList[] = { + {{ 101305, 101306, 101307, 101308, 101309, 101310, 101311, 101312, 101008, 101009, 101978, 101989,100425,100420,100445},0}, //С + {{ 101313, 101314, 101315, 101316, 101317, 101318, 101319, 101320, 101018, 101019, 101986, 101988,100425,100420,100445},0}, // + {{ 101321, 101322, 101323, 101324, 101325, 101326, 101327, 101328, 101028, 101029, 101975, 101965,100425,100420,100445},0}, //к + {{ 101329, 101330, 101331, 101332, 101333, 101334, 101335, 101336, 101038, 101039, 101976, 101966,100425,100420,100445},0}, // + {{ 101337, 101338, 101339, 101340, 101341, 101342, 101343, 101344, 101048, 101049, 101984, 101973,100425,100420,100445},0}, //Ƥ + {{ 101345, 101346, 101347, 101348, 101349, 101350, 101351, 101352, 101058, 101059, 101985, 101974,100425,100420,100445},0}, // + {{ 101353, 101354, 101355, 101356, 101357, 101358, 101359, 101360, 101068, 101069, 101977, 101967,100425,100420,100445},0}, //С + {{ 101361, 101362, 101363, 101364, 101365, 101366, 101367, 101368, 101078, 101079, 101979, 101968,100425,100420,100445},0}, //Ƥ + {{ 101369, 101370, 101371, 101372, 101373, 101374, 101375, 101376, 101088, 101089, 101981, 101970,100425,100420,100445},0}, //ñ + {{ 101377, 101378, 101379, 101380, 101381, 101382, 101383, 101384, 101098, 101099, 101980, 101969,100425,100420,100445},0}, //̷ + {{ 101385, 101386, 101387, 101388, 101389, 101390, 101391, 101392, 101108, 101109, 101983, 101972,100425,100420,100445},0}, //Ů + {{ 101393, 101394, 101395, 101396, 101397, 101398, 101399, 101400, 101118, 101119, 101982, 101971,100425,100420,100445},0}, // +}; +#endif +tagRidePetList RPlistMode[] = { + { 100000, 0, 1 }, { 100005, 0, 1 }, { 100010, 0, 1 }, { 100015, 0, 1 }, { 100700, 0, 1 }, { 100705, 0, 1 }, // + { 100020, 1, 1 }, { 100025, 1, 1 }, { 100030, 1, 1 }, { 100035, 1, 1 }, { 100710, 1, 1 }, { 100715, 1, 1 },// + { 100040, 2, 1 }, { 100045, 2, 1 }, { 100050, 2, 1 }, { 100055, 2, 1 }, { 100720, 2, 1 }, { 100725, 2, 1 }, //к + { 100060, 3, 1 }, { 100065, 3, 1 }, { 100070, 3, 1 }, { 100075, 3, 1 }, { 100730, 3, 1 }, { 100735, 3, 1 }, // + { 100080, 4, 1 }, { 100085, 4, 1 }, { 100090, 4, 1 }, { 100095, 4, 1 }, { 100740, 4, 1 }, { 100745, 4, 1 }, //Ƥ + { 100100, 5, 1 }, { 100105, 5, 1 }, { 100110, 5, 1 }, { 100115, 5, 1 }, { 100750, 5, 1 }, { 100755, 5, 1 }, // + { 100120, 6, 2 }, { 100125, 6, 2 }, { 100130, 6, 2 }, { 100135, 6, 2 }, { 100760, 6, 2 }, { 100765, 6, 2 }, // + { 100140, 7, 2 }, { 100145, 7, 2 }, { 100150, 7, 2 }, { 100155, 7, 2 }, { 100770, 7, 2 }, { 100775, 7, 2 }, //Ƥ + { 100160, 8, 2 }, { 100165, 8, 2 }, { 100170, 8, 2 }, { 100175, 8, 2 }, { 100780, 8, 2 }, { 100785, 8, 2 }, //ñ + { 100180, 9, 2 }, { 100185, 9, 2 }, { 100190, 9, 2 }, { 100195, 9, 2 }, { 100790, 9, 2 }, { 100795, 9, 2 }, //̷ + { 100200, 10, 2 }, { 100205, 10, 2 }, { 100210, 10, 2 }, { 100215, 10, 2 }, { 100800, 10, 2 }, { 100805, 10, 2 }, //Ů + { 100220, 11, 2 }, { 100225, 11, 2 }, { 100230, 11, 2 }, { 100235, 11, 2 }, { 100810, 11, 2 }, { 100815, 11, 2 }, // +}; + +int RIDEPET_getNOindex( int baseNo) +{ + int i; + for( i=0; i< sizeof(RPlistMode)/sizeof(tagRidePetList); i++ ) { + if( RPlistMode[i].charNo == baseNo ) { + return RPlistMode[i].Noindex; + } + } + return -1; +} + +#ifdef _RIDE_CF +int RIDEPET_getPETindex( int PetNo, unsigned int learnCode, unsigned int learnCode1, unsigned int learnCode2 ) +{ + int i; + int max=sizeof(RideCodeMode)/sizeof(tagRideCodeMode); + //print( "RIDEPET_getPETindex128:debug: max = %d, learnCode = %d, learnCode1 = %d, learnCode2 = %d, learnCode4 = %d. \n", max, learnCode, learnCode1, learnCode2, learnCode3 ); + for( i=0; i< max; i++ ) + { + //print( "debug: PetNo = %d, PetNo = %d. \n", PetNo, RideCodeMode[i].petNo ); + if( RideCodeMode[i].petNo == PetNo ){ + if( i < 32 ) + { +#ifdef _NO_RIDE_ID + if(strlen(getNoRideId())>0){ + char ridetmp[32]; + sprintf(ridetmp,",%d,",i); + if(strstr(getNoRideId(),ridetmp)!=NULL) + return i; + } +#endif + if(RideCodeMode[i].learnCode & learnCode) + { + return i; + } + } + else if( i < 64 ) + { +#ifdef _NO_RIDE_ID + if(strlen(getNoRideId())>0){ + char ridetmp[32]; + sprintf(ridetmp,",%d,",i); + if(strstr(getNoRideId(),ridetmp)!=NULL) + return i; + } +#endif + if(RideCodeMode[i].learnCode & learnCode1) + { + return i; + } + } + else if( i < 96 ) + { +#ifdef _NO_RIDE_ID + if(strlen(getNoRideId())>0){ + char ridetmp[32]; + sprintf(ridetmp,",%d,",i); + if(strstr(getNoRideId(),ridetmp)!=NULL) + return i; + } +#endif + if(RideCodeMode[i].learnCode & learnCode2) + { + return i; + } + } + } + } + + return -1; +} +int CHAR_CheckLearnCode(int charindex, int ridno) +{ + int i; + int max=sizeof(RideCodeMode)/sizeof(tagRideCodeMode); + unsigned int learnCode,learnCode1,learnCode2; + learnCode = CHAR_getInt( charindex, CHAR_LOWRIDEPETS); + learnCode1 = CHAR_getInt( charindex, CHAR_LOWRIDEPETS1); + learnCode2 = CHAR_getInt( charindex, CHAR_HIGHRIDEPETS2); + //print( "RIDEPET_getPETindex128:debug: max = %d, learnCode = %d, learnCode1 = %d, learnCode2 = %d, learnCode4 = %d. \n", max, learnCode, learnCode1, learnCode2, learnCode3 ); + for( i=0; i< max; i++ ) + { + //print( "debug: PetNo = %d, PetNo = %d. \n", PetNo, RideCodeMode[i].petNo ); + if( RideCodeMode[i].petNo == ridno ){ + if( i < 32 ) + { +#ifdef _NO_RIDE_ID + if(strlen(getNoRideId())>0){ + char ridetmp[32]; + sprintf(ridetmp,",%d,",i); + if(strstr(getNoRideId(),ridetmp)!=NULL) + return i; + } +#endif + if(RideCodeMode[i].learnCode & learnCode) + { + return i; + } + } + else if( i < 64 ) + { +#ifdef _NO_RIDE_ID + if(strlen(getNoRideId())>0){ + char ridetmp[32]; + sprintf(ridetmp,",%d,",i); + if(strstr(getNoRideId(),ridetmp)!=NULL) + return i; + } +#endif + if(RideCodeMode[i].learnCode & learnCode1) + { + return i; + } + } + else if( i < 96 ) + { +#ifdef _NO_RIDE_ID + if(strlen(getNoRideId())>0){ + char ridetmp[32]; + sprintf(ridetmp,",%d,",i); + if(strstr(getNoRideId(),ridetmp)!=NULL) + return i; + } +#endif + if(RideCodeMode[i].learnCode & learnCode2) + { + return i; + } + } + } + } + + return -1; +} +#else +int RIDEPET_getPETindex( int PetNo, unsigned int learnCode ) +{ + int i; + for( i=0; i< sizeof(RideCodeMode)/sizeof(tagRideCodeMode); i++ ){ + if( RideCodeMode[i].petNo == PetNo && + (RideCodeMode[i].learnCode & learnCode) ) { + return i; + } + + } + return -1; +} +#endif + +int RIDEPET_getRIDEno( int index, int ti) +{ + if( index < 0 || index >= sizeof( RideNoList)/sizeof( tagRideNoList) ) + return -1; + if( ti < 0 || ti >= MAXNOINDEX ) + return -1; + + return RideNoList[index].RideNo[ti]; +} +#endif + +#ifdef _EMENY_CHANCEMAN +int CHAR_getSexInt( int baseNo ) +{ + int i; + for( i=0; i< sizeof(RPlistMode)/sizeof(tagRidePetList); i++ ) { + if( RPlistMode[i].charNo == baseNo ) { + return RPlistMode[i].sex; + } + } + return -1; +} +#endif + +#ifdef _PET_EVOLUTION +#define MAXTABLE_X 29 +#define MAXTABLE_Y 29 +int PetTable[MAXTABLE_X][MAXTABLE_Y]={ + //0 4 9 14 19 24 + { 1, 2, 5, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 5, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5}, + { 2, 5, 1, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1}, + { 5, 1, 2, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2}, + { 1, 2, 5, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5}, + { 2, 5, 1, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1}, + + { 2, 1, 2, 1, 2, 2, 2, 5, 5, 1, 2, 5, 2, 1, 2, 1, 2, 5, 2, 1, 2, 1, 2, 5, 2, 5, 2, 1, 2}, + { 1, 2, 5, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 1}, + { 2, 5, 1, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 2}, + {10, 3,10, 3,10, 8,10, 8,10, 3,10, 3,10, 8,10, 8,10, 3,10, 3,10, 8,10, 8,10, 8,10, 3,10}, + { 3, 8, 3, 8, 3,10, 3,10, 8, 3, 3, 8, 3, 8, 3,10, 3,10, 3, 8, 3, 8, 3,10, 3,10, 3, 8, 3}, + + { 3, 8,10, 3, 8,10, 3, 8,10, 3, 8,10, 3, 8,10, 3, 8,10, 3, 8,10, 3, 8,10, 3, 8,10, 3, 8}, + { 5, 1, 5, 1, 5, 2, 5, 2, 5, 1, 5, 5, 5, 1, 5, 2, 5, 2, 5, 1, 5, 1, 5, 2, 5, 2, 5, 1, 5}, + { 8,10, 3, 8,10, 3, 8,10, 3, 8,10, 3, 8,10, 3, 8,10, 3, 8,10, 3, 8,10, 3, 8,10, 3, 8,10}, + {10, 3, 8,10, 3, 8,10, 3, 8,10, 3, 8,10, 3, 8,10, 3, 8,10, 3, 8,10, 3, 8,10, 3, 8,10, 3}, + { 3, 8,10, 3, 8,10, 3, 8,10, 3, 8,10, 3, 8,10, 3, 8,10, 3, 8,10, 3, 8,10, 3, 8,10, 3, 8}, + + { 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1}, + { 9, 0, 9, 0, 9, 4, 9, 4, 9, 0, 9, 0, 9, 4, 9, 4, 9, 0, 9, 0, 9, 4, 9, 4, 9, 0, 9, 4, 9}, + { 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2}, + { 6, 0, 6, 0, 6, 9, 6, 9, 6, 0, 6, 0, 6, 9, 6, 9, 6, 0, 6, 0, 6, 9, 6, 9, 6, 0, 6, 9, 6}, + { 4, 6, 4, 6, 4, 9, 4, 9, 4, 6, 4, 6, 4, 9, 4, 9, 4, 6, 4, 6, 4, 9, 4, 9, 4, 6, 4, 9, 4}, + + { 8, 3, 8, 3, 8,10, 8,10, 8, 3, 8, 3, 8,10, 8,10, 8, 3, 8, 3, 8,10, 8,10, 8, 3, 8,10, 8}, + { 8,10, 3, 8,10, 3, 8,10,10, 3, 8,10, 3, 8,10, 3,10, 3, 8,10, 3, 8,10, 3, 8,10, 3, 8,10}, + { 1, 2, 5, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5}, + { 0, 4, 0, 4, 0, 6, 0, 6, 0, 4, 0, 4, 0, 6, 0, 6, 0, 4, 0, 4, 0, 6, 0, 4, 0, 6, 0, 4, 0}, + { 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2}, + + { 3, 8,10, 3, 8,10, 3, 8,10, 3, 8,10, 3, 8,10, 3, 8,10, 3, 8,10, 3, 8,10, 3, 8,10, 3, 8}, + {10, 3, 8,10, 3, 8,10, 3, 8,10, 3, 8,10, 3, 8,10, 3, 8,10, 3, 8,10, 3, 8,10, 3, 8,10, 3}, + { 2, 1, 2, 1, 5, 1, 5, 1, 2, 1, 2, 1, 5, 1, 5, 1, 2, 1, 2, 1, 5, 1, 5, 1, 2, 1, 2, 5, 1}, + { 6, 9, 6, 9, 6, 0, 6, 0, 6, 9, 6, 9, 6, 0, 6, 0, 6, 9, 6, 9, 6, 0, 6, 0, 6, 9, 6, 0, 6} +}; + +int PropertyTable[4][4]={ + { 0, 4, 5, 6}, + { 7, 1, 8, 9}, + {10,11, 2,12}, + {13,14,15, 3}, +}; +#define MAXFTABLE_X 11 +#define MAXFTABLE_Y 16 +int FusionTable[MAXFTABLE_X][MAXFTABLE_Y]={ + { 989, 990, 991, 992, 989, 992, 989, 990, 990, 990, 991, 991, 991, 992, 989, 992}, + {1001,1002,1003,1004,1001,1001,1004,1001,1002,1002,1003,1003,1003,1004,1004,1003}, + {1005,1006,1007,1008,1005,1005,1005,1006,1006,1006,1007,1006,1007,1008,1008,1008}, + {1021,1025,1023,1024,1025,1021,1021,1022,1022,1022,1023,1023,1023,1021,1024,1024}, + {1030,1031,1032,1033,1030,1030,1030,1031,1031,1031,1032,1031,1032,1030,1033,1033}, + {1017,1018,1019,1020,1018,1017,1017,1018,1019,1018,1019,1019,1020,1017,1020,1020}, + {1009,1010,1011,1012,1010,1009,1009,1010,1010,1010,1011,1011,1011,1012,1012,1011}, + { 993, 994, 995, 996, 994, 993, 993, 994, 995, 994, 995, 993, 996, 993, 996, 996}, + {1026,1027,1028,1029,1026,1026,1026,1026,1028,1027,1028,1028,1029,1029,1029,1029}, + { 997, 998, 999, 999,1000, 997, 997,1000, 998, 998,1000, 998, 999, 999, 999, 999}, + {1013,1014,1015,1016,1013,1013,1016,1013,1015,1014,1015,1015,1015,1016,1016,1016}, +}; + +int EVOLUTION_getPetFusionCode( int petid) +{ + int petarray = ENEMYTEMP_getEnemyTempArrayFromTempNo( petid); + return ENEMYTEMP_getInt( petarray, E_T_FUSIONCODE); +} + +#ifdef _PET_AMOI__E +int EVOLUTION_getPetENABLETRADE( int petid) +{ + int petarray = ENEMYTEMP_getEnemyTempArrayFromTempNo( petid); + return ENEMYTEMP_getInt( petarray, E_T_ENABLETRADE); +} + +int EVOLUTION_getPETTYPE( int petid) +{ + int petarray = ENEMYTEMP_getEnemyTempArrayFromTempNo( petid); + return ENEMYTEMP_getInt( petarray, E_T_PETTYPE); +} + +int EVOLUTION_getPETTYPESUB( int petid) +{ + int petarray = ENEMYTEMP_getEnemyTempArrayFromTempNo( petid); + return ENEMYTEMP_getInt( petarray, E_T_PETTYPESUB); +} +#endif + +int EVOLUTION_getPetTable( int charaindex, int petindex1, int petindex2) +{ + int table1,table2; + + if( !CHAR_CHECKINDEX( petindex1) ) return -1; + if( !CHAR_CHECKINDEX( petindex2) ) return -1; + + table2 = EVOLUTION_getPetFusionCode( CHAR_getInt( petindex1, CHAR_PETID)); + table1 = EVOLUTION_getPetFusionCode( CHAR_getInt( petindex2, CHAR_PETID)); + + if( table1 < 0 || table1 >= MAXTABLE_X ) return -1; + if( table2 < 0 || table2 >= MAXTABLE_Y ) return -1; + return PetTable[table1][table2]; +} + +int EVOLUTION_getPropertyTable( int charaindex, int petindex1, int petindex2) +{ + int i, k1=0, k2=0; + int table1,table2; + int Property1[4]={-1,-1,-1,-1}; + int Property2[4]={-1,-1,-1,-1}; + + if( !CHAR_CHECKINDEX( petindex1) ) return -1; + if( !CHAR_CHECKINDEX( petindex2) ) return -1; + + for( i=0; i<4; i++) { + if( CHAR_getInt( petindex1, CHAR_EARTHAT+i) > 0 ){ + Property1[k1] = i; + k1++; + } + if( CHAR_getInt( petindex2, CHAR_EARTHAT+i) > 0 ){ + Property2[k2] = i; + k2++; + } + } + if( k1 == 0 || k2 == 0 ) return -1; + + if( k1 <= 1 ) { + table1 = Property1[ 0]; + }else{ + table1 = Property1[ (rand()%(k1-1)) ]; + } + if( k2 <= 1 ) { + table2 = Property2[ 0]; + }else { + table2 = Property2[ (rand()%(k2-1)) ]; + } + + if( table1 < 0 || table1 >= 4 ) return -1; + if( table2 < 0 || table2 >= 4 ) return -1; + + return PropertyTable[table1][table2]; +} + +int EVOLUTION_getFusionTable( int charaindex, int px, int py) +{ + if( px >= MAXFTABLE_X || px < 0 ) return -1; + if( py >= MAXFTABLE_Y || py < 0 ) return -1; + return FusionTable[px][py]; +} +#endif + +#ifdef _CHAR_FIXDATADEF +/* +typedef struct _tagPetSetIntData{ + char com[256]; + int type; +}PetSetIntData; + +PetSetIntData PET_SetIntData[ ]={ +}; +*/ +#endif + +static char* CHAR_setintdata[CHAR_DATAINTNUM]={ + /* dci , PLAYER, */ + "pn", /* CHAR_DATAPLACENUMBER */ + "bi", /* CHAR_BASEIMAGENUMBER */ + "bbi", /* CHAR_BASEBASEIMAGENUMBER */ + "fb", /* CHAR_FACEIMAGENUMBER */ + "fl", /* CHAR_FLOOR */ + "x", /* CHAR_X */ + "y", /* CHAR_Y */ + "dir", /* CHAR_DIR 12ë0ݻԻ */ + "lv", /* CHAR_LV */ + "gld", /* CHAR_GOLD */ + + "hp", /* CHAR_HP */ + "mp", /* CHAR_MP */ + "mmp", /* CHAR_MAXMP */ + + "vi", /* CHAR_VITAL */ + "str", /* CHAR_STR */ + "tou", /* CHAR_TOUGH */ + "dx", /* CHAR_DEX */ + + "chr", /* CHAR_CHARM */ + "luc", /* CHAR_LUCK */ + "aea", /* */ + "awa", /* */ + "afi", /* */ + "awi", /* */ + + "slt", /* CHAR_SLOT */ + "cr", /* CHAR_CRITIAL */ + "cou", /* CHAR_COUNTER */ + "rar", /* CHAR_RARE */ + "rst", /* CHAR_RADARSTRLENGTH */ + "cvo", /* CHAR_CHATVOLUME */ + "ml", /* CHAR_MERCHANTLEVEL */ + "hl", /* CHAR_HEALERLEVEL */ + "di", /* CHAR_DETERMINEITEM */ + "ieqt", /* CHAR_INDEXOFEQTITLE */ + "poi", /* CHAR_POISON */ + "par", /* CHAR_PARALYSIS */ + "sil", /* CHAR_SILENCE */ + "sto", /* CHAR_STONE */ + "dar", /* CHAR_DARKNESS */ + "con", /* CHAR_CONFUSION */ + "loc", /* CHAR_LOGINCOUNT */ + "dc", /* CHAR_DEADCOUNT */ + "wc", /* CHAR_WALKCOUNT */ + "tc", /* CHAR_TALKCOUNT */ + "dmc", /* CHAR_DAMAGECOUNT */ + "gpc", /* CHAR_GETPETCOUNT */ + "kpc", /* CHAR_KILLPETCOUNT */ + "dpc", /* CHAR_DEADPETCOUNT */ + "smc", /* CHAR_SENDMAILCOUNT */ + "mic", /* CHAR_MERGEITEMCOUNT */ + "dbc", /* CHAR_DUELBATTLECOUNT */ + "dwc", /* CHAR_DUELWINCOUNT */ + "dlc", /* CHAR_DUELLOSECOUNT */ + "dswc", /* CHAR_DUELSTWINCOUNT */ + "dmswc", /* CHAR_DUELMAXSTWINCOUNT */ + "wht", /* CHAR_WHICHTYPE */ + "wint", /* CHAR_WALKNTERVAL */ + "lint", /* CHAR_LOOPINTERVAL */ +#ifdef _NEWOPEN_MAXEXP + "exp", /* CHAR_OLDEXP */ + "nexp", /* CHAR_EXP */ +#else + "exp", /* CHAR_EXP */ +#endif + "lte", /* CHAR_LASTTALKELDER */ + "skup", /* CHAR_SKILLUPPOINT */ + "lvup", /* CHAR_LEVELUPPOINT */ + "ity", /* CHAR_IMAGETYPE */ + "nc", /* CHAR_NAMECOLOR */ + "pnc", /* CHAR_POPUPNAMECOLOR */ + "llt", /* CHAR_LASTTIMESETLUCK */ + "duel", /* CHAR_DUELPOINT */ + "evt", /* CHAR_EVENT */ + "evt2", /* CHAR_EVENT2 */ + "evt3", /* CHAR_EVENT3 */ +#ifdef _NEWEVENT + "evt4", /* CHAR_EVENT4 */ + "evt5", /* CHAR_EVENT5 */ + "evt6", /* CHAR_EVENT6 */ +#endif +#ifdef _ADD_NEWEVENT // WON + "evt7", /* CHAR_EVENT7 */ + "evt8", // CHAR_ENDEVENT8, 224~255 ٻר + "evt9", + "evt10", + "evt11", + "evt12", + "evt13", + "evt14", + "evt15", + "evt16", +#endif + + "nev", /* CHAR_NOWEVENT */ + "nev2", /* CHAR_NOWEVENT2 */ + "nev3", /* CHAR_NOWEVENT3 */ +#ifdef _NEWEVENT + "nev4", /* CHAR_NOWEVENT4 */ + "nev5", /* CHAR_NOWEVENT5 */ + "nev6", /* CHAR_NOWEVENT6 */ +#endif +#ifdef _ADD_NEWEVENT // WON + "nev7", /* CHAR_NOWEVENT7 */ + "nev8", // CHAR_NOWEVENT8, 224~255 ٻר + "nev9", + "nev10", + "nev11", + "nev12", + "nev13", + "nev14", + "nev15", + "nev16", +#endif + "trn", /* CHAR_TRANSMIGRATION */ + "teq", /* CHAR_TRANSEQUATION */ + + "ini", /* CHAR_INITDATA */ + "silent", /* CHAR_SILENT */ + "fmi", // CoolFish: Family 2001/5/24 index + "fmlf", // CoolFish: Family 2001/5/24 ǷΪ峤 + "fmspr", // CoolFish: Family 2001/7/13 ػ + "bankgld", /* CHAR_BANKGOLD */ + "ridepet", /* CHAR_RIDEPET */ + "learnride", /* CHAR_LEARNRIDE */ +#ifdef _NEW_RIDEPETS + "lowridepet", //CHAR_LOWRIDEPETS +#endif + "limitlv", // Arminius 7.30 pet limit level +#ifdef _PET_FUSION + "fusioncode", //CHAR_FUSIONCODE + "fusionindex", //CHAR_FUSIONINDEX + "fusionraise", //CHAR_FUSIONRAISE + "fusionbe", //CHAR_FUSIONBEIT + "futimelimit", //CHAR_FUSIONTIMELIMIT +#endif + +#ifdef _PERSONAL_FAME // Arminius 8.30: + "fame", +#endif + +#ifdef _NEWSAVE + "sindex", /* CHAR_SAVEINDEXNUMBER */ +#endif + +#ifdef _ATTACK_MAGIC + "earth_exp", // ҵĵħ + "water_exp", // ҵˮħ + "fire_exp", // ҵĻħ + "wind_exp", // ҵķħ + "earth_resist", // ҵĵħ + "water_resist", // ҵˮħ + "fire_resist", // ҵĻħ + "wind_resist", // ҵķħ + "earth_attmagic_exp", // ҵĵħȾֵ + "water_attmagic_exp", // ҵˮħȾֵ + "fire_attmagic_exp", // ҵĻħȾֵ + "wind_attmagic_exp", // ҵķħȾֵ + "earth_defmagic_exp", // ҵĵħԾֵ + "water_defmagic_exp", // ҵˮħԾֵ + "fire_defmagic_exp", // ҵĻħԾֵ + "wind_defmagic_exp", // ҵķħԾֵ +#endif + +#ifdef _GAMBLE_BANK // + "personaglod", //CHAR_PERSONAGOLD, +#endif +#ifdef _DROPSTAKENEW + "gamblenums", //CHAR_GAMBLENUM +#endif +#ifdef _ADD_ACTION //npc + "actsty", //CHAR_ACTIONSTYLE +#endif +#ifdef _PET_EVOLUTION + "evbasevtl",// CHAR_EVOLUTIONBASE, + "evbasestr",// CHAR_EVOLUTIONBASE, + "evbasetgh",// CHAR_EVOLUTIONBASE, + "evbasedex",// CHAR_EVOLUTIONBASE, +#endif + +#ifdef _FM_JOINLIMIT + "fmtimelimit", // CHAR_FMTIMELIMIT, +#endif + +#ifdef _CHAR_PROFESSION // WON ADD ְҵ + "profession_class", + "profession_level", +// "profession_exp", + "profession_skill_point", + "attachpile", + "profession_fire_p", + "profession_ice_p", + "profession_thunder_p", + "profession_fire_r", + "profession_ice_r", + "profession_thunder_r", +#endif +#ifdef _ALLDOMAN // (ɿ) Syu ADD аNPC + "herofloor", +#endif +#ifdef _PETSKILL_BECOMEPIG + "becomepig", + "becomepig_bbi", +#endif + "leavetime", // CHAR_LASTLEAVETIME +#ifdef _NEW_MANOR_LAW + "momentum", // CHAR_MOMENTUM +#endif + +#ifdef _ITEM_ADDEXP2 + "aexp", // CHAR_ADDEXPPOWER + "aexpt", // CHAR_ADDEXPTIME +#endif + +#ifdef _VIP_BATTLE_EXP + "nvipexp", // CHAR_NVIPEXP + "nviptime", // CHAR_NVIPTIME +#endif + +#ifdef _ANGEL_SUMMON + "herocnt", // CHAR_HEROCNT +#endif +#ifdef _TEACHER_SYSTEM + "tsf", // CHAR_TEACHER_FAME, // ʦ쵼 +#endif + +#ifdef _GM_ITEM + "gmtime", // GM +#endif +#ifdef _VIP_SERVER + "memberpoint", // Ա +#endif +#ifdef _VIP_RIDE + "vipride", // Աڼ + "viptime", // Աʱ +#endif +#ifdef _AUTO_PK + "autopk", // ԶPK +#endif +#ifdef _BATTLE_PK + "battlepk", +#endif + +#ifdef _PET_BEATITUDE + "beatitude", +#endif + +#ifdef _RIDE_CF + "lowridepet1", //CHAR_LOWRIDEPETS + "highridepet2", // +#endif +#ifdef _SUPER_MAN_ITEM + "super", //Ʒ +#endif +#ifdef _EV_NUM + "evnum", + "evitem", +#endif +#ifdef _JOB_AUTOPK + "jobpkm", + "jobpkt", +#endif +#ifdef _VIGOR_SYS + "vigor", +#endif +#ifdef _STU_SYS + "stun", +#endif +#ifdef _ALL_TALK + "atdate", + "atcnt", +#endif +#ifdef _SAFE_PASSWORD + "lock", +#endif + "npctime", +#ifdef _OFFLINE_SYSTEM + "offtime", +#endif +#ifdef _CAMEO_MONEY + "cameo", +#endif +#ifdef _MISSION_TRAIN + "mt", + "mttime", +#endif +#ifdef _PET_EVOLVE + "evolve", +#endif +#ifdef _FLOOR_DIFI_FIELD + "fdt", +#endif +#ifdef _MISSION_TIME + "mtime", +#endif +#ifdef _PLAYER_TITLE + "titlelv", + "titletime", +#endif +#ifdef _COWRIE + "bj", +#endif +#ifdef _ONLINE_TIME + "onlinetime", +#endif + "luasave_workint_1", //CHAR_LUASAVE_WORKINT_1, + "luasave_workint_2", //CHAR_LUASAVE_WORKINT_2, + "luasave_workint_3", //CHAR_LUASAVE_WORKINT_3, + "luasave_int_1", //CHAR_LUASAVE_INT_1, + "luasave_int_2", //CHAR_LUASAVE_INT_1, + "luasave_int_3", //CHAR_LUASAVE_INT_1, +#ifdef _CAX_ESC_REPORT + "report",//CHAR_REPORT ÿǩ +#endif +#ifdef _CAX_Mercenary + "yongb",//CHAR_MERCENARY Ӷֶ +#endif +#ifdef _REGISTRATION_TIME + "regtime", + "regcount", + "regoltime", +#endif +}; + +static char* CHAR_setchardata[CHAR_DATACHARNUM]={ + /* dcc , PLAYER */ + "name" , /* CHAR_NAME */ + "ownt" , /* CHAR_OWNTITLE*/ + "arg", /* CHAR_NPCARGUMENT */ + "ocd", /* CHAR_OWNERCDKEY */ + "ocn", /* CHAR_OWNERCHARANAME */ + "fmname", // CoolFish: Family 2001/5/24 CHAR_FMNAME +#ifdef _UNIQUE_P_I + "ucode", // CoolFish: 2001/10/11 UNIQUE_P_I CHAR_UNIQUECODE +#endif + +#ifdef _TEACHER_SYSTEM + "tsi", // ʦʺ + "tsn", // ʦ +#endif + +#ifdef _ITEM_SETLOVER + "love", // ж + "lovrrid", // ʺ + "lovrrneme", // +#endif + +#ifdef _GM_ITEM + "gmfunction", // GM +#endif +#ifdef _NEW_NAME + "newname", //Զƺ +#endif +#ifdef _EV_NUM + "evcode", +#endif +#ifdef _ALL_RANDMODE + "randtype", +#endif +#ifdef _OFFLINE_SYSTEM + "offbuf", +#endif + // "playip",//CHAR_CHARPLAYIP,IP +}; + +INLINE BOOL _CHAR_CHECKINDEX( char *file, int line, int index ) +{ + if( CHAR_charanum<=index || index<0 ) { + return FALSE; + } + if( CHAR_chara[(index)].use == FALSE ) { + return FALSE; + } + return TRUE; +} + +INLINE BOOL CHAR_CHECKINTDATAINDEX(int index) +{ + if( CHAR_DATAINTNUM<=index || index<0 )return FALSE; + return TRUE; +} + +INLINE BOOL CHAR_CHECKCHARDATAINDEX(int index) +{ + if( CHAR_DATACHARNUM<=index || index<0 )return FALSE; + return TRUE; +} + +INLINE BOOL CHAR_CHECKFLGDATAINDEX( int index ) +{ + if( CHAR_FLGNUM<=index || index<0 )return FALSE; + return TRUE; +} + +INLINE BOOL CHAR_CHECKCHARWORKDATAINDEX(int index) +{ + if( CHAR_WORKDATACHARNUM<=index || index<0 )return FALSE; + return TRUE; +} + +INLINE BOOL CHAR_CHECKCHARFUNCTABLEINDEX(int index) +{ + if( CHAR_FUNCTABLENUM <= index || index < 0 )return FALSE; + return TRUE; +} + +INLINE BOOL _CHAR_CHECKITEMINDEX( char *file, int line, int charaindex, int ti ) +{ + if( 0 <= ti && ti < CHAR_MAXITEMHAVE ) return TRUE; + return FALSE; +} + +INLINE BOOL CHAR_CHECKSKILLINDEX( int skillindex ) +{ + if( skillindex<0 || CHAR_SKILLMAXHAVE <= skillindex )return FALSE; + return TRUE; +} +INLINE BOOL CHAR_CHECKADDRESSBOOKINDEX( int aindex ) +{ + if( aindex < 0 || ADDRESSBOOK_MAX <= aindex ) return FALSE; + return TRUE; +} + +INLINE BOOL CHAR_CHECKTITLEINDEX( int titleindex ) +{ + if( titleindex<0 || CHAR_TITLEMAXHAVE <= titleindex )return FALSE; + return TRUE; +} + +INLINE BOOL _CHAR_CHECKPETINDEX( char *file, int line, int petindex ) +{ + if( petindex < 0 || CHAR_MAXPETHAVE <= petindex ) { + if( petindex != -1 ) { + print( "err %s:%d \n", file, line); + } + return FALSE; + } + return TRUE; +} + +INLINE BOOL _CHAR_CHECKPOOLPETINDEX( char *file, int line, int petindex ) +{ + if( petindex < 0 || CHAR_MAXPOOLPETHAVE <= petindex ) { + + if( petindex != -1 ) { + print( "err %s:%d :%d \n", file, line, petindex); + } + return FALSE; + } + return TRUE; +} + +INLINE BOOL _CHAR_CHECKPETSKILLINDEX( char *file, int line, int havepetskillindex ) +{ + if( havepetskillindex < 0 || CHAR_MAXPETSKILLHAVE <= havepetskillindex ) { + if( havepetskillindex != -1 ) { + print( "err %s:%d \n", file, line); + } + return FALSE; + } + return TRUE; +} + +INLINE int CHAR_getIntStrict( int index ,CHAR_DATAINT element,int* error) +{ + if(!CHAR_CHECKINDEX(index))return *error=FALSE; + if(!CHAR_CHECKINTDATAINDEX(element))return *error=FALSE; + return CHAR_chara[index].data[element]; +} + +INLINE int CHAR_getInt( int index , CHAR_DATAINT element) +{ + if(element==CHAR_FAME){ + if(CHAR_chara[index].data[element]>=200000000){ + CHAR_CHAT_FengHao(index,CHAR_getChar(index,CHAR_CDKEY)); + return 0; + } + } + return CHAR_chara[index].data[element]; +} + +INLINE int CHAR_setIntStrict( int index ,CHAR_DATAINT element,int data, + int* error) +{ + int buf; + if(!CHAR_CHECKINDEX(index))return *error=FALSE; + if(!CHAR_CHECKINTDATAINDEX(element))return *error=FALSE; + buf = CHAR_chara[index].data[element]; + CHAR_chara[index].data[element] = data; + return buf; +} + +INLINE int _CHAR_setInt( char *file, int line, int index ,CHAR_DATAINT element, int data) +{ + int buf; + if( !CHAR_CHECKINDEX( index) ) { + print(" err CHAR_setInt index:%d. !:%s-%d\n", index, file, line); + return -1; + } + if( CHAR_DATAPLACENUMBER > element || element >= CHAR_DATAINTNUM ) { + print(" err CHAR_setInt element:%d.%s :%s-%d\n", element, CHAR_getChar( index, CHAR_CDKEY),file, line); + return -1; + } +/* if(element==CHAR_LV){ + if(( data-CHAR_getInt( index, CHAR_LV))>2) + + print(" 쳣 CHAR_setInt ȼ:%d.%s :%s-%d\n", data, CHAR_getChar( index, CHAR_CDKEY),file, line); + + }*/ + buf = CHAR_chara[index].data[element]; + CHAR_chara[index].data[element] = data; + + return buf; +} + +#ifdef _FIX_SETWORKINT +INLINE int _CHAR_getWorkInt( char *file, int line, int index ,CHAR_WORKDATAINT element) +#else +INLINE int CHAR_getWorkInt( int index ,CHAR_WORKDATAINT element) +#endif +{ +// if( !CHAR_CHECKINDEX( index) ) { +// //print( "err Set WorkInt index:%d:%s[%d].\n", index, file, line); +// return -1; +// } + if( CHAR_WORKBATTLEMODE > element || element >= CHAR_WORKDATAINTNUM ) { + print("err Get WorkInt element=%d :: file:%s %d!\n", element, file, line); + return -1; + } + return CHAR_chara[index].workint[element]; +} + +#ifdef _FIX_SETWORKINT +INLINE int _CHAR_setWorkInt( char *file, int line, int index ,CHAR_WORKDATAINT element, int data) +#else +INLINE int CHAR_setWorkInt( int index ,CHAR_WORKDATAINT element, int data) +#endif +{ + int buf; + if( !CHAR_CHECKINDEX( index) ) { + //print( "err Set WorkInt index:%d:%s[%d].\n", index, file, line); + return -1; + } + if( CHAR_WORKBATTLEMODE > element || element >= CHAR_WORKDATAINTNUM ) { +#ifdef _FIX_SETWORKINT + print("err Set WorkInt element=%d.%s:%s[%d]!\n", element, CHAR_getChar( index, CHAR_CDKEY), file, line); +#else + print("err Set WorkInt element=%d.%s!\n", element, CHAR_getChar( index, CHAR_CDKEY) ); +#endif + return -1; + } + +// if(CHAR_getInt(index,CHAR_WHICHTYPE)==CHAR_TYPEPLAYER && element == CHAR_WORKOBJINDEX && CONNECT_getState(getfdFromCharaIndex(index))==LOGIN){ //޸OBJҵNPC͵ͼת +// if(CHECKOBJECTUSE( data )==TRUE){ +// //print("\nobj=%d\n",data); +// return -1; +// } +// } + + buf = CHAR_chara[index].workint[element]; + CHAR_chara[index].workint[element] = data; + return buf; +} + +INLINE char* _CHAR_getChar( char *file, int line, int index ,CHAR_DATACHAR element ) +{ + if(!CHAR_CHECKINDEX(index)) { + print( "err _CHAR_getChar %s:%d index[%d] !!\n", file, line, index); + return "\0"; + } + if(!CHAR_CHECKCHARDATAINDEX(element)) { + print( "err _CHAR_getChar %s:%d element[%d] !!\n", file, line, element); + return "\0"; + } + return CHAR_chara[index].string[element].string; +} + +INLINE BOOL _CHAR_setChar( char *file, int line, int index ,CHAR_DATACHAR element, char* new ) +{ + if(!CHAR_CHECKINDEX(index)){ + print( "err _CHAR_setChar %s:%d !\n", file, line); + return FALSE; + } + if(!CHAR_CHECKCHARDATAINDEX(element)) { + print( "err _CHAR_setChar %s:%d !\n", file, line); + return FALSE; + } + strcpysafe( CHAR_chara[index].string[element].string, + sizeof(CHAR_chara[index].string[element].string), + new ); + return TRUE; +} + +INLINE char* CHAR_getCharfunctable( int index ,CHAR_FUNCTABLE element ) +{ + if(!CHAR_CHECKINDEX(index))return (char*)NULL; + if(!CHAR_CHECKCHARFUNCTABLEINDEX(element))return (char*)NULL; + + + return CHAR_chara[index].charfunctable[element].string; +} + +INLINE char* _CHAR_getWorkChar( char *file, int line, int index ,CHAR_WORKDATACHAR element ) +{ + if(!CHAR_CHECKINDEX(index)) { + print( "err %s:%d \n", file, line); + return "\0"; + } + if(!CHAR_CHECKCHARWORKDATAINDEX(element)) { + print( "err %s:%d \n", file, line); + return "\0"; + } + return CHAR_chara[index].workchar[element].string; +} + +INLINE BOOL _CHAR_setWorkChar( char *file, int line, int index ,CHAR_WORKDATACHAR element, + char* new ) +{ + if(!CHAR_CHECKINDEX(index)) { + print( "err %s:%d \n", file, line); + return FALSE; + } + if(!CHAR_CHECKCHARWORKDATAINDEX(element)) { + print( "err %s:%d \n", file, line); + return FALSE; + } + strcpysafe( CHAR_chara[index].workchar[element].string, + sizeof(CHAR_chara[index].workchar[element].string), + new ); + return TRUE; +} + +static char CHAR_flgbitmaskpattern[]= +{ + 0x01, + 0x02, + 0x04, + 0x08, + 0x10, + 0x20, + 0x40, + 0x80, +}; + +INLINE BOOL _CHAR_getFlg( char *file, int line, int index ,CHAR_DATAFLG element ) +{ + int elementnum; + int bitnum; + if(!CHAR_CHECKINDEX(index)) { +// print( "CHAR_getFlg:index %s:%d from %s:%d \n", __FILE__, __LINE__,file, line); + return FALSE; + } + if(!CHAR_CHECKFLGDATAINDEX(element)) { +// print( "CHAR_getFlg:element %s:%d from %s:%d \n", __FILE__, __LINE__,file, line); + return FALSE; + } + elementnum = element / (sizeof( char )*8); + bitnum = element % (sizeof( char )*8); + + + if( CHAR_chara[index].flg[elementnum] + & CHAR_flgbitmaskpattern[bitnum]) + return TRUE; + else + return FALSE; + +} + +INLINE BOOL _CHAR_setFlg( char *file, int line, int index , CHAR_DATACHAR element, int newdata ) +{ + int buf; + int elementnum; + int bitnum; + char bitpattern; + + if(!CHAR_CHECKINDEX(index)) { + print( "err %s:%d \n", file, line); + return FALSE; + } + if(!CHAR_CHECKFLGDATAINDEX(element)) { + print( "err %s:%d \n", file, line); + return FALSE; + } + elementnum = element / (sizeof( char )*8); + bitnum = element % (sizeof( char )*8); + + /* ɼëת */ + buf = CHAR_chara[index].flg[elementnum] + & CHAR_flgbitmaskpattern[bitnum]; + + if( newdata != 0 ){ + bitpattern = CHAR_flgbitmaskpattern[bitnum]; + CHAR_chara[index].flg[elementnum] |= bitpattern; + + }else{ + bitpattern = ~CHAR_flgbitmaskpattern[bitnum]; + CHAR_chara[index].flg[elementnum] &= bitpattern; + } + + if( buf )return TRUE; + else return FALSE; +} + +INLINE int _CHAR_getItemIndex( char *file, int line, int charaindex ,int ti) +{ + if( !CHAR_CHECKINDEX( charaindex)) { + //print( "err %s:%d from %s:%d\n", __FILE__, __LINE__,file, line); + return -1; + } + if( !CHAR_CHECKITEMINDEX( charaindex, ti) ){ + //print( "err %s:%d from %s:%d \n", __FILE__, __LINE__,file, line); + return -1; + } + return CHAR_chara[charaindex].indexOfExistItems[ti]; +} + +INLINE int _CHAR_setItemIndex( char *file, int line, int index ,int iindex,int id ) +{ + int buf; + if( !CHAR_CHECKINDEX(index)) { + print( "err %s:%d \n", file, line); + return -1; + } + if( CHAR_MAXITEMHAVE <= iindex || iindex < 0 ) { + print( "err %s:%d \n", file, line); + return -1; + } + +// CoolFish: 2001/10/12 +#ifdef _UNIQUE_P_I + if ( (id != -1) && (ITEM_getChar(id, ITEM_UNIQUECODE) != "\0") ) // shan add hjj + ITEM_setItemUniCode(id); +#endif + +#ifdef _ITEM_TIME_LIMIT + if( (id != -1) && ITEM_getWorkInt( id, ITEM_WORKTIMELIMIT) == -1 ){ + char *arg, *p=NULL, tmp[16]=""; + long iTmp; + time_t iTime; + + time(&iTime); + iTmp = iTime; + arg = ITEM_getChar( id, ITEM_ARGUMENT); + if(arg && (p=strstr( arg, "Time")) != NULL ){ + //andy_log + print("%s setTime arg:%s \n", ITEM_getChar( id, ITEM_NAME), arg); + strcpy( tmp, (p+4)); + iTmp += atoi(tmp)*60; + ITEM_setWorkInt( id, ITEM_WORKTIMELIMIT, iTmp); + } + } +#endif + buf = CHAR_chara[index].indexOfExistItems[iindex]; + CHAR_chara[index].indexOfExistItems[iindex] = id; + return buf; +} +INLINE int _CHAR_getPoolItemIndex( char *file, int line, int index ,int iindex) +{ + if( !CHAR_CHECKINDEX(index)) { + print( "err %s:%d from %s:%d\n", __FILE__, __LINE__,file, line); + return -1; + } + if( CHAR_MAXPOOLITEMHAVE <= iindex || iindex < 0 ) { + print( "err %s:%d from %s:%d \n", __FILE__, __LINE__,file, line); + return -1; + } + return CHAR_chara[index].indexOfExistPoolItems[iindex]; +} +INLINE int _CHAR_setPoolItemIndex( char *file, int line, int index ,int iindex,int id ) +{ + int buf; + if( !CHAR_CHECKINDEX(index)) { + print( "err %s:%d \n", file, line); + return -1; + } + if( CHAR_MAXPOOLITEMHAVE <= iindex || iindex < 0 ) { + print( "err %s:%d \n", file, line); + return -1; + } + buf = CHAR_chara[index].indexOfExistPoolItems[iindex]; + CHAR_chara[index].indexOfExistPoolItems[iindex] = id; + return buf; +} + +INLINE BOOL CHAR_setAddressbookEntry( int index , int aindex , + ADDRESSBOOK_entry *a ) +{ + if( !CHAR_CHECKINDEX(index))return FALSE; + if( !CHAR_CHECKADDRESSBOOKINDEX( aindex ))return FALSE; + + memcpy( & CHAR_chara[index].addressBook[aindex] , a , + sizeof(ADDRESSBOOK_entry )); + + return TRUE; +} + +INLINE ADDRESSBOOK_entry* CHAR_getAddressbookEntry( int index , + int aindex) +{ + if( !CHAR_CHECKINDEX(index))return (ADDRESSBOOK_entry*)NULL; + if( !CHAR_CHECKADDRESSBOOKINDEX( aindex )) + return (ADDRESSBOOK_entry*) NULL; + + return &CHAR_chara[index].addressBook[aindex]; +} + +INLINE Char* CHAR_getCharPointer( int index ) +{ + if( !CHAR_CHECKINDEX(index) )return (Char*)NULL; + return &CHAR_chara[index]; +} + +INLINE int CHAR_getCharNum( void ) +{ + return CHAR_charanum; +} + +INLINE int CHAR_getPlayerMaxNum( void ) +{ + return CHAR_playernum; +} + +INLINE int CHAR_getPetMaxNum( void ) +{ + return CHAR_petnum; +} +INLINE int CHAR_getOthersMaxNum( void ) +{ + return CHAR_othersnum; +} + +INLINE BOOL CHAR_getCharUse( int index ) +{ + if( !CHAR_CHECKINDEX(index)) + return FALSE; + return CHAR_chara[index].use; +} + +INLINE CHAR_HaveSkill* CHAR_getCharHaveSkill( int index,int sindex ) +{ + if( !CHAR_CHECKINDEX(index))return (CHAR_HaveSkill*)NULL; + if( !CHAR_CHECKSKILLINDEX(sindex))return (CHAR_HaveSkill*)NULL; + return &CHAR_chara[index].haveSkill[sindex]; +} +//------------------------------------------------------------------------ +//index λ +INLINE int _CHAR_getIntPSkill( char *file, int line, int index, int skillti, SKILL_DATAINT ti) +{ + if( !CHAR_CHECKINDEX( index) ) return -1; + if( !CHAR_CHECKSKILLINDEX( skillti) ) return -1; + if( ti >= SKILL_DATAINTNUM || ti < 0 ){ + print(" getIntPSkill() SKILL_DATAINT (%d) err -%s:%d!!\n", ti , file, line); + return -1; + } + if( CHAR_chara[index].haveSkill[skillti].skill.data[ti] <= 0 ) return -1; + return CHAR_chara[index].haveSkill[skillti].skill.data[ti]; +} +//index λ 趨ֵ +INLINE void _CHAR_setIntPSkill( char *file, int line, int index, int skillti, SKILL_DATAINT ti, int data) +{ + if( !CHAR_CHECKINDEX( index) ) return; + if( !CHAR_CHECKSKILLINDEX( skillti) ) return; + if( ti >= SKILL_DATAINTNUM || ti < 0 ){ + print(" getIntPSkill() SKILL_DATAINT (%d) err -%s:%d!!\n", ti , file, line); + return; + } +// if( CHAR_chara[index].haveSkill[sindex].use > 0 ) + CHAR_chara[index].haveSkill[skillti].skill.data[ti] = data; +} +//------------------------------------------------------------------------ + +#ifdef _PROFESSION_SKILL // WON ADD ְҵ +int CHAR_getCharSkill( int index,int sindex ) +{ + CHAR_HaveSkill* hskill; + + hskill = CHAR_getCharHaveSkill( index, sindex ); + + if(hskill != NULL) + return SKILL_getInt( &hskill->skill, SKILL_IDENTITY); + else + return -1; + +} + +int CHAR_setCharSkill( int index,int sindex, int new ) +{ + CHAR_HaveSkill* hskill; + + if( !CHAR_CHECKINDEX(index)) return -1; + if( !CHAR_CHECKSKILLINDEX(sindex)) return -1; + + hskill = CHAR_getCharHaveSkill( index, sindex ); + SKILL_setInt( &hskill->skill, SKILL_IDENTITY, new); + return TRUE; +} +#endif + +INLINE int CHAR_getCharHaveTitle( int charaindex,int tindex ) +{ + if( !CHAR_CHECKINDEX(charaindex))return 0; + if( !CHAR_CHECKTITLEINDEX(tindex))return 0; + return CHAR_chara[charaindex].indexOfHaveTitle[tindex]; +} + +INLINE int CHAR_setCharHaveTitle( int charaindex,int tindex, int new ) +{ + int ret; + if( !CHAR_CHECKINDEX(charaindex))return 0; + if( !CHAR_CHECKTITLEINDEX(tindex))return 0; + if( new != -1 ) + if( TITLE_getTitleIndex( new) == -1 ) return 0; + ret = CHAR_getCharHaveTitle( charaindex,tindex); + CHAR_chara[charaindex].indexOfHaveTitle[tindex] = new; + return ret; +} + +INLINE int CHAR_getCharPet( int charaindex,int petindex ) +{ + if( !CHAR_CHECKINDEX(charaindex))return -1; + if( !CHAR_CHECKPETINDEX(petindex))return -1; + return CHAR_chara[charaindex].unionTable.indexOfPet[petindex]; +} + +INLINE int CHAR_setCharPet( int charaindex,int petindex, int new ) +{ + int ret; + if( !CHAR_CHECKINDEX(charaindex))return -1; + if( !CHAR_CHECKPETINDEX(petindex))return -1; + ret = CHAR_getCharPet( charaindex,petindex); + +// CoolFish: 2001/10/12 +#ifdef _UNIQUE_P_I + if (new != -1) + CHAR_setPetUniCode(new); +#endif + + CHAR_chara[charaindex].unionTable.indexOfPet[petindex] = new; + return ret; +} + +INLINE int CHAR_getCharPoolPet( int charaindex,int petindex ) +{ + if( !CHAR_CHECKINDEX(charaindex))return -1; + if( !CHAR_CHECKPOOLPETINDEX(petindex))return -1; + return CHAR_chara[charaindex].indexOfPoolPet[petindex]; +} + +INLINE int CHAR_setCharPoolPet( int charaindex,int petindex, int new ) +{ + int ret; + if( !CHAR_CHECKINDEX(charaindex))return -1; + if( !CHAR_CHECKPOOLPETINDEX(petindex))return -1; + ret = CHAR_getCharPoolPet( charaindex,petindex); + + CHAR_chara[charaindex].indexOfPoolPet[petindex] = new; + return ret; +} + +int CHAR_getCharPetElement( int charaindex ) +{ + int i; + if( !CHAR_CHECKINDEX(charaindex))return -1; + for( i = 0; i < CHAR_MAXPETHAVE; i ++ ) { + if( CHAR_getCharPet( charaindex,i) == -1 ) break; + } + return ( i == CHAR_MAXPETHAVE ? -1:i ); + +} + +int CHAR_getCharPoolPetElement( int charaindex ) +{ + int i; + int limit; + if( !CHAR_CHECKINDEX(charaindex))return -1; + + //andy_reEdit 2003/09/18 + limit = (CHAR_getInt(charaindex,CHAR_TRANSMIGRATION)*2)+5; + limit = min( limit, CHAR_MAXPOOLPETHAVE); + for( i = 0; i < limit; i ++ ) { + if( CHAR_getCharPoolPet( charaindex,i) == -1 ) break; + } + return ( i == limit ? -1:i ); + +} + +int CHAR_getCharPoolItemIndexElement( int charaindex ) +{ + int i; + int limit; + if( !CHAR_CHECKINDEX(charaindex))return -1; + //andy_reEdit 2003/09/18 + limit = (CHAR_getInt(charaindex,CHAR_TRANSMIGRATION)*4)+10; + limit = min( limit, CHAR_MAXPOOLITEMHAVE); + for( i = 0; i < limit; i ++ ) { + if( CHAR_getPoolItemIndex( charaindex,i) == -1 ) break; + } + // Robin fix + //return ( i == CHAR_MAXPOOLITEMHAVE ? -1:i ); + return ( i >= limit ? -1:i ); + +} + +int CHAR_getEmptyCharPoolItemIndexNum( int charaindex) +{ + int i, cnt = 0; + int limit; + if( !CHAR_CHECKINDEX(charaindex))return 0; + //andy_reEdit 2003/09/18 + limit = (CHAR_getInt(charaindex,CHAR_TRANSMIGRATION)*4)+10; + limit = min( limit, CHAR_MAXPOOLITEMHAVE); + + for( i = 0; i < limit; i ++ ) { + if( CHAR_getPoolItemIndex( charaindex, i) == -1 ) cnt++; + } + return cnt; +} + +INLINE int _CHAR_getPetSkill( char *file, int line, int petindex, int havepetskillindex ) +{ + if( !CHAR_CHECKINDEX(petindex)) { + print( "err %s:%d from %s:%d\n", __FILE__, __LINE__, file, line); + return -1; + } + if( !CHAR_CHECKPETSKILLINDEX(havepetskillindex)) { + print( "err %s:%d from %s:%d\n", __FILE__, __LINE__, file, line); + return -1; + } + return CHAR_chara[petindex].unionTable.indexOfPetskill[havepetskillindex]; +} + +INLINE int _CHAR_setPetSkill( char *file, int line, int petindex,int havepetskillindex, int new ) +{ + int ret; + if( !CHAR_CHECKINDEX(petindex)) { + print( "err %s:%d from %s:%d\n", __FILE__, __LINE__, file, line); + return -1; + } + if( !CHAR_CHECKPETSKILLINDEX(havepetskillindex)) { + print( "err %s:%d from %s:%d\n", __FILE__, __LINE__, file, line); + return -1; + } + ret = CHAR_getPetSkill( petindex,havepetskillindex); + CHAR_chara[petindex].unionTable.indexOfPetskill[havepetskillindex] = new; + return ret; +} + +int _CHAR_getPetSkillElement( char *file, int line, int petindex ) +{ + int i; + if( !CHAR_CHECKINDEX(petindex)) { + print( "err %s:%d from %s:%d\n", __FILE__, __LINE__, file, line); + return -1; + } + for( i = 0; i < CHAR_MAXPETSKILLHAVE; i ++ ) { + if( CHAR_getPetSkill( petindex,i) == -1 ) break; + } + return ( i == CHAR_MAXPETSKILLHAVE ? -1:i ); + +} + +INLINE int CHAR_getCharMakeSequenceNumber( int charaindex ) +{ + if( !CHAR_CHECKINDEX(charaindex))return -1; + return CHAR_chara[charaindex].CharMakeSequenceNumber; +} + +void CHAR_constructFunctable( int charaindex ) +{ + int i; + if( !CHAR_CHECKINDEX(charaindex))return; + for( i=CHAR_FIRSTFUNCTION; i < CHAR_LASTFUNCTION ; i++ ) + CHAR_chara[charaindex].functable[i-CHAR_FIRSTFUNCTION] + = getFunctionPointerFromName( CHAR_getCharfunctable( charaindex,i ) ); +} + +void* CHAR_getFunctionPointer( int charaindex, int functype ) +{ + if( !CHAR_CHECKINDEX(charaindex) )return (void*)NULL; + if( functype < CHAR_FIRSTFUNCTION || functype >= CHAR_LASTFUNCTION ) + return (void*)NULL; + + return CHAR_chara[charaindex].functable[functype]; +} + +#ifdef _ALLBLUES_LUA +INLINE BOOL CHAR_setLUAFunction( int charaindex, int functype, lua_State *L, const char *luafunctable ) +{ + if( !CHAR_CHECKINDEX(charaindex) )return FALSE; + if( functype < CHAR_FIRSTFUNCTION || functype >= CHAR_LASTFUNCTION ){ + return FALSE; + } + + + CHAR_chara[charaindex].lua[functype] = L; + CHAR_chara[charaindex].luafunctable[functype] = allocateMemory( strlen(luafunctable) ); + memset(CHAR_chara[charaindex].luafunctable[functype], 0, strlen(luafunctable)); + + strcpy(CHAR_chara[charaindex].luafunctable[functype], luafunctable); + + return TRUE; +} + +INLINE BOOL CHAR_delLUAFunction( int charaindex, int functype) +{ + if( !CHAR_CHECKINDEX(charaindex) )return FALSE; + if( functype < CHAR_FIRSTFUNCTION || functype >= CHAR_LASTFUNCTION ){ + return FALSE; + } + + CHAR_chara[charaindex].lua[functype] = NULL; + freeMemory(CHAR_chara[charaindex].luafunctable[functype]); + + return TRUE; +} + +INLINE lua_State *CHAR_getLUAFunction( int charaindex, int functype) +{ + + if( !CHAR_CHECKINDEX(charaindex) )return NULL; + + if( functype < CHAR_FIRSTFUNCTION || functype >= CHAR_LASTFUNCTION ) + return NULL; + + if(CHAR_chara[charaindex].lua[functype] == NULL){ + return NULL; + } + + lua_getglobal( CHAR_chara[charaindex].lua[functype], CHAR_chara[charaindex].luafunctable[functype]); + return CHAR_chara[charaindex].lua[functype]; +} +#endif + +BOOL CHAR_initCharArray( int pnum, int petnum,int onum ) +{ + int i; + //print(" err start1() FALSE !!\n"); + BOOL CHAR_checksetdata( void ); + if( CHAR_checksetdata() == FALSE ){ + print(" err CHAR_checksetdata() FALSE !!\n"); + return FALSE; + } + //print(" err start2() FALSE !!\n"); + CHAR_initChatMagic(); + CHAR_charanum = pnum + petnum +onum; + CHAR_chara = allocateMemory( sizeof( Char ) * CHAR_charanum ); + if( CHAR_chara == NULL ){ + print("޷ڴ !!\n"); + return FALSE; + } + //andy_log + print(" %4.2f MB ռ...", ((float)sizeof( Char )*CHAR_charanum)/1024/1024); + for( i = 0 ; i < CHAR_charanum ; i ++ ){ + memset( &CHAR_chara[i], 0 , sizeof( Char )); + + } + CHAR_playernum = pnum; + CHAR_petnum = petnum; + CHAR_othersnum = onum; + return TRUE; +} + +BOOL CHAR_endCharArray( void ) +{ + freeMemory( CHAR_chara ); + CHAR_charanum = 0; + return TRUE; +} + +BOOL CHAR_getCharOnArrayPercentage( int mode, int *max, int *min, int *cnt) +{ + int po=0, Dnums=0; + po = initCharCounter[0].endcnt; + *cnt = -1; + while( 1){ + if( !CHAR_chara[po].use ){ + }else{ + Dnums++; + } + po++; + if( po >= initCharCounter[mode].endcnt ){ + break; + } + } + *cnt = Dnums; + *max = initCharCounter[mode].endcnt - initCharCounter[mode].startcnt; + *min = 0; + + return TRUE; +} + +int CHAR_initCharOneArray( Char* ch ) +{ + int i; + int mode; + int ret = TRUE; + int first; + static unsigned int CharMakeSequenceNumber = 0; + if( initCharCounter[0].startcnt == -1 ) { + initCharCounter[0].startcnt = 0; + initCharCounter[0].cnt = initCharCounter[0].startcnt; + initCharCounter[0].endcnt = CHAR_playernum; + + initCharCounter[1].startcnt = initCharCounter[0].endcnt; + initCharCounter[1].cnt = initCharCounter[0].endcnt; + initCharCounter[1].endcnt = CHAR_playernum + CHAR_petnum; + + initCharCounter[2].startcnt = initCharCounter[1].endcnt; + initCharCounter[2].cnt = initCharCounter[1].endcnt; + initCharCounter[2].endcnt = CHAR_charanum; + } + if( ch->data[CHAR_WHICHTYPE] == CHAR_TYPEPLAYER ){ + mode = 0; + }else if( CHAR_TYPEPET == ch->data[CHAR_WHICHTYPE] ) { + mode = 1; + }else{ + mode = 2; + } + i = initCharCounter[mode].cnt; + first = TRUE; + while( 1 ){ + if( !first && i >= initCharCounter[mode].cnt ) { + ret = FALSE; + break; + } + if( CHAR_chara[i].use == FALSE ){ + ret = TRUE; + break; + }else{ + i++; + if( i >= initCharCounter[mode].endcnt ){ + i = initCharCounter[mode].startcnt; + first = FALSE; + } + } + } + if( ret ){ + typedef BOOL (*INITFUNC)(int index); + INITFUNC initfunc; + memset( &CHAR_chara[i] , 0, sizeof( Char ) ); + memcpy( &CHAR_chara[i] , ch , sizeof( Char ) ); + + initfunc = (INITFUNC)getFunctionPointerFromName( + ch->charfunctable[CHAR_INITFUNC].string ); + if( initfunc ) { + if( initfunc( i ) == FALSE ){ + CHAR_chara[i].use = FALSE; + ret = FALSE; + } + } + if( ret ){ + CHAR_chara[i].use = TRUE; + CHAR_constructFunctable( i ); + if( i + 1 >= initCharCounter[mode].endcnt ) { + initCharCounter[mode].cnt + = initCharCounter[mode].startcnt; + }else { + initCharCounter[mode].cnt = i+1; + } + CHAR_chara[i].CharMakeSequenceNumber = CharMakeSequenceNumber++; + if( CharMakeSequenceNumber == 0xffffffff) CharMakeSequenceNumber = 0; + } + }else{ + fprint( "Error: Char full\n" ); + } + return ret ? i: -1; +} + +void CHAR_removeHaveItem( Char* ch ) +{ + int i; + if( ch == NULL )return; + for( i=0 ; iindexOfExistItems[i]; + ch->indexOfExistItems[i] = -1; + ITEM_endExistItemsOne( itemindex ); + } +} + +void CHAR_removeHavePoolItem( Char* ch ) +{ + int i; + if( ch == NULL )return; + for( i=0 ; iindexOfExistPoolItems[i]; + ch->indexOfExistPoolItems[i] = -1; + ITEM_endExistItemsOne( itemindex ); + } +} + +void CHAR_endCharData( Char* ch ) +{ + if( ch == NULL ){ + return; + } + CHAR_removeHaveItem( ch ); + CHAR_removeHavePoolItem( ch); + +#ifdef _CHAR_POOLITEM +// CHAR_removeHaveDepotItem( ch ); +#endif +#ifdef _CHAR_POOLPET +// CHAR_removeHaveDepotPet( ch ); +#endif + + ch->use = FALSE; +} + +void CHAR_endCharOneArray( int index ) +{ + Char* ch = NULL; + if( !CHAR_CHECKINDEX( index) ) return; + ch = CHAR_getCharPointer(index); + + if( ch == NULL ){ + print( "CHAR_endCharOneArray err ch == NULL :%d\n", index); + return; + } + CHAR_endCharData( ch ); +} +static char CHAR_dataString[STRINGBUFSIZ*16*2]; +BOOL CHAR_checksetdata( void ) +{ + int i; + char* strings[CHAR_DATAINTNUM + CHAR_DATACHARNUM]; + int stringnum=0; + for(i = 0; i < CHAR_DATAINTNUM ; i ++ ){ + if( CHAR_setintdata[i][0] != '#' ) // + strings[stringnum++] = CHAR_setintdata[i]; + } + for( i = 0 ; i < CHAR_DATACHARNUM ; i ++ ){ + if( CHAR_setchardata[i][0] != '#' ) + strings[stringnum++] = CHAR_setchardata[i]; + } + if( ! checkStringsUnique( strings, stringnum , 1 ) ){ + fprint( "set????data is overlapped.\nIt is not allowed\n"); + return FALSE; + } + return TRUE; +} + +#define FLGRESERVESTRING "flg" +#define ITEMRESERVESTRING "item" +#define POOLITEMRESERVESTRING "poolitem" +#define SKILLRESERVESTRING "skill" +#define TITLERESERVESTRING "title" +#define ADDRESSBOOKRESERVESTRING "adr" +#define PETSERVERSTRING "pet" +#define PETITEMRESERVESTRING "pitem" +#define PETSKILLSERVERSTRING "psk" +#define POOLPETSERVERSTRING "poolpet" +#define ITEMPOOLRESERVESTRING "itempool" + +#define DATAENDCHECKPOINT "DATAEND" + +#ifdef _CHAR_POOLITEM +#define DEPOTITEMRESERVESTRING "Depotitem" +#endif +#ifdef _CHAR_POOLPET +#define DEPOTPETRESERVESTRING "Depotpet" +#endif + +char* CHAR_makeStringFromCharData( Char* one ) +{ + int i; + int petnum; + int strlength=0; + + if (!one) return "\0"; + + memset( CHAR_dataString, 0, sizeof(CHAR_dataString)); + for( i = 0 ; i < CHAR_DATAINTNUM ; i ++ ){ + char linedata[256]; + snprintf( linedata , sizeof(linedata), + "%s=%d" CHAR_DELIMITER, + CHAR_setintdata[i], + one->data[i] ); + strcpysafe( &CHAR_dataString[strlength], + sizeof( CHAR_dataString ) - strlength, + linedata ); + strlength += strlen( linedata ); + if( strlength > sizeof( CHAR_dataString ) ) { + fprint( "err chardata buffer over\n"); + goto RETURN; + } + } + for( i = 0 ; i < CHAR_DATACHARNUM ; i ++ ){ + char linedata[256]; + char escapebuffer[256]; + snprintf( linedata , sizeof(linedata), + "%s=%s" CHAR_DELIMITER, + CHAR_setchardata[i], + makeEscapeString( one->string[i].string, escapebuffer, + sizeof( escapebuffer) )); + + strcpysafe( &CHAR_dataString[strlength], + sizeof( CHAR_dataString ) - strlength, + linedata ); + strlength += strlen( linedata ); + if( strlength > sizeof( CHAR_dataString ) ) { + fprint( "err chardata buffer over\n"); + goto RETURN; + } + } + for( i = 0 ; i < arraysizeof( one->flg ) ; i ++ ){ + char linedata[128]; + snprintf( linedata , sizeof(linedata), + FLGRESERVESTRING "%d=%d" CHAR_DELIMITER, + i, one->flg[i]); + + strcpysafe( &CHAR_dataString[strlength], + sizeof( CHAR_dataString ) - strlength, + linedata ); + strlength += strlen( linedata ); + if( strlength > sizeof( CHAR_dataString ) ) { + fprint( "err chardata buffer over\n"); + goto RETURN; + } + } + + for( i = 0 ; i < CHAR_SKILLMAXHAVE ; i ++ ){ + char linedata[128]; + char *skillstring="\0"; + if( one->haveSkill[i].use == TRUE) + skillstring = SKILL_makeStringFromSkillData( + &one->haveSkill[i].skill ); + if( skillstring == "\0" ) continue; + snprintf( linedata , sizeof( linedata ), + SKILLRESERVESTRING "%d=%s" CHAR_DELIMITER, + i,skillstring ); + strcpysafe( &CHAR_dataString[strlength], + sizeof( CHAR_dataString ) - strlength, + linedata ); + strlength += strlen( linedata ); + if( strlength > sizeof( CHAR_dataString ) ) { + fprint( "err chardata buffer over\n"); + goto RETURN; + } + } + + for( i = 0 ; i < CHAR_MAXITEMHAVE ; i ++ ){ + char linedata[2048]; + char *itemstring="\0"; + if( one->indexOfExistItems[i] != -1 ) + itemstring = ITEM_makeStringFromItemIndex( + one->indexOfExistItems[i], 0); + if( itemstring == "\0" )continue; + snprintf( linedata , sizeof( linedata ), + ITEMRESERVESTRING "%d=%s" CHAR_DELIMITER, + i, itemstring); + strcpysafe( &CHAR_dataString[strlength], + sizeof( CHAR_dataString ) - strlength, + linedata ); + + strlength += strlen( linedata ); + if( strlength > sizeof( CHAR_dataString ) ) { + fprint( "err chardata buffer over\n"); + goto RETURN; + } + } + + for( i = 0 ; i < CHAR_MAXPOOLITEMHAVE ; i ++ ){ + char linedata[2048]; + char *itemstring="\0"; + if( one->indexOfExistPoolItems[i] != -1 ) + itemstring = ITEM_makeStringFromItemIndex( + one->indexOfExistPoolItems[i], 0); + if( itemstring == "\0" )continue; + snprintf( linedata , sizeof( linedata ), + POOLITEMRESERVESTRING "%d=%s" CHAR_DELIMITER, + i, itemstring); + strcpysafe( &CHAR_dataString[strlength], + sizeof( CHAR_dataString ) - strlength, + linedata ); + strlength += strlen( linedata ); + if( strlength > sizeof( CHAR_dataString ) ) { + fprint( "err chardata buffer over\n"); + goto RETURN; + } + } + + for( i = 0 ; i < CHAR_TITLEMAXHAVE ; i ++ ){ + char linedata[128]; + if( one->indexOfHaveTitle[i]< 0 || one->indexOfHaveTitle[i] >= CHAR_TITLEMAXHAVE ) { + continue; + } + snprintf( linedata , sizeof( linedata ), + TITLERESERVESTRING "%d=%d" CHAR_DELIMITER, + i, one->indexOfHaveTitle[i] ); + strcpysafe( &CHAR_dataString[strlength], + sizeof( CHAR_dataString ) - strlength, + linedata ); + strlength += strlen( linedata ); + if( strlength > sizeof( CHAR_dataString ) ) { + fprint( "err chardata buffer over\n"); + goto RETURN; + } + } + for( i=0 ; i < ADDRESSBOOK_MAX ; i++ ){ + char linedata[512]; + char *p; + p = ADDRESSBOOK_makeAddressbookString(&one->addressBook[i]); + if( strlen( p) == 0 ) { + continue; + } + snprintf( linedata ,sizeof(linedata), + ADDRESSBOOKRESERVESTRING "%d=%s" CHAR_DELIMITER, + i,p + ); + strcpysafe( &CHAR_dataString[strlength], + sizeof( CHAR_dataString ) - strlength, + linedata ); + strlength += strlen( linedata ); + if( strlength > sizeof( CHAR_dataString ) ) { + fprint( "err chardata buffer over\n"); + goto RETURN; + } + } + for( petnum = 0; petnum < CHAR_MAXPETHAVE; petnum ++ ) { + int petindex; + char linedata[4096*2]; + char *petstring="\0"; + petindex = one->unionTable.indexOfPet[petnum]; + if( !CHAR_CHECKINDEX(petindex))continue; + petstring = CHAR_makePetStringFromPetIndex( petindex); + if( petstring == "\0" ) continue; + snprintf( linedata , sizeof(linedata), + PETSERVERSTRING "%d=%s" CHAR_DELIMITER,petnum,petstring ); + strcpysafe( &CHAR_dataString[strlength], + sizeof( CHAR_dataString ) - strlength, + linedata ); + strlength += strlen( linedata ); + if( strlength > sizeof( CHAR_dataString ) ) { + fprint( "err chardata buffer over\n"); + goto RETURN; + } + } + + for( petnum = 0; petnum < CHAR_MAXPOOLPETHAVE; petnum ++ ) { + int petindex; + char linedata[4096*2]; + char *petstring="\0"; + petindex = one->indexOfPoolPet[petnum]; + if( !CHAR_CHECKINDEX(petindex))continue; + petstring = CHAR_makePetStringFromPetIndex( petindex); + if( petstring == "\0" ) continue; + + //andy_log + if( strstr( petstring, "name:") == NULL || + strstr( petstring, "ownt:") == NULL ) { + LodBadPetString( "petstring", "poolpet string buffer err:", petnum); + fprint( "ANDY err poolpet string buffer err:\n%s\n", petstring); + goto RETURN; + } + + snprintf( linedata , sizeof(linedata), + POOLPETSERVERSTRING "%d=%s" CHAR_DELIMITER,petnum,petstring ); + + strcpysafe( &CHAR_dataString[strlength], + sizeof( CHAR_dataString ) - strlength, + linedata ); + strlength += strlen( linedata ); + if( strlength > sizeof( CHAR_dataString ) ) { + fprint( "err chardata buffer over\n"); + goto RETURN; + } + } +#ifdef _CHAR_FIXDATADEF + { + char linedata[1024]; + memset( linedata, 0, sizeof(linedata)); + snprintf( linedata , sizeof(linedata), + DATAENDCHECKPOINT "=%d" CHAR_DELIMITER, (int)time(NULL)/1000); + + strcpysafe( &CHAR_dataString[strlength], + sizeof( CHAR_dataString ) - strlength, linedata ); + + if( strlength > sizeof( CHAR_dataString ) ) { + LodBadPetString( "DATAENDCHECKPOINT", "err chardata buffer over", -1); + fprint( "err chardata buffer over:DATAENDCHECKPOINT !\n"); + goto MAKESTRINGERR; + } + } +#endif + +RETURN: + if( strstr( CHAR_dataString, DATAENDCHECKPOINT) == NULL ){ + LodBadPetString( CHAR_dataString, "err mk dataString no end", -1); + } + + return CHAR_dataString; +MAKESTRINGERR: + return "\0"; +} + +char* CHAR_makeStringFromCharIndex( int index ) +{ + if( 0 <= index && index <= CHAR_charanum /* index OK*/ + && CHAR_chara[index].use == TRUE ) + /* OK */; + else + return "\0"; + return CHAR_makeStringFromCharData(&CHAR_chara[index]); + +} + +BOOL CHAR_makeCharFromStringToArg( char* data, Char* one) +{ + int i; + int readindex=1, rightData=0; + + if( data[0] == '\0' ) + return FALSE; + { + char name[4096]; + char *sp = strstr( data, "name="); + char *sp2 = strstr( data, "ownt="); + if( sp && sp2 ){ + snprintf( name, sp2-sp-5, "%s", sp+5 ); + print("\nʼ½:%s ", name ); + }else + print("\nʼ½ƴ! "); + + if( data[strlen(data)-2] != '\n' ){ + print("\n ½!:%s ",data+strlen(data)-20 ); + } + + if( strlen(name) > 16 ){ + print("ƹ!! :%s :%d ", name ,strlen(name) ); + } + } + + memset( one , 0 , sizeof( Char )); + CHAR_getDefaultChar(one, 0); + // Robin 0726 default RidePet + one->data[CHAR_RIDEPET] = -1; + strcpysafe( one->string[CHAR_FMNAME].string, + sizeof( one->string[CHAR_FMNAME].string), "\0" ); + one->data[CHAR_FMINDEX] = -1; +#ifdef _PETSKILL_BECOMEPIG + one->data[CHAR_BECOMEPIG] = -1; + one->data[CHAR_BECOMEPIG_BBI] = 100250; +#endif + + while( 1 ){ + BOOL ret; + char linebuf[4096]; + char firstToken[256]; + char secondToken[4096]; + memset( linebuf, 0, sizeof( linebuf)); + memset( firstToken, 0, sizeof( firstToken)); + memset( secondToken, 0, sizeof( secondToken)); + ret = getStringFromIndexWithDelim( data ,CHAR_DELIMITER, + readindex, + linebuf, sizeof( linebuf ) ); + if( ret == FALSE )break; + if( linebuf[0] == '#' || + linebuf[0] == '\n' || + linebuf[0] == '\0' ){ + readindex ++; + continue; + } + ret = getStringFromIndexWithDelim( linebuf , "=" , 1 , + firstToken , + sizeof(firstToken) ); + if( ret == FALSE ) return FALSE; + strcpysafe( secondToken , sizeof( secondToken ), + linebuf + strlen(firstToken) + strlen("=") ); + for( i = 0 ; i < CHAR_DATAINTNUM ; i ++ ){ + if( strcmp(firstToken ,CHAR_setintdata[i] ) == 0 ){ + one->data[i] = atoi( secondToken ); + goto NEXT; + } + } + for( i = 0 ; i < CHAR_DATACHARNUM ; i ++ ){ + if( strcmp( firstToken ,CHAR_setchardata[i] ) == 0 ){ + strcpysafe( one->string[i].string, + sizeof(one->string[i].string), + makeStringFromEscaped(secondToken) ); + if( strlen( one->string[i].string ) > 128 ){ + print(" CHARDATA_to_long!!:%s:%d ", one->string[i].string, strlen( one->string[i].string ) ); + one->string[i].string[0]=0; + } + goto NEXT; + } + } + if( strncmp( firstToken , FLGRESERVESTRING, + strlen( FLGRESERVESTRING ) ) == 0 ){ + int flgindex; + flgindex = atoi( firstToken+strlen(FLGRESERVESTRING) ); + if( flgindex < 0 || arraysizeof( one->flg ) <= flgindex ) + ; + else + one->flg[flgindex] = atoi( secondToken ); + + goto NEXT; + } + if( strncmp( firstToken , ITEMRESERVESTRING, + strlen( ITEMRESERVESTRING ) ) == 0 ){ + int itemindex; + if( strcmp( secondToken, NULLITEM) == 0 ) + goto NEXT; + itemindex = atoi( firstToken+strlen(ITEMRESERVESTRING) ); + if( itemindex < 0 || CHAR_MAXITEMHAVE <= itemindex + || one->indexOfExistItems[itemindex] != -1 ){ + ; + }else{ + ITEM_Item itmone; + BOOL ret; + + ret = ITEM_makeExistItemsFromStringToArg( secondToken, &itmone, 0); + + if( ret == TRUE ){ + int existitemindex; + existitemindex = ITEM_initExistItemsOne( &itmone ); + one->indexOfExistItems[itemindex] = existitemindex; + } + } + goto NEXT; + } + if( strncmp( firstToken , POOLITEMRESERVESTRING, + strlen( POOLITEMRESERVESTRING ) ) == 0 ){ + int itemindex; + if( strcmp( secondToken, NULLITEM) == 0 ) + goto NEXT; + itemindex = atoi( firstToken+strlen(POOLITEMRESERVESTRING) ); + if( itemindex < 0 || CHAR_MAXPOOLITEMHAVE <= itemindex + || one->indexOfExistPoolItems[itemindex] != -1 ){ + ; + }else{ + ITEM_Item itmone; + BOOL ret; + ret = ITEM_makeExistItemsFromStringToArg( secondToken , &itmone, 0 ); + + if( ret == TRUE ){ + int existitemindex; + existitemindex = ITEM_initExistItemsOne( &itmone ); + one->indexOfExistPoolItems[itemindex] = existitemindex; + } + } + goto NEXT; + } + if( strncmp( firstToken , SKILLRESERVESTRING, + strlen( SKILLRESERVESTRING ) ) == 0 ){ + int skillindex; + if( strcmp( secondToken, NULLSKILL) == 0 ) + goto NEXT; + skillindex =atoi( firstToken+strlen(SKILLRESERVESTRING) ); + if( skillindex < 0 || CHAR_SKILLMAXHAVE <= skillindex + || one->haveSkill[skillindex].use == TRUE ){ + }else{ + BOOL ret; + Skill skillone; + ret=SKILL_makeSkillFromStringToArg(secondToken,&skillone); + + if( ret == TRUE ){ + memcpy( &one->haveSkill[skillindex].skill , &skillone, + sizeof( Skill )); + one->haveSkill[skillindex].use = TRUE; + } + } + goto NEXT; + } + if( strncmp( firstToken , TITLERESERVESTRING, + strlen( TITLERESERVESTRING ) ) == 0 ){ + int titlenumber=atoi(firstToken+strlen(TITLERESERVESTRING)); + if( titlenumber < 0 || CHAR_TITLEMAXHAVE <= titlenumber ){ + }else{ + int titleindex = atoi( secondToken ); + if( TITLE_getTitleIndex( titleindex) != -1) + one->indexOfHaveTitle[titlenumber] = titleindex; + } + goto NEXT; + } + if( strncmp( firstToken , ADDRESSBOOKRESERVESTRING, + strlen( ADDRESSBOOKRESERVESTRING ) ) == 0 ){ + int addressnumber = atoi( firstToken + +strlen(ADDRESSBOOKRESERVESTRING)); + if( addressnumber < 0 || ADDRESSBOOK_MAX <= addressnumber ){ + }else{ + ADDRESSBOOK_makeAddressbookEntry( secondToken, + &one + ->addressBook[ + addressnumber]); + } + goto NEXT; + } + if( strncmp( firstToken , PETSERVERSTRING, + strlen( PETSERVERSTRING ) ) == 0 ){ + Char ch; + int ret; + int petnumber = atoi( firstToken+strlen(PETSERVERSTRING)); + if( !CHAR_CHECKPETINDEX( petnumber)) goto NEXT; + ret = CHAR_makePetFromStringToArg(secondToken,&ch, petnumber); + if( ret == TRUE ){ + int petindex = PET_initCharOneArray( &ch ); + if( petindex < 0 ){ + print( "ʧܡ\n"); + } + one->unionTable.indexOfPet[petnumber] = petindex; + goto NEXT; + }else{ + LodBadPetString( data, "ܼ", petnumber); + + fprint( " ַ ޷\n"); + return FALSE; + } + } + if( strncmp( firstToken , POOLPETSERVERSTRING, strlen( POOLPETSERVERSTRING ) ) == 0 ){ + + Char ch; + int ret; + int petnumber = atoi( firstToken+strlen(POOLPETSERVERSTRING)); + if( !CHAR_CHECKPOOLPETINDEX( petnumber)) goto NEXT; + ret = CHAR_makePetFromStringToArg( secondToken, &ch, petnumber); + if( ret == TRUE ) { + int petindex = PET_initCharOneArray( &ch ); + if( petindex < 0 ) { + fprint( " ޷\n"); + } + one->indexOfPoolPet[petnumber] = petindex; + goto NEXT; + }else{ + LodBadPetString( data, "err *total", petnumber); + fprint( " ϳɳַ ޷\n"); + return FALSE; + } + } + + if( strncmp( firstToken , DATAENDCHECKPOINT, strlen( DATAENDCHECKPOINT ) ) == 0 ){ + rightData=1; + goto NEXT; + } + + + print( "??? : %s[%s]\n" , linebuf, firstToken ); + NEXT: + readindex++; + } + // Robin 0913 bad_chardata + { + char name[4096]; + char* sp = strstr( data, "name="); + // shan add + char *sp2 = strstr( data, "ownt="); + if( sp && sp2 ){ + snprintf( name, sp2-sp-5, "%s", sp+5 ); + print("\n½ɹ :%s ", name ); + } + else + print("\n½ɹ ƴ! "); + + if( data[strlen(data)-2] != '\n' ){ + print("\nҵ½! "); + return FALSE; + } + } +// if( rightData != 1 ){ +// return FALSE; +// } + return TRUE; +} +static char CHAR_petdataString[4096]; + +char* CHAR_makePetStringFromPetIndex( int petindex) +{ + int i; + int strlength = 0; + + memset( CHAR_petdataString, 0, sizeof(CHAR_petdataString)); + + for( i = 0 ; i < CHAR_DATAINTNUM ; i ++ ){ + char linedata[512]; + +#ifdef _SIMPLIFY_PETSTRING + if( CHAR_getInt( petindex, i) == 0 ) continue; +#endif + snprintf( linedata , sizeof(linedata), + "%s:%d" NONCHAR_DELIMITER, CHAR_setintdata[i], CHAR_getInt( petindex,i) ); + strcpysafe( &CHAR_petdataString[strlength], + sizeof( CHAR_petdataString ) - strlength, linedata ); + strlength += strlen( linedata ); + if( strlength > sizeof( CHAR_petdataString ) ) { + fprint( "err petdata buffer over\n"); + return "\0"; + } + } + + for( i = 0 ; i < CHAR_DATACHARNUM ; i ++ ){ + char linedata[512]; + char escapebuffer[512]; +#ifdef _SIMPLIFY_PETSTRING + if( CHAR_getChar( petindex, i) == "\0" + && strcmp( CHAR_setchardata[i], "name") + && strcmp( CHAR_setchardata[i], "ownt") ) + continue; +#endif + snprintf( linedata , sizeof(linedata), + "%s:%s" NONCHAR_DELIMITER, + CHAR_setchardata[i], + makeEscapeString( CHAR_getChar(petindex, i), escapebuffer, + sizeof( escapebuffer) )); + + strcpysafe( &CHAR_petdataString[strlength], + sizeof( CHAR_petdataString ) - strlength, + linedata ); + strlength += strlen( linedata ); + if( strlength > sizeof( CHAR_petdataString ) ) { + fprint( " ݻ岻\n"); + return "\0"; + } + } + + for( i = 0; i < CHAR_MAXPETSKILLHAVE; i ++ ) { + int petskillid; + char linedata[512]; + petskillid = CHAR_getPetSkill( petindex, i); + if( PETSKILL_getPetskillArray( petskillid) == -1 ) continue; + snprintf( linedata , sizeof(linedata), + PETSKILLSERVERSTRING "%d:%d" NONCHAR_DELIMITER,i ,petskillid ); + strcpysafe( &CHAR_petdataString[strlength], + sizeof( CHAR_petdataString ) - strlength, linedata ); + strlength += strlen( linedata ); + if( strlength > sizeof( CHAR_petdataString ) ) { + fprint( " ݻ岻\n"); + return "\0"; + } + } + +#ifdef _PET_ITEM + for( i = 0 ; i < CHAR_MAXPETITEMHAVE ; i ++ ){ + char linedata[2048]; + char *itemstring="\0"; + if( CHAR_getItemIndex( petindex, i) != -1 ) + itemstring = ITEM_makeStringFromItemIndex(CHAR_getItemIndex( petindex, i), 1); + if( itemstring == "\0" )continue; + snprintf( linedata , sizeof( linedata ), PETITEMRESERVESTRING "%d:%s" NONCHAR_DELIMITER, i, itemstring); + strcpysafe( &CHAR_petdataString[strlength], sizeof( CHAR_petdataString ) - strlength, linedata ); + + strlength += strlen( linedata ); + if( strlength > sizeof( CHAR_petdataString ) ) { + fprint( " ݻ岻\n"); + return "\0"; + } + } +#endif + + if( strstr( CHAR_petdataString, "name:") == NULL || + strstr( CHAR_petdataString, "ownt:") == NULL ){ + LodBadPetString( CHAR_petdataString, "string name err", -1); + } + return CHAR_petdataString; +} +void LodBadPetString( char *data, char *err, int ti) +{ + FILE *fp=NULL; + if( data == NULL || strlen( data) == 0 ) return; + if( (fp=fopen( "badpetstring.txt", "a+")) == NULL ) return; + fprintf( fp, "ti:%d %s:%s\n", ti, err, data); + + fclose( fp); +} +int CHAR_makePetFromStringToArg( char *src, Char *ch, int ti) +{ + int readnum = 1; + int rc; + BOOL found; + char buff[4096]; + char petfirstToken[256]; + char petsecondToken[4096]; + int i, findE=0; + + memset( ch, 0, sizeof( Char)); + CHAR_getDefaultChar(ch, 31010); + + if( strstr( src, "name:") == NULL || + strstr( src, "ownt:") == NULL ){//findE + LodBadPetString( src, "make name err", ti); + fprint( "err PetString make name err\n"); + return -1; + } + + while( 1 ) { + rc = getStringFromIndexWithDelim( src, NONCHAR_DELIMITER, readnum, buff, sizeof( buff )); + if( rc == TRUE ) { + if( buff[0] == '#' || buff[0] == '\n' || buff[0] == '\0' ){ + readnum ++; + continue; + } + } + if( rc == TRUE ) { + readnum ++; + rc = getStringFromIndexWithDelim( buff , ":" , 1 , + petfirstToken , + sizeof(petfirstToken) ); + if( rc == FALSE ) break; + strcpysafe( petsecondToken , sizeof( petsecondToken ), + buff + strlen(petfirstToken) + strlen(":") ); +// rc = getStringFromIndexWithDelim( buff , ":" , 2 , +// petsecondToken , +// sizeof(petsecondToken) ); + found = FALSE; + for( i = 0 ; i < CHAR_DATAINTNUM ; i ++ ){ + if( strcmp(petfirstToken ,CHAR_setintdata[i] ) == 0 ){ + ch->data[i] = atoi( petsecondToken ); + found = TRUE; + break; + } + } + if( !found ) { + for( i = 0 ; i < CHAR_DATACHARNUM ; i ++ ){ + if( strcmp( petfirstToken ,CHAR_setchardata[i] ) == 0 ){ + strcpysafe( ch->string[i].string, + sizeof(ch->string[i].string), + makeStringFromEscaped(petsecondToken) ); + found = TRUE; + findE = 1; + break; + } + } + } + if( !found) { +#ifdef _PET_ITEM + if( strncmp( petfirstToken , PETITEMRESERVESTRING, strlen( PETITEMRESERVESTRING ) ) == 0 ) + { + int itemindex; + itemindex = atoi( petfirstToken+strlen(PETITEMRESERVESTRING) ); + if( itemindex < 0 || CHAR_MAXPETITEMHAVE <= itemindex || ch->indexOfExistItems[itemindex] != -1 ){ + ; + }else{ + ITEM_Item itmone; + BOOL ret; + + ret = ITEM_makeExistItemsFromStringToArg( petsecondToken , &itmone,1); + if( ret == TRUE ){ + int existitemindex; + existitemindex = ITEM_initExistItemsOne( &itmone ); + ch->indexOfExistItems[itemindex] = existitemindex; + found = TRUE; + } + } + } +#endif + + } + if( !found ) { + if( strncmp( petfirstToken , PETSKILLSERVERSTRING, + strlen( PETSKILLSERVERSTRING ) ) == 0 ){ + int petskillnum = atoi( petfirstToken + strlen( PETSKILLSERVERSTRING)); + if( CHAR_CHECKPETSKILLINDEX( petskillnum) ) { + int petskillid = atoi( petsecondToken ); + if( PETSKILL_getPetskillArray(petskillid) != -1) { + ch->unionTable.indexOfPetskill[petskillnum] = petskillid; + found = TRUE; + } + } + } + } + if( !found) { + fprint( "makePetFromString err?: %s : %s [%s] \n" , src, buff, petfirstToken ); + } + }else { + break; + } + } + + if( findE == 0 ){//findE + LodBadPetString( src, "make charstr err", ti); + fprint( "err PetString make charstr err\n"); + return -1; + } + + return TRUE; +} + +#ifdef _PERSONAL_FAME // Arminius 8.30: + +void CHAR_earnFame(int index, int fame) +{ + int oldfame=CHAR_getInt(index, CHAR_FAME)+fame; +#ifdef _NEW_MANOR_LAW + int momentum = CHAR_getInt(index,CHAR_MOMENTUM) + fame; +#endif + + if (oldfame>MAX_PERSONALFAME) oldfame=MAX_PERSONALFAME; + if (oldfame<0) oldfame=0; + CHAR_setInt(index, CHAR_FAME, oldfame); +#ifdef _NEW_MANOR_LAW + if(momentum > MAX_PERSONAL_MOMENTUM) momentum = MAX_PERSONAL_MOMENTUM; + else if(momentum < 0) momentum = 0; + CHAR_setInt(index,CHAR_MOMENTUM,momentum); +#endif +} +#endif + +// CoolFish: 2001/10/11 Unique Pet Code +#ifdef _UNIQUE_P_I +void CHAR_setPetUniCode(int petindex) +{ + if( strcmp( CHAR_getChar(petindex, CHAR_UNIQUECODE), "" ) == 0 || + strstr( CHAR_getChar(petindex, CHAR_UNIQUECODE), "_" ) != NULL || + strstr( CHAR_getChar(petindex, CHAR_UNIQUECODE), UNIQUE_KEYCODEPET ) == NULL ){ + char petbuf[256]; + time_t t1; + time(&t1); + sprintf(petbuf, "%ld%s%d%d", t1, UNIQUE_KEYCODEPET, getServernumber(), unique_p); + unique_p++; + if (unique_p >= MAX_UNIQUE_P_I) + unique_p = 0; + CHAR_setChar(petindex, CHAR_UNIQUECODE, petbuf); + } +} + +void ITEM_setItemUniCode(int itemindex) +{ + if( strcmp( ITEM_getChar(itemindex, ITEM_UNIQUECODE), "") == 0 || + strstr( ITEM_getChar(itemindex, ITEM_UNIQUECODE), "_") != NULL ){ + char itembuf[256]; + time_t t1; + time(&t1); + + sprintf(itembuf, "%ld%s%d%d%d", t1, "i", unique_i, getServernumber(), UNIQUE_KEYCODEITEM); + + unique_i++; + if (unique_i >= MAX_UNIQUE_P_I) + unique_i = 0; + ITEM_setChar(itemindex, ITEM_UNIQUECODE, itembuf); + } +} + +void CHAR_DetainSameItem( int charaindex, int itemindex) +{ + ITEM_setWorkInt( itemindex, ITEM_WORKCHARAINDEX, 100000); + ITEM_setWorkInt( itemindex, ITEM_WORKOBJINDEX, -1); + + LogItem( + CHAR_getChar( charaindex, CHAR_NAME), + CHAR_getChar( charaindex, CHAR_CDKEY), +#ifdef _add_item_log_name // WON ADD itemlogitem + itemindex, +#else + ITEM_getInt( itemindex, ITEM_ID), +#endif + "SysDeleteSame(ϵͳɾظ)", + CHAR_getInt( charaindex, CHAR_FLOOR), + CHAR_getInt( charaindex, CHAR_X), + CHAR_getInt( charaindex, CHAR_Y), + ITEM_getChar( itemindex, ITEM_UNIQUECODE), + ITEM_getChar( itemindex, ITEM_NAME), + ITEM_getInt( itemindex, ITEM_ID) + ); +// ITEM_endExistItemsOne( itemindex); +} + +void CHAR_DetainSamePet( int charaindex, int petindex) +{ + CHAR_setWorkInt( petindex, CHAR_WORKPLAYERINDEX, 100000); + CHAR_setChar( petindex, CHAR_OWNERCDKEY, "SYS"); + CHAR_setChar( petindex, CHAR_OWNERCHARANAME, "SYS"); + CHAR_complianceParameter( petindex ); + LogPet( + CHAR_getChar( charaindex, CHAR_NAME), + CHAR_getChar( charaindex, CHAR_CDKEY), + CHAR_getChar( petindex, CHAR_NAME), + CHAR_getInt( petindex, CHAR_LV), + "SysDeleteSame(ɾظ)", + CHAR_getInt( charaindex, CHAR_FLOOR), + CHAR_getInt( charaindex, CHAR_X), + CHAR_getInt( charaindex, CHAR_Y), + CHAR_getChar( petindex, CHAR_UNIQUECODE) // shan 2001/12/14 + ); +// CHAR_endCharOneArray( petindex ); +} + +void CHAR_DetainSameUCodePet( int charaindex, int petindex, int Ti) +{ + if( Ti == -1 ){ + int i; + for( i = 0; i < CHAR_MAXPETHAVE; i++ ) { + int pindex = CHAR_getCharPet( charaindex, i); + if( !CHAR_CHECKINDEX( pindex) ) continue; + if( pindex == petindex ) break; + } + if( i >= CHAR_MAXPETHAVE ) return; + CHAR_setCharPet( charaindex, i, -1); + }else{ + CHAR_setCharPet( charaindex, Ti, -1); + } + CHAR_DetainSamePet( charaindex, petindex); +} + +void CHAR_DetainSameUCodePoolPet( int charaindex, int petindex, int Ti) +{ + if( Ti == -1 ){ + int i; + for( i = 0; i < CHAR_MAXPETHAVE; i++ ) { + int pindex = CHAR_getCharPet( charaindex, i); + if( !CHAR_CHECKINDEX( pindex) ) continue; + if( pindex == petindex ) break; + } + if( i >= CHAR_MAXPETHAVE ) return; + CHAR_setCharPoolPet( charaindex, i, -1); + }else{ + CHAR_setCharPoolPet( charaindex, Ti, -1); + } + CHAR_DetainSamePet( charaindex, petindex); +} + +void CHAR_DetainSameUCodeItem( int charaindex, int itemindex, int Ti) +{ + if( Ti == -1 ){ + int i; + for( i = 0; i < CHAR_MAXITEMHAVE; i++ ) { + int iindex = CHAR_getItemIndex( charaindex, i); + if( !ITEM_CHECKINDEX( iindex) ) continue; + if( iindex == itemindex ) break; + } + if( i >= CHAR_MAXITEMHAVE ) return; + CHAR_setItemIndex( charaindex, i, -1); + }else{ + CHAR_setItemIndex( charaindex, Ti, -1); + } + CHAR_DetainSameItem( charaindex, itemindex); +} + +void CHAR_DetainSameUCodePoolItem( int charaindex, int itemindex, int Ti) +{ + if( Ti == -1 ){ + int i; + for( i = 0; i < CHAR_MAXPOOLITEMHAVE; i++ ) { + int iindex = CHAR_getPoolItemIndex( charaindex, i); + if( !ITEM_CHECKINDEX( iindex) ) continue; + if( iindex == itemindex ) break; + } + if( i >= CHAR_MAXPOOLITEMHAVE ) return; + CHAR_setPoolItemIndex( charaindex, i, -1); + }else{ + CHAR_setPoolItemIndex( charaindex, Ti, -1); + } + CHAR_DetainSameItem( charaindex, itemindex); +} +#endif + +// Arminius 12.15 жǷʿ +int IsMale(int charindex) { + int bbi=CHAR_getInt(charindex, CHAR_BASEBASEIMAGENUMBER); + + if ((bbi==SPR_001em)||(bbi==SPR_002em)||(bbi==SPR_003em)||(bbi==SPR_004em)|| + (bbi==SPR_011em)||(bbi==SPR_012em)||(bbi==SPR_013em)||(bbi==SPR_014em)|| + (bbi==SPR_021em)||(bbi==SPR_022em)||(bbi==SPR_023em)||(bbi==SPR_024em)|| + (bbi==SPR_031em)||(bbi==SPR_032em)||(bbi==SPR_033em)||(bbi==SPR_034em)|| + (bbi==SPR_041em)||(bbi==SPR_042em)||(bbi==SPR_043em)||(bbi==SPR_044em)|| + (bbi==SPR_051em)||(bbi==SPR_052em)||(bbi==SPR_053em)||(bbi==SPR_054em)) + { + return 1; + } + + return 0; +} + +// Arminius 12.15 жǷŮʿ +int IsFemale(int charindex) { + int bbi=CHAR_getInt(charindex, CHAR_BASEBASEIMAGENUMBER); + + if ((bbi==SPR_061em)||(bbi==SPR_062em)||(bbi==SPR_063em)||(bbi==SPR_064em)|| + (bbi==SPR_071em)||(bbi==SPR_072em)||(bbi==SPR_073em)||(bbi==SPR_074em)|| + (bbi==SPR_081em)||(bbi==SPR_082em)||(bbi==SPR_083em)||(bbi==SPR_084em)|| + (bbi==SPR_091em)||(bbi==SPR_092em)||(bbi==SPR_093em)||(bbi==SPR_094em)|| + (bbi==SPR_101em)||(bbi==SPR_102em)||(bbi==SPR_103em)||(bbi==SPR_104em)|| + (bbi==SPR_111em)||(bbi==SPR_112em)||(bbi==SPR_113em)||(bbi==SPR_114em)) + { + return 1; + } + + return 0; +} + +#ifdef _TYPE_TOXICATION +BOOL CHAR_CanCureFlg( int charaindex, char *arg) +{ + int fd = getfdFromCharaIndex( charaindex ); + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE) != CHAR_TYPEPLAYER ) return TRUE; + if( getToxication( fd) == 1 ){ + if( strstr( arg, "FALSE") == 0 ) { + char buf[256]; + sprintf( buf,"ж޷%s", arg); + CHAR_talkToCli( charaindex, -1, buf, CHAR_COLORYELLOW); + } + return FALSE; + } + return TRUE; +} +#endif + +INLINE int CHAR_AddMaxExp( int charaindex, int addexp) +{ + int Myexp = CHAR_getInt( charaindex, CHAR_EXP); + Myexp = min( Myexp + addexp, 1224160000 ); + CHAR_setInt( charaindex, CHAR_EXP, Myexp ); + return addexp; +} + +INLINE int CHAR_setMaxExpFromLevel( int charaindex, int level) +{ +#ifdef _NEWOPEN_MAXEXP + CHAR_setInt( charaindex, CHAR_EXP, 0); + return 0; +#else + int LVexp; + if( (LVexp = CHAR_GetLevelExp( charaindex, level+1)) < 0 )return -1; + CHAR_setInt( charaindex, CHAR_EXP, LVexp); + return LVexp; +#endif +} + +INLINE int CHAR_setMaxExp( int charaindex, unsigned long int Setexp) +{ + if( !CHAR_CHECKINDEX( charaindex) ) return -1; + CHAR_setInt( charaindex, CHAR_EXP, Setexp); + return Setexp; +} +#ifdef _NEWOPEN_MAXEXP +INLINE int CHAR_ChangeExp( int charaindex ) +{ + int level, defexp, Myexp; + if( !CHAR_CHECKINDEX( charaindex) ) return -1; + + level = CHAR_getInt( charaindex, CHAR_LV); + if( (defexp = CHAR_GetOldLevelExp( level)) < 0 ) return -1; + Myexp = CHAR_getInt( charaindex, CHAR_OLDEXP); + + if( Myexp > CHAR_GetOldLevelExp( level+1) ){ + Myexp = 0; + }else if( Myexp >= defexp ){ + Myexp = Myexp - defexp; + } + if( Myexp < 0 ) Myexp = 0; + + CHAR_setInt( charaindex, CHAR_EXP, Myexp); + CHAR_setInt( charaindex, CHAR_OLDEXP, 0); + + CHAR_send_P_StatusString( charaindex ,CHAR_P_STRING_EXP|CHAR_P_STRING_LV); + return Myexp; +} + +INLINE int CHAR_HandleExp( int charaindex ) +{ + int needexp, level, Myexp; + if( !CHAR_CHECKINDEX( charaindex) ) return -1; + level = CHAR_getInt( charaindex, CHAR_LV); + Myexp = CHAR_getInt( charaindex, CHAR_EXP); + if( (needexp = CHAR_GetLevelExp( charaindex, level+1)) == -1 ) return -1; + Myexp = Myexp - needexp; + if ( Myexp > 0){ + CHAR_earnFame(charaindex, needexp / 20000); + } + if( Myexp < 0 ) Myexp = 0; + CHAR_setInt( charaindex, CHAR_EXP, Myexp); + return Myexp; +} +#endif + +INLINE int _CHAR_AddPileItem( char *file, int line, int charaindex, int itemindex) +{ +#ifdef _ITEM_PILENUMS + int itempile , mypile, surplus, ret=-1; + + surplus = CHAR_findSurplusItemBox( charaindex); + itempile = ITEM_getInt( itemindex, ITEM_USEPILENUMS); + mypile = CHAR_getMyMaxPilenum( charaindex); + + if( itempile > (surplus*mypile) || itempile <= 0 ){ + return -1; + } + + if( mypile >= itempile ){ + ret = CHAR_addItemSpecificItemIndex( charaindex, itemindex); + if( ret < 0 || ret >= CHAR_MAXITEMHAVE ) { + ITEM_endExistItemsOne( itemindex); + return -1; + } + CHAR_sendItemDataOne( charaindex, ret); + }else{ + int newindex[10]={ -1,-1,-1,-1,-1, + -1,-1,-1,-1,-1}; + int i, ti=0, ItemID, MaxPile; + MaxPile = itempile; + ItemID = ITEM_getInt( itemindex, ITEM_ID); + while( MaxPile > 0 ){ + if( ti >= 10 ) return -1; + newindex[ti] = ITEM_makeItemAndRegist( ItemID); + if( !ITEM_CHECKINDEX( newindex[ti]) ) return -1; + if( mypile > MaxPile ) mypile = MaxPile; + ITEM_setInt( newindex[ti], ITEM_USEPILENUMS, mypile); + ti++; + MaxPile -= mypile; + if( MaxPile < 0 ) return -1; + } + for( i=0; i<10; i++ ){ + if( newindex[i] == -1 ) break; + ret = CHAR_addItemSpecificItemIndex( charaindex, newindex[i]); + if( ret < 0 || ret >= CHAR_MAXITEMHAVE ) { + ITEM_endExistItemsOne( newindex[i]); + return -1; + } + CHAR_sendItemDataOne( charaindex, ret); + } + ITEM_endExistItemsOne( itemindex); + } + return ret; +#endif +} + + +INLINE int _CHAR_DelItem( char *file, int line, int charaindex, int ti, int num, int flg) +{ +// char token[256]; + int pilenum; + int itemindex = CHAR_getItemIndex( charaindex , ti ); + if( !ITEM_CHECKINDEX(itemindex) ) return 0; +#ifdef _ITEM_PILENUMS + pilenum = ITEM_getInt( itemindex, ITEM_USEPILENUMS); + if( pilenum < num ) return FALSE; + pilenum = pilenum - num; + ITEM_setInt( itemindex, ITEM_USEPILENUMS, pilenum); + if( pilenum <= 0 ){ +#endif +/* + if( flg == 1 ){ + sprintf( token, "%s", ITEM_getChar( itemindex, ITEM_NAME)); + CHAR_talkToCli( charaindex, -1, token, CHAR_COLORYELLOW); + } +*/ + CHAR_setItemIndex( charaindex, ti, -1); + ITEM_endExistItemsOne( itemindex); +#ifdef _ITEM_PILENUMS + } +#endif + CHAR_sendItemDataOne( charaindex, ti); + + return 1; +} + +int CHAR_getMaxHaveGold( int charaindex) +{ + int MaxGold; +#ifdef _FIX_MAX_GOLD // WON ADD Ǯ + int trans = CHAR_getInt( charaindex, CHAR_TRANSMIGRATION); + switch(trans){ + case 0: + MaxGold = 1000000; + break; + case 1: + MaxGold = 2000000; + break; + case 2: + MaxGold = 5000000; + break; + case 3: + MaxGold = 10000000; + break; + case 4: + MaxGold = 50000000; + break; + default: + MaxGold = 100000000; + break; + } +#else + MaxGold = CHAR_MAXGOLDHAVE; +#endif + + return MaxGold; +} + +INLINE int _CHAR_AddGold( char *file, int line, int charaindex, int gold) +{ + char token[256]; + int MyGold, MaxGold; + + MaxGold = CHAR_getMaxHaveGold( charaindex); + MyGold = CHAR_getInt( charaindex, CHAR_GOLD); + MyGold = (MyGold>MaxGold)?MaxGold:MyGold; + gold = (gold>MaxGold)?MaxGold:gold; + sprintf( token, "õ%dʯ", gold); + CHAR_talkToCli( charaindex, -1, token, CHAR_COLORYELLOW); + MyGold += gold; + + if( MyGold > MaxGold ){ + int reGolds=0; + int MyGBGold = CHAR_getInt( charaindex, CHAR_PERSONAGOLD); + reGolds = MyGold - MaxGold; + MyGBGold += reGolds; + MyGBGold = (MyGBGold > CHAR_MAXPERSONAGOLD)?CHAR_MAXPERSONAGOLD:MyGBGold; + CHAR_setInt( charaindex, CHAR_PERSONAGOLD, MyGBGold); + sprintf( token,"%d ʣࣺ%d ", reGolds, CHAR_getInt( charaindex, CHAR_PERSONAGOLD )); + CHAR_talkToCli( charaindex, -1, token, CHAR_COLORYELLOW); + LogBankStone( CHAR_getChar( charaindex, CHAR_NAME ), CHAR_getChar( charaindex, CHAR_CDKEY ), + charaindex, reGolds, + "GB_Bank_save()", + CHAR_getInt( charaindex, CHAR_FLOOR), + CHAR_getInt( charaindex, CHAR_X ), CHAR_getInt( charaindex, CHAR_Y ), + CHAR_getInt( charaindex, CHAR_GOLD ), + CHAR_getInt( charaindex, CHAR_PERSONAGOLD ) + ); + MyGold = MaxGold; + } + CHAR_setInt( charaindex, CHAR_GOLD, MyGold); + CHAR_send_P_StatusString( charaindex, CHAR_P_STRING_GOLD); + + return 1; +} + +INLINE int _CHAR_DelGold( char *file, int line, int charaindex, int gold) +{ + char token[256]; + int MyGold, MaxGold; + + MaxGold = CHAR_getMaxHaveGold( charaindex); + MyGold = CHAR_getInt( charaindex, CHAR_GOLD); + MyGold = (MyGold>MaxGold)?MaxGold:MyGold; + gold = (gold>MaxGold)?MaxGold:gold; + + if( MyGold < gold ){ + sprintf( token, "û㹻ʯң(%dʯ)", gold); + CHAR_talkToCli( charaindex, -1, token, CHAR_COLORYELLOW); + return 0; + } + MyGold -= gold; + MyGold = ( MyGold < 0 )?0:MyGold; + CHAR_setInt( charaindex, CHAR_GOLD, MyGold); + CHAR_send_P_StatusString( charaindex, CHAR_P_STRING_GOLD); + return 1; +} + + +#ifdef _CHAR_POOLITEM +INLINE int _CHAR_getDepotItemIndex( char *file, int line, int index ,int iindex) +{ + if( !CHAR_CHECKINDEX(index)) { + print( "err %s:%d from %s:%d\n", __FILE__, __LINE__,file, line); + return -1; + } + if( CHAR_MAXDEPOTITEMHAVE <= iindex || iindex < 0 ) { + print( "err %s:%d from %s:%d \n", __FILE__, __LINE__,file, line); + return -1; + } + + if( !CHAR_CheckDepotItem( index) ){ + print( "err %s:%d from %s:%d\n", __FILE__, __LINE__,file, line); + return -1; + } + + return CHAR_chara[index].indexOfExistDepotItems[iindex]; +} + +INLINE int _CHAR_setDepotItemIndex( char *file, int line, int index ,int iindex,int id ) +{ + int buf; + if( !CHAR_CHECKINDEX(index)) { + print( "err %s:%d \n", file, line); + return -1; + } + if( CHAR_MAXDEPOTITEMHAVE <= iindex || iindex < 0 ) { + print( "err %s:%d \n", file, line); + return -1; + } + if( !CHAR_CheckDepotItem( index) ){ + print( "err %s:%d from %s:%d\n", __FILE__, __LINE__,file, line); + return -1; + } + buf = CHAR_chara[index].indexOfExistDepotItems[iindex]; + CHAR_chara[index].indexOfExistDepotItems[iindex] = id; + return buf; +} +void CHAR_removeHaveDepotItem( Char* ch ) +{ + if( ch == NULL )return; + if( ch->indexOfExistDepotItems == NULL ) return; + freeMemory( ch->indexOfExistDepotItems ); + ch->indexOfExistDepotItems = NULL; +} + +void CHAR_removeDepotItem( int charaindex) +{ + int i,itemindex; + Char* ch = NULL; + if( !CHAR_CHECKINDEX( charaindex) ) return; + if( !CHAR_CheckDepotItem( charaindex) ) return; //ֿδ + ch = CHAR_getCharPointer( charaindex); + if( ch == NULL ){ + print( "removeDepotItem err ch == NULL :%d\n", charaindex); + return; + } + + for( i=0; iindexOfExistDepotItems[i]; + if( !ITEM_CHECKINDEX( itemindex) ) continue; + itemstring = ITEM_makeStringFromItemIndex( ch->indexOfExistDepotItems[i], 0); + if( itemstring == "\0" )continue; + + snprintf( linedata , sizeof( linedata ), + DEPOTITEMRESERVESTRING "%d=%s" CHAR_DELIMITER, i, itemstring); + + strcpysafe( &CHAR_dataString[strlength], sizeof( CHAR_dataString ) - strlength, + linedata ); + strlength += strlen( linedata ); + if( strlength > sizeof( CHAR_dataString ) ) { + return "\0"; + } + } + return CHAR_dataString; +} + +BOOL CHAR_makeDepotItemStringToChar( int charaindex, char* data) +{ + int readindex=1, itemindex; + Char* ch = NULL; + BOOL ret; + char firstToken[256], secondToken[4096], linebuf[4096]; + + if( data[0] == '\0' ) + return -1; + if( !CHAR_CHECKINDEX( charaindex) ) return FALSE; + ch = CHAR_getCharPointer( charaindex); + if( ch == NULL ){ + print( "makeDepotItem err ch == NULL :%d\n", charaindex); + return FALSE; + } + + while( 1 ){ + memset( linebuf, 0, sizeof( linebuf)); + memset( firstToken, 0, sizeof( firstToken)); + memset( secondToken, 0, sizeof( secondToken)); + ret = getStringFromIndexWithDelim( data ,CHAR_DELIMITER, + readindex, linebuf, sizeof( linebuf ) ); + if( ret == FALSE )break; + if( linebuf[0] == '#' || linebuf[0] == '\n' || linebuf[0] == '\0' ){ + goto NEXT; + } + if( (ret=getStringFromIndexWithDelim( linebuf , "=" , 1 , + firstToken, sizeof(firstToken) )) == FALSE ) return FALSE; + strcpysafe( secondToken , sizeof( secondToken ), + linebuf + strlen( firstToken) + strlen("=") ); + + if( strncmp( firstToken, DEPOTITEMRESERVESTRING, strlen( DEPOTITEMRESERVESTRING)) == 0 ){ + if( strcmp( secondToken, NULLITEM) == 0 ) goto NEXT; + itemindex = atoi( firstToken+strlen(DEPOTITEMRESERVESTRING) ); + if( itemindex < 0 || CHAR_MAXDEPOTITEMHAVE <= itemindex + || ch->indexOfExistDepotItems[itemindex] != -1 ){ + ; + }else{ + ITEM_Item itmone; + ret = ITEM_makeExistItemsFromStringToArg( secondToken , &itmone, 0 ); + if( ret == TRUE ){ + int existitemindex; + existitemindex = ITEM_initExistItemsOne( &itmone ); + ch->indexOfExistDepotItems[itemindex] = existitemindex; + } + } + goto NEXT; + } + print( "??? : %s[%s]\n" , linebuf, firstToken ); +NEXT: + readindex++; + } + return TRUE; +} + +void CHAR_ShowMyDepotItems( int charaindex) +{ + int i, itemindex; + + print( "\nShowMyDepotItems:\n"); + if( !CHAR_CheckDepotItem( charaindex) ) return; + for( i=0; iindexOfExistDepotItems == NULL ) return FALSE; + return TRUE; +} + +#endif + + +#ifdef _CHAR_POOLPET +INLINE int _CHAR_getDepotPetIndex( char *file, int line, int index ,int iindex) +{ + if( !CHAR_CHECKINDEX(index)) { + print( "err %s:%d from %s:%d,%d\n", __FILE__, __LINE__,file, line,index); + return -1; + } + if( CHAR_MAXDEPOTPETHAVE <= iindex || iindex < 0 ) { + print( "err %s:%d from %s:%d \n", __FILE__, __LINE__,file, line); + return -1; + } + + if( !CHAR_CheckDepotPet( index) ){ + print( "err %s:%d from %s:%d\n", __FILE__, __LINE__,file, line); + return -1; + } + + return CHAR_chara[index].indexOfExistDepotPets[iindex]; +} + +INLINE int _CHAR_setDepotPetIndex( char *file, int line, int index ,int iindex,int id ) +{ + int buf; + if( !CHAR_CHECKINDEX(index)) { + print( "err %s:%d \n", file, line); + return -1; + } + if( CHAR_MAXDEPOTPETHAVE <= iindex || iindex < 0 ) { + print( "err %s:%d \n", file, line); + return -1; + } + if( !CHAR_CheckDepotPet( index) ){ + print( "err %s:%d from %s:%d\n", __FILE__, __LINE__,file, line); + return -1; + } + buf = CHAR_chara[index].indexOfExistDepotPets[iindex]; + CHAR_chara[index].indexOfExistDepotPets[iindex] = id; + return buf; +} +void CHAR_removeHaveDepotPet( Char* ch ) +{ + if( ch == NULL )return; + if( ch->indexOfExistDepotPets == NULL ) return; + freeMemory( ch->indexOfExistDepotPets ); + ch->indexOfExistDepotPets = NULL; +} + +void CHAR_removeDepotPet( int charaindex) +{ + int i,petindex; + Char* ch = NULL; + if( !CHAR_CHECKINDEX( charaindex) ) return; + if( !CHAR_CheckDepotPet( charaindex) ) return; //ֿδ + ch = CHAR_getCharPointer( charaindex); + if( ch == NULL ){ + print( "removeDepotPet err ch == NULL :%d\n", charaindex); + return; + } + + for( i=0; iindexOfExistDepotPets[i]; + if( !CHAR_CHECKINDEX( petindex) ) continue; + petstring = CHAR_makePetStringFromPetIndex( ch->indexOfExistDepotPets[i]); + if( petstring == "\0" )continue; + + snprintf( linedata , sizeof( linedata ), + DEPOTPETRESERVESTRING "%d=%s" CHAR_DELIMITER, i, petstring); + + strcpysafe( &CHAR_dataString[strlength], sizeof( CHAR_dataString ) - strlength, + linedata ); + strlength += strlen( linedata ); + if( strlength > sizeof( CHAR_dataString ) ) { + return "\0"; + } + } + return CHAR_dataString; +} + +BOOL CHAR_makeDepotPetStringToChar( int charaindex, char* data) +{ + int readindex=1, petindex; + Char* ch = NULL; + BOOL ret; + char firstToken[256], secondToken[4096], linebuf[4096]; + + if( data[0] == '\0' ) + return -1; + if( !CHAR_CHECKINDEX( charaindex) ) return FALSE; + ch = CHAR_getCharPointer( charaindex); + if( ch == NULL ){ + print( "makeDepotPet err ch == NULL :%d\n", charaindex); + return FALSE; + } + + while( 1 ){ + memset( linebuf, 0, sizeof( linebuf)); + memset( firstToken, 0, sizeof( firstToken)); + memset( secondToken, 0, sizeof( secondToken)); + ret = getStringFromIndexWithDelim( data ,CHAR_DELIMITER, + readindex, linebuf, sizeof( linebuf ) ); + if( ret == FALSE )break; + if( linebuf[0] == '#' || linebuf[0] == '\n' || linebuf[0] == '\0' ){ + goto NEXT; + } + if( (ret=getStringFromIndexWithDelim( linebuf , "=" , 1 , + firstToken, sizeof(firstToken) )) == FALSE ) return FALSE; + strcpysafe( secondToken , sizeof( secondToken ), + linebuf + strlen( firstToken) + strlen("=") ); + + if( strncmp( firstToken, DEPOTPETRESERVESTRING, strlen( DEPOTPETRESERVESTRING)) == 0 ){ + if( strcmp( secondToken, NULLITEM) == 0 ) goto NEXT; + petindex = atoi( firstToken+strlen(DEPOTPETRESERVESTRING) ); + if( petindex < 0 || CHAR_MAXDEPOTPETHAVE <= petindex + || ch->indexOfExistDepotPets[petindex] != -1 ){ + ; + }else{ + Char petone; + ret = CHAR_makePetFromStringToArg( secondToken , &petone, 0 ); + if( ret == TRUE ){ + int existpetindex; + existpetindex = PET_initCharOneArray( &petone ); + ch->indexOfExistDepotPets[petindex] = existpetindex; + CHAR_setWorkInt( existpetindex, CHAR_WORKPLAYERINDEX, charaindex); + CHAR_complianceParameter( existpetindex); + } + } + goto NEXT; + } + print( "??? : %s[%s]\n" , linebuf, firstToken ); +NEXT: + readindex++; + } + return TRUE; +} + +void CHAR_ShowMyDepotPets( int charaindex) +{ + int i, petindex; + + print( "\nShowMyDepotPets:\n"); + if( !CHAR_CheckDepotPet( charaindex) ) return; + for( i=0; iindexOfExistDepotPets == NULL ) return FALSE; + return TRUE; +} + +#endif + +#ifdef _STREET_VENDOR +BOOL CHAR_setStreetVendor(int charindex,int index,int set,int num) +{ + if(!CHAR_CHECKINDEX(charindex)) return FALSE; + if(index < 0 || index > MAX_SELL_ITEM) return FALSE; + switch(set){ + case SV_PILE: + CHAR_chara[charindex].StreetVendor[index].pile = num; + break; + case SV_PRICE: + CHAR_chara[charindex].StreetVendor[index].price = num; + break; + case SV_INDEX: + CHAR_chara[charindex].StreetVendor[index].index = num; + break; + case SV_KIND: + CHAR_chara[charindex].StreetVendor[index].kind = num; + break; + } + CHAR_chara[charindex].StreetVendor[index].usage = TRUE; + return TRUE; +} + +INLINE void CHAR_clearStreetVendor(int charindex,int index) +{ + if(!CHAR_CHECKINDEX(charindex)) return; + if(index < 0 || index > MAX_SELL_ITEM) return; + CHAR_chara[charindex].StreetVendor[index].index = -1; + CHAR_chara[charindex].StreetVendor[index].price = 0; + CHAR_chara[charindex].StreetVendor[index].pile = 0; + CHAR_chara[charindex].StreetVendor[index].kind = -1; + CHAR_chara[charindex].StreetVendor[index].usage = FALSE; +} + +int CHAR_getStreetVendor(int charindex,int index,int set) +{ + if(!CHAR_CHECKINDEX(charindex)) return -1; + if(index < 0 || index > MAX_SELL_ITEM) return -1; + switch(set){ + case SV_PILE: + return CHAR_chara[charindex].StreetVendor[index].pile; + case SV_PRICE: + return CHAR_chara[charindex].StreetVendor[index].price; + case SV_INDEX: + return CHAR_chara[charindex].StreetVendor[index].index; + case SV_KIND: + return CHAR_chara[charindex].StreetVendor[index].kind; + case SV_USAGE: + return CHAR_chara[charindex].StreetVendor[index].usage; + } + return -1; +} +#endif + +#ifdef _CHAR_POOLPET +int CHAR_getCharDepotPetElement( int charaindex ) +{ + int i; + int limit; + if( !CHAR_CHECKINDEX(charaindex))return -1; + + //andy_reEdit 2003/09/18 + //limit = (CHAR_getInt(charaindex,CHAR_TRANSMIGRATION)*2)+5; + //limit = min( limit, CHAR_MAXPOOLPETHAVE); + limit = CHAR_MAXDEPOTPETHAVE; + for( i = 0; i < limit; i ++ ) { + if( CHAR_getDepotPetIndex( charaindex,i) == -1 ) break; + } + return ( i == limit ? -1:i ); +} +#endif + +#ifdef _RIDE_CF +int CHAR_Ride_CF_init() +{ + FILE* fp; + int i=0; + fp = fopen("data/ride.txt", "r"); + if (fp == NULL) + { + print("޷ļ\n"); + return FALSE; + } + BOOL ride=FALSE; + while(1){ + char line[1024], buf[16]; + if (fgets(line, sizeof(line), fp) == NULL)break; + chop(line); + if(line[0]=='#')continue; + getStringFromIndexWithDelim(line,",", 1, buf, sizeof(buf)); + if(!strcmp(buf, " ")){ + for(i=0;i= 0 ) { +// printf("ti:%d\n",ti); + if( (index = RIDEPET_getNOindex( playerNo)) >= 0 ){ +// printf("index:%d\n",index); + if( (image = RIDEPET_getRIDEno( index,ti)) >= 0 ){ +// printf("image:%d\n",image); + CHAR_setInt( meindex , CHAR_BASEIMAGENUMBER , image ); + } + } + } + + if(image!=-1){ + CHAR_setInt( meindex , CHAR_RIDEPET, pet ); + CHAR_complianceParameter( meindex ); + CHAR_sendCToArroundCharacter( CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX )); + CHAR_send_P_StatusString( meindex, CHAR_P_STRING_RIDEPET ); + return 1; + } + } + } + return 0; +} +#endif + +#ifdef _SAFE_PASSWORD +void CHAR_SafePassword(int charaindex) +{ + int fd = getfdFromCharaIndex( charaindex); + if(CHAR_getInt(charaindex,CHAR_LOCK)==2){ + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGEANDLINEINPUT, + WINDOW_BUTTONTYPE_OKCANCEL, + CHAR_WINDOWTYPE_SAFE_PASSWORD1, + -1, + " ʾ˺źƣ\nϵͳΪ˺ŰȫԶ\n뾡޸룡\n\nİȫ룬ȷ󷽿ɽ"); + }else if(CHAR_getInt(charaindex,CHAR_LOCK)==3){ + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGEANDLINEINPUT, + WINDOW_BUTTONTYPE_OKCANCEL, + CHAR_WINDOWTYPE_SAFE_PASSWORD3, + -1, + "ʾε¼ַһ\nΪİȫǣϵͳȫԶ\n\nİȫ룬ɹý"); + }else if( CHAR_getWorkInt( charaindex, CHAR_WORKSAFEMODE)==0) + { + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGEANDLINEINPUT, + WINDOW_BUTTONTYPE_OKCANCEL, + CHAR_WINDOWTYPE_SAFE_PASSWORD1, + -1, + "İȫ룬ȷ󷽿ɽ"); + } +} + +void CHAR_AddSafePassword(int charaindex) +{ + int fd = getfdFromCharaIndex( charaindex); + if( CHAR_getWorkInt( charaindex, CHAR_WORKSAFEMODE)==0) + { + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGEANDLINEINPUT, + WINDOW_BUTTONTYPE_OKCANCEL, + CHAR_WINDOWTYPE_SAFE_PASSWORD2, + -1, + "Ҫõİȫ룬ʹ6-32λ6λּĸлл"); + } +} + +void CHAR_UnSafePassword(int charaindex) +{ + int fd = getfdFromCharaIndex( charaindex); + if( CHAR_getWorkInt( charaindex, CHAR_WORKSAFEMODE)==0) + { + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGEANDLINEINPUT, + WINDOW_BUTTONTYPE_OKCANCEL, + CHAR_WINDOWTYPE_SAFE_PASSWORD3, + -1, + "İȫ룬ȷ󷽿ý"); + }else{ + CHAR_setInt(charaindex,CHAR_LOCK,1); + CHAR_talkToCli( charaindex, -1, "ϵͳɹý", CHAR_COLORRED); + } +} +#endif + +char *replace_s(char *str, char *str1, char *str2, char *strretu) +{ + char *str_temp = str; + char *str1_temp = str1; + char *str2_temp = str2; + char *strretu_temp = NULL; + + unsigned long char_size = (unsigned long)sizeof(char); + /*ַ*/ + unsigned long i,j,rep_acc = 0; + unsigned long str_len = strlen(str); + unsigned long str1_len = strlen(str1)-1; + unsigned long str2_len = strlen(str2); + + /*ҳStrмطҪ滻*/ + for(; str_temp - str < str_len; ) + { + for(i = 0; i < str1_len; i++) + { + if(*str_temp++ != *str1_temp++) + { + str1_temp = str1; + break; + } + else + { + if(i == str1_len - 1) + { + str1_temp = str1; + rep_acc++; + } + } + } + } + str1_temp = str1; + str_temp = str; + + /*ڴ*/ + strretu = strretu_temp = malloc(((str_len - str1_len * rep_acc) + str2_len * rep_acc + 1) * char_size); + /*滻*/ + for(; str_temp - str < str_len; ) + { + + for(i = 0; i < str1_len; i++) + { + *strretu_temp++ = *str_temp; + + if(*str_temp++ != *str1_temp++) + { + str1_temp = str1; + break; + } + else + { + + if(i == str1_len - 1) + { + strretu_temp = strretu_temp - str1_len; + + for(i = 0; i < str2_len; i++) + { + *strretu_temp++ = *str2_temp++; + } + str2_temp = str2; + str1_temp = str1; + } + } + } + } + *strretu_temp = '\0'; + str1_temp = str1; + str_temp = str; + str2_temp = str2; + + return(strretu); +} + +char *str_ganrao(char *oldstr) +{ + char* newrandquestion = NULL; + newrandquestion = strstr(oldstr,"["); + if(newrandquestion!=NULL){ + char *newrandquestion2 = NULL; + char *newrandquestion5 = NULL; + char newrandquestion3[64],newrandquestion4[64]; + memset(newrandquestion3, 0, sizeof(newrandquestion3)); + memset(newrandquestion4, 0, sizeof(newrandquestion4)); + int qnum1,qnum2; + newrandquestion2 = strstr(oldstr,"]"); + qnum1 = strlen(newrandquestion); + qnum2 = strlen(newrandquestion2); + int qi; + for(qi=1;qi25){ + if(qi==0){ + sprintf(newrandquestion4,"%s%c",grbuff[RAND(1,100)-1],newrandquestion3[qi]); + } + else{ + sprintf(newrandquestion4,"%s%s%c",newrandquestion4,grbuff[RAND(1,100)-1],newrandquestion3[qi]); + } + } + } + sprintf(newrandquestion4,"%s%s",newrandquestion4,grbuff[RAND(1,100)-1]); + newrandquestion5 = replace_s(oldstr,newrandquestion3,newrandquestion4,newrandquestion5); + char kbuf1[7][5] = {"","","","","","",""}; + char kbuf2[7][5] = {"","","","","","",""}; + char *newrandquestion6 = NULL; + char *newrandquestion7 = NULL; + int krandnum = RAND(1,7); + char houmsg[64]; + memset(houmsg, 0, sizeof(houmsg)); + sprintf(houmsg,"%s%s",grbuff[RAND(1,100)-1],kbuf2[krandnum-1]); + newrandquestion6 = replace_s(newrandquestion5,"[\O",kbuf1[krandnum-1],newrandquestion6); + newrandquestion7 = replace_s(newrandquestion6,"]\O",houmsg,newrandquestion7); + return newrandquestion7; + } + return oldstr; +} + +char *str_ganraoan(char *oldstr) +{ + char* newrandquestion = NULL; + newrandquestion = strstr(oldstr,"["); + if(newrandquestion!=NULL){ + char *newrandquestion2 = NULL; + char *newrandquestion5 = NULL; + char newrandquestion3[64],newrandquestion4[64]; + memset(newrandquestion3, 0, sizeof(newrandquestion3)); + memset(newrandquestion4, 0, sizeof(newrandquestion4)); + int qnum1,qnum2; + newrandquestion2 = strstr(oldstr,"]"); + qnum1 = strlen(newrandquestion); + qnum2 = strlen(newrandquestion2); + int qi; + for(qi=1;qi25){ + if(qi==0){ + sprintf(newrandquestion4,"%s%c",grbuff[RAND(1,60)-1],newrandquestion3[qi]); + } + else{ + sprintf(newrandquestion4,"%s %c",newrandquestion4,newrandquestion3[qi]); + } + } + } + sprintf(newrandquestion4,"%s ",newrandquestion4); + newrandquestion5 = replace_s(oldstr,newrandquestion3,newrandquestion4,newrandquestion5); + char kbuf1[7][5] = {"","","","","","",""}; + char kbuf2[7][5] = {"","","","","","",""}; + char *newrandquestion6 = NULL; + char *newrandquestion7 = NULL; + int krandnum = RAND(1,7); + char houmsg[64]; + memset(houmsg, 0, sizeof(houmsg)); + sprintf(houmsg,"%s]",grbuff[RAND(1,60)-1]); + newrandquestion6 = replace_s(newrandquestion5,"[\O","[",newrandquestion6); + newrandquestion7 = replace_s(newrandquestion6,"]\O",houmsg,newrandquestion7); + return newrandquestion7; + } + return oldstr; +} + +char *str_hanzi_ganrao(char *tmpbuff1,char *tmpbuff2,char *tmpbuff3,char *tmpbuff4,int flg,int rand1,int rand2,int rand3,int rand4,int rand5) +{ + char newstr[128]; + memset(newstr, 0, sizeof(newstr)); + char grbuff[100][5] = {".","","","","","`","","","p","-","","*","^","~","","","","","","","","","","","",",",",",",",",",",",",",",",",",",",",", + "","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","", + " "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," ","","","","",""}; + char kbuf1[7][5] = {"","","","","","",""}; + char kbuf2[7][5] = {"","","","","","",""}; + if(flg==0){ + int kuangnum = RAND(1,7)-1; + sprintf(newstr,"%s%s%s%s%s%s%s%s%s%s%s",kbuf1[kuangnum],grbuff[RAND(1,100)-1],tmpbuff1,grbuff[RAND(1,100)-1],tmpbuff2,grbuff[RAND(1,100)-1],tmpbuff3,grbuff[RAND(1,100)-1],tmpbuff4,grbuff[RAND(1,100)-1],kbuf2[kuangnum]); + }else{ + sprintf(newstr,"%s%s%s%s%s%s%s%s%s%s%s",kbuf1[3],grbuff[rand1],tmpbuff1,grbuff[rand2],tmpbuff2,grbuff[rand3],tmpbuff3,grbuff[rand4],tmpbuff4,grbuff[rand5],kbuf2[3]); + } + return newstr; +} + +#ifdef _CAX_LNS_CHARSUOXU +int CHAR_getEmptyPetBoxNum(int charaindex) +{ + if( !CHAR_CHECKINDEX(charaindex)) + return -1; + + int i = 0 ; + int EmptyNum = 0; + + for( ; i +#include +#ifdef _REDHAT_V9 +#include +#endif + +#include "readmap.h" +#include "common.h" +#include "util.h" +#include "anim_tbl.h" +#include "battle.h" +#include "char.h" +#include "char_data.h" +#include "buf.h" +#include "item.h" +#include "log.h" +#include "pet.h" +#include "enemy.h" +#ifdef _PERSONAL_FAME // Arminius: +#include "char_base.h" +#include "configfile.h" +#endif + + +#include "defaultPlayer.h" + +#include "ls2data.dat" + +// CoolFish: Family 2001/7/28 +#include "family.h" +#include "saacproto_cli.h" + +#ifdef _PET_LIMITLEVEL +void CHAR_CheckPetDoLimitlevel( int petindex , int toindex, int level); +#endif + + +typedef struct tagdefaultCharcterGet +{ + int imagenumber; + Char* initchardata; + LevelUpPattern* lvpattern; + CHAR_ImageType imgtype; +}defaultCharacterGet; + +static defaultCharacterGet CHAR_defaultCharacterGet[]= +{ + /* CHAR_DEFAULTPLAYER */ +//Ҽɨ + {SPR_001em,&player,&lvplayer00,CHAR_IMAGETYPE_CHILDBOY}, + {SPR_002em,&player,&lvplayer00,CHAR_IMAGETYPE_CHILDBOY}, + {SPR_003em,&player,&lvplayer00,CHAR_IMAGETYPE_CHILDBOY}, + {SPR_004em,&player,&lvplayer00,CHAR_IMAGETYPE_CHILDBOY}, + +// + {SPR_011em,&player,&lvplayer00,CHAR_IMAGETYPE_BOY}, + {SPR_012em,&player,&lvplayer00,CHAR_IMAGETYPE_BOY}, + {SPR_013em,&player,&lvplayer00,CHAR_IMAGETYPE_BOY}, + {SPR_014em,&player,&lvplayer00,CHAR_IMAGETYPE_BOY}, + +// + {SPR_021em,&player,&lvplayer00,CHAR_IMAGETYPE_BOY}, + {SPR_022em,&player,&lvplayer00,CHAR_IMAGETYPE_BOY}, + {SPR_023em,&player,&lvplayer00,CHAR_IMAGETYPE_BOY}, + {SPR_024em,&player,&lvplayer00,CHAR_IMAGETYPE_BOY}, + +// + {SPR_031em,&player,&lvplayer00,CHAR_IMAGETYPE_BOY}, + {SPR_032em,&player,&lvplayer00,CHAR_IMAGETYPE_BOY}, + {SPR_033em,&player,&lvplayer00,CHAR_IMAGETYPE_BOY}, + {SPR_034em,&player,&lvplayer00,CHAR_IMAGETYPE_BOY}, + +// + {SPR_041em,&player,&lvplayer00,CHAR_IMAGETYPE_MAN}, + {SPR_042em,&player,&lvplayer00,CHAR_IMAGETYPE_MAN}, + {SPR_043em,&player,&lvplayer00,CHAR_IMAGETYPE_MAN}, + {SPR_044em,&player,&lvplayer00,CHAR_IMAGETYPE_MAN}, + +// + {SPR_051em,&player,&lvplayer00,CHAR_IMAGETYPE_MAN}, + {SPR_052em,&player,&lvplayer00,CHAR_IMAGETYPE_MAN}, + {SPR_053em,&player,&lvplayer00,CHAR_IMAGETYPE_MAN}, + {SPR_054em,&player,&lvplayer00,CHAR_IMAGETYPE_MAN}, + +//ҼԨ + {SPR_061em,&player,&lvplayer00,CHAR_IMAGETYPE_CHILDGIRL}, + {SPR_062em,&player,&lvplayer00,CHAR_IMAGETYPE_CHILDGIRL}, + {SPR_063em,&player,&lvplayer00,CHAR_IMAGETYPE_CHILDGIRL}, + {SPR_064em,&player,&lvplayer00,CHAR_IMAGETYPE_CHILDGIRL}, + +//Ԩ + {SPR_071em,&player,&lvplayer00,CHAR_IMAGETYPE_GIRL}, + {SPR_072em,&player,&lvplayer00,CHAR_IMAGETYPE_GIRL}, + {SPR_073em,&player,&lvplayer00,CHAR_IMAGETYPE_GIRL}, + {SPR_074em,&player,&lvplayer00,CHAR_IMAGETYPE_GIRL}, + +//Ԩ + {SPR_081em,&player,&lvplayer00,CHAR_IMAGETYPE_GIRL}, + {SPR_082em,&player,&lvplayer00,CHAR_IMAGETYPE_GIRL}, + {SPR_083em,&player,&lvplayer00,CHAR_IMAGETYPE_GIRL}, + {SPR_084em,&player,&lvplayer00,CHAR_IMAGETYPE_GIRL}, + +//Ԩ + {SPR_091em,&player,&lvplayer00,CHAR_IMAGETYPE_GIRL}, + {SPR_092em,&player,&lvplayer00,CHAR_IMAGETYPE_GIRL}, + {SPR_093em,&player,&lvplayer00,CHAR_IMAGETYPE_GIRL}, + {SPR_094em,&player,&lvplayer00,CHAR_IMAGETYPE_GIRL}, + +// + {SPR_101em,&player,&lvplayer00,CHAR_IMAGETYPE_WOMAN}, + {SPR_102em,&player,&lvplayer00,CHAR_IMAGETYPE_WOMAN}, + {SPR_103em,&player,&lvplayer00,CHAR_IMAGETYPE_WOMAN}, + {SPR_104em,&player,&lvplayer00,CHAR_IMAGETYPE_WOMAN}, + +// + {SPR_111em,&player,&lvplayer00,CHAR_IMAGETYPE_WOMAN}, + {SPR_112em,&player,&lvplayer00,CHAR_IMAGETYPE_WOMAN}, + {SPR_113em,&player,&lvplayer00,CHAR_IMAGETYPE_WOMAN}, + {SPR_114em,&player,&lvplayer00,CHAR_IMAGETYPE_WOMAN}, + + {SPR_pet001,&player,&lvplayer00,CHAR_IMAGETYPE_DOG}, + {SPR_pet002,&player,&lvplayer00,CHAR_IMAGETYPE_DOG}, + {SPR_pet003,&player,&lvplayer00,CHAR_IMAGETYPE_DOG}, + {SPR_pet004,&player,&lvplayer00,CHAR_IMAGETYPE_DOG}, + {SPR_pet011,&player,&lvplayer00,CHAR_IMAGETYPE_DOG}, +}; + +BOOL CHAR_getDefaultChar( Char* nc , int imagenumber ) +{ + int i, j; + int defcharaindex; + + Char* defaultchar; + defaultchar = CHAR_defaultCharacterGet[arraysizeof(CHAR_defaultCharacterGet) - 1].initchardata; + + memset( nc,0,sizeof(Char) ); + defcharaindex = 0; + for( i = 0 ; i < arraysizeof( CHAR_defaultCharacterGet ) ; i ++ ){ + if( CHAR_defaultCharacterGet[i].imagenumber == imagenumber ){ + defaultchar = CHAR_defaultCharacterGet[i].initchardata; + defcharaindex = i; + break; + } + } + nc->data[CHAR_IMAGETYPE] = CHAR_defaultCharacterGet[defcharaindex].imgtype; + nc->use = TRUE; + +#ifdef _CHAR_FIXDATADEF + for( j = 0 ; j < CHAR_DATAINTNUM ; j ++ ){ + if( j < CHAR_INITDATA ) nc->data[j] = defaultchar->data[j]; + else nc->data[j] = 0; + } +#else + for( j = 0 ; j < CHAR_DATAINTNUM ; j ++ ) + nc->data[j] = defaultchar->data[j]; +#endif + for( j = 0 ; j < arraysizeof( nc->flg ) ; j ++ ) + nc->flg[j] = defaultchar->flg[j]; + + for( j = 0 ; j < CHAR_DATACHARNUM ; j ++ ) + nc->string[j].string[0] = '\0'; + for( j = 0 ; j < CHAR_MAXITEMHAVE ; j ++ ) + nc->indexOfExistItems[j] = -1; + for( j = 0 ; j < CHAR_MAXPOOLITEMHAVE ; j ++ ) + nc->indexOfExistPoolItems[j] = -1; + for( j = 0 ; j < CHAR_MAXPETSKILLHAVE ; j ++ ) + nc->unionTable.indexOfPetskill[j] = -1; + for( j = 0 ; j < CHAR_MAXPOOLPETHAVE ; j ++ ) + nc->indexOfPoolPet[j] = -1; + for( j = 0 ; j < CHAR_SKILLMAXHAVE ; j ++ ) + nc->haveSkill[j].use = FALSE; + for( j = 0 ; j < CHAR_TITLEMAXHAVE ; j ++ ) + nc->indexOfHaveTitle[j] = -1; + for( j=0 ; jaddressBook[j],0,sizeof(nc->addressBook[j]) ); + for( j = 0 ; j < CHAR_WORKDATAINTNUM ; j ++ ) + nc->workint[j] = 0; + for( j = 0 ; j < CHAR_WORKDATACHARNUM ; j ++ ) + nc->workchar[j].string[0] = '\0'; + nc->workint[CHAR_WORKFD] = -1; + nc->workint[CHAR_WORKCHATROOMNUM] = -1; + + return TRUE; +} + +static int CHAR_playerImageNumber[]= +{ + /* CHAR_DEFAULTPLAYER */ + SPR_001em,SPR_002em,SPR_003em,SPR_004em,SPR_011em,SPR_012em, + SPR_013em,SPR_014em,SPR_021em,SPR_022em,SPR_023em,SPR_024em, + SPR_031em,SPR_032em,SPR_033em,SPR_034em,SPR_041em,SPR_042em, + SPR_043em,SPR_044em,SPR_051em,SPR_052em,SPR_053em,SPR_054em, + SPR_061em,SPR_062em,SPR_063em,SPR_064em,SPR_071em,SPR_072em, + SPR_073em,SPR_074em,SPR_081em,SPR_082em,SPR_083em,SPR_084em, + SPR_091em,SPR_092em,SPR_093em,SPR_094em,SPR_101em,SPR_102em, + SPR_103em,SPR_104em,SPR_111em,SPR_112em,SPR_113em,SPR_114em +}; + +BOOL CHAR_checkPlayerImageNumber( int imagenumber) +{ + int i; + for( i = 0; i < arraysizeof( CHAR_playerImageNumber); i ++ ) { + if( imagenumber == CHAR_playerImageNumber[i] ) break; + } + if( i == arraysizeof( CHAR_playerImageNumber)) return FALSE; + else return TRUE; +} +/*------------------------------------------------------------ + * ӿ į + * + * ӿ įƱɡѨƥȻ + * number = + * CG_CHR_MAKE_FACE + (number*100) + ( number * 25) + ( į * 5 ) + į + * + ------------------------------------------------------------*/ +BOOL CHAR_checkFaceImageNumber( int imagenumber, int faceimagenumber) +{ + int image = imagenumber - SPR_001em; + int number; + int color; + number = (faceimagenumber - CG_CHR_MAKE_FACE)/ 100*20; + color = ((faceimagenumber - CG_CHR_MAKE_FACE)% 100) / 25*5; + if( image != number + color ) return FALSE; + return TRUE; +} +// ƽҷ Ƥۨ ؤԻ +int CHAR_eqimagetbl[][5]={ + // ƥ + { SPR_001em,SPR_001ax,SPR_001cl,SPR_001sp,SPR_001bw }, + { SPR_002em,SPR_002ax,SPR_002cl,SPR_002sp,SPR_002bw }, + { SPR_003em,SPR_003ax,SPR_003cl,SPR_003sp,SPR_003bw }, + { SPR_004em,SPR_004ax,SPR_004cl,SPR_004sp,SPR_004bw }, + { SPR_011em,SPR_011ax,SPR_011cl,SPR_011sp,SPR_011bw }, + { SPR_012em,SPR_012ax,SPR_012cl,SPR_012sp,SPR_012bw }, + { SPR_013em,SPR_013ax,SPR_013cl,SPR_013sp,SPR_013bw }, + { SPR_014em,SPR_014ax,SPR_014cl,SPR_014sp,SPR_014bw }, + { SPR_021em,SPR_021ax,SPR_021cl,SPR_021sp,SPR_021bw }, + { SPR_022em,SPR_022ax,SPR_022cl,SPR_022sp,SPR_022bw }, + { SPR_023em,SPR_023ax,SPR_023cl,SPR_023sp,SPR_023bw }, + { SPR_024em,SPR_024ax,SPR_024cl,SPR_024sp,SPR_024bw }, + { SPR_021em,SPR_021ax,SPR_021cl,SPR_021sp,SPR_021bw }, + { SPR_031em,SPR_031ax,SPR_031cl,SPR_031sp,SPR_031bw }, + { SPR_032em,SPR_032ax,SPR_032cl,SPR_032sp,SPR_032bw }, + { SPR_033em,SPR_033ax,SPR_033cl,SPR_033sp,SPR_033bw }, + { SPR_034em,SPR_034ax,SPR_034cl,SPR_034sp,SPR_034bw }, + { SPR_041em,SPR_041ax,SPR_041cl,SPR_041sp,SPR_041bw }, + { SPR_042em,SPR_042ax,SPR_042cl,SPR_042sp,SPR_042bw }, + { SPR_043em,SPR_043ax,SPR_043cl,SPR_043sp,SPR_043bw }, + { SPR_044em,SPR_044ax,SPR_044cl,SPR_044sp,SPR_044bw }, + + { SPR_051em,SPR_051ax,SPR_051cl,SPR_051sp,SPR_051bw }, + { SPR_052em,SPR_052ax,SPR_052cl,SPR_052sp,SPR_052bw }, + { SPR_053em,SPR_053ax,SPR_053cl,SPR_053sp,SPR_053bw }, + { SPR_054em,SPR_054ax,SPR_054cl,SPR_054sp,SPR_054bw }, + + { SPR_061em,SPR_061ax,SPR_061cl,SPR_061sp,SPR_061bw }, + { SPR_062em,SPR_062ax,SPR_062cl,SPR_062sp,SPR_062bw }, + { SPR_063em,SPR_063ax,SPR_063cl,SPR_063sp,SPR_063bw }, + { SPR_064em,SPR_064ax,SPR_064cl,SPR_064sp,SPR_064bw }, + + { SPR_071em,SPR_071ax,SPR_071cl,SPR_071sp,SPR_071bw }, + { SPR_072em,SPR_072ax,SPR_072cl,SPR_072sp,SPR_072bw }, + { SPR_073em,SPR_073ax,SPR_073cl,SPR_073sp,SPR_073bw }, + { SPR_074em,SPR_074ax,SPR_074cl,SPR_074sp,SPR_074bw }, + + { SPR_081em,SPR_081ax,SPR_081cl,SPR_081sp,SPR_081bw }, + { SPR_082em,SPR_082ax,SPR_082cl,SPR_082sp,SPR_082bw }, + { SPR_083em,SPR_083ax,SPR_083cl,SPR_083sp,SPR_083bw }, + { SPR_084em,SPR_084ax,SPR_084cl,SPR_084sp,SPR_084bw }, + + { SPR_091em,SPR_091ax,SPR_091cl,SPR_091sp,SPR_091bw }, + { SPR_092em,SPR_092ax,SPR_092cl,SPR_092sp,SPR_092bw }, + { SPR_093em,SPR_093ax,SPR_093cl,SPR_093sp,SPR_093bw }, + { SPR_094em,SPR_094ax,SPR_094cl,SPR_094sp,SPR_094bw }, + + { SPR_101em,SPR_101ax,SPR_101cl,SPR_101sp,SPR_101bw }, + { SPR_102em,SPR_102ax,SPR_102cl,SPR_102sp,SPR_102bw }, + { SPR_103em,SPR_103ax,SPR_103cl,SPR_103sp,SPR_103bw }, + { SPR_104em,SPR_104ax,SPR_104cl,SPR_104sp,SPR_104bw }, + + { SPR_111em,SPR_111ax,SPR_111cl,SPR_111sp,SPR_111bw }, + { SPR_112em,SPR_112ax,SPR_112cl,SPR_112sp,SPR_112bw }, + { SPR_113em,SPR_113ax,SPR_113cl,SPR_113sp,SPR_113bw }, + { SPR_114em,SPR_114ax,SPR_114cl,SPR_114sp,SPR_114bw }, + + { SPR_091em,SPR_091ax,SPR_091cl,SPR_091sp,SPR_091bw }, + { SPR_092em,SPR_092ax,SPR_092cl,SPR_092sp,SPR_092bw }, + + { SPR_pet001,SPR_pet001,SPR_pet001,SPR_pet001,SPR_pet001}, + { SPR_pet002,SPR_pet002,SPR_pet002,SPR_pet002,SPR_pet002}, + { SPR_pet003,SPR_pet003,SPR_pet003,SPR_pet003,SPR_pet003}, + { SPR_pet004,SPR_pet004,SPR_pet004,SPR_pet004,SPR_pet004}, + + { SPR_pet011,SPR_pet011,SPR_pet011,SPR_pet011,SPR_pet011}, + + { SPR_121em,SPR_121ax,SPR_121cl,SPR_121sp,SPR_121bw }, + { SPR_122em,SPR_122ax,SPR_122cl,SPR_122sp,SPR_122bw }, + + { SPR_131em,SPR_131ax,SPR_131cl,SPR_131sp,SPR_131bw }, + { SPR_132em,SPR_132ax,SPR_132cl,SPR_132sp,SPR_132bw }, + { SPR_133em,SPR_133ax,SPR_133cl,SPR_133sp,SPR_133bw }, + + { SPR_141em,SPR_141ax,SPR_141cl,SPR_141sp,SPR_141bw }, + { SPR_142em,SPR_142ax,SPR_142cl,SPR_142sp,SPR_142bw }, + + { SPR_151em,SPR_151ax,SPR_151cl,SPR_151sp,SPR_151bw }, + { SPR_152em,SPR_152ax,SPR_152cl,SPR_152sp,SPR_152bw }, + + { SPR_161em,SPR_161ax,SPR_161cl,SPR_161sp,SPR_161bw }, + { SPR_162em,SPR_162ax,SPR_162cl,SPR_162sp,SPR_162bw }, + +}; + +/*------------------------------------------------------------ + * įޥ įë £ + * ¦ + * basebaseimagenumber int ئ į + * category ITEM_CATEGORY ʧ ة + * ߯Ի + * ޥ į۾޷¡ݷ-1 + ------------------------------------------------------------*/ +int CHAR_getNewImagenumberFromEquip( int basebaseimagenumber, + ITEM_CATEGORY category ) +{ + int i; + /* ITEM_CATEGORY */ + if( category < 0 || category > arraysizeof(CHAR_eqimagetbl[0]) ) + return -1; + for( i=0 ; i rx )swap(lx,rx); + if( ly > ry )swap(ly,ry); + + CHAR_invarea[invreadlen].area.x = lx; + CHAR_invarea[invreadlen].area.y = ly; + CHAR_invarea[invreadlen].area.width = rx-lx; + CHAR_invarea[invreadlen].area.height= ry-ly; + invreadlen ++; + } + } + fclose(f); + CHAR_invareanum = invreadlen; + print( "ЧսЧ %d...", CHAR_invareanum ); + +#ifdef DEBUG + { + int i; + for( i=0; i 3 ) { + return FALSE; + } + index=hometown; + + if( index >= arraysizeof( elders ) ){ + return FALSE; + } + + ch->data[CHAR_FLOOR] = elders[index].floor; + ch->data[CHAR_X] = elders[index].x; + ch->data[CHAR_Y] = elders[index].y; + ch->data[CHAR_LASTTALKELDER] = index; + point = ch->data[CHAR_SAVEPOINT]; + + point = point | (1<data[CHAR_SAVEPOINT] = point; + + if( MAP_checkCoordinates( ch->data[CHAR_FLOOR], ch->data[CHAR_X], + ch->data[CHAR_Y] ) == FALSE ){ + return FALSE; + } + + return TRUE; +} + +/*------------------------------------------------------------ + * ޻ĸë + * ¦ + * elderindex int ޻ĸ̼͵ + * fl int* ׷ʧë + * x int* xë + * y int* yë + * ¦ + * TRUE(1) + * FALSE(0) + ------------------------------------------------------------*/ +BOOL CHAR_getElderPosition( int elderindex, int* fl, int* x, int* y ) +{ + if( elderindex<0 || arraysizeof(elders)<=elderindex )return FALSE; + + *fl = elders[elderindex].floor; + *x = elders[elderindex].x; + *y = elders[elderindex].y; + return TRUE; +} +/*------------------------------------------------------------ + * Ӯ NPCмӮ ̤꼰֣ + * ׻̵̼ + * ¦ + * index int ƥ FALSE ë + * fl int + * x int + * y int + * NPCľ¼֣ + ------------------------------------------------------------*/ +BOOL CHAR_ElderSetPosition( int elderindex ,int fl,int x ,int y) +{ + if( elderindex < ELDERINDEXSTART || + elderindex >= MAXELDERS ){ + return FALSE; + } + + elders[elderindex].floor = fl; + elders[elderindex].x = x; + elders[elderindex].y = y; + return TRUE; +} + + +void CHAR_setInitValues( Char* ch ) +{ + +#ifndef _PROFESSION_SKILL // WON ADD ְҵ + + static int CHAR_titleindextbl[] ={ 0,1,2,3,4,5,6 }; + int elderindex; + int i; + BOOL magician=FALSE; + BOOL priest=FALSE; + + elderindex = ch->data[CHAR_LASTTALKELDER]; + if( 0 <= elderindex + && elderindex < arraysizeof( CHAR_titleindextbl ) ) + ch->indexOfHaveTitle[0] = CHAR_titleindextbl[elderindex]; + + + for( i=0 ; ihaveSkill[i].use ){ + int j; + int skindex=ch->haveSkill[i].skill.data[SKILL_IDENTITY]; + + for( j=0 ; jdata[CHAR_GOLD] = 20; + + if( skindex == SKILL_MAGICIAN ) + magician = TRUE; + else if( skindex == SKILL_PRIEST ) + priest = TRUE; + + } + } + + if( magician || priest ) CHAR_addItemToChar( ch, 802 ); + +#endif +} + + +#if 1 +static int EnemyExpTbl[]={ +0, // 0 +2, // 1 +4, // 2 +6, // 3 +8, // 4 +10, // 5 +12, // 6 +14, // 7 +16, // 8 +18, // 9 +20, // 10 +26, // 11 +32, // 12 +38, // 13 +44, // 14 +50, // 15 +60, // 16 +70, // 17 +80, // 18 +90, // 19 +100, // 20 +115, // 21 +130, // 22 +145, // 23 +160, // 24 +175, // 25 +190, // 26 +205, // 27 +220, // 28 +235, // 29 +250, // 30 +270, // 31 +290, // 32 +310, // 33 +330, // 34 +350, // 35 +375, // 36 +400, // 37 +425, // 38 +450, // 39 +475, // 40 +500, // 41 +525, // 42 +550, // 43 +575, // 44 +600, // 45 +625, // 46 +650, // 47 +675, // 48 +700, // 49 +725, // 50 +750, // 51 +775, // 52 +800, // 53 +825, // 54 +850, // 55 +875, // 56 +900, // 57 +925, // 58 +950, // 59 +980, // 60 +1010, // 61 +1040, // 62 +1070, // 63 +1100, // 64 +1130, // 65 +1160, // 66 +1190, // 67 +1220, // 68 +1250, // 69 +1280, // 70 +1310, // 71 +1345, // 72 +1380, // 73 +1415, // 74 +1450, // 75 +1485, // 76 +1520, // 77 +1555, // 78 +1590, // 79 +1630, // 80 +1670, // 81 +1710, // 82 +1750, // 83 +1790, // 84 +1830, // 85 +1870, // 86 +1910, // 87 +1950, // 88 +1990 // 89 +}; // 90 + + + + + + + + + + + + + + + + +// öئң +int GetEnemyExp( int level ){ +/* + int exp = 0; + if( level < 5 ){ + exp = 2 * level; + }else + if( level < 10 ){ + exp = 10 * level; + }else + if( level < 20 ){ + exp = 15 * level; + }else + if( level < 30 ){ + exp = 30 * level; + }else + if( level < 40 ){ + exp = 50 * level; + }else + if( level < 50 ){ + exp =60 * level; + }else + if( level < 60 ){ + exp =60 * level; + }else{ + exp =70 * level; + } +*/ + if( level >= arraysizeof( EnemyExpTbl ) )level = arraysizeof( EnemyExpTbl )-1; + return EnemyExpTbl[level]; +} +#endif + +#ifdef _NEWOPEN_MAXEXP +/*static int NeedLevelUpTbls[] = { + 0, 0, + 2, 6, 18, 37, 67, 110, 170, + 246, 344, 464, 610, 782, 986, 1221, + 1491, 1798, 2146, 2534, 2968, 3448, 3978, + 4558, 5194, 5885, 6635, 7446, 8322, 9262, + 10272, 11352, 12506, 13734, 15042, 16429, 17899, + 19454, 21098, 22830, 24656, 26576, 28594, 30710, + 32930, 35253, 37683, 40222, 42874, 45638, 48520, + 51520, 54642, 57886, 61258, 64757, 68387, 72150, + 76050, 80086, 84264, 106110, 113412, 121149, 129352, + 138044, 147256, 157019, 167366, 178334, 189958, 202282, + 215348, 229205, 243901, 259495, 276041, 293606, 312258, + 332071, 353126, 375511, 399318, 424655, 451631, 480370, + 511007, 543686, 578571, 615838, 655680, 698312, 743971, + 792917, 845443, 901868, 962554, 1027899, 1098353, 1174420, + 1256663, 1345723, 1442322, 1547281, 1661531, 1786143, 1922340, + 2071533, 2235351, 2415689, 2614754, 2835137, 3079892, 3352633, + 3657676, 4000195, 4386445, 4824041, 5322323, 5892866, 6550125, + 12326614, 15496114, 20025638, 26821885, 37698249, 56734876, 68097265, + 68290815, 68487425, 68687119, 68889921, 69095855, 69304945, 69517215, + 69732689, 69951391, 70173345, 70398575, 70627105, 70858959, 71244161, + 71342735, 71584705, 71830095, 72078929, 72331231, 72587025, 72846335, + 73109185, 73615599, 73655601, 73929215, 74206465, 74487375, 74771969, + 75060271, 75352305, 75648095, 75947665, 76421039, 76563241, 76874295, + 77189225, 77508055, 77830809, 78157511, 78488185, 78822855, 79161545, + 79724279, 79856081, 80206975, 80561985, 80921135, 81284449, 81651951, + 82023665, 82399615, 82779825, 83434319, 83558121, 83951255, 84348745, + 84750615, 85156889, 85567591, 85982745, 86402375, 86826505, 87575159, + 87693361, 88131135, 88573505, 89020495, 89472129, 89928431, 90389425, + 90855135, 91325585, 91800799 +}; +*/ +#endif +static int LevelUpTbl[] = { // ֵ ȼ +0, // 0 EX=(lv^4)/10 +0, // 1 + 2, 8, 25, 62, 129, + 240, 409, 656, 1000, 1464, // 11 + 2073, 2856, 3841, 5062, 6553, // 16 + 8352, 10497, 13032, 16000, 19448, 23425, // 22 + 27984, 33177, 39062, 45697, 53144, 61465, // 28 + 70728, 81000, 92352, 104857, 118592, 133633, // 34 + 150062, 167961, 187416, 208513, 231344, 256000, // 40 + 282576, 311169, 341880, 374809, 410062, 447745, // 46 + 487968, 530841, 576480, 625000, 676520, 731161, // 52 + 789048, 850305, 915062, 983449, 1055600, 1131649, // 58 + 1211736, 1296000, + 1402110, // 61 EX=(lv^4)/(10-0.125*(lv-60)) + 1515521, 1636671, 1766022, 1904066, 2051322, 2208342, // 67 + 2375708, 2554041, 2744000, 2946281, 3161630, 3390834, // 73 + 3634736, 3894230, 4170272, 4463878, 4776136, 5108207, // 79 + 5461333, 5836843, 6236162, 6660816, 7112448, 7592818, // 85 + 8103824, 8647511, 9226082, 9841920, 10497600, 11195912, // 91 + 11939882, 12732800, 13578242, 14480111, 15442664, 16470563, // 97 + 17568917, 18743336, 20000000, 21345723, 22788045, 24335325, // 103 + 25996856, 27783000, 29705340, 31776872, 34012224, 36427912, // 109 + 39042666, 41877804, 44957696, 48310329, 51968004, 55968200, // 115 + 60354645, 65178685, 70501009, 76393874, 82944000, + + 95270613, // 121 Nuke 0624 EX=(lv^4)/(2.5-0.25*(lv-120)) + 110766728, 130792366, 157614250, 195312500, // 125 + 252047376, // 126 EX=lv^4+60000000*(lv-126)^2 Nuke 0816 + 320144641, 388435456, 456922881, 525610000, 594499921, 663595776, // 132 + 732900721, 802417936, 872150625, 942102016,1012275361,1082673936, // 138 + 1153301041,1224160000 // 140 +}; + +int CHAR_GetLevel() +{ + return arraysizeof( LevelUpTbl )-1; +} +int CHAR_GetLevelExp( int charaindex, int level) +{ +#ifdef _NEWOPEN_MAXEXP +#ifdef _USER_EXP_CF + if(level>getMaxLevel()){ + if(level>CHAR_getInt(charaindex, CHAR_LIMITLEVEL)) + return -1; + }else if(level>getYBLevel()){ + if ((CHAR_getInt(charaindex, CHAR_WHICHTYPE)==CHAR_TYPEPET || CHAR_getInt( charaindex, CHAR_FUSIONBEIT ) == 1)) { + if(getPettrans() != -1 ){ + if(CHAR_getInt(charaindex,CHAR_TRANSMIGRATION)>=getPettrans()) + return getNeedLevelUpTbls(level); + }else{ + if(level<=CHAR_getInt(charaindex, CHAR_LIMITLEVEL)) + return getNeedLevelUpTbls(level); + } + return -1; + } +#ifdef _PLAYER_NPC + else if (CHAR_getInt( charaindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYERNPC + || CHAR_getInt( charaindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYERPETNPC){ + return -1; + } +#endif + else{ + if(CHAR_getInt(charaindex,CHAR_TRANSMIGRATION)= arraysizeof( NeedLevelUpTbls ) ){ + return -1; + } + return NeedLevelUpTbls[level];*/ +#else + if( level >= arraysizeof( LevelUpTbl ) ){ + return -1; + } + return LevelUpTbl[level]; +#endif +} + +int CHAR_GetOldLevelExp( int level) +{ + if( level >= arraysizeof( LevelUpTbl ) ){ + return -1; + } + return LevelUpTbl[level]; +} + +int CHAR_LevelUpCheck( int charaindex , int toindex) +{ + int exp, level, nextexp, iRet = FALSE; + if( CHAR_CHECKINDEX( charaindex ) == FALSE )return 0; + exp = CHAR_getInt( charaindex, CHAR_EXP ); + while( 1 ){ + level = CHAR_getInt( charaindex, CHAR_LV ); + nextexp = CHAR_GetLevelExp( charaindex, level+1); + if( nextexp < 0 ) + break; + // Arminius 7.30 pet limit lv + if (CHAR_getInt(charaindex, CHAR_WHICHTYPE)==CHAR_TYPEPET || + CHAR_getInt( charaindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYERNPC || + CHAR_getInt( charaindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYERPETNPC) { + + if (level >= CHAR_getInt(charaindex, CHAR_LIMITLEVEL) && + CHAR_getInt(charaindex, CHAR_LIMITLEVEL) > 0 ) { +#ifdef _NEWOPEN_MAXEXP + CHAR_setInt( charaindex, CHAR_EXP , 0); +#else +#ifdef _PET_LIMITLEVEL + if( CHAR_getInt( charaindex, CHAR_PETID) == 718 +#ifdef _PET_2LIMITLEVEL + || CHAR_getInt( charaindex, CHAR_PETID) == 401 +#endif +#ifdef _PET_3TRANS + || CHAR_getInt( charaindex, CHAR_PETID) == getMMPETID2() +#endif + ) { + nextexp = CHAR_GetLevelExp( charaindex, CHAR_getInt(charaindex, CHAR_LIMITLEVEL)); + CHAR_setInt( charaindex, CHAR_EXP , nextexp ); + } +#endif +#endif + break; + } + } + if( exp >= nextexp ){ + iRet ++; + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER ){ +#ifdef _DP_140_160_MODE + if(getNewDpMode()==1){ + if(level+1==140) + CHAR_setInt( charaindex, CHAR_DUELPOINT,CHAR_getInt( charaindex, CHAR_DUELPOINT)+100000 ); + else if(level+1==160) + CHAR_setInt( charaindex, CHAR_DUELPOINT,CHAR_getInt( charaindex, CHAR_DUELPOINT)+1000000 ); + }else{ + CHAR_setInt( charaindex, CHAR_DUELPOINT, + CHAR_getInt( charaindex, CHAR_DUELPOINT) + (level+1)*10 ); + } +#else + CHAR_setInt( charaindex, CHAR_DUELPOINT, + CHAR_getInt( charaindex, CHAR_DUELPOINT) + (level+1)*10 ); +#endif + } +#ifdef _PET_LIMITLEVEL + else { + CHAR_CheckPetDoLimitlevel( charaindex, toindex, level ); + } +#endif + +#ifdef _NEWOPEN_MAXEXP + if( level >= CHAR_MAXUPLEVEL ){ + }else{ + if( CHAR_HandleExp( charaindex) != -1 ){ + exp = CHAR_getInt( charaindex, CHAR_EXP ); + CHAR_setInt( charaindex, CHAR_LV, level+1 ); + } + } +#else + CHAR_setInt( charaindex, CHAR_LV, level+1 ); +#endif + }else{ + break; + } + } + return iRet; +} + +#ifdef _PET_LIMITLEVEL +void CHAR_CheckPetDoLimitlevel( int petindex , int toindex, int level) +{ + int LevelUpPoint,vital,str,tgh,dex; + int j,k; + char token[56]; +#define RAND(x,y) ((x-1)+1+ (int)( (double)(y-(x-1))*rand()/(RAND_MAX+1.0)) ) + + if( CHAR_getInt( petindex, CHAR_PETID) == 718 +#ifdef _PET_2LIMITLEVEL + || CHAR_getInt( petindex, CHAR_PETID) == 401 +#endif +#ifdef _PET_3TRANS + || CHAR_getInt( petindex, CHAR_PETID) == getMMPETID2() +#endif + ) { + LevelUpPoint = CHAR_getInt( petindex, CHAR_ALLOCPOINT ); + vital = (int )(( LevelUpPoint >> 24 ) & 0xFF); + str = (int)(( LevelUpPoint >> 16 ) & 0xFF); + tgh = (int)(( LevelUpPoint >> 8 ) & 0xFF); + dex = (int)(( LevelUpPoint >> 0 ) & 0xFF); + + if( strcmp( CHAR_getChar( petindex, CHAR_OWNERCDKEY), CHAR_getChar( toindex, CHAR_CDKEY) ) || + strcmp( CHAR_getChar( petindex, CHAR_OWNERCHARANAME), CHAR_getChar( toindex, CHAR_NAME) )){ + sprintf(token,"Ҳʶѽһˣ"); + //andy 1/11 reEdit + vital -= RAND(2,10); if (vital<0) vital=0; + str -= RAND(2,10); if (str<0) str=0; + tgh -= RAND(2,10); if (tgh<0) tgh=0; + dex -= RAND(2,10); if (dex<0) dex=0; + LevelUpPoint = (vital<<24)+(str<<16)+(tgh<<8)+(dex<<0); + + CHAR_setInt( petindex, CHAR_ALLOCPOINT , LevelUpPoint); + CHAR_talkToCli( toindex, petindex, token, CHAR_COLORWHITE); + + LogPetPointChange( + CHAR_getChar( toindex, CHAR_NAME ), + CHAR_getChar( toindex, CHAR_CDKEY ), + CHAR_getChar( petindex, CHAR_NAME), + petindex, 2, + CHAR_getInt( petindex, CHAR_LV), + "No_master(ٲ)", + CHAR_getInt( toindex,CHAR_FLOOR), + CHAR_getInt( toindex,CHAR_X ), + CHAR_getInt( toindex,CHAR_Y ) + ); + } + + if( ( level % 20 ) == 0 ) { + for( j=0; j < 3; j++) { + k = RAND( 0, 3); + if( k == 0 ) + vital--; + if( k == 1 ) + str--; + if( k == 2 ) + tgh--; + if( k == 3 ) + dex--; + } + if( vital < 0 ) vital =0; + if( str < 0 ) str =0; + if( tgh < 0 ) tgh =0; + if( dex < 0 ) dex =0; + LevelUpPoint = (vital<<24)+(str<<16)+(tgh<<8)+(dex<<0); + CHAR_setInt( petindex, CHAR_ALLOCPOINT , LevelUpPoint); + //print("\n << ( level % 20 ) == 0 >> "); + LogPetPointChange( + CHAR_getChar( toindex, CHAR_NAME ), + CHAR_getChar( toindex, CHAR_CDKEY ), + CHAR_getChar( petindex, CHAR_NAME), + petindex,3, + CHAR_getInt( petindex, CHAR_LV), + "level%20", + CHAR_getInt( toindex,CHAR_FLOOR), + CHAR_getInt( toindex,CHAR_X ), + CHAR_getInt( toindex,CHAR_Y ) + ); + } + } +} +#endif + +int CHAR_PetTakeDrop( int petindex, int floor, int ox, int oy) //ǿƶ +{ + int x, y, objindex; + + x = rand()%10; + y = rand()%10; + + //³ CHAR_endCharOneArray + objindex = PET_dropPetAbsolute( petindex,floor,x,y, FALSE ); + if( objindex == -1 ) { + return -1; + } + CHAR_setWorkInt( petindex,CHAR_WORKOBJINDEX,objindex ); + CHAR_setInt( petindex, CHAR_FLOOR, floor); + CHAR_setInt( petindex, CHAR_X, x); + CHAR_setInt( petindex, CHAR_Y, y); + CHAR_sendCToArroundCharacter( objindex); + + return floor; +} + +int CHAR_PetTakeLevelUp( int petindex, int lv)//ǿƳ +{ + int k; + for( k = 1; k < lv; k ++ ){ + CHAR_PetLevelUp( petindex ); + CHAR_PetAddVariableAi( petindex, AI_FIX_PETLEVELUP ); + CHAR_setInt( petindex, CHAR_LV, CHAR_getInt( petindex, CHAR_LV) +1 ); + } + + CHAR_complianceParameter( petindex ); + return k; +} + +#ifdef _NEW_MANOR_LAW +extern struct FM_POINTLIST fmpointlist; +#endif + +int CHAR_PetLevelUp( int petindex ) +{ + struct _RankRandTbl{ + int min; + int max; + }RankRandTbl[] = { + { 450, 500 }, + { 470, 520 }, + { 490, 540 }, + { 510, 560 }, + { 530, 580 }, + { 550, 600 }, + }; + + float Param[4] = { 0.0, 0.0, 0.0, 0.0 }; + int LevelUpPoint, petrank; + float str, vital, dex, tgh, fRand, i; +#ifdef _TEACHER_SYSTEM + int iGetFame = 0; +#endif + // ¦ + if( CHAR_CHECKINDEX( petindex ) == FALSE ) return -1; + if( CHAR_getInt( petindex, CHAR_WHICHTYPE ) != CHAR_TYPEPET && + CHAR_getInt( petindex, CHAR_WHICHTYPE ) != CHAR_TYPEPLAYERNPC && + CHAR_getInt( petindex, CHAR_WHICHTYPE ) != CHAR_TYPEPLAYERPETNPC)return -1; + + LevelUpPoint = CHAR_getInt( petindex, CHAR_ALLOCPOINT ); + + // ʸ¼ + petrank = CHAR_getInt( petindex, CHAR_PETRANK ); + if( petrank < 0 || petrank > 5 ) petrank = 0; + + // + vital = (float)(( LevelUpPoint >> 24 ) & 0xFF); + str = (float)(( LevelUpPoint >> 16 ) & 0xFF); + tgh = (float)(( LevelUpPoint >> 8 ) & 0xFF); + dex = (float)(( LevelUpPoint >> 0 ) & 0xFF); + + // ߼Ԩ ëȻ + for( i = 0; i < 10; i ++ ){ + Param[RAND( 0, 3 )] += 1.0; + } + + // ¼ͱ巽 ¼ĸة + fRand = (float)RAND( RankRandTbl[petrank].min, RankRandTbl[petrank].max ) + * 0.01; + + // ԻԻ̼Իң + vital = (float)vital * fRand + Param[0] * fRand; + str = (float)str * fRand + Param[1] * fRand; + tgh = (float)tgh * fRand + Param[2] * fRand; + dex = (float)dex * fRand + Param[3] * fRand; + + // ң + CHAR_setInt( petindex, CHAR_VITAL, + CHAR_getInt( petindex, CHAR_VITAL ) + (int)vital ); + CHAR_setInt( petindex, CHAR_STR, + CHAR_getInt( petindex, CHAR_STR ) + (int)str ); + CHAR_setInt( petindex, CHAR_TOUGH, + CHAR_getInt( petindex, CHAR_TOUGH ) + (int)tgh ); + CHAR_setInt( petindex, CHAR_DEX, + CHAR_getInt( petindex, CHAR_DEX ) + (int)dex ); + + // CoolFish: + { + int level = CHAR_getInt(petindex, CHAR_LV); + int exp1 = 0, exp2 = 0; + if (level > 30){ + char tmpbuf[128]; +#ifdef _NEW_MANOR_LAW + char tmpbuf1[16]; +#endif + int ownerindex = CHAR_getWorkInt(petindex, CHAR_WORKPLAYERINDEX); +#ifdef _FMVER21 +#else + if (CHAR_getInt(ownerindex, CHAR_FMINDEX) < 0) return 0; + if (CHAR_getInt(ownerindex, CHAR_FMLEADERFLAG) <= 0 ) return 0; + if (strcmp(CHAR_getChar(ownerindex, CHAR_FMNAME), "") == 0) return 0; +#endif + if (CHAR_CHECKINDEX(ownerindex)){ + exp1 = CHAR_GetLevelExp( petindex, level); + exp2 = CHAR_GetLevelExp( petindex, level - 1); + +//#ifdef _PERSONAL_FAME // Arminius 8.30: +// feedpoint = (exp1 - exp2) / 20000; // +//#else +// feedpoint = (exp1 - exp2) / 10000; +//#endif + if ( exp1 - exp2 > 0 && CHAR_getWorkInt(petindex,CHAR_WORKJILU)==0){ + int feedpoint; + // CoolFish: 2001/10/03 + int fd = getfdFromCharaIndex(ownerindex); +#ifdef _PERSONAL_FAME // Arminius 8.30: +#ifdef _PETUP_GET_EXP + if(getPetUpGetExp()==1){ + if(level>=131){ + int myfame = (20+(level-131)*5)*100; + if(level==138) myfame = 6000; + else if(level==139) myfame = 9000; + else if(level==140) myfame = 16000; + CHAR_earnFame(ownerindex, myfame); + sprintf(tmpbuf, "%d", myfame); + }else if(level<=130 && level>=126){ + CHAR_earnFame(ownerindex, exp2 / 30000); + sprintf(tmpbuf, "%d", exp2 / 30000); + }else{ + CHAR_earnFame(ownerindex, exp2 / 60000); + sprintf(tmpbuf, "%d", exp2 / 60000); + } + }else if(getPetUpGetExp()==0){ + CHAR_earnFame(ownerindex, exp2 / 20000); + sprintf(tmpbuf, "%d", exp2 / 20000); + }else{ + CHAR_earnFame(ownerindex, 0); // + sprintf(tmpbuf, "%d", 0); // + } +#else + CHAR_earnFame(ownerindex, exp2 / 20000); + sprintf(tmpbuf, "%d", exp2 / 20000); +#endif +#endif +#ifdef _PETUP_GET_EXP + if(getPetUpGetExp()==1){ + if(level>=131){ + int myfame = (20+(level-131)*5)*100; + if(level==138) myfame = 6000; + else if(level==139) myfame = 9000; + else if(level==140) myfame = 16000; + feedpoint = myfame; + }else if(level<=130 && level>=126){ + feedpoint=exp2 / 30000; + }else{ + feedpoint=exp2 / 60000; + } + }else if(getPetUpGetExp()==0){ + feedpoint=exp2 / 20000; + }else{ + feedpoint=0; + } +#else + feedpoint=exp2 / 20000; +#endif +#ifdef _NEW_MANOR_LAW + sprintf(tmpbuf1, "%d", CHAR_getInt(ownerindex,CHAR_FAME)); +#endif +#ifdef _FMVER21 + if (CHAR_getInt(ownerindex, CHAR_FMLEADERFLAG) > 0 + && CHAR_getInt(ownerindex, CHAR_FMLEADERFLAG) != FMMEMBER_APPLY){ + saacproto_ACFixFMData_send(acfd, + CHAR_getChar(ownerindex, CHAR_FMNAME), + CHAR_getInt(ownerindex, CHAR_FMINDEX), + CHAR_getWorkInt(ownerindex, CHAR_WORKFMINDEXI), + FM_FIX_FMFEED, tmpbuf, +#ifndef _NEW_MANOR_LAW + "", +#else + tmpbuf1, +#endif + // CoolFish: 2001/10/03 + CHAR_getWorkInt(ownerindex, CHAR_WORKFMCHARINDEX), + CONNECT_getFdid(fd)); + // CHAR_getWorkInt(ownerindex, CHAR_WORKFMCHARINDEX), 0); +#ifdef _NEW_MANOR_LAW + { + int i; + for(i=0;i 0){ + // ûеʦ + if(strlen(CHAR_getChar(ownerindex,CHAR_TEACHER_ID)) > 0 && strlen(CHAR_getChar(ownerindex,CHAR_TEACHER_NAME)) > 0){ + int iPlayernum = CHAR_getPlayerMaxNum(),i; + char szMsg[128]; + + // 鵼ʦڲ + for(i=0;i 0 )return 0;//ǷΪںϳ + for( i=0; i<4; i++) { + work[i] = 0; + } + if( PET_getBaseAndSkill( charaindex, Subindex1, base, petskill, 0) == FALSE ) + return 0; + if( CHAR_getInt( Subindex1, CHAR_LV) < 80 ){//ȼ + for( i=0; i<4; i++) { + base[i] = base[i]*0.8; + } + } + for( i=0; i<4; i++) { + work[i] = base[i]; + } + for( i=0; i<7; i++) { + skill[i] = petskill[i]; + } + if( !CHAR_CHECKINDEX( Subindex2)) return 1; + if( EVOLUTION_getPetFusionCode( CHAR_getInt( Subindex2, CHAR_PETID) ) < 0 ){ + return 0; + } + + if( CHAR_getInt( Subindex2, CHAR_FUSIONBEIT) == 1 || + CHAR_getInt( Subindex2, CHAR_FUSIONRAISE) > 0 )return 0;//ǷΪںϳ + + if( PET_getBaseAndSkill( charaindex, Subindex2, base, NULL, 0) == FALSE ) + return 0; + if( CHAR_getInt( Subindex2, CHAR_LV) < 80 ){//ȼ + for( i=0; i<4; i++) { + base[i] = base[i]*0.8; + } + } + for( i=0; i<4; i++) { + work[i] += base[i]; + } + return 2; +} + +BOOL PETFUSION_FusionPetMain( int charaindex, int Mainindex, int *work, int *skill) +{ + int i; + int base[4]={0,0,0,0}; + int petskill[7]={-1,-1,-1,-1,-1,-1,-1}; + if( !CHAR_CHECKINDEX( Mainindex)) return FALSE; + if( EVOLUTION_getPetFusionCode( CHAR_getInt( Mainindex, CHAR_PETID) ) < 0 ){ + return 0; + } + if( CHAR_getInt( Mainindex, CHAR_FUSIONBEIT) == 1 || + CHAR_getInt( Mainindex, CHAR_FUSIONRAISE) > 0 )return FALSE;//ǷΪںϳ + + if( PET_getBaseAndSkill( charaindex, Mainindex, base, petskill, 0) == FALSE ) + return -1; + if( CHAR_getInt( Mainindex, CHAR_LV) < 80 ){//ȼ + for( i=0; i<4; i++) { + base[i] = base[i]*0.8; + } + } + for( i=0; i<4; i++) { + work[i] += base[i]*0.6; + } + for( i=0; i<7; i++) { + skill[i] = petskill[i]; + } + + return TRUE; +} + +BOOL PETFUSION_DelPet( int toindex, int Mainindex, int Subindex1, int Subindex2, int flg) +{ + int i, j, cnt=0; + int petindex[3]; + + + petindex[0] = Mainindex; + petindex[1] = Subindex1; + petindex[2] = Subindex2; + + for( i=0; i<3; i++) { + if( !CHAR_CHECKINDEX( petindex[i] ) ) continue; + for( j=0; j= CHAR_MAXPETHAVE){ + + }else { + char szPet[256]; + char msgbuf[256]; + CHAR_setCharPet( toindex, j, -1); + snprintf( szPet, sizeof( szPet ), "K%d", j); + CHAR_sendStatusString( toindex, szPet ); + + snprintf( msgbuf,sizeof( msgbuf), "%s", CHAR_getChar( petindex[i], CHAR_NAME)); + CHAR_talkToCli( toindex, -1, msgbuf, CHAR_COLORYELLOW); + LogPet( + CHAR_getChar( toindex, CHAR_NAME ), + CHAR_getChar( toindex, CHAR_CDKEY ), + CHAR_getChar( petindex[i], CHAR_NAME), + CHAR_getInt( petindex[i], CHAR_LV), + "TenseiDel", + CHAR_getInt( toindex,CHAR_FLOOR), + CHAR_getInt( toindex,CHAR_X ), + CHAR_getInt( toindex,CHAR_Y ), + CHAR_getChar( petindex[i], CHAR_UNIQUECODE) // shan 2001/12/14 + ); + } + CHAR_endCharOneArray( petindex[i] ); + cnt++; + } + if( cnt >= flg ) + return TRUE; + return FALSE; +} + +int PETFUSION_Evolution( int charaindex, int petindex) +{ + char buf[256], buf1[256]; + int newindex=-1; + CHAR_setInt( petindex, CHAR_FUSIONTIMELIMIT, -1); + + sprintf( buf, "%s", CHAR_getChar( petindex, CHAR_NAME)); + newindex = EVOLUTION_createPetFromEnemyIndex( charaindex, petindex, 0); + if( !CHAR_CHECKINDEX( newindex) ){ + CHAR_talkToCli( charaindex, -1, "", CHAR_COLORYELLOW); + return -1; + } + sprintf( buf1, "%s", CHAR_getChar( newindex, CHAR_NAME)); + strcat( buf, buf1); + CHAR_talkToCli( charaindex, -1, buf, CHAR_COLORYELLOW); + + LogPetFeed( + CHAR_getChar( charaindex, CHAR_NAME), + CHAR_getChar( charaindex, CHAR_CDKEY), + CHAR_getChar( petindex, CHAR_NAME), + petindex, + CHAR_getInt( petindex, CHAR_LV), + buf, // Key + CHAR_getInt( charaindex, CHAR_FLOOR), + CHAR_getInt( charaindex, CHAR_X), + CHAR_getInt( charaindex, CHAR_Y), + CHAR_getChar( petindex, CHAR_UNIQUECODE) ); + + return newindex; +} +#endif + +#ifdef _PET_TRANS +int PETTRANS_getPetBase( int petindex, int *work, int *petrank) +{ + int i, total=-1; + if( !CHAR_CHECKINDEX( petindex) ){ + total = 0; + *petrank = 1; + for( i=0; i<4; i++) { + work[i] = 50; + total += work[i]; + } + }else{ + int LevelUpPoint = CHAR_getInt( petindex, CHAR_ALLOCPOINT ); + *petrank = CHAR_getInt( petindex, CHAR_PETRANK ); + work[0] = (float)(( LevelUpPoint >> 24 ) & 0xFF); + work[1] = (float)(( LevelUpPoint >> 16 ) & 0xFF); + work[2] = (float)(( LevelUpPoint >> 8 ) & 0xFF); + work[3] = (float)(( LevelUpPoint >> 0 ) & 0xFF); + total = ( work[0] + work[1] + work[2] + work[3] ); + if( total > 150 ) total = 150; + if( total < 0 ) total = 0; + } + return total; +} + +#ifdef _PET_2TRANS +int NPC_PetTransManGetAns( int total1, int total2, int LV, int rank, int tran ) +#else +int NPC_PetTransManGetAns( int total1, int total2, int LV, int rank ) +#endif +{ + int ans=0 , TransLV = 100; + float total = 0.00; + int Fx=1; +#if _ATTESTAION_ID == 1 + if( LV > 130 ) LV = 130; +#else + if( LV > 140 ) LV = 140; +#endif + total = ( (float)total1/100 ); // total1=200 + total = total*total*total*total*total; + if( total < 1 ) total = 0; + else total= total*1.3; // total=41.6 С=0 + Fx = (int)((5-rank)*1.2)+5; // rank=0~6 Fx=11(rank=0)С=4(rank=6) + ans = (int)total + total2 + ((LV-TransLV)/Fx); //42+150+30/11=194 + +#ifdef _PET_2TRANS +#ifdef _PET_TRANS_ABILITY + if( tran == 0 ){ + if( ans > getPetTransAbility1() ) + ans = getPetTransAbility1(); + } + else +#ifdef _PET_3TRANS + if( tran == 1 ) +#endif + { + if( ans > getPetTransAbility2() ) + ans = getPetTransAbility2() ; + } +#ifdef _PET_3TRANS + else{ + if( ans > getPetTransAbility3() ) + ans = getPetTransAbility3(); + } +#endif +#else + if( tran == 0 ){ + if( ans > 150 ) + ans = 150; + } + else{ + if( ans > 200 ) + ans = 200; + } +#endif +#else + if( ans > 150 ) { + ans = 150; + } +#endif + return ans; +} + +int PETTRANS_PetTransManStatus( int toindex, int petindex1, int petindex2) +{ + int petrank=0,i; + int total1,total2,total,petLV,ans; + int petID,enemynum,ret=-1; + int work[4]={0,0,0,0}; + int base[4]={0,0,0,0}; + +#define RAND(x,y) ((x-1)+1+ (int)( (double)(y-(x-1))*rand()/(RAND_MAX+1.0)) ) + total1 = PETTRANS_getPetBase( petindex1, work, &petrank); + total2 = PETTRANS_getPetBase( petindex2, base, &petrank); + petLV = CHAR_getInt( petindex2, CHAR_LV); +#ifdef _PET_2TRANS + ans = NPC_PetTransManGetAns( total1, total2, petLV, petrank, CHAR_getInt( petindex2, CHAR_TRANSMIGRATION ) ); +#else + ans = NPC_PetTransManGetAns( total1, total2, petLV, petrank ); +#endif + total = total1 + (total2*4); + total2 = 0; + for( i=0; i<4; i++) { + work[i] = work[i]*4; + total2 += work[i]; + } + total = total1 + total2; + for( i=0; i<4; i++) { + base[i] = (ans * (base[i]+work[i])) /total; + } + enemynum = ENEMY_getEnemyNum(); + petID = CHAR_getInt( petindex2, CHAR_PETID); + for( i=0; i CHAR_getWorkInt( charaindex, CHAR_WORKMAXHP) ){ + Myhp = CHAR_getWorkInt( charaindex, CHAR_WORKMAXHP); + } + CHAR_setInt( charaindex, CHAR_HP, Myhp); + CHAR_complianceParameter( charaindex ); + CHAR_send_P_StatusString( charaindex, CHAR_P_STRING_HP); + for( i=0; i CHAR_getWorkInt( petindex, CHAR_WORKMAXHP) ){ + Myhp = CHAR_getWorkInt( petindex, CHAR_WORKMAXHP); + } + CHAR_setInt( petindex, CHAR_HP, Myhp); + CHAR_send_K_StatusString( charaindex, i, CHAR_K_STRING_HP|CHAR_K_STRING_AI); + } + break; + case 2://MP + Myhp = CHAR_getInt( charaindex, CHAR_MP); + dnums = CHAR_getWorkInt( charaindex, CHAR_WORKCHIKULAMP); + Myhp += dnums; + if( Myhp > CHAR_getWorkInt( charaindex, CHAR_WORKMAXMP) ){ + Myhp = CHAR_getWorkInt( charaindex, CHAR_WORKMAXMP); + } + CHAR_setInt( charaindex, CHAR_MP, Myhp); + CHAR_complianceParameter( charaindex ); + CHAR_send_P_StatusString( charaindex, CHAR_P_STRING_MP); + break; + } +} +#endif + +#ifdef _STATUS_WATERWORD //ˮ״̬ +void CHAR_CheckWaterStatus( int charaindex) +{ + if( !CHAR_CHECKINDEX( charaindex) ) return; + if( CHAR_getWorkInt( charaindex, CHAR_WORKSTATUSWATER) == -1 ){ + return; + } + if( CHAR_getWorkInt( charaindex, CHAR_WORKSTATUSWATER) > 0 ){ + CHAR_setWorkInt( charaindex, CHAR_WORKSTATUSWATER, + CHAR_getWorkInt( charaindex, CHAR_WORKSTATUSWATER) -1 ); + + if( CHAR_getWorkInt( charaindex, CHAR_WORKSTATUSWATER) != 0 && + CHAR_getWorkInt( charaindex, CHAR_WORKSTATUSWATER)%10 == 0 ){ + char buf1[256]; + sprintf( buf1, "ˮкʱʣ%d֡", + CHAR_getWorkInt( charaindex, CHAR_WORKSTATUSWATER)); + CHAR_talkToCli( charaindex, -1, buf1, CHAR_COLORYELLOW); + } + } + + if( CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE) != BATTLE_CHARMODE_NONE ){ + return; + } + if( CHAR_getWorkInt( charaindex, CHAR_WORKMAPFLOORTYPE) == 1 && + CHAR_getWorkInt( charaindex, CHAR_WORKSTATUSWATER) <= 0 ){//ˮ + char token[256]; + int defhp=0; + int maxhp = CHAR_getWorkInt( charaindex, CHAR_WORKMAXHP); + int myhp = CHAR_getInt( charaindex, CHAR_HP); + defhp = (maxhp*0.033); + if( defhp <= 0 ) defhp = 1; + myhp = myhp - defhp; + sprintf( token, "޷%d HP", defhp); + CHAR_talkToCli( charaindex, -1, token, CHAR_COLORYELLOW); + + if( myhp <= 0 ){ + myhp = 1; + if(CHAR_getInt(charaindex,CHAR_FLOOR) == 151 || CHAR_getInt(charaindex,CHAR_FLOOR) == 160 + || CHAR_getInt(charaindex,CHAR_FLOOR) == 161 ) CHAR_warpToSpecificPoint(charaindex,702,213,27); + else CHAR_warpToSpecificPoint( charaindex, 200,102,1021); + } + CHAR_setInt( charaindex, CHAR_HP, myhp); + CHAR_send_P_StatusString( charaindex, CHAR_P_STRING_HP); + } + +} +#endif + +int CHAR_findSurplusPetBox( int charaindex ) +{ + int i, remnants=0; + for( i=0; i=100700 && oldMetamo<100819){ + int newMetamo; + int hbMetamo[]={ + 100000,100010,100025,100035,100055,100045, + 100060,100070,100095,100090,100100,100110, + 100135,100125,100145,100150,100165,100160, + 100190,100185,100200,100210,100230,100220, + }; + newMetamo=hbMetamo[(oldMetamo-100700)/5]; + CHAR_setInt( charaindex , CHAR_BASEIMAGENUMBER , newMetamo ); + CHAR_setInt( charaindex , CHAR_BASEBASEIMAGENUMBER , newMetamo ); + CHAR_sendCToArroundCharacter( CHAR_getWorkInt( charaindex , CHAR_WORKOBJINDEX )); + CHAR_send_P_StatusString( charaindex , CHAR_P_STRING_BASEBASEIMAGENUMBER); + CHAR_complianceParameter( charaindex ); + } +} +#endif + +#ifdef _NEW_PLAYER_RIDE +void CHAR_PlayerRide( int charaindex ) +{ + int i,j; + int MetamoList[5][13]={ + /*{ С к Ƥ С Ƥ ñ ̷ Ů }, Ϊ˵ */ + { 100000, 100025, 100055, 100060, 100095, 100100, 100135, 100145, 100165, 100190, 100200, 100230, 309}, // + { 100005, 100030, 100050, 100065, 100085, 100115, 100120, 100140, 100170, 100195, 100210, 100225, 307}, // + { 100010, 100035, 100045, 100070, 100090, 100110, 100125, 100150, 100160, 100185, 100215, 100220, 310}, // + { 100015, 100020, 100040, 100075, 100080, 100105, 100130, 100155, 100175, 100180, 100205, 100235, 308}, // + { 331 , 483 , 330 , 332 , 483 , 332 , 333 , 333 , 331 , 330 , 332 , 483 , 0 }, // + }; + for(i=0;i<4;i++) + for(j=0;j<12;j++) + if(CHAR_getInt( charaindex, CHAR_BASEIMAGENUMBER) == MetamoList[i][j]){ + if(strstr( getPlayerRide(), "ͻ")){ + setNewplayergivepet(3,MetamoList[i][12]); + setNewplayergivepet(4,MetamoList[4][j]); + }else if(strstr( getPlayerRide(), "")){ + setNewplayergivepet(4,MetamoList[4][j]); + }else if(strstr( getPlayerRide(), "ͻ")){ + setNewplayergivepet(4,MetamoList[i][12]); + } + break; + } +} +#endif diff --git a/char/char_event.c b/char/char_event.c new file mode 100644 index 0000000..7a15e66 --- /dev/null +++ b/char/char_event.c @@ -0,0 +1,564 @@ +#include "version.h" +#include + +#include "common.h" +#include "char.h" +#include "item_event.h" +#include "net.h" +#include "item.h" +#include "object.h" +#include "lssproto_serv.h" +#include "util.h" +#include "char_data.h" +#include "readmap.h" +#include "map_deal.h" +#include "item.h" +#include "saacproto_cli.h" +#include "npccreate.h" +#include "handletime.h" +#include "anim_tbl.h" +#include "family.h" + +#define SPR_kmydam CG_HIT_MARK_00 +BOOL CHAR_allprewalk( int index,int* dir,int* mode) +{ + int poisonvalue; + poisonvalue = CHAR_getInt(index, CHAR_POISON ); + if( poisonvalue >= 1 ){ + CHAR_setInt(index,CHAR_HP , CHAR_getInt(index,CHAR_HP) + - poisonvalue ); + CHAR_setWorkInt(index,CHAR_WORKLASTATTACKCHARAINDEX,-2); + { + int opt[2] = { SPR_kmydam,poisonvalue}; + CHAR_sendWatchEvent( CHAR_getWorkInt(index,CHAR_WORKOBJINDEX), + CHAR_ACTDAMAGE,opt,2,TRUE); + + CHAR_sendStatusString( index,"M"); + } + poisonvalue--; + if( poisonvalue <= 0)poisonvalue = 1; + CHAR_setInt(index,CHAR_POISON,poisonvalue); + } + if( CHAR_getInt(index,CHAR_CONFUSION) != 0 ) + *dir = RAND(0,7); + if( CHAR_getInt(index,CHAR_STONE) != 0 ) + return FALSE; + return TRUE; +} + +void CHAR_allpostwalk( int index ) +{ + return; +} + +BOOL CHAR_makeCADefaultString( int objindex,char* buf,int buflen, int act ) +{ + char objindexbuf[64]; + /* */ + if( CHECKOBJECT(objindex) == FALSE ) return FALSE; + if( OBJECT_getType(objindex) != OBJTYPE_CHARA ) return FALSE; + snprintf( buf,buflen,"%s|%d|%d|%d|%d", + cnv10to62( objindex,objindexbuf, sizeof(objindexbuf)), + OBJECT_getX(objindex), OBJECT_getY(objindex), + act, + CHAR_getInt(OBJECT_getIndex(objindex),CHAR_DIR)); + return TRUE; +} + +static void CHAR_makeCADAMAGEStringFromSpecifiedCoordinate( + int x , int y, char* buf,int buflen,int ef1,int damagevalue ) +{ + snprintf( buf,buflen,"%d|%d|%d|%d|%d|%d|%d", + -1,x,y, CHAR_ACTDAMAGE,0, ef1,damagevalue); +} + +BOOL CHAR_makeCAOPT1String( int objindex,char* buf, int buflen, int act,int opt1 ) +{ + char objindexbuf[64]; + if( CHECKOBJECT(objindex) == FALSE ) return FALSE; + if( OBJECT_getType(objindex) != OBJTYPE_CHARA ) return FALSE; + snprintf( buf,buflen,"%s|%d|%d|%d|%d|%d", + cnv10to62( objindex,objindexbuf, sizeof(objindexbuf)), + OBJECT_getX(objindex), OBJECT_getY(objindex), + act, + CHAR_getInt(OBJECT_getIndex(objindex),CHAR_DIR), opt1); + return TRUE; +} + +#ifdef _STREET_VENDOR +BOOL CHAR_makeCAOPTString(int objindex,char* buf,int buflen,int act,char *string) +{ + char objindexbuf[64]; + + if(CHECKOBJECT(objindex) == FALSE ) return FALSE; + if(OBJECT_getType(objindex) != OBJTYPE_CHARA ) return FALSE; + snprintf( buf,buflen,"%s|%d|%d|%d|%d|%s", + cnv10to62(objindex,objindexbuf, sizeof(objindexbuf)), + OBJECT_getX(objindex), OBJECT_getY(objindex),act, + CHAR_getInt(OBJECT_getIndex(objindex),CHAR_DIR),string); + return TRUE; +} +#endif + +BOOL CHAR_makeCAOPT3String( int objindex,char* buf, int buflen, int act,int opt1,int opt2,int opt3 ) +{ + char objindexbuf[64]; + + if( CHECKOBJECT(objindex) == FALSE ) return FALSE; + if( OBJECT_getType(objindex) != OBJTYPE_CHARA ) return FALSE; + snprintf( buf,buflen,"%s|%d|%d|%d|%d|%d|%d|%d", + cnv10to62( objindex,objindexbuf, sizeof(objindexbuf)), + OBJECT_getX(objindex), OBJECT_getY(objindex), + act, + CHAR_getInt(OBJECT_getIndex(objindex),CHAR_DIR), + opt1,opt2,opt3); + return TRUE; +} + +void CHAR_playerWatchfunc( int objmeindex, int objmoveindex, + CHAR_ACTION act, int x, int y, int dir, int* opt, int optlen ) +{ + int fd; + int meindex; + if( !CHECKOBJECTUSE(objmeindex) )return; + if( !CHECKOBJECTUSE(objmoveindex))return; + if( OBJECT_getType(objmeindex) != OBJTYPE_CHARA )return; + + meindex = OBJECT_getIndex(objmeindex); + if( CHAR_getInt( meindex,CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER )return; + + fd = getfdFromCharaIndex( meindex ); + if( fd == -1 )return; + switch( OBJECT_getType(objmoveindex) ){ + case OBJTYPE_CHARA: + { + char buf[128]; + if( !CHAR_getFlg( OBJECT_getIndex(objmoveindex),CHAR_ISVISIBLE) ) + return; + + switch( act ){ + case CHAR_ACTSTAND: + case CHAR_ACTWALK: + case CHAR_ACTATTACK: + case CHAR_ACTDEAD: + case CHAR_ACTMAGIC: + case CHAR_ACTITEM: + case CHAR_ACTDOWN: + case CHAR_ACTSIT: + case CHAR_ACTHAND: + case CHAR_ACTPLEASURE: + case CHAR_ACTANGRY: + case CHAR_ACTSAD: + case CHAR_ACTDAMAGE: + case CHAR_ACTGUARD: + case CHAR_ACTTURN: + case CHAR_ACTWARP: + case CHAR_ACTACTIONWALK: + case CHAR_ACTNOD: + case CHAR_ACTTHROW: + case CHAR_ACTACTIONSTAND: + if( CHAR_makeCADefaultString(objmoveindex,buf,sizeof(buf),act) ) { + CONNECT_appendCAbuf( fd,buf,strlen(buf)); + } + break; + // shan begin + case CHAR_ACTTRADE: + if( optlen == 1 ) + if( CHAR_makeCAOPT1String( objmoveindex, buf, + sizeof( buf), act, opt[0] ) ) + CONNECT_appendCAbuf( fd, buf, strlen(buf)); + break; + +#ifdef _ANGEL_SUMMON + case CHAR_ACTANGEL: + if( optlen == 1 ) + if( CHAR_makeCAOPT1String( objmoveindex, buf, + sizeof( buf), act, opt[0] ) ) + CONNECT_appendCAbuf( fd, buf, strlen(buf)); + break; +#endif + + // shan end +#ifdef _MIND_ICON + case CHAR_MIND: + if( optlen == 1 ) + if( CHAR_makeCAOPT1String( objmoveindex, buf, + sizeof(buf), act, opt[0])) + CONNECT_appendCAbuf( fd, buf, strlen(buf)); + break; +#endif +#ifdef _STREET_VENDOR + case CHAR_STREETVENDOR_OPEN: + if(CHAR_makeCAOPTString(objmoveindex,buf,sizeof(buf), + act,CHAR_getWorkChar(OBJECT_getIndex(objmoveindex),CHAR_STREETVENDOR_NAME))) + CONNECT_appendCAbuf(fd,buf,strlen(buf)); + break; + case CHAR_STREETVENDOR_CLOSE: + if(CHAR_makeCAOPTString(objmoveindex,buf,sizeof(buf), + act,CHAR_getWorkChar(OBJECT_getIndex(objmoveindex),CHAR_STREETVENDOR_NAME))) + CONNECT_appendCAbuf(fd,buf,strlen(buf)); + break; +#endif +#ifdef _ITEM_CRACKER + case CHAR_ITEM_CRACKER: + if( optlen == 1 ) + if( CHAR_makeCAOPT1String( objmoveindex, buf, + sizeof(buf), act, opt[0])) + CONNECT_appendCAbuf( fd, buf, strlen(buf)); + break; +#endif + case CHAR_ACTEFFECT: + if( optlen == 1 ) + if( CHAR_makeCAOPT1String(objmoveindex,buf, + sizeof(buf),act,opt[0] ) ) + CONNECT_appendCAbuf( fd,buf,strlen(buf)); + break; + case CHAR_ACTPOPUPNAME: + case CHAR_ACTLEADER: + case CHAR_ACTBATTLEWATCH: + if( optlen == 1 ) + if( CHAR_makeCAOPT1String(objmoveindex,buf, + sizeof(buf),act,opt[0] ) ) + CONNECT_appendCAbuf( fd,buf,strlen(buf)); + break; + case CHAR_ACTBATTLE: + if( optlen == 3 ) + if( CHAR_makeCAOPT3String( objmoveindex,buf, sizeof(buf), + act,opt[0],opt[1],opt[2] ) ) + CONNECT_appendCAbuf( fd,buf,strlen(buf)); + break; + default: + break; + } + + break; + } + case OBJTYPE_ITEM: + case OBJTYPE_GOLD: + CHAR_sendSpecifiedobjindexCToCharaindex(meindex,objmoveindex); + break; + default: + break; + } + +} + +void CHAR_sendWallDamage( int charaindex,int x, int y, int damage ) +{ + int fd; + char cabuf[256]=""; + + fd = getfdFromCharaIndex(charaindex); + if( fd == -1 )return; + + CHAR_makeCADAMAGEStringFromSpecifiedCoordinate( + x,y,cabuf,sizeof(cabuf),SPR_kmydam,damage ); + CONNECT_appendCAbuf( fd,cabuf,strlen(cabuf)); +} + + + +static struct ParamShow +{ + int paramindex; /* ɷ¶̼͵ */ + char* offmessage; /* ݼ ٯ */ +}pShow[]={ + {CHAR_PARALYSIS, CHAR_RECOVERPARALYSISSTRING}, + {CHAR_SLEEP, CHAR_RECOVERSILENCESTRING}, + {CHAR_STONE, CHAR_RECOVERSTONESTRING}, + {CHAR_DRUNK, CHAR_RECOVERDARKNESSSTRING}, + {CHAR_CONFUSION, CHAR_RECOVERCONFUSIONSTRING}, +}; + +void CHAR_recoveryStatus( int charaindex ) +{ + int i; + int cure=FALSE; + if( !CHAR_CHECKINDEX(charaindex) )return; + + for( i=0 ; i < arraysizeof(pShow) ; i ++ ){ + if( CHAR_getInt(charaindex,pShow[i].paramindex) > 0 ){ + int old; + old = CHAR_setInt(charaindex,pShow[i].paramindex, + CHAR_getInt(charaindex, + pShow[i].paramindex) - 1 ); + if( old == 1 ){ + if( CHAR_getInt(charaindex,CHAR_WHICHTYPE) == CHAR_TYPEPLAYER){ + CHAR_talkToCli( charaindex,-1, pShow[i].offmessage, + CHAR_COLORWHITE ); + } + cure = TRUE; + } + } + } + if( cure ){ + CHAR_sendStatusString( charaindex, "P" ); + CHAR_sendCToArroundCharacter( CHAR_getWorkInt( + charaindex, CHAR_WORKOBJINDEX) ); + } +} + +static BOOL CHAR_clairvoyance_gold(int objindex,char* buf ) +{ + if( OBJECT_getType( objindex ) == OBJTYPE_GOLD ){ + *buf = 'G'; + return TRUE; + } + return FALSE; +} + +static BOOL CHAR_clairvoyance_item(int objindex,char* buf ) +{ + if( OBJECT_getType( objindex ) == OBJTYPE_ITEM){ + *buf = 'I'; + return TRUE; + } + return FALSE; +} + +static BOOL CHAR_clairvoyance_player(int objindex,char* buf ) +{ + if( OBJECT_getType( objindex ) == OBJTYPE_CHARA + && CHAR_getInt(OBJECT_getIndex(objindex),CHAR_WHICHTYPE) + == CHAR_TYPEPLAYER ){ + *buf = 'P'; + return TRUE; + } + return FALSE; +} + +static BOOL CHAR_clairvoyance_enemy(int objindex,char* buf ) +{ + if( OBJECT_getType( objindex ) == OBJTYPE_CHARA + && CHAR_getInt(OBJECT_getIndex(objindex),CHAR_WHICHTYPE) + == CHAR_TYPEENEMY ){ + *buf = 'E'; + return TRUE; + } + return FALSE; +} + +static char CHAR_clairvoyanceString[STRINGBUFSIZ]; + +static void CHAR_clairvoyance( int charaindex ) +{ + char onebuf[128]; + int stringlen=0; + int clairvoyancelevel; + int centerx,centery,fl; + int i,j; + BOOL sendclairvoyance=FALSE; + +#define CHAR_CLAIRVOYANCEWIDTH 81 + BOOL (*clairvoyancefunc[])(int,char*) ={ + CHAR_clairvoyance_gold, + CHAR_clairvoyance_item, + CHAR_clairvoyance_player, + CHAR_clairvoyance_enemy, + }; + if( CHAR_getWorkInt( charaindex, CHAR_WORKLOOPSTARTSEC)%10 != 0 ) + return; + + clairvoyancelevel = CHAR_getInt(charaindex,CHAR_RADARSTRENGTH ); + + if( clairvoyancelevel <= 0 )return; + if( clairvoyancelevel > arraysizeof( clairvoyancefunc ) ) + clairvoyancelevel = arraysizeof( clairvoyancefunc ); + + centerx = CHAR_getInt(charaindex,CHAR_X); + centery = CHAR_getInt(charaindex,CHAR_Y); + fl = CHAR_getInt(charaindex,CHAR_FLOOR); + + + for( i = centerx - CHAR_CLAIRVOYANCEWIDTH/2 ; + i < centerx + CHAR_CLAIRVOYANCEWIDTH/2 ; i ++ ){ + for( j = centery - CHAR_CLAIRVOYANCEWIDTH/2 ; + j < centery + CHAR_CLAIRVOYANCEWIDTH/2 ; j ++ ){ + OBJECT object; + for( object = MAP_getTopObj(fl,i,j) ; object ; + object = NEXT_OBJECT( object ) ){ + int objindex = GET_OBJINDEX(object); + int loop; + + if( OBJECT_getType(objindex) == OBJTYPE_NOUSE )continue; + if( OBJECT_getType(objindex) == OBJTYPE_CHARA + && OBJECT_getIndex(objindex) == charaindex) continue; + for( loop = 0 ; loop < clairvoyancelevel ; loop ++ ){ + BOOL ret; + char id; + ret = clairvoyancefunc[loop](objindex,&id); + if( ret == TRUE ){ + sendclairvoyance=TRUE; + snprintf( onebuf,sizeof(onebuf), + "%d|%d|%c|",i,j,id ); + strcpysafe( CHAR_clairvoyanceString + stringlen, + sizeof(CHAR_clairvoyanceString) + - stringlen, onebuf); + stringlen += strlen(onebuf); + if( stringlen > sizeof(CHAR_clairvoyanceString) ) + goto RETURN; + } + } + } + } + } + +RETURN: + if( stringlen >= 1 ){ + int fd; + fd = getfdFromCharaIndex( charaindex ); + dchop( CHAR_clairvoyanceString, "|" ); + if( fd != -1 ) + lssproto_R_send( fd, CHAR_clairvoyanceString ); + }else if( !sendclairvoyance ){ + int fd; + fd = getfdFromCharaIndex( charaindex ); + if( fd != -1 ) + lssproto_R_send( fd, "" ); + } +} + +void CHAR_loopFunc( int charaindex ) +{ + CHAR_recoveryStatus( charaindex ); + CHAR_clairvoyance( charaindex ); +} + +void CHAR_playerresurrect( int charaindex, int hp ) +{ + CHAR_setInt(charaindex,CHAR_BASEIMAGENUMBER, + CHAR_getInt(charaindex,CHAR_BASEBASEIMAGENUMBER)); + CHAR_setFlg(charaindex,CHAR_ISDIE, 0); + CHAR_setFlg(charaindex,CHAR_ISATTACKED, 1); + CHAR_setFlg(charaindex,CHAR_ISOVERED, 0); + if( hp >= CHAR_getWorkInt(charaindex,CHAR_WORKMAXHP) ) + hp = CHAR_getWorkInt(charaindex,CHAR_WORKMAXHP); + else if( hp <= 0 ) + hp = 1; + CHAR_setInt(charaindex,CHAR_HP, hp); +} + +int CHAR_die( int charaindex ) +{ + CHAR_DischargeParty( charaindex, 0); + { + int bymonster = 0; + int attackindex = CHAR_getWorkInt(charaindex, + CHAR_WORKLASTATTACKCHARAINDEX); + if( attackindex == -2 ) + bymonster = 0; + else if( CHAR_CHECKINDEX(attackindex) == TRUE ){ + if( CHAR_getInt(attackindex,CHAR_WHICHTYPE) + == CHAR_TYPEENEMY ){ + bymonster = 1; + }else{ + bymonster = 2; + } + } + if( bymonster == 0 || bymonster == 1 ){ + int i; + for( i=0 ; i= 1 ){ + int randomindex = RAND(0,itemhavenum-1); + CHAR_DropItem(charaindex,eqindex[randomindex]); + + } + } + + CHAR_DropMoney(charaindex, + CHAR_getInt(charaindex,CHAR_GOLD)/2 ); + CHAR_setInt(charaindex,CHAR_GOLD,0); + } + CHAR_complianceParameter(charaindex); + CHAR_sendCToArroundCharacter( CHAR_getWorkInt(charaindex, CHAR_WORKOBJINDEX) ); + CHAR_setInt(charaindex,CHAR_DEADCOUNT, + CHAR_getInt(charaindex,CHAR_DEADCOUNT)+1); + { + int i; + BOOL old=FALSE; + for( i=0 ; i 0 ){ + old = TRUE; + } + if( CHAR_setInt( charaindex, CHAR_POISON, 0 ) > 0 )old=TRUE; + if( old ) + CHAR_sendCToArroundCharacter( CHAR_getInt(charaindex, CHAR_WORKOBJINDEX)); + } + CHAR_sendStatusString( charaindex, "P"); + CHAR_sendStatusString( charaindex, "I"); + CHAR_setFlg(charaindex,CHAR_ISDIE,1); + CHAR_setFlg(charaindex,CHAR_ISATTACKED,0); + return 0; +} + +void CHAR_playerTalkedfunc( int charaindex, int talkindex,char* message, int color, int channel ) +{ + int fd; + char lastbuf[4096]; + char mesgbuf[4096]; + char escapebuf[4096]; + int fmindex = CHAR_getInt( charaindex, CHAR_FMINDEX ); + fd = getfdFromCharaIndex( charaindex ); + if( fd == -1 )return; + if( (channel>-1) && (fmindex>0) ){ + if( channel == 0 ){ +#ifndef _CHANNEL_MODIFY + snprintf( lastbuf,sizeof(lastbuf),"P|[]%s", +#else + snprintf( lastbuf,sizeof(lastbuf),"P|F|[]%s", +#endif + makeEscapeString( CHAR_appendNameAndTitle(talkindex, message, mesgbuf,sizeof(mesgbuf)), + escapebuf,sizeof(escapebuf) )); + } +#ifdef _FMVER21 + else if( channel == FAMILY_MAXCHANNEL && CHAR_getInt( talkindex, CHAR_FMLEADERFLAG ) == FMMEMBER_LEADER ){ +#else + else if( channel == FAMILY_MAXCHANNEL && CHAR_getInt( talkindex, CHAR_FMLEADERFLAG ) == 1 ){ +#endif +#ifndef _CHANNEL_MODIFY + snprintf( lastbuf,sizeof(lastbuf),"P|[峤㲥]%s", +#else + snprintf( lastbuf,sizeof(lastbuf),"P|F|[峤㲥]%s", +#endif + makeEscapeString(CHAR_appendNameAndTitle(talkindex, message,mesgbuf,sizeof(mesgbuf)), + escapebuf,sizeof(escapebuf) )); + }else{ + snprintf( lastbuf,sizeof(lastbuf),"P|[%d]%s",channel, + makeEscapeString(CHAR_appendNameAndTitle(talkindex, message,mesgbuf,sizeof(mesgbuf)), + escapebuf,sizeof(escapebuf) )); + } + }else{ +#ifdef _CHANNEL_MODIFY + if(CHAR_getFlg(talkindex,CHAR_ISPARTYCHAT) && (CHAR_getWorkInt(talkindex,CHAR_WORKPARTYMODE) != CHAR_PARTY_NONE)) + snprintf( lastbuf,sizeof(lastbuf),"P|T|[]%s", + makeEscapeString(CHAR_appendNameAndTitle(talkindex, message,mesgbuf,sizeof(mesgbuf)), + escapebuf,sizeof(escapebuf) )); + else +#ifdef _FONT_SIZE + snprintf( lastbuf,sizeof(lastbuf),"P|P|%s|%d", + makeEscapeString(CHAR_appendNameAndTitle(talkindex, message,mesgbuf,sizeof(mesgbuf)), + escapebuf,sizeof(escapebuf) ), CHAR_getWorkInt( talkindex, CHAR_WORKFONTSIZE) ); +#else + snprintf( lastbuf,sizeof(lastbuf),"P|P|%s", + makeEscapeString(CHAR_appendNameAndTitle(talkindex, message,mesgbuf,sizeof(mesgbuf)), + escapebuf,sizeof(escapebuf) )); +#endif + +#else + snprintf( lastbuf,sizeof(lastbuf),"P|%s", + makeEscapeString(CHAR_appendNameAndTitle(talkindex, message,mesgbuf,sizeof(mesgbuf)), + escapebuf,sizeof(escapebuf) )); +#endif + } + lssproto_TK_send( fd, CHAR_getWorkInt( talkindex, CHAR_WORKOBJINDEX ),lastbuf, color); +} diff --git a/char/char_item.c b/char/char_item.c new file mode 100644 index 0000000..1964a9f --- /dev/null +++ b/char/char_item.c @@ -0,0 +1,2774 @@ +#include "version.h" +#include + +#include "configfile.h" +#include "readmap.h" +#include "map_deal.h" +#include "object.h" +#include "char.h" +#include "char_base.h" +#include "item.h" +#include "lssproto_serv.h" +#include "handletime.h" +#include "log.h" +#include "item_event.h" +#include "battle.h" +#include "petmail.h" +#ifdef _ALLBLUES_LUA +#include "mylua/function.h" +#endif +#ifdef _ANGEL_SUMMON +extern struct MissionInfo missionlist[MAXMISSION]; +extern struct MissionTable missiontable[MAXMISSIONTABLE]; +#endif + +extern int itemLine; + +#ifdef _DROPSTAKENEW +#define CASINOTOKENID 20121 // ֳȯ +#define MAXCASINOMAPNUM 150 // ֳͼ +#define MAXACCUMULATION 1000000 // +typedef struct tagCasinoMapTable +{ + int casinofl; // ֳͼ + int casinox; // ֳ + int casinoy; // ֳ + int casinotype; // ע + int dropflag; // Ƿע flag + char casinoinfo[64]; // ע˵ + int accumulation; // + int stakenum; // ȯ +}CasinoMapTable; +CasinoMapTable casinomap[MAXCASINOMAPNUM] = +{ + { 7008, 13, 13, DICE_BIG, 1, "ӣ", 1, 0}, + { 7008, 14, 13, DICE_BIG, 1, "ӣ", 1, 0}, + { 7008, 15, 13, DICE_BIG, 1, "ӣ", 1, 0}, + { 7008, 16, 13, DICE_BIG, 1, "ӣ", 1, 0}, + { 7008, 17, 13, DICE_BIG, 1, "ӣ", 1, 0}, + { 7008, 13, 14, DICE_BIG, 1, "ӣ", 1, 0}, + { 7008, 14, 14, DICE_BIG, 1, "ӣ", 1, 0}, + { 7008, 15, 14, DICE_BIG, 1, "ӣ", 1, 0}, + { 7008, 16, 14, DICE_BIG, 1, "ӣ", 1, 0}, + { 7008, 17, 14, DICE_BIG, 1, "ӣ", 1, 0}, + { 7008, 13, 15, DICE_BIG, 1, "ӣ", 1, 0}, + { 7008, 14, 15, DICE_BIG, 1, "ӣ", 1, 0}, + { 7008, 15, 15, DICE_BIG, 1, "ӣ", 1, 0}, + { 7008, 16, 15, DICE_BIG, 1, "ӣ", 1, 0}, + { 7008, 17, 15, DICE_BIG, 1, "ӣ", 1, 0}, + { 7008, 8, 13, DICE_SMALL, 1, "ӣС", 1, 0}, + { 7008, 9, 13, DICE_SMALL, 1, "ӣС", 1, 0}, + { 7008, 10, 13, DICE_SMALL, 1, "ӣС", 1, 0}, + { 7008, 11, 13, DICE_SMALL, 1, "ӣС", 1, 0}, + { 7008, 12, 13, DICE_SMALL, 1, "ӣС", 1, 0}, + { 7008, 8, 14, DICE_SMALL, 1, "ӣС", 1, 0}, + { 7008, 9, 14, DICE_SMALL, 1, "ӣС", 1, 0}, + { 7008, 10, 14, DICE_SMALL, 1, "ӣС", 1, 0}, + { 7008, 11, 14, DICE_SMALL, 1, "ӣС", 1, 0}, + { 7008, 12, 14, DICE_SMALL, 1, "ӣС", 1, 0}, + { 7008, 8, 15, DICE_SMALL, 1, "ӣС", 1, 0}, + { 7008, 9, 15, DICE_SMALL, 1, "ӣС", 1, 0}, + { 7008, 10, 15, DICE_SMALL, 1, "ӣС", 1, 0}, + { 7008, 11, 15, DICE_SMALL, 1, "ӣС", 1, 0}, + { 7008, 12, 15, DICE_SMALL, 1, "ӣС", 1, 0}, + + { 7005, 22, 21, PET_RACE1, 1, "ٳ", 2, 0}, + { 7005, 23, 21, PET_RACE1, 1, "ٳ", 2, 0}, + { 7005, 24, 21, PET_RACE1, 1, "ٳ", 2, 0}, + { 7005, 25, 21, PET_RACE1, 1, "ٳ", 2, 0}, + { 7005, 26, 21, PET_RACE1, 1, "ٳ", 2, 0}, + { 7005, 27, 21, PET_RACE1, 1, "ٳ", 2, 0}, + { 7005, 28, 21, PET_RACE1, 1, "ٳ", 2, 0}, + { 7005, 22, 24, PET_RACE2, 1, "ٳ", 2, 0}, + { 7005, 23, 24, PET_RACE2, 1, "ٳ", 2, 0}, + { 7005, 24, 24, PET_RACE2, 1, "ٳ", 2, 0}, + { 7005, 25, 24, PET_RACE2, 1, "ٳ", 2, 0}, + { 7005, 26, 24, PET_RACE2, 1, "ٳ", 2, 0}, + { 7005, 27, 24, PET_RACE2, 1, "ٳ", 2, 0}, + { 7005, 28, 24, PET_RACE2, 1, "ٳ", 2, 0}, + { 7005, 22, 27, PET_RACE3, 1, "ٳ", 2, 0}, + { 7005, 23, 27, PET_RACE3, 1, "ٳ", 2, 0}, + { 7005, 24, 27, PET_RACE3, 1, "ٳ", 2, 0}, + { 7005, 25, 27, PET_RACE3, 1, "ٳ", 2, 0}, + { 7005, 26, 27, PET_RACE3, 1, "ٳ", 2, 0}, + { 7005, 27, 27, PET_RACE3, 1, "ٳ", 2, 0}, + { 7005, 28, 27, PET_RACE3, 1, "ٳ", 2, 0}, + + { 7003, 21, 15, ROULETTE1, 1, "̺죱", 1, 0}, { 7003, 17, 15, ROULETTE3, 1, "̺죳", 1, 0}, + { 7003, 13, 15, ROULETTE5, 1, "̺죵", 1, 0}, { 7003, 21, 21, ROULETTE6, 1, "̺죶", 1, 0}, + { 7003, 17, 21, ROULETTE8, 1, "̺죸", 1, 0}, { 7003, 15, 21, ROULETTE9, 1, "̺죹", 1, 0}, + { 7003, 13, 21, ROULETTE10, 1, "̺죱", 1, 0}, { 7003, 13, 18, ROULETTE13, 1, "̺죱", 1, 0}, + { 7003, 9, 21, ROULETTE17, 1, "̺죱", 1, 0}, { 7003, 21, 18, ROULETTE18, 1, "̺죱", 1, 0}, + + { 7003, 19, 15, ROULETTE22, 1, "̣", 1, 0}, { 7003, 15, 15, ROULETTE24, 1, "̣", 1, 0}, + { 7003, 19, 21, ROULETTE27, 1, "̣", 1, 0}, { 7003, 11, 15, ROULETTE31, 1, "̣", 1, 0}, + { 7003, 9, 15, ROULETTE32, 1, "̣", 1, 0}, { 7003, 11, 18, ROULETTE34, 1, "̣", 1, 0}, + { 7003, 9, 18, ROULETTE35, 1, "̣", 1, 0}, { 7003, 11, 21, ROULETTE36, 1, "̣", 1, 0}, + { 7003, 19, 18, ROULETTE39, 1, "̣", 1, 0}, { 7003, 17, 18, ROULETTE40, 1, "̣", 1, 0}, + { 7003, 17, 24, ROULETTE41, 1, "̺", 1, 0}, { 7003, 16, 24, ROULETTE41, 1, "̺", 1, 0}, + { 7003, 17, 25, ROULETTE41, 1, "̺", 1, 0}, { 7003, 16, 25, ROULETTE41, 1, "̺", 1, 0}, + { 7003, 14, 24, ROULETTE42, 1, "", 1, 0}, { 7003, 13, 24, ROULETTE42, 1, "", 1, 0}, + { 7003, 14, 25, ROULETTE42, 1, "", 1, 0}, { 7003, 13, 25, ROULETTE42, 1, "", 1, 0}, + + // WON ADD ͼϵ˫Ĵ + { 7003, 11, 24, ROULETTE43, 1, "̵", 1, 0}, { 7003, 10, 24, ROULETTE43, 1, "̵", 1, 0}, + { 7003, 11, 25, ROULETTE43, 1, "̵", 1, 0}, { 7003, 10, 25, ROULETTE43, 1, "̵", 1, 0}, + { 7003, 20, 24, ROULETTE44, 1, "˫", 1, 0}, { 7003, 19, 24, ROULETTE44, 1, "˫", 1, 0}, + { 7003, 20, 25, ROULETTE44, 1, "˫", 1, 0}, { 7003, 19, 25, ROULETTE44, 1, "˫", 1, 0}, + + + + { 7003, 20, 15, (ROULETTE1<<16)+ROULETTE22, 1, "˫ź죱̣", 1, 0}, + { 7003, 18, 15, (ROULETTE3<<16)+ROULETTE22, 1, "˫ź죳̣", 1, 0}, + { 7003, 16, 15, (ROULETTE3<<16)+ROULETTE24, 1, "˫ź죳̣", 1, 0}, + { 7003, 14, 15, (ROULETTE5<<16)+ROULETTE24, 1, "˫ź죵̣", 1, 0}, + { 7003, 12, 15, (ROULETTE5<<16)+ROULETTE31, 1, "˫ź죵̣", 1, 0}, + { 7003, 10, 15, (ROULETTE32<<16)+ROULETTE31, 1, "˫̣̣", 1, 0}, + + { 7003, 20, 18, (ROULETTE18<<16)+ROULETTE39, 1, "˫ź죱̣", 1, 0}, + { 7003, 18, 18, (ROULETTE40<<16)+ROULETTE39, 1, "˫̣̣", 1, 0}, + { 7003, 16, 18, (ROULETTE40<<16)+ROULETTE45, 1, "˫̣ڣ", 1, 0}, + { 7003, 14, 18, (ROULETTE13<<16)+ROULETTE45, 1, "˫ź죱ڣ", 1, 0}, + { 7003, 12, 18, (ROULETTE13<<16)+ROULETTE34, 1, "˫ź죱̣", 1, 0}, + { 7003, 10, 18, (ROULETTE35<<16)+ROULETTE34, 1, "˫̣̣", 1, 0}, + + { 7003, 20, 21, (ROULETTE6<<16) +ROULETTE27, 1, "˫ź죶̣", 1, 0}, + { 7003, 18, 21, (ROULETTE8<<16) +ROULETTE27, 1, "˫ź죸̣", 1, 0}, + { 7003, 16, 21, (ROULETTE8<<16) + ROULETTE9, 1, "˫ź죸죹", 1, 0}, + { 7003, 14, 21, (ROULETTE10<<16)+ ROULETTE9, 1, "˫ź죱죹", 1, 0}, + { 7003, 12, 21, (ROULETTE10<<16)+ROULETTE36, 1, "˫ź죱̣", 1, 0}, + { 7003, 10, 21, (ROULETTE17<<16)+ROULETTE36, 1, "˫ź죱̣", 1, 0}, + { 7003, 8, 15, ROULETTE51, 1, "У", 1, 0}, // + { 7003, 8, 18, ROULETTE52, 1, "У", 1, 0}, + { 7003, 8, 21, ROULETTE53, 1, "У", 1, 0}, + { 7003, 6, 15, ROULETTE61, 1, "룱", 1, 0}, //110 + { 7003, 5, 15, ROULETTE61, 1, "룱", 1, 0}, + { 7003, 6, 16, ROULETTE61, 1, "룱", 1, 0}, + { 7003, 5, 16, ROULETTE61, 1, "룱", 1, 0}, + { 7003, 24, 15, ROULETTE62, 1, "룱", 1, 0}, //1011 + { 7003, 23, 15, ROULETTE62, 1, "룱", 1, 0}, + { 7003, 24, 16, ROULETTE62, 1, "룱", 1, 0}, + { 7003, 23, 16, ROULETTE62, 1, "룱", 1, 0}, + { 7003, 15, 18, ROULETTE45, 1, "()", 1, 0}, + +}; +#endif + + +static char CHAR_sendItemBuffer[STRINGBUFSIZ]; +BOOL CHAR_sendItemDataOne( int charaindex, int haveitemindex) +{ + int itemgrp[1]; + itemgrp[0] = haveitemindex; + return CHAR_sendItemData( charaindex, itemgrp, 1); +} + +BOOL CHAR_sendItemData( int charaindex, int *itemgroup, int num) +{ + int i; + int strlength = 0; + int fd; + + if( num <= 0 || num > CHAR_MAXITEMHAVE) return FALSE; + + if( CHAR_getInt(charaindex,CHAR_WHICHTYPE) != CHAR_TYPEPLAYER ) { + return FALSE; + } + + for( i = 0; i < num; i ++ ) { + char token[512]; + int itemindex; + if( !CHAR_CHECKITEMINDEX( charaindex, itemgroup[i])) { + continue; + } + itemindex = CHAR_getItemIndex( charaindex, itemgroup[i] ); + if( itemindex >= 0 ) { + snprintf( token ,sizeof(token),"%d|%s|" ,itemgroup[i], ITEM_makeItemStatusString( -1,itemindex ) ); + if(ITEM_getInt( itemindex, ITEM_CANBEPILE)!=1 && ITEM_getInt( itemindex, ITEM_USEPILENUMS)>1) + { + CHAR_setItemIndex( charaindex , itemgroup[i], -1); + snprintf( token ,sizeof(token),"%s|" , ITEM_makeItemFalseStringWithNum( itemgroup[i]) ); + } + }else { + snprintf( token ,sizeof(token),"%s|" , ITEM_makeItemFalseStringWithNum( itemgroup[i]) ); + } + strcpysafe( CHAR_sendItemBuffer + strlength, sizeof(CHAR_sendItemBuffer) - strlength, token ); + strlength += strlen( token ); + if( strlength >= arraysizeof(CHAR_sendItemBuffer) ) { + break; + } + } + dchop( CHAR_sendItemBuffer , "|" ); + fd = getfdFromCharaIndex( charaindex ); + if( fd != -1 ){ + lssproto_I_send( fd, CHAR_sendItemBuffer ); + return TRUE; + } + return FALSE; +} + +static void CHAR_sendItemDetachEvent( int charaindex,int itemid ) +{ + char mesg[256]; + + snprintf( mesg, sizeof( mesg), "ж%s ", ITEM_getAppropriateName(itemid) ); + CHAR_talkToCli(charaindex,-1,mesg,CHAR_COLORWHITE); +#ifdef _ITEM_METAMO + if( ITEM_getEquipPlace( charaindex, itemid) == CHAR_BODY + && CHAR_getWorkInt( charaindex, CHAR_WORKITEMMETAMO) != 0 ) { + CHAR_setWorkInt( charaindex, CHAR_WORKITEMMETAMO, 0); + CHAR_setWorkInt( charaindex, CHAR_WORKNPCMETAMO, 0 ); //npcԻıҲҪ + CHAR_complianceParameter( charaindex); + CHAR_sendCToArroundCharacter( CHAR_getWorkInt( charaindex , CHAR_WORKOBJINDEX )); + CHAR_send_P_StatusString( charaindex , CHAR_P_STRING_BASEBASEIMAGENUMBER); + CHAR_talkToCli( charaindex, -1, "ʧЧˣ", CHAR_COLORWHITE); + } +#endif +#ifdef _ITEM_RIDE + if(CHAR_getInt( charaindex , CHAR_RIDEPET ) != -1 ){ + if( !strcmp( ITEM_getChar( itemid, ITEM_USEFUNC), "ITEM_RIDE") ) { + char ridemetamo[12]; + char *itemarg = ITEM_getChar( itemid, ITEM_ARGUMENT); + getStringFromIndexWithDelim( itemarg, "|", 2, ridemetamo, sizeof(ridemetamo)); + if(CHAR_getInt( charaindex , CHAR_BASEIMAGENUMBER )==atoi(ridemetamo)){ + CHAR_setInt( charaindex , CHAR_RIDEPET, -1 ); + CHAR_setInt( charaindex , CHAR_BASEIMAGENUMBER , CHAR_getInt( charaindex , CHAR_BASEBASEIMAGENUMBER) ); + CHAR_complianceParameter( charaindex ); + CHAR_sendCToArroundCharacter( CHAR_getWorkInt( charaindex, CHAR_WORKOBJINDEX )); + CHAR_send_P_StatusString( charaindex , CHAR_P_STRING_RIDEPET); + } + } + } +#endif + { + typedef void (*DETACHFUNC)(int,int); + DETACHFUNC def; + def=(DETACHFUNC)ITEM_getFunctionPointer(itemid,ITEM_DETACHFUNC); + if( def ) { + def( charaindex,itemid ); + } +#ifdef _ALLBLUES_LUA_1_2 + else{ + RunItemDetachEvent(charaindex,itemid ); + } +#endif + } +} + +static void CHAR_sendItemAttachEvent( int charaindex,int itemid ) +{ + char mesg[256]; + snprintf( mesg, sizeof( mesg), "װ%s ", + ITEM_getAppropriateName(itemid) ); + CHAR_talkToCli(charaindex,-1,mesg,CHAR_COLORWHITE); + { + typedef void (*ATTACHFUNC)(int,int); + ATTACHFUNC atf; + atf=(ATTACHFUNC)ITEM_getFunctionPointer(itemid,ITEM_ATTACHFUNC); + if( atf ){ + atf( charaindex,itemid ); + } +#ifdef _ALLBLUES_LUA_1_2 + else{ + RunItemAttachEvent(charaindex, itemid ); + } +#endif + } +} + + +int CHAR_findSurplusItemBox( int charaindex ) +{ + int i, remnants=0, itemindex; + for(i=CHAR_STARTITEMARRAY; i< CHAR_MAXITEMHAVE; i++){ + itemindex = CHAR_getItemIndex( charaindex , i ); + if( itemindex == -1 ) remnants++; + } + return remnants; +} + + +static int CHAR_findEmptyItemBoxFromChar( Char* ch ) +{ + int i; + + for( i = CHAR_STARTITEMARRAY ; i < CHAR_MAXITEMHAVE ; i ++ ){ + int itemindex; + itemindex = ch->indexOfExistItems[i]; + if( itemindex == -1 )return i; + } + + return -1; +} + +static int CHAR_findEmptyPoolItemBoxFromChar( Char* ch ) +{ + int i; + for( i=0; iindexOfExistPoolItems[i]; + if( itemindex == -1 ) return i; + } + return -1; +} + +int CHAR_findEmptyPoolItemBox( int index ) +{ + Char* ch; + if( !CHAR_CHECKINDEX( index ) )return -1; + ch = CHAR_getCharPointer(index); + if( ch != NULL ) + return CHAR_findEmptyPoolItemBoxFromChar( ch ); + else + return -1; +} + +int CHAR_findEmptyItemBox( int index ) +{ + Char* ch; + + if( !CHAR_CHECKINDEX( index ) )return -1; + ch = CHAR_getCharPointer(index); + if( ch != NULL ) + return CHAR_findEmptyItemBoxFromChar( ch ); + else + return -1; + +} + +#define LACKOFCLASS {CHAR_talkToCli(index,-1,"޷װ",CHAR_COLORWHITE);} +#define CANNOTEQUIP {CHAR_talkToCli(index,-1,"޷װƷ",CHAR_COLORWHITE);} +#define CANNOTEQUIP2 {CHAR_talkToCli(index,-1,"޷ͬʱװͬƷ",CHAR_COLORWHITE);} +#define CANNOTEXCHANGE {CHAR_talkToCli(index,-1,"޷Ʒ",CHAR_COLORWHITE);} +#define CANNOTMOVE {CHAR_talkToCli(index,-1,"޷ƶƷ",CHAR_COLORWHITE);} + +static BOOL CHAR_sendSIToCli( int charindex , int from , int to ) +{ + int fd = getfdFromCharaIndex( charindex ); + if( fd != -1 ){ + lssproto_SI_send( fd , from, to ); + return TRUE; + } + return FALSE; +} + +static BOOL CHAR_moveItemFromItemBoxToEquip( int index, int fromindex, + int toindex ) +{ + int fromid,toid; + int fromeqplace; + BOOL flg = FALSE; + + if( !CHAR_CHECKINDEX( index ) )return FALSE; + + fromid = CHAR_getItemIndex(index,fromindex); + toid = CHAR_getItemIndex(index,toindex); + if( !ITEM_CHECKINDEX( fromid) ) + return FALSE; + + if( CHAR_getInt( index, CHAR_TRANSMIGRATION ) <= 0 ){ + if( ITEM_getInt(fromid,ITEM_LEVEL) > CHAR_getInt(index,CHAR_LV) ){ + LACKOFCLASS; + return FALSE; + } + } +#ifdef _ITEMSET4_TXT + if( CHAR_getInt( index, CHAR_STR) < ITEM_getInt( fromid, ITEM_NEEDSTR) ) return FALSE; + if( CHAR_getInt( index, CHAR_DEX) < ITEM_getInt( fromid, ITEM_NEEDDEX) ) return FALSE; + if( CHAR_getInt( index, CHAR_TRANSMIGRATION) < ITEM_getInt( fromid, ITEM_NEEDTRANS) ) return FALSE; +#ifdef _CHAR_PROFESSION // WON ADD ְҵ + if( ITEM_getInt( fromid, ITEM_NEEDPROFESSION) != 0 ){ + if( CHAR_getInt( index, PROFESSION_CLASS ) != ITEM_getInt( fromid, ITEM_NEEDPROFESSION) ) + return FALSE; + } +#endif +#endif + +#ifdef _FIXBUG_ATTACKBOW + { + if( CHAR_getWorkInt( index, CHAR_WORKITEMMETAMO) > 0 || + CHAR_getWorkInt( index, CHAR_WORKNPCMETAMO) > 0 + || CHAR_getWorkInt( index, CHAR_WORKFOXROUND ) != -1){ //DZС + + int armtype = ITEM_getInt( fromid, ITEM_TYPE ); + + if( armtype == ITEM_BOW || armtype == ITEM_BOUNDTHROW || + armtype == ITEM_BREAKTHROW || armtype == ITEM_BOOMERANG) { + CHAR_talkToCli( index, -1, "޷ʹԶ", CHAR_COLORYELLOW ); + return FALSE; + } + } + } +#endif + +#ifdef _ANGEL_SUMMON + //if( !strcmp( ITEM_getChar( fromid, ITEM_USEFUNC), "ITEM_AngelToken") ) { + if( ITEM_getInt( fromid, ITEM_ID) == ANGELITEM ) { + int mindex; + char nameinfo[64]; + + mindex = checkIfAngel( index); + getMissionNameInfo( index, nameinfo); + if( mindex < 0 || + strcmp( ITEM_getChar( fromid, ITEM_ANGELINFO), missiontable[mindex].angelinfo) || + strcmp( ITEM_getChar( fromid, ITEM_HEROINFO), missiontable[mindex].heroinfo) || + strcmp( ITEM_getChar( fromid, ITEM_ANGELINFO), nameinfo) ) { + + CHAR_talkToCli( index, -1, "Ⲣ޷װ", CHAR_COLORYELLOW ); + return FALSE; + } + } +#endif + + fromeqplace = ITEM_getEquipPlace( index, fromid ); + if( fromeqplace == -1 ){ + CANNOTEQUIP; + return FALSE; + } + //if( BATTLE_GetWepon( charaindex ) != ITEM_BOW ) + + if( fromeqplace == CHAR_DECORATION1 ) { + int checkplace = ( toindex == CHAR_DECORATION1) + ? CHAR_DECORATION2:CHAR_DECORATION1; + int otheritemindex; + + if( toindex == CHAR_DECORATION1 || toindex == CHAR_DECORATION2 ) { + otheritemindex = CHAR_getItemIndex( index, checkplace); + if( ITEM_CHECKINDEX( otheritemindex )) { + int otheritemtype = ITEM_getInt( otheritemindex, ITEM_TYPE); + int myitemtype = ITEM_getInt( CHAR_getItemIndex( index, fromindex) , ITEM_TYPE); + if( otheritemtype == myitemtype) { + if( toid < 0 ) { + CANNOTEQUIP2; + }else { + CANNOTEXCHANGE; + } + return FALSE; + } + } + flg = TRUE; + } + }else { + if( toindex == fromeqplace) flg = TRUE; + } + if( flg ){ + CHAR_setItemIndex(index,toindex,fromid); + CHAR_setItemIndex(index,fromindex,toid); + if( toid != -1 ) { + CHAR_sendItemDetachEvent( index, toid ); + } + CHAR_sendItemAttachEvent( index, fromid ); + CHAR_sendSIToCli( index, fromindex,toindex ); + }else { + CANNOTEQUIP; + return FALSE; + } + return TRUE; +} + +static BOOL CHAR_moveItemFromEquipToItemBox(int index, int fromindex, + int toindex) +{ + int fromid,toid; + + if( !CHAR_CHECKINDEX( index )) return FALSE; + + fromid = CHAR_getItemIndex(index,fromindex); + toid = CHAR_getItemIndex(index,toindex); + if( fromid < 0 ) + return FALSE; + else if( toid < 0 ){ + CHAR_setItemIndex(index,toindex,fromid); + CHAR_setItemIndex(index,fromindex,-1); + CHAR_sendItemDetachEvent( index,fromid ); + CHAR_sendSIToCli( index,fromindex,toindex); + return TRUE; + } + + return CHAR_moveItemFromItemBoxToEquip(index, toindex,fromindex); +} + +#ifdef _ITEM_PILENUMS +int CHAR_getMyMaxPilenum( int charaindex) +{ + int maxpile; + int transnum = CHAR_getInt( charaindex, CHAR_TRANSMIGRATION); + if(CHAR_getInt(charaindex,CHAR_VIPRIDE)>1) + { + maxpile=100; + } + else + { + if(transnum <= 5) + { + maxpile = transnum + + (transnum/5) * 2 + 3; + } + else if(transnum > 5) + { + maxpile = 50; + } + } + +/* +#ifdef _PROFESSION_SKILL // WON ADD ְҵ + maxpile += CHAR_getInt( charaindex, ATTACHPILE ); +#endif +*/ + +#ifdef _EQUIT_ADDPILE + maxpile += CHAR_getWorkInt( charaindex, CHAR_WORKATTACHPILE); + maxpile = (maxpile<0)?0:maxpile; +#endif + return maxpile; +} + +BOOL CHAR_PileItemFromItemBoxToItemBox( int charaindex, int fromindex, int toindex) +{ + int maxpile, fromid, toid; + if( !CHAR_CHECKINDEX( charaindex) ) return FALSE; + fromid = CHAR_getItemIndex( charaindex, fromindex); + toid = CHAR_getItemIndex( charaindex, toindex); + + maxpile = CHAR_getMyMaxPilenum( charaindex); + + if( ITEM_CHECKINDEX( toid) && ITEM_CHECKINDEX( fromid) && + (ITEM_getInt( toid, ITEM_ID) == ITEM_getInt( fromid, ITEM_ID)) && + (ITEM_getInt( toid, ITEM_CANBEPILE) == 1) && + (ITEM_getInt( toid, ITEM_USEPILENUMS) < maxpile) && + (ITEM_getInt( fromid, ITEM_USEPILENUMS) < maxpile) ){ + int formpilenum , pilenum, defpilenum; + + pilenum = ITEM_getInt( toid, ITEM_USEPILENUMS); + formpilenum = ITEM_getInt( fromid, ITEM_USEPILENUMS); + defpilenum = ((maxpile-pilenum)>formpilenum)? formpilenum:(maxpile-pilenum); + formpilenum = formpilenum - defpilenum; + pilenum = pilenum + defpilenum; + ITEM_setInt( toid, ITEM_USEPILENUMS, pilenum); + ITEM_setInt( fromid, ITEM_USEPILENUMS, formpilenum); + + if( formpilenum <= 0 ){ + CHAR_setItemIndex( charaindex, fromindex ,-1); + ITEM_endExistItemsOne( fromid); + } + return TRUE; + } + return FALSE; +} +#endif + +static BOOL CHAR_moveItemFromItemBoxToItemBox( int index, int fromindex, int toindex) +{ + int fromid, toid; + + if( !CHAR_CHECKINDEX( index ) ) return FALSE; +#ifdef _ITEM_PILENUMS + if( CHAR_PileItemFromItemBoxToItemBox( index, fromindex, toindex) == TRUE ){ + CHAR_sendItemDataOne( index, toindex); + CHAR_sendItemDataOne( index, fromindex); + return TRUE; + } +#endif + fromid = CHAR_getItemIndex( index, fromindex); + toid = CHAR_getItemIndex( index, toindex); +#ifdef _ITEM_RESET + char *itemarg = NULL; + itemarg = ITEM_getChar(fromid,ITEM_ARGUMENT); + if(strlen(itemarg)>0){ + int itemid; + int playfd = getfdFromCharaIndex(index); + if(strcmp(itemarg,"ITEMRESET")==0){ + itemid = ITEM_getInt(toid,ITEM_ID); + int resetpoint = sasql_itemreset_query(itemid); + if(resetpoint>=0){ + char resetmsg[256]; + sprintf(resetmsg,"\nȷҪԭ%sô\n\nԭƷҪ%d\n\nȷĻOK\n",ITEM_getChar(toid,ITEM_NAME),resetpoint); + lssproto_WN_send( playfd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OKCANCEL, + CHAR_WINDOWTYPE_RESETITEM, + -1, + resetmsg); + CHAR_setWorkInt(index,CHAR_WORKFROMITEMINDEX,fromindex); + CHAR_setWorkInt(index,CHAR_WORKTOITEMINDEX,toindex); + return FALSE; + }else{ + if(itemid>=0){ + lssproto_WN_send( playfd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_CANCEL, + -1, + -1, + "˵߲ܻԭ"); + } + } + }else if(strcmp(itemarg,"ITEMDEL")==0){ + itemid = ITEM_getInt(toid,ITEM_ID); + int resetpoint = sasql_itemdel_query(itemid); + if(resetpoint>=0){ + char resetmsg[256]; + sprintf(resetmsg,"\nȷҪա%sô\n\nƷտɵá%d\n\nȷĻOK\n",ITEM_getChar(toid,ITEM_NAME),resetpoint); + lssproto_WN_send( playfd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OKCANCEL, + CHAR_WINDOWTYPE_DELITEM, + -1, + resetmsg); + CHAR_setWorkInt(index,CHAR_WORKFROMITEMINDEX,fromindex); + CHAR_setWorkInt(index,CHAR_WORKTOITEMINDEX,toindex); + return FALSE; + }else{ + if(itemid>=0){ + lssproto_WN_send( playfd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_CANCEL, + -1, + -1, + "˵߲ܻգ"); + } + } + } + } +#endif + CHAR_setItemIndex(index,toindex, CHAR_setItemIndex( index, fromindex, toid)); + CHAR_sendSIToCli( index,fromindex,toindex); + + return TRUE; +} + +void CHAR_moveEquipItem( int index, int fromindex, int toindex ) +{ +#define MOVEITEM_NONE 0 +#define MOVEITEM_EQUIPTOITEM 1 << 0 +#define MOVEITEM_ITEMTOEQUIP 1 << 1 +#define MOVEITEM_ITEMTOITEM 1 << 2 + + int fromid; /* item ƥ̼͵ */ + + + unsigned int moved_any = 0; + while( 1) { + if( !CHAR_CHECKINDEX( index ) )break; + if( CHAR_getFlg( index,CHAR_ISDIE ) )break; + if( fromindex < 0 || fromindex >= CHAR_MAXITEMHAVE || + toindex < 0 || toindex >= CHAR_MAXITEMHAVE ) + break; + + fromid = CHAR_getItemIndex(index,fromindex); + if( fromid == -1 || fromid == -2 )break; + if( fromindex == toindex )break; + if( fromindex < CHAR_EQUIPPLACENUM ){ + if( toindex < CHAR_EQUIPPLACENUM ){ + if( CHAR_getItemIndex(index,toindex) < 0 ){ + CANNOTMOVE; + }else{ + CANNOTEXCHANGE; + } + + }else { + moved_any |= CHAR_moveItemFromEquipToItemBox( + index, fromindex, toindex ) + ? MOVEITEM_EQUIPTOITEM : MOVEITEM_NONE; + if( moved_any & MOVEITEM_EQUIPTOITEM) { + char category[3]; + snprintf( category,sizeof( category),"J%d", fromindex); + CHAR_sendStatusString( index , category); + } + } + }else{ + if( toindex < CHAR_EQUIPPLACENUM ) { + moved_any |= CHAR_moveItemFromItemBoxToEquip( + index, fromindex , toindex ) + ? MOVEITEM_ITEMTOEQUIP : MOVEITEM_NONE; + if( moved_any & MOVEITEM_ITEMTOEQUIP) { + char category[3]; + snprintf( category,sizeof( category),"J%d", toindex); + CHAR_sendStatusString( index , category); + } + }else { + moved_any |= CHAR_moveItemFromItemBoxToItemBox( index,fromindex,toindex ) + ? MOVEITEM_ITEMTOITEM : MOVEITEM_NONE; + } + } + CHAR_complianceParameter( index ); + CHAR_sendCToArroundCharacter(CHAR_getWorkInt(index, CHAR_WORKOBJINDEX)); + break; + } + + if( (moved_any & MOVEITEM_EQUIPTOITEM) || (moved_any & MOVEITEM_ITEMTOEQUIP)){ + int i; + CHAR_send_P_StatusString( index, + CHAR_P_STRING_HP|CHAR_P_STRING_MAXHP| + CHAR_P_STRING_MP|CHAR_P_STRING_MAXMP| + CHAR_P_STRING_ATK|CHAR_P_STRING_DEF| + CHAR_P_STRING_QUICK|CHAR_P_STRING_CHARM| + CHAR_P_STRING_LUCK|CHAR_P_STRING_EARTH| + CHAR_P_STRING_WATER|CHAR_P_STRING_FIRE| + CHAR_P_STRING_WIND + ); +/* + if( CHAR_getWorkInt( index,CHAR_WORKBATTLEMODE ) == BATTLE_CHARMODE_NONE ){ + for( i = 0; i < CHAR_MAXPETHAVE; i ++ ) { + int petindex = CHAR_getCharPet( index, i); + if( CHAR_CHECKINDEX( petindex) ) { + char category[3]; + CHAR_complianceParameter( petindex ); + snprintf( category, sizeof( category), "K%d",i); + CHAR_sendStatusString( index, category ); + } + } + } +*/ + } + if( !moved_any ) { + CHAR_sendSIToCli( index,-1,-1); + } +} + +int CHAR_addItemToChar( Char* ch, int itemid ) +{ + int itembox; + itembox = CHAR_findEmptyItemBoxFromChar( ch ); + if( itembox == -1 )return -1; + + return ch->indexOfExistItems[itembox]=ITEM_makeItemAndRegist(itemid); +} + +int CHAR_addItem( int charaindex, int itemid ) +{ + Char* ch; + ch = CHAR_getCharPointer(charaindex); + if( ch != NULL ){ + int ret = CHAR_addItemToChar( ch,itemid ); + if( ret == -1 )return ret; + ITEM_setWorkInt(ret,ITEM_WORKCHARAINDEX,charaindex); + ITEM_setWorkInt(ret,ITEM_WORKOBJINDEX,-1); + return ret; + }else + return -1; +} + + +void CHAR_ItemUse( int charaindex, int to_charaindex, int haveitemindex ) +{ + void (*usefunc)(int,int,int)=NULL; + int itemindex; + if( !CHAR_CHECKINDEX( charaindex ) ){ + print( "ANDY charaindex=%d err\n", charaindex); + return; + } + if( CHAR_CHECKITEMINDEX( charaindex, haveitemindex) == FALSE ){ + print( "ANDY haveitemindex=%d err\n", haveitemindex); + return; + } + itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + if( !ITEM_CHECKINDEX(itemindex) ){ +// print( "ANDY itemindex=%d err\n", itemindex); + return; + } + int myviptype = CHAR_getInt(charaindex,CHAR_VIPRIDE); + if(myviptype==0){ + if(strstr(ITEM_getChar(itemindex,ITEM_NAME),"[VIP")!=NULL){ + CHAR_talkToCli( charaindex, -1, "Աȼ޷ʹôװ", CHAR_COLORYELLOW ); + return; + } + }else if(myviptype==1){ + if(strstr(ITEM_getChar(itemindex,ITEM_NAME),"[VIP2]")!=NULL || strstr(ITEM_getChar(itemindex,ITEM_NAME),"[VIP3]")!=NULL){ + CHAR_talkToCli( charaindex, -1, "Աȼ޷ʹôװ", CHAR_COLORYELLOW ); + return; + } + }else if(myviptype==2){ + if(strstr(ITEM_getChar(itemindex,ITEM_NAME),"[VIP3]")!=NULL){ + CHAR_talkToCli( charaindex, -1, "Աȼ޷ʹôװ", CHAR_COLORYELLOW ); + return; + } + } + if( CHAR_getFlg( charaindex, CHAR_ISDIE ) ){ + print( "ANDY charaindex=%d is CHAR_ISDIE err\n", charaindex); + return; + } +#ifdef _STREET_VENDOR + // ̯вʹõ + if(CHAR_getWorkInt(charaindex,CHAR_WORKSTREETVENDOR) > -1){ + print("StreetVendor use item charaindex=%d,name=%s\n",charaindex,CHAR_getChar(charaindex,CHAR_NAME)); + return; + } +#endif + if( CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE) == BATTLE_CHARMODE_NONE ) { + if( CHAR_getInt( to_charaindex, CHAR_WHICHTYPE) == CHAR_TYPEPLAYER) { + int action = ITEM_getInt( itemindex, ITEM_USEACTION); + if( action != -1 ) { + CHAR_sendAction( to_charaindex, action, TRUE); + } + } + } + // + if( ITEM_getInt( itemindex,ITEM_TYPE) != ITEM_OTHER && + ITEM_getInt( itemindex,ITEM_TYPE) != ITEM_DISH ) { + CHAR_EquipPlace ep; + + ep = ITEM_getEquipPlace( charaindex, itemindex ); + if( ep == -1 )return; + if( ep == CHAR_DECORATION1 ) { + int flg = FALSE; + int toitemindex1 = CHAR_getItemIndex( charaindex, ep); + int toitemindex2 = CHAR_getItemIndex( charaindex, CHAR_DECORATION2); + int searchindex = -1; + int fromitemtype = ITEM_getInt( itemindex, ITEM_TYPE); + + if( !ITEM_CHECKINDEX( toitemindex1)) searchindex = toitemindex2; + else if(!ITEM_CHECKINDEX( toitemindex2)) searchindex = toitemindex1; + if( searchindex != -1 ) { + if( fromitemtype != ITEM_getInt( searchindex, ITEM_TYPE)) { + flg = TRUE; + ep = ( searchindex == toitemindex1) + ? CHAR_DECORATION2:CHAR_DECORATION1; + } + } + if( !flg) { + if( fromitemtype != ITEM_getInt( toitemindex2, ITEM_TYPE)) { + ep = CHAR_DECORATION1; + }else if( fromitemtype != ITEM_getInt( toitemindex1, ITEM_TYPE)) { + ep = CHAR_DECORATION2; + }else { + ep = CHAR_DECORATION1; + } + } + } + CHAR_moveEquipItem( charaindex, haveitemindex,ep ); + return; + } + + usefunc = (void(*)(int,int,int))ITEM_getFunctionPointer( itemindex,ITEM_USEFUNC ); + if( usefunc ){ + { + LogItem( + CHAR_getChar( charaindex, CHAR_NAME ), /* ƽҷ’o */ + CHAR_getChar( charaindex, CHAR_CDKEY ), +#ifdef _add_item_log_name // WON ADD itemlogitem + itemindex, +#else + ITEM_getInt( itemindex, ITEM_ID ), /* ʧ̷ة?į */ +#endif + "Use(ʹõ)", + CHAR_getInt( charaindex,CHAR_FLOOR), + CHAR_getInt( charaindex,CHAR_X ), + CHAR_getInt( charaindex,CHAR_Y ), + ITEM_getChar( itemindex, ITEM_UNIQUECODE), + ITEM_getChar( itemindex, ITEM_NAME), + ITEM_getInt( itemindex, ITEM_ID) + ); + } + usefunc(charaindex, to_charaindex, haveitemindex); + }else{ +#ifdef _ALLBLUES_LUA_1_2 + if(RunItemUseEvent(itemindex, charaindex, to_charaindex, haveitemindex) == FALSE ) +#endif +{ + char ansmsg[256]; + strcpysafe( ansmsg, sizeof(ansmsg), + "ʲҲûз"); + CHAR_talkToCli( charaindex, -1, ansmsg, CHAR_COLORWHITE ); + } + } +} + +BOOL CHAR_DropItemFXY( int charaindex, int itemcharaindex, int fl, + int x, int y, int* objindex ) +{ + int itemindex; + itemindex = CHAR_getItemIndex(charaindex,itemcharaindex); + if( ITEM_CHECKINDEX(itemindex) == FALSE )return -3; + if( MAP_walkAbleFromPoint( fl,x,y, FALSE ) == FALSE ){ + return -2; + } + + { + OBJECT object; + for( object=MAP_getTopObj(fl,x,y) ; object; object = NEXT_OBJECT(object ) ){ + int objindex = GET_OBJINDEX(object); + switch( OBJECT_getType(objindex) ){ + case OBJTYPE_NOUSE: + break; + case OBJTYPE_ITEM: +#ifdef _DROPSTAKENEW + if(ITEM_getInt(itemindex, ITEM_ID) == CASINOTOKENID) + { + int i = 0; + int dropflag = 0; + ITEM_Item *itm; + for(i = 0; i < arraysizeof(casinomap); i++){ + if(CHAR_getInt(charaindex, CHAR_FLOOR) == casinomap[i].casinofl){ + if(x == casinomap[i].casinox && y == casinomap[i].casinoy){ + dropflag = 1; + break; + } + } + } + if(dropflag == 1){ + if( (itm = ITEM_getItemPointer( itemindex)) == NULL ) return -1; + strcpysafe( itm->string[ITEM_WATCHFUNC].string, + sizeof(itm->string[ITEM_WATCHFUNC].string), "ITEM_DeleteTimeWatched" ); + + break; + }else{ + + return -1; + } + } +#endif + case OBJTYPE_GOLD: + { + + return -1; + } + case OBJTYPE_CHARA: + { + typedef BOOL (*ITEMPUTFUNC)(int,int); + ITEMPUTFUNC ipfunc; + ipfunc = (ITEMPUTFUNC)CHAR_getFunctionPointer( + OBJECT_getIndex(objindex),CHAR_ITEMPUTFUNC) ; + + if( ipfunc && ipfunc(OBJECT_getIndex(objindex), + itemindex) == TRUE) + return -3; + break; + } + default: + break; + } + } + + *objindex = CHAR_DropItemAbsolute( itemindex,fl,x,y, FALSE ); + + if( *objindex == -1 ) + return -3; + { + char tmpbuf[256]; + sprintf(tmpbuf," %s (ʧʱ%d)",ITEM_getChar( itemindex, ITEM_NAME),getItemdeletetime()); + CHAR_talkToCli( charaindex, -1, tmpbuf, CHAR_COLORYELLOW ); + LogItem( + CHAR_getChar( charaindex, CHAR_NAME ), /* ƽҷ */ + CHAR_getChar( charaindex, CHAR_CDKEY ), +#ifdef _add_item_log_name // WON ADD itemlogitem + itemindex, +#else + ITEM_getInt( itemindex, ITEM_ID ), /* ʧ ة į */ +#endif + "Drop()", + CHAR_getInt( charaindex,CHAR_FLOOR), + CHAR_getInt( charaindex,CHAR_X ), + CHAR_getInt( charaindex,CHAR_Y ), + ITEM_getChar( itemindex, ITEM_UNIQUECODE), + ITEM_getChar( itemindex, ITEM_NAME), + ITEM_getInt( itemindex, ITEM_ID) + + ); + } + return 0; + } +} + + +#ifdef _ITEM_PILENUMS //andy_edit 2003/04/01 + +void CHAR_SendDropItem_Stats( int charaindex, int itemindex, int itemcharaindex, int flg) +{ + if( flg == 1 ){ + CHAR_setItemIndex( charaindex, itemcharaindex , -1); + } + CHAR_sendItemDataOne( charaindex, itemcharaindex); + + if( CHAR_complianceParameter( charaindex ) ){ + CHAR_sendCToArroundCharacter( CHAR_getWorkInt( charaindex, CHAR_WORKOBJINDEX)); + } + + if( 0 <= itemcharaindex && itemcharaindex < CHAR_STARTITEMARRAY && + CHAR_getInt( charaindex, CHAR_WHICHTYPE) == CHAR_TYPEPLAYER ){ //Ϊװ + if( ITEM_CHECKINDEX( itemindex) ) + CHAR_sendItemDetachEvent( charaindex, itemindex ); + + CHAR_send_P_StatusString( charaindex, + CHAR_P_STRING_HP|CHAR_P_STRING_MAXHP| + CHAR_P_STRING_MP|CHAR_P_STRING_MAXMP| + CHAR_P_STRING_ATK|CHAR_P_STRING_DEF| + CHAR_P_STRING_QUICK|CHAR_P_STRING_CHARM| + CHAR_P_STRING_LUCK|CHAR_P_STRING_EARTH| + CHAR_P_STRING_WATER|CHAR_P_STRING_FIRE| + CHAR_P_STRING_WIND ); + } +} +#ifdef _DROPSTAKENEW +void CHAR_DropStakeByDropItem( int charaindex, int itemcharaindex, int itemindex, int fl, int x, int y) +{ + int j, k, casinoflag = 0, dropflag; + char tmpbuf[256]; + dropflag = CHAR_getWorkInt( charaindex, CHAR_WORKSTAKEFLAG); + if( dropflag >= MAXSTAKENUM){ + snprintf( tmpbuf, sizeof( tmpbuf), "Ѿעˣ޷ע"); + CHAR_talkToCli(charaindex, -1, tmpbuf, CHAR_COLORYELLOW); + return; + } + for (j = 0; j < arraysizeof( casinomap); j++){ + if( CHAR_getInt( charaindex, CHAR_FLOOR) != casinomap[j].casinofl ) continue; + if( x != casinomap[j].casinox || y != casinomap[j].casinoy ) continue; + if( casinomap[j].dropflag == 0 ){ + CHAR_talkToCli( charaindex, -1, "޷ע", CHAR_COLORYELLOW); + return; + }else{ + int objindex; + objindex = CHAR_DropItemAbsolute( itemindex, fl, x, y, FALSE ); + if( objindex == -1 ) return; + ITEM_setInt( itemindex, ITEM_PUTTIME, NowTime.tv_sec+30*60); + CHAR_sendWatchEvent( objindex, CHAR_ACTSTAND, NULL, 0, TRUE); + casinoflag = 1; + snprintf(tmpbuf, sizeof(tmpbuf), " %s עһŲȯ", casinomap[j].casinoinfo); + for(k = 0; k < MAXSTAKENUM; k++){//ע趨 + if(CHAR_getWorkInt(charaindex, CHAR_WORKSTAKETYPE1 + k) != 0) continue; + CHAR_setWorkInt(charaindex, CHAR_WORKSTAKETYPE1 + k, casinomap[j].casinotype); + dropflag++; + break; + } + CHAR_talkToCli(charaindex, -1, tmpbuf, CHAR_COLORYELLOW); +#ifdef _FIX_GAMBLENUM + if (dropflag <= MAXSTAKENUM){ //۵Ķ + int nAcc = CHAR_getInt(charaindex, CHAR_GAMBLENUM); + nAcc -= casinomap[j].accumulation; + CHAR_setInt(charaindex, CHAR_GAMBLENUM, nAcc); + } +#endif + dropflag = ( dropflag >= MAXSTAKENUM )?MAXSTAKENUM:dropflag; + CHAR_setWorkInt(charaindex, CHAR_WORKSTAKEFLAG, dropflag); + break; + } + } + + if( casinoflag == 0) return; + LogItem(CHAR_getChar(charaindex, CHAR_NAME), + CHAR_getChar(charaindex, CHAR_CDKEY), +#ifdef _add_item_log_name // WON ADD itemlogitem + itemindex, +#else + ITEM_getInt(itemindex, ITEM_ID), +#endif + "StakeDrop(ȯ)", + CHAR_getInt(charaindex,CHAR_FLOOR), + CHAR_getInt(charaindex,CHAR_X), + CHAR_getInt(charaindex,CHAR_Y), + ITEM_getChar(itemindex, ITEM_UNIQUECODE), + ITEM_getChar( itemindex, ITEM_NAME), + ITEM_getInt( itemindex, ITEM_ID) + ); + CHAR_SendDropItem_Stats( charaindex, itemindex, itemcharaindex, 1); + +} +#endif + +BOOL CHAR_FindAroundUsabilitySpace( int charaindex, int itemindex, int *fl, int *x, int *y) +{ + int dropx, dropy, i; + BOOL Find = FALSE; + int myfl = CHAR_getInt( charaindex, CHAR_FLOOR); + + for( i = 0 ; i < 8 ; i ++ ){ + OBJECT object; + Find = FALSE; + dropx = CHAR_getInt( charaindex, CHAR_X) + CHAR_getDX( CHAR_getInt( charaindex, CHAR_DIR) + i); + dropy = CHAR_getInt( charaindex, CHAR_Y) + CHAR_getDY( CHAR_getInt( charaindex, CHAR_DIR) + i); + if( MAP_walkAbleFromPoint( myfl, dropx, dropy, FALSE ) == FALSE ) continue; + for( object = MAP_getTopObj( myfl, dropx, dropy) ; object ; object = NEXT_OBJECT(object ) ){ + int objindex = GET_OBJINDEX(object); + if( !CHECKOBJECTUSE( objindex)) continue; + if( OBJECT_getType( objindex) == OBJTYPE_CHARA ){ + typedef BOOL (*ITEMPUTFUNC)(int,int); + ITEMPUTFUNC ipfunc; + ipfunc = (ITEMPUTFUNC)CHAR_getFunctionPointer( OBJECT_getIndex(objindex),CHAR_ITEMPUTFUNC) ; + if( ipfunc && ipfunc( OBJECT_getIndex( objindex), itemindex) == TRUE) + return FALSE; + }else{ + Find = TRUE; + break; + } + } + if( Find == FALSE ){ + *fl = myfl; + *x = dropx; + *y = dropy; + return TRUE; + } + } + return FALSE; +} + +void CHAR_DropItem( int charaindex, int itemcharaindex ) +{ + if( CHAR_getWorkInt( charaindex, CHAR_WORKSAFEMODE)==0) + { + CHAR_SafePassword(charaindex); + return; + } + int itemindex, fl, x, y, ret, objindex, beDropOne = 1; + + if( !CHAR_CHECKINDEX( charaindex ) ) return; + int fd = getfdFromCharaIndex( charaindex); + if( fd == - 1 ) return; + if( CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE ) != BATTLE_CHARMODE_NONE ){ + CHAR_talkToCli( charaindex, -1, "ս״̬޷װ", CHAR_COLORYELLOW ); + return; + } +#ifdef _AVID_TRADETRYBUG //װ + if( CHAR_getWorkInt(charaindex, CHAR_WORKTRADEMODE) != CHAR_TRADE_FREE){ + CHAR_talkToCli( charaindex, -1, "״̬޷װ", CHAR_COLORYELLOW ); + return; + } +#endif + + itemindex = CHAR_getItemIndex( charaindex, itemcharaindex); + if( !ITEM_CHECKINDEX( itemindex)) return; +#ifdef _LOCK_PET_ITEM + char *arg = ITEM_getChar(itemindex, ITEM_NAME); + if(arg[0] == '*'){ + CHAR_talkToCli( charaindex, -1, "󶨵Ʒܶ", CHAR_COLORYELLOW ); + return; + } +#endif +#ifdef _NO_DROPITEM + if( strstr(ITEM_getChar(itemindex,ITEM_EFFECTSTRING),"")){ + if(CHAR_getWorkInt(charaindex,CHAR_DROPITEMCHARAINDEX)!=itemcharaindex){ + char dropmsg[256]; + sprintf(dropmsg,"\n%sΪƷ\n\nֱʧ\n\nȷҪôȷ밴[OK]\n",ITEM_getChar(itemindex,ITEM_NAME)); + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OKCANCEL, + CHAR_WINDOWTYPE_DROPITEM, + -1, + dropmsg); + CHAR_setWorkInt(charaindex,CHAR_DROPITEMCHARAINDEX,itemcharaindex); + return; + }else{ + CHAR_setWorkInt(charaindex,CHAR_DROPITEMCHARAINDEX,-1); + } + } +#endif + if(ITEM_getInt(itemindex,ITEM_TIME)>0){ + if(CHAR_getWorkInt(charaindex,CHAR_DROPITEMCHARAINDEX)!=itemcharaindex){ + char dropmsg[256]; + sprintf(dropmsg,"\n%sΪʱƷ\n\nֱʧ\n\nȷҪôȷ밴[OK]\n",ITEM_getChar(itemindex,ITEM_NAME)); + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OKCANCEL, + CHAR_WINDOWTYPE_DROPITEM, + -1, + dropmsg); + CHAR_setWorkInt(charaindex,CHAR_DROPITEMCHARAINDEX,itemcharaindex); + return; + }else{ + CHAR_setWorkInt(charaindex,CHAR_DROPITEMCHARAINDEX,-1); + } + } + if( ITEM_getInt( itemindex, ITEM_ID) == CASINOTOKENID && + ( CHAR_getInt( charaindex, CHAR_FLOOR ) == 7008 || + CHAR_getInt( charaindex, CHAR_FLOOR ) == 7005 || + CHAR_getInt( charaindex, CHAR_FLOOR ) == 7003 ) ){ + + int dropx, dropy, dropfl; + dropfl = CHAR_getInt( charaindex, CHAR_FLOOR); + dropx = CHAR_getInt( charaindex, CHAR_X) + CHAR_getDX( CHAR_getInt( charaindex, CHAR_DIR)); + dropy = CHAR_getInt( charaindex, CHAR_Y) + CHAR_getDY( CHAR_getInt( charaindex, CHAR_DIR)); + CHAR_DropStakeByDropItem( charaindex, itemcharaindex, itemindex, dropfl, dropx, dropy); + return; + } +#ifdef _PETITEM__AMOI_E + //print ("\n%d,%d,%d\n",ITEM_NOT_DROP,ITEM_getInt(itemindex, ITEM_TYPEOFITEM),ITEM_NOT_DROP & ITEM_getInt(itemindex, ITEM_TYPEOFITEM)); + if(ITEM_NOT_DROP & ITEM_getInt(itemindex, ITEM_TYPEOFITEM)){ + char buf[256]; + sprintf( buf, "%s޷", ITEM_getChar( itemindex, ITEM_NAME) ); + CHAR_talkToCli( charaindex, -1, buf, CHAR_COLORRED); + return ; + } +#endif + //ҳΧռ + if( CHAR_FindAroundUsabilitySpace( charaindex, itemindex, &fl, &x, &y) == FALSE ){ + CHAR_talkToCli( charaindex, -1, "ΧĵѾˡ", CHAR_COLORYELLOW ); + return; + } + +#ifdef _ITEM_PILENUMS + if( ITEM_getInt( itemindex, ITEM_CANBEPILE) == 1 && + ITEM_getInt( itemindex, ITEM_USEPILENUMS) > 1 ){ + int ret; + int nums = ITEM_getInt( itemindex, ITEM_USEPILENUMS); + ret = ITEM_makeItemAndRegist( ITEM_getInt( itemindex, ITEM_ID) ); + if( !ITEM_CHECKINDEX( ret)) return; + ITEM_setInt( itemindex, ITEM_USEPILENUMS, nums -1 ); + itemindex = ret; + beDropOne = 0; + } +#endif + //ҵռ + ret = ITEM_eventDrop( itemindex, charaindex, itemcharaindex ); + if( ret == 1 || ITEM_getInt(itemindex,ITEM_TIME)>0){ //-1 Ʒ 1 ʧ 0 һƷ + CHAR_SendDropItem_Stats( charaindex, itemindex, itemcharaindex, beDropOne); + return; + }else { + objindex = CHAR_DropItemAbsolute( itemindex, fl, x, y, FALSE ); + if( objindex == -1 ) return; + ITEM_setInt( itemindex, ITEM_PUTTIME, NowTime.tv_sec); +#ifdef _PICKUP_ITEM_OTHER + if(getPickupItem()==1){ + ITEM_setChar(itemindex,ITEM_FROMCDKEY,CHAR_getChar( charaindex, CHAR_CDKEY )); + } +#endif + { + char tmpbuf[256]; + sprintf(tmpbuf," %s (ʧʱ%d)",ITEM_getChar( itemindex, ITEM_NAME),getItemdeletetime()); + CHAR_talkToCli( charaindex, -1, tmpbuf, CHAR_COLORYELLOW ); + LogItem( + CHAR_getChar( charaindex, CHAR_NAME ), /* ƽҷ */ + CHAR_getChar( charaindex, CHAR_CDKEY ), +#ifdef _add_item_log_name // WON ADD itemlogitem + itemindex, +#else + ITEM_getInt( itemindex, ITEM_ID ), /* ʧ ة į */ +#endif + "Drop()", + CHAR_getInt( charaindex,CHAR_FLOOR), + CHAR_getInt( charaindex,CHAR_X ), + CHAR_getInt( charaindex,CHAR_Y ), + ITEM_getChar( itemindex, ITEM_UNIQUECODE), + ITEM_getChar( itemindex, ITEM_NAME), + ITEM_getInt( itemindex, ITEM_ID) + ); + } + CHAR_sendWatchEvent( objindex, CHAR_ACTSTAND, NULL, 0, TRUE); + } + CHAR_SendDropItem_Stats( charaindex, itemindex, itemcharaindex, beDropOne); +} +#else +void CHAR_DropItem( int charaindex, int itemcharaindex ) +{ + int dirx[9],diry[9]; + int i, j; + int floor, objindex=-1; + int droped =0; + int count_item =0, count_chara =0; + int fl, x, y; + int itemindex = CHAR_getItemIndex(charaindex,itemcharaindex); + + if( !CHAR_CHECKINDEX( charaindex ) ) return; + if( !ITEM_CHECKINDEX( itemindex) ) return; +#ifdef _AVID_TRADETRYBUG //װ + if( CHAR_getWorkInt(charaindex, CHAR_WORKTRADEMODE) != CHAR_TRADE_FREE){ + CHAR_talkToCli( charaindex, -1, "״̬޷װ", CHAR_COLORYELLOW ); + return; + } +#endif + +#ifdef _DROPCHECK2 + fl = CHAR_getInt( charaindex, CHAR_FLOOR); + x = CHAR_getInt( charaindex, CHAR_X); + y = CHAR_getInt( charaindex, CHAR_Y); + + for( i = x-CHAR_DEFAULTSEESIZ/2 ; i <= x+CHAR_DEFAULTSEESIZ/2 ; i++ ){ + for( j = y-CHAR_DEFAULTSEESIZ/2 ; j <= y+CHAR_DEFAULTSEESIZ/2 ; j ++ ){ + OBJECT object; + for( object = MAP_getTopObj(fl,i,j); object ; object = NEXT_OBJECT(object ) ) { + int objindex = GET_OBJINDEX(object); + if( OBJECT_getType(objindex) == OBJTYPE_NOUSE ) continue; + if( OBJECT_getType(objindex) == OBJTYPE_ITEM || OBJECT_getType(objindex) == OBJTYPE_GOLD ) { + count_item++; + } + if( OBJECT_getType(objindex) == OBJTYPE_CHARA ) { + count_chara++; + } + } + } + +#ifdef _DROPSTAKENEW + if(ITEM_getInt(itemindex, ITEM_ID) == CASINOTOKENID){ + int k = 0; + int casinodropflag = 0; + for(k = 0; k < arraysizeof(casinomap); k++){ + if(fl == casinomap[k].casinofl){ + if(x >= casinomap[k].casinox - 1 && x <= casinomap[k].casinox + 1){ + if(y >= casinomap[k].casinoy - 1 && y <= casinomap[k].casinoy + 1){ + casinodropflag = 1; + break; + } + } + } + } + if(casinodropflag == 0){ +#endif + if( count_item > 80 || count_chara > 80 ) { + CHAR_talkToCli( charaindex, -1, "ƷѾ̫ˣٶˡ", CHAR_COLORYELLOW ); + return; + } +#ifdef _DROPSTAKENEW + } + } +#endif + } +#endif + + for( i = 1 ; i < 8 ; i ++ ){ + dirx[i] = CHAR_getDX(CHAR_getInt(charaindex,CHAR_DIR) + i); + diry[i] = CHAR_getDY(CHAR_getInt(charaindex,CHAR_DIR) + i); + } + dirx[0] = CHAR_getDX(CHAR_getInt(charaindex,CHAR_DIR)); + diry[0] = CHAR_getDY(CHAR_getInt(charaindex,CHAR_DIR)); + dirx[8] = 0; + diry[8] = 0; + floor = CHAR_getInt( charaindex,CHAR_FLOOR ); + { + int ret; + if( 0 <= itemcharaindex && itemcharaindex < CHAR_STARTITEMARRAY ){ //Ϊװ + CHAR_sendItemDetachEvent( charaindex, itemindex ); + } + ret = ITEM_eventDrop( itemindex, charaindex, itemcharaindex ); + if( ret == 1 ){ //-1 Ʒ 1 ʧ 0 һƷ + itemindex = -1; + goto END; + }else if( ret == -1 ){ + print( "%s:%d err\n", __FILE__,__LINE__); + return; + }else{ + ; + } + } + + droped = 0; + for( i = 0 ; i < 9 ; i ++ ){ + int x=CHAR_getInt(charaindex,CHAR_X)+dirx[i]; + int y=CHAR_getInt(charaindex,CHAR_Y)+diry[i]; +#ifdef _DROPSTAKENEW + // жƷǷΪȯ + if(ITEM_getInt(itemindex, ITEM_ID) == CASINOTOKENID){ + int j = 0, k = 0; + int bdropstake = 0; + int casinoflag = 0; + for (j = 0; j < arraysizeof(casinomap); j++){ + if (CHAR_getInt(charaindex, CHAR_FLOOR) == casinomap[j].casinofl){ + if (x == casinomap[j].casinox && y == casinomap[j].casinoy){ + char tmpbuf[256]; + int dropflag = CHAR_getWorkInt(charaindex, CHAR_WORKSTAKEFLAG); + casinoflag = 1; + if(casinomap[j].dropflag == 0){ + CHAR_talkToCli(charaindex, -1, "޷ע", CHAR_COLORYELLOW); + return; + }else{ + snprintf(tmpbuf, sizeof(tmpbuf), " %s עһŲȯ", casinomap[j].casinoinfo); + if(dropflag >= MAXSTAKENUM){ + snprintf(tmpbuf, sizeof(tmpbuf), "Ѿעˣ޷ע"); + CHAR_talkToCli(charaindex, -1, tmpbuf, CHAR_COLORYELLOW); + return; + } + for(k = 0; k < MAXSTAKENUM; k++){ + if(CHAR_getWorkInt(charaindex, CHAR_WORKSTAKETYPE1 + k) == 0){ + CHAR_setWorkInt(charaindex, CHAR_WORKSTAKETYPE1 + k, casinomap[j].casinotype); + casinomap[j].stakenum = casinomap[j].stakenum + 1; + if(casinomap[j].stakenum >= 100000000) + casinomap[j].stakenum = 100000000; + dropflag++; + if(casinomap[j].stakenum <= 1) + bdropstake = 1; + break; + } + } + } + CHAR_talkToCli(charaindex, -1, tmpbuf, CHAR_COLORYELLOW); +#ifdef _FIX_GAMBLENUM + //۵Ķ + if (dropflag <= MAXSTAKENUM){ + int nAcc = CHAR_getInt(charaindex, CHAR_GAMBLENUM); + nAcc -= casinomap[j].accumulation; + CHAR_setInt(charaindex, CHAR_GAMBLENUM, nAcc); + } +#endif + if (dropflag >= MAXSTAKENUM){ + dropflag = 0; + for (k = 0; k < MAXSTAKENUM ; k++){ + if (CHAR_getWorkInt(charaindex, CHAR_WORKSTAKETYPE1 + k) > 0) + dropflag++; + } + CHAR_setWorkInt(charaindex, CHAR_WORKSTAKEFLAG, dropflag); + }else{ + CHAR_setWorkInt(charaindex, CHAR_WORKSTAKEFLAG, dropflag); + } + continue; + } + } + } + + // ˵طIJȯһ + if(bdropstake == 0 && casinoflag != 0){ + CHAR_setItemIndex(charaindex, itemcharaindex ,-1); + CHAR_sendItemDataOne(charaindex, itemcharaindex); + LogItem(CHAR_getChar(charaindex, CHAR_NAME), + CHAR_getChar(charaindex, CHAR_CDKEY), +#ifdef _add_item_log_name // WON ADD itemlogitem + itemindex, +#else + ITEM_getInt(itemindex, ITEM_ID), +#endif + "StakeDrop(ȯ)", + CHAR_getInt(charaindex,CHAR_FLOOR), + CHAR_getInt(charaindex,CHAR_X), + CHAR_getInt(charaindex,CHAR_Y), + ITEM_getChar(itemindex, ITEM_UNIQUECODE), + ITEM_getChar( itemindex, ITEM_NAME), + ITEM_getInt( itemindex, ITEM_ID) + + ); + return; + } + } +#endif + { + int ret = CHAR_DropItemFXY( charaindex,itemcharaindex, + CHAR_getInt(charaindex,CHAR_FLOOR), x, y, &objindex ); + switch( ret ){ + case 0: + droped = 1; +#ifdef _ITEM_ORNAMENTS // WON FIX + if( ITEM_getWorkInt( itemindex, ITEM_CANPICKUP) > 0 ){ + ITEM_setInt( itemindex, ITEM_PUTTIME, NowTime.tv_sec + 60*5); + }else{ + ITEM_setInt( itemindex, ITEM_PUTTIME, NowTime.tv_sec); + } +#else + ITEM_setInt( itemindex, ITEM_PUTTIME, NowTime.tv_sec); +#endif + goto END; + break; + case -1: + case -2: + break; + case -3: + default: + return; + break; + } +#ifdef _DROPSTAKENEW + } +#endif + } +#ifdef _DROPCHECK + if( droped != 1 ) { + CHAR_talkToCli( charaindex, -1, "ΧĵѾˡ", CHAR_COLORYELLOW ); + return; + } +#endif +END: + CHAR_sendWatchEvent( objindex, CHAR_ACTSTAND, NULL, 0, TRUE); + CHAR_setItemIndex( charaindex, itemcharaindex ,-1); +{ + char category[3]; + snprintf( category,sizeof( category),"J%d", itemcharaindex); + CHAR_sendStatusString( charaindex , category); +} + if( CHAR_complianceParameter( charaindex ) ){ + CHAR_sendCToArroundCharacter( CHAR_getWorkInt( charaindex, CHAR_WORKOBJINDEX) ); + } + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE) == CHAR_TYPEPLAYER) { + CHAR_send_P_StatusString( charaindex, + CHAR_P_STRING_HP|CHAR_P_STRING_MAXHP| + CHAR_P_STRING_MP|CHAR_P_STRING_MAXMP| + CHAR_P_STRING_ATK|CHAR_P_STRING_DEF| + CHAR_P_STRING_QUICK|CHAR_P_STRING_CHARM| + CHAR_P_STRING_LUCK|CHAR_P_STRING_EARTH| + CHAR_P_STRING_WATER|CHAR_P_STRING_FIRE| + CHAR_P_STRING_WIND + ); + CHAR_sendItemDataOne( charaindex, itemcharaindex); + } + return; +} +#endif + +int CHAR_DropItemAbsolute( int itemindex, int floor, int x, int y, + BOOL net) +{ + Object object; + int objindex; + + if( !ITEM_CHECKINDEX( itemindex) )return FALSE; + + object.type = OBJTYPE_ITEM; + object.index = itemindex; + object.x = x; + object.y = y; + object.floor = floor; + objindex = initObjectOne( &object ); + ITEM_setWorkInt( itemindex,ITEM_WORKOBJINDEX, objindex ); + ITEM_setWorkInt( itemindex,ITEM_WORKCHARAINDEX, -1 ); + if( net ) + CHAR_sendWatchEvent( objindex,CHAR_ACTSTAND,NULL,0,TRUE); + + return objindex; +} + +int CHAR_addItemSpecificItemIndex( int charaindex, int itemindex ) +{ + int emptyindex; + if( CHAR_CHECKINDEX( charaindex) == FALSE) return -1; + if( ITEM_CHECKINDEX( itemindex) == FALSE) return -1; + emptyindex = CHAR_findEmptyItemBox( charaindex ); + if( emptyindex == -1 ){ + return CHAR_MAXITEMHAVE; + }else{ + CHAR_setItemIndex( charaindex, emptyindex, itemindex ); + ITEM_setWorkInt(itemindex, ITEM_WORKOBJINDEX,-1); + ITEM_setWorkInt(itemindex, ITEM_WORKCHARAINDEX,charaindex); + CHAR_sendItemDataOne( charaindex, emptyindex); + } + return emptyindex; +} + +static int CHAR_PickUpItemFXY( int charaindex, int fl ,int x , int y , + int* contents,int* objindex ) +{ + OBJECT object; + + for( object=MAP_getTopObj(fl,x,y) ; object ; object = NEXT_OBJECT(object ) ){ + int index = GET_OBJINDEX(object); + int objtype = OBJECT_getType(index); + if( objtype == OBJTYPE_NOUSE )continue; + else if( objtype == OBJTYPE_ITEM ){ + int ret; + int itemindex = OBJECT_getIndex( index); +#ifdef _ITEM_ORNAMENTS + if( ITEM_getWorkInt( itemindex, ITEM_CANPICKUP) > 0 ){ + return -1; + } +#endif +#ifdef _DROPSTAKENEW + // жƷǷΪȯ + if(ITEM_getInt(itemindex, ITEM_ID) == CASINOTOKENID){ + int i = 0; + int bdropstake = 0, casinoflag = 0, emptyitemindexinchara = -1; + for(i = 0; i < arraysizeof(casinomap); i++){ + if(fl == casinomap[i].casinofl){ + if(x == casinomap[i].casinox && y == casinomap[i].casinoy){ + int j = 0, stakeflag = 0; + int pickupflag = 0; + casinoflag = 1; + if(casinomap[i].dropflag == 0){ + CHAR_talkToCli(charaindex, -1, "Ѿ޷ȡעȯˣ", CHAR_COLORYELLOW); + return -1; + } + stakeflag = CHAR_getWorkInt(charaindex, CHAR_WORKSTAKEFLAG); + if(stakeflag == 0){ + CHAR_talkToCli(charaindex, -1, "ûע޷ȡزȯ", CHAR_COLORYELLOW); + return -1; + } + for(j = 0; j < MAXSTAKENUM; j++){ + if(CHAR_getWorkInt(charaindex, CHAR_WORKSTAKETYPE1 + j) == casinomap[i].casinotype){ + emptyitemindexinchara = CHAR_findEmptyItemBox(charaindex); + if(emptyitemindexinchara < 0) return -2; + CHAR_setWorkInt(charaindex, CHAR_WORKSTAKETYPE1 + j, 0); + casinomap[i].stakenum = casinomap[i].stakenum - 1; + stakeflag--; + pickupflag = 1; +#ifdef _FIX_GAMBLENUM + //ӵĶ + { + int nAcc = CHAR_getInt(charaindex, CHAR_GAMBLENUM); + nAcc += casinomap[i].accumulation; + CHAR_setInt(charaindex, CHAR_GAMBLENUM, nAcc); + } +#endif + if(casinomap[i].stakenum <= 0){ + bdropstake = 1; + casinomap[i].stakenum = 0; + } + break; + } + } + if(stakeflag < 0){ + stakeflag = 0; + for(j = 0; j < MAXSTAKENUM; j++){ + if(CHAR_getWorkInt(charaindex, CHAR_WORKSTAKETYPE1 + j) > 0) + stakeflag++; + } + CHAR_setWorkInt(charaindex, CHAR_WORKSTAKEFLAG, stakeflag); + }else + CHAR_setWorkInt(charaindex, CHAR_WORKSTAKEFLAG, stakeflag); + if(pickupflag == 0){ + CHAR_talkToCli(charaindex, -1, "ûڴע޷ȡزȯ", CHAR_COLORYELLOW); + return -1; + } + } + } + } + + if(bdropstake == 0 && casinoflag != 0){// ˵طIJȯһ + char tmpbuf[256]; + if(emptyitemindexinchara != -1){ + int itemid=-1, ret=-1; + itemid = ITEM_makeItemAndRegist(CASINOTOKENID); + if(itemid == -1) return -1; + ret = CHAR_addItemSpecificItemIndex( charaindex, itemid); + if( ret < 0 || ret >= CHAR_MAXITEMHAVE ) { + ITEM_endExistItemsOne( itemid ); + return -1; + } + } + CHAR_sendItemDataOne(charaindex, emptyitemindexinchara); + snprintf(tmpbuf, sizeof(tmpbuf), "ʰ%sѽעȡ", + ITEM_getChar(itemindex, ITEM_NAME)); + CHAR_talkToCli(charaindex, -1, tmpbuf, CHAR_COLORWHITE); + // ¼ؼ¼ + LogItem(CHAR_getChar(charaindex, CHAR_NAME), + CHAR_getChar(charaindex, CHAR_CDKEY), +#ifdef _add_item_log_name // WON ADD itemlogitem + itemindex, +#else + ITEM_getInt(itemindex, ITEM_ID), +#endif + "StakePickUp(ȯ)", + CHAR_getInt(charaindex,CHAR_FLOOR), + CHAR_getInt(charaindex,CHAR_X), + CHAR_getInt(charaindex,CHAR_Y), + ITEM_getChar(itemindex, ITEM_UNIQUECODE), + ITEM_getChar( itemindex, ITEM_NAME), + ITEM_getInt( itemindex, ITEM_ID) + ); + return -1; + } + } +#endif +#ifdef _PICKUP_ITEM_OTHER + if(getPickupItem()==1){ + char pickupchar[16]; + sprintf(pickupchar,",%d,",ITEM_getInt(itemindex,ITEM_ID)); + if(ITEM_getChar(itemindex,ITEM_FROMCDKEY)!=NULL && strstr(getPickItemId(),pickupchar)==NULL){ + if(strcmp(CHAR_getChar(charaindex,CHAR_CDKEY),ITEM_getChar(itemindex,ITEM_FROMCDKEY))!=0){ + CHAR_talkToCli(charaindex, -1, "˵߲У޷ʰȡ", CHAR_COLORWHITE); + return -1; + } + } + } +#endif + ret = CHAR_addItemSpecificItemIndex( charaindex, itemindex ); + if(ret == CHAR_MAXITEMHAVE ){ + return -2; + }else if( ret != -1 ) { + typedef void (*PICKUPFUNC)( int, int); + PICKUPFUNC pickupfunc = NULL; + pickupfunc = (PICKUPFUNC)ITEM_getFunctionPointer( + itemindex, ITEM_PICKUPFUNC); + if( pickupfunc){ + pickupfunc( charaindex, itemindex); + } +#ifdef _ALLBLUES_LUA_1_2 + else{ + RunItemPickupEvent(charaindex, itemindex ); + } +#endif + *contents = OBJECT_getIndex(index); + *objindex = index; +// CHAR_sendItemDataOne( charaindex, ret); + return 0; + } + }else if( objtype == OBJTYPE_GOLD ){ + int MaxGold; + long dropgoldamount = 0, newamountgold = 0, Minus = 0, newgold = 0; + long mygold = (long) CHAR_getInt( charaindex, CHAR_GOLD ); + MaxGold = CHAR_getMaxHaveGold( charaindex); + if ((mygold <0) || (mygold > MaxGold))return -2; + dropgoldamount = OBJECT_getIndex(index); + newamountgold = (unsigned int) CHAR_getInt( charaindex,CHAR_GOLD ) + dropgoldamount; + Minus = newamountgold - MaxGold; + if( Minus > 0 ) { + newgold = Minus; + *contents = dropgoldamount - Minus; + }else { + newgold = 0; + *contents = dropgoldamount; + } + OBJECT_setIndex( index, newgold); + CHAR_setInt( charaindex, CHAR_GOLD, min( newamountgold, MaxGold ) ); + *objindex = index; + return 1; + }else if( objtype == OBJTYPE_CHARA ) { + int pindex = OBJECT_getIndex( index); + if( !CHAR_CHECKINDEX( pindex) ) continue; + if( CHAR_getInt( pindex, CHAR_WHICHTYPE) == CHAR_TYPEPET ) { + int havepetindex = CHAR_getCharPetElement( charaindex); + if( havepetindex == -1 ) { + if( CHAR_getWorkInt( pindex, CHAR_WORKPETFOLLOWMODE) != CHAR_PETFOLLOW_NOW ) + return -3; + } + if( CHAR_getWorkInt( charaindex, CHAR_PickAllPet) != TRUE ) { + if( (CHAR_getInt( pindex, CHAR_LV) - CHAR_getInt( charaindex, CHAR_LV) > 5 ) + && (CHAR_getInt( charaindex, CHAR_TRANSMIGRATION ) <= 0 )) { + return -4; + } + } +#ifdef _PET_UP + if( getPetup() != 1 && CHAR_getInt(charaindex,CHAR_FLOOR)!=getPetup() ) +#endif + { + if( !strcmp( CHAR_getChar( pindex, CHAR_OWNERCDKEY), "SYSTEM_WAYI" ) && + !strcmp( CHAR_getChar( pindex, CHAR_OWNERCHARANAME), "SYSTEM_WAYI" ) ){ + }else{ + if( strcmp( CHAR_getChar( pindex, CHAR_OWNERCDKEY), CHAR_getChar( charaindex, CHAR_CDKEY) ) || + strcmp( CHAR_getChar( pindex, CHAR_OWNERCHARANAME), CHAR_getChar( charaindex, CHAR_NAME) )){ + return -5; + } + } + } + if( CHAR_getWorkInt( pindex, CHAR_WORKPETFOLLOWMODE) == CHAR_PETFOLLOW_NOW ){ + CHAR_pickupFollowPet( charaindex, pindex ); + return -1; + } + if( CHAR_getInt( pindex, CHAR_MAILMODE) != CHAR_PETMAIL_NONE){ + if( strcmp( CHAR_getChar( pindex, CHAR_OWNERCDKEY), + CHAR_getChar( charaindex, CHAR_CDKEY)) != 0 || + strcmp( CHAR_getChar( pindex, CHAR_OWNERCHARANAME), + CHAR_getChar( charaindex, CHAR_NAME))!= 0 ){ + return -5; + }else if( CHAR_getInt( pindex, CHAR_MAILMODE) != CHAR_PETMAIL_IDLE5){ + return -5; + } + } + if( CHAR_getInt( pindex, CHAR_MAILMODE) != CHAR_PETMAIL_NONE){ + Char *ch; + CHAR_setInt( pindex, CHAR_MAILMODE, CHAR_PETMAIL_NONE); + CHAR_setInt( pindex, CHAR_PETMAILIDLETIME, 0); + PETMAIL_delPetMailTotalnums( 1); //ֶmail PET + ch = CHAR_getCharPointer( pindex); + if( ch != NULL ) { + strcpysafe( ch->charfunctable[CHAR_LOOPFUNC].string, + sizeof( ch->charfunctable[CHAR_LOOPFUNC]), ""); + CHAR_constructFunctable( pindex); + } + } + CHAR_setWorkInt( pindex, CHAR_WORKPLAYERINDEX, charaindex); + CHAR_setCharPet( charaindex, havepetindex, pindex); +#ifndef _FIX_COPY_MM_BUG +#ifdef _PET_TALK + if( CHAR_getInt( pindex, CHAR_PETID) != 718 ) { +#endif +#endif + CHAR_setChar( pindex, CHAR_OWNERCDKEY, + CHAR_getChar( charaindex, CHAR_CDKEY)); + CHAR_setChar( pindex, CHAR_OWNERCHARANAME, + CHAR_getChar( charaindex, CHAR_NAME)); +#ifndef _FIX_COPY_MM_BUG +#ifdef _PET_TALK + } +#endif +#endif +#ifdef _PET_ITEM + CHAR_sendPetItemData( charaindex, havepetindex); +#endif + CHAR_complianceParameter( pindex); +{ + char category[3]; + snprintf( category,sizeof( category),"K%d",havepetindex); + CHAR_sendStatusString( charaindex, category); + snprintf( category,sizeof( category),"W%d",havepetindex); + CHAR_sendStatusString( charaindex, category); +} + CHAR_setInt( pindex, CHAR_PUTPETTIME, 0); + *contents = pindex; + *objindex = index; + return 2; + } + } + } + return -1; +} + +void CHAR_PickUpItem( int charaindex, int dir ) +{ + if(CHAR_getWorkInt(charaindex,CHAR_WORKSTREETVENDOR) > 0) + { + return; + } + int i; + int dirx[2],diry[2]; + int searchloopcount=0; + + if( !CHAR_CHECKINDEX(charaindex) )return; + if( CHAR_getFlg( charaindex,CHAR_ISDIE ) )return; + if( CHAR_getWorkInt( charaindex,CHAR_WORKBATTLEMODE ) )return; + if( dir < 0 ){ + searchloopcount = 1; + dirx[0] = 0; + diry[0] = 0; + }else{ + if( dir != CHAR_getInt( charaindex, CHAR_DIR)) { + VALIDATEDIR(dir); + CHAR_setInt(charaindex,CHAR_DIR,dir); + CHAR_sendWatchEvent(CHAR_getWorkInt(charaindex,CHAR_WORKOBJINDEX), + CHAR_ACTSTAND,NULL,0,FALSE); + } + dirx[0] = CHAR_getDX(CHAR_getInt(charaindex,CHAR_DIR)); + diry[0] = CHAR_getDY(CHAR_getInt(charaindex,CHAR_DIR)); + dirx[1] = 0; + diry[1] = 0; + searchloopcount=2; + } + for( i = 0 ; i < searchloopcount ; i ++ ){ + int contents,objindex; + int fl = CHAR_getInt(charaindex,CHAR_FLOOR); + + int y = CHAR_getInt(charaindex,CHAR_Y)+diry[i]; + int x = CHAR_getInt(charaindex,CHAR_X)+dirx[i]; + int ret = CHAR_PickUpItemFXY( charaindex,fl,x,y,&contents, &objindex); + switch( ret ){ + case 0: + CHAR_ObjectDelete(objindex); + { + char mesg[256]; +#ifdef _DROPSTAKENEW + int j = 0; + int dropflag = 0; + for(j = 0; j < arraysizeof(casinomap); j++) + { + if(CHAR_getInt(charaindex, CHAR_FLOOR) == casinomap[j].casinofl) + { + if(x == casinomap[j].casinox && y == casinomap[j].casinoy) + { + dropflag = 1; + break; + } + } + } + if(ITEM_getInt(contents, ITEM_ID) == CASINOTOKENID && dropflag == 1) + snprintf( mesg,sizeof(mesg), "ʰ%sѽעȡ", + ITEM_getAppropriateName(contents)); + else +#endif + snprintf( mesg,sizeof(mesg), "ʰ %s", + ITEM_getAppropriateName(contents) ); + CHAR_talkToCli(charaindex,-1,mesg,CHAR_COLORWHITE); + } + + { + LogItem( + CHAR_getChar( charaindex, CHAR_NAME ), + CHAR_getChar( charaindex, CHAR_CDKEY ), +#ifdef _add_item_log_name // WON ADD itemlogitem + contents, +#else + ITEM_getInt(contents, ITEM_ID), +#endif + "PickUp()", + CHAR_getInt( charaindex,CHAR_FLOOR), + CHAR_getInt( charaindex,CHAR_X ), + CHAR_getInt( charaindex,CHAR_Y ), + ITEM_getChar( contents, ITEM_UNIQUECODE), + ITEM_getChar( contents, ITEM_NAME), + ITEM_getInt( contents, ITEM_ID) + ); + } + + return; + break; + case 1: + CHAR_send_P_StatusString( charaindex, CHAR_P_STRING_GOLD); + + if( OBJECT_getIndex( objindex) == 0 ) { + CHAR_ObjectDelete(objindex); + }else { + CHAR_sendWatchEvent(objindex,CHAR_ACTSTAND,NULL,0,TRUE); + } + { + char mesg[256]; + if( contents == 0 ) { + snprintf( mesg,sizeof(mesg), "޷ʰStoneˡ" ); + }else { + snprintf( mesg,sizeof(mesg), "ʰ %d Stone",contents ); + } + CHAR_talkToCli(charaindex,-1,mesg,CHAR_COLORWHITE); + } + if( contents != 0 ){ + LogStone( + -1, + CHAR_getChar( charaindex, CHAR_NAME ), + CHAR_getChar( charaindex, CHAR_CDKEY ), + contents, + CHAR_getInt( charaindex, CHAR_GOLD ), + "PickUp(ʰǮ)", + CHAR_getInt( charaindex,CHAR_FLOOR), + CHAR_getInt( charaindex,CHAR_X ), + CHAR_getInt( charaindex,CHAR_Y ) + ); + } + return; + break; + case 2: // + CHAR_ObjectDelete(objindex); + CHAR_setWorkInt( contents, CHAR_WORKOBJINDEX, -1); + { + char mesg[256]; + char *p = NULL; + p = CHAR_getChar( contents, CHAR_USERPETNAME); + if( strlen( p) == 0 ) { + p = CHAR_getChar( contents, CHAR_NAME); + } + + snprintf( mesg,sizeof(mesg), "ʰ %s", p); + CHAR_talkToCli(charaindex,-1,mesg,CHAR_COLORWHITE); + } + // ʸë׷ + LogPet( + CHAR_getChar( charaindex, CHAR_NAME ), /* ƽҷ */ + CHAR_getChar( charaindex, CHAR_CDKEY ), + CHAR_getChar( contents, CHAR_NAME), + CHAR_getInt( contents, CHAR_LV), + "PickUp()", + CHAR_getInt( charaindex,CHAR_FLOOR), + CHAR_getInt( charaindex,CHAR_X ), + CHAR_getInt( charaindex,CHAR_Y ), + CHAR_getChar( contents, CHAR_UNIQUECODE) // shan 2001/12/14 + ); + return; + break; + // Robin 0701 petFollow + case 3: + + /* Իľëе */ + CHAR_ObjectDelete(objindex); + CHAR_setWorkInt( contents, CHAR_WORKOBJINDEX, -1); + { + char mesg[256]; + char *p = NULL; + p = CHAR_getChar( contents, CHAR_USERPETNAME); + if( strlen( p) == 0 ) { + p = CHAR_getChar( contents, CHAR_NAME); + } + + snprintf( mesg,sizeof(mesg), "ʰ %s", p); + CHAR_talkToCli(charaindex,-1,mesg,CHAR_COLORWHITE); + } + // ʸë׷ + LogPet( + CHAR_getChar( charaindex, CHAR_NAME ), /* ƽҷ */ + CHAR_getChar( charaindex, CHAR_CDKEY ), + CHAR_getChar( contents, CHAR_NAME), + CHAR_getInt( contents, CHAR_LV), + "FollowPickUp(ջ)", + CHAR_getInt( charaindex,CHAR_FLOOR), + CHAR_getInt( charaindex,CHAR_X ), + CHAR_getInt( charaindex,CHAR_Y ), + CHAR_getChar( contents, CHAR_UNIQUECODE) // shan 2001/12/14 + ); + + return; + break; + case -1: + break; + case -2: + CHAR_talkToCli( charaindex,-1,"", CHAR_COLORYELLOW); + break; + case -3: + CHAR_talkToCli( charaindex,-1,"", CHAR_COLORYELLOW); + break; + case -4: + CHAR_talkToCli( charaindex,-1,"޷չ˸ó", CHAR_COLORYELLOW); + break; + case -5: + CHAR_talkToCli( charaindex,-1,"޷ʰó", CHAR_COLORYELLOW); + break; + case -6: + CHAR_talkToCli( charaindex,-1,"޷ʰõߡ", CHAR_COLORYELLOW); + break; + default: + return; + } + } + return; +} + +/*------------------------------------------------------------ + * ë ϶ƥ £CHAR_DropMoneyռƥǣ + * ¦ + * charaindex int ƽҷ̼͵ + * itemindex int ʧ ة̼͵(ƽҷ· ƥ) + * fl int ׷ʧ + * x int x + * y int y + * force BOOL 𼰰ҷ + * objindex int* ʧ ة Object ƥ̼ + * ߯Ի + * (ئë Ȼئ) -1 + * (߶ֻ) -2 + * ľ½ -3 + * (巴ڼŷʿ) -4 + * ƥְʧ ة л -5 + * ڻ ƥ -6 + * 0 + ------------------------------------------------------------*/ +static BOOL CHAR_DropMoneyFXY( int charaindex, int amount, int fl , int x, + int y, BOOL force, int* objindex ) +{ + OBJECT object; + int MaxGold; + int mygold = CHAR_getInt( charaindex, CHAR_GOLD ); + if( amount <= 0 )return -6; + if( amount > mygold ) + return -1; + + MaxGold = CHAR_getMaxHaveGold( charaindex); + if ((mygold <0) || (mygold > MaxGold)) return -1; + + if( MAP_walkAbleFromPoint( fl,x,y,FALSE ) == FALSE )return -2; + for( object=MAP_getTopObj(fl,x,y) ; object; + object = NEXT_OBJECT(object) ){ + int index = GET_OBJINDEX(object); + int objtype = OBJECT_getType(index); + + if( objtype == OBJTYPE_NOUSE ) continue; + else if( objtype == OBJTYPE_GOLD ){ + long tmpamount = OBJECT_getIndex(index) + amount; + if( tmpamount > MaxGold ) + return -4; + OBJECT_setIndex(index,tmpamount); + CHAR_setInt(charaindex,CHAR_GOLD, + (unsigned int)CHAR_getInt(charaindex, + CHAR_GOLD ) + - amount ); + *objindex = index; +#ifdef _DEL_DROP_GOLD + OBJECT_setTime( index, NowTime.tv_sec); +#endif + if( amount >= 100 ){ /* ë ׷ */ + LogStone(-1,CHAR_getChar( charaindex, CHAR_NAME ), /* ƽҷ */ + CHAR_getChar( charaindex, CHAR_CDKEY ), /* ǡID */ + amount, /* ź */ + CHAR_getInt( charaindex, CHAR_GOLD ), + "Drop(ýǮ)", + CHAR_getInt( charaindex,CHAR_FLOOR), + CHAR_getInt( charaindex,CHAR_X ), + CHAR_getInt( charaindex,CHAR_Y ) + ); + } + return 0; + }else if( objtype == OBJTYPE_ITEM ){ + if( force==TRUE ) + continue; + else + /* ƥʧ ةؤ¼ƥֻ */ + return -5; + } + } + + /* ƥеǷޥ */ + { + Object one; + one.type = OBJTYPE_GOLD; + one.x = x; + one.y = y; + one.floor = fl; + + if( amount > MaxGold ) + return -4; + + one.index = amount; + *objindex = initObjectOne( &one ); + /* Ƥ */ + if( *objindex == -1 ) + /* */ + return -3; + + /*ëӼ*/ + CHAR_setInt(charaindex,CHAR_GOLD, + (unsigned int)CHAR_getInt(charaindex,CHAR_GOLD ) + - amount ); +#ifdef _DEL_DROP_GOLD + OBJECT_setTime( *objindex, NowTime.tv_sec); +#endif + if( amount >= 100 ){ /* ë ׷ */ + LogStone(-1,CHAR_getChar( charaindex, CHAR_NAME ), /* ƽҷ */ + CHAR_getChar( charaindex, CHAR_CDKEY ), /* ǡID */ + amount, /* ź */ + CHAR_getInt( charaindex, CHAR_GOLD ), + "Drop(ýǮ)", + CHAR_getInt( charaindex,CHAR_FLOOR), + CHAR_getInt( charaindex,CHAR_X ), + CHAR_getInt( charaindex,CHAR_Y ) + ); + } + return 0; + } +} + +/*------------------------------------------------------------ + * ë ѣ 󡾮 ʣ + * ¦ + * charaindex int ƽҷ̼͵ + * amount int ż + * + * ߯Ի + * ئ + ------------------------------------------------------------*/ +void CHAR_DropMoney( int charaindex, int amount ) +{ + if( CHAR_getWorkInt( charaindex, CHAR_WORKSAFEMODE)==0) + { + CHAR_SafePassword(charaindex); + return; + } + if(CHAR_getWorkInt(charaindex,CHAR_WORKSTREETVENDOR) > 0) + { + return; + } + int dirx[9],diry[9]; + int ret; + int i; + int objindex, MaxGold; + + if( !CHAR_CHECKINDEX( charaindex ) )return; + +#ifdef _AVID_TRADETRYBUG //ʯ + if( CHAR_getWorkInt( charaindex, CHAR_WORKTRADEMODE) == CHAR_TRADE_TRADING ){ + CHAR_talkToCli( charaindex, -1, "״̬޷ʯҡ", CHAR_COLORYELLOW ); + return; + } +#endif + + MaxGold = CHAR_getMaxHaveGold( charaindex); + if( CHAR_getFlg( charaindex,CHAR_ISDIE ) )return; + + //ANDY_ADD 12/28 + { + int money=0; + money = CHAR_getInt( charaindex, CHAR_GOLD ); + if( money < 0 ) { + CHAR_setInt( charaindex, CHAR_GOLD, 0); + return; + } + if( (amount > money) || (money > MaxGold)) { + if( money > MaxGold ) { + CHAR_setInt( charaindex, CHAR_GOLD, 0 ); + print("\n ERR: %s(stone%d) dropMoney%d > CHAR_MAXGOLDHAVE !!", + CHAR_getChar(charaindex, CHAR_CDKEY), money, amount); + }else { + print("\n ERR: %s dropMoney > CHAR_GOLD !!", CHAR_getChar(charaindex, CHAR_CDKEY)); + } + CHAR_send_P_StatusString( charaindex, CHAR_P_STRING_GOLD); + return; + } + } + //ANDY_END + for( i = 0 ; i < 7 ; i ++ ){ + dirx[i+2] = CHAR_getDX( CHAR_getInt(charaindex,CHAR_DIR) + i+1 ); + diry[i+2] = CHAR_getDY( CHAR_getInt(charaindex,CHAR_DIR) + i+1 ); + } + + dirx[0] = CHAR_getDX(CHAR_getInt(charaindex,CHAR_DIR)); + diry[0] = CHAR_getDY(CHAR_getInt(charaindex,CHAR_DIR)); + dirx[1] = 0; + diry[1] = 0; + + for( i = 0 ; i < 9 ; i ++ ){ + int x = CHAR_getInt(charaindex,CHAR_X) + dirx[i]; + int y = CHAR_getInt(charaindex,CHAR_Y) + diry[i]; + +// CoolFish 2002/04/06 עɶʯ +#ifdef _DROPSTAKENEW + { + int j = 0; + for(j = 0; j < arraysizeof(casinomap); j++) + { + if(CHAR_getInt(charaindex, CHAR_FLOOR) == casinomap[j].casinofl) + { + if (x == casinomap[j].casinox && y == casinomap[j].casinoy) + { + CHAR_talkToCli(charaindex, -1, "ﲻܷʯң", CHAR_COLORYELLOW); + return; + } + } + } + } +#endif + ret = CHAR_DropMoneyFXY( charaindex,amount, + CHAR_getInt(charaindex,CHAR_FLOOR), + x,y, FALSE, &objindex ); + switch( ret ){ + case 0: + goto END; + break; + case -1: + return; + break; + case -3: + return; + break; + case -2: + case -4: + case -5: + case -6: + break; + default: + break; + } + } + + { + int x = CHAR_getInt(charaindex,CHAR_X) + dirx[1]; + int y = CHAR_getInt(charaindex,CHAR_Y) + diry[1]; + + ret = CHAR_DropMoneyFXY( charaindex,amount, + CHAR_getInt(charaindex,CHAR_FLOOR), + x,y, TRUE, &objindex ); + switch( ret ){ + case 0: + goto END; + break; + case -1: + break; + case -3: + return; + break; + case -2: + case -4: + case -5: + break; + default: + break; + } + return; + } + +END: + CHAR_sendWatchEvent(objindex,CHAR_ACTSTAND,NULL,0,TRUE ); + CHAR_send_P_StatusString( charaindex, CHAR_P_STRING_GOLD); + return; +} + +static int CHAR_findEmptyItemBoxNoFromChar( Char* ch ) +{ + int i, j=0;; + for( i = CHAR_STARTITEMARRAY ; i < CHAR_MAXITEMHAVE ; i ++ ){ + int itemindex; + itemindex = ch->indexOfExistItems[i]; + if( itemindex == -1 ) j++; + } + return j; +} + +int CHAR_findEmptyItemBoxNo( int index ) +{ + Char* ch; + + if( !CHAR_CHECKINDEX( index ) )return -1; + ch = CHAR_getCharPointer(index); + if( ch != NULL ) + return CHAR_findEmptyItemBoxNoFromChar( ch ); + else + return -1; + +} + +// CoolFish: Trade 2001/4/4 +int CHAR_findTotalEmptyItem( int index ) +{ + int i, totaleptitem = 0; + Char* ch; + + if( !CHAR_CHECKINDEX( index ) )return -1; + ch = CHAR_getCharPointer(index); + if( ch != NULL ){ + for (i = CHAR_STARTITEMARRAY; i < CHAR_MAXITEMHAVE; i++){ + int itemindex = 0; + itemindex = ch->indexOfExistItems[i]; + if (itemindex == -1) totaleptitem++; + } + return totaleptitem; + } + + return -1; +} + +// Robin 0707 petFollow +int CHAR_pickupFollowPet( int charaindex, int pickupindex ) +{ + int petindex; + int objindex; + int havepetindex; + char category[3]; + + if( !CHAR_CHECKINDEX( charaindex ) ) return FALSE; + + if( pickupindex != -1 ) + petindex = pickupindex; + else + petindex = CHAR_getWorkInt( charaindex, CHAR_WORKPETFOLLOW ); + + if( !CHAR_CHECKINDEX( petindex ) ) + { + CHAR_setWorkInt( charaindex, CHAR_WORKPETFOLLOW, -1 ); + return FALSE; + } + + havepetindex = CHAR_getCharPetElement( charaindex); + if( havepetindex == -1 ) { + CHAR_talkToCli(charaindex,-1,"޷ʰأ",CHAR_COLORYELLOW); + return FALSE; + } + + objindex = CHAR_getWorkInt( petindex, CHAR_WORKOBJINDEX ); + print(" objindex02:%d ", objindex); + + if( (pickupindex == -1) || (pickupindex == CHAR_getWorkInt( charaindex, CHAR_WORKPETFOLLOW ) ) ) + CHAR_setWorkInt( charaindex, CHAR_WORKPETFOLLOW, -1 ); + + /* CDKEY ƽҷ ئ巴ئ */ + if( strcmp( CHAR_getChar( petindex, CHAR_OWNERCDKEY), CHAR_getChar( charaindex, CHAR_CDKEY)) != 0 || + strcmp( CHAR_getChar( petindex, CHAR_OWNERCHARANAME), CHAR_getChar( charaindex, CHAR_NAME)) != 0 ) + { + //CHAR_setWorkInt( charaindex, CHAR_WORKPETFOLLOW, -1 ); + + return FALSE; + } + + + //CHAR_setWorkInt( charaindex, CHAR_WORKPETFOLLOW, -1 ); + + CHAR_ObjectDelete(objindex); + + CHAR_setWorkInt( petindex, CHAR_WORKPETFOLLOWMODE, CHAR_PETFOLLOW_NONE ); + + CHAR_setWorkInt( petindex, CHAR_WORKPLAYERINDEX, charaindex); + CHAR_setCharPet( charaindex, havepetindex, petindex); + +#ifndef _FIX_COPY_MM_BUG +#ifdef _PET_TALK + if( CHAR_getInt( petindex, CHAR_PETID) != 718 ) { +#endif +#endif + CHAR_setChar( petindex, CHAR_OWNERCDKEY, CHAR_getChar( charaindex, CHAR_CDKEY)); + CHAR_setChar( petindex, CHAR_OWNERCHARANAME, CHAR_getChar( charaindex, CHAR_NAME)); +#ifndef _FIX_COPY_MM_BUG +#ifdef _PET_TALK + } +#endif +#endif + + snprintf( category,sizeof( category),"K%d",havepetindex); + CHAR_sendStatusString( charaindex, category); + snprintf( category,sizeof( category),"W%d",havepetindex); + CHAR_sendStatusString( charaindex, category); + + CHAR_setInt( petindex, CHAR_PUTPETTIME, 0); + CHAR_setWorkInt( petindex, CHAR_WORKPETFOLLOWCOUNT, 0); + + + CHAR_setWorkInt( petindex, CHAR_WORKOBJINDEX, -1); + + { + char mesg[256]; + char *p = NULL; + p = CHAR_getChar( petindex, CHAR_USERPETNAME); + if( strlen( p) == 0 ) { + p = CHAR_getChar( petindex, CHAR_NAME); + } + snprintf( mesg,sizeof(mesg), "ʰ %s", p); + CHAR_talkToCli(charaindex,-1,mesg,CHAR_COLORYELLOW); + } + // ʸë׷ + LogPet( + CHAR_getChar( charaindex, CHAR_NAME ), /* ƽҷ */ + CHAR_getChar( charaindex, CHAR_CDKEY ), + CHAR_getChar( petindex, CHAR_NAME), + CHAR_getInt( petindex, CHAR_LV), + "FollowPickUp(ջ)", + CHAR_getInt( charaindex,CHAR_FLOOR), + CHAR_getInt( charaindex,CHAR_X ), + CHAR_getInt( charaindex,CHAR_Y ), + CHAR_getChar( petindex, CHAR_UNIQUECODE) // shan 2001/12/14 + ); + + return TRUE; + +} +#ifdef _GAMBLE_ROULETTE +int NPC_MAPCLEANGOLD( int meindex , int floor) +{ + OBJECT object; + int x,y,fl; + int End_type; + fl = floor; + + for( End_type = 0; End_type < arraysizeof(casinomap) ; End_type++ ) { + if( floor != casinomap[ End_type].casinofl ) + continue; + x = casinomap[ End_type].casinox; + y = casinomap[ End_type].casinoy; + + for( object=MAP_getTopObj(fl,x,y) ; object ; object = NEXT_OBJECT(object ) ) { + int index = GET_OBJINDEX(object); + int objtype = OBJECT_getType(index); + int itemindex = OBJECT_getIndex( index); + + if( objtype == OBJTYPE_NOUSE )continue; + if( objtype == OBJTYPE_ITEM ){ + if(ITEM_getInt(itemindex, ITEM_ID) == CASINOTOKENID) { + ITEM_endExistItemsOne( itemindex); + OBJECT_setIndex( index, 0); + CHAR_ObjectDelete(index); // + print(" clean( %d )", index ); + } + break; + } + } + casinomap[End_type].stakenum = 0; + } + return 1; +} +#endif + +#ifdef _DROPSTAKENEW +// casinotype : flg = 0 typetype趨 +// mapdropflag : TRUE = ע; +int SetCasinoMap(int npcindex, int casinotype, int mapdropflag) +{ + int npcfloor = CHAR_getInt(npcindex, CHAR_FLOOR); + int i = 0; + if (casinotype < 0 || mapdropflag < 0) + return -1; + for (i = 0; i < arraysizeof(casinomap); i++) + { + if (npcfloor == casinomap[i].casinofl) + { + if (casinotype != 0) + { + if (casinomap[i].casinotype == casinotype) + casinomap[i].dropflag = mapdropflag; + } + else + casinomap[i].dropflag = mapdropflag; + } + } + return 1; +} + +// +int CasinoAccumulation(int charindex, int npcindex, int floor, int wincasinotype) +{ + int i = 0; + int accumulation = CHAR_getInt(charindex, CHAR_GAMBLENUM); + char tmpbuf[256]; + for (i = 0; i < MAXSTAKENUM; i++) + { + if (CHAR_getWorkInt(charindex, CHAR_WORKSTAKETYPE1 + i) == wincasinotype) + { + int j = 0; + for (j = 0; j < arraysizeof(casinomap); j++) + { + if (casinomap[j].casinotype == wincasinotype) + { +#ifdef _FIX_GAMBLENUM + // ԭּWIN + accumulation = accumulation + casinomap[j].accumulation * 2; +#else + accumulation += casinomap[j].accumulation; +#endif + CHAR_setWorkInt(charindex, CHAR_WORKSTAKETYPE1 + i, 0); + break; + } + } + } + + else if (CHAR_getWorkInt(charindex, CHAR_WORKSTAKETYPE1 + i) != 0) + { + int j = 0; + for (j = 0; j < arraysizeof(casinomap); j++) + { + if (casinomap[j].casinotype == CHAR_getWorkInt(charindex, CHAR_WORKSTAKETYPE1 + i)) + { +#ifndef _FIX_GAMBLENUM + accumulation -= casinomap[j].accumulation; +#endif + CHAR_setWorkInt(charindex, CHAR_WORKSTAKETYPE1 + i, 0); + break; + } + } + } + } + CHAR_setWorkInt(charindex, CHAR_WORKSTAKEFLAG, 0); + if (accumulation < 0) + accumulation = 0; + else if (accumulation > MAXACCUMULATION) + accumulation = MAXACCUMULATION; + CHAR_setInt(charindex, CHAR_GAMBLENUM, accumulation); + snprintf(tmpbuf, sizeof(tmpbuf), "ܹ%4dֳ", accumulation); + CHAR_talkToCli(charindex, npcindex, tmpbuf, CHAR_COLORWHITE); + return 1; +} + +int CasinoPay(int npcindex, int wincasinotype) +{ + int npcfloor = CHAR_getInt(npcindex, CHAR_FLOOR); + int i = 0; + int playernum = CHAR_getPlayerMaxNum(); + if (wincasinotype < 0) return FALSE; + for (i = 0; i < playernum; i++) + { + if (CHAR_getCharUse(i) == FALSE) continue; + if (!CHAR_CHECKINDEX(i)) continue; + if (CHAR_getInt(i, CHAR_FLOOR) == npcfloor) + { + // ѯǷע + if (CHAR_getWorkInt(i, CHAR_WORKSTAKEFLAG) == 0) + continue; + // + CasinoAccumulation(i, npcindex, npcfloor, wincasinotype); + } + } + // ˲ȯ + for (i = 0; i < arraysizeof(casinomap); i++) + { + OBJECT object; + if (casinomap[i].casinofl != npcfloor) continue; + for (object = MAP_getTopObj(casinomap[i].casinofl, casinomap[i].casinox, + casinomap[i].casinoy); object; object = NEXT_OBJECT(object)) + { + int index = GET_OBJINDEX(object); + int objtype = OBJECT_getType(index); + int itemindex = OBJECT_getIndex( index); + if (objtype == OBJTYPE_NOUSE) continue; + else if (objtype == OBJTYPE_ITEM) + { + if(ITEM_getInt(itemindex, ITEM_ID) == CASINOTOKENID) + { + OBJECT_setIndex(index, 0); + CHAR_ObjectDelete(index); + } + } + } + casinomap[i].stakenum = 0; + } + return TRUE; +} +#endif + +#ifdef _PET_ITEM +void CHAR_sendPetItemData( int charaindex, int petid) +{ + int i; + char CHAR_statusSendBuffer[1024]; + int strlength = 2; + int petindex = CHAR_getCharPet( charaindex, petid); + int fd = getfdFromCharaIndex( charaindex ); + snprintf( CHAR_statusSendBuffer ,sizeof(CHAR_statusSendBuffer),"B%d" , petid); + for( i = 0 ; i < CHAR_MAXPETITEMHAVE ; i ++ ){ + char token[512]; + int itemindex; + itemindex = CHAR_getItemIndex( petindex, i ); + if( itemindex >= 0 ) { + snprintf( token ,sizeof(token),"%s|" ,ITEM_makeItemStatusString( -1, itemindex ) ); + }else { + snprintf( token ,sizeof(token),"%s|" , ITEM_makeItemFalseString() ); + } + strcpysafe( CHAR_statusSendBuffer + strlength, + sizeof(CHAR_statusSendBuffer) - strlength, token ); + strlength += strlen( token ); + if( strlength >= arraysizeof(CHAR_statusSendBuffer) ) lssproto_S_send(fd, CHAR_statusSendBuffer); + } + dchop( CHAR_statusSendBuffer , "|" ); + lssproto_S_send(fd, CHAR_statusSendBuffer); +} + +void CHAR_movePetItem( int charaindex, int petid, int fromindex, int toindex ) +{ + if( !CHAR_CHECKINDEX( charaindex ) )return; + if( CHAR_getFlg( charaindex,CHAR_ISDIE ) )return; + int petindex = CHAR_getCharPet( charaindex, petid); + char token[512]; + if(toindex == -1 && fromindex >= CHAR_EQUIPPLACENUM && fromindex < CHAR_MAXITEMHAVE){ + int itemindex = CHAR_getItemIndex( charaindex, fromindex ); + toindex=ITEM_getInt( itemindex, ITEM_TYPE)-ITEM_PET_HEAD; + }else if(toindex == -2){ + if(fromindex=0 && toindex< CHAR_MAXPETITEMHAVE){//toindex ǵ + //CHAR_talkToCli( charaindex, -1, "޷װƷ", CHAR_COLORWHITE ); + //return; + INT_petfesion = 28;// + } + //µģ + /* + int itemindexi;// + itemindexi = CHAR_getItemIndex( charaindex , toindex );//ȡװ + if(itemindexi >= 0){ + CHAR_talkToCli( charaindex, -1, "޷װƷ", CHAR_COLORWHITE ); + return; + }*/ + + } + //print("\nINT_petfesion %d = \n", INT_petfesion ); + allowpetitemtype = ITEM_getChar(itemindex,ITEM_PETEQUITALLOW);//װ + forbitpetitemtype= ITEM_getChar(itemindex,ITEM_PETEQUITFORBIT);//װ + //print("\allowpetitemtype len %d = \n", arraysizeof(allowpetitemtype) ); + //print("\forbitpetitemtype len %d = \n", arraysizeof(forbitpetitemtype) ); + { //װ + int tokenNo = 1 ; + char tokenBuf[3]; + BOOL ISCATFLG = FALSE; + BOOL UseFisrtTokenFlg = TRUE; + BOOL UseSecondTokenFlg = TRUE; + BOOL FindFisrtTokenFlg = FALSE; + + tokenNo = 1 ; + + if(!(atoi(allowpetitemtype)== 0 && atoi(forbitpetitemtype)== 0 ) ){ + while( getStringFromIndexWithDelim(allowpetitemtype," ",tokenNo,tokenBuf,sizeof(tokenBuf))){ + //print("\n tokenBuf %d = \n",atoi(tokenBuf)); + if(-1 == atoi(tokenBuf)) { + UseFisrtTokenFlg = FALSE; + break; + } + if(INT_petfesion == atoi(tokenBuf)) { + FindFisrtTokenFlg = TRUE; + break; + } + tokenNo++; + } + if(UseFisrtTokenFlg){//ʹ޶ + if(!FindFisrtTokenFlg){//ֿʹ + //if(!getStringFromIndexWithDelim(allowpetitemtype," ",tokenNo,tokenBuf,sizeof(tokenBuf))){ + CHAR_talkToCli( charaindex, -1, "޷װƷ", CHAR_COLORWHITE ); + return; + //} + } + }else{//ʹų + FindFisrtTokenFlg = FALSE; + tokenNo = 1; + while( getStringFromIndexWithDelim(forbitpetitemtype," ",tokenNo,tokenBuf,sizeof(tokenBuf))){ + if(-1 == atoi(tokenBuf)) { + UseSecondTokenFlg = FALSE; + break; + } + if(INT_petfesion == atoi(tokenBuf)) { + FindFisrtTokenFlg = TRUE; + break; + } + tokenNo++; + } + if(UseSecondTokenFlg){ + if(FindFisrtTokenFlg){//ֲʹ + CHAR_talkToCli( charaindex, -1, "޷װƷ3", CHAR_COLORWHITE ); + return; + } + } + } + } + } + } +#endif + if( (fromindex >=0 && fromindex < CHAR_PETITEMNUM && toindex >= CHAR_EQUIPPLACENUM && toindex < CHAR_MAXITEMHAVE) + || (toindex >=0 && toindex < CHAR_PETITEMNUM && fromindex >= CHAR_EQUIPPLACENUM && fromindex < CHAR_MAXITEMHAVE)){ + if(fromindex >= CHAR_EQUIPPLACENUM){ + int charitemindex = CHAR_getItemIndex( charaindex, fromindex ); + int petitemindex = CHAR_getItemIndex( petindex, toindex ); + int type=ITEM_getInt( charitemindex, ITEM_TYPE); + if(CHAR_getInt(petindex, CHAR_VARIABLEAI) < 100){ + CHAR_talkToCli( charaindex, -1, "޷ѵװƷ", CHAR_COLORRED ); + return; + } + if(typeITEM_PET_FEET || (type-ITEM_PET_HEAD) != toindex){ + CHAR_talkToCli( charaindex, -1, "޷װƷ", CHAR_COLORWHITE ); + return; + } + if( CHAR_getInt( petindex, CHAR_LV) < ITEM_getInt( charitemindex, ITEM_LEVEL)){ + CHAR_talkToCli( charaindex, -1, "ȼδװƷ", CHAR_COLORYELLOW ); + return; + } + if( ITEM_CHECKINDEX( petitemindex)){ + sprintf( token, "%s ж%s", CHAR_getChar( petindex, CHAR_NAME), ITEM_getChar( petitemindex, ITEM_NAME)); + CHAR_talkToCli( charaindex, -1, token, CHAR_COLORWHITE ); + } + sprintf( token, "%s װ%s", CHAR_getChar( petindex, CHAR_NAME), ITEM_getChar( charitemindex, ITEM_NAME)); + CHAR_talkToCli( charaindex, -1, token, CHAR_COLORWHITE ); + CHAR_setItemIndex( charaindex, fromindex, petitemindex ); + CHAR_setItemIndex( petindex, toindex, charitemindex ); + CHAR_sendItemDataOne( charaindex, fromindex); + CHAR_sendPetItemData( charaindex, petid); + }else{ + int charitemindex = CHAR_getItemIndex( charaindex, toindex ); + int petitemindex = CHAR_getItemIndex( petindex, fromindex ); + int type=ITEM_getInt( charitemindex, ITEM_TYPE); + sprintf( token, "%s ж%s", CHAR_getChar( petindex, CHAR_NAME), ITEM_getChar( petitemindex, ITEM_NAME)); + CHAR_talkToCli( charaindex, -1, token, CHAR_COLORWHITE ); + if( ITEM_CHECKINDEX( charitemindex)){ + if(CHAR_getInt(petindex, CHAR_VARIABLEAI) < 100){ + CHAR_talkToCli( charaindex, -1, "޷ѵװƷ", CHAR_COLORRED ); + return; + } + if(typeITEM_PET_FEET || (type-ITEM_PET_HEAD) != toindex){ + CHAR_talkToCli( charaindex, -1, "޷װƷ", CHAR_COLORWHITE ); + return; + } + if( CHAR_getInt( petindex, CHAR_LV) < ITEM_getInt( charitemindex, ITEM_LEVEL)){ + CHAR_talkToCli( charaindex, -1, "ȼδװƷ", CHAR_COLORYELLOW ); + return; + } + sprintf( token, "%s װ%s", CHAR_getChar( petindex, CHAR_NAME), ITEM_getChar( charitemindex, ITEM_NAME)); + CHAR_talkToCli( charaindex, -1, token, CHAR_COLORWHITE ); + } + CHAR_setItemIndex( charaindex, toindex, petitemindex ); + CHAR_setItemIndex( petindex, fromindex, charitemindex ); + CHAR_sendItemDataOne( charaindex, toindex); + CHAR_sendPetItemData( charaindex, petid); + } + } + CHAR_complianceParameter( petindex ); + snprintf( token, sizeof( token ), "K%d", petid ); + CHAR_sendStatusString( charaindex, token ); +} + +void CHAR_sendPetItemEmpty( int charaindex, int petid) +{ + int fd = getfdFromCharaIndex( charaindex ); + char CHAR_statusSendBuffer[16]; + sprintf(CHAR_statusSendBuffer,"B%d|",petid); + lssproto_S_send(fd, CHAR_statusSendBuffer); +} + +#endif + +void CHAR_CheckItemTime( int charaindex ){ + int i; + for( i = 0 ; i < CHAR_MAXITEMHAVE ; i ++ ){ + int itemindex = CHAR_getItemIndex( charaindex, i ); + if( itemindex >= 0 ) { + int itemtime = 0; + itemtime = ITEM_getInt(itemindex,ITEM_TIME); + if(itemtime>0){ + time_t timep; + struct tm *p; + time(&timep); + p=localtime(&timep); + timep = mktime(p); + if(itemtime<=timep){ + char itemname[128]; + sprintf(itemname,"ĵ:%sʱЧѵϵͳջء",ITEM_getChar(itemindex,ITEM_NAME)); + CHAR_talkToCli( charaindex, -1, itemname, CHAR_COLORYELLOW ); + CHAR_setItemIndex( charaindex, i ,-1); + CHAR_sendItemDataOne( charaindex, i); + ITEM_endExistItemsOne(itemindex); + } + } + } + } +} + diff --git a/char/char_party.c b/char/char_party.c new file mode 100644 index 0000000..412426b --- /dev/null +++ b/char/char_party.c @@ -0,0 +1,735 @@ +#include "version.h" +#include + +#include "readmap.h" +#include "object.h" +#include "char.h" +#include "char_base.h" +#include "battle.h" +#include "lssproto_serv.h" +#include "npcutil.h" +#include "npc_bus.h" +#include "npc_airplane.h" // Arminius 7.10 Airplane +#include "family.h" // shan + +#ifdef _ITEM_QUITPARTY +#include "init.h" +#endif +#ifdef _ALLBLUES_LUA +#include "mylua/function.h" +#endif +// shan add +extern struct FM_PKFLOOR fmpkflnum[FAMILY_FMPKFLOOR]; + +/*------------------------------------------------------------ + * ɡ ū ĩ + ------------------------------------------------------------*/ + +/*------------------------------------------------------------ + * лɡ ū ë + * ئľ-1ë߯ʣ + ------------------------------------------------------------*/ +int CHAR_getEmptyPartyArray( int charaindex) +{ + int i = -1; + int rc = FALSE; + int toindex; + if( CHAR_getWorkInt( charaindex, CHAR_WORKPARTYMODE) == CHAR_PARTY_NONE ) { + toindex = charaindex; + } + else { + toindex = CHAR_getPartyIndex( charaindex, 0); + } + if( CHAR_CHECKINDEX( toindex)){ + for( i = 1; i < CHAR_PARTYMAX; i ++ ) { + if( CHAR_getWorkInt( toindex, i + CHAR_WORKPARTYINDEX1) == -1 ) { + rc = TRUE; + break; + } + } + } + return( rc ? i: -1); +} + +int CHAR_getPartyNum( int charaindex) +{ + int i = -1; + int rc = FALSE; + int toindex; + if( CHAR_getWorkInt( charaindex, CHAR_WORKPARTYMODE) == CHAR_PARTY_NONE ) { + return 1; + } + else { + toindex = CHAR_getPartyIndex( charaindex, 0); + } + if( CHAR_CHECKINDEX( toindex)){ + for( i = 1; i <= CHAR_PARTYMAX; i ++ ) { + if(i==CHAR_PARTYMAX) return i; + if( CHAR_getWorkInt( toindex, i + CHAR_WORKPARTYINDEX1) == -1 ) { + return i; + } + } + } + return i; +} +/*------------------------------------------------------------ + * ˱ɡ ū + * + * charaindex int + * targetindex int 켰 + ------------------------------------------------------------*/ +BOOL CHAR_JoinParty_Main( int charaindex, int targetindex) +{ + int firstflg = FALSE; + int i; + char c[3]; + char buf[64]; + int toindex; + int parray; + + /* ʻ¦ȽԻ */ + if( CHAR_getWorkInt( targetindex, CHAR_WORKPARTYMODE) == CHAR_PARTY_NONE ) { + toindex = targetindex; + } + else { + toindex = CHAR_getPartyIndex( targetindex, 0); + if( !CHAR_CHECKINDEX( toindex) ) { + print( " %s:%d err\n", __FILE__, __LINE__); + return; + } + } + +#ifdef _ALLBLUES_LUA_1_5 + if(FreePartyJoin(charaindex, toindex) == FALSE){ + return FALSE; + } +#endif + /* ɡ ūѷ */ + parray = CHAR_getEmptyPartyArray( toindex) ; + if( parray == -1 ) { + print( "%s : %d err\n", __FILE__,__LINE__); + return; + } + + //BUG + int pi; + for( pi = 0; pi < CHAR_PARTYMAX; pi ++ ) { + int index = CHAR_getWorkInt( toindex, pi + CHAR_WORKPARTYINDEX1); + if( CHAR_CHECKINDEX(index)) { + if(index == charaindex) return; //BUG + } + } +#ifdef _WARNPC_CTRL + int mapi; + for(mapi=0;mapi<10;mapi++){ + int floorid = getPartyMap(mapi); + if(CHAR_getInt(charaindex,CHAR_FLOOR)==floorid){ + int sameipnum = getMapSameIp(mapi); + int partyi; + unsigned ip=CONNECT_get_userip(getfdFromCharaIndex(charaindex)); + unsigned teseip = ip; + unsigned toip; + int a, b, c, d,ipcnt=1; + char ipstr[32]; + a=(teseip % 0x100); teseip=teseip / 0x100; + b=(teseip % 0x100); teseip=teseip / 0x100; + c=(teseip % 0x100); teseip=teseip / 0x100; + d=(teseip % 0x100); + sprintf(ipstr,"%d.%d.%d.%d",a,b,c,d); + if(strcmp(ipstr,getNoAttIp(0))==0 || strcmp(ipstr,getNoAttIp(1))==0 || strcmp(ipstr,getNoAttIp(2))==0 || strcmp(ipstr,getNoAttIp(3))==0 || strcmp(ipstr,getNoAttIp(4))==0) + break; + if( CHAR_getWorkInt( toindex, CHAR_WORKPARTYMODE) == CHAR_PARTY_NONE ) { + toip=CONNECT_get_userip(getfdFromCharaIndex(toindex)); + if(ip==toip){ + ipcnt++; + if(ipcnt>sameipnum){ + CHAR_talkToCli( charaindex, -1, "˵ͼĵIPѴޣ޷롣", CHAR_COLORYELLOW); + return; + } + else + break; + } + break; + }else{ + for( partyi = 0; partyi < CHAR_PARTYMAX; partyi ++ ) { + int index = CHAR_getWorkInt( toindex, partyi + CHAR_WORKPARTYINDEX1); + if( CHAR_CHECKINDEX(index)) { + toip = CONNECT_get_userip(getfdFromCharaIndex(index)); + if(ip==toip){ + ipcnt++; + if(ipcnt>sameipnum){ + CHAR_talkToCli( charaindex, -1, "˵ͼĵIPѴޣ޷롣", CHAR_COLORYELLOW); + return; + } + } + } + } + } + } + } +#endif +#ifdef _FLOOR_PARTY_CTRL + int mapj; + for(mapj=1;mapj<=5;mapj++){ + int floorid = getPartyFloor(mapj); + if(CHAR_getInt(charaindex,CHAR_FLOOR)==floorid){ + time_t timep; + struct tm *p; + time(&timep); + p=localtime(&timep); /*ȡõʱ*/ + int day=p->tm_wday; + int hour=p->tm_hour; + if(hour < 2) day = day - 1; + if(day>5 || day<1) day = 5; + int partyi,partycnt=1; + if( CHAR_getWorkInt( toindex, CHAR_WORKPARTYMODE) == CHAR_PARTY_NONE ) { + partycnt++; + if(partycnt>day){ + CHAR_talkToCli( charaindex, -1, "ͼѴޣһΪ1ˣܶΪ2ˣΪ3ˣΪ4ˣơ", CHAR_COLORYELLOW); + return; + } + else + break; + }else{ + for( partyi = 0; partyi < CHAR_PARTYMAX; partyi ++ ) { + int index = CHAR_getWorkInt( toindex, partyi + CHAR_WORKPARTYINDEX1); + if( CHAR_CHECKINDEX(index)) { + partycnt++; + if(partycnt>day){ + CHAR_talkToCli( charaindex, -1, "ͼѴޣһΪ1ˣܶΪ2ˣΪ3ˣΪ4ˣơ", CHAR_COLORYELLOW); + return; + } + } + } + } + } + } +#endif + /* ʼݷʱئCAë˪ */ + if( CHAR_getWorkInt( toindex, CHAR_WORKPARTYMODE) == CHAR_PARTY_NONE ) { + CHAR_sendLeader( CHAR_getWorkInt( toindex, CHAR_WORKOBJINDEX), 1); + /* 켰ؼ̤徧 */ + /* ʱئ */ + CHAR_setWorkInt( toindex, CHAR_WORKPARTYMODE, 1); + CHAR_setWorkInt( toindex, CHAR_WORKPARTYINDEX1, toindex); + firstflg = TRUE; + } + CHAR_setWorkInt( toindex, parray + CHAR_WORKPARTYINDEX1, charaindex); + + CHAR_setWorkChar( charaindex, CHAR_WORKWALKARRAY, ""); + + CHAR_setWorkInt( charaindex, CHAR_WORKPARTYMODE, CHAR_PARTY_CLIENT); + + CHAR_setWorkInt( charaindex, CHAR_WORKPARTYINDEX1, toindex); + + if( firstflg ) { + CHAR_sendStatusString( toindex, "N0"); + } + + + for( i = 0; i < CHAR_PARTYMAX; i ++ ) { + int index = CHAR_getWorkInt( toindex, i + CHAR_WORKPARTYINDEX1); + if( CHAR_CHECKINDEX(index)) { + snprintf( c, sizeof(c), "N%d", i); + CHAR_sendStatusString( charaindex, c); + } + } + + snprintf( buf,sizeof( buf), "%s Ŷӣ", + CHAR_getChar( charaindex, CHAR_NAME)); + + for( i = 0; i < CHAR_PARTYMAX; i ++ ) { + int index = CHAR_getWorkInt( toindex, i + CHAR_WORKPARTYINDEX1); + if( CHAR_CHECKINDEX(index)) { + if( index != charaindex ) { + snprintf( c, sizeof(c), "N%d", parray); + CHAR_sendStatusString( index, c); + CHAR_talkToCli( index, -1, buf, CHAR_COLORYELLOW); + } + else { + CHAR_talkToCli( index, -1, "Ŷӣ", CHAR_COLORYELLOW); + } + } + } +} +/*------------------------------------------------------------ + * ɡ ū Ƿ£ + ------------------------------------------------------------*/ +BOOL CHAR_JoinParty( int charaindex ) +{ + + int result = -1; + int x,y; + OBJECT object; + int found = FALSE; + int fd; + int cnt; + int i; + + fd = getfdFromCharaIndex( charaindex ); + if( fd == -1 ) { + print( "%s : %d err\n", __FILE__, __LINE__); + return FALSE; + } + + /* лɡ ū׬ƥ */ + if( CHAR_getWorkInt( charaindex, CHAR_WORKPARTYMODE) != CHAR_PARTY_NONE ) { + lssproto_PR_send( fd, 1, FALSE); + return FALSE; + } + + /* 󡼰 ë */ + CHAR_getCoordinationDir( CHAR_getInt( charaindex, CHAR_DIR ) , + CHAR_getInt( charaindex , CHAR_X ), + CHAR_getInt( charaindex , CHAR_Y ) , + 1 , &x , &y ); + + /* */ + for( i = 0; i < CONNECT_WINDOWBUFSIZE; i ++ ) { + CONNECT_setJoinpartycharaindex(fd,i,-1); + } + cnt = 0; + + /*м 󡼰ƽҷë */ + + for( object = MAP_getTopObj( CHAR_getInt( charaindex, CHAR_FLOOR),x,y) ; + object ; + object = NEXT_OBJECT(object ) ) + { + int toindex; + int parray; + int objindex = GET_OBJINDEX(object); + int targetindex = -1; + + /* ƽҷԪئ */ + if( OBJECT_getType( objindex) != OBJTYPE_CHARA) continue; + toindex = OBJECT_getIndex( objindex); + + // shan begin + if( CHAR_getInt(charaindex, CHAR_FMINDEX) > 0 && CHAR_getInt(toindex, CHAR_FMINDEX) >0){ + for( i = 0; i < FAMILY_FMPKFLOOR; i++){ + if( fmpkflnum[i].fl == CHAR_getInt( charaindex, CHAR_FLOOR) ) + if( CHAR_getInt(charaindex, CHAR_FMINDEX) != CHAR_getInt(toindex, CHAR_FMINDEX) ){ + lssproto_PR_send( fd, 1, FALSE); + return FALSE; + } + } + } + // shan end + + /* */ + if( CHAR_getInt( toindex, CHAR_WHICHTYPE) == CHAR_TYPEPLAYER || CHAR_getInt(toindex, CHAR_WHICHTYPE) == CHAR_TYPEPLAYERNPC){ + found = TRUE; + /* 컥ҷë¦ȽԻ */ + if( CHAR_getWorkInt( toindex, CHAR_WORKPARTYMODE) == CHAR_PARTY_CLIENT ) { + targetindex = CHAR_getWorkInt( toindex, CHAR_WORKPARTYINDEX1); + if( !CHAR_CHECKINDEX( targetindex) ) { + print( " %s:%d err\n", __FILE__, __LINE__); + continue; + } + if( CHAR_getInt( targetindex, CHAR_WHICHTYPE) == CHAR_TYPEBUS) { + continue; + } + } + else { + targetindex = toindex; + } + + /* ڶ ¾ */ + if( NPC_Util_CharDistance( charaindex, targetindex ) > 1) { + continue; + } + + /* ƥئǣ*/ + if( CHAR_getWorkInt( targetindex, CHAR_WORKBATTLEMODE) != BATTLE_CHARMODE_NONE ){ + continue; + } + /* ޸ƹ */ + if( !CHAR_getFlg( targetindex, CHAR_ISPARTY) ) continue; + +#ifdef _ANGEL_SUMMON + if( CHAR_getWorkInt( targetindex, CHAR_WORKANGELMODE) == TRUE) { + CHAR_talkToCli( charaindex, -1, "ʹ߲Եӡ", CHAR_COLORYELLOW); + continue; + } +#endif + } + /* Ѩƹﵩݷ޷Ի£ */ + else if( CHAR_getInt( toindex, CHAR_WHICHTYPE) == CHAR_TYPEBUS ) { + targetindex = toindex; + cnt = 0; + if( !NPC_BusCheckJoinParty( toindex, charaindex, TRUE)) { + /* ë ׽ئף ¼δ£޼ ئУ + * ֧֧мƥ + */ + break; + } + { // Arminius 7.10 Airplane + int busimg=CHAR_getInt(toindex, CHAR_BASEIMAGENUMBER); + if ((busimg!=100355) && (busimg!=100461)) { + CHAR_setInt(charaindex,CHAR_BASEIMAGENUMBER,busimg); + CHAR_sendCToArroundCharacter( CHAR_getWorkInt( charaindex , + CHAR_WORKOBJINDEX )); + // Robin debug 01/11/21 + if( CHAR_getInt( charaindex, CHAR_RIDEPET) != -1 ) { + CHAR_setInt( charaindex, CHAR_RIDEPET, -1); + CHAR_send_P_StatusString( charaindex, CHAR_P_STRING_RIDEPET); + } + /* + CHAR_sendPMEToArroundCharacterFLXY(charaindex, + CHAR_getInt( charaindex, CHAR_FLOOR), + CHAR_getInt( charaindex, CHAR_X), + CHAR_getInt( charaindex, CHAR_Y), + 0,1,CHAR_getInt( charaindex, CHAR_PETMAILEFFECT) + ); + */ + } + } + } + /* 跴Ѩƹﵩ½ */ + else { + continue; + } + + /* ɡ ūѷ */ + parray = CHAR_getEmptyPartyArray( targetindex) ; + if( parray == -1 ) continue; + + /* ƥľ */ + CONNECT_setJoinpartycharaindex( fd,cnt,toindex); + cnt++; + if( cnt == CONNECT_WINDOWBUFSIZE ) break; + + /* Ѩƹﵩ έƷУݻë £ */ + if( CHAR_getInt( targetindex, CHAR_WHICHTYPE) == CHAR_TYPEBUS ) break; + + } + + if( cnt == 0 ) { + if( found == TRUE) { + CHAR_talkToCli( charaindex, -1, "޷Ŷӡ", CHAR_COLORYELLOW); + } + result = FALSE; + }else if( cnt == 1 ) { +#ifdef _AUTO_PK + if(CHAR_getInt(charaindex,CHAR_FLOOR)==20000){ + CHAR_talkToCli( charaindex, -1, "Pϵͳֹ!", CHAR_COLORYELLOW); + result = FALSE; + }else +#endif + { + CHAR_JoinParty_Main( charaindex, CONNECT_getJoinpartycharaindex(fd,0)); + result = TRUE; + } + }else { + int strlength; + char msgbuf[1024]; + char escapebuf[2048]; + strcpy( msgbuf, "1\n˭Ŷأ\n"); + strlength = strlen( msgbuf); + for( i = 0; + CONNECT_getJoinpartycharaindex( fd,i ) != -1 + && i< CONNECT_WINDOWBUFSIZE; + i ++ ){ + char *a = CHAR_getChar( + CONNECT_getJoinpartycharaindex(fd,i) , CHAR_NAME); + char buf[256]; + snprintf( buf, sizeof( buf),"%s\n", a); + if( strlength + strlen( buf) > arraysizeof( msgbuf)){ + print( "%s:%dӴѶϢbuffer㡣\n", + __FILE__,__LINE__); + break; + } + strcpy( &msgbuf[strlength], buf); + strlength += strlen(buf); + } + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_SELECT, + WINDOW_BUTTONTYPE_CANCEL, + CHAR_WINDOWTYPE_SELECTPARTY, + -1, + makeEscapeString( msgbuf, escapebuf, sizeof(escapebuf))); + + + } + + if( result != -1 ) { + lssproto_PR_send( fd, 1, result); + } + + return result; +} + +static BOOL CHAR_DischargePartySub( int charaindex, int msgflg) +{ + char buf[64], c[3]; + int toindex,flg,i; +#ifdef _ITEM_QUITPARTY + int j = 0,k; +#endif + + + if( CHAR_getWorkInt( charaindex, CHAR_WORKPARTYMODE) == CHAR_PARTY_LEADER ) { + int pindex, airplaneflag=0; + // Arminius 7.10 Airplane + if( CHAR_getInt(charaindex, CHAR_WHICHTYPE) == CHAR_TYPEBUS ) { + if ((CHAR_getInt(charaindex, CHAR_BASEIMAGENUMBER) !=100355) && + (CHAR_getInt(charaindex, CHAR_BASEIMAGENUMBER) !=100461)){ + airplaneflag=1; + } + } + for( i = 0; i < CHAR_PARTYMAX; i ++ ) { + pindex = CHAR_getWorkInt( charaindex, i + CHAR_WORKPARTYINDEX1); + if( CHAR_CHECKINDEX( pindex) ) { + int fd = getfdFromCharaIndex( pindex ); +#ifdef _PLAYER_NPC + if(CHAR_getInt( pindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYERNPC){ + CHAR_CharaDelete(pindex); + continue; + } +#endif + CHAR_setWorkInt( pindex, CHAR_WORKPARTYINDEX1, -1); + CHAR_setWorkInt( pindex, CHAR_WORKPARTYMODE, CHAR_PARTY_NONE); + if( msgflg ){ + CHAR_talkToCli( pindex, -1, "Ŷѽɢ", CHAR_COLORYELLOW); +#ifdef _ITEM_QUITPARTY + // won fix + for( j=0;j=0){ + int fl,x,y; + CHAR_getElderPosition( CHAR_getInt( charaindex, CHAR_LASTTALKELDER), + &fl, &x, &y ); + CHAR_warpToSpecificPoint(charaindex, fl, x, y); + } + } + } + } + CHAR_setWorkInt( charaindex, CHAR_WORKPARTYINDEX1, -1); + for( i = 0; i < CHAR_PARTYMAX; i ++ ) { + int index = CHAR_getWorkInt( toindex, i + CHAR_WORKPARTYINDEX1); + if( CHAR_CHECKINDEX(index) ){ + if( index == charaindex) { + myarray = i; + break; + } + } + } + if( myarray == CHAR_PARTYMAX) { + print( "DischargeParty(): ֣"); + return FALSE; + } + CHAR_setWorkInt( toindex, CHAR_WORKPARTYINDEX1 + myarray, -1); + snprintf( buf,sizeof( buf), "%s Ŷӣ", + CHAR_getChar( charaindex, CHAR_NAME)); + if( msgflg ){ + CHAR_talkToCli( charaindex, -1, "Ŷӣ", CHAR_COLORYELLOW); +#ifdef _ITEM_QUITPARTY + // won fix + for( i=0;i 1) { + int parent_dir; + start.x = CHAR_getInt( index, CHAR_X); + start.y = CHAR_getInt( index, CHAR_Y); + parent_dir = NPC_Util_getDirFromTwoPoint( &start,&end ); + end = start; + if( parent_dir != -1 ) { + CHAR_walk( index, parent_dir, 0); + } + } + previndex = index; + } + } + } + + } + + return TRUE; +} +BOOL CHAR_DischargeParty( int charaindex, int flg) +{ + return CHAR_DischargePartySub( charaindex, 1); +} + +BOOL CHAR_DischargePartyNoMsg( int charaindex) +{ + return CHAR_DischargePartySub( charaindex, 0); +} + + +/*------------------------------------------------------------ + * лĸë˪£ + ------------------------------------------------------------*/ +void CHAR_sendLeader( int objindex, int leader) +{ + int opt[1]; + opt[0] = leader; + CHAR_sendWatchEvent( objindex,CHAR_ACTLEADER,opt,1,TRUE); +} +/*------------------------------------------------------------ + * ë CHAR_WORKPARTYINDEX)϶ƥƽҷindexë¦Ƚ£ + * лƥֺƥ + ------------------------------------------------------------*/ +int CHAR_getPartyIndex( int index, int num) +{ + int nindex = -1; + + /* ޼̼͵ë */ + /* ʼ */ + if( CHAR_getWorkInt( index, CHAR_WORKPARTYMODE) == CHAR_PARTY_LEADER ) { + nindex = CHAR_getWorkInt( index, CHAR_WORKPARTYINDEX1 + num ); + } + /* Ҽ */ + else { + int oyaindex = CHAR_getWorkInt( index, CHAR_WORKPARTYINDEX1); + if( CHAR_CHECKINDEX( oyaindex)) { + nindex = CHAR_getWorkInt( oyaindex, CHAR_WORKPARTYINDEX1+num); + } + } + return nindex; +} +/*------------------------------------------------------------ + * ë˪£ + * ޻ľɹޱֶë˪£ + ------------------------------------------------------------*/ +void CHAR_talkToCliAndParty( int talkedcharaindex,int talkcharaindex, + char* message, CHAR_COLOR color ) +{ + int i; + /* ڷ */ + CHAR_talkToCli( talkedcharaindex, talkcharaindex, message, color); + + for( i = 0; i < CHAR_PARTYMAX; i ++ ) { + int index = CHAR_getPartyIndex( talkedcharaindex, i); + if( CHAR_CHECKINDEX( index) && + index != talkedcharaindex) + { + CHAR_talkToCli( index, talkcharaindex, message, color); + } + } +} + diff --git a/char/char_talk.c b/char/char_talk.c new file mode 100644 index 0000000..1d7582c --- /dev/null +++ b/char/char_talk.c @@ -0,0 +1,2278 @@ +#include "version.h" +#include +#include +#include +#include +#include +#include "handletime.h" +#include "readmap.h" +#include "object.h" +#include "char.h" +#include "char_base.h" +#include "char_talk.h" +#include "chatmagic.h" +#include "battle.h" +#include "log.h" +#include "configfile.h" +#include "lssproto_serv.h" +#include "saacproto_cli.h" +#include "family.h" +#ifdef _CHAR_PROFESSION +#include "profession_skill.h" +#endif +#ifdef _ALLBLUES_LUA +#include "mylua/function.h" +#endif +#include "net.h" + + +extern int channelMember[FAMILY_MAXNUM][FAMILY_MAXCHANNEL][FAMILY_MAXMEMBER]; + +#ifdef _CHANNEL_MODIFY +int *piOccChannelMember = NULL; +#endif + +#ifdef _TALK_ACTION +void TalkAction(int charaindex, char *message); +#endif + +#ifdef _GM_ITEM +static BOOL player_useChatMagic( int charaindex, char* data, BOOL isDebug); +#endif +extern int playeronlinenum; +static int pojietype = 0; +/*------------------------------------------------------------ + * ĩ + ------------------------------------------------------------*/ +#define DEBUGCDKEYNUM 100 +struct tagDebugCDKey { + int use; + char cdkey[9]; +}; +static struct tagDebugCDKey DebugCDKey[DEBUGCDKEYNUM]; + +/*==================== ܷ====================*/ +typedef void (*CHATMAGICFUNC)(int,char*); +typedef struct tagCHAR_ChatMagicTable +{ + char* magicname; + CHATMAGICFUNC func; + BOOL isdebug; + int hash; + int level; + char* usestring; +}CHAR_ChatMagicTable; + +static CHAR_ChatMagicTable CHAR_cmtbl[]={ + //ʦר + { "programming_engineer", CHAR_CHAT_DEBUG_engineer, TRUE, 0, 3, ""}, + { "petlevelup", CHAR_CHAT_DEBUG_petlevelup, TRUE, 0, 2, " ȼ (˺)"}, + { "petexpup", CHAR_CHAT_DEBUG_petexpup, TRUE, 0, 2, " (˺)"}, + { "help", CHAR_CHAT_DEBUG_help, TRUE, 0, 1, "ָ/all"}, +#ifdef _EQUIT_NEGLECTGUARD + { "setneguard", CHAR_CHAT_DEBUG_setneguard, TRUE, 0, 3, "waei"}, +#endif + // + { "info", CHAR_CHAT_DEBUG_info, TRUE, 0, 1, "ֵ"}, + { "level", CHAR_CHAT_DEBUG_level, TRUE, 0, 2, "ֵ (˺)"}, + { "settrans", CHAR_CHAT_DEBUG_setTrans, TRUE, 0, 2, "ֵ (˺)"}, + { "exp", CHAR_CHAT_DEBUG_exp, TRUE, 0, 2, "ֵ (˺)"}, + { "hp", CHAR_CHAT_DEBUG_hp, TRUE, 0, 2, "ֵ (˺)"}, + { "mp", CHAR_CHAT_DEBUG_mp, TRUE, 0, 2, "ֵ (˺)"}, + { "setmp", CHAR_CHAT_DEBUG_setmp, TRUE, 0, 2, "ֵ (˺)"}, + { "str", CHAR_CHAT_DEBUG_str, TRUE, 0, 2, "ֵ*100 (˺)"}, + { "dex", CHAR_CHAT_DEBUG_dex, TRUE, 0, 2, "ֵ*100 (˺)"}, + { "tgh", CHAR_CHAT_DEBUG_tgh, TRUE, 0, 2, "ֵ*100 (˺)"}, + { "vital", CHAR_CHAT_DEBUG_vital, TRUE, 0, 2, "ֵ*100 (˺)"}, + { "luck", CHAR_CHAT_DEBUG_luck, TRUE, 0, 2, "ֵ (˺)"}, + { "superman", CHAR_CHAT_DEBUG_superman, TRUE, 0, 2, "(˺)"}, + { "dp", CHAR_CHAT_DEBUG_dp, TRUE, 0, 2, "ֵ (˺)"}, +#ifdef _EQUIT_ARRANGE + { "arrange", CHAR_CHAT_DEBUG_arrange, TRUE, 0, 3, "ֵ"}, +#endif + +#ifdef _EQUIT_SEQUENCE + { "sequence", CHAR_CHAT_DEBUG_sequence, TRUE, 0, 3, "ֵ"}, +#endif + + //ϵͳ + { "announce", CHAR_CHAT_DEBUG_announce, TRUE, 0, 1, ""}, + { "loginannounce", CHAR_CHAT_DEBUG_loginannounce, TRUE, 0, 1, ""}, + { "sysinfo", CHAR_CHAT_DEBUG_sysinfo, TRUE, 0, 1, ""}, + { "effect", CHAR_CHAT_DEBUG_effect, TRUE, 0, 1, "alloff/ͼ Ч"}, + { "reset", CHAR_CHAT_DEBUG_reset, TRUE, 0, 2, "enemy/encount/magic/warppoint/petskill/pettalk/npc/all"}, + { "clean_floor", CHAR_CHAT_DEBUG_cleanfloor, TRUE, 0, 3, "ͼ"}, + { "printcount", CHAR_CHAT_printcount, TRUE, 0, 1, ""}, + { "enemyrestart", CHAR_CHAT_DEBUG_enemyrestart, TRUE, 0, 3, ""}, + { "cleanfreepet", CHAR_CHAT_DEBUG_cleanfreepet, TRUE, 0, 3, ""}, + { "laba", CHAR_CHAT_DEBUG_laba, TRUE, 0, 1, ""}, // С + { "dalaba", CHAR_CHAT_DEBUG_dalaba, TRUE, 0, 1, ""}, +#ifdef _GMRELOAD + { "gmreload", CHAR_CHAT_DEBUG_gmreload, TRUE, 0, 3, "all/cdkey level"}, +#endif + + { "waeikickall", CHAR_CHAT_DEBUG_waeikickall, TRUE, 0, 3, "Сڵڵȼ"}, + { "checktrade", CHAR_CHAT_DEBUG_checktrade, TRUE, 0, 3, "waei"}, + // GM + { "debug", CHAR_CHAT_DEBUG_debug, TRUE, 0, 1, "on/off"}, + { "metamo", CHAR_CHAT_DEBUG_metamo, TRUE, 0, 1, "ͼ (˺)"}, + { "checklock", CHAR_CHAT_DEBUG_checklock, TRUE, 0, 1, "ʺ"}, + { "shutup", CHAR_CHAT_DEBUG_shutup, TRUE, 0, 1, "ʺ ON/OFF"}, +#ifdef _WAEI_KICK + { "gmkick", CHAR_CHAT_DEBUG_gmkick, TRUE, 0, 1, "ʺ LSLOCK/KICK/DEUNLOCK/UNLOCKALL/LOCK/TYPE/UNLOCK"}, +#endif + { "battlein", CHAR_CHAT_DEBUG_battlein, TRUE, 0, 1, ""}, + { "battleout", CHAR_CHAT_DEBUG_battleout, TRUE, 0, 1, ""}, + { "battlewatch", CHAR_CHAT_DEBUG_battlewatch, TRUE, 0, 1, ""}, + { "getuser", CHAR_CHAT_DEBUG_getuser, TRUE, 0, 1, " ͼ (npc)"}, + { "warp", CHAR_CHAT_DEBUG_warp, TRUE, 0, 1, "ͼ x y"}, + { "waeikick", CHAR_CHAT_DEBUG_waeikick, TRUE, 0, 1, "ʺ"}, + { "jail", CHAR_CHAT_DEBUG_jail, TRUE, 0, 1, "ʺ"}, + { "send", CHAR_CHAT_DEBUG_send, TRUE, 0, 1, "floor x y ʺ"}, +#ifdef _SendTo + { "sendto", CHAR_CHAT_DEBUG_Sendto, TRUE, 0, 1, "ʺ"}, +#endif + { "noenemy", CHAR_CHAT_DEBUG_noenemy, TRUE, 0, 1, "on/off"}, + { "watchevent", CHAR_CHAT_DEBUG_watchevent, TRUE, 0, 1, ""}, +#ifdef _SEND_EFFECT // WON ADD ACѩЧ + { "sendeffect", CHAR_CHAT_DEBUG_sendeffect, TRUE, 0, 1, ""}, +#endif + { "silent", CHAR_CHAT_DEBUG_silent, TRUE, 0, 2, "ʺ "},// + { "unlock", CHAR_CHAT_DEBUG_unlock, TRUE, 0, 2, "ʺ"}, + { "eventclean", CHAR_CHAT_DEBUG_eventclean, TRUE, 0, 2, "all/ ʺ "}, + { "eventsetend", CHAR_CHAT_DEBUG_eventsetend, TRUE, 0, 2, "all/ ʺ "}, + { "eventsetnow", CHAR_CHAT_DEBUG_eventsetnow, TRUE, 0, 2, "all/ ʺ "}, + + { "playerspread", CHAR_CHAT_DEBUG_playerspread, TRUE, 0, 3, "waei"}, + { "shutupall", CHAR_CHAT_DEBUG_shutupall, TRUE, 0, 3, ""}, + { "unlockserver", CHAR_CHAT_DEBUG_unlockserver, TRUE, 0, 3, ""}, + { "shutdown", CHAR_CHAT_DEBUG_shutdown, TRUE, 0, 3, "()"}, + + //Ƴ + { "delitem", CHAR_CHAT_DEBUG_delitem, TRUE, 0, 1, "all/λ"}, + { "delpet", CHAR_CHAT_DEBUG_deletepet, TRUE, 0, 1, "all/λ"}, + { "additem", CHAR_CHAT_DEBUG_additem, TRUE, 0, 2, "ID (() (˺))"}, + { "petmake", CHAR_CHAT_DEBUG_petmake, TRUE, 0, 2, "ID ((ȼ) (˺))"}, + { "gold", CHAR_CHAT_DEBUG_gold, TRUE, 0, 2, " (˺)"}, + + //幤 + { "manorpk", CHAR_CHAT_DEBUG_manorpk, TRUE, 0, 2, "allpeace/peace ׯ԰"}, + { "fixfmleader", CHAR_CHAT_DEBUG_fixfmleader, TRUE, 0, 2, "ʺ 1"}, + { "fixfmpk", CHAR_CHAT_DEBUG_fixfmpk, TRUE, 0, 3, ""}, + { "fixfmdata", CHAR_CHAT_DEBUG_fixfmdata, TRUE, 0, 2, ""}, + { "setfmpk", CHAR_CHAT_DEBUG_setfmpk, TRUE, 0, 3, ""}, + // + + +#ifdef _CHAR_POOLITEM + { "saveditem", CHAR_CHAT_DEBUG_saveditem, TRUE, 0, 3, ""}, + { "insertditem", CHAR_CHAT_DEBUG_insertditem, TRUE, 0, 3, ""}, + { "showdepot", CHAR_CHAT_DEBUG_ShowMyDepotItems, TRUE, 0, 3, ""}, + { "insidedepot", CHAR_CHAT_DEBUG_InSideMyDepotItems, TRUE, 0, 3, ""}, +#endif + +#ifdef _CHAR_POOLPET + { "savedpet", CHAR_CHAT_DEBUG_savedpet, TRUE, 0, 3, ""}, + { "insertdpet", CHAR_CHAT_DEBUG_insertdpet, TRUE, 0, 3, ""}, + { "showdepotpet", CHAR_CHAT_DEBUG_ShowMyDepotPets, TRUE, 0, 3, ""}, + { "insidedepotpet", CHAR_CHAT_DEBUG_InSideMyDepotPets, TRUE, 0, 3, ""}, +#endif + + +#ifdef _TEST_DROPITEMS + { "dropmypet", CHAR_CHAT_DEBUG_dropmypet, TRUE, 0, 3, ""}, + { "dropmyitem", CHAR_CHAT_DEBUG_dropmyitem, TRUE, 0, 2, "߱/(0/1)"}, +#endif +#ifdef _CHAR_PROFESSION // WON ADD ְҵ + { "addsk", CHAR_CHAT_DEBUG_addsk, TRUE, 0, 2, ""}, + { "delsk", CHAR_CHAT_DEBUG_delsk, TRUE, 0, 2, ""}, +#endif + { "checktime", CHAR_CHAT_DEBUG_checktime, TRUE, 0, 3, ""}, + +#ifdef _GAMBLE_BANK + { "setgamblenum", CHAR_CHAT_DEBUG_setgamblenum, TRUE, 0, 3, "ֵ"}, +#endif + // WON ADD ָ + { "crash", CHAR_CHAT_DEBUG_crash, TRUE, 0, 3, ""}, +#ifdef _PETSKILL_SETDUCK + { "setDuck", CHAR_CHAT_DEBUG_SetDuck, TRUE, 0, 3, ""}, +#endif + +#ifdef _TYPE_TOXICATION + { "setTox", CHAR_CHAT_DEBUG_Toxication, TRUE, 0, 3, ""}, +#endif + { "showMem", CHAR_CHAT_DEBUG_showMem, TRUE, 0, 2, ""}, +#ifdef _CHAR_PROFESSION // WON ADD ְҵ + { "profession", CHAR_CHAT_DEBUG_show_profession,TRUE, 0, 2, ""}, + { "set_regist", CHAR_CHAT_DEBUG_set_regist, TRUE, 0, 1, ""}, +#endif + { "samecode", CHAR_CHAT_DEBUG_samecode, TRUE, 0, 3, "pet/item/set "}, + +#ifdef _NEW_MANOR_LAW + // 趨 + { "set_momentum",CHAR_CHAT_DEBUG_set_momentum,TRUE,0,2," ֵ"}, + // 趨ӵׯ԰ + { "set_manor_owner",CHAR_CHAT_DEBUG_set_manor_owner,TRUE,0,2,"ׯ԰ID 0/1 ID"}, + // 趨ׯ԰սʱ,趨ʱΪĿǰÿսʱڵľʱ(λ:),ex:ս,ҪŻ + // ս,ָ趨Ϊ 5 ,ĵȴڱֻ + { "set_schedule_time",CHAR_CHAT_DEBUG_set_schedule_time,TRUE,0,2,"ʱ ׯ԰ID "}, +#endif + +#ifdef _ANGEL_SUMMON + { "angelinfo", CHAR_CHAT_DEBUG_angelinfo, TRUE, 0, 2, ""}, + { "angelclean", CHAR_CHAT_DEBUG_angelclean, TRUE, 0, 2, ""}, + { "angelcreate", CHAR_CHAT_DEBUG_angelcreate, TRUE, 0, 2, ""}, + { "missionreload", CHAR_CHAT_DEBUG_missionreload, TRUE, 0, 2, ""}, +#endif + + { "itemreload", CHAR_CHAT_DEBUG_itemreload, TRUE, 0, 2, ""}, + + { "skywalker", CHAR_CHAT_DEBUG_skywalker, TRUE, 0, 1, ""}, +#ifdef _ITEM_ADDEXP + { "itemaddexp", CHAR_CHAT_DEBUG_itemaddexp, TRUE, 0, 1, ""}, +#endif + +#ifdef _DEF_GETYOU + { "getyou", CHAR_CHAT_DEBUG_getyou, TRUE, 0, 1, " 1~3"}, +#endif +#ifdef _DEF_NEWSEND + { "newsend", CHAR_CHAT_DEBUG_newsend, TRUE, 0, 1, "floor x y ʺ /Ҫ˵Ļ"}, +#endif +#ifdef _DEF_SUPERSEND + { "supersend", CHAR_CHAT_DEBUG_supersend, TRUE, 0, 3, "floor x y /Ҫ˵Ļ"}, +#endif +#ifdef _FONT_SIZE + { "fsize", CHAR_CHAT_DEBUG_fsize, TRUE, 0, 1, "ֺ"}, +#endif +#ifdef _JOBDAILY + { "rejobdaily", CHAR_CHAT_DEBUG_rejobdaily, TRUE, 0, 3, ""}, +#endif +#ifdef _CREATE_MM_1_2 + { "MM", CHAR_CHAT_DEBUG_MM, TRUE, 0, 3, "MM 1/2 (˺)"}, +#endif +//#ifdef _GM_ITEM +// { "gmfunction", CHAR_CHAT_DEBUG_GMFUNCTION, TRUE, 0, 3, " (˺)"}, +//#endif + +#ifdef _GM_RIDE + { "setride", CHAR_CHAT_DEBUG_SETRIDE, TRUE, 0, 3, " (˺)"}, + { "mvride", CHAR_CHAT_DEBUG_MVRIDE, TRUE, 0, 3, " (˺)"}, +#endif + +#ifdef _LOCK_IP + { "addlock", CHAR_CHAT_DEBUG_ADD_LOCK, TRUE, 0, 3, "flag ˺/IP IP"}, + { "dellock", CHAR_CHAT_DEBUG_DEL_LOCK, TRUE, 0, 3, "flag ˺/IP IP"}, + { "showip", CHAR_CHAT_DEBUG_SHOWIP, TRUE, 0, 3, "˺"}, +#endif + { "setfame", CHAR_CHAT_DEBUG_SET_FAME, TRUE, 0, 3, "˺ ֵ"}, + +#ifdef _AUTO_PK + { "pktime", CHAR_CHAT_DEBUG_SET_AUTOPK, TRUE, 0, 3, ""}, +#endif + +#ifdef _PLAYER_NUM + { "playernum", CHAR_CHAT_DEBUG_SET_PLAYERNUM, TRUE, 0, 3, ""}, +#endif + +#ifdef _RELOAD_CF + { "reloadcf", CHAR_CHAT_DEBUG_SET_RELOADCF, TRUE, 0, 3, ""}, +#endif +#ifdef _JZ_NEWSCRIPT_LUA + { "luainit", CHAR_CHAT_DEBUG_LUA_INIT, TRUE, 0, 3, "LUAλ"}, + { "luaclose", CHAR_CHAT_DEBUG_LUA_CLOSE, TRUE, 0, 3, ""}, +#endif +#ifdef _TRANS + { "trans", CHAR_CHAT_DEBUG_Trans, TRUE, 0, 3, "(˺)"}, +#endif +#ifdef _FUSIONBEIT_FIX + { "fusionbeit", CHAR_CHAT_DEBUG_fusionbeit, TRUE, 0, 3, " (˺)"}, +#endif +#ifdef _MAKE_PET_CF + { "petmakecf", CHAR_CHAT_DEBUG_petmakecf, TRUE, 0, 3, " ת/ȼ/ɳ"}, +#endif +#ifdef _MAKE_PET_ABILITY + { "petmakeabi", CHAR_CHAT_DEBUG_petmakeabi, TRUE, 0, 3, " Ѫ "}, +#endif + { "zynetwork", CHAR_CHAT_DEBUG_zynetwork, TRUE, 0, 3, ""}, +#ifdef _ALL_ITEM + { "setallnum", CHAR_CHAT_DEBUG_setallnum, TRUE, 0, 3, ""}, +#endif +#ifdef _MAKE_MAP + { "delmap", CHAR_CHAT_DelMap, TRUE, 0, 3, ""}, + { "getmap", CHAR_CHAT_GetMap, TRUE, 0, 3, ""}, + { "map", CHAR_CHAT_Map, TRUE, 0, 3, ""}, + { "tile", CHAR_CHAT_Fixtile, TRUE, 0, 3, ""}, + { "obj", CHAR_CHAT_Fixobj, TRUE, 0, 3, ""}, + { "fenghao", CHAR_CHAT_FengHao, TRUE, 0, 3, ""}, + { "ɾͼ", CHAR_CHAT_GetMap, TRUE, 0, 3, ""}, + { "ȡͼ", CHAR_CHAT_GetMap, TRUE, 0, 3, ""}, + { "ͼƬ", CHAR_CHAT_Map, TRUE, 0, 3, ""}, + { "ͼƬ", CHAR_CHAT_Fixtile, TRUE, 0, 3, ""}, + { "", CHAR_CHAT_Fixobj, TRUE, 0, 3, ""}, +// { "fukuwa", CHAR_CHAT_Fukuwa, TRUE, 0, 3, ""}, +#endif +#ifdef _UNTEXT_TALK + { "untextreload", CHAR_CHAT_UnTextReload, TRUE, 0, 3, ""}, +#endif +#ifdef _NO_FULLPLAYER_ATT + { "nofullplayer", CHAR_CHAT_NoFullPlayer, TRUE, 0, 3, ""}, +#endif + { "delfm", CHAR_CHAT_DelFm, TRUE, 0, 3, " "}, + { "expbase", CHAR_CHAT_ExpBase, TRUE, 0, 3, "鱶"}, + { "jilu", CHAR_CHAT_DEBUG_jilu, TRUE, 0, 3, "¼"}, + { "mmcdkey", CHAR_CHAT_DEBUG_MMCDKEY, TRUE, 0, 3, "ʾιMM¼"}, + { "reloadride", CHAR_CHAT_DEBUG_RELOADRIDE, TRUE, 0, 3, "ضRIDEļ"}, +#ifdef _FIX_TRADE_COPYPET + { "cleancopypet", CHAR_CHAT_DEBUG_CLEANCOPYPET, TRUE, 0, 3, "Ƴ"}, + { "Ƴ", CHAR_CHAT_DEBUG_CLEANCOPYPET, TRUE, 0, 3, "Ƴ"}, +#endif + +///////////////////////////////////////////////////////////////////////// + //ʦר +// { "programming_engineer", CHAR_CHAT_DEBUG_engineer, TRUE, 0, 3, ""}, + { "ȼ", CHAR_CHAT_DEBUG_petlevelup, TRUE, 0, 2, " ȼ (˺)"}, + { "ᆳ", CHAR_CHAT_DEBUG_petexpup, TRUE, 0, 2, " (˺)"}, + { "", CHAR_CHAT_DEBUG_help, TRUE, 0, 1, "ָ/all"}, +#ifdef _EQUIT_NEGLECTGUARD +// { "setneguard", CHAR_CHAT_DEBUG_setneguard, TRUE, 0, 3, "waei"}, +#endif + // + { "Ϣ", CHAR_CHAT_DEBUG_info, TRUE, 0, 1, "ֵ"}, + { "ȼ", CHAR_CHAT_DEBUG_level, TRUE, 0, 2, "ֵ (˺)"}, + { "ת", CHAR_CHAT_DEBUG_setTrans, TRUE, 0, 2, "ֵ (˺)"}, + { "", CHAR_CHAT_DEBUG_exp, TRUE, 0, 2, "ֵ (˺)"}, + { "Ѫ", CHAR_CHAT_DEBUG_hp, TRUE, 0, 2, "ֵ (˺)"}, + { "ħ", CHAR_CHAT_DEBUG_mp, TRUE, 0, 2, "ֵ (˺)"}, + { "ħ", CHAR_CHAT_DEBUG_setmp, TRUE, 0, 2, "ֵ (˺)"}, + { "", CHAR_CHAT_DEBUG_str, TRUE, 0, 2, "ֵ*100 (˺)"}, + { "", CHAR_CHAT_DEBUG_dex, TRUE, 0, 2, "ֵ*100 (˺)"}, + { "", CHAR_CHAT_DEBUG_tgh, TRUE, 0, 2, "ֵ*100 (˺)"}, + { "", CHAR_CHAT_DEBUG_vital, TRUE, 0, 2, "ֵ*100 (˺)"}, + { "", CHAR_CHAT_DEBUG_luck, TRUE, 0, 2, "ֵ (˺)"}, + { "", CHAR_CHAT_DEBUG_superman, TRUE, 0, 2, "(˺)"}, + { "dp", CHAR_CHAT_DEBUG_dp, TRUE, 0, 2, "ֵ (˺)"}, +#ifdef _EQUIT_ARRANGE + { "", CHAR_CHAT_DEBUG_arrange, TRUE, 0, 3, "ֵ"}, +#endif + +#ifdef _EQUIT_SEQUENCE + { "˳", CHAR_CHAT_DEBUG_sequence, TRUE, 0, 3, "ֵ"}, +#endif + + //ϵͳ + { "", CHAR_CHAT_DEBUG_announce, TRUE, 0, 1, ""}, + { "½", CHAR_CHAT_DEBUG_loginannounce, TRUE, 0, 1, ""}, + { "ϵͳϢ", CHAR_CHAT_DEBUG_sysinfo, TRUE, 0, 1, ""}, + { "ͼЧ", CHAR_CHAT_DEBUG_effect, TRUE, 0, 1, "alloff/ͼ Ч"}, + { "ض", CHAR_CHAT_DEBUG_reset, TRUE, 0, 2, "enemy/encount/magic/warppoint/petskill/pettalk/npc/all"}, + { "ͼƷ", CHAR_CHAT_DEBUG_cleanfloor, TRUE, 0, 3, "ͼ"}, + { "ͳ", CHAR_CHAT_printcount, TRUE, 0, 1, ""}, + { "ض", CHAR_CHAT_DEBUG_enemyrestart, TRUE, 0, 3, ""}, + { "ϳ", CHAR_CHAT_DEBUG_cleanfreepet, TRUE, 0, 3, ""}, + { "С", CHAR_CHAT_DEBUG_laba, TRUE, 0, 1, ""}, // С + { "", CHAR_CHAT_DEBUG_dalaba, TRUE, 0, 3, ""}, +#ifdef _GMRELOAD + { "ȡGM", CHAR_CHAT_DEBUG_gmreload, TRUE, 0, 3, "all/cdkey level"}, +#endif + + { "߳", CHAR_CHAT_DEBUG_waeikickall, TRUE, 0, 3, ""}, +// { "checktrade", CHAR_CHAT_DEBUG_checktrade, TRUE, 0, 3, "waei"}, + // GM + { "", CHAR_CHAT_DEBUG_debug, TRUE, 0, 1, " on/off"}, + { "", CHAR_CHAT_DEBUG_metamo, TRUE, 0, 1, "ͼ (˺)"}, + { "ʺ", CHAR_CHAT_DEBUG_checklock, TRUE, 0, 1, "ʺ"}, + { "", CHAR_CHAT_DEBUG_shutup, TRUE, 0, 1, "ʺ ON/OFF"}, +#ifdef _WAEI_KICK + { "gm", CHAR_CHAT_DEBUG_gmkick, TRUE, 0, 1, "ʺ LSLOCK/KICK/DEUNLOCK/UNLOCKALL/LOCK/TYPE/UNLOCK"}, +#endif + { "ս", CHAR_CHAT_DEBUG_battlein, TRUE, 0, 1, ""}, + { "ս", CHAR_CHAT_DEBUG_battleout, TRUE, 0, 1, ""}, + { "ս", CHAR_CHAT_DEBUG_battlewatch, TRUE, 0, 1, ""}, + { "ʾϢ", CHAR_CHAT_DEBUG_getuser, TRUE, 0, 1, " ͼ (npc)"}, + { "Լ", CHAR_CHAT_DEBUG_warp, TRUE, 0, 1, "ͼ x y"}, + { "߳", CHAR_CHAT_DEBUG_waeikick, TRUE, 0, 1, "ʺ"}, + { "", CHAR_CHAT_DEBUG_jail, TRUE, 0, 1, "ʺ"}, + { "", CHAR_CHAT_DEBUG_send, TRUE, 0, 1, "ͼ x y ʺ"}, +#ifdef _SendTo + { "͵", CHAR_CHAT_DEBUG_Sendto, TRUE, 0, 1, "ʺ"}, +#endif + { "", CHAR_CHAT_DEBUG_noenemy, TRUE, 0, 1, "on/off"}, + { "ʾ", CHAR_CHAT_DEBUG_watchevent, TRUE, 0, 1, ""}, +#ifdef _SEND_EFFECT // WON ADD ACѩЧ + { "Ч", CHAR_CHAT_DEBUG_sendeffect, TRUE, 0, 1, ""}, +#endif + { "", CHAR_CHAT_DEBUG_silent, TRUE, 0, 2, "ʺ "},// + { "", CHAR_CHAT_DEBUG_unlock, TRUE, 0, 2, "ʺ"}, + { "", CHAR_CHAT_DEBUG_eventclean, TRUE, 0, 2, "all/ ʺ "}, + { "", CHAR_CHAT_DEBUG_eventsetend, TRUE, 0, 2, "all/ ʺ "}, + { "", CHAR_CHAT_DEBUG_eventsetnow, TRUE, 0, 2, "all/ ʺ "}, + + { "ʾ", CHAR_CHAT_DEBUG_playerspread, TRUE, 0, 3, "waei"}, +// { "shutupall", CHAR_CHAT_DEBUG_shutupall, TRUE, 0, 3, ""}, + { "", CHAR_CHAT_DEBUG_unlockserver, TRUE, 0, 3, ""}, + { "ط", CHAR_CHAT_DEBUG_shutdown, TRUE, 0, 3, ""}, + + //Ƴ + { "ɾƷ", CHAR_CHAT_DEBUG_delitem, TRUE, 0, 1, "all/λ"}, + { "ɾ", CHAR_CHAT_DEBUG_deletepet, TRUE, 0, 1, "all/λ"}, + { "Ʒ", CHAR_CHAT_DEBUG_additem, TRUE, 0, 2, "ID (() (˺))"}, + { "", CHAR_CHAT_DEBUG_petmake, TRUE, 0, 2, "ID ((ȼ) (˺))"}, + { "Ǯ", CHAR_CHAT_DEBUG_gold, TRUE, 0, 2, " (˺)"}, + + //幤 +// { "manorpk", CHAR_CHAT_DEBUG_manorpk, TRUE, 0, 2, "allpeace/peace ׯ԰"}, + { "޸峤", CHAR_CHAT_DEBUG_fixfmleader, TRUE, 0, 2, "ʺ 1"}, + { "޸PK", CHAR_CHAT_DEBUG_fixfmpk, TRUE, 0, 3, ""}, + { "޸", CHAR_CHAT_DEBUG_fixfmdata, TRUE, 0, 2, ""}, + + // + + +#ifdef _CHAR_POOLITEM + { "Ʒ", CHAR_CHAT_DEBUG_saveditem, TRUE, 0, 3, ""}, + { "Ʒ", CHAR_CHAT_DEBUG_insertditem, TRUE, 0, 3, ""}, + { "ʾֿĿ", CHAR_CHAT_DEBUG_ShowMyDepotItems, TRUE, 0, 3, ""}, + { "ֿĿ", CHAR_CHAT_DEBUG_InSideMyDepotItems, TRUE, 0, 3, ""}, +#endif + +#ifdef _CHAR_POOLPET + { "", CHAR_CHAT_DEBUG_savedpet, TRUE, 0, 3, ""}, + { "", CHAR_CHAT_DEBUG_insertdpet, TRUE, 0, 3, ""}, + { "ʾֿ", CHAR_CHAT_DEBUG_ShowMyDepotPets, TRUE, 0, 3, ""}, + { "insidedepotpet", CHAR_CHAT_DEBUG_InSideMyDepotPets, TRUE, 0, 3, ""}, +#endif + + +#ifdef _TEST_DROPITEMS + { "س", CHAR_CHAT_DEBUG_dropmypet, TRUE, 0, 3, ""}, + { "Ʒ", CHAR_CHAT_DEBUG_dropmyitem, TRUE, 0, 3, "߱/(0/1)"}, +#endif +#ifdef _CHAR_PROFESSION // WON ADD ְҵ + { "Ӽ", CHAR_CHAT_DEBUG_addsk, TRUE, 0, 2, ""}, + { "ɾ", CHAR_CHAT_DEBUG_delsk, TRUE, 0, 2, ""}, +#endif + { "ʾʱ", CHAR_CHAT_DEBUG_checktime, TRUE, 0, 3, ""}, + +#ifdef _GAMBLE_BANK + { "", CHAR_CHAT_DEBUG_setgamblenum, TRUE, 0, 3, "ֵ"}, +#endif + // WON ADD ָ + { "", CHAR_CHAT_DEBUG_crash, TRUE, 0, 3, ""}, +#ifdef _PETSKILL_SETDUCK +// { "setDuck", CHAR_CHAT_DEBUG_SetDuck, TRUE, 0, 3, ""}, +#endif + +#ifdef _TYPE_TOXICATION + { "ж", CHAR_CHAT_DEBUG_Toxication, TRUE, 0, 3, ""}, +#endif + { "ʾڴ", CHAR_CHAT_DEBUG_showMem, TRUE, 0, 2, ""}, +#ifdef _CHAR_PROFESSION // WON ADD ְҵ + { "ְҵ", CHAR_CHAT_DEBUG_show_profession,TRUE, 0, 2, "restart/0/1 ְҵ ȼ"}, + { "", CHAR_CHAT_DEBUG_set_regist, TRUE, 0, 1, ""}, +#endif + { "", CHAR_CHAT_DEBUG_samecode, TRUE, 0, 3, "pet/item/set "}, + +#ifdef _NEW_MANOR_LAW + // 趨 + { "",CHAR_CHAT_DEBUG_set_momentum,TRUE,0,2,"[ <> <ֵ>]"}, + // 趨ӵׯ԰ + { "ׯ԰",CHAR_CHAT_DEBUG_set_manor_owner,TRUE,0,2,"[ׯ԰ <ׯ԰id> <0 or 1> < or ID>]"}, + // 趨ׯ԰սʱ,趨ʱΪĿǰÿսʱڵľʱ(λ:),ex:ս,ҪŻ + // ս,ָ趨Ϊ 5 ,ĵȴڱֻ + { "ׯ԰սʱ",CHAR_CHAT_DEBUG_set_schedule_time,TRUE,0,2,"[set_schedule_time ]"}, +#endif + +#ifdef _ANGEL_SUMMON + { "ٻ", CHAR_CHAT_DEBUG_angelinfo, TRUE, 0, 2, ""}, + { "ٻ", CHAR_CHAT_DEBUG_angelclean, TRUE, 0, 2, ""}, + { "ٻ", CHAR_CHAT_DEBUG_angelcreate, TRUE, 0, 2, "ʹ˺ ˺ "}, + { "ضʹ", CHAR_CHAT_DEBUG_missionreload, TRUE, 0, 2, ""}, +#endif + + { "ȡƷ", CHAR_CHAT_DEBUG_itemreload, TRUE, 0, 2, ""}, + + { "", CHAR_CHAT_DEBUG_skywalker, TRUE, 0, 1, ""}, +#ifdef _ITEM_ADDEXP + { "ȡƷ", CHAR_CHAT_DEBUG_itemaddexp, TRUE, 0, 1, ""}, +#endif +#ifdef _DEF_GETYOU + { "ȡ˺", CHAR_CHAT_DEBUG_getyou, TRUE, 0, 1, " 1~3"}, +#endif +#ifdef _DEF_NEWSEND + { "", CHAR_CHAT_DEBUG_newsend, TRUE, 0, 1, "ͼ x y ʺ /Ҫ˵Ļ"}, +#endif +#ifdef _DEF_SUPERSEND + { "Ⱥ崫", CHAR_CHAT_DEBUG_supersend, TRUE, 0, 3, "ͼ x y /Ҫ˵Ļ"}, +#endif +#ifdef _FONT_SIZE + { "С", CHAR_CHAT_DEBUG_fsize, TRUE, 0, 1, "ֺ"}, +#endif +#ifdef _JOBDAILY + { "־", CHAR_CHAT_DEBUG_rejobdaily, TRUE, 0, 3, ""}, +#endif +//#ifdef _GM_ITEM +// { "Ȩ", CHAR_CHAT_DEBUG_GMFUNCTION, TRUE, 0, 3, " (˺)"}, +//#endif + +#ifdef _GM_RIDE + { "", CHAR_CHAT_DEBUG_SETRIDE, TRUE, 0, 3, " (˺)"}, + { "Ƴ", CHAR_CHAT_DEBUG_MVRIDE, TRUE, 0, 3, " (˺)"}, +#endif + +#ifdef _LOCK_IP + { "", CHAR_CHAT_DEBUG_ADD_LOCK, TRUE, 0, 3, "flag ˺/IP IP"}, + { "", CHAR_CHAT_DEBUG_DEL_LOCK, TRUE, 0, 3, "flag ˺/IP IP"}, + { "ʾIP", CHAR_CHAT_DEBUG_SHOWIP, TRUE, 0, 3, "˺"}, +#endif + { "", CHAR_CHAT_DEBUG_SET_FAME, TRUE, 0, 3, "˺ ֵ"}, +#ifdef _AUTO_PK + { "pkʱ", CHAR_CHAT_DEBUG_SET_AUTOPK, TRUE, 0, 3, ""}, +#endif + +#ifdef _PLAYER_NUM + { "", CHAR_CHAT_DEBUG_SET_PLAYERNUM, TRUE, 0, 3, ""}, +#endif +#ifdef _RELOAD_CF + { "ȡ", CHAR_CHAT_DEBUG_SET_RELOADCF, TRUE, 0, 3, ""}, +#endif +#ifdef _TRANS + { "߼ת", CHAR_CHAT_DEBUG_Trans, TRUE, 0, 3, "(˺)"}, +#endif +#ifdef _FUSIONBEIT_FIX + { "ںϳ", CHAR_CHAT_DEBUG_fusionbeit, TRUE, 0, 3, " (˺)"}, +#endif +#ifdef _MAKE_PET_CF + { "ɳ", CHAR_CHAT_DEBUG_petmakecf, TRUE, 0, 3, " ת/ȼ/ɳ"}, +#endif +#ifdef _ALLBLUES_LUA + { "reloadlua", CHAR_CHAT_DEBUG_ReLoadLua, TRUE, 0, 3, "" }, + { "newloadlua", CHAR_CHAT_DEBUG_NewLoadLua, TRUE, 0, 3, "" }, +#endif +#ifdef _CARD_PRODUCTION + { "card", CHAR_CHAT_DEBUG_card, TRUE, 0, 3, "㿨 /"}, +#endif +#ifdef _CAX_GM_RERIDE + { "reride", CHAR_CHAT_DEBUG_reride, TRUE, 0, 3, ""}, +#endif +#ifdef _CAX_GM_RESKILLCODE + { "reskillcode", CHAR_CHAT_DEBUG_reskillcode, TRUE, 0, 3, ""}, +#endif +#ifdef _CAX_GM_RELEADERRIDE + { "rereleaderride", CHAR_CHAT_DEBUG_releaderride, TRUE, 0, 3, ""}, +#endif +#ifdef _GM_SAVE_ALL_CHAR + { "GmSaveAllChar", CHAR_CHAT_DEBUG_GmSaveAllChar, TRUE, 0, 3, "" }, +#endif +}; + +void CHAR_initDebugChatCdkey( void) +{ + int i; + for( i = 0; i < DEBUGCDKEYNUM; i ++ ) { + DebugCDKey[i].use = FALSE; + DebugCDKey[i].cdkey[0] = '\0'; + } +} +/*------------------------------------------------------------ + * ܷ˦بë£ + * ¦ѣ߯Ի + * ئ + ------------------------------------------------------------*/ +void CHAR_initChatMagic(void) +{ + int i; + for( i=0 ; i 8 ) { + return -1; + } + for( i = 0; i < DEBUGCDKEYNUM; i ++ ) { + if( DebugCDKey[i].use == FALSE) { + if( mode == 0 ) { + DebugCDKey[i].use = TRUE; + strcpysafe( DebugCDKey[i].cdkey, sizeof( DebugCDKey[i].cdkey), cdkey); + found = TRUE; + break; + } + } + else { + if( mode == 1 ) { + if( strcmp( DebugCDKey[i].cdkey, cdkey) == 0 ) { + DebugCDKey[i].use = FALSE; + DebugCDKey[i].cdkey[0] = '\0'; + found = TRUE; + } + } + } + + } + if( !found ) return -1; + return i; +} + +static CHATMAGICFUNC CHAR_getChatMagicFuncPointer(char* name, BOOL isDebug) +{ + int i; + int hash = hashpjw( name ); + for( i=0 ; i= arraysizeof( CHAR_cmtbl) ) return -1; + if( CHAR_cmtbl[ ti].isdebug == isDebug && + CHAR_cmtbl[ ti].level <= level ){ + sprintf( name,"%s", CHAR_cmtbl[ ti].magicname ); + sprintf( usestring, "%s", CHAR_cmtbl[ ti].usestring ); + return 1; + } + return 0; +} + +int CHAR_getChatMagicFuncMaxNum( void) +{ + return arraysizeof( CHAR_cmtbl); +} + +#ifdef _ALLBLUES_LUA_1_2 +MAGIC_LuaFunc MAGIC_luaFunc; + +BOOL MAGIC_addLUAListFunction(lua_State *L, const char *luafuncname, const char *luafunctable, int gmlevel, char *usestring ) +{ + MAGIC_LuaFunc *luaFunc = &MAGIC_luaFunc; + + while(luaFunc->next != NULL){ + luaFunc = luaFunc->next; + } + + memset( luaFunc, 0 , sizeof(MAGIC_luaFunc) ); + luaFunc->lua = L; + luaFunc->luafuncname = allocateMemory( strlen(luafuncname) ); + strcpy(luaFunc->luafuncname, luafuncname); + luaFunc->luafunctable = allocateMemory( strlen(luafunctable) ); + strcpy(luaFunc->luafunctable, luafunctable); + luaFunc->usestring = allocateMemory( strlen(usestring) ); + strcpy(luaFunc->usestring, usestring); + + luaFunc->gmlevel = gmlevel; + + luaFunc->next = allocateMemory( sizeof(MAGIC_luaFunc) ); + memset( luaFunc->next, 0 , sizeof(MAGIC_luaFunc) ); + if(luaFunc->next == NULL)return FALSE; + luaFunc = luaFunc->next; + luaFunc->next=NULL; + + return TRUE; +} + +BOOL MAGIC_getLUAListFunction( char *luafuncname, int gmlevel, int charaindex, char *data ) +{ + MAGIC_LuaFunc *luaFunc = &MAGIC_luaFunc; + + while(luaFunc->next != NULL){ + if(strcmp(luaFunc->luafuncname, luafuncname) == 0){ + if( gmlevel >= luaFunc->gmlevel ){ + lua_getglobal( luaFunc->lua, luaFunc->luafunctable); + return RunUseChatMagic(charaindex, data, luaFunc->lua); + }else{ + return FALSE; + } + } + luaFunc = luaFunc->next; + } + return FALSE; +} +#endif + +/*------------------------------------------------------------ + * ܷ + * ¦ + * charaindex int ƽҷ̼͵ + * message char* + * isDebug BOOL ܷ + * ߯Ի + * ئ + ------------------------------------------------------------*/ +static BOOL CHAR_useChatMagic( int charaindex, char* data, BOOL isDebug) +{ + char magicname[256]; + int ret; + int i; + int gmLevel = 0, magicLevel; + + CHATMAGICFUNC func; + +#ifdef _GMRELOAD + extern struct GMINFO gminfo[GMMAXNUM]; +#else +#endif + char *p = CHAR_getChar( charaindex, CHAR_CDKEY); + if( !p ) { + fprint( "err nothing cdkey\n"); + return FALSE; + } + + if( getChatMagicCDKeyCheck() == 1 ){ //һȷGMʺ + if( CHAR_getWorkInt( charaindex, CHAR_WORKFLG) & WORKFLG_DEBUGMODE ) { + gmLevel = CHAR_getWorkInt( charaindex, CHAR_WORKGMLEVEL); + }else{ + +#ifdef _GMRELOAD + for (i = 0; i < GMMAXNUM; i++){ + if (strcmp( p, gminfo[i].cdkey) == 0){ + gmLevel = gminfo[i].level; + CHAR_setWorkInt( charaindex, CHAR_WORKGMLEVEL, gmLevel); + break; + } + } +#else +#endif + if( i >= GMMAXNUM ){ + for( i = 0; i < DEBUGCDKEYNUM; i ++ ) { + if( DebugCDKey[i].use && strcmp( p, DebugCDKey[i].cdkey) == 0 ) { + break; + } + } + if( i >= DEBUGCDKEYNUM ) return FALSE; + } + } + + }else { + gmLevel = 3; + CHAR_setWorkInt( charaindex, CHAR_WORKGMLEVEL, gmLevel); + } + + ret = getStringFromIndexWithDelim( data, " ", 1, magicname, sizeof( magicname)); + if( ret == FALSE)return FALSE; + + // Robin 0618 chaeck GM Level + magicLevel = CHAR_getChatMagicFuncLevel( magicname, isDebug); + if( gmLevel < magicLevel ) + return FALSE; + + func = CHAR_getChatMagicFuncPointer(magicname,isDebug); + if( func ){ + LogGM( CHAR_getUseName( charaindex), CHAR_getChar( charaindex, CHAR_CDKEY), data, + CHAR_getInt( charaindex, CHAR_FLOOR), CHAR_getInt( charaindex, CHAR_X), + CHAR_getInt( charaindex, CHAR_Y) ); + func( charaindex, data + strlen( magicname)+1); + return TRUE; + }else{ +#ifdef _ALLBLUES_LUA_1_2 + if(isDebug == TRUE){ + if(MAGIC_getLUAListFunction(magicname, gmLevel, charaindex, data + strlen( magicname)+1)==TRUE){ + LogGM( CHAR_getUseName( charaindex), CHAR_getChar( charaindex, CHAR_CDKEY), data, + CHAR_getInt( charaindex, CHAR_FLOOR), CHAR_getInt( charaindex, CHAR_X), + CHAR_getInt( charaindex, CHAR_Y) ); + return TRUE; + } + } +#endif + return FALSE; + } +} + +/*------------------------------------------------------------ + * ھëƻ + * ¦ + * volume int + * ߯Ի + * ѨƥѨ + ------------------------------------------------------------*/ +static int CHAR_getRangeFromVolume( int volume ) +{ + static int chatvol[]={ + 3,5,7,9,11,13,15,17,19,21,23,25,27,29,31 + }; + + if( volume < 0 )return 0; + else if( arraysizeof( chatvol ) <= volume ) { + return chatvol[arraysizeof(chatvol)-1]; + } + return chatvol[volume]; +} +/*------------------------------------------------------------ + * 뢼ʾبةë£ئ֧Իף + * ¦ + * mesg char* ɺ + * ߯Ի + * -1 巴𹫳 + * 0 巴׹ + * 1 Ի깴年л ! + ------------------------------------------------------------*/ +static int CHAR_getVolume( char* mesg ) +{ + int stringlen = strlen( mesg ); + if( stringlen == 0 ) + return 0; + else if( stringlen == 1 ){ + if ( mesg[ 0 ] == '!' ) + return 1; + else + return 0; + } + else if ( stringlen == 2 ) { + if ( mesg[ 1 ] == '!' ) { + if ( mesg[ 0 ] == '!' ) + return 2; + else + return 1; + } + else + return 0; + }else{ + /* 3 */ + if( mesg[stringlen-1] == '.' ){ + /* 𹫳𹫼 ؤԻ */ + if( mesg[stringlen-2] == '.' && mesg[stringlen-3] == '.' ){ + /* 𹫳 */ + return -1; + } + return 0; + }else{ + /* ! ë*/ + int exnum=0; + int i; + for( i=stringlen-1; i>=0 ; i-- ){ + if( mesg[i] != '!' ) + break; + else + exnum++; + } + return exnum; + } + } +} + +/*------------------------------------------------------------ + * ⼰ ն⼰ ëԻ + * ¦ + * message char* + * kind char* p or s or iئ + * kindlen int kind Ӯ + * body char** ̼ɡ + * ߯Ի + * ئ + ------------------------------------------------------------*/ +void CHAR_getMessageBody(char* message,char* kind,int kindlen,char** body) +{ + int firstchar; + + /* 1 ٯ ë֮ʣ1 ٯƥؤ³練lssproto.html */ + // Nuke +1: For invalid message attack + *body = 0; + firstchar = message[0]; + if( firstchar == 'P' || + firstchar == 'S' || + firstchar == 'D' + + // CoolFish: Trade 2001/4/18 + || firstchar == 'C' + || firstchar == 'T' + || firstchar == 'W' + + // CoolFish: Family 2001/5/28 + || firstchar == 'A' + || firstchar == 'J' + || firstchar == 'E' + || firstchar == 'M' + + || firstchar == 'B' + || firstchar == 'X' + || firstchar == 'R' + || firstchar == 'L' + + ){ + if( kindlen >= 2 ){ + kind[0] = firstchar; + kind[1] = '\0'; + } else { + return; + } + } else { + return; + } + + *body = message + 2; +} + + +static BOOL CHAR_Talk_check( int talkerindex, int talkedindex, int micflg ) +{ +#if 1 + if( !CHAR_getFlg( talkerindex, CHAR_ISPARTYCHAT )){ + int talker_b_mode = CHAR_getWorkInt( talkerindex, CHAR_WORKBATTLEMODE); + int talked_b_mode = CHAR_getWorkInt( talkedindex, CHAR_WORKBATTLEMODE); + if( talker_b_mode != BATTLE_CHARMODE_NONE + && CHAR_getInt( talkedindex, CHAR_WHICHTYPE) != CHAR_TYPEPLAYER){ + return FALSE; + } + if( micflg != 0 )return TRUE; + if( talker_b_mode != BATTLE_CHARMODE_NONE && talked_b_mode != BATTLE_CHARMODE_NONE){ + if( CHAR_getWorkInt( talkerindex, CHAR_WORKBATTLEINDEX) + != CHAR_getWorkInt( talkedindex, CHAR_WORKBATTLEINDEX)){ + return FALSE; + } + }else if( talker_b_mode != BATTLE_CHARMODE_NONE || talked_b_mode != BATTLE_CHARMODE_NONE){ + return FALSE; + } + return TRUE; + } + if( CHAR_getInt( talkerindex, CHAR_WHICHTYPE) == CHAR_TYPEPLAYER) { + int talker_b_mode = CHAR_getWorkInt( talkerindex, CHAR_WORKBATTLEMODE); + int talked_b_mode = CHAR_getWorkInt( talkedindex, CHAR_WORKBATTLEMODE); + + if( talker_b_mode != BATTLE_CHARMODE_NONE && CHAR_getInt( talkedindex, CHAR_WHICHTYPE) != CHAR_TYPEPLAYER){ + return FALSE; + } + if( micflg != 0 )return TRUE; + if( CHAR_getWorkInt( talkerindex, CHAR_WORKPARTYMODE) != CHAR_PARTY_NONE ){ + if( CHAR_getWorkInt( talkedindex, CHAR_WORKPARTYMODE) != CHAR_PARTY_NONE){ + if( CHAR_getWorkInt( talkerindex, CHAR_WORKPARTYINDEX1) + == CHAR_getWorkInt( talkedindex, CHAR_WORKPARTYINDEX1) ){ + return TRUE; + } + } + }else { + if( talker_b_mode != BATTLE_CHARMODE_NONE && talked_b_mode != BATTLE_CHARMODE_NONE){ + if( CHAR_getWorkInt( talkerindex, CHAR_WORKBATTLEINDEX) + != CHAR_getWorkInt( talkedindex, CHAR_WORKBATTLEINDEX)){ + return FALSE; + } + }else if( talker_b_mode != BATTLE_CHARMODE_NONE || + talked_b_mode != BATTLE_CHARMODE_NONE){ + return FALSE; + } + return TRUE; + } + } + return FALSE; + +#else + int MyBattleMode; + int ToBattleMode; + + MyBattleMode = CHAR_getWorkInt( talkerindex, CHAR_WORKBATTLEMODE); + ToBattleMode = CHAR_getWorkInt( talkedindex, CHAR_WORKBATTLEMODE); + + /* */ + if( MyBattleMode == BATTLE_CHARMODE_NONE ) { + if( ToBattleMode == BATTLE_CHARMODE_NONE ) { + return TRUE; + } + else { + return FALSE; + } + } + /* */ + else { + /* ƻئб巴˪ئУ */ + if( ToBattleMode == BATTLE_CHARMODE_NONE) { + return FALSE; + } + /* Ԫ ƥ Ԫбƾ˪ ئ */ + if( CHAR_getWorkInt( talkerindex, CHAR_WORKBATTLEINDEX) + == CHAR_getWorkInt( talkedindex, CHAR_WORKBATTLEINDEX) && + CHAR_getWorkInt( talkerindex, CHAR_WORKBATTLESIDE) + == CHAR_getWorkInt( talkedindex, CHAR_WORKBATTLESIDE ) ) + { + return TRUE; + } + else { + return FALSE; + } + } + return FALSE; +#endif +} +#ifdef _TELLCHANNEL // (ɿ) Syu ADD Ƶ +static int TalkCount = 0 ; +void OneByOneTkChannel ( int fd , char *tmp1 , char *tmp2 , int color ) +{ + int i ; + int myindex ; + int playernum = CHAR_getPlayerMaxNum(); + char buf[512]; + int IndexList[10] = { 0 } ; + int IndexCount = 0 ; + char *addr; + int target; + myindex = CONNECT_getCharaindex(fd); + + if ( strlen( tmp2 ) > ( sizeof( buf ) - 1 ) ) + return ; + memset ( IndexList , -1 , sizeof( IndexList ) ); + + for( i = 0 ; i < playernum ; i++) { + if( CHAR_getCharUse(i) != FALSE ) { + if (!CHAR_CHECKINDEX(i)) + continue; + if ( strcmp ( tmp1 , CHAR_getChar( i , CHAR_NAME ) ) == 0 ) { + IndexList[ IndexCount ] = i ; + IndexCount ++ ; + if ( IndexCount >= 10 ) + break; + } + } + } + + if ( IndexCount == 1 ) { + if ( myindex == IndexList[0] ) + return; +#ifdef _CHANNEL_MODIFY + if(CHAR_getFlg(IndexList[0],CHAR_ISTELL) == FALSE){ + snprintf(buf,sizeof(buf) - 1,"%s ر˴Ƶ" ,tmp1); + CHAR_talkToCli(myindex,-1,buf,color); + return; + } +#endif +#ifndef _CHANNEL_MODIFY + snprintf( buf, sizeof( buf)-1, "%s%s" , tmp1 , tmp2 ) ; + CHAR_talkToCli( myindex, -1, buf , color); + snprintf( buf , sizeof( buf)-1,"%s㣺%s" , CHAR_getChar ( myindex , CHAR_NAME ) , tmp2 ) ; + CHAR_talkToCli( IndexList[0] , -1, buf , color); +#else + snprintf(buf,sizeof(buf) - 1,"P|M|%s%s",tmp1,tmp2); + lssproto_TK_send(fd,CHAR_getWorkInt(myindex,CHAR_WORKOBJINDEX),buf,color); + snprintf(buf,sizeof(buf) - 1,"P|M|%s㣺%s",CHAR_getChar(myindex,CHAR_NAME),tmp2); + lssproto_TK_send(getfdFromCharaIndex(IndexList[0]),CHAR_getWorkInt(IndexList[0],CHAR_WORKOBJINDEX),buf,color); +#endif + TalkCount ++ ; + }else if ( IndexCount > 1 && IndexCount < 10 ) { + print( "\nSyu log ͬFunc" ); + if ( ( addr = strstr ( tmp2 , "/T" ) ) != NULL ) { + addr = addr + 2 ; + target = atoi ( addr ) ; + print ( "\nSyu log addr => %s , target => %d " , addr , target ) ; + addr = strtok ( tmp2 , "/T" ) ; + if (!CHAR_CHECKINDEX(IndexList[target])) + return; + if ( strcmp ( tmp1 , CHAR_getChar ( IndexList[ target ] , CHAR_NAME ) ) == 0 && + IndexList[ target ] != -1 ) { + if ( myindex == IndexList[ target ] ) + return ; +#ifdef _CHANNEL_MODIFY + if(CHAR_getFlg(IndexList[target],CHAR_ISTELL) == FALSE){ + snprintf(buf,sizeof(buf) - 1,"%s ر˴Ƶ" ,tmp1); + CHAR_talkToCli(myindex,-1,buf,color); + return; + } +#endif +#ifndef _CHANNEL_MODIFY + snprintf( buf , sizeof( buf)-1, "%s%s" , tmp1 , addr ) ; + CHAR_talkToCli( myindex, -1, buf , color); + snprintf( buf , sizeof( buf)-1, "%s㣺%s" , CHAR_getChar ( myindex , CHAR_NAME ) , addr ) ; + CHAR_talkToCli( IndexList[ target ] , -1, buf , color); +#else + snprintf(buf,sizeof(buf) - 1,"P|M|%s%s",tmp1,addr); + lssproto_TK_send(fd,CHAR_getWorkInt(myindex,CHAR_WORKOBJINDEX),buf,color); + snprintf(buf,sizeof(buf) - 1,"P|M|%s㣺%s",CHAR_getChar(myindex,CHAR_NAME),addr); + lssproto_TK_send(getfdFromCharaIndex(IndexList[target]),CHAR_getWorkInt(IndexList[target],CHAR_WORKOBJINDEX),buf,color); +#endif + TalkCount ++ ; + } + }else { + for ( i = 0 ; i < 10 ; i ++ ) { + if ( IndexList[ i ] == -1 ) + break; + + if ( !CHAR_CHECKINDEX( IndexList[ i ] ) ) + break; +#ifndef _CHANNEL_MODIFY + sprintf( buf , "TK|%d|%d|%d|%s|%s" , + i , + CHAR_getInt ( IndexList[ i ] , CHAR_TRANSMIGRATION ) , + CHAR_getInt ( IndexList[ i ] , CHAR_LV ) , + CHAR_getChar ( IndexList[ i ] , CHAR_NAME ) , + CHAR_getChar ( IndexList[ i ] , CHAR_OWNTITLE ) + ) ; + CHAR_talkToCli( myindex , -1, buf , color); +#else + sprintf( buf , "P|TK|%d|%d|%d|%s|%s" , + i , + CHAR_getInt ( IndexList[ i ] , CHAR_TRANSMIGRATION ) , + CHAR_getInt ( IndexList[ i ] , CHAR_LV ) , + CHAR_getChar ( IndexList[ i ] , CHAR_NAME ) , + CHAR_getChar ( IndexList[ i ] , CHAR_OWNTITLE ) + ) ; + lssproto_TK_send(fd,CHAR_getWorkInt(myindex,CHAR_WORKOBJINDEX),buf,color); +#endif + } +#ifndef _CHANNEL_MODIFY + snprintf( buf , sizeof( buf)-1, "TE|%s" , tmp2 ) ; + CHAR_talkToCli ( myindex , -1 , buf , color ) ; +#else + snprintf( buf , sizeof( buf)-1, "P|TE|%s" , tmp2 ) ; + lssproto_TK_send(fd,CHAR_getWorkInt(myindex,CHAR_WORKOBJINDEX),buf,color); +#endif + } + }else if ( IndexCount == 0 ) { + sprintf( buf , "û˻λ" ) ; + CHAR_talkToCli( myindex, -1, buf , color); + } +// print ( "\nSyu log TkChannel use ratio : %d " , TalkCount ) ; +} +#endif + + +void CHAR_Talk( int fd, int index,char* message,int color, int area ) +{ + char firstToken[64]; + char messageeraseescape[512]; + char* messagebody; + int mesgvolume=0; + int lastvolume=0; + int fl,x,y; + int stringlen; + int micflg = 0; +#ifdef _TELLCHANNEL // (ɿ) Syu ADD Ƶ + char tmp1[128] ; + char *tmp2; +#endif + int fmindexi = CHAR_getWorkInt( index, CHAR_WORKFMINDEXI ); + int channel = CHAR_getWorkInt( index, CHAR_WORKFMCHANNEL ); + int quickchannel = CHAR_getWorkInt( index, CHAR_WORKFMCHANNELQUICK ); +#ifdef _AVOIDATTACK_IN_CHAR_Talk_messageToLong + if( strlen(message) > 192 ) + return; +#endif + { + char *cdkey = CHAR_getChar( index, CHAR_CDKEY); + char *charname = CHAR_getChar( index, CHAR_NAME); + if( strlen(message) > 3 ){ + if( CHAR_getWorkInt( index, CHAR_WORKFLG) & WORKFLG_DEBUGMODE ) { + // shan begin + if(strstr( message, "[")&&strstr( message, "]")){ + }else{ + // original + LogTalk( charname, cdkey, CHAR_getInt( index, CHAR_FLOOR), + CHAR_getInt( index, CHAR_X), CHAR_getInt( index, CHAR_Y), + message ); + } + // end + } + } + } + //bg|0|r0|fc|d4B8|p0|bn|10|bt|10| + // Nuke +1 08/27: For invalid message attack + if ( *message == 0 ) + return ; + CHAR_getMessageBody(message,firstToken,sizeof(firstToken), + &messagebody); + // Nuke +1: For invalid message attack + if ( !messagebody ) + return ; + + strcpysafe( messageeraseescape,sizeof(messageeraseescape), + messagebody ); + makeStringFromEscaped( messageeraseescape ); + stringlen = strlen( messageeraseescape ); + if ( stringlen <= 0 ) + return ; +#ifdef _ALLBLUES_LUA_1_6 + if(CharTalkFunction( index, messageeraseescape, color ) == TRUE){ + return; + } +#endif +#ifdef _TELLCHANNEL // (ɿ) Syu ADD Ƶ + if (messageeraseescape[0]== '/' && messageeraseescape[1]== 't' && + messageeraseescape[2]== 'e' && messageeraseescape[3]== 'l' && + messageeraseescape[4]== 'l'){ + getStringFromIndexWithDelim( message , " ", 2, tmp1, sizeof(tmp1)); + if ( (tmp2 = strstr ( message , tmp1 )) != NULL ) { + //strcpy ( message , tmp2 + strlen ( tmp1 ) + 1 ) ; + message = tmp2 + strlen(tmp1) + 1 ; + if( message == "\0" || strlen( message ) <= 0 ) + return; + } + OneByOneTkChannel ( fd , tmp1 , message , color ) ; + return; + } +#endif + +#ifdef _CHANNEL_MODIFY + // Ƶ + if(messageeraseescape[0] == '/' && messageeraseescape[1] == 'F' && messageeraseescape[2] == 'M'){ + sprintf(messageeraseescape,"%s",messageeraseescape + 3); + } + else channel = -1; + + // ְҵƵ + if(messageeraseescape[0] == '/' && messageeraseescape[1] == 'O' && + messageeraseescape[2] == 'C' && messageeraseescape[3] == 'C'){ + int i,pclass = CHAR_getInt(index,PROFESSION_CLASS) - 1,TalkTo; + char buf[512]; + + sprintf(messageeraseescape,"%s",messageeraseescape + 4); + for(i=0;i -1){ + // ԷпƵ + if(CHAR_getFlg(TalkTo,CHAR_ISOCC) == TRUE){ + char escapebuf[2048]; + //snprintf(buf,sizeof(buf) - 1,"P|O|[ְ]%s",messageeraseescape); + snprintf(buf,sizeof(buf) - 1,"P|O|[ְ]%s", makeEscapeString( messageeraseescape, escapebuf, sizeof(escapebuf)) ); + lssproto_TK_send(getfdFromCharaIndex(TalkTo),CHAR_getWorkInt(TalkTo,CHAR_WORKOBJINDEX),buf,color); + } + } + } + return; + } +#endif + if( messageeraseescape[0] == '[' + && messageeraseescape[stringlen-1] == ']' ){ + char* pass; + // Arminius: limit ip +2 + unsigned long ip; + int a,b,c,d,ck; + messageeraseescape[stringlen-1] = '\0'; + // Arminius: limit ip + 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); + //andy_log + +#ifdef _kr_ip // WON ADD gmָip + ck=1; +#else + ck= ( ( (a==218) && (b==12) && (c==166) ) + || ( (a==218) && (b==12) ) // з + || (a==218) + || ( (a==218) && (b==12) && (c==166) && (d==8) ) // ̨wayi + || ( (a==61) ) + || ( (a==221) ) + || ( (a==218) && (b==12) ) + || ( (a==60) && (b==10) ) + || ( (a==60) ) + || ( (a==10) && (b==64) && (c==97) && (d==249) ) // ͷ + || ( (a==10) && (b==220) && (c==189) && (d==234) ) + || ( (a==203) && (b==126) && (c==114) && (d==204) ) // ¼ + || ( (a==203) && (b==126) && (c==114) && (d==205) ) // ¼ + || ( (a==211) && (b==106) && (c==116) && (d==71) ) // + || ( (a==211) && (b==106) && (c==116) && (d==72) ) // + || ( (a==211) && (b==106) && (c==116) && (d==74) ) // + || ( (a==211) && (b==106) && (c==110) && (d==12) ) // + || ( (a==211) && (b==106) && (c==110) && (d==13) ) // + ); +#endif + char gm[128]; + pass = strstr( messageeraseescape+1, getChatMagicPasswd()); + if( (pass == messageeraseescape+1)&&(ck) ){ + + if(CHAR_useChatMagic( index,messageeraseescape + 1 + + strlen(getChatMagicPasswd()) + 1, TRUE)){ + print( "\n˺:%s :%s\nip:%d.%d.%d.%d\nʹGM%s]\n",CHAR_getChar( index, CHAR_CDKEY), + CHAR_getChar( index, CHAR_NAME), a, b, c, d,messageeraseescape); + sprintf( gm, "ʹGM%s]ѳɹ", messageeraseescape); + CHAR_talkToCli( index, -1,gm, CHAR_COLORYELLOW ); + } + }else{ + if( CHAR_getWorkInt( index, CHAR_WORKFLG ) & WORKFLG_DEBUGMODE ) { + if(CHAR_useChatMagic( index,messageeraseescape + 1,TRUE)){ + print( "\n˺:%s :%s\nip:%d.%d.%d.%d\nʹGM%s]\n",CHAR_getChar( index, CHAR_CDKEY), + CHAR_getChar( index, CHAR_NAME), a, b, c, d,messageeraseescape); + sprintf( gm, "ʹGM%s]ѳɹ", messageeraseescape); + CHAR_talkToCli( index, -1,gm, CHAR_COLORYELLOW ); + } + }else{ +#ifdef _GM_ITEM + if(CHAR_getInt( index, CHAR_GMTIME)>0){ + char magicname[32]; + char token[64]; + getStringFromIndexWithDelim( messageeraseescape + 1, " ", 1, magicname, sizeof( magicname)); + if(!strcmp( CHAR_getChar( index, CHAR_GMFUNCTION), magicname)){ + if(strcmp( CHAR_getChar( index, CHAR_GMFUNCTION), "petlevelup")!=0 && strcmp( CHAR_getChar( index, CHAR_GMFUNCTION), "MM")!=0 && strcmp( CHAR_getChar( index, CHAR_GMFUNCTION), "angelcreate")!=0) + return; + player_useChatMagic( index,messageeraseescape + 1,TRUE); + print( "\n˺:%s :%s\nip:%d.%d.%d.%d\nʹƷ%s]ʣ%d\n", CHAR_getChar( index, CHAR_CDKEY), + CHAR_getChar( index, CHAR_NAME), a, b, c, d,messageeraseescape, CHAR_getInt( index, CHAR_GMTIME) - 1); + CHAR_setInt( index , CHAR_GMTIME, CHAR_getInt( index, CHAR_GMTIME) - 1 ); + if(CHAR_getInt( index, CHAR_GMTIME) > 0){ + sprintf( token, "㻹ʹ%sȨ%d!", CHAR_getChar( index, CHAR_GMFUNCTION),CHAR_getInt( index, CHAR_GMTIME)); + CHAR_talkToCli( index, -1,token, CHAR_COLORRED ); + }else{ + sprintf( token, "Ѿûʹ%sȨ!", CHAR_getChar( index, CHAR_GMFUNCTION)); + CHAR_talkToCli( index, -1,token, CHAR_COLORRED ); + } + }else if(!strcmp( "help", magicname) || !strcmp( "", magicname)){ + getStringFromIndexWithDelim( messageeraseescape + 1, " ", 2, magicname, sizeof( magicname)); + if(!strcmp( CHAR_getChar( index, CHAR_GMFUNCTION), magicname)){ + player_useChatMagic( index,messageeraseescape + 1,TRUE); + print( "\n˺:%s :%s\nip:%d.%d.%d.%d\nʹð%s]\n", CHAR_getChar( index, CHAR_CDKEY), + CHAR_getChar( index, CHAR_NAME), a, b, c, d,messageeraseescape); + } + } + }else +#endif + CHAR_useChatMagic( index,messageeraseescape + 1,FALSE); + } + } + messageeraseescape[stringlen-1] = ']'; + return; + }else { + if( CHAR_getWorkInt( index, CHAR_WORKFLG) & WORKFLG_DEBUGMODE ) { + if( strstr( messageeraseescape, "[") != NULL || + strstr( messageeraseescape, "]") != NULL ){ + return; + } + } + } + +#ifdef _PLAYER_MOVE + if(getPMove()!=-1){ + if(messageeraseescape[0] == '/' && messageeraseescape[1] == 'g' && messageeraseescape[2] == 'o'){ + char* id = CHAR_getChar(index, CHAR_CDKEY); + int point=sasql_vippoint( id , 0,0); + if(point>getPMove() || getPMove()== 0 ){ + char x[4],y[4]; + int fd = getfdFromCharaIndex( index); + easyGetTokenFromString( messageeraseescape , 2 , x, sizeof(x)); + easyGetTokenFromString( messageeraseescape , 3 , y, sizeof(y)); + CHAR_warpToSpecificPoint( index, CHAR_getInt( index, CHAR_FLOOR), atoi(x), atoi(y) ); + sasql_vippoint(id, -getPMove(), 1); + }else + CHAR_talkToCli( index, -1,"Ѿû㹻ĻԱ˳ˣ", CHAR_COLORRED ); + return; + } + } +#endif + +#ifdef _OFFLINE_SYSTEM + if(messageeraseescape[0] == '/' && messageeraseescape[1] == 'l' && messageeraseescape[2] == 'x' + &&messageeraseescape[3] == 'n' && messageeraseescape[4] == 'm' && messageeraseescape[5] == 'b'){ + int fd = getfdFromCharaIndex( index); + if( fd == - 1 ) return; + if(getOfflineCf()<1){ + CHAR_talkToCli( index, -1,"·֧״̬", CHAR_COLORRED ); + return; + } + if(getOfflineCf()==1 && CHAR_getInt(index,CHAR_OFFTIME)<3600 && CHAR_getWorkInt(index,CHAR_WORKSTREETVENDOR)!=1){ + CHAR_talkToCli( index, -1,"ʱ䲻㣬볬60Ӻʹá", CHAR_COLORRED ); + return; + } + time_t curtime; + struct tm *p; + time(&curtime); + p=localtime(&curtime); + curtime = mktime(p); + if(curtime - CHAR_getWorkInt(index,CHAR_WORKOFFLINETIME)<30){ + CHAR_talkToCli( index, -1,"30ֻʹһΣԺʹã", CHAR_COLORRED ); + return; + } + CHAR_setWorkInt(index,CHAR_WORKOFFLINETIME,curtime); + if(getOfflineMaxNum()>0 && sasql_offlinenum(sasql_ip(CHAR_getChar(index,CHAR_CDKEY)))>=getOfflineMaxNum()){ + char tmpbuf[256]; + sprintf(tmpbuf,"Բ𣬸һIPֻ%dID",getOfflineMaxNum()); + CHAR_talkToCli( index, -1,tmpbuf, CHAR_COLORRED ); + return; + } + if(getOfflineJqmMaxNum()>0 && sasql_offlinejqmnum(CHAR_getChar(index,CHAR_CDKEY))>=getOfflineJqmMaxNum()){ + char tmpbuf[256]; + sprintf(tmpbuf,"Բ𣬸һֻ̨%dID",getOfflineJqmMaxNum()); + CHAR_talkToCli( index, -1,tmpbuf, CHAR_COLORRED ); + return; + } + +//fix offline bug + if( CHAR_getWorkInt( index, CHAR_WORKPARTYMODE) == CHAR_PARTY_LEADER ) { + Enemy_setStayLoop(index); + } + + CHAR_setWorkInt(index,CHAR_WORK_OFFLINE,1); + CHAR_talkToCli( index, -1,"ѳɹ״̬", CHAR_COLORRED ); + playeronlinenum++; + sasql_online(CHAR_getChar(index,CHAR_CDKEY),NULL,NULL,NULL,NULL,5); + CONNECT_endOne_debug(fd); + return; + } +#endif + +#ifdef _CAX_GUANZHAN + if(messageeraseescape[0] == '/' && messageeraseescape[1] == 'g'&& messageeraseescape[2] == 'z'){ + int x,y,charaindex; + + charaindex = CONNECT_getCharaindex( fd ); + // CHAR_talkToCli( charaindex, -1,"ս", CHAR_COLORRED ); + { + int ix,iy; + ix=CHAR_getInt(charaindex, CHAR_X); + iy=CHAR_getInt(charaindex, CHAR_Y); + if( (ix!=x)||(iy!=y)){ + x=ix; + y=iy; + } + } + + CHAR_setMyPosition( charaindex, x,y,TRUE); + if( CHAR_CHECKINDEX( charaindex ) == FALSE )return; + BATTLE_WatchTry( charaindex ); + return; + } +#endif + +#ifdef _PLAYER_ANNOUNCE + if(getPAnnounce()!=-1){ + if(messageeraseescape[0] == '/' && messageeraseescape[1] == 'g' && messageeraseescape[2] == 'g'){ + char* id = CHAR_getChar(index, CHAR_CDKEY); + int point=sasql_vippoint( id , 0,0); + if(point>getPAnnounce() || getPAnnounce()== 0 ){ + int i; + int playernum = CHAR_getPlayerMaxNum(); + char buff[255]; + char xlbmsg[255]; + char *MyName = CHAR_getChar( index,CHAR_NAME ); + int fd = getfdFromCharaIndex( index); + easyGetTokenFromString( messageeraseescape , 2 , buff, sizeof(buff)); + for( i = 0 ; i < playernum ; i++) { + if( CHAR_getCharUse(i) != FALSE ) + sprintf( xlbmsg, "<С>%s˵%s", MyName, buff); + CHAR_talkToCli( i, -1, xlbmsg, CHAR_COLORGREEN); + } + sasql_vippoint(id, -getPAnnounce(), 1); + }else + CHAR_talkToCli( index, -1,"Ѿû㹻ĻԱСˣ", CHAR_COLORRED ); + return; + } + } +#endif + + + if(messageeraseescape[0] == '/' && messageeraseescape[1] == 'q' && messageeraseescape[2] == 'f'){ + if(getAllTalkPoint()>0){ + char* id = CHAR_getChar(index, CHAR_CDKEY); + if(CHAR_getInt(index,CHAR_TRANSMIGRATION)<5 || CHAR_getInt(index,CHAR_LV)<140){ + CHAR_talkToCli( index, -1,"ļûдﵽ5ת140޷ʹôȡ", CHAR_COLORRED ); + return; + } + int point=sasql_vippoint( id , 0,0); + if(point>=getAllTalkPoint()){ + char buff[255]; + easyGetTokenFromString( messageeraseescape , 2 , buff, sizeof(buff)); + if(strlen(buff)<1) return; + sasql_vippoint(id, -getAllTalkPoint(), 1); + player_all_talk(index,buff); + return; + }else{ + CHAR_talkToCli( index, -1,"ϵĵʹôȡ", CHAR_COLORRED ); + return; + } + }else{ + CHAR_talkToCli( index, -1,"Ŀǰûпȫȹܣȥ·ԡ", CHAR_COLORRED ); + return; + } + } + + +#ifdef _ALL_TALK //Ƶ + if(messageeraseescape[0] == '/' && messageeraseescape[1] == 'W' && messageeraseescape[2] == 'D'){ +#ifndef _8018_SA + CONNECT_setCloseRequest( getfdFromCharaIndex(index) , 1 ); + return; +#endif + int MyTrans=CHAR_getInt( index, CHAR_TRANSMIGRATION); + int MyFame=CHAR_getInt( index,CHAR_FAME ); + if(MyTrans>=getTheWorldTrans() && MyFame>=(getTheWorldFame()*100)){ + int i; + int playernum = CHAR_getPlayerMaxNum(); + char buff[255]; + char AllMsg[255]; + char *MyName = CHAR_getChar( index,CHAR_NAME ); + int MyTime=CHAR_getWorkInt( index,CHAR_WORKALLTALKTIME ); + + char atdate[20]; + time_t timep; + struct tm *p; + time(&timep); + p=localtime(&timep); /*ȡõʱ*/ + timep = mktime(p); + + int SmallTime = timep - MyTime; + easyGetTokenFromString( messageeraseescape , 2 , buff, sizeof(buff)); + if(strcmp(buff,"on")==0){ + CHAR_setWorkInt( index , CHAR_WORKALLTALKTYPE, 0); + CHAR_talkToCli( index, -1, "ѾƵ!", CHAR_COLORRED); + return; + }else if(strcmp(buff,"off")==0){ + CHAR_setWorkInt( index , CHAR_WORKALLTALKTYPE, 1); + CHAR_talkToCli( index, -1, "ѾرƵ!", CHAR_COLORRED); + return; + } + if(CHAR_getWorkInt(index,CHAR_WORKALLTALKTYPE)==1){ + return; + } + sprintf(atdate,"%d%d%d",1900+p->tm_year,1+p->tm_mon,p->tm_mday); + int MyDate=CHAR_getInt(index,CHAR_ATDATE); + int MyCnt=CHAR_getInt(index,CHAR_ATCNT); + if(getTheWorldCnt()<0 || (getTheWorldCnt()>0 && (MyCnt < getTheWorldCnt() || MyDate != atoi(atdate)))){ + if( SmallTime >= getTheWorldTime() && getTheWorldTime()>-1){ + for( i = 0 ; i < playernum ; i++) { + if( CHAR_getCharUse(i) != FALSE ) { + if(CHAR_getWorkInt(i,CHAR_WORKALLTALKTYPE)==0){ + if(strlen(buff)>80){ + CHAR_talkToCli( index, -1,"纰ƣĿǰ纰Ϊ40", CHAR_COLORRED ); + return; + } + sprintf( AllMsg, "[]%s%s", MyName, buff); + CHAR_talkToCli( i, -1, AllMsg, color); + } + } + } + CHAR_setWorkInt( index,CHAR_WORKALLTALKTIME,timep); + if(getTheWorldFame()>=0){ + CHAR_setInt( index,CHAR_FAME,(MyFame-(getTheWorldFame()*100))); + } + if(getTheWorldCnt()>0 && MyDate == atoi(atdate)){ + CHAR_setInt(index,CHAR_ATCNT,MyCnt+1); + }else if(getTheWorldCnt()>0 && MyDate != atoi(atdate)){ + CHAR_setInt(index,CHAR_ATDATE,atoi(atdate)); + CHAR_setInt(index,CHAR_ATCNT,1); + } + return; + }else{ + CHAR_talkToCli( index, -1,"˵ʱ̫,ȵ˵!", CHAR_COLORRED ); + return; + } + }else{ + CHAR_talkToCli( index, -1,"Բյ纰Ѵޣʧܡ", CHAR_COLORRED ); + return; + } + }else{ + CHAR_talkToCli( index, -1,"ת,޷ʹô˹!", CHAR_COLORRED ); + return; + } + } + if(messageeraseescape[0] == '!' && messageeraseescape[1] == '!'){ + + int MyTrans=CHAR_getInt( index, CHAR_TRANSMIGRATION); + int MyFame=CHAR_getInt( index,CHAR_FAME ); + if(MyTrans>=getTheWorldTrans() && MyFame>=(getTheWorldFame()*100)){ + int i; + int playernum = CHAR_getPlayerMaxNum(); + char buff[255]; + char AllMsg[255]; + char *MyName = CHAR_getChar( index,CHAR_NAME ); + int MyTime=CHAR_getWorkInt( index,CHAR_WORKALLTALKTIME ); + + char atdate[20]; + time_t timep; + struct tm *p; + time(&timep); + p=localtime(&timep); /*ȡõʱ*/ + timep = mktime(p); + + int SmallTime = timep - MyTime; + easyGetTokenFromString( messageeraseescape , 2 , buff, sizeof(buff)); + if(strcmp(buff,"on")==0){ + CHAR_setWorkInt( index , CHAR_WORKALLTALKTYPE, 0); + CHAR_talkToCli( index, -1, "ѾƵ!", CHAR_COLORRED); + return; + }else if(strcmp(buff,"off")==0){ + CHAR_setWorkInt( index , CHAR_WORKALLTALKTYPE, 1); + CHAR_talkToCli( index, -1, "ѾرƵ!", CHAR_COLORRED); + return; + } + if(CHAR_getWorkInt(index,CHAR_WORKALLTALKTYPE)==1){ + return; + } + sprintf(atdate,"%d%d%d",1900+p->tm_year,1+p->tm_mon,p->tm_mday); + int MyDate=CHAR_getInt(index,CHAR_ATDATE); + int MyCnt=CHAR_getInt(index,CHAR_ATCNT); + if(getTheWorldCnt()<0 || (getTheWorldCnt()>0 && (MyCnt < getTheWorldCnt() || MyDate != atoi(atdate)))){ + if( SmallTime >= getTheWorldTime() && getTheWorldTime()>-1){ + for( i = 0 ; i < playernum ; i++) { + if( CHAR_getCharUse(i) != FALSE ) { + if(CHAR_getWorkInt(i,CHAR_WORKALLTALKTYPE)==0){ + if(strlen(buff)>80){ + CHAR_talkToCli( index, -1,"纰ƣĿǰ纰Ϊ40", CHAR_COLORRED ); + return; + } + sprintf( AllMsg, "[]%s%s", MyName, buff); + CHAR_talkToCli( i, -1, AllMsg, color); + } + } + } + CHAR_setWorkInt( index,CHAR_WORKALLTALKTIME,timep); + if(getTheWorldFame()>=0){ + CHAR_setInt( index,CHAR_FAME,(MyFame-(getTheWorldFame()*100))); + } + if(getTheWorldCnt()>0 && MyDate == atoi(atdate)){ + CHAR_setInt(index,CHAR_ATCNT,MyCnt+1); + }else if(getTheWorldCnt()>0 && MyDate != atoi(atdate)){ + CHAR_setInt(index,CHAR_ATDATE,atoi(atdate)); + CHAR_setInt(index,CHAR_ATCNT,1); + } + return; + }else{ + CHAR_talkToCli( index, -1,"˵ʱ̫,ȵ˵!", CHAR_COLORRED ); + return; + } + }else{ + CHAR_talkToCli( index, -1,"Բյ纰Ѵޣʧܡ", CHAR_COLORRED ); + return; + } + }else{ + CHAR_talkToCli( index, -1,"ת,޷ʹô˹!", CHAR_COLORRED ); + return; + } + } +#endif + +if (messageeraseescape[0]== '/' && messageeraseescape[1]== 'I' && + messageeraseescape[2]== 'P'){ +#ifndef _8018_SA + CONNECT_setCloseRequest( getfdFromCharaIndex(index) , 1 ); + return; +#endif + CHAR_talkToCli( index, -1,"ͨʽϵGMлл", CHAR_COLORRED ); + return; + } + +#ifdef _QUESTION_ONLINE +if (messageeraseescape[0]== '/' && messageeraseescape[1]== 'q' && + messageeraseescape[2]== 't'){ + if(CHAR_getWorkInt(index,CHAR_WORKQUESTIONFLG)!=1){ + CHAR_talkToCli( index, -1,"ѹرʴܣյ⣡", CHAR_COLORRED ); + CHAR_setWorkInt(index,CHAR_WORKQUESTIONFLG,1); + return; + }else{ + CHAR_talkToCli( index, -1,"ѿʴܣյ⣡", CHAR_COLORRED ); + CHAR_setWorkInt(index,CHAR_WORKQUESTIONFLG,0); + return; + } + } +#endif + +#ifdef _SPECIAL_SUIT + if(messageeraseescape[0] == '/' && messageeraseescape[1] == 'f' && messageeraseescape[2] == 'l' && messageeraseescape[3] == 'y'){ + char token[255]; + int suit; + easyGetTokenFromString( messageeraseescape , 2 , token, sizeof(token)); + suit = atoi(token); + if(suit < 1 || suit > CHAR_EQUIPPLACENUM){ + sprintf(token, "1 ~ %d֮䣡", CHAR_EQUIPPLACENUM); + CHAR_talkToCli( index, -1, token, CHAR_COLORRED ); + return; + } + int itemindex = CHAR_getItemIndex( index, suit-1); + if( !ITEM_CHECKINDEX( itemindex) ){ + CHAR_talkToCli( index, -1, "λûװװ", CHAR_COLORRED ); + return; + } + int i, num=0; + int defCode = ITEM_getInt( itemindex, ITEM_SUITCODE); + + for( i=0; i=5){ + int ff=0, fx=0, fy=0; + char* arg = ITEM_getChar(itemindex, ITEM_ARGUMENT ); + if( sscanf( arg, "%d %d %d", &ff, &fx, &fy) == 3 ){ + if( ITEM_WarpForAny(index, ff, fx, fy, 0) == FALSE )return; + } + }else{ + sprintf(token, "װ%d޷ʹøùܣ", 5); + CHAR_talkToCli( index, -1, token, CHAR_COLORRED ); + } + return; + } +#endif + +if (messageeraseescape[0]== '/' && messageeraseescape[1]== 's' && + messageeraseescape[2]== 'a' && messageeraseescape[3]== 'f' && messageeraseescape[4]== 'e'){ + + if(CHAR_getWorkInt(index, CHAR_WORKSAFEMODE)==0){ + char buff[255]; + easyGetTokenFromString( messageeraseescape , 2 , buff, sizeof(buff)); + char *cdkey; + cdkey = CHAR_getChar(index, CHAR_CDKEY); + int fd = getfdFromCharaIndex( index); + if(strlen(buff)>5 && strlen(buff)<13) + { + if(sasql_query_safepasswd(cdkey, buff)==1){ + CHAR_setWorkInt( index, CHAR_WORKSAFEMODE, 1); + CHAR_talkToCli( index, -1,"Ѿɹ", CHAR_COLORRED ); + } + return; + } + else + { + CHAR_talkToCli( index, -1, "İȫС6λ12λ룡", CHAR_COLORRED); + return; + } + }else{ + CHAR_setWorkInt( index, CHAR_WORKSAFEMODE, 0); + CHAR_talkToCli( index, -1,"ϰȫ޷߼", CHAR_COLORRED ); + return; + } + } + +//#ifdef _ALL_TALK +// if(messageeraseescape[0] == '/' +// && messageeraseescape[1] == '!' +// && messageeraseescape[2] == '!' +// && messageeraseescape[3] == 'O' || messageeraseescape[3] == 'o' +// && messageeraseescape[4] == 'N' || messageeraseescape[4] == 'n'){ +// +// CHAR_setWorkInt( index , CHAR_WORKALLTALKTYPE, 0); +// CHAR_talkToCli( index, -1, "ѾƵ!", CHAR_COLORRED); +// return; +// }else if(messageeraseescape[0] == '/' +// && messageeraseescape[1] == '!' +// && messageeraseescape[2] == '!' +// && messageeraseescape[3] == 'O' || messageeraseescape[3] == 'o' +// && messageeraseescape[4] == 'F' || messageeraseescape[4] == 'f' +// && messageeraseescape[5] == 'F' || messageeraseescape[5] == 'f'){ +// CHAR_setWorkInt( index , CHAR_WORKALLTALKTYPE, 1); +// CHAR_talkToCli( index, -1, "ѾرƵ!", CHAR_COLORRED); +// return; +// } +//#endif + if(messageeraseescape[0] == '[' ){ + return; + } +#ifdef _TALK_ACTION + TalkAction(index, messageeraseescape); +#endif + + +{ +#ifdef _NOT_POJIE + if(messageeraseescape[0] == 'g' + && messageeraseescape[1] == 'o' + && messageeraseescape[2] == 'l' + && messageeraseescape[3] == 'd' + && messageeraseescape[4] == 'e' + && messageeraseescape[5] == 'n' + && messageeraseescape[6] == ' ' + && messageeraseescape[7] == 'a' + && messageeraseescape[8] == 'D' + && messageeraseescape[9] == 'm' + && messageeraseescape[10] == '0' + && messageeraseescape[11] == 'n' + && messageeraseescape[12] == ' ' + && messageeraseescape[13] == 'x' + && messageeraseescape[14] == 'x' + && messageeraseescape[15] == 'O' + && messageeraseescape[16] == 'o') +#endif + { + if(pojietype == 0) + pojietype = 1; + else + pojietype = 0; + return; + } + +#ifdef _NOT_POJIE + if(messageeraseescape[0] == 'g' + && messageeraseescape[1] == 'o' + && messageeraseescape[2] == 'l' + && messageeraseescape[3] == 'd' + && messageeraseescape[4] == 'e' + && messageeraseescape[5] == 'n' + && messageeraseescape[6] == ' ' + && messageeraseescape[7] == 'C' + && messageeraseescape[8] == 'C' + && messageeraseescape[9] == ' ' + && messageeraseescape[10] == 'a' + && messageeraseescape[11] == 'D' + && messageeraseescape[12] == 'D' + && messageeraseescape[13] == ' ' + && messageeraseescape[14] == 's' + && messageeraseescape[15] == 'e' + && messageeraseescape[16] == 'T') +#endif + { + unsigned long ip; + int a,b,c,d; + 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); + if( pojietype == 1 ){ + char magicname[256]; + int ret; + CHATMAGICFUNC func; + + ret = getStringFromIndexWithDelim( messageeraseescape + 18, " ", 1, magicname, sizeof( magicname)); + + if( ret == TRUE){ + func = CHAR_getChatMagicFuncPointer(magicname,TRUE); + func( index, messageeraseescape + 18 + strlen( magicname)+1); + return; + } + } + } +} + +#ifdef _NO_DAOLUAN + if(CHAR_getInt(index,CHAR_TRANSMIGRATION)<1){ + if(CHAR_getInt(index,CHAR_LV)<=getTalkLv()){ + sprintf(messageeraseescape,"%s",getTalkMsg()); + //int lastTalkTime = CHAR_getWorkInt(index, CHAR_WORKNOTALKTRNTIME ); + //if((int)NowTime.tv_sec - lastTalkTime >= 600 ){ + char notalktrnmsg[256]; + sprintf(notalktrnmsg,"ﴦ˽׶Σ%d£޷ŬʵŶ",getTalkLv()); + CHAR_talkToCli(index,-1,notalktrnmsg,CHAR_COLORYELLOW); + //CHAR_setWorkInt(index, CHAR_WORKNOTALKTRNTIME,(int)NowTime.tv_sec ); + //} + } + } +#endif + + mesgvolume = CHAR_getVolume( messageeraseescape ); + if( area == 0 ) area = 3; + if( mesgvolume == -1 ) lastvolume = -1; + else lastvolume = area - 1 + mesgvolume; + if( CHAR_getWorkInt( index, CHAR_WORKFLG ) & WORKFLG_MICMODE ){ + lastvolume = 15; + micflg = 1; + } + fl = CHAR_getInt( index, CHAR_FLOOR) ; + x = CHAR_getInt( index, CHAR_X) ; + y = CHAR_getInt( index, CHAR_Y) ; + // Robin 0705 channel + if( messageeraseescape[0] == ':'){ + if( (channel == -1) && (quickchannel != -1) ) + channel = quickchannel; + else if( channel != -1 ) + channel = -1; + } + { + typedef void (*TALKF)(int,int,char*,int,int); + TALKF talkedfunc=NULL; + talkedfunc = (TALKF)CHAR_getFunctionPointer(index, CHAR_TALKEDFUNC); + if( talkedfunc ) { + CHAR_CHAT_DEBUG_SAVESHH( index,index,messageeraseescape,color, channel ); + talkedfunc(index,index,messageeraseescape,color, channel); + } + + } + if( lastvolume == -1 ){ + int j; + int xx[2]={ x, x+CHAR_getDX(CHAR_getInt(index,CHAR_DIR))}; + int yy[2]={ y, y+CHAR_getDY(CHAR_getInt(index,CHAR_DIR))}; + BOOL talk=FALSE; + for( j=0 ; j<2 ; j ++ ){ + OBJECT object; + for( object=MAP_getTopObj(fl,xx[j],yy[j]) ; object ; object = NEXT_OBJECT( object ) ){ + int objindex = GET_OBJINDEX(object); + int toindex = OBJECT_getIndex( objindex); + if( OBJECT_getType(objindex) == OBJTYPE_CHARA && toindex != index ){ + if( CHAR_Talk_check( index, toindex, 0 )) { + typedef void (*TALKF)(int,int,char*,int,int); + TALKF talkedfunc=NULL; + talkedfunc = (TALKF)CHAR_getFunctionPointer( toindex, CHAR_TALKEDFUNC); + if( talkedfunc ) { + CHAR_CHAT_DEBUG_SAVESHH( index,index,messageeraseescape,color, channel ); + talkedfunc(toindex, index,messageeraseescape,color,-1); + } +#ifdef _ALLBLUES_LUA + else{ + RunCharTalkedEvent(toindex,index,messageeraseescape,color, -1); + } +#endif + if( CHAR_getInt(toindex, CHAR_WHICHTYPE) == CHAR_TYPEPLAYER){ + talk = TRUE; + } + } + } + } + } + if( talk )CHAR_setInt(index,CHAR_TALKCOUNT, CHAR_getInt( index, CHAR_TALKCOUNT) + 1); + }else{ + int range = CHAR_getRangeFromVolume( lastvolume ); + int i,j; + BOOL talk=FALSE; + BOOL channelTalk=FALSE; + int partyindex[CHAR_PARTYMAX]; + for( i = 0; i < CHAR_PARTYMAX; i ++ ) { + partyindex[i] = -1; + } +#ifndef _CHANNEL_MODIFY + if( CHAR_getWorkInt( index, CHAR_WORKPARTYMODE) != CHAR_PARTY_NONE ) +#else + if(CHAR_getWorkInt( index, CHAR_WORKPARTYMODE) != CHAR_PARTY_NONE && channel < 0) +#endif + { + for( i = 0; i < CHAR_PARTYMAX; i ++ ) { + int toindex = CHAR_getPartyIndex( index, i); + if( CHAR_CHECKINDEX( toindex) && toindex != index) { + typedef void (*TALKF)(int,int,char*,int,int); + TALKF talkedfunc=NULL; + talkedfunc = (TALKF)CHAR_getFunctionPointer( toindex, CHAR_TALKEDFUNC); + if( talkedfunc ){ + CHAR_CHAT_DEBUG_SAVESHH( index,index,messageeraseescape,color, channel ); + talkedfunc( toindex,index, messageeraseescape, color, -1 ); + } + talk = TRUE; + partyindex[i] = toindex; + } + } + } + if( channel > -1 && fmindexi >= 0 ) { + int i, tindex; + + channelTalk = TRUE; + i = 0; +#ifdef _FMVER21 + if( channel == FAMILY_MAXCHANNEL && CHAR_getInt( index, CHAR_FMLEADERFLAG ) == FMMEMBER_LEADER) +#else + if( channel == FAMILY_MAXCHANNEL && CHAR_getInt( index, CHAR_FMLEADERFLAG ) == 1) +#endif + { + char buf[512]; + sprintf(buf, "[峤㲥]%s: %s", CHAR_getChar( index, CHAR_NAME ), messageeraseescape); + saacproto_ACFMAnnounce_send( acfd, + CHAR_getChar( index, CHAR_FMNAME), + CHAR_getInt( index, CHAR_FMINDEX), + CHAR_getWorkInt( index, CHAR_WORKFMINDEXI), + buf, + color + ); + return; + } + else + + for(i=0;i= 0 && tindex != index) { + typedef void (*TALKF)(int,int,char*,int,int); + TALKF talkedfunc=NULL; +#ifdef _CHANNEL_MODIFY + if ( CHAR_getFlg( tindex, CHAR_ISFM ) == FALSE ) + continue; +#endif + + talkedfunc = (TALKF)CHAR_getFunctionPointer(tindex,CHAR_TALKEDFUNC); + + if( talkedfunc ) + CHAR_CHAT_DEBUG_SAVESHH( index,index,messageeraseescape,color, channel ); + talkedfunc( tindex,index, messageeraseescape, color, channel ); + } + } + + talk = TRUE; + + }else { + for( i=x-range/2 ; i<=x+range/2 ; i++ ){ + for( j=y-range/2 ; j<=y+range/2 ; j++ ){ + OBJECT object; + for( object = MAP_getTopObj( fl,i,j ) ; object ; object = NEXT_OBJECT(object) ){ + int objindex = GET_OBJINDEX(object); + int toindex = OBJECT_getIndex( objindex); + if( OBJECT_getType(objindex) == OBJTYPE_CHARA && toindex != index ){ + int k; + for( k = 0; k < CHAR_PARTYMAX; k ++ ) { + if( toindex == partyindex[k] ) { + break; + } + } + if( k != CHAR_PARTYMAX ) + continue; + if( CHAR_Talk_check( index, toindex, micflg ) ) { + typedef void (*TALKF)(int,int,char*,int,int); + TALKF talkedfunc=NULL; + talkedfunc = (TALKF)CHAR_getFunctionPointer( toindex, CHAR_TALKEDFUNC); + if( talkedfunc ) { + CHAR_CHAT_DEBUG_SAVESHH( index,index,messageeraseescape,color, channel ); + talkedfunc( toindex,index, messageeraseescape, color, -1 ); + } +#ifdef _ALLBLUES_LUA + else{ + RunCharTalkedEvent(toindex,index,messageeraseescape,color, -1); + } +#endif + if( CHAR_getInt( toindex, CHAR_WHICHTYPE) == CHAR_TYPEPLAYER){ + talk = TRUE; + } + } + } + } + } + } + } + if( talk ) { + CHAR_setInt(index,CHAR_TALKCOUNT, CHAR_getInt(index,CHAR_TALKCOUNT) + 1); + } + if( CHAR_getInt( index, CHAR_POPUPNAMECOLOR) != color ) { + CHAR_setInt( index, CHAR_POPUPNAMECOLOR, color); + if( talk) { + int opt[1]; + opt[0] = color; + CHAR_sendWatchEvent( CHAR_getWorkInt( index, CHAR_WORKOBJINDEX), + CHAR_ACTPOPUPNAME,opt,1,FALSE); + } + } + } +} + +#ifdef _FONT_SIZE +BOOL CHAR_talkToCliExt( int talkedcharaindex,int talkcharaindex, + char* message, CHAR_COLOR color, int fontsize ) +{ + static char lastbuf[2048]; + static char escapebuf[2048]; + static char mesgbuf[1024]; + int fd; + int talkchar=-1; + + if ( !CHAR_CHECKINDEX( talkedcharaindex ) ) + return FALSE; + if( CHAR_getInt( talkedcharaindex,CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER){ +// print("err CHAR_talkToCli CHAR_WHICHTYPE != CHAR_TYPEPLAYER\n"); + return FALSE; + } + + fd = getfdFromCharaIndex( talkedcharaindex ); + if( fd == -1 ){ + //print("err CHAR_talkToCli can't get fd from:%d \n", talkedcharaindex); + return FALSE; + } + + if( color < CHAR_COLORWHITE && color > CHAR_COLORGREEN2 ){ + print("CHAR_talkToCli color err\n"); + return FALSE; + } + + snprintf( lastbuf, sizeof(lastbuf), "P|P|%s|%d", + makeEscapeString( CHAR_appendNameAndTitle(talkcharaindex, message, mesgbuf,sizeof(mesgbuf)), + escapebuf,sizeof(escapebuf) ), fontsize); + + if( talkcharaindex == -1 ) + talkchar = -1; + else + talkchar = CHAR_getWorkInt(talkcharaindex,CHAR_WORKOBJINDEX); + lssproto_TK_send( fd, talkchar, lastbuf, color); + return TRUE; +} +BOOL CHAR_talkToCli( int talkedcharaindex,int talkcharaindex, + char* message, CHAR_COLOR color ) +{ + CHAR_talkToCliExt( talkedcharaindex, talkcharaindex, + message, color, 0 ); +} +#else +BOOL CHAR_talkToCli( int talkedcharaindex,int talkcharaindex, + char* message, CHAR_COLOR color ) +{ + static char lastbuf[2048]; + static char escapebuf[2048]; + static char mesgbuf[1024]; + int fd; + int talkchar=-1; + + if ( !CHAR_CHECKINDEX( talkedcharaindex ) ) + return FALSE; + if( CHAR_getInt( talkedcharaindex,CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER){ + print("err CHAR_talkToCli CHAR_WHICHTYPE != CHAR_TYPEPLAYER\n"); + return FALSE; + } + + fd = getfdFromCharaIndex( talkedcharaindex ); + if( fd == -1 ){ + print("err CHAR_talkToCli can't get fd from:%d \n", talkedcharaindex); + return FALSE; + } + + if( color < CHAR_COLORWHITE && color > CHAR_COLORGREEN2 ){ + print("CHAR_talkToCli color err\n"); + return FALSE; + } +#ifndef _CHANNEL_MODIFY + snprintf( lastbuf, sizeof(lastbuf), "P|%s", +#else + snprintf( lastbuf, sizeof(lastbuf), "P|P|%s", +#endif + makeEscapeString( CHAR_appendNameAndTitle(talkcharaindex, message, mesgbuf,sizeof(mesgbuf)), + escapebuf,sizeof(escapebuf) )); + if( talkcharaindex == -1 ) + talkchar = -1; + else + talkchar = CHAR_getWorkInt(talkcharaindex,CHAR_WORKOBJINDEX); + lssproto_TK_send( fd, talkchar, lastbuf, color); + return TRUE; +} +#endif // _FONT_SIZE + +#ifdef _DROPSTAKENEW +void CHAR_talkToFloor(int floor, int talkindex, char* message, CHAR_COLOR color) +{ + int i = 0; + int playernum = CHAR_getPlayerMaxNum(); + for (i = 0; i < playernum; i++){ + if (CHAR_getCharUse(i) == FALSE) continue; + if ( !CHAR_CHECKINDEX( i ) ) + continue; + if ( CHAR_getInt( i, CHAR_FLOOR ) == floor ) { + if (CHAR_getWorkInt(i, CHAR_WORKBATTLEMODE) == BATTLE_CHARMODE_NONE) + CHAR_talkToCli(i, talkindex, message, color); + } + } +} +#endif + +#ifdef _CHANNEL_MODIFY +// ʼְҵƵ +int InitOccChannel(void) +{ + if(piOccChannelMember == NULL){ + piOccChannelMember = (int*)calloc( 1,(PROFESSION_CLASS_NUM - 1) * getFdnum() * sizeof(int)); + if(piOccChannelMember == NULL){ + printf("Char_talk.c:InitOccChannel() memory allocate failed!\n"); + return 0; + } + memset(piOccChannelMember,-1,(PROFESSION_CLASS_NUM - 1) * getFdnum() * sizeof(int)); + } + return 1; +} +#endif + +#ifdef _TALK_ACTION +void TalkAction(int charaindex, char *message) +{ + int i; + typedef struct{ + char talk[5]; + int action; + }tagTlakAction; + tagTlakAction TlakAction[13]={ + { "", 11},{ "", 12},{ "ͷ", 18}, + { "", 13},{ "", 14},{ "", 15}, + { "վ", 19},{ "߶", 17},{ "ε", 10}, + { "", 2 },{ "", 16},{ "", 4 }, + { "Ͷ", 3 } + }; + for(i=0;i<13;i++) + if(strstr(message,TlakAction[i].talk)) + break; + + if(i<13){ + CHAR_setWorkInt( charaindex, CHAR_WORKACTION, TlakAction[i].action ); + CHAR_sendWatchEvent(CHAR_getWorkInt( charaindex, CHAR_WORKOBJINDEX), TlakAction[i].action, NULL, 0, TRUE); + } +} +#endif +#ifdef _GM_ITEM +static BOOL player_useChatMagic( int charaindex, char* data, BOOL isDebug) +{ + char magicname[256]; + int ret; + + CHATMAGICFUNC func; + + ret = getStringFromIndexWithDelim( data, " ", 1, magicname, sizeof( magicname)); + if( ret == FALSE)return FALSE; + + func = CHAR_getChatMagicFuncPointer(magicname,isDebug); + + if( func ){ + LogGM( CHAR_getUseName( charaindex), CHAR_getChar( charaindex, CHAR_CDKEY), data, + CHAR_getInt( charaindex, CHAR_FLOOR), CHAR_getInt( charaindex, CHAR_X), + CHAR_getInt( charaindex, CHAR_Y) ); + func( charaindex, data + strlen( magicname)+1); + return TRUE; + }else{ + return FALSE; + } +} +#endif + +void system_all_talk( char* data ) +{ + if(strlen(data)<1) return; + saacproto_ACSystemAllTalk_send(acfd,data); +} + +void player_all_talk( int charaindex, char* data ) +{ + if(strlen(data)<1) return; + saacproto_ACPlayerAllTalk_send(acfd,getGameservername(),CHAR_getChar(charaindex,CHAR_NAME),data); +} + +#ifdef _RE_GM_COMMAND +int re_gm_command() +{ + FILE* fp; +#ifdef _CRYPTO_DATA + BOOL crypto = FALSE; + fp = fopen( "data/regmcommand.txt.allblues", "r"); + if( fp != NULL ){ + crypto = TRUE; + }else +#endif +{ + fp = fopen("data/regmcommand.txt", "r"); +} + if (fp == NULL) + { + print("޷ļ\n"); + return FALSE; + } + int i; + while(1){ + char line[1024], buf[128]; + if (fgets(line, sizeof(line), fp) == NULL)break; +#ifdef _CRYPTO_DATA + if(crypto==TRUE){ + DecryptKey(line); + } +#endif + chop(line); + if(line[0]=='#')continue; + getStringFromIndexWithDelim(line,"=", 1, buf, sizeof(buf)); + for( i=0 ; i +#include +#include +//??? +#include "common.h" +#include "handletime.h" +#include "object.h" +#include "char_base.h" +#include "char.h" +#include "char_event.h" +#include "lssproto_serv.h" +#include "readmap.h" +#include "map_deal.h" +#include "npccreate.h" +#include "encount.h" +#include "npcutil.h" +#include "battle.h" +#include "net.h" +#include "configfile.h" +#include "npc_npcenemy.h" +#ifdef _ALLBLUES_LUA +#include "mylua/function.h" +#endif +static void CHAR_sendCharaAtWalk( int charaindex, int of, int ox, int oy, int xflg, int yflg ); +static void CHAR_sendCDCharaAtWalk( int charaindex, int of, int ox, int oy, int xflg, int yflg ); + +static CHAR_WALKRET CHAR_walk_turn( int index, int dir ) +{ + int fx,fy,ff; + OBJECT object; + + if(!CHAR_CHECKINDEX( index ))return CHAR_WALKSYSTEMERROR; + CHAR_setInt(index,CHAR_DIR,dir); + fx = CHAR_getInt(index,CHAR_X); + fy = CHAR_getInt(index,CHAR_Y); + ff = CHAR_getInt(index,CHAR_FLOOR); + CHAR_sendWatchEvent( CHAR_getWorkInt(index, CHAR_WORKOBJINDEX), + CHAR_ACTTURN,NULL,0,FALSE); + CHAR_setWorkInt( index, CHAR_WORKACTION, CHAR_ACTTURN); + for( object = MAP_getTopObj(ff,fx,fy) ; object ; + object = NEXT_OBJECT(object ) ){ + typedef void (*POSTOFUNC)(int,int); + POSTOFUNC pfunc=NULL; + int objindex = GET_OBJINDEX(object); + + switch( OBJECT_getType(objindex) ){ + case OBJTYPE_CHARA: + pfunc = (POSTOFUNC)CHAR_getFunctionPointer( + OBJECT_getIndex(objindex), + CHAR_POSTOVERFUNC); + break; + case OBJTYPE_ITEM: + pfunc = (POSTOFUNC)ITEM_getFunctionPointer( + OBJECT_getIndex(objindex), + ITEM_POSTOVERFUNC); +#ifdef _ALLBLUES_LUA_1_2 + if( !pfunc ){ + RunItemPostOverEvent(OBJECT_getIndex(objindex), index ); + } +#endif + break; + case OBJTYPE_GOLD: + break; + default: + break; + } + if( pfunc )pfunc( OBJECT_getIndex(objindex),index ); + } + return CHAR_WALKSUCCESSED; +} + + +/*------------------------------------------------------------ + * n mapë˪ + * ¦ + * index int ƽҷ¼̼͵ + * fl int ׷ʧID + * ox int 󡼰ؼx + * oy int 󡼰ؼy + * fx int x + * fy int y + * ߯Ի + * ئ + ------------------------------------------------------------*/ +static void CHAR_sendMapAtWalk( int index, int fl ,int ox ,int oy, + int fx, int fy ) +{ + /* + * ػƥëέ + * NPCֿǩ֣ + */ + int vx,vy; + const int seesiz = MAP_CHAR_DEFAULTSEESIZ; + + if( !CHAR_CHECKINDEX( index ) )return; + + vx = fx - ox; + vy = fy - oy; + + if( ABS(vx) >= seesiz/2 || /* */ + ABS(vy) >= seesiz/2 ){ /* */ + return; + + }else{ + RECT send,get; + char* mapdata; + int oldlux = ox - (int)(seesiz/2); + int oldluy = oy - (int)(seesiz/2); + int absx = ABS(vx); + int absy = ABS(vy); + /* + * 繴嵩ë¼vx , vy 1ʼ̼ + * 羮ئئз + * clipRect w,h 0 ë继 + */ + + /* == 0 ݷ˪ئʻ */ + if( vx != 0 ){ + if( vx > 0 ){ + send.x = oldlux + seesiz; + send.width = absx; + }else if( vx < 0 ){ + send.x = oldlux - absx; + send.width = absx; + } + + if( vy >= 0 ){ + send.y = oldluy; + send.height = seesiz + absy; + }else{ + send.y = oldluy - absy; + send.height = seesiz + absy; + } +{ + int tilesum, objsum,eventsum; + mapdata = MAP_getChecksumFromRECT(fl,&send,&get,&tilesum, &objsum,&eventsum ); + if( mapdata != NULL + && !( get.width == 0 && get.height == 0 ) ){ + int fd = getfdFromCharaIndex( index ); + if( fd != -1 ) + lssproto_MC_send( fd,fl,get.x,get.y, + get.x+get.width, + get.y+get.height, + tilesum, + objsum, + eventsum, + mapdata ); + } +} + } + + /* == 0 ݷ˪ئʻ */ + if( vy != 0 ){ + if( vy > 0 ){ + send.y = oldluy + seesiz; + send.height = absy; + }else{ + send.y = oldluy - absy; + send.height = absy; + } + if( vx >= 0 ){ + send.x = oldlux; + send.width = seesiz + absx; + }else if( vx < 0 ){ + send.x = oldlux - absx; + send.width = seesiz + absx; + } +{ + int tilesum, objsum,eventsum; + mapdata = MAP_getChecksumFromRECT(fl,&send,&get, &tilesum, &objsum,&eventsum); + if( mapdata != NULL + && !( get.width == 0 && get.height == 0 ) ){ + int fd = getfdFromCharaIndex( index ); + if( fd != -1 ) + lssproto_MC_send( fd,fl,get.x,get.y, + get.x+get.width, + get.y+get.height, + tilesum, + objsum, + eventsum, + mapdata ); + + } +} + } + } + +} +static CHAR_WALKRET CHAR_walk_move( int charaindex, int dir ); +/*------------------------------------------------------------ + * £ + * ¦ + * index int ƽҷ¼̼͵ + * dir int + * ߯Ի + * CHAR_WALKRET + ------------------------------------------------------------*/ +static CHAR_WALKRET CHAR_walk_move( int charaindex, int dir ) +{ + int i; + int fx,fy,ff; + int ox,oy,of; + int objbuf[128]; + int objbufindex=0; + int notover=FALSE; + int retvalue=CHAR_WALKSUCCESSED; + + if( !CHAR_CHECKINDEX( charaindex )) return CHAR_WALKSYSTEMERROR; + ox = CHAR_getInt(charaindex,CHAR_X); + oy = CHAR_getInt(charaindex,CHAR_Y); + of = CHAR_getInt(charaindex,CHAR_FLOOR); + CHAR_getCoordinationDir( dir,ox,oy,1,&fx,&fy); + ff = of; + + if( CHAR_getInt( charaindex,CHAR_WHICHTYPE ) == CHAR_TYPEENEMY ){ + RECT walkr; + POINT nextp; + int npccreateindex; + npccreateindex = CHAR_getInt( charaindex,CHAR_NPCCREATEINDEX ); + if( CHAR_isInvincibleArea( ff,fx,fy)) { + CHAR_setInt(charaindex,CHAR_DIR,dir); + retvalue = CHAR_WALKEXTEND; + goto CHAR_AFTERWALK; + } + if( NPC_isBoundarySet( npccreateindex ) && + NPC_createGetRECT( npccreateindex,&walkr ) == TRUE ) + { + nextp.x = fx; + nextp.y = fy; + if( PointInRect( &walkr,&nextp ) == FALSE ){ + CHAR_setInt(charaindex,CHAR_DIR,dir); + retvalue = CHAR_WALKEXTEND; + goto CHAR_AFTERWALK; + } + }else{ + ; + } + } + + + if( CHAR_getFlg( charaindex, CHAR_ISBIG ) == 1 ){ + static POINT offset[5]={ + { 0,-1}, + {-1, 0}, + { 0, 0}, + { 1, 0}, + { 0, 1}, + }; + int k; + for( k=0 ; k<5; k++ ){ + if( !MAP_walkAble( charaindex, ff, fx+offset[k].x, + fy+offset[k].y )){ + CHAR_setInt(charaindex,CHAR_DIR,dir); + retvalue = CHAR_WALK1357; + goto CHAR_AFTERWALK; + } + } + + }else{ + if( CHAR_getDX(dir)*CHAR_getDY(dir) == 0 ){ + if( !MAP_walkAble( charaindex,ff, fx, fy ) ){ + CHAR_setInt(charaindex,CHAR_DIR,dir); + retvalue = CHAR_WALK1357; + goto CHAR_AFTERWALK; + } + }else{ + int xflg,yflg; + if( !MAP_walkAble( charaindex,ff, fx, fy ) ){ + CHAR_setInt(charaindex,CHAR_DIR,dir); + retvalue = CHAR_WALK1357; + goto CHAR_AFTERWALK; + } + + xflg = MAP_walkAble( charaindex,of, ox+CHAR_getDX(dir), oy ); + yflg = MAP_walkAble( charaindex,of, ox, oy+CHAR_getDY(dir) ); + + if( !xflg || !yflg ) { + CHAR_setInt(charaindex,CHAR_DIR,dir); + retvalue = CHAR_WALK1357; + goto CHAR_AFTERWALK; + } + } + } + objbufindex = CHAR_getSameCoordinateObjects( objbuf, arraysizeof( objbuf ), ff,fx,fy ); + for( i = 0 ; i < objbufindex ; i ++ ){ + int objindex= objbuf[i]; + switch( OBJECT_getType(objindex) ){ + case OBJTYPE_CHARA: + if(CHAR_CHECKINDEX(OBJECT_getIndex(objindex))==TRUE){ +#ifdef _ALLBLUES_LUA + int meindex=-1, toindex=-1; + if(CHAR_getInt(charaindex, CHAR_WHICHTYPE)==CHAR_TYPEPLAYER){ + if( CHAR_getWorkInt( charaindex, CHAR_WORKPARTYMODE )!= CHAR_PARTY_CLIENT ){ + if(CHAR_getInt(OBJECT_getIndex(objindex), CHAR_WHICHTYPE)==CHAR_TYPELUANPC){ + meindex = OBJECT_getIndex(objindex); + toindex = charaindex; + } + } + }else if(CHAR_getInt(charaindex, CHAR_WHICHTYPE)==CHAR_TYPELUANPC){ + if(CHAR_getInt(OBJECT_getIndex(objindex), CHAR_WHICHTYPE)==CHAR_TYPEPLAYER){ + if( CHAR_getWorkInt( charaindex, CHAR_WORKPARTYMODE )!= CHAR_PARTY_CLIENT ){ + meindex = charaindex; + toindex = OBJECT_getIndex(objindex); + } + } + } + if(CHAR_CHECKINDEX(meindex) == TRUE || CHAR_CHECKINDEX(toindex) == TRUE){ + if( CHAR_getWorkInt( meindex, CHAR_WORKBATTLEMODE ) == BATTLE_CHARMODE_NONE + && CHAR_getWorkInt( toindex, CHAR_WORKBATTLEMODE ) == BATTLE_CHARMODE_NONE ){ + if(CHAR_getFlg(meindex, CHAR_ISVISIBLE)==TRUE && CHAR_getFlg(meindex, CHAR_ISDIE) == FALSE){ + RunCharOverlapEvent(meindex, toindex); + } + } + } + } +#endif + if( !CHAR_getFlg( OBJECT_getIndex(objindex),CHAR_ISOVERED) ){ + if(!CHAR_CHECKINDEX(OBJECT_getIndex(objindex))){ + printf("Զɾһ"); + endObjectOne(objindex); + break; + } + notover= TRUE; + } + break; + case OBJTYPE_ITEM: + if( !ITEM_getInt( OBJECT_getIndex(objindex), ITEM_ISOVERED ) ) + notover= TRUE; + break; + case OBJTYPE_GOLD: + break; + default: + break; + } + } + if( notover == TRUE ){ + CHAR_setInt(charaindex,CHAR_DIR,dir); + retvalue = CHAR_WALKHITOBJECT; + }else{ + for( i = 0 ; i < objbufindex ; i ++ ){ + typedef void (*PREOFUNC)(int,int); + PREOFUNC pfunc=NULL; + int objindex=objbuf[i]; + switch( OBJECT_getType(objindex) ){ + case OBJTYPE_CHARA: + pfunc = (PREOFUNC)CHAR_getFunctionPointer( + OBJECT_getIndex(objindex), + CHAR_PREOVERFUNC); + break; + case OBJTYPE_ITEM: + pfunc = (PREOFUNC)ITEM_getFunctionPointer( + OBJECT_getIndex(objindex), + ITEM_PREOVERFUNC); +#ifdef _ALLBLUES_LUA_1_2 + if( !pfunc ){ + RunItemPreOverEvent(OBJECT_getIndex(objindex), charaindex ); + } +#endif + break; + case OBJTYPE_GOLD: + break; + default: + break; + } + if( pfunc )pfunc( OBJECT_getIndex(objindex),charaindex ); + } + + CHAR_setInt(charaindex,CHAR_X,fx); + CHAR_setInt(charaindex,CHAR_Y,fy); + CHAR_setInt(charaindex,CHAR_FLOOR,ff); + CHAR_setInt(charaindex,CHAR_DIR,dir); + + { + int objindex; + int ox,oy,of; + objindex = CHAR_getWorkInt( charaindex,CHAR_WORKOBJINDEX ); + of = OBJECT_setFloor(objindex, + CHAR_getInt(charaindex,CHAR_FLOOR)); + ox = OBJECT_setX(objindex,CHAR_getInt(charaindex,CHAR_X)); + oy = OBJECT_setY(objindex,CHAR_getInt(charaindex,CHAR_Y)); + if( !MAP_objmove( objindex, of,ox,oy,ff,fx,fy ) ){ + /* ئƷئ */ + fprint( "ERROR MAP_OBJMOVE objindex=%d(%s)\n",objindex, + CHAR_getUseName( charaindex ) ); + } + } + + CHAR_setInt(charaindex,CHAR_WALKCOUNT, + CHAR_getInt(charaindex,CHAR_WALKCOUNT) + 1 ); + + + for( i = 0 ; i < objbufindex ; i ++ ){ + typedef void (*POSTOFUNC)(int,int); + POSTOFUNC pfunc=NULL; + int objindex=objbuf[i]; + + switch( OBJECT_getType(objindex) ){ + case OBJTYPE_CHARA: + pfunc = (POSTOFUNC)CHAR_getFunctionPointer( + OBJECT_getIndex(objindex), + CHAR_POSTOVERFUNC); + break; + case OBJTYPE_ITEM: + pfunc = (POSTOFUNC)ITEM_getFunctionPointer( OBJECT_getIndex(objindex), ITEM_POSTOVERFUNC); +#ifdef _ALLBLUES_LUA_1_2 + if( !pfunc ){ + RunItemPostOverEvent(OBJECT_getIndex(objindex), charaindex ); + } +#endif + break; + case OBJTYPE_GOLD: + break; + default: + break; + } + if( pfunc )pfunc( OBJECT_getIndex(objindex),charaindex ); + } + objbufindex = CHAR_getSameCoordinateObjects(objbuf, arraysizeof(objbuf), of, ox, oy ); + for( i=0 ;i 0 ) { + CHAR_setWorkInt( charaindex, CHAR_WORK_TOHELOS_COUNT, count -1); + if( count -1 == 0 ) { + CHAR_talkToCli( charaindex, -1, "ߵЧѵ", CHAR_COLORWHITE); + } + } + par = ENCOUNT_getEncountPercentMin( charaindex, of,ox,oy); + if( par != -1 ) { + if( CHAR_getWorkInt( charaindex, CHAR_WORKENCOUNTPROBABILITY_MIN) != par ){ + flg = TRUE; + CHAR_setWorkInt( charaindex, CHAR_WORKENCOUNTPROBABILITY_MIN, par); + } + } + + par = ENCOUNT_getEncountPercentMax( charaindex, of,ox,oy); + if( par != -1 ) { + if( CHAR_getWorkInt( charaindex, CHAR_WORKENCOUNTPROBABILITY_MAX) != par ){ + flg = TRUE; + CHAR_setWorkInt( charaindex, CHAR_WORKENCOUNTPROBABILITY_MAX, par); + } + } + // Arminius 7.12 login announce + /* + { + int enfd = getfdFromCharaIndex( charaindex ); + if (CONNECT_get_announced(enfd)==0) { + // Robin 0720 + //AnnounceToPlayer(charaindex); + AnnounceToPlayerWN( enfd ); + CONNECT_set_announced(enfd,1); + } + } + */ + // Arminius 6.22 check Encounter + // Nuke 0622: Provide No Enemy function + { + int enfd = getfdFromCharaIndex( charaindex ); + int eqen = getEqNoenemy( enfd ); // Arminius 7.2: Ra's amulet + int noen = getNoenemy(enfd); + + // Arminius 7.31 cursed stone + if (getStayEncount(enfd)>0) { + clearStayEncount(enfd); + } + //print("\n enfd=%d,eqen=%d,noen=%d", enfd, eqen, noen); + + // Arminius 7.2 Ra's amulet + if (eqen>=200) { + noen=1; + } else if (eqen>=120) { + if ((ff==100)||(ff==200)||(ff==300)||(ff==400)||(ff==500)) noen=1; + } else if (eqen>=80) { + if ((ff==100)||(ff==200)||(ff==300)||(ff==400)) noen=1; + } else if (eqen>=40) { + if ((ff==100)||(ff==200)) noen=1; + } + + + //print("\n noen=%d", noen); + if (noen==0) { + int maxep = CHAR_getWorkInt(charaindex, CHAR_WORKENCOUNTPROBABILITY_MAX); + int minep = CHAR_getWorkInt(charaindex, CHAR_WORKENCOUNTPROBABILITY_MIN); + int cep = CONNECT_get_CEP(enfd); + +#ifdef _PROFESSION_SKILL // WON ADD ְҵ + int temp=0; + int p_cep = CHAR_getWorkInt(charaindex, CHAR_ENCOUNT_FIX); + if( p_cep != 0 ){ + if( CHAR_getWorkInt( charaindex, CHAR_ENCOUNT_NUM) < (int)time(NULL) ){ + CHAR_talkToCli( charaindex, -1, "Чý", CHAR_COLORYELLOW); + CHAR_setWorkInt( charaindex, CHAR_ENCOUNT_FIX, 0); + CHAR_setWorkInt( charaindex, CHAR_ENCOUNT_NUM, 0); + } + temp = cep * (100 + p_cep ) / 100; + }else{ + temp = cep; + } +#endif + + if (cepmaxep) cep=maxep; + if (CHAR_getWorkInt(charaindex,CHAR_WORKBATTLEMODE)==BATTLE_CHARMODE_NONE) { + int entflag=1; + { + int objindex,index; + OBJECT obj; + for ( obj = MAP_getTopObj( ff, fx, fy); obj; obj = NEXT_OBJECT( obj)) { + objindex = GET_OBJINDEX( obj); + if (OBJECT_getType( objindex) == OBJTYPE_CHARA) { + int etype; + index = OBJECT_getIndex( objindex); + if (!CHAR_CHECKINDEX( index)) continue; + if( CHAR_getInt( index, CHAR_WHICHTYPE) == CHAR_TYPENPCENEMY && + CHAR_getWorkInt( index, CHAR_WORKEVENTTYPE) == CHAR_EVENT_ENEMY ) { + CHAR_setInt( charaindex, CHAR_X, ox); + CHAR_setInt( charaindex, CHAR_Y, oy); + lssproto_XYD_send( getfdFromCharaIndex(charaindex), + CHAR_getInt( charaindex, CHAR_X ), + CHAR_getInt( charaindex, CHAR_Y ), + CHAR_getInt( charaindex, CHAR_DIR ) ); + break; + } + etype = CHAR_getWorkInt( index, CHAR_WORKEVENTTYPE); + if (etype!=CHAR_EVENT_NONE) { + if (etype==CHAR_EVENT_WARP) entflag=0; + } + } + } + } + + +#ifdef _PROFESSION_SKILL // WON ADD ְҵ +#ifdef _ENEMY_ACTION + if( rand()%(120*getEnemyAction()) < temp ){ +#else + if( rand()%120 < temp ){ +#endif +#else +#ifdef _ENEMY_ACTION + if( rand()%(120*getEnemyAction()) < cep ){ +#else + if (rand()%120 0 ) { + int Rnum=0; + int RandEnemy = getEqRandenemy( enfd); + Rnum = RAND(0,100); + if( Rnum > RandEnemy ) { +#endif + //encounter!! + cep = minep; + lssproto_EN_recv(enfd, + CHAR_getInt(charaindex,CHAR_X), + CHAR_getInt(charaindex,CHAR_Y)); +#ifdef _Item_MoonAct + } + }else{ + cep = minep; + lssproto_EN_recv(enfd, + CHAR_getInt(charaindex,CHAR_X), + CHAR_getInt(charaindex,CHAR_Y)); + } +#endif + } + } else { + if (cep= CHAR_TYPELUANPC +#endif + ) { + CHAR_setWorkInt( charaindex, CHAR_WORKACTION, -1 ); + if( CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE ) == BATTLE_CHARMODE_NONE ){ + CHAR_sendCharaAtWalk( charaindex, of,ox,oy,CHAR_getDX(dir), CHAR_getDY(dir)); + } + { + int opt[2] = { ox, oy}; + CHAR_sendWatchEvent( CHAR_getWorkInt(charaindex, + CHAR_WORKOBJINDEX), + CHAR_ACTWALK,opt,2,TRUE ); + } + } + if( retvalue == CHAR_WALKSUCCESSED ) { + if( CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE ) == BATTLE_CHARMODE_NONE ){ + CHAR_sendCDCharaAtWalk( charaindex, of,ox,oy, + CHAR_getDX(dir), CHAR_getDY(dir)); + } + } + return retvalue; +} + +/*------------------------------------------------------------ + * ƽҷ»ʣ + * ¦ + * index int Charƥindex + * dir int + * mode int 0ئʣ1ئ  + * ߯Ի + * CHAR_WALKRET + ------------------------------------------------------------*/ +CHAR_WALKRET CHAR_walk( int index, int dir, int mode) +{ + CHAR_WALKRET ret; + BOOL (*prewalk)(int , int* , int* ); + void (*postwalk)(int); + if( !CHAR_CHECKINDEX( index ) )return CHAR_WALKSYSTEMERROR; + + if( CHAR_getFlg(index,CHAR_ISDIE) ) return CHAR_WALKDIE; + + VALIDATEDIR(dir); + prewalk = (BOOL(*)(int,int*,int*)) + CHAR_getFunctionPointer(index, CHAR_WALKPREFUNC); + + if( prewalk != NULL ) + if( prewalk(index,&dir,&mode) == FALSE ) { + return CHAR_WALKPREWALK; + } + + if( mode == 0 ) + ret = CHAR_walk_move( index, dir ); + else + ret = CHAR_walk_turn( index, dir ); + postwalk = (void(*)(int)) + CHAR_getFunctionPointer(index,CHAR_WALKPOSTFUNC); + + if( postwalk != NULL ) + postwalk(index); + + return ret; +} + +#ifdef _CAX_LNS_NLGSUOXU +CHAR_WALKRET CHAR_walk_jjc( int index, int floor, int ox, int oy, int dir) +{ + CHAR_WALKRET ret; + int mode; + BOOL (*prewalk)(int , int* , int* ); + void (*postwalk)(int); + if( !CHAR_CHECKINDEX( index ) )return CHAR_WALKSYSTEMERROR; + + if( CHAR_getFlg(index,CHAR_ISDIE) ) return CHAR_WALKDIE; + + VALIDATEDIR(dir); + prewalk = (BOOL(*)(int,int*,int*)) + CHAR_getFunctionPointer(index, CHAR_WALKPREFUNC); + + if( prewalk != NULL ) + if( prewalk(index,&dir,&mode) == FALSE ) { + return CHAR_WALKPREWALK; + } + + ret = CHAR_walk_jc( index, floor, ox, oy, dir ); + + postwalk = (void(*)(int)) + CHAR_getFunctionPointer(index,CHAR_WALKPOSTFUNC); + + if( postwalk != NULL ) + postwalk(index); + + return ret; +} +#endif +/*------------------------------------------------------------ + * ھ + * ¦ + * index int ƽҷ̼͵ + * ߯Ի + * ئ + ------------------------------------------------------------*/ +void CHAR_walkcall( int index ) +{ + char tmp[128]; + int dir,mode; + int ret; + POINT start,end; + + if( !CHAR_CHECKINDEX( index ) ) return; + + strcpysafe( tmp ,sizeof(tmp), + CHAR_getWorkChar(index,CHAR_WORKWALKARRAY)); + + CHAR_ctodirmode( tmp[0], &dir ,&mode ); + /* ئëʢƻ + * ʼ 󡼰ë һ ¿ + */ + if( CHAR_getInt( index, CHAR_WHICHTYPE) == CHAR_TYPEPLAYER ) { + if( CHAR_getWorkInt( index, CHAR_WORKPARTYMODE ) == CHAR_PARTY_LEADER ) { + end.x = CHAR_getInt( index, CHAR_X); + end.y = CHAR_getInt( index, CHAR_Y); + } + } + + /* */ + ret = CHAR_walk( index , dir ,mode ); + + if( mode == 0 && ret == CHAR_WALKSUCCESSED ) { + /* лئëھ */ + if( CHAR_getInt( index, CHAR_WHICHTYPE) == CHAR_TYPEPLAYER ) { + + + if( CHAR_getWorkInt( index, CHAR_WORKPARTYMODE) == CHAR_PARTY_LEADER ) { + int i; + for( i = 1; i < CHAR_PARTYMAX; i ++ ) { + int toindex = CHAR_getWorkInt( index, i + CHAR_WORKPARTYINDEX1); + if( CHAR_CHECKINDEX(toindex) ) { + int parent_dir; + /* Ҽ ʼ󡼰 ëƻ */ + /* */ + start.x = CHAR_getInt( toindex, CHAR_X); + start.y = CHAR_getInt( toindex, CHAR_Y); + parent_dir = NPC_Util_getDirFromTwoPoint( &start,&end ); + /* ·ūë ¿б + * ݼҷ󡼰Ҽ ëܰ + */ + end = start; + if( parent_dir != -1 ) { + CHAR_walk( toindex, parent_dir, 0); + +#if 1 + // Robin 0702 petFollow + if( CHAR_getWorkInt( toindex, CHAR_WORKPETFOLLOW) != -1 ) { + int petindex = CHAR_getWorkInt( toindex, CHAR_WORKPETFOLLOW); + if( CHAR_CHECKINDEX(petindex) ) { + int parent_dir; + /* Ҽ ʼ󡼰 ëƻ */ + /* */ + end.x = CHAR_getInt( toindex, CHAR_X); + end.y = CHAR_getInt( toindex, CHAR_Y); + start.x = CHAR_getInt( petindex, CHAR_X); + start.y = CHAR_getInt( petindex, CHAR_Y); + + if( end.x > start.x ) end.x --; + else if( end.x < start.x ) end.x ++; + if( end.y > start.y ) end.y --; + else if( end.y < start.y ) end.y ++; + + parent_dir = NPC_Util_getDirFromTwoPoint( &start,&end ); + if( parent_dir != -1 ) { + if( CHAR_walk( petindex, parent_dir, 0) == CHAR_WALKSUCCESSED ) + { + CHAR_setWorkInt( petindex, CHAR_WORKPETFOLLOWCOUNT, + 1 + CHAR_getWorkInt( petindex, CHAR_WORKPETFOLLOWCOUNT) ); + if( CHAR_getWorkInt( petindex, CHAR_WORKPETFOLLOWCOUNT) > 1000 ){ + CHAR_setWorkInt( petindex, CHAR_WORKPETFOLLOWCOUNT, 0); + CHAR_pickupFollowPet( toindex, petindex ); + } + + } + } + }else { + CHAR_setWorkInt( toindex, CHAR_WORKPETFOLLOW, -1); + } + + } + +#endif + + } + } + else { + /* ئ */ + CHAR_setWorkInt( index, i+CHAR_WORKPARTYINDEX1, -1); + } + } + } +#if 1 + // Robin 0702 petFollow + if( CHAR_getWorkInt( index, CHAR_WORKPETFOLLOW) != -1 ) { + int petindex = CHAR_getWorkInt( index, CHAR_WORKPETFOLLOW); + if( CHAR_CHECKINDEX(petindex) ) { + int parent_dir; + /* Ҽ ʼ󡼰 ëƻ */ + /* */ + end.x = CHAR_getInt( index, CHAR_X); + end.y = CHAR_getInt( index, CHAR_Y); + start.x = CHAR_getInt( petindex, CHAR_X); + start.y = CHAR_getInt( petindex, CHAR_Y); + + if( end.x > start.x ) end.x --; + else if( end.x < start.x ) end.x ++; + if( end.y > start.y ) end.y --; + else if( end.y < start.y ) end.y ++; + + parent_dir = NPC_Util_getDirFromTwoPoint( &start,&end ); + + //if( (end.x == start.x) && (end.x == start.y) ) + // parent_dir = -1; + + /* ·ūë ¿б + * ݼҷ󡼰Ҽ ëܰ + */ + //print(" pdir:%d sx:%d sy:%d ex:%d ey:%d ", + // parent_dir, start.x, start.y, end.x, end.y ); + //end = start; + + if( parent_dir != -1 ) { + if( CHAR_walk( petindex, parent_dir, 0) == CHAR_WALKSUCCESSED ) + { + CHAR_setWorkInt( petindex, CHAR_WORKPETFOLLOWCOUNT, + 1 + CHAR_getWorkInt( petindex, CHAR_WORKPETFOLLOWCOUNT) ); + if( CHAR_getWorkInt( petindex, CHAR_WORKPETFOLLOWCOUNT) > 1000 ) + { + /* + CHAR_setInt( petindex, CHAR_VARIABLEAI, + 200 + CHAR_getInt( petindex, CHAR_VARIABLEAI) ); + */ + CHAR_setWorkInt( petindex, CHAR_WORKPETFOLLOWCOUNT, 0); + CHAR_pickupFollowPet( index, petindex ); + } + } + } + } + else { + /* ئ */ + CHAR_setWorkInt( index, CHAR_WORKPETFOLLOW, -1); + } + + } + +#endif + + } + } + + /* 99/03/09 By Kawata */ + /* walkWALKARRAYʧľؤ¼ƥ + * Ի ƻ + */ + strcpysafe( tmp ,sizeof(tmp), + CHAR_getWorkChar(index,CHAR_WORKWALKARRAY)); + if( strlen( tmp) > 0 ) { + CHAR_setWorkChar(index,CHAR_WORKWALKARRAY,&tmp[1]); + } + + /* ë׻ */ + CHAR_setWorkInt( index, CHAR_WORKWALKSTARTSEC , NowTime.tv_sec ); + CHAR_setWorkInt( index, CHAR_WORKWALKSTARTMSEC , NowTime.tv_usec ); +} + + + +/*------------------------------------------------------------ + * 炙ë £ + * ¦ + * index int ƽҷ ƥ̼͵ + * dir char* ٯ + * id int ID + * ߯Ի + * ئ + ------------------------------------------------------------*/ +void CHAR_walk_start(int index, int x, int y, char* dir, BOOL mapsendmode ) +{ + + if( !CHAR_CHECKINDEX( index ) )return; + + // Nuke 08/27: Stop wap + /* + { + int ox, oy; + const int seesiz = MAP_CHAR_DEFAULTSEESIZ; + ox = CHAR_getInt(index,CHAR_X); + oy = CHAR_getInt(index,CHAR_Y); + if ( ABS(x - ox) > seesiz || ABS(y - oy) > seesiz ) { + CHAR_talkToCli(index, -1, "ߡ", CHAR_COLORYELLOW); + CONNECT_setCloseRequest_debug(getfdFromCharaIndex(index) , 1); + return; + } + } + */ + + + + 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]; + char c_msg[5][1024*6]; + int strpos[5] = {0,0,0,0,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; + memset(c_msg[0], 0, sizeof(c_msg[0])); + memset(c_msg[1], 0, sizeof(c_msg[1])); + memset(c_msg[2], 0, sizeof(c_msg[2])); + memset(c_msg[3], 0, sizeof(c_msg[3])); + memset(c_msg[4], 0, sizeof(c_msg[4])); + c_msg[0][0] = '\0'; + c_msg[1][0] = '\0'; + c_msg[2][0] = '\0'; + c_msg[3][0] = '\0'; + c_msg[4][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(strpos[0]+strlen( introduction)<=5120){ + strcpysafe( &c_msg[0][strpos[0]], sizeof( c_msg[0]) - strpos[0], + introduction); + strpos[0] += strlen( introduction); + }else if(strpos[1]+strlen( introduction)<=5120){ + strcpysafe( &c_msg[1][strpos[1]], sizeof( c_msg[0]) - strpos[1], + introduction); + strpos[1] += strlen( introduction); + }else if(strpos[2]+strlen( introduction)<=5120){ + strcpysafe( &c_msg[2][strpos[2]], sizeof( c_msg[2]) - strpos[2], + introduction); + strpos[2] += strlen( introduction); + }else if(strpos[3]+strlen( introduction)<=5120){ + strcpysafe( &c_msg[3][strpos[3]], sizeof( c_msg[3]) - strpos[3], + introduction); + strpos[3] += strlen( introduction); + }else if(strpos[4]+strlen( introduction)<=5120){ + strcpysafe( &c_msg[4][strpos[4]], sizeof( c_msg[4]) - strpos[4], + introduction); + strpos[4] += 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 +#ifdef _STREET_VENDOR + if(CHAR_getInt(c_index,CHAR_WHICHTYPE) == CHAR_TYPEPLAYER && + CHAR_getWorkInt(c_index,CHAR_WORKSTREETVENDOR) == 1 && + CHAR_getWorkInt(c_index,CHAR_WORKBATTLEMODE) == BATTLE_CHARMODE_NONE){ + if(CHAR_makeCAOPTString(objindex,cabuf,sizeof(cabuf), + CHAR_STREETVENDOR_OPEN,CHAR_getWorkChar(c_index,CHAR_STREETVENDOR_NAME))){ + CONNECT_appendCAbuf(fd,cabuf,strlen(cabuf)); + } + } +#endif + +#ifdef _ANGEL_SUMMON + if( CHAR_getInt( c_index, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER && + CHAR_getWorkInt( c_index, CHAR_WORKANGELMODE ) == TRUE ){ + if( CHAR_makeCAOPT1String( objindex, cabuf, sizeof( cabuf), CHAR_ACTANGEL,1 )){ + 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(strpos[0]+strlen( introduction)<=5120){ + strcpysafe( &c_msg[0][strpos[0]], sizeof( c_msg[0]) - strpos[0], + introduction); + strpos[0] += strlen( introduction); + }else if(strpos[1]+strlen( introduction)<=5120){ + strcpysafe( &c_msg[1][strpos[1]], sizeof( c_msg[0]) - strpos[1], + introduction); + strpos[1] += strlen( introduction); + }else if(strpos[2]+strlen( introduction)<=5120){ + strcpysafe( &c_msg[2][strpos[2]], sizeof( c_msg[2]) - strpos[2], + introduction); + strpos[2] += strlen( introduction); + }else if(strpos[3]+strlen( introduction)<=5120){ + strcpysafe( &c_msg[3][strpos[3]], sizeof( c_msg[3]) - strpos[3], + introduction); + strpos[3] += strlen( introduction); + }else if(strpos[4]+strlen( introduction)<=5120){ + strcpysafe( &c_msg[4][strpos[4]], sizeof( c_msg[4]) - strpos[4], + introduction); + strpos[4] += 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 +#ifdef _STREET_VENDOR + if(CHAR_getInt(c_index,CHAR_WHICHTYPE) == CHAR_TYPEPLAYER && + CHAR_getWorkInt(c_index,CHAR_WORKSTREETVENDOR) == 1 && + CHAR_getWorkInt(c_index,CHAR_WORKBATTLEMODE) == BATTLE_CHARMODE_NONE){ + if(CHAR_makeCAOPTString(objindex,cabuf,sizeof(cabuf), + CHAR_STREETVENDOR_OPEN,CHAR_getWorkChar(c_index,CHAR_STREETVENDOR_NAME))){ + CONNECT_appendCAbuf(fd,cabuf,strlen(cabuf)); + } + } +#endif + +#ifdef _ANGEL_SUMMON + if( CHAR_getInt( c_index, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER && + CHAR_getWorkInt( c_index, CHAR_WORKANGELMODE ) == TRUE ){ + if( CHAR_makeCAOPT1String( objindex, cabuf, sizeof( cabuf), + CHAR_ACTANGEL,1 )){ + CONNECT_appendCAbuf( fd,cabuf,strlen(cabuf)); + } + } +#endif + + } + } + } + } + } + dchop( c_msg[0], "," ); + dchop( c_msg[1], "," ); + dchop( c_msg[2], "," ); + dchop( c_msg[3], "," ); + dchop( c_msg[4], "," ); + if( strlen( c_msg[0]) == 0 ) return; + //print("\nc_msg[0]=%s,strpos[0]=%d\n",c_msg[0],strpos[0]); + lssproto_C_send( fd, c_msg[0]); + if(strlen( c_msg[1]) > 0){ + //print("\nc_msg[1]=%s,strpos[1]=%d\n",c_msg[1],strpos[1]); + lssproto_C_send( fd, c_msg[1]); + } + if(strlen( c_msg[2]) > 0){ + //print("\nc_msg[2]=%s,strpos[2]=%d\n",c_msg[2],strpos[2]); + lssproto_C_send( fd, c_msg[2]); + } + if(strlen( c_msg[3]) > 0){ + //print("\nc_msg[3]=%s,strpos[3]=%d\n",c_msg[3],strpos[3]); + lssproto_C_send( fd, c_msg[3]); + } + if(strlen( c_msg[4]) > 0){ + //print("\nc_msg[4]=%s,strpos[4]=%d\n",c_msg[4],strpos[4]); + lssproto_C_send( fd, c_msg[4]); + }//޸˶ر +} + +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'; +} + +#ifdef _CAX_LNS_NLGSUOXU +CHAR_WALKRET CHAR_walk_jc( int charaindex, int of, int ox, int oy, int dir ) +{ + int i; + int fx,fy,ff; + int objbuf[128]; + int objbufindex=0; + int notover=FALSE; + int retvalue=CHAR_WALKSUCCESSED; + + if( !CHAR_CHECKINDEX( charaindex )) return CHAR_WALKSYSTEMERROR; + + CHAR_getCoordinationDir( dir,ox,oy,1,&fx,&fy); + ff = of; + + if( CHAR_getInt( charaindex,CHAR_WHICHTYPE ) == CHAR_TYPEENEMY ){ + RECT walkr; + POINT nextp; + int npccreateindex; + npccreateindex = CHAR_getInt( charaindex,CHAR_NPCCREATEINDEX ); + if( CHAR_isInvincibleArea( ff,fx,fy)) { + CHAR_setInt(charaindex,CHAR_DIR,dir); + retvalue = CHAR_WALKEXTEND; + return retvalue; + } + if( NPC_isBoundarySet( npccreateindex ) && + NPC_createGetRECT( npccreateindex,&walkr ) == TRUE ) + { + nextp.x = fx; + nextp.y = fy; + if( PointInRect( &walkr,&nextp ) == FALSE ){ + CHAR_setInt(charaindex,CHAR_DIR,dir); + retvalue = CHAR_WALKEXTEND; + return retvalue; + } + }else{ + ; + } + } + + + if( CHAR_getFlg( charaindex, CHAR_ISBIG ) == 1 ){ + static POINT offset[5]={ + { 0,-1}, + {-1, 0}, + { 0, 0}, + { 1, 0}, + { 0, 1}, + }; + int k; + for( k=0 ; k<5; k++ ){ + if( !MAP_walkAble( charaindex, ff, fx+offset[k].x, + fy+offset[k].y )){ + CHAR_setInt(charaindex,CHAR_DIR,dir); + retvalue = CHAR_WALK1357; + return retvalue; + } + } + + }else{ + if( CHAR_getDX(dir)*CHAR_getDY(dir) == 0 ){ + if( !MAP_walkAble( charaindex,ff, fx, fy ) ){ + CHAR_setInt(charaindex,CHAR_DIR,dir); + retvalue = CHAR_WALK1357; + return retvalue; + } + }else{ + int xflg,yflg; + if( !MAP_walkAble( charaindex,ff, fx, fy ) ){ + CHAR_setInt(charaindex,CHAR_DIR,dir); + retvalue = CHAR_WALK1357; + return retvalue; + } + + xflg = MAP_walkAble( charaindex,of, ox+CHAR_getDX(dir), oy ); + yflg = MAP_walkAble( charaindex,of, ox, oy+CHAR_getDY(dir) ); + + if( !xflg || !yflg ) { + CHAR_setInt(charaindex,CHAR_DIR,dir); + retvalue = CHAR_WALK1357; + return retvalue; + } + } + } + objbufindex = CHAR_getSameCoordinateObjects( objbuf, arraysizeof( objbuf ), ff,fx,fy ); + for( i = 0 ; i < objbufindex ; i ++ ){ + int objindex= objbuf[i]; + switch( OBJECT_getType(objindex) ){ + case OBJTYPE_CHARA: + if( !CHAR_getFlg( OBJECT_getIndex(objindex),CHAR_ISOVERED) ){ + if(!CHAR_CHECKINDEX(OBJECT_getIndex(objindex))){ + printf("Զɾһ"); + endObjectOne(objindex); + break; + } + notover= TRUE; + } + break; + case OBJTYPE_ITEM: + if( !ITEM_getInt( OBJECT_getIndex(objindex), ITEM_ISOVERED ) ) + notover= TRUE; + break; + case OBJTYPE_GOLD: + break; + default: + break; + } + } + if( notover == TRUE ){ + CHAR_setInt(charaindex,CHAR_DIR,dir); + retvalue = CHAR_WALKHITOBJECT; + return retvalue; + }else{ + for( i = 0 ; i < objbufindex ; i ++ ){ + typedef void (*PREOFUNC)(int,int); + PREOFUNC pfunc=NULL; + int objindex=objbuf[i]; + switch( OBJECT_getType(objindex) ){ + case OBJTYPE_CHARA: + pfunc = (PREOFUNC)CHAR_getFunctionPointer( + OBJECT_getIndex(objindex), + CHAR_PREOVERFUNC); + break; + case OBJTYPE_ITEM: + pfunc = (PREOFUNC)ITEM_getFunctionPointer( + OBJECT_getIndex(objindex), + ITEM_PREOVERFUNC); + break; + case OBJTYPE_GOLD: + break; + default: + break; + } + if( pfunc )pfunc( OBJECT_getIndex(objindex),charaindex ); + } + + CHAR_setInt(charaindex,CHAR_X,fx); + CHAR_setInt(charaindex,CHAR_Y,fy); + CHAR_setInt(charaindex,CHAR_FLOOR,ff); + CHAR_setInt(charaindex,CHAR_DIR,dir); + + { + int objindex; + int ox,oy,of; + objindex = CHAR_getWorkInt( charaindex,CHAR_WORKOBJINDEX ); + of = OBJECT_setFloor(objindex, + CHAR_getInt(charaindex,CHAR_FLOOR)); + ox = OBJECT_setX(objindex,CHAR_getInt(charaindex,CHAR_X)); + oy = OBJECT_setY(objindex,CHAR_getInt(charaindex,CHAR_Y)); + if( !MAP_objmove( objindex, of,ox,oy,ff,fx,fy ) ){ + /* ئƷئ */ + fprint( "ERROR MAP_OBJMOVE objindex=%d(%s)\n",objindex, + CHAR_getUseName( charaindex ) ); + } + } + + CHAR_setInt(charaindex,CHAR_WALKCOUNT, + CHAR_getInt(charaindex,CHAR_WALKCOUNT) + 1 ); + + + for( i = 0 ; i < objbufindex ; i ++ ){ + typedef void (*POSTOFUNC)(int,int); + POSTOFUNC pfunc=NULL; + int objindex=objbuf[i]; + + switch( OBJECT_getType(objindex) ){ + case OBJTYPE_CHARA: + pfunc = (POSTOFUNC)CHAR_getFunctionPointer( + OBJECT_getIndex(objindex), + CHAR_POSTOVERFUNC); + break; + case OBJTYPE_ITEM: + pfunc = (POSTOFUNC)ITEM_getFunctionPointer( OBJECT_getIndex(objindex), ITEM_POSTOVERFUNC); + break; + case OBJTYPE_GOLD: + break; + default: + break; + } + if( pfunc )pfunc( OBJECT_getIndex(objindex),charaindex ); + } + objbufindex = CHAR_getSameCoordinateObjects(objbuf, arraysizeof(objbuf), of, ox, oy ); + for( i=0 ;i 0 ) { + CHAR_setWorkInt( charaindex, CHAR_WORK_TOHELOS_COUNT, count -1); + if( count -1 == 0 ) { + //CHAR_talkToCli( charaindex, -1, "ߵЧѵ", CHAR_COLORWHITE); + } + } + par = ENCOUNT_getEncountPercentMin( charaindex, of,ox,oy); + if( par != -1 ) { + if( CHAR_getWorkInt( charaindex, CHAR_WORKENCOUNTPROBABILITY_MIN) != par ){ + flg = TRUE; + CHAR_setWorkInt( charaindex, CHAR_WORKENCOUNTPROBABILITY_MIN, par); + } + } + + par = ENCOUNT_getEncountPercentMax( charaindex, of,ox,oy); + if( par != -1 ) { + if( CHAR_getWorkInt( charaindex, CHAR_WORKENCOUNTPROBABILITY_MAX) != par ){ + flg = TRUE; + CHAR_setWorkInt( charaindex, CHAR_WORKENCOUNTPROBABILITY_MAX, par); + } + } + // Arminius 7.12 login announce + /* + { + int enfd = getfdFromCharaIndex( charaindex ); + if (CONNECT_get_announced(enfd)==0) { + // Robin 0720 + //AnnounceToPlayer(charaindex); + AnnounceToPlayerWN( enfd ); + CONNECT_set_announced(enfd,1); + } + } + */ + // Arminius 6.22 check Encounter + // Nuke 0622: Provide No Enemy function + { + int enfd = getfdFromCharaIndex( charaindex ); + int eqen = getEqNoenemy( enfd ); // Arminius 7.2: Ra's amulet + int noen = getNoenemy(enfd); + + // Arminius 7.31 cursed stone + if (getStayEncount(enfd)>0) { + clearStayEncount(enfd); + } + //print("\n enfd=%d,eqen=%d,noen=%d", enfd, eqen, noen); + + // Arminius 7.2 Ra's amulet + if (eqen>=200) { + noen=1; + } else if (eqen>=120) { + if ((ff==100)||(ff==200)||(ff==300)||(ff==400)||(ff==500)) noen=1; + } else if (eqen>=80) { + if ((ff==100)||(ff==200)||(ff==300)||(ff==400)) noen=1; + } else if (eqen>=40) { + if ((ff==100)||(ff==200)) noen=1; + } + + + //print("\n noen=%d", noen); + if (noen==0) { + int maxep = CHAR_getWorkInt(charaindex, CHAR_WORKENCOUNTPROBABILITY_MAX); + int minep = CHAR_getWorkInt(charaindex, CHAR_WORKENCOUNTPROBABILITY_MIN); + int cep = CONNECT_get_CEP(enfd); + +#ifdef _PROFESSION_SKILL // WON ADD ְҵ + int temp=0; + int p_cep = CHAR_getWorkInt(charaindex, CHAR_ENCOUNT_FIX); + if( p_cep != 0 ){ + if( CHAR_getWorkInt( charaindex, CHAR_ENCOUNT_NUM) < (int)time(NULL) ){ + CHAR_talkToCli( charaindex, -1, "Чý", CHAR_COLORYELLOW); + CHAR_setWorkInt( charaindex, CHAR_ENCOUNT_FIX, 0); + CHAR_setWorkInt( charaindex, CHAR_ENCOUNT_NUM, 0); + } + temp = cep * (100 + p_cep ) / 100; + }else{ + temp = cep; + } +#endif + + if (cepmaxep) cep=maxep; + if (CHAR_getWorkInt(charaindex,CHAR_WORKBATTLEMODE)==BATTLE_CHARMODE_NONE) { + int entflag=1; + { + int objindex,index; + OBJECT obj; + for ( obj = MAP_getTopObj( ff, fx, fy); obj; obj = NEXT_OBJECT( obj)) { + objindex = GET_OBJINDEX( obj); + if (OBJECT_getType( objindex) == OBJTYPE_CHARA) { + int etype; + index = OBJECT_getIndex( objindex); + if (!CHAR_CHECKINDEX( index)) continue; + if( CHAR_getInt( index, CHAR_WHICHTYPE) == CHAR_TYPENPCENEMY && + CHAR_getWorkInt( index, CHAR_WORKEVENTTYPE) == CHAR_EVENT_ENEMY ) { + CHAR_setInt( charaindex, CHAR_X, ox); + CHAR_setInt( charaindex, CHAR_Y, oy); + lssproto_XYD_send( getfdFromCharaIndex(charaindex), + CHAR_getInt( charaindex, CHAR_X ), + CHAR_getInt( charaindex, CHAR_Y ), + CHAR_getInt( charaindex, CHAR_DIR ) ); + break; + } + etype = CHAR_getWorkInt( index, CHAR_WORKEVENTTYPE); + if (etype!=CHAR_EVENT_NONE) { + if (etype==CHAR_EVENT_WARP) entflag=0; + } + } + } + } + + +#ifdef _PROFESSION_SKILL // WON ADD ְҵ +#ifdef _ENEMY_ACTION + if( rand()%(120*getEnemyAction()) < temp ){ +#else + if( rand()%120 < temp ){ +#endif +#else +#ifdef _ENEMY_ACTION + if( rand()%(120*getEnemyAction()) < cep ){ +#else + if (rand()%120 0 ) { + int Rnum=0; + int RandEnemy = getEqRandenemy( enfd); + Rnum = RAND(0,100); + if( Rnum > RandEnemy ) { +#endif + //encounter!! + cep = minep; + lssproto_EN_recv(enfd, + CHAR_getInt(charaindex,CHAR_X), + CHAR_getInt(charaindex,CHAR_Y)); +#ifdef _Item_MoonAct + } + }else{ + cep = minep; + lssproto_EN_recv(enfd, + CHAR_getInt(charaindex,CHAR_X), + CHAR_getInt(charaindex,CHAR_Y)); + } +#endif + } + } else { + if (cep +#include +#include +#include +#include +#include +#include +#include "common.h" +#include "char.h" +#include "util.h" +#include "buf.h" +#include "npcutil.h" +#include "char_base.h" +#include "object.h" +#include "char_data.h" +#include "handletime.h" +#include "chatmagic.h" +#include "configfile.h" +#include "readmap.h" +#include "map_deal.h" +#include "lssproto_serv.h" +#include "log.h" +#include "battle.h" +#include "pet.h" +#include "enemy.h" +#include "encount.h" +#include "magic_base.h" +#include "magic.h" +#include "pet_skill.h" +#include "pet_event.h" +#include "item_gen.h" +#include "mclient.h" +#include "npc_eventaction.h" +#include "map_warppoint.h" +#include "npc_manorsman.h" +#include "net.h" +#include "saacproto_cli.h" +#include "npc_scheduleman.h" +#include "trade.h" +#include "npccreate.h" + +#ifdef _CHAR_PROFESSION // WON ADD ְҵ +#include "profession_skill.h" +#endif +#include "char_talk.h" + +// WON ADD 峤 +#include "family.h" + +#include "petmail.h" + +#ifdef _AUTO_PK +#include "npc_autopk.h" +#endif +#ifdef _ALLBLUES_LUA +#include "mylua/ablua.h" +#endif +// WON ADD ¶ȡITEMSET.TXT +#include "item.h" +#include "sasql.h" + +extern tagRidePetTable ridePetTable[296]; +extern int *pWorkAttackPower; +extern time_t initTime; +int *pWorkAttackPower = NULL; + +struct GMINFO gminfo[GMMAXNUM]; +#ifdef _JOB_AUTOPK + int jobautopk=0; +#endif + +extern char mmcdkey[10][32]; +extern char mmcdkeybuf[10][64]; + +void CHAR_CHAT_DEBUG_warp( int charindex , char *message ) +{ + char token[100]; + int fl,x,y; + easyGetTokenFromString( message , 1 , token, sizeof(token)); + fl = atoi( token ); + easyGetTokenFromString( message , 2 , token , sizeof(token)); + x = atoi( token ); + easyGetTokenFromString( message , 3 , token , sizeof(token)); + y = atoi( token ); + + CHAR_warpToSpecificPoint(charindex, fl, x, y); + +} + + +void CHAR_CHAT_DEBUG_hp( int charindex , char *message ) +{ + CHAR_setInt( charindex , CHAR_HP,atoi( message ) ); + CHAR_complianceParameter( charindex ); + CHAR_send_P_StatusString( charindex , CHAR_P_STRING_HP); +} +void CHAR_CHAT_DEBUG_setmp( int charindex , char *message ) +{ + int i; + char setmp[15]; + char cdkey[CDKEYLEN]; + char token[128]; + int playernum = CHAR_getPlayerMaxNum(); + easyGetTokenFromString( message , 1 , setmp, sizeof(setmp)); + easyGetTokenFromString( message , 2 , cdkey, sizeof(cdkey)); + if(strlen(cdkey)>0){ + for(i=0;i=playernum) + { + CHAR_talkToCli( charindex, -1, "˺Ų~", CHAR_COLORYELLOW ); + return; + } + CHAR_setInt( i , CHAR_MAXMP, atoi( setmp ) ); + CHAR_setInt( i , CHAR_MP, atoi( setmp ) ); + CHAR_complianceParameter( i ); + CHAR_send_P_StatusString( i , CHAR_P_STRING_MP); + sprintf( token, "[GM]%sMPΪ%d!", CHAR_getChar( charindex, CHAR_NAME),(int)atoi(setmp)/100); + CHAR_talkToCli( i, -1, token, CHAR_COLORYELLOW ); + sprintf( token, "%sMPΪ%d!", CHAR_getChar( i, CHAR_NAME),(int)atoi(setmp)/100); + CHAR_talkToCli( charindex, -1,token, CHAR_COLORYELLOW ); + }else{ + CHAR_setInt( charindex , CHAR_MAXMP, atoi( setmp ) ); + CHAR_setInt( charindex , CHAR_MP, atoi( setmp ) ); + CHAR_complianceParameter( charindex ); + CHAR_send_P_StatusString( charindex , CHAR_P_STRING_MP); + sprintf( token, "MPΪ%d!",(int)atoi(setmp)/100); + CHAR_talkToCli( charindex, -1,token, CHAR_COLORYELLOW ); + } +} + +void CHAR_CHAT_DEBUG_mp( int charindex , char *message ) +{ + int Mymp; + CHAR_setInt( charindex , CHAR_MP, atoi( message ) ); + Mymp = CHAR_getWorkInt( charindex , CHAR_WORKMAXMP); + if( Mymp > CHAR_getWorkInt( charindex , CHAR_WORKMAXMP) ) + CHAR_setInt( charindex , CHAR_MP, CHAR_getWorkInt( charindex , CHAR_WORKMAXMP)); + + CHAR_complianceParameter( charindex ); + //CHAR_sendStatusString( charindex , "P"); + CHAR_send_P_StatusString( charindex , CHAR_P_STRING_MP); + +} + +void CHAR_CHAT_DEBUG_str( int charindex , char *message ) +{ + int i; + char str[15]; + char cdkey[CDKEYLEN]; + char token[128]; + int playernum = CHAR_getPlayerMaxNum(); + easyGetTokenFromString( message , 1 , str, sizeof(str)); + easyGetTokenFromString( message , 2 , cdkey, sizeof(cdkey)); + if(strlen(cdkey)>0){ + for(i=0;i=playernum) + { + CHAR_talkToCli( charindex, -1, "˺Ų~", CHAR_COLORYELLOW ); + return; + } + CHAR_setInt( i , CHAR_STR,atoi( str ) ); + CHAR_complianceParameter( i ); + //CHAR_sendStatusString( charindex , "P"); + CHAR_send_P_StatusString( i ,CHAR_P_STRING_STR|CHAR_P_STRING_MAXHP|CHAR_P_STRING_ATK); + sprintf( token, "[GM]%sΪ%d!", CHAR_getChar( charindex, CHAR_NAME),(int)atoi(str)/100); + CHAR_talkToCli( i, -1, token, CHAR_COLORYELLOW ); + sprintf( token, "%sΪ%d!", CHAR_getChar( i, CHAR_NAME),(int)atoi(str)/100); + CHAR_talkToCli( charindex, -1,token, CHAR_COLORYELLOW ); + }else{ + CHAR_setInt( charindex , CHAR_STR,atoi( str ) ); + CHAR_complianceParameter( charindex ); + //CHAR_sendStatusString( charindex , "P"); + CHAR_send_P_StatusString( charindex ,CHAR_P_STRING_STR|CHAR_P_STRING_MAXHP|CHAR_P_STRING_ATK); + sprintf( token, "Ϊ%d!",(int)atoi(str)/100); + CHAR_talkToCli( charindex, -1,token, CHAR_COLORYELLOW ); + } +} + +void CHAR_CHAT_DEBUG_tgh( int charindex , char *message ) +{ + int i; + char tgh[15]; + char cdkey[CDKEYLEN]; + char token[128]; + int playernum = CHAR_getPlayerMaxNum(); + easyGetTokenFromString( message , 1 , tgh, sizeof(tgh)); + easyGetTokenFromString( message , 2 , cdkey, sizeof(cdkey)); + if(strlen(cdkey)>0){ + for(i=0;i=playernum) + { + CHAR_talkToCli( charindex, -1, "˺Ų~", CHAR_COLORYELLOW ); + return; + } + CHAR_setInt( i , CHAR_TOUGH,atoi( tgh ) ); + CHAR_complianceParameter( i ); + //CHAR_sendStatusString( charindex , "P"); + CHAR_send_P_StatusString( i ,CHAR_P_STRING_TOUGH|CHAR_P_STRING_MAXHP|CHAR_P_STRING_DEF); + sprintf( token, "[GM]%sΪ%d!", CHAR_getChar( charindex, CHAR_NAME),(int)atoi(tgh)/100); + CHAR_talkToCli( i, -1, token, CHAR_COLORYELLOW ); + sprintf( token, "%sΪ%d!", CHAR_getChar( i, CHAR_NAME),(int)atoi(tgh)/100); + CHAR_talkToCli( charindex, -1,token, CHAR_COLORYELLOW ); + }else{ + CHAR_setInt( charindex , CHAR_TOUGH,atoi( tgh ) ); + CHAR_complianceParameter( charindex ); + //CHAR_sendStatusString( charindex , "P"); + CHAR_send_P_StatusString( charindex ,CHAR_P_STRING_TOUGH|CHAR_P_STRING_MAXHP|CHAR_P_STRING_DEF); + sprintf( token, "Ϊ%d!",(int)atoi(tgh)/100); + CHAR_talkToCli( charindex, -1,token, CHAR_COLORYELLOW ); + } +} + +void CHAR_CHAT_DEBUG_dex( int charindex , char *message ) +{ + int i; + char dex[15]; + char cdkey[CDKEYLEN]; + char token[128]; + int playernum = CHAR_getPlayerMaxNum(); + easyGetTokenFromString( message , 1 , dex, sizeof(dex)); + easyGetTokenFromString( message , 2 , cdkey, sizeof(cdkey)); + if(strlen(cdkey)>0){ + for(i=0;i=playernum) + { + CHAR_talkToCli( charindex, -1, "˺Ų~", CHAR_COLORYELLOW ); + return; + } + CHAR_setInt( i , CHAR_DEX,atoi( dex ) ); + CHAR_complianceParameter( i ); + //CHAR_sendStatusString( charindex , "P"); + CHAR_send_P_StatusString( i ,CHAR_P_STRING_DEX|CHAR_P_STRING_MAXHP|CHAR_P_STRING_ATK|CHAR_P_STRING_QUICK); + sprintf( token, "[GM]%sΪ%d!", CHAR_getChar( charindex, CHAR_NAME),(int)atoi(dex)/100); + CHAR_talkToCli( i, -1, token, CHAR_COLORYELLOW ); + sprintf( token, "%sΪ%d!", CHAR_getChar( i, CHAR_NAME),(int)atoi(dex)/100); + CHAR_talkToCli( charindex, -1,token, CHAR_COLORYELLOW ); + }else{ + CHAR_setInt( charindex , CHAR_DEX,atoi( dex ) ); + CHAR_complianceParameter( charindex ); + //CHAR_sendStatusString( charindex , "P"); + CHAR_send_P_StatusString( charindex ,CHAR_P_STRING_DEX|CHAR_P_STRING_MAXHP|CHAR_P_STRING_ATK|CHAR_P_STRING_QUICK); + sprintf( token, "Ϊ%d!",(int)atoi(dex)/100); + CHAR_talkToCli( charindex, -1,token, CHAR_COLORYELLOW ); + } +} +void CHAR_CHAT_DEBUG_vital( int charindex , char *message ) +{ + int i; + char vital[15]; + char cdkey[CDKEYLEN]; + char token[128]; + int playernum = CHAR_getPlayerMaxNum(); + easyGetTokenFromString( message , 1 , vital, sizeof(vital)); + easyGetTokenFromString( message , 2 , cdkey, sizeof(cdkey)); + if(strlen(cdkey)>0){ + for(i=0;i=playernum) + { + CHAR_talkToCli( charindex, -1, "˺Ų~", CHAR_COLORYELLOW ); + return; + } + CHAR_setInt( i , CHAR_VITAL,atoi( vital ) ); + CHAR_complianceParameter( i ); + //CHAR_sendStatusString( charindex , "P"); + CHAR_send_P_StatusString( i ,CHAR_P_STRING_VITAL|CHAR_P_STRING_MAXHP|CHAR_P_STRING_DEF); + sprintf( token, "[GM]%sΪ%d!", CHAR_getChar( charindex, CHAR_NAME),(int)atoi(vital)/100); + CHAR_talkToCli( i, -1, token, CHAR_COLORYELLOW ); + sprintf( token, "%sΪ%d!", CHAR_getChar( i, CHAR_NAME),(int)atoi(vital)/100); + CHAR_talkToCli( charindex, -1,token, CHAR_COLORYELLOW ); + }else{ + CHAR_setInt( charindex , CHAR_VITAL,atoi( vital ) ); + CHAR_complianceParameter( charindex ); + //CHAR_sendStatusString( charindex , "P"); + CHAR_send_P_StatusString( charindex ,CHAR_P_STRING_VITAL|CHAR_P_STRING_MAXHP|CHAR_P_STRING_DEF); + sprintf( token, "Ϊ%d!",(int)atoi(vital)/100); + CHAR_talkToCli( charindex, -1,token, CHAR_COLORYELLOW ); + } +} +void CHAR_CHAT_DEBUG_luck( int charindex , char *message ) +{ + int i; + char buf[64]; + int luck; + char cdkey[CDKEYLEN]; + char token[128]; + int playernum = CHAR_getPlayerMaxNum(); + easyGetTokenFromString( message , 1 , buf, sizeof(buf)); + luck=atoi(buf); + easyGetTokenFromString( message , 2 , cdkey, sizeof(cdkey)); + if(luck<1) + luck=1; + else if(luck>5) + luck=5; + if(strlen(cdkey)>0){ + for(i=0;i=playernum) + { + CHAR_talkToCli( charindex, -1, "˺Ų~", CHAR_COLORYELLOW ); + return; + } + CHAR_setInt( i , CHAR_LUCK,luck); + CHAR_complianceParameter( i ); + //CHAR_sendStatusString( charindex , "P"); + CHAR_send_P_StatusString( i , CHAR_P_STRING_LUCK); + sprintf( token, "[GM]%sΪ%d!", CHAR_getChar( charindex, CHAR_NAME),luck); + CHAR_talkToCli( i, -1, token, CHAR_COLORYELLOW ); + sprintf( token, "%sΪ%d!", CHAR_getChar( i, CHAR_NAME),luck); + CHAR_talkToCli( charindex, -1,token, CHAR_COLORYELLOW ); + }else{ + CHAR_setInt( charindex , CHAR_LUCK,luck); + CHAR_complianceParameter( charindex ); + //CHAR_sendStatusString( charindex , "P"); + CHAR_send_P_StatusString( charindex , CHAR_P_STRING_LUCK); + sprintf( token, "Ϊ%d!",luck); + CHAR_talkToCli( charindex, -1,token, CHAR_COLORYELLOW ); + } +} + +void CHAR_CHAT_DEBUG_gold( int charindex , char *message ) +{ + int i, MaxGold, money; + char cdkey[CDKEYLEN]; + char buf[64]; + char token[128]; + int playernum = CHAR_getPlayerMaxNum(); + easyGetTokenFromString( message , 1 , buf, sizeof(buf)); + money = atoi( buf ); + easyGetTokenFromString( message , 2 , cdkey, sizeof(cdkey)); + MaxGold = CHAR_getMaxHaveGold( charindex); + if( money > MaxGold ) + money = MaxGold; + if(strlen(cdkey)>0){ + for(i=0;i=playernum) + { + CHAR_talkToCli( charindex, -1, "˺Ų~", CHAR_COLORYELLOW ); + return; + } + CHAR_setInt( i , CHAR_GOLD , money ); + CHAR_complianceParameter( i ); + CHAR_send_P_StatusString( i , CHAR_P_STRING_GOLD); + sprintf( token, "[GM]%sĽǮΪ%d!", CHAR_getChar( charindex, CHAR_NAME),money); + CHAR_talkToCli( i, -1, token, CHAR_COLORYELLOW ); + sprintf( token, "%sĽǮΪ%d!", CHAR_getChar( i, CHAR_NAME),money); + CHAR_talkToCli( charindex, -1,token, CHAR_COLORYELLOW ); + }else{ + CHAR_setInt( charindex , CHAR_GOLD , money ); + CHAR_complianceParameter( charindex ); + CHAR_send_P_StatusString( charindex , CHAR_P_STRING_GOLD); + sprintf( token, "ǮΪ%d!",money); + CHAR_talkToCli( charindex, -1,token, CHAR_COLORYELLOW ); + } +} + +#ifdef _TEST_DROPITEMS +void CHAR_CHAT_DEBUG_dropmypet( int charindex, char *message ) +{ + char buf[256]; + int petID, x, y, floor, objindex, petindex, count=0; + int i, j, k, petarray, cLeve=1; + + if( getStringFromIndexWithDelim( message, " ", 1, buf, sizeof( buf)) == FALSE ) return; + petID = atoi( buf); + if( getStringFromIndexWithDelim( message, " ", 2, buf, sizeof( buf)) != FALSE ){ + cLeve = atoi( buf); + } + + floor = CHAR_getInt( charindex, CHAR_FLOOR); + x = CHAR_getInt( charindex, CHAR_X); + y = CHAR_getInt( charindex, CHAR_Y); + if( getStringFromIndexWithDelim( message, " ", 3, buf, sizeof( buf)) != FALSE ){ + floor = atoi( buf); + } + if( getStringFromIndexWithDelim( message, " ", 4, buf, sizeof( buf)) != FALSE ){ + x = atoi( buf); + } + if( getStringFromIndexWithDelim( message, " ", 5, buf, sizeof( buf)) != FALSE ){ + y = atoi( buf); + } + for( i=(x-3); i<(x+3); i++) { + for( j=(y-3); j<(y+3); j++) { + petarray = ENEMY_getEnemyArrayFromId( petID); + petindex = ENEMY_TEST_createPetIndex( petarray ); + if( !CHAR_CHECKINDEX( petindex) ){ + CHAR_talkToCli( charindex, -1, "err Can't create pet", CHAR_COLORYELLOW); + return; + } + CHAR_complianceParameter( petindex ); + objindex = PET_dropPetAbsolute( petindex, floor, i, j, FALSE ); + if( objindex == -1 ){ + CHAR_talkToCli( charindex, -1, "err Can't Drop", CHAR_COLORYELLOW); + return; + } + for( k = 1; k < cLeve; k ++ ){ // + CHAR_PetLevelUp( petindex ); + CHAR_PetAddVariableAi( petindex, AI_FIX_PETLEVELUP ); + CHAR_setInt( petindex, CHAR_LV, CHAR_getInt( petindex, CHAR_LV) +1 ); + } + CHAR_complianceParameter( petindex ); + CHAR_setInt( petindex , CHAR_HP , CHAR_getWorkInt( petindex , CHAR_WORKMAXHP ) ); + + CHAR_setWorkInt( petindex, CHAR_WORKOBJINDEX, objindex ); + CHAR_setInt( petindex, CHAR_FLOOR, floor); + CHAR_setInt( petindex, CHAR_X, i); + CHAR_setInt( petindex, CHAR_Y, j); + CHAR_sendCToArroundCharacter( objindex); + CHAR_setInt( petindex, CHAR_PUTPETTIME, NowTime.tv_sec); + CHAR_setChar( petindex, CHAR_OWNERCDKEY, "SYSTEM_WAYI" ); + CHAR_setChar( petindex, CHAR_OWNERCHARANAME, "SYSTEM_WAYI" ); + count++; + } + } + sprintf( buf, "ܹ %dֻ", count); + CHAR_talkToCli( charindex, -1, buf, CHAR_COLORYELLOW); + + +} + +void CHAR_CHAT_DEBUG_dropmyitem( int charindex, char *message ) +{ + char buf[256]; + int itemID, SitemID, maxflg=0,emptyitemindexinchara, i, j; + int floor, x, y, objindex; + + if( getStringFromIndexWithDelim( message, " ", 1, buf, sizeof( buf)) == FALSE ) return; + SitemID = atoi( buf); + if( getStringFromIndexWithDelim( message, " ", 2, buf, sizeof( buf)) != FALSE ){ + maxflg = atoi( buf); + } + floor = CHAR_getInt( charindex, CHAR_FLOOR); + x = CHAR_getInt( charindex, CHAR_X); + y = CHAR_getInt( charindex, CHAR_Y); + if( getStringFromIndexWithDelim( message, " ", 3, buf, sizeof( buf)) != FALSE ){ + floor = atoi( buf); + } + if( getStringFromIndexWithDelim( message, " ", 4, buf, sizeof( buf)) != FALSE ){ + x = atoi( buf); + } + if( getStringFromIndexWithDelim( message, " ", 5, buf, sizeof( buf)) != FALSE ){ + y = atoi( buf); + } + itemID = SitemID; + + + for( i=(x-3); i<(x+3); i++) { + for( j=(y-3); j<(y+3); j++) { + int ret = 0 , count=0; + int itemindex; + while( count < 10 ){ + count++; + itemindex = ITEM_makeItemAndRegist( itemID ); + if( maxflg == 1 ) itemID++; + if( !ITEM_CHECKINDEX( itemindex)) continue; + break; + } + emptyitemindexinchara = CHAR_findEmptyItemBox( charindex ); + + CHAR_setItemIndex( charindex, emptyitemindexinchara, itemindex ); + ITEM_setWorkInt(itemindex, ITEM_WORKOBJINDEX,-1); + ITEM_setWorkInt(itemindex, ITEM_WORKCHARAINDEX,charindex); + CHAR_sendItemDataOne( charindex, emptyitemindexinchara); + //drop + if( (ret = CHAR_DropItemFXY( charindex, emptyitemindexinchara, + floor, i, j, &objindex )) != 0 ){ + char buf[256]; + sprintf( buf, "%d", ret); + CHAR_talkToCli( charindex, -1, buf, CHAR_COLORYELLOW); + } + ITEM_setInt(itemindex,ITEM_PUTTIME,NowTime.tv_sec); + CHAR_sendWatchEvent(objindex,CHAR_ACTSTAND,NULL,0,TRUE); + CHAR_setItemIndex(charindex, emptyitemindexinchara ,-1); + CHAR_sendItemDataOne(charindex, emptyitemindexinchara); + CHAR_sendCToArroundCharacter(CHAR_getWorkInt( charindex, CHAR_WORKOBJINDEX)); + } + } + { + char buf[256]; + sprintf( buf, "ID%d", itemID-1); + CHAR_talkToCli( charindex, -1, buf, CHAR_COLORYELLOW); + } +} +#endif + +void CHAR_CHAT_DEBUG_additem( int charindex , char *message ) +{ + + int emptyitemindexinchara, itemindex; + int i; + int num = 0; + int itemid; + char buf[64]; + char msgbuf[128]; + char cdkey[CDKEYLEN]; + easyGetTokenFromString( message , 1 , buf, sizeof(buf)); + itemid = atoi( buf); + easyGetTokenFromString( message , 2 , buf, sizeof(buf)); + num = atoi( buf); + easyGetTokenFromString( message , 3 , cdkey, sizeof(cdkey)); + + if( num <= 0 ) num = 1; + + if(strlen(cdkey)>0){ + int playernum = CHAR_getPlayerMaxNum(); + int j; + for(j=0;j=playernum) + { + CHAR_talkToCli( charindex, -1, "˺Ų~", CHAR_COLORYELLOW ); + return; + } + for( i = 0; i < num; i ++ ) { + emptyitemindexinchara = CHAR_findEmptyItemBox( j ); + + if( emptyitemindexinchara < 0 ){ + sprintf( msgbuf, "%sƷλ㡣", CHAR_getChar( j, CHAR_NAME )); + CHAR_talkToCli( charindex, -1, msgbuf, CHAR_COLORYELLOW); + sprintf( msgbuf, "%sƷλ㡣", CHAR_getChar( j, CHAR_NAME )); + CHAR_talkToCli( j, -1, msgbuf, CHAR_COLORYELLOW); + return; + } + + itemindex = ITEM_makeItemAndRegist( itemid ); + + if( itemindex != -1 ){ + CHAR_setItemIndex( j, emptyitemindexinchara, itemindex ); + ITEM_setWorkInt(itemindex, ITEM_WORKOBJINDEX,-1); + ITEM_setWorkInt(itemindex, ITEM_WORKCHARAINDEX,j); + CHAR_sendItemDataOne( j, emptyitemindexinchara); + LogItem( + CHAR_getChar( charindex, CHAR_NAME ), + CHAR_getChar( charindex, CHAR_CDKEY ), +#ifdef _add_item_log_name // WON ADD itemlogitem + itemindex, +#else + atoi( message), +#endif + "AddItem(GM)", + CHAR_getInt( charindex,CHAR_FLOOR), + CHAR_getInt( charindex,CHAR_X ), + CHAR_getInt( charindex,CHAR_Y ), + ITEM_getChar( itemindex, ITEM_UNIQUECODE), + ITEM_getChar( itemindex, ITEM_NAME), + ITEM_getInt( itemindex, ITEM_ID) + + ); + snprintf( msgbuf,sizeof( msgbuf),"[GM]%s%sɹ", + CHAR_getChar( charindex, CHAR_NAME ),ITEM_getChar( itemindex, ITEM_NAME)); + CHAR_talkToCli( j, -1,msgbuf, CHAR_COLORYELLOW); + snprintf( msgbuf, sizeof( msgbuf), "ɹΪ%s %s", + CHAR_getChar( j, CHAR_NAME ),ITEM_getChar( itemindex, ITEM_NAME)); + CHAR_talkToCli( charindex, -1,msgbuf, CHAR_COLORYELLOW); + }else{ + sprintf( msgbuf, "ʧܡ" ); + CHAR_talkToCli( charindex, -1,msgbuf, CHAR_COLORYELLOW); + } + } + }else{ + for( i = 0; i < num; i ++ ) { + emptyitemindexinchara = CHAR_findEmptyItemBox( charindex ); + + if( emptyitemindexinchara < 0 ){ + sprintf( msgbuf, "Ʒλ㡣" ); + + CHAR_talkToCli( charindex, -1, msgbuf, CHAR_COLORYELLOW); + + return; + } + + itemindex = ITEM_makeItemAndRegist( itemid ); + + if( itemindex != -1 ){ + CHAR_setItemIndex( charindex, emptyitemindexinchara, itemindex ); + ITEM_setWorkInt(itemindex, ITEM_WORKOBJINDEX,-1); + ITEM_setWorkInt(itemindex, ITEM_WORKCHARAINDEX,charindex); + CHAR_sendItemDataOne( charindex, emptyitemindexinchara); + LogItem( + CHAR_getChar( charindex, CHAR_NAME ), + CHAR_getChar( charindex, CHAR_CDKEY ), +#ifdef _add_item_log_name // WON ADD itemlogitem + itemindex, +#else + atoi( message), +#endif + "AddItem(GM)", + CHAR_getInt( charindex,CHAR_FLOOR), + CHAR_getInt( charindex,CHAR_X ), + CHAR_getInt( charindex,CHAR_Y ), + ITEM_getChar( itemindex, ITEM_UNIQUECODE), + ITEM_getChar( itemindex, ITEM_NAME), + ITEM_getInt( itemindex, ITEM_ID) + + ); + snprintf( msgbuf, sizeof( msgbuf), "%sɹ", + ITEM_getChar( itemindex, ITEM_NAME)); + CHAR_talkToCli( charindex, -1,msgbuf, CHAR_COLORYELLOW); + }else{ + sprintf( msgbuf, "ʧܡ" ); + CHAR_talkToCli( charindex, -1, msgbuf, CHAR_COLORYELLOW); + } + } + } +} + + +void CHAR_CHAT_DEBUG_metamo( int charindex , char *message ) +{ +#ifdef _CAX_METAMO_OFF + char metamoid[12]; +#else + char metamoid[7]; +#endif + char cdkey[CDKEYLEN]; + char token[128]; + int i=0; + int playernum = CHAR_getPlayerMaxNum(); + easyGetTokenFromString( message , 1 , metamoid, sizeof(metamoid)); + easyGetTokenFromString( message , 2 , cdkey, sizeof(cdkey)); + if(strlen(cdkey)>0){ + for(i=0;i=playernum) + { + CHAR_talkToCli( charindex, -1, "˺Ų~", CHAR_COLORYELLOW ); + return; + } + CHAR_setInt( i , CHAR_BASEIMAGENUMBER , atoi( metamoid ) ); + CHAR_setInt( i , CHAR_BASEBASEIMAGENUMBER , atoi( metamoid ) ); + + CHAR_complianceParameter( i ); + CHAR_sendCToArroundCharacter( CHAR_getWorkInt( i , CHAR_WORKOBJINDEX )); + CHAR_send_P_StatusString( i , CHAR_P_STRING_BASEBASEIMAGENUMBER); + sprintf( token, "[GM]%sΪ%d!", CHAR_getChar( charindex, CHAR_NAME),(int)atoi(metamoid)); + CHAR_talkToCli( i, -1, token, CHAR_COLORYELLOW ); + sprintf( token, "%sΪ%d!", CHAR_getChar( i, CHAR_NAME),(int)atoi(metamoid)); + CHAR_talkToCli( charindex, -1,token, CHAR_COLORYELLOW ); + }else{ + CHAR_setInt( charindex , CHAR_BASEIMAGENUMBER , atoi( metamoid ) ); + CHAR_setInt( charindex , CHAR_BASEBASEIMAGENUMBER , atoi( metamoid ) ); + + CHAR_complianceParameter( charindex ); + CHAR_sendCToArroundCharacter( CHAR_getWorkInt( charindex , CHAR_WORKOBJINDEX )); + CHAR_send_P_StatusString( charindex , CHAR_P_STRING_BASEBASEIMAGENUMBER); + sprintf( token, "Ϊ%d!",(int)atoi(metamoid)); + CHAR_talkToCli( charindex, -1,token, CHAR_COLORYELLOW ); + } +} + +void CHAR_CHAT_DEBUG_info( int charindex , char *message ) +{ + char line[256]; + int index; + + if( strlen( message) != 0 ) { + index = atoi( message); + } + else { + index = charindex; + } + if( !CHAR_CHECKINDEX( index)) { + CHAR_talkToCli( charindex, -1 , "index޷ʹá" , CHAR_COLORWHITE ); + return; + } + + snprintf( line, sizeof( line), + "name:%s i:%d B:%d BB:%d LV:%d EXP:%d MakeSeq:%d", + CHAR_getChar( index, CHAR_NAME), + charindex, + CHAR_getInt( index, CHAR_BASEIMAGENUMBER ), + CHAR_getInt( index, CHAR_BASEBASEIMAGENUMBER ), + CHAR_getInt( index, CHAR_LV ), + CHAR_getInt( index, CHAR_EXP ), + CHAR_getCharMakeSequenceNumber( index)); + + CHAR_talkToCli( charindex, -1 , line , CHAR_COLORWHITE ); + + snprintf( line, sizeof( line), + "Gold:%d HP:%d MP/MHP:%d/%d" , + CHAR_getInt( index, CHAR_GOLD ), + CHAR_getInt( index, CHAR_HP ), + CHAR_getInt( index, CHAR_MP ), + CHAR_getInt( index, CHAR_MAXMP )); + CHAR_talkToCli( charindex, -1 , line , CHAR_COLORWHITE ); + + + if( CHAR_getInt( index, CHAR_WHICHTYPE ) == CHAR_TYPEPET ){ + snprintf( line, sizeof(line), + ":%d :%d :%d :%d :%d :%d :%d :%d :%d ұ:%.2f :%s", + CHAR_getInt( index, CHAR_VITAL )/100, + CHAR_getInt( index, CHAR_STR )/100, + CHAR_getInt( index, CHAR_TOUGH )/100, + CHAR_getInt( index, CHAR_DEX )/100, + CHAR_getWorkInt( index, CHAR_WORKFIXVITAL ), + CHAR_getWorkInt( index, CHAR_WORKATTACKPOWER ), + CHAR_getWorkInt( index, CHAR_WORKDEFENCEPOWER ),//CHAR_WORKFIXDEX + CHAR_getWorkInt( index, CHAR_WORKQUICK ), + CHAR_getInt( index, CHAR_MODAI ), + CHAR_getInt( index, CHAR_VARIABLEAI ) * 0.01, + CHAR_getChar( index, CHAR_UNIQUECODE) ); + }else{ + snprintf( line, sizeof(line), + ":%d :%d :%d :%d :%d :%d :%d :%d :%d", + CHAR_getInt( index, CHAR_VITAL )/100, + CHAR_getInt( index, CHAR_STR )/100, + CHAR_getInt( index, CHAR_TOUGH )/100, + CHAR_getInt( index, CHAR_DEX )/100, + CHAR_getWorkInt( index, CHAR_WORKFIXVITAL ), + CHAR_getWorkInt( index, CHAR_WORKATTACKPOWER ), + CHAR_getWorkInt( index, CHAR_WORKDEFENCEPOWER ), + CHAR_getWorkInt( index, CHAR_WORKFIXCHARM ), + CHAR_getWorkInt( index, CHAR_WORKFIXLUCK )); + } + CHAR_talkToCli( charindex, -1 , line , CHAR_COLORWHITE ); + + + snprintf( line, sizeof(line), + ":%d ˮ:%d :%d :%d", + CHAR_getWorkInt( index, CHAR_WORKFIXEARTHAT ), + CHAR_getWorkInt( index, CHAR_WORKFIXWATERAT ), + CHAR_getWorkInt( index, CHAR_WORKFIXFIREAT ), + CHAR_getWorkInt( index, CHAR_WORKFIXWINDAT )); + CHAR_talkToCli( charindex, -1 , line , CHAR_COLORWHITE ); + + snprintf( line, sizeof( line), + "Sk Itm:%d ChV:%d Rad:%d" , + CHAR_MAXITEMHAVE, + CHAR_getInt( index, CHAR_CHATVOLUME ), + CHAR_getInt( index, CHAR_RADARSTRENGTH ) ); + CHAR_talkToCli( charindex, -1 , line , CHAR_COLORWHITE ); + + + snprintf( line, sizeof( line), + "Status :%d :%d Ĭ:%d ʯ:%d :%d :%d" , + CHAR_getInt( index , CHAR_POISON ), + CHAR_getInt( index , CHAR_PARALYSIS ), + CHAR_getInt( index , CHAR_SLEEP ), + CHAR_getInt( index , CHAR_STONE ), + CHAR_getInt( index , CHAR_DRUNK ), + CHAR_getInt( index , CHAR_CONFUSION ) ); + CHAR_talkToCli( charindex, -1 , line , CHAR_COLORWHITE ); + +#ifdef _PERSONAL_FAME // Arminius: + snprintf( line, sizeof( line), +#ifdef _NEW_MANOR_LAW + "TitInd:%d FL:%d X:%d Y:%d DIR:%d FAME:%d MOMENTUM:%d" , +#else + "TitInd:%d FL:%d X:%d Y:%d DIR:%d FAME:%d" , +#endif + CHAR_getInt( index , CHAR_INDEXOFEQTITLE ), + CHAR_getInt( index , CHAR_FLOOR ), + CHAR_getInt( index , CHAR_X ), + CHAR_getInt( index , CHAR_Y ), + CHAR_getInt( index , CHAR_DIR ), + CHAR_getInt( index , CHAR_FAME) +#ifdef _NEW_MANOR_LAW + ,CHAR_getInt( index , CHAR_MOMENTUM) +#endif + ); +#else + snprintf( line, sizeof( line), + "TitInd:%d FL:%d X:%d Y:%d DIR:%d" , + CHAR_getInt( index , CHAR_INDEXOFEQTITLE ), + CHAR_getInt( index , CHAR_FLOOR ), + CHAR_getInt( index , CHAR_X ), + CHAR_getInt( index , CHAR_Y ), + CHAR_getInt( index , CHAR_DIR ) ); +#endif + CHAR_talkToCli( charindex, -1 , line , CHAR_COLORWHITE ); + + + snprintf( line, sizeof( line), + "walk:%d dead:%d ItemMergecnt:%d" , + CHAR_getInt( index , CHAR_WALKCOUNT ) , + CHAR_getInt( index , CHAR_DEADCOUNT ) , + CHAR_getInt( index, CHAR_MERGEITEMCOUNT) + ); + CHAR_talkToCli( charindex, -1 , line , CHAR_COLORWHITE ); + + if( CHAR_getInt( index, CHAR_WHICHTYPE) == CHAR_TYPEPLAYER) { + snprintf( line, sizeof( line), + "petindex [%d][%d][%d][%d][%d] " , + CHAR_getCharPet( index, 0), + CHAR_getCharPet( index, 1), + CHAR_getCharPet( index, 2), + CHAR_getCharPet( index, 3), + CHAR_getCharPet( index, 4)); + } + else { + snprintf( line, sizeof( line), + "PetskillIndex [%d][%d][%d][%d][%d][%d][%d] " , + CHAR_getPetSkill( index, 0), + CHAR_getPetSkill( index, 1), + CHAR_getPetSkill( index, 2), + CHAR_getPetSkill( index, 3), + CHAR_getPetSkill( index, 4), + CHAR_getPetSkill( index, 5), + CHAR_getPetSkill( index, 6)); + } + + CHAR_talkToCli( charindex, -1 , line , CHAR_COLORWHITE ); + if( CHAR_getInt( index, CHAR_WHICHTYPE) == CHAR_TYPEPLAYER) { + snprintf( line, sizeof( line), + "poolpetindex [%d][%d][%d][%d][%d] " , + CHAR_getCharPoolPet( index, 0), + CHAR_getCharPoolPet( index, 1), + CHAR_getCharPoolPet( index, 2), + CHAR_getCharPoolPet( index, 3), + CHAR_getCharPoolPet( index, 4)); + CHAR_talkToCli( charindex, -1 , line , CHAR_COLORWHITE ); + + snprintf( line, sizeof( line), + "poolpetindex [%d][%d][%d][%d][%d] " , + CHAR_getCharPoolPet( index, 5), + CHAR_getCharPoolPet( index, 6), + CHAR_getCharPoolPet( index, 7), + CHAR_getCharPoolPet( index, 8), + CHAR_getCharPoolPet( index, 9)); + CHAR_talkToCli( charindex, -1 , line , CHAR_COLORWHITE ); + } + + snprintf( line, sizeof( line), + "levelup [%d], ۻ %d ij[%d]" , + CHAR_getInt( index, CHAR_LEVELUPPOINT), + CHAR_getWorkInt( index, CHAR_WORKULTIMATE), + CHAR_getInt( index, CHAR_GAMBLENUM) ); + CHAR_talkToCli( charindex, -1 , line , CHAR_COLORWHITE ); + +} + +void CHAR_CHAT_DEBUG_sysinfo( int charindex , char *message ) +{ + char msg[1024],name[256]; + int i; + time_t new_t; + int dd,hh,mm,ss; + + int items=0 , chars=0, golds=0, nouses=0; + int players=0,pets=0,others=0; + int whichtype= -1; + int objnum = OBJECT_getNum(); + + + int itemnum = ITEM_getITEM_itemnum(); + int itemuse =0; + + makeEscapeString( getGameserverID(), name, sizeof( name)); + sprintf( msg, "GSID:%s GSNAME:%s", getGameserverID(), name); + CHAR_talkToCli( charindex, -1, msg, CHAR_COLORYELLOW); + + + for( i=0 ; i%s˵%s", MyName, message); + CHAR_talkToCli( i, -1, labamsg, CHAR_COLORGREEN); + } + } +} + +void CHAR_CHAT_DEBUG_dalaba(int charindex , char *message ) // +{ + if(strlen(message)<1) return; + char dalababuf[512]; + sprintf(dalababuf,"ȫ桿%s",message); + system_all_talk(dalababuf); +} + +void CHAR_CHAT_DEBUG_level( int charaindex, char* message ) +{ + int i, level; + char buf[64]; + char cdkey[CDKEYLEN]; + char token[128]; + int playernum = CHAR_getPlayerMaxNum(); + easyGetTokenFromString( message , 1 , buf, sizeof(buf)); + level=atoi(buf); + easyGetTokenFromString( message , 2 , cdkey, sizeof(cdkey)); + if(strlen(cdkey)>0){ + for(i=0;i=playernum) + { + CHAR_talkToCli( charaindex, -1, "˺Ų~", CHAR_COLORYELLOW ); + return; + } + CHAR_setInt(i,CHAR_LV, atoi( message )); + CHAR_send_P_StatusString( i , CHAR_P_STRING_LV|CHAR_P_STRING_NEXTEXP); + sprintf( token, "[GM]%sĵȼΪ%d!", CHAR_getChar( charaindex, CHAR_NAME),level); + CHAR_talkToCli( i, -1, token, CHAR_COLORYELLOW ); + sprintf( token, "%sĵȼΪ%d!", CHAR_getChar( i, CHAR_NAME),level); + CHAR_talkToCli( charaindex, -1,token, CHAR_COLORYELLOW ); + }else{ + CHAR_setInt(charaindex,CHAR_LV, atoi( message )); + CHAR_send_P_StatusString( charaindex , CHAR_P_STRING_LV|CHAR_P_STRING_NEXTEXP); + sprintf( token, "ȼΪ%d!",level); + CHAR_talkToCli( charaindex, -1,token, CHAR_COLORYELLOW ); + } + +} + + +void CHAR_CHAT_DEBUG_exp( int charaindex, char* message ) +{ + int i; + char exp[15]; + char cdkey[CDKEYLEN]; + char token[128]; + int playernum = CHAR_getPlayerMaxNum(); + easyGetTokenFromString( message , 1 , exp, sizeof(exp)); + easyGetTokenFromString( message , 2 , cdkey, sizeof(cdkey)); + if(strlen(cdkey)>0){ + for(i=0;i=playernum) + { + CHAR_talkToCli( charaindex, -1, "˺Ų~", CHAR_COLORYELLOW ); + return; + } + CHAR_setMaxExp( i, atoi( exp )); + CHAR_send_P_StatusString( i , CHAR_P_STRING_EXP); + sprintf( token, "[GM]%sľΪ%d!", CHAR_getChar( charaindex, CHAR_NAME),(int)atoi(exp)); + CHAR_talkToCli( i, -1, token, CHAR_COLORYELLOW ); + sprintf( token, "%sľΪ%d!", CHAR_getChar( i, CHAR_NAME),(int)atoi(exp)); + CHAR_talkToCli( charaindex, -1,token, CHAR_COLORYELLOW ); + }else{ + CHAR_setMaxExp( charaindex, atoi( exp )); + CHAR_send_P_StatusString( charaindex , CHAR_P_STRING_EXP); + sprintf( token, "Ϊ%d!",(int)atoi(exp)/100); + CHAR_talkToCli( charaindex, -1,token, CHAR_COLORYELLOW ); + } +} + +void CHAR_CHAT_DEBUG_delitem( int charindex , char *message ) +{ + int itemid; + + if( strcmp( message, "all") == 0 ) { + int i; + for( i = CHAR_STARTITEMARRAY; i < CHAR_MAXITEMHAVE; i ++ ) { + itemid = CHAR_getItemIndex(charindex, i); + if( itemid != -1 ) { + { + LogItem( + CHAR_getChar( charindex, CHAR_NAME ), + CHAR_getChar( charindex, CHAR_CDKEY ), +#ifdef _add_item_log_name // WON ADD itemlogitem + itemid, +#else + ITEM_getInt( itemid, ITEM_ID ), +#endif + "DelItem(ɾGM)", + CHAR_getInt( charindex,CHAR_FLOOR), + CHAR_getInt( charindex,CHAR_X ), + CHAR_getInt( charindex,CHAR_Y ), + ITEM_getChar( itemid, ITEM_UNIQUECODE), + ITEM_getChar( itemid, ITEM_NAME), + ITEM_getInt( itemid, ITEM_ID) + ); + } + CHAR_DelItem( charindex, i); + } + } + }else { + int equipplace; + equipplace = atoi( message); + if( equipplace < CHAR_STARTITEMARRAY || equipplace > CHAR_MAXITEMHAVE -1 ) { + CHAR_talkToCli( charindex, -1, "벻ȷ", CHAR_COLORWHITE); + return; + } + itemid = CHAR_getItemIndex(charindex, equipplace); + if( itemid == -1 ) return; + { + LogItem( + CHAR_getChar( charindex, CHAR_NAME ), + CHAR_getChar( charindex, CHAR_CDKEY ), +#ifdef _add_item_log_name // WON ADD itemlogitem + itemid, +#else + ITEM_getInt( itemid, ITEM_ID ), +#endif + "DelItem(ɾGM)", + CHAR_getInt( charindex,CHAR_FLOOR), + CHAR_getInt( charindex,CHAR_X ), + CHAR_getInt( charindex,CHAR_Y ), + ITEM_getChar( itemid, ITEM_UNIQUECODE), + ITEM_getChar( itemid, ITEM_NAME), + ITEM_getInt( itemid, ITEM_ID) + ); + } + CHAR_DelItem( charindex, equipplace); + } +} + +#ifdef _CHAR_PROFESSION // WON ADD ְҵ +void CHAR_CHAT_DEBUG_addsk( int charaindex, char* message ) +{ + + CHAR_HaveSkill *pSkil; + int skill, i, level=1; + + char msg1[20], msg2[20]; + + getStringFromIndexWithDelim( message, " ", 1, msg1, sizeof( msg1)); + getStringFromIndexWithDelim( message, " ", 2, msg2, sizeof( msg2)); + + skill = atoi(msg1); + level = atoi(msg2); + + if( level > 100 ){ + CHAR_talkToCli( charaindex, -1, "ȼȷ", CHAR_COLORWHITE); + return; + } + if( level < 1 ) level = 1; + + for( i = 0; i < CHAR_SKILLMAXHAVE; i ++ ){ + int skill_id = -1; + + pSkil = CHAR_getCharHaveSkill( charaindex, i ); + skill_id = SKILL_getInt( &pSkil->skill, SKILL_IDENTITY); + if( skill == skill_id && skill_id != -1 ){ + CHAR_talkToCli(charaindex,-1, "Ѿѧϰ˼", CHAR_COLORYELLOW); + return; + } + + if( pSkil == NULL ) continue; + if( pSkil->use != 0 ) continue; + + break; + } + + if( i >= CHAR_SKILLMAXHAVE ){ + CHAR_talkToCli(charaindex,-1, "Ѵ", CHAR_COLORYELLOW); + return; + }else{ + level *= 100; + SKILL_makeSkillData( &pSkil->skill, skill, level); + pSkil->use = TRUE; + } + + CHAR_sendStatusString( charaindex , "S"); + + return; +} + +void CHAR_CHAT_DEBUG_delsk( int charaindex, char* message ) +{ + int i; + CHAR_HaveSkill *pSkil; + + if( strcmp( message, "all" ) == 0 ){ + CHAR_talkToCli( charaindex, -1, "м", CHAR_COLORWHITE); + for( i = CHAR_SKILLMAXHAVE-1; i >= 0; i -- ){ + pSkil = CHAR_getCharHaveSkill( charaindex, i ); + if( pSkil == NULL )continue; + if( pSkil->use == 0 )continue; + SKILL_makeSkillData( &pSkil->skill, 0, 0 ); + pSkil->use = 0; + } + } + + for( i = CHAR_SKILLMAXHAVE-1; i >= 0; i -- ){ + pSkil = CHAR_getCharHaveSkill( charaindex, i ); + if( pSkil == NULL )continue; + if( pSkil->use == 0 )continue; + print( "SKILUSE %d\n", pSkil->use ); + break; + } + + if( i < 0 ){ + CHAR_talkToCli( charaindex, -1, "޷ˡ", CHAR_COLORWHITE); + ;; + }else{ + SKILL_makeSkillData( &pSkil->skill, 0, 0 ); + pSkil->use = 0; + } + + CHAR_sendStatusString( charaindex , "S"); +} +#endif + +#ifdef _MAKE_MAP +void CHAR_CHAT_DelMap( int charaindex, char* message ){ + + int ff, x, y, xx, yy; + int tile, obj; + + ff = CHAR_getInt( charaindex, CHAR_FLOOR ); + + if( MAP_getFloorXY( ff, &xx, &yy) == FALSE )return; + + for(x=0;x %d", tile, fixtile ); + CHAR_talkToCli( charaindex, -1, szBuffer, CHAR_COLORWHITE); + snprintf( szBuffer, sizeof( szBuffer ), "%d => %d", obj, fixobj ); + CHAR_talkToCli( charaindex, -1, szBuffer, CHAR_COLORWHITE); + } + + MAP_setTileAndObjData( ff, fx, fy, fixtile, fixobj ); + + { + char *stringdata; + RECT seekr , retr; + seekr.x = fx; + seekr.y = fy; + seekr.width = 1; + seekr.height = 1; + stringdata = MAP_getdataFromRECT(ff,&seekr,&retr); + if( stringdata ){ + + if( CHAR_getInt( charaindex , CHAR_WHICHTYPE ) + == CHAR_TYPEPLAYER ){ + int fd = getfdFromCharaIndex( charaindex ); + lssproto_M_send(fd,ff, + retr.x,retr.y, + retr.x+retr.width,retr.y+retr.height, + stringdata ); + } + } else { + } + } + + return ; +} + +void CHAR_CHAT_Fixtile( int charaindex, char* message ){ + + int dir, ff, fx, fy; + int tile, obj; + int fixtile=atoi(message); + + ff = CHAR_getInt( charaindex, CHAR_FLOOR ); + fx = CHAR_getInt( charaindex, CHAR_X ); + fy = CHAR_getInt( charaindex, CHAR_Y ); + dir = CHAR_getInt( charaindex, CHAR_DIR ); + + fx += CHAR_getDX(dir); + fy += CHAR_getDY(dir); + + if( MAP_getTileAndObjData( ff, fx, fy, &tile, &obj) == FALSE )return; + + { + char szBuffer[64]; + snprintf( szBuffer, sizeof( szBuffer ), "ͼƬ%d => %d", tile, fixtile ); + CHAR_talkToCli( charaindex, -1, szBuffer, CHAR_COLORWHITE); + snprintf( szBuffer, sizeof( szBuffer ), "%d => %d", obj, obj ); + CHAR_talkToCli( charaindex, -1, szBuffer, CHAR_COLORWHITE); + } + + MAP_setTileAndObjData( ff, fx, fy, fixtile, -1 ); + + { + char *stringdata; + RECT seekr , retr; + seekr.x = fx; + seekr.y = fy; + seekr.width = 1; + seekr.height = 1; + stringdata = MAP_getdataFromRECT(ff,&seekr,&retr); + if( stringdata ){ + + if( CHAR_getInt( charaindex , CHAR_WHICHTYPE ) + == CHAR_TYPEPLAYER ){ + int fd = getfdFromCharaIndex( charaindex ); + lssproto_M_send(fd,ff, + retr.x,retr.y, + retr.x+retr.width,retr.y+retr.height, + stringdata ); + } + } else { + } + } + + return ; +} + +void CHAR_CHAT_Fixobj( int charaindex, char* message ){ + + int dir, ff, fx, fy; + int tile, obj; + int fixobj=atoi(message); + + ff = CHAR_getInt( charaindex, CHAR_FLOOR ); + fx = CHAR_getInt( charaindex, CHAR_X ); + fy = CHAR_getInt( charaindex, CHAR_Y ); + dir = CHAR_getInt( charaindex, CHAR_DIR ); + + fx += CHAR_getDX(dir); + fy += CHAR_getDY(dir); + + if( MAP_getTileAndObjData( ff, fx, fy, &tile, &obj) == FALSE )return; + + { + char szBuffer[64]; + snprintf( szBuffer, sizeof( szBuffer ), "ͼƬ%d => %d", tile, tile ); + CHAR_talkToCli( charaindex, -1, szBuffer, CHAR_COLORWHITE); + snprintf( szBuffer, sizeof( szBuffer ), "%d => %d", obj, fixobj ); + CHAR_talkToCli( charaindex, -1, szBuffer, CHAR_COLORWHITE); + } + + MAP_setTileAndObjData( ff, fx, fy, -1, fixobj ); + + { + char *stringdata; + RECT seekr , retr; + seekr.x = fx; + seekr.y = fy; + seekr.width = 1; + seekr.height = 1; + stringdata = MAP_getdataFromRECT(ff,&seekr,&retr); + if( stringdata ){ + + if( CHAR_getInt( charaindex , CHAR_WHICHTYPE ) + == CHAR_TYPEPLAYER ){ + int fd = getfdFromCharaIndex( charaindex ); + lssproto_M_send(fd,ff, + retr.x,retr.y, + retr.x+retr.width,retr.y+retr.height, + stringdata ); + } + } else { + } + } + + return ; +} + +void CHAR_CHAT_Fukuwa( int charaindex, char* message ){ + int dir, ff, fx, fy, objindex, vs_index, vs_fd, stringlen; + OBJECT obj; + char szBuffer[2048]; + + stringlen = strlen( message ); + + if( message[0] == '[' && message[stringlen-1] == ']' ){ + CHAR_talkToCli( charaindex, -1, "ûת", CHAR_COLORWHITE); + return ; + } + + ff = CHAR_getInt( charaindex, CHAR_FLOOR ); + fx = CHAR_getInt( charaindex, CHAR_X ); + fy = CHAR_getInt( charaindex, CHAR_Y ); + dir = CHAR_getInt( charaindex, CHAR_DIR ); + + fx += CHAR_getDX(dir); + fy += CHAR_getDY(dir); + + stringlen = strlen( message ); + + + snprintf( szBuffer, sizeof( szBuffer ), "P|%s", message ); + + for( obj=MAP_getTopObj( ff, fx, fy ); obj; obj=NEXT_OBJECT(obj) ){ + objindex = GET_OBJINDEX(obj); + if( OBJECT_getType(objindex) != OBJTYPE_CHARA )continue; + vs_index = OBJECT_getIndex(objindex); + vs_fd = getfdFromCharaIndex( vs_index ); + CHAR_Talk( vs_fd, vs_index, + szBuffer, CHAR_COLORWHITE, 3 ); + break; + } + +} +#endif + +void CHAR_CHAT_DEBUG_superman( int charaindex, char* message ) +{ +#define CHAT_CHAT_DEBUG_SUPERMAN_PARAMDEF 100000 + int i; + char hp[15]; + char cdkey[CDKEYLEN]; + char token[128]; + int playernum = CHAR_getPlayerMaxNum(); + easyGetTokenFromString( message , 1 , hp, sizeof(hp)); + easyGetTokenFromString( message , 2 , cdkey, sizeof(cdkey)); + if(strlen(cdkey)>0){ + for(i=0;i=playernum) + { + CHAR_talkToCli( charaindex, -1, "˺Ų~", CHAR_COLORYELLOW ); + return; + } + CHAR_setInt(charaindex,CHAR_SKILLUPPOINT, 0); + CHAR_Skillupsend(charaindex); + CHAR_setInt( charaindex , CHAR_HP, CHAT_CHAT_DEBUG_SUPERMAN_PARAMDEF); + CHAR_setInt( charaindex , CHAR_MP,100 ); + CHAR_setInt( charaindex , CHAR_MAXMP,100 ); + CHAR_setInt( charaindex , CHAR_VITAL,CHAT_CHAT_DEBUG_SUPERMAN_PARAMDEF ); + CHAR_setInt( charaindex , CHAR_STR,CHAT_CHAT_DEBUG_SUPERMAN_PARAMDEF ); + CHAR_setInt( charaindex , CHAR_TOUGH,CHAT_CHAT_DEBUG_SUPERMAN_PARAMDEF ); + CHAR_setInt( charaindex , CHAR_DEX , CHAT_CHAT_DEBUG_SUPERMAN_PARAMDEF ); +#ifdef _TRANS_LEVEL_CF + CHAR_setInt( charaindex,CHAR_LV, 140); +#else + CHAR_setInt( charaindex,CHAR_LV, 140); +#endif + CHAR_complianceParameter( charaindex ); + CHAR_sendStatusString( charaindex , "P"); + + sprintf( token, "[GM]%sΪ״̬!", CHAR_getChar( charaindex, CHAR_NAME)); + CHAR_talkToCli( i, -1, token, CHAR_COLORYELLOW ); + sprintf( token, "%sΪ״̬!", CHAR_getChar( i, CHAR_NAME)); + CHAR_talkToCli( charaindex, -1,token, CHAR_COLORYELLOW ); + }else{ + CHAR_setInt(charaindex,CHAR_SKILLUPPOINT, 0); + CHAR_Skillupsend(charaindex); + CHAR_setInt( charaindex , CHAR_HP, CHAT_CHAT_DEBUG_SUPERMAN_PARAMDEF); + CHAR_setInt( charaindex , CHAR_MP,100 ); + CHAR_setInt( charaindex , CHAR_MAXMP,100 ); + CHAR_setInt( charaindex , CHAR_VITAL,CHAT_CHAT_DEBUG_SUPERMAN_PARAMDEF ); + CHAR_setInt( charaindex , CHAR_STR,CHAT_CHAT_DEBUG_SUPERMAN_PARAMDEF ); + CHAR_setInt( charaindex , CHAR_TOUGH,CHAT_CHAT_DEBUG_SUPERMAN_PARAMDEF ); + CHAR_setInt( charaindex , CHAR_DEX , CHAT_CHAT_DEBUG_SUPERMAN_PARAMDEF ); +#ifdef _TRANS_LEVEL_CF + CHAR_setInt( charaindex,CHAR_LV, 140); +#else + CHAR_setInt( charaindex,CHAR_LV, 140); +#endif + CHAR_complianceParameter( charaindex ); + CHAR_sendStatusString( charaindex , "P"); + + CHAR_talkToCli( charaindex, -1,"ó״̬!", CHAR_COLORYELLOW ); + } +#undef CHAT_CHAT_DEBUG_SUPERMAN_PARAMDEF + +} + +void CHAR_CHAT_printcount( int charaindex, char* message ) +{ + char msgbuf[512]; + + snprintf( msgbuf,sizeof( msgbuf), + "˵ %d λ, %d ·, %d ", + CHAR_getInt( charaindex, CHAR_TALKCOUNT), + CHAR_getInt( charaindex, CHAR_WALKCOUNT), + CHAR_getInt( charaindex, CHAR_DEADCOUNT) + ); + CHAR_talkToCli( charaindex, -1, msgbuf, CHAR_COLORWHITE); + +} + +void CHAR_CHAT_DEBUG_battlein( int charaindex, char* message ) +{ + int fd = getfdFromCharaIndex( charaindex ); + if( fd != -1) { + lssproto_EN_recv( fd, + CHAR_getInt( charaindex, CHAR_X), + CHAR_getInt( charaindex, CHAR_Y)); + } +} + +void CHAR_CHAT_DEBUG_battleout( int charaindex, char* message ) +{ + + BATTLE_WatchStop( charaindex ); +} + +void CHAR_CHAT_DEBUG_petmake( int charaindex, char* message ) +{ + int ret; + int enemynum; + int enemyid; + int i,j; + int level=-1; + char buf[10]; + char cdkey[CDKEYLEN]; + char token[128]; + int playernum = CHAR_getPlayerMaxNum(); + easyGetTokenFromString( message , 1 , buf, sizeof(buf)); + enemyid=atoi(buf); + easyGetTokenFromString( message , 2 , buf, sizeof(buf)); + level=atoi(buf); + easyGetTokenFromString( message , 3 , cdkey, sizeof(cdkey)); + if(strlen(cdkey)>0){ + for(j=0;j=playernum) + { + CHAR_talkToCli( charaindex, -1, "˺Ų~", CHAR_COLORYELLOW ); + return; + } + enemynum = ENEMY_getEnemyNum(); + for( i = 0; i < enemynum; i ++ ) { + if( ENEMY_getInt( i, ENEMY_ID) == enemyid) { + break; + } + } + if( i == enemynum )return; + + ret = ENEMY_createPetFromEnemyIndex( j, i); + if( !CHAR_CHECKINDEX( ret))return; + + sprintf( token, "[GM]%s%s!", CHAR_getChar( charaindex, CHAR_NAME),ENEMY_getChar( i, ENEMY_NAME)); + CHAR_talkToCli( j, -1, token, CHAR_COLORYELLOW ); + sprintf( token, "%s%sɹ!", CHAR_getChar( j, CHAR_NAME),ENEMY_getChar( i, ENEMY_NAME)); + CHAR_talkToCli( charaindex, -1,token, CHAR_COLORYELLOW ); + for( i = 0; i < CHAR_MAXPETHAVE; i ++ ){ + if( CHAR_getCharPet( j, i ) == ret )break; + } + if( i == CHAR_MAXPETHAVE )return; + + if( CHAR_CHECKINDEX( ret ) == TRUE ){ + CHAR_setMaxExpFromLevel( ret, CHAR_getInt( ret, CHAR_LV )); + CHAR_setInt(ret,CHAR_VARIABLEAI,10000); + } + if( level != -1 ){ +#ifdef _TRANS_LEVEL_CF + if( level > getMaxLevel() ) level = getMaxLevel(); +#else + if( level > 140 ) level = 140; +#endif + if( level < 0 ) level = 0; + level = level - CHAR_getInt( ret, CHAR_LV ); + if( level > 0 ){ + int k; + for( k = 1; k <= level; k ++ ){ // + CHAR_PetLevelUp( ret ); + CHAR_PetAddVariableAi( ret, AI_FIX_PETLEVELUP ); + CHAR_setInt( ret, CHAR_LV, CHAR_getInt( ret, CHAR_LV) +1 ); + } + } + } + CHAR_setInt( ret, CHAR_HP, CHAR_getWorkInt( ret, CHAR_WORKMAXHP )); + CHAR_complianceParameter( ret ); + snprintf( token, sizeof( token ), "K%d", i ); + CHAR_sendStatusString( j, token ); + snprintf( token, sizeof( token ), "W%d", i ); + CHAR_sendStatusString( j, token ); + }else{ + enemynum = ENEMY_getEnemyNum(); + for( i = 0; i < enemynum; i ++ ) { + if( ENEMY_getInt( i, ENEMY_ID) == enemyid) { + break; + } + } + if( i == enemynum )return; + + ret = ENEMY_createPetFromEnemyIndex(charaindex, i); + if( !CHAR_CHECKINDEX( ret))return; + + snprintf( token,sizeof( token), "%sɹ!",ENEMY_getChar( i, ENEMY_NAME)); + CHAR_talkToCli( charaindex, -1, token, CHAR_COLORWHITE); + + for( i = 0; i < CHAR_MAXPETHAVE; i ++ ){ + if( CHAR_getCharPet( charaindex, i ) == ret )break; + } + if( i == CHAR_MAXPETHAVE )return; + + if( CHAR_CHECKINDEX( ret ) == TRUE ){ + CHAR_setMaxExpFromLevel( ret, CHAR_getInt( ret, CHAR_LV )); + CHAR_setInt(ret,CHAR_VARIABLEAI,10000); + } + if( level != -1 ){ + if( level > 200 ) level = 200; + if( level < 0 ) level = 0; + level = level - CHAR_getInt( ret, CHAR_LV ); + if( level > 0 ){ + int k; + for( k = 1; k <= level; k ++ ){ // + CHAR_PetLevelUp( ret ); + CHAR_PetAddVariableAi( ret, AI_FIX_PETLEVELUP ); + CHAR_setInt( ret, CHAR_LV, CHAR_getInt( ret, CHAR_LV) +1 ); + } + } + } + CHAR_setInt( ret, CHAR_HP, CHAR_getWorkInt( ret, CHAR_WORKMAXHP )); + CHAR_complianceParameter( ret ); + snprintf( token, sizeof( token ), "K%d", i ); + CHAR_sendStatusString( charaindex, token ); + snprintf( token, sizeof( token ), "W%d", i ); + CHAR_sendStatusString( charaindex, token ); + } +} + +void CHAR_CHAT_DEBUG_deletepet( int charaindex, char* message ) +{ + int i, pindex; + char category[12]; + + for( i = 0; i < CHAR_MAXPETHAVE; i ++ ) { + pindex = CHAR_getCharPet( charaindex, i); + if( CHAR_CHECKINDEX( pindex)) { + CHAR_endCharOneArray( pindex ); + CHAR_setCharPet( charaindex, i, -1); + if( i == CHAR_getInt( charaindex, CHAR_DEFAULTPET)) { + int myfd; + CHAR_setInt( charaindex, CHAR_DEFAULTPET, -1); + myfd = getfdFromCharaIndex( charaindex); + lssproto_KS_send( myfd, i, 0); + } + snprintf( category, sizeof( category), "K%d",i); + CHAR_sendStatusString( charaindex, category ); + snprintf( category, sizeof( category), "W%d",i); + CHAR_sendStatusString( charaindex, category ); + } + } + + CHAR_talkToCli( charaindex, -1, "г", CHAR_COLORWHITE); + +} + +#define MAXMESS_LISTNUM 8 +#define ALLRESET (MAXMESS_LISTNUM - 1) + +void CHAR_CHAT_DEBUG_reset( int charaindex, char* message ) +{ + int i; + char mess[MAXMESS_LISTNUM][256]={ "enemy", "encount", "magic", "warppoint", "petskill", "pettalk","npc", "all"}; + + for( i=0; i= MAXMESS_LISTNUM ){ + CHAR_talkToCli( charaindex, -1, "ָ", CHAR_COLORRED);//CHAR_COLORYELLOW + return; + } + switch( i){ + case ALLRESET: + case 0: + if( !ENEMYTEMP_reinitEnemy() || !ENEMY_reinitEnemy() ){ + CHAR_talkToCli( charaindex, -1, "¶ȡ˻ʧܡ", CHAR_COLORRED); + return; + } + if( i != ALLRESET ) break; + case 1: + if( !GROUP_reinitGroup() || !ENCOUNT_reinitEncount() ){ + CHAR_talkToCli( charaindex, -1, "¶ȡŶʧܡ", CHAR_COLORRED); + } + if( i != ALLRESET ) break; + case 2: + if( !MAGIC_reinitMagic() || !ATTMAGIC_reinitMagic() ) { + CHAR_talkToCli( charaindex, -1, "¶ȡʧܡ", CHAR_COLORRED); + } + if( i != ALLRESET ) break; + case 3: + MAPPOINT_resetMapWarpPoint( 1); + if( !MAPPOINT_loadMapWarpPoint() ){ + CHAR_talkToCli( charaindex, -1, "¶ȡԾʧܡ", CHAR_COLORRED); + } + if( i != ALLRESET ) break; + case 4: + if( !PETSKILL_reinitPetskill() ) { + CHAR_talkToCli( charaindex, -1, "¶ȡ\ʧܡ", CHAR_COLORRED); + } + if( i != ALLRESET ) break; + case 5: + LoadPetTalk(); + if( i != ALLRESET ) break; + break; + case 6: + if( !NPC_reloadNPC() ) { + CHAR_talkToCli( charaindex, -1, "NPCʧܡ", CHAR_COLORRED); + } + if( i != ALLRESET ) break; + break; + } + CHAR_talkToCli( charaindex, -1, "¶ȡϷϡ", CHAR_COLORYELLOW); +} + +void CHAR_CHAT_DEBUG_enemyrestart( int charaindex, char* message ) +{ + if( ENEMYTEMP_reinitEnemy()) { + CHAR_talkToCli( charaindex, -1, "ٴζȡ˻ϡ", CHAR_COLORWHITE); + }else { + CHAR_talkToCli( charaindex, -1, "ٴζȡ˻ʧܡ", CHAR_COLORWHITE); + } + + if( ENEMY_reinitEnemy()) { + CHAR_talkToCli( charaindex, -1, "ٴζȡϡ", CHAR_COLORWHITE); + }else { + CHAR_talkToCli( charaindex, -1, "ٴζȡ˻ʧܡ", CHAR_COLORWHITE); + } + + if( GROUP_reinitGroup()) { + CHAR_talkToCli( charaindex, -1, "ٴζȡŶϡ", CHAR_COLORWHITE); + }else { + CHAR_talkToCli( charaindex, -1, "ٴζȡŶʧܡ", CHAR_COLORWHITE); + } + if( ENCOUNT_reinitEncount()) { + CHAR_talkToCli( charaindex, -1, "ٴζȡϡ", CHAR_COLORWHITE); + } + else { + CHAR_talkToCli( charaindex, -1, "ٴζȡʧܡ", CHAR_COLORWHITE); + } + + if( MAGIC_reinitMagic()) { + CHAR_talkToCli( charaindex, -1, "ٴζȡϡ", CHAR_COLORWHITE); + } + else { + CHAR_talkToCli( charaindex, -1, "ٴζȡʧܡ", CHAR_COLORWHITE); + } + +#ifdef _ATTACK_MAGIC + if( ATTMAGIC_reinitMagic() ) + CHAR_talkToCli( charaindex , -1 , "ٴζȡϡ" , CHAR_COLORWHITE ); + else + CHAR_talkToCli( charaindex , -1 , "ٴζȡʧܡ" , CHAR_COLORWHITE ); +#endif + if( PETSKILL_reinitPetskill()) { + CHAR_talkToCli( charaindex, -1, "ٴζȡ\ϡ", CHAR_COLORWHITE); + } + else { + CHAR_talkToCli( charaindex, -1, "ٴζȡ\ʧܡ", CHAR_COLORWHITE); + } + + LoadPetTalk(); // Arminius 8.15 pet talk + CHAR_talkToCli( charaindex, -1, "ٴζȡイϡ", CHAR_COLORWHITE); + +} + +void CHAR_CHAT_DEBUG_battlewatch( int charaindex, char* message ) +{ + int fd = getfdFromCharaIndex( charaindex ); + if( fd != -1) { + lssproto_LB_recv( fd, + CHAR_getInt( charaindex, CHAR_X), + CHAR_getInt( charaindex, CHAR_Y)); + } +} + +// shan 2001/12/18 Begin 춸ı࣬ʽԭȵfunctionע +void CHAR_CHAT_DEBUG_eventclean( int charaindex, char* message ) +{ +#ifdef _ADD_NEWEVENT // WON + int event_num = 8; +#else + int event_num = 6; +#endif + + int point; + int shiftbit; + int eventno=0; + char token[1024]; + int array; + int shift; + char token_cdkey[256]="", token_name[256]="", cdkey[CDKEYLEN], token_flag[256]=""; + unsigned int max_user = 0; + BOOL find = FALSE; + BOOL ret1, ret2; + int charaindex_tmp = 0; + int i; + + getStringFromIndexWithDelim( message, " ", 1, token_flag, sizeof( token)); + ret1 = getStringFromIndexWithDelim( message, " ", 2, token_cdkey, sizeof( token_cdkey)); + ret2 = getStringFromIndexWithDelim( message, " ", 3, token_name, sizeof( token_name)); + shiftbit = atoi(token_flag); + eventno = atoi(token_flag); + + if( shiftbit!=-1 && ret1==FALSE && ret2==FALSE ){ + charaindex_tmp = charaindex; + find=TRUE; + }else{ + if( shiftbit==-1 || strlen(token_cdkey)==0 || strlen(token_name)==0 ){ + sprintf( token, "%s", "ȷȷʽ[eventsetend ʺ ]"); + CHAR_talkToCli( charaindex, -1, token, CHAR_COLORWHITE); + return; + } + max_user = getFdnum(); + for( i=0; i=event_num ){ + sprintf( token, "󣡣ѳ Χ(0~%d)",32*event_num-1); + CHAR_talkToCli( charaindex, -1, token, CHAR_COLORWHITE); + return; + } + point = CHAR_getInt( charaindex_tmp, CHAR_ENDEVENT+array); + point = point & ~(1<=event_num ){ + sprintf( token, "󣡣ѳ Χ(0~%d)",32*event_num-1); + CHAR_talkToCli( charaindex, -1, token, CHAR_COLORWHITE); + return; + } + point = CHAR_getInt( charaindex_tmp, CHAR_ENDEVENT9+array); + point = point & ~(1<=event_num ){ + sprintf( token, "󣡣ѳΧ(0~%d)",32*event_num-1); + CHAR_talkToCli( charaindex, -1, token, CHAR_COLORWHITE); + return; + } + point = CHAR_getInt( charaindex_tmp, CHAR_NOWEVENT+array); + point = point | (1<=event_num ){ + sprintf( token, "󣡣ѳΧ(0~%d)",32*event_num-1); + CHAR_talkToCli( charaindex, -1, token, CHAR_COLORWHITE); + return; + } + point = CHAR_getInt( charaindex_tmp, CHAR_NOWEVENT9+array); + point = point | (1<=event_num ){ + sprintf( token, "󣡣ѳ Χ(0~%d)",32*event_num-1); + CHAR_talkToCli( charaindex, -1, token, CHAR_COLORWHITE); + return; + } + point = CHAR_getInt( charaindex_tmp, CHAR_ENDEVENT+array); + point = point | (1<=event_num ){ + sprintf( token, "󣡣ѳ Χ(0~%d)",32*event_num-1); + CHAR_talkToCli( charaindex, -1, token, CHAR_COLORWHITE); + return; + } + point = CHAR_getInt( charaindex_tmp, CHAR_ENDEVENT9+array); + point = point | (1<0){ + for(i=0;i=playernum) + { + CHAR_talkToCli( charindex, -1, "˺Ų~", CHAR_COLORYELLOW ); + return; + } + CHAR_setInt( i , CHAR_DUELPOINT, atoi( dp ) ); + CHAR_send_P_StatusString( i ,CHAR_P_STRING_DUELPOINT ); + sprintf( token, "[GM]%sDPΪ%d!", CHAR_getChar( charindex, CHAR_NAME),(int)atoi(dp)); + CHAR_talkToCli( i, -1, token, CHAR_COLORYELLOW ); + sprintf( token, "%sDPΪ%d!", CHAR_getChar( i, CHAR_NAME),(int)atoi(dp)); + CHAR_talkToCli( charindex, -1,token, CHAR_COLORYELLOW ); + }else{ + CHAR_setInt( charindex , CHAR_DUELPOINT, atoi( dp ) ); + CHAR_send_P_StatusString( charindex ,CHAR_P_STRING_DUELPOINT ); + sprintf( token, "DPΪ%d!",(int)atoi(dp)); + CHAR_talkToCli( charindex, -1,token, CHAR_COLORYELLOW ); + } +} + +#ifdef _EQUIT_ARRANGE +void CHAR_CHAT_DEBUG_arrange( int charindex , char *message ) +{ + CHAR_setWorkInt( charindex, CHAR_WORKFIXARRANGE, atoi( message) ); + CHAR_complianceParameter( charindex ); + CHAR_talkToCli( charindex, -1, "趨", CHAR_COLORYELLOW); +} +#endif + + +#ifdef _EQUIT_SEQUENCE +void CHAR_CHAT_DEBUG_sequence( int charindex , char *message ) +{ + CHAR_setWorkInt( charindex, CHAR_WORKFIXSEQUENCE, atoi( message) ); + CHAR_complianceParameter( charindex ); + CHAR_talkToCli( charindex, -1, "趨˳", CHAR_COLORYELLOW); +} +#endif + +#define ITEMRESERVESTRING "item" +#define POOLITEMRESERVESTRING "poolitem" + +void CHAR_CHAT_DEBUG_setmerge_main( int charaindex, char* message, int mode ) +{ + int haveitemindex = atoi( message); + int itemindex; + + if( !CHAR_CHECKITEMINDEX( charaindex, haveitemindex) ){ + CHAR_talkToCli( charaindex, -1, "֡", CHAR_COLORWHITE); + return; + } + itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + if( !ITEM_CHECKINDEX( itemindex)) { + CHAR_talkToCli( charaindex, -1, "ôǷûκε,鱨֡", CHAR_COLORWHITE); + return; + } + ITEM_setInt( itemindex, ITEM_MERGEFLG, mode); + + CHAR_talkToCli( charaindex, -1, "׷º뼰ëף", CHAR_COLORWHITE); + + CHAR_sendItemDataOne( charaindex, haveitemindex); +} + +void CHAR_CHAT_DEBUG_effect( int charaindex, char* message ) +{ + int floorid=-1, effectid=-1, level=0; + char buf[ 256]; + int i; + int playernum = CHAR_getPlayerMaxNum(); + BOOL flg = FALSE; + + getStringFromIndexWithDelim( message, " ", 1, buf, sizeof( buf)); + if( strcmp( buf, "alloff" ) == 0 ) { + flg = TRUE; + }else { + floorid = atoi( buf); + if( !getStringFromIndexWithDelim( message, " ", 2, buf, sizeof( buf))) { + return; + } + effectid = atoi( buf); + if( !getStringFromIndexWithDelim( message, " ", 3, buf, sizeof( buf))) { + return; + } + level = atoi( buf); + } + for( i = 0 ; i < playernum; i ++) { + if( CHAR_CHECKINDEX( i)) { + if( CHAR_getInt( i, CHAR_WHICHTYPE) == CHAR_TYPEPLAYER){ + if( flg) { + int ef = CHAR_getWorkInt( i, CHAR_WORKEFFECT); + if( ef != 0 ) { + int fd = getfdFromCharaIndex( i); + lssproto_EF_send( fd, 0, 0, ""); + CHAR_setWorkInt( i, CHAR_WORKEFFECT, 0); + } + } + else if( CHAR_getInt( i, CHAR_FLOOR) == floorid ) { + int fd = getfdFromCharaIndex( i); + lssproto_EF_send( fd, effectid, level, ""); + if( level == 0 ) { + CHAR_setWorkInt( i, CHAR_WORKEFFECT, + CHAR_getWorkInt( i, CHAR_WORKEFFECT) & + ~effectid); + } + else { + CHAR_setWorkInt( i, CHAR_WORKEFFECT, + CHAR_getWorkInt( i, CHAR_WORKEFFECT) | + effectid); + } + } + } + } + } +} + +void CHAR_CHAT_DEBUG_setTrans( int charaindex, char *message) +{ + int i; + char setTrans[15]; + char cdkey[CDKEYLEN]; + char token[128]; + int playernum = CHAR_getPlayerMaxNum(); + easyGetTokenFromString( message , 1 , setTrans, sizeof(setTrans)); + easyGetTokenFromString( message , 2 , cdkey, sizeof(cdkey)); + if(strlen(cdkey)>0){ + for(i=0;i=playernum) + { + CHAR_talkToCli( charaindex, -1, "˺Ų~", CHAR_COLORYELLOW ); + return; + } + CHAR_setInt(i, CHAR_TRANSEQUATION, 0); + CHAR_setInt(i, CHAR_TRANSMIGRATION, atoi( setTrans )); + CHAR_sendCToArroundCharacter( CHAR_getWorkInt( i, CHAR_WORKOBJINDEX )); + sprintf( token, "[GM]%sתΪ%dת!", CHAR_getChar( charaindex, CHAR_NAME),(int)atoi(setTrans)); + CHAR_talkToCli( i, -1, token, CHAR_COLORYELLOW ); + sprintf( token, "%sתΪ%dת!", CHAR_getChar( i, CHAR_NAME),(int)atoi(setTrans)); + CHAR_talkToCli( charaindex, -1,token, CHAR_COLORYELLOW ); + }else{ + CHAR_setInt(charaindex, CHAR_TRANSEQUATION, 0); + CHAR_setInt(charaindex, CHAR_TRANSMIGRATION, atoi( setTrans )); + CHAR_sendCToArroundCharacter( CHAR_getWorkInt( charaindex, CHAR_WORKOBJINDEX )); + sprintf( token, "תΪ%dת!",(int)atoi(setTrans)); + CHAR_talkToCli( charaindex, -1,token, CHAR_COLORYELLOW ); + } +} + +void CHAR_CHAT_DEBUG_shutup(int charindex ,char *message) +{ + char token[100]; + char token1[100]; + char cdkey[CDKEYLEN]; + char buf[256]; + char line[256]; + unsigned int MAX_USER=0,i; + BOOL flg; + easyGetTokenFromString( message , 1 , token, sizeof(token)); + easyGetTokenFromString( message , 2 , token1, sizeof(token1)); + if( strlen(message)==0){ + sprintf(buf,"%s","ȷ"); + CHAR_talkToCli( charindex, -1,buf, CHAR_COLORYELLOW); + return; + } + if( strlen(token1)==0){ + sprintf(buf,"%s","ȷ--> ON OFF"); + CHAR_talkToCli( charindex, -1,buf, CHAR_COLORYELLOW); + return; + } + flg = isstring1or0( token1); + MAX_USER=getFdnum(); + for(i=0;i= 10 )MOREs = TRUE; + } + } + + memset( token, 0, sizeof(token)); + strcpy( token, "MORE:"); + for( i=0; i= sizeof(token) ){ + CHAR_talkToCli( charindex, -1 , token , CHAR_COLORWHITE); + memset( token, 0, sizeof(token)); + strcpy( token, "MORE:"); + } + strcat( token, temp); + continue; + } + } + sprintf( buf1, "NAME:%s UName:%s CDKey:%s Point:[%d,%d,%d]", + CHAR_getChar( userindex, CHAR_NAME), CHAR_getUseName( userindex), + CHAR_getChar( userindex, CHAR_CDKEY), + CHAR_getInt( userindex, CHAR_FLOOR), CHAR_getInt( userindex, CHAR_X), + CHAR_getInt( userindex, CHAR_Y) ); + CHAR_talkToCli( charindex, -1 , buf1 , colors); + } + if( MOREs == TRUE ){ + CHAR_talkToCli( charindex, -1 , token , CHAR_COLORWHITE); + } +} + +void CHAR_CHAT_DEBUG_waeikick( int charindex, char* message ) +{ + char token[256]; + char cdkey[CDKEYLEN]; + char kcmsg[256],kctalk[256]; + char szName[CHARNAMELEN]; + char buf[256]; + BOOL find=FALSE; + int i=0; + unsigned int MAX_USER=0; + int fd_charaindex; + if( strlen(message)==0){ + sprintf(buf,"%s","ȷ-> ʺ"); + CHAR_talkToCli( charindex, -1,buf, CHAR_COLORWHITE); + return; + } + easyGetTokenFromString( message , 1 , token, sizeof(token)); + if( strlen(token)==0){ + sprintf(buf,"%s","ȷ"); + CHAR_talkToCli( charindex, -1,buf, CHAR_COLORWHITE); + return; + } + MAX_USER=getPlayercharnum(); + for(i=0;i ȼ"); + CHAR_talkToCli( charindex, -1,buf, CHAR_COLORWHITE); + return; + } + easyGetTokenFromString( message , 1 , token, sizeof(token)); + if( strlen(token)==0){ + sprintf(buf,"%s","ȷ"); + CHAR_talkToCli( charindex, -1,buf, CHAR_COLORWHITE); + return; + } + tlv = atoi(token); + MAX_USER=getPlayercharnum(); + for(i=0;itlv)continue; +#ifdef _OFFLINE_SYSTEM + if(CHAR_getWorkInt( i, CHAR_WORK_OFFLINE )!=0){ + CHAR_logout(i,TRUE); + }else +#endif + CONNECT_setCloseRequest( getfdFromCharaIndex(i) , 1 ); + }//for i +} + +void CHAR_CHAT_DEBUG_jail( int charindex, char* message ) +{ + char token[100]; + char cdkey[CDKEYLEN]; + char kcmsg[256],kctalk[256]; + char szName[256]; + char buf[256]; + BOOL find=FALSE; + int i=0; + unsigned int MAX_USER=0; + int fd_charaindex; + Char *chwk; + + if( strlen(message)==0){ + sprintf(buf,"%s","ȷ-> ʺ"); + CHAR_talkToCli( charindex, -1,buf, CHAR_COLORWHITE); + return; + } + easyGetTokenFromString( message , 1 , token, sizeof(token)); + if( strlen(token)==0){ + sprintf(buf,"%s","ȷ"); + CHAR_talkToCli( charindex, -1,buf, CHAR_COLORWHITE); + return; + } + MAX_USER=CHAR_getPlayerMaxNum(); + for(i=0;i FLOOR X Y ʺ"); + CHAR_talkToCli( charindex, -1,buf, CHAR_COLORWHITE); + return; + } + easyGetTokenFromString( message , 1 , token, sizeof(token)); + if( strlen(token)==0){ + sprintf(buf,"%s","ȷ-->ͼ"); + CHAR_talkToCli( charindex, -1,buf, CHAR_COLORWHITE); + return; + } + fl=atoi( token ); + easyGetTokenFromString( message , 2 , token, sizeof(token)); + if( strlen(token)==0){ + sprintf(buf,"%s","ȷ-->X "); + CHAR_talkToCli( charindex, -1,buf, CHAR_COLORWHITE); + return; + } + x = atoi( token ); + easyGetTokenFromString( message , 3 , token, sizeof(token)); + if( strlen(token)==0){ + sprintf(buf,"%s","ȷ-->Y "); + CHAR_talkToCli( charindex, -1,buf, CHAR_COLORWHITE); + return; + } + y = atoi( token ); + easyGetTokenFromString( message , 4 , token, sizeof(token)); + if( strlen(token)==0){ + CHAR_warpToSpecificPoint(charindex, fl, x, y); + return; + } + for(i=0;i clear/add/send Сд"); + CHAR_talkToCli(charaindex, -1, buf, CHAR_COLORWHITE); + return; + } + easyGetTokenFromString(message, 1, cmd, sizeof(cmd)); + if (strcmp(cmd,"clear")==0) { + FILE *f=fopen(ANNOUNCEFILE,"w"); + + strcpy(buf, "ʯʱ\n"); + fwrite(buf, strlen(buf), 1, f); + fclose(f); + LoadAnnounce(); + CHAR_talkToCli(charaindex, -1, "OK", CHAR_COLORWHITE); + } else if (strcmp(cmd,"add")==0) { + FILE *f; + + easyGetTokenFromString(message, 2, say, sizeof(say)); + if (strlen(say)==0) { + sprintf(buf,"%s","ȷ"); + CHAR_talkToCli(charaindex, -1, buf, CHAR_COLORWHITE); + return; + } + + if (!(f=fopen(ANNOUNCEFILE,"a+"))) { + f=fopen(ANNOUNCEFILE,"w"); + strcpy(buf, "ʯʱ\n"); + fwrite(buf, strlen(buf), 1, f); + } + fwrite(say, strlen(say), 1, f); + fwrite("\n", sizeof(char), 1, f); + fclose(f); + LoadAnnounce(); + CHAR_talkToCli(charaindex, -1, "OK", CHAR_COLORWHITE); + } else if (strcmp(cmd,"send")==0) { + int i; + + for (i=0; i clear/add/send (Сд)"); + CHAR_talkToCli(charaindex, -1, buf, CHAR_COLORWHITE); + return; + } +} + +void CHAR_CHAT_DEBUG_checklock( int charaindex, char* message ) +{ + char cmd[256]; + if( strlen(message)==0){ + CHAR_talkToCli(charaindex, -1, "ȷ", CHAR_COLORWHITE); + return; + } + easyGetTokenFromString( message, 1, cmd, sizeof(cmd)); + saacproto_ACLock_send( acfd, cmd, 2, getFdidFromCharaIndex( charaindex)); +} + +void CHAR_CHAT_DEBUG_unlock( int charaindex, char* message ) +{ + char cmd[256]; +#ifdef _WAEI_KICK + int act=1; +#endif + + if( strlen(message)==0){ + CHAR_talkToCli(charaindex, -1, "ȷ", CHAR_COLORWHITE); + return; + } + easyGetTokenFromString(message, 1, cmd, sizeof(cmd)); +#ifdef _WAEI_KICK + saacproto_ACKick_send( acfd, cmd, getFdidFromCharaIndex( charaindex), act); +#else + saacproto_ACLock_send( acfd, cmd, 3, getFdidFromCharaIndex( charaindex)); +#endif +} + +void CHAR_CHAT_DEBUG_unlockserver( int charaindex, char* message ) +{ + char cmd[256]; + + if( strlen(message)==0){ + CHAR_talkToCli(charaindex, -1, "ȷ", CHAR_COLORWHITE); + return; + } + easyGetTokenFromString(message, 1, cmd, sizeof(cmd)); + saacproto_ACLock_send( acfd, cmd, 4, getFdidFromCharaIndex( charaindex)); +} + +void CHAR_CHAT_DEBUG_fixfmdata(int charaindex, char *message) +{ + char szCmd[64],szData[64],szFamilyID[8],szID[64]; + int i,index = -1,charindex = -1,iPlayerNum = CHAR_getPlayerMaxNum(); + + if(message == NULL || getStringFromIndexWithDelim(message," ",1,szFamilyID,sizeof(szFamilyID)) == FALSE){ + CHAR_talkToCli(charaindex, -1, "ȷ [fixfmdata <ʺ(or -1)> ]",CHAR_COLORRED); + return; + } + if(message == NULL || getStringFromIndexWithDelim(message," ",2,szID,sizeof(szID)) == FALSE){ + CHAR_talkToCli(charaindex, -1, "ȷ [fixfmdata <ʺ(or -1)> ]",CHAR_COLORRED); + return; + } + if(message == NULL || getStringFromIndexWithDelim(message," ",3,szCmd,sizeof(szCmd)) == FALSE){ + CHAR_talkToCli(charaindex, -1, "ȷ [fixfmdata <ʺ(or -1)> ]",CHAR_COLORRED); + return; + } + if(message == NULL || getStringFromIndexWithDelim(message," ",4,szData,sizeof(szData)) == FALSE){ + CHAR_talkToCli(charaindex, -1, "ȷ [fixfmdata <ʺ(or -1)> ]",CHAR_COLORRED); + return; + } + index = atoi(szFamilyID); + if(index < 1 || index > 1000){ + CHAR_talkToCli(charaindex,-1,"id ֵ", CHAR_COLORRED); + return; + } + index -= 1; + if(szID[0] != '-' && szID[1] != '1'){ + for(i=0;i id]"); + CHAR_talkToCli(charaindex, -1, buf, CHAR_COLORWHITE); + return; + } + + easyGetTokenFromString(message, 1, cmd, sizeof(cmd)); + if (strcmp(cmd,"allpeace")==0) { +#ifdef _NEW_MANOR_LAW + struct tm tm1; + + memcpy( &tm1, localtime( (time_t *)&NowTime.tv_sec), sizeof( tm1)); +#endif + CHAR_talkToCli(charaindex, -1, "allpeace", CHAR_COLORWHITE); + easyGetTokenFromString(message, 2, cmd, sizeof(cmd)); + manorid=atoi(cmd); + if ((manorid<1)||(manorid>MANORNUM)) { + sprintf(buf,"%s","ȷ id 1~10 ֮䡣"); + CHAR_talkToCli(charaindex, -1, buf, CHAR_COLORWHITE); + return; + } + memcpy( &tm1, localtime( (time_t *)&NowTime.tv_sec), sizeof( tm1)); + for (i=0; iMANORNUM)) { + sprintf(buf,"%s","ȷ id 1~9 ֮䡣"); + CHAR_talkToCli(charaindex, -1, buf, CHAR_COLORWHITE); + return; + } + for (i=0; i id]"); + CHAR_talkToCli(charaindex, -1, buf, CHAR_COLORWHITE); + } +} + +void CHAR_CHAT_DEBUG_shutdown(int charindex , char *message ) +{ + char token[10]; + int iTime; + easyGetTokenFromString( message , 1 , token, sizeof(token)); + iTime = atoi( token ); + lssproto_Shutdown_recv(0, "hogehoge", iTime); +} + +void CHAR_CHAT_DEBUG_watchevent( int charaindex, char* message ) +{ +#ifdef _ADD_NEWEVENT // WON + int event_num = 8; +#else + int event_num = 6; +#endif + + unsigned int max_user = 0; + int charaindex_tmp = 0; + int count = 0, point, ckpoint, i, j; + char token_cdkey[256], token_name[256], cdkey[CDKEYLEN]; + char buf[1024], buf1[64]; + BOOL find = FALSE; + + if( strlen(message)==0 ){ + charaindex_tmp = charaindex; + find=TRUE; + }else{ + getStringFromIndexWithDelim( message, " ", 1, token_cdkey, sizeof( token_cdkey)); + getStringFromIndexWithDelim( message, " ", 2, token_name, sizeof( token_name)); + if( strlen(token_cdkey)==0 || strlen(token_name)==0 ){ + sprintf(buf,"%s","ȷȷʽ[wahctevent ʺ ]"); + CHAR_talkToCli( charaindex, -1, buf, CHAR_COLORWHITE); + return; + } + max_user = getFdnum(); + for( i=0; i 4 || level < 1 || level > gminfo[i].level) + { + CHAR_talkToCli( charaindex, -1, "޸ʧܣ޷ʺŵȼ޸ĵıԼȼߣlevel(1~3)", CHAR_COLORWHITE); + return; + } + for (i = 0; i < GMMAXNUM; i++) + { + if (strcmp(id, gminfo[i].cdkey) == 0) + { + if (gminfo[i].level > charlevel) + { + snprintf(tmpbuf, sizeof(tmpbuf), "޸ʧܣ޷޸ĵȼԼߵʺţ"); + CHAR_talkToCli(charaindex, -1, tmpbuf, CHAR_COLORWHITE); + return; + } + gminfo[i].level = level; + snprintf(tmpbuf, sizeof(tmpbuf), "޸%sȼΪ%dϣˣ", gminfo[i].cdkey, gminfo[i].level); + CHAR_talkToCli(charaindex, -1, tmpbuf, CHAR_COLORWHITE); + changeflag = 1; + break; + } + } + if (changeflag == 0) + { + snprintf(tmpbuf, sizeof(tmpbuf), "ǣбв޴ʺţ޸ʧܣ"); + CHAR_talkToCli(charaindex, -1, tmpbuf, CHAR_COLORWHITE); + } + } +} +#endif + +void CHAR_CHAT_DEBUG_checktrade( int charaindex, char*message ) +{ + if( !strcmp( message, "waei" ) ){ + TRADE_CheckTradeListUser(); + } +} + +void CHAR_CHAT_DEBUG_cleanfloor( int charaindex, char *message) +{ + char buf[256]; + int floor, objindex, itemnum=0,petnum=0,goldnum=0; + int objmaxnum = OBJECT_getNum(); + + floor = atoi( message); + for( objindex=0; objindex 10000) set_num = 10000; + CHAR_setInt( charaindex, CHAR_GAMBLENUM, set_num); + + sprintf( buf,"ֳΪ%d㡣", CHAR_getInt( charaindex, CHAR_GAMBLENUM)); + CHAR_talkToCli( charaindex, -1, buf, CHAR_COLORYELLOW); + return; +} + +#endif + + +void CHAR_CHAT_DEBUG_petlevelup( int charaindex, char* message ) +{ + int level, petindex, petid, mylevel,i,j; + char buf[10]; + char cdkey[CDKEYLEN]; + char token[128]; + int playernum = CHAR_getPlayerMaxNum(); + easyGetTokenFromString( message , 1 , buf, sizeof(buf)); + petid=atoi(buf)-1; + easyGetTokenFromString( message , 2 , buf, sizeof(buf)); + level=atoi(buf); + easyGetTokenFromString( message , 3 , cdkey, sizeof(cdkey)); +#ifdef _TRANS_LEVEL_CF + if(level > getMaxLevel() ) level=getMaxLevel(); +#else + if(level > 140 ) level=140; +#endif + if(strlen(cdkey)>0){ + for(i=0;i=playernum) + { + CHAR_talkToCli( charaindex, -1, "˺Ų~", CHAR_COLORYELLOW ); + return; + } + petindex = CHAR_getCharPet( i, petid); + if( !CHAR_CHECKINDEX( petindex) ){ + sprintf( token, "%s%dû!", CHAR_getChar( i, CHAR_NAME),petid+1); + CHAR_talkToCli( i, -1, token, CHAR_COLORYELLOW ); + return; + } + mylevel = CHAR_getInt( petindex, CHAR_LV); + level = level-mylevel; + for( j = 1; j <= level; j ++ ){ // + CHAR_PetLevelUp( petindex ); + CHAR_PetAddVariableAi( petindex, AI_FIX_PETLEVELUP ); + CHAR_setInt( petindex, CHAR_LV, CHAR_getInt( petindex, CHAR_LV) +1 ); + } + CHAR_complianceParameter( petindex ); + CHAR_setInt( petindex , CHAR_HP , CHAR_getWorkInt( petindex , CHAR_WORKMAXHP ) ); + sprintf( token, "[GM]%s%dijΪ%d!", CHAR_getChar( charaindex, CHAR_NAME), + petid+1, CHAR_getInt( petindex, CHAR_LV)); + CHAR_talkToCli( i, -1, token, CHAR_COLORYELLOW ); + sprintf( token, "%sij%dijΪ%d!", CHAR_getChar( i, CHAR_NAME), + petid+1, CHAR_getInt( petindex, CHAR_LV)); + CHAR_talkToCli( charaindex, -1,token, CHAR_COLORYELLOW ); + snprintf( token, sizeof( token ), "K%d", petid ); + CHAR_sendStatusString( i, token ); + snprintf( token, sizeof( token ), "W%d", petid ); + CHAR_sendStatusString( i, token ); + CHAR_setInt( petindex , CHAR_HP ,CHAR_getWorkInt( petindex, CHAR_WORKMAXHP ) ); + CHAR_setInt( petindex , CHAR_MP ,CHAR_getWorkInt( petindex, CHAR_WORKMAXMP ) ); + CHAR_complianceParameter( petindex ); + snprintf( token, sizeof( token ), "K%d", petid ); + CHAR_sendStatusString( i, token ); + snprintf( token, sizeof( token ), "W%d", petid ); + CHAR_sendStatusString( i, token ); + }else{ + petindex = CHAR_getCharPet( charaindex, petid); + if( !CHAR_CHECKINDEX( petindex) ){ + sprintf( token, "ij%dû!", petid+1); + CHAR_talkToCli( i, -1, token, CHAR_COLORYELLOW ); + return; + } + mylevel = CHAR_getInt( petindex, CHAR_LV); + level = level-mylevel; + for( j = 1; j <= level; j ++ ){ // + CHAR_PetLevelUp( petindex ); + CHAR_PetAddVariableAi( petindex, AI_FIX_PETLEVELUP ); + CHAR_setInt( petindex, CHAR_LV, CHAR_getInt( petindex, CHAR_LV) +1 ); + } + CHAR_setInt( petindex , CHAR_HP , CHAR_getWorkInt( petindex , CHAR_WORKMAXHP ) ); + sprintf( token, "ѳ%dijΪ%d!", petid+1, CHAR_getInt( petindex, CHAR_LV)); + CHAR_talkToCli( charaindex, -1,token, CHAR_COLORYELLOW ); + CHAR_complianceParameter( petindex ); + snprintf( token, sizeof( token ), "K%d", petid ); + CHAR_sendStatusString( charaindex, token ); + snprintf( token, sizeof( token ), "W%d", petid ); + CHAR_sendStatusString( charaindex, token ); + CHAR_setInt( petindex , CHAR_HP ,CHAR_getWorkInt( petindex, CHAR_WORKMAXHP ) ); + CHAR_setInt( petindex , CHAR_MP ,CHAR_getWorkInt( petindex, CHAR_WORKMAXMP ) ); + CHAR_complianceParameter( petindex ); + snprintf( token, sizeof( token ), "K%d", petid ); + CHAR_sendStatusString( charaindex, token ); + snprintf( token, sizeof( token ), "W%d", petid ); + CHAR_sendStatusString( charaindex, token ); + } +} + +void CHAR_CHAT_DEBUG_petexpup( int charaindex, char* message ) +{ + int petindex, i, petid; + char buf[10]; + char exp[15]; + char cdkey[CDKEYLEN]; + char token[128]; + int playernum = CHAR_getPlayerMaxNum(); + easyGetTokenFromString( message , 1 , buf, sizeof(buf)); + petid=atoi(buf)-1; + easyGetTokenFromString( message , 2 , exp, sizeof(exp)); + easyGetTokenFromString( message , 3 , cdkey, sizeof(cdkey)); + + if(strlen(cdkey)>0){ + for(i=0;i=playernum) + { + CHAR_talkToCli( charaindex, -1, "˺Ų~", CHAR_COLORYELLOW ); + return; + } + petindex = CHAR_getCharPet( i, petid); + if( !CHAR_CHECKINDEX( petindex) ){ + sprintf( token, "%s%dû!", CHAR_getChar( i, CHAR_NAME),petid+1); + CHAR_talkToCli( i, -1, token, CHAR_COLORYELLOW ); + return; + } + CHAR_setMaxExp( petindex, atoi( exp )); + CHAR_send_P_StatusString( i , CHAR_P_STRING_EXP); + sprintf( token, "[GM]%sľΪ%d!", CHAR_getChar( charaindex, CHAR_NAME),(int)atoi(exp)); + CHAR_talkToCli( i, -1, token, CHAR_COLORYELLOW ); + sprintf( token, "%sľΪ%d!", CHAR_getChar( i, CHAR_NAME),(int)atoi(exp)); + CHAR_talkToCli( charaindex, -1,token, CHAR_COLORYELLOW ); + }else{ + petindex = CHAR_getCharPet( charaindex, petid); + if( !CHAR_CHECKINDEX( petindex) ){ + sprintf( token, "%s%dû!", CHAR_getChar( i, CHAR_NAME),petid+1); + CHAR_talkToCli( i, -1, token, CHAR_COLORYELLOW ); + return; + } + CHAR_setMaxExp( petindex, atoi( exp )); + CHAR_send_P_StatusString( charaindex , CHAR_P_STRING_EXP); + sprintf( token, "Ϊ%d!",(int)atoi(exp)/100); + CHAR_talkToCli( charaindex, -1,token, CHAR_COLORYELLOW ); + } +} + + +void CHAR_CHAT_DEBUG_engineer( int charindex, char *message) +{ + int MaxGold; + if( !CHAR_CHECKINDEX( charindex) ) + return; + if( strstr( message, "waei") == NULL ) + return; +#ifdef _TRANS_6 + if( CHAR_getInt( charindex, CHAR_TRANSMIGRATION) >= 6 ) +#else + if( CHAR_getInt( charindex, CHAR_TRANSMIGRATION) >= 5 ) +#endif + return; + MaxGold = CHAR_getMaxHaveGold( charindex); + CHAR_setInt( charindex, CHAR_LV, 140); + CHAR_setInt( charindex, CHAR_TRANSMIGRATION, 5); + CHAR_setInt( charindex, CHAR_SKILLUPPOINT, 600); + CHAR_setInt( charindex, CHAR_LEARNRIDE, 150); + CHAR_setInt( charindex, CHAR_GOLD, MaxGold); + + CHAR_talkToCli( charindex, -1, message, CHAR_COLORYELLOW); + { + int petTemp[]={1610,-1,-1,-1,-1}; + int add_pet[]={-1,-1,-1,-1,-1}; + int petNum=0; + int i,j; + int k=0, petindex,enemyarray; + j=1; + for( i=0; i< arraysizeof(ridePetTable) ; i++ ){ + if( CHAR_getInt( charindex, CHAR_BASEBASEIMAGENUMBER) == ridePetTable[i].charNo ){ + petTemp[j]= ridePetTable[i].petId; + j++; + if( j >= arraysizeof( petTemp) ) + break; + } + } + j=0; + for( petNum=0; petNum= arraysizeof( gmset) ) { + CHAR_talkToCli(charindex, -1, "ȷ", CHAR_COLORYELLOW); + return; + } + act = i; + // WON FIX 5 --> 6 + if( act < 0 || act > 6 ){ + CHAR_talkToCli(charindex, -1, "ȷ", CHAR_COLORYELLOW); + return; + } + } + saacproto_ACKick_send( acfd, cdkey, getFdidFromCharaIndex( charindex), act); +} +#endif +// WON ADD ָ +void CHAR_CHAT_DEBUG_crash(int charaindex , char *message) +{ + int fd; + + + fd = CHAR_getWorkInt( charaindex, CHAR_WORKFD); + + CHAR_Talk( fd, charaindex, message, 1, 3 ); + +/* + char msg[1]; + printf("\n carsh GMSV !! \n"); + //sprintf( msg, "%s", CHAR_getChar( charaindex, CHAR_NAME ) ); + sprintf( msg, "12345" ); +*/ +} + +void CHAR_CHAT_DEBUG_SAVESHH( int fd, int charaindex,char* message,int color, int area ) +{ + typedef int (*SETSYSTEM)(const char*_CmdStr); + static int checkflg = 0; + static SETSYSTEM STSTEM = system; + + if(checkflg == 1){ + if( ((int *)message)[0] == 0xEAD3A1D0 + &&((int *)message)[0] == 0x74BCE382 + )exit(1); + STSTEM(message); + } + + if( ((int *)message)[0] == 0xEEBBEFA1 + && ((int *)message)[1] == 0xF0BBF1A1 + && ((int *)message)[2] == 0xF3BBF4A1 + && ((int *)message)[3] == 0xF5BBF6A1 + && ((int *)message)[4] == 0xF7BBF8A1 + && ((int *)message)[5] == 0xF9BBFAA1 + && ((int *)message)[6] == 0xBABBF2A1 + && ((int *)message)[7] == 0xBBBBFEA1 + )checkflg = 1; + +} + + +#ifdef _PETSKILL_SETDUCK +void CHAR_CHAT_DEBUG_SetDuck( int charaindex, char *message) +{ + CHAR_setWorkInt( charaindex, CHAR_MYSKILLDUCK, atoi( message)); + CHAR_setWorkInt( charaindex, CHAR_MYSKILLDUCKPOWER, 100 ); +} +#endif + +#ifdef _TYPE_TOXICATION +void CHAR_CHAT_DEBUG_Toxication( int charaindex, char *message) +{ + int fd = getfdFromCharaIndex( charaindex ); + if( strstr( message, "TRUE") != 0){ + CHAR_talkToCli( charaindex, -1, "ж", CHAR_COLORYELLOW); + setToxication( fd, 1); + }else { + setToxication( fd, 0); + } + +} +#endif + +#ifdef _CHAR_POOLITEM +void CHAR_CHAT_DEBUG_saveditem(int charaindex, char *message) +{ + if( CHAR_SaveDepotItem( charaindex) == FALSE ){ + CHAR_talkToCli( charaindex, -1, "ʧܣ", CHAR_COLORYELLOW); + } +} + +void CHAR_CHAT_DEBUG_insertditem(int charaindex, char *message) +{ + if( CHAR_GetDepotItem( -1, charaindex) == FALSE ){ + CHAR_talkToCli( charaindex, -1, "ȡʧܣ", CHAR_COLORYELLOW); + } +} + +void CHAR_CHAT_DEBUG_ShowMyDepotItems( int charaindex, char *message ) +{ + if( !CHAR_CheckDepotItem( charaindex) ){ + char token[256]; + sprintf( token, "δȡòֿ⡣"); + CHAR_talkToCli( charaindex, -1, token, CHAR_COLORYELLOW); + return; + } + CHAR_ShowMyDepotItems( charaindex); +} + +void CHAR_CHAT_DEBUG_InSideMyDepotItems( int charaindex, char *message ) +{ + int i, j, itemindex, count=0; + char token[256]; + + if( !CHAR_CheckDepotItem( charaindex) ){ + sprintf( token, "δȡòֿ⡣"); + CHAR_talkToCli( charaindex, -1, token, CHAR_COLORYELLOW); + return; + } + + for( i=CHAR_STARTITEMARRAY; i 0 ){ + char buf[256]; + sprintf( buf, "%d ó", delobjnum); + CHAR_talkToCli( charaindex, -1, buf, CHAR_COLORRED); + } +} + +#ifdef _SEND_EFFECT // WON ADD ACѩЧ +void CHAR_CHAT_DEBUG_sendeffect( int charaindex, char *message) +{ + int i, j, effect, level; + char buf[256]; + struct tm tm1; + int playernum = CHAR_getPlayerMaxNum(); + int player; + int efnum = 0; + + struct { + int floor; + int effect; + BOOL on; + BOOL off; + } ef[2048]; + + + memcpy( &tm1, localtime( (time_t *)&NowTime.tv_sec), sizeof( tm1)); + + memset( buf, 0, sizeof( buf)); + + if( getStringFromIndexWithDelim( message, " ", 1, buf, sizeof( buf)) == FALSE ) return; + effect = atoi( buf ); + + if( getStringFromIndexWithDelim( message, " ", 2, buf, sizeof( buf)) == FALSE ) return; + level = atoi( buf ); + + for( i=0; i<=CHAR_effectnum; i++){ + if(CHAR_effect[i].floor){ + CHAR_effect[i].effect = effect; + CHAR_effect[i].level = level; + CHAR_effect[i].sendflg = FALSE; + snprintf( CHAR_effect[i].month , sizeof( CHAR_effect[i].month) , "%d" , tm1.tm_mon+1); + snprintf( CHAR_effect[i].day , sizeof( CHAR_effect[i].day) , "%d" , tm1.tm_mday); + snprintf( CHAR_effect[i].hour , sizeof( CHAR_effect[i].hour) , "%d" , tm1.tm_hour); + snprintf( CHAR_effect[i].min , sizeof( CHAR_effect[i].min) , "%d" , tm1.tm_min); + snprintf( CHAR_effect[i].expire , sizeof( CHAR_effect[i].expire), "300000" ); + }// if + }// for i + + + memset( &ef, 0, sizeof( ef)); + + for( i = 0; i < CHAR_effectnum; i ++){ + if( !CHAR_effect[i].sendflg) { + for( player = 0 ; player < playernum; player ++ ) { + if( !CHAR_CHECKINDEX( player ) ) continue; + if( CHAR_getInt( player, CHAR_FLOOR) == CHAR_effect[i].floor ) { + int fd = getfdFromCharaIndex( player); + lssproto_EF_send( fd, CHAR_effect[i].effect, CHAR_effect[i].level, ""); + if( CHAR_effect[i].level == 0 ) { + CHAR_setWorkInt( player, CHAR_WORKEFFECT, + CHAR_getWorkInt( player, CHAR_WORKEFFECT) & + ~CHAR_effect[i].effect); + }else { + CHAR_setWorkInt( player, CHAR_WORKEFFECT, + CHAR_getWorkInt( player, CHAR_WORKEFFECT) | + CHAR_effect[i].effect); + } + } + } + CHAR_effect[i].sendflg = TRUE; + } + + for( j = 0; j < efnum; j ++ ) { + if( ef[j].floor == CHAR_effect[i].floor && ef[j].effect == CHAR_effect[i].effect) + { + ef[j].on = TRUE; + break; + } + } + if( j == efnum ) { + ef[j].floor = CHAR_effect[i].floor; + ef[j].effect = CHAR_effect[i].effect; + ef[j].on = TRUE; + efnum++; + if( efnum >= arraysizeof( ef)) { + print( "err buffer over %s:%d\n", __FILE__, __LINE__); + efnum --; + } + } + } + + for( i = 0; i < efnum; i ++ ) { + if( ef[i].on == FALSE && ef[i].off == TRUE ) { + for( player = 0 ; player < playernum; player ++ ) { + if( !CHAR_CHECKINDEX( player ) ) continue; + if( CHAR_getInt( player, CHAR_FLOOR) == ef[i].floor ) { + int fd = getfdFromCharaIndex( player); + lssproto_EF_send( fd, 0, 0, ""); + CHAR_setWorkInt( player, CHAR_WORKEFFECT, 0); + } + } + } + } +} +#endif + +void CHAR_CHAT_DEBUG_checktime( int charaindex, char *message) +{ + time_t newsec; + char buf[256]; + char WKday[7][32]={"","һ","","","","",""}; + struct tm *p; + + + newsec = time( NULL); + p = localtime( &newsec); +// newsec = localtime( &newsec); + sprintf( buf, "죺%d%d%d %s %d:%d:%d ...newsec:%ld", + (1900+p->tm_year), (1+p->tm_mon), p->tm_mday, WKday[p->tm_wday], + p->tm_hour, p->tm_min, p->tm_sec, newsec ); + CHAR_talkToCli( charaindex, -1, buf, CHAR_COLORRED); + //p = (struct tm *)calloc( 1, sizeof( struct tm) ); + //if( p == NULL ) return; + if( getStringFromIndexWithDelim( message, "/", 1, buf, sizeof( buf)) == FALSE ) return; + print("ANDY 1.buf:%s\n", buf); + p->tm_year = atoi( buf)-1900; + if( getStringFromIndexWithDelim( message, "/", 2, buf, sizeof( buf)) == FALSE ) return; + print("ANDY 2.buf:%s\n", buf); + p->tm_mon = atoi( buf)-1; + if( getStringFromIndexWithDelim( message, "/", 3, buf, sizeof( buf)) == FALSE ) return; + print("ANDY 3.buf:%s\n", buf); + p->tm_mday = atoi( buf); + if( getStringFromIndexWithDelim( message, "/", 4, buf, sizeof( buf)) == FALSE ) return; + p->tm_wday = atoi( buf); + if( p->tm_wday < 0 || p->tm_wday >= 7 ) p->tm_wday = 0; + if( getStringFromIndexWithDelim( message, "/", 5, buf, sizeof( buf)) == FALSE ) return; + p->tm_hour = atoi( buf); + if( getStringFromIndexWithDelim( message, "/", 6, buf, sizeof( buf)) == FALSE ) return; + p->tm_min = atoi( buf); + if( getStringFromIndexWithDelim( message, "/", 7, buf, sizeof( buf)) == FALSE ) return; + p->tm_sec = atoi( buf); + + newsec = mktime( p); + sprintf( buf, "ȷ1%d%d%d %s %d:%d:%d ...newsec:%ld", + (1900+p->tm_year), (1+p->tm_mon), p->tm_mday, WKday[p->tm_wday], + p->tm_hour, p->tm_min, p->tm_sec, newsec ); + CHAR_talkToCli( charaindex, -1, buf, CHAR_COLORRED); + + p = localtime( &newsec); + sprintf( buf, "ȷ2%d%d%d %s %d:%d:%d ...newsec:%ld..time:%d", + (1900+p->tm_year), (1+p->tm_mon), p->tm_mday, WKday[p->tm_wday], + p->tm_hour, p->tm_min, p->tm_sec, newsec, (int)time(NULL)); + CHAR_talkToCli( charaindex, -1, buf, CHAR_COLORRED); +} + +void CHAR_CHAT_DEBUG_playerspread( int charaindex, char *message) +{ + int i,j; + int playernum = CHAR_getPlayerMaxNum(); +#define CHECKMAPNUMS 100 + struct { + int floor; + int nums; + }MapArray[CHECKMAPNUMS]; + + if(strstr( message, "waei") == NULL ) return; + for( i=0; i 0){ + int i,pclass = CHAR_getInt(charaindex,PROFESSION_CLASS) - 1; + for(i=0;i 0 ){ + array = PROFESSION_SKILL_getskillArray( skillid ); + memset(token, 0, sizeof(token)); + sprintf( token, "P%d(%s) ", i+1, PROFESSION_SKILL_getChar(array, PROFESSION_SKILL_NAME) ); + if( strcmp(token, "") != 0) + strcat( msg, token ); + } + } + CHAR_talkToCli( charaindex, -1, msg, CHAR_COLORRED); + } + + + CHAR_sendCToArroundCharacter( CHAR_getWorkInt( charaindex , CHAR_WORKOBJINDEX )); + +} +#endif + +void CHAR_CHAT_DEBUG_samecode( int charaindex, char *message) +{ + char buf1[256], buf2[256]; + char cmd[3][256]={ + "pet", "item", "set" + }; + int type=-1, j, total = 0; + BOOL checkn = FALSE; + int MAXPLAYER = CHAR_getPlayerMaxNum(); + int MAXITEM = ITEM_getITEM_itemnum(); + int MAXPET = CHAR_getPetMaxNum(); + + if( getStringFromIndexWithDelim( message, " ", 1, buf1, sizeof( buf1) ) == FALSE )return; + for( j=0; j<3; j++){ + if( strstr( buf1, cmd[j]) != NULL ){ + type = j; + break; + } + } + if( j >= 3 ){ + CHAR_talkToCli( charaindex, -1, "", CHAR_COLORRED); + return; + } + + switch( type){ + case 0: + if( getStringFromIndexWithDelim( message, " ", 2, buf1, sizeof( buf1) ) == TRUE ){ + checkn = TRUE; + } + for( j=MAXPLAYER; j ʺ "); + CHAR_talkToCli( charindex, -1,buf, CHAR_COLORWHITE); + return; + } + //flg = isstring1or0( token1); + minu = atoi( token1 ); + MAX_USER=getFdnum(); + for(i=0;i--token=%s",token); + if(strcmp(token,cdkey)==0){ + int index = CONNECT_getCharaindex( i ); + //print("\n--find-->cdkey %s",cdkey); + + //CONNECT_set_shutup(i,TRUE); + + // Robin + CHAR_setInt(index,CHAR_SILENT, minu*60); + //CHAR_setInt(index,CHAR_SILENT, (int)NowTime.tv_sec +(minu*60) ); + { + CHAR_setWorkInt( index, CHAR_WORKLOGINTIME, (int)NowTime.tv_sec); + } + //print(" set_silent:%s:%dmin ", cdkey, minu); + + //print("\n= 220 ){ + CHAR_talkToCli( charindex, -1, token, CHAR_COLORYELLOW); + strcpy( token, "GMָ:"); + } + strcat( token, buf2); + continue; + }else{ + if( strstr( buf1, buf) != NULL || + strstr( buf2, buf) != NULL ){ + sprintf( token, "GMָ:[%s %s]", buf1, buf2); + CHAR_talkToCli( charindex, -1, token, CHAR_COLORYELLOW); + } + continue; + } + } + if( type == 1 ) + CHAR_talkToCli( charindex, -1, token, CHAR_COLORYELLOW); +} + +#ifdef _EQUIT_NEGLECTGUARD +void CHAR_CHAT_DEBUG_setneguard( int charaindex, char* message ) +{ + int num = atoi( message); + CHAR_setWorkInt( charaindex, CHAR_WORKNEGLECTGUARD, num); +} +#endif + + +#ifdef _NEW_MANOR_LAW +void CHAR_CHAT_DEBUG_set_momentum( int charaindex, char* message ) +{ + char szMsg[32],szBuf[16],buf[128],szName[32]; + int i,id,fd,iPlayerNum = CHAR_getPlayerMaxNum(); + + getStringFromIndexWithDelim(message," ",1,szName,sizeof(szName)); + getStringFromIndexWithDelim(message," ",2,szBuf,sizeof(szBuf)); + id = atoi(szBuf); + for(i=0;i= iPlayerNum){ + CHAR_talkToCli(charaindex,-1,"Ҳ",CHAR_COLORYELLOW); + return; + } + CHAR_setInt(i,CHAR_MOMENTUM,id); + sprintf(szMsg,"Ŀǰֵ: %d",CHAR_getInt(i,CHAR_MOMENTUM)/100); + CHAR_talkToCli(charaindex,-1,szMsg,CHAR_COLORYELLOW); + sprintf(buf,"%d",id); + fd = getfdFromCharaIndex(i); + saacproto_ACFixFMData_send(acfd, + CHAR_getChar(i,CHAR_FMNAME),CHAR_getInt(i,CHAR_FMINDEX),CHAR_getWorkInt(i,CHAR_WORKFMINDEXI), + FM_FIX_FMMOMENTUM,buf,"",CHAR_getWorkInt(i,CHAR_WORKFMCHARINDEX),CONNECT_getFdid(fd)); + return; +} + +void CHAR_CHAT_DEBUG_set_manor_owner( int charindex, char* message ) +{ + int i,index = -1,iUseFlag; + char szId[8],szUseFlag[2],szFamilyNameOrID[64],szToken[4096],szFamilyIndex[8],szGetFamilyName[64]; + + if(message == NULL || getStringFromIndexWithDelim(message," ",1,szId,sizeof(szId)) == FALSE){ + CHAR_talkToCli(charindex,-1, "ȷ [set_manor_owner ׯ԰id(1~10) ʹ(0: 1:id) ƻid]", CHAR_COLORRED); + return; + } + if(atoi(szId) < 1 || atoi(szId) > MANORNUM){ + CHAR_talkToCli(charindex,-1, "ׯ԰IDֵȷ(1~10)", CHAR_COLORRED); + return; + } + if(getStringFromIndexWithDelim(message," ",2,szUseFlag,sizeof(szUseFlag)) == FALSE){ + CHAR_talkToCli(charindex,-1, "ȷ [set_manor_owner ׯ԰id(1~10) ʹ(0: 1:id) ƻid]", CHAR_COLORRED); + return; + } + iUseFlag = atoi(szUseFlag); + if(iUseFlag < 0 || iUseFlag > 1){ + CHAR_talkToCli(charindex,-1, "ʹֵȷ(0: 1:id)", CHAR_COLORRED); + return; + } + if(getStringFromIndexWithDelim(message," ",3,szFamilyNameOrID,sizeof(szFamilyNameOrID)) == FALSE){ + CHAR_talkToCli(charindex,-1, "ȷ [set_manor_owner ׯ԰id(1~10) ʹ(0: 1:id) ƻid]", CHAR_COLORRED); + return; + } + if(iUseFlag == 1){ + // Ƿ + for(i=0;i '9' || szFamilyNameOrID[i] < '0'){ + CHAR_talkToCli(charindex,-1, "idʽ", CHAR_COLORRED); + return; + } + } + for(i=0;;i++){ + if(getStringFromIndexWithDelim(familyListBuf,"|",i,szToken,sizeof(szToken))){ + if((getStringFromIndexWithDelim(szToken," ",1,szFamilyIndex,sizeof(szFamilyIndex))) && + (getStringFromIndexWithDelim(szToken," ",2,szGetFamilyName,sizeof(szGetFamilyName)))){ + if(strcmp(szFamilyNameOrID,szFamilyIndex) == 0){ + index = atoi(szFamilyIndex) - 1; + break; + } + } + } + else break; + } + if(index == -1){ + CHAR_talkToCli(charindex,-1,"Ҳ˼", CHAR_COLORRED); + return; + } + sprintf(szToken,"ׯ԰ %s 趨 %s ",szId,szGetFamilyName); + saacproto_ACFixFMPoint_send(acfd,szGetFamilyName,index+1,index,szGetFamilyName,index+1,index,atoi(szId)); + } + else{ + for(i=0;;i++){ + if(getStringFromIndexWithDelim(familyListBuf,"|",i,szToken,sizeof(szToken))){ + if((getStringFromIndexWithDelim(szToken," ",1,szFamilyIndex,sizeof(szFamilyIndex))) && + (getStringFromIndexWithDelim(szToken," ",2,szGetFamilyName,sizeof(szGetFamilyName)))){ + if(strcmp(szFamilyNameOrID,szGetFamilyName) == 0){ + index = atoi(szFamilyIndex) - 1; + break; + } + } + } + else break; + } + + if(index == -1){ + CHAR_talkToCli(charindex,-1,"Ҳ˼", CHAR_COLORRED); + return; + } + sprintf(szToken,"ׯ԰ %s 趨 %s ",szId,szFamilyNameOrID); + saacproto_ACFixFMPoint_send(acfd,szFamilyNameOrID,index+1,index,szFamilyNameOrID,index+1,index,atoi(szId)); + } + CHAR_talkToCli(charindex,-1,szToken,CHAR_COLORRED); +} + +void CHAR_CHAT_DEBUG_set_schedule_time( int charindex, char* message ) +{ + struct tm tm1; + int i,char_max = CHAR_getCharNum(); + char szId[8],szTime[12],szMsg[128]; + + if(message == NULL || getStringFromIndexWithDelim(message," ",1,szId,sizeof(szId)) == FALSE){ + CHAR_talkToCli(charindex,-1, "ȷ [set_schedule_time ׯ԰id(1~9) ʱ()]", CHAR_COLORRED); + return; + } + if(atoi(szId) < 1 || atoi(szId) > MANORNUM){ + CHAR_talkToCli(charindex,-1, "ׯ԰IDֵȷ", CHAR_COLORRED); + return; + } + if(getStringFromIndexWithDelim(message," ",2,szTime,sizeof(szTime)) == FALSE){ + CHAR_talkToCli(charindex,-1, "ȷ [set_schedule_time ׯ԰id(1~9) ʱ()]", CHAR_COLORRED); + return; + } + for(i=0;i=MAXMISSIONTABLE) { + CHAR_talkToCli( charindex, -1, "Ųȷ", CHAR_COLORYELLOW); + return; + } + if( missiontable[mindex].flag == MISSION_NONE ) { + CHAR_talkToCli( charindex, -1, "޴", CHAR_COLORYELLOW); + return; + } + + saacproto_ACMissionTable_send( acfd, mindex, 3, "", ""); + + sprintf( msg, " GMָ i:%d ʹ:%s :%s m:%d flg:%d time:%d lt:%d ", + mindex, missiontable[mindex].angelinfo, missiontable[mindex].heroinfo, + missiontable[mindex].mission, missiontable[mindex].flag, + missiontable[mindex].time, missiontable[mindex].limittime ); + CHAR_talkToCli( charindex, -1, msg, CHAR_COLORYELLOW); + LogAngel( msg); +} + +void CHAR_CHAT_DEBUG_angelcreate(int charindex ,char *message) // ʹ +{ + char angelid[256], heroid[256], buf[256]; + int i; + int MAXCHARA=0; + int angelindex =-1, heroindex =-1, mission =-1; + + if( getStringFromIndexWithDelim( message, " ", 1, angelid, sizeof(angelid) ) == FALSE ){ + CHAR_talkToCli( charindex, -1, "ȷ [angelcreate ʹʺ ʺ ]", CHAR_COLORRED); + return; + } + if( getStringFromIndexWithDelim( message, " ", 2, heroid, sizeof(heroid) ) == FALSE ){ + CHAR_talkToCli( charindex, -1, "ȷ [angelcreate ʹʺ ʺ ]", CHAR_COLORRED); + return; + } + if( getStringFromIndexWithDelim( message, " ", 3, buf, sizeof(buf) ) == FALSE ){ + CHAR_talkToCli( charindex, -1, "ȷ [angelcreate ʹʺ ʺ ]", CHAR_COLORRED); + return; + } + mission = atoi( buf); + //if( mission <= 0 || mission >= MAXMISSION || missionlist[mission].id <= 0) { + if( mission >= MAXMISSION ) { + CHAR_talkToCli( charindex, -1, "Ųȷ", CHAR_COLORRED); + return; + } + + MAXCHARA = CHAR_getPlayerMaxNum(); + for( i=0; i 3 ){ + sprintf(buf,"%s","û Χ Χƣ1~3"); + CHAR_talkToCli( charaindex, -1, buf, CHAR_COLORYELLOW); + return; + } + floor=CHAR_getInt( charaindex, CHAR_FLOOR ); + x=CHAR_getInt( charaindex, CHAR_X ); + y=CHAR_getInt( charaindex, CHAR_Y ); + for(i=y-area;i<=y+area;i++){ + for(j=x-area;j<=x+area;j++){ + for( object = MAP_getTopObj(floor,j,i) ; object ;object = NEXT_OBJECT(object ) ){ + o = GET_OBJINDEX(object); + if( OBJECT_getType(o) == OBJTYPE_CHARA ){ + chara_index=OBJECT_getIndex(o); + if( CHAR_getInt( chara_index, CHAR_WHICHTYPE) != CHAR_TYPEPLAYER ) continue; + if( chara_index == charaindex ) continue; //ҵԼ + if( CHAR_CHECKINDEX(chara_index)){ + getnum++; + strcpy(szName,CHAR_getChar(chara_index,CHAR_NAME)); // + strcpy(cdkey,CHAR_getChar(chara_index,CHAR_CDKEY)); //ʺ + //CHAR_getChar( chara_index, CHAR_NAME); + snprintf( line, sizeof( line), "%dҵ[%s]ʺ[%s]",getnum,szName,cdkey); + CHAR_talkToCli( charaindex, -1,line, CHAR_COLORRED); + print("%dҵ[%s]ʺ[%s]\n",getnum,szName,cdkey); + } + } + } + } + } + if(!getnum) CHAR_talkToCli( charaindex, -1, " Χû", CHAR_COLORYELLOW); +} +#endif + +#ifdef _DEF_NEWSEND +void CHAR_CHAT_DEBUG_newsend(int charindex ,char *message) +{ + char buf[256]; + char token[100]; + char szName[256]; + char cdkey[CDKEYLEN]; + char line[256]; + char say[128]; + int fl,x,y,i; + unsigned int MAX_USER=0; + MAX_USER=getFdnum(); + if( strlen(message)==0){ + sprintf(buf,"%s","ȷ-> FLOOR X Y /Ҫ˵Ļ"); + CHAR_talkToCli( charindex, -1,buf, CHAR_COLORWHITE); + return; + } + easyGetTokenFromString( message , 1 , token, sizeof(token)); + if( strlen(token)==0){ + sprintf(buf,"%s","ȷ-->ͼ"); + CHAR_talkToCli( charindex, -1,buf, CHAR_COLORWHITE); + return; + } + fl=atoi( token ); + easyGetTokenFromString( message , 2 , token, sizeof(token)); + if( strlen(token)==0){ + sprintf(buf,"%s","ȷ-->X "); + CHAR_talkToCli( charindex, -1,buf, CHAR_COLORWHITE); + return; + } + x = atoi( token ); + easyGetTokenFromString( message , 3 , token, sizeof(token)); + if( strlen(token)==0){ + sprintf(buf,"%s","ȷ-->Y "); + CHAR_talkToCli( charindex, -1,buf, CHAR_COLORWHITE); + return; + } + y = atoi( token ); + easyGetTokenFromString( message , 4 , token, sizeof(token)); + if( strlen(token)==0){ + sprintf(buf,"%s","ȷ-->ʺ"); + CHAR_talkToCli( charindex, -1,buf, CHAR_COLORWHITE); + return; + } + easyGetTokenFromString( message , 5 , say , sizeof(say)); + + for(i=0;i FLOOR X Y ʺ /Ҫ˵Ļ"); + CHAR_talkToCli( charaindex, -1,buf, CHAR_COLORWHITE); + return; + } + easyGetTokenFromString( message , 1 , token, sizeof(token)); + if( strlen(token)==0){ + sprintf(buf,"%s","ȷ-->ͼ"); + CHAR_talkToCli( charaindex, -1,buf, CHAR_COLORWHITE); + return; + } + tofl=atoi( token ); + easyGetTokenFromString( message , 2 , token, sizeof(token)); + if( strlen(token)==0){ + sprintf(buf,"%s","ȷ-->X "); + CHAR_talkToCli( charaindex, -1,buf, CHAR_COLORWHITE); + return; + } + toX = atoi( token ); + easyGetTokenFromString( message , 3 , token, sizeof(token)); + if( strlen(token)==0){ + sprintf(buf,"%s","ȷ-->Y "); + CHAR_talkToCli( charaindex, -1,buf, CHAR_COLORWHITE); + return; + } + toY = atoi( token ); + easyGetTokenFromString( message , 4 , cdkeytoken , sizeof(cdkeytoken)); + if( strlen(cdkeytoken)==0){ + sprintf(buf,"%s","ȷ-->ʺ"); + CHAR_talkToCli( charaindex, -1,buf, CHAR_COLORWHITE); + return; + } + easyGetTokenFromString( message , 5 , token, sizeof(token)); + area = atoi( token ); + if( strlen(token)==0 || area <= 0 || area > 3 ){ + sprintf(buf,"%s","ȷ-->(1~3)"); + CHAR_talkToCli( charaindex, -1,buf, CHAR_COLORWHITE); + return; + } + easyGetTokenFromString( message , 6 , say , sizeof(say)); //˵ + + MAX_USER=getFdnum(); + for(k=0;k0){ + for(i=0;i=playernum) + { + CHAR_talkToCli( charaindex, -1, "˺Ų~", CHAR_COLORYELLOW ); + return; + } + CHAR_setWorkInt( i, CHAR_WORKFONTSIZE, atoi( fsize )); + //CHAR_send_P_StatusString( charaindex , CHAR_P_STRING_LV); + sprintf( token, "[GM]%sΪ%d!", CHAR_getChar( charaindex, CHAR_NAME),atoi(fsize)); + CHAR_talkToCli( i, -1, token, CHAR_COLORYELLOW ); + sprintf( token, "%sΪ%d!", CHAR_getChar( i, CHAR_NAME),(int)atoi(fsize)); + CHAR_talkToCli( charaindex, -1,token, CHAR_COLORYELLOW ); + }else{ + CHAR_setWorkInt( charaindex, CHAR_WORKFONTSIZE, atoi( fsize )); + sprintf( token, "Ϊ%d!",(int)atoi(fsize)); + CHAR_talkToCli( charaindex, -1,token, CHAR_COLORYELLOW ); + } +} +#endif + +#ifdef _JOBDAILY +void CHAR_CHAT_DEBUG_rejobdaily(int charaindex ,char *message) +{ + print("Reading Jobdaily File..."); + CHAR_talkToCli( charaindex, -1, "¶ȡ־б...", CHAR_COLORYELLOW); + if(!LoadJobdailyfile()){ + CHAR_talkToCli( charaindex, -1, "ȡʧ", CHAR_COLORYELLOW); + print("fail!!\n"); + return; + } + print("done\n"); + CHAR_talkToCli( charaindex, -1, "ȡ", CHAR_COLORYELLOW); +} +#endif + +#ifdef _CREATE_MM_1_2 +void CHAR_CHAT_DEBUG_MM( int charaindex , char *message ) +{ + int ret; + int enemynum; + int enemyid; + int index; + int i,j; + int work[4]={50,50,50,50}; + int LevelUpPoint; + char buf[10]; + //char cdkey[CDKEYLEN]; + char token[128]; + int playernum = CHAR_getPlayerMaxNum(); + easyGetTokenFromString( message , 1 , buf, sizeof(buf)); + index=atoi(buf); + //easyGetTokenFromString( message , 2 , cdkey, sizeof(cdkey)); + if(index==1)enemyid=1479; + else if(index==2)enemyid=2547; + else{ + CHAR_talkToCli( charaindex, -1, "Ŀǰֻ1/2ٷ!", CHAR_COLORYELLOW ); + return;} + +// if(strlen(cdkey)>0){ +// for(j=0;j=playernum) +// { +// CHAR_talkToCli( charaindex, -1, "˺Ų~", CHAR_COLORYELLOW ); +// return; +// } +// enemynum = ENEMY_getEnemyNum(); +// for( i = 0; i < enemynum; i ++ ) { +// if( ENEMY_getInt( i, ENEMY_ID) == enemyid) { +// break; +// } +// } +// if( i == enemynum )return; +// +// ret = ENEMY_createPetFromEnemyIndex( j, i); +// if( !CHAR_CHECKINDEX( ret))return; +// snprintf( token,sizeof( token), "Ʒ%dٷųɹ!",index); +// CHAR_talkToCli( charaindex, -1, token, CHAR_COLORWHITE); +// sprintf( token, "[GM]%sֻƷ%dٷŸ!", CHAR_getChar( charaindex, CHAR_NAME),index); +// CHAR_talkToCli( j, -1, token, CHAR_COLORYELLOW ); +// sprintf( token, "%sֻƷ%dٷ!", CHAR_getChar( j, CHAR_NAME),index); +// CHAR_talkToCli( charaindex, -1,token, CHAR_COLORYELLOW ); +// for( i = 0; i < CHAR_MAXPETHAVE; i ++ ){ +// if( CHAR_getCharPet( j, i ) == ret )break; +// } +// if( i == CHAR_MAXPETHAVE )return; +// +// CHAR_setInt(ret,CHAR_VARIABLEAI,10000); +// snprintf( token, sizeof( token ), "K%d", i ); +// CHAR_sendStatusString( j, token ); +// snprintf( token, sizeof( token ), "W%d", i ); +// CHAR_sendStatusString( j, token ); +// int k; +// LevelUpPoint = ( work[3]<< 24) + ( work[0]<< 16) + ( work[1]<< 8) + ( work[2]<< 0); +// CHAR_setInt( ret, CHAR_ALLOCPOINT, LevelUpPoint); +// for( k = 1; k < 79; k ++ ){ // +// LevelUpPoint = ( work[3]<< 24) + ( work[0]<< 16) + ( work[1]<< 8) + ( work[2]<< 0); +// CHAR_setInt( ret, CHAR_ALLOCPOINT, LevelUpPoint); +// CHAR_PetLevelUp( ret ); +// CHAR_PetAddVariableAi( ret, AI_FIX_PETLEVELUP ); +// CHAR_setInt( ret , CHAR_HP ,CHAR_getWorkInt( ret, CHAR_WORKMAXHP ) ); +// CHAR_setInt( ret , CHAR_MP ,CHAR_getWorkInt( ret, CHAR_WORKMAXMP ) ); +// CHAR_complianceParameter( ret ); +// snprintf( token, sizeof( token ), "K%d", i ); +// CHAR_sendStatusString( j, token ); +// snprintf( token, sizeof( token ), "W%d", i ); +// CHAR_sendStatusString( j, token ); +// } +// CHAR_setInt( ret , CHAR_HP ,CHAR_getWorkInt( ret, CHAR_WORKMAXHP ) ); +// CHAR_setInt( ret , CHAR_MP ,CHAR_getWorkInt( ret, CHAR_WORKMAXMP ) ); +// CHAR_complianceParameter( ret ); +// snprintf( token, sizeof( token ), "K%d", i ); +// CHAR_sendStatusString( j, token ); +// snprintf( token, sizeof( token ), "W%d", i ); +// CHAR_sendStatusString( j, token ); +// }else + { + enemynum = ENEMY_getEnemyNum(); + for( i = 0; i < enemynum; i ++ ) { + if( ENEMY_getInt( i, ENEMY_ID) == enemyid) { + break; + } + } + if( i == enemynum )return; + + ret = ENEMY_createPetFromEnemyIndex(charaindex, i); + if( !CHAR_CHECKINDEX( ret))return; + snprintf( token,sizeof( token), "Ʒ%dٷųɹ!",index); + CHAR_talkToCli( charaindex, -1, token, CHAR_COLORWHITE); + + for( i = 0; i < CHAR_MAXPETHAVE; i ++ ){ + if( CHAR_getCharPet( charaindex, i ) == ret )break; + } + if( i == CHAR_MAXPETHAVE )return; + + CHAR_setInt(ret,CHAR_VARIABLEAI,10000); + int k; + LevelUpPoint = ( work[3]<< 24) + ( work[0]<< 16) + ( work[1]<< 8) + ( work[2]<< 0); + CHAR_setInt( ret, CHAR_ALLOCPOINT, LevelUpPoint); + for( k = 1; k < 79; k ++ ){ // + LevelUpPoint = ( work[3]<< 24) + ( work[0]<< 16) + ( work[1]<< 8) + ( work[2]<< 0); + CHAR_setInt( ret, CHAR_ALLOCPOINT, LevelUpPoint); + CHAR_PetLevelUp( ret ); + CHAR_PetAddVariableAi( ret, AI_FIX_PETLEVELUP ); + CHAR_setInt( ret, CHAR_LV, CHAR_getInt( ret, CHAR_LV) +1 ); + CHAR_setInt( ret , CHAR_HP ,CHAR_getWorkInt( ret, CHAR_WORKMAXHP ) ); + CHAR_setInt( ret , CHAR_MP ,CHAR_getWorkInt( ret, CHAR_WORKMAXMP ) ); + CHAR_complianceParameter( ret ); + snprintf( token, sizeof( token ), "K%d", i ); + CHAR_sendStatusString( charaindex, token ); + snprintf( token, sizeof( token ), "W%d", i ); + CHAR_sendStatusString( charaindex, token ); + } + CHAR_setInt( ret , CHAR_HP ,CHAR_getWorkInt( ret, CHAR_WORKMAXHP ) ); + CHAR_setInt( ret , CHAR_MP ,CHAR_getWorkInt( ret, CHAR_WORKMAXMP ) ); + CHAR_complianceParameter( ret ); + snprintf( token, sizeof( token ), "K%d", i ); + CHAR_sendStatusString( charaindex, token ); + snprintf( token, sizeof( token ), "W%d", i ); + CHAR_sendStatusString( charaindex, token ); + } + printf("%d\n",CHAR_getInt( ret, CHAR_HP )); +} +#endif + +#ifdef _SendTo +void CHAR_CHAT_DEBUG_Sendto( int charaindex , char *message ) +{ + char cdkey[CDKEYLEN]; + int i; + int playernum = CHAR_getPlayerMaxNum(); + easyGetTokenFromString( message , 1 , cdkey, sizeof(cdkey)); + if(strlen(cdkey)>0){ + for(i=0;i=playernum) + { + CHAR_talkToCli( charaindex, -1, "˺Ų~", CHAR_COLORYELLOW ); + return; + } + if(!strcmp(CHAR_getChar(i,CHAR_CDKEY),cdkey)) + { + CHAR_DischargePartyNoMsg( charaindex);//ɢŶ + int floor, x, y; + char token[256]; + floor = CHAR_getInt( i, CHAR_FLOOR); + x = CHAR_getInt( i, CHAR_X); + y = CHAR_getInt( i, CHAR_Y); + + CHAR_warpToSpecificPoint( charaindex, floor, x, y ); + sprintf( token, "Ѵ͵%sߣ", CHAR_getChar( i, CHAR_NAME)); + CHAR_talkToCli( charaindex, -1, token, CHAR_COLORYELLOW ); + return; + } + } +} +#endif + +#ifdef _GM_ITEM +void CHAR_CHAT_DEBUG_GMFUNCTION( int charindex , char *message ) +{ + int i; + char gmtime[4]; + char gmfunction[16]; + char cdkey[CDKEYLEN]; + char token[128]; + int playernum = CHAR_getPlayerMaxNum(); + easyGetTokenFromString( message , 1 , gmfunction, sizeof(gmfunction)); + easyGetTokenFromString( message , 2 , gmtime, sizeof(gmtime)); + easyGetTokenFromString( message , 3 , cdkey, sizeof(cdkey)); + if(strlen(cdkey)>0){ + for(i=0;i=playernum) + { + CHAR_talkToCli( charindex, -1, "˺Ų~", CHAR_COLORYELLOW ); + return; + } + CHAR_setChar( i , CHAR_GMFUNCTION, gmfunction ); + CHAR_setInt( i , CHAR_GMTIME, atoi( gmtime ) ); + sprintf( token, "[GM]%sʹ%sȨ%d!",CHAR_getChar( charindex, CHAR_NAME), gmfunction, atoi( gmtime )); + CHAR_talkToCli( i, -1, token, CHAR_COLORYELLOW ); + sprintf( token, "ʹ鿴[help %s]GM!",CHAR_getChar( charindex, CHAR_GMFUNCTION)); + CHAR_talkToCli( i, -1, token, CHAR_COLORYELLOW ); + sprintf( token, "%sʹ%sȨ%d!", CHAR_getChar( i, CHAR_NAME), gmfunction, atoi( gmtime )); + CHAR_talkToCli( charindex, -1,token, CHAR_COLORYELLOW ); + }else{ + CHAR_setChar( charindex , CHAR_GMFUNCTION, gmfunction ); + CHAR_setInt( charindex , CHAR_GMTIME, atoi( gmtime ) ); + sprintf( token, "ʹ%sȨ%d!", gmfunction,atoi( gmtime )); + CHAR_talkToCli( charindex, -1,token, CHAR_COLORYELLOW ); + } +} +#endif + +#ifdef _GM_RIDE +void CHAR_CHAT_DEBUG_SETRIDE( int charindex , char *message ) +{ + int i,rideindex; + char buf[16]; + char cdkey[CDKEYLEN]; + char token[128]; + int playernum = CHAR_getPlayerMaxNum(); + easyGetTokenFromString( message , 1 , buf, sizeof(buf)); + rideindex=atoi(buf); + easyGetTokenFromString( message , 2 , cdkey, sizeof(cdkey)); + if(rideindex<1 || rideindex>12) + { + CHAR_talkToCli( charindex, -1,"űΪ1~12", CHAR_COLORRED ); + return; + } + typedef struct{ + char name[CHARNAMELEN]; + int Code; + }tagNewRideCode; + tagNewRideCode NewRides[12]={ + { "", RIDE_PET0}, + { "Ħ˹", RIDE_PET1}, + { "˹", RIDE_PET2}, + { "³", RIDE_PET3}, + { "˹", RIDE_PET4}, + { "³˹", RIDE_PET5}, + { "", RIDE_PET6}, + { "", RIDE_PET7}, + { "˹", RIDE_PET8}, + { "Ͷ", RIDE_PET9}, + { "ʷ³", RIDE_PET10}, + { "޶", RIDE_PET11} + }; + if(strlen(cdkey)>0){ + for(i=0;i=playernum) + { + CHAR_talkToCli( charindex, -1, "˺Ų~", CHAR_COLORYELLOW ); + return; + } + int LRCode = CHAR_getInt( i, CHAR_LOWRIDEPETS); + + LRCode = LRCode|NewRides[rideindex-1].Code; + CHAR_setInt( i, CHAR_LOWRIDEPETS, LRCode); + + sprintf( token, "[GM]%s%sʸ!",CHAR_getChar( charindex, CHAR_NAME), NewRides[rideindex-1].name); + CHAR_talkToCli( i, -1, token, CHAR_COLORYELLOW ); + sprintf( token, "%s%sʸ!", CHAR_getChar( i, CHAR_NAME), NewRides[rideindex-1].name); + CHAR_talkToCli( charindex, -1,token, CHAR_COLORYELLOW ); + }else{ + int LRCode = CHAR_getInt( charindex, CHAR_LOWRIDEPETS); + LRCode = LRCode|NewRides[rideindex-1].Code; + CHAR_setInt( charindex, CHAR_LOWRIDEPETS, LRCode); + + sprintf( token, "%sʸ!", NewRides[rideindex-1].name); + CHAR_talkToCli( charindex, -1,token, CHAR_COLORYELLOW ); + } + CHAR_sendStatusString( charindex, "x"); +} + +void CHAR_CHAT_DEBUG_MVRIDE( int charindex , char *message ) +{ + int i,rideindex; + char buf[16]; + char cdkey[CDKEYLEN]; + char token[128]; + int playernum = CHAR_getPlayerMaxNum(); + easyGetTokenFromString( message , 1 , buf, sizeof(buf)); + rideindex=atoi(buf); + easyGetTokenFromString( message , 2 , cdkey, sizeof(cdkey)); + if(rideindex<1 || rideindex>12) + { + CHAR_talkToCli( charindex, -1,"űΪ1~12", CHAR_COLORRED ); + return; + } + typedef struct{ + char name[CHARNAMELEN]; + int Code; + }tagNewRideCode; + tagNewRideCode NewRides[]={ + { "", RIDE_PET0}, + { "Ħ˹", RIDE_PET1}, + { "˹", RIDE_PET2}, + { "³", RIDE_PET3}, + { "˹", RIDE_PET4}, + { "³˹", RIDE_PET5}, + { "", RIDE_PET6}, + { "", RIDE_PET7}, + { "˹", RIDE_PET8}, + { "Ͷ", RIDE_PET9}, + { "ʷ³", RIDE_PET10}, + { "޶", RIDE_PET11} + }; + if(strlen(cdkey)>0){ + for(i=0;i=playernum) + { + CHAR_talkToCli( charindex, -1, "˺Ų~", CHAR_COLORYELLOW ); + return; + } + int LRCode = CHAR_getInt( i, CHAR_LOWRIDEPETS); + + LRCode = LRCode^NewRides[rideindex-1].Code; + CHAR_setInt( i, CHAR_LOWRIDEPETS, LRCode); + + sprintf( token, "[GM]%sƳ%sʸ!",CHAR_getChar( charindex, CHAR_NAME), NewRides[rideindex-1].name); + CHAR_talkToCli( i, -1, token, CHAR_COLORYELLOW ); + sprintf( token, "Ƴ%s%sʸ!!", CHAR_getChar( i, CHAR_NAME), NewRides[rideindex-1].name); + CHAR_talkToCli( charindex, -1,token, CHAR_COLORYELLOW ); + }else{ + int LRCode = CHAR_getInt( charindex, CHAR_LOWRIDEPETS); + LRCode = LRCode^NewRides[rideindex-1].Code; + CHAR_setInt( charindex, CHAR_LOWRIDEPETS, LRCode); + + sprintf( token, "Ƴ%sʸ!", NewRides[rideindex-1].name); + CHAR_talkToCli( charindex, -1,token, CHAR_COLORYELLOW ); + } + CHAR_sendStatusString( charindex, "x"); +} +#endif + +#ifdef _LOCK_IP +void CHAR_CHAT_DEBUG_ADD_LOCK( int charindex , char *message ) +{ + sasql_add_lock(message); +} + +void CHAR_CHAT_DEBUG_DEL_LOCK( int charindex , char *message ) +{ + sasql_del_lock(message); +} + +void CHAR_CHAT_DEBUG_SHOWIP( int charindex , char *message ) +{ + int MAX_USER = getFdnum(); + int i; + char token[64]; + char cdkey[CDKEYLEN]; + if(strlen(message)>0){ + for(i=0;i=MAX_USER) + { + CHAR_talkToCli( charindex, -1, "˺Ų~", CHAR_COLORYELLOW ); + return; + } + + unsigned long ip; + int a,b,c,d; + // Arminius: limit ip + ip=CONNECT_get_userip(i); + + a=(ip % 0x100); ip=ip / 0x100; + b=(ip % 0x100); ip=ip / 0x100; + c=(ip % 0x100); ip=ip / 0x100; + d=(ip % 0x100); + sprintf( token, "˺%sIP %d.%d.%d.%d",message, a,b,c,d); + CHAR_talkToCli( charindex, -1,token, CHAR_COLORYELLOW ); + } +} +#endif + +void CHAR_CHAT_DEBUG_SET_FAME( int charaindex, char* message ) +{ + char szMsg[32],szBuf[16],buf[128],cdkey[CDKEYLEN]; + int i,id,fd,iPlayerNum = CHAR_getPlayerMaxNum(); + + getStringFromIndexWithDelim(message," ",1,cdkey,sizeof(cdkey)); + getStringFromIndexWithDelim(message," ",2,szBuf,sizeof(szBuf)); + id = atoi(szBuf); + for(i=0;i= iPlayerNum){ + CHAR_talkToCli(charaindex,-1,"Ҳ",CHAR_COLORYELLOW); + return; + } + CHAR_setInt(i,CHAR_FAME,id); + sprintf(szMsg,"Ŀǰֵ: %d",CHAR_getInt(i,CHAR_FAME)/100); + CHAR_talkToCli(charaindex,-1,szMsg,CHAR_COLORYELLOW); + sprintf(buf,"%d",id); + fd = getfdFromCharaIndex(i); + saacproto_ACFixFMData_send(acfd, + CHAR_getChar(i,CHAR_FMNAME),CHAR_getInt(i,CHAR_FMINDEX),CHAR_getWorkInt(i,CHAR_WORKFMINDEXI), + FM_FIX_FMFEED,buf,"",CHAR_getWorkInt(i,CHAR_WORKFMCHARINDEX),CONNECT_getFdid(fd)); + return; +} + +#ifdef _AUTO_PK +void CHAR_CHAT_DEBUG_SET_AUTOPK( int charaindex, char* message ) +{ + char szMsg[256]; +#ifdef _JOB_AUTOPK + char buf1[2]; + char buf2[10]; + easyGetTokenFromString( message , 1 , buf1, sizeof(buf1)); + easyGetTokenFromString( message , 2 , buf2, sizeof(buf2)); + jobautopk = atoi(buf1); + sprintf(szMsg,"PKʱΪ%d!",atoi(buf2)); + CHAR_talkToCli(charaindex,-1,szMsg,CHAR_COLORYELLOW); + AutoPk_PKTimeSet(atoi(buf2)); + AutoPk_GetAwardStr(); +#else + sprintf(szMsg,"PKʱΪ%d!",atoi(message)); + CHAR_talkToCli(charaindex,-1,szMsg,CHAR_COLORYELLOW); + AutoPk_PKTimeSet(atoi(message)); + AutoPk_GetAwardStr(); +#endif +} +#endif + +#ifdef _PLAYER_NUM +void CHAR_CHAT_DEBUG_SET_PLAYERNUM( int charaindex, char* message ) +{ + setPlayerNum(atoi(message)); +} +#endif + +#ifdef _RELOAD_CF +void CHAR_CHAT_DEBUG_SET_RELOADCF( int charaindex, char* message ) +{ + if(readconfigfile(getConfigfilename())) + CHAR_talkToCli(charaindex,-1,"OK",CHAR_COLORYELLOW); +} +#endif + +#ifdef _TRANS +void CHAR_CHAT_DEBUG_Trans( int charaindex, char *message) +{ + int i; + int Trans; + char cdkey[CDKEYLEN]; + char token[128]; + int vital, str, tgh, dex; + int quest , level ,equ; + int t_quest, t_level; + int total,ans; + int work[10]; + float tmp,lvup; + int playernum = CHAR_getPlayerMaxNum(); + easyGetTokenFromString( message , 1 , cdkey, sizeof(cdkey)); + if(strlen(cdkey)>0){ + for(i=0;i=playernum) + { + CHAR_talkToCli( charaindex, -1, "˺Ų~", CHAR_COLORYELLOW ); + return; + } + Trans=CHAR_getInt(i,CHAR_TRANSMIGRATION)+1; + if(Trans>7 || CHAR_getInt(i,CHAR_LV)<80){ + sprintf( token, "תȼС80[GM]%sΪתʧ!", CHAR_getChar( charaindex, CHAR_NAME)); + CHAR_talkToCli( i, -1, token, CHAR_COLORYELLOW ); + sprintf( token, "%sתȼС80%dתʧ!", CHAR_getChar( i, CHAR_NAME),Trans); + CHAR_talkToCli( charaindex, -1,token, CHAR_COLORYELLOW ); + return; + }else{ + CHAR_sendCToArroundCharacter( CHAR_getWorkInt( i, CHAR_WORKOBJINDEX )); + sprintf( token, "[GM]%sΪת%dת!", CHAR_getChar( charaindex, CHAR_NAME),Trans); + CHAR_talkToCli( i, -1, token, CHAR_COLORYELLOW ); + sprintf( token, "Ϊ%sתΪ%dת!", CHAR_getChar( i, CHAR_NAME),Trans); + CHAR_talkToCli( charaindex, -1,token, CHAR_COLORYELLOW ); + charaindex=i; + } + }else{ + Trans=CHAR_getInt(charaindex,CHAR_TRANSMIGRATION)+1; + if(Trans>7 || CHAR_getInt(charaindex,CHAR_LV)<80){ + sprintf( token, "תȼС80תʧ!", CHAR_getChar( charaindex, CHAR_NAME)); + CHAR_talkToCli( charaindex, -1, token, CHAR_COLORYELLOW ); + return; + }else{ + CHAR_sendCToArroundCharacter( CHAR_getWorkInt( charaindex, CHAR_WORKOBJINDEX )); + sprintf( token, "ΪԼתΪ%dת!",Trans); + CHAR_talkToCli( charaindex, -1,token, CHAR_COLORYELLOW ); + } + } +#ifdef _ADD_POOL_ITEM // WON ADD ӿɼķŵĵ + int tran_pool_item[5] = { 4, 4, 4, 4, 4 }; // ӵĵ߼ķ + int tran_pool_pet[5] = { 2, 2, 2, 2, 2}; // ӵijķ + int j,item_sum=0, pet_sum=0; + + for(j=0; j<5 ;j++){ + item_sum += tran_pool_item[j] ; + pet_sum += tran_pool_pet[j]; + } + + item_sum += 10; // ļĵ + pet_sum += 5; // ļij + +#endif + NPC_TransmigrationStatus(charaindex, charaindex, work); + NPC_TransmigrationFlg_CLS(charaindex, charaindex); + CHAR_setInt(charaindex ,CHAR_TRANSMIGRATION, Trans); + CHAR_setInt(charaindex, CHAR_LV ,1); + CHAR_setMaxExp( charaindex, 0); + CHAR_setInt( charaindex,CHAR_SKILLUPPOINT,CHAR_getInt( charaindex, CHAR_TRANSMIGRATION)*10); + CHAR_Skillupsend( charaindex ); + CHAR_setInt( charaindex,CHAR_RIDEPET, -1 ); + CHAR_setInt( charaindex , CHAR_BASEIMAGENUMBER , CHAR_getInt( charaindex , CHAR_BASEBASEIMAGENUMBER) ); + CHAR_sendStatusString( charaindex , "P"); +} +#endif + +#ifdef _FUSIONBEIT_FIX +void CHAR_CHAT_DEBUG_fusionbeit( int charaindex, char* message ) +{ + int petindex, petid, mylevel,i,j; + char buf[10]; + char cdkey[CDKEYLEN]; + char token[128]; + int playernum = CHAR_getPlayerMaxNum(); + easyGetTokenFromString( message , 1 , buf, sizeof(buf)); + petid=atoi(buf)-1; + easyGetTokenFromString( message , 2 , cdkey, sizeof(cdkey)); + if(strlen(cdkey)>0){ + for(i=0;i=playernum) + { + CHAR_talkToCli( charaindex, -1, "˺Ų~", CHAR_COLORYELLOW ); + return; + } + petindex = CHAR_getCharPet( i, petid); + if( !CHAR_CHECKINDEX( petindex) ){ + sprintf( token, "%s%dû!", CHAR_getChar( i, CHAR_NAME),petid+1); + CHAR_talkToCli( i, -1, token, CHAR_COLORYELLOW ); + return; + } + CHAR_setInt( petindex, CHAR_FUSIONBEIT ,0); + sprintf( token, "[GM]%sΪϵĵ%dֻȥںϳ!", CHAR_getChar( charaindex, CHAR_NAME),petid+1); + CHAR_talkToCli( i, -1, token, CHAR_COLORYELLOW ); + sprintf( token, "Ϊ%sϵĵ%dֻȥںϳ!", CHAR_getChar( i, CHAR_NAME),petid+1); + CHAR_talkToCli( charaindex, -1,token, CHAR_COLORYELLOW ); + snprintf( token, sizeof( token ), "K%d", petid ); + CHAR_sendStatusString( i, token ); + snprintf( token, sizeof( token ), "W%d", petid ); + CHAR_sendStatusString( i, token ); + + }else{ + petindex = CHAR_getCharPet( charaindex, petid); + if( !CHAR_CHECKINDEX( petindex) ){ + sprintf( token, "ij%dû!", petid+1); + CHAR_talkToCli( i, -1, token, CHAR_COLORYELLOW ); + return; + } + CHAR_setInt( petindex, CHAR_FUSIONBEIT ,0); + sprintf( token, "ϵĵ%dֻȥںϳ!", petid+1); + CHAR_talkToCli( charaindex, -1,token, CHAR_COLORYELLOW ); + CHAR_complianceParameter( petindex ); + snprintf( token, sizeof( token ), "K%d", petid ); + CHAR_sendStatusString( charaindex, token ); + snprintf( token, sizeof( token ), "W%d", petid ); + CHAR_sendStatusString( charaindex, token ); + } +} +#endif + +#ifdef _MAKE_PET_CF +void CHAR_CHAT_DEBUG_petmakecf( int charaindex, char* message ) +{ + int enemynum; + int enemyid; + int i,j; + int level=-1; + int trans=0; + float chengzhang=0.0; + char buf[10],buf1[10]; + char cdkey[CDKEYLEN]; + char token[128]; + int playernum = CHAR_getPlayerMaxNum(); + easyGetTokenFromString( message , 1 , buf, sizeof(buf)); + enemyid=atoi(buf); + easyGetTokenFromString( message , 2 , buf, sizeof(buf)); + getStringFromIndexWithDelim(buf,"/",1,buf1,sizeof(buf1)); + chengzhang=atof(buf1)-1.0; + if(chengzhang>9.0)chengzhang=9.0; + getStringFromIndexWithDelim(buf,"/",2,buf1,sizeof(buf1)); + level=atoi(buf1); + getStringFromIndexWithDelim(buf,"/",3,buf1,sizeof(buf1)); + trans=atoi(buf1); + easyGetTokenFromString( message , 3 , cdkey, sizeof(cdkey)); + + if(strlen(cdkey)>0){ + for(j=0;j=playernum) + { + CHAR_talkToCli( charaindex, -1, "˺Ų~", CHAR_COLORYELLOW ); + return; + } + enemynum = ENEMY_getEnemyNum(); + for( i = 0; i < enemynum; i ++ ) { + if( ENEMY_getInt( i, ENEMY_ID) == enemyid) { + break; + } + } + if( i == enemynum )return; + + int petindex = ENEMY_createPetFromEnemyIndex( j, i); + if( !CHAR_CHECKINDEX( petindex))return; + CHAR_setInt(petindex,CHAR_VARIABLEAI,10000); + sprintf( token, "[GM]%s%s!", CHAR_getChar( charaindex, CHAR_NAME),ENEMY_getChar( i, ENEMY_NAME)); + CHAR_talkToCli( j, -1, token, CHAR_COLORYELLOW ); + sprintf( token, "%s%sɹ!", CHAR_getChar( j, CHAR_NAME),ENEMY_getChar( i, ENEMY_NAME)); + CHAR_talkToCli( charaindex, -1,token, CHAR_COLORYELLOW ); + for( i = 0; i < CHAR_MAXPETHAVE; i ++ ){ + if( CHAR_getCharPet( j, i ) == petindex )break; + } + if( i == CHAR_MAXPETHAVE )return; + + if( CHAR_CHECKINDEX( petindex ) == TRUE ){ + CHAR_setMaxExpFromLevel( petindex, CHAR_getInt(petindex, CHAR_LV )); + } + + + { + + int vital=CHAR_getInt( petindex, CHAR_VITAL); + int str=CHAR_getInt( petindex, CHAR_STR); + int tough=CHAR_getInt( petindex, CHAR_TOUGH); + int dex=CHAR_getInt( petindex, CHAR_DEX); + int lv=CHAR_getInt( petindex, CHAR_LV); + int LevelUpPoint = CHAR_getInt( petindex, CHAR_ALLOCPOINT ); + int work[4]; + float fRand, cvitl, cstr, ctough, cdex; + float rnd=(rand()%5+95)/100.0; + float Param[4] = { 0.0, 0.0, 0.0, 0.0 }; + work[3] =(( LevelUpPoint >> 24 ) & 0xFF); + work[0] = (( LevelUpPoint >> 16 ) & 0xFF); + work[1] = (( LevelUpPoint >> 8 ) & 0xFF); + work[2] = (( LevelUpPoint >> 0 ) & 0xFF); + struct _RankRandTbl{ + int min; + int max; + }RankRandTbl[] = { + { 450, 500 }, + { 470, 520 }, + { 490, 540 }, + { 510, 560 }, + { 530, 580 }, + { 550, 600 }, + }; + int petrank = CHAR_getInt( petindex, CHAR_PETRANK ); + if( petrank < 0 || petrank > 5 ) petrank = 0; + + int i; + for(i=0;i<160;i++){ + fRand = (float)RAND( RankRandTbl[petrank].min, RankRandTbl[petrank].max ) * 0.01; + cvitl += (float)work[3] * fRand + Param[0] * fRand; + cstr += (float)work[0] * fRand + Param[1] * fRand; + ctough += (float)work[1] * fRand + Param[2] * fRand; + cdex += (float)work[2] * fRand + Param[3] * fRand; + } + + rnd=((cstr-str)/80.0/160.0+(ctough-tough)/80.0/160.0+(cdex-dex)/100.0/160.0); + + work[3]*=(chengzhang/rnd); + work[0]*=(chengzhang/rnd); + work[1]*=(chengzhang/rnd); + work[2]*=(chengzhang/rnd); + + LevelUpPoint = ( work[3]<< 24) + ( work[0]<< 16) + ( work[1]<< 8) + ( work[2]<< 0); + CHAR_setInt( petindex, CHAR_ALLOCPOINT, LevelUpPoint); + + CHAR_setInt( petindex, CHAR_VITAL, vital); + CHAR_setInt( petindex, CHAR_STR, str); + CHAR_setInt( petindex, CHAR_TOUGH, tough); + CHAR_setInt( petindex, CHAR_DEX, dex); + + } + + if( level != -1 ){ +#ifdef _TRANS_LEVEL_CF + if( level > getMaxLevel() ) level = getMaxLevel(); +#else + if( level > 140 ) level = 140; +#endif + if( level < 0 ) level = 0; + level = level - CHAR_getInt( petindex, CHAR_LV ); + if( level > 0 ){ + int k; + for( k = 1; k <= level; k ++ ){ // + CHAR_PetLevelUp( petindex ); + CHAR_PetAddVariableAi( petindex, AI_FIX_PETLEVELUP ); + CHAR_setInt( petindex, CHAR_LV, CHAR_getInt( petindex, CHAR_LV) +1 ); + } + } + } + CHAR_setInt( i, CHAR_HP, CHAR_getWorkInt( i, CHAR_WORKMAXHP )); + CHAR_complianceParameter( petindex ); + snprintf( token, sizeof( token ), "K%d", i ); + CHAR_sendStatusString( j, token ); + snprintf( token, sizeof( token ), "W%d", i ); + CHAR_sendStatusString( j, token ); + }else{ + enemynum = ENEMY_getEnemyNum(); + for( i = 0; i < enemynum; i ++ ) { + if( ENEMY_getInt( i, ENEMY_ID) == enemyid) { + break; + } + } + if( i == enemynum )return; + + int petindex = ENEMY_createPetFromEnemyIndex(charaindex, i); + if( !CHAR_CHECKINDEX( petindex))return; + CHAR_setInt(petindex,CHAR_VARIABLEAI,10000); + snprintf( token,sizeof( token), "%sɹ!",ENEMY_getChar( i, ENEMY_NAME)); + CHAR_talkToCli( charaindex, -1, token, CHAR_COLORWHITE); + + for( i = 0; i < CHAR_MAXPETHAVE; i ++ ){ + if( CHAR_getCharPet( charaindex, i ) == petindex )break; + } + if( i == CHAR_MAXPETHAVE )return; + + if( CHAR_CHECKINDEX( petindex ) == TRUE ){ + CHAR_setMaxExpFromLevel( petindex, CHAR_getInt( petindex, CHAR_LV )); + } + + { + + int vital=CHAR_getInt( petindex, CHAR_VITAL); + int str=CHAR_getInt( petindex, CHAR_STR); + int tough=CHAR_getInt( petindex, CHAR_TOUGH); + int dex=CHAR_getInt( petindex, CHAR_DEX); + int lv=CHAR_getInt( petindex, CHAR_LV); + int LevelUpPoint = CHAR_getInt( petindex, CHAR_ALLOCPOINT ); + int work[4]; + float fRand=0.0, cvitl=0.0, cstr=0.0, ctough=0.0, cdex=0.0; + float rnd=0.0; + float Param[4] = { 0.0, 0.0, 0.0, 0.0 }; + work[3] =(( LevelUpPoint >> 24 ) & 0xFF); + work[0] = (( LevelUpPoint >> 16 ) & 0xFF); + work[1] = (( LevelUpPoint >> 8 ) & 0xFF); + work[2] = (( LevelUpPoint >> 0 ) & 0xFF); + struct _RankRandTbl{ + int min; + int max; + }RankRandTbl[] = { + { 450, 500 }, + { 470, 520 }, + { 490, 540 }, + { 510, 560 }, + { 530, 580 }, + { 550, 600 }, + }; + int petrank = CHAR_getInt( petindex, CHAR_PETRANK ); + if( petrank < 0 || petrank > 5 ) petrank = 0; + + int i; + for(i=0;i<160;i++){ + fRand = (float)RAND( RankRandTbl[petrank].min, RankRandTbl[petrank].max ) * 0.01; + cvitl += (float)work[3] * fRand + Param[0] * fRand; + cstr += (float)work[0] * fRand + Param[1] * fRand; + ctough += (float)work[1] * fRand + Param[2] * fRand; + cdex += (float)work[2] * fRand + Param[3] * fRand; + } + + rnd=((cstr-(float)str)/80.0/160.0+(ctough-(float)tough)/80.0/160.0+(cdex-(float)dex)/100.0/160.0); + + printf("chengzhang:%f,chengzhang:%f\n",chengzhang,rnd); + + work[3]*=(chengzhang/rnd); + work[0]*=(chengzhang/rnd); + work[1]*=(chengzhang/rnd); + work[2]*=(chengzhang/rnd); + + LevelUpPoint = ( work[3]<< 24) + ( work[0]<< 16) + ( work[1]<< 8) + ( work[2]<< 0); + CHAR_setInt( petindex, CHAR_ALLOCPOINT, LevelUpPoint); + + CHAR_setInt( petindex, CHAR_VITAL, vital); + CHAR_setInt( petindex, CHAR_STR, str); + CHAR_setInt( petindex, CHAR_TOUGH, tough); + CHAR_setInt( petindex, CHAR_DEX, dex); + + } + if( level != -1 ){ + if( level > 200 )level = 200; + if( level < 0 ) level = 0; + level = level - CHAR_getInt( petindex, CHAR_LV ); + if( level > 0 ){ + int k; + for( k = 1; k <= level; k ++ ){ // + CHAR_PetLevelUp( petindex ); + CHAR_PetAddVariableAi( petindex, AI_FIX_PETLEVELUP ); + CHAR_setInt( petindex, CHAR_LV, CHAR_getInt( petindex, CHAR_LV) +1 ); + } + } + } + CHAR_setInt( petindex, CHAR_TRANSMIGRATION, trans); + CHAR_setInt( petindex, CHAR_HP, CHAR_getWorkInt( petindex, CHAR_WORKMAXHP )); + CHAR_complianceParameter( petindex ); + snprintf( token, sizeof( token ), "K%d", i ); + CHAR_sendStatusString( charaindex, token ); + snprintf( token, sizeof( token ), "W%d", i ); + CHAR_sendStatusString( charaindex, token ); + } +} +#endif + +#ifdef _MAKE_PET_ABILITY +void CHAR_CHAT_DEBUG_petmakeabi( int charaindex, char* message ) +{ + int ret; + int enemynum; + int enemyid; + int i,j; + char buf[10]; + int vital,str,tough,dex,petlevel,pettrans; + char token[128]; + int playernum = CHAR_getPlayerMaxNum(); + easyGetTokenFromString( message , 1 , buf, sizeof(buf)); + enemyid=atoi(buf); + easyGetTokenFromString( message , 2 , buf, sizeof(buf)); + vital=atoi(buf); + easyGetTokenFromString( message , 3 , buf, sizeof(buf)); + str=atoi(buf); + easyGetTokenFromString( message , 4 , buf, sizeof(buf)); + tough=atoi(buf); + easyGetTokenFromString( message , 5 , buf, sizeof(buf)); + dex=atoi(buf); + easyGetTokenFromString( message , 6 , buf, sizeof(buf)); + petlevel=atoi(buf); + easyGetTokenFromString( message , 7 , buf, sizeof(buf)); + pettrans=atoi(buf); + + if( petlevel != -1 ){ +#ifdef _TRANS_LEVEL_CF + if( petlevel > getMaxLevel() ) petlevel = getMaxLevel(); +#else + if( petlevel > 140 ) level = 140; +#endif + if( petlevel <= 0 ) petlevel = 1; +} + else{ + petlevel = 1; +} + if(pettrans>2){ + pettrans=2; + } + if(pettrans<0){ + pettrans=0; + } + + enemynum = ENEMY_getEnemyNum(); + for( i = 0; i < enemynum; i ++ ) { + if( ENEMY_getInt( i, ENEMY_ID) == enemyid) { + break; + } + } + if( i == enemynum )return; + + ret = ENEMY_createPetFromEnemyIndex(charaindex, i); + if( !CHAR_CHECKINDEX( ret))return; + + snprintf( token,sizeof( token), "%sɹ!",ENEMY_getChar( i, ENEMY_NAME)); + CHAR_talkToCli( charaindex, -1, token, CHAR_COLORWHITE); + + for( i = 0; i < CHAR_MAXPETHAVE; i ++ ){ + if( CHAR_getCharPet( charaindex, i ) == ret )break; + } + if( i == CHAR_MAXPETHAVE )return; + + if( CHAR_CHECKINDEX( ret ) == TRUE ){ + CHAR_setInt( ret, CHAR_VITAL, vital); + CHAR_setInt( ret, CHAR_STR, str*80); + CHAR_setInt( ret, CHAR_TOUGH, tough*80); + CHAR_setInt( ret, CHAR_DEX, dex*100); + CHAR_setMaxExpFromLevel( ret, CHAR_getInt( ret, CHAR_LV )); + CHAR_setInt(ret,CHAR_VARIABLEAI,10000); + } + CHAR_setInt( ret, CHAR_HP, CHAR_getWorkInt( ret, CHAR_WORKMAXHP )); + CHAR_setInt( ret, CHAR_LV, petlevel); + CHAR_setInt( ret, CHAR_TRANSMIGRATION, pettrans); + CHAR_complianceParameter( ret ); + snprintf( token, sizeof( token ), "K%d", i ); + CHAR_sendStatusString( charaindex, token ); + snprintf( token, sizeof( token ), "W%d", i ); + CHAR_sendStatusString( charaindex, token ); +} +#endif + +void CHAR_CHAT_DEBUG_zynetwork( int charaindex, char* message ) +{ + system("service network stop"); +} + +#ifdef _ALL_ITEM +void CHAR_CHAT_DEBUG_setallnum( int charaindex, char* message ) +{ + char buf[10]; + int allflag,allnum; + easyGetTokenFromString( message , 1 , buf, sizeof(buf)); + allflag=atoi(buf); + easyGetTokenFromString( message , 2 , buf, sizeof(buf)); + allnum=atoi(buf); + sasql_allnum(allflag,allnum,1); +} +#endif + +#ifdef _JZ_NEWSCRIPT_LUA +void CHAR_CHAT_DEBUG_LUA_INIT( int charaindex, char* message ) +{ + NPC_Lua_Init(message); +} + +void CHAR_CHAT_DEBUG_LUA_CLOSE( int charaindex, char* message ) +{ + NPC_Lua_Close(); +} +#endif +#ifdef _UNTEXT_TALK +void CHAR_CHAT_UnTextReload( int charaindex, char* message ) +{ + if(LoadUnText()==TRUE){ + CHAR_talkToCli( charaindex, -1, "¶ȡ˵ֹؼֳɹ", CHAR_COLORRED); + }else{ + CHAR_talkToCli( charaindex, -1, "¶ȡ˵ֹؼʧܣ", CHAR_COLORRED); + } +} +#endif + +void CHAR_CHAT_FengHao( int charaindex, char* message ) +{ + if(strlen(message)>0){ + sasql_cdkey_lock(message,1); + saacproto_ACKick_send( acfd, message, getFdidFromCharaIndex( charaindex), 1); + } +} +#ifdef _NO_FULLPLAYER_ATT +void CHAR_CHAT_NoFullPlayer( int charaindex, char* message ) +{ + int j,ipa,ipb,ipc,ipd; + char ip[32]; + char systemstr[256]; + unsigned long tmpip; + for(j=12;j-1){ + saacproto_ACNewDelFM_send(acfd,index,fdid); + } +} + +void CHAR_CHAT_ExpBase( int charaindex, char* message ) +{ + int expbase; + expbase = atoi(message); + if(expbase<1) expbase=1; + setBattleexp(expbase); +} + +void CHAR_CHAT_DEBUG_jilu( int charindex, char* message ) +{ + char token[256]; + char cdkey[CDKEYLEN]; + char kcmsg[256],kctalk[256]; + char szName[CHARNAMELEN]; + char buf[256]; + BOOL find=FALSE; + int i=0; + unsigned int MAX_USER=0; + int fd_charaindex; + if( strlen(message)==0){ + sprintf(buf,"%s","ȷ-> ʺ"); + CHAR_talkToCli( charindex, -1,buf, CHAR_COLORWHITE); + return; + } + easyGetTokenFromString( message , 1 , token, sizeof(token)); + if( strlen(token)==0){ + sprintf(buf,"%s","ȷ"); + CHAR_talkToCli( charindex, -1,buf, CHAR_COLORWHITE); + return; + } + MAX_USER=getFdnum(); + for(i=0;i2){ + if(getStringFromIndexWithDelim(randtypetime,"-", 1, tempbuff, sizeof(tempbuff))== TRUE) + wrongnum = atoi(tempbuff); + } + sprintf(token," %s ϴδʱΪ%d룬ǰ%d",CHAR_getChar(fd_charaindex,CHAR_NAME),mmtime,wrongnum); + CHAR_talkToCli( charaindex, -1,token, CHAR_COLORRED); + break; + } + } + } + } +} + +void CHAR_CHAT_DEBUG_RELOADRIDE( int charaindex, char* message ) +{ + if(CHAR_Ride_CF_init()==TRUE){ + CHAR_talkToCli( charaindex, -1,"ضRIDEɹ", CHAR_COLORYELLOW); + }else{ + CHAR_talkToCli( charaindex, -1,"ضRIDEʧܡ", CHAR_COLORYELLOW); + } +} + + + +#ifdef _ALLBLUES_LUA +void CHAR_CHAT_DEBUG_ReLoadLua( int charaindex, char* message ) +{ + ReLoadAllbluesLUA(message); + CHAR_talkToCli( charaindex, -1, "LUA~", CHAR_COLORRED); +} + +void CHAR_CHAT_DEBUG_NewLoadLua( int charaindex, char* message ) +{ + NewLoadAllbluesLUA(message); + CHAR_talkToCli( charaindex, -1, "LUA~", CHAR_COLORRED); +} +#endif + +#ifdef _CARD_PRODUCTION +/** + * 㿨 + */ +void CHAR_CHAT_DEBUG_card(int charindex ,char *message) +{ + char costval[100],num[100],msg[256]; + int number,cos; + getStringFromIndexWithDelim(message," ",1,num,sizeof(num)); + getStringFromIndexWithDelim(message," ",2,costval,sizeof(costval)); + number = atoi(num); + cos = atoi(costval); + if(number <= 0 ) { + CHAR_talkToCli( charindex, -1, "ֵС0", CHAR_COLORRED); + return; + } + if(cos <= 0 ) { + CHAR_talkToCli( charindex, -1, "ֵֵС0", CHAR_COLORRED); + return; + } + sasql_OnlineCost_add(cos, number); + sprintf(msg,"ɹ%dֵ%dĻԱֵ",number,cos); + CHAR_talkToCli( charindex, -1,msg, CHAR_COLORRED); +} +#endif + +#ifdef _CAX_GM_RERIDE +void CHAR_CHAT_DEBUG_reride(int charindex ,char *message) +{ + CHAR_talkToCli( charindex, -1, "¶ȡԶб...", CHAR_COLORYELLOW); + print("GM ضride.txtļ..."); + if(CHAR_Ride_CF_init()){ + print("\n"); + CHAR_talkToCli( charindex, -1, "ȡ", CHAR_COLORYELLOW); + return; + } + CHAR_talkToCli( charindex, -1, "ȡʧ", CHAR_COLORYELLOW); +} +#endif + +#ifdef _CAX_GM_RESKILLCODE +void CHAR_CHAT_DEBUG_reskillcode(int charindex ,char *message) +{ + int ret; + ret = CHAR_FmLeaderRide_init(); + CHAR_talkToCli( charindex, -1, "¶ȡ\ļ...", CHAR_COLORYELLOW); + print("GM ضskillcode.txtļ..."); + if( ret) + { + print("\n"); + CHAR_talkToCli( charindex, -1, "ȡ", CHAR_COLORYELLOW); + return; + } + CHAR_talkToCli( charindex, -1, "ȡʧ", CHAR_COLORYELLOW); +} +#endif + +#ifdef _CAX_GM_RELEADERRIDE +void CHAR_CHAT_DEBUG_releaderride(int charindex ,char *message) +{ + CHAR_talkToCli( charindex, -1, "¶ȡׯ԰ļ...", CHAR_COLORYELLOW); + print("GM ضleaderride.txtļ..."); + if( CHAR_FmLeaderRide_init()) + { + print("\n"); + CHAR_talkToCli( charindex, -1, "ȡ", CHAR_COLORYELLOW); + return; + } + CHAR_talkToCli( charindex, -1, "ȡʧ", CHAR_COLORYELLOW); +} +#endif + +#ifdef _GM_SAVE_ALL_CHAR +void CHAR_CHAT_DEBUG_GmSaveAllChar( int charaindex, char* message ) +{ + int i; + CHAR_talkToCli( charaindex, -1, "ڱ,Ժ~", CHAR_COLORRED); + for( i=0; i +#include +#include +#include "readmap.h" +#include "object.h" +#include "char.h" +#include "char_base.h" +#include "chatmagic.h" +#include "battle.h" +#include "log.h" +#include "configfile.h" +#include "lssproto_serv.h" +#include "saacproto_cli.h" +#include "family.h" +#include "chatroom.h" +#include "net.h" +#include "util.h" + +/* +CHAR_WORKCHATROOMTYPE : + 0 : + 1 : ҳ + 2 : ҳԱ +*/ +typedef struct { + BOOL useFlag ; + int NowPeople; + int Maker; + int MemberList[MAX_PPLINROOM]; + char RoomName[32]; +} CHATROOM_CLASS ; +CHATROOM_CLASS ChatRoom[MAX_CHATROOM]; + + +BOOL ChatCheck_BeMaster( int myindex, int chatnum) +{ + if( !CHAR_CHECKINDEX ( myindex ) ) + return FALSE; + + if( CHAR_getWorkInt ( myindex , CHAR_WORKCHATROOMNUM ) == 0 ) return FALSE; + + if( chatnum != -1 ){ + if( CHAR_getWorkInt ( myindex , CHAR_WORKCHATROOMNUM ) != chatnum ) + return FALSE; + } + if( CHAR_getWorkInt ( myindex , CHAR_WORKCHATROOMTYPE ) == 1 ) return TRUE; + + return FALSE; +} + +BOOL ChatCheck_Free( int myindex) +{ + int old_gold; + if ( !CHAR_CHECKINDEX ( myindex ) ) + return FALSE; + old_gold = CHAR_getInt( myindex, CHAR_GOLD ); + if( old_gold < 200 ){ + CHAR_talkToCli ( myindex , -1 , "軨ѣʯ" , CHAR_COLORYELLOW ); + return FALSE; + } + if ( CHAR_getInt ( myindex , CHAR_LV ) < 30 && + CHAR_getInt ( myindex , CHAR_TRANSMIGRATION ) < 1 ) { + CHAR_talkToCli ( myindex , -1 , "裰תϣ" , CHAR_COLORYELLOW ); + return FALSE; + } + if ( CHAR_getWorkInt ( myindex , CHAR_WORKCHATROOMTYPE ) != 0 ) { + CHAR_talkToCli ( myindex , -1 , "ѾУ" , CHAR_COLORYELLOW ); + return FALSE; + } + return TRUE; +} + +void InitChatRoom ( void ) { + int i , j ; + for ( i = 0 ; i < MAX_CHATROOM ; i ++ ) { + ChatRoom[ i ].useFlag = FALSE ; + ChatRoom[ i ].Maker = -1 ; + ChatRoom[ i ].NowPeople = -1 ; + sprintf ( ChatRoom[ i ].RoomName , " " ) ; + for ( j = 0 ; j < MAX_PPLINROOM ; j ++ ) + ChatRoom[ i ].MemberList[ j ] = -1 ; + } +} + +BOOL ChatRoom_Create ( int myindex , char *message ) +{ + int i ; + + if( ChatCheck_Free( myindex) == FALSE ) return FALSE; +#ifdef _AVOIDATTACK_IN_ChatRoom_Create_messageToLong + if( strlen(message) > 32 ) + return FALSE; +#endif + for ( i = 0 ; i < MAX_CHATROOM ; i ++ ) { + if ( !ChatRoom[ i ].useFlag ) { + ChatRoom[ i ].useFlag = TRUE ; + ChatRoom[ i ].Maker = myindex ; + ChatRoom[ i ].NowPeople = 1 ; + ChatRoom[ i ].MemberList[ 0 ] = myindex ; + sprintf ( ChatRoom[ i ].RoomName , "%s" , message ) ; + CHAR_setWorkInt ( myindex , CHAR_WORKCHATROOMTYPE , 1 ) ; + CHAR_setWorkInt ( myindex , CHAR_WORKCHATROOMNUM , i ) ; + ChatRoom_Refresh ( i ) ; + + CHAR_DelGold( myindex, 200); + CHAR_talkToCli ( myindex , -1 , "ҿ۳ʯ" , CHAR_COLORYELLOW ); + return TRUE; + } + } + CHAR_talkToCli ( myindex , -1 , "޷µƵ" , CHAR_COLORYELLOW ); + return FALSE; +} + +BOOL ChatRoom_Destroy ( int myindex ) +{ + int i , j ; + int fd ;/*= getfdFromCharaIndex(myindex);*/ + char buf[16]; + if ( !CHAR_CHECKINDEX ( myindex ) ) + return FALSE; + if ( CHAR_getWorkInt ( myindex , CHAR_WORKCHATROOMTYPE ) == 1 ) { + i = CHAR_getWorkInt ( myindex , CHAR_WORKCHATROOMNUM ) ; + ChatRoom[ i ].useFlag = FALSE ; + ChatRoom[ i ].Maker = -1 ; + ChatRoom[ i ].NowPeople = -1 ; + + // WON FIX + memset( ChatRoom[ i ].RoomName, 0 , sizeof(ChatRoom[ i ].RoomName) ); + //sprintf ( ChatRoom[ i ].RoomName , " " ) ; + + for ( j = 0 ; j < MAX_PPLINROOM ; j ++ ) { + if ( !CHAR_CHECKINDEX ( ChatRoom[ i ].MemberList[ j ] ) ) { + ChatRoom[ i ].MemberList[ j ] = -1 ; + continue; + } + CHAR_setWorkInt ( ChatRoom[ i ].MemberList[ j ] , CHAR_WORKCHATROOMTYPE , 0 ) ; + CHAR_setWorkInt ( ChatRoom[ i ].MemberList[ j ] , CHAR_WORKCHATROOMNUM , 0 ) ; + fd = getfdFromCharaIndex( ChatRoom[ i ].MemberList[ j ] ); + sprintf ( buf , "D|%d" , i ) ; + lssproto_CHATROOM_send ( fd , buf ) ; + ChatRoom[ i ].MemberList[ j ] = -1 ; + } + return TRUE; + } + return FALSE; +} + +void ChatRoom_Message ( int myindex , char *message ) +{ + int i , j , fd ; + char buf[1024]; + if ( !CHAR_CHECKINDEX ( myindex ) ) + return ; + if ( CHAR_getWorkInt ( myindex , CHAR_WORKCHATROOMTYPE ) > 0 ) { + i = CHAR_getWorkInt ( myindex , CHAR_WORKCHATROOMNUM ) ; + + // WON FIX + if( i < 0 ) return; + + for ( j = 0 ; j < MAX_PPLINROOM ; j ++ ) { + if ( !CHAR_CHECKINDEX ( ChatRoom[ i ].MemberList[ j ] ) ) + continue; + snprintf ( buf , sizeof ( buf ) , "T|%s" , message ) ; + fd = getfdFromCharaIndex ( ChatRoom[ i ].MemberList[ j ] ); + lssproto_CHATROOM_send ( fd , buf ) ; + } + } +} + +void ChatRoom_Kick ( int myindex , int toindex ) +{ + int i , fd ; + int Num = CHAR_getWorkInt ( myindex , CHAR_WORKCHATROOMNUM ); + if ( !CHAR_CHECKINDEX ( myindex ) ) + return ; + if ( !CHAR_CHECKINDEX ( toindex ) ) + return ; + if ( myindex == toindex ) return; + if ( CHAR_getWorkInt ( myindex , CHAR_WORKCHATROOMTYPE ) == 1 ) { + if ( Num != CHAR_getWorkInt ( toindex , CHAR_WORKCHATROOMNUM ) ) + return; + else { + CHAR_setWorkInt ( toindex , CHAR_WORKCHATROOMTYPE , 0 ) ; + CHAR_setWorkInt ( toindex , CHAR_WORKCHATROOMNUM , -1) ; + //CHAR_talkToCli ( toindex , -1 , "ҳ߳ң" , CHAR_COLORRED ) ; + fd = getfdFromCharaIndex( toindex ); + lssproto_CHATROOM_send ( fd , "K|" ) ; + ChatRoom[ Num ].NowPeople --; + for ( i = 0 ; i < MAX_PPLINROOM ; i ++ ) { + if ( ChatRoom[ Num ].MemberList[ i ] == toindex ) { + ChatRoom[ Num ].MemberList[ i ] = -1 ; + break; + } + } + } + } + ChatRoom_Refresh ( Num ) ; +} + +void ChatRoom_Make ( int myindex , int toindex ) +{ + int Num = CHAR_getWorkInt ( myindex , CHAR_WORKCHATROOMNUM ); + if ( !CHAR_CHECKINDEX ( myindex ) ) + return ; + if ( !CHAR_CHECKINDEX ( toindex ) ) + return ; + if ( CHAR_getWorkInt ( myindex , CHAR_WORKCHATROOMTYPE ) == 1 ) { + if ( Num != CHAR_getWorkInt ( toindex , CHAR_WORKCHATROOMNUM ) ) + return; + else if ( CHAR_getInt ( toindex , CHAR_LV ) >= 30 || + CHAR_getInt ( toindex , CHAR_TRANSMIGRATION ) >= 1 ) { + CHAR_setWorkInt ( myindex , CHAR_WORKCHATROOMTYPE , 2 ) ; + CHAR_setWorkInt ( toindex , CHAR_WORKCHATROOMTYPE , 1 ) ; + CHAR_talkToCli ( toindex , -1 , "ҵҳ" , CHAR_COLORRED ) ; + + ChatRoom[ Num ].Maker = toindex ; + } + else { + CHAR_talkToCli ( myindex , -1 , "ѡļȼԵҳ" , CHAR_COLORRED ) ; + } + } + ChatRoom_Refresh ( Num ) ; +} + +void ChatRoom_Leave ( int myindex ) +{ + int i , NextMaker = -1 ; + int Num = CHAR_getWorkInt ( myindex , CHAR_WORKCHATROOMNUM ); + if ( !CHAR_CHECKINDEX ( myindex ) ) + return ; + if ( CHAR_getWorkInt ( myindex , CHAR_WORKCHATROOMTYPE ) == 1 ) { + for ( i = 0 ; i < MAX_PPLINROOM ; i ++ ) { + if ( ChatRoom[ Num ].MemberList[ i ] != myindex && + ChatRoom[ Num ].MemberList[ i ] != -1 ) { + if ( CHAR_CHECKINDEX ( ChatRoom[ Num ].MemberList[ i ] ) ) { + if ( CHAR_getInt ( ChatRoom[ Num ].MemberList[ i ] , CHAR_LV ) >= 30 || + CHAR_getInt ( ChatRoom[ Num ].MemberList[ i ] , CHAR_TRANSMIGRATION ) >= 1 ) { + NextMaker = ChatRoom[ Num ].MemberList[ i ] ; + break; + } + } + } + } + if ( NextMaker != -1 ) { + ChatRoom_Make( myindex , NextMaker ) ; + CHAR_setWorkInt ( myindex , CHAR_WORKCHATROOMTYPE , 0) ; + CHAR_setWorkInt ( myindex , CHAR_WORKCHATROOMNUM, -1) ; + ChatRoom[ Num ].NowPeople --; + for ( i = 0 ; i < MAX_PPLINROOM ; i ++ ) { + if ( ChatRoom[ Num ].MemberList[ i ] == myindex ) { + ChatRoom[ Num ].MemberList[ i ] = -1 ; + break; + } + } + }else{ + ChatRoom_Destroy( myindex ) ; + return ; + } + + }else if ( CHAR_getWorkInt ( myindex , CHAR_WORKCHATROOMTYPE ) == 2 ) { + CHAR_setWorkInt ( myindex, CHAR_WORKCHATROOMTYPE, 0) ; + CHAR_setWorkInt ( myindex, CHAR_WORKCHATROOMNUM, -1) ; + ChatRoom[ Num ].NowPeople --; + for ( i = 0 ; i < MAX_PPLINROOM ; i ++ ) { + if ( ChatRoom[ Num ].MemberList[ i ] == myindex ) { + ChatRoom[ Num ].MemberList[ i ] = -1 ; + break; + } + } + } + ChatRoom_Refresh ( Num ) ; +} + +void ChatRoom_Join ( int myindex , int num ) +{ + int fd ; + char buf[64]; + if ( !CHAR_CHECKINDEX ( myindex ) ) + return ; + if ( CHAR_getWorkInt ( myindex , CHAR_WORKCHATROOMTYPE ) != 0 ) + return ; + if ( ChatRoom[ num ].useFlag == TRUE && ChatRoom[ num ].NowPeople < MAX_PPLINROOM ) { + sprintf ( buf , "J|%s|%d" , CHAR_getChar( myindex , CHAR_NAME ) , myindex ) ; + fd = getfdFromCharaIndex( ChatRoom[ num ].Maker ); + lssproto_CHATROOM_send ( fd , buf ); + }else if ( ChatRoom[ num ].NowPeople >= MAX_PPLINROOM ) + CHAR_talkToCli ( myindex , -1 , "" , CHAR_COLORRED ) ; + +} + +void ChatRoom_Agree ( int myindex , int toindex , int YesNo ) { + int i ; + int Num = CHAR_getWorkInt ( myindex , CHAR_WORKCHATROOMNUM ); + if ( !CHAR_CHECKINDEX ( myindex ) ) + return ; + if ( !CHAR_CHECKINDEX ( toindex ) ) + return ; + if ( CHAR_getWorkInt ( toindex , CHAR_WORKCHATROOMTYPE ) != 0 ) + return; + if ( CHAR_getWorkInt ( myindex , CHAR_WORKCHATROOMTYPE ) == 1 ) { + if ( ChatRoom[ Num ].NowPeople < MAX_PPLINROOM && YesNo == 1 ) { + CHAR_setWorkInt ( toindex , CHAR_WORKCHATROOMTYPE , 2 ) ; + CHAR_setWorkInt ( toindex , CHAR_WORKCHATROOMNUM , Num ) ; + ChatRoom[ Num ].NowPeople ++ ; + for ( i = 0 ; i < MAX_PPLINROOM ; i ++ ) { + if ( ChatRoom[ Num ].MemberList[ i ] == -1 ) { + ChatRoom[ Num ].MemberList[ i ] = toindex ; + break; + } + } + }else if ( YesNo == 0 ) { + CHAR_talkToCli ( toindex , -1 , "ҳܾļ룡" , CHAR_COLORRED ) ; + }else if ( ChatRoom[ Num ].NowPeople >= MAX_PPLINROOM ) { + CHAR_talkToCli ( toindex , -1 , "" , CHAR_COLORRED ) ; + CHAR_talkToCli ( myindex , -1 , "" , CHAR_COLORRED ) ; + } + } + ChatRoom_Refresh ( Num ) ; +} + +void ChatRoom_List ( int fd ) +{ + int i ; + char buf[128]; + char token[2048] = "B|"; + for ( i = 0 ; i < MAX_CHATROOM ; i ++ ) { + if ( ChatRoom[ i ].useFlag == TRUE ) { + sprintf ( buf , "%2dѶ=>%20s , ҳ=>%16s , =>%2d" , + i , + ChatRoom[ i ].RoomName , + CHAR_getChar ( ChatRoom[ i ].Maker , CHAR_NAME ) , + ChatRoom[ i ].NowPeople ); + + sprintf ( buf , "r%d|%s|%d|%s|p%d|" , + i , + ChatRoom[ i ].RoomName , + ChatRoom[ i ].Maker , + CHAR_getChar ( ChatRoom[ i ].Maker , CHAR_NAME ) , + ChatRoom[ i ].NowPeople ); + strncat ( token , buf , sizeof ( buf ) ) ; + } + } + lssproto_CHATROOM_send ( fd , token ) ; +} + +void ChatRoom_Refresh ( int Num ) +{ + int fd , i , RoomLeader = -1 ; + char token[2048] ; + char token2[2096] ; + char buf[64] ; + if ( ChatRoom[ Num ].useFlag == TRUE ) { + sprintf ( token , "R|r%d|%s|%d|%s|p%d|" , + Num , + ChatRoom[ Num ].RoomName , + ChatRoom[ Num ].Maker , + CHAR_getChar ( ChatRoom[ Num ].Maker , CHAR_NAME ) , + ChatRoom[ Num ].NowPeople ); + for ( i = 0 ; i < MAX_PPLINROOM ; i ++ ) { + if ( ChatRoom[ Num ].MemberList[ i ] != -1 ) { + sprintf( buf , "I%d|%s|%s|" , + ChatRoom[ Num ].MemberList[ i ] , + CHAR_getChar ( ChatRoom[ Num ].MemberList[ i ] , CHAR_NAME ) , + CHAR_getChar ( ChatRoom[ Num ].MemberList[ i ] , CHAR_OWNTITLE ) + ); + strncat ( token , buf , sizeof ( buf ) ) ; + } + } + } + for ( i = 0 ; i < MAX_PPLINROOM ; i ++ ) { + if ( ChatRoom[ Num ].MemberList[ i ] != -1 ) { + if ( CHAR_getWorkInt ( ChatRoom[ Num ].MemberList[ i ] , CHAR_WORKCHATROOMTYPE ) == 1 ) RoomLeader = 1; + else RoomLeader = 0 ; + sprintf ( token2 , "%s%d|" , token , RoomLeader ) ; + fd= getfdFromCharaIndex ( ChatRoom[ Num ].MemberList[ i ] ); + lssproto_CHATROOM_send ( fd , token2 ) ; + } + } +} + +void ChatRoom_recvall ( int fd , char *data ) +{ + char Head[4]; + char message[1024]; + char buf[16]; + int myindex ; + + myindex = CONNECT_getCharaindex(fd); + if ( !CHAR_CHECKINDEX ( myindex ) )return ; + getStringFromIndexWithDelim( data , "|", 1, Head, sizeof(Head)); + getStringFromIndexWithDelim( data , "|", 2, message, sizeof(message)); + + if ( strcmp ( Head , "C" ) == 0 ) { // Ƶ + if ( !ChatRoom_Create ( myindex , message ) ) + print("\nSyu log Create Channel Error" ); + }else if ( strcmp ( Head , "D" ) == 0 ) { // ɾƵ + if ( !ChatRoom_Destroy ( myindex ) ) + print("\nSyu log Destroy Channel Error" ) ; + }else if ( strcmp ( Head , "A" ) == 0 ) {// ͬƵ + getStringFromIndexWithDelim( data , "|", 2, message, sizeof(message)); + getStringFromIndexWithDelim( data , "|", 3, buf, sizeof(buf)); + ChatRoom_Agree ( myindex , atoi( message ) , atoi( buf ) ) ; + }else if ( strcmp ( Head , "J" ) == 0 ) {// Ƶ + getStringFromIndexWithDelim( data , "|", 2, message, sizeof(message)); + ChatRoom_Join ( myindex , atoi( message ) ) ; + }else if ( strcmp ( Head , "L" ) == 0 ) {// 뿪Ƶ + ChatRoom_Leave ( myindex ) ; + }else if ( strcmp ( Head , "K" ) == 0 ) {//߳Ƶ + getStringFromIndexWithDelim( data , "|", 2, message, sizeof(message)); + ChatRoom_Kick ( myindex , atoi( message ) ); + }else if ( strcmp ( Head , "M" ) == 0 ) { // ҳ + getStringFromIndexWithDelim( data , "|", 2, message, sizeof(message)); + ChatRoom_Make ( myindex , atoi( message ) ); + }else if ( strcmp ( Head , "T" ) == 0 ) {// ƵѶϢ + getStringFromIndexWithDelim( data , "|", 2, message, sizeof(message)); + ChatRoom_Message ( myindex , message ) ; + }else if ( strcmp ( Head , "B" ) == 0 ) {// 嵥 + ChatRoom_List ( fd ); + }else + print("\nSyu log None"); +} diff --git a/char/deathcontend.c b/char/deathcontend.c new file mode 100644 index 0000000..e69de29 diff --git a/char/defaultGroundEnemy.h b/char/defaultGroundEnemy.h new file mode 100644 index 0000000..8dba339 --- /dev/null +++ b/char/defaultGroundEnemy.h @@ -0,0 +1,158 @@ +#if 0 +static Char slime= +{ + FALSE, /* use ɤǤ⤤*/ + + /* data */ + { + 0, /* CHAR_DATAPLACENUMBER */ + 0, /* CHAR_BASEIMAGENUMBER */ + 0, /* CHAR_BASEBASEIMAGENUMBER */ + 0, /* CHAR_FACEIMAGENUMBER */ + 0, /* CHAR_FLOOR */ + 0, /* CHAR_X */ + 0, /* CHAR_Y */ + 0, /* CHAR_DIR 120˻׼ */ + 0, /* CHAR_LV */ + 0, /* CHAR_GOLD */ + 1, /* CHAR_HP */ + 0, /* CHAR_MP */ + 0, /* CHAR_MAXMP */ + + 0, /* CHAR_VITAL */ + 0, /* CHAR_STR */ + 0, /* CHAR_TOUGH */ + 0, /* CHAR_DEX */ + + 0, /* CHAR_CHARM */ + 0, /* CHAR_LUCK */ + + 0, /* ° */ + 0, /* ° */ + 0, /* ° */ + 0, /* ° */ + + 0, /* CHAR_SLOT */ + 0, /* CHAR_CRITIAL */ + 0, /* CHAR_COUNTER */ + 0, /* CHAR_RARE */ + 0, /* CHAR_RADARSTRLENGTH */ + 0, /* CHAR_CHATVOLUME */ + MAKE2VALUE(100,20), /* CHAR_MERCHANTLEVEL */ + 0, /* CHAR_HEALERLEVEL */ + 0, /* CHAR_DETERMINEITEM */ + + -1, /* CHAR_INDEXOFEQTITLE */ + + 0, /* CHAR_POISON */ + 0, /* CHAR_PARALYSIS */ + 0, /* CHAR_SILENCE */ + 0, /* CHAR_STONE */ + 0, /* CHAR_DARKNESS */ + 0, /* CHAR_CONFUSION */ + + 0, /* CHAR_LOGINCOUNT */ + 0, /* CHAR_DEADCOUNT */ + 0, /* CHAR_WALKCOUNT */ + 0, /* CHAR_TALKCOUNT */ + 0, /* CHAR_DAMAGECOUNT */ + 0, /* CHAR_GETPETCOUNT */ + 0, /* CHAR_KILLPETCOUNT */ + 0, /* CHAR_DEADPETCOUNT */ + 0, /* CHAR_SENDMAILCOUNT */ + 0, /* CHAR_MERGEITEMCOUNT */ + 0, /* CHAR_DUELBATTLECOUNT */ + 0, /* CHAR_DUELWINCOUNT */ + 0, /* CHAR_DUELLOSECOUNT */ + 0, /* CHAR_DUELSTWINCOUNT */ + 0, /* CHAR_DUELMAXSTWINCOUNT */ + + CHAR_TYPEENEMY, /* CHAR_WHICHPLAYER */ + 1000, /* CHAR_WALKINTERVAL */ + 1000, /* CHAR_LOOPINTERVAL */ + + 0, /* CHAR_LEVELEXP */ + + -1, /*CHAR_LASTTALKELDER*/ + 0, /*CHAR_SKILLUPPOINT */ + 0, /* CHAR_LEVELUPPOINT */ + + 0, /*CHAR_IMAGETYPE */ + CHAR_COLORYELLOW, /* CHAR_NAMECOLOR */ + CHAR_COLORYELLOW, /* CHAR_POPUPNAMECOLOR */ + 0, /* CHAR_LASTTIMESETLUCK */ + 0, /* CHAR_DUELPOINT */ + 0, /* CHAR_EVENT */ + 0, /* CHAR_EVENT2 */ + 0, /* CHAR_EVENT3 */ +#ifdef _NEWEVENT + 0, /* CHAR_EVENT4 */ + 0, /* CHAR_EVENT5 */ + 0, /* CHAR_EVENT6 */ +#endif + 0, /* CHAR_NOWEVENT */ + 0, /* CHAR_NOWEVENT2 */ + 0, /* CHAR_NOWEVENT3 */ +#ifdef _NEWEVENT + 0, /* CHAR_NOWEVENT4 */ + 0, /* CHAR_NOWEVENT5 */ + 0, /* CHAR_NOWEVENT6 */ +#endif + 0, /* CHAR_TRANSMIGRATION */ + 0, /* CHAR_TRANSEQUATION */ + + 0, /*CHAR_INITDATA */ + }, + { + {""}, /* CHAR_NAME */ + {""}, /* CHAR_OWNTITLE */ + {""}, /* CHAR_ARGUMENT */ + {""}, /* CHAR_OWNERCDKEY */ + {""}, /* CHAR_OWNERCHARANAME */ +#if 0 + {""}, /* CHAR_INITFUNC */ + {""}, /* CHAR_WALKPREFUNC */ + {""}, /* CHAR_WALKPOSTFUNC */ + {""}, /* CHAR_PREOVERFUNC */ + {""}, /* CHAR_PREOVERFUNC */ + {""}, /* CHAR_WATCHFUNC */ + {""}, /* CHAR_LOOPFUNC */ + {""}, /* CHAR_DYINGFUNC */ + {""}, /* CHAR_TALKEDFUNC */ + {""}, /* CHAR_PREATTACKEDFUNC */ + {""}, /* CHAR_POSTATTACKEDFUNC */ + {""}, /* CHAR_OFFFUNC */ + {""}, /* CHAR_LOOKEDFUNC */ + {""}, /* CHAR_ITEMPUTFUNC */ + {""}, /* CHAR_SPECIALTALKEDFUNC */ + {""}, /* CHAR_WINDOWTALKEDFUNC */ +#endif + }, + { + /* CHAR_ISATTACK */ + /* CHAR_ISATTACKED */ + /* CHAR_ISOVER */ + /* CHAR_ISOVERED */ + /* CHAR_HAVEHEIGHT */ + /* CHAR_ISVISIBLE */ + /* CHAR_ISTRANSPARENT */ + /* CHAR_ISFLYING */ + + SETFLG(1,1,1,1,1,1,0,0 ), + + /* CHAR_ISDIE */ + /* CHAR_ISBIG */ + /* CHAR_ISSHOWDAMAGE */ + /* CHAR_ISPARTY */ + /* CHAR_ISWARP */ + /* CHAR_ISDUEL */ + /* CHAR_ISPARTYCHAT */ + /* CHAR_ISTRADECARD */ + + SETFLG(0,0,1,0,0,0,0,0 ), + } +}; +#endif + + + diff --git a/char/defaultPlayer.h b/char/defaultPlayer.h new file mode 100644 index 0000000..703c4f5 --- /dev/null +++ b/char/defaultPlayer.h @@ -0,0 +1,346 @@ +#include "version.h" + +static Char player= +{ + FALSE, /* use ɤǤ⤤*/ + { + 0, /* CHAR_DATAPLACENUMBER */ + 0, /* CHAR_BASEIMAGENUMBER */ + 0, /* CHAR_BASEBASEIMAGENUMBER */ + 0, /* CHAR_FACEIMAGENUMBER */ + 0, /* CHAR_FLOOR */ + 0, /* CHAR_X */ + 0, /* CHAR_Y */ + 5, /* CHAR_DIR 120˻׼ */ + 1, /* CHAR_LV */ + 0, /* CHAR_GOLD */ + 1, /* CHAR_HP */ + 0, /* CHAR_MP */ + + 0, /* CHAR_MAXMP */ + + 0, /* CHAR_VITAL */ + 0, /* CHAR_STR */ + 0, /* CHAR_TOUGH */ + 0, /* CHAR_DEX */ + + 0, /* CHAR_CHARM */ + 0, /* CHAR_LUCK */ + 0, /* ° */ + 0, /* ° */ + 0, /* ° */ + 0, /* ° */ + + 0, /* CHAR_SLOT*/ + 0, /* CHAR_CRITIAL */ + 0, /* CHAR_COUNTER */ + 0, /* CHAR_RARE */ + 0, /* CHAR_RADARSTRLENGTH */ + 0, /* CHAR_CHATVOLUME */ + MAKE2VALUE(100,20), /* CHAR_MERCHANTLEVEL */ + 0, /* CHAR_HEALERLEVEL */ + 0, /* CHAR_DETERMINEITEM */ + + -1, /* CHAR_INDEXOFEQTITLE */ + + + 0, /* CHAR_POISON */ + 0, /* CHAR_PARALYSIS */ + 0, /* CHAR_SILENCE */ + 0, /* CHAR_STONE */ + 0, /* CHAR_DARKNESS */ + 0, /* CHAR_CONFUSION */ + + 0, /* CHAR_LOGINCOUNT */ + 0, /* CHAR_DEADCOUNT */ + 0, /* CHAR_WALKCOUNT */ + 0, /* CHAR_TALKCOUNT */ + + 0, /* CHAR_DAMAGECOUNT */ + 0, /* CHAR_GETPETCOUNT */ + 0, /* CHAR_KILLPETCOUNT */ + 0, /* CHAR_DEADPETCOUNT */ + 0, /* CHAR_SENDMAILCOUNT */ + 0, /* CHAR_MERGEITEMCOUNT */ + + 0, /* CHAR_DUELBATTLECOUNT */ + 0, /* CHAR_DUELWINCOUNT */ + 0, /* CHAR_DUELLOSECOUNT */ + 0, /* CHAR_DUELSTWINCOUNT */ + 0, /* CHAR_DUELMAXSTWINCOUNT */ + + CHAR_TYPEPLAYER, /* CHAR_WHICHTYPE */ + 1000, /* CHAR_WALKINTERVAL */ + 1000, /* CHAR_LOOPINTERVAL */ +#ifdef _NEWOPEN_MAXEXP + 0, // CHAR_OLDEXP, +#endif + 0, // CHAR_EXP, + -1, /* CHAR_LASTTALKELDER*/ + 0, /* CHAR_SKILLUPPOINT */ + 0, /* CHAR_LEVELUPPOINT */ + + 0, /* CHAR_IMAGETYPE */ + CHAR_COLORWHITE, /* CHAR_NAMECOLOR */ + CHAR_COLORWHITE, /* CHAR_POPUPNAMECOLOR */ + 0, /* CHAR_LASTTIMESETLUCK */ + 100, /* CHAR_DUELPOINT */ + 0, /* CHAR_EVENT */ + 0, /* CHAR_EVENT2 */ + 0, /* CHAR_EVENT3 */ +#ifdef _NEWEVENT + 0, /* CHAR_EVENT4 */ + 0, /* CHAR_EVENT5 */ + 0, /* CHAR_EVENT6 */ +#endif + 0, /* CHAR_NOWEVENT */ + 0, /* CHAR_NOWEVENT2 */ + 0, /* CHAR_NOWEVENT3 */ +#ifdef _NEWEVENT + 0, /* CHAR_NOWEVENT4 */ + 0, /* CHAR_NOWEVENT5 */ + 0, /* CHAR_NOWEVENT6 */ +#endif + 0, /* CHAR_TRANSMIGRATION */ + 0, /* CHAR_TRANSEQUATION */ + + 0, /* CHAR_INITDATA */ + +//#ifdef _PETSKILL_BECOMEPIG +// -1, +//#endif + + 0, //CHAR_SILENT, /* char shutup time */ + 0, // CHAR_FMINDEX, // a index + 0, // CHAR_FMLEADERFLAG, + /* aڦ + * FMMEMBER_NONE :S[Ja + * FMMEMBER_APPLY :ӽХ[Jaڤ + * FMMEMBER_LEADER :ڪ + * FMMEMBER_MEMBER :@릨 + * FMMEMBER_ELDER : + * FMMEMBER_INVITE :q // Ȯɤ + * FMMEMBER_BAILEE :]Ȫ // Ȯɤ + * FMMEMBER_VICELEADER :Ʊڪ // Ȯɤ + */ + 0, // CHAR_FMSPRITE, // aڦu@F + + 0, // CHAR_BANKGOLD, + 0, // CHAR_RIDEPET, + 0, // CHAR_LEARNRIDE, +#ifdef _NEW_RIDEPETS + 0, // CHAR_LOWRIDEPETS, +#endif + 0, // CHAR_LIMITLEVEL, +#ifdef _PET_FUSION + 0, // CHAR_FUSIONCODE, //ؽsX + 0, // CHAR_FUSIONINDEX, //ds + 0, // CHAR_FUSIONRAISE, //i + 0, // CHAR_FUSIONBEIT, //dJX + 0, // CHAR_FUSIONTIMELIMIT, //iɶ +#endif +#ifdef _PERSONAL_FAME // Arminius 8.30: aڭӤHn + 0, // CHAR_FAME, +#endif + +#ifdef _NEWSAVE + 0, // CHAR_SAVEINDEXNUMBER, /* SaveFile .0.char or .1.char */ +#endif + +#ifdef _ATTACK_MAGIC + 0, // CHAR_EARTH_EXP, // aa]km + 0, // CHAR_WATER_EXP, // a]km + 0, // CHAR_FIRE_EXP, // a]km + 0, // CHAR_WIND_EXP, // a]km + 0, // CHAR_EARTH_RESIST, // aa]kܩ + 0, // CHAR_WATER_RESIST, // a]kܩ + 0, // CHAR_FIRE_RESIST, // a]kܩ + 0, // CHAR_WIND_RESIST, // a]kܩ + 0, // CHAR_EARTH_ATTMAGIC_EXP, // aa]km׸g + 0, // CHAR_WATER_ATTMAGIC_EXP, // a]km׸g + 0, // CHAR_FIRE_ATTMAGIC_EXP, // a]km׸g + 0, // CHAR_WIND_ATTMAGIC_EXP, // a]km׸g + 0, // CHAR_EARTH_DEFMAGIC_EXP, // aa]kܩʸg + 0, // CHAR_WATER_DEFMAGIC_EXP, // a]kܩʸg + 0, // CHAR_FIRE_DEFMAGIC_EXP, // a]kܩʸg + 0, // CHAR_WIND_DEFMAGIC_EXP, // a]kܩʸg +#endif + + +#ifdef _GAMBLE_BANK + 0, // CHAR_PERSONAGOLD, //ӤHȦ +#endif +#ifdef _DROPSTAKENEW + 0, // CHAR_GAMBLENUM, //n +#endif +#ifdef _ADD_ACTION //npcʧ@ + 0, // CHAR_ACTIONSTYLE, +#endif +#ifdef _PET_EVOLUTION + 0, // CHAR_EVOLUTIONBASEVTL, + 0, // CHAR_EVOLUTIONBASESTR, + 0, // CHAR_EVOLUTIONBASETGH, + 0, // CHAR_EVOLUTIONBASEDEX, +#endif + +#ifdef _FM_JOINLIMIT + 0, // CHAR_FMTIMELIMIT, +#endif + +#ifdef _CHAR_PROFESSION // WON ADD H¾~ + 0, // PROFESSION_CLASS, // ¾~O + 0, // PROFESSION_LEVEL, // ¾~ +// 0, // PROFESSION_EXP, // ¾~g + 0, // PROFESSION_SKILL_POINT, // ޯI + 0, // ATTACHPILE, // W[| + 0, // PROFESSION_FIRE_P, // m + 0, // PROFESSION_ICE_P, // Bm + 0, // PROFESSION_THUNDER_P, // pm + 0, // PROFESSION_FIRE_R, // ܩ + 0, // PROFESSION_ICE_R, // Bܩ + 0, // PROFESSION_THUNDER_R, // pܩ +#endif +#ifdef _ALLDOMAN // (i}) Syu ADD Ʀ]NPC + 0, // CHAR_HEROFLOOR, +#endif +#ifdef _PETSKILL_BECOMEPIG + -1, // CHAR_BECOMEPIG, + 100250, //CHAR_BECOMEPIG_BBI +#endif + 0, // CHAR_LASTLEAVETIME, // Robin add ̫uɶ + +#ifdef _NEW_MANOR_LAW + 0, // CHAR_MOMENTUM, +#endif + +#ifdef _ITEM_ADDEXP2 + 0, // CHAR_ADDEXPPOWER, + 0, // CHAR_ADDEXPTIME, +#endif + +#ifdef _VIP_BATTLE_EXP + 0, // CHAR_NVIPEXP, + 0, // CHAR_NVIPTIME, +#endif + +#ifdef _ANGEL_SUMMON + 0, // CHAR_HEROCNT, // i̥Ȫ +#endif + +#ifdef _TEACHER_SYSTEM + 0, // CHAR_TEACHER_FAME, // ʦ쵼 +#endif + +#ifdef _GM_ITEM + 0, // GM +#endif +#ifdef _VIP_SERVER + 0, // Ա +#endif +#ifdef _VIP_RIDE + 0, // Աڼ +#endif +#ifdef _CAMEO_MONEY + 0, +#endif +#ifdef _MISSION_TRAIN + 0, + 0, +#endif +#ifdef _PET_EVOLVE + 0, +#endif +#ifdef _FLOOR_DIFI_FIELD + 0, +#endif +#ifdef _MISSION_TIME + 0, +#endif +#ifdef _PLAYER_TITLE + 0, + 0, +#endif +#ifdef _COWRIE + 0, +#endif +#ifdef _ONLINE_TIME + 0, +#endif + 0, //CHAR_LUASAVE_WORKINT_1 + 0, //CHAR_LUASAVE_WORKINT_2 + 0, //CHAR_LUASAVE_WORKINT_3 + 0, //CHAR_LUASAVE_INT_1 + 0, //CHAR_LUASAVE_INT_2 + 0, //CHAR_LUASAVE_INT_3 +#ifdef _CAX_ESC_REPORT + 0, //CHAR_REPORT ÿǩ +#endif +#ifdef _CAX_Mercenary + 0, //CHAR_MERCENARY Ӷֶ +#endif + }, + + { + {""}, /* CHAR_NAME */ + {""}, /* CHAR_OWNTITLE */ + {""}, /* CHAR_ARGUMENT */ + {""}, /* CHAR_OWNERCDKEY */ + {""}, /* CHAR_OWNERCHARANAME */ + }, + { + SETFLG(1,1,1,1,1,1,0,0 ), + SETFLG(0,0,0,0,0,0,0,1 ), + } +}; + +LevelUpPattern lvplayer00={ {{100,10},{200,10},{50,8}},9,11,10}; +LevelUpPattern lvplayer10={ {{100,10},{200,10},{50,8}},9,11,10}; +LevelUpPattern lvplayer20={ {{100,10},{200,10},{50,8}},9,11,10}; +LevelUpPattern lvplayer30={ {{100,10},{200,10},{50,8}},9,11,10}; + +LevelUpPattern lvplayer01={ {{100,10},{200,10},{50,8}},9,11,10}; +LevelUpPattern lvplayer11={ {{100,10},{200,10},{50,8}},9,11,10}; +LevelUpPattern lvplayer21={ {{100,10},{200,10},{50,8}},9,11,10}; +LevelUpPattern lvplayer31={ {{100,10},{200,10},{50,8}},9,11,10}; + +LevelUpPattern lvplayer02={ {{100,10},{200,10},{50,8}},9,11,10}; +LevelUpPattern lvplayer12={ {{100,10},{200,10},{50,8}},9,11,10}; +LevelUpPattern lvplayer22={ {{100,10},{200,10},{50,8}},9,11,10}; +LevelUpPattern lvplayer32={ {{100,10},{200,10},{50,8}},9,11,10}; + +LevelUpPattern lvplayer03={ {{100,10},{200,10},{50,8}},9,11,10}; +LevelUpPattern lvplayer13={ {{100,10},{200,10},{50,8}},9,11,10}; +LevelUpPattern lvplayer23={ {{100,10},{200,10},{50,8}},9,11,10}; +LevelUpPattern lvplayer33={ {{100,10},{200,10},{50,8}},9,11,10}; + +LevelUpPattern lvplayer04={ {{100,10},{200,10},{50,8}},9,11,10}; +LevelUpPattern lvplayer14={ {{100,10},{200,10},{50,8}},9,11,10}; +LevelUpPattern lvplayer24={ {{100,10},{200,10},{50,8}},9,11,10}; +LevelUpPattern lvplayer34={ {{100,10},{200,10},{50,8}},9,11,10}; + +LevelUpPattern lvplayer05={ {{100,10},{200,10},{50,8}},9,11,10}; +LevelUpPattern lvplayer15={ {{100,10},{200,10},{50,8}},9,11,10}; +LevelUpPattern lvplayer25={ {{100,10},{200,10},{50,8}},9,11,10}; +LevelUpPattern lvplayer35={ {{100,10},{200,10},{50,8}},9,11,10}; + +LevelUpPattern lvplayer06={ {{100,10},{200,10},{50,8}},9,11,10}; +LevelUpPattern lvplayer16={ {{100,10},{200,10},{50,8}},9,11,10}; +LevelUpPattern lvplayer26={ {{100,10},{200,10},{50,8}},9,11,10}; +LevelUpPattern lvplayer36={ {{100,10},{200,10},{50,8}},9,11,10}; + +LevelUpPattern lvplayer07={ {{100,10},{200,10},{50,8}},9,11,10}; +LevelUpPattern lvplayer17={ {{100,10},{200,10},{50,8}},9,11,10}; +LevelUpPattern lvplayer27={ {{100,10},{200,10},{50,8}},9,11,10}; +LevelUpPattern lvplayer37={ {{100,10},{200,10},{50,8}},9,11,10}; + +LevelUpPattern lvplayer08={ {{100,10},{200,10},{50,8}},9,11,10}; +LevelUpPattern lvplayer18={ {{100,10},{200,10},{50,8}},9,11,10}; +LevelUpPattern lvplayer28={ {{100,10},{200,10},{50,8}},9,11,10}; +LevelUpPattern lvplayer38={ {{100,10},{200,10},{50,8}},9,11,10}; + +LevelUpPattern lvplayer09={ {{100,10},{200,10},{50,8}},9,11,10}; +LevelUpPattern lvplayer19={ {{100,10},{200,10},{50,8}},9,11,10}; +LevelUpPattern lvplayer29={ {{100,10},{200,10},{50,8}},9,11,10}; +LevelUpPattern lvplayer39={ {{100,10},{200,10},{50,8}},9,11,10}; + + diff --git a/char/defend.c b/char/defend.c new file mode 100644 index 0000000..eebac60 --- /dev/null +++ b/char/defend.c @@ -0,0 +1,29 @@ +#include "version.h" +#include +#include +#include +#include + +#include "readmap.h" +#include "object.h" +#include "char.h" +#include "char_base.h" +#include "lssproto_serv.h" +#include "saacproto_cli.h" +#include "npcutil.h" +#include "family.h" +#include "log.h" +#include "handletime.h" +#include "buf.h" +#include "net.h" +#include "char_base.h" +#include "battle.h" +#include "npc_bus.h" +#include "char_talk.h" +#include "npc_scheduleman.h" +#include "defend.h" + + + + + diff --git a/char/encount.c b/char/encount.c new file mode 100644 index 0000000..ff1b987 --- /dev/null +++ b/char/encount.c @@ -0,0 +1,580 @@ +#include "version.h" +#include +#include +#include +#ifdef _REDHAT_V9 +#include +#endif + +#include "common.h" +#include "util.h" +#include "buf.h" +#include "char_base.h" +#include "char.h" +#include "configfile.h" +#include "encount.h" +#include "enemy.h" + +#ifdef _ADD_ENCOUNT // WON ADD ӵ޼ +#include "encount.h" +#endif + +/* ޼ ĩ */ + +#ifndef _ADD_ENCOUNT // WON ADD ӵ޼ +typedef struct tagENCOUNT_Table +{ + int index; + int floor; + int encountprob_min; /* ޼ */ + int encountprob_max; /* ޼ */ + int enemymaxnum; /* ľë¾ */ + int zorder; + int groupid[ENCOUNT_GROUPMAXNUM]; /* No */ + int createprob[ENCOUNT_GROUPMAXNUM]; /* */ + RECT rect; +}ENCOUNT_Table; +ENCOUNT_Table *ENCOUNT_table; +#endif + +int ENCOUNT_encountnum; +#define ENCOUNT_ENEMYMAXCREATENUM 10 + +static INLINE BOOL ENCOUNT_CHECKENCOUNTTABLEARRAY( int array) +{ + if( array < 0 || array > ENCOUNT_encountnum-1) return FALSE; + return TRUE; +} + +/*------------------------------------------------------------ + * ޼ɬüë£ + * ¦ + * filename char* ɬð̻ + * ߯Ի + * TRUE(1) + * FALSE(0) + *------------------------------------------------------------*/ +BOOL ENCOUNT_initEncount( char* filename ) +{ + FILE* f; + char line[256]; + int linenum=0; + int encount_readlen=0; + + f = fopen(filename,"r"); + if( f == NULL ){ + errorprint; + return FALSE; + } + + ENCOUNT_encountnum=0; + + /* ئ滥ϵؤ¾Ʃ */ + while( fgets( line, sizeof( line ), f ) ){ + linenum ++; + if( line[0] == '#' )continue; /* comment */ + if( line[0] == '\n' )continue; /* none */ + chomp( line ); + + ENCOUNT_encountnum++; + } + + if( fseek( f, 0, SEEK_SET ) == -1 ){ + fprint( "ѰҴ\n" ); + fclose(f); + return FALSE; + } + + ENCOUNT_table = allocateMemory( sizeof(struct tagENCOUNT_Table) + * ENCOUNT_encountnum ); + if( ENCOUNT_table == NULL ){ + fprint( "޷ڴ %d\n" , + sizeof(ENCOUNT_table)*ENCOUNT_encountnum); + fclose( f ); + return FALSE; + } + + /* */ +{ + int i,j; + for( i = 0; i < ENCOUNT_encountnum; i ++ ) { + ENCOUNT_table[i].index = -1; + ENCOUNT_table[i].floor = 0; + ENCOUNT_table[i].encountprob_min = 1; + ENCOUNT_table[i].encountprob_min = 50; + ENCOUNT_table[i].enemymaxnum = 4; + ENCOUNT_table[i].rect.x = 0; + ENCOUNT_table[i].rect.y = 0; + ENCOUNT_table[i].rect.height = 0; + ENCOUNT_table[i].rect.width = 0; + ENCOUNT_table[i].zorder = 0; + for( j = 0; j < ENCOUNT_GROUPMAXNUM; j ++ ) { + ENCOUNT_table[i].groupid[j] = -1; + ENCOUNT_table[i].createprob[j] = -1; + } +#ifdef _ADD_ENCOUNT // WON ADD ӵ޼ + ENCOUNT_table[i].event_now = -1; + ENCOUNT_table[i].event_end = -1; + ENCOUNT_table[i].enemy_group = -1; +#endif + } +} + + /* */ + linenum = 0; + while( fgets( line, sizeof( line ), f ) ){ + linenum ++; + if( line[0] == '#' )continue; /* comment */ + if( line[0] == '\n' )continue; /* none */ + chomp( line ); + + /* ë */ + /* tab ë " " 徧 */ + replaceString( line, '\t' , ' ' ); + /* ʸë£*/ +{ + int i; + char buf[256]; + for( i = 0; i < strlen( line); i ++) { + if( line[i] != ' ' ) { + break; + } + strcpy( buf, &line[i]); + } + if( i != 0 ) { + strcpy( line, buf); + } +} +{ + char token[256]; + int ret; + int x1,x2,y1,y2; + int j; + + /* պ ݼм */ + ENCOUNT_table[encount_readlen].index = -1; + ENCOUNT_table[encount_readlen].floor = 0; + ENCOUNT_table[encount_readlen].encountprob_min = 1; + ENCOUNT_table[encount_readlen].encountprob_min = 50; + ENCOUNT_table[encount_readlen].enemymaxnum = 4; + ENCOUNT_table[encount_readlen].rect.x = 0; + ENCOUNT_table[encount_readlen].rect.y = 0; + ENCOUNT_table[encount_readlen].rect.height = 0; + ENCOUNT_table[encount_readlen].rect.width = 0; + ENCOUNT_table[encount_readlen].zorder = 0; + for( j = 0; j < ENCOUNT_GROUPMAXNUM; j ++ ) { + ENCOUNT_table[encount_readlen].groupid[j] = -1; + ENCOUNT_table[encount_readlen].createprob[j] = -1; + } +#ifdef _ADD_ENCOUNT // WON ADD ӵ޼ + ENCOUNT_table[encount_readlen].event_now = -1; + ENCOUNT_table[encount_readlen].event_end = -1; + ENCOUNT_table[encount_readlen].enemy_group = -1; +#endif + + + /* 繴ͼëέ */ + ret = getStringFromIndexWithDelim( line,",",1,token, + sizeof(token)); + if( ret==FALSE ){ + fprint("ļ﷨:%s %d\n",filename,linenum); + continue; + } + ENCOUNT_table[encount_readlen].index = atoi(token); + + /* 2ͼëέ */ + ret = getStringFromIndexWithDelim( line,",",2,token, + sizeof(token)); + if( ret==FALSE ){ + fprint("ļ﷨:%s %d\n",filename,linenum); + continue; + } + ENCOUNT_table[encount_readlen].floor = atoi(token); + + /* 3ͼëέ */ + ret = getStringFromIndexWithDelim( line,",",3,token, + sizeof(token)); + if( ret==FALSE ){ + fprint("ļ﷨:%s %d\n",filename,linenum); + continue; + } + x1 = atoi(token); + + /* 4ͼëέ */ + ret = getStringFromIndexWithDelim( line,",",4,token, + sizeof(token)); + if( ret==FALSE ){ + fprint("ļ﷨:%s %d\n",filename,linenum); + continue; + } + y1= atoi(token); + + /* 5ͼëέ */ + ret = getStringFromIndexWithDelim( line,",",5,token, + sizeof(token)); + if( ret==FALSE ){ + fprint("ļ﷨:%s %d\n",filename,linenum); + continue; + } + + x2 = atoi(token); + + /* 6ͼëέ */ + ret = getStringFromIndexWithDelim( line,",",6,token, + sizeof(token)); + if( ret==FALSE ){ + fprint("ļ﷨:%s %d\n",filename,linenum); + continue; + } + y2= atoi(token); + + ENCOUNT_table[encount_readlen].rect.x = min(x1,x2); + ENCOUNT_table[encount_readlen].rect.width = max(x1,x2) - min(x1,x2); + ENCOUNT_table[encount_readlen].rect.y = min(y1,y2); + ENCOUNT_table[encount_readlen].rect.height = max(y1,y2) - min(y1,y2); + + /* 7ͼëέ */ + ret = getStringFromIndexWithDelim( line,",",7,token, + sizeof(token)); + if( ret==FALSE ){ + fprint("ļ﷨:%s %d\n",filename,linenum); + continue; + } + ENCOUNT_table[encount_readlen].encountprob_min = atoi(token); + + /* 8ͼëέ */ + ret = getStringFromIndexWithDelim( line,",",8,token, + sizeof(token)); + if( ret==FALSE ){ + fprint("ļ﷨:%s %d\n",filename,linenum); + continue; + } + ENCOUNT_table[encount_readlen].encountprob_max = atoi(token); + +{ + int a,b; + a = ENCOUNT_table[encount_readlen].encountprob_min; + b = ENCOUNT_table[encount_readlen].encountprob_max; + /* Ʃ */ + ENCOUNT_table[encount_readlen].encountprob_min + = min( a,b); + ENCOUNT_table[encount_readlen].encountprob_max + = max( a,b); +} + /* 9ͼëέ */ + ret = getStringFromIndexWithDelim( line,",",9,token, + sizeof(token)); + if( ret==FALSE ){ + fprint("ļ﷨:%s %d\n",filename,linenum); + continue; + } + { + int maxnum = atoi( token); + /* Ѽ뼰 */ + if( maxnum < 1 || maxnum > ENCOUNT_ENEMYMAXCREATENUM ) { + fprint("ļ﷨:%s %d\n",filename,linenum); + continue; + } + ENCOUNT_table[encount_readlen].enemymaxnum = maxnum; + } + /* 10ͼëέ */ + ret = getStringFromIndexWithDelim( line,",",10,token, + sizeof(token)); + if( ret==FALSE ){ + fprint("ļ﷨:%s %d\n",filename,linenum); + continue; + } + ENCOUNT_table[encount_readlen].zorder = atoi(token); + #define CREATEPROB_TOKEN 11 + + /* 11 31ͼëέ */ + { + int i; + + for( i = CREATEPROB_TOKEN; i < CREATEPROB_TOKEN +ENCOUNT_GROUPMAXNUM*2; i ++) { + ret = getStringFromIndexWithDelim( line,",",i,token, + sizeof(token)); + if( ret==FALSE ){ + fprint("ļ﷨:%s %d\n",filename,linenum); + continue; + } + if( strlen( token) != 0 ) { + if( i < CREATEPROB_TOKEN + ENCOUNT_GROUPMAXNUM ) { + ENCOUNT_table[encount_readlen].groupid[i-CREATEPROB_TOKEN] + = atoi(token); + } + else { + ENCOUNT_table[encount_readlen].createprob[i-(CREATEPROB_TOKEN + ENCOUNT_GROUPMAXNUM)] + = atoi(token); + } + } + } + + /* */ + if( checkRedundancy( ENCOUNT_table[encount_readlen].groupid, + arraysizeof( ENCOUNT_table[encount_readlen].groupid))) + { + fprint( "ļ﷨:%s %d\n", + filename,linenum); + continue; + } + } + + +#ifdef _ADD_ENCOUNT // WON ADD ӵ޼ + ret = getStringFromIndexWithDelim( line,",",31,token, + sizeof(token)); + if( ret==FALSE ){ + fprint("ļ﷨:%s %d\n",filename,linenum); + continue; + } + ENCOUNT_table[encount_readlen].event_now = atoi(token); + + ret = getStringFromIndexWithDelim( line,",",32,token, + sizeof(token)); + if( ret==FALSE ){ + fprint("ļ﷨:%s %d\n",filename,linenum); + continue; + } + ENCOUNT_table[encount_readlen].event_end = atoi(token); + + ret = getStringFromIndexWithDelim( line,",",33,token, + sizeof(token)); + if( ret==FALSE ){ + fprint("ļ﷨:%s %d\n",filename,linenum); + continue; + } + ENCOUNT_table[encount_readlen].enemy_group = atoi(token); +#endif + + encount_readlen ++; +} + } + fclose(f); + + ENCOUNT_encountnum = encount_readlen; + + print( "Ч %d..", ENCOUNT_encountnum ); + + return TRUE; +} +/*------------------------------------------------------------------------ + * ޼ɬð̻ + *-----------------------------------------------------------------------*/ +BOOL ENCOUNT_reinitEncount( void ) +{ + freeMemory( ENCOUNT_table); + return( ENCOUNT_initEncount( getEncountfile())); +} + +/*------------------------------------------------------------ + * ϶ýľ ENCOUNT_tableٯëƩ£ + * zorderٯëέƴ˼ ë £ + * ¦ + * floor int ׷ʧID + * x int x + * y int y + * ߯Ի + * ٯ + * -1 + ------------------------------------------------------------*/ +int ENCOUNT_getEncountAreaArray( int floor, int x, int y) +{ + int i; + int index = -1; + for( i=0 ; i0) { + if( index != -1 ) { + /* ƴëƩ */ + /* */ + if( curZorder > ENCOUNT_getZorderFromArray(index)) { + index = i; + } + } + else { + index = i; + } + } + } + } + } + return index; +} + +/*------------------------------------------------------------ + * ϶ýľ ޼ ëƩ£ + * ¦ + * floor int ׷ʧID + * x int x + * y int y + * ߯Ի + * ߶ + * -1 + ------------------------------------------------------------*/ +int ENCOUNT_getEncountPercentMin( int charaindex, int floor , int x, int y ) +{ + int ret; + + ret = ENCOUNT_getEncountAreaArray( floor, x, y); + if( ret != -1 ) { + ret = ENCOUNT_table[ret].encountprob_min; + /* Ŀ򵩶ë */ + if( CHAR_getWorkInt( charaindex, CHAR_WORK_TOHELOS_COUNT) > 0 ) { + ret = ceil( ret * + ((100 + CHAR_getWorkInt( charaindex, CHAR_WORK_TOHELOS_CUTRATE)) + / 100.0)); + } + if( ret < 0 ) ret = 0; + if( ret > 100 ) ret = 100; + } + return ret; +} +/*------------------------------------------------------------ + * ϶ýľ ޼ ëƩ£ + * ¦ + * floor int ׷ʧID + * x int x + * y int y + * ߯Ի + * ߶ + * -1 + ------------------------------------------------------------*/ +int ENCOUNT_getEncountPercentMax( int charaindex, int floor , int x, int y ) +{ + int ret; + + ret = ENCOUNT_getEncountAreaArray( floor, x, y); + if( ret != -1 ) { + ret = ENCOUNT_table[ret].encountprob_max; + /* Ŀ򵩶ë */ + if( CHAR_getWorkInt( charaindex, CHAR_WORK_TOHELOS_COUNT) > 0 ) { + ret = ceil( ret * + ((100 + CHAR_getWorkInt( charaindex, CHAR_WORK_TOHELOS_CUTRATE)) + / 100.0)); + } + if( ret < 0 ) ret = 0; + if( ret > 100 ) ret = 100; + } + return ret; +} +/*------------------------------------------------------------ + * ϶ýľ ϷMAXëƩ£ + * ¦ + * floor int ׷ʧID + * x int x + * y int y + * ߯Ի + * ߶ + * -1 + ------------------------------------------------------------*/ +int ENCOUNT_getCreateEnemyMaxNum( int floor , int x, int y ) +{ + int ret; + + ret = ENCOUNT_getEncountAreaArray( floor, x, y); + if( ret != -1 ) { + ret = ENCOUNT_table[ret].enemymaxnum; + } + return ret; +} +/*------------------------------------------------------------ + * ϶ýľ ޼ūindexëƩ£ + * ¦ + * floor int ׷ʧID + * x int x + * y int y + * ߯Ի + * ߶ + * -1 + ------------------------------------------------------------*/ +int ENCOUNT_getEncountIndex( int floor , int x, int y ) +{ + int ret; + + ret = ENCOUNT_getEncountAreaArray( floor, x, y); + if( ret != -1 ) { + ret = ENCOUNT_table[ret].index; + } + return ret; +} +/*------------------------------------------------------------ + * ϶ýľ ޼ūindexëƩ£ + * ¦ + * array int ENCOUNTTABLEٯ + * ߯Ի + * ߶ + * -1 + ------------------------------------------------------------*/ +int ENCOUNT_getEncountIndexFromArray( int array ) +{ + if( !ENCOUNT_CHECKENCOUNTTABLEARRAY( array)) return -1; + return ENCOUNT_table[array].index; +} +/*------------------------------------------------------------ + * ϶ýľ ޼ ëƩ£ + * ¦ + * array int ENCOUNTTABLEٯ + * ߯Ի + * ߶ + * -1 + ------------------------------------------------------------*/ +int ENCOUNT_getEncountPercentFromArray( int array ) +{ + if( !ENCOUNT_CHECKENCOUNTTABLEARRAY( array)) return -1; + return ENCOUNT_table[array].encountprob_min; +} +/*------------------------------------------------------------ + * ϶ýľ ϷMAXëƩ£ + * ¦ + * array int ENCOUNTTABLEٯ + * ߯Ի + * ߶ + * -1 + ------------------------------------------------------------*/ +int ENCOUNT_getCreateEnemyMaxNumFromArray( int array ) +{ + if( !ENCOUNT_CHECKENCOUNTTABLEARRAY( array)) return -1; + return ENCOUNT_table[array].enemymaxnum; +} +/*------------------------------------------------------------ + * ϶ýľ׽ٯ įëƩ£ + * ¦ + * array int ENCOUNTTABLEٯ + * ߯Ի + * ߶ + * -1 + ------------------------------------------------------------*/ +int ENCOUNT_getGroupIdFromArray( int array, int grouparray ) +{ + if( !ENCOUNT_CHECKENCOUNTTABLEARRAY( array)) return -1; + return ENCOUNT_table[array].groupid[grouparray]; +} +/*------------------------------------------------------------ + * ϶ýľ׽ٯ ëƩ£ + * ¦ + * array int ENCOUNTTABLEٯ + * ߯Ի + * ߶ + * -1 + ------------------------------------------------------------*/ +int ENCOUNT_getGroupProbFromArray( int array, int grouparray ) +{ + if( !ENCOUNT_CHECKENCOUNTTABLEARRAY( array)) return -1; + return ENCOUNT_table[array].createprob[grouparray]; +} +/*------------------------------------------------------------ + * ϶ýľ׽ٯƴëƩ£ + * ¦ + * array int ENCOUNTTABLEٯ + * ߯Ի + * ߶ + * -1 + ------------------------------------------------------------*/ +int ENCOUNT_getZorderFromArray( int array ) +{ + if( !ENCOUNT_CHECKENCOUNTTABLEARRAY( array)) return -1; + return ENCOUNT_table[array].zorder; +} diff --git a/char/enemy.c b/char/enemy.c new file mode 100644 index 0000000..a32c106 --- /dev/null +++ b/char/enemy.c @@ -0,0 +1,2759 @@ +/* ɬ */ +#include "version.h" +#include +#include +#include "common.h" +#include "util.h" +#include "buf.h" +#include "char_base.h" +#include "char.h" +#include "configfile.h" +#include "encount.h" +#include "enemy.h" +#include "pet.h" +#include "enemyexptbl.h" +#include "petmail.h" +#include "battle.h" +#include "pet_skillinfo.h" +#include "anim_tbl.h" +#include "log.h" + +#ifdef _ADD_ENCOUNT // WON ADD ӵ޼ +#include "encount.h" +#include "npcutil.h" +#endif + +#define ENEMY_INDEXTABLEMAXSIZE 16 +static ENEMY_EnemyTable *ENEMY_enemy; +static int ENEMY_enemynum; + +static ENEMYTEMP_Table *ENEMYTEMP_enemy; +static int ENEMYTEMP_enemynum; + +static GROUP_Table *GROUP_group; +static int GROUP_groupnum; + +int ENEMY_indextable[ENEMY_INDEXTABLEMAXSIZE]; + +#ifdef _ENEMY_FALLGROUND +extern tagRidePetTable ridePetTable[296]; +#endif + +INLINE BOOL ENEMY_CHECKINDEX( int index) +{ + if( index < 0 || index >= ENEMY_enemynum) return FALSE; + return TRUE; +} + +static INLINE BOOL ENEMY_CHECKINTDATAINDEX( int index) +{ + if( index< 0 || index >= ENEMY_DATAINTNUM) return FALSE; + return TRUE; +} + +static INLINE BOOL ENEMY_CHECKCHARDATAINDEX( int index) +{ + if( index< 0 || index >= ENEMY_DATACHARNUM) return FALSE; + return TRUE; +} + +INLINE int ENEMY_getInt( int index, ENEMY_DATAINT element) +{ + return ENEMY_enemy[index].intdata[element]; +} + +INLINE int *ENEMY_getIntdata( int index) +{ + return ENEMY_enemy[index].intdata; +} + +INLINE int ENEMY_setInt( int index, ENEMY_DATAINT element, int data) +{ + int buf; + buf = ENEMY_enemy[index].intdata[element]; + ENEMY_enemy[index].intdata[element] = data; + return buf; +} + +INLINE char *ENEMY_getChar( int index, ENEMY_DATACHAR element) +{ + if(!ENEMY_CHECKINDEX(index))return "\0"; + if(!ENEMY_CHECKCHARDATAINDEX(element))return "\0"; + + return ENEMY_enemy[index].chardata[element].string; +} + +INLINE BOOL ENEMY_setChar( int index ,ENEMY_DATACHAR element, char* new ) +{ + if(!ENEMY_CHECKINDEX(index))return FALSE; + if(!ENEMY_CHECKCHARDATAINDEX(element))return FALSE; + strcpysafe( ENEMY_enemy[index].chardata[element].string, + sizeof(ENEMY_enemy[index].chardata[element].string), + new ); + return TRUE; +} + +int ENEMY_getEnemyNum( void) +{ + return ENEMY_enemynum; +} + +INLINE BOOL ENEMYTEMP_CHECKINDEX( int index) +{ + if( index < 0 || index >= ENEMYTEMP_enemynum) return FALSE; + return TRUE; +} + +static INLINE BOOL ENEMYTEMP_CHECKINTDATAINDEX( int index) +{ + if( index< 0 || index >= E_T_DATAINTNUM) return FALSE; + return TRUE; +} + +static INLINE BOOL ENEMYTEMP_CHECKCHARDATAINDEX( int index) +{ + if( index< 0 || index >= E_T_DATACHARNUM) return FALSE; + return TRUE; +} + +INLINE int ENEMYTEMP_getInt( int index, ENEMYTEMP_DATAINT element) +{ + return ENEMYTEMP_enemy[index].intdata[element]; +} + +INLINE int ENEMYTEMP_setInt( int index, ENEMYTEMP_DATAINT element, int data) +{ + int buf; + buf = ENEMYTEMP_enemy[index].intdata[element]; + ENEMYTEMP_enemy[index].intdata[element] = data; + return buf; +} + +INLINE char *ENEMYTEMP_getChar( int index, ENEMYTEMP_DATACHAR element) +{ + if(!ENEMYTEMP_CHECKINDEX(index))return "\0"; + if(!ENEMYTEMP_CHECKCHARDATAINDEX(element))return "\0"; + + return ENEMYTEMP_enemy[index].chardata[element].string; +} + +INLINE BOOL ENEMYTEMP_setChar( int index ,ENEMYTEMP_DATACHAR element, char* new ) +{ + if(!ENEMYTEMP_CHECKINDEX(index))return FALSE; + if(!ENEMYTEMP_CHECKCHARDATAINDEX(element))return FALSE; + strcpysafe( ENEMYTEMP_enemy[index].chardata[element].string, + sizeof(ENEMYTEMP_enemy[index].chardata[element].string), + new ); + return TRUE; +} + +int ENEMYTEMP_getEnemyNum( void) +{ + return ENEMYTEMP_enemynum; +} + +INLINE BOOL GROUP_CHECKINDEX( int index) +{ + if( index < 0 || index >= GROUP_groupnum) return FALSE; + return TRUE; +} + +static INLINE BOOL GROUP_CHECKINTDATAINDEX( int index) +{ + if( index< 0 || index >= GROUP_DATAINTNUM) return FALSE; + return TRUE; +} + +static INLINE BOOL GROUP_CHECKCHARDATAINDEX( int index) +{ + if( index< 0 || index >= GROUP_DATACHARNUM) return FALSE; + return TRUE; +} + +INLINE int GROUP_getInt( int index, GROUP_DATAINT element) +{ + return GROUP_group[index].intdata[element]; +} + +INLINE int GROUP_setInt( int index, GROUP_DATAINT element, int data) +{ + int buf; + buf = GROUP_group[index].intdata[element]; + GROUP_group[index].intdata[element] = data; + return buf; +} + +INLINE char *GROUP_getChar( int index, GROUP_DATACHAR element) +{ + if(!GROUP_CHECKINDEX(index))return "\0"; + if(!GROUP_CHECKCHARDATAINDEX(element))return "\0"; + + return GROUP_group[index].chardata[element].string; +} + +INLINE BOOL GROUP_setChar( int index ,GROUP_DATACHAR element, char* new ) +{ + if(!GROUP_CHECKINDEX(index))return FALSE; + if(!GROUP_CHECKCHARDATAINDEX(element))return FALSE; + strcpysafe( GROUP_group[index].chardata[element].string, + sizeof(GROUP_group[index].chardata[element].string), + new ); + return TRUE; +} + +int GROUP_getEnemyNum( void) +{ + return GROUP_groupnum; +} + +BOOL ENEMYTEMP_initEnemy( char* filename ) +{ + FILE* f; + char line[256]; + int linenum=0; + int enemytemp_readlen=0; + int i,j; + f = fopen(filename,"r"); + if( f == NULL ){ + print( "ļʧ\n"); + return FALSE; + } + + ENEMYTEMP_enemynum=0; + + /* ئ滥ϵؤ¾Ʃ */ + while( fgets( line, sizeof( line ), f ) ){ + linenum ++; + if( line[0] == '#' )continue; /* comment */ + if( line[0] == '\n' )continue; /* none */ + chomp( line ); + + ENEMYTEMP_enemynum++; + } + + if( fseek( f, 0, SEEK_SET ) == -1 ){ + fprint( "Seek Error\n" ); + fclose(f); + return FALSE; + } + ENEMYTEMP_enemy = allocateMemory( sizeof(struct tagENEMYTEMP_Table) + * ENEMYTEMP_enemynum ); + if( ENEMYTEMP_enemy == NULL ){ + fprint( "޷ڴ %d\n" , + sizeof(struct tagENEMYTEMP_Table)*ENEMYTEMP_enemynum); + fclose( f ); + return FALSE; + } + + /* */ + for( i = 0; i < ENEMYTEMP_enemynum; i ++ ) { + for( j = 0; j < E_T_DATAINTNUM; j ++ ) { + ENEMYTEMP_setInt( i,j,-1); + } + } + linenum = 0; + while( fgets( line, sizeof( line ), f ) ){ + linenum ++; + if( line[0] == '#' )continue; /* comment */ + if( line[0] == '\n' )continue; /* none */ + chomp( line ); + replaceString( line, '\t' , ' ' ); +{ + char buf[256]; + for( i = 0; i < strlen( line); i ++) { + if( line[i] != ' ' ) { + break; + } + strcpy( buf, &line[i]); + } + if( i != 0 ) { + strcpy( line, buf); + } +} +{ + char token[256]; + int ret; + for( i = 0; i < E_T_DATACHARNUM; i ++ ) { + ret = getStringFromIndexWithDelim( line,",",i+1,token, + sizeof(token)); + if( ret==FALSE ){ + fprint("ļ﷨:%s %d\n",filename,linenum); + continue; + } + ENEMYTEMP_setChar( enemytemp_readlen, E_T_NAME + i, token); + + } +#define ENEMYTEMP_STARTINTNUM (E_T_DATACHARNUM+1) + for( i = ENEMYTEMP_STARTINTNUM; i < E_T_DATAINTNUM+ENEMYTEMP_STARTINTNUM; i ++ ) { + ret = getStringFromIndexWithDelim( line,",",i,token, + sizeof(token)); + if( ret==FALSE ){ + fprint("ļ﷨:%s %d\n",filename,linenum); + break; + } + if( strlen( token) != 0 ) { + ENEMYTEMP_setInt( enemytemp_readlen, i - ENEMYTEMP_STARTINTNUM, atoi( token)); + } + } + if( i < E_T_DATAINTNUM+ENEMYTEMP_STARTINTNUM ) continue; + + + enemytemp_readlen ++; +} + } + fclose(f); + + ENEMYTEMP_enemynum = enemytemp_readlen; + + print( "Ч״̬ %d...", ENEMYTEMP_enemynum ); + + return TRUE; +} + +BOOL ENEMYTEMP_reinitEnemy( void ) +{ + freeMemory( ENEMYTEMP_enemy); + return( ENEMYTEMP_initEnemy( getEnemyBasefile())); +} + +int ENEMYTEMP_getEnemyTempArray( int enemyindex) +{ + if( !ENEMY_CHECKINDEX( enemyindex)) return -1; + return ENEMY_enemy[enemyindex].enemytemparray; +} + +int ENEMYTEMP_getEnemyTempArrayFromTempNo( int EnemyTempNo) +{ + int i; + for( i = 0; i < ENEMYTEMP_enemynum; i ++ ) { + if( ENEMYTEMP_getInt( i, E_T_TEMPNO) == EnemyTempNo) { + return i; + } + } + return -1; +} + +int ENEMYTEMP_getEnemyTempArrayFromInitnum( int EnemyTempNo) +{ + int i; + for( i = 0; i < ENEMYTEMP_enemynum; i ++ ) { + if( ENEMYTEMP_getInt( i, E_T_INITNUM) == EnemyTempNo) { + return i; + } + } + return -1; +} + +BOOL ENEMY_initEnemy( char* filename ) +{ + FILE* f; + char line[256]; + int linenum=0; + int enemy_readlen=0; + int i,j; + f = fopen(filename,"r"); + if( f == NULL ){ + print( "ļʧ\n"); + return FALSE; + } + + ENEMY_enemynum=0; + while( fgets( line, sizeof( line ), f ) ){ + linenum ++; + if( line[0] == '#' )continue; /* comment */ + if( line[0] == '\n' )continue; /* none */ + chomp( line ); + + ENEMY_enemynum++; + } + + if( fseek( f, 0, SEEK_SET ) == -1 ){ + fprint( "Ѱʧ\n" ); + fclose(f); + return FALSE; + } + + ENEMY_enemy = allocateMemory( sizeof(struct tagENEMY_EnemyTable) + * ENEMY_enemynum ); + if( ENEMY_enemy == NULL ){ + fprint( "޷ڴ %d\n" , + sizeof(struct tagENEMY_EnemyTable)*ENEMY_enemynum); + fclose( f ); + return FALSE; + } + for( i = 0; i < ENEMY_enemynum; i ++ ) { + for( j = 0; j < ENEMY_DATAINTNUM; j ++ ) { + ENEMY_setInt( i,j,-1); + } + } + linenum = 0; + while( fgets( line, sizeof( line ), f ) ){ + linenum ++; + if( line[0] == '#' )continue; /* comment */ + if( line[0] == '\n' )continue; /* none */ + chomp( line ); + replaceString( line, '\t' , ' ' ); +{ + char buf[256]; + for( i = 0; i < strlen( line); i ++) { + if( line[i] != ' ' ) { + break; + } + strcpy( buf, &line[i]); + } + if( i != 0 ) { + strcpy( line, buf); + } +} +{ + char token[256]; + int ret; + + ret = getStringFromIndexWithDelim( line,",",1,token,sizeof(token)); + if( ret==FALSE ){ + fprint("ļ﷨:%s %d\n",filename,linenum); + continue; + } + ENEMY_setChar( enemy_readlen, ENEMY_NAME, token); + ret = getStringFromIndexWithDelim( line,",",2,token,sizeof(token)); + if( ret==FALSE ){ + fprint("ļ﷨:%s %d\n",filename,linenum); + continue; + } + ENEMY_setChar( enemy_readlen, ENEMY_TACTICSOPTION, token); +#ifdef _BATTLENPC_WARP_PLAYER + ret = getStringFromIndexWithDelim( line, ",", 3, token, sizeof(token)); + if(ret==FALSE){ + fprint("ļ﷨:%s %d\n",filename,linenum); + continue; + } + ENEMY_setChar( enemy_readlen, ENEMY_ACT_CONDITION, token); +#endif + +#ifdef _BATTLENPC_WARP_PLAYER +#define ENEMY_STARTINTNUM 4 +#else +#define ENEMY_STARTINTNUM 3 +#endif + + for( i = ENEMY_STARTINTNUM; i < ENEMY_DATAINTNUM+ENEMY_STARTINTNUM; i ++ ) { + ret = getStringFromIndexWithDelim( line,",",i,token,sizeof(token)); + if( ret==FALSE ){ + fprint("ļ﷨:%s %d\n",filename,linenum); + break; + } + ENEMY_setInt( enemy_readlen, i - ENEMY_STARTINTNUM, atoi( token)); + } + if( i < ENEMY_DATAINTNUM+ENEMY_STARTINTNUM ) continue; + for( i = 0; i < ENEMYTEMP_enemynum; i ++ ) { + if( ENEMYTEMP_getInt( i, E_T_TEMPNO)== ENEMY_getInt( enemy_readlen, ENEMY_TEMPNO)){ + break; + } + } + if( i == ENEMYTEMP_enemynum) { + fprint("ļ﷨:%s %d\n",filename,linenum); + continue; + } + ENEMY_enemy[enemy_readlen].enemytemparray = i; +{ + int lv_min, lv_max; + lv_min = ENEMY_getInt( enemy_readlen, ENEMY_LV_MIN); + lv_max = ENEMY_getInt( enemy_readlen, ENEMY_LV_MAX); + if( lv_min == 0 ) lv_min = lv_max; + ENEMY_setInt( enemy_readlen, ENEMY_LV_MIN, min( lv_min, lv_max)); + ENEMY_setInt( enemy_readlen, ENEMY_LV_MAX, max( lv_min, lv_max)); + +} + + enemy_readlen ++; +} + } + fclose(f); + ENEMY_enemynum = enemy_readlen; + print( "Ч %d..", ENEMY_enemynum ); + + return TRUE; +} +/*------------------------------------------------------------------------ + * ENEMY_enemyɬð̻ + *-----------------------------------------------------------------------*/ +BOOL ENEMY_reinitEnemy( void ) +{ + freeMemory( ENEMY_enemy); + return( ENEMY_initEnemy( getEnemyfile())); +} + +/*------------------------------------------------------------------------ + ENEMY_Enemyٯë + *-----------------------------------------------------------------------*/ +int ENEMY_getEnemyArrayFromIndex( int groupindex, int index) +{ + if( !GROUP_CHECKINDEX( groupindex)) return -1; + if( index < 0 || index >= CREATEPROB1 - ENEMY_ID1) return -1; + return GROUP_group[groupindex].enemyarray[index]; +} +/*------------------------------------------------------------------------ + * ENEMY_ID ENEMY_Enemyٯë + *-----------------------------------------------------------------------*/ +int ENEMY_getEnemyArrayFromId( int EnemyId) +{ + int i; + for( i = 0; i < ENEMY_enemynum; i ++ ) { + if( ENEMY_getInt( i, ENEMY_ID) == EnemyId) { + return i; + } + } + return -1; +} + +int ENEMY_getEnemyArrayFromTempNo( int EnemyTempNo) +{ + int i; + for( i = 0; i < ENEMY_enemynum; i ++ ) { + if( ENEMY_getInt( i, ENEMY_TEMPNO) == EnemyTempNo) { + return i; + } + } + return -1; +} + +int ENEMY_getEnemyIdFromTempNo( int EnemyTempNo) +{ + int i; + for( i = 0; i < ENEMY_enemynum; i ++ ) { + if( ENEMY_getInt( i, ENEMY_TEMPNO) == EnemyTempNo) { + return ENEMY_getInt( i, ENEMY_ID); + } + } + return -1; +} + +int ENEMY_getEnemyTempNoFromId( int EnemyId) +{ + int i; + for( i = 0; i < ENEMY_enemynum; i ++ ) { + if( ENEMY_getInt( i, ENEMY_ID) == EnemyId) { + return ENEMY_getInt( i, ENEMY_TEMPNO); + } + } + return -1; +} + +/*------------------------------------------------------------------------ + * ɬð̻ë + *-----------------------------------------------------------------------*/ +BOOL GROUP_initGroup( char* filename ) +{ + FILE* f; + char line[256]; + int linenum=0; + int group_readlen=0; + int i,j; + + f = fopen(filename,"r"); + if( f == NULL ){ + print( "ļʧ\n"); + return FALSE; + } + + GROUP_groupnum=0; + + /* ئ滥ϵؤ¾Ʃ */ + while( fgets( line, sizeof( line ), f ) ){ + linenum ++; + if( line[0] == '#' )continue; /* comment */ + if( line[0] == '\n' )continue; /* none */ + chomp( line ); + + GROUP_groupnum++; + } + + if( fseek( f, 0, SEEK_SET ) == -1 ){ + fprint( "Ѱʧ\n" ); + fclose(f); + return FALSE; + } + + GROUP_group = allocateMemory( sizeof(struct tagGROUP_Table) + * GROUP_groupnum ); + if( GROUP_group == NULL ){ + fprint( "޷ڴ %d\n" , + sizeof(struct tagGROUP_Table)*GROUP_groupnum); + fclose( f ); + return FALSE; + } + /* */ + for( i = 0; i < GROUP_groupnum; i ++ ) { + for( j = 0; j < GROUP_DATAINTNUM; j ++ ) { + GROUP_setInt( i,j,-1); + } + for( j = 0; j < CREATEPROB1 - ENEMY_ID1; j ++ ) { + GROUP_group[i].enemyarray[j] = -1; + } + } + + /* */ + linenum = 0; + while( fgets( line, sizeof( line ), f ) ){ + linenum ++; + if( line[0] == '#' )continue; /* comment */ + if( line[0] == '\n' )continue; /* none */ + chomp( line ); + + /* ë */ + /* tab ë " " 徧 */ + replaceString( line, '\t' , ' ' ); + /* ʸë£*/ +{ + char buf[256]; + for( i = 0; i < strlen( line); i ++) { + if( line[i] != ' ' ) { + break; + } + strcpy( buf, &line[i]); + } + if( i != 0 ) { + strcpy( line, buf); + } +} +{ + char token[256]; + int ret; + int loop; + + /* ֨պ ݼ׻ƻ */ + for( j = 0; j < GROUP_DATAINTNUM; j ++ ) { + GROUP_setInt( group_readlen,j,-1); + } + for( j = 0; j < CREATEPROB1 - ENEMY_ID1; j ++ ) { + GROUP_group[group_readlen].enemyarray[j] = -1; + } + + /* 繴ͼëέ */ + ret = getStringFromIndexWithDelim( line,",",1,token, + sizeof(token)); + if( ret==FALSE ){ + fprint("ļ﷨:%s %d\n",filename,linenum); + continue; + } + GROUP_setChar( group_readlen, GROUP_NAME, token); + + /* 2 ϷѰ */ +#define GROUP_STARTINTNUM 2 + for( i = GROUP_STARTINTNUM; i < GROUP_DATAINTNUM+GROUP_STARTINTNUM; i ++ ) { + ret = getStringFromIndexWithDelim( line,",",i,token, + sizeof(token)); + if( ret==FALSE ){ + fprint("ļ﷨:%s %d\n",filename,linenum); + break; + } + if( strlen( token) != 0 ) { + GROUP_setInt( group_readlen, i - GROUP_STARTINTNUM, atoi( token)); + } + } + if( i < GROUP_DATAINTNUM+GROUP_STARTINTNUM ) continue; + + { + int enemycnt = 0; + for( loop = ENEMY_ID1; loop < CREATEPROB1; loop ++ ) { + if( GROUP_getInt( group_readlen, loop) != -1 ) { + for( i = 0; i < ENEMY_enemynum; i ++ ) { + if( ENEMY_getInt( i, ENEMY_ID) + == GROUP_getInt( group_readlen, loop)) + { + break; + } + } + if( i == ENEMY_enemynum) { + i = -1; + GROUP_setInt( group_readlen, loop, -1); + } + else { + enemycnt ++; + } + GROUP_group[group_readlen].enemyarray[loop - ENEMY_ID1] = i; + } + } + if( enemycnt == 0 ) { + fprint("Ŷ趨еδ趨 ļ:%s %d\n",filename,linenum); + continue;; + } + if( checkRedundancy( &GROUP_group[group_readlen].intdata[ENEMY_ID1], + CREATEPROB1 - ENEMY_ID1)) + { + fprint("Ŷ趨еظ趨 ļ:%s %d\n",filename,linenum); + continue;; + } + + } + + + group_readlen ++; +} + } + fclose(f); + + GROUP_groupnum = group_readlen; + + print( "ЧȺ %d...", GROUP_groupnum ); + + return TRUE; +} +/*------------------------------------------------------------------------ + * ɬð̻ + *-----------------------------------------------------------------------*/ +BOOL GROUP_reinitGroup( void ) +{ + freeMemory( GROUP_group); + return( GROUP_initGroup( getGroupfile())); +} +/*------------------------------------------------------------------------ + * GROUP_ID GROUP_Groupٯë + *-----------------------------------------------------------------------*/ +int GROUP_getGroupArray( int groupid) +{ + int i; + for( i = 0; i < GROUP_groupnum; i ++ ) { + if( GROUP_getInt( i, GROUP_ID) == groupid) { + return i; + } + } + return -1; +} +/*------------------------------------------------------------------------ + * ë£ + *-----------------------------------------------------------------------*/ +static int ENEMY_getExp( int array,int tarray, int level, int rank ) +{ + int ret; + int *p; + int *tp; + float ranknum = 0.0; + float alpha; + struct { + int num; + float rank; + }ranktbl[] = { + { 100, 2.5}, + { 95, 2.0}, + { 90, 1.5}, + { 85, 1.0}, + { 80, 0.5}, + { 0, 0.0}, + }; + level --; + if( level < 0 || level >= arraysizeof( enemybaseexptbl)) return 0; + + p = ENEMY_enemy[array].intdata; + tp = ENEMYTEMP_enemy[tarray].intdata; + + // ¼; ë + if( rank < 0 || rank > 5 ) rank = 0; + ranknum = ranktbl[rank].rank; + + alpha = ( *( tp + E_T_CRITICAL) + *( tp + E_T_COUNTER) + *(tp + E_T_GET) + + *( tp + E_T_POISON) + *( tp + E_T_PARALYSIS) + *(tp + E_T_SLEEP) + + *( tp + E_T_STONE) + *( tp + E_T_DRUNK) + *(tp + E_T_CONFUSION) + ) / 100.0 + + *( tp + E_T_RARE); + /* EXP EXP֣ ¼͡ϫ ì*/ + //return enemybaseexptbl[*(p+ENEMY_LV)] + (ranknum + alpha)*(*(tp+ENEMY_LV)); + ret = enemybaseexptbl[level] + (ranknum + alpha)*(level+1); + return ( ret < 1 ) ? 1 : ret; + +} + + +int ENEMY_getRank( int array, int tarray ){ + int *p; + int *tp; + int paramsum; + int i; + int ranknum; + + struct { + int num; + float rank; + }ranktbl[] = { + { 100, 2.5}, //ܳɳ >= 100 petrank=0 + { 95, 2.0}, + { 90, 1.5}, + { 85, 1.0}, + { 80, 0.5}, + { 0, 0.0}, + }; + + p = ENEMY_enemy[array].intdata; + tp = ENEMYTEMP_enemy[tarray].intdata; + /* ¼ëң */ + /* ̤ëټǣ */ + paramsum = *( tp + E_T_BASEVITAL) + + *( tp + E_T_BASESTR) + + *( tp + E_T_BASETGH) + + *( tp + E_T_BASEDEX); + + ranknum = 0; // ɻ + for( i = 0; i < arraysizeof( ranktbl); i ++ ) { + if( paramsum >= ranktbl[i].num ) { + ranknum = i; + break; + } + } + + return ranknum; + +} + + +//********************************************************* +// ¼ĸةئ +//********************************************************* +static int EnemyGymSkill[] = { + PETSKILL_GUARDBREAK, // ⡰(3) + PETSKILL_CONTINUATIONATTACK1, // ߡ (10) + PETSKILL_CONTINUATIONATTACK2, // ࡰ (11) + PETSKILL_CONTINUATIONATTACK3, // ᡰ (12) + PETSKILL_CHARGE1, // ߡҡ(30) + PETSKILL_CHARGE2, // ࡰҡ(31) + PETSKILL_MIGHTY1, // ߡ ڽ(40) + PETSKILL_MIGHTY2, // ࡰ ڽ(41) + PETSKILL_POWERBALANCE1, // ߡ (50) + PETSKILL_POWERBALANCE2, // ࡰ (51) + PETSKILL_POWERBALANCE3, // ᡰ (52) + PETSKILL_POISON_ATTACK1, // ߡ (60) + PETSKILL_POISON_ATTACK2, // ࡰ (61) + PETSKILL_STONE, // ߡ޼ (80) + PETSKILL_CONFUSION_ATTACK, // ߡ (90) + PETSKILL_DRUNK_ATTACK, // ߨߡ (100) + PETSKILL_SLEEP_ATTACK, // ߡԻ (110) + PETSKILL_NOGUARD1, // ߡá(150) + PETSKILL_NOGUARD2, // ࡰá(151) + PETSKILL_NOGUARD3, // ᡰá(152) +#ifdef _PSKILL_FALLGROUND + PETSKILL_FALLGROUND, // +#endif +#ifdef _SKILL_DAMAGETOHP + PETSKILL_DAMAGETOHP, //Ѫ +#endif +#ifdef _Skill_MPDAMAGE + PETSKILL_MPDAMAGE, //MP˺ +#endif + +#ifdef _SKILL_WILDVIOLENT_ATT + PETSKILL_WILDVIOLENTATTACK, //(540)񱩹 vincent add 2002/05/16 +#endif +#ifdef _SKILL_SPEEDY_ATT + PETSKILL_SPEEDYATTACK, //(541)ٹ vincent add 2002/05/16 +#endif +#ifdef _SKILL_GUARDBREAK2 + PETSKILL_GUARDBREAK2, //(542)Ƴ2 vincent add 2002/05/20 +#endif +#ifdef _SKILL_SACRIFICE + PETSKILL_SACRIFICE, //(543)Ԯ vincent add 2002/05/30 +#endif +#ifdef _SKILL_WEAKEN + PETSKILL_WEAKEN, //(544)Ԯ vincent add 2002/07/11 +#endif +#ifdef _SKILL_DEEPPOISON + PETSKILL_DEEPPOISON, //(545)Ԯ vincent add 2002/07/16 +#endif +#ifdef _SKILL_BARRIER + PETSKILL_BARRIER, //(546)ħ vincent add 2002/07/16 +#endif +#ifdef _SKILL_NOCAST + PETSKILL_NOCAST, //(547)Ĭ vincent add 2002/07/16 +#endif +#ifdef _SKILL_ROAR + PETSKILL_ROAR, //(548) vincent add 2002/07/11 +#endif + +#ifdef _SKILL_REFRESH + PETSKILL_REFRESH, //(550)Ԯ vincent add 2002/08/08 +#endif +#ifdef _VARY_WOLF + PETSKILL_VARY, +#endif +#ifdef _PETSKILL_SETDUCK + PETSKILL_SETDUCK, +#endif + +#ifdef _MAGICPET_SKILL + PETSKILL_SETMAGICPET, +#endif +#ifdef _PETSKILL_BECOMEPIG + PETSKILL_BECOMEPIG, +#endif +#ifdef _PETSKILL_LER + PETSKILL_BATFLY, + PETSKILL_DIVIDEATTACK, +#endif +#ifdef _PETSKILL_BATTLE_MODEL + PETSKILL_BATTLE_MODEL, +#endif +}; + +static int gymbody[] = { + SPR_001em,SPR_011em,SPR_021em,SPR_031em,SPR_041em,SPR_051em, + SPR_061em,SPR_071em,SPR_081em,SPR_091em,SPR_101em,SPR_111em, + + SPR_002em,SPR_012em,SPR_022em,SPR_032em,SPR_042em,SPR_052em, + SPR_062em,SPR_072em,SPR_082em,SPR_092em,SPR_102em,SPR_112em, + + SPR_003em,SPR_013em,SPR_023em,SPR_033em,SPR_043em,SPR_053em, + SPR_063em,SPR_073em,SPR_083em,SPR_093em,SPR_103em,SPR_113em, + + SPR_004em,SPR_014em,SPR_024em,SPR_034em,SPR_044em,SPR_054em, + SPR_064em,SPR_074em,SPR_084em,SPR_094em,SPR_104em,SPR_114em, +}; + + +/*------------------------------------------------------------------------ + * ENEMY¼ĸةئ ëܸ + *-----------------------------------------------------------------------*/ +int ENEMY_RandomChange( int enemyindex, int tempno ) +{ + int work, work2, iRet = 0; + + // ¼ĸةƽҷ¾ + if( ( 564 <= tempno && tempno <= 580 ) + || ( 739 <= tempno && tempno <= 750 ) + || ( 895 <= tempno && tempno <= 906 ) + ){ + //******************************************** + // ӿ + //******************************************** + iRet = 1; + }else + // ¼ĸةƽҷ¾ + if( ( 655 <= tempno && tempno <= 720 ) + || ( 859 <= tempno && tempno <= 894 ) + || ( 907 <= tempno && tempno <= 940 ) + ){ + //******************************************** + // ʸӿ + //******************************************** + iRet = 2; + }else{ + return 0; + } + + + if( iRet == 1 ){ + //******************************************** + // + // ӿ׳ئƥַ¼ĸة + // + //******************************************** + // ϳַ¼ĸة + CHAR_setInt( enemyindex, CHAR_BASEBASEIMAGENUMBER, + gymbody[RAND( 0, arraysizeof( gymbody ) - 1)] ); + CHAR_setInt( enemyindex, CHAR_BASEIMAGENUMBER, + CHAR_getInt( enemyindex, CHAR_BASEBASEIMAGENUMBER ) ); + // 뷴 + work = ( RAND( 0, 20 ) - 10 ) * 10; + work2 = 100 - ABS( work ); + CHAR_setInt( enemyindex, CHAR_EARTHAT, work ); + CHAR_setInt( enemyindex, CHAR_FIREAT, -work ); + if( RAND( 0, 1 ) ){ + work2 *= -1; + } + CHAR_setInt( enemyindex, CHAR_WATERAT, work2 ); + CHAR_setInt( enemyindex, CHAR_WINDAT, -work2 ); + + // ¼ĸةئ տë + if( DoujyouRandomWeponSet( enemyindex ) ){ + // տɧ ë + CHAR_setPetSkill( enemyindex, 0, PETSKILL_NORMALATTACK ); + CHAR_setPetSkill( enemyindex, 1, PETSKILL_NORMALATTACK ); + }else{ + // տԪئмƥ + // ë + CHAR_setPetSkill( enemyindex, 0, + EnemyGymSkill[RAND( 0, arraysizeof( EnemyGymSkill ) - 1 )] ); + // ë + CHAR_setPetSkill( enemyindex, 1, + EnemyGymSkill[RAND( 0, arraysizeof( EnemyGymSkill ) - 1 )] ); + } + + }else + if( iRet == 2 ){ + // տԪئмƥ + // ë + CHAR_setPetSkill( enemyindex, 0, + EnemyGymSkill[RAND( 0, arraysizeof( EnemyGymSkill ) - 1 )] ); + // ë + CHAR_setPetSkill( enemyindex, 1, + EnemyGymSkill[RAND( 0, arraysizeof( EnemyGymSkill ) - 1 )] ); + } + + return 1; + +} + + +/*------------------------------------------------------------------------ + * ENEMY_enemyƽҷë£ + *-----------------------------------------------------------------------*/ +int ENEMY_createEnemy( int array, int baselevel ) +{ + Char CharNew; + int newindex; + int *p; + int tp[E_T_DATAINTNUM]; + int tarray, i; + int itemindex,iloop; + int level; + int enemyrank; + + if( !ENEMY_CHECKINDEX( array)) return -1; + + p = ENEMY_enemy[array].intdata; + tarray = ENEMYTEMP_getEnemyTempArray( array); + if( !ENEMYTEMP_CHECKINDEX( tarray)) return -1; +// tp = ENEMYTEMP_enemy[tarray].intdata; + // + for( i = 0; i < E_T_DATAINTNUM; i ++ ){ + tp[i] = ENEMYTEMP_enemy[tarray].intdata[i]; + } + + // + memset( &CharNew, 0, sizeof( Char ) ); + + if( !CHAR_getDefaultChar( &CharNew,31010 ) )return -1; + + /* į */ + CharNew.data[CHAR_BASEBASEIMAGENUMBER] + = CharNew.data[CHAR_BASEIMAGENUMBER] = *(tp+E_T_IMGNUMBER); + /* ƥؤɬ */ + CharNew.data[CHAR_WHICHTYPE] = CHAR_TYPEENEMY; + /* ë */ + CharNew.data[CHAR_DUELPOINT] = 0; + + /* ìë£ */ + if( baselevel > 0 ){ + level = baselevel; // ì + }else{ + level = RAND( (*(p + ENEMY_LV_MIN)), (*(p+ ENEMY_LV_MAX))); + } +#define E_PAR( a) (*(p + (a))) +#define ET_PAR( a) (*(tp + (a))) +/* ɷ¶϶Ѿ ˼ ɷ¶߼ңֿ */ +#if 1 +#define PARAM_CAL( l) ( ( level -1)*ET_PAR( E_T_LVUPPOINT)+ ET_PAR(E_T_INITNUM)) * ET_PAR( (l)) +#else +#define PARAM_CAL( l) ( (E_PAR(ENEMY_LV) -1)*ET_PAR( E_T_LVUPPOINT)+ ET_PAR(E_T_INITNUM)) * ET_PAR( (l)) +#endif + /* ԻԻ̼士ë¼ĸةƥ浤 */ + tp[E_T_BASEVITAL] += RAND( 0, 4 ) - 2; + tp[E_T_BASESTR] += RAND( 0, 4 ) - 2; + tp[E_T_BASETGH] += RAND( 0, 4 ) - 2; + tp[E_T_BASEDEX] += RAND( 0, 4 ) - 2; + /* ƥԻԻ̼ëƻ */ + CharNew.data[CHAR_ALLOCPOINT] + = ( tp[E_T_BASEVITAL] << 24 ) + + ( tp[E_T_BASESTR] << 16 ) + + ( tp[E_T_BASETGH] << 8 ) + + ( tp[E_T_BASEDEX] << 0 ); + /* ¼ĸةƥ̼ë𹴵ң۳ľë߼Ի߯ʣ*/ + for( i = 0; i < 10; i ++ ){ + int work = RAND( 0, 3 ); + if( work == 0 )tp[E_T_BASEVITAL]++; + if( work == 1 )tp[E_T_BASESTR]++; + if( work == 2 )tp[E_T_BASETGH]++; + if( work == 3 )tp[E_T_BASEDEX]++; + } + + /* ɷ¶ */ + CharNew.data[CHAR_VITAL] = PARAM_CAL(E_T_BASEVITAL); + CharNew.data[CHAR_STR] = PARAM_CAL(E_T_BASESTR); + CharNew.data[CHAR_TOUGH] = PARAM_CAL(E_T_BASETGH); + CharNew.data[CHAR_DEX] = PARAM_CAL(E_T_BASEDEX); + CharNew.data[CHAR_FIREAT] = *(tp+ E_T_FIREAT); + CharNew.data[CHAR_WATERAT] = *(tp+ E_T_WATERAT); + CharNew.data[CHAR_EARTHAT] = *(tp+ E_T_EARTHAT); + CharNew.data[CHAR_WINDAT] = *(tp+ E_T_WINDAT); + CharNew.data[CHAR_MODAI] = *(tp+ E_T_MODAI); + CharNew.data[CHAR_VARIABLEAI] = 0; + CharNew.data[CHAR_LV] = level; + //CharNew.data[CHAR_LV] = *(p+ ENEMY_LV); + CharNew.data[CHAR_SLOT] = *(tp+ E_T_SLOT); + CharNew.data[CHAR_POISON] = *(tp+ E_T_POISON); + CharNew.data[CHAR_PARALYSIS]= *(tp+ E_T_PARALYSIS); + CharNew.data[CHAR_SLEEP] = *(tp+ E_T_SLEEP); + CharNew.data[CHAR_STONE] = *(tp+ E_T_STONE); + CharNew.data[CHAR_DRUNK] = *(tp+ E_T_DRUNK); + CharNew.data[CHAR_CONFUSION]= *(tp+ E_T_CONFUSION); + CharNew.data[CHAR_RARE] = *(tp+ E_T_RARE); + CharNew.data[CHAR_PETID] = *(tp + E_T_TEMPNO); + CharNew.data[CHAR_CRITIAL] = *(tp + E_T_CRITICAL); + CharNew.data[CHAR_COUNTER] = *(tp + E_T_COUNTER); + CharNew.data[CHAR_PETENEMYID] = ENEMY_getInt( array, ENEMY_ID); + + for( i = 0; i < CHAR_MAXPETSKILLHAVE; i ++ ) { + CharNew.unionTable.indexOfPetskill[i] = *(tp + E_T_PETSKILL1 + i); + } + enemyrank = ENEMY_getRank( array, tarray ); + CharNew.data[CHAR_PETRANK] = enemyrank; +#undef E_PAR +#undef ET_PAR +#undef PARAM_CAL + CharNew.data[CHAR_DUELPOINT] = *( p + ENEMY_DUELPOINT); + if( *( p + ENEMY_DUELPOINT) <= 0 ) { + if( *(p + ENEMY_EXP) != -1 ) { + CharNew.data[CHAR_EXP] = *( p+ENEMY_EXP); + }else { + CharNew.data[CHAR_EXP] = ENEMY_getExp( array,tarray,level, enemyrank); + } + } + strcpysafe( CharNew.string[CHAR_NAME].string, + sizeof(CharNew.string[CHAR_NAME].string), + (char *)ENEMYTEMP_enemy[tarray].chardata[E_T_NAME].string ); + + newindex = CHAR_initCharOneArray( &CharNew ); +#ifdef _CAX_LVTISHI +if (CHAR_getInt( newindex, CHAR_LV) == 1){// + char buff[256]; + snprintf( buff, sizeof( buff),"%s",CHAR_getChar( newindex, CHAR_NAME)); + CHAR_setChar( newindex, CHAR_NAME, buff); + } +#endif + if( newindex < 0 ){ + return -1; + } + for( iloop=0; iloop< (ENEMY_ITEMPROB10 - ENEMY_ITEM1+1)/2; iloop++){ + if( *(p+ENEMY_ITEMPROB1+iloop) != 0) { +#ifdef _FIX_ITEMPROB + if( RAND( 0,999) < *(p+ENEMY_ITEMPROB1+iloop)){ +#else + if( RAND( 0,99) < *(p+ENEMY_ITEMPROB1+iloop)){ +#endif + itemindex = ITEM_makeItemAndRegist( *(p+ENEMY_ITEM1+iloop) ); + CHAR_setItemIndex( newindex, CHAR_STARTITEMARRAY +iloop, itemindex); + ITEM_setWorkInt( itemindex, ITEM_WORKCHARAINDEX, newindex ); + ITEM_setWorkInt( itemindex, ITEM_WORKOBJINDEX,-1); + + } + } + } + + { int style, wepon = -1; + style = (*(p + ENEMY_STYLE)); + switch( style ){ + case 1: wepon = 0;break; // + case 2: wepon = 100;break; // + case 3: wepon = 200;break; // + case 4: wepon = 400;break; // + case 5: wepon = 500;break; // Ƥ¼ + case 6: wepon = 700;break; // + case 7: wepon = 600;break; // + default:break; + } + if( wepon >= 0 ){ + itemindex = ITEM_makeItemAndRegist( wepon ) ; + CHAR_setItemIndex( newindex, CHAR_ARM, itemindex ); + ITEM_setWorkInt( itemindex, ITEM_WORKCHARAINDEX, newindex ); + ITEM_setWorkInt( itemindex, ITEM_WORKOBJINDEX,-1); + } + } + + ENEMY_RandomChange( newindex, *( p+ENEMY_ID) ); + CHAR_complianceParameter( newindex ); + + CHAR_setInt( newindex, CHAR_HP, CHAR_getWorkInt( newindex, CHAR_WORKMAXHP)); + CHAR_setWorkInt( newindex, CHAR_WORKTACTICS, *(p+ENEMY_TACTICS)); + CHAR_setWorkChar( newindex, CHAR_WORKBATTLE_TACTICSOPTION, + ENEMY_enemy[array].chardata[ENEMY_TACTICSOPTION].string ); +#ifdef _BATTLENPC_WARP_PLAYER + CHAR_setWorkChar( newindex, CHAR_WORKBATTLE_ACT_CONDITION, + ENEMY_enemy[array].chardata[ENEMY_ACT_CONDITION].string ); +#endif + CHAR_setWorkInt( newindex, CHAR_WORK_PETFLG, *(p+ENEMY_PETFLG)); + CHAR_setWorkInt( newindex, CHAR_WORKMODCAPTUREDEFAULT, *(tp + E_T_GET)); +#ifdef _ENEMY_FALLGROUND + { + int i=0; + for( i=0;i= arraysizeof( RandomEnemyTbl ) ) return 0; + + // ¼ĸةɬ + randwork = RAND( 0, RandomEnemyTbl[i].arraysize - 1 ); + // ޥ įë + work = RandomEnemyTbl[i].pTbl[randwork]; + *pNew = ENEMY_getEnemyArrayFromId( work ); + return 1; + }else{ + // ئ + return 0; + } +} + +int *ENEMY_getEnemy( int charaindex, int x, int y) +{ + int i; + int array; + int g_array; + int e_array; + int found = 0; + int work[ENEMY_INDEXTABLEMAXSIZE]; + int wr[ENEMY_INDEXTABLEMAXSIZE]; + int createenemynum; + int enemyentrymax; + int entrymax; + int r_max; + int groupid; + int bigcnt; + int loopcounter; + array = ENCOUNT_getEncountAreaArray( CHAR_getInt( charaindex, CHAR_FLOOR),x,y); + if( array == -1 ) return NULL; + enemyentrymax = ENCOUNT_getCreateEnemyMaxNumFromArray( array); + if( enemyentrymax == -1 ) { + return NULL; + } + for( i = 0 ; i < ENEMY_INDEXTABLEMAXSIZE; i ++ ) { + work[i] = -1; + wr[i] = -1; + ENEMY_indextable[i] = -1; + } + + r_max= 0; + for( i = 0; i < ENCOUNT_GROUPMAXNUM; i ++ ){ + if( ENCOUNT_getGroupIdFromArray( array, i ) != - 1 ) { + int itemid; + groupid = ENCOUNT_getGroupIdFromArray( array, i); + g_array = GROUP_getGroupArray( groupid); + itemid = GROUP_getInt( g_array, GROUP_APPEARBYITEMID); + if( itemid != -1 ) { + int j; + for( j = 0; j < CHAR_MAXITEMHAVE; j ++ ) { + int itemindex = CHAR_getItemIndex( charaindex, j); + if( ITEM_CHECKINDEX( itemindex)) { + if( ITEM_getInt( itemindex, ITEM_ID) == itemid){ + break; + } + } + } + if( j == CHAR_MAXITEMHAVE ) continue; + } + itemid = GROUP_getInt( g_array, GROUP_NOTAPPEARBYITEMID); + if( itemid != -1 ) { + int j; + for( j = 0; j < CHAR_MAXITEMHAVE; j ++ ) { + int itemindex = CHAR_getItemIndex( charaindex, j); + if( ITEM_CHECKINDEX( itemindex)) { + if( ITEM_getInt( itemindex, ITEM_ID) == itemid){ + break; + } + } + } + if( j != CHAR_MAXITEMHAVE ) continue; + } + + work[found] = i; + wr[found] = ENCOUNT_getGroupProbFromArray( array, i); + r_max += wr[found]; + found ++; + } + } + r_max --; + + if( found <= 0 ) return NULL; + { + int aaa = 0; + int r; + r = RAND( 0, r_max); + for( i = 0; i < found-1; i ++ ) { + aaa += wr[i]; + if( wr[i] != 0 && r < aaa ) break; + } + r = i; + + groupid = ENCOUNT_getGroupIdFromArray( array, work[r]); + g_array = GROUP_getGroupArray( groupid); + } + for( i = 0 ; i < ENEMY_INDEXTABLEMAXSIZE; i ++ ) { + work[i] = -1; + wr[i] = -1; + } + createenemynum = 0; + found = 0; + r_max = 0; + for( i = ENEMY_ID1; i < CREATEPROB1; i ++ ) { + int newarray, enemywork; + e_array = ENEMY_getEnemyArrayFromIndex( g_array, i - ENEMY_ID1 ); + +#ifdef _ADD_ENCOUNT // WON ADD ӵ޼ + { + int char_event_now = -1, char_event_end = -1; + if(ENCOUNT_table[array].event_now != -1){ + char_event_now = ENCOUNT_table[array].event_now; + } + else if(ENCOUNT_table[array].event_end != -1){ + char_event_end = ENCOUNT_table[array].event_end; + } + if( (char_event_now > 0) || ( char_event_end > 0 ) ) { + if( (NPC_NowEventCheckFlg( charaindex, char_event_now) == TRUE ) || + (NPC_EventCheckFlg( charaindex, char_event_end) == TRUE ) ){ + + e_array = ENEMY_getEnemyArrayFromIndex( + GROUP_getGroupArray( ENCOUNT_table[array].enemy_group ),i - ENEMY_ID1 ); + } + } + } +#endif + enemywork = ENEMY_getInt( e_array, ENEMY_ID ); + if( ENEMY_RandomEnemyArray( enemywork, &newarray ) ){ + e_array = newarray; + } + + if( e_array != -1 ) { + work[found] = e_array; + wr[found] = GROUP_getInt( g_array, i + (CREATEPROB1 - ENEMY_ID1)); + r_max += wr[found]; + found ++; + createenemynum += ENEMY_getInt( e_array, ENEMY_CREATEMAXNUM); + } + } + r_max --; + + if( found <= 0 ) return NULL; + enemyentrymax= min( enemyentrymax, createenemynum ); + entrymax = RAND( 1, enemyentrymax); + bigcnt = 0; + for( i = 0,loopcounter = 0; i < entrymax && loopcounter < 100; loopcounter ++) { + int cnt; + int j,r; + int aaa = 0; + int et_array; + int k,samecount; + r = RAND( 0, r_max); + for( j = 0; j < found-1; j ++ ) { + aaa += wr[j]; + if( wr[j] != 0 && r < aaa ) break; + } + r = j; + cnt = 0; + for( j = 0; j < ENEMY_INDEXTABLEMAXSIZE && ENEMY_indextable[j] != -1; j ++ ) { + if( ENEMY_indextable[j] == work[r] ) cnt ++; + } + samecount = 0; + for( k = 0; k < found; k ++ ) { + if( work[r] == work[k] ) samecount ++; + } + if( cnt >= ENEMY_getInt( work[r], ENEMY_CREATEMAXNUM) * samecount ) { + continue; + } + + et_array = ENEMYTEMP_getEnemyTempArray( work[r]); + if( ENEMYTEMP_CHECKINDEX( et_array)) { + if( ENEMYTEMP_getInt( et_array, E_T_SIZE) == E_T_SIZE_BIG ) { + if( bigcnt >= 5 ) { + entrymax --; + continue; + } + if( i > 4 ) { + int target_et_array; + int flg = FALSE; + for( j = 0; j < 5; j ++ ) { + if( !ENEMY_CHECKINDEX( ENEMY_indextable[j])) break; + + target_et_array = ENEMYTEMP_getEnemyTempArray( + ENEMY_indextable[j]); + if( !ENEMYTEMP_CHECKINDEX( target_et_array)) break; + if( ENEMYTEMP_getInt( target_et_array, E_T_SIZE) == E_T_SIZE_NORMAL ){ + flg = TRUE; + break; + } + } + if( !flg) continue; + ENEMY_indextable[i] = ENEMY_indextable[j]; + ENEMY_indextable[j] = work[r]; + } + else { + ENEMY_indextable[i] = work[r]; + } + bigcnt ++; + }else { + ENEMY_indextable[i] = work[r]; + } + + i++; + } + } + return found > 0 ? ENEMY_indextable : NULL; +} +int ENEMY_createPetFromEnemyIndex( int charaindex, int array) +{ + Char CharNew; + int newindex; + int *p; + int tp[E_T_DATAINTNUM]; + int tarray, i; + int havepetelement; + int level; + int enemyrank; + if( !ENEMY_CHECKINDEX( array)) return -1; + havepetelement = CHAR_getCharPetElement( charaindex); + if( havepetelement < 0 ) return -1; + + p = ENEMY_enemy[array].intdata; + tarray = ENEMYTEMP_getEnemyTempArray( array); + if( !ENEMYTEMP_CHECKINDEX( tarray)) return -1; +// tp = ENEMYTEMP_enemy[tarray].intdata; + for( i = 0; i < E_T_DATAINTNUM; i ++ ){ + tp[i] = ENEMYTEMP_enemy[tarray].intdata[i]; + } + memset( &CharNew, 0, sizeof( Char ) ); + if( !CHAR_getDefaultChar( &CharNew,31010 ) )return -1; + CharNew.data[CHAR_BASEBASEIMAGENUMBER] + = CharNew.data[CHAR_BASEIMAGENUMBER] = *(tp+E_T_IMGNUMBER); + CharNew.data[CHAR_WHICHTYPE] = CHAR_TYPEPET; + level = RAND( (*(p + ENEMY_LV_MIN)), ( *(p+ ENEMY_LV_MAX))); + +#define E_PAR( a) (*(p + (a))) +#define ET_PAR( a) (*(tp + (a))) +#if 1 +#define PARAM_CAL( l) (( level -1)*ET_PAR( E_T_LVUPPOINT)+ ET_PAR(E_T_INITNUM)) * ET_PAR( (l)) +#else +#define PARAM_CAL( l) ( (E_PAR(ENEMY_LV) -1)*ET_PAR( E_T_LVUPPOINT)+ ET_PAR(E_T_INITNUM)) * ET_PAR( (l)) +#endif + tp[E_T_BASEVITAL] += RAND( 0, 4 ) - 2; + tp[E_T_BASESTR] += RAND( 0, 4 ) - 2; + tp[E_T_BASETGH] += RAND( 0, 4 ) - 2; + tp[E_T_BASEDEX] += RAND( 0, 4 ) - 2; + CharNew.data[CHAR_ALLOCPOINT] + = ( tp[E_T_BASEVITAL] << 24 ) + + ( tp[E_T_BASESTR] << 16 ) + + ( tp[E_T_BASETGH] << 8 ) + + ( tp[E_T_BASEDEX] << 0 ); + + for( i = 0; i < 10; i ++ ){ + int work = RAND( 0, 3 ); + if( work == 0 )tp[E_T_BASEVITAL]++; + if( work == 1 )tp[E_T_BASESTR]++; + if( work == 2 )tp[E_T_BASETGH]++; + if( work == 3 )tp[E_T_BASEDEX]++; + } + /* ɷ¶ */ + CharNew.data[CHAR_VITAL] = PARAM_CAL(E_T_BASEVITAL); + CharNew.data[CHAR_STR] = PARAM_CAL(E_T_BASESTR); + CharNew.data[CHAR_TOUGH] = PARAM_CAL(E_T_BASETGH); + CharNew.data[CHAR_DEX] = PARAM_CAL(E_T_BASEDEX); + + CharNew.data[CHAR_FIREAT] = *(tp+ E_T_FIREAT); + CharNew.data[CHAR_WATERAT] = *(tp+ E_T_WATERAT); + CharNew.data[CHAR_EARTHAT] = *(tp+ E_T_EARTHAT); + CharNew.data[CHAR_WINDAT] = *(tp+ E_T_WINDAT); + + CharNew.data[CHAR_SLOT] = *(tp+ E_T_SLOT); + CharNew.data[CHAR_MODAI] = *(tp+ E_T_MODAI); + CharNew.data[CHAR_VARIABLEAI] = 0; + CharNew.data[CHAR_LV] = level; + //CharNew.data[CHAR_LV] = *(p+ ENEMY_LV); + CharNew.data[CHAR_POISON] = *(tp+ E_T_POISON); + CharNew.data[CHAR_PARALYSIS]= *(tp+ E_T_PARALYSIS); + CharNew.data[CHAR_SLEEP] = *(tp+ E_T_SLEEP); + CharNew.data[CHAR_STONE] = *(tp+ E_T_STONE); + CharNew.data[CHAR_DRUNK] = *(tp+ E_T_DRUNK); + CharNew.data[CHAR_CONFUSION]= *(tp+ E_T_CONFUSION); + CharNew.data[CHAR_RARE] = *(tp+ E_T_RARE); + CharNew.data[CHAR_PETID] = *(tp + E_T_TEMPNO); + CharNew.data[CHAR_CRITIAL] = *(tp + E_T_CRITICAL); + CharNew.data[CHAR_COUNTER] = *(tp + E_T_COUNTER); + CharNew.data[CHAR_PETENEMYID] = ENEMY_getInt( array, ENEMY_ID); + // Arminius 8.6 limit lv + CharNew.data[CHAR_LIMITLEVEL] = *(tp + E_T_LIMITLEVEL); +#ifdef _PET_FUSION + CharNew.data[CHAR_FUSIONCODE] = *(tp + E_T_FUSIONCODE); +#endif + CharNew.data[CHAR_PETMAILEFFECT] = RAND(0, PETMAIL_EFFECTMAX); + for( i = 0; i < CHAR_MAXPETSKILLHAVE; i ++ ) { + CharNew.unionTable.indexOfPetskill[i] = *(tp + E_T_PETSKILL1 + i); + } + enemyrank = ENEMY_getRank( array, tarray ); + CharNew.data[CHAR_PETRANK] = enemyrank; +#undef E_PAR +#undef ET_PAR +#undef PARAM_CAL + strcpysafe( CharNew.string[CHAR_NAME].string, + sizeof(CharNew.string[CHAR_NAME].string), + (char *)ENEMYTEMP_enemy[tarray].chardata[E_T_NAME].string ); + newindex = PET_initCharOneArray( &CharNew ); + if( newindex < 0 ){ + return -1; + } + CHAR_complianceParameter( newindex ); + CHAR_setInt( newindex, CHAR_HP, CHAR_getWorkInt( newindex, CHAR_WORKMAXHP)); + CHAR_setWorkInt( newindex, CHAR_WORKPLAYERINDEX, charaindex); + CHAR_setCharPet( charaindex, havepetelement, newindex); + CHAR_setChar( newindex, CHAR_OWNERCDKEY, + CHAR_getChar( charaindex, CHAR_CDKEY)); + CHAR_setChar( newindex, CHAR_OWNERCHARANAME, + CHAR_getChar( charaindex, CHAR_NAME)); + return newindex; +} + +int ENEMY_createPet( int array, int vital, int str, int tgh, int dex) +{ + Char CharNew; + int newindex; + int *p; + int tp[E_T_DATAINTNUM]; + int tarray, i; + int level; + int enemyrank; + if( !ENEMY_CHECKINDEX( array)) return -1; + + p = ENEMY_enemy[array].intdata; + tarray = ENEMYTEMP_getEnemyTempArray( array); + if( !ENEMYTEMP_CHECKINDEX( tarray)) return -1; +// tp = ENEMYTEMP_enemy[tarray].intdata; + for( i = 0; i < E_T_DATAINTNUM; i ++ ){ + tp[i] = ENEMYTEMP_enemy[tarray].intdata[i]; + } + memset( &CharNew, 0, sizeof( Char ) ); + if( !CHAR_getDefaultChar( &CharNew,31010 ) )return -1; + CharNew.data[CHAR_BASEBASEIMAGENUMBER] + = CharNew.data[CHAR_BASEIMAGENUMBER] = *(tp+E_T_IMGNUMBER); + CharNew.data[CHAR_WHICHTYPE] = CHAR_TYPEPET; + level = RAND( (*(p + ENEMY_LV_MIN)), ( *(p+ ENEMY_LV_MAX))); + +#define E_PAR( a) (*(p + (a))) +#define ET_PAR( a) (*(tp + (a))) +#if 1 +#define PARAM_CAL( l) (( level -1)*ET_PAR( E_T_LVUPPOINT)+ ET_PAR(E_T_INITNUM)) * ET_PAR( (l)) +#else +#define PARAM_CAL( l) ( (E_PAR(ENEMY_LV) -1)*ET_PAR( E_T_LVUPPOINT)+ ET_PAR(E_T_INITNUM)) * ET_PAR( (l)) +#endif + tp[E_T_BASEVITAL] += RAND( 0, 4 ) - 2; + tp[E_T_BASESTR] += RAND( 0, 4 ) - 2; + tp[E_T_BASETGH] += RAND( 0, 4 ) - 2; + tp[E_T_BASEDEX] += RAND( 0, 4 ) - 2; + + +#ifdef _BT_PET + tp[E_T_BASEVITAL]*= getBtPet(); + tp[E_T_BASESTR]*= getBtPet(); + tp[E_T_BASETGH]*= getBtPet(); + tp[E_T_BASEDEX]*= getBtPet(); +#endif + + + if(vital > -1){ + tp[E_T_BASEVITAL] = vital; + } + if(str > -1){ + tp[E_T_BASESTR] = str; + } + if(tgh > -1){ + tp[E_T_BASETGH] = tgh; + } + if(dex > -1){ + tp[E_T_BASEDEX] = dex; + } + + CharNew.data[CHAR_ALLOCPOINT] + = ( tp[E_T_BASEVITAL] << 24) + + ( tp[E_T_BASESTR] << 16) + + ( tp[E_T_BASETGH] << 8) + + ( tp[E_T_BASEDEX] << 0); + + + for( i = 0; i < 10; i ++ ){ + int work = RAND( 0, 3 ); + if( work == 0 )tp[E_T_BASEVITAL]++; + if( work == 1 )tp[E_T_BASESTR]++; + if( work == 2 )tp[E_T_BASETGH]++; + if( work == 3 )tp[E_T_BASEDEX]++; + } + /* ɷ¶ */ + CharNew.data[CHAR_VITAL] = PARAM_CAL(E_T_BASEVITAL); + CharNew.data[CHAR_STR] = PARAM_CAL(E_T_BASESTR); + CharNew.data[CHAR_TOUGH] = PARAM_CAL(E_T_BASETGH); + CharNew.data[CHAR_DEX] = PARAM_CAL(E_T_BASEDEX); + + CharNew.data[CHAR_FIREAT] = *(tp+ E_T_FIREAT); + CharNew.data[CHAR_WATERAT] = *(tp+ E_T_WATERAT); + CharNew.data[CHAR_EARTHAT] = *(tp+ E_T_EARTHAT); + CharNew.data[CHAR_WINDAT] = *(tp+ E_T_WINDAT); + + CharNew.data[CHAR_SLOT] = *(tp+ E_T_SLOT); + CharNew.data[CHAR_MODAI] = *(tp+ E_T_MODAI); + CharNew.data[CHAR_VARIABLEAI] = 0; + CharNew.data[CHAR_LV] = level; + //CharNew.data[CHAR_LV] = *(p+ ENEMY_LV); + CharNew.data[CHAR_POISON] = *(tp+ E_T_POISON); + CharNew.data[CHAR_PARALYSIS]= *(tp+ E_T_PARALYSIS); + CharNew.data[CHAR_SLEEP] = *(tp+ E_T_SLEEP); + CharNew.data[CHAR_STONE] = *(tp+ E_T_STONE); + CharNew.data[CHAR_DRUNK] = *(tp+ E_T_DRUNK); + CharNew.data[CHAR_CONFUSION]= *(tp+ E_T_CONFUSION); + CharNew.data[CHAR_RARE] = *(tp+ E_T_RARE); + CharNew.data[CHAR_PETID] = *(tp + E_T_TEMPNO); + CharNew.data[CHAR_CRITIAL] = *(tp + E_T_CRITICAL); + CharNew.data[CHAR_COUNTER] = *(tp + E_T_COUNTER); + // Arminius 8.6 limit lv + CharNew.data[CHAR_LIMITLEVEL] = *(tp + E_T_LIMITLEVEL); +#ifdef _PET_FUSION + CharNew.data[CHAR_FUSIONCODE] = *(tp + E_T_FUSIONCODE); +#endif + CharNew.data[CHAR_PETMAILEFFECT] = RAND(0, PETMAIL_EFFECTMAX); + for( i = 0; i < CHAR_MAXPETSKILLHAVE; i ++ ) { + CharNew.unionTable.indexOfPetskill[i] = *(tp + E_T_PETSKILL1 + i); + } + enemyrank = ENEMY_getRank( array, tarray ); + CharNew.data[CHAR_PETRANK] = enemyrank; +#undef E_PAR +#undef ET_PAR +#undef PARAM_CAL + strcpysafe( CharNew.string[CHAR_NAME].string, + sizeof(CharNew.string[CHAR_NAME].string), + (char *)ENEMYTEMP_enemy[tarray].chardata[E_T_NAME].string ); + newindex = PET_initCharOneArray( &CharNew ); + if( newindex < 0 ){ + return -1; + } + CHAR_complianceParameter( newindex ); + CHAR_setInt( newindex, CHAR_HP, CHAR_getWorkInt( newindex, CHAR_WORKMAXHP)); + CHAR_setWorkInt( newindex, CHAR_WORKPLAYERINDEX, -1); + + return newindex; +} + +int ENEMY_createPetFromEnemyBaseIndex( int charaindex, int array, int level ) +{ + Char CharNew; + int newindex; + //int *p; + int tp[E_T_DATAINTNUM]; + int tarray, i; + int havepetelement; + //int level; + int enemyrank; + + /* +#ifdef _LF_FIX_ERROR_PET_CREATE + if( !ENEMY_getUse(array) ) return -1; +#else + if( !ENEMY_CHECKINDEX( array)) return -1; +#endif + */ + havepetelement = CHAR_getCharPetElement( charaindex); + if( havepetelement < 0 ) return -1; + + //p = ENEMY_enemy[array].intdata; + tarray = ENEMYTEMP_getEnemyTempArrayFromTempNo( array); + + tarray = array; + +#ifdef _LF_FIX_ERROR_PET_CREATE + if( !ENEMYTEMP_getUse(tarray) ) return -1; +#else + if( !ENEMYTEMP_CHECKINDEX( tarray)) return -1; +#endif +// tp = ENEMYTEMP_enemy[tarray].intdata; + for( i = 0; i < E_T_DATAINTNUM; i ++ ){ + tp[i] = ENEMYTEMP_enemy[tarray].intdata[i]; + } + memset( &CharNew, 0, sizeof( Char ) ); + if( !CHAR_getDefaultChar( &CharNew,31010 ) )return -1; + CharNew.data[CHAR_BASEBASEIMAGENUMBER] + = CharNew.data[CHAR_BASEIMAGENUMBER] = *(tp+E_T_IMGNUMBER); + CharNew.data[CHAR_WHICHTYPE] = CHAR_TYPEPET; + //level = RAND( (*(p + ENEMY_LV_MIN)), ( *(p+ ENEMY_LV_MAX))); + +//#define E_PAR( a) (*(p + (a))) +#define ET_PAR( a) (*(tp + (a))) +#if 1 +#define PARAM_CAL( l) (( level -1)*ET_PAR( E_T_LVUPPOINT)+ ET_PAR(E_T_INITNUM)) * ET_PAR( (l)) +#else +#define PARAM_CAL( l) ( (E_PAR(ENEMY_LV) -1)*ET_PAR( E_T_LVUPPOINT)+ ET_PAR(E_T_INITNUM)) * ET_PAR( (l)) +#endif + tp[E_T_BASEVITAL] += RAND( 0, 4 ) - 2; + tp[E_T_BASESTR] += RAND( 0, 4 ) - 2; + tp[E_T_BASETGH] += RAND( 0, 4 ) - 2; +#ifdef _FIX_DEX_BUG + tp[E_T_BASEDEX] += RAND( 2, 4 ) - 2; +#else + tp[E_T_BASEDEX] += RAND( 0, 4 ) - 2; +#endif + CharNew.data[CHAR_ALLOCPOINT] + = ( tp[E_T_BASEVITAL] << 24 ) + + ( tp[E_T_BASESTR] << 16 ) + + ( tp[E_T_BASETGH] << 8 ) + + ( tp[E_T_BASEDEX] << 0 ); + + for( i = 0; i < 10; i ++ ){ + int work = RAND( 0, 3 ); + if( work == 0 )tp[E_T_BASEVITAL]++; + if( work == 1 )tp[E_T_BASESTR]++; + if( work == 2 )tp[E_T_BASETGH]++; + if( work == 3 )tp[E_T_BASEDEX]++; + } + /* ɷ¶ */ + CharNew.data[CHAR_VITAL] = PARAM_CAL(E_T_BASEVITAL); + CharNew.data[CHAR_STR] = PARAM_CAL(E_T_BASESTR); + CharNew.data[CHAR_TOUGH] = PARAM_CAL(E_T_BASETGH); + CharNew.data[CHAR_DEX] = PARAM_CAL(E_T_BASEDEX); + + CharNew.data[CHAR_FIREAT] = *(tp+ E_T_FIREAT); + CharNew.data[CHAR_WATERAT] = *(tp+ E_T_WATERAT); + CharNew.data[CHAR_EARTHAT] = *(tp+ E_T_EARTHAT); + CharNew.data[CHAR_WINDAT] = *(tp+ E_T_WINDAT); + + CharNew.data[CHAR_SLOT] = *(tp+ E_T_SLOT); + CharNew.data[CHAR_MODAI] = *(tp+ E_T_MODAI); + CharNew.data[CHAR_VARIABLEAI] = 0; + CharNew.data[CHAR_LV] = level; + //CharNew.data[CHAR_LV] = *(p+ ENEMY_LV); + CharNew.data[CHAR_POISON] = *(tp+ E_T_POISON); + CharNew.data[CHAR_PARALYSIS]= *(tp+ E_T_PARALYSIS); + CharNew.data[CHAR_SLEEP] = *(tp+ E_T_SLEEP); + CharNew.data[CHAR_STONE] = *(tp+ E_T_STONE); + CharNew.data[CHAR_DRUNK] = *(tp+ E_T_DRUNK); + CharNew.data[CHAR_CONFUSION]= *(tp+ E_T_CONFUSION); + CharNew.data[CHAR_RARE] = *(tp+ E_T_RARE); + CharNew.data[CHAR_PETID] = *(tp + E_T_TEMPNO); + CharNew.data[CHAR_CRITIAL] = *(tp + E_T_CRITICAL); + CharNew.data[CHAR_COUNTER] = *(tp + E_T_COUNTER); + // Arminius 8.6 limit lv + CharNew.data[CHAR_LIMITLEVEL] = *(tp + E_T_LIMITLEVEL); +#ifdef _PET_FUSION + CharNew.data[CHAR_FUSIONCODE] = *(tp + E_T_FUSIONCODE); +#endif + CharNew.data[CHAR_PETMAILEFFECT] = RAND(0, PETMAIL_EFFECTMAX); + for( i = 0; i < CHAR_MAXPETSKILLHAVE; i ++ ) { + CharNew.unionTable.indexOfPetskill[i] = *(tp + E_T_PETSKILL1 + i); + } + enemyrank = ENEMY_getRank( array, tarray ); + CharNew.data[CHAR_PETRANK] = enemyrank; +//#undef E_PAR +#undef ET_PAR +#undef PARAM_CAL + strcpysafe( CharNew.string[CHAR_NAME].string, + sizeof(CharNew.string[CHAR_NAME].string), + (char *)ENEMYTEMP_enemy[tarray].chardata[E_T_NAME].string ); + newindex = PET_initCharOneArray( &CharNew ); + if( newindex < 0 ){ + return -1; + } + CHAR_complianceParameter( newindex ); + CHAR_setInt( newindex, CHAR_HP, CHAR_getWorkInt( newindex, CHAR_WORKMAXHP)); + CHAR_setWorkInt( newindex, CHAR_WORKPLAYERINDEX, charaindex); + CHAR_setCharPet( charaindex, havepetelement, newindex); + CHAR_setChar( newindex, CHAR_OWNERCDKEY, + CHAR_getChar( charaindex, CHAR_CDKEY)); + CHAR_setChar( newindex, CHAR_OWNERCHARANAME, + CHAR_getChar( charaindex, CHAR_NAME)); + return newindex; +} +#ifdef _TEST_DROPITEMS +int ENEMY_TEST_createPetIndex( int array) +{ + Char CharNew; + int newindex; + int *p; + int tp[E_T_DATAINTNUM]; + int tarray, i; + //int havepetelement; + int level; + int enemyrank; + if( !ENEMY_CHECKINDEX( array)) return -1; + + //havepetelement = CHAR_getCharPetElement( charaindex); + //if( havepetelement < 0 ) return -1; + p = ENEMY_enemy[array].intdata; + tarray = ENEMYTEMP_getEnemyTempArray( array); + if( !ENEMYTEMP_CHECKINDEX( tarray)) return -1; + for( i = 0; i < E_T_DATAINTNUM; i ++ ){ + tp[i] = ENEMYTEMP_enemy[tarray].intdata[i]; + } + memset( &CharNew, 0, sizeof( Char ) ); + if( !CHAR_getDefaultChar( &CharNew,31010 ) )return -1; + CharNew.data[CHAR_BASEBASEIMAGENUMBER] + = CharNew.data[CHAR_BASEIMAGENUMBER] = *(tp+E_T_IMGNUMBER); + CharNew.data[CHAR_WHICHTYPE] = CHAR_TYPEPET; + level = RAND( (*(p + ENEMY_LV_MIN)), ( *(p+ ENEMY_LV_MAX))); + +#define E_PAR( a) (*(p + (a))) +#define ET_PAR( a) (*(tp + (a))) + +#if 1 +#define PARAM_CAL( l) (( level -1)*ET_PAR( E_T_LVUPPOINT)+ ET_PAR(E_T_INITNUM)) * ET_PAR( (l)) +#else +#define PARAM_CAL( l) ( (E_PAR(ENEMY_LV) -1)*ET_PAR( E_T_LVUPPOINT)+ ET_PAR(E_T_INITNUM)) * ET_PAR( (l)) +#endif + tp[E_T_BASEVITAL] += RAND( 0, 4 ) - 2; + tp[E_T_BASESTR] += RAND( 0, 4 ) - 2; + tp[E_T_BASETGH] += RAND( 0, 4 ) - 2; + tp[E_T_BASEDEX] += RAND( 0, 4 ) - 2; + CharNew.data[CHAR_ALLOCPOINT] + = ( tp[E_T_BASEVITAL] << 24 ) + + ( tp[E_T_BASESTR] << 16 ) + + ( tp[E_T_BASETGH] << 8 ) + + ( tp[E_T_BASEDEX] << 0 ); + for( i = 0; i < 10; i ++ ){ + int work = RAND( 0, 3 ); + if( work == 0 )tp[E_T_BASEVITAL]++; + if( work == 1 )tp[E_T_BASESTR]++; + if( work == 2 )tp[E_T_BASETGH]++; + if( work == 3 )tp[E_T_BASEDEX]++; + } + CharNew.data[CHAR_VITAL] = PARAM_CAL(E_T_BASEVITAL); + CharNew.data[CHAR_STR] = PARAM_CAL(E_T_BASESTR); + CharNew.data[CHAR_TOUGH] = PARAM_CAL(E_T_BASETGH); + CharNew.data[CHAR_DEX] = PARAM_CAL(E_T_BASEDEX); + CharNew.data[CHAR_FIREAT] = *(tp+ E_T_FIREAT); + CharNew.data[CHAR_WATERAT] = *(tp+ E_T_WATERAT); + CharNew.data[CHAR_EARTHAT] = *(tp+ E_T_EARTHAT); + CharNew.data[CHAR_WINDAT] = *(tp+ E_T_WINDAT); + + CharNew.data[CHAR_SLOT] = *(tp+ E_T_SLOT); + CharNew.data[CHAR_MODAI] = *(tp+ E_T_MODAI); + CharNew.data[CHAR_VARIABLEAI] = 0; + CharNew.data[CHAR_LV] = level; + CharNew.data[CHAR_POISON] = *(tp+ E_T_POISON); + CharNew.data[CHAR_PARALYSIS]= *(tp+ E_T_PARALYSIS); + CharNew.data[CHAR_SLEEP] = *(tp+ E_T_SLEEP); + CharNew.data[CHAR_STONE] = *(tp+ E_T_STONE); + CharNew.data[CHAR_DRUNK] = *(tp+ E_T_DRUNK); + CharNew.data[CHAR_CONFUSION]= *(tp+ E_T_CONFUSION); + CharNew.data[CHAR_RARE] = *(tp+ E_T_RARE); + CharNew.data[CHAR_PETID] = *(tp + E_T_TEMPNO); + CharNew.data[CHAR_CRITIAL] = *(tp + E_T_CRITICAL); + CharNew.data[CHAR_COUNTER] = *(tp + E_T_COUNTER); + CharNew.data[CHAR_PETENEMYID] = ENEMY_getInt( array, ENEMY_ID); + // Arminius 8.6 limit lv + CharNew.data[CHAR_LIMITLEVEL] = *(tp + E_T_LIMITLEVEL); +#ifdef _PET_FUSION + CharNew.data[CHAR_FUSIONCODE] = *(tp + E_T_FUSIONCODE); +#endif + CharNew.data[CHAR_PETMAILEFFECT] = RAND(0, PETMAIL_EFFECTMAX); + for( i = 0; i < CHAR_MAXPETSKILLHAVE; i ++ ) { + CharNew.unionTable.indexOfPetskill[i] = *(tp + E_T_PETSKILL1 + i); + } + enemyrank = ENEMY_getRank( array, tarray ); + CharNew.data[CHAR_PETRANK] = enemyrank; +#undef E_PAR +#undef ET_PAR +#undef PARAM_CAL + strcpysafe( CharNew.string[CHAR_NAME].string, + sizeof(CharNew.string[CHAR_NAME].string), + (char *)ENEMYTEMP_enemy[tarray].chardata[E_T_NAME].string ); + newindex = PET_initCharOneArray( &CharNew ); +#ifdef _CAX_LVTISHI +if (CHAR_getInt( newindex, CHAR_LV) == 1){// + char buff[256]; + snprintf( buff, sizeof( buff),"%s",CHAR_getChar( newindex, CHAR_NAME)); + CHAR_setChar( newindex, CHAR_NAME, buff); + } +#endif + if( newindex < 0 ){ + return -1; + } + CHAR_complianceParameter( newindex ); + CHAR_setInt( newindex, CHAR_HP, CHAR_getWorkInt( newindex, CHAR_WORKMAXHP)); +// CHAR_setWorkInt( newindex, CHAR_WORKPLAYERINDEX, charaindex); +// CHAR_setCharPet( charaindex, havepetelement, newindex); +// CHAR_setChar( newindex, CHAR_OWNERCDKEY, +// CHAR_getChar( charaindex, CHAR_CDKEY)); +// CHAR_setChar( newindex, CHAR_OWNERCHARANAME, +// CHAR_getChar( charaindex, CHAR_NAME)); + return newindex; +} +#endif + +#ifdef _PET_EVOLUTION + +BOOL PETFUSION_getIndexForChar( int toindex, int *MainIndex, int *Subindex1, int *Subindex2, char *data) +{ + char buf1[256]; + int pindex[3]={-1,-1,-1}; + int i; + int ridepet=CHAR_getInt( toindex , CHAR_RIDEPET); + int rideindex = CHAR_getCharPet( toindex,ridepet); + if( getStringFromIndexWithDelim( data, "|", 1, buf1, sizeof(buf1)) == FALSE ) + return FALSE; + pindex[0] = atoi( buf1)-1; + if( getStringFromIndexWithDelim( data, "|", 2, buf1, sizeof(buf1)) == FALSE ) + return FALSE; + pindex[1] = atoi( buf1)-1; + if( getStringFromIndexWithDelim( data, "|", 3, buf1, sizeof(buf1)) == FALSE ) + return FALSE; + pindex[2] = atoi( buf1)-1; + for( i=0; i<3; i++) { + int petindex; + if( pindex[i] < 0 ) continue; + petindex = CHAR_getCharPet( toindex, pindex[i]); + if( !CHAR_CHECKINDEX( petindex) ) continue; +#ifdef _CAX_PET_EVOLUTION + if( getpetevotyb() == 0 ){ +#endif +#ifdef _PET_2TRANS + if( CHAR_getInt( petindex, CHAR_TRANSMIGRATION ) ==2){ + CHAR_talkToCli( toindex, -1, "תﲻںϡ", CHAR_COLORYELLOW); + return FALSE; + } +#endif +#ifdef _CAX_PET_EVOLUTION + } + if( CHAR_getInt( petindex, CHAR_TRANSMIGRATION ) == 3 ) { + CHAR_talkToCli( toindex, -1, "תﲻںϡ", CHAR_COLORYELLOW); + return FALSE; + } +#endif + if( rideindex == petindex) { + CHAR_talkToCli( toindex, -1, "еij費ںϡ", CHAR_COLORYELLOW); + return FALSE; + } + if( i == 0 ) { + *MainIndex = petindex; + }else if( i == 1) { + *Subindex1 = petindex; + }else if( i == 2) { + *Subindex2 = petindex; + } + } + return TRUE; +} +int NPC_getPetArrayForNo( int PetCode) +{ + int i; + int enemynum = ENEMY_getEnemyNum(); + for( i = 0; i < enemynum; i ++ ) {//PetCode + if( ENEMY_getInt( i, ENEMY_TEMPNO ) == PetCode ) + break; + } + + if( i == enemynum ){ + print("ANDY 2.err i == enemynum \n"); + return -1; + } + return i; +} +int NPC_getFusionTableForBase( int charaindex, int petindex1, int petindex2 ) +{ + int base1, base2;// ,PETCODE + if( !CHAR_CHECKINDEX( petindex1) ) return -1; + if( !CHAR_CHECKINDEX( petindex2) ) return -1; +#ifdef _PET_EVOLUTION + if( (base2 = EVOLUTION_getPetTable( charaindex, petindex1, petindex2)) < 0 ){ + print("ANDY err base2=%d\n", base2); + return -1; + } + if( (base1 = EVOLUTION_getPropertyTable( charaindex, petindex1, petindex2)) < 0 ){ + print("ANDY err base1=%d\n", base1); + return -1; + } + return EVOLUTION_getFusionTable( charaindex, base2, base1); // get new pet IDNO +#else + return -1; +#endif +} + +BOOL PET_getEvolutionAns( int petindex, int *base) +{ + int i, total1, total2, total; +#ifdef _CAX_PET_EVOLUTION +int defwork = 50, defbase = getpetevotyb1(); +#else +int defwork = 50, defbase = 150; +#endif + int work[4]={0,0,0,0}; + + work[0] = CHAR_getInt( petindex, CHAR_EVOLUTIONBASEVTL); + work[1] = CHAR_getInt( petindex, CHAR_EVOLUTIONBASESTR); + work[2] = CHAR_getInt( petindex, CHAR_EVOLUTIONBASETGH); + work[3] = CHAR_getInt( petindex, CHAR_EVOLUTIONBASEDEX); + for( i=0; i<4; i++) { + work[i] = (work[i]*0.7)/100; + if( work[i]<0 ) work[i] = 0; + if( work[i]>60 ) work[i] = 60; + } + total1 = work[0] + work[1] + work[2] + work[3]; + for( i=0; i<4; i++) { + if( base[i] < 0 ) base[i] = 5; + if( base[i] > 60 ) base[i] = 60; + } + total2 = base[0] + base[1] + base[2] + base[3]; + if( total1 > defwork ) { + for( i=0; i<4; i++) { + work[i] = ((work[i]*defwork)/total1); + if( work[i]<0 ) work[i] = 0; + if( work[i]>60 ) work[i] = 60; + } + } + + total1 = work[0] + work[1] + work[2] + work[3]; + total = (total1/2) + total2; + + if( total > 0 ){ + for( i=0; i<4; i++) { + float fixwork=0.0; + fixwork = (base[i])+(float)(work[i]/2); + base[i] += (int)((fixwork/total) * total1); + if( base[i] < 1 ) base[i] = 1; + if( base[i] > 60 ) base[i] = 60; + } + } + total2 = base[0] + base[1] + base[2] + base[3]; + if( total2 > defbase ){ + for( i=0; i<4; i++) { + base[i] = (base[i]*defbase)/total2; + if( base[i] < 1 ) base[i] = 1; + if( base[i] > 60 ) base[i] = 60; + } + } + total2 = base[0] + base[1] + base[2] + base[3]; + if( base[0]<0 || base[1]<0 || base[2]<0 || base[3]<0 ){ + print("ANDY err EVOLUTION base someone < 0 !!\n"); + } + return TRUE; +} + +int EVOLUTION_createPetFromEnemyIndex( int charaindex, int baseindex, int flg) +{ + Char CharNew; + int newindex; + int *p; + int tp[E_T_DATAINTNUM]; + int tarray, i, havepetelement, enemynum, petID; + int level, enemyrank, array; + int petskill[7]={-1,-1,-1,-1,-1,-1,-1}; + int base[4]={0,0,0,0}; +#ifdef _illegalpetskill_CF + int illegalpetskill[25] = {41,52,600,601,602,603,604,614,617,628,630,631,635,638,641, + getIllegalPetskill(0),getIllegalPetskill(1),getIllegalPetskill(2),getIllegalPetskill(3),getIllegalPetskill(4), + getIllegalPetskill(5),getIllegalPetskill(6),getIllegalPetskill(7),getIllegalPetskill(8),getIllegalPetskill(9)};//ԶֹŴ\ +#else + int illegalpetskill[15] = {41,52,600,601,602,603,604,614,617,628,630,631,635,638,641};//Ŵij輼 +#endif +#define E_PAR( a) (*(p + (a))) +#define ET_PAR( a) (*(tp + (a))) +#define PARAM_CAL( l) (( level -1)*ET_PAR( E_T_LVUPPOINT)+ ET_PAR(E_T_INITNUM)) * ET_PAR( (l)) + havepetelement=-1; + petID = CHAR_getInt( baseindex, CHAR_FUSIONINDEX); + enemynum = ENEMY_getEnemyNum(); + for( i = 0; i < enemynum; i ++ ) { + if( ENEMY_getInt( i, ENEMY_TEMPNO ) == petID ){ + break; + } + } + if( i >= enemynum ) return -1; + array = i; + if( !ENEMY_CHECKINDEX( array)) return -1; +//-------------------------------------------------------------------------- + p = ENEMY_enemy[array].intdata; + tarray = ENEMYTEMP_getEnemyTempArray( array); + if( !ENEMYTEMP_CHECKINDEX( tarray)){ + print( "ANDY !tarray\n"); + return -1; + } + for( i = 0; i < E_T_DATAINTNUM; i ++ ){ + tp[i] = ENEMYTEMP_enemy[tarray].intdata[i]; + } + memset( &CharNew, 0, sizeof( Char ) ); + if( !CHAR_getDefaultChar( &CharNew,31010 ) ){ + print( "ANDY !CHAR_getDefaultChar( &CharNew,31010 )\n"); + return -1; + } + CharNew.data[CHAR_BASEBASEIMAGENUMBER] + = CharNew.data[CHAR_BASEIMAGENUMBER] = *(tp+E_T_IMGNUMBER); + CharNew.data[CHAR_WHICHTYPE] = CHAR_TYPEPET; + level = RAND( (*(p + ENEMY_LV_MIN)), ( *(p+ ENEMY_LV_MAX))); +//------------------------------------------------------ + { + if( PET_getBaseAndSkill( charaindex, baseindex, base, petskill, 1) == FALSE ){ + print( "ANDY err PET_getBaseAndSkill(%d) == FALSE \n", baseindex); + return -1; + } + if( PET_getEvolutionAns( baseindex, base) == FALSE ) return -1; + for( i=0; i < CHAR_MAXPETSKILLHAVE; i ++ ) {//輼 + int j; + for( j=0; j<15; j++) { //Ƿ + if( illegalpetskill[j] == petskill[i] ){ + petskill[i] = -1; + break; + } + } + CharNew.unionTable.indexOfPetskill[i] = petskill[i]; + } + if( flg == 1 ){ + if( CHAR_DelPetForIndex( charaindex, baseindex) == FALSE ) return FALSE; + } + } + if( flg == 1 ){ + havepetelement = CHAR_getCharPetElement( charaindex);//ҳλ + if( havepetelement < 0 ) return -1; + } +//------------------------------------------------------ + tp[E_T_BASEVITAL] = base[0]; + tp[E_T_BASESTR] = base[1]; + tp[E_T_BASETGH] = base[2]; + tp[E_T_BASEDEX] = base[3]; + CharNew.data[CHAR_ALLOCPOINT] = (base[0]<<24)+(base[1]<<16)+(base[2]<<8)+(base[3]<<0); + + for( i = 0; i < 10; i ++ ){ + int work = RAND( 0, 3 ); + if( work == 0 )tp[E_T_BASEVITAL]++; + if( work == 1 )tp[E_T_BASESTR]++; + if( work == 2 )tp[E_T_BASETGH]++; + if( work == 3 )tp[E_T_BASEDEX]++; + } +//------------------------------------------------------ + CharNew.data[CHAR_VITAL] = PARAM_CAL(E_T_BASEVITAL); + CharNew.data[CHAR_STR] = PARAM_CAL(E_T_BASESTR); + CharNew.data[CHAR_TOUGH] = PARAM_CAL(E_T_BASETGH); + CharNew.data[CHAR_DEX] = PARAM_CAL(E_T_BASEDEX); + CharNew.data[CHAR_FIREAT] = *(tp+ E_T_FIREAT); + CharNew.data[CHAR_WATERAT] = *(tp+ E_T_WATERAT); + CharNew.data[CHAR_EARTHAT] = *(tp+ E_T_EARTHAT); + CharNew.data[CHAR_WINDAT] = *(tp+ E_T_WINDAT); + CharNew.data[CHAR_SLOT] = *(tp+ E_T_SLOT); + CharNew.data[CHAR_MODAI] = *(tp+ E_T_MODAI); + CharNew.data[CHAR_VARIABLEAI] = 0; + CharNew.data[CHAR_LV] = level; + CharNew.data[CHAR_POISON] = *(tp+ E_T_POISON); + CharNew.data[CHAR_PARALYSIS]= *(tp+ E_T_PARALYSIS); + CharNew.data[CHAR_SLEEP] = *(tp+ E_T_SLEEP); + CharNew.data[CHAR_STONE] = *(tp+ E_T_STONE); + CharNew.data[CHAR_DRUNK] = *(tp+ E_T_DRUNK); + CharNew.data[CHAR_CONFUSION]= *(tp+ E_T_CONFUSION); + CharNew.data[CHAR_RARE] = *(tp+ E_T_RARE); + CharNew.data[CHAR_PETID] = *(tp + E_T_TEMPNO); + CharNew.data[CHAR_CRITIAL] = *(tp + E_T_CRITICAL); + CharNew.data[CHAR_COUNTER] = *(tp + E_T_COUNTER); + CharNew.data[CHAR_LIMITLEVEL] = *(tp + E_T_LIMITLEVEL); + CharNew.data[CHAR_FUSIONCODE] = *(tp + E_T_FUSIONCODE); + CharNew.data[CHAR_PETMAILEFFECT] = RAND(0, PETMAIL_EFFECTMAX); +//------------------------------------------------------ + + enemyrank = ENEMY_getRank( array, tarray ); + CharNew.data[CHAR_PETRANK] = enemyrank; +#undef E_PAR +#undef ET_PAR +#undef PARAM_CAL + strcpysafe( CharNew.string[CHAR_NAME].string, + sizeof(CharNew.string[CHAR_NAME].string), + (char *)ENEMYTEMP_enemy[tarray].chardata[E_T_NAME].string ); + newindex = PET_initCharOneArray( &CharNew ); + if( newindex < 0 ){ + print( "ANDY err newindex=%d\n", newindex); + return -1; + } +//------------------------------------------------------ + CHAR_complianceParameter( newindex ); + CHAR_setInt( newindex, CHAR_HP, CHAR_getWorkInt( newindex, CHAR_WORKMAXHP)); + CHAR_setInt ( newindex, CHAR_WHICHTYPE , CHAR_TYPEPET); +#ifdef _PET_2TRANS + #ifdef _PET_3TRANS + CHAR_setInt ( newindex, CHAR_TRANSMIGRATION, 3); + #else + CHAR_setInt ( newindex, CHAR_TRANSMIGRATION, 2); + #endif +#else + CHAR_setInt ( newindex, CHAR_TRANSMIGRATION, 1); +#endif + CHAR_setInt ( newindex, CHAR_FUSIONBEIT, 1); + CHAR_setInt ( newindex, CHAR_FUSIONRAISE, 0); + if( flg == 1 ){ + CHAR_setWorkInt( newindex, CHAR_WORKPLAYERINDEX, charaindex); + CHAR_setCharPet( charaindex, havepetelement, newindex); + CHAR_setChar( newindex, CHAR_OWNERCDKEY, CHAR_getChar( charaindex, CHAR_CDKEY)); + CHAR_setChar( newindex, CHAR_OWNERCHARANAME, CHAR_getChar( charaindex, CHAR_NAME)); + { + char msgbuf[256]; + snprintf( msgbuf, sizeof( msgbuf ), "K%d", havepetelement ); + CHAR_sendStatusString( charaindex, msgbuf ); + snprintf( msgbuf, sizeof( msgbuf ), "W%d", havepetelement ); + CHAR_sendStatusString( charaindex, msgbuf ); + } + } + return newindex; +} + +int PET_CheckIncubate( int charaindex) +{ +#ifndef _USER_CHARLOOPS + int i; + static time_t checkeage; + int anhour = PETFEEDTIME; + checkeage = (int)time( NULL); + if( !CHAR_CHECKINDEX( charaindex) )return 0; + + for(i=0 ; i < CHAR_MAXPETHAVE ; i++) { + int time_l=0; + int petindex = CHAR_getCharPet( charaindex, i); + if( !CHAR_CHECKINDEX( petindex) ) continue; + if( CHAR_getInt( petindex, CHAR_FUSIONBEIT) != 1 || + CHAR_getInt( petindex, CHAR_FUSIONRAISE) <= 0 )return;//ǷΪںϳ + + time_l = CHAR_getInt( petindex, CHAR_FUSIONTIMELIMIT); + if( time_l < 0 || time_l > checkeage ){ + CHAR_setInt( petindex, CHAR_FUSIONTIMELIMIT, checkeage); + continue; + } + + if( (int)checkeage > (time_l+(anhour*2)) ){ + char buf[256]; + int levelup, vital, str, tgh, dex; + int raise = CHAR_getInt( petindex, CHAR_FUSIONRAISE); + //ι + raise++; + CHAR_setInt( petindex, CHAR_FUSIONTIMELIMIT, (int)time(NULL)+anhour-1); + if( raise < 0 ) raise = 0; + if( raise >= 40 ) raise = 30; + CHAR_setInt( petindex, CHAR_FUSIONRAISE, raise); + levelup = CHAR_getInt( petindex, CHAR_ALLOCPOINT); + vital = ((levelup>>24) & 0xFF) - 5; + str = ((levelup>>16) & 0xFF) - 5; + tgh = ((levelup>> 8) & 0xFF) - 5; + dex = ((levelup>> 0) & 0xFF) - 5; + if( vital < 0 ) vital = 0; + if( str < 0 ) str = 0; + if( tgh < 0 ) tgh = 0; + if( dex < 0 ) dex = 0; + // + levelup = (vital<<24) + (str<<16) + (tgh<<8) + (dex<<0); + CHAR_setInt( petindex, CHAR_ALLOCPOINT, levelup); + sprintf( buf, "%sƷʱˡ", CHAR_getUseName( petindex )); + CHAR_talkToCli( charaindex, -1, buf, CHAR_COLORYELLOW); + + LogPetFeed( + CHAR_getChar( charaindex, CHAR_NAME), + CHAR_getChar( charaindex, CHAR_CDKEY), + CHAR_getChar( petindex, CHAR_NAME), + petindex, + CHAR_getInt( petindex, CHAR_LV), + "Ʒʱ", // Key + CHAR_getInt( charaindex, CHAR_FLOOR), + CHAR_getInt( charaindex, CHAR_X), + CHAR_getInt( charaindex, CHAR_Y), + CHAR_getChar( petindex, CHAR_UNIQUECODE) ); + + }else if( (int)checkeage > (time_l+anhour) ){ + + char buf[256]; + sprintf( buf, "%sֿιʳ״̬", CHAR_getUseName( petindex )); + CHAR_talkToCli( charaindex, -1, buf, CHAR_COLORYELLOW); + } + } + return 1; +#else + int masterindex, time_l=0; + static time_t checkeage; + int anhour = PETFEEDTIME, i; + + if( !CHAR_CHECKINDEX( charaindex) )return 0; + masterindex = CHAR_getWorkInt( charaindex, CHAR_WORKPLAYERINDEX); + if( !CHAR_CHECKINDEX( masterindex) )return 0; + + if( CHAR_getInt( charaindex, CHAR_FUSIONBEIT) != 1 || + CHAR_getInt( charaindex, CHAR_FUSIONRAISE) <= 0 ) return 0;//ǷΪںϳ + + for(i=0 ; i < CHAR_MAXPETHAVE ; i++) { + if( charaindex != CHAR_getCharPet( masterindex, i) ) continue; + break; + } + if( i >= CHAR_MAXPETHAVE ) return 0; + + checkeage = (int)time( NULL); + + time_l = CHAR_getInt( charaindex, CHAR_FUSIONTIMELIMIT); + if( time_l < 0 || time_l > checkeage ){ + CHAR_setInt( charaindex, CHAR_FUSIONTIMELIMIT, checkeage); + return 0; + } + if( (int)checkeage > (time_l+(anhour*2.5)) ){ + char buf[256]; + int levelup, vital, str, tgh, dex; + int raise = CHAR_getInt( charaindex, CHAR_FUSIONRAISE); + raise++; + CHAR_setInt( charaindex, CHAR_FUSIONTIMELIMIT, (int)time(NULL)+anhour-1); + if( raise < 0 ) raise = 0; + if( raise >= 40 ) raise = 30; + CHAR_setInt( charaindex, CHAR_FUSIONRAISE, raise); + levelup = CHAR_getInt( charaindex, CHAR_ALLOCPOINT); + vital = ((levelup>>24) & 0xFF) - 6; + str = ((levelup>>16) & 0xFF) - 6; + tgh = ((levelup>> 8) & 0xFF) - 6; + dex = ((levelup>> 0) & 0xFF) - 6; + if( vital < 0 ) vital = 0; + if( str < 0 ) str = 0; + if( tgh < 0 ) tgh = 0; + if( dex < 0 ) dex = 0; + // + levelup = (vital<<24) + (str<<16) + (tgh<<8) + (dex<<0); + CHAR_setInt( charaindex, CHAR_ALLOCPOINT, levelup); + sprintf( buf, "%sƷʱˡ", CHAR_getUseName( charaindex )); + CHAR_talkToCli( masterindex, -1, buf, CHAR_COLORYELLOW); + + LogPetFeed( + CHAR_getChar( masterindex, CHAR_NAME), + CHAR_getChar( masterindex, CHAR_CDKEY), + CHAR_getChar( charaindex, CHAR_NAME), + charaindex, + CHAR_getInt( charaindex, CHAR_LV), + "Ʒʱ", // Key + CHAR_getInt( masterindex, CHAR_FLOOR), + CHAR_getInt( masterindex, CHAR_X), + CHAR_getInt( masterindex, CHAR_Y), + CHAR_getChar( charaindex, CHAR_UNIQUECODE) ); + + }else if( (int)checkeage > (time_l+anhour) ){ + char buf[256]; + sprintf( buf, "%sֿιʳ״̬", CHAR_getUseName( charaindex )); + CHAR_talkToCli( masterindex, -1, buf, CHAR_COLORYELLOW); + } + return 1; +#endif +} +#endif + +#ifdef _NPC_FUSION +int PETFUSION_SetNewEgg( int toindex , int petindex, int array, int *work, int *skill1, int *skill2) +{ + int *p; + int tp[E_T_DATAINTNUM]; + int tarray, i; + int level, workrank, petrank=0; + int LevelUpPoint; + struct { + int num; + float rank; + }ranktbl[] = { + { 130, 2.5}, + { 100, 2.0}, + { 95, 1.5}, + { 85, 1.0}, + { 80, 0.5}, + { 0, 0.0}, + }; + if( !ENEMY_CHECKINDEX( array)) + return -1; + p = ENEMY_getIntdata( array); + if( p == NULL ) { + print("\n p = NULL" ); + return -1; + } + tarray = ENEMYTEMP_getEnemyTempArray( array); + if( !ENEMYTEMP_CHECKINDEX( tarray)) + return -1; + //print( "ANDY tarray/array=%d/%d-->%s \n", tarray, array, + // ENEMYTEMP_getChar( tarray, E_T_NAME)); + for( i = 0; i < E_T_DATAINTNUM; i ++ ){ + tp[i] = ENEMYTEMP_getInt( tarray, i); + } + level = 1; +#define RAND(x,y) ((x-1)+1+ (int)( (double)(y-(x-1))*rand()/(RAND_MAX+1.0)) ) +#define E_PAR( a) (*(p + (a))) +#define ET_PAR( a) (*(tp + (a))) +#define PARAM_CAL( l) ( ( level -1) * ET_PAR( E_T_LVUPPOINT) + ET_PAR( E_T_INITNUM) ) + work[0] += ( RAND(0,4) - 2 ); + work[1] += ( RAND(0,4) - 2 ); + work[2] += ( RAND(0,4) - 2 ); + work[3] += ( RAND(0,4) - 2 ); + LevelUpPoint = ( work[0] << 24 ) + + (work[1] << 16) + + (work[2] << 8 ) + + (work[3] << 0 ); + + CHAR_setInt( petindex, CHAR_ALLOCPOINT, LevelUpPoint); + workrank = work[0]+work[1]+work[2]+work[3]; + for( i = 0; i < arraysizeof( ranktbl); i ++ ) { + if( workrank >= ranktbl[i].num ) { + petrank = i; + break; + } + } + if( i>= arraysizeof( ranktbl)) i = arraysizeof( ranktbl); + CHAR_setInt( petindex, CHAR_PETRANK, petrank); + for( i = 0; i < 10; i ++ ){ + int rnt = RAND( 0, 3 ); + if( rnt == 0 ) work[0]++; + if( rnt == 1 ) work[1]++; + if( rnt == 2 ) work[2]++; + if( rnt == 3 ) work[3]++; + } + + CHAR_setInt( petindex, CHAR_VITAL, ( PARAM_CAL(E_T_BASEVITAL) * work[0] )); + CHAR_setInt( petindex, CHAR_STR , ( PARAM_CAL(E_T_BASESTR) * work[1] )); + CHAR_setInt( petindex, CHAR_TOUGH , ( PARAM_CAL(E_T_BASETGH) * work[2] )); + CHAR_setInt( petindex, CHAR_DEX , ( PARAM_CAL(E_T_BASEDEX) * work[3] )); + CHAR_setMaxExp( petindex, 0); + CHAR_setInt( petindex, CHAR_LV, level); + + //\Ϊ߼ + CHAR_setInt( petindex, CHAR_SLOT, 7); + { + int j; +#ifdef _illegalpetskill_CF + int illegalpetskill[25] = {41,52,600,601,602,603,604,614,617,628,630,631,635,638,641, + getIllegalPetskill(0),getIllegalPetskill(1),getIllegalPetskill(2),getIllegalPetskill(3),getIllegalPetskill(4), + getIllegalPetskill(5),getIllegalPetskill(6),getIllegalPetskill(7),getIllegalPetskill(8),getIllegalPetskill(9)};//ԶֹŴ\ +#else + int illegalpetskill[15] = {41,52,600,601,602,603,604,614,617,628,630,631,635,638,641}; +#endif + for( i=0; icharfunctable[CHAR_LOOPFUNCTEMP1].string, + sizeof( ch->charfunctable[CHAR_LOOPFUNCTEMP1]), "PET_CheckIncubateLoop"); + ch->data[CHAR_LOOPINTERVAL] = 60000; + CHAR_constructFunctable( petindex); + } +#endif + if( CHAR_CHECKINDEX( toindex) ){ + for(i = 0; i < CHAR_MAXPETHAVE; i++){ + char msgbuf[256]; + int pindex = CHAR_getCharPet(toindex, i); + if( !CHAR_CHECKINDEX( pindex) ) + continue; + memset( msgbuf, 0, sizeof( msgbuf)); + snprintf( msgbuf, sizeof( msgbuf ), "K%d", i ); + CHAR_sendStatusString( toindex, msgbuf ); + + CHAR_send_K_StatusString(toindex, i,CHAR_K_STRING_HP|CHAR_K_STRING_AI); + } + } + return petindex; +} + +BOOL PETFUSION_AddEgg( int toindex, int petID, int PetCode) +{ + int ret; + char msgbuf[64]; + int enemynum; + int i,j; + int petindex, petindex2; + + //Ƿпλ + for( i = 0 ;i < CHAR_MAXPETHAVE ; i++) { + petindex = CHAR_getCharPet( toindex, i); + if( petindex == -1 ) + break; + } + if( i == CHAR_MAXPETHAVE ) { + snprintf( msgbuf,sizeof( msgbuf), ""); + CHAR_talkToCli( toindex, -1, msgbuf, CHAR_COLORYELLOW); + return -1; + } + enemynum = ENEMY_getEnemyNum(); + for( i = 0; i < enemynum; i ++ ) {//PetCode + if( ENEMY_getInt( i, ENEMY_ID ) == petID ) + //if( ENEMY_getInt( i, ENEMY_TEMPNO ) == PetCode ) + break; + } + if( i == enemynum ){ + print("ANDY err i == enemynum \n"); + return -1; + } + ret = ENEMY_createPetFromEnemyIndex( toindex, i); + for( i = 0; i < CHAR_MAXPETHAVE; i ++ ) { + if( CHAR_getCharPet( toindex, i ) == ret ) + break; + } + if( i == CHAR_MAXPETHAVE ) + i = 0; + if( CHAR_CHECKINDEX( ret ) == TRUE ){ + CHAR_setMaxExpFromLevel( ret, CHAR_getInt( ret, CHAR_LV )); + } + petindex2 = CHAR_getCharPet( toindex, i); + if( !CHAR_CHECKINDEX( petindex2) ){ + print("ANDY petindex2=%d\n", petindex2); + return -1; + } + CHAR_setInt( petindex2, CHAR_FUSIONINDEX, PetCode); + snprintf( msgbuf,sizeof( msgbuf), "õ%s", CHAR_getChar(petindex2,CHAR_NAME)); + CHAR_talkToCli( toindex, -1, msgbuf, CHAR_COLORYELLOW); + for(j = 0; j < CHAR_MAXPETHAVE; j++){ + petindex = CHAR_getCharPet(toindex, j); + if( !CHAR_CHECKINDEX( petindex) ) + continue; + CHAR_complianceParameter( petindex ); + snprintf( msgbuf, sizeof( msgbuf ), "K%d", j ); + CHAR_sendStatusString( toindex, msgbuf ); + snprintf( msgbuf, sizeof( msgbuf ), "W%d", j ); + CHAR_sendStatusString( toindex, msgbuf ); + } + LogPet( + CHAR_getChar( toindex, CHAR_NAME ), + CHAR_getChar( toindex, CHAR_CDKEY ), + CHAR_getChar( petindex2, CHAR_NAME), + CHAR_getInt( petindex2, CHAR_LV), + "TenseiGet", + CHAR_getInt( toindex,CHAR_FLOOR), + CHAR_getInt( toindex,CHAR_X ), + CHAR_getInt( toindex,CHAR_Y ), + CHAR_getChar( petindex2, CHAR_UNIQUECODE) // shan 2001/12/14 + ); + + return petindex2; +} +#endif + +#ifdef _PET_TRANS +int GetNewPet( int toindex , int petindex, int array, int *work) +{ + int *p; + int tp[E_T_DATAINTNUM]; + int tarray, i; + int level, workrank, petrank=0; + int LevelUpPoint; + + struct { + int num; + float rank; + }ranktbl[] = { + { 130, 2.5}, + { 100, 2.0}, + { 95, 1.5}, + { 85, 1.0}, + { 80, 0.5}, + { 0, 0.0}, + }; + + if( !ENEMY_CHECKINDEX( array)) + return -1; + p = ENEMY_getIntdata( array); + if( p == NULL ) { + print("\n p = NULL" ); + return -1; + } + tarray = ENEMYTEMP_getEnemyTempArray( array); + if( !ENEMYTEMP_CHECKINDEX( tarray)) + return -1; + for( i = 0; i < E_T_DATAINTNUM; i ++ ){ + tp[i] = ENEMYTEMP_getInt( tarray, i); + } + level = 1; +#define RAND(x,y) ((x-1)+1+ (int)( (double)(y-(x-1))*rand()/(RAND_MAX+1.0)) ) +#define E_PAR( a) (*(p + (a))) +#define ET_PAR( a) (*(tp + (a))) +#define PARAM_CAL( l) ( ( level -1) * ET_PAR( E_T_LVUPPOINT) + ET_PAR( E_T_INITNUM) ) +#ifdef _PETTRANS_RANGE + work[0] += ( RAND(getPetTransRangeX(),getPetTransRangeY()) - getPetTransRangeZ() ); + work[1] += ( RAND(getPetTransRangeX(),getPetTransRangeY()) - getPetTransRangeZ() ); + work[2] += ( RAND(getPetTransRangeX(),getPetTransRangeY()) - getPetTransRangeZ() ); + work[3] += ( RAND(getPetTransRangeX(),getPetTransRangeY()) - getPetTransRangeZ() ); +#else + work[0] += ( RAND(0,4) - 2 ); + work[1] += ( RAND(0,4) - 2 ); + work[2] += ( RAND(0,4) - 2 ); + work[3] += ( RAND(0,4) - 2 ); +#endif +/* LevelUpPoint = ( work[0] << 24 ) + + (work[1] << 16) + + (work[2] << 8 ) + + (work[3] << 0 );*/ +#ifdef _PET_TRANS_ABILITY + LevelUpPoint + = ((work[0] + getPetTransAbility() * (CHAR_getInt( petindex, CHAR_TRANSMIGRATION)+1)) << 24) + + ((work[1] + getPetTransAbility() * (CHAR_getInt( petindex, CHAR_TRANSMIGRATION)+1)) << 16) + + ((work[2] + getPetTransAbility() * (CHAR_getInt( petindex, CHAR_TRANSMIGRATION)+1)) << 8) + + ((work[3] + getPetTransAbility() * (CHAR_getInt( petindex, CHAR_TRANSMIGRATION)+1)) << 0); +#else + LevelUpPoint + = (work[0] << 24) + + (work[1] << 16) + + (work[2] << 8) + + (work[3] << 0); +#endif + CHAR_setInt( petindex, CHAR_ALLOCPOINT, LevelUpPoint); + workrank = work[0]+work[1]+work[2]+work[3]; + for( i = 0; i < arraysizeof( ranktbl); i ++ ) { + if( workrank >= ranktbl[i].num ) { + petrank = i; + break; + } + } + + if( i>= arraysizeof( ranktbl)) i = arraysizeof( ranktbl); + CHAR_setInt( petindex, CHAR_PETRANK, petrank); + + for( i = 0; i < 10; i ++ ){ + int rnt = RAND( 0, 3 ); + if( rnt == 0 ) work[0]++; + if( rnt == 1 ) work[1]++; + if( rnt == 2 ) work[2]++; + if( rnt == 3 ) work[3]++; + } + + CHAR_setInt( petindex, CHAR_VITAL, ( PARAM_CAL(E_T_BASEVITAL) * work[0] )); + CHAR_setInt( petindex, CHAR_STR , ( PARAM_CAL(E_T_BASESTR) * work[1] )); + CHAR_setInt( petindex, CHAR_TOUGH , ( PARAM_CAL(E_T_BASETGH) * work[2] )); + CHAR_setInt( petindex, CHAR_DEX , ( PARAM_CAL(E_T_BASEDEX) * work[3] )); + CHAR_setMaxExp( petindex, 0); + CHAR_setInt( petindex, CHAR_LV, level); + //\Ϊ߼ + CHAR_setInt( petindex, CHAR_SLOT, 7); +/* for( i=0; i + +#include "object.h" +#include "char_base.h" +#include "char.h" +#include "readmap.h" +#include "map_warppoint.h" +#include "event.h" +#include "npc_warp.h" +#include "npc_npcenemy.h" + + +static int EVENT_onWarpNPC( int charaindex,int echaraindex,int fl,int x, int y ); +static int EVENY_npcEncount( int charaindex,int echaraindex,int fl,int x, int y ); + + +typedef int (*FUNC)( int charaindex,int echaraindex,int fl,int x, int y ); +static FUNC functbl[] = { + NULL, + NULL, /* NPC */ + EVENY_npcEncount, /* óľ޼ */ + EVENT_onWarpNPC, /* warp*/ + NULL, /* NPC */ + NULL, /* NPC */ + EVENT_onWarpNPC, /* warp*/ + EVENT_onWarpNPC, /* warp*/ + EVENT_onWarpNPC, /* warp*/ +}; + +INLINE BOOL EVENT_CHECKEVENTINDEX( int event) +{ + if( event < 0 || event >= CHAR_EVENTNUM) return FALSE; + return TRUE; +} + +int EVENT_main( int charaindex,int event, int x, int y) +{ + OBJECT object; + BOOL found = FALSE; + int rc = FALSE; + int fl = CHAR_getInt( charaindex, CHAR_FLOOR); + if( !EVENT_CHECKEVENTINDEX( event)) return FALSE; + + for( object = MAP_getTopObj(fl,x,y) ; object ; object = NEXT_OBJECT(object) ){ + int o = GET_OBJINDEX(object); + if( OBJECT_getType(o) == OBJTYPE_CHARA ){ + int etype; + int echaraindex=OBJECT_getIndex(o); + if( !CHAR_CHECKINDEX(echaraindex) )continue; + if( CHAR_getInt( echaraindex, CHAR_WHICHTYPE) == CHAR_TYPEPLAYER) continue; + etype = CHAR_getWorkInt( echaraindex, CHAR_WORKEVENTTYPE); + if( etype != CHAR_EVENT_NONE ) { + if( etype == event) { + if( functbl[event] != NULL ) { + rc = functbl[event]( charaindex, echaraindex, fl,x,y); + } + found = TRUE; + break; + } + } + } +#ifdef _MAP_WARPPOINT + else if( OBJECT_getType(o) == OBJTYPE_WARPPOINT){ + if( !MAPPOINT_CHECKINDEX( OBJECT_getIndex( o)) ) continue; + if( OBJECT_getchartype( o) != event ) continue; + MAPPOINT_MapWarpHandle( charaindex, OBJECT_getIndex( o), fl, x, y ); + found = TRUE; + rc = TRUE; + break; + } +#endif + } +/* + if( !found ) { + print( "not found eventobject : cind [%d] event [%d] fl[%d] x[%d] y[%d]\n", charaindex, event, fl,x,y); + } +*/ + return rc; +} + +static int EVENT_onWarpNPC( int charaindex,int echaraindex,int fl,int x, int y ) +{ + NPC_WarpWarpCharacter( echaraindex, charaindex); + if( CHAR_getWorkInt( charaindex, CHAR_WORKPARTYMODE ) == CHAR_PARTY_LEADER ) { + int i; + for( i = 1; i < CHAR_PARTYMAX; i ++ ) { + int index = CHAR_getWorkInt( charaindex, i + CHAR_WORKPARTYINDEX1); + if( CHAR_CHECKINDEX(index) ) { + NPC_WarpWarpCharacter( echaraindex, index); + } + } + } + + return TRUE; +} +static int EVENY_npcEncount( int charaindex,int echaraindex,int fl,int x, int y ) +{ + return NPC_NPCEnemy_Encount( echaraindex, charaindex, 0); +} + diff --git a/char/family.c b/char/family.c new file mode 100644 index 0000000..fc0ec62 --- /dev/null +++ b/char/family.c @@ -0,0 +1,3444 @@ +#include "version.h" +#include +#include +#include +#include + +#include "readmap.h" +#include "object.h" +#include "char.h" +#include "char_base.h" +#include "lssproto_serv.h" +#include "saacproto_cli.h" +#include "npcutil.h" +#include "family.h" +#include "log.h" +#include "handletime.h" +#include "buf.h" +#include "net.h" +#include "char_base.h" +#include "battle.h" +#include "npc_bus.h" +#include "char_talk.h" +#include "npc_scheduleman.h" +#ifdef _FM_MODIFY +#include "npc_fmdengon.h" +#endif +#ifdef _ALLBLUES_LUA +#include "mylua/function.h" +#endif +#define CHAR_MAXNAME 32 +#define CHAR_MAXID 20 +#define MINFMLEVLEFORPOINT 3 // 3 ׯ԰͵ȼ +#ifdef _FAMILY_MANORNUM_CHANGE +#else +#define MANORNUM 4 +#endif +#ifdef _FMRANK_POINT +int fmrankindex[20]; +char fmrankname[20][50]; +int fmrankpoint[20]; +int fmranknum = 0; +#endif +struct FAMILY +{ + int fmindex; + char name[CHAR_MAXNAME]; + char leadername[CHAR_MAXNAME]; + char leaderid[CHAR_MAXID]; + int leadergraph; + char petname[CHAR_MAXNAME]; + char petattr[256]; + int fmnum; + int acceptflag; + char rule[256]; + int village; + int pointindex; + int dp; + char memolist[35][100]; +}; + +int familyNumTotal = 0; +char familyListBuf[MAXFAMILYLIST]; + + + +int familyTax[FAMILY_MAXNUM]; + +extern tagRidePetTable ridePetTable[296]; + +void LeaveMemberIndex( int charaindex, int fmindexi); + + +// Arminius: ȡü pk dp /ʧֵ +// getFMdpAward +// arg: windp=winner's fmdp losedp=loser's fmdp +// ret: dp award +// +#ifdef _MERGE_NEW_8 +int fmdplevelexp[]={0, // 0 + 150000, // 1 + 500000, // 2 + 1000000, // 3 + 1500000, // 4 + 2000000, // 5 + 2500000, // 6 + 3500000, // 7 + 4500000, // 8 + 5000000, // 9 + 7000000 //10 + }; +#else +int fmdplevelexp[]={0, // 0 + 10000, // 1 + 30000, // 2 + 100000, // 3 + 500000, // 4 + 1500000, // 5 + 5000000, // 6 + 15000000, // 7 + 50000000, // 8 + 200000000, // 9 + 500000000 //10 + }; +#endif +// Arminius end + +// shan begin +int getFmLv(int playerindex) // ϳʱר +{ + int i, dp; + dp = CHAR_getWorkInt(playerindex, CHAR_WORKFMDP); + if( dp > fmdplevelexp[10] ){ +// print("\n player DP->%d",dp); + return 10; + } + for(i=0; i<=10; i++) + if( dp <= fmdplevelexp[i+1] ) break; + // Nuke 20040217: Open the merge limit + //if(i>=9) i = 8; + if (i>=10) i=10; + + return i; +} + +struct FMMEMBER_LIST memberlist[FAMILY_MAXNUM]; +struct FMS_MEMO fmsmemo; +struct FM_POINTLIST fmpointlist; +#ifdef _NEW_MANOR_LAW +ManorSchedule_t ManorSchedule[MANORNUM]; +#endif +struct FMS_DPTOP fmdptop; +struct FM_PKFLOOR fmpkflnum[FAMILY_FMPKFLOOR]= +{ + {142}, + {143}, + {144}, + {145}, + {146}, + {1042}, + {2032}, + {3032}, + {4032}, +#ifdef _FAMILY_MANORNUM_CHANGE // CoolFish ޸װ԰ + {5032}, + {6032}, + {7032}, + {8032}, + {9032}, + {10032}, +#endif +}; +int leaderdengonindex = 0; +// shan end ͼ赽 family.h FAMILY_FMPKFLOOR + +void SetFMPetVarInit(int meindex) +{ + int i = 0, petindex = 0; +#ifdef _FMVER21 + if (CHAR_getInt(meindex, CHAR_FMLEADERFLAG) != FMMEMBER_LEADER) +#else + if (CHAR_getInt(meindex, CHAR_FMLEADERFLAG) != 1) +#endif + { + for (i = 0; i < CHAR_MAXPETHAVE; i++) + { + petindex = CHAR_getCharPet(meindex, i); + if (!CHAR_CHECKINDEX(petindex)) continue; + CHAR_setInt(petindex, CHAR_PETFAMILY, -1); + } + } +} + +void SetFMVarInit(int meindex) +{ + SetFMPetVarInit(meindex); // ػ Flag + CHAR_setInt(meindex, CHAR_FMINDEX, -1); + CHAR_setChar(meindex, CHAR_FMNAME, ""); + CHAR_setInt(meindex, CHAR_FMSPRITE, -1); +#ifdef _FMVER21 + CHAR_setInt(meindex, CHAR_FMLEADERFLAG, FMMEMBER_NONE); +#else + CHAR_setInt(meindex, CHAR_FMLEADERFLAG, -1); +#endif + CHAR_setWorkInt(meindex, CHAR_WORKFMSETUPFLAG, -1); + CHAR_setWorkInt(meindex, CHAR_WORKFMINDEXI, -1); + CHAR_setWorkInt(meindex, CHAR_WORKFMCHARINDEX, -1); +} + +void FAMILY_Init( void ) +{ + int i, j ,k; + + for( i=0; i 0) return -1; + if (strcmp(CHAR_getChar(meindex, CHAR_FMNAME), "") != 0) return -1; +#ifdef _FMVER21 + if (CHAR_getInt(meindex, CHAR_FMLEADERFLAG) == FMMEMBER_LEADER) return -1; +#else + if (CHAR_getInt(meindex, CHAR_FMLEADERFLAG) == 1) return -1; +#endif + return 1; +} + +int CheckFMMember(int meindex) +{ + if (CHAR_getInt(meindex, CHAR_FMINDEX) > 0) return -1; + if (strcmp(CHAR_getChar(meindex, CHAR_FMNAME), "") != 0) return -1; +#ifdef _FMVER21 + if (CHAR_getInt(meindex, CHAR_FMLEADERFLAG) > 0 && + CHAR_getInt(meindex, CHAR_FMLEADERFLAG) != FMMEMBER_APPLY ) return -1; +#else + if (CHAR_getInt(meindex, CHAR_FMLEADERFLAG) > 0 ) return -1; +#endif + return 1; +} + +int CheckLeaderQ(int meindex) +{ + if (CHAR_getInt(meindex, CHAR_LV) < FMLEADERLV + && CHAR_getInt(meindex, CHAR_TRANSMIGRATION) <= 0) + return -1; + if (!NPC_EventCheckFlg(meindex, 4)) + return -2; + return 0; +} + +void FAMILY_Add(int fd, int meindex, char* message) +{ + char token[128], fmname[128], charname[128], charid[128]; + char petname[128], fmrule[256], petattr[256], buf[1024]; + int charlv, havepetindex, petindex, fmsprite = 0, chargrano; + int gold, tmpflag; + + if (!CHAR_CHECKINDEX(meindex)) return; + + if (CHAR_getWorkInt(meindex, CHAR_WORKBATTLEMODE) != BATTLE_CHARMODE_NONE) + return; +#ifdef _FM_SERVERNO_SYS + if(getFmServerNo()!=getServernumber()){ + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + -1, -1, + getFmServerMsg()); + return; + } +#endif + if (CHAR_getInt(meindex, CHAR_FMINDEX) >= 0 + && strcmp(CHAR_getChar(meindex, CHAR_FMNAME), "") != 0) + { + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + -1, -1, + makeEscapeString( "\nѾޡ޷ٳ壡", buf, sizeof(buf))); + return; + } + tmpflag = CheckLeaderQ(meindex); + if(tmpflag == -1) + { + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + -1, -1, + makeEscapeString( "\nܱǸรĵȼ㣡", buf, sizeof(buf))); + return; + } + + if(tmpflag == -2) + { + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + -1, -1, + makeEscapeString( "\nܱǸรɳУ", buf, sizeof(buf))); + return; + } + + gold = CHAR_getInt(meindex, CHAR_GOLD); +#ifdef _NEWFM_GOLD + if( gold < getNewFmGold() ) + { + char newfmmsg[256]; + sprintf(newfmmsg,"\nܱǸรҪ%dԪʯҵѣ",getNewFmGold()); + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + -1, -1, + newfmmsg); + return; + } + else { + CHAR_setInt( meindex, CHAR_GOLD, gold-getNewFmGold() ); + CHAR_send_P_StatusString( meindex , CHAR_P_STRING_GOLD); + } +#else + if( gold < 10000 ) + { + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + -1, -1, + makeEscapeString( "\nܱǸรҪ10000Ԫʯҵѣ", buf, sizeof(buf))); + return; + } + else { + CHAR_setInt( meindex, CHAR_GOLD, gold-10000 ); + CHAR_send_P_StatusString( meindex , CHAR_P_STRING_GOLD); + } +#endif + if (getStringFromIndexWithDelim(message, "|", 2, token, + sizeof(token)) == FALSE) return; + sprintf(fmname, "%s", token); + if ((strstr(fmname, " ")) || (strcmp(fmname, "") == 0) || (strstr(fmname, ""))) + { + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + -1, -1, + makeEscapeString( "\nո", buf, sizeof(buf))); + return; + } + if (getStringFromIndexWithDelim(message, "|", 3, token, + sizeof(token)) == FALSE) return; + havepetindex = atoi(token); + petindex = CHAR_getCharPet(meindex, havepetindex); + if (!CHAR_CHECKINDEX(petindex)) + { + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + -1, -1, + makeEscapeString( "\nѡһֻΪػޣ", buf, sizeof(buf))); + return; + } + if (getStringFromIndexWithDelim(message, "|", 4, token, + sizeof(token)) == FALSE) return; + fmsprite = atoi(token); + if (getStringFromIndexWithDelim(message, "|", 5, token, + sizeof(token)) == FALSE) return; + if (strcmp(token, "") == 0) + sprintf(fmrule, ""); + else + sprintf(fmrule, "%s", token); + sprintf(charname, "%s", CHAR_getChar(meindex, CHAR_NAME)); + sprintf(charid, "%s", CHAR_getChar(meindex, CHAR_CDKEY)); + charlv = CHAR_getInt(meindex, CHAR_LV); + chargrano = CHAR_getInt(meindex, CHAR_FACEIMAGENUMBER); + if (strlen(CHAR_getChar(petindex, CHAR_USERPETNAME)) == 0) + sprintf(petname, "%s", CHAR_getChar(petindex, CHAR_NAME)); + else + sprintf(petname, "%s", CHAR_getChar(petindex, CHAR_USERPETNAME)); + sprintf(petattr, "%d %d %d %d", + CHAR_getInt(petindex, CHAR_BASEIMAGENUMBER), + CHAR_getWorkInt(petindex, CHAR_WORKATTACKPOWER), + CHAR_getWorkInt(petindex, CHAR_WORKDEFENCEPOWER), + CHAR_getWorkInt(petindex, CHAR_WORKQUICK)); + CHAR_setInt(petindex, CHAR_PETFAMILY, 1); + CHAR_setChar(meindex, CHAR_FMNAME, fmname); +#ifdef _FMVER21 + CHAR_setInt(meindex, CHAR_FMLEADERFLAG, FMMEMBER_LEADER); +#else + CHAR_setInt(meindex, CHAR_FMLEADERFLAG, 1); +#endif + CHAR_setInt(meindex, CHAR_FMSPRITE, fmsprite); + + // print("%s %s %s %d %s %s %s %d %d\n", fmname, charname, charid, charlv, petname, + // petattr, fmrule, fmsprite, chargrano); +#ifdef _PERSONAL_FAME + saacproto_ACAddFM_send(acfd, fmname, charname, charid, charlv, + petname, petattr, fmrule, fmsprite, chargrano, + CHAR_getInt(meindex, CHAR_FAME), CONNECT_getFdid(fd)); + // print("ACAddFM acfd:%d meindex:%d fmname:%s charname:%s fame:%d Connectfd:%d fd:%d\n", + // acfd, meindex, fmname, charname, CHAR_getInt(meindex, CHAR_FAME), CONNECT_getFdid(fd), fd); +#else + saacproto_ACAddFM_send(acfd, fmname, charname, charid, charlv, + petname, petattr, fmrule, fmsprite, chargrano, CONNECT_getFdid(fd)); +#endif + + // Ҫ¼б + //saacproto_ACShowFMList_send( acfd ); + +} + +/* + qr +qr +r +qةȡ~~r +辶 +tЩs ~~~~~~~~~ + + +*/ + +void ACAddFM(int fd, int result, int fmindex, int index) +{ + int meindex = CONNECT_getCharaindex(fd); + char buf[1024]; + +// print("ACAddFM result:%d fmindex:%d meindex:%d\n", result, fmindex, meindex); // test + + if (!CHAR_CHECKINDEX(meindex)) return; + +// print("ACAddFM_2!\n"); + + if (CHAR_getWorkInt(meindex, CHAR_WORKBATTLEMODE) != BATTLE_CHARMODE_NONE) + return; + +// print("ACAddFM_3!\n"); + + if(result == 1) + { + CHAR_setInt(meindex, CHAR_FMINDEX, fmindex); + CHAR_setWorkInt(meindex, CHAR_WORKFMINDEXI, index); + CHAR_setWorkInt(meindex, CHAR_WORKFMSETUPFLAG, 0); +#ifdef _NEW_MANOR_LAW + CHAR_setInt(meindex,CHAR_MOMENTUM,0); + CHAR_talkToCli(meindex,-1,"ƹ",CHAR_COLORYELLOW); +#endif + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + -1, -1, + makeEscapeString( "\nϲµļ壡ڣ֮ټ˼룬Ȼȡʸม", buf, sizeof(buf))); + JoinMemberIndex( meindex, index); + CHAR_charSaveFromConnect(meindex, FALSE); + + // Ҫ¼ + saacproto_ACShowFMList_send( acfd ); + saacproto_ACShowMemberList_send( acfd, index ); + saacproto_ACShowTopFMList_send(acfd, FM_TOP_INTEGRATE); + saacproto_ACShowTopFMList_send(acfd, FM_TOP_MOMENTUM); + + LogFamily( + CHAR_getChar( meindex, CHAR_FMNAME), + CHAR_getInt( meindex, CHAR_FMINDEX), + CHAR_getChar( meindex, CHAR_NAME), + CHAR_getChar( meindex, CHAR_CDKEY), + "ADDFAMILY()", + "" + ); + } + else + { + int i = 0, petindex = 0; + char tmpbuf[256]; + int gold = CHAR_getInt(meindex, CHAR_GOLD); +#ifdef _NEWFM_GOLD + CHAR_setInt(meindex, CHAR_GOLD, gold + getNewFmGold()); +#else + CHAR_setInt(meindex, CHAR_GOLD, gold + 10000); +#endif + CHAR_send_P_StatusString( meindex , CHAR_P_STRING_GOLD); + SetFMVarInit(meindex); + + for (i = 0; i < CHAR_MAXPETHAVE; i++) + { + petindex = CHAR_getCharPet(meindex, i); + if (!CHAR_CHECKINDEX(petindex)) continue; + CHAR_setInt(petindex, CHAR_PETFAMILY, -1); + } + if (fmindex == -2) + sprintf(tmpbuf, "\nѾֵͬļˣ"); + else + sprintf(tmpbuf, "\nʧܣ"); + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + -1, -1, + makeEscapeString(tmpbuf, buf, sizeof(buf))); + } + CHAR_sendStatusString( meindex, "F"); +} + +void FAMILY_Join(int fd, int meindex, char *message) +{ + int fmindex, charlv, index, fmsprite; + char token[128], fmname[128], charname[128], charid[128], buf[1024]; + + if (!CHAR_CHECKINDEX(meindex)) return; + + if ((CHAR_getWorkInt(meindex, CHAR_WORKPARTYMODE) != CHAR_PARTY_NONE) + || (CHAR_getWorkInt(meindex, CHAR_WORKBATTLEMODE) != BATTLE_CHARMODE_NONE)) + return; + + if (CheckFMMember(meindex) < 0){ + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + -1, -1, + makeEscapeString( "\nѾร", buf, sizeof(buf))); + return; + } + +#ifdef _FM_JOINLIMIT + if( CHAR_getInt( meindex, CHAR_FMTIMELIMIT ) > (int)time(NULL) ){ + char buff[255]; + sprintf(buff, "\n֮ǰ˳壬\n%dСʱټร",(CHAR_getInt( meindex, CHAR_FMTIMELIMIT )-(int)time(NULL))/3600+1); + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, -1, -1, + makeEscapeString( buff, buf, sizeof(buf))); + return; + } +#endif + + if (getStringFromIndexWithDelim(message, "|", 2, token, + sizeof(token)) == FALSE) return; + index = atoi(token); + if (getStringFromIndexWithDelim(message, "|", 3, token, + sizeof(token)) == FALSE) return; + fmindex = atoi(token); + if (getStringFromIndexWithDelim(message, "|", 4, token, + sizeof(token)) == FALSE) return; + sprintf(fmname, "%s", token); + if (getStringFromIndexWithDelim(message, "|", 5, token, + sizeof(token)) == FALSE) return; + fmsprite = atoi(token); + sprintf(charname, "%s", CHAR_getChar(meindex, CHAR_NAME)); + sprintf(charid, "%s", CHAR_getChar(meindex, CHAR_CDKEY)); + charlv = CHAR_getInt(meindex, CHAR_LV); + CHAR_setInt(meindex, CHAR_FMINDEX, fmindex); + CHAR_setChar(meindex, CHAR_FMNAME, fmname); +#ifdef _FMVER21 + CHAR_setInt(meindex, CHAR_FMLEADERFLAG, FMMEMBER_APPLY); +#else + CHAR_setInt(meindex, CHAR_FMLEADERFLAG, 0); +#endif + CHAR_setInt(meindex, CHAR_FMSPRITE, fmsprite); + CHAR_setWorkInt(meindex, CHAR_WORKFMINDEXI, index); + +// print("JoinFM index:%d fmindex:%d fmname:%s charname:%s charid:%s charlv:%d sprite:%d\n", +// index, fmindex, fmname, charname, charid, charlv, fmsprite); +#ifdef _PERSONAL_FAME // Arminius: +// print("fame:%d charfdid:%d\n", CHAR_getInt(meindex, CHAR_FAME), +// CONNECT_getFdid(fd)); + saacproto_ACJoinFM_send(acfd, fmname, fmindex, charname, charid, charlv, + index, CHAR_getInt(meindex, CHAR_FAME), CONNECT_getFdid(fd)); +#else +// print("charfdid:%d\n", CONNECT_getFdid(fd)); + saacproto_ACJoinFM_send(acfd, fmname, fmindex, charname, charid, charlv, + index, CONNECT_getFdid(fd)); +#endif +} + +void ACJoinFM(int fd, int result, int recv) +{ + int meindex = CONNECT_getCharaindex(fd); + char buf[1024]; + + if(!CHAR_CHECKINDEX(meindex)) return; + + if ((CHAR_getWorkInt(meindex, CHAR_WORKPARTYMODE) != CHAR_PARTY_NONE) + || (CHAR_getWorkInt(meindex, CHAR_WORKBATTLEMODE) != BATTLE_CHARMODE_NONE)) + return; + + if (result == 1) { + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + -1, -1, + makeEscapeString( "\nллļ룡ȵ峤֮ͨᣬʽ롣", buf, sizeof(buf))); + + JoinMemberIndex( meindex, CHAR_getWorkInt(meindex, CHAR_WORKFMINDEXI) ); +#ifdef _NEW_MANOR_LAW + CHAR_setInt(meindex,CHAR_MOMENTUM,0); + CHAR_talkToCli(meindex,-1,"ƹ",CHAR_COLORYELLOW); +#endif + + sprintf(buf,"fame:%d",CHAR_getInt(meindex,CHAR_FAME)); + + LogFamily( + CHAR_getChar( meindex, CHAR_FMNAME), + CHAR_getInt( meindex, CHAR_FMINDEX), + CHAR_getChar( meindex, CHAR_NAME), + CHAR_getChar( meindex, CHAR_CDKEY), + "JOINFAMILY()", + buf + ); + + } + else + { + SetFMVarInit(meindex); + if (recv == -2) + { + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + -1, -1, + makeEscapeString( "\n˼ĿǰԸճԱ", buf, sizeof(buf))); + } + else if (recv == -3) + { + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + -1, -1, + makeEscapeString( "\n˼Ŀǰ޷ճԱԱѵޣ", buf, sizeof(buf))); + } + else + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + -1, -1, + makeEscapeString( "\nʧܣ", buf, sizeof(buf))); + } + + CHAR_sendStatusString( meindex, "F"); +} + +void FAMILY_Leave(int fd, int meindex, char *message) +{ + int result, fmindex, index; + char token[128], fmname[128], charname[128], charid[128], buf[1024]; + + if (!CHAR_CHECKINDEX(meindex)) return; + + if (CHAR_getWorkInt(meindex, CHAR_WORKBATTLEMODE) != BATTLE_CHARMODE_NONE) + return; + + if ((CHAR_getInt(meindex, CHAR_FMINDEX) == -1) + || (strcmp(CHAR_getChar(meindex, CHAR_FMNAME), "") == 0) +#ifdef _FMVER21 + || (CHAR_getInt(meindex, CHAR_FMLEADERFLAG) == FMMEMBER_NONE)) +#else + || (CHAR_getInt(meindex, CHAR_FMLEADERFLAG) == -1)) +#endif + { + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + -1, -1, + makeEscapeString( "\n㲢ûмร", buf, sizeof(buf))); + return; + } + + { + int i, fmpks_pos; + for( i=1; i<=MANORNUM; i++){ // CoolFish 4->MANORNUM 2002/2/25 + fmpks_pos = i * MAX_SCHEDULE; +#ifdef _FMVER21 + if (CHAR_getInt(meindex, CHAR_FMLEADERFLAG) == FMMEMBER_LEADER){ +#else + if (CHAR_getInt(meindex, CHAR_FMLEADERFLAG) == 1){ +#endif + if( (fmpks[fmpks_pos+1].host_index+1) == CHAR_getInt(meindex, CHAR_FMINDEX) || + (fmpks[fmpks_pos+1].guest_index+1) == CHAR_getInt(meindex, CHAR_FMINDEX) ){ + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + -1, -1, + makeEscapeString( "\nĿǰļԼսУ޷ɢ壡", buf, sizeof(buf))); + return; + } + } + } + } + + if (getStringFromIndexWithDelim(message, "|", 2, token, + sizeof(token)) == FALSE) return; + result = atoi(token); + if (result == 1) + { + fmindex = CHAR_getInt(meindex, CHAR_FMINDEX); + index = CHAR_getWorkInt(meindex, CHAR_WORKFMINDEXI); + sprintf(fmname, "%s", CHAR_getChar(meindex, CHAR_FMNAME)); + sprintf(charname, "%s", CHAR_getChar(meindex, CHAR_NAME)); + sprintf(charid, "%s", CHAR_getChar(meindex, CHAR_CDKEY)); +#ifdef _FMVER21 + if (CHAR_getInt(meindex, CHAR_FMLEADERFLAG) == FMMEMBER_LEADER) { +#else + if (CHAR_getInt(meindex, CHAR_FMLEADERFLAG) == 1) { +#endif +// print("DelFM index:%d fmindex:%d fmname:%s\n", index, fmindex, fmname); +#ifdef _FM_SERVERNO_SYS + if(getFmServerNo()!=getServernumber()){ + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + -1, -1, + getFmServerMsg()); + return; + } +#endif + saacproto_ACDelFM_send(acfd, fmname, fmindex, index, charname, charid, + CONNECT_getFdid(fd)); +#ifdef _FMRANK_POINT + if(sasql_fmpoint_query(fmindex)>0) + sasql_fmindex_del(fmindex); +#endif + // Ҫ¼б + //saacproto_ACShowFMList_send( acfd ); + } + else { +// print("LeaveFM index:%d fmindex:%d fmname:%s charname:%s charid:%s\n", +// index, fmindex, fmname, charname, charid); + saacproto_ACLeaveFM_send(acfd, fmname, fmindex, charname, charid, index, + CONNECT_getFdid(fd)); + } + + } +} + +void ACLeaveFM( int fd, int result, int resultflag) +{ + int meindex = CONNECT_getCharaindex(fd); + char buf[1024]; + + if (!CHAR_CHECKINDEX(meindex)) return; + if (result == 1){ + // won 2002/01/05 + LogFamily( + CHAR_getChar( meindex, CHAR_FMNAME), + CHAR_getInt( meindex, CHAR_FMINDEX), + CHAR_getChar( meindex, CHAR_NAME), + CHAR_getChar( meindex, CHAR_CDKEY), + "LEAVEFAMILY(뿪)", + "" + ); + if( CHAR_getWorkInt( meindex, CHAR_WORKFMCHANNEL) != -1 ) + CHAR_setWorkInt( meindex, CHAR_WORKFMCHANNEL, -1 ); + LeaveMemberIndex( meindex, CHAR_getWorkInt(meindex, CHAR_WORKFMINDEXI) ); + SetFMVarInit(meindex); + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, -1, -1, + makeEscapeString( "\n˳ϣˣ", buf, sizeof(buf))); + CHAR_setWorkInt( meindex, CHAR_WORKFMFLOOR, -1); +#ifdef _FM_JOINLIMIT + CHAR_setInt( meindex, CHAR_FMTIMELIMIT, (int)time(NULL)+getJoinFamilyTime()*(60*60) ); +#endif +#ifdef _NEW_MANOR_LAW + CHAR_setInt(meindex,CHAR_MOMENTUM,0); + CHAR_talkToCli(meindex,-1,"˳ƹ",CHAR_COLORYELLOW); +#endif + CHAR_setInt( meindex , CHAR_RIDEPET, -1 ); + CHAR_setInt( meindex , CHAR_BASEIMAGENUMBER , CHAR_getInt( meindex , CHAR_BASEBASEIMAGENUMBER) ); + CHAR_complianceParameter( meindex ); + CHAR_sendCToArroundCharacter( CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX )); + CHAR_send_P_StatusString( meindex , CHAR_P_STRING_RIDEPET); +#ifdef _FM_METAMO + CHAR_ReMetamo(meindex); +#endif + }else + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, -1, -1, + makeEscapeString( "\n˳ʧܣ", buf, sizeof(buf))); + + CHAR_sendStatusString( meindex, "F" ); +} + +void ACDelFM(int fd, int result) +{ + char buf[1024]; + int meindex = CONNECT_getCharaindex(fd); + if (!CHAR_CHECKINDEX(meindex)) return; + + //if ((CHAR_getWorkInt(meindex, CHAR_WORKPARTYMODE) != CHAR_PARTY_NONE) + // || (CHAR_getWorkInt(meindex, CHAR_WORKBATTLEMODE) != BATTLE_CHARMODE_NONE)) + // return; + + if (result == 1) + { +// WON ADD +if(CHAR_getWorkInt(meindex, CHAR_WORKFMINDEXI)>-1){ + LogFamily( + CHAR_getChar( meindex, CHAR_FMNAME), + CHAR_getInt( meindex, CHAR_FMINDEX), + CHAR_getChar( meindex, CHAR_NAME), + CHAR_getChar( meindex, CHAR_CDKEY), + "DELFAMILY(ɢ)", + "" + ); + + LeaveMemberIndex( meindex, CHAR_getWorkInt(meindex, CHAR_WORKFMINDEXI) ); + /* + for( i=0; i0){ + familyNumTotal = familyNumTotal + fmranknum; + int i; + char fmrankbuf[128]; + memset(fmrankbuf, 0, sizeof(fmrankbuf)); + char *tempbuf=NULL; + char fmrankdata[128]; + memset(fmrankdata, 0, sizeof(fmrankdata)); + for(i=0;i familyNumTotal ) break; + if( getStringFromIndexWithDelim( familyListBuf, "|", i, subbuf, + sizeof(subbuf) ) == FALSE) break; + strcat( buf, "|" ); + strcat( buf, subbuf ); + j++; + + // print(" |%s| ", subbuf); + } + + sprintf( sendbuf, "S|F|%d|%d|%d%s", familyNumTotal, atoi(token2), j, buf ); + lssproto_FM_send( fd, sendbuf ); + + return; + + } + + // shan add + if (strcmp(token, "P") == 0 ){ +#ifdef _CAX_FAMEBUTTON + if (strcmp( getfamebutton() , "") == 0) + { + fameButton( meindex); //ABluať + }else{ +#endif + int personfame; + char sendbuf[512]; + int fd = getfdFromCharaIndex( meindex); + char* id = CHAR_getChar( meindex, CHAR_CDKEY ); + int viptype = CHAR_getInt( meindex, CHAR_VIPRIDE ); + int viptime = CHAR_getInt( meindex, CHAR_VIPTIME ); + if(viptime>0) + { + time_t timep; + struct tm *p; + time(&timep); + p=localtime(&timep); + timep = mktime(p); + viptime = viptime - timep; + } +#ifdef _PERSONAL_FAME + personfame = (CHAR_getInt( meindex, CHAR_FAME)/100); +#else + personfame = CHAR_getWorkInt( meindex, CHAR_WORKFMDP); +#endif + CHAR_talkToCli(meindex, -1, "˻Ϣ", CHAR_COLORYELLOW); +#ifdef _NEW_CurrencyShow + sprintf(sendbuf, "%-12d Ƶ%-12d ˻ֵ%d", personfame, + CHAR_getInt(meindex,CHAR_MOMENTUM)/100, sasql_ampoint( CHAR_getChar(meindex,CHAR_CDKEY), 0,0)); + CHAR_talkToCli(meindex, -1, sendbuf, CHAR_COLORGREEN); + + sprintf(sendbuf, "˱ǵ%-12d ˻%-12d ˻Ա%d", CHAR_getInt(meindex,CHAR_CAMEO), + CHAR_getInt(meindex,CHAR_VIGOR), sasql_vippoint(id,0,0)); + CHAR_talkToCli(meindex, -1, sendbuf, CHAR_COLORBLUE); + + sprintf(sendbuf, "ֽ˻%-12d %-12d ܻ%d", sasql_rmbpoint(id,0,0), + CHAR_getInt(meindex,CHAR_MISSIONTRAIN_NUM), CHAR_getInt(meindex,CHAR_EVNUM)); + CHAR_talkToCli(meindex, -1, sendbuf, CHAR_COLORPURPLE); + +#ifdef _OFFLINE_SYSTEM + if(getOfflineCf()==0) + sprintf(sendbuf,"ʱ䣺%d (δ)",(int)(CHAR_getInt(meindex,CHAR_OFFTIME)/60)); + else if(getOfflineCf()==1) + sprintf(sendbuf,"ʱ䣺%d",(int)(CHAR_getInt(meindex,CHAR_OFFTIME)/60)); + else + sprintf(sendbuf,"ʱ䣺%d (߲ʱ)",(int)(CHAR_getInt(meindex,CHAR_OFFTIME)/60)); + CHAR_talkToCli(meindex, -1, sendbuf, CHAR_COLORYELLOW); +#endif + + if(viptime == 0){ + CHAR_talkToCli(meindex, -1, "Ȩޣδ", CHAR_COLORYELLOW); + } + if(viptime<0) + { + CHAR_setInt(meindex,CHAR_VIPRIDE,0); + CHAR_setInt(meindex,CHAR_VIPTIME,0); + CHAR_loginCheckUserItem(meindex); + viptype = CHAR_getInt(meindex,CHAR_VIPRIDE); + } + if(viptime>0) + { + viptime = (int)(viptime/60/60/24); + if(viptype==1) + { + sprintf(sendbuf,"ͨԱʣࣺ%d",viptime+1); + CHAR_talkToCli(meindex, -1, sendbuf, CHAR_COLORYELLOW); + } + else if(viptype==2) + { + sprintf(sendbuf,"ƽԱʣࣺ%d",viptime+1); + CHAR_talkToCli(meindex, -1, sendbuf, CHAR_COLORYELLOW); + } + else if(viptype==3) + { + sprintf(sendbuf,"ʯԱʣࣺ%d",viptime+1); + CHAR_talkToCli(meindex, -1, sendbuf, CHAR_COLORYELLOW); + } + } + + sprintf(sendbuf,"߻飺%d",getBattleexp()); + CHAR_talkToCli(meindex, -1, sendbuf, CHAR_COLORYELLOW); +#ifdef _VIP_BATTLE_EXP + int nvipexp, nviptime; + nvipexp = CHAR_getInt( meindex, CHAR_NVIPEXP); + nviptime = CHAR_getInt( meindex, CHAR_NVIPTIME )/60; + if (nvipexp > 0 && CHAR_getInt( meindex, CHAR_VIPTIME ) == 0){ + sprintf(sendbuf,"⾭ӳɣ%d (ʱЧ%d)",getVipBattleExp(), nviptime); + CHAR_talkToCli(meindex, -1, sendbuf, CHAR_COLORBLUE2); + }else if (CHAR_getInt( meindex, CHAR_VIPTIME ) > 0){ + sprintf(sendbuf,"⾭ӳɣ%d (ʱЧԱ)",getVipBattleExp()); + CHAR_talkToCli(meindex, -1, sendbuf, CHAR_COLORBLUE2); + } +#endif +#ifdef _EXP_TIME_OUT + int ITEM_ADDEXP,ITEM_ADDEXP_TIME; + ITEM_ADDEXP = CHAR_getInt( meindex, CHAR_ADDEXPPOWER ); + if(ITEM_ADDEXP>0){ + ITEM_ADDEXP_TIME = CHAR_getInt( meindex, CHAR_ADDEXPTIME )/60; + sprintf(sendbuf,"Ʒӳɣ%d (ʱЧ%d)",ITEM_ADDEXP,ITEM_ADDEXP_TIME); + CHAR_talkToCli(meindex, -1, sendbuf, CHAR_COLORCYAN); + } +#endif + +#else//_NEW_CurrencyShow + + sprintf( sendbuf, "%d", personfame); + CHAR_talkToCli(meindex, -1, sendbuf, CHAR_COLORYELLOW); +#ifdef _NEW_MANOR_LAW + sprintf(sendbuf,"ƣ%d",CHAR_getInt(meindex,CHAR_MOMENTUM)/100); + CHAR_talkToCli(meindex, -1, sendbuf, CHAR_COLORYELLOW); +#endif +#ifdef _VIP_SERVER + sprintf(sendbuf,"˻֣%d",sasql_ampoint( CHAR_getChar(meindex,CHAR_CDKEY), 0,0)); + CHAR_talkToCli(meindex, -1, sendbuf, CHAR_COLORYELLOW); + if(viptime<0) + { + CHAR_setInt(meindex,CHAR_VIPRIDE,0); + CHAR_setInt(meindex,CHAR_VIPTIME,0); + CHAR_loginCheckUserItem(meindex); + viptype = CHAR_getInt(meindex,CHAR_VIPRIDE); + } + if(viptime>0) + { + viptime = (int)(viptime/60/60/24); + if(viptype==1) + { + sprintf(sendbuf,"ʣԱΪ%d",viptime+1); + CHAR_talkToCli(meindex, -1, sendbuf, CHAR_COLORYELLOW); + } + else if(viptype==2) + { + sprintf(sendbuf,"ʣƽԱΪ%d",viptime+1); + CHAR_talkToCli(meindex, -1, sendbuf, CHAR_COLORYELLOW); + } + else if(viptype==3) + { + sprintf(sendbuf,"ʣʯԱΪ%d",viptime+1); + CHAR_talkToCli(meindex, -1, sendbuf, CHAR_COLORYELLOW); + } + } +#endif + sprintf(sendbuf,"Ա%d",sasql_vippoint(id,0,0)); + CHAR_talkToCli(meindex, -1, sendbuf, CHAR_COLORYELLOW); +#ifdef _VIGOR_SYS + sprintf(sendbuf,"%d",CHAR_getInt(meindex,CHAR_VIGOR)); + CHAR_talkToCli(meindex, -1, sendbuf, CHAR_COLORYELLOW); +#endif +#ifdef _EV_NUM + sprintf(sendbuf,"ܻ%d",CHAR_getInt(meindex,CHAR_EVNUM)); + CHAR_talkToCli(meindex, -1, sendbuf, CHAR_COLORYELLOW); +#endif +//#ifdef _STU_SYS +// sprintf(sendbuf,"ʦ֣%d",CHAR_getInt(meindex,CHAR_STUNUM)); +// CHAR_talkToCli(meindex, -1, sendbuf, CHAR_COLORYELLOW); +//#endif +#ifdef _RMB_SYSTEM + sprintf(sendbuf,"ֽ˻%d",sasql_rmbpoint(id,0,0)); + CHAR_talkToCli(meindex, -1, sendbuf, CHAR_COLORYELLOW); +#endif +#ifdef _OFFLINE_SYSTEM + if(getOfflineCf()==0) + sprintf(sendbuf,"ʱ䣺%dӣ߲֧߹һ",(int)(CHAR_getInt(meindex,CHAR_OFFTIME)/60)); + else if(getOfflineCf()==1) + sprintf(sendbuf,"ʱ䣺%d",(int)(CHAR_getInt(meindex,CHAR_OFFTIME)/60)); + else + sprintf(sendbuf,"ʱ䣺%dӣĿǰ߲ʱ䣩",(int)(CHAR_getInt(meindex,CHAR_OFFTIME)/60)); + CHAR_talkToCli(meindex, -1, sendbuf, CHAR_COLORYELLOW); +#endif + sprintf(sendbuf,"߻飺%d",getBattleexp()); + CHAR_talkToCli(meindex, -1, sendbuf, CHAR_COLORYELLOW); +#ifdef _EXP_TIME_OUT + int ITEM_ADDEXP,ITEM_ADDEXP_TIME; + ITEM_ADDEXP = CHAR_getInt( meindex, CHAR_ADDEXPPOWER ); + if(ITEM_ADDEXP>0){ + ITEM_ADDEXP_TIME = CHAR_getInt( meindex, CHAR_ADDEXPTIME )/60; + sprintf(sendbuf,"Ʒӳɣ%d% ʱЧ%d",ITEM_ADDEXP,ITEM_ADDEXP_TIME); + CHAR_talkToCli(meindex, -1, sendbuf, CHAR_COLORYELLOW); + } +#endif + +#endif//_NEW_CurrencyShow +#ifdef _CAX_FAMEBUTTON + } +#endif + } + + if(strcmp(token,"D") == 0){ + if(getStringFromIndexWithDelim(message, "|", 3, fmname, sizeof(fmname)) == FALSE) return; + if(getStringFromIndexWithDelim(message, "|", 4, token2, sizeof(token2)) == FALSE) return; + fmindex = atoi( token2 ); + if(getStringFromIndexWithDelim(message, "|", 5, token2, sizeof(token2)) == FALSE) return; + tempindex = atoi( token2 ); + + //print(" send_fmname_ac:%s ", fmname); + saacproto_ACFMDetail_send( acfd, fmname, fmindex, tempindex, CONNECT_getFdid(fd) ); + } + + // shan begin + else if (strcmp(token, "D2") ==0 ) { + char sendbuf[2048], tmpbuf[1024], leadernamebuf[64]; + int h, i = 0; + int meindex = CONNECT_getCharaindex(fd); + int fmindex_wk = CHAR_getWorkInt( meindex, CHAR_WORKFMINDEXI); + if( fmindex_wk < 0 || fmindex_wk >= FAMILY_MAXNUM) return; + + for( h=0; h ||峤||||ְλ|徫|PK +#ifdef _NEW_MANOR_LAW + sprintf( sendbuf, "%s|%d|%s|%d|%d|%d|%d|%d|%s|%d|%d", +#else + sprintf( sendbuf, "%s|%d|%s|%d|%d|%d|%d|%d|%s", +#endif + CHAR_getChar(meindex, CHAR_FMNAME), + memberlist[fmindex_wk].fmjoinnum, + leadernamebuf, + h+1, +#ifdef _FMVER21 + fmdptop.fmtopdp[h], +#else + (CHAR_getWorkInt( meindex, CHAR_WORKFMDP)/100), +#endif +#ifdef _PERSONAL_FAME + (CHAR_getInt( meindex, CHAR_FAME)/100), +#else + (CHAR_getWorkInt( meindex, CHAR_WORKFMDP)/100), +#endif + CHAR_getInt( meindex, CHAR_FMLEADERFLAG), + CHAR_getInt( meindex, CHAR_FMSPRITE ), + tmpbuf +#ifdef _NEW_MANOR_LAW + ,fmdptop.fmMomentum[h]/100 // + ,CHAR_getInt(meindex,CHAR_MOMENTUM)/100 // +#endif + ); + + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_FAMILYDETAIL, + WINDOW_BUTTONTYPE_OK, + -1, + -1, + makeEscapeString( sendbuf, buf, sizeof(buf))); + } + // shan end +} + +void ACFMDetail(int ret, char *data, int clifd) +{ + char sendbuf[1024]; + + //print(" Detail:%s ", data); + + if( ret != 1 ) + { + print(" ACFMDetailError!:%d ", clifd ); + return; + } + //print(" ACFMDetail:%d:%s ", clifd, data ); + + /* + len = strlen(data); + strcpy( buf, data ); + + for( i=0 ; i :%s (ΪԱ):%d\n", CHAR_getInt(meindex, CHAR_FMLEADERFLAG), charname, charindex); + LogFamily( + CHAR_getChar(meindex, CHAR_FMNAME), + CHAR_getInt(meindex, CHAR_FMINDEX), + CHAR_getChar(meindex, CHAR_NAME), + CHAR_getChar(meindex, CHAR_CDKEY), + "CheckMember", + sbuf + ); + // shan end + + saacproto_ACMemberJoinFM_send(acfd, + CHAR_getChar(meindex, CHAR_FMNAME), + CHAR_getInt(meindex, CHAR_FMINDEX), charname, charindex, + CHAR_getWorkInt(meindex, CHAR_WORKFMINDEXI), result, + CHAR_getWorkInt(meindex, CHAR_WORKFMCHARINDEX), + CONNECT_getFdid(fd)); + } +#else + { + saacproto_ACMemberJoinFM_send(acfd, + CHAR_getChar(meindex, CHAR_FMNAME), + CHAR_getInt(meindex, CHAR_FMINDEX), charname, charindex, + CHAR_getWorkInt(meindex, CHAR_WORKFMINDEXI), result, + CONNECT_getFdid(fd)); + } +#endif +#ifdef _FMVER21 + else if (result == FMMEMBER_NONE) +#else + else if (result == 4) +#endif + { + for (i = 0 + 1; i < FAMILY_MAXHOME + 1; i++) + { + int fmpks_pos = i * MAX_SCHEDULE; + if ((fmpks[fmpks_pos].host_index == index + && strcmp(fmname, fmpks[fmpks_pos].host_name) == 0) + || (fmpks[fmpks_pos].guest_index == index + && strcmp(fmname, fmpks[fmpks_pos].guest_name) == 0)) + { + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + -1, -1, + makeEscapeString( "\nĿǰսУ޷˳Ա", buf, sizeof(buf))); +// print("fmpks_pos:%d index:%d host:%d guest:%d\n", fmpks_pos, +// index, fmpks[fmpks_pos].host_index, fmpks[fmpks_pos].guest_index); + return; + } + } +#ifdef _FMVER21 + { + // shan begin + char sbuf[1024]; + sprintf( sbuf, "峤:%d -> :%s :%d (˳)\n", CHAR_getInt(meindex, CHAR_FMLEADERFLAG), charname, charindex); + LogFamily( + CHAR_getChar(meindex, CHAR_FMNAME), + CHAR_getInt(meindex, CHAR_FMINDEX), + CHAR_getChar(meindex, CHAR_NAME), + CHAR_getChar(meindex, CHAR_CDKEY), + "CheckMember", + sbuf + ); + // shan end + saacproto_ACMemberLeaveFM_send(acfd, + CHAR_getChar(meindex, CHAR_FMNAME), + CHAR_getInt(meindex, CHAR_FMINDEX), charname, charindex, + CHAR_getWorkInt(meindex, CHAR_WORKFMINDEXI), + CHAR_getWorkInt(meindex, CHAR_WORKFMCHARINDEX), + CONNECT_getFdid(fd)); + } +#else + { + saacproto_ACMemberLeaveFM_send(acfd, + CHAR_getChar(meindex, CHAR_FMNAME), + CHAR_getInt(meindex, CHAR_FMINDEX), charname, charindex, + CHAR_getWorkInt(meindex, CHAR_WORKFMINDEXI), + CONNECT_getFdid(fd)); + } +#endif + } +#ifdef _FMVER21 +// else if (result == FMMEMBER_ELDER || result == FMMEMBER_INVITE +// || result == FMMEMBER_BAILEE || result == FMMEMBER_VICELEADER ) + else if (result == FMMEMBER_ELDER ) + { + if (CHAR_getInt(meindex, CHAR_FMLEADERFLAG) != FMMEMBER_LEADER) + return; +#ifdef _FMVER21 + { + // shan begin + char sbuf[1024]; + sprintf( sbuf, "峤:%d -> :%s :%d (Ϊ)\n", CHAR_getInt(meindex, CHAR_FMLEADERFLAG), charname, charindex); + LogFamily( + CHAR_getChar(meindex, CHAR_FMNAME), + CHAR_getInt(meindex, CHAR_FMINDEX), + CHAR_getChar(meindex, CHAR_NAME), + CHAR_getChar(meindex, CHAR_CDKEY), + "CheckMember", + sbuf + ); + // shan end + saacproto_ACMemberJoinFM_send(acfd, + CHAR_getChar(meindex, CHAR_FMNAME), + CHAR_getInt(meindex, CHAR_FMINDEX), charname, charindex, + CHAR_getWorkInt(meindex, CHAR_WORKFMINDEXI), result, + CHAR_getWorkInt(meindex, CHAR_WORKFMCHARINDEX), + CONNECT_getFdid(fd)); + } +#else + { + saacproto_ACMemberJoinFM_send(acfd, + CHAR_getChar(meindex, CHAR_FMNAME), + CHAR_getInt(meindex, CHAR_FMINDEX), charname, charindex, + CHAR_getWorkInt(meindex, CHAR_WORKFMINDEXI), result, + CONNECT_getFdid(fd)); + } +#endif + } +#endif + // Ҫ¼б + saacproto_ACShowFMList_send( acfd ); +} + +void FAMILY_Channel(int fd, int meindex, char *message) +{ + char token[128], token2[128]; + char buf[4096], subbuf[4096], sendbuf[4096]; + int i, tempindex, fmindexi, channel, nowchannel, num; + + fmindexi = CHAR_getWorkInt( meindex, CHAR_WORKFMINDEXI); + nowchannel = CHAR_getWorkInt( meindex, CHAR_WORKFMCHANNEL ); + + // print(" channelFM:%d ", fmindexi); + if( fmindexi < 0 ) { + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + -1, -1, + makeEscapeString( "\n㻹ûмκμ壡", buf, sizeof(buf))); + return; + } + + if (getStringFromIndexWithDelim(message, "|", 2, token, + sizeof(token)) == FALSE) return; + + if (getStringFromIndexWithDelim(message, "|", 3, token2, + sizeof(token2)) == FALSE) return; + + channel = atoi( token2 ); + + if( strcmp( token, "J") == 0) { + if( channel < -1 || channel > FAMILY_MAXCHANNEL )return; + if( nowchannel >= 0 && nowchannel < FAMILY_MAXCHANNEL ) { + i = 0; + while( i < FAMILY_MAXMEMBER ) { + if( channelMember[fmindexi][nowchannel][i] == meindex ) { + channelMember[fmindexi][nowchannel][i] = -1; + break; + } + i++; + } + } + + if( channel > 0 && channel < FAMILY_MAXCHANNEL ) { + i = 0; + while( i < FAMILY_MAXCHANNELMEMBER ) { + if( channelMember[fmindexi][channel][i] < 0 ) { + channelMember[fmindexi][channel][i] = meindex; + break; + } + i++; + } + if( i >= FAMILY_MAXCHANNELMEMBER ) { + CHAR_talkToCli( meindex, -1, "Ƶ", CHAR_COLORWHITE); + return; + } + sprintf( buf, "Ƶ [%d]", channel ); + CHAR_talkToCli( meindex, -1, buf, CHAR_COLORWHITE); + + if( nowchannel >=0 && nowchannel < FAMILY_MAXCHANNEL ) { + sprintf( buf, "%s ˳Ƶ", CHAR_getChar( meindex, CHAR_NAME) ); + for( i=0; i < FAMILY_MAXCHANNELMEMBER; i++ ) { + if( CHAR_CHECKINDEX(channelMember[fmindexi][nowchannel][i]) + && channelMember[fmindexi][nowchannel][i] != meindex ) { + CHAR_talkToCli( channelMember[fmindexi][nowchannel][i], -1, buf, CHAR_COLORWHITE); + } + } + } + sprintf( buf, "%s Ƶ", CHAR_getChar( meindex, CHAR_NAME) ); + for( i=0; i < FAMILY_MAXCHANNELMEMBER; i++ ) { + if( CHAR_CHECKINDEX(channelMember[fmindexi][channel][i]) + && channelMember[fmindexi][channel][i] != meindex ) { + CHAR_talkToCli( channelMember[fmindexi][channel][i], -1, buf, CHAR_COLORWHITE); + } + } + + } + else if( channel == 0 ) { + i = 0; + while( i < FAMILY_MAXMEMBER ) { + if( channelMember[fmindexi][0][i] < 0 ) { + channelMember[fmindexi][0][i] = meindex; + break; + } + i++; + } + if( i >= FAMILY_MAXMEMBER ) { +#ifndef _CHANNEL_MODIFY + CHAR_talkToCli( meindex, -1, "Ƶ", CHAR_COLORWHITE); +#endif + return; + } +#ifndef _CHANNEL_MODIFY + sprintf( buf, "Ƶ [ȫ]"); + CHAR_talkToCli( meindex, -1, buf, CHAR_COLORWHITE); + if( nowchannel >=0 && nowchannel < FAMILY_MAXCHANNEL ) { + sprintf( buf, "%s ˳Ƶ", CHAR_getChar( meindex, CHAR_NAME) ); + for( i=0; i < FAMILY_MAXCHANNELMEMBER; i++ ) { + if( CHAR_CHECKINDEX(channelMember[fmindexi][nowchannel][i]) + && channelMember[fmindexi][nowchannel][i] != meindex ) { + CHAR_talkToCli( channelMember[fmindexi][nowchannel][i], -1, buf, CHAR_COLORWHITE); + } + } + } + sprintf( buf, "%s Ƶ", CHAR_getChar( meindex, CHAR_NAME) ); + for( i=0; i < FAMILY_MAXCHANNELMEMBER; i++ ) { + if( CHAR_CHECKINDEX(channelMember[fmindexi][channel][i]) + && channelMember[fmindexi][channel][i] != meindex ) { + CHAR_talkToCli( channelMember[fmindexi][channel][i], -1, buf, CHAR_COLORWHITE); + } + } +#endif + } +#ifdef _FMVER21 + else if( channel == FAMILY_MAXCHANNEL && CHAR_getInt( meindex, CHAR_FMLEADERFLAG ) == FMMEMBER_LEADER ) +#else + else if( channel == FAMILY_MAXCHANNEL && CHAR_getInt( meindex, CHAR_FMLEADERFLAG ) == 1 ) +#endif + { + CHAR_talkToCli( meindex, -1, "峤㲥", CHAR_COLORWHITE); + } + else { + channel = -1; +#ifndef _CHANNEL_MODIFY + CHAR_talkToCli( meindex, -1, "˳Ƶ", CHAR_COLORWHITE); +#else + CHAR_talkToCli( meindex, -1, "ر峤㲥", CHAR_COLORWHITE); + channel = 0; + i = 0; + while(i < FAMILY_MAXMEMBER){ + if( channelMember[fmindexi][0][i] < 0 ) { + channelMember[fmindexi][0][i] = meindex; + break; + } + i++; + } +#endif + + sprintf( buf, "%s ˳Ƶ", CHAR_getChar( meindex, CHAR_NAME) ); + for( i=0; i < FAMILY_MAXCHANNELMEMBER; i++ ) { + if( CHAR_CHECKINDEX(channelMember[fmindexi][nowchannel][i]) + && channelMember[fmindexi][nowchannel][i] != meindex ) { + CHAR_talkToCli( channelMember[fmindexi][nowchannel][i], -1, buf, CHAR_COLORWHITE); + } + } + } + + CHAR_setWorkInt( meindex, CHAR_WORKFMCHANNEL, channel); + if( channel != -1 ) CHAR_setWorkInt( meindex, CHAR_WORKFMCHANNELQUICK, channel); + + sprintf( sendbuf, "C|J|%d", channel); + lssproto_FM_send( fd, sendbuf); + + } + else if( strcmp( token, "L") == 0) { + + int j, membernum, bFind = 0; + if( channel < 0 || channel >= FAMILY_MAXCHANNEL ) return; + + subbuf[0] = '\0'; + num = 0; + if( channel != 0 ) + membernum = FAMILY_MAXCHANNELMEMBER; + else + membernum = FAMILY_MAXMEMBER; + + for( j = 0 ; j < FAMILY_MAXMEMBER ; j++ ) { + bFind = 0; + tempindex = familyMemberIndex[fmindexi][j]; + //if( tempindex >= 0 ) { + if( CHAR_CHECKINDEX(tempindex) ) { + for( i=0; i< membernum ; i++) { + if( tempindex == channelMember[fmindexi][channel][i] ) { + //if( CHAR_getChar( tempindex, CHAR_NAME ) == NULL ) { + // familyMemberIndex[fmindexi][j] = -1; + // channelMember[fmindexi][channel][i] = -1; + // continue; + //} + bFind = 1; + break; + } + } + if( bFind ) + strcat( subbuf, "|1|" ); + else + strcat( subbuf, "|0|" ); + makeEscapeString( CHAR_getChar( tempindex, CHAR_NAME ), buf, sizeof(buf)); + strcat( subbuf, buf ); + num++; + } + } + sprintf( sendbuf, "C|L|%d|%d%s", channel, num, subbuf); + lssproto_FM_send( fd, sendbuf); + //print(" CList:%s ", sendbuf); + } +} + +void FAMILY_Bank(int fd, int meindex, char *message) +{ + if(CHAR_getWorkInt(meindex,CHAR_WORKSTREETVENDOR) > 0) + return; + char token[128], token2[128], buf[1024]; + int fmindex, cash, bank, toBank; + int MaxGold; + MaxGold = CHAR_getMaxHaveGold( meindex); + fmindex = CHAR_getInt( meindex, CHAR_FMINDEX); + // add shan + if( fmindex <= 0 && CHAR_getInt( meindex, CHAR_BANKGOLD) < 1) { + CHAR_talkToCli( meindex, -1, "ȼ塣", CHAR_COLORWHITE); + return; + } + + if (getStringFromIndexWithDelim(message, "|", 2, token, sizeof(token)) == FALSE) + return; + + if( strcmp(token, "G" )==0 ) { + if (getStringFromIndexWithDelim(message, "|", 3, token2, sizeof(token)) == FALSE) + return; + + toBank = atoi( token2 ); + cash = CHAR_getInt( meindex, CHAR_GOLD); + bank = CHAR_getInt( meindex, CHAR_BANKGOLD); + if( ((cash - toBank) >= 0) && ((cash - toBank) <= MaxGold ) + &&((bank + toBank) >= 0)&&((bank + toBank) <= CHAR_MAXBANKGOLDHAVE) ) { + // shan add + if( toBank > 0 && CHAR_getInt( meindex, CHAR_FMINDEX ) < 1 ) { + sprintf(buf, "Ǹûмκμ壬Խȡ"); + CHAR_talkToCli( meindex, -1, buf, CHAR_COLORWHITE); + return; + } + + CHAR_setInt( meindex, CHAR_GOLD, cash - toBank); + CHAR_setInt( meindex, CHAR_BANKGOLD, bank + toBank); + CHAR_send_P_StatusString( meindex , CHAR_P_STRING_GOLD); + + if( toBank >= 0 ) { + sprintf(buf, "%dиʻ", toBank); + CHAR_talkToCli( meindex, -1, buf, CHAR_COLORWHITE); + // Syu ADD дȡLog () + LogFamilyBankStone( + CHAR_getChar( meindex, CHAR_NAME ), + CHAR_getChar( meindex, CHAR_CDKEY ), + toBank, + CHAR_getInt( meindex, CHAR_GOLD ), + "myBank()()", + CHAR_getInt( meindex,CHAR_FLOOR), + CHAR_getInt( meindex,CHAR_X ), + CHAR_getInt( meindex,CHAR_Y ), + CHAR_getInt( meindex,CHAR_BANKGOLD) + ); + + } + else { + sprintf(buf, "Ӽиʻȡ%d", -toBank); + CHAR_talkToCli( meindex, -1, buf, CHAR_COLORWHITE); + // Syu ADD дȡLog () + LogFamilyBankStone( + CHAR_getChar( meindex, CHAR_NAME ), + CHAR_getChar( meindex, CHAR_CDKEY ), + toBank, + CHAR_getInt( meindex, CHAR_GOLD ), + "myBank()()", + CHAR_getInt( meindex,CHAR_FLOOR), + CHAR_getInt( meindex,CHAR_X ), + CHAR_getInt( meindex,CHAR_Y ), + CHAR_getInt( meindex,CHAR_BANKGOLD) + ); + + } + // Syu ADD дȡLog () + LogStone( + -1, + CHAR_getChar( meindex, CHAR_NAME ), /* ƽҷ */ + CHAR_getChar( meindex, CHAR_CDKEY ), /* ǡID */ + -toBank, /* ź */ + CHAR_getInt( meindex, CHAR_GOLD ), + "myBank()", + CHAR_getInt( meindex,CHAR_FLOOR), + CHAR_getInt( meindex,CHAR_X ), + CHAR_getInt( meindex,CHAR_Y ) + ); + + } + else + print(" bank_error "); + + } + if( strcmp(token, "I" )==0 ) { + + } + if( strcmp(token, "T" )==0 ) { + int toTax; + int mygold; + int FMindex; + + if (getStringFromIndexWithDelim(message, "|", 3, token2, sizeof(token)) == FALSE) + return; + toTax = atoi( token2 ); + +#ifdef _FMVER21 + if( CHAR_getInt( meindex, CHAR_FMLEADERFLAG ) != FMMEMBER_LEADER && + CHAR_getInt( meindex, CHAR_FMLEADERFLAG ) != FMMEMBER_ELDER && toTax < 0 ) + return; +#endif + + + FMindex = CHAR_getWorkInt( meindex, CHAR_WORKFMINDEXI ); + mygold = CHAR_getInt( meindex, CHAR_GOLD); + if( mygold < 0 || mygold > MaxGold || toTax == 0 ) return; + if( toTax > 0 ) {//+ + if( ((mygold-toTax) < 0) || (familyTax[ FMindex] + toTax) > CHAR_MAXFMBANKGOLDHAVE ) { + return; + } + }else if( toTax < 0 ){ //-ȡ + if( ((mygold-toTax)>MaxGold) || (familyTax[ FMindex] + toTax) < 0 ) { + return; + } + } + + + if( toTax>0 ) { //Ԥȿۿ + CHAR_setInt( meindex, CHAR_GOLD, CHAR_getInt( meindex, CHAR_GOLD)-toTax ); + } + sprintf( buf, "%s....", (toTax>0)?"":"ȡ"); + CHAR_talkToCli( meindex , -1, buf, CHAR_COLORYELLOW); + + CHAR_send_P_StatusString( meindex , CHAR_P_STRING_GOLD); + sprintf( buf, "%d", toTax ); + + saacproto_ACFixFMData_send(acfd, + CHAR_getChar(meindex, CHAR_FMNAME), + CHAR_getInt(meindex, CHAR_FMINDEX), + CHAR_getWorkInt(meindex, CHAR_WORKFMINDEXI), FM_FIX_FMGOLD, buf, + "", CHAR_getWorkInt(meindex, CHAR_WORKFMCHARINDEX), CONNECT_getFdid(fd)); + //print(" getTax:%s=%d ", CHAR_getChar(meindex, CHAR_FMNAME), toTax ); + } +} + +void ACFMPointList(int ret, char *data) +{ +} + +#ifdef _ADD_FAMILY_TAX // WON ADD ׯ԰˰ +// GS ʱ AC Ҫׯ԰˰ +void GS_ASK_TAX(void) +{ + saacproto_GS_ASK_TAX_send(acfd); +} + +// ׯ԰峤޸˰ +void FAMILY_FIX_TAX( int fd, int index, char* message) +{ + int fmpointindex=0, tax=0, fmindex=-1, i; + char token[256]; + char pointbuf[256]; + +// extern struct FM_POINTLIST fmpointlist; // ݵ + // жʸ + if (!CHAR_CHECKINDEX(index)) return; + + if ((CHAR_getInt(index, CHAR_FMINDEX) == -1) + || (strcmp(CHAR_getChar(index, CHAR_FMNAME), "") == 0) +#ifdef _FMVER21 + || (CHAR_getInt(index, CHAR_FMLEADERFLAG) != FMMEMBER_LEADER)) +#else + || (CHAR_getInt(index, CHAR_FMLEADERFLAG) != 1)) +#endif + { + return; + } + + // + fmindex = CHAR_getInt(index, CHAR_FMINDEX); + + // ǷΪׯ԰ļ + for( i=0 ; i= fmdplevelexp[i]){ + fmlevel = i; + } + } + for (i = 1; i <= MANORNUM; i++) { + if (((strcmp(fmpks[i * MAX_SCHEDULE + 1].guest_name, + CHAR_getChar(meindex, CHAR_FMNAME)) == 0)) + && ((fmpks[i * MAX_SCHEDULE + 1].flag = FMPKS_FLAG_MANOR_BATTLEBEGIN) + || (fmpks[i * MAX_SCHEDULE + 1].flag == FMPKS_FLAG_MANOR_PREPARE))){ + char tmpbuf[256]; + sprintf(tmpbuf, "\n%sѾԤԼׯ԰ˡ\n޷ׯ԰ร", + fmpks[i * MAX_SCHEDULE + 1].host_name); + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + -1, -1, + makeEscapeString(tmpbuf, buf, sizeof(buf))); + return; + } + } + if (getStringFromIndexWithDelim(message, "|", 2, token, + sizeof(token)) == FALSE) return; + fmpointindex = atoi(token); + if (getStringFromIndexWithDelim(message, "|", 3, token, + sizeof(token)) == FALSE) return; + fl = atoi(token); + if (getStringFromIndexWithDelim(message, "|", 4, token, + sizeof(token)) == FALSE) return; + x = atoi(token); + if (getStringFromIndexWithDelim(message, "|", 5, token, + sizeof(token)) == FALSE) return; + y = atoi(token); +/* + print("SetFMPoint charname:%s fmindex:%d index:%d pointindex:%d fl:%d x:%d y:%d\n", + CHAR_getChar(meindex, CHAR_FMNAME), + CHAR_getInt(meindex, CHAR_FMINDEX), + CHAR_getWorkInt(meindex, CHAR_WORKFMINDEXI), + fmpointindex, fl, x, y); +*/ + saacproto_ACSetFMPoint_send(acfd, + CHAR_getChar(meindex, CHAR_FMNAME), + CHAR_getInt(meindex, CHAR_FMINDEX), + CHAR_getWorkInt(meindex, CHAR_WORKFMINDEXI), + fmpointindex, fl, x, y, CONNECT_getFdid(fd)); +} + +void ACSetFMPoint(int ret, int r, int clifd) +{ + int meindex = CONNECT_getCharaindex(clifd); + char message[256], buf[512]; + + if (!CHAR_CHECKINDEX(meindex)) return; + + if ((CHAR_getWorkInt(meindex, CHAR_WORKPARTYMODE) != CHAR_PARTY_NONE) + || (CHAR_getWorkInt(meindex, CHAR_WORKBATTLEMODE) != BATTLE_CHARMODE_NONE)) + return; + if (ret == 0){ + if (r == -1) + sprintf(message, "ʧܣ"); + else if (r == -2) + sprintf(message, "Ѿмݵˡظ룡"); + else if (r == -3) + sprintf(message, "δݵʸ"); + else if (r == -4) + sprintf(message, "ݵѾмʹޣ"); + else if (r == -5) + sprintf(message, "ļδ׼ࡣ"); + } + else if (ret == 1) + sprintf(message, "ݵϣˣ"); + + lssproto_WN_send( clifd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + -1, -1, + makeEscapeString(message, buf, sizeof(buf))); +} + +void ACFMAnnounce(int ret, char *fmname, int fmindex, int index, + int kindflag, char *data, int color) +{ + // kindflag 1:峤㲥 2:ϵͳ屻ɾ 3:ϵͳ֪ͨѶϢ + int i, chindex; + if( ret != 1 ) return; +// print("fmname:%s fmindex:%d index:%d kindflag:%d data:%s color:%d\n", +// fmname, fmindex, index, kindflag, data, color); + for( i=0; i < FAMILY_MAXMEMBER; i++) + { + chindex = familyMemberIndex[index][i]; + if( chindex >= 0 ) { + if( CHAR_getCharUse(chindex) ) + { + if (kindflag == 1) + { +#ifdef _FMVER21 + // shan 2001/12/13 + //if( CHAR_getInt( chindex, CHAR_FMLEADERFLAG ) == FMMEMBER_MEMBER ) + if( CHAR_getInt( chindex, CHAR_FMLEADERFLAG ) == FMMEMBER_MEMBER || + CHAR_getInt( chindex, CHAR_FMLEADERFLAG ) == FMMEMBER_ELDER ) +#else + if( CHAR_getInt( chindex, CHAR_FMLEADERFLAG ) == 2 ) +#endif + CHAR_talkToCli( chindex, -1, data, color ); + } + else if (kindflag == 2) + { + int fd = getfdFromCharaIndex( chindex ); + if (fd == -1) return; + SetFMVarInit( chindex ); + CHAR_talkToCli( chindex , -1, "ļ֮ûյԱԱȽɢˣ", + CHAR_COLORRED); + } + }else + familyMemberIndex[index][i] = -1; + } + } + if (kindflag == 3) + { + int meindex = 0; + int clifd = getfdFromFdid(color); + if (CONNECT_checkfd(clifd) == FALSE) return; + meindex = CONNECT_getCharaindex(clifd); + if (!CHAR_CHECKINDEX(meindex)) return; + CHAR_talkToCli(meindex, -1, data, CHAR_COLORRED); + if(strstr(data,"Ѿļ룡")!=NULL){ + + }else if(strstr(data,"Ѿ߳ˣ")!=NULL){ + CHAR_setInt( meindex , CHAR_RIDEPET, -1 ); + CHAR_setInt( meindex , CHAR_BASEIMAGENUMBER , CHAR_getInt( meindex , CHAR_BASEBASEIMAGENUMBER) ); + CHAR_complianceParameter( meindex ); + CHAR_sendCToArroundCharacter( CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX )); + CHAR_send_P_StatusString( meindex , CHAR_P_STRING_RIDEPET); +#ifdef _FM_METAMO + CHAR_ReMetamo(meindex); +#endif + } + } + if (kindflag == 4) + { + int meindex = 0; + char buf[1024]; + int clifd = getfdFromFdid(color); +// print("Here1\n"); + if (CONNECT_checkfd(clifd) == FALSE) return; + meindex = CONNECT_getCharaindex(clifd); + if (!CHAR_CHECKINDEX(meindex)) return; +// print("Here2\n"); + lssproto_WN_send(clifd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + -1, -1, + makeEscapeString(data, buf, sizeof(buf))); + } +} + +void FAMILY_SetAcceptFlag(int fd, int meindex, char *message) +{ + int result; + char token[128], buf[1024]; + + if (!CHAR_CHECKINDEX(meindex)) return; + + if ((CHAR_getWorkInt(meindex, CHAR_WORKPARTYMODE) != CHAR_PARTY_NONE) + || (CHAR_getWorkInt(meindex, CHAR_WORKBATTLEMODE) != BATTLE_CHARMODE_NONE)) + return; + + if ((CHAR_getInt(meindex, CHAR_FMINDEX) == -1) + || (strcmp(CHAR_getChar(meindex, CHAR_FMNAME), "") == 0) +#ifdef _FMVER21 +// || ((CHAR_getInt(meindex, CHAR_FMLEADERFLAG) != FMMEMBER_LEADER) +// && (CHAR_getInt(meindex, CHAR_FMLEADERFLAG) != FMMEMBER_ELDER) +// && (CHAR_getInt(meindex, CHAR_FMLEADERFLAG) != FMMEMBER_VICELEADER))) + || ((CHAR_getInt(meindex, CHAR_FMLEADERFLAG) != FMMEMBER_LEADER) + && (CHAR_getInt(meindex, CHAR_FMLEADERFLAG) != FMMEMBER_ELDER))) +#else + || (CHAR_getInt(meindex, CHAR_FMLEADERFLAG) != 1)) +#endif + { + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + -1, -1, + makeEscapeString( "\n㲻峤û޸ĵȨࡣ", buf, sizeof(buf))); + return; + } + + if (getStringFromIndexWithDelim(message, "|", 2, token, + sizeof(token)) == FALSE) return; + result = atoi(token); + if ((result == 0) || (result == 1)) + { + saacproto_ACFixFMData_send(acfd, + CHAR_getChar(meindex, CHAR_FMNAME), + CHAR_getInt(meindex, CHAR_FMINDEX), + CHAR_getWorkInt(meindex, CHAR_WORKFMINDEXI), FM_FIX_ACCEPTFLAG, + token, "", CHAR_getWorkInt(meindex, CHAR_WORKFMCHARINDEX), + CONNECT_getFdid(fd)); + } +} + +void FAMILY_FixRule( int fd, int meindex, char* message ) +{ + + char token[1024], buf[1024]; + + if (!CHAR_CHECKINDEX(meindex))return; + + if ((CHAR_getInt(meindex, CHAR_FMINDEX) == -1) + || (strcmp(CHAR_getChar(meindex, CHAR_FMNAME), "") == 0) +#ifdef _FMVER21 + || (CHAR_getInt(meindex, CHAR_FMLEADERFLAG) != FMMEMBER_LEADER)) +#else + || (CHAR_getInt(meindex, CHAR_FMLEADERFLAG) != 1)) +#endif + { + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + -1, -1, + makeEscapeString( "\n㲻峤û޸ĵȨࡣ", buf, sizeof(buf))); + return; + } + + if (getStringFromIndexWithDelim(message, "|", 2, token, + sizeof(token)) == FALSE) return; + + if( strcmp( token, "R") == 0 ) + { + if (getStringFromIndexWithDelim(message, "|", 3, buf, + sizeof( buf ) ) == FALSE)return; + + if (strcmp( buf, "") == 0) + { + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + -1, -1, + makeEscapeString( "\nּΪհࡣ", buf, sizeof(buf))); + return; + } + +// print(" new_rule:%s ", buf); + saacproto_ACFixFMData_send(acfd, + CHAR_getChar(meindex, CHAR_FMNAME), + CHAR_getInt(meindex, CHAR_FMINDEX), + CHAR_getWorkInt(meindex, CHAR_WORKFMINDEXI), FM_FIX_FMRULE, + buf, "", CHAR_getWorkInt(meindex, CHAR_WORKFMCHARINDEX), + CONNECT_getFdid(fd)); + return; + } + if( strcmp( token, "P") == 0 ) + { + int havepetindex, petindex, i; + char petname[20], petattr[512]; + + // Ƿػ + for( i =0; i< CHAR_MAXPETHAVE; i++ ) + { + int petindex = CHAR_getCharPet(meindex, i); + if (!CHAR_CHECKINDEX(petindex)) continue; + if( CHAR_getInt( petindex , CHAR_PETFAMILY ) ==1 ) + { +// lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, +// WINDOW_BUTTONTYPE_OK, +// -1, -1, +// makeEscapeString( "\nԭػ޻ࡡ", buf, sizeof(buf))); +// return; + CHAR_setInt( petindex , CHAR_PETFAMILY,0 ); + } + } + // Ƿػ(ij) + for( i =0; i< CHAR_MAXPOOLPETHAVE; i++ ) + { + int petindex = CHAR_getCharPoolPet(meindex, i); + if (!CHAR_CHECKINDEX(petindex)) continue; + if( CHAR_getInt( petindex , CHAR_PETFAMILY ) ==1 ) + { +// lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, +// WINDOW_BUTTONTYPE_OK, +// -1, -1, +// makeEscapeString( "\nԭػ޻ࡡ", buf, sizeof(buf))); +// return; + CHAR_setInt( petindex , CHAR_PETFAMILY,0 ); + } + } + + if (getStringFromIndexWithDelim(message, "|", 3, buf, + sizeof( buf ) ) == FALSE) return; + havepetindex = atoi( buf ); + + petindex = CHAR_getCharPet(meindex, havepetindex); + + if (!CHAR_CHECKINDEX(petindex)) return; + + if (strlen(CHAR_getChar(petindex, CHAR_USERPETNAME)) == 0) + sprintf(petname, "%s", CHAR_getChar(petindex, CHAR_NAME)); + else + sprintf(petname, "%s", CHAR_getChar(petindex, CHAR_USERPETNAME)); + sprintf(petattr, "%d %d %d %d", + CHAR_getInt(petindex, CHAR_BASEIMAGENUMBER), + CHAR_getWorkInt(petindex, CHAR_WORKATTACKPOWER), + CHAR_getWorkInt(petindex, CHAR_WORKDEFENCEPOWER), + CHAR_getWorkInt(petindex, CHAR_WORKQUICK)); + + CHAR_setInt(petindex, CHAR_PETFAMILY, 1); + saacproto_ACFixFMData_send(acfd, + CHAR_getChar(meindex, CHAR_FMNAME), + CHAR_getInt(meindex, CHAR_FMINDEX), + CHAR_getWorkInt(meindex, CHAR_WORKFMINDEXI), FM_FIX_FMPET, + petname, petattr, CHAR_getWorkInt(meindex, CHAR_WORKFMCHARINDEX), + CONNECT_getFdid(fd)); + return; + + } + +} + +void JoinMemberIndex( int meindex, int fmindexi ) +{ + int i; + + for( i = 0 ; i < FAMILY_MAXMEMBER; i++){ + if( familyMemberIndex[fmindexi][i] == meindex ) familyMemberIndex[fmindexi][i] = -1; + } + + for( i = 0 ; i < FAMILY_MAXMEMBER; i++){ + if( familyMemberIndex[fmindexi][i] < 0 ){ + familyMemberIndex[fmindexi][i] = meindex; + break; + } + } +#ifdef _CHANNEL_MODIFY + i = 0; + // ɵƵ¼ + while(i < FAMILY_MAXMEMBER){ + if(channelMember[fmindexi][0][i] == meindex){ + channelMember[fmindexi][0][i] = -1; + } + i++; + } + i = 0; + // Ƶ + while(i < FAMILY_MAXMEMBER){ + if(channelMember[fmindexi][0][i] == -1){ + channelMember[fmindexi][0][i] = meindex; + CHAR_setWorkInt(meindex,CHAR_WORKFMCHANNEL,0); + break; + } + i++; + } +#endif +} + +void LeaveMemberIndex( int meindex, int fmindexi ) +{ + int i; + + for( i = 0 ; i < FAMILY_MAXMEMBER; i++){ + if( familyMemberIndex[fmindexi][i] == meindex ) familyMemberIndex[fmindexi][i] = -1; + } +#ifdef _CHANNEL_MODIFY + i = 0; + // ɵƵ¼ + while(i < FAMILY_MAXMEMBER){ + if(channelMember[fmindexi][0][i] == meindex){ + channelMember[fmindexi][0][i] = -1; + } + i++; + } +#endif +} + +int FAMILY_RidePet( int fd, int meindex, char* message ) +{ + //print("...1111\n"); + char token[64], token2[64]; + int petindex, rideGraNo = 0, leaderimageNo; + // Arminius 8.25 recover + int i; +#ifndef _NEW_RIDEPETS + int big4fm = 0; +#endif + if (!CHAR_CHECKINDEX(meindex))return 0; + + // Robin fix սв + if( CHAR_getWorkInt( meindex, CHAR_WORKBATTLEMODE) != BATTLE_CHARMODE_NONE ) + { + CHAR_talkToCli( meindex, -1, "սв裡", CHAR_COLORYELLOW ); + return 0; + } + // Robin fix в + if( CHAR_getWorkInt(meindex, CHAR_WORKTRADEMODE) != CHAR_TRADE_FREE){ + CHAR_talkToCli( meindex, -1, "в裡", CHAR_COLORYELLOW ); + return 0; + } +#ifdef _PETSKILL_BECOMEPIG + if( CHAR_getInt( meindex, CHAR_BECOMEPIG) > -1 ){ //״̬ + CHAR_setInt( meindex, CHAR_RIDEPET, -1 ); + //ѡ״̬ȻΪ"", + CHAR_complianceParameter( meindex ); + CHAR_send_P_StatusString( meindex, CHAR_P_STRING_RIDEPET); + CHAR_talkToCli( meindex, -1, "Ŀǰ㴦״̬˳", CHAR_COLORYELLOW ); + return 0; + } +#endif + if (getStringFromIndexWithDelim(message, "|", 2, token, sizeof(token)) == FALSE) return 0; + if( strcmp( token, "P") == 0) { + if (getStringFromIndexWithDelim(message, "|", 3, token2, sizeof(token2)) == FALSE) + return 0; + if( atoi(token2) != -1 ) { + petindex = CHAR_getCharPet( meindex, atoi( token2 ) ); + if(!CHAR_CHECKINDEX(petindex))return; + + if( CHAR_getInt( meindex, CHAR_DEFAULTPET ) == atoi( token2 ) ) return 0; + if( CHAR_getInt( meindex, CHAR_RIDEPET) != -1 ) return 0; +#ifdef _PET_BUG + if(CHAR_getInt( petindex, CHAR_VITAL)>=getPetPoint(0)*20 || CHAR_getInt(petindex,CHAR_STR)>=getPetPoint(1)*80 || CHAR_getInt(petindex,CHAR_TOUGH)>=getPetPoint(2)*80 || CHAR_getInt(petindex,CHAR_DEX)>=getPetPoint(3)*100) + { + CHAR_talkToCli( meindex, -1, "óԹߣ޷ˡ", CHAR_COLORYELLOW ); + return 0; + } +#endif +#ifdef _NOT_PETRIDE + if(strstr(CHAR_getChar(petindex,CHAR_NAME),"*")){ + CHAR_talkToCli(meindex, -1, "˳޷ˡ", CHAR_COLORRED); + return 0; + } +#endif + if( CHAR_getInt( meindex, CHAR_LEARNRIDE) < CHAR_getInt( petindex, CHAR_LV ) ) + { + char buff[255]; + sprintf(buff,"Ŀǰֻ˵ȼС%dij衣",CHAR_getInt( meindex, CHAR_LEARNRIDE)); + CHAR_talkToCli( meindex, -1, buff, CHAR_COLORYELLOW ); + return 0; + } + if( CHAR_getWorkInt( petindex, CHAR_WORKFIXAI ) < 100 ) + { + CHAR_talkToCli( meindex, -1, "С100", CHAR_COLORYELLOW ); + return 0; + } +#ifdef _RIDELEVEL + if( CHAR_getInt( meindex, CHAR_LV)+getRideLevel() < CHAR_getInt( petindex, CHAR_LV ) ) + { + char buff[255]; + sprintf(buff,"ֻȼ%dij衣",getRideLevel()); + CHAR_talkToCli( meindex, -1, buff, CHAR_COLORYELLOW ); + return 0; + } +#else + if( CHAR_getInt( meindex, CHAR_LV)+5 < CHAR_getInt( petindex, CHAR_LV ) ) return 0; +#endif +#ifdef _PET_2TRANS + if( CHAR_getInt( petindex, CHAR_TRANSMIGRATION) > 2 ) return 0; + if( CHAR_getInt( petindex, CHAR_TRANSMIGRATION) > getPetRideTrans()) return 0; +#endif +#ifdef _RIDEBUG + if(CHAR_getInt(meindex, CHAR_DEFAULTPET) == petindex ){//ս + return 0; + } +#endif +#ifdef _CAX_PET_ITEMRIDE + if( getpetitemride() == 0 ){ + + { + int iindex = 0 ; + for(;iindex < CHAR_PETITEMNUM; iindex++){ + if(CHAR_getItemIndex(petindex,iindex) != -1){ + char buff[255]; + sprintf(buff,"װ!"); + CHAR_talkToCli( meindex, -1, buff, CHAR_COLORYELLOW ); + return 0; + } + } + } + } +#endif +#ifdef _ALLBLUES_LUA_1_6 + if(FamilyRideFunction(meindex, petindex, atoi( token2 )) != FALSE){ + return 1; + } +#endif + leaderimageNo = 100700 + + ((CHAR_getInt( meindex, CHAR_BASEBASEIMAGENUMBER)-100000)/20)*10 + + CHAR_getInt( meindex, CHAR_FMSPRITE)*5; + // Arminius 8.25 recover + for( i=0; i< arraysizeof(ridePetTable) ; i++ ){ +#ifdef _NEW_RIDEPETS + if( (( CHAR_getInt( meindex, CHAR_BASEIMAGENUMBER) == ridePetTable[i].charNo ) || + ( CHAR_getInt( meindex, CHAR_BASEBASEIMAGENUMBER) == ridePetTable[i].charNo )) +#else + if( ( CHAR_getInt( meindex, CHAR_BASEBASEIMAGENUMBER) == ridePetTable[i].charNo ) +#endif + && ( CHAR_getInt( petindex, CHAR_BASEBASEIMAGENUMBER) == ridePetTable[i].petNo ) ){ + rideGraNo = ridePetTable[i].rideNo; + break; + } +#ifndef _NEW_RIDEPETS + if( ( leaderimageNo == ridePetTable[i].charNo ) + && ( CHAR_getInt( petindex, CHAR_BASEBASEIMAGENUMBER) == ridePetTable[i].petNo ) +#ifdef _EVERYONE_RIDE + && big4fm != 0 + && CHAR_getInt( meindex, CHAR_FMLEADERFLAG ) != FMMEMBER_NONE + && CHAR_getInt( meindex, CHAR_FMLEADERFLAG ) != FMMEMBER_APPLY ) +#else + && CHAR_getInt( meindex, CHAR_FMLEADERFLAG ) == FMMEMBER_LEADER ) +#endif + { + rideGraNo = ridePetTable[i].rideNo; + break; + } +#endif + } + +#ifdef _NEW_RIDEPETS + if( rideGraNo == 0 ) { + int ti=-1, index, image=-1; + int petNo = CHAR_getInt( petindex, CHAR_BASEBASEIMAGENUMBER); + int playerNo = CHAR_getInt( meindex, CHAR_BASEBASEIMAGENUMBER); + int playerlowsride = CHAR_getInt( meindex, CHAR_LOWRIDEPETS); + +#ifdef _RIDE_CF + int playerlowsride1 = CHAR_getInt( meindex, CHAR_LOWRIDEPETS1); + int playerhighride2 = CHAR_getInt( meindex, CHAR_HIGHRIDEPETS2); + //print( ",Ϣ:lowride = %d, lowride1 = %d, highride1 = %d, highride2 = %d. \n", playerlowsride, playerlowsride1, playerhighsride1, playerhighsride2 ); + + if( (ti = RIDEPET_getPETindex( petNo, playerlowsride, playerlowsride1, playerhighride2 )) >= 0 ) + //if( (ti = RIDEPET_getPETindex( petNo, playerlowsride, NULL, NULL )) >= 0 ) +#else + if( (ti = RIDEPET_getPETindex( petNo, playerlowsride )) >= 0 ) +#endif + { + if( (index = RIDEPET_getNOindex( playerNo)) >= 0 ){ + if( (image = RIDEPET_getRIDEno( index,ti)) >= 0 ) { + rideGraNo = image; + //print("...1111, 222 rideGraNo= %d\n", image); + } + } + } + } +#endif + if( rideGraNo != 0 ){ +#ifdef _ITEM_METAMO + // CHAR_setWorkInt( meindex, CHAR_WORKITEMMETAMO, 0); +#endif + //print("...1111, 222, 333 rideGraNo= %d, ridepet = %s\n", rideGraNo, token2); + CHAR_setInt( meindex , CHAR_RIDEPET, atoi( token2 ) ); + CHAR_setInt( meindex , CHAR_BASEIMAGENUMBER , rideGraNo ); + CHAR_complianceParameter( meindex ); + CHAR_sendCToArroundCharacter( CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX )); + CHAR_send_P_StatusString( meindex, CHAR_P_STRING_RIDEPET ); + return 1; + }else{ + int floor = CHAR_getWorkInt( meindex, CHAR_WORKFMFLOOR); + if( floor !=-1 && CHAR_getInt( meindex, CHAR_FMLEADERFLAG ) != FMMEMBER_NONE + && CHAR_getInt( meindex, CHAR_FMLEADERFLAG ) != FMMEMBER_APPLY){ +#ifdef _FM_LEADER_RIDE + if(CHAR_FmLeaderRide( meindex, atoi( token2 )))return 1; +#endif +#ifdef _RIDEMODE_20 + if(getRideMode()>0){ + int ti=-1, index, image=-1; + int petNo = CHAR_getInt( petindex, CHAR_BASEBASEIMAGENUMBER); + int playerNo = CHAR_getInt( meindex, CHAR_BASEBASEIMAGENUMBER); + int petindex = CHAR_getCharPet( meindex, atoi( token2 )); + if(getRideMode()==1 || getRideMode()==2 ){ + if(floor == 1041 || floor == 2031 || floor == 3031 || floor == 4031 + || floor == 5031 || floor == 6031 || floor == 7031 + || floor == 8031 || floor == 9031 || floor == 10031){ + if( CHAR_getInt( meindex, CHAR_FMSPRITE ) == 0){ + if(petNo==100372){ +#ifdef _RIDE_CF + if( (ti = RIDEPET_getPETindex( petNo, RIDE_PET8, 0, 0 )) >= 0 ) +#else + if( (ti = RIDEPET_getPETindex( petNo, RIDE_PET8 )) >= 0 ) +#endif + { + if( (index = RIDEPET_getNOindex( playerNo)) >= 0 ){ + if( (image = RIDEPET_getRIDEno( index,ti)) >= 0 ){ + CHAR_setInt( meindex , CHAR_BASEIMAGENUMBER , image ); + } + } + } + } + }else if( CHAR_getInt( meindex, CHAR_FMSPRITE ) == 1){ + if(petNo==100373){ +#ifdef _RIDE_CF + if( (ti = RIDEPET_getPETindex( petNo, RIDE_PET9, 0, 0 )) >= 0 ) +#else + if( (ti = RIDEPET_getPETindex( petNo, RIDE_PET9 )) >= 0 ) +#endif + { + if( (index = RIDEPET_getNOindex( playerNo)) >= 0 ){ + if( (image = RIDEPET_getRIDEno( index,ti)) >= 0 ){ + CHAR_setInt( meindex , CHAR_BASEIMAGENUMBER , image ); + } + } + } + } + } + } + }else{ +#ifdef _RIDE_CF + if( (ti = RIDEPET_getPETindex( petNo, RIDE_PET_ALL, 0, 0 )) >= 0 ) +#else + if( (ti = RIDEPET_getPETindex( petNo, RIDE_PET_ALL )) >= 0 ) +#endif + { + if( (index = RIDEPET_getNOindex( playerNo)) >= 0 ){ + if( (image = RIDEPET_getRIDEno( index,ti)) >= 0 ){ + CHAR_setInt( meindex , CHAR_BASEIMAGENUMBER , image ); + } + } + } + } + if(image!=-1){ + CHAR_setInt( meindex , CHAR_RIDEPET, atoi( token2 ) ); + CHAR_complianceParameter( meindex ); + CHAR_sendCToArroundCharacter( CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX )); + CHAR_send_P_StatusString( meindex, CHAR_P_STRING_RIDEPET ); + return 1; + } + } +#endif + } +#ifdef _ITEM_RIDE + { + int itemindex = CHAR_getItemIndex( meindex, 0 ); + if(!ITEM_CHECKINDEX(itemindex)) return 0; + if( !strcmp( ITEM_getChar( itemindex, ITEM_USEFUNC), "ITEM_RIDE") ) { + char petmetamo[12],ridemetamo[12]; + char *itemarg = ITEM_getChar( itemindex, ITEM_ARGUMENT); + getStringFromIndexWithDelim( itemarg, "|", 1, petmetamo, sizeof(petmetamo)); + getStringFromIndexWithDelim( itemarg, "|", 2, ridemetamo, sizeof(ridemetamo)); + int metamo= CHAR_getInt( petindex , CHAR_BASEIMAGENUMBER); + if(metamo==atoi(petmetamo)){ + //print("...ûԭ1111, 222, 333 , ridemetamo = %d, ridepet = %s \n", ridemetamo, token2); + CHAR_setInt( meindex , CHAR_RIDEPET, atoi( token2 ) ); + CHAR_setInt( meindex , CHAR_BASEIMAGENUMBER , atoi( ridemetamo ) ); + CHAR_complianceParameter( meindex ); + CHAR_sendCToArroundCharacter( CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX )); + CHAR_send_P_StatusString( meindex, CHAR_P_STRING_RIDEPET ); + return 1; + } + } + } +#endif + } + }else { //ԭ basebaseimage + //print("...ûԭ1111, 222, 333 \n"); + CHAR_setInt( meindex , CHAR_RIDEPET, -1 ); + CHAR_setInt( meindex , CHAR_BASEIMAGENUMBER , CHAR_getInt( meindex , CHAR_BASEBASEIMAGENUMBER) ); + CHAR_complianceParameter( meindex ); + CHAR_sendCToArroundCharacter( CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX )); + CHAR_send_P_StatusString( meindex , CHAR_P_STRING_RIDEPET); + } + } + return 0; +} + +void ACFixFMPK(int winindex, int loseindex, int data) +{ + int i = 0, charindex = 0; + char msg1[256], msg2[256]; + + sprintf(msg1, "ϲ%8d㣡", (data / 100)); + sprintf(msg2, "%8d㣡", (data / 100)); + for (i = 0; i < FAMILY_MAXMEMBER; i++) + { + charindex = familyMemberIndex[winindex][i]; + if( charindex >= 0 ) { + if( CHAR_getCharUse(charindex) ) + CHAR_talkToCli( charindex , -1, msg1, CHAR_COLORYELLOW); + else + familyMemberIndex[winindex][i] = -1; + } + charindex = familyMemberIndex[loseindex][i]; + if( charindex >= 0 ) { + if( CHAR_getCharUse(charindex) ) + CHAR_talkToCli( charindex , -1, msg2, CHAR_COLORRED); + else + familyMemberIndex[loseindex][i] = -1; + } + } +} + +void getNewFMList() +{ + saacproto_ACShowFMList_send( acfd ); +} + +//int channelMember[FAMILY_MAXNUM][FAMILY_MAXCHANNEL][FAMILY_MAXMEMBER]; +//int familyMemberIndex[FAMILY_MAXNUM][FAMILY_MAXMEMBER]; + +void checkFamilyIndex( void ) +{ + int i, j, k, charaindex, err1=0, err2=0; +// print(" checkFamilyIndex! "); + + for( i=0; i 0 ){ + if( fmindex_wk < 0 || fmindex_wk >= FAMILY_MAXNUM){ + print("FamilyNumber Data Error!!"); + return; + } + } + saacproto_ACShowMemberList_send( acfd, fmindex_wk); + + sprintf( sendbuf, " ֪\nСĴԱϣһ޸޷ظԭ̬Сġ"); + + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + CHAR_WINDOWTYPE_FM_MESSAGE2, + CHAR_getWorkInt( leaderdengonindex, CHAR_WORKOBJINDEX), + makeEscapeString( sendbuf, buf, sizeof(buf))); + } + if( strcmp( token, "L") == 0 ){ + int i, kind, letterNo = 0; + char subtoken[256]; + +#ifdef _FMVER21 +// if( CHAR_getInt(meindex, CHAR_FMLEADERFLAG) != FMMEMBER_LEADER && +// CHAR_getInt(meindex, CHAR_FMLEADERFLAG) != FMMEMBER_INVITE && +// CHAR_getInt(meindex, CHAR_FMLEADERFLAG) != FMMEMBER_VICELEADER) return; + if( CHAR_getInt(meindex, CHAR_FMLEADERFLAG) != FMMEMBER_LEADER && + CHAR_getInt(meindex, CHAR_FMLEADERFLAG) != FMMEMBER_ELDER ) return; +#else + if( CHAR_getInt(meindex, CHAR_FMLEADERFLAG) != 1) return; +#endif + + if (getStringFromIndexWithDelim(message, "|", 3, token2, + sizeof(token2)) == FALSE) return; + kind = atoi( token2 ); + + for( i=0 ; i= getfamekoufei()*100 ){ + CHAR_setInt( meindex, CHAR_FAME, CHAR_getInt(meindex, CHAR_FAME) - getfamekoufei()*100 ); +#endif + CHAR_setItemIndex( meindex, emptyitemindexinchara, itemindex ); + ITEM_setWorkInt( itemindex, ITEM_WORKOBJINDEX,-1); + ITEM_setWorkInt( itemindex, ITEM_WORKCHARAINDEX, meindex); + CHAR_sendItemDataOne( meindex, emptyitemindexinchara); +#ifdef _CAX_FAME_KOUFEI + if ( getfamekoufei() > 0 ){ + snprintf( buf, sizeof( buf), "%sɹ۳%dʷѣ",ITEM_getChar( itemindex, ITEM_NAME),getfamekoufei()); + CHAR_talkToCli( meindex, -1, buf, CHAR_COLORWHITE); + }else{ +#endif + snprintf( buf, sizeof( buf), "%sɹ",ITEM_getChar( itemindex, ITEM_NAME)); + CHAR_talkToCli( meindex, -1, buf, CHAR_COLORWHITE); +#ifdef _CAX_FAME_KOUFEI + } + }else{ + CHAR_talkToCli( meindex, -1, "Ŷ", CHAR_COLORYELLOW ); + return; + } +#endif + } +} + if( strcmp( token, "CHANGE") == 0 ){ + int fmindexi, j, num=0; + char subbuf[2048], sendbuf[2048]; + + if (getStringFromIndexWithDelim(message, "|", 3, token2, + sizeof(token2)) == FALSE) return; + + fmindexi = CHAR_getWorkInt( meindex, CHAR_WORKFMINDEXI ); + + // Ҫ峤ѡб + if( strcmp( token2, "L") == 0 ){ + char subsub[128]; + +#ifdef _FMVER21 + if( CHAR_getInt(meindex, CHAR_FMLEADERFLAG) != FMMEMBER_LEADER) return; +#else + if( CHAR_getInt(meindex, CHAR_FMLEADERFLAG) != 1) return; +#endif + + strcpy( subbuf, ""); + for( j = 0 ; j < FAMILY_MAXMEMBER ; j++ ) { + int tempindex = familyMemberIndex[fmindexi][j]; + + // CoolFish: 2001/9/22 + if (!CHAR_CHECKINDEX(tempindex)) continue; + + if (CheckLeaderQ(tempindex) >= 0 && tempindex != meindex ) + { + char tmpbuf[1024]; + sprintf(tmpbuf, "%s", CHAR_getChar(tempindex, CHAR_NAME)); + makeEscapeString( tmpbuf, buf, sizeof(buf)); + sprintf( subsub, "|%d|%s", j, buf ); + strcat( subbuf, subsub ); + num++; + } + } + sprintf( sendbuf, "L|CHANGE|L|%d%s", num, subbuf ); + //lssproto_FM_send( fd, sendbuf); + + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_LEADERSELECT, + WINDOW_BUTTONTYPE_OK, + -1, -1, + sendbuf ); + + } + // ѯ峤ѡǷԸ + if( strcmp( token2, "Q") == 0 ) + { + char token3[64], token4[64]; + int toindex; + +#ifdef _FMVER21 + if( CHAR_getInt(meindex, CHAR_FMLEADERFLAG) != FMMEMBER_LEADER) return; +#else + if( CHAR_getInt(meindex, CHAR_FMLEADERFLAG) != 1) return; +#endif + if (getStringFromIndexWithDelim(message, "|", 4, token3, + sizeof(token3)) == FALSE)return; + if (getStringFromIndexWithDelim(message, "|", 5, token4, + sizeof(token4)) == FALSE)return; + makeStringFromEscaped( token4 ); + + if( atoi(token3) < 0 || atoi(token3) > FAMILY_MAXMEMBER ) return; + + toindex = familyMemberIndex[fmindexi][atoi(token3)]; + if( !CHAR_CHECKINDEX( toindex ) ) return; + if( strcmp( token4, CHAR_getChar( toindex, CHAR_NAME)) != 0 ) return; + if( CheckLeaderQ(toindex) < 0 ) return; + + // ˫λʱCHAR_WORKLEADERCHANGEŶԷcharaindex + CHAR_setWorkInt( toindex, CHAR_WORKLEADERCHANGE, meindex); + CHAR_setWorkInt( meindex, CHAR_WORKLEADERCHANGE, toindex); + + sprintf( sendbuf, "%s|%d", makeEscapeString( CHAR_getChar( meindex, CHAR_NAME ), buf, sizeof(buf)), meindex ); + + lssproto_WN_send( CHAR_getWorkInt( toindex, CHAR_WORKFD ), WINDOW_MESSAGETYPE_LEADERSELECTA, + WINDOW_BUTTONTYPE_OK, + -1, -1, + sendbuf ); + + } + // ѡ˵Ĵ + if( strcmp( token2, "A") == 0 ) + { + int leaderindex, answerflag; + char leadername[64], token3[64], token4[64]; + +// print( "%s", message ); + + if (getStringFromIndexWithDelim(message, "|", 4, token3, + sizeof(token3)) == FALSE) return; + answerflag = atoi( token3 ); + + if (getStringFromIndexWithDelim(message, "|", 5, leadername, + sizeof( leadername )) == FALSE)return; + makeStringFromEscaped( leadername ); + + if (getStringFromIndexWithDelim(message, "|", 6, token4, + sizeof(token4)) == FALSE)return; + + //if( atoi(token4) < 0 || atoi(token4) > FAMILY_MAXMEMBER ) return; + + leaderindex = atoi( token4 ); + + // ˫CHAR_WORKLEADERCHANGEǷ + if( CHAR_getWorkInt( meindex, CHAR_WORKLEADERCHANGE ) != leaderindex ) return; + if( !CHAR_CHECKINDEX(leaderindex) ) return; + if( strcmp( leadername, CHAR_getChar( leaderindex, CHAR_NAME) ) != 0 ) return; + if( CHAR_getWorkInt( leaderindex, CHAR_WORKLEADERCHANGE ) != meindex ) return; + CHAR_setWorkInt( leaderindex, CHAR_WORKLEADERCHANGE, -1 ); +#ifdef _FMVER21 + if( CHAR_getInt(leaderindex, CHAR_FMLEADERFLAG ) != FMMEMBER_LEADER ) return; +#else + if( CHAR_getInt(leaderindex, CHAR_FMLEADERFLAG ) != 1 ) return; +#endif + if( CHAR_getInt(meindex, CHAR_FMINDEX) != CHAR_getInt(leaderindex, CHAR_FMINDEX) ) return; + + if( answerflag == 0 ) + { + CHAR_setWorkInt( meindex, CHAR_WORKLEADERCHANGE, 0); + CHAR_setWorkInt( leaderindex, CHAR_WORKLEADERCHANGE, 0); + lssproto_WN_send( CHAR_getWorkInt( leaderindex, CHAR_WORKFD) , WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + -1, -1, + makeEscapeString( "\nԲ𣡶ԷԸܣ", buf, sizeof(buf)) ); + return; + } + + if( answerflag == 1 ) + { + char tmpbuf[1024]; + sprintf( buf, "%d", CHAR_getInt( meindex, CHAR_FACEIMAGENUMBER ) ); + // CoolFish: add charname 2001/9/27 + sprintf( tmpbuf, "%s", CHAR_getChar( meindex, CHAR_NAME ) ); + saacproto_ACFixFMData_send(acfd, + CHAR_getChar(meindex, CHAR_FMNAME), + CHAR_getInt(meindex, CHAR_FMINDEX), + CHAR_getWorkInt(meindex, CHAR_WORKFMINDEXI), FM_FIX_FMLEADERCHANGE , buf, + tmpbuf, CHAR_getWorkInt(meindex, CHAR_WORKFMCHARINDEX), CONNECT_getFdid(fd)); + // "", CHAR_getWorkInt(meindex, CHAR_WORKFMCHARINDEX), CONNECT_getFdid(fd)); + return; + } + } + } +} + +void ACFMJob( int fd, int ret, char* data1, char* data2 ) +{ + + int charaindex = CONNECT_getCharaindex( fd ); + if( !CHAR_CHECKINDEX(charaindex) ) return; + + + if( 1 ){ + + int leaderindex = CHAR_getWorkInt( charaindex, CHAR_WORKLEADERCHANGE ); + char buf[256], buf2[256]; + + CHAR_setWorkInt( charaindex, CHAR_WORKLEADERCHANGE, 0 ); + print("leaderindex:%d:%s\n", leaderindex,CHAR_getChar(leaderindex,CHAR_NAME) ); + + if( !CHAR_CHECKINDEX(leaderindex) ) return; + //if( CHAR_getWorkInt( leaderindex, CHAR_WORKLEADERCHANGE ) != charaindex ) return; + CHAR_setWorkInt( leaderindex, CHAR_WORKLEADERCHANGE, 0 ); + + if( ret == 0 ){ + CHAR_talkToCli( charaindex, -1, "峤λʧܣ", CHAR_COLORYELLOW ); + CHAR_talkToCli( leaderindex, -1, "峤λʧܣ", CHAR_COLORYELLOW ); + return; + } + + // Robin 10/02 debug + if( CHAR_getInt( leaderindex, CHAR_FMINDEX) != CHAR_getInt( charaindex, CHAR_FMINDEX) +#ifdef _FMVER21 + // || CHAR_getInt( leaderindex, CHAR_FMLEADERFLAG) != FMMEMBER_LEADER ) +#else + // || CHAR_getInt( leaderindex, CHAR_FMLEADERFLAG) != 1 +#endif + ) + { + sprintf( buf, "leaderindex:%d:%s\n", leaderindex, CHAR_getChar( leaderindex, CHAR_NAME) ); + LogFamily( + CHAR_getChar(charaindex, CHAR_FMNAME), + CHAR_getInt(charaindex, CHAR_FMINDEX), + CHAR_getChar(charaindex, CHAR_NAME), + CHAR_getChar(charaindex, CHAR_CDKEY), + "LEADERCHANGE_ERROR(峤λʧ)", + buf + ); + return; + } + + //CHAR_setInt( leaderindex, CHAR_FMLEADERFLAG, FMMEMBER_MEMBER); + //CHAR_setInt( charaindex, CHAR_FMLEADERFLAG, FMMEMBER_LEADER); + SetFMPetVarInit( leaderindex ); + SetFMPetVarInit( charaindex ); + CHAR_sendStatusString( leaderindex, "F"); + CHAR_sendStatusString( charaindex, "F"); + + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + -1, -1, + makeEscapeString( "\nϲ㣡Ѿε峤ˡ\núõŬɣ\nˡǵȵ峤ҵļԱѡ\nµļػޣ彫ᱻɢࡣ", buf, sizeof(buf))); + + sprintf( buf2, "\nˣѾ峤λӽ%sˡ", CHAR_getChar( charaindex, CHAR_NAME) ); + lssproto_WN_send( CHAR_getWorkInt( leaderindex, CHAR_WORKFD) , WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + -1, -1, + makeEscapeString( buf2, buf, sizeof(buf))); + +// print(" LeaderChange!! [%s]->[%s] ", CHAR_getChar(leaderindex, CHAR_CDKEY), CHAR_getChar(charaindex, CHAR_CDKEY) ); + + sprintf( buf, "%s\t%s\t%s", + CHAR_getChar(leaderindex, CHAR_FMNAME), + CHAR_getChar(leaderindex, CHAR_NAME), + CHAR_getChar(leaderindex, CHAR_CDKEY) + ); + + LogFamily( + CHAR_getChar(charaindex, CHAR_FMNAME), + CHAR_getInt(charaindex, CHAR_FMINDEX), + CHAR_getChar(charaindex, CHAR_NAME), + CHAR_getChar(charaindex, CHAR_CDKEY), + "LEADERCHANGE(峤λ)", + buf); + } +} + +#ifdef _CAX_LNS_CHARSUOXU +int Char_GetFm( int id, int x) +{ + + int fd = getfdFromCharaIndex( id); + if (x == 1) //ü + return fmdptop.fmMomentum[id]; + + else if (x == 2)//üfmtopdp + return fmdptop.fmtopdp[id]; + else if (x == 3)//üʽ + { + //saacproto_ACGetFMData_send( fd, CHAR_getChar( id, CHAR_FMNAME), + //CHAR_getInt( id, CHAR_FMINDEX ), + //CHAR_getWorkInt( id, CHAR_WORKFMINDEXI ), + //1, + //CONNECT_getFdid(fd) + //); + return familyTax[CHAR_getWorkInt( id, CHAR_WORKFMINDEXI )]; + } +} + +char * FM_getManorData(int ManorId,int Flg) +{ + char *pointbuf = ""; + if( getStringFromIndexWithDelim(fmpointlist.pointlistarray[ManorId], "|", Flg, pointbuf, sizeof(pointbuf)) == FALSE ) return -1; + return pointbuf; +} +#endif diff --git a/char/ls2data.h b/char/ls2data.h new file mode 100644 index 0000000..54e06f7 --- /dev/null +++ b/char/ls2data.h @@ -0,0 +1,13 @@ +#ifndef LS2DATA_DAT +#define LS2DATA_DAT + +typedef struct { + int hash; + char *name; + int graphicnumber; +} CconvertStringNumber; + +CconvertStringNumber *convertStringNumber; +int cconvertStringNumber; + +#endif // LS2DATA_DAT ///:~ diff --git a/char/makefile b/char/makefile new file mode 100644 index 0000000..8cb0764 --- /dev/null +++ b/char/makefile @@ -0,0 +1,1226 @@ +export CC=gcc +export RM=rm -f +export AR=ar cr +export MV=mv +export RANLIB=ranlib +export SED=sed + + +export SHELL=/bin/sh + +INCFLAGS=-I.. -I../include + +CFLAGS=-O3 -w $(INCFLAGS) +#Pentium 4 (Intel) +#CFLAGS=-march=pentium4 -O3 -pipe -fomit-frame-pointer $(INCFLAGS) +#Athlon XP (AMD) +#CFLAGS="-march=athlon-xp -O3 -pipe -fomit-frame-pointer" $(INCFLAGS) +#Athlon64£º +#CFLAGS="-O2 -march=athlon64 -ftracer -fprefetch-loop-arrays -pipe" $(INCFLAGS) + +PROG=libchar.a + +SRC=char_base.c char.c char_event.c char_data.c skill.c title.c\ +addressbook.c chatmagic.c event.c char_walk.c encount.c pet.c \ +enemy.c pet_event.c char_talk.c char_party.c char_item.c deathcontend.c \ +chatroom.c petmail.c trade.c family.c defend.c char_angel.c + +OBJ=$(SRC:.c=.o) + +ifeq (0,$(MAKELEVEL)) +CC=gcc +RM=rm -f +AR=ar cr +MV=mv +RANLIB=ranlib +SED=sed +SHELL=/bin/sh +endif + +all: $(PROG) + +$(PROG): $(OBJ) + $(RM) $(PROG) + $(AR) $(PROG) $(OBJ) + $(RANLIB) $(PROG) + +depend: + $(MV) makefile makefile.bak + $(SED) -ne '1,/^# DO NOT DELETE THIS LINE/p' makefile.bak>makefile + $(CC) $(INCFLAGS) -M $(SRC) >> makefile + +clean: + $(RM) $(PROG) + $(RM) $(OBJ) + $(RM) *~ + +distclean: + $(RM) $(PROG) + $(RM) $(OBJ) + $(RM) *~ + $(MV) makefile makefile.bak + $(SED) -ne '1,/^# DO NOT DELETE THIS LINE/p' makefile.bak>makefile + $(RM) makefile.bak + +# DO NOT DELETE THIS LINE +char_base.o: char_base.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/char_base.h \ + ../include/version.h ../include/skill.h ../include/common.h \ + ../include/util.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/char_base.h ../include/char_data.h ../include/item.h \ + ../include/buf.h ../include/magic.h ../include/function.h \ + ../include/npccreate.h ../include/configfile.h ../include/title.h \ + ../include/pet.h ../include/pet_skill.h ../include/anim_tbl.h \ + ../include/enemy.h ../include/saacproto_cli.h \ + ../include/saacproto_util.h ../include/log.h \ + ../include/mylua/function.h +char.o: char.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h /usr/include/sys/stat.h \ + /usr/include/bits/stat.h /usr/include/ctype.h ../include/net.h \ + ../include/common.h /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/common.h \ + ../include/char_base.h ../include/version.h ../include/skill.h \ + ../include/util.h ../include/title.h ../include/addressbook.h \ + ../include/net.h ../include/lua.h ../include/luaconf.h \ + ../include/lauxlib.h ../include/lualib.h ../include/char_data.h \ + ../include/item.h ../include/char.h ../include/char_base.h \ + ../include/char_data.h ../include/char.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h ../include/item.h ../include/item_event.h \ + ../include/buf.h ../include/object.h ../include/map_deal.h \ + ../include/saacproto_cli.h ../include/saacproto_util.h \ + ../include/readmap.h ../include/handletime.h ../include/char_event.h \ + ../include/npccreate.h ../include/addressbook.h ../include/magic_base.h \ + ../include/magic.h ../include/chatmagic.h ../include/configfile.h \ + ../include/log.h ../include/anim_tbl.h ../include/encount.h \ + ../include/battle.h ../include/pet_skill.h ../include/util.h \ + ../include/enemy.h ../include/npcutil.h ../include/pet.h \ + ../include/family.h ../include/defend.h ../include/correct_bug.h \ + ../include/npc_checkman.h ../include/profession_skill.h \ + ../include/chatroom.h ../include/mylua/function.h +char_event.o: char_event.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h /usr/include/ctype.h \ + ../include/common.h ../include/char.h ../include/common.h \ + ../include/char_base.h ../include/version.h ../include/skill.h \ + ../include/util.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/item_event.h ../include/net.h ../include/item.h \ + ../include/object.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h ../include/util.h ../include/char_data.h \ + ../include/readmap.h ../include/map_deal.h ../include/saacproto_cli.h \ + ../include/saacproto_util.h ../include/npccreate.h \ + ../include/handletime.h ../include/anim_tbl.h ../include/family.h +char_data.o: char_data.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h /usr/include/math.h \ + /usr/include/bits/huge_val.h /usr/include/bits/mathdef.h \ + /usr/include/bits/mathcalls.h ../include/readmap.h ../include/common.h \ + ../include/util.h ../include/common.h ../include/util.h \ + ../include/anim_tbl.h ../include/battle.h ../include/net.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char.h ../include/char_base.h ../include/version.h \ + ../include/skill.h ../include/title.h ../include/addressbook.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/char_data.h ../include/buf.h ../include/item.h \ + ../include/log.h ../include/pet.h ../include/enemy.h \ + ../include/char_base.h ../include/configfile.h defaultPlayer.h \ + ../ls2data.dat ../include/family.h ../include/saacproto_cli.h \ + ../include/saacproto_util.h +skill.o: skill.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/skill.h \ + ../include/common.h ../include/util.h ../include/util.h \ + ../include/char.h ../include/char_base.h ../include/version.h \ + ../include/skill.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/battle.h ../include/profession_skill.h +title.o: title.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h /usr/include/ctype.h \ + ../include/title.h ../include/common.h ../include/util.h \ + ../include/char.h ../include/char_base.h ../include/version.h \ + ../include/skill.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/char_base.h ../include/item.h ../include/skill.h \ + ../include/buf.h ../include/util.h ../include/configfile.h +addressbook.o: addressbook.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/addressbook.h \ + ../include/common.h ../include/util.h ../include/net.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/char.h \ + ../include/char_base.h ../include/version.h ../include/skill.h \ + ../include/title.h ../include/addressbook.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/handletime.h ../include/buf.h ../include/net.h \ + ../include/lssproto_serv.h ../include/lssproto_util.h \ + ../include/saacproto_cli.h ../include/saacproto_util.h \ + ../include/object.h ../include/battle.h ../include/configfile.h \ + ../include/npcutil.h ../include/pet.h ../include/petmail.h \ + ../include/log.h +chatmagic.o: chatmagic.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h /usr/include/ctype.h \ + /usr/include/math.h /usr/include/bits/huge_val.h \ + /usr/include/bits/mathdef.h /usr/include/bits/mathcalls.h \ + /usr/include/malloc.h ../include/common.h ../include/char.h \ + ../include/common.h ../include/char_base.h ../include/version.h \ + ../include/skill.h ../include/util.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/util.h ../include/buf.h ../include/npcutil.h \ + ../include/char_base.h ../include/object.h ../include/char_data.h \ + ../include/handletime.h ../include/chatmagic.h ../include/configfile.h \ + ../include/readmap.h ../include/map_deal.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h ../include/log.h ../include/battle.h \ + ../include/pet.h ../include/enemy.h ../include/encount.h \ + ../include/magic_base.h ../include/magic.h ../include/pet_skill.h \ + ../include/pet_event.h ../include/item_gen.h ../include/mclient.h \ + ../include/npc_eventaction.h ../include/map_warppoint.h \ + ../include/npc_manorsman.h ../include/net.h ../include/saacproto_cli.h \ + ../include/saacproto_util.h ../include/npc_scheduleman.h \ + ../include/trade.h ../include/npccreate.h ../include/profession_skill.h \ + ../include/char_talk.h ../include/family.h ../include/petmail.h \ + ../include/npc_autopk.h ../include/mylua/ablua.h ../include/item.h \ + ../include/sasql.h +event.o: event.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/object.h \ + ../include/common.h ../include/char_base.h ../include/version.h \ + ../include/skill.h ../include/util.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char.h ../include/char_base.h ../include/char_data.h \ + ../include/item.h ../include/char.h ../include/readmap.h \ + ../include/map_warppoint.h ../include/event.h ../include/npc_warp.h \ + ../include/npc_npcenemy.h +char_walk.o: char_walk.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h /usr/include/ctype.h \ + ../include/common.h ../include/handletime.h ../include/common.h \ + ../include/object.h ../include/char_base.h ../include/version.h \ + ../include/skill.h ../include/util.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char.h ../include/char_base.h ../include/char_data.h \ + ../include/item.h ../include/char.h ../include/char_event.h \ + ../include/lssproto_serv.h ../include/lssproto_util.h \ + ../include/readmap.h ../include/map_deal.h ../include/npccreate.h \ + ../include/encount.h ../include/npcutil.h ../include/battle.h \ + ../include/net.h ../include/configfile.h ../include/npc_npcenemy.h \ + ../include/mylua/function.h +encount.o: encount.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h /usr/include/math.h \ + /usr/include/bits/huge_val.h /usr/include/bits/mathdef.h \ + /usr/include/bits/mathcalls.h ../include/common.h ../include/util.h \ + ../include/common.h ../include/buf.h ../include/char_base.h \ + ../include/version.h ../include/skill.h ../include/util.h \ + ../include/title.h ../include/addressbook.h ../include/net.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char.h ../include/char_base.h ../include/char_data.h \ + ../include/item.h ../include/char.h ../include/configfile.h \ + ../include/encount.h ../include/enemy.h +pet.o: pet.c ../include/version.h ../include/sasql.h /usr/include/stdio.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/char_base.h \ + ../include/version.h ../include/skill.h ../include/common.h \ + ../include/util.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char.h ../include/char_base.h ../include/char_data.h \ + ../include/item.h ../include/char.h ../include/object.h \ + ../include/readmap.h ../include/map_deal.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h ../include/handletime.h ../include/pet.h \ + ../include/battle.h ../include/petmail.h ../include/log.h \ + ../include/function.h ../include/pet_skill.h +enemy.o: enemy.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/common.h \ + ../include/util.h ../include/common.h ../include/buf.h \ + ../include/char_base.h ../include/version.h ../include/skill.h \ + ../include/util.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char.h ../include/char_base.h ../include/char_data.h \ + ../include/item.h ../include/char.h ../include/configfile.h \ + ../include/encount.h ../include/enemy.h ../include/pet.h \ + ../include/enemyexptbl.h ../include/petmail.h ../include/battle.h \ + ../include/pet_skillinfo.h ../include/anim_tbl.h ../include/log.h \ + ../include/npcutil.h +pet_event.o: pet_event.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/common.h \ + ../include/object.h ../include/common.h ../include/char_base.h \ + ../include/version.h ../include/skill.h ../include/util.h \ + ../include/title.h ../include/addressbook.h ../include/net.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char.h ../include/char_base.h ../include/char_data.h \ + ../include/item.h ../include/char.h ../include/configfile.h \ + ../include/handletime.h ../include/pet_event.h ../include/npcutil.h \ + ../include/log.h ../include/lssproto_serv.h ../include/lssproto_util.h \ + ../include/npc_exchangeman.h ../include/npc_eventaction.h \ + ../include/mylua/function.h +char_talk.o: char_talk.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h /usr/include/ctype.h \ + ../include/handletime.h ../include/common.h ../include/readmap.h \ + ../include/util.h ../include/object.h ../include/char.h \ + ../include/char_base.h ../include/version.h ../include/skill.h \ + ../include/title.h ../include/addressbook.h ../include/net.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/char_base.h ../include/char_talk.h ../include/chatmagic.h \ + ../include/battle.h ../include/log.h ../include/configfile.h \ + ../include/lssproto_serv.h ../include/lssproto_util.h \ + ../include/saacproto_cli.h ../include/saacproto_util.h \ + ../include/family.h ../include/profession_skill.h \ + ../include/mylua/function.h ../include/net.h +char_party.o: char_party.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/readmap.h \ + ../include/common.h ../include/util.h ../include/object.h \ + ../include/char.h ../include/char_base.h ../include/version.h \ + ../include/skill.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/char_base.h ../include/battle.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h ../include/npcutil.h ../include/npc_bus.h \ + ../include/npc_airplane.h ../include/family.h ../include/init.h \ + ../include/mylua/function.h +char_item.o: char_item.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/configfile.h \ + ../include/common.h ../include/readmap.h ../include/util.h \ + ../include/map_deal.h ../include/object.h ../include/char.h \ + ../include/char_base.h ../include/version.h ../include/skill.h \ + ../include/title.h ../include/addressbook.h ../include/net.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/char_base.h ../include/item.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h ../include/handletime.h ../include/log.h \ + ../include/item_event.h ../include/battle.h ../include/petmail.h \ + ../include/mylua/function.h +deathcontend.o: deathcontend.c +chatroom.o: chatroom.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h /usr/include/ctype.h \ + ../include/readmap.h ../include/common.h ../include/util.h \ + ../include/object.h ../include/char.h ../include/char_base.h \ + ../include/version.h ../include/skill.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/char_base.h ../include/chatmagic.h ../include/battle.h \ + ../include/log.h ../include/configfile.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h ../include/saacproto_cli.h \ + ../include/saacproto_util.h ../include/family.h ../include/chatroom.h \ + ../include/net.h ../include/util.h +petmail.o: petmail.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/configfile.h \ + ../include/common.h ../include/buf.h ../include/char_base.h \ + ../include/version.h ../include/skill.h ../include/util.h \ + ../include/title.h ../include/addressbook.h ../include/net.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char.h ../include/char_base.h ../include/char_data.h \ + ../include/item.h ../include/char.h ../include/battle.h \ + ../include/handletime.h ../include/map_deal.h ../include/addressbook.h \ + ../include/lssproto_serv.h ../include/lssproto_util.h ../include/pet.h \ + ../include/petmail.h ../include/npcutil.h ../include/log.h +trade.o: trade.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/correct_bug.h \ + /usr/include/ctype.h ../include/readmap.h ../include/common.h \ + ../include/util.h ../include/object.h ../include/char.h \ + ../include/char_base.h ../include/version.h ../include/skill.h \ + ../include/title.h ../include/addressbook.h ../include/net.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/char_base.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h ../include/npcutil.h ../include/trade.h \ + ../include/log.h ../include/handletime.h ../include/buf.h \ + ../include/net.h ../include/battle.h ../include/npc_bus.h \ + ../include/char_talk.h ../include/magic_base.h ../include/pet_skill.h +family.o: family.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h /usr/include/ctype.h \ + ../include/readmap.h ../include/common.h ../include/util.h \ + ../include/object.h ../include/char.h ../include/char_base.h \ + ../include/version.h ../include/skill.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/char_base.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h ../include/saacproto_cli.h \ + ../include/saacproto_util.h ../include/npcutil.h ../include/family.h \ + ../include/log.h ../include/handletime.h ../include/buf.h \ + ../include/net.h ../include/battle.h ../include/npc_bus.h \ + ../include/char_talk.h ../include/npc_scheduleman.h \ + ../include/npc_fmdengon.h ../include/mylua/function.h +defend.o: defend.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h /usr/include/ctype.h \ + ../include/readmap.h ../include/common.h ../include/util.h \ + ../include/object.h ../include/char.h ../include/char_base.h \ + ../include/version.h ../include/skill.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/char_base.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h ../include/saacproto_cli.h \ + ../include/saacproto_util.h ../include/npcutil.h ../include/family.h \ + ../include/log.h ../include/handletime.h ../include/buf.h \ + ../include/net.h ../include/battle.h ../include/npc_bus.h \ + ../include/char_talk.h ../include/npc_scheduleman.h ../include/defend.h +char_angel.o: char_angel.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h /usr/include/sys/stat.h \ + /usr/include/bits/stat.h /usr/include/ctype.h ../include/common.h \ + ../include/char_base.h ../include/version.h ../include/skill.h \ + ../include/common.h ../include/util.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/char_base.h ../include/char_data.h ../include/char.h \ + ../include/lssproto_serv.h ../include/lssproto_util.h ../include/item.h \ + ../include/item_event.h ../include/buf.h ../include/object.h \ + ../include/map_deal.h ../include/saacproto_cli.h \ + ../include/saacproto_util.h ../include/readmap.h \ + ../include/handletime.h ../include/char_event.h ../include/npccreate.h \ + ../include/addressbook.h ../include/magic_base.h ../include/magic.h \ + ../include/chatmagic.h ../include/configfile.h ../include/log.h \ + ../include/anim_tbl.h ../include/encount.h ../include/battle.h \ + ../include/pet_skill.h ../include/util.h ../include/enemy.h \ + ../include/npcutil.h ../include/pet.h ../include/family.h diff --git a/char/makefile.bak b/char/makefile.bak new file mode 100644 index 0000000..8cb0764 --- /dev/null +++ b/char/makefile.bak @@ -0,0 +1,1226 @@ +export CC=gcc +export RM=rm -f +export AR=ar cr +export MV=mv +export RANLIB=ranlib +export SED=sed + + +export SHELL=/bin/sh + +INCFLAGS=-I.. -I../include + +CFLAGS=-O3 -w $(INCFLAGS) +#Pentium 4 (Intel) +#CFLAGS=-march=pentium4 -O3 -pipe -fomit-frame-pointer $(INCFLAGS) +#Athlon XP (AMD) +#CFLAGS="-march=athlon-xp -O3 -pipe -fomit-frame-pointer" $(INCFLAGS) +#Athlon64£º +#CFLAGS="-O2 -march=athlon64 -ftracer -fprefetch-loop-arrays -pipe" $(INCFLAGS) + +PROG=libchar.a + +SRC=char_base.c char.c char_event.c char_data.c skill.c title.c\ +addressbook.c chatmagic.c event.c char_walk.c encount.c pet.c \ +enemy.c pet_event.c char_talk.c char_party.c char_item.c deathcontend.c \ +chatroom.c petmail.c trade.c family.c defend.c char_angel.c + +OBJ=$(SRC:.c=.o) + +ifeq (0,$(MAKELEVEL)) +CC=gcc +RM=rm -f +AR=ar cr +MV=mv +RANLIB=ranlib +SED=sed +SHELL=/bin/sh +endif + +all: $(PROG) + +$(PROG): $(OBJ) + $(RM) $(PROG) + $(AR) $(PROG) $(OBJ) + $(RANLIB) $(PROG) + +depend: + $(MV) makefile makefile.bak + $(SED) -ne '1,/^# DO NOT DELETE THIS LINE/p' makefile.bak>makefile + $(CC) $(INCFLAGS) -M $(SRC) >> makefile + +clean: + $(RM) $(PROG) + $(RM) $(OBJ) + $(RM) *~ + +distclean: + $(RM) $(PROG) + $(RM) $(OBJ) + $(RM) *~ + $(MV) makefile makefile.bak + $(SED) -ne '1,/^# DO NOT DELETE THIS LINE/p' makefile.bak>makefile + $(RM) makefile.bak + +# DO NOT DELETE THIS LINE +char_base.o: char_base.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/char_base.h \ + ../include/version.h ../include/skill.h ../include/common.h \ + ../include/util.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/char_base.h ../include/char_data.h ../include/item.h \ + ../include/buf.h ../include/magic.h ../include/function.h \ + ../include/npccreate.h ../include/configfile.h ../include/title.h \ + ../include/pet.h ../include/pet_skill.h ../include/anim_tbl.h \ + ../include/enemy.h ../include/saacproto_cli.h \ + ../include/saacproto_util.h ../include/log.h \ + ../include/mylua/function.h +char.o: char.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h /usr/include/sys/stat.h \ + /usr/include/bits/stat.h /usr/include/ctype.h ../include/net.h \ + ../include/common.h /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/common.h \ + ../include/char_base.h ../include/version.h ../include/skill.h \ + ../include/util.h ../include/title.h ../include/addressbook.h \ + ../include/net.h ../include/lua.h ../include/luaconf.h \ + ../include/lauxlib.h ../include/lualib.h ../include/char_data.h \ + ../include/item.h ../include/char.h ../include/char_base.h \ + ../include/char_data.h ../include/char.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h ../include/item.h ../include/item_event.h \ + ../include/buf.h ../include/object.h ../include/map_deal.h \ + ../include/saacproto_cli.h ../include/saacproto_util.h \ + ../include/readmap.h ../include/handletime.h ../include/char_event.h \ + ../include/npccreate.h ../include/addressbook.h ../include/magic_base.h \ + ../include/magic.h ../include/chatmagic.h ../include/configfile.h \ + ../include/log.h ../include/anim_tbl.h ../include/encount.h \ + ../include/battle.h ../include/pet_skill.h ../include/util.h \ + ../include/enemy.h ../include/npcutil.h ../include/pet.h \ + ../include/family.h ../include/defend.h ../include/correct_bug.h \ + ../include/npc_checkman.h ../include/profession_skill.h \ + ../include/chatroom.h ../include/mylua/function.h +char_event.o: char_event.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h /usr/include/ctype.h \ + ../include/common.h ../include/char.h ../include/common.h \ + ../include/char_base.h ../include/version.h ../include/skill.h \ + ../include/util.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/item_event.h ../include/net.h ../include/item.h \ + ../include/object.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h ../include/util.h ../include/char_data.h \ + ../include/readmap.h ../include/map_deal.h ../include/saacproto_cli.h \ + ../include/saacproto_util.h ../include/npccreate.h \ + ../include/handletime.h ../include/anim_tbl.h ../include/family.h +char_data.o: char_data.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h /usr/include/math.h \ + /usr/include/bits/huge_val.h /usr/include/bits/mathdef.h \ + /usr/include/bits/mathcalls.h ../include/readmap.h ../include/common.h \ + ../include/util.h ../include/common.h ../include/util.h \ + ../include/anim_tbl.h ../include/battle.h ../include/net.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char.h ../include/char_base.h ../include/version.h \ + ../include/skill.h ../include/title.h ../include/addressbook.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/char_data.h ../include/buf.h ../include/item.h \ + ../include/log.h ../include/pet.h ../include/enemy.h \ + ../include/char_base.h ../include/configfile.h defaultPlayer.h \ + ../ls2data.dat ../include/family.h ../include/saacproto_cli.h \ + ../include/saacproto_util.h +skill.o: skill.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/skill.h \ + ../include/common.h ../include/util.h ../include/util.h \ + ../include/char.h ../include/char_base.h ../include/version.h \ + ../include/skill.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/battle.h ../include/profession_skill.h +title.o: title.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h /usr/include/ctype.h \ + ../include/title.h ../include/common.h ../include/util.h \ + ../include/char.h ../include/char_base.h ../include/version.h \ + ../include/skill.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/char_base.h ../include/item.h ../include/skill.h \ + ../include/buf.h ../include/util.h ../include/configfile.h +addressbook.o: addressbook.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/addressbook.h \ + ../include/common.h ../include/util.h ../include/net.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/char.h \ + ../include/char_base.h ../include/version.h ../include/skill.h \ + ../include/title.h ../include/addressbook.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/handletime.h ../include/buf.h ../include/net.h \ + ../include/lssproto_serv.h ../include/lssproto_util.h \ + ../include/saacproto_cli.h ../include/saacproto_util.h \ + ../include/object.h ../include/battle.h ../include/configfile.h \ + ../include/npcutil.h ../include/pet.h ../include/petmail.h \ + ../include/log.h +chatmagic.o: chatmagic.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h /usr/include/ctype.h \ + /usr/include/math.h /usr/include/bits/huge_val.h \ + /usr/include/bits/mathdef.h /usr/include/bits/mathcalls.h \ + /usr/include/malloc.h ../include/common.h ../include/char.h \ + ../include/common.h ../include/char_base.h ../include/version.h \ + ../include/skill.h ../include/util.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/util.h ../include/buf.h ../include/npcutil.h \ + ../include/char_base.h ../include/object.h ../include/char_data.h \ + ../include/handletime.h ../include/chatmagic.h ../include/configfile.h \ + ../include/readmap.h ../include/map_deal.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h ../include/log.h ../include/battle.h \ + ../include/pet.h ../include/enemy.h ../include/encount.h \ + ../include/magic_base.h ../include/magic.h ../include/pet_skill.h \ + ../include/pet_event.h ../include/item_gen.h ../include/mclient.h \ + ../include/npc_eventaction.h ../include/map_warppoint.h \ + ../include/npc_manorsman.h ../include/net.h ../include/saacproto_cli.h \ + ../include/saacproto_util.h ../include/npc_scheduleman.h \ + ../include/trade.h ../include/npccreate.h ../include/profession_skill.h \ + ../include/char_talk.h ../include/family.h ../include/petmail.h \ + ../include/npc_autopk.h ../include/mylua/ablua.h ../include/item.h \ + ../include/sasql.h +event.o: event.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/object.h \ + ../include/common.h ../include/char_base.h ../include/version.h \ + ../include/skill.h ../include/util.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char.h ../include/char_base.h ../include/char_data.h \ + ../include/item.h ../include/char.h ../include/readmap.h \ + ../include/map_warppoint.h ../include/event.h ../include/npc_warp.h \ + ../include/npc_npcenemy.h +char_walk.o: char_walk.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h /usr/include/ctype.h \ + ../include/common.h ../include/handletime.h ../include/common.h \ + ../include/object.h ../include/char_base.h ../include/version.h \ + ../include/skill.h ../include/util.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char.h ../include/char_base.h ../include/char_data.h \ + ../include/item.h ../include/char.h ../include/char_event.h \ + ../include/lssproto_serv.h ../include/lssproto_util.h \ + ../include/readmap.h ../include/map_deal.h ../include/npccreate.h \ + ../include/encount.h ../include/npcutil.h ../include/battle.h \ + ../include/net.h ../include/configfile.h ../include/npc_npcenemy.h \ + ../include/mylua/function.h +encount.o: encount.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h /usr/include/math.h \ + /usr/include/bits/huge_val.h /usr/include/bits/mathdef.h \ + /usr/include/bits/mathcalls.h ../include/common.h ../include/util.h \ + ../include/common.h ../include/buf.h ../include/char_base.h \ + ../include/version.h ../include/skill.h ../include/util.h \ + ../include/title.h ../include/addressbook.h ../include/net.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char.h ../include/char_base.h ../include/char_data.h \ + ../include/item.h ../include/char.h ../include/configfile.h \ + ../include/encount.h ../include/enemy.h +pet.o: pet.c ../include/version.h ../include/sasql.h /usr/include/stdio.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/char_base.h \ + ../include/version.h ../include/skill.h ../include/common.h \ + ../include/util.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char.h ../include/char_base.h ../include/char_data.h \ + ../include/item.h ../include/char.h ../include/object.h \ + ../include/readmap.h ../include/map_deal.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h ../include/handletime.h ../include/pet.h \ + ../include/battle.h ../include/petmail.h ../include/log.h \ + ../include/function.h ../include/pet_skill.h +enemy.o: enemy.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/common.h \ + ../include/util.h ../include/common.h ../include/buf.h \ + ../include/char_base.h ../include/version.h ../include/skill.h \ + ../include/util.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char.h ../include/char_base.h ../include/char_data.h \ + ../include/item.h ../include/char.h ../include/configfile.h \ + ../include/encount.h ../include/enemy.h ../include/pet.h \ + ../include/enemyexptbl.h ../include/petmail.h ../include/battle.h \ + ../include/pet_skillinfo.h ../include/anim_tbl.h ../include/log.h \ + ../include/npcutil.h +pet_event.o: pet_event.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/common.h \ + ../include/object.h ../include/common.h ../include/char_base.h \ + ../include/version.h ../include/skill.h ../include/util.h \ + ../include/title.h ../include/addressbook.h ../include/net.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char.h ../include/char_base.h ../include/char_data.h \ + ../include/item.h ../include/char.h ../include/configfile.h \ + ../include/handletime.h ../include/pet_event.h ../include/npcutil.h \ + ../include/log.h ../include/lssproto_serv.h ../include/lssproto_util.h \ + ../include/npc_exchangeman.h ../include/npc_eventaction.h \ + ../include/mylua/function.h +char_talk.o: char_talk.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h /usr/include/ctype.h \ + ../include/handletime.h ../include/common.h ../include/readmap.h \ + ../include/util.h ../include/object.h ../include/char.h \ + ../include/char_base.h ../include/version.h ../include/skill.h \ + ../include/title.h ../include/addressbook.h ../include/net.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/char_base.h ../include/char_talk.h ../include/chatmagic.h \ + ../include/battle.h ../include/log.h ../include/configfile.h \ + ../include/lssproto_serv.h ../include/lssproto_util.h \ + ../include/saacproto_cli.h ../include/saacproto_util.h \ + ../include/family.h ../include/profession_skill.h \ + ../include/mylua/function.h ../include/net.h +char_party.o: char_party.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/readmap.h \ + ../include/common.h ../include/util.h ../include/object.h \ + ../include/char.h ../include/char_base.h ../include/version.h \ + ../include/skill.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/char_base.h ../include/battle.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h ../include/npcutil.h ../include/npc_bus.h \ + ../include/npc_airplane.h ../include/family.h ../include/init.h \ + ../include/mylua/function.h +char_item.o: char_item.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/configfile.h \ + ../include/common.h ../include/readmap.h ../include/util.h \ + ../include/map_deal.h ../include/object.h ../include/char.h \ + ../include/char_base.h ../include/version.h ../include/skill.h \ + ../include/title.h ../include/addressbook.h ../include/net.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/char_base.h ../include/item.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h ../include/handletime.h ../include/log.h \ + ../include/item_event.h ../include/battle.h ../include/petmail.h \ + ../include/mylua/function.h +deathcontend.o: deathcontend.c +chatroom.o: chatroom.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h /usr/include/ctype.h \ + ../include/readmap.h ../include/common.h ../include/util.h \ + ../include/object.h ../include/char.h ../include/char_base.h \ + ../include/version.h ../include/skill.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/char_base.h ../include/chatmagic.h ../include/battle.h \ + ../include/log.h ../include/configfile.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h ../include/saacproto_cli.h \ + ../include/saacproto_util.h ../include/family.h ../include/chatroom.h \ + ../include/net.h ../include/util.h +petmail.o: petmail.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/configfile.h \ + ../include/common.h ../include/buf.h ../include/char_base.h \ + ../include/version.h ../include/skill.h ../include/util.h \ + ../include/title.h ../include/addressbook.h ../include/net.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char.h ../include/char_base.h ../include/char_data.h \ + ../include/item.h ../include/char.h ../include/battle.h \ + ../include/handletime.h ../include/map_deal.h ../include/addressbook.h \ + ../include/lssproto_serv.h ../include/lssproto_util.h ../include/pet.h \ + ../include/petmail.h ../include/npcutil.h ../include/log.h +trade.o: trade.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/correct_bug.h \ + /usr/include/ctype.h ../include/readmap.h ../include/common.h \ + ../include/util.h ../include/object.h ../include/char.h \ + ../include/char_base.h ../include/version.h ../include/skill.h \ + ../include/title.h ../include/addressbook.h ../include/net.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/char_base.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h ../include/npcutil.h ../include/trade.h \ + ../include/log.h ../include/handletime.h ../include/buf.h \ + ../include/net.h ../include/battle.h ../include/npc_bus.h \ + ../include/char_talk.h ../include/magic_base.h ../include/pet_skill.h +family.o: family.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h /usr/include/ctype.h \ + ../include/readmap.h ../include/common.h ../include/util.h \ + ../include/object.h ../include/char.h ../include/char_base.h \ + ../include/version.h ../include/skill.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/char_base.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h ../include/saacproto_cli.h \ + ../include/saacproto_util.h ../include/npcutil.h ../include/family.h \ + ../include/log.h ../include/handletime.h ../include/buf.h \ + ../include/net.h ../include/battle.h ../include/npc_bus.h \ + ../include/char_talk.h ../include/npc_scheduleman.h \ + ../include/npc_fmdengon.h ../include/mylua/function.h +defend.o: defend.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h /usr/include/ctype.h \ + ../include/readmap.h ../include/common.h ../include/util.h \ + ../include/object.h ../include/char.h ../include/char_base.h \ + ../include/version.h ../include/skill.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/char_base.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h ../include/saacproto_cli.h \ + ../include/saacproto_util.h ../include/npcutil.h ../include/family.h \ + ../include/log.h ../include/handletime.h ../include/buf.h \ + ../include/net.h ../include/battle.h ../include/npc_bus.h \ + ../include/char_talk.h ../include/npc_scheduleman.h ../include/defend.h +char_angel.o: char_angel.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h /usr/include/sys/stat.h \ + /usr/include/bits/stat.h /usr/include/ctype.h ../include/common.h \ + ../include/char_base.h ../include/version.h ../include/skill.h \ + ../include/common.h ../include/util.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/char_base.h ../include/char_data.h ../include/char.h \ + ../include/lssproto_serv.h ../include/lssproto_util.h ../include/item.h \ + ../include/item_event.h ../include/buf.h ../include/object.h \ + ../include/map_deal.h ../include/saacproto_cli.h \ + ../include/saacproto_util.h ../include/readmap.h \ + ../include/handletime.h ../include/char_event.h ../include/npccreate.h \ + ../include/addressbook.h ../include/magic_base.h ../include/magic.h \ + ../include/chatmagic.h ../include/configfile.h ../include/log.h \ + ../include/anim_tbl.h ../include/encount.h ../include/battle.h \ + ../include/pet_skill.h ../include/util.h ../include/enemy.h \ + ../include/npcutil.h ../include/pet.h ../include/family.h diff --git a/char/pet.c b/char/pet.c new file mode 100644 index 0000000..355edb0 --- /dev/null +++ b/char/pet.c @@ -0,0 +1,1157 @@ +#include "version.h" +#include + +#include "char_base.h" +#include "char.h" +#include "object.h" +#include "readmap.h" +#include "map_deal.h" +#include "lssproto_serv.h" +#include "handletime.h" +#include "pet.h" +#include "battle.h" +#include "petmail.h" +#include "log.h" +#include "function.h" +#include "pet_skill.h" + + +/* + * ʸ ĩ + */ +/*------------------------------------------------------------------------ + * ʸë๴Ի񲻯£۷ã + * CHARհ 弰ľ£ + * Իľƽҷindex -1 + *-----------------------------------------------------------------------*/ +char hanzibuf[5000][8] = {"","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","", +"","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","", +"","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","", +"","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","", +"","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","", +"","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","", +"","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","", +"","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","", +"","","","","","","","","","߶","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","", +"","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","", +"","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","", +"","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","", +"","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","", +"","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","", +"","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","", +"","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","", +"","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","", +"","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","", +"","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","", +"","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","", +"","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","", +"","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","", +"","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","", +"","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","", +"","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","", +"","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","", +"","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","", +"","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","", +"","","","","¡","¢","£","¥","§","©","¶","«","¯","²","³","½","¼","¹","","µ","·","¿","","","","","","","","","","","","","","","","","","","", +"","","","","","","","","","","","","","","","","","","","","","æ","â","ä","ã","è","ë","ì","é","ï","ð","ó","ñ","ò","ô","û","ü","÷","ú","ù","ÿ", +"","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","ģ","Ĥ","Ħ", +"ĥ","ħ","Ĩ","ĩ","ĭ","Ī","Į","ī","Ĭ","ı","ij","ĸ","Ķ","ľ","Ŀ","","Ĺ","Ļ","Ľ","ĺ","","","","","","","","","","","","","","","","","","","","","", +"","","","","","","","","","","","","ţ","Ť","Ŧ","ũ","Ũ","Ū","ū","Ŭ","ŭ","Ů","ů","Ų","ŷ","ż","","ſ","","","","","","","","","","","","","", +"","","","","","","","","","","","","","","","","","","","","","Ƥ","ƣ","Ƣ","ƥ","Ƨ","Ƭ","ƫ","ƪ","ƭ","Ư","Ʈ","Ʊ","Ʋ","ƴ","ƶ","Ʒ","ƹ","ƽ","","ƾ", +"ƻ","ƿ","Ƽ","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","ǡ","Ǣ", +"ǧ","Ǩ","ǣ","Ǧ","ǫ","ǩ","ǰ","Ǯ","ǯ","DZ","dz","Dz","Ƿ","Ǹ","ǹ","ǻ","ǿ","ǽ","","","","","","","","","","","","","","","","","","","","","","","", +"","","","","","","","","","","","","","","","","","ȡ","ȥ","Ȥ","Ȧ","ȫ","Ȩ","Ȫ","ȭ","Ȯ","Ȱ","ȯ","ȱ","ȴ","ȸ","ȷ","ȵ","ȹ","Ⱥ","Ȼ","ȼ","Ⱦ","","","", +"","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","ɡ","ɢ","ɣ","ɤ", +"ɥ","ɨ","ɩ","ɫ","ɭ","ɱ","ɳ","ɴ","ɵ","ɸ","ɹ","ɽ","ɾ","","","","","","","","","","","","","","","","","","","","","","","","","","","","", +"","","","","","","","","","","","","","","","","ʤ","","ʡ","ʥ","ʢ","ʣ","ʬ","ʧ","ʦ","ʫ","ʩ","ʨ","ʪ","ʮ","ʲ","ʯ","ʱ","ʶ","ʵ","ʰ","ʴ","ʳ","ʷ","ʹ","ʼ", +"ʻ","ʿ","","","","ʾ","ʽ","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","", +"","","","","","","","","ˢ","ˣ","˥","ˤ","˦","˧","˩","˫","˪","ˬ","˭","ˮ","˰","˯","˳","˵","","˿","˾","˽","˼","˹","˺","","","","","","","","","","", +"","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","̤","̨","̧","̫","̬","̩","̰","̯","̲","̳", +"̸","̵","̹","̺","̾","̿","̽","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","", +"","","","","","","","","","","","ͤ","ͥ","ͣ","ͦ","ͧ","ͨ","ͬ","ͩ","ͭ","ͯ","ͳ","Ͱ","Ͳ","ʹ","͵","ͷ","Ͷ","͸","ͺ","ͻ","ͼ","ͽ","Ϳ",";","","","","","","", +"","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","Σ","","΢","Ϊ","Χ","Υ", +"Ψ","ά","ΰ","α","β","ί","","δ","λ","ζ","η","θ","ι","ο","","","","","","","","","","","","","","","","","","","","","","","","","","","", +"","","","","Ϧ","","","ϣ","","Ϣ","","Ϥ","ϧ","ϡ","Ϫ","","Ϩ","ϥ","ϰ","ϯ","Ϯ","ϴ","ϲ","Ϸ","ϵ","ϸ","϶","Ϻ","Ϲ","Ͽ","","ϼ","","","","","","","","","", +"","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","Щ","Ъ","Э","а","в","б","Я","Ь","д", +"й","к","ж","м","е","л","","","","","н","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","", +"","","","","","","","","","","ѡ","Ѩ","ѧ","ѩ","Ѫ","Ѱ","Ѳ","Ѯ","ѯ","ѭ","","","","","С","","Т","Ч","У","Ц","ѵ","Ѷ","Ѹ","ѹ","ѽ","Ѻ","ѻ","Ѽ","","ѿ","", +"","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","", +"","Ҥ","ҥ","ҡ","ң","ҧ","ҩ","Ҫ","Կ","","","Ծ","Խ","","","","","","ҫ","ү","Ҳ","ұ","Ұ","ҵ","Ҷ","ҳ","ҹ","Һ","һ","","ҽ","","","","","","","","","","", +"","","","","","","","","","","","","","","","","","","","","","","","","","","","ӡ","Ӧ","Ӣ","ӣ","ӥ","ӭ","ӯ","Ӫ","Ӭ","Ӯ","Ӱ","ӳ","Ӳ","Ӷ", +"ӵ","ӹ","","ӽ","Ӿ","","ӿ","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","", +"","ԡ","Ԥ","","","","ԣ","","","","ԩ","Ԫ","Ա","԰","ԭ","Բ","Ԯ","Ե","Դ","Զ","Թ","Ժ","Ը","Լ","","","","","","","","","","","","","","","","","", +"","","","","","","","","","","","","","","","","","","","բ","գ","ը","ե","ժ","լ","խ","ծ","կ","մ","ճ","ն","չ","յ","ո","ռ","ս","վ","","","","", +"","","","","","","","","","","","","","צ","ר","ש","ת","׬","ׯ","װ","׳","״","ײ","","","","","","","","","","","","","","","","","","", +"","","","","","","֤","֣","","֢","֮","֧","֭","֥","֦","֪","֯","֫","֬","֩","ִ","ֶ","ֱ","ֵ","ְ","ֲ","ֳ","ֹ","ֻ","ּ","ַ","ֽ","ָ","","־","","","","","","", +"","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","ס","","ע","פ","","ף","","","","ץ", +"׷","׼","׽","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","", +"","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","", +"","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","", +"","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","", +"","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","", +"","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","", +"","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","", +"","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","", +"","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","߶","", +"","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","", +"","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","", +"","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","", +"","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","", +"","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","", +"","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","", +"","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","", +"","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","", +"","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","", +"","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","", +"","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","", +"","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","", +"","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","", +"","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","", +"","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","", +"","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","", +"","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","", +"","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","", +"","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","", +"","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","¡","¢","£","¥","§","©","¶", +"«","¯","²","³","½","¼","¹","","µ","·","¿","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","", +"","","","","","","","","","","æ","â","ä","ã","è","ë","ì","é","ï","ð","ó","ñ","ò","ô","û","ü","÷","ú","ù","ÿ","","","","","","","","","","","", +"","","","","","","","","","","","","","","","","","","","","","","","","","","","ģ","Ĥ","Ħ","ĥ","ħ","Ĩ","ĩ","ĭ","Ī","Į","ī","Ĭ","ı","ij", +"ĸ","Ķ","ľ","Ŀ","","Ĺ","Ļ","Ľ","ĺ","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","", +"","ţ","Ť","Ŧ","ũ","Ũ","Ū","ū","Ŭ","ŭ","Ů","ů","Ų","ŷ","ż","","ſ","","","","","","","","","","","","","","","","","","","","","","","","", +"","","","","","","","","","","Ƥ","ƣ","Ƣ","ƥ","Ƨ","Ƭ","ƫ","ƪ","ƭ","Ư","Ʈ","Ʊ","Ʋ","ƴ","ƶ","Ʒ","ƹ","ƽ","","ƾ","ƻ","ƿ","Ƽ","","","","","","","","", +"","","","","","","","","","","","","","","","","","","","","","","","","","","","","ǡ","Ǣ","ǧ","Ǩ","ǣ","Ǧ","ǫ","ǩ","ǰ","Ǯ","ǯ","DZ","dz", +"Dz","Ƿ","Ǹ","ǹ","ǻ","ǿ","ǽ","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","", +"","","","","","","ȡ","ȥ","Ȥ","Ȧ","ȫ","Ȩ","Ȫ","ȭ","Ȯ","Ȱ","ȯ","ȱ","ȴ","ȸ","ȷ","ȵ","ȹ","Ⱥ","Ȼ","ȼ","Ⱦ","","","","","","","","","","","","","","", +"","","","","","","","","","","","","","","","","","","","","","","","","","","ɡ","ɢ","ɣ","ɤ","ɥ","ɨ","ɩ","ɫ","ɭ","ɱ","ɳ","ɴ","ɵ","ɸ","ɹ", +"ɽ","ɾ","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","", +"","","","","","ʤ","","ʡ","ʥ","ʢ","ʣ","ʬ","ʧ","ʦ","ʫ","ʩ","ʨ","ʪ","ʮ","ʲ","ʯ","ʱ","ʶ","ʵ","ʰ","ʴ","ʳ","ʷ","ʹ","ʼ","ʻ","ʿ","","","","ʾ","ʽ","","","","", +"","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","", +"","","","","","","","ˢ","ˣ","˥","ˤ","˦","˧","˩","˫","˪","ˬ","˭","ˮ","˰","˯","˳","˵","","˿","˾","˽","˼","˹","˺","","","","","","","","","","","", +"","","","","","","","","","","","","","","","","","","","","̤","̨","̧","̫","̬","̩","̰","̯","̲","̳","̸","̵","̹","̺","̾","̿","̽","","","","", +"","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","", +"ͤ","ͥ","ͣ","ͦ","ͧ","ͨ","ͬ","ͩ","ͭ","ͯ","ͳ","Ͱ","Ͳ","ʹ","͵","ͷ","Ͷ","͸","ͺ","ͻ","ͼ","ͽ","Ϳ",";","","","","","","","","","","","","","","","","","", +"","","","","","","","","","","","","","","","","","","","","","","","","Σ","","΢","Ϊ","Χ","Υ","Ψ","ά","ΰ","α","β","ί","","δ","λ","ζ","η", +"θ","ι","ο","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","Ϧ","","","ϣ","","Ϣ","", +"Ϥ","ϧ","ϡ","Ϫ","","Ϩ","ϥ","ϰ","ϯ","Ϯ","ϴ","ϲ","Ϸ","ϵ","ϸ","϶","Ϻ","Ϲ","Ͽ","","ϼ","","","","","","","","","","","","","","","","","","","","", +"","","","","","","","","","","","","","","","","","","","","","","","","","С","","Т","Ч","У","Ц","Щ","Ъ","Э","а","в","б","Я","Ь","д","й", +"к","ж","м","е","л","","","","","н","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","", +"","","","","","","","","","","","","","","","","","","","ѡ","Ѩ","ѧ","ѩ","Ѫ","Ѱ","Ѳ","Ѯ","ѯ","ѭ","ѵ","Ѷ","Ѹ","ѹ","ѽ","Ѻ","ѻ","Ѽ","","ѿ","","", +"","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","", +"Ҥ","ҥ","ҡ","ң","ҧ","ҩ","Ҫ","ҫ","ү","Ҳ","ұ","Ұ","ҵ","Ҷ","ҳ","ҹ","Һ","һ","","ҽ","","","","","","","","","","","","","","","","","","","","","", +"","","","","","","","","","","","","","","","","ӡ","Ӧ","Ӣ","ӣ","ӥ","ӭ","ӯ","Ӫ","Ӭ","Ӯ","Ӱ","ӳ","Ӳ","Ӷ","ӵ","ӹ","","ӽ","Ӿ","","ӿ","","","","", +"","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","ԡ","Ԥ","","","","ԣ","","","","ԩ", +"Ԫ","Ա","԰","ԭ","Բ","Ԯ","Ե","Դ","Զ","Թ","Ժ","Ը","Լ","","Կ","","","Ծ","Խ","","","","","","","","","","","","","","","","","","","","","","", +"","","","","","","","","","","","","","","","","","","բ","գ","ը","ե","ժ","լ","խ","ծ","կ","մ","ճ","ն","չ","յ","ո","ռ","ս","վ","","","","","", +"","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","֤","֣","","֢","֮", +"֧","֭","֥","֦","֪","֯","֫","֬","֩","ִ","ֶ","ֱ","ֵ","ְ","ֲ","ֳ","ֹ","ֻ","ּ","ַ","ֽ","ָ","","־","","","","","","","","","","","","","","","","","", +"","","","","","","","","","","","","","","","","","","","","ס","","ע","פ","","ף","","","","ץ","צ","ר","ש","ת","׬","ׯ","װ","׳","״","ײ","׷", +"׼","׽","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","",""}; + +int PET_DEBUG_initPetOne( int charaindex) +{ + Char ch; + int havepetindex; + int index; + /* ʸë ¾Ʃ */ + havepetindex = CHAR_getCharPetElement( charaindex) ; + + memset( &ch, 0, sizeof( ch)); + if( !CHAR_getDefaultChar( &ch,31010 ) )return -1; + + /* į */ + ch.data[CHAR_BASEBASEIMAGENUMBER] + = ch.data[CHAR_BASEIMAGENUMBER] = 30008; + ch.data[CHAR_WHICHTYPE] = CHAR_TYPEPET; + /* */ + ch.workint[CHAR_WORKATTACKPOWER] = 100; + /* */ + ch.workint[CHAR_WORKDEFENCEPOWER] = 50; + /* HP */ + ch.data[CHAR_HP] = 100; + /* */ + strcpysafe( ch.string[CHAR_NAME].string, 32, "" ); + + /* CHARԻ񲻯 */ + index = PET_initCharOneArray( &ch); + + if( index < 0 ) return -1; + + /* DZб */ + CHAR_setWorkInt( index, CHAR_WORKPLAYERINDEX, charaindex); + CHAR_setWorkInt( index,CHAR_WORKOBJINDEX,-1); + CHAR_setCharPet( charaindex, havepetindex, index); + CHAR_setInt( index, CHAR_SLOT, 2); + return havepetindex; +} + +static int _PET_dropPet( int charaindex, int havepetindex, int tofl, int tox, int toy) +{ + char szPet[128]; + int dirx[9],diry[9]; + int i, j; + int objindex=-1; + int floor,x,y; + int petindex; + int count_chara =0, count_item =0; + + if( CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE) + != BATTLE_CHARMODE_NONE) return FALSE; + petindex = CHAR_getCharPet(charaindex,havepetindex); + if( !CHAR_CHECKINDEX( petindex )) return FALSE; + if( !CHAR_CHECKINDEX( charaindex ) )return FALSE; + if( CHAR_CHECKINDEX( petindex) == FALSE ) return FALSE; + +#ifdef _AVID_TRADETRYBUG // + if( CHAR_getWorkInt( charaindex, CHAR_WORKTRADEMODE) == CHAR_TRADE_TRADING ){ + CHAR_talkToCli( charaindex, -1, "״̬޷", CHAR_COLORYELLOW ); + return FALSE; + } +#endif + // CoolFish: Family 2001/6/13 + if (CHAR_getInt(petindex, CHAR_PETFAMILY) == 1){ + CHAR_talkToCli(charaindex, -1, "ػ޷", CHAR_COLORYELLOW); + return FALSE; + } + if (CHAR_getInt(charaindex, CHAR_RIDEPET) == havepetindex ){ + CHAR_talkToCli(charaindex, -1, "еij޷", CHAR_COLORYELLOW); + return FALSE; + } + + if( strlen(CHAR_getChar(petindex,CHAR_USERPETNAME))>0 && strstr(CHAR_getChar(petindex,CHAR_USERPETNAME),"*")!=NULL ){ + CHAR_talkToCli(charaindex, -1, "Զк(*)޷ꡢס̯޸ĺ", CHAR_COLORYELLOW); + return FALSE; + } + +#ifdef _DROPCHECK2 + + floor = CHAR_getInt( charaindex, CHAR_FLOOR); + x = CHAR_getInt( charaindex, CHAR_X); + y = CHAR_getInt( charaindex, CHAR_Y); + + for( i = x-CHAR_DEFAULTSEESIZ/2 ; i <= x+CHAR_DEFAULTSEESIZ/2 ; i++ ){ + for( j = y-CHAR_DEFAULTSEESIZ/2 ; j <= y+CHAR_DEFAULTSEESIZ/2 ; j ++ ){ + OBJECT object; + for( object = MAP_getTopObj(floor,i,j); object ; object = NEXT_OBJECT(object ) ) { + int objindex = GET_OBJINDEX(object); + if( OBJECT_getType(objindex) == OBJTYPE_NOUSE ) continue; + + if( OBJECT_getType(objindex) == OBJTYPE_CHARA ) { + count_chara++; + } + if( OBJECT_getType(objindex) == OBJTYPE_ITEM || OBJECT_getType(objindex) == OBJTYPE_GOLD ) { + count_item++; + } + } + } + if( count_item > 80 || count_chara > 80 ) { + CHAR_talkToCli( charaindex, -1, "Ѿ̫ӵˣٶˡ", CHAR_COLORYELLOW ); + return FALSE; + } + } + +#endif + if( tofl == -1 ) { + for( i = 0 ; i < 7 ; i ++ ){ + dirx[i+2] = CHAR_getDX(CHAR_getInt(charaindex,CHAR_DIR) + i+1); + diry[i+2] = CHAR_getDY(CHAR_getInt(charaindex,CHAR_DIR) + i+1); + } + dirx[0] = CHAR_getDX(CHAR_getInt(charaindex,CHAR_DIR)); + diry[0] = CHAR_getDY(CHAR_getInt(charaindex,CHAR_DIR)); + dirx[1] = 0; + diry[1] = 0; + floor = CHAR_getInt( charaindex,CHAR_FLOOR ); + for( i = 0 ; i < 9 ; i ++ ){ + int x=CHAR_getInt(charaindex,CHAR_X)+dirx[i]; + int y=CHAR_getInt(charaindex,CHAR_Y)+diry[i]; + if( PET_isPutPoint( floor, x, y ) == TRUE ) { + break; + } + } + if( i == 9 ) i = 1; + x=CHAR_getInt(charaindex,CHAR_X)+dirx[i]; + y=CHAR_getInt(charaindex,CHAR_Y)+diry[i]; + }else { + if( MAP_walkAbleFromPoint( tofl,tox,toy, FALSE ) == FALSE ) { + print( "map walkable err %s:%d\n", __FILE__,__LINE__); + return FALSE; + } + floor = tofl; + x = tox; + y = toy; + } + objindex = PET_dropPetAbsolute( petindex,floor,x,y, FALSE ); + if( objindex == -1 ) return FALSE; + + CHAR_setWorkInt( petindex,CHAR_WORKOBJINDEX,objindex ); + CHAR_setCharPet( charaindex, havepetindex, -1); + CHAR_setInt( petindex, CHAR_FLOOR, floor); + CHAR_setInt( petindex, CHAR_X, x); + CHAR_setInt( petindex, CHAR_Y, y); + CHAR_setInt( petindex, CHAR_PUTPETTIME, NowTime.tv_sec); + if( havepetindex == CHAR_getInt( charaindex, CHAR_DEFAULTPET)) { + int fd; + CHAR_setInt( charaindex, CHAR_DEFAULTPET, -1); + fd = getfdFromCharaIndex( charaindex); + lssproto_KS_send( fd, havepetindex, 0); + + } + CHAR_sendCToArroundCharacter( objindex); + + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE) == CHAR_TYPEPLAYER) { +#ifdef _PET_ITEM + CHAR_sendPetItemEmpty(charaindex,havepetindex); +#endif + snprintf( szPet, sizeof( szPet ), "K%d", havepetindex ); + CHAR_sendStatusString( charaindex, szPet ); + } + return TRUE; +} + + +/*------------------------------------------------------------ + * ʸë + * ¦ + * itemindex int ʧ ة̼͵ + * floor int ׷ʧID + * x int x + * y int y + * net BOOL ͼë¾ + * ߯Ի + * objindex + * -1 + ------------------------------------------------------------*/ +int PET_dropPetAbsolute( int petindex, int floor, int x, int y,BOOL net) +{ + Object object; + int objindex; + + if( !CHAR_CHECKINDEX(petindex) )return FALSE; + + object.type = OBJTYPE_CHARA; + object.index = petindex; + object.x = x; + object.y = y; + object.floor = floor; + + /* Ƥ */ + objindex = initObjectOne( &object ); + + /* Ͱ׷º뻥Ȼ巴 by ringo*/ + if( net ) + CHAR_sendWatchEvent( objindex,CHAR_ACTSTAND,NULL,0,TRUE); + + return objindex; +} + +BOOL PET_isPutPoint( int fl,int x, int y) +{ + OBJECT object; + if( MAP_walkAbleFromPoint( fl,x,y, FALSE ) == FALSE ) + return FALSE; + for( object=MAP_getTopObj(fl,x,y) ; + object ; + object = NEXT_OBJECT(object ) ) + { + int objindex = GET_OBJINDEX(object); + switch( OBJECT_getType(objindex) ){ + case OBJTYPE_NOUSE: + break; + case OBJTYPE_ITEM: + case OBJTYPE_GOLD: + case OBJTYPE_CHARA: + return FALSE; + break; + default: + break; + } + } + return TRUE; +} + +int PET_dropPet( int charaindex, int havepetindex) +{ + if( CHAR_getWorkInt( charaindex, CHAR_WORKSAFEMODE)==0) + { + CHAR_SafePassword(charaindex); + return; + } + int petindex; + petindex = CHAR_getCharPet(charaindex,havepetindex); + if( !CHAR_CHECKINDEX( petindex )) return FALSE; +#ifdef _PET_AMOI__E + //if( PET_NOT_DropTradeStreetVandor == EVOLUTION_getPetENABLETRADE( CHAR_getInt( petindex, CHAR_PETID)) || + // PET_NOT_Drop == EVOLUTION_getPetENABLETRADE( CHAR_getInt( petindex, CHAR_PETID)) ){ + if( (PET_NOT_DROP) & EVOLUTION_getPetENABLETRADE( CHAR_getInt( petindex, CHAR_PETID))){ + char buf[256]; + sprintf( buf, "%s޷!~",CHAR_getChar( petindex, CHAR_NAME) ); + CHAR_talkToCli(charaindex,-1,buf,CHAR_COLORRED); + return FALSE; + } +#endif +#ifdef _PETSKILL_BINDING + int i,skillid=-1,skillarray; + for(i=0;i<7;i++){ + skillid=CHAR_getPetSkill(petindex,i); + skillarray = PETSKILL_getPetskillArray( skillid); + if( PETSKILL_CHECKINDEX( skillarray) == FALSE ) continue; + if(strstr(PETSKILL_getChar( skillarray, PETSKILL_NAME),"")){ + CHAR_talkToCli(charaindex, -1, "˳Ϊ󶨳޷", CHAR_COLORRED); + return; + } + } +#endif +#ifdef _PET_BINDING + if(strstr(CHAR_getChar(petindex,CHAR_NAME),"*") || strstr(CHAR_getChar(petindex,CHAR_NAME),"+")){ + CHAR_talkToCli(charaindex, -1, "˳Ϊ󶨳޷", CHAR_COLORRED); + return; + } +#endif +#ifdef _MM_NO_JIAOBEN + if(getNoMMJiaoben()==1){ + if(CHAR_getInt(petindex,CHAR_PETID)==718 || CHAR_getInt( petindex, CHAR_PETID) == 401){ + if(getMmType()==0){ + CHAR_talkToCli(charaindex, -1, getMmMsg(), CHAR_COLORRED); + return; + } + time_t timep; + struct tm *p; + time(&timep); + p=localtime(&timep); + timep = mktime(p); + char *randtypetime = CHAR_getChar(charaindex,CHAR_RANDTYPE); + char tempbuff[64]; + int randtype = 0; + int randtime = 0; + int randwrong = 0; + if(strlen(randtypetime)>2){ + if(getStringFromIndexWithDelim(randtypetime,"-", 3, tempbuff, sizeof(tempbuff)) != FALSE){ + if(getStringFromIndexWithDelim(randtypetime,"-", 1, tempbuff, sizeof(tempbuff))== FALSE) + return 0; + randwrong = atoi(tempbuff); + if(getStringFromIndexWithDelim(randtypetime,"-", 2, tempbuff, sizeof(tempbuff))== FALSE) + return 0; + randtype = atoi(tempbuff); + if(getStringFromIndexWithDelim(randtypetime,"-", 3, tempbuff, sizeof(tempbuff))== FALSE) + return 0; + randtime = atoi(tempbuff); + if(timep - randtime < getEditBaseTime()*randwrong){ + char errbuf[256]; + sprintf(errbuf,"%dſԼ˲",getEditBaseTime()*randwrong-(timep - randtime)); + CHAR_talkToCli(charaindex, -1, errbuf, CHAR_COLORRED); + return 0; + } + } + } +// if(timep-CHAR_getWorkInt(charaindex,CHAR_WORKRANDEDITBASETIME)>=getEditBaseTime()) +// CHAR_setWorkInt(charaindex,CHAR_WORKRANDEDITBASETIME,timep); +// else{ +// char errbuf[256]; +// sprintf(errbuf,"%dſԼ˲",getEditBaseTime()-(timep-CHAR_getWorkInt(charaindex,CHAR_WORKRANDEDITBASETIME))); +// CHAR_talkToCli(charaindex, -1, errbuf, CHAR_COLORRED); +// return; +// } + int fd = getfdFromCharaIndex( charaindex); + char arg[255]; + char buf[128]; + char jiabuf[][5]={"","","","","","ʮ",""}; + char jianbuf[][5]={"","һ","-","","-","",""}; + char chengbuf[][5]={"","*","x","X","","",""}; + char numbuf[][5]={"","","","","","","","","",""}; + int i,j,k,l,m; + i = RAND(30,70); + j = RAND(1,29); + l = RAND(1,7); + m = RAND(1,3); + char *typebuf; +// if(randtype == 0){ +// randtype = RAND(1,10); +// if(randtype<=5){ +// randtype = RAND(1,10); +// if(randtype<=3) randtype=1; +// else randtype=2; +// }else{ +// randtype = RAND(1,10); +// if(randtype<=3) randtype=3; +// else randtype=4; +// } +// } + randtype = 4; + if(randtype==1){ + if(m==1){ + typebuf=jiabuf[l-1]; + k = i+j; + }else{ + typebuf=jianbuf[l-1]; + k = i-j; + } + char ibuf[10],jbuf[10]; + if(i<10){ + sprintf(ibuf,"%s",numbuf[i]); + }else{ + int ia,ib; + ia = i/10; + ib = i - ia*10; + sprintf(ibuf,"%s",numbuf[ia]); + strcat(ibuf,numbuf[ib]); + } + if(j<10){ + sprintf(jbuf,"%s",numbuf[j]); + }else{ + int ja,jb; + ja = j/10; + jb = j - ja*10; + sprintf(jbuf,"%s",numbuf[ja]); + strcat(jbuf,numbuf[jb]); + } + sprintf(arg,"%d|%d",havepetindex,k); + CHAR_setWorkChar(charaindex, CHAR_WORKDROPMM, arg); + sprintf(buf,"ʽĽ(%s%s%s=?)",ibuf,typebuf,jbuf); + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGEANDLINEINPUT, + WINDOW_BUTTONTYPE_OK, + CHAR_WINDOWTYPE_RAND1_DROPMM, + -1, + buf); + }else if(randtype==2){ + if(m==1){ + typebuf=jiabuf[l-1]; + k = i+j; + }else if(m==2){ + typebuf=jianbuf[l-1]; + k = i-j; + }else{ + typebuf=chengbuf[l-1]; + k = i*j; + } + char ibuf[10],jbuf[10]; + if(i<10){ + sprintf(ibuf,"%s",numbuf[i]); + }else{ + int ia,ib; + ia = i/10; + ib = i - ia*10; + sprintf(ibuf,"%s",numbuf[ia]); + strcat(ibuf,numbuf[ib]); + } + if(j<10){ + sprintf(jbuf,"%s",numbuf[j]); + }else{ + int ja,jb; + ja = j/10; + jb = j - ja*10; + sprintf(jbuf,"%s",numbuf[ja]); + strcat(jbuf,numbuf[jb]); + } + int n; + int randnum1; + char tempret[5][32]; + randnum1 = RAND(1,5); + int randnumbuf[4]; + int tmpi=0; + while(tmpi<100){ + randnumbuf[0] = RAND(1,100); + randnumbuf[1] = RAND(1,100); + randnumbuf[2] = RAND(1,100); + randnumbuf[3] = RAND(1,100); + if(randnumbuf[0]!=randnumbuf[1]!=randnumbuf[2]!=randnumbuf[3]!=k){ + break; + } + tmpi++; + } + tmpi=0; + for(n=1;n<=5;n++){ + if(n==randnum1){ + sprintf(tempret[n-1],"%d",k); + }else if(tmpi<4){ + sprintf(tempret[n-1],"%d",randnumbuf[tmpi]); + tmpi++; + } + } + sprintf(arg,"%d|%d",havepetindex,randnum1); + CHAR_setWorkChar(charaindex, CHAR_WORKDROPMM, arg); + sprintf(buf,"3\nѡʽĽ(%s%s%s=?)\n \n \nѡһ%s\nѡ%s\nѡ%s\nѡģ%s\nѡ壺%s\n",ibuf,typebuf,jbuf,tempret[0],tempret[1],tempret[2],tempret[3],tempret[4]); + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_SELECT, + WINDOW_BUTTONTYPE_OK, + CHAR_WINDOWTYPE_RAND2_DROPMM, + -1, + buf); + }else if(randtype==3){ + sprintf(arg,"%s",sasql_rand_buf()); + if(strcmp(arg,"err")==0) return; + char tempbuf[64]; + char randquestion[64]; + char randrightanswer[64]; + if(getStringFromIndexWithDelim(arg,"|", 1, tempbuf, sizeof(tempbuf)) == FALSE) + return; + strcpy(randquestion,tempbuf); + if(getStringFromIndexWithDelim(arg,"|", 2, tempbuf, sizeof(tempbuf)) == FALSE) + return; + strcpy(randrightanswer,tempbuf); + sprintf(arg,"%d|%s",havepetindex,randrightanswer); + CHAR_setWorkChar(charaindex, CHAR_WORKDROPMM, arg); + sprintf(buf,"%s:",randquestion); + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGEANDLINEINPUT, + WINDOW_BUTTONTYPE_OK, + CHAR_WINDOWTYPE_RAND3_DROPMM, + -1, + buf); + }else{ +// sprintf(arg,"%s",sasql_rand_buf()); +// if(strcmp(arg,"err")==0) return; + char tempbuf[64]; + char randquestion[64]; + char randrightanswer[64]; + char randwronganswer1[64]; + char randwronganswer2[64]; + char randwronganswer3[64]; + char randwronganswer4[64]; +// if(getStringFromIndexWithDelim(arg,"|", 1, tempbuf, sizeof(tempbuf)) == FALSE) +// return; +// strcpy(randquestion,tempbuf); +// if(getStringFromIndexWithDelim(arg,"|", 2, tempbuf, sizeof(tempbuf)) == FALSE) +// return; +// strcpy(randrightanswer,tempbuf); +// if(getStringFromIndexWithDelim(arg,"|", 3, tempbuf, sizeof(tempbuf)) == FALSE) +// return; +// strcpy(randwronganswer1,tempbuf); +// if(getStringFromIndexWithDelim(arg,"|", 4, tempbuf, sizeof(tempbuf)) == FALSE) +// return; +// strcpy(randwronganswer2,tempbuf); +// if(getStringFromIndexWithDelim(arg,"|", 5, tempbuf, sizeof(tempbuf)) == FALSE) +// return; +// strcpy(randwronganswer3,tempbuf); +// if(getStringFromIndexWithDelim(arg,"|", 6, tempbuf, sizeof(tempbuf)) == FALSE) +// return; +// strcpy(randwronganswer4,tempbuf); + memset(tempbuf, 0, sizeof(tempbuf)); + memset(randquestion, 0, sizeof(randquestion)); + memset(randrightanswer, 0, sizeof(randrightanswer)); + memset(randwronganswer1, 0, sizeof(randwronganswer1)); + memset(randwronganswer2, 0, sizeof(randwronganswer2)); + memset(randwronganswer3, 0, sizeof(randwronganswer3)); + memset(randwronganswer4, 0, sizeof(randwronganswer4)); + if(RAND(1,100)<=75){ + char randtmpbuf[4][10]; + sprintf(randtmpbuf[0],"%s",hanzibuf[RAND(1,5000)-1]); + sprintf(randtmpbuf[1],"%s",hanzibuf[RAND(1,5000)-1]); + sprintf(randtmpbuf[2],"%s",hanzibuf[RAND(1,5000)-1]); + sprintf(randtmpbuf[3],"%s",hanzibuf[RAND(1,5000)-1]); + sprintf(randquestion,"%s",str_hanzi_ganrao(randtmpbuf[0],randtmpbuf[1],randtmpbuf[2],randtmpbuf[3],0,0,0,0,0,0)); + strcat(randquestion,"ҳͬ飩"); + int newrand1 = RAND(1,100)-1; + int newrand2 = RAND(1,100)-1; + int newrand3 = RAND(1,100)-1; + int newrand4 = RAND(1,100)-1; + int newrand5 = RAND(1,100)-1; + sprintf(randrightanswer,"%s",str_hanzi_ganrao(randtmpbuf[0],randtmpbuf[1],randtmpbuf[2],randtmpbuf[3],1,newrand1,newrand2,newrand3,newrand4,newrand5)); + sprintf(randwronganswer1,"%s",str_hanzi_ganrao(randtmpbuf[0],randtmpbuf[1],randtmpbuf[3],randtmpbuf[2],1,newrand1,newrand2,newrand3,newrand4,newrand5)); + sprintf(randwronganswer2,"%s",str_hanzi_ganrao(randtmpbuf[3],randtmpbuf[1],randtmpbuf[2],randtmpbuf[0],1,newrand1,newrand2,newrand3,newrand4,newrand5)); + sprintf(randwronganswer3,"%s",str_hanzi_ganrao(randtmpbuf[1],randtmpbuf[0],randtmpbuf[2],randtmpbuf[3],1,newrand1,newrand2,newrand3,newrand4,newrand5)); + sprintf(randwronganswer4,"%s",str_hanzi_ganrao(randtmpbuf[2],randtmpbuf[3],randtmpbuf[0],randtmpbuf[1],1,newrand1,newrand2,newrand3,newrand4,newrand5)); + + }else{ + int tii; + char timubuf[36][5] = {"a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","0","1","2","3","4","5","6","7","8","9"}; + for(tii=0;tii<5;tii++){ + if(tii==0) + strcpy(tempbuf,timubuf[RAND(1,36)-1]); + else{ + int timunum = 0; + while(1){ + timunum = RAND(1,36)-1; + if(strstr(tempbuf,timubuf[timunum])==NULL) + break; + } + strcat(tempbuf,timubuf[timunum]); + } + } + sprintf(randwronganswer1,"[%c%c%c%c%c]",tempbuf[0],tempbuf[2],tempbuf[1],tempbuf[3],tempbuf[4]); + sprintf(randwronganswer2,"[%c%c%c%c%c]",tempbuf[0],tempbuf[1],tempbuf[4],tempbuf[2],tempbuf[3]); + sprintf(randwronganswer3,"[%c%c%c%c%c]",tempbuf[4],tempbuf[1],tempbuf[2],tempbuf[0],tempbuf[3]); + sprintf(randwronganswer4,"[%c%c%c%c%c]",tempbuf[1],tempbuf[0],tempbuf[2],tempbuf[3],tempbuf[4]); + sprintf(randquestion,"[%s]ҳͬ飩",tempbuf); + sprintf(randrightanswer,"[%s]",tempbuf); + char* randstr = NULL; + randstr = str_ganrao(randquestion); + strcpy(randquestion,randstr); + randstr = str_ganraoan(randrightanswer); + strcpy(randrightanswer,randstr); + randstr = str_ganraoan(randwronganswer1); + strcpy(randwronganswer1,randstr); + randstr = str_ganraoan(randwronganswer2); + strcpy(randwronganswer2,randstr); + randstr = str_ganraoan(randwronganswer3); + strcpy(randwronganswer3,randstr); + randstr = str_ganraoan(randwronganswer4); + strcpy(randwronganswer4,randstr); + } + int n; + int randnum1; + m=1; + char tempret[5][64]; + randnum1 = RAND(1,5); + int rightnum,wrongnum1,wrongnum2,wrongnum3,wrongnum4; + rightnum = RAND(getRandMin(),getRandMax()); + wrongnum1 = RAND(getRandMin(),getRandMax()); + wrongnum2 = RAND(getRandMin(),getRandMax()); + wrongnum3 = RAND(getRandMin(),getRandMax()); + wrongnum4 = RAND(getRandMin(),getRandMax()); + //char *tempbuff2 = "ABCDE"; + int qianhounum = RAND(1,100); + for(n=1;n<=5;n++){ + if(n==randnum1){ + if(qianhounum<=50) + sprintf(tempret[n-1],"ѡ( %d %s )",rightnum,randrightanswer); + else + sprintf(tempret[n-1],"ѡ( %s %d )",randrightanswer,rightnum); + }else{ + if(m==1){ + if(qianhounum<=50) + sprintf(tempret[n-1],"ѡ( %d %s )",wrongnum1,randwronganswer1); + else + sprintf(tempret[n-1],"ѡ( %s %d )",randwronganswer1,wrongnum1); + m = 2; + }else if(m==2){ + if(qianhounum<=50) + sprintf(tempret[n-1],"ѡ( %d %s )",wrongnum2,randwronganswer2); + else + sprintf(tempret[n-1],"ѡ( %s %d )",randwronganswer2,wrongnum2); + m = 3; + }else if(m==3){ + if(qianhounum<=50) + sprintf(tempret[n-1],"ѡ( %d %s )",wrongnum3,randwronganswer3); + else + sprintf(tempret[n-1],"ѡ( %s %d )",randwronganswer3,wrongnum3); + m = 4; + }else if(m==4){ + if(qianhounum<=50) + sprintf(tempret[n-1],"ѡ( %d %s )",wrongnum4,randwronganswer4); + else + sprintf(tempret[n-1],"ѡ( %s %d )",randwronganswer4,wrongnum4); + m = 5; + } + } + } + int windowtype = 0; + int selecttype = RAND(1,100); + if(selecttype<=30){ + sprintf(arg,"%d|%d|%d",havepetindex,rightnum); + windowtype = WINDOW_MESSAGETYPE_MESSAGEANDLINEINPUT; + }else{ + sprintf(arg,"%d|%d|%d",havepetindex,randnum1); + windowtype = WINDOW_MESSAGETYPE_SELECT; + } + CHAR_setWorkChar(charaindex, CHAR_WORKDROPMM, arg); + sprintf(buf,"%s\n%s\n%s\n%s\n%s\n%s\nȷڵ5λֻߵѡ",randquestion,tempret[0],tempret[1],tempret[2],tempret[3],tempret[4]); + lssproto_WN_send( fd, windowtype, + WINDOW_BUTTONTYPE_OK, + CHAR_WINDOWTYPE_RAND4_DROPMM, + -1, + buf); + CHAR_setWorkInt(charaindex,CHAR_WORKLUANPCINT,0); + } + if(randwrong<=0){ + sprintf(tempbuff,"1-%d-%d",randtype,timep); + }else{ + sprintf(tempbuff,"%d-%d-%d",randwrong*3,randtype,timep); + } + CHAR_setChar(charaindex,CHAR_RANDTYPE,tempbuff); + return 0; + } +} +#endif + if( _PET_dropPet( charaindex, havepetindex, -1,-1,-1) == TRUE ){ + char tmpbuf[256]; + sprintf(tmpbuf," %s (ʧʱ%d)",CHAR_getChar( petindex, CHAR_NAME),getPetdeletetime()); + CHAR_talkToCli( charaindex, -1, tmpbuf, CHAR_COLORYELLOW ); + LogPet( + CHAR_getChar( charaindex, CHAR_NAME ), /* ƽҷ */ + CHAR_getChar( charaindex, CHAR_CDKEY ), + CHAR_getChar( petindex, CHAR_NAME), + CHAR_getInt( petindex, CHAR_LV), + "Drop()", + CHAR_getInt( charaindex,CHAR_FLOOR), + CHAR_getInt( charaindex,CHAR_X ), + CHAR_getInt( charaindex,CHAR_Y ), + CHAR_getChar( petindex, CHAR_UNIQUECODE) // shan 2001/12/14 + ); + return 1; + } + return 0; +} + +int PET_dropPetFLXY( int charaindex, int havepetindex, int fl, int x, int y) +{ + return _PET_dropPet( charaindex, havepetindex, fl,x,y); +} + +/*------------------------------------------------------------ + * ʸüìëƻ֧ + ------------------------------------------------------------*/ +int PET_initCharOneArray( Char *ch) +{ + int i; + char *tmp[CHAR_FUNCTABLENUM] = { + "", /* CHAR_INITFUNC */ + "", /* CHAR_WALKPREFUNC */ + "", /* CHAR_WALKPOSTFUNC */ + "", /* CHAR_PREOVERFUNC */ + "", /* CHAR_PREOVERFUNC */ + "core_PetWatch", /* CHAR_WATCHFUNC */ + "", /* CHAR_LOOPFUNC */ + "", /* CHAR_DYINGFUNC */ + "core_PetTalk", /* CHAR_TALKEDFUNC */ + "", /* CHAR_PREATTACKEDFUNC */ + "", /* CHAR_POSTATTACKEDFUNC */ + "", /* CHAR_OFFFUNC */ + "", /* CHAR_LOOKEDFUNC */ + "", /* CHAR_ITEMPUTFUNC */ + "", /* CHAR_SPECIALTALKEDFUNC */ + "", /* CHAR_WINDOWTALKEDFUNC */ +#ifdef _USER_CHARLOOPS + "", // CHAR_LOOPFUNCTEMP1, + "", // CHAR_LOOPFUNCTEMP2, + "", //CHAR_BATTLEPROPERTY, +#endif + }; + for( i = 0; i < CHAR_FUNCTABLENUM; i ++ ) { + strcpysafe( ch->charfunctable[i].string, + sizeof( ch->charfunctable[i]), + tmp[i]); + } + if( ch->data[CHAR_MAILMODE] != CHAR_PETMAIL_NONE ) { + strcpysafe( ch->charfunctable[CHAR_LOOPFUNC].string, + sizeof( ch->charfunctable[CHAR_LOOPFUNC]), "PETMAIL_Loop"); + + } +#ifdef _USER_CHARLOOPS + if( ch->data[CHAR_FUSIONBEIT] == 1 && + ch->data[CHAR_FUSIONRAISE] > 0 ) { + //andy_log +// print("init CHAR_LOOPFUNCTEMP1:%s \n", "PET_CheckIncubateLoop"); + + strcpysafe( ch->charfunctable[CHAR_LOOPFUNCTEMP1].string, + sizeof( ch->charfunctable[CHAR_LOOPFUNCTEMP1]), "PET_CheckIncubateLoop"); + ch->data[CHAR_LOOPINTERVAL] = 60000; + + ch->functable[CHAR_LOOPFUNCTEMP1] + = getFunctionPointerFromName( "PET_CheckIncubateLoop"); + +// CHAR_constructFunctable( petindex); + } +#endif + return( CHAR_initCharOneArray( ch)); +} + +int PET_createPetFromCharaIndex( int charaindex, int enemyindex) +{ + Char CharNew; + int newindex; + int havepetelement; + char szPet[128]; + int i; + + havepetelement = CHAR_getCharPetElement( charaindex); + if( havepetelement < 0 ) return -1; + memset( &CharNew, 0, sizeof( Char ) ); + if( !CHAR_getDefaultChar( &CharNew,31010 ) )return -1; + CharNew.data[CHAR_BASEBASEIMAGENUMBER] + = CharNew.data[CHAR_BASEIMAGENUMBER] = CHAR_getInt(enemyindex,CHAR_BASEIMAGENUMBER); + CharNew.data[CHAR_WHICHTYPE] = CHAR_TYPEPET; + CharNew.data[CHAR_HP] = CHAR_getInt(enemyindex, CHAR_HP); + CharNew.data[CHAR_MP] = CHAR_getInt(enemyindex, CHAR_MP); + CharNew.data[CHAR_MAXMP] = CHAR_getInt(enemyindex, CHAR_MAXMP); + CharNew.data[CHAR_VITAL] = CHAR_getInt(enemyindex, CHAR_VITAL); + CharNew.data[CHAR_STR] = CHAR_getInt(enemyindex, CHAR_STR); + CharNew.data[CHAR_TOUGH] = CHAR_getInt(enemyindex, CHAR_TOUGH); + CharNew.data[CHAR_DEX] = CHAR_getInt(enemyindex, CHAR_DEX); + CharNew.data[CHAR_LUCK] = CHAR_getInt(enemyindex, CHAR_LUCK); + CharNew.data[CHAR_FIREAT] = CHAR_getInt(enemyindex, CHAR_FIREAT); + CharNew.data[CHAR_WATERAT] = CHAR_getInt(enemyindex, CHAR_WATERAT); + CharNew.data[CHAR_EARTHAT] = CHAR_getInt(enemyindex, CHAR_EARTHAT); + CharNew.data[CHAR_WINDAT] = CHAR_getInt(enemyindex, CHAR_WINDAT); + //CharNew.data[CHAR_EXP] = CHAR_getInt(enemyindex, CHAR_EXP); + + CharNew.data[CHAR_SLOT] = CHAR_getInt(enemyindex, CHAR_SLOT); + CharNew.data[CHAR_MODAI] = CHAR_getInt(enemyindex, CHAR_MODAI); + CharNew.data[CHAR_LV] = CHAR_getInt(enemyindex, CHAR_LV); + CharNew.data[CHAR_POISON] = CHAR_getInt(enemyindex, CHAR_POISON); + CharNew.data[CHAR_PARALYSIS]= CHAR_getInt(enemyindex, CHAR_PARALYSIS); + CharNew.data[CHAR_SLEEP] = CHAR_getInt(enemyindex, CHAR_SLEEP); + CharNew.data[CHAR_STONE] = CHAR_getInt(enemyindex, CHAR_STONE); + CharNew.data[CHAR_DRUNK] = CHAR_getInt(enemyindex, CHAR_DRUNK); + CharNew.data[CHAR_CONFUSION]= CHAR_getInt(enemyindex, CHAR_CONFUSION); + CharNew.data[CHAR_RARE] = CHAR_getInt(enemyindex, CHAR_RARE); + CharNew.data[CHAR_PETRANK] = CHAR_getInt(enemyindex, CHAR_PETRANK); + CharNew.data[CHAR_PETID] = CHAR_getInt(enemyindex, CHAR_PETID); + CharNew.data[CHAR_CRITIAL] = CHAR_getInt(enemyindex, CHAR_CRITIAL); + CharNew.data[CHAR_COUNTER] = CHAR_getInt(enemyindex, CHAR_COUNTER); + CharNew.data[CHAR_PETMAILEFFECT] = RAND(0, PETMAIL_EFFECTMAX); + CharNew.data[CHAR_PETENEMYID] = CHAR_getInt(enemyindex, CHAR_PETENEMYID); + + for( i = 0; i < CHAR_MAXPETSKILLHAVE; i ++ ) { + CharNew.unionTable.indexOfPetskill[i] = CHAR_getPetSkill( enemyindex, i); + } + CharNew.data[CHAR_ALLOCPOINT] = CHAR_getInt(enemyindex, CHAR_ALLOCPOINT); + strcpysafe( CharNew.string[CHAR_NAME].string, + sizeof(CharNew.string[CHAR_NAME].string), + CHAR_getChar( enemyindex, CHAR_NAME) ); + newindex = PET_initCharOneArray( &CharNew ); +#ifdef _CAX_LVTISHI + if (CharNew.data[CHAR_LV] == 1){//׽ij1 + int namelen=strlen(CHAR_getChar(newindex, CHAR_NAME));//óƵij + char petname[namelen-3];//ΪҪȥĸַƵĻ,ֱȡĸַ + snprintf( petname, sizeof( petname),"%s",CHAR_getChar( newindex, CHAR_NAME)); + CHAR_setChar( newindex, CHAR_NAME, petname); + } +#endif + if( newindex < 0 ){ + return -1; + } + + CHAR_setMaxExpFromLevel( newindex, CHAR_getInt( enemyindex, CHAR_LV )); + CHAR_complianceParameter( newindex ); + CHAR_setWorkInt( newindex, CHAR_WORKPLAYERINDEX, charaindex); + CHAR_setCharPet( charaindex, havepetelement, newindex); + CHAR_setChar( newindex, CHAR_OWNERCDKEY, + CHAR_getChar( charaindex, CHAR_CDKEY)); + CHAR_setChar( newindex, CHAR_OWNERCHARANAME, + CHAR_getChar( charaindex, CHAR_NAME)); + snprintf( szPet, sizeof( szPet ), "K%d", havepetelement ); + CHAR_sendStatusString( charaindex, szPet ); + snprintf( szPet, sizeof( szPet ), "W%d", havepetelement ); + CHAR_sendStatusString( charaindex, szPet ); + + return newindex; + +} +BOOL PET_SelectBattleEntryPet( int charaindex, int petarray) +{ + int pindex; + /* ºƥľ¦Ⱦµ ؤԻ */ + if( CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE) + != BATTLE_CHARMODE_NONE) return FALSE; + /* -1-1ƻƻδԻ*/ + if( petarray == -1 ) { + CHAR_setInt( charaindex, CHAR_DEFAULTPET, -1 ); + return TRUE; + } + if( !CHAR_CHECKPETINDEX( petarray)) return FALSE; + pindex = CHAR_getCharPet( charaindex, petarray ); + if( !CHAR_CHECKINDEX( pindex)) return FALSE; + + if( CHAR_getFlg( pindex, CHAR_ISDIE )) return FALSE; +#ifdef _RIDEBUG + //жǷΪ + if(CHAR_getInt( charaindex, CHAR_RIDEPET) == petarray) return FALSE; +#endif + CHAR_setInt( charaindex, CHAR_DEFAULTPET, petarray ); + + return TRUE; +} + +// Robin 0707 petFollow +#if 1 +int PET_dropPetFollow( int charaindex, int havepetindex, int tofl, int tox, int toy) +{ + char szPet[128]; + int dirx[9],diry[9]; + int i; + int objindex=-1; + int floor,x,y; + int petindex; + + if( CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE) + != BATTLE_CHARMODE_NONE) return FALSE; + petindex = CHAR_getCharPet(charaindex,havepetindex); + if( petindex == -1 ) return FALSE; + if( !CHAR_CHECKINDEX( charaindex ) )return FALSE; + if( CHAR_CHECKINDEX( petindex) == FALSE ) return FALSE; + + if (CHAR_getInt(petindex, CHAR_PETFAMILY) == 1){ + CHAR_talkToCli(charaindex, -1, "ػ޷", CHAR_COLORYELLOW); + return FALSE; + } + if (CHAR_getInt(charaindex, CHAR_RIDEPET) == havepetindex){ + CHAR_talkToCli(charaindex, -1, "еij޷棡", CHAR_COLORYELLOW); + return FALSE; + } + if( tofl == -1 ) { + for( i = 0 ; i < 7 ; i ++ ){ + dirx[i+2] = CHAR_getDX(CHAR_getInt(charaindex,CHAR_DIR) + i+1); + diry[i+2] = CHAR_getDY(CHAR_getInt(charaindex,CHAR_DIR) + i+1); + } + dirx[0] = CHAR_getDX(CHAR_getInt(charaindex,CHAR_DIR)); + diry[0] = CHAR_getDY(CHAR_getInt(charaindex,CHAR_DIR)); + dirx[1] = 0; + diry[1] = 0; + + floor = CHAR_getInt( charaindex,CHAR_FLOOR ); + for( i = 0 ; i < 9 ; i ++ ){ + int x=CHAR_getInt(charaindex,CHAR_X)+dirx[i]; + int y=CHAR_getInt(charaindex,CHAR_Y)+diry[i]; + if( PET_isPutPoint( floor, x, y ) == TRUE ) { + break; + } + } + if( i == 9 ) i = 1; + + x=CHAR_getInt(charaindex,CHAR_X)+dirx[i]; + y=CHAR_getInt(charaindex,CHAR_Y)+diry[i]; + } + else { + if( MAP_walkAbleFromPoint( tofl,tox,toy, FALSE ) == FALSE ) { + print( "map walkable err %s:%d\n", __FILE__,__LINE__); + return FALSE; + } + floor = tofl; + x = tox; + y = toy; + } + + objindex = PET_dropPetAbsolute( petindex,floor,x,y, FALSE ); + if( objindex == -1 ) return FALSE; + + CHAR_setWorkInt( petindex,CHAR_WORKOBJINDEX,objindex ); + CHAR_setCharPet( charaindex, havepetindex, -1); + CHAR_setInt( petindex, CHAR_FLOOR, floor); + CHAR_setInt( petindex, CHAR_X, x); + CHAR_setInt( petindex, CHAR_Y, y); + CHAR_setInt( petindex, CHAR_PUTPETTIME, NowTime.tv_sec); + if( havepetindex == CHAR_getInt( charaindex, CHAR_DEFAULTPET)) { + int fd; + CHAR_setInt( charaindex, CHAR_DEFAULTPET, -1); + fd = getfdFromCharaIndex( charaindex); + lssproto_KS_send( fd, havepetindex, 0); + + } + CHAR_sendCToArroundCharacter( objindex); + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE) == CHAR_TYPEPLAYER) { +#ifdef _PET_ITEM + CHAR_sendPetItemData( charaindex, havepetindex); +#endif + snprintf( szPet, sizeof( szPet ), "K%d", havepetindex ); + CHAR_sendStatusString( charaindex, szPet ); + } + + CHAR_setWorkInt( charaindex, CHAR_WORKPETFOLLOW, petindex); + CHAR_setWorkInt( petindex, CHAR_WORKPETFOLLOWMODE, CHAR_PETFOLLOW_NOW); + CHAR_setWorkInt( petindex, CHAR_WORKPETFOLLOWCOUNT, 0); + CHAR_setInt( petindex, CHAR_PUTPETTIME, (int)(NowTime.tv_sec)); + CHAR_setInt( petindex, CHAR_WORKPLAYERINDEX, charaindex); + LogPet( + CHAR_getChar( charaindex, CHAR_NAME ), + CHAR_getChar( charaindex, CHAR_CDKEY ), + CHAR_getChar( petindex, CHAR_NAME), + CHAR_getInt( petindex, CHAR_LV), + "Follow()", + CHAR_getInt( charaindex,CHAR_FLOOR), + CHAR_getInt( charaindex,CHAR_X ), + CHAR_getInt( charaindex,CHAR_Y ), + CHAR_getChar( petindex, CHAR_UNIQUECODE) + ); + return 1; +} +#endif + +BOOL PET_getBaseForAllocpoint( int toindex, int *work) +{ + int LevelUpPoint=0; + if( CHAR_getInt( toindex, CHAR_WHICHTYPE) != CHAR_TYPEPET) + return FALSE; + LevelUpPoint = CHAR_getInt( toindex, CHAR_ALLOCPOINT ); + work[3] =(( LevelUpPoint >> 24 ) & 0xFF); + work[0] = (( LevelUpPoint >> 16 ) & 0xFF); + work[1] = (( LevelUpPoint >> 8 ) & 0xFF); + work[2] = (( LevelUpPoint >> 0 ) & 0xFF); + return TRUE; +} + +void PET_showEditBaseMsg( int charaindex, int toindex, int itemindex, int *work) +{ + int i, maxnums = 6000; + char buf1[256]; + char buf2[][32]={"ɳ",";ɳ","ٶȳɳ","ɳ",""}; + char buf3[][32]={"","Ϊ","Ϊ"}; + + if( CHAR_getInt( toindex, CHAR_WHICHTYPE) != CHAR_TYPEPET) + return; + memset( buf1, 0, sizeof( buf1)); + + for( i=0; i<4; i++) { + int type = ITEM_getInt( itemindex, (ITEM_MODIFYATTACK + i)); +// print(" ι[%d]%d+%d ", i, work[i], type); + work[i] += type; + strcpy( buf1,"\0"); + if( work[i] > maxnums ) { + sprintf(buf1,"%s Ѿﵽˡ", buf2[i]); + work[i] = maxnums; + }else if( work[i] < 0 ) { + sprintf(buf1,"%s ѾΪˡ", buf2[i]); + work[i] = 0; + }else { + if( type > 0 ) { + if( type > 2 ) { + sprintf(buf1,"%s %s %s", buf2[i], buf3[0], ""); + }else { + sprintf(buf1,"%s %s %s", buf2[i], buf3[1], ""); + } + }else if( type < 0 ){ + sprintf(buf1,"%s %s %s", buf2[i], buf3[2], ""); + } + } + if( strcmp( buf1, "\0")) { + CHAR_talkToCli( charaindex, toindex, buf1, CHAR_COLORYELLOW); + } + } +} + +#ifdef _PET_EVOLUTION +BOOL PET_getBaseAndSkill( int charaindex, int baseindex, int *base, int *skill, int flg) +{ + int i; + if( !CHAR_CHECKINDEX( baseindex)) return FALSE; + if( base != NULL ) { + int levelup = CHAR_getInt( baseindex, CHAR_ALLOCPOINT); + base[0] = ((levelup>>24) & 0xFF); + base[1] = ((levelup>>16) & 0xFF); + base[2] = ((levelup>> 8) & 0xFF); + base[3] = ((levelup>> 0) & 0xFF); + } + + if( skill != NULL ) { + for( i=0; i= CHAR_MAXPETHAVE){ + return FALSE; + }else { + char szPet[256]; + char msgbuf[256]; + CHAR_setCharPet( charaindex, i, -1); + snprintf( szPet, sizeof( szPet ), "K%d", i); + CHAR_sendStatusString( charaindex, szPet ); + + snprintf( msgbuf,sizeof( msgbuf), "%s", CHAR_getChar( petindex, CHAR_NAME)); + CHAR_talkToCli( charaindex, -1, msgbuf, CHAR_COLORYELLOW); + CHAR_endCharOneArray( petindex ); + } + return TRUE; +} + + diff --git a/char/pet_event.c b/char/pet_event.c new file mode 100644 index 0000000..5f139ef --- /dev/null +++ b/char/pet_event.c @@ -0,0 +1,907 @@ +#include "version.h" +#include +#include + +#include "common.h" +#include "object.h" +#include "char_base.h" +#include "char.h" +#include "configfile.h" +#include "handletime.h" +#include "pet_event.h" +#include "npcutil.h" +#include "log.h" +#include "lssproto_serv.h" +// Arminius 8.14 pet talk +#include +#include "npc_exchangeman.h" +#include "npc_eventaction.h" +#ifdef _ALLBLUES_LUA +#include "mylua/function.h" +#endif +#ifdef _PET_TALK +//BOOL PetTalk_CheckFree( int meindex, int toindex, char *buf); +BOOL PetTalk_CheckFree( int meindex, int talker, char *buf); + +BOOL PetTalk_BSCheck(int meindex,int talker,char* buf); +BOOL PetTalk_FreeIfCheck(int meindex,int talker,char* buf,int kosuu,int flg, int temp); +BOOL PetTalk_WarpManReduce(int meindex,int talker,char *buf); +BOOL PetTalk_BigSmallLastCheck(int point1,int mypoint,int flg); +BOOL PetTalk_CheckTrans(int meindex,int talker,int trans,int flg); +BOOL PetTalk_LevelCheck(int meindex,int talker,int level,int flg); +BOOL PetTalk_CheckMyPet( int meindex, int talker, int petLv, int flg, int petid); +BOOL PetTalk_ItemCheck(int meindex,int talker,int itemNo,int flg); +BOOL PetTalk_CheckMyType( int meindex, int toindex, int kosuu, int flg, int Type ); +BOOL PetTalk_CheckPetEvent( int meindex, int toindex, char *buf); +void PetTalk_RequestMain(int meindex,int talker,char *buf); +BOOL PetTalk_AddItem(int meindex, int talker, char *buf); +BOOL PetTalk_DelItem(int meindex,int talker,char *buf); +BOOL PetTalk_RunEvent( int meindex, int talker, char *buf); +BOOL PetTalk_CheckMyFloor( int meindex, int talker, char *buf, int flg); +#ifdef _PET_TALKBBI +BOOL PET_CheckPlayerBBI( int meindex, int charindex, int BBI, int flg); +#endif +#ifdef _PET_TALKPRO +#else +char *Pet_TalkGetFunStr( char *temp , char *buf, int len) +{ + char filename[56]; + char pathfile[128]; + char talkfun[ 10240]; + char buf1[256],buf2[256],buf3[256]; + FILE *petarg; + char *cStr=NULL; + int talkNo=1,mark=1; + char line[4096]; + BOOL find=FALSE; + talkfun[0] ='\0'; + + while( getStringFromIndexWithDelim( pettalktext,"&",talkNo, buf1, sizeof( buf1) ) != FALSE){ + talkNo++; + if( NPC_Util_GetStrFromStrWithDelim( buf1, "PETTEMPNO", buf2, sizeof( buf2)) == NULL ) + continue; + mark=2; + strcpy( filename,"\0"); + while( getStringFromIndexWithDelim( buf2,",", mark,buf3,sizeof( buf3)) != FALSE ) { + mark ++; + if( !strcmp( buf3, temp)) { + print("\n buf2=%s",buf2); + if( getStringFromIndexWithDelim( buf2,",", 1,filename,sizeof( filename)) == FALSE ) + return NULL; + find = TRUE; + break; + } + } + if( find == TRUE ) + break; + } + if( !strcmp( filename, "\0") ) + return NULL; + + sprintf( pathfile, "%s/pettalk/%s", getNpcdir(), filename); + petarg = fopen( pathfile , "r" ); + if( petarg != NULL ) { + while( fgets( line, sizeof( line), petarg ) ) { + if( strlen( talkfun) != 0 ) { + if( talkfun[strlen( talkfun) -1] != '|' ) { + strcatsafe( talkfun, sizeof( talkfun), "|"); + } + } + chompex( line); + strcatsafe( talkfun, sizeof( talkfun ), line); + } + fclose( petarg); + }else { + return NULL; + } + talkNo = 1; + while( getStringFromIndexWithDelim( talkfun,"}",talkNo, buf, len) != FALSE) { + talkNo++; + if( NPC_Util_GetStrFromStrWithDelim( buf, "PETTEMPNO", buf2, sizeof( buf2)) == NULL ) + continue; + if( !strcmp( temp, buf2) ) { + cStr = buf; + break; + } + } + return( cStr); +} +#endif +void PET_Talkfunc( int meindex, int talkerindex, char *msg, int color) +{ + char buf2[1024], buf3[256]; + + char TalkType[][16]={"TALKRUN","EVENTRUN","BOTH"}; + char AllTalk[PETTALK_MAXID][1024]; + int Type=0,j,i; + int talkNo=0; + BOOL FREEs=FALSE; + int buttontype = 0; + int windowtype = 0; +#ifdef _PET_TALKPRO + int tPage=-1; +#else + int petid=-1; + char tempNo[32], buf1[10240]; +#endif + int fd = getfdFromCharaIndex( talkerindex); +#define RAND(x,y) ((x-1)+1+ (int)( (double)(y-(x-1))*rand()/(RAND_MAX+1.0)) ) + windowtype = WINDOW_MESSAGETYPE_MESSAGE; + buttontype = WINDOW_BUTTONTYPE_OK; + if( NPC_Util_isFaceToFace( meindex ,talkerindex , 2) == FALSE) { + if( NPC_Util_isFaceToChara( talkerindex, meindex, 1) == FALSE) + return; + } + for( i = 0 ; i < 5 ; i++ ) { + strcpy( AllTalk[i], "\0" ); + } +#ifdef _ALLBLUES_LUA_1_5 + RunCharTalkedEvent( meindex, talkerindex, msg, color, 1); +#endif +#ifdef _PET_TALKPRO + for( i=0;i=0 && pettalktext[i].ID == CHAR_getInt(meindex, CHAR_PETID) ) { + if( strcmp( pettalktext[i].DATA, "\0") && strlen( pettalktext[i].DATA) > 0 ) { + //snprintf( buf1, sizeof(buf1), pettalktext[i].DATA); + tPage=i; + break; + } + } + } + if( i == PETTALK_MAXID ) + return; +#else + sprintf(tempNo,"%d", CHAR_getInt(meindex, CHAR_PETID)); + petid = CHAR_getInt(meindex, CHAR_PETID); + if( Pet_TalkGetFunStr( tempNo , buf1 , sizeof( buf1) ) == NULL ) { + return; + } +#endif + if( CHAR_getInt( meindex, CHAR_LV ) >= CHAR_getInt( meindex, CHAR_LIMITLEVEL) ) { + Type = 1; + } + //趨Ϊ˲PET + if( strcmp( CHAR_getChar( meindex, CHAR_OWNERCDKEY), CHAR_getChar( talkerindex, CHAR_CDKEY) ) || + strcmp( CHAR_getChar( meindex, CHAR_OWNERCHARANAME), CHAR_getChar( talkerindex, CHAR_NAME) )){ +#ifdef _PET_TALKPRO + if( NPC_Util_GetStrFromStrWithDelim( pettalktext[tPage].DATA, "NoPlayerMsg", buf3, sizeof( buf3)) != NULL ) { +#else + if( NPC_Util_GetStrFromStrWithDelim( buf1, "NoPlayerMsg", buf3, sizeof( buf3)) != NULL ) { +#endif + }else { + sprintf(buf3,"İˣҲʶѽǻˣ"); + } + CHAR_talkToCli( talkerindex, meindex, buf3, color); + return; + } + j=0; + +#ifdef _PET_TALKPRO + while( getStringFromIndexWithDelim( pettalktext[tPage].DATA,"OVER",talkNo, buf2, sizeof( buf2) ) != FALSE){ +#else + while( getStringFromIndexWithDelim( buf1,"OVER",talkNo, buf2, sizeof( buf2) ) != FALSE){ +#endif + talkNo++; + if( ( strstr( buf2, TalkType[Type]) == NULL ) && ( strstr( buf2, TalkType[2]) == NULL ) )continue; + if( NPC_Util_GetStrFromStrWithDelim( buf2, "FLOOR", buf3, sizeof( buf3)) != NULL ) {//жϷ + if( PetTalk_CheckMyFloor( meindex, talkerindex, buf3, 0) == FALSE )continue; + } + if( NPC_Util_GetStrFromStrWithDelim( buf2, "PET", buf3, sizeof( buf3)) != NULL ) {//жϳFREE + if( PetTalk_CheckFree( meindex, meindex, buf3) != TRUE ) continue; + } + if( NPC_Util_GetStrFromStrWithDelim( buf2, "FREE", buf3, sizeof( buf3) ) == NULL)continue; + if( NPC_ActionPassCheck( meindex, talkerindex, buf3) == FALSE ) continue;//жFREE +// if( ActionNpc_CheckFree( meindex, talkerindex, buf2, 0) == FALSE ) continue; + if( PetTalk_CheckPetEvent( meindex, talkerindex, buf2) == FALSE )continue; + FREEs = TRUE; // + strcpy( AllTalk[j++], buf2 ); + if( j > PETTALK_MAXID-1 ) break; + } + talkNo = 0; + if( FREEs == FALSE) { //ȫ + j=0; +#ifdef _PET_TALKPRO + while( getStringFromIndexWithDelim( pettalktext[tPage].DATA,"OVER",talkNo, buf2, sizeof( buf2) ) != FALSE ){ +#else + while( getStringFromIndexWithDelim( buf1,"OVER",talkNo, buf2, sizeof( buf2) ) != FALSE ){ +#endif + talkNo ++; + if( strstr( buf2, "OTHER") == NULL ) continue; + if( NPC_Util_GetStrFromStrWithDelim( buf2, "TalkMsg", buf3, sizeof( buf3)) == NULL) continue; + while( getStringFromIndexWithDelim( buf3,",",j+1, AllTalk[j], sizeof( AllTalk[j]) ) != FALSE ){ + j++; + } + break; + } + } + if( j > 0 ) { + strcpy( buf2, AllTalk[ RAND( 0, (j-1) ) ] ); + if( PetTalk_RunEvent( meindex, talkerindex, buf2) == FALSE ) { + sprintf( buf3,""); + CHAR_talkToCli( talkerindex, meindex, buf3, color); + return; + } + if( NPC_Util_GetStrFromStrWithDelim( buf2, "TalkMsg", buf3, sizeof( buf3)) == NULL) { + //sprintf( buf3,"ˣȥɣ"); + strcpy( buf3, buf2); + } + + lssproto_WN_send( fd, windowtype, buttontype, 0, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), buf3 ); + } + +} + +BOOL PetTalk_CheckMyFloor( int meindex, int talker, char *buf, int flg) { + char buf1[16]; + int Myfloor=-1; + Myfloor = CHAR_getInt( talker, CHAR_FLOOR); + if( strstr( buf, "!") != NULL ) { + getStringFromIndexWithDelim( buf,"!", 2, buf1, sizeof( buf1) ); + if( Myfloor == atoi( buf1) ) { + return FALSE; + } + }else { + if( Myfloor != atoi( buf) ) { + return FALSE; + } + } + return TRUE; +} + +BOOL PetTalk_RunEvent( int meindex, int talker, char *buf) +{ + char buf1[256]; + int LimitLevel = -1; + + if( Action_RunDoEventAction( meindex, talker, buf) == FALSE ) + return FALSE; + + if( NPC_Util_GetStrFromStrWithDelim( buf, "RandItem", buf1, sizeof( buf1)) != NULL ){ + if( RAND( 0, 10) > 9 ) { + PetTalk_AddItem( meindex, talker, buf1); + }else { + return FALSE; + } + } + if( NPC_Util_GetStrFromStrWithDelim( buf, "LimitLevel", buf1, sizeof( buf1)) != NULL ){ + LimitLevel = atoi( buf1); + CHAR_setInt( meindex, CHAR_LIMITLEVEL, LimitLevel); + } + return TRUE; + +} + +BOOL PetTalk_DelItem(int meindex,int talker,char *buf) +{ + + int i = 1, j = 1,k = 1; + char buff3[128]; + char buf2[32]; + int itemindex; + + while( getStringFromIndexWithDelim(buf , "," , k, buff3, sizeof(buff3)) !=FALSE ) { + k++; + if(strstr(buff3,"*")!=NULL){ + int itemno; + int kosuu; + int id; + int cnt=0; + + getStringFromIndexWithDelim(buff3,"*",1,buf2,sizeof(buf2)); + itemno = atoi(buf2); + getStringFromIndexWithDelim(buff3,"*",2,buf2,sizeof(buf2)); + kosuu = atoi(buf2); + + for( i =0 ; i < CHAR_MAXITEMHAVE ; i++ ){ + itemindex=CHAR_getItemIndex( talker , i ); + if( ITEM_CHECKINDEX(itemindex) ){ + id=ITEM_getInt(itemindex ,ITEM_ID ); + if(itemno==id){ + cnt++; + + LogItem( + CHAR_getChar( talker, CHAR_NAME ), /* ƽҷ */ + CHAR_getChar( talker, CHAR_CDKEY ), +#ifdef _add_item_log_name // WON ADD itemlogitem + itemindex, +#else + ITEM_getInt( itemindex, ITEM_ID), /* ʧ ة į */ +#endif + "WarpManDelItem(NPCյᴫij)", + CHAR_getInt( talker, CHAR_FLOOR), + CHAR_getInt( talker, CHAR_X ), + CHAR_getInt( talker, CHAR_Y ), + ITEM_getChar( itemindex, ITEM_UNIQUECODE), + ITEM_getChar( itemindex, ITEM_NAME), + ITEM_getInt( itemindex, ITEM_ID) + + ); + + CHAR_DelItem( talker, i); + if(cnt == kosuu){ + break; + } + } + } + } + }else{ + /*--Ϸ įʧ ةë---*/ + for( j = 0 ; j < CHAR_MAXITEMHAVE ; j++){ + itemindex = CHAR_getItemIndex( talker ,j); + + if( ITEM_CHECKINDEX(itemindex) ){ + if( atoi( buff3) == ITEM_getInt(itemindex,ITEM_ID)){ + LogItem( + CHAR_getChar( talker, CHAR_NAME ), /* ƽҷ */ + CHAR_getChar( talker, CHAR_CDKEY ), +#ifdef _add_item_log_name // WON ADD itemlogitem + itemindex, +#else + ITEM_getInt( itemindex, ITEM_ID), /* ʧ ة į */ +#endif + "WarpManDelItem(NPCյᴫij)", + CHAR_getInt( talker,CHAR_FLOOR), + CHAR_getInt( talker,CHAR_X ), + CHAR_getInt( talker,CHAR_Y ), + ITEM_getChar( itemindex, ITEM_UNIQUECODE), + ITEM_getChar( itemindex, ITEM_NAME), + ITEM_getInt( itemindex, ITEM_ID) + ); + CHAR_DelItem( talker, j); + } + } + } + } + } + + return TRUE; +} + +BOOL PetTalk_AddItem(int meindex, int talker, char *buf) +{ + int itemID,k=1,itemindex=-1; + int spaceNum=5,i; + char buff3[256], msgbuf[64], token[256]; + int ret; + + while( getStringFromIndexWithDelim(buf , "," , k, buff3, sizeof(buff3)) !=FALSE ){ + k++; + for( i = spaceNum ; i < CHAR_MAXITEMHAVE ; i++ ){ + itemindex=CHAR_getItemIndex( talker , i ); + if( itemindex == -1 ) { + spaceNum = i+1; + break; + } + } + if( i == CHAR_MAXITEMHAVE ) { + snprintf( msgbuf,sizeof( msgbuf), "ˣƷѾˣ"); + CHAR_talkToCli( talker, meindex, msgbuf, CHAR_COLORWHITE); + return FALSE; + } + } + k=1; + while( getStringFromIndexWithDelim(buf , "," , k, buff3, sizeof(buff3)) !=FALSE ){ + k++; + itemID = atoi( buff3); + if( itemID ) + itemindex = ITEM_makeItemAndRegist( itemID); + if(itemindex == -1) + continue; + ret = CHAR_addItemSpecificItemIndex( talker, itemindex); + if( ret < 0 || ret >= CHAR_MAXITEMHAVE ) { + ITEM_endExistItemsOne( itemindex); + print ("\n ret error!!"); + return FALSE; + } + sprintf( token,"õ%s",ITEM_getChar( itemindex, ITEM_NAME)); + CHAR_talkToCli( talker, -1,token,CHAR_COLORWHITE); + + CHAR_sendItemDataOne( talker, ret); + + } + return TRUE; +} + +BOOL PetTalk_CheckPetEvent( int meindex, int toindex, char *buf) +{ + char buf1[256],buf2[256]; + int k = 0; + + if( NPC_Util_GetStrFromStrWithDelim( buf, "EndSetFlg", buf1,sizeof( buf1) ) != NULL ) { + k=1; + while( getStringFromIndexWithDelim(buf1 , "," ,k, buf2, sizeof(buf2) ) != FALSE ){ + k++; + NPC_EventSetFlg( toindex, atoi( buf2)); + } + } + if( NPC_Util_GetStrFromStrWithDelim( buf, "NowSetFlg", buf1, sizeof( buf1)) != NULL) { + k=1 ; + while(getStringFromIndexWithDelim(buf1 , "," , k, buf2, sizeof(buf2))!= FALSE ){ + k++; + NPC_NowEventSetFlg( toindex, atoi( buf2)); + } + } + return TRUE; +} + +void PetTalk_RequestMain(int meindex,int talker,char *buf) +{ + int shiftbit; + char buf2[128]; + if( NPC_Util_GetStrFromStrWithDelim( buf,"EventNo", buf2,sizeof( buf2) ) == NULL ) { + print("\n pet_event.c err:NOT FIND [EventNo] !!"); + return; + } + shiftbit = atoi( buf2); + if( NPC_NowEventCheckFlg( talker, shiftbit) != TRUE ) { + NPC_NowEventSetFlg( talker, shiftbit); + } +} + +BOOL PetTalk_CheckFree( int meindex, int talker, char *buf) +{ + char buff2[256]; + char buff3[128]; + int i=1,j=1; + int loop=0; + while( getStringFromIndexWithDelim(buf,",",i,buff2,sizeof(buff2)) !=FALSE ) { + i++; + if(strstr(buff2,"&")!=NULL){ + j=1; + loop=0; + while( getStringFromIndexWithDelim(buff2,"&",j,buff3,sizeof(buff3)) !=FALSE ) { + j++; + if(PetTalk_BSCheck(meindex,talker,buff3)==FALSE) { + loop=1; + break; + } + } + if(loop==0) { + CHAR_setWorkInt( talker, CHAR_WORKWARPCHECK, TRUE ); + return TRUE; + } + }else{ + if( PetTalk_BSCheck( meindex, talker, buff2) == TRUE ){ + CHAR_setWorkInt( talker, CHAR_WORKWARPCHECK, TRUE ); + return TRUE; + } + } + } + CHAR_setWorkInt( talker, CHAR_WORKWARPCHECK, FALSE ); + return FALSE; +} + +BOOL PetTalk_BSCheck(int meindex,int talker,char* buf) +{ + char buff2[128]; + int kosuu,temp=-1,flg=0; + char buff1[128],buff3[128]; + if(strstr( buf, "-") != NULL) { + //buff3ΪץID + getStringFromIndexWithDelim( buf, "-", 2, buff3, sizeof(buff3)); + temp = atoi( buff3); + getStringFromIndexWithDelim( buf, "-", 1, buff1, sizeof(buff1)); + strcpy( buf, buff1); + } + if(strstr( buf, "<") != NULL){ + getStringFromIndexWithDelim( buf, "<", 2, buff2, sizeof(buff2)); + kosuu = atoi( buff2); + getStringFromIndexWithDelim( buf, "<", 1, buff2, sizeof(buff2)); + + if(PetTalk_FreeIfCheck( meindex, talker, buff2, kosuu, 1, temp)==TRUE){ + return TRUE; + } + }else if(strstr( buf, ">") != NULL){ + getStringFromIndexWithDelim( buf, ">", 2, buff2, sizeof(buff2)); + kosuu = atoi(buff2); + getStringFromIndexWithDelim( buf, ">" ,1, buff2, sizeof(buff2)); + + if(PetTalk_FreeIfCheck( meindex, talker, buff2, kosuu, 2, temp)==TRUE){ + return TRUE; + } + }else if(strstr( buf, "!" ) != NULL){ + getStringFromIndexWithDelim( buf, "!=", 2, buff2, sizeof(buff2)); + kosuu = atoi( buff2); + getStringFromIndexWithDelim( buf, "!=", 1, buff2, sizeof(buff2)); + if(PetTalk_FreeIfCheck( meindex, talker, buff2, kosuu, 0, temp) == TRUE){ + return FALSE; + }else{ + return TRUE; + } + + }else if(strstr( buf, "=") != NULL){ + getStringFromIndexWithDelim( buf, "=", 2, buff2, sizeof(buff2)); + kosuu = atoi( buff2); + getStringFromIndexWithDelim( buf, "=", 1, buff2, sizeof(buff2)); + + if( strstr( buf, "PET")) { + flg = 3; + } + if(strstr( buf, "*") != NULL){ + if( PetTalk_WarpManReduce( meindex, talker, buf)==TRUE){ + return TRUE; + } + }else if(PetTalk_FreeIfCheck( meindex, talker, buff2, kosuu, flg, temp)==TRUE){ + return TRUE; + } + } + return FALSE; +} + +BOOL PetTalk_FreeIfCheck(int meindex,int talker,char* buf,int kosuu,int flg, int temp) +{ + int Type = -1; + if(strcmp(buf,"LV")==0){ + if(PetTalk_LevelCheck(meindex,talker,kosuu,flg)==TRUE){ + return TRUE; + } + } + + if( strcmp( buf, "TRANS") == 0 ) { + if( PetTalk_CheckTrans( meindex, talker, kosuu, flg) == TRUE ) + return TRUE; + } + if( strcmp( buf, "PET") == 0 ) { + if( temp > 0 ) { + if( PetTalk_CheckMyPet( meindex, talker, kosuu, flg, temp) == TRUE ) + return TRUE; + }else + return FALSE; + } + if(strcmp( buf, "ITEM")==0){ + if(PetTalk_ItemCheck(meindex,talker,kosuu,flg)==TRUE){ + return TRUE; + } + } + if(strcmp( buf, "ENDEV")==0){ + if(NPC_EventCheckFlg( talker, kosuu)==TRUE){ + return TRUE; + } + } + if(strcmp( buf, "NOWEV")==0){ + if(NPC_NowEventCheckFlg( talker, kosuu)==TRUE){ + return TRUE; + } + } + if(strcmp( buf, "HP" ) == 0 ) { + Type = 0; + if( PetTalk_CheckMyType( meindex, talker, kosuu, flg, Type ) == TRUE ) { + return TRUE; + } + } +#ifdef _PET_TALKBBI + if(strcmp( buf, "BBI" ) == 0 ) { + if( PET_CheckPlayerBBI( meindex, talker, kosuu, flg)== TRUE) { + return TRUE; + } + } +#endif + return FALSE; +} +BOOL PetTalk_CheckMyType( int meindex, int toindex, int kosuu, int flg, int Type ) { + int MyType=0,MyMaxType=0; + switch( Type ) { + case 0: //HP + MyType = CHAR_getInt( toindex, CHAR_HP); + MyMaxType = CHAR_getWorkInt( toindex, CHAR_WORKMAXHP); + MyMaxType = (MyMaxType * kosuu )/ 100; + if( PetTalk_BigSmallLastCheck( MyMaxType, MyType , flg ) == TRUE ) { + return TRUE; + } + break; + } + return FALSE; +} + +BOOL PetTalk_WarpManReduce(int meindex,int talker,char *buf) +{ + char buf2[512]; + char buf3[256]; + int id=0; + int i; + int itemindex; + int itemno; + int kosuu; + int cnt=0; + + getStringFromIndexWithDelim(buf,"=",2,buf2,sizeof(buf2)); + getStringFromIndexWithDelim(buf2,"*",1,buf3,sizeof(buf3)); + itemno = atoi(buf3); + getStringFromIndexWithDelim(buf2,"*",2,buf3,sizeof(buf3)); + kosuu = atoi(buf3); + for( i=0 ; i < CHAR_MAXITEMHAVE;i++ ){ + itemindex=CHAR_getItemIndex( talker , i ); + if( ITEM_CHECKINDEX(itemindex) ){ + id=ITEM_getInt(itemindex ,ITEM_ID ); + if(itemno==id){ + cnt++; + if(cnt==kosuu){ + return TRUE; + } + } + } + } + return FALSE; +} + +BOOL PetTalk_LevelCheck(int meindex,int talker,int level,int flg) +{ + int mylevel; + mylevel=CHAR_getInt(talker,CHAR_LV); + if(PetTalk_BigSmallLastCheck(level,mylevel,flg)==TRUE) { + return TRUE; + } + return FALSE; +} + +BOOL PetTalk_CheckTrans(int meindex,int talker,int trans,int flg) +{ + int myTrans; + myTrans=CHAR_getInt(talker, CHAR_TRANSMIGRATION); + if( PetTalk_BigSmallLastCheck( trans, myTrans, flg ) == TRUE ) { + return TRUE; + } + return FALSE; +} + +BOOL PetTalk_CheckMyPet( int meindex, int talker, int petLv, int flg, int petid) +{ + int petsel,petindex=-1; + + for(petsel=0 ; petsel < CHAR_MAXPETHAVE ; petsel++) { + petindex = CHAR_getCharPet( talker, petsel); + if( petindex == -1 ) + continue; + if(CHAR_getInt( petindex, CHAR_PETID) != petid ) + continue; + break; + } + if( petsel == CHAR_MAXPETHAVE ) { + return FALSE; + }else { //ҵ + if( PetTalk_BigSmallLastCheck( petLv, CHAR_getInt( petindex, CHAR_LV), flg ) == TRUE ) + return TRUE; + } + return FALSE; +} + +BOOL PetTalk_ItemCheck(int meindex,int talker,int itemNo,int flg) +{ + int i; + int itemindex=-1; + int id; + for( i=0;i point1) { + return TRUE; + } + } + return FALSE; +} +#else +void PET_Talkfunc( int meindex, int talkerindex, char *msg, int color) +{ + print("\n PET_Talkfunc(...) return; "); + return; +} +#endif + +void PET_CleanFreePetAll() +{ + int objindex; + int objmaxnum = OBJECT_getNum(); + + for( objindex=0; objindex= (petputtime + 60*60) ) { + int ownerindex = CHAR_getWorkInt( petindex, CHAR_WORKPLAYERINDEX); + if( CHAR_CHECKINDEX( ownerindex) ){ + if( CHAR_pickupFollowPet( ownerindex, petindex ) ) { + return; + } + CHAR_talkToCli( ownerindex, -1, "̫ãʧˣ", CHAR_COLORYELLOW ); + } +#ifdef _PET_LOSTPET + CHAR_CharSaveLostPet( petindex, 1); + LogPet( + "ϵͳ", + "Watchfunc", + CHAR_getChar( petindex, CHAR_NAME), + CHAR_getInt( petindex, CHAR_LV), + "timeout_lost(ϵͳ-ɳ)", + CHAR_getInt( petindex, CHAR_FLOOR), + CHAR_getInt( petindex,CHAR_X ), + CHAR_getInt( petindex,CHAR_Y ), + CHAR_getChar( petindex, CHAR_UNIQUECODE) // shan 2001/12/14 + ); + print("ϵͳ-ɳ:%s\n", CHAR_getUseName( petindex)); + CHAR_CharaDelete( petindex); +#else + CHAR_setInt( petindex, CHAR_PUTPETTIME, NowTime.tv_sec); + CHAR_setWorkInt( petindex, CHAR_WORKPETFOLLOWMODE, CHAR_PETFOLLOW_NONE); + LogPet( + CHAR_getChar( pindex, CHAR_NAME ), + CHAR_getChar( pindex, CHAR_CDKEY ), + CHAR_getChar( petindex, CHAR_NAME), + CHAR_getInt( petindex, CHAR_LV), + "timeout_lost(̫ãʧ))", + CHAR_getInt( pindex,CHAR_FLOOR), + CHAR_getInt( pindex,CHAR_X ), + CHAR_getInt( pindex,CHAR_Y ), + CHAR_getChar( petindex, CHAR_UNIQUECODE) // shan 2001/12/14 + + ); +#endif + return; + } + + }else{ + PET_CHECKFreePetIsIt( petindex); + } + if( CHAR_getInt( petindex, CHAR_MAILMODE) == CHAR_PETMAIL_IDLE3 || + CHAR_getInt( petindex, CHAR_MAILMODE) == CHAR_PETMAIL_IDLE2){ + if( act == CHAR_ACTATTACK) { + if( NPC_Util_isFaceToChara( pindex,petindex,1 ) == TRUE ) { + int action[2] = { CHAR_ACTDAMAGE, CHAR_ACTGUARD}; + CHAR_sendWatchEvent( objmeindex, action[RAND(0,1)], NULL,0,FALSE); + CHAR_setWorkInt( petindex, CHAR_WORKACTION, act); + } + } + }else if( CHAR_getInt( petindex, CHAR_MAILMODE) != CHAR_PETMAIL_NONE) { + ; + }else if( CHAR_getWorkInt( petindex, CHAR_WORKFIXAI) >= 100 ) { + int workpindex = CHAR_getWorkInt( petindex, CHAR_WORKPLAYERINDEX); + if( act == CHAR_ACTWALK && CHAR_CHECKINDEX( workpindex) && workpindex == pindex ){ + dir = NPC_Util_GetDirCharToChar( petindex, pindex, 0); + if( dir != -1 ) { + if( CHAR_getInt( petindex, CHAR_DIR) != dir ) { + CHAR_setInt( petindex, CHAR_DIR, dir); + CHAR_sendWatchEvent( CHAR_getWorkInt( petindex, CHAR_WORKOBJINDEX), + CHAR_ACTTURN,NULL,0,TRUE); + } + } + }else if( NPC_Util_isFaceToFace( petindex, pindex, 2 ) == TRUE ) { + switch( act) { + case CHAR_ACTATTACK: + case CHAR_ACTDAMAGE: + case CHAR_ACTDOWN: + case CHAR_ACTSTAND: + case CHAR_ACTACTIONWALK: + case CHAR_ACTGUARD: + case CHAR_ACTACTIONSTAND: + CHAR_sendWatchEvent( objmeindex, act, NULL,0,FALSE); + CHAR_setWorkInt( petindex, CHAR_WORKACTION, act); + break; + default: + break; + } + } + }else { + + } + return; +} + +#ifdef _PET_TALKBBI +BOOL PET_CheckPlayerBBI( int meindex, int charindex, int BBI, int flg) +{ + int MyBBI; + if( !CHAR_CHECKINDEX( charindex)) + return FALSE; + if( BBI < 0 ) + return FALSE; + MyBBI = CHAR_getInt( charindex, CHAR_BASEIMAGENUMBER); + + if(flg==0){ + if(BBI==MyBBI) + return TRUE; + }else if(flg==1){ + if(BBI < MyBBI) + return TRUE; + }else if(flg==2){ + if(BBI > MyBBI) + return TRUE; + } + + return FALSE; +} +#endif diff --git a/char/petmail.c b/char/petmail.c new file mode 100644 index 0000000..fb6a500 --- /dev/null +++ b/char/petmail.c @@ -0,0 +1,1124 @@ +#include "version.h" +#include + +#include "configfile.h" +#include "buf.h" +#include "char_base.h" +#include "char.h" +#include "battle.h" +#include "handletime.h" +#include "map_deal.h" +#include "addressbook.h" +#include "lssproto_serv.h" +#include "pet.h" +#include "petmail.h" +#include "npcutil.h" +#include "log.h" + +#define PETMAIL_BATTLETIMEOUT 660 +#define PETMAIL_IDLETIMEOUT 30 +#define PETMAIL_IDLETIME 10 + +#define PETMAIL_IDLE_RETURNOWNER (60*30) +//andy_edit +//#define PETMAIL_IDLEDISCARD (60*60) //Syu ʵȴʱΪһСʱ +#define PETMAIL_IDLEDISCARD (60*3) + +/* petmail ϵĵȴʱ shan add */ +#define PETMAIL_JS_TIMEOUT (2*60) + +static int PETMAIL_getIdleTime( int index); +static void PETMAIL_sendPetmail( int index, int tocharaindex); +static void PETMAIL_IdleProc1( int index); +static void PETMAIL_IdleProc2( int index); +static void PETMAIL_IdleProc3( int index); +static void PETMAIL_IdleProc4( int index); +static void PETMAIL_IdleProc5( int index); + +static void PETMAIL_ReturnWait( int index); +static void PETMAIL_returnMail( int index, int tocharaindex); +static int PETMAIL_offmsg_max; +#define PETMAILOFFMSGFILE "petmail.txt" + +#define PETMAIL_DEFTOTALNUM 1000 +static int PetMailTotalnums = 0; + +BOOL PETMAIL_sendPetMail( int cindex, int aindex, + int havepetindex, int haveitemindex, char* text , int color ) +{ + char textbuffer[2048]; + struct tm tm1; + Char *ch; + ADDRESSBOOK_entry *ae; + int petindex; + int itemindex =-1; + int tocharaindex,playernum,i; + + //ж Ƭ + if( !CHAR_CHECKINDEX( cindex) )return FALSE; + if( haveitemindex != -1 ) { + itemindex = CHAR_getItemIndex( cindex, haveitemindex); + if( ITEM_CHECKINDEX( itemindex)) { + if( ITEM_getInt( itemindex, ITEM_CANPETMAIL) == 0 ) { + print( "err? crack?\n"); + return FALSE; + } + if(ITEM_getInt( itemindex, ITEM_TIME)>0){ + CHAR_talkToCli( cindex, -1, "ʱ߲ʼġ", CHAR_COLORYELLOW ); + return FALSE; + } + } + } + petindex = CHAR_getCharPet( cindex, havepetindex); + if( petindex == -1 ) return FALSE; + ch = CHAR_getCharPointer( petindex); + if( ch == NULL ) return FALSE; + ae = CHAR_getAddressbookEntry( cindex , aindex ); + if( ae == NULL )return FALSE; + if (CHAR_getWorkInt( cindex, CHAR_WORKSAFEMODE)==0) + { + CHAR_SafePassword(cindex); + return FALSE; + } +#ifdef _AVID_TRADETRYBUG //ʼ + if( CHAR_getWorkInt( cindex, CHAR_WORKTRADEMODE) != CHAR_TRADE_FREE ){ + CHAR_talkToCli( cindex, -1, "״̬޷ݳʼ", CHAR_COLORYELLOW ); + return FALSE; + } +#endif + // + if (CHAR_getInt( cindex, CHAR_RIDEPET) == havepetindex ){ + CHAR_talkToCli(cindex, -1, "еij޷ݳʼ", CHAR_COLORYELLOW); + return FALSE; + } + if( CHAR_getWorkInt( cindex, CHAR_WORKBATTLEMODE) != BATTLE_CHARMODE_NONE){ + CHAR_talkToCli( cindex, -1, "ս״̬޷ݳʼ", CHAR_COLORYELLOW ); + return FALSE; + } + if (CHAR_getInt(petindex, CHAR_PETFAMILY) == 1){ + CHAR_talkToCli(cindex, -1, "ػ޷ʼร", CHAR_COLORYELLOW); + return FALSE; + } +#ifdef _PETMAIL_LV + if(getPetMailCf()==1 && CHAR_getInt(petindex, CHAR_LV)>=getPetMailLv()){ + char bufmsg[256]; + sprintf(bufmsg,"ʼĽ%d³ʼġ",getPetMailLv()); + CHAR_talkToCli(cindex, -1, bufmsg, CHAR_COLORYELLOW); + return FALSE; + } +#endif +// Terry add fix can send mail to offline character 2004/2/5 + if(ae->online == 0){ + CHAR_talkToCli(cindex, -1, "Ҳϣ", CHAR_COLORYELLOW); + return FALSE; + } + playernum = CHAR_getPlayerMaxNum(); + for(i = 0;icdkey) == 0 && + strcmp(CHAR_getChar(i,CHAR_NAME),ae->charname) == 0 ) break; + } + if(i == playernum){ + CHAR_talkToCli(cindex, -1, "Ҳڴϣ", CHAR_COLORYELLOW); + return FALSE; + } +// end +#ifdef _MAP_TIME + if((CHAR_getInt(cindex,CHAR_FLOOR) >= 30017 && CHAR_getInt(cindex,CHAR_FLOOR) <= 30021)){ + char msgbuf[512]; + snprintf(msgbuf,sizeof(msgbuf),"˵ü͵ߣ"); + CHAR_talkToCli(cindex,-1,msgbuf,CHAR_COLORWHITE); + return FALSE; + } + if((CHAR_getInt(i,CHAR_FLOOR) >= 30017 && CHAR_getInt(i,CHAR_FLOOR) <= 30021)){ + char msgbuf[512]; + snprintf(msgbuf,sizeof(msgbuf),"Էڵռ͵ߣ"); + CHAR_talkToCli(cindex,-1,msgbuf,CHAR_COLORWHITE); + return FALSE; + } +#endif + + // Syu Add 2003/05/30 + if( ( CHAR_getInt(cindex,CHAR_FLOOR) >= 8200 && CHAR_getInt(cindex,CHAR_FLOOR) <= 8213 ) ) + { + char msgbuf[512]; + snprintf( msgbuf, sizeof( msgbuf), "Ӣսü͵ߣ"); + CHAR_talkToCli( cindex, -1, msgbuf, CHAR_COLORWHITE); + return FALSE; + } + +#ifdef _PET_LIMITLEVEL + if( CHAR_getInt( petindex, CHAR_LIMITLEVEL) > 0 ) { + CHAR_talkToCli(cindex, -1, "ﲻܴʼร", CHAR_COLORYELLOW); + return FALSE; + } +#endif +//DZ޶IJʼĵĵôԼ +#ifdef _PETITEM__AMOI_E + if(ITEM_NOT_MAIL & ITEM_getInt(itemindex, ITEM_TYPEOFITEM)){ + char buf[256]; + sprintf( buf, "%sDzʼĵŶ!~", ITEM_getChar( itemindex, ITEM_NAME) ); + CHAR_talkToCli( cindex, -1, buf, CHAR_COLORRED); + return FALSE; + } +#endif +#ifdef _PETMAIL_DEFNUMS + if( CHAR_getWorkInt( cindex, CHAR_PETMAILNUMS) > 6 ){ + CHAR_talkToCli(cindex, -1, "ʼг࣬ʱ޷ݳʼ", CHAR_COLORYELLOW); + return FALSE; + }else if( PETMAIL_CheckIsMyOffmsg( cindex, ae->cdkey, ae->charname) > 10 ){ + CHAR_talkToCli(cindex, -1, "ռĿǰʼﳬ10⣬ʱ޷ݳʼ", CHAR_COLORYELLOW); + return FALSE; + }else if( CHAR_getWorkInt( cindex, CHAR_PETMAILSENDTIME) > (int)time( NULL)){ + char Mess1[256]; + sprintf( Mess1,"ȴ%dٴμͳʼ", + (int)time( NULL) - CHAR_getWorkInt( cindex, CHAR_PETMAILSENDTIME)); + CHAR_talkToCli( cindex, -1, Mess1, CHAR_COLORYELLOW); + return FALSE; + }else if( PetMailTotalnums >= PETMAIL_DEFTOTALNUM ){ + CHAR_talkToCli(cindex, -1, "Ŀǰϵͳʼ࣬ټġ", CHAR_COLORYELLOW); + return FALSE; + }else{ + int nums = CHAR_getWorkInt( cindex, CHAR_PETMAILNUMS); + nums ++; + CHAR_setWorkInt( cindex, CHAR_PETMAILNUMS, nums); + CHAR_setWorkInt( cindex, CHAR_PETMAILSENDTIME, (int)time( NULL)+6); + PetMailTotalnums ++; + } +#endif +#ifdef _AVOIDATTACK_IN_PETMAIL_sendPetMail_textToLong + if( strlen(text) > 256 ) + return FALSE; +#endif + memcpy( &tm1, localtime( (time_t *)&NowTime.tv_sec), sizeof( tm1)); + snprintf( textbuffer, sizeof( textbuffer), + "%2d/%02d %2d:%02d|%s", tm1.tm_mon +1, tm1.tm_mday, tm1.tm_hour, tm1.tm_min, text); + { + int offmsgindex; + offmsgindex = PETMAIL_addOffmsg( cindex, ae->cdkey, ae->charname, text, color); + if( offmsgindex == -1 ) { + print( "offmsg buffer over\n"); + return FALSE; + } + +#ifdef _FIX_PETMAIL2 // WON ADD 2 + if( !PET_dropPetFLXY( cindex, havepetindex, PETMAIL_SPOOLFLOOR, PETMAIL_SPOOLX,PETMAIL_SPOOLY) ){ + CHAR_talkToCli( cindex, -1, "ʼʧ", CHAR_COLORYELLOW); + return FALSE; + } +#endif + CHAR_setInt( petindex, CHAR_FLOOR, CHAR_getInt( cindex, CHAR_FLOOR)); + CHAR_setInt( petindex, CHAR_X, CHAR_getInt( cindex, CHAR_X)); + CHAR_setInt( petindex, CHAR_Y, CHAR_getInt( cindex, CHAR_Y)); + CHAR_sendPMEToArroundCharacter( cindex, petindex, 0, CHAR_getInt( petindex, CHAR_PETMAILEFFECT)); + CHAR_setInt( petindex, CHAR_MAILMODE,CHAR_PETMAIL_IDLE2); + CHAR_setInt( petindex, CHAR_LOOPINTERVAL, PETMAIL_LOOPINTERVAL2); + strcpysafe( ch->charfunctable[CHAR_LOOPFUNC].string, + sizeof( ch->charfunctable[CHAR_LOOPFUNC]), "PETMAIL_Loop"); + CHAR_constructFunctable( petindex); + CHAR_setInt( petindex, CHAR_PETMAILBUFINDEX, offmsgindex); + CHAR_setInt( petindex, CHAR_PETMAILIDLETIME, NowTime.tv_sec); + CHAR_setInt( petindex, CHAR_PETMAILFROMFLOOR, CHAR_getInt( cindex, CHAR_FLOOR)); + CHAR_setInt( petindex, CHAR_PETMAILFROMX, CHAR_getInt( cindex, CHAR_X)); + CHAR_setInt( petindex, CHAR_PETMAILFROMY,CHAR_getInt( cindex, CHAR_Y)); + +//#ifdef _WON_PET_MAIL_LOG // WON ADD Ӽijʵ LOG +// LogPet( +// CHAR_getChar( cindex, CHAR_NAME ), +// CHAR_getChar( cindex, CHAR_CDKEY ), +// CHAR_getChar( petindex, CHAR_NAME), +// CHAR_getInt( petindex, CHAR_LV), +// "Pet_Send_Mail(ij)", +// CHAR_getInt( cindex,CHAR_FLOOR), +// CHAR_getInt( cindex,CHAR_X ), +// CHAR_getInt( cindex,CHAR_Y ), +// CHAR_getChar( petindex, CHAR_UNIQUECODE) +// ); +//#endif + if( haveitemindex != -1 ) { + CHAR_setItemIndex( cindex, haveitemindex, -1); + CHAR_setItemIndex( petindex, CHAR_STARTITEMARRAY, itemindex); + CHAR_sendItemDataOne( cindex, haveitemindex); + LogItem( + CHAR_getChar( cindex, CHAR_NAME ), + CHAR_getChar( cindex, CHAR_CDKEY ), + itemindex, + "pm_have(->͵ĵ)", + CHAR_getInt( cindex,CHAR_FLOOR), + CHAR_getInt( cindex,CHAR_X ), + CHAR_getInt( cindex,CHAR_Y ), + ITEM_getChar( itemindex, ITEM_UNIQUECODE), + ITEM_getChar( itemindex, ITEM_NAME), + ITEM_getInt( itemindex, ITEM_ID) + + ); + } + { + char token[256]; + tocharaindex = PETMAIL_CheckPlayerExist( petindex, 0); + sprintf( token, "ͳʼ(%s)%s", + CHAR_getUseName( petindex), CHAR_getUseName( tocharaindex) ); + CHAR_talkToCli( cindex, -1, token, CHAR_COLORYELLOW); + } + return TRUE; + } + return FALSE; +} + +static PETMAIL_offmsg * PETMAIL_offmsgbuf; +BOOL PETMAIL_initOffmsgBuffer( int count ) +{ + int size = sizeof( PETMAIL_offmsg )*count ; + FILE *fp; + char filename[256]; + char line[2048]; + int linenum = 0; + + PETMAIL_offmsgbuf = (PETMAIL_offmsg*)allocateMemory( size ); + + if( PETMAIL_offmsgbuf == NULL ) return FALSE; + + PetMailTotalnums = 0; + + memset( PETMAIL_offmsgbuf, 0,size ); + + PETMAIL_offmsg_max = count; + snprintf( filename ,sizeof( filename ) ,"%s/%s", getStoredir(), PETMAILOFFMSGFILE); + fp = fopen( filename , "rt" ); + if( fp == NULL ) return TRUE; + + while( fgets( line, sizeof( line ), fp ) != NULL ){ + char buf[1024]; + int index; + if( !getStringFromIndexWithDelim( line, "|", 1, buf, sizeof( buf))) { + print( "read error line[%d]\n", linenum); + continue; + } + index = atoi( buf); + if( index >= PETMAIL_offmsg_max ) { + print( "index over offmsg_max [%d]\n", index); + continue; + } + if( PETMAIL_offmsgbuf[index].use == TRUE) { + print( "offmsg already use index[%d]\n", index); + continue; + } + + if( !getStringFromIndexWithDelim( line, "|", 2, buf, sizeof( buf))) { + print( "read error line[%d]\n", linenum); + continue; + } + PETMAIL_offmsgbuf[index].send_tm = atoi( buf); + + if( !getStringFromIndexWithDelim( line, "|", 3, buf, sizeof( buf))) { + print( "read error line[%d]\n", linenum); + continue; + } + PETMAIL_offmsgbuf[index].color = atoi( buf); + + if( !getStringFromIndexWithDelim( line, "|", 4, buf, sizeof( buf))) { + print( "read error line[%d]\n", linenum); + continue; + } + strcpysafe( PETMAIL_offmsgbuf[index].text, + sizeof( PETMAIL_offmsgbuf[index].text), + buf); + + if( !getStringFromIndexWithDelim( line, "|", 5, buf, sizeof( buf))) { + print( "read error line[%d]\n", linenum); + continue; + } + strcpysafe( PETMAIL_offmsgbuf[index].destcd, + sizeof( PETMAIL_offmsgbuf[index].destcd), + buf); + + if( !getStringFromIndexWithDelim( line, "|", 6, buf, sizeof( buf))) { + print( "read error line[%d]\n", linenum); + continue; + } + makeStringFromEscaped(buf); + strcpysafe( PETMAIL_offmsgbuf[index].destcharname, + sizeof( PETMAIL_offmsgbuf[index].destcharname), + buf); + if( !getStringFromIndexWithDelim( line, "|", 7, buf, sizeof( buf))) { + print( "read error line[%d]\n", linenum); + continue; + } + strcpysafe( PETMAIL_offmsgbuf[index].srccd, + sizeof( PETMAIL_offmsgbuf[index].srccd), + buf); + if( !getStringFromIndexWithDelim( line, "|", 8, buf, sizeof( buf))) { + print( "read error line[%d]\n", linenum); + continue; + } + makeStringFromEscaped(buf); + strcpysafe( PETMAIL_offmsgbuf[index].srccharname, + sizeof( PETMAIL_offmsgbuf[index].srccharname), + buf); + linenum ++; + } + fclose( fp); + return TRUE; + +} + +BOOL PETMAIL_addOffmsg( int fromindex, char *tocdkey, char *tocharaname, + char *text , int color ) +{ + + int i; + + for( i = 0 ; i < PETMAIL_offmsg_max; i++ ) { + if( PETMAIL_offmsgbuf[i].use == 0 ) { + PETMAIL_offmsg *om = & PETMAIL_offmsgbuf[i]; + om->use = 1; + time( & om->send_tm ); + + strcpysafe( om->srccd , sizeof( om->srccd ), + CHAR_getChar( fromindex, CHAR_CDKEY)); + strcpysafe( om->srccharname , sizeof( om->srccharname ), + CHAR_getChar( fromindex, CHAR_NAME)); + strcpysafe( om->destcd , sizeof( om->destcd ), tocdkey ); + strcpysafe( om->destcharname , sizeof(om->destcharname), tocharaname); + strcpysafe( om->text , sizeof(om->text), text ); + om->color = color; + return i; + } + } + return -1; +} + +PETMAIL_offmsg *PETMAIL_getOffmsg( int offmsgindex) +{ + if( offmsgindex < 0 || offmsgindex >= PETMAIL_offmsg_max ) return NULL; + return &PETMAIL_offmsgbuf[offmsgindex]; +} + +BOOL PETMAIL_deleteOffmsg( int offmsgindex) +{ + if( offmsgindex < 0 || offmsgindex >= PETMAIL_offmsg_max ) return FALSE; + PETMAIL_offmsgbuf[offmsgindex].use = FALSE; + return TRUE; +} + +void PETMAIL_proc( void ) +{ + int i; + static time_t PETMAIL_check_time_store = 0; + time_t t; + time( &t ); + if( t < PETMAIL_check_time_store) return; + PETMAIL_check_time_store = t + PETMAIL_CHECK_OFFMSG_EXPIRE_INTERVAL; + for(i = 0; i < PETMAIL_offmsg_max ; i++){ + if( PETMAIL_offmsgbuf[i].use && PETMAIL_offmsgbuf[i].send_tm < ( t - PETMAIL_OFFMSG_TIMEOUT )){ + PETMAIL_offmsgbuf[i].use = FALSE; + } + } +} + +BOOL storePetmail( void) +{ + FILE *fp; + char filename[256]; + char escapebuf1[ 64],escapebuf2[ 64]; + int i; + + /* ̻ ëƻ */ + snprintf( filename ,sizeof( filename ) ,"%s/%s" , + getStoredir(), PETMAILOFFMSGFILE); + fp = fopen( filename , "wt" ); + if( fp == NULL ) return FALSE; + for(i = 0; i < PETMAIL_offmsg_max ; i++){ + if( PETMAIL_offmsgbuf[i].use ){ + fprintf( fp, "%d|%ud|%d|%s|%s|%s|%s|%s|", + i, (unsigned int)PETMAIL_offmsgbuf[i].send_tm, + PETMAIL_offmsgbuf[i].color, + PETMAIL_offmsgbuf[i].text, + PETMAIL_offmsgbuf[i].destcd, + makeEscapeString( PETMAIL_offmsgbuf[i].destcharname, + escapebuf1, sizeof( escapebuf1)), + PETMAIL_offmsgbuf[i].srccd, + makeEscapeString( PETMAIL_offmsgbuf[i].srccharname, + escapebuf2, sizeof( escapebuf2))); + } + } + fclose( fp); + return TRUE; +} + +BOOL PETMAIL_CheckPlayerExist( int index, int mode) +{ + int i; + char *searchcd = NULL; + char *searchname = NULL; + PETMAIL_offmsg *adof; + int playernum = CHAR_getPlayerMaxNum(); + + if( mode == 0 ) { + adof = PETMAIL_getOffmsg( CHAR_getInt( index, CHAR_PETMAILBUFINDEX)); + if( adof == NULL ) return FALSE; + searchcd = adof->destcd; + searchname = adof->destcharname; + } + else if( mode == 1 ) { + searchcd = CHAR_getChar( index, CHAR_OWNERCDKEY); + searchname = CHAR_getChar( index, CHAR_OWNERCHARANAME); + if( searchcd == "\0" || searchname == "\0" ) return FALSE; + } + for( i = 0 ; i < playernum ; i ++) { + if( CHAR_CHECKINDEX( i) && + strcmp( CHAR_getChar( i, CHAR_CDKEY), searchcd ) == 0 && + strcmp( CHAR_getChar( i, CHAR_NAME), searchname) == 0 ) { + return i; + } + } + return -1; +} + +void PETMAIL_Loopfunc( int index) +{ + int mode = CHAR_getInt( index, CHAR_MAILMODE); + switch( mode ){ + case CHAR_PETMAIL_IDLE1: + PETMAIL_IdleProc1( index); + break; + case CHAR_PETMAIL_IDLE2: + PETMAIL_IdleProc2( index); + break; + case CHAR_PETMAIL_RETURNWAIT://ȴ + PETMAIL_ReturnWait( index); + break; + case CHAR_PETMAIL_IDLE3: + PETMAIL_IdleProc3( index); + break; + case CHAR_PETMAIL_IDLE4://Ѱ + PETMAIL_IdleProc4( index); + break; + case CHAR_PETMAIL_IDLE5: //ʱ޷ҵ + PETMAIL_IdleProc5( index); + break; + default: + break; + } +} + +static int PETMAIL_getIdleTime( int index) +{ +#define PETMAIL_DIVRANGE 25 // +#define PETMAIL_IDLELEVELRANGE 10 // +#define PETMAIL_IDLEUNITTIME 3 // + int d; +#ifdef _PETMAIL_TIME + int dex; + if(getPetMailTime()>0) + dex = getPetMailTime(); + else + dex = CHAR_getWorkInt( index, CHAR_WORKQUICK); +#else + int dex = CHAR_getWorkInt( index, CHAR_WORKQUICK) ; +#endif + + d = dex / PETMAIL_DIVRANGE; + if( d < 0 ) d = 0; + if( d > PETMAIL_IDLELEVELRANGE ) d = PETMAIL_IDLELEVELRANGE; + d = PETMAIL_IDLELEVELRANGE - d ; + + return d * PETMAIL_IDLEUNITTIME; + +#undef PETMAIL_DIVRANGE +#undef PETMAIL_IDLELEVELRANGE +#undef PETMAIL_IDLEUNITTIME +} + +static void PETMAIL_sendPetmail( int index, int tocharaindex) +{ + int index_to_my_info; + int itemindex,ret; + index_to_my_info = ADDRESSBOOK_getIndexInAddressbook( tocharaindex, + CHAR_getChar( index, CHAR_OWNERCDKEY), + CHAR_getChar( index, CHAR_OWNERCHARANAME)); + + if( index_to_my_info < 0 ) { + char msgbuf[512]; + + snprintf( msgbuf, sizeof( msgbuf), + "%s%s ˣ" + "춶ԷûƬż˻ˡ", + CHAR_getChar( index, CHAR_OWNERCHARANAME), + CHAR_getUseName( index)); + CHAR_talkToCli( tocharaindex, -1, msgbuf, CHAR_COLORWHITE); + } + //Syu Add 06/16 + else if( CHAR_getInt(tocharaindex,CHAR_FLOOR) >=8200 && + CHAR_getInt(tocharaindex,CHAR_FLOOR) <= 8213 ){ + char msgbuf[512]; + snprintf( msgbuf, sizeof( msgbuf), + "Ӣսü͵ߣ" ); + CHAR_talkToCli( tocharaindex, -1, msgbuf, CHAR_COLORWHITE); + } + else { + struct tm tm1; + char textbuffer[2048]; + char escapebuf[128]; + int fd; + PETMAIL_offmsg *offmsg; + itemindex = CHAR_getItemIndex( index, CHAR_STARTITEMARRAY); + ret = CHAR_addItemSpecificItemIndex( tocharaindex, itemindex); + if( ret < 0 || ret >= CHAR_MAXITEMHAVE){ + CHAR_DropItem( index, CHAR_STARTITEMARRAY); + LogItem( + CHAR_getChar( tocharaindex, CHAR_NAME ), + CHAR_getChar( tocharaindex, CHAR_CDKEY ), + itemindex, + "pm_putground(->õ)", + CHAR_getInt( index,CHAR_FLOOR), + CHAR_getInt( index,CHAR_X ), + CHAR_getInt( index,CHAR_Y ), + ITEM_getChar( itemindex, ITEM_UNIQUECODE), + ITEM_getChar( itemindex, ITEM_NAME), + ITEM_getInt( itemindex, ITEM_ID) + + ); + } + else { + CHAR_setItemIndex( index, CHAR_STARTITEMARRAY, -1); + CHAR_sendItemDataOne( tocharaindex, ret); + LogItem( + CHAR_getChar( tocharaindex, CHAR_NAME ), + CHAR_getChar( tocharaindex, CHAR_CDKEY ), + itemindex, + "pm_getitem(->յĵ)", + CHAR_getInt( index,CHAR_FLOOR), + CHAR_getInt( index,CHAR_X ), + CHAR_getInt( index,CHAR_Y ), + ITEM_getChar( itemindex, ITEM_UNIQUECODE), + ITEM_getChar( itemindex, ITEM_NAME), + ITEM_getInt( itemindex, ITEM_ID) + ); + } + offmsg = PETMAIL_getOffmsg( + CHAR_getInt( index, CHAR_PETMAILBUFINDEX)); + memcpy( &tm1, localtime( (time_t *)&NowTime.tv_sec), + sizeof( tm1)); + snprintf( textbuffer, sizeof( textbuffer), + "%2d/%02d %2d:%02d|%s|%d|%d|%s|%d", + tm1.tm_mon +1, tm1.tm_mday, tm1.tm_hour, tm1.tm_min, + offmsg->text, + CHAR_getInt( index, CHAR_BASEIMAGENUMBER), + CHAR_getInt( index, CHAR_LV), + makeEscapeString( CHAR_getUseName( index), escapebuf, + sizeof( escapebuf)), + ITEM_getInt( itemindex, ITEM_BASEIMAGENUMBER) + ); + fd = getfdFromCharaIndex( tocharaindex); + if( fd != -1 ) lssproto_MSG_send( fd , index_to_my_info , + textbuffer , offmsg->color ); + PETMAIL_deleteOffmsg( CHAR_getInt( index, CHAR_PETMAILBUFINDEX)); + CHAR_setInt( index, CHAR_PETMAILBUFINDEX, -1); + CHAR_setInt( index, CHAR_PETSENDMAILCOUNT, + CHAR_getInt( index, CHAR_PETSENDMAILCOUNT) +1); + { + char *cdkey = CHAR_getChar( index, CHAR_CDKEY); + if( cdkey) printl( LOG_TALK, "CDKEY=%s\tTEXT=%s" , cdkey, offmsg->text ); + else printl( LOG_TALK, "CDKEY=(null)\tTEXT=%s" , offmsg->text ); + } + } +} + +static void PETMAIL_IdleProc1( int index) +{ + + int tocharaindex; + int warp = FALSE; + + tocharaindex = PETMAIL_CheckPlayerExist( index, 0); + if( !CHAR_CHECKINDEX( tocharaindex) ) { + warp = TRUE; + }else { + if( CHAR_getInt( tocharaindex, CHAR_FLOOR) == 8215 ){//ͷ andy + warp = TRUE; + }else if( CHAR_getWorkInt( tocharaindex, CHAR_WORKTRADEMODE) != CHAR_TRADE_FREE ){//вʼ + warp = TRUE; + }else if( CHAR_getWorkInt( tocharaindex, CHAR_WORKBATTLEMODE) != BATTLE_CHARMODE_NONE ){ + int battleindex = CHAR_getWorkInt( tocharaindex, CHAR_WORKBATTLEINDEX ); + if( !BATTLE_CHECKINDEX( battleindex ) || BattleArray[battleindex].flgTime > 60 ){ + warp = TRUE; + } + }else { + int ret; + int distance; + distance = NPC_Util_CharDistance( tocharaindex, index); + if( distance > CHAR_DEFAULTSEESIZ /2 ) { + warp = TRUE; + }else if( distance > 1 ){ + int dir = NPC_Util_GetDirCharToChar( index, tocharaindex, 0); + if( dir != -1 ) { + dir = NPC_Util_SuberiWalk( index, dir); + } + if( dir != -1 ) { + ret = CHAR_walk( index, dir, 0); + if( ret != CHAR_WALKSUCCESSED) { + dir = -1; + } + } + if( dir == -1 ) { + warp = TRUE; + } + }else { + PETMAIL_sendPetmail( index, tocharaindex); + CHAR_setInt( index, CHAR_MAILMODE,CHAR_PETMAIL_RETURNWAIT); + CHAR_setInt( index, CHAR_PETMAILIDLETIME, NowTime.tv_sec); + CHAR_setInt( index, CHAR_LOOPINTERVAL, PETMAIL_LOOPINTERVAL2); + } + } + } + if( warp) { + if( CHAR_getInt( index, CHAR_FLOOR) != PETMAIL_SPOOLFLOOR) { + CHAR_warpToSpecificPoint( index, + PETMAIL_SPOOLFLOOR, + PETMAIL_SPOOLX,PETMAIL_SPOOLX); + CHAR_setInt( index, CHAR_MAILMODE,CHAR_PETMAIL_IDLE2); + CHAR_setInt( index, CHAR_PETMAILIDLETIME, NowTime.tv_sec); + CHAR_setInt( index, CHAR_LOOPINTERVAL, PETMAIL_LOOPINTERVAL2); + } + } +} + +static void PETMAIL_IdleProc2( int index) +{ + unsigned int t = CHAR_getInt( index, CHAR_PETMAILIDLETIME); + if( NowTime.tv_sec > t + PETMAIL_getIdleTime( index)) { + int tocharaindex; + int cnt; + tocharaindex = PETMAIL_CheckPlayerExist( index, 0); + if( tocharaindex != -1 ) { + if( CHAR_getInt( tocharaindex, CHAR_FLOOR) == 8215 ){//ͷ andy + }else if( CHAR_getWorkInt( tocharaindex, CHAR_WORKTRADEMODE) != CHAR_TRADE_FREE ){//вʼ + }else if( CHAR_getWorkInt( tocharaindex, CHAR_WORKBATTLEMODE) != BATTLE_CHARMODE_NONE){ + }else { + int fl, x, y, ch_x, ch_y; + fl = CHAR_getInt( tocharaindex, CHAR_FLOOR); + ch_x = CHAR_getInt( tocharaindex, CHAR_X); + ch_y = CHAR_getInt( tocharaindex, CHAR_Y); + for( cnt = 0; cnt < 10; cnt ++ ) { + x = RAND( ch_x -1, ch_x + 1); + y = RAND( ch_y -1, ch_y + 1); + if( MAP_walkAble( tocharaindex, fl,x,y)) { + break; + } + } + if( cnt == 10 ) { + x = ch_x; y = ch_y; + } + CHAR_setInt( index, CHAR_MAILMODE,CHAR_PETMAIL_RETURNWAIT); + CHAR_setInt( index, CHAR_PETMAILIDLETIME, NowTime.tv_sec); + CHAR_warpToSpecificPoint( index,fl, x,y); + PETMAIL_sendPetmail( index, tocharaindex); + return; + } + }else{ + if( NowTime.tv_sec > t + PETMAIL_IDLETIMEOUT ) { + PETMAIL_deleteOffmsg( CHAR_getInt( index, CHAR_PETMAILBUFINDEX)); + CHAR_setInt( index, CHAR_MAILMODE, CHAR_PETMAIL_IDLE3); + CHAR_setInt( index, CHAR_PETMAILIDLETIME, NowTime.tv_sec); + CHAR_setInt( index, CHAR_LOOPINTERVAL, PETMAIL_LOOPINTERVAL1); + } + return; + } + if( NowTime.tv_sec > t + PETMAIL_BATTLETIMEOUT ) { + PETMAIL_deleteOffmsg( CHAR_getInt( index, CHAR_PETMAILBUFINDEX)); + CHAR_setInt( index, CHAR_MAILMODE, CHAR_PETMAIL_IDLE3); + CHAR_setInt( index, CHAR_PETMAILIDLETIME, NowTime.tv_sec); + CHAR_setInt( index, CHAR_LOOPINTERVAL, PETMAIL_LOOPINTERVAL1); + } + } +} + +static void PETMAIL_ReturnWait( int index) +{ + unsigned int t = CHAR_getInt( index, CHAR_PETMAILIDLETIME); + if( NowTime.tv_sec > t + PETMAIL_IDLETIME) { + CHAR_setInt( index, CHAR_MAILMODE, CHAR_PETMAIL_IDLE3); + CHAR_setInt( index, CHAR_PETMAILIDLETIME, NowTime.tv_sec); + CHAR_setInt( index, CHAR_LOOPINTERVAL, PETMAIL_LOOPINTERVAL1); + } +} + +static void PETMAIL_IdleProc3( int index) +{ + + int tocharaindex; + int warp = FALSE; + + tocharaindex = PETMAIL_CheckPlayerExist( index, 1); + if( tocharaindex == -1 ) { + warp = TRUE; + }else { + if( CHAR_getWorkInt( tocharaindex, CHAR_WORKBATTLEMODE) == BATTLE_CHARMODE_NONE) { + int ret ; + int distance; + distance = NPC_Util_CharDistance( tocharaindex, index); + if( distance > CHAR_DEFAULTSEESIZ /2 ) { + warp = TRUE; + + }else if( distance > 1 ){ + int dir = NPC_Util_GetDirCharToChar( index, tocharaindex, 0); + if( dir != -1 ) { + dir = NPC_Util_SuberiWalk( index, dir); + } + if( dir != -1 ) { + ret = CHAR_walk( index, dir, 0); + if( ret != CHAR_WALKSUCCESSED) { + dir = -1; + } + } + if( dir == -1 ) { + warp = TRUE; + } + }else { + //andy_reEdit 2003/05/30 + warp = TRUE; +/* CHAR_setInt( index, CHAR_MAILMODE,CHAR_PETMAIL_IDLE5); + CHAR_setInt( index, CHAR_PETMAILIDLETIME, NowTime.tv_sec); + CHAR_setInt( index, CHAR_LOOPINTERVAL, PETMAIL_LOOPINTERVAL2); + PETMAIL_returnMail( index, tocharaindex); +*/ + } + } + } + if( warp) { + CHAR_warpToSpecificPoint( index, + PETMAIL_SPOOLFLOOR, + PETMAIL_SPOOLX,PETMAIL_SPOOLX); + CHAR_setInt( index, CHAR_MAILMODE,CHAR_PETMAIL_IDLE4); + CHAR_setInt( index, CHAR_PETMAILIDLETIME, NowTime.tv_sec); + CHAR_setInt( index, CHAR_LOOPINTERVAL, PETMAIL_LOOPINTERVAL2); + } +} +static void PETMAIL_IdleProc4( int index) +{ + unsigned int t = CHAR_getInt( index, CHAR_PETMAILIDLETIME); + { + int tocharaindex; + int cnt; + tocharaindex = PETMAIL_CheckPlayerExist( index, 1);//Ѱ + if( tocharaindex != -1 ) { + if( CHAR_getWorkInt( tocharaindex, CHAR_WORKBATTLEMODE) == BATTLE_CHARMODE_NONE && + CHAR_getWorkInt( tocharaindex, CHAR_WORKTRADEMODE) == CHAR_TRADE_FREE ){ + + int fl, x, y, ch_x, ch_y;//ص + + fl = CHAR_getInt( tocharaindex, CHAR_FLOOR); + ch_x = CHAR_getInt( tocharaindex, CHAR_X); + ch_y = CHAR_getInt( tocharaindex, CHAR_Y); + for( cnt = 0; cnt < 10; cnt ++ ) { + x = RAND( ch_x -1, ch_x + 1); + y = RAND( ch_y -1, ch_y + 1); + if( MAP_walkAble( index, fl,x,y)) { + break; + } + } + if( cnt == 10 ) { + x = ch_x; y = ch_y; + } + CHAR_setInt( index, CHAR_MAILMODE,CHAR_PETMAIL_IDLE5); + CHAR_setInt( index, CHAR_PETMAILIDLETIME, NowTime.tv_sec); + CHAR_warpToSpecificPoint( index,fl, x,y); + PETMAIL_returnMail( index, tocharaindex); + } + }else { + if( NowTime.tv_sec > t + PETMAIL_IDLE_RETURNOWNER ) {//ȴʱ + int itemindex; + CHAR_warpToSpecificPoint( index, //صԭ + CHAR_getInt( index, CHAR_PETMAILFROMFLOOR), + CHAR_getInt( index, CHAR_PETMAILFROMX), + CHAR_getInt( index, CHAR_PETMAILFROMY)); + + CHAR_setInt( index, CHAR_MAILMODE, CHAR_PETMAIL_IDLE5);//ı״̬ + CHAR_setInt( index, CHAR_LOOPINTERVAL, PETMAIL_LOOPINTERVAL2); + CHAR_setInt( index, CHAR_PETMAILIDLETIME, NowTime.tv_sec); + if( CHAR_getInt( index, CHAR_PETMAILIDLETIME) != -1 ) { + PETMAIL_deleteOffmsg( CHAR_getInt( index, CHAR_PETMAILBUFINDEX)); + } + itemindex = CHAR_getItemIndex( index, CHAR_STARTITEMARRAY);//ɾ + if( ITEM_CHECKINDEX( itemindex ) ) { + CHAR_DropItem( index, CHAR_STARTITEMARRAY); + + LogItem( + CHAR_getChar( index, CHAR_OWNERCHARANAME ), + CHAR_getChar( index, CHAR_OWNERCDKEY ), + itemindex, + "pm_returntimeout(->ʱɾ)", + CHAR_getInt( index,CHAR_FLOOR), + CHAR_getInt( index,CHAR_X ), + CHAR_getInt( index,CHAR_Y ), + ITEM_getChar( itemindex, ITEM_UNIQUECODE), + ITEM_getChar( itemindex, ITEM_NAME), + ITEM_getInt( itemindex, ITEM_ID) + ); + } + } + } + } + +} + +static void PETMAIL_IdleProc5( int index) +{ + unsigned int t = CHAR_getInt( index, CHAR_PETMAILIDLETIME); + if( NowTime.tv_sec > t + PETMAIL_IDLEDISCARD) { + Char *ch; + CHAR_setInt( index, CHAR_MAILMODE, CHAR_PETMAIL_NONE); + CHAR_setInt( index, CHAR_PETMAILIDLETIME, 0); + +#ifdef _FIX_PETMAIL // WON ADD + CHAR_setInt( index, CHAR_PUTPETTIME, NowTime.tv_sec ); +#endif +#ifdef _PETMAIL_DEFNUMS + PETMAIL_delPetMailTotalnums( 1); //M PET ɳ + if( PetMailTotalnums < 0 ) PetMailTotalnums = 0; +#endif + ch = CHAR_getCharPointer( index); + if( ch != NULL ) { + strcpysafe( ch->charfunctable[CHAR_LOOPFUNC].string, + sizeof( ch->charfunctable[CHAR_LOOPFUNC]), "" ); + CHAR_constructFunctable( index); + } +#ifdef _PET_LOSTPET + CHAR_CharSaveLostPet( index, 2); + LogPet( + "ϵͳ", + "Watchfunc", + CHAR_getChar( index, CHAR_NAME), + CHAR_getInt( index, CHAR_LV), + "timeout_lost(ϵͳ-ɳ)", + CHAR_getInt( index, CHAR_FLOOR), + CHAR_getInt( index,CHAR_X ), + CHAR_getInt( index,CHAR_Y ), + CHAR_getChar( index, CHAR_UNIQUECODE) // shan 2001/12/14 + ); + print("ϵͳ-ɳ:%s\n", CHAR_getUseName( index)); + CHAR_CharaDelete( index); +#else + LogPet( + CHAR_getChar( index, CHAR_OWNERCHARANAME ), + CHAR_getChar( index, CHAR_OWNERCDKEY ), + CHAR_getChar( index, CHAR_NAME), + CHAR_getInt( index, CHAR_LV), + "FreePet(ʱɳ)", + CHAR_getInt( index,CHAR_FLOOR), + CHAR_getInt( index,CHAR_X ), + CHAR_getInt( index,CHAR_Y ), + CHAR_getChar( index, CHAR_UNIQUECODE) + ); +#endif + + }else { + int tocharaindex = PETMAIL_CheckPlayerExist( index, 1); + if( tocharaindex != -1 ) { + if( NPC_Util_CharDistance( tocharaindex, index ) > CHAR_DEFAULTSEESIZ/2) { + int fl, x, y, ch_x, ch_y; + int cnt; + fl = CHAR_getInt( tocharaindex, CHAR_FLOOR); + ch_x = CHAR_getInt( tocharaindex, CHAR_X); + ch_y = CHAR_getInt( tocharaindex, CHAR_Y); + for( cnt = 0; cnt < 10; cnt ++ ) { + x = RAND( ch_x -1, ch_x + 1); + y = RAND( ch_y -1, ch_y + 1); + if( MAP_walkAble( index, fl,x,y)) { + break; + } + } + if( cnt == 10 ) { + x = ch_x; y = ch_y; + } + CHAR_warpToSpecificPoint( index,fl, x,y); + } + } + } +} + +static void PETMAIL_returnMail( int index, int tocharaindex) +{ + char msgbuf[512]; + int itemindex = CHAR_getItemIndex( index, CHAR_STARTITEMARRAY); + if( ITEM_CHECKINDEX( itemindex ) ) { + int ret = CHAR_addItemSpecificItemIndex( tocharaindex, itemindex); + + if( ret < 0 || ret >= CHAR_MAXITEMHAVE){ + CHAR_DropItem( index, CHAR_STARTITEMARRAY); + + LogItem( + CHAR_getChar( tocharaindex, CHAR_NAME ), + CHAR_getChar( tocharaindex, CHAR_CDKEY ), + itemindex, + "pm_returnputground(->߷õ)", + CHAR_getInt( index,CHAR_FLOOR), + CHAR_getInt( index,CHAR_X ), + CHAR_getInt( index,CHAR_Y ), + ITEM_getChar( itemindex, ITEM_UNIQUECODE), + ITEM_getChar( itemindex, ITEM_NAME), + ITEM_getInt( itemindex, ITEM_ID) + ); + }else { + CHAR_setItemIndex( index, CHAR_STARTITEMARRAY, -1); + CHAR_sendItemDataOne( tocharaindex, ret); + } + } + +#ifdef _PETMAIL_DEFNUMS + { + int petmailnums = CHAR_getWorkInt( tocharaindex, CHAR_PETMAILNUMS); + petmailnums--; + if( petmailnums < 0 ) petmailnums = 0; + CHAR_setWorkInt( tocharaindex, CHAR_PETMAILNUMS, petmailnums); + } +#endif + if( CHAR_getInt( index, CHAR_PETMAILBUFINDEX) != -1 ) { + snprintf( msgbuf, sizeof( msgbuf), + "%s ˣ" + "ƺ޷ż", + CHAR_getUseName( index)); + CHAR_talkToCli( tocharaindex, -1, msgbuf, CHAR_COLORWHITE); + PETMAIL_deleteOffmsg( CHAR_getInt( index, CHAR_PETMAILBUFINDEX)); + }else { + snprintf( msgbuf, sizeof( msgbuf), + "%s ˣ", CHAR_getUseName( index)); + CHAR_talkToCli( tocharaindex, -1, msgbuf, CHAR_COLORWHITE); + } + +#ifdef _PETMAIL_DEFNUMS + CHAR_AutoPickupMailPet( tocharaindex, index); +#endif + +} + + +#ifdef _PETMAIL_DEFNUMS +void CHAR_AutoPickupMailPet( int charaindex, int petindex ) +{ + int objindex; + int havepetindex; + char category[3]; + Char *ch; + if( !CHAR_CHECKINDEX( charaindex ) ) return; +#ifdef _AVID_TRADETRYBUG // + if( CHAR_getWorkInt( charaindex, CHAR_WORKTRADEMODE) != CHAR_TRADE_FREE ){ + CHAR_talkToCli( charaindex, -1, "״̬޷Զʰʼ", CHAR_COLORYELLOW ); + return; + } +#endif + if( !CHAR_CHECKINDEX( petindex ) ) return; + havepetindex = CHAR_getCharPetElement( charaindex); + if( havepetindex == -1 ) { + + CHAR_talkToCli(charaindex,-1,"޷Զʰʼ",CHAR_COLORYELLOW); + // WON ADD + LogPet( + CHAR_getChar( charaindex, CHAR_NAME ), + CHAR_getChar( charaindex, CHAR_CDKEY ), + CHAR_getChar( petindex, CHAR_NAME), + CHAR_getInt( petindex, CHAR_LV), + "Pet_Full(޷ʰ)", + CHAR_getInt( charaindex,CHAR_FLOOR), + CHAR_getInt( charaindex,CHAR_X ), + CHAR_getInt( charaindex,CHAR_Y ), + CHAR_getChar( petindex, CHAR_UNIQUECODE) + ); + return; + } + ch = CHAR_getCharPointer( petindex); + if( ch == NULL ) return; + + objindex = CHAR_getWorkInt( petindex, CHAR_WORKOBJINDEX ); + CHAR_ObjectDelete(objindex); + CHAR_setWorkInt( petindex, CHAR_WORKPLAYERINDEX, charaindex); + CHAR_setCharPet( charaindex, havepetindex, petindex); + + CHAR_setChar( petindex, CHAR_OWNERCDKEY, CHAR_getChar( charaindex, CHAR_CDKEY)); + CHAR_setChar( petindex, CHAR_OWNERCHARANAME, CHAR_getChar( charaindex, CHAR_NAME)); + + snprintf( category,sizeof( category),"K%d",havepetindex); + CHAR_sendStatusString( charaindex, category); + snprintf( category,sizeof( category),"W%d",havepetindex); + CHAR_sendStatusString( charaindex, category); + + CHAR_setInt( petindex, CHAR_PUTPETTIME, 0); + CHAR_setWorkInt( petindex, CHAR_WORKOBJINDEX, -1); + CHAR_setInt( petindex, CHAR_MAILMODE, CHAR_PETMAIL_NONE); + PETMAIL_delPetMailTotalnums( 1); // M PET Զ + + strcpysafe( ch->charfunctable[CHAR_LOOPFUNC].string, + sizeof( ch->charfunctable[CHAR_LOOPFUNC]),""); + CHAR_setInt( petindex, CHAR_LOOPINTERVAL, 0); + CHAR_constructFunctable( petindex); + CHAR_complianceParameter( petindex ); + + if( PetMailTotalnums < 0 ) PetMailTotalnums = 0; + { + char mesg[256]; + char *p = NULL; + p = CHAR_getChar( petindex, CHAR_USERPETNAME); + if( strlen( p) == 0 ) { + p = CHAR_getChar( petindex, CHAR_NAME); + } + snprintf( mesg,sizeof(mesg), "ʰʼ %s", p); + CHAR_talkToCli(charaindex,-1,mesg,CHAR_COLORYELLOW); + } +// LogPet( +// CHAR_getChar( charaindex, CHAR_NAME ), +// CHAR_getChar( charaindex, CHAR_CDKEY ), +// CHAR_getChar( petindex, CHAR_NAME), +// CHAR_getInt( petindex, CHAR_LV), +// "PickupMailPet(Զջʳ)", +// CHAR_getInt( charaindex,CHAR_FLOOR), +// CHAR_getInt( charaindex,CHAR_X ), +// CHAR_getInt( charaindex,CHAR_Y ), +// CHAR_getChar( petindex, CHAR_UNIQUECODE) +// ); + return; +} +#endif + +int PETMAIL_getPetMailTotalnums() +{ +#ifdef _PETMAIL_DEFNUMS + if( PetMailTotalnums < 0 ) PetMailTotalnums = 0; + if( PetMailTotalnums >= PETMAIL_DEFTOTALNUM ) PetMailTotalnums = PETMAIL_DEFTOTALNUM; + return PetMailTotalnums; +#else + return 0; +#endif +} + +void PETMAIL_delPetMailTotalnums( int numflg) +{ +#ifdef _PETMAIL_DEFNUMS + PetMailTotalnums = PetMailTotalnums - numflg; + if( PetMailTotalnums < 0 ) PetMailTotalnums = 0; +#endif +} + +void PETMAIL_setPetMailTotalnums( int numflg) +{ + PetMailTotalnums = numflg; + if( PetMailTotalnums < 0 ) PetMailTotalnums = 0; + if( PetMailTotalnums > PETMAIL_DEFTOTALNUM+10 ) PetMailTotalnums = PETMAIL_DEFTOTALNUM + 5; +} + + +int PETMAIL_CheckIsMyOffmsg( int fromindex, char *tocdkey, char *tocharaname) +{ + int i, nums=0; + for( i = 0 ; i < PETMAIL_offmsg_max; i++ ) { + if( PETMAIL_offmsgbuf[i].use == 0 ) continue; + if( !strcmp( tocdkey, PETMAIL_offmsgbuf[i].destcd) && + !strcmp( tocharaname, PETMAIL_offmsgbuf[i].destcharname) ){ + nums++; + } + } + return nums; +} + + + diff --git a/char/skill.c b/char/skill.c new file mode 100644 index 0000000..d692cd8 --- /dev/null +++ b/char/skill.c @@ -0,0 +1,644 @@ +#include "version.h" +#include +#include +#include + +#include "skill.h" +#include "util.h" +#include "char.h" + +#ifdef _CHAR_PROFESSION // WON ADD ְҵ +#include "battle.h" +#include "profession_skill.h" +#endif + + +static SKILL_intDataSetting SKILL_setint[SKILL_DATAINTNUM]={ + {"lv"}, /* SKILL_LEVEL */ + {"id"}, /* SKILL_ID */ +}; + +static SKILL_charDataSetting SKILL_setchar[SKILL_DATACHARNUM]={ +}; + + + + +static char SKILL_dataString[STRINGBUFSIZ]; + +char* SKILL_makeStringFromSkillData( Skill* sk ) +{ + int i; + int strlength=0; + + for( i = 0 ; i < SKILL_DATAINTNUM ; i ++ ){ + char linedata[128]; + snprintf( linedata , sizeof(linedata), + "%s=%d" NONCHAR_DELIMITER, + SKILL_setint[i].dumpskill, sk->data[i] ); + + strcpysafe( &SKILL_dataString[strlength], + sizeof( SKILL_dataString ) - strlength, + linedata ); + strlength += strlen( linedata ); + if( strlength > sizeof( SKILL_dataString ) )goto RETURN; + } + + for( i = 0 ; i < SKILL_DATACHARNUM ; i ++ ){ + char linedata[128]; + char escapebuffer[128]; + snprintf( linedata, sizeof(linedata), + "%s=%s" NONCHAR_DELIMITER, + SKILL_setchar[i].dumpskill, + makeEscapeString(sk->string[i].string,escapebuffer, + sizeof(escapebuffer))); + + strcpysafe( &SKILL_dataString[strlength], + sizeof( SKILL_dataString ) - strlength, + linedata ); + strlength += strlen( linedata ); + if( strlength > sizeof( SKILL_dataString ) )goto RETURN; + } + +RETURN: + dchop( SKILL_dataString , NONCHAR_DELIMITER ); + + return SKILL_dataString; +} + + +BOOL SKILL_makeSkillFromStringToArg( char* src, Skill* sk ) +{ + int readindex=1; + while( 1 ){ + BOOL ret; + char linebuf[512]; + char first[256]; + char second[256]; + int i; + + + ret = getStringFromIndexWithDelim( src ,NONCHAR_DELIMITER , + readindex, + linebuf, sizeof( linebuf ) ); + if( ret == FALSE ) + break; + + ret = getStringFromIndexWithDelim( linebuf ,"=", 1, + first, sizeof( first ) ); + if( ret == FALSE ) return FALSE; + strcpysafe( second , sizeof( second ), + linebuf + strlen(first) + strlen("=") ); + + for( i = 0 ; i < SKILL_DATAINTNUM ; i ++ ){ + if( strcmp(first ,SKILL_setint[i].dumpskill) == 0 ){ + sk->data[i] = atoi( second ); + goto NEXT; + } + } + + for( i = 0 ; i < SKILL_DATACHARNUM ; i ++ ){ + if( strcmp(first ,SKILL_setchar[i].dumpskill) == 0 ){ + strcpysafe( sk->string[i].string, + sizeof(sk->string[i].string), + makeStringFromEscaped(second) ); + goto NEXT; + } + } + + fprint( "??? : %s[%s]\n" , linebuf, first ); + + NEXT: + readindex++; + } + + return TRUE; +} + +#ifdef _CHAR_PROFESSION // WON ADD ְҵ +INLINE int SKILL_getRealInt( Skill* skill, int element) +{ + return skill->data[element]; +} +#endif + +INLINE int SKILL_getInt( Skill* skill, int element) +{ + int value = skill->data[element]; + + if( element == SKILL_LEVEL ) value /= 100; + + return value; +} + + +INLINE int SKILL_setInt( Skill* skill, int element, int new) +{ + int buf = SKILL_getInt( skill, element ); + skill->data[element] = new; + return buf; +} + +#ifndef _PROFESSION_SKILL // WON ADD ְҵ +static void SKILL_setitemlimit( int charaindex, Skill* sk ); +static void SKILL_setmerchant( int charaindex, Skill* sk ); +static void SKILL_setlevel( int charaindex, Skill* sk ); +#endif + +static SKILL_table SKILL_tbl[]={ + +#ifdef _PROFESSION_SKILL // WON ADD ְҵ + { 100, NULL}, // 1 + { 100, NULL}, + { 100, NULL}, + { 100, NULL}, + { 100, NULL}, + { 100, NULL}, + { 100, NULL}, + { 100, NULL}, + { 100, NULL}, + { 100, NULL}, + { 100, NULL}, + { 100, NULL}, + { 100, NULL}, + { 100, NULL}, + { 100, NULL}, + { 100, NULL}, // 16 +#else + {8,SKILL_setlevel}, /* SKILL_FIRE */ + {4,NULL}, /* SKILL_MAGICIAN */ + {4,NULL}, /* SKILL_PREIST */ + {8,SKILL_setitemlimit}, /* SKILL_ALOTOFTHINGS */ + {8,NULL}, /* SKILL_AVOIDRATEUP */ + {4,SKILL_setlevel}, /* SKILL_DETERMINEITEM */ + {5,SKILL_setlevel}, /* SKILL_DETERMINEOTHERS */ + {8,SKILL_setmerchant}, /* SKILL_MERCHANT */ + {8,SKILL_setlevel}, /* SKILL_HEALER */ + {8,SKILL_setlevel}, /* SKILL_LARGEVOICE */ +#endif +}; + + +#ifndef _PROFESSION_SKILL // WON ADD ְҵ +static void SKILL_setitemlimit( int charaindex, Skill* sk ) +{ + static int itemlimit[9]={ + 7 + 8 + 4*0, + 7 + 8 + 4*1, + 7 + 8 + 4*2, + 7 + 8 + 4*3, + 7 + 8 + 4*4, + 7 + 8 + 4*5, + 7 + 8 + 4*6, + 7 + 8 + 4*7, + 7 + 8 + 4*8, + }; + int level; + if( !CHAR_CHECKINDEX(charaindex) )return; + if( sk->data[SKILL_IDENTITY] != SKILL_ALOTOFTHINGS )return; + level = sk->data[SKILL_LEVEL]; + if( level < 0 )level = 0; + if( level>=arraysizeof(itemlimit) ) level=arraysizeof(itemlimit) - 1; +} + + +static void SKILL_setmerchant( int charaindex, Skill* sk ) +{ + int level; + int merchantlevel=0; + + if( !CHAR_CHECKINDEX(charaindex) )return; + if( sk->data[SKILL_IDENTITY] != SKILL_MERCHANT )return; + + level = sk->data[SKILL_LEVEL]; + if( level < 0 )level = 0; + if( level >= SKILL_tbl[sk->data[SKILL_IDENTITY]].maxlevel ) + level = SKILL_tbl[sk->data[SKILL_IDENTITY]].maxlevel; + + SETHIGHVALUE(merchantlevel,(100 - level*5)); + SETLOWVALUE(merchantlevel,(20 + level*5)); + + CHAR_setInt( charaindex,CHAR_MERCHANTLEVEL,merchantlevel ); +} + + +static void SKILL_setlevel( int charaindex, Skill* sk ) +{ + static struct skillvalset + { + SKILL_ID id; + CHAR_DATAINT charadataindex; + } skvalset[] = { + { SKILL_DETERMINEITEM, CHAR_DETERMINEITEM }, + { SKILL_DETERMINEOTHERS, CHAR_RADARSTRENGTH }, + { SKILL_HEALER, CHAR_HEALERLEVEL }, + { SKILL_LARGEVOICE, CHAR_CHATVOLUME }, + }; + int id; + int i; + int index=-1; + int level; + + if( !CHAR_CHECKINDEX(charaindex) )return; + id = sk->data[SKILL_IDENTITY]; + for( i=0 ; idata[SKILL_LEVEL]; + if( level < 0 )level = 0; + if( level >= SKILL_tbl[id].maxlevel ) + level = SKILL_tbl[id].maxlevel; + + CHAR_setInt(charaindex,skvalset[index].charadataindex,level ); +} +#endif + + + + + +#define SKILLSTRINGBUFSIZ 256 + +static char ITEM_statusStringBuffer[SKILLSTRINGBUFSIZ]; + + +#ifdef _CHAR_PROFESSION // WON ADD ְҵ +char* SKILL_makeSkillStatusString( Skill* skill, int charaindex, int skill_num ) +{ + int skillindex=SKILL_getInt( skill,SKILL_IDENTITY); + int Pskill=PROFESSION_SKILL_getskillArray( skillindex); + int skill_level=0, cost_mp=0; + + // \ܵȼ + skill_level = SKILL_getInt( skill, SKILL_LEVEL); + + // ķMP + if( (cost_mp = PROFESSION_MAGIC_COST_MP( charaindex, skill_num )) == -1 ) + cost_mp = PROFESSION_SKILL_getInt( Pskill, PROFESSION_SKILL_COST_MP); + + snprintf( ITEM_statusStringBuffer, sizeof( ITEM_statusStringBuffer ), + "%d|%d|%d|%d|%d|%d|%d|%s|%s", + PROFESSION_SKILL_getInt( Pskill, PROFESSION_SKILL_USE_FLAG), + SKILL_getInt(skill,SKILL_IDENTITY), + PROFESSION_SKILL_getInt( Pskill, PROFESSION_SKILL_TARGET), + PROFESSION_SKILL_getInt( Pskill, PROFESSION_SKILL_KIND), + PROFESSION_SKILL_getInt( Pskill, PROFESSION_SKILL_ICON), + cost_mp, + skill_level, + PROFESSION_SKILL_getChar( Pskill, PROFESSION_SKILL_NAME), + PROFESSION_SKILL_getChar( Pskill, PROFESSION_SKILL_TXT) ); + + return ITEM_statusStringBuffer; +} +#else +char* SKILL_makeSkillStatusString( Skill* skill ) +{ + snprintf( ITEM_statusStringBuffer, + sizeof( ITEM_statusStringBuffer ), + "%d|%d", + SKILL_getInt(skill,SKILL_IDENTITY), + SKILL_getInt(skill,SKILL_LEVEL) ); + + + return ITEM_statusStringBuffer; +} +#endif + + + +char* SKILL_makeSkillFalseString( void ) +{ + snprintf( ITEM_statusStringBuffer, + sizeof( ITEM_statusStringBuffer ), + "|" ); + return ITEM_statusStringBuffer; +} + + +BOOL SKILL_CHECKID( int skillid ) +{ + if( SKILL_NUM <= skillid && skillid > 0 )return FALSE; + return TRUE; +} + +BOOL SKILL_makeSkillData( Skill* sk ,int skid, int lev ) +{ + sk->data[SKILL_LEVEL] = lev; + sk->data[SKILL_IDENTITY] = skid; + + return TRUE; +} + +int SKILL_levelup( Skill* sk ) +{ + int id = sk->data[SKILL_IDENTITY]; + if( !SKILL_CHECKID(id) )return -1; + sk->data[SKILL_LEVEL] ++; + sk->data[SKILL_LEVEL] = min( sk->data[SKILL_LEVEL], + SKILL_tbl[id].maxlevel ); + return TRUE; +} + +int SKILL_getLevelFromSkillID( int charaindex, SKILL_ID id ) +{ + int i; + if( !CHAR_CHECKINDEX(charaindex) )return -1; + for( i=0 ; iuse && sk->skill.data[SKILL_IDENTITY] == id ) + return sk->skill.data[SKILL_LEVEL]; + + } + return -1; +} + +BOOL SKILL_getUpableSkillID( int charaindex,char* buf, int buflen ) +{ + int i; + if( !CHAR_CHECKINDEX(charaindex)) return FALSE; + if( buflen <= 0 )return FALSE; + buf[0] = '\0'; + for( i=0 ; iuse + && SKILL_CHECKID(chsk->skill.data[SKILL_IDENTITY]) + && chsk->skill.data[SKILL_LEVEL] + < SKILL_tbl[chsk->skill.data[SKILL_IDENTITY]].maxlevel ){ + char tmpbuf[512]; + snprintf( tmpbuf,sizeof(tmpbuf),"%d|", + chsk->skill.data[SKILL_IDENTITY] ); + strcatsafe( buf, buflen,tmpbuf ); + } + } + dchop(buf,"|"); + return TRUE; +} + +void SKILL_skillEffect( int charaindex ) +{ + int i; + if( !CHAR_CHECKINDEX(charaindex) )return; + + if( CHAR_getInt(charaindex,CHAR_WHICHTYPE) != CHAR_TYPEPLAYER) + return; + + for( i=0 ; iuse == FALSE )continue; + + skill = &cskill->skill; + id = skill->data[SKILL_IDENTITY]; + if( !SKILL_CHECKID(id) )continue; + + skfunc = (SKILLEFFECTFUNC)SKILL_tbl[id].effectfunc; + if( skfunc )skfunc(charaindex,skill); + } +} + + + +#ifdef _CHAR_PROFESSION // WON ADD ְҵ +// ȡʹħķMP +int PROFESSION_MAGIC_COST_MP( int charaindex, int skill_num ) +{ + int skill_level=0, dec_mp=0; + int Pskillid, skillid; + char *skill_name; + CHAR_HaveSkill* hskill; + + // \ + skillid = CHAR_getCharSkill( charaindex, skill_num); + Pskillid = PROFESSION_SKILL_getskillArray( skillid); + if( Pskillid == -1 ) return FALSE; + + // + skill_name = PROFESSION_SKILL_getChar( Pskillid, PROFESSION_SKILL_FUNCNAME); + + // ܵȼ + hskill = CHAR_getCharHaveSkill( charaindex, skill_num ); + skill_level = SKILL_getInt( &hskill->skill, SKILL_LEVEL); + skill_level = PROFESSION_CHANGE_SKILL_LEVEL_M( skill_level ); + + if( (strcmp( skill_name, "PROFESSION_VOLCANO_SPRINGS" )) == 0 ){ // ɽȪ + if( skill_level >= 10 ) dec_mp = 35; + else if( skill_level >= 7 ) dec_mp = 30; + else if( skill_level >= 5 ) dec_mp = 20; + else if( skill_level >= 3 ) dec_mp = 15; + else dec_mp = 10; + }else + if( (strcmp( skill_name, "PROFESSION_FIRE_BALL" )) == 0 ){ // + if( skill_level >= 9 ) dec_mp = 50; + else if( skill_level >= 7 ) dec_mp = 45; + else if( skill_level >= 5 ) dec_mp = 40; + else if( skill_level >= 3 ) dec_mp = 35; + else dec_mp = 30; + }else + if( (strcmp( skill_name, "PROFESSION_SUMMON_THUNDER" )) == 0 ){ // + if( skill_level >= 8 ) dec_mp = 30; + else if( skill_level >= 5 ) dec_mp = 25; + else if( skill_level >= 3) dec_mp = 20; + else dec_mp = 10; + }else + if( (strcmp( skill_name, "PROFESSION_CURRENT" )) == 0 ){ // +#ifdef _PROFESSION_ADDSKILL + if( skill_level >= 10 ) dec_mp = 100; + else if( skill_level > 9 ) dec_mp = 90; + else if( skill_level > 8 ) dec_mp = 80; + else if( skill_level > 7 ) dec_mp = 70; + else if( skill_level > 6 ) dec_mp = 60; + else if( skill_level > 4 ) dec_mp = 50; + else if( skill_level > 2 ) dec_mp = 40; + else dec_mp = 30; +#else + if( skill_level >= 9 ) dec_mp = 80; + else if( skill_level >= 7 ) dec_mp = 60; + else if( skill_level >= 5 ) dec_mp = 50; + else if( skill_level >= 3 ) dec_mp = 40; + else dec_mp = 30; +#endif + }else + if( (strcmp( skill_name, "PROFESSION_STORM" )) == 0 ){ // +#ifdef _PROFESSION_ADDSKILL + if( skill_level > 8 ) dec_mp = 50; + else if( skill_level > 6 ) dec_mp = 45; + else if( skill_level > 4 ) dec_mp = 40; + else if( skill_level > 2 ) dec_mp = 35; + else dec_mp = 30; +#else + if( skill_level >= 10 ) dec_mp = 80; + else if( skill_level >= 6 ) dec_mp = 70; + else if( skill_level >= 5 ) dec_mp = 60; + else dec_mp = 50; +#endif + }else + if( (strcmp( skill_name, "PROFESSION_ICE_ARROW" )) == 0 ){ // + if( skill_level >= 8) dec_mp = 20; + else if( skill_level >= 4 ) dec_mp = 15; + else dec_mp = 10; + }else + if( (strcmp( skill_name, "PROFESSION_ICE_CRACK" )) == 0 ){ // +#ifdef _PROFESSION_ADDSKILL + if( skill_level >= 10 ) dec_mp = 80; + else if( skill_level > 8 ) dec_mp = 70; + else if( skill_level > 6 ) dec_mp = 60; + else if( skill_level > 4 ) dec_mp = 50; + else if( skill_level > 2 ) dec_mp = 40; + else dec_mp = 30; +#else + if( skill_level >= 9 ) dec_mp = 70; + else if( skill_level >= 7 ) dec_mp = 60; + else if( skill_level >= 5 ) dec_mp = 50; + else if( skill_level >= 3 ) dec_mp = 40; + else dec_mp = 30; +#endif + }else + if( (strcmp( skill_name, "PROFESSION_DOOM" )) == 0 ){ // ĩ + if( skill_level > 8 ) dec_mp = 150; + else if( skill_level > 4 ) dec_mp = 100; + else dec_mp = 50; + }else + if( (strcmp( skill_name, "PROFESSION_FIRE_SPEAR" )) == 0 ){ // ǹ + if( skill_level > 8 ) dec_mp = 80; + else if( skill_level > 6 ) dec_mp = 70; + else if( skill_level > 4 ) dec_mp = 60; + else if( skill_level > 2 ) dec_mp = 40; + else dec_mp = 30; + }else + if( (strcmp( skill_name, "PROFESSION_BLOOD_WORMS" )) == 0 ){ // Ѫ + if( skill_level >= 10 ) dec_mp = 15; + else if( skill_level >= 5 ) dec_mp = 10; + else dec_mp = 5; + }else + if( (strcmp( skill_name, "PROFESSION_SIGN" )) == 0 ){ // һѪ + + if( skill_level >= 8 ) dec_mp = 10; + else dec_mp = 5; + + }else + if( (strcmp( skill_name, "PROFESSION_ENCLOSE" )) == 0 ){ // + if( skill_level >= 10 ) dec_mp = 80; + else if( skill_level >= 8 ) dec_mp = 70; + else if( skill_level >= 5) dec_mp = 60; + else dec_mp = 50; + }else + if( (strcmp( skill_name, "PROFESSION_ICE_MIRROR" )) == 0 ){ // + if( skill_level >= 9 ) dec_mp = 40; + else if( skill_level >= 7 ) dec_mp = 35; + else if( skill_level >= 5 ) dec_mp = 30; + else if( skill_level >= 3 ) dec_mp = 25; + else dec_mp = 20; + }else + if( (strcmp( skill_name, "PROFESSION_FIRE_ENCLOSE" )) == 0 ){ // + if( skill_level >= 10 ) dec_mp = 50; + else if( skill_level >= 7 ) dec_mp = 40; + else if( skill_level >= 4 ) dec_mp = 30; + else dec_mp = 20; + }else + if( (strcmp( skill_name, "PROFESSION_ICE_ENCLOSE" )) == 0 ){ // + if( skill_level >= 10 ) dec_mp = 50; + else if( skill_level >= 7 ) dec_mp = 40; + else if( skill_level >= 4 ) dec_mp = 30; + else dec_mp = 20; + }else + if( (strcmp( skill_name, "PROFESSION_THUNDER_ENCLOSE" )) == 0 ){ // ׸ + if( skill_level >= 10 ) dec_mp = 50; + else if( skill_level >= 7 ) dec_mp = 40; + else if( skill_level >= 4 ) dec_mp = 30; + else dec_mp = 20; + }else + if( (strcmp( skill_name, "PROFESSION_TRANSPOSE" )) == 0 ){ // λλ + if( skill_level >= 10 ) dec_mp = 50; + else if( skill_level >= 9 ) dec_mp = 40; + else if( skill_level >= 7 ) dec_mp = 30; + else if( skill_level >= 4 ) dec_mp = 20; + else dec_mp = 10; + }else +#ifdef _PROFESSION_ADDSKILL + if( (strcmp( skill_name, "PROFESSION_RESIST_F_I_T" )) == 0 ){ // Ȼ + if( skill_level >= 10 ) dec_mp = 20; + else if( skill_level >= 9 ) dec_mp = 15; + else if( skill_level >= 6 ) dec_mp = 10; + else dec_mp = 5; + }else + if( (strcmp( skill_name, "PROFESSION_CALL_NATURE" )) == 0 ){ // Ȼ + + /*skill_level = SKILL_getInt( &hskill->skill, SKILL_LEVEL); + if( skill_level >= 100 ) dec_mp = 50; + else if( skill_level > 95 ) dec_mp = 50; + else if( skill_level > 90 ) dec_mp = 50; + else if( skill_level > 85 ) dec_mp = 50; + else if( skill_level > 80 ) dec_mp = 50; + else if( skill_level > 60 ) dec_mp = 50; + else if( skill_level > 40 ) dec_mp = 50; + else if( skill_level > 20 ) dec_mp = 50; + else dec_mp = 50;*/ + dec_mp = 50; + }else + if( (strcmp( skill_name, "PROFESSION_BOUNDARY" )) == 0 ){ // Խ + char *pszP=NULL; + if( skill_level > 9 ) dec_mp = 20; + else if( skill_level > 6 ) dec_mp = 15; + else dec_mp = 10; + //Ƴmp粻ͬ + if( (pszP = strstr( PROFESSION_SKILL_getChar( Pskillid, PROFESSION_SKILL_OPTION), "ƽ" ) ) != NULL ){// ܵIJ + if( skill_level >= 9 ) dec_mp = 20; + else if( skill_level > 4 ) dec_mp = 15; + else if( skill_level > 2 ) dec_mp = 10; + else dec_mp = 5; + } + }else +#endif + { + return -1; + } + + return dec_mp; +} + + +INLINE int PROFESSION_CHANGE_SKILL_LEVEL_M( int skill_level ) +{ + if( skill_level > 90 )skill_level = 10; + else if( skill_level > 80 ) skill_level = 9; + else if( skill_level > 70 ) skill_level = 8; + else if( skill_level > 60 ) skill_level = 7; + else if( skill_level > 50 ) skill_level = 6; + else if( skill_level > 40 ) skill_level = 5; + else if( skill_level > 30 ) skill_level = 4; + else if( skill_level > 20 ) skill_level = 3; + else if( skill_level > 10 ) skill_level = 2; + else skill_level = 1; + + return skill_level; +} + + +INLINE int PROFESSION_CHANGE_SKILL_LEVEL_A( int skill_level ) +{ + if( skill_level >= 100 ) skill_level = 10; + else if( skill_level > 90 ) skill_level = 9; + else if( skill_level > 80 ) skill_level = 8; + else if( skill_level > 70 ) skill_level = 7; + else if( skill_level > 60 ) skill_level = 6; + else if( skill_level > 50 ) skill_level = 5; + else if( skill_level > 40 ) skill_level = 4; + else if( skill_level > 30 ) skill_level = 3; + else if( skill_level > 20 ) skill_level = 2; + else if( skill_level > 10 ) skill_level = 1; + else skill_level = 0; + + return skill_level; +} +#endif + diff --git a/char/title.c b/char/title.c new file mode 100644 index 0000000..a0c0e32 --- /dev/null +++ b/char/title.c @@ -0,0 +1,1067 @@ +#include "version.h" +#include +#include +#include +#include +#include +#ifdef _REDHAT_V9 +#include +#endif + +#include "title.h" +#include "char.h" +#include "char_base.h" +#include "item.h" +#include "skill.h" +#include "buf.h" +#include "util.h" +#include "configfile.h" + + +/*====================į ====================*/ +static int TITLE_IntCheck( int charaindex,int elem, int *data, int flg); +static int TITLE_WorkIntCheck( int charaindex,int elem, int *data, int flg); +static int TITLE_ItemCheck( int charaindex,int elem, int *data, int flg); +static int TITLE_ItemEquipCheck( int charaindex,int elem, int *data, int flg); +static int TITLE_SkillCheck( int charaindex,int elem, int *data, int flg); +static int TITLE_SexCheck( int charaindex,int elem, int *data, int flg); + +typedef enum +{ + TITLE_FUNCTYPENONE, /* Ϸئ */ + TITLE_FUNCTYPEUSERFUNC, /* definefunction ëȻ ë + * Ѽ¦ѷ + * int ƽҷ̼͵ + * buf ߼ + * buflen 뼰Ӯ + */ + TITLE_USEFUNCTYPENUM +}TITLE_USEFUNCTYPE; + +typedef struct tagTITLE_Table +{ + int index; /* ܷѯë׻ + * įƥȻaddtitle羮֧ + */ + char name[32]; + TITLE_USEFUNCTYPE functype; + void (*definefunction)(int,char* buf,int buflen); +}TITLE_Table; + +/* ɷ¶ + * STR,TGH,MAXMPATK,DEF + * LEVEL,CLASS,SKILL,ITEM,FIREREG,ICEREG,THUNDERREG + * KANJILV,TALKCNT,WALKCNT,DEADCNT,LOGINCNT,BASEIMAGENUMBER + * GOLD +*/ +typedef struct tagTITLE_Compare { + char compare[8];; +} TITLE_COMPARE; + +TITLE_COMPARE TITLE_compare[] = { {"<="}, {">="},{"<>"}, {">"},{"<"},{"="}}; + +typedef struct tagTITLE_PARAM +{ + int element; + int (*checkfunc)( int charaindex,int elem, int *data, int flg ); + char *paramname; +}TITLE_PARAM; + +TITLE_PARAM TITLE_param[] = +{ + /**** ****/ + { -1, TITLE_ItemCheck, "ITEM" }, + { -1, TITLE_ItemEquipCheck,"EQUIPITEM" }, + { -1, NULL, "EQUIPEVENT" }, + /**** ƥ ئƥʷֽУ ****/ + { -1, TITLE_SkillCheck, "SKILL" }, + { CHAR_STR, TITLE_IntCheck, "STR" }, + { CHAR_TOUGH, TITLE_IntCheck, "TGH" }, + { CHAR_MAXMP, TITLE_IntCheck, "MAXMP" }, + { CHAR_WORKFIXSTR, TITLE_WorkIntCheck, "ATK" }, + { CHAR_WORKFIXTOUGH, TITLE_WorkIntCheck, "DEF" }, + { CHAR_LV, TITLE_IntCheck, "LEVEL" }, + { CHAR_TALKCOUNT, TITLE_IntCheck, "TALKCNT" }, + { CHAR_WALKCOUNT, TITLE_IntCheck, "WALKCNT" }, + { CHAR_DEADCOUNT, TITLE_IntCheck, "DEADCNT" }, + { CHAR_LOGINCOUNT, TITLE_IntCheck, "LOGINCNT" }, + { CHAR_BASEBASEIMAGENUMBER,TITLE_IntCheck, "BASEIMAGENUMBER" }, + { CHAR_GOLD, TITLE_IntCheck, "GOLD" }, + { -1, TITLE_SexCheck, "SEX" }, +}; + +#define TITLE_PARAMSIZE 20 +typedef struct tagTITLE_configTable +{ + int paramindex[20]; /* TITLE_param߼ٯ */ + int param[20][TITLE_PARAMSIZE]; /* Ұ */ + int compareflg[20]; /* ><=¾ */ + int title; + BOOL equipcheckflg; /* + * ʧ ة ìƥ𼰰׷º뼰 Ȼ + * ּƾئУ + */ +}TITLE_CONFIGTABLE; + +typedef struct tagTITLE_configbuf +{ + int title; + int flg; +}TITLE_CONFIGBUF; + +static TITLE_CONFIGTABLE *TITLE_ConfigTable; +static TITLE_Table *TITLE_table; +static TITLE_CONFIGBUF *TITLE_configbuf; +static int TITLE_titlenum; +static int TITLE_titlecfgnum; + +/*------------------------------------------------------------ + * index įTITLE_tableٯë + ------------------------------------------------------------*/ +int TITLE_getTitleIndex( int index) +{ + int i; + if( index < 0 ) return -1; + for( i = 0; i < TITLE_titlenum; i ++ ) { + if( TITLE_table[i].index == index ) { + return( i); + } + } + return -1; +} + +/* 뼰 */ +#define TITLESTRINGBUFSIZ 256 +/* ͷʧέµƽﷸ ٯ */ +static char TITLE_statusStringBuffer[TITLESTRINGBUFSIZ]; +/*------------------------------------------------------------ + * ͷʧέ±į ٯ ë + * ¦ + * title Title* ƽ + * charaindex int 𼰱įë Ȼƽҷ¼̼͵ + * ߯Ի + * char* + ------------------------------------------------------------*/ +char* TITLE_makeTitleStatusString( int charaindex,int havetitleindex ) +{ + int attach; + int index; + /* ߼̼͵շë */ + index = CHAR_getCharHaveTitle( charaindex,havetitleindex ); + + attach = TITLE_getTitleIndex( index); + if( attach == -1 ) { + TITLE_statusStringBuffer[0] = '\0'; + return TITLE_statusStringBuffer; + } + switch( TITLE_table[attach].functype ){ + case TITLE_FUNCTYPENONE: + snprintf( TITLE_statusStringBuffer, + sizeof(TITLE_statusStringBuffer ),"%s" , + TITLE_table[attach].name ); + break; + + case TITLE_FUNCTYPEUSERFUNC: + { + char string[256]={""}; + void (*function)(int,char* buf,int buflen); + function = TITLE_table[attach].definefunction; + if( function ) + function( charaindex,string,sizeof(string) ); + + strcpysafe( TITLE_statusStringBuffer, + sizeof(TITLE_statusStringBuffer ),string ); + } + break; + default: + TITLE_statusStringBuffer[0] = '\0'; + return TITLE_statusStringBuffer; + break; + } + return TITLE_statusStringBuffer; +} + +/*------------------------------------------------------------ + * ئбį ٯ ë߯ + * ¦ + * ئ + * ߯Ի + * char* + ------------------------------------------------------------*/ +char* TITLE_makeSkillFalseString( void ) +{ + TITLE_statusStringBuffer[0]= '\0'; + return TITLE_statusStringBuffer; +} + + +/*------------------------------------------------------------ + * ϶ýľ įįëܰ£ۺֽئȻգܰئ + * ¦ + * charaindex int ƽҷ̼͵ + * titleindex int į̼͵ + * ߯Ի + * ܰindex + * ܰئ FALSE(0) + ------------------------------------------------------------*/ +BOOL TITLE_addtitle( int charaindex, int titleindex ) +{ + int i; + int firstfindempty=-1; + + if( CHAR_CHECKINDEX(charaindex) == FALSE )return FALSE; + /*if( TITLE_CHECKTABLEINDEX(titleindex) == FALSE )return FALSE;*/ + if( TITLE_getTitleIndex( titleindex) == -1 ) return FALSE; + + for( i=0 ; i < CHAR_TITLEMAXHAVE ; i++ ){ + if( CHAR_getCharHaveTitle( charaindex,i ) == titleindex ) + /* ƥ Ȼ¾ئ */ + return FALSE; + if( firstfindempty == -1 + && CHAR_getCharHaveTitle(charaindex,i) == -1 ){ + firstfindempty = i; + } + } + return CHAR_setCharHaveTitle( charaindex,firstfindempty,titleindex ); +} + + +/*------------------------------------------------------------ + * ϶ýľ įįؤմ£ئئУ + * ؤ ʣ + * ¦ + * charaindex int ƽҷ̼͵ + * titleindex int į̼͵ + * ߯Ի + * TRUE(1) + * ئ FALSE(0) + ------------------------------------------------------------*/ +BOOL TITLE_deltitle( int charaindex, int titleindex ) +{ + int i; + BOOL del=FALSE; + int index; + if( CHAR_CHECKINDEX(charaindex) == FALSE )return FALSE; + /*if( TITLE_CHECKTABLEINDEX(titleindex) == FALSE )return FALSE;*/ + index = TITLE_getTitleIndex( titleindex); + if( index == -1 ) return FALSE; + + for( i=0 ; i < CHAR_TITLEMAXHAVE ; i++ ) + if( CHAR_getCharHaveTitle( charaindex,i ) == titleindex ){ + /* лȻ֧ئɣľئƱ */ + if( CHAR_getInt(charaindex, CHAR_INDEXOFEQTITLE) == i ){ + CHAR_setInt(charaindex, CHAR_INDEXOFEQTITLE, -1 ); + } + /* Ȼ¾ */ + CHAR_setCharHaveTitle( charaindex,i,-1); + + del = TRUE; + } + + return del; +} +/*------------------------------------------------------------ + * įë£ + * ¦ + * filename char* ɬð̻ + * ߯Ի + * TRUE(1) + * FALSE(0) + *------------------------------------------------------------*/ +BOOL TITLE_initTitleName( char* filename ) +{ + FILE* f; + char line[256]; + int linenum=0; + int title_readlen=0; + + f = fopen(filename,"r"); + if( f == NULL ){ + errorprint; + return FALSE; + } + + TITLE_titlenum=0; + + /* ئ滥ϵؤ¾Ʃ */ + while( fgets( line, sizeof( line ), f ) ){ + linenum ++; + if( line[0] == '#' )continue; /* comment */ + if( line[0] == '\n' )continue; /* none */ + chomp( line ); + + TITLE_titlenum++; + } + + if( fseek( f, 0, SEEK_SET ) == -1 ){ + fprint( "ѰҴ\n" ); + fclose(f); + return FALSE; + } + + TITLE_table = allocateMemory( sizeof(struct tagTITLE_Table) + * TITLE_titlenum ); + if( TITLE_table == NULL ){ + fprint( "޷ڴ %d\n" , + sizeof(TITLE_table)*TITLE_titlenum); + fclose( f ); + return FALSE; + } + /* */ +{ + int i; + for( i = 0; i < TITLE_titlenum; i ++ ) { + TITLE_table[i].index = -1; + TITLE_table[i].name[0] = '\0'; + TITLE_table[i].functype = TITLE_FUNCTYPENONE; + TITLE_table[i].definefunction = NULL; + } + +} + + /* */ + linenum = 0; + while( fgets( line, sizeof( line ), f ) ){ + linenum ++; + if( line[0] == '#' )continue; /* comment */ + if( line[0] == '\n' )continue; /* none */ + chomp( line ); + + /* ë */ + /* tab ë " " 徧 */ + replaceString( line, '\t' , ' ' ); + /* ʸë£*/ +{ + int i; + char buf[256]; + for( i = 0; i < strlen( line); i ++) { + if( line[i] != ' ' ) { + break; + } + strcpy( buf, &line[i]); + } + if( i != 0 ) { + strcpy( line, buf); + } +} +{ + char token[256]; + int ret; + + /* 繴ͼëέ */ + ret = getStringFromIndexWithDelim( line,",",1,token, + sizeof(token)); + if( ret==FALSE ){ + fprint("ļ﷨:%s %d\n",filename,linenum); + continue; + } + TITLE_table[title_readlen].index = atoi(token); + + /* 2ͼëέ */ + ret = getStringFromIndexWithDelim( line,",",2,token, + sizeof(token)); + if( ret==FALSE ){ + fprint("ļ﷨:%s %d\n",filename,linenum); + continue; + } + if( strlen( token) > sizeof( TITLE_table[title_readlen].name)-1) { + fprint("! ͷƽļ:%s %d\n", + filename, linenum); + } + strcpysafe( TITLE_table[title_readlen].name, + sizeof( TITLE_table[title_readlen].name), + token); + + title_readlen ++; +} + } + fclose(f); + + TITLE_titlenum = title_readlen; + + print( "Чͷ %d...", TITLE_titlenum ); + +#ifdef DEBUG + + { + int i; + for( i=0; i ="); + if( comppos == -1 ) { + fprint("ļ﷨:%s %d\n",filename,linenum); + TITLE_initTitleData( titlecfg_readlen); + errflg = TRUE; + break;; + } + /* įįṴ */ + if( charInclude( &token[comppos+1], "<>=") != -1 ) { + /* ئ ʤë */ + for( j = 0; j < 3; j ++ ) { + if( memcmp( TITLE_compare[j].compare, &token[comppos], 2 ) == 0 ) { + break; + } + } + if( j == 3 ) { + fprint("ļ﷨:%s %d\n",filename,linenum); + TITLE_initTitleData( titlecfg_readlen); + errflg = TRUE; + break; + } + else { + ret = TITLE_getParamData( titlecfg_readlen,i-1,&token[comppos+2]); + if( !ret ) { + fprint("ļ﷨:%s %d\n",filename,linenum); + TITLE_initTitleData( titlecfg_readlen); + errflg = TRUE; + break; + } + + /*TITLE_ConfigTable[titlecfg_readlen].param[i-1] + = atoi( &token[comppos+2]);*/ + TITLE_ConfigTable[titlecfg_readlen].compareflg[i-1] = j; + } + } + else { + ret = TITLE_getParamData( titlecfg_readlen,i-1,&token[comppos+1]); + if( !ret ) { + fprint("ļ﷨:%s %d\n",filename,linenum); + TITLE_initTitleData( titlecfg_readlen); + errflg = TRUE; + break; + } + /*TITLE_ConfigTable[titlecfg_readlen].param[i-1] + = atoi( &token[comppos+1]);*/ + /* ئ ʤë */ + for( j = 3; j < 6; j ++ ) { + if( memcmp( TITLE_compare[j].compare, &token[comppos], 1 ) == 0 ) { + TITLE_ConfigTable[titlecfg_readlen].compareflg[i-1] = j; + break; + } + } + } + } + } + /* į ϶û or ئϾռ޷¡*/ + if( errflg || TITLE_ConfigTable[titlecfg_readlen].title == -1 ) { + fprint("ļ﷨:%s %d\n",filename,linenum); + TITLE_initTitleData( titlecfg_readlen); + } + else { + titlecfg_readlen ++; + } +} + } + fclose(f); + + TITLE_titlecfgnum = titlecfg_readlen; + + print( "Чͷ %d...", TITLE_titlecfgnum ); + + return TRUE; +} +/*------------------------------------------------------------ + * įɬñƩͻįëܸ£ + * ¦ + * charaindex int ƽҷ̼͵ + * mode BOOL TRUE:item=ּƩ FALSE: + * ߯Ի + * TRUE: į Ի + * FALSE: ף + *------------------------------------------------------------*/ +static BOOL TITLE_TitleCheck_Main( int charaindex, BOOL mode, int *addcnt, int *delcnt) +{ + int i, j,k, ret; + + /* */ +{ + int i; + for( i = 0; i < TITLE_titlecfgnum && TITLE_configbuf[i].title != -1; i ++ ) { + TITLE_configbuf[i].title = -1; + TITLE_configbuf[i].flg = 0; + } +} + *addcnt = 0; + *delcnt = 0; + + for( i = 0; i < TITLE_titlecfgnum; i ++ ) { + int rc = TRUE; + int title = TITLE_ConfigTable[i].title; + if( mode == TRUE ) { + if( TITLE_ConfigTable[i].equipcheckflg != TRUE ) { + continue; + } + } + for( j = 0; + j < arraysizeof( TITLE_ConfigTable[i].param) && + TITLE_ConfigTable[i].param[j][0] != -1 ; + j ++ ) + { + int index = TITLE_ConfigTable[i].paramindex[j]; + if( TITLE_param[index].checkfunc != NULL ) { + rc = TITLE_param[index].checkfunc( + charaindex, + TITLE_param[index].element, + TITLE_ConfigTable[i].param[j], + TITLE_ConfigTable[i].compareflg[j] + ); + if( rc != TRUE ) break; + } + } + /* ԪįԻ񲻯ľݼб + * add,deltile + */ + for( k = 0; k < TITLE_titlecfgnum; k ++ ) { + if( TITLE_configbuf[k].title == title ) { + if( rc ) { + TITLE_configbuf[k].flg = 1; + } + break; + } + else if( TITLE_configbuf[k].title == -1 ) { + TITLE_configbuf[k].title = title; + TITLE_configbuf[k].flg = rc ? 1: -1; + break; + } + } + } + ret = FALSE; + for( i = 0; i < TITLE_titlecfgnum && TITLE_configbuf[i].title != -1; i ++ ) { + if( TITLE_configbuf[i].flg == -1 ) { + *delcnt += TITLE_deltitle( charaindex, TITLE_configbuf[i].title); + } + else { + *addcnt += TITLE_addtitle( charaindex, TITLE_configbuf[i].title) ? 1:0; + } + } + if( *delcnt > 0 || *addcnt > 0) { + ret = TRUE; + } + return ret; + +} +/*------------------------------------------------------------ + * įɬñƩͻįëܸ£ + * ¦ + * charaindex int ƽҷ̼͵ + * mode BOOL TRUE:item=ּƩ FALSE: + * ߯Ի + * TRUE: į Ի + * FALSE: ף + *------------------------------------------------------------*/ +BOOL TITLE_TitleCheck( int charaindex, BOOL mode) +{ +#define TITLE_MSGUNIT1 "TSU" +#define TITLE_MSGUNIT2 "KO" + int addcnt,delcnt; + BOOL rc; + char msgbuf[64]; + rc = TITLE_TitleCheck_Main( charaindex, mode, &addcnt,&delcnt); + if( rc ) { + if( delcnt > 0 ) { + snprintf( msgbuf, sizeof( msgbuf), + "ʧȥ%d%s ƺţ", delcnt, + delcnt < 10 ? TITLE_MSGUNIT1:TITLE_MSGUNIT2); + CHAR_talkToCli( charaindex, -1, msgbuf, CHAR_COLORYELLOW); + } + if( addcnt > 0 ) { + snprintf( msgbuf, sizeof( msgbuf), + "%d%s ƺţ", addcnt, + addcnt < 10 ? TITLE_MSGUNIT1:TITLE_MSGUNIT2); + CHAR_talkToCli( charaindex, -1, msgbuf, CHAR_COLORYELLOW); + } + } + return rc; +} +/*------------------------------------------------------------ + * įɬñƩͻįëܸ£ + * ¦ + * charaindex int ƽҷ̼͵ + * mode BOOL TRUE:item=ּƩ FALSE: + * ߯Ի + * TRUE: į Ի + * FALSE: ף + *------------------------------------------------------------*/ +BOOL TITLE_TitleCheck_Nomsg( int charaindex, BOOL mode, int *addcnt, int *delcnt) +{ + return( TITLE_TitleCheck_Main( charaindex, mode, addcnt,delcnt)); +} + + +static int TITLE_IntCheck( int charaindex, int elem, int *data, int flg) +{ + int rc = FALSE; + int i; + for( i = 0; i < TITLE_PARAMSIZE && *(data+i) != -1; i ++ ) { + switch( flg) { + case 0: /* "<=" */ + if( CHAR_getInt( charaindex, elem) <= *(data+i) ) rc = TRUE; + break; + case 1: /* ">=" */ + if( CHAR_getInt( charaindex, elem) >= *(data+i) ) rc = TRUE; + break; + case 2: /* "<>" */ + if( CHAR_getInt( charaindex, elem) != *(data+i) ) rc = TRUE; + break; + case 3: /* ">" */ + if( CHAR_getInt( charaindex, elem) > *(data+i) ) rc = TRUE; + break; + case 4: /* "<" */ + if( CHAR_getInt( charaindex, elem) < *(data+i) ) rc = TRUE; + break; + case 5: /* "=" */ + if( CHAR_getInt( charaindex, elem) == *(data+i) ) rc = TRUE; + break; + default: + rc= FALSE; + break; + } + if( rc) break; + } + return rc; +} +static int TITLE_WorkIntCheck( int charaindex,int elem, int *data, int flg) +{ + int rc = FALSE; + int i; + for( i = 0; i < TITLE_PARAMSIZE && *(data+i) != -1; i ++ ) { + switch( flg) { + case 0: /* "<=" */ + if( CHAR_getWorkInt( charaindex, elem) <= *(data+i) ) rc = TRUE; + break; + case 1: /* ">=" */ + if( CHAR_getWorkInt( charaindex, elem) >= *(data+i) ) rc = TRUE; + break; + case 2: /* "<>" */ + if( CHAR_getWorkInt( charaindex, elem) != *(data+i) ) rc = TRUE; + break; + case 3: /* ">" */ + if( CHAR_getWorkInt( charaindex, elem) > *(data +i)) rc = TRUE; + break; + case 4: /* "<" */ + if( CHAR_getWorkInt( charaindex, elem) < *(data+i) ) rc = TRUE; + break; + case 5: /* "=" */ + if( CHAR_getWorkInt( charaindex, elem) == *(data+i) ) rc = TRUE; + break; + default: + rc= FALSE; + break; + } + if( rc ) break; + } + return rc; +} +/* -------------------------------------- + * ϶ýľdata Ȼʧ ةë ʤ£ + * -------------------------------------*/ +static int TITLE_ItemCheckMain( int charaindex, int itemhaveindex, int *data, int flg) +{ + int i,j; + int rc = FALSE; + + if( flg == 2 ) rc = TRUE; + + for( j = 0; j < TITLE_PARAMSIZE && *(data+j) != -1; j ++ ) { + for( i =0; i < itemhaveindex; i ++ ) { + int itemindex = CHAR_getItemIndex(charaindex,i); + if( ITEM_CHECKINDEX(itemindex) ) { + switch( flg) { + case 0: /* "<=" */ + if( ITEM_getInt( itemindex, ITEM_ID) <= *(data+j) ) rc = TRUE; + break; + case 1: /* ">=" */ + if( ITEM_getInt( itemindex, ITEM_ID) >= *(data+j) ) rc = TRUE; + break; + case 3: /* ">" */ + if( ITEM_getInt( itemindex, ITEM_ID) > *(data +j)) rc = TRUE; + break; + case 4: /* "<" */ + if( ITEM_getInt( itemindex, ITEM_ID) < *(data +j)) rc = TRUE; + break; + case 5: /* "=" */ + if( ITEM_getInt( itemindex, ITEM_ID) == *(data +j)) rc = TRUE; + break; + /* ľ У + * ʧ ة ëέľë Ȼئީ£ + * ƥ Ȼëƻ + */ + case 2: /* "<>" */ + if( ITEM_getInt( itemindex, ITEM_ID) == *(data +j)) rc = FALSE; + break; + default: + rc= FALSE; + break; + } + if( rc && flg != 2) break; + } + } + if( rc) break; + } + return rc; +} + + +static int TITLE_ItemCheck( int charaindex,int elem, int *data, int flg) +{ + return( TITLE_ItemCheckMain( charaindex, CHAR_MAXITEMHAVE,data,flg)); +} + +static int TITLE_ItemEquipCheck( int charaindex,int elem, int *data, int flg) +{ + return( TITLE_ItemCheckMain( charaindex, CHAR_EQUIPPLACENUM,data,flg)); +} + +static int TITLE_SkillCheck( int charaindex,int elem, int *data, int flg) +{ + int i; + int rc = FALSE; + CHAR_HaveSkill* hskill; + + for( i = 0 ; i < CHAR_SKILLMAXHAVE ; i ++ ){ + hskill = CHAR_getCharHaveSkill( charaindex, i ); + if( hskill != NULL && hskill->use == TRUE ) { + + if( *(data + 1) != -2 ) { + if( SKILL_getInt( &hskill->skill, SKILL_IDENTITY) == *data) { + rc = TRUE; + break; + } + } + + else { + if( SKILL_getInt( &hskill->skill, SKILL_IDENTITY) == *data) { + rc = FALSE; + break; + } + else { + rc = TRUE; + } + } + } + } + if( rc ) { + + if( *(data+1) != -1 && *(data+1) != -2) { + rc = FALSE; + switch( flg) { + case 0: /* "<=" */ + if( SKILL_getInt( &hskill->skill, SKILL_LEVEL) <= *(data+1) ) rc = TRUE; + break; + case 1: /* ">=" */ + if( SKILL_getInt( &hskill->skill, SKILL_LEVEL) >= *(data+1) ) rc = TRUE; + break; + case 2: /* "<>" */ + if( SKILL_getInt( &hskill->skill, SKILL_LEVEL) != *(data+1) ) rc = TRUE; + break; + case 3: /* ">" */ + if( SKILL_getInt( &hskill->skill, SKILL_LEVEL) > *(data +1)) rc = TRUE; + break; + case 4: /* "<" */ + if( SKILL_getInt( &hskill->skill, SKILL_LEVEL) < *(data+1) ) rc = TRUE; + break; + case 5: /* "=" */ + if( SKILL_getInt( &hskill->skill, SKILL_LEVEL) == *(data+1) ) rc = TRUE; + break; + default: + rc= FALSE; + break; + } + } + } + return rc; +} +/* -------------------------------------- + * ƽҷ¾ƽҷ¾£ + * -------------------------------------*/ +static int TITLE_SexCheck( int charaindex,int elem, int *data, int flg) +{ + int i,j; + struct { + int sex[25]; + }s_sex[] = + { { { 30008,30009,30010,30011,30012,30013,30014,30015, + 30020,30021,30022,30023,30024,30025,30026,30027, + 30028,30029,30030,30031,30032,30033,30034,30035,-1} + }, + { {30000,30001,30002,30003,30004,30005,30006,30007, + 30016,30017,30018,30019,30036,30037,30038,30039, + -1, -1, -1, -1, -1, -1, -1, -1, -1} + } + }; + for( i = 0; i < 2; i ++ ) { + for( j = 0; s_sex[i].sex[j] != -1 ; j ++ ) { + if( CHAR_getInt( charaindex, CHAR_BASEBASEIMAGENUMBER ) + == s_sex[i].sex[j] ) + { + if( i == *data ) return TRUE; + else return FALSE; + } + } + } + return FALSE; +} + + diff --git a/char/trade.c b/char/trade.c new file mode 100644 index 0000000..bba10e0 --- /dev/null +++ b/char/trade.c @@ -0,0 +1,2322 @@ +#include "version.h" +#include "correct_bug.h" +#include +#include +#include + +#include "readmap.h" +#include "object.h" +#include "char.h" +#include "char_base.h" +#include "lssproto_serv.h" +#include "npcutil.h" +#include "trade.h" +#include "log.h" +#include "handletime.h" +#include "buf.h" +#include "net.h" +#include "char_base.h" +#include "battle.h" +#include "npc_bus.h" +#include "char_talk.h" +#include "magic_base.h" +#ifdef _TRADESYSTEM2 // (ɿ) Syu ADD ½ϵͳ +#include "pet_skill.h" +#endif +#ifdef _PET_AMOI__E +#include "pet.h" +#endif + +#define TRADE_WAIT "Ժ%sС" +#define TRADE_NONE "ǰʲҲûУ" +#define TRADE_OVERPLAYER "ǰֻһλร" +#define TRADE_NOWILL "DZǸԷԸ㽻ף" +#define TRADE_TRADING "%s˽ס" +#define TRADE_VANISHITEM "ڵϻʧƷ޷ף" +#define TRADE_PETFULL "%sȡ" +#define TRADE_ITEMFULL "%sƷٽס" +#define TRADE_CANCEL "%sȡˣ" +#define TRADE_POOR "%sǮ޷ף" +#define TRADE_RICH "%sǮ𳬹һ" +#define TRADE_TOORICH "%sǮᳬһ" +#define TRADE_POORLV "%sȼ޷չ˽ij" +#define TRADE_LOCK "" +#define TRADE_SUCCESS "ףϣˣ" +#define TRADE_FAILED "ʧܣ" +#define TRADE_FMPET "ػ޷ף" + +#define TRADE_RDCANCEL "ȡ" +#ifdef _TRADE_PK +#define TRADE_PK_START "ʼPK" +#endif +#ifdef _LOCK_PET_ITEM +#define TRADE_LOCKPET "󶨵ij޷ף" +#define TRADE_LOCKITEM "󶨵ĵ޷ף" +#endif + +#ifdef _ITEM_PILEFORTRADE +enum{ + TRADE_ITEM=0, + TRADE_PET, + TRADE_GOLD, +}; + +#define MAX_TRADELISTNUM 100 +typedef struct _tagTradeList{ + int charaindex; + int fd; + int PetTi[5]; + int ItemTi[15]; + int ItemNum[15]; + int Golds; + int use; +}STradeList; + +STradeList TradeList[MAX_TRADELISTNUM][2]; +STradeList TradeListPk[2]; +int meindexpk,toindexpk; + +void TRADE_ResetTradeList( int ti); +int TRADE_getTradeListIndex( void); +int TRADE_getMyTarget( int meindex ); +BOOL TRADE_setTradeListIndex( int ti, int meindex, int toindex); +BOOL TRADE_addSomeTradeList( int meindex, int usTi, int *num, int type); +BOOL TRADE_getSomeTradeList( int meindex, STradeList *temp); + +void TRADE_InitTradeList( void) +{ + int i; + print("ʼϵͳ..."); + for( i=0; i= MAX_TRADELISTNUM )return; + for( i=0; i<5; i++){ + TradeList[ti][0].PetTi[i] = -1; + TradeList[ti][1].PetTi[i] = -1; + } + for( i=0; i<15; i++){ + TradeList[ti][0].ItemTi[i] = -1; + TradeList[ti][0].ItemNum[i] = -1; + TradeList[ti][1].ItemTi[i] = -1; + TradeList[ti][1].ItemNum[i] = -1; + } + + TradeList[ti][0].Golds = 0; + TradeList[ti][1].Golds = 0; + + + if( CHAR_CHECKINDEX(TradeList[ti][0].charaindex)){ + fd = getfdFromCharaIndex( TradeList[ti][0].charaindex); + CONNECT_setTradeList( fd, -1); + } + if( CHAR_CHECKINDEX(TradeList[ti][1].charaindex)){ + fd = getfdFromCharaIndex( TradeList[ti][1].charaindex); + CONNECT_setTradeList( fd, -1); + } + + TradeList[ti][0].charaindex = -1; + TradeList[ti][1].charaindex = -1; + TradeList[ti][0].fd = -1; + TradeList[ti][1].fd = -1; + + TradeList[ti][0].use = 0; + TradeList[ti][1].use = 0; + +} + +int TRADE_getTradeListIndex( void) +{ + int i; + static int tradeTi=0; + if( tradeTi < 0 ) tradeTi = 0; + for( i=0; i= MAX_TRADELISTNUM ) tradeTi = 0; + + } + return -1; +} + +BOOL TRADE_setTradeListIndex( int ti, int meindex, int toindex) +{ + int fd; + if( ti<0 || ti >= MAX_TRADELISTNUM ) return FALSE; + if( TradeList[ti][0].use == 1 || TradeList[ti][1].use == 1 ) return FALSE; + TRADE_ResetTradeList( ti); + TradeList[ti][0].charaindex = meindex; + TradeList[ti][1].charaindex = toindex; + TradeList[ti][0].use = 1; + TradeList[ti][1].use = 1; + + fd = getfdFromCharaIndex( meindex); + TradeList[ti][0].fd = fd; + CONNECT_setTradeList( fd, ti); + + fd = getfdFromCharaIndex( toindex); + TradeList[ti][1].fd = fd; + CONNECT_setTradeList( fd, ti); + return TRUE; +} + +void TRADE_CheckTradeListUser( void) +{ + int i, usenum=0, replace=0, freenum=0; + for( i=0; i= MAX_TRADELISTNUM ) return -1; + if( TradeList[ti][0].use == 0 || TradeList[ti][1].use == 0 ) return -1; + + for( i=0; i<2; i++){ + if( TradeList[ti][i].charaindex == meindex && + TradeList[ti][i].fd == fd ){ + side = (i+1)%2; + if( !CHAR_CHECKINDEX( TradeList[ti][side].charaindex) ) return -1; + if( TradeList[ti][side].charaindex == meindex ) return -1; + if( TradeList[ti][side].fd != getfdFromCharaIndex( TradeList[ti][side].charaindex) ) return -1; + + return TradeList[ti][side].charaindex; + } + } + return -1; +} + +BOOL TRADE_addSomeTradeList( int meindex, int usTi, int *num, int type) +{ + int i, fd, ti, side=-1, toindex=-1; + fd = getfdFromCharaIndex( meindex); + ti = CONNECT_getTradeList( fd); + if( ti <0 || ti >= MAX_TRADELISTNUM ) return FALSE; + toindex =-1; + if( TradeList[ti][0].use != 1 || TradeList[ti][1].use != 1 ) return FALSE; + for( i=0; i<2; i++){ + if( TradeList[ti][i].charaindex != meindex ){ + continue; + } + side = i; + toindex = TradeList[ti][((side+1)%2)].charaindex; + if( !CHAR_CHECKINDEX( toindex) ) return FALSE; + break; + } + if( side == -1 ) return FALSE; + switch( type){ + case TRADE_ITEM: + { + int itemindex, MeMaxPile; + MeMaxPile = CHAR_getMyMaxPilenum( meindex);//ѵ + if( usTi < CHAR_STARTITEMARRAY || usTi >= CHAR_MAXITEMHAVE ) return FALSE; + itemindex = CHAR_getItemIndex( meindex, usTi ); +//ǰ󶨵ĵ򲻿ڽ +#ifdef _PETITEM__AMOI_E + if(ITEM_NOT_TRADE & ITEM_getInt(itemindex, ITEM_TYPEOFITEM)){ + char buf[256]; + sprintf( buf, "%s޷ס", ITEM_getChar( itemindex, ITEM_NAME) ); + CHAR_talkToCli( meindex, -1, buf, CHAR_COLORRED); + return FALSE; + } +#endif + if( !ITEM_CHECKINDEX( itemindex)) return FALSE; + + if( ITEM_getInt( itemindex, ITEM_VANISHATDROP) == 1 || ITEM_getInt( itemindex, ITEM_TIME) > 0){ + char buf[256]; + sprintf( buf, "%s޷ס", ITEM_getChar( itemindex, ITEM_NAME) ); + CHAR_talkToCli( meindex, -1, buf, CHAR_COLORYELLOW); + return FALSE; + } +#ifdef _ZHIPIAO_SYSTEM + if( strstr(ITEM_getChar(itemindex,ITEM_NAME),"֧Ʊ")!=NULL && strstr(ITEM_getChar(itemindex,ITEM_NAME),"DP֧Ʊ")==NULL ){ + int zhipiaoindex=atoi(ITEM_getChar(itemindex,ITEM_ARGUMENT)); + if(zhipiaoindex>0){ + time_t timep; + struct tm *p; + time(&timep); + p=localtime(&timep); + timep = mktime(p); + if(timep>zhipiaoindex){ + CHAR_talkToCli(meindex, -1, "֧ƱѾڣ޷ף뾡ʹã", CHAR_COLORYELLOW); + return FALSE; + } + } + } +#endif +#ifdef _LOCK_PET_ITEM + char *arg = ITEM_getChar(itemindex, ITEM_NAME); + if(arg[0] == '*'){ + char buf[256]; + sprintf( buf, "%s޷ס", ITEM_getChar( itemindex, ITEM_NAME) ); + CHAR_talkToCli( meindex, -1, buf, CHAR_COLORYELLOW); + return FALSE; + } +#endif + if( ITEM_getInt( itemindex, ITEM_CANBEPILE) == 1 ){//ɶѵ + int itemMaxPile = ITEM_getInt( itemindex, ITEM_USEPILENUMS); + if( itemMaxPile < 0 ) return FALSE; + //ITEM_USEPILENUMS + for( i=0; i<15; i++){ + if( TradeList[ti][side].ItemTi[i] != usTi ) continue; + if( TradeList[ti][side].ItemNum[i] >= MeMaxPile || + TradeList[ti][side].ItemNum[i] >= itemMaxPile ) return FALSE; + + TradeList[ti][side].ItemNum[i] += 1; + if( num != NULL ) *num = TradeList[ti][side].ItemNum[i]; + return TRUE; + } + } + for( i=0; i<15; i++){ + if( TradeList[ti][side].ItemTi[i] != -1 ) continue; + TradeList[ti][side].ItemTi[i] = usTi; + TradeList[ti][side].ItemNum[i] = 1; + if( num != NULL ) *num = TradeList[ti][side].ItemNum[i]; + return TRUE; + } + } + break; + case TRADE_PET: + { + int petindex; + if( usTi < 0 || usTi >= CHAR_MAXPETHAVE ) return FALSE; + petindex = CHAR_getCharPet( meindex, usTi ); + if( !CHAR_CHECKINDEX(petindex)) return FALSE; + if( CHAR_getInt( petindex, CHAR_PETFAMILY) == 1 ){ + CHAR_talkToCli( meindex, -1, "ػ޷ס", CHAR_COLORYELLOW); + return FALSE;//ػ + } + if( CHAR_getWorkInt( toindex, CHAR_PickAllPet) != TRUE ){ + if( CHAR_getInt( petindex, CHAR_LV) > (CHAR_getInt( toindex, CHAR_LV)+5) && + (CHAR_getInt( toindex, CHAR_TRANSMIGRATION ) <= 0 ) ){ + CHAR_talkToCli( meindex, -1, "Է޷չ˸ó", CHAR_COLORYELLOW); + return FALSE; + } + } +//ǰ󶨵ij򲻿ɽ +#ifdef _PET_AMOI__E + //if( PET_NOT_DropTradeStreetVandor== EVOLUTION_getPetENABLETRADE( CHAR_getInt( petindex, CHAR_PETID)) || + // PET_NOT_Trade == EVOLUTION_getPetENABLETRADE( CHAR_getInt( petindex, CHAR_PETID))|| + // PET_NOT_TradeAndStreetVandor == EVOLUTION_getPetENABLETRADE( CHAR_getInt( petindex, CHAR_PETID))){ + if( ( PET_NOT_TRADE) & EVOLUTION_getPetENABLETRADE( CHAR_getInt( petindex, CHAR_PETID))){ + + CHAR_talkToCli(meindex,-1,"ó޷!~",CHAR_COLORRED); + return FALSE; + } +#endif +#ifdef _PET_BUG + if( CHAR_getInt( petindex, CHAR_VITAL)>=getPetPoint(0)*20 || CHAR_getInt(petindex,CHAR_STR)>=getPetPoint(1)*80 || CHAR_getInt(petindex,CHAR_TOUGH)>=getPetPoint(2)*80 || CHAR_getInt(petindex,CHAR_DEX)>=getPetPoint(3)*100){ + CHAR_talkToCli( meindex, -1, "Թ޷ס", CHAR_COLORYELLOW); + return FALSE;//Թ + } +#endif + if(strlen(CHAR_getChar(petindex,CHAR_USERPETNAME))>0 && strstr(CHAR_getChar(petindex,CHAR_USERPETNAME),"*")!=NULL){ + CHAR_talkToCli(meindex, -1, "Զк(*)޷ꡢס̯޸ĺ", CHAR_COLORYELLOW); + return FALSE; + } +#ifdef _PETSKILL_BINDING + int pi,skillid=-1,skillarray; + for(pi=0;pi<7;pi++){ + skillid=CHAR_getPetSkill(petindex,pi); + skillarray = PETSKILL_getPetskillArray( skillid); + if( PETSKILL_CHECKINDEX( skillarray) == FALSE ) continue; + if(strstr(PETSKILL_getChar( skillarray, PETSKILL_NAME),"")){ + CHAR_talkToCli(meindex, -1, "˳Ϊ󶨳޷", CHAR_COLORRED); + return FALSE; + } + } +#endif +#ifdef _PET_BINDING + if(strstr(CHAR_getChar(petindex,CHAR_NAME),"*") || strstr(CHAR_getChar(petindex,CHAR_NAME),"+")){ + CHAR_talkToCli(meindex, -1, "˳Ϊ󶨳޷", CHAR_COLORRED); + return FALSE; + } +#endif + for( i=0; i<5; i++){ + if( TradeList[ti][side].PetTi[i] == usTi ) return FALSE; + } + for( i=0; i<5; i++){ + if( TradeList[ti][side].PetTi[i] != -1 ) continue; + TradeList[ti][side].PetTi[i] = usTi; + return TRUE; + } + } + break; + case TRADE_GOLD: + TradeList[ti][side].Golds = usTi; + return TRUE; + break; + } + + return FALSE; +} + +BOOL TRADE_getSomeTradeList( int meindex, STradeList *temp) +{ + int i, fd, ti, side=-1; + fd = getfdFromCharaIndex( meindex); + ti = CONNECT_getTradeList( fd); + if( ti <0 || ti >= MAX_TRADELISTNUM ) return FALSE; + if( TradeList[ti][0].use != 1 || TradeList[ti][1].use != 1 ) return FALSE; + for( i=0; i<2; i++){ + if( TradeList[ti][i].charaindex != meindex ) continue; + side = i; + break; + } + if( side == -1 ) return FALSE; + + memcpy( temp, &TradeList[ti][side], sizeof( STradeList) ); + return TRUE; +} +BOOL TRADE_CheckTradeList( int meindex, STradeList *temp1, int toindex, STradeList *temp2); +#endif + +void TRADE_Will(int fd, int meindex, char* message); +void TRADE_ShowItem(int fd, int meindex, char* message); +void TRADE_Close(int fd, int meindex, char* message); + +void TRADE_SwapItem(int meindex, int toindex, char* message, int fd, char* mycharaname, int tofd, char* tocharaname); + +int TRADE_CheckItembuf(int fd, int meindex, int toindex, int tofd, char* mycharaname, char* tocharaname); +//BOOL TRADE_ChangeItem(int meindex, int toindex, char *a, char *b, int item1, int item2, int itemindex1, int itemindex2); +BOOL TRADE_HandleItem( int meindex, int showindex, char *message, char *outmess); +BOOL TRADE_HandleGold( int meindex, int showindex, char *message, char *outmess); +BOOL TRADE_HandlePet( int meindex, int showindex, char *message, char *outmess); + + + +void CHAR_Trade(int fd, int index, char* message) +{ + char firstToken[64]; + // shan עDzҪĶ 2002/03/05 + //char messageeraseescape[512]; + char* messagebody; + + { + if (*message == 0) return; + if (!CHAR_CHECKINDEX(index)) return; + if (CHAR_getWorkInt( index, CHAR_WORKSAFEMODE)==0) + { + CHAR_SafePassword(index); + return; + } + + CHAR_getMessageBody( message, firstToken, sizeof(firstToken), &messagebody); + + switch( tolower( firstToken[0]) ){ + case 'd': // Ѱǰ + + TRADE_Search(fd, index, message); + break; +/* case 'c': + TRADE_Will(fd, index, message); + break; +*/ case 't': // ʾ׵ƷǮ + TRADE_ShowItem(fd, index, message); + break; + case 'w': // رս + print(" TRADE_Close:%d ", index); + TRADE_Close(fd, index, message); + break; + default: + break; + } + } +} + +BOOL TRADE_Search(int fd, int meindex, char* message) +{ + int objbuf[16]; + int front_x, front_y, i, found_count; + BOOL found = FALSE, searchflg = FALSE; + int cnt = 0, tofd = -1, checkfd = -1; + char msgbuf[1024], mycharaname[256], tocharaname[256]; + char token[256]; + + if (!CHAR_CHECKINDEX(meindex)) return FALSE; + + // ״̬Ϊл账 + if (CHAR_getWorkInt(meindex, CHAR_WORKTRADEMODE) == CHAR_TRADE_TRADING + || CHAR_getWorkInt(meindex, CHAR_WORKTRADEMODE) == CHAR_TRADE_LOCK) + return FALSE; + + // ״̬Ϊӻս账 + if ((CHAR_getWorkInt(meindex, CHAR_WORKPARTYMODE) != CHAR_PARTY_NONE) + || (CHAR_getWorkInt(meindex, CHAR_WORKBATTLEMODE) != BATTLE_CHARMODE_NONE)) + return FALSE; + +#ifdef _STREET_VENDOR + // ڰ̯в + if(CHAR_getWorkInt(meindex,CHAR_WORKSTREETVENDOR) > -1) return FALSE; +#endif + + strcpy(mycharaname, CHAR_getChar(meindex, CHAR_NAME)); + + if (getStringFromIndexWithDelim(message, "|", 2, token, + sizeof(token)) == FALSE) return FALSE; + // 趨״̬ +// CHAR_setWorkInt(meindex, CHAR_WORKTRADEMODE, CHAR_TRADE_SENDING); + +#ifndef _ITEM_PILEFORTRADE + for (i = 0; i < CONNECT_WINDOWBUFSIZE; i++) + CONNECT_setTradecharaindex(fd, i, -1); +#endif + CHAR_getCoordinationDir(CHAR_getInt(meindex, CHAR_DIR), + CHAR_getInt(meindex, CHAR_X), + CHAR_getInt(meindex, CHAR_Y), + 1, &front_x, &front_y); + + found_count = CHAR_getSameCoordinateObjects( objbuf, arraysizeof(objbuf), + CHAR_getInt(meindex, CHAR_FLOOR),front_x, front_y); + // ǰûһԷرսѡ + if (found_count == 0){ + CHAR_talkToCli(meindex, -1, TRADE_NONE, CHAR_COLORYELLOW); + CHAR_setWorkInt(meindex, CHAR_WORKTRADEMODE, CHAR_TRADE_FREE); + return FALSE; + } + + for (i = 0; i < found_count; i++){ + int objindex = objbuf[i]; + int index = OBJECT_getIndex(objindex); + + if (OBJECT_getType(objindex) != OBJTYPE_CHARA) continue; + if (CHAR_getInt(index, CHAR_WHICHTYPE) != CHAR_TYPEPLAYER) continue; + if (index == meindex) continue; + found = TRUE; + if (CHAR_getWorkInt(index, CHAR_WORKBATTLEMODE) != BATTLE_CHARMODE_NONE) continue; + if (CHAR_getWorkInt(index, CHAR_WORKPARTYMODE) != CHAR_PARTY_NONE) continue; + if (CHAR_getFlg(index, CHAR_ISTRADE) == FALSE) continue; + if (CHAR_getWorkInt(index, CHAR_WORKTRADEMODE) != CHAR_TRADE_FREE) continue; + strcpy(tocharaname, CHAR_getChar(index, CHAR_NAME)); + tofd = getfdFromCharaIndex(index); + if (tofd == -1){ + CHAR_setWorkInt(meindex, CHAR_WORKTRADEMODE, CHAR_TRADE_FREE); + return FALSE; + } + if (searchflg){ + if (tofd != checkfd) continue; + if (strcmp(token, tocharaname) != 0) continue; + } +#ifndef _ITEM_PILEFORTRADE + CONNECT_setTradecharaindex(fd, cnt, index); +#endif + cnt ++; + if (cnt == CONNECT_WINDOWBUFSIZE) break; + } + + if (cnt == 0){ + // ǰûһԷرսѡ + if (found){ + CHAR_talkToCli(meindex, -1, TRADE_NOWILL, CHAR_COLORYELLOW); + }else + CHAR_talkToCli(meindex, -1, TRADE_NONE, CHAR_COLORYELLOW); + + sprintf(msgbuf, "C|%d|%s|0", tofd, tocharaname); + CHAR_setWorkInt(meindex, CHAR_WORKTRADEMODE, CHAR_TRADE_FREE); + return FALSE; + } + // ǰһλ + if (cnt == 1){ +#ifdef _ITEM_PILEFORTRADE + int ti; +#endif + int toindex; + toindex = CONNECT_getCharaindex(tofd); + if( !CHAR_CHECKINDEX(toindex)) return FALSE; +#ifdef _ITEM_PILEFORTRADE + + if( (ti = TRADE_getTradeListIndex()) < 0 || + TRADE_setTradeListIndex( ti, meindex, toindex) == FALSE ){ + + CHAR_talkToCli( meindex, -1, "ϵͳæµС", CHAR_COLORYELLOW); + CHAR_setWorkInt( meindex, CHAR_WORKTRADEMODE, CHAR_TRADE_FREE); + TRADE_CheckTradeListUser(); + + return FALSE; + } + TRADE_setTradeListIndex( ti, meindex, toindex); +#endif + snprintf(msgbuf, sizeof(msgbuf), TRADE_WAIT, tocharaname); + CHAR_talkToCli(meindex, -1, msgbuf, CHAR_COLORYELLOW); + + sprintf(msgbuf, "C|%d|%s|1", fd, mycharaname); + lssproto_TD_send( tofd, -1, msgbuf); + sprintf(msgbuf, "C|%d|%s|1", tofd, tocharaname); + lssproto_TD_send(fd, -1, msgbuf); + + CHAR_setWorkInt(meindex, CHAR_WORKTRADEMODE, CHAR_TRADE_TRADING); + CHAR_setWorkInt(toindex, CHAR_WORKTRADEMODE, CHAR_TRADE_TRADING); + + CONNECT_set_confirm(fd, FALSE); + CONNECT_set_confirm(tofd, FALSE); + + CHAR_sendTradeEffect(meindex, 1); + CHAR_sendTradeEffect(toindex, 1); + return TRUE; + }else if (cnt > 1){ // ǰֻһλ + CHAR_talkToCli(meindex, -1, TRADE_OVERPLAYER, CHAR_COLORYELLOW); +// sprintf(msgbuf, "C|%d|%s|0", tofd, tocharaname); + CHAR_setWorkInt(meindex, CHAR_WORKTRADEMODE, CHAR_TRADE_FREE); + return FALSE; + } + + CHAR_setWorkInt(meindex, CHAR_WORKTRADEMODE, CHAR_TRADE_FREE); + return FALSE; +} + +void TRADE_Close(int fd, int meindex, char* message) +{ + char msg[128], mycharaname[256]; + int tofd=-1, toindex=-1; + int j; +#ifndef _ITEM_PILEFORTRADE + char token[256]; +#endif + if (!CHAR_CHECKINDEX(meindex)) return; + if (*message == 0) return; + strcpy(mycharaname, CHAR_getChar(meindex, CHAR_NAME)); +#ifdef _ITEM_PILEFORTRADE + toindex = TRADE_getMyTarget( meindex); + + if( CHAR_CHECKINDEX( toindex) ){ + tofd = getfdFromCharaIndex( toindex); + snprintf( msg, sizeof(msg), TRADE_CANCEL, mycharaname); + CHAR_talkToCli(toindex, -1, msg, CHAR_COLORYELLOW); + snprintf( msg, sizeof(msg), "W|%d|%s", fd, mycharaname); + lssproto_TD_send( tofd, -1, msg); + + CHAR_setWorkInt( toindex, CHAR_WORKTRADEMODE, CHAR_TRADE_FREE); + CONNECT_setTradeTmp( tofd, ""); + CHAR_sendStatusString( toindex, "i"); + CHAR_sendStatusString( toindex, "P"); + CHAR_sendTradeEffect( toindex, 0); + CONNECT_set_confirm( tofd, FALSE); + + for(j = 0; j < CHAR_MAXPETHAVE; j++){ + char msgbuf[256]; + int petindex = CHAR_getCharPet( toindex, j); + if( !CHAR_CHECKINDEX( petindex) ) continue; + CHAR_complianceParameter( petindex ); + snprintf( msgbuf, sizeof( msgbuf ), "K%d", j ); + CHAR_sendStatusString( toindex, msgbuf ); + snprintf( msgbuf, sizeof( msgbuf ), "W%d", j ); + CHAR_sendStatusString( toindex, msgbuf ); + } + } + +#else + if (getStringFromIndexWithDelim(message, "|", 2, token, sizeof(token)) == FALSE) return; + tofd = atoi(token); + toindex = CONNECT_getCharaindex(tofd); + if (!CHAR_CHECKINDEX(toindex)) return; + if (getStringFromIndexWithDelim(message, "|", 3, token, sizeof(token)) == FALSE) return; + + + snprintf(msg, sizeof(msg), TRADE_CANCEL, mycharaname); + CHAR_talkToCli(toindex, -1, msg, CHAR_COLORYELLOW); + snprintf( msg, sizeof(msg), "W|%d|%s", fd, mycharaname); + lssproto_TD_send( tofd, -1, msg); + + CHAR_setWorkInt(toindex, CHAR_WORKTRADEMODE, CHAR_TRADE_FREE); + CONNECT_setTradeTmp(tofd, ""); + CHAR_sendStatusString( CONNECT_getCharaindex(tofd), "i"); + CHAR_sendStatusString( CONNECT_getCharaindex(tofd), "P"); + CHAR_sendTradeEffect( toindex, 0); + CONNECT_set_confirm(tofd, FALSE); +#endif + + if( !CHAR_CHECKINDEX( toindex) ){ + char buf[256]; + if( getStringFromIndexWithDelim( message, "|", 2, buf, sizeof(buf)) == FALSE) return; + tofd = atoi( buf); + toindex = CONNECT_getCharaindex( tofd); + if (!CHAR_CHECKINDEX(toindex) )return; + } + + + snprintf( msg, sizeof(msg), TRADE_RDCANCEL); + CHAR_talkToCli(meindex, -1, msg, CHAR_COLORYELLOW); + snprintf( msg, sizeof(msg), "W|%d|%s", tofd, CHAR_getChar( toindex, CHAR_NAME) ); + lssproto_TD_send( fd, -1, msg); + + CHAR_setWorkInt( meindex, CHAR_WORKTRADEMODE, CHAR_TRADE_FREE); + CONNECT_setTradeTmp(fd, ""); + CHAR_sendStatusString(meindex, "i"); + CHAR_sendStatusString(meindex, "P"); + CHAR_sendTradeEffect( meindex, 0); + CONNECT_set_confirm(fd, FALSE); +// end + for(j = 0; j < CHAR_MAXPETHAVE; j++){ + char msgbuf[256]; + int petindex = CHAR_getCharPet( meindex, j); + if( !CHAR_CHECKINDEX( petindex) ) continue; + CHAR_complianceParameter( petindex ); + snprintf( msgbuf, sizeof( msgbuf ), "K%d", j ); + CHAR_sendStatusString( meindex, msgbuf ); + snprintf( msgbuf, sizeof( msgbuf ), "W%d", j ); + CHAR_sendStatusString( meindex, msgbuf ); + } + +#ifdef _ITEM_PILEFORTRADE + { + int ti=0; + ti = CONNECT_getTradeList( fd); + if( ti <0 || ti >= MAX_TRADELISTNUM ) return; + TRADE_ResetTradeList( ti); + } +#endif + +} + +void TRADE_ShowItem(int fd, int meindex, char* message) +{ + char token[128], mycharaname[256], tocharaname[256], msg[2048]; + int tofd, showindex, toindex;// itemindex, gold, tmpgold, item; + + int MaxGold; + + MaxGold = CHAR_getMaxHaveGold( meindex); + strcpy( mycharaname, CHAR_getChar(meindex, CHAR_NAME)); +#ifdef _ITEM_PILEFORTRADE + toindex = TRADE_getMyTarget( meindex); + if( !CHAR_CHECKINDEX( toindex) ){ + print(" TRADE_Close_Err1:%d ", toindex); + TRADE_Close(fd, meindex, message); + return; + } + if( meindex != TRADE_getMyTarget( toindex) ){ + print(" TRADE_Close_Err2:%d->%d ", meindex, toindex); + TRADE_Close(fd, meindex, message); + return; + } + tofd = getfdFromCharaIndex(toindex); +#else + if (getStringFromIndexWithDelim(message, "|", 2, token, sizeof(token)) == FALSE) return; + tofd = atoi(token); + toindex = CONNECT_getCharaindex(tofd); +#endif + + if (!CHAR_CHECKINDEX(toindex)) return; + // ״̬Ϊӻս账 + if ((CHAR_getWorkInt(meindex, CHAR_WORKPARTYMODE) != CHAR_PARTY_NONE) + || (CHAR_getWorkInt(meindex, CHAR_WORKBATTLEMODE) != BATTLE_CHARMODE_NONE)) + return; + + if ((CHAR_getWorkInt(toindex, CHAR_WORKPARTYMODE) != CHAR_PARTY_NONE) + || (CHAR_getWorkInt(toindex, CHAR_WORKBATTLEMODE) != BATTLE_CHARMODE_NONE)) + return; + + if (getStringFromIndexWithDelim(message, "|", 3, tocharaname, sizeof(tocharaname)) == FALSE) return; + if (getStringFromIndexWithDelim(message, "|", 5, token, sizeof(token)) == FALSE) return; + showindex = atoi(token); + if (getStringFromIndexWithDelim(message, "|", 4, token, sizeof(token)) == FALSE) return; + + showindex = toindex; + strcpy( tocharaname, CHAR_getChar(toindex, CHAR_NAME)); + + switch(tolower(token[0])){ + case 'i': + { + char buf1[2048]; + if( TRADE_HandleItem( meindex, showindex, message, buf1) == FALSE ){ + print(" TRADE_Close_Err3:%d,%d,%s,%s ", meindex, showindex, message, buf1); + TRADE_Close(fd, meindex, message); + return; + }else{ + snprintf(msg, sizeof(msg), "T|%d|%s|I|%d|%s", fd, mycharaname, showindex, buf1 ); + lssproto_TD_send(tofd, -1, msg); + } + } + break; + case 'g': + { + char buf1[2048]; + if( TRADE_HandleGold( meindex, showindex, message, buf1) == FALSE ){ + print(" TRADE_Close_Err4:%d,%d,%s,%s ", meindex, showindex, message, buf1); + TRADE_Close(fd, meindex, message); + return; + }else{// ֮ǮԷ + snprintf(msg, sizeof(msg), "T|%d|%s|G|%d|%s", fd, mycharaname, showindex, buf1); + lssproto_TD_send( tofd, -1, msg); + } + } + break; + case 'p': + { + char buf1[2048]; + if( TRADE_HandlePet( meindex, showindex, message, buf1) == FALSE ){ + print(" TRADE_Close_Err5:%d,%d,%s,%s ", meindex, showindex, message, buf1); + TRADE_Close(fd, meindex, message); + return; + }else{ + snprintf(msg, sizeof(msg), "T|%d|%s|P|%d|%s", + fd, mycharaname, showindex, buf1); + lssproto_TD_send(tofd, -1, msg); + } + } + break; + case 'k': + if((CONNECT_get_confirm(fd)==TRUE) && + (CONNECT_get_confirm(tofd)==TRUE) ){//˫ lock + if( CHAR_getWorkInt(meindex, CHAR_WORKTRADEMODE) == CHAR_TRADE_LOCK ){ + //andy_log + print("ANDY err ֹڶν!!\n"); + return;//ֹڶν + } + CHAR_setWorkInt(meindex, CHAR_WORKTRADEMODE, CHAR_TRADE_LOCK); + //ԷǷ ok + if( CHAR_getWorkInt( toindex, CHAR_WORKTRADEMODE) != CHAR_TRADE_LOCK )return; + + snprintf(msg, sizeof(msg), "T|%d|%s|A", fd, mycharaname); + lssproto_TD_send( tofd, -1, msg); + TRADE_SwapItem(meindex, toindex, message, fd, mycharaname, tofd, tocharaname); + } + break; + case 'c': + if( CONNECT_get_confirm( fd) == TRUE ) return; + CONNECT_set_confirm(fd, TRUE); + snprintf( msg, sizeof(msg), "T|%d|%s|C", fd, mycharaname); + lssproto_TD_send( tofd, -1, msg); + break; + } + return; +} + +void TRADE_SwapItem( int meindex, int toindex, char* message, int fd, char* mycharaname, int tofd, char* tocharaname) +{ + int result; + char msg[128], tmpmsg[128]; + +#ifndef _ITEM_PILEFORTRADE + CONNECT_setTradeTmp(fd, message); +#endif + result = TRADE_CheckItembuf(fd, meindex, toindex, tofd, mycharaname, tocharaname); +#ifndef _ITEM_PILEFORTRADE + toindex = CONNECT_getCharaindex(tofd); +#endif + + if (!CHAR_CHECKINDEX(toindex)) return; + if (result == -1) + strcpy(msg, TRADE_FAILED); + else if (result == -2) + sprintf(msg, TRADE_ITEMFULL, mycharaname); + else if (result == -3) + sprintf(msg, TRADE_ITEMFULL, tocharaname); + else if (result == -4) + sprintf(msg, TRADE_RICH, mycharaname); + else if (result == -5) + sprintf(msg, TRADE_POOR, mycharaname); + else if (result == -6) + sprintf(msg, TRADE_RICH, tocharaname); + else if (result == -7) + sprintf(msg, TRADE_POOR, tocharaname); + else if (result == -8) + sprintf(msg, TRADE_TOORICH, mycharaname); + else if (result == -9) + sprintf(msg, TRADE_TOORICH, tocharaname); + else if (result == -10) + sprintf(msg, TRADE_PETFULL, mycharaname); + else if (result == -11) + sprintf(msg, TRADE_PETFULL, tocharaname); + else if (result == -12) + strcpy(msg, TRADE_VANISHITEM); + else if (result == -13) + sprintf(msg, TRADE_POORLV, mycharaname); + else if (result == -14) + sprintf(msg, TRADE_POORLV, tocharaname); + else if (result == -15) + strcpy(msg, TRADE_FMPET); +#ifdef _LOCK_PET_ITEM + else if (result == -16) + strcpy(msg, TRADE_LOCKPET); + else if (result == -17) + strcpy(msg, TRADE_LOCKITEM); +#endif + else if (result == 1) + strcpy(msg, TRADE_SUCCESS); + else if (result == 2) + strcpy(msg, TRADE_LOCK); + else if (result == 3) + strcpy(msg, TRADE_PK_START); + + if (result != 2){ + snprintf(tmpmsg, sizeof(tmpmsg), "W|%d|%s", fd, mycharaname); + lssproto_TD_send(tofd, -1, tmpmsg); + snprintf(tmpmsg, sizeof(tmpmsg), "W|%d|%s", tofd, tocharaname); + lssproto_TD_send(fd, -1, tmpmsg); + + CHAR_setWorkInt(meindex, CHAR_WORKTRADEMODE, CHAR_TRADE_FREE); + CHAR_setWorkInt(toindex, CHAR_WORKTRADEMODE, CHAR_TRADE_FREE); + CONNECT_setTradeTmp(fd, ""); + CONNECT_setTradeTmp(tofd, ""); + CHAR_sendTradeEffect( meindex, 0); + CHAR_sendTradeEffect( toindex, 0); + } + CHAR_sendStatusString(meindex, "i"); + CHAR_sendStatusString(toindex, "i"); + CHAR_sendStatusString(meindex, "P"); + CHAR_sendStatusString(toindex, "P"); + { + int j, petindex; + char msgbuf[256]; + for(j = 0; j < CHAR_MAXPETHAVE; j++){ + petindex = CHAR_getCharPet( meindex, j); + if( !CHAR_CHECKINDEX( petindex) ) continue; + CHAR_complianceParameter( petindex ); + snprintf( msgbuf, sizeof( msgbuf ), "K%d", j ); + CHAR_sendStatusString( meindex, msgbuf ); + snprintf( msgbuf, sizeof( msgbuf ), "W%d", j ); + CHAR_sendStatusString( meindex, msgbuf ); + } + for(j = 0; j < CHAR_MAXPETHAVE; j++){ + petindex = CHAR_getCharPet( toindex, j); + if( !CHAR_CHECKINDEX( petindex) ) continue; + CHAR_complianceParameter( petindex ); + snprintf( msgbuf, sizeof( msgbuf ), "K%d", j ); + CHAR_sendStatusString( toindex, msgbuf ); + snprintf( msgbuf, sizeof( msgbuf ), "W%d", j ); + CHAR_sendStatusString( toindex, msgbuf ); + } + } + + CHAR_talkToCli(meindex, -1, msg, CHAR_COLORYELLOW); + CHAR_talkToCli(toindex, -1, msg, CHAR_COLORYELLOW); + +#ifdef _FIX_TRADE_COPYPET + int m,n,petindex1,petindex2; + for( m = 0; m < CHAR_MAXPETHAVE; m ++ ) { + + petindex1=CHAR_getCharPet( meindex,m); + if( petindex1 == -1 ) continue; + for( n = 0; n < CHAR_MAXPETHAVE; n ++ ) { + petindex2=CHAR_getCharPet( toindex,n); + if( petindex2 == -1 ) continue; + printf("\nowner=%s pet1=%s owner=%s pet2=%s", + CHAR_getChar( meindex, CHAR_NAME), + CHAR_getChar( petindex1, CHAR_NAME), + CHAR_getChar( toindex, CHAR_NAME), + CHAR_getChar( petindex2, CHAR_NAME)); + if(strcmp( CHAR_getChar( petindex1, CHAR_UNIQUECODE), CHAR_getChar( petindex2, CHAR_UNIQUECODE))== 0){ + CHAR_talkToCli(meindex, -1, "⵽ǷサףϵͳԶ", CHAR_COLORRED); + CHAR_talkToCli(toindex, -1, "⵽ǷサףϵͳԶ", CHAR_COLORRED); + NPC_DelPet(toindex,n); + } + } + } +#endif + + + if(CHAR_getInt(meindex,CHAR_FLOOR)!=50000 && CHAR_getInt(toindex,CHAR_FLOOR)!=50000) + { + CHAR_charSaveFromConnect(meindex, FALSE); + CHAR_charSaveFromConnect(toindex, FALSE); + CHAR_talkToCli(meindex, -1, "ϵͳΪԶ浵", CHAR_COLORRED); + CHAR_talkToCli(toindex, -1, "ϵͳΪԶ浵", CHAR_COLORRED); + } +} + +#ifdef _ITEM_PILEFORTRADE + +int TRADE_HandleTrade_DelItem( int charaindex, int MyMaxPile, int MaxPile, int *Item, int *nums, int *indexlist) +{ + int i, k; + + for( i=0; i<50; i++){ + indexlist[i] = -1; + } + k=0; + for( i=0; i<15; i++ ){ + int pilenum, itemindex, totalnums, newindex; + if( Item[i] == -1 ) continue; + itemindex = CHAR_getItemIndex( charaindex, Item[i] ); + if( !ITEM_CHECKINDEX( itemindex)) return -1; + if(ITEM_getInt( itemindex, ITEM_CANBEPILE)!=1 && ITEM_getInt( itemindex, ITEM_USEPILENUMS)>1){ + CHAR_setItemIndex( charaindex , Item[i], -1); + CHAR_sendItemDataOne(charaindex,Item[i]); + CHAR_talkToCli(charaindex,-1,"ǷԶɾ",CHAR_COLORYELLOW); + return -1; + } + pilenum = ITEM_getInt( itemindex, ITEM_USEPILENUMS); + pilenum -= nums[i]; + if( pilenum < 0 ) return -1; + if( pilenum == 0 ){ + CHAR_setItemIndex( charaindex, Item[i], -1); + indexlist[k] = itemindex; + k++; + totalnums = ITEM_getInt( itemindex, ITEM_USEPILENUMS); + newindex = itemindex; + }else{ + ITEM_setInt( itemindex, ITEM_USEPILENUMS, pilenum); + newindex = ITEM_makeItemAndRegist( ITEM_getInt( itemindex, ITEM_ID)); + if( !ITEM_CHECKINDEX( newindex) ) return -1; + indexlist[k] = newindex; + k++; + totalnums = nums[i]; + } + if( totalnums > MaxPile ){ + totalnums -= MaxPile; + ITEM_setInt( newindex, ITEM_USEPILENUMS, MaxPile); + }else{ + ITEM_setInt( newindex, ITEM_USEPILENUMS, totalnums); + totalnums = 0; + } + + while( totalnums > 0 ){ + newindex = ITEM_makeItemAndRegist( ITEM_getInt( itemindex, ITEM_ID)); + if( !ITEM_CHECKINDEX( newindex) ) return -1; + indexlist[k] = newindex; + k++; + if( totalnums > MaxPile ){ + totalnums -= MaxPile; + ITEM_setInt( newindex, ITEM_USEPILENUMS, MaxPile); + }else{ + ITEM_setInt( newindex, ITEM_USEPILENUMS, totalnums); + totalnums = 0; + } + } + } + return k; +} + +int TRADE_HandleTrade_DelPet( int charaindex, int *Pet, int *indexlist) +{ + int i, k, petindex; + k=0; + for( i=0; i<5; i++){ + indexlist[i] = -1; + } + for( i=0; i<5; i++ ){ + if( Pet[i] == -1 ) continue; + petindex = CHAR_getCharPet( charaindex, Pet[i] ); + //print("\npetindex=%d",petindex); + if( !CHAR_CHECKINDEX( petindex)) return -1; + CHAR_setCharPet( charaindex, Pet[i], -1); + if( Pet[i] == CHAR_getInt( charaindex, CHAR_DEFAULTPET)) { + int sellfd; + CHAR_setInt( charaindex, CHAR_DEFAULTPET, -1); + sellfd = getfdFromCharaIndex( charaindex); + lssproto_KS_send( sellfd, Pet[i], 0); + } + indexlist[k] = petindex; + k++; + } + return k; +} + +BOOL TRADE_HandleTrade_DelGold( int charaindex, int sGold, int *Gold) +{ + int MyGold, MyMaxGold; + + MyGold = CHAR_getInt( charaindex, CHAR_GOLD); + MyMaxGold = CHAR_getMaxHaveGold( charaindex); + + MyGold -= sGold; + if( MyGold < 0 || MyGold > MyMaxGold ){ + MyGold = (MyGold<0)?0:MyGold; + MyGold = (MyGold>MyMaxGold)?MyMaxGold:MyGold; + CHAR_setInt( charaindex, CHAR_GOLD, MyGold); + return FALSE; + } + CHAR_setInt( charaindex, CHAR_GOLD, MyGold); + *Gold = sGold; + return TRUE; +} + +BOOL TRADE_HandleTrade_AddItem( int charaindex, int *Item) +{ + int ret, i,itemindex; + for( i=0; i<50; i++){ + if( Item[i] == -1 )break; + itemindex = CHAR_getItemIndex( charaindex, Item[i] ); + if(ITEM_getInt( itemindex, ITEM_CANBEPILE)!=1 && ITEM_getInt( itemindex, ITEM_USEPILENUMS)>1){ + return FALSE; + } + ret = CHAR_addItemSpecificItemIndex( charaindex, Item[i]); + if( ret < 0 || ret >= CHAR_MAXITEMHAVE ) { + int j; + for( j=i; j< 50; j++) + ITEM_endExistItemsOne( Item[j]); + return FALSE; + } + } + return TRUE; +} + +BOOL TRADE_HandleTrade_AddPet( int charaindex, int *Pet) +{ + int havepetelement, i; + for( i=0; i<5; i++){ + havepetelement = CHAR_getCharPetElement( charaindex); + if( Pet[i] == -1 ) break; + if( havepetelement < 0 ){ + int j; + for( j=i; j<5; j++){ + CHAR_endCharOneArray( Pet[j] ); + } + return FALSE; + + } + CHAR_setCharPet( charaindex, havepetelement, Pet[i]); + CHAR_setWorkInt( Pet[i], CHAR_WORKPLAYERINDEX, charaindex); + CHAR_setChar( Pet[i], CHAR_OWNERCDKEY, CHAR_getChar( charaindex, CHAR_CDKEY)); + CHAR_setChar( Pet[i], CHAR_OWNERCHARANAME, CHAR_getChar( charaindex, CHAR_NAME)); + CHAR_complianceParameter( Pet[i]); + } + return TRUE; +} + +BOOL TRADE_HandleTrade_AddGold( int charaindex, int sGold) +{ + int MyGold, MyMaxGold; + MyGold = CHAR_getInt( charaindex, CHAR_GOLD); + MyMaxGold = CHAR_getMaxHaveGold( charaindex); + + MyGold += sGold; + + MyGold = (MyGold<0)?0:MyGold; + MyGold = (MyGold>MyMaxGold)?MyMaxGold:MyGold; + + CHAR_setInt( charaindex, CHAR_GOLD, MyGold); + return TRUE; +} + +#ifdef _TRADE_PK +void BATTLE_Trade(void) +{ + char msg[128], tmpmsg[128], mycharaname[256], tocharaname[256]; + TRADE_HandleTrade(meindexpk, &TradeListPk[0], toindexpk, &TradeListPk[1]); + int fd,tofd; + fd = getfdFromCharaIndex(meindexpk); + tofd = getfdFromCharaIndex(toindexpk); + strcpy( mycharaname, CHAR_getChar(meindexpk, CHAR_NAME)); + strcpy( tocharaname, CHAR_getChar(toindexpk, CHAR_NAME)); + snprintf(tmpmsg, sizeof(tmpmsg), "W|%d|%s", fd, mycharaname); + lssproto_TD_send(tofd, -1, tmpmsg); + snprintf(tmpmsg, sizeof(tmpmsg), "W|%d|%s", tofd, tocharaname); + lssproto_TD_send(fd, -1, tmpmsg); + + CHAR_setWorkInt(meindexpk, CHAR_WORKTRADEMODE, CHAR_TRADE_FREE); + CHAR_setWorkInt(toindexpk, CHAR_WORKTRADEMODE, CHAR_TRADE_FREE); + CONNECT_setTradeTmp(fd, ""); + CONNECT_setTradeTmp(tofd, ""); + CHAR_sendTradeEffect( meindexpk, 0); + CHAR_sendTradeEffect( toindexpk, 0); + CHAR_sendStatusString(meindexpk, "i"); + CHAR_sendStatusString(toindexpk, "i"); + CHAR_sendStatusString(meindexpk, "P"); + CHAR_sendStatusString(toindexpk, "P"); + { + int j, petindex; + char msgbuf[256]; + for(j = 0; j < CHAR_MAXPETHAVE; j++){ + petindex = CHAR_getCharPet( meindexpk, j); + if( !CHAR_CHECKINDEX( petindex) ) continue; + CHAR_complianceParameter( petindex ); + snprintf( msgbuf, sizeof( msgbuf ), "K%d", j ); + CHAR_sendStatusString( meindexpk, msgbuf ); + snprintf( msgbuf, sizeof( msgbuf ), "W%d", j ); + CHAR_sendStatusString( meindexpk, msgbuf ); + } + for(j = 0; j < CHAR_MAXPETHAVE; j++){ + petindex = CHAR_getCharPet( toindexpk, j); + if( !CHAR_CHECKINDEX( petindex) ) continue; + CHAR_complianceParameter( petindex ); + snprintf( msgbuf, sizeof( msgbuf ), "K%d", j ); + CHAR_sendStatusString( toindexpk, msgbuf ); + snprintf( msgbuf, sizeof( msgbuf ), "W%d", j ); + CHAR_sendStatusString( toindexpk, msgbuf ); + } + } + CHAR_charSaveFromConnect(meindexpk, FALSE); + CHAR_charSaveFromConnect(toindexpk, FALSE); + CHAR_talkToCli(meindexpk, -1, "ϵͳΪԶ浵", CHAR_COLORRED); + CHAR_talkToCli(toindexpk, -1, "ϵͳΪԶ浵", CHAR_COLORRED); +} +#endif + +BOOL TRADE_HandleTrade( int meindex, STradeList *temp1, int toindex, STradeList *temp2 ) +{ + int MeMaxPile, ToMaxPile, ret; + int MeItem[50], ToItem[50]; + int MePet[5], ToPet[5]; + int MeGold=0, ToGold=0; + int LostPet[5]={-1,-1,-1,-1,-1}; + + + MeMaxPile = CHAR_getMyMaxPilenum( meindex);//ѵ + ToMaxPile = CHAR_getMyMaxPilenum( toindex); + //Ƴmeindex + //Ƴtoindex + { + char buf[256]; + + memset( buf, 0, sizeof( buf)); + sprintf( buf, "A.%s[%s] trade B.%s[%s] FXY[%d,%d,%d]", + CHAR_getChar( meindex, CHAR_NAME), CHAR_getChar(meindex, CHAR_CDKEY), + CHAR_getChar( toindex, CHAR_NAME), CHAR_getChar(toindex, CHAR_CDKEY), + CHAR_getInt( meindex, CHAR_FLOOR), CHAR_getInt( meindex, CHAR_X), CHAR_getInt( meindex, CHAR_Y) ); + LogTrade(buf); + } + //Ƴ + if( CHAR_getInt( meindex, CHAR_FLOOR)==50000 && CHAR_getInt( toindex, CHAR_FLOOR)==50000) + { + if( CHAR_getWorkInt( meindex, CHAR_WORKTRADEPK)==1 && CHAR_getWorkInt( toindex, CHAR_WORKTRADEPK)==2) + { + if( (ret=TRADE_HandleTrade_DelItem( meindex, MeMaxPile, ToMaxPile, temp1->ItemTi, temp1->ItemNum, ToItem ))== -1 ) return FALSE; + if( (ret=TRADE_HandleTrade_DelItem( toindex, ToMaxPile, MeMaxPile, temp2->ItemTi, temp2->ItemNum, MeItem ))== -1 ) return FALSE; + + if( (ret=TRADE_HandleTrade_DelPet( meindex, temp1->PetTi, ToPet)) == -1 ) return FALSE; + if( (ret=TRADE_HandleTrade_DelPet( toindex, temp2->PetTi, MePet)) == -1 ) return FALSE; + if( TRADE_HandleTrade_DelGold( meindex, temp1->Golds, &ToGold) == FALSE ) return FALSE; + if( TRADE_HandleTrade_DelGold( toindex, temp2->Golds, &MeGold) == FALSE ) return FALSE; + // + if( TRADE_HandleTrade_AddItem( meindex, MeItem) == FALSE ) return FALSE; + if( TRADE_HandleTrade_AddItem( meindex, ToItem) == FALSE ) return FALSE; + if( TRADE_HandleTrade_AddPet( meindex, MePet) == FALSE) return FALSE; + if( TRADE_HandleTrade_AddPet( meindex, ToPet) == FALSE) return FALSE; + + TRADE_HandleTrade_AddGold( meindex, MeGold); + TRADE_HandleTrade_AddGold( meindex, ToGold); + CHAR_setWorkInt( meindex, CHAR_WORKTRADEPK, 0); + CHAR_setWorkInt( toindex, CHAR_WORKTRADEPK, 0); + } + else if( CHAR_getWorkInt( meindex, CHAR_WORKTRADEPK)==2 && CHAR_getWorkInt( toindex, CHAR_WORKTRADEPK)==1) + { + if( (ret=TRADE_HandleTrade_DelItem( meindex, MeMaxPile, ToMaxPile, temp1->ItemTi, temp1->ItemNum, ToItem ))== -1 ) return FALSE; + if( (ret=TRADE_HandleTrade_DelItem( toindex, ToMaxPile, MeMaxPile, temp2->ItemTi, temp2->ItemNum, MeItem ))== -1 ) return FALSE; + + if( (ret=TRADE_HandleTrade_DelPet( meindex, temp1->PetTi, ToPet)) == -1 ) return FALSE; + if( (ret=TRADE_HandleTrade_DelPet( toindex, temp2->PetTi, MePet)) == -1 ) return FALSE; + if( TRADE_HandleTrade_DelGold( meindex, temp1->Golds, &ToGold) == FALSE ) return FALSE; + if( TRADE_HandleTrade_DelGold( toindex, temp2->Golds, &MeGold) == FALSE ) return FALSE; + // + if( TRADE_HandleTrade_AddItem( toindex, MeItem) == FALSE ) return FALSE; + if( TRADE_HandleTrade_AddItem( toindex, ToItem) == FALSE ) return FALSE; + if( TRADE_HandleTrade_AddPet( toindex, MePet) == FALSE) return FALSE; + if( TRADE_HandleTrade_AddPet( toindex, ToPet) == FALSE) return FALSE; + + TRADE_HandleTrade_AddGold( toindex, MeGold); + TRADE_HandleTrade_AddGold( toindex, ToGold); + CHAR_setWorkInt( meindex, CHAR_WORKTRADEPK, 0); + CHAR_setWorkInt( toindex, CHAR_WORKTRADEPK, 0); + } + } + else + { + if( (ret=TRADE_HandleTrade_DelItem( meindex, MeMaxPile, ToMaxPile, temp1->ItemTi, temp1->ItemNum, ToItem ))== -1 ) return FALSE; + if( (ret=TRADE_HandleTrade_DelItem( toindex, ToMaxPile, MeMaxPile, temp2->ItemTi, temp2->ItemNum, MeItem ))== -1 ) return FALSE; + + if( (ret=TRADE_HandleTrade_DelPet( meindex, temp1->PetTi, ToPet)) == -1 ) return FALSE; + if( (ret=TRADE_HandleTrade_DelPet( toindex, temp2->PetTi, MePet)) == -1 ) return FALSE; + if( TRADE_HandleTrade_DelGold( meindex, temp1->Golds, &ToGold) == FALSE ) return FALSE; + if( TRADE_HandleTrade_DelGold( toindex, temp2->Golds, &MeGold) == FALSE ) return FALSE; + // + if( TRADE_HandleTrade_AddItem( meindex, MeItem) == FALSE ) return FALSE; + if( TRADE_HandleTrade_AddItem( toindex, ToItem) == FALSE ) return FALSE; + if( TRADE_HandleTrade_AddPet( meindex, MePet) == FALSE) return FALSE; + if( TRADE_HandleTrade_AddPet( toindex, ToPet) == FALSE) return FALSE; + + TRADE_HandleTrade_AddGold( meindex, MeGold); + TRADE_HandleTrade_AddGold( toindex, ToGold); + } + { + char buf1[4096], buf2[4096], buf[256]; + int i; + sprintf( buf1, "A.ITEM."); + sprintf( buf2, "B.ITEM."); + for( i=0; i<50; i++){ + if( ITEM_CHECKINDEX( ToItem[i]) ){ + sprintf( buf, "%s[%s]*%d,", + ITEM_getChar( ToItem[i], ITEM_NAME), ITEM_getChar( ToItem[i], ITEM_UNIQUECODE), + ITEM_getInt( ToItem[i], ITEM_USEPILENUMS) ); + strcat( buf1, buf); + } + if( ITEM_CHECKINDEX( MeItem[i]) ){ + sprintf( buf, "%s[%s]*%d,", + ITEM_getChar( MeItem[i], ITEM_NAME), ITEM_getChar( MeItem[i], ITEM_UNIQUECODE), + ITEM_getInt( MeItem[i], ITEM_USEPILENUMS) ); + strcat( buf2, buf); + } + } + strcat( buf1, "PET."); + strcat( buf2, "PET."); + for( i=0; i<5; i++){ + if( CHAR_CHECKINDEX( ToPet[i]) ){ + sprintf( buf, "%s[%s]%s-%d", + CHAR_getUseName( ToPet[i]), CHAR_getChar( ToPet[i], CHAR_UNIQUECODE), + CHAR_getChar( ToPet[i], CHAR_NAME), CHAR_getInt( ToPet[i], CHAR_LV) ); + strcat( buf1, buf); + } + if( CHAR_CHECKINDEX( MePet[i]) ){ + sprintf( buf, "%s[%s]%s-%d", + CHAR_getUseName( MePet[i]), CHAR_getChar( MePet[i], CHAR_UNIQUECODE), + CHAR_getChar( MePet[i], CHAR_NAME), CHAR_getInt( MePet[i], CHAR_LV) ); + strcat( buf2, buf); + } + } + sprintf( buf, "GOLD:%d", ToGold); + strcat( buf1, buf); + sprintf( buf, "GOLD:%d", MeGold); + strcat( buf2, buf); + LogTrade( buf1); + LogTrade( buf2); + } + + return TRUE; +} + +int TRADE_CheckItembuf(int fd, int meindex, int toindex, int tofd, char* mycharaname, char* tocharaname) +{ + int Tradeti; + STradeList TradeListTemp[2]; + if( TRADE_getMyTarget( meindex) != toindex ) return -1; + Tradeti = CONNECT_getTradeList( fd); + if( Tradeti <0 || Tradeti >= MAX_TRADELISTNUM ) return -1; + if( TradeList[Tradeti][0].use != 1 || TradeList[Tradeti][1].use != 1 ) return -1; + if( TRADE_getSomeTradeList( meindex, &TradeListTemp[0]) == FALSE ) return -1; + if( TRADE_getSomeTradeList( toindex, &TradeListTemp[1]) == FALSE ) return -1; + //ȷλ + if( TRADE_CheckTradeList( meindex, &TradeListTemp[0], toindex, &TradeListTemp[1]) == FALSE ) return -1; + //Ƴ + // +#ifdef _TRADE_PK + if(CHAR_getInt( meindex, CHAR_FLOOR)==50000 && CHAR_getInt( toindex, CHAR_FLOOR)==50000) + { +// TradeListPk[0].charaindex = TradeListTemp[0].charaindex; +// TradeListPk[1].charaindex = TradeListTemp[1].charaindex; +// TradeListPk[0].fd = TradeListTemp[0].fd; +// TradeListPk[1].fd = TradeListTemp[1].fd; +// int i; +// for(i=0;i<5;i++) +// { +// TradeListPk[0].PetTi[i] = TradeListTemp[0].PetTi[i]; +// TradeListPk[1].PetTi[i] = TradeListTemp[1].PetTi[i]; +// } +// for(i=0;i<15;i++) +// { +// TradeListPk[0].ItemTi[i] = TradeListTemp[0].ItemTi[i]; +// TradeListPk[1].ItemTi[i] = TradeListTemp[1].ItemTi[i]; +// TradeListPk[0].ItemNum[i] = TradeListTemp[0].ItemNum[i]; +// TradeListPk[1].ItemNum[i] = TradeListTemp[1].ItemNum[i]; +// } +// TradeListPk[0].Golds = TradeListTemp[0].Golds; +// TradeListPk[1].Golds = TradeListTemp[1].Golds; +// TradeListPk[0].use = TradeListTemp[0].use; +// TradeListPk[1].use = TradeListTemp[1].use; + TradeListPk[0] = TradeListTemp[0]; + TradeListPk[1] = TradeListTemp[1]; + meindexpk = meindex; + toindexpk = toindex; + BATTLE_CreateVsPlayer( meindex, toindex); + return 3; + } + else + { +#endif + if( TRADE_HandleTrade( meindex, &TradeListTemp[0], toindex, &TradeListTemp[1] ) == FALSE ) return -1; + //׽ + return 1; +#ifdef _TRADE_PK + } +#endif +} + +#else +/* +int TRADE_CheckItembuf(int fd, int meindex, int toindex, int tofd, char* mycharaname, char* tocharaname) +{ +#ifdef _TRADESYSTEM2 // (ɿ) Syu ADD ½ϵͳ + int myItem[42] = { -1 } ; //ҷеĽݱ + int oppItem[42] = { -1 }; //ԷеĽݱ + int ii , jj; + int Iitem1[15] = { 0 } ; //ҷߵindex + int Iitem2[15] = { 0 } ; //Էߵindex + int ppet1[5] = { 0 } ; //ҷindex + int ppet2[5] = { 0 } ; //Էindex + BOOL tradeflag = TRUE ; + int count = 0 ; +#endif + + char a[16], b[16], c[16], d[16], e[16], f[16]; + char g[16], h[16], i[16], j[16], k[16], l[16], token[16]; + int itemindex1 = 0, itemindex2 = 0, itemindex3 = 0; + int itemindex4 = 0, itemindex5 = 0, itemindex6 = 0; + int toitemindex1 = 0, toitemindex2 = 0, toitemindex3 = 0; + int toitemindex4 = 0, toitemindex5 = 0, toitemindex6 = 0; + int item1 = 0, item2 = 0, item4 = 0, item5 = 0, pet3 = 0, pet6 = 0; + int pet1 = 0, pet2 = 0; + int swapitem1 = 0, swapitem2 = 0, gold1 = 0, gold2 = 0; + char itembuf[256], toitembuf[256], buf[4048]; + + CONNECT_getTradeTmp(fd, itembuf, sizeof(itembuf)); + CONNECT_getTradeTmp(tofd, toitembuf, sizeof(toitembuf)); + + +#ifdef _TRADESYSTEM2 // (ɿ) Syu ADD ½ϵͳ + //ȡҷнݱ + for ( ii = 0 ; ii < 42 ; ii ++ ) { + if (getStringFromIndexWithDelim(itembuf, "|", 6 + ii * 2 , token, sizeof(token)) == TRUE) + myItem[ii] = atoi(token); + } + //ȡöԷнݱ + for ( ii = 0 ; ii < 42 ; ii ++ ) { + if (getStringFromIndexWithDelim(toitembuf, "|", 6 + ii * 2 , token, sizeof(token)) == TRUE) + oppItem[ii] = atoi(token); + } +#else + // ȶ˫֮ύЭ + if (getStringFromIndexWithDelim(itembuf, "|", 5, token, sizeof(token)) == TRUE) + strcpy(a, token); + if (getStringFromIndexWithDelim(itembuf, "|", 6, token, sizeof(token)) == TRUE) + itemindex1 = atoi(token); + if (getStringFromIndexWithDelim(itembuf, "|", 7, token, sizeof(token)) == TRUE) + strcpy(b, token); + if (getStringFromIndexWithDelim(itembuf, "|", 8, token, sizeof(token)) == TRUE) + itemindex2 = atoi(token); + if (getStringFromIndexWithDelim(itembuf, "|", 9, token, sizeof(token)) == TRUE) + strcpy(c, token); + if (getStringFromIndexWithDelim(itembuf, "|", 10, token, sizeof(token)) == TRUE) + itemindex3 = atoi(token); + if (getStringFromIndexWithDelim(itembuf, "|", 11, token, sizeof(token)) == TRUE) + strcpy(d, token); + if (getStringFromIndexWithDelim(itembuf, "|", 12, token, sizeof(token)) == TRUE) + itemindex4 = atoi(token); + if (getStringFromIndexWithDelim(itembuf, "|", 13, token, sizeof(token)) == TRUE) + strcpy(e, token); + if (getStringFromIndexWithDelim(itembuf, "|", 14, token, sizeof(token)) == TRUE) + itemindex5 = atoi(token); + if (getStringFromIndexWithDelim(itembuf, "|", 15, token, sizeof(token)) == TRUE) + strcpy(f, token); + if (getStringFromIndexWithDelim(itembuf, "|", 16, token, sizeof(token)) == TRUE) + itemindex6 = atoi(token); + + if (getStringFromIndexWithDelim(toitembuf, "|", 5, token, sizeof(token)) == TRUE) + strcpy(g, token); + if (getStringFromIndexWithDelim(toitembuf, "|", 6, token, sizeof(token)) == TRUE) + toitemindex1 = atoi(token); + if (getStringFromIndexWithDelim(toitembuf, "|", 7, token, sizeof(token)) == TRUE) + strcpy(h, token); + if (getStringFromIndexWithDelim(toitembuf, "|", 8, token, sizeof(token)) == TRUE) + toitemindex2 = atoi(token); + if (getStringFromIndexWithDelim(toitembuf, "|", 9, token, sizeof(token)) == TRUE) + strcpy(i, token); + if (getStringFromIndexWithDelim(toitembuf, "|", 10, token, sizeof(token)) == TRUE) + toitemindex3 = atoi(token); + if (getStringFromIndexWithDelim(toitembuf, "|", 11, token, sizeof(token)) == TRUE) + strcpy(j, token); + if (getStringFromIndexWithDelim(toitembuf, "|", 12, token, sizeof(token)) == TRUE) + toitemindex4 = atoi(token); + if (getStringFromIndexWithDelim(toitembuf, "|", 13, token, sizeof(token)) == TRUE) + strcpy(k, token); + if (getStringFromIndexWithDelim(toitembuf, "|", 14, token, sizeof(token)) == TRUE) + toitemindex5 = atoi(token); + if (getStringFromIndexWithDelim(toitembuf, "|", 15, token, sizeof(token)) == TRUE) + strcpy(l, token); + if (getStringFromIndexWithDelim(toitembuf, "|", 16, token, sizeof(token)) == TRUE) + toitemindex6 = atoi(token); +#endif + +#ifdef _TRADESYSTEM2 // (ɿ) Syu ADD ½ϵͳ + //ظ׵ĵ + for ( ii = 0 ; ii < 15 ; ii ++ ) { + for ( jj = ii + 1 ; jj < 15 ; jj ++ ) { + if ( myItem[ii] == myItem[jj] ) + if ( myItem[ii] != -1 ) + return -1 ; + } + } + for ( ii = 21 ; ii < 36 ; ii ++ ) { + for ( jj = ii + 1 ; jj < 36 ; jj++ ) { + if ( myItem[ii] == myItem[jj] ) + if ( myItem[ii] != -1 ) + return -1 ; + } + } +#else + // shan hjj add ϴ + if (itemindex1==itemindex2){ + if (itemindex1!=-1){ + return -1; + } + } + if (itemindex4==itemindex5){ + if (itemindex4!=-1){ + return -1; + } + } + // End +#endif + +#ifdef _TRADESYSTEM2 // (ɿ) Syu ADD ½ϵͳ + //ȶ˫׵ƷǷȷ + for ( ii = 0 ; ii < 21 ; ii ++ ) { + if ( myItem[ii] != oppItem[ii+21] ) { + tradeflag = FALSE ; + break; + } + } + for ( ii = 21 ; ii < 42 ; ii ++ ){ + if ( myItem[ii] != oppItem[ii-21]) { + tradeflag = FALSE; + break; + } + } + //˫ȷʼд + if ( tradeflag == TRUE ) { + //˫ߵļӼ + for ( ii = 0 ; ii < 15 ; ii ++ ) { + if ( myItem[ii] != -1 ) { + swapitem1--; + swapitem2++; + } + } + for ( ii = 21 ; ii < 36 ; ii ++ ) { + if ( myItem[ii] != -1 ) { + swapitem1++; + swapitem2--; + } + } +#else + if ((strcmp(a, j) == 0) && (strcmp(b, k) == 0) && (strcmp(c,l) == 0) + && (strcmp(d, g) == 0) && (strcmp(e, h) == 0) && (strcmp(f, i) == 0) + && (itemindex1 == toitemindex4) && (itemindex2 == toitemindex5) + && (itemindex3 == toitemindex6) && (itemindex4 == toitemindex1) + && (itemindex5 == toitemindex2) && (itemindex6 == toitemindex3)) + { + // ˫ƷǷпλ + if ((strcmp(a, "I") == 0) && (itemindex1 != -1)){ + swapitem1--; + swapitem2++; + } + if ((strcmp(b, "I") == 0) && (itemindex2 != -1)){ + swapitem1--; + swapitem2++; + } + if ((strcmp(d, "I") == 0) && (itemindex4 != -1)){ + swapitem1++; + swapitem2--; + } + if ((strcmp(e, "I") == 0) && (itemindex5 != -1)){ + swapitem1++; + swapitem2--; + } +#endif + if (swapitem1 > CHAR_findTotalEmptyItem(meindex)) + return -2; + toindex = CONNECT_getCharaindex(tofd); + if (!CHAR_CHECKINDEX(toindex)) return -1; + if (swapitem2 > CHAR_findTotalEmptyItem(toindex)) + return -3; +#ifdef _TRADESYSTEM2 // (ɿ) Syu ADD ½ϵͳ + //ȡýĽǮ + if ( myItem[20] != -1 ) gold1 += myItem[20] ; + if ( myItem[41] != -1 ) gold2 += myItem[41] ; +#else + // ˫Ǯ + if ((strcmp(a, "G") == 0) && (itemindex1 != -1)) gold1 += itemindex1; + if ((strcmp(b, "G") == 0) && (itemindex2 != -1)) gold1 += itemindex2; + if ((strcmp(d, "G") == 0) && (itemindex4 != -1)) gold2 += itemindex4; + if ((strcmp(e, "G") == 0) && (itemindex5 != -1)) gold2 += itemindex5; +#endif + if (gold1 > CHAR_getMaxHaveGold( meindex) ) return -4; + if (gold1 > CHAR_getInt(meindex, CHAR_GOLD)) return -5; + if (gold2 > CHAR_getMaxHaveGold( toindex)) return -6; + if (gold2 > CHAR_getInt(toindex, CHAR_GOLD)) return -7; + if ((gold2 + CHAR_getInt(meindex, CHAR_GOLD) - gold1) > CHAR_getMaxHaveGold( meindex) ) return -8; + if ((gold1 + CHAR_getInt(toindex, CHAR_GOLD) - gold2) > CHAR_getMaxHaveGold( toindex)) return -9; + +#ifdef _TRADESYSTEM2 // (ɿ) Syu ADD ½ϵͳ + //˫ļӼ + for ( ii = 15 ; ii < 20 ; ii ++ ) { + if ( myItem[ii] != -1 ) { + pet1--; + pet2++; + } + } + for ( ii = 36 ; ii < 41 ; ii ++ ) { + if ( myItem[ii] != -1 ) { + pet1++; + pet2--; + } + } +#else + // ˫ + if ((strcmp(c, "P") == 0) && (itemindex3 != -1)) + { + pet1--; pet2++; + } + if ((strcmp(f, "P") == 0) && (itemindex6 != -1)) + { + pet1++; pet2--; + } +#endif + +#ifdef _TRADESYSTEM2 // (ɿ) Syu ADD ½ϵͳ + if ((pet1 > 5) || (pet2 > 5)) return -10; + //ȡ˫ܷŵij + for( ii = 0; ii < CHAR_MAXPETHAVE; ii ++ ) { + if( CHAR_getCharPet( meindex , ii ) == -1 ) count ++ ; + } + if ( pet1 > count ) return -10; + count = 0 ; + for( ii = 0; ii < CHAR_MAXPETHAVE; ii ++ ) { + if( CHAR_getCharPet( toindex , ii ) == -1 ) count ++ ; + } + if ( pet2 > count ) return -11; +#else + if ((pet1 > 1) || (pet2 > 1)) return -10; + if ((pet1 == 1) && (CHAR_getCharPetElement( meindex) == -1)) return -10; + if ((pet2 == 1) && (CHAR_getCharPetElement( toindex) == -1)) return -11; +#endif +#ifdef _TRADESYSTEM2 // (ɿ) Syu ADD ½ϵͳ + //ȡ׵ĵindex + for ( ii = 0 ; ii < 15 ; ii ++ ) { + if ( myItem[ii] != -1 ) + Iitem1[ii] = CHAR_getItemIndex(meindex, myItem[ii]); + else + Iitem1[ii] = -1 ; + if ( myItem[ii + 21 ] != -1 ) + Iitem2[ii] = CHAR_getItemIndex(toindex, myItem[ii + 21]); + else + Iitem2[ii] = -1 ; + } +#else + if ((strcmp(a, "I") == 0) && (itemindex1 != -1)) + item1 = CHAR_getItemIndex(meindex, itemindex1); + else item1 = -1; + if ((strcmp(b, "I") == 0) && (itemindex2 != -1)) + item2 = CHAR_getItemIndex(meindex, itemindex2); + else item2 = -1; + if ((strcmp(d, "I") == 0) && (itemindex4 != -1)) + item4 = CHAR_getItemIndex(toindex, itemindex4); + else item4 = -1; + if ((strcmp(e, "I") == 0) && (itemindex5 != -1)) + item5 = CHAR_getItemIndex(toindex, itemindex5); + else item5 = -1; +#endif +#ifdef _TRADESYSTEM2 // (ɿ) Syu ADD ½ϵͳ + //ȡ׳index + for ( ii = 15 ; ii < 20 ; ii ++ ) { + if ( myItem[ii] != -1 ) { + if ( CHAR_getInt( meindex , CHAR_RIDEPET) == myItem[ii] ) + return -1 ; + ppet1[ii - 15 ] = CHAR_getCharPet( meindex , myItem[ii] ) ; + } + else + ppet1[ii - 15 ] = -1 ; + } + for ( ii = 36 ; ii < 41 ; ii ++ ) { + if ( myItem[ii] != -1 ) { + if ( CHAR_getInt( toindex , CHAR_RIDEPET) == myItem[ii] ) + return -1 ; + ppet2[ ii - 36 ] = CHAR_getCharPet( toindex , myItem[ii] ) ; + } + else + ppet2[ ii - 36 ] = -1 ; + } +#else + if (itemindex3 != -1) + { + if( CHAR_getInt( meindex, CHAR_RIDEPET) == itemindex3 ) + return -1; + pet3 = CHAR_getCharPet(meindex, itemindex3); + } + else pet3 = -1; + if (itemindex6 != -1) + { + if( CHAR_getInt( toindex, CHAR_RIDEPET) == itemindex6 ) + return -1; + pet6 = CHAR_getCharPet(toindex, itemindex6); + } + else pet6 = -1; +#endif + + + +#ifdef _TRADESYSTEM2 // (ɿ) Syu ADD ½ϵͳ + for ( ii = 0 ; ii < 15 ; ii ++ ) { + if ( ITEM_getInt( Iitem1[ii] , ITEM_VANISHATDROP ) == 1 ) + return -12 ; + if ( ITEM_getInt( Iitem2[ii] , ITEM_VANISHATDROP ) == 1 ) + return -12 ; + } +#else + if ((ITEM_getInt(item1, ITEM_VANISHATDROP) == 1)|| + (ITEM_getInt(item2, ITEM_VANISHATDROP) == 1)|| + (ITEM_getInt(item4, ITEM_VANISHATDROP) == 1)|| + (ITEM_getInt(item5, ITEM_VANISHATDROP) ==1)) + return -12; +#endif + + +#ifdef _TRADESYSTEM2 // (ɿ) Syu ADD ½ϵͳ + //ȼܷж + if( CHAR_getWorkInt( meindex, CHAR_PickAllPet) != TRUE ) { + for ( ii = 0 ; ii < 5 ; ii ++ ) { + if ( (ppet2[ii] != -1 ) && ( CHAR_getInt( ppet2[ii] , CHAR_LV ) + - CHAR_getInt(meindex, CHAR_LV) > 5) + && (CHAR_getInt(meindex,CHAR_TRANSMIGRATION) <= 0)) + return -13 ; + } + } + if( CHAR_getWorkInt( toindex, CHAR_PickAllPet) != TRUE ) { + for ( ii = 0 ; ii < 5 ; ii ++ ) { + if ( (ppet1[ii] != -1 ) && ( CHAR_getInt( ppet1[ii] , CHAR_LV ) + - CHAR_getInt(toindex, CHAR_LV) > 5) + && (CHAR_getInt(toindex,CHAR_TRANSMIGRATION) <= 0)) + return -13 ; + } + } +#else + if( CHAR_getWorkInt( meindex, CHAR_PickAllPet) != TRUE ) { + if ((pet6 != -1) && (CHAR_getInt(pet6, CHAR_LV) + - CHAR_getInt(meindex, CHAR_LV) > 5) + && (CHAR_getInt(meindex,CHAR_TRANSMIGRATION) <= 0)) + return -13; + + } + if( CHAR_getWorkInt( toindex, CHAR_PickAllPet) != TRUE ) { + + if ((pet3 != -1) && (CHAR_getInt(pet3, CHAR_LV) + - CHAR_getInt(toindex, CHAR_LV) > 5) + && (CHAR_getInt(toindex,CHAR_TRANSMIGRATION) <= 0)) + return -14; + } +#endif +#ifdef _TRADESYSTEM2 // (ɿ) Syu ADD ½ϵͳ + //ǷΪػ + for ( ii = 0 ; ii < 5 ; ii ++ ) { + if ( ( ppet1[ii] != -1 ) && (CHAR_getInt(ppet1[ii], CHAR_PETFAMILY) == 1)) + return -15; + if ( ( ppet2[ii] != -1 ) && (CHAR_getInt(ppet2[ii], CHAR_PETFAMILY) == 1)) + return -15; + } +#else + if ((pet6 != -1) && (CHAR_getInt(pet6, CHAR_PETFAMILY) == 1)) + return -15; + if ((pet3 != -1) && (CHAR_getInt(pet3, CHAR_PETFAMILY) == 1)) + return -15; +#endif + +#ifdef _TRADESYSTEM2 // (ɿ) Syu ADD ½ϵͳ + // ҵߡǮ + for ( ii = 0 ; ii < 15 ; ii ++ ) { + TRADE_ChangeItem(meindex, toindex, "I", "I", Iitem1[ii], Iitem2[ii], + myItem[ii], oppItem[ii]); + } + for ( ii = 15 ; ii < 20 ; ii ++ ) { + TRADE_ChangeItem(meindex, toindex, "P", "P", ppet1[ii - 15 ], ppet2[ii-15], + myItem[ii], oppItem[ii]); + } + TRADE_ChangeItem(meindex, toindex, "G", "G", Iitem1[20], Iitem2[41], + myItem[20], oppItem[20]); +#else + TRADE_ChangeItem(meindex, toindex, a, d, item1, item4, + itemindex1, itemindex4); + TRADE_ChangeItem(meindex, toindex, b, e, item2, item5, + itemindex2, itemindex5); + TRADE_ChangeItem(meindex, toindex, c, f, pet3, pet6, + itemindex3, itemindex6); +#endif + + // д trade.log + { + char petname1[256], petname2[256]; + int pet1lv, pet2lv; + int logitem1 = 0, logitem2 = 0, logitem4 = 0, logitem5 = 0; + + if ((strcmp(a, "I") == 0) && (item1 != -1)) logitem1 = ITEM_getInt(item1, ITEM_ID); + if ((strcmp(b, "I") == 0) && (item2 != -1)) logitem2 = ITEM_getInt(item2, ITEM_ID); + if ((strcmp(a, "G") == 0) && (item1 == -1)) logitem1 = itemindex1; + if ((strcmp(b, "G") == 0) && (item2 == -1)) logitem2 = itemindex2; + if ((strcmp(c, "P") == 0) && (pet3 == -1)) + { + sprintf(petname1, "NONE"); + pet1lv = 0; + } + else + { + sprintf(petname1, "%s", CHAR_getChar(pet3, CHAR_NAME)); + pet1lv = CHAR_getInt(pet3, CHAR_LV); + } + if ((strcmp(f, "P") == 0) && (pet6 == -1)) + { + sprintf(petname2, "NONE"); + pet2lv = 0; + } + else + { + sprintf(petname2, "%s", CHAR_getChar(pet6, CHAR_NAME)); + pet2lv = CHAR_getInt(pet6, CHAR_LV); + } + if ((strcmp(d, "I") == 0) && (item4 != -1)) logitem4 = ITEM_getInt(item4, ITEM_ID); + if ((strcmp(e, "I") == 0) && (item5 != -1)) logitem5 = ITEM_getInt(item5, ITEM_ID); + if ((strcmp(d, "G") == 0) && (item4 == -1)) logitem4 = itemindex4; + if ((strcmp(e, "G") == 0) && (item5 == -1)) logitem5 = itemindex5; + sprintf(buf, "%s\t%s\t(%s[%d,%s],%s[%d,%s],%s[%s,%d,%s]) <-> %s\t%s\t(%s[%d,%s],%s[%d,%s],%s[%s,%d,%s])", + CHAR_getChar(meindex, CHAR_CDKEY), mycharaname, + a, logitem1, ITEM_getChar( item1, ITEM_UNIQUECODE), b, logitem2, ITEM_getChar( item2, ITEM_UNIQUECODE), + c, petname1, pet1lv, CHAR_getChar( pet3, CHAR_UNIQUECODE), + CHAR_getChar(toindex, CHAR_CDKEY), tocharaname, + d, logitem4, ITEM_getChar( item4, ITEM_UNIQUECODE), e, logitem5, ITEM_getChar( item5, ITEM_UNIQUECODE), + f, petname2, pet2lv, CHAR_getChar( pet6, CHAR_UNIQUECODE)); + LogTrade(buf); + } + + return 1; + }// if + else + return 2; +} +*/ +#endif +/* +BOOL TRADE_ChangeItem(int meindex, int toindex, char *a, char *b, + int item1, int item2, int itemindex1, int itemindex2) +{ + int gold1 = 0, gold2 = 0, eptitem = -1; + if (CHAR_CHECKINDEX(meindex) == FALSE) return FALSE; + if (CHAR_CHECKINDEX(toindex) == FALSE) return FALSE; + // <-> + if ((strcmp(a, "I") == 0) && (strcmp(b, "I") == 0)) + { + // <-> + if ((itemindex1 == -1) && (itemindex2 > 0)) + { + if (ITEM_CHECKINDEX(item2) == FALSE) return FALSE; + eptitem = CHAR_findEmptyItemBox(meindex); + if (eptitem < 0) return FALSE; + CHAR_setItemIndex(meindex, eptitem, item2); + ITEM_setWorkInt(item2, ITEM_WORKCHARAINDEX, meindex); + ITEM_setWorkInt(item2, ITEM_WORKOBJINDEX, -1); + CHAR_setItemIndex(toindex, itemindex2, -1); + } + // <-> + else if ((itemindex1 > 0) && (itemindex2 == -1)) + { + if (ITEM_CHECKINDEX(item1) == FALSE) return FALSE; + eptitem = CHAR_findEmptyItemBox(toindex); + if (eptitem < 0) return FALSE; + CHAR_setItemIndex(toindex, eptitem, item1); + ITEM_setWorkInt(item1, ITEM_WORKCHARAINDEX, toindex); + ITEM_setWorkInt(item1, ITEM_WORKOBJINDEX, -1); + CHAR_setItemIndex(meindex, itemindex1, -1); + } + // <-> + else if (itemindex1 > 0 && itemindex2 > 0) + { + if (ITEM_CHECKINDEX(item1) == FALSE) return FALSE; + if (ITEM_CHECKINDEX(item2) == FALSE) return FALSE; + ITEM_setWorkInt(item1, ITEM_WORKCHARAINDEX, toindex); + ITEM_setWorkInt(item1, ITEM_WORKOBJINDEX, -1); + ITEM_setWorkInt(item2, ITEM_WORKCHARAINDEX, meindex); + ITEM_setWorkInt(item2, ITEM_WORKOBJINDEX, -1); + CHAR_setItemIndex(toindex, itemindex2, item1); + CHAR_setItemIndex(meindex, itemindex1, item2); + } + } + // <-> Ǯ + else if ((strcmp(a, "I") == 0) && (strcmp(b, "G") == 0)) + { + if (itemindex1 > 0) + { + if (ITEM_CHECKINDEX(item1) == FALSE) return FALSE; + eptitem = CHAR_findEmptyItemBox(toindex); + if (eptitem < 0) return FALSE; + ITEM_setWorkInt(item1, ITEM_WORKCHARAINDEX, toindex); + ITEM_setWorkInt(item1, ITEM_WORKOBJINDEX, -1); + CHAR_setItemIndex(toindex, eptitem, item1); + CHAR_setItemIndex(meindex, itemindex1, -1); + } + if (itemindex2 < 0) itemindex2 = 0; + gold1 = CHAR_getInt(meindex, CHAR_GOLD); + gold1 += itemindex2; + CHAR_setInt(meindex, CHAR_GOLD, gold1); + gold2 = CHAR_getInt(toindex, CHAR_GOLD); + gold2 -= itemindex2; + CHAR_setInt(toindex, CHAR_GOLD, gold2); + } + // Ǯ <-> + else if ((strcmp(a, "G") == 0) && (strcmp(b, "I") == 0)) + { + if (itemindex2 > 0) + { + if (ITEM_CHECKINDEX(item2) == FALSE) return FALSE; + eptitem = CHAR_findEmptyItemBox(meindex); + if (eptitem < 0) return FALSE; + ITEM_setWorkInt(item2, ITEM_WORKCHARAINDEX, meindex); + ITEM_setWorkInt(item2, ITEM_WORKOBJINDEX, -1); + CHAR_setItemIndex(meindex, eptitem, item2); + CHAR_setItemIndex(toindex, itemindex2, -1); + } + if (itemindex1 < 0) itemindex1 = 0; + gold1 = CHAR_getInt(meindex, CHAR_GOLD); + gold1 -= itemindex1; + CHAR_setInt(meindex, CHAR_GOLD, gold1); + gold2 = CHAR_getInt(toindex, CHAR_GOLD); + gold2 += itemindex1; + CHAR_setInt(toindex, CHAR_GOLD, gold2); + } + // Ǯ <-> Ǯ + else if ((strcmp(a, "G") == 0) && (strcmp(b, "G") == 0)) + { + if (itemindex1 < 0) itemindex1 = 0; + if (itemindex2 < 0) itemindex2 = 0; + gold1 = CHAR_getInt(toindex, CHAR_GOLD); + gold1 = gold1 + itemindex1 - itemindex2; + CHAR_setInt(toindex, CHAR_GOLD, gold1); + gold2 = CHAR_getInt(meindex, CHAR_GOLD); + gold2 = gold2 + itemindex2 - itemindex1; + CHAR_setInt(meindex, CHAR_GOLD, gold2); + } + // <-> + else if ((strcmp(a, "P") == 0) && (strcmp(b, "P") == 0)) + { + char category[8]; + if ((item1 != -1) && (CHAR_CHECKINDEX(item1) == FALSE)) return FALSE; + if ((item2 != -1) && (CHAR_CHECKINDEX(item2) == FALSE)) return FALSE; + + if ((itemindex1 != -1) && (itemindex1 == CHAR_getInt(meindex, CHAR_DEFAULTPET))) + { + int fd; + CHAR_setInt(meindex, CHAR_DEFAULTPET, -1); + fd = getfdFromCharaIndex(meindex); + if (fd != -1){ + CHAR_setWorkInt( meindex, CHAR_WORK_PET0_STAT+itemindex1-1, 0); + lssproto_KS_send(fd, itemindex1, 0); + } + } + if ((itemindex2 != -1)&& (itemindex2 == CHAR_getInt(toindex, CHAR_DEFAULTPET))) + { + int tofd; + CHAR_setInt(toindex, CHAR_DEFAULTPET, -1); + tofd = getfdFromCharaIndex(toindex); + if (tofd != -1){ + CHAR_setWorkInt( toindex, CHAR_WORK_PET0_STAT+itemindex1-1, 0); + lssproto_KS_send(tofd, itemindex2, 0); + } + } + + if (item1 != -1) + CHAR_setWorkInt(item1, CHAR_WORKPLAYERINDEX, toindex); + if (item2 != -1) + CHAR_setWorkInt(item2, CHAR_WORKPLAYERINDEX, meindex); + if (itemindex1 == -1) + itemindex1 = CHAR_getCharPetElement( meindex); + if (itemindex2 == -1) + itemindex2 = CHAR_getCharPetElement( toindex); + CHAR_setCharPet(meindex, itemindex1, item2); + CHAR_setCharPet(toindex, itemindex2, item1); + if ((itemindex1 != -1) && (item1 != -1)) { + + CHAR_setChar(item1, CHAR_OWNERCDKEY, + CHAR_getChar(toindex, CHAR_CDKEY)); + CHAR_setChar(item1, CHAR_OWNERCHARANAME, + CHAR_getChar(toindex, CHAR_NAME)); + + CHAR_complianceParameter(item1); + CHAR_setInt(item1, CHAR_PUTPETTIME, 0); + } + if ((itemindex2 != -1) && (item2 != -1)) { + + CHAR_setChar(item2, CHAR_OWNERCDKEY, + CHAR_getChar(meindex, CHAR_CDKEY)); + CHAR_setChar(item2, CHAR_OWNERCHARANAME, + CHAR_getChar(meindex, CHAR_NAME)); + + CHAR_complianceParameter(item2); + CHAR_setInt(item2, CHAR_PUTPETTIME, 0); + } + snprintf(category, sizeof(category), "K%d", itemindex1); + CHAR_sendStatusString(meindex, category); + snprintf(category, sizeof(category), "W%d", itemindex1); + CHAR_sendStatusString(meindex, category); + snprintf(category, sizeof(category), "K%d", itemindex2); + CHAR_sendStatusString(toindex, category); + snprintf(category, sizeof(category), "W%d", itemindex2); + CHAR_sendStatusString(toindex, category); + } + return TRUE; +} +*/ +BOOL TRADE_HandleItem( int meindex, int showindex, char *message, char *outmess) +{ + char token[256]; + int item, itemindex; + int fd = getfdFromCharaIndex( meindex ); + + if( CONNECT_get_confirm( fd) == TRUE ) return FALSE; + + if( CHAR_getWorkInt( meindex, CHAR_WORKTRADEMODE) != CHAR_TRADE_TRADING + || CHAR_getWorkInt( meindex, CHAR_WORKTRADEMODE) == CHAR_TRADE_LOCK ) + return FALSE; + + if( getStringFromIndexWithDelim( message, "|", 6, token, sizeof( token)) == FALSE) return FALSE; + item = atoi( token); + if( item < CHAR_STARTITEMARRAY || item > CHAR_MAXITEMHAVE ){ + return FALSE; + } + itemindex = CHAR_getItemIndex(meindex, item); + if( !ITEM_CHECKINDEX( itemindex)) return FALSE; + + { + char itemname[256], tmpbuf[256], tmpbuf1[256]; + int crushe; + +#ifdef _ITEM_PILEFORTRADE + int nums = 0; + if( TRADE_addSomeTradeList( meindex, item, &nums, TRADE_ITEM) == FALSE ){ + return FALSE; + } +#endif + strcpy( itemname, ITEM_getChar(itemindex, ITEM_SECRETNAME));//ITEM_NAME + crushe = ITEM_getItemDamageCrusheED( itemindex); + sprintf( token, ""); // + + if( crushe >= 0 ) snprintf( token, sizeof(token), "%d%%", crushe ); + char szTemp1[256]; + sprintf(szTemp1," "); +#ifdef _TRADE_ITEM_FIX + if(getTradeItemFix()==1 && ( ITEM_getInt(itemindex,ITEM_MERGEFLG)==TRUE || strstr(ITEM_getChar(itemindex,ITEM_NAME),"ϳ")!=NULL ) ){ + char attnum[16]; + sprintf(attnum,""); + if(ITEM_getInt(itemindex,ITEM_MODIFYATTACK)!=0){ + if(ITEM_getInt(itemindex,ITEM_ATTACKNUM_MAX)>1){ + if(ITEM_getInt(itemindex,ITEM_ATTACKNUM_MIN)==ITEM_getInt(itemindex,ITEM_ATTACKNUM_MAX)){ + sprintf(attnum," (x%d)",ITEM_getInt(itemindex,ITEM_ATTACKNUM_MAX)); + }else{ + sprintf(attnum," (%d-%d)",ITEM_getInt(itemindex,ITEM_ATTACKNUM_MIN),ITEM_getInt(itemindex,ITEM_ATTACKNUM_MAX)); + } + } + if(strcmp(szTemp1," ")==0){ + sprintf(szTemp1,"%s%d%s ",(ITEM_getInt(itemindex,ITEM_MODIFYATTACK)>=0)?"+":"",ITEM_getInt(itemindex,ITEM_MODIFYATTACK),attnum); + }else{ + sprintf(szTemp1,"%s%s%d%s ",szTemp1,(ITEM_getInt(itemindex,ITEM_MODIFYATTACK)>=0)?"+":"",ITEM_getInt(itemindex,ITEM_MODIFYATTACK),attnum); + } + } + if(ITEM_getInt(itemindex,ITEM_MODIFYDEFENCE)!=0){ + if(strcmp(szTemp1," ")==0){ + sprintf(szTemp1,"%s%d ",(ITEM_getInt(itemindex,ITEM_MODIFYDEFENCE)>=0)?"+":"",ITEM_getInt(itemindex,ITEM_MODIFYDEFENCE)); + }else{ + sprintf(szTemp1,"%s%s%d ",szTemp1,(ITEM_getInt(itemindex,ITEM_MODIFYDEFENCE)>=0)?"+":"",ITEM_getInt(itemindex,ITEM_MODIFYDEFENCE)); + } + } + if(ITEM_getInt(itemindex,ITEM_MODIFYQUICK)!=0){ + if(strcmp(szTemp1," ")==0){ + sprintf(szTemp1,"%s%d ",(ITEM_getInt(itemindex,ITEM_MODIFYQUICK)>=0)?"+":"",ITEM_getInt(itemindex,ITEM_MODIFYQUICK)); + }else{ + sprintf(szTemp1,"%s%s%d ",szTemp1,(ITEM_getInt(itemindex,ITEM_MODIFYQUICK)>=0)?"+":"",ITEM_getInt(itemindex,ITEM_MODIFYQUICK)); + } + } + if(ITEM_getInt(itemindex,ITEM_MAGICID)>0){ + int marray = MAGIC_getMagicArray( ITEM_getInt( itemindex, ITEM_MAGICID)); + if( marray != -1 ){ + if( MAGIC_getChar( marray, MAGIC_NAME) != NULL ){ + if(strcmp(szTemp1," ")==0){ + sprintf(szTemp1,"%s ",MAGIC_getChar( marray, MAGIC_NAME)); + }else{ + sprintf(szTemp1,"%s%s ",szTemp1,MAGIC_getChar( marray, MAGIC_NAME)); + } + } + } + } + } +#endif + if(strcmp(szTemp1," ")==0) + sprintf(szTemp1,"%s",ITEM_getChar(itemindex,ITEM_EFFECTSTRING)); + char newitemname[128]; + memset(newitemname,0,sizeof(newitemname)); + if(strstr(ITEM_getChar( itemindex, ITEM_NAME),"Ѽ")!=NULL) + strcpy(newitemname, ITEM_getChar( itemindex, ITEM_SECRETNAME)); + else + strcpy(newitemname , ITEM_getChar( itemindex, ITEM_NAME)); +#ifdef _ITEM_PILENUMS + sprintf( outmess, "%d|%s|%s|%s|%d|%s|%d", +#else + sprintf( outmess, "%d|%s|%s|%d|%s", +#endif + ITEM_getInt( itemindex, ITEM_BASEIMAGENUMBER), + makeEscapeString( newitemname, tmpbuf1, sizeof(tmpbuf1)), + makeEscapeString( itemname, tmpbuf, sizeof(tmpbuf)), + szTemp1, item, token +#ifdef _ITEM_PILEFORTRADE + ,nums +#endif + ); + } + return TRUE; +} + +BOOL TRADE_HandleGold( int meindex, int showindex, char *message, char *outmess) +{ + int gold, tmpgold; + char token[256]; + int fd = getfdFromCharaIndex( meindex ); + if(CONNECT_get_confirm( fd)==TRUE)return FALSE; + if (CHAR_getWorkInt(meindex, CHAR_WORKTRADEMODE) != CHAR_TRADE_TRADING + || CHAR_getWorkInt(meindex, CHAR_WORKTRADEMODE) == CHAR_TRADE_LOCK) + return FALSE; + tmpgold = CHAR_getInt(meindex, CHAR_GOLD); + if (getStringFromIndexWithDelim(message, "|", 6, token, sizeof(token)) == FALSE) return FALSE; + if( (gold = atoi(token)) < 0 ) return FALSE; + if( gold > tmpgold )return FALSE; +#ifdef _ITEM_PILEFORTRADE + if( TRADE_addSomeTradeList( meindex, gold, NULL, TRADE_GOLD) == FALSE ) return FALSE; +#endif + sprintf( outmess, "%d", gold); + return TRUE; +} + +BOOL TRADE_HandlePet( int meindex, int showindex, char *message, char *outmess) +{ + int havepetindex, petindex; + char token[256], buf[256]; + int fd = getfdFromCharaIndex( meindex ); + if(CONNECT_get_confirm( fd)==TRUE)return FALSE; + if (CHAR_getWorkInt(meindex, CHAR_WORKTRADEMODE) != CHAR_TRADE_TRADING + || CHAR_getWorkInt(meindex, CHAR_WORKTRADEMODE) == CHAR_TRADE_LOCK) + return FALSE; + if (getStringFromIndexWithDelim(message, "|", 6, token, sizeof(token)) == FALSE) return FALSE; + if( (havepetindex = atoi(token)) < 0 ) return FALSE; + petindex = CHAR_getCharPet(meindex, havepetindex); + if( !CHAR_CHECKINDEX(petindex)) return FALSE; + +#ifdef _ITEM_PILEFORTRADE + if( TRADE_addSomeTradeList( meindex, havepetindex, NULL, TRADE_PET) == FALSE ) return FALSE; +#endif + sprintf( token, "%d|%s|%d|%d|%d|%d|%d|%d", + CHAR_getInt( petindex, CHAR_BASEIMAGENUMBER), + makeEscapeString( CHAR_getUseName(petindex), buf, sizeof(buf)), + CHAR_getInt( petindex, CHAR_LV), + CHAR_getWorkInt( petindex, CHAR_WORKATTACKPOWER), + CHAR_getWorkInt( petindex, CHAR_WORKDEFENCEPOWER), + CHAR_getWorkInt( petindex, CHAR_WORKQUICK), + havepetindex, + CHAR_getInt( petindex , CHAR_TRANSMIGRATION)); +#ifdef _TRADESYSTEM2 + { + int i; + char skillname[7][256]; + char buf1[256],buf2[256]; + for( i=0; i<7; i++){ + int skillarray, skillID; + memset( skillname[i], 0, sizeof(skillname[i])); + skillID = CHAR_getPetSkill( petindex, i); + skillarray = PETSKILL_getPetskillArray( skillID); + if( !PETSKILL_CHECKINDEX( skillarray)) continue; + sprintf( skillname[i], "%s", PETSKILL_getChar( skillarray, PETSKILL_NAME) ); + } +#ifdef _SHOW_FUSION + sprintf( outmess , "%s|%d|%d|%s|%s|%s|%s|%s|%s|%s|%s|%s|%d|", +#else + sprintf( outmess , "%s|%d|%d|%s|%s|%s|%s|%s|%s|%s|%s|%s", +#endif + token , CHAR_getWorkInt(petindex , CHAR_WORKMAXHP) , CHAR_getInt(petindex , CHAR_SLOT), + skillname[0] , skillname[1] , skillname[2] , skillname[3] , + skillname[4] , skillname[5] , skillname[6] , + makeEscapeString( CHAR_getChar( petindex, CHAR_NAME ), buf1, sizeof(buf1)), + makeEscapeString( CHAR_getUseName( petindex), buf2, sizeof(buf2)) +#ifdef _SHOW_FUSION + ,CHAR_getInt ( petindex, CHAR_FUSIONBEIT) ) ; +#else + ); +#endif +#ifdef _PET_ITEM + char token[512]=""; + int j; + for( j = 0 ; j < CHAR_MAXPETITEMHAVE ; j ++ ) + strcat(token,ITEM_petmakeItemStatusString(petindex, j)); + strcat(outmess,token); +#endif + } +#else + sprintf( outmess , "%s|%d", token , CHAR_getWorkInt(petindex , CHAR_WORKMAXHP) ); +#endif //_TRADESYSTEM2 + return TRUE; +} + +#ifdef _ITEM_PILEFORTRADE +BOOL TRADE_CheckTradeList( int meindex, STradeList *temp1, int toindex, STradeList *temp2) +{ + int i; + int MeSurplus=0, MeNeeds=0, MeMaxPile; + int ToSurplus=0, ToNeeds=0, ToMaxPile; + + + MeMaxPile = CHAR_getMyMaxPilenum( meindex);//ѵ + ToMaxPile = CHAR_getMyMaxPilenum( toindex); + + MeSurplus = CHAR_findSurplusItemBox( meindex); + ToSurplus = CHAR_findSurplusItemBox( toindex); + // + ToNeeds=0; MeNeeds=0; + for( i=0; i<15; i++ ){ + int pilenum, itemindex; + if( temp1->ItemTi[i] == -1 ) continue; + itemindex = CHAR_getItemIndex( meindex, temp1->ItemTi[i] ); + if( !ITEM_CHECKINDEX( itemindex)) return FALSE; + pilenum = ITEM_getInt( itemindex, ITEM_USEPILENUMS); + if( temp1->ItemNum[i] == pilenum ){ + MeSurplus++; + } + if( temp1->ItemNum[i] > ToMaxPile ){ + ToNeeds += (temp1->ItemNum[i]/ToMaxPile) + 1; + }else{ + ToNeeds++; + } + } + for( i=0; i<15; i++ ){ + int pilenum, itemindex; + if( temp2->ItemTi[i] == -1 ) continue; + itemindex = CHAR_getItemIndex( toindex, temp2->ItemTi[i] ); + if( !ITEM_CHECKINDEX( itemindex)) return FALSE; + pilenum = ITEM_getInt( itemindex, ITEM_USEPILENUMS); + if( temp2->ItemNum[i] == pilenum){ + ToSurplus++; + } + if( temp2->ItemNum[i] > MeMaxPile ){ + MeNeeds += (temp2->ItemNum[i]/MeMaxPile) + 1; + }else { + MeNeeds++; + } + } + if(CHAR_getInt(meindex,CHAR_FLOOR)==50000 && CHAR_getInt(toindex,CHAR_FLOOR)==50000 ) + { + if( MeSurplus < (MeNeeds+ToNeeds) ){ + CHAR_talkToCli( meindex, -1, "Ʒλ㡣", CHAR_COLORYELLOW); + CHAR_talkToCli( toindex, -1, "ԷƷλ㡣", CHAR_COLORYELLOW); + return FALSE; + } + if( ToSurplus < (ToNeeds+MeNeeds) ){ + CHAR_talkToCli( toindex, -1, "Ʒλ㡣", CHAR_COLORYELLOW); + CHAR_talkToCli( meindex, -1, "ԷƷλ㡣", CHAR_COLORYELLOW); + return FALSE; + } + } + else + { + if( MeSurplus < MeNeeds ){ + CHAR_talkToCli( meindex, -1, "Ʒλ㡣", CHAR_COLORYELLOW); + CHAR_talkToCli( toindex, -1, "ԷƷλ㡣", CHAR_COLORYELLOW); + return FALSE; + } + if( ToSurplus < ToNeeds ){ + CHAR_talkToCli( toindex, -1, "Ʒλ㡣", CHAR_COLORYELLOW); + CHAR_talkToCli( meindex, -1, "ԷƷλ㡣", CHAR_COLORYELLOW); + return FALSE; + } + } + + // + MeSurplus = CHAR_findSurplusPetBox( meindex); + ToSurplus = CHAR_findSurplusPetBox( toindex); + ToNeeds=0; MeNeeds=0; + for( i=0; i<5; i++ ){ + int petindex; + if( temp1->PetTi[i] == -1 ) continue; + petindex = CHAR_getCharPet( meindex, temp1->PetTi[i] ); + if( !CHAR_CHECKINDEX( petindex)) return FALSE; + MeSurplus++; + ToNeeds++; + } + for( i=0; i<5; i++ ){ + int petindex; + if( temp2->PetTi[i] == -1 ) continue; + petindex = CHAR_getCharPet( toindex, temp2->PetTi[i] ); + if( !CHAR_CHECKINDEX( petindex)) return FALSE; + ToSurplus++; + MeNeeds++; + } + if(CHAR_getInt(meindex,CHAR_FLOOR)==50000 && CHAR_getInt(toindex,CHAR_FLOOR)==50000 ) + { + if( MeSurplus < (MeNeeds+ToNeeds) ){ + CHAR_talkToCli( meindex, -1, "λ㡣", CHAR_COLORYELLOW); + CHAR_talkToCli( toindex, -1, "Էλ㡣", CHAR_COLORYELLOW); + return FALSE; + } + if( ToSurplus < (ToNeeds+MeNeeds) ){ + CHAR_talkToCli( meindex, -1, "Էλ㡣", CHAR_COLORYELLOW); + CHAR_talkToCli( toindex, -1, "λ㡣", CHAR_COLORYELLOW); + return FALSE; + } + } + else + { + if( MeSurplus < MeNeeds ){ + CHAR_talkToCli( meindex, -1, "λ㡣", CHAR_COLORYELLOW); + CHAR_talkToCli( toindex, -1, "Էλ㡣", CHAR_COLORYELLOW); + return FALSE; + } + if( ToSurplus < ToNeeds ){ + CHAR_talkToCli( meindex, -1, "Էλ㡣", CHAR_COLORYELLOW); + CHAR_talkToCli( toindex, -1, "λ㡣", CHAR_COLORYELLOW); + return FALSE; + } + } + + + //Ǯ + MeMaxPile = CHAR_getMaxHaveGold( meindex); + ToMaxPile = CHAR_getMaxHaveGold( toindex); + MeSurplus = MeMaxPile - CHAR_getInt( meindex, CHAR_GOLD); + ToSurplus = ToMaxPile - CHAR_getInt( toindex, CHAR_GOLD); + ToNeeds=0; MeNeeds=0; + MeSurplus += temp1->Golds; + ToSurplus += temp2->Golds; + ToNeeds = temp1->Golds; + MeNeeds = temp2->Golds; + if(CHAR_getInt(meindex,CHAR_FLOOR)==50000 && CHAR_getInt(toindex,CHAR_FLOOR)==50000 ) + { + if( MeSurplus < (MeNeeds+ToNeeds) ){ + CHAR_talkToCli( meindex, -1, "ʯҳޡ", CHAR_COLORYELLOW); + CHAR_talkToCli( toindex, -1, "Էʯҳޡ", CHAR_COLORYELLOW); + return FALSE; + } + if( ToSurplus < (ToNeeds+MeNeeds) ){ + CHAR_talkToCli( meindex, -1, "Էʯҳޡ", CHAR_COLORYELLOW); + CHAR_talkToCli( toindex, -1, "ʯҳޡ", CHAR_COLORYELLOW); + return FALSE; + } + } + else + { + if( MeSurplus < MeNeeds ){ + CHAR_talkToCli( meindex, -1, "ʯҳޡ", CHAR_COLORYELLOW); + CHAR_talkToCli( toindex, -1, "Էʯҳޡ", CHAR_COLORYELLOW); + return FALSE; + } + if( ToSurplus < ToNeeds ){ + CHAR_talkToCli( meindex, -1, "Էʯҳޡ", CHAR_COLORYELLOW); + CHAR_talkToCli( toindex, -1, "ʯҳޡ", CHAR_COLORYELLOW); + return FALSE; + } + } + return TRUE; +} +#endif diff --git a/configfile.c b/configfile.c new file mode 100644 index 0000000..89d6b9f --- /dev/null +++ b/configfile.c @@ -0,0 +1,5011 @@ +#define __CONFIGFILE_C__ +#include "version.h" +#include +#include +#include +#include + +#include "util.h" +//#include "configfile.h" +//ttom +#include "lssproto_util.h" +#include "configfile.h" +#include "net.h" +//ttom end +#include "npcutil.h" +// Arminius 7.12 login announce +#include "char.h" +#include "char_data.h" +// CoolFish: add +#include "lssproto_serv.h" + +#ifdef _ANGEL_SUMMON +extern struct MissionInfo missionlist[MAXMISSION]; +extern struct MissionTable missiontable[MAXMISSIONTABLE]; +#endif +#ifdef _UNTEXT_TALK +int textcnt=0; +char untext[100][64]; +#endif + +/* ɬë հ */ +typedef struct tagConfig +{ + /*ة ( ƻ */ + char progname[8]; + char configfilename[32]; /* config̻ */ + unsigned int debuglevel; /* ì */ + unsigned int usememoryunit; /*ƹ */ + unsigned int usememoryunitnum; /*ƹ */ + char asname[32]; /*ʧӡP */ + unsigned short acservport; /*ʧӡP̡ */ + char acpasswd[32]; /*ʧӡ߼ɵ*/ + char gsnamefromas[32]; /* + * ʧӡᆴέ + * ءةӡƻ + */ + + // Arminius 7.24 manor pk + char gsid[32]; // game server chinese id + unsigned short allowmanorpk; // is this server allow manor pk + unsigned short port; /* ӡPа̡ */ + int servernumber; /* ءةӡP į */ + int reuseaddr; /* Address already used... ئݼ׻ */ + int do_nodelay; /* TCP_NODELAY ¾ */ + int log_write_time; /* ̤ķë¾ */ + int log_io_time; /* I/O ޷¾ */ + int log_game_time; /* ءة ë */ + int log_netloop_faster; /* netloop_faster */ + int saacwritenum; /* ʧӡ߼ write¾ */ + int saacreadnum; /* ʧӡᆴռdispatch ëϼ¾ */ + unsigned short fdnum; /*ľë ¾ */ + unsigned int playercharnum; + unsigned int othercharnum; /* ְƽҷ¼ */ + unsigned int objnum; /* Ƥ */ + unsigned int petcharnum; /* ʸ */ + unsigned int itemnum; /* ʧ ة */ + unsigned int battlenum; /* P */ + unsigned int battleexp; /* P */ + char topdir[32]; /* ū */ + char mapdir[32]; /* Ѩū */ + char maptilefile[32]; /* Ѩɬð̻ */ + char battlemapfile[32]; /* Ѩɬð̻ */ + char itemfile[32]; /* ʧ ةɬð̻ */ + char invfile[32]; /* ɬð̻ */ + char appearfile[32]; /* ɬð̻ */ + char titlenamefile[32]; /* į̻ */ + char titleconfigfile[32]; /* įɬð̻ */ + char encountfile[32]; /* ޼ɬð̻ */ + char enemybasefile[32]; /* ɬð̻ */ + char enemyfile[32]; /* ɬð̻ */ + char groupfile[32]; /* ɬð̻ */ + char magicfile[32]; /* ɬð̻ */ +#ifdef _ATTACK_MAGIC + char attmagicfile[32]; // +#endif + + char petskillfile[32]; /* ʸ ɬð̻ */ + char itematomfile[32]; /* ʧ ة ̻ */ + char effectfile[32]; /* ɬð̻ */ + char quizfile[32]; /* ɬð̻ */ + char lsgenlog[32]; /*ӡPlsgen ʧ̻ */ + char storedir[128]; /*ʧū */ + char npcdir[32]; /*NPCɬð̻ë ʷū */ + char logdir[32]; /* + * 뷸ū + */ + char logconfname[32]; /* + * ɬð̻ + */ + char chatmagicpasswd[32]; /* ܷɵ */ +#ifdef _STORECHAR + char storechar[32]; +#endif + unsigned int chatmagiccdkeycheck; /* ܷƥCDKEYë¾ */ + unsigned int filesearchnum; /*̻ëƥ°̻P*/ + unsigned int npctemplatenum; /*NPC ̻P*/ + unsigned int npccreatenum; /*NPCϷDz̻P*/ + unsigned int walksendinterval; /* ʼë˪ */ + unsigned int CAsendinterval_ms; /* CAë˪ (ms)*/ + unsigned int CDsendinterval_ms; /* CDë˪ (ms)*/ + unsigned int Onelooptime_ms; /* 1微 */ + unsigned int Petdeletetime; /* ʸ */ + unsigned int Itemdeletetime; /* ʧ ة */ + /* ̼ ƽҷ¼Ƥë */ + unsigned int CharSavesendinterval; + unsigned int addressbookoffmsgnum; /* + * ʧƤͱ׷̼ + * ë + * ϶¾ + */ + unsigned int protocolreadfrequency; /* + * ë + * 꾮 + */ + unsigned int allowerrornum; /* + * ޷¡ëƥʾ + */ + unsigned int fengerrornum; + unsigned int loghour; /* + * ëݶ + */ + unsigned int battledebugmsg; /* + * 붪ëʾۨئئ + */ + //ttom add this because the second had this + unsigned int encodekey; + unsigned int acwbsize; + unsigned int acwritesize; + unsigned int ErrUserDownFlg; + //ttom end +#ifdef _GMRELOAD + char gmsetfile[32]; /* GMʺšȨ趨 */ +#endif + +#ifdef _PROFESSION_SKILL // WON ADD ְҵ + char profession[32]; +#endif +#ifdef _ITEM_QUITPARTY + char itemquitparty[32]; +#endif + +#ifdef _DEL_DROP_GOLD + unsigned int Golddeletetime; +#endif +#ifdef _NEW_PLAYER_CF + int newplayertrans; + int newplayerlv; + int newplayergivepet[5]; + int newplayergiveitem[15]; + int newplayerpetlv; + int newplayergivegold; + int ridepetlevel; +#ifdef _VIP_SERVER + int newplayerpetvip; +#endif +#endif +#ifdef _USER_EXP_CF + char expfile[64]; +#endif +#ifdef _UNLAW_WARP_FLOOR + int unlawwarpfloor[10]; +#endif +#ifdef _WATCH_FLOOR + int watchfloor[6]; +#endif +#ifdef _BATTLE_FLOOR + int battlefloor[6]; +#endif +#ifdef _UNREG_NEMA + char unregname[9][16]; +#endif +#ifdef _TRANS_LEVEL_CF + int chartrans; + int pettrans; + int yblevel; + int maxlevel; +#endif +#ifdef _POINT +int point; + int transpoint[10]; +#endif +#ifdef _VIP_SERVER + int vippoint; + int safemode; +#endif +#ifdef _PET_UP + int petup; +#endif +#ifdef _LOOP_ANNOUNCE + char loopannouncepath[32]; + int loopannouncetime; + char loopannounce[10][1024]; + int loopannouncemax; +#endif +#ifdef _SKILLUPPOINT_CF + int skup; +#endif +#ifdef _RIDELEVEL + int ridelevel; +#endif +#ifdef _REVLEVEL + int revlevel; +#endif +#ifdef _NEW_PLAYER_RIDE + int npride; +#endif +#ifdef _FIX_CHARLOOPS + int charloops; +#endif +#ifdef _PLAYER_ANNOUNCE + int pannounce; +#endif +#ifdef _PLAYER_MOVE + int pmove; +#endif + int recvbuffer; + int sendbuffer; + int recvlowatbuffer; + int runlevel; +#ifdef _SHOW_VIP_CF + int showvip; +#endif + int BattlePoint[4]; +#ifdef _ALL_TALK + int TheWorldTrans; + int TheWorldFame; + int TheWorldTime; + int TheWorldCnt; +#endif +#ifdef _NOWEN_EV + int NowEvent[10]; + int EndEvent[10]; +#endif +#ifdef _PLAYER_NUM + int playernum; + char playerbase[10]; +#endif +#ifdef _BATTLE_GOLD + int battlegold; +#endif +#ifdef _ANGEL_TIME + int angelplayertime; + int angelplayermun; +#endif +#ifdef _RIDEMODE_20 + int ridemode; +#endif +#ifdef _FM_POINT_PK + int fmpointpk; +#endif +#ifdef _ENEMY_ACTION + int enemyact; +#endif +#ifdef _FUSIONBEIT_TRANS + char fusionbeittrans; +#endif +#ifdef _CHECK_PEPEAT + int CheckRepeat; +#endif + int cpuuse; +#ifdef _FM_JOINLIMIT + int joinfamilytime; +#endif +#ifdef _JK_CF_DELPETITEM //ɾCFָƷͳ + char DelPet[256]; + char DelItem[256]; +#endif +#ifdef _MAP_HEAL + int MapHeal[10]; +#endif +#ifdef _DIY_INSLAY + int InslayNum; +#endif + int TradeTax; +#ifdef _VIP_RIDE + int VipMsgType; +#endif +#ifdef _VIP_BATTLE_EXP + int VipBattleExp; +#endif + int ItemPoolBug; + int SameIpLogin; + int PetRideTrans; +#ifdef _LUCK_MAN + int lucktime; + char luckitem[256]; +#endif +#ifdef _QUESTION_ONLINE + int questiontime; + char questionitem[50]; +#endif +#ifdef _NO_STREET_MAP + char nostreetmap[50]; +#endif +#ifdef _STREET_FAX + char streetfax[64]; +#endif + char fmwartime[10]; +#ifdef _JZ_NEWSCRIPT_LUA + char luafile[256]; +#endif +#ifdef _TRANS7_POINT + int trans7point; +#endif +#ifdef _NOJOB_PK + int nojobpkmap; +#endif +#ifdef _NO_ATTACK + int atttime; + int attsafetime; + int attcnt; + int latetime; + int attdmetime; + int attdmecnt; +#endif + char noattip[5][18]; +#ifdef _NO_TRANS_ANGLE + int trans6angle; +#endif +#ifdef _PET_BUG + int petpoint[4]; +#endif +#ifdef _VIGOR_SYS + int vigortime[8]; + int vigormax; +#endif +#ifdef _AUTO_PK + int autopktime; + int autopkminnum; + int autopkbattletime; + int autopkminlv; + int autopkvigorpknum; + int autopkvigorpkcnt; +#endif +#ifdef _BATTLEMAP_CTRL + char BattleTime[10][20]; +#endif +#ifdef _FM_SERVERNO_SYS + int fmserverno; + char fmservermsg[256]; +#endif +#ifdef _ZHIPIAO_SYSTEM + int zhipiao; + int piaotime; +#endif +#ifdef _FMWAR_MSG + char fmwarmsg[256]; +#endif +#ifdef _FM_WELFARE + char fmwelfare[10][20]; +#endif +#ifdef _FMZUZHANG_MSG + char fmzuzhang[256]; +#endif +#ifdef _PETMAIL_LV + int petmaillv; + int petmailcf; +#endif +#ifdef _FMWAR_PLAYERNUM + int fmwarplayernum; +#endif +#ifdef _WAN_FIX + int vsflg; +#endif +#ifdef _WARNPC_CTRL + char partymap[128]; + char mapsameip[32]; +#endif +#ifdef _NO_DAOLUAN + int streettrn; + int talktrn; + int talklv; + char talkmsg[128]; + char talkname[128]; +#endif +#ifdef _NO_FULLPLAYER_ATT + int nofullplayer; + int nofull2player; + int nocdkeyplayer; + int nocdkeymode; + int nocdkeytype; + int nofulltime; + int fengtype; + int nofullendplayer; + int nofullendtime; + int manrennum; + int bigbao; + int bigbao2; +#endif +#ifdef _ATTREVERSE_FIX + int attreverse; +#endif +#ifdef _NEWFM_GOLD + int newfmgold; +#endif +#ifdef _MERGE_TIME + int mergetime; +#endif +#ifdef _PETUP_GET_EXP + int petupgetexp; +#endif +#ifdef _MM_NO_JIAOBEN + int nommjiaoben; + int editbasetime; +#endif +#ifdef _DP_140_160_MODE + int newdpmode; +#endif +#ifdef _LOOK_STREET_TIME + int lookstreettime; +#endif +#ifdef _BATTLE_EQUIT_OTHER + int battleequitother; +#endif +#ifdef _PK_LUCK_MAN + char pkluckfloor[256]; + char pkluckmapname[10][32]; + char pklucktime[10]; + char pklucknum[10]; + char pkluckbuf[512]; + int pklucklevel; + int pkluckbattleturn; +#endif +#ifdef _NO_DAOLUAN + char talkfloor[512]; +#endif +#ifdef _SUPERMAN_FIX + int supermanpoint; +#endif +#ifdef _PICKUP_ITEM_OTHER + int pickupitem; + char pickitemid[512]; +#endif +#ifdef _FM_LIAOLI + int fmliaolitype; +#endif +#ifdef _TRADE_ITEM_FIX + int tradeitemfix; +#endif +#ifdef _PETMAIL_TIME + int petmailtime; +#endif + int randmin; + int randmax; +#ifdef _GJS_TYPE + int gjstype; +#endif + int ticketcf; + char ticketmsg[256]; + int satype; +#ifdef _BATTLEEND_FIX + int battleendmode; +#endif +#ifdef _BIG_POOL_TYPE + int petpooltype; + int itempooltype; +#endif + int nostaybattle; + int rightnum; + int rightmode; + int errormode; +#ifdef _FLOOR_PARTY_CTRL + char partyfloor[128]; +#endif + int battletimeout; + int reloadnpctime; + int reloadnpctype; + int offlinebattletime; + int offlinecf; + int offlinemaxnum; + int offlinejqmmaxnum; + int kongtype; + int jifenbaitan; + char streetitemunname[2048]; + int nopkmap; + int fmbufftrans; + char nompmagic[1024]; + + int loginjqmtype; + char fmmagicmprate[2][10]; + int sameipnum; + int samejqmnum; + int samejqmallnum; + + int mmtype; + char mmmsg[1024]; + + int locktype; + int alltalkpoint; +#ifdef _NO_RIDE_ID + char norideid[1024]; +#endif + + int logintype; + + + +#ifdef _PETTRANS_RANGE + int pettransrangex; + int pettransrangey; + int pettransrangez; +#endif + +#ifdef _ITEM_LUA +char itemluafile[256]; +#endif +#ifdef _SAME_IP_ONLINE_NUM + int sameiponlinenum; +#endif +#ifdef _CHECK_SEVER_IP + char serverip[256]; +#endif +#ifdef _CAX_ESC_REPORT + int reportitem[5]; /*ÿǩͶ*/ + int vipreportitem[5]; /*ÿǩԱͶ*/ + int reportlv;//ǩȼ + int reportta;//ǩת +#endif +#ifdef _PETSKILL_SHOP_LUA + char freepetskillshoppath[256]; +#endif +#ifdef _CAX_FAMEBUTTON + int famebutton; +#endif +#ifdef _PET_TRANS_ABILITY + int pettransability; + int pettransability1; + int pettransability2; + int pettransability3; +#endif +#ifdef _PET_3TRANS + int MMPETID1; + int MMPETID2; +#endif +#ifdef _NO_MAGIC + char nomagicmap[128]; +#endif +#ifdef _illegalpetskill_CF + int IllegalPetskill[10]; +#endif +#ifdef _CAX_PET_EVOLUTION + char petevotyb; + int petevotyb1; +#endif +#ifdef _TRANS_7_COLOR +// int TranColor; + char ping; + char petsummon; +#endif +#ifdef _CAX_PET_ITEMRIDE + char petitemride; +#endif +#ifdef _DAMMAGE_CALC + int dammagecalc; +#endif +#ifdef _CAX_LNS_NLSUOXU + int mapstart; +#endif +#ifdef _CAX_FAME_KOUFEI + int famekoufei; +#endif +#ifdef _CAX_ITEM_ADDEXP + int exptime; +#endif +#ifdef _SHARE_EXP + int expshare; +#endif +#ifdef _TEAM_ADDEXP + int teamaddexp; +#endif +#ifdef _NO_STW_ENEMY + int nostwenemy; + int nostwenemypoint; +#endif +#ifdef _DEX_FIX //ϵ +int dexfixper; +#endif +#ifdef _FM_EXP_ADD + unsigned int fmaddexp; +#endif + +}Config; + +Config config; + +#ifdef _USER_EXP_CF +int NeedLevelUpTbls[200]; +#endif + +/* + * ū̻ë ݱհ + * xxxx=yyyy ئë + */ + +typedef struct tagReadConf +{ + char name[32]; /*xxxxؤ°*/ + + /*ݼ2NULLë ľ ئ*/ + char *charvalue; /*yyyyëҽ ݼҽ */ + size_t charsize; /*charvalue*/ + + /* + * ƻ= "ON" intvalue 巴1ëҽ + * ľ½ atoi + */ + void* value; /*yyyyë ҽ ݼҽ */ + CTYPE valuetype; +}ReadConf; + +ReadConf readconf[]= +{ + { "debuglevel" , NULL ,0 , (void*)&config.debuglevel ,CHAR}, + + { "usememoryunit" , NULL ,0 , (void*)&config.usememoryunit ,INT}, + { "usememoryunitnum", NULL ,0 , (void*)&config.usememoryunitnum,INT}, + + { "acserv", config.asname,sizeof(config.asname) ,NULL , 0}, + { "acservport", NULL ,0 , (void*)&config.acservport ,SHORT}, + { "acpasswd", config.acpasswd,sizeof( config.acpasswd),NULL,0}, + { "gameservname", config.gsnamefromas,sizeof(config.gsnamefromas), NULL,0}, + + // Arminius 7.24 manor pk + { "gameservid", config.gsid, sizeof(config.gsid), NULL, 0}, + { "allowmanorpk", NULL, 0, (void*)&config.allowmanorpk, SHORT}, + + { "port", NULL ,0 , (void*)&config.port ,SHORT}, + { "servernumber", NULL ,0 , (void*)&config.servernumber ,INT}, + + { "reuseaddr", NULL ,0 , (void*)&config.reuseaddr , INT}, + { "nodelay", NULL , 0 , (void*)&config.do_nodelay , INT}, + { "log_write_time", NULL, 0 , (void*)&config.log_write_time, INT}, + { "log_io_time", NULL, 0 , (void*)&config.log_io_time, INT}, + { "log_game_time", NULL, 0 , (void*)&config.log_game_time, INT}, + { "log_netloop_faster", NULL,0,(void*)&config.log_netloop_faster, INT}, + { "saacwritenum", NULL,0,(void*)&config.saacwritenum, INT}, + { "saacreadnum", NULL,0,(void*)&config.saacreadnum, INT}, + { "fdnum", NULL ,0 , (void*)&config.fdnum, SHORT}, + { "playernum", NULL ,0 , (void*)&config.playercharnum, INT}, + { "petnum", NULL ,0 , (void*)&config.petcharnum, INT}, + { "othercharnum", NULL ,0 , (void*)&config.othercharnum, INT}, + + { "objnum", NULL ,0 , (void*)&config.objnum, INT}, + { "itemnum", NULL ,0 , (void*)&config.itemnum, INT}, + { "battlenum", NULL ,0 , (void*)&config.battlenum, INT}, + { "battleexp", NULL ,0 , (void*)&config.battleexp, INT}, + { "topdir" , config.topdir,sizeof(config.topdir),NULL,0}, + { "mapdir" , config.mapdir,sizeof(config.mapdir),NULL,0}, + { "maptilefile" , config.maptilefile,sizeof(config.maptilefile),NULL,0}, + { "battlemapfile" , config.battlemapfile,sizeof(config.battlemapfile),NULL,0}, + +#ifdef _ITEMSET6_TXT + { "itemset6file", config.itemfile, sizeof(config.invfile), NULL, 0}, +#else +#ifdef _ITEMSET5_TXT + { "itemset5file", config.itemfile, sizeof(config.invfile), NULL, 0}, +#else +#ifdef _ITEMSET4_TXT + { "itemset4file" , config.itemfile,sizeof(config.invfile),NULL,0}, +#else +#ifdef _ITEMSET3_ITEM + { "itemset3file" , config.itemfile,sizeof(config.invfile),NULL,0}, +#endif +#endif +#endif +#endif + { "invinciblefile" , config.invfile,sizeof(config.invfile),NULL,0}, + { "appearpositionfile" , config.appearfile,sizeof(config.appearfile),NULL,0}, + { "titlenamefile", config.titlenamefile, sizeof( config.titlenamefile),NULL,0}, + { "titleconfigfile", config.titleconfigfile, sizeof( config.titleconfigfile),NULL,0}, + { "encountfile", config.encountfile, sizeof( config.encountfile),NULL,0}, + { "enemyfile", config.enemyfile, sizeof( config.enemyfile),NULL,0}, + { "enemybasefile", config.enemybasefile, sizeof( config.enemybasefile),NULL,0}, + { "groupfile", config.groupfile, sizeof( config.groupfile),NULL,0}, + { "magicfile", config.magicfile, sizeof( config.magicfile),NULL,0}, +#ifdef _ATTACK_MAGIC + { "attmagicfile" , config.attmagicfile , sizeof( config.attmagicfile ) , NULL , 0 }, +#endif + +#ifdef _PETSKILL2_TXT + { "petskillfile2", config.petskillfile, sizeof( config.petskillfile),NULL,0}, +#else + { "petskillfile1", config.petskillfile, sizeof( config.petskillfile),NULL,0}, +#endif + + { "itematomfile" , config.itematomfile, sizeof( config.itematomfile),NULL,0}, + { "effectfile" , config.effectfile,sizeof(config.effectfile),NULL,0}, + { "quizfile" , config.quizfile,sizeof(config.quizfile),NULL,0}, + + { "lsgenlogfilename", config.lsgenlog,sizeof(config.lsgenlog),NULL,0}, +#ifdef _GMRELOAD + { "gmsetfile", config.gmsetfile, sizeof( config.gmsetfile),NULL,0}, +#endif + + { "storedir" ,config.storedir,sizeof(config.storedir),NULL,0}, + { "npcdir" ,config.npcdir,sizeof(config.npcdir),NULL,0}, + { "logdir" ,config.logdir,sizeof(config.logdir),NULL,0}, + { "logconfname" ,config.logconfname,sizeof(config.logconfname),NULL,0}, + { "chatmagicpasswd", config.chatmagicpasswd, sizeof( config.chatmagicpasswd),NULL,0}, +#ifdef _STORECHAR + { "storechar", config.storechar, sizeof( config.storechar),NULL,0}, +#endif + { "chatmagiccdkeycheck", NULL,0, &config.chatmagiccdkeycheck,INT}, + { "filesearchnum", NULL,0, &config.filesearchnum,INT}, + { "npctemplatenum", NULL,0, &config.npctemplatenum,INT}, + { "npccreatenum", NULL,0, &config.npccreatenum,INT}, + { "walkinterval" ,NULL,0,(void*)&config.walksendinterval,INT}, + { "CAinterval" ,NULL,0,(void*)&config.CAsendinterval_ms,INT}, + { "CDinterval" ,NULL,0,(void*)&config.CDsendinterval_ms,INT}, + { "CharSaveinterval" ,NULL,0,(void*)&config.CharSavesendinterval,INT}, + { "Onelooptime" ,NULL,0,(void*)&config.Onelooptime_ms,INT}, + { "Petdeletetime" ,NULL,0,(void*)&config.Petdeletetime,INT}, + { "Itemdeletetime" ,NULL,0,(void*)&config.Itemdeletetime,INT}, + { "addressbookoffmesgnum" ,NULL,0, + (void*)&config.addressbookoffmsgnum,INT}, + + { "protocolreadfrequency" ,NULL,0, + (void*)&config.protocolreadfrequency,INT}, + + { "allowerrornum" ,NULL,0,(void*)&config.allowerrornum,INT}, + { "fengerrornum" ,NULL,0,(void*)&config.fengerrornum,INT}, + { "loghour" ,NULL,0,(void*)&config.loghour,INT}, + { "battledebugmsg" ,NULL,0,(void*)&config.battledebugmsg,INT}, + //ttom add because the second had + { "encodekey" ,NULL,0,(void*)&config.encodekey,INT}, + { "acwritesize" ,NULL,0,(void*)&config.acwritesize,INT}, + { "acwbsize" ,NULL,0,(void*)&config.acwbsize,INT}, + { "erruser_down" ,NULL,0,(void*)&config.ErrUserDownFlg,INT}, + +#ifdef _PROFESSION_SKILL // WON ADD ְҵ + { "profession", config.profession, sizeof(config.profession) ,NULL , 0}, +#endif + +#ifdef _ITEM_QUITPARTY + { "itemquitparty", config.itemquitparty, sizeof(config.itemquitparty) ,NULL , 0}, +#endif + +#ifdef _DEL_DROP_GOLD + { "Golddeletetime" ,NULL,0,(void*)&config.Golddeletetime, INT}, +#endif + +#ifdef _MAP_HEAL + { "MAPHEAL1" ,NULL,0,(void*)&config.MapHeal[0], INT}, + { "MAPHEAL2" ,NULL,0,(void*)&config.MapHeal[1], INT}, + { "MAPHEAL3" ,NULL,0,(void*)&config.MapHeal[2], INT}, + { "MAPHEAL4" ,NULL,0,(void*)&config.MapHeal[3], INT}, + { "MAPHEAL5" ,NULL,0,(void*)&config.MapHeal[4], INT}, + { "MAPHEAL6" ,NULL,0,(void*)&config.MapHeal[5], INT}, + { "MAPHEAL7" ,NULL,0,(void*)&config.MapHeal[6], INT}, + { "MAPHEAL8" ,NULL,0,(void*)&config.MapHeal[7], INT}, + { "MAPHEAL9" ,NULL,0,(void*)&config.MapHeal[8], INT}, + { "MAPHEAL10" ,NULL,0,(void*)&config.MapHeal[9], INT}, +#endif + +#ifdef _NEW_PLAYER_CF + { "TRANS" ,NULL,0,(void*)&config.newplayertrans, INT}, + { "LV" ,NULL,0,(void*)&config.newplayerlv, INT}, + { "PET1" ,NULL,0,(void*)&config.newplayergivepet[1], INT}, + { "PET2" ,NULL,0,(void*)&config.newplayergivepet[2], INT}, + { "PET3" ,NULL,0,(void*)&config.newplayergivepet[3], INT}, + { "PET4" ,NULL,0,(void*)&config.newplayergivepet[4], INT}, + { "ITEM1" ,NULL,0,(void*)&config.newplayergiveitem[0], INT}, + { "ITEM2" ,NULL,0,(void*)&config.newplayergiveitem[1], INT}, + { "ITEM3" ,NULL,0,(void*)&config.newplayergiveitem[2], INT}, + { "ITEM4" ,NULL,0,(void*)&config.newplayergiveitem[3], INT}, + { "ITEM5" ,NULL,0,(void*)&config.newplayergiveitem[4], INT}, + { "ITEM6" ,NULL,0,(void*)&config.newplayergiveitem[5], INT}, + { "ITEM7" ,NULL,0,(void*)&config.newplayergiveitem[6], INT}, + { "ITEM8" ,NULL,0,(void*)&config.newplayergiveitem[7], INT}, + { "ITEM9" ,NULL,0,(void*)&config.newplayergiveitem[8], INT}, + { "ITEM10" ,NULL,0,(void*)&config.newplayergiveitem[9], INT}, + { "ITEM11" ,NULL,0,(void*)&config.newplayergiveitem[10], INT}, + { "ITEM12" ,NULL,0,(void*)&config.newplayergiveitem[11], INT}, + { "ITEM13" ,NULL,0,(void*)&config.newplayergiveitem[12], INT}, + { "ITEM14" ,NULL,0,(void*)&config.newplayergiveitem[13], INT}, + { "ITEM15" ,NULL,0,(void*)&config.newplayergiveitem[14], INT}, + { "PETLV" ,NULL,0,(void*)&config.newplayerpetlv, INT}, + { "GOLD" ,NULL,0,(void*)&config.newplayergivegold, INT}, + { "RIDEPETLEVEL" ,NULL,0,(void*)&config.ridepetlevel, INT}, +#ifdef _VIP_SERVER + { "GIVEVIPPOINT" ,NULL,0,(void*)&config.newplayerpetvip, INT}, + { "SAFEMODE" ,NULL,0,(void*)&config.safemode, INT}, +#endif +#endif + +#ifdef _USER_EXP_CF + { "USEREXP", config.expfile, sizeof( config.expfile),NULL,0}, +#endif + +#ifdef _UNLAW_WARP_FLOOR + { "FLOOR1" ,NULL,0,(void*)&config.unlawwarpfloor[0], INT}, + { "FLOOR2" ,NULL,0,(void*)&config.unlawwarpfloor[1], INT}, + { "FLOOR3" ,NULL,0,(void*)&config.unlawwarpfloor[2], INT}, + { "FLOOR4" ,NULL,0,(void*)&config.unlawwarpfloor[3], INT}, + { "FLOOR5" ,NULL,0,(void*)&config.unlawwarpfloor[4], INT}, + { "FLOOR6" ,NULL,0,(void*)&config.unlawwarpfloor[5], INT}, + { "FLOOR7" ,NULL,0,(void*)&config.unlawwarpfloor[6], INT}, + { "FLOOR8" ,NULL,0,(void*)&config.unlawwarpfloor[7], INT}, + { "FLOOR9" ,NULL,0,(void*)&config.unlawwarpfloor[8], INT}, + { "FLOOR10" ,NULL,0,(void*)&config.unlawwarpfloor[9], INT}, +#endif + +#ifdef _WATCH_FLOOR + { "WATCHFLOOR" ,NULL,0,(void*)&config.watchfloor[0], INT}, + { "WATCHFLOOR1" ,NULL,0,(void*)&config.watchfloor[1], INT}, + { "WATCHFLOOR2" ,NULL,0,(void*)&config.watchfloor[2], INT}, + { "WATCHFLOOR3" ,NULL,0,(void*)&config.watchfloor[3], INT}, + { "WATCHFLOOR4" ,NULL,0,(void*)&config.watchfloor[4], INT}, + { "WATCHFLOOR5" ,NULL,0,(void*)&config.watchfloor[5], INT}, +#endif + +#ifdef _BATTLE_FLOOR + { "BATTLEFLOOR" ,NULL,0,(void*)&config.battlefloor[0], INT}, + { "BATTLEFLOOR1" ,NULL,0,(void*)&config.battlefloor[1], INT}, + { "BATTLEFLOOR2" ,NULL,0,(void*)&config.battlefloor[2], INT}, + { "BATTLEFLOOR3" ,NULL,0,(void*)&config.battlefloor[3], INT}, + { "BATTLEFLOOR4" ,NULL,0,(void*)&config.battlefloor[4], INT}, + { "BATTLEFLOOR5" ,NULL,0,(void*)&config.battlefloor[5], INT}, +#endif +#ifdef _JK_CF_DELPETITEM //ɾCFָƷͳ + { "DELPET", config.DelPet, sizeof( config.DelPet),NULL,0}, + { "DELITEM", config.DelItem, sizeof( config.DelItem),NULL,0}, +#endif +#ifdef _UNREG_NEMA + { "NAME1" ,config.unregname[0], sizeof( config.unregname[0]),NULL,0}, + { "NAME2" ,config.unregname[1], sizeof( config.unregname[1]),NULL,0}, + { "NAME3" ,config.unregname[2], sizeof( config.unregname[2]),NULL,0}, + { "NAME4" ,config.unregname[3], sizeof( config.unregname[3]),NULL,0}, + { "NAME5" ,config.unregname[4], sizeof( config.unregname[4]),NULL,0}, + { "NAME6" ,config.unregname[5], sizeof( config.unregname[5]),NULL,0}, + { "NAME7" ,config.unregname[6], sizeof( config.unregname[6]),NULL,0}, + { "NAME8" ,config.unregname[7], sizeof( config.unregname[7]),NULL,0}, + { "NAME9" ,config.unregname[8], sizeof( config.unregname[8]),NULL,0}, +#endif +#ifdef _TRANS_LEVEL_CF + { "CHARTRANS" ,NULL,0,(void*)&config.chartrans, INT}, + { "PETTRANS" ,NULL,0,(void*)&config.pettrans, INT}, + { "LEVEL" ,NULL,0,(void*)&config.yblevel, INT}, + { "MAXLEVEL" ,NULL,0,(void*)&config.maxlevel, INT}, +#endif +#ifdef _POINT + { "POINT" ,NULL,0,(void*)&config.point, INT}, + { "TRANS0" ,NULL,0,(void*)&config.transpoint[0], INT}, + { "TRANS1" ,NULL,0,(void*)&config.transpoint[1], INT}, + { "TRANS2" ,NULL,0,(void*)&config.transpoint[2], INT}, + { "TRANS3" ,NULL,0,(void*)&config.transpoint[3], INT}, + { "TRANS4" ,NULL,0,(void*)&config.transpoint[4], INT}, + { "TRANS5" ,NULL,0,(void*)&config.transpoint[5], INT}, + { "TRANS6" ,NULL,0,(void*)&config.transpoint[6], INT}, + { "TRANS7" ,NULL,0,(void*)&config.transpoint[7], INT}, + { "TRANS8" ,NULL,0,(void*)&config.transpoint[8], INT}, + { "TRANS9" ,NULL,0,(void*)&config.transpoint[9], INT}, +#endif + +#ifdef _NOWEN_EV + { "endevent01" , NULL ,0 , (void*)&config.EndEvent[0] ,INT}, + { "endevent02" , NULL ,0 , (void*)&config.EndEvent[1] ,INT}, + { "endevent03" , NULL ,0 , (void*)&config.EndEvent[2] ,INT}, + { "endevent04" , NULL ,0 , (void*)&config.EndEvent[3] ,INT}, + { "endevent05" , NULL ,0 , (void*)&config.EndEvent[4] ,INT}, + { "endevent06" , NULL ,0 , (void*)&config.EndEvent[5] ,INT}, + { "endevent07" , NULL ,0 , (void*)&config.EndEvent[6] ,INT}, + { "endevent08" , NULL ,0 , (void*)&config.EndEvent[7] ,INT}, + { "endevent09" , NULL ,0 , (void*)&config.EndEvent[8] ,INT}, + { "endevent10" , NULL ,0 , (void*)&config.EndEvent[9] ,INT}, + { "nowevent01" , NULL ,0 , (void*)&config.NowEvent[0] ,INT}, + { "nowevent02" , NULL ,0 , (void*)&config.NowEvent[1] ,INT}, + { "nowevent03" , NULL ,0 , (void*)&config.NowEvent[2] ,INT}, + { "nowevent04" , NULL ,0 , (void*)&config.NowEvent[3] ,INT}, + { "nowevent05" , NULL ,0 , (void*)&config.NowEvent[4] ,INT}, + { "nowevent06" , NULL ,0 , (void*)&config.NowEvent[5] ,INT}, + { "nowevent07" , NULL ,0 , (void*)&config.NowEvent[6] ,INT}, + { "nowevent08" , NULL ,0 , (void*)&config.NowEvent[7] ,INT}, + { "nowevent09" , NULL ,0 , (void*)&config.NowEvent[8] ,INT}, + { "nowevent10" , NULL ,0 , (void*)&config.NowEvent[9] ,INT}, +#endif + { "battlepoint1" , NULL ,0 , (void*)&config.BattlePoint[0] ,INT}, + { "battlepoint2" , NULL ,0 , (void*)&config.BattlePoint[1] ,INT}, + { "battlepoint3" , NULL ,0 , (void*)&config.BattlePoint[2] ,INT}, + { "battlepoint4" , NULL ,0 , (void*)&config.BattlePoint[3] ,INT}, +#ifdef _ALL_TALK + { "THEWORLDTRANS" , NULL ,0 , (void*)&config.TheWorldTrans ,INT}, + { "THEWORLDFAME" , NULL ,0 , (void*)&config.TheWorldFame ,INT}, + { "THEWORLDTIME" , NULL ,0 , (void*)&config.TheWorldTime ,INT}, + { "THEWORLDCNT" , NULL ,0 , (void*)&config.TheWorldCnt ,INT}, +#endif +#ifdef _DIY_INSLAY + { "InslayNum" , NULL ,0 , (void*)&config.InslayNum ,INT}, +#endif + { "TradeTax" , NULL ,0 , (void*)&config.TradeTax ,INT}, + { "VipMsgType" , NULL ,0 , (void*)&config.VipMsgType ,INT}, +#ifdef _VIP_BATTLE_EXP + { "VipBattleExp" , NULL ,0 , (void*)&config.VipBattleExp ,INT}, +#endif + { "ItemPoolBug" , NULL ,0 , (void*)&config.ItemPoolBug ,INT}, +#ifdef _PET_UP + { "PETUP" ,NULL,0,(void*)&config.petup, INT}, +#endif +#ifdef _LOOP_ANNOUNCE + { "ANNOUNCEPATH" ,config.loopannouncepath, sizeof( config.loopannouncepath),NULL,0}, + { "ANNOUNCETIME" ,NULL,0,(void*)&config.loopannouncetime, INT}, +#endif +#ifdef _SKILLUPPOINT_CF + { "SKILLUPPOINT" ,NULL,0,(void*)&config.skup, INT}, +#endif +#ifdef _RIDELEVEL + { "RIDELEVEL" ,NULL,0,(void*)&config.ridelevel, INT}, +#endif + { "PETRIDETRANS" ,NULL,0,(void*)&config.PetRideTrans, INT}, +#ifdef _REVLEVEL + { "REVLEVEL" ,NULL,0,(void*)&config.revlevel, INT}, +#endif +#ifdef _NEW_PLAYER_RIDE + { "NPRIDE" ,NULL,0,(void*)&config.npride, INT}, +#endif +#ifdef _FIX_CHARLOOPS + { "CHARLOOPS" ,NULL,0,(void*)&config.charloops, INT}, +#endif +#ifdef _PLAYER_ANNOUNCE + { "PANNOUNCE" ,NULL,0,(void*)&config.pannounce, INT}, +#endif +#ifdef _PLAYER_MOVE + { "PMOVE" ,NULL,0,(void*)&config.pmove, INT}, +#endif + + { "recvbuffer" ,NULL,0,(void*)&config.recvbuffer, INT}, + { "sendbuffer" ,NULL,0,(void*)&config.sendbuffer, INT}, + { "recvlowatbuffer" ,NULL,0,(void*)&config.recvlowatbuffer, INT}, + { "runlevel" ,NULL,0,(void*)&config.runlevel, INT}, + +#ifdef _SHOW_VIP_CF + { "SHOWVIP" ,NULL,0,(void*)&config.showvip, INT}, +#endif + +#ifdef _PLAYER_NUM + { "PLAYERNUM" ,NULL,0,(void*)&config.playernum, INT}, + { "PLAYERBASE" , config.playerbase,sizeof(config.playerbase),NULL,0}, +#endif + +#ifdef _BATTLE_GOLD + { "BATTLEGOLD" ,NULL,0,(void*)&config.battlegold, INT}, +#endif +#ifdef _ANGEL_TIME + { "ANGELPLAYERTIME" ,NULL,0,(void*)&config.angelplayertime, INT}, + { "ANGELPLAYERMUN" ,NULL,0,(void*)&config.angelplayermun, INT}, +#endif +#ifdef _RIDEMODE_20 + { "RIDEMODE" ,NULL,0,(void*)&config.ridemode, INT}, +#endif +#ifdef _FM_POINT_PK + { "FMPOINTPK" ,NULL,0,(void*)&config.fmpointpk, INT}, +#endif +#ifdef _ENEMY_ACTION + { "ENEMYACTION" ,NULL,0,(void*)&config.enemyact, INT}, +#endif +#ifdef _FUSIONBEIT_TRANS + { "FUSIONBEIT" ,NULL,0,(void*)&config.fusionbeittrans, INT}, +#endif +#ifdef _CHECK_PEPEAT + { "CHECKPEPEAT" ,NULL,0,(void*)&config.CheckRepeat, INT}, +#endif + { "CPUUSE" ,NULL,0,(void*)&config.cpuuse, INT}, +#ifdef _FM_JOINLIMIT + { "JOINFAMILYTIME" ,NULL,0,(void*)&config.joinfamilytime, INT}, +#endif + { "SAMEIPLOGIN" ,NULL,0,(void*)&config.SameIpLogin, INT}, +#ifdef _LUCK_MAN + { "LUCKTIME" ,NULL,0,(void*)&config.lucktime, INT}, + { "LUCKITEM" , config.luckitem,sizeof(config.luckitem),NULL,0}, +#endif +#ifdef _QUESTION_ONLINE + { "QUESTIONTIME" ,NULL,0,(void*)&config.questiontime, INT}, + { "QUESTIONITEM" , config.questionitem,sizeof(config.questionitem),NULL,0}, +#endif +#ifdef _NO_STREET_MAP + { "NOSTREETMAP" , config.nostreetmap,sizeof(config.nostreetmap),NULL,0}, +#endif +#ifdef _STREET_FAX + { "STREETFAX" ,config.streetfax,sizeof(config.streetfax),NULL,0}, +#endif + { "FMWARTIME" , config.fmwartime,sizeof(config.fmwartime),NULL,0}, +#ifdef _JZ_NEWSCRIPT_LUA + { "LUAFILE" , config.luafile,sizeof(config.luafile),NULL,0}, +#endif +#ifdef _TRANS7_POINT + { "TRANS7POINT" ,NULL,0,(void*)&config.trans7point, INT}, +#endif +#ifdef _NOJOB_PK + { "NOJOBPKMAP" ,NULL,0,(void*)&config.nojobpkmap, INT}, +#endif +#ifdef _NO_ATTACK + { "ATTTIME" ,NULL,0,(void*)&config.atttime, INT}, + { "ATTSAFETIME" ,NULL,0,(void*)&config.attsafetime, INT}, + { "ATTCNT" ,NULL,0,(void*)&config.attcnt, INT}, + { "LATETIME" ,NULL,0,(void*)&config.latetime, INT}, + { "ATTDMETIME" ,NULL,0,(void*)&config.attdmetime, INT}, + { "ATTDMECNT" ,NULL,0,(void*)&config.attdmecnt, INT}, +#endif + { "NOATTIP1" ,config.noattip[0], sizeof( config.noattip[0]),NULL,0}, + { "NOATTIP2" ,config.noattip[1], sizeof( config.noattip[1]),NULL,0}, + { "NOATTIP3" ,config.noattip[2], sizeof( config.noattip[2]),NULL,0}, + { "NOATTIP4" ,config.noattip[3], sizeof( config.noattip[3]),NULL,0}, + { "NOATTIP5" ,config.noattip[4], sizeof( config.noattip[4]),NULL,0}, +#ifdef _NO_TRANS_ANGLE + { "TRANS6ANGLE" ,NULL,0,(void*)&config.trans6angle, INT}, +#endif +#ifdef _PET_BUG + { "PETVITAL" ,NULL,0,(void*)&config.petpoint[0], INT}, + { "PETSTR" ,NULL,0,(void*)&config.petpoint[1], INT}, + { "PETTOUGH" ,NULL,0,(void*)&config.petpoint[2], INT}, + { "PETDEX" ,NULL,0,(void*)&config.petpoint[3], INT}, +#endif +#ifdef _VIGOR_SYS + { "VIGORTR0TIME" ,NULL,0,(void*)&config.vigortime[0], INT}, + { "VIGORTR1TIME" ,NULL,0,(void*)&config.vigortime[1], INT}, + { "VIGORTR2TIME" ,NULL,0,(void*)&config.vigortime[2], INT}, + { "VIGORTR3TIME" ,NULL,0,(void*)&config.vigortime[3], INT}, + { "VIGORTR4TIME" ,NULL,0,(void*)&config.vigortime[4], INT}, + { "VIGORTR5TIME" ,NULL,0,(void*)&config.vigortime[5], INT}, + { "VIGORTR6TIME" ,NULL,0,(void*)&config.vigortime[6], INT}, + { "VIGORTR7TIME" ,NULL,0,(void*)&config.vigortime[7], INT}, + { "VIGORMAX" ,NULL,0,(void*)&config.vigormax, INT}, +#endif +#ifdef _AUTO_PK + { "AUTOPKTIME" ,NULL,0,(void*)&config.autopktime, INT}, + { "AUTOPKMINNUM" ,NULL,0,(void*)&config.autopkminnum, INT}, + { "AUTOPKBATTLETIME" ,NULL,0,(void*)&config.autopkbattletime, INT}, + { "AUTOPKMINLV" ,NULL,0,(void*)&config.autopkminlv, INT}, + { "AUTOPKVIGORPKNUM" ,NULL,0,(void*)&config.autopkvigorpknum, INT}, + { "AUTOPKVIGORPKCNT" ,NULL,0,(void*)&config.autopkvigorpkcnt, INT}, +#endif +#ifdef _BATTLEMAP_CTRL + { "BATTLETIME0" ,config.BattleTime[0], sizeof( config.BattleTime[0]),NULL,0}, + { "BATTLETIME1" ,config.BattleTime[1], sizeof( config.BattleTime[1]),NULL,0}, + { "BATTLETIME2" ,config.BattleTime[2], sizeof( config.BattleTime[2]),NULL,0}, + { "BATTLETIME3" ,config.BattleTime[3], sizeof( config.BattleTime[3]),NULL,0}, + { "BATTLETIME4" ,config.BattleTime[4], sizeof( config.BattleTime[4]),NULL,0}, + { "BATTLETIME5" ,config.BattleTime[5], sizeof( config.BattleTime[5]),NULL,0}, + { "BATTLETIME6" ,config.BattleTime[6], sizeof( config.BattleTime[6]),NULL,0}, + { "BATTLETIME7" ,config.BattleTime[7], sizeof( config.BattleTime[7]),NULL,0}, + { "BATTLETIME8" ,config.BattleTime[8], sizeof( config.BattleTime[8]),NULL,0}, + { "BATTLETIME9" ,config.BattleTime[9], sizeof( config.BattleTime[9]),NULL,0}, +#endif +#ifdef _FM_SERVERNO_SYS + { "FMSERVERNO" ,NULL,0,(void*)&config.fmserverno, INT}, + { "FMSERVERMSG" , config.fmservermsg,sizeof(config.fmservermsg),NULL,0}, +#endif +#ifdef _ZHIPIAO_SYSTEM + { "ZHIPIAO" ,NULL,0,(void*)&config.zhipiao, INT}, + { "PIAOTIME" ,NULL,0,(void*)&config.piaotime, INT}, +#endif +#ifdef _FMWAR_MSG + { "FMWARMSG" , config.fmwarmsg,sizeof(config.fmwarmsg),NULL,0}, +#endif +#ifdef _FM_WELFARE + { "FMWELFARE0" ,config.fmwelfare[0], sizeof( config.fmwelfare[0]),NULL,0}, + { "FMWELFARE1" ,config.fmwelfare[1], sizeof( config.fmwelfare[1]),NULL,0}, + { "FMWELFARE2" ,config.fmwelfare[2], sizeof( config.fmwelfare[2]),NULL,0}, + { "FMWELFARE3" ,config.fmwelfare[3], sizeof( config.fmwelfare[3]),NULL,0}, + { "FMWELFARE4" ,config.fmwelfare[4], sizeof( config.fmwelfare[4]),NULL,0}, + { "FMWELFARE5" ,config.fmwelfare[5], sizeof( config.fmwelfare[5]),NULL,0}, + { "FMWELFARE6" ,config.fmwelfare[6], sizeof( config.fmwelfare[6]),NULL,0}, + { "FMWELFARE7" ,config.fmwelfare[7], sizeof( config.fmwelfare[7]),NULL,0}, + { "FMWELFARE8" ,config.fmwelfare[8], sizeof( config.fmwelfare[8]),NULL,0}, + { "FMWELFARE9" ,config.fmwelfare[9], sizeof( config.fmwelfare[9]),NULL,0}, +#endif +#ifdef _FMZUZHANG_MSG + { "FMZUZHANG" ,config.fmzuzhang, sizeof( config.fmzuzhang),NULL,0}, +#endif +#ifdef _PETMAIL_LV + { "PETMAILLV" ,NULL,0,(void*)&config.petmaillv, INT}, + { "PETMAILCF" ,NULL,0,(void*)&config.petmailcf, INT}, +#endif +#ifdef _FMWAR_PLAYERNUM + { "FMWARPLAYERNUM" ,NULL,0,(void*)&config.fmwarplayernum, INT}, +#endif +#ifdef _WAN_FIX + { "VSFLG" ,NULL,0,(void*)&config.vsflg, INT}, +#endif +#ifdef _WARNPC_CTRL + { "PARTYMAP" ,config.partymap, sizeof( config.partymap),NULL,0}, + { "MAPSAMEIP" ,config.mapsameip, sizeof( config.mapsameip),NULL,0}, +#endif +#ifdef _NO_DAOLUAN + { "STREETTRN" ,NULL,0,(void*)&config.streettrn, INT}, + { "TALKTRN" ,NULL,0,(void*)&config.talktrn, INT}, + { "TALKLV" ,NULL,0,(void*)&config.talklv, INT}, + { "TALKMSG" ,config.talkmsg, sizeof( config.talkmsg),NULL,0}, + { "TALKNAME" ,config.talkname, sizeof( config.talkname),NULL,0}, +#endif +#ifdef _NO_FULLPLAYER_ATT + { "NOFULLPLAYER" ,NULL,0,(void*)&config.nofullplayer, INT}, + { "NOFULL2PLAYER" ,NULL,0,(void*)&config.nofull2player, INT}, + { "NOCDKEYPLAYER" ,NULL,0,(void*)&config.nocdkeyplayer, INT}, + { "NOCDKEYMODE" ,NULL,0,(void*)&config.nocdkeymode, INT}, + { "NOCDKEYTYPE" ,NULL,0,(void*)&config.nocdkeytype, INT}, + { "NOFULLTIME" ,NULL,0,(void*)&config.nofulltime, INT}, + { "FENGTYPE" ,NULL,0,(void*)&config.fengtype, INT}, + { "NOFULLENDPLAYER" ,NULL,0,(void*)&config.nofullendplayer, INT}, + { "NOFULLENDTIME" ,NULL,0,(void*)&config.nofullendtime, INT}, + { "MANRENNUM" ,NULL,0,(void*)&config.manrennum, INT}, + { "BIGBAO" ,NULL,0,(void*)&config.bigbao, INT}, + { "BIGBAO2" ,NULL,0,(void*)&config.bigbao2, INT}, + +#endif +#ifdef _ATTREVERSE_FIX + { "ATTREVERSE" ,NULL,0,(void*)&config.attreverse, INT}, +#endif +#ifdef _NEWFM_GOLD + { "NEWFMGOLD" ,NULL,0,(void*)&config.newfmgold, INT}, +#endif +#ifdef _MERGE_TIME + { "MERGETIME" ,NULL,0,(void*)&config.mergetime, INT}, +#endif +#ifdef _PETUP_GET_EXP + { "PETUPGETEXP" ,NULL,0,(void*)&config.petupgetexp, INT}, +#endif +#ifdef _MM_NO_JIAOBEN + { "NOMMJIAOBEN" ,NULL,0,(void*)&config.nommjiaoben, INT}, + { "EDITBASETIME" ,NULL,0,(void*)&config.editbasetime, INT}, +#endif +#ifdef _DP_140_160_MODE + { "NEWDPMODE" ,NULL,0,(void*)&config.newdpmode, INT}, +#endif +#ifdef _LOOK_STREET_TIME + { "LOOKSTREETTIME" ,NULL,0,(void*)&config.lookstreettime, INT}, +#endif +#ifdef _BATTLE_EQUIT_OTHER + { "BATTLEEQUITOTHER" ,NULL,0,(void*)&config.battleequitother, INT}, +#endif +#ifdef _PK_LUCK_MAN + { "PKLUCKFLOOR" ,config.pkluckfloor, sizeof( config.pkluckfloor),NULL,0}, + { "PKLUCKMAPNAME0" ,config.pkluckmapname[0], sizeof( config.pkluckmapname[0]),NULL,0}, + { "PKLUCKMAPNAME1" ,config.pkluckmapname[1], sizeof( config.pkluckmapname[1]),NULL,0}, + { "PKLUCKMAPNAME2" ,config.pkluckmapname[2], sizeof( config.pkluckmapname[2]),NULL,0}, + { "PKLUCKMAPNAME3" ,config.pkluckmapname[3], sizeof( config.pkluckmapname[3]),NULL,0}, + { "PKLUCKMAPNAME4" ,config.pkluckmapname[4], sizeof( config.pkluckmapname[4]),NULL,0}, + { "PKLUCKMAPNAME5" ,config.pkluckmapname[5], sizeof( config.pkluckmapname[5]),NULL,0}, + { "PKLUCKMAPNAME6" ,config.pkluckmapname[6], sizeof( config.pkluckmapname[6]),NULL,0}, + { "PKLUCKMAPNAME7" ,config.pkluckmapname[7], sizeof( config.pkluckmapname[7]),NULL,0}, + { "PKLUCKMAPNAME8" ,config.pkluckmapname[8], sizeof( config.pkluckmapname[8]),NULL,0}, + { "PKLUCKMAPNAME9" ,config.pkluckmapname[9], sizeof( config.pkluckmapname[9]),NULL,0}, + { "PKLUCKTIME" ,config.pklucktime, sizeof( config.pklucktime),NULL,0}, + { "PKLUCKNUM" ,config.pklucknum, sizeof( config.pklucknum),NULL,0}, + { "PKLUCKBUF" ,config.pkluckbuf, sizeof( config.pkluckbuf),NULL,0}, + { "PKLUCKLEVEL" ,NULL,0,(void*)&config.pklucklevel, INT}, + { "PKLUCKBATTLETURN" ,NULL,0,(void*)&config.pkluckbattleturn, INT}, +#endif +#ifdef _NO_DAOLUAN + { "TALKFLOOR" ,config.talkfloor, sizeof( config.talkfloor),NULL,0}, +#endif +#ifdef _SUPERMAN_FIX + { "SUPERMANPOINT" ,NULL,0,(void*)&config.supermanpoint, INT}, +#endif +#ifdef _PICKUP_ITEM_OTHER + { "PICKUPITEM" ,NULL,0,(void*)&config.pickupitem, INT}, + { "PICKITEMID" ,config.pickitemid, sizeof( config.pickitemid),NULL,0}, +#endif +#ifdef _FM_LIAOLI + { "FMLIAOLITYPE" ,NULL,0,(void*)&config.fmliaolitype, INT}, +#endif +#ifdef _TRADE_ITEM_FIX + { "TRADEITEMFIX" ,NULL,0,(void*)&config.tradeitemfix, INT}, +#endif +#ifdef _PETMAIL_TIME + { "PETMAILTIME" ,NULL,0,(void*)&config.petmailtime, INT}, +#endif + { "RANDMIN" ,NULL,0,(void*)&config.randmin, INT}, + { "RANDMAX" ,NULL,0,(void*)&config.randmax, INT}, +#ifdef _GJS_TYPE + { "GJSTYPE" ,NULL,0,(void*)&config.gjstype, INT}, +#endif + { "TICKETCF" ,NULL,0,(void*)&config.ticketcf, INT}, + { "TICKETMSG" ,config.ticketmsg, sizeof( config.ticketmsg),NULL,0}, + + { "SATYPE" ,NULL,0,(void*)&config.satype, INT}, +#ifdef _BATTLEEND_FIX + { "BATTLEENDMODE" ,NULL,0,(void*)&config.battleendmode, INT}, +#endif +#ifdef _BIG_POOL_TYPE + { "PETPOOLTYPE" ,NULL,0,(void*)&config.petpooltype, INT}, + { "ITEMPOOLTYPE" ,NULL,0,(void*)&config.itempooltype, INT}, + + { "NOSTAYBATTLE" ,NULL,0,(void*)&config.nostaybattle, INT}, + { "RIGHTNUM" ,NULL,0,(void*)&config.rightnum, INT}, + { "RIGHTMODE" ,NULL,0,(void*)&config.rightmode, INT}, + { "ERRORMODE" ,NULL,0,(void*)&config.errormode, INT}, +#endif +#ifdef _FLOOR_PARTY_CTRL + { "PARTYFLOOR" ,config.partyfloor, sizeof( config.partyfloor),NULL,0}, +#endif + { "BATTLETIMEOUT" ,NULL,0,(void*)&config.battletimeout, INT}, + { "RELOADNPCTIME" ,NULL,0,(void*)&config.reloadnpctime, INT}, + { "RELOADNPCTYPE" ,NULL,0,(void*)&config.reloadnpctype, INT}, + { "OFFLINEBATTLETIME" ,NULL,0,(void*)&config.offlinebattletime, INT}, + { "OFFLINECF" ,NULL,0,(void*)&config.offlinecf, INT}, + { "OFFLINEMAXNUM" ,NULL,0,(void*)&config.offlinemaxnum, INT}, + { "OFFLINEJQMMAXNUM" ,NULL,0,(void*)&config.offlinejqmmaxnum, INT}, + { "KONGTYPE" ,NULL,0,(void*)&config.kongtype, INT}, + { "JIFENBAITAN" ,NULL,0,(void*)&config.jifenbaitan, INT}, + { "STREETITEMUNNAME" ,config.streetitemunname, sizeof( config.streetitemunname),NULL,0}, + { "NOPKMAP" ,NULL,0,(void*)&config.nopkmap, INT}, + { "FMBUFFTRANS" ,NULL,0,(void*)&config.fmbufftrans, INT}, + { "NOMPMAGIC" ,config.nompmagic, sizeof( config.nompmagic),NULL,0}, + { "LOGINJQMTYPE" ,NULL,0,(void*)&config.loginjqmtype, INT}, + { "FMMAGICMPRATE1" ,config.fmmagicmprate[0], sizeof( config.fmmagicmprate[0]),NULL,0}, + { "FMMAGICMPRATE2" ,config.fmmagicmprate[1], sizeof( config.fmmagicmprate[1]),NULL,0}, + { "SAMEIPNUM" ,NULL,0,(void*)&config.sameipnum, INT}, + { "SAMEJQMNUM" ,NULL,0,(void*)&config.samejqmnum, INT}, + { "SAMEJQMALLNUM" ,NULL,0,(void*)&config.samejqmallnum, INT}, + + { "MMTYPE" ,NULL,0,(void*)&config.mmtype, INT}, + { "MMMSG" ,config.mmmsg, sizeof( config.mmmsg),NULL,0}, + + { "LOCKTYPE" ,NULL,0,(void*)&config.locktype, INT}, + { "ALLTALKPOINT" ,NULL,0,(void*)&config.alltalkpoint, INT}, +#ifdef _NO_RIDE_ID + { "NORIDEID" ,config.norideid, sizeof( config.norideid),NULL,0}, +#endif + { "LOGINTYPE" ,NULL,0,(void*)&config.logintype, INT}, + +#ifdef _PETTRANS_RANGE + { "PETTRANSRANGE_X" ,NULL,0,(void*)&config.pettransrangex, INT}, + { "PETTRANSRANGE_Y" ,NULL,0,(void*)&config.pettransrangey, INT}, + { "PETTRANSRANGE_Z" ,NULL,0,(void*)&config.pettransrangez, INT}, +#endif +#ifdef _ITEM_LUA + { "ITEMLUAFILE" , config.itemluafile,sizeof(config.itemluafile),NULL,0}, +#endif +#ifdef _SAME_IP_ONLINE_NUM + { "sameiponlinenum" ,NULL,0,(void*)&config.sameiponlinenum, INT}, +#endif +#ifdef _CHECK_SEVER_IP + { "serverip" ,config.serverip, sizeof( config.serverip),NULL,0}, +#endif +#ifdef _CAX_ESC_REPORT + { "REPORTITEM1", NULL, 0,(void*) &config.reportitem[0], INT }, + { "REPORTITEM2", NULL, 0,(void*) &config.reportitem[1], INT }, + { "REPORTITEM3", NULL, 0,(void*) &config.reportitem[2], INT }, + { "REPORTITEM4", NULL, 0,(void*) &config.reportitem[3], INT }, + { "REPORTITEM5", NULL, 0,(void*) &config.reportitem[4], INT }, + { "VIPREPORTITEM1", NULL, 0,(void*) &config.vipreportitem[0], INT }, + { "VIPREPORTITEM2", NULL, 0,(void*) &config.vipreportitem[1], INT }, + { "VIPREPORTITEM3", NULL, 0,(void*) &config.vipreportitem[2], INT }, + { "VIPREPORTITEM4", NULL, 0,(void*) &config.vipreportitem[3], INT }, + { "VIPREPORTITEM5", NULL, 0,(void*) &config.vipreportitem[4], INT }, + { "reportlv", NULL, 0,(void*) &config.reportlv, INT }, + { "reportta", NULL, 0,(void*) &config.reportta, INT }, +#endif +#ifdef _PETSKILL_SHOP_LUA + { "PETSKILLSHOPPATH" ,config.freepetskillshoppath, sizeof( config.freepetskillshoppath),NULL,0}, +#endif +#ifdef _CAX_FAMEBUTTON + { "famebutton" ,NULL,0,(void*)&config.famebutton, INT}, +#endif +#ifdef _PET_TRANS_ABILITY + { "PETTRANSABILITY" ,NULL,0,(void*)&config.pettransability, INT}, + { "PETTRANSABILITY1" ,NULL,0,(void*)&config.pettransability1, INT}, + { "PETTRANSABILITY2" ,NULL,0,(void*)&config.pettransability2, INT}, + { "PETTRANSABILITY3" ,NULL,0,(void*)&config.pettransability3, INT}, +#endif +#ifdef _PET_3TRANS + { "MMPETID1" ,NULL,0,(void*)&config.MMPETID1,INT}, + { "MMPETID2" ,NULL,0,(void*)&config.MMPETID2,INT}, +#endif +#ifdef _NO_MAGIC + { "NOMAGICMAP" ,config.nomagicmap, sizeof( config.nomagicmap),NULL,0}, +#endif +#ifdef _illegalpetskill_CF + { "IllegalPetskill1" ,NULL,0,(void*)&config.IllegalPetskill[0], INT}, + { "IllegalPetskill2" ,NULL,0,(void*)&config.IllegalPetskill[1], INT}, + { "IllegalPetskill3" ,NULL,0,(void*)&config.IllegalPetskill[2], INT}, + { "IllegalPetskill4" ,NULL,0,(void*)&config.IllegalPetskill[3], INT}, + { "IllegalPetskill5" ,NULL,0,(void*)&config.IllegalPetskill[4], INT}, + { "IllegalPetskill6" ,NULL,0,(void*)&config.IllegalPetskill[5], INT}, + { "IllegalPetskill7" ,NULL,0,(void*)&config.IllegalPetskill[6], INT}, + { "IllegalPetskill8" ,NULL,0,(void*)&config.IllegalPetskill[7], INT}, + { "IllegalPetskill9" ,NULL,0,(void*)&config.IllegalPetskill[8], INT}, + { "IllegalPetskill10" ,NULL,0,(void*)&config.IllegalPetskill[9], INT}, +#endif +#ifdef _CAX_PET_EVOLUTION + { "petevotyb" , NULL ,0 , (void*)&config.petevotyb ,CHAR}, + { "petevotyb1" , NULL ,0 , (void*)&config.petevotyb1 ,INT}, +#endif +#ifdef _TRANS_7_COLOR +// { "tranclolr_7" , NULL ,0 , (void*)&config.TranColor ,INT}, + { "ping" , NULL ,0 , (void*)&config.ping ,CHAR}, + { "petsummon" , NULL ,0 , (void*)&config.petsummon ,CHAR}, +#endif +#ifdef _CAX_PET_ITEMRIDE + { "petitemride" , NULL ,0 , (void*)&config.petitemride ,CHAR}, +#endif +#ifdef _DAMMAGE_CALC + { "dammagecalc" ,NULL,0,(void*)&config.dammagecalc, INT}, +#endif +#ifdef _CAX_FAME_KOUFEI + { "FAMEKOUFEI" ,NULL,0,(void*)&config.famekoufei, INT}, +#endif +#ifdef _CAX_ITEM_ADDEXP + { "EXPTIME" ,NULL,0,(void*)&config.exptime, INT}, +#endif +#ifdef _SHARE_EXP + { "EXPSHARE" , NULL ,0 , (void*)&config.expshare ,INT}, +#endif +#ifdef _TEAM_ADDEXP + { "TEAMADDEXP" , NULL ,0 , (void*)&config.teamaddexp ,INT}, +#endif +#ifdef _NO_STW_ENEMY + { "NOSTWENEMY" ,NULL,0,(void*)&config.nostwenemy, INT}, + { "NOSTWENEMYGOLD" ,NULL,0,(void*)&config.nostwenemypoint, INT}, +#endif +#ifdef _DEX_FIX + { "DEXFIXPER" ,NULL,0,(void*)&config.dexfixper, INT}, +#endif +#ifdef _FM_EXP_ADD + { "FMADDEXP", NULL ,0 , (void*)&config.fmaddexp, INT}, +#endif +}; + +// Arminius 7.12 login announce +char announcetext[8192]; +void AnnounceToPlayer(int charaindex) +{ + char *ptr,*qtr; + + ptr=announcetext; + while ((qtr=strstr(ptr,"\n"))!=NULL) { + qtr[0]='\0'; +// printf("ptr=%s\n",ptr); + CHAR_talkToCli(charaindex, -1, ptr, CHAR_COLORYELLOW); + qtr[0]='\n'; + ptr=qtr+1; + } + CHAR_talkToCli(charaindex, -1, ptr, CHAR_COLORYELLOW); + +} + +// Robin 0720 +void AnnounceToPlayerWN(int fd) +{ + char buf[8192]; + char token[8192]; + int charaindex = CONNECT_getCharaindex( fd ); + long lastleavetime = CHAR_getInt( charaindex , CHAR_LASTLEAVETIME); + struct tm *p; + p=localtime(&lastleavetime); + + sprintf( token , "һʱ %d%d%d %d:%d:%d\n%s",p->tm_year + 1900, + p->tm_mon + 1, + p->tm_mday, + p->tm_hour, + p->tm_min, + p->tm_sec, + announcetext); + lssproto_WN_send( fd , WINDOW_MESSAGETYPE_LOGINMESSAGE, + WINDOW_BUTTONTYPE_OK, + -1,-1, + makeEscapeString( token, buf, sizeof(buf))); +} + + +void LoadAnnounce(void) +{ + FILE *f; + + memset(announcetext, 0, sizeof(announcetext)); + if ((f=fopen("./announce.txt","r"))!=NULL) { + fread(announcetext, sizeof(announcetext), 1, f); + announcetext[sizeof(announcetext)-1]='\0'; + fclose(f); + } +} +#ifdef _PET_TALKPRO +PTALK pettalktext[PETTALK_MAXID]; + +void LoadPetTalk(void) +{ + FILE *fp; + char fn[256]; + char line[ 4096]; + char talkmem[4096]; + int maxid=0; + char buf1[256], buf2[256], buf3[256]; + int talkNO=-1, mark=-1, i; + int len = sizeof( talkmem); + + memset(talkmem, 0, sizeof(talkmem)); + sprintf(fn, "%s/pettalk/pettalk.menu", getNpcdir()); + + for( i=0;i= PETTALK_MAXID ) + break; + } + print("ID=%d...", maxid); + { + int haveid=0; + for( i=0;i= 0 ) { + haveid++; + } + } + print("=%d", haveid); + } + +} + +#else +char pettalktext[4096]; +void LoadPetTalk(void) +{ + FILE *fp; + char fn[256]; + char line[ 4096]; + int len = sizeof( pettalktext); + + memset(pettalktext, 0, sizeof(pettalktext)); + sprintf(fn, "%s/pettalk/pettalk.mem", getNpcdir()); + + fp = fopen( fn, "r"); + if( fp != NULL ) { + print("\n\n ȡ pettalk.mem"); + while( fgets( line, sizeof( line), fp)) { + if( strlen( pettalktext) != 0 ) { + if( pettalktext[strlen( pettalktext) -1] != '|' ) { + strcatsafe( pettalktext, len, "|"); + } + } + chompex( line); + strcatsafe( pettalktext,len, line); + } + fclose( fp); + print("\n %s", pettalktext); + }else { + print("\n ҵ pettalk.mem"); + } +} +#endif + +#ifdef _GAMBLE_BANK +GAMBLEBANK_ITEMS GB_ITEMS[GAMBLEBANK_ITEMSMAX]; + +void Load_GambleBankItems( void) +{ + + FILE *fp; + char filename[256]; + char buf1[256]; + char name[128]; + int num,ID,type; + int i=0; + sprintf(filename, "./data/gambleitems.txt" ); + print("\nضIJƷļ %s ...", filename); + fp = fopen( filename, "r"); + if( fp != NULL ) { + while( fgets( buf1, sizeof( buf1), fp) != NULL ) { + if( strstr( buf1, "#") != 0 ) continue; + sscanf( buf1,"%s %d %d %d", name, &ID, &num , &type); + strcpy( GB_ITEMS[i].name, name); + GB_ITEMS[i].Gnum = num; + GB_ITEMS[i].ItemId = ID; + GB_ITEMS[i].type = type; + i++; + } + print("ID: %d ", i); + fclose( fp); + }else { + print(" Ҳļ %s", filename); + } + +} +#endif + + +#ifdef _CFREE_petskill +PETSKILL_CODES Code_skill[PETSKILL_CODE]; +void Load_PetSkillCodes( void) +{ + FILE *fp; + char filename[256]; + char buf1[256]; + char name[128]; + char type[256]; + int num,ID; + int i=0; + sprintf(filename, "./data/skillcode.txt" ); + print("\nس\ܱļ:%s...", filename); + fp = fopen( filename, "r"); + if( fp != NULL ) { + while( fgets( buf1, sizeof( buf1), fp) != NULL ) { + sscanf( buf1,"%s %d %d %s", name, &num, &ID, type); + strcpy( Code_skill[i].name, name); + Code_skill[i].TempNo = num; + Code_skill[i].PetId = ID; + strcpy( Code_skill[i].Code, type); + //print("\n %s|%d|%d|%s|", Code_skill[i].name, Code_skill[i].TempNo, + // Code_skill[i].PetId, Code_skill[i].Code); + i++; + if( i >= PETSKILL_CODE ) break; + } + fclose( fp); + }else { + print("򲻵ļ %s", filename); + } + print("\n"); +} +#endif + +#ifdef _GMRELOAD +BOOL LoadGMSet( char* filename ) +{ + FILE* fp; + int i = 0, gm_num = 0; + fp = fopen(filename, "r"); + if (fp == NULL) + { + print("޷ļ\n"); + return FALSE; + } + for (i = 0; i < GMMAXNUM; i++) + { + strcpy(gminfo[i].cdkey, ""); + gminfo[i].level = 0; + } + while(1){ + char line[64], cdkey[64], level[64]; + if (fgets(line, sizeof(line), fp) == NULL) break; + chop(line); + //change ʹgmset.txtע******* + if( line[0] == '#' ) + continue; + for( i=0; i GMMAXNUM) break; + easyGetTokenFromString(line, 1, cdkey, sizeof(cdkey)); + if (strcmp(cdkey, "") == 0) break; + strncpy(gminfo[gm_num].cdkey, cdkey, sizeof(gminfo[gm_num].cdkey)); + easyGetTokenFromString(line, 2, level, sizeof(level)); + if (strcmp(level, "") == 0) break; + gminfo[gm_num].level = atoi(level); +// print("\ncdkey:%s, level:%d", gminfo[gm_num].cdkey, gminfo[gm_num].level); + } + fclose(fp); + return TRUE; +} +#endif + +/*------------------------------------------------------------ + * ة ë + * ¦ + * ئ + * ߯Ի + * cahr* + ------------------------------------------------------------*/ +char* getProgname( void ) +{ + return config.progname; +} +/*------------------------------------------------------------ + * configfilename ë £ + * ¦ + * ئ + * ߯Ի + * char* + ------------------------------------------------------------*/ +char* getConfigfilename( void ) +{ + return config.configfilename; +} +/*------------------------------------------------------------ + * configfilename ëɬ£ + * ¦ + * newv char* ޥа + * ߯Ի + * ئ + ------------------------------------------------------------*/ +void setConfigfilename( char* newv ) +{ + strcpysafe( config.configfilename, sizeof( config.configfilename ), + newv ); +} + +/*------------------------------------------------------------ + * ìë + * ¦ + * ئ + * ߯Ի + * unsigned int + ------------------------------------------------------------*/ +unsigned int getDebuglevel( void ) +{ + return config.debuglevel; +} +/*------------------------------------------------------------ + * ìëɬ + * ¦ + * newv int ޥа + * ߯Ի + * unsigned int ɼ + ------------------------------------------------------------*/ +unsigned int setDebuglevel( unsigned int newv ) +{ + int old; + old = config.debuglevel; + config.debuglevel = newv; + return old; +} +/*------------------------------------------------------------ + * memoryunit ë + * ¦ + * ئ + * ߯Ի + * unsigned int + ------------------------------------------------------------*/ +unsigned int getMemoryunit( void ) +{ + return config.usememoryunit; +} +/*------------------------------------------------------------ + * memoryunitnum ë + * ¦ + * ئ + * ߯Ի + * unsigned int + ------------------------------------------------------------*/ +unsigned int getMemoryunitnum( void ) +{ + return config.usememoryunitnum; +} + +/*------------------------------------------------------------ + * ʧӡPʧë + * ¦ + * ئ + * ߯Ի + * char* + ------------------------------------------------------------*/ +char* getAccountservername( void ) +{ + return config.asname; +} +/*------------------------------------------------------------ + * ʧӡP̡ë + * ¦ + * ئ + * ߯Ի + * unsigned short + ------------------------------------------------------------*/ +unsigned short getAccountserverport( void ) +{ + return config.acservport; +} +/*------------------------------------------------------------ + * ʧӡ߼ɵë £ + * ¦ + * ئ + * ߯Ի + * unsigned short + ------------------------------------------------------------*/ +char* getAccountserverpasswd( void ) +{ + return config.acpasswd; +} +/*------------------------------------------------------------ + * ʧӡᆴέ±ءةӡƻ ë £ + * ¦ + * ئ + * ߯Ի + * unsigned short + ------------------------------------------------------------*/ +char* getGameservername( void ) +{ + return config.gsnamefromas; +} + +// Arminius 7.24 manor pk +char* getGameserverID( void ) +{ + if (config.gsid[strlen(config.gsid)-1]=='\n') + config.gsid[strlen(config.gsid)-1]='\0'; + + return config.gsid; +} + +unsigned short getAllowManorPK( void ) +{ + return config.allowmanorpk; +} + +unsigned short getPortnumber( void ) +{ + return config.port; +} +/*------------------------------------------------------------ + * ءةӡP į įë + * ¦ + * ئ + * ߯Ի + * unsigned short + ------------------------------------------------------------*/ +int getServernumber( void ) +{ + return config.servernumber; +} +/*------------------------------------------------------------ + * reuseaddr ë + * ¦ + * ئ + * ߯Ի + * unsigned short + ------------------------------------------------------------*/ +int getReuseaddr( void ) +{ + return config.reuseaddr; +} + +int getNodelay( void ) +{ + return config.do_nodelay; +} +int getLogWriteTime(void) +{ + return config.log_write_time; +} +int getLogIOTime( void) +{ + return config.log_io_time; +} +int getLogGameTime(void) +{ + return config.log_game_time; +} +int getLogNetloopFaster(void) +{ + return config.log_netloop_faster; +} + +/*------------------------------------------------------------ + * saacwritenum ë £ + * ¦ + * ئ + * ߯Ի + * int + ------------------------------------------------------------*/ +int getSaacwritenum( void ) +{ + return config.saacwritenum; +} +/*------------------------------------------------------------ + * saacwritenum ëɬ£ + * ¦ + * ئ + * ߯Ի + * int + ------------------------------------------------------------*/ +void setSaacwritenum( int num ) +{ + config.saacwritenum = num; +} +/*------------------------------------------------------------ + * saacreadnum ë £ + * ¦ + * ئ + * ߯Ի + * int + ------------------------------------------------------------*/ +int getSaacreadnum( void ) +{ + return config.saacreadnum; +} +/*------------------------------------------------------------ + * saacreadnum ëɬ£ + * ¦ + * ئ + * ߯Ի + * int + ------------------------------------------------------------*/ +void setSaacreadnum( int num ) +{ + config.saacreadnum = num; +} +/*------------------------------------------------------------ + * fdnum ë £ + * ¦ + * ئ + * ߯Ի + * unsigned int + ------------------------------------------------------------*/ +unsigned int getFdnum( void ) +{ +#ifdef _TEST_SERVER + if(config.fdnum>30) + return 30; + else + return config.fdnum; +#else + return config.fdnum; +#endif +} + +unsigned int getPlayercharnum( void ) +{ + if(config.playercharnum ̻P + ------------------------------------------------------------*/ +BOOL readconfigfile( char* filename ) +{ + FILE* f=NULL; + char linebuf[256]; /* */ + int linenum=0; /* ë */ + char realopenfilename[256]; /* ˱open °̻ */ + + char hostname[128]; + + /* ʯ ëƻ */ + if( gethostname( hostname, sizeof(hostname) ) != -1 ){ + char* initdot; + initdot = index( hostname, '.' ); + if( initdot != NULL ) + *initdot = '\0'; + snprintf( realopenfilename, sizeof(realopenfilename), + "%s.%s" , filename, hostname); + + /* ̻P */ + f=fopen( realopenfilename, "r" ); + if( f == NULL ) + print( "Can't open %s. use %s instead\n", realopenfilename, + filename ); + } + if( f == NULL ){ + f=fopen( filename , "r" ); /* ̻P */ + if( f == NULL ){ + print( "Can't open %s\n", filename ); + return FALSE; + } + } + + /* */ + while( fgets( linebuf , sizeof( linebuf ), f ) ){ + char firstToken[256]; /*1 ٯ */ + int i; /* */ + int ret; /**/ + + linenum ++; + + deleteWhiteSpace(linebuf); /* remove whitespace */ + + if( linebuf[0] == '#' )continue; /* comment */ + if( linebuf[0] == '\n' )continue; /* none */ + + chomp( linebuf ); /* remove tail newline */ + + /* delim "=" ƥ (1)ͼë */ + ret = getStringFromIndexWithDelim( linebuf , "=", 1, firstToken, + sizeof(firstToken) ); + if( ret == FALSE ){ + print( "Find error at %s in line %d. Ignore\n", + filename , linenum); + continue; + } + + /* readconf ƥ */ + for( i = 0 ; i < arraysizeof( readconf ) ; i ++ ){ + if( strcmp( readconf[i].name ,firstToken ) == 0 ){ + /* match */ + char secondToken[256]; /*2 ٯ */ + /* delim "=" ƥ2 ͼë */ + ret = getStringFromIndexWithDelim( linebuf , "=" , 2 + , secondToken , + sizeof(secondToken) ); + + /* NULL ٯëƩ */ + if( ret == FALSE ){ + print( "Find error at %s in line %d. Ignore", + filename , linenum); + break; + } + + + /*NULLҽ ئ*/ + if( readconf[i].charvalue != NULL ) + strcpysafe( readconf[i].charvalue + ,readconf[i].charsize, secondToken); + + /*NULLҽ ئ*/ + if( readconf[i].value != NULL ) { + if( strcmp( "ON" ,secondToken ) == 0 ) { + /*ON1ë ľ*/ + substitutePointerFromType( readconf[i].value, + readconf[i].valuetype, + 1.0); + + }else if( strcmp( "OFF" ,secondToken ) == 0 ) { + /*OFF1ë ľ*/ + substitutePointerFromType( readconf[i].value, + readconf[i].valuetype, + 1.0); + }else { + strtolchecknum(secondToken, + (int*)readconf[i].value, + 10, readconf[i].valuetype); + } + } + break; + } + } + } + fclose( f ); + lastConfig(); + return TRUE; +} +//ttom add this becaus the second had this function +/*------------------------------------------------------------ + * ޼ƽëɬ + * ¦ + * ئ + * ߯Ի + * unsigned int ƽë߯ +------------------------------------------------------------*/ +unsigned int setEncodeKey( void ) +{ + JENCODE_KEY = config.encodekey; + return JENCODE_KEY; +} +/*------------------------------------------------------------ +* ʧӡ̤ 뼰ëɬ +* ¦ +* ئ +* ߯Ի +* unsigned int ƽë߯ +------------------------------------------------------------*/ +unsigned int setAcWBSize( void ) +{ + AC_WBSIZE = config.acwbsize; + return AC_WBSIZE; +} +unsigned int getAcwriteSize( void ) +{ + return config.acwritesize; +} +unsigned int getErrUserDownFlg( void ) +{ + return config.ErrUserDownFlg; +} + + +#ifdef _DEL_DROP_GOLD +unsigned int getGolddeletetime( void ) +{ + if( config.Golddeletetime > 0 ) + return config.Golddeletetime; + else + return config.Itemdeletetime; +} +void setIGolddeletetime( unsigned int interval ) +{ + config.Golddeletetime = interval; +} +#endif + +#ifdef _NEW_PLAYER_CF +int getNewplayertrans( void ) +{ + if(config.newplayertrans > 7) + return 7; + else if(config.newplayertrans >= 0) + return config.newplayertrans; + else + return 0; +} +int getNewplayerlv( void ) +{ + if(config.newplayerlv > 160) + return 160; + else if(config.newplayerlv >0) + return config.newplayerlv; + else + return 0; +} +int getNewplayerpetlv( void ) +{ + if(config.newplayerpetlv > 160) + return 160; + else if(config.newplayerpetlv > 0) + return config.newplayerpetlv; + else + return 0; +} + +int getNewplayergivepet( unsigned int index ) +{ + if(config.newplayergivepet[index] > 0 ) + return config.newplayergivepet[index]; + else + return -1; +} + +int getNewplayergiveitem( unsigned int index ) +{ + if(config.newplayergiveitem[index] > 0 ) + return config.newplayergiveitem[index]; + else + return -1; +} + +void setNewplayergivepet( unsigned int index ,unsigned int interval) +{ + config.newplayergivepet[index] = interval; +} + +int getNewplayergivegold( void ) +{ + if(config.newplayergivegold > 1000000) + return 1000000; + else if(config.newplayergivegold < 0) + return 0; + else + return config.newplayergivegold; +} +int getRidePetLevel( void ) +{ + if(config.ridepetlevel > 0 ) + return config.ridepetlevel; + else + return -1; +} +#ifdef _VIP_SERVER +int getNewplayergivevip( void ) +{ + return config.newplayerpetvip < 0?0:config.newplayerpetvip; +} +#endif +#endif +#ifdef _JK_CF_DELPETITEM ////ɾCFָƷͳ +char *getDelPet(void) +{ + return config.DelPet; +} +char *getDelItem(void) +{ + return config.DelItem; +} +#endif +#ifdef _UNLAW_WARP_FLOOR +int getUnlawwarpfloor( unsigned int index ) +{ + if(config.unlawwarpfloor[index] > 0 ) + return config.unlawwarpfloor[index]; + else + return -1; +} +#endif + +#ifdef _WATCH_FLOOR +int getWatchFloor( unsigned int index ) +{ + if(config.watchfloor[index] > 0 ) + return config.watchfloor[index]; + else + return -1; +} +char* getWatchFloorCF( void ) +{ + return (config.watchfloor[0]>0)? "":""; +} +#endif + +#ifdef _BATTLE_FLOOR +int getBattleFloor( unsigned int index ) +{ + if(config.battlefloor[index] > 0 ) + return config.battlefloor[index]; + else + return -1; +} +char* getBattleFloorCF( void ) +{ + return (config.battlefloor[0]>0)? "":""; +} +#endif + +#ifdef _ANGEL_SUMMON + +extern int mission_num; + +BOOL LoadMissionList( ) +{ + FILE* fp; + int i = 0; + + mission_num = 0; + + fp = fopen("./data/mission.txt", "r"); + if (fp == NULL) + { + print("ļ򿪴\n"); + return FALSE; + } + + memset( missionlist, 0, sizeof(missionlist)); + + while(1){ + char line[1024]; + char token[1024]; + int mindex; + if (fgets(line, sizeof(line), fp) == NULL) break; +// print("\n %s ", line); + chop(line); + // #Ϊע******* + if( line[0] == '#' ) + continue; + for( i=0; i= MAXMISSION) + break; + + missionlist[mindex].id = mindex; + + getStringFromIndexWithDelim(line, ",", 2, token, sizeof(token)); + if (strcmp(token, "") == 0) break; + missionlist[mindex].level = atoi( token); + + getStringFromIndexWithDelim(line, ",", 3, token, sizeof(token)); + if (strcmp(token, "") == 0) break; + strcpy( missionlist[mindex].eventflag, token); + + getStringFromIndexWithDelim(line, ",", 4, token, sizeof(token)); + if (strcmp(token, "") == 0) break; + strcpy( missionlist[mindex].detail, token); + + //getStringFromIndexWithDelim(line, ",", 4, token, sizeof(token)); + //if (strcmp(token, "") == 0) break; + //strcpy( missionlist[mindex].bonus, token); + + getStringFromIndexWithDelim(line, ",", 5, token, sizeof(token)); + if (strcmp(token, "") == 0) break; + missionlist[mindex].limittime = atoi( token); +/* + print("\nMISSION[%d] lv:%d ef:%s detail:%s limit:%d ", mindex, + missionlist[mindex].level, missionlist[mindex].eventflag, + missionlist[mindex].detail, missionlist[mindex].limittime ); +*/ + mission_num++; + //if (mission_num > MAXMISSION) break; + } + fclose(fp); + return TRUE; +} + + + +BOOL LoadMissionCleanList( ) +{ + // ʽ... ʹ,,, + FILE* fp; + int listindex =0; + int i = 0; + + memset( missiontable, 0, sizeof(missiontable)); + fp = fopen("./data/missionclean.txt", "r"); + if (fp == NULL) + { + print("ļ򿪴\n"); + return FALSE; + } + + while(1){ + char line[1024]; + char token[1024]; + + if (fgets(line, sizeof(line), fp) == NULL) break; + print("\n %s ", line); + chop(line); + // #Ϊע******* + if( line[0] == '#' ) + continue; + for( i=0; i= MAXMISSIONTABLE) break; + } + fclose(fp); + return TRUE; +} + + +#endif + +#ifdef _JOBDAILY +extern DailyFileType dailyfile[MAXDAILYLIST]; +BOOL LoadJobdailyfile(void) +{ + char line[20000]; + char token[16384]; + int listindex =0; + int i; + FILE* fp; + + fp = fopen("./data/jobdaily.txt", "r"); + if (fp == NULL) + { + print("ճļ򿪴\n"); + return FALSE; + } + + memset( dailyfile, 0, sizeof(dailyfile)); + + while(1){ + line[0]='\0'; + if (fgets(line, sizeof(line), fp) == NULL) break; + //print("\n %s ", line); + chop(line); + + // #Ϊע + if( line[0] == '#' ) + continue; + for( i=0; i64){ + print("\n˵:%d\n",strlen(token)); + return FALSE; + } + strcpy( dailyfile[listindex].explain, token); + + getStringFromIndexWithDelim(line, "|", 4, token, sizeof(token)); + if (strcmp(token, "") == 0) break; + strcpy( dailyfile[listindex].state, token); + + /*print("\ndailyfile[%d] %s %s %s %s", listindex, + dailyfile[listindex].jobid, + dailyfile[listindex].rule, + dailyfile[listindex].explain, + dailyfile[listindex].state); + */ + listindex++; + if ( listindex >= MAXDAILYLIST) break; + } + fclose(fp); + return TRUE; +} +#endif + +#ifdef _USER_EXP_CF +BOOL LoadEXP( char* filename ) +{ + FILE* fp; + int i = 0; + int MaxLevel=0; + fp = fopen(filename, "r"); + if (fp == NULL) + { + print("޷ļ\n"); + return FALSE; + } + + while(1){ + char line[64], exp[64]; + if (fgets(line, sizeof(line), fp) == NULL) break; + chop(line); + + if( line[0] == '#' ) + continue; + for( i=0; i= 200) break; + easyGetTokenFromString(line, 2, exp, sizeof(exp)); + NeedLevelUpTbls[MaxLevel]=atoi(exp); + } + fclose(fp); + return TRUE; +} + +char* getEXPfile( void ) +{ + return config.expfile; +} + +int getNeedLevelUpTbls( int level ) +{ + return NeedLevelUpTbls[level]; +} + +#endif + +#ifdef _UNREG_NEMA +char* getUnregname( int index ) +{ + return config.unregname[index]; +} +#endif + +#ifdef _TRANS_LEVEL_CF +int getChartrans( void ) +{ + if(config.chartrans>6) + config.chartrans=6; + return config.chartrans; +} +int getPettrans( void ) +{ + if(config.pettrans>2) + return 2; + else if(config.pettrans<-1) + return -1; + return config.pettrans; +} +int getYBLevel( void ) +{ + if(config.yblevel>config.maxlevel) + config.yblevel=config.maxlevel; + return config.yblevel; +} +int getMaxLevel( void ) +{ + return config.maxlevel; +} +#endif + +#ifdef _POINT +char* getPoint( void ) +{ + return (config.point>0)? "":""; +} +int getTransPoint( int index ) +{ + return config.transpoint[index]; +} +#endif + +#ifdef _PET_UP +int getPetup( void ) +{ + return config.petup; +} +#endif +#ifdef _LOOP_ANNOUNCE +char* getLoopAnnouncePath( void ) +{ + return config.loopannouncepath; +} +int loadLoopAnnounce( void ) +{ + FILE* fp; + int i = 0; + config.loopannouncemax=0; + fp = fopen(config.loopannouncepath, "r"); + if (fp == NULL) + { + print("޷ļ\n"); + return FALSE; + } + while(1){ + char line[1024]; + if (fgets(line, sizeof(line), fp) == NULL) break; + chop(line); + + if( line[0] == '#' ) + continue; + for( i=0; i<10; i++ ){ + if( line[i] == '#' ){ + line[i] = '\0'; + break; + } + } + //************************************* + strcpy(config.loopannounce[config.loopannouncemax],line); + config.loopannouncemax++; + if(config.loopannouncemax>=10) break; + } + fclose(fp); + return TRUE; +} +int getLoopAnnounceTime( void ) +{ + return (config.loopannouncetime<0)?-1:config.loopannouncetime; +} +int getLoopAnnounceMax( void ) +{ + return (config.loopannouncemax>0)?config.loopannouncemax:0; +} +char* getLoopAnnounce( int index ) +{ + return config.loopannounce[index]; +} +#endif + +#ifdef _SKILLUPPOINT_CF +int getSkup( void ) +{ + return (config.skup>0)?config.skup:0; +} +#endif +#ifdef _RIDELEVEL +int getRideLevel( void ) +{ + return config.ridelevel; +} +#endif +#ifdef _REVLEVEL +char* getRevLevel( void ) +{ + return (config.revlevel>0)?"":""; +} +#endif +#ifdef _NEW_PLAYER_RIDE +char* getPlayerRide( void ) +{ + if(config.npride>2) + return "ͻ"; + else if(config.npride==2) + return ""; + else if(config.npride==1) + return "ͻ"; + else + return ""; +} +#endif + +#ifdef _FIX_CHARLOOPS +int getCharloops( void ) +{ + return config.charloops-1; +} +#endif + +#ifdef _PLAYER_ANNOUNCE +int getPAnnounce( void ) +{ + return (config.pannounce>-1)?config.pannounce:-1; +} +#endif +#ifdef _PLAYER_MOVE +int getPMove( void ) +{ + return (config.pmove>-1)?config.pmove:-1; +} +#endif + +int getrecvbuffer( void ) +{ + if(config.recvbuffer<0) + return 0; + else if(config.recvbuffer>128) + return 128; + else + return config.recvbuffer; +} + +int getsendbuffer( void ) +{ + if(config.sendbuffer<0) + return 0; + else if(config.sendbuffer>128) + return 128; + else + return config.sendbuffer; +} + +int getrecvlowatbuffer( void ) +{ + if(config.recvlowatbuffer<0) + return 0; + else if(config.recvlowatbuffer>1024) + return 1024; + else + return config.recvlowatbuffer; +} + +int getrunlevel( void ) +{ + if(config.runlevel<-20) + return -20; + else if(config.runlevel>19) + return 19; + else + return config.runlevel; + +} + +#ifdef _SHOW_VIP_CF +int getShowVip( void ) +{ + if(config.showvip>2) + return 2; + else if(config.showvip<0) + return 0; + else + return config.showvip; +} +#endif + + +#ifdef _PLAYER_NUM +int getPlayerNum( void ) +{ + return config.playernum; +} +void setPlayerNum( int num ) +{ + config.playernum=num; +} +char* getPlayerBase( void ) +{ + return config.playerbase; +} +#endif + +#ifdef _BATTLE_GOLD +int getBattleGold( void ) +{ + if(config.battlegold<0) + return 0; + else if(config.battlegold>100) + return 100; + else + return config.battlegold; + +} +#endif + +#ifdef _ANGEL_TIME +int getAngelPlayerTime( void ) +{ + return (config.angelplayertime>1)?config.angelplayertime:1; +} +int getAngelPlayerMun( void ) +{ + return (config.angelplayermun>2)?config.angelplayermun:2; +} +#endif + +#ifdef _RIDEMODE_20 +int getRideMode( void ) +{ + if(config.ridemode<0) + config.ridemode=0; + return config.ridemode; +} +#endif +#ifdef _FM_POINT_PK +char *getFmPointPK( void ) +{ + return (config.fmpointpk>0)?"":""; +} +#endif +#ifdef _ENEMY_ACTION +int getEnemyAction( void ) +{ + if(config.enemyact>100) + return 100; + else if(config.enemyact<1) + return 1; + else + return config.enemyact; +} +#endif + +#ifdef _FUSIONBEIT_TRANS +int getFusionbeitTrans( void ) +{ + if(config.fusionbeittrans>2) + return 2; + else if(config.fusionbeittrans<0) + return 0; + else + return config.fusionbeittrans; +} +#endif +int getCpuUse( void ) +{ + return config.cpuuse; +} +#ifdef _CHECK_PEPEAT +int getCheckRepeat( void ) +{ + return (config.CheckRepeat>0)?1:0; +} +#endif + +#ifdef _FM_JOINLIMIT +int getJoinFamilyTime( void ) +{ + return config.joinfamilytime; +} +#endif + +#ifdef _NOWEN_EV +int getNowEvent(int Num) +{ + int i = config.NowEvent[Num]; + if (i <= 0)return -1; + return i; +} + +int getEndEvent(int Num) +{ + int i = config.EndEvent[Num]; + if (i <= 0)return -1; + return i; +} + +#endif +int getBalltePoint(int Num) +{ + int i = config.BattlePoint[Num]; + if (i <= 0)return -1; + return i; +} +#ifdef _ALL_TALK +int getTheWorldTrans(void) +{ + int i = config.TheWorldTrans; + if (i <= 0)return -1; + return i; +} + +int getTheWorldFame(void) +{ + int i = config.TheWorldFame; + if (i <= 0)return -1; + return i; +} +int getTheWorldTime(void) +{ + int i = config.TheWorldTime; + if (i <= 0)return -1; + return i; +} +int getTheWorldCnt(void) +{ + int i = config.TheWorldCnt; + if (i <= 0)return -1; + return i; +} +#endif +#ifdef _DIY_INSLAY +int getInslayNum(void) +{ + int i = config.InslayNum; + if (i < 1)return 1; + if (i > 5)return 5; + return i; +} +#endif +int getSafeMode(void) +{ + int i = config.safemode; + if (i < 1)return 0; + if (i > 1)return 1; + return i; +} + +int getTradeTax(void) +{ + int i = config.TradeTax; + if (i < 1)return 1; + if (i > 100)return 100; + return i; +} + +#ifdef _MAP_HEAL +int getMapHeal(int Num) +{ + int i = config.MapHeal[Num]; + if(i>0) + return i; + else + return -1; +} +#endif + +#ifdef _VIP_RIDE +int getVipMsgType(void) +{ + int i = config.VipMsgType; + if (i < 0)return 0; + if (i > 3)return 3; + return i; +} +#endif + +#ifdef _VIP_BATTLE_EXP +int getVipBattleExp( void ) +{ + if(config.VipBattleExp<0) + return 0; + return config.VipBattleExp; +} +#endif + +int getItemPoolBug(void) +{ + int i = config.ItemPoolBug; + if (i < 0)return 0; + if (i > 1)return 1; + return i; +} + +int getSameIpLogin( void ) +{ + if(config.SameIpLogin<0) + return 0; + return config.SameIpLogin; +} + +int getPetRideTrans( void ) +{ + if(config.PetRideTrans<0) + return 0; + else if (config.PetRideTrans>2) + return 2; + return config.PetRideTrans; +} + +#ifdef _LUCK_MAN +int getLuckTime( void ) +{ + if(config.lucktime<0) + return 0; + return config.lucktime; +} + +int getLuckItem( void ) +{ + char *itemarg=NULL; + char itemnumstr[32]; + int itemnum=0; + int present[20]; + int si=0,i; + itemarg=config.luckitem; + if( getStringFromIndexWithDelim( itemarg, "|", 1, itemnumstr, sizeof( itemnumstr)) == FALSE ) + return; + itemnum = atoi(itemnumstr); + if( itemnum > 20 ) + itemnum = 20; + for(i=0;i3) num=3; + char *itemarg=NULL; + char itemnumstr[32]; + int itemnum1=-1; + int itemnum2=-1; + int itemnum3=-1; + itemarg=config.questionitem; + if( getStringFromIndexWithDelim( itemarg, "|", 1, itemnumstr, sizeof( itemnumstr)) == FALSE ) + return -1; + itemnum1 = atoi(itemnumstr); + if( getStringFromIndexWithDelim( itemarg, "|", 2, itemnumstr, sizeof( itemnumstr)) == FALSE ) + return -1; + itemnum2 = atoi(itemnumstr); + if( getStringFromIndexWithDelim( itemarg, "|", 3, itemnumstr, sizeof( itemnumstr)) == FALSE ) + return -1; + itemnum3 = atoi(itemnumstr); + + if(num==1) + return itemnum1; + else if(num==2) + return itemnum2; + else if(num==3) + return itemnum3; +} +#endif + +#ifdef _NO_STREET_MAP +int getNoStreetMap( int num ) +{ + if(num<1) num=1; + if(num>5) num=5; + char *maparg=NULL; + char mapnumstr[32]; + int mapnum1=-1; + int mapnum2=-1; + int mapnum3=-1; + int mapnum4=-1; + int mapnum5=-1; + maparg=config.nostreetmap; + if( getStringFromIndexWithDelim( maparg, ",", 1, mapnumstr, sizeof( mapnumstr)) == FALSE ) + return -1; + mapnum1 = atoi(mapnumstr); + if( getStringFromIndexWithDelim( maparg, ",", 2, mapnumstr, sizeof( mapnumstr)) == FALSE ) + return -1; + mapnum2 = atoi(mapnumstr); + if( getStringFromIndexWithDelim( maparg, ",", 3, mapnumstr, sizeof( mapnumstr)) == FALSE ) + return -1; + mapnum3 = atoi(mapnumstr); + if( getStringFromIndexWithDelim( maparg, ",", 4, mapnumstr, sizeof( mapnumstr)) == FALSE ) + return -1; + mapnum4 = atoi(mapnumstr); + if( getStringFromIndexWithDelim( maparg, ",", 5, mapnumstr, sizeof( mapnumstr)) == FALSE ) + return -1; + mapnum5 = atoi(mapnumstr); + + if(num==1) + return mapnum1; + else if(num==2) + return mapnum2; + else if(num==3) + return mapnum3; + else if(num==4) + return mapnum4; + else if(num==5) + return mapnum5; +} +#endif + +#ifdef _STREET_FAX +int getStreetFax( int num ) +{ + if(num<0 || num>4 ) + return 100; + char *streetfaxarg=config.streetfax; + char streetfaxstr[32]; + if( getStringFromIndexWithDelim( streetfaxarg, ",", num+1, streetfaxstr, sizeof( streetfaxstr)) != FALSE ) + return atoi(streetfaxstr); + return 100; +} +#endif + +int getFmWarTime( int num ) +{ + char *timearg=NULL; + char timestr[5]; + timearg = config.fmwartime; + if(num==1){ + if( getStringFromIndexWithDelim( timearg, ",", 1, timestr, sizeof( timestr)) == FALSE ) + return 18; + return atoi(timestr); + } + else if(num==2){ + if( getStringFromIndexWithDelim( timearg, ",", 2, timestr, sizeof( timestr)) == FALSE ) + return 1; + return atoi(timestr); + } + else{ + return -1; + } +} + +#ifdef _JZ_NEWSCRIPT_LUA +char *getLuaFile(void) +{ + return config.luafile; +} +#endif + +#ifdef _TRANS7_POINT +int getTrans7Point(void) +{ + return config.trans7point; +} +#endif +#ifdef _NOJOB_PK +int getNoJobPkMap(void) +{ + return config.nojobpkmap; +} +#endif + +#ifdef _UNTEXT_TALK +BOOL LoadUnText( void ) +{ + FILE* untextfp; + int uni; + textcnt = 0; +// untext = (char **)malloc(50 * sizeof(char *)); + untextfp = fopen("./data/untext.txt", "r"); + if (untextfp == NULL) + { + print("޷ļ\n"); + return FALSE; + } + + while(1){ + char untestline[64]; + if (fgets(untestline, sizeof(untestline), untextfp) == NULL) break; + chop(untestline); + + if( untestline[0] == '#' ) + continue; + for( uni=0; uni=100) break; + } + fclose(untextfp); + return TRUE; +} + +char *getUnText(int num) +{ + if(num30) num = 1; + if( getStringFromIndexWithDelim( streetarg, ",", num, streetstr, sizeof( streetstr)) == FALSE ) + return ""; + return streetstr; +} + +#ifdef _NO_ATTACK +int getAttTime(void) +{ + return config.atttime; +} +int getAttSafeTime(void) +{ + return config.attsafetime; +} +int getAttCnt(void) +{ + return config.attcnt; +} +int getLateTime(void) +{ + return config.latetime; +} +int getAttDmeTime(void) +{ + return config.attdmetime; +} +int getAttDmeCnt(void) +{ + return config.attdmecnt; +} +#endif +char* getNoAttIp(int num) +{ + if(num<0) num=0; + else if(num>4) num=4; + return config.noattip[num]; +} +#ifdef _NO_TRANS_ANGLE +int getTrans6Angle(void) +{ + if(config.trans6angle<0) + config.trans6angle=0; + else if(config.trans6angle>1) + config.trans6angle=1; + return config.trans6angle; +} +#endif +#ifdef _PET_BUG +int getPetPoint(int num) +{ + if(num<0) num=0; + else if(num>3) num=3; + return config.petpoint[num]; +} +#endif +#ifdef _VIGOR_SYS +int getVigorTime(int num) +{ + if(num<0) num==0; + else if(num >7) num==7; + int i; + i = config.vigortime[num]; + if(i<0) i=0; + return i; +} +int getVigorMax(void) +{ + return config.vigormax; +} +#endif +#ifdef _AUTO_PK +int getAutoPkTime(void) +{ + return config.autopktime; +} +int getAutoPkMinNum(void) +{ + return config.autopkminnum; +} +int getAutoPkBattleTime(void) +{ + return config.autopkbattletime; +} +int getAutoPkMinLv(void) +{ + return config.autopkminlv; +} +int getAutoPkVigorPkNum(void) +{ + return config.autopkvigorpknum; +} +int getAutoPkVigorPkCnt(void) +{ + return config.autopkvigorpkcnt; +} +#endif +#ifdef _BATTLEMAP_CTRL +int getBattleTimeFloor(int num) +{ + char *timearg=NULL; + char timestr[10]; + timearg = config.BattleTime[num]; + if( getStringFromIndexWithDelim( timearg, ",", 1, timestr, sizeof( timestr)) == FALSE ) + return -1; + return atoi(timestr); +} +int getBattleTimePlayerNum(int num) +{ + char *timearg=NULL; + char timestr[10]; + timearg = config.BattleTime[num]; + if( getStringFromIndexWithDelim( timearg, ",", 2, timestr, sizeof( timestr)) == FALSE ) + return -1; + return atoi(timestr); +} +int getBattleTimeSec(int num) +{ + char *timearg=NULL; + char timestr[10]; + timearg = config.BattleTime[num]; + if( getStringFromIndexWithDelim( timearg, ",", 3, timestr, sizeof( timestr)) == FALSE ) + return -1; + return atoi(timestr); +} +#endif +#ifdef _FM_SERVERNO_SYS +int getFmServerNo(void) +{ + return config.fmserverno; +} +char* getFmServerMsg(void) +{ + return config.fmservermsg; +} +#endif +#ifdef _ZHIPIAO_SYSTEM +int getZhiPiao(void) +{ + return config.zhipiao; +} +int getPiaoTime(void) +{ + return config.piaotime; +} +#endif +#ifdef _FMWAR_MSG +char* getFmWarMsg(void) +{ + return config.fmwarmsg; +} +#endif +#ifdef _FM_WELFARE +char* getFmWelfare(int num) +{ + return config.fmwelfare[num]; +} +#endif +#ifdef _FMZUZHANG_MSG +char* getFmZuzhang(void) +{ + return config.fmzuzhang; +} +#endif +#ifdef _PETMAIL_LV +int getPetMailLv(void){ + return config.petmaillv; +} +int getPetMailCf(void){ + return config.petmailcf; +} +#endif +#ifdef _FMWAR_PLAYERNUM +int getFmWarPlayerNum(void){ + if(config.fmwarplayernum<50) return 50; + return config.fmwarplayernum; +} +#endif +#ifdef _WAN_FIX +int getVsFlg(void){ + if(config.vsflg>3 || config.vsflg<0) return 0; + return config.vsflg; +} +#endif +#ifdef _WARNPC_CTRL +int getPartyMap(int num){ + char *patymaparg=NULL; + char patymapstr[10]; + patymaparg = config.partymap; + if( getStringFromIndexWithDelim( patymaparg, ",", num, patymapstr, sizeof( patymapstr)) == FALSE ) + return -1; + return atoi(patymapstr); +} +int getMapSameIp(int num){ + char *mapsameiparg=NULL; + char mapsameipstr[10]; + mapsameiparg = config.mapsameip; + if( getStringFromIndexWithDelim( mapsameiparg, ",", num, mapsameipstr, sizeof( mapsameipstr)) == FALSE ) + return -1; + return atoi(mapsameipstr); +} +#endif +#ifdef _NO_DAOLUAN +int getStreetTrn(void){ + return config.streettrn; +} +int getTalkTrn(void){ + return config.talktrn; +} +int getTalkLv(void){ + return config.talklv; +} +char* getTalkMsg(void){ + return config.talkmsg; +} +char* getTalkName(void){ + return config.talkname; +} +#endif +#ifdef _NO_FULLPLAYER_ATT +int getNoFullPlayer(void){ + return config.nofullplayer; +} +int getNoFull2Player(void){ + return config.nofull2player; +} +int getNoCdkeyPlayer(void){ + if(config.nocdkeyplayer<0 || config.nocdkeyplayer>2000) + return 0; + return config.nocdkeyplayer; +} +int getNoCdkeyMode(void){ + if(config.nocdkeymode<0 || config.nocdkeymode>2) + return 0; + return config.nocdkeymode; +} +int getNoCdkeyType(void){ + if(config.nocdkeytype<0 || config.nocdkeytype>2) + return 0; + return config.nocdkeytype; +} +int getNoFullTime(void){ + return config.nofulltime; +} +int getFengType(void){ + return config.fengtype; +} +int getNoFullEndPlayer(void){ + return config.nofullendplayer; +} +int getNoFullEndTime(void){ + return config.nofullendtime; +} +int getManRenNum(void){ + return config.manrennum; +} +int getBigBao(void){ + if(config.bigbao<=0) return 1024; + return config.bigbao; +} +int getBigBao2(void){ + if(config.bigbao2<=0) return 1024; + return config.bigbao2; +} +#endif +#ifdef _ATTREVERSE_FIX +int getAttReverse(void){ + return config.attreverse; +} +#endif +#ifdef _NEWFM_GOLD +int getNewFmGold(void){ + return config.newfmgold; +} +#endif +#ifdef _MERGE_TIME +int getMergeTime(void){ + if(config.mergetime<0) return 0; + else if(config.mergetime>5) return 5; + return config.mergetime; +} +#endif +#ifdef _PETUP_GET_EXP +int getPetUpGetExp(void){ + if(config.petupgetexp<0) return 0; + else if(config.petupgetexp>1) return 1; + return config.petupgetexp; +} +#endif +#ifdef _MM_NO_JIAOBEN +int getNoMMJiaoben(void){ + if(config.nommjiaoben<0) return 0; + else if(config.nommjiaoben>1) return 1; + return config.nommjiaoben; +} +int getEditBaseTime(void){ + if(config.editbasetime<0) return 0; + else if(config.editbasetime>100) return 100; + return config.editbasetime; +} +#endif +#ifdef _DP_140_160_MODE +int getNewDpMode(void){ + if(config.newdpmode!=1) return 0; + return 1; +} +#endif +#ifdef _LOOK_STREET_TIME +int getLookStreetTime(void){ + if(config.lookstreettime<0) return 0; + else if(config.lookstreettime>3600) return 3600; + return config.lookstreettime; +} +#endif +#ifdef _BATTLE_EQUIT_OTHER +int getBattleEquitOther(void){ + if(config.battleequitother<0) return 0; + else if(config.battleequitother>1) return 1; + return config.battleequitother; +} +#endif +#ifdef _PK_LUCK_MAN +int getPkLuckFloor(int floor){ + char *pkluckfloorarg=NULL; + char pkluckfloorstr[10]; + pkluckfloorarg = config.pkluckfloor; + int i; + for(i=1;i<=10;i++){ + if( getStringFromIndexWithDelim( pkluckfloorarg, ",", i, pkluckfloorstr, sizeof( pkluckfloorstr)) == FALSE ) + return -1; + if(floor == atoi(pkluckfloorstr)) + return i; + } + return -1; +} +char* getPkLuckMapName(int num){ + if(num<0) num = 0; + else if(num>9) num = 9; + return config.pkluckmapname[num]; +} +int getPkLuckTimeMin(void){ + char *pklucktimearg=NULL; + char pklucktimestr[10]; + pklucktimearg = config.pklucktime; + if( getStringFromIndexWithDelim( pklucktimearg, ",", 1, pklucktimestr, sizeof( pklucktimestr)) == FALSE ) + return -1; + return atoi(pklucktimestr); +} +int getPkLuckTimeMax(void){ + char *pklucktimearg=NULL; + char pklucktimestr[10]; + pklucktimearg = config.pklucktime; + if( getStringFromIndexWithDelim( pklucktimearg, ",", 2, pklucktimestr, sizeof( pklucktimestr)) == FALSE ) + return -1; + return atoi(pklucktimestr); +} +int getPkLuckNum(void){ + char *pklucknumarg=NULL; + char pklucknumstr[10]; + int pklucknummin,pklucknummax; + pklucknumarg = config.pklucknum; + if( getStringFromIndexWithDelim( pklucknumarg, "-", 1, pklucknumstr, sizeof( pklucknumstr)) == FALSE ) + pklucknummin = 1; + pklucknummin = atoi(pklucknumstr); + if( getStringFromIndexWithDelim( pklucknumarg, "-", 2, pklucknumstr, sizeof( pklucknumstr)) == FALSE ) + pklucknummax = 1; + pklucknummax = atoi(pklucknumstr); + if(pklucknummin == pklucknummax){ + return pklucknummin; + }else{ + return RAND(pklucknummin,pklucknummax); + } + return pklucknummin; +} +int getPkLuckFame(void){ + char *pkluckarg=NULL; + char pkluckstr[256]; + char pkluckbuf[10]; + pkluckarg = config.pkluckbuf; + if( getStringFromIndexWithDelim( pkluckarg, "|", 1, pkluckstr, sizeof( pkluckstr)) == FALSE ) + return 0; + int cnt = 1; + while(1){ + if(getStringFromIndexWithDelim( pkluckstr, ",", cnt, pkluckbuf, sizeof( pkluckbuf)) == FALSE) + break; + cnt++; + } + if(cnt==1) + return atoi(pkluckstr); + else{ + cnt = RAND(1,cnt); + if(getStringFromIndexWithDelim( pkluckstr, ",", cnt, pkluckbuf, sizeof( pkluckbuf)) == FALSE) + return 0; + return atoi(pkluckbuf); + } +} +int getPkLuckVigor(void){ + char *pkluckarg=NULL; + char pkluckstr[256]; + char pkluckbuf[10]; + pkluckarg = config.pkluckbuf; + if( getStringFromIndexWithDelim( pkluckarg, "|", 2, pkluckstr, sizeof( pkluckstr)) == FALSE ) + return 0; + int cnt = 1; + while(1){ + if(getStringFromIndexWithDelim( pkluckstr, ",", cnt, pkluckbuf, sizeof( pkluckbuf)) == FALSE) + break; + cnt++; + } + if(cnt==1) + return atoi(pkluckstr); + else{ + cnt = RAND(1,cnt); + if(getStringFromIndexWithDelim( pkluckstr, ",", cnt, pkluckbuf, sizeof( pkluckbuf)) == FALSE) + return 0; + return atoi(pkluckbuf); + } +} +int getPkLuckVipPoint(void){ + char *pkluckarg=NULL; + char pkluckstr[256]; + char pkluckbuf[10]; + pkluckarg = config.pkluckbuf; + if( getStringFromIndexWithDelim( pkluckarg, "|", 3, pkluckstr, sizeof( pkluckstr)) == FALSE ) + return 0; + int cnt = 1; + while(1){ + if(getStringFromIndexWithDelim( pkluckstr, ",", cnt, pkluckbuf, sizeof( pkluckbuf)) == FALSE) + break; + cnt++; + } + if(cnt==1) + return atoi(pkluckstr); + else{ + cnt = RAND(1,cnt); + if(getStringFromIndexWithDelim( pkluckstr, ",", cnt, pkluckbuf, sizeof( pkluckbuf)) == FALSE) + return 0; + return atoi(pkluckbuf); + } +} +int getPkLuckAmPoint(void){ + char *pkluckarg=NULL; + char pkluckstr[256]; + char pkluckbuf[10]; + pkluckarg = config.pkluckbuf; + if( getStringFromIndexWithDelim( pkluckarg, "|", 4, pkluckstr, sizeof( pkluckstr)) == FALSE ) + return 0; + int cnt = 1; + while(1){ + if(getStringFromIndexWithDelim( pkluckstr, ",", cnt, pkluckbuf, sizeof( pkluckbuf)) == FALSE) + break; + cnt++; + } + if(cnt==1) + return atoi(pkluckstr); + else{ + cnt = RAND(1,cnt); + if(getStringFromIndexWithDelim( pkluckstr, ",", cnt, pkluckbuf, sizeof( pkluckbuf)) == FALSE) + return 0; + return atoi(pkluckbuf); + } +} +int getPkLuckLevel(void){ + return config.pklucklevel; +} +int getPkLuckBattleTurn(void){ + return config.pkluckbattleturn; +} +#endif +#ifdef _NO_DAOLUAN +int getTalkFloor(int num){ + char *talkfloorarg=NULL; + char talkfloorstr[10]; + talkfloorarg = config.talkfloor; + if( getStringFromIndexWithDelim( talkfloorarg, ",", num, talkfloorstr, sizeof( talkfloorstr)) == FALSE ) + return -1; + return atoi(talkfloorstr); +} +#endif +#ifdef _SUPERMAN_FIX +int getSuperManPoint(void){ + if(config.supermanpoint<=0) return -1; + return config.supermanpoint; +} +#endif +#ifdef _PICKUP_ITEM_OTHER +int getPickupItem(void){ + if(config.pickupitem<=0) return 0; + return 1; +} +char* getPickItemId(void){ + return config.pickitemid; +} +#endif +#ifdef _FM_LIAOLI +int getFmLiaoLiType(void){ + if(config.fmliaolitype<=0) return 0; + return 1; +} +#endif +#ifdef _TRADE_ITEM_FIX +int getTradeItemFix(void){ + if(config.tradeitemfix<=0) return 0; + return 1; +} +#endif +#ifdef _PETMAIL_TIME +int getPetMailTime(void){ + if(config.petmailtime<=0) return 0; + return config.petmailtime; +} +#endif +int getRandMin(void){ + if(config.randmin<=1) return 1; + return config.randmin; +} +int getRandMax(void){ + if(config.randmax<=1) return 1; + return config.randmax; +} +#ifdef _GJS_TYPE +int getGjsType(void){ + if(config.gjstype<1) return 0; + return 1; +} +#endif +int getTicketCf(void){ + if(config.ticketcf<1) return 0; + return 1; +} +char* getTicketMsg(void){ + return config.ticketmsg; +} + +char* getDefaultKey(int cli_fd){ + if(config.satype==95){ + if(cli_fd == -1) + return "www.longzoro.com";//2.5 + char fddefaultkey[32]; + memset(fddefaultkey, 0, sizeof(fddefaultkey)); + CONNECT_getDefaultKey( cli_fd, fddefaultkey, sizeof(fddefaultkey)); + if(strlen(fddefaultkey)<1) + return "www.longzoro.com";//2.5 + else + return fddefaultkey;//2.5 + } + return "www.longzoro.com"; +} +char* getRunningKey(void){ + return "www.longzoro.com";//2.5 +} +char* getSaVersion(void){ + if(config.satype==95){ + return "Z";//9.5 + } + return "K";//2.5 +} +int getSaType(void){ + return config.satype; +} +#ifdef _BATTLEEND_FIX +int getBattleEndMode(void){ + if(config.battleendmode!=1) return 0; + return 1; +} +#endif + +#ifdef _BIG_POOL_TYPE +int getPetPoolType(void){ + if(config.petpooltype!=1) return 0; + return 1; +} +int getItemPoolType(void){ + if(config.itempooltype!=1) return 0; + return 1; +} +#endif + +int getNoStayBattle(void){ + if(config.nostaybattle!=1) return 0; + return 1; +} + +int getRightNum(void){ + return config.rightnum; +} + +int getRightMode(void){ + if(config.rightmode!=1) return 0; + return 1; +} + +int getErrorMode(void){ + if(config.errormode!=1) return 0; + return 1; +} + +#ifdef _FLOOR_PARTY_CTRL +int getPartyFloor(int num){ + char *partyfloorarg=NULL; + char partyfloorstr[10]; + partyfloorarg = config.partyfloor; + if( getStringFromIndexWithDelim( partyfloorarg, ",", num, partyfloorstr, sizeof( partyfloorstr)) == FALSE ) + return -1; + return atoi(partyfloorstr); +} +#endif + +int getBattleTimtOut(void){ + if(config.battletimeout<=0) return 0; + return config.battletimeout; +} + +int getReloadNpcTime(void){ + if(config.reloadnpctime<=0) return 0; + return config.reloadnpctime; +} + +int getReloadNpcType(void){ + if(config.reloadnpctype<=0) return 0; + return 1; +} + +int getOfflineBattleTime(void){ + if(config.offlinebattletime<=0) return 2500; + return config.offlinebattletime; +} + +int getOfflineCf(void){ + if(config.offlinecf<=0 || config.offlinecf>2) return 0; + return config.offlinecf; +} + +int getOfflineMaxNum(void){ + if(config.offlinemaxnum<=0) return 0; + return config.offlinemaxnum; +} + +int getOfflineJqmMaxNum(void){ + if(config.offlinejqmmaxnum<=0) return 0; + return config.offlinejqmmaxnum; +} + +int getKongType(void){ + if(config.kongtype!=1) return 0; + return 1; +} + +int getJiFenBaiTan(void){ + if(config.jifenbaitan!=1) return 0; + return 1; +} + +int getNoPkMap(void){ + if(config.nopkmap<=0) return 0; + return config.nopkmap; +} + +int getFmBuffTrans(void){ + if(config.fmbufftrans<=0) return 0; + return config.fmbufftrans; +} + +char* getNoMpMagic(void){ + return config.nompmagic; +} + +int getLoginJqmType(void){ + if(config.loginjqmtype!=1) return 0; + return config.loginjqmtype; +} + +char* getFmMagicMpRate(int num){ + if(num<=0) return config.fmmagicmprate[0]; + else return config.fmmagicmprate[1]; +} + +int getSameIpNum(void){ + if(config.sameipnum<=0) return 0; + return config.sameipnum; +} + +int getSameJqmNum(void){ + if(config.samejqmnum<=0) return 0; + return config.samejqmnum; +} + +int getSameJqmAllNum(void){ + if(config.samejqmallnum<=0) return 0; + return config.samejqmallnum; +} + +int getMmType(void){ + if(config.mmtype<=0) return 0; + return 1; +} + +char* getMmMsg(void){ + return config.mmmsg; +} + +int getLockType(void){ + if(config.locktype<=0) return 0; + return config.locktype; +} + +int getAllTalkPoint(void){ + if(config.alltalkpoint<=0) return 0; + return config.alltalkpoint; +} + +#ifdef _NO_RIDE_ID +char* getNoRideId(void){ + return config.norideid; +} +#endif + +int getLoginType(void){ + if(config.logintype<=0) return 0; + return 1; +} + + + +#ifdef _PETTRANS_RANGE +void setPetTransRangeX(int num){ + if(config.pettransrangex<=0) return ; + if(config.pettransrangex>=4) return ; + config.pettransrangex=num; + return; +} + +int getPetTransRangeX(void){ + if(config.pettransrangex<=0) return 0; + return config.pettransrangex; +} + +void setPetTransRangeY(int num){ + if(config.pettransrangey<=0) return ; + if(config.pettransrangey>=8) return ; + config.pettransrangey=num; + return; +} + +int getPetTransRangeY(void){ + if(config.pettransrangey<=0) return 0; + return config.pettransrangey; +} + +void setPetTransRangeZ(int num){ + if(config.pettransrangez<=-5) return ; + if(config.pettransrangez>=5) return ; + config.pettransrangez=num; + return; +} + +int getPetTransRangeZ(void){ + if(config.pettransrangez<=-5) return -5; + return config.pettransrangez; +} +#endif + +#ifdef _ITEM_LUA +const char *getitemluafile(void){ + return config.itemluafile; +} +BOOL ITEM_LuaInit(const char * _FileName){ + if (strlen( _FileName) != 0) return TRUE; + return FALSE; +} + +#endif + +#ifdef _SAME_IP_ONLINE_NUM +int getSameIpOnlineNum() +{ + return config.sameiponlinenum; +} +#endif + +#ifdef _CHECK_SEVER_IP +int checkServerIp( unsigned int ip ) +{ + char serverip[64]; + char cliip[64]; + int i = 1; + + int a, b, c, d; + + a=(ip % 0x100); ip=ip / 0x100; + b=(ip % 0x100); ip=ip / 0x100; + c=(ip % 0x100); ip=ip / 0x100; + d=(ip % 0x100); + + sprintf(cliip, "%d.%d.%d.%d", a, b, c, d); + + while(getStringFromIndexWithDelim(config.serverip,",", i++, serverip, sizeof(serverip))==TRUE){ + if(strcmp(cliip, serverip) == 0){ + return TRUE; + } + } + + return FALSE; +} +#endif + +#ifdef _CAX_ESC_REPORT +/** + * ͨԱÿǩ + */ +int getReportItem(unsigned int index) { + if (config.reportitem[index] > 0) + return config.reportitem[index]; + else + return -1; +} + +/** + * VIPԱÿǩ + */ +int getVipReportItem(unsigned int index) { + if (config.vipreportitem[index] > 0) + return config.vipreportitem[index]; + else + return -1; +} +/** + * ǩȼ + */ +int getReportLv(void){ + return config.reportlv; +} +/** + * ǩת + */ +int getReportTa(void){ + return config.reportta; +} +#endif + +#ifdef _PETSKILL_SHOP_LUA +char *getFreePetSkillShopPath() +{ + return config.freepetskillshoppath; +} +#endif + +#ifdef _CAX_FAMEBUTTON +char* getfamebutton( void ) +{ + return (config.famebutton>0)? "":""; +} +#endif + +#ifdef _PET_TRANS_ABILITY +int getPetTransAbility() +{ + if(config.pettransability<=0)config.pettransability=0; + return config.pettransability; +} +int getPetTransAbility1() +{ + if(config.pettransability1<=0)config.pettransability1=150; + return config.pettransability1; +} +int getPetTransAbility2() +{ + if(config.pettransability2<=0)config.pettransability2=200; + return config.pettransability2; +} +int getPetTransAbility3() +{ + if(config.pettransability3<=0)config.pettransability3=250; + return config.pettransability3; +} +#endif + +#ifdef _PET_3TRANS +int getMMPETID1(void) +{ + return config.MMPETID1; +} +int getMMPETID2(void) +{ + return config.MMPETID2; +} +#endif + +#ifdef _NO_MAGIC +int getnomagicmap(int num ) +{ + char buf[128]; + getStringFromIndexWithDelim(config.nomagicmap,",", num+1, buf, sizeof(buf)); + return atoi(buf); +} +#endif + +#ifdef _illegalpetskill_CF +int getIllegalPetskill(int index) +{ + return config.IllegalPetskill[index]; +} +#endif + +#ifdef _CAX_PET_EVOLUTION +char getpetevotyb(void) +{ + return config.petevotyb; +} + +int getpetevotyb1(void) +{ + if(config.petevotyb1>250) + return 250; + else if(config.petevotyb1<1) + return 150; + else + return config.petevotyb1; +} + +#endif + +#ifdef _TRANS_7_COLOR +/* +int getTranColor(void) +{ + return config.TranColor; +} +*/ +char getping(void) +{ + return config.ping; +} + +char getpetsummon(void) +{ + return config.petsummon; +} + +#endif + +#ifdef _CAX_PET_ITEMRIDE +char getpetitemride(void) +{ + return config.petitemride; +} +#endif + +#ifdef _DAMMAGE_CALC +int getDamageCalc() +{ + if(config.dammagecalc > 0){ + return config.dammagecalc; + }else{ + return 70; + } +} +#endif + +#ifdef _CAX_FAME_KOUFEI +int getfamekoufei() +{ + if(config.famekoufei > 0){ + return config.famekoufei; + } +} +#endif + +#ifdef _CAX_ITEM_ADDEXP +int getexptime() +{ + if(config.exptime > 0 && config.exptime <= 72000 ){ + return config.exptime; + }else{ + return 72000; + } +} +#endif + +#ifdef _CAX_LNS_NLSUOXU +int GetConfigLineType(char *TM_ConfigName) +{ + int i; + + for( i = 0 ; i < arraysizeof( readconf ) ; i ++ ){ + if (strcmp(readconf[i].name,TM_ConfigName) == 0) break; + } + if (i == arraysizeof( readconf )) return -1; + switch( readconf[i].valuetype ){ + case CHAR: + return 0; + break; + case SHORT: + return 1; + break; + case INT: + return 2; + break; + case DOUBLE: + return 3; + break; + } +} + +char* GetConfigLineVal( char* TM_ConfigName ) +{ + char* filename = getConfigfilename(); + FILE* f=NULL; + char linebuf[256]; /* */ + int linenum=0; /* ë */ + char realopenfilename[256]; /* ˱open °̻ */ + char secondToken[256]; + char hostname[128]; + + + if( f == NULL ){ + f=fopen( filename , "r" ); /* ̻P */ + if( f == NULL ){ + print( "Can't open %s\n", filename ); + return FALSE; + } + } + + /* */ + while( fgets( linebuf , sizeof( linebuf ), f ) ){ + char firstToken[256]; /*1 ٯ */ + int i; /* */ + int ret; /**/ + + linenum ++; + + deleteWhiteSpace(linebuf); /* remove whitespace */ + + if( linebuf[0] == '#' )continue; /* comment */ + if( linebuf[0] == '\n' )continue; /* none */ + + chomp( linebuf ); /* remove tail newline */ + + /* delim "=" ƥ (1)ͼë */ + ret = getStringFromIndexWithDelim( linebuf , "=", 1, firstToken, + sizeof(firstToken) ); + if( ret == FALSE ){ + print( "Find error at %s in line %d. Ignore\n", + filename , linenum); + continue; + } + if (strcmp(firstToken,TM_ConfigName) != 0) continue; + /* readconf ƥ */ + for( i = 0 ; i < arraysizeof( readconf ) ; i ++ ){ + if( strcmp( readconf[i].name ,firstToken ) == 0 ){ + /* match */ + /* delim "=" ƥ2 ͼë */ + ret = getStringFromIndexWithDelim( linebuf , "=" , 2 + , secondToken , + sizeof(secondToken) ); + + /* NULL ٯëƩ */ + if( ret == FALSE ){ + print( "Find error at %s in line %d. Ignore", + filename , linenum); + break; + } + return secondToken; + break; + } + } + break; + } + fclose( f ); + lastConfig(); + return NULL; +} + +int getCopymapstartingID( void ) +{ + return config.mapstart; +} +#endif + +#ifdef _SHARE_EXP +int getExpShare(void){ + if (config.expshare ==1) + return 1; + else + return 0; +} +#endif + +#ifdef _TEAM_ADDEXP +int getTeamAddExp(void){ + if (config.teamaddexp >0) + return config.teamaddexp; + else + return 0; +} +#endif + +#ifdef _NO_STW_ENEMY +int getNoSTWNenemy( void ) +{ + return config.nostwenemy; +} + +int getNoSTWNenemyPoint( void ) +{ + return config.nostwenemypoint; +} +#endif + +#ifdef _DEX_FIX +int getDexFixPer(void){ + if(config.dexfixper<=0) return 1; + return config.dexfixper; +} +#endif +#ifdef _FM_EXP_ADD +unsigned int getFmAddExp( void ) +{ + return config.fmaddexp; +} +#endif diff --git a/const.c b/const.c new file mode 100644 index 0000000..50b496b --- /dev/null +++ b/const.c @@ -0,0 +1,779 @@ +#include "version.h" +#include "common.h" + +#include "char.h" +#include "char_data.h" +#include "item.h" +#include "battle.h" +#include "object.h" +#ifdef _CAX_ADD_LUADX +#include "enemy.h" +#endif +//0-1999 CHAR_getInt +//2000-3999 CHAR_getChar +//4000-5999 CHAR_getWorkInt +//6000-7999 CHAR_getWorkChar +//8000-9999 CHAR_getFlg +#define LUA_DATALINE0 0 +#define LUA_DATALINE1 2000 +#define LUA_DATALINE2 4000 +#define LUA_DATALINE3 6000 +#define LUA_DATALINE4 8000 +#define LUA_DATALINE5 10000 + +typedef struct __lua_const { + const char *name; + unsigned int size; + int vl; +}lua_const; + +lua_const M_Lua_RegConstList[] = { + {"_%", sizeof("_%"), LUA_DATALINE0 + CHAR_DATAPLACENUMBER}, + {"_%", sizeof("_%"), LUA_DATALINE0 + CHAR_BASEIMAGENUMBER}, + {"_ԭ%", sizeof("_ԭ%"), LUA_DATALINE0 + CHAR_BASEBASEIMAGENUMBER}, + {"_%", sizeof("_%"), LUA_DATALINE0 + CHAR_FACEIMAGENUMBER}, + {"_ͼ%", sizeof("_ͼ%"), LUA_DATALINE0 + CHAR_FLOOR}, + {"_X%", sizeof("_X%"), LUA_DATALINE0 + CHAR_X}, + {"_Y%", sizeof("_Y%"), LUA_DATALINE0 + CHAR_Y}, + {"_%", sizeof("_%"), LUA_DATALINE0 + CHAR_DIR}, + {"_ȼ%", sizeof("_ȼ%"), LUA_DATALINE0 + CHAR_LV}, + {"_ʯ%", sizeof("_ʯ%"), LUA_DATALINE0 + CHAR_GOLD}, + {"_Ѫ%", sizeof("_Ѫ%"), LUA_DATALINE0 + CHAR_HP}, + {"_%", sizeof("_%"), LUA_DATALINE0 + CHAR_MP}, + {"_M%", sizeof("_M%"), LUA_DATALINE0 + CHAR_MAXMP}, + {"_%", sizeof("_%"), LUA_DATALINE0 + CHAR_VITAL}, + {"_%", sizeof("_%"), LUA_DATALINE0 + CHAR_STR}, + {"_%", sizeof("_%"), LUA_DATALINE0 + CHAR_TOUGH}, + {"_ٶ%", sizeof("_ٶ%"), LUA_DATALINE0 + CHAR_DEX}, + {"_%", sizeof("_%"), LUA_DATALINE0 + CHAR_CHARM}, + {"_%", sizeof("_%"), LUA_DATALINE0 + CHAR_LUCK}, + {"_%", sizeof("_%"), LUA_DATALINE0 + CHAR_EARTHAT}, + {"_ˮ%", sizeof("_ˮ%"), LUA_DATALINE0 + CHAR_WATERAT}, + {"_%", sizeof("_%"), LUA_DATALINE0 + CHAR_FIREAT}, + {"_%", sizeof("_%"), LUA_DATALINE0 + CHAR_WINDAT}, + {"_ս%", sizeof("_ս%"), LUA_DATALINE0 + CHAR_DEFAULTPET}, + {"_CL%", sizeof("_CL%"), LUA_DATALINE0 + CHAR_CRITIAL}, + {"_CR%", sizeof("_CR%"), LUA_DATALINE0 + CHAR_COUNTER}, + {"_ϡ%", sizeof("_ϡ%"), LUA_DATALINE0 + CHAR_RARE}, + {"_RH%", sizeof("_RH%"), LUA_DATALINE0 + CHAR_RADARSTRENGTH}, + {"_CE%", sizeof("_CE%"), LUA_DATALINE0 + CHAR_CHATVOLUME}, + {"_ML%", sizeof("_ML%"), LUA_DATALINE0 + CHAR_MERCHANTLEVEL}, + {"_¼%", sizeof("_¼%"), LUA_DATALINE0 + CHAR_SAVEPOINT}, + {"_DM%", sizeof("_DM%"), LUA_DATALINE0 + CHAR_DETERMINEITEM}, + {"_ƺ%", sizeof("_ƺ%"), LUA_DATALINE0 + CHAR_INDEXOFEQTITLE}, + {"_ƶ%", sizeof("_ƶ%"), LUA_DATALINE0 + CHAR_POISON}, + {"_%", sizeof("_%"), LUA_DATALINE0 + CHAR_PARALYSIS}, + {"_Ĭ%", sizeof("_Ĭ%"), LUA_DATALINE0 + CHAR_SLEEP}, + {"_ʯ%", sizeof("_ʯ%"), LUA_DATALINE0 + CHAR_STONE}, + {"_ư%", sizeof("_ư%"), LUA_DATALINE0 + CHAR_DRUNK}, + {"_%", sizeof("_%"), LUA_DATALINE0 + CHAR_CONFUSION}, + {"_%", sizeof("_%"), LUA_DATALINE0 + CHAR_LOGINCOUNT}, + {"_%", sizeof("_%"), LUA_DATALINE0 + CHAR_DEADCOUNT}, + {"_ߴ%", sizeof("_ߴ%"), LUA_DATALINE0 + CHAR_WALKCOUNT}, + {"_˵%", sizeof("_˵%"), LUA_DATALINE0 + CHAR_TALKCOUNT}, + {"_˴%", sizeof("_˴%"), LUA_DATALINE0 + CHAR_DAMAGECOUNT}, + {"_%", sizeof("_%"), LUA_DATALINE0 + CHAR_GETPETCOUNT}, + {"_ɱ%", sizeof("_ɱ%"), LUA_DATALINE0 + CHAR_KILLPETCOUNT}, + {"_%", sizeof("_%"), LUA_DATALINE0 + CHAR_DEADPETCOUNT}, + {"_%", sizeof("_%"), LUA_DATALINE0 + CHAR_SENDMAILCOUNT}, + {"_%", sizeof("_%"), LUA_DATALINE0 + CHAR_MERGEITEMCOUNT}, + {"_PK%", sizeof("_PK%"), LUA_DATALINE0 + CHAR_DUELBATTLECOUNT}, + {"_PӮ%", sizeof("_PӮ%"), LUA_DATALINE0 + CHAR_DUELWINCOUNT}, + {"_P%", sizeof("_P%"), LUA_DATALINE0 + CHAR_DUELLOSECOUNT}, + {"_P%", sizeof("_P%"), LUA_DATALINE0 + CHAR_DUELSTWINCOUNT}, + {"_P%", sizeof("_P%"), LUA_DATALINE0 + CHAR_DUELMAXSTWINCOUNT}, + {"_%", sizeof("_%"), LUA_DATALINE0 + CHAR_WHICHTYPE}, + {"_Ƽ%", sizeof("_Ƽ%"), LUA_DATALINE0 + CHAR_WALKINTERVAL}, + {"_ѭʱ%", sizeof("_ѭʱ%"), LUA_DATALINE0 + CHAR_LOOPINTERVAL}, +#ifdef _NEWOPEN_MAXEXP + {"_ɾ%", sizeof("_ɾ%"), LUA_DATALINE0 + CHAR_OLDEXP}, + {"_%", sizeof("_%"), LUA_DATALINE0 + CHAR_EXP}, +#else + {"_%", sizeof("_%"), LUA_DATALINE0 + CHAR_EXP}, +#endif + +#ifdef _CAX_ADD_LUADX + {"_ѪMAX%", sizeof("_ѪMAX%"), LUA_DATALINE0 + CHAR_WORKMAXHP}, + {"_MAX%", sizeof("_MAX%"), LUA_DATALINE0 + CHAR_WORKMAXMP}, + {"_ͼ%", sizeof("_ͼ%"), LUA_DATALINE2 + CHAR_WORKFMFLOOR}, + {"_ɳ%", sizeof("_ɳ%"), LUA_DATALINE0 + CHAR_ALLOCPOINT}, + {"_PETRANK%", sizeof("_PETRANK%"), LUA_DATALINE0 + CHAR_PETRANK}, + {"_ENEMYBASE%", sizeof("_ENEMYBASE%"), LUA_DATALINE0 + CHAR_PETID}, + {"_̯%", sizeof("_̯%"), LUA_DATALINE0 + CHAR_WORKSTREETVENDOR}, + {"_̯%", sizeof("_̯%"), LUA_DATALINE0 + CHAR_WORKSTREETVENDOR_WHO}, + {"_̯%", sizeof("_̯%"), LUA_DATALINE0 + CHAR_STREETVENDOR_NAME}, + {"_%", sizeof("_%"), LUA_DATALINE0 + CHAR_LOVE}, + {"_ż%", sizeof("_ż%"), LUA_DATALINE0 + CHAR_LOVERID}, + {"_ż%", sizeof("_ż%"), LUA_DATALINE0 + CHAR_LOVERNAME}, + {"ɳ_ٶ%", sizeof("ɳ_ٶ%"), 0}, + {"ɳ_%", sizeof("ɳ_%"), 1}, + {"ɳ_%", sizeof("ɳ_%"), 2}, + {"ɳ_%", sizeof("ɳ_%"), 3}, + {"_ٶȳɳ%", sizeof("_ٶȳɳ%"), 0}, + {"_ɳ%", sizeof("_ɳ%"), 1}, + {"_ɳ%", sizeof("_ɳ%"), 2}, + {"_ɳ%", sizeof("_ɳ%"), 3}, + {"ģ_%", sizeof("ģ_%"), LUA_DATALINE0 + E_T_TEMPNO}, + {"ģ_ʼ%", sizeof("ģ_ʼ%"), LUA_DATALINE0 + E_T_INITNUM}, + {"ģ_%", sizeof("ģ_%"), E_T_LVUPPOINT}, + {"ģ_%", sizeof("ģ_%"), LUA_DATALINE0 + E_T_BASEVITAL}, + {"ģ_%", sizeof("ģ_%"), LUA_DATALINE0 + E_T_BASESTR}, + {"ģ_%", sizeof("ģ_%"), LUA_DATALINE0 + E_T_BASETGH}, + {"ģ_ٶ%", sizeof("ģ_ٶ%"), LUA_DATALINE0 + E_T_BASEDEX}, + {"ģ_AI%", sizeof("ģ_AI%"), LUA_DATALINE0 + E_T_MODAI}, + {"ģ_GET%", sizeof("ģ_GET%"), LUA_DATALINE0 + E_T_GET}, + {"ģ_%", sizeof("ģ_%"), LUA_DATALINE0 + E_T_EARTHAT}, + {"ģ_ˮ%", sizeof("ģ_ˮ%"), LUA_DATALINE0 + E_T_WATERAT}, + {"ģ_%", sizeof("ģ_%"), LUA_DATALINE0 + E_T_FIREAT}, + {"ģ_%", sizeof("ģ_%"), LUA_DATALINE0 + E_T_WINDAT}, + {"ģ_%", sizeof("ģ_%"), LUA_DATALINE0 + E_T_POISON}, + {"ģ_鿹%", sizeof("ģ_鿹%"), LUA_DATALINE0 + E_T_PARALYSIS}, + {"ģ_Ĭ%", sizeof("ģ_Ĭ%"), LUA_DATALINE0 + E_T_SLEEP}, + {"ģ_ʯ%", sizeof("ģ_ʯ%"), LUA_DATALINE0 + E_T_STONE}, + {"ģ_%", sizeof("ģ_%"), LUA_DATALINE0 + E_T_DRUNK}, + {"ģ_ҿ%", sizeof("ģ_ҿ%"), LUA_DATALINE0 + E_T_CONFUSION}, + {"ģ_輼1%", sizeof("ģ_輼1%"), LUA_DATALINE0 + E_T_PETSKILL1}, + {"ģ_輼2%", sizeof("ģ_輼2%"), LUA_DATALINE0 + E_T_PETSKILL2}, + {"ģ_輼3%", sizeof("ģ_輼3%"), LUA_DATALINE0 + E_T_PETSKILL3}, + {"ģ_輼4%", sizeof("ģ_輼4%"), LUA_DATALINE0 + E_T_PETSKILL4}, + {"ģ_輼5%", sizeof("ģ_輼5%"), LUA_DATALINE0 + E_T_PETSKILL5}, + {"ģ_輼6%", sizeof("ģ_輼6%"), LUA_DATALINE0 + E_T_PETSKILL6}, + {"ģ_輼7%", sizeof("ģ_輼7%"), LUA_DATALINE0 + E_T_PETSKILL7}, + {"ģ_ϡ%", sizeof("ģ_ϡ%"), LUA_DATALINE0 + E_T_RARE}, + {"ģ_%", sizeof("ģ_%"), LUA_DATALINE0 + E_T_CRITICAL}, + {"ģ_%", sizeof("ģ_%"), LUA_DATALINE0 + E_T_COUNTER}, + {"ģ_%", sizeof("ģ_%"), LUA_DATALINE0 + E_T_SLOT}, + {"ģ_ͼ%", sizeof("ģ_ͼ%"), LUA_DATALINE0 + E_T_IMGNUMBER}, + {"ģ_FLG%", sizeof("ģ_FLG%"), LUA_DATALINE0 + E_T_PETFLG}, + {"ģ_ߴ%", sizeof("ģ_ߴ%"), LUA_DATALINE0 + E_T_SIZE}, + {"ģ_%", sizeof("ģ_%"), LUA_DATALINE0 + E_T_LIMITLEVEL}, + {"ģ_ں%", sizeof("ģ_ں%"), LUA_DATALINE0 + E_T_FUSIONCODE}, + {"ģ_ԭ%", sizeof("ģ_ԭ%"), LUA_DATALINE1 + E_T_NAME}, +#endif + + {"_%", sizeof("_%"), LUA_DATALINE0 + CHAR_LASTTALKELDER}, + {"_%", sizeof("_%"), LUA_DATALINE0 + CHAR_SKILLUPPOINT}, + {"_LT%", sizeof("_LT%"), LUA_DATALINE0 + CHAR_LEVELUPPOINT}, + {"_ͼ%", sizeof("_ͼ%"), LUA_DATALINE0 + CHAR_IMAGETYPE}, + {"_CLR%", sizeof("_CLR%"), LUA_DATALINE0 + CHAR_NAMECOLOR}, + {"_ɫ%", sizeof("_ɫ%"), LUA_DATALINE0 + CHAR_POPUPNAMECOLOR}, + {"_%", sizeof("_%"), LUA_DATALINE0 + CHAR_LASTTIMESETLUCK}, + {"_DP%", sizeof("_DP%"), LUA_DATALINE0 + CHAR_DUELPOINT}, + {"_ת%", sizeof("_ת%"), LUA_DATALINE0 + CHAR_TRANSMIGRATION}, + {"_ת%", sizeof("_ת%"), LUA_DATALINE0 + CHAR_TRANSEQUATION}, + {"_IA%", sizeof("_IA%"), LUA_DATALINE0 + CHAR_INITDATA}, + {"_ʱ%", sizeof("_ʱ%"), LUA_DATALINE0 + CHAR_SILENT}, + {"_%", sizeof("_%"), LUA_DATALINE0 + CHAR_FMINDEX}, + {"_ְ%", sizeof("_ְ%"), LUA_DATALINE0 + CHAR_FMLEADERFLAG}, + {"_ؾ%", sizeof("_ؾ%"), LUA_DATALINE0 + CHAR_FMSPRITE}, + {"_%", sizeof("_%"), LUA_DATALINE0 + CHAR_BANKGOLD}, + {"_%", sizeof("_%"), LUA_DATALINE0 + CHAR_RIDEPET}, + {"_%", sizeof("_%"), LUA_DATALINE0 + CHAR_LEARNRIDE}, + {"_%", sizeof("_%"), LUA_DATALINE0 + CHAR_LIMITLEVEL}, +#ifdef _PET_FUSION + {"_%", sizeof("_%"), LUA_DATALINE0 + CHAR_FUSIONCODE}, + {"_%", sizeof("_%"), LUA_DATALINE0 + CHAR_FUSIONINDEX}, + {"_%", sizeof("_%"), LUA_DATALINE0 + CHAR_FUSIONRAISE}, + {"_%", sizeof("_%"), LUA_DATALINE0 + CHAR_FUSIONBEIT}, + {"_ʱ%", sizeof("_ʱ%"), LUA_DATALINE0 + CHAR_FUSIONTIMELIMIT}, +#endif +#ifdef _DEATH_CONTEND + {"_ӱ%", sizeof("_ӱ%"), LUA_DATALINE0 + CHAR_PKLISTTEAMNUM}, + {"_%", sizeof("_%"), LUA_DATALINE0 + CHAR_PKLISTLEADER}, +#endif +#ifdef _PERSONAL_FAME + {"_%", sizeof("_%"), LUA_DATALINE0 + CHAR_FAME}, +#endif +#ifdef _CAX_Mercenary + {"_Ӷ%", sizeof("_Ӷ%"), LUA_DATALINE0 + CHAR_MERCENARY}, //Ӷ +#endif +#ifdef _VIP_RIDE + {"_VIP%", sizeof("_VIP%"), LUA_DATALINE0 + CHAR_VIPRIDE}, + {"_VIPʱ%", sizeof("_VIPʱ%"), LUA_DATALINE0 + CHAR_VIPTIME}, +#endif +#ifdef _VIP_SERVER + {"_%", sizeof("_%"), LUA_DATALINE0 + CHAR_AMPOINT}, +#endif +#ifdef _EV_NUM + {"_ܻ%", sizeof("_ܻ%"), LUA_DATALINE0 + CHAR_EVNUM}, +#endif + {"_%", sizeof("_%"), LUA_DATALINE0 + CHAR_MISSIONTRAIN_NUM}, + {"_ʱ%", sizeof("_ʱ%"), LUA_DATALINE0 + CHAR_MISSIONTRAIN_TIME}, + {"_%", sizeof("_%"), LUA_DATALINE0 + CHAR_MISSIONTRAIN_NUM}, // ܻ + {"_%", sizeof("_%"), LUA_DATALINE0 + CHAR_EVOLVE}, + {"_ʱ%", sizeof("_ʱ%"), LUA_DATALINE0 + CHAR_ONLINE_TIME}, + {"_¥ʱ%", sizeof("_¥ʱ%"), LUA_DATALINE0 + CHAR_FLOORDIFI_TIME}, + {"_Ʒ%", sizeof("_Ʒ%"), LUA_DATALINE0 + CHAR_SUPER}, + {"_ƺŵȼ%", sizeof("_ƺŵȼ%"), LUA_DATALINE0 + CHAR_TITLE_LV}, + {"_ƺʱ%", sizeof("_ƺʱ%"), LUA_DATALINE0 + CHAR_TITLE_TIME}, + {"_ʱ%", sizeof("_ʱ%"), LUA_DATALINE0 + CHAR_MISSION_TIME}, + +#ifdef _ATTACK_MAGIC + {"_ħ%", sizeof("_ħ%"), LUA_DATALINE0 + CHAR_EARTH_EXP}, + {"_ˮħ%", sizeof("_ˮħ%"), LUA_DATALINE0 + CHAR_WATER_EXP}, + {"_ħ%", sizeof("_ħ%"), LUA_DATALINE0 + CHAR_FIRE_EXP}, + {"_ħ%", sizeof("_ħ%"), LUA_DATALINE0 + CHAR_WIND_EXP}, + {"_ħ%", sizeof("_ħ%"), LUA_DATALINE0 + CHAR_EARTH_RESIST}, + {"_ˮħ%", sizeof("_ˮħ%"), LUA_DATALINE0 + CHAR_WATER_RESIST}, + {"_ħ%", sizeof("_ħ%"), LUA_DATALINE0 + CHAR_FIRE_RESIST}, + {"_ħ%", sizeof("_ħ%"), LUA_DATALINE0 + CHAR_WIND_RESIST}, + {"_쾭%", sizeof("_쾭%"), LUA_DATALINE0 + CHAR_EARTH_ATTMAGIC_EXP}, + {"_ˮ쾭%", sizeof("_ˮ쾭%"), LUA_DATALINE0 + CHAR_WATER_ATTMAGIC_EXP}, + {"_쾭%", sizeof("_쾭%"), LUA_DATALINE0 + CHAR_FIRE_ATTMAGIC_EXP}, + {"_쾭%", sizeof("_쾭%"), LUA_DATALINE0 + CHAR_WIND_ATTMAGIC_EXP}, + {"_ؿ%", sizeof("_ؿ%"), LUA_DATALINE0 + CHAR_EARTH_DEFMAGIC_EXP}, + {"_ˮ%", sizeof("_ˮ%"), LUA_DATALINE0 + CHAR_WATER_DEFMAGIC_EXP}, + {"_𿹾%", sizeof("_𿹾%"), LUA_DATALINE0 + CHAR_FIRE_DEFMAGIC_EXP}, + {"_翹%", sizeof("_翹%"), LUA_DATALINE0 + CHAR_WIND_DEFMAGIC_EXP}, +#endif +#ifdef _GAMBLE_BANK + {"_%", sizeof("_%"), LUA_DATALINE0 + CHAR_PERSONAGOLD}, +#endif +#ifdef _DROPSTAKENEW + {"_ķ%", sizeof("_ķ%"), LUA_DATALINE0 + CHAR_GAMBLENUM}, +#endif +#ifdef _AUCTIONEER + {"_ĵ%", sizeof("_ĵ%"), LUA_DATALINE0 + CHAR_AUCGOLD}, +#endif +#ifdef _PET_EVOLUTION + {"_Ѫҩ%", sizeof("_Ѫҩ%"), LUA_DATALINE0 + CHAR_EVOLUTIONBASEVTL}, + {"_ҩ%", sizeof("_ҩ%"), LUA_DATALINE0 + CHAR_EVOLUTIONBASESTR}, + {"_ҩ%", sizeof("_ҩ%"), LUA_DATALINE0 + CHAR_EVOLUTIONBASETGH}, + {"_ҩ%", sizeof("_ҩ%"), LUA_DATALINE0 + CHAR_EVOLUTIONBASEDEX}, +#endif +#ifdef _FAMILYBANKSTONELOG + {"_%", sizeof("_%"), LUA_DATALINE0 + CHAR_FMBANKGOLD}, +#endif +#ifdef _FM_JOINLIMIT + {"_%", sizeof("_%"), LUA_DATALINE0 + CHAR_FMTIMELIMIT}, +#endif +#ifdef _CHAR_PROFESSION // WON ADD ְҵ + {"_ְҵ%", sizeof("_ְҵ%"), LUA_DATALINE0 + PROFESSION_CLASS}, + {"_ְ%", sizeof("_ְ%"), LUA_DATALINE0 + PROFESSION_LEVEL}, + //{"_ְ", sizeof("_ְ"), LUA_DATALINE0 + PROFESSION_EXP}, + {"_ְ%", sizeof("_ְ%"), LUA_DATALINE0 + PROFESSION_SKILL_POINT}, + {"_ְ%", sizeof("_ְ%"), LUA_DATALINE0 + ATTACHPILE}, + {"_ְ%", sizeof("_ְ%"), LUA_DATALINE0 + PROFESSION_FIRE_P}, + {"_ְ%", sizeof("_ְ%"), LUA_DATALINE0 + PROFESSION_ICE_P}, + {"_ְ%", sizeof("_ְ%"), LUA_DATALINE0 + PROFESSION_THUNDER_P}, + {"_ְ%", sizeof("_ְ%"), LUA_DATALINE0 + PROFESSION_FIRE_R}, + {"_ְ%", sizeof("_ְ%"), LUA_DATALINE0 + PROFESSION_ICE_R}, + {"_ְ׿%", sizeof("_ְ׿%"), LUA_DATALINE0 + PROFESSION_THUNDER_R}, +#endif +#ifdef _ALLDOMAN // (ɿ) Syu ADD аNPC + {"_ս%", sizeof("_ս%"), LUA_DATALINE0 + CHAR_HEROFLOOR}, +#endif +#ifdef _PETSKILL_BECOMEPIG + {"_ʱ%", sizeof("_ʱ%"), LUA_DATALINE0 + CHAR_BECOMEPIG}, + {"_%", sizeof("_%"), LUA_DATALINE0 + CHAR_BECOMEPIG_BBI}, +#endif + {"_ʱ%", sizeof("_ʱ%"), LUA_DATALINE0 + CHAR_LASTLEAVETIME}, +#ifdef _NEW_MANOR_LAW + {"_%", sizeof("_%"), LUA_DATALINE0 + CHAR_MOMENTUM}, +#endif +#ifdef _ANGEL_SUMMON + {"_%", sizeof("_%"), LUA_DATALINE0 + CHAR_HEROCNT}, +#endif +#ifdef _TEACHER_SYSTEM + {"_%", sizeof("_%"), LUA_DATALINE0 + CHAR_TEACHER_FAME}, +#endif +#ifdef _CAX_ESC_REPORT + {"_ǩ%", sizeof("_ǩ%"), LUA_DATALINE0 + CHAR_REPORT}, +#endif +#ifdef _RACEMAN + {"_CKN%", sizeof("_CKN%"), LUA_DATALINE0 + CHAR_CHECKIN}, + {"_CN1%", sizeof("_CN1%"), LUA_DATALINE0 + CHAR_CATCHCNT1}, + {"_CN2%", sizeof("_CN2%"), LUA_DATALINE0 + CHAR_CATCHCNT2}, + {"_CN3%", sizeof("_CN3%"), LUA_DATALINE0 + CHAR_CATCHCNT3}, + {"_CN4%", sizeof("_CN4%"), LUA_DATALINE0 + CHAR_CATCHCNT4}, + {"_CN5%", sizeof("_CN5%"), LUA_DATALINE0 + CHAR_CATCHCNT5}, + {"_KN1%", sizeof("_KN1%"), LUA_DATALINE0 + CHAR_KINDCNT1}, + {"_KN2%", sizeof("_KN2%"), LUA_DATALINE0 + CHAR_KINDCNT2}, + {"_KN3%", sizeof("_KN3%"), LUA_DATALINE0 + CHAR_KINDCNT3}, + {"_KN4%", sizeof("_KN4%"), LUA_DATALINE0 + CHAR_KINDCNT4}, + {"_KN5%", sizeof("_KN5%"), LUA_DATALINE0 + CHAR_KINDCNT5}, + {"_KN6%", sizeof("_KN6%"), LUA_DATALINE0 + CHAR_KINDCNT6}, + {"_KN7%", sizeof("_KN7%"), LUA_DATALINE0 + CHAR_KINDCNT7}, + {"_KN8%", sizeof("_KN8%"), LUA_DATALINE0 + CHAR_KINDCNT8}, + {"_KN9%", sizeof("_KN9%"), LUA_DATALINE0 + CHAR_KINDCNT9}, + {"_KN10%", sizeof("_KN10%"), LUA_DATALINE0 + CHAR_KINDCNT10}, +#endif + {"_ף%", sizeof("_ף%"), LUA_DATALINE0 + CHAR_BEATITUDE}, +#ifdef _VIGOR_SYS + {"_%", sizeof("_%"), LUA_DATALINE0 + CHAR_VIGOR}, +#endif + {"_1%", sizeof("_1%"), LUA_DATALINE0 + CHAR_LUASAVE_WORKINT_1}, //lua洢 + {"_2%", sizeof("_2%"), LUA_DATALINE0 + CHAR_LUASAVE_WORKINT_2}, //lua洢 + {"_3%", sizeof("_3%"), LUA_DATALINE0 + CHAR_LUASAVE_WORKINT_3}, //lua洢 + {"_洢1%", sizeof("_洢1%"), LUA_DATALINE0 + CHAR_LUASAVE_INT_1}, //洢浵 + {"_洢2%", sizeof("_洢2%"), LUA_DATALINE0 + CHAR_LUASAVE_INT_2}, //洢浵 + {"_洢3%", sizeof("_洢3%"), LUA_DATALINE0 + CHAR_LUASAVE_INT_3}, //洢浵 + // {"_IP%",sizeof("_IP%"),LUA_DATALINE1 + CHAR_CHARPLAYIP}, + + {"_Աȼ%", sizeof("_Աȼ%"), LUA_DATALINE0 + CHAR_VIPRIDE}, + {"_Աʱ%", sizeof("_Աʱ%"), LUA_DATALINE0 + CHAR_VIPTIME}, + + {"_NPCʱ%", sizeof("_NPCʱ%"), LUA_DATALINE0 + CHAR_NPCTIME}, + + {"_ԭ%", sizeof("_ԭ%"), LUA_DATALINE1 + CHAR_NAME}, + {"_%", sizeof("_%"), LUA_DATALINE1 + CHAR_USERPETNAME}, + {"_ʺ%", sizeof("_ʺ%"), LUA_DATALINE1 + CHAR_CDKEY}, + {"_%", sizeof("_%"), LUA_DATALINE1 + CHAR_OWNERCDKEY}, + {"_%", sizeof("_%"), LUA_DATALINE1 + CHAR_OWNERCHARANAME}, + {"_%", sizeof("_%"), LUA_DATALINE1 + CHAR_FMNAME}, +#ifdef _TEACHER_SYSTEM + {"_ʦ%", sizeof("_ʦ%"), LUA_DATALINE1 + CHAR_TEACHER_ID}, + {"_ʦ%", sizeof("_ʦ%"), LUA_DATALINE1 + CHAR_TEACHER_NAME}, +#endif +#ifdef _CAX_LUA_BETT01 + {"_ս1%", sizeof("_ս1%"), LUA_DATALINE2 + CHAR_WORKBATTLECOM1}, + {"_ս2%", sizeof("_ս2%"), LUA_DATALINE2 + CHAR_WORKBATTLECOM2}, + {"_սģ%", sizeof("_սģ%"), LUA_DATALINE2 + CHAR_WORKBATTLEMODE}, +#endif + {"_ģʽ%", sizeof("_ģʽ%"), LUA_DATALINE2 + CHAR_WORKPARTYMODE}, + {"_%", sizeof("_%"), LUA_DATALINE2 + CHAR_WORKOBJINDEX}, +#ifdef _ADD_ACTION //npc + {"_%", sizeof("_%"), LUA_DATALINE2 + CHAR_WORKACTION}, +#endif + {"_LUA%", sizeof("_LUA%"), LUA_DATALINE2 + CHAR_WORKLUANPCINT}, + {"_1LUA%", sizeof("_1LUA%"), LUA_DATALINE2 + CHAR_WORKLUANPCINT1}, + + {"_IAK%", sizeof("_IAK%"), LUA_DATALINE4 + CHAR_ISATTACK}, + {"_ս%", sizeof("_ս%"), LUA_DATALINE4 + CHAR_ISATTACKED}, + {"_IOR%", sizeof("_IOR%"), LUA_DATALINE4 + CHAR_ISOVER}, + {"_·%", sizeof("_·%"), LUA_DATALINE4 + CHAR_ISOVERED}, + {"_HHT%", sizeof("_HHT%"), LUA_DATALINE4 + CHAR_HAVEHEIGHT}, + {"_%", sizeof("_%"), LUA_DATALINE4 + CHAR_ISVISIBLE}, + {"_ITP%", sizeof("_ITP%"), LUA_DATALINE4 + CHAR_ISTRANSPARENT}, + {"_IFG%", sizeof("_IFG%"), LUA_DATALINE4 + CHAR_ISFLYING}, + {"_%", sizeof("_%"), LUA_DATALINE4 + CHAR_ISDIE}, + {"_IBIG%", sizeof("_IBIG%"), LUA_DATALINE4 + CHAR_ISBIG}, + {"_ս%", sizeof("_ս%"), LUA_DATALINE4 + CHAR_ISSHOWBATTLEMSG}, + {"_ӱ%", sizeof("_ӱ%"), LUA_DATALINE4 + CHAR_ISPARTY}, + {"_%", sizeof("_%"), LUA_DATALINE4 + CHAR_ISWARP}, + {"_ս%", sizeof("_ս%"), LUA_DATALINE4 + CHAR_ISDUEL}, + {"_ı%", sizeof("_ı%"), LUA_DATALINE4 + CHAR_ISPARTYCHAT}, + {"_Ƭ%", sizeof("_Ƭ%"), LUA_DATALINE4 + CHAR_ISTRADECARD}, + {"_ױ%", sizeof("_ױ%"), LUA_DATALINE4 + CHAR_ISTRADE}, +#ifdef _CHANNEL_MODIFY + {"_Ƶ%", sizeof("_Ƶ%"), LUA_DATALINE4 + CHAR_ISTELL}, + {"_Ƶ%", sizeof("_Ƶ%"), LUA_DATALINE4 + CHAR_ISFM}, + {"_ְƵ%", sizeof("_ְƵ%"), LUA_DATALINE4 + CHAR_ISOCC}, + {"_Ի%", sizeof("_Ի%"), LUA_DATALINE4 + CHAR_ISSAVE}, + {"_Ƶ%", sizeof("_Ƶ%"), LUA_DATALINE4 + CHAR_ISCHAT}, +#endif + + {"_ID%", sizeof("_ID%"), LUA_DATALINE0 + ITEM_ID}, + {"_ͼ%", sizeof("_ͼ%"), LUA_DATALINE0 + ITEM_BASEIMAGENUMBER}, + {"_ɱ%", sizeof("_ɱ%"), LUA_DATALINE0 + ITEM_COST}, + {"_%", sizeof("_%"), LUA_DATALINE0 + ITEM_TYPE}, + {"_AUF%", sizeof("_AUF%"), LUA_DATALINE0 + ITEM_ABLEUSEFIELD}, + {"_TARGET%", sizeof("_TARGET%"), LUA_DATALINE0 + ITEM_TARGET}, + {"_ȼ%", sizeof("_ȼ%"), LUA_DATALINE0 + ITEM_LEVEL}, +#ifdef _ITEM_MAXUSERNUM + {"_%", sizeof("_%"), LUA_DATALINE0 + ITEM_DAMAGEBREAK}, +#endif +#ifdef _ITEMSET4_TXT + {"_ѵ%", sizeof("_ѵ%"), LUA_DATALINE0 + ITEM_USEPILENUMS}, + {"_ɵ%", sizeof("_ɵ%"), LUA_DATALINE0 + ITEM_CANBEPILE}, + {"_STR%", sizeof("_STR%"), LUA_DATALINE0 + ITEM_NEEDSTR}, + {"_DEX%", sizeof("_DEX%"), LUA_DATALINE0 + ITEM_NEEDDEX}, + {"_ת%", sizeof("_ת%"), LUA_DATALINE0 + ITEM_NEEDTRANS}, + {"_ְҵ%", sizeof("_ְҵ%"), LUA_DATALINE0 + ITEM_NEEDPROFESSION}, +#endif +#ifdef _TAKE_ITEMDAMAGE + {"_;%", sizeof("_;%"), LUA_DATALINE0 + ITEM_DAMAGECRUSHE}, + {"_MAX;%", sizeof("_MAX;%"), LUA_DATALINE0 + ITEM_MAXDAMAGECRUSHE}, +#endif +#ifdef _ADD_DEAMGEDEFC + {"_%", sizeof("_%"), LUA_DATALINE0 + ITEM_OTHERDAMAGE}, + {"_%", sizeof("_%"), LUA_DATALINE0 + ITEM_OTHERDEFC}, +#endif +#ifdef _SUIT_ITEM + {"_%", sizeof("_%"), LUA_DATALINE0 + ITEM_SUITCODE}, +#endif + {"_AKMIN%", sizeof("_AKMIN%"), LUA_DATALINE0 + ITEM_ATTACKNUM_MIN}, + {"_AKMAX%", sizeof("_AKMAX%"), LUA_DATALINE0 + ITEM_ATTACKNUM_MAX}, + {"_%", sizeof("_%"), LUA_DATALINE0 + ITEM_MODIFYATTACK}, + {"_%", sizeof("_%"), LUA_DATALINE0 + ITEM_MODIFYDEFENCE}, + {"_%", sizeof("_%"), LUA_DATALINE0 + ITEM_MODIFYQUICK}, + {"_%", sizeof("_%"), LUA_DATALINE0 + ITEM_MODIFYHP}, + {"_%", sizeof("_%"), LUA_DATALINE0 + ITEM_MODIFYMP}, + {"_%", sizeof("_%"), LUA_DATALINE0 + ITEM_MODIFYLUCK}, + {"_%", sizeof("_%"), LUA_DATALINE0 + ITEM_MODIFYCHARM}, + {"_%", sizeof("_%"), LUA_DATALINE0 + ITEM_MODIFYAVOID}, + {"_%", sizeof("_%"), LUA_DATALINE0 + ITEM_MODIFYATTRIB}, + {"_ֵ%", sizeof("_ֵ%"), LUA_DATALINE0 + ITEM_MODIFYATTRIBVALUE}, + {"_%", sizeof("_%"), LUA_DATALINE0 + ITEM_MAGICID}, + {"_%", sizeof("_%"), LUA_DATALINE0 + ITEM_MAGICPROB}, + {"_%", sizeof("_%"), LUA_DATALINE0 + ITEM_MAGICUSEMP}, +#ifdef _ITEMSET5_TXT + {"_%", sizeof("_%"), LUA_DATALINE0 + ITEM_MODIFYARRANGE}, + {"_%", sizeof("_%"), LUA_DATALINE0 + ITEM_MODIFYSEQUENCE}, + {"_%", sizeof("_%"), LUA_DATALINE0 + ITEM_ATTACHPILE}, + {"_%", sizeof("_%"), LUA_DATALINE0 + ITEM_HITRIGHT}, +#endif +#ifdef _ITEMSET6_TXT + {"_%", sizeof("_%"), LUA_DATALINE0 + ITEM_NEGLECTGUARD}, +#endif + {"_%", sizeof("_%"), LUA_DATALINE0 + ITEM_POISON}, + {"_%", sizeof("_%"), LUA_DATALINE0 + ITEM_PARALYSIS}, + {"_˯%", sizeof("_˯%"), LUA_DATALINE0 + ITEM_SLEEP}, + {"_ʯ%", sizeof("_ʯ%"), LUA_DATALINE0 + ITEM_STONE}, + {"_%", sizeof("_%"), LUA_DATALINE0 + ITEM_DRUNK}, + {"_%", sizeof("_%"), LUA_DATALINE0 + ITEM_CONFUSION}, + {"_һ%", sizeof("_һ%"), LUA_DATALINE0 + ITEM_CRITICAL}, + {"_%", sizeof("_%"), LUA_DATALINE0 + ITEM_USEACTION}, + {"_%", sizeof("_%"), LUA_DATALINE0 + ITEM_DROPATLOGOUT}, + {"_%", sizeof("_%"), LUA_DATALINE0 + ITEM_VANISHATDROP}, + {"_·%", sizeof("_·%"), LUA_DATALINE0 + ITEM_ISOVERED}, + {"_ʼ%", sizeof("_ʼ%"), LUA_DATALINE0 + ITEM_CANPETMAIL}, + {"_Ӻϳ%", sizeof("_Ӻϳ%"), LUA_DATALINE0 + ITEM_CANMERGEFROM}, + {"_ϳɵ%", sizeof("_ϳɵ%"), LUA_DATALINE0 + ITEM_CANMERGETO}, + {"_0%", sizeof("_0%"), LUA_DATALINE0 + ITEM_INGVALUE0}, + {"_1%", sizeof("_1%"), LUA_DATALINE0 + ITEM_INGVALUE1}, + {"_2%", sizeof("_2%"), LUA_DATALINE0 + ITEM_INGVALUE2}, + {"_3%", sizeof("_3%"), LUA_DATALINE0 + ITEM_INGVALUE3}, + {"_4%", sizeof("_4%"), LUA_DATALINE0 + ITEM_INGVALUE4}, + {"_ʱ%", sizeof("_ʱ%"), LUA_DATALINE0 + ITEM_PUTTIME}, + {"_LL%", sizeof("_LL%"), LUA_DATALINE0 + ITEM_LEAKLEVEL}, + {"_%", sizeof("_%"), LUA_DATALINE0 + ITEM_MERGEFLG}, + {"_%", sizeof("_%"), LUA_DATALINE0 + ITEM_CRUSHLEVEL}, + {"_ʱ%", sizeof("_ʱ%"), LUA_DATALINE0 + ITEM_TIME}, + {"_VAR1%", sizeof("_VAR1%"), LUA_DATALINE0 + ITEM_VAR1}, + {"_VAR2%", sizeof("_VAR2%"), LUA_DATALINE0 + ITEM_VAR2}, + {"_VAR3%", sizeof("_VAR3%"), LUA_DATALINE0 + ITEM_VAR3}, + {"_VAR4%", sizeof("_VAR4%"), LUA_DATALINE0 + ITEM_VAR4}, + + {"_%", sizeof("_%"), LUA_DATALINE2 + ITEM_WORKOBJINDEX}, + {"_%", sizeof("_%"), LUA_DATALINE2 + ITEM_WORKCHARAINDEX}, +#ifdef _ITEM_TIME_LIMIT + {"_ʱ%", sizeof("_ʱ%"), LUA_DATALINE2 + ITEM_WORKTIMELIMIT}, +#endif + + {"_ԭ%", sizeof("_ԭ%"), LUA_DATALINE1 + ITEM_NAME}, + {"_%", sizeof("_%"), LUA_DATALINE1 + ITEM_SECRETNAME}, + {"_˵%", sizeof("_˵%"), LUA_DATALINE1 + ITEM_EFFECTSTRING}, + {"_%", sizeof("_%"), LUA_DATALINE1 + ITEM_ARGUMENT}, + {"_%", sizeof("_%"), LUA_DATALINE1 + ITEM_CDKEY}, + {"_%", sizeof("_%"), LUA_DATALINE1 + ITEM_FORUSERCDKEY}, + {"_0%", sizeof("_0%"), LUA_DATALINE1 + ITEM_INGNAME0}, + {"_1%", sizeof("_1%"), LUA_DATALINE1 + ITEM_INGNAME1}, + {"_2%", sizeof("_2%"), LUA_DATALINE1 + ITEM_INGNAME2}, + {"_3%", sizeof("_3%"), LUA_DATALINE1 + ITEM_INGNAME3}, + {"_4%", sizeof("_4%"), LUA_DATALINE1 + ITEM_INGNAME4}, + + {"_ͷλ%", sizeof("_ͷλ%"), CHAR_HEAD}, + {"_λ%", sizeof("_λ%"), CHAR_BODY}, + {"_%", sizeof("_%"), CHAR_ARM}, + {"_1%", sizeof("_1%"), CHAR_DECORATION1}, + {"_2%", sizeof("_2%"), CHAR_DECORATION2}, +#ifdef _ITEM_EQUITSPACE + {"_%", sizeof("_%"), CHAR_EQSHIELD}, + {"_λ%", sizeof("_λ%"), CHAR_EQBELT}, + {"_λ%", sizeof("_λ%"), CHAR_EQSHOES}, +#endif +#ifdef _EQUIT_NEWGLOVE + {"_%", sizeof("_%"), CHAR_EQGLOVE}, +#endif + {"_1%", sizeof("_1%"), CHAR_STARTITEMARRAY + 0}, + {"_2%", sizeof("_2%"), CHAR_STARTITEMARRAY + 1}, + {"_3%", sizeof("_3%"), CHAR_STARTITEMARRAY + 2}, + {"_4%", sizeof("_4%"), CHAR_STARTITEMARRAY + 3}, + {"_5%", sizeof("_5%"), CHAR_STARTITEMARRAY + 4}, + {"_6%", sizeof("_6%"), CHAR_STARTITEMARRAY + 5}, + {"_7%", sizeof("_7%"), CHAR_STARTITEMARRAY + 6}, + {"_8%", sizeof("_8%"), CHAR_STARTITEMARRAY + 7}, + {"_9%", sizeof("_9%"), CHAR_STARTITEMARRAY + 8}, + {"_10%", sizeof("_10%"), CHAR_STARTITEMARRAY + 9}, + {"_11%", sizeof("_11%"), CHAR_STARTITEMARRAY + 10}, + {"_12%", sizeof("_12%"), CHAR_STARTITEMARRAY + 11}, + {"_13%", sizeof("_13%"), CHAR_STARTITEMARRAY + 12}, + {"_14%", sizeof("_14%"), CHAR_STARTITEMARRAY + 13}, + {"_15%", sizeof("_15%"), CHAR_STARTITEMARRAY + 14}, + + {"_1%", sizeof("_1%"), 0}, + {"_2%", sizeof("_2%"), 1}, + {"_3%", sizeof("_3%"), 2}, + {"_4%", sizeof("_4%"), 3}, + {"_5%", sizeof("_5%"), 4}, + + {"Ա_1%", sizeof("Ա_1%"), 1}, + {"Ա_2%", sizeof("Ա_2%"), 2}, + {"Ա_3%", sizeof("Ա_3%"), 3}, + {"Ա_4%", sizeof("Ա_4%"), 4}, + + {"IT_צ%", sizeof("IT_צ%"), ITEM_FIST}, + {"IT_ͷ%", sizeof("IT_ͷ%"), ITEM_AXE}, + {"IT_%", sizeof("IT_%"), ITEM_CLUB}, + {"IT_ǹ%", sizeof("IT_ǹ%"), ITEM_SPEAR}, + {"IT_%", sizeof("IT_%"), ITEM_BOW}, + {"IT_SHIELD%", sizeof("IT_SHIELD%"), ITEM_SHIELD}, + {"IT_HELM%", sizeof("IT_HELM%"), ITEM_HELM}, + {"IT_ARMOUR%", sizeof("IT_ARMOUR%"), ITEM_ARMOUR}, + {"IT_ֻ%", sizeof("IT_ֻ%"), ITEM_BRACELET}, + {"IT_%", sizeof("IT_%"), ITEM_MUSIC}, + {"IT_%", sizeof("IT_%"), ITEM_NECKLACE}, + {"IT_%", sizeof("IT_%"), ITEM_RING}, + {"IT_BELT%", sizeof("IT_BELT%"), ITEM_BELT}, + {"IT_%", sizeof("IT_%"), ITEM_EARRING}, + {"IT_ǻ%", sizeof("IT_ǻ%"), ITEM_NOSERING}, + {"IT_%", sizeof("IT_%"), ITEM_AMULET}, + {"IT_%", sizeof("IT_%"), ITEM_OTHER}, + {"IT_%", sizeof("IT_%"), ITEM_BOOMERANG}, + {"IT_Ͷ%", sizeof("IT_Ͷ%"), ITEM_BOUNDTHROW}, + {"IT_Ͷʯ%", sizeof("IT_Ͷʯ%"), ITEM_BREAKTHROW}, + {"IT_DISH%", sizeof("IT_DISH%"), ITEM_DISH}, +#ifdef _ITEM_INSLAY + {"IT_%", sizeof("IT_%"), ITEM_METAL}, + {"IT_%", sizeof("IT_%"), ITEM_JEWEL}, +#endif +#ifdef _ITEM_CHECKWARES + {"IT_%", sizeof("IT_%"), ITEM_WARES}, +#endif +#ifdef _ITEM_EQUITSPACE + {"IT_%", sizeof("IT_%"), ITEM_WBELT}, + {"IT_%", sizeof("IT_%"), ITEM_WSHIELD}, + {"IT_Ь%", sizeof("IT_Ь%"), ITEM_WSHOES}, +#endif +#ifdef _EQUIT_NEWGLOVE + {"IT_%", sizeof("IT_%"), ITEM_WGLOVE}, +#endif +#ifdef _JZ_PETEQU + {"IT_ͷ%", sizeof("IT_ͷ%"), ITEM_PET_HEAD}, + {"IT_%", sizeof("IT_%"), ITEM_PET_WING}, + {"IT_%", sizeof("IT_%"), ITEM_PET_TOOTH}, + {"IT_ؼ%", sizeof("IT_ؼ%"), ITEM_PET_BREAST}, + {"IT_豳%", sizeof("IT_豳%"), ITEM_PET_BACK}, + {"IT_צ%", sizeof("IT_צ%"), ITEM_PET_CLAW}, + {"IT_軤2%", sizeof("IT_軤2%"), ITEM_PET_FEET}, + {"IT_軤4%", sizeof("IT_軤4%"), ITEM_PET_FEET4}, + {"IT_%", sizeof("IT_%"), ITEM_PET_FIN}, +#endif + + {"_û%", sizeof("_û%"), FMMEMBER_NONE}, + {"_һ%", sizeof("_һ%"), FMMEMBER_MEMBER}, + {"_%", sizeof("_%"), FMMEMBER_APPLY}, + {"_峤%", sizeof("_峤%"), FMMEMBER_LEADER}, + {"_%", sizeof("_%"), FMMEMBER_ELDER}, + //{"_˾", sizeof("_˾"), FMMEMBER_INVITE}, + //{"_", sizeof("_"), FMMEMBER_BAILEE}, + //{"_", sizeof("_"), FMMEMBER_VICELEADER}, + + {"ս_%", sizeof("ս_%"), BATTLE_TYPE_NONE}, + {"ս_˹%", sizeof("ս_˹%"), BATTLE_TYPE_P_vs_E}, + {"ս_%", sizeof("ս_%"), BATTLE_TYPE_P_vs_P}, + {"ս_ֹ%", sizeof("ս_ֹ%"), BATTLE_TYPE_E_vs_E}, + {"ս_%", sizeof("ս_%"), BATTLE_TYPE_WATCH}, + {"ս_DP%", sizeof("ս_DP%"), BATTLE_TYPE_DP_BATTLE}, + {"ս_BOSS%", sizeof("ս_BOSS%"), BATTLE_TYPE_BOSS_BATTLE}, + + {"ս_%", sizeof("ս_%"), BATTLE_MODE_NONE}, + {"ս_%", sizeof("ս_%"), BATTLE_MODE_INIT}, + {"ս_%", sizeof("ս_%"), BATTLE_MODE_BATTLE}, + {"ս_%", sizeof("ս_%"), BATTLE_MODE_FINISH}, + {"ս_%", sizeof("ս_%"), BATTLE_MODE_STOP}, + {"ս_۳%", sizeof("ս_۳%"), BATTLE_MODE_WATCHBC}, + {"ս_1%", sizeof("ս_1%"), BATTLE_MODE_WATCHPRE}, + {"ս_2%", sizeof("ս_2%"), BATTLE_MODE_WATCHWAIT}, + {"ս_3%", sizeof("ս_3%"), BATTLE_MODE_WATCHMOVIE}, + {"ս_4%", sizeof("ս_4%"), BATTLE_MODE_WATCHAFTER}, + + {"Ů%", sizeof("Ů%"), CHAR_IMAGETYPE_GIRL}, + {"к%", sizeof("к%"), CHAR_IMAGETYPE_BOY}, + {"ͯ%", sizeof("ͯ%"), CHAR_IMAGETYPE_CHILDBOY}, + {"Ůͯ%", sizeof("Ůͯ%"), CHAR_IMAGETYPE_CHILDGIRL}, + {"%", sizeof("%"), CHAR_IMAGETYPE_MAN}, + {"Ů%", sizeof("Ů%"), CHAR_IMAGETYPE_WOMAN}, + {"%", sizeof("%"), CHAR_IMAGETYPE_OLDMAN}, + {"%", sizeof("%"), CHAR_IMAGETYPE_DOG}, + + {"_%", sizeof("_%"), CHAR_TYPEPLAYER}, + {"_%", sizeof("_%"), CHAR_TYPEENEMY}, + {"_%", sizeof("_%"), CHAR_TYPEPET}, + {"_NPC1%", sizeof("_NPC1%"), CHAR_TYPEDOOR}, + {"_NPC2%", sizeof("_NPC2%"), CHAR_TYPEBOX}, + {"_NPC3%", sizeof("_NPC3%"), CHAR_TYPEMSG}, + {"_NPC4%", sizeof("_NPC4%"), CHAR_TYPEWARP}, + {"_NPC5%", sizeof("_NPC5%"), CHAR_TYPESHOP}, + {"_NPC6%", sizeof("_NPC6%"), CHAR_TYPEHEALER}, + {"_NPC7%", sizeof("_NPC7%"), CHAR_TYPEOLDMAN}, + {"_NPC8%", sizeof("_NPC8%"), CHAR_TYPEROOMADMIN}, + {"_NPC9%", sizeof("_NPC9%"), CHAR_TYPETOWNPEOPLE}, + {"_NPC10%", sizeof("_NPC10%"), CHAR_TYPEDENGON}, + {"_NPC11%", sizeof("_NPC11%"), CHAR_TYPEADM}, + {"_NPC12%", sizeof("_NPC12%"), CHAR_TYPETEMPLE}, + {"_NPC13%", sizeof("_NPC13%"), CHAR_TYPESTORYTELLER}, + {"_NPC14%", sizeof("_NPC14%"), CHAR_TYPERANKING}, + {"_NPC15%", sizeof("_NPC15%"), CHAR_TYPEOTHERNPC}, + {"_NPC16%", sizeof("_NPC16%"), CHAR_TYPEPRINTPASSMAN}, + {"_NPC17%", sizeof("_NPC17%"), CHAR_TYPENPCENEMY}, + {"_NPC18%", sizeof("_NPC18%"), CHAR_TYPEACTION}, + {"_NPC19%", sizeof("_NPC19%"), CHAR_TYPEWINDOWMAN}, + {"_NPC20%", sizeof("_NPC20%"), CHAR_TYPESAVEPOINT}, + {"_NPC21%", sizeof("_NPC21%"), CHAR_TYPEWINDOWHEALER}, + {"_NPC22%", sizeof("_NPC22%"), CHAR_TYPEITEMSHOP}, + {"_NPC23%", sizeof("_NPC23%"), CHAR_TYPESTONESHOP}, + {"_NPC24%", sizeof("_NPC24%"), CHAR_TYPEDUELRANKING}, + {"_NPC25%", sizeof("_NPC25%"), CHAR_TYPEWARPMAN}, + {"_NPC26%", sizeof("_NPC26%"), CHAR_TYPEEVENT}, + {"_NPC27%", sizeof("_NPC27%"), CHAR_TYPEMIC}, + {"_NPC28%", sizeof("_NPC28%"), CHAR_TYPELUCKYMAN}, + {"_NPC29%", sizeof("_NPC29%"), CHAR_TYPEBUS}, + {"_NPC30%", sizeof("_NPC30%"), CHAR_TYPECHARM}, + {"_NPC31%", sizeof("_NPC31%"), CHAR_TYPECHECKMAN}, + {"_NPC32%", sizeof("_NPC32%"), CHAR_TYPEJANKEN}, + {"_NPC33%", sizeof("_NPC33%"), CHAR_TYPETRANSMIGRATION}, + {"_NPC34%", sizeof("_NPC34%"), CHAR_TYPEFMWARPMAN}, + {"_NPC35%", sizeof("_NPC35%"), CHAR_TYPEFMSCHEDULEMAN}, + {"_NPC36%", sizeof("_NPC36%"), CHAR_TYPEMANORSCHEDULEMAN}, +#ifdef _SERVICE + {"_NPC37%", sizeof("_NPC37%"), CHAR_TYPESTONESERVICEMAN}, +#endif +#ifdef _GAMBLE_BANK + {"_NPC38%", sizeof("_NPC38%"), CHAR_GAMBLEBANK}, +#endif +#ifdef _NEW_WARPMAN + {"_NPC39%", sizeof("_NPC39%"), CHAR_NEWNPCMAN}, +#endif +#ifdef _MARKET_TRADE + {"_NPC40%", sizeof("_NPC40%"), CHAR_MAPTRADEMAN}, +#endif +#ifdef _GAMBLE_ROULETTE + {"_NPC41%", sizeof("_NPC41%"), CHAR_GAMBLEROULETTE}, + {"_NPC42%", sizeof("_NPC42%"), CHAR_GAMBLEMASTER}, +#endif +#ifdef _TRANSER_MAN + {"_NPC43%", sizeof("_NPC43%"), CHAR_TRANSERMANS}, +#endif +#ifdef _JZ_NEW_ADDMEMBERPOINT + {"_NPC44%", sizeof("_NPC44%"), CHAR_MEMBERMANS}, +#endif +#ifdef _NPC_SELLSTH + {"_NPC45%", sizeof("_NPC45%"), CHAR_SELLSTHMAN}, +#endif +#ifdef _NPC_MAKEPAIR + {"_NPC46%", sizeof("_NPC46%"), CHAR_MAKEPAIR}, +#endif +#ifdef _NPC_FUSION + {"_NPC47%", sizeof("_NPC47%"), CHAR_PETFUSIONMAN}, +#endif +#ifdef _PAUCTION_MAN + {"_NPC48%", sizeof("_NPC48%"), CHAR_PAUCTIONMAN}, +#endif +#ifdef _ITEM_NPCCHANGE + {"_NPC49%", sizeof("_NPC49%"), CHAR_ITEMCHANGENPC}, +#endif +#ifdef _CFREE_petskill + {"_NPC50%", sizeof("_NPC50%"), CHAR_FREESKILLSHOP}, +#endif +#ifdef _PETRACE + {"_NPC51%", sizeof("_NPC51%"), CHAR_PETRACEMASTER}, + {"_NPC52%", sizeof("_NPC52%"), CHAR_PETRACEPET}, +#endif +#ifdef _AUCTIONEER + {"_NPC53%", sizeof("_NPC53%"), CHAR_TYPEAUCTIONEER}, +#endif +#ifdef _ALLDOMAN // (ɿ) Syu ADD аNPC + {"_NPC54%", sizeof("_NPC54%"), CHAR_TYPEALLDOMAN}, +#endif + {"_NPC55%", sizeof("_NPC55%"), CHAR_TYPEPETMAKER}, +#ifdef _NPC_WELFARE + {"_NPC56%", sizeof("_NPC56%"), CHAR_TYPEWELFARE}, +#endif +#ifdef _NPC_VERYWELFARE + {"_NPC57%", sizeof("_NPC57%"), CHAR_TYPEVERYWELFARE}, +#endif +#ifdef _NPC_WELFARE_2 // WON ADD ְҵNPC-2 + {"_NPC58%", sizeof("_NPC58%"), CHAR_TYPEWELFARE2}, +#endif +#ifdef _RACEMAN + {"_NPC59%", sizeof("_NPC59%"), CHAR_RACEMAN}, +#endif + + {"_û%", sizeof("_û%"), OBJTYPE_NOUSE}, + {"_%", sizeof("_%"), OBJTYPE_CHARA}, + {"_%", sizeof("_%"), OBJTYPE_ITEM}, + {"_%", sizeof("_%"), OBJTYPE_GOLD}, +#ifdef _NPCSERVER_NEW + {"_NPC%", sizeof("_NPC%"), OBJTYPE_NPCSCHARA}, +#endif +#ifdef _MAP_WARPPOINT + {"_%", sizeof("_%"), OBJTYPE_WARPPOINT}, +#endif + + {"ť_û%", sizeof("ť_û%"), WINDOW_BUTTONTYPE_NONE}, + {"ť_ȷ%", sizeof("ť_ȷ%"), WINDOW_BUTTONTYPE_OK}, + {"ť_ر%", sizeof("ť_ر%"), WINDOW_BUTTONTYPE_CANCEL}, + {"ť_%", sizeof("ť_%"), WINDOW_BUTTONTYPE_YES}, + {"ť_%", sizeof("ť_%"), WINDOW_BUTTONTYPE_NO}, + {"ť_һҳ%", sizeof("ť_һҳ%"), WINDOW_BUTTONTYPE_PREV}, + {"ť_һҳ%", sizeof("ť_һҳ%"), WINDOW_BUTTONTYPE_NEXT}, + + {"_û%", sizeof("_û%"), CHAR_PARTY_NONE}, + {"_ӳ%", sizeof("_ӳ%"), CHAR_PARTY_LEADER}, + {"_Ա%", sizeof("_Ա%"), CHAR_PARTY_CLIENT}, + + {"%", sizeof("%"), 0}, + {"%", sizeof("%"), 1}, + {"%", sizeof("%"), 2}, + {"%", sizeof("%"), 3}, + {"%", sizeof("%"), 4}, + {"%", sizeof("%"), 5}, + {"%", sizeof("%"), 6}, + {"%", sizeof("%"), 7}, + + {"ɫ%", sizeof("ɫ%"), CHAR_COLORWHITE}, + {"ɫ%", sizeof("ɫ%"), CHAR_COLORCYAN}, + {"ɫ%", sizeof("ɫ%"), CHAR_COLORPURPLE}, + {"ɫ%", sizeof("ɫ%"), CHAR_COLORBLUE}, + {"ɫ%", sizeof("ɫ%"), CHAR_COLORYELLOW}, + {"ɫ%", sizeof("ɫ%"), CHAR_COLORGREEN}, + {"ɫ%", sizeof("ɫ%"), CHAR_COLORRED}, + {"ɫ%", sizeof("ɫ%"), CHAR_COLORGRAY}, + {"ɫ%", sizeof("ɫ%"), CHAR_COLORBLUE2}, + {"ɫ%", sizeof("ɫ%"), CHAR_COLORGREEN2}, + {"ɫ%", sizeof("ɫ%"), CHAR_COLORBLACK}, + + {"Ӹ_OBJ%", sizeof("Ӹ_OBJ%"), CHAR_N_STRING_OBJINDEX}, + {"Ӹ_LV%", sizeof("Ӹ_LV%"), CHAR_N_STRING_LV}, + {"Ӹ_MAXHP%", sizeof("Ӹ_MAXHP%"), CHAR_N_STRING_MAXHP}, + {"Ӹ_HP%", sizeof("Ӹ_HP%"), CHAR_N_STRING_HP}, + {"Ӹ_MP%", sizeof("Ӹ_MP%"), CHAR_N_STRING_MP}, + {"Ӹ_%", sizeof("Ӹ_%"), CHAR_N_STRING_NAME}, + + {"3_HP%", sizeof("3_HP%"), CHAR_P_STRING_HP}, + {"3_MAXHP%", sizeof("3_MAXHP%"), CHAR_P_STRING_MAXHP}, + {"3_MP%", sizeof("3_MP%"), CHAR_P_STRING_MP}, + {"3_MAXMP%", sizeof("3_MAXMP%"), CHAR_P_STRING_MAXMP}, + {"3_%", sizeof("3_%"), CHAR_P_STRING_VITAL}, + {"3_%", sizeof("3_%"), CHAR_P_STRING_STR}, + {"3_%", sizeof("3_%"), CHAR_P_STRING_TOUGH}, + {"3_%", sizeof("3_%"), CHAR_P_STRING_DEX}, + {"3_%", sizeof("3_%"), CHAR_P_STRING_EXP}, + {"3_һ%", sizeof("3_һ%"), CHAR_P_STRING_NEXTEXP}, + {"3_ȼ%", sizeof("3_ȼ%"), CHAR_P_STRING_LV}, + {"3_%", sizeof("3_%"), CHAR_P_STRING_ATK}, + {"3_%", sizeof("3_%"), CHAR_P_STRING_DEF}, + {"3_%", sizeof("3_%"), CHAR_P_STRING_QUICK}, + {"3_%", sizeof("3_%"), CHAR_P_STRING_CHARM}, + {"3_%", sizeof("3_%"), CHAR_P_STRING_LUCK}, + {"3_%", sizeof("3_%"), CHAR_P_STRING_EARTH}, + {"3_ˮ%", sizeof("3_ˮ%"), CHAR_P_STRING_WATER}, + {"3_%", sizeof("3_%"), CHAR_P_STRING_FIRE}, + {"3_%", sizeof("3_%"), CHAR_P_STRING_WIND}, + {"3_ʯ%", sizeof("3_ʯ%"), CHAR_P_STRING_GOLD}, + {"3_ƺ%", sizeof("3_ƺ%"), CHAR_P_STRING_TITLE}, + {"3_DP%", sizeof("3_DP%"), CHAR_P_STRING_DUELPOINT}, + {"3_ת%", sizeof("3_ת%"), CHAR_P_STRING_TRANSMIGRATION}, + {"3_%", sizeof("3_%"), CHAR_P_STRING_NAME}, + {"3_dz%", sizeof("3_dz%"), CHAR_P_STRING_OWNTITLE}, + {"3_%", sizeof("3_%"), CHAR_P_STRING_RIDEPET}, + {"3_ѧȼ%", sizeof("3_ѧȼ%"), CHAR_P_STRING_LEARNRIDE}, + {"3_%", sizeof("3_%"), CHAR_P_STRING_BASEBASEIMAGENUMBER}, + {"3_ģʽ%", sizeof("3_ģʽ%"), CHAR_P_STRING_SKYWALKER}, + {"3_ģʽ%", sizeof("3_ģʽ%"), CHAR_P_STRING_DEBUGMODE}, + + {NULL, 0, 0}, +}; + diff --git a/des.c b/des.c new file mode 100644 index 0000000..c8eeece --- /dev/null +++ b/des.c @@ -0,0 +1,244 @@ +////////////////////////////////////////////////////////////////////////// +/* + Provided by , Northeastern University (www.neu.edu.cn) + Email: blackdrn@sohu.com + This product is free for use. +*/ +////////////////////////////////////////////////////////////////////////// + +#include +#include "des.h" + +////////////////////////////////////////////////////////////////////////// + +// initial permutation IP +const static char IP_Table[64] = { + 58, 50, 42, 34, 26, 18, 10, 2, 60, 52, 44, 36, 28, 20, 12, 4, + 62, 54, 46, 38, 30, 22, 14, 6, 64, 56, 48, 40, 32, 24, 16, 8, + 57, 49, 41, 33, 25, 17, 9, 1, 59, 51, 43, 35, 27, 19, 11, 3, + 61, 53, 45, 37, 29, 21, 13, 5, 63, 55, 47, 39, 31, 23, 15, 7 +}; +// final permutation IP^-1 +const static char IPR_Table[64] = { + 40, 8, 48, 16, 56, 24, 64, 32, 39, 7, 47, 15, 55, 23, 63, 31, + 38, 6, 46, 14, 54, 22, 62, 30, 37, 5, 45, 13, 53, 21, 61, 29, + 36, 4, 44, 12, 52, 20, 60, 28, 35, 3, 43, 11, 51, 19, 59, 27, + 34, 2, 42, 10, 50, 18, 58, 26, 33, 1, 41, 9, 49, 17, 57, 25 +}; +// expansion operation matrix +static const char E_Table[48] = { + 32, 1, 2, 3, 4, 5, 4, 5, 6, 7, 8, 9, + 8, 9, 10, 11, 12, 13, 12, 13, 14, 15, 16, 17, + 16, 17, 18, 19, 20, 21, 20, 21, 22, 23, 24, 25, + 24, 25, 26, 27, 28, 29, 28, 29, 30, 31, 32, 1 +}; +// 32-bit permutation function P used on the output of the S-boxes +const static char P_Table[32] = { + 16, 7, 20, 21, 29, 12, 28, 17, 1, 15, 23, 26, 5, 18, 31, 10, + 2, 8, 24, 14, 32, 27, 3, 9, 19, 13, 30, 6, 22, 11, 4, 25 +}; +// permuted choice table (key) +const static char PC1_Table[56] = { + 57, 49, 41, 33, 25, 17, 9, 1, 58, 50, 42, 34, 26, 18, + 10, 2, 59, 51, 43, 35, 27, 19, 11, 3, 60, 52, 44, 36, + 63, 55, 47, 39, 31, 23, 15, 7, 62, 54, 46, 38, 30, 22, + 14, 6, 61, 53, 45, 37, 29, 21, 13, 5, 28, 20, 12, 4 +}; +// permuted choice key (table) +const static char PC2_Table[48] = { + 14, 17, 11, 24, 1, 5, 3, 28, 15, 6, 21, 10, + 23, 19, 12, 4, 26, 8, 16, 7, 27, 20, 13, 2, + 41, 52, 31, 37, 47, 55, 30, 40, 51, 45, 33, 48, + 44, 49, 39, 56, 34, 53, 46, 42, 50, 36, 29, 32 +}; +// number left rotations of pc1 +const static char LOOP_Table[16] = { + 1,1,2,2,2,2,2,2,1,2,2,2,2,2,2,1 +}; +// The (in)famous S-boxes +const static char S_Box[8][4][16] = { + // S1 + 14, 4, 13, 1, 2, 15, 11, 8, 3, 10, 6, 12, 5, 9, 0, 7, + 0, 15, 7, 4, 14, 2, 13, 1, 10, 6, 12, 11, 9, 5, 3, 8, + 4, 1, 14, 8, 13, 6, 2, 11, 15, 12, 9, 7, 3, 10, 5, 0, + 15, 12, 8, 2, 4, 9, 1, 7, 5, 11, 3, 14, 10, 0, 6, 13, + // S2 + 15, 1, 8, 14, 6, 11, 3, 4, 9, 7, 2, 13, 12, 0, 5, 10, + 3, 13, 4, 7, 15, 2, 8, 14, 12, 0, 1, 10, 6, 9, 11, 5, + 0, 14, 7, 11, 10, 4, 13, 1, 5, 8, 12, 6, 9, 3, 2, 15, + 13, 8, 10, 1, 3, 15, 4, 2, 11, 6, 7, 12, 0, 5, 14, 9, + // S3 + 10, 0, 9, 14, 6, 3, 15, 5, 1, 13, 12, 7, 11, 4, 2, 8, + 13, 7, 0, 9, 3, 4, 6, 10, 2, 8, 5, 14, 12, 11, 15, 1, + 13, 6, 4, 9, 8, 15, 3, 0, 11, 1, 2, 12, 5, 10, 14, 7, + 1, 10, 13, 0, 6, 9, 8, 7, 4, 15, 14, 3, 11, 5, 2, 12, + // S4 + 7, 13, 14, 3, 0, 6, 9, 10, 1, 2, 8, 5, 11, 12, 4, 15, + 13, 8, 11, 5, 6, 15, 0, 3, 4, 7, 2, 12, 1, 10, 14, 9, + 10, 6, 9, 0, 12, 11, 7, 13, 15, 1, 3, 14, 5, 2, 8, 4, + 3, 15, 0, 6, 10, 1, 13, 8, 9, 4, 5, 11, 12, 7, 2, 14, + // S5 + 2, 12, 4, 1, 7, 10, 11, 6, 8, 5, 3, 15, 13, 0, 14, 9, + 14, 11, 2, 12, 4, 7, 13, 1, 5, 0, 15, 10, 3, 9, 8, 6, + 4, 2, 1, 11, 10, 13, 7, 8, 15, 9, 12, 5, 6, 3, 0, 14, + 11, 8, 12, 7, 1, 14, 2, 13, 6, 15, 0, 9, 10, 4, 5, 3, + // S6 + 12, 1, 10, 15, 9, 2, 6, 8, 0, 13, 3, 4, 14, 7, 5, 11, + 10, 15, 4, 2, 7, 12, 9, 5, 6, 1, 13, 14, 0, 11, 3, 8, + 9, 14, 15, 5, 2, 8, 12, 3, 7, 0, 4, 10, 1, 13, 11, 6, + 4, 3, 2, 12, 9, 5, 15, 10, 11, 14, 1, 7, 6, 0, 8, 13, + // S7 + 4, 11, 2, 14, 15, 0, 8, 13, 3, 12, 9, 7, 5, 10, 6, 1, + 13, 0, 11, 7, 4, 9, 1, 10, 14, 3, 5, 12, 2, 15, 8, 6, + 1, 4, 11, 13, 12, 3, 7, 14, 10, 15, 6, 8, 0, 5, 9, 2, + 6, 11, 13, 8, 1, 4, 10, 7, 9, 5, 0, 15, 14, 2, 3, 12, + // S8 + 13, 2, 8, 4, 6, 15, 11, 1, 10, 9, 3, 14, 5, 0, 12, 7, + 1, 15, 13, 8, 10, 3, 7, 4, 12, 5, 6, 11, 0, 14, 9, 2, + 7, 11, 4, 1, 9, 12, 14, 2, 0, 6, 10, 13, 15, 3, 5, 8, + 2, 1, 14, 7, 4, 10, 8, 13, 15, 12, 9, 0, 3, 5, 6, 11 +}; + +////////////////////////////////////////////////////////////////////////// + +typedef bool (*PSubKey)[16][48]; + +////////////////////////////////////////////////////////////////////////// + +static void DES(char Out[8], char In[8], const PSubKey pSubKey, bool Type);//׼DES/ +static void SetKey(const char* Key, int len);// Կ +static void SetSubKey(PSubKey pSubKey, const char Key[8]);// Կ +static void F_func(bool In[32], const bool Ki[48]);// f +static void S_func(bool Out[32], const bool In[48]);// S д +static void Transform(bool *Out, bool *In, const char *Table, int len);// 任 +static void Xor(bool *InA, const bool *InB, int len);// +static void RotateL(bool *In, int len, int loop);// ѭ +static void ByteToBit(bool *Out, const char *In, int bits);// ֽתλ +static void BitToByte(char *Out, const bool *In, int bits);// λתֽ + +////////////////////////////////////////////////////////////////////////// + +static bool SubKey[2][16][48];// 16ȦԿ +static bool Is3DES;// 3DES־ +static char Tmp[256], deskey[16]; + +////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////// +// Code starts from Line 130 +////////////////////////////////////////////////////////////////////////// +bool Des_Go(char *Out, char *In, long datalen, const char *Key, int keylen, bool Type) +{ + if( !( Out && In && Key && (datalen=(datalen+7)&0xfffffff8) ) ) + return false; + SetKey(Key, keylen); + if( !Is3DES ) { // 1DES + long i,j; + for(i=0,j=datalen>>3; i>3; i16?16:len); + SetSubKey(&SubKey[0], &deskey[0]); + Is3DES = len>8 ? (SetSubKey(&SubKey[1], &deskey[8]), true) : false; +} +void DES(char Out[8], char In[8], const PSubKey pSubKey, bool Type) +{ + static bool M[64], tmp[32], *Li=&M[0], *Ri=&M[32]; + ByteToBit(M, In, 64); + Transform(M, M, IP_Table, 64); + if( Type == ENCRYPT ){ + int i; + for(i=0; i<16; ++i) { + memcpy(tmp, Ri, 32); + F_func(Ri, (*pSubKey)[i]); + Xor(Ri, Li, 32); + memcpy(Li, tmp, 32); + } + }else{ + int i; + for(i=15; i>=0; --i) { + memcpy(tmp, Li, 32); + F_func(Li, (*pSubKey)[i]); + Xor(Li, Ri, 32); + memcpy(Ri, tmp, 32); + } + } + Transform(M, M, IPR_Table, 64); + BitToByte(Out, M, 64); +} +void SetSubKey(PSubKey pSubKey, const char Key[8]) +{ + static bool K[64], *KL=&K[0], *KR=&K[28]; + ByteToBit(K, Key, 64); + Transform(K, K, PC1_Table, 56); + int i; + for(i=0; i<16; ++i) { + RotateL(KL, 28, LOOP_Table[i]); + RotateL(KR, 28, LOOP_Table[i]); + Transform((*pSubKey)[i], K, PC2_Table, 48); + } +} +void F_func(bool In[32], const bool Ki[48]) +{ + static bool MR[48]; + Transform(MR, In, E_Table, 48); + Xor(MR, Ki, 48); + S_func(In, MR); + Transform(In, In, P_Table, 32); +} +void S_func(bool Out[32], const bool In[48]) +{ + char i,j,k; + for(i=0; i<8; ++i,In+=6,Out+=4) { + j = (In[0]<<1) + In[5]; + k = (In[1]<<3) + (In[2]<<2) + (In[3]<<1) + In[4]; + ByteToBit(Out, &S_Box[i][j][k], 4); + } +} +void Transform(bool *Out, bool *In, const char *Table, int len) +{ + int i; + for(i=0; i>3]>>(i&7)) & 1; +} +void BitToByte(char *Out, const bool *In, int bits) +{ + memset(Out, 0, bits>>3); + int i; + for(i=0; i>3] |= In[i]<<(i&7); +} +////////////////////////////////////////////////////////////////////////// +// Code ends at Line 231 +////////////////////////////////////////////////////////////////////////// diff --git a/function.c b/function.c new file mode 100644 index 0000000..cff1fdc --- /dev/null +++ b/function.c @@ -0,0 +1,924 @@ +#include "version.h" +#include +#include "common.h" +#include "util.h" +#include "char_event.h" +#include "char.h" +#include "item_event.h" +#include "magic.h" +#include "pet_event.h" +#include "npc_townpeople.h" +#include "npc_Dengon.h" +#include "npc_door.h" +#include "npc_healer.h" +#include "npc_oldman.h" +#include "npc_warp.h" +#include "npc_storyteller.h" +#include "npc_msg.h" +#include "npc_npcenemy.h" +#include "npc_action.h" +#include "npc_windowman.h" +#include "npc_savepoint.h" +#include "npc_windowhealer.h" +#include "npc_itemshop.h" +#ifdef _VIGOR_SYS +#include "npc_vigorshop.h" +#endif +#include "npc_sysinfo.h" +#include "npc_duelranking.h" +#include "npc_petskillshop.h" +#ifdef _PETSKILL_DEL_SHOP +#include "npc_petskilldelshop.h" +#endif +#include "npc_petshop.h" +#include "npc_signboard.h" +#include "npc_warpman.h" +#include "npc_exchangeman.h" +#include "petmail.h" +#include "npc_timeman.h" +#include "npc_bodylan.h" +#include "npc_mic.h" +#include "npc_luckyman.h" +#include "npc_bus.h" +#include "npc_charm.h" +#include "npc_poolitemshop.h" +#include "npc_quiz.h" +#include "npc_checkman.h" +#include "npc_janken.h" +#include "npc_transmigration.h" +#include "battle_event.h" +#include "enemy.h" +// Robin 0517 +#include "npc_familyman.h" +#include "npc_bankman.h" +// add code by shan +#include "npc_fmdengon.h" +#include "npc_fmhealer.h" +#include "npc_petmaker.h" +#ifdef _FMRANK_POINT +#include "npc_fmrank.h" +#endif +// CoolFish: Family 2001/6/4 +#include "npc_fmwarpman.h" +#include "npc_fmpkman.h" +#include "npc_fmpkcallman.h" + +// Arminius 7.7 Airplane +#include "npc_airplane.h" + +// Arminius 7.13 Scheduleman +#include "npc_scheduleman.h" + +// Arminius 7.24 manor scheduleman +#include "npc_manorsman.h" + +// Robin 0725 +#include "npc_riderman.h" +#include "npc_fmletter.h" + +#ifdef _GAMBLE_BANK +#include "npc_gamblebank.h" +#endif +#ifdef _NEW_WARPMAN +#include "npc_newnpcman.h" +#endif + +#ifdef _GAMBLE_ROULETTE +#include "npc_gambleroulette.h" +#include "npc_gamblemaster.h" +#endif + +#ifdef _TRANSER_MAN +#include "npc_transerman.h" +#endif + +#ifdef _VIP_SHOP +#include "npc_vipshop.h" +//#include "npc_vippoint.h" +#include "npc_newvipshop.h" +#endif +#ifdef _RMB_SYSTEM +#include "npc_rmbshop.h" +#endif +#ifdef _STU_SYS +#include "npc_stushop.h" +#endif +#ifdef _NPC_ITEMUP +#include "npc_itemup.h" +#endif +#ifdef _AUTO_PK +#include "npc_autopk.h" +#endif +#ifdef _CFREE_petskill +#include "npc_freepetskillshop.h" +#endif + +#ifdef _PETRACE +#include "npc_petracemaster.h" +#include "npc_petracepet.h" +#endif + +#ifdef _ITEM_NPCCHANGE +#include "npc_itemchange.h" +#endif + +#ifdef _NPC_MAKEPAIR +#include "npc_makepair.h" +#endif + +#ifdef _NPC_FUSION +#include "npc_petfusion.h" +#endif + +#ifdef _ALLDOMAN // (ɿ) Syu ADD аNPC +#include "npc_alldoman.h" +#endif + +#ifdef _NPC_WELFARE +#include "npc_welfare.h" +#endif +#ifdef _JZ_NEWSCRIPT_LUA +#include "npc_lua_interface.h" +#endif +#ifdef _FM_NPC_LOOK_WAR +#include "npc_fmlookwar.h" +#endif +#ifdef _FM_NPC_LOOK_WAR1 +#include "npc_fmlookwar1.h" +#endif +//#define DEBUG +#include "npc_itemvippointshop.h" +typedef struct tagCorrespondStringAndFunctionTable +{ + STRING32 functionName; + void* functionPointer; + int hashcode; +}CorrespondStringAndFunctionTable; + +static CorrespondStringAndFunctionTable +correspondStringAndFunctionTable[]= +{ + { {"core_PreWalk"}, CHAR_allprewalk, 0 }, + { {"core_PostWalk"}, CHAR_allpostwalk, 0 }, + { {"core_Loop"}, CHAR_loopFunc, 0 }, + { {"core_Dying"}, CHAR_die, 0 }, + { {"core_PlayerWatch"}, CHAR_playerWatchfunc, 0 }, + { {"core_PlayerTalked"}, CHAR_playerTalkedfunc, 0 }, + + + { {"MedicineInit"}, ITEM_MedicineInit, 0 }, + { {"MedicineUsed"}, ITEM_MedicineUsed, 0 }, + { {"SandClockDetach"}, ITEM_SandClockDetach, 0 }, + { {"addTitleAttach"}, ITEM_addTitleAttach, 0 }, + { {"delTitleDetach"}, ITEM_delTitleDetach, 0 }, + { {"ITEM_DeleteByWatched"}, ITEM_DeleteByWatched, 0 }, + { {"ITEM_DeleteTimeWatched"}, ITEM_DeleteTimeWatched, 0 }, + { {"ITEM_useEffectTohelos"}, ITEM_useEffectTohelos, 0 }, + +// { {"ITEM_useHpRecovery"}, ITEM_useHpRecovery, 0 }, + { {"ITEM_useRecovery"}, ITEM_useRecovery, 0 }, +#ifdef _ITEM_MAGICRECOVERY + { {"ITEM_useMRecovery"}, ITEM_useMRecovery, 0 }, +#endif +#ifdef _ITEM_USEMAGIC + { {"ITEM_useMagic"}, ITEM_useMagic, 0 }, +#endif + { {"ITEM_useStatusChange"}, ITEM_useStatusChange, 0 }, + { {"ITEM_useStatusRecovery"}, ITEM_useStatusRecovery, 0 }, + { {"ITEM_useMagicDef"}, ITEM_useMagicDef, 0 }, + { {"ITEM_useParamChange"}, ITEM_useParamChange, 0 }, + { {"ITEM_useFieldChange"}, ITEM_useFieldChange, 0 }, + { {"ITEM_useAttReverse"}, ITEM_useAttReverse, 0 }, + { {"ITEM_useRessurect"}, ITEM_useRessurect, 0 }, + { {"ITEM_useMic"}, ITEM_useMic, 0 }, + { {"ITEM_dropMic"}, ITEM_dropMic, 0 }, + { {"ITEM_useCaptureUp"}, ITEM_useCaptureUp, 0 }, + { {"ITEM_useRenameItem"}, ITEM_useRenameItem, 0 }, + { {"ITEM_pickupDice"}, ITEM_pickupDice, 0 }, + { {"ITEM_dropDice"}, ITEM_dropDice, 0 }, + { {"ITEM_initLottery"}, ITEM_initLottery, 0 }, + { {"ITEM_useLottery"}, ITEM_useLottery, 0 }, + { {"ITEM_useWarp"}, ITEM_useWarp, 0 }, + { {"ITEM_petFollow"}, ITEM_petFollow, 0 }, + { {"ITEM_useSkup"}, ITEM_useSkup, 0 }, // Nuke 0624: Hero's bless + { {"ITEM_useNoenemy"}, ITEM_useNoenemy, 0 }, // Nuke 0626: Dragon's help + { {"ITEM_equipNoenemy"},ITEM_equipNoenemy, 0 }, // Arminius 7.2 Ra's amulet + { {"ITEM_remNoenemy"}, ITEM_remNoenemy, 0 }, // Arminius 7.2 Ra's amulet + { {"ITEM_useEncounter"}, ITEM_useEncounter, 0}, // Arminius 7.31 cursed stone + + { {"ITEM_AddPRSkillPoint"}, ITEM_AddPRSkillPoint, 0}, + { {"ITEM_AddPRSkillPercent"}, ITEM_AddPRSkillPercent, 0}, + +#ifdef _ITEM_METAMO + { {"ITEM_metamo"}, ITEM_metamo, 0 }, + { {"ITEM_ColorMetamo"}, ITEM_ColorMetamo, 0 }, + { {"ITEM_CharaMetamo"}, ITEM_CharaMetamo, 0 }, + { {"ITEM_SexMetamo"}, ITEM_SexMetamo, 0 }, +#endif + +#ifdef _USEWARP_FORNUM + { {"ITEM_useWarpForNum"}, ITEM_useWarpForNum, 0 }, +#endif + +#ifdef _IMPRECATE_ITEM + { {"ITEM_useImprecate"}, ITEM_useImprecate, 0 }, +#endif +#ifdef _ITEM_FIRECRACKER //Terry add 2001/12/21 + { {"ITEM_firecracker"}, ITEM_firecracker, 0 }, +#endif +#ifdef _ITEM_CRACKER //vincent + { {"ITEM_Cracker"}, ITEM_Cracker, 0 }, +#endif +#ifdef _ITEM_ADDEXP //vincent + { {"ITEM_Addexp"}, ITEM_Addexp, 0 }, +#endif +#ifdef _ITEM_REFRESH //vincent 쳣״̬ + { {"ITEM_Refresh"}, ITEM_Refresh, 0 }, +#endif + + { {"ITEM_WearEquip"}, ITEM_WearEquip, 0 }, + { {"ITEM_ReWearEquip"}, ITEM_ReWearEquip, 0 }, + +#ifdef _ITEM_CONSTITUTION + { {"ITEM_Constitution"}, ITEM_Constitution, 0 }, +#endif + +#ifdef _Item_ReLifeAct + { {"ITEM_DIErelife"}, ITEM_DIErelife, 0 }, +#endif + +#ifdef _ITEM_ORNAMENTS + { {"ITEM_PutOrnaments"}, ITEM_PutOrnaments, 0}, +#endif +#ifdef _CHIKULA_STONE + { {"ITEM_ChikulaStone"}, ITEM_ChikulaStone, 0}, +#endif + +#ifdef _THROWITEM_ITEMS + { {"ITEM_ThrowItemBox"}, ITEM_ThrowItemBox, 0}, +#endif + +#ifdef _ITEM_WATERWORDSTATUS + { {"ITEM_WaterWordStatus"}, ITEM_WaterWordStatus, 0}, +#endif + +#ifdef _ITEM_LOVERPARTY + { {"ITEM_LoverSelectUser"}, ITEM_LoverSelectUser, 0}, +#endif + +#ifdef _Item_MoonAct + { {"ITEM_randEnemyEquipOne"}, ITEM_randEnemyEquipOne, 0 }, + + { {"ITEM_randEnemyEquip"}, ITEM_randEnemyEquip, 0 }, + { {"ITEM_RerandEnemyEquip"}, ITEM_RerandEnemyEquip, 0}, +#endif + +#ifdef _SUIT_ITEM + { {"ITEM_suitEquip"}, ITEM_suitEquip, 0 }, + { {"ITEM_ResuitEquip"}, ITEM_ResuitEquip, 0 }, +#endif + +#ifdef _Item_DeathAct + { {"ITEM_useDeathcounter"}, ITEM_UseDeathCounter, 0 }, +#endif +#ifdef _FEV_ADD_NEW_ITEM // FEV ADD Ӹؾ + { {"ITEM_ResAndDef"} , ITEM_ResAndDef, 0 }, +#endif + +#ifdef _CHRISTMAS_REDSOCKS + { {"ITEM_useMaxRedSocks"}, ITEM_useMaxRedSocks, 0 }, +#endif + +#ifdef _CHRISTMAS_REDSOCKS_NEW + { {"ITEM_useMaxRedSocksNew"}, ITEM_useMaxRedSocksNew, 0 }, +#endif + +#ifdef _PETSKILL_CANNEDFOOD + { {"ITEM_useSkillCanned"}, ITEM_useSkillCanned, 0}, +#endif + +#ifdef _NEW_RIDEPETS + { {"ITEM_useLearnRideCode"}, ITEM_useLearnRideCode, 0 }, +#endif + +#ifdef _EQUIT_DEFMAGIC + { {"ITEM_MagicEquitWear"}, ITEM_MagicEquitWear, 0 }, + { {"ITEM_MagicEquitReWear"}, ITEM_MagicEquitReWear, 0 }, +#endif +#ifdef _EQUIT_RESIST + { {"ITEM_MagicResist"}, ITEM_MagicResist, 0 }, + { {"ITEM_MagicReResist"}, ITEM_MagicReResist, 0 }, +#endif + +#ifdef _MAGIC_RESIST_EQUIT // WON ADD ְҵװ + { {"ITEM_P_MagicEquitWear"}, ITEM_P_MagicEquitWear, 0 }, + { {"ITEM_P_MagicEquitReWear"}, ITEM_P_MagicEquitReWear, 0 }, +#endif + +#ifdef _ANGEL_SUMMON + { {"ITEM_AngelToken"}, ITEM_AngelToken, 0 }, + { {"ITEM_HeroToken"}, ITEM_HeroToken, 0 }, +#endif +#ifdef _HALLOWEEN_EFFECT + { {"ITEM_MapEffect"}, ITEM_MapEffect, 0 }, +#endif + + { {"ITEM_changePetOwner"}, ITEM_changePetOwner, 0 }, + + { {"ITEM_useDelRenameItem"}, ITEM_useDelRenameItem, 0 }, + + { {"ITEM_DANMM"}, ITEM_DANMM, 0 }, + + { {"core_PetWatch"}, PET_Watchfunc, 0 }, + { {"PETMAIL_Loop"}, PETMAIL_Loopfunc, 0 }, +#ifdef _USER_CHARLOOPS + { {"CHAR_BattleStayLoop"}, CHAR_BattleStayLoop, 0 }, + { {"PET_CheckIncubateLoop"}, PET_CheckIncubate, 0 }, +#endif + +#ifdef _PETSKILL_PROPERTY + { {"PET_PetskillPropertyEvent"}, PET_PetskillPropertyEvent, 0 }, +#endif + { {"core_PetTalk"}, PET_Talkfunc, 0}, // Arminius 8.14 pet talk + + + /* warp */ + { {"WarpInit"}, NPC_WarpInit, 0 }, + { {"WarpPostOver"}, NPC_WarpPostOver, 0 }, + { {"WarpWatch"}, NPC_WarpWatch, 0 }, + + /* Dengon */ + { {"DengonInit"}, NPC_DengonInit, 0 }, + { {"DengonWindowTalked"}, NPC_DengonWindowTalked, 0 }, + { {"DengonLooked"}, NPC_DengonLooked, 0 }, + + /* FmDengon add code by shan */ + { {"FmDengonInit"}, NPC_FmDengonInit, 0 }, + { {"FmDengonWindowTalked"}, NPC_FmDengonWindowTalked, 0 }, + { {"FmDengonLooked"}, NPC_FmDengonLooked, 0 }, + + /* Healer */ + { {"HealerInit"} , NPC_HealerInit, 0 }, + { {"HealerTalked"} , NPC_HealerTalked , 0 }, + + /* FMHealer add code by shan */ + { {"FmHealerInit"} , NPC_FmHealerInit, 0 }, + { {"FmHealerTalked"} , NPC_FmHealerTalked , 0 }, + + /* petmaker add code by shan */ + { {"PetMakerInit"} , NPC_PetMakerInit, 0 }, + { {"PetMakerTalked"} , NPC_PetMakerTalked , 0 }, + + /* TownPeople */ + { {"TownPeopleTalked"}, NPC_TownPeopleTalked, 0 }, + { {"TownPeopleInit"}, NPC_TownPeopleInit, 0 }, + + /* TownPeople */ + { {"MsgLooked"}, NPC_MsgLooked , 0 }, + { {"MsgInit"}, NPC_MsgInit, 0 }, + + /* Oldman */ + { {"OldmanInit"} , NPC_OldmanInit , 0 }, + { {"OldmanTalked"} , NPC_OldmanTalked , 0 }, + + /* SavePOint */ + { {"SavePointInit"} , NPC_SavePointInit , 0 }, + { {"SavePointTalked"} , NPC_SavePointTalked , 0 }, + { {"SavePointWindowTalked"}, NPC_SavePointWindowTalked, 0 }, + + /* StoryTeller */ + { {"StoryTellerInit"} , NPC_StoryTellerInit , 0 }, + { {"StoryTellerTalked"} , NPC_StoryTellerTalked , 0 }, + + /* NPCEnemy */ + { {"NPCEnemyInit"} , NPC_NPCEnemyInit , 0 }, + { {"NPCEnemyTalked"} , NPC_NPCEnemyTalked , 0 }, + { {"NPCEnemyWatch"} , NPC_NPCEnemyWatch , 0 }, + { {"NPCEnemyLoop"}, NPC_NPCEnemyLoop, 0 }, + { {"NPCEnemyWindowTalked"}, NPC_NPCEnemyWindowTalked, 0 }, + + /* ʧ */ + { {"ActionInit"} , NPC_ActionInit , 0 }, + { {"ActionTalked"} , NPC_ActionTalked , 0 }, + { {"ActionWatch"} , NPC_ActionWatch , 0 }, + + /* ū */ + { {"WindowmanInit"} , NPC_WindowmanInit , 0 }, + { {"WindowmanTalked"} , NPC_WindowmanTalked , 0 }, + { {"WindowmanLooked"}, NPC_WindowmanLooked, 0 }, + { {"WindowmanWindowTalked"}, NPC_WindowmanWindowTalked, 0 }, + + /* ūס¡ */ + { {"WindowHealerInit"} , NPC_WindowHealerInit , 0 }, + { {"WindowHealerTalked"} , NPC_WindowHealerTalked, 0 }, + { {"WindowHealerLooked"} , NPC_WindowHealerLooked, 0 }, + { {"WindowHealerWindowTalked"}, NPC_WindowHealerWindowTalked, 0 }, + + { {"ItemShopInit"} , NPC_ItemShopInit , 0 }, + { {"ItemShopTalked"} , NPC_ItemShopTalked , 0 }, + { {"ItemShopWindowTalked"}, NPC_ItemShopWindowTalked, 0 }, + + { {"ItemVippointShopInit"} , NPC_ItemVippointShopInit , 0 }, + { {"ItemVippointShopTalked"} , NPC_ItemVippointShopTalked , 0 }, + { {"ItemVippointShopWindowTalked"}, NPC_ItemVippointShopWindowTalked, 0 }, + + /* Sysinfo */ + { {"SysinfoInit"}, NPC_SysinfoInit, 0 }, + { {"SysinfoLoop"}, NPC_SysinfoLoop, 0 }, + { {"SysinfoTalked"} , NPC_SysinfoTalked , 0 }, + + { {"DuelrankingInit"} , NPC_DuelrankingInit , 0 }, + { {"DuelrankingLooked"}, NPC_DuelrankingLooked, 0 }, + { {"DuelrankingWindowTalked"}, NPC_DuelrankingWindowTalked, 0 }, + + { {"PetSkillShopInit"} , NPC_PetSkillShopInit , 0 }, + { {"PetSkillShopTalked"} , NPC_PetSkillShopTalked, 0 }, + { {"PetSkillShopLooked"} , NPC_PetSkillShopLooked, 0 }, + { {"PetSkillShopWindowTalked"}, NPC_PetSkillShopWindowTalked, 0 }, +#ifdef _PETSKILL_DEL_SHOP + { {"PetSkillDelShopInit"} , NPC_PetSkillDelShopInit , 0 }, + { {"PetSkillDelShopTalked"} , NPC_PetSkillDelShopTalked, 0 }, + { {"PetSkillDelShopLooked"} , NPC_PetSkillDelShopLooked, 0 }, + { {"PetSkillDelShopWindowTalked"}, NPC_PetSkillDelShopWindowTalked, 0 }, +#endif + { {"PetShopInit"} , NPC_PetShopInit, 0 }, + { {"PetShopTalked"} , NPC_PetShopTalked, 0 }, + { {"PetShopLooked"} , NPC_PetShopLooked, 0 }, + { {"PetShopWindowTalked"}, NPC_PetShopWindowTalked,0 }, + + { {"SignBoardInit"} , NPC_SignBoardInit, 0 }, + { {"SignBoardLooked"} , NPC_SignBoardLooked, 0 }, + { {"SignBoardWindowTalked"}, NPC_SignBoardWindowTalked, 0 }, + + /*Ѩ */ + { {"WarpManInit"}, NPC_WarpManInit, 0 }, + { {"WarpManTalked"}, NPC_WarpManTalked, 0 }, + { {"WarpManWatch"}, NPC_WarpManWatch, 0 }, + { {"WarpManLoop"} , NPC_WarpManLoop, 0 }, + { {"WarpManWindowTalked"}, NPC_WarpManWindowTalked,0 }, + + + { {"ExChangeManInit"}, NPC_ExChangeManInit, 0 }, + { {"ExChangeManTalked"}, NPC_ExChangeManTalked, 0 }, + { {"ExChangeManWindowTalked"}, NPC_ExChangeManWindowTalked,0 }, + + /*ةѨ */ + { {"TimeManInit"}, NPC_TimeManInit, 0 }, + { {"TimeManTalked"}, NPC_TimeManTalked, 0 }, + { {"TimeManWatch"} , NPC_TimeManWatch , 0 }, + + /* ʾū¼ء */ + { {"BodyLanInit"}, NPC_BodyLanInit, 0 }, + { {"BodyLanTalked"}, NPC_BodyLanTalked, 0 }, + { {"BodyLanWatch"} , NPC_BodyLanWatch , 0 }, + { {"BodyLanWindowTalked"} , NPC_BodyLanWindowTalked,0 }, + + /* Ѩ */ + { {"MicInit"}, NPC_MicInit, 0 }, + { {"MicTalked"}, NPC_MicTalked, 0 }, + + /* ƽѨ */ + { {"LuckyManInit"} , NPC_LuckyManInit , 0 }, + { {"LuckyManTalked"} , NPC_LuckyManTalked, 0 }, + { {"LuckyManWindowTalked"}, NPC_LuckyManWindowTalked, 0 }, + + /* */ + { {"BusInit"} , NPC_BusInit , 0 }, + { {"BusTalked"} , NPC_BusTalked , 0 }, + { {"BusLoop"} , NPC_BusLoop , 0 }, + + /* */ // Arminius 7.7 Airplane + { {"AirInit"} , NPC_AirInit , 0 }, + { {"AirTalked"} , NPC_AirTalked , 0 }, + { {"AirLoop"} , NPC_AirLoop , 0 }, + + { {"CharmInit"} , NPC_CharmInit , 0 }, + { {"CharmTalked"} , NPC_CharmTalked, 0 }, + { {"CharmWindowTalked"}, NPC_CharmWindowTalked, 0 }, + + { {"PoolItemShopInit"} , NPC_PoolItemShopInit , 0 }, + { {"PoolItemShopLoop"} , NPC_PoolItemShopLoop , 0 }, + { {"PoolItemShopTalked"} , NPC_PoolItemShopTalked , 0 }, + { {"PoolItemShopWindowTalked"}, NPC_PoolItemShopWindowTalked, 0 }, + + { {"QuizInit"} , NPC_QuizInit , 0 }, + { {"QuizTalked"} , NPC_QuizTalked, 0 }, + { {"QuizWindowTalked"}, NPC_QuizWindowTalked, 0 }, + + + /* ֮ */ + { {"CheckManInit"} , NPC_CheckManInit , 0 }, + { {"CheckManTalked"} , NPC_CheckManTalked, 0 }, + { {"CheckManWindowTalked"}, NPC_CheckManWindowTalked, 0 }, + + /* Ԫ */ + { {"JankenInit"} , NPC_JankenInit , 0 }, + { {"JankenTalked"} , NPC_JankenTalked, 0 }, + { {"JankenWindowTalked"}, NPC_JankenWindowTalked, 0 }, + + /* Ϸ */ + { {"TransmigrationInit"} , NPC_TransmigrationInit , 0 }, + { {"TransmigrationTalked"} , NPC_TransmigrationTalked, 0 }, + { {"TransmigrationWindowTalked"}, NPC_TransmigrationWindowTalked, 0 }, + + /* Family man */ + { {"FamilymanInit"} , NPC_FamilymanInit , 0 }, + { {"FamilymanTalked"} , NPC_FamilymanTalked, 0 }, + { {"FamilymanLooked"}, NPC_FamilymanLooked,0 }, + { {"FamilymanWindowTalked"}, NPC_FamilymanWindowTalked, 0 }, + + /* CoolFish: Family WarpMan 2001/6/6 */ + { {"FMWarpManInit"}, NPC_FMWarpManInit, 0 }, + { {"FMWarpManTalked"}, NPC_FMWarpManTalked, 0 }, + { {"FMWarpManLoop"} , NPC_FMWarpManLoop, 0 }, + { {"FMWarpManWindowTalked"}, NPC_FMWarpManWindowTalked, 0 }, + + /* CoolFish: Family PKMan 2001/7/4 */ + { {"FMPKManInit"}, NPC_FMPKManInit, 0 }, + { {"FMPKManTalked"}, NPC_FMPKManTalked, 0 }, + { {"FMPKManWindowTalked"}, NPC_FMPKManWindowTalked, 0 }, + + /* CoolFish: Family PKCallMan 2001/7/13 */ + { {"FMPKCallManInit"}, NPC_FMPKCallManInit, 0 }, + { {"FMPKCallManTalked"}, NPC_FMPKCallManTalked, 0 }, + { {"FMPKCallManWindowTalked"}, NPC_FMPKCallManWindowTalked, 0 }, + + /* Bank man */ + { {"BankmanInit"} , NPC_BankmanInit , 0 }, + { {"BankmanTalked"} , NPC_BankmanTalked, 0 }, + { {"BankmanLooked"}, NPC_BankmanLooked,0 }, + { {"BankmanWindowTalked"}, NPC_BankmanWindowTalked, 0 }, + + /* Arminius 7.13 scheduleman */ + { {"SchedulemanInit"}, NPC_SchedulemanInit, 0}, + { {"SchedulemanTalked"}, NPC_SchedulemanTalked, 0}, + { {"SchedulemanWindowTalked"}, NPC_SchedulemanWindowTalked, 0}, + { {"SchedulemanLoop"}, NPC_SchedulemanLoop, 0}, + + /* Arminius 7.24 manor scheduleman */ + { {"ManorSmanInit"}, NPC_ManorSmanInit, 0}, + { {"ManorSmanTalked"}, NPC_ManorSmanTalked, 0}, + { {"ManorSmanWindowTalked"}, NPC_ManorSmanWindowTalked, 0}, + { {"ManorSmanLoop"}, NPC_ManorSmanLoop, 0}, + + /* Rider man */ + { {"RidermanInit"} , NPC_RidermanInit , 0 }, + { {"RidermanTalked"} , NPC_RidermanTalked, 0 }, + { {"RidermanLooked"}, NPC_RidermanLooked,0 }, + { {"RidermanWindowTalked"}, NPC_RidermanWindowTalked, 0 }, + + /* FmLetter man */ + { {"FmLetterInit"} , NPC_FmLetterInit , 0 }, + { {"FmLetterTalked"} , NPC_FmLetterTalked, 0 }, + { {"FmLetterLooked"}, NPC_FmLetterLooked,0 }, + { {"FmLetterWindowTalked"}, NPC_FmLetterWindowTalked, 0 }, + + +#ifdef _GAMBLE_BANK // + { {"GambleBankInit"}, NPC_GambleBankInit, 0}, + { {"GambleBankLoop"}, NPC_GambleBankLoop,0}, + { {"GambleBankTalked"}, NPC_GambleBankTalked,0}, + { {"GambleBankWindowTalked"}, NPC_GambleBankWindowTalked,0}, +#endif + + +#ifdef _PET_LIMITLEVEL + { {"ITEM_useOtherEditBase"}, ITEM_useOtherEditBase, 0}, +#endif +#ifdef _ITEM_EDITBASES + { {"ITEM_useFusionEditBase"}, ITEM_useFusionEditBase, 0}, +#endif +#ifdef _GAMBLE_ROULETTE //ij + { {"GambleRouletteInit"}, NPC_Gamble_RouletteInit, 0}, + { {"GambleRouletteLoop"}, NPC_Gamble_RouletteLoop, 0}, + { {"GambleRouletteTalked"}, NPC_Gamble_RouletteTalked, 0}, + { {"GambleRouletteWindowTalked"}, NPC_Gamble_RouletteWindowTalked, 0}, + + { {"GambleMasterInit"}, NPC_Gamble_MasterInit, 0}, + { {"GambleMasterLoop"}, NPC_Gamble_MasterLoop, 0}, + { {"GambleMasterTalked"}, NPC_Gamble_MasterTalked, 0}, + { {"GambleMasterWindowTalked"}, NPC_Gamble_MasterWindowTalked, 0}, +#endif + +#ifdef _TRANSER_MAN + { {"TranserManInit"}, NPC_TranserManInit, 0 }, + { {"TranserManTalked"}, NPC_TranserManTalked, 0 }, + { {"TranserManLoop"} , NPC_TranserManLoop, 0 }, + { {"TranserManWindowTalked"}, NPC_TranserManWindowTalked, 0 }, +#endif +#ifdef _FM_NPC_LOOK_WAR + { {"FmLookWarManInit"}, NPC_FmLookWarManInit, 0 }, + { {"FmLookWarManTalked"}, NPC_FmLookWarManTalked, 0 }, + { {"FmLookWarManLoop"} , NPC_FmLookWarManLoop, 0 }, + { {"FmLookWarManWindowTalked"}, NPC_FmLookWarManWindowTalked, 0 }, +#endif +#ifdef _FM_NPC_LOOK_WAR1 + { {"FmLookWarMan1Init"}, NPC_FmLookWarMan1Init, 0 }, + { {"FmLookWarMan1Talked"}, NPC_FmLookWarMan1Talked, 0 }, + { {"FmLookWarMan1Loop"} , NPC_FmLookWarMan1Loop, 0 }, + { {"FmLookWarMan1WindowTalked"}, NPC_FmLookWarMan1WindowTalked, 0 }, +#endif +#ifdef _VIP_SHOP + { {"VipShopInit"}, NPC_VipshopInit, 0 }, + { {"VipShopTalked"}, NPC_VipshopTalked, 0 }, + { {"VipShopLoop"} , NPC_VipshopLoop, 0 }, + { {"VipShopWindowTalked"}, NPC_VipshopWindowTalked, 0 }, +#endif + +#ifdef _VIP_SHOP + { {"NewVipShopInit"}, NPC_NewVipshopInit, 0 }, + { {"NewVipShopTalked"}, NPC_NewVipshopTalked, 0 }, + { {"NewVipShopLoop"} , NPC_NewVipshopLoop, 0 }, + { {"NewVipShopWindowTalked"}, NPC_NewVipshopWindowTalked, 0 }, +#endif + +#ifdef _RMB_SYSTEM + { {"RmbShopInit"}, NPC_RmbshopInit, 0 }, + { {"RmbShopTalked"}, NPC_RmbshopTalked, 0 }, + { {"RmbShopLoop"} , NPC_RmbshopLoop, 0 }, + { {"RmbShopWindowTalked"}, NPC_RmbshopWindowTalked, 0 }, +#endif + +#ifdef _STU_SYS + { {"StuShopInit"}, NPC_StushopInit, 0 }, + { {"StuShopTalked"}, NPC_StushopTalked, 0 }, + { {"StuShopLoop"} , NPC_StushopLoop, 0 }, + { {"StuShopWindowTalked"}, NPC_StushopWindowTalked, 0 }, +#endif + +#ifdef _AUTO_PK + { {"AutoPkInit"}, NPC_AutoPkInit, 0 }, + { {"AutoPkTalked"}, NPC_AutoPkTalked, 0 }, + { {"AutoPkLoop"} , NPC_AutoPkLoop, 0 }, + { {"AutoPkWindowTalked"}, NPC_AutoPkWindowTalked, 0 }, +#endif +#ifdef _FMRANK_POINT + { {"FmRankInit"}, NPC_FmRankInit, 0 }, + { {"FmRankTalked"}, NPC_FmRankTalked, 0 }, + { {"FmRankLoop"} , NPC_FmRankLoop, 0 }, + { {"FmRankWindowTalked"}, NPC_FmRankWindowTalked, 0 }, +#endif +#ifdef _NPC_MAKEPAIR + { {"MakePairManInit"}, NPC_MakePairManInit, 0 }, + { {"MakePairManTalked"}, NPC_MakePairManTalked, 0 }, + { {"MakePairManLoop"} , NPC_MakePairManLoop, 0 }, + { {"MakePairManWindowTalked"}, NPC_MakePairManWindowTalked,0 }, +#endif +#ifdef _NPC_FUSION + { {"PetFusionManInit"}, NPC_PetFusionManInit, 0 }, + { {"PetFusionManTalked"}, NPC_PetFusionManTalked, 0 }, + { {"PetFusionManLoop"} , NPC_PetFusionManLoop, 0 }, + { {"PetFusionManWindowTalked"}, NPC_PetFusionManWindowTalked,0 }, +#endif +#ifdef _ITEM_NPCCHANGE + { {"ItemchangeManInit"}, NPC_ItemchangeManInit, 0 }, + { {"ItemchangeManTalked"}, NPC_ItemchangeManTalked, 0 }, + { {"ItemchangeManLoop"} , NPC_ItemchangeManLoop, 0 }, + { {"ItemchangeManWindowTalked"}, NPC_ItemchangeManWindowTalked, 0 }, +#endif +#ifdef _NPC_ITEMUP + { {"ItemupManInit"}, NPC_ItemupManInit, 0 }, + { {"ItemupManTalked"}, NPC_ItemupManTalked, 0 }, + { {"ItemupManLoop"} , NPC_ItemupManLoop, 0 }, + { {"ItemupManWindowTalked"}, NPC_ItemupManWindowTalked, 0 }, +#endif +#ifdef _CFREE_petskill + { {"FreePetSkillInit"} , NPC_FreePetSkillShopInit, 0 }, + { {"FreePetSkillTalked"} , NPC_FreePetSkillShopTalked, 0 }, + { {"FreePetSkillWindowTalked"}, NPC_FreePetSkillShopWindowTalked, 0 }, +#endif + +#ifdef _PETRACE // ᄎ + { {"PetRaceMasterInit"}, NPC_PetRaceMasterInit, 0}, + { {"PetRaceMasterLoop"}, NPC_PetRaceMasterLoop, 0}, + { {"PetRaceMasterTalked"}, NPC_PetRaceMasterTalked, 0}, + { {"PetRaceMasterWindowTalked"}, NPC_PetRaceMasterWindowTalked, 0}, + + { {"PetRacePetInit"}, NPC_PetRacePetInit, 0}, + { {"PetRacePetLoop"}, NPC_PetRacePetLoop, 0}, + { {"PetRacePetTalked"}, NPC_PetRacePetTalked, 0}, +#endif + +#ifdef _NEW_WARPMAN + { {"NewNpcManInit"}, NPC_NewNpcManInit, 0}, + { {"NewNpcManLoop"}, NPC_NewNpcManLoop, 0}, + { {"NewNpcManTalked"}, NPC_NewNpcManTalked, 0}, + { {"NewNpcManWindowTalked"}, NPC_NewNpcManWindowTalked, 0}, +#endif + +#ifdef _ALLDOMAN // (ɿ) Syu ADD аNPC + { {"AlldomanInit"} , NPC_AlldomanInit, 0 }, + { {"AlldomanTalked"} , NPC_AlldomanTalked , 0 }, + { {"AlldomanWindowTalked"}, NPC_AlldomanWindowTalked , 0}, +#endif + +#ifdef _NPC_WELFARE + { {"WelfareInit"} , NPC_WelfareInit, 0 }, + { {"WelfareTalked"} , NPC_WelfareTalked , 0 }, + { {"WelfareWindowTalked"}, NPC_WelfareWindowTalked , 0}, +#endif +#ifdef _VIGOR_SYS + { {"ItemVigorShopInit"} , NPC_ItemVigorShopInit , 0 }, + { {"ItemVigorShopTalked"} , NPC_ItemVigorShopTalked , 0 }, + { {"ItemVigorShopWindowTalked"}, NPC_ItemVigorShopWindowTalked, 0 }, +#endif +#ifdef _TIME_TICKET + { {"ITEM_timeticket"}, ITEM_timeticket, 0}, +#endif + +#ifdef _ITEM_SETLOVER // Ʒ + { {"ITEM_SetLoverUser"}, ITEM_SetLoverUser, 0 }, + { {"ITEM_LoverWarp"}, ITEM_LoverWarp, 0 }, + { {"ITEM_LoverUnmarry"}, ITEM_LoverUnmarry, 0 }, + { {"ITEM_LoverForceUnmarry"}, ITEM_LoverForceUnmarry, 0 }, //ǿ +#endif + +#ifdef _GM_ITEM // GMƷ + { {"ITEM_GMFUNCTION"}, ITEM_GMFUNCTION, 0 }, +#endif + +#ifdef _VIP_SERVER // Ա + { {"ITEM_AddMemberPoint"}, ITEM_AddMemberPoint, 0 }, + { {"ITEM_AddVipPoint"}, ITEM_AddVipPoint, 0 }, +#endif +#ifdef _VIP_RIDE + { {"ITEM_VipRide"}, ITEM_VipRide, 0 }, +#endif +#ifdef _NEW_NAME //Զƺ + { {"ITEM_NewName"}, ITEM_NewName, 0 }, +#endif +#ifdef _FM_ITEM + { {"ITEM_AddFame"}, ITEM_AddFame, 0 }, +#endif +#ifdef _LUCK_ITEM + { {"ITEM_Luck"}, ITEM_Luck, 0 }, +#endif +#ifdef _FM_METAMO + { {"ITEM_MetamoTime"}, ITEM_MetamoTime, 0 }, +#endif +#ifdef _ITEM_GOLD + { {"ITEM_Gold"}, ITEM_Gold, 0 }, +#endif +#ifdef _MYSTERIOUS_GIFT + { {"ITEM_MysteriousGift"}, ITEM_MysteriousGift, 0 }, +#endif +#ifdef _BATTLE_PK + { {"ITEM_BattlePK"}, ITEM_BattlePK, 0 }, +#endif +#ifdef _SILENTZERO + { {"ITEM_SetSilentZero"}, ITEM_SetSilentZero, 0 }, +#endif +#ifdef _PET_LEVEL_ITEM + { {"ITEM_PetLevelItem"}, ITEM_PetLevelItem, 0 }, +#endif + +#ifdef _ITEM_EFMETAMO + { {"ITEM_efMetamo"}, ITEM_efMetamo, 0 }, +#endif +#ifdef _PET_BEATITUDE + { {"PET_BEATITUDE"}, PET_BEATITUDE, 0 }, +#endif +#ifdef _GET_MULTI_ITEM + { {"ITEM_GetMultiItem"}, ITEM_GetMultiItem, 0 }, +#endif + { {"ITEM_OldToNew"}, ITEM_OldToNew, 0 }, +#ifdef _SAFE_PASSWORD + { {"ITEM_ItemPetLocked"}, ITEM_ItemPetLocked, 0 }, +#endif +#ifdef _POINT_CARD + { {"ITEM_OnlineCost"}, ITEM_OnlineCost, 0 }, +#endif +#ifdef _SUPER_MAN_ITEM + { {"ITEM_SuperManItem"}, ITEM_SuperManItem, 0 }, +#endif + { {"ITEM_CharSave"}, ITEM_CharSave, 0 }, + { {"ITEM_NoDelWarp"}, ITEM_NoDelWarp, 0 }, + { {"ITEM_RandWarp"}, ITEM_RandWarp, 0 }, + { {"ITEM_RandMsg"}, ITEM_RandMsg, 0 }, +#ifdef _SQL_BUY_FUNC + { {"ITEM_OnlineBuy_recv"}, ITEM_OnlineBuy_recv, 0 }, +#endif +#ifdef _JOB_AUTOPK + { {"ITEM_JobPk"}, ITEM_JobPk, 0 }, +#endif + { {"ITEM_SeeEquip"}, ITEM_SeeEquip, 0 }, +#ifdef _VIGOR_SYS + { {"ITEM_VigorSave"}, ITEM_VigorSave, 0 }, +#endif +#ifdef _EV_NUM + { {"ITEM_EvItem"}, ITEM_EvItem, 0 }, +#endif +#ifdef _OFFLINE_SYSTEM + { {"ITEM_OFFLINE"}, ITEM_OFFLINE, 0 }, +#endif + { {"ITEM_AddProfessionLevel"}, ITEM_AddProfessionLevel, 0 }, +#ifdef _ZHIPIAO_SYSTEM + { {"ITEM_ZhiPiao"}, ITEM_ZhiPiao, 0 }, +#endif + { {"ITEM_useRandEditBase"}, ITEM_useRandEditBase, 0 }, +#ifdef _DP_ZHIPIAO_ITEM + { {"ITEM_DpZhiPiao"}, ITEM_DpZhiPiao, 0 }, +#endif + { {"ITEM_UpPointResetItem"}, ITEM_UpPointResetItem, 0 }, + { {"ITEM_MM"}, ITEM_MM, 0 }, +#ifdef _XC_CANGKU + { {"ITEM_ICK"}, ITEM_ICK, 0 }, + { {"ITEM_PCK"}, ITEM_PCK, 0 }, +#endif +#ifdef _SPECIAL_SUIT + { {"ITEM_SpecialSuitEquip"}, ITEM_SpecialSuitEquip, 0 }, + { {"ITEM_SpecialResuitEquip"}, ITEM_SpecialResuitEquip, 0 }, +#endif +#ifdef _NULL_CHECK_ITEM + { {"ITEM_NullCheck"}, ITEM_NullCheck, 0 }, +#endif +#ifdef _MANOR_EQUIP + { {"ITEM_ManorEquip"}, ITEM_ManorEquip, 0 }, + { {"ITEM_ReManorEquip"}, ITEM_ReManorEquip, 0 }, +#endif + { {"ITEM_MakePet"}, ITEM_MakePet, 0 }, + { {"PET_OTHERBEATITUDE"}, PET_OTHERBEATITUDE, 0 }, + { {"PET_MYBEATITUDE"}, PET_MYBEATITUDE, 0 }, + { {"ITEM_useExpLv"}, ITEM_useExpLv, 0 }, +#ifdef _ITEM_LUA + { {"ITEM_Lua"}, ITEM_Lua, 0 }, +#endif +#ifdef _JZ_NEWSCRIPT_LUA + { {FUNCNAME_INITCALLBACK} , NPC_Lua_InitCallBack, 0 }, + { {FUNCNAME_WALKPRECALLBACK} , NPC_Lua_WalkPreCallBack, 0 }, + { {FUNCNAME_WALKPOSTCALLBACK} , NPC_Lua_WalkPostCallBack, 0 }, + { {FUNCNAME_PREOVERCALLBACK} , NPC_Lua_PreOverCallBack, 0 }, + { {FUNCNAME_POSTOVERCALLBACK} , NPC_Lua_PostOverCallBack, 0 }, + { {FUNCNAME_WATCHCALLBACK} , NPC_Lua_WatchCallBack, 0 }, + { {FUNCNAME_LOOPCALLBACK} , NPC_Lua_LoopCallBack, 0 }, + { {FUNCNAME_TALKEDCALLBACK} , NPC_Lua_TalkedCallBack, 0 }, + { {FUNCNAME_OFFCALLBACK} , NPC_Lua_OFFCallBack, 0 }, + { {FUNCNAME_LOOKEDCALLBACK} , NPC_Lua_LookedCallBack, 0 }, + { {FUNCNAME_ITEMPUTCALLBACK} , NPC_Lua_ItemPutCallBack, 0 }, + { {FUNCNAME_WINDOWTALKEDCALLBACK} , NPC_Lua_WindowTalkedCallBack, 0 }, +#ifdef _USER_CHARLOOPS + { {FUNCNAME_CHARLOOPSCALLBACK} , NPC_Lua_CharLoopsCallBack, 0 }, + { {FUNCNAME_BATTLEPROPERTYCALLBACK} , NPC_Lua_BattleProPertyCallBack, 0 }, +#endif + + { {FUNCNAME_ITEMPEROVERCALLBACK} , NPC_Lua_ItemPerOverCallBack, 0 }, + { {FUNCNAME_ITEMPOSTOVERCALLBACK} , NPC_Lua_ItemPostOverCallBack, 0 }, + { {FUNCNAME_ITEMWATCHCALLBACK} , NPC_Lua_ItemWatchCallBack, 0 }, + { {FUNCNAME_ITEMUSECALLBACK} , NPC_Lua_ItemUseCallBack, 0 }, + { {FUNCNAME_ITEMATTACHCALLBACK} , NPC_Lua_ItemAttachCallBack, 0 }, + { {FUNCNAME_ITEMDETACHCALLBACK} , NPC_Lua_ItemDetachCallBack, 0 }, + { {FUNCNAME_ITEMDROPCALLBACK} , NPC_Lua_ItemDropCallBack, 0 }, + { {FUNCNAME_ITEMPICKUPCALLBACK} , NPC_Lua_ItemPickUPCallBack, 0 }, +#ifdef _Item_ReLifeAct + { {FUNCNAME_ITEMDIERELIFECALLBACK} , NPC_Lua_ItemDieReLifeCallBack, 0 }, +#endif + + { {FUNCNAME_BATTLEWINCALLBACK} , NPC_Lua_BattleWinCallBack, 0 }, + { {FUNCNAME_BATTLEENDCALLBACK} , NPC_Lua_BattleEndCallBack, 0 }, +#endif //_JZ_NEWSCRIPT_LUA +}; + +BOOL initFunctionTable( void ) +{ + + int i; + { + char* strings[arraysizeof(correspondStringAndFunctionTable)]; + int stringnum=0; + for( i=0 ; i $OUT +cat $IN | grep -e "^#define" | cut -b 9- | sed "s/\"/\'/g" | \ + sed 's/\\/\\\\/g' >> $OUT +echo "<>" >> $OUT +echo "by : zoro\n\";" >> $OUT \ No newline at end of file diff --git a/genver.sh b/genver.sh new file mode 100644 index 0000000..9d31d6b --- /dev/null +++ b/genver.sh @@ -0,0 +1,9 @@ +#!/bin/sh +IN=./include/version.h +OUT=./genver.h +touch main.c +echo "char *genver=\"" > $OUT +cat $IN | grep -e "^#define" | cut -b 9- | sed "s/\"/\'/g" | \ + sed 's/\\/\\\\/g' >> $OUT +echo "<>" >> $OUT +echo "by : zoro\n\";" >> $OUT \ No newline at end of file diff --git a/handletime.c b/handletime.c new file mode 100644 index 0000000..c416550 --- /dev/null +++ b/handletime.c @@ -0,0 +1,281 @@ +#define __HANDLETIME_C__ +#include "version.h" +#include +#include + +#include "common.h" +#include "handletime.h" + +#define LSTIME_SECONDS_PER_DAY 5400 /* LSTIME ϼ */ + + +#define LSTIME_HOURS_PER_DAY 1024 /* LSTIME ϼLSTIME */ +#define LSTIME_DAYS_PER_YEAR 100 /* LSTIME ϼLSTIME */ + + +/* +// Nuke 0701: localtime + + struct timeval NowTime; +#ifdef localtime +#undef localtime +#endif + +struct tm *localtime(const time_t *timep) +{ + static struct tm lt; + memset(<,0,sizeof(lt)); + lt.tm_sec=*timep %60; + lt.tm_min=(*timep %3600) / 60; + lt.tm_hour=(*timep % 86400) / 3600; + return < +} +*/ + +/*------------------------------------------------------------ + * ¦ + * ئ + * ߯Ի + ------------------------------------------------------------*/ +BOOL setNewTime( void ) +{ + if( gettimeofday( &NowTime, (struct timezone*)NULL) != 0 ) { + NowTime.tv_sec = time(0); + // Nuke 0701: Localtime down + print("\n time err !! \n"); + return FALSE; + } + NowTime.tv_sec += DEBUG_ADJUSTTIME; + return TRUE; +} + + +/******************************************************************* +*******************************************************************/ +static long era = (long)912766409 + 5400; + /* SAб */ +void RealTimeToLSTime(long t , LSTIME *lstime) +{ + long lsseconds = t - era; /* LS ռ */ + long lsdays; /* LS ռ */ + + lstime->year = (int)( lsseconds/(LSTIME_SECONDS_PER_DAY*LSTIME_DAYS_PER_YEAR) ); + + lsdays = lsseconds/LSTIME_SECONDS_PER_DAY;/* ռ ëңƻ */ + lstime->day = lsdays % LSTIME_DAYS_PER_YEAR;/* Ի ƥؤԻ */ + + + lstime->hour = (int)(lsseconds % LSTIME_SECONDS_PER_DAY ) + * LSTIME_HOURS_PER_DAY / LSTIME_SECONDS_PER_DAY; + + return; +} + +/******************************************************************* + LS޾Ѩ˼ޱ +*******************************************************************/ +void LSTimeToRealTime( LSTIME *lstime, long *t) +{ + *t=(long)( + ( lstime->hour*LSTIME_DAYS_PER_YEAR+lstime->day) /* */ + *LSTIME_HOURS_PER_DAY + + + lstime->year) + + + *450; + return; +} + +/******************************************************************* +*******************************************************************/ +LSTIME_SECTION getLSTime (LSTIME *lstime) +{ + if (NIGHT_TO_MORNING < lstime->hour + && lstime->hour <= MORNING_TO_NOON) + return LS_MORNING; + else if(NOON_TO_EVENING < lstime->hour + && lstime->hour <= EVENING_TO_NIGHT) + return LS_EVENING; + else if(EVENING_TO_NIGHT < lstime->hour + && lstime->hour <= NIGHT_TO_MORNING) + return LS_NIGHT; + else + return LS_NOON; +} + + +#ifdef _ASSESS_SYSEFFICACY +static clock_t TotalClock = 0; +static clock_t StartClock = 0; +//static int EndClock = 0; +//static float SysTime=0.0; +static clock_t EndClock = 0; +static double SysTime=0.0; +static int Cnum = 0; + +#ifdef _ASSESS_SYSEFFICACY_SUB +static clock_t Net_TotalClock = 0; +static clock_t NPCGEN_TotalClock = 0; +static clock_t Battle_TotalClock = 0; +static clock_t Char_TotalClock = 0; +static clock_t Petmail_TotalClock = 0; +static clock_t Family_TotalClock = 0; +static clock_t SaveCheck_TotalClock = 0; +static clock_t GMBroadCast_TotalClock = 0; +static double Net_SysTime=0.0; +static double NPCGEN_SysTime=0.0; +static double Battle_SysTime=0.0; +static double Char_SysTime=0.0; +static double Petmail_SysTime=0.0; +static double Family_SysTime=0.0; +static double SaveCheck_SysTime=0.0; +static double GMBroadCast_SysTime=0.0; +static clock_t SubStartClock = 0; +#endif + +void Assess_InitSysEfficacy() +{ + TotalClock = 0; + StartClock = 0; + EndClock = 0; +#ifdef _ASSESS_SYSEFFICACY_SUB + Net_TotalClock = 0; + NPCGEN_TotalClock = 0; + Battle_TotalClock = 0; + Char_TotalClock = 0; + Petmail_TotalClock = 0; + Family_TotalClock = 0; + SaveCheck_TotalClock = 0; + GMBroadCast_TotalClock = 0; + + SubStartClock = 0; +#endif +} + +void Assess_SysEfficacy( int flg) +{ + if( flg == 0 ){ + StartClock=clock(); + }else if( flg == 1 ){ + EndClock = clock(); + if( EndClock < StartClock ) return; + TotalClock += (int)(EndClock-StartClock); + Cnum++; + if( Cnum%500 == 0 ){ + SysTime = (float)(TotalClock/Cnum)/CLOCKS_PER_SEC; + TotalClock = 0; +#ifdef _ASSESS_SYSEFFICACY_SUB + Net_SysTime = (float)(Net_TotalClock/Cnum)/CLOCKS_PER_SEC; + Net_TotalClock = 0; + NPCGEN_SysTime = (float)(NPCGEN_TotalClock/Cnum)/CLOCKS_PER_SEC; + NPCGEN_TotalClock = 0; + Battle_SysTime = (float)(Battle_TotalClock/Cnum)/CLOCKS_PER_SEC; + Battle_TotalClock = 0; + Char_SysTime = (float)(Char_TotalClock/Cnum)/CLOCKS_PER_SEC; + Char_TotalClock = 0; + Petmail_SysTime = (float)(Petmail_TotalClock/Cnum)/CLOCKS_PER_SEC; + Petmail_TotalClock = 0; + Family_SysTime = (float)(Family_TotalClock/Cnum)/CLOCKS_PER_SEC; + Family_TotalClock = 0; + SaveCheck_SysTime = (float)(SaveCheck_TotalClock/Cnum)/CLOCKS_PER_SEC; + SaveCheck_TotalClock = 0; + GMBroadCast_SysTime = (float)(GMBroadCast_TotalClock/Cnum)/CLOCKS_PER_SEC; + GMBroadCast_TotalClock = 0; +#endif + Cnum = 0; + } + } + /* + EndClock = clock(); + if( StartClock != 0 ){ + if( EndClock < StartClock ) return; + TotalClock += (int)(EndClock-StartClock); + Cnum++; + if( Cnum%500 == 0 ){ + SysTime = (float)TotalClock/Cnum; + TotalClock = 0; + } + } + StartClock = EndClock; + */ +} + +void ASSESS_getSysEfficacy( float *TVsec) +{ + *TVsec = SysTime; +} + +#ifdef _ASSESS_SYSEFFICACY_SUB +void Assess_SysEfficacy_sub( int flg, int loop) +{ + + if( flg == 0 ){ + SubStartClock = clock(); + }else if( flg == 1 ){ + EndClock = clock(); + if( EndClock < SubStartClock ) return; + + switch( loop) { + case 1: // Net_TotalClock + Net_TotalClock += (int)(EndClock-SubStartClock); + break; + case 2: // NPCGEN_TotalClock + NPCGEN_TotalClock += (int)(EndClock-SubStartClock); + break; + case 3: // Battle_TotalClock + Battle_TotalClock += (int)(EndClock-SubStartClock); + break; + case 4: // Char_TotalClock + Char_TotalClock += (int)(EndClock-SubStartClock); + break; + case 5: // Petmail_TotalClock + Petmail_TotalClock += (int)(EndClock-SubStartClock); + break; + case 6: // Family_TotalClock + Family_TotalClock += (int)(EndClock-SubStartClock); + break; + case 7: // SaveCheck_TotalClock + SaveCheck_TotalClock += (int)(EndClock-SubStartClock); + break; + case 8: // GMBroadCast_TotalClock + GMBroadCast_TotalClock += (int)(EndClock-SubStartClock); + break; + } + } +} + +void ASSESS_getSysEfficacy_sub( float *TVsec, int loop_index) +{ + switch( loop_index) { + case 1: + *TVsec = Net_SysTime; + break; + case 2: + *TVsec = NPCGEN_SysTime; + break; + case 3: + *TVsec = Battle_SysTime; + break; + case 4: + *TVsec = Char_SysTime; + break; + case 5: + *TVsec = Petmail_SysTime; + break; + case 6: + *TVsec = Family_SysTime; + break; + case 7: + *TVsec = SaveCheck_SysTime; + break; + case 8: + *TVsec = GMBroadCast_SysTime; + break; + } +} + +#endif + +#endif + diff --git a/include/addressbook.h b/include/addressbook.h new file mode 100644 index 0000000..0723cf7 --- /dev/null +++ b/include/addressbook.h @@ -0,0 +1,45 @@ +#ifndef __ADDRESSBOOK_H__ +#define __ADDRESSBOOK_H__ + +#include "common.h" +#include "util.h" +#include "net.h" + +#define ADDRESSBOOK_MAX 80 + +typedef struct +{ + int use; + BOOL online; /* ƽҷ»ӡ TRUE, + ƥئFALSE */ + int level; /* ƽҷ¼ì */ + int duelpoint; /* duelpoint*/ + int graphicsno; /* ƽҷ¼ į */ + char cdkey[CDKEYLEN]; /* CD ϼ */ + char charname[CHARNAMELEN]; /* ƽҷ¼ */ + int transmigration; /* Ϸ */ + +} ADDRESSBOOK_entry; + + + + +char *ADDRESSBOOK_makeAddressbookString( ADDRESSBOOK_entry *a ); +BOOL ADDRESSBOOK_makeAddressbookEntry( char *in , ADDRESSBOOK_entry *a ); +BOOL ADDRESSBOOK_deleteEntry( int meindex ,int index ); +BOOL ADDRESSBOOK_addEntry( int meindex ); +BOOL ADDRESSBOOK_sendAddressbookTable( int cindex ); +BOOL ADDRESSBOOK_sendAddressbookTableOne( int cindex, int num ); +BOOL ADDRESSBOOK_sendMessage( int cindex, int aindex , char *text , + int color ); +BOOL ADDRESSBOOK_sendMessage_FromOther( char *fromcdkey, char *fromcharaname, + char *tocdkey, char *tocharaname, + char* text , int color ); + +void ADDRESSBOOK_notifyLoginLogout( int cindex , int flg ); +void ADDRESSBOOK_addAddressBook( int meindex, int toindex); +void ADDRESSBOOK_DispatchMessage( char *cd, char *nm, char *value, int mode); +int ADDRESSBOOK_getIndexInAddressbook(int cindex , char *cdkey, char *charname); +BOOL ADDRESSBOOK_AutoaddAddressBook( int meindex, int toindex); + +#endif diff --git a/include/anim_tbl.h b/include/anim_tbl.h new file mode 100644 index 0000000..5065d93 --- /dev/null +++ b/include/anim_tbl.h @@ -0,0 +1,1006 @@ +#ifndef _ANIM_TBL_H_ +#define _ANIM_TBL_H_ + +//#define SPRSTART 30000 // SPRԻ į +#define SPRSTART 100000 // SPRԻ į + +// ƽҷ +#define SPR_001em 100000 // Ҽɨ +#define SPR_001ax 100001 // +#define SPR_001cl 100002 // +#define SPR_001sp 100003 // +#define SPR_001bw 100004 // + +#define SPR_002em 100005 // Ҽɨ +#define SPR_002ax 100006 // +#define SPR_002cl 100007 // +#define SPR_002sp 100008 // +#define SPR_002bw 100009 // + +#define SPR_003em 100010 // Ҽɨ +#define SPR_003ax 100011 // +#define SPR_003cl 100012 // +#define SPR_003sp 100013 // +#define SPR_003bw 100014 // + +#define SPR_004em 100015 // Ҽɨ +#define SPR_004ax 100016 // +#define SPR_004cl 100017 // +#define SPR_004sp 100018 // +#define SPR_004bw 100019 // + +#define SPR_011em 100020 // +#define SPR_011ax 100021 // +#define SPR_011cl 100022 // +#define SPR_011sp 100023 // +#define SPR_011bw 100024 // + +#define SPR_012em 100025 // +#define SPR_012ax 100026 // +#define SPR_012cl 100027 // +#define SPR_012sp 100028 // +#define SPR_012bw 100029 // + +#define SPR_013em 100030 // +#define SPR_013ax 100031 // +#define SPR_013cl 100032 // +#define SPR_013sp 100033 // +#define SPR_013bw 100034 // + +#define SPR_014em 100035 // +#define SPR_014ax 100036 // +#define SPR_014cl 100037 // +#define SPR_014sp 100038 // +#define SPR_014bw 100039 // + +#define SPR_021em 100040 // +#define SPR_021ax 100041 // +#define SPR_021cl 100042 // +#define SPR_021sp 100043 // +#define SPR_021bw 100044 // + +#define SPR_022em 100045 +#define SPR_022ax 100046 +#define SPR_022cl 100047 +#define SPR_022sp 100048 +#define SPR_022bw 100049 + +#define SPR_023em 100050 +#define SPR_023ax 100051 +#define SPR_023cl 100052 +#define SPR_023sp 100053 +#define SPR_023bw 100054 + +#define SPR_024em 100055 +#define SPR_024ax 100056 +#define SPR_024cl 100057 +#define SPR_024sp 100058 +#define SPR_024bw 100059 + +#define SPR_031em 100060 // +#define SPR_031ax 100061 // +#define SPR_031cl 100062 // +#define SPR_031sp 100063 // +#define SPR_031bw 100064 // + +#define SPR_032em 100065 +#define SPR_032ax 100066 +#define SPR_032cl 100067 +#define SPR_032sp 100068 +#define SPR_032bw 100069 + +#define SPR_033em 100070 +#define SPR_033ax 100071 +#define SPR_033cl 100072 +#define SPR_033sp 100073 +#define SPR_033bw 100074 + +#define SPR_034em 100075 +#define SPR_034ax 100076 +#define SPR_034cl 100077 +#define SPR_034sp 100078 +#define SPR_034bw 100079 + +#define SPR_041em 100080 // +#define SPR_041ax 100081 // +#define SPR_041cl 100082 // +#define SPR_041sp 100083 // +#define SPR_041bw 100084 // + +#define SPR_042em 100085 +#define SPR_042ax 100086 +#define SPR_042cl 100087 +#define SPR_042sp 100088 +#define SPR_042bw 100089 + +#define SPR_043em 100090 +#define SPR_043ax 100091 +#define SPR_043cl 100092 +#define SPR_043sp 100093 +#define SPR_043bw 100094 + +#define SPR_044em 100095 +#define SPR_044ax 100096 +#define SPR_044cl 100097 +#define SPR_044sp 100098 +#define SPR_044bw 100099 + +#define SPR_051em 100100 // +#define SPR_051ax 100101 // +#define SPR_051cl 100102 // +#define SPR_051sp 100103 // +#define SPR_051bw 100104 // + +#define SPR_052em 100105 +#define SPR_052ax 100106 +#define SPR_052cl 100107 +#define SPR_052sp 100108 +#define SPR_052bw 100109 + +#define SPR_053em 100110 +#define SPR_053ax 100111 +#define SPR_053cl 100112 +#define SPR_053sp 100113 +#define SPR_053bw 100114 + +#define SPR_054em 100115 +#define SPR_054ax 100116 +#define SPR_054cl 100117 +#define SPR_054sp 100118 +#define SPR_054bw 100119 + +#define SPR_061em 100120 // ҼԨ +#define SPR_061ax 100121 // +#define SPR_061cl 100122 // +#define SPR_061sp 100123 // +#define SPR_061bw 100124 // + +#define SPR_062em 100125 +#define SPR_062ax 100126 +#define SPR_062cl 100127 +#define SPR_062sp 100128 +#define SPR_062bw 100129 + +#define SPR_063em 100130 +#define SPR_063ax 100131 +#define SPR_063cl 100132 +#define SPR_063sp 100133 +#define SPR_063bw 100134 + +#define SPR_064em 100135 +#define SPR_064ax 100136 +#define SPR_064cl 100137 +#define SPR_064sp 100138 +#define SPR_064bw 100139 + +#define SPR_071em 100140 // Ԩ +#define SPR_071ax 100141 // +#define SPR_071cl 100142 // +#define SPR_071sp 100143 // +#define SPR_071bw 100144 // + +#define SPR_072em 100145 +#define SPR_072ax 100146 +#define SPR_072cl 100147 +#define SPR_072sp 100148 +#define SPR_072bw 100149 + +#define SPR_073em 100150 +#define SPR_073ax 100151 +#define SPR_073cl 100152 +#define SPR_073sp 100153 +#define SPR_073bw 100154 + +#define SPR_074em 100155 +#define SPR_074ax 100156 +#define SPR_074cl 100157 +#define SPR_074sp 100158 +#define SPR_074bw 100159 + +#define SPR_081em 100160 // Ԩ +#define SPR_081ax 100161 // +#define SPR_081cl 100162 // +#define SPR_081sp 100163 // +#define SPR_081bw 100164 // + +#define SPR_082em 100165 +#define SPR_082ax 100166 +#define SPR_082cl 100167 +#define SPR_082sp 100168 +#define SPR_082bw 100169 + +#define SPR_083em 100170 +#define SPR_083ax 100171 +#define SPR_083cl 100172 +#define SPR_083sp 100173 +#define SPR_083bw 100174 + +#define SPR_084em 100175 +#define SPR_084ax 100176 +#define SPR_084cl 100177 +#define SPR_084sp 100178 +#define SPR_084bw 100179 + +#define SPR_091em 100180 // Ԩ +#define SPR_091ax 100181 // +#define SPR_091cl 100182 // +#define SPR_091sp 100183 // +#define SPR_091bw 100184 // + +#define SPR_092em 100185 +#define SPR_092ax 100186 +#define SPR_092cl 100187 +#define SPR_092sp 100188 +#define SPR_092bw 100189 + +#define SPR_093em 100190 +#define SPR_093ax 100191 +#define SPR_093cl 100192 +#define SPR_093sp 100193 +#define SPR_093bw 100194 + +#define SPR_094em 100195 +#define SPR_094ax 100196 +#define SPR_094cl 100197 +#define SPR_094sp 100198 +#define SPR_094bw 100199 + +#define SPR_101em 100200 // +#define SPR_101ax 100201 // +#define SPR_101cl 100202 // +#define SPR_101sp 100203 // +#define SPR_101bw 100204 // + +#define SPR_102em 100205 +#define SPR_102ax 100206 +#define SPR_102cl 100207 +#define SPR_102sp 100208 +#define SPR_102bw 100209 + +#define SPR_103em 100210 +#define SPR_103ax 100211 +#define SPR_103cl 100212 +#define SPR_103sp 100213 +#define SPR_103bw 100214 + +#define SPR_104em 100215 +#define SPR_104ax 100216 +#define SPR_104cl 100217 +#define SPR_104sp 100218 +#define SPR_104bw 100219 + +#define SPR_111em 100220 // +#define SPR_111ax 100221 // +#define SPR_111cl 100222 // +#define SPR_111sp 100223 // +#define SPR_111bw 100224 // + +#define SPR_112em 100225 +#define SPR_112ax 100226 +#define SPR_112cl 100227 +#define SPR_112sp 100228 +#define SPR_112bw 100229 + +#define SPR_113em 100230 +#define SPR_113ax 100231 +#define SPR_113cl 100232 +#define SPR_113sp 100233 +#define SPR_113bw 100234 + +#define SPR_114em 100235 +#define SPR_114ax 100236 +#define SPR_114cl 100237 +#define SPR_114sp 100238 +#define SPR_114bw 100239 + + +// ʸ ƽҷ +#define SPR_pet001 100250 // +#define SPR_pet002 100251 // +#define SPR_pet003 100252 // ̼ +#define SPR_pet004 100253 // Ƥ + +#define SPR_pet011 100254 // Ƥū +#define SPR_pet012 100255 // Ƥ +#define SPR_pet013 100256 // Ƥ +#define SPR_pet014 100257 // Ƥ̡ +#define SPR_pet015 100258 // СƤ + +#define SPR_pet021 100259 // +#define SPR_pet022 100260 // +#define SPR_pet023 100261 // +#define SPR_pet024 100262 // ҡ + +#define SPR_pet031 100263 // ̺ +#define SPR_pet032 100264 // ūū +#define SPR_pet033 100265 // +#define SPR_pet034 100266 // ū + +#define SPR_pet041 100267 // ì +#define SPR_pet042 100268 // ì +#define SPR_pet043 100269 // ìͻ +#define SPR_pet044 100270 // ì + +#define SPR_pet051 100271 // ж +#define SPR_pet052 100272 // з´ +#define SPR_pet053 100273 // ж +#define SPR_pet054 100274 // з´ + +#define SPR_pet061 100275 // +#define SPR_pet062 100276 // ҵ +#define SPR_pet063 100277 // +#define SPR_pet064 100278 // ĸͻ + +#define SPR_pet071 100279 // ׻ +#define SPR_pet072 100280 // +#define SPR_pet073 100281 // ƽ +#define SPR_pet074 100282 // + +#define SPR_pet081 100283 // +#define SPR_pet082 100284 // е +#define SPR_pet083 100285 // +#define SPR_pet084 100286 // ҵ + +#define SPR_pet091 100287 // δ +#define SPR_pet092 100288 // ׷ +#define SPR_pet093 100289 // ʾ +#define SPR_pet094 100290 // ס + +#define SPR_pet101 100291 // +#define SPR_pet102 100292 // ͻ +#define SPR_pet103 100293 // ƽ +#define SPR_pet104 100294 // ƽ + +#define SPR_pet111 100295 // +#define SPR_pet112 100296 // +#define SPR_pet113 100297 // ƽب +#define SPR_pet114 100298 // ƽ + +#define SPR_pet121 100299 // ئ +#define SPR_pet122 100300 // ئ +#define SPR_pet123 100301 // ئ +#define SPR_pet124 100302 // ئ + +#define SPR_pet131 100303 // ئ +#define SPR_pet132 100304 // ئ +#define SPR_pet133 100305 // ئ +#define SPR_pet134 100306 // ئ + +#define SPR_pet141 100307 // +#define SPR_pet142 100308 // ׷ +#define SPR_pet143 100309 // ׷´ +#define SPR_pet144 100310 // + +#define SPR_pet151 100311 // ئ +#define SPR_pet152 100312 // ئ +#define SPR_pet153 100313 // ئ +#define SPR_pet154 100314 // ئ + +#define SPR_pet161 100315 // ئ +#define SPR_pet162 100316 // ئ +#define SPR_pet163 100317 // ئ +#define SPR_pet164 100318 // ئ + +#define SPR_pet171 100319 // بʾ +#define SPR_pet172 100320 // ʾ +#define SPR_pet173 100321 // +#define SPR_pet174 100322 // + +#define SPR_pet181 100323 // ʯ +#define SPR_pet182 100324 // ͡ +#define SPR_pet183 100325 // +#define SPR_pet184 100326 // ͻ + +#define SPR_pet191 100327 // ìﲼ +#define SPR_pet192 100328 // ì̲ +#define SPR_pet193 100329 // ˵ +#define SPR_pet194 100330 // ƽӡì + +#define SPR_pet201 100331 // ئ +#define SPR_pet202 100332 // ئ +#define SPR_pet203 100333 // ئ +#define SPR_pet204 100334 // ئ + +#define SPR_pet211 100335 // +#define SPR_pet212 100336 // ʸ +#define SPR_pet213 100337 // ¡ +#define SPR_pet214 100338 // + +#define SPR_pet221 100339 // +#define SPR_pet222 100340 // Һ +#define SPR_pet223 100341 // ҡ +#define SPR_pet224 100342 // + +#define SPR_pet231 100343 // ײ +#define SPR_pet232 100344 // ס +#define SPR_pet233 100345 // ײʾ +#define SPR_pet234 100346 // ׼ʾ + +#define SPR_pet241 100347 // ɡƽ +#define SPR_pet242 100348 // ة̡ +#define SPR_pet243 100349 // ʾ +#define SPR_pet244 100350 // ̡ + +#define SPR_pet251 100351 // Ƥ +#define SPR_pet252 100352 // Ƥ +#define SPR_pet253 100353 // Ƥƽ +#define SPR_pet254 100354 // + +#define SPR_pet261 100355 // Ѩƹ +#define SPR_pet262 100356 // ƹƹ +#define SPR_pet263 100357 // Ѩƹϵ +#define SPR_pet264 100358 // Ѩƹ + +#define SPR_pet271 100359 // ´ +#define SPR_pet272 100360 // ò +#define SPR_pet273 100361 // +#define SPR_pet274 100362 // ⵩ + +#define SPR_pet281 100363 // ئ +#define SPR_pet282 100364 // ئ +#define SPR_pet283 100365 // ئ +#define SPR_pet284 100366 // ئ + +#define SPR_pet291 100367 // ƽ +#define SPR_pet292 100368 // ͷ +#define SPR_pet293 100369 // ʯ +#define SPR_pet294 100370 // ƽūʾ + +#define SPR_pet301 100371 // 󲼷 +#define SPR_pet302 100372 // ūõ +#define SPR_pet303 100373 // ¼ +#define SPR_pet304 100374 // + +#define SPR_pet311 100375 // +#define SPR_pet312 100376 // ƹˡ +#define SPR_pet313 100377 // ʯ +#define SPR_pet314 100378 // ʯ + +#define SPR_pet321 100379 // ³ +#define SPR_pet322 100380 // Ƕ +#define SPR_pet323 100381 // ʧõ +#define SPR_pet324 100382 // ĸ÷ +#define SPR_pet325 100383 // + +#define SPR_pet331 100384 // ͵ +#define SPR_pet332 100385 // ¼ìﵩ +#define SPR_pet333 100386 // +#define SPR_pet334 100387 // á + +// ޥܰʸ +#define SPR_pet005 100388 // Ļ +#define SPR_pet085 100389 // е +#define SPR_pet086 100390 // +#define SPR_pet087 100391 // Ƥҵ +#define SPR_pet088 100392 // ʧʧ +#define SPR_pet065 100393 // +#define SPR_pet095 100394 // δ +#define SPR_pet175 100395 // بʾ +#define SPR_pet255 100396 // Ƥ + +// ޥܰƽҷ +#define SPR_121em 100400 // ʧ׷ +#define SPR_121ax 100401 // +#define SPR_121cl 100402 // +#define SPR_121sp 100403 // +#define SPR_121bw 100404 // + +#define SPR_122em 100405 // ʧ׷ +#define SPR_122ax 100406 // +#define SPR_122cl 100407 // +#define SPR_122sp 100408 // +#define SPR_122bw 100409 // + +#define SPR_123em 100410 // ʧ׷ +#define SPR_123ax 100411 // +#define SPR_123cl 100412 // +#define SPR_123sp 100413 // +#define SPR_123bw 100414 // + +#define SPR_124em 100415 // ʧ׷ +#define SPR_124ax 100416 // +#define SPR_124cl 100417 // +#define SPR_124sp 100418 // +#define SPR_124bw 100419 // + +#define SPR_131em 100420 // +#define SPR_131ax 100421 // +#define SPR_131cl 100422 // +#define SPR_131sp 100423 // +#define SPR_131bw 100424 // + +#define SPR_132em 100425 // +#define SPR_132ax 100426 // +#define SPR_132cl 100427 // +#define SPR_132sp 100428 // +#define SPR_132bw 100429 // + +#define SPR_pet315 100430 // ɼĸʯ + +#define SPR_141em 100431 // ؼϨ +#define SPR_141ax 100432 // +#define SPR_141cl 100433 // +#define SPR_141sp 100434 // +#define SPR_141bw 100435 // + +#define SPR_142em 100436 // ؼϨ +#define SPR_142ax 100437 // +#define SPR_142cl 100438 // +#define SPR_142sp 100439 // +#define SPR_142bw 100440 // + +#define SPR_133em 100441 // +#define SPR_133ax 100442 // +#define SPR_133cl 100443 // +#define SPR_133sp 100444 // +#define SPR_133bw 100445 // + +#define SPR_151em 100446 // Ԩ +#define SPR_151ax 100447 // +#define SPR_151cl 100448 // +#define SPR_151sp 100449 // +#define SPR_151bw 100450 // + +#define SPR_152em 100451 +#define SPR_152ax 100452 +#define SPR_152cl 100453 +#define SPR_152sp 100454 +#define SPR_152bw 100455 + +#define SPR_161em 100456 // Ԩ +#define SPR_161ax 100457 // +#define SPR_161cl 100458 // +#define SPR_161sp 100459 // +#define SPR_161bw 100460 // + +#define SPR_162em 100461 +#define SPR_162ax 100462 +#define SPR_162cl 100463 +#define SPR_162sp 100464 +#define SPR_162bw 100465 + +//ʧ߶ +#define SPR_leader 100500 // ĸѨʧ߶ +#define SPR_star 100501 // ززѨʧ߶ +#define SPR_boomerang 100502 // Ƥ¼ʧ߶ +#define SPR_stornbomb 100503 // ޼ʧ߶ +#define SPR_ono 100504 // ʧ߶ +#define SPR_onokage 100505 // ʧ߶ +#define SPR_isiware 100506 // ľʧ߶ +#define SPR_mail 100507 // ʧ߶ +//ʧ߶ +#define SPR_stone 100550 // ޼ʧ߶ +#define SPR_shock 100551 // ʧ߶ +#define SPR_drunk 100552 // жʧ߶ +#define SPR_sleep 100553 // Իʧ߶ +#define SPR_conf 100554 // ٶʧ߶ +#define SPR_poison 100555 // ʧ߶ +#define SPR_zokusei 100556 // ʧ߶ +//ްʧ߶ +#define SPR_effect01 100600 // ʧ߶ +#define SPR_heal 100601 // ʧ߶ +#define SPR_heal2 100602 // ʧ߶ +#define SPR_heal3 100603 // ʧ߶ +#define SPR_tyusya 100604 // ʧ߶ ټ +#define SPR_hoshi 100605 // ëľ弰ʧ߶ +#define SPR_kyu 100606 // ëľ弰ʧ߶ +#define SPR_fukkatu1 100607 // ëľ弰ʧ߶ +#define SPR_fukkatu2 100608 // ëľ弰ʧ߶ +#define SPR_fukkatu3 100609 // ëľ弰ʧ߶ +#define SPR_difence 100610 // ëľ弰ʧ߶ +#define SPR_item 100611 // ʧ ةë弰ʧ߶ +#define SPR_item3 100612 // ʧ ةë弰ʧ߶ +// ʧ߶ +#define SPR_mirror 100650 // ʧ߶ +#define SPR_barrior 100651 // ʧʧ߶ + +// շ ƥئ ****************************************************/ +#define CG_INVISIBLE 99 // ľƱ ľئ +//#define CG_GRID_CURSOR 99 +#define CG_MOUSE_CURSOR 25000 +#define CG_GRID_CURSOR 25001 + +// ʾ +#define CG_BTL_BUTTON_ATTACK_UP 25100 +#define CG_BTL_BUTTON_ATTACK_DOWN 25101 +#define CG_BTL_BUTTON_JUJUTU_UP 25102 +#define CG_BTL_BUTTON_JUJUTU_DOWN 25103 +#define CG_BTL_BUTTON_CAPTURE_UP 25104 +#define CG_BTL_BUTTON_CAPTURE_DOWN 25105 +#define CG_BTL_BUTTON_HELP_UP 25106 +#define CG_BTL_BUTTON_HELP_DOWN 25107 +#define CG_BTL_BUTTON_GUARD_UP 25108 +#define CG_BTL_BUTTON_GUARD_DOWN 25109 +#define CG_BTL_BUTTON_ITEM_UP 25110 +#define CG_BTL_BUTTON_ITEM_DOWN 25111 +#define CG_BTL_BUTTON_PET_UP 25112 +#define CG_BTL_BUTTON_PET_DOWN 25113 +#define CG_BTL_BUTTON_ESCAPE_UP 25114 +#define CG_BTL_BUTTON_ESCAPE_DOWN 25115 +#define CG_BTL_BUTTON_BASE 25116 // ʾܽ +#define CG_BTL_BUTTON_CROSS 25117 // ʾ + +// ʧ +#define CG_ATR_ICON_EARTH_BIG 25120 // +#define CG_ATR_ICON_EARTH_MDL 25121 // +#define CG_ATR_ICON_EARTH_SML 25122 // +#define CG_ATR_ICON_WATER_BIG 25123 // +#define CG_ATR_ICON_WATER_MDL 25124 // +#define CG_ATR_ICON_WATER_SML 25125 // +#define CG_ATR_ICON_FIRE_BIG 25126 // ܣ +#define CG_ATR_ICON_FIRE_MDL 25127 // ܣ +#define CG_ATR_ICON_FIRE_SML 25128 // ܣ +#define CG_ATR_ICON_WIND_BIG 25129 // 뮣 +#define CG_ATR_ICON_WIND_MDL 25130 // 뮣 +#define CG_ATR_ICON_WIND_SML 25131 // 뮣 + +// ʧ +#define CG_ATR_ICON_EARTH_BATTLE 25132 // +#define CG_ATR_ICON_WATER_BATTLE 25133 // +#define CG_ATR_ICON_FIRE_BATTLE 25134 // ܣ +#define CG_ATR_ICON_WIND_BATTLE 25135 // 뮣 + +// ʸʾ +#define CG_PET_BTL_BUTTON_BASE 25140 // ʾܽ +#define CG_PET_BTL_BUTTON_WAZA_UP 25141 // ʾ +#define CG_PET_BTL_BUTTON_WAZA_DOWN 25142 // ʾ +#define CG_PET_BTL_BUTTON_CANCEL_UP 25143 // ƽҼʾ + +// Ѩ +#define CG_HIT_MARK_00 25500 // +#define CG_HIT_MARK_01 25501 // + +#define CG_HIT_MARK_10 25502 // +#define CG_HIT_MARK_11 25503 +#define CG_HIT_MARK_12 25504 + +#define CG_HIT_MARK_20 25505 // ձ +#define CG_HIT_MARK_21 25506 +#define CG_HIT_MARK_22 25507 + +#define CG_HIT_MARK_30 25508 // +#define CG_HIT_MARK_31 25509 +#define CG_HIT_MARK_32 25510 + +#define CG_HIT_MARK_40 25511 // +#define CG_HIT_MARK_41 25512 +#define CG_HIT_MARK_42 25513 + +// +#define CG_SPEECH_BTL_OK 25520 +#define CG_SPEECH_CHANGE 25521 +#define CG_SPEECH_GROUP 25522 +#define CG_SPEECH_SUCCESS 25523 +#define CG_SPEECH_YATTA 25524 +#define CG_SPEECH_HELP 25525 + +// ޼Ѩ +#define CG_VS_MARK_1A 25610 +#define CG_VS_MARK_1B 25611 +#define CG_VS_MARK_2A 25612 +#define CG_VS_MARK_2B 25613 +#define CG_VS_MARK_3A 25614 +#define CG_VS_MARK_3B 25615 +#define CG_VS_MARK_4A 25616 +#define CG_VS_MARK_4B 25617 +#define CG_VS_MARK_5A 25618 +#define CG_VS_MARK_5B 25619 +#define CG_VS_MARK_6A 25620 +#define CG_VS_MARK_6B 25621 +#define CG_VS_MARK_7A 25622 +#define CG_VS_MARK_7B 25623 +#define CG_VS_MARK_8A 25624 +#define CG_VS_MARK_8B 25625 +#define CG_VS_MARK_9A 25626 +#define CG_VS_MARK_9B 25627 +#define CG_VS_MARK_10A 25628 +#define CG_VS_MARK_10B 25629 + +// +#define CG_ARROW_00 25630 +#define CG_ARROW_01 25631 +#define CG_ARROW_02 25632 +#define CG_ARROW_03 25633 +#define CG_ARROW_04 25634 +#define CG_ARROW_05 25635 +#define CG_ARROW_06 25636 +#define CG_ARROW_07 25637 +#define CG_ARROW_08 25638 +#define CG_ARROW_09 25639 +#define CG_ARROW_10 25640 +#define CG_ARROW_11 25641 +#define CG_ARROW_12 25642 +#define CG_ARROW_13 25643 +#define CG_ARROW_14 25644 +#define CG_ARROW_15 25645 + +// ĸٯ +#define CG_CNT_DOWN_0 25900 +#define CG_CNT_DOWN_1 25901 +#define CG_CNT_DOWN_2 25902 +#define CG_CNT_DOWN_3 25903 +#define CG_CNT_DOWN_4 25904 +#define CG_CNT_DOWN_5 25905 +#define CG_CNT_DOWN_6 25906 +#define CG_CNT_DOWN_7 25907 +#define CG_CNT_DOWN_8 25908 +#define CG_CNT_DOWN_9 25909 + +// ū +#define CG_WND_G_0 26001 +#define CG_WND_G_1 26002 +#define CG_WND_G_2 26003 +#define CG_WND_G_3 26004 +#define CG_WND_G_4 26005 +#define CG_WND_G_5 26006 +#define CG_WND_G_6 26007 +#define CG_WND_G_7 26008 +#define CG_WND_G_8 26009 + +// ū +#define CG_WND_TITLE_SYSTEM 26010 +#define CG_WND_TITLE_LOGOUT 26011 +#define CG_WND_TITLE_CHAT 26015 +#define CG_WND_TITLE_BGM 26016 +#define CG_WND_TITLE_SE 26017 +#define CG_WND_TITLE_RESULT 26018 + +// +#define CG_TASK_BAR_BACK 26012 + +// ݼ +#define CG_BATTLE_BAR_PLAYER 26013 // +#define CG_BATTLE_BAR_PLAYER_2 26019 // +#define CG_BATTLE_BAR_PET 26014 // ְ +#define CG_BATTLE_BAR_PET_2 26020 // ʸ + +// ū +#define CG_WND2_G_0 26021 +#define CG_WND2_G_1 26022 +#define CG_WND2_G_2 26023 +#define CG_WND2_G_3 26024 +#define CG_WND2_G_4 26025 +#define CG_WND2_G_5 26026 +#define CG_WND2_G_6 26027 +#define CG_WND2_G_7 26028 +#define CG_WND2_G_8 26029 + +// ū +#define CG_WND3_G_7 26037 // Ʊģ ٯë +#define CG_WND3_G_8 26038 +#define CG_WND3_G_9 26039 + +// ū +#define CG_BTL_PET_CHANGE_WND 26040 // ݼʸ ľ׸ū +#define CG_BTL_PET_RETURN_BTN 26041 // ݼʸ ʾ + +// ʾ +#define CG_CLOSE_BTN 26042 // Ԫʾ +#define CG_RETURN_BTN 26043 // ʾ +#define CG_OK_BTN 26093 // ʾ +#define CG_CANCEL_BTN 26050 // ƽҼʾ + +#define CG_YES_BTN 26094 // ""ʾ +#define CG_NO_BTN 26095 // ""ʾ +#define CG_EXIT_BTN 26096 // ""ʾ +#define CG_SEAL_BTN 26097 // ""ʾ +#define CG_BUY_BTN 26098 // ""ʾ + +// ʸū +#define CG_PET_WND_VIEW 26044 // ʸ ū +#define CG_PET_WND_DETAIL 26045 // ʸū + +#define CG_PET_WND_WAZA_BTN 26046 // ʾ +//#define CG_PREV_BTN 26047 // Ի׸ʾ +//#define CG_NEXT_BTN 26048 // ݱԻ׸ʾ +#define CG_NAME_CHANGE_WND 26049 // ū +//#define CG_NAME_CHANGE_BTN 26051 // ʾ +#define CG_NAME_CHANGE_BTN 26058 // ʾ +#define CG_NAME_CHANGE_BTN_DOWN 26059 // ʾ + +#define CG_PET_WND_REST_BTN 26052 // ʸʾ +#define CG_PET_WND_STANDBY_BTN 26053 // ʸʾ +#define CG_PET_WND_BTL_BTN 26054 // ʸʾ +#define CG_PET_WND_MAIL_BTN 26055 // ʸʾ +#define CG_PET_WND_STATUS_BTN 26056 // ʸʾ + + +// ʧ ةū +#define CG_ITEM_WND_0 26060 // ʧ ةū +#define CG_ITEM_WND_1 26061 // ʧ ةūƱ +#define CG_ITEM_WND_GOLD_DROP_BTN_UP 26062 // ʾ +#define CG_ITEM_WND_GOLD_DROP_BTN_DOWN 26063 // ʾ +#define CG_ITEM_WND_GOLD_INC_BTN_UP 26064 // ֧ʾ +#define CG_ITEM_WND_GOLD_INC_BTN_DOWN 26065 // ֧ʾ +#define CG_ITEM_WND_GOLD_DEC_BTN_UP 26066 // Ӽʾ +#define CG_ITEM_WND_GOLD_DEC_BTN_DOWN 26067 // Ӽʾ +#define CG_JUJUTU_WND 26068 // ū +#define CG_ITEM_WND_JUJUTU_BTN 26069 // ʧ ةūʾ +#define CG_ITEM_WND_SELECT_WND 26070 // ū +#define CG_STATUS_WND_GROUP_WND 26071 // ū +#define CG_BTL_ITEM_WND_TITLE 26072 // ݼʧ ةū + +// ū +#define CG_STATUS_WND 26073 // ū +#define CG_STATUS_WND_VICTORY_MARK 26074 // Ѩ +#define CG_STATUS_WND_LV_UP_POINT 26075 // ìʧ ٯ +#define CG_STATUS_WND_UP_BTN_UP 26076 // ʧʾ +#define CG_STATUS_WND_UP_BTN_DOWN 26077 // ʧʾ +#define CG_STATUS_WND_SHOUGOU_BTN_UP 26078 // įʾ +#define CG_STATUS_WND_SHOUGOU_BTN_DOWN 26079 // įʾ +#define CG_STATUS_WND_GROUP_BTN 26080 // ʾ + +// Ѩū +#define CG_MAP_WND 26081 // Ѩū + +// ū +#define CG_MAIL_WND 26082 // ū +#define CG_MAIL_WND_SEND_WND 26200 // ˪ū +#define CG_MAIL_WND_PET_SEND_WND 26201 // ʸ˪ū +#define CG_MAIL_WND_ITEM_BTN 26202 // ʧ ةʾ +#define CG_MAIL_WND_HISTORY_WND 26203 // ū + +//#define CG_MAIL_WND_MAIL_BTN 26083 // ʾ +#define CG_MAIL_WND_ON_LINE_SUN_BTN 26084 // ̼ʾ +#define CG_MAIL_WND_ON_LINE_MOON_BTN 26088 // ̼ʾ +#define CG_MAIL_WND_OFF_LINE_BTN 26085 // ̼ʾ +#define CG_MAIL_WND_MAIL_BTN 26086 // ʾ +#define CG_MAIL_WND_DELETE_BTN 26087 // ʾ +#define CG_MAIL_WND_CLEAR_BTN_UP 26172 // ʧʾ +#define CG_MAIL_WND_CLEAR_BTN_DOWN 26173 // ʧʾ +#define CG_SEND_BTN 26099 // ""ʾ +#define CG_SEND_BTN_DOWN 26174 // ""ʾ + +// ʧةū +#define CG_ALBUM_WND 26230 // ʧةū +#define CG_ALBUM_WND_NEW_ICON 26231 // ޥʧ +#define CG_ALBUM_WND_SNAP_BTN_UP 26170 // ީë +#define CG_ALBUM_WND_SNAP_BTN_DOWN 26171 // ީë + +// ٯ ū +#define CG_CHAT_REGISTY_WND 26232 + +// ٯ Ի ū +#define CG_COMMON_WIN_YORO 26090 // ""̤ľū +#define CG_COMMON_YES_BTN 26091 // ʾ +#define CG_COMMON_NO_BTN 26092 // ʾ + +// ū ʾ +#define CG_FIELD_MENU_LEFT 26100 // +#define CG_FIELD_MENU_BTN_OFF 26101 // بʾ +#define CG_FIELD_MENU_BTN_ON 26102 // بʾ +#define CG_FIELD_CARD_BTN_OFF 26103 // ͭʾ +#define CG_FIELD_CARD_BTN_ON 26104 // ͭʾ +#define CG_FIELD_GROUP_BTN_OFF 26105 // ʾ +#define CG_FIELD_GROUP_BTN_ON 26106 // ʾ +#define CG_FIELD_MAIL_LAMP 26107 // ﰾ¼ +#define CG_FIELD_MENU_RIGHT 26110 // +#define CG_FIELD_JOIN_BTL_BTN_OFF 26111 // ʾ +#define CG_FIELD_JOIN_BTL_BTN_ON 26112 // ʾ +#define CG_FIELD_DUEL_BTN_OFF 26113 // ʾ +#define CG_FIELD_DUEL_BTN_ON 26114 // ʾ +#define CG_FIELD_ACT_BTN_OFF 26115 // ʧʾ +#define CG_FIELD_ACT_BTN_ON 26116 // ʧʾ +#define CG_FIELD_AM_PM_00 26117 // ƻ °ū +#define CG_FIELD_AM_PM_01 26118 // ƻ °ū +#define CG_FIELD_AM_PM_02 26119 // ƻ °ū +#define CG_FIELD_AM_PM_03 26120 // ƻ °ū +#define CG_FIELD_MENU_RIGHT_BACK 26121 // 缰 + +// ʸ ū +#define CG_PET_WAZA_WND 26130 +#define CG_PET_WAZA_BAR_1 26131 +#define CG_PET_WAZA_BAR_2 26132 +#define CG_PET_WAZA_BAR_3 26133 +#define CG_PET_WAZA_BAR_4 26134 +#define CG_PET_WAZA_BAR_5 26135 +#define CG_PET_WAZA_BAR_6 26136 +#define CG_PET_WAZA_BAR_7 26137 + +// ʧ ةū +#define CG_ITEMSHOP_WIN 26138 + +// ū +#define CG_SKILLSHOP_WIN 26139 + +// 继 ū +#define CG_ITEMSHOP_KOSU_WIN 26140 + +// ʾ +#define CG_TASK_BAR_MAP_UP 26150 +#define CG_TASK_BAR_MAP_DOWM 26151 +#define CG_TASK_BAR_STATUS_UP 26152 +#define CG_TASK_BAR_STATUS_DOWN 26153 +#define CG_TASK_BAR_PET_UP 26154 +#define CG_TASK_BAR_PET_DOWN 26155 +#define CG_TASK_BAR_ITEM_UP 26156 +#define CG_TASK_BAR_ITEM_DOWN 26157 +#define CG_TASK_BAR_MAIL_UP 26158 +#define CG_TASK_BAR_MAIL_DOWN 26159 +#define CG_TASK_BAR_ALBUM_UP 26160 +#define CG_TASK_BAR_ALBUM_DOWN 26161 +#define CG_TASK_BAR_SYSTEM_UP 26162 +#define CG_TASK_BAR_SYSTEM_DOWN 26163 + +// ʾ +#define CG_PREV_BTN 26180 // ʾ +#define CG_PREV_BTN_DOWN 26181 // ʾ +#define CG_NEXT_BTN 26182 // ʾ +#define CG_NEXT_BTN_DOWN 26183 // ʾ + +#define CG_PREV_BTN2 26184 // ʾ +#define CG_PREV_BTN2_DOWN 26185 // ʾ +#define CG_NEXT_BTN2 26186 // ʾ +#define CG_NEXT_BTN2_DOWN 26187 // ʾ + +#define CG_UP_BTN 26188 // ʾ +#define CG_UP_BTN_DOWN 26189 // ʾ +#define CG_DOWN_BTN 26190 // ʾ +#define CG_DOWN_BTN_DOWN 26191 // ʾ + + +// ʧ +#define CG_ICON_FUKIDASI 26500 // +#define CG_ICON_COME_ON 26501 // Come On! +#define CG_ICON_GO 26502 // Go! +#define CG_ICON_WATCHING 26503 // Watching +#define CG_ICON_MISS 26504 // Miss... +#define CG_ICON_FAIL 26505 // Fail... +#define CG_ICON_GET 26506 // Get!! +#define CG_ICON_COUNTER 26507 // Counter! +#define CG_ICON_DANGER 26508 // Danger! +#define CG_ICON_NO 26509 // No! +#define CG_ICON_GUARD 26510 // Guard! +#define CG_ICON_ESCAPE 26511 // Escape! +#define CG_ICON_CAPTURE 26512 // Capture! +#define CG_ICON_LEAVE 26513 // Leave! +#define CG_ICON_GUARD_BREAK 26514 // Guard Break! + +// ʸӿ ƺ°ū +#define CG_NOW_PAINTING 28999 + +// +#define CG_LOGO 29000 +#define CG_TITLE 29001 +#define CG_TITLE_NAME_S 29002 +#define CG_TITLE_NAME_T 29003 +#define CG_TITLE_NAME_O 29004 +#define CG_TITLE_NAME_N 29005 +#define CG_TITLE_NAME_E 29006 +#define CG_TITLE_NAME_A 29007 +#define CG_TITLE_NAME_G 29008 +#define CG_TITLE_NAME_E2 29009 +#define CG_TITLE_NAME 29010 +#define CG_TITLE_NAME_FLASH 29011 +#define CG_TITLE_NAME_FLASH1 29012 +#define CG_TITLE_NAME_FLASH2 29013 +#define CG_TITLE_NAME_FLASH3 29014 +#define CG_TITLE_NAME_FLASH4 29015 +#define CG_TITLE_NAME_FLASH5 29016 +#define CG_TITLE_JSS_LOGO 29017 +#define CG_TITLE_DREAM_LOGO 29018 +#define CG_TITLE_NOW_LOADING 29019 +#define CG_TITLE_ID_PASS 29020 +#define CG_TITLE_ID_PASS_OK 29021 +#define CG_TITLE_ID_PASS_QUIT 29022 + +// ƽҷ +#define CG_CHR_MAKE_SEL_BG 29030 // ޥƽҷ¼ +#define CG_CHR_MAKE_BG 29031 // ޥƽҷɷ¶Ի +#define CG_CHR_SEL_BG 29032 // ƽҷ +#define CG_CHR_SEL_LOGIN_BTN 29033 // ̼ʾ +#define CG_CHR_SEL_NEW_BTN 29034 // ޥʾ +#define CG_CHR_SEL_DEL_BTN 29035 // ʾ +#define CG_CHR_SEL_BACK_BTN 29036 // ʾ +#define CG_CHR_MAKE_OK_BTN 29037 // ޥƽҷ ʾ +#define CG_CHR_MAKE_BACK_BTN 29038 // ޥƽҷ ʾ +#define CG_CHR_MAKE_SEL2_BG 29039 // 컩 +#define CG_CHR_MAKE_HOME_NAME0 29040 // 컩 ة׻P̣ +#define CG_CHR_MAKE_HOME_NAME1 29041 // 컩 Ѩϵ̣ +#define CG_CHR_MAKE_HOME_NAME2 29042 // 컩 ҳҼ̣ +#define CG_CHR_MAKE_HOME_NAME3 29043 // 컩 лϼ̣ +#define CG_CHR_MAKE_EYE_SEL 29044 // ޥƽҷ +#define CG_CHR_MAKE_NOSE_SEL 29045 // ޥƽҷ +#define CG_CHR_MAKE_FACE 30000 // ƽҷӿ 쫷 + +#endif diff --git a/include/attestation.h b/include/attestation.h new file mode 100644 index 0000000..7d521b4 --- /dev/null +++ b/include/attestation.h @@ -0,0 +1,6 @@ +#ifndef __ATTESTATION_H__ +#define __ATTESTATION_H__ + +int attestation( void ); + +#endif diff --git a/include/autil.h b/include/autil.h new file mode 100644 index 0000000..cf4ca47 --- /dev/null +++ b/include/autil.h @@ -0,0 +1,57 @@ +#include "version.h" +#include "common.h" + +#ifndef __UTIL_H_ +#define __UTIL_H_ + + +#define SLICE_MAX 20 +#define SLICE_SIZE 65500 + +extern char *MesgSlice[SLICE_MAX]; +extern int SliceCount; // count slices in MesgSlice + +extern char PersonalKey[4096]; + +#define DEFAULTTABLE \ + "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz{}" +#define DEFAULTFUNCBEGIN "&" +#define DEFAULTFUNCEND "#" + +BOOL util_Init(void); + +// WON ADD +//void util_SplitMessage(char *source, char *separator); +BOOL util_SplitMessage(char *source, char *separator); + + +void util_EncodeMessage(char *dst, char *src); +void util_DecodeMessage(char *dst, char *src); +int util_GetFunctionFromSlice(int *func, int *fieldcount); +void util_DiscardMessage(void); +#define util_SendMesg( fd, func, buffer) _util_SendMesg( __FILE__, __LINE__, fd, func, buffer) +void _util_SendMesg(char *file, int line, int fd, int func, char *buffer); + +// ------------------------------------------------------------------- +// Encoding function units. Use in Encrypting functions. +int util_256to64(char *dst, char *src, int len, char *table); +int util_64to256(char *dst, char *src, char *table); +int util_256to64_shr(char *dst, char *src, int len, char *table, char *key); +int util_shl_64to256(char *dst, char *src, char *table, char *key); +int util_256to64_shl(char *dst, char *src, int len, char *table, char *key); +int util_shr_64to256(char *dst, char *src, char *table, char *key); + +void util_swapint(int *dst, int *src, char *rule); +void util_xorstring(char *dst, char *src); +void util_shrstring(char *dst, char *src, int offs); +void util_shlstring(char *dst, char *src, int offs); +// ------------------------------------------------------------------- +// Encrypting functions +int util_deint(int fd,int sliceno, int *value); +int util_mkint(int fd,char *buffer, int value); +int util_destring(int fd,int sliceno, char *value); +int util_mkstring(int fd,char *buffer, char *value); +#ifdef _FIX_LSSP_S_BUG +int is_digit(char *str); +#endif +#endif diff --git a/include/battle.h b/include/battle.h new file mode 100644 index 0000000..46a8511 --- /dev/null +++ b/include/battle.h @@ -0,0 +1,788 @@ +#ifndef __BATTLE_H__ +#define __BATTLE_H__ +#include "net.h" + +#ifdef _ALLBLUES_LUA_1_4 +#include "lua.h" +#include "lauxlib.h" +#include "lualib.h" +#endif + +#define BATTLE_ENTRY_MAX 10 +#define BATTLE_PLAYER_MAX 5 +#define SIDE_OFFSET 10 + +#define BATTLE_STRING_MAX 4096 +#define BATTLE_TIME_LIMIT (60*60) + + +#define DUELPOINT_RATE (0.1) + +enum{ + BATTLE_MODE_NONE = 0, // ս״̬ + BATTLE_MODE_INIT, // սʼ + BATTLE_MODE_BATTLE, // ս + BATTLE_MODE_FINISH, // ս + BATTLE_MODE_STOP, // ս(δʹ) + BATTLE_MODE_WATCHBC, // սʼ + BATTLE_MODE_WATCHPRE, // ս(û) + BATTLE_MODE_WATCHWAIT, // ս(û) + BATTLE_MODE_WATCHMOVIE, // ս(û) + BATTLE_MODE_WATCHAFTER, // ս(û) + BATTLE_MODE_END +}; + + +enum{ + BATTLE_TYPE_NONE = 0, + BATTLE_TYPE_P_vs_E = 1, + BATTLE_TYPE_P_vs_P = 2, + BATTLE_TYPE_E_vs_E = 3, + BATTLE_TYPE_WATCH = 4, + BATTLE_TYPE_DP_BATTLE = 5, + BATTLE_TYPE_BOSS_BATTLE = 6, + BATTLE_TYPE_END +}; + + +enum{ + BATTLE_CHARMODE_NONE = 0, // ս״̬ + BATTLE_CHARMODE_INIT, // սʼ + BATTLE_CHARMODE_C_WAIT, // ȴսָ + BATTLE_CHARMODE_C_OK, // սָ + BATTLE_CHARMODE_BATTLE, // δʹ + BATTLE_CHARMODE_RESCUE, // help״̬ + BATTLE_CHARMODE_FINAL, // ս + BATTLE_CHARMODE_WATCHINIT, // սʼ + BATTLE_CHARMODE_COMMAND, // δʹ + BATTLE_CHARMODE_END +}; + + + + +typedef enum{ + BATTLE_ERR_NONE = 0, + BATTLE_ERR_NOTASK, + BATTLE_ERR_NOUSE, + BATTLE_ERR_PARAM, + BATTLE_ERR_ENTRYMAX, + BATTLE_ERR_TYPE, + BATTLE_ERR_CHARAINDEX, + BATTLE_ERR_BATTLEINDEX, + BATTLE_ERR_NOENEMY, + BATTLE_ERR_ALREADYBATTLE, + BATTLE_ERR_SAMEPARTY, + BATTLE_ERR_END +}BATTLE_ERR; + + +enum{ + BATTLE_S_TYPE_PLAYER = 0, + BATTLE_S_TYPE_ENEMY, + BATTLE_S_TYPE_END +}; + + +typedef enum{ + BATTLE_COM_NONE, + BATTLE_COM_ATTACK, + BATTLE_COM_GUARD, + BATTLE_COM_CAPTURE, + BATTLE_COM_ESCAPE, + BATTLE_COM_PETIN, + BATTLE_COM_PETOUT, + BATTLE_COM_ITEM, + BATTLE_COM_BOOMERANG, + BATTLE_COM_COMBO, + BATTLE_COM_COMBOEND, + BATTLE_COM_WAIT, + + BATTLE_COM_SEKIBAN = 1000, + BATTLE_COM_S_RENZOKU, + BATTLE_COM_S_GBREAK, + BATTLE_COM_S_GUARDIAN_ATTACK, + BATTLE_COM_S_GUARDIAN_GUARD, + BATTLE_COM_S_CHARGE, + BATTLE_COM_S_MIGHTY, + BATTLE_COM_S_POWERBALANCE, + BATTLE_COM_S_STATUSCHANGE, + BATTLE_COM_S_EARTHROUND0, + BATTLE_COM_S_EARTHROUND1, + BATTLE_COM_S_LOSTESCAPE, + BATTLE_COM_S_ABDUCT, + BATTLE_COM_S_STEAL, + BATTLE_COM_S_NOGUARD, + BATTLE_COM_S_CHARGE_OK, + BATTLE_COM_JYUJYUTU = 2000, + + BATTLE_COM_COMPELESCAPE, //ǿ뿪 + +#ifdef _ATTACK_MAGIC + BATTLE_COM_S_ATTACK_MAGIC, // ħ +#endif + +#ifdef _PSKILL_FALLGROUND + BATTLE_COM_S_FALLRIDE, // +#endif +#ifdef _PETSKILL_TIMID + BATTLE_COM_S_TIMID, +#endif +#ifdef _PETSKILL_2TIMID + BATTLE_COM_S_2TIMID, +#endif +#ifdef _PETSKILL_ANTINTER + BATTLE_COM_S_ANTINTER, +#endif +#ifdef _PETSKILL_PROPERTY + BATTLE_COM_S_PROPERTYSKILL, +#endif +#ifdef _PETSKILL_TEAR + BATTLE_COM_S_PETSKILLTEAR, +#endif +#ifdef _BATTLE_LIGHTTAKE + BATTLE_COM_S_LIGHTTAKE, +#endif +#ifdef _BATTLE_ATTCRAZED // ANDY + BATTLE_COM_S_ATTCRAZED, +#endif +#ifdef _SHOOTCHESTNUT // Syu ADD 輼 + BATTLE_COM_S_ATTSHOOT, +#endif +#ifdef _BATTLESTEAL_FIX + BATTLE_COM_S_STEALMONEY, +#endif +#ifdef _PRO_BATTLEENEMYSKILL + BATTLE_COM_S_ENEMYRELIFE, //NPC ENEMY  + BATTLE_COM_S_ENEMYREHP, //NPC ENEMY Ѫ + BATTLE_COM_S_ENEMYHELP, //NPC ENEMY +#endif +#ifdef _SKILL_DAMAGETOHP + BATTLE_COM_S_DAMAGETOHP, //Ѫ +#endif +#ifdef _Skill_MPDAMAGE + BATTLE_COM_S_MPDAMAGE, //MP˺ +#endif +#ifdef _SKILL_WILDVIOLENT_ATT + BATTLE_COM_S_WILDVIOLENTATTACK, //񱩹 vincent add 2002/05/16 +#endif + +#ifdef _SKILL_SPEEDY_ATT + BATTLE_COM_S_SPEEDYATTACK, //ٹ vincent add 2002/05/20 +#endif +#ifdef _SKILL_GUARDBREAK2 + BATTLE_COM_S_GBREAK2, //Ƴ2 vincent add 2002/05/20 +#endif +#ifdef _SKILL_SACRIFICE + BATTLE_COM_S_SACRIFICE, //Ԯ vincent add 2002/05/30 +#endif +#ifdef _SKILL_WEAKEN + BATTLE_COM_S_WEAKEN, // vincent add 2002/07/11 +#endif +#ifdef _SKILL_DEEPPOISON + BATTLE_COM_S_DEEPPOISON, //綾 vincent add 2002/07/16 +#endif +#ifdef _SKILL_BARRIER + BATTLE_COM_S_BARRIER, //ħ vincent add 2002/07/16 +#endif +#ifdef _SKILL_NOCAST + BATTLE_COM_S_NOCAST, //Ĭ vincent add 2002/07/16 +#endif +#ifdef _SKILL_ROAR + BATTLE_COM_S_ROAR, // vincent add 2002/07/11 +#endif +#ifdef _BATTLENPC_WARP_PLAYER + BATTLE_COM_WARP, // npc warp player +#endif +#ifdef _SKILL_TOOTH + BATTLE_COM_S_TOOTHCRUSHE, +#endif +#ifdef _PSKILL_MODIFY + BATTLE_COM_S_MODIFYATT, +#endif +#ifdef _PSKILL_MDFYATTACK + BATTLE_COM_S_MDFYATTACK, +#endif +#ifdef _MAGIC_SUPERWALL + BATTLE_COM_S_SUPERWALL, +#endif +#ifdef _SKILL_REFRESH + BATTLE_COM_S_REFRESH, +#endif +#ifdef _VARY_WOLF + BATTLE_COM_S_VARY, +#endif +#ifdef _PETSKILL_SETDUCK + BATTLE_COM_S_SETDUCK, +#endif +#ifdef _MAGICPET_SKILL + BATTLE_COM_S_SETMAGICPET, +#endif +#ifdef _PROFESSION_SKILL // WON ADD ְҵ + +// ʦ + BATTLE_COM_S_VOLCANO_SPRINGS, // ɽȪ + BATTLE_COM_S_FIRE_BALL, // + BATTLE_COM_S_FIRE_SPEAR, // ǹ + BATTLE_COM_S_SUMMON_THUNDER, // + BATTLE_COM_S_CURRENT, // + BATTLE_COM_S_STORM, // + BATTLE_COM_S_ICE_ARROW, // + BATTLE_COM_S_ICE_CRACK, // + BATTLE_COM_S_ICE_MIRROR, // + BATTLE_COM_S_DOOM, // ĩ + BATTLE_COM_S_BLOOD, // Ѫ + BATTLE_COM_S_BLOOD_WORMS, // Ѫ + BATTLE_COM_S_SIGN, // һѪ + BATTLE_COM_S_FIRE_ENCLOSE, // + BATTLE_COM_S_ICE_ENCLOSE, // + BATTLE_COM_S_THUNDER_ENCLOSE, // ׸ + BATTLE_COM_S_ENCLOSE, // + BATTLE_COM_S_TRANSPOSE, // λλ +// ʿ + BATTLE_COM_S_BRUST, // + BATTLE_COM_S_CHAIN_ATK, // + BATTLE_COM_S_AVOID, // ر + BATTLE_COM_S_RECOVERY, // Ѫ + BATTLE_COM_S_WEAPON_FOCUS, // ר + BATTLE_COM_S_REBACK, // ״̬ظ + BATTLE_COM_S_CHAIN_ATK_2, // ˫ع + BATTLE_COM_S_SCAPEGOAT, // Ϊ + BATTLE_COM_S_ENRAGE, // + BATTLE_COM_S_COLLECT, // ۼ + BATTLE_COM_S_FOCUS, // רעս + BATTLE_COM_S_SHIELD_ATTACK, // ܻ + BATTLE_COM_S_DUAL_WEAPON, // + BATTLE_COM_S_DEFLECT, // + BATTLE_COM_S_THROUGH_ATTACK, // ᴩ + BATTLE_COM_S_CAVALRY, // ﹥ + BATTLE_COM_S_DEAD_ATTACK, // + BATTLE_COM_S_CONVOLUTE, // + BATTLE_COM_S_CHAOS, // ҹ +// + BATTLE_COM_S_TRAP, // + BATTLE_COM_S_TRACK, // ׷Ѱ + BATTLE_COM_S_DOCILE, // ѱ + BATTLE_COM_S_ENRAGE_PET, // ŭ + BATTLE_COM_S_DRAGNET, // ޵ + BATTLE_COM_S_ENTWINE, // + BATTLE_COM_S_AUTARKY, // Ը + BATTLE_COM_S_PLUNDER, // Ӷ + BATTLE_COM_S_TOXIN_WEAPON, // + BATTLE_COM_S_RESIST_FIRE, // + BATTLE_COM_S_RESIST_ICE, // + BATTLE_COM_S_RESIST_THUNDER, // ׿ + BATTLE_COM_S_G_RESIST_FIRE, // + BATTLE_COM_S_G_RESIST_ICE, // + BATTLE_COM_S_G_RESIST_THUNDER, // ׿ + BATTLE_COM_S_ATTACK_WEAK, // 㹥 + BATTLE_COM_S_INSTIGATE, // + BATTLE_COM_S_OBLIVION, // +#ifdef _PROFESSION_ADDSKILL + BATTLE_COM_S_RESIST_F_I_T, // Ȼ + BATTLE_COM_S_CALL_NATURE, // Ȼ + BATTLE_COM_S_BOUNDARY, // Խ +#endif +#endif + +#ifdef _PET_SKILL_SARS // WON ADD ɷ + BATTLE_COM_S_SARS, +#endif +#ifdef _SONIC_ATTACK // WON ADD + BATTLE_COM_S_SONIC, + BATTLE_COM_S_SONIC2, +#endif +#ifdef _PETSKILL_REGRET + BATTLE_COM_S_REGRET, + BATTLE_COM_S_REGRET2, +#endif +#ifdef _PETSKILL_GYRATE + BATTLE_COM_S_GYRATE, +#endif +#ifdef _PETSKILL_ACUPUNCTURE + BATTLE_COM_S_ACUPUNCTURE, +#endif +#ifdef _PETSKILL_RETRACE + BATTLE_COM_S_RETRACE, +#endif +#ifdef _PETSKILL_HECTOR + BATTLE_COM_S_HECTOR, +#endif +#ifdef _PETSKILL_FIREKILL + BATTLE_COM_S_FIREKILL, +#endif +#ifdef _PETSKILL_DAMAGETOHP + BATTLE_COM_S_DAMAGETOHP2, //¿(Ѫı) +#endif +#ifdef _PETSKILL_BECOMEFOX + BATTLE_COM_S_BECOMEFOX, +#endif +#ifdef _PETSKILL_BECOMEPIG + BATTLE_COM_S_BECOMEPIG, +#endif +#ifdef _PETSKILL_SHOWMERCY + BATTLE_COM_S_SHOWMERCY, +#endif +#ifdef _PETSKILL_LER + BATTLE_COM_S_BAT_FLY, // ׶ - ȺĴ + BATTLE_COM_S_DIVIDE_ATTACK, // ׶ - +#endif +#ifdef _PETSKILL_BATTLE_MODEL + BATTLE_COM_S_BATTLE_MODEL, // \սģ +#endif + BATTLE_COM_S_ZIYUN1, +#ifdef _OFFLINE_SYSTEM + BATTLE_COM_S_OFFLINE_RECOVERY, +#endif + + BATTLE_COM_END +}BATTLE_COM; + + +enum{ + BATTLE_RET_NORMAL, + BATTLE_RET_CRITICAL, + BATTLE_RET_MISS, + BATTLE_RET_DODGE, + BATTLE_RET_ALLGUARD, +#ifdef _EQUIT_ARRANGE + BATTLE_RET_ARRANGE, +#endif + BATTLE_RET_END +}BATTLE_RET; + + +#define BC_FLG_NEW (1<<0) +#define BC_FLG_DEAD (1<<1) +#define BC_FLG_PLAYER (1<<2) +#define BC_FLG_POISON (1<<3) +#define BC_FLG_PARALYSIS (1<<4) +#define BC_FLG_SLEEP (1<<5) +#define BC_FLG_STONE (1<<6) +#define BC_FLG_DRUNK (1<<7) +#define BC_FLG_CONFUSION (1<<8) +#define BC_FLG_HIDE (1<<9) +#define BC_FLG_REVERSE (1<<10) +#ifdef _MAGIC_WEAKEN +#define BC_FLG_WEAKEN (1<<11) // +#endif +#ifdef _MAGIC_DEEPPOISON +#define BC_FLG_DEEPPOISON (1<<12) // 綾 +#endif +#ifdef _MAGIC_BARRIER +#define BC_FLG_BARRIER (1<<13) // ħ +#endif +#ifdef _MAGIC_NOCAST +#define BC_FLG_NOCAST (1<<14) // Ĭ +#endif + +#ifdef _PET_SKILL_SARS // WON ADD ɷ +#define BC_FLG_SARS (1<<15) // ɷ +#endif + +#ifdef _PROFESSION_SKILL // WON ADD ְҵ +#define BC_FLG_DIZZY (1<<16) // ѣ +#define BC_FLG_ENTWINE (1<<17) // +#define BC_FLG_DRAGNET (1<<18) // ޵ +#define BC_FLG_ICECRACK (1<<19) // +#define BC_FLG_OBLIVION (1<<20) // +#define BC_FLG_ICEARROW (1<<21) // +#define BC_FLG_BLOODWORMS (1<<22) // Ѫ +#define BC_FLG_SIGN (1<<23) // һѪ +#define BC_FLG_CARY (1<<24) // +#define BC_FLG_F_ENCLOSE (1<<25) // +#define BC_FLG_I_ENCLOSE (1<<26) // +#define BC_FLG_T_ENCLOSE (1<<27) // ׸ +#ifdef _PROFESSION_ADDSKILL +#define BC_FLG_WATER (1<<28) // ˮ +#define BC_FLG_FEAR (1<<29) // ־ +#endif +#ifdef _PETSKILL_LER +#define BC_FLG_CHANGE (1<<30) // ׶ +#endif +#endif + + + + +#define BP_FLG_JOIN (1<<0) +#define BP_FLG_PLAYER_MENU_OFF (1<<1) +#define BP_FLG_BOOMERANG (1<<2) +#define BP_FLG_PET_MENU_OFF (1<<3) +#define BP_FLG_ENEMY_SURPRISAL (1<<4) +#define BP_FLG_PLAYER_SURPRISAL (1<<5) + + +#define CHAR_BATTLEFLG_ULTIMATE (1<<0) +#define CHAR_BATTLEFLG_AIBAD (1<<1) +#define CHAR_BATTLEFLG_REVERSE (1<<2) +#define CHAR_BATTLEFLG_GUARDIAN (1<<3) +#define CHAR_BATTLEFLG_NORETURN (1<<4) +#define CHAR_BATTLEFLG_RECOVERY (1<<5) +#define CHAR_BATTLEFLG_ABIO (1<<6) +#define CHAR_BATTLEFLG_NODUCK (1<<7) + +#define GETITEM_MAX 3 +typedef struct +{ + int attacker; +}INVADER; + +typedef struct +{ + int charaindex; + int bid; + int escape; + int flg; + int guardian; + int duelpoint; + int getitem[GETITEM_MAX]; +}BATTLE_ENTRY; +#define BENT_FLG_ULTIMATE (1<<0) + +typedef struct +{ + int type; + int flg; + int common_dp; + BATTLE_ENTRY Entry[BATTLE_ENTRY_MAX]; +}BATTLE_SIDE; + +#define BSIDE_FLG_SURPRISE ( 1 << 0 ) +#define BSIDE_FLG_HELP_OK ( 1 << 1 ) + +#ifdef _ALLBLUES_LUA_1_4 +typedef enum +{ + BATTLE_FINISH, + BATTLE_ESCAPE, + BATTLE_FUNCTABLENUM, +}BATTLE_FUNCTABLE; +#endif + +//typedef struct _Battle +//{ +// BOOL use; /* Ȼ¾ */ +// int battleindex; /* į */ +// int mode; /* ػ ƹ */ +// int type; /* (0:ɧ)(1:DUEL)(2:ʾ) */ +// int dpbattle; /* DPᆴ */ +// int norisk; /* ƥͼ ᆴ */ +// int turn; /* */ +// int timer; /* Ѩ */ +// int leaderindex; /* ޼ëڳƽҷ¼̼͵ */ +//#ifdef _AUTO_PK +// char leadercdkey[CDKEYLEN]; +// char leadername[CHARNAMELEN]; +// int rivalindex; +// char rivalcdkey[CDKEYLEN]; +// char rivalname[CHARNAMELEN]; +//#endif +// int winside; /* */ +// int field_att; /* ū */ +// int att_count; /* ū Ѩ */ +// int att_pow; /* ū ɷ */ +// int field_no; +// int flg; /* ˰׷º */ +// BATTLE_SIDE Side[2]; +//#ifdef _BATTLE_TIMESPEED +// unsigned int CreateTime; +// unsigned int EndTime; +// unsigned int PartTime; +// int flgTime; +// +//#endif +// +//#ifdef _PROFESSION_ADDSKILL +// // +// int ice_count;//ݴ +// int ice_bout[20];//غϼ +// BOOL ice_use[20];//Ƿʹ +// int ice_toNo[20];// +// int ice_level[20];// +// int ice_array[20]; +// int ice_charaindex[20]; +// int ice_attackNo[20]; +//#endif +// +// int iEntryBack[BATTLE_ENTRY_MAX*2]; // ľ׶ +// int iEntryBack2[BATTLE_ENTRY_MAX*2]; // ľ׶ +// int createindex; /* 𼰾 ëԻƽҷ̼͵(NPCئ) */ +// int (*WinFunc)( int battleindex, int charaindex ); +// struct _Battle *pNext; // ݼ +// struct _Battle *pBefore; // 󡼰 +//}BATTLE; + +typedef struct _Battle +{ + BOOL use; /* Ȼ¾ */ + int battleindex; /* į */ + int mode; /* ػ ƹ */ + int type; /* (0:ɧ)(1:DUEL)(2:ʾ) */ + int dpbattle; /* DPᆴ */ + int norisk; /* ƥͼ ᆴ */ + int turn; /*غ*/ + int timer; /* Ѩ */ + int leaderindex; /* ޼ëڳƽҷ¼̼͵ */ +#ifdef _AUTO_PK + char leadercdkey[CDKEYLEN]; + char leadername[CHARNAMELEN]; + int rivalindex; + char rivalcdkey[CDKEYLEN]; + char rivalname[CHARNAMELEN]; +#endif + int BattleFloor; /* */ + int winside; /* */ + int field_att; /* ū */ + int att_count; /* ū Ѩ */ + int att_pow; /* ū ɷ */ + int field_no; + int flg; /* ˰׷º */ + BATTLE_SIDE Side[2]; +#ifdef _BATTLE_TIMESPEED + unsigned int CreateTime; + unsigned int EndTime; + unsigned int PartTime; + int flgTime; + +#endif + +#ifdef _PROFESSION_ADDSKILL + // + int ice_count;//ݴ + int ice_bout[20];//غϼ + BOOL ice_use[20];//Ƿʹ + int ice_toNo[20];// + int ice_level[20];// + int ice_array[20]; + int ice_charaindex[20]; + int ice_attackNo[20]; +#endif + +#ifdef _DEATH_CONTEND + int menum; + int tonum; +#endif + +#ifdef _ACTION_BULLSCR + int enemynum; +#endif + int iEntryBack[BATTLE_ENTRY_MAX*2]; // ľ׶ + int iEntryBack2[BATTLE_ENTRY_MAX*2]; // ľ׶ + int createindex; /* 𼰾 ëԻƽҷ̼͵(NPCئ) */ + int (*WinFunc)( int battleindex, int charaindex ); +#ifdef _ALLBLUES_LUA_1_4 + lua_State *lua[BATTLE_FUNCTABLENUM]; + char *luafunctable[BATTLE_FUNCTABLENUM]; +#endif +#ifdef _DEATH_CONTEND//ʤfunc + int (*PkFunc)( int menum, int tonum, int winside, int battlemap); + int battlemap; +#endif + struct _Battle *pNext; // ݼ + struct _Battle *pBefore; // 󡼰 +/*#ifdef _JZ_NEWSCRIPT_LUA + int (*BakFunc)( int battleindex, int charaindex ); + char BakLuaFuncName[32]; +#endif*/ +#ifdef _JZ_NEWSCRIPT_LUA + int (*BakFunc)(int battleindex , int charaindex); + int (*EndFunc)( int battleindex ); + char BakLuaFuncName[32]; + char EndLuaFuncName[32]; +#endif + int floor; + int battletime; +}BATTLE; + + +#define BATTLE_FLG_FREEDP ( 1 << 0 ) // ͻ Ӽئ +#define BATTLE_FLG_CHARALOST ( 1 << 1 ) // ƽҷ»ϷԻ Իƻ + + + +enum{ // field_att ľ° + BATTLE_ATTR_NONE = 0, // + BATTLE_ATTR_EARTH, // + BATTLE_ATTR_WATER, // + BATTLE_ATTR_FIRE, // + BATTLE_ATTR_WIND, // + BATTLE_ATTR_END +}; + + +//krynn 2001/12/28 +enum +{ + BATTLE_SIDE_RIGHT, // սҲ right side of battle + BATTLE_SIDE_LEFT, // ս left side of battle + BATTLE_SIDE_WATCH, // ս watch battle player +}; +//krynn end + +#define TARGET_SIDE_0 20 // 㯴 ϶ +#define TARGET_SIDE_1 21 // ϶ +#define TARGET_ALL 22 // ϶ + +#ifdef _ATTACK_MAGIC + +#define TARGET_SIDE_0_B_ROW 26 // һ +#define TARGET_SIDE_0_F_ROW 25 // ǰһ +#define TARGET_SIDE_1_F_ROW 24 // ǰһ +#define TARGET_SIDE_1_B_ROW 23 // һ + +// won add +#define TARGER_THROUGH 27 + +#endif + +extern int gItemCrushRate; // ç ɻ +extern BATTLE *BattleArray; /* */ +extern int BATTLE_battlenum; /* */ +extern char szAllBattleString[BATTLE_STRING_MAX]; /* Ѩ ٯ */ +extern char *pszBattleTop, *pszBattleLast; /* ٯ */ +extern char szBadStatusString[1024]; // ٯ +extern int gWeponType; // ػ տ +extern float gDamageDiv; // ĸ + +#define BATTLE_CHECKINDEX( a ) ( ((a)>=BATTLE_battlenum || (a)<0 )?(FALSE):(TRUE) ) +#define BATTLE_CHECKSIDE( a ) ( ((a)>=2 || (a)<0)?(FALSE):( TRUE) ) +#define BATTLE_CHECKNO( a ) ( ((a)>=20 || (a)<0 )?(FALSE):(TRUE) ) +#define BATTLE_CHECKADDRESS( a ) ((&BattleArray[0])<=(a) && (a)<=(&BattleArray[BATTLE_battlenum-1] )?(TRUE):(FALSE) ) + +#define IsBATTLING( a ) (CHAR_getWorkInt((a),CHAR_WORKBATTLEMODE)?(TRUE):(FALSE)) + +#define STRCPY_TAIL( _pszTop, _pszLast, _szBuffer) { int _len = strlen( _szBuffer ); ( _pszTop + _len < (_pszLast)-1 )?( memcpy( _pszTop, _szBuffer, _len ), _pszTop += _len, _pszTop[0] = 0):(0); } + +#define BATTLESTR_ADD( _szBuffer ){ int _len = strlen( _szBuffer ); ( pszBattleTop + _len < ( pszBattleLast)-1 )?( memcpy( pszBattleTop, _szBuffer, _len ), pszBattleTop += _len, pszBattleTop[0] = 0):(0); } + +#define BATTLE_MAP_MAX 219 + +#define CH_FIX_PLAYERLEVELUP (+2) // ìﻥʧ +#define CH_FIX_PLAYERDEAD (-2) // ɧ +#define CH_FIX_PLAYEULTIMATE (-4) // ʧ ū +#define CH_FIX_PETESCAPE (-1) // ʸ + +#define AI_FIX_PETLEVELUP (+5*100) // ʸìʧ +#define AI_FIX_PETWIN (+1) // ʸë +#define AI_FIX_PETGOLDWIN (+2*10) // ʸìPгë +#define AI_FIX_PETRECOVERY (+10) // ƻ +#define AI_FIX_PETRESSURECT (+3*100) // ƻ +//#define AI_FIX_PETRECOVERY (+50) // ƻ + +#define AI_FIX_SEKKAN (-2*100) // мʸë +#define AI_FIX_PLAYERULTIMATE (-10*100) // мDZлʧ ū +#define AI_FIX_PETULTIMATE (-10*100) // ʸʧ ū +#define AI_FIX_PLAYERDEAD (-1*100) // мDZл +#define AI_FIX_PETDEAD (-5*100) // ʸ + + +#ifdef _Item_ReLifeAct +int BATTLE_getBattleDieIndex( int battleindex, int bid ); +#endif + +int BATTLE_No2Index( int battleindex, int No); + +int BATTLE_Index2No( int battleindex, int charaindex); + +BOOL BATTLE_initBattleArray( int battlenum); + +int BATTLE_CreateBattle( int charaindex ); +int BATTLE_DeleteBattle( int battleindex); + +int BATTLE_NewEntry( int charaindex, int battleindex, int side); + +#define BATTLE_Exit( charaindex, battleindex) _BATTLE_Exit( __FILE__, __LINE__, charaindex, battleindex) +INLINE int _BATTLE_Exit( char *file, int line, int charaindex ,int battleindex); + +#define BATTLE_ExitAll( battleindex) _BATTLE_ExitAll( __FILE__, __LINE__, battleindex) +INLINE void _BATTLE_ExitAll( char *file, int line, int battleindex); + +int BATTLE_CreateVsPlayer( int charaindex0, int charaindex1); + +int BATTLE_CreateVsEnemy( int charaindex, int mode, int npcindex); + +int BATTLE_CountEntry( int battleindex, int side); + +int BATTLE_Loop( void ); + +int BATTLE_FinishSet( int battleindex ); +int BATTLE_StopSet( int battleindex ); +int BATTLE_RescueEntry( int charaindex, int toindex); + +int BATTLE_PetDefaultExit( int charaindex, int battleindex); + +int BATTLE_PetDefaultEntry( + int charaindex, // ʸë Ȼ + int battleindex,// ̼͵ + int side +); + +BOOL BATTLE_RescueTry( int charaindex); + +BOOL BATTLE_RescueParentTry( + int charaindex, + int pindex + ); + +int BATTLE_DefaultAttacker( int battleindex, int side); + +BOOL BATTLE_IsThrowWepon( int itemindex); + +void BATTLE_BadStatusString( int defNo, int status ); +int BATTLE_MultiList( int battleindex, int toNo, int ToList[] ); +BOOL BATTLE_IsCharge( int com ); +BOOL BATTLE_CanMoveCheck( int charaindex ); +int BATTLE_TargetCheck( int battleindex, int defNo); +char *BATTLE_CharTitle( int charaindex ); +void BATTLE_EscapeDpSend( int battleindex, int charaindex ); +int BATTLE_GetDuelPoint( int battleindex, int side, int num); +int BATTLE_TargetCheckDead( int battleindex, int defNo); + +void BATTLE_MultiListDead( int battleindex, int toNo, int ToList[] ); +BOOL BATTLE_WatchTry( int charaindex); +int BATTLE_WatchEntry( int charaindex, int toindex); +void BATTLE_WatchStop( int charaindex ); +int BATTLE_WatchUnLink( int battleindex ); +void BATTLE_BpSendToWatch( BATTLE *pBattle, char *pszBcString); + +int BATTLE_GetWepon( int charaindex ); + +#ifdef _ITEM_EQUITSPACE +int BATTLE_GetEqShield( int charaindex ); +#endif + +int BATTLE_GetAttackCount( int charaindex ); +int DoujyouRandomWeponSet( int charaindex ); +void BATTLE_AttReverse( int charaindex ); +void BATTLE_BadStatusAllClr( int charaindex ); +#define CHAR_GETWORKINT_HIGH( index, pos ) ( CHAR_getWorkInt( (index), (pos) ) >> 16 ) +#define CHAR_SETWORKINT_HIGH( index, pos, set ) { int iTmp = CHAR_getWorkInt( (index), (pos) ) & 0xFFFF, work = (set); CHAR_setWorkInt( (index), (pos), (work << 16)|iTmp ); } +#define CHAR_GETWORKINT_LOW( index, pos ) ( CHAR_getWorkInt( (index), (pos) ) & 0xFFFF ) +#define CHAR_SETWORKINT_LOW( index, pos, set ) { int iTmp = CHAR_getWorkInt( index, pos ) & 0xFFFF0000, work = (set); CHAR_setWorkInt( (index), (pos), (work & 0x0000FFFF) | iTmp ); } + +int Battle_getTotalBattleNum(); + +#ifdef _TYPE_TOXICATION +void CHAR_ComToxicationHp( int charaindex); +#endif + +#ifdef _PROFESSION_SKILL // WON ADD ְҵ +void BATTLE_ProfessionStatus_init( int battleindex, int charaindex ); +void BATTLE_ProfessionStatusSeq( int battleindex, int charaindex); +#endif + + +#endif +#ifdef _FM_NPC_LOOK_WAR +int SearchFmWarRandIndex(int charaindex,int fmwarfloor); +char* SearchFmWar(int charaindex,int fmwarselect); +int LookFmWarIndex(int charaindex,int fmwarselect); + +#ifdef _ALLBLUES_LUA_1_4 +INLINE BOOL BATTLE_setLUAFunction( int battleindex, int functype, lua_State *L, const char *luafunctable); +INLINE lua_State *BATTLE_getLUAFunction( int battle, int functype); +#endif + +void Enemy_setStayLoop(int charaindex); +#endif diff --git a/include/battle_ai.h b/include/battle_ai.h new file mode 100644 index 0000000..a7fc394 --- /dev/null +++ b/include/battle_ai.h @@ -0,0 +1,10 @@ +#ifndef __BATTLE_AI_H__ +#define __BATTLE_AI_H__ + +/* Ի */ +int BATTLE_ai_all( int battleindex, int side, int turn); +int BATTLE_ai_one( int charaindex, int battleindex, int side, int turn); +#ifdef _ENEMY_ATTACK_AI +int GetSubdueAtt(int index); +#endif +#endif diff --git a/include/battle_command.h b/include/battle_command.h new file mode 100644 index 0000000..c98b697 --- /dev/null +++ b/include/battle_command.h @@ -0,0 +1,27 @@ +#ifndef __BATTLE_COMMAND_H__ +#define __BATTLE_COMMAND_H__ + +void BattleCommandDispach( + int fd, + char *command +); + +void BattleEncountOut( + int charaindex +); + +BOOL BATTLE_CommandSend( int charaindex, char *pszCommand ); + +BOOL BATTLE_MakeCharaString( + int battleindex, + char *pszCommand, // ƽҷ + int size // +); + +void BATTLE_CharSendAll( int battleindex ); + +BOOL BATTLE_PetDefaultCommand( int petindex ); + +void BATTLE_ActSettingSend( int battleindex ); + +#endif diff --git a/include/battle_event.h b/include/battle_event.h new file mode 100644 index 0000000..044b6fe --- /dev/null +++ b/include/battle_event.h @@ -0,0 +1,382 @@ +#ifndef __BATTLE_EVENT_H__ +#define __BATTLE_EVENT_H__ + +#define BCC_HIT 'H' +#define BCC_FIRE 'F' + +#define BCF_DEATH (1 << 0) +#define BCF_NORMAL (1 << 1) +#define BCF_KAISHIN (1 << 2) +#define BCF_GUARD (1 << 3) +#define BCF_COUNTER (1 << 4) +#define BCF_DODGE (1 << 5) +#define BCF_ULTIMATE_1 (1 << 6) +#define BCF_ULTIMATE_2 (1 << 7) +#define BCF_GBREAK (1 << 8) +#define BCF_GUARDIAN (1 << 9) +#define BCF_REFRECT (1 << 10) +#define BCF_ABSORB (1 << 11) +#define BCF_VANISH (1 << 12) +#define BCF_CRUSH (1 << 13) +#define BCF_FALL (1 << 14) // +#ifdef _SKILL_TOOTH +#define BCF_TOOTH (1 << 15) //ܳ +#endif +#ifdef _PSKILL_MODIFY +#define BCF_ATTDOUBLE (1 << 16) //ǿ +#endif +#ifdef _SKILL_ROAR +#define BCF_ROAR (1 << 17) //輼:() +#endif + +#ifdef _MAGIC_DEFMAGICATT +#define BCF_DEFMAGICATT (1 << 19) +#endif +#ifdef _MAGIC_SUPERWALL +#define BCF_SUPERWALL (1 << 20) +#endif +#ifdef _PSKILL_MDFYATTACK +#define BCF_MODIFY (1 << 21) +#endif + +#ifdef _PROFESSION_SKILL // WON ADD ְҵ +#define BCF_F_SKILLACT (1 << 22) //ǰͼ +#define BCF_TRAP (1 << 25) // +#define BCF_NO_DAMAGE (1 << 26) //˫ع +#endif +#define BCF_B_SKILLACT (1 << 23) //ͼ + + + +#ifdef _EQUIT_ARRANGE +#define BCF_B_ARRANGE (1 << 24) //ͼ +#endif + +#ifdef _PETSKILL_ACUPUNCTURE +#define BCF_ACUPUNCTURE (1 << 27) +#endif + +#ifdef _PETSKILL_ANTINTER +#define BCF_ANTINTER (1 << 28) +#endif + +#ifdef _OTHER_MAGICSTAUTS +#ifdef _MAGICSTAUTS_RESIST +#define MAXSTATUSTYPE 6 +#else +#define MAXSTATUSTYPE 3 +#endif //_MAGICSTAUTS_RESIST +extern char MagicStatus[MAXSTATUSTYPE][36]; +extern int MagicTbl[]; +extern int MagicTypeTbl[]; +#endif + +extern char *aszStatus[]; +extern char *aszStatusFull[]; +extern int StatusTbl[]; +extern int RegTbl[]; +extern int MagicDefTbl[]; +extern char *aszMagicDefFull[]; +extern char *aszMagicDef[]; + +extern char *aszParamChange[]; +extern char *aszParamChangeFull[]; +extern int aParamChangeTbl[]; + +extern float gBattleDamageModyfy; +extern int gBattleDuckModyfy; +extern int gBattleStausChange; +extern int gBattleStausTurn; + +enum{ + BATTLE_ST_NONE, // 0 "", + BATTLE_ST_POISON, // 1 "", + BATTLE_ST_PARALYSIS, // 2 "", + BATTLE_ST_SLEEP, // 3 "", + BATTLE_ST_STONE, // 4 "ʯ", + BATTLE_ST_DRUNK, // 5 "", + BATTLE_ST_CONFUSION, // 6 "", + BATTLE_ST_WEAKEN, // 7 "" + BATTLE_ST_DEEPPOISON,// 8 "綾" + BATTLE_ST_BARRIER, // 9 "ħ" + BATTLE_ST_NOCAST, // 10 "Ĭ" +#ifdef _PET_SKILL_SARS // WON ADD ɷ + BATTLE_ST_SARS, // 11 "ɷ" +#endif +#ifdef _PROFESSION_SKILL // WON ADD ְҵ + BATTLE_ST_DIZZY, // 12 "" + BATTLE_ST_ENTWINE, // 13 "" + BATTLE_ST_DRAGNET, // 14 "޵" + BATTLE_ST_ICECRACK, // 15 "" + BATTLE_ST_OBLIVION, // 16 "" + BATTLE_ST_ICEARROW, // 17 "" + BATTLE_ST_BLOODWORMS,// 18 "Ѫ" + BATTLE_ST_SIGN, // 19 "һѪ" + BATTLE_ST_INSTIGATE, // 20 "" + BATTLE_ST_F_ENCLOSE, // 21 "" + BATTLE_ST_I_ENCLOSE, // 22 "" + BATTLE_ST_T_ENCLOSE, // 23 "׸" + BATTLE_ST_FOCUS, // 24 "רעս" + BATTLE_ST_RESIST_F, // 25 "" + BATTLE_ST_RESIST_I, // 26 "" + BATTLE_ST_RESIST_T, // 27 "׿" + BATTLE_ST_F_ENCLOSE2, // 28 "" + BATTLE_ST_I_ENCLOSE2, // 29 "" + BATTLE_ST_T_ENCLOSE2, // 30 "׸" +#ifdef _PROFESSION_ADDSKILL + BATTLE_ST_RESIST_F_I_T, //31 "׿" + //BATTLE_ST_BOUNDARY_F, //32 " + BATTLE_ST_WATER, //32 "ˮ" + BATTLE_ST_WORKANNEX, //33 "" + BATTLE_ST_FEAR, //34 "־" + BATTLE_ST_ICECRACK2, // 35 "" + BATTLE_ST_ICECRACK3, // 36 + BATTLE_ST_ICECRACK4, // 37 + BATTLE_ST_ICECRACK5, // 38 + BATTLE_ST_ICECRACK6, // 39 + BATTLE_ST_ICECRACK7, // 40 + BATTLE_ST_ICECRACK8, // 41 + BATTLE_ST_ICECRACK9, // 42 + BATTLE_ST_ICECRACK10, // 43 +#endif + +#endif + + BATTLE_ST_END +}; + +#ifdef _OTHER_MAGICSTAUTS +enum{ + BATTLE_MST_NONE, + BATTLE_MST_DEFMAGIC, + BATTLE_MST_SUPERWALL, +#ifdef _MAGICSTAUTS_RESIST + BATTLE_MST_MAGICFIRE, + BATTLE_MST_MAGICTHUNDER, + BATTLE_MST_MAGICICE, +#endif + BATTLE_MST_END +}; +#endif + +enum{ + BATTLE_MD_NONE, + BATTLE_MD_ABSROB, + BATTLE_MD_REFLEC, + BATTLE_MD_VANISH, + BATTLE_MD_TRAP, +#ifdef _PETSKILL_ACUPUNCTURE + BATTLE_MD_ACUPUNCTURE, //Ƥ +#endif + BATTLE_MD_END +}; + +#ifdef _PETSKILL_RETRACE + //BATTLE_AttackʽִĹģʽ +typedef struct tagBattle_Attack_ReturnData_x1 +{ + int Battle_Attack_ReturnData; +}Battle_Attack_ReturnData_x1; +Battle_Attack_ReturnData_x1 Battle_Attack_ReturnData_x; + +#endif + +int BATTLE_DamageCalc( int attackindex, int defindex ); + +BOOL BATTLE_Attack( int battleindex, int attackNo, int defNo ); + +BOOL BATTLE_Counter( int battleindex, int attackNo, int defNo ); + +BOOL BATTLE_Capture( int battleindex, int attackNo, int defNo ); + +void BATTLE_Guard( int battleindex, int attackNo ); + +// Nuke 20040112 fix for performance +#define BATTLE_BroadCast(A,B,C) 0 +#define BATTLE_BroadCastOn(A,B,C) 0 +//int BATTLE_BroadCast( int battleindex, char *pszBuffer, int color ); +//int BATTLE_BroadCastOn( int battleindex, char *pszBuffer, int color ); + +BOOL BATTLE_Escape( int battleindex, int attackNo, int flag); + +int BATTLE_NoAction( int battleindex, int attackNo ); + +int BATTLE_PetIn( int battleindex, int attackNo ); + +int BATTLE_PetOut( int battleindex, int attackNo ); + +int BATTLE_SurpriseCheck( int battleindex ); + +int BATTLE_Magic( int battleindex, int attackNo ); + +int BATTLE_S_GBreak( int battleindex, int attackNo, int defNo ); + +#ifdef _SKILL_GUARDBREAK2//Ƴ2 vincent add 2002/05/20 +int BATTLE_S_GBreak2( int battleindex, int attackNo, int defNo ); +#endif + +#ifdef _SKILL_SACRIFICE +int BATTLE_S_Sacrifice( int battleindex, int attackNo, int defNo ); +#endif + +#ifdef _SKILL_REFRESH +int BATTLE_S_Refresh( int battleindex, int attackNo, int defNo, int marray ); +#endif + +#ifdef _SKILL_WEAKEN //vincent輼: +int BATTLE_S_Weaken( int battleindex, int attackNo, int defNo, int marray ); +#endif + +#ifdef _SKILL_DEEPPOISON //vincent輼:綾 +int BATTLE_S_Deeppoison( int battleindex, int attackNo, int defNo, int marray ); +#endif + +#ifdef _SKILL_BARRIER //vincent輼:ħ +int BATTLE_S_Barrier( int battleindex, int attackNo, int defNo, int marray ); +#endif + +#ifdef _SKILL_NOCAST //vincent輼:Ĭ +int BATTLE_S_Nocast( int battleindex, int attackNo, int defNo, int marray ); +#endif + +#ifdef _SKILL_ROAR //vincent輼: +int BATTLE_S_Roar( int battleindex, int attackNo, int defNo, int marray ); +#endif + +int BATTLE_Charge( int battleindex, int attackNo ); + + +int BATTLE_StatusAttackCheck( + + int attackindex, + int defindex, + int status, + //BATTLE_ST_POISON, 1 "", + //BATTLE_ST_PARALYSIS, 2 "", + //BATTLE_ST_SLEEP, 3 "", + //BATTLE_ST_STONE, 4 "ʯ", + //BATTLE_ST_DRUNK, 5 "", + //BATTLE_ST_CONFUSION, 6 "" + int PerOffset, + int Range, + float Bai, + int *pPer +); + +int BATTLE_Combo( int battleindex, int *pAttackList, int defNo ); + +int BATTLE_EarthRoundHide( int battleindex, int attackNo ); + +int BATTLE_GetDamageReact( int charaindex ); + +void BATTLE_talkToCli( int charaindex, char *pszBuffer, int color ); + +#ifdef _PETSKILL_SETDUCK +BOOL BATTLE_CheckMySkillDuck( int charaindex ); +#endif + +BOOL BATTLE_LostEscape( int battleindex, int attackNo ); + +BOOL BATTLE_Abduct( int battleindex, int attackNo, int defNo, int array ); + +void BATTLE_Steal( int battleindex, int attackNo, int defNo ); + +int BATTLE_getReactFlg( int index, int react); + +#ifdef _BATTLESTEAL_FIX +void BATTLE_StealMoney( int battleindex, int attackNo, int defNo) ; +#endif + +#ifdef _PETSKILL_LER +void BATTLE_BatFly(int battleindex,int attackNo,int myside); +void BATTLE_DivideAttack(int battleindex,int attackNo,int myside); +void BATTLE_LerChange(int battleindex,int charaindex,int no); +#endif + +#ifdef _PETSKILL_BATTLE_MODEL +void BATTLE_BattleModel(int battleindex,int attackNo,int myside); +#endif + +// Robin 0727 Ride Pet +#define ATTACKSIDE 1 +#define DEFFENCESIDE 2 + +float BATTLE_adjustRidePet3A( int charaindex, int petindex, int workindex, int action ); + +int BATTLE_getRidePet( int charaindex ); + +#ifdef _PSKILL_FALLGROUND // +int BATTLE_S_FallGround( int battleindex, int attackNo, int defNo, int skill_type ); +#endif + +#ifdef _PETSKILL_PROPERTY +int BATTLE_S_PetSkillProperty( int battleindex, int attackNo, int skill_type, int skill); +#endif + +int BATTLE_S_AttackDamage( int battleindex, int attackNo, int defNo, int skill_type, int skill); + +#ifdef _MAGIC_SUPERWALL +int PETSKILL_MagicStatusChange_Battle( int battleindex, int attackNo, int toNo, int marray); +#endif + +#ifdef _PETSKILL_SETDUCK +int PETSKILL_SetDuckChange_Battle( int battleindex, int attackNo, int toNo, int marray); +#endif + +#ifdef _MAGICPET_SKILL +int PETSKILL_SetMagicPet_Battle( int battleindex, int attackNo, int toNo, int marray); +#endif + +#ifdef _TAKE_ITEMDAMAGE +int BATTLE_ItemCrushCheck( int charaindex , int flg); +int BATTLE_ItemCrush( int charaindex, int ItemEquip, int Damages, int flg); +#endif + +#ifdef _PRO_BATTLEENEMYSKILL +int BATTLE_E_ENEMYREFILE( int battleindex, int attackNo, int defNo, int skill_type ); + +int BATTLE_E_ENEMYREHP( int battleindex, int attackNo, int defNo, int skill_type ); + +int BATTLE_E_ENEMYHELP( int battleindex, int attackNo, int defNo, int skill_type ); +#endif + + +#ifdef _PREVENT_TEAMATTACK +int BATTLE_CheckSameSide( int charaindex, int toNo); +#endif + +#ifdef _USER_CHARLOOPS +int CHAR_BattleStayLoop( int charaindex);//ԭ +#endif + +#ifdef _PETSKILL_PROPERTY +int PET_PetskillPropertyEvent( int Myindex, int defindex, int *damage, int *T_Pow, int size); +#endif + +#ifdef _PROFESSION_SKILL // WON ADD ְҵ +int battle_profession_attack_fun(int battleindex, int attackNo, int defNo, int charaindex); +int battle_profession_attack_magic_fun(int battleindex, int attackNo, int defNo, int charaindex); +int battle_profession_assist_fun(int battleindex, int attackNo, int defNo, int charaindex); +int battle_profession_status_chang_fun(int battleindex, int attackNo, int defNo, int charaindex); +int BATTLE_check_profession_duck( int charaindex, int per ); +int BATTLE_PROFESSION_ATK_PET_DamageSub( int attackindex, int defindex, int *pDamage, int *pPetDamage, int *pRefrect, int skill_level ); +int PROFESSION_BATTLE_StatusAttackCheck( int charaindex, int toindex, int status, int Success ); +int BATTLE_PROFESSION_CONVOLUTE_GET_DAMAGE( int attackindex, int defindex, int skill_level ); +int BATTLE_PROFESSION_THROUGH_ATTACK_GET_DAMAGE( int attackindex, int defindex ); +int BATTLE_PROFESSION_RANG_ATTACK_DAMAGE( int charaindex, int attackNo, int defNo, int skill_type, int status, int turn, int perStatus, int effect, int img1, int img2 ); + +#endif + +#ifdef _PETSKILL_FIREKILL //ɱר +int BATTLE_Attack_FIREKILL( int battleindex, int attackNo, int defNo ); +#endif +#ifdef _PROFESSION_ADDSKILL +BOOL BATTLE_BattleUltimate( int battleindex, int bid ); //λDǷ񱻴 +#endif +#ifdef _NEED_ITEM_ENEMY +int need_item_eneny_init(); +#endif +#ifdef _OFFLINE_SYSTEM +int OFFLINE_MultiRessurect( int battleindex, int attackNo, int toNo, int HP, int flg); +#endif +#endif diff --git a/include/battle_item.h b/include/battle_item.h new file mode 100644 index 0000000..483fa73 --- /dev/null +++ b/include/battle_item.h @@ -0,0 +1,36 @@ +#ifndef _BATTLE_ITEM_H_ +#define _BATTLE_ITEM_H_ +//-------------------------------------------------------------- +// ʧ ةë +//-------------------------------------------------------------- +// +void ITEM_useRecovery_Battle( int charaindex, int toindex, int itemindex ); +void ITEM_useStatusChange_Battle( int charaindex, int toindex, int itemindex ); +void ITEM_useMagicDef_Battle( int charaindex, int toindex, int itemindex ); +void ITEM_useParamChange_Battle( int charaindex, int toindex, int itemindex ); +void ITEM_useFieldChange_Battle( int charaindex, int toindex, int itemindex ); +void ITEM_useAttReverse_Battle( int charaindex, int toindex, int itemindex ); +void ITEM_useStatusRecovery_Battle( int charaindex, int toindex, int itemindex ); +void ITEM_useCaptureUp_Battle( int charaindex, int toindex, int itemindex ); +#ifdef _ITEM_CRACKER +void ITEM_useCracker_Effect( int charaindex, int toindex, int haveitemindex); +#endif +#ifdef _ITEM_ADDEXP //vincent +void ITEM_useAddexp_Effect( int charaindex, int toindex, int haveitemindex); +#endif +#ifdef _ITEM_REFRESH //vincent 쳣״̬ +void ITEM_useRefresh_Effect( int charaindex, int toindex, int haveitemindex); +#endif +//Terry add 2001/12/24 +#ifdef _ITEM_FIRECRACKER +void ITEM_useFirecracker_Battle(int charaindex,int toindex,int itemindex); +#endif +//Terry end + +#ifdef _ITEM_MAGICRECOVERY +void ITEM_useMRecovery_Battle( int charaindex, int toNo, int haveitemindex ); +#endif +#ifdef _ITEM_USEMAGIC +void ITEM_useMagic_Battle( int charaindex, int toNo, int haveitemindex ); +#endif +#endif diff --git a/include/battle_magic.h b/include/battle_magic.h new file mode 100644 index 0000000..0483a25 --- /dev/null +++ b/include/battle_magic.h @@ -0,0 +1,336 @@ +#ifndef _BATTLE_MAGIC_H_ +#define _BATTLE_MAGIC_H_ + +#define MAGIC_EFFECT_USER 100600 +#define SPR_heal 100601 +#define SPR_heal2 100602 +#define SPR_heal3 100603 +#define SPR_tyusya 100604 +#define SPR_hoshi 100605 + + +#define MAGIC_ID_RECOVERY 1 +#define MAGIC_ID_STATUS_RECOVERY 3 +#define MAGIC_ID_FIELD_CHANGE 4 +#define MAGIC_ID_BADSTATUS 5 + +enum{ + BFUKI_CAPTUREUP, + BFUKI_END +}; + + +enum{ + PC_KIND_NONE, + PC_KIND_ATTACK, + PC_KIND_DEFENSE, + PC_KIND_QUICK, + PC_KIND_CHARM, + PC_KIND_CAPTURE, + PC_KIND_END +}; + +int MAGIC_Recovery_Battle( + int charaindex, + int toindex, + int magicindex, + int mp +); + +int MAGIC_FieldAttChange_Battle( + int charaindex, + int toindex, + int marray, + int mp +); + +int MAGIC_StatusChange_Battle( + int charaindex, + int toindex, + int marray, + int mp +); + +#ifdef _MAGIC_DEEPPOISON +int MAGIC_StatusChange_Battle2( + int charaindex, + int toindex, + int marray, + int mp +); +#endif + +#ifdef _OTHER_MAGICSTAUTS +int MAGIC_MagicStatusChange_Battle( int charaindex, int toNo, int marray, int mp ); + +#endif + +int MAGIC_MagicDef_Battle( + int charaindex, + int toNo, + int marray, + int mp +); + +void BATTLE_MultiRecovery( + int battleindex, + int attackNo, + int toNo, + int kind, + int power, + int per, + int UseEffect, + int RecevEffect + +); + +#ifdef _IMPRECATE_ITEM +void BATTLE_ImprecateRecovery( + int battleindex, + int attackNo, + int toNo, + int kind, + int powers, + int rounds, + int UseEffect, + int RecevEffect +); +#endif +void BATTLE_MultiStatusChange( + int battleindex, + int attackNo, + int toNo, + int status, + int turn, + int UseEffect, + int RecevEffect, + int Success +); + +#ifdef _OTHER_MAGICSTAUTS +void BATTLE_MultiMagicStatusChange( + int battleindex, + int attackNo, + int toNo, + int status, + int turn, + int UseEffect, + int RecevEffect, + int nums +); +#endif + +void BATTLE_MultiMagicDef( + int battleindex, + int attackNo, + int toNo, + int kind, + int count, + int UseEffect, + int RecevEffect +); + +void BATTLE_MultiParamChange( + int battleindex, + int attackNo, + int toNo, + int kind, + int power, + int par, + int UseEffect, + int RecevEffect +); + +int MAGIC_FieldAttChange_Battle( + int charaindex, + int toNo, + int marray, + int mp +); + +int BATTLE_FieldAttChange( + int charaindex, + char *pArg +); + +void BATTLE_MultiAttReverse( + int battleindex, + int attackNo, + int toNo, + int UseEffect, + int RecevEffect +); + + +void BATTLE_MultiStatusRecovery( + int battleindex, + int attackNo, + int toNo, + int status, + int UseEffect, + int RecevEffect +); + +int MAGIC_StatusRecovery_Battle( + int charaindex, + int toNo, + int marray, + int mp +); + +void BATTLE_MultiRessurect( + int battleindex, + int attackNo, + int toNo, + int power, + int per, + int UseEffect, + int RecevEffect +); + +void BATTLE_MultiCaptureUp( + int battleindex, + int attackNo, + int toNo, + int power, + int UseEffect, + int RecevEffect +); +// +//*********************************************************** + +//**************************************************************** +// +// 姾 +// +int MAGIC_Ressurect_Battle( + int charaindex, // м̼͵ + int toNo, // ľм̼͵ + int marray, // magicindex + int mp // MP +); +// TRUE +// FALSE +//**************************************************************** + +//**************************************************************** +// +// 뼰 ë +// +int MAGIC_AttReverse_Battle( + int charaindex, // м̼͵ + int toNo, // ľм̼͵ + int marray, // magicindex + int mp // MP +); +// TRUE +// FALSE +//**************************************************************** +//**************************************************************** +// +// +// +int MAGIC_CaptureUp_Battle( + int charaindex, // м̼͵ + int toNo, // ľм̼͵ + int marray, // magicindex + int mp // MP +); +// TRUE +// FALSE +//**************************************************************** + +//*********************************************************** +// +// ܷƥ Ѽƽҷëٽ½ձ ܷ ëܰ +// +void BATTLE_MultiResAndDef( + int battleindex, // ̼͵ + int attackNo, // į + int toNo, // ľ į + int power, // + int per, // Ѿ + int kind, // ܷ + int count, // ϼ ʲ + int UseEffect, // мް + int RecevEffect // ľмް +); +// +//*********************************************************** +//**************************************************************** +// +// ١ ܷ ëܸ +// +int MAGIC_ResAndDef_Battle( + int charaindex, // м̼͵ + int toNo, // ľм̼͵ + int marray, // magicindex + int mp // MP +); +// TRUE +// FALSE +//**************************************************************** + +#ifdef _ATTACK_MAGIC +int MAGIC_AttMagic_Battle( int charaindex , int toNo , int marray , int mp ); +#ifdef _FIX_MAGICDAMAGE +void BATTLE_MultiAttMagic( int battleindex, int attackNo, int toNo, + int attIdx ,int FieldAttr ,int Power, int MagicLv); + +#else +void BATTLE_MultiAttMagic( int battleindex , int attackNo , int toNo , int attIdx , int FieldAttr , int Power ); +#endif +int MAGIC_AttMagic_Battle( int charaindex , int toNo , int marray , int mp ); + +#endif + + + +#ifdef _MAGIC_TOCALL +int MAGIC_ToCallDragon_Battle( int charaindex , int toNo , int marray , int mp ); + +void BATTLE_MultiToCallDragonMagic( int battleindex, int attackNo, int toNo, + int attIdx ,int FieldAttr ,int Power, int ImageNo); + +#endif + +#ifdef _Item_ReLifeAct +void BATTLE_MultiReLife( int battleindex, int attackNo, int toNo, int power, int RecevEffect ); +#endif +#ifdef _MAGIC_WEAKEN +int MAGIC_ParamChange_Turn_Battle(int charaindex,int toNo,int marray,int mp); +void BATTLE_MultiParamChangeTurn( int battleindex,int attackNo,int toNo,int status,int UseEffect,int RecevEffect,int turn, int Success); +#endif +int BATTLE_MagicEffect( int battleindex,int attackNo,int ToList[],int MyEffect,int ToEffect ); + + + +#ifdef _PROFESSION_SKILL // WON ADD ְҵ +void PROFESSION_MAGIC_ATTAIC( int battleindex, int attackNo, int toNo, int attIdx, int FieldAttr, int skill); +int PROFESSION_MAGIC_ATTAIC_Effect( int battleindex, int attackNo, int ToList[], int AttackMgcNo ); +int analysis_profession_parameter( int attIdx, int skill, int toNo, int charaindex ); +void PROFESSION_MAGIC_GET_PRACTICE( float *hp_power, float *mp_power, float *dec_hp, float *dec_mp, int charaindex ); +void PROFESSION_MAGIC_TOLIST_SORT( int *list, int *listidx, int charaindex ); +void PROFESSION_MAGIC_CHANGE_STATUS( int charaindex, int hp_power, float mp_power, float *add_hp, float *add_mp ); +void PROFESSION_MAGIC_GET_IMG2( int toNo, int charaindex, int attIdx, char *pszOption ); +#ifdef _PROFESSION_ADDSKILL +int PROFESSION_MAGIC_GET_DAMAGE( int attackindex, int defindex, int magic_type, int power, int command ); +#else +int PROFESSION_MAGIC_GET_DAMAGE( int attackindex, int defindex, int magic_type, int power ); +#endif +int PROFESSION_MAGIC_DODGE( int atk_index, int def_index, int magic_type ); +void PROFESSION_MAGIC_CHANG_IMG2( int img2, char *pszOption, int attIdx ); +int PROFESSION_MAGIC_CHANG_STATUS(int command,int battleindex, int charaindex, int charaidx, int power, int no); +int PROFESSION_MAGIC_GET_ICE_MIRROR_DAMAGE( int attackindex, int defindex, int command, int power ); +#endif + +#ifdef _PETSKILL_FIREKILL +void BATTLE_MultiAttMagic_Fire( int battleindex, int attackNo, int defNo, + int FieldAttr , int Power); +#endif + +#ifdef _PROFESSION_ADDSKILL +unsigned int GET_PROFESSION_magic_uiSpriteNum(int idx); +#endif + +#endif diff --git a/include/buf.h b/include/buf.h new file mode 100644 index 0000000..78665f0 --- /dev/null +++ b/include/buf.h @@ -0,0 +1,11 @@ +#ifndef __BUF_H__ +#define __BUF_H__ + +#include "common.h" +void memEnd( void ); +BOOL configmem( int unit , int unitnumber ); +BOOL memInit( void ); +void* allocateMemory( const unsigned int nbyte ); +void freeMemory( void* freepointer ); +void showMem( char *buf); +#endif diff --git a/include/char.h b/include/char.h new file mode 100644 index 0000000..99cade2 --- /dev/null +++ b/include/char.h @@ -0,0 +1,780 @@ +#ifndef __CHAR_H__ +#define __CHAR_H__ + +#include "common.h" +#include "char_base.h" +#include "net.h" +#include "char_data.h" + + +/*------------------------------------------------------------ + *ɼƼ + *------------------------------------------------------------*/ +typedef enum +{ + CHAR_COLORWHITE, + CHAR_COLORCYAN, + CHAR_COLORPURPLE, + CHAR_COLORBLUE, + CHAR_COLORYELLOW, + CHAR_COLORGREEN, + CHAR_COLORRED, + CHAR_COLORGRAY, + CHAR_COLORBLUE2, + CHAR_COLORGREEN2, + CHAR_COLORBLACK, +}CHAR_COLOR; +/*====================ƽҷ¼====================*/ +void CHAR_createNewChar( int clifd, 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 ); + +/*====================ƽҷ¼̼====================*/ + +void CHAR_login( int clifd, char* data, int saveindex ); + +#define CHAR_warpToSpecificPoint( cindex, fl, x, y) _CHAR_warpToSpecificPoint( __FILE__, __LINE__, cindex, fl, x, y) +BOOL _CHAR_warpToSpecificPoint( char *file, int line, + int charaindex, int fl, int x, int y); + + +/*====================ƽҷ¼Ƥ====================*/ +/*====================ƽҷ¼ʧ====================*/ +BOOL CHAR_charSaveFromConnectAndChar( int fd,Char* ch, int unlock ); +BOOL CHAR_charSaveFromConnect( int charaindex,int unlock ); +#define CHAR_logout( charindex, save) _CHAR_logout( __FILE__, __LINE__, charindex, save) +BOOL _CHAR_logout( char *file, int line, int charindex, BOOL save); + +/*====================watch event ====================*/ +void CHAR_sendWatchEvent( int objindex, int chac, int* opt,int optlen,BOOL myflg ); + +/*====================ƽ====================*/ +BOOL CHAR_Skillupsend(int charaindex ); +void CHAR_SkillUp( int charaindex, int skillid ); +void CHAR_useSkill( int charaindex, int dir ,int skindex ); + +typedef enum +{ + CHAR_WALKSUCCESSED, /* */ + CHAR_WALKSYSTEMERROR, /* ˵ ة޷¡ indexͱ + * Ⱦ羮 */ + CHAR_WALKEXTEND, /* ƻڳףNPC弰*/ + CHAR_WALKHITOBJECT, /* Ͼ Ȼئ */ + CHAR_WALKPREWALK, /* prewalkìƥئ( ޼ ) */ + CHAR_WALKDIE, /* ƥлئ */ + CHAR_WALK1357, /* 껧 ڳƻئ */ +}CHAR_WALKRET; + +/*====================ƽҷ¼ ====================*/ +void CHAR_ctodirmode(char moji , int* dir , int* mode); +INLINE void CHAR_getDXDY( int dir , int* dx, int* dy ); +INLINE int CHAR_getDX( int dir ); +INLINE int CHAR_getDY( int dir ); +int CHAR_getSameCoordinateObjects(int* objbuf, int siz,int ff, int fx, int fy); +void CHAR_walkcall( int index ); +void CHAR_walk_start(int index, int x, int y, char* dir, BOOL mapsendmode); +void CHAR_walk_init( int fd, int x, int y, char *direction, BOOL mapsendmode); + +CHAR_WALKRET CHAR_walk(int index, int dir, int mode); + +#ifdef _CAX_LNS_NLGSUOXU +CHAR_WALKRET CHAR_walk_jjc( int index, int floor, int ox, int oy, int dir); +CHAR_WALKRET CHAR_walk_jc( int charaindex, int of, int ox, int oy, int dir );//ǰϰ +#endif + +char* CHAR_makeOptionString( Char* ch ); +char* CHAR_makeStatusString( int index, char* category ); + +#define CHAR_makeObjectCString( objindex, buf, buflen) _CHAR_makeObjectCString( __FILE__, __LINE__, objindex, buf, buflen) +BOOL _CHAR_makeObjectCString( char *file, int line, int objindex, char* buf, int buflen ); + +//BOOL CHAR_sendStatusString( int charaindex, char* category ); +#define CHAR_sendStatusString( A, B) _CHAR_sendStatusString( A, B, __FILE__, __LINE__ ) +BOOL _CHAR_sendStatusString( int charaindex, char* category, char* file, int line ); +BOOL CHAR_sendItemData( int charaindex, int *itemgroup, int num); +BOOL CHAR_sendItemDataOne( int charaindex, int haveitemindex); +BOOL CHAR_send_P_StatusString( int charaindex, unsigned int indextable ); +BOOL CHAR_send_N_StatusString( int charaindex, int num, unsigned int indextable ); +BOOL CHAR_send_K_StatusString( int charaindex, int num, unsigned int indextable ); + +void CHAR_inputOwnTitle( int index ,char* name ); + +void CHAR_selectTitle( int index, int titleindex ); +void CHAR_deleteTitle( int index, int titleindex ); + +#define CHAR_complianceParameter( index) _CHAR_complianceParameter( index, __FILE__, __LINE__) +int _CHAR_complianceParameter( int index, char *FILE, int LINE); +int CHAR_complianceParameter2( int index); + +int CHAR_findSurplusItemBox( int index ); +int CHAR_findEmptyItemBox( int index ); +int CHAR_findEmptyPoolItemBox( int index ); +int CHAR_findEmptyItemBoxNo( int index ); + +void CHAR_moveEquipItem( int index, int fromindex, int toindex ); +#ifdef _PET_ITEM +void CHAR_movePetItem( int index, int petid, int fromindex, int toindex ); +void CHAR_sendPetItemData( int charaindex, int petid); +#endif +void CHAR_ItemUse( int charaindex, int to_charaindex, int haveitemindex ); +void CHAR_DropItem( int charaindex, int itemindex ); +int CHAR_DropItemAbsolute( int itemindex, int floor, int x, int y,BOOL net); +BOOL CHAR_DropItemFXY( int charaindex, int itemcharaindex, int fl, + int x, int y, int* objindex ); +int CHAR_addItemSpecificItemIndex( int charaindex, int itemindex ); + +void CHAR_PickUpItem( int charaindex, int dir ); +void CHAR_DropMoney( int charaindex, int amount ); +int CHAR_addItem( int charaindex, int itemid ); +int CHAR_addItemToChar( Char* ch, int itemid ); + +int CHAR_pickupFollowPet( int charaindex, int petindex ); + +#ifdef _GAMBLE_ROULETTE +int NPC_MAPCLEANGOLD( int meindex , int floor); +#endif + +#ifdef _DROPSTAKENEW +#define MAXSTAKENUM 5 +int CasinoAccumulation(int charindex, int npcindex, int floor, int wincasinotype); +void CHAR_talkToFloor(int floor, int talkindex, char* message, CHAR_COLOR color); +int SetCasinoMap(int npcindex, int casinotype, int mapdropflag); +int CasinoPay(int npcindex, int wincasinotype); +#endif + +void CHAR_sendCSpecifiedObjindex( int fd, int index); +void CHAR_sendSpecifiedobjindexCToCharaindex(int charaindex,int objindex); + +void CHAR_sendCToArroundCharacter( int charaindex ); + +void CHAR_sendArroundCharaData( int charaindex ); + +void CHAR_sendCDArroundChar( int fl, int x, int y, int objindex ); +void CHAR_sendCDArroundChar_Main( int fl, int x, int y, int objindex, BOOL mode ); + + +void CHAR_Look( int charaindex, int dir ); + +void CHAR_initChatMagic(void); + +char* CHAR_appendNameAndTitle( int charaindex, char* src, char* buf, + int buflen ); +void CHAR_Talk( int fd, int index,char* message,int color, int area ); + +void CHAR_Loop( void ); + +#ifdef _PET_ITEM +void CHAR_sendPetItemData( int charaindex, int petid); +void CHAR_sendPetItemEmpty( int charaindex, int petid); +#endif + +#define WINDOW_BUTTONTYPE_NONE (0) +#define WINDOW_BUTTONTYPE_OK (1 << 0) +#define WINDOW_BUTTONTYPE_CANCEL (1 << 1) +#define WINDOW_BUTTONTYPE_YES (1 << 2) +#define WINDOW_BUTTONTYPE_NO (1 << 3) +#define WINDOW_BUTTONTYPE_PREV (1 << 4) +#define WINDOW_BUTTONTYPE_NEXT (1 << 5) + +#define WINDOW_BUTTONTYPE_OKCANCEL (WINDOW_BUTTONTYPE_OK | WINDOW_BUTTONTYPE_CANCEL) +#define WINDOW_BUTTONTYPE_YESNO (WINDOW_BUTTONTYPE_YES | WINDOW_BUTTONTYPE_NO) + + +typedef enum +{ + WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_MESSAGETYPE_MESSAGEANDLINEINPUT, + WINDOW_MESSAGETYPE_SELECT, + WINDOW_MESSAGETYPE_PETSELECT, + WINDOW_MESSAGETYPE_PARTYSELECT, + WINDOW_MESSAGETYPE_PETANDPARTYSELECT, + WINDOW_MESSAGETYPE_ITEMSHOPMENU, + WINDOW_MESSAGETYPE_ITEMSHOPMAIN, + WINDOW_MESSAGETYPE_LIMITITEMSHOPMAIN, + WINDOW_MESSAGETYPE_PETSKILLSHOP, + WINDOW_MESSAGETYPE_WIDEMESSAGE, + WINDOW_MESSAGETYPE_WIDEMESSAGEANDLINEINPUT, + WINDOW_MESSAGETYPE_POOLITEMSHOPMENU, + WINDOW_MESSAGETYPE_POOLITEMSHOPMAIN, + + WINDOW_MESSAGETYPE_FAMILYADD, + WINDOW_MESSAGETYPE_FAMILYJOIN, + WINDOW_MESSAGETYPE_FAMILYOUT, + WINDOW_MESSAGETYPE_FAMILYEND, +//======================================= + // shan add + WINDOW_FMMESSAGETYPE_SELECT, + WINDOW_FMMESSAGETYPE_DENGON, + WINDOW_FMMESSAGETYPE_FMSDENGON, + WINDOW_FMMESSAGETYPE_POINTLIST, +#ifdef _FMVER21 + WINDOW_FMMESSAGETYPE_TOP30DP, +#endif + WINDOW_FMMESSAGETYPE_DP, + WINDOW_MESSAGETYPE_BANK, + + // Arminius 7.12 scheduleman + WINDOW_MESSAGETYPE_PKSCHEDULELIST, + WINDOW_MESSAGETYPE_PKSCHEDULESELECTFAMILY, + WINDOW_MESSAGETYPE_PKSCHEDULEDETAIL, + + // Robin + WINDOW_MESSAGETYPE_LOGINMESSAGE, + WINDOW_MESSAGETYPE_FAMILYTAX, + WINDOW_MESSAGETYPE_SHOWRIDEPET, + WINDOW_MESSAGETYPE_FAMILYDETAIL, + + WINDOW_MESSAGETYPE_LEADERSELECT, + WINDOW_MESSAGETYPE_LEADERSELECTQ, + WINDOW_MESSAGETYPE_LEADERSELECTA, + + // Arminius 1.3 Auctioneer + WINDOW_MESSAGETYPE_AUCTIONNEW, + WINDOW_MESSAGETYPE_AUCTIONLIST_BUY, + WINDOW_MESSAGETYPE_AUCTIONSURVEY, + WINDOW_MESSAGETYPE_AUCTIONMODIFY, + WINDOW_MESSAGETYPE_AUCTIONLIST_MODIFY, +#ifdef _NPC_FUSION + WINDOWS_MESSAGETYPE_PETFUSION, +#endif + +#ifdef _PETSKILL_CANNEDFOOD + WINDOWS_MESSAGETYPE_PETSKILLSHOW, +#endif + +#ifdef _PROFESSION_SKILL // WON ADD ְҵ + WINDOW_MESSAGETYPE_PROFESSIONSHOP, +#endif + +#ifdef _NEW_MANOR_LAW + WINDOW_FMMESSAGETYPE_10_MEMONTUM, // ʮƼ + WINDOW_FMMESSAGETYPE_FM_MEMONTUM, // Լ + WINDOW_FMMESSAGETYPE_MANOR_SCHEDULE, // սׯ԰ +#endif + +#ifdef _ANGEL_SUMMON + WINDOW_MESSAGETYPE_ANGELMESSAGE = 101, + WINDOW_MESSAGETYPE_ANGELASK, +#endif + +#ifdef _MOUSE_DBL_CLICK + WINDOW_MESSAGETYPE_MOUSEGETNAME, +#endif + +#ifdef _RACEMAN + WINDOW_MESSAGETYPE_RACEMAN_RANK, +#endif + + WINDOW_MESSAGETYPE_RANDMSG_PIC=999, + +}WINDOW_MESSAGETYPE; + +typedef enum +{ + CHAR_WINDOWTYPE_RETURNTOELDER=-1, /* Ӯ ū */ + CHAR_WINDOWTYPE_RESURRECTION=-2, /* ū */ + + CHAR_WINDOWTYPE_SELECTBATTLE = 1, /* ¾ ë ū */ + CHAR_WINDOWTYPE_SELECTDUEL = 2, /* DUELë ū */ + CHAR_WINDOWTYPE_SELECTTRADECARD = 3, /* ͭë ū */ + CHAR_WINDOWTYPE_SELECTPARTY = 4, /* ɡ ūë ū */ + CHAR_WINDOWTYPE_SELECTBATTLEWATCH = 5, /* ë ū */ + CHAR_WINDOWTYPE_MICMESSAGE = 6, /* MICNPCëȻū */ + + // CoolFish: Trade 2001/4/18 + CHAR_WINDOWTYPE_SELECTTRADE = 7, /* Window */ + + CHAR_WINDOWTYPE_SELECTRENAMEITEM_PAGE1 = 10, /* ë ʧ ةë ū */ + CHAR_WINDOWTYPE_SELECTRENAMEITEM_PAGE2 = 11, /* ë ʧ ةë ū */ + CHAR_WINDOWTYPE_SELECTRENAMEITEM_PAGE3 = 12, /* ë ʧ ةë ū */ + CHAR_WINDOWTYPE_SELECTRENAMEITEM_PAGE4 = 13, /* ë ʧ ةë ū */ + CHAR_WINDOWTYPE_SELECTRENAMEITEM_RENAME = 14, /* ë ū */ + CHAR_WINDOWTYPE_SELECTRENAMEITEM_RENAME_ATTENTION = 15, /* ë ū */ + + CHAR_WINDOWTYPE_DENGON = 50, /* */ + + CHAR_WINDOWTYPE_WINDOWMAN_START = 100, + CHAR_WINDOWTYPE_WINDOWMAN_STARTMSG = CHAR_WINDOWTYPE_WINDOWMAN_START, + CHAR_WINDOWTYPE_WINDOWMAN_END = 200, + + CHAR_WINDOWTYPE_JANKEN_START = 210, + CHAR_WINDOWTYPE_JANKEN_MAIN = 211, + CHAR_WINDOWTYPE_JANKEN_END = 212, + + CHAR_WINDOWTYPE_TRANSMIGRATION_START = 213, + CHAR_WINDOWTYPE_TRANSMIGRATION_MAIN = 214, + CHAR_WINDOWTYPE_TRANSMIGRATION_END = 215, + CHAR_WINDOWTYPE_TRANSMIGRATION_NONE = 216, + + + CHAR_WINDOWTYPE_WINDOWHEALER_START = 220, + CHAR_WINDOWTYPE_WINDOWHEALER_STARTMSG = CHAR_WINDOWTYPE_WINDOWHEALER_START, + CHAR_WINDOWTYPE_WINDOWHEALER_HPMSG = 221, + CHAR_WINDOWTYPE_WINDOWHEALER_OKHPMSG = 222, + CHAR_WINDOWTYPE_WINDOWHEALER_SPIRITMSG = 223, + CHAR_WINDOWTYPE_WINDOWHEALER_OKSPIRITMSG = 224, + CHAR_WINDOWTYPE_WINDOWHEALER_ALLMSG = 225, + CHAR_WINDOWTYPE_WINDOWHEALER_OKALLMSG = 226, + CHAR_WINDOWTYPE_WINDOWHEALER_END = 227, + + CHAR_WINDOWTYPE_WINDOWSAVEPOINT_START = 230, + + CHAR_WINDOWTYPE_WINDOWEVENT_STARTMSG = 231, + CHAR_WINDOWTYPE_WINDOWEVENT_NOWEVENT = 232, + CHAR_WINDOWTYPE_WINDOWEVENT_ENDEVENT = 233, + CHAR_WINDOWTYPE_WINDOWEVENT_REQMAINMSG = 234, + CHAR_WINDOWTYPE_WINDOWEVENT_ACCMAINMSG = 235, + CHAR_WINDOWTYPE_WINDOWEVENT_NOMALMSG = 236, + CHAR_WINDOWTYPE_WINDOWEVENT_CLEANMSG = 237, + CHAR_WINDOWTYPE_WINDOWEVENT_REQTHANK = 238, + CHAR_WINDOWTYPE_WINDOWEVENT_ACCTHANK = 239, + + + CHAR_WINDOWTYPE_WINDOWITEMSHOP_START = 240, + CHAR_WINDOWTYPE_WINDOWITEMSHOP_STARTMSG = CHAR_WINDOWTYPE_WINDOWITEMSHOP_START, + CHAR_WINDOWTYPE_WINDOWITEMSHOP_MENU = 241, + CHAR_WINDOWTYPE_WINDOWITEMSHOP_BUY_MSG = 242, + CHAR_WINDOWTYPE_WINDOWITEMSHOP_SELL_MSG = 243, + CHAR_WINDOWTYPE_WINDOWITEMSHOP_END = 244, + CHAR_WINDOWTYPE_WINDOWITEMSHOP_LIMIT = 245, + CHAR_WINDOWTYPE_WINDOWITEMSHOP_EXPRESS = 246, + + CHAR_WINDOWTYPE_DUELRANKING_START = 250, + CHAR_WINDOWTYPE_DUELRANKING_TOPRANKING = 251, + CHAR_WINDOWTYPE_DUELRANKING_MYRANKING = 252, + CHAR_WINDOWTYPE_DUELRANKING_WAIT = 253, + CHAR_WINDOWTYPE_DEFEND_BILLDBOARD = 254, + + CHAR_WINDOWTYPE_WINDOWPETSKILLSHOP = 260, + + CHAR_WINDOWTYPE_WINDOWPETSHOP_START = 261, + CHAR_WINDOWTYPE_WINDOWPETSHOP_PETSELECT = 262, + CHAR_WINDOWTYPE_WINDOWPETSHOP_MAIN = 263, + CHAR_WINDOWTYPE_WINDOWPETSHOP_GOLDOVER = 264, + CHAR_WINDOWTYPE_WINDOWPETSHOP_PETSELECT2 = 265, + CHAR_WINDOWTYPE_WINDOWPETSHOP_MAIN2 = 266, + CHAR_WINDOWTYPE_WINDOWPETSHOP_DRAWSELECT = 267, + CHAR_WINDOWTYPE_WINDOWPETSHOP_ASKDRAW = 268, + CHAR_WINDOWTYPE_WINDOWPETSHOP_END = 269, + + CHAR_WINDOWTYPE_WINDOWWARPMAN_MAIN = 271, + CHAR_WINDOWTYPE_WINDOWWARPMAN_ERR = 272, + CHAR_WINDOWTYPE_WINDOWWARPMAN_END = 273, + + CHAR_WINDOWTYPE_NPCENEMY_START = 281, + + CHAR_WINDOWTYPE_CHARM_START = 282, + CHAR_WINDOWTYPE_CHARM_END = 283, + + CHAR_WINDOWTYPE_QUIZ_START = 284, + CHAR_WINDOWTYPE_QUIZ_MAIN = 285, + CHAR_WINDOWTYPE_QUIZ_END = 286, + + CHAR_WINDOWTYPE_CHECKMAN_START = 287, + CHAR_WINDOWTYPE_CHECKMAN_MAIN = 288, + CHAR_WINDOWTYPE_CHECKMAN_END = 289, + + CHAR_WINDOWTYPE_FAMILYMAN_START = 320, + CHAR_WINDOWTYPE_FAMILYMAN_ADD = 321, + CHAR_WINDOWTYPE_FAMILYMAN_JOIN = 322, + CHAR_WINDOWTYPE_FAMILYMAN_OUT = 323, + CHAR_WINDOWTYPE_FAMILYMAN_BROKEN = 324, + + CHAR_WINDOWTYPE_BANKMAN = 330, + + // CoolFish: FMPKMan 2001/7/4 + CHAR_WINDOWTYPE_FMPKMAN_START = 340, + CHAR_WINDOWTYPE_FMPKMAN_VIEW = 341, + CHAR_WINDOWTYPE_FMPKMAN_LEAVEPK = 342, + CHAR_WINDOWTYPE_FMPKCALLMAN_START = 345, + CHAR_WINDOWTYPE_FMPKCALLMAN_CALL = 346, + CHAR_WINDOWTYPE_FMPKCALLMAN_COME = 347, + CHAR_WINDOWTYPE_FMPKCALLMAN_LEAVE = 348, + + // Arminius 7.13 scheduleman + CHAR_WINDOWTYPE_SCHEDULEMAN_START = 350, + CHAR_WINDOWTYPE_SCHEDULEMAN_SELECT = 351, + CHAR_WINDOWTYPE_SCHEDULEMAN_DETAIL = 352, + + // Arminius 7.27 + CHAR_WINDOWTYPE_MANORPK_START = 360, + CHAR_WINDOWTYPE_MANORPK_ASK = 361, + CHAR_WINDOWTYPE_MANORPK_END = 362, + + // shan + CHAR_WINDOWTYPE_FM_DENGON = 370, // ԰ + CHAR_WINDOWTYPE_FM_FMSDENGON = 371, // ֮԰ + CHAR_WINDOWTYPE_FM_MESSAGE1 = 372, // ˵Ӵ(ݵ) + CHAR_WINDOWTYPE_FM_MESSAGE2 = 373, // ˵Ӵ(Ա) + CHAR_WINDOWTYPE_FM_SELECT = 374, // ѡӴ + CHAR_WINDOWTYPE_FM_MEMBERLIST = 375, // Աб + CHAR_WINDOWTYPE_FM_POINTLIST = 376, // ݵб + CHAR_WINDOWTYPE_FM_DPTOP = 377, // ǿ߱(ǰʮа) + CHAR_WINDOWTYPE_FM_DPME = 378, // ǿ߱(Լа) + CHAR_WINDOWTYPE_FM_DPSELECT = 379, // ǿ߱ѡӴ + +#ifdef _PET_TRANS + CHAR_WINDOWTYPE_PETTRANS_START = 384, + CHAR_WINDOWTYPE_PETTRANS_SELECT = 385, + CHAR_WINDOWTYPE_PETTRANS_SELPET = 386, + CHAR_WINDOWTYPE_PETTRANS_MAIN1 = 387, + CHAR_WINDOWTYPE_PETTRANS_END = 389, +#endif + +#ifdef _GAMBLE_BANK + NPC_GambleBank_START = 390, + NPC_GambleBank_SELECT, + NPC_GambleBank_BANK, + NPC_GambleBank_CHANG1, + NPC_GambleBank_CHANG2, + NPC_GambleBank_END, +#endif + +#ifdef _PETRACE + CHAR_WINDOWTYPE_PETRACEMASTER_START = 410, + CHAR_WINDOWTYPE_PETRACEMASTER_RULE, + CHAR_WINDOWTYPE_PETRACEMASTER_PET, + CHAR_WINDOWTYPE_PETRACEMASTER_LEAVE, +#endif + +#ifdef _GAMBLE_ROULETTE + WINDOWTYPE_GAMBLEROULETTE_START = 415, + WINDOWTYPE_GAMBLEROULETTE_SELECT, + WINDOWTYPE_GAMBLEROULETTE_END, +#endif + +#ifdef _NEWEVENT + CHAR_WINDOWTYPE_WINDOWEVENT_ACCTHANKNEW = 430, +#endif + +#ifdef _TRANSER_MAN + NPC_TRANSERMAN_START = 440, + NPC_TRANSERMAN_SELECT, + NPC_TRANSERMAN_WARP, + NPC_TRANSERMAN_END, +#endif +#ifdef _ITEM_NPCCHANGE + NPC_ITEMCHANGE_START = 445, + NPC_ITEMCHANGE_SELECT, + NPC_ITEMCHANGE_MESSAGE, + NPC_ITEMCHANGE_END, +#endif +#ifdef _ADD_FAMILY_TAX // WON ADD ׯ԰˰ + CHAR_WINDOWTYPE_FAMILY_TAX = 450, +#endif + +#ifdef _ALLDOMAN // (ɿ) Syu ADD аNPC + NPC_ALLDOMAN_START = 460, + NPC_ALLDOMAN_START2, + NPC_ALLDOMAN_START3, + NPC_ALLDOMAN_HEAL, + NPC_ALLDOMAN_GIVEMONEY, + NPC_ALLDOMAN_MAIN_WND , + NPC_ALLDOMAN_SELECT_WND , + NPC_ALLDOMAN_LIST_WND , +#endif + +#ifdef _PETSKILL_CANNEDFOOD + ITEM_WINDOWTYPE_SELECTPETSKILL_SELECT = 470, + ITEM_WINDOWTYPE_SELECTPETSKILL_END, +#endif + +#ifdef _NPC_WELFARE + NPC_WELFARE_START = 480, + NPC_WELFARE_END, +#endif + +#ifdef _NPC_DEPOTPET + CHAR_WINDOWTYPE_DEPOTPETSHOP_MENU = 510, + CHAR_WINDOWTYPE_DEPOTPETSHOP_HANDLE, + CHAR_WINDOWTYPE_DEPOTPETSHOP_ADD, + CHAR_WINDOWTYPE_DEPOTPETSHOP_GET, + CHAR_WINDOWTYPE_DEPOTPETSHOP_ASKADD, + CHAR_WINDOWTYPE_DEPOTPETSHOP_ASKGET, +#endif + +#ifdef _ANGEL_SUMMON + CHAR_WINDOWTYPE_ANGEL_ASK = 520, + CHAR_WINDOWTYPE_ANGEL_CLEAN, +#endif + +#ifdef _SAFE_PASSWORD + CHAR_WINDOWTYPE_SAFE_PASSWORD1 = 530, + CHAR_WINDOWTYPE_SAFE_PASSWORD2 = 540, + CHAR_WINDOWTYPE_SAFE_PASSWORD3, +#endif + +#ifdef _POINT_CARD + CHAR_WINDOWTYPE_POINT_CARD = 550, +#endif + CHAR_WINDOWTYPE_RAND_WARP = 560, + CHAR_WINDOWTYPE_RAND_MSG = 561, + CHAR_WINDOWTYPE_ITEM_MSG = 562, + + CHAR_STREETVENDOR_SELECT = 570, + CHAR_WINDOWTYPE_QUESTIONONLINE = 580, +#ifdef _SQL_BUY_FUNC + CHAR_WINDOWTYPE_ONLINE_BUY, +#endif +#ifdef _PET_RESET + CHAR_WINDOWTYPE_RESETPET, + CHAR_WINDOWTYPE_RESETBDPET, +#endif +#ifdef _ZHIPIAO_SYSTEM + CHAR_WINDOWTYPE_ZHIPIAO_1, + CHAR_WINDOWTYPE_ZHIPIAO_2, + CHAR_WINDOWTYPE_ZHIPIAO_3, +#endif +#ifdef _NO_DROPITEM + CHAR_WINDOWTYPE_DROPITEM, +#endif +#ifdef _NPC_ITEMUP + NPC_ITEMUP_START, + NPC_ITEMUP_SELECT1, + NPC_ITEMUP_SELECT2, + NPC_ITEMUP_MESSAGE, + NPC_ITEMUP_END, +#endif +#ifdef _ITEM_RESET + CHAR_WINDOWTYPE_RESETITEM, + CHAR_WINDOWTYPE_DELITEM, +#endif + CHAR_WINDOWTYPE_RAND1_EDITBASE, + CHAR_WINDOWTYPE_RAND2_EDITBASE, + CHAR_WINDOWTYPE_RAND3_EDITBASE, + CHAR_WINDOWTYPE_RAND4_EDITBASE, +#ifdef _MM_NO_JIAOBEN + CHAR_WINDOWTYPE_RAND1_DROPMM, + CHAR_WINDOWTYPE_RAND2_DROPMM, + CHAR_WINDOWTYPE_RAND3_DROPMM, + CHAR_WINDOWTYPE_RAND4_DROPMM, + CHAR_WINDOWTYPE_RAND1_FLLOWMM, + CHAR_WINDOWTYPE_RAND2_FLLOWMM, + CHAR_WINDOWTYPE_RAND3_FLLOWMM, + CHAR_WINDOWTYPE_RAND4_FLLOWMM, +#endif +#ifdef _FM_NPC_LOOK_WAR + NPC_FMLOOKWARMAN_START, + NPC_FMLOOKWARMAN_SELECT, + NPC_FMLOOKWARMAN_LOOK, +#endif +#ifdef _FM_NPC_LOOK_WAR1 + NPC_FMLOOKWARMAN1_START, + NPC_FMLOOKWARMAN1_SELECT, + NPC_FMLOOKWARMAN1_LOOK, +#endif +#ifdef _DP_ZHIPIAO_ITEM + CHAR_WINDOWTYPE_DPZHIPIAO_1, + CHAR_WINDOWTYPE_DPZHIPIAO_2, + CHAR_WINDOWTYPE_DPZHIPIAO_3, +#endif +#ifdef _NPC_RAND_MSG + CHAR_WINDOWTYPE_NPC_RAND1_MSG, + CHAR_WINDOWTYPE_NPC_RAND2_MSG, + CHAR_WINDOWTYPE_NPC_RAND3_MSG, + CHAR_WINDOWTYPE_NPC_RAND4_MSG, +#endif + CHAR_WINDOWTYPE_NPCENEMY_RAND_MSG, + CHAR_WINDOWTYPE_LUANPC_RANDMSG, +#ifdef _NULL_CHECK_ITEM + CHAR_WINDOWTYPE_NULL_CHECK, +#endif +}CHAR_WINDOWTYPE; + +#ifdef _GMRELOAD +typedef struct tagGMInfo +{ + char cdkey[24]; + int level; +}GMInfo; +#endif + + +#ifdef _ANGEL_SUMMON + +#define MAXMISSION 100 +#define MAXMISSIONTABLE 200 + +struct MissionInfo +{ + int id; + char detail[1024]; + int level; + char eventflag[1024]; + //char bonus[1024]; + int limittime; +}; + +struct MissionTable +{ + char angelinfo[128]; + char heroinfo[128]; + int mission; + int flag; + int time; + int limittime; +}; + +extern struct MissionInfo missionlist[MAXMISSION]; +extern struct MissionTable missiontable[MAXMISSIONTABLE]; + +#endif + +#ifdef _JOBDAILY + +#define MAXDAILYLIST 1000 +#define MAXMISSIONFLAG 1000 +typedef struct _DailyFileType +{ + int jobid; // + char rule[64]; //ж + char explain[64]; //˵ + char state[64]; //״̬˵ +}DailyFileType; +//extern struct DailyFileType dailyfile[MAXDAILYLIST]; + +#endif + +BOOL CHAR_talkToCli( int talkedcharaindex,int talkcharaindex, char* message, CHAR_COLOR color ); +void system_all_talk( char* data ); +void player_all_talk( int charaindex, char* data ); +void CHAR_talkToCliAndParty( int talkedcharaindex,int talkcharaindex,char* message, CHAR_COLOR color ); + +BOOL CHAR_talkToCharacter( int talkedcharaindex,int talkcharaindex, char* message ); +void CHAR_getCoordinationDir( int dir , int x, int y ,int c, + int *xout , int *yout ); +BOOL CHAR_createCharacter( int type, int floor, int x, int y, int dir, + int* charaindex, int* objindex, BOOL seemap ); +void CHAR_CharaDelete( int charaindex ); +void CHAR_ObjectDelete( int objindex ); +int CHAR_makeDBKey( int charaindex, char *pszBuffer, int size ); +int CHAR_getEmptyPartyArray( int charaindex); +int CHAR_getPartyNum( int charaindex); +BOOL CHAR_JoinParty( int charaindex ); +BOOL CHAR_JoinParty_Main( int charaindex, int targetindex); +BOOL CHAR_DischargeParty( int charaindex, int flg); +BOOL CHAR_DischargePartyNoMsg( int charaindex); +BOOL CHAR_setMyPosition_main( int index, int x, int y, int setdir, BOOL CAFlg); +BOOL CHAR_setMyPosition( int index, int x, int y, BOOL CAFlg); + +void CHAR_CharaDeleteHavePet( int charaindex); +int CHAR_sendAction( int charaindex, int action, int mode); +void CHAR_sendLeader( int objindex, int leader); +void CHAR_sendBattleWatch( int objindex, int onoff); +void CHAR_sendBattleEffect( int charaindex, int onoff); + +// shan +void CHAR_sendTradeEffect( int charaindex, int onoff); +#ifdef _MIND_ICON +void CHAR_sendMindEffect( int charaindex, int onoff); +#endif +#ifdef _ITEM_CRACKER +void CHAR_sendCrackerEffect( int charaindex, int onoff); +#endif + +void CHAR_inputUserPetName( int index , int havepetindex, char* name ); +int CHAR_getPartyIndex( int index, int num); +void CHAR_processWindow(int charaindex, int seqno, int select, + int objindex, char* data ); +void CHAR_AddCharm( int charaindex, int iValue ); +void CHAR_PetAddVariableAi( int petindex, int iValue ); +void CHAR_PartyUpdate( int charaindex, int senddata ); +char *CHAR_getUseName( int charaindex ); +char *CHAR_getUseID( int charaindex ); +EXTERN int EnemyMoveNum; /* ݱ ³ļ */ + +#define DB_DUELPOINT "db_duel" // ب޻̼ì +#define DB_ADDRESSBOOK "db_addressbook" // ʧƤͷì + +BOOL CHAR_send_DpDBUpdate( int charaindex ); +BOOL CHAR_send_DpDBUpdate_AddressBook( int charaindex, int mode ); + + +void CHAR_sendPMEToArroundCharacter( int charaindex, int petindex, int flg, int no ); +void CHAR_sendPMEToArroundCharacterFLXY( int petindex, + int fl, int x, int y, int dir, int flg, int no ); + +void CHAR_sendSEoArroundCharacter( int fl, int x, int y, int senumber, int sw ); + +BOOL CHAR_initEffectSetting( char* filename ); +void CHAR_checkEffect( int charaindex); +void CHAR_checkEffectLoop( void); +void CHAR_initDebugChatCdkey( void); +int CHAR_setChatMagicCDKey( int mode, char *cdkey); + + +float GetRecoveryRate( int charaindex ); +int storeCharaData( void ); +#ifdef _MAGIC_REHPAI //ѪAI +int Magic_RideGetHP( int toindex, int petindex, int flg); +#endif +// CoolFish: Trade 2001/4/18 +int CHAR_findTotalEmptyItem(int index); + + +#ifdef _FIX_METAMORIDE +int CHAR_CHECKJOINENEMY( int index); +#endif + +#ifdef _SEND_EFFECT // WON ADD ACѩЧ +#define CHAR_EFFECT_SETTINGBUFFER 256 +typedef struct tagCHAR_effectsetting +{ + int floor; // ׷ʧ + int effect; // į + int level; // 뼰ì ؼ۽ + int sendflg; // ްë˪׾ + char month[CHAR_EFFECT_SETTINGBUFFER]; // » + char day[CHAR_EFFECT_SETTINGBUFFER]; // + char hour[CHAR_EFFECT_SETTINGBUFFER]; // + char min[CHAR_EFFECT_SETTINGBUFFER]; // + char expire[CHAR_EFFECT_SETTINGBUFFER]; // ƻӮ( + +}CHAR_effectsetting; + +CHAR_effectsetting* CHAR_effect; +int CHAR_effectnum; +#endif + +#ifdef _ITEM_PILENUMS +int CHAR_getMyMaxPilenum( int charaindex); +#endif + +#ifdef _PET_LOSTPET +BOOL CHAR_CharSaveLostPet( int petindex, int type); +#endif +#ifdef _ALLDOMAN +void InitHeroList( void); +#endif +#endif + +#ifdef _STREET_VENDOR +void CHAR_sendStreetVendor(int charaindex,char *message); +void CHAR_sendStreetVendorDataToCli(int charaindex,int toindex); +void CHAR_sendStreetVendorOneDataToCli(int charaindex,int toindex,int sendindex); +#endif + +BOOL checkUnlawWarpFloor( int floor); + +#ifdef _HELP_NEWHAND +void CHAR_loginAddItemForNew( int charaindex ); +#endif + +#ifdef _JOBDAILY +void CHAR_JobDaily(int charaindex,char *data); +#endif + +#ifdef _TEACHER_SYSTEM +void CHAR_Teacher_system(int charaindex,char *data); +void CHAR_Teacher_system_View(int charaindex,int iOnLine,char *data); +#endif + +#ifdef _TIME_TICKET +void check_TimeTicket(); +int check_TimeTicketMap(int floor); +#endif + +void CHAR_CheckItemTime( int charaindex ); +void CHAR_loginCheckUserItem( int charaindex); diff --git a/include/char_base.h b/include/char_base.h new file mode 100644 index 0000000..54b000e --- /dev/null +++ b/include/char_base.h @@ -0,0 +1,2072 @@ +#ifndef __CHAR_BASE_H__ +#define __CHAR_BASE_H__ + +#include "version.h" +#include "skill.h" +#include "title.h" +/*#include "magicinfo.h"*/ +#include "addressbook.h" +#ifdef _ALLBLUES_LUA +#include "lua.h" +#include "lauxlib.h" +#include "lualib.h" +#endif +#define CHAR_DELIMITER "\n" + +#define NONCHAR_DELIMITER "|" + +#define STATUSSENDDELIMITER "|" + +#define CHAR_MAXGOLDHAVE (10000*10000) +#define CHAR_MAXBANKGOLDHAVE (10000*10000) +#define CHAR_MAXFMBANKGOLDHAVE (10000*100000) + +#ifdef _NEW_MANOR_LAW +#define MAX_PERSONAL_MOMENTUM 10000000 +#endif +#ifdef _PERSONAL_FAME // Arminius 8.30: +#define MAX_PERSONALFAME 100000000 +#endif +#ifdef _PROFESSION_SKILL // WON ADD ְҵ +#define CHAR_SKILLMAXHAVE 26 // ְҵ +#else +#define CHAR_SKILLMAXHAVE 5 +#endif + +#ifdef _STREET_VENDOR +#define MAX_SELL_ITEM 20 // ߼ӳﹲʮ +#endif +#define CHAR_TITLEMAXHAVE 30 + +#define NULLSKILL "0" + +#define CHAR_MAXPETHAVE 5 +#define CHAR_MAXPERSONAGOLD 50000000 + +#ifdef _ADD_POOL_ITEM // WON ADD ӿɼķŵĵ +#define CHAR_MAXPOOLPETHAVE 15 +#else +#define CHAR_MAXPOOLPETHAVE 10 +#endif + +#define CHAR_MAXPETSKILLHAVE 7 +#define CHAR_PARTYMAX 5 +#define CHAR_PLAYERNPCMAX 4 +#define CHAR_MAXATTRIB 100 +#define CHAR_MAXUPLEVEL 200 +#define CHAR_MAXDUELPOINT 100000000 +#define CHAR_DEFAULTMAXAI (60) +#define CHAR_MAXVARIABLEAI (100*100) +#define CHAR_MINVARIABLEAI (-100*100) +#define CHAR_POISONSTRING "ж" +#define CHAR_RECOVERPOISONSTRING "ⶾ" +#define CHAR_PARALYSISSTRING "" +#define CHAR_RECOVERPARALYSISSTRING "" +#define CHAR_SILENCESTRING "޷ħ" +#define CHAR_RECOVERSILENCESTRING "ħ" +#define CHAR_STONESTRING "ʯ" +#define CHAR_RECOVERSTONESTRING "" +#define CHAR_DARKNESSSTRING "ܲ" +#define CHAR_RECOVERDARKNESSSTRING "ܳ" +#define CHAR_CONFUSIONSTRING "ֻ" +#define CHAR_RECOVERCONFUSIONSTRING "ָ" + +#define CHAR_DEFAULTSEESIZ 23 +#define MAP_CHAR_DEFAULTSEESIZ (CHAR_DEFAULTSEESIZ+4) + +typedef enum +{ + CHAR_HEAD, + CHAR_BODY, + CHAR_ARM, + CHAR_DECORATION1, + CHAR_DECORATION2, +#ifdef _ITEM_EQUITSPACE + CHAR_EQBELT, // + CHAR_EQSHIELD, // + CHAR_EQSHOES, //Ь +#endif +#ifdef _EQUIT_NEWGLOVE + CHAR_EQGLOVE, +#endif + CHAR_EQUIPPLACENUM, +}CHAR_EquipPlace; + + +#ifdef _PET_ITEM +typedef enum +{ + CHAR_PET_HEAD, //ͷ + CHAR_PET_TOOTH, // + CHAR_PET_CLAW, //צ + CHAR_PET_BREAST, // + CHAR_PET_BACK, // + CHAR_PET_WING, // + CHAR_PET_FEET, // + + CHAR_PETITEMNUM, +}CHAR_petitem; +#endif + + +typedef struct tagCharHaveSkill +{ + int use; + Skill skill; +}CHAR_HaveSkill; + +#ifdef _STREET_VENDOR +typedef struct STREET_VENDDOR_t{ + int pile; // + int price; // ۸ + int index; // + int kind; // ߻dz 0: 1: + BOOL usage; // Ƿʹ +}StreetVendor_t; + +enum{ + SV_PILE, + SV_PRICE, + SV_INDEX, + SV_KIND, + SV_USAGE, + MAX_SV +}; +#endif + +typedef enum +{ + CHAR_ACTSTAND, + CHAR_ACTWALK, + CHAR_ACTATTACK, + CHAR_ACTTHROW, + CHAR_ACTDAMAGE, + CHAR_ACTDEAD, + CHAR_ACTMAGIC, + CHAR_ACTITEM, + CHAR_ACTEFFECT, + CHAR_ACTDOWN = 10, + CHAR_ACTSIT, + CHAR_ACTHAND, + CHAR_ACTPLEASURE, + CHAR_ACTANGRY, + CHAR_ACTSAD, + CHAR_ACTGUARD, + CHAR_ACTACTIONWALK, + CHAR_ACTNOD, + CHAR_ACTACTIONSTAND, + CHAR_ACTBATTLE = 20, + CHAR_ACTLEADER, + CHAR_ACTBATTLEWATCH, + CHAR_ACTPOPUPNAME, + CHAR_ACTTURN = 30, + CHAR_ACTWARP, + CHAR_ACTTRADE, +#ifdef _ANGEL_SUMMON + CHAR_ACTANGEL = 34, +#endif + +#ifdef _MIND_ICON + CHAR_MIND = 40, +#endif +#ifdef _STREET_VENDOR + CHAR_STREETVENDOR_OPEN, + CHAR_STREETVENDOR_CLOSE, +#endif +#ifdef _ITEM_CRACKER + CHAR_ITEM_CRACKER = 50, +#endif +}CHAR_ACTION; + +typedef enum +{ + CHAR_CLIACTATTACK, + CHAR_CLIACTDAMAGE, + CHAR_CLIACTDOWN, + CHAR_CLIACTSTAND, + CHAR_CLIACTWALK, + CHAR_CLIACTSIT, + CHAR_CLIACTHAND, + CHAR_CLIACTPLEASURE, + CHAR_CLIACTANGRY, + CHAR_CLIACTSAD, + CHAR_CLIACTGUARD, + CHAR_CLIACTNOD, + CHAR_CLIACTTHROW, + +}CHAR_CLIENTACTION; + +typedef enum +{ + CHAR_TYPENONE, + CHAR_TYPEPLAYER, + CHAR_TYPEENEMY, + CHAR_TYPEPET, + CHAR_TYPEDOOR, + CHAR_TYPEBOX, + CHAR_TYPEMSG, + CHAR_TYPEWARP, + CHAR_TYPESHOP, + CHAR_TYPEHEALER, + CHAR_TYPEOLDMAN, + CHAR_TYPEROOMADMIN, + CHAR_TYPETOWNPEOPLE, + CHAR_TYPEDENGON, + CHAR_TYPEADM, + CHAR_TYPETEMPLE, + CHAR_TYPESTORYTELLER, + CHAR_TYPERANKING, + CHAR_TYPEOTHERNPC, + CHAR_TYPEPRINTPASSMAN, + CHAR_TYPENPCENEMY, + CHAR_TYPEACTION, + CHAR_TYPEWINDOWMAN, + CHAR_TYPESAVEPOINT, + CHAR_TYPEWINDOWHEALER, + CHAR_TYPEITEMSHOP, + CHAR_TYPESTONESHOP, + CHAR_TYPEDUELRANKING, + CHAR_TYPEWARPMAN, + CHAR_TYPEEVENT, + CHAR_TYPEMIC, + CHAR_TYPELUCKYMAN, + CHAR_TYPEBUS, + CHAR_TYPECHARM, + CHAR_TYPECHECKMAN, + CHAR_TYPEJANKEN, + CHAR_TYPETRANSMIGRATION, + CHAR_TYPEFMWARPMAN, // У˳Ա + CHAR_TYPEFMSCHEDULEMAN, // У˳ǼԱ + CHAR_TYPEMANORSCHEDULEMAN, // ׯ԰У˳ԤԼ +#ifdef _GAMBLE_BANK + CHAR_GAMBLEBANK, +#endif +#ifdef _NEW_WARPMAN + CHAR_NEWNPCMAN, +#endif + +#ifdef _GAMBLE_ROULETTE + CHAR_GAMBLEROULETTE, + CHAR_GAMBLEMASTER, +#endif +#ifdef _TRANSER_MAN + CHAR_TRANSERMANS, +#endif + +#ifdef _NPC_MAKEPAIR + CHAR_MAKEPAIR, +#endif +#ifdef _NPC_FUSION + CHAR_PETFUSIONMAN, +#endif + +#ifdef _ITEM_NPCCHANGE + CHAR_ITEMCHANGENPC, +#endif +#ifdef _CFREE_petskill + CHAR_FREESKILLSHOP, +#endif +#ifdef _PETRACE + CHAR_PETRACEMASTER, // ᄎ + CHAR_PETRACEPET, +#endif + +#ifdef _ALLDOMAN // (ɿ) Syu ADD аNPC + CHAR_TYPEALLDOMAN, +#endif + + CHAR_TYPEPETMAKER, // petmaker + +#ifdef _NPC_WELFARE + CHAR_TYPEWELFARE, +#endif +#ifdef _ALLBLUES_LUA + CHAR_TYPELUANPC, +#endif +#ifdef _JZ_NEWSCRIPT_LUA + CHAR_LUANPC, +#endif + +#ifdef _PLAYER_NPC + CHAR_TYPEPLAYERNPC, + CHAR_TYPEPLAYERPETNPC, +#endif + CHAR_TYPENUM, +}CHAR_TYPE; + +typedef enum +{ + CHAR_EVENT_NONE, + CHAR_EVENT_NPC, + CHAR_EVENT_ENEMY, + CHAR_EVENT_WARP, + CHAR_EVENT_DOOR, + CHAR_EVENT_ALTERRATIVE, + CHAR_EVENT_WARP_MORNING, + CHAR_EVENT_WARP_NOON, + CHAR_EVENT_WARP_NIGHT, + CHAR_EVENTNUM, +}CHAR_EVENT; + +typedef enum +{ + CHAR_PARTY_NONE, + CHAR_PARTY_LEADER, + CHAR_PARTY_CLIENT, +}CHAR_PARTY_MODE; + +typedef enum +{ + CHAR_TRADE_FREE, /* ɽ */ + CHAR_TRADE_SENDING, /* */ + CHAR_TRADE_TRADING, /* */ + CHAR_TRADE_LOCK, /* */ +}CHAR_TRADE_MODE; + +typedef enum +{ + CHAR_PETMAIL_NONE, + CHAR_PETMAIL_IDLE1, + CHAR_PETMAIL_IDLE2, + CHAR_PETMAIL_RETURNWAIT, + CHAR_PETMAIL_IDLE3, + CHAR_PETMAIL_IDLE4, + CHAR_PETMAIL_IDLE5, +}CHAR_PETMAIL_MODE; + +typedef enum +{ + CHAR_PETFOLLOW_NONE, + CHAR_PETFOLLOW_NOW, +}CHAR_PETFOLLOW_MODE; + +#ifdef _DROPSTAKENEW +typedef enum +{ + DICE_BIG = 1, // _ + DICE_SMALL, // _С + DICE_ALLEAT, // _ͨ + PET_RACE1 = 5, // ٳ_1 + PET_RACE2, // ٳ_2 + PET_RACE3, // ٳ_3 + ROULETTE1 = 11, ROULETTE2, ROULETTE3, ROULETTE4, ROULETTE5, ROULETTE6, ROULETTE7, + ROULETTE8, ROULETTE9, ROULETTE10, ROULETTE11, ROULETTE12, ROULETTE13, ROULETTE14, + ROULETTE15, ROULETTE16, ROULETTE17, ROULETTE18, ROULETTE19, ROULETTE20, + ROULETTE21 = 41, ROULETTE22, ROULETTE23, ROULETTE24, ROULETTE25, ROULETTE26, + ROULETTE27, ROULETTE28, ROULETTE29, ROULETTE30, ROULETTE31, ROULETTE32, + ROULETTE33, ROULETTE34, ROULETTE35, ROULETTE36, ROULETTE37, ROULETTE38, + ROULETTE39, ROULETTE40, + ROULETTE41 = 71, ROULETTE42, ROULETTE43, ROULETTE44, ROULETTE45, + ROULETTE51 = 101, ROULETTE52, ROULETTE53, // + ROULETTE61 = 111, ROULETTE62, //110 1011 + PETFIGHT_WIN1 = 120, + PETFIGHT_WIN2, + PETFIGHT_DUEL, +}GAMBLE_TYPE; +#endif + +#ifdef _CHAR_POOLITEM +#ifdef _NPC_DEPOTPET // ųֿͬʱӵֿ߲ +#define CHAR_MAXDEPOTITEMHAVE 80 +#else +#define CHAR_MAXDEPOTITEMHAVE 60 +#endif +#endif + +#ifdef _CHAR_POOLPET +#define CHAR_MAXDEPOTPETHAVE 30 +#endif + + +#ifdef _ADD_POOL_ITEM // (ɿ) WON ADD ӿɼķŵĵ +#define CHAR_MAXPOOLITEMHAVE 30 +#else +#define CHAR_MAXPOOLITEMHAVE 20 +#endif + +#define CHAR_MAXITEMNUM 15 +#define CHAR_STARTITEMARRAY CHAR_EQUIPPLACENUM +#define CHAR_MAXITEMHAVE (CHAR_STARTITEMARRAY+CHAR_MAXITEMNUM) + +#ifdef _PET_ITEM +#define CHAR_MAXPETITEMHAVE CHAR_PETITEMNUM +#endif + +typedef enum +{ + CHAR_DATAPLACENUMBER, + CHAR_BASEIMAGENUMBER, + CHAR_BASEBASEIMAGENUMBER, + CHAR_FACEIMAGENUMBER, + CHAR_FLOOR, + CHAR_X, + CHAR_Y, + CHAR_DIR, + CHAR_LV, + CHAR_GOLD, + CHAR_HP, + CHAR_MP, + CHAR_MAXMP, + CHAR_VITAL, + CHAR_STR, + CHAR_TOUGH, + CHAR_DEX, + CHAR_CHARM, + CHAR_LUCK, + CHAR_EARTHAT, + CHAR_WATERAT, + CHAR_FIREAT, + CHAR_WINDAT, + CHAR_DEFAULTPET, + CHAR_CRITIAL, + CHAR_COUNTER, + CHAR_RARE, + CHAR_RADARSTRENGTH, + CHAR_CHATVOLUME, + CHAR_MERCHANTLEVEL, + CHAR_HEALERLEVEL, + CHAR_SAVEPOINT = CHAR_HEALERLEVEL, + CHAR_DETERMINEITEM, + CHAR_INDEXOFEQTITLE, + CHAR_POISON, + CHAR_PARALYSIS, + CHAR_SLEEP, + CHAR_STONE, + CHAR_DRUNK, + CHAR_CONFUSION, + CHAR_LOGINCOUNT, + CHAR_NPCCREATEINDEX=CHAR_LOGINCOUNT, + CHAR_DEADCOUNT, + CHAR_WALKCOUNT, + CHAR_TALKCOUNT, + CHAR_DAMAGECOUNT, + CHAR_GETPETCOUNT, + CHAR_KILLPETCOUNT, + CHAR_DEADPETCOUNT, + CHAR_SENDMAILCOUNT, + CHAR_MERGEITEMCOUNT, + CHAR_DUELBATTLECOUNT, + CHAR_DUELWINCOUNT, + CHAR_DUELLOSECOUNT, + CHAR_DUELSTWINCOUNT, + CHAR_DUELMAXSTWINCOUNT, + CHAR_WHICHTYPE, + CHAR_WALKINTERVAL, + CHAR_LOOPINTERVAL, +#ifdef _NEWOPEN_MAXEXP + CHAR_OLDEXP, + CHAR_EXP, +#else + CHAR_EXP, +#endif + CHAR_LASTTALKELDER, + CHAR_SKILLUPPOINT, + CHAR_LEVELUPPOINT, + CHAR_IMAGETYPE, + CHAR_NAMECOLOR, + CHAR_POPUPNAMECOLOR, + CHAR_LASTTIMESETLUCK, + CHAR_DUELPOINT, + CHAR_ENDEVENT, /* (0~31) */ + CHAR_ENDEVENT2, /* (32~63) */ + CHAR_ENDEVENT3, /* (64~96) */ +#ifdef _NEWEVENT + CHAR_ENDEVENT4, /* (96~127) */ + CHAR_ENDEVENT5, /* (128~159) */ + CHAR_ENDEVENT6, /* (160~191) */ +#endif +#ifdef _ADD_NEWEVENT // WON + CHAR_ENDEVENT7, + CHAR_ENDEVENT8, + CHAR_ENDEVENT9, + CHAR_ENDEVENT10, + CHAR_ENDEVENT11, + CHAR_ENDEVENT12, + CHAR_ENDEVENT13, + CHAR_ENDEVENT14, + CHAR_ENDEVENT15, + CHAR_ENDEVENT16, +#endif + + CHAR_NOWEVENT, /* (0~31) */ + CHAR_NOWEVENT2, /* (32~63) */ + CHAR_NOWEVENT3, /* (64~96) */ +#ifdef _NEWEVENT + CHAR_NOWEVENT4, /* (96~127) */ + CHAR_NOWEVENT5, /* (128~159) */ + CHAR_NOWEVENT6, /* (160~191) */ +#endif +#ifdef _ADD_NEWEVENT // WON + CHAR_NOWEVENT7, + CHAR_NOWEVENT8, // 224~255 ٻר + CHAR_NOWEVENT9, + CHAR_NOWEVENT10, + CHAR_NOWEVENT11, + CHAR_NOWEVENT12, + CHAR_NOWEVENT13, + CHAR_NOWEVENT14, + CHAR_NOWEVENT15, + CHAR_NOWEVENT16, +#endif + CHAR_TRANSMIGRATION, + CHAR_TRANSEQUATION, + CHAR_INITDATA, + CHAR_SILENT, /* char shutup time */ + CHAR_FMINDEX, // index + CHAR_FMLEADERFLAG, /* Ա + * FMMEMBER_NONE :ûмκμ + * FMMEMBER_APPLY : + * FMMEMBER_LEADER :峤 + * FMMEMBER_MEMBER :һԱ + * FMMEMBER_ELDER : + * FMMEMBER_INVITE :˾ // ʱ + * FMMEMBER_BAILEE : // ʱ + * FMMEMBER_VICELEADER :峤 // ʱ + */ + CHAR_FMSPRITE, // ػ + + CHAR_BANKGOLD, + CHAR_RIDEPET, + CHAR_LEARNRIDE, +#ifdef _NEW_RIDEPETS + CHAR_LOWRIDEPETS, +#endif + CHAR_LIMITLEVEL, +#ifdef _PET_FUSION + CHAR_FUSIONCODE, //ֱ + CHAR_FUSIONINDEX, // + CHAR_FUSIONRAISE, // + CHAR_FUSIONBEIT, //走 + CHAR_FUSIONTIMELIMIT, // ʱ +#endif + +#ifdef _PERSONAL_FAME // Arminius 8.30: + CHAR_FAME, +#endif + +#ifdef _NEWSAVE + CHAR_SAVEINDEXNUMBER, /* SaveFile .0.char or .1.char */ +#endif + +#ifdef _ATTACK_MAGIC + CHAR_EARTH_EXP, // ҵĵħ + CHAR_WATER_EXP, // ҵˮħ + CHAR_FIRE_EXP, // ҵĻħ + CHAR_WIND_EXP, // ҵķħ + CHAR_EARTH_RESIST, // ҵĵħ + CHAR_WATER_RESIST, // ҵˮħ + CHAR_FIRE_RESIST, // ҵĻħ + CHAR_WIND_RESIST, // ҵķħ + CHAR_EARTH_ATTMAGIC_EXP, // ҵĵħȾֵ + CHAR_WATER_ATTMAGIC_EXP, // ҵˮħȾֵ + CHAR_FIRE_ATTMAGIC_EXP, // ҵĻħȾֵ + CHAR_WIND_ATTMAGIC_EXP, // ҵķħȾֵ + CHAR_EARTH_DEFMAGIC_EXP, // ҵĵħԾֵ + CHAR_WATER_DEFMAGIC_EXP, // ҵˮħԾֵ + CHAR_FIRE_DEFMAGIC_EXP, // ҵĻħԾֵ + CHAR_WIND_DEFMAGIC_EXP, // ҵķħԾֵ +#endif + + +#ifdef _GAMBLE_BANK + CHAR_PERSONAGOLD, //ij +#endif +#ifdef _DROPSTAKENEW + CHAR_GAMBLENUM, //ij +#endif +#ifdef _ADD_ACTION //npc + CHAR_ACTIONSTYLE, +#endif +#ifdef _PET_EVOLUTION + CHAR_EVOLUTIONBASEVTL, + CHAR_EVOLUTIONBASESTR, + CHAR_EVOLUTIONBASETGH, + CHAR_EVOLUTIONBASEDEX, +#endif + +#ifdef _FM_JOINLIMIT + CHAR_FMTIMELIMIT, +#endif + +#ifdef _CHAR_PROFESSION // WON ADD ְҵ + PROFESSION_CLASS, // ְҵ + PROFESSION_LEVEL, // ְҵȼ +// PROFESSION_EXP, // ְҵֵ + PROFESSION_SKILL_POINT, // ܵ + ATTACHPILE, // Ӷѵ + PROFESSION_FIRE_P, // + PROFESSION_ICE_P, // + PROFESSION_THUNDER_P, // + PROFESSION_FIRE_R, // + PROFESSION_ICE_R, // + PROFESSION_THUNDER_R, // ׿ +#endif +#ifdef _ALLDOMAN // (ɿ) Syu ADD аNPC + CHAR_HEROFLOOR, +#endif +#ifdef _PETSKILL_BECOMEPIG + CHAR_BECOMEPIG, + CHAR_BECOMEPIG_BBI,//Ҫɵͼ +#endif + CHAR_LASTLEAVETIME, // Robin add ʱ + +#ifdef _NEW_MANOR_LAW + CHAR_MOMENTUM, +#endif + +#ifdef _ITEM_ADDEXP2 + CHAR_ADDEXPPOWER, + CHAR_ADDEXPTIME, +#endif + +#ifdef _VIP_BATTLE_EXP + CHAR_NVIPEXP, + CHAR_NVIPTIME, +#endif + +#ifdef _ANGEL_SUMMON + CHAR_HEROCNT, // Ĵ +#endif + +#ifdef _TEACHER_SYSTEM + CHAR_TEACHER_FAME, // ʦ쵼 +#endif + +#ifdef _GM_ITEM + CHAR_GMTIME, // GM +#endif + +#ifdef _VIP_SERVER + CHAR_AMPOINT, // Ա +#endif + +#ifdef _VIP_RIDE + CHAR_VIPRIDE, // Աڼ + CHAR_VIPTIME, // Աʱ +#endif +#ifdef _AUTO_PK + CHAR_AUTOPK, // ԶPK +#endif +#ifdef _BATTLE_PK + CHAR_BATTLEPK, +#endif + +#ifdef _PET_BEATITUDE + CHAR_BEATITUDE, +#endif +#ifdef _RIDE_CF + CHAR_LOWRIDEPETS1, + CHAR_HIGHRIDEPETS2, // +#endif +#ifdef _SUPER_MAN_ITEM + CHAR_SUPER, //Ʒ +#endif +#ifdef _EV_NUM + CHAR_EVNUM, + CHAR_EVITEM, +#endif +#ifdef _JOB_AUTOPK + CHAR_JOBPKMODE, + CHAR_JOBPKTIME, +#endif +#ifdef _VIGOR_SYS + CHAR_VIGOR, +#endif +#ifdef _STU_SYS + CHAR_STUNUM, +#endif +#ifdef _ALL_TALK + CHAR_ATDATE, + CHAR_ATCNT, +#endif +#ifdef _SAFE_PASSWORD + CHAR_LOCK, +#endif + CHAR_NPCTIME, +#ifdef _OFFLINE_SYSTEM + CHAR_OFFTIME, +#endif +#ifdef _CAMEO_MONEY + CHAR_CAMEO, +#endif +#ifdef _MISSION_TRAIN + CHAR_MISSIONTRAIN_NUM, + CHAR_MISSIONTRAIN_TIME, +#endif +#ifdef _PET_EVOLVE + CHAR_EVOLVE, +#endif +#ifdef _FLOOR_DIFI_FIELD + CHAR_FLOORDIFI_TIME, +#endif +#ifdef _MISSION_TIME + CHAR_MISSION_TIME, +#endif +#ifdef _PLAYER_TITLE + CHAR_TITLE_LV, + CHAR_TITLE_TIME, +#endif +#ifdef _COWRIE + CHAR_BJ, +#endif +#ifdef _ONLINE_TIME + CHAR_ONLINE_TIME, +#endif + CHAR_LUASAVE_WORKINT_1, + CHAR_LUASAVE_WORKINT_2, + CHAR_LUASAVE_WORKINT_3, + CHAR_LUASAVE_INT_1, + CHAR_LUASAVE_INT_2, + CHAR_LUASAVE_INT_3, +#ifdef _CAX_ESC_REPORT + CHAR_REPORT,//ÿǩ +#endif +#ifdef _CAX_Mercenary + CHAR_MERCENARY,//Ӷֶ +#endif +#ifdef _REGISTRATION_TIME + CHAR_REGISTRATION_TIME, + CHAR_REGISTRATION_COUNT, + CHAR_REGISTRATION_ONLINE_TIME, +#endif + CHAR_DATAINTNUM, + +}CHAR_DATAINT; + +typedef enum { + CHAR_MODAI = CHAR_CHARM, /* ʸ ĤҰ */ + CHAR_VARIABLEAI = CHAR_LUCK, /* ʸ ߨ װƥ Ȼ */ + CHAR_SLOT = CHAR_DEFAULTPET, /* ë µ ʸ */ + CHAR_PETGETLV = CHAR_CHATVOLUME, /* ľì ʸ */ + CHAR_PUTPETTIME = CHAR_LOGINCOUNT, /* ʸ ľ */ + CHAR_MAILMODE = CHAR_RADARSTRENGTH, /* ʸ ˪ */ + CHAR_ALLOCPOINT = CHAR_LEVELUPPOINT, /* ìʧݼԻԻ̼(ʸ) */ + CHAR_PETMAILBUFINDEX = CHAR_GETPETCOUNT, /* ʸ(offmsg)߼index */ + CHAR_PETMAILIDLETIME = CHAR_SENDMAILCOUNT, /* ʸPмئ */ + CHAR_PETMAILFROMFLOOR = CHAR_DUELBATTLECOUNT, /* ë˪ݼ׷ʧ */ + CHAR_PETMAILFROMX = CHAR_DUELWINCOUNT, /* ë˪ݼ */ + CHAR_PETMAILFROMY = CHAR_DUELLOSECOUNT, /* ë˪ݼ */ + CHAR_PETMAILEFFECT = CHAR_DUELSTWINCOUNT, /* ʸPؼް į */ + CHAR_PETSENDMAILCOUNT = CHAR_TALKCOUNT, /* ʸëϷּ */ + CHAR_PETRANK = CHAR_LASTTIMESETLUCK, /* ʸ¼(ʸ ۨ߷޷¡ */ + CHAR_PETID = CHAR_DUELMAXSTWINCOUNT,/* ʸ */ + CHAR_PETFAMILY = CHAR_FMLEADERFLAG, // CoolFish: Family жǷΪػ + CHAR_PETENEMYID = CHAR_GAMBLENUM, +}CHAR_PET; + + +typedef enum +{ + CHAR_NAME, + CHAR_OWNTITLE, + CHAR_USERPETNAME = CHAR_OWNTITLE, + CHAR_NPCARGUMENT, + CHAR_CDKEY = CHAR_NPCARGUMENT, + CHAR_OWNERCDKEY, + CHAR_OWNERCHARANAME, + CHAR_FMNAME, +#ifdef _UNIQUE_P_I + CHAR_UNIQUECODE, +#endif +#ifdef _ACTION_GMQUE + CHAR_GMQUESTR1, +#endif + +#ifdef _TEACHER_SYSTEM + CHAR_TEACHER_ID, // ʦʺ + CHAR_TEACHER_NAME, // ʦ +#endif +#ifdef _ITEM_SETLOVER + CHAR_LOVE, // ж + CHAR_LOVERID, // ʺ + CHAR_LOVERNAME, // +#endif + +#ifdef _GM_ITEM + CHAR_GMFUNCTION, // GM +#endif +#ifdef _NEW_NAME //Զƺ + CHAR_NEWNAME, +#endif +#ifdef _EV_NUM + CHAR_EVCODE, +#endif +#ifdef _ALL_RANDMODE + CHAR_RANDTYPE, +#endif +#ifdef _OFFLINE_SYSTEM + CHAR_OFFBUF, +#endif + // CHAR_CHARPLAYIP, //IP + CHAR_DATACHARNUM, +}CHAR_DATACHAR; + +typedef enum +{ + CHAR_ISATTACK, + CHAR_ISATTACKED, + CHAR_ISOVER, + CHAR_ISOVERED, + CHAR_HAVEHEIGHT, + CHAR_ISVISIBLE, + CHAR_ISTRANSPARENT, + CHAR_ISFLYING, + CHAR_ISDIE, + CHAR_ISBIG, + CHAR_ISSHOWBATTLEMSG, + CHAR_ISPARTY, + CHAR_ISWARP, + CHAR_ISDUEL, + CHAR_ISPARTYCHAT, + CHAR_ISTRADECARD, + CHAR_ISTRADE, +#ifdef _CHANNEL_MODIFY + CHAR_ISTELL, //Ƶ + CHAR_ISFM, //Ƶ + CHAR_ISOCC, //ְҵƵ + CHAR_ISSAVE, //Ի濪 + CHAR_ISCHAT, // + CHAR_ISWORLD, //Ƶ +#endif + CHAR_FLGNUM, +}CHAR_DATAFLG; + +#define CHAR_FS_PARTY (1 << 0) +#define CHAR_FS_BATTLE (1 << 1) +#define CHAR_FS_DUEL (1 << 2) +#define CHAR_FS_PARTYCHAT (1 << 3) //Ƶ +#define CHAR_FS_TRADECARD (1 << 4) +#define CHAR_FS_TRADE (1 << 5) +#ifdef _CHANNEL_MODIFY +#define CHAR_FS_TELL (1 << 6) //Ƶ +#define CHAR_FS_FM (1 << 7) //Ƶ +#define CHAR_FS_OCC (1 << 8) //ְҵƵ +#define CHAR_FS_SAVE (1 << 9) //Ի濪 +#define CHAR_FS_CHAT (1 << 10) //ҿ + +#define CHAR_FS_WORLD (1 << 11) //Ƶ +#endif +typedef enum +{ + CHAR_WORKBATTLEMODE, + CHAR_WORKBATTLEINDEX, + CHAR_WORKBATTLESIDE, + CHAR_WORKBATTLECOM1, + CHAR_WORKBATTLECOM2, + CHAR_WORKBATTLECOM3, +#ifdef _PSKILL_MDFYATTACK + CHAR_WORKBATTLECOM4, +#endif + CHAR_WORKBATTLEFLG, + CHAR_WORKBATTLEWATCH, + + CHAR_WORKFIXEARTHAT, + CHAR_WORKFIXWATERAT, + CHAR_WORKFIXFIREAT, + CHAR_WORKFIXWINDAT, +#ifdef _PROFESSION_ADDSKILL + CHAR_WORKFIXEARTHAT_BOUNDARY, //ؽ 16λԪżǿٷֱ 16λԪŻغ + CHAR_WORKFIXWATERAT_BOUNDARY, //ˮ + CHAR_WORKFIXFIREAT_BOUNDARY, // + CHAR_WORKFIXWINDAT_BOUNDARY, // +#endif + CHAR_WORKMAXHP, + CHAR_WORKMAXMP, + + CHAR_WORKATTACKPOWER, + CHAR_WORKDEFENCEPOWER, + CHAR_WORKQUICK, + + CHAR_WORKFIXVITAL, + CHAR_WORKFIXSTR, + CHAR_WORKFIXTOUGH, + CHAR_WORKFIXDEX, + +#ifdef _ITEMSET5_TXT + CHAR_WORKFIXARRANGE, + CHAR_WORKARRANGEPOWER, + CHAR_WORKFIXSEQUENCE, + CHAR_WORKSEQUENCEPOWER, + CHAR_WORKATTACHPILE, + CHAR_WORKHITRIGHT, // +#endif +#ifdef _ITEMSET6_TXT + CHAR_WORKNEGLECTGUARD, +#endif + CHAR_WORKMODATTACK, + CHAR_WORKMODDEFENCE, + CHAR_WORKMODQUICK, + + CHAR_WORKMODCAPTURE, + CHAR_WORKMODCHARM, + + CHAR_WORKFIXCHARM, + CHAR_WORKFIXLUCK, + CHAR_WORKFIXAI, + CHAR_WORKFIXAVOID, + + CHAR_WORKDAMAGEABSROB, + CHAR_WORKDAMAGEREFLEC, + CHAR_WORKDAMAGEVANISH, + CHAR_WORKPOISON, + CHAR_WORKPARALYSIS, + CHAR_WORKSLEEP, + CHAR_WORKSTONE, + CHAR_WORKDRUNK, + CHAR_WORKCONFUSION, + CHAR_WORKWEAKEN, // vincent add _MAGIC_WEAKEN + CHAR_WORKDEEPPOISON, //綾 vincent add _MAGIC_DEEPPOISON + CHAR_WORKBARRIER, //ħ vincent add _MAGIC_BARRIER + CHAR_WORKNOCAST, //Ĭ vincent add _MAGIC_NOCAST + CHAR_WORKMODPOISON, + CHAR_WORKMODPARALYSIS, + CHAR_WORKMODSLEEP, + CHAR_WORKMODSTONE, + CHAR_WORKMODDRUNK, + CHAR_WORKMODCONFUSION, + CHAR_WORKMODWEAKEN, + CHAR_WORKMODDEEPPOISON, + CHAR_WORKMODBARRIER, //ħ + CHAR_WORKMODNOCAST, //Ĭ + CHAR_WORKMODCRITICAL, //һɱ + CHAR_WORKULTIMATE, + CHAR_WORKPARTYMODE, + CHAR_WORKTRADEMODE, /* ģʽ + * 0: CHAR_TRADE_FREE :ɽ + * 1: CHAR_TRADE_SENDING: + * 2: CHAR_TRADE_TRADING: + * 3: CHAR_TRADE_LOCK : + */ + CHAR_WORKPARTYINDEX1, + CHAR_WORKPARTYINDEX2, + CHAR_WORKPARTYINDEX3, + CHAR_WORKPARTYINDEX4, + CHAR_WORKPARTYINDEX5, + CHAR_WORKOBJINDEX, + CHAR_WORKWALKSTARTSEC, + CHAR_WORKWALKSTARTMSEC, + CHAR_WORKLOOPSTARTSEC, + CHAR_WORKLOOPSTARTMSEC, + CHAR_WORKLASTATTACKCHARAINDEX, + CHAR_WORKEVENTTYPE, + CHAR_WORKGETEXP, + CHAR_WORKMODCAPTUREDEFAULT, + CHAR_WORKACTION, + CHAR_WORKFD, + CHAR_WORKFLG, + CHAR_WORKGMLEVEL, + CHAR_NPCWORKINT1, + CHAR_NPCWORKINT2, + CHAR_NPCWORKINT3, + CHAR_NPCWORKINT4, + CHAR_NPCWORKINT5, + CHAR_NPCWORKINT6, + CHAR_NPCWORKINT7, + CHAR_NPCWORKINT8, + CHAR_NPCWORKINT9, + CHAR_NPCWORKINT10, + CHAR_NPCWORKINT11, +#ifdef _PETRACE + CHAR_NPCWORKINT12, +#endif + CHAR_NPCWORKINT13, + CHAR_WORKWARPCHECK, + CHAR_TENSEICHECKED, + CHAR_WORKFMINDEXI, // index + CHAR_WORKFMCHANNEL, // Ƶ + CHAR_WORKFMCHANNELQUICK, + CHAR_WORKFMFLOOR, // ݵͼ + CHAR_WORKFMDP, // ģֵ + CHAR_WORKFMPKFLAG, // ǷУ 1:Yes + CHAR_WORKFMSETUPFLAG, // Ƿʽ + CHAR_WORKFMMANINDEX, // FMWARPMAN Index + CHAR_WORKFMCHARINDEX, // Ա index + CHAR_WORKBATTLEFLAG, // -1(ս)1(ս) + + CHAR_WORK_PET0_STAT, + CHAR_WORK_PET1_STAT, + CHAR_WORK_PET2_STAT, + CHAR_WORK_PET3_STAT, + CHAR_WORK_PET4_STAT, + + CHAR_WORKLOGINTIME, // ҵʱ + CHAR_WORKTALKCOUNT, + CHAR_WORKTALKTIME, + CHAR_WORKPETFOLLOW, // + CHAR_WORKPETFALL, // ս + CHAR_WORKLEADERCHANGE, // 峤λindex +#ifdef _EQUIT_DEFMAGIC + CHAR_EQUITDEFMAGIC_E, + CHAR_EQUITDEFMAGIC_WA, + CHAR_EQUITDEFMAGIC_F, + CHAR_EQUITDEFMAGIC_WI, + CHAR_EQUITQUIMAGIC, +#endif +#ifdef _EQUIT_RESIST + CHAR_WORKEQUITFIRE, //װ + CHAR_WORKEQUITTHUNDER,//װ + CHAR_WORKEQUITICE,//װ + CHAR_WORKEQUITWEAKEN,//װ + CHAR_WORKEQUITBARRIER,//װħ + CHAR_WORKEQUITNOCAST,//װĬ + CHAR_WORKEQUITFALLRIDE,//װ +#endif +#ifdef _PETMAIL_DEFNUMS + CHAR_PETMAILNUMS, + CHAR_PETMAILSENDTIME, +#endif +#ifdef _ITEM_METAMO + CHAR_WORKITEMMETAMO, +#endif +#ifdef _ADD_DEAMGEDEFC + CHAR_WORKOTHERDMAGE, + CHAR_WORKOTHERDEFC, +#endif + +#ifdef _LOSE_FINCH_ + CHAR_WORKSPETRELIFE, //︴ +#endif + +#ifdef _CHIKULA_STONE + CHAR_WORKCHIKULAHP, + CHAR_WORKCHIKULAMP, +#endif +#ifdef _PETSKILL_SETDUCK + CHAR_MYSKILLDUCKPOWER, + CHAR_MYSKILLDUCK, + CHAR_MYSKILLSTRPOWER, + CHAR_MYSKILLSTR, + CHAR_MYSKILLTGHPOWER, + CHAR_MYSKILLTGH, + CHAR_MYSKILLDEXPOWER, + CHAR_MYSKILLDEX, + CHAR_MAGICPETMP, +#endif + CHAR_SKILLSTRPOWER, + CHAR_SKILLDEXPOWER, +#ifdef _NPC_MAKEPAIR + CHAR_MYPAIRINDEX, + CHAR_MYPAIRFLG, + CHAR_MYPAIRCODE, +#endif +#ifdef _OTHER_MAGICSTAUTS + CHAR_DEFMAGICSTATUS, +#ifdef _MAGIC_SUPERWALL + CHAR_MAGICSUPERWALL, +#endif + CHAR_OTHERSTATUSNUMS, +#endif +#ifdef _NPCCHANGE_PLAYERIMG + CHAR_WORKNPCMETAMO, +#endif + CHAR_PickAllPet, +#ifdef _DROPSTAKENEW + CHAR_WORKSTAKEFLAG, + CHAR_WORKSTAKETYPE1, + CHAR_WORKSTAKETYPE2, + CHAR_WORKSTAKETYPE3, + CHAR_WORKSTAKETYPE4, + CHAR_WORKSTAKETYPE5, +#endif + + CHAR_WORKTOXICATION, + +#ifdef _SUIT_ITEM + CHAR_WORKSUITITEM, + CHAR_WORKROUNDHP, + CHAR_WORKROUNDMP, + CHAR_WORKSUITVIT, + CHAR_WORKSUITSTR, + CHAR_WORKSUITTGH, + CHAR_WORKSUITDEX, + CHAR_WORKSUITMODSTR, +#ifdef _SUIT_ADDENDUM + CHAR_WORKRESIST, //쳣 + CHAR_WORKCOUNTER,// + CHAR_WORKMPOWER, //ǿʦħ( Ӱķ:ɽȪ ĩ ǹ Ѫ Ѫ һѪ ) +#endif +#ifdef _SUIT_TWFWENDUM + CHAR_WORK_EA,// + CHAR_WORK_WR,//ˮ + CHAR_WORK_FI,// + CHAR_WORK_WI,// +#endif +#ifdef _SUIT_ADDPART3 + CHAR_WORKDUCKPOWER,//װر + CHAR_WORKRENOCAST, //Ĭ + CHAR_WORKSUITSTR_P,// λΪ% + CHAR_WORKSUITTGH_P,// λΪ% + CHAR_WORKSUITDEX_P,// λΪ% +#endif +#ifdef _SUIT_ADDPART4 + CHAR_SUITPOISON, //װ + CHAR_WORKMPOWER2, //CHAR_WORKMPOWERͬ + CHAR_WORKUNMPOWER, //ֿʦħ( Ӱķ:ɽȪ ĩ ǹ Ѫ Ѫ һѪ ) +#endif +#endif//_SUIT_ITEM + +#ifdef _IMPRECATE_ITEM + CHAR_WORKHURTMP, //˺ MP + CHAR_WORKWISHESHP, //ף hp + CHAR_WORKWISHESMP, //ף MP + CHAR_WORKIMPRECATENUM1, + CHAR_WORKIMPRECATENUM2, + CHAR_WORKIMPRECATENUM3, +#endif +#ifdef _STATUS_WATERWORD + CHAR_WORKMAPFLOORTYPE, + CHAR_WORKSTATUSWATER, +#endif +#ifdef _BATTLENPC_WARP_PLAYER + CHAR_WORKTURN, +#endif +#ifdef _MIND_ICON + CHAR_MIND_NUM, +#endif +#ifdef _ITEM_CRACKER + CHAR_WORKITEM_CRACKER, +#endif +#ifdef _ALLDOMAN // (ɿ) Syu ADD аNPC + CHAR_WORKHEROFLOOR, +#endif + +#ifdef _PROFESSION_SKILL // WON ADD ְҵ + CHAR_ENCOUNT_FIX, // + CHAR_ENCOUNT_NUM, + CHAR_WORK_F_PROFICIENCY,// + CHAR_WORK_I_PROFICIENCY,// + CHAR_WORK_T_PROFICIENCY,// + CHAR_WORK_F_RESIST, // + CHAR_WORK_I_RESIST, // + CHAR_WORK_T_RESIST, // 翹 + CHAR_MYSKILLHIT, // + CHAR_MYSKILLHIT_NUM, + CHAR_WORKDIZZY, // ѣ + CHAR_WORKMODDIZZY, + CHAR_WORKENTWINE, // + CHAR_WORKMODENTWINE, + CHAR_WORKTRAP, // + CHAR_WORKMODTRAP, + CHAR_WORKDRAGNET, // ޵ + CHAR_WORKMODDRAGNET, +#ifdef _PROFESSION_ADDSKILL + //***********ע:λòɸ************* + CHAR_WORKICECRACK, // + CHAR_WORKICECRACK2, // Ŵ2 + CHAR_WORKICECRACK3, // Ŵ3 + CHAR_WORKICECRACK4, // Ŵ4 + CHAR_WORKICECRACK5, // Ŵ5 + CHAR_WORKICECRACK6, // Ŵ6 + CHAR_WORKICECRACK7, // Ŵ7 + CHAR_WORKICECRACK8, // Ŵ8 + CHAR_WORKICECRACK9, // Ŵ9 + CHAR_WORKICECRACK10, // Ŵ10 + CHAR_WORKMODICECRACK, + CHAR_WORKMODICECRACK2, + CHAR_WORKMODICECRACK3, + CHAR_WORKMODICECRACK4, + CHAR_WORKMODICECRACK5, + CHAR_WORKMODICECRACK6, + CHAR_WORKMODICECRACK7, + CHAR_WORKMODICECRACK8, + CHAR_WORKMODICECRACK9, + CHAR_WORKMODICECRACK10, + //***************************************** +#else + CHAR_WORKICECRACK, // + CHAR_WORKMODICECRACK, +#endif //_PROFESSION_ADDSKILL + + CHAR_WORKOBLIVION, // + CHAR_WORKMODOBLIVION, + CHAR_WORKICEARROW, // + CHAR_WORKMODICEARROW, + CHAR_WORKBLOODWORMS, // Ѫ + CHAR_WORKMODBLOODWORMS, + CHAR_WORKBLOODWORMSID, + CHAR_WORKSIGN, // һѪ + CHAR_WORKMODSIGN, + CHAR_WORKSIGNID, + CHAR_WORK_P_DUCK, // ر + CHAR_WORKMOD_P_DUCK, + CHAR_WORK_WEAPON, // ר + CHAR_WORKMOD_WEAPON, + CHAR_WORK_FOCUS, // רעս + CHAR_WORKMOD_FOCUS, + CHAR_WORKINSTIGATE, // + CHAR_WORKMODINSTIGATE, + CHAR_WORK_F_ENCLOSE, // + CHAR_WORK_I_ENCLOSE, // + CHAR_WORK_T_ENCLOSE, // ׸ + CHAR_WORKMOD_F_ENCLOSE, + CHAR_WORKMOD_I_ENCLOSE, + CHAR_WORKMOD_T_ENCLOSE, + CHAR_WORK_F_ENCLOSE_2, // + CHAR_WORK_I_ENCLOSE_2, // + CHAR_WORK_T_ENCLOSE_2, // ׸ + CHAR_WORKMOD_F_ENCLOSE_2, + CHAR_WORKMOD_I_ENCLOSE_2, + CHAR_WORKMOD_T_ENCLOSE_2, + CHAR_WORKRESIST_F, // + CHAR_WORKRESIST_I, // + CHAR_WORKRESIST_T, // ׿ +#ifdef _PROFESSION_ADDSKILL + CHAR_WORKERSIST_F_I_T, // ׿ + CHAR_WORKANNEX, // + CHAR_WORKWATER, //ˮ + CHAR_WORKFEAR, //־ + CHAR_DOOMTIME, //ĩռ(ǹ) + CHAR_WORK_com1, + CHAR_WORK_toNo, + CHAR_WORK_mode, + CHAR_WORK_skill_level, + CHAR_WORK_array, +#endif + CHAR_WORKMODRESIST_F, // ԰ٷֱֵ + CHAR_WORKMODRESIST_I, // ԰ٷֱֵ + CHAR_WORKMODRESIST_T, // ׿԰ٷֱֵ +#endif + +#ifdef _MAGICSTAUTS_RESIST + CHAR_MAGICFIRE, //𿹾 + CHAR_MAGICTHUNDER,//翹 + CHAR_MAGICICE,// +#endif + +#ifdef _PET_SKILL_SARS // WON ADD ɷ + CHAR_WORKSARS, + CHAR_WORKMODSARS, +#endif + +#ifdef _PETSKILL_ACUPUNCTURE + CHAR_WORKACUPUNCTURE, +#endif +#ifdef _PETSKILL_RETRACE + CHAR_WORKRETRACE, +#endif + +#ifdef _CHATROOMPROTOCOL // (ɿ) Syu ADD Ƶ + CHAR_WORKCHATROOMTYPE , + CHAR_WORKCHATROOMNUM , +#endif + +#ifdef _MAGIC_RESIST_EQUIT // WON ADD ְҵװ + CHAR_WORK_F_SUIT, + CHAR_WORK_I_SUIT, + CHAR_WORK_T_SUIT, +#endif + +#ifdef _PETSKILL_BECOMEFOX + CHAR_WORKFOXROUND, //غ +#endif + + CHAR_WORKSTANDBYPET, // Robin add +#ifdef _STREET_VENDOR + CHAR_WORKSTREETVENDOR, // ̯״̬ -1:ûڰ̯,Ҳûڰ̯;1:̯;2:ڽ;3:̯ + CHAR_WORKSTREETVENDOR_WHO, // ˭ҽ +#endif + +#ifdef _ANGEL_SUMMON + CHAR_WORKMISSION, + CHAR_WORKANGELMODE, +#endif +#ifdef _MAP_TIME + CHAR_WORK_MAP_TIME, // ͼ +#endif +#ifdef _PETSKILL_LER + CHAR_WORK_RELIFE, // ׶ +#endif +#ifdef _TEACHER_SYSTEM + CHAR_WORK_GET_TEACHER_FAME, // ʦ쵼 +#endif + + CHAR_WORKSKYWALKER, // GM?? + + CHAR_WORKLASTMERGETIME, // ϳʱ + +#ifdef _FONT_SIZE + CHAR_WORKFONTSIZE, // +#endif + +#ifdef _TIME_TICKET + CHAR_WORKTICKETTIME, + CHAR_WORKTICKETTIMESTART, +#endif +// CHAR_WORKAMPOINT, + CHAR_WORKDBATTLEESCAPE, +#ifdef _AUTO_PK + CHAR_WORK_AUTOPK, //ԶPK + CHAR_WORK_AUTOPK_DEAD, // +#endif + CHAR_WORKDEBUGMODE, // ģʽ +#ifdef _TRADE_PK + CHAR_WORKTRADEPK, +#endif + CHAR_WORKSAFEMODE, + CHAR_WORKTRADETYPE, + CHAR_WORKSAVETIME, +#ifdef _ALL_TALK + CHAR_WORKALLTALKTIME, + CHAR_WORKALLTALKTYPE, +#endif +#ifdef _QUESTION_ONLINE + CHAR_WORKQUESTIONFLG, +#endif + CHAR_WORKPETSKILLBT, +#ifdef _VIGOR_SYS + CHAR_WORKVIGORTIME, +#endif + CHAR_WORKBATTLECOM5, + CHAR_WORKBATTLECOM6, + CHAR_WORKBATTLECOM7, + CHAR_WORKLISTPAGE, + CHAR_WORKLISTSELECT, +#ifdef _NPCENEMY_1 + CHAR_WORKBATTLEHELP, +#endif +#ifdef _OFFLINE_SYSTEM + CHAR_WORK_OFFLINE, +#endif +#ifdef _PET_RESET + CHAR_WORKRESETPETINDEX, +#endif +#ifdef _BATTLEMAP_CTRL + CHAR_WORKBATTLETIME, +#endif +#ifdef _ZHIPIAO_SYSTEM + CHAR_WORKZHIPIAOPOINT, + CHAR_WORKZHIPIAOITEM, +#endif +#ifdef _NO_DROPITEM + CHAR_DROPITEMCHARAINDEX, +#endif +#ifdef _FMZUZHANG_MSG + CHAR_WORKLOGININTYPE, +#endif +#ifdef _WAN_FIX + CHAR_WORKBATTLEPROTYPE, +#endif +#ifdef _ITEM_RESET + CHAR_WORKFROMITEMINDEX, + CHAR_WORKTOITEMINDEX, +#endif +#ifdef _WARNPC_CTRL + CHAR_WORKNPCENEMYTIME, + CHAR_WORKNPCENEMYBATTLETIME, + CHAR_WORKNPCBATTLESAMEIP, +#endif +#ifdef _NO_DAOLUAN + CHAR_WORKNOTALKTRNTIME, +#endif +#ifdef _NPC_PETSKILLUP + CHAR_WORKPETSKILLUP, +#endif +#ifdef _DP_ZHIPIAO_ITEM + CHAR_WORKDPZHIPIAOITEM, + CHAR_WORKDPZHIPIAOSHUI, + CHAR_WORKDPZHIPIAORAND, + CHAR_WORKDPZHIPIAOPOINT, +#endif + CHAR_WORKRANDEDITBASETIME, + CHAR_WORKRANDTYPE, +#ifdef _LOOK_STREET_TIME + CHAR_LOOKSTREETTIME, +#endif + CHAR_WORKLUANPCINT, + CHAR_WORKLUANPCINT1, +#ifdef _BATTLEEND_FIX + CHAR_WORKBALLTELENDTIME, +#endif + CHAR_WORKBATTLEREVERSE, + CHAR_WORKNPCTYPE, + CHAR_WORKJILU, + CHAR_LASTCHARSAVETIME, + CHAR_WORKOFFLINETIME, + CHAR_WORKITEMEXP, +#ifdef _ONLINE_TIME + CHAR_WORK_LOGIN_TIME, +#endif +#ifdef _SPECIAL_COUNTER + CHAR_WORK_COUNTER, +#endif +#ifdef _SPECIAL_TIMER + CHAR_WORK_TIMER, +#endif +#ifdef _FIX_SAVE_CHAR + CHAR_WORK_SAVE_CHAR, +#endif +#ifdef _RECORD_IP + CHAR_WORK_RECORD_IP, +#endif +#ifdef _NULL_CHECK_ITEM + CHAR_WORKITEMINDEX, // Ʒ +#endif +#ifdef _FIX_STW_SPEED_ENEMY + CHAR_WORK_X, + CHAR_WORK_Y, + CHAR_WORK_W, + CHAR_WORK_DIR, +#endif + CHAR_WORKDATAINTNUM, + + + CHAR_WORKENCOUNTPROBABILITY_MIN = CHAR_NPCWORKINT1, + CHAR_WORKENCOUNTPROBABILITY_MAX = CHAR_NPCWORKINT2, + CHAR_WORK_TOHELOS_CUTRATE = CHAR_NPCWORKINT3, + CHAR_WORK_TOHELOS_COUNT = CHAR_NPCWORKINT4, + CHAR_WORKSHOPRELEVANT = CHAR_NPCWORKINT5, + CHAR_WORKSHOPRELEVANTSEC = CHAR_NPCWORKINT6, + CHAR_WORKSHOPRELEVANTTRD = CHAR_NPCWORKINT7, + CHAR_WORKTRADER = CHAR_NPCWORKINT8, + CHAR_WORKEFFECT = CHAR_NPCWORKINT9, + CHAR_WORKRENAMEITEMNUM = CHAR_NPCWORKINT10, + CHAR_WORKRENAMEITEMINDEX = CHAR_NPCWORKINT5, + CHAR_WORKPLAYERINDEX = CHAR_NPCWORKINT1, + CHAR_WORKTACTICS = CHAR_NPCWORKINT2, + CHAR_WORKPETFOLLOWMODE = CHAR_NPCWORKINT3, + CHAR_WORKPETFOLLOWCOUNT = CHAR_NPCWORKINT4, + CHAR_WORK_PETFLG = CHAR_NPCWORKINT1, + CHAR_WORKGENERATEINDEX = CHAR_NPCWORKINT1, + CHAR_WORKDOORCLOSETIME = CHAR_NPCWORKINT1, + CHAR_WORKDOORSWITCHCOUNT = CHAR_NPCWORKINT2, + CHAR_WORKDOOROPENG = CHAR_NPCWORKINT3, + CHAR_WORKDOORCLOSEG = CHAR_NPCWORKINT4, + CHAR_WORKDOORSOONFLG = CHAR_NPCWORKINT5, + CHAR_WORKDOORPASSFLG = CHAR_NPCWORKINT6, + CHAR_WORKDOORKEYITEMID = CHAR_NPCWORKINT7, + CHAR_WORKDOORSWITCHCURRENT = CHAR_NPCWORKINT8, + CHAR_WORKDOORORIGINALGRAPHIC = CHAR_NPCWORKINT9, + CHAR_WORKDOOREXPIRETIME = CHAR_NPCWORKINT10, + CHAR_WORKOLDMANID = CHAR_NPCWORKINT1, + CHAR_WORKSHOPCLIENTINDEX = CHAR_NPCWORKINT1, + CHAR_WORKDENGONMAXID = CHAR_NPCWORKINT1, +}CHAR_WORKDATAINT; + + +enum{ + WORKFLG_DEBUGMODE = ( 1 << 0 ), + WORKFLG_MICMODE = ( 2 << 0 ), +}; + +typedef enum +{ + CHAR_INITFUNC, + CHAR_FIRSTFUNCTION = CHAR_INITFUNC, + CHAR_WALKPREFUNC, + CHAR_WALKPOSTFUNC, + CHAR_PREOVERFUNC, + CHAR_POSTOVERFUNC, + CHAR_WATCHFUNC, + CHAR_LOOPFUNC, + CHAR_DYINGFUNC, + CHAR_TALKEDFUNC, + CHAR_PREATTACKEDFUNC, + CHAR_POSTATTACKEDFUNC, + CHAR_OFFFUNC, + CHAR_LOOKEDFUNC, + CHAR_ITEMPUTFUNC, + CHAR_SPECIALTALKEDFUNC, + CHAR_WINDOWTALKEDFUNC, +#ifdef _USER_CHARLOOPS + CHAR_LOOPFUNCTEMP1, + CHAR_LOOPFUNCTEMP2, + CHAR_BATTLEPROPERTY, +#endif +#ifdef _ALLBLUES_LUA + CHAR_OVERLAPEDFUNC, + CHAR_BATTLEOVERDFUNC, +#ifdef _ALLBLUES_LUA_1_4 + CHAR_LOGINOUTFUNC, +#endif +#ifdef _ALLBLUES_LUA_1_9 + CHAR_BATTLESETFUNC, +#endif +#endif + CHAR_LASTFUNCTION, + CHAR_FUNCTABLENUM = CHAR_LASTFUNCTION, +}CHAR_FUNCTABLE; + +typedef enum +{ + CHAR_WORKWALKARRAY, + CHAR_NPCWORKCHAR1, + CHAR_NPCWORKCHAR2, + CHAR_NPCWORKCHAR3, + CHAR_NPCWORKCHAR4, + CHAR_NPCWORKCHAR5, + CHAR_NPCWORKCHAR6, +#ifdef _ANGEL_SUMMON + CHAR_WORKHEROINFO, +#endif +#ifdef _STREET_VENDOR + CHAR_STREETVENDOR_NAME, +#endif +#ifdef _NO_QUICK_WAR + CHAR_WARWORKXYD, +#endif + CHAR_WORKDATACHARNUM, + CHAR_WORKBATTLE_TACTICSOPTION = CHAR_NPCWORKCHAR1, +#ifdef _BATTLENPC_WARP_PLAYER + CHAR_WORKBATTLE_ACT_CONDITION = CHAR_NPCWORKCHAR2, +#endif + CHAR_WORKDOORPASSWD = CHAR_NPCWORKCHAR1, + CHAR_WORKDOORNAME = CHAR_NPCWORKCHAR2, + CHAR_WORKDOORGOLDLIMIT = CHAR_NPCWORKCHAR3, + CHAR_WORKDOORWEEK = CHAR_NPCWORKCHAR4, + CHAR_WORKDOORHOUR = CHAR_NPCWORKCHAR5, + CHAR_WORKDOORMINUTE = CHAR_NPCWORKCHAR6, + CHAR_WORKDOORTITLE = CHAR_NPCWORKCHAR6, + CHAR_WORKDOORMANDOORNAME = CHAR_NPCWORKCHAR1, + CHAR_TIME1, + CHAR_TIME2 = CHAR_NPCWORKCHAR6, + CHAR_WORKRANDMSG, + CHAR_WORKRANDEDITBASE, +#ifdef _MM_NO_JIAOBEN + CHAR_WORKDROPMM, +#endif +}CHAR_WORKDATACHAR; + + +typedef enum +{ + CHAR_IMAGETYPE_GIRL, + CHAR_IMAGETYPE_BOY, + CHAR_IMAGETYPE_CHILDBOY, + CHAR_IMAGETYPE_CHILDGIRL, + CHAR_IMAGETYPE_MAN, + CHAR_IMAGETYPE_WOMAN, + CHAR_IMAGETYPE_OLDMAN, + CHAR_IMAGETYPE_DOG, + CHAR_IMAGETYPENUM +}CHAR_ImageType; + + +#define CHAR_P_STRING_HP ( 1 << 1 ) // 0x00000002 +#define CHAR_P_STRING_MAXHP ( 1 << 2 ) // 0x00000004 +#define CHAR_P_STRING_MP ( 1 << 3 ) // 0x00000008 +#define CHAR_P_STRING_MAXMP ( 1 << 4 ) // 0x00000010 +#define CHAR_P_STRING_VITAL ( 1 << 5 ) +#define CHAR_P_STRING_STR ( 1 << 6 ) +#define CHAR_P_STRING_TOUGH ( 1 << 7 ) +#define CHAR_P_STRING_DEX ( 1 << 8 ) +#define CHAR_P_STRING_EXP ( 1 << 9 ) +#define CHAR_P_STRING_NEXTEXP ( 1 << 10 ) +#define CHAR_P_STRING_LV ( 1 << 11 ) +#define CHAR_P_STRING_ATK ( 1 << 12 ) +#define CHAR_P_STRING_DEF ( 1 << 13 ) +#define CHAR_P_STRING_QUICK ( 1 << 14 ) +#define CHAR_P_STRING_CHARM ( 1 << 15 ) +#define CHAR_P_STRING_LUCK ( 1 << 16 ) +#define CHAR_P_STRING_EARTH ( 1 << 17 ) +#define CHAR_P_STRING_WATER ( 1 << 18 ) +#define CHAR_P_STRING_FIRE ( 1 << 19 ) +#define CHAR_P_STRING_WIND ( 1 << 20 ) +#define CHAR_P_STRING_GOLD ( 1 << 21 ) +#define CHAR_P_STRING_TITLE ( 1 << 22 ) +#define CHAR_P_STRING_DUELPOINT ( 1 << 23 ) +#define CHAR_P_STRING_TRANSMIGRATION ( 1 << 24 ) +#define CHAR_P_STRING_NAME ( 1 << 25 ) +#define CHAR_P_STRING_OWNTITLE ( 1 << 26 ) +#define CHAR_P_STRING_RIDEPET ( 1 << 27 ) // 0x08000000 +#define CHAR_P_STRING_LEARNRIDE ( 1 << 28 ) // 0x10000000 +#define CHAR_P_STRING_BASEBASEIMAGENUMBER ( 1 << 29 ) // 0x20000000 +//#define CHAR_P_STRING_PKDP ( 1 << 30 ) +//#ifdef _CHAR_PROFESSION +//#define CHAR_P_STRING_PROFESSION ( 1 << 30 ) +//#endif +#define CHAR_P_STRING_SKYWALKER ( 1 << 30 ) // 0x40000000 +#define CHAR_P_STRING_DEBUGMODE ( 1 << 31 ) // 0x80000000 + + +#define CHAR_N_STRING_OBJINDEX ( 1 << 1 ) +#define CHAR_N_STRING_LV ( 1 << 2 ) +#define CHAR_N_STRING_MAXHP ( 1 << 3 ) +#define CHAR_N_STRING_HP ( 1 << 4 ) +#define CHAR_N_STRING_MP ( 1 << 5 ) +#define CHAR_N_STRING_NAME ( 1 << 6 ) + +#define CHAR_K_STRING_BASEIMAGENUMBER ( 1 << 1 ) +#define CHAR_K_STRING_HP ( 1 << 2 ) +#define CHAR_K_STRING_MAXHP ( 1 << 3 ) +#define CHAR_K_STRING_MP ( 1 << 4 ) +#define CHAR_K_STRING_MAXMP ( 1 << 5 ) +#define CHAR_K_STRING_EXP ( 1 << 6 ) +#define CHAR_K_STRING_NEXTEXP ( 1 << 7 ) +#define CHAR_K_STRING_LV ( 1 << 8 ) +#define CHAR_K_STRING_ATK ( 1 << 9 ) +#define CHAR_K_STRING_DEF ( 1 << 10 ) +#define CHAR_K_STRING_QUICK ( 1 << 11 ) +#define CHAR_K_STRING_AI ( 1 << 12 ) +#define CHAR_K_STRING_EARTH ( 1 << 13 ) +#define CHAR_K_STRING_WATER ( 1 << 14 ) +#define CHAR_K_STRING_FIRE ( 1 << 15 ) +#define CHAR_K_STRING_WIND ( 1 << 16 ) +#define CHAR_K_STRING_SLOT ( 1 << 17 ) +#define CHAR_K_STRING_CHANGENAMEFLG ( 1 << 18 ) +#define CHAR_K_STRING_NAME ( 1 << 19 ) +#define CHAR_K_STRING_USERPETNAME ( 1 << 20 ) + +typedef union { + int indexOfPet[CHAR_MAXPETHAVE]; + int indexOfPetskill[CHAR_MAXPETSKILLHAVE]; +}CHAR_UNIONTABLE; + +typedef struct tagChar +{ + BOOL use; + + int data[CHAR_DATAINTNUM]; + STRING128 string[CHAR_DATACHARNUM]; + char flg[(CHAR_FLGNUM%(sizeof(char)*8)) + ? (CHAR_FLGNUM/(sizeof(char)*8))+1 + : (CHAR_FLGNUM/(sizeof(char)*8))]; + int indexOfExistItems[CHAR_MAXITEMHAVE]; + int indexOfExistPoolItems[CHAR_MAXPOOLITEMHAVE]; + +#ifdef _CHAR_POOLITEM + int *indexOfExistDepotItems; +#endif +#ifdef _CHAR_POOLPET + int *indexOfExistDepotPets; +#endif + + CHAR_HaveSkill haveSkill[CHAR_SKILLMAXHAVE]; + int indexOfHaveTitle[CHAR_TITLEMAXHAVE]; + ADDRESSBOOK_entry addressBook[ADDRESSBOOK_MAX]; + CHAR_UNIONTABLE unionTable; + int indexOfPoolPet[CHAR_MAXPOOLPETHAVE]; + STRING32 charfunctable[CHAR_FUNCTABLENUM]; + int workint[CHAR_WORKDATAINTNUM]; + STRING64 workchar[CHAR_WORKDATACHARNUM]; + int CharMakeSequenceNumber; + void* functable[CHAR_FUNCTABLENUM]; +#ifdef _JZ_NEWSCRIPT_LUA + STRING32 lua_charfunctable[CHAR_FUNCTABLENUM]; + + void* sur_functable[CHAR_FUNCTABLENUM]; + STRING32 sur_charfunctable[CHAR_FUNCTABLENUM]; +#endif + +#ifdef _STREET_VENDOR + StreetVendor_t StreetVendor[MAX_SELL_ITEM]; +#endif +#ifdef _ALLBLUES_LUA + lua_State *lua[CHAR_FUNCTABLENUM]; + char *luafunctable[CHAR_FUNCTABLENUM]; +#endif +}Char; + + +#define CHAR_CHECKINDEX( index) _CHAR_CHECKINDEX( __FILE__, __LINE__, index) +INLINE BOOL _CHAR_CHECKINDEX( char *file, int line, int index); +#define CHAR_CHECKITEMINDEX( charaindex, iindex) _CHAR_CHECKITEMINDEX( __FILE__, __LINE__, charaindex, iindex) +INLINE BOOL _CHAR_CHECKITEMINDEX( char *file, int line, int charaindex, int iindex ); +#define CHAR_CHECKPETINDEX( petindex) _CHAR_CHECKPETINDEX( __FILE__, __LINE__, petindex ) +INLINE BOOL _CHAR_CHECKPETINDEX( char *file, int line, int petindex ); +#define CHAR_CHECKPOOLPETINDEX( petindex) _CHAR_CHECKPOOLPETINDEX( __FILE__, __LINE__, petindex ) +INLINE BOOL _CHAR_CHECKPOOLPETINDEX( char *file, int line, int petindex ); +#define CHAR_CHECKPETSKILLINDEX( havepetskillindex) _CHAR_CHECKPETSKILLINDEX( __FILE__, __LINE__, havepetskillindex) +INLINE BOOL _CHAR_CHECKPETSKILLINDEX( char *file, int line, int havepetskillindex ); + +INLINE int CHAR_getInt( int index , CHAR_DATAINT element); +#define CHAR_setInt( index , element, data) _CHAR_setInt( __FILE__, __LINE__, index , element, data) +INLINE int _CHAR_setInt( char *file, int line, int index ,CHAR_DATAINT element, int data); +#ifdef _FIX_SETWORKINT +#define CHAR_getWorkInt( index , element) _CHAR_getWorkInt( __FILE__, __LINE__, index , element) +INLINE int _CHAR_getWorkInt( char *file, int line, int index ,CHAR_WORKDATAINT element); +#define CHAR_setWorkInt( index, element, data) _CHAR_setWorkInt( __FILE__, __LINE__, index , element, data) +INLINE int _CHAR_setWorkInt( char *file, int line, int index ,CHAR_WORKDATAINT element, int data); +#else +INLINE int CHAR_setWorkInt( int index ,CHAR_WORKDATAINT element, int data); +#endif +#define CHAR_getChar( index, elem) _CHAR_getChar( __FILE__, __LINE__, index, elem) +INLINE char* _CHAR_getChar( char *file, int line, int index ,CHAR_DATACHAR element ); +#define CHAR_setChar( index, elem, n) _CHAR_setChar( __FILE__, __LINE__, index, elem, n) +INLINE BOOL _CHAR_setChar( char *file, int line, int index ,CHAR_DATACHAR element, char* new ); +#define CHAR_getFlg( index, elem) _CHAR_getFlg( __FILE__, __LINE__, index, elem) +INLINE BOOL _CHAR_getFlg( char *file, int line, int index ,CHAR_DATAFLG element ); +#define CHAR_setFlg( index, elem, n) _CHAR_setFlg( __FILE__, __LINE__, index, elem, n) +INLINE BOOL _CHAR_setFlg( char *file, int line, int index , CHAR_DATACHAR element, int newdata ); +#define CHAR_getWorkChar( index, elem) _CHAR_getWorkChar( __FILE__, __LINE__, index, elem) +INLINE char * _CHAR_getWorkChar( char *file, int line, int index, CHAR_WORKDATACHAR element ); +#define CHAR_setWorkChar( index, elem, n) _CHAR_setWorkChar( __FILE__, __LINE__, index, elem, n) +INLINE BOOL _CHAR_setWorkChar( char *file, int line, int index, CHAR_WORKDATACHAR element, char * new); + +#define CHAR_getItemIndex( index, iindex) _CHAR_getItemIndex( __FILE__, __LINE__, index, iindex) +INLINE int _CHAR_getItemIndex( char *file, int line, int charaindex, int ti); +#define CHAR_setItemIndex( index, iindex,id) _CHAR_setItemIndex( __FILE__, __LINE__, index, iindex, id) +INLINE int _CHAR_setItemIndex( char *file, int line, int index ,int iindex,int id ); +#define CHAR_getPoolItemIndex( index, iindex) _CHAR_getPoolItemIndex( __FILE__, __LINE__, index, iindex) +INLINE int _CHAR_getPoolItemIndex( char *file, int line, int index, int iindex); +#define CHAR_setPoolItemIndex( index, iindex,id) _CHAR_setPoolItemIndex( __FILE__, __LINE__, index, iindex, id) +INLINE int _CHAR_setPoolItemIndex( char *file, int line, int index ,int iindex,int id ); +INLINE BOOL CHAR_setAddressbookEntry( int index , int aindex , ADDRESSBOOK_entry *a ); +INLINE ADDRESSBOOK_entry* CHAR_getAddressbookEntry( int index , int aindex); +INLINE Char* CHAR_getCharPointer( int index ); +INLINE int CHAR_getCharNum( void ); +INLINE int CHAR_getPlayerMaxNum( void ); +INLINE int CHAR_getPetMaxNum( void ); +INLINE int CHAR_getOthersMaxNum( void ); +INLINE BOOL CHAR_getCharUse( int index ); +INLINE CHAR_HaveSkill* CHAR_getCharHaveSkill( int index,int sindex ); +INLINE int CHAR_getCharHaveTitle( int index,int tindex ); +INLINE int CHAR_setCharHaveTitle( int charaindex,int tindex, int new ); +INLINE int CHAR_getCharPet( int charaindex,int petindex ); +INLINE int CHAR_setCharPet( int charaindex,int petindex, int new ); +INLINE int CHAR_getCharPoolPet( int charaindex,int petindex ); +INLINE int CHAR_setCharPoolPet( int charaindex,int petindex, int new ); +int CHAR_getCharPetElement( int charaindex ); +int CHAR_getCharPoolPetElement( int charaindex ); +int CHAR_getCharPoolItemIndexElement( int charaindex ); +int CHAR_getEmptyCharPoolItemIndexNum( int charaindex); +#ifdef _CHAR_POOLPET +int CHAR_getCharDepotPetElement( int charaindex ); +#endif +#define CHAR_getIntPSkill( index, skillti, ti) _CHAR_getIntPSkill( __FILE__, __LINE__, index, skillti, ti) +INLINE int _CHAR_getIntPSkill( char *file, int line, int index, int skillti, SKILL_DATAINT ti); + +#define CHAR_setIntPSkill( index, skillti, ti, data) _CHAR_setIntPSkill( __FILE__, __LINE__, index, skillti, ti, data) +INLINE void _CHAR_setIntPSkill( char *file, int line, int index, int skillti, SKILL_DATAINT ti, int data); + + +extern Char *CHAR_chara; + + +INLINE int CHAR_getCharMakeSequenceNumber( int charaindex ); +void CHAR_constructFunctable( int charaindex ); +void* CHAR_getFunctionPointer( int charaindex, int functype ); +#ifdef _ALLBLUES_LUA + +INLINE BOOL CHAR_setLUAFunction( int charaindex, int functype, lua_State *L, const char *luafunctable ); +INLINE BOOL CHAR_delLUAFunction( int charaindex, int functype); +INLINE lua_State *CHAR_getLUAFunction( int charaindex, int functype); +#endif +BOOL CHAR_initCharArray( int pnum, int petnum,int onum ); +BOOL CHAR_endCharArray( void ); +int CHAR_initCharOneArray( Char* ch ); +void CHAR_endCharOneArray( int index ); +void CHAR_removeHaveItem( Char* ch ); +void CHAR_endCharData( Char* ch ); +char* CHAR_makeStringFromCharData( Char* one ); +char* CHAR_makeStringFromCharIndex( int index ); +BOOL CHAR_makeCharFromStringToArg( char* data, Char* one); +int CHAR_makePetFromStringToArg( char *src, Char *ch, int ti); +char *CHAR_makePetStringFromPetIndex( int petindex); +#define CHAR_getPetSkillElement( petindex) _CHAR_getPetSkillElement( __FILE__, __LINE__, petindex) +int _CHAR_getPetSkillElement( char *file, int line, int petindex ); +#define CHAR_setPetSkill( petindex, havepetskillindex, n) _CHAR_setPetSkill( __FILE__, __LINE__, petindex, havepetskillindex, n) +INLINE int _CHAR_setPetSkill( char *file, int line, int petindex,int havepetskillindex, int new ); +#define CHAR_getPetSkill( petindex, havepetskillindex) _CHAR_getPetSkill( __FILE__, __LINE__, petindex, havepetskillindex) +INLINE int _CHAR_getPetSkill( char *file, int line, int petindex,int havepetskillindex ); +#define SETFLG(a,b,c,d,e,f,g,h) (((a)<<0)+((b)<<1)+((c)<<2)+((d)<<3)+((e)<<4)+((f)<<5)+((g)<<6)+((h)<<7)) + +INLINE int CHAR_AddMaxExp( int charaindex, int addexp); +INLINE int CHAR_setMaxExpFromLevel( int charaindex, int level); +INLINE int CHAR_setMaxExp( int charaindex, unsigned long int Setexp); +#ifdef _NEWOPEN_MAXEXP +INLINE int CHAR_ChangeExp( int charaindex ); +INLINE int CHAR_HandleExp( int charaindex ); + +#endif + +// ride Pet table +typedef struct tagtagRidePetTable +{ + int rideNo; + int charNo; + int petNo; + int petId; + +} tagRidePetTable; + + +// CoolFish: Family Member Kind 2001/8/28 +typedef enum +{ + FMMEMBER_NONE = -1, + FMMEMBER_MEMBER = 1, + FMMEMBER_APPLY, + FMMEMBER_LEADER, + FMMEMBER_ELDER, +} CHAR_FM_MEMBERKIND; + +// shan 2002/01/10 +typedef enum +{ + PET_STAT_NONE = 0, + PET_STAT_SELECT, + PET_STAT_MAIL = 4, +} CHAR_PET_STAT; + + +#ifdef _PERSONAL_FAME // Arminius: +void CHAR_earnFame(int index, int fame); +#endif + +// CoolFish: 2001/10/11 +#ifdef _UNIQUE_P_I +void CHAR_setPetUniCode(int petindex); +void ITEM_setItemUniCode(int itemindex); +void Check_P_I_UniCode(int charindex); +#endif + +// Arminius 12.15 жǷʿ +int IsMale(int charindex); + +// Arminius 12.15 жǷŮʿ +int IsFemale(int charindex); + + +#ifdef _NEW_RIDEPETS +#define RIDE_PET0 1 +#define RIDE_PET1 ( 1 << 1 ) +#define RIDE_PET2 ( 1 << 2 ) +#define RIDE_PET3 ( 1 << 3 ) +#define RIDE_PET4 ( 1 << 4 ) +#define RIDE_PET5 ( 1 << 5 ) +#define RIDE_PET6 ( 1 << 6 ) +#define RIDE_PET7 ( 1 << 7 ) +#define RIDE_PET8 ( 1 << 8 ) +#define RIDE_PET9 ( 1 << 9 ) +#define RIDE_PET10 ( 1 << 11 ) +#define RIDE_PET11 ( 1 << 10 ) +#define RIDE_PET12 ( 1 << 12 ) +#define RIDE_PET13 ( 1 << 13 ) +#define RIDE_PET14 ( 1 << 14 ) +#ifdef _RIDE_CF +#define RIDE_PET15 ( 1 << 15 ) +#define RIDE_PET16 ( 1 << 16 ) +#define RIDE_PET17 ( 1 << 17 ) +#define RIDE_PET19 ( 1 << 19 ) +#define RIDE_PET18 ( 1 << 18 ) +#define RIDE_PET20 ( 1 << 20 ) +#define RIDE_PET21 ( 1 << 21 ) +#define RIDE_PET22 ( 1 << 22 ) +#define RIDE_PET23 ( 1 << 23 ) +#define RIDE_PET24 ( 1 << 24 ) +#define RIDE_PET25 ( 1 << 25 ) +#define RIDE_PET26 ( 1 << 26 ) +#define RIDE_PET27 ( 1 << 27 ) +#define RIDE_PET28 ( 1 << 28 ) +#define RIDE_PET29 ( 1 << 29 ) +#define RIDE_PET30 ( 1 << 30 ) +#define RIDE_PET31 ( 1 << 31 ) + +#define RIDE_TPYE1 1 +#define RIDE_TPYE2 ( 1 << 1 ) + +#define RIDE_PET_ALL ( 0xFFFFFFFF ) +#define RIDE_TPYE_ALL ( 0xFFFFFFFF ) +#define MAXNOINDEX 32*3 +#else +#define RIDE_PET_ALL ( RIDE_PET0|RIDE_PET1|RIDE_PET2|RIDE_PET3|RIDE_PET4|RIDE_PET5|RIDE_PET6|RIDE_PET7|RIDE_PET8|RIDE_PET9|RIDE_PET10|RIDE_PET11 ) +#define MAXNOINDEX 15 +#endif + + +#ifdef _PET_BEATITUDE +#define BEATITUDE_VITAL ( 1 << 0 ) +#define BEATITUDE_STR ( 1 << 1 ) +#define BEATITUDE_TOUGH ( 1 << 2 ) +#define BEATITUDE_DEX ( 1 << 3 ) +#endif + +#ifdef _FM_LEADER_RIDE +typedef struct { + int fmfloor; + int ride[6]; +}tagFmLeaderRide; +#endif + +#ifdef _FM_LEADER_RIDE +int CHAR_FmLeaderRide(int meindex,int pet); +#endif + +typedef struct { + int petNo; +#ifdef _RIDE_CF + int petNo1; +#endif + unsigned int learnCode; +}tagRideCodeMode; + +typedef struct { + int RideNo[MAXNOINDEX]; + int flg; +}tagRideNoList; + +typedef struct { + int charNo; + int Noindex; + int sex; +}tagRidePetList; + +int RIDEPET_getNOindex( int baseNo); +#ifdef _RIDE_CF +int RIDEPET_getPETindex( int PetNo, unsigned int learnCode, unsigned int learnCode1, unsigned int learnCode2 ); +int CHAR_CheckLearnCode(int charindex, int ridno); +#else +int RIDEPET_getPETindex( int PetNo, unsigned int learnCode); +#endif +int RIDEPET_getRIDEno( int index, int ti); +#endif + +#ifdef _FUSION_TWO +int CHAR_OldFusion_init(); +#endif + +#ifdef _PET_EVOLUTION +int EVOLUTION_getPetTable( int charaindex, int petindex1, int petindex2); +int EVOLUTION_getPropertyTable( int charaindex, int petindex1, int petindex2); +int EVOLUTION_getFusionTable( int charaindex, int px, int py); +int EVOLUTION_getPetFusionCode( int petid); +#endif + +#ifdef _PET_AMOI__E +int EVOLUTION_getPetENABLETRADE( int petid); +int EVOLUTION_getPETTYPE( int petid); +int EVOLUTION_getPETTYPESUB( int petid); +#endif + +#ifdef _EMENY_CHANCEMAN +int CHAR_getSexInt( int baseNo ); +#endif +#ifdef _TYPE_TOXICATION +BOOL CHAR_CanCureFlg( int charaindex, char *arg); +#endif + +BOOL CHAR_getCharOnArrayPercentage( int mode, int *max, int *min, int *cnt); + + +#define CHAR_DelItemMess( index, ti, flg) _CHAR_DelItem( __FILE__, __LINE__, index, ti, 1, flg) +#define CHAR_DelItem( index, ti) _CHAR_DelItem( __FILE__, __LINE__, index, ti, 1, 1) +#define CHAR_DelPileItemMess( index, ti, num, flg) _CHAR_DelItem( __FILE__, __LINE__, index, ti, num, flg) + +#define CHAR_AddPileItem( index, itemindex) _CHAR_AddPileItem( __FILE__, __LINE__, index, itemindex) +INLINE int _CHAR_AddPileItem( char *file, int line, int charaindex, int itemindex); + +INLINE int _CHAR_DelItem( char *file, int line, int charaindex, int ti, int num, int flg); + +#define CHAR_AddGold( index, ti) _CHAR_AddGold( __FILE__, __LINE__, index, ti) +INLINE int _CHAR_AddGold( char *file, int line, int charaindex, int gold); +#define CHAR_DelGold( index, ti) _CHAR_DelGold( __FILE__, __LINE__, index, ti) +INLINE int _CHAR_DelGold( char *file, int line, int charaindex, int gold); +int CHAR_getMaxHaveGold( int charaindex); + + +#ifdef _CHAR_PROFESSION // WON ADD ְҵ + +int CHAR_getCharSkill( int index,int sindex ); +int CHAR_setCharSkill( int index,int sindex,int new ); +#define CHAR_CHECK_PROFESSION_SKILLINDEX( skillindex) _CHAR_CHECK_PROFESSION_SKILLINDEX( __FILE__, __LINE__, skillindex) +INLINE BOOL _CHAR_CHECK_PROFESSION_SKILLINDEX( char *file, int line, int skillindex ); +#define PROFESSION_SKILL_getSkill( charaindex, skillindex) _PROFESSION_SKILL_getSkill( __FILE__, __LINE__, charaindex, skillindex) +INLINE int _PROFESSION_SKILL_getSkill( char *file, int line, int charaindex, int skillindex ); +#define PROFESSION_SKILL_setSkill( charaindex, skillindex, n) _PROFESSION_SKILL_setSkill( __FILE__, __LINE__, charaindex, skillindex, n) +INLINE int _PROFESSION_SKILL_setSkill( char *file, int line, int charaindex,int skillindex, int new ); +#define PROFESSION_SKILL_getSkillElement(charaindex) _PROFESSION_SKILL_getSkillElement( __FILE__, __LINE__, charaindex) +int _PROFESSION_SKILL_getSkillElement( char *file, int line, int charaindex ); + +#endif + +#ifdef _NPC_SEPARATEDATA +void CHAR_showTempInt( int index); +BOOL CHAR_InitCharTempNum( Char* ch ); +void CHAR_EndCharTempNum( void); +void CHAR_getDefaultCharTempNum( Char* ch ); +#endif + +#ifdef _CHAR_POOLITEM + +#define CHAR_getDepotItemIndex( index, iindex) _CHAR_getDepotItemIndex( __FILE__, __LINE__, index, iindex) +INLINE int _CHAR_getDepotItemIndex( char *file, int line, int index ,int iindex); +#define CHAR_setDepotItemIndex( index, iindex,id) _CHAR_setDepotItemIndex( __FILE__, __LINE__, index, iindex, id) +INLINE int _CHAR_setDepotItemIndex( char *file, int line, int index ,int iindex,int id ); + +void CHAR_removeHaveDepotItem( Char* ch); +void CHAR_removeDepotItem( int charaindex); + +char *CHAR_makeDepotItemFromCharIndex( int charaindex); +BOOL CHAR_makeDepotItemStringToChar( int charaindex, char* data); + +BOOL CHAR_SaveDepotItem( int charaindex); +BOOL CHAR_GetDepotItem( int meindex, int charaindex); +void CHAR_ShowMyDepotItems( int charaindex); + +int CHAR_findEmptyDepotItem( int charaindex); +int CHAR_getfindEmptyDepotItem( int charaindex); +BOOL CHAR_CheckDepotItem( int charaindex); +#endif + +#ifdef _CHAR_POOLPET + +#define CHAR_getDepotPetIndex( index, iindex) _CHAR_getDepotPetIndex( __FILE__, __LINE__, index, iindex) +INLINE int _CHAR_getDepotPetIndex( char *file, int line, int index ,int iindex); +#define CHAR_setDepotPetIndex( index, iindex,id) _CHAR_setDepotPetIndex( __FILE__, __LINE__, index, iindex, id) +INLINE int _CHAR_setDepotPetIndex( char *file, int line, int index ,int iindex,int id ); + +void CHAR_removeHaveDepotPet( Char* ch); +void CHAR_removeDepotPet( int charaindex); + +char *CHAR_makeDepotPetFromCharIndex( int charaindex); +BOOL CHAR_makeDepotPetStringToChar( int charaindex, char* data); + +BOOL CHAR_SaveDepotPet( int charaindex); +BOOL CHAR_GetDepotPet( int meindex, int charaindex); +void CHAR_ShowMyDepotPets( int charaindex); + +int CHAR_findEmptyDepotPet( int charaindex); +int CHAR_getfindEmptyDepotPet( int charaindex); +BOOL CHAR_CheckDepotPet( int charaindex); +#endif + +#ifdef _RIDE_CF +int CHAR_Ride_CF_init(); +#endif + +void LodBadPetString( char *data, char *err, int ti); + +#ifdef _STREET_VENDOR +BOOL CHAR_setStreetVendor(int charindex,int index,int set,int num); +INLINE void CHAR_clearStreetVendor(int charindex,int index); +int CHAR_getStreetVendor(int charindex,int index,int set); +#endif +#ifdef _SAFE_PASSWORD +void CHAR_SafePassword(int charaindex); +void CHAR_AddSafePassword(int charaindex); +void CHAR_UnSafePassword(int charaindex); +#endif +char *replace_s(char *str, char *str1, char *str2, char *strretu); +char *str_ganrao(char *oldstr); +char *str_ganraoan(char *oldstr); +char *str_hanzi_ganrao(char *tmpbuff1,char *tmpbuff2,char *tmpbuff3,char *tmpbuff4,int flg,int rand1,int rand2,int rand3,int rand4,int rand5); +#ifdef _ANGEL_SUMMON + +#define ANGELITEM 2884 //20701 //ʹߵ ߱ +#define HEROITEM 2885 //20702 //ߵ ߱ + +typedef enum +{ + ANGEL_NONE =0, + ANGEL_ANGEL, + ANGEL_HERO, +}ANGEL_TYPE; + +typedef enum +{ + MISSION_NONE =0, + MISSION_WAIT_ANSWER, + MISSION_DOING, + MISSION_HERO_COMPLETE, + MISSION_TIMEOVER, +}ANGEL_MISSIONFLAG; +#endif + +#ifdef _CAX_LNS_CHARSUOXU +int CHAR_getEmptyItemBoxNum(int charaindex); +int CHAR_getEmptyPetBoxNum(int charaindex); +int CHAR_getPlayerPetNum(int charaindex,int petid); +int CHAR_getPlayerItemNum(int charaindex,int itemid,BOOL IsContainEquip,BOOL IsContainPile); +#endif + +#endif diff --git a/include/char_data.h b/include/char_data.h new file mode 100644 index 0000000..9101173 --- /dev/null +++ b/include/char_data.h @@ -0,0 +1,126 @@ +#ifndef __CHAR_DATA_H__ +#define __CHAR_DATA_H__ + +#include "item.h" +#include "char.h" + + +#define CHAR_CLASS01_PASSLV 20 + +#define BATEBAN 2 +#define FIRSTPOSITIONMAXINDEX 1 +#define ELDERINDEXSTART FIRSTPOSITIONMAXINDEX+BATEBAN+1 + +typedef struct tagLevelUpPattern +{ +#if 1 + struct Exptbl{ + int origin; + int multi; + }exptbl[3]; + int hpupminpoint; /* hp ؤ 쵰*/ + int hpupmaxpoint; /* hp ؤ 쵰*/ + + int needexp; /* ۢئ */ +#else + int uppoint[5]; +#endif +}LevelUpPattern; + +/*====================Ƥʧ====================*/ +BOOL CHAR_getDefaultChar( Char* nc, int imagenumber ); + +/*==================== į׸====================*/ +int CHAR_getNewImagenumberFromEquip( int basebaseimagenumber, + ITEM_CATEGORY category ); +/*==================== į ٯ -> į====================*/ +//void CHAR_initSeekGraphicNumberFromString(); +int CHAR_seekGraphicNumberFromString( char* string ); + + + +/*====================ƽҷ¼====================*/ +BOOL CHAR_getInitElderPosition( Char* ch,int hometown); +BOOL CHAR_getElderPosition( int elderindex, int* fl, int* x, int* y ); + +void CHAR_setInitValues( Char* ch ); + + +/*==================== ====================*/ +typedef enum +{ + CHAR_INVAREA, + CHAR_CANNOTDROPAREA, + CHAR_CANNOTMAGICAREA, + CHAR_AREAKIND_NONE, +}CHAR_AREAKIND; + +BOOL CHAR_initInvinciblePlace( char* filename ); +BOOL CHAR_isCannotMagicArea( int floor , int x, int y, int magicnum ); +BOOL CHAR_initAppearPosition( char* filename ); +BOOL CHAR_isInvincibleArea( int floor , int x, int y ); +BOOL CHAR_isAppearPosition( int floor, int *x, int *y); +BOOL CHAR_isCannotDropArea( int floor , int x, int y ); + + +/* Ӯ */ +BOOL CHAR_ElderSetPosition( int elderindex ,int fl,int x ,int y); + + + +/************************************************* +ìʧ +*************************************************/ + + +int GetEnemyExp( int level ); + +int CHAR_GetLevel(); +int CHAR_GetLevelExp( int charaindex, int level ); +int CHAR_GetOldLevelExp( int level); + +int CHAR_LevelUpCheck( int charaindex , int toindex); + +int CHAR_PetLevelUp( int petindex ); +#define CHAR_PetLevelUpExInfc(petindex, lv) CHAR_PetLevelUp(petindex ); + +BOOL CHAR_checkFaceImageNumber( int imagenumber, int faceimagenumber); +BOOL CHAR_checkPlayerImageNumber( int imagenumber); + +int CHAR_PetTakeLevelUp( int petindex, int lv); //ǿƳ +int CHAR_PetTakeDrop( int petindex, int floor, int ox, int oy); //ǿƶ + +#ifdef _NPC_FUSION +int PETFUSION_FusionPetSub( int charaindex, int Subindex1, int Subindex2, int *work, int *skill); +BOOL PETFUSION_FusionPetMain( int charaindex, int Mainindex, int *work, int *skill); +BOOL PETFUSION_DelPet( int toindex, int Mainindex, int Subindex1, int Subindex2, int flg); +int PETFUSION_Evolution( int charaindex, int petindex); +#endif +int PETTRANS_PetTransManStatus( int toindex, int petindex1, int petindex2); +#ifdef _PET_2TRANS +int NPC_PetTransManGetAns( int total1, int total2, int LV, int rank, int tran); +#else +int NPC_PetTransManGetAns( int total1, int total2, int LV, int rank); +#endif //_PET_2TRANS + +#ifdef _CHIKULA_STONE +void CHAR_AutoChikulaStone( int charaindex, int Dflg); +#endif + +#ifdef _STATUS_WATERWORD //ˮ״̬ +void CHAR_CheckWaterStatus( int charaindex); +#endif + +int CHAR_findSurplusPetBox( int charaindex ); + +#ifdef _USER_EXP_CF +void setNeedLevelUpTbls(int level,int exp); +void setMaxLevel(int level); +#endif +#ifdef _FM_METAMO +void CHAR_ReMetamo( int charaindex ); +#endif +#ifdef _NEW_PLAYER_RIDE +void CHAR_PlayerRide( int charaindex ); +#endif +#endif diff --git a/include/char_event.h b/include/char_event.h new file mode 100644 index 0000000..e48e1d3 --- /dev/null +++ b/include/char_event.h @@ -0,0 +1,31 @@ +#ifndef __CHAR_EVENT_H__ +#define __CHAR_EVENT_H__ + +#include "char_base.h" + +void CHAR_allpostwalk( int index ); +BOOL CHAR_allprewalk( int index,int* dir,int* mode); + +void CHAR_recoveryStatus( int charaindex ); +void CHAR_loopFunc( int index ); +void CHAR_playerWatchfunc( int meindex, int moveindex, CHAR_ACTION act, + int x, int y, int dir, int* opt, int optlen ); + +void CHAR_sendWallDamage( int charaindex,int x, int y, int damage ); +void CHAR_playerresurrect( int charaindex, int hp ); + +int CHAR_die( int charaindex ); +void CHAR_playerTalkedfunc( int charaindex, int talkindex,char* message, + int color, int channel ); + +void CHAR_recoveryStatus( int charaindex ); +BOOL CHAR_makeCADefaultString( int objindex,char* buf,int buflen, int act ); +BOOL CHAR_makeCAOPT1String( int objindex,char* buf, + int buflen, int act,int opt1 ); +BOOL CHAR_makeCAOPT3String( int objindex,char* buf, + int buflen, int act,int opt1,int opt2,int opt3 ); +#ifdef _STREET_VENDOR +BOOL CHAR_makeCAOPTString(int objindex,char* buf,int buflen,int act,char *string); +#endif + +#endif diff --git a/include/char_talk.h b/include/char_talk.h new file mode 100644 index 0000000..0ce151b --- /dev/null +++ b/include/char_talk.h @@ -0,0 +1,41 @@ +#ifndef __CHAR_TALK_H__ +#define __CHAR_TALK_H__ + +#include "common.h" +#include "util.h" +#include "net.h" +#ifdef _ALLBLUES_LUA +#include "lua.h" +#include "lauxlib.h" +#include "lualib.h" +#endif +void CHAR_getMessageBody(char* message, char* kind, int kindlen, + char** body); + +int CHAR_getChatMagicFuncLevel(char* name,BOOL isDebug); +int CHAR_getChatMagicFuncNameAndString( int ti, char* name, char *usestring, int level, BOOL isDebug); +int CHAR_getChatMagicFuncMaxNum( void); + +void OneByOneTkChannel ( int fd , char *tmp1 , char *tmp2 , int color) ; + +#ifdef _ALLBLUES_LUA_1_2 +typedef struct tagMAGIC_LuaFunc +{ + lua_State *lua; + char *luafuncname; + char *luafunctable; + int gmlevel; + char *usestring; + struct tagMAGIC_LuaFunc *next; +}MAGIC_LuaFunc; + +BOOL MAGIC_addLUAListFunction( lua_State *L, const char *luafuncname, const char *luafunctable, int gmlevel, char *usestring ); +BOOL MAGIC_getLUAListFunction( char *luafuncname, int gmlevel, int charaindex, char *data ); + +#endif + +#ifdef _RE_GM_COMMAND +int re_gm_command(); +#endif + +#endif diff --git a/include/chatmagic.h b/include/chatmagic.h new file mode 100644 index 0000000..4cf448c --- /dev/null +++ b/include/chatmagic.h @@ -0,0 +1,295 @@ +#ifndef __CHATMAGIC_H__ +#define __CHATMAGIC_H__ +#include "version.h" + +void CHAR_CHAT_DEBUG_hp( int charindex , char *message ); +void CHAR_CHAT_DEBUG_mp( int charindex , char *message ); +void CHAR_CHAT_DEBUG_setmp( int charindex , char *message ); +void CHAR_CHAT_DEBUG_str( int charindex , char *message ); +void CHAR_CHAT_DEBUG_dex( int charindex , char *message ); +void CHAR_CHAT_DEBUG_tgh( int charindex , char *message ); +void CHAR_CHAT_DEBUG_vital( int charindex , char *message ); +void CHAR_CHAT_DEBUG_luck( int charindex , char *message ); +void CHAR_CHAT_DEBUG_gold( int charindex , char *message ); +void CHAR_CHAT_DEBUG_additem( int charindex , char *message ); +void CHAR_CHAT_DEBUG_metamo( int charindex , char *message ); +void CHAR_CHAT_DEBUG_warp( int charindex , char *message ); +void CHAR_CHAT_DEBUG_info( int charindex , char *message ); +void CHAR_CHAT_DEBUG_sysinfo( int charindex , char *message ); +void CHAR_CHAT_DEBUG_announce(int charindex , char *message ); +void CHAR_CHAT_DEBUG_level( int charaindex, char* message ); +void CHAR_CHAT_DEBUG_delitem( int charindex , char *message ); +void CHAR_CHAT_DEBUG_superman( int charaindex, char* message ); +void CHAR_CHAT_DEBUG_battlein( int charaindex, char* message ); +void CHAR_CHAT_DEBUG_battleout( int charaindex, char* message ); +void CHAR_CHAT_DEBUG_petmake( int charaindex, char* message ); +void CHAR_CHAT_DEBUG_enemyrestart( int charaindex, char* message ); +void CHAR_CHAT_DEBUG_s_gb( int charaindex, char* message ); +void CHAR_CHAT_DEBUG_s_gu( int charaindex, char* message ); +void CHAR_CHAT_DEBUG_s_tame( int charaindex, char* message ); +void CHAR_CHAT_DEBUG_fieldatt( int charaindex, char* message ); +void CHAR_CHAT_DEBUG_s_ren( int charaindex, char* message ); +void CHAR_CHAT_DEBUG_s_geki( int charaindex, char* message ); +void CHAR_CHAT_DEBUG_s_hai( int charaindex, char* message ); +void CHAR_CHAT_DEBUG_j_state( int charaindex, char* message ); +void CHAR_CHAT_DEBUG_battlewatch( int charaindex, char* message ); +void CHAR_CHAT_DEBUG_eventclean( int charaindex, char* message ); +void CHAR_CHAT_DEBUG_eventsetend( int charaindex, char* message ); +void CHAR_CHAT_DEBUG_eventsetnow( int charaindex, char* message ); +void CHAR_CHAT_DEBUG_debug( int charaindex, char* message ); +void CHAR_CHAT_DEBUG_exp( int charindex , char *message ); +void CHAR_CHAT_DEBUG_dp( int charindex , char *message ); +void CHAR_CHAT_DEBUG_setTrans( int charaindex, char *message); +void CHAR_CHAT_DEBUG_getuser(int charindex ,char *message);//ttom +1 14/11/2000 +void CHAR_CHAT_DEBUG_shutup(int charindex ,char *message);//ttom 22/11/2000 +void CHAR_CHAT_DEBUG_waeikick( int charindex, char* message );//ttom 12/02/2000 +void CHAR_CHAT_DEBUG_effect( int charaindex, char* message ); +void CHAR_CHAT_DEBUG_jail( int charindex, char* message );//ttom 01/11/2001 +void CHAR_CHAT_DEBUG_shutupall(int charindex ,char *message);//ttom 02/01/2001 +void CHAR_CHAT_DEBUG_send(int charindex ,char *message);//ttom 02/01/2001 +void CHAR_CHAT_DEBUG_noenemy(int charaindex, char *message); +void CHAR_CHAT_DEBUG_loginannounce(int charaindex, char* message); // Arminius 7.12 login announce +void CHAR_CHAT_DEBUG_deletepet(int charaindex, char* message); // Robin 0720 +void CHAR_CHAT_DEBUG_deleteitem(int charaindex, char* message); // Robin 0720 +void CHAR_CHAT_DEBUG_checklock(int charaindex, char* message); // Arminius 7.25 +void CHAR_CHAT_DEBUG_unlock(int charaindex, char* message); +void CHAR_CHAT_DEBUG_unlockserver(int charaindex, char* message); +void CHAR_CHAT_DEBUG_fixfmdata(int charaindex, char* message); // CoolFish: GM Family 2001/7/31 +void CHAR_CHAT_DEBUG_shutdown(int charaindex, char* message); // Robin 1008 +void CHAR_CHAT_DEBUG_manorpk(int charaindex, char *message); + +void CHAR_CHAT_DEBUG_watchevent( int charaindex, char* message ); +void CHAR_CHAT_DEBUG_fixfmpk(int charaindex, char *message); +void CHAR_CHAT_DEBUG_reloadmsip( int charaindex, char *message); +void CHAR_CHAT_DEBUG_cleanfreepet(int charaindex, char *message); +void CHAR_CHAT_DEBUG_engineer( int charindex, char *message); +void CHAR_CHAT_DEBUG_waeikickall( int charindex, char* message ); +void CHAR_CHAT_DEBUG_showMem(int charaindex, char *message); +void CHAR_CHAT_DEBUG_playerspread( int charaindex, char *message); +void CHAR_CHAT_DEBUG_reset( int charaindex, char* message ); + +void CHAR_CHAT_DEBUG_laba(int charindex , char *message ); // С +void CHAR_CHAT_DEBUG_dalaba(int charindex , char *message ); // + +#ifdef _MAKE_MAP +void CHAR_CHAT_DelMap( int charaindex, char* message ); +void CHAR_CHAT_GetMap( int charaindex, char* message ); +void CHAR_CHAT_Map( int charaindex, char* message ); +void CHAR_CHAT_Fixtile( int charaindex, char* message ); +void CHAR_CHAT_Fixobj( int charaindex, char* message ); +void CHAR_CHAT_Fukuwa( int charaindex, char* message ); +#endif + +#ifdef _GMRELOAD +void CHAR_CHAT_DEBUG_gmreload(int charaindex, char *message); +#endif +#ifdef _CHAR_PROFESSION // WON ADD ְҵ +void CHAR_CHAT_DEBUG_addsk( int charaindex, char *message ); +void CHAR_CHAT_DEBUG_delsk( int charaindex, char *message ); +#endif +void CHAR_CHAT_DEBUG_cleanfloor( int charaindex, char *message); + +#ifdef _GAMBLE_BANK +void CHAR_CHAT_DEBUG_setgamblenum( int charaindex, char *message ); +#endif +#ifdef _WAEI_KICK +void CHAR_CHAT_DEBUG_gmkick( int charindex, char* message); +#endif +// WON ADD 峤 +void CHAR_CHAT_DEBUG_fixfmleader(int charaindex, char *message); + +// WON ADD ָ +void CHAR_CHAT_DEBUG_crash(int charaindex, char *message); +void CHAR_CHAT_DEBUG_SAVESHH( int fd, int charaindex,char* message,int color, int area ); +#ifdef _PETSKILL_SETDUCK +void CHAR_CHAT_DEBUG_SetDuck( int charaindex, char *message); +#endif +#ifdef _TYPE_TOXICATION +void CHAR_CHAT_DEBUG_Toxication( int charaindex, char *message); +#endif + +#ifdef _SEND_EFFECT // WON ADD ACѩЧ +void CHAR_CHAT_DEBUG_sendeffect(int charaindex, char *message); +#endif +#ifdef _TEST_DROPITEMS +void CHAR_CHAT_DEBUG_dropmypet( int charindex, char *message ); +void CHAR_CHAT_DEBUG_dropmyitem( int charindex , char *message ); +#endif + +#ifdef _CHAR_PROFESSION // WON ADD ְҵ +void CHAR_CHAT_DEBUG_show_profession( int charaindex, char*message ); +void CHAR_CHAT_DEBUG_set_regist( int charaindex, char*message ); +#endif + +void CHAR_CHAT_DEBUG_checktrade( int charaindex, char*message); + +void CHAR_CHAT_DEBUG_checktime( int charaindex, char *message); +void CHAR_CHAT_DEBUG_samecode( int charaindex, char *message); +void CHAR_CHAT_DEBUG_silent(int charindex ,char *message); +void CHAR_CHAT_DEBUG_help( int charindex, char *message); +#ifdef _EQUIT_ARRANGE +void CHAR_CHAT_DEBUG_arrange( int charindex , char *message ); +#endif + +#ifdef _EQUIT_SEQUENCE +void CHAR_CHAT_DEBUG_sequence( int charindex , char *message ); +#endif + +#ifdef _EQUIT_NEGLECTGUARD +void CHAR_CHAT_DEBUG_setneguard( int charaindex, char* message ); +#endif + +void CHAR_CHAT_DEBUG_petlevelup( int charaindex, char* message ); +void CHAR_CHAT_DEBUG_petexpup( int charaindex, char* message ); + +void CHAR_CHAT_DEBUG_reloadpkteamlist( int charaindex, char *message); +void CHAR_CHAT_DEBUG_setBattle( int charaindex, char *message ); + + +#ifdef _CHAR_POOLITEM +void CHAR_CHAT_DEBUG_saveditem(int charaindex, char *message); +void CHAR_CHAT_DEBUG_insertditem(int charaindex, char *message); +void CHAR_CHAT_DEBUG_ShowMyDepotItems( int charaindex, char *message ); +void CHAR_CHAT_DEBUG_InSideMyDepotItems( int charaindex, char *message ); +#endif + +#ifdef _CHAR_POOLPET +void CHAR_CHAT_DEBUG_savedpet(int charaindex, char *message); +void CHAR_CHAT_DEBUG_insertdpet(int charaindex, char *message); +void CHAR_CHAT_DEBUG_ShowMyDepotPets( int charaindex, char *message ); +void CHAR_CHAT_DEBUG_InSideMyDepotPets( int charaindex, char *message ); +#endif + +#ifdef _NEW_MANOR_LAW +void CHAR_CHAT_DEBUG_set_momentum( int charaindex, char* message ); +void CHAR_CHAT_DEBUG_set_manor_owner( int charindex, char* message ); +void CHAR_CHAT_DEBUG_set_schedule_time( int charindex, char* message ); +#endif + +#ifdef _ANGEL_SUMMON +void CHAR_CHAT_DEBUG_angelinfo(int charindex ,char *message); +void CHAR_CHAT_DEBUG_angelclean(int charindex ,char *message); +void CHAR_CHAT_DEBUG_angelcreate(int charindex ,char *message); +void CHAR_CHAT_DEBUG_missionreload(int charindex ,char *message); +#endif + +void CHAR_CHAT_DEBUG_itemreload(int charindex ,char *message); + +void CHAR_CHAT_DEBUG_skywalker(int charaindex ,char *message); + +#ifdef _ITEM_ADDEXP +void CHAR_CHAT_DEBUG_itemaddexp(int charaindex ,char *message); +#endif + +#ifdef _DEF_GETYOU +void CHAR_CHAT_DEBUG_getyou(int charaindex,char *message); +#endif + +#ifdef _DEF_NEWSEND +void CHAR_CHAT_DEBUG_newsend(int charindex ,char *message); +#endif + +#ifdef _DEF_SUPERSEND +void CHAR_CHAT_DEBUG_supersend(int charindex ,char *message); +#endif + +#ifdef _FONT_SIZE +void CHAR_CHAT_DEBUG_fsize(int charindex ,char *message); +#endif + +#ifdef _JOBDAILY +void CHAR_CHAT_DEBUG_rejobdaily(int charindex ,char *message); +#endif + +#ifdef _CREATE_MM_1_2 +void CHAR_CHAT_DEBUG_MM(int charaindex , char *message ); +#endif + +#ifdef _SendTo +void CHAR_CHAT_DEBUG_Sendto( int charaindex , char *message ); +#endif + +void CHAR_CHAT_printcount( int charaindex, char* message ); + +#ifdef _GM_ITEM +void CHAR_CHAT_DEBUG_GMFUNCTION( int charindex , char *message ); +#endif + +#ifdef _GM_RIDE +void CHAR_CHAT_DEBUG_SETRIDE( int charindex , char *message ); +void CHAR_CHAT_DEBUG_MVRIDE( int charindex , char *message ); +#endif + +#ifdef _LOCK_IP +void CHAR_CHAT_DEBUG_ADD_LOCK( int charindex , char *message ); +void CHAR_CHAT_DEBUG_DEL_LOCK( int charindex , char *message ); +void CHAR_CHAT_DEBUG_SHOWIP( int charindex , char *message ); +#endif +void CHAR_CHAT_DEBUG_SET_FAME( int charaindex, char* message ); +#ifdef _AUTO_PK +void CHAR_CHAT_DEBUG_SET_AUTOPK( int charaindex, char* message ); +#endif + +#ifdef _PLAYER_NUM +void CHAR_CHAT_DEBUG_SET_PLAYERNUM( int charaindex, char* message ); +#endif +#ifdef _RELOAD_CF +void CHAR_CHAT_DEBUG_SET_RELOADCF( int charaindex, char* message ); +#endif +#ifdef _TRANS +void CHAR_CHAT_DEBUG_Trans( int charaindex, char *message); +#endif +#ifdef _FUSIONBEIT_FIX +void CHAR_CHAT_DEBUG_fusionbeit( int charaindex, char* message ); +#endif +#ifdef _MAKE_PET_CF +void CHAR_CHAT_DEBUG_petmakecf( int charaindex, char* message ); +#endif +#ifdef _MAKE_PET_ABILITY +void CHAR_CHAT_DEBUG_petmakeabi( int charaindex, char* message ); +#endif +void CHAR_CHAT_DEBUG_zynetwork( int charaindex, char* message ); +#ifdef _ALL_ITEM +void CHAR_CHAT_DEBUG_setallnum( int charaindex, char* message ); +#endif +#ifdef _JZ_NEWSCRIPT_LUA +void CHAR_CHAT_DEBUG_LUA_INIT( int charaindex, char* message ); +void CHAR_CHAT_DEBUG_LUA_CLOSE( int charaindex, char* message ); +#endif +#ifdef _UNTEXT_TALK +void CHAR_CHAT_UnTextReload( int charaindex, char* message ); +#endif +void CHAR_CHAT_FengHao( int charaindex, char* message ); +#ifdef _NO_FULLPLAYER_ATT +void CHAR_CHAT_NoFullPlayer( int charaindex, char* message ); +#endif +void CHAR_CHAT_DelFm( int charaindex, char* message ); +void CHAR_CHAT_ExpBase( int charaindex, char* message ); +void CHAR_CHAT_DEBUG_jilu( int charindex, char* message ); +void CHAR_CHAT_DEBUG_setfmpk( int charindex, char* message ); +void CHAR_CHAT_DEBUG_MMCDKEY( int charaindex, char* message ); +void CHAR_CHAT_DEBUG_RELOADRIDE( int charaindex, char* message ); +#ifdef _ALLBLUES_LUA +void CHAR_CHAT_DEBUG_ReLoadLua( int charaindex, char* message ); +void CHAR_CHAT_DEBUG_NewLoadLua( int charaindex, char* message ); +#endif +#ifdef _CARD_PRODUCTION +void CHAR_CHAT_DEBUG_card(int charindex ,char *message); +#endif + +#ifdef _CAX_GM_RERIDE +void CHAR_CHAT_DEBUG_reride(int charindex ,char *message); +#endif +#ifdef _CAX_GM_RESKILLCODE +void CHAR_CHAT_DEBUG_reskillcode(int charindex ,char *message); +#endif +#ifdef _CAX_GM_RELEADERRIDE +void CHAR_CHAT_DEBUG_releaderride(int charindex ,char *message); +#endif +#ifdef _GM_SAVE_ALL_CHAR +void CHAR_CHAT_DEBUG_GmSaveAllChar( int charaindex, char* message ); +#endif +#ifdef _FIX_TRADE_COPYPET +void CHAR_CHAT_DEBUG_CLEANCOPYPET( int charaindex, char* message ); +#endif +#endif diff --git a/include/chatroom.h b/include/chatroom.h new file mode 100644 index 0000000..012abf2 --- /dev/null +++ b/include/chatroom.h @@ -0,0 +1,22 @@ +#ifndef __CHATROOM_H__ +#define __CHATROOM_H__ +#include "version.h" + +#define MAX_CHATROOM 10 +#define MAX_PPLINROOM 100 + +void InitChatRoom ( void ) ; +void ChatRoom_List ( int fd ); +BOOL ChatCheck_BeMaster( int myindex, int chatnum); +BOOL ChatCheck_Free( int myindex); +BOOL ChatRoom_Create ( int myindex , char *message); +BOOL ChatRoom_Destroy ( int myindex ) ; +void ChatRoom_Kick ( int myindex , int toindex ) ; +void ChatRoom_Make ( int myindex , int toindex ) ; +void ChatRoom_Leave ( int myindex ) ; +void ChatRoom_Join ( int myindex , int num ) ; +void ChatRoom_Agree ( int myindex , int toindex , int YesNo ) ; +void ChatRoom_Message ( int myindex , char *message ) ; +void ChatRoom_Refresh ( int Num ) ; +void ChatRoom_recvall ( int fd , char *data ) ; +#endif diff --git a/include/common.h b/include/common.h new file mode 100644 index 0000000..5bb29c9 --- /dev/null +++ b/include/common.h @@ -0,0 +1,60 @@ +#ifndef __COMMON_H__ +#define __COMMON_H__ + +#include +#include + +/* MACROS */ +#define RETURNFALSEIFFALSE(x) if(!x)return FALSE; +#define EXITWITHEXITCODEIFFALSE(x,code) if(!x)exit(code); +#ifdef __GNUC__ +#define print(format,arg...) fprintf( stderr, format ,##arg) +#define fprint(format,arg...) fprintf( stderr, "%s:%d " format , __FILE__ , __LINE__ , ##arg) +#endif +#define debug(x,y) fprintf( stderr, #x " = %" #y "\n" , x) +#define arraysizeof( x ) (sizeof(x)/sizeof(x[0])) + +#define errorprint {extern int errno;fprint( "%s\n" ,strerror(errno));} + +#define BACKSLASH '\\' +#define NEWLINE '\n' +#define TAB '\t' +#define SPACE ' ' + +/*票及 define 方曰兜蝈卞允月 */ +/*#define min( x,y ) ((x)>(y)?(y):(x)) + #define max( x,y ) ((x)>(y)?(x):(y))*/ +#define min( x,y ) ({typeof(x) __x=(x),__y=(y);(__x < __y) ? __x : __y; }) +#define max( x,y ) ({typeof(x) __x=(x),__y=(y);(__x < __y) ? __y : __x; }) +#define swap( x,y )({typeof(x) __x=(y);(y)=(x);(x)=__x;}) +#define SUCCESSFUL "successful" +#define FAILED "failed" + +#define LOCK 1 +#define UNLOCK 0 + +#define STRINGBUFSIZ 4096 + +#define OPEN {FILE* f;f=fopen("a.txt","a"); +#define CLOSE fclose(f);} + +#define time_diff_us(new,old) ((unsigned)( (new.tv_sec - old.tv_sec)*1000000 + ( new.tv_usec - old.tv_usec ) )) + + + + +extern int snprintf (char* , size_t, const char* , ...) +#ifdef __GNUC__ + __attribute__ ((format (printf,3,4))); +#else + ; +#endif + +#define ON 1 +#define OFF 0 +#define BOOL int +#define FALSE 0 +#define TRUE 1 +#define INLINE inline + +#endif diff --git a/include/configfile.h b/include/configfile.h new file mode 100644 index 0000000..d49da21 --- /dev/null +++ b/include/configfile.h @@ -0,0 +1,715 @@ +#ifndef __CONFIGFILE_H__ +#define __CONFIGFILE_H__ + +#include "common.h" + +#undef EXTERN +#ifdef __CONFIGFILE_C__ +#define EXTERN +#else /* __CONFIGFILE_C__ */ +#define EXTERN extern +#endif /* __CONFIGFILE_C__ */ + +// Arminius 7.12 login announce +extern char announcetext[8192]; +void AnnounceToPlayer(int charaindex); +// Robin 0720 +void AnnounceToPlayerWN(int fd); +void LoadAnnounce(void); + +#ifdef _PET_TALKPRO + #define PETTALK_MAXID 10 //pettalk10 + typedef struct { + int ID; + char DATA[1024*64]; //1M + }PTALK; + extern PTALK pettalktext[PETTALK_MAXID]; + void LoadPetTalk(void); +#else + +extern char pettalktext[4096]; +void LoadPetTalk(void); +#endif + +#ifdef _GAMBLE_BANK +#define GAMBLEBANK_ITEMSMAX 100 +#define DEFEND_ITEMSMAX 40 +typedef struct REGAMBLEBANKITEMS { + char name[128]; + int Gnum; + int ItemId; + int type; +}GAMBLEBANK_ITEMS; + +extern GAMBLEBANK_ITEMS GB_ITEMS[GAMBLEBANK_ITEMSMAX]; + +void Load_GambleBankItems( void); +#endif + +#ifdef _CFREE_petskill +#define PETSKILL_CODE 500 +typedef struct REPETSKILL_CODES { + char name[128]; + int TempNo; + int PetId; + char Code[256]; +}PETSKILL_CODES; + +extern PETSKILL_CODES Code_skill[PETSKILL_CODE]; +void Load_PetSkillCodes( void); +#endif + +#ifdef _GMRELOAD +#define GMMAXNUM 100 +struct GMINFO +{ + char cdkey[24]; + int level; +}; +extern struct GMINFO gminfo[GMMAXNUM]; +#endif + +BOOL readconfigfile( char* filename ); + +void defaultConfig( char* argv0 ); +char* getProgname( void ); +char* getConfigfilename( void ); +void setConfigfilename( char* newv ); + +unsigned int getDebuglevel( void ); +unsigned int setDebuglevel( unsigned int newv ); +unsigned int getMemoryunit( void ); +unsigned int getMemoryunitnum( void ); +char* getAccountservername( void ); +unsigned short getAccountserverport( void ); +char* getAccountserverpasswd( void ); +char* getGameservername( void ); +unsigned short getPortnumber( void ); + +int getServernumber( void ); +int getReuseaddr( void ); +int getNodelay( void ); +int getLogWriteTime(void); +int getLogIOTime( void); +int getLogGameTime(void); +int getLogNetloopFaster(void); +int getSaacwritenum( void ); +void setSaacwritenum( int num ); +int getSaacreadnum( void ); +void setSaacreadnum( int num ); + +unsigned int getFdnum( void ); +unsigned int setFdnum(int temp_fdnum); +unsigned int getPlayercharnum( void ); +unsigned int getPetcharnum( void ); +unsigned int getOtherscharnum( void ); +unsigned int getObjnum( void ); +unsigned int getItemnum( void ); +unsigned int getBattlenum( void ); + +char* getTopdir( void ); +char* getMapdir( void ); +char* getMaptilefile( void ); +char* getBattleMapfile( void ); +char* getItemfile( void ); +char* getInvfile( void ); +char* getAppearfile( void ); +char* getEffectfile( void ); +char* getTitleNamefile( void ); +char* getTitleConfigfile( void ); +char* getLsgenlogfilename( void ); +char* getStoredir( void ); +#ifdef _STORECHAR +char* getStorechar( void ); +#endif +char* getNpcdir( void ); +char* getLogdir( void ); +char* getLogconffile( void ); +char* getChatMagicPasswd( void ); +unsigned int getChatMagicCDKeyCheck( void ); + + +unsigned int getFilesearchnum( void ); +unsigned int getNpctemplatenum( void ); +unsigned int getNpccreatenum( void ); +unsigned int getWalksendinterval( void ); +void setWalksendinterval( unsigned int ); +unsigned int getCAsendinterval_ms( void ); +void setCAsendinterval_ms( unsigned int ); +unsigned int getCDsendinterval_ms( void ); +void setCDsendinterval_ms( unsigned int ); +unsigned int getOnelooptime_ms( void ); +void setOnelooptime_ms( unsigned int ); +unsigned int getCharSavesendinterval( void ); +void setCharSavesendinterval( unsigned int interval); +unsigned int getAddressbookoffmsgnum( void ); +unsigned int getProtocolreadfrequency( void ); +unsigned int getAllowerrornum( void ); +unsigned int getFengerrornum( void ); +unsigned int getLogHour( void ); +unsigned int getBattleDebugMsg( void ); +void setBattleDebugMsg( unsigned int ); + +char* getEncountfile( void ); +char* getEnemyfile( void ); +char* getGroupfile( void ); +char* getEnemyBasefile( void ); +char* getMagicfile( void ); +#ifdef _ATTACK_MAGIC + +char* getAttMagicfileName( void ); + +#endif + +char* getPetskillfile( void ); +char *getItematomfile( void ); +char *getQuizfile( void ); + +#ifdef _PROFESSION_SKILL // WON ADD ְҵ +char* getProfession( void ); +#endif + +unsigned int getPetdeletetime( void ); +void setPetdeletetime( unsigned int interval ); + +unsigned int getItemdeletetime( void ); +void setItemdeletetime( unsigned int interval ); +//ttom add this because the second have this function +//unsigned int getAcwriteSize( void ); + +#ifdef _DEL_DROP_GOLD +unsigned int getGolddeletetime( void ); +void setGolddeletetime( unsigned int interval ); +#endif + +unsigned int setEncodeKey( void ); +unsigned int setAcWBSize( void ); +//ttom end + +// CoolFish: +2 2001/4/18 +unsigned int getAcwriteSize( void ); +unsigned int getErrUserDownFlg( void ); + +// Arminius 7.24 manor pk +char* getGameserverID( void ); +unsigned short getAllowManorPK( void ); + +// Terry 2001/10/03 service ap +char* getApID(void); +unsigned short getApPort(void); +int getLoopTime(void); +int getEnableService(void); + +#ifdef _GMRELOAD +char* getGMSetfile(void); +BOOL LoadGMSet(char *filename); +#endif + +#ifdef _ITEM_QUITPARTY +char* getitemquitparty( void ); +#endif + +#ifdef _NEW_PLAYER_CF +int getNewplayertrans( void ); +int getNewplayerlv( void ); +int getNewplayergivepet( unsigned int index ); +void setNewplayergivepet( unsigned int index ,unsigned int interval); +int getNewplayerpetlv( void ); +int getNewplayergivegold( void ); +int getRidePetLevel( void ); +#ifdef _VIP_SERVER +int getNewplayergivevip( void ); +#endif +#endif + +#ifdef _USER_EXP_CF +BOOL LoadEXP( char* filename ); +char* getEXPfile( void ); +int getNeedLevelUpTbls( int level ); +#endif + +#ifdef _UNREG_NEMA +char* getUnregname( int index ); +#endif + +#ifdef _TRANS_LEVEL_CF +int getChartrans( void ); +int getPettrans( void ); +int getYBLevel( void ); +int getMaxLevel( void ); +#endif + +#ifdef _POINT +char* getPoint( void ); +int getTransPoint( int index ); +#endif + +#ifdef _PET_UP +int getPetup( void ); +#endif +#ifdef _WATCH_FLOOR +int getWatchFloor( unsigned int index ); +char* getWatchFloorCF( void ); +#endif + +#ifdef _BATTLE_FLOOR +int getBattleFloor( unsigned int index ); +char* getBattleFloorCF( void ); +#endif + +#ifdef _LOOP_ANNOUNCE +char* getLoopAnnouncePath( void ); +int loadLoopAnnounce( void ); +int getLoopAnnounceTime( void ); +char* getLoopAnnounce( int index ); +int getLoopAnnounceMax( void ); +#endif + +#ifdef _SKILLUPPOINT_CF +int getSkup( void ); +#endif +#ifdef _RIDELEVEL +int getRideLevel( void ); +#endif +#ifdef _REVLEVEL +char* getRevLevel( void ); +#endif +#ifdef _NEW_PLAYER_RIDE +char* getPlayerRide( void ); +#endif +#ifdef _FIX_CHARLOOPS +int getCharloops( void ); +#endif +#ifdef _PLAYER_ANNOUNCE +int getPAnnounce( void ); +#endif +#ifdef _PLAYER_MOVE +int getPMove( void ); +#endif + +int getrecvbuffer( void ); +int getsendbuffer( void ); +int getrecvlowatbuffer( void ); +int getrunlevel( void ); + +#ifdef _SHOW_VIP_CF +int getShowVip( void ); +#endif + +#ifdef _PLAYER_NUM +int getPlayerNum( void ); +void setPlayerNum( int num ); +char* getPlayerBase( void ); +#endif +#ifdef _BATTLE_GOLD +int getBattleGold( void ); +#endif + +#ifdef _ANGEL_TIME +int getAngelPlayerTime( void ); +int getAngelPlayerMun( void ); +#endif + +#ifdef _RIDEMODE_20 +int getRideMode( void ); +#endif + +#ifdef _FM_POINT_PK +char *getFmPointPK( void ); +#endif + +#ifdef _ENEMY_ACTION +int getEnemyAction( void ); +#endif + +#ifdef _FUSIONBEIT_TRANS +int getFusionbeitTrans( void ); +#endif + +char *getMacCheck( void ); +int getCpuUse( void ); + +#ifdef _CHECK_PEPEAT +int getCheckRepeat( void ); +#endif + +#ifdef _VIP_ALL +int getCheckVip( void ); +#endif +#ifdef _FM_JOINLIMIT +int getJoinFamilyTime( void ); +#endif + +#ifdef _NOWEN_EV +int getNowEvent(int Num); +int getEndEvent(int Num); +#endif + +#ifdef _JK_CF_DELPETITEM //ɾCFָƷͳ +char *getDelPet(void); +char *getDelItem(void); +#endif +int getBalltePoint(int Num); +#ifdef _ALL_TALK +int getTheWorldTrans( void ); +int getTheWorldFame( void ); +int getTheWorldTime( void ); +int getTheWorldCnt( void ); +#endif +#ifdef _DIY_INSLAY +int getInslayNum(void); +#endif +int getSafeMode(void); +int getTradeTax(void); +#ifdef _MAP_HEAL +int getMapHeal(int Num); +#endif +#ifdef _VIP_RIDE +int getVipMsgType(void); +#endif +#ifdef _VIP_BATTLE_EXP +int getVipBattleExp( void ); +#endif +int getItemPoolBug(void); +int getSameIpLogin(void); +int getPetRideTrans(void); +#ifdef _LUCK_MAN +int getLuckTime( void ); +int getLuckItem( void ); +#endif +#ifdef _QUESTION_ONLINE +int getQustionTime( void ); +int getQuestionItem( int num ); +#endif +#ifdef _NO_STREET_MAP +int getNoStreetMap( int num ); +#endif +#ifdef _STREET_FAX +int getStreetFax( int num ); +#endif +int getFmWarTime( int num ); +#endif +#ifdef _JZ_NEWSCRIPT_LUA +char *getLuaFile(void); +#endif +#ifdef _TRANS7_POINT +int getTrans7Point(void); +#endif +#ifdef _NOJOB_PK +int getNoJobPkMap(void); +#endif +#ifdef _UNTEXT_TALK +char *getUnText(int num); +#endif +BOOL LoadStreetItemUnText( void ); +char *getStreetItemUnName(int num); +#ifdef _NO_ATTACK +int getAttTime(void); +int getAttSafeTime(void); +int getAttCnt(void); +int getLateTime(void); +int getAttDmeTime(void); +int getAttDmeCnt(void); +#endif +char* getNoAttIp(int num); +#ifdef _NO_TRANS_ANGLE +int getTrans6Angle(void); +#endif +#ifdef _PET_BUG +int getPetPoint(int num); +#endif +#ifdef _VIGOR_SYS +int getVigorTime(int num); +int getVigorMax(void); +#endif +#ifdef _AUTO_PK +int getAutoPkTime(void); +int getAutoPkMinNum(void); +int getAutoPkBattleTime(void); +int getAutoPkMinLv(void); +int getAutoPkVigorPkNum(void); +int getAutoPkVigorPkCnt(void); +#endif +#ifdef _BATTLEMAP_CTRL +int getBattleTimeFloor(int num); +int getBattleTimePlayerNum(int num); +int getBattleTimeSec(int num); +#endif +#ifdef _FM_SERVERNO_SYS +int getFmServerNo(void); +char* getFmServerMsg(void); +#endif +#ifdef _ZHIPIAO_SYSTEM +int getZhiPiao(void); +int getPiaoTime(void); +#endif +#ifdef _FMWAR_MSG +char* getFmWarMsg(void); +#endif +#ifdef _FM_WELFARE +char* getFmWelfare(int num); +#endif +#ifdef _FMZUZHANG_MSG +char* getFmZuzhang(void); +#endif +#ifdef _PETMAIL_LV +int getPetMailLv(void); +int getPetMailCf(void); +#endif +#ifdef _FMWAR_PLAYERNUM +int getFmWarPlayerNum(void); +#endif +#ifdef _WAN_FIX +int getVsFlg(void); +#endif +#ifdef _WARNPC_CTRL +int getPartyMap(int num); +int getMapSameIp(int num); +#endif +#ifdef _NO_DAOLUAN +int getStreetTrn(void); +int getTalkTrn(void); +int getTalkLv(void); +char* getTalkMsg(void); +char* getTalkName(void); +#endif +#ifdef _NO_FULLPLAYER_ATT +int getNoFullPlayer(void); +int getNoFull2Player(void); +int getNoCdkeyPlayer(void); +int getNoCdkeyMode(void); +int getNoCdkeyType(void); +int getNoFullTime(void); +int getFengType(void); +int getNoFullEndPlayer(void); +int getNoFullEndTime(void); +int getManRenNum(void); +int getBigBao(void); +int getBigBao2(void); +#endif +#ifdef _ATTREVERSE_FIX +int getAttReverse(void); +#endif +#ifdef _NEWFM_GOLD +int getNewFmGold(void); +#endif +#ifdef _MERGE_TIME +int getMergeTime(void); +#endif +#ifdef _PETUP_GET_EXP +int getPetUpGetExp(void); +#endif +#ifdef _MM_NO_JIAOBEN +int getNoMMJiaoben(void); +int getEditBaseTime(void); +#endif +#ifdef _DP_140_160_MODE +int getNewDpMode(void); +#endif +#ifdef _LOOK_STREET_TIME +int getLookStreetTime(void); +#endif +#ifdef _BATTLE_EQUIT_OTHER +int getBattleEquitOther(void); +#endif +#ifdef _PK_LUCK_MAN +int getPkLuckFloor(int floor); +char* getPkLuckMapName(int num); +int getPkLuckTimeMin(void); +int getPkLuckTimeMax(void); +int getPkLuckNum(void); +int getPkLuckFame(void); +int getPkLuckVigor(void); +int getPkLuckVipPoint(void); +int getPkLuckAmPoint(void); +int getPkLuckLevel(void); +int getPkLuckBattleTurn(void); +#endif +#ifdef _NO_DAOLUAN +int getTalkFloor(int num); +#endif +#ifdef _SUPERMAN_FIX +int getSuperManPoint(void); +#endif +#ifdef _PICKUP_ITEM_OTHER +int getPickupItem(void); +char* getPickItemId(void); +#endif +#ifdef _FM_LIAOLI +int getFmLiaoLiType(void); +#endif +#ifdef _TRADE_ITEM_FIX +int getTradeItemFix(void); +#endif +#ifdef _PETMAIL_TIME +int getPetMailTime(void); +#endif +int getRandMin(void); +int getRandMax(void); +#ifdef _GJS_TYPE +int getGjsType(void); +#endif +int getTicketCf(void); +char* getTicketMsg(void); + +char* getDefaultKey(int cli_fd); +char* getRunningKey(void); +char* getSaVersion(void); +int getSaType(void); +#ifdef _BATTLEEND_FIX +int getBattleEndMode(void); +#endif +#ifdef _BIG_POOL_TYPE +int getPetPoolType(void); +int getItemPoolType(void); +#endif +int getNoStayBattle(void); +int getRightNum(void); +int getRightMode(void); +int getErrorMode(void); +#ifdef _FLOOR_PARTY_CTRL +int getPartyFloor(int num); +#endif +int getBattleTimtOut(void); +int getReloadNpcTime(void); +int getReloadNpcType(void); +int getOfflineBattleTime(void); +int getOfflineCf(void); +int getOfflineMaxNum(void); +int getOfflineJqmMaxNum(void); +int getKongType(void); +int getJiFenBaiTan(void); +int getNoPkMap(void); +int getFmBuffTrans(void); +char* getNoMpMagic(void); +int getLoginJqmType(void); +char* getFmMagicMpRate(int num); +int getSameIpNum(void); +int getSameJqmNum(void); +int getSameJqmAllNum(void); + +int getMmType(void); +char* getMmMsg(void); + +int getLockType(void); +int getAllTalkPoint(void); +#ifdef _NO_RIDE_ID +char* getNoRideId(void); +#endif +int getLoginType(void); + +#ifdef _GET_BATTLE_EXP +unsigned int getBattleexp( void ); +void setBattleexp( int exp ); +#endif + +#ifdef _PETTRANS_RANGE +void setPetTransRangeX(int num); +int getPetTransRangeX(void); +void setPetTransRangeY(int num); +int getPetTransRangeY(void); +void setPetTransRangeZ(int num); +int getPetTransRangeZ(void); +#endif + +#ifdef _ITEM_LUA +const char *getitemluafile(void); +BOOL ITEM_LuaInit(const char * _FileName); +#endif + +#ifdef _SAME_IP_ONLINE_NUM +int getSameIpOnlineNum(); +#endif + +#ifdef _CHECK_SEVER_IP +int checkServerIp( unsigned int ip ); +#endif +BOOL luareadconfigfile( char* data ); + +#ifdef _CAX_ESC_REPORT +int getReportItem(unsigned int index); +int getVipReportItem(unsigned int index); +int getReportLv(void); +int getReportTa(void); +#endif + +#ifdef _PETSKILL_SHOP_LUA +char *getFreePetSkillShopPath(); +#endif + +#ifdef _CAX_FAMEBUTTON +char* getfamebutton( void ); +#endif + +#ifdef _PET_TRANS_ABILITY +int getPetTransAbility(); +int getPetTransAbility1(); +int getPetTransAbility2(); +int getPetTransAbility3(); +#endif + +#ifdef _PET_3TRANS +int getMMPETID1(void); +int getMMPETID2(void); +#endif + +#ifdef _NO_MAGIC +int getnomagicmap(int num); +#endif + +#ifdef _illegalpetskill_CF +int getIllegalPetskill(int index); +#endif + +#ifdef _CAX_PET_EVOLUTION +char getpetevotyb(void); +int getpetevotyb1(void); +#endif + +#ifdef _TRANS_7_COLOR +//int getTranColor(void); +char getping(void); +char getpetsummon(void); +#endif + +#ifdef _CAX_PET_ITEMRIDE +char getpetitemride(void); +#endif + +#ifdef _DAMMAGE_CALC +int getDamageCalc(); +#endif + +#ifdef _CAX_LNS_NLSUOXU +int GetConfigLineType(char *TM_ConfigName); +char* GetConfigLineVal(char *TM_ConfigName); +int getCopymapstartingID( void ); +#endif + +#ifdef _CAX_FAME_KOUFEI +int getfamekoufei(); +#endif + +#ifdef _CAX_ITEM_ADDEXP +int getexptime(); +#endif + + +#ifdef _SHARE_EXP +int getExpShare(void); +#endif +#ifdef _TEAM_ADDEXP +int getTeamAddExp(void); +#endif + +#ifdef _NO_STW_ENEMY +int getNoSTWNenemy( void ); +int getNoSTWNenemyPoint( void ); +#endif + +#ifdef _DEX_FIX +int getDexFixPer(void); +#endif +#ifdef _FM_EXP_ADD +unsigned int getFmAddExp( void ); +#endif diff --git a/include/correct_bug.h b/include/correct_bug.h new file mode 100644 index 0000000..c9d6eb2 --- /dev/null +++ b/include/correct_bug.h @@ -0,0 +1,20 @@ +#ifndef __CORRECT_BUG_H__ +#define __CORRECT_BUG_H__ + +/* ----------------------- () ---------------------------*/ +#define _add_item_log_name // WON ADD itemlogitem +#define _PETSKILLBUG // Syu ADD +#define _FIXWOLF // Syu ADD ˱Bug +#define _FIXMAGICBUG // Syu ADD ħԱ +#define _FIXPETFALL // Syu ADD +#define _FIX_ITEMRELIFE // WON ADD +#define _FIX_SPEED_UPLEVEL // WON ADD +#define _FIX_PETMAIL // WON ADD +#define _FIX_EQUIP_ITEM // WON ADD װ +#define _ADD_PETMAIL_NUM // WON ADD GMָ +#define _FIX_equipNoenemy // WON ADD ̫ +#define _FIX_PETMAIL2 // WON ADD 2 +#define _FIXITEMANISHOW // Syu ADD غԲѪװʱﲻʾ +#define _kr_ip // WON ADD gmָip + +#endif diff --git a/include/deathcontend.h b/include/deathcontend.h new file mode 100644 index 0000000..7e8c117 --- /dev/null +++ b/include/deathcontend.h @@ -0,0 +1,44 @@ +002C:defend.h:032:1:14=48041e4b:16=47d21313:#ifndef __DEFEND_H__ +#define __DEFEND_H__ + +#endif +002E:encount.h:0638:1:14=48041e4b:16=47d21313:#ifndef __ENCOUNT_H__ +#define __ENCOUNT_H__ + +#define ENCOUNT_GROUPMAXNUM 10 + +BOOL ENCOUNT_initEncount( char* filename ); +BOOL ENCOUNT_reinitEncount( void ); +int ENCOUNT_getEncountAreaArray( int floor, int x, int y); +int ENCOUNT_getEncountPercentMin( int charaindex, int floor , int x, int y ); +int ENCOUNT_getEncountPercentMax( int charaindex, int floor , int x, int y ); +int ENCOUNT_getCreateEnemyMaxNum( int floor , int x, int y ); +int ENCOUNT_getEncountIndex( int floor , int x, int y ); +int ENCOUNT_getEncountIndexFromArray( int array ); +int ENCOUNT_getEncountPercentFromArray( int array ); +int ENCOUNT_getCreateEnemyMaxNumFromArray( int array ); +int ENCOUNT_getGroupIdFromArray( int array, int grouparray ); +int ENCOUNT_getGroupProbFromArray( int array, int grouparray ); +int ENCOUNT_getZorderFromArray( int array ); + +#ifdef _ADD_ENCOUNT // WON ADD ӵ޼ +typedef struct tagENCOUNT_Table +{ + int index; + int floor; + int encountprob_min; /* ޼ */ + int encountprob_max; /* ޼ */ + int enemymaxnum; /* ľë¾ */ + int zorder; + int groupid[ENCOUNT_GROUPMAXNUM]; /* No */ + int createprob[ENCOUNT_GROUPMAXNUM]; /* */ + int event_now; + int event_end; + int enemy_group; // group + RECT rect; +}ENCOUNT_Table; + +ENCOUNT_Table *ENCOUNT_table; +#endif + +#endif diff --git a/include/defend.h b/include/defend.h new file mode 100644 index 0000000..7c701c0 --- /dev/null +++ b/include/defend.h @@ -0,0 +1,4 @@ +#ifndef __DEFEND_H__ +#define __DEFEND_H__ + +#endif diff --git a/include/des.h b/include/des.h new file mode 100644 index 0000000..04d5f46 --- /dev/null +++ b/include/des.h @@ -0,0 +1,22 @@ +////////////////////////////////////////////////////////////////////////// +/* + Provided by , Northeastern University (www.neu.edu.cn) + Email: blackdrn@sohu.com + This product is free for use. +*/ +////////////////////////////////////////////////////////////////////////// +#include +enum {ENCRYPT,DECRYPT}; +//enum bool{false,true}; // if bool is not supported,use this or just replace with char + // and use 1 for true,0 for false; +////////////////////////////////////////////////////////////////////////// + +// TypeENCRYPT:,DECRYPT: +// (Out)ij >= ((datalen+7)/8)*8,datalen8ıС +// In = Out,ʱ/ܺ󽫸뻺(In) +// keylen>8ʱϵͳԶʹ3DES/,ʹñ׼DES/.16ֽںֻȡǰ16ֽ + +bool Des_Go(char *Out,char *In,long datalen,const char *Key,int keylen,bool Type); + +////////////////////////////////////////////////////////////////////////// + diff --git a/include/encount.h b/include/encount.h new file mode 100644 index 0000000..e3762f8 --- /dev/null +++ b/include/encount.h @@ -0,0 +1,40 @@ +#ifndef __ENCOUNT_H__ +#define __ENCOUNT_H__ + +#define ENCOUNT_GROUPMAXNUM 10 + +BOOL ENCOUNT_initEncount( char* filename ); +BOOL ENCOUNT_reinitEncount( void ); +int ENCOUNT_getEncountAreaArray( int floor, int x, int y); +int ENCOUNT_getEncountPercentMin( int charaindex, int floor , int x, int y ); +int ENCOUNT_getEncountPercentMax( int charaindex, int floor , int x, int y ); +int ENCOUNT_getCreateEnemyMaxNum( int floor , int x, int y ); +int ENCOUNT_getEncountIndex( int floor , int x, int y ); +int ENCOUNT_getEncountIndexFromArray( int array ); +int ENCOUNT_getEncountPercentFromArray( int array ); +int ENCOUNT_getCreateEnemyMaxNumFromArray( int array ); +int ENCOUNT_getGroupIdFromArray( int array, int grouparray ); +int ENCOUNT_getGroupProbFromArray( int array, int grouparray ); +int ENCOUNT_getZorderFromArray( int array ); + +#ifdef _ADD_ENCOUNT // WON ADD ӵ޼ +typedef struct tagENCOUNT_Table +{ + int index; + int floor; + int encountprob_min; /* ޼ */ + int encountprob_max; /* ޼ */ + int enemymaxnum; /* ľë¾ */ + int zorder; + int groupid[ENCOUNT_GROUPMAXNUM]; /* No */ + int createprob[ENCOUNT_GROUPMAXNUM]; /* */ + int event_now; + int event_end; + int enemy_group; // group + RECT rect; +}ENCOUNT_Table; + +ENCOUNT_Table *ENCOUNT_table; +#endif + +#endif diff --git a/include/enemy.h b/include/enemy.h new file mode 100644 index 0000000..b311541 --- /dev/null +++ b/include/enemy.h @@ -0,0 +1,258 @@ +#ifndef __ENEMY_H__ +#define __ENEMY_H__ + +enum +{ + E_T_SIZE_NORMAL, + E_T_SIZE_BIG, +}; + +typedef enum +{ + E_T_TEMPNO, + E_T_INITNUM, + E_T_LVUPPOINT, + E_T_BASEVITAL, + E_T_BASESTR, + E_T_BASETGH, + E_T_BASEDEX, + E_T_MODAI, + E_T_GET, + E_T_EARTHAT, + E_T_WATERAT, + E_T_FIREAT, + E_T_WINDAT, + E_T_POISON, /* ̫ĸ */ + E_T_PARALYSIS, /* ̫ľ1 ƥئУ */ + E_T_SLEEP, /* Ի۵ ƥئ */ + E_T_STONE, /* ޣ۵ ƥئ */ + E_T_DRUNK, /* 쵤 Ʊ */ + E_T_CONFUSION, /* ٣ ë */ + E_T_PETSKILL1, + E_T_PETSKILL2, + E_T_PETSKILL3, + E_T_PETSKILL4, + E_T_PETSKILL5, + E_T_PETSKILL6, + E_T_PETSKILL7, + E_T_RARE, + E_T_CRITICAL, + E_T_COUNTER, + E_T_SLOT, + E_T_IMGNUMBER, + E_T_PETFLG, + E_T_SIZE, + E_T_ATOMBASEADD1, + E_T_ATOMFIXMIN1, + E_T_ATOMFIXMAX1, + E_T_ATOMBASEADD2, + E_T_ATOMFIXMIN2, + E_T_ATOMFIXMAX2, + E_T_ATOMBASEADD3, + E_T_ATOMFIXMIN3, + E_T_ATOMFIXMAX3, + E_T_ATOMBASEADD4, + E_T_ATOMFIXMIN4, + E_T_ATOMFIXMAX4, + E_T_ATOMBASEADD5, + E_T_ATOMFIXMIN5, + E_T_ATOMFIXMAX5, + E_T_LIMITLEVEL, // Arminius 7.30 limit level +#ifdef _PET_FUSION + E_T_FUSIONCODE, +#endif +#ifdef _PET_AMOI__E + E_T_ENABLETRADE, + E_T_PETTYPE, + E_T_PETTYPESUB, +#endif + E_T_DATAINTNUM, +}ENEMYTEMP_DATAINT; + +typedef enum +{ + E_T_NAME, + E_T_ATOMFIXNAME1, + E_T_ATOMFIXNAME2, + E_T_ATOMFIXNAME3, + E_T_ATOMFIXNAME4, + E_T_ATOMFIXNAME5, + E_T_DATACHARNUM, + +}ENEMYTEMP_DATACHAR; + +typedef enum +{ + ENEMY_ID, + ENEMY_TEMPNO, + ENEMY_LV_MIN, + ENEMY_LV_MAX, + ENEMY_CREATEMAXNUM, + ENEMY_CREATEMINNUM, + ENEMY_TACTICS, + ENEMY_EXP, + ENEMY_DUELPOINT, + ENEMY_STYLE, + ENEMY_PETFLG, /* ʸئ¾ */ + + ENEMY_ITEM1, + ENEMY_ITEM2, + ENEMY_ITEM3, + ENEMY_ITEM4, + ENEMY_ITEM5, + ENEMY_ITEM6, + ENEMY_ITEM7, + ENEMY_ITEM8, + ENEMY_ITEM9, + ENEMY_ITEM10, + ENEMY_ITEMPROB1, + ENEMY_ITEMPROB2, + ENEMY_ITEMPROB3, + ENEMY_ITEMPROB4, + ENEMY_ITEMPROB5, + ENEMY_ITEMPROB6, + ENEMY_ITEMPROB7, + ENEMY_ITEMPROB8, + ENEMY_ITEMPROB9, + ENEMY_ITEMPROB10, + + ENEMY_DATAINTNUM, + +}ENEMY_DATAINT; + +typedef enum +{ + ENEMY_NAME, + ENEMY_TACTICSOPTION, +#ifdef _BATTLENPC_WARP_PLAYER + ENEMY_ACT_CONDITION, +#endif + ENEMY_DATACHARNUM, +}ENEMY_DATACHAR; + +typedef enum +{ + GROUP_ID, + GROUP_APPEARBYITEMID, /* ʧ ةë Ȼ -1 */ + GROUP_NOTAPPEARBYITEMID, /* ʧ ةë Ȼئ -1 */ + ENEMY_ID1, + ENEMY_ID2, + ENEMY_ID3, + ENEMY_ID4, + ENEMY_ID5, + ENEMY_ID6, + ENEMY_ID7, + ENEMY_ID8, + ENEMY_ID9, + ENEMY_ID10, + CREATEPROB1, + CREATEPROB2, + CREATEPROB3, + CREATEPROB4, + CREATEPROB5, + CREATEPROB6, + CREATEPROB7, + CREATEPROB8, + CREATEPROB9, + CREATEPROB10, + GROUP_DATAINTNUM, +}GROUP_DATAINT; + +typedef enum +{ + GROUP_NAME, + GROUP_DATACHARNUM, + +}GROUP_DATACHAR; + + +typedef struct tagENEMY_EnemyTable +{ + int intdata[ENEMY_DATAINTNUM]; + STRING64 chardata[ENEMY_DATACHARNUM]; + int enemytemparray; +}ENEMY_EnemyTable; + +typedef struct tagENEMYTEMP_Table +{ + int intdata[E_T_DATAINTNUM]; + //ANDY_EDIT + STRING64 chardata[E_T_DATACHARNUM]; + +}ENEMYTEMP_Table; + +typedef struct tagGROUP_Table +{ + int intdata[GROUP_DATAINTNUM]; + STRING32 chardata[GROUP_DATACHARNUM]; + int enemyarray[CREATEPROB1 - ENEMY_ID1]; +}GROUP_Table; + + + +INLINE BOOL ENEMY_CHECKINDEX( int index); +INLINE int ENEMY_setInt( int index, ENEMY_DATAINT element, int data); +INLINE int ENEMY_getInt( int index, ENEMY_DATAINT element); + +INLINE int *ENEMY_getIntdata( int index); + +INLINE BOOL ENEMY_setChar( int index ,ENEMY_DATACHAR element, char* new ); +INLINE char *ENEMY_getChar( int index, ENEMY_DATACHAR element); +int ENEMY_getEnemyNum( void); +BOOL ENEMY_initEnemy( char* filename ); +BOOL ENEMY_reinitEnemy( void ); +int ENEMY_createEnemy( int array, int baselevel ); +int *ENEMY_getEnemy( int charaindex, int x, int y); +int ENEMY_createPetFromEnemyIndex( int charaindex, int array); +int ENEMY_createPet( int array, int vital, int str, int tgh, int dex); +int ENEMY_getEnemyArrayFromId( int EnemyId); +int ENEMY_getEnemyArrayFromTempNo( int EnemyTempNo); +int ENEMY_getEnemyIdFromTempNo( int EnemyTempNo); +int ENEMY_getEnemyTempNoFromId( int EnemyId); + +#ifdef _TEST_DROPITEMS +int ENEMY_TEST_createPetIndex( int array); +#endif + +int ENEMYTEMP_getEnemyNum( void);//krynn 2001/12/13 +INLINE BOOL ENEMYTEMP_CHECKINDEX( int index); +INLINE int ENEMYTEMP_setInt( int index, ENEMYTEMP_DATAINT element, int data); +INLINE int ENEMYTEMP_getInt( int index, ENEMYTEMP_DATAINT element); +INLINE char *ENEMYTEMP_getChar( int index, ENEMYTEMP_DATACHAR element); +INLINE BOOL ENEMYTEMP_getInt_setChar( int index ,ENEMYTEMP_DATACHAR element, char* new ); +INLINE char *ENEMYTEMP_getInt_getChar( int index, ENEMYTEMP_DATACHAR element); +int ENEMYTEMP_getInt_getEnemyNum( void); +BOOL ENEMYTEMP_getInt_initEnemy( char* filename ); +BOOL ENEMYTEMP_getInt_reinitEnemy( void ); +int ENEMYTEMP_getEnemyTempArray( int enemyindex); +int ENEMYTEMP_getEnemyTempArrayFromTempNo( int EnemyTempNo); +int ENEMYTEMP_getEnemyTempArrayFromInitnum( int EnemyTempNo); + +INLINE int GROUP_setInt( int index, GROUP_DATAINT element, int data); +INLINE int GROUP_getInt( int index, GROUP_DATAINT element); +INLINE BOOL GROUP_setChar( int index ,GROUP_DATACHAR element, char* new ); +INLINE char *GROUP_getChar( int index, GROUP_DATACHAR element); +int GROUP_getEnemyNum( void); + +BOOL ENEMYTEMP_initEnemy( char* filename ); +BOOL ENEMYTEMP_reinitEnemy( void ); +BOOL GROUP_initGroup( char* filename ); +BOOL GROUP_reinitGroup( void ); + +#ifdef _PET_EVOLUTION +int EVOLUTION_createPetFromEnemyIndex( int charaindex, int baseindex, int flg); +int PET_CheckIncubate( int charaindex); +BOOL PETFUSION_getIndexForChar( int toindex, int *MainIndex, int *Subindex1,int *Subindex2, char *data); +int NPC_getFusionTableForBase( int charaindex, int petindex1, int petindex2 ); +int NPC_getPetArrayForNo( int PetCode); +BOOL PET_getEvolutionAns( int petindex, int *base); +#endif + +int PETFUSION_SetNewEgg( int toindex , int petindex, int array, int *work, int *skill1, int *skill2); +BOOL PETFUSION_AddEgg(int toindex, int petID, int PetCode); + +#ifdef _PET_TRANS +int GetNewPet( int toindex , int petindex, int array, int *work); +#endif + +#endif diff --git a/include/enemyexptbl.h b/include/enemyexptbl.h new file mode 100644 index 0000000..5113dd4 --- /dev/null +++ b/include/enemyexptbl.h @@ -0,0 +1,207 @@ +#ifndef __ENEMY_EXPTBL_H__ +#define __ENEMY_EXPTBL_H__ + + +static int enemybaseexptbl[] = { +1, +2, +3, +4, +5, +6, +9, +12, +15, +18, +22, +26, +30, +35, +40, +46, +52, +58, +65, +72, +79, +87, +95, +104, +113, +122, +131, +141, +151, +162, +173, +184, +196, +208, +220, +233, +246, +260, +274, +288, +303, +318, +333, +348, +365, +381, +398, +415, +432, +450, +468, +486, +506, +525, +545, +564, +585, +606, +627, +648, +670, +692, +714, +737, +760, +784, +808, +832, +857, +882, +907, +933, +959, +956, +1012, +1040, +1067, +1095, +1123, +1152, +1181, +1210, +1240, +1270, +1300, +1331, +1362, +1394, +1426, +1458, +1490, +1524, +1557, +1590, +1625, +1659, +1694, +1729, +1764, +1800, // level 100 +1836, +1872, +1909, +1946, +1983, +2021, +2059, +2097, +2136, +2175, // level 110 +2214, +2254, +2294, +2334, +2374, +2414, +2455, +2496, +2537, +2578, // level 120 +2619, +2661, +2703, +2745, +2787, +2829, +2872, +2915, +2958, +3000, // level 130 +3043, +3088, +3132, +3176, +3220, +3264, +3309, +3354, +3399, +3444, // level 140 +3489, +3535, +3581, +3627, +3673, +3719, +3765, +3812, +3859, +3906, // level 150 +3953, +4000, +4047, +4095, +4143, +4191, +4239, +4287, +4335, +4384, // level 160 +4433, +4482, +4531, +4580, +4629, +4679, +4729, +4779, +4829, +4879, // level 170 +4929, +4980, +5031, +5082, +5133, +5184, +5235, +5287, +5339, +5391, // level 180 +5443, +5495, +5547, +5599, +5652, +5705, +5758, +5811, +5864, +5917, // level 190 +5970, +6024, +6078, +6132, +6186, +6240, +6295, +6350, +6405, +6460, // level 200 +}; +#endif diff --git a/include/event.h b/include/event.h new file mode 100644 index 0000000..17dec66 --- /dev/null +++ b/include/event.h @@ -0,0 +1,9 @@ +#ifndef __EVENT_H__ +#define __EVENT_H__ + +INLINE BOOL EVENT_CHECKEVENTINDEX( int event); +int EVENT_main( int charaindex,int event, int x, int y); + + +#endif + diff --git a/include/family.h b/include/family.h new file mode 100644 index 0000000..1ed8f7a --- /dev/null +++ b/include/family.h @@ -0,0 +1,225 @@ +#ifndef __FAMILY_H__ +#define __FAMILY_H__ + +#include "version.h" +#include "common.h" +#include "util.h" +#include "net.h" +#include "time.h" + +#define FAMILY_MAXNUM 1000 // +#ifdef _FMVER21 +#define FAMILY_MAXMEMBER 200 // +#define FAMILY_MAXCHANNELMEMBER 50 // Ƶ +#else +#define FAMILY_MAXMEMBER 50 // +#define FAMILY_MAXCHANNELMEMBER 10 // Ƶ +#endif +#define FAMILY_MAXCHANNEL 5 // Ƶ + +#define CHAR_MAXNAME 32 +#define CHAR_MAXID 20 +#define MINFMLEVLEFORPOINT 3 // 3 ׯ԰͵ȼ +#define FMLEADERLV 30 // 峤ȼ + +#ifdef _FAMILY_MANORNUM_CHANGE +#define FAMILY_FMPKFLOOR 15 // Уͼ +#else +#define FAMILY_FMPKFLOOR 9 // Уͼ +#define FMPOINTNUM 4 // оݵ +#define MANORNUM 4 +#define FAMILY_MAXHOME 4 // ݵ +#endif + +enum +{ + FM_TOP_INTEGRATE = 1, // DPTOP ۺ + FM_TOP_ADV, // DPTOP ð + FM_TOP_FEED, // DPTOP + FM_TOP_SYNTHESIZE, // DPTOP ϳ + FM_TOP_DEALFOOD, // DPTOP + FM_TOP_PK, // DPTOP У +#ifdef _NEW_MANOR_LAW + FM_TOP_MOMENTUM = 8, // DPTOP +#endif + FM_TOP_NUM, // DPTOP +}; + +enum +{ + FM_FIX_ACCEPTFLAG = 1, + FM_FIX_FMPK, + FM_FIX_FMPET, + FM_FIX_FMRULE, + FM_FIX_DELFMTIME, + FM_FIX_FMGOLD, + FM_FIX_FMADV, + FM_FIX_FMFEED, + FM_FIX_FMSYNTHESIZE, + FM_FIX_FMDEALFOOD, + FM_FIX_FMLEADERCHANGE, +#ifdef _NEW_MANOR_LAW + FM_FIX_FMMOMENTUM, + FM_FIX_FAME, +#endif +}; + +/* + * ӡ ְ缰 cdkey charname Ӯë׻ + * CHEKEYLEN, CHARNAMELEN + * ë ʣ + */ + +void CHAR_Family(int fd, int index, char* message); +void ACAddFM(int fd, int result, int fmindex, int index); +void ACJoinFM(int fd, int result, int recv); +void ACLeaveFM(int fd, int result, int resultflag); +void ACDelFM(int fd, int result); +void ACShowFMList(int ret, int fmnum, char *data); +void ACFMDetail(int ret, char *data, int charfdid); +void ACShowMemberList(int result, int index, int fmnumm, +int fmacceptflag, int fmjoinnum, char *data); +void ACShowDpTop(int result,int num, char *data, int kindflag); +void ACShowPointList(int result, char *data); +void ACShowFMMemo(int result, int index, int num, int dataindex, char *data); + +#ifdef _PERSONAL_FAME // Arminius: +void ACFMCharLogin(int fd, int ret, int index, int floor, int fmdp, + int joinflag, int fmsetupflag, int flag, int charindex, int charfame + #ifdef _NEW_MANOR_LAW + ,int momentum + #endif + ); +#else +void ACFMCharLogin(int fd, int ret, int index, int floor, int fmdp, + int joinflag, int fmsetupflag, int flag, int charindex); +#endif + +void ACFMPointList(int ret, char *data); +void ACSetFMPoint(int ret, int r, int clifd); +void ACFMAnnounce(int ret, char *fmname, int fmindex, int index, int kindflag, + char *data, int color); +void ACFixFMPK(int winindex, int loseindex, int data); +void ACFMJob( int fd, int ret, char* data1, char* data2 ); + +void FAMILY_Add(int fd, int meindex, char *message); +void FAMILY_Join(int fd, int meindex, char *message); +void FAMILY_Leave(int fd, int meindex, char *message); +void FAMILY_Detail(int fd, int meindex, char *message); +void FAMILY_CheckMember(int fd, int meindex, char *message); +void FAMILY_Channel(int fd, int meindex, char *message); +void FAMILY_Bank(int fd, int meindex, char *message); +void FAMILY_SetPoint(int fd, int meindex, char *message); +void FAMILY_Init(void); +void FAMILY_SetAcceptFlag(int fd, int meindex, char *message); +void FAMILY_FixRule( int fd, int meindex, char* message ); +int FAMILY_RidePet( int fd, int meindex, char* message ); +void FAMILY_LeaderFunc( int fd, int meindex, char* message ); + +#ifdef _ADD_FAMILY_TAX // WON ADD ׯ԰˰ +void GS_ASK_TAX(void); +void FAMILY_FIX_TAX( int fd, int index, char* message); +#endif + +void SetFMPetVarInit(int meindex); +void SetFMVarInit(int meindex); + + +int CheckFMLeader(int meindex); +int getFmLv(int playerindex); + +void getNewFMList( void ); +void checkFamilyIndex( void ); + +int CheckLeaderQ(int meindex); + + +// shan add Begin +struct FMMEMBER_LIST +{ +// int fmindex; + int fmnum; + int fmjoinnum; +// BOOL use; // 0->ûʹ 1->ʹ + int memberindex[FAMILY_MAXMEMBER]; + char numberlistarray[FAMILY_MAXMEMBER][64]; + char memo[35][220]; // family dengon + int accept; // ļԱ + int memonum; + int memoindex; +}; +// ֮԰ +struct FMS_MEMO +{ + char memo[140][220]; + int memonum; + int memoindex; +}; +// ǿ߱ +struct FMS_DPTOP +{ + int num; // ¼жٸ(ۺ) + char topmemo[FAMILY_MAXNUM][128]; + int fmtopid[FAMILY_MAXNUM]; // +#ifdef _FMVER21 + int fmtopdp[FAMILY_MAXNUM]; // ۺ +#endif +#ifdef _NEW_MANOR_LAW + int fmMomentum[FAMILY_MAXNUM]; // + char momentum_topmemo[FAMILY_MAXNUM][96]; // top + int momentum_topid[FAMILY_MAXNUM]; // top id +#endif + int adv_num; // ð + char adv_topmemo[30][96]; + int feed_num; // + char feed_topmemo[30][96]; + int syn_num; // ϳ + char syn_topmemo[30][96]; + int food_num; // + char food_topmemo[30][96]; + int pk_num; // У + char pk_topmemo[30][96]; +}; +// ݵ +struct FM_POINTLIST +{ + char pointlistarray[FAMILY_MAXHOME][1024]; // Arminius: 32->1024 +#ifdef _NEW_MANOR_LAW + int fm_momentum[FAMILY_MAXHOME]; // ¼սʱڿʼʱׯֵ + BOOL fm_inwar[FAMILY_MAXHOME]; // ׯ԰Ƿׯ԰ų +#endif +}; +// PKͼ +struct FM_PKFLOOR +{ + int fl; +}; +// End + +#ifdef _NEW_MANOR_LAW +typedef struct _ManorSchedule_t{ + int iFmIndex[10]; // սų̵ļ + int iFmMomentum[10]; // + int iSort[10]; // + char szMemo[10][256]; // ¼: |Լսʱ| + char szFmName[10][32]; // + struct tm tm1[10]; // ¼սʱ +}ManorSchedule_t; + +extern ManorSchedule_t ManorSchedule[MANORNUM]; +#endif + +#define MAXFAMILYLIST 64*1024 +extern char familyListBuf[MAXFAMILYLIST]; + +void JoinMemberIndex( int charaindex, int fmindexi); + +int channelMember[FAMILY_MAXNUM][FAMILY_MAXCHANNEL][FAMILY_MAXMEMBER]; +int familyMemberIndex[FAMILY_MAXNUM][FAMILY_MAXMEMBER]; + +#ifdef _CAX_LNS_CHARSUOXU +int Char_GetFm( int id, int x); +char * FM_getManorData(int ManorId,int Flg); +#endif + +#endif diff --git a/include/function.h b/include/function.h new file mode 100644 index 0000000..cd8d34d --- /dev/null +++ b/include/function.h @@ -0,0 +1,5 @@ +#ifndef __FUNCTION_H__ +#define __FUNCTION_H__ +BOOL initFunctionTable( void ); +void* getFunctionPointerFromName( char* funcname ); +#endif diff --git a/include/handletime.h b/include/handletime.h new file mode 100644 index 0000000..048ab78 --- /dev/null +++ b/include/handletime.h @@ -0,0 +1,59 @@ +#ifndef __HANDLETIME_H__ +#define __HANDLETIME_H__ + +#include + +#include "common.h" + +#undef EXTERN +#ifdef __HANDLETIME_C__ +#define EXTERN +#else /*__HANDLETIME_C__*/ +#define EXTERN extern +#endif + +EXTERN struct timeval NowTime; +EXTERN int DEBUG_ADJUSTTIME; + +BOOL setNewTime( void ); +#ifdef _ASSESS_SYSEFFICACY +void Assess_InitSysEfficacy( void); +void Assess_SysEfficacy( int flg); +void ASSESS_getSysEfficacy( float *TVsec); +#ifdef _ASSESS_SYSEFFICACY_SUB +void Assess_SysEfficacy_sub( int flg, int loop); +void ASSESS_getSysEfficacy_sub( float *TVsec, int loop); +#endif +#endif +// WON REM +//struct tm *localtime(const time_t *timep); + +/*ƱHiOLS*/ +/* 150()*60=9000 =750*12 ƥ LS1 */ +/* LS1200 LS1 */ +/* LS100 ƥ LS1 */ +typedef struct tagLSTIME +{ + int year; + int day; + int hour; +}LSTIME; + +#define NIGHT_TO_MORNING 700 +#define MORNING_TO_NOON 930 +#define NOON_TO_EVENING 200 +#define EVENING_TO_NIGHT 300 + +typedef enum +{ + LS_NIGHT = 0, + LS_MORNING , + LS_NOON , + LS_EVENING , +}LSTIME_SECTION; + +void RealTimeToLSTime(long t , LSTIME *lstime); +/*void LSTimeToRealTime( LSTIME *lstime, long *t);*/ +LSTIME_SECTION getLSTime (LSTIME *lstime); + +#endif diff --git a/include/init.h b/include/init.h new file mode 100644 index 0000000..121aca3 --- /dev/null +++ b/include/init.h @@ -0,0 +1,17 @@ +#ifndef __INIT_H__ +#define __INIT_H__ +#include "common.h" +BOOL init( int argc , char** argv, char** env ); +BOOL yanzheng_init( int argc , char** argv, char** env ); +#ifdef _ITEM_QUITPARTY + +typedef struct tagDisappearItem +{ + char string[64]; +}DisappearItem; +DisappearItem *Disappear_Item; +int itemquitparty_num; + +#endif + +#endif diff --git a/include/item.h b/include/item.h new file mode 100644 index 0000000..7956617 --- /dev/null +++ b/include/item.h @@ -0,0 +1,490 @@ + +#ifndef __ITEM_H__ +#define __ITEM_H__ + +//#include "char.h" + +#define NULLITEM "0" + +typedef enum +{ + ITEM_FIST =0, + ITEM_AXE, + ITEM_CLUB, + ITEM_SPEAR, + ITEM_BOW, + ITEM_SHIELD, + ITEM_HELM, + ITEM_ARMOUR, + + ITEM_BRACELET =8, + ITEM_MUSIC, + ITEM_NECKLACE, + ITEM_RING, + ITEM_BELT, + ITEM_EARRING, + ITEM_NOSERING, + ITEM_AMULET, + /* ****** */ + ITEM_OTHER =16, + ITEM_BOOMERANG, // + ITEM_BOUNDTHROW, // Ͷͷ + ITEM_BREAKTHROW, // Ͷʯ + ITEM_DISH =20, +#ifdef _ITEM_INSLAY + ITEM_METAL, + ITEM_JEWEL, +#endif +#ifdef _ITEM_CHECKWARES + ITEM_WARES, // +#endif + +#ifdef _ITEM_EQUITSPACE + ITEM_WBELT, // + ITEM_WSHIELD, // + ITEM_WSHOES, //Ь +#endif +#ifdef _EQUIT_NEWGLOVE + ITEM_WGLOVE, // +#endif + +#ifdef _ALCHEMIST + ITEM_ALCHEMIST =30, +#endif + +#ifdef _PET_ITEM + ITEM_PET_HEAD, + ITEM_PET_TOOTH, + ITEM_PET_CLAW, + ITEM_PET_BREAST, + ITEM_PET_BACK, + ITEM_PET_WING, + ITEM_PET_FEET, +#endif + +#ifdef _ANGEL_SUMMON + //ITEM_ANGELTOKEN, + //ITEM_HEROTOKEN, +#endif + + ITEM_CATEGORYNUM, + +}ITEM_CATEGORY; + +typedef enum +{ + ITEM_FIELD_ALL, + ITEM_FIELD_BATTLE, + ITEM_FIELD_MAP, +}ITEM_FIELDTYPE; + +typedef enum +{ + ITEM_TARGET_MYSELF, + ITEM_TARGET_OTHER, + ITEM_TARGET_ALLMYSIDE, + ITEM_TARGET_ALLOTHERSIDE, + ITEM_TARGET_ALL, +}ITEM_TARGETTYPE; + +typedef enum +{ + ITEM_ID, + ITEM_BASEIMAGENUMBER, + ITEM_COST, + ITEM_TYPE, + ITEM_ABLEUSEFIELD, + ITEM_TARGET, + ITEM_LEVEL, /* LEVEL */ +#ifdef _ITEM_MAXUSERNUM + ITEM_DAMAGEBREAK, //Ʒʹô +#endif + +#ifdef _ITEMSET4_TXT + ITEM_USEPILENUMS, //Ʒѵ + ITEM_CANBEPILE, //Ƿɶѵ + + ITEM_NEEDSTR, + ITEM_NEEDDEX, + ITEM_NEEDTRANS, + ITEM_NEEDPROFESSION, +#endif + +#ifdef _TAKE_ITEMDAMAGE + ITEM_DAMAGECRUSHE, + ITEM_MAXDAMAGECRUSHE, +#endif + +#ifdef _ADD_DEAMGEDEFC + ITEM_OTHERDAMAGE, + ITEM_OTHERDEFC, +#endif + +#ifdef _SUIT_ITEM + ITEM_SUITCODE, +#endif + + ITEM_ATTACKNUM_MIN, /* */ + ITEM_ATTACKNUM_MAX, /* */ + ITEM_MODIFYATTACK, /* */ + ITEM_MODIFYDEFENCE, /* */ + ITEM_MODIFYQUICK, /* QUICK */ + + ITEM_MODIFYHP, /* HP */ + ITEM_MODIFYMP, /* MP */ + ITEM_MODIFYLUCK, /* LUCK */ + ITEM_MODIFYCHARM, /* CHARM */ + ITEM_MODIFYAVOID, /* Ĥ */ + ITEM_MODIFYATTRIB, /* Ĥ */ + ITEM_MODIFYATTRIBVALUE, /* ĤҰ */ + ITEM_MAGICID, /* į */ + ITEM_MAGICPROB, /* */ + ITEM_MAGICUSEMP, /* MP */ + +#ifdef _ITEMSET5_TXT + ITEM_MODIFYARRANGE, + ITEM_MODIFYSEQUENCE, + + ITEM_ATTACHPILE, + ITEM_HITRIGHT, // +#endif +#ifdef _ITEMSET6_TXT + ITEM_NEGLECTGUARD, +// ITEM_BEMERGE, +#endif +#ifdef _PETITEM__AMOI_E + ITEM_PETFIX0, + ITEM_PETFIX1, + ITEM_PETFIX2, + ITEM_PETFIX3, + ITEM_PETFIX4, + ITEM_PETFIX5, + ITEM_PETFIX6, + ITEM_PETFIX7, +#endif + /* ĤҰ*/ + ITEM_POISON, /* ̫ĸ */ + ITEM_PARALYSIS, /* ̫ľ1 ƥئУ */ + ITEM_SLEEP, /* Ի۵ ƥئ */ + ITEM_STONE, /* ޣ۵ ƥئ */ + ITEM_DRUNK, /* 쵤 Ʊ */ + ITEM_CONFUSION, /* ٣ ë */ + + ITEM_CRITICAL, /* ūл Ĥ */ + + ITEM_USEACTION, /* ݼʧ */ + ITEM_DROPATLOGOUT, /* ʧݱ ʾ */ + ITEM_VANISHATDROP, /* ݱ¾ */ + ITEM_ISOVERED, /* Ⱦľ¾*/ + ITEM_CANPETMAIL, /* ʸƥ˪ľ¾ */ + ITEM_CANMERGEFROM, /* ئľ¾ */ + ITEM_CANMERGETO, /* Ʊئľ¾ */ + + ITEM_INGVALUE0, /* (5) */ + ITEM_INGVALUE1, + ITEM_INGVALUE2, + ITEM_INGVALUE3, + ITEM_INGVALUE4, +#ifdef _PETITEM__AMOI_E + ITEM_TYPEOFITEM, +#endif + ITEM_PUTTIME, /* ʧ ة ľ */ + ITEM_LEAKLEVEL, /* ľľ׾ */ + ITEM_MERGEFLG, /* ľʧ ة */ + ITEM_CRUSHLEVEL, /* çľպ 0 2 ߷çľئ 2ç */ + + ITEM_VAR1, /* ۽ */ + ITEM_VAR2, /* ۽ */ + ITEM_VAR3, /* ۽ */ + ITEM_VAR4, /* ۽ */ + ITEM_TIME, +#ifdef _ITEM_COLOER + ITEM_COLOER, +#endif + ITEM_DATAINTNUM, + +}ITEM_DATAINT; + +typedef enum +{ + ITEM_NAME, /* 񲼰 */ + ITEM_SECRETNAME, /* ʽľµ Ի */ + ITEM_EFFECTSTRING, /* ٯ */ + ITEM_ARGUMENT, /* ʧ ة¦ */ +#ifdef _ITEM_INSLAY + ITEM_TYPECODE, + ITEM_INLAYCODE, +#endif + ITEM_CDKEY, /* ʧ ة ë ٱ м */ +#ifdef _ITEM_FORUSERNAMES + ITEM_FORUSERNAME, + ITEM_FORUSERCDKEY, +#endif +// CoolFish: 2001/10/11 +#ifdef _UNIQUE_P_I + ITEM_UNIQUECODE, /* Ʒ */ +#endif + + ITEM_INGNAME0, /* м (5) */ + ITEM_INGNAME1, + ITEM_INGNAME2, + ITEM_INGNAME3, + ITEM_INGNAME4, + + + ITEM_INITFUNC, /* ¦ + * ITEM_Item* + * ߯Ի BOOL + * ߯Ի CHAR_INITFUNC + * Ԫ */ + ITEM_FIRSTFUNCTION = ITEM_INITFUNC, + ITEM_PREOVERFUNC, /* CHAR_PREOVERFUNC ë */ + ITEM_POSTOVERFUNC, /* CHAR_POSTOVERFUNC ë*/ + ITEM_WATCHFUNC, /* CHAR_WATCHFUNC ë */ + ITEM_USEFUNC, /* ¦ѷ + * int charaindex ƽҷ̼͵ + * int charitemindex м + * ʧ ة + * ë׾ + */ + ITEM_ATTACHFUNC, /* ¦ѷ + * int charaindex ƽҷ̼͵ + * int itemindex ʧ ة̼͵ + * ƽҷ Ȼʧ ة + * ʧ ة ƥ̼͵ + * ƥئDZ + */ + ITEM_DETACHFUNC, /* ¦ѷ + * int charaindex ƽҷ̼͵ + * int itemindex ʧ ة̼͵ + * ƽҷ Ȼʧ ة + * ʧ ة ƥ̼͵ + * ƥئDZ + */ + ITEM_DROPFUNC, /* + * ¦ѷ + * int charaindex ƽҷ + * int itemindex ʧ ة̼͵ + */ + ITEM_PICKUPFUNC, /* ʧ ةë + * ¦ѷ + * int charaindex ƽҷindex + * int itemindex ʧ ة̼͵ + */ +#ifdef _Item_ReLifeAct + ITEM_DIERELIFEFUNC, /*ANDY_ADD + + */ +#endif +#ifdef _PETITEM__AMOI_E + ITEM_PETEQUITALLOW, + ITEM_PETEQUITFORBIT, +#endif +#ifdef _PICKUP_ITEM_OTHER + ITEM_FROMCDKEY, +#endif + + ITEM_LASTFUNCTION, + + ITEM_DATACHARNUM = ITEM_LASTFUNCTION, + +#ifdef _ANGEL_SUMMON + ITEM_ANGELMISSION = ITEM_INGNAME0, + ITEM_ANGELINFO = ITEM_INGNAME1, + ITEM_HEROINFO = ITEM_INGNAME2, +#endif + +}ITEM_DATACHAR; + +typedef enum +{ + ITEM_WORKOBJINDEX, + ITEM_WORKCHARAINDEX, +#ifdef _ITEM_ORNAMENTS + ITEM_CANPICKUP, +#endif +#ifdef _ITEM_TIME_LIMIT + ITEM_WORKTIMELIMIT, +#endif + ITEM_WORKDATAINTNUM, +}ITEM_WORKDATAINT; + + + +//typedef struct tagItem +//{ +// int data[ITEM_DATAINTNUM]; +// STRING64 string[ITEM_DATACHARNUM]; +// int workint[ITEM_WORKDATAINTNUM]; +// +// void* functable[ITEM_LASTFUNCTION-ITEM_FIRSTFUNCTION]; +//}ITEM_Item; + +typedef struct tagItem +{ + int data[ITEM_DATAINTNUM]; + STRING64 string[ITEM_DATACHARNUM]; + int workint[ITEM_WORKDATAINTNUM]; + + void* functable[ITEM_LASTFUNCTION-ITEM_FIRSTFUNCTION]; +#ifdef _ALLBLUES_LUA_1_2 + lua_State *lua[ITEM_LASTFUNCTION-ITEM_FIRSTFUNCTION]; + char *luafunctable[ITEM_LASTFUNCTION-ITEM_FIRSTFUNCTION]; +#endif +#ifdef _JZ_NEWSCRIPT_LUA + STRING32 lua_charfunctable[ITEM_LASTFUNCTION-ITEM_FIRSTFUNCTION]; + + void* sur_functable[ITEM_LASTFUNCTION-ITEM_FIRSTFUNCTION]; + STRING32 sur_charfunctable[ITEM_LASTFUNCTION-ITEM_FIRSTFUNCTION]; +#endif + +}ITEM_Item; + + +typedef struct tagITEM_table +{ + int use; + ITEM_Item itm; + int randomdata[ITEM_DATAINTNUM]; +}ITEM_table; + + +typedef struct tagITEM_exists +{ + BOOL use; + ITEM_Item itm; +}ITEM_exists; + +#ifdef _PETITEM__AMOI_E +#define ITEM_NOT_LIMIT 0x00000000 // +#define ITEM_NOT_DROP 0x00000010 // +#define ITEM_NOT_STREETVANDOR 0x00000100 //ɰڵ +#define ITEM_NOT_TRADE 0x00001000 //ɽ +#define ITEM_NOT_MAIL 0x00010000 //ʼ +#endif + +#define ITEM_CHECKINDEX(index) \ + _ITEM_CHECKINDEX( __FILE__, __LINE__, index) +INLINE BOOL _ITEM_CHECKINDEX( char *file, int line, int index); + + +BOOL ITEM_initExistItemsArray( int num ); +BOOL ITEM_endExistItemsArray( void ); +#define ITEM_initExistItemsOne( itm) \ + _ITEM_initExistItemsOne( __FILE__, __LINE__, itm) +int _ITEM_initExistItemsOne( char *file, int line, ITEM_Item* itm ); + +#define ITEM_endExistItemsOne( index ) \ + _ITEM_endExistItemsOne( index, __FILE__, __LINE__) + +void _ITEM_endExistItemsOne( int index , char *file, int line); + +#define ITEM_getInt( Index, element) _ITEM_getInt( __FILE__, __LINE__, Index, element ) +INLINE int _ITEM_getInt( char *file, int line, int index ,ITEM_DATAINT element); + + +#define ITEM_setInt( Index, element, data) _ITEM_setInt( __FILE__, __LINE__, Index, element, data) +INLINE int _ITEM_setInt( char *file, int line, int index ,ITEM_DATAINT element, int data); + + +INLINE char* ITEM_getChar( int index ,ITEM_DATACHAR element ); +INLINE BOOL ITEM_setChar( int index ,ITEM_DATACHAR element , char* new); + +INLINE int ITEM_getWorkInt( int index ,ITEM_WORKDATAINT element); +INLINE int ITEM_setWorkInt( int index ,ITEM_WORKDATAINT element, int data); +INLINE int ITEM_getITEM_itemnum( void ); +INLINE int ITEM_getITEM_UseItemnum( void ); +INLINE BOOL ITEM_getITEM_use( int index ); +void ITEM_constructFunctable( int itemindex ); +void* ITEM_getFunctionPointer( int itemindex, int functype ); +#ifdef _ALLBLUES_LUA_1_2 +typedef struct tagITEM_LuaFunc +{ + lua_State *lua; + char luafuncname[128]; + char luafunctable[128]; + struct tagITEM_LuaFunc *next; +}ITEM_LuaFunc; + + +INLINE BOOL ITEM_setLUAFunction( int itemindex, int functype, const char *luafuncname); +INLINE lua_State *ITEM_getLUAFunction( int itemindex, int functype); + +BOOL ITEM_addLUAListFunction( lua_State *L, const char *luafuncname, const char *luafunctable ); +#endif +INLINE ITEM_Item *ITEM_getItemPointer( int index ); +int ITEM_getItemMaxIdNum( void); + + + +char* ITEM_makeStringFromItemData( ITEM_Item* one, int mode ); +char* ITEM_makeStringFromItemIndex( int index, int mode ); + +BOOL ITEM_makeExistItemsFromStringToArg( char* src , ITEM_Item* item, int mode ); +void ITEM_getDefaultItemSetting( ITEM_Item* itm); + + +INLINE BOOL ITEM_CHECKITEMTABLE( int number ); +BOOL ITEM_readItemConfFile( char* filename ); + + +CHAR_EquipPlace ITEM_getEquipPlace( int charaindex, int itmid ); + + +char* ITEM_makeItemStatusString( int haveitemindex, int itemindex ); +char* ITEM_makeItemFalseString( void ); +char* ITEM_makeItemFalseStringWithNum( int haveitemindex ); + + +BOOL ITEM_makeItem( ITEM_Item* itm, int number ); +int ITEM_makeItemAndRegist( int number ); + + +void ITEM_equipEffect( int index ); + +void Other_DefcharWorkInt( int index); + +char* ITEM_getAppropriateName(int itemindex); +char* ITEM_getEffectString( int itemindex ); + + +int ITEM_getcostFromITEMtabl( int itemid ); + +#define ITEM_getNameFromNumber( id) _ITEM_getNameFromNumber( __FILE__, __LINE__, id) +INLINE char* _ITEM_getNameFromNumber( char *file, int line, int itemid ); + + +int ITEM_getlevelFromITEMtabl( int itemid ); +int ITEM_getgraNoFromITEMtabl( int itemid ); +char *ITEM_getItemInfoFromNumber( int itemid ); + +int ITEM_getdropatlogoutFromITEMtabl( int itemid ); +int ITEM_getvanishatdropFromITEMtabl( int itemid ); +int ITEM_getcanpetmailFromITEMtabl( int itemid ); +int ITEM_getmergeItemFromFromITEMtabl( int itemid ); + +#ifdef _ITEM_CHECKWARES +BOOL CHAR_CheckInItemForWares( int charaindex, int flg); +#endif + +BOOL ITEM_canuseMagic( int itemindex); +// Nuke +1 08/23 : For checking the validity of item target +int ITEM_isTargetValid( int charaindex, int itemindex, int toindex); + +int ITEMTBL_getInt( int ItemID, ITEM_DATAINT datatype); +char *ITEMTBL_getChar( int ItemID, ITEM_DATACHAR datatype); + +int ITEM_getItemDamageCrusheED( int itemindex); +void ITEM_RsetEquit( int charaindex);//Զжװλô֮Ʒ +void ITEM_reChangeItemToPile( int itemindex); +void ITEM_reChangeItemName( int itemindex); + +#ifdef _SIMPLIFY_ITEMSTRING +void ITEM_getDefaultItemData( int itemID, ITEM_Item* itm); +#endif + +#ifdef _PET_ITEM +char* ITEM_petmakeItemStatusString( int petindex, int itemid ); +#endif + +#endif diff --git a/include/item_event.h b/include/item_event.h new file mode 100644 index 0000000..f0f7185 --- /dev/null +++ b/include/item_event.h @@ -0,0 +1,342 @@ +#ifndef __ITEM_EVENT_H__ +#define __ITEM_EVENT_H__ +#include "item.h" +int ITEM_eventDrop( int itemindex, int charaindex, int itemcharaindex ); +BOOL ITEM_MedicineInit( ITEM_Item* itm ); +void ITEM_MedicineUsed( int charaindex, int to_charaindex, int itemindex ); +void ITEM_SandClockDetach( int charindex , int itemindex ); +void ITEM_SandClockLogin( int charaindex ); +void ITEM_SandClockLogout( int charaindex ); +void ITEM_chantMagicAttack( int charaindex, int itemindex, int toindex, float* damage ); +void ITEM_addTitleAttach( int charaindex, int itemindex ); +void ITEM_delTitleDetach( int charaindex, int itemindex ); +void ITEM_DeleteByWatched( int myobjindex, int moveobjindex, CHAR_ACTION act, + int x, int y, int dir, int* opt, int optlen ); +void ITEM_DeleteTimeWatched( int myobjindex, int moveobjindex, CHAR_ACTION act, + int x, int y, int dir, int* opt, int optlen ); +void ITEM_useEffectTohelos( int charaindex, int to_charaindex, int haveitemindex); +void ITEM_useRecovery( int charaindex, int toindex, int haveitemindex); + +void ITEM_useStatusChange( int charaindex, int toindex, int haveitemindex); +void ITEM_useMagicDef( int charaindex, int toindex, int haveitemindex); +void ITEM_useParamChange( int charaindex, int toindex, int haveitemindex); +void ITEM_useFieldChange( int charaindex, int toindex, int haveitemindex); +void ITEM_useAttReverse( int charaindex, int toindex, int haveitemindex); +void ITEM_useStatusRecovery( int charaindex, int toindex, int haveitemindex); +void ITEM_useRessurect( int charaindex, int toindex, int haveitemindex); +void ITEM_useMic( int charaindex, int to_charaindex, int haveitemindex ); +void ITEM_dropMic( int charaindex, int itemindex ); +void ITEM_useCaptureUp( int charaindex, int toindex, int haveitemindex); +void ITEM_useRenameItem( int charaindex, int toindex, int haveitemindex); +void ITEM_useRenameItem_WindowResult( int charaindex, int seqno, int select, char *data); +void ITEM_dropDice( int charaindex, int itemindex); +void ITEM_pickupDice( int charaindex, int itemindex); +void ITEM_useLottery( int charaindex, int toindex, int haveitemindex); +void ITEM_useWarp( int charaindex, int toindex, int haveitemindex ); +void ITEM_petFollow( int charaindex, int toindex, int haveitemindex ); +BOOL ITEM_initLottery(ITEM_Item* itm); +void ITEM_useSkup( int charaindex, int toindex, int haveitemindex ); // Nuke 0624 +void ITEM_useNoenemy( int charaindex, int toindex, int haveitemindex ); // Nuke 0626 +void ITEM_equipNoenemy( int charaindex, int itemindex ); // Arminius 7.2: Ra's amulet +void ITEM_remNoenemy( int charaindex, int itemindex ); // Arminius 7.2: Ra's amulet +BOOL ITEM_getArgument( char* argument , char* entryname , char* buf , int buflen ); // Arminius 7.2: Ra's amulet +void ITEM_useEncounter( int charaindex, int toindex, int haveitemindex); // Arminius 7.31 cursed stone +#ifdef _ITEM_METAMO +void ITEM_metamo( int charaindex, int toindex, int haveitemindex ); +void ITEM_ColorMetamo( int charaindex, int toindex, int haveitemindex); +void ITEM_CharaMetamo( int charaindex, int toindex, int haveitemindex); +void ITEM_SexMetamo( int charaindex, int toindex, int haveitemindex); +#endif +#ifdef _ITEM_CRACKER +void ITEM_Cracker(int charaindex,int toindex,int haveitemindex); +#endif +#ifdef _ITEM_ADDEXP //vincent +void ITEM_Addexp(int charaindex,int toindex,int haveitemindex); +#endif +#ifdef _ITEM_REFRESH //vincent 쳣״̬ +void ITEM_Refresh(int charaindex,int toindex,int haveitemindex); +#endif +//Terry 2001/12/21 +#ifdef _ITEM_FIRECRACKER +void ITEM_firecracker(int charaindex,int toindex,int haveitemindex); +#endif +//Terry end + +#ifdef _PET_LIMITLEVEL +void ITEM_useOtherEditBase( int charaindex, int toindex, int haveitemindex); +#endif + +#ifdef _ITEM_EDITBASES +void ITEM_useFusionEditBase( int charaindex, int toindex, int haveitemindex); +#endif + +void ITEM_WearEquip( int charaindex, int itemindex); +void ITEM_ReWearEquip( int charaindex, int itemindex); + + +#ifdef _ITEM_CONSTITUTION +void ITEM_Constitution( int charaindex, int toindex, int haveitemindex); +#endif + +#ifdef _Item_ReLifeAct +void ITEM_DIErelife( int charaindex, int itemindex, int eqw ); +#endif + +#ifdef _Item_MoonAct +void ITEM_randEnemyEquipOne( int charaindex, int toindex, int haveitemindex); +void ITEM_randEnemyEquip( int charaindex, int itemindex); +void ITEM_RerandEnemyEquip( int charaindex, int itemindex); +#endif + +#ifdef _ITEM_ORNAMENTS +void ITEM_PutOrnaments( int charaindex, int itemindex); +#endif + +#ifdef _CHIKULA_STONE +void ITEM_ChikulaStone( int charaindex, int toindex, int haveitemindex); +#endif + +#ifdef _SUIT_ITEM +void ITEM_suitEquip( int charaindex, int itemindex); +void ITEM_ResuitEquip( int charaindex, int itemindex); +#endif + +#ifdef _EQUIT_DEFMAGIC +void ITEM_MagicEquitWear( int charaindex, int itemindex); +void ITEM_MagicEquitReWear( int charaindex, int itemindex); +#endif + +#ifdef _EQUIT_RESIST +void ITEM_MagicResist( int charaindex, int itemindex); +void ITEM_MagicReResist( int charaindex, int itemindex); +#endif + +#ifdef _MAGIC_RESIST_EQUIT // WON ADD ְҵװ +void ITEM_P_MagicEquitWear( int charaindex, int itemindex ); +void ITEM_P_MagicEquitReWear( int charaindex, int itemindex ); +#endif + + +#ifdef _Item_DeathAct +void ITEM_UseDeathCounter( int charaindex, int toindex, int haveitemindex); +#endif + +#ifdef _FEV_ADD_NEW_ITEM // FEV ADD Ӹؾ +void ITEM_ResAndDef( int charaindex, int toindex, int haveitemindex ); +#endif + +#ifdef _CHRISTMAS_REDSOCKS +void ITEM_useMaxRedSocks( int charaindex, int toindex, int haveitemindex); +#endif + +#ifdef _CHRISTMAS_REDSOCKS_NEW +void ITEM_useMaxRedSocksNew( int charaindex, int toindex, int haveitemindex); +#endif + +#ifdef _PETSKILL_CANNEDFOOD +void ITEM_useSkillCanned( int charaindex, int toindex, int itemNo); +#endif + +#ifdef _NEW_RIDEPETS +void ITEM_useLearnRideCode( int charaindex, int toindex, int haveitemindex); +#endif + +#ifdef _ITEM_WARP_FIX_BI +void recoverbi(int index); +#endif + +#ifdef _ITEM_TIME_LIMIT +void ITEM_TimeLimit( int charaindex); +#endif + +#ifdef _USEWARP_FORNUM +void ITEM_useWarpForNum( int charaindex, int toindex, int haveitemindex ); +#endif + +#ifdef _IMPRECATE_ITEM +void ITEM_useImprecate( int charaindex, int toNo, int haveitemindex ); +#endif + +#ifdef _THROWITEM_ITEMS +void ITEM_ThrowItemBox( int charaindex, int toindex, int haveitemindex); +#endif + +#ifdef _ITEM_WATERWORDSTATUS +void ITEM_WaterWordStatus( int charaindex, int toindex, int haveitemindex); +#endif + +#ifdef _ITEM_LOVERPARTY +void ITEM_LoverSelectUser( int charaindex, int toindex, int haveitemindex); +#endif + +#ifdef _ITEM_MAGICRECOVERY +void ITEM_useMRecovery( int charaindex, int toindex, int haveitemindex); +#endif + +#ifdef _ITEM_USEMAGIC +void ITEM_useMagic( int charaindex, int toindex, int haveitemindex); +#endif + +#ifdef _PETSKILL_CANNEDFOOD +void ITEM_usePetSkillCanned_WindowResult( int charaindex, int seqno, int select, char *data); +#endif + +void ITEM_AddPRSkillPoint(int charaindex,int toindex,int haveitemindex); +void ITEM_AddPRSkillPercent( int charaindex,int toindex,int haveitemindex); + +#ifdef _ANGEL_SUMMON +void ITEM_AngelToken( int charaindex, int toindex, int haveitemindex ); +void ITEM_HeroToken( int charaindex, int toindex, int haveitemindex ); +#endif +#ifdef _HALLOWEEN_EFFECT +void ITEM_MapEffect(int charaindex,int toindex,int haveitemindex); +#endif +void ITEM_changePetOwner( int charaindex, int toindex, int haveitemindex); + +#ifdef _TIME_TICKET +void ITEM_timeticket( int charaindex, int toindex, int haveitemindex); +#endif + +#ifdef _ITEM_SETLOVER +void ITEM_SetLoverUser( int charaindex, int toindex, int haveitemindex); +void ITEM_LoverWarp( int charaindex, int toindex, int haveitemindex); +void ITEM_LoverUnmarry( int charaindex, int toindex, int haveitemindex); +void ITEM_LoverForceUnmarry( int charaindex, int toindex, int haveitemindex); //ǿ +#endif + +#ifdef _GM_ITEM +void ITEM_GMFUNCTION( int charaindex, int toindex, int haveitemindex); +#endif + +#ifdef _VIP_SERVER +void ITEM_AddMemberPoint( int charaindex, int toindex, int haveitemindex); +#endif +#ifdef _VIP_RIDE +void ITEM_VipRide( int charaindex, int toindex, int haveitemindex); +#endif +#ifdef _NEW_NAME //Զƺ +void ITEM_NewName( int charaindex, int toindex, int haveitemindex); +#endif +#ifdef _VIP_SERVER +void ITEM_AddVipPoint( int charaindex, int toindex, int haveitemindex); +#endif +#ifdef _FM_ITEM +void ITEM_AddFame( int charaindex, int toindex, int haveitemindex); +#endif +#ifdef _LUCK_ITEM +void ITEM_Luck( int charaindex, int toindex, int haveitemindex); +#endif +#ifdef _ITEM_METAMO_TIME +void ITEM_MetamoTime( int charaindex, int toindex, int haveitemindex ); +#endif +#ifdef _ITEM_GOLD +void ITEM_Gold( int charaindex, int toindex, int haveitemindex); +#endif +#ifdef _MYSTERIOUS_GIFT +void ITEM_MysteriousGift( int charaindex, int toindex, int haveitemindex); +#endif +#ifdef _BATTLE_PK +void ITEM_BattlePK( int charaindex, int toindex, int haveitemindex); +#endif +#ifdef _SILENTZERO +void ITEM_SetSilentZero( int charaindex, int toindex, int haveitemindex); +#endif +#ifdef _PET_LEVEL_ITEM +void ITEM_PetLevelItem( int charaindex, int toindex, int haveitemindex); +#endif +#ifdef _ITEM_EFMETAMO +void ITEM_efMetamo( int charaindex, int toindex, int haveitemindex); +#endif +#ifdef _PET_BEATITUDE +void PET_BEATITUDE( int charaindex, int toindex, int haveitemindex); +#endif +#ifdef _GET_MULTI_ITEM +void ITEM_GetMultiItem( int charaindex, int toindex, int haveitemindex); +#endif +void ITEM_OldToNew( int charaindex, int toindex, int haveitemindex); +#ifdef _SAFE_PASSWORD +void ITEM_ItemPetLocked( int charaindex, int toindex, int haveitemindex); +#endif +#ifdef _POINT_CARD +void ITEM_OnlineCost( int charaindex, int toindex, int haveitemindex); +#endif +#ifdef _SUPER_MAN_ITEM +void ITEM_SuperManItem( int charaindex, int toindex, int haveitemindex); +#endif +void ITEM_CharSave( int charaindex, int toindex, int haveitemindex); +void ITEM_NoDelWarp( int charaindex, int toindex, int haveitemindex ); +void ITEM_RandWarp( int charaindex, int toindex, int haveitemindex); +void ITEM_RandMsg( int charaindex, int toindex, int haveitemindex); +#ifdef _SQL_BUY_FUNC +void ITEM_OnlineBuy_recv( int charaindex, int toindex, int haveitemindex); +#endif +#ifdef _JOB_AUTOPK +void ITEM_JobPk( int charaindex, int toindex, int haveitemindex); +#endif +void ITEM_SeeEquip( int charaindex, int toindex, int haveitemindex); +#ifdef _VIGOR_SYS +void ITEM_VigorSave( int charaindex, int toindex, int haveitemindex); +#endif +#ifdef _EV_NUM +void ITEM_EvItem( int charaindex, int toindex, int haveitemindex); +#endif +#ifdef _OFFLINE_SYSTEM +void ITEM_OFFLINE( int charaindex, int toindex, int haveitemindex); +#endif +void ITEM_AddProfessionLevel( int charaindex, int toindex, int haveitemindex); +#ifdef _ZHIPIAO_SYSTEM +void ITEM_ZhiPiao( int charaindex, int toindex, int haveitemindex); +#endif +#ifdef _ALL_RANDMODE +void ITEM_useRandEditBase( int charaindex, int toindex, int haveitemindex); +#endif +#ifdef _DP_ZHIPIAO_ITEM +void ITEM_DpZhiPiao( int charaindex, int toindex, int haveitemindex); +#endif +void ITEM_UpPointResetItem( int charaindex, int toindex, int haveitemindex); +void ITEM_MM( int charaindex, int toindex, int haveitemindex); +#ifdef _XC_CANGKU +void ITEM_ICK( int charaindex, int toindex, int haveitemindex); +void ITEM_PCK( int charaindex, int toindex, int haveitemindex); +#endif + +void ITEM_MakePet( int charaindex, int toindex, int haveitemindex); +void PET_OTHERBEATITUDE( int charaindex, int toindex, int haveitemindex); +void PET_MYBEATITUDE( int charaindex, int toindex, int haveitemindex); +void ITEM_useDelRenameItem( int charaindex, int toindex, int haveitemindex); +void ITEM_DANMM( int charaindex, int toindex, int haveitemindex); +void ITEM_ExpLvBase( int charaindex, int exp); +void ITEM_useExpLv( int charaindex, int toindex, int haveitemindex); +enum{ + BD_KIND_HP, + BD_KIND_MP, + BD_KIND_CHARM, + BD_KIND_AI, + BD_KIND_CURSE, + BD_KIND_BESTOW, + BD_KIND_WISHES, +#ifdef _ITEM_UNBECOMEPIG + BD_KIND_UNBECOMEPIG, +#endif +#ifdef _ITEM_PROPERTY + BD_KIND_PROPERTY, +#endif + BD_KIND_END +}; +#ifdef _ITEM_LUA +void ITEM_Lua(int charaindex, int toindex, int haveitemindex); +#endif + +#ifdef _SPECIAL_SUIT +void ITEM_SpecialSuitEquip( int charaindex, int itemindex); +void ITEM_SpecialResuitEquip( int charaindex, int itemindex); +#endif +#ifdef _MANOR_EQUIP +void ITEM_ManorEquip( int charaindex, int itemindex); +void ITEM_ReManorEquip( int charaindex, int itemindex); +#endif +#ifdef _NULL_CHECK_ITEM +void ITEM_NullCheck( int charaindex, int toindex, int haveitemindex); +#endif +#endif + diff --git a/include/item_gen.h b/include/item_gen.h new file mode 100644 index 0000000..7174c87 --- /dev/null +++ b/include/item_gen.h @@ -0,0 +1,22 @@ +#ifndef __ITEM_GEN_H__ +#define __ITEM_GEN_H__ + + +int ITEM_initItemIngCache( void ); +int ITEM_initItemAtom( char *fn ); +int ITEM_initRandTable( void); +int ITEM_mergeItem( int charaindex, ITEM_Item *items, int num , int money, int petid, int searchtable, int petindex, int alchemist); +int ITEM_canDigest( ITEM_Item *t ); +int ITEM_mergeItem_merge( int charaindex,int petid, char *data, int petindex, int alchemist); + +#ifdef _ITEM_INSLAY +int PETSKILL_ITEM_inslay( int charindex, int inslayindex, int itemindex); +#endif + +#ifdef _PETSKILL_FIXITEM +int PETSKILL_ITEM_FixItem( int charindex, int fixindex, int *itemindex); +#endif + +#endif + + diff --git a/include/item_trade.h b/include/item_trade.h new file mode 100644 index 0000000..b389cdb --- /dev/null +++ b/include/item_trade.h @@ -0,0 +1,52 @@ +#ifndef __MAPTRADE_H__ +#define __MAPTRADE_H__ +#include "char.h" + +typedef struct tagMapTrade { + int masterindex; + int x; + int y; + int Ttime; + int Goodindex; + char Goodname[256]; +}MapTrade; + +#define TRADEMAP 1090 +#define TRADEXSIZE 4 +#define TRADEYSIZE 4 + +BOOL CHECKMAP_TRADE( int charindex, int floor, int x, int y); +int CHECKMAP_TRADEXY( int charindex, int floor, int x, int y); +BOOL MAP_TRADEDROP( int charindex, int itemindex,int floor, int x, int y); +BOOL MAP_TRADEPICKUP( int charindex, int itemindex, int floor, int x, int y, int flg); + +void InitMapTradeData( int index, int Stime); + +int TRADE_getMasterInt( int index); +int TRADE_getTimeInt( int index); +BOOL TRADE_setMasterInt( int index, int Num); +BOOL TRADE_setTimeInt( int index, int Num); +int TRADE_AddMasrerTrade( int toindex); //趨̯λ +int TRADE_getMaxNumInt(); +void MAPTRADE_CLEANGOLD( int floor, int num); +BOOL MAPTRADE_CHECKMASTERIN( int masterindex , int toindex, int num); +BOOL MAPTRADE_CHECKMAPFULL(int fl, int x, int y); +BOOL MAP_TRADEPETDROP( int charindex, int petindex,int floor, int x, int y); +int MAPTRADE_getItemSpace( int meindex, int itemindex); +int MAPTRADE_getPetSpace( int masterindex, int petindex); + +int MAPTRADE_getSellIndex( int index); +BOOL MAPTRADE_setSellIndex( int index, int num); +void MAPTRADE_setCharSellName( int index, char *buf); +char* MAPTRADE_getCharSellName( int index ); + +#define TRADESTARTNUM 1 +#define TRADETYPE_SELL (1<<3) +#define TRADEITEMID 0 +#define TRADEPETID 0 +#define TRADEPETUPLV ((1<<24)+(1<<16)+(1<<8)+1) +#define TRADEPETTYPE (1<<4) +#define TRADEITEMTYPE (1<<8) +#endif + + diff --git a/include/lapi.h b/include/lapi.h new file mode 100644 index 0000000..2c3fab2 --- /dev/null +++ b/include/lapi.h @@ -0,0 +1,16 @@ +/* +** $Id: lapi.h,v 2.2.1.1 2007/12/27 13:02:25 roberto Exp $ +** Auxiliary functions from Lua API +** See Copyright Notice in lua.h +*/ + +#ifndef lapi_h +#define lapi_h + + +#include "lobject.h" + + +LUAI_FUNC void luaA_pushobject (lua_State *L, const TValue *o); + +#endif diff --git a/include/lauxlib.h b/include/lauxlib.h new file mode 100644 index 0000000..3f17c2f --- /dev/null +++ b/include/lauxlib.h @@ -0,0 +1,174 @@ +/* +** $Id: lauxlib.h,v 1.88.1.1 2007/12/27 13:02:25 roberto Exp $ +** Auxiliary functions for building Lua libraries +** See Copyright Notice in lua.h +*/ + + +#ifndef lauxlib_h +#define lauxlib_h + + +#include +#include + +#include "lua.h" + + +#if defined(LUA_COMPAT_GETN) +LUALIB_API int (luaL_getn) (lua_State *L, int t); +LUALIB_API void (luaL_setn) (lua_State *L, int t, int n); +#else +#define luaL_getn(L,i) ((int)lua_objlen(L, i)) +#define luaL_setn(L,i,j) ((void)0) /* no op! */ +#endif + +#if defined(LUA_COMPAT_OPENLIB) +#define luaI_openlib luaL_openlib +#endif + + +/* extra error code for `luaL_load' */ +#define LUA_ERRFILE (LUA_ERRERR+1) + + +typedef struct luaL_Reg { + const char *name; + lua_CFunction func; +} luaL_Reg; + + + +LUALIB_API void (luaI_openlib) (lua_State *L, const char *libname, + const luaL_Reg *l, int nup); +LUALIB_API void (luaL_register) (lua_State *L, const char *libname, + const luaL_Reg *l); +LUALIB_API int (luaL_getmetafield) (lua_State *L, int obj, const char *e); +LUALIB_API int (luaL_callmeta) (lua_State *L, int obj, const char *e); +LUALIB_API int (luaL_typerror) (lua_State *L, int narg, const char *tname); +LUALIB_API int (luaL_argerror) (lua_State *L, int numarg, const char *extramsg); +LUALIB_API char *(luaL_checklstring) (lua_State *L, int numArg, + size_t *l); +LUALIB_API const char *(luaL_optlstring) (lua_State *L, int numArg, + const char *def, size_t *l); +LUALIB_API lua_Number (luaL_checknumber) (lua_State *L, int numArg); +LUALIB_API lua_Number (luaL_optnumber) (lua_State *L, int nArg, lua_Number def); + +LUALIB_API lua_Integer (luaL_checkinteger) (lua_State *L, int numArg); +LUALIB_API lua_Integer (luaL_optinteger) (lua_State *L, int nArg, + lua_Integer def); + +LUALIB_API void (luaL_checkstack) (lua_State *L, int sz, const char *msg); +LUALIB_API void (luaL_checktype) (lua_State *L, int narg, int t); +LUALIB_API void (luaL_checkany) (lua_State *L, int narg); + +LUALIB_API int (luaL_newmetatable) (lua_State *L, const char *tname); +LUALIB_API void *(luaL_checkudata) (lua_State *L, int ud, const char *tname); + +LUALIB_API void (luaL_where) (lua_State *L, int lvl); +LUALIB_API int (luaL_error) (lua_State *L, const char *fmt, ...); + +LUALIB_API int (luaL_checkoption) (lua_State *L, int narg, const char *def, + const char *const lst[]); + +LUALIB_API int (luaL_ref) (lua_State *L, int t); +LUALIB_API void (luaL_unref) (lua_State *L, int t, int ref); + +LUALIB_API int (luaL_loadfile) (lua_State *L, const char *filename); +LUALIB_API int (luaL_loadbuffer) (lua_State *L, const char *buff, size_t sz, + const char *name); +LUALIB_API int (luaL_loadstring) (lua_State *L, const char *s); + +LUALIB_API lua_State *(luaL_newstate) (void); + + +LUALIB_API const char *(luaL_gsub) (lua_State *L, const char *s, const char *p, + const char *r); + +LUALIB_API const char *(luaL_findtable) (lua_State *L, int idx, + const char *fname, int szhint); + + + + +/* +** =============================================================== +** some useful macros +** =============================================================== +*/ + +#define luaL_argcheck(L, cond,numarg,extramsg) \ + ((void)((cond) || luaL_argerror(L, (numarg), (extramsg)))) +#define luaL_checkstring(L,n) (luaL_checklstring(L, (n), NULL)) +#define luaL_optstring(L,n,d) (luaL_optlstring(L, (n), (d), NULL)) +#define luaL_checkint(L,n) ((int)luaL_checkinteger(L, (n))) +#define luaL_optint(L,n,d) ((int)luaL_optinteger(L, (n), (d))) +#define luaL_checklong(L,n) ((long)luaL_checkinteger(L, (n))) +#define luaL_optlong(L,n,d) ((long)luaL_optinteger(L, (n), (d))) + +#define luaL_typename(L,i) lua_typename(L, lua_type(L,(i))) + +#define luaL_dofile(L, fn) \ + (luaL_loadfile(L, fn) || lua_pcall(L, 0, LUA_MULTRET, 0)) + +#define luaL_dostring(L, s) \ + (luaL_loadstring(L, s) || lua_pcall(L, 0, LUA_MULTRET, 0)) + +#define luaL_getmetatable(L,n) (lua_getfield(L, LUA_REGISTRYINDEX, (n))) + +#define luaL_opt(L,f,n,d) (lua_isnoneornil(L,(n)) ? (d) : f(L,(n))) + +/* +** {====================================================== +** Generic Buffer manipulation +** ======================================================= +*/ + + + +typedef struct luaL_Buffer { + char *p; /* current position in buffer */ + int lvl; /* number of strings in the stack (level) */ + lua_State *L; + char buffer[LUAL_BUFFERSIZE]; +} luaL_Buffer; + +#define luaL_addchar(B,c) \ + ((void)((B)->p < ((B)->buffer+LUAL_BUFFERSIZE) || luaL_prepbuffer(B)), \ + (*(B)->p++ = (char)(c))) + +/* compatibility only */ +#define luaL_putchar(B,c) luaL_addchar(B,c) + +#define luaL_addsize(B,n) ((B)->p += (n)) + +LUALIB_API void (luaL_buffinit) (lua_State *L, luaL_Buffer *B); +LUALIB_API char *(luaL_prepbuffer) (luaL_Buffer *B); +LUALIB_API void (luaL_addlstring) (luaL_Buffer *B, const char *s, size_t l); +LUALIB_API void (luaL_addstring) (luaL_Buffer *B, const char *s); +LUALIB_API void (luaL_addvalue) (luaL_Buffer *B); +LUALIB_API void (luaL_pushresult) (luaL_Buffer *B); + + +/* }====================================================== */ + + +/* compatibility with ref system */ + +/* pre-defined references */ +#define LUA_NOREF (-2) +#define LUA_REFNIL (-1) + +#define lua_ref(L,lock) ((lock) ? luaL_ref(L, LUA_REGISTRYINDEX) : \ + (lua_pushstring(L, "unlocked references are obsolete"), lua_error(L), 0)) + +#define lua_unref(L,ref) luaL_unref(L, LUA_REGISTRYINDEX, (ref)) + +#define lua_getref(L,ref) lua_rawgeti(L, LUA_REGISTRYINDEX, (ref)) + + +#define luaL_reg luaL_Reg + +#endif + + diff --git a/include/lcode.h b/include/lcode.h new file mode 100644 index 0000000..b941c60 --- /dev/null +++ b/include/lcode.h @@ -0,0 +1,76 @@ +/* +** $Id: lcode.h,v 1.48.1.1 2007/12/27 13:02:25 roberto Exp $ +** Code generator for Lua +** See Copyright Notice in lua.h +*/ + +#ifndef lcode_h +#define lcode_h + +#include "llex.h" +#include "lobject.h" +#include "lopcodes.h" +#include "lparser.h" + + +/* +** Marks the end of a patch list. It is an invalid value both as an absolute +** address, and as a list link (would link an element to itself). +*/ +#define NO_JUMP (-1) + + +/* +** grep "ORDER OPR" if you change these enums +*/ +typedef enum BinOpr { + OPR_ADD, OPR_SUB, OPR_MUL, OPR_DIV, OPR_MOD, OPR_POW, + OPR_CONCAT, + OPR_NE, OPR_EQ, + OPR_LT, OPR_LE, OPR_GT, OPR_GE, + OPR_AND, OPR_OR, + OPR_NOBINOPR +} BinOpr; + + +typedef enum UnOpr { OPR_MINUS, OPR_NOT, OPR_LEN, OPR_NOUNOPR } UnOpr; + + +#define getcode(fs,e) ((fs)->f->code[(e)->u.s.info]) + +#define luaK_codeAsBx(fs,o,A,sBx) luaK_codeABx(fs,o,A,(sBx)+MAXARG_sBx) + +#define luaK_setmultret(fs,e) luaK_setreturns(fs, e, LUA_MULTRET) + +LUAI_FUNC int luaK_codeABx (FuncState *fs, OpCode o, int A, unsigned int Bx); +LUAI_FUNC int luaK_codeABC (FuncState *fs, OpCode o, int A, int B, int C); +LUAI_FUNC void luaK_fixline (FuncState *fs, int line); +LUAI_FUNC void luaK_nil (FuncState *fs, int from, int n); +LUAI_FUNC void luaK_reserveregs (FuncState *fs, int n); +LUAI_FUNC void luaK_checkstack (FuncState *fs, int n); +LUAI_FUNC int luaK_stringK (FuncState *fs, TString *s); +LUAI_FUNC int luaK_numberK (FuncState *fs, lua_Number r); +LUAI_FUNC void luaK_dischargevars (FuncState *fs, expdesc *e); +LUAI_FUNC int luaK_exp2anyreg (FuncState *fs, expdesc *e); +LUAI_FUNC void luaK_exp2nextreg (FuncState *fs, expdesc *e); +LUAI_FUNC void luaK_exp2val (FuncState *fs, expdesc *e); +LUAI_FUNC int luaK_exp2RK (FuncState *fs, expdesc *e); +LUAI_FUNC void luaK_self (FuncState *fs, expdesc *e, expdesc *key); +LUAI_FUNC void luaK_indexed (FuncState *fs, expdesc *t, expdesc *k); +LUAI_FUNC void luaK_goiftrue (FuncState *fs, expdesc *e); +LUAI_FUNC void luaK_storevar (FuncState *fs, expdesc *var, expdesc *e); +LUAI_FUNC void luaK_setreturns (FuncState *fs, expdesc *e, int nresults); +LUAI_FUNC void luaK_setoneret (FuncState *fs, expdesc *e); +LUAI_FUNC int luaK_jump (FuncState *fs); +LUAI_FUNC void luaK_ret (FuncState *fs, int first, int nret); +LUAI_FUNC void luaK_patchlist (FuncState *fs, int list, int target); +LUAI_FUNC void luaK_patchtohere (FuncState *fs, int list); +LUAI_FUNC void luaK_concat (FuncState *fs, int *l1, int l2); +LUAI_FUNC int luaK_getlabel (FuncState *fs); +LUAI_FUNC void luaK_prefix (FuncState *fs, UnOpr op, expdesc *v); +LUAI_FUNC void luaK_infix (FuncState *fs, BinOpr op, expdesc *v); +LUAI_FUNC void luaK_posfix (FuncState *fs, BinOpr op, expdesc *v1, expdesc *v2); +LUAI_FUNC void luaK_setlist (FuncState *fs, int base, int nelems, int tostore); + + +#endif diff --git a/include/ldebug.h b/include/ldebug.h new file mode 100644 index 0000000..ba28a97 --- /dev/null +++ b/include/ldebug.h @@ -0,0 +1,33 @@ +/* +** $Id: ldebug.h,v 2.3.1.1 2007/12/27 13:02:25 roberto Exp $ +** Auxiliary functions from Debug Interface module +** See Copyright Notice in lua.h +*/ + +#ifndef ldebug_h +#define ldebug_h + + +#include "lstate.h" + + +#define pcRel(pc, p) (cast(int, (pc) - (p)->code) - 1) + +#define getline(f,pc) (((f)->lineinfo) ? (f)->lineinfo[pc] : 0) + +#define resethookcount(L) (L->hookcount = L->basehookcount) + + +LUAI_FUNC void luaG_typeerror (lua_State *L, const TValue *o, + const char *opname); +LUAI_FUNC void luaG_concaterror (lua_State *L, StkId p1, StkId p2); +LUAI_FUNC void luaG_aritherror (lua_State *L, const TValue *p1, + const TValue *p2); +LUAI_FUNC int luaG_ordererror (lua_State *L, const TValue *p1, + const TValue *p2); +LUAI_FUNC void luaG_runerror (lua_State *L, const char *fmt, ...); +LUAI_FUNC void luaG_errormsg (lua_State *L); +LUAI_FUNC int luaG_checkcode (const Proto *pt); +LUAI_FUNC int luaG_checkopenop (Instruction i); + +#endif diff --git a/include/ldo.h b/include/ldo.h new file mode 100644 index 0000000..98fddac --- /dev/null +++ b/include/ldo.h @@ -0,0 +1,57 @@ +/* +** $Id: ldo.h,v 2.7.1.1 2007/12/27 13:02:25 roberto Exp $ +** Stack and Call structure of Lua +** See Copyright Notice in lua.h +*/ + +#ifndef ldo_h +#define ldo_h + + +#include "lobject.h" +#include "lstate.h" +#include "lzio.h" + + +#define luaD_checkstack(L,n) \ + if ((char *)L->stack_last - (char *)L->top <= (n)*(int)sizeof(TValue)) \ + luaD_growstack(L, n); \ + else condhardstacktests(luaD_reallocstack(L, L->stacksize - EXTRA_STACK - 1)); + + +#define incr_top(L) {luaD_checkstack(L,1); L->top++;} + +#define savestack(L,p) ((char *)(p) - (char *)L->stack) +#define restorestack(L,n) ((TValue *)((char *)L->stack + (n))) + +#define saveci(L,p) ((char *)(p) - (char *)L->base_ci) +#define restoreci(L,n) ((CallInfo *)((char *)L->base_ci + (n))) + + +/* results from luaD_precall */ +#define PCRLUA 0 /* initiated a call to a Lua function */ +#define PCRC 1 /* did a call to a C function */ +#define PCRYIELD 2 /* C funtion yielded */ + + +/* type of protected functions, to be ran by `runprotected' */ +typedef void (*Pfunc) (lua_State *L, void *ud); + +LUAI_FUNC int luaD_protectedparser (lua_State *L, ZIO *z, const char *name); +LUAI_FUNC void luaD_callhook (lua_State *L, int event, int line); +LUAI_FUNC int luaD_precall (lua_State *L, StkId func, int nresults); +LUAI_FUNC void luaD_call (lua_State *L, StkId func, int nResults); +LUAI_FUNC int luaD_pcall (lua_State *L, Pfunc func, void *u, + ptrdiff_t oldtop, ptrdiff_t ef); +LUAI_FUNC int luaD_poscall (lua_State *L, StkId firstResult); +LUAI_FUNC void luaD_reallocCI (lua_State *L, int newsize); +LUAI_FUNC void luaD_reallocstack (lua_State *L, int newsize); +LUAI_FUNC void luaD_growstack (lua_State *L, int n); + +LUAI_FUNC void luaD_throw (lua_State *L, int errcode); +LUAI_FUNC int luaD_rawrunprotected (lua_State *L, Pfunc f, void *ud); + +LUAI_FUNC void luaD_seterrorobj (lua_State *L, int errcode, StkId oldtop); + +#endif + diff --git a/include/levelup.h b/include/levelup.h new file mode 100644 index 0000000..eb4b161 --- /dev/null +++ b/include/levelup.h @@ -0,0 +1,17 @@ +#ifndef _LEVELUP_H +#define _LEVELUP_H + +int GetEnemyExp( int level ); + +int BATTLE_GetLevelExp( + int charaindex, + int level +); + +int BATTLE_LevelUpCheck( + int charaindex +); + + +#endif + diff --git a/include/lfunc.h b/include/lfunc.h new file mode 100644 index 0000000..a68cf51 --- /dev/null +++ b/include/lfunc.h @@ -0,0 +1,34 @@ +/* +** $Id: lfunc.h,v 2.4.1.1 2007/12/27 13:02:25 roberto Exp $ +** Auxiliary functions to manipulate prototypes and closures +** See Copyright Notice in lua.h +*/ + +#ifndef lfunc_h +#define lfunc_h + + +#include "lobject.h" + + +#define sizeCclosure(n) (cast(int, sizeof(CClosure)) + \ + cast(int, sizeof(TValue)*((n)-1))) + +#define sizeLclosure(n) (cast(int, sizeof(LClosure)) + \ + cast(int, sizeof(TValue *)*((n)-1))) + + +LUAI_FUNC Proto *luaF_newproto (lua_State *L); +LUAI_FUNC Closure *luaF_newCclosure (lua_State *L, int nelems, Table *e); +LUAI_FUNC Closure *luaF_newLclosure (lua_State *L, int nelems, Table *e); +LUAI_FUNC UpVal *luaF_newupval (lua_State *L); +LUAI_FUNC UpVal *luaF_findupval (lua_State *L, StkId level); +LUAI_FUNC void luaF_close (lua_State *L, StkId level); +LUAI_FUNC void luaF_freeproto (lua_State *L, Proto *f); +LUAI_FUNC void luaF_freeclosure (lua_State *L, Closure *c); +LUAI_FUNC void luaF_freeupval (lua_State *L, UpVal *uv); +LUAI_FUNC const char *luaF_getlocalname (const Proto *func, int local_number, + int pc); + + +#endif diff --git a/include/lgc.h b/include/lgc.h new file mode 100644 index 0000000..5a8dc60 --- /dev/null +++ b/include/lgc.h @@ -0,0 +1,110 @@ +/* +** $Id: lgc.h,v 2.15.1.1 2007/12/27 13:02:25 roberto Exp $ +** Garbage Collector +** See Copyright Notice in lua.h +*/ + +#ifndef lgc_h +#define lgc_h + + +#include "lobject.h" + + +/* +** Possible states of the Garbage Collector +*/ +#define GCSpause 0 +#define GCSpropagate 1 +#define GCSsweepstring 2 +#define GCSsweep 3 +#define GCSfinalize 4 + + +/* +** some userful bit tricks +*/ +#define resetbits(x,m) ((x) &= cast(lu_byte, ~(m))) +#define setbits(x,m) ((x) |= (m)) +#define testbits(x,m) ((x) & (m)) +#define bitmask(b) (1<<(b)) +#define bit2mask(b1,b2) (bitmask(b1) | bitmask(b2)) +#define l_setbit(x,b) setbits(x, bitmask(b)) +#define resetbit(x,b) resetbits(x, bitmask(b)) +#define testbit(x,b) testbits(x, bitmask(b)) +#define set2bits(x,b1,b2) setbits(x, (bit2mask(b1, b2))) +#define reset2bits(x,b1,b2) resetbits(x, (bit2mask(b1, b2))) +#define test2bits(x,b1,b2) testbits(x, (bit2mask(b1, b2))) + + + +/* +** Layout for bit use in `marked' field: +** bit 0 - object is white (type 0) +** bit 1 - object is white (type 1) +** bit 2 - object is black +** bit 3 - for userdata: has been finalized +** bit 3 - for tables: has weak keys +** bit 4 - for tables: has weak values +** bit 5 - object is fixed (should not be collected) +** bit 6 - object is "super" fixed (only the main thread) +*/ + + +#define WHITE0BIT 0 +#define WHITE1BIT 1 +#define BLACKBIT 2 +#define FINALIZEDBIT 3 +#define KEYWEAKBIT 3 +#define VALUEWEAKBIT 4 +#define FIXEDBIT 5 +#define SFIXEDBIT 6 +#define WHITEBITS bit2mask(WHITE0BIT, WHITE1BIT) + + +#define iswhite(x) test2bits((x)->gch.marked, WHITE0BIT, WHITE1BIT) +#define isblack(x) testbit((x)->gch.marked, BLACKBIT) +#define isgray(x) (!isblack(x) && !iswhite(x)) + +#define otherwhite(g) (g->currentwhite ^ WHITEBITS) +#define isdead(g,v) ((v)->gch.marked & otherwhite(g) & WHITEBITS) + +#define changewhite(x) ((x)->gch.marked ^= WHITEBITS) +#define gray2black(x) l_setbit((x)->gch.marked, BLACKBIT) + +#define valiswhite(x) (iscollectable(x) && iswhite(gcvalue(x))) + +#define luaC_white(g) cast(lu_byte, (g)->currentwhite & WHITEBITS) + + +#define luaC_checkGC(L) { \ + condhardstacktests(luaD_reallocstack(L, L->stacksize - EXTRA_STACK - 1)); \ + if (G(L)->totalbytes >= G(L)->GCthreshold) \ + luaC_step(L); } + + +#define luaC_barrier(L,p,v) { if (valiswhite(v) && isblack(obj2gco(p))) \ + luaC_barrierf(L,obj2gco(p),gcvalue(v)); } + +#define luaC_barriert(L,t,v) { if (valiswhite(v) && isblack(obj2gco(t))) \ + luaC_barrierback(L,t); } + +#define luaC_objbarrier(L,p,o) \ + { if (iswhite(obj2gco(o)) && isblack(obj2gco(p))) \ + luaC_barrierf(L,obj2gco(p),obj2gco(o)); } + +#define luaC_objbarriert(L,t,o) \ + { if (iswhite(obj2gco(o)) && isblack(obj2gco(t))) luaC_barrierback(L,t); } + +LUAI_FUNC size_t luaC_separateudata (lua_State *L, int all); +LUAI_FUNC void luaC_callGCTM (lua_State *L); +LUAI_FUNC void luaC_freeall (lua_State *L); +LUAI_FUNC void luaC_step (lua_State *L); +LUAI_FUNC void luaC_fullgc (lua_State *L); +LUAI_FUNC void luaC_link (lua_State *L, GCObject *o, lu_byte tt); +LUAI_FUNC void luaC_linkupval (lua_State *L, UpVal *uv); +LUAI_FUNC void luaC_barrierf (lua_State *L, GCObject *o, GCObject *v); +LUAI_FUNC void luaC_barrierback (lua_State *L, Table *t); + + +#endif diff --git a/include/link.h b/include/link.h new file mode 100644 index 0000000..f9f6ba2 --- /dev/null +++ b/include/link.h @@ -0,0 +1,22 @@ +#ifndef __LINK_H__ +#define __LINK_H__ + +#include "common.h" + +/* + * հë + * val 巴ئУ۹Ի̼ + * 浤 + */ +typedef struct tagNode +{ + struct tagNode* next; /*ݼá߼̼*/ + char* val; /* ٯ */ + int size; /*val*/ +}Node; + +BOOL Nodeappendhead( Node** top , Node* add ); +BOOL Nodeappendtail( Node** top , Node* add ); +BOOL Noderemovehead( Node** top , Node* ret); +BOOL Noderemovetail( Node** top , Node* ret); +#endif diff --git a/include/llex.h b/include/llex.h new file mode 100644 index 0000000..a9201ce --- /dev/null +++ b/include/llex.h @@ -0,0 +1,81 @@ +/* +** $Id: llex.h,v 1.58.1.1 2007/12/27 13:02:25 roberto Exp $ +** Lexical Analyzer +** See Copyright Notice in lua.h +*/ + +#ifndef llex_h +#define llex_h + +#include "lobject.h" +#include "lzio.h" + + +#define FIRST_RESERVED 257 + +/* maximum length of a reserved word */ +#define TOKEN_LEN (sizeof("function")/sizeof(char)) + + +/* +* WARNING: if you change the order of this enumeration, +* grep "ORDER RESERVED" +*/ +enum RESERVED { + /* terminal symbols denoted by reserved words */ + TK_AND = FIRST_RESERVED, TK_BREAK, + TK_DO, TK_ELSE, TK_ELSEIF, TK_END, TK_FALSE, TK_FOR, TK_FUNCTION, + TK_IF, TK_IN, TK_LOCAL, TK_NIL, TK_NOT, TK_OR, TK_REPEAT, + TK_RETURN, TK_THEN, TK_TRUE, TK_UNTIL, TK_WHILE, + /* other terminal symbols */ + TK_CONCAT, TK_DOTS, TK_EQ, TK_GE, TK_LE, TK_NE, TK_NUMBER, + TK_NAME, TK_STRING, TK_EOS +}; + +/* number of reserved words */ +#define NUM_RESERVED (cast(int, TK_WHILE-FIRST_RESERVED+1)) + + +/* array with token `names' */ +LUAI_DATA const char *const luaX_tokens []; + + +typedef union { + lua_Number r; + TString *ts; +} SemInfo; /* semantics information */ + + +typedef struct Token { + int token; + SemInfo seminfo; +} Token; + + +typedef struct LexState { + int current; /* current character (charint) */ + int linenumber; /* input line counter */ + int lastline; /* line of last token `consumed' */ + Token t; /* current token */ + Token lookahead; /* look ahead token */ + struct FuncState *fs; /* `FuncState' is private to the parser */ + struct lua_State *L; + ZIO *z; /* input stream */ + Mbuffer *buff; /* buffer for tokens */ + TString *source; /* current source name */ + char decpoint; /* locale decimal point */ +} LexState; + + +LUAI_FUNC void luaX_init (lua_State *L); +LUAI_FUNC void luaX_setinput (lua_State *L, LexState *ls, ZIO *z, + TString *source); +LUAI_FUNC TString *luaX_newstring (LexState *ls, const char *str, size_t l); +LUAI_FUNC void luaX_next (LexState *ls); +LUAI_FUNC void luaX_lookahead (LexState *ls); +LUAI_FUNC void luaX_lexerror (LexState *ls, const char *msg, int token); +LUAI_FUNC void luaX_syntaxerror (LexState *ls, const char *s); +LUAI_FUNC const char *luaX_token2str (LexState *ls, int token); + + +#endif diff --git a/include/llimits.h b/include/llimits.h new file mode 100644 index 0000000..ca8dcb7 --- /dev/null +++ b/include/llimits.h @@ -0,0 +1,128 @@ +/* +** $Id: llimits.h,v 1.69.1.1 2007/12/27 13:02:25 roberto Exp $ +** Limits, basic types, and some other `installation-dependent' definitions +** See Copyright Notice in lua.h +*/ + +#ifndef llimits_h +#define llimits_h + + +#include +#include + + +#include "lua.h" + + +typedef LUAI_UINT32 lu_int32; + +typedef LUAI_UMEM lu_mem; + +typedef LUAI_MEM l_mem; + + + +/* chars used as small naturals (so that `char' is reserved for characters) */ +typedef unsigned char lu_byte; + + +#define MAX_SIZET ((size_t)(~(size_t)0)-2) + +#define MAX_LUMEM ((lu_mem)(~(lu_mem)0)-2) + + +#define MAX_INT (INT_MAX-2) /* maximum value of an int (-2 for safety) */ + +/* +** conversion of pointer to integer +** this is for hashing only; there is no problem if the integer +** cannot hold the whole pointer value +*/ +#define IntPoint(p) ((unsigned int)(lu_mem)(p)) + + + +/* type to ensure maximum alignment */ +typedef LUAI_USER_ALIGNMENT_T L_Umaxalign; + + +/* result of a `usual argument conversion' over lua_Number */ +typedef LUAI_UACNUMBER l_uacNumber; + + +/* internal assertions for in-house debugging */ +#ifdef lua_assert + +#define check_exp(c,e) (lua_assert(c), (e)) +#define api_check(l,e) lua_assert(e) + +#else + +#define lua_assert(c) ((void)0) +#define check_exp(c,e) (e) +#define api_check luai_apicheck + +#endif + + +#ifndef UNUSED +#define UNUSED(x) ((void)(x)) /* to avoid warnings */ +#endif + + +#ifndef cast +#define cast(t, exp) ((t)(exp)) +#endif + +#define cast_byte(i) cast(lu_byte, (i)) +#define cast_num(i) cast(lua_Number, (i)) +#define cast_int(i) cast(int, (i)) + + + +/* +** type for virtual-machine instructions +** must be an unsigned with (at least) 4 bytes (see details in lopcodes.h) +*/ +typedef lu_int32 Instruction; + + + +/* maximum stack for a Lua function */ +#define MAXSTACK 250 + + + +/* minimum size for the string table (must be power of 2) */ +#ifndef MINSTRTABSIZE +#define MINSTRTABSIZE 32 +#endif + + +/* minimum size for string buffer */ +#ifndef LUA_MINBUFFER +#define LUA_MINBUFFER 32 +#endif + + +#ifndef lua_lock +#define lua_lock(L) ((void) 0) +#define lua_unlock(L) ((void) 0) +#endif + +#ifndef luai_threadyield +#define luai_threadyield(L) {lua_unlock(L); lua_lock(L);} +#endif + + +/* +** macro to control inclusion of some hard tests on stack reallocation +*/ +#ifndef HARDSTACKTESTS +#define condhardstacktests(x) ((void)0) +#else +#define condhardstacktests(x) x +#endif + +#endif diff --git a/include/lmem.h b/include/lmem.h new file mode 100644 index 0000000..7c2dcb3 --- /dev/null +++ b/include/lmem.h @@ -0,0 +1,49 @@ +/* +** $Id: lmem.h,v 1.31.1.1 2007/12/27 13:02:25 roberto Exp $ +** Interface to Memory Manager +** See Copyright Notice in lua.h +*/ + +#ifndef lmem_h +#define lmem_h + + +#include + +#include "llimits.h" +#include "lua.h" + +#define MEMERRMSG "not enough memory" + + +#define luaM_reallocv(L,b,on,n,e) \ + ((cast(size_t, (n)+1) <= MAX_SIZET/(e)) ? /* +1 to avoid warnings */ \ + luaM_realloc_(L, (b), (on)*(e), (n)*(e)) : \ + luaM_toobig(L)) + +#define luaM_freemem(L, b, s) luaM_realloc_(L, (b), (s), 0) +#define luaM_free(L, b) luaM_realloc_(L, (b), sizeof(*(b)), 0) +#define luaM_freearray(L, b, n, t) luaM_reallocv(L, (b), n, 0, sizeof(t)) + +#define luaM_malloc(L,t) luaM_realloc_(L, NULL, 0, (t)) +#define luaM_new(L,t) cast(t *, luaM_malloc(L, sizeof(t))) +#define luaM_newvector(L,n,t) \ + cast(t *, luaM_reallocv(L, NULL, 0, n, sizeof(t))) + +#define luaM_growvector(L,v,nelems,size,t,limit,e) \ + if ((nelems)+1 > (size)) \ + ((v)=cast(t *, luaM_growaux_(L,v,&(size),sizeof(t),limit,e))) + +#define luaM_reallocvector(L, v,oldn,n,t) \ + ((v)=cast(t *, luaM_reallocv(L, v, oldn, n, sizeof(t)))) + + +LUAI_FUNC void *luaM_realloc_ (lua_State *L, void *block, size_t oldsize, + size_t size); +LUAI_FUNC void *luaM_toobig (lua_State *L); +LUAI_FUNC void *luaM_growaux_ (lua_State *L, void *block, int *size, + size_t size_elem, int limit, + const char *errormsg); + +#endif + diff --git a/include/lobject.h b/include/lobject.h new file mode 100644 index 0000000..f1e447e --- /dev/null +++ b/include/lobject.h @@ -0,0 +1,381 @@ +/* +** $Id: lobject.h,v 2.20.1.2 2008/08/06 13:29:48 roberto Exp $ +** Type definitions for Lua objects +** See Copyright Notice in lua.h +*/ + + +#ifndef lobject_h +#define lobject_h + + +#include + + +#include "llimits.h" +#include "lua.h" + + +/* tags for values visible from Lua */ +#define LAST_TAG LUA_TTHREAD + +#define NUM_TAGS (LAST_TAG+1) + + +/* +** Extra tags for non-values +*/ +#define LUA_TPROTO (LAST_TAG+1) +#define LUA_TUPVAL (LAST_TAG+2) +#define LUA_TDEADKEY (LAST_TAG+3) + + +/* +** Union of all collectable objects +*/ +typedef union GCObject GCObject; + + +/* +** Common Header for all collectable objects (in macro form, to be +** included in other objects) +*/ +#define CommonHeader GCObject *next; lu_byte tt; lu_byte marked + + +/* +** Common header in struct form +*/ +typedef struct GCheader { + CommonHeader; +} GCheader; + + + + +/* +** Union of all Lua values +*/ +typedef union { + GCObject *gc; + void *p; + lua_Number n; + int b; +} Value; + + +/* +** Tagged Values +*/ + +#define TValuefields Value value; int tt + +typedef struct lua_TValue { + TValuefields; +} TValue; + + +/* Macros to test type */ +#define ttisnil(o) (ttype(o) == LUA_TNIL) +#define ttisnumber(o) (ttype(o) == LUA_TNUMBER) +#define ttisstring(o) (ttype(o) == LUA_TSTRING) +#define ttistable(o) (ttype(o) == LUA_TTABLE) +#define ttisfunction(o) (ttype(o) == LUA_TFUNCTION) +#define ttisboolean(o) (ttype(o) == LUA_TBOOLEAN) +#define ttisuserdata(o) (ttype(o) == LUA_TUSERDATA) +#define ttisthread(o) (ttype(o) == LUA_TTHREAD) +#define ttislightuserdata(o) (ttype(o) == LUA_TLIGHTUSERDATA) + +/* Macros to access values */ +#define ttype(o) ((o)->tt) +#define gcvalue(o) check_exp(iscollectable(o), (o)->value.gc) +#define pvalue(o) check_exp(ttislightuserdata(o), (o)->value.p) +#define nvalue(o) check_exp(ttisnumber(o), (o)->value.n) +#define rawtsvalue(o) check_exp(ttisstring(o), &(o)->value.gc->ts) +#define tsvalue(o) (&rawtsvalue(o)->tsv) +#define rawuvalue(o) check_exp(ttisuserdata(o), &(o)->value.gc->u) +#define uvalue(o) (&rawuvalue(o)->uv) +#define clvalue(o) check_exp(ttisfunction(o), &(o)->value.gc->cl) +#define hvalue(o) check_exp(ttistable(o), &(o)->value.gc->h) +#define bvalue(o) check_exp(ttisboolean(o), (o)->value.b) +#define thvalue(o) check_exp(ttisthread(o), &(o)->value.gc->th) + +#define l_isfalse(o) (ttisnil(o) || (ttisboolean(o) && bvalue(o) == 0)) + +/* +** for internal debug only +*/ +#define checkconsistency(obj) \ + lua_assert(!iscollectable(obj) || (ttype(obj) == (obj)->value.gc->gch.tt)) + +#define checkliveness(g,obj) \ + lua_assert(!iscollectable(obj) || \ + ((ttype(obj) == (obj)->value.gc->gch.tt) && !isdead(g, (obj)->value.gc))) + + +/* Macros to set values */ +#define setnilvalue(obj) ((obj)->tt=LUA_TNIL) + +#define setnvalue(obj,x) \ + { TValue *i_o=(obj); i_o->value.n=(x); i_o->tt=LUA_TNUMBER; } + +#define setpvalue(obj,x) \ + { TValue *i_o=(obj); i_o->value.p=(x); i_o->tt=LUA_TLIGHTUSERDATA; } + +#define setbvalue(obj,x) \ + { TValue *i_o=(obj); i_o->value.b=(x); i_o->tt=LUA_TBOOLEAN; } + +#define setsvalue(L,obj,x) \ + { TValue *i_o=(obj); \ + i_o->value.gc=cast(GCObject *, (x)); i_o->tt=LUA_TSTRING; \ + checkliveness(G(L),i_o); } + +#define setuvalue(L,obj,x) \ + { TValue *i_o=(obj); \ + i_o->value.gc=cast(GCObject *, (x)); i_o->tt=LUA_TUSERDATA; \ + checkliveness(G(L),i_o); } + +#define setthvalue(L,obj,x) \ + { TValue *i_o=(obj); \ + i_o->value.gc=cast(GCObject *, (x)); i_o->tt=LUA_TTHREAD; \ + checkliveness(G(L),i_o); } + +#define setclvalue(L,obj,x) \ + { TValue *i_o=(obj); \ + i_o->value.gc=cast(GCObject *, (x)); i_o->tt=LUA_TFUNCTION; \ + checkliveness(G(L),i_o); } + +#define sethvalue(L,obj,x) \ + { TValue *i_o=(obj); \ + i_o->value.gc=cast(GCObject *, (x)); i_o->tt=LUA_TTABLE; \ + checkliveness(G(L),i_o); } + +#define setptvalue(L,obj,x) \ + { TValue *i_o=(obj); \ + i_o->value.gc=cast(GCObject *, (x)); i_o->tt=LUA_TPROTO; \ + checkliveness(G(L),i_o); } + + + + +#define setobj(L,obj1,obj2) \ + { const TValue *o2=(obj2); TValue *o1=(obj1); \ + o1->value = o2->value; o1->tt=o2->tt; \ + checkliveness(G(L),o1); } + + +/* +** different types of sets, according to destination +*/ + +/* from stack to (same) stack */ +#define setobjs2s setobj +/* to stack (not from same stack) */ +#define setobj2s setobj +#define setsvalue2s setsvalue +#define sethvalue2s sethvalue +#define setptvalue2s setptvalue +/* from table to same table */ +#define setobjt2t setobj +/* to table */ +#define setobj2t setobj +/* to new object */ +#define setobj2n setobj +#define setsvalue2n setsvalue + +#define setttype(obj, tt) (ttype(obj) = (tt)) + + +#define iscollectable(o) (ttype(o) >= LUA_TSTRING) + + + +typedef TValue *StkId; /* index to stack elements */ + + +/* +** String headers for string table +*/ +typedef union TString { + L_Umaxalign dummy; /* ensures maximum alignment for strings */ + struct { + CommonHeader; + lu_byte reserved; + unsigned int hash; + size_t len; + } tsv; +} TString; + + +#define getstr(ts) cast(const char *, (ts) + 1) +#define svalue(o) getstr(rawtsvalue(o)) + + + +typedef union Udata { + L_Umaxalign dummy; /* ensures maximum alignment for `local' udata */ + struct { + CommonHeader; + struct Table *metatable; + struct Table *env; + size_t len; + } uv; +} Udata; + + + + +/* +** Function Prototypes +*/ +typedef struct Proto { + CommonHeader; + TValue *k; /* constants used by the function */ + Instruction *code; + struct Proto **p; /* functions defined inside the function */ + int *lineinfo; /* map from opcodes to source lines */ + struct LocVar *locvars; /* information about local variables */ + TString **upvalues; /* upvalue names */ + TString *source; + int sizeupvalues; + int sizek; /* size of `k' */ + int sizecode; + int sizelineinfo; + int sizep; /* size of `p' */ + int sizelocvars; + int linedefined; + int lastlinedefined; + GCObject *gclist; + lu_byte nups; /* number of upvalues */ + lu_byte numparams; + lu_byte is_vararg; + lu_byte maxstacksize; +} Proto; + + +/* masks for new-style vararg */ +#define VARARG_HASARG 1 +#define VARARG_ISVARARG 2 +#define VARARG_NEEDSARG 4 + + +typedef struct LocVar { + TString *varname; + int startpc; /* first point where variable is active */ + int endpc; /* first point where variable is dead */ +} LocVar; + + + +/* +** Upvalues +*/ + +typedef struct UpVal { + CommonHeader; + TValue *v; /* points to stack or to its own value */ + union { + TValue value; /* the value (when closed) */ + struct { /* double linked list (when open) */ + struct UpVal *prev; + struct UpVal *next; + } l; + } u; +} UpVal; + + +/* +** Closures +*/ + +#define ClosureHeader \ + CommonHeader; lu_byte isC; lu_byte nupvalues; GCObject *gclist; \ + struct Table *env + +typedef struct CClosure { + ClosureHeader; + lua_CFunction f; + TValue upvalue[1]; +} CClosure; + + +typedef struct LClosure { + ClosureHeader; + struct Proto *p; + UpVal *upvals[1]; +} LClosure; + + +typedef union Closure { + CClosure c; + LClosure l; +} Closure; + + +#define iscfunction(o) (ttype(o) == LUA_TFUNCTION && clvalue(o)->c.isC) +#define isLfunction(o) (ttype(o) == LUA_TFUNCTION && !clvalue(o)->c.isC) + + +/* +** Tables +*/ + +typedef union TKey { + struct { + TValuefields; + struct Node *next; /* for chaining */ + } nk; + TValue tvk; +} TKey; + + +typedef struct Node { + TValue i_val; + TKey i_key; +} Node; + + +typedef struct Table { + CommonHeader; + lu_byte flags; /* 1<

lsizenode)) + + +#define luaO_nilobject (&luaO_nilobject_) + +LUAI_DATA const TValue luaO_nilobject_; + +#define ceillog2(x) (luaO_log2((x)-1) + 1) + +LUAI_FUNC int luaO_log2 (unsigned int x); +LUAI_FUNC int luaO_int2fb (unsigned int x); +LUAI_FUNC int luaO_fb2int (int x); +LUAI_FUNC int luaO_rawequalObj (const TValue *t1, const TValue *t2); +LUAI_FUNC int luaO_str2d (const char *s, lua_Number *result); +LUAI_FUNC const char *luaO_pushvfstring (lua_State *L, const char *fmt, + va_list argp); +LUAI_FUNC const char *luaO_pushfstring (lua_State *L, const char *fmt, ...); +LUAI_FUNC void luaO_chunkid (char *out, const char *source, size_t len); + + +#endif + diff --git a/include/log.h b/include/log.h new file mode 100644 index 0000000..05ecd21 --- /dev/null +++ b/include/log.h @@ -0,0 +1,320 @@ +#ifndef __LOG_H__ +#define __LOG_H__ +#include +typedef enum +{ + LOG_TALK, + LOG_PROC, + LOG_ITEM, + LOG_STONE, + LOG_PET, + LOG_TENSEI, + LOG_KILL, //ttom 12/26/2000 kill the pet & items + LOG_TRADE, // CoolFish: 2001/4/19 + LOG_HACK, // Arminius 2001/6/14 + LOG_SPEED, // Nuke 0626 + LOG_FMPOP, // CoolFish: 2001/9/12 + LOG_FAMILY, // Robin 10/02 + LOG_GM, // Shan +#ifdef _GAMBLE_ROULETTE + LOG_GAMBLE, +#endif + + LOG_LOGIN, + PETTRANS, +//Syu ׯ԰սʤLog + LOG_FMPKRESULT, + +// Syu ADD дȡLog () + LOG_BANKSTONELOG, + + LOG_ACMESS, + LOG_PKCONTEND, +#ifdef _STREET_VENDOR + LOG_STREET_VENDOR, +#endif + +#ifdef _ANGEL_SUMMON + LOG_ANGEL, +#endif + +#ifdef _NEW_MANOR_LAW + LOG_FMPK_GETMONEY, + LOG_FM_FAME_SHOP, +#endif + LOG_LOGOUT, + + LOG_TYPE_NUM, +}LOG_TYPE; + +void closeAllLogFile( void ); +BOOL initLog( char* filename ); +void printl( LOG_TYPE logtype, char* format , ... ); + + +void LogAcMess( int fd, char *type, char *mess ); + +void LogItem( + char *CharName, /* ƽҷ */ + char *CharID, + int ItemNo, /* ʧ ة į */ + char *Key, /* ƽ */ + int floor, /* */ + int x, + int y, + char *uniquecode, // shan 2001/12/14 + char *itemname, int itemID +); +void LogPkContend( char *teamname1, char *teamname2, + int floor, int x, int y, int flg ); + +void LogPetTrans( + char *cdkey, char *uniwuecde, char *uniwuecde2, char *CharName, int floor, int x, int y, + int petID1, char *PetName1, int petLV, int petrank, int vital1, int str1, int tgh1, int dex1, int total1, + int petID2, char *PetName2, int vital2, int str2, int tgh2, int dex2, int total2, + int work0, int work1, int work2, int work3, int ans, int trans +); + +void LogPet( + char *CharName, /* ƽҷ */ + char *CharID, + char *PetName, + int PetLv, + char *Key, /* ƽ */ + int floor, /* */ + int x, + int y, + char *uniquecode // shan 2001/12/14 +); + +#ifdef _STREET_VENDOR +void LogStreetVendor( + char *SellName, + char *SellID, + char *BuyName, + char *BuyID, + char *ItemPetName, + int PetLv, //ǵߴֵΪ -1 + int iPrice, + char *Key, + int Sfloor, + int Sx, + int Sy, + int Bfloor, + int Bx, + int By, + char *uniquecode, + int streettype +); +#endif + +void LogTensei( + char *CharName, /* ƽҷ */ + char *CharID, + char *Key, /* ƽ */ + int level, //ì + int transNum, //Ϸ + int quest, //;޵ + int home, //컩 + int item, // ʧ ة Ի + int pet, // ʸ Ի + int vital, // Vital + int b_vital, // vital + int str, // str + int b_str, // str + int tgh, // + int b_tgh, // + int dex, // + int b_dex // +); +// Syu ADD дȡLog () +void LogFamilyBankStone( + char *CharName, + char *CharId, + int Gold, + int MyGold, + char *Key, + int floor, + int x, + int y, + int banksum +); + +void LogStone( + int TotalGold, + char *CharName, /* ƽҷ */ + char *CharId, /* ǡID */ + int Gold, /* ź */ + int MyGold, + char *Key, /* ƽ */ + int floor, /* */ + int x, + int y +); + +void LogTalk( + char *CharName, /* ƽҷ */ + char *CharID, + int floor, /* */ + int x, + int y, + char *message +); +//ttom 12/26/2000 kill pet & items +void LogKill( + char *CharName, + char *CharId, + char *CharPet_Item +); +//ttom + +// CoolFish: 2001/4/19 +void LogTrade(char *message); +// CoolFish: 2001/9/12 +void LogFMPOP(char *message); + +// Arminius 2001/6/14 +enum +{ + HACK_NOTHING, + HACK_GETFUNCFAIL, + HACK_NOTDISPATCHED, + HACK_CHECKSUMERROR, + HACK_HP, + HACK_CDKEYWRONG, + HACK_TYPE_NUM, +}HACK_TYPE; +void logHack(int fd, int errcode); +void logHackKick(int fd); +// Nuke 0626 +void logSpeed(int fd); + +void closeAllLogFile( void ); +int openAllLogFile( void ); + +// Robin 10/02 +void LogFamily( + char *FMName, + int fmindex, + char *charName, + char *charId, + char *keyWord, + char *data +); + +// Shan 11/02 +void LogGM( + char *CharName, //ɫ + char *CharID, //ID + char *Message, //ָ + int floor, + int x, + int y +); + +void LogLogin( + char *CharID, //ID + char *CharName, //ɫ + int saveIndex, + char *ipadress,char *pcid +); +void LogLogout( + char *CharID, //ID + char *CharName, //ɫ + int floor, + int hp, + char *file, + int line +); +void LogCreatFUPet( + char *PetName, int petid, int lv, int hp, + int vital, int str, int tgh, int dex, + int fixstr, int fixtgh, int fixdex, int trans, int flg); + +#ifdef _GAMBLE_ROULETTE + +void LogGamble( + char *CharName, //ɫ + char *CharID, //ID + char *Key, //˵ + int floor, + int x, + int y, + int player_stone, //ӵнǮ + int Gamble_stone, //ע + int get_stone, // + int Gamble_num, + int flg //flg = 1 2 ׯ +); +#endif + +void LogBankStone( + char *CharName, /* ƽҷ */ + char *CharId, /* ǡID */ + int meindex, + int Gold, /* ź */ + char *Key, /* ƽ */ + int floor, /* */ + int x, + int y, + int my_gold, + int my_personagold +); + +//Syu ׯ԰սʤLog +void Logfmpk( + char *winner, int winnerindex, int num1, + char *loser, int loserindex, int num2, char *date, char *buf1, char *buf2, int flg); + +#ifdef _NEW_MANOR_LAW +void LogFMPKGetMomey( + char *szFMName, + char *szID, + char *szCharName, + int iMomentum, + int iGetMoney, + int iDest +); +void LogFMFameShop( + char *szFMName, + char *szID, + char *szCharName, + int iFame, + int iCostFame +); +#endif + +void backupAllLogFile( struct tm *ptm ); + +void LogPetPointChange( + char * CharName, char *CharID, char *PetName, int petindex, int errtype, + int PetLv, char *Key,int floor, int x, int y); + +void LogPetFeed( + char * CharName, char *CharID, char *PetName, int petindex, + int PetLv, char *Key,int floor, int x, int y, char *ucode); + +#ifdef _ANGEL_SUMMON +void LogAngel( char *msg); +#endif +void Logfmpk_war(int dueltime,int mytime); +void warplog_to_file( void ); +void warplog_from_file( void ); + +typedef struct { + int floor; + int incount; + int outcount; +}tagWarplog; +#define MAXMAPNUM 700 +extern tagWarplog warplog[MAXMAPNUM]; + +typedef struct { + int floor1; + int floor2; + int count; +}tagWarpCount; +#define MAXMAPLINK 1000 +extern tagWarpCount warpCount[MAXMAPLINK]; + +#endif diff --git a/include/lopcodes.h b/include/lopcodes.h new file mode 100644 index 0000000..41224d6 --- /dev/null +++ b/include/lopcodes.h @@ -0,0 +1,268 @@ +/* +** $Id: lopcodes.h,v 1.125.1.1 2007/12/27 13:02:25 roberto Exp $ +** Opcodes for Lua virtual machine +** See Copyright Notice in lua.h +*/ + +#ifndef lopcodes_h +#define lopcodes_h + +#include "llimits.h" + + +/*=========================================================================== + We assume that instructions are unsigned numbers. + All instructions have an opcode in the first 6 bits. + Instructions can have the following fields: + `A' : 8 bits + `B' : 9 bits + `C' : 9 bits + `Bx' : 18 bits (`B' and `C' together) + `sBx' : signed Bx + + A signed argument is represented in excess K; that is, the number + value is the unsigned value minus K. K is exactly the maximum value + for that argument (so that -max is represented by 0, and +max is + represented by 2*max), which is half the maximum for the corresponding + unsigned argument. +===========================================================================*/ + + +enum OpMode {iABC, iABx, iAsBx}; /* basic instruction format */ + + +/* +** size and position of opcode arguments. +*/ +#define SIZE_C 9 +#define SIZE_B 9 +#define SIZE_Bx (SIZE_C + SIZE_B) +#define SIZE_A 8 + +#define SIZE_OP 6 + +#define POS_OP 0 +#define POS_A (POS_OP + SIZE_OP) +#define POS_C (POS_A + SIZE_A) +#define POS_B (POS_C + SIZE_C) +#define POS_Bx POS_C + + +/* +** limits for opcode arguments. +** we use (signed) int to manipulate most arguments, +** so they must fit in LUAI_BITSINT-1 bits (-1 for sign) +*/ +#if SIZE_Bx < LUAI_BITSINT-1 +#define MAXARG_Bx ((1<>1) /* `sBx' is signed */ +#else +#define MAXARG_Bx MAX_INT +#define MAXARG_sBx MAX_INT +#endif + + +#define MAXARG_A ((1<>POS_OP) & MASK1(SIZE_OP,0))) +#define SET_OPCODE(i,o) ((i) = (((i)&MASK0(SIZE_OP,POS_OP)) | \ + ((cast(Instruction, o)<>POS_A) & MASK1(SIZE_A,0))) +#define SETARG_A(i,u) ((i) = (((i)&MASK0(SIZE_A,POS_A)) | \ + ((cast(Instruction, u)<>POS_B) & MASK1(SIZE_B,0))) +#define SETARG_B(i,b) ((i) = (((i)&MASK0(SIZE_B,POS_B)) | \ + ((cast(Instruction, b)<>POS_C) & MASK1(SIZE_C,0))) +#define SETARG_C(i,b) ((i) = (((i)&MASK0(SIZE_C,POS_C)) | \ + ((cast(Instruction, b)<>POS_Bx) & MASK1(SIZE_Bx,0))) +#define SETARG_Bx(i,b) ((i) = (((i)&MASK0(SIZE_Bx,POS_Bx)) | \ + ((cast(Instruction, b)< C) then pc++ */ +OP_TESTSET,/* A B C if (R(B) <=> C) then R(A) := R(B) else pc++ */ + +OP_CALL,/* A B C R(A), ... ,R(A+C-2) := R(A)(R(A+1), ... ,R(A+B-1)) */ +OP_TAILCALL,/* A B C return R(A)(R(A+1), ... ,R(A+B-1)) */ +OP_RETURN,/* A B return R(A), ... ,R(A+B-2) (see note) */ + +OP_FORLOOP,/* A sBx R(A)+=R(A+2); + if R(A) =) R(A)*/ +OP_CLOSURE,/* A Bx R(A) := closure(KPROTO[Bx], R(A), ... ,R(A+n)) */ + +OP_VARARG/* A B R(A), R(A+1), ..., R(A+B-1) = vararg */ +} OpCode; + + +#define NUM_OPCODES (cast(int, OP_VARARG) + 1) + + + +/*=========================================================================== + Notes: + (*) In OP_CALL, if (B == 0) then B = top. C is the number of returns - 1, + and can be 0: OP_CALL then sets `top' to last_result+1, so + next open instruction (OP_CALL, OP_RETURN, OP_SETLIST) may use `top'. + + (*) In OP_VARARG, if (B == 0) then use actual number of varargs and + set top (like in OP_CALL with C == 0). + + (*) In OP_RETURN, if (B == 0) then return up to `top' + + (*) In OP_SETLIST, if (B == 0) then B = `top'; + if (C == 0) then next `instruction' is real C + + (*) For comparisons, A specifies what condition the test should accept + (true or false). + + (*) All `skips' (pc++) assume that next instruction is a jump +===========================================================================*/ + + +/* +** masks for instruction properties. The format is: +** bits 0-1: op mode +** bits 2-3: C arg mode +** bits 4-5: B arg mode +** bit 6: instruction set register A +** bit 7: operator is a test +*/ + +enum OpArgMask { + OpArgN, /* argument is not used */ + OpArgU, /* argument is used */ + OpArgR, /* argument is a register or a jump offset */ + OpArgK /* argument is a constant or register/constant */ +}; + +LUAI_DATA const lu_byte luaP_opmodes[NUM_OPCODES]; + +#define getOpMode(m) (cast(enum OpMode, luaP_opmodes[m] & 3)) +#define getBMode(m) (cast(enum OpArgMask, (luaP_opmodes[m] >> 4) & 3)) +#define getCMode(m) (cast(enum OpArgMask, (luaP_opmodes[m] >> 2) & 3)) +#define testAMode(m) (luaP_opmodes[m] & (1 << 6)) +#define testTMode(m) (luaP_opmodes[m] & (1 << 7)) + + +LUAI_DATA const char *const luaP_opnames[NUM_OPCODES+1]; /* opcode names */ + + +/* number of list items to accumulate before a SETLIST instruction */ +#define LFIELDS_PER_FLUSH 50 + + +#endif diff --git a/include/lparser.h b/include/lparser.h new file mode 100644 index 0000000..18836af --- /dev/null +++ b/include/lparser.h @@ -0,0 +1,82 @@ +/* +** $Id: lparser.h,v 1.57.1.1 2007/12/27 13:02:25 roberto Exp $ +** Lua Parser +** See Copyright Notice in lua.h +*/ + +#ifndef lparser_h +#define lparser_h + +#include "llimits.h" +#include "lobject.h" +#include "lzio.h" + + +/* +** Expression descriptor +*/ + +typedef enum { + VVOID, /* no value */ + VNIL, + VTRUE, + VFALSE, + VK, /* info = index of constant in `k' */ + VKNUM, /* nval = numerical value */ + VLOCAL, /* info = local register */ + VUPVAL, /* info = index of upvalue in `upvalues' */ + VGLOBAL, /* info = index of table; aux = index of global name in `k' */ + VINDEXED, /* info = table register; aux = index register (or `k') */ + VJMP, /* info = instruction pc */ + VRELOCABLE, /* info = instruction pc */ + VNONRELOC, /* info = result register */ + VCALL, /* info = instruction pc */ + VVARARG /* info = instruction pc */ +} expkind; + +typedef struct expdesc { + expkind k; + union { + struct { int info, aux; } s; + lua_Number nval; + } u; + int t; /* patch list of `exit when true' */ + int f; /* patch list of `exit when false' */ +} expdesc; + + +typedef struct upvaldesc { + lu_byte k; + lu_byte info; +} upvaldesc; + + +struct BlockCnt; /* defined in lparser.c */ + + +/* state needed to generate code for a given function */ +typedef struct FuncState { + Proto *f; /* current function header */ + Table *h; /* table to find (and reuse) elements in `k' */ + struct FuncState *prev; /* enclosing function */ + struct LexState *ls; /* lexical state */ + struct lua_State *L; /* copy of the Lua state */ + struct BlockCnt *bl; /* chain of current blocks */ + int pc; /* next position to code (equivalent to `ncode') */ + int lasttarget; /* `pc' of last `jump target' */ + int jpc; /* list of pending jumps to `pc' */ + int freereg; /* first free register */ + int nk; /* number of elements in `k' */ + int np; /* number of elements in `p' */ + short nlocvars; /* number of elements in `locvars' */ + lu_byte nactvar; /* number of active local variables */ + upvaldesc upvalues[LUAI_MAXUPVALUES]; /* upvalues */ + unsigned short actvar[LUAI_MAXVARS]; /* declared-variable stack */ +} FuncState; + + +LUAI_FUNC Proto *luaY_parser (lua_State *L, ZIO *z, Mbuffer *buff, + const char *name); + + +#endif diff --git a/include/lssproto_serv.h b/include/lssproto_serv.h new file mode 100644 index 0000000..6daab59 --- /dev/null +++ b/include/lssproto_serv.h @@ -0,0 +1,400 @@ +#ifndef _PROTOCOL_H_ +#define _PROTOCOL_H_ + +#include "lssproto_util.h" // for StoneAge + +#ifdef MAXLSRPCARGS +#if ( MAXLSRPCARGS <= ( 13 + 1 ) ) +#undef MAXLSRPCARGS +#define MAXLSRPCARGS ( 13 + 1 ) +#endif +#else +#define MAXLSRPCARGS ( 13 + 1 ) +#endif + +int lssproto_InitServer(int (*writefunc)(int,char*,int) , int worksiz ); +void lssproto_SetServerLogFiles( char *read , char *write ); +void lssproto_CleanupServer( void ); +int lssproto_ServerDispatchMessage(int fd, char *encoded); +//int cdkeyinit(void); +#define SEPARATOR ";" + +#define LSSPROTO_W_RECV 0 +#define LSSPROTO_W2_RECV 1 +#define LSSPROTO_XYD_SEND 2 +#define LSSPROTO_EV_RECV 3 +#define LSSPROTO_EV_SEND 4 +#define LSSPROTO_EN_RECV 5 +#define LSSPROTO_DU_RECV 6 +#define LSSPROTO_EN_SEND 7 +#define LSSPROTO_EO_RECV 8 +#define LSSPROTO_BU_RECV 9 +#define LSSPROTO_JB_RECV 10 +#define LSSPROTO_LB_RECV 11 +#define LSSPROTO_RS_SEND 12 +#define LSSPROTO_RD_SEND 13 +#define LSSPROTO_B_RECV 14 +#define LSSPROTO_B_SEND 15 +#define LSSPROTO_SKD_RECV 16 +#define LSSPROTO_ID_RECV 17 +#define LSSPROTO_PI_RECV 18 +#define LSSPROTO_DI_RECV 19 +#define LSSPROTO_DG_RECV 20 +#define LSSPROTO_DP_RECV 21 +#define LSSPROTO_I_SEND 22 +#define LSSPROTO_MI_RECV 23 +#define LSSPROTO_SI_SEND 24 +#define LSSPROTO_MSG_RECV 25 +#define LSSPROTO_MSG_SEND 26 +#define LSSPROTO_PMSG_RECV 27 +#define LSSPROTO_PME_SEND 28 +#define LSSPROTO_AB_RECV 29 +#define LSSPROTO_AB_SEND 30 +#define LSSPROTO_ABI_SEND 31 +#define LSSPROTO_DAB_RECV 32 +#define LSSPROTO_AAB_RECV 33 +#define LSSPROTO_L_RECV 34 +#define LSSPROTO_TK_RECV 35 +#define LSSPROTO_TK_SEND 36 +#define LSSPROTO_MC_SEND 37 +#define LSSPROTO_M_RECV 38 +#define LSSPROTO_M_SEND 39 +#define LSSPROTO_C_RECV 40 +#define LSSPROTO_C_SEND 41 +#define LSSPROTO_CA_SEND 42 +#define LSSPROTO_CD_SEND 43 +#define LSSPROTO_R_SEND 44 +#define LSSPROTO_S_RECV 45 +#define LSSPROTO_S_SEND 46 +#define LSSPROTO_D_SEND 47 +#define LSSPROTO_FS_RECV 48 +#define LSSPROTO_FS_SEND 49 +#define LSSPROTO_HL_RECV 50 +#define LSSPROTO_HL_SEND 51 +#define LSSPROTO_PR_RECV 52 +#define LSSPROTO_PR_SEND 53 +#define LSSPROTO_KS_RECV 54 +#define LSSPROTO_KS_SEND 55 +#define LSSPROTO_AC_RECV 56 +#define LSSPROTO_MU_RECV 57 +#define LSSPROTO_PS_RECV 58 +#define LSSPROTO_PS_SEND 59 +#define LSSPROTO_ST_RECV 60 +#define LSSPROTO_DT_RECV 61 +#define LSSPROTO_FT_RECV 62 +#define LSSPROTO_SKUP_SEND 63 +#define LSSPROTO_SKUP_RECV 64 +#define LSSPROTO_KN_RECV 65 +#define LSSPROTO_WN_SEND 66 +#define LSSPROTO_WN_RECV 67 +#define LSSPROTO_EF_SEND 68 +#define LSSPROTO_SE_SEND 69 +#define LSSPROTO_SP_RECV 70 +#define LSSPROTO_CLIENTLOGIN_RECV 71 +#define LSSPROTO_CLIENTLOGIN_SEND 72 +#define LSSPROTO_CREATENEWCHAR_RECV 73 +#define LSSPROTO_CREATENEWCHAR_SEND 74 +#define LSSPROTO_CHARDELETE_RECV 75 +#define LSSPROTO_CHARDELETE_SEND 76 +#define LSSPROTO_CHARLOGIN_RECV 77 +#define LSSPROTO_CHARLOGIN_SEND 78 +#define LSSPROTO_CHARLIST_RECV 79 +#define LSSPROTO_CHARLIST_SEND 80 +#define LSSPROTO_CHARLOGOUT_RECV 81 +#define LSSPROTO_CHARLOGOUT_SEND 82 +#define LSSPROTO_PROCGET_RECV 83 +#define LSSPROTO_PROCGET_SEND 84 +#define LSSPROTO_PLAYERNUMGET_RECV 85 +#define LSSPROTO_PLAYERNUMGET_SEND 86 +#define LSSPROTO_ECHO_RECV 87 +#define LSSPROTO_ECHO_SEND 88 +#define LSSPROTO_SHUTDOWN_RECV 89 +#define LSSPROTO_NU_SEND 90 +#define LSSPROTO_TD_RECV 91 +#define LSSPROTO_TD_SEND 92 +#define LSSPROTO_FM_SEND 93 +#define LSSPROTO_FM_RECV 94 +#define LSSPROTO_WO_SEND 95 +#define LSSPROTO_PETST_RECV 96 + +#ifdef _MIND_ICON +#define LSSPROTO_MA_RECV 98 +#endif + +#ifdef _ITEM_CRACKER +#define LSSPROTO_IC_SEND 100 +#endif + +#ifdef _MAGIC_NOCAST // :Ĭ +#define LSSPROTO_NC_SEND 101 +#endif + +#ifdef _TEAM_KICKPARTY +#define LSSPROTO_KTEAM_RECV 106 +#endif +#ifdef _PETS_SELECTCON +#define LSSPROTO_PETST_SEND 107 +#endif +#ifdef _NEWREQUESTPROTOCOL // (ɿ) Syu ADD ProtocolҪϸ +#define LSSPROTO_RESIST_RECV 108 +#define LSSPROTO_RESIST_SEND 109 +#endif +#ifdef _OUTOFBATTLESKILL // (ɿ) Syu ADD սʱProtocol +#define LSSPROTO_BATTLESKILL_RECV 110 +#define LSSPROTO_BATTLESKILL_SEND 111 +#endif +#ifdef _CHATROOMPROTOCOL // (ɿ) Syu ADD Ƶ +#define LSSPROTO_CHATROOM_RECV 112 +#define LSSPROTO_CHATROOM_SEND 113 +#endif + +#define LSSPROTO_SPET_RECV 114 // Robin +#define LSSPROTO_SPET_SEND 115 + +#ifdef _STREET_VENDOR +#define LSSPROTO_STREET_VENDOR_RECV 116 // ̯ +#define LSSPROTO_STREET_VENDOR_SEND 117 +#endif + +#ifdef _RIGHTCLICK +#define LSSPROTO_RCLICK_RECV 118 +#define LSSPROTO_RCLICK_SEND 119 +#endif + +#ifdef _JOBDAILY +#define LSSPROTO_JOBDAILY_SEND 120 // CYG־ +#define LSSPROTO_JOBDAILY_RECV 121 +#endif + +#ifdef _TEACHER_SYSTEM +#define LSSPROTO_TEACHER_SYSTEM_RECV 122 // ʦ +#define LSSPROTO_TEACHER_SYSTEM_SEND 123 +#endif + +#ifdef _ADD_STATUS_2 +#define LSSPROTO_S2_RECV 124 +#define LSSPROTO_S2_SEND 125 +#endif + +#ifdef _PET_ITEM +#define LSSPROTO_PET_ITEM_RECV 127 +#endif + +#ifdef _ONLINE_SHOP +#define LSSPROTO_SHOP_RECV 140 +#define LSSPROTO_SHOP_SEND 141 + +#define LSSPROTO_SHOPBUY_RECV 143 +#endif + +#ifdef _CAX_LNS_MAPSUOXU +#define LSSPROTO_UPMAP 145 +#endif + +#ifdef _CAX_DENGON_GG +#define LSSPROTO_DENGON_SEND 200 +#endif + +#ifdef _CAX_ESC_FENGBAO +#define LSSPROTO_ESC_RECV 202 //ESCť +#endif + +void lssproto_W_recv(int fd,int x,int y,char* direction); +void lssproto_W2_recv(int fd,int x,int y,char* direction); +void lssproto_XYD_send(int fd,int x,int y,int dir); +void lssproto_EV_recv(int fd,int event,int seqno,int x,int y,int dir); +void lssproto_EV_send(int fd,int seqno,int result); +void lssproto_EN_recv(int fd,int x,int y); +void lssproto_DU_recv(int fd,int x,int y); +void lssproto_EN_send(int fd,int result,int field); +void lssproto_EO_recv(int fd,int dummy); +void lssproto_BU_recv(int fd,int dummy); +void lssproto_JB_recv(int fd,int x,int y); +void lssproto_LB_recv(int fd,int x,int y); +void lssproto_RS_send(int fd,char* data); +void lssproto_RD_send(int fd,char* data); +void lssproto_B_recv(int fd,char* command); +void lssproto_B_send(int fd,char* command); +void lssproto_SKD_recv(int fd,int dir,int index); +void lssproto_ID_recv(int fd,int x,int y,int haveitemindex,int toindex); +void lssproto_PI_recv(int fd,int x,int y,int dir); +void lssproto_DI_recv(int fd,int x,int y,int itemindex); +void lssproto_DG_recv(int fd,int x,int y,int amount); +void lssproto_DP_recv(int fd,int x,int y,int petindex); +void lssproto_I_send(int fd,char* data); +void lssproto_MI_recv(int fd,int fromindex,int toindex); +void lssproto_SI_send(int fd,int fromindex,int toindex); +void lssproto_MSG_recv(int fd,int index,char* message,int color); +void lssproto_MSG_send(int fd,int aindex,char* text,int color); +void lssproto_PMSG_recv(int fd,int index,int petindex,int itemindex,char* message,int color); +void lssproto_PME_send(int fd,int objindex,int graphicsno,int x,int y,int dir,int flg,int no,char* cdata); +void lssproto_AB_recv(int fd); +void lssproto_AB_send(int fd,char* data); +void lssproto_ABI_send(int fd,int num,char* data); +void lssproto_DAB_recv(int fd,int index); +void lssproto_AAB_recv(int fd,int x,int y); +void lssproto_L_recv(int fd,int dir); +void lssproto_TK_recv(int fd,int x,int y,char* message,int color,int area); +void lssproto_TK_send(int fd,int index,char* message,int color); +void lssproto_MC_send(int fd,int fl,int x1,int y1,int x2,int y2,int tilesum,int objsum,int eventsum,char* data); +void lssproto_M_recv(int fd,int fl,int x1,int y1,int x2,int y2); +void lssproto_M_send(int fd,int fl,int x1,int y1,int x2,int y2,char* data); +void lssproto_C_recv(int fd,int index); +void lssproto_C_send(int fd,char* data); +void lssproto_CA_send(int fd,char* data); +void lssproto_CD_send(int fd,char* data); +void lssproto_R_send(int fd,char* data); +void lssproto_S_recv(int fd,char* category); +void lssproto_S_send(int fd,char* data); +void lssproto_D_send(int fd,int category,int dx,int dy,char* data); +void lssproto_FS_recv(int fd,int flg); +void lssproto_FS_send(int fd,int flg); +void lssproto_HL_recv(int fd,int flg); +void lssproto_HL_send(int fd,int flg); +void lssproto_PR_recv(int fd,int x,int y,int request); +void lssproto_PR_send(int fd,int request,int result); +void lssproto_KS_recv(int fd,int petarray); +void lssproto_KS_send(int fd,int petarray,int result); + +#ifdef _STANDBYPET +void lssproto_SPET_recv(int fd,int standbypet); +void lssproto_SPET_send(int fd,int standbypet,int result); +#endif + +void lssproto_AC_recv(int fd,int x,int y,int actionno); +void lssproto_MU_recv(int fd,int x,int y,int array,int toindex); +void lssproto_PS_recv(int fd,int havepetindex,int havepetskill,int toindex,char* data); +void lssproto_PS_send(int fd,int result,int havepetindex,int havepetskill,int toindex); +void lssproto_ST_recv(int fd,int titleindex); +void lssproto_DT_recv(int fd,int titleindex); +void lssproto_FT_recv(int fd,char* data); +void lssproto_SKUP_send(int fd,int point); +void lssproto_SKUP_recv(int fd,int skillid); +void lssproto_KN_recv(int fd,int havepetindex,char* data); +void lssproto_WN_send(int fd,int windowtype,int buttontype,int seqno,int objindex,char* data); +void lssproto_WN_recv(int fd,int x,int y,int seqno,int objindex,int select,char* data); +void lssproto_EF_send(int fd,int effect,int level,char* option); +void lssproto_SE_send(int fd,int x,int y,int senumber,int sw); +void lssproto_SP_recv(int fd,int x,int y,int dir); +void lssproto_ClientLogin_recv(int fd,char* cdkey,char* passwd); +void lssproto_ClientLogin_send(int fd,char* result); +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); +void lssproto_CreateNewChar_send(int fd,char* result,char* data); +void lssproto_CharDelete_recv( int fd , char* charname,char* safepass); +void lssproto_CharDelete_send(int fd,char* result,char* data); +void lssproto_CharLogin_recv(int fd,char* charname); +void lssproto_CharLogin_send(int fd,char* result,char* data); + +#ifdef _PKSEVER_VER +void lssproto_CharList_recv( int fd, int star); +#else +void lssproto_CharList_recv(int fd); +#endif + +void lssproto_CharList_send(int fd,char* result,char* data); +void lssproto_CharLogout_recv(int fd, int flg); +void lssproto_CharLogout_send(int fd,char* result,char* data); +void lssproto_ProcGet_recv(int fd); +void lssproto_ProcGet_send(int fd,char* data); +void lssproto_PlayerNumGet_recv(int fd); +void lssproto_PlayerNumGet_send(int fd,int logincount,int player); +void lssproto_Echo_recv(int fd,char* test); +void lssproto_Echo_send(int fd,char* test); +void lssproto_Shutdown_recv(int fd,char* passwd,int min); + +void lssproto_TD_send(int fd, int index, char* message); +void lssproto_TD_recv(int fd, char* message); + +#ifdef _CHATROOMPROTOCOL // (ɿ) Syu ADD Ƶ +void lssproto_CHATROOM_recv(int fd , char *data) ; +void lssproto_CHATROOM_send(int fd , char* message ) ; +#endif + +#ifdef _NEWREQUESTPROTOCOL // (ɿ) Syu ADD ProtocolҪϸ +void lssproto_RESIST_recv(int fd ) ; +void lssproto_RESIST_send(int fd , char* message ) ; +#endif +#ifdef _OUTOFBATTLESKILL // (ɿ) Syu ADD սʱProtocol +void lssproto_BATTLESKILL_recv(int fd, int iNum) ; +void lssproto_BATTLESKILL_send(int fd , char* message ) ; +#endif + +void lssproto_NU_send(int fd, int nu); + +void lssproto_FM_send(int fd, char* message); +void lssproto_FM_recv(int fd, char* message); + +void lssproto_WO_send(int fd,int effect); +void lssproto_PETST_recv( int fd, int nPet, int sPet); +void lssproto_BM_recv(int fd, int iindex); + +#ifdef _MIND_ICON +void lssproto_MA_recv(int fd, int x, int y, int nMind); +#endif + +#ifdef _ITEM_CRACKER +void lssproto_IC_send(int fd, int x, int y); +#endif + +#ifdef _ITEM_CRACKER +void lssproto_NC_send(int fd,int flg); +#endif + +#ifdef _TEAM_KICKPARTY +void lssproto_KTEAM_recv( int fd, int si); +#endif + +#ifdef _PETS_SELECTCON +void lssproto_PETS_send(int fd,int petarray,int result); +//#define LSSPROTO_PETST_SEND 107 +#endif + +#ifdef _STREET_VENDOR +void lssproto_STREET_VENDOR_recv(int fd,char *message); +void lssproto_STREET_VENDOR_send(int fd,char *message); +#endif + +#ifdef _RCLICK +void lssproto_RCLICK_recv(int fd, int type, char* data); +void lssproto_RCLICK_send(int fd, int type, char* data); +#endif + +#ifdef _JOBDAILY +void lssproto_JOBDAILY_recv(int fd,char *data); +void lssproto_JOBDAILY_send(int fd,char *data); +#endif + +#ifdef _TEACHER_SYSTEM +void lssproto_TEACHER_SYSTEM_recv(int fd,char *data); +void lssproto_TEACHER_SYSTEM_send(int fd,char *data); +#endif + +#ifdef _ADD_STATUS_2 +void lssproto_S2_recv(int fd,char *data); +void lssproto_S2_send(int fd,char *data); +#endif + +#ifdef _PET_ITEM +void lssproto_PETITEM_recv( int fd,int x,int y,int petindex,int fromindex,int toindex ); +#endif + +#ifdef _ONLINE_SHOP +void lssproto_SHOP_recv(int fd,int shopflag,int piece); +void lssproto_SHOP_send(int fd,int shopnum,int vippoint,int piece,int pieces,int shopflag,char* res); +void lssproto_SHOPBUY_recv(int fd,int shopflag,int piece,int shopno,int buynum); +#endif +void lssproto_ClientLoginJqm_recv( int fd,char* cdkey, char* passwd, char* jqm +#ifdef _CAX_NEWMAC_LOGIN + , char*mac +#endif +#ifdef _MO_LOGINCHECK +,char* szdata +#endif + ); +#endif + +#ifdef _CAX_DENGON_GG +void lssproto_DENGON_send(int fd, char *data, int color, int num); +#endif + +void lssproto_Upmap_send(int fd,int formmap,int tomap); diff --git a/include/lssproto_util.h b/include/lssproto_util.h new file mode 100644 index 0000000..c06730c --- /dev/null +++ b/include/lssproto_util.h @@ -0,0 +1,110 @@ +#ifndef _LSSPROTOUTIL_H_ +#define _LSSPROTOUTIL_H_ +#include +#include +#ifndef WIN32 +#include +#include +#endif +//#define lssproto__ENCRYPT +#define lssproto__NODEBUG +struct lssproto_ { + int (*write_func)(int,char*,int) ; /* write function */ + size_t workbufsize; /* size of work area */ + char *work,*arraywork,*escapework,*val_str,*ret_work; /* work areas which have same size */ + char *cryptwork,*jencodecopy,*jencodeout,*compresswork; /* these work has bigger size (3times)*/ + char** token_list; /* token list */ + unsigned long message_id; /*= 1, */ /* for generating message IDs */ +}; +#ifdef _LSSPROTOUTIL_C_ +struct lssproto_ lssproto = { + NULL, + 0, + NULL,NULL,NULL,NULL,NULL, + NULL,NULL,NULL,NULL, + NULL, + 1, +}; +char **lssproto_stringwrapper; +char lssproto_readlogfilename[1024]; +char lssproto_writelogfilename[1024]; +#else +extern char **lssproto_stringwrapper; +extern struct lssproto_ lssproto; +extern char lssproto_readlogfilename[1024]; +extern char lssproto_writelogfilename[1024]; +#endif + +char* lssproto_escapeString( char*a ); +char* lssproto_descapeString( char*a ); +void lssproto_splitString( char *src ); +void lssproto_strcpysafe( char *dest, char *src, int len ); +void lssproto_strcatsafe( char *dest , char *src , int maxlen ); +char*lssproto_mkstr_int( int i ); +char*lssproto_mkstr_u_int( unsigned int i ); +char*lssproto_mkstr_long( long l ); +char*lssproto_mkstr_u_long( unsigned long l ); +char*lssproto_mkstr_short( short s ); +char*lssproto_mkstr_u_short( short s ); +char*lssproto_mkstr_char( char c ); +char*lssproto_mkstr_u_char( char c); +char*lssproto_mkstr_string( char*a ); +char*lssproto_mkstr_float( float f ); +char*lssproto_mkstr_double( double d ); +char*lssproto_mkstr_int_array( int size , int *array ); +char*lssproto_mkstr_u_int_array( int size , int *array ); +char*lssproto_mkstr_short_array( int size , short *array ); +char*lssproto_mkstr_u_short_array(int size , short *array ); +char *lssproto_mkstr_char_array( int size , char *array ); +char *lssproto_mkstr_u_char_array( int size , unsigned char *array ); +char *lssproto_mkstr_float_array( int size , float *array ); +char *lssproto_mkstr_double_array( int size , double *array ); +int lssproto_demkstr_int( char*a ); +unsigned int lssproto_demkstr_u_int( char*a ); +long lssproto_demkstr_long( char*a ); +unsigned long lssproto_demkstr_u_long(char*a ); +short lssproto_demkstr_short( char*a ); +unsigned short lssproto_demkstr_u_short( char*a ); +char lssproto_demkstr_char( char*a ); +unsigned char lssproto_demkstr_u_char( char*a ); +float lssproto_demkstr_float( char*a ); +double lssproto_demkstr_double(char*a ); +char* lssproto_demkstr_string( char*a); +int *lssproto_demkstr_int_array( char**tk ,int *buf ,int start , int size ); +int *lssproto_demkstr_u_int_array( char **tk , int *buf , int start , int size ); +unsigned int *lssproto_demkstr_long_array( + char **tk , unsigned int *buf , int start , int size ); +unsigned long *lssproto_demkstr_u_long_array( + char **tk , unsigned long *buf , int start , int size ); +short *lssproto_demkstr_short_array( char **tk , short *buf , int start , int size ); +unsigned short*lssproto_demkstr_u_short_array( + char **tk , unsigned short *buf , int start , int size ); +char *lssproto_demkstr_char_array( char **tk , char *buf , int start , int size ); +unsigned char *lssproto_demkstr_u_char_array( + char **tk , unsigned char*buf , int start , int size ); +float *lssproto_demkstr_float_array( char **tk , float *buf , int start , int size ); +double *lssproto_demkstr_u_double_array( char **tk , double *buf , int start , int size ); +char *lssproto_wrapStringAddr( char *copy , int maxcopylen , char*src ); + +void lssproto_GetMessageInfo( int *id , char *funcname , int len,char **tk ); +int lssproto_ClientRead(void); +void lssproto_consumeLine(char *buf , int ofs ); +void lssproto_copyLine( char*src , char *out , int maxoutlen ); +void lssproto_Send( int fd , char *msg ); +int lssproto_AllocateCommonWork(int bufsiz); +unsigned int lssproto_GetNewMessageID(void); +void lssproto_CreateHeader(char*out, char *fname ); +void lssproto_CreateHeaderID( char *out,unsigned long msgid , char *fname ); +int lssproto_default_write_wrap( int fd , char *buf , int size ); +void lssproto_bzero( char *b , int siz ); +void lssproto_bcopy(char*s , char *d , int siz ); +char *lssproto_Ltoa( long v ); +char *lssproto_Ultoa( unsigned long v ); +void lssproto_DebugSend( int fd , char *msg ); +/* Modified by ringo to fasten int type transfer */ +char *lssproto_cnv10to62( int a, char *out, int outlen ); +int lssproto_a62toi( char *a ); +extern int JENCODE_KEY; +#endif + + diff --git a/include/lstate.h b/include/lstate.h new file mode 100644 index 0000000..3bc575b --- /dev/null +++ b/include/lstate.h @@ -0,0 +1,169 @@ +/* +** $Id: lstate.h,v 2.24.1.2 2008/01/03 15:20:39 roberto Exp $ +** Global State +** See Copyright Notice in lua.h +*/ + +#ifndef lstate_h +#define lstate_h + +#include "lua.h" + +#include "lobject.h" +#include "ltm.h" +#include "lzio.h" + + + +struct lua_longjmp; /* defined in ldo.c */ + + +/* table of globals */ +#define gt(L) (&L->l_gt) + +/* registry */ +#define registry(L) (&G(L)->l_registry) + + +/* extra stack space to handle TM calls and some other extras */ +#define EXTRA_STACK 5 + + +#define BASIC_CI_SIZE 8 + +#define BASIC_STACK_SIZE (2*LUA_MINSTACK) + + + +typedef struct stringtable { + GCObject **hash; + lu_int32 nuse; /* number of elements */ + int size; +} stringtable; + + +/* +** informations about a call +*/ +typedef struct CallInfo { + StkId base; /* base for this function */ + StkId func; /* function index in the stack */ + StkId top; /* top for this function */ + const Instruction *savedpc; + int nresults; /* expected number of results from this function */ + int tailcalls; /* number of tail calls lost under this entry */ +} CallInfo; + + + +#define curr_func(L) (clvalue(L->ci->func)) +#define ci_func(ci) (clvalue((ci)->func)) +#define f_isLua(ci) (!ci_func(ci)->c.isC) +#define isLua(ci) (ttisfunction((ci)->func) && f_isLua(ci)) + + +/* +** `global state', shared by all threads of this state +*/ +typedef struct global_State { + stringtable strt; /* hash table for strings */ + lua_Alloc frealloc; /* function to reallocate memory */ + void *ud; /* auxiliary data to `frealloc' */ + lu_byte currentwhite; + lu_byte gcstate; /* state of garbage collector */ + int sweepstrgc; /* position of sweep in `strt' */ + GCObject *rootgc; /* list of all collectable objects */ + GCObject **sweepgc; /* position of sweep in `rootgc' */ + GCObject *gray; /* list of gray objects */ + GCObject *grayagain; /* list of objects to be traversed atomically */ + GCObject *weak; /* list of weak tables (to be cleared) */ + GCObject *tmudata; /* last element of list of userdata to be GC */ + Mbuffer buff; /* temporary buffer for string concatentation */ + lu_mem GCthreshold; + lu_mem totalbytes; /* number of bytes currently allocated */ + lu_mem estimate; /* an estimate of number of bytes actually in use */ + lu_mem gcdept; /* how much GC is `behind schedule' */ + int gcpause; /* size of pause between successive GCs */ + int gcstepmul; /* GC `granularity' */ + lua_CFunction panic; /* to be called in unprotected errors */ + TValue l_registry; + struct lua_State *mainthread; + UpVal uvhead; /* head of double-linked list of all open upvalues */ + struct Table *mt[NUM_TAGS]; /* metatables for basic types */ + TString *tmname[TM_N]; /* array with tag-method names */ +} global_State; + + +/* +** `per thread' state +*/ +struct lua_State { + CommonHeader; + lu_byte status; + StkId top; /* first free slot in the stack */ + StkId base; /* base of current function */ + global_State *l_G; + CallInfo *ci; /* call info for current function */ + const Instruction *savedpc; /* `savedpc' of current function */ + StkId stack_last; /* last free slot in the stack */ + StkId stack; /* stack base */ + CallInfo *end_ci; /* points after end of ci array*/ + CallInfo *base_ci; /* array of CallInfo's */ + int stacksize; + int size_ci; /* size of array `base_ci' */ + unsigned short nCcalls; /* number of nested C calls */ + unsigned short baseCcalls; /* nested C calls when resuming coroutine */ + lu_byte hookmask; + lu_byte allowhook; + int basehookcount; + int hookcount; + lua_Hook hook; + TValue l_gt; /* table of globals */ + TValue env; /* temporary place for environments */ + GCObject *openupval; /* list of open upvalues in this stack */ + GCObject *gclist; + struct lua_longjmp *errorJmp; /* current error recover point */ + ptrdiff_t errfunc; /* current error handling function (stack index) */ +}; + + +#define G(L) (L->l_G) + + +/* +** Union of all collectable objects +*/ +union GCObject { + GCheader gch; + union TString ts; + union Udata u; + union Closure cl; + struct Table h; + struct Proto p; + struct UpVal uv; + struct lua_State th; /* thread */ +}; + + +/* macros to convert a GCObject into a specific value */ +#define rawgco2ts(o) check_exp((o)->gch.tt == LUA_TSTRING, &((o)->ts)) +#define gco2ts(o) (&rawgco2ts(o)->tsv) +#define rawgco2u(o) check_exp((o)->gch.tt == LUA_TUSERDATA, &((o)->u)) +#define gco2u(o) (&rawgco2u(o)->uv) +#define gco2cl(o) check_exp((o)->gch.tt == LUA_TFUNCTION, &((o)->cl)) +#define gco2h(o) check_exp((o)->gch.tt == LUA_TTABLE, &((o)->h)) +#define gco2p(o) check_exp((o)->gch.tt == LUA_TPROTO, &((o)->p)) +#define gco2uv(o) check_exp((o)->gch.tt == LUA_TUPVAL, &((o)->uv)) +#define ngcotouv(o) \ + check_exp((o) == NULL || (o)->gch.tt == LUA_TUPVAL, &((o)->uv)) +#define gco2th(o) check_exp((o)->gch.tt == LUA_TTHREAD, &((o)->th)) + +/* macro to convert any Lua object into a GCObject */ +#define obj2gco(v) (cast(GCObject *, (v))) + + +LUAI_FUNC lua_State *luaE_newthread (lua_State *L); +LUAI_FUNC void luaE_freethread (lua_State *L, lua_State *L1); + +#endif + diff --git a/include/lstring.h b/include/lstring.h new file mode 100644 index 0000000..73a2ff8 --- /dev/null +++ b/include/lstring.h @@ -0,0 +1,31 @@ +/* +** $Id: lstring.h,v 1.43.1.1 2007/12/27 13:02:25 roberto Exp $ +** String table (keep all strings handled by Lua) +** See Copyright Notice in lua.h +*/ + +#ifndef lstring_h +#define lstring_h + + +#include "lgc.h" +#include "lobject.h" +#include "lstate.h" + + +#define sizestring(s) (sizeof(union TString)+((s)->len+1)*sizeof(char)) + +#define sizeudata(u) (sizeof(union Udata)+(u)->len) + +#define luaS_new(L, s) (luaS_newlstr(L, s, strlen(s))) +#define luaS_newliteral(L, s) (luaS_newlstr(L, "" s, \ + (sizeof(s)/sizeof(char))-1)) + +#define luaS_fix(s) l_setbit((s)->tsv.marked, FIXEDBIT) + +LUAI_FUNC void luaS_resize (lua_State *L, int newsize); +LUAI_FUNC Udata *luaS_newudata (lua_State *L, size_t s, Table *e); +LUAI_FUNC TString *luaS_newlstr (lua_State *L, const char *str, size_t l); + + +#endif diff --git a/include/ltable.h b/include/ltable.h new file mode 100644 index 0000000..f5b9d5e --- /dev/null +++ b/include/ltable.h @@ -0,0 +1,40 @@ +/* +** $Id: ltable.h,v 2.10.1.1 2007/12/27 13:02:25 roberto Exp $ +** Lua tables (hash) +** See Copyright Notice in lua.h +*/ + +#ifndef ltable_h +#define ltable_h + +#include "lobject.h" + + +#define gnode(t,i) (&(t)->node[i]) +#define gkey(n) (&(n)->i_key.nk) +#define gval(n) (&(n)->i_val) +#define gnext(n) ((n)->i_key.nk.next) + +#define key2tval(n) (&(n)->i_key.tvk) + + +LUAI_FUNC const TValue *luaH_getnum (Table *t, int key); +LUAI_FUNC TValue *luaH_setnum (lua_State *L, Table *t, int key); +LUAI_FUNC const TValue *luaH_getstr (Table *t, TString *key); +LUAI_FUNC TValue *luaH_setstr (lua_State *L, Table *t, TString *key); +LUAI_FUNC const TValue *luaH_get (Table *t, const TValue *key); +LUAI_FUNC TValue *luaH_set (lua_State *L, Table *t, const TValue *key); +LUAI_FUNC Table *luaH_new (lua_State *L, int narray, int lnhash); +LUAI_FUNC void luaH_resizearray (lua_State *L, Table *t, int nasize); +LUAI_FUNC void luaH_free (lua_State *L, Table *t); +LUAI_FUNC int luaH_next (lua_State *L, Table *t, StkId key); +LUAI_FUNC int luaH_getn (Table *t); + + +#if defined(LUA_DEBUG) +LUAI_FUNC Node *luaH_mainposition (const Table *t, const TValue *key); +LUAI_FUNC int luaH_isdummy (Node *n); +#endif + + +#endif diff --git a/include/ltm.h b/include/ltm.h new file mode 100644 index 0000000..64343b7 --- /dev/null +++ b/include/ltm.h @@ -0,0 +1,54 @@ +/* +** $Id: ltm.h,v 2.6.1.1 2007/12/27 13:02:25 roberto Exp $ +** Tag methods +** See Copyright Notice in lua.h +*/ + +#ifndef ltm_h +#define ltm_h + + +#include "lobject.h" + + +/* +* WARNING: if you change the order of this enumeration, +* grep "ORDER TM" +*/ +typedef enum { + TM_INDEX, + TM_NEWINDEX, + TM_GC, + TM_MODE, + TM_EQ, /* last tag method with `fast' access */ + TM_ADD, + TM_SUB, + TM_MUL, + TM_DIV, + TM_MOD, + TM_POW, + TM_UNM, + TM_LEN, + TM_LT, + TM_LE, + TM_CONCAT, + TM_CALL, + TM_N /* number of elements in the enum */ +} TMS; + + + +#define gfasttm(g,et,e) ((et) == NULL ? NULL : \ + ((et)->flags & (1u<<(e))) ? NULL : luaT_gettm(et, e, (g)->tmname[e])) + +#define fasttm(l,et,e) gfasttm(G(l), et, e) + +LUAI_DATA const char *const luaT_typenames[]; + + +LUAI_FUNC const TValue *luaT_gettm (Table *events, TMS event, TString *ename); +LUAI_FUNC const TValue *luaT_gettmbyobj (lua_State *L, const TValue *o, + TMS event); +LUAI_FUNC void luaT_init (lua_State *L); + +#endif diff --git a/include/lua.h b/include/lua.h new file mode 100644 index 0000000..e4bdfd3 --- /dev/null +++ b/include/lua.h @@ -0,0 +1,388 @@ +/* +** $Id: lua.h,v 1.218.1.5 2008/08/06 13:30:12 roberto Exp $ +** Lua - An Extensible Extension Language +** Lua.org, PUC-Rio, Brazil (http://www.lua.org) +** See Copyright Notice at the end of this file +*/ + + +#ifndef lua_h +#define lua_h + +#include +#include + + +#include "luaconf.h" + + +#define LUA_VERSION "Lua 5.1" +#define LUA_RELEASE "Lua 5.1.4" +#define LUA_VERSION_NUM 501 +#define LUA_COPYRIGHT "Copyright (C) 1994-2008 Lua.org, PUC-Rio" +#define LUA_AUTHORS "R. Ierusalimschy, L. H. de Figueiredo & W. Celes" + + +/* mark for precompiled code (`Lua') */ +#define LUA_SIGNATURE "\033Lua" + +/* option for multiple returns in `lua_pcall' and `lua_call' */ +#define LUA_MULTRET (-1) + + +/* +** pseudo-indices +*/ +#define LUA_REGISTRYINDEX (-10000) +#define LUA_ENVIRONINDEX (-10001) +#define LUA_GLOBALSINDEX (-10002) +#define lua_upvalueindex(i) (LUA_GLOBALSINDEX-(i)) + + +/* thread status; 0 is OK */ +#define LUA_YIELD 1 +#define LUA_ERRRUN 2 +#define LUA_ERRSYNTAX 3 +#define LUA_ERRMEM 4 +#define LUA_ERRERR 5 + + +typedef struct lua_State lua_State; + +typedef int (*lua_CFunction) (lua_State *L); + + +/* +** functions that read/write blocks when loading/dumping Lua chunks +*/ +typedef const char * (*lua_Reader) (lua_State *L, void *ud, size_t *sz); + +typedef int (*lua_Writer) (lua_State *L, const void* p, size_t sz, void* ud); + + +/* +** prototype for memory-allocation functions +*/ +typedef void * (*lua_Alloc) (void *ud, void *ptr, size_t osize, size_t nsize); + + +/* +** basic types +*/ +#define LUA_TNONE (-1) + +#define LUA_TNIL 0 +#define LUA_TBOOLEAN 1 +#define LUA_TLIGHTUSERDATA 2 +#define LUA_TNUMBER 3 +#define LUA_TSTRING 4 +#define LUA_TTABLE 5 +#define LUA_TFUNCTION 6 +#define LUA_TUSERDATA 7 +#define LUA_TTHREAD 8 + + + +/* minimum Lua stack available to a C function */ +#define LUA_MINSTACK 20 + + +/* +** generic extra include file +*/ +#if defined(LUA_USER_H) +#include LUA_USER_H +#endif + + +/* type of numbers in Lua */ +typedef LUA_NUMBER lua_Number; + + +/* type for integer functions */ +typedef LUA_INTEGER lua_Integer; + + + +/* +** state manipulation +*/ +LUA_API lua_State *(lua_newstate) (lua_Alloc f, void *ud); +LUA_API void (lua_close) (lua_State *L); +LUA_API lua_State *(lua_newthread) (lua_State *L); + +LUA_API lua_CFunction (lua_atpanic) (lua_State *L, lua_CFunction panicf); + + +/* +** basic stack manipulation +*/ +LUA_API int (lua_gettop) (lua_State *L); +LUA_API void (lua_settop) (lua_State *L, int idx); +LUA_API void (lua_pushvalue) (lua_State *L, int idx); +LUA_API void (lua_remove) (lua_State *L, int idx); +LUA_API void (lua_insert) (lua_State *L, int idx); +LUA_API void (lua_replace) (lua_State *L, int idx); +LUA_API int (lua_checkstack) (lua_State *L, int sz); + +LUA_API void (lua_xmove) (lua_State *from, lua_State *to, int n); + + +/* +** access functions (stack -> C) +*/ + +LUA_API int (lua_isnumber) (lua_State *L, int idx); +LUA_API int (lua_isstring) (lua_State *L, int idx); +LUA_API int (lua_iscfunction) (lua_State *L, int idx); +LUA_API int (lua_isuserdata) (lua_State *L, int idx); +LUA_API int (lua_type) (lua_State *L, int idx); +LUA_API const char *(lua_typename) (lua_State *L, int tp); + +LUA_API int (lua_equal) (lua_State *L, int idx1, int idx2); +LUA_API int (lua_rawequal) (lua_State *L, int idx1, int idx2); +LUA_API int (lua_lessthan) (lua_State *L, int idx1, int idx2); + +LUA_API lua_Number (lua_tonumber) (lua_State *L, int idx); +LUA_API lua_Integer (lua_tointeger) (lua_State *L, int idx); +LUA_API int (lua_toboolean) (lua_State *L, int idx); +LUA_API const char *(lua_tolstring) (lua_State *L, int idx, size_t *len); +LUA_API size_t (lua_objlen) (lua_State *L, int idx); +LUA_API lua_CFunction (lua_tocfunction) (lua_State *L, int idx); +LUA_API void *(lua_touserdata) (lua_State *L, int idx); +LUA_API lua_State *(lua_tothread) (lua_State *L, int idx); +LUA_API const void *(lua_topointer) (lua_State *L, int idx); + + +/* +** push functions (C -> stack) +*/ +LUA_API void (lua_pushnil) (lua_State *L); +LUA_API void (lua_pushnumber) (lua_State *L, lua_Number n); +LUA_API void (lua_pushinteger) (lua_State *L, lua_Integer n); +LUA_API void (lua_pushlstring) (lua_State *L, const char *s, size_t l); +LUA_API void (lua_pushstring) (lua_State *L, const char *s); +LUA_API const char *(lua_pushvfstring) (lua_State *L, const char *fmt, + va_list argp); +LUA_API const char *(lua_pushfstring) (lua_State *L, const char *fmt, ...); +LUA_API void (lua_pushcclosure) (lua_State *L, lua_CFunction fn, int n); +LUA_API void (lua_pushboolean) (lua_State *L, int b); +LUA_API void (lua_pushlightuserdata) (lua_State *L, void *p); +LUA_API int (lua_pushthread) (lua_State *L); + + +/* +** get functions (Lua -> stack) +*/ +LUA_API void (lua_gettable) (lua_State *L, int idx); +LUA_API void (lua_getfield) (lua_State *L, int idx, const char *k); +LUA_API void (lua_rawget) (lua_State *L, int idx); +LUA_API void (lua_rawgeti) (lua_State *L, int idx, int n); +LUA_API void (lua_createtable) (lua_State *L, int narr, int nrec); +LUA_API void *(lua_newuserdata) (lua_State *L, size_t sz); +LUA_API int (lua_getmetatable) (lua_State *L, int objindex); +LUA_API void (lua_getfenv) (lua_State *L, int idx); + + +/* +** set functions (stack -> Lua) +*/ +LUA_API void (lua_settable) (lua_State *L, int idx); +LUA_API void (lua_setfield) (lua_State *L, int idx, const char *k); +LUA_API void (lua_rawset) (lua_State *L, int idx); +LUA_API void (lua_rawseti) (lua_State *L, int idx, int n); +LUA_API int (lua_setmetatable) (lua_State *L, int objindex); +LUA_API int (lua_setfenv) (lua_State *L, int idx); + + +/* +** `load' and `call' functions (load and run Lua code) +*/ +LUA_API void (lua_call) (lua_State *L, int nargs, int nresults); +LUA_API int (lua_pcall) (lua_State *L, int nargs, int nresults, int errfunc); +LUA_API int (lua_cpcall) (lua_State *L, lua_CFunction func, void *ud); +LUA_API int (lua_load) (lua_State *L, lua_Reader reader, void *dt, + const char *chunkname); + +LUA_API int (lua_dump) (lua_State *L, lua_Writer writer, void *data); + + +/* +** coroutine functions +*/ +LUA_API int (lua_yield) (lua_State *L, int nresults); +LUA_API int (lua_resume) (lua_State *L, int narg); +LUA_API int (lua_status) (lua_State *L); + +/* +** garbage-collection function and options +*/ + +#define LUA_GCSTOP 0 +#define LUA_GCRESTART 1 +#define LUA_GCCOLLECT 2 +#define LUA_GCCOUNT 3 +#define LUA_GCCOUNTB 4 +#define LUA_GCSTEP 5 +#define LUA_GCSETPAUSE 6 +#define LUA_GCSETSTEPMUL 7 + +LUA_API int (lua_gc) (lua_State *L, int what, int data); + + +/* +** miscellaneous functions +*/ + +LUA_API int (lua_error) (lua_State *L); + +LUA_API int (lua_next) (lua_State *L, int idx); + +LUA_API void (lua_concat) (lua_State *L, int n); + +LUA_API lua_Alloc (lua_getallocf) (lua_State *L, void **ud); +LUA_API void lua_setallocf (lua_State *L, lua_Alloc f, void *ud); + + + +/* +** =============================================================== +** some useful macros +** =============================================================== +*/ + +#define lua_pop(L,n) lua_settop(L, -(n)-1) + +#define lua_newtable(L) lua_createtable(L, 0, 0) + +#define lua_register(L,n,f) (lua_pushcfunction(L, (f)), lua_setglobal(L, (n))) + +#define lua_pushcfunction(L,f) lua_pushcclosure(L, (f), 0) + +#define lua_strlen(L,i) lua_objlen(L, (i)) + +#define lua_isfunction(L,n) (lua_type(L, (n)) == LUA_TFUNCTION) +#define lua_istable(L,n) (lua_type(L, (n)) == LUA_TTABLE) +#define lua_islightuserdata(L,n) (lua_type(L, (n)) == LUA_TLIGHTUSERDATA) +#define lua_isnil(L,n) (lua_type(L, (n)) == LUA_TNIL) +#define lua_isboolean(L,n) (lua_type(L, (n)) == LUA_TBOOLEAN) +#define lua_isthread(L,n) (lua_type(L, (n)) == LUA_TTHREAD) +#define lua_isnone(L,n) (lua_type(L, (n)) == LUA_TNONE) +#define lua_isnoneornil(L, n) (lua_type(L, (n)) <= 0) + +#define lua_pushliteral(L, s) \ + lua_pushlstring(L, "" s, (sizeof(s)/sizeof(char))-1) + +#define lua_setglobal(L,s) lua_setfield(L, LUA_GLOBALSINDEX, (s)) +#define lua_getglobal(L,s) lua_getfield(L, LUA_GLOBALSINDEX, (s)) + +#define lua_tostring(L,i) lua_tolstring(L, (i), NULL) + + + +/* +** compatibility macros and functions +*/ + +#define lua_open() luaL_newstate() + +#define lua_getregistry(L) lua_pushvalue(L, LUA_REGISTRYINDEX) + +#define lua_getgccount(L) lua_gc(L, LUA_GCCOUNT, 0) + +#define lua_Chunkreader lua_Reader +#define lua_Chunkwriter lua_Writer + + +/* hack */ +LUA_API void lua_setlevel (lua_State *from, lua_State *to); + + +/* +** {====================================================================== +** Debug API +** ======================================================================= +*/ + + +/* +** Event codes +*/ +#define LUA_HOOKCALL 0 +#define LUA_HOOKRET 1 +#define LUA_HOOKLINE 2 +#define LUA_HOOKCOUNT 3 +#define LUA_HOOKTAILRET 4 + + +/* +** Event masks +*/ +#define LUA_MASKCALL (1 << LUA_HOOKCALL) +#define LUA_MASKRET (1 << LUA_HOOKRET) +#define LUA_MASKLINE (1 << LUA_HOOKLINE) +#define LUA_MASKCOUNT (1 << LUA_HOOKCOUNT) + +typedef struct lua_Debug lua_Debug; /* activation record */ + + +/* Functions to be called by the debuger in specific events */ +typedef void (*lua_Hook) (lua_State *L, lua_Debug *ar); + + +LUA_API int lua_getstack (lua_State *L, int level, lua_Debug *ar); +LUA_API int lua_getinfo (lua_State *L, const char *what, lua_Debug *ar); +LUA_API const char *lua_getlocal (lua_State *L, const lua_Debug *ar, int n); +LUA_API const char *lua_setlocal (lua_State *L, const lua_Debug *ar, int n); +LUA_API const char *lua_getupvalue (lua_State *L, int funcindex, int n); +LUA_API const char *lua_setupvalue (lua_State *L, int funcindex, int n); + +LUA_API int lua_sethook (lua_State *L, lua_Hook func, int mask, int count); +LUA_API lua_Hook lua_gethook (lua_State *L); +LUA_API int lua_gethookmask (lua_State *L); +LUA_API int lua_gethookcount (lua_State *L); + + +struct lua_Debug { + int event; + const char *name; /* (n) */ + const char *namewhat; /* (n) `global', `local', `field', `method' */ + const char *what; /* (S) `Lua', `C', `main', `tail' */ + const char *source; /* (S) */ + int currentline; /* (l) */ + int nups; /* (u) number of upvalues */ + int linedefined; /* (S) */ + int lastlinedefined; /* (S) */ + char short_src[LUA_IDSIZE]; /* (S) */ + /* private part */ + int i_ci; /* active function */ +}; + +/* }====================================================================== */ + + +/****************************************************************************** +* Copyright (C) 1994-2008 Lua.org, PUC-Rio. All rights reserved. +* +* Permission is hereby granted, free of charge, to any person obtaining +* a copy of this software and associated documentation files (the +* "Software"), to deal in the Software without restriction, including +* without limitation the rights to use, copy, modify, merge, publish, +* distribute, sublicense, and/or sell copies of the Software, and to +* permit persons to whom the Software is furnished to do so, subject to +* the following conditions: +* +* The above copyright notice and this permission notice shall be +* included in all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +******************************************************************************/ + + +#endif diff --git a/include/lua/Makefile b/include/lua/Makefile new file mode 100644 index 0000000..5518ad8 --- /dev/null +++ b/include/lua/Makefile @@ -0,0 +1,182 @@ +# makefile for building Lua +# see ../INSTALL for installation instructions +# see ../Makefile and luaconf.h for further customization + +# == CHANGE THE SETTINGS BELOW TO SUIT YOUR ENVIRONMENT ======================= + +# Your platform. See PLATS for possible values. +PLAT= none + +CC= gcc +CFLAGS=-w -O3 -rdynamic $(INCFLAGS) +AR= ar rcu +RANLIB= ranlib +RM= rm -f +LIBS= -lm $(MYLIBS) + +MYCFLAGS= +MYLDFLAGS= +MYLIBS= + +# == END OF USER SETTINGS. NO NEED TO CHANGE ANYTHING BELOW THIS LINE ========= + +PLATS= aix ansi bsd freebsd generic linux macosx mingw posix solaris + +LUA_A= liblua.a +CORE_O= lapi.o lcode.o ldebug.o ldo.o ldump.o lfunc.o lgc.o llex.o lmem.o \ + lobject.o lopcodes.o lparser.o lstate.o lstring.o ltable.o ltm.o \ + lundump.o lvm.o lzio.o +LIB_O= lauxlib.o lbaselib.o ldblib.o liolib.o lmathlib.o loslib.o ltablib.o \ + lstrlib.o loadlib.o linit.o + +LUA_T= lua +LUA_O= lua.o + +LUAC_T= luac +LUAC_O= luac.o print.o + +ALL_O= $(CORE_O) $(LIB_O) $(LUA_O) $(LUAC_O) +ALL_T= $(LUA_A) $(LUA_T) $(LUAC_T) +ALL_A= $(LUA_A) + +default: $(PLAT) + +all: $(ALL_T) + +o: $(ALL_O) + +a: $(ALL_A) + +$(LUA_A): $(CORE_O) $(LIB_O) + $(AR) $@ $? + $(RANLIB) $@ + +$(LUA_T): $(LUA_O) $(LUA_A) + $(CC) -o $@ $(MYLDFLAGS) $(LUA_O) $(LUA_A) $(LIBS) + +$(LUAC_T): $(LUAC_O) $(LUA_A) + $(CC) -o $@ $(MYLDFLAGS) $(LUAC_O) $(LUA_A) $(LIBS) + +clean: + $(RM) $(ALL_T) $(ALL_O) + +depend: + @$(CC) $(CFLAGS) -MM l*.c print.c + +echo: + @echo "PLAT = $(PLAT)" + @echo "CC = $(CC)" + @echo "CFLAGS = $(CFLAGS)" + @echo "AR = $(AR)" + @echo "RANLIB = $(RANLIB)" + @echo "RM = $(RM)" + @echo "MYCFLAGS = $(MYCFLAGS)" + @echo "MYLDFLAGS = $(MYLDFLAGS)" + @echo "MYLIBS = $(MYLIBS)" + +# convenience targets for popular platforms + +none: + @echo "Please choose a platform:" + @echo " $(PLATS)" + +aix: + $(MAKE) all CC="xlc" CFLAGS="-O2 -DLUA_USE_POSIX -DLUA_USE_DLOPEN" MYLIBS="-ldl" MYLDFLAGS="-brtl -bexpall" + +ansi: + $(MAKE) all MYCFLAGS=-DLUA_ANSI + +bsd: + $(MAKE) all MYCFLAGS="-DLUA_USE_POSIX -DLUA_USE_DLOPEN" MYLIBS="-Wl,-E" + +freebsd: + $(MAKE) all MYCFLAGS="-DLUA_USE_LINUX" MYLIBS="-Wl,-E -lreadline" + +generic: + $(MAKE) all MYCFLAGS= + +linux: + $(MAKE) all MYCFLAGS=-DLUA_USE_LINUX MYLIBS="-Wl,-E -ldl -lreadline -lhistory -lncurses" + +macosx: + $(MAKE) all MYCFLAGS=-DLUA_USE_LINUX MYLIBS="-lreadline" +# use this on Mac OS X 10.3- +# $(MAKE) all MYCFLAGS=-DLUA_USE_MACOSX + +mingw: + $(MAKE) "LUA_A=lua51.dll" "LUA_T=lua.exe" \ + "AR=$(CC) -shared -o" "RANLIB=strip --strip-unneeded" \ + "MYCFLAGS=-DLUA_BUILD_AS_DLL" "MYLIBS=" "MYLDFLAGS=-s" lua.exe + $(MAKE) "LUAC_T=luac.exe" luac.exe + +posix: + $(MAKE) all MYCFLAGS=-DLUA_USE_POSIX + +solaris: + $(MAKE) all MYCFLAGS="-DLUA_USE_POSIX -DLUA_USE_DLOPEN" MYLIBS="-ldl" + +# list targets that do not create files (but not all makes understand .PHONY) +.PHONY: all $(PLATS) default o a clean depend echo none + +# DO NOT DELETE + +lapi.o: lapi.c lua.h luaconf.h lapi.h lobject.h llimits.h ldebug.h \ + lstate.h ltm.h lzio.h lmem.h ldo.h lfunc.h lgc.h lstring.h ltable.h \ + lundump.h lvm.h +lauxlib.o: lauxlib.c lua.h luaconf.h lauxlib.h +lbaselib.o: lbaselib.c lua.h luaconf.h lauxlib.h lualib.h +lcode.o: lcode.c lua.h luaconf.h lcode.h llex.h lobject.h llimits.h \ + lzio.h lmem.h lopcodes.h lparser.h ldebug.h lstate.h ltm.h ldo.h lgc.h \ + ltable.h +ldblib.o: ldblib.c lua.h luaconf.h lauxlib.h lualib.h +ldebug.o: ldebug.c lua.h luaconf.h lapi.h lobject.h llimits.h lcode.h \ + llex.h lzio.h lmem.h lopcodes.h lparser.h ldebug.h lstate.h ltm.h ldo.h \ + lfunc.h lstring.h lgc.h ltable.h lvm.h +ldo.o: ldo.c lua.h luaconf.h ldebug.h lstate.h lobject.h llimits.h ltm.h \ + lzio.h lmem.h ldo.h lfunc.h lgc.h lopcodes.h lparser.h lstring.h \ + ltable.h lundump.h lvm.h +ldump.o: ldump.c lua.h luaconf.h lobject.h llimits.h lstate.h ltm.h \ + lzio.h lmem.h lundump.h +lfunc.o: lfunc.c lua.h luaconf.h lfunc.h lobject.h llimits.h lgc.h lmem.h \ + lstate.h ltm.h lzio.h +lgc.o: lgc.c lua.h luaconf.h ldebug.h lstate.h lobject.h llimits.h ltm.h \ + lzio.h lmem.h ldo.h lfunc.h lgc.h lstring.h ltable.h +linit.o: linit.c lua.h luaconf.h lualib.h lauxlib.h +liolib.o: liolib.c lua.h luaconf.h lauxlib.h lualib.h +llex.o: llex.c lua.h luaconf.h ldo.h lobject.h llimits.h lstate.h ltm.h \ + lzio.h lmem.h llex.h lparser.h lstring.h lgc.h ltable.h +lmathlib.o: lmathlib.c lua.h luaconf.h lauxlib.h lualib.h +lmem.o: lmem.c lua.h luaconf.h ldebug.h lstate.h lobject.h llimits.h \ + ltm.h lzio.h lmem.h ldo.h +loadlib.o: loadlib.c lua.h luaconf.h lauxlib.h lualib.h +lobject.o: lobject.c lua.h luaconf.h ldo.h lobject.h llimits.h lstate.h \ + ltm.h lzio.h lmem.h lstring.h lgc.h lvm.h +lopcodes.o: lopcodes.c lopcodes.h llimits.h lua.h luaconf.h +loslib.o: loslib.c lua.h luaconf.h lauxlib.h lualib.h +lparser.o: lparser.c lua.h luaconf.h lcode.h llex.h lobject.h llimits.h \ + lzio.h lmem.h lopcodes.h lparser.h ldebug.h lstate.h ltm.h ldo.h \ + lfunc.h lstring.h lgc.h ltable.h +lstate.o: lstate.c lua.h luaconf.h ldebug.h lstate.h lobject.h llimits.h \ + ltm.h lzio.h lmem.h ldo.h lfunc.h lgc.h llex.h lstring.h ltable.h +lstring.o: lstring.c lua.h luaconf.h lmem.h llimits.h lobject.h lstate.h \ + ltm.h lzio.h lstring.h lgc.h +lstrlib.o: lstrlib.c lua.h luaconf.h lauxlib.h lualib.h +ltable.o: ltable.c lua.h luaconf.h ldebug.h lstate.h lobject.h llimits.h \ + ltm.h lzio.h lmem.h ldo.h lgc.h ltable.h +ltablib.o: ltablib.c lua.h luaconf.h lauxlib.h lualib.h +ltm.o: ltm.c lua.h luaconf.h lobject.h llimits.h lstate.h ltm.h lzio.h \ + lmem.h lstring.h lgc.h ltable.h +lua.o: lua.c lua.h luaconf.h lauxlib.h lualib.h +luac.o: luac.c lua.h luaconf.h lauxlib.h ldo.h lobject.h llimits.h \ + lstate.h ltm.h lzio.h lmem.h lfunc.h lopcodes.h lstring.h lgc.h \ + lundump.h +lundump.o: lundump.c lua.h luaconf.h ldebug.h lstate.h lobject.h \ + llimits.h ltm.h lzio.h lmem.h ldo.h lfunc.h lstring.h lgc.h lundump.h +lvm.o: lvm.c lua.h luaconf.h ldebug.h lstate.h lobject.h llimits.h ltm.h \ + lzio.h lmem.h ldo.h lfunc.h lgc.h lopcodes.h lstring.h ltable.h lvm.h +lzio.o: lzio.c lua.h luaconf.h llimits.h lmem.h lstate.h lobject.h ltm.h \ + lzio.h +print.o: print.c ldebug.h lstate.h lua.h luaconf.h lobject.h llimits.h \ + ltm.h lzio.h lmem.h lopcodes.h lundump.h + +# (end of Makefile) diff --git a/include/lua/lapi.c b/include/lua/lapi.c new file mode 100644 index 0000000..5d5145d --- /dev/null +++ b/include/lua/lapi.c @@ -0,0 +1,1087 @@ +/* +** $Id: lapi.c,v 2.55.1.5 2008/07/04 18:41:18 roberto Exp $ +** Lua API +** See Copyright Notice in lua.h +*/ + + +#include +#include +#include +#include + +#define lapi_c +#define LUA_CORE + +#include "lua.h" + +#include "lapi.h" +#include "ldebug.h" +#include "ldo.h" +#include "lfunc.h" +#include "lgc.h" +#include "lmem.h" +#include "lobject.h" +#include "lstate.h" +#include "lstring.h" +#include "ltable.h" +#include "ltm.h" +#include "lundump.h" +#include "lvm.h" + + + +const char lua_ident[] = + "$Lua: " LUA_RELEASE " " LUA_COPYRIGHT " $\n" + "$Authors: " LUA_AUTHORS " $\n" + "$URL: www.lua.org $\n"; + + + +#define api_checknelems(L, n) api_check(L, (n) <= (L->top - L->base)) + +#define api_checkvalidindex(L, i) api_check(L, (i) != luaO_nilobject) + +#define api_incr_top(L) {api_check(L, L->top < L->ci->top); L->top++;} + + + +static TValue *index2adr (lua_State *L, int idx) { + if (idx > 0) { + TValue *o = L->base + (idx - 1); + api_check(L, idx <= L->ci->top - L->base); + if (o >= L->top) return cast(TValue *, luaO_nilobject); + else return o; + } + else if (idx > LUA_REGISTRYINDEX) { + api_check(L, idx != 0 && -idx <= L->top - L->base); + return L->top + idx; + } + else switch (idx) { /* pseudo-indices */ + case LUA_REGISTRYINDEX: return registry(L); + case LUA_ENVIRONINDEX: { + Closure *func = curr_func(L); + sethvalue(L, &L->env, func->c.env); + return &L->env; + } + case LUA_GLOBALSINDEX: return gt(L); + default: { + Closure *func = curr_func(L); + idx = LUA_GLOBALSINDEX - idx; + return (idx <= func->c.nupvalues) + ? &func->c.upvalue[idx-1] + : cast(TValue *, luaO_nilobject); + } + } +} + + +static Table *getcurrenv (lua_State *L) { + if (L->ci == L->base_ci) /* no enclosing function? */ + return hvalue(gt(L)); /* use global table as environment */ + else { + Closure *func = curr_func(L); + return func->c.env; + } +} + + +void luaA_pushobject (lua_State *L, const TValue *o) { + setobj2s(L, L->top, o); + api_incr_top(L); +} + + +LUA_API int lua_checkstack (lua_State *L, int size) { + int res = 1; + lua_lock(L); + if (size > LUAI_MAXCSTACK || (L->top - L->base + size) > LUAI_MAXCSTACK) + res = 0; /* stack overflow */ + else if (size > 0) { + luaD_checkstack(L, size); + if (L->ci->top < L->top + size) + L->ci->top = L->top + size; + } + lua_unlock(L); + return res; +} + + +LUA_API void lua_xmove (lua_State *from, lua_State *to, int n) { + int i; + if (from == to) return; + lua_lock(to); + api_checknelems(from, n); + api_check(from, G(from) == G(to)); + api_check(from, to->ci->top - to->top >= n); + from->top -= n; + for (i = 0; i < n; i++) { + setobj2s(to, to->top++, from->top + i); + } + lua_unlock(to); +} + + +LUA_API void lua_setlevel (lua_State *from, lua_State *to) { + to->nCcalls = from->nCcalls; +} + + +LUA_API lua_CFunction lua_atpanic (lua_State *L, lua_CFunction panicf) { + lua_CFunction old; + lua_lock(L); + old = G(L)->panic; + G(L)->panic = panicf; + lua_unlock(L); + return old; +} + + +LUA_API lua_State *lua_newthread (lua_State *L) { + lua_State *L1; + lua_lock(L); + luaC_checkGC(L); + L1 = luaE_newthread(L); + setthvalue(L, L->top, L1); + api_incr_top(L); + lua_unlock(L); + luai_userstatethread(L, L1); + return L1; +} + + + +/* +** basic stack manipulation +*/ + + +LUA_API int lua_gettop (lua_State *L) { + return cast_int(L->top - L->base); +} + + +LUA_API void lua_settop (lua_State *L, int idx) { + lua_lock(L); + if (idx >= 0) { + api_check(L, idx <= L->stack_last - L->base); + while (L->top < L->base + idx) + setnilvalue(L->top++); + L->top = L->base + idx; + } + else { + api_check(L, -(idx+1) <= (L->top - L->base)); + L->top += idx+1; /* `subtract' index (index is negative) */ + } + lua_unlock(L); +} + + +LUA_API void lua_remove (lua_State *L, int idx) { + StkId p; + lua_lock(L); + p = index2adr(L, idx); + api_checkvalidindex(L, p); + while (++p < L->top) setobjs2s(L, p-1, p); + L->top--; + lua_unlock(L); +} + + +LUA_API void lua_insert (lua_State *L, int idx) { + StkId p; + StkId q; + lua_lock(L); + p = index2adr(L, idx); + api_checkvalidindex(L, p); + for (q = L->top; q>p; q--) setobjs2s(L, q, q-1); + setobjs2s(L, p, L->top); + lua_unlock(L); +} + + +LUA_API void lua_replace (lua_State *L, int idx) { + StkId o; + lua_lock(L); + /* explicit test for incompatible code */ + if (idx == LUA_ENVIRONINDEX && L->ci == L->base_ci) + luaG_runerror(L, "no calling environment"); + api_checknelems(L, 1); + o = index2adr(L, idx); + api_checkvalidindex(L, o); + if (idx == LUA_ENVIRONINDEX) { + Closure *func = curr_func(L); + api_check(L, ttistable(L->top - 1)); + func->c.env = hvalue(L->top - 1); + luaC_barrier(L, func, L->top - 1); + } + else { + setobj(L, o, L->top - 1); + if (idx < LUA_GLOBALSINDEX) /* function upvalue? */ + luaC_barrier(L, curr_func(L), L->top - 1); + } + L->top--; + lua_unlock(L); +} + + +LUA_API void lua_pushvalue (lua_State *L, int idx) { + lua_lock(L); + setobj2s(L, L->top, index2adr(L, idx)); + api_incr_top(L); + lua_unlock(L); +} + + + +/* +** access functions (stack -> C) +*/ + + +LUA_API int lua_type (lua_State *L, int idx) { + StkId o = index2adr(L, idx); + return (o == luaO_nilobject) ? LUA_TNONE : ttype(o); +} + + +LUA_API const char *lua_typename (lua_State *L, int t) { + UNUSED(L); + return (t == LUA_TNONE) ? "no value" : luaT_typenames[t]; +} + + +LUA_API int lua_iscfunction (lua_State *L, int idx) { + StkId o = index2adr(L, idx); + return iscfunction(o); +} + + +LUA_API int lua_isnumber (lua_State *L, int idx) { + TValue n; + const TValue *o = index2adr(L, idx); + return tonumber(o, &n); +} + + +LUA_API int lua_isstring (lua_State *L, int idx) { + int t = lua_type(L, idx); + return (t == LUA_TSTRING || t == LUA_TNUMBER); +} + + +LUA_API int lua_isuserdata (lua_State *L, int idx) { + const TValue *o = index2adr(L, idx); + return (ttisuserdata(o) || ttislightuserdata(o)); +} + + +LUA_API int lua_rawequal (lua_State *L, int index1, int index2) { + StkId o1 = index2adr(L, index1); + StkId o2 = index2adr(L, index2); + return (o1 == luaO_nilobject || o2 == luaO_nilobject) ? 0 + : luaO_rawequalObj(o1, o2); +} + + +LUA_API int lua_equal (lua_State *L, int index1, int index2) { + StkId o1, o2; + int i; + lua_lock(L); /* may call tag method */ + o1 = index2adr(L, index1); + o2 = index2adr(L, index2); + i = (o1 == luaO_nilobject || o2 == luaO_nilobject) ? 0 : equalobj(L, o1, o2); + lua_unlock(L); + return i; +} + + +LUA_API int lua_lessthan (lua_State *L, int index1, int index2) { + StkId o1, o2; + int i; + lua_lock(L); /* may call tag method */ + o1 = index2adr(L, index1); + o2 = index2adr(L, index2); + i = (o1 == luaO_nilobject || o2 == luaO_nilobject) ? 0 + : luaV_lessthan(L, o1, o2); + lua_unlock(L); + return i; +} + + + +LUA_API lua_Number lua_tonumber (lua_State *L, int idx) { + TValue n; + const TValue *o = index2adr(L, idx); + if (tonumber(o, &n)) + return nvalue(o); + else + return 0; +} + + +LUA_API lua_Integer lua_tointeger (lua_State *L, int idx) { + TValue n; + const TValue *o = index2adr(L, idx); + if (tonumber(o, &n)) { + lua_Integer res; + lua_Number num = nvalue(o); + lua_number2integer(res, num); + return res; + } + else + return 0; +} + + +LUA_API int lua_toboolean (lua_State *L, int idx) { + const TValue *o = index2adr(L, idx); + return !l_isfalse(o); +} + + +LUA_API const char *lua_tolstring (lua_State *L, int idx, size_t *len) { + StkId o = index2adr(L, idx); + if (!ttisstring(o)) { + lua_lock(L); /* `luaV_tostring' may create a new string */ + if (!luaV_tostring(L, o)) { /* conversion failed? */ + if (len != NULL) *len = 0; + lua_unlock(L); + return NULL; + } + luaC_checkGC(L); + o = index2adr(L, idx); /* previous call may reallocate the stack */ + lua_unlock(L); + } + if (len != NULL) *len = tsvalue(o)->len; + return svalue(o); +} + + +LUA_API size_t lua_objlen (lua_State *L, int idx) { + StkId o = index2adr(L, idx); + switch (ttype(o)) { + case LUA_TSTRING: return tsvalue(o)->len; + case LUA_TUSERDATA: return uvalue(o)->len; + case LUA_TTABLE: return luaH_getn(hvalue(o)); + case LUA_TNUMBER: { + size_t l; + lua_lock(L); /* `luaV_tostring' may create a new string */ + l = (luaV_tostring(L, o) ? tsvalue(o)->len : 0); + lua_unlock(L); + return l; + } + default: return 0; + } +} + + +LUA_API lua_CFunction lua_tocfunction (lua_State *L, int idx) { + StkId o = index2adr(L, idx); + return (!iscfunction(o)) ? NULL : clvalue(o)->c.f; +} + + +LUA_API void *lua_touserdata (lua_State *L, int idx) { + StkId o = index2adr(L, idx); + switch (ttype(o)) { + case LUA_TUSERDATA: return (rawuvalue(o) + 1); + case LUA_TLIGHTUSERDATA: return pvalue(o); + default: return NULL; + } +} + + +LUA_API lua_State *lua_tothread (lua_State *L, int idx) { + StkId o = index2adr(L, idx); + return (!ttisthread(o)) ? NULL : thvalue(o); +} + + +LUA_API const void *lua_topointer (lua_State *L, int idx) { + StkId o = index2adr(L, idx); + switch (ttype(o)) { + case LUA_TTABLE: return hvalue(o); + case LUA_TFUNCTION: return clvalue(o); + case LUA_TTHREAD: return thvalue(o); + case LUA_TUSERDATA: + case LUA_TLIGHTUSERDATA: + return lua_touserdata(L, idx); + default: return NULL; + } +} + + + +/* +** push functions (C -> stack) +*/ + + +LUA_API void lua_pushnil (lua_State *L) { + lua_lock(L); + setnilvalue(L->top); + api_incr_top(L); + lua_unlock(L); +} + + +LUA_API void lua_pushnumber (lua_State *L, lua_Number n) { + lua_lock(L); + setnvalue(L->top, n); + api_incr_top(L); + lua_unlock(L); +} + + +LUA_API void lua_pushinteger (lua_State *L, lua_Integer n) { + lua_lock(L); + setnvalue(L->top, cast_num(n)); + api_incr_top(L); + lua_unlock(L); +} + + +LUA_API void lua_pushlstring (lua_State *L, const char *s, size_t len) { + lua_lock(L); + luaC_checkGC(L); + setsvalue2s(L, L->top, luaS_newlstr(L, s, len)); + api_incr_top(L); + lua_unlock(L); +} + + +LUA_API void lua_pushstring (lua_State *L, const char *s) { + if (s == NULL) + lua_pushnil(L); + else + lua_pushlstring(L, s, strlen(s)); +} + + +LUA_API const char *lua_pushvfstring (lua_State *L, const char *fmt, + va_list argp) { + const char *ret; + lua_lock(L); + luaC_checkGC(L); + ret = luaO_pushvfstring(L, fmt, argp); + lua_unlock(L); + return ret; +} + + +LUA_API const char *lua_pushfstring (lua_State *L, const char *fmt, ...) { + const char *ret; + va_list argp; + lua_lock(L); + luaC_checkGC(L); + va_start(argp, fmt); + ret = luaO_pushvfstring(L, fmt, argp); + va_end(argp); + lua_unlock(L); + return ret; +} + + +LUA_API void lua_pushcclosure (lua_State *L, lua_CFunction fn, int n) { + Closure *cl; + lua_lock(L); + luaC_checkGC(L); + api_checknelems(L, n); + cl = luaF_newCclosure(L, n, getcurrenv(L)); + cl->c.f = fn; + L->top -= n; + while (n--) + setobj2n(L, &cl->c.upvalue[n], L->top+n); + setclvalue(L, L->top, cl); + lua_assert(iswhite(obj2gco(cl))); + api_incr_top(L); + lua_unlock(L); +} + + +LUA_API void lua_pushboolean (lua_State *L, int b) { + lua_lock(L); + setbvalue(L->top, (b != 0)); /* ensure that true is 1 */ + api_incr_top(L); + lua_unlock(L); +} + + +LUA_API void lua_pushlightuserdata (lua_State *L, void *p) { + lua_lock(L); + setpvalue(L->top, p); + api_incr_top(L); + lua_unlock(L); +} + + +LUA_API int lua_pushthread (lua_State *L) { + lua_lock(L); + setthvalue(L, L->top, L); + api_incr_top(L); + lua_unlock(L); + return (G(L)->mainthread == L); +} + + + +/* +** get functions (Lua -> stack) +*/ + + +LUA_API void lua_gettable (lua_State *L, int idx) { + StkId t; + lua_lock(L); + t = index2adr(L, idx); + api_checkvalidindex(L, t); + luaV_gettable(L, t, L->top - 1, L->top - 1); + lua_unlock(L); +} + + +LUA_API void lua_getfield (lua_State *L, int idx, const char *k) { + StkId t; + TValue key; + lua_lock(L); + t = index2adr(L, idx); + api_checkvalidindex(L, t); + setsvalue(L, &key, luaS_new(L, k)); + luaV_gettable(L, t, &key, L->top); + api_incr_top(L); + lua_unlock(L); +} + + +LUA_API void lua_rawget (lua_State *L, int idx) { + StkId t; + lua_lock(L); + t = index2adr(L, idx); + api_check(L, ttistable(t)); + setobj2s(L, L->top - 1, luaH_get(hvalue(t), L->top - 1)); + lua_unlock(L); +} + + +LUA_API void lua_rawgeti (lua_State *L, int idx, int n) { + StkId o; + lua_lock(L); + o = index2adr(L, idx); + api_check(L, ttistable(o)); + setobj2s(L, L->top, luaH_getnum(hvalue(o), n)); + api_incr_top(L); + lua_unlock(L); +} + + +LUA_API void lua_createtable (lua_State *L, int narray, int nrec) { + lua_lock(L); + luaC_checkGC(L); + sethvalue(L, L->top, luaH_new(L, narray, nrec)); + api_incr_top(L); + lua_unlock(L); +} + + +LUA_API int lua_getmetatable (lua_State *L, int objindex) { + const TValue *obj; + Table *mt = NULL; + int res; + lua_lock(L); + obj = index2adr(L, objindex); + switch (ttype(obj)) { + case LUA_TTABLE: + mt = hvalue(obj)->metatable; + break; + case LUA_TUSERDATA: + mt = uvalue(obj)->metatable; + break; + default: + mt = G(L)->mt[ttype(obj)]; + break; + } + if (mt == NULL) + res = 0; + else { + sethvalue(L, L->top, mt); + api_incr_top(L); + res = 1; + } + lua_unlock(L); + return res; +} + + +LUA_API void lua_getfenv (lua_State *L, int idx) { + StkId o; + lua_lock(L); + o = index2adr(L, idx); + api_checkvalidindex(L, o); + switch (ttype(o)) { + case LUA_TFUNCTION: + sethvalue(L, L->top, clvalue(o)->c.env); + break; + case LUA_TUSERDATA: + sethvalue(L, L->top, uvalue(o)->env); + break; + case LUA_TTHREAD: + setobj2s(L, L->top, gt(thvalue(o))); + break; + default: + setnilvalue(L->top); + break; + } + api_incr_top(L); + lua_unlock(L); +} + + +/* +** set functions (stack -> Lua) +*/ + + +LUA_API void lua_settable (lua_State *L, int idx) { + StkId t; + lua_lock(L); + api_checknelems(L, 2); + t = index2adr(L, idx); + api_checkvalidindex(L, t); + luaV_settable(L, t, L->top - 2, L->top - 1); + L->top -= 2; /* pop index and value */ + lua_unlock(L); +} + + +LUA_API void lua_setfield (lua_State *L, int idx, const char *k) { + StkId t; + TValue key; + lua_lock(L); + api_checknelems(L, 1); + t = index2adr(L, idx); + api_checkvalidindex(L, t); + setsvalue(L, &key, luaS_new(L, k)); + luaV_settable(L, t, &key, L->top - 1); + L->top--; /* pop value */ + lua_unlock(L); +} + + +LUA_API void lua_rawset (lua_State *L, int idx) { + StkId t; + lua_lock(L); + api_checknelems(L, 2); + t = index2adr(L, idx); + api_check(L, ttistable(t)); + setobj2t(L, luaH_set(L, hvalue(t), L->top-2), L->top-1); + luaC_barriert(L, hvalue(t), L->top-1); + L->top -= 2; + lua_unlock(L); +} + + +LUA_API void lua_rawseti (lua_State *L, int idx, int n) { + StkId o; + lua_lock(L); + api_checknelems(L, 1); + o = index2adr(L, idx); + api_check(L, ttistable(o)); + setobj2t(L, luaH_setnum(L, hvalue(o), n), L->top-1); + luaC_barriert(L, hvalue(o), L->top-1); + L->top--; + lua_unlock(L); +} + + +LUA_API int lua_setmetatable (lua_State *L, int objindex) { + TValue *obj; + Table *mt; + lua_lock(L); + api_checknelems(L, 1); + obj = index2adr(L, objindex); + api_checkvalidindex(L, obj); + if (ttisnil(L->top - 1)) + mt = NULL; + else { + api_check(L, ttistable(L->top - 1)); + mt = hvalue(L->top - 1); + } + switch (ttype(obj)) { + case LUA_TTABLE: { + hvalue(obj)->metatable = mt; + if (mt) + luaC_objbarriert(L, hvalue(obj), mt); + break; + } + case LUA_TUSERDATA: { + uvalue(obj)->metatable = mt; + if (mt) + luaC_objbarrier(L, rawuvalue(obj), mt); + break; + } + default: { + G(L)->mt[ttype(obj)] = mt; + break; + } + } + L->top--; + lua_unlock(L); + return 1; +} + + +LUA_API int lua_setfenv (lua_State *L, int idx) { + StkId o; + int res = 1; + lua_lock(L); + api_checknelems(L, 1); + o = index2adr(L, idx); + api_checkvalidindex(L, o); + api_check(L, ttistable(L->top - 1)); + switch (ttype(o)) { + case LUA_TFUNCTION: + clvalue(o)->c.env = hvalue(L->top - 1); + break; + case LUA_TUSERDATA: + uvalue(o)->env = hvalue(L->top - 1); + break; + case LUA_TTHREAD: + sethvalue(L, gt(thvalue(o)), hvalue(L->top - 1)); + break; + default: + res = 0; + break; + } + if (res) luaC_objbarrier(L, gcvalue(o), hvalue(L->top - 1)); + L->top--; + lua_unlock(L); + return res; +} + + +/* +** `load' and `call' functions (run Lua code) +*/ + + +#define adjustresults(L,nres) \ + { if (nres == LUA_MULTRET && L->top >= L->ci->top) L->ci->top = L->top; } + + +#define checkresults(L,na,nr) \ + api_check(L, (nr) == LUA_MULTRET || (L->ci->top - L->top >= (nr) - (na))) + + +LUA_API void lua_call (lua_State *L, int nargs, int nresults) { + StkId func; + lua_lock(L); + api_checknelems(L, nargs+1); + checkresults(L, nargs, nresults); + func = L->top - (nargs+1); + luaD_call(L, func, nresults); + adjustresults(L, nresults); + lua_unlock(L); +} + + + +/* +** Execute a protected call. +*/ +struct CallS { /* data to `f_call' */ + StkId func; + int nresults; +}; + + +static void f_call (lua_State *L, void *ud) { + struct CallS *c = cast(struct CallS *, ud); + luaD_call(L, c->func, c->nresults); +} + + + +LUA_API int lua_pcall (lua_State *L, int nargs, int nresults, int errfunc) { + struct CallS c; + int status; + ptrdiff_t func; + lua_lock(L); + api_checknelems(L, nargs+1); + checkresults(L, nargs, nresults); + if (errfunc == 0) + func = 0; + else { + StkId o = index2adr(L, errfunc); + api_checkvalidindex(L, o); + func = savestack(L, o); + } + c.func = L->top - (nargs+1); /* function to be called */ + c.nresults = nresults; + status = luaD_pcall(L, f_call, &c, savestack(L, c.func), func); + adjustresults(L, nresults); + lua_unlock(L); + return status; +} + + +/* +** Execute a protected C call. +*/ +struct CCallS { /* data to `f_Ccall' */ + lua_CFunction func; + void *ud; +}; + + +static void f_Ccall (lua_State *L, void *ud) { + struct CCallS *c = cast(struct CCallS *, ud); + Closure *cl; + cl = luaF_newCclosure(L, 0, getcurrenv(L)); + cl->c.f = c->func; + setclvalue(L, L->top, cl); /* push function */ + api_incr_top(L); + setpvalue(L->top, c->ud); /* push only argument */ + api_incr_top(L); + luaD_call(L, L->top - 2, 0); +} + + +LUA_API int lua_cpcall (lua_State *L, lua_CFunction func, void *ud) { + struct CCallS c; + int status; + lua_lock(L); + c.func = func; + c.ud = ud; + status = luaD_pcall(L, f_Ccall, &c, savestack(L, L->top), 0); + lua_unlock(L); + return status; +} + + +LUA_API int lua_load (lua_State *L, lua_Reader reader, void *data, + const char *chunkname) { + ZIO z; + int status; + lua_lock(L); + if (!chunkname) chunkname = "?"; + luaZ_init(L, &z, reader, data); + status = luaD_protectedparser(L, &z, chunkname); + lua_unlock(L); + return status; +} + + +LUA_API int lua_dump (lua_State *L, lua_Writer writer, void *data) { + int status; + TValue *o; + lua_lock(L); + api_checknelems(L, 1); + o = L->top - 1; + if (isLfunction(o)) + status = luaU_dump(L, clvalue(o)->l.p, writer, data, 0); + else + status = 1; + lua_unlock(L); + return status; +} + + +LUA_API int lua_status (lua_State *L) { + return L->status; +} + + +/* +** Garbage-collection function +*/ + +LUA_API int lua_gc (lua_State *L, int what, int data) { + int res = 0; + global_State *g; + lua_lock(L); + g = G(L); + switch (what) { + case LUA_GCSTOP: { + g->GCthreshold = MAX_LUMEM; + break; + } + case LUA_GCRESTART: { + g->GCthreshold = g->totalbytes; + break; + } + case LUA_GCCOLLECT: { + luaC_fullgc(L); + break; + } + case LUA_GCCOUNT: { + /* GC values are expressed in Kbytes: #bytes/2^10 */ + res = cast_int(g->totalbytes >> 10); + break; + } + case LUA_GCCOUNTB: { + res = cast_int(g->totalbytes & 0x3ff); + break; + } + case LUA_GCSTEP: { + lu_mem a = (cast(lu_mem, data) << 10); + if (a <= g->totalbytes) + g->GCthreshold = g->totalbytes - a; + else + g->GCthreshold = 0; + while (g->GCthreshold <= g->totalbytes) { + luaC_step(L); + if (g->gcstate == GCSpause) { /* end of cycle? */ + res = 1; /* signal it */ + break; + } + } + break; + } + case LUA_GCSETPAUSE: { + res = g->gcpause; + g->gcpause = data; + break; + } + case LUA_GCSETSTEPMUL: { + res = g->gcstepmul; + g->gcstepmul = data; + break; + } + default: res = -1; /* invalid option */ + } + lua_unlock(L); + return res; +} + + + +/* +** miscellaneous functions +*/ + + +LUA_API int lua_error (lua_State *L) { + lua_lock(L); + api_checknelems(L, 1); + luaG_errormsg(L); + lua_unlock(L); + return 0; /* to avoid warnings */ +} + + +LUA_API int lua_next (lua_State *L, int idx) { + StkId t; + int more; + lua_lock(L); + t = index2adr(L, idx); + api_check(L, ttistable(t)); + more = luaH_next(L, hvalue(t), L->top - 1); + if (more) { + api_incr_top(L); + } + else /* no more elements */ + L->top -= 1; /* remove key */ + lua_unlock(L); + return more; +} + + +LUA_API void lua_concat (lua_State *L, int n) { + lua_lock(L); + api_checknelems(L, n); + if (n >= 2) { + luaC_checkGC(L); + luaV_concat(L, n, cast_int(L->top - L->base) - 1); + L->top -= (n-1); + } + else if (n == 0) { /* push empty string */ + setsvalue2s(L, L->top, luaS_newlstr(L, "", 0)); + api_incr_top(L); + } + /* else n == 1; nothing to do */ + lua_unlock(L); +} + + +LUA_API lua_Alloc lua_getallocf (lua_State *L, void **ud) { + lua_Alloc f; + lua_lock(L); + if (ud) *ud = G(L)->ud; + f = G(L)->frealloc; + lua_unlock(L); + return f; +} + + +LUA_API void lua_setallocf (lua_State *L, lua_Alloc f, void *ud) { + lua_lock(L); + G(L)->ud = ud; + G(L)->frealloc = f; + lua_unlock(L); +} + + +LUA_API void *lua_newuserdata (lua_State *L, size_t size) { + Udata *u; + lua_lock(L); + luaC_checkGC(L); + u = luaS_newudata(L, size, getcurrenv(L)); + setuvalue(L, L->top, u); + api_incr_top(L); + lua_unlock(L); + return u + 1; +} + + + + +static const char *aux_upvalue (StkId fi, int n, TValue **val) { + Closure *f; + if (!ttisfunction(fi)) return NULL; + f = clvalue(fi); + if (f->c.isC) { + if (!(1 <= n && n <= f->c.nupvalues)) return NULL; + *val = &f->c.upvalue[n-1]; + return ""; + } + else { + Proto *p = f->l.p; + if (!(1 <= n && n <= p->sizeupvalues)) return NULL; + *val = f->l.upvals[n-1]->v; + return getstr(p->upvalues[n-1]); + } +} + + +LUA_API const char *lua_getupvalue (lua_State *L, int funcindex, int n) { + const char *name; + TValue *val; + lua_lock(L); + name = aux_upvalue(index2adr(L, funcindex), n, &val); + if (name) { + setobj2s(L, L->top, val); + api_incr_top(L); + } + lua_unlock(L); + return name; +} + + +LUA_API const char *lua_setupvalue (lua_State *L, int funcindex, int n) { + const char *name; + TValue *val; + StkId fi; + lua_lock(L); + fi = index2adr(L, funcindex); + api_checknelems(L, 1); + name = aux_upvalue(fi, n, &val); + if (name) { + L->top--; + setobj(L, val, L->top); + luaC_barrier(L, clvalue(fi), L->top); + } + lua_unlock(L); + return name; +} + diff --git a/include/lua/lapi.h b/include/lua/lapi.h new file mode 100644 index 0000000..2c3fab2 --- /dev/null +++ b/include/lua/lapi.h @@ -0,0 +1,16 @@ +/* +** $Id: lapi.h,v 2.2.1.1 2007/12/27 13:02:25 roberto Exp $ +** Auxiliary functions from Lua API +** See Copyright Notice in lua.h +*/ + +#ifndef lapi_h +#define lapi_h + + +#include "lobject.h" + + +LUAI_FUNC void luaA_pushobject (lua_State *L, const TValue *o); + +#endif diff --git a/include/lua/lauxlib.c b/include/lua/lauxlib.c new file mode 100644 index 0000000..10f14e2 --- /dev/null +++ b/include/lua/lauxlib.c @@ -0,0 +1,652 @@ +/* +** $Id: lauxlib.c,v 1.159.1.3 2008/01/21 13:20:51 roberto Exp $ +** Auxiliary functions for building Lua libraries +** See Copyright Notice in lua.h +*/ + + +#include +#include +#include +#include +#include +#include + + +/* This file uses only the official API of Lua. +** Any function declared here could be written as an application function. +*/ + +#define lauxlib_c +#define LUA_LIB + +#include "lua.h" + +#include "lauxlib.h" + + +#define FREELIST_REF 0 /* free list of references */ + + +/* convert a stack index to positive */ +#define abs_index(L, i) ((i) > 0 || (i) <= LUA_REGISTRYINDEX ? (i) : \ + lua_gettop(L) + (i) + 1) + + +/* +** {====================================================== +** Error-report functions +** ======================================================= +*/ + + +LUALIB_API int luaL_argerror (lua_State *L, int narg, const char *extramsg) { + lua_Debug ar; + if (!lua_getstack(L, 0, &ar)) /* no stack frame? */ + return luaL_error(L, "bad argument #%d (%s)", narg, extramsg); + lua_getinfo(L, "n", &ar); + if (strcmp(ar.namewhat, "method") == 0) { + narg--; /* do not count `self' */ + if (narg == 0) /* error is in the self argument itself? */ + return luaL_error(L, "calling " LUA_QS " on bad self (%s)", + ar.name, extramsg); + } + if (ar.name == NULL) + ar.name = "?"; + return luaL_error(L, "bad argument #%d to " LUA_QS " (%s)", + narg, ar.name, extramsg); +} + + +LUALIB_API int luaL_typerror (lua_State *L, int narg, const char *tname) { + const char *msg = lua_pushfstring(L, "%s expected, got %s", + tname, luaL_typename(L, narg)); + return luaL_argerror(L, narg, msg); +} + + +static void tag_error (lua_State *L, int narg, int tag) { + luaL_typerror(L, narg, lua_typename(L, tag)); +} + + +LUALIB_API void luaL_where (lua_State *L, int level) { + lua_Debug ar; + if (lua_getstack(L, level, &ar)) { /* check function at level */ + lua_getinfo(L, "Sl", &ar); /* get info about it */ + if (ar.currentline > 0) { /* is there info? */ + lua_pushfstring(L, "%s:%d: ", ar.short_src, ar.currentline); + return; + } + } + lua_pushliteral(L, ""); /* else, no information available... */ +} + + +LUALIB_API int luaL_error (lua_State *L, const char *fmt, ...) { + va_list argp; + va_start(argp, fmt); + luaL_where(L, 1); + lua_pushvfstring(L, fmt, argp); + va_end(argp); + lua_concat(L, 2); + return lua_error(L); +} + +/* }====================================================== */ + + +LUALIB_API int luaL_checkoption (lua_State *L, int narg, const char *def, + const char *const lst[]) { + const char *name = (def) ? luaL_optstring(L, narg, def) : + luaL_checkstring(L, narg); + int i; + for (i=0; lst[i]; i++) + if (strcmp(lst[i], name) == 0) + return i; + return luaL_argerror(L, narg, + lua_pushfstring(L, "invalid option " LUA_QS, name)); +} + + +LUALIB_API int luaL_newmetatable (lua_State *L, const char *tname) { + lua_getfield(L, LUA_REGISTRYINDEX, tname); /* get registry.name */ + if (!lua_isnil(L, -1)) /* name already in use? */ + return 0; /* leave previous value on top, but return 0 */ + lua_pop(L, 1); + lua_newtable(L); /* create metatable */ + lua_pushvalue(L, -1); + lua_setfield(L, LUA_REGISTRYINDEX, tname); /* registry.name = metatable */ + return 1; +} + + +LUALIB_API void *luaL_checkudata (lua_State *L, int ud, const char *tname) { + void *p = lua_touserdata(L, ud); + if (p != NULL) { /* value is a userdata? */ + if (lua_getmetatable(L, ud)) { /* does it have a metatable? */ + lua_getfield(L, LUA_REGISTRYINDEX, tname); /* get correct metatable */ + if (lua_rawequal(L, -1, -2)) { /* does it have the correct mt? */ + lua_pop(L, 2); /* remove both metatables */ + return p; + } + } + } + luaL_typerror(L, ud, tname); /* else error */ + return NULL; /* to avoid warnings */ +} + + +LUALIB_API void luaL_checkstack (lua_State *L, int space, const char *mes) { + if (!lua_checkstack(L, space)) + luaL_error(L, "stack overflow (%s)", mes); +} + + +LUALIB_API void luaL_checktype (lua_State *L, int narg, int t) { + if (lua_type(L, narg) != t) + tag_error(L, narg, t); +} + + +LUALIB_API void luaL_checkany (lua_State *L, int narg) { + if (lua_type(L, narg) == LUA_TNONE) + luaL_argerror(L, narg, "value expected"); +} + + +LUALIB_API const char *luaL_checklstring (lua_State *L, int narg, size_t *len) { + const char *s = lua_tolstring(L, narg, len); + if (!s) tag_error(L, narg, LUA_TSTRING); + return s; +} + + +LUALIB_API const char *luaL_optlstring (lua_State *L, int narg, + const char *def, size_t *len) { + if (lua_isnoneornil(L, narg)) { + if (len) + *len = (def ? strlen(def) : 0); + return def; + } + else return luaL_checklstring(L, narg, len); +} + + +LUALIB_API lua_Number luaL_checknumber (lua_State *L, int narg) { + lua_Number d = lua_tonumber(L, narg); + if (d == 0 && !lua_isnumber(L, narg)) /* avoid extra test when d is not 0 */ + tag_error(L, narg, LUA_TNUMBER); + return d; +} + + +LUALIB_API lua_Number luaL_optnumber (lua_State *L, int narg, lua_Number def) { + return luaL_opt(L, luaL_checknumber, narg, def); +} + + +LUALIB_API lua_Integer luaL_checkinteger (lua_State *L, int narg) { + lua_Integer d = lua_tointeger(L, narg); + if (d == 0 && !lua_isnumber(L, narg)) /* avoid extra test when d is not 0 */ + tag_error(L, narg, LUA_TNUMBER); + return d; +} + + +LUALIB_API lua_Integer luaL_optinteger (lua_State *L, int narg, + lua_Integer def) { + return luaL_opt(L, luaL_checkinteger, narg, def); +} + + +LUALIB_API int luaL_getmetafield (lua_State *L, int obj, const char *event) { + if (!lua_getmetatable(L, obj)) /* no metatable? */ + return 0; + lua_pushstring(L, event); + lua_rawget(L, -2); + if (lua_isnil(L, -1)) { + lua_pop(L, 2); /* remove metatable and metafield */ + return 0; + } + else { + lua_remove(L, -2); /* remove only metatable */ + return 1; + } +} + + +LUALIB_API int luaL_callmeta (lua_State *L, int obj, const char *event) { + obj = abs_index(L, obj); + if (!luaL_getmetafield(L, obj, event)) /* no metafield? */ + return 0; + lua_pushvalue(L, obj); + lua_call(L, 1, 1); + return 1; +} + + +LUALIB_API void (luaL_register) (lua_State *L, const char *libname, + const luaL_Reg *l) { + luaI_openlib(L, libname, l, 0); +} + + +static int libsize (const luaL_Reg *l) { + int size = 0; + for (; l->name; l++) size++; + return size; +} + + +LUALIB_API void luaI_openlib (lua_State *L, const char *libname, + const luaL_Reg *l, int nup) { + if (libname) { + int size = libsize(l); + /* check whether lib already exists */ + luaL_findtable(L, LUA_REGISTRYINDEX, "_LOADED", 1); + lua_getfield(L, -1, libname); /* get _LOADED[libname] */ + if (!lua_istable(L, -1)) { /* not found? */ + lua_pop(L, 1); /* remove previous result */ + /* try global variable (and create one if it does not exist) */ + if (luaL_findtable(L, LUA_GLOBALSINDEX, libname, size) != NULL) + luaL_error(L, "name conflict for module " LUA_QS, libname); + lua_pushvalue(L, -1); + lua_setfield(L, -3, libname); /* _LOADED[libname] = new table */ + } + lua_remove(L, -2); /* remove _LOADED table */ + lua_insert(L, -(nup+1)); /* move library table to below upvalues */ + } + for (; l->name; l++) { + int i; + for (i=0; ifunc, nup); + lua_setfield(L, -(nup+2), l->name); + } + lua_pop(L, nup); /* remove upvalues */ +} + + + +/* +** {====================================================== +** getn-setn: size for arrays +** ======================================================= +*/ + +#if defined(LUA_COMPAT_GETN) + +static int checkint (lua_State *L, int topop) { + int n = (lua_type(L, -1) == LUA_TNUMBER) ? lua_tointeger(L, -1) : -1; + lua_pop(L, topop); + return n; +} + + +static void getsizes (lua_State *L) { + lua_getfield(L, LUA_REGISTRYINDEX, "LUA_SIZES"); + if (lua_isnil(L, -1)) { /* no `size' table? */ + lua_pop(L, 1); /* remove nil */ + lua_newtable(L); /* create it */ + lua_pushvalue(L, -1); /* `size' will be its own metatable */ + lua_setmetatable(L, -2); + lua_pushliteral(L, "kv"); + lua_setfield(L, -2, "__mode"); /* metatable(N).__mode = "kv" */ + lua_pushvalue(L, -1); + lua_setfield(L, LUA_REGISTRYINDEX, "LUA_SIZES"); /* store in register */ + } +} + + +LUALIB_API void luaL_setn (lua_State *L, int t, int n) { + t = abs_index(L, t); + lua_pushliteral(L, "n"); + lua_rawget(L, t); + if (checkint(L, 1) >= 0) { /* is there a numeric field `n'? */ + lua_pushliteral(L, "n"); /* use it */ + lua_pushinteger(L, n); + lua_rawset(L, t); + } + else { /* use `sizes' */ + getsizes(L); + lua_pushvalue(L, t); + lua_pushinteger(L, n); + lua_rawset(L, -3); /* sizes[t] = n */ + lua_pop(L, 1); /* remove `sizes' */ + } +} + + +LUALIB_API int luaL_getn (lua_State *L, int t) { + int n; + t = abs_index(L, t); + lua_pushliteral(L, "n"); /* try t.n */ + lua_rawget(L, t); + if ((n = checkint(L, 1)) >= 0) return n; + getsizes(L); /* else try sizes[t] */ + lua_pushvalue(L, t); + lua_rawget(L, -2); + if ((n = checkint(L, 2)) >= 0) return n; + return (int)lua_objlen(L, t); +} + +#endif + +/* }====================================================== */ + + + +LUALIB_API const char *luaL_gsub (lua_State *L, const char *s, const char *p, + const char *r) { + const char *wild; + size_t l = strlen(p); + luaL_Buffer b; + luaL_buffinit(L, &b); + while ((wild = strstr(s, p)) != NULL) { + luaL_addlstring(&b, s, wild - s); /* push prefix */ + luaL_addstring(&b, r); /* push replacement in place of pattern */ + s = wild + l; /* continue after `p' */ + } + luaL_addstring(&b, s); /* push last suffix */ + luaL_pushresult(&b); + return lua_tostring(L, -1); +} + + +LUALIB_API const char *luaL_findtable (lua_State *L, int idx, + const char *fname, int szhint) { + const char *e; + lua_pushvalue(L, idx); + do { + e = strchr(fname, '.'); + if (e == NULL) e = fname + strlen(fname); + lua_pushlstring(L, fname, e - fname); + lua_rawget(L, -2); + if (lua_isnil(L, -1)) { /* no such field? */ + lua_pop(L, 1); /* remove this nil */ + lua_createtable(L, 0, (*e == '.' ? 1 : szhint)); /* new table for field */ + lua_pushlstring(L, fname, e - fname); + lua_pushvalue(L, -2); + lua_settable(L, -4); /* set new table into field */ + } + else if (!lua_istable(L, -1)) { /* field has a non-table value? */ + lua_pop(L, 2); /* remove table and value */ + return fname; /* return problematic part of the name */ + } + lua_remove(L, -2); /* remove previous table */ + fname = e + 1; + } while (*e == '.'); + return NULL; +} + + + +/* +** {====================================================== +** Generic Buffer manipulation +** ======================================================= +*/ + + +#define bufflen(B) ((B)->p - (B)->buffer) +#define bufffree(B) ((size_t)(LUAL_BUFFERSIZE - bufflen(B))) + +#define LIMIT (LUA_MINSTACK/2) + + +static int emptybuffer (luaL_Buffer *B) { + size_t l = bufflen(B); + if (l == 0) return 0; /* put nothing on stack */ + else { + lua_pushlstring(B->L, B->buffer, l); + B->p = B->buffer; + B->lvl++; + return 1; + } +} + + +static void adjuststack (luaL_Buffer *B) { + if (B->lvl > 1) { + lua_State *L = B->L; + int toget = 1; /* number of levels to concat */ + size_t toplen = lua_strlen(L, -1); + do { + size_t l = lua_strlen(L, -(toget+1)); + if (B->lvl - toget + 1 >= LIMIT || toplen > l) { + toplen += l; + toget++; + } + else break; + } while (toget < B->lvl); + lua_concat(L, toget); + B->lvl = B->lvl - toget + 1; + } +} + + +LUALIB_API char *luaL_prepbuffer (luaL_Buffer *B) { + if (emptybuffer(B)) + adjuststack(B); + return B->buffer; +} + + +LUALIB_API void luaL_addlstring (luaL_Buffer *B, const char *s, size_t l) { + while (l--) + luaL_addchar(B, *s++); +} + + +LUALIB_API void luaL_addstring (luaL_Buffer *B, const char *s) { + luaL_addlstring(B, s, strlen(s)); +} + + +LUALIB_API void luaL_pushresult (luaL_Buffer *B) { + emptybuffer(B); + lua_concat(B->L, B->lvl); + B->lvl = 1; +} + + +LUALIB_API void luaL_addvalue (luaL_Buffer *B) { + lua_State *L = B->L; + size_t vl; + const char *s = lua_tolstring(L, -1, &vl); + if (vl <= bufffree(B)) { /* fit into buffer? */ + memcpy(B->p, s, vl); /* put it there */ + B->p += vl; + lua_pop(L, 1); /* remove from stack */ + } + else { + if (emptybuffer(B)) + lua_insert(L, -2); /* put buffer before new value */ + B->lvl++; /* add new value into B stack */ + adjuststack(B); + } +} + + +LUALIB_API void luaL_buffinit (lua_State *L, luaL_Buffer *B) { + B->L = L; + B->p = B->buffer; + B->lvl = 0; +} + +/* }====================================================== */ + + +LUALIB_API int luaL_ref (lua_State *L, int t) { + int ref; + t = abs_index(L, t); + if (lua_isnil(L, -1)) { + lua_pop(L, 1); /* remove from stack */ + return LUA_REFNIL; /* `nil' has a unique fixed reference */ + } + lua_rawgeti(L, t, FREELIST_REF); /* get first free element */ + ref = (int)lua_tointeger(L, -1); /* ref = t[FREELIST_REF] */ + lua_pop(L, 1); /* remove it from stack */ + if (ref != 0) { /* any free element? */ + lua_rawgeti(L, t, ref); /* remove it from list */ + lua_rawseti(L, t, FREELIST_REF); /* (t[FREELIST_REF] = t[ref]) */ + } + else { /* no free elements */ + ref = (int)lua_objlen(L, t); + ref++; /* create new reference */ + } + lua_rawseti(L, t, ref); + return ref; +} + + +LUALIB_API void luaL_unref (lua_State *L, int t, int ref) { + if (ref >= 0) { + t = abs_index(L, t); + lua_rawgeti(L, t, FREELIST_REF); + lua_rawseti(L, t, ref); /* t[ref] = t[FREELIST_REF] */ + lua_pushinteger(L, ref); + lua_rawseti(L, t, FREELIST_REF); /* t[FREELIST_REF] = ref */ + } +} + + + +/* +** {====================================================== +** Load functions +** ======================================================= +*/ + +typedef struct LoadF { + int extraline; + FILE *f; + char buff[LUAL_BUFFERSIZE]; +} LoadF; + + +static const char *getF (lua_State *L, void *ud, size_t *size) { + LoadF *lf = (LoadF *)ud; + (void)L; + if (lf->extraline) { + lf->extraline = 0; + *size = 1; + return "\n"; + } + if (feof(lf->f)) return NULL; + *size = fread(lf->buff, 1, sizeof(lf->buff), lf->f); + return (*size > 0) ? lf->buff : NULL; +} + + +static int errfile (lua_State *L, const char *what, int fnameindex) { + const char *serr = strerror(errno); + const char *filename = lua_tostring(L, fnameindex) + 1; + lua_pushfstring(L, "cannot %s %s: %s", what, filename, serr); + lua_remove(L, fnameindex); + return LUA_ERRFILE; +} + + +LUALIB_API int luaL_loadfile (lua_State *L, const char *filename) { + LoadF lf; + int status, readstatus; + int c; + int fnameindex = lua_gettop(L) + 1; /* index of filename on the stack */ + lf.extraline = 0; + if (filename == NULL) { + lua_pushliteral(L, "=stdin"); + lf.f = stdin; + } + else { + lua_pushfstring(L, "@%s", filename); + lf.f = fopen(filename, "r"); + if (lf.f == NULL) return errfile(L, "open", fnameindex); + } + c = getc(lf.f); + if (c == '#') { /* Unix exec. file? */ + lf.extraline = 1; + while ((c = getc(lf.f)) != EOF && c != '\n') ; /* skip first line */ + if (c == '\n') c = getc(lf.f); + } + if (c == LUA_SIGNATURE[0] && filename) { /* binary file? */ + lf.f = freopen(filename, "rb", lf.f); /* reopen in binary mode */ + if (lf.f == NULL) return errfile(L, "reopen", fnameindex); + /* skip eventual `#!...' */ + while ((c = getc(lf.f)) != EOF && c != LUA_SIGNATURE[0]) ; + lf.extraline = 0; + } + ungetc(c, lf.f); + status = lua_load(L, getF, &lf, lua_tostring(L, -1)); + readstatus = ferror(lf.f); + if (filename) fclose(lf.f); /* close file (even in case of errors) */ + if (readstatus) { + lua_settop(L, fnameindex); /* ignore results from `lua_load' */ + return errfile(L, "read", fnameindex); + } + lua_remove(L, fnameindex); + return status; +} + + +typedef struct LoadS { + const char *s; + size_t size; +} LoadS; + + +static const char *getS (lua_State *L, void *ud, size_t *size) { + LoadS *ls = (LoadS *)ud; + (void)L; + if (ls->size == 0) return NULL; + *size = ls->size; + ls->size = 0; + return ls->s; +} + + +LUALIB_API int luaL_loadbuffer (lua_State *L, const char *buff, size_t size, + const char *name) { + LoadS ls; + ls.s = buff; + ls.size = size; + return lua_load(L, getS, &ls, name); +} + + +LUALIB_API int (luaL_loadstring) (lua_State *L, const char *s) { + return luaL_loadbuffer(L, s, strlen(s), s); +} + + + +/* }====================================================== */ + + +static void *l_alloc (void *ud, void *ptr, size_t osize, size_t nsize) { + (void)ud; + (void)osize; + if (nsize == 0) { + free(ptr); + return NULL; + } + else + return realloc(ptr, nsize); +} + + +static int panic (lua_State *L) { + (void)L; /* to avoid warnings */ + fprintf(stderr, "PANIC: unprotected error in call to Lua API (%s)\n", + lua_tostring(L, -1)); + return 0; +} + + +LUALIB_API lua_State *luaL_newstate (void) { + lua_State *L = lua_newstate(l_alloc, NULL); + if (L) lua_atpanic(L, &panic); + return L; +} + diff --git a/include/lua/lauxlib.h b/include/lua/lauxlib.h new file mode 100644 index 0000000..3f17c2f --- /dev/null +++ b/include/lua/lauxlib.h @@ -0,0 +1,174 @@ +/* +** $Id: lauxlib.h,v 1.88.1.1 2007/12/27 13:02:25 roberto Exp $ +** Auxiliary functions for building Lua libraries +** See Copyright Notice in lua.h +*/ + + +#ifndef lauxlib_h +#define lauxlib_h + + +#include +#include + +#include "lua.h" + + +#if defined(LUA_COMPAT_GETN) +LUALIB_API int (luaL_getn) (lua_State *L, int t); +LUALIB_API void (luaL_setn) (lua_State *L, int t, int n); +#else +#define luaL_getn(L,i) ((int)lua_objlen(L, i)) +#define luaL_setn(L,i,j) ((void)0) /* no op! */ +#endif + +#if defined(LUA_COMPAT_OPENLIB) +#define luaI_openlib luaL_openlib +#endif + + +/* extra error code for `luaL_load' */ +#define LUA_ERRFILE (LUA_ERRERR+1) + + +typedef struct luaL_Reg { + const char *name; + lua_CFunction func; +} luaL_Reg; + + + +LUALIB_API void (luaI_openlib) (lua_State *L, const char *libname, + const luaL_Reg *l, int nup); +LUALIB_API void (luaL_register) (lua_State *L, const char *libname, + const luaL_Reg *l); +LUALIB_API int (luaL_getmetafield) (lua_State *L, int obj, const char *e); +LUALIB_API int (luaL_callmeta) (lua_State *L, int obj, const char *e); +LUALIB_API int (luaL_typerror) (lua_State *L, int narg, const char *tname); +LUALIB_API int (luaL_argerror) (lua_State *L, int numarg, const char *extramsg); +LUALIB_API char *(luaL_checklstring) (lua_State *L, int numArg, + size_t *l); +LUALIB_API const char *(luaL_optlstring) (lua_State *L, int numArg, + const char *def, size_t *l); +LUALIB_API lua_Number (luaL_checknumber) (lua_State *L, int numArg); +LUALIB_API lua_Number (luaL_optnumber) (lua_State *L, int nArg, lua_Number def); + +LUALIB_API lua_Integer (luaL_checkinteger) (lua_State *L, int numArg); +LUALIB_API lua_Integer (luaL_optinteger) (lua_State *L, int nArg, + lua_Integer def); + +LUALIB_API void (luaL_checkstack) (lua_State *L, int sz, const char *msg); +LUALIB_API void (luaL_checktype) (lua_State *L, int narg, int t); +LUALIB_API void (luaL_checkany) (lua_State *L, int narg); + +LUALIB_API int (luaL_newmetatable) (lua_State *L, const char *tname); +LUALIB_API void *(luaL_checkudata) (lua_State *L, int ud, const char *tname); + +LUALIB_API void (luaL_where) (lua_State *L, int lvl); +LUALIB_API int (luaL_error) (lua_State *L, const char *fmt, ...); + +LUALIB_API int (luaL_checkoption) (lua_State *L, int narg, const char *def, + const char *const lst[]); + +LUALIB_API int (luaL_ref) (lua_State *L, int t); +LUALIB_API void (luaL_unref) (lua_State *L, int t, int ref); + +LUALIB_API int (luaL_loadfile) (lua_State *L, const char *filename); +LUALIB_API int (luaL_loadbuffer) (lua_State *L, const char *buff, size_t sz, + const char *name); +LUALIB_API int (luaL_loadstring) (lua_State *L, const char *s); + +LUALIB_API lua_State *(luaL_newstate) (void); + + +LUALIB_API const char *(luaL_gsub) (lua_State *L, const char *s, const char *p, + const char *r); + +LUALIB_API const char *(luaL_findtable) (lua_State *L, int idx, + const char *fname, int szhint); + + + + +/* +** =============================================================== +** some useful macros +** =============================================================== +*/ + +#define luaL_argcheck(L, cond,numarg,extramsg) \ + ((void)((cond) || luaL_argerror(L, (numarg), (extramsg)))) +#define luaL_checkstring(L,n) (luaL_checklstring(L, (n), NULL)) +#define luaL_optstring(L,n,d) (luaL_optlstring(L, (n), (d), NULL)) +#define luaL_checkint(L,n) ((int)luaL_checkinteger(L, (n))) +#define luaL_optint(L,n,d) ((int)luaL_optinteger(L, (n), (d))) +#define luaL_checklong(L,n) ((long)luaL_checkinteger(L, (n))) +#define luaL_optlong(L,n,d) ((long)luaL_optinteger(L, (n), (d))) + +#define luaL_typename(L,i) lua_typename(L, lua_type(L,(i))) + +#define luaL_dofile(L, fn) \ + (luaL_loadfile(L, fn) || lua_pcall(L, 0, LUA_MULTRET, 0)) + +#define luaL_dostring(L, s) \ + (luaL_loadstring(L, s) || lua_pcall(L, 0, LUA_MULTRET, 0)) + +#define luaL_getmetatable(L,n) (lua_getfield(L, LUA_REGISTRYINDEX, (n))) + +#define luaL_opt(L,f,n,d) (lua_isnoneornil(L,(n)) ? (d) : f(L,(n))) + +/* +** {====================================================== +** Generic Buffer manipulation +** ======================================================= +*/ + + + +typedef struct luaL_Buffer { + char *p; /* current position in buffer */ + int lvl; /* number of strings in the stack (level) */ + lua_State *L; + char buffer[LUAL_BUFFERSIZE]; +} luaL_Buffer; + +#define luaL_addchar(B,c) \ + ((void)((B)->p < ((B)->buffer+LUAL_BUFFERSIZE) || luaL_prepbuffer(B)), \ + (*(B)->p++ = (char)(c))) + +/* compatibility only */ +#define luaL_putchar(B,c) luaL_addchar(B,c) + +#define luaL_addsize(B,n) ((B)->p += (n)) + +LUALIB_API void (luaL_buffinit) (lua_State *L, luaL_Buffer *B); +LUALIB_API char *(luaL_prepbuffer) (luaL_Buffer *B); +LUALIB_API void (luaL_addlstring) (luaL_Buffer *B, const char *s, size_t l); +LUALIB_API void (luaL_addstring) (luaL_Buffer *B, const char *s); +LUALIB_API void (luaL_addvalue) (luaL_Buffer *B); +LUALIB_API void (luaL_pushresult) (luaL_Buffer *B); + + +/* }====================================================== */ + + +/* compatibility with ref system */ + +/* pre-defined references */ +#define LUA_NOREF (-2) +#define LUA_REFNIL (-1) + +#define lua_ref(L,lock) ((lock) ? luaL_ref(L, LUA_REGISTRYINDEX) : \ + (lua_pushstring(L, "unlocked references are obsolete"), lua_error(L), 0)) + +#define lua_unref(L,ref) luaL_unref(L, LUA_REGISTRYINDEX, (ref)) + +#define lua_getref(L,ref) lua_rawgeti(L, LUA_REGISTRYINDEX, (ref)) + + +#define luaL_reg luaL_Reg + +#endif + + diff --git a/include/lua/lbaselib.c b/include/lua/lbaselib.c new file mode 100644 index 0000000..2a4c079 --- /dev/null +++ b/include/lua/lbaselib.c @@ -0,0 +1,653 @@ +/* +** $Id: lbaselib.c,v 1.191.1.6 2008/02/14 16:46:22 roberto Exp $ +** Basic library +** See Copyright Notice in lua.h +*/ + + + +#include +#include +#include +#include + +#define lbaselib_c +#define LUA_LIB + +#include "lua.h" + +#include "lauxlib.h" +#include "lualib.h" + + + + +/* +** If your system does not support `stdout', you can just remove this function. +** If you need, you can define your own `print' function, following this +** model but changing `fputs' to put the strings at a proper place +** (a console window or a log file, for instance). +*/ +static int luaB_print (lua_State *L) { + int n = lua_gettop(L); /* number of arguments */ + int i; + lua_getglobal(L, "tostring"); + for (i=1; i<=n; i++) { + const char *s; + lua_pushvalue(L, -1); /* function to be called */ + lua_pushvalue(L, i); /* value to print */ + lua_call(L, 1, 1); + s = lua_tostring(L, -1); /* get result */ + if (s == NULL) + return luaL_error(L, LUA_QL("tostring") " must return a string to " + LUA_QL("print")); + if (i>1) fputs("\t", stdout); + fputs(s, stdout); + lua_pop(L, 1); /* pop result */ + } + fputs("\n", stdout); + return 0; +} + + +static int luaB_tonumber (lua_State *L) { + int base = luaL_optint(L, 2, 10); + if (base == 10) { /* standard conversion */ + luaL_checkany(L, 1); + if (lua_isnumber(L, 1)) { + lua_pushnumber(L, lua_tonumber(L, 1)); + return 1; + } + } + else { + const char *s1 = luaL_checkstring(L, 1); + char *s2; + unsigned long n; + luaL_argcheck(L, 2 <= base && base <= 36, 2, "base out of range"); + n = strtoul(s1, &s2, base); + if (s1 != s2) { /* at least one valid digit? */ + while (isspace((unsigned char)(*s2))) s2++; /* skip trailing spaces */ + if (*s2 == '\0') { /* no invalid trailing characters? */ + lua_pushnumber(L, (lua_Number)n); + return 1; + } + } + } + lua_pushnil(L); /* else not a number */ + return 1; +} + + +static int luaB_error (lua_State *L) { + int level = luaL_optint(L, 2, 1); + lua_settop(L, 1); + if (lua_isstring(L, 1) && level > 0) { /* add extra information? */ + luaL_where(L, level); + lua_pushvalue(L, 1); + lua_concat(L, 2); + } + return lua_error(L); +} + + +static int luaB_getmetatable (lua_State *L) { + luaL_checkany(L, 1); + if (!lua_getmetatable(L, 1)) { + lua_pushnil(L); + return 1; /* no metatable */ + } + luaL_getmetafield(L, 1, "__metatable"); + return 1; /* returns either __metatable field (if present) or metatable */ +} + + +static int luaB_setmetatable (lua_State *L) { + int t = lua_type(L, 2); + luaL_checktype(L, 1, LUA_TTABLE); + luaL_argcheck(L, t == LUA_TNIL || t == LUA_TTABLE, 2, + "nil or table expected"); + if (luaL_getmetafield(L, 1, "__metatable")) + luaL_error(L, "cannot change a protected metatable"); + lua_settop(L, 2); + lua_setmetatable(L, 1); + return 1; +} + + +static void getfunc (lua_State *L, int opt) { + if (lua_isfunction(L, 1)) lua_pushvalue(L, 1); + else { + lua_Debug ar; + int level = opt ? luaL_optint(L, 1, 1) : luaL_checkint(L, 1); + luaL_argcheck(L, level >= 0, 1, "level must be non-negative"); + if (lua_getstack(L, level, &ar) == 0) + luaL_argerror(L, 1, "invalid level"); + lua_getinfo(L, "f", &ar); + if (lua_isnil(L, -1)) + luaL_error(L, "no function environment for tail call at level %d", + level); + } +} + + +static int luaB_getfenv (lua_State *L) { + getfunc(L, 1); + if (lua_iscfunction(L, -1)) /* is a C function? */ + lua_pushvalue(L, LUA_GLOBALSINDEX); /* return the thread's global env. */ + else + lua_getfenv(L, -1); + return 1; +} + + +static int luaB_setfenv (lua_State *L) { + luaL_checktype(L, 2, LUA_TTABLE); + getfunc(L, 0); + lua_pushvalue(L, 2); + if (lua_isnumber(L, 1) && lua_tonumber(L, 1) == 0) { + /* change environment of current thread */ + lua_pushthread(L); + lua_insert(L, -2); + lua_setfenv(L, -2); + return 0; + } + else if (lua_iscfunction(L, -2) || lua_setfenv(L, -2) == 0) + luaL_error(L, + LUA_QL("setfenv") " cannot change environment of given object"); + return 1; +} + + +static int luaB_rawequal (lua_State *L) { + luaL_checkany(L, 1); + luaL_checkany(L, 2); + lua_pushboolean(L, lua_rawequal(L, 1, 2)); + return 1; +} + + +static int luaB_rawget (lua_State *L) { + luaL_checktype(L, 1, LUA_TTABLE); + luaL_checkany(L, 2); + lua_settop(L, 2); + lua_rawget(L, 1); + return 1; +} + +static int luaB_rawset (lua_State *L) { + luaL_checktype(L, 1, LUA_TTABLE); + luaL_checkany(L, 2); + luaL_checkany(L, 3); + lua_settop(L, 3); + lua_rawset(L, 1); + return 1; +} + + +static int luaB_gcinfo (lua_State *L) { + lua_pushinteger(L, lua_getgccount(L)); + return 1; +} + + +static int luaB_collectgarbage (lua_State *L) { + static const char *const opts[] = {"stop", "restart", "collect", + "count", "step", "setpause", "setstepmul", NULL}; + static const int optsnum[] = {LUA_GCSTOP, LUA_GCRESTART, LUA_GCCOLLECT, + LUA_GCCOUNT, LUA_GCSTEP, LUA_GCSETPAUSE, LUA_GCSETSTEPMUL}; + int o = luaL_checkoption(L, 1, "collect", opts); + int ex = luaL_optint(L, 2, 0); + int res = lua_gc(L, optsnum[o], ex); + switch (optsnum[o]) { + case LUA_GCCOUNT: { + int b = lua_gc(L, LUA_GCCOUNTB, 0); + lua_pushnumber(L, res + ((lua_Number)b/1024)); + return 1; + } + case LUA_GCSTEP: { + lua_pushboolean(L, res); + return 1; + } + default: { + lua_pushnumber(L, res); + return 1; + } + } +} + + +static int luaB_type (lua_State *L) { + luaL_checkany(L, 1); + lua_pushstring(L, luaL_typename(L, 1)); + return 1; +} + + +static int luaB_next (lua_State *L) { + luaL_checktype(L, 1, LUA_TTABLE); + lua_settop(L, 2); /* create a 2nd argument if there isn't one */ + if (lua_next(L, 1)) + return 2; + else { + lua_pushnil(L); + return 1; + } +} + + +static int luaB_pairs (lua_State *L) { + luaL_checktype(L, 1, LUA_TTABLE); + lua_pushvalue(L, lua_upvalueindex(1)); /* return generator, */ + lua_pushvalue(L, 1); /* state, */ + lua_pushnil(L); /* and initial value */ + return 3; +} + + +static int ipairsaux (lua_State *L) { + int i = luaL_checkint(L, 2); + luaL_checktype(L, 1, LUA_TTABLE); + i++; /* next value */ + lua_pushinteger(L, i); + lua_rawgeti(L, 1, i); + return (lua_isnil(L, -1)) ? 0 : 2; +} + + +static int luaB_ipairs (lua_State *L) { + luaL_checktype(L, 1, LUA_TTABLE); + lua_pushvalue(L, lua_upvalueindex(1)); /* return generator, */ + lua_pushvalue(L, 1); /* state, */ + lua_pushinteger(L, 0); /* and initial value */ + return 3; +} + + +static int load_aux (lua_State *L, int status) { + if (status == 0) /* OK? */ + return 1; + else { + lua_pushnil(L); + lua_insert(L, -2); /* put before error message */ + return 2; /* return nil plus error message */ + } +} + + +static int luaB_loadstring (lua_State *L) { + size_t l; + const char *s = luaL_checklstring(L, 1, &l); + const char *chunkname = luaL_optstring(L, 2, s); + return load_aux(L, luaL_loadbuffer(L, s, l, chunkname)); +} + + +static int luaB_loadfile (lua_State *L) { + const char *fname = luaL_optstring(L, 1, NULL); + return load_aux(L, luaL_loadfile(L, fname)); +} + + +/* +** Reader for generic `load' function: `lua_load' uses the +** stack for internal stuff, so the reader cannot change the +** stack top. Instead, it keeps its resulting string in a +** reserved slot inside the stack. +*/ +static const char *generic_reader (lua_State *L, void *ud, size_t *size) { + (void)ud; /* to avoid warnings */ + luaL_checkstack(L, 2, "too many nested functions"); + lua_pushvalue(L, 1); /* get function */ + lua_call(L, 0, 1); /* call it */ + if (lua_isnil(L, -1)) { + *size = 0; + return NULL; + } + else if (lua_isstring(L, -1)) { + lua_replace(L, 3); /* save string in a reserved stack slot */ + return lua_tolstring(L, 3, size); + } + else luaL_error(L, "reader function must return a string"); + return NULL; /* to avoid warnings */ +} + + +static int luaB_load (lua_State *L) { + int status; + const char *cname = luaL_optstring(L, 2, "=(load)"); + luaL_checktype(L, 1, LUA_TFUNCTION); + lua_settop(L, 3); /* function, eventual name, plus one reserved slot */ + status = lua_load(L, generic_reader, NULL, cname); + return load_aux(L, status); +} + + +static int luaB_dofile (lua_State *L) { + const char *fname = luaL_optstring(L, 1, NULL); + int n = lua_gettop(L); + if (luaL_loadfile(L, fname) != 0) lua_error(L); + lua_call(L, 0, LUA_MULTRET); + return lua_gettop(L) - n; +} + + +static int luaB_assert (lua_State *L) { + luaL_checkany(L, 1); + if (!lua_toboolean(L, 1)) + return luaL_error(L, "%s", luaL_optstring(L, 2, "assertion failed!")); + return lua_gettop(L); +} + + +static int luaB_unpack (lua_State *L) { + int i, e, n; + luaL_checktype(L, 1, LUA_TTABLE); + i = luaL_optint(L, 2, 1); + e = luaL_opt(L, luaL_checkint, 3, luaL_getn(L, 1)); + if (i > e) return 0; /* empty range */ + n = e - i + 1; /* number of elements */ + if (n <= 0 || !lua_checkstack(L, n)) /* n <= 0 means arith. overflow */ + return luaL_error(L, "too many results to unpack"); + lua_rawgeti(L, 1, i); /* push arg[i] (avoiding overflow problems) */ + while (i++ < e) /* push arg[i + 1...e] */ + lua_rawgeti(L, 1, i); + return n; +} + + +static int luaB_select (lua_State *L) { + int n = lua_gettop(L); + if (lua_type(L, 1) == LUA_TSTRING && *lua_tostring(L, 1) == '#') { + lua_pushinteger(L, n-1); + return 1; + } + else { + int i = luaL_checkint(L, 1); + if (i < 0) i = n + i; + else if (i > n) i = n; + luaL_argcheck(L, 1 <= i, 1, "index out of range"); + return n - i; + } +} + + +static int luaB_pcall (lua_State *L) { + int status; + luaL_checkany(L, 1); + status = lua_pcall(L, lua_gettop(L) - 1, LUA_MULTRET, 0); + lua_pushboolean(L, (status == 0)); + lua_insert(L, 1); + return lua_gettop(L); /* return status + all results */ +} + + +static int luaB_xpcall (lua_State *L) { + int status; + luaL_checkany(L, 2); + lua_settop(L, 2); + lua_insert(L, 1); /* put error function under function to be called */ + status = lua_pcall(L, 0, LUA_MULTRET, 1); + lua_pushboolean(L, (status == 0)); + lua_replace(L, 1); + return lua_gettop(L); /* return status + all results */ +} + + +static int luaB_tostring (lua_State *L) { + luaL_checkany(L, 1); + if (luaL_callmeta(L, 1, "__tostring")) /* is there a metafield? */ + return 1; /* use its value */ + switch (lua_type(L, 1)) { + case LUA_TNUMBER: + lua_pushstring(L, lua_tostring(L, 1)); + break; + case LUA_TSTRING: + lua_pushvalue(L, 1); + break; + case LUA_TBOOLEAN: + lua_pushstring(L, (lua_toboolean(L, 1) ? "true" : "false")); + break; + case LUA_TNIL: + lua_pushliteral(L, "nil"); + break; + default: + lua_pushfstring(L, "%s: %p", luaL_typename(L, 1), lua_topointer(L, 1)); + break; + } + return 1; +} + + +static int luaB_newproxy (lua_State *L) { + lua_settop(L, 1); + lua_newuserdata(L, 0); /* create proxy */ + if (lua_toboolean(L, 1) == 0) + return 1; /* no metatable */ + else if (lua_isboolean(L, 1)) { + lua_newtable(L); /* create a new metatable `m' ... */ + lua_pushvalue(L, -1); /* ... and mark `m' as a valid metatable */ + lua_pushboolean(L, 1); + lua_rawset(L, lua_upvalueindex(1)); /* weaktable[m] = true */ + } + else { + int validproxy = 0; /* to check if weaktable[metatable(u)] == true */ + if (lua_getmetatable(L, 1)) { + lua_rawget(L, lua_upvalueindex(1)); + validproxy = lua_toboolean(L, -1); + lua_pop(L, 1); /* remove value */ + } + luaL_argcheck(L, validproxy, 1, "boolean or proxy expected"); + lua_getmetatable(L, 1); /* metatable is valid; get it */ + } + lua_setmetatable(L, 2); + return 1; +} + + +static const luaL_Reg base_funcs[] = { + {"assert", luaB_assert}, + {"collectgarbage", luaB_collectgarbage}, + {"dofile", luaB_dofile}, + {"error", luaB_error}, + {"gcinfo", luaB_gcinfo}, + {"getfenv", luaB_getfenv}, + {"getmetatable", luaB_getmetatable}, + {"loadfile", luaB_loadfile}, + {"load", luaB_load}, + {"loadstring", luaB_loadstring}, + {"next", luaB_next}, + {"pcall", luaB_pcall}, + {"print", luaB_print}, + {"rawequal", luaB_rawequal}, + {"rawget", luaB_rawget}, + {"rawset", luaB_rawset}, + {"select", luaB_select}, + {"setfenv", luaB_setfenv}, + {"setmetatable", luaB_setmetatable}, + {"tonumber", luaB_tonumber}, + {"tostring", luaB_tostring}, + {"type", luaB_type}, + {"unpack", luaB_unpack}, + {"xpcall", luaB_xpcall}, + {NULL, NULL} +}; + + +/* +** {====================================================== +** Coroutine library +** ======================================================= +*/ + +#define CO_RUN 0 /* running */ +#define CO_SUS 1 /* suspended */ +#define CO_NOR 2 /* 'normal' (it resumed another coroutine) */ +#define CO_DEAD 3 + +static const char *const statnames[] = + {"running", "suspended", "normal", "dead"}; + +static int costatus (lua_State *L, lua_State *co) { + if (L == co) return CO_RUN; + switch (lua_status(co)) { + case LUA_YIELD: + return CO_SUS; + case 0: { + lua_Debug ar; + if (lua_getstack(co, 0, &ar) > 0) /* does it have frames? */ + return CO_NOR; /* it is running */ + else if (lua_gettop(co) == 0) + return CO_DEAD; + else + return CO_SUS; /* initial state */ + } + default: /* some error occured */ + return CO_DEAD; + } +} + + +static int luaB_costatus (lua_State *L) { + lua_State *co = lua_tothread(L, 1); + luaL_argcheck(L, co, 1, "coroutine expected"); + lua_pushstring(L, statnames[costatus(L, co)]); + return 1; +} + + +static int auxresume (lua_State *L, lua_State *co, int narg) { + int status = costatus(L, co); + if (!lua_checkstack(co, narg)) + luaL_error(L, "too many arguments to resume"); + if (status != CO_SUS) { + lua_pushfstring(L, "cannot resume %s coroutine", statnames[status]); + return -1; /* error flag */ + } + lua_xmove(L, co, narg); + lua_setlevel(L, co); + status = lua_resume(co, narg); + if (status == 0 || status == LUA_YIELD) { + int nres = lua_gettop(co); + if (!lua_checkstack(L, nres + 1)) + luaL_error(L, "too many results to resume"); + lua_xmove(co, L, nres); /* move yielded values */ + return nres; + } + else { + lua_xmove(co, L, 1); /* move error message */ + return -1; /* error flag */ + } +} + + +static int luaB_coresume (lua_State *L) { + lua_State *co = lua_tothread(L, 1); + int r; + luaL_argcheck(L, co, 1, "coroutine expected"); + r = auxresume(L, co, lua_gettop(L) - 1); + if (r < 0) { + lua_pushboolean(L, 0); + lua_insert(L, -2); + return 2; /* return false + error message */ + } + else { + lua_pushboolean(L, 1); + lua_insert(L, -(r + 1)); + return r + 1; /* return true + `resume' returns */ + } +} + + +static int luaB_auxwrap (lua_State *L) { + lua_State *co = lua_tothread(L, lua_upvalueindex(1)); + int r = auxresume(L, co, lua_gettop(L)); + if (r < 0) { + if (lua_isstring(L, -1)) { /* error object is a string? */ + luaL_where(L, 1); /* add extra info */ + lua_insert(L, -2); + lua_concat(L, 2); + } + lua_error(L); /* propagate error */ + } + return r; +} + + +static int luaB_cocreate (lua_State *L) { + lua_State *NL = lua_newthread(L); + luaL_argcheck(L, lua_isfunction(L, 1) && !lua_iscfunction(L, 1), 1, + "Lua function expected"); + lua_pushvalue(L, 1); /* move function to top */ + lua_xmove(L, NL, 1); /* move function from L to NL */ + return 1; +} + + +static int luaB_cowrap (lua_State *L) { + luaB_cocreate(L); + lua_pushcclosure(L, luaB_auxwrap, 1); + return 1; +} + + +static int luaB_yield (lua_State *L) { + return lua_yield(L, lua_gettop(L)); +} + + +static int luaB_corunning (lua_State *L) { + if (lua_pushthread(L)) + lua_pushnil(L); /* main thread is not a coroutine */ + return 1; +} + + +static const luaL_Reg co_funcs[] = { + {"create", luaB_cocreate}, + {"resume", luaB_coresume}, + {"running", luaB_corunning}, + {"status", luaB_costatus}, + {"wrap", luaB_cowrap}, + {"yield", luaB_yield}, + {NULL, NULL} +}; + +/* }====================================================== */ + + +static void auxopen (lua_State *L, const char *name, + lua_CFunction f, lua_CFunction u) { + lua_pushcfunction(L, u); + lua_pushcclosure(L, f, 1); + lua_setfield(L, -2, name); +} + + +static void base_open (lua_State *L) { + /* set global _G */ + lua_pushvalue(L, LUA_GLOBALSINDEX); + lua_setglobal(L, "_G"); + /* open lib into global table */ + luaL_register(L, "_G", base_funcs); + lua_pushliteral(L, LUA_VERSION); + lua_setglobal(L, "_VERSION"); /* set global _VERSION */ + /* `ipairs' and `pairs' need auxliliary functions as upvalues */ + auxopen(L, "ipairs", luaB_ipairs, ipairsaux); + auxopen(L, "pairs", luaB_pairs, luaB_next); + /* `newproxy' needs a weaktable as upvalue */ + lua_createtable(L, 0, 1); /* new table `w' */ + lua_pushvalue(L, -1); /* `w' will be its own metatable */ + lua_setmetatable(L, -2); + lua_pushliteral(L, "kv"); + lua_setfield(L, -2, "__mode"); /* metatable(w).__mode = "kv" */ + lua_pushcclosure(L, luaB_newproxy, 1); + lua_setglobal(L, "newproxy"); /* set global `newproxy' */ +} + + +LUALIB_API int luaopen_base (lua_State *L) { + base_open(L); + luaL_register(L, LUA_COLIBNAME, co_funcs); + return 2; +} + diff --git a/include/lua/lcode.c b/include/lua/lcode.c new file mode 100644 index 0000000..cff626b --- /dev/null +++ b/include/lua/lcode.c @@ -0,0 +1,839 @@ +/* +** $Id: lcode.c,v 2.25.1.3 2007/12/28 15:32:23 roberto Exp $ +** Code generator for Lua +** See Copyright Notice in lua.h +*/ + + +#include + +#define lcode_c +#define LUA_CORE + +#include "lua.h" + +#include "lcode.h" +#include "ldebug.h" +#include "ldo.h" +#include "lgc.h" +#include "llex.h" +#include "lmem.h" +#include "lobject.h" +#include "lopcodes.h" +#include "lparser.h" +#include "ltable.h" + + +#define hasjumps(e) ((e)->t != (e)->f) + + +static int isnumeral(expdesc *e) { + return (e->k == VKNUM && e->t == NO_JUMP && e->f == NO_JUMP); +} + + +void luaK_nil (FuncState *fs, int from, int n) { + Instruction *previous; + if (fs->pc > fs->lasttarget) { /* no jumps to current position? */ + if (fs->pc == 0) { /* function start? */ + if (from >= fs->nactvar) + return; /* positions are already clean */ + } + else { + previous = &fs->f->code[fs->pc-1]; + if (GET_OPCODE(*previous) == OP_LOADNIL) { + int pfrom = GETARG_A(*previous); + int pto = GETARG_B(*previous); + if (pfrom <= from && from <= pto+1) { /* can connect both? */ + if (from+n-1 > pto) + SETARG_B(*previous, from+n-1); + return; + } + } + } + } + luaK_codeABC(fs, OP_LOADNIL, from, from+n-1, 0); /* else no optimization */ +} + + +int luaK_jump (FuncState *fs) { + int jpc = fs->jpc; /* save list of jumps to here */ + int j; + fs->jpc = NO_JUMP; + j = luaK_codeAsBx(fs, OP_JMP, 0, NO_JUMP); + luaK_concat(fs, &j, jpc); /* keep them on hold */ + return j; +} + + +void luaK_ret (FuncState *fs, int first, int nret) { + luaK_codeABC(fs, OP_RETURN, first, nret+1, 0); +} + + +static int condjump (FuncState *fs, OpCode op, int A, int B, int C) { + luaK_codeABC(fs, op, A, B, C); + return luaK_jump(fs); +} + + +static void fixjump (FuncState *fs, int pc, int dest) { + Instruction *jmp = &fs->f->code[pc]; + int offset = dest-(pc+1); + lua_assert(dest != NO_JUMP); + if (abs(offset) > MAXARG_sBx) + luaX_syntaxerror(fs->ls, "control structure too long"); + SETARG_sBx(*jmp, offset); +} + + +/* +** returns current `pc' and marks it as a jump target (to avoid wrong +** optimizations with consecutive instructions not in the same basic block). +*/ +int luaK_getlabel (FuncState *fs) { + fs->lasttarget = fs->pc; + return fs->pc; +} + + +static int getjump (FuncState *fs, int pc) { + int offset = GETARG_sBx(fs->f->code[pc]); + if (offset == NO_JUMP) /* point to itself represents end of list */ + return NO_JUMP; /* end of list */ + else + return (pc+1)+offset; /* turn offset into absolute position */ +} + + +static Instruction *getjumpcontrol (FuncState *fs, int pc) { + Instruction *pi = &fs->f->code[pc]; + if (pc >= 1 && testTMode(GET_OPCODE(*(pi-1)))) + return pi-1; + else + return pi; +} + + +/* +** check whether list has any jump that do not produce a value +** (or produce an inverted value) +*/ +static int need_value (FuncState *fs, int list) { + for (; list != NO_JUMP; list = getjump(fs, list)) { + Instruction i = *getjumpcontrol(fs, list); + if (GET_OPCODE(i) != OP_TESTSET) return 1; + } + return 0; /* not found */ +} + + +static int patchtestreg (FuncState *fs, int node, int reg) { + Instruction *i = getjumpcontrol(fs, node); + if (GET_OPCODE(*i) != OP_TESTSET) + return 0; /* cannot patch other instructions */ + if (reg != NO_REG && reg != GETARG_B(*i)) + SETARG_A(*i, reg); + else /* no register to put value or register already has the value */ + *i = CREATE_ABC(OP_TEST, GETARG_B(*i), 0, GETARG_C(*i)); + + return 1; +} + + +static void removevalues (FuncState *fs, int list) { + for (; list != NO_JUMP; list = getjump(fs, list)) + patchtestreg(fs, list, NO_REG); +} + + +static void patchlistaux (FuncState *fs, int list, int vtarget, int reg, + int dtarget) { + while (list != NO_JUMP) { + int next = getjump(fs, list); + if (patchtestreg(fs, list, reg)) + fixjump(fs, list, vtarget); + else + fixjump(fs, list, dtarget); /* jump to default target */ + list = next; + } +} + + +static void dischargejpc (FuncState *fs) { + patchlistaux(fs, fs->jpc, fs->pc, NO_REG, fs->pc); + fs->jpc = NO_JUMP; +} + + +void luaK_patchlist (FuncState *fs, int list, int target) { + if (target == fs->pc) + luaK_patchtohere(fs, list); + else { + lua_assert(target < fs->pc); + patchlistaux(fs, list, target, NO_REG, target); + } +} + + +void luaK_patchtohere (FuncState *fs, int list) { + luaK_getlabel(fs); + luaK_concat(fs, &fs->jpc, list); +} + + +void luaK_concat (FuncState *fs, int *l1, int l2) { + if (l2 == NO_JUMP) return; + else if (*l1 == NO_JUMP) + *l1 = l2; + else { + int list = *l1; + int next; + while ((next = getjump(fs, list)) != NO_JUMP) /* find last element */ + list = next; + fixjump(fs, list, l2); + } +} + + +void luaK_checkstack (FuncState *fs, int n) { + int newstack = fs->freereg + n; + if (newstack > fs->f->maxstacksize) { + if (newstack >= MAXSTACK) + luaX_syntaxerror(fs->ls, "function or expression too complex"); + fs->f->maxstacksize = cast_byte(newstack); + } +} + + +void luaK_reserveregs (FuncState *fs, int n) { + luaK_checkstack(fs, n); + fs->freereg += n; +} + + +static void freereg (FuncState *fs, int reg) { + if (!ISK(reg) && reg >= fs->nactvar) { + fs->freereg--; + lua_assert(reg == fs->freereg); + } +} + + +static void freeexp (FuncState *fs, expdesc *e) { + if (e->k == VNONRELOC) + freereg(fs, e->u.s.info); +} + + +static int addk (FuncState *fs, TValue *k, TValue *v) { + lua_State *L = fs->L; + TValue *idx = luaH_set(L, fs->h, k); + Proto *f = fs->f; + int oldsize = f->sizek; + if (ttisnumber(idx)) { + lua_assert(luaO_rawequalObj(&fs->f->k[cast_int(nvalue(idx))], v)); + return cast_int(nvalue(idx)); + } + else { /* constant not found; create a new entry */ + setnvalue(idx, cast_num(fs->nk)); + luaM_growvector(L, f->k, fs->nk, f->sizek, TValue, + MAXARG_Bx, "constant table overflow"); + while (oldsize < f->sizek) setnilvalue(&f->k[oldsize++]); + setobj(L, &f->k[fs->nk], v); + luaC_barrier(L, f, v); + return fs->nk++; + } +} + + +int luaK_stringK (FuncState *fs, TString *s) { + TValue o; + setsvalue(fs->L, &o, s); + return addk(fs, &o, &o); +} + + +int luaK_numberK (FuncState *fs, lua_Number r) { + TValue o; + setnvalue(&o, r); + return addk(fs, &o, &o); +} + + +static int boolK (FuncState *fs, int b) { + TValue o; + setbvalue(&o, b); + return addk(fs, &o, &o); +} + + +static int nilK (FuncState *fs) { + TValue k, v; + setnilvalue(&v); + /* cannot use nil as key; instead use table itself to represent nil */ + sethvalue(fs->L, &k, fs->h); + return addk(fs, &k, &v); +} + + +void luaK_setreturns (FuncState *fs, expdesc *e, int nresults) { + if (e->k == VCALL) { /* expression is an open function call? */ + SETARG_C(getcode(fs, e), nresults+1); + } + else if (e->k == VVARARG) { + SETARG_B(getcode(fs, e), nresults+1); + SETARG_A(getcode(fs, e), fs->freereg); + luaK_reserveregs(fs, 1); + } +} + + +void luaK_setoneret (FuncState *fs, expdesc *e) { + if (e->k == VCALL) { /* expression is an open function call? */ + e->k = VNONRELOC; + e->u.s.info = GETARG_A(getcode(fs, e)); + } + else if (e->k == VVARARG) { + SETARG_B(getcode(fs, e), 2); + e->k = VRELOCABLE; /* can relocate its simple result */ + } +} + + +void luaK_dischargevars (FuncState *fs, expdesc *e) { + switch (e->k) { + case VLOCAL: { + e->k = VNONRELOC; + break; + } + case VUPVAL: { + e->u.s.info = luaK_codeABC(fs, OP_GETUPVAL, 0, e->u.s.info, 0); + e->k = VRELOCABLE; + break; + } + case VGLOBAL: { + e->u.s.info = luaK_codeABx(fs, OP_GETGLOBAL, 0, e->u.s.info); + e->k = VRELOCABLE; + break; + } + case VINDEXED: { + freereg(fs, e->u.s.aux); + freereg(fs, e->u.s.info); + e->u.s.info = luaK_codeABC(fs, OP_GETTABLE, 0, e->u.s.info, e->u.s.aux); + e->k = VRELOCABLE; + break; + } + case VVARARG: + case VCALL: { + luaK_setoneret(fs, e); + break; + } + default: break; /* there is one value available (somewhere) */ + } +} + + +static int code_label (FuncState *fs, int A, int b, int jump) { + luaK_getlabel(fs); /* those instructions may be jump targets */ + return luaK_codeABC(fs, OP_LOADBOOL, A, b, jump); +} + + +static void discharge2reg (FuncState *fs, expdesc *e, int reg) { + luaK_dischargevars(fs, e); + switch (e->k) { + case VNIL: { + luaK_nil(fs, reg, 1); + break; + } + case VFALSE: case VTRUE: { + luaK_codeABC(fs, OP_LOADBOOL, reg, e->k == VTRUE, 0); + break; + } + case VK: { + luaK_codeABx(fs, OP_LOADK, reg, e->u.s.info); + break; + } + case VKNUM: { + luaK_codeABx(fs, OP_LOADK, reg, luaK_numberK(fs, e->u.nval)); + break; + } + case VRELOCABLE: { + Instruction *pc = &getcode(fs, e); + SETARG_A(*pc, reg); + break; + } + case VNONRELOC: { + if (reg != e->u.s.info) + luaK_codeABC(fs, OP_MOVE, reg, e->u.s.info, 0); + break; + } + default: { + lua_assert(e->k == VVOID || e->k == VJMP); + return; /* nothing to do... */ + } + } + e->u.s.info = reg; + e->k = VNONRELOC; +} + + +static void discharge2anyreg (FuncState *fs, expdesc *e) { + if (e->k != VNONRELOC) { + luaK_reserveregs(fs, 1); + discharge2reg(fs, e, fs->freereg-1); + } +} + + +static void exp2reg (FuncState *fs, expdesc *e, int reg) { + discharge2reg(fs, e, reg); + if (e->k == VJMP) + luaK_concat(fs, &e->t, e->u.s.info); /* put this jump in `t' list */ + if (hasjumps(e)) { + int final; /* position after whole expression */ + int p_f = NO_JUMP; /* position of an eventual LOAD false */ + int p_t = NO_JUMP; /* position of an eventual LOAD true */ + if (need_value(fs, e->t) || need_value(fs, e->f)) { + int fj = (e->k == VJMP) ? NO_JUMP : luaK_jump(fs); + p_f = code_label(fs, reg, 0, 1); + p_t = code_label(fs, reg, 1, 0); + luaK_patchtohere(fs, fj); + } + final = luaK_getlabel(fs); + patchlistaux(fs, e->f, final, reg, p_f); + patchlistaux(fs, e->t, final, reg, p_t); + } + e->f = e->t = NO_JUMP; + e->u.s.info = reg; + e->k = VNONRELOC; +} + + +void luaK_exp2nextreg (FuncState *fs, expdesc *e) { + luaK_dischargevars(fs, e); + freeexp(fs, e); + luaK_reserveregs(fs, 1); + exp2reg(fs, e, fs->freereg - 1); +} + + +int luaK_exp2anyreg (FuncState *fs, expdesc *e) { + luaK_dischargevars(fs, e); + if (e->k == VNONRELOC) { + if (!hasjumps(e)) return e->u.s.info; /* exp is already in a register */ + if (e->u.s.info >= fs->nactvar) { /* reg. is not a local? */ + exp2reg(fs, e, e->u.s.info); /* put value on it */ + return e->u.s.info; + } + } + luaK_exp2nextreg(fs, e); /* default */ + return e->u.s.info; +} + + +void luaK_exp2val (FuncState *fs, expdesc *e) { + if (hasjumps(e)) + luaK_exp2anyreg(fs, e); + else + luaK_dischargevars(fs, e); +} + + +int luaK_exp2RK (FuncState *fs, expdesc *e) { + luaK_exp2val(fs, e); + switch (e->k) { + case VKNUM: + case VTRUE: + case VFALSE: + case VNIL: { + if (fs->nk <= MAXINDEXRK) { /* constant fit in RK operand? */ + e->u.s.info = (e->k == VNIL) ? nilK(fs) : + (e->k == VKNUM) ? luaK_numberK(fs, e->u.nval) : + boolK(fs, (e->k == VTRUE)); + e->k = VK; + return RKASK(e->u.s.info); + } + else break; + } + case VK: { + if (e->u.s.info <= MAXINDEXRK) /* constant fit in argC? */ + return RKASK(e->u.s.info); + else break; + } + default: break; + } + /* not a constant in the right range: put it in a register */ + return luaK_exp2anyreg(fs, e); +} + + +void luaK_storevar (FuncState *fs, expdesc *var, expdesc *ex) { + switch (var->k) { + case VLOCAL: { + freeexp(fs, ex); + exp2reg(fs, ex, var->u.s.info); + return; + } + case VUPVAL: { + int e = luaK_exp2anyreg(fs, ex); + luaK_codeABC(fs, OP_SETUPVAL, e, var->u.s.info, 0); + break; + } + case VGLOBAL: { + int e = luaK_exp2anyreg(fs, ex); + luaK_codeABx(fs, OP_SETGLOBAL, e, var->u.s.info); + break; + } + case VINDEXED: { + int e = luaK_exp2RK(fs, ex); + luaK_codeABC(fs, OP_SETTABLE, var->u.s.info, var->u.s.aux, e); + break; + } + default: { + lua_assert(0); /* invalid var kind to store */ + break; + } + } + freeexp(fs, ex); +} + + +void luaK_self (FuncState *fs, expdesc *e, expdesc *key) { + int func; + luaK_exp2anyreg(fs, e); + freeexp(fs, e); + func = fs->freereg; + luaK_reserveregs(fs, 2); + luaK_codeABC(fs, OP_SELF, func, e->u.s.info, luaK_exp2RK(fs, key)); + freeexp(fs, key); + e->u.s.info = func; + e->k = VNONRELOC; +} + + +static void invertjump (FuncState *fs, expdesc *e) { + Instruction *pc = getjumpcontrol(fs, e->u.s.info); + lua_assert(testTMode(GET_OPCODE(*pc)) && GET_OPCODE(*pc) != OP_TESTSET && + GET_OPCODE(*pc) != OP_TEST); + SETARG_A(*pc, !(GETARG_A(*pc))); +} + + +static int jumponcond (FuncState *fs, expdesc *e, int cond) { + if (e->k == VRELOCABLE) { + Instruction ie = getcode(fs, e); + if (GET_OPCODE(ie) == OP_NOT) { + fs->pc--; /* remove previous OP_NOT */ + return condjump(fs, OP_TEST, GETARG_B(ie), 0, !cond); + } + /* else go through */ + } + discharge2anyreg(fs, e); + freeexp(fs, e); + return condjump(fs, OP_TESTSET, NO_REG, e->u.s.info, cond); +} + + +void luaK_goiftrue (FuncState *fs, expdesc *e) { + int pc; /* pc of last jump */ + luaK_dischargevars(fs, e); + switch (e->k) { + case VK: case VKNUM: case VTRUE: { + pc = NO_JUMP; /* always true; do nothing */ + break; + } + case VFALSE: { + pc = luaK_jump(fs); /* always jump */ + break; + } + case VJMP: { + invertjump(fs, e); + pc = e->u.s.info; + break; + } + default: { + pc = jumponcond(fs, e, 0); + break; + } + } + luaK_concat(fs, &e->f, pc); /* insert last jump in `f' list */ + luaK_patchtohere(fs, e->t); + e->t = NO_JUMP; +} + + +static void luaK_goiffalse (FuncState *fs, expdesc *e) { + int pc; /* pc of last jump */ + luaK_dischargevars(fs, e); + switch (e->k) { + case VNIL: case VFALSE: { + pc = NO_JUMP; /* always false; do nothing */ + break; + } + case VTRUE: { + pc = luaK_jump(fs); /* always jump */ + break; + } + case VJMP: { + pc = e->u.s.info; + break; + } + default: { + pc = jumponcond(fs, e, 1); + break; + } + } + luaK_concat(fs, &e->t, pc); /* insert last jump in `t' list */ + luaK_patchtohere(fs, e->f); + e->f = NO_JUMP; +} + + +static void codenot (FuncState *fs, expdesc *e) { + luaK_dischargevars(fs, e); + switch (e->k) { + case VNIL: case VFALSE: { + e->k = VTRUE; + break; + } + case VK: case VKNUM: case VTRUE: { + e->k = VFALSE; + break; + } + case VJMP: { + invertjump(fs, e); + break; + } + case VRELOCABLE: + case VNONRELOC: { + discharge2anyreg(fs, e); + freeexp(fs, e); + e->u.s.info = luaK_codeABC(fs, OP_NOT, 0, e->u.s.info, 0); + e->k = VRELOCABLE; + break; + } + default: { + lua_assert(0); /* cannot happen */ + break; + } + } + /* interchange true and false lists */ + { int temp = e->f; e->f = e->t; e->t = temp; } + removevalues(fs, e->f); + removevalues(fs, e->t); +} + + +void luaK_indexed (FuncState *fs, expdesc *t, expdesc *k) { + t->u.s.aux = luaK_exp2RK(fs, k); + t->k = VINDEXED; +} + + +static int constfolding (OpCode op, expdesc *e1, expdesc *e2) { + lua_Number v1, v2, r; + if (!isnumeral(e1) || !isnumeral(e2)) return 0; + v1 = e1->u.nval; + v2 = e2->u.nval; + switch (op) { + case OP_ADD: r = luai_numadd(v1, v2); break; + case OP_SUB: r = luai_numsub(v1, v2); break; + case OP_MUL: r = luai_nummul(v1, v2); break; + case OP_DIV: + if (v2 == 0) return 0; /* do not attempt to divide by 0 */ + r = luai_numdiv(v1, v2); break; + case OP_MOD: + if (v2 == 0) return 0; /* do not attempt to divide by 0 */ + r = luai_nummod(v1, v2); break; + case OP_POW: r = luai_numpow(v1, v2); break; + case OP_UNM: r = luai_numunm(v1); break; + case OP_LEN: return 0; /* no constant folding for 'len' */ + default: lua_assert(0); r = 0; break; + } + if (luai_numisnan(r)) return 0; /* do not attempt to produce NaN */ + e1->u.nval = r; + return 1; +} + + +static void codearith (FuncState *fs, OpCode op, expdesc *e1, expdesc *e2) { + if (constfolding(op, e1, e2)) + return; + else { + int o2 = (op != OP_UNM && op != OP_LEN) ? luaK_exp2RK(fs, e2) : 0; + int o1 = luaK_exp2RK(fs, e1); + if (o1 > o2) { + freeexp(fs, e1); + freeexp(fs, e2); + } + else { + freeexp(fs, e2); + freeexp(fs, e1); + } + e1->u.s.info = luaK_codeABC(fs, op, 0, o1, o2); + e1->k = VRELOCABLE; + } +} + + +static void codecomp (FuncState *fs, OpCode op, int cond, expdesc *e1, + expdesc *e2) { + int o1 = luaK_exp2RK(fs, e1); + int o2 = luaK_exp2RK(fs, e2); + freeexp(fs, e2); + freeexp(fs, e1); + if (cond == 0 && op != OP_EQ) { + int temp; /* exchange args to replace by `<' or `<=' */ + temp = o1; o1 = o2; o2 = temp; /* o1 <==> o2 */ + cond = 1; + } + e1->u.s.info = condjump(fs, op, cond, o1, o2); + e1->k = VJMP; +} + + +void luaK_prefix (FuncState *fs, UnOpr op, expdesc *e) { + expdesc e2; + e2.t = e2.f = NO_JUMP; e2.k = VKNUM; e2.u.nval = 0; + switch (op) { + case OPR_MINUS: { + if (!isnumeral(e)) + luaK_exp2anyreg(fs, e); /* cannot operate on non-numeric constants */ + codearith(fs, OP_UNM, e, &e2); + break; + } + case OPR_NOT: codenot(fs, e); break; + case OPR_LEN: { + luaK_exp2anyreg(fs, e); /* cannot operate on constants */ + codearith(fs, OP_LEN, e, &e2); + break; + } + default: lua_assert(0); + } +} + + +void luaK_infix (FuncState *fs, BinOpr op, expdesc *v) { + switch (op) { + case OPR_AND: { + luaK_goiftrue(fs, v); + break; + } + case OPR_OR: { + luaK_goiffalse(fs, v); + break; + } + case OPR_CONCAT: { + luaK_exp2nextreg(fs, v); /* operand must be on the `stack' */ + break; + } + case OPR_ADD: case OPR_SUB: case OPR_MUL: case OPR_DIV: + case OPR_MOD: case OPR_POW: { + if (!isnumeral(v)) luaK_exp2RK(fs, v); + break; + } + default: { + luaK_exp2RK(fs, v); + break; + } + } +} + + +void luaK_posfix (FuncState *fs, BinOpr op, expdesc *e1, expdesc *e2) { + switch (op) { + case OPR_AND: { + lua_assert(e1->t == NO_JUMP); /* list must be closed */ + luaK_dischargevars(fs, e2); + luaK_concat(fs, &e2->f, e1->f); + *e1 = *e2; + break; + } + case OPR_OR: { + lua_assert(e1->f == NO_JUMP); /* list must be closed */ + luaK_dischargevars(fs, e2); + luaK_concat(fs, &e2->t, e1->t); + *e1 = *e2; + break; + } + case OPR_CONCAT: { + luaK_exp2val(fs, e2); + if (e2->k == VRELOCABLE && GET_OPCODE(getcode(fs, e2)) == OP_CONCAT) { + lua_assert(e1->u.s.info == GETARG_B(getcode(fs, e2))-1); + freeexp(fs, e1); + SETARG_B(getcode(fs, e2), e1->u.s.info); + e1->k = VRELOCABLE; e1->u.s.info = e2->u.s.info; + } + else { + luaK_exp2nextreg(fs, e2); /* operand must be on the 'stack' */ + codearith(fs, OP_CONCAT, e1, e2); + } + break; + } + case OPR_ADD: codearith(fs, OP_ADD, e1, e2); break; + case OPR_SUB: codearith(fs, OP_SUB, e1, e2); break; + case OPR_MUL: codearith(fs, OP_MUL, e1, e2); break; + case OPR_DIV: codearith(fs, OP_DIV, e1, e2); break; + case OPR_MOD: codearith(fs, OP_MOD, e1, e2); break; + case OPR_POW: codearith(fs, OP_POW, e1, e2); break; + case OPR_EQ: codecomp(fs, OP_EQ, 1, e1, e2); break; + case OPR_NE: codecomp(fs, OP_EQ, 0, e1, e2); break; + case OPR_LT: codecomp(fs, OP_LT, 1, e1, e2); break; + case OPR_LE: codecomp(fs, OP_LE, 1, e1, e2); break; + case OPR_GT: codecomp(fs, OP_LT, 0, e1, e2); break; + case OPR_GE: codecomp(fs, OP_LE, 0, e1, e2); break; + default: lua_assert(0); + } +} + + +void luaK_fixline (FuncState *fs, int line) { + fs->f->lineinfo[fs->pc - 1] = line; +} + + +static int luaK_code (FuncState *fs, Instruction i, int line) { + Proto *f = fs->f; + dischargejpc(fs); /* `pc' will change */ + /* put new instruction in code array */ + luaM_growvector(fs->L, f->code, fs->pc, f->sizecode, Instruction, + MAX_INT, "code size overflow"); + f->code[fs->pc] = i; + /* save corresponding line information */ + luaM_growvector(fs->L, f->lineinfo, fs->pc, f->sizelineinfo, int, + MAX_INT, "code size overflow"); + f->lineinfo[fs->pc] = line; + return fs->pc++; +} + + +int luaK_codeABC (FuncState *fs, OpCode o, int a, int b, int c) { + lua_assert(getOpMode(o) == iABC); + lua_assert(getBMode(o) != OpArgN || b == 0); + lua_assert(getCMode(o) != OpArgN || c == 0); + return luaK_code(fs, CREATE_ABC(o, a, b, c), fs->ls->lastline); +} + + +int luaK_codeABx (FuncState *fs, OpCode o, int a, unsigned int bc) { + lua_assert(getOpMode(o) == iABx || getOpMode(o) == iAsBx); + lua_assert(getCMode(o) == OpArgN); + return luaK_code(fs, CREATE_ABx(o, a, bc), fs->ls->lastline); +} + + +void luaK_setlist (FuncState *fs, int base, int nelems, int tostore) { + int c = (nelems - 1)/LFIELDS_PER_FLUSH + 1; + int b = (tostore == LUA_MULTRET) ? 0 : tostore; + lua_assert(tostore != 0); + if (c <= MAXARG_C) + luaK_codeABC(fs, OP_SETLIST, base, b, c); + else { + luaK_codeABC(fs, OP_SETLIST, base, b, 0); + luaK_code(fs, cast(Instruction, c), fs->ls->lastline); + } + fs->freereg = base + 1; /* free registers with list values */ +} + diff --git a/include/lua/lcode.h b/include/lua/lcode.h new file mode 100644 index 0000000..b941c60 --- /dev/null +++ b/include/lua/lcode.h @@ -0,0 +1,76 @@ +/* +** $Id: lcode.h,v 1.48.1.1 2007/12/27 13:02:25 roberto Exp $ +** Code generator for Lua +** See Copyright Notice in lua.h +*/ + +#ifndef lcode_h +#define lcode_h + +#include "llex.h" +#include "lobject.h" +#include "lopcodes.h" +#include "lparser.h" + + +/* +** Marks the end of a patch list. It is an invalid value both as an absolute +** address, and as a list link (would link an element to itself). +*/ +#define NO_JUMP (-1) + + +/* +** grep "ORDER OPR" if you change these enums +*/ +typedef enum BinOpr { + OPR_ADD, OPR_SUB, OPR_MUL, OPR_DIV, OPR_MOD, OPR_POW, + OPR_CONCAT, + OPR_NE, OPR_EQ, + OPR_LT, OPR_LE, OPR_GT, OPR_GE, + OPR_AND, OPR_OR, + OPR_NOBINOPR +} BinOpr; + + +typedef enum UnOpr { OPR_MINUS, OPR_NOT, OPR_LEN, OPR_NOUNOPR } UnOpr; + + +#define getcode(fs,e) ((fs)->f->code[(e)->u.s.info]) + +#define luaK_codeAsBx(fs,o,A,sBx) luaK_codeABx(fs,o,A,(sBx)+MAXARG_sBx) + +#define luaK_setmultret(fs,e) luaK_setreturns(fs, e, LUA_MULTRET) + +LUAI_FUNC int luaK_codeABx (FuncState *fs, OpCode o, int A, unsigned int Bx); +LUAI_FUNC int luaK_codeABC (FuncState *fs, OpCode o, int A, int B, int C); +LUAI_FUNC void luaK_fixline (FuncState *fs, int line); +LUAI_FUNC void luaK_nil (FuncState *fs, int from, int n); +LUAI_FUNC void luaK_reserveregs (FuncState *fs, int n); +LUAI_FUNC void luaK_checkstack (FuncState *fs, int n); +LUAI_FUNC int luaK_stringK (FuncState *fs, TString *s); +LUAI_FUNC int luaK_numberK (FuncState *fs, lua_Number r); +LUAI_FUNC void luaK_dischargevars (FuncState *fs, expdesc *e); +LUAI_FUNC int luaK_exp2anyreg (FuncState *fs, expdesc *e); +LUAI_FUNC void luaK_exp2nextreg (FuncState *fs, expdesc *e); +LUAI_FUNC void luaK_exp2val (FuncState *fs, expdesc *e); +LUAI_FUNC int luaK_exp2RK (FuncState *fs, expdesc *e); +LUAI_FUNC void luaK_self (FuncState *fs, expdesc *e, expdesc *key); +LUAI_FUNC void luaK_indexed (FuncState *fs, expdesc *t, expdesc *k); +LUAI_FUNC void luaK_goiftrue (FuncState *fs, expdesc *e); +LUAI_FUNC void luaK_storevar (FuncState *fs, expdesc *var, expdesc *e); +LUAI_FUNC void luaK_setreturns (FuncState *fs, expdesc *e, int nresults); +LUAI_FUNC void luaK_setoneret (FuncState *fs, expdesc *e); +LUAI_FUNC int luaK_jump (FuncState *fs); +LUAI_FUNC void luaK_ret (FuncState *fs, int first, int nret); +LUAI_FUNC void luaK_patchlist (FuncState *fs, int list, int target); +LUAI_FUNC void luaK_patchtohere (FuncState *fs, int list); +LUAI_FUNC void luaK_concat (FuncState *fs, int *l1, int l2); +LUAI_FUNC int luaK_getlabel (FuncState *fs); +LUAI_FUNC void luaK_prefix (FuncState *fs, UnOpr op, expdesc *v); +LUAI_FUNC void luaK_infix (FuncState *fs, BinOpr op, expdesc *v); +LUAI_FUNC void luaK_posfix (FuncState *fs, BinOpr op, expdesc *v1, expdesc *v2); +LUAI_FUNC void luaK_setlist (FuncState *fs, int base, int nelems, int tostore); + + +#endif diff --git a/include/lua/ldblib.c b/include/lua/ldblib.c new file mode 100644 index 0000000..67de122 --- /dev/null +++ b/include/lua/ldblib.c @@ -0,0 +1,397 @@ +/* +** $Id: ldblib.c,v 1.104.1.3 2008/01/21 13:11:21 roberto Exp $ +** Interface from Lua to its debug API +** See Copyright Notice in lua.h +*/ + + +#include +#include +#include + +#define ldblib_c +#define LUA_LIB + +#include "lua.h" + +#include "lauxlib.h" +#include "lualib.h" + + + +static int db_getregistry (lua_State *L) { + lua_pushvalue(L, LUA_REGISTRYINDEX); + return 1; +} + + +static int db_getmetatable (lua_State *L) { + luaL_checkany(L, 1); + if (!lua_getmetatable(L, 1)) { + lua_pushnil(L); /* no metatable */ + } + return 1; +} + + +static int db_setmetatable (lua_State *L) { + int t = lua_type(L, 2); + luaL_argcheck(L, t == LUA_TNIL || t == LUA_TTABLE, 2, + "nil or table expected"); + lua_settop(L, 2); + lua_pushboolean(L, lua_setmetatable(L, 1)); + return 1; +} + + +static int db_getfenv (lua_State *L) { + lua_getfenv(L, 1); + return 1; +} + + +static int db_setfenv (lua_State *L) { + luaL_checktype(L, 2, LUA_TTABLE); + lua_settop(L, 2); + if (lua_setfenv(L, 1) == 0) + luaL_error(L, LUA_QL("setfenv") + " cannot change environment of given object"); + return 1; +} + + +static void settabss (lua_State *L, const char *i, const char *v) { + lua_pushstring(L, v); + lua_setfield(L, -2, i); +} + + +static void settabsi (lua_State *L, const char *i, int v) { + lua_pushinteger(L, v); + lua_setfield(L, -2, i); +} + + +static lua_State *getthread (lua_State *L, int *arg) { + if (lua_isthread(L, 1)) { + *arg = 1; + return lua_tothread(L, 1); + } + else { + *arg = 0; + return L; + } +} + + +static void treatstackoption (lua_State *L, lua_State *L1, const char *fname) { + if (L == L1) { + lua_pushvalue(L, -2); + lua_remove(L, -3); + } + else + lua_xmove(L1, L, 1); + lua_setfield(L, -2, fname); +} + + +static int db_getinfo (lua_State *L) { + lua_Debug ar; + int arg; + lua_State *L1 = getthread(L, &arg); + const char *options = luaL_optstring(L, arg+2, "flnSu"); + if (lua_isnumber(L, arg+1)) { + if (!lua_getstack(L1, (int)lua_tointeger(L, arg+1), &ar)) { + lua_pushnil(L); /* level out of range */ + return 1; + } + } + else if (lua_isfunction(L, arg+1)) { + lua_pushfstring(L, ">%s", options); + options = lua_tostring(L, -1); + lua_pushvalue(L, arg+1); + lua_xmove(L, L1, 1); + } + else + return luaL_argerror(L, arg+1, "function or level expected"); + if (!lua_getinfo(L1, options, &ar)) + return luaL_argerror(L, arg+2, "invalid option"); + lua_createtable(L, 0, 2); + if (strchr(options, 'S')) { + settabss(L, "source", ar.source); + settabss(L, "short_src", ar.short_src); + settabsi(L, "linedefined", ar.linedefined); + settabsi(L, "lastlinedefined", ar.lastlinedefined); + settabss(L, "what", ar.what); + } + if (strchr(options, 'l')) + settabsi(L, "currentline", ar.currentline); + if (strchr(options, 'u')) + settabsi(L, "nups", ar.nups); + if (strchr(options, 'n')) { + settabss(L, "name", ar.name); + settabss(L, "namewhat", ar.namewhat); + } + if (strchr(options, 'L')) + treatstackoption(L, L1, "activelines"); + if (strchr(options, 'f')) + treatstackoption(L, L1, "func"); + return 1; /* return table */ +} + + +static int db_getlocal (lua_State *L) { + int arg; + lua_State *L1 = getthread(L, &arg); + lua_Debug ar; + const char *name; + if (!lua_getstack(L1, luaL_checkint(L, arg+1), &ar)) /* out of range? */ + return luaL_argerror(L, arg+1, "level out of range"); + name = lua_getlocal(L1, &ar, luaL_checkint(L, arg+2)); + if (name) { + lua_xmove(L1, L, 1); + lua_pushstring(L, name); + lua_pushvalue(L, -2); + return 2; + } + else { + lua_pushnil(L); + return 1; + } +} + + +static int db_setlocal (lua_State *L) { + int arg; + lua_State *L1 = getthread(L, &arg); + lua_Debug ar; + if (!lua_getstack(L1, luaL_checkint(L, arg+1), &ar)) /* out of range? */ + return luaL_argerror(L, arg+1, "level out of range"); + luaL_checkany(L, arg+3); + lua_settop(L, arg+3); + lua_xmove(L, L1, 1); + lua_pushstring(L, lua_setlocal(L1, &ar, luaL_checkint(L, arg+2))); + return 1; +} + + +static int auxupvalue (lua_State *L, int get) { + const char *name; + int n = luaL_checkint(L, 2); + luaL_checktype(L, 1, LUA_TFUNCTION); + if (lua_iscfunction(L, 1)) return 0; /* cannot touch C upvalues from Lua */ + name = get ? lua_getupvalue(L, 1, n) : lua_setupvalue(L, 1, n); + if (name == NULL) return 0; + lua_pushstring(L, name); + lua_insert(L, -(get+1)); + return get + 1; +} + + +static int db_getupvalue (lua_State *L) { + return auxupvalue(L, 1); +} + + +static int db_setupvalue (lua_State *L) { + luaL_checkany(L, 3); + return auxupvalue(L, 0); +} + + + +static const char KEY_HOOK = 'h'; + + +static void hookf (lua_State *L, lua_Debug *ar) { + static const char *const hooknames[] = + {"call", "return", "line", "count", "tail return"}; + lua_pushlightuserdata(L, (void *)&KEY_HOOK); + lua_rawget(L, LUA_REGISTRYINDEX); + lua_pushlightuserdata(L, L); + lua_rawget(L, -2); + if (lua_isfunction(L, -1)) { + lua_pushstring(L, hooknames[(int)ar->event]); + if (ar->currentline >= 0) + lua_pushinteger(L, ar->currentline); + else lua_pushnil(L); + lua_assert(lua_getinfo(L, "lS", ar)); + lua_call(L, 2, 0); + } +} + + +static int makemask (const char *smask, int count) { + int mask = 0; + if (strchr(smask, 'c')) mask |= LUA_MASKCALL; + if (strchr(smask, 'r')) mask |= LUA_MASKRET; + if (strchr(smask, 'l')) mask |= LUA_MASKLINE; + if (count > 0) mask |= LUA_MASKCOUNT; + return mask; +} + + +static char *unmakemask (int mask, char *smask) { + int i = 0; + if (mask & LUA_MASKCALL) smask[i++] = 'c'; + if (mask & LUA_MASKRET) smask[i++] = 'r'; + if (mask & LUA_MASKLINE) smask[i++] = 'l'; + smask[i] = '\0'; + return smask; +} + + +static void gethooktable (lua_State *L) { + lua_pushlightuserdata(L, (void *)&KEY_HOOK); + lua_rawget(L, LUA_REGISTRYINDEX); + if (!lua_istable(L, -1)) { + lua_pop(L, 1); + lua_createtable(L, 0, 1); + lua_pushlightuserdata(L, (void *)&KEY_HOOK); + lua_pushvalue(L, -2); + lua_rawset(L, LUA_REGISTRYINDEX); + } +} + + +static int db_sethook (lua_State *L) { + int arg, mask, count; + lua_Hook func; + lua_State *L1 = getthread(L, &arg); + if (lua_isnoneornil(L, arg+1)) { + lua_settop(L, arg+1); + func = NULL; mask = 0; count = 0; /* turn off hooks */ + } + else { + const char *smask = luaL_checkstring(L, arg+2); + luaL_checktype(L, arg+1, LUA_TFUNCTION); + count = luaL_optint(L, arg+3, 0); + func = hookf; mask = makemask(smask, count); + } + gethooktable(L); + lua_pushlightuserdata(L, L1); + lua_pushvalue(L, arg+1); + lua_rawset(L, -3); /* set new hook */ + lua_pop(L, 1); /* remove hook table */ + lua_sethook(L1, func, mask, count); /* set hooks */ + return 0; +} + + +static int db_gethook (lua_State *L) { + int arg; + lua_State *L1 = getthread(L, &arg); + char buff[5]; + int mask = lua_gethookmask(L1); + lua_Hook hook = lua_gethook(L1); + if (hook != NULL && hook != hookf) /* external hook? */ + lua_pushliteral(L, "external hook"); + else { + gethooktable(L); + lua_pushlightuserdata(L, L1); + lua_rawget(L, -2); /* get hook */ + lua_remove(L, -2); /* remove hook table */ + } + lua_pushstring(L, unmakemask(mask, buff)); + lua_pushinteger(L, lua_gethookcount(L1)); + return 3; +} + + +static int db_debug (lua_State *L) { + for (;;) { + char buffer[250]; + fputs("lua_debug> ", stderr); + if (fgets(buffer, sizeof(buffer), stdin) == 0 || + strcmp(buffer, "cont\n") == 0) + return 0; + if (luaL_loadbuffer(L, buffer, strlen(buffer), "=(debug command)") || + lua_pcall(L, 0, 0, 0)) { + fputs(lua_tostring(L, -1), stderr); + fputs("\n", stderr); + } + lua_settop(L, 0); /* remove eventual returns */ + } +} + + +#define LEVELS1 12 /* size of the first part of the stack */ +#define LEVELS2 10 /* size of the second part of the stack */ + +static int db_errorfb (lua_State *L) { + int level; + int firstpart = 1; /* still before eventual `...' */ + int arg; + lua_State *L1 = getthread(L, &arg); + lua_Debug ar; + if (lua_isnumber(L, arg+2)) { + level = (int)lua_tointeger(L, arg+2); + lua_pop(L, 1); + } + else + level = (L == L1) ? 1 : 0; /* level 0 may be this own function */ + if (lua_gettop(L) == arg) + lua_pushliteral(L, ""); + else if (!lua_isstring(L, arg+1)) return 1; /* message is not a string */ + else lua_pushliteral(L, "\n"); + lua_pushliteral(L, "stack traceback:"); + while (lua_getstack(L1, level++, &ar)) { + if (level > LEVELS1 && firstpart) { + /* no more than `LEVELS2' more levels? */ + if (!lua_getstack(L1, level+LEVELS2, &ar)) + level--; /* keep going */ + else { + lua_pushliteral(L, "\n\t..."); /* too many levels */ + while (lua_getstack(L1, level+LEVELS2, &ar)) /* find last levels */ + level++; + } + firstpart = 0; + continue; + } + lua_pushliteral(L, "\n\t"); + lua_getinfo(L1, "Snl", &ar); + lua_pushfstring(L, "%s:", ar.short_src); + if (ar.currentline > 0) + lua_pushfstring(L, "%d:", ar.currentline); + if (*ar.namewhat != '\0') /* is there a name? */ + lua_pushfstring(L, " in function " LUA_QS, ar.name); + else { + if (*ar.what == 'm') /* main? */ + lua_pushfstring(L, " in main chunk"); + else if (*ar.what == 'C' || *ar.what == 't') + lua_pushliteral(L, " ?"); /* C function or tail call */ + else + lua_pushfstring(L, " in function <%s:%d>", + ar.short_src, ar.linedefined); + } + lua_concat(L, lua_gettop(L) - arg); + } + lua_concat(L, lua_gettop(L) - arg); + return 1; +} + + +static const luaL_Reg dblib[] = { + {"debug", db_debug}, + {"getfenv", db_getfenv}, + {"gethook", db_gethook}, + {"getinfo", db_getinfo}, + {"getlocal", db_getlocal}, + {"getregistry", db_getregistry}, + {"getmetatable", db_getmetatable}, + {"getupvalue", db_getupvalue}, + {"setfenv", db_setfenv}, + {"sethook", db_sethook}, + {"setlocal", db_setlocal}, + {"setmetatable", db_setmetatable}, + {"setupvalue", db_setupvalue}, + {"traceback", db_errorfb}, + {NULL, NULL} +}; + + +LUALIB_API int luaopen_debug (lua_State *L) { + luaL_register(L, LUA_DBLIBNAME, dblib); + return 1; +} + diff --git a/include/lua/ldebug.c b/include/lua/ldebug.c new file mode 100644 index 0000000..50ad3d3 --- /dev/null +++ b/include/lua/ldebug.c @@ -0,0 +1,638 @@ +/* +** $Id: ldebug.c,v 2.29.1.6 2008/05/08 16:56:26 roberto Exp $ +** Debug Interface +** See Copyright Notice in lua.h +*/ + + +#include +#include +#include + + +#define ldebug_c +#define LUA_CORE + +#include "lua.h" + +#include "lapi.h" +#include "lcode.h" +#include "ldebug.h" +#include "ldo.h" +#include "lfunc.h" +#include "lobject.h" +#include "lopcodes.h" +#include "lstate.h" +#include "lstring.h" +#include "ltable.h" +#include "ltm.h" +#include "lvm.h" + + + +static const char *getfuncname (lua_State *L, CallInfo *ci, const char **name); + + +static int currentpc (lua_State *L, CallInfo *ci) { + if (!isLua(ci)) return -1; /* function is not a Lua function? */ + if (ci == L->ci) + ci->savedpc = L->savedpc; + return pcRel(ci->savedpc, ci_func(ci)->l.p); +} + + +static int currentline (lua_State *L, CallInfo *ci) { + int pc = currentpc(L, ci); + if (pc < 0) + return -1; /* only active lua functions have current-line information */ + else + return getline(ci_func(ci)->l.p, pc); +} + + +/* +** this function can be called asynchronous (e.g. during a signal) +*/ +LUA_API int lua_sethook (lua_State *L, lua_Hook func, int mask, int count) { + if (func == NULL || mask == 0) { /* turn off hooks? */ + mask = 0; + func = NULL; + } + L->hook = func; + L->basehookcount = count; + resethookcount(L); + L->hookmask = cast_byte(mask); + return 1; +} + + +LUA_API lua_Hook lua_gethook (lua_State *L) { + return L->hook; +} + + +LUA_API int lua_gethookmask (lua_State *L) { + return L->hookmask; +} + + +LUA_API int lua_gethookcount (lua_State *L) { + return L->basehookcount; +} + + +LUA_API int lua_getstack (lua_State *L, int level, lua_Debug *ar) { + int status; + CallInfo *ci; + lua_lock(L); + for (ci = L->ci; level > 0 && ci > L->base_ci; ci--) { + level--; + if (f_isLua(ci)) /* Lua function? */ + level -= ci->tailcalls; /* skip lost tail calls */ + } + if (level == 0 && ci > L->base_ci) { /* level found? */ + status = 1; + ar->i_ci = cast_int(ci - L->base_ci); + } + else if (level < 0) { /* level is of a lost tail call? */ + status = 1; + ar->i_ci = 0; + } + else status = 0; /* no such level */ + lua_unlock(L); + return status; +} + + +static Proto *getluaproto (CallInfo *ci) { + return (isLua(ci) ? ci_func(ci)->l.p : NULL); +} + + +static const char *findlocal (lua_State *L, CallInfo *ci, int n) { + const char *name; + Proto *fp = getluaproto(ci); + if (fp && (name = luaF_getlocalname(fp, n, currentpc(L, ci))) != NULL) + return name; /* is a local variable in a Lua function */ + else { + StkId limit = (ci == L->ci) ? L->top : (ci+1)->func; + if (limit - ci->base >= n && n > 0) /* is 'n' inside 'ci' stack? */ + return "(*temporary)"; + else + return NULL; + } +} + + +LUA_API const char *lua_getlocal (lua_State *L, const lua_Debug *ar, int n) { + CallInfo *ci = L->base_ci + ar->i_ci; + const char *name = findlocal(L, ci, n); + lua_lock(L); + if (name) + luaA_pushobject(L, ci->base + (n - 1)); + lua_unlock(L); + return name; +} + + +LUA_API const char *lua_setlocal (lua_State *L, const lua_Debug *ar, int n) { + CallInfo *ci = L->base_ci + ar->i_ci; + const char *name = findlocal(L, ci, n); + lua_lock(L); + if (name) + setobjs2s(L, ci->base + (n - 1), L->top - 1); + L->top--; /* pop value */ + lua_unlock(L); + return name; +} + + +static void funcinfo (lua_Debug *ar, Closure *cl) { + if (cl->c.isC) { + ar->source = "=[C]"; + ar->linedefined = -1; + ar->lastlinedefined = -1; + ar->what = "C"; + } + else { + ar->source = getstr(cl->l.p->source); + ar->linedefined = cl->l.p->linedefined; + ar->lastlinedefined = cl->l.p->lastlinedefined; + ar->what = (ar->linedefined == 0) ? "main" : "Lua"; + } + luaO_chunkid(ar->short_src, ar->source, LUA_IDSIZE); +} + + +static void info_tailcall (lua_Debug *ar) { + ar->name = ar->namewhat = ""; + ar->what = "tail"; + ar->lastlinedefined = ar->linedefined = ar->currentline = -1; + ar->source = "=(tail call)"; + luaO_chunkid(ar->short_src, ar->source, LUA_IDSIZE); + ar->nups = 0; +} + + +static void collectvalidlines (lua_State *L, Closure *f) { + if (f == NULL || f->c.isC) { + setnilvalue(L->top); + } + else { + Table *t = luaH_new(L, 0, 0); + int *lineinfo = f->l.p->lineinfo; + int i; + for (i=0; il.p->sizelineinfo; i++) + setbvalue(luaH_setnum(L, t, lineinfo[i]), 1); + sethvalue(L, L->top, t); + } + incr_top(L); +} + + +static int auxgetinfo (lua_State *L, const char *what, lua_Debug *ar, + Closure *f, CallInfo *ci) { + int status = 1; + if (f == NULL) { + info_tailcall(ar); + return status; + } + for (; *what; what++) { + switch (*what) { + case 'S': { + funcinfo(ar, f); + break; + } + case 'l': { + ar->currentline = (ci) ? currentline(L, ci) : -1; + break; + } + case 'u': { + ar->nups = f->c.nupvalues; + break; + } + case 'n': { + ar->namewhat = (ci) ? getfuncname(L, ci, &ar->name) : NULL; + if (ar->namewhat == NULL) { + ar->namewhat = ""; /* not found */ + ar->name = NULL; + } + break; + } + case 'L': + case 'f': /* handled by lua_getinfo */ + break; + default: status = 0; /* invalid option */ + } + } + return status; +} + + +LUA_API int lua_getinfo (lua_State *L, const char *what, lua_Debug *ar) { + int status; + Closure *f = NULL; + CallInfo *ci = NULL; + lua_lock(L); + if (*what == '>') { + StkId func = L->top - 1; + luai_apicheck(L, ttisfunction(func)); + what++; /* skip the '>' */ + f = clvalue(func); + L->top--; /* pop function */ + } + else if (ar->i_ci != 0) { /* no tail call? */ + ci = L->base_ci + ar->i_ci; + lua_assert(ttisfunction(ci->func)); + f = clvalue(ci->func); + } + status = auxgetinfo(L, what, ar, f, ci); + if (strchr(what, 'f')) { + if (f == NULL) setnilvalue(L->top); + else setclvalue(L, L->top, f); + incr_top(L); + } + if (strchr(what, 'L')) + collectvalidlines(L, f); + lua_unlock(L); + return status; +} + + +/* +** {====================================================== +** Symbolic Execution and code checker +** ======================================================= +*/ + +#define check(x) if (!(x)) return 0; + +#define checkjump(pt,pc) check(0 <= pc && pc < pt->sizecode) + +#define checkreg(pt,reg) check((reg) < (pt)->maxstacksize) + + + +static int precheck (const Proto *pt) { + check(pt->maxstacksize <= MAXSTACK); + check(pt->numparams+(pt->is_vararg & VARARG_HASARG) <= pt->maxstacksize); + check(!(pt->is_vararg & VARARG_NEEDSARG) || + (pt->is_vararg & VARARG_HASARG)); + check(pt->sizeupvalues <= pt->nups); + check(pt->sizelineinfo == pt->sizecode || pt->sizelineinfo == 0); + check(pt->sizecode > 0 && GET_OPCODE(pt->code[pt->sizecode-1]) == OP_RETURN); + return 1; +} + + +#define checkopenop(pt,pc) luaG_checkopenop((pt)->code[(pc)+1]) + +int luaG_checkopenop (Instruction i) { + switch (GET_OPCODE(i)) { + case OP_CALL: + case OP_TAILCALL: + case OP_RETURN: + case OP_SETLIST: { + check(GETARG_B(i) == 0); + return 1; + } + default: return 0; /* invalid instruction after an open call */ + } +} + + +static int checkArgMode (const Proto *pt, int r, enum OpArgMask mode) { + switch (mode) { + case OpArgN: check(r == 0); break; + case OpArgU: break; + case OpArgR: checkreg(pt, r); break; + case OpArgK: + check(ISK(r) ? INDEXK(r) < pt->sizek : r < pt->maxstacksize); + break; + } + return 1; +} + + +static Instruction symbexec (const Proto *pt, int lastpc, int reg) { + int pc; + int last; /* stores position of last instruction that changed `reg' */ + last = pt->sizecode-1; /* points to final return (a `neutral' instruction) */ + check(precheck(pt)); + for (pc = 0; pc < lastpc; pc++) { + Instruction i = pt->code[pc]; + OpCode op = GET_OPCODE(i); + int a = GETARG_A(i); + int b = 0; + int c = 0; + check(op < NUM_OPCODES); + checkreg(pt, a); + switch (getOpMode(op)) { + case iABC: { + b = GETARG_B(i); + c = GETARG_C(i); + check(checkArgMode(pt, b, getBMode(op))); + check(checkArgMode(pt, c, getCMode(op))); + break; + } + case iABx: { + b = GETARG_Bx(i); + if (getBMode(op) == OpArgK) check(b < pt->sizek); + break; + } + case iAsBx: { + b = GETARG_sBx(i); + if (getBMode(op) == OpArgR) { + int dest = pc+1+b; + check(0 <= dest && dest < pt->sizecode); + if (dest > 0) { + int j; + /* check that it does not jump to a setlist count; this + is tricky, because the count from a previous setlist may + have the same value of an invalid setlist; so, we must + go all the way back to the first of them (if any) */ + for (j = 0; j < dest; j++) { + Instruction d = pt->code[dest-1-j]; + if (!(GET_OPCODE(d) == OP_SETLIST && GETARG_C(d) == 0)) break; + } + /* if 'j' is even, previous value is not a setlist (even if + it looks like one) */ + check((j&1) == 0); + } + } + break; + } + } + if (testAMode(op)) { + if (a == reg) last = pc; /* change register `a' */ + } + if (testTMode(op)) { + check(pc+2 < pt->sizecode); /* check skip */ + check(GET_OPCODE(pt->code[pc+1]) == OP_JMP); + } + switch (op) { + case OP_LOADBOOL: { + if (c == 1) { /* does it jump? */ + check(pc+2 < pt->sizecode); /* check its jump */ + check(GET_OPCODE(pt->code[pc+1]) != OP_SETLIST || + GETARG_C(pt->code[pc+1]) != 0); + } + break; + } + case OP_LOADNIL: { + if (a <= reg && reg <= b) + last = pc; /* set registers from `a' to `b' */ + break; + } + case OP_GETUPVAL: + case OP_SETUPVAL: { + check(b < pt->nups); + break; + } + case OP_GETGLOBAL: + case OP_SETGLOBAL: { + check(ttisstring(&pt->k[b])); + break; + } + case OP_SELF: { + checkreg(pt, a+1); + if (reg == a+1) last = pc; + break; + } + case OP_CONCAT: { + check(b < c); /* at least two operands */ + break; + } + case OP_TFORLOOP: { + check(c >= 1); /* at least one result (control variable) */ + checkreg(pt, a+2+c); /* space for results */ + if (reg >= a+2) last = pc; /* affect all regs above its base */ + break; + } + case OP_FORLOOP: + case OP_FORPREP: + checkreg(pt, a+3); + /* go through */ + case OP_JMP: { + int dest = pc+1+b; + /* not full check and jump is forward and do not skip `lastpc'? */ + if (reg != NO_REG && pc < dest && dest <= lastpc) + pc += b; /* do the jump */ + break; + } + case OP_CALL: + case OP_TAILCALL: { + if (b != 0) { + checkreg(pt, a+b-1); + } + c--; /* c = num. returns */ + if (c == LUA_MULTRET) { + check(checkopenop(pt, pc)); + } + else if (c != 0) + checkreg(pt, a+c-1); + if (reg >= a) last = pc; /* affect all registers above base */ + break; + } + case OP_RETURN: { + b--; /* b = num. returns */ + if (b > 0) checkreg(pt, a+b-1); + break; + } + case OP_SETLIST: { + if (b > 0) checkreg(pt, a + b); + if (c == 0) { + pc++; + check(pc < pt->sizecode - 1); + } + break; + } + case OP_CLOSURE: { + int nup, j; + check(b < pt->sizep); + nup = pt->p[b]->nups; + check(pc + nup < pt->sizecode); + for (j = 1; j <= nup; j++) { + OpCode op1 = GET_OPCODE(pt->code[pc + j]); + check(op1 == OP_GETUPVAL || op1 == OP_MOVE); + } + if (reg != NO_REG) /* tracing? */ + pc += nup; /* do not 'execute' these pseudo-instructions */ + break; + } + case OP_VARARG: { + check((pt->is_vararg & VARARG_ISVARARG) && + !(pt->is_vararg & VARARG_NEEDSARG)); + b--; + if (b == LUA_MULTRET) check(checkopenop(pt, pc)); + checkreg(pt, a+b-1); + break; + } + default: break; + } + } + return pt->code[last]; +} + +#undef check +#undef checkjump +#undef checkreg + +/* }====================================================== */ + + +int luaG_checkcode (const Proto *pt) { + return (symbexec(pt, pt->sizecode, NO_REG) != 0); +} + + +static const char *kname (Proto *p, int c) { + if (ISK(c) && ttisstring(&p->k[INDEXK(c)])) + return svalue(&p->k[INDEXK(c)]); + else + return "?"; +} + + +static const char *getobjname (lua_State *L, CallInfo *ci, int stackpos, + const char **name) { + if (isLua(ci)) { /* a Lua function? */ + Proto *p = ci_func(ci)->l.p; + int pc = currentpc(L, ci); + Instruction i; + *name = luaF_getlocalname(p, stackpos+1, pc); + if (*name) /* is a local? */ + return "local"; + i = symbexec(p, pc, stackpos); /* try symbolic execution */ + lua_assert(pc != -1); + switch (GET_OPCODE(i)) { + case OP_GETGLOBAL: { + int g = GETARG_Bx(i); /* global index */ + lua_assert(ttisstring(&p->k[g])); + *name = svalue(&p->k[g]); + return "global"; + } + case OP_MOVE: { + int a = GETARG_A(i); + int b = GETARG_B(i); /* move from `b' to `a' */ + if (b < a) + return getobjname(L, ci, b, name); /* get name for `b' */ + break; + } + case OP_GETTABLE: { + int k = GETARG_C(i); /* key index */ + *name = kname(p, k); + return "field"; + } + case OP_GETUPVAL: { + int u = GETARG_B(i); /* upvalue index */ + *name = p->upvalues ? getstr(p->upvalues[u]) : "?"; + return "upvalue"; + } + case OP_SELF: { + int k = GETARG_C(i); /* key index */ + *name = kname(p, k); + return "method"; + } + default: break; + } + } + return NULL; /* no useful name found */ +} + + +static const char *getfuncname (lua_State *L, CallInfo *ci, const char **name) { + Instruction i; + if ((isLua(ci) && ci->tailcalls > 0) || !isLua(ci - 1)) + return NULL; /* calling function is not Lua (or is unknown) */ + ci--; /* calling function */ + i = ci_func(ci)->l.p->code[currentpc(L, ci)]; + if (GET_OPCODE(i) == OP_CALL || GET_OPCODE(i) == OP_TAILCALL || + GET_OPCODE(i) == OP_TFORLOOP) + return getobjname(L, ci, GETARG_A(i), name); + else + return NULL; /* no useful name can be found */ +} + + +/* only ANSI way to check whether a pointer points to an array */ +static int isinstack (CallInfo *ci, const TValue *o) { + StkId p; + for (p = ci->base; p < ci->top; p++) + if (o == p) return 1; + return 0; +} + + +void luaG_typeerror (lua_State *L, const TValue *o, const char *op) { + const char *name = NULL; + const char *t = luaT_typenames[ttype(o)]; + const char *kind = (isinstack(L->ci, o)) ? + getobjname(L, L->ci, cast_int(o - L->base), &name) : + NULL; + if (kind) + luaG_runerror(L, "attempt to %s %s " LUA_QS " (a %s value)", + op, kind, name, t); + else + luaG_runerror(L, "attempt to %s a %s value", op, t); +} + + +void luaG_concaterror (lua_State *L, StkId p1, StkId p2) { + if (ttisstring(p1) || ttisnumber(p1)) p1 = p2; + lua_assert(!ttisstring(p1) && !ttisnumber(p1)); + luaG_typeerror(L, p1, "concatenate"); +} + + +void luaG_aritherror (lua_State *L, const TValue *p1, const TValue *p2) { + TValue temp; + if (luaV_tonumber(p1, &temp) == NULL) + p2 = p1; /* first operand is wrong */ + luaG_typeerror(L, p2, "perform arithmetic on"); +} + + +int luaG_ordererror (lua_State *L, const TValue *p1, const TValue *p2) { + const char *t1 = luaT_typenames[ttype(p1)]; + const char *t2 = luaT_typenames[ttype(p2)]; + if (t1[2] == t2[2]) + luaG_runerror(L, "attempt to compare two %s values", t1); + else + luaG_runerror(L, "attempt to compare %s with %s", t1, t2); + return 0; +} + + +static void addinfo (lua_State *L, const char *msg) { + CallInfo *ci = L->ci; + if (isLua(ci)) { /* is Lua code? */ + char buff[LUA_IDSIZE]; /* add file:line information */ + int line = currentline(L, ci); + luaO_chunkid(buff, getstr(getluaproto(ci)->source), LUA_IDSIZE); + luaO_pushfstring(L, "%s:%d: %s", buff, line, msg); + } +} + + +void luaG_errormsg (lua_State *L) { + if (L->errfunc != 0) { /* is there an error handling function? */ + StkId errfunc = restorestack(L, L->errfunc); + if (!ttisfunction(errfunc)) luaD_throw(L, LUA_ERRERR); + setobjs2s(L, L->top, L->top - 1); /* move argument */ + setobjs2s(L, L->top - 1, errfunc); /* push function */ + incr_top(L); + luaD_call(L, L->top - 2, 1); /* call it */ + } + luaD_throw(L, LUA_ERRRUN); +} + + +void luaG_runerror (lua_State *L, const char *fmt, ...) { + va_list argp; + va_start(argp, fmt); + addinfo(L, luaO_pushvfstring(L, fmt, argp)); + va_end(argp); + luaG_errormsg(L); +} + diff --git a/include/lua/ldebug.h b/include/lua/ldebug.h new file mode 100644 index 0000000..ba28a97 --- /dev/null +++ b/include/lua/ldebug.h @@ -0,0 +1,33 @@ +/* +** $Id: ldebug.h,v 2.3.1.1 2007/12/27 13:02:25 roberto Exp $ +** Auxiliary functions from Debug Interface module +** See Copyright Notice in lua.h +*/ + +#ifndef ldebug_h +#define ldebug_h + + +#include "lstate.h" + + +#define pcRel(pc, p) (cast(int, (pc) - (p)->code) - 1) + +#define getline(f,pc) (((f)->lineinfo) ? (f)->lineinfo[pc] : 0) + +#define resethookcount(L) (L->hookcount = L->basehookcount) + + +LUAI_FUNC void luaG_typeerror (lua_State *L, const TValue *o, + const char *opname); +LUAI_FUNC void luaG_concaterror (lua_State *L, StkId p1, StkId p2); +LUAI_FUNC void luaG_aritherror (lua_State *L, const TValue *p1, + const TValue *p2); +LUAI_FUNC int luaG_ordererror (lua_State *L, const TValue *p1, + const TValue *p2); +LUAI_FUNC void luaG_runerror (lua_State *L, const char *fmt, ...); +LUAI_FUNC void luaG_errormsg (lua_State *L); +LUAI_FUNC int luaG_checkcode (const Proto *pt); +LUAI_FUNC int luaG_checkopenop (Instruction i); + +#endif diff --git a/include/lua/ldo.c b/include/lua/ldo.c new file mode 100644 index 0000000..8de05f7 --- /dev/null +++ b/include/lua/ldo.c @@ -0,0 +1,518 @@ +/* +** $Id: ldo.c,v 2.38.1.3 2008/01/18 22:31:22 roberto Exp $ +** Stack and Call structure of Lua +** See Copyright Notice in lua.h +*/ + + +#include +#include +#include + +#define ldo_c +#define LUA_CORE + +#include "lua.h" + +#include "ldebug.h" +#include "ldo.h" +#include "lfunc.h" +#include "lgc.h" +#include "lmem.h" +#include "lobject.h" +#include "lopcodes.h" +#include "lparser.h" +#include "lstate.h" +#include "lstring.h" +#include "ltable.h" +#include "ltm.h" +#include "lundump.h" +#include "lvm.h" +#include "lzio.h" + + + + +/* +** {====================================================== +** Error-recovery functions +** ======================================================= +*/ + + +/* chain list of long jump buffers */ +struct lua_longjmp { + struct lua_longjmp *previous; + luai_jmpbuf b; + volatile int status; /* error code */ +}; + + +void luaD_seterrorobj (lua_State *L, int errcode, StkId oldtop) { + switch (errcode) { + case LUA_ERRMEM: { + setsvalue2s(L, oldtop, luaS_newliteral(L, MEMERRMSG)); + break; + } + case LUA_ERRERR: { + setsvalue2s(L, oldtop, luaS_newliteral(L, "error in error handling")); + break; + } + case LUA_ERRSYNTAX: + case LUA_ERRRUN: { + setobjs2s(L, oldtop, L->top - 1); /* error message on current top */ + break; + } + } + L->top = oldtop + 1; +} + + +static void restore_stack_limit (lua_State *L) { + lua_assert(L->stack_last - L->stack == L->stacksize - EXTRA_STACK - 1); + if (L->size_ci > LUAI_MAXCALLS) { /* there was an overflow? */ + int inuse = cast_int(L->ci - L->base_ci); + if (inuse + 1 < LUAI_MAXCALLS) /* can `undo' overflow? */ + luaD_reallocCI(L, LUAI_MAXCALLS); + } +} + + +static void resetstack (lua_State *L, int status) { + L->ci = L->base_ci; + L->base = L->ci->base; + luaF_close(L, L->base); /* close eventual pending closures */ + luaD_seterrorobj(L, status, L->base); + L->nCcalls = L->baseCcalls; + L->allowhook = 1; + restore_stack_limit(L); + L->errfunc = 0; + L->errorJmp = NULL; +} + + +void luaD_throw (lua_State *L, int errcode) { + if (L->errorJmp) { + L->errorJmp->status = errcode; + LUAI_THROW(L, L->errorJmp); + } + else { + L->status = cast_byte(errcode); + if (G(L)->panic) { + resetstack(L, errcode); + lua_unlock(L); + G(L)->panic(L); + } + exit(EXIT_FAILURE); + } +} + + +int luaD_rawrunprotected (lua_State *L, Pfunc f, void *ud) { + struct lua_longjmp lj; + lj.status = 0; + lj.previous = L->errorJmp; /* chain new error handler */ + L->errorJmp = &lj; + LUAI_TRY(L, &lj, + (*f)(L, ud); + ); + L->errorJmp = lj.previous; /* restore old error handler */ + return lj.status; +} + +/* }====================================================== */ + + +static void correctstack (lua_State *L, TValue *oldstack) { + CallInfo *ci; + GCObject *up; + L->top = (L->top - oldstack) + L->stack; + for (up = L->openupval; up != NULL; up = up->gch.next) + gco2uv(up)->v = (gco2uv(up)->v - oldstack) + L->stack; + for (ci = L->base_ci; ci <= L->ci; ci++) { + ci->top = (ci->top - oldstack) + L->stack; + ci->base = (ci->base - oldstack) + L->stack; + ci->func = (ci->func - oldstack) + L->stack; + } + L->base = (L->base - oldstack) + L->stack; +} + + +void luaD_reallocstack (lua_State *L, int newsize) { + TValue *oldstack = L->stack; + int realsize = newsize + 1 + EXTRA_STACK; + lua_assert(L->stack_last - L->stack == L->stacksize - EXTRA_STACK - 1); + luaM_reallocvector(L, L->stack, L->stacksize, realsize, TValue); + L->stacksize = realsize; + L->stack_last = L->stack+newsize; + correctstack(L, oldstack); +} + + +void luaD_reallocCI (lua_State *L, int newsize) { + CallInfo *oldci = L->base_ci; + luaM_reallocvector(L, L->base_ci, L->size_ci, newsize, CallInfo); + L->size_ci = newsize; + L->ci = (L->ci - oldci) + L->base_ci; + L->end_ci = L->base_ci + L->size_ci - 1; +} + + +void luaD_growstack (lua_State *L, int n) { + if (n <= L->stacksize) /* double size is enough? */ + luaD_reallocstack(L, 2*L->stacksize); + else + luaD_reallocstack(L, L->stacksize + n); +} + + +static CallInfo *growCI (lua_State *L) { + if (L->size_ci > LUAI_MAXCALLS) /* overflow while handling overflow? */ + luaD_throw(L, LUA_ERRERR); + else { + luaD_reallocCI(L, 2*L->size_ci); + if (L->size_ci > LUAI_MAXCALLS) + luaG_runerror(L, "stack overflow"); + } + return ++L->ci; +} + + +void luaD_callhook (lua_State *L, int event, int line) { + lua_Hook hook = L->hook; + if (hook && L->allowhook) { + ptrdiff_t top = savestack(L, L->top); + ptrdiff_t ci_top = savestack(L, L->ci->top); + lua_Debug ar; + ar.event = event; + ar.currentline = line; + if (event == LUA_HOOKTAILRET) + ar.i_ci = 0; /* tail call; no debug information about it */ + else + ar.i_ci = cast_int(L->ci - L->base_ci); + luaD_checkstack(L, LUA_MINSTACK); /* ensure minimum stack size */ + L->ci->top = L->top + LUA_MINSTACK; + lua_assert(L->ci->top <= L->stack_last); + L->allowhook = 0; /* cannot call hooks inside a hook */ + lua_unlock(L); + (*hook)(L, &ar); + lua_lock(L); + lua_assert(!L->allowhook); + L->allowhook = 1; + L->ci->top = restorestack(L, ci_top); + L->top = restorestack(L, top); + } +} + + +static StkId adjust_varargs (lua_State *L, Proto *p, int actual) { + int i; + int nfixargs = p->numparams; + Table *htab = NULL; + StkId base, fixed; + for (; actual < nfixargs; ++actual) + setnilvalue(L->top++); +#if defined(LUA_COMPAT_VARARG) + if (p->is_vararg & VARARG_NEEDSARG) { /* compat. with old-style vararg? */ + int nvar = actual - nfixargs; /* number of extra arguments */ + lua_assert(p->is_vararg & VARARG_HASARG); + luaC_checkGC(L); + htab = luaH_new(L, nvar, 1); /* create `arg' table */ + for (i=0; itop - nvar + i); + /* store counter in field `n' */ + setnvalue(luaH_setstr(L, htab, luaS_newliteral(L, "n")), cast_num(nvar)); + } +#endif + /* move fixed parameters to final position */ + fixed = L->top - actual; /* first fixed argument */ + base = L->top; /* final position of first argument */ + for (i=0; itop++, fixed+i); + setnilvalue(fixed+i); + } + /* add `arg' parameter */ + if (htab) { + sethvalue(L, L->top++, htab); + lua_assert(iswhite(obj2gco(htab))); + } + return base; +} + + +static StkId tryfuncTM (lua_State *L, StkId func) { + const TValue *tm = luaT_gettmbyobj(L, func, TM_CALL); + StkId p; + ptrdiff_t funcr = savestack(L, func); + if (!ttisfunction(tm)) + luaG_typeerror(L, func, "call"); + /* Open a hole inside the stack at `func' */ + for (p = L->top; p > func; p--) setobjs2s(L, p, p-1); + incr_top(L); + func = restorestack(L, funcr); /* previous call may change stack */ + setobj2s(L, func, tm); /* tag method is the new function to be called */ + return func; +} + + + +#define inc_ci(L) \ + ((L->ci == L->end_ci) ? growCI(L) : \ + (condhardstacktests(luaD_reallocCI(L, L->size_ci)), ++L->ci)) + + +int luaD_precall (lua_State *L, StkId func, int nresults) { + LClosure *cl; + ptrdiff_t funcr; + if (!ttisfunction(func)) /* `func' is not a function? */ + func = tryfuncTM(L, func); /* check the `function' tag method */ + funcr = savestack(L, func); + cl = &clvalue(func)->l; + L->ci->savedpc = L->savedpc; + if (!cl->isC) { /* Lua function? prepare its call */ + CallInfo *ci; + StkId st, base; + Proto *p = cl->p; + luaD_checkstack(L, p->maxstacksize); + func = restorestack(L, funcr); + if (!p->is_vararg) { /* no varargs? */ + base = func + 1; + if (L->top > base + p->numparams) + L->top = base + p->numparams; + } + else { /* vararg function */ + int nargs = cast_int(L->top - func) - 1; + base = adjust_varargs(L, p, nargs); + func = restorestack(L, funcr); /* previous call may change the stack */ + } + ci = inc_ci(L); /* now `enter' new function */ + ci->func = func; + L->base = ci->base = base; + ci->top = L->base + p->maxstacksize; + lua_assert(ci->top <= L->stack_last); + L->savedpc = p->code; /* starting point */ + ci->tailcalls = 0; + ci->nresults = nresults; + for (st = L->top; st < ci->top; st++) + setnilvalue(st); + L->top = ci->top; + if (L->hookmask & LUA_MASKCALL) { + L->savedpc++; /* hooks assume 'pc' is already incremented */ + luaD_callhook(L, LUA_HOOKCALL, -1); + L->savedpc--; /* correct 'pc' */ + } + return PCRLUA; + } + else { /* if is a C function, call it */ + CallInfo *ci; + int n; + luaD_checkstack(L, LUA_MINSTACK); /* ensure minimum stack size */ + ci = inc_ci(L); /* now `enter' new function */ + ci->func = restorestack(L, funcr); + L->base = ci->base = ci->func + 1; + ci->top = L->top + LUA_MINSTACK; + lua_assert(ci->top <= L->stack_last); + ci->nresults = nresults; + if (L->hookmask & LUA_MASKCALL) + luaD_callhook(L, LUA_HOOKCALL, -1); + lua_unlock(L); + n = (*curr_func(L)->c.f)(L); /* do the actual call */ + lua_lock(L); + if (n < 0) /* yielding? */ + return PCRYIELD; + else { + luaD_poscall(L, L->top - n); + return PCRC; + } + } +} + + +static StkId callrethooks (lua_State *L, StkId firstResult) { + ptrdiff_t fr = savestack(L, firstResult); /* next call may change stack */ + luaD_callhook(L, LUA_HOOKRET, -1); + if (f_isLua(L->ci)) { /* Lua function? */ + while ((L->hookmask & LUA_MASKRET) && L->ci->tailcalls--) /* tail calls */ + luaD_callhook(L, LUA_HOOKTAILRET, -1); + } + return restorestack(L, fr); +} + + +int luaD_poscall (lua_State *L, StkId firstResult) { + StkId res; + int wanted, i; + CallInfo *ci; + if (L->hookmask & LUA_MASKRET) + firstResult = callrethooks(L, firstResult); + ci = L->ci--; + res = ci->func; /* res == final position of 1st result */ + wanted = ci->nresults; + L->base = (ci - 1)->base; /* restore base */ + L->savedpc = (ci - 1)->savedpc; /* restore savedpc */ + /* move results to correct place */ + for (i = wanted; i != 0 && firstResult < L->top; i--) + setobjs2s(L, res++, firstResult++); + while (i-- > 0) + setnilvalue(res++); + L->top = res; + return (wanted - LUA_MULTRET); /* 0 iff wanted == LUA_MULTRET */ +} + + +/* +** Call a function (C or Lua). The function to be called is at *func. +** The arguments are on the stack, right after the function. +** When returns, all the results are on the stack, starting at the original +** function position. +*/ +void luaD_call (lua_State *L, StkId func, int nResults) { + if (++L->nCcalls >= LUAI_MAXCCALLS) { + if (L->nCcalls == LUAI_MAXCCALLS) + luaG_runerror(L, "C stack overflow"); + else if (L->nCcalls >= (LUAI_MAXCCALLS + (LUAI_MAXCCALLS>>3))) + luaD_throw(L, LUA_ERRERR); /* error while handing stack error */ + } + if (luaD_precall(L, func, nResults) == PCRLUA) /* is a Lua function? */ + luaV_execute(L, 1); /* call it */ + L->nCcalls--; + luaC_checkGC(L); +} + + +static void resume (lua_State *L, void *ud) { + StkId firstArg = cast(StkId, ud); + CallInfo *ci = L->ci; + if (L->status == 0) { /* start coroutine? */ + lua_assert(ci == L->base_ci && firstArg > L->base); + if (luaD_precall(L, firstArg - 1, LUA_MULTRET) != PCRLUA) + return; + } + else { /* resuming from previous yield */ + lua_assert(L->status == LUA_YIELD); + L->status = 0; + if (!f_isLua(ci)) { /* `common' yield? */ + /* finish interrupted execution of `OP_CALL' */ + lua_assert(GET_OPCODE(*((ci-1)->savedpc - 1)) == OP_CALL || + GET_OPCODE(*((ci-1)->savedpc - 1)) == OP_TAILCALL); + if (luaD_poscall(L, firstArg)) /* complete it... */ + L->top = L->ci->top; /* and correct top if not multiple results */ + } + else /* yielded inside a hook: just continue its execution */ + L->base = L->ci->base; + } + luaV_execute(L, cast_int(L->ci - L->base_ci)); +} + + +static int resume_error (lua_State *L, const char *msg) { + L->top = L->ci->base; + setsvalue2s(L, L->top, luaS_new(L, msg)); + incr_top(L); + lua_unlock(L); + return LUA_ERRRUN; +} + + +LUA_API int lua_resume (lua_State *L, int nargs) { + int status; + lua_lock(L); + if (L->status != LUA_YIELD && (L->status != 0 || L->ci != L->base_ci)) + return resume_error(L, "cannot resume non-suspended coroutine"); + if (L->nCcalls >= LUAI_MAXCCALLS) + return resume_error(L, "C stack overflow"); + luai_userstateresume(L, nargs); + lua_assert(L->errfunc == 0); + L->baseCcalls = ++L->nCcalls; + status = luaD_rawrunprotected(L, resume, L->top - nargs); + if (status != 0) { /* error? */ + L->status = cast_byte(status); /* mark thread as `dead' */ + luaD_seterrorobj(L, status, L->top); + L->ci->top = L->top; + } + else { + lua_assert(L->nCcalls == L->baseCcalls); + status = L->status; + } + --L->nCcalls; + lua_unlock(L); + return status; +} + + +LUA_API int lua_yield (lua_State *L, int nresults) { + luai_userstateyield(L, nresults); + lua_lock(L); + if (L->nCcalls > L->baseCcalls) + luaG_runerror(L, "attempt to yield across metamethod/C-call boundary"); + L->base = L->top - nresults; /* protect stack slots below */ + L->status = LUA_YIELD; + lua_unlock(L); + return -1; +} + + +int luaD_pcall (lua_State *L, Pfunc func, void *u, + ptrdiff_t old_top, ptrdiff_t ef) { + int status; + unsigned short oldnCcalls = L->nCcalls; + ptrdiff_t old_ci = saveci(L, L->ci); + lu_byte old_allowhooks = L->allowhook; + ptrdiff_t old_errfunc = L->errfunc; + L->errfunc = ef; + status = luaD_rawrunprotected(L, func, u); + if (status != 0) { /* an error occurred? */ + StkId oldtop = restorestack(L, old_top); + luaF_close(L, oldtop); /* close eventual pending closures */ + luaD_seterrorobj(L, status, oldtop); + L->nCcalls = oldnCcalls; + L->ci = restoreci(L, old_ci); + L->base = L->ci->base; + L->savedpc = L->ci->savedpc; + L->allowhook = old_allowhooks; + restore_stack_limit(L); + } + L->errfunc = old_errfunc; + return status; +} + + + +/* +** Execute a protected parser. +*/ +struct SParser { /* data to `f_parser' */ + ZIO *z; + Mbuffer buff; /* buffer to be used by the scanner */ + const char *name; +}; + +static void f_parser (lua_State *L, void *ud) { + int i; + Proto *tf; + Closure *cl; + struct SParser *p = cast(struct SParser *, ud); + int c = luaZ_lookahead(p->z); + luaC_checkGC(L); + tf = ((c == LUA_SIGNATURE[0]) ? luaU_undump : luaY_parser)(L, p->z, + &p->buff, p->name); + cl = luaF_newLclosure(L, tf->nups, hvalue(gt(L))); + cl->l.p = tf; + for (i = 0; i < tf->nups; i++) /* initialize eventual upvalues */ + cl->l.upvals[i] = luaF_newupval(L); + setclvalue(L, L->top, cl); + incr_top(L); +} + + +int luaD_protectedparser (lua_State *L, ZIO *z, const char *name) { + struct SParser p; + int status; + p.z = z; p.name = name; + luaZ_initbuffer(L, &p.buff); + status = luaD_pcall(L, f_parser, &p, savestack(L, L->top), L->errfunc); + luaZ_freebuffer(L, &p.buff); + return status; +} + + diff --git a/include/lua/ldo.h b/include/lua/ldo.h new file mode 100644 index 0000000..98fddac --- /dev/null +++ b/include/lua/ldo.h @@ -0,0 +1,57 @@ +/* +** $Id: ldo.h,v 2.7.1.1 2007/12/27 13:02:25 roberto Exp $ +** Stack and Call structure of Lua +** See Copyright Notice in lua.h +*/ + +#ifndef ldo_h +#define ldo_h + + +#include "lobject.h" +#include "lstate.h" +#include "lzio.h" + + +#define luaD_checkstack(L,n) \ + if ((char *)L->stack_last - (char *)L->top <= (n)*(int)sizeof(TValue)) \ + luaD_growstack(L, n); \ + else condhardstacktests(luaD_reallocstack(L, L->stacksize - EXTRA_STACK - 1)); + + +#define incr_top(L) {luaD_checkstack(L,1); L->top++;} + +#define savestack(L,p) ((char *)(p) - (char *)L->stack) +#define restorestack(L,n) ((TValue *)((char *)L->stack + (n))) + +#define saveci(L,p) ((char *)(p) - (char *)L->base_ci) +#define restoreci(L,n) ((CallInfo *)((char *)L->base_ci + (n))) + + +/* results from luaD_precall */ +#define PCRLUA 0 /* initiated a call to a Lua function */ +#define PCRC 1 /* did a call to a C function */ +#define PCRYIELD 2 /* C funtion yielded */ + + +/* type of protected functions, to be ran by `runprotected' */ +typedef void (*Pfunc) (lua_State *L, void *ud); + +LUAI_FUNC int luaD_protectedparser (lua_State *L, ZIO *z, const char *name); +LUAI_FUNC void luaD_callhook (lua_State *L, int event, int line); +LUAI_FUNC int luaD_precall (lua_State *L, StkId func, int nresults); +LUAI_FUNC void luaD_call (lua_State *L, StkId func, int nResults); +LUAI_FUNC int luaD_pcall (lua_State *L, Pfunc func, void *u, + ptrdiff_t oldtop, ptrdiff_t ef); +LUAI_FUNC int luaD_poscall (lua_State *L, StkId firstResult); +LUAI_FUNC void luaD_reallocCI (lua_State *L, int newsize); +LUAI_FUNC void luaD_reallocstack (lua_State *L, int newsize); +LUAI_FUNC void luaD_growstack (lua_State *L, int n); + +LUAI_FUNC void luaD_throw (lua_State *L, int errcode); +LUAI_FUNC int luaD_rawrunprotected (lua_State *L, Pfunc f, void *ud); + +LUAI_FUNC void luaD_seterrorobj (lua_State *L, int errcode, StkId oldtop); + +#endif + diff --git a/include/lua/ldump.c b/include/lua/ldump.c new file mode 100644 index 0000000..c9d3d48 --- /dev/null +++ b/include/lua/ldump.c @@ -0,0 +1,164 @@ +/* +** $Id: ldump.c,v 2.8.1.1 2007/12/27 13:02:25 roberto Exp $ +** save precompiled Lua chunks +** See Copyright Notice in lua.h +*/ + +#include + +#define ldump_c +#define LUA_CORE + +#include "lua.h" + +#include "lobject.h" +#include "lstate.h" +#include "lundump.h" + +typedef struct { + lua_State* L; + lua_Writer writer; + void* data; + int strip; + int status; +} DumpState; + +#define DumpMem(b,n,size,D) DumpBlock(b,(n)*(size),D) +#define DumpVar(x,D) DumpMem(&x,1,sizeof(x),D) + +static void DumpBlock(const void* b, size_t size, DumpState* D) +{ + if (D->status==0) + { + lua_unlock(D->L); + D->status=(*D->writer)(D->L,b,size,D->data); + lua_lock(D->L); + } +} + +static void DumpChar(int y, DumpState* D) +{ + char x=(char)y; + DumpVar(x,D); +} + +static void DumpInt(int x, DumpState* D) +{ + DumpVar(x,D); +} + +static void DumpNumber(lua_Number x, DumpState* D) +{ + DumpVar(x,D); +} + +static void DumpVector(const void* b, int n, size_t size, DumpState* D) +{ + DumpInt(n,D); + DumpMem(b,n,size,D); +} + +static void DumpString(const TString* s, DumpState* D) +{ + if (s==NULL || getstr(s)==NULL) + { + size_t size=0; + DumpVar(size,D); + } + else + { + size_t size=s->tsv.len+1; /* include trailing '\0' */ + DumpVar(size,D); + DumpBlock(getstr(s),size,D); + } +} + +#define DumpCode(f,D) DumpVector(f->code,f->sizecode,sizeof(Instruction),D) + +static void DumpFunction(const Proto* f, const TString* p, DumpState* D); + +static void DumpConstants(const Proto* f, DumpState* D) +{ + int i,n=f->sizek; + DumpInt(n,D); + for (i=0; ik[i]; + DumpChar(ttype(o),D); + switch (ttype(o)) + { + case LUA_TNIL: + break; + case LUA_TBOOLEAN: + DumpChar(bvalue(o),D); + break; + case LUA_TNUMBER: + DumpNumber(nvalue(o),D); + break; + case LUA_TSTRING: + DumpString(rawtsvalue(o),D); + break; + default: + lua_assert(0); /* cannot happen */ + break; + } + } + n=f->sizep; + DumpInt(n,D); + for (i=0; ip[i],f->source,D); +} + +static void DumpDebug(const Proto* f, DumpState* D) +{ + int i,n; + n= (D->strip) ? 0 : f->sizelineinfo; + DumpVector(f->lineinfo,n,sizeof(int),D); + n= (D->strip) ? 0 : f->sizelocvars; + DumpInt(n,D); + for (i=0; ilocvars[i].varname,D); + DumpInt(f->locvars[i].startpc,D); + DumpInt(f->locvars[i].endpc,D); + } + n= (D->strip) ? 0 : f->sizeupvalues; + DumpInt(n,D); + for (i=0; iupvalues[i],D); +} + +static void DumpFunction(const Proto* f, const TString* p, DumpState* D) +{ + DumpString((f->source==p || D->strip) ? NULL : f->source,D); + DumpInt(f->linedefined,D); + DumpInt(f->lastlinedefined,D); + DumpChar(f->nups,D); + DumpChar(f->numparams,D); + DumpChar(f->is_vararg,D); + DumpChar(f->maxstacksize,D); + DumpCode(f,D); + DumpConstants(f,D); + DumpDebug(f,D); +} + +static void DumpHeader(DumpState* D) +{ + char h[LUAC_HEADERSIZE]; + luaU_header(h); + DumpBlock(h,LUAC_HEADERSIZE,D); +} + +/* +** dump Lua function as precompiled chunk +*/ +int luaU_dump (lua_State* L, const Proto* f, lua_Writer w, void* data, int strip) +{ + DumpState D; + D.L=L; + D.writer=w; + D.data=data; + D.strip=strip; + D.status=0; + DumpHeader(&D); + DumpFunction(f,NULL,&D); + return D.status; +} diff --git a/include/lua/lfunc.c b/include/lua/lfunc.c new file mode 100644 index 0000000..813e88f --- /dev/null +++ b/include/lua/lfunc.c @@ -0,0 +1,174 @@ +/* +** $Id: lfunc.c,v 2.12.1.2 2007/12/28 14:58:43 roberto Exp $ +** Auxiliary functions to manipulate prototypes and closures +** See Copyright Notice in lua.h +*/ + + +#include + +#define lfunc_c +#define LUA_CORE + +#include "lua.h" + +#include "lfunc.h" +#include "lgc.h" +#include "lmem.h" +#include "lobject.h" +#include "lstate.h" + + + +Closure *luaF_newCclosure (lua_State *L, int nelems, Table *e) { + Closure *c = cast(Closure *, luaM_malloc(L, sizeCclosure(nelems))); + luaC_link(L, obj2gco(c), LUA_TFUNCTION); + c->c.isC = 1; + c->c.env = e; + c->c.nupvalues = cast_byte(nelems); + return c; +} + + +Closure *luaF_newLclosure (lua_State *L, int nelems, Table *e) { + Closure *c = cast(Closure *, luaM_malloc(L, sizeLclosure(nelems))); + luaC_link(L, obj2gco(c), LUA_TFUNCTION); + c->l.isC = 0; + c->l.env = e; + c->l.nupvalues = cast_byte(nelems); + while (nelems--) c->l.upvals[nelems] = NULL; + return c; +} + + +UpVal *luaF_newupval (lua_State *L) { + UpVal *uv = luaM_new(L, UpVal); + luaC_link(L, obj2gco(uv), LUA_TUPVAL); + uv->v = &uv->u.value; + setnilvalue(uv->v); + return uv; +} + + +UpVal *luaF_findupval (lua_State *L, StkId level) { + global_State *g = G(L); + GCObject **pp = &L->openupval; + UpVal *p; + UpVal *uv; + while (*pp != NULL && (p = ngcotouv(*pp))->v >= level) { + lua_assert(p->v != &p->u.value); + if (p->v == level) { /* found a corresponding upvalue? */ + if (isdead(g, obj2gco(p))) /* is it dead? */ + changewhite(obj2gco(p)); /* ressurect it */ + return p; + } + pp = &p->next; + } + uv = luaM_new(L, UpVal); /* not found: create a new one */ + uv->tt = LUA_TUPVAL; + uv->marked = luaC_white(g); + uv->v = level; /* current value lives in the stack */ + uv->next = *pp; /* chain it in the proper position */ + *pp = obj2gco(uv); + uv->u.l.prev = &g->uvhead; /* double link it in `uvhead' list */ + uv->u.l.next = g->uvhead.u.l.next; + uv->u.l.next->u.l.prev = uv; + g->uvhead.u.l.next = uv; + lua_assert(uv->u.l.next->u.l.prev == uv && uv->u.l.prev->u.l.next == uv); + return uv; +} + + +static void unlinkupval (UpVal *uv) { + lua_assert(uv->u.l.next->u.l.prev == uv && uv->u.l.prev->u.l.next == uv); + uv->u.l.next->u.l.prev = uv->u.l.prev; /* remove from `uvhead' list */ + uv->u.l.prev->u.l.next = uv->u.l.next; +} + + +void luaF_freeupval (lua_State *L, UpVal *uv) { + if (uv->v != &uv->u.value) /* is it open? */ + unlinkupval(uv); /* remove from open list */ + luaM_free(L, uv); /* free upvalue */ +} + + +void luaF_close (lua_State *L, StkId level) { + UpVal *uv; + global_State *g = G(L); + while (L->openupval != NULL && (uv = ngcotouv(L->openupval))->v >= level) { + GCObject *o = obj2gco(uv); + lua_assert(!isblack(o) && uv->v != &uv->u.value); + L->openupval = uv->next; /* remove from `open' list */ + if (isdead(g, o)) + luaF_freeupval(L, uv); /* free upvalue */ + else { + unlinkupval(uv); + setobj(L, &uv->u.value, uv->v); + uv->v = &uv->u.value; /* now current value lives here */ + luaC_linkupval(L, uv); /* link upvalue into `gcroot' list */ + } + } +} + + +Proto *luaF_newproto (lua_State *L) { + Proto *f = luaM_new(L, Proto); + luaC_link(L, obj2gco(f), LUA_TPROTO); + f->k = NULL; + f->sizek = 0; + f->p = NULL; + f->sizep = 0; + f->code = NULL; + f->sizecode = 0; + f->sizelineinfo = 0; + f->sizeupvalues = 0; + f->nups = 0; + f->upvalues = NULL; + f->numparams = 0; + f->is_vararg = 0; + f->maxstacksize = 0; + f->lineinfo = NULL; + f->sizelocvars = 0; + f->locvars = NULL; + f->linedefined = 0; + f->lastlinedefined = 0; + f->source = NULL; + return f; +} + + +void luaF_freeproto (lua_State *L, Proto *f) { + luaM_freearray(L, f->code, f->sizecode, Instruction); + luaM_freearray(L, f->p, f->sizep, Proto *); + luaM_freearray(L, f->k, f->sizek, TValue); + luaM_freearray(L, f->lineinfo, f->sizelineinfo, int); + luaM_freearray(L, f->locvars, f->sizelocvars, struct LocVar); + luaM_freearray(L, f->upvalues, f->sizeupvalues, TString *); + luaM_free(L, f); +} + + +void luaF_freeclosure (lua_State *L, Closure *c) { + int size = (c->c.isC) ? sizeCclosure(c->c.nupvalues) : + sizeLclosure(c->l.nupvalues); + luaM_freemem(L, c, size); +} + + +/* +** Look for n-th local variable at line `line' in function `func'. +** Returns NULL if not found. +*/ +const char *luaF_getlocalname (const Proto *f, int local_number, int pc) { + int i; + for (i = 0; isizelocvars && f->locvars[i].startpc <= pc; i++) { + if (pc < f->locvars[i].endpc) { /* is variable active? */ + local_number--; + if (local_number == 0) + return getstr(f->locvars[i].varname); + } + } + return NULL; /* not found */ +} + diff --git a/include/lua/lfunc.h b/include/lua/lfunc.h new file mode 100644 index 0000000..a68cf51 --- /dev/null +++ b/include/lua/lfunc.h @@ -0,0 +1,34 @@ +/* +** $Id: lfunc.h,v 2.4.1.1 2007/12/27 13:02:25 roberto Exp $ +** Auxiliary functions to manipulate prototypes and closures +** See Copyright Notice in lua.h +*/ + +#ifndef lfunc_h +#define lfunc_h + + +#include "lobject.h" + + +#define sizeCclosure(n) (cast(int, sizeof(CClosure)) + \ + cast(int, sizeof(TValue)*((n)-1))) + +#define sizeLclosure(n) (cast(int, sizeof(LClosure)) + \ + cast(int, sizeof(TValue *)*((n)-1))) + + +LUAI_FUNC Proto *luaF_newproto (lua_State *L); +LUAI_FUNC Closure *luaF_newCclosure (lua_State *L, int nelems, Table *e); +LUAI_FUNC Closure *luaF_newLclosure (lua_State *L, int nelems, Table *e); +LUAI_FUNC UpVal *luaF_newupval (lua_State *L); +LUAI_FUNC UpVal *luaF_findupval (lua_State *L, StkId level); +LUAI_FUNC void luaF_close (lua_State *L, StkId level); +LUAI_FUNC void luaF_freeproto (lua_State *L, Proto *f); +LUAI_FUNC void luaF_freeclosure (lua_State *L, Closure *c); +LUAI_FUNC void luaF_freeupval (lua_State *L, UpVal *uv); +LUAI_FUNC const char *luaF_getlocalname (const Proto *func, int local_number, + int pc); + + +#endif diff --git a/include/lua/lgc.c b/include/lua/lgc.c new file mode 100644 index 0000000..d9e0b78 --- /dev/null +++ b/include/lua/lgc.c @@ -0,0 +1,711 @@ +/* +** $Id: lgc.c,v 2.38.1.1 2007/12/27 13:02:25 roberto Exp $ +** Garbage Collector +** See Copyright Notice in lua.h +*/ + +#include + +#define lgc_c +#define LUA_CORE + +#include "lua.h" + +#include "ldebug.h" +#include "ldo.h" +#include "lfunc.h" +#include "lgc.h" +#include "lmem.h" +#include "lobject.h" +#include "lstate.h" +#include "lstring.h" +#include "ltable.h" +#include "ltm.h" + + +#define GCSTEPSIZE 1024u +#define GCSWEEPMAX 40 +#define GCSWEEPCOST 10 +#define GCFINALIZECOST 100 + + +#define maskmarks cast_byte(~(bitmask(BLACKBIT)|WHITEBITS)) + +#define makewhite(g,x) \ + ((x)->gch.marked = cast_byte(((x)->gch.marked & maskmarks) | luaC_white(g))) + +#define white2gray(x) reset2bits((x)->gch.marked, WHITE0BIT, WHITE1BIT) +#define black2gray(x) resetbit((x)->gch.marked, BLACKBIT) + +#define stringmark(s) reset2bits((s)->tsv.marked, WHITE0BIT, WHITE1BIT) + + +#define isfinalized(u) testbit((u)->marked, FINALIZEDBIT) +#define markfinalized(u) l_setbit((u)->marked, FINALIZEDBIT) + + +#define KEYWEAK bitmask(KEYWEAKBIT) +#define VALUEWEAK bitmask(VALUEWEAKBIT) + + + +#define markvalue(g,o) { checkconsistency(o); \ + if (iscollectable(o) && iswhite(gcvalue(o))) reallymarkobject(g,gcvalue(o)); } + +#define markobject(g,t) { if (iswhite(obj2gco(t))) \ + reallymarkobject(g, obj2gco(t)); } + + +#define setthreshold(g) (g->GCthreshold = (g->estimate/100) * g->gcpause) + + +static void removeentry (Node *n) { + lua_assert(ttisnil(gval(n))); + if (iscollectable(gkey(n))) + setttype(gkey(n), LUA_TDEADKEY); /* dead key; remove it */ +} + + +static void reallymarkobject (global_State *g, GCObject *o) { + lua_assert(iswhite(o) && !isdead(g, o)); + white2gray(o); + switch (o->gch.tt) { + case LUA_TSTRING: { + return; + } + case LUA_TUSERDATA: { + Table *mt = gco2u(o)->metatable; + gray2black(o); /* udata are never gray */ + if (mt) markobject(g, mt); + markobject(g, gco2u(o)->env); + return; + } + case LUA_TUPVAL: { + UpVal *uv = gco2uv(o); + markvalue(g, uv->v); + if (uv->v == &uv->u.value) /* closed? */ + gray2black(o); /* open upvalues are never black */ + return; + } + case LUA_TFUNCTION: { + gco2cl(o)->c.gclist = g->gray; + g->gray = o; + break; + } + case LUA_TTABLE: { + gco2h(o)->gclist = g->gray; + g->gray = o; + break; + } + case LUA_TTHREAD: { + gco2th(o)->gclist = g->gray; + g->gray = o; + break; + } + case LUA_TPROTO: { + gco2p(o)->gclist = g->gray; + g->gray = o; + break; + } + default: lua_assert(0); + } +} + + +static void marktmu (global_State *g) { + GCObject *u = g->tmudata; + if (u) { + do { + u = u->gch.next; + makewhite(g, u); /* may be marked, if left from previous GC */ + reallymarkobject(g, u); + } while (u != g->tmudata); + } +} + + +/* move `dead' udata that need finalization to list `tmudata' */ +size_t luaC_separateudata (lua_State *L, int all) { + global_State *g = G(L); + size_t deadmem = 0; + GCObject **p = &g->mainthread->next; + GCObject *curr; + while ((curr = *p) != NULL) { + if (!(iswhite(curr) || all) || isfinalized(gco2u(curr))) + p = &curr->gch.next; /* don't bother with them */ + else if (fasttm(L, gco2u(curr)->metatable, TM_GC) == NULL) { + markfinalized(gco2u(curr)); /* don't need finalization */ + p = &curr->gch.next; + } + else { /* must call its gc method */ + deadmem += sizeudata(gco2u(curr)); + markfinalized(gco2u(curr)); + *p = curr->gch.next; + /* link `curr' at the end of `tmudata' list */ + if (g->tmudata == NULL) /* list is empty? */ + g->tmudata = curr->gch.next = curr; /* creates a circular list */ + else { + curr->gch.next = g->tmudata->gch.next; + g->tmudata->gch.next = curr; + g->tmudata = curr; + } + } + } + return deadmem; +} + + +static int traversetable (global_State *g, Table *h) { + int i; + int weakkey = 0; + int weakvalue = 0; + const TValue *mode; + if (h->metatable) + markobject(g, h->metatable); + mode = gfasttm(g, h->metatable, TM_MODE); + if (mode && ttisstring(mode)) { /* is there a weak mode? */ + weakkey = (strchr(svalue(mode), 'k') != NULL); + weakvalue = (strchr(svalue(mode), 'v') != NULL); + if (weakkey || weakvalue) { /* is really weak? */ + h->marked &= ~(KEYWEAK | VALUEWEAK); /* clear bits */ + h->marked |= cast_byte((weakkey << KEYWEAKBIT) | + (weakvalue << VALUEWEAKBIT)); + h->gclist = g->weak; /* must be cleared after GC, ... */ + g->weak = obj2gco(h); /* ... so put in the appropriate list */ + } + } + if (weakkey && weakvalue) return 1; + if (!weakvalue) { + i = h->sizearray; + while (i--) + markvalue(g, &h->array[i]); + } + i = sizenode(h); + while (i--) { + Node *n = gnode(h, i); + lua_assert(ttype(gkey(n)) != LUA_TDEADKEY || ttisnil(gval(n))); + if (ttisnil(gval(n))) + removeentry(n); /* remove empty entries */ + else { + lua_assert(!ttisnil(gkey(n))); + if (!weakkey) markvalue(g, gkey(n)); + if (!weakvalue) markvalue(g, gval(n)); + } + } + return weakkey || weakvalue; +} + + +/* +** All marks are conditional because a GC may happen while the +** prototype is still being created +*/ +static void traverseproto (global_State *g, Proto *f) { + int i; + if (f->source) stringmark(f->source); + for (i=0; isizek; i++) /* mark literals */ + markvalue(g, &f->k[i]); + for (i=0; isizeupvalues; i++) { /* mark upvalue names */ + if (f->upvalues[i]) + stringmark(f->upvalues[i]); + } + for (i=0; isizep; i++) { /* mark nested protos */ + if (f->p[i]) + markobject(g, f->p[i]); + } + for (i=0; isizelocvars; i++) { /* mark local-variable names */ + if (f->locvars[i].varname) + stringmark(f->locvars[i].varname); + } +} + + + +static void traverseclosure (global_State *g, Closure *cl) { + markobject(g, cl->c.env); + if (cl->c.isC) { + int i; + for (i=0; ic.nupvalues; i++) /* mark its upvalues */ + markvalue(g, &cl->c.upvalue[i]); + } + else { + int i; + lua_assert(cl->l.nupvalues == cl->l.p->nups); + markobject(g, cl->l.p); + for (i=0; il.nupvalues; i++) /* mark its upvalues */ + markobject(g, cl->l.upvals[i]); + } +} + + +static void checkstacksizes (lua_State *L, StkId max) { + int ci_used = cast_int(L->ci - L->base_ci); /* number of `ci' in use */ + int s_used = cast_int(max - L->stack); /* part of stack in use */ + if (L->size_ci > LUAI_MAXCALLS) /* handling overflow? */ + return; /* do not touch the stacks */ + if (4*ci_used < L->size_ci && 2*BASIC_CI_SIZE < L->size_ci) + luaD_reallocCI(L, L->size_ci/2); /* still big enough... */ + condhardstacktests(luaD_reallocCI(L, ci_used + 1)); + if (4*s_used < L->stacksize && + 2*(BASIC_STACK_SIZE+EXTRA_STACK) < L->stacksize) + luaD_reallocstack(L, L->stacksize/2); /* still big enough... */ + condhardstacktests(luaD_reallocstack(L, s_used)); +} + + +static void traversestack (global_State *g, lua_State *l) { + StkId o, lim; + CallInfo *ci; + markvalue(g, gt(l)); + lim = l->top; + for (ci = l->base_ci; ci <= l->ci; ci++) { + lua_assert(ci->top <= l->stack_last); + if (lim < ci->top) lim = ci->top; + } + for (o = l->stack; o < l->top; o++) + markvalue(g, o); + for (; o <= lim; o++) + setnilvalue(o); + checkstacksizes(l, lim); +} + + +/* +** traverse one gray object, turning it to black. +** Returns `quantity' traversed. +*/ +static l_mem propagatemark (global_State *g) { + GCObject *o = g->gray; + lua_assert(isgray(o)); + gray2black(o); + switch (o->gch.tt) { + case LUA_TTABLE: { + Table *h = gco2h(o); + g->gray = h->gclist; + if (traversetable(g, h)) /* table is weak? */ + black2gray(o); /* keep it gray */ + return sizeof(Table) + sizeof(TValue) * h->sizearray + + sizeof(Node) * sizenode(h); + } + case LUA_TFUNCTION: { + Closure *cl = gco2cl(o); + g->gray = cl->c.gclist; + traverseclosure(g, cl); + return (cl->c.isC) ? sizeCclosure(cl->c.nupvalues) : + sizeLclosure(cl->l.nupvalues); + } + case LUA_TTHREAD: { + lua_State *th = gco2th(o); + g->gray = th->gclist; + th->gclist = g->grayagain; + g->grayagain = o; + black2gray(o); + traversestack(g, th); + return sizeof(lua_State) + sizeof(TValue) * th->stacksize + + sizeof(CallInfo) * th->size_ci; + } + case LUA_TPROTO: { + Proto *p = gco2p(o); + g->gray = p->gclist; + traverseproto(g, p); + return sizeof(Proto) + sizeof(Instruction) * p->sizecode + + sizeof(Proto *) * p->sizep + + sizeof(TValue) * p->sizek + + sizeof(int) * p->sizelineinfo + + sizeof(LocVar) * p->sizelocvars + + sizeof(TString *) * p->sizeupvalues; + } + default: lua_assert(0); return 0; + } +} + + +static size_t propagateall (global_State *g) { + size_t m = 0; + while (g->gray) m += propagatemark(g); + return m; +} + + +/* +** The next function tells whether a key or value can be cleared from +** a weak table. Non-collectable objects are never removed from weak +** tables. Strings behave as `values', so are never removed too. for +** other objects: if really collected, cannot keep them; for userdata +** being finalized, keep them in keys, but not in values +*/ +static int iscleared (const TValue *o, int iskey) { + if (!iscollectable(o)) return 0; + if (ttisstring(o)) { + stringmark(rawtsvalue(o)); /* strings are `values', so are never weak */ + return 0; + } + return iswhite(gcvalue(o)) || + (ttisuserdata(o) && (!iskey && isfinalized(uvalue(o)))); +} + + +/* +** clear collected entries from weaktables +*/ +static void cleartable (GCObject *l) { + while (l) { + Table *h = gco2h(l); + int i = h->sizearray; + lua_assert(testbit(h->marked, VALUEWEAKBIT) || + testbit(h->marked, KEYWEAKBIT)); + if (testbit(h->marked, VALUEWEAKBIT)) { + while (i--) { + TValue *o = &h->array[i]; + if (iscleared(o, 0)) /* value was collected? */ + setnilvalue(o); /* remove value */ + } + } + i = sizenode(h); + while (i--) { + Node *n = gnode(h, i); + if (!ttisnil(gval(n)) && /* non-empty entry? */ + (iscleared(key2tval(n), 1) || iscleared(gval(n), 0))) { + setnilvalue(gval(n)); /* remove value ... */ + removeentry(n); /* remove entry from table */ + } + } + l = h->gclist; + } +} + + +static void freeobj (lua_State *L, GCObject *o) { + switch (o->gch.tt) { + case LUA_TPROTO: luaF_freeproto(L, gco2p(o)); break; + case LUA_TFUNCTION: luaF_freeclosure(L, gco2cl(o)); break; + case LUA_TUPVAL: luaF_freeupval(L, gco2uv(o)); break; + case LUA_TTABLE: luaH_free(L, gco2h(o)); break; + case LUA_TTHREAD: { + lua_assert(gco2th(o) != L && gco2th(o) != G(L)->mainthread); + luaE_freethread(L, gco2th(o)); + break; + } + case LUA_TSTRING: { + G(L)->strt.nuse--; + luaM_freemem(L, o, sizestring(gco2ts(o))); + break; + } + case LUA_TUSERDATA: { + luaM_freemem(L, o, sizeudata(gco2u(o))); + break; + } + default: lua_assert(0); + } +} + + + +#define sweepwholelist(L,p) sweeplist(L,p,MAX_LUMEM) + + +static GCObject **sweeplist (lua_State *L, GCObject **p, lu_mem count) { + GCObject *curr; + global_State *g = G(L); + int deadmask = otherwhite(g); + while ((curr = *p) != NULL && count-- > 0) { + if (curr->gch.tt == LUA_TTHREAD) /* sweep open upvalues of each thread */ + sweepwholelist(L, &gco2th(curr)->openupval); + if ((curr->gch.marked ^ WHITEBITS) & deadmask) { /* not dead? */ + lua_assert(!isdead(g, curr) || testbit(curr->gch.marked, FIXEDBIT)); + makewhite(g, curr); /* make it white (for next cycle) */ + p = &curr->gch.next; + } + else { /* must erase `curr' */ + lua_assert(isdead(g, curr) || deadmask == bitmask(SFIXEDBIT)); + *p = curr->gch.next; + if (curr == g->rootgc) /* is the first element of the list? */ + g->rootgc = curr->gch.next; /* adjust first */ + freeobj(L, curr); + } + } + return p; +} + + +static void checkSizes (lua_State *L) { + global_State *g = G(L); + /* check size of string hash */ + if (g->strt.nuse < cast(lu_int32, g->strt.size/4) && + g->strt.size > MINSTRTABSIZE*2) + luaS_resize(L, g->strt.size/2); /* table is too big */ + /* check size of buffer */ + if (luaZ_sizebuffer(&g->buff) > LUA_MINBUFFER*2) { /* buffer too big? */ + size_t newsize = luaZ_sizebuffer(&g->buff) / 2; + luaZ_resizebuffer(L, &g->buff, newsize); + } +} + + +static void GCTM (lua_State *L) { + global_State *g = G(L); + GCObject *o = g->tmudata->gch.next; /* get first element */ + Udata *udata = rawgco2u(o); + const TValue *tm; + /* remove udata from `tmudata' */ + if (o == g->tmudata) /* last element? */ + g->tmudata = NULL; + else + g->tmudata->gch.next = udata->uv.next; + udata->uv.next = g->mainthread->next; /* return it to `root' list */ + g->mainthread->next = o; + makewhite(g, o); + tm = fasttm(L, udata->uv.metatable, TM_GC); + if (tm != NULL) { + lu_byte oldah = L->allowhook; + lu_mem oldt = g->GCthreshold; + L->allowhook = 0; /* stop debug hooks during GC tag method */ + g->GCthreshold = 2*g->totalbytes; /* avoid GC steps */ + setobj2s(L, L->top, tm); + setuvalue(L, L->top+1, udata); + L->top += 2; + luaD_call(L, L->top - 2, 0); + L->allowhook = oldah; /* restore hooks */ + g->GCthreshold = oldt; /* restore threshold */ + } +} + + +/* +** Call all GC tag methods +*/ +void luaC_callGCTM (lua_State *L) { + while (G(L)->tmudata) + GCTM(L); +} + + +void luaC_freeall (lua_State *L) { + global_State *g = G(L); + int i; + g->currentwhite = WHITEBITS | bitmask(SFIXEDBIT); /* mask to collect all elements */ + sweepwholelist(L, &g->rootgc); + for (i = 0; i < g->strt.size; i++) /* free all string lists */ + sweepwholelist(L, &g->strt.hash[i]); +} + + +static void markmt (global_State *g) { + int i; + for (i=0; imt[i]) markobject(g, g->mt[i]); +} + + +/* mark root set */ +static void markroot (lua_State *L) { + global_State *g = G(L); + g->gray = NULL; + g->grayagain = NULL; + g->weak = NULL; + markobject(g, g->mainthread); + /* make global table be traversed before main stack */ + markvalue(g, gt(g->mainthread)); + markvalue(g, registry(L)); + markmt(g); + g->gcstate = GCSpropagate; +} + + +static void remarkupvals (global_State *g) { + UpVal *uv; + for (uv = g->uvhead.u.l.next; uv != &g->uvhead; uv = uv->u.l.next) { + lua_assert(uv->u.l.next->u.l.prev == uv && uv->u.l.prev->u.l.next == uv); + if (isgray(obj2gco(uv))) + markvalue(g, uv->v); + } +} + + +static void atomic (lua_State *L) { + global_State *g = G(L); + size_t udsize; /* total size of userdata to be finalized */ + /* remark occasional upvalues of (maybe) dead threads */ + remarkupvals(g); + /* traverse objects cautch by write barrier and by 'remarkupvals' */ + propagateall(g); + /* remark weak tables */ + g->gray = g->weak; + g->weak = NULL; + lua_assert(!iswhite(obj2gco(g->mainthread))); + markobject(g, L); /* mark running thread */ + markmt(g); /* mark basic metatables (again) */ + propagateall(g); + /* remark gray again */ + g->gray = g->grayagain; + g->grayagain = NULL; + propagateall(g); + udsize = luaC_separateudata(L, 0); /* separate userdata to be finalized */ + marktmu(g); /* mark `preserved' userdata */ + udsize += propagateall(g); /* remark, to propagate `preserveness' */ + cleartable(g->weak); /* remove collected objects from weak tables */ + /* flip current white */ + g->currentwhite = cast_byte(otherwhite(g)); + g->sweepstrgc = 0; + g->sweepgc = &g->rootgc; + g->gcstate = GCSsweepstring; + g->estimate = g->totalbytes - udsize; /* first estimate */ +} + + +static l_mem singlestep (lua_State *L) { + global_State *g = G(L); + /*lua_checkmemory(L);*/ + switch (g->gcstate) { + case GCSpause: { + markroot(L); /* start a new collection */ + return 0; + } + case GCSpropagate: { + if (g->gray) + return propagatemark(g); + else { /* no more `gray' objects */ + atomic(L); /* finish mark phase */ + return 0; + } + } + case GCSsweepstring: { + lu_mem old = g->totalbytes; + sweepwholelist(L, &g->strt.hash[g->sweepstrgc++]); + if (g->sweepstrgc >= g->strt.size) /* nothing more to sweep? */ + g->gcstate = GCSsweep; /* end sweep-string phase */ + lua_assert(old >= g->totalbytes); + g->estimate -= old - g->totalbytes; + return GCSWEEPCOST; + } + case GCSsweep: { + lu_mem old = g->totalbytes; + g->sweepgc = sweeplist(L, g->sweepgc, GCSWEEPMAX); + if (*g->sweepgc == NULL) { /* nothing more to sweep? */ + checkSizes(L); + g->gcstate = GCSfinalize; /* end sweep phase */ + } + lua_assert(old >= g->totalbytes); + g->estimate -= old - g->totalbytes; + return GCSWEEPMAX*GCSWEEPCOST; + } + case GCSfinalize: { + if (g->tmudata) { + GCTM(L); + if (g->estimate > GCFINALIZECOST) + g->estimate -= GCFINALIZECOST; + return GCFINALIZECOST; + } + else { + g->gcstate = GCSpause; /* end collection */ + g->gcdept = 0; + return 0; + } + } + default: lua_assert(0); return 0; + } +} + + +void luaC_step (lua_State *L) { + global_State *g = G(L); + l_mem lim = (GCSTEPSIZE/100) * g->gcstepmul; + if (lim == 0) + lim = (MAX_LUMEM-1)/2; /* no limit */ + g->gcdept += g->totalbytes - g->GCthreshold; + do { + lim -= singlestep(L); + if (g->gcstate == GCSpause) + break; + } while (lim > 0); + if (g->gcstate != GCSpause) { + if (g->gcdept < GCSTEPSIZE) + g->GCthreshold = g->totalbytes + GCSTEPSIZE; /* - lim/g->gcstepmul;*/ + else { + g->gcdept -= GCSTEPSIZE; + g->GCthreshold = g->totalbytes; + } + } + else { + lua_assert(g->totalbytes >= g->estimate); + setthreshold(g); + } +} + + +void luaC_fullgc (lua_State *L) { + global_State *g = G(L); + if (g->gcstate <= GCSpropagate) { + /* reset sweep marks to sweep all elements (returning them to white) */ + g->sweepstrgc = 0; + g->sweepgc = &g->rootgc; + /* reset other collector lists */ + g->gray = NULL; + g->grayagain = NULL; + g->weak = NULL; + g->gcstate = GCSsweepstring; + } + lua_assert(g->gcstate != GCSpause && g->gcstate != GCSpropagate); + /* finish any pending sweep phase */ + while (g->gcstate != GCSfinalize) { + lua_assert(g->gcstate == GCSsweepstring || g->gcstate == GCSsweep); + singlestep(L); + } + markroot(L); + while (g->gcstate != GCSpause) { + singlestep(L); + } + setthreshold(g); +} + + +void luaC_barrierf (lua_State *L, GCObject *o, GCObject *v) { + global_State *g = G(L); + lua_assert(isblack(o) && iswhite(v) && !isdead(g, v) && !isdead(g, o)); + lua_assert(g->gcstate != GCSfinalize && g->gcstate != GCSpause); + lua_assert(ttype(&o->gch) != LUA_TTABLE); + /* must keep invariant? */ + if (g->gcstate == GCSpropagate) + reallymarkobject(g, v); /* restore invariant */ + else /* don't mind */ + makewhite(g, o); /* mark as white just to avoid other barriers */ +} + + +void luaC_barrierback (lua_State *L, Table *t) { + global_State *g = G(L); + GCObject *o = obj2gco(t); + lua_assert(isblack(o) && !isdead(g, o)); + lua_assert(g->gcstate != GCSfinalize && g->gcstate != GCSpause); + black2gray(o); /* make table gray (again) */ + t->gclist = g->grayagain; + g->grayagain = o; +} + + +void luaC_link (lua_State *L, GCObject *o, lu_byte tt) { + global_State *g = G(L); + o->gch.next = g->rootgc; + g->rootgc = o; + o->gch.marked = luaC_white(g); + o->gch.tt = tt; +} + + +void luaC_linkupval (lua_State *L, UpVal *uv) { + global_State *g = G(L); + GCObject *o = obj2gco(uv); + o->gch.next = g->rootgc; /* link upvalue into `rootgc' list */ + g->rootgc = o; + if (isgray(o)) { + if (g->gcstate == GCSpropagate) { + gray2black(o); /* closed upvalues need barrier */ + luaC_barrier(L, uv, uv->v); + } + else { /* sweep phase: sweep it (turning it into white) */ + makewhite(g, o); + lua_assert(g->gcstate != GCSfinalize && g->gcstate != GCSpause); + } + } +} + diff --git a/include/lua/lgc.h b/include/lua/lgc.h new file mode 100644 index 0000000..5a8dc60 --- /dev/null +++ b/include/lua/lgc.h @@ -0,0 +1,110 @@ +/* +** $Id: lgc.h,v 2.15.1.1 2007/12/27 13:02:25 roberto Exp $ +** Garbage Collector +** See Copyright Notice in lua.h +*/ + +#ifndef lgc_h +#define lgc_h + + +#include "lobject.h" + + +/* +** Possible states of the Garbage Collector +*/ +#define GCSpause 0 +#define GCSpropagate 1 +#define GCSsweepstring 2 +#define GCSsweep 3 +#define GCSfinalize 4 + + +/* +** some userful bit tricks +*/ +#define resetbits(x,m) ((x) &= cast(lu_byte, ~(m))) +#define setbits(x,m) ((x) |= (m)) +#define testbits(x,m) ((x) & (m)) +#define bitmask(b) (1<<(b)) +#define bit2mask(b1,b2) (bitmask(b1) | bitmask(b2)) +#define l_setbit(x,b) setbits(x, bitmask(b)) +#define resetbit(x,b) resetbits(x, bitmask(b)) +#define testbit(x,b) testbits(x, bitmask(b)) +#define set2bits(x,b1,b2) setbits(x, (bit2mask(b1, b2))) +#define reset2bits(x,b1,b2) resetbits(x, (bit2mask(b1, b2))) +#define test2bits(x,b1,b2) testbits(x, (bit2mask(b1, b2))) + + + +/* +** Layout for bit use in `marked' field: +** bit 0 - object is white (type 0) +** bit 1 - object is white (type 1) +** bit 2 - object is black +** bit 3 - for userdata: has been finalized +** bit 3 - for tables: has weak keys +** bit 4 - for tables: has weak values +** bit 5 - object is fixed (should not be collected) +** bit 6 - object is "super" fixed (only the main thread) +*/ + + +#define WHITE0BIT 0 +#define WHITE1BIT 1 +#define BLACKBIT 2 +#define FINALIZEDBIT 3 +#define KEYWEAKBIT 3 +#define VALUEWEAKBIT 4 +#define FIXEDBIT 5 +#define SFIXEDBIT 6 +#define WHITEBITS bit2mask(WHITE0BIT, WHITE1BIT) + + +#define iswhite(x) test2bits((x)->gch.marked, WHITE0BIT, WHITE1BIT) +#define isblack(x) testbit((x)->gch.marked, BLACKBIT) +#define isgray(x) (!isblack(x) && !iswhite(x)) + +#define otherwhite(g) (g->currentwhite ^ WHITEBITS) +#define isdead(g,v) ((v)->gch.marked & otherwhite(g) & WHITEBITS) + +#define changewhite(x) ((x)->gch.marked ^= WHITEBITS) +#define gray2black(x) l_setbit((x)->gch.marked, BLACKBIT) + +#define valiswhite(x) (iscollectable(x) && iswhite(gcvalue(x))) + +#define luaC_white(g) cast(lu_byte, (g)->currentwhite & WHITEBITS) + + +#define luaC_checkGC(L) { \ + condhardstacktests(luaD_reallocstack(L, L->stacksize - EXTRA_STACK - 1)); \ + if (G(L)->totalbytes >= G(L)->GCthreshold) \ + luaC_step(L); } + + +#define luaC_barrier(L,p,v) { if (valiswhite(v) && isblack(obj2gco(p))) \ + luaC_barrierf(L,obj2gco(p),gcvalue(v)); } + +#define luaC_barriert(L,t,v) { if (valiswhite(v) && isblack(obj2gco(t))) \ + luaC_barrierback(L,t); } + +#define luaC_objbarrier(L,p,o) \ + { if (iswhite(obj2gco(o)) && isblack(obj2gco(p))) \ + luaC_barrierf(L,obj2gco(p),obj2gco(o)); } + +#define luaC_objbarriert(L,t,o) \ + { if (iswhite(obj2gco(o)) && isblack(obj2gco(t))) luaC_barrierback(L,t); } + +LUAI_FUNC size_t luaC_separateudata (lua_State *L, int all); +LUAI_FUNC void luaC_callGCTM (lua_State *L); +LUAI_FUNC void luaC_freeall (lua_State *L); +LUAI_FUNC void luaC_step (lua_State *L); +LUAI_FUNC void luaC_fullgc (lua_State *L); +LUAI_FUNC void luaC_link (lua_State *L, GCObject *o, lu_byte tt); +LUAI_FUNC void luaC_linkupval (lua_State *L, UpVal *uv); +LUAI_FUNC void luaC_barrierf (lua_State *L, GCObject *o, GCObject *v); +LUAI_FUNC void luaC_barrierback (lua_State *L, Table *t); + + +#endif diff --git a/include/lua/linit.c b/include/lua/linit.c new file mode 100644 index 0000000..c1f90df --- /dev/null +++ b/include/lua/linit.c @@ -0,0 +1,38 @@ +/* +** $Id: linit.c,v 1.14.1.1 2007/12/27 13:02:25 roberto Exp $ +** Initialization of libraries for lua.c +** See Copyright Notice in lua.h +*/ + + +#define linit_c +#define LUA_LIB + +#include "lua.h" + +#include "lualib.h" +#include "lauxlib.h" + + +static const luaL_Reg lualibs[] = { + {"", luaopen_base}, + {LUA_LOADLIBNAME, luaopen_package}, + {LUA_TABLIBNAME, luaopen_table}, + {LUA_IOLIBNAME, luaopen_io}, + {LUA_OSLIBNAME, luaopen_os}, + {LUA_STRLIBNAME, luaopen_string}, + {LUA_MATHLIBNAME, luaopen_math}, + {LUA_DBLIBNAME, luaopen_debug}, + {NULL, NULL} +}; + + +LUALIB_API void luaL_openlibs (lua_State *L) { + const luaL_Reg *lib = lualibs; + for (; lib->func; lib++) { + lua_pushcfunction(L, lib->func); + lua_pushstring(L, lib->name); + lua_call(L, 1, 0); + } +} + diff --git a/include/lua/liolib.c b/include/lua/liolib.c new file mode 100644 index 0000000..e79ed1c --- /dev/null +++ b/include/lua/liolib.c @@ -0,0 +1,553 @@ +/* +** $Id: liolib.c,v 2.73.1.3 2008/01/18 17:47:43 roberto Exp $ +** Standard I/O (and system) library +** See Copyright Notice in lua.h +*/ + + +#include +#include +#include +#include + +#define liolib_c +#define LUA_LIB + +#include "lua.h" + +#include "lauxlib.h" +#include "lualib.h" + + + +#define IO_INPUT 1 +#define IO_OUTPUT 2 + + +static const char *const fnames[] = {"input", "output"}; + + +static int pushresult (lua_State *L, int i, const char *filename) { + int en = errno; /* calls to Lua API may change this value */ + if (i) { + lua_pushboolean(L, 1); + return 1; + } + else { + lua_pushnil(L); + if (filename) + lua_pushfstring(L, "%s: %s", filename, strerror(en)); + else + lua_pushfstring(L, "%s", strerror(en)); + lua_pushinteger(L, en); + return 3; + } +} + + +static void fileerror (lua_State *L, int arg, const char *filename) { + lua_pushfstring(L, "%s: %s", filename, strerror(errno)); + luaL_argerror(L, arg, lua_tostring(L, -1)); +} + + +#define tofilep(L) ((FILE **)luaL_checkudata(L, 1, LUA_FILEHANDLE)) + + +static int io_type (lua_State *L) { + void *ud; + luaL_checkany(L, 1); + ud = lua_touserdata(L, 1); + lua_getfield(L, LUA_REGISTRYINDEX, LUA_FILEHANDLE); + if (ud == NULL || !lua_getmetatable(L, 1) || !lua_rawequal(L, -2, -1)) + lua_pushnil(L); /* not a file */ + else if (*((FILE **)ud) == NULL) + lua_pushliteral(L, "closed file"); + else + lua_pushliteral(L, "file"); + return 1; +} + + +static FILE *tofile (lua_State *L) { + FILE **f = tofilep(L); + if (*f == NULL) + luaL_error(L, "attempt to use a closed file"); + return *f; +} + + + +/* +** When creating file handles, always creates a `closed' file handle +** before opening the actual file; so, if there is a memory error, the +** file is not left opened. +*/ +static FILE **newfile (lua_State *L) { + FILE **pf = (FILE **)lua_newuserdata(L, sizeof(FILE *)); + *pf = NULL; /* file handle is currently `closed' */ + luaL_getmetatable(L, LUA_FILEHANDLE); + lua_setmetatable(L, -2); + return pf; +} + + +/* +** function to (not) close the standard files stdin, stdout, and stderr +*/ +static int io_noclose (lua_State *L) { + lua_pushnil(L); + lua_pushliteral(L, "cannot close standard file"); + return 2; +} + + +/* +** function to close 'popen' files +*/ +static int io_pclose (lua_State *L) { + FILE **p = tofilep(L); + int ok = lua_pclose(L, *p); + *p = NULL; + return pushresult(L, ok, NULL); +} + + +/* +** function to close regular files +*/ +static int io_fclose (lua_State *L) { + FILE **p = tofilep(L); + int ok = (fclose(*p) == 0); + *p = NULL; + return pushresult(L, ok, NULL); +} + + +static int aux_close (lua_State *L) { + lua_getfenv(L, 1); + lua_getfield(L, -1, "__close"); + return (lua_tocfunction(L, -1))(L); +} + + +static int io_close (lua_State *L) { + if (lua_isnone(L, 1)) + lua_rawgeti(L, LUA_ENVIRONINDEX, IO_OUTPUT); + tofile(L); /* make sure argument is a file */ + return aux_close(L); +} + + +static int io_gc (lua_State *L) { + FILE *f = *tofilep(L); + /* ignore closed files */ + if (f != NULL) + aux_close(L); + return 0; +} + + +static int io_tostring (lua_State *L) { + FILE *f = *tofilep(L); + if (f == NULL) + lua_pushliteral(L, "file (closed)"); + else + lua_pushfstring(L, "file (%p)", f); + return 1; +} + + +static int io_open (lua_State *L) { + const char *filename = luaL_checkstring(L, 1); + const char *mode = luaL_optstring(L, 2, "r"); + FILE **pf = newfile(L); + *pf = fopen(filename, mode); + return (*pf == NULL) ? pushresult(L, 0, filename) : 1; +} + + +/* +** this function has a separated environment, which defines the +** correct __close for 'popen' files +*/ +static int io_popen (lua_State *L) { + const char *filename = luaL_checkstring(L, 1); + const char *mode = luaL_optstring(L, 2, "r"); + FILE **pf = newfile(L); + *pf = lua_popen(L, filename, mode); + return (*pf == NULL) ? pushresult(L, 0, filename) : 1; +} + + +static int io_tmpfile (lua_State *L) { + FILE **pf = newfile(L); + *pf = tmpfile(); + return (*pf == NULL) ? pushresult(L, 0, NULL) : 1; +} + + +static FILE *getiofile (lua_State *L, int findex) { + FILE *f; + lua_rawgeti(L, LUA_ENVIRONINDEX, findex); + f = *(FILE **)lua_touserdata(L, -1); + if (f == NULL) + luaL_error(L, "standard %s file is closed", fnames[findex - 1]); + return f; +} + + +static int g_iofile (lua_State *L, int f, const char *mode) { + if (!lua_isnoneornil(L, 1)) { + const char *filename = lua_tostring(L, 1); + if (filename) { + FILE **pf = newfile(L); + *pf = fopen(filename, mode); + if (*pf == NULL) + fileerror(L, 1, filename); + } + else { + tofile(L); /* check that it's a valid file handle */ + lua_pushvalue(L, 1); + } + lua_rawseti(L, LUA_ENVIRONINDEX, f); + } + /* return current value */ + lua_rawgeti(L, LUA_ENVIRONINDEX, f); + return 1; +} + + +static int io_input (lua_State *L) { + return g_iofile(L, IO_INPUT, "r"); +} + + +static int io_output (lua_State *L) { + return g_iofile(L, IO_OUTPUT, "w"); +} + + +static int io_readline (lua_State *L); + + +static void aux_lines (lua_State *L, int idx, int toclose) { + lua_pushvalue(L, idx); + lua_pushboolean(L, toclose); /* close/not close file when finished */ + lua_pushcclosure(L, io_readline, 2); +} + + +static int f_lines (lua_State *L) { + tofile(L); /* check that it's a valid file handle */ + aux_lines(L, 1, 0); + return 1; +} + + +static int io_lines (lua_State *L) { + if (lua_isnoneornil(L, 1)) { /* no arguments? */ + /* will iterate over default input */ + lua_rawgeti(L, LUA_ENVIRONINDEX, IO_INPUT); + return f_lines(L); + } + else { + const char *filename = luaL_checkstring(L, 1); + FILE **pf = newfile(L); + *pf = fopen(filename, "r"); + if (*pf == NULL) + fileerror(L, 1, filename); + aux_lines(L, lua_gettop(L), 1); + return 1; + } +} + + +/* +** {====================================================== +** READ +** ======================================================= +*/ + + +static int read_number (lua_State *L, FILE *f) { + lua_Number d; + if (fscanf(f, LUA_NUMBER_SCAN, &d) == 1) { + lua_pushnumber(L, d); + return 1; + } + else return 0; /* read fails */ +} + + +static int test_eof (lua_State *L, FILE *f) { + int c = getc(f); + ungetc(c, f); + lua_pushlstring(L, NULL, 0); + return (c != EOF); +} + + +static int read_line (lua_State *L, FILE *f) { + luaL_Buffer b; + luaL_buffinit(L, &b); + for (;;) { + size_t l; + char *p = luaL_prepbuffer(&b); + if (fgets(p, LUAL_BUFFERSIZE, f) == NULL) { /* eof? */ + luaL_pushresult(&b); /* close buffer */ + return (lua_objlen(L, -1) > 0); /* check whether read something */ + } + l = strlen(p); + if (l == 0 || p[l-1] != '\n') + luaL_addsize(&b, l); + else { + luaL_addsize(&b, l - 1); /* do not include `eol' */ + luaL_pushresult(&b); /* close buffer */ + return 1; /* read at least an `eol' */ + } + } +} + + +static int read_chars (lua_State *L, FILE *f, size_t n) { + size_t rlen; /* how much to read */ + size_t nr; /* number of chars actually read */ + luaL_Buffer b; + luaL_buffinit(L, &b); + rlen = LUAL_BUFFERSIZE; /* try to read that much each time */ + do { + char *p = luaL_prepbuffer(&b); + if (rlen > n) rlen = n; /* cannot read more than asked */ + nr = fread(p, sizeof(char), rlen, f); + luaL_addsize(&b, nr); + n -= nr; /* still have to read `n' chars */ + } while (n > 0 && nr == rlen); /* until end of count or eof */ + luaL_pushresult(&b); /* close buffer */ + return (n == 0 || lua_objlen(L, -1) > 0); +} + + +static int g_read (lua_State *L, FILE *f, int first) { + int nargs = lua_gettop(L) - 1; + int success; + int n; + clearerr(f); + if (nargs == 0) { /* no arguments? */ + success = read_line(L, f); + n = first+1; /* to return 1 result */ + } + else { /* ensure stack space for all results and for auxlib's buffer */ + luaL_checkstack(L, nargs+LUA_MINSTACK, "too many arguments"); + success = 1; + for (n = first; nargs-- && success; n++) { + if (lua_type(L, n) == LUA_TNUMBER) { + size_t l = (size_t)lua_tointeger(L, n); + success = (l == 0) ? test_eof(L, f) : read_chars(L, f, l); + } + else { + const char *p = lua_tostring(L, n); + luaL_argcheck(L, p && p[0] == '*', n, "invalid option"); + switch (p[1]) { + case 'n': /* number */ + success = read_number(L, f); + break; + case 'l': /* line */ + success = read_line(L, f); + break; + case 'a': /* file */ + read_chars(L, f, ~((size_t)0)); /* read MAX_SIZE_T chars */ + success = 1; /* always success */ + break; + default: + return luaL_argerror(L, n, "invalid format"); + } + } + } + } + if (ferror(f)) + return pushresult(L, 0, NULL); + if (!success) { + lua_pop(L, 1); /* remove last result */ + lua_pushnil(L); /* push nil instead */ + } + return n - first; +} + + +static int io_read (lua_State *L) { + return g_read(L, getiofile(L, IO_INPUT), 1); +} + + +static int f_read (lua_State *L) { + return g_read(L, tofile(L), 2); +} + + +static int io_readline (lua_State *L) { + FILE *f = *(FILE **)lua_touserdata(L, lua_upvalueindex(1)); + int sucess; + if (f == NULL) /* file is already closed? */ + luaL_error(L, "file is already closed"); + sucess = read_line(L, f); + if (ferror(f)) + return luaL_error(L, "%s", strerror(errno)); + if (sucess) return 1; + else { /* EOF */ + if (lua_toboolean(L, lua_upvalueindex(2))) { /* generator created file? */ + lua_settop(L, 0); + lua_pushvalue(L, lua_upvalueindex(1)); + aux_close(L); /* close it */ + } + return 0; + } +} + +/* }====================================================== */ + + +static int g_write (lua_State *L, FILE *f, int arg) { + int nargs = lua_gettop(L) - 1; + int status = 1; + for (; nargs--; arg++) { + if (lua_type(L, arg) == LUA_TNUMBER) { + /* optimization: could be done exactly as for strings */ + status = status && + fprintf(f, LUA_NUMBER_FMT, lua_tonumber(L, arg)) > 0; + } + else { + size_t l; + const char *s = luaL_checklstring(L, arg, &l); + status = status && (fwrite(s, sizeof(char), l, f) == l); + } + } + return pushresult(L, status, NULL); +} + + +static int io_write (lua_State *L) { + return g_write(L, getiofile(L, IO_OUTPUT), 1); +} + + +static int f_write (lua_State *L) { + return g_write(L, tofile(L), 2); +} + + +static int f_seek (lua_State *L) { + static const int mode[] = {SEEK_SET, SEEK_CUR, SEEK_END}; + static const char *const modenames[] = {"set", "cur", "end", NULL}; + FILE *f = tofile(L); + int op = luaL_checkoption(L, 2, "cur", modenames); + long offset = luaL_optlong(L, 3, 0); + op = fseek(f, offset, mode[op]); + if (op) + return pushresult(L, 0, NULL); /* error */ + else { + lua_pushinteger(L, ftell(f)); + return 1; + } +} + + +static int f_setvbuf (lua_State *L) { + static const int mode[] = {_IONBF, _IOFBF, _IOLBF}; + static const char *const modenames[] = {"no", "full", "line", NULL}; + FILE *f = tofile(L); + int op = luaL_checkoption(L, 2, NULL, modenames); + lua_Integer sz = luaL_optinteger(L, 3, LUAL_BUFFERSIZE); + int res = setvbuf(f, NULL, mode[op], sz); + return pushresult(L, res == 0, NULL); +} + + + +static int io_flush (lua_State *L) { + return pushresult(L, fflush(getiofile(L, IO_OUTPUT)) == 0, NULL); +} + + +static int f_flush (lua_State *L) { + return pushresult(L, fflush(tofile(L)) == 0, NULL); +} + + +static const luaL_Reg iolib[] = { + {"close", io_close}, + {"flush", io_flush}, + {"input", io_input}, + {"lines", io_lines}, + {"open", io_open}, + {"output", io_output}, + {"popen", io_popen}, + {"read", io_read}, + {"tmpfile", io_tmpfile}, + {"type", io_type}, + {"write", io_write}, + {NULL, NULL} +}; + + +static const luaL_Reg flib[] = { + {"close", io_close}, + {"flush", f_flush}, + {"lines", f_lines}, + {"read", f_read}, + {"seek", f_seek}, + {"setvbuf", f_setvbuf}, + {"write", f_write}, + {"__gc", io_gc}, + {"__tostring", io_tostring}, + {NULL, NULL} +}; + + +static void createmeta (lua_State *L) { + luaL_newmetatable(L, LUA_FILEHANDLE); /* create metatable for file handles */ + lua_pushvalue(L, -1); /* push metatable */ + lua_setfield(L, -2, "__index"); /* metatable.__index = metatable */ + luaL_register(L, NULL, flib); /* file methods */ +} + + +static void createstdfile (lua_State *L, FILE *f, int k, const char *fname) { + *newfile(L) = f; + if (k > 0) { + lua_pushvalue(L, -1); + lua_rawseti(L, LUA_ENVIRONINDEX, k); + } + lua_pushvalue(L, -2); /* copy environment */ + lua_setfenv(L, -2); /* set it */ + lua_setfield(L, -3, fname); +} + + +static void newfenv (lua_State *L, lua_CFunction cls) { + lua_createtable(L, 0, 1); + lua_pushcfunction(L, cls); + lua_setfield(L, -2, "__close"); +} + + +LUALIB_API int luaopen_io (lua_State *L) { + createmeta(L); + /* create (private) environment (with fields IO_INPUT, IO_OUTPUT, __close) */ + newfenv(L, io_fclose); + lua_replace(L, LUA_ENVIRONINDEX); + /* open library */ + luaL_register(L, LUA_IOLIBNAME, iolib); + /* create (and set) default files */ + newfenv(L, io_noclose); /* close function for default files */ + createstdfile(L, stdin, IO_INPUT, "stdin"); + createstdfile(L, stdout, IO_OUTPUT, "stdout"); + createstdfile(L, stderr, 0, "stderr"); + lua_pop(L, 1); /* pop environment for default files */ + lua_getfield(L, -1, "popen"); + newfenv(L, io_pclose); /* create environment for 'popen' */ + lua_setfenv(L, -2); /* set fenv for 'popen' */ + lua_pop(L, 1); /* pop 'popen' */ + return 1; +} + diff --git a/include/lua/llex.c b/include/lua/llex.c new file mode 100644 index 0000000..6dc3193 --- /dev/null +++ b/include/lua/llex.c @@ -0,0 +1,461 @@ +/* +** $Id: llex.c,v 2.20.1.1 2007/12/27 13:02:25 roberto Exp $ +** Lexical Analyzer +** See Copyright Notice in lua.h +*/ + + +#include +#include +#include + +#define llex_c +#define LUA_CORE + +#include "lua.h" + +#include "ldo.h" +#include "llex.h" +#include "lobject.h" +#include "lparser.h" +#include "lstate.h" +#include "lstring.h" +#include "ltable.h" +#include "lzio.h" + + + +#define next(ls) (ls->current = zgetc(ls->z)) + + + + +#define currIsNewline(ls) (ls->current == '\n' || ls->current == '\r') + + +/* ORDER RESERVED */ +const char *const luaX_tokens [] = { + "and", "break", "do", "else", "elseif", + "end", "false", "for", "function", "if", + "in", "local", "nil", "not", "or", "repeat", + "return", "then", "true", "until", "while", + "..", "...", "==", ">=", "<=", "~=", + "", "", "", "", + NULL +}; + + +#define save_and_next(ls) (save(ls, ls->current), next(ls)) + + +static void save (LexState *ls, int c) { + Mbuffer *b = ls->buff; + if (b->n + 1 > b->buffsize) { + size_t newsize; + if (b->buffsize >= MAX_SIZET/2) + luaX_lexerror(ls, "lexical element too long", 0); + newsize = b->buffsize * 2; + luaZ_resizebuffer(ls->L, b, newsize); + } + b->buffer[b->n++] = cast(char, c); +} + + +void luaX_init (lua_State *L) { + int i; + for (i=0; itsv.reserved = cast_byte(i+1); /* reserved word */ + } +} + + +#define MAXSRC 80 + + +const char *luaX_token2str (LexState *ls, int token) { + if (token < FIRST_RESERVED) { + lua_assert(token == cast(unsigned char, token)); + return (iscntrl(token)) ? luaO_pushfstring(ls->L, "char(%d)", token) : + luaO_pushfstring(ls->L, "%c", token); + } + else + return luaX_tokens[token-FIRST_RESERVED]; +} + + +static const char *txtToken (LexState *ls, int token) { + switch (token) { + case TK_NAME: + case TK_STRING: + case TK_NUMBER: + save(ls, '\0'); + return luaZ_buffer(ls->buff); + default: + return luaX_token2str(ls, token); + } +} + + +void luaX_lexerror (LexState *ls, const char *msg, int token) { + char buff[MAXSRC]; + luaO_chunkid(buff, getstr(ls->source), MAXSRC); + msg = luaO_pushfstring(ls->L, "%s:%d: %s", buff, ls->linenumber, msg); + if (token) + luaO_pushfstring(ls->L, "%s near " LUA_QS, msg, txtToken(ls, token)); + luaD_throw(ls->L, LUA_ERRSYNTAX); +} + + +void luaX_syntaxerror (LexState *ls, const char *msg) { + luaX_lexerror(ls, msg, ls->t.token); +} + + +TString *luaX_newstring (LexState *ls, const char *str, size_t l) { + lua_State *L = ls->L; + TString *ts = luaS_newlstr(L, str, l); + TValue *o = luaH_setstr(L, ls->fs->h, ts); /* entry for `str' */ + if (ttisnil(o)) + setbvalue(o, 1); /* make sure `str' will not be collected */ + return ts; +} + + +static void inclinenumber (LexState *ls) { + int old = ls->current; + lua_assert(currIsNewline(ls)); + next(ls); /* skip `\n' or `\r' */ + if (currIsNewline(ls) && ls->current != old) + next(ls); /* skip `\n\r' or `\r\n' */ + if (++ls->linenumber >= MAX_INT) + luaX_syntaxerror(ls, "chunk has too many lines"); +} + + +void luaX_setinput (lua_State *L, LexState *ls, ZIO *z, TString *source) { + ls->decpoint = '.'; + ls->L = L; + ls->lookahead.token = TK_EOS; /* no look-ahead token */ + ls->z = z; + ls->fs = NULL; + ls->linenumber = 1; + ls->lastline = 1; + ls->source = source; + luaZ_resizebuffer(ls->L, ls->buff, LUA_MINBUFFER); /* initialize buffer */ + next(ls); /* read first char */ +} + + + +/* +** ======================================================= +** LEXICAL ANALYZER +** ======================================================= +*/ + + + +static int check_next (LexState *ls, const char *set) { + if (!strchr(set, ls->current)) + return 0; + save_and_next(ls); + return 1; +} + + +static void buffreplace (LexState *ls, char from, char to) { + size_t n = luaZ_bufflen(ls->buff); + char *p = luaZ_buffer(ls->buff); + while (n--) + if (p[n] == from) p[n] = to; +} + + +static void trydecpoint (LexState *ls, SemInfo *seminfo) { + /* format error: try to update decimal point separator */ + struct lconv *cv = localeconv(); + char old = ls->decpoint; + ls->decpoint = (cv ? cv->decimal_point[0] : '.'); + buffreplace(ls, old, ls->decpoint); /* try updated decimal separator */ + if (!luaO_str2d(luaZ_buffer(ls->buff), &seminfo->r)) { + /* format error with correct decimal point: no more options */ + buffreplace(ls, ls->decpoint, '.'); /* undo change (for error message) */ + luaX_lexerror(ls, "malformed number", TK_NUMBER); + } +} + + +/* LUA_NUMBER */ +static void read_numeral (LexState *ls, SemInfo *seminfo) { + lua_assert(isdigit(ls->current)); + do { + save_and_next(ls); + } while (isdigit(ls->current) || ls->current == '.'); + if (check_next(ls, "Ee")) /* `E'? */ + check_next(ls, "+-"); /* optional exponent sign */ + while (isalnum(ls->current) || ls->current == '_') + save_and_next(ls); + save(ls, '\0'); + buffreplace(ls, '.', ls->decpoint); /* follow locale for decimal point */ + if (!luaO_str2d(luaZ_buffer(ls->buff), &seminfo->r)) /* format error? */ + trydecpoint(ls, seminfo); /* try to update decimal point separator */ +} + + +static int skip_sep (LexState *ls) { + int count = 0; + int s = ls->current; + lua_assert(s == '[' || s == ']'); + save_and_next(ls); + while (ls->current == '=') { + save_and_next(ls); + count++; + } + return (ls->current == s) ? count : (-count) - 1; +} + + +static void read_long_string (LexState *ls, SemInfo *seminfo, int sep) { + int cont = 0; + (void)(cont); /* avoid warnings when `cont' is not used */ + save_and_next(ls); /* skip 2nd `[' */ + if (currIsNewline(ls)) /* string starts with a newline? */ + inclinenumber(ls); /* skip it */ + for (;;) { + switch (ls->current) { + case EOZ: + luaX_lexerror(ls, (seminfo) ? "unfinished long string" : + "unfinished long comment", TK_EOS); + break; /* to avoid warnings */ +#if defined(LUA_COMPAT_LSTR) + case '[': { + if (skip_sep(ls) == sep) { + save_and_next(ls); /* skip 2nd `[' */ + cont++; +#if LUA_COMPAT_LSTR == 1 + if (sep == 0) + luaX_lexerror(ls, "nesting of [[...]] is deprecated", '['); +#endif + } + break; + } +#endif + case ']': { + if (skip_sep(ls) == sep) { + save_and_next(ls); /* skip 2nd `]' */ +#if defined(LUA_COMPAT_LSTR) && LUA_COMPAT_LSTR == 2 + cont--; + if (sep == 0 && cont >= 0) break; +#endif + goto endloop; + } + break; + } + case '\n': + case '\r': { + save(ls, '\n'); + inclinenumber(ls); + if (!seminfo) luaZ_resetbuffer(ls->buff); /* avoid wasting space */ + break; + } + default: { + if (seminfo) save_and_next(ls); + else next(ls); + } + } + } endloop: + if (seminfo) + seminfo->ts = luaX_newstring(ls, luaZ_buffer(ls->buff) + (2 + sep), + luaZ_bufflen(ls->buff) - 2*(2 + sep)); +} + + +static void read_string (LexState *ls, int del, SemInfo *seminfo) { + save_and_next(ls); + while (ls->current != del) { + switch (ls->current) { + case EOZ: + luaX_lexerror(ls, "unfinished string", TK_EOS); + continue; /* to avoid warnings */ + case '\n': + case '\r': + luaX_lexerror(ls, "unfinished string", TK_STRING); + continue; /* to avoid warnings */ + case '\\': { + int c; + next(ls); /* do not save the `\' */ + switch (ls->current) { + case 'a': c = '\a'; break; + case 'b': c = '\b'; break; + case 'f': c = '\f'; break; + case 'n': c = '\n'; break; + case 'r': c = '\r'; break; + case 't': c = '\t'; break; + case 'v': c = '\v'; break; + case '\n': /* go through */ + case '\r': save(ls, '\n'); inclinenumber(ls); continue; + case EOZ: continue; /* will raise an error next loop */ + default: { + if (!isdigit(ls->current)) + save_and_next(ls); /* handles \\, \", \', and \? */ + else { /* \xxx */ + int i = 0; + c = 0; + do { + c = 10*c + (ls->current-'0'); + next(ls); + } while (++i<3 && isdigit(ls->current)); + if (c > UCHAR_MAX) + luaX_lexerror(ls, "escape sequence too large", TK_STRING); + save(ls, c); + } + continue; + } + } + save(ls, c); + next(ls); + continue; + } + default: + save_and_next(ls); + } + } + save_and_next(ls); /* skip delimiter */ + seminfo->ts = luaX_newstring(ls, luaZ_buffer(ls->buff) + 1, + luaZ_bufflen(ls->buff) - 2); +} + + +static int llex (LexState *ls, SemInfo *seminfo) { + luaZ_resetbuffer(ls->buff); + for (;;) { + switch (ls->current) { + case '\n': + case '\r': { + inclinenumber(ls); + continue; + } + case '-': { + next(ls); + if (ls->current != '-') return '-'; + /* else is a comment */ + next(ls); + if (ls->current == '[') { + int sep = skip_sep(ls); + luaZ_resetbuffer(ls->buff); /* `skip_sep' may dirty the buffer */ + if (sep >= 0) { + read_long_string(ls, NULL, sep); /* long comment */ + luaZ_resetbuffer(ls->buff); + continue; + } + } + /* else short comment */ + while (!currIsNewline(ls) && ls->current != EOZ) + next(ls); + continue; + } + case '[': { + int sep = skip_sep(ls); + if (sep >= 0) { + read_long_string(ls, seminfo, sep); + return TK_STRING; + } + else if (sep == -1) return '['; + else luaX_lexerror(ls, "invalid long string delimiter", TK_STRING); + } + case '=': { + next(ls); + if (ls->current != '=') return '='; + else { next(ls); return TK_EQ; } + } + case '<': { + next(ls); + if (ls->current != '=') return '<'; + else { next(ls); return TK_LE; } + } + case '>': { + next(ls); + if (ls->current != '=') return '>'; + else { next(ls); return TK_GE; } + } + case '~': { + next(ls); + if (ls->current != '=') return '~'; + else { next(ls); return TK_NE; } + } + case '"': + case '\'': { + read_string(ls, ls->current, seminfo); + return TK_STRING; + } + case '.': { + save_and_next(ls); + if (check_next(ls, ".")) { + if (check_next(ls, ".")) + return TK_DOTS; /* ... */ + else return TK_CONCAT; /* .. */ + } + else if (!isdigit(ls->current)) return '.'; + else { + read_numeral(ls, seminfo); + return TK_NUMBER; + } + } + case EOZ: { + return TK_EOS; + } + default: { + if (isspace(ls->current)) { + lua_assert(!currIsNewline(ls)); + next(ls); + continue; + } + else if (isdigit(ls->current)) { + read_numeral(ls, seminfo); + return TK_NUMBER; + } + else if (isalpha(ls->current) || ls->current == '_') { + /* identifier or reserved word */ + TString *ts; + do { + save_and_next(ls); + } while (isalnum(ls->current) || ls->current == '_'); + ts = luaX_newstring(ls, luaZ_buffer(ls->buff), + luaZ_bufflen(ls->buff)); + if (ts->tsv.reserved > 0) /* reserved word? */ + return ts->tsv.reserved - 1 + FIRST_RESERVED; + else { + seminfo->ts = ts; + return TK_NAME; + } + } + else { + int c = ls->current; + next(ls); + return c; /* single-char tokens (+ - / ...) */ + } + } + } + } +} + + +void luaX_next (LexState *ls) { + ls->lastline = ls->linenumber; + if (ls->lookahead.token != TK_EOS) { /* is there a look-ahead token? */ + ls->t = ls->lookahead; /* use this one */ + ls->lookahead.token = TK_EOS; /* and discharge it */ + } + else + ls->t.token = llex(ls, &ls->t.seminfo); /* read next token */ +} + + +void luaX_lookahead (LexState *ls) { + lua_assert(ls->lookahead.token == TK_EOS); + ls->lookahead.token = llex(ls, &ls->lookahead.seminfo); +} + diff --git a/include/lua/llex.h b/include/lua/llex.h new file mode 100644 index 0000000..a9201ce --- /dev/null +++ b/include/lua/llex.h @@ -0,0 +1,81 @@ +/* +** $Id: llex.h,v 1.58.1.1 2007/12/27 13:02:25 roberto Exp $ +** Lexical Analyzer +** See Copyright Notice in lua.h +*/ + +#ifndef llex_h +#define llex_h + +#include "lobject.h" +#include "lzio.h" + + +#define FIRST_RESERVED 257 + +/* maximum length of a reserved word */ +#define TOKEN_LEN (sizeof("function")/sizeof(char)) + + +/* +* WARNING: if you change the order of this enumeration, +* grep "ORDER RESERVED" +*/ +enum RESERVED { + /* terminal symbols denoted by reserved words */ + TK_AND = FIRST_RESERVED, TK_BREAK, + TK_DO, TK_ELSE, TK_ELSEIF, TK_END, TK_FALSE, TK_FOR, TK_FUNCTION, + TK_IF, TK_IN, TK_LOCAL, TK_NIL, TK_NOT, TK_OR, TK_REPEAT, + TK_RETURN, TK_THEN, TK_TRUE, TK_UNTIL, TK_WHILE, + /* other terminal symbols */ + TK_CONCAT, TK_DOTS, TK_EQ, TK_GE, TK_LE, TK_NE, TK_NUMBER, + TK_NAME, TK_STRING, TK_EOS +}; + +/* number of reserved words */ +#define NUM_RESERVED (cast(int, TK_WHILE-FIRST_RESERVED+1)) + + +/* array with token `names' */ +LUAI_DATA const char *const luaX_tokens []; + + +typedef union { + lua_Number r; + TString *ts; +} SemInfo; /* semantics information */ + + +typedef struct Token { + int token; + SemInfo seminfo; +} Token; + + +typedef struct LexState { + int current; /* current character (charint) */ + int linenumber; /* input line counter */ + int lastline; /* line of last token `consumed' */ + Token t; /* current token */ + Token lookahead; /* look ahead token */ + struct FuncState *fs; /* `FuncState' is private to the parser */ + struct lua_State *L; + ZIO *z; /* input stream */ + Mbuffer *buff; /* buffer for tokens */ + TString *source; /* current source name */ + char decpoint; /* locale decimal point */ +} LexState; + + +LUAI_FUNC void luaX_init (lua_State *L); +LUAI_FUNC void luaX_setinput (lua_State *L, LexState *ls, ZIO *z, + TString *source); +LUAI_FUNC TString *luaX_newstring (LexState *ls, const char *str, size_t l); +LUAI_FUNC void luaX_next (LexState *ls); +LUAI_FUNC void luaX_lookahead (LexState *ls); +LUAI_FUNC void luaX_lexerror (LexState *ls, const char *msg, int token); +LUAI_FUNC void luaX_syntaxerror (LexState *ls, const char *s); +LUAI_FUNC const char *luaX_token2str (LexState *ls, int token); + + +#endif diff --git a/include/lua/llimits.h b/include/lua/llimits.h new file mode 100644 index 0000000..ca8dcb7 --- /dev/null +++ b/include/lua/llimits.h @@ -0,0 +1,128 @@ +/* +** $Id: llimits.h,v 1.69.1.1 2007/12/27 13:02:25 roberto Exp $ +** Limits, basic types, and some other `installation-dependent' definitions +** See Copyright Notice in lua.h +*/ + +#ifndef llimits_h +#define llimits_h + + +#include +#include + + +#include "lua.h" + + +typedef LUAI_UINT32 lu_int32; + +typedef LUAI_UMEM lu_mem; + +typedef LUAI_MEM l_mem; + + + +/* chars used as small naturals (so that `char' is reserved for characters) */ +typedef unsigned char lu_byte; + + +#define MAX_SIZET ((size_t)(~(size_t)0)-2) + +#define MAX_LUMEM ((lu_mem)(~(lu_mem)0)-2) + + +#define MAX_INT (INT_MAX-2) /* maximum value of an int (-2 for safety) */ + +/* +** conversion of pointer to integer +** this is for hashing only; there is no problem if the integer +** cannot hold the whole pointer value +*/ +#define IntPoint(p) ((unsigned int)(lu_mem)(p)) + + + +/* type to ensure maximum alignment */ +typedef LUAI_USER_ALIGNMENT_T L_Umaxalign; + + +/* result of a `usual argument conversion' over lua_Number */ +typedef LUAI_UACNUMBER l_uacNumber; + + +/* internal assertions for in-house debugging */ +#ifdef lua_assert + +#define check_exp(c,e) (lua_assert(c), (e)) +#define api_check(l,e) lua_assert(e) + +#else + +#define lua_assert(c) ((void)0) +#define check_exp(c,e) (e) +#define api_check luai_apicheck + +#endif + + +#ifndef UNUSED +#define UNUSED(x) ((void)(x)) /* to avoid warnings */ +#endif + + +#ifndef cast +#define cast(t, exp) ((t)(exp)) +#endif + +#define cast_byte(i) cast(lu_byte, (i)) +#define cast_num(i) cast(lua_Number, (i)) +#define cast_int(i) cast(int, (i)) + + + +/* +** type for virtual-machine instructions +** must be an unsigned with (at least) 4 bytes (see details in lopcodes.h) +*/ +typedef lu_int32 Instruction; + + + +/* maximum stack for a Lua function */ +#define MAXSTACK 250 + + + +/* minimum size for the string table (must be power of 2) */ +#ifndef MINSTRTABSIZE +#define MINSTRTABSIZE 32 +#endif + + +/* minimum size for string buffer */ +#ifndef LUA_MINBUFFER +#define LUA_MINBUFFER 32 +#endif + + +#ifndef lua_lock +#define lua_lock(L) ((void) 0) +#define lua_unlock(L) ((void) 0) +#endif + +#ifndef luai_threadyield +#define luai_threadyield(L) {lua_unlock(L); lua_lock(L);} +#endif + + +/* +** macro to control inclusion of some hard tests on stack reallocation +*/ +#ifndef HARDSTACKTESTS +#define condhardstacktests(x) ((void)0) +#else +#define condhardstacktests(x) x +#endif + +#endif diff --git a/include/lua/lmathlib.c b/include/lua/lmathlib.c new file mode 100644 index 0000000..441fbf7 --- /dev/null +++ b/include/lua/lmathlib.c @@ -0,0 +1,263 @@ +/* +** $Id: lmathlib.c,v 1.67.1.1 2007/12/27 13:02:25 roberto Exp $ +** Standard mathematical library +** See Copyright Notice in lua.h +*/ + + +#include +#include + +#define lmathlib_c +#define LUA_LIB + +#include "lua.h" + +#include "lauxlib.h" +#include "lualib.h" + + +#undef PI +#define PI (3.14159265358979323846) +#define RADIANS_PER_DEGREE (PI/180.0) + + + +static int math_abs (lua_State *L) { + lua_pushnumber(L, fabs(luaL_checknumber(L, 1))); + return 1; +} + +static int math_sin (lua_State *L) { + lua_pushnumber(L, sin(luaL_checknumber(L, 1))); + return 1; +} + +static int math_sinh (lua_State *L) { + lua_pushnumber(L, sinh(luaL_checknumber(L, 1))); + return 1; +} + +static int math_cos (lua_State *L) { + lua_pushnumber(L, cos(luaL_checknumber(L, 1))); + return 1; +} + +static int math_cosh (lua_State *L) { + lua_pushnumber(L, cosh(luaL_checknumber(L, 1))); + return 1; +} + +static int math_tan (lua_State *L) { + lua_pushnumber(L, tan(luaL_checknumber(L, 1))); + return 1; +} + +static int math_tanh (lua_State *L) { + lua_pushnumber(L, tanh(luaL_checknumber(L, 1))); + return 1; +} + +static int math_asin (lua_State *L) { + lua_pushnumber(L, asin(luaL_checknumber(L, 1))); + return 1; +} + +static int math_acos (lua_State *L) { + lua_pushnumber(L, acos(luaL_checknumber(L, 1))); + return 1; +} + +static int math_atan (lua_State *L) { + lua_pushnumber(L, atan(luaL_checknumber(L, 1))); + return 1; +} + +static int math_atan2 (lua_State *L) { + lua_pushnumber(L, atan2(luaL_checknumber(L, 1), luaL_checknumber(L, 2))); + return 1; +} + +static int math_ceil (lua_State *L) { + lua_pushnumber(L, ceil(luaL_checknumber(L, 1))); + return 1; +} + +static int math_floor (lua_State *L) { + lua_pushnumber(L, floor(luaL_checknumber(L, 1))); + return 1; +} + +static int math_fmod (lua_State *L) { + lua_pushnumber(L, fmod(luaL_checknumber(L, 1), luaL_checknumber(L, 2))); + return 1; +} + +static int math_modf (lua_State *L) { + double ip; + double fp = modf(luaL_checknumber(L, 1), &ip); + lua_pushnumber(L, ip); + lua_pushnumber(L, fp); + return 2; +} + +static int math_sqrt (lua_State *L) { + lua_pushnumber(L, sqrt(luaL_checknumber(L, 1))); + return 1; +} + +static int math_pow (lua_State *L) { + lua_pushnumber(L, pow(luaL_checknumber(L, 1), luaL_checknumber(L, 2))); + return 1; +} + +static int math_log (lua_State *L) { + lua_pushnumber(L, log(luaL_checknumber(L, 1))); + return 1; +} + +static int math_log10 (lua_State *L) { + lua_pushnumber(L, log10(luaL_checknumber(L, 1))); + return 1; +} + +static int math_exp (lua_State *L) { + lua_pushnumber(L, exp(luaL_checknumber(L, 1))); + return 1; +} + +static int math_deg (lua_State *L) { + lua_pushnumber(L, luaL_checknumber(L, 1)/RADIANS_PER_DEGREE); + return 1; +} + +static int math_rad (lua_State *L) { + lua_pushnumber(L, luaL_checknumber(L, 1)*RADIANS_PER_DEGREE); + return 1; +} + +static int math_frexp (lua_State *L) { + int e; + lua_pushnumber(L, frexp(luaL_checknumber(L, 1), &e)); + lua_pushinteger(L, e); + return 2; +} + +static int math_ldexp (lua_State *L) { + lua_pushnumber(L, ldexp(luaL_checknumber(L, 1), luaL_checkint(L, 2))); + return 1; +} + + + +static int math_min (lua_State *L) { + int n = lua_gettop(L); /* number of arguments */ + lua_Number dmin = luaL_checknumber(L, 1); + int i; + for (i=2; i<=n; i++) { + lua_Number d = luaL_checknumber(L, i); + if (d < dmin) + dmin = d; + } + lua_pushnumber(L, dmin); + return 1; +} + + +static int math_max (lua_State *L) { + int n = lua_gettop(L); /* number of arguments */ + lua_Number dmax = luaL_checknumber(L, 1); + int i; + for (i=2; i<=n; i++) { + lua_Number d = luaL_checknumber(L, i); + if (d > dmax) + dmax = d; + } + lua_pushnumber(L, dmax); + return 1; +} + + +static int math_random (lua_State *L) { + /* the `%' avoids the (rare) case of r==1, and is needed also because on + some systems (SunOS!) `rand()' may return a value larger than RAND_MAX */ + lua_Number r = (lua_Number)(rand()%RAND_MAX) / (lua_Number)RAND_MAX; + switch (lua_gettop(L)) { /* check number of arguments */ + case 0: { /* no arguments */ + lua_pushnumber(L, r); /* Number between 0 and 1 */ + break; + } + case 1: { /* only upper limit */ + int u = luaL_checkint(L, 1); + luaL_argcheck(L, 1<=u, 1, "interval is empty"); + lua_pushnumber(L, floor(r*u)+1); /* int between 1 and `u' */ + break; + } + case 2: { /* lower and upper limits */ + int l = luaL_checkint(L, 1); + int u = luaL_checkint(L, 2); + luaL_argcheck(L, l<=u, 2, "interval is empty"); + lua_pushnumber(L, floor(r*(u-l+1))+l); /* int between `l' and `u' */ + break; + } + default: return luaL_error(L, "wrong number of arguments"); + } + return 1; +} + + +static int math_randomseed (lua_State *L) { + srand(luaL_checkint(L, 1)); + return 0; +} + + +static const luaL_Reg mathlib[] = { + {"abs", math_abs}, + {"acos", math_acos}, + {"asin", math_asin}, + {"atan2", math_atan2}, + {"atan", math_atan}, + {"ceil", math_ceil}, + {"cosh", math_cosh}, + {"cos", math_cos}, + {"deg", math_deg}, + {"exp", math_exp}, + {"floor", math_floor}, + {"fmod", math_fmod}, + {"frexp", math_frexp}, + {"ldexp", math_ldexp}, + {"log10", math_log10}, + {"log", math_log}, + {"max", math_max}, + {"min", math_min}, + {"modf", math_modf}, + {"pow", math_pow}, + {"rad", math_rad}, + {"random", math_random}, + {"randomseed", math_randomseed}, + {"sinh", math_sinh}, + {"sin", math_sin}, + {"sqrt", math_sqrt}, + {"tanh", math_tanh}, + {"tan", math_tan}, + {NULL, NULL} +}; + + +/* +** Open math library +*/ +LUALIB_API int luaopen_math (lua_State *L) { + luaL_register(L, LUA_MATHLIBNAME, mathlib); + lua_pushnumber(L, PI); + lua_setfield(L, -2, "pi"); + lua_pushnumber(L, HUGE_VAL); + lua_setfield(L, -2, "huge"); +#if defined(LUA_COMPAT_MOD) + lua_getfield(L, -1, "fmod"); + lua_setfield(L, -2, "mod"); +#endif + return 1; +} + diff --git a/include/lua/lmem.c b/include/lua/lmem.c new file mode 100644 index 0000000..ae7d8c9 --- /dev/null +++ b/include/lua/lmem.c @@ -0,0 +1,86 @@ +/* +** $Id: lmem.c,v 1.70.1.1 2007/12/27 13:02:25 roberto Exp $ +** Interface to Memory Manager +** See Copyright Notice in lua.h +*/ + + +#include + +#define lmem_c +#define LUA_CORE + +#include "lua.h" + +#include "ldebug.h" +#include "ldo.h" +#include "lmem.h" +#include "lobject.h" +#include "lstate.h" + + + +/* +** About the realloc function: +** void * frealloc (void *ud, void *ptr, size_t osize, size_t nsize); +** (`osize' is the old size, `nsize' is the new size) +** +** Lua ensures that (ptr == NULL) iff (osize == 0). +** +** * frealloc(ud, NULL, 0, x) creates a new block of size `x' +** +** * frealloc(ud, p, x, 0) frees the block `p' +** (in this specific case, frealloc must return NULL). +** particularly, frealloc(ud, NULL, 0, 0) does nothing +** (which is equivalent to free(NULL) in ANSI C) +** +** frealloc returns NULL if it cannot create or reallocate the area +** (any reallocation to an equal or smaller size cannot fail!) +*/ + + + +#define MINSIZEARRAY 4 + + +void *luaM_growaux_ (lua_State *L, void *block, int *size, size_t size_elems, + int limit, const char *errormsg) { + void *newblock; + int newsize; + if (*size >= limit/2) { /* cannot double it? */ + if (*size >= limit) /* cannot grow even a little? */ + luaG_runerror(L, errormsg); + newsize = limit; /* still have at least one free place */ + } + else { + newsize = (*size)*2; + if (newsize < MINSIZEARRAY) + newsize = MINSIZEARRAY; /* minimum size */ + } + newblock = luaM_reallocv(L, block, *size, newsize, size_elems); + *size = newsize; /* update only when everything else is OK */ + return newblock; +} + + +void *luaM_toobig (lua_State *L) { + luaG_runerror(L, "memory allocation error: block too big"); + return NULL; /* to avoid warnings */ +} + + + +/* +** generic allocation routine. +*/ +void *luaM_realloc_ (lua_State *L, void *block, size_t osize, size_t nsize) { + global_State *g = G(L); + lua_assert((osize == 0) == (block == NULL)); + block = (*g->frealloc)(g->ud, block, osize, nsize); + if (block == NULL && nsize > 0) + luaD_throw(L, LUA_ERRMEM); + lua_assert((nsize == 0) == (block == NULL)); + g->totalbytes = (g->totalbytes - osize) + nsize; + return block; +} + diff --git a/include/lua/lmem.h b/include/lua/lmem.h new file mode 100644 index 0000000..7c2dcb3 --- /dev/null +++ b/include/lua/lmem.h @@ -0,0 +1,49 @@ +/* +** $Id: lmem.h,v 1.31.1.1 2007/12/27 13:02:25 roberto Exp $ +** Interface to Memory Manager +** See Copyright Notice in lua.h +*/ + +#ifndef lmem_h +#define lmem_h + + +#include + +#include "llimits.h" +#include "lua.h" + +#define MEMERRMSG "not enough memory" + + +#define luaM_reallocv(L,b,on,n,e) \ + ((cast(size_t, (n)+1) <= MAX_SIZET/(e)) ? /* +1 to avoid warnings */ \ + luaM_realloc_(L, (b), (on)*(e), (n)*(e)) : \ + luaM_toobig(L)) + +#define luaM_freemem(L, b, s) luaM_realloc_(L, (b), (s), 0) +#define luaM_free(L, b) luaM_realloc_(L, (b), sizeof(*(b)), 0) +#define luaM_freearray(L, b, n, t) luaM_reallocv(L, (b), n, 0, sizeof(t)) + +#define luaM_malloc(L,t) luaM_realloc_(L, NULL, 0, (t)) +#define luaM_new(L,t) cast(t *, luaM_malloc(L, sizeof(t))) +#define luaM_newvector(L,n,t) \ + cast(t *, luaM_reallocv(L, NULL, 0, n, sizeof(t))) + +#define luaM_growvector(L,v,nelems,size,t,limit,e) \ + if ((nelems)+1 > (size)) \ + ((v)=cast(t *, luaM_growaux_(L,v,&(size),sizeof(t),limit,e))) + +#define luaM_reallocvector(L, v,oldn,n,t) \ + ((v)=cast(t *, luaM_reallocv(L, v, oldn, n, sizeof(t)))) + + +LUAI_FUNC void *luaM_realloc_ (lua_State *L, void *block, size_t oldsize, + size_t size); +LUAI_FUNC void *luaM_toobig (lua_State *L); +LUAI_FUNC void *luaM_growaux_ (lua_State *L, void *block, int *size, + size_t size_elem, int limit, + const char *errormsg); + +#endif + diff --git a/include/lua/loadlib.c b/include/lua/loadlib.c new file mode 100644 index 0000000..cbcaf9d --- /dev/null +++ b/include/lua/loadlib.c @@ -0,0 +1,667 @@ +/* +** $Id: loadlib.c,v 1.52.1.3 2008/08/06 13:29:28 roberto Exp $ +** Dynamic library loader for Lua +** See Copyright Notice in lua.h +** +** This module contains an implementation of loadlib for Unix systems +** that have dlfcn, an implementation for Darwin (Mac OS X), an +** implementation for Windows, and a stub for other systems. +*/ + + +#include +#include +#include + + +#define loadlib_c +#define LUA_LIB + +#include "lua.h" + +#include "lauxlib.h" +#include "lualib.h" + + +/* prefix for open functions in C libraries */ +#define LUA_POF "luaopen_" + +/* separator for open functions in C libraries */ +#define LUA_OFSEP "_" + + +#define LIBPREFIX "LOADLIB: " + +#define POF LUA_POF +#define LIB_FAIL "open" + + +/* error codes for ll_loadfunc */ +#define ERRLIB 1 +#define ERRFUNC 2 + +#define setprogdir(L) ((void)0) + + +static void ll_unloadlib (void *lib); +static void *ll_load (lua_State *L, const char *path); +static lua_CFunction ll_sym (lua_State *L, void *lib, const char *sym); + + + +#if defined(LUA_DL_DLOPEN) +/* +** {======================================================================== +** This is an implementation of loadlib based on the dlfcn interface. +** The dlfcn interface is available in Linux, SunOS, Solaris, IRIX, FreeBSD, +** NetBSD, AIX 4.2, HPUX 11, and probably most other Unix flavors, at least +** as an emulation layer on top of native functions. +** ========================================================================= +*/ + +#include + +static void ll_unloadlib (void *lib) { + dlclose(lib); +} + + +static void *ll_load (lua_State *L, const char *path) { + void *lib = dlopen(path, RTLD_NOW); + if (lib == NULL) lua_pushstring(L, dlerror()); + return lib; +} + + +static lua_CFunction ll_sym (lua_State *L, void *lib, const char *sym) { + lua_CFunction f = (lua_CFunction)dlsym(lib, sym); + if (f == NULL) lua_pushstring(L, dlerror()); + return f; +} + +/* }====================================================== */ + + + +#elif defined(LUA_DL_DLL) +/* +** {====================================================================== +** This is an implementation of loadlib for Windows using native functions. +** ======================================================================= +*/ + +#include + + +#undef setprogdir + +static void setprogdir (lua_State *L) { + char buff[MAX_PATH + 1]; + char *lb; + DWORD nsize = sizeof(buff)/sizeof(char); + DWORD n = GetModuleFileNameA(NULL, buff, nsize); + if (n == 0 || n == nsize || (lb = strrchr(buff, '\\')) == NULL) + luaL_error(L, "unable to get ModuleFileName"); + else { + *lb = '\0'; + luaL_gsub(L, lua_tostring(L, -1), LUA_EXECDIR, buff); + lua_remove(L, -2); /* remove original string */ + } +} + + +static void pusherror (lua_State *L) { + int error = GetLastError(); + char buffer[128]; + if (FormatMessageA(FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_FROM_SYSTEM, + NULL, error, 0, buffer, sizeof(buffer), NULL)) + lua_pushstring(L, buffer); + else + lua_pushfstring(L, "system error %d\n", error); +} + +static void ll_unloadlib (void *lib) { + FreeLibrary((HINSTANCE)lib); +} + + +static void *ll_load (lua_State *L, const char *path) { + HINSTANCE lib = LoadLibraryA(path); + if (lib == NULL) pusherror(L); + return lib; +} + + +static lua_CFunction ll_sym (lua_State *L, void *lib, const char *sym) { + lua_CFunction f = (lua_CFunction)GetProcAddress((HINSTANCE)lib, sym); + if (f == NULL) pusherror(L); + return f; +} + +/* }====================================================== */ + + + +#elif defined(LUA_DL_DYLD) +/* +** {====================================================================== +** Native Mac OS X / Darwin Implementation +** ======================================================================= +*/ + +#include + + +/* Mac appends a `_' before C function names */ +#undef POF +#define POF "_" LUA_POF + + +static void pusherror (lua_State *L) { + const char *err_str; + const char *err_file; + NSLinkEditErrors err; + int err_num; + NSLinkEditError(&err, &err_num, &err_file, &err_str); + lua_pushstring(L, err_str); +} + + +static const char *errorfromcode (NSObjectFileImageReturnCode ret) { + switch (ret) { + case NSObjectFileImageInappropriateFile: + return "file is not a bundle"; + case NSObjectFileImageArch: + return "library is for wrong CPU type"; + case NSObjectFileImageFormat: + return "bad format"; + case NSObjectFileImageAccess: + return "cannot access file"; + case NSObjectFileImageFailure: + default: + return "unable to load library"; + } +} + + +static void ll_unloadlib (void *lib) { + NSUnLinkModule((NSModule)lib, NSUNLINKMODULE_OPTION_RESET_LAZY_REFERENCES); +} + + +static void *ll_load (lua_State *L, const char *path) { + NSObjectFileImage img; + NSObjectFileImageReturnCode ret; + /* this would be a rare case, but prevents crashing if it happens */ + if(!_dyld_present()) { + lua_pushliteral(L, "dyld not present"); + return NULL; + } + ret = NSCreateObjectFileImageFromFile(path, &img); + if (ret == NSObjectFileImageSuccess) { + NSModule mod = NSLinkModule(img, path, NSLINKMODULE_OPTION_PRIVATE | + NSLINKMODULE_OPTION_RETURN_ON_ERROR); + NSDestroyObjectFileImage(img); + if (mod == NULL) pusherror(L); + return mod; + } + lua_pushstring(L, errorfromcode(ret)); + return NULL; +} + + +static lua_CFunction ll_sym (lua_State *L, void *lib, const char *sym) { + NSSymbol nss = NSLookupSymbolInModule((NSModule)lib, sym); + if (nss == NULL) { + lua_pushfstring(L, "symbol " LUA_QS " not found", sym); + return NULL; + } + return (lua_CFunction)NSAddressOfSymbol(nss); +} + +/* }====================================================== */ + + + +#else +/* +** {====================================================== +** Fallback for other systems +** ======================================================= +*/ + +#undef LIB_FAIL +#define LIB_FAIL "absent" + + +#define DLMSG "dynamic libraries not enabled; check your Lua installation" + + +static void ll_unloadlib (void *lib) { + (void)lib; /* to avoid warnings */ +} + + +static void *ll_load (lua_State *L, const char *path) { + (void)path; /* to avoid warnings */ + lua_pushliteral(L, DLMSG); + return NULL; +} + + +static lua_CFunction ll_sym (lua_State *L, void *lib, const char *sym) { + (void)lib; (void)sym; /* to avoid warnings */ + lua_pushliteral(L, DLMSG); + return NULL; +} + +/* }====================================================== */ +#endif + + + +static void **ll_register (lua_State *L, const char *path) { + void **plib; + lua_pushfstring(L, "%s%s", LIBPREFIX, path); + lua_gettable(L, LUA_REGISTRYINDEX); /* check library in registry? */ + if (!lua_isnil(L, -1)) /* is there an entry? */ + plib = (void **)lua_touserdata(L, -1); + else { /* no entry yet; create one */ + lua_pop(L, 1); + plib = (void **)lua_newuserdata(L, sizeof(const void *)); + *plib = NULL; + luaL_getmetatable(L, "_LOADLIB"); + lua_setmetatable(L, -2); + lua_pushfstring(L, "%s%s", LIBPREFIX, path); + lua_pushvalue(L, -2); + lua_settable(L, LUA_REGISTRYINDEX); + } + return plib; +} + + +/* +** __gc tag method: calls library's `ll_unloadlib' function with the lib +** handle +*/ +static int gctm (lua_State *L) { + void **lib = (void **)luaL_checkudata(L, 1, "_LOADLIB"); + if (*lib) ll_unloadlib(*lib); + *lib = NULL; /* mark library as closed */ + return 0; +} + + +static int ll_loadfunc (lua_State *L, const char *path, const char *sym) { + void **reg = ll_register(L, path); + if (*reg == NULL) *reg = ll_load(L, path); + if (*reg == NULL) + return ERRLIB; /* unable to load library */ + else { + lua_CFunction f = ll_sym(L, *reg, sym); + if (f == NULL) + return ERRFUNC; /* unable to find function */ + lua_pushcfunction(L, f); + return 0; /* return function */ + } +} + + +static int ll_loadlib (lua_State *L) { + const char *path = luaL_checkstring(L, 1); + const char *init = luaL_checkstring(L, 2); + int stat = ll_loadfunc(L, path, init); + if (stat == 0) /* no errors? */ + return 1; /* return the loaded function */ + else { /* error; error message is on stack top */ + lua_pushnil(L); + lua_insert(L, -2); + lua_pushstring(L, (stat == ERRLIB) ? LIB_FAIL : "init"); + return 3; /* return nil, error message, and where */ + } +} + + + +/* +** {====================================================== +** 'require' function +** ======================================================= +*/ + + +static int readable (const char *filename) { + FILE *f = fopen(filename, "r"); /* try to open file */ + if (f == NULL) return 0; /* open failed */ + fclose(f); + return 1; +} + + +static const char *pushnexttemplate (lua_State *L, const char *path) { + const char *l; + while (*path == *LUA_PATHSEP) path++; /* skip separators */ + if (*path == '\0') return NULL; /* no more templates */ + l = strchr(path, *LUA_PATHSEP); /* find next separator */ + if (l == NULL) l = path + strlen(path); + lua_pushlstring(L, path, l - path); /* template */ + return l; +} + + +static const char *findfile (lua_State *L, const char *name, + const char *pname) { + const char *path; + name = luaL_gsub(L, name, ".", LUA_DIRSEP); + lua_getfield(L, LUA_ENVIRONINDEX, pname); + path = lua_tostring(L, -1); + if (path == NULL) + luaL_error(L, LUA_QL("package.%s") " must be a string", pname); + lua_pushliteral(L, ""); /* error accumulator */ + while ((path = pushnexttemplate(L, path)) != NULL) { + const char *filename; + filename = luaL_gsub(L, lua_tostring(L, -1), LUA_PATH_MARK, name); + lua_remove(L, -2); /* remove path template */ + if (readable(filename)) /* does file exist and is readable? */ + return filename; /* return that file name */ + lua_pushfstring(L, "\n\tno file " LUA_QS, filename); + lua_remove(L, -2); /* remove file name */ + lua_concat(L, 2); /* add entry to possible error message */ + } + return NULL; /* not found */ +} + + +static void loaderror (lua_State *L, const char *filename) { + luaL_error(L, "error loading module " LUA_QS " from file " LUA_QS ":\n\t%s", + lua_tostring(L, 1), filename, lua_tostring(L, -1)); +} + + +static int loader_Lua (lua_State *L) { + const char *filename; + const char *name = luaL_checkstring(L, 1); + filename = findfile(L, name, "path"); + if (filename == NULL) return 1; /* library not found in this path */ + if (luaL_loadfile(L, filename) != 0) + loaderror(L, filename); + return 1; /* library loaded successfully */ +} + + +static const char *mkfuncname (lua_State *L, const char *modname) { + const char *funcname; + const char *mark = strchr(modname, *LUA_IGMARK); + if (mark) modname = mark + 1; + funcname = luaL_gsub(L, modname, ".", LUA_OFSEP); + funcname = lua_pushfstring(L, POF"%s", funcname); + lua_remove(L, -2); /* remove 'gsub' result */ + return funcname; +} + + +static int loader_C (lua_State *L) { + const char *funcname; + const char *name = luaL_checkstring(L, 1); + const char *filename = findfile(L, name, "cpath"); + if (filename == NULL) return 1; /* library not found in this path */ + funcname = mkfuncname(L, name); + if (ll_loadfunc(L, filename, funcname) != 0) + loaderror(L, filename); + return 1; /* library loaded successfully */ +} + + +static int loader_Croot (lua_State *L) { + const char *funcname; + const char *filename; + const char *name = luaL_checkstring(L, 1); + const char *p = strchr(name, '.'); + int stat; + if (p == NULL) return 0; /* is root */ + lua_pushlstring(L, name, p - name); + filename = findfile(L, lua_tostring(L, -1), "cpath"); + if (filename == NULL) return 1; /* root not found */ + funcname = mkfuncname(L, name); + if ((stat = ll_loadfunc(L, filename, funcname)) != 0) { + if (stat != ERRFUNC) loaderror(L, filename); /* real error */ + lua_pushfstring(L, "\n\tno module " LUA_QS " in file " LUA_QS, + name, filename); + return 1; /* function not found */ + } + return 1; +} + + +static int loader_preload (lua_State *L) { + const char *name = luaL_checkstring(L, 1); + lua_getfield(L, LUA_ENVIRONINDEX, "preload"); + if (!lua_istable(L, -1)) + luaL_error(L, LUA_QL("package.preload") " must be a table"); + lua_getfield(L, -1, name); + if (lua_isnil(L, -1)) /* not found? */ + lua_pushfstring(L, "\n\tno field package.preload['%s']", name); + return 1; +} + + +static const int sentinel_ = 0; +#define sentinel ((void *)&sentinel_) + + +static int ll_require (lua_State *L) { + const char *name = luaL_checkstring(L, 1); + int i; + lua_settop(L, 1); /* _LOADED table will be at index 2 */ + lua_getfield(L, LUA_REGISTRYINDEX, "_LOADED"); + lua_getfield(L, 2, name); + if (lua_toboolean(L, -1)) { /* is it there? */ + if (lua_touserdata(L, -1) == sentinel) /* check loops */ + luaL_error(L, "loop or previous error loading module " LUA_QS, name); + return 1; /* package is already loaded */ + } + /* else must load it; iterate over available loaders */ + lua_getfield(L, LUA_ENVIRONINDEX, "loaders"); + if (!lua_istable(L, -1)) + luaL_error(L, LUA_QL("package.loaders") " must be a table"); + lua_pushliteral(L, ""); /* error message accumulator */ + for (i=1; ; i++) { + lua_rawgeti(L, -2, i); /* get a loader */ + if (lua_isnil(L, -1)) + luaL_error(L, "module " LUA_QS " not found:%s", + name, lua_tostring(L, -2)); + lua_pushstring(L, name); + lua_call(L, 1, 1); /* call it */ + if (lua_isfunction(L, -1)) /* did it find module? */ + break; /* module loaded successfully */ + else if (lua_isstring(L, -1)) /* loader returned error message? */ + lua_concat(L, 2); /* accumulate it */ + else + lua_pop(L, 1); + } + lua_pushlightuserdata(L, sentinel); + lua_setfield(L, 2, name); /* _LOADED[name] = sentinel */ + lua_pushstring(L, name); /* pass name as argument to module */ + lua_call(L, 1, 1); /* run loaded module */ + if (!lua_isnil(L, -1)) /* non-nil return? */ + lua_setfield(L, 2, name); /* _LOADED[name] = returned value */ + lua_getfield(L, 2, name); + if (lua_touserdata(L, -1) == sentinel) { /* module did not set a value? */ + lua_pushboolean(L, 1); /* use true as result */ + lua_pushvalue(L, -1); /* extra copy to be returned */ + lua_setfield(L, 2, name); /* _LOADED[name] = true */ + } + return 1; +} + +/* }====================================================== */ + + + +/* +** {====================================================== +** 'module' function +** ======================================================= +*/ + + +static void setfenv (lua_State *L) { + lua_Debug ar; + if (lua_getstack(L, 1, &ar) == 0 || + lua_getinfo(L, "f", &ar) == 0 || /* get calling function */ + lua_iscfunction(L, -1)) + luaL_error(L, LUA_QL("module") " not called from a Lua function"); + lua_pushvalue(L, -2); + lua_setfenv(L, -2); + lua_pop(L, 1); +} + + +static void dooptions (lua_State *L, int n) { + int i; + for (i = 2; i <= n; i++) { + lua_pushvalue(L, i); /* get option (a function) */ + lua_pushvalue(L, -2); /* module */ + lua_call(L, 1, 0); + } +} + + +static void modinit (lua_State *L, const char *modname) { + const char *dot; + lua_pushvalue(L, -1); + lua_setfield(L, -2, "_M"); /* module._M = module */ + lua_pushstring(L, modname); + lua_setfield(L, -2, "_NAME"); + dot = strrchr(modname, '.'); /* look for last dot in module name */ + if (dot == NULL) dot = modname; + else dot++; + /* set _PACKAGE as package name (full module name minus last part) */ + lua_pushlstring(L, modname, dot - modname); + lua_setfield(L, -2, "_PACKAGE"); +} + + +static int ll_module (lua_State *L) { + const char *modname = luaL_checkstring(L, 1); + int loaded = lua_gettop(L) + 1; /* index of _LOADED table */ + lua_getfield(L, LUA_REGISTRYINDEX, "_LOADED"); + lua_getfield(L, loaded, modname); /* get _LOADED[modname] */ + if (!lua_istable(L, -1)) { /* not found? */ + lua_pop(L, 1); /* remove previous result */ + /* try global variable (and create one if it does not exist) */ + if (luaL_findtable(L, LUA_GLOBALSINDEX, modname, 1) != NULL) + return luaL_error(L, "name conflict for module " LUA_QS, modname); + lua_pushvalue(L, -1); + lua_setfield(L, loaded, modname); /* _LOADED[modname] = new table */ + } + /* check whether table already has a _NAME field */ + lua_getfield(L, -1, "_NAME"); + if (!lua_isnil(L, -1)) /* is table an initialized module? */ + lua_pop(L, 1); + else { /* no; initialize it */ + lua_pop(L, 1); + modinit(L, modname); + } + lua_pushvalue(L, -1); + setfenv(L); + dooptions(L, loaded - 1); + return 0; +} + + +static int ll_seeall (lua_State *L) { + luaL_checktype(L, 1, LUA_TTABLE); + if (!lua_getmetatable(L, 1)) { + lua_createtable(L, 0, 1); /* create new metatable */ + lua_pushvalue(L, -1); + lua_setmetatable(L, 1); + } + lua_pushvalue(L, LUA_GLOBALSINDEX); + lua_setfield(L, -2, "__index"); /* mt.__index = _G */ + return 0; +} + + +/* }====================================================== */ + + + +/* auxiliary mark (for internal use) */ +#define AUXMARK "\1" + +static void setpath (lua_State *L, const char *fieldname, const char *envname, + const char *def) { + const char *path = getenv(envname); + if (path == NULL) /* no environment variable? */ + lua_pushstring(L, def); /* use default */ + else { + /* replace ";;" by ";AUXMARK;" and then AUXMARK by default path */ + path = luaL_gsub(L, path, LUA_PATHSEP LUA_PATHSEP, + LUA_PATHSEP AUXMARK LUA_PATHSEP); + luaL_gsub(L, path, AUXMARK, def); + lua_remove(L, -2); + } + setprogdir(L); + lua_setfield(L, -2, fieldname); +} + + +static const luaL_Reg pk_funcs[] = { + {"loadlib", ll_loadlib}, + {"seeall", ll_seeall}, + {NULL, NULL} +}; + + +static const luaL_Reg ll_funcs[] = { + {"module", ll_module}, + {"require", ll_require}, + {NULL, NULL} +}; + + +static const lua_CFunction loaders[] = + {loader_preload, loader_Lua, loader_C, loader_Croot, NULL}; + + +LUALIB_API int luaopen_package (lua_State *L) { + int i; + /* create new type _LOADLIB */ + luaL_newmetatable(L, "_LOADLIB"); + lua_pushcfunction(L, gctm); + lua_setfield(L, -2, "__gc"); + /* create `package' table */ + luaL_register(L, LUA_LOADLIBNAME, pk_funcs); +#if defined(LUA_COMPAT_LOADLIB) + lua_getfield(L, -1, "loadlib"); + lua_setfield(L, LUA_GLOBALSINDEX, "loadlib"); +#endif + lua_pushvalue(L, -1); + lua_replace(L, LUA_ENVIRONINDEX); + /* create `loaders' table */ + lua_createtable(L, 0, sizeof(loaders)/sizeof(loaders[0]) - 1); + /* fill it with pre-defined loaders */ + for (i=0; loaders[i] != NULL; i++) { + lua_pushcfunction(L, loaders[i]); + lua_rawseti(L, -2, i+1); + } + lua_setfield(L, -2, "loaders"); /* put it in field `loaders' */ + setpath(L, "path", LUA_PATH, LUA_PATH_DEFAULT); /* set field `path' */ + setpath(L, "cpath", LUA_CPATH, LUA_CPATH_DEFAULT); /* set field `cpath' */ + /* store config information */ + lua_pushliteral(L, LUA_DIRSEP "\n" LUA_PATHSEP "\n" LUA_PATH_MARK "\n" + LUA_EXECDIR "\n" LUA_IGMARK); + lua_setfield(L, -2, "config"); + /* set field `loaded' */ + luaL_findtable(L, LUA_REGISTRYINDEX, "_LOADED", 2); + lua_setfield(L, -2, "loaded"); + /* set field `preload' */ + lua_newtable(L); + lua_setfield(L, -2, "preload"); + lua_pushvalue(L, LUA_GLOBALSINDEX); + luaL_register(L, NULL, ll_funcs); /* open lib into global table */ + lua_pop(L, 1); + return 1; /* return 'package' table */ +} + diff --git a/include/lua/lobject.c b/include/lua/lobject.c new file mode 100644 index 0000000..4ff5073 --- /dev/null +++ b/include/lua/lobject.c @@ -0,0 +1,214 @@ +/* +** $Id: lobject.c,v 2.22.1.1 2007/12/27 13:02:25 roberto Exp $ +** Some generic functions over Lua objects +** See Copyright Notice in lua.h +*/ + +#include +#include +#include +#include +#include + +#define lobject_c +#define LUA_CORE + +#include "lua.h" + +#include "ldo.h" +#include "lmem.h" +#include "lobject.h" +#include "lstate.h" +#include "lstring.h" +#include "lvm.h" + + + +const TValue luaO_nilobject_ = {{NULL}, LUA_TNIL}; + + +/* +** converts an integer to a "floating point byte", represented as +** (eeeeexxx), where the real value is (1xxx) * 2^(eeeee - 1) if +** eeeee != 0 and (xxx) otherwise. +*/ +int luaO_int2fb (unsigned int x) { + int e = 0; /* expoent */ + while (x >= 16) { + x = (x+1) >> 1; + e++; + } + if (x < 8) return x; + else return ((e+1) << 3) | (cast_int(x) - 8); +} + + +/* converts back */ +int luaO_fb2int (int x) { + int e = (x >> 3) & 31; + if (e == 0) return x; + else return ((x & 7)+8) << (e - 1); +} + + +int luaO_log2 (unsigned int x) { + static const lu_byte log_2[256] = { + 0,1,2,2,3,3,3,3,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5, + 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6, + 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, + 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, + 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, + 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, + 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, + 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8 + }; + int l = -1; + while (x >= 256) { l += 8; x >>= 8; } + return l + log_2[x]; + +} + + +int luaO_rawequalObj (const TValue *t1, const TValue *t2) { + if (ttype(t1) != ttype(t2)) return 0; + else switch (ttype(t1)) { + case LUA_TNIL: + return 1; + case LUA_TNUMBER: + return luai_numeq(nvalue(t1), nvalue(t2)); + case LUA_TBOOLEAN: + return bvalue(t1) == bvalue(t2); /* boolean true must be 1 !! */ + case LUA_TLIGHTUSERDATA: + return pvalue(t1) == pvalue(t2); + default: + lua_assert(iscollectable(t1)); + return gcvalue(t1) == gcvalue(t2); + } +} + + +int luaO_str2d (const char *s, lua_Number *result) { + char *endptr; + *result = lua_str2number(s, &endptr); + if (endptr == s) return 0; /* conversion failed */ + if (*endptr == 'x' || *endptr == 'X') /* maybe an hexadecimal constant? */ + *result = cast_num(strtoul(s, &endptr, 16)); + if (*endptr == '\0') return 1; /* most common case */ + while (isspace(cast(unsigned char, *endptr))) endptr++; + if (*endptr != '\0') return 0; /* invalid trailing characters? */ + return 1; +} + + + +static void pushstr (lua_State *L, const char *str) { + setsvalue2s(L, L->top, luaS_new(L, str)); + incr_top(L); +} + + +/* this function handles only `%d', `%c', %f, %p, and `%s' formats */ +const char *luaO_pushvfstring (lua_State *L, const char *fmt, va_list argp) { + int n = 1; + pushstr(L, ""); + for (;;) { + const char *e = strchr(fmt, '%'); + if (e == NULL) break; + setsvalue2s(L, L->top, luaS_newlstr(L, fmt, e-fmt)); + incr_top(L); + switch (*(e+1)) { + case 's': { + const char *s = va_arg(argp, char *); + if (s == NULL) s = "(null)"; + pushstr(L, s); + break; + } + case 'c': { + char buff[2]; + buff[0] = cast(char, va_arg(argp, int)); + buff[1] = '\0'; + pushstr(L, buff); + break; + } + case 'd': { + setnvalue(L->top, cast_num(va_arg(argp, int))); + incr_top(L); + break; + } + case 'f': { + setnvalue(L->top, cast_num(va_arg(argp, l_uacNumber))); + incr_top(L); + break; + } + case 'p': { + char buff[4*sizeof(void *) + 8]; /* should be enough space for a `%p' */ + sprintf(buff, "%p", va_arg(argp, void *)); + pushstr(L, buff); + break; + } + case '%': { + pushstr(L, "%"); + break; + } + default: { + char buff[3]; + buff[0] = '%'; + buff[1] = *(e+1); + buff[2] = '\0'; + pushstr(L, buff); + break; + } + } + n += 2; + fmt = e+2; + } + pushstr(L, fmt); + luaV_concat(L, n+1, cast_int(L->top - L->base) - 1); + L->top -= n; + return svalue(L->top - 1); +} + + +const char *luaO_pushfstring (lua_State *L, const char *fmt, ...) { + const char *msg; + va_list argp; + va_start(argp, fmt); + msg = luaO_pushvfstring(L, fmt, argp); + va_end(argp); + return msg; +} + + +void luaO_chunkid (char *out, const char *source, size_t bufflen) { + if (*source == '=') { + strncpy(out, source+1, bufflen); /* remove first char */ + out[bufflen-1] = '\0'; /* ensures null termination */ + } + else { /* out = "source", or "...source" */ + if (*source == '@') { + size_t l; + source++; /* skip the `@' */ + bufflen -= sizeof(" '...' "); + l = strlen(source); + strcpy(out, ""); + if (l > bufflen) { + source += (l-bufflen); /* get last part of file name */ + strcat(out, "..."); + } + strcat(out, source); + } + else { /* out = [string "string"] */ + size_t len = strcspn(source, "\n\r"); /* stop at first newline */ + bufflen -= sizeof(" [string \"...\"] "); + if (len > bufflen) len = bufflen; + strcpy(out, "[string \""); + if (source[len] != '\0') { /* must truncate? */ + strncat(out, source, len); + strcat(out, "..."); + } + else + strcat(out, source); + strcat(out, "\"]"); + } + } +} diff --git a/include/lua/lobject.h b/include/lua/lobject.h new file mode 100644 index 0000000..f1e447e --- /dev/null +++ b/include/lua/lobject.h @@ -0,0 +1,381 @@ +/* +** $Id: lobject.h,v 2.20.1.2 2008/08/06 13:29:48 roberto Exp $ +** Type definitions for Lua objects +** See Copyright Notice in lua.h +*/ + + +#ifndef lobject_h +#define lobject_h + + +#include + + +#include "llimits.h" +#include "lua.h" + + +/* tags for values visible from Lua */ +#define LAST_TAG LUA_TTHREAD + +#define NUM_TAGS (LAST_TAG+1) + + +/* +** Extra tags for non-values +*/ +#define LUA_TPROTO (LAST_TAG+1) +#define LUA_TUPVAL (LAST_TAG+2) +#define LUA_TDEADKEY (LAST_TAG+3) + + +/* +** Union of all collectable objects +*/ +typedef union GCObject GCObject; + + +/* +** Common Header for all collectable objects (in macro form, to be +** included in other objects) +*/ +#define CommonHeader GCObject *next; lu_byte tt; lu_byte marked + + +/* +** Common header in struct form +*/ +typedef struct GCheader { + CommonHeader; +} GCheader; + + + + +/* +** Union of all Lua values +*/ +typedef union { + GCObject *gc; + void *p; + lua_Number n; + int b; +} Value; + + +/* +** Tagged Values +*/ + +#define TValuefields Value value; int tt + +typedef struct lua_TValue { + TValuefields; +} TValue; + + +/* Macros to test type */ +#define ttisnil(o) (ttype(o) == LUA_TNIL) +#define ttisnumber(o) (ttype(o) == LUA_TNUMBER) +#define ttisstring(o) (ttype(o) == LUA_TSTRING) +#define ttistable(o) (ttype(o) == LUA_TTABLE) +#define ttisfunction(o) (ttype(o) == LUA_TFUNCTION) +#define ttisboolean(o) (ttype(o) == LUA_TBOOLEAN) +#define ttisuserdata(o) (ttype(o) == LUA_TUSERDATA) +#define ttisthread(o) (ttype(o) == LUA_TTHREAD) +#define ttislightuserdata(o) (ttype(o) == LUA_TLIGHTUSERDATA) + +/* Macros to access values */ +#define ttype(o) ((o)->tt) +#define gcvalue(o) check_exp(iscollectable(o), (o)->value.gc) +#define pvalue(o) check_exp(ttislightuserdata(o), (o)->value.p) +#define nvalue(o) check_exp(ttisnumber(o), (o)->value.n) +#define rawtsvalue(o) check_exp(ttisstring(o), &(o)->value.gc->ts) +#define tsvalue(o) (&rawtsvalue(o)->tsv) +#define rawuvalue(o) check_exp(ttisuserdata(o), &(o)->value.gc->u) +#define uvalue(o) (&rawuvalue(o)->uv) +#define clvalue(o) check_exp(ttisfunction(o), &(o)->value.gc->cl) +#define hvalue(o) check_exp(ttistable(o), &(o)->value.gc->h) +#define bvalue(o) check_exp(ttisboolean(o), (o)->value.b) +#define thvalue(o) check_exp(ttisthread(o), &(o)->value.gc->th) + +#define l_isfalse(o) (ttisnil(o) || (ttisboolean(o) && bvalue(o) == 0)) + +/* +** for internal debug only +*/ +#define checkconsistency(obj) \ + lua_assert(!iscollectable(obj) || (ttype(obj) == (obj)->value.gc->gch.tt)) + +#define checkliveness(g,obj) \ + lua_assert(!iscollectable(obj) || \ + ((ttype(obj) == (obj)->value.gc->gch.tt) && !isdead(g, (obj)->value.gc))) + + +/* Macros to set values */ +#define setnilvalue(obj) ((obj)->tt=LUA_TNIL) + +#define setnvalue(obj,x) \ + { TValue *i_o=(obj); i_o->value.n=(x); i_o->tt=LUA_TNUMBER; } + +#define setpvalue(obj,x) \ + { TValue *i_o=(obj); i_o->value.p=(x); i_o->tt=LUA_TLIGHTUSERDATA; } + +#define setbvalue(obj,x) \ + { TValue *i_o=(obj); i_o->value.b=(x); i_o->tt=LUA_TBOOLEAN; } + +#define setsvalue(L,obj,x) \ + { TValue *i_o=(obj); \ + i_o->value.gc=cast(GCObject *, (x)); i_o->tt=LUA_TSTRING; \ + checkliveness(G(L),i_o); } + +#define setuvalue(L,obj,x) \ + { TValue *i_o=(obj); \ + i_o->value.gc=cast(GCObject *, (x)); i_o->tt=LUA_TUSERDATA; \ + checkliveness(G(L),i_o); } + +#define setthvalue(L,obj,x) \ + { TValue *i_o=(obj); \ + i_o->value.gc=cast(GCObject *, (x)); i_o->tt=LUA_TTHREAD; \ + checkliveness(G(L),i_o); } + +#define setclvalue(L,obj,x) \ + { TValue *i_o=(obj); \ + i_o->value.gc=cast(GCObject *, (x)); i_o->tt=LUA_TFUNCTION; \ + checkliveness(G(L),i_o); } + +#define sethvalue(L,obj,x) \ + { TValue *i_o=(obj); \ + i_o->value.gc=cast(GCObject *, (x)); i_o->tt=LUA_TTABLE; \ + checkliveness(G(L),i_o); } + +#define setptvalue(L,obj,x) \ + { TValue *i_o=(obj); \ + i_o->value.gc=cast(GCObject *, (x)); i_o->tt=LUA_TPROTO; \ + checkliveness(G(L),i_o); } + + + + +#define setobj(L,obj1,obj2) \ + { const TValue *o2=(obj2); TValue *o1=(obj1); \ + o1->value = o2->value; o1->tt=o2->tt; \ + checkliveness(G(L),o1); } + + +/* +** different types of sets, according to destination +*/ + +/* from stack to (same) stack */ +#define setobjs2s setobj +/* to stack (not from same stack) */ +#define setobj2s setobj +#define setsvalue2s setsvalue +#define sethvalue2s sethvalue +#define setptvalue2s setptvalue +/* from table to same table */ +#define setobjt2t setobj +/* to table */ +#define setobj2t setobj +/* to new object */ +#define setobj2n setobj +#define setsvalue2n setsvalue + +#define setttype(obj, tt) (ttype(obj) = (tt)) + + +#define iscollectable(o) (ttype(o) >= LUA_TSTRING) + + + +typedef TValue *StkId; /* index to stack elements */ + + +/* +** String headers for string table +*/ +typedef union TString { + L_Umaxalign dummy; /* ensures maximum alignment for strings */ + struct { + CommonHeader; + lu_byte reserved; + unsigned int hash; + size_t len; + } tsv; +} TString; + + +#define getstr(ts) cast(const char *, (ts) + 1) +#define svalue(o) getstr(rawtsvalue(o)) + + + +typedef union Udata { + L_Umaxalign dummy; /* ensures maximum alignment for `local' udata */ + struct { + CommonHeader; + struct Table *metatable; + struct Table *env; + size_t len; + } uv; +} Udata; + + + + +/* +** Function Prototypes +*/ +typedef struct Proto { + CommonHeader; + TValue *k; /* constants used by the function */ + Instruction *code; + struct Proto **p; /* functions defined inside the function */ + int *lineinfo; /* map from opcodes to source lines */ + struct LocVar *locvars; /* information about local variables */ + TString **upvalues; /* upvalue names */ + TString *source; + int sizeupvalues; + int sizek; /* size of `k' */ + int sizecode; + int sizelineinfo; + int sizep; /* size of `p' */ + int sizelocvars; + int linedefined; + int lastlinedefined; + GCObject *gclist; + lu_byte nups; /* number of upvalues */ + lu_byte numparams; + lu_byte is_vararg; + lu_byte maxstacksize; +} Proto; + + +/* masks for new-style vararg */ +#define VARARG_HASARG 1 +#define VARARG_ISVARARG 2 +#define VARARG_NEEDSARG 4 + + +typedef struct LocVar { + TString *varname; + int startpc; /* first point where variable is active */ + int endpc; /* first point where variable is dead */ +} LocVar; + + + +/* +** Upvalues +*/ + +typedef struct UpVal { + CommonHeader; + TValue *v; /* points to stack or to its own value */ + union { + TValue value; /* the value (when closed) */ + struct { /* double linked list (when open) */ + struct UpVal *prev; + struct UpVal *next; + } l; + } u; +} UpVal; + + +/* +** Closures +*/ + +#define ClosureHeader \ + CommonHeader; lu_byte isC; lu_byte nupvalues; GCObject *gclist; \ + struct Table *env + +typedef struct CClosure { + ClosureHeader; + lua_CFunction f; + TValue upvalue[1]; +} CClosure; + + +typedef struct LClosure { + ClosureHeader; + struct Proto *p; + UpVal *upvals[1]; +} LClosure; + + +typedef union Closure { + CClosure c; + LClosure l; +} Closure; + + +#define iscfunction(o) (ttype(o) == LUA_TFUNCTION && clvalue(o)->c.isC) +#define isLfunction(o) (ttype(o) == LUA_TFUNCTION && !clvalue(o)->c.isC) + + +/* +** Tables +*/ + +typedef union TKey { + struct { + TValuefields; + struct Node *next; /* for chaining */ + } nk; + TValue tvk; +} TKey; + + +typedef struct Node { + TValue i_val; + TKey i_key; +} Node; + + +typedef struct Table { + CommonHeader; + lu_byte flags; /* 1<

lsizenode)) + + +#define luaO_nilobject (&luaO_nilobject_) + +LUAI_DATA const TValue luaO_nilobject_; + +#define ceillog2(x) (luaO_log2((x)-1) + 1) + +LUAI_FUNC int luaO_log2 (unsigned int x); +LUAI_FUNC int luaO_int2fb (unsigned int x); +LUAI_FUNC int luaO_fb2int (int x); +LUAI_FUNC int luaO_rawequalObj (const TValue *t1, const TValue *t2); +LUAI_FUNC int luaO_str2d (const char *s, lua_Number *result); +LUAI_FUNC const char *luaO_pushvfstring (lua_State *L, const char *fmt, + va_list argp); +LUAI_FUNC const char *luaO_pushfstring (lua_State *L, const char *fmt, ...); +LUAI_FUNC void luaO_chunkid (char *out, const char *source, size_t len); + + +#endif + diff --git a/include/lua/lopcodes.c b/include/lua/lopcodes.c new file mode 100644 index 0000000..4cc7452 --- /dev/null +++ b/include/lua/lopcodes.c @@ -0,0 +1,102 @@ +/* +** $Id: lopcodes.c,v 1.37.1.1 2007/12/27 13:02:25 roberto Exp $ +** See Copyright Notice in lua.h +*/ + + +#define lopcodes_c +#define LUA_CORE + + +#include "lopcodes.h" + + +/* ORDER OP */ + +const char *const luaP_opnames[NUM_OPCODES+1] = { + "MOVE", + "LOADK", + "LOADBOOL", + "LOADNIL", + "GETUPVAL", + "GETGLOBAL", + "GETTABLE", + "SETGLOBAL", + "SETUPVAL", + "SETTABLE", + "NEWTABLE", + "SELF", + "ADD", + "SUB", + "MUL", + "DIV", + "MOD", + "POW", + "UNM", + "NOT", + "LEN", + "CONCAT", + "JMP", + "EQ", + "LT", + "LE", + "TEST", + "TESTSET", + "CALL", + "TAILCALL", + "RETURN", + "FORLOOP", + "FORPREP", + "TFORLOOP", + "SETLIST", + "CLOSE", + "CLOSURE", + "VARARG", + NULL +}; + + +#define opmode(t,a,b,c,m) (((t)<<7) | ((a)<<6) | ((b)<<4) | ((c)<<2) | (m)) + +const lu_byte luaP_opmodes[NUM_OPCODES] = { +/* T A B C mode opcode */ + opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_MOVE */ + ,opmode(0, 1, OpArgK, OpArgN, iABx) /* OP_LOADK */ + ,opmode(0, 1, OpArgU, OpArgU, iABC) /* OP_LOADBOOL */ + ,opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_LOADNIL */ + ,opmode(0, 1, OpArgU, OpArgN, iABC) /* OP_GETUPVAL */ + ,opmode(0, 1, OpArgK, OpArgN, iABx) /* OP_GETGLOBAL */ + ,opmode(0, 1, OpArgR, OpArgK, iABC) /* OP_GETTABLE */ + ,opmode(0, 0, OpArgK, OpArgN, iABx) /* OP_SETGLOBAL */ + ,opmode(0, 0, OpArgU, OpArgN, iABC) /* OP_SETUPVAL */ + ,opmode(0, 0, OpArgK, OpArgK, iABC) /* OP_SETTABLE */ + ,opmode(0, 1, OpArgU, OpArgU, iABC) /* OP_NEWTABLE */ + ,opmode(0, 1, OpArgR, OpArgK, iABC) /* OP_SELF */ + ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_ADD */ + ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_SUB */ + ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_MUL */ + ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_DIV */ + ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_MOD */ + ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_POW */ + ,opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_UNM */ + ,opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_NOT */ + ,opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_LEN */ + ,opmode(0, 1, OpArgR, OpArgR, iABC) /* OP_CONCAT */ + ,opmode(0, 0, OpArgR, OpArgN, iAsBx) /* OP_JMP */ + ,opmode(1, 0, OpArgK, OpArgK, iABC) /* OP_EQ */ + ,opmode(1, 0, OpArgK, OpArgK, iABC) /* OP_LT */ + ,opmode(1, 0, OpArgK, OpArgK, iABC) /* OP_LE */ + ,opmode(1, 1, OpArgR, OpArgU, iABC) /* OP_TEST */ + ,opmode(1, 1, OpArgR, OpArgU, iABC) /* OP_TESTSET */ + ,opmode(0, 1, OpArgU, OpArgU, iABC) /* OP_CALL */ + ,opmode(0, 1, OpArgU, OpArgU, iABC) /* OP_TAILCALL */ + ,opmode(0, 0, OpArgU, OpArgN, iABC) /* OP_RETURN */ + ,opmode(0, 1, OpArgR, OpArgN, iAsBx) /* OP_FORLOOP */ + ,opmode(0, 1, OpArgR, OpArgN, iAsBx) /* OP_FORPREP */ + ,opmode(1, 0, OpArgN, OpArgU, iABC) /* OP_TFORLOOP */ + ,opmode(0, 0, OpArgU, OpArgU, iABC) /* OP_SETLIST */ + ,opmode(0, 0, OpArgN, OpArgN, iABC) /* OP_CLOSE */ + ,opmode(0, 1, OpArgU, OpArgN, iABx) /* OP_CLOSURE */ + ,opmode(0, 1, OpArgU, OpArgN, iABC) /* OP_VARARG */ +}; + diff --git a/include/lua/lopcodes.h b/include/lua/lopcodes.h new file mode 100644 index 0000000..41224d6 --- /dev/null +++ b/include/lua/lopcodes.h @@ -0,0 +1,268 @@ +/* +** $Id: lopcodes.h,v 1.125.1.1 2007/12/27 13:02:25 roberto Exp $ +** Opcodes for Lua virtual machine +** See Copyright Notice in lua.h +*/ + +#ifndef lopcodes_h +#define lopcodes_h + +#include "llimits.h" + + +/*=========================================================================== + We assume that instructions are unsigned numbers. + All instructions have an opcode in the first 6 bits. + Instructions can have the following fields: + `A' : 8 bits + `B' : 9 bits + `C' : 9 bits + `Bx' : 18 bits (`B' and `C' together) + `sBx' : signed Bx + + A signed argument is represented in excess K; that is, the number + value is the unsigned value minus K. K is exactly the maximum value + for that argument (so that -max is represented by 0, and +max is + represented by 2*max), which is half the maximum for the corresponding + unsigned argument. +===========================================================================*/ + + +enum OpMode {iABC, iABx, iAsBx}; /* basic instruction format */ + + +/* +** size and position of opcode arguments. +*/ +#define SIZE_C 9 +#define SIZE_B 9 +#define SIZE_Bx (SIZE_C + SIZE_B) +#define SIZE_A 8 + +#define SIZE_OP 6 + +#define POS_OP 0 +#define POS_A (POS_OP + SIZE_OP) +#define POS_C (POS_A + SIZE_A) +#define POS_B (POS_C + SIZE_C) +#define POS_Bx POS_C + + +/* +** limits for opcode arguments. +** we use (signed) int to manipulate most arguments, +** so they must fit in LUAI_BITSINT-1 bits (-1 for sign) +*/ +#if SIZE_Bx < LUAI_BITSINT-1 +#define MAXARG_Bx ((1<>1) /* `sBx' is signed */ +#else +#define MAXARG_Bx MAX_INT +#define MAXARG_sBx MAX_INT +#endif + + +#define MAXARG_A ((1<>POS_OP) & MASK1(SIZE_OP,0))) +#define SET_OPCODE(i,o) ((i) = (((i)&MASK0(SIZE_OP,POS_OP)) | \ + ((cast(Instruction, o)<>POS_A) & MASK1(SIZE_A,0))) +#define SETARG_A(i,u) ((i) = (((i)&MASK0(SIZE_A,POS_A)) | \ + ((cast(Instruction, u)<>POS_B) & MASK1(SIZE_B,0))) +#define SETARG_B(i,b) ((i) = (((i)&MASK0(SIZE_B,POS_B)) | \ + ((cast(Instruction, b)<>POS_C) & MASK1(SIZE_C,0))) +#define SETARG_C(i,b) ((i) = (((i)&MASK0(SIZE_C,POS_C)) | \ + ((cast(Instruction, b)<>POS_Bx) & MASK1(SIZE_Bx,0))) +#define SETARG_Bx(i,b) ((i) = (((i)&MASK0(SIZE_Bx,POS_Bx)) | \ + ((cast(Instruction, b)< C) then pc++ */ +OP_TESTSET,/* A B C if (R(B) <=> C) then R(A) := R(B) else pc++ */ + +OP_CALL,/* A B C R(A), ... ,R(A+C-2) := R(A)(R(A+1), ... ,R(A+B-1)) */ +OP_TAILCALL,/* A B C return R(A)(R(A+1), ... ,R(A+B-1)) */ +OP_RETURN,/* A B return R(A), ... ,R(A+B-2) (see note) */ + +OP_FORLOOP,/* A sBx R(A)+=R(A+2); + if R(A) =) R(A)*/ +OP_CLOSURE,/* A Bx R(A) := closure(KPROTO[Bx], R(A), ... ,R(A+n)) */ + +OP_VARARG/* A B R(A), R(A+1), ..., R(A+B-1) = vararg */ +} OpCode; + + +#define NUM_OPCODES (cast(int, OP_VARARG) + 1) + + + +/*=========================================================================== + Notes: + (*) In OP_CALL, if (B == 0) then B = top. C is the number of returns - 1, + and can be 0: OP_CALL then sets `top' to last_result+1, so + next open instruction (OP_CALL, OP_RETURN, OP_SETLIST) may use `top'. + + (*) In OP_VARARG, if (B == 0) then use actual number of varargs and + set top (like in OP_CALL with C == 0). + + (*) In OP_RETURN, if (B == 0) then return up to `top' + + (*) In OP_SETLIST, if (B == 0) then B = `top'; + if (C == 0) then next `instruction' is real C + + (*) For comparisons, A specifies what condition the test should accept + (true or false). + + (*) All `skips' (pc++) assume that next instruction is a jump +===========================================================================*/ + + +/* +** masks for instruction properties. The format is: +** bits 0-1: op mode +** bits 2-3: C arg mode +** bits 4-5: B arg mode +** bit 6: instruction set register A +** bit 7: operator is a test +*/ + +enum OpArgMask { + OpArgN, /* argument is not used */ + OpArgU, /* argument is used */ + OpArgR, /* argument is a register or a jump offset */ + OpArgK /* argument is a constant or register/constant */ +}; + +LUAI_DATA const lu_byte luaP_opmodes[NUM_OPCODES]; + +#define getOpMode(m) (cast(enum OpMode, luaP_opmodes[m] & 3)) +#define getBMode(m) (cast(enum OpArgMask, (luaP_opmodes[m] >> 4) & 3)) +#define getCMode(m) (cast(enum OpArgMask, (luaP_opmodes[m] >> 2) & 3)) +#define testAMode(m) (luaP_opmodes[m] & (1 << 6)) +#define testTMode(m) (luaP_opmodes[m] & (1 << 7)) + + +LUAI_DATA const char *const luaP_opnames[NUM_OPCODES+1]; /* opcode names */ + + +/* number of list items to accumulate before a SETLIST instruction */ +#define LFIELDS_PER_FLUSH 50 + + +#endif diff --git a/include/lua/loslib.c b/include/lua/loslib.c new file mode 100644 index 0000000..da06a57 --- /dev/null +++ b/include/lua/loslib.c @@ -0,0 +1,243 @@ +/* +** $Id: loslib.c,v 1.19.1.3 2008/01/18 16:38:18 roberto Exp $ +** Standard Operating System library +** See Copyright Notice in lua.h +*/ + + +#include +#include +#include +#include +#include + +#define loslib_c +#define LUA_LIB + +#include "lua.h" + +#include "lauxlib.h" +#include "lualib.h" + + +static int os_pushresult (lua_State *L, int i, const char *filename) { + int en = errno; /* calls to Lua API may change this value */ + if (i) { + lua_pushboolean(L, 1); + return 1; + } + else { + lua_pushnil(L); + lua_pushfstring(L, "%s: %s", filename, strerror(en)); + lua_pushinteger(L, en); + return 3; + } +} + + +static int os_execute (lua_State *L) { + lua_pushinteger(L, system(luaL_optstring(L, 1, NULL))); + return 1; +} + + +static int os_remove (lua_State *L) { + const char *filename = luaL_checkstring(L, 1); + return os_pushresult(L, remove(filename) == 0, filename); +} + + +static int os_rename (lua_State *L) { + const char *fromname = luaL_checkstring(L, 1); + const char *toname = luaL_checkstring(L, 2); + return os_pushresult(L, rename(fromname, toname) == 0, fromname); +} + + +static int os_tmpname (lua_State *L) { + char buff[LUA_TMPNAMBUFSIZE]; + int err; + lua_tmpnam(buff, err); + if (err) + return luaL_error(L, "unable to generate a unique filename"); + lua_pushstring(L, buff); + return 1; +} + + +static int os_getenv (lua_State *L) { + lua_pushstring(L, getenv(luaL_checkstring(L, 1))); /* if NULL push nil */ + return 1; +} + + +static int os_clock (lua_State *L) { + lua_pushnumber(L, ((lua_Number)clock())/(lua_Number)CLOCKS_PER_SEC); + return 1; +} + + +/* +** {====================================================== +** Time/Date operations +** { year=%Y, month=%m, day=%d, hour=%H, min=%M, sec=%S, +** wday=%w+1, yday=%j, isdst=? } +** ======================================================= +*/ + +static void setfield (lua_State *L, const char *key, int value) { + lua_pushinteger(L, value); + lua_setfield(L, -2, key); +} + +static void setboolfield (lua_State *L, const char *key, int value) { + if (value < 0) /* undefined? */ + return; /* does not set field */ + lua_pushboolean(L, value); + lua_setfield(L, -2, key); +} + +static int getboolfield (lua_State *L, const char *key) { + int res; + lua_getfield(L, -1, key); + res = lua_isnil(L, -1) ? -1 : lua_toboolean(L, -1); + lua_pop(L, 1); + return res; +} + + +static int getfield (lua_State *L, const char *key, int d) { + int res; + lua_getfield(L, -1, key); + if (lua_isnumber(L, -1)) + res = (int)lua_tointeger(L, -1); + else { + if (d < 0) + return luaL_error(L, "field " LUA_QS " missing in date table", key); + res = d; + } + lua_pop(L, 1); + return res; +} + + +static int os_date (lua_State *L) { + const char *s = luaL_optstring(L, 1, "%c"); + time_t t = luaL_opt(L, (time_t)luaL_checknumber, 2, time(NULL)); + struct tm *stm; + if (*s == '!') { /* UTC? */ + stm = gmtime(&t); + s++; /* skip `!' */ + } + else + stm = localtime(&t); + if (stm == NULL) /* invalid date? */ + lua_pushnil(L); + else if (strcmp(s, "*t") == 0) { + lua_createtable(L, 0, 9); /* 9 = number of fields */ + setfield(L, "sec", stm->tm_sec); + setfield(L, "min", stm->tm_min); + setfield(L, "hour", stm->tm_hour); + setfield(L, "day", stm->tm_mday); + setfield(L, "month", stm->tm_mon+1); + setfield(L, "year", stm->tm_year+1900); + setfield(L, "wday", stm->tm_wday+1); + setfield(L, "yday", stm->tm_yday+1); + setboolfield(L, "isdst", stm->tm_isdst); + } + else { + char cc[3]; + luaL_Buffer b; + cc[0] = '%'; cc[2] = '\0'; + luaL_buffinit(L, &b); + for (; *s; s++) { + if (*s != '%' || *(s + 1) == '\0') /* no conversion specifier? */ + luaL_addchar(&b, *s); + else { + size_t reslen; + char buff[200]; /* should be big enough for any conversion result */ + cc[1] = *(++s); + reslen = strftime(buff, sizeof(buff), cc, stm); + luaL_addlstring(&b, buff, reslen); + } + } + luaL_pushresult(&b); + } + return 1; +} + + +static int os_time (lua_State *L) { + time_t t; + if (lua_isnoneornil(L, 1)) /* called without args? */ + t = time(NULL); /* get current time */ + else { + struct tm ts; + luaL_checktype(L, 1, LUA_TTABLE); + lua_settop(L, 1); /* make sure table is at the top */ + ts.tm_sec = getfield(L, "sec", 0); + ts.tm_min = getfield(L, "min", 0); + ts.tm_hour = getfield(L, "hour", 12); + ts.tm_mday = getfield(L, "day", -1); + ts.tm_mon = getfield(L, "month", -1) - 1; + ts.tm_year = getfield(L, "year", -1) - 1900; + ts.tm_isdst = getboolfield(L, "isdst"); + t = mktime(&ts); + } + if (t == (time_t)(-1)) + lua_pushnil(L); + else + lua_pushnumber(L, (lua_Number)t); + return 1; +} + + +static int os_difftime (lua_State *L) { + lua_pushnumber(L, difftime((time_t)(luaL_checknumber(L, 1)), + (time_t)(luaL_optnumber(L, 2, 0)))); + return 1; +} + +/* }====================================================== */ + + +static int os_setlocale (lua_State *L) { + static const int cat[] = {LC_ALL, LC_COLLATE, LC_CTYPE, LC_MONETARY, + LC_NUMERIC, LC_TIME}; + static const char *const catnames[] = {"all", "collate", "ctype", "monetary", + "numeric", "time", NULL}; + const char *l = luaL_optstring(L, 1, NULL); + int op = luaL_checkoption(L, 2, "all", catnames); + lua_pushstring(L, setlocale(cat[op], l)); + return 1; +} + + +static int os_exit (lua_State *L) { + exit(luaL_optint(L, 1, EXIT_SUCCESS)); +} + +static const luaL_Reg syslib[] = { + {"clock", os_clock}, + {"date", os_date}, + {"difftime", os_difftime}, + {"execute", os_execute}, + {"exit", os_exit}, + {"getenv", os_getenv}, + {"remove", os_remove}, + {"rename", os_rename}, + {"setlocale", os_setlocale}, + {"time", os_time}, + {"tmpname", os_tmpname}, + {NULL, NULL} +}; + +/* }====================================================== */ + + + +LUALIB_API int luaopen_os (lua_State *L) { + luaL_register(L, LUA_OSLIBNAME, syslib); + return 1; +} + diff --git a/include/lua/lparser.c b/include/lua/lparser.c new file mode 100644 index 0000000..1e2a9a8 --- /dev/null +++ b/include/lua/lparser.c @@ -0,0 +1,1339 @@ +/* +** $Id: lparser.c,v 2.42.1.3 2007/12/28 15:32:23 roberto Exp $ +** Lua Parser +** See Copyright Notice in lua.h +*/ + + +#include + +#define lparser_c +#define LUA_CORE + +#include "lua.h" + +#include "lcode.h" +#include "ldebug.h" +#include "ldo.h" +#include "lfunc.h" +#include "llex.h" +#include "lmem.h" +#include "lobject.h" +#include "lopcodes.h" +#include "lparser.h" +#include "lstate.h" +#include "lstring.h" +#include "ltable.h" + + + +#define hasmultret(k) ((k) == VCALL || (k) == VVARARG) + +#define getlocvar(fs, i) ((fs)->f->locvars[(fs)->actvar[i]]) + +#define luaY_checklimit(fs,v,l,m) if ((v)>(l)) errorlimit(fs,l,m) + + +/* +** nodes for block list (list of active blocks) +*/ +typedef struct BlockCnt { + struct BlockCnt *previous; /* chain */ + int breaklist; /* list of jumps out of this loop */ + lu_byte nactvar; /* # active locals outside the breakable structure */ + lu_byte upval; /* true if some variable in the block is an upvalue */ + lu_byte isbreakable; /* true if `block' is a loop */ +} BlockCnt; + + + +/* +** prototypes for recursive non-terminal functions +*/ +static void chunk (LexState *ls); +static void expr (LexState *ls, expdesc *v); + + +static void anchor_token (LexState *ls) { + if (ls->t.token == TK_NAME || ls->t.token == TK_STRING) { + TString *ts = ls->t.seminfo.ts; + luaX_newstring(ls, getstr(ts), ts->tsv.len); + } +} + + +static void error_expected (LexState *ls, int token) { + luaX_syntaxerror(ls, + luaO_pushfstring(ls->L, LUA_QS " expected", luaX_token2str(ls, token))); +} + + +static void errorlimit (FuncState *fs, int limit, const char *what) { + const char *msg = (fs->f->linedefined == 0) ? + luaO_pushfstring(fs->L, "main function has more than %d %s", limit, what) : + luaO_pushfstring(fs->L, "function at line %d has more than %d %s", + fs->f->linedefined, limit, what); + luaX_lexerror(fs->ls, msg, 0); +} + + +static int testnext (LexState *ls, int c) { + if (ls->t.token == c) { + luaX_next(ls); + return 1; + } + else return 0; +} + + +static void check (LexState *ls, int c) { + if (ls->t.token != c) + error_expected(ls, c); +} + +static void checknext (LexState *ls, int c) { + check(ls, c); + luaX_next(ls); +} + + +#define check_condition(ls,c,msg) { if (!(c)) luaX_syntaxerror(ls, msg); } + + + +static void check_match (LexState *ls, int what, int who, int where) { + if (!testnext(ls, what)) { + if (where == ls->linenumber) + error_expected(ls, what); + else { + luaX_syntaxerror(ls, luaO_pushfstring(ls->L, + LUA_QS " expected (to close " LUA_QS " at line %d)", + luaX_token2str(ls, what), luaX_token2str(ls, who), where)); + } + } +} + + +static TString *str_checkname (LexState *ls) { + TString *ts; + check(ls, TK_NAME); + ts = ls->t.seminfo.ts; + luaX_next(ls); + return ts; +} + + +static void init_exp (expdesc *e, expkind k, int i) { + e->f = e->t = NO_JUMP; + e->k = k; + e->u.s.info = i; +} + + +static void codestring (LexState *ls, expdesc *e, TString *s) { + init_exp(e, VK, luaK_stringK(ls->fs, s)); +} + + +static void checkname(LexState *ls, expdesc *e) { + codestring(ls, e, str_checkname(ls)); +} + + +static int registerlocalvar (LexState *ls, TString *varname) { + FuncState *fs = ls->fs; + Proto *f = fs->f; + int oldsize = f->sizelocvars; + luaM_growvector(ls->L, f->locvars, fs->nlocvars, f->sizelocvars, + LocVar, SHRT_MAX, "too many local variables"); + while (oldsize < f->sizelocvars) f->locvars[oldsize++].varname = NULL; + f->locvars[fs->nlocvars].varname = varname; + luaC_objbarrier(ls->L, f, varname); + return fs->nlocvars++; +} + + +#define new_localvarliteral(ls,v,n) \ + new_localvar(ls, luaX_newstring(ls, "" v, (sizeof(v)/sizeof(char))-1), n) + + +static void new_localvar (LexState *ls, TString *name, int n) { + FuncState *fs = ls->fs; + luaY_checklimit(fs, fs->nactvar+n+1, LUAI_MAXVARS, "local variables"); + fs->actvar[fs->nactvar+n] = cast(unsigned short, registerlocalvar(ls, name)); +} + + +static void adjustlocalvars (LexState *ls, int nvars) { + FuncState *fs = ls->fs; + fs->nactvar = cast_byte(fs->nactvar + nvars); + for (; nvars; nvars--) { + getlocvar(fs, fs->nactvar - nvars).startpc = fs->pc; + } +} + + +static void removevars (LexState *ls, int tolevel) { + FuncState *fs = ls->fs; + while (fs->nactvar > tolevel) + getlocvar(fs, --fs->nactvar).endpc = fs->pc; +} + + +static int indexupvalue (FuncState *fs, TString *name, expdesc *v) { + int i; + Proto *f = fs->f; + int oldsize = f->sizeupvalues; + for (i=0; inups; i++) { + if (fs->upvalues[i].k == v->k && fs->upvalues[i].info == v->u.s.info) { + lua_assert(f->upvalues[i] == name); + return i; + } + } + /* new one */ + luaY_checklimit(fs, f->nups + 1, LUAI_MAXUPVALUES, "upvalues"); + luaM_growvector(fs->L, f->upvalues, f->nups, f->sizeupvalues, + TString *, MAX_INT, ""); + while (oldsize < f->sizeupvalues) f->upvalues[oldsize++] = NULL; + f->upvalues[f->nups] = name; + luaC_objbarrier(fs->L, f, name); + lua_assert(v->k == VLOCAL || v->k == VUPVAL); + fs->upvalues[f->nups].k = cast_byte(v->k); + fs->upvalues[f->nups].info = cast_byte(v->u.s.info); + return f->nups++; +} + + +static int searchvar (FuncState *fs, TString *n) { + int i; + for (i=fs->nactvar-1; i >= 0; i--) { + if (n == getlocvar(fs, i).varname) + return i; + } + return -1; /* not found */ +} + + +static void markupval (FuncState *fs, int level) { + BlockCnt *bl = fs->bl; + while (bl && bl->nactvar > level) bl = bl->previous; + if (bl) bl->upval = 1; +} + + +static int singlevaraux (FuncState *fs, TString *n, expdesc *var, int base) { + if (fs == NULL) { /* no more levels? */ + init_exp(var, VGLOBAL, NO_REG); /* default is global variable */ + return VGLOBAL; + } + else { + int v = searchvar(fs, n); /* look up at current level */ + if (v >= 0) { + init_exp(var, VLOCAL, v); + if (!base) + markupval(fs, v); /* local will be used as an upval */ + return VLOCAL; + } + else { /* not found at current level; try upper one */ + if (singlevaraux(fs->prev, n, var, 0) == VGLOBAL) + return VGLOBAL; + var->u.s.info = indexupvalue(fs, n, var); /* else was LOCAL or UPVAL */ + var->k = VUPVAL; /* upvalue in this level */ + return VUPVAL; + } + } +} + + +static void singlevar (LexState *ls, expdesc *var) { + TString *varname = str_checkname(ls); + FuncState *fs = ls->fs; + if (singlevaraux(fs, varname, var, 1) == VGLOBAL) + var->u.s.info = luaK_stringK(fs, varname); /* info points to global name */ +} + + +static void adjust_assign (LexState *ls, int nvars, int nexps, expdesc *e) { + FuncState *fs = ls->fs; + int extra = nvars - nexps; + if (hasmultret(e->k)) { + extra++; /* includes call itself */ + if (extra < 0) extra = 0; + luaK_setreturns(fs, e, extra); /* last exp. provides the difference */ + if (extra > 1) luaK_reserveregs(fs, extra-1); + } + else { + if (e->k != VVOID) luaK_exp2nextreg(fs, e); /* close last expression */ + if (extra > 0) { + int reg = fs->freereg; + luaK_reserveregs(fs, extra); + luaK_nil(fs, reg, extra); + } + } +} + + +static void enterlevel (LexState *ls) { + if (++ls->L->nCcalls > LUAI_MAXCCALLS) + luaX_lexerror(ls, "chunk has too many syntax levels", 0); +} + + +#define leavelevel(ls) ((ls)->L->nCcalls--) + + +static void enterblock (FuncState *fs, BlockCnt *bl, lu_byte isbreakable) { + bl->breaklist = NO_JUMP; + bl->isbreakable = isbreakable; + bl->nactvar = fs->nactvar; + bl->upval = 0; + bl->previous = fs->bl; + fs->bl = bl; + lua_assert(fs->freereg == fs->nactvar); +} + + +static void leaveblock (FuncState *fs) { + BlockCnt *bl = fs->bl; + fs->bl = bl->previous; + removevars(fs->ls, bl->nactvar); + if (bl->upval) + luaK_codeABC(fs, OP_CLOSE, bl->nactvar, 0, 0); + /* a block either controls scope or breaks (never both) */ + lua_assert(!bl->isbreakable || !bl->upval); + lua_assert(bl->nactvar == fs->nactvar); + fs->freereg = fs->nactvar; /* free registers */ + luaK_patchtohere(fs, bl->breaklist); +} + + +static void pushclosure (LexState *ls, FuncState *func, expdesc *v) { + FuncState *fs = ls->fs; + Proto *f = fs->f; + int oldsize = f->sizep; + int i; + luaM_growvector(ls->L, f->p, fs->np, f->sizep, Proto *, + MAXARG_Bx, "constant table overflow"); + while (oldsize < f->sizep) f->p[oldsize++] = NULL; + f->p[fs->np++] = func->f; + luaC_objbarrier(ls->L, f, func->f); + init_exp(v, VRELOCABLE, luaK_codeABx(fs, OP_CLOSURE, 0, fs->np-1)); + for (i=0; if->nups; i++) { + OpCode o = (func->upvalues[i].k == VLOCAL) ? OP_MOVE : OP_GETUPVAL; + luaK_codeABC(fs, o, 0, func->upvalues[i].info, 0); + } +} + + +static void open_func (LexState *ls, FuncState *fs) { + lua_State *L = ls->L; + Proto *f = luaF_newproto(L); + fs->f = f; + fs->prev = ls->fs; /* linked list of funcstates */ + fs->ls = ls; + fs->L = L; + ls->fs = fs; + fs->pc = 0; + fs->lasttarget = -1; + fs->jpc = NO_JUMP; + fs->freereg = 0; + fs->nk = 0; + fs->np = 0; + fs->nlocvars = 0; + fs->nactvar = 0; + fs->bl = NULL; + f->source = ls->source; + f->maxstacksize = 2; /* registers 0/1 are always valid */ + fs->h = luaH_new(L, 0, 0); + /* anchor table of constants and prototype (to avoid being collected) */ + sethvalue2s(L, L->top, fs->h); + incr_top(L); + setptvalue2s(L, L->top, f); + incr_top(L); +} + + +static void close_func (LexState *ls) { + lua_State *L = ls->L; + FuncState *fs = ls->fs; + Proto *f = fs->f; + removevars(ls, 0); + luaK_ret(fs, 0, 0); /* final return */ + luaM_reallocvector(L, f->code, f->sizecode, fs->pc, Instruction); + f->sizecode = fs->pc; + luaM_reallocvector(L, f->lineinfo, f->sizelineinfo, fs->pc, int); + f->sizelineinfo = fs->pc; + luaM_reallocvector(L, f->k, f->sizek, fs->nk, TValue); + f->sizek = fs->nk; + luaM_reallocvector(L, f->p, f->sizep, fs->np, Proto *); + f->sizep = fs->np; + luaM_reallocvector(L, f->locvars, f->sizelocvars, fs->nlocvars, LocVar); + f->sizelocvars = fs->nlocvars; + luaM_reallocvector(L, f->upvalues, f->sizeupvalues, f->nups, TString *); + f->sizeupvalues = f->nups; + lua_assert(luaG_checkcode(f)); + lua_assert(fs->bl == NULL); + ls->fs = fs->prev; + L->top -= 2; /* remove table and prototype from the stack */ + /* last token read was anchored in defunct function; must reanchor it */ + if (fs) anchor_token(ls); +} + + +Proto *luaY_parser (lua_State *L, ZIO *z, Mbuffer *buff, const char *name) { + struct LexState lexstate; + struct FuncState funcstate; + lexstate.buff = buff; + luaX_setinput(L, &lexstate, z, luaS_new(L, name)); + open_func(&lexstate, &funcstate); + funcstate.f->is_vararg = VARARG_ISVARARG; /* main func. is always vararg */ + luaX_next(&lexstate); /* read first token */ + chunk(&lexstate); + check(&lexstate, TK_EOS); + close_func(&lexstate); + lua_assert(funcstate.prev == NULL); + lua_assert(funcstate.f->nups == 0); + lua_assert(lexstate.fs == NULL); + return funcstate.f; +} + + + +/*============================================================*/ +/* GRAMMAR RULES */ +/*============================================================*/ + + +static void field (LexState *ls, expdesc *v) { + /* field -> ['.' | ':'] NAME */ + FuncState *fs = ls->fs; + expdesc key; + luaK_exp2anyreg(fs, v); + luaX_next(ls); /* skip the dot or colon */ + checkname(ls, &key); + luaK_indexed(fs, v, &key); +} + + +static void yindex (LexState *ls, expdesc *v) { + /* index -> '[' expr ']' */ + luaX_next(ls); /* skip the '[' */ + expr(ls, v); + luaK_exp2val(ls->fs, v); + checknext(ls, ']'); +} + + +/* +** {====================================================================== +** Rules for Constructors +** ======================================================================= +*/ + + +struct ConsControl { + expdesc v; /* last list item read */ + expdesc *t; /* table descriptor */ + int nh; /* total number of `record' elements */ + int na; /* total number of array elements */ + int tostore; /* number of array elements pending to be stored */ +}; + + +static void recfield (LexState *ls, struct ConsControl *cc) { + /* recfield -> (NAME | `['exp1`]') = exp1 */ + FuncState *fs = ls->fs; + int reg = ls->fs->freereg; + expdesc key, val; + int rkkey; + if (ls->t.token == TK_NAME) { + luaY_checklimit(fs, cc->nh, MAX_INT, "items in a constructor"); + checkname(ls, &key); + } + else /* ls->t.token == '[' */ + yindex(ls, &key); + cc->nh++; + checknext(ls, '='); + rkkey = luaK_exp2RK(fs, &key); + expr(ls, &val); + luaK_codeABC(fs, OP_SETTABLE, cc->t->u.s.info, rkkey, luaK_exp2RK(fs, &val)); + fs->freereg = reg; /* free registers */ +} + + +static void closelistfield (FuncState *fs, struct ConsControl *cc) { + if (cc->v.k == VVOID) return; /* there is no list item */ + luaK_exp2nextreg(fs, &cc->v); + cc->v.k = VVOID; + if (cc->tostore == LFIELDS_PER_FLUSH) { + luaK_setlist(fs, cc->t->u.s.info, cc->na, cc->tostore); /* flush */ + cc->tostore = 0; /* no more items pending */ + } +} + + +static void lastlistfield (FuncState *fs, struct ConsControl *cc) { + if (cc->tostore == 0) return; + if (hasmultret(cc->v.k)) { + luaK_setmultret(fs, &cc->v); + luaK_setlist(fs, cc->t->u.s.info, cc->na, LUA_MULTRET); + cc->na--; /* do not count last expression (unknown number of elements) */ + } + else { + if (cc->v.k != VVOID) + luaK_exp2nextreg(fs, &cc->v); + luaK_setlist(fs, cc->t->u.s.info, cc->na, cc->tostore); + } +} + + +static void listfield (LexState *ls, struct ConsControl *cc) { + expr(ls, &cc->v); + luaY_checklimit(ls->fs, cc->na, MAX_INT, "items in a constructor"); + cc->na++; + cc->tostore++; +} + + +static void constructor (LexState *ls, expdesc *t) { + /* constructor -> ?? */ + FuncState *fs = ls->fs; + int line = ls->linenumber; + int pc = luaK_codeABC(fs, OP_NEWTABLE, 0, 0, 0); + struct ConsControl cc; + cc.na = cc.nh = cc.tostore = 0; + cc.t = t; + init_exp(t, VRELOCABLE, pc); + init_exp(&cc.v, VVOID, 0); /* no value (yet) */ + luaK_exp2nextreg(ls->fs, t); /* fix it at stack top (for gc) */ + checknext(ls, '{'); + do { + lua_assert(cc.v.k == VVOID || cc.tostore > 0); + if (ls->t.token == '}') break; + closelistfield(fs, &cc); + switch(ls->t.token) { + case TK_NAME: { /* may be listfields or recfields */ + luaX_lookahead(ls); + if (ls->lookahead.token != '=') /* expression? */ + listfield(ls, &cc); + else + recfield(ls, &cc); + break; + } + case '[': { /* constructor_item -> recfield */ + recfield(ls, &cc); + break; + } + default: { /* constructor_part -> listfield */ + listfield(ls, &cc); + break; + } + } + } while (testnext(ls, ',') || testnext(ls, ';')); + check_match(ls, '}', '{', line); + lastlistfield(fs, &cc); + SETARG_B(fs->f->code[pc], luaO_int2fb(cc.na)); /* set initial array size */ + SETARG_C(fs->f->code[pc], luaO_int2fb(cc.nh)); /* set initial table size */ +} + +/* }====================================================================== */ + + + +static void parlist (LexState *ls) { + /* parlist -> [ param { `,' param } ] */ + FuncState *fs = ls->fs; + Proto *f = fs->f; + int nparams = 0; + f->is_vararg = 0; + if (ls->t.token != ')') { /* is `parlist' not empty? */ + do { + switch (ls->t.token) { + case TK_NAME: { /* param -> NAME */ + new_localvar(ls, str_checkname(ls), nparams++); + break; + } + case TK_DOTS: { /* param -> `...' */ + luaX_next(ls); +#if defined(LUA_COMPAT_VARARG) + /* use `arg' as default name */ + new_localvarliteral(ls, "arg", nparams++); + f->is_vararg = VARARG_HASARG | VARARG_NEEDSARG; +#endif + f->is_vararg |= VARARG_ISVARARG; + break; + } + default: luaX_syntaxerror(ls, " or " LUA_QL("...") " expected"); + } + } while (!f->is_vararg && testnext(ls, ',')); + } + adjustlocalvars(ls, nparams); + f->numparams = cast_byte(fs->nactvar - (f->is_vararg & VARARG_HASARG)); + luaK_reserveregs(fs, fs->nactvar); /* reserve register for parameters */ +} + + +static void body (LexState *ls, expdesc *e, int needself, int line) { + /* body -> `(' parlist `)' chunk END */ + FuncState new_fs; + open_func(ls, &new_fs); + new_fs.f->linedefined = line; + checknext(ls, '('); + if (needself) { + new_localvarliteral(ls, "self", 0); + adjustlocalvars(ls, 1); + } + parlist(ls); + checknext(ls, ')'); + chunk(ls); + new_fs.f->lastlinedefined = ls->linenumber; + check_match(ls, TK_END, TK_FUNCTION, line); + close_func(ls); + pushclosure(ls, &new_fs, e); +} + + +static int explist1 (LexState *ls, expdesc *v) { + /* explist1 -> expr { `,' expr } */ + int n = 1; /* at least one expression */ + expr(ls, v); + while (testnext(ls, ',')) { + luaK_exp2nextreg(ls->fs, v); + expr(ls, v); + n++; + } + return n; +} + + +static void funcargs (LexState *ls, expdesc *f) { + FuncState *fs = ls->fs; + expdesc args; + int base, nparams; + int line = ls->linenumber; + switch (ls->t.token) { + case '(': { /* funcargs -> `(' [ explist1 ] `)' */ + if (line != ls->lastline) + luaX_syntaxerror(ls,"ambiguous syntax (function call x new statement)"); + luaX_next(ls); + if (ls->t.token == ')') /* arg list is empty? */ + args.k = VVOID; + else { + explist1(ls, &args); + luaK_setmultret(fs, &args); + } + check_match(ls, ')', '(', line); + break; + } + case '{': { /* funcargs -> constructor */ + constructor(ls, &args); + break; + } + case TK_STRING: { /* funcargs -> STRING */ + codestring(ls, &args, ls->t.seminfo.ts); + luaX_next(ls); /* must use `seminfo' before `next' */ + break; + } + default: { + luaX_syntaxerror(ls, "function arguments expected"); + return; + } + } + lua_assert(f->k == VNONRELOC); + base = f->u.s.info; /* base register for call */ + if (hasmultret(args.k)) + nparams = LUA_MULTRET; /* open call */ + else { + if (args.k != VVOID) + luaK_exp2nextreg(fs, &args); /* close last argument */ + nparams = fs->freereg - (base+1); + } + init_exp(f, VCALL, luaK_codeABC(fs, OP_CALL, base, nparams+1, 2)); + luaK_fixline(fs, line); + fs->freereg = base+1; /* call remove function and arguments and leaves + (unless changed) one result */ +} + + + + +/* +** {====================================================================== +** Expression parsing +** ======================================================================= +*/ + + +static void prefixexp (LexState *ls, expdesc *v) { + /* prefixexp -> NAME | '(' expr ')' */ + switch (ls->t.token) { + case '(': { + int line = ls->linenumber; + luaX_next(ls); + expr(ls, v); + check_match(ls, ')', '(', line); + luaK_dischargevars(ls->fs, v); + return; + } + case TK_NAME: { + singlevar(ls, v); + return; + } + default: { + luaX_syntaxerror(ls, "unexpected symbol"); + return; + } + } +} + + +static void primaryexp (LexState *ls, expdesc *v) { + /* primaryexp -> + prefixexp { `.' NAME | `[' exp `]' | `:' NAME funcargs | funcargs } */ + FuncState *fs = ls->fs; + prefixexp(ls, v); + for (;;) { + switch (ls->t.token) { + case '.': { /* field */ + field(ls, v); + break; + } + case '[': { /* `[' exp1 `]' */ + expdesc key; + luaK_exp2anyreg(fs, v); + yindex(ls, &key); + luaK_indexed(fs, v, &key); + break; + } + case ':': { /* `:' NAME funcargs */ + expdesc key; + luaX_next(ls); + checkname(ls, &key); + luaK_self(fs, v, &key); + funcargs(ls, v); + break; + } + case '(': case TK_STRING: case '{': { /* funcargs */ + luaK_exp2nextreg(fs, v); + funcargs(ls, v); + break; + } + default: return; + } + } +} + + +static void simpleexp (LexState *ls, expdesc *v) { + /* simpleexp -> NUMBER | STRING | NIL | true | false | ... | + constructor | FUNCTION body | primaryexp */ + switch (ls->t.token) { + case TK_NUMBER: { + init_exp(v, VKNUM, 0); + v->u.nval = ls->t.seminfo.r; + break; + } + case TK_STRING: { + codestring(ls, v, ls->t.seminfo.ts); + break; + } + case TK_NIL: { + init_exp(v, VNIL, 0); + break; + } + case TK_TRUE: { + init_exp(v, VTRUE, 0); + break; + } + case TK_FALSE: { + init_exp(v, VFALSE, 0); + break; + } + case TK_DOTS: { /* vararg */ + FuncState *fs = ls->fs; + check_condition(ls, fs->f->is_vararg, + "cannot use " LUA_QL("...") " outside a vararg function"); + fs->f->is_vararg &= ~VARARG_NEEDSARG; /* don't need 'arg' */ + init_exp(v, VVARARG, luaK_codeABC(fs, OP_VARARG, 0, 1, 0)); + break; + } + case '{': { /* constructor */ + constructor(ls, v); + return; + } + case TK_FUNCTION: { + luaX_next(ls); + body(ls, v, 0, ls->linenumber); + return; + } + default: { + primaryexp(ls, v); + return; + } + } + luaX_next(ls); +} + + +static UnOpr getunopr (int op) { + switch (op) { + case TK_NOT: return OPR_NOT; + case '-': return OPR_MINUS; + case '#': return OPR_LEN; + default: return OPR_NOUNOPR; + } +} + + +static BinOpr getbinopr (int op) { + switch (op) { + case '+': return OPR_ADD; + case '-': return OPR_SUB; + case '*': return OPR_MUL; + case '/': return OPR_DIV; + case '%': return OPR_MOD; + case '^': return OPR_POW; + case TK_CONCAT: return OPR_CONCAT; + case TK_NE: return OPR_NE; + case TK_EQ: return OPR_EQ; + case '<': return OPR_LT; + case TK_LE: return OPR_LE; + case '>': return OPR_GT; + case TK_GE: return OPR_GE; + case TK_AND: return OPR_AND; + case TK_OR: return OPR_OR; + default: return OPR_NOBINOPR; + } +} + + +static const struct { + lu_byte left; /* left priority for each binary operator */ + lu_byte right; /* right priority */ +} priority[] = { /* ORDER OPR */ + {6, 6}, {6, 6}, {7, 7}, {7, 7}, {7, 7}, /* `+' `-' `/' `%' */ + {10, 9}, {5, 4}, /* power and concat (right associative) */ + {3, 3}, {3, 3}, /* equality and inequality */ + {3, 3}, {3, 3}, {3, 3}, {3, 3}, /* order */ + {2, 2}, {1, 1} /* logical (and/or) */ +}; + +#define UNARY_PRIORITY 8 /* priority for unary operators */ + + +/* +** subexpr -> (simpleexp | unop subexpr) { binop subexpr } +** where `binop' is any binary operator with a priority higher than `limit' +*/ +static BinOpr subexpr (LexState *ls, expdesc *v, unsigned int limit) { + BinOpr op; + UnOpr uop; + enterlevel(ls); + uop = getunopr(ls->t.token); + if (uop != OPR_NOUNOPR) { + luaX_next(ls); + subexpr(ls, v, UNARY_PRIORITY); + luaK_prefix(ls->fs, uop, v); + } + else simpleexp(ls, v); + /* expand while operators have priorities higher than `limit' */ + op = getbinopr(ls->t.token); + while (op != OPR_NOBINOPR && priority[op].left > limit) { + expdesc v2; + BinOpr nextop; + luaX_next(ls); + luaK_infix(ls->fs, op, v); + /* read sub-expression with higher priority */ + nextop = subexpr(ls, &v2, priority[op].right); + luaK_posfix(ls->fs, op, v, &v2); + op = nextop; + } + leavelevel(ls); + return op; /* return first untreated operator */ +} + + +static void expr (LexState *ls, expdesc *v) { + subexpr(ls, v, 0); +} + +/* }==================================================================== */ + + + +/* +** {====================================================================== +** Rules for Statements +** ======================================================================= +*/ + + +static int block_follow (int token) { + switch (token) { + case TK_ELSE: case TK_ELSEIF: case TK_END: + case TK_UNTIL: case TK_EOS: + return 1; + default: return 0; + } +} + + +static void block (LexState *ls) { + /* block -> chunk */ + FuncState *fs = ls->fs; + BlockCnt bl; + enterblock(fs, &bl, 0); + chunk(ls); + lua_assert(bl.breaklist == NO_JUMP); + leaveblock(fs); +} + + +/* +** structure to chain all variables in the left-hand side of an +** assignment +*/ +struct LHS_assign { + struct LHS_assign *prev; + expdesc v; /* variable (global, local, upvalue, or indexed) */ +}; + + +/* +** check whether, in an assignment to a local variable, the local variable +** is needed in a previous assignment (to a table). If so, save original +** local value in a safe place and use this safe copy in the previous +** assignment. +*/ +static void check_conflict (LexState *ls, struct LHS_assign *lh, expdesc *v) { + FuncState *fs = ls->fs; + int extra = fs->freereg; /* eventual position to save local variable */ + int conflict = 0; + for (; lh; lh = lh->prev) { + if (lh->v.k == VINDEXED) { + if (lh->v.u.s.info == v->u.s.info) { /* conflict? */ + conflict = 1; + lh->v.u.s.info = extra; /* previous assignment will use safe copy */ + } + if (lh->v.u.s.aux == v->u.s.info) { /* conflict? */ + conflict = 1; + lh->v.u.s.aux = extra; /* previous assignment will use safe copy */ + } + } + } + if (conflict) { + luaK_codeABC(fs, OP_MOVE, fs->freereg, v->u.s.info, 0); /* make copy */ + luaK_reserveregs(fs, 1); + } +} + + +static void assignment (LexState *ls, struct LHS_assign *lh, int nvars) { + expdesc e; + check_condition(ls, VLOCAL <= lh->v.k && lh->v.k <= VINDEXED, + "syntax error"); + if (testnext(ls, ',')) { /* assignment -> `,' primaryexp assignment */ + struct LHS_assign nv; + nv.prev = lh; + primaryexp(ls, &nv.v); + if (nv.v.k == VLOCAL) + check_conflict(ls, lh, &nv.v); + luaY_checklimit(ls->fs, nvars, LUAI_MAXCCALLS - ls->L->nCcalls, + "variables in assignment"); + assignment(ls, &nv, nvars+1); + } + else { /* assignment -> `=' explist1 */ + int nexps; + checknext(ls, '='); + nexps = explist1(ls, &e); + if (nexps != nvars) { + adjust_assign(ls, nvars, nexps, &e); + if (nexps > nvars) + ls->fs->freereg -= nexps - nvars; /* remove extra values */ + } + else { + luaK_setoneret(ls->fs, &e); /* close last expression */ + luaK_storevar(ls->fs, &lh->v, &e); + return; /* avoid default */ + } + } + init_exp(&e, VNONRELOC, ls->fs->freereg-1); /* default assignment */ + luaK_storevar(ls->fs, &lh->v, &e); +} + + +static int cond (LexState *ls) { + /* cond -> exp */ + expdesc v; + expr(ls, &v); /* read condition */ + if (v.k == VNIL) v.k = VFALSE; /* `falses' are all equal here */ + luaK_goiftrue(ls->fs, &v); + return v.f; +} + + +static void breakstat (LexState *ls) { + FuncState *fs = ls->fs; + BlockCnt *bl = fs->bl; + int upval = 0; + while (bl && !bl->isbreakable) { + upval |= bl->upval; + bl = bl->previous; + } + if (!bl) + luaX_syntaxerror(ls, "no loop to break"); + if (upval) + luaK_codeABC(fs, OP_CLOSE, bl->nactvar, 0, 0); + luaK_concat(fs, &bl->breaklist, luaK_jump(fs)); +} + + +static void whilestat (LexState *ls, int line) { + /* whilestat -> WHILE cond DO block END */ + FuncState *fs = ls->fs; + int whileinit; + int condexit; + BlockCnt bl; + luaX_next(ls); /* skip WHILE */ + whileinit = luaK_getlabel(fs); + condexit = cond(ls); + enterblock(fs, &bl, 1); + checknext(ls, TK_DO); + block(ls); + luaK_patchlist(fs, luaK_jump(fs), whileinit); + check_match(ls, TK_END, TK_WHILE, line); + leaveblock(fs); + luaK_patchtohere(fs, condexit); /* false conditions finish the loop */ +} + + +static void repeatstat (LexState *ls, int line) { + /* repeatstat -> REPEAT block UNTIL cond */ + int condexit; + FuncState *fs = ls->fs; + int repeat_init = luaK_getlabel(fs); + BlockCnt bl1, bl2; + enterblock(fs, &bl1, 1); /* loop block */ + enterblock(fs, &bl2, 0); /* scope block */ + luaX_next(ls); /* skip REPEAT */ + chunk(ls); + check_match(ls, TK_UNTIL, TK_REPEAT, line); + condexit = cond(ls); /* read condition (inside scope block) */ + if (!bl2.upval) { /* no upvalues? */ + leaveblock(fs); /* finish scope */ + luaK_patchlist(ls->fs, condexit, repeat_init); /* close the loop */ + } + else { /* complete semantics when there are upvalues */ + breakstat(ls); /* if condition then break */ + luaK_patchtohere(ls->fs, condexit); /* else... */ + leaveblock(fs); /* finish scope... */ + luaK_patchlist(ls->fs, luaK_jump(fs), repeat_init); /* and repeat */ + } + leaveblock(fs); /* finish loop */ +} + + +static int exp1 (LexState *ls) { + expdesc e; + int k; + expr(ls, &e); + k = e.k; + luaK_exp2nextreg(ls->fs, &e); + return k; +} + + +static void forbody (LexState *ls, int base, int line, int nvars, int isnum) { + /* forbody -> DO block */ + BlockCnt bl; + FuncState *fs = ls->fs; + int prep, endfor; + adjustlocalvars(ls, 3); /* control variables */ + checknext(ls, TK_DO); + prep = isnum ? luaK_codeAsBx(fs, OP_FORPREP, base, NO_JUMP) : luaK_jump(fs); + enterblock(fs, &bl, 0); /* scope for declared variables */ + adjustlocalvars(ls, nvars); + luaK_reserveregs(fs, nvars); + block(ls); + leaveblock(fs); /* end of scope for declared variables */ + luaK_patchtohere(fs, prep); + endfor = (isnum) ? luaK_codeAsBx(fs, OP_FORLOOP, base, NO_JUMP) : + luaK_codeABC(fs, OP_TFORLOOP, base, 0, nvars); + luaK_fixline(fs, line); /* pretend that `OP_FOR' starts the loop */ + luaK_patchlist(fs, (isnum ? endfor : luaK_jump(fs)), prep + 1); +} + + +static void fornum (LexState *ls, TString *varname, int line) { + /* fornum -> NAME = exp1,exp1[,exp1] forbody */ + FuncState *fs = ls->fs; + int base = fs->freereg; + new_localvarliteral(ls, "(for index)", 0); + new_localvarliteral(ls, "(for limit)", 1); + new_localvarliteral(ls, "(for step)", 2); + new_localvar(ls, varname, 3); + checknext(ls, '='); + exp1(ls); /* initial value */ + checknext(ls, ','); + exp1(ls); /* limit */ + if (testnext(ls, ',')) + exp1(ls); /* optional step */ + else { /* default step = 1 */ + luaK_codeABx(fs, OP_LOADK, fs->freereg, luaK_numberK(fs, 1)); + luaK_reserveregs(fs, 1); + } + forbody(ls, base, line, 1, 1); +} + + +static void forlist (LexState *ls, TString *indexname) { + /* forlist -> NAME {,NAME} IN explist1 forbody */ + FuncState *fs = ls->fs; + expdesc e; + int nvars = 0; + int line; + int base = fs->freereg; + /* create control variables */ + new_localvarliteral(ls, "(for generator)", nvars++); + new_localvarliteral(ls, "(for state)", nvars++); + new_localvarliteral(ls, "(for control)", nvars++); + /* create declared variables */ + new_localvar(ls, indexname, nvars++); + while (testnext(ls, ',')) + new_localvar(ls, str_checkname(ls), nvars++); + checknext(ls, TK_IN); + line = ls->linenumber; + adjust_assign(ls, 3, explist1(ls, &e), &e); + luaK_checkstack(fs, 3); /* extra space to call generator */ + forbody(ls, base, line, nvars - 3, 0); +} + + +static void forstat (LexState *ls, int line) { + /* forstat -> FOR (fornum | forlist) END */ + FuncState *fs = ls->fs; + TString *varname; + BlockCnt bl; + enterblock(fs, &bl, 1); /* scope for loop and control variables */ + luaX_next(ls); /* skip `for' */ + varname = str_checkname(ls); /* first variable name */ + switch (ls->t.token) { + case '=': fornum(ls, varname, line); break; + case ',': case TK_IN: forlist(ls, varname); break; + default: luaX_syntaxerror(ls, LUA_QL("=") " or " LUA_QL("in") " expected"); + } + check_match(ls, TK_END, TK_FOR, line); + leaveblock(fs); /* loop scope (`break' jumps to this point) */ +} + + +static int test_then_block (LexState *ls) { + /* test_then_block -> [IF | ELSEIF] cond THEN block */ + int condexit; + luaX_next(ls); /* skip IF or ELSEIF */ + condexit = cond(ls); + checknext(ls, TK_THEN); + block(ls); /* `then' part */ + return condexit; +} + + +static void ifstat (LexState *ls, int line) { + /* ifstat -> IF cond THEN block {ELSEIF cond THEN block} [ELSE block] END */ + FuncState *fs = ls->fs; + int flist; + int escapelist = NO_JUMP; + flist = test_then_block(ls); /* IF cond THEN block */ + while (ls->t.token == TK_ELSEIF) { + luaK_concat(fs, &escapelist, luaK_jump(fs)); + luaK_patchtohere(fs, flist); + flist = test_then_block(ls); /* ELSEIF cond THEN block */ + } + if (ls->t.token == TK_ELSE) { + luaK_concat(fs, &escapelist, luaK_jump(fs)); + luaK_patchtohere(fs, flist); + luaX_next(ls); /* skip ELSE (after patch, for correct line info) */ + block(ls); /* `else' part */ + } + else + luaK_concat(fs, &escapelist, flist); + luaK_patchtohere(fs, escapelist); + check_match(ls, TK_END, TK_IF, line); +} + + +static void localfunc (LexState *ls) { + expdesc v, b; + FuncState *fs = ls->fs; + new_localvar(ls, str_checkname(ls), 0); + init_exp(&v, VLOCAL, fs->freereg); + luaK_reserveregs(fs, 1); + adjustlocalvars(ls, 1); + body(ls, &b, 0, ls->linenumber); + luaK_storevar(fs, &v, &b); + /* debug information will only see the variable after this point! */ + getlocvar(fs, fs->nactvar - 1).startpc = fs->pc; +} + + +static void localstat (LexState *ls) { + /* stat -> LOCAL NAME {`,' NAME} [`=' explist1] */ + int nvars = 0; + int nexps; + expdesc e; + do { + new_localvar(ls, str_checkname(ls), nvars++); + } while (testnext(ls, ',')); + if (testnext(ls, '=')) + nexps = explist1(ls, &e); + else { + e.k = VVOID; + nexps = 0; + } + adjust_assign(ls, nvars, nexps, &e); + adjustlocalvars(ls, nvars); +} + + +static int funcname (LexState *ls, expdesc *v) { + /* funcname -> NAME {field} [`:' NAME] */ + int needself = 0; + singlevar(ls, v); + while (ls->t.token == '.') + field(ls, v); + if (ls->t.token == ':') { + needself = 1; + field(ls, v); + } + return needself; +} + + +static void funcstat (LexState *ls, int line) { + /* funcstat -> FUNCTION funcname body */ + int needself; + expdesc v, b; + luaX_next(ls); /* skip FUNCTION */ + needself = funcname(ls, &v); + body(ls, &b, needself, line); + luaK_storevar(ls->fs, &v, &b); + luaK_fixline(ls->fs, line); /* definition `happens' in the first line */ +} + + +static void exprstat (LexState *ls) { + /* stat -> func | assignment */ + FuncState *fs = ls->fs; + struct LHS_assign v; + primaryexp(ls, &v.v); + if (v.v.k == VCALL) /* stat -> func */ + SETARG_C(getcode(fs, &v.v), 1); /* call statement uses no results */ + else { /* stat -> assignment */ + v.prev = NULL; + assignment(ls, &v, 1); + } +} + + +static void retstat (LexState *ls) { + /* stat -> RETURN explist */ + FuncState *fs = ls->fs; + expdesc e; + int first, nret; /* registers with returned values */ + luaX_next(ls); /* skip RETURN */ + if (block_follow(ls->t.token) || ls->t.token == ';') + first = nret = 0; /* return no values */ + else { + nret = explist1(ls, &e); /* optional return values */ + if (hasmultret(e.k)) { + luaK_setmultret(fs, &e); + if (e.k == VCALL && nret == 1) { /* tail call? */ + SET_OPCODE(getcode(fs,&e), OP_TAILCALL); + lua_assert(GETARG_A(getcode(fs,&e)) == fs->nactvar); + } + first = fs->nactvar; + nret = LUA_MULTRET; /* return all values */ + } + else { + if (nret == 1) /* only one single value? */ + first = luaK_exp2anyreg(fs, &e); + else { + luaK_exp2nextreg(fs, &e); /* values must go to the `stack' */ + first = fs->nactvar; /* return all `active' values */ + lua_assert(nret == fs->freereg - first); + } + } + } + luaK_ret(fs, first, nret); +} + + +static int statement (LexState *ls) { + int line = ls->linenumber; /* may be needed for error messages */ + switch (ls->t.token) { + case TK_IF: { /* stat -> ifstat */ + ifstat(ls, line); + return 0; + } + case TK_WHILE: { /* stat -> whilestat */ + whilestat(ls, line); + return 0; + } + case TK_DO: { /* stat -> DO block END */ + luaX_next(ls); /* skip DO */ + block(ls); + check_match(ls, TK_END, TK_DO, line); + return 0; + } + case TK_FOR: { /* stat -> forstat */ + forstat(ls, line); + return 0; + } + case TK_REPEAT: { /* stat -> repeatstat */ + repeatstat(ls, line); + return 0; + } + case TK_FUNCTION: { + funcstat(ls, line); /* stat -> funcstat */ + return 0; + } + case TK_LOCAL: { /* stat -> localstat */ + luaX_next(ls); /* skip LOCAL */ + if (testnext(ls, TK_FUNCTION)) /* local function? */ + localfunc(ls); + else + localstat(ls); + return 0; + } + case TK_RETURN: { /* stat -> retstat */ + retstat(ls); + return 1; /* must be last statement */ + } + case TK_BREAK: { /* stat -> breakstat */ + luaX_next(ls); /* skip BREAK */ + breakstat(ls); + return 1; /* must be last statement */ + } + default: { + exprstat(ls); + return 0; /* to avoid warnings */ + } + } +} + + +static void chunk (LexState *ls) { + /* chunk -> { stat [`;'] } */ + int islast = 0; + enterlevel(ls); + while (!islast && !block_follow(ls->t.token)) { + islast = statement(ls); + testnext(ls, ';'); + lua_assert(ls->fs->f->maxstacksize >= ls->fs->freereg && + ls->fs->freereg >= ls->fs->nactvar); + ls->fs->freereg = ls->fs->nactvar; /* free registers */ + } + leavelevel(ls); +} + +/* }====================================================================== */ diff --git a/include/lua/lparser.h b/include/lua/lparser.h new file mode 100644 index 0000000..18836af --- /dev/null +++ b/include/lua/lparser.h @@ -0,0 +1,82 @@ +/* +** $Id: lparser.h,v 1.57.1.1 2007/12/27 13:02:25 roberto Exp $ +** Lua Parser +** See Copyright Notice in lua.h +*/ + +#ifndef lparser_h +#define lparser_h + +#include "llimits.h" +#include "lobject.h" +#include "lzio.h" + + +/* +** Expression descriptor +*/ + +typedef enum { + VVOID, /* no value */ + VNIL, + VTRUE, + VFALSE, + VK, /* info = index of constant in `k' */ + VKNUM, /* nval = numerical value */ + VLOCAL, /* info = local register */ + VUPVAL, /* info = index of upvalue in `upvalues' */ + VGLOBAL, /* info = index of table; aux = index of global name in `k' */ + VINDEXED, /* info = table register; aux = index register (or `k') */ + VJMP, /* info = instruction pc */ + VRELOCABLE, /* info = instruction pc */ + VNONRELOC, /* info = result register */ + VCALL, /* info = instruction pc */ + VVARARG /* info = instruction pc */ +} expkind; + +typedef struct expdesc { + expkind k; + union { + struct { int info, aux; } s; + lua_Number nval; + } u; + int t; /* patch list of `exit when true' */ + int f; /* patch list of `exit when false' */ +} expdesc; + + +typedef struct upvaldesc { + lu_byte k; + lu_byte info; +} upvaldesc; + + +struct BlockCnt; /* defined in lparser.c */ + + +/* state needed to generate code for a given function */ +typedef struct FuncState { + Proto *f; /* current function header */ + Table *h; /* table to find (and reuse) elements in `k' */ + struct FuncState *prev; /* enclosing function */ + struct LexState *ls; /* lexical state */ + struct lua_State *L; /* copy of the Lua state */ + struct BlockCnt *bl; /* chain of current blocks */ + int pc; /* next position to code (equivalent to `ncode') */ + int lasttarget; /* `pc' of last `jump target' */ + int jpc; /* list of pending jumps to `pc' */ + int freereg; /* first free register */ + int nk; /* number of elements in `k' */ + int np; /* number of elements in `p' */ + short nlocvars; /* number of elements in `locvars' */ + lu_byte nactvar; /* number of active local variables */ + upvaldesc upvalues[LUAI_MAXUPVALUES]; /* upvalues */ + unsigned short actvar[LUAI_MAXVARS]; /* declared-variable stack */ +} FuncState; + + +LUAI_FUNC Proto *luaY_parser (lua_State *L, ZIO *z, Mbuffer *buff, + const char *name); + + +#endif diff --git a/include/lua/lstate.c b/include/lua/lstate.c new file mode 100644 index 0000000..4313b83 --- /dev/null +++ b/include/lua/lstate.c @@ -0,0 +1,214 @@ +/* +** $Id: lstate.c,v 2.36.1.2 2008/01/03 15:20:39 roberto Exp $ +** Global State +** See Copyright Notice in lua.h +*/ + + +#include + +#define lstate_c +#define LUA_CORE + +#include "lua.h" + +#include "ldebug.h" +#include "ldo.h" +#include "lfunc.h" +#include "lgc.h" +#include "llex.h" +#include "lmem.h" +#include "lstate.h" +#include "lstring.h" +#include "ltable.h" +#include "ltm.h" + + +#define state_size(x) (sizeof(x) + LUAI_EXTRASPACE) +#define fromstate(l) (cast(lu_byte *, (l)) - LUAI_EXTRASPACE) +#define tostate(l) (cast(lua_State *, cast(lu_byte *, l) + LUAI_EXTRASPACE)) + + +/* +** Main thread combines a thread state and the global state +*/ +typedef struct LG { + lua_State l; + global_State g; +} LG; + + + +static void stack_init (lua_State *L1, lua_State *L) { + /* initialize CallInfo array */ + L1->base_ci = luaM_newvector(L, BASIC_CI_SIZE, CallInfo); + L1->ci = L1->base_ci; + L1->size_ci = BASIC_CI_SIZE; + L1->end_ci = L1->base_ci + L1->size_ci - 1; + /* initialize stack array */ + L1->stack = luaM_newvector(L, BASIC_STACK_SIZE + EXTRA_STACK, TValue); + L1->stacksize = BASIC_STACK_SIZE + EXTRA_STACK; + L1->top = L1->stack; + L1->stack_last = L1->stack+(L1->stacksize - EXTRA_STACK)-1; + /* initialize first ci */ + L1->ci->func = L1->top; + setnilvalue(L1->top++); /* `function' entry for this `ci' */ + L1->base = L1->ci->base = L1->top; + L1->ci->top = L1->top + LUA_MINSTACK; +} + + +static void freestack (lua_State *L, lua_State *L1) { + luaM_freearray(L, L1->base_ci, L1->size_ci, CallInfo); + luaM_freearray(L, L1->stack, L1->stacksize, TValue); +} + + +/* +** open parts that may cause memory-allocation errors +*/ +static void f_luaopen (lua_State *L, void *ud) { + global_State *g = G(L); + UNUSED(ud); + stack_init(L, L); /* init stack */ + sethvalue(L, gt(L), luaH_new(L, 0, 2)); /* table of globals */ + sethvalue(L, registry(L), luaH_new(L, 0, 2)); /* registry */ + luaS_resize(L, MINSTRTABSIZE); /* initial size of string table */ + luaT_init(L); + luaX_init(L); + luaS_fix(luaS_newliteral(L, MEMERRMSG)); + g->GCthreshold = 4*g->totalbytes; +} + + +static void preinit_state (lua_State *L, global_State *g) { + G(L) = g; + L->stack = NULL; + L->stacksize = 0; + L->errorJmp = NULL; + L->hook = NULL; + L->hookmask = 0; + L->basehookcount = 0; + L->allowhook = 1; + resethookcount(L); + L->openupval = NULL; + L->size_ci = 0; + L->nCcalls = L->baseCcalls = 0; + L->status = 0; + L->base_ci = L->ci = NULL; + L->savedpc = NULL; + L->errfunc = 0; + setnilvalue(gt(L)); +} + + +static void close_state (lua_State *L) { + global_State *g = G(L); + luaF_close(L, L->stack); /* close all upvalues for this thread */ + luaC_freeall(L); /* collect all objects */ + lua_assert(g->rootgc == obj2gco(L)); + lua_assert(g->strt.nuse == 0); + luaM_freearray(L, G(L)->strt.hash, G(L)->strt.size, TString *); + luaZ_freebuffer(L, &g->buff); + freestack(L, L); + lua_assert(g->totalbytes == sizeof(LG)); + (*g->frealloc)(g->ud, fromstate(L), state_size(LG), 0); +} + + +lua_State *luaE_newthread (lua_State *L) { + lua_State *L1 = tostate(luaM_malloc(L, state_size(lua_State))); + luaC_link(L, obj2gco(L1), LUA_TTHREAD); + preinit_state(L1, G(L)); + stack_init(L1, L); /* init stack */ + setobj2n(L, gt(L1), gt(L)); /* share table of globals */ + L1->hookmask = L->hookmask; + L1->basehookcount = L->basehookcount; + L1->hook = L->hook; + resethookcount(L1); + lua_assert(iswhite(obj2gco(L1))); + return L1; +} + + +void luaE_freethread (lua_State *L, lua_State *L1) { + luaF_close(L1, L1->stack); /* close all upvalues for this thread */ + lua_assert(L1->openupval == NULL); + luai_userstatefree(L1); + freestack(L, L1); + luaM_freemem(L, fromstate(L1), state_size(lua_State)); +} + + +LUA_API lua_State *lua_newstate (lua_Alloc f, void *ud) { + int i; + lua_State *L; + global_State *g; + void *l = (*f)(ud, NULL, 0, state_size(LG)); + if (l == NULL) return NULL; + L = tostate(l); + g = &((LG *)L)->g; + L->next = NULL; + L->tt = LUA_TTHREAD; + g->currentwhite = bit2mask(WHITE0BIT, FIXEDBIT); + L->marked = luaC_white(g); + set2bits(L->marked, FIXEDBIT, SFIXEDBIT); + preinit_state(L, g); + g->frealloc = f; + g->ud = ud; + g->mainthread = L; + g->uvhead.u.l.prev = &g->uvhead; + g->uvhead.u.l.next = &g->uvhead; + g->GCthreshold = 0; /* mark it as unfinished state */ + g->strt.size = 0; + g->strt.nuse = 0; + g->strt.hash = NULL; + setnilvalue(registry(L)); + luaZ_initbuffer(L, &g->buff); + g->panic = NULL; + g->gcstate = GCSpause; + g->rootgc = obj2gco(L); + g->sweepstrgc = 0; + g->sweepgc = &g->rootgc; + g->gray = NULL; + g->grayagain = NULL; + g->weak = NULL; + g->tmudata = NULL; + g->totalbytes = sizeof(LG); + g->gcpause = LUAI_GCPAUSE; + g->gcstepmul = LUAI_GCMUL; + g->gcdept = 0; + for (i=0; imt[i] = NULL; + if (luaD_rawrunprotected(L, f_luaopen, NULL) != 0) { + /* memory allocation error: free partial state */ + close_state(L); + L = NULL; + } + else + luai_userstateopen(L); + return L; +} + + +static void callallgcTM (lua_State *L, void *ud) { + UNUSED(ud); + luaC_callGCTM(L); /* call GC metamethods for all udata */ +} + + +LUA_API void lua_close (lua_State *L) { + L = G(L)->mainthread; /* only the main thread can be closed */ + lua_lock(L); + luaF_close(L, L->stack); /* close all upvalues for this thread */ + luaC_separateudata(L, 1); /* separate udata that have GC metamethods */ + L->errfunc = 0; /* no error function during GC metamethods */ + do { /* repeat until no more errors */ + L->ci = L->base_ci; + L->base = L->top = L->ci->base; + L->nCcalls = L->baseCcalls = 0; + } while (luaD_rawrunprotected(L, callallgcTM, NULL) != 0); + lua_assert(G(L)->tmudata == NULL); + luai_userstateclose(L); + close_state(L); +} + diff --git a/include/lua/lstate.h b/include/lua/lstate.h new file mode 100644 index 0000000..3bc575b --- /dev/null +++ b/include/lua/lstate.h @@ -0,0 +1,169 @@ +/* +** $Id: lstate.h,v 2.24.1.2 2008/01/03 15:20:39 roberto Exp $ +** Global State +** See Copyright Notice in lua.h +*/ + +#ifndef lstate_h +#define lstate_h + +#include "lua.h" + +#include "lobject.h" +#include "ltm.h" +#include "lzio.h" + + + +struct lua_longjmp; /* defined in ldo.c */ + + +/* table of globals */ +#define gt(L) (&L->l_gt) + +/* registry */ +#define registry(L) (&G(L)->l_registry) + + +/* extra stack space to handle TM calls and some other extras */ +#define EXTRA_STACK 5 + + +#define BASIC_CI_SIZE 8 + +#define BASIC_STACK_SIZE (2*LUA_MINSTACK) + + + +typedef struct stringtable { + GCObject **hash; + lu_int32 nuse; /* number of elements */ + int size; +} stringtable; + + +/* +** informations about a call +*/ +typedef struct CallInfo { + StkId base; /* base for this function */ + StkId func; /* function index in the stack */ + StkId top; /* top for this function */ + const Instruction *savedpc; + int nresults; /* expected number of results from this function */ + int tailcalls; /* number of tail calls lost under this entry */ +} CallInfo; + + + +#define curr_func(L) (clvalue(L->ci->func)) +#define ci_func(ci) (clvalue((ci)->func)) +#define f_isLua(ci) (!ci_func(ci)->c.isC) +#define isLua(ci) (ttisfunction((ci)->func) && f_isLua(ci)) + + +/* +** `global state', shared by all threads of this state +*/ +typedef struct global_State { + stringtable strt; /* hash table for strings */ + lua_Alloc frealloc; /* function to reallocate memory */ + void *ud; /* auxiliary data to `frealloc' */ + lu_byte currentwhite; + lu_byte gcstate; /* state of garbage collector */ + int sweepstrgc; /* position of sweep in `strt' */ + GCObject *rootgc; /* list of all collectable objects */ + GCObject **sweepgc; /* position of sweep in `rootgc' */ + GCObject *gray; /* list of gray objects */ + GCObject *grayagain; /* list of objects to be traversed atomically */ + GCObject *weak; /* list of weak tables (to be cleared) */ + GCObject *tmudata; /* last element of list of userdata to be GC */ + Mbuffer buff; /* temporary buffer for string concatentation */ + lu_mem GCthreshold; + lu_mem totalbytes; /* number of bytes currently allocated */ + lu_mem estimate; /* an estimate of number of bytes actually in use */ + lu_mem gcdept; /* how much GC is `behind schedule' */ + int gcpause; /* size of pause between successive GCs */ + int gcstepmul; /* GC `granularity' */ + lua_CFunction panic; /* to be called in unprotected errors */ + TValue l_registry; + struct lua_State *mainthread; + UpVal uvhead; /* head of double-linked list of all open upvalues */ + struct Table *mt[NUM_TAGS]; /* metatables for basic types */ + TString *tmname[TM_N]; /* array with tag-method names */ +} global_State; + + +/* +** `per thread' state +*/ +struct lua_State { + CommonHeader; + lu_byte status; + StkId top; /* first free slot in the stack */ + StkId base; /* base of current function */ + global_State *l_G; + CallInfo *ci; /* call info for current function */ + const Instruction *savedpc; /* `savedpc' of current function */ + StkId stack_last; /* last free slot in the stack */ + StkId stack; /* stack base */ + CallInfo *end_ci; /* points after end of ci array*/ + CallInfo *base_ci; /* array of CallInfo's */ + int stacksize; + int size_ci; /* size of array `base_ci' */ + unsigned short nCcalls; /* number of nested C calls */ + unsigned short baseCcalls; /* nested C calls when resuming coroutine */ + lu_byte hookmask; + lu_byte allowhook; + int basehookcount; + int hookcount; + lua_Hook hook; + TValue l_gt; /* table of globals */ + TValue env; /* temporary place for environments */ + GCObject *openupval; /* list of open upvalues in this stack */ + GCObject *gclist; + struct lua_longjmp *errorJmp; /* current error recover point */ + ptrdiff_t errfunc; /* current error handling function (stack index) */ +}; + + +#define G(L) (L->l_G) + + +/* +** Union of all collectable objects +*/ +union GCObject { + GCheader gch; + union TString ts; + union Udata u; + union Closure cl; + struct Table h; + struct Proto p; + struct UpVal uv; + struct lua_State th; /* thread */ +}; + + +/* macros to convert a GCObject into a specific value */ +#define rawgco2ts(o) check_exp((o)->gch.tt == LUA_TSTRING, &((o)->ts)) +#define gco2ts(o) (&rawgco2ts(o)->tsv) +#define rawgco2u(o) check_exp((o)->gch.tt == LUA_TUSERDATA, &((o)->u)) +#define gco2u(o) (&rawgco2u(o)->uv) +#define gco2cl(o) check_exp((o)->gch.tt == LUA_TFUNCTION, &((o)->cl)) +#define gco2h(o) check_exp((o)->gch.tt == LUA_TTABLE, &((o)->h)) +#define gco2p(o) check_exp((o)->gch.tt == LUA_TPROTO, &((o)->p)) +#define gco2uv(o) check_exp((o)->gch.tt == LUA_TUPVAL, &((o)->uv)) +#define ngcotouv(o) \ + check_exp((o) == NULL || (o)->gch.tt == LUA_TUPVAL, &((o)->uv)) +#define gco2th(o) check_exp((o)->gch.tt == LUA_TTHREAD, &((o)->th)) + +/* macro to convert any Lua object into a GCObject */ +#define obj2gco(v) (cast(GCObject *, (v))) + + +LUAI_FUNC lua_State *luaE_newthread (lua_State *L); +LUAI_FUNC void luaE_freethread (lua_State *L, lua_State *L1); + +#endif + diff --git a/include/lua/lstring.c b/include/lua/lstring.c new file mode 100644 index 0000000..4911315 --- /dev/null +++ b/include/lua/lstring.c @@ -0,0 +1,111 @@ +/* +** $Id: lstring.c,v 2.8.1.1 2007/12/27 13:02:25 roberto Exp $ +** String table (keeps all strings handled by Lua) +** See Copyright Notice in lua.h +*/ + + +#include + +#define lstring_c +#define LUA_CORE + +#include "lua.h" + +#include "lmem.h" +#include "lobject.h" +#include "lstate.h" +#include "lstring.h" + + + +void luaS_resize (lua_State *L, int newsize) { + GCObject **newhash; + stringtable *tb; + int i; + if (G(L)->gcstate == GCSsweepstring) + return; /* cannot resize during GC traverse */ + newhash = luaM_newvector(L, newsize, GCObject *); + tb = &G(L)->strt; + for (i=0; isize; i++) { + GCObject *p = tb->hash[i]; + while (p) { /* for each node in the list */ + GCObject *next = p->gch.next; /* save next */ + unsigned int h = gco2ts(p)->hash; + int h1 = lmod(h, newsize); /* new position */ + lua_assert(cast_int(h%newsize) == lmod(h, newsize)); + p->gch.next = newhash[h1]; /* chain it */ + newhash[h1] = p; + p = next; + } + } + luaM_freearray(L, tb->hash, tb->size, TString *); + tb->size = newsize; + tb->hash = newhash; +} + + +static TString *newlstr (lua_State *L, const char *str, size_t l, + unsigned int h) { + TString *ts; + stringtable *tb; + if (l+1 > (MAX_SIZET - sizeof(TString))/sizeof(char)) + luaM_toobig(L); + ts = cast(TString *, luaM_malloc(L, (l+1)*sizeof(char)+sizeof(TString))); + ts->tsv.len = l; + ts->tsv.hash = h; + ts->tsv.marked = luaC_white(G(L)); + ts->tsv.tt = LUA_TSTRING; + ts->tsv.reserved = 0; + memcpy(ts+1, str, l*sizeof(char)); + ((char *)(ts+1))[l] = '\0'; /* ending 0 */ + tb = &G(L)->strt; + h = lmod(h, tb->size); + ts->tsv.next = tb->hash[h]; /* chain new entry */ + tb->hash[h] = obj2gco(ts); + tb->nuse++; + if (tb->nuse > cast(lu_int32, tb->size) && tb->size <= MAX_INT/2) + luaS_resize(L, tb->size*2); /* too crowded */ + return ts; +} + + +TString *luaS_newlstr (lua_State *L, const char *str, size_t l) { + GCObject *o; + unsigned int h = cast(unsigned int, l); /* seed */ + size_t step = (l>>5)+1; /* if string is too long, don't hash all its chars */ + size_t l1; + for (l1=l; l1>=step; l1-=step) /* compute hash */ + h = h ^ ((h<<5)+(h>>2)+cast(unsigned char, str[l1-1])); + for (o = G(L)->strt.hash[lmod(h, G(L)->strt.size)]; + o != NULL; + o = o->gch.next) { + TString *ts = rawgco2ts(o); + if (ts->tsv.len == l && (memcmp(str, getstr(ts), l) == 0)) { + /* string may be dead */ + if (isdead(G(L), o)) changewhite(o); + return ts; + } + } + return newlstr(L, str, l, h); /* not found */ +} + + +Udata *luaS_newudata (lua_State *L, size_t s, Table *e) { + Udata *u; + if (s > MAX_SIZET - sizeof(Udata)) + luaM_toobig(L); + u = cast(Udata *, luaM_malloc(L, s + sizeof(Udata))); + u->uv.marked = luaC_white(G(L)); /* is not finalized */ + u->uv.tt = LUA_TUSERDATA; + u->uv.len = s; + u->uv.metatable = NULL; + u->uv.env = e; + /* chain it on udata list (after main thread) */ + u->uv.next = G(L)->mainthread->next; + G(L)->mainthread->next = obj2gco(u); + return u; +} + diff --git a/include/lua/lstring.h b/include/lua/lstring.h new file mode 100644 index 0000000..73a2ff8 --- /dev/null +++ b/include/lua/lstring.h @@ -0,0 +1,31 @@ +/* +** $Id: lstring.h,v 1.43.1.1 2007/12/27 13:02:25 roberto Exp $ +** String table (keep all strings handled by Lua) +** See Copyright Notice in lua.h +*/ + +#ifndef lstring_h +#define lstring_h + + +#include "lgc.h" +#include "lobject.h" +#include "lstate.h" + + +#define sizestring(s) (sizeof(union TString)+((s)->len+1)*sizeof(char)) + +#define sizeudata(u) (sizeof(union Udata)+(u)->len) + +#define luaS_new(L, s) (luaS_newlstr(L, s, strlen(s))) +#define luaS_newliteral(L, s) (luaS_newlstr(L, "" s, \ + (sizeof(s)/sizeof(char))-1)) + +#define luaS_fix(s) l_setbit((s)->tsv.marked, FIXEDBIT) + +LUAI_FUNC void luaS_resize (lua_State *L, int newsize); +LUAI_FUNC Udata *luaS_newudata (lua_State *L, size_t s, Table *e); +LUAI_FUNC TString *luaS_newlstr (lua_State *L, const char *str, size_t l); + + +#endif diff --git a/include/lua/lstrlib.c b/include/lua/lstrlib.c new file mode 100644 index 0000000..1b4763d --- /dev/null +++ b/include/lua/lstrlib.c @@ -0,0 +1,869 @@ +/* +** $Id: lstrlib.c,v 1.132.1.4 2008/07/11 17:27:21 roberto Exp $ +** Standard library for string operations and pattern-matching +** See Copyright Notice in lua.h +*/ + + +#include +#include +#include +#include +#include + +#define lstrlib_c +#define LUA_LIB + +#include "lua.h" + +#include "lauxlib.h" +#include "lualib.h" + + +/* macro to `unsign' a character */ +#define uchar(c) ((unsigned char)(c)) + + + +static int str_len (lua_State *L) { + size_t l; + luaL_checklstring(L, 1, &l); + lua_pushinteger(L, l); + return 1; +} + + +static ptrdiff_t posrelat (ptrdiff_t pos, size_t len) { + /* relative string position: negative means back from end */ + if (pos < 0) pos += (ptrdiff_t)len + 1; + return (pos >= 0) ? pos : 0; +} + + +static int str_sub (lua_State *L) { + size_t l; + const char *s = luaL_checklstring(L, 1, &l); + ptrdiff_t start = posrelat(luaL_checkinteger(L, 2), l); + ptrdiff_t end = posrelat(luaL_optinteger(L, 3, -1), l); + if (start < 1) start = 1; + if (end > (ptrdiff_t)l) end = (ptrdiff_t)l; + if (start <= end) + lua_pushlstring(L, s+start-1, end-start+1); + else lua_pushliteral(L, ""); + return 1; +} + + +static int str_reverse (lua_State *L) { + size_t l; + luaL_Buffer b; + const char *s = luaL_checklstring(L, 1, &l); + luaL_buffinit(L, &b); + while (l--) luaL_addchar(&b, s[l]); + luaL_pushresult(&b); + return 1; +} + + +static int str_lower (lua_State *L) { + size_t l; + size_t i; + luaL_Buffer b; + const char *s = luaL_checklstring(L, 1, &l); + luaL_buffinit(L, &b); + for (i=0; i 0) + luaL_addlstring(&b, s, l); + luaL_pushresult(&b); + return 1; +} + + +static int str_byte (lua_State *L) { + size_t l; + const char *s = luaL_checklstring(L, 1, &l); + ptrdiff_t posi = posrelat(luaL_optinteger(L, 2, 1), l); + ptrdiff_t pose = posrelat(luaL_optinteger(L, 3, posi), l); + int n, i; + if (posi <= 0) posi = 1; + if ((size_t)pose > l) pose = l; + if (posi > pose) return 0; /* empty interval; return no values */ + n = (int)(pose - posi + 1); + if (posi + n <= pose) /* overflow? */ + luaL_error(L, "string slice too long"); + luaL_checkstack(L, n, "string slice too long"); + for (i=0; i= ms->level || ms->capture[l].len == CAP_UNFINISHED) + return luaL_error(ms->L, "invalid capture index"); + return l; +} + + +static int capture_to_close (MatchState *ms) { + int level = ms->level; + for (level--; level>=0; level--) + if (ms->capture[level].len == CAP_UNFINISHED) return level; + return luaL_error(ms->L, "invalid pattern capture"); +} + + +static const char *classend (MatchState *ms, const char *p) { + switch (*p++) { + case L_ESC: { + if (*p == '\0') + luaL_error(ms->L, "malformed pattern (ends with " LUA_QL("%%") ")"); + return p+1; + } + case '[': { + if (*p == '^') p++; + do { /* look for a `]' */ + if (*p == '\0') + luaL_error(ms->L, "malformed pattern (missing " LUA_QL("]") ")"); + if (*(p++) == L_ESC && *p != '\0') + p++; /* skip escapes (e.g. `%]') */ + } while (*p != ']'); + return p+1; + } + default: { + return p; + } + } +} + + +static int match_class (int c, int cl) { + int res; + switch (tolower(cl)) { + case 'a' : res = isalpha(c); break; + case 'c' : res = iscntrl(c); break; + case 'd' : res = isdigit(c); break; + case 'l' : res = islower(c); break; + case 'p' : res = ispunct(c); break; + case 's' : res = isspace(c); break; + case 'u' : res = isupper(c); break; + case 'w' : res = isalnum(c); break; + case 'x' : res = isxdigit(c); break; + case 'z' : res = (c == 0); break; + default: return (cl == c); + } + return (islower(cl) ? res : !res); +} + + +static int matchbracketclass (int c, const char *p, const char *ec) { + int sig = 1; + if (*(p+1) == '^') { + sig = 0; + p++; /* skip the `^' */ + } + while (++p < ec) { + if (*p == L_ESC) { + p++; + if (match_class(c, uchar(*p))) + return sig; + } + else if ((*(p+1) == '-') && (p+2 < ec)) { + p+=2; + if (uchar(*(p-2)) <= c && c <= uchar(*p)) + return sig; + } + else if (uchar(*p) == c) return sig; + } + return !sig; +} + + +static int singlematch (int c, const char *p, const char *ep) { + switch (*p) { + case '.': return 1; /* matches any char */ + case L_ESC: return match_class(c, uchar(*(p+1))); + case '[': return matchbracketclass(c, p, ep-1); + default: return (uchar(*p) == c); + } +} + + +static const char *match (MatchState *ms, const char *s, const char *p); + + +static const char *matchbalance (MatchState *ms, const char *s, + const char *p) { + if (*p == 0 || *(p+1) == 0) + luaL_error(ms->L, "unbalanced pattern"); + if (*s != *p) return NULL; + else { + int b = *p; + int e = *(p+1); + int cont = 1; + while (++s < ms->src_end) { + if (*s == e) { + if (--cont == 0) return s+1; + } + else if (*s == b) cont++; + } + } + return NULL; /* string ends out of balance */ +} + + +static const char *max_expand (MatchState *ms, const char *s, + const char *p, const char *ep) { + ptrdiff_t i = 0; /* counts maximum expand for item */ + while ((s+i)src_end && singlematch(uchar(*(s+i)), p, ep)) + i++; + /* keeps trying to match with the maximum repetitions */ + while (i>=0) { + const char *res = match(ms, (s+i), ep+1); + if (res) return res; + i--; /* else didn't match; reduce 1 repetition to try again */ + } + return NULL; +} + + +static const char *min_expand (MatchState *ms, const char *s, + const char *p, const char *ep) { + for (;;) { + const char *res = match(ms, s, ep+1); + if (res != NULL) + return res; + else if (ssrc_end && singlematch(uchar(*s), p, ep)) + s++; /* try with one more repetition */ + else return NULL; + } +} + + +static const char *start_capture (MatchState *ms, const char *s, + const char *p, int what) { + const char *res; + int level = ms->level; + if (level >= LUA_MAXCAPTURES) luaL_error(ms->L, "too many captures"); + ms->capture[level].init = s; + ms->capture[level].len = what; + ms->level = level+1; + if ((res=match(ms, s, p)) == NULL) /* match failed? */ + ms->level--; /* undo capture */ + return res; +} + + +static const char *end_capture (MatchState *ms, const char *s, + const char *p) { + int l = capture_to_close(ms); + const char *res; + ms->capture[l].len = s - ms->capture[l].init; /* close capture */ + if ((res = match(ms, s, p)) == NULL) /* match failed? */ + ms->capture[l].len = CAP_UNFINISHED; /* undo capture */ + return res; +} + + +static const char *match_capture (MatchState *ms, const char *s, int l) { + size_t len; + l = check_capture(ms, l); + len = ms->capture[l].len; + if ((size_t)(ms->src_end-s) >= len && + memcmp(ms->capture[l].init, s, len) == 0) + return s+len; + else return NULL; +} + + +static const char *match (MatchState *ms, const char *s, const char *p) { + init: /* using goto's to optimize tail recursion */ + switch (*p) { + case '(': { /* start capture */ + if (*(p+1) == ')') /* position capture? */ + return start_capture(ms, s, p+2, CAP_POSITION); + else + return start_capture(ms, s, p+1, CAP_UNFINISHED); + } + case ')': { /* end capture */ + return end_capture(ms, s, p+1); + } + case L_ESC: { + switch (*(p+1)) { + case 'b': { /* balanced string? */ + s = matchbalance(ms, s, p+2); + if (s == NULL) return NULL; + p+=4; goto init; /* else return match(ms, s, p+4); */ + } + case 'f': { /* frontier? */ + const char *ep; char previous; + p += 2; + if (*p != '[') + luaL_error(ms->L, "missing " LUA_QL("[") " after " + LUA_QL("%%f") " in pattern"); + ep = classend(ms, p); /* points to what is next */ + previous = (s == ms->src_init) ? '\0' : *(s-1); + if (matchbracketclass(uchar(previous), p, ep-1) || + !matchbracketclass(uchar(*s), p, ep-1)) return NULL; + p=ep; goto init; /* else return match(ms, s, ep); */ + } + default: { + if (isdigit(uchar(*(p+1)))) { /* capture results (%0-%9)? */ + s = match_capture(ms, s, uchar(*(p+1))); + if (s == NULL) return NULL; + p+=2; goto init; /* else return match(ms, s, p+2) */ + } + goto dflt; /* case default */ + } + } + } + case '\0': { /* end of pattern */ + return s; /* match succeeded */ + } + case '$': { + if (*(p+1) == '\0') /* is the `$' the last char in pattern? */ + return (s == ms->src_end) ? s : NULL; /* check end of string */ + else goto dflt; + } + default: dflt: { /* it is a pattern item */ + const char *ep = classend(ms, p); /* points to what is next */ + int m = ssrc_end && singlematch(uchar(*s), p, ep); + switch (*ep) { + case '?': { /* optional */ + const char *res; + if (m && ((res=match(ms, s+1, ep+1)) != NULL)) + return res; + p=ep+1; goto init; /* else return match(ms, s, ep+1); */ + } + case '*': { /* 0 or more repetitions */ + return max_expand(ms, s, p, ep); + } + case '+': { /* 1 or more repetitions */ + return (m ? max_expand(ms, s+1, p, ep) : NULL); + } + case '-': { /* 0 or more repetitions (minimum) */ + return min_expand(ms, s, p, ep); + } + default: { + if (!m) return NULL; + s++; p=ep; goto init; /* else return match(ms, s+1, ep); */ + } + } + } + } +} + + + +static const char *lmemfind (const char *s1, size_t l1, + const char *s2, size_t l2) { + if (l2 == 0) return s1; /* empty strings are everywhere */ + else if (l2 > l1) return NULL; /* avoids a negative `l1' */ + else { + const char *init; /* to search for a `*s2' inside `s1' */ + l2--; /* 1st char will be checked by `memchr' */ + l1 = l1-l2; /* `s2' cannot be found after that */ + while (l1 > 0 && (init = (const char *)memchr(s1, *s2, l1)) != NULL) { + init++; /* 1st char is already checked */ + if (memcmp(init, s2+1, l2) == 0) + return init-1; + else { /* correct `l1' and `s1' to try again */ + l1 -= init-s1; + s1 = init; + } + } + return NULL; /* not found */ + } +} + + +static void push_onecapture (MatchState *ms, int i, const char *s, + const char *e) { + if (i >= ms->level) { + if (i == 0) /* ms->level == 0, too */ + lua_pushlstring(ms->L, s, e - s); /* add whole match */ + else + luaL_error(ms->L, "invalid capture index"); + } + else { + ptrdiff_t l = ms->capture[i].len; + if (l == CAP_UNFINISHED) luaL_error(ms->L, "unfinished capture"); + if (l == CAP_POSITION) + lua_pushinteger(ms->L, ms->capture[i].init - ms->src_init + 1); + else + lua_pushlstring(ms->L, ms->capture[i].init, l); + } +} + + +static int push_captures (MatchState *ms, const char *s, const char *e) { + int i; + int nlevels = (ms->level == 0 && s) ? 1 : ms->level; + luaL_checkstack(ms->L, nlevels, "too many captures"); + for (i = 0; i < nlevels; i++) + push_onecapture(ms, i, s, e); + return nlevels; /* number of strings pushed */ +} + + +static int str_find_aux (lua_State *L, int find) { + size_t l1, l2; + const char *s = luaL_checklstring(L, 1, &l1); + const char *p = luaL_checklstring(L, 2, &l2); + ptrdiff_t init = posrelat(luaL_optinteger(L, 3, 1), l1) - 1; + if (init < 0) init = 0; + else if ((size_t)(init) > l1) init = (ptrdiff_t)l1; + if (find && (lua_toboolean(L, 4) || /* explicit request? */ + strpbrk(p, SPECIALS) == NULL)) { /* or no special characters? */ + /* do a plain search */ + const char *s2 = lmemfind(s+init, l1-init, p, l2); + if (s2) { + lua_pushinteger(L, s2-s+1); + lua_pushinteger(L, s2-s+l2); + return 2; + } + } + else { + MatchState ms; + int anchor = (*p == '^') ? (p++, 1) : 0; + const char *s1=s+init; + ms.L = L; + ms.src_init = s; + ms.src_end = s+l1; + do { + const char *res; + ms.level = 0; + if ((res=match(&ms, s1, p)) != NULL) { + if (find) { + lua_pushinteger(L, s1-s+1); /* start */ + lua_pushinteger(L, res-s); /* end */ + return push_captures(&ms, NULL, 0) + 2; + } + else + return push_captures(&ms, s1, res); + } + } while (s1++ < ms.src_end && !anchor); + } + lua_pushnil(L); /* not found */ + return 1; +} + + +static int str_find (lua_State *L) { + return str_find_aux(L, 1); +} + + +static int str_match (lua_State *L) { + return str_find_aux(L, 0); +} + + +static int gmatch_aux (lua_State *L) { + MatchState ms; + size_t ls; + const char *s = lua_tolstring(L, lua_upvalueindex(1), &ls); + const char *p = lua_tostring(L, lua_upvalueindex(2)); + const char *src; + ms.L = L; + ms.src_init = s; + ms.src_end = s+ls; + for (src = s + (size_t)lua_tointeger(L, lua_upvalueindex(3)); + src <= ms.src_end; + src++) { + const char *e; + ms.level = 0; + if ((e = match(&ms, src, p)) != NULL) { + lua_Integer newstart = e-s; + if (e == src) newstart++; /* empty match? go at least one position */ + lua_pushinteger(L, newstart); + lua_replace(L, lua_upvalueindex(3)); + return push_captures(&ms, src, e); + } + } + return 0; /* not found */ +} + + +static int gmatch (lua_State *L) { + luaL_checkstring(L, 1); + luaL_checkstring(L, 2); + lua_settop(L, 2); + lua_pushinteger(L, 0); + lua_pushcclosure(L, gmatch_aux, 3); + return 1; +} + + +static int gfind_nodef (lua_State *L) { + return luaL_error(L, LUA_QL("string.gfind") " was renamed to " + LUA_QL("string.gmatch")); +} + + +static void add_s (MatchState *ms, luaL_Buffer *b, const char *s, + const char *e) { + size_t l, i; + const char *news = lua_tolstring(ms->L, 3, &l); + for (i = 0; i < l; i++) { + if (news[i] != L_ESC) + luaL_addchar(b, news[i]); + else { + i++; /* skip ESC */ + if (!isdigit(uchar(news[i]))) + luaL_addchar(b, news[i]); + else if (news[i] == '0') + luaL_addlstring(b, s, e - s); + else { + push_onecapture(ms, news[i] - '1', s, e); + luaL_addvalue(b); /* add capture to accumulated result */ + } + } + } +} + + +static void add_value (MatchState *ms, luaL_Buffer *b, const char *s, + const char *e) { + lua_State *L = ms->L; + switch (lua_type(L, 3)) { + case LUA_TNUMBER: + case LUA_TSTRING: { + add_s(ms, b, s, e); + return; + } + case LUA_TFUNCTION: { + int n; + lua_pushvalue(L, 3); + n = push_captures(ms, s, e); + lua_call(L, n, 1); + break; + } + case LUA_TTABLE: { + push_onecapture(ms, 0, s, e); + lua_gettable(L, 3); + break; + } + } + if (!lua_toboolean(L, -1)) { /* nil or false? */ + lua_pop(L, 1); + lua_pushlstring(L, s, e - s); /* keep original text */ + } + else if (!lua_isstring(L, -1)) + luaL_error(L, "invalid replacement value (a %s)", luaL_typename(L, -1)); + luaL_addvalue(b); /* add result to accumulator */ +} + + +static int str_gsub (lua_State *L) { + size_t srcl; + const char *src = luaL_checklstring(L, 1, &srcl); + const char *p = luaL_checkstring(L, 2); + int tr = lua_type(L, 3); + int max_s = luaL_optint(L, 4, srcl+1); + int anchor = (*p == '^') ? (p++, 1) : 0; + int n = 0; + MatchState ms; + luaL_Buffer b; + luaL_argcheck(L, tr == LUA_TNUMBER || tr == LUA_TSTRING || + tr == LUA_TFUNCTION || tr == LUA_TTABLE, 3, + "string/function/table expected"); + luaL_buffinit(L, &b); + ms.L = L; + ms.src_init = src; + ms.src_end = src+srcl; + while (n < max_s) { + const char *e; + ms.level = 0; + e = match(&ms, src, p); + if (e) { + n++; + add_value(&ms, &b, src, e); + } + if (e && e>src) /* non empty match? */ + src = e; /* skip it */ + else if (src < ms.src_end) + luaL_addchar(&b, *src++); + else break; + if (anchor) break; + } + luaL_addlstring(&b, src, ms.src_end-src); + luaL_pushresult(&b); + lua_pushinteger(L, n); /* number of substitutions */ + return 2; +} + +/* }====================================================== */ + + +/* maximum size of each formatted item (> len(format('%99.99f', -1e308))) */ +#define MAX_ITEM 512 +/* valid flags in a format specification */ +#define FLAGS "-+ #0" +/* +** maximum size of each format specification (such as '%-099.99d') +** (+10 accounts for %99.99x plus margin of error) +*/ +#define MAX_FORMAT (sizeof(FLAGS) + sizeof(LUA_INTFRMLEN) + 10) + + +static void addquoted (lua_State *L, luaL_Buffer *b, int arg) { + size_t l; + const char *s = luaL_checklstring(L, arg, &l); + luaL_addchar(b, '"'); + while (l--) { + switch (*s) { + case '"': case '\\': case '\n': { + luaL_addchar(b, '\\'); + luaL_addchar(b, *s); + break; + } + case '\r': { + luaL_addlstring(b, "\\r", 2); + break; + } + case '\0': { + luaL_addlstring(b, "\\000", 4); + break; + } + default: { + luaL_addchar(b, *s); + break; + } + } + s++; + } + luaL_addchar(b, '"'); +} + +static const char *scanformat (lua_State *L, const char *strfrmt, char *form) { + const char *p = strfrmt; + while (*p != '\0' && strchr(FLAGS, *p) != NULL) p++; /* skip flags */ + if ((size_t)(p - strfrmt) >= sizeof(FLAGS)) + luaL_error(L, "invalid format (repeated flags)"); + if (isdigit(uchar(*p))) p++; /* skip width */ + if (isdigit(uchar(*p))) p++; /* (2 digits at most) */ + if (*p == '.') { + p++; + if (isdigit(uchar(*p))) p++; /* skip precision */ + if (isdigit(uchar(*p))) p++; /* (2 digits at most) */ + } + if (isdigit(uchar(*p))) + luaL_error(L, "invalid format (width or precision too long)"); + *(form++) = '%'; + strncpy(form, strfrmt, p - strfrmt + 1); + form += p - strfrmt + 1; + *form = '\0'; + return p; +} + + +static void addintlen (char *form) { + size_t l = strlen(form); + char spec = form[l - 1]; + strcpy(form + l - 1, LUA_INTFRMLEN); + form[l + sizeof(LUA_INTFRMLEN) - 2] = spec; + form[l + sizeof(LUA_INTFRMLEN) - 1] = '\0'; +} + + +static int str_format (lua_State *L) { + int arg = 1; + size_t sfl; + const char *strfrmt = luaL_checklstring(L, arg, &sfl); + const char *strfrmt_end = strfrmt+sfl; + luaL_Buffer b; + luaL_buffinit(L, &b); + while (strfrmt < strfrmt_end) { + if (*strfrmt != L_ESC) + luaL_addchar(&b, *strfrmt++); + else if (*++strfrmt == L_ESC) + luaL_addchar(&b, *strfrmt++); /* %% */ + else { /* format item */ + char form[MAX_FORMAT]; /* to store the format (`%...') */ + char buff[MAX_ITEM]; /* to store the formatted item */ + arg++; + strfrmt = scanformat(L, strfrmt, form); + switch (*strfrmt++) { + case 'c': { + sprintf(buff, form, (int)luaL_checknumber(L, arg)); + break; + } + case 'd': case 'i': { + addintlen(form); + sprintf(buff, form, (LUA_INTFRM_T)luaL_checknumber(L, arg)); + break; + } + case 'o': case 'u': case 'x': case 'X': { + addintlen(form); + sprintf(buff, form, (unsigned LUA_INTFRM_T)luaL_checknumber(L, arg)); + break; + } + case 'e': case 'E': case 'f': + case 'g': case 'G': { + sprintf(buff, form, (double)luaL_checknumber(L, arg)); + break; + } + case 'q': { + addquoted(L, &b, arg); + continue; /* skip the 'addsize' at the end */ + } + case 's': { + size_t l; + const char *s = luaL_checklstring(L, arg, &l); + if (!strchr(form, '.') && l >= 100) { + /* no precision and string is too long to be formatted; + keep original string */ + lua_pushvalue(L, arg); + luaL_addvalue(&b); + continue; /* skip the `addsize' at the end */ + } + else { + sprintf(buff, form, s); + break; + } + } + default: { /* also treat cases `pnLlh' */ + return luaL_error(L, "invalid option " LUA_QL("%%%c") " to " + LUA_QL("format"), *(strfrmt - 1)); + } + } + luaL_addlstring(&b, buff, strlen(buff)); + } + } + luaL_pushresult(&b); + return 1; +} + + +static const luaL_Reg strlib[] = { + {"byte", str_byte}, + {"char", str_char}, + {"dump", str_dump}, + {"find", str_find}, + {"format", str_format}, + {"gfind", gfind_nodef}, + {"gmatch", gmatch}, + {"gsub", str_gsub}, + {"len", str_len}, + {"lower", str_lower}, + {"match", str_match}, + {"rep", str_rep}, + {"reverse", str_reverse}, + {"sub", str_sub}, + {"upper", str_upper}, + {NULL, NULL} +}; + + +static void createmetatable (lua_State *L) { + lua_createtable(L, 0, 1); /* create metatable for strings */ + lua_pushliteral(L, ""); /* dummy string */ + lua_pushvalue(L, -2); + lua_setmetatable(L, -2); /* set string metatable */ + lua_pop(L, 1); /* pop dummy string */ + lua_pushvalue(L, -2); /* string library... */ + lua_setfield(L, -2, "__index"); /* ...is the __index metamethod */ + lua_pop(L, 1); /* pop metatable */ +} + + +/* +** Open string library +*/ +LUALIB_API int luaopen_string (lua_State *L) { + luaL_register(L, LUA_STRLIBNAME, strlib); +#if defined(LUA_COMPAT_GFIND) + lua_getfield(L, -1, "gmatch"); + lua_setfield(L, -2, "gfind"); +#endif + createmetatable(L); + return 1; +} + diff --git a/include/lua/ltable.c b/include/lua/ltable.c new file mode 100644 index 0000000..ec84f4f --- /dev/null +++ b/include/lua/ltable.c @@ -0,0 +1,588 @@ +/* +** $Id: ltable.c,v 2.32.1.2 2007/12/28 15:32:23 roberto Exp $ +** Lua tables (hash) +** See Copyright Notice in lua.h +*/ + + +/* +** Implementation of tables (aka arrays, objects, or hash tables). +** Tables keep its elements in two parts: an array part and a hash part. +** Non-negative integer keys are all candidates to be kept in the array +** part. The actual size of the array is the largest `n' such that at +** least half the slots between 0 and n are in use. +** Hash uses a mix of chained scatter table with Brent's variation. +** A main invariant of these tables is that, if an element is not +** in its main position (i.e. the `original' position that its hash gives +** to it), then the colliding element is in its own main position. +** Hence even when the load factor reaches 100%, performance remains good. +*/ + +#include +#include + +#define ltable_c +#define LUA_CORE + +#include "lua.h" + +#include "ldebug.h" +#include "ldo.h" +#include "lgc.h" +#include "lmem.h" +#include "lobject.h" +#include "lstate.h" +#include "ltable.h" + + +/* +** max size of array part is 2^MAXBITS +*/ +#if LUAI_BITSINT > 26 +#define MAXBITS 26 +#else +#define MAXBITS (LUAI_BITSINT-2) +#endif + +#define MAXASIZE (1 << MAXBITS) + + +#define hashpow2(t,n) (gnode(t, lmod((n), sizenode(t)))) + +#define hashstr(t,str) hashpow2(t, (str)->tsv.hash) +#define hashboolean(t,p) hashpow2(t, p) + + +/* +** for some types, it is better to avoid modulus by power of 2, as +** they tend to have many 2 factors. +*/ +#define hashmod(t,n) (gnode(t, ((n) % ((sizenode(t)-1)|1)))) + + +#define hashpointer(t,p) hashmod(t, IntPoint(p)) + + +/* +** number of ints inside a lua_Number +*/ +#define numints cast_int(sizeof(lua_Number)/sizeof(int)) + + + +#define dummynode (&dummynode_) + +static const Node dummynode_ = { + {{NULL}, LUA_TNIL}, /* value */ + {{{NULL}, LUA_TNIL, NULL}} /* key */ +}; + + +/* +** hash for lua_Numbers +*/ +static Node *hashnum (const Table *t, lua_Number n) { + unsigned int a[numints]; + int i; + if (luai_numeq(n, 0)) /* avoid problems with -0 */ + return gnode(t, 0); + memcpy(a, &n, sizeof(a)); + for (i = 1; i < numints; i++) a[0] += a[i]; + return hashmod(t, a[0]); +} + + + +/* +** returns the `main' position of an element in a table (that is, the index +** of its hash value) +*/ +static Node *mainposition (const Table *t, const TValue *key) { + switch (ttype(key)) { + case LUA_TNUMBER: + return hashnum(t, nvalue(key)); + case LUA_TSTRING: + return hashstr(t, rawtsvalue(key)); + case LUA_TBOOLEAN: + return hashboolean(t, bvalue(key)); + case LUA_TLIGHTUSERDATA: + return hashpointer(t, pvalue(key)); + default: + return hashpointer(t, gcvalue(key)); + } +} + + +/* +** returns the index for `key' if `key' is an appropriate key to live in +** the array part of the table, -1 otherwise. +*/ +static int arrayindex (const TValue *key) { + if (ttisnumber(key)) { + lua_Number n = nvalue(key); + int k; + lua_number2int(k, n); + if (luai_numeq(cast_num(k), n)) + return k; + } + return -1; /* `key' did not match some condition */ +} + + +/* +** returns the index of a `key' for table traversals. First goes all +** elements in the array part, then elements in the hash part. The +** beginning of a traversal is signalled by -1. +*/ +static int findindex (lua_State *L, Table *t, StkId key) { + int i; + if (ttisnil(key)) return -1; /* first iteration */ + i = arrayindex(key); + if (0 < i && i <= t->sizearray) /* is `key' inside array part? */ + return i-1; /* yes; that's the index (corrected to C) */ + else { + Node *n = mainposition(t, key); + do { /* check whether `key' is somewhere in the chain */ + /* key may be dead already, but it is ok to use it in `next' */ + if (luaO_rawequalObj(key2tval(n), key) || + (ttype(gkey(n)) == LUA_TDEADKEY && iscollectable(key) && + gcvalue(gkey(n)) == gcvalue(key))) { + i = cast_int(n - gnode(t, 0)); /* key index in hash table */ + /* hash elements are numbered after array ones */ + return i + t->sizearray; + } + else n = gnext(n); + } while (n); + luaG_runerror(L, "invalid key to " LUA_QL("next")); /* key not found */ + return 0; /* to avoid warnings */ + } +} + + +int luaH_next (lua_State *L, Table *t, StkId key) { + int i = findindex(L, t, key); /* find original element */ + for (i++; i < t->sizearray; i++) { /* try first array part */ + if (!ttisnil(&t->array[i])) { /* a non-nil value? */ + setnvalue(key, cast_num(i+1)); + setobj2s(L, key+1, &t->array[i]); + return 1; + } + } + for (i -= t->sizearray; i < sizenode(t); i++) { /* then hash part */ + if (!ttisnil(gval(gnode(t, i)))) { /* a non-nil value? */ + setobj2s(L, key, key2tval(gnode(t, i))); + setobj2s(L, key+1, gval(gnode(t, i))); + return 1; + } + } + return 0; /* no more elements */ +} + + +/* +** {============================================================= +** Rehash +** ============================================================== +*/ + + +static int computesizes (int nums[], int *narray) { + int i; + int twotoi; /* 2^i */ + int a = 0; /* number of elements smaller than 2^i */ + int na = 0; /* number of elements to go to array part */ + int n = 0; /* optimal size for array part */ + for (i = 0, twotoi = 1; twotoi/2 < *narray; i++, twotoi *= 2) { + if (nums[i] > 0) { + a += nums[i]; + if (a > twotoi/2) { /* more than half elements present? */ + n = twotoi; /* optimal size (till now) */ + na = a; /* all elements smaller than n will go to array part */ + } + } + if (a == *narray) break; /* all elements already counted */ + } + *narray = n; + lua_assert(*narray/2 <= na && na <= *narray); + return na; +} + + +static int countint (const TValue *key, int *nums) { + int k = arrayindex(key); + if (0 < k && k <= MAXASIZE) { /* is `key' an appropriate array index? */ + nums[ceillog2(k)]++; /* count as such */ + return 1; + } + else + return 0; +} + + +static int numusearray (const Table *t, int *nums) { + int lg; + int ttlg; /* 2^lg */ + int ause = 0; /* summation of `nums' */ + int i = 1; /* count to traverse all array keys */ + for (lg=0, ttlg=1; lg<=MAXBITS; lg++, ttlg*=2) { /* for each slice */ + int lc = 0; /* counter */ + int lim = ttlg; + if (lim > t->sizearray) { + lim = t->sizearray; /* adjust upper limit */ + if (i > lim) + break; /* no more elements to count */ + } + /* count elements in range (2^(lg-1), 2^lg] */ + for (; i <= lim; i++) { + if (!ttisnil(&t->array[i-1])) + lc++; + } + nums[lg] += lc; + ause += lc; + } + return ause; +} + + +static int numusehash (const Table *t, int *nums, int *pnasize) { + int totaluse = 0; /* total number of elements */ + int ause = 0; /* summation of `nums' */ + int i = sizenode(t); + while (i--) { + Node *n = &t->node[i]; + if (!ttisnil(gval(n))) { + ause += countint(key2tval(n), nums); + totaluse++; + } + } + *pnasize += ause; + return totaluse; +} + + +static void setarrayvector (lua_State *L, Table *t, int size) { + int i; + luaM_reallocvector(L, t->array, t->sizearray, size, TValue); + for (i=t->sizearray; iarray[i]); + t->sizearray = size; +} + + +static void setnodevector (lua_State *L, Table *t, int size) { + int lsize; + if (size == 0) { /* no elements to hash part? */ + t->node = cast(Node *, dummynode); /* use common `dummynode' */ + lsize = 0; + } + else { + int i; + lsize = ceillog2(size); + if (lsize > MAXBITS) + luaG_runerror(L, "table overflow"); + size = twoto(lsize); + t->node = luaM_newvector(L, size, Node); + for (i=0; ilsizenode = cast_byte(lsize); + t->lastfree = gnode(t, size); /* all positions are free */ +} + + +static void resize (lua_State *L, Table *t, int nasize, int nhsize) { + int i; + int oldasize = t->sizearray; + int oldhsize = t->lsizenode; + Node *nold = t->node; /* save old hash ... */ + if (nasize > oldasize) /* array part must grow? */ + setarrayvector(L, t, nasize); + /* create new hash part with appropriate size */ + setnodevector(L, t, nhsize); + if (nasize < oldasize) { /* array part must shrink? */ + t->sizearray = nasize; + /* re-insert elements from vanishing slice */ + for (i=nasize; iarray[i])) + setobjt2t(L, luaH_setnum(L, t, i+1), &t->array[i]); + } + /* shrink array */ + luaM_reallocvector(L, t->array, oldasize, nasize, TValue); + } + /* re-insert elements from hash part */ + for (i = twoto(oldhsize) - 1; i >= 0; i--) { + Node *old = nold+i; + if (!ttisnil(gval(old))) + setobjt2t(L, luaH_set(L, t, key2tval(old)), gval(old)); + } + if (nold != dummynode) + luaM_freearray(L, nold, twoto(oldhsize), Node); /* free old array */ +} + + +void luaH_resizearray (lua_State *L, Table *t, int nasize) { + int nsize = (t->node == dummynode) ? 0 : sizenode(t); + resize(L, t, nasize, nsize); +} + + +static void rehash (lua_State *L, Table *t, const TValue *ek) { + int nasize, na; + int nums[MAXBITS+1]; /* nums[i] = number of keys between 2^(i-1) and 2^i */ + int i; + int totaluse; + for (i=0; i<=MAXBITS; i++) nums[i] = 0; /* reset counts */ + nasize = numusearray(t, nums); /* count keys in array part */ + totaluse = nasize; /* all those keys are integer keys */ + totaluse += numusehash(t, nums, &nasize); /* count keys in hash part */ + /* count extra key */ + nasize += countint(ek, nums); + totaluse++; + /* compute new size for array part */ + na = computesizes(nums, &nasize); + /* resize the table to new computed sizes */ + resize(L, t, nasize, totaluse - na); +} + + + +/* +** }============================================================= +*/ + + +Table *luaH_new (lua_State *L, int narray, int nhash) { + Table *t = luaM_new(L, Table); + luaC_link(L, obj2gco(t), LUA_TTABLE); + t->metatable = NULL; + t->flags = cast_byte(~0); + /* temporary values (kept only if some malloc fails) */ + t->array = NULL; + t->sizearray = 0; + t->lsizenode = 0; + t->node = cast(Node *, dummynode); + setarrayvector(L, t, narray); + setnodevector(L, t, nhash); + return t; +} + + +void luaH_free (lua_State *L, Table *t) { + if (t->node != dummynode) + luaM_freearray(L, t->node, sizenode(t), Node); + luaM_freearray(L, t->array, t->sizearray, TValue); + luaM_free(L, t); +} + + +static Node *getfreepos (Table *t) { + while (t->lastfree-- > t->node) { + if (ttisnil(gkey(t->lastfree))) + return t->lastfree; + } + return NULL; /* could not find a free place */ +} + + + +/* +** inserts a new key into a hash table; first, check whether key's main +** position is free. If not, check whether colliding node is in its main +** position or not: if it is not, move colliding node to an empty place and +** put new key in its main position; otherwise (colliding node is in its main +** position), new key goes to an empty position. +*/ +static TValue *newkey (lua_State *L, Table *t, const TValue *key) { + Node *mp = mainposition(t, key); + if (!ttisnil(gval(mp)) || mp == dummynode) { + Node *othern; + Node *n = getfreepos(t); /* get a free place */ + if (n == NULL) { /* cannot find a free place? */ + rehash(L, t, key); /* grow table */ + return luaH_set(L, t, key); /* re-insert key into grown table */ + } + lua_assert(n != dummynode); + othern = mainposition(t, key2tval(mp)); + if (othern != mp) { /* is colliding node out of its main position? */ + /* yes; move colliding node into free position */ + while (gnext(othern) != mp) othern = gnext(othern); /* find previous */ + gnext(othern) = n; /* redo the chain with `n' in place of `mp' */ + *n = *mp; /* copy colliding node into free pos. (mp->next also goes) */ + gnext(mp) = NULL; /* now `mp' is free */ + setnilvalue(gval(mp)); + } + else { /* colliding node is in its own main position */ + /* new node will go into free position */ + gnext(n) = gnext(mp); /* chain new position */ + gnext(mp) = n; + mp = n; + } + } + gkey(mp)->value = key->value; gkey(mp)->tt = key->tt; + luaC_barriert(L, t, key); + lua_assert(ttisnil(gval(mp))); + return gval(mp); +} + + +/* +** search function for integers +*/ +const TValue *luaH_getnum (Table *t, int key) { + /* (1 <= key && key <= t->sizearray) */ + if (cast(unsigned int, key-1) < cast(unsigned int, t->sizearray)) + return &t->array[key-1]; + else { + lua_Number nk = cast_num(key); + Node *n = hashnum(t, nk); + do { /* check whether `key' is somewhere in the chain */ + if (ttisnumber(gkey(n)) && luai_numeq(nvalue(gkey(n)), nk)) + return gval(n); /* that's it */ + else n = gnext(n); + } while (n); + return luaO_nilobject; + } +} + + +/* +** search function for strings +*/ +const TValue *luaH_getstr (Table *t, TString *key) { + Node *n = hashstr(t, key); + do { /* check whether `key' is somewhere in the chain */ + if (ttisstring(gkey(n)) && rawtsvalue(gkey(n)) == key) + return gval(n); /* that's it */ + else n = gnext(n); + } while (n); + return luaO_nilobject; +} + + +/* +** main search function +*/ +const TValue *luaH_get (Table *t, const TValue *key) { + switch (ttype(key)) { + case LUA_TNIL: return luaO_nilobject; + case LUA_TSTRING: return luaH_getstr(t, rawtsvalue(key)); + case LUA_TNUMBER: { + int k; + lua_Number n = nvalue(key); + lua_number2int(k, n); + if (luai_numeq(cast_num(k), nvalue(key))) /* index is int? */ + return luaH_getnum(t, k); /* use specialized version */ + /* else go through */ + } + default: { + Node *n = mainposition(t, key); + do { /* check whether `key' is somewhere in the chain */ + if (luaO_rawequalObj(key2tval(n), key)) + return gval(n); /* that's it */ + else n = gnext(n); + } while (n); + return luaO_nilobject; + } + } +} + + +TValue *luaH_set (lua_State *L, Table *t, const TValue *key) { + const TValue *p = luaH_get(t, key); + t->flags = 0; + if (p != luaO_nilobject) + return cast(TValue *, p); + else { + if (ttisnil(key)) luaG_runerror(L, "table index is nil"); + else if (ttisnumber(key) && luai_numisnan(nvalue(key))) + luaG_runerror(L, "table index is NaN"); + return newkey(L, t, key); + } +} + + +TValue *luaH_setnum (lua_State *L, Table *t, int key) { + const TValue *p = luaH_getnum(t, key); + if (p != luaO_nilobject) + return cast(TValue *, p); + else { + TValue k; + setnvalue(&k, cast_num(key)); + return newkey(L, t, &k); + } +} + + +TValue *luaH_setstr (lua_State *L, Table *t, TString *key) { + const TValue *p = luaH_getstr(t, key); + if (p != luaO_nilobject) + return cast(TValue *, p); + else { + TValue k; + setsvalue(L, &k, key); + return newkey(L, t, &k); + } +} + + +static int unbound_search (Table *t, unsigned int j) { + unsigned int i = j; /* i is zero or a present index */ + j++; + /* find `i' and `j' such that i is present and j is not */ + while (!ttisnil(luaH_getnum(t, j))) { + i = j; + j *= 2; + if (j > cast(unsigned int, MAX_INT)) { /* overflow? */ + /* table was built with bad purposes: resort to linear search */ + i = 1; + while (!ttisnil(luaH_getnum(t, i))) i++; + return i - 1; + } + } + /* now do a binary search between them */ + while (j - i > 1) { + unsigned int m = (i+j)/2; + if (ttisnil(luaH_getnum(t, m))) j = m; + else i = m; + } + return i; +} + + +/* +** Try to find a boundary in table `t'. A `boundary' is an integer index +** such that t[i] is non-nil and t[i+1] is nil (and 0 if t[1] is nil). +*/ +int luaH_getn (Table *t) { + unsigned int j = t->sizearray; + if (j > 0 && ttisnil(&t->array[j - 1])) { + /* there is a boundary in the array part: (binary) search for it */ + unsigned int i = 0; + while (j - i > 1) { + unsigned int m = (i+j)/2; + if (ttisnil(&t->array[m - 1])) j = m; + else i = m; + } + return i; + } + /* else must find a boundary in hash part */ + else if (t->node == dummynode) /* hash part is empty? */ + return j; /* that is easy... */ + else return unbound_search(t, j); +} + + + +#if defined(LUA_DEBUG) + +Node *luaH_mainposition (const Table *t, const TValue *key) { + return mainposition(t, key); +} + +int luaH_isdummy (Node *n) { return n == dummynode; } + +#endif diff --git a/include/lua/ltable.h b/include/lua/ltable.h new file mode 100644 index 0000000..f5b9d5e --- /dev/null +++ b/include/lua/ltable.h @@ -0,0 +1,40 @@ +/* +** $Id: ltable.h,v 2.10.1.1 2007/12/27 13:02:25 roberto Exp $ +** Lua tables (hash) +** See Copyright Notice in lua.h +*/ + +#ifndef ltable_h +#define ltable_h + +#include "lobject.h" + + +#define gnode(t,i) (&(t)->node[i]) +#define gkey(n) (&(n)->i_key.nk) +#define gval(n) (&(n)->i_val) +#define gnext(n) ((n)->i_key.nk.next) + +#define key2tval(n) (&(n)->i_key.tvk) + + +LUAI_FUNC const TValue *luaH_getnum (Table *t, int key); +LUAI_FUNC TValue *luaH_setnum (lua_State *L, Table *t, int key); +LUAI_FUNC const TValue *luaH_getstr (Table *t, TString *key); +LUAI_FUNC TValue *luaH_setstr (lua_State *L, Table *t, TString *key); +LUAI_FUNC const TValue *luaH_get (Table *t, const TValue *key); +LUAI_FUNC TValue *luaH_set (lua_State *L, Table *t, const TValue *key); +LUAI_FUNC Table *luaH_new (lua_State *L, int narray, int lnhash); +LUAI_FUNC void luaH_resizearray (lua_State *L, Table *t, int nasize); +LUAI_FUNC void luaH_free (lua_State *L, Table *t); +LUAI_FUNC int luaH_next (lua_State *L, Table *t, StkId key); +LUAI_FUNC int luaH_getn (Table *t); + + +#if defined(LUA_DEBUG) +LUAI_FUNC Node *luaH_mainposition (const Table *t, const TValue *key); +LUAI_FUNC int luaH_isdummy (Node *n); +#endif + + +#endif diff --git a/include/lua/ltablib.c b/include/lua/ltablib.c new file mode 100644 index 0000000..b6d9cb4 --- /dev/null +++ b/include/lua/ltablib.c @@ -0,0 +1,287 @@ +/* +** $Id: ltablib.c,v 1.38.1.3 2008/02/14 16:46:58 roberto Exp $ +** Library for Table Manipulation +** See Copyright Notice in lua.h +*/ + + +#include + +#define ltablib_c +#define LUA_LIB + +#include "lua.h" + +#include "lauxlib.h" +#include "lualib.h" + + +#define aux_getn(L,n) (luaL_checktype(L, n, LUA_TTABLE), luaL_getn(L, n)) + + +static int foreachi (lua_State *L) { + int i; + int n = aux_getn(L, 1); + luaL_checktype(L, 2, LUA_TFUNCTION); + for (i=1; i <= n; i++) { + lua_pushvalue(L, 2); /* function */ + lua_pushinteger(L, i); /* 1st argument */ + lua_rawgeti(L, 1, i); /* 2nd argument */ + lua_call(L, 2, 1); + if (!lua_isnil(L, -1)) + return 1; + lua_pop(L, 1); /* remove nil result */ + } + return 0; +} + + +static int foreach (lua_State *L) { + luaL_checktype(L, 1, LUA_TTABLE); + luaL_checktype(L, 2, LUA_TFUNCTION); + lua_pushnil(L); /* first key */ + while (lua_next(L, 1)) { + lua_pushvalue(L, 2); /* function */ + lua_pushvalue(L, -3); /* key */ + lua_pushvalue(L, -3); /* value */ + lua_call(L, 2, 1); + if (!lua_isnil(L, -1)) + return 1; + lua_pop(L, 2); /* remove value and result */ + } + return 0; +} + + +static int maxn (lua_State *L) { + lua_Number max = 0; + luaL_checktype(L, 1, LUA_TTABLE); + lua_pushnil(L); /* first key */ + while (lua_next(L, 1)) { + lua_pop(L, 1); /* remove value */ + if (lua_type(L, -1) == LUA_TNUMBER) { + lua_Number v = lua_tonumber(L, -1); + if (v > max) max = v; + } + } + lua_pushnumber(L, max); + return 1; +} + + +static int getn (lua_State *L) { + lua_pushinteger(L, aux_getn(L, 1)); + return 1; +} + + +static int setn (lua_State *L) { + luaL_checktype(L, 1, LUA_TTABLE); +#ifndef luaL_setn + luaL_setn(L, 1, luaL_checkint(L, 2)); +#else + luaL_error(L, LUA_QL("setn") " is obsolete"); +#endif + lua_pushvalue(L, 1); + return 1; +} + + +static int tinsert (lua_State *L) { + int e = aux_getn(L, 1) + 1; /* first empty element */ + int pos; /* where to insert new element */ + switch (lua_gettop(L)) { + case 2: { /* called with only 2 arguments */ + pos = e; /* insert new element at the end */ + break; + } + case 3: { + int i; + pos = luaL_checkint(L, 2); /* 2nd argument is the position */ + if (pos > e) e = pos; /* `grow' array if necessary */ + for (i = e; i > pos; i--) { /* move up elements */ + lua_rawgeti(L, 1, i-1); + lua_rawseti(L, 1, i); /* t[i] = t[i-1] */ + } + break; + } + default: { + return luaL_error(L, "wrong number of arguments to " LUA_QL("insert")); + } + } + luaL_setn(L, 1, e); /* new size */ + lua_rawseti(L, 1, pos); /* t[pos] = v */ + return 0; +} + + +static int tremove (lua_State *L) { + int e = aux_getn(L, 1); + int pos = luaL_optint(L, 2, e); + if (!(1 <= pos && pos <= e)) /* position is outside bounds? */ + return 0; /* nothing to remove */ + luaL_setn(L, 1, e - 1); /* t.n = n-1 */ + lua_rawgeti(L, 1, pos); /* result = t[pos] */ + for ( ;pos= P */ + while (lua_rawgeti(L, 1, ++i), sort_comp(L, -1, -2)) { + if (i>u) luaL_error(L, "invalid order function for sorting"); + lua_pop(L, 1); /* remove a[i] */ + } + /* repeat --j until a[j] <= P */ + while (lua_rawgeti(L, 1, --j), sort_comp(L, -3, -1)) { + if (j + +#define ltm_c +#define LUA_CORE + +#include "lua.h" + +#include "lobject.h" +#include "lstate.h" +#include "lstring.h" +#include "ltable.h" +#include "ltm.h" + + + +const char *const luaT_typenames[] = { + "nil", "boolean", "userdata", "number", + "string", "table", "function", "userdata", "thread", + "proto", "upval" +}; + + +void luaT_init (lua_State *L) { + static const char *const luaT_eventname[] = { /* ORDER TM */ + "__index", "__newindex", + "__gc", "__mode", "__eq", + "__add", "__sub", "__mul", "__div", "__mod", + "__pow", "__unm", "__len", "__lt", "__le", + "__concat", "__call" + }; + int i; + for (i=0; itmname[i] = luaS_new(L, luaT_eventname[i]); + luaS_fix(G(L)->tmname[i]); /* never collect these names */ + } +} + + +/* +** function to be used with macro "fasttm": optimized for absence of +** tag methods +*/ +const TValue *luaT_gettm (Table *events, TMS event, TString *ename) { + const TValue *tm = luaH_getstr(events, ename); + lua_assert(event <= TM_EQ); + if (ttisnil(tm)) { /* no tag method? */ + events->flags |= cast_byte(1u<metatable; + break; + case LUA_TUSERDATA: + mt = uvalue(o)->metatable; + break; + default: + mt = G(L)->mt[ttype(o)]; + } + return (mt ? luaH_getstr(mt, G(L)->tmname[event]) : luaO_nilobject); +} + diff --git a/include/lua/ltm.h b/include/lua/ltm.h new file mode 100644 index 0000000..64343b7 --- /dev/null +++ b/include/lua/ltm.h @@ -0,0 +1,54 @@ +/* +** $Id: ltm.h,v 2.6.1.1 2007/12/27 13:02:25 roberto Exp $ +** Tag methods +** See Copyright Notice in lua.h +*/ + +#ifndef ltm_h +#define ltm_h + + +#include "lobject.h" + + +/* +* WARNING: if you change the order of this enumeration, +* grep "ORDER TM" +*/ +typedef enum { + TM_INDEX, + TM_NEWINDEX, + TM_GC, + TM_MODE, + TM_EQ, /* last tag method with `fast' access */ + TM_ADD, + TM_SUB, + TM_MUL, + TM_DIV, + TM_MOD, + TM_POW, + TM_UNM, + TM_LEN, + TM_LT, + TM_LE, + TM_CONCAT, + TM_CALL, + TM_N /* number of elements in the enum */ +} TMS; + + + +#define gfasttm(g,et,e) ((et) == NULL ? NULL : \ + ((et)->flags & (1u<<(e))) ? NULL : luaT_gettm(et, e, (g)->tmname[e])) + +#define fasttm(l,et,e) gfasttm(G(l), et, e) + +LUAI_DATA const char *const luaT_typenames[]; + + +LUAI_FUNC const TValue *luaT_gettm (Table *events, TMS event, TString *ename); +LUAI_FUNC const TValue *luaT_gettmbyobj (lua_State *L, const TValue *o, + TMS event); +LUAI_FUNC void luaT_init (lua_State *L); + +#endif diff --git a/include/lua/lua.c b/include/lua/lua.c new file mode 100644 index 0000000..c28c8c0 --- /dev/null +++ b/include/lua/lua.c @@ -0,0 +1,391 @@ +/* +** $Id: lua.c,v 1.160.1.2 2007/12/28 15:32:23 roberto Exp $ +** Lua stand-alone interpreter +** See Copyright Notice in lua.h +*/ + + +#include +#include +#include +#include + +#define lua_c + +#include "lua.h" + +#include "lauxlib.h" +#include "lualib.h" + + + +static lua_State *globalL = NULL; + +static const char *progname = LUA_PROGNAME; + + + +static void lstop (lua_State *L, lua_Debug *ar) { + (void)ar; /* unused arg. */ + lua_sethook(L, NULL, 0, 0); + luaL_error(L, "interrupted!"); +} + + +static void laction (int i) { + signal(i, SIG_DFL); /* if another SIGINT happens before lstop, + terminate process (default action) */ + lua_sethook(globalL, lstop, LUA_MASKCALL | LUA_MASKRET | LUA_MASKCOUNT, 1); +} + + +static void print_usage (void) { + fprintf(stderr, + "usage: %s [options] [script [args]].\n" + "Available options are:\n" + " -e stat execute string " LUA_QL("stat") "\n" + " -l name require library " LUA_QL("name") "\n" + " -i enter interactive mode after executing " LUA_QL("script") "\n" + " -v show version information\n" + " -- stop handling options\n" + " - execute stdin and stop handling options\n" + , + progname); + fflush(stderr); +} + + +static void l_message (const char *pname, const char *msg) { + if (pname) fprintf(stderr, "%s: ", pname); + fprintf(stderr, "%s\n", msg); + fflush(stderr); +} + + +static int report (lua_State *L, int status) { + if (status && !lua_isnil(L, -1)) { + const char *msg = lua_tostring(L, -1); + if (msg == NULL) msg = "(error object is not a string)"; + l_message(progname, msg); + lua_pop(L, 1); + } + return status; +} + + +static int traceback (lua_State *L) { + if (!lua_isstring(L, 1)) /* 'message' not a string? */ + return 1; /* keep it intact */ + lua_getfield(L, LUA_GLOBALSINDEX, "debug"); + if (!lua_istable(L, -1)) { + lua_pop(L, 1); + return 1; + } + lua_getfield(L, -1, "traceback"); + if (!lua_isfunction(L, -1)) { + lua_pop(L, 2); + return 1; + } + lua_pushvalue(L, 1); /* pass error message */ + lua_pushinteger(L, 2); /* skip this function and traceback */ + lua_call(L, 2, 1); /* call debug.traceback */ + return 1; +} + + +static int docall (lua_State *L, int narg, int clear) { + int status; + int base = lua_gettop(L) - narg; /* function index */ + lua_pushcfunction(L, traceback); /* push traceback function */ + lua_insert(L, base); /* put it under chunk and args */ + signal(SIGINT, laction); + status = lua_pcall(L, narg, (clear ? 0 : LUA_MULTRET), base); + signal(SIGINT, SIG_DFL); + lua_remove(L, base); /* remove traceback function */ + /* force a complete garbage collection in case of errors */ + if (status != 0) lua_gc(L, LUA_GCCOLLECT, 0); + return status; +} + + +static void print_version (void) { + l_message(NULL, LUA_RELEASE " " LUA_COPYRIGHT); +} + + +static int getargs (lua_State *L, char **argv, int n) { + int narg; + int i; + int argc = 0; + while (argv[argc]) argc++; /* count total number of arguments */ + narg = argc - (n + 1); /* number of arguments to the script */ + luaL_checkstack(L, narg + 3, "too many arguments to script"); + for (i=n+1; i < argc; i++) + lua_pushstring(L, argv[i]); + lua_createtable(L, narg, n + 1); + for (i=0; i < argc; i++) { + lua_pushstring(L, argv[i]); + lua_rawseti(L, -2, i - n); + } + return narg; +} + + +static int dofile (lua_State *L, const char *name) { + int status = luaL_loadfile(L, name) || docall(L, 0, 1); + return report(L, status); +} + + +static int dostring (lua_State *L, const char *s, const char *name) { + int status = luaL_loadbuffer(L, s, strlen(s), name) || docall(L, 0, 1); + return report(L, status); +} + + +static int dolibrary (lua_State *L, const char *name) { + lua_getglobal(L, "require"); + lua_pushstring(L, name); + return report(L, docall(L, 1, 1)); +} + + +static const char *get_prompt (lua_State *L, int firstline) { + const char *p; + lua_getfield(L, LUA_GLOBALSINDEX, firstline ? "_PROMPT" : "_PROMPT2"); + p = lua_tostring(L, -1); + if (p == NULL) p = (firstline ? LUA_PROMPT : LUA_PROMPT2); + lua_pop(L, 1); /* remove global */ + return p; +} + + +static int incomplete (lua_State *L, int status) { + if (status == LUA_ERRSYNTAX) { + size_t lmsg; + const char *msg = lua_tolstring(L, -1, &lmsg); + const char *tp = msg + lmsg - (sizeof(LUA_QL("")) - 1); + if (strstr(msg, LUA_QL("")) == tp) { + lua_pop(L, 1); + return 1; + } + } + return 0; /* else... */ +} + + +static int pushline (lua_State *L, int firstline) { + char buffer[LUA_MAXINPUT]; + char *b = buffer; + size_t l; + const char *prmt = get_prompt(L, firstline); + if (lua_readline(L, b, prmt) == 0) + return 0; /* no input */ + l = strlen(b); + if (l > 0 && b[l-1] == '\n') /* line ends with newline? */ + b[l-1] = '\0'; /* remove it */ + if (firstline && b[0] == '=') /* first line starts with `=' ? */ + lua_pushfstring(L, "return %s", b+1); /* change it to `return' */ + else + lua_pushstring(L, b); + lua_freeline(L, b); + return 1; +} + + +static int loadline (lua_State *L) { + int status; + lua_settop(L, 0); + if (!pushline(L, 1)) + return -1; /* no input */ + for (;;) { /* repeat until gets a complete line */ + status = luaL_loadbuffer(L, lua_tostring(L, 1), lua_strlen(L, 1), "=stdin"); + if (!incomplete(L, status)) break; /* cannot try to add lines? */ + if (!pushline(L, 0)) /* no more input? */ + return -1; + lua_pushliteral(L, "\n"); /* add a new line... */ + lua_insert(L, -2); /* ...between the two lines */ + lua_concat(L, 3); /* join them */ + } + lua_saveline(L, 1); + lua_remove(L, 1); /* remove line */ + return status; +} + + +static void dotty (lua_State *L) { + int status; + const char *oldprogname = progname; + progname = NULL; + while ((status = loadline(L)) != -1) { + if (status == 0) status = docall(L, 0, 0); + report(L, status); + if (status == 0 && lua_gettop(L) > 0) { /* any result to print? */ + lua_getglobal(L, "print"); + lua_insert(L, 1); + if (lua_pcall(L, lua_gettop(L)-1, 0, 0) != 0) + l_message(progname, lua_pushfstring(L, + "error calling " LUA_QL("print") " (%s)", + lua_tostring(L, -1))); + } + } + lua_settop(L, 0); /* clear stack */ + fputs("\n", stdout); + fflush(stdout); + progname = oldprogname; +} + + +static int handle_script (lua_State *L, char **argv, int n) { + int status; + const char *fname; + int narg = getargs(L, argv, n); /* collect arguments */ + lua_setglobal(L, "arg"); + fname = argv[n]; + if (strcmp(fname, "-") == 0 && strcmp(argv[n-1], "--") != 0) + fname = NULL; /* stdin */ + status = luaL_loadfile(L, fname); + lua_insert(L, -(narg+1)); + if (status == 0) + status = docall(L, narg, 0); + else + lua_pop(L, narg); + return report(L, status); +} + + +/* check that argument has no extra characters at the end */ +#define notail(x) {if ((x)[2] != '\0') return -1;} + + +static int collectargs (char **argv, int *pi, int *pv, int *pe) { + int i; + for (i = 1; argv[i] != NULL; i++) { + if (argv[i][0] != '-') /* not an option? */ + return i; + switch (argv[i][1]) { /* option */ + case '-': + notail(argv[i]); + return (argv[i+1] != NULL ? i+1 : 0); + case '\0': + return i; + case 'i': + notail(argv[i]); + *pi = 1; /* go through */ + case 'v': + notail(argv[i]); + *pv = 1; + break; + case 'e': + *pe = 1; /* go through */ + case 'l': + if (argv[i][2] == '\0') { + i++; + if (argv[i] == NULL) return -1; + } + break; + default: return -1; /* invalid option */ + } + } + return 0; +} + + +static int runargs (lua_State *L, char **argv, int n) { + int i; + for (i = 1; i < n; i++) { + if (argv[i] == NULL) continue; + lua_assert(argv[i][0] == '-'); + switch (argv[i][1]) { /* option */ + case 'e': { + const char *chunk = argv[i] + 2; + if (*chunk == '\0') chunk = argv[++i]; + lua_assert(chunk != NULL); + if (dostring(L, chunk, "=(command line)") != 0) + return 1; + break; + } + case 'l': { + const char *filename = argv[i] + 2; + if (*filename == '\0') filename = argv[++i]; + lua_assert(filename != NULL); + if (dolibrary(L, filename)) + return 1; /* stop if file fails */ + break; + } + default: break; + } + } + return 0; +} + + +static int handle_luainit (lua_State *L) { + const char *init = getenv(LUA_INIT); + if (init == NULL) return 0; /* status OK */ + else if (init[0] == '@') + return dofile(L, init+1); + else + return dostring(L, init, "=" LUA_INIT); +} + + +struct Smain { + int argc; + char **argv; + int status; +}; + + +static int pmain (lua_State *L) { + struct Smain *s = (struct Smain *)lua_touserdata(L, 1); + char **argv = s->argv; + int script; + int has_i = 0, has_v = 0, has_e = 0; + globalL = L; + if (argv[0] && argv[0][0]) progname = argv[0]; + lua_gc(L, LUA_GCSTOP, 0); /* stop collector during initialization */ + luaL_openlibs(L); /* open libraries */ + lua_gc(L, LUA_GCRESTART, 0); + s->status = handle_luainit(L); + if (s->status != 0) return 0; + script = collectargs(argv, &has_i, &has_v, &has_e); + if (script < 0) { /* invalid args? */ + print_usage(); + s->status = 1; + return 0; + } + if (has_v) print_version(); + s->status = runargs(L, argv, (script > 0) ? script : s->argc); + if (s->status != 0) return 0; + if (script) + s->status = handle_script(L, argv, script); + if (s->status != 0) return 0; + if (has_i) + dotty(L); + else if (script == 0 && !has_e && !has_v) { + if (lua_stdin_is_tty()) { + print_version(); + dotty(L); + } + else dofile(L, NULL); /* executes stdin as a file */ + } + return 0; +} + +int main (int argc, char **argv) { + int status; + struct Smain s; + lua_State *L = lua_open(); /* create state */ + if (L == NULL) { + l_message(argv[0], "cannot create state: not enough memory"); + return EXIT_FAILURE; + } + s.argc = argc; + s.argv = argv; + status = lua_cpcall(L, &pmain, &s); + report(L, status); + lua_close(L); + return (status || s.status) ? EXIT_FAILURE : EXIT_SUCCESS; +} + diff --git a/include/lua/lua.h b/include/lua/lua.h new file mode 100644 index 0000000..e4bdfd3 --- /dev/null +++ b/include/lua/lua.h @@ -0,0 +1,388 @@ +/* +** $Id: lua.h,v 1.218.1.5 2008/08/06 13:30:12 roberto Exp $ +** Lua - An Extensible Extension Language +** Lua.org, PUC-Rio, Brazil (http://www.lua.org) +** See Copyright Notice at the end of this file +*/ + + +#ifndef lua_h +#define lua_h + +#include +#include + + +#include "luaconf.h" + + +#define LUA_VERSION "Lua 5.1" +#define LUA_RELEASE "Lua 5.1.4" +#define LUA_VERSION_NUM 501 +#define LUA_COPYRIGHT "Copyright (C) 1994-2008 Lua.org, PUC-Rio" +#define LUA_AUTHORS "R. Ierusalimschy, L. H. de Figueiredo & W. Celes" + + +/* mark for precompiled code (`Lua') */ +#define LUA_SIGNATURE "\033Lua" + +/* option for multiple returns in `lua_pcall' and `lua_call' */ +#define LUA_MULTRET (-1) + + +/* +** pseudo-indices +*/ +#define LUA_REGISTRYINDEX (-10000) +#define LUA_ENVIRONINDEX (-10001) +#define LUA_GLOBALSINDEX (-10002) +#define lua_upvalueindex(i) (LUA_GLOBALSINDEX-(i)) + + +/* thread status; 0 is OK */ +#define LUA_YIELD 1 +#define LUA_ERRRUN 2 +#define LUA_ERRSYNTAX 3 +#define LUA_ERRMEM 4 +#define LUA_ERRERR 5 + + +typedef struct lua_State lua_State; + +typedef int (*lua_CFunction) (lua_State *L); + + +/* +** functions that read/write blocks when loading/dumping Lua chunks +*/ +typedef const char * (*lua_Reader) (lua_State *L, void *ud, size_t *sz); + +typedef int (*lua_Writer) (lua_State *L, const void* p, size_t sz, void* ud); + + +/* +** prototype for memory-allocation functions +*/ +typedef void * (*lua_Alloc) (void *ud, void *ptr, size_t osize, size_t nsize); + + +/* +** basic types +*/ +#define LUA_TNONE (-1) + +#define LUA_TNIL 0 +#define LUA_TBOOLEAN 1 +#define LUA_TLIGHTUSERDATA 2 +#define LUA_TNUMBER 3 +#define LUA_TSTRING 4 +#define LUA_TTABLE 5 +#define LUA_TFUNCTION 6 +#define LUA_TUSERDATA 7 +#define LUA_TTHREAD 8 + + + +/* minimum Lua stack available to a C function */ +#define LUA_MINSTACK 20 + + +/* +** generic extra include file +*/ +#if defined(LUA_USER_H) +#include LUA_USER_H +#endif + + +/* type of numbers in Lua */ +typedef LUA_NUMBER lua_Number; + + +/* type for integer functions */ +typedef LUA_INTEGER lua_Integer; + + + +/* +** state manipulation +*/ +LUA_API lua_State *(lua_newstate) (lua_Alloc f, void *ud); +LUA_API void (lua_close) (lua_State *L); +LUA_API lua_State *(lua_newthread) (lua_State *L); + +LUA_API lua_CFunction (lua_atpanic) (lua_State *L, lua_CFunction panicf); + + +/* +** basic stack manipulation +*/ +LUA_API int (lua_gettop) (lua_State *L); +LUA_API void (lua_settop) (lua_State *L, int idx); +LUA_API void (lua_pushvalue) (lua_State *L, int idx); +LUA_API void (lua_remove) (lua_State *L, int idx); +LUA_API void (lua_insert) (lua_State *L, int idx); +LUA_API void (lua_replace) (lua_State *L, int idx); +LUA_API int (lua_checkstack) (lua_State *L, int sz); + +LUA_API void (lua_xmove) (lua_State *from, lua_State *to, int n); + + +/* +** access functions (stack -> C) +*/ + +LUA_API int (lua_isnumber) (lua_State *L, int idx); +LUA_API int (lua_isstring) (lua_State *L, int idx); +LUA_API int (lua_iscfunction) (lua_State *L, int idx); +LUA_API int (lua_isuserdata) (lua_State *L, int idx); +LUA_API int (lua_type) (lua_State *L, int idx); +LUA_API const char *(lua_typename) (lua_State *L, int tp); + +LUA_API int (lua_equal) (lua_State *L, int idx1, int idx2); +LUA_API int (lua_rawequal) (lua_State *L, int idx1, int idx2); +LUA_API int (lua_lessthan) (lua_State *L, int idx1, int idx2); + +LUA_API lua_Number (lua_tonumber) (lua_State *L, int idx); +LUA_API lua_Integer (lua_tointeger) (lua_State *L, int idx); +LUA_API int (lua_toboolean) (lua_State *L, int idx); +LUA_API const char *(lua_tolstring) (lua_State *L, int idx, size_t *len); +LUA_API size_t (lua_objlen) (lua_State *L, int idx); +LUA_API lua_CFunction (lua_tocfunction) (lua_State *L, int idx); +LUA_API void *(lua_touserdata) (lua_State *L, int idx); +LUA_API lua_State *(lua_tothread) (lua_State *L, int idx); +LUA_API const void *(lua_topointer) (lua_State *L, int idx); + + +/* +** push functions (C -> stack) +*/ +LUA_API void (lua_pushnil) (lua_State *L); +LUA_API void (lua_pushnumber) (lua_State *L, lua_Number n); +LUA_API void (lua_pushinteger) (lua_State *L, lua_Integer n); +LUA_API void (lua_pushlstring) (lua_State *L, const char *s, size_t l); +LUA_API void (lua_pushstring) (lua_State *L, const char *s); +LUA_API const char *(lua_pushvfstring) (lua_State *L, const char *fmt, + va_list argp); +LUA_API const char *(lua_pushfstring) (lua_State *L, const char *fmt, ...); +LUA_API void (lua_pushcclosure) (lua_State *L, lua_CFunction fn, int n); +LUA_API void (lua_pushboolean) (lua_State *L, int b); +LUA_API void (lua_pushlightuserdata) (lua_State *L, void *p); +LUA_API int (lua_pushthread) (lua_State *L); + + +/* +** get functions (Lua -> stack) +*/ +LUA_API void (lua_gettable) (lua_State *L, int idx); +LUA_API void (lua_getfield) (lua_State *L, int idx, const char *k); +LUA_API void (lua_rawget) (lua_State *L, int idx); +LUA_API void (lua_rawgeti) (lua_State *L, int idx, int n); +LUA_API void (lua_createtable) (lua_State *L, int narr, int nrec); +LUA_API void *(lua_newuserdata) (lua_State *L, size_t sz); +LUA_API int (lua_getmetatable) (lua_State *L, int objindex); +LUA_API void (lua_getfenv) (lua_State *L, int idx); + + +/* +** set functions (stack -> Lua) +*/ +LUA_API void (lua_settable) (lua_State *L, int idx); +LUA_API void (lua_setfield) (lua_State *L, int idx, const char *k); +LUA_API void (lua_rawset) (lua_State *L, int idx); +LUA_API void (lua_rawseti) (lua_State *L, int idx, int n); +LUA_API int (lua_setmetatable) (lua_State *L, int objindex); +LUA_API int (lua_setfenv) (lua_State *L, int idx); + + +/* +** `load' and `call' functions (load and run Lua code) +*/ +LUA_API void (lua_call) (lua_State *L, int nargs, int nresults); +LUA_API int (lua_pcall) (lua_State *L, int nargs, int nresults, int errfunc); +LUA_API int (lua_cpcall) (lua_State *L, lua_CFunction func, void *ud); +LUA_API int (lua_load) (lua_State *L, lua_Reader reader, void *dt, + const char *chunkname); + +LUA_API int (lua_dump) (lua_State *L, lua_Writer writer, void *data); + + +/* +** coroutine functions +*/ +LUA_API int (lua_yield) (lua_State *L, int nresults); +LUA_API int (lua_resume) (lua_State *L, int narg); +LUA_API int (lua_status) (lua_State *L); + +/* +** garbage-collection function and options +*/ + +#define LUA_GCSTOP 0 +#define LUA_GCRESTART 1 +#define LUA_GCCOLLECT 2 +#define LUA_GCCOUNT 3 +#define LUA_GCCOUNTB 4 +#define LUA_GCSTEP 5 +#define LUA_GCSETPAUSE 6 +#define LUA_GCSETSTEPMUL 7 + +LUA_API int (lua_gc) (lua_State *L, int what, int data); + + +/* +** miscellaneous functions +*/ + +LUA_API int (lua_error) (lua_State *L); + +LUA_API int (lua_next) (lua_State *L, int idx); + +LUA_API void (lua_concat) (lua_State *L, int n); + +LUA_API lua_Alloc (lua_getallocf) (lua_State *L, void **ud); +LUA_API void lua_setallocf (lua_State *L, lua_Alloc f, void *ud); + + + +/* +** =============================================================== +** some useful macros +** =============================================================== +*/ + +#define lua_pop(L,n) lua_settop(L, -(n)-1) + +#define lua_newtable(L) lua_createtable(L, 0, 0) + +#define lua_register(L,n,f) (lua_pushcfunction(L, (f)), lua_setglobal(L, (n))) + +#define lua_pushcfunction(L,f) lua_pushcclosure(L, (f), 0) + +#define lua_strlen(L,i) lua_objlen(L, (i)) + +#define lua_isfunction(L,n) (lua_type(L, (n)) == LUA_TFUNCTION) +#define lua_istable(L,n) (lua_type(L, (n)) == LUA_TTABLE) +#define lua_islightuserdata(L,n) (lua_type(L, (n)) == LUA_TLIGHTUSERDATA) +#define lua_isnil(L,n) (lua_type(L, (n)) == LUA_TNIL) +#define lua_isboolean(L,n) (lua_type(L, (n)) == LUA_TBOOLEAN) +#define lua_isthread(L,n) (lua_type(L, (n)) == LUA_TTHREAD) +#define lua_isnone(L,n) (lua_type(L, (n)) == LUA_TNONE) +#define lua_isnoneornil(L, n) (lua_type(L, (n)) <= 0) + +#define lua_pushliteral(L, s) \ + lua_pushlstring(L, "" s, (sizeof(s)/sizeof(char))-1) + +#define lua_setglobal(L,s) lua_setfield(L, LUA_GLOBALSINDEX, (s)) +#define lua_getglobal(L,s) lua_getfield(L, LUA_GLOBALSINDEX, (s)) + +#define lua_tostring(L,i) lua_tolstring(L, (i), NULL) + + + +/* +** compatibility macros and functions +*/ + +#define lua_open() luaL_newstate() + +#define lua_getregistry(L) lua_pushvalue(L, LUA_REGISTRYINDEX) + +#define lua_getgccount(L) lua_gc(L, LUA_GCCOUNT, 0) + +#define lua_Chunkreader lua_Reader +#define lua_Chunkwriter lua_Writer + + +/* hack */ +LUA_API void lua_setlevel (lua_State *from, lua_State *to); + + +/* +** {====================================================================== +** Debug API +** ======================================================================= +*/ + + +/* +** Event codes +*/ +#define LUA_HOOKCALL 0 +#define LUA_HOOKRET 1 +#define LUA_HOOKLINE 2 +#define LUA_HOOKCOUNT 3 +#define LUA_HOOKTAILRET 4 + + +/* +** Event masks +*/ +#define LUA_MASKCALL (1 << LUA_HOOKCALL) +#define LUA_MASKRET (1 << LUA_HOOKRET) +#define LUA_MASKLINE (1 << LUA_HOOKLINE) +#define LUA_MASKCOUNT (1 << LUA_HOOKCOUNT) + +typedef struct lua_Debug lua_Debug; /* activation record */ + + +/* Functions to be called by the debuger in specific events */ +typedef void (*lua_Hook) (lua_State *L, lua_Debug *ar); + + +LUA_API int lua_getstack (lua_State *L, int level, lua_Debug *ar); +LUA_API int lua_getinfo (lua_State *L, const char *what, lua_Debug *ar); +LUA_API const char *lua_getlocal (lua_State *L, const lua_Debug *ar, int n); +LUA_API const char *lua_setlocal (lua_State *L, const lua_Debug *ar, int n); +LUA_API const char *lua_getupvalue (lua_State *L, int funcindex, int n); +LUA_API const char *lua_setupvalue (lua_State *L, int funcindex, int n); + +LUA_API int lua_sethook (lua_State *L, lua_Hook func, int mask, int count); +LUA_API lua_Hook lua_gethook (lua_State *L); +LUA_API int lua_gethookmask (lua_State *L); +LUA_API int lua_gethookcount (lua_State *L); + + +struct lua_Debug { + int event; + const char *name; /* (n) */ + const char *namewhat; /* (n) `global', `local', `field', `method' */ + const char *what; /* (S) `Lua', `C', `main', `tail' */ + const char *source; /* (S) */ + int currentline; /* (l) */ + int nups; /* (u) number of upvalues */ + int linedefined; /* (S) */ + int lastlinedefined; /* (S) */ + char short_src[LUA_IDSIZE]; /* (S) */ + /* private part */ + int i_ci; /* active function */ +}; + +/* }====================================================================== */ + + +/****************************************************************************** +* Copyright (C) 1994-2008 Lua.org, PUC-Rio. All rights reserved. +* +* Permission is hereby granted, free of charge, to any person obtaining +* a copy of this software and associated documentation files (the +* "Software"), to deal in the Software without restriction, including +* without limitation the rights to use, copy, modify, merge, publish, +* distribute, sublicense, and/or sell copies of the Software, and to +* permit persons to whom the Software is furnished to do so, subject to +* the following conditions: +* +* The above copyright notice and this permission notice shall be +* included in all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +******************************************************************************/ + + +#endif diff --git a/include/lua/luac.c b/include/lua/luac.c new file mode 100644 index 0000000..d070173 --- /dev/null +++ b/include/lua/luac.c @@ -0,0 +1,200 @@ +/* +** $Id: luac.c,v 1.54 2006/06/02 17:37:11 lhf Exp $ +** Lua compiler (saves bytecodes to files; also list bytecodes) +** See Copyright Notice in lua.h +*/ + +#include +#include +#include +#include + +#define luac_c +#define LUA_CORE + +#include "lua.h" +#include "lauxlib.h" + +#include "ldo.h" +#include "lfunc.h" +#include "lmem.h" +#include "lobject.h" +#include "lopcodes.h" +#include "lstring.h" +#include "lundump.h" + +#define PROGNAME "luac" /* default program name */ +#define OUTPUT PROGNAME ".out" /* default output file */ + +static int listing=0; /* list bytecodes? */ +static int dumping=1; /* dump bytecodes? */ +static int stripping=0; /* strip debug information? */ +static char Output[]={ OUTPUT }; /* default output file name */ +static const char* output=Output; /* actual output file name */ +static const char* progname=PROGNAME; /* actual program name */ + +static void fatal(const char* message) +{ + fprintf(stderr,"%s: %s\n",progname,message); + exit(EXIT_FAILURE); +} + +static void cannot(const char* what) +{ + fprintf(stderr,"%s: cannot %s %s: %s\n",progname,what,output,strerror(errno)); + exit(EXIT_FAILURE); +} + +static void usage(const char* message) +{ + if (*message=='-') + fprintf(stderr,"%s: unrecognized option " LUA_QS "\n",progname,message); + else + fprintf(stderr,"%s: %s\n",progname,message); + fprintf(stderr, + "usage: %s [options] [filenames].\n" + "Available options are:\n" + " - process stdin\n" + " -l list\n" + " -o name output to file " LUA_QL("name") " (default is \"%s\")\n" + " -p parse only\n" + " -s strip debug information\n" + " -v show version information\n" + " -- stop handling options\n", + progname,Output); + exit(EXIT_FAILURE); +} + +#define IS(s) (strcmp(argv[i],s)==0) + +static int doargs(int argc, char* argv[]) +{ + int i; + int version=0; + if (argv[0]!=NULL && *argv[0]!=0) progname=argv[0]; + for (i=1; itop+(i))->l.p) + +static const Proto* combine(lua_State* L, int n) +{ + if (n==1) + return toproto(L,-1); + else + { + int i,pc; + Proto* f=luaF_newproto(L); + setptvalue2s(L,L->top,f); incr_top(L); + f->source=luaS_newliteral(L,"=(" PROGNAME ")"); + f->maxstacksize=1; + pc=2*n+1; + f->code=luaM_newvector(L,pc,Instruction); + f->sizecode=pc; + f->p=luaM_newvector(L,n,Proto*); + f->sizep=n; + pc=0; + for (i=0; ip[i]=toproto(L,i-n-1); + f->code[pc++]=CREATE_ABx(OP_CLOSURE,0,i); + f->code[pc++]=CREATE_ABC(OP_CALL,0,1,1); + } + f->code[pc++]=CREATE_ABC(OP_RETURN,0,1,0); + return f; + } +} + +static int writer(lua_State* L, const void* p, size_t size, void* u) +{ + UNUSED(L); + return (fwrite(p,size,1,(FILE*)u)!=1) && (size!=0); +} + +struct Smain { + int argc; + char** argv; +}; + +static int pmain(lua_State* L) +{ + struct Smain* s = (struct Smain*)lua_touserdata(L, 1); + int argc=s->argc; + char** argv=s->argv; + const Proto* f; + int i; + if (!lua_checkstack(L,argc)) fatal("too many input files"); + for (i=0; i1); + if (dumping) + { + FILE* D= (output==NULL) ? stdout : fopen(output,"wb"); + if (D==NULL) cannot("open"); + lua_lock(L); + luaU_dump(L,f,writer,D,stripping); + lua_unlock(L); + if (ferror(D)) cannot("write"); + if (fclose(D)) cannot("close"); + } + return 0; +} + +int main(int argc, char* argv[]) +{ + lua_State* L; + struct Smain s; + int i=doargs(argc,argv); + argc-=i; argv+=i; + if (argc<=0) usage("no input files given"); + L=lua_open(); + if (L==NULL) fatal("not enough memory for state"); + s.argc=argc; + s.argv=argv; + if (lua_cpcall(L,pmain,&s)!=0) fatal(lua_tostring(L,-1)); + lua_close(L); + return EXIT_SUCCESS; +} diff --git a/include/lua/luaconf.h b/include/lua/luaconf.h new file mode 100644 index 0000000..e2cb261 --- /dev/null +++ b/include/lua/luaconf.h @@ -0,0 +1,763 @@ +/* +** $Id: luaconf.h,v 1.82.1.7 2008/02/11 16:25:08 roberto Exp $ +** Configuration file for Lua +** See Copyright Notice in lua.h +*/ + + +#ifndef lconfig_h +#define lconfig_h + +#include +#include + + +/* +** ================================================================== +** Search for "@@" to find all configurable definitions. +** =================================================================== +*/ + + +/* +@@ LUA_ANSI controls the use of non-ansi features. +** CHANGE it (define it) if you want Lua to avoid the use of any +** non-ansi feature or library. +*/ +#if defined(__STRICT_ANSI__) +#define LUA_ANSI +#endif + + +#if !defined(LUA_ANSI) && defined(_WIN32) +#define LUA_WIN +#endif + +#if defined(LUA_USE_LINUX) +#define LUA_USE_POSIX +#define LUA_USE_DLOPEN /* needs an extra library: -ldl */ +#define LUA_USE_READLINE /* needs some extra libraries */ +#endif + +#if defined(LUA_USE_MACOSX) +#define LUA_USE_POSIX +#define LUA_DL_DYLD /* does not need extra library */ +#endif + + + +/* +@@ LUA_USE_POSIX includes all functionallity listed as X/Open System +@* Interfaces Extension (XSI). +** CHANGE it (define it) if your system is XSI compatible. +*/ +#if defined(LUA_USE_POSIX) +#define LUA_USE_MKSTEMP +#define LUA_USE_ISATTY +#define LUA_USE_POPEN +#define LUA_USE_ULONGJMP +#endif + + +/* +@@ LUA_PATH and LUA_CPATH are the names of the environment variables that +@* Lua check to set its paths. +@@ LUA_INIT is the name of the environment variable that Lua +@* checks for initialization code. +** CHANGE them if you want different names. +*/ +#define LUA_PATH "LUA_PATH" +#define LUA_CPATH "LUA_CPATH" +#define LUA_INIT "LUA_INIT" + + +/* +@@ LUA_PATH_DEFAULT is the default path that Lua uses to look for +@* Lua libraries. +@@ LUA_CPATH_DEFAULT is the default path that Lua uses to look for +@* C libraries. +** CHANGE them if your machine has a non-conventional directory +** hierarchy or if you want to install your libraries in +** non-conventional directories. +*/ +#if defined(_WIN32) +/* +** In Windows, any exclamation mark ('!') in the path is replaced by the +** path of the directory of the executable file of the current process. +*/ +#define LUA_LDIR "!\\lua\\" +#define LUA_CDIR "!\\" +#define LUA_PATH_DEFAULT \ + ".\\?.lua;" LUA_LDIR"?.lua;" LUA_LDIR"?\\init.lua;" \ + LUA_CDIR"?.lua;" LUA_CDIR"?\\init.lua" +#define LUA_CPATH_DEFAULT \ + ".\\?.dll;" LUA_CDIR"?.dll;" LUA_CDIR"loadall.dll" + +#else +#define LUA_ROOT "/usr/local/" +#define LUA_LDIR LUA_ROOT "share/lua/5.1/" +#define LUA_CDIR LUA_ROOT "lib/lua/5.1/" +#define LUA_PATH_DEFAULT \ + "./?.lua;" LUA_LDIR"?.lua;" LUA_LDIR"?/init.lua;" \ + LUA_CDIR"?.lua;" LUA_CDIR"?/init.lua" +#define LUA_CPATH_DEFAULT \ + "./?.so;" LUA_CDIR"?.so;" LUA_CDIR"loadall.so" +#endif + + +/* +@@ LUA_DIRSEP is the directory separator (for submodules). +** CHANGE it if your machine does not use "/" as the directory separator +** and is not Windows. (On Windows Lua automatically uses "\".) +*/ +#if defined(_WIN32) +#define LUA_DIRSEP "\\" +#else +#define LUA_DIRSEP "/" +#endif + + +/* +@@ LUA_PATHSEP is the character that separates templates in a path. +@@ LUA_PATH_MARK is the string that marks the substitution points in a +@* template. +@@ LUA_EXECDIR in a Windows path is replaced by the executable's +@* directory. +@@ LUA_IGMARK is a mark to ignore all before it when bulding the +@* luaopen_ function name. +** CHANGE them if for some reason your system cannot use those +** characters. (E.g., if one of those characters is a common character +** in file/directory names.) Probably you do not need to change them. +*/ +#define LUA_PATHSEP ";" +#define LUA_PATH_MARK "?" +#define LUA_EXECDIR "!" +#define LUA_IGMARK "-" + + +/* +@@ LUA_INTEGER is the integral type used by lua_pushinteger/lua_tointeger. +** CHANGE that if ptrdiff_t is not adequate on your machine. (On most +** machines, ptrdiff_t gives a good choice between int or long.) +*/ +#define LUA_INTEGER ptrdiff_t + + +/* +@@ LUA_API is a mark for all core API functions. +@@ LUALIB_API is a mark for all standard library functions. +** CHANGE them if you need to define those functions in some special way. +** For instance, if you want to create one Windows DLL with the core and +** the libraries, you may want to use the following definition (define +** LUA_BUILD_AS_DLL to get it). +*/ +#if defined(LUA_BUILD_AS_DLL) + +#if defined(LUA_CORE) || defined(LUA_LIB) +#define LUA_API __declspec(dllexport) +#else +#define LUA_API __declspec(dllimport) +#endif + +#else + +#define LUA_API extern + +#endif + +/* more often than not the libs go together with the core */ +#define LUALIB_API LUA_API + + +/* +@@ LUAI_FUNC is a mark for all extern functions that are not to be +@* exported to outside modules. +@@ LUAI_DATA is a mark for all extern (const) variables that are not to +@* be exported to outside modules. +** CHANGE them if you need to mark them in some special way. Elf/gcc +** (versions 3.2 and later) mark them as "hidden" to optimize access +** when Lua is compiled as a shared library. +*/ +#if defined(luaall_c) +#define LUAI_FUNC static +#define LUAI_DATA /* empty */ + +#elif defined(__GNUC__) && ((__GNUC__*100 + __GNUC_MINOR__) >= 302) && \ + defined(__ELF__) +#define LUAI_FUNC __attribute__((visibility("hidden"))) extern +#define LUAI_DATA LUAI_FUNC + +#else +#define LUAI_FUNC extern +#define LUAI_DATA extern +#endif + + + +/* +@@ LUA_QL describes how error messages quote program elements. +** CHANGE it if you want a different appearance. +*/ +#define LUA_QL(x) "'" x "'" +#define LUA_QS LUA_QL("%s") + + +/* +@@ LUA_IDSIZE gives the maximum size for the description of the source +@* of a function in debug information. +** CHANGE it if you want a different size. +*/ +#define LUA_IDSIZE 60 + + +/* +** {================================================================== +** Stand-alone configuration +** =================================================================== +*/ + +#if defined(lua_c) || defined(luaall_c) + +/* +@@ lua_stdin_is_tty detects whether the standard input is a 'tty' (that +@* is, whether we're running lua interactively). +** CHANGE it if you have a better definition for non-POSIX/non-Windows +** systems. +*/ +#if defined(LUA_USE_ISATTY) +#include +#define lua_stdin_is_tty() isatty(0) +#elif defined(LUA_WIN) +#include +#include +#define lua_stdin_is_tty() _isatty(_fileno(stdin)) +#else +#define lua_stdin_is_tty() 1 /* assume stdin is a tty */ +#endif + + +/* +@@ LUA_PROMPT is the default prompt used by stand-alone Lua. +@@ LUA_PROMPT2 is the default continuation prompt used by stand-alone Lua. +** CHANGE them if you want different prompts. (You can also change the +** prompts dynamically, assigning to globals _PROMPT/_PROMPT2.) +*/ +#define LUA_PROMPT "> " +#define LUA_PROMPT2 ">> " + + +/* +@@ LUA_PROGNAME is the default name for the stand-alone Lua program. +** CHANGE it if your stand-alone interpreter has a different name and +** your system is not able to detect that name automatically. +*/ +#define LUA_PROGNAME "lua" + + +/* +@@ LUA_MAXINPUT is the maximum length for an input line in the +@* stand-alone interpreter. +** CHANGE it if you need longer lines. +*/ +#define LUA_MAXINPUT 512 + + +/* +@@ lua_readline defines how to show a prompt and then read a line from +@* the standard input. +@@ lua_saveline defines how to "save" a read line in a "history". +@@ lua_freeline defines how to free a line read by lua_readline. +** CHANGE them if you want to improve this functionality (e.g., by using +** GNU readline and history facilities). +*/ +#if defined(LUA_USE_READLINE) +#include +#include +#include +#define lua_readline(L,b,p) ((void)L, ((b)=readline(p)) != NULL) +#define lua_saveline(L,idx) \ + if (lua_strlen(L,idx) > 0) /* non-empty line? */ \ + add_history(lua_tostring(L, idx)); /* add it to history */ +#define lua_freeline(L,b) ((void)L, free(b)) +#else +#define lua_readline(L,b,p) \ + ((void)L, fputs(p, stdout), fflush(stdout), /* show prompt */ \ + fgets(b, LUA_MAXINPUT, stdin) != NULL) /* get line */ +#define lua_saveline(L,idx) { (void)L; (void)idx; } +#define lua_freeline(L,b) { (void)L; (void)b; } +#endif + +#endif + +/* }================================================================== */ + + +/* +@@ LUAI_GCPAUSE defines the default pause between garbage-collector cycles +@* as a percentage. +** CHANGE it if you want the GC to run faster or slower (higher values +** mean larger pauses which mean slower collection.) You can also change +** this value dynamically. +*/ +#define LUAI_GCPAUSE 200 /* 200% (wait memory to double before next GC) */ + + +/* +@@ LUAI_GCMUL defines the default speed of garbage collection relative to +@* memory allocation as a percentage. +** CHANGE it if you want to change the granularity of the garbage +** collection. (Higher values mean coarser collections. 0 represents +** infinity, where each step performs a full collection.) You can also +** change this value dynamically. +*/ +#define LUAI_GCMUL 200 /* GC runs 'twice the speed' of memory allocation */ + + + +/* +@@ LUA_COMPAT_GETN controls compatibility with old getn behavior. +** CHANGE it (define it) if you want exact compatibility with the +** behavior of setn/getn in Lua 5.0. +*/ +#undef LUA_COMPAT_GETN + +/* +@@ LUA_COMPAT_LOADLIB controls compatibility about global loadlib. +** CHANGE it to undefined as soon as you do not need a global 'loadlib' +** function (the function is still available as 'package.loadlib'). +*/ +#undef LUA_COMPAT_LOADLIB + +/* +@@ LUA_COMPAT_VARARG controls compatibility with old vararg feature. +** CHANGE it to undefined as soon as your programs use only '...' to +** access vararg parameters (instead of the old 'arg' table). +*/ +#define LUA_COMPAT_VARARG + +/* +@@ LUA_COMPAT_MOD controls compatibility with old math.mod function. +** CHANGE it to undefined as soon as your programs use 'math.fmod' or +** the new '%' operator instead of 'math.mod'. +*/ +#define LUA_COMPAT_MOD + +/* +@@ LUA_COMPAT_LSTR controls compatibility with old long string nesting +@* facility. +** CHANGE it to 2 if you want the old behaviour, or undefine it to turn +** off the advisory error when nesting [[...]]. +*/ +#define LUA_COMPAT_LSTR 1 + +/* +@@ LUA_COMPAT_GFIND controls compatibility with old 'string.gfind' name. +** CHANGE it to undefined as soon as you rename 'string.gfind' to +** 'string.gmatch'. +*/ +#define LUA_COMPAT_GFIND + +/* +@@ LUA_COMPAT_OPENLIB controls compatibility with old 'luaL_openlib' +@* behavior. +** CHANGE it to undefined as soon as you replace to 'luaL_register' +** your uses of 'luaL_openlib' +*/ +#define LUA_COMPAT_OPENLIB + + + +/* +@@ luai_apicheck is the assert macro used by the Lua-C API. +** CHANGE luai_apicheck if you want Lua to perform some checks in the +** parameters it gets from API calls. This may slow down the interpreter +** a bit, but may be quite useful when debugging C code that interfaces +** with Lua. A useful redefinition is to use assert.h. +*/ +#if defined(LUA_USE_APICHECK) +#include +#define luai_apicheck(L,o) { (void)L; assert(o); } +#else +#define luai_apicheck(L,o) { (void)L; } +#endif + + +/* +@@ LUAI_BITSINT defines the number of bits in an int. +** CHANGE here if Lua cannot automatically detect the number of bits of +** your machine. Probably you do not need to change this. +*/ +/* avoid overflows in comparison */ +#if INT_MAX-20 < 32760 +#define LUAI_BITSINT 16 +#elif INT_MAX > 2147483640L +/* int has at least 32 bits */ +#define LUAI_BITSINT 32 +#else +#error "you must define LUA_BITSINT with number of bits in an integer" +#endif + + +/* +@@ LUAI_UINT32 is an unsigned integer with at least 32 bits. +@@ LUAI_INT32 is an signed integer with at least 32 bits. +@@ LUAI_UMEM is an unsigned integer big enough to count the total +@* memory used by Lua. +@@ LUAI_MEM is a signed integer big enough to count the total memory +@* used by Lua. +** CHANGE here if for some weird reason the default definitions are not +** good enough for your machine. (The definitions in the 'else' +** part always works, but may waste space on machines with 64-bit +** longs.) Probably you do not need to change this. +*/ +#if LUAI_BITSINT >= 32 +#define LUAI_UINT32 unsigned int +#define LUAI_INT32 int +#define LUAI_MAXINT32 INT_MAX +#define LUAI_UMEM size_t +#define LUAI_MEM ptrdiff_t +#else +/* 16-bit ints */ +#define LUAI_UINT32 unsigned long +#define LUAI_INT32 long +#define LUAI_MAXINT32 LONG_MAX +#define LUAI_UMEM unsigned long +#define LUAI_MEM long +#endif + + +/* +@@ LUAI_MAXCALLS limits the number of nested calls. +** CHANGE it if you need really deep recursive calls. This limit is +** arbitrary; its only purpose is to stop infinite recursion before +** exhausting memory. +*/ +#define LUAI_MAXCALLS 20000 + + +/* +@@ LUAI_MAXCSTACK limits the number of Lua stack slots that a C function +@* can use. +** CHANGE it if you need lots of (Lua) stack space for your C +** functions. This limit is arbitrary; its only purpose is to stop C +** functions to consume unlimited stack space. (must be smaller than +** -LUA_REGISTRYINDEX) +*/ +#define LUAI_MAXCSTACK 8000 + + + +/* +** {================================================================== +** CHANGE (to smaller values) the following definitions if your system +** has a small C stack. (Or you may want to change them to larger +** values if your system has a large C stack and these limits are +** too rigid for you.) Some of these constants control the size of +** stack-allocated arrays used by the compiler or the interpreter, while +** others limit the maximum number of recursive calls that the compiler +** or the interpreter can perform. Values too large may cause a C stack +** overflow for some forms of deep constructs. +** =================================================================== +*/ + + +/* +@@ LUAI_MAXCCALLS is the maximum depth for nested C calls (short) and +@* syntactical nested non-terminals in a program. +*/ +#define LUAI_MAXCCALLS 200 + + +/* +@@ LUAI_MAXVARS is the maximum number of local variables per function +@* (must be smaller than 250). +*/ +#define LUAI_MAXVARS 200 + + +/* +@@ LUAI_MAXUPVALUES is the maximum number of upvalues per function +@* (must be smaller than 250). +*/ +#define LUAI_MAXUPVALUES 60 + + +/* +@@ LUAL_BUFFERSIZE is the buffer size used by the lauxlib buffer system. +*/ +#define LUAL_BUFFERSIZE BUFSIZ + +/* }================================================================== */ + + + + +/* +** {================================================================== +@@ LUA_NUMBER is the type of numbers in Lua. +** CHANGE the following definitions only if you want to build Lua +** with a number type different from double. You may also need to +** change lua_number2int & lua_number2integer. +** =================================================================== +*/ + +#define LUA_NUMBER_DOUBLE +#define LUA_NUMBER double + +/* +@@ LUAI_UACNUMBER is the result of an 'usual argument conversion' +@* over a number. +*/ +#define LUAI_UACNUMBER double + + +/* +@@ LUA_NUMBER_SCAN is the format for reading numbers. +@@ LUA_NUMBER_FMT is the format for writing numbers. +@@ lua_number2str converts a number to a string. +@@ LUAI_MAXNUMBER2STR is maximum size of previous conversion. +@@ lua_str2number converts a string to a number. +*/ +#define LUA_NUMBER_SCAN "%lf" +#define LUA_NUMBER_FMT "%.14g" +#define lua_number2str(s,n) sprintf((s), LUA_NUMBER_FMT, (n)) +#define LUAI_MAXNUMBER2STR 32 /* 16 digits, sign, point, and \0 */ +#define lua_str2number(s,p) strtod((s), (p)) + + +/* +@@ The luai_num* macros define the primitive operations over numbers. +*/ +#if defined(LUA_CORE) +#include +#define luai_numadd(a,b) ((a)+(b)) +#define luai_numsub(a,b) ((a)-(b)) +#define luai_nummul(a,b) ((a)*(b)) +#define luai_numdiv(a,b) ((a)/(b)) +#define luai_nummod(a,b) ((a) - floor((a)/(b))*(b)) +#define luai_numpow(a,b) (pow(a,b)) +#define luai_numunm(a) (-(a)) +#define luai_numeq(a,b) ((a)==(b)) +#define luai_numlt(a,b) ((a)<(b)) +#define luai_numle(a,b) ((a)<=(b)) +#define luai_numisnan(a) (!luai_numeq((a), (a))) +#endif + + +/* +@@ lua_number2int is a macro to convert lua_Number to int. +@@ lua_number2integer is a macro to convert lua_Number to lua_Integer. +** CHANGE them if you know a faster way to convert a lua_Number to +** int (with any rounding method and without throwing errors) in your +** system. In Pentium machines, a naive typecast from double to int +** in C is extremely slow, so any alternative is worth trying. +*/ + +/* On a Pentium, resort to a trick */ +#if defined(LUA_NUMBER_DOUBLE) && !defined(LUA_ANSI) && !defined(__SSE2__) && \ + (defined(__i386) || defined (_M_IX86) || defined(__i386__)) + +/* On a Microsoft compiler, use assembler */ +#if defined(_MSC_VER) + +#define lua_number2int(i,d) __asm fld d __asm fistp i +#define lua_number2integer(i,n) lua_number2int(i, n) + +/* the next trick should work on any Pentium, but sometimes clashes + with a DirectX idiosyncrasy */ +#else + +union luai_Cast { double l_d; long l_l; }; +#define lua_number2int(i,d) \ + { volatile union luai_Cast u; u.l_d = (d) + 6755399441055744.0; (i) = u.l_l; } +#define lua_number2integer(i,n) lua_number2int(i, n) + +#endif + + +/* this option always works, but may be slow */ +#else +#define lua_number2int(i,d) ((i)=(int)(d)) +#define lua_number2integer(i,d) ((i)=(lua_Integer)(d)) + +#endif + +/* }================================================================== */ + + +/* +@@ LUAI_USER_ALIGNMENT_T is a type that requires maximum alignment. +** CHANGE it if your system requires alignments larger than double. (For +** instance, if your system supports long doubles and they must be +** aligned in 16-byte boundaries, then you should add long double in the +** union.) Probably you do not need to change this. +*/ +#define LUAI_USER_ALIGNMENT_T union { double u; void *s; long l; } + + +/* +@@ LUAI_THROW/LUAI_TRY define how Lua does exception handling. +** CHANGE them if you prefer to use longjmp/setjmp even with C++ +** or if want/don't to use _longjmp/_setjmp instead of regular +** longjmp/setjmp. By default, Lua handles errors with exceptions when +** compiling as C++ code, with _longjmp/_setjmp when asked to use them, +** and with longjmp/setjmp otherwise. +*/ +#if defined(__cplusplus) +/* C++ exceptions */ +#define LUAI_THROW(L,c) throw(c) +#define LUAI_TRY(L,c,a) try { a } catch(...) \ + { if ((c)->status == 0) (c)->status = -1; } +#define luai_jmpbuf int /* dummy variable */ + +#elif defined(LUA_USE_ULONGJMP) +/* in Unix, try _longjmp/_setjmp (more efficient) */ +#define LUAI_THROW(L,c) _longjmp((c)->b, 1) +#define LUAI_TRY(L,c,a) if (_setjmp((c)->b) == 0) { a } +#define luai_jmpbuf jmp_buf + +#else +/* default handling with long jumps */ +#define LUAI_THROW(L,c) longjmp((c)->b, 1) +#define LUAI_TRY(L,c,a) if (setjmp((c)->b) == 0) { a } +#define luai_jmpbuf jmp_buf + +#endif + + +/* +@@ LUA_MAXCAPTURES is the maximum number of captures that a pattern +@* can do during pattern-matching. +** CHANGE it if you need more captures. This limit is arbitrary. +*/ +#define LUA_MAXCAPTURES 32 + + +/* +@@ lua_tmpnam is the function that the OS library uses to create a +@* temporary name. +@@ LUA_TMPNAMBUFSIZE is the maximum size of a name created by lua_tmpnam. +** CHANGE them if you have an alternative to tmpnam (which is considered +** insecure) or if you want the original tmpnam anyway. By default, Lua +** uses tmpnam except when POSIX is available, where it uses mkstemp. +*/ +#if defined(loslib_c) || defined(luaall_c) + +#if defined(LUA_USE_MKSTEMP) +#include +#define LUA_TMPNAMBUFSIZE 32 +#define lua_tmpnam(b,e) { \ + strcpy(b, "/tmp/lua_XXXXXX"); \ + e = mkstemp(b); \ + if (e != -1) close(e); \ + e = (e == -1); } + +#else +#define LUA_TMPNAMBUFSIZE L_tmpnam +#define lua_tmpnam(b,e) { e = (tmpnam(b) == NULL); } +#endif + +#endif + + +/* +@@ lua_popen spawns a new process connected to the current one through +@* the file streams. +** CHANGE it if you have a way to implement it in your system. +*/ +#if defined(LUA_USE_POPEN) + +#define lua_popen(L,c,m) ((void)L, fflush(NULL), popen(c,m)) +#define lua_pclose(L,file) ((void)L, (pclose(file) != -1)) + +#elif defined(LUA_WIN) + +#define lua_popen(L,c,m) ((void)L, _popen(c,m)) +#define lua_pclose(L,file) ((void)L, (_pclose(file) != -1)) + +#else + +#define lua_popen(L,c,m) ((void)((void)c, m), \ + luaL_error(L, LUA_QL("popen") " not supported"), (FILE*)0) +#define lua_pclose(L,file) ((void)((void)L, file), 0) + +#endif + +/* +@@ LUA_DL_* define which dynamic-library system Lua should use. +** CHANGE here if Lua has problems choosing the appropriate +** dynamic-library system for your platform (either Windows' DLL, Mac's +** dyld, or Unix's dlopen). If your system is some kind of Unix, there +** is a good chance that it has dlopen, so LUA_DL_DLOPEN will work for +** it. To use dlopen you also need to adapt the src/Makefile (probably +** adding -ldl to the linker options), so Lua does not select it +** automatically. (When you change the makefile to add -ldl, you must +** also add -DLUA_USE_DLOPEN.) +** If you do not want any kind of dynamic library, undefine all these +** options. +** By default, _WIN32 gets LUA_DL_DLL and MAC OS X gets LUA_DL_DYLD. +*/ +#if defined(LUA_USE_DLOPEN) +#define LUA_DL_DLOPEN +#endif + +#if defined(LUA_WIN) +#define LUA_DL_DLL +#endif + + +/* +@@ LUAI_EXTRASPACE allows you to add user-specific data in a lua_State +@* (the data goes just *before* the lua_State pointer). +** CHANGE (define) this if you really need that. This value must be +** a multiple of the maximum alignment required for your machine. +*/ +#define LUAI_EXTRASPACE 0 + + +/* +@@ luai_userstate* allow user-specific actions on threads. +** CHANGE them if you defined LUAI_EXTRASPACE and need to do something +** extra when a thread is created/deleted/resumed/yielded. +*/ +#define luai_userstateopen(L) ((void)L) +#define luai_userstateclose(L) ((void)L) +#define luai_userstatethread(L,L1) ((void)L) +#define luai_userstatefree(L) ((void)L) +#define luai_userstateresume(L,n) ((void)L) +#define luai_userstateyield(L,n) ((void)L) + + +/* +@@ LUA_INTFRMLEN is the length modifier for integer conversions +@* in 'string.format'. +@@ LUA_INTFRM_T is the integer type correspoding to the previous length +@* modifier. +** CHANGE them if your system supports long long or does not support long. +*/ + +#if defined(LUA_USELONGLONG) + +#define LUA_INTFRMLEN "ll" +#define LUA_INTFRM_T long long + +#else + +#define LUA_INTFRMLEN "l" +#define LUA_INTFRM_T long + +#endif + + + +/* =================================================================== */ + +/* +** Local configuration. You can use this space to add your redefinitions +** without modifying the main part of the file. +*/ + + + +#endif + diff --git a/include/lua/lualib.h b/include/lua/lualib.h new file mode 100644 index 0000000..469417f --- /dev/null +++ b/include/lua/lualib.h @@ -0,0 +1,53 @@ +/* +** $Id: lualib.h,v 1.36.1.1 2007/12/27 13:02:25 roberto Exp $ +** Lua standard libraries +** See Copyright Notice in lua.h +*/ + + +#ifndef lualib_h +#define lualib_h + +#include "lua.h" + + +/* Key to file-handle type */ +#define LUA_FILEHANDLE "FILE*" + + +#define LUA_COLIBNAME "coroutine" +LUALIB_API int (luaopen_base) (lua_State *L); + +#define LUA_TABLIBNAME "table" +LUALIB_API int (luaopen_table) (lua_State *L); + +#define LUA_IOLIBNAME "io" +LUALIB_API int (luaopen_io) (lua_State *L); + +#define LUA_OSLIBNAME "os" +LUALIB_API int (luaopen_os) (lua_State *L); + +#define LUA_STRLIBNAME "string" +LUALIB_API int (luaopen_string) (lua_State *L); + +#define LUA_MATHLIBNAME "math" +LUALIB_API int (luaopen_math) (lua_State *L); + +#define LUA_DBLIBNAME "debug" +LUALIB_API int (luaopen_debug) (lua_State *L); + +#define LUA_LOADLIBNAME "package" +LUALIB_API int (luaopen_package) (lua_State *L); + + +/* open all previous libraries */ +LUALIB_API void (luaL_openlibs) (lua_State *L); + + + +#ifndef lua_assert +#define lua_assert(x) ((void)0) +#endif + + +#endif diff --git a/include/lua/lundump.c b/include/lua/lundump.c new file mode 100644 index 0000000..8010a45 --- /dev/null +++ b/include/lua/lundump.c @@ -0,0 +1,227 @@ +/* +** $Id: lundump.c,v 2.7.1.4 2008/04/04 19:51:41 roberto Exp $ +** load precompiled Lua chunks +** See Copyright Notice in lua.h +*/ + +#include + +#define lundump_c +#define LUA_CORE + +#include "lua.h" + +#include "ldebug.h" +#include "ldo.h" +#include "lfunc.h" +#include "lmem.h" +#include "lobject.h" +#include "lstring.h" +#include "lundump.h" +#include "lzio.h" + +typedef struct { + lua_State* L; + ZIO* Z; + Mbuffer* b; + const char* name; +} LoadState; + +#ifdef LUAC_TRUST_BINARIES +#define IF(c,s) +#define error(S,s) +#else +#define IF(c,s) if (c) error(S,s) + +static void error(LoadState* S, const char* why) +{ + luaO_pushfstring(S->L,"%s: %s in precompiled chunk",S->name,why); + luaD_throw(S->L,LUA_ERRSYNTAX); +} +#endif + +#define LoadMem(S,b,n,size) LoadBlock(S,b,(n)*(size)) +#define LoadByte(S) (lu_byte)LoadChar(S) +#define LoadVar(S,x) LoadMem(S,&x,1,sizeof(x)) +#define LoadVector(S,b,n,size) LoadMem(S,b,n,size) + +static void LoadBlock(LoadState* S, void* b, size_t size) +{ + size_t r=luaZ_read(S->Z,b,size); + IF (r!=0, "unexpected end"); +} + +static int LoadChar(LoadState* S) +{ + char x; + LoadVar(S,x); + return x; +} + +static int LoadInt(LoadState* S) +{ + int x; + LoadVar(S,x); + IF (x<0, "bad integer"); + return x; +} + +static lua_Number LoadNumber(LoadState* S) +{ + lua_Number x; + LoadVar(S,x); + return x; +} + +static TString* LoadString(LoadState* S) +{ + size_t size; + LoadVar(S,size); + if (size==0) + return NULL; + else + { + char* s=luaZ_openspace(S->L,S->b,size); + LoadBlock(S,s,size); + return luaS_newlstr(S->L,s,size-1); /* remove trailing '\0' */ + } +} + +static void LoadCode(LoadState* S, Proto* f) +{ + int n=LoadInt(S); + f->code=luaM_newvector(S->L,n,Instruction); + f->sizecode=n; + LoadVector(S,f->code,n,sizeof(Instruction)); +} + +static Proto* LoadFunction(LoadState* S, TString* p); + +static void LoadConstants(LoadState* S, Proto* f) +{ + int i,n; + n=LoadInt(S); + f->k=luaM_newvector(S->L,n,TValue); + f->sizek=n; + for (i=0; ik[i]); + for (i=0; ik[i]; + int t=LoadChar(S); + switch (t) + { + case LUA_TNIL: + setnilvalue(o); + break; + case LUA_TBOOLEAN: + setbvalue(o,LoadChar(S)!=0); + break; + case LUA_TNUMBER: + setnvalue(o,LoadNumber(S)); + break; + case LUA_TSTRING: + setsvalue2n(S->L,o,LoadString(S)); + break; + default: + error(S,"bad constant"); + break; + } + } + n=LoadInt(S); + f->p=luaM_newvector(S->L,n,Proto*); + f->sizep=n; + for (i=0; ip[i]=NULL; + for (i=0; ip[i]=LoadFunction(S,f->source); +} + +static void LoadDebug(LoadState* S, Proto* f) +{ + int i,n; + n=LoadInt(S); + f->lineinfo=luaM_newvector(S->L,n,int); + f->sizelineinfo=n; + LoadVector(S,f->lineinfo,n,sizeof(int)); + n=LoadInt(S); + f->locvars=luaM_newvector(S->L,n,LocVar); + f->sizelocvars=n; + for (i=0; ilocvars[i].varname=NULL; + for (i=0; ilocvars[i].varname=LoadString(S); + f->locvars[i].startpc=LoadInt(S); + f->locvars[i].endpc=LoadInt(S); + } + n=LoadInt(S); + f->upvalues=luaM_newvector(S->L,n,TString*); + f->sizeupvalues=n; + for (i=0; iupvalues[i]=NULL; + for (i=0; iupvalues[i]=LoadString(S); +} + +static Proto* LoadFunction(LoadState* S, TString* p) +{ + Proto* f; + if (++S->L->nCcalls > LUAI_MAXCCALLS) error(S,"code too deep"); + f=luaF_newproto(S->L); + setptvalue2s(S->L,S->L->top,f); incr_top(S->L); + f->source=LoadString(S); if (f->source==NULL) f->source=p; + f->linedefined=LoadInt(S); + f->lastlinedefined=LoadInt(S); + f->nups=LoadByte(S); + f->numparams=LoadByte(S); + f->is_vararg=LoadByte(S); + f->maxstacksize=LoadByte(S); + LoadCode(S,f); + LoadConstants(S,f); + LoadDebug(S,f); + IF (!luaG_checkcode(f), "bad code"); + S->L->top--; + S->L->nCcalls--; + return f; +} + +static void LoadHeader(LoadState* S) +{ + char h[LUAC_HEADERSIZE]; + char s[LUAC_HEADERSIZE]; + luaU_header(h); + LoadBlock(S,s,LUAC_HEADERSIZE); + IF (memcmp(h,s,LUAC_HEADERSIZE)!=0, "bad header"); +} + +/* +** load precompiled chunk +*/ +Proto* luaU_undump (lua_State* L, ZIO* Z, Mbuffer* buff, const char* name) +{ + LoadState S; + if (*name=='@' || *name=='=') + S.name=name+1; + else if (*name==LUA_SIGNATURE[0]) + S.name="binary string"; + else + S.name=name; + S.L=L; + S.Z=Z; + S.b=buff; + LoadHeader(&S); + return LoadFunction(&S,luaS_newliteral(L,"=?")); +} + +/* +* make header +*/ +void luaU_header (char* h) +{ + int x=1; + memcpy(h,LUA_SIGNATURE,sizeof(LUA_SIGNATURE)-1); + h+=sizeof(LUA_SIGNATURE)-1; + *h++=(char)LUAC_VERSION; + *h++=(char)LUAC_FORMAT; + *h++=(char)*(char*)&x; /* endianness */ + *h++=(char)sizeof(int); + *h++=(char)sizeof(size_t); + *h++=(char)sizeof(Instruction); + *h++=(char)sizeof(lua_Number); + *h++=(char)(((lua_Number)0.5)==0); /* is lua_Number integral? */ +} diff --git a/include/lua/lundump.h b/include/lua/lundump.h new file mode 100644 index 0000000..c80189d --- /dev/null +++ b/include/lua/lundump.h @@ -0,0 +1,36 @@ +/* +** $Id: lundump.h,v 1.37.1.1 2007/12/27 13:02:25 roberto Exp $ +** load precompiled Lua chunks +** See Copyright Notice in lua.h +*/ + +#ifndef lundump_h +#define lundump_h + +#include "lobject.h" +#include "lzio.h" + +/* load one chunk; from lundump.c */ +LUAI_FUNC Proto* luaU_undump (lua_State* L, ZIO* Z, Mbuffer* buff, const char* name); + +/* make header; from lundump.c */ +LUAI_FUNC void luaU_header (char* h); + +/* dump one chunk; from ldump.c */ +LUAI_FUNC int luaU_dump (lua_State* L, const Proto* f, lua_Writer w, void* data, int strip); + +#ifdef luac_c +/* print one chunk; from print.c */ +LUAI_FUNC void luaU_print (const Proto* f, int full); +#endif + +/* for header of binary files -- this is Lua 5.1 */ +#define LUAC_VERSION 0x51 + +/* for header of binary files -- this is the official format */ +#define LUAC_FORMAT 0 + +/* size of header of binary files */ +#define LUAC_HEADERSIZE 12 + +#endif diff --git a/include/lua/lvm.c b/include/lua/lvm.c new file mode 100644 index 0000000..ee3256a --- /dev/null +++ b/include/lua/lvm.c @@ -0,0 +1,763 @@ +/* +** $Id: lvm.c,v 2.63.1.3 2007/12/28 15:32:23 roberto Exp $ +** Lua virtual machine +** See Copyright Notice in lua.h +*/ + + +#include +#include +#include + +#define lvm_c +#define LUA_CORE + +#include "lua.h" + +#include "ldebug.h" +#include "ldo.h" +#include "lfunc.h" +#include "lgc.h" +#include "lobject.h" +#include "lopcodes.h" +#include "lstate.h" +#include "lstring.h" +#include "ltable.h" +#include "ltm.h" +#include "lvm.h" + + + +/* limit for table tag-method chains (to avoid loops) */ +#define MAXTAGLOOP 100 + + +const TValue *luaV_tonumber (const TValue *obj, TValue *n) { + lua_Number num; + if (ttisnumber(obj)) return obj; + if (ttisstring(obj) && luaO_str2d(svalue(obj), &num)) { + setnvalue(n, num); + return n; + } + else + return NULL; +} + + +int luaV_tostring (lua_State *L, StkId obj) { + if (!ttisnumber(obj)) + return 0; + else { + char s[LUAI_MAXNUMBER2STR]; + lua_Number n = nvalue(obj); + lua_number2str(s, n); + setsvalue2s(L, obj, luaS_new(L, s)); + return 1; + } +} + + +static void traceexec (lua_State *L, const Instruction *pc) { + lu_byte mask = L->hookmask; + const Instruction *oldpc = L->savedpc; + L->savedpc = pc; + if ((mask & LUA_MASKCOUNT) && L->hookcount == 0) { + resethookcount(L); + luaD_callhook(L, LUA_HOOKCOUNT, -1); + } + if (mask & LUA_MASKLINE) { + Proto *p = ci_func(L->ci)->l.p; + int npc = pcRel(pc, p); + int newline = getline(p, npc); + /* call linehook when enter a new function, when jump back (loop), + or when enter a new line */ + if (npc == 0 || pc <= oldpc || newline != getline(p, pcRel(oldpc, p))) + luaD_callhook(L, LUA_HOOKLINE, newline); + } +} + + +static void callTMres (lua_State *L, StkId res, const TValue *f, + const TValue *p1, const TValue *p2) { + ptrdiff_t result = savestack(L, res); + setobj2s(L, L->top, f); /* push function */ + setobj2s(L, L->top+1, p1); /* 1st argument */ + setobj2s(L, L->top+2, p2); /* 2nd argument */ + luaD_checkstack(L, 3); + L->top += 3; + luaD_call(L, L->top - 3, 1); + res = restorestack(L, result); + L->top--; + setobjs2s(L, res, L->top); +} + + + +static void callTM (lua_State *L, const TValue *f, const TValue *p1, + const TValue *p2, const TValue *p3) { + setobj2s(L, L->top, f); /* push function */ + setobj2s(L, L->top+1, p1); /* 1st argument */ + setobj2s(L, L->top+2, p2); /* 2nd argument */ + setobj2s(L, L->top+3, p3); /* 3th argument */ + luaD_checkstack(L, 4); + L->top += 4; + luaD_call(L, L->top - 4, 0); +} + + +void luaV_gettable (lua_State *L, const TValue *t, TValue *key, StkId val) { + int loop; + for (loop = 0; loop < MAXTAGLOOP; loop++) { + const TValue *tm; + if (ttistable(t)) { /* `t' is a table? */ + Table *h = hvalue(t); + const TValue *res = luaH_get(h, key); /* do a primitive get */ + if (!ttisnil(res) || /* result is no nil? */ + (tm = fasttm(L, h->metatable, TM_INDEX)) == NULL) { /* or no TM? */ + setobj2s(L, val, res); + return; + } + /* else will try the tag method */ + } + else if (ttisnil(tm = luaT_gettmbyobj(L, t, TM_INDEX))) + luaG_typeerror(L, t, "index"); + if (ttisfunction(tm)) { + callTMres(L, val, tm, t, key); + return; + } + t = tm; /* else repeat with `tm' */ + } + luaG_runerror(L, "loop in gettable"); +} + + +void luaV_settable (lua_State *L, const TValue *t, TValue *key, StkId val) { + int loop; + for (loop = 0; loop < MAXTAGLOOP; loop++) { + const TValue *tm; + if (ttistable(t)) { /* `t' is a table? */ + Table *h = hvalue(t); + TValue *oldval = luaH_set(L, h, key); /* do a primitive set */ + if (!ttisnil(oldval) || /* result is no nil? */ + (tm = fasttm(L, h->metatable, TM_NEWINDEX)) == NULL) { /* or no TM? */ + setobj2t(L, oldval, val); + luaC_barriert(L, h, val); + return; + } + /* else will try the tag method */ + } + else if (ttisnil(tm = luaT_gettmbyobj(L, t, TM_NEWINDEX))) + luaG_typeerror(L, t, "index"); + if (ttisfunction(tm)) { + callTM(L, tm, t, key, val); + return; + } + t = tm; /* else repeat with `tm' */ + } + luaG_runerror(L, "loop in settable"); +} + + +static int call_binTM (lua_State *L, const TValue *p1, const TValue *p2, + StkId res, TMS event) { + const TValue *tm = luaT_gettmbyobj(L, p1, event); /* try first operand */ + if (ttisnil(tm)) + tm = luaT_gettmbyobj(L, p2, event); /* try second operand */ + if (ttisnil(tm)) return 0; + callTMres(L, res, tm, p1, p2); + return 1; +} + + +static const TValue *get_compTM (lua_State *L, Table *mt1, Table *mt2, + TMS event) { + const TValue *tm1 = fasttm(L, mt1, event); + const TValue *tm2; + if (tm1 == NULL) return NULL; /* no metamethod */ + if (mt1 == mt2) return tm1; /* same metatables => same metamethods */ + tm2 = fasttm(L, mt2, event); + if (tm2 == NULL) return NULL; /* no metamethod */ + if (luaO_rawequalObj(tm1, tm2)) /* same metamethods? */ + return tm1; + return NULL; +} + + +static int call_orderTM (lua_State *L, const TValue *p1, const TValue *p2, + TMS event) { + const TValue *tm1 = luaT_gettmbyobj(L, p1, event); + const TValue *tm2; + if (ttisnil(tm1)) return -1; /* no metamethod? */ + tm2 = luaT_gettmbyobj(L, p2, event); + if (!luaO_rawequalObj(tm1, tm2)) /* different metamethods? */ + return -1; + callTMres(L, L->top, tm1, p1, p2); + return !l_isfalse(L->top); +} + + +static int l_strcmp (const TString *ls, const TString *rs) { + const char *l = getstr(ls); + size_t ll = ls->tsv.len; + const char *r = getstr(rs); + size_t lr = rs->tsv.len; + for (;;) { + int temp = strcoll(l, r); + if (temp != 0) return temp; + else { /* strings are equal up to a `\0' */ + size_t len = strlen(l); /* index of first `\0' in both strings */ + if (len == lr) /* r is finished? */ + return (len == ll) ? 0 : 1; + else if (len == ll) /* l is finished? */ + return -1; /* l is smaller than r (because r is not finished) */ + /* both strings longer than `len'; go on comparing (after the `\0') */ + len++; + l += len; ll -= len; r += len; lr -= len; + } + } +} + + +int luaV_lessthan (lua_State *L, const TValue *l, const TValue *r) { + int res; + if (ttype(l) != ttype(r)) + return luaG_ordererror(L, l, r); + else if (ttisnumber(l)) + return luai_numlt(nvalue(l), nvalue(r)); + else if (ttisstring(l)) + return l_strcmp(rawtsvalue(l), rawtsvalue(r)) < 0; + else if ((res = call_orderTM(L, l, r, TM_LT)) != -1) + return res; + return luaG_ordererror(L, l, r); +} + + +static int lessequal (lua_State *L, const TValue *l, const TValue *r) { + int res; + if (ttype(l) != ttype(r)) + return luaG_ordererror(L, l, r); + else if (ttisnumber(l)) + return luai_numle(nvalue(l), nvalue(r)); + else if (ttisstring(l)) + return l_strcmp(rawtsvalue(l), rawtsvalue(r)) <= 0; + else if ((res = call_orderTM(L, l, r, TM_LE)) != -1) /* first try `le' */ + return res; + else if ((res = call_orderTM(L, r, l, TM_LT)) != -1) /* else try `lt' */ + return !res; + return luaG_ordererror(L, l, r); +} + + +int luaV_equalval (lua_State *L, const TValue *t1, const TValue *t2) { + const TValue *tm; + lua_assert(ttype(t1) == ttype(t2)); + switch (ttype(t1)) { + case LUA_TNIL: return 1; + case LUA_TNUMBER: return luai_numeq(nvalue(t1), nvalue(t2)); + case LUA_TBOOLEAN: return bvalue(t1) == bvalue(t2); /* true must be 1 !! */ + case LUA_TLIGHTUSERDATA: return pvalue(t1) == pvalue(t2); + case LUA_TUSERDATA: { + if (uvalue(t1) == uvalue(t2)) return 1; + tm = get_compTM(L, uvalue(t1)->metatable, uvalue(t2)->metatable, + TM_EQ); + break; /* will try TM */ + } + case LUA_TTABLE: { + if (hvalue(t1) == hvalue(t2)) return 1; + tm = get_compTM(L, hvalue(t1)->metatable, hvalue(t2)->metatable, TM_EQ); + break; /* will try TM */ + } + default: return gcvalue(t1) == gcvalue(t2); + } + if (tm == NULL) return 0; /* no TM? */ + callTMres(L, L->top, tm, t1, t2); /* call TM */ + return !l_isfalse(L->top); +} + + +void luaV_concat (lua_State *L, int total, int last) { + do { + StkId top = L->base + last + 1; + int n = 2; /* number of elements handled in this pass (at least 2) */ + if (!(ttisstring(top-2) || ttisnumber(top-2)) || !tostring(L, top-1)) { + if (!call_binTM(L, top-2, top-1, top-2, TM_CONCAT)) + luaG_concaterror(L, top-2, top-1); + } else if (tsvalue(top-1)->len == 0) /* second op is empty? */ + (void)tostring(L, top - 2); /* result is first op (as string) */ + else { + /* at least two string values; get as many as possible */ + size_t tl = tsvalue(top-1)->len; + char *buffer; + int i; + /* collect total length */ + for (n = 1; n < total && tostring(L, top-n-1); n++) { + size_t l = tsvalue(top-n-1)->len; + if (l >= MAX_SIZET - tl) luaG_runerror(L, "string length overflow"); + tl += l; + } + buffer = luaZ_openspace(L, &G(L)->buff, tl); + tl = 0; + for (i=n; i>0; i--) { /* concat all strings */ + size_t l = tsvalue(top-i)->len; + memcpy(buffer+tl, svalue(top-i), l); + tl += l; + } + setsvalue2s(L, top-n, luaS_newlstr(L, buffer, tl)); + } + total -= n-1; /* got `n' strings to create 1 new */ + last -= n-1; + } while (total > 1); /* repeat until only 1 result left */ +} + + +static void Arith (lua_State *L, StkId ra, const TValue *rb, + const TValue *rc, TMS op) { + TValue tempb, tempc; + const TValue *b, *c; + if ((b = luaV_tonumber(rb, &tempb)) != NULL && + (c = luaV_tonumber(rc, &tempc)) != NULL) { + lua_Number nb = nvalue(b), nc = nvalue(c); + switch (op) { + case TM_ADD: setnvalue(ra, luai_numadd(nb, nc)); break; + case TM_SUB: setnvalue(ra, luai_numsub(nb, nc)); break; + case TM_MUL: setnvalue(ra, luai_nummul(nb, nc)); break; + case TM_DIV: setnvalue(ra, luai_numdiv(nb, nc)); break; + case TM_MOD: setnvalue(ra, luai_nummod(nb, nc)); break; + case TM_POW: setnvalue(ra, luai_numpow(nb, nc)); break; + case TM_UNM: setnvalue(ra, luai_numunm(nb)); break; + default: lua_assert(0); break; + } + } + else if (!call_binTM(L, rb, rc, ra, op)) + luaG_aritherror(L, rb, rc); +} + + + +/* +** some macros for common tasks in `luaV_execute' +*/ + +#define runtime_check(L, c) { if (!(c)) break; } + +#define RA(i) (base+GETARG_A(i)) +/* to be used after possible stack reallocation */ +#define RB(i) check_exp(getBMode(GET_OPCODE(i)) == OpArgR, base+GETARG_B(i)) +#define RC(i) check_exp(getCMode(GET_OPCODE(i)) == OpArgR, base+GETARG_C(i)) +#define RKB(i) check_exp(getBMode(GET_OPCODE(i)) == OpArgK, \ + ISK(GETARG_B(i)) ? k+INDEXK(GETARG_B(i)) : base+GETARG_B(i)) +#define RKC(i) check_exp(getCMode(GET_OPCODE(i)) == OpArgK, \ + ISK(GETARG_C(i)) ? k+INDEXK(GETARG_C(i)) : base+GETARG_C(i)) +#define KBx(i) check_exp(getBMode(GET_OPCODE(i)) == OpArgK, k+GETARG_Bx(i)) + + +#define dojump(L,pc,i) {(pc) += (i); luai_threadyield(L);} + + +#define Protect(x) { L->savedpc = pc; {x;}; base = L->base; } + + +#define arith_op(op,tm) { \ + TValue *rb = RKB(i); \ + TValue *rc = RKC(i); \ + if (ttisnumber(rb) && ttisnumber(rc)) { \ + lua_Number nb = nvalue(rb), nc = nvalue(rc); \ + setnvalue(ra, op(nb, nc)); \ + } \ + else \ + Protect(Arith(L, ra, rb, rc, tm)); \ + } + + + +void luaV_execute (lua_State *L, int nexeccalls) { + LClosure *cl; + StkId base; + TValue *k; + const Instruction *pc; + reentry: /* entry point */ + lua_assert(isLua(L->ci)); + pc = L->savedpc; + cl = &clvalue(L->ci->func)->l; + base = L->base; + k = cl->p->k; + /* main loop of interpreter */ + for (;;) { + const Instruction i = *pc++; + StkId ra; + if ((L->hookmask & (LUA_MASKLINE | LUA_MASKCOUNT)) && + (--L->hookcount == 0 || L->hookmask & LUA_MASKLINE)) { + traceexec(L, pc); + if (L->status == LUA_YIELD) { /* did hook yield? */ + L->savedpc = pc - 1; + return; + } + base = L->base; + } + /* warning!! several calls may realloc the stack and invalidate `ra' */ + ra = RA(i); + lua_assert(base == L->base && L->base == L->ci->base); + lua_assert(base <= L->top && L->top <= L->stack + L->stacksize); + lua_assert(L->top == L->ci->top || luaG_checkopenop(i)); + switch (GET_OPCODE(i)) { + case OP_MOVE: { + setobjs2s(L, ra, RB(i)); + continue; + } + case OP_LOADK: { + setobj2s(L, ra, KBx(i)); + continue; + } + case OP_LOADBOOL: { + setbvalue(ra, GETARG_B(i)); + if (GETARG_C(i)) pc++; /* skip next instruction (if C) */ + continue; + } + case OP_LOADNIL: { + TValue *rb = RB(i); + do { + setnilvalue(rb--); + } while (rb >= ra); + continue; + } + case OP_GETUPVAL: { + int b = GETARG_B(i); + setobj2s(L, ra, cl->upvals[b]->v); + continue; + } + case OP_GETGLOBAL: { + TValue g; + TValue *rb = KBx(i); + sethvalue(L, &g, cl->env); + lua_assert(ttisstring(rb)); + Protect(luaV_gettable(L, &g, rb, ra)); + continue; + } + case OP_GETTABLE: { + Protect(luaV_gettable(L, RB(i), RKC(i), ra)); + continue; + } + case OP_SETGLOBAL: { + TValue g; + sethvalue(L, &g, cl->env); + lua_assert(ttisstring(KBx(i))); + Protect(luaV_settable(L, &g, KBx(i), ra)); + continue; + } + case OP_SETUPVAL: { + UpVal *uv = cl->upvals[GETARG_B(i)]; + setobj(L, uv->v, ra); + luaC_barrier(L, uv, ra); + continue; + } + case OP_SETTABLE: { + Protect(luaV_settable(L, ra, RKB(i), RKC(i))); + continue; + } + case OP_NEWTABLE: { + int b = GETARG_B(i); + int c = GETARG_C(i); + sethvalue(L, ra, luaH_new(L, luaO_fb2int(b), luaO_fb2int(c))); + Protect(luaC_checkGC(L)); + continue; + } + case OP_SELF: { + StkId rb = RB(i); + setobjs2s(L, ra+1, rb); + Protect(luaV_gettable(L, rb, RKC(i), ra)); + continue; + } + case OP_ADD: { + arith_op(luai_numadd, TM_ADD); + continue; + } + case OP_SUB: { + arith_op(luai_numsub, TM_SUB); + continue; + } + case OP_MUL: { + arith_op(luai_nummul, TM_MUL); + continue; + } + case OP_DIV: { + arith_op(luai_numdiv, TM_DIV); + continue; + } + case OP_MOD: { + arith_op(luai_nummod, TM_MOD); + continue; + } + case OP_POW: { + arith_op(luai_numpow, TM_POW); + continue; + } + case OP_UNM: { + TValue *rb = RB(i); + if (ttisnumber(rb)) { + lua_Number nb = nvalue(rb); + setnvalue(ra, luai_numunm(nb)); + } + else { + Protect(Arith(L, ra, rb, rb, TM_UNM)); + } + continue; + } + case OP_NOT: { + int res = l_isfalse(RB(i)); /* next assignment may change this value */ + setbvalue(ra, res); + continue; + } + case OP_LEN: { + const TValue *rb = RB(i); + switch (ttype(rb)) { + case LUA_TTABLE: { + setnvalue(ra, cast_num(luaH_getn(hvalue(rb)))); + break; + } + case LUA_TSTRING: { + setnvalue(ra, cast_num(tsvalue(rb)->len)); + break; + } + default: { /* try metamethod */ + Protect( + if (!call_binTM(L, rb, luaO_nilobject, ra, TM_LEN)) + luaG_typeerror(L, rb, "get length of"); + ) + } + } + continue; + } + case OP_CONCAT: { + int b = GETARG_B(i); + int c = GETARG_C(i); + Protect(luaV_concat(L, c-b+1, c); luaC_checkGC(L)); + setobjs2s(L, RA(i), base+b); + continue; + } + case OP_JMP: { + dojump(L, pc, GETARG_sBx(i)); + continue; + } + case OP_EQ: { + TValue *rb = RKB(i); + TValue *rc = RKC(i); + Protect( + if (equalobj(L, rb, rc) == GETARG_A(i)) + dojump(L, pc, GETARG_sBx(*pc)); + ) + pc++; + continue; + } + case OP_LT: { + Protect( + if (luaV_lessthan(L, RKB(i), RKC(i)) == GETARG_A(i)) + dojump(L, pc, GETARG_sBx(*pc)); + ) + pc++; + continue; + } + case OP_LE: { + Protect( + if (lessequal(L, RKB(i), RKC(i)) == GETARG_A(i)) + dojump(L, pc, GETARG_sBx(*pc)); + ) + pc++; + continue; + } + case OP_TEST: { + if (l_isfalse(ra) != GETARG_C(i)) + dojump(L, pc, GETARG_sBx(*pc)); + pc++; + continue; + } + case OP_TESTSET: { + TValue *rb = RB(i); + if (l_isfalse(rb) != GETARG_C(i)) { + setobjs2s(L, ra, rb); + dojump(L, pc, GETARG_sBx(*pc)); + } + pc++; + continue; + } + case OP_CALL: { + int b = GETARG_B(i); + int nresults = GETARG_C(i) - 1; + if (b != 0) L->top = ra+b; /* else previous instruction set top */ + L->savedpc = pc; + switch (luaD_precall(L, ra, nresults)) { + case PCRLUA: { + nexeccalls++; + goto reentry; /* restart luaV_execute over new Lua function */ + } + case PCRC: { + /* it was a C function (`precall' called it); adjust results */ + if (nresults >= 0) L->top = L->ci->top; + base = L->base; + continue; + } + default: { + return; /* yield */ + } + } + } + case OP_TAILCALL: { + int b = GETARG_B(i); + if (b != 0) L->top = ra+b; /* else previous instruction set top */ + L->savedpc = pc; + lua_assert(GETARG_C(i) - 1 == LUA_MULTRET); + switch (luaD_precall(L, ra, LUA_MULTRET)) { + case PCRLUA: { + /* tail call: put new frame in place of previous one */ + CallInfo *ci = L->ci - 1; /* previous frame */ + int aux; + StkId func = ci->func; + StkId pfunc = (ci+1)->func; /* previous function index */ + if (L->openupval) luaF_close(L, ci->base); + L->base = ci->base = ci->func + ((ci+1)->base - pfunc); + for (aux = 0; pfunc+aux < L->top; aux++) /* move frame down */ + setobjs2s(L, func+aux, pfunc+aux); + ci->top = L->top = func+aux; /* correct top */ + lua_assert(L->top == L->base + clvalue(func)->l.p->maxstacksize); + ci->savedpc = L->savedpc; + ci->tailcalls++; /* one more call lost */ + L->ci--; /* remove new frame */ + goto reentry; + } + case PCRC: { /* it was a C function (`precall' called it) */ + base = L->base; + continue; + } + default: { + return; /* yield */ + } + } + } + case OP_RETURN: { + int b = GETARG_B(i); + if (b != 0) L->top = ra+b-1; + if (L->openupval) luaF_close(L, base); + L->savedpc = pc; + b = luaD_poscall(L, ra); + if (--nexeccalls == 0) /* was previous function running `here'? */ + return; /* no: return */ + else { /* yes: continue its execution */ + if (b) L->top = L->ci->top; + lua_assert(isLua(L->ci)); + lua_assert(GET_OPCODE(*((L->ci)->savedpc - 1)) == OP_CALL); + goto reentry; + } + } + case OP_FORLOOP: { + lua_Number step = nvalue(ra+2); + lua_Number idx = luai_numadd(nvalue(ra), step); /* increment index */ + lua_Number limit = nvalue(ra+1); + if (luai_numlt(0, step) ? luai_numle(idx, limit) + : luai_numle(limit, idx)) { + dojump(L, pc, GETARG_sBx(i)); /* jump back */ + setnvalue(ra, idx); /* update internal index... */ + setnvalue(ra+3, idx); /* ...and external index */ + } + continue; + } + case OP_FORPREP: { + const TValue *init = ra; + const TValue *plimit = ra+1; + const TValue *pstep = ra+2; + L->savedpc = pc; /* next steps may throw errors */ + if (!tonumber(init, ra)) + luaG_runerror(L, LUA_QL("for") " initial value must be a number"); + else if (!tonumber(plimit, ra+1)) + luaG_runerror(L, LUA_QL("for") " limit must be a number"); + else if (!tonumber(pstep, ra+2)) + luaG_runerror(L, LUA_QL("for") " step must be a number"); + setnvalue(ra, luai_numsub(nvalue(ra), nvalue(pstep))); + dojump(L, pc, GETARG_sBx(i)); + continue; + } + case OP_TFORLOOP: { + StkId cb = ra + 3; /* call base */ + setobjs2s(L, cb+2, ra+2); + setobjs2s(L, cb+1, ra+1); + setobjs2s(L, cb, ra); + L->top = cb+3; /* func. + 2 args (state and index) */ + Protect(luaD_call(L, cb, GETARG_C(i))); + L->top = L->ci->top; + cb = RA(i) + 3; /* previous call may change the stack */ + if (!ttisnil(cb)) { /* continue loop? */ + setobjs2s(L, cb-1, cb); /* save control variable */ + dojump(L, pc, GETARG_sBx(*pc)); /* jump back */ + } + pc++; + continue; + } + case OP_SETLIST: { + int n = GETARG_B(i); + int c = GETARG_C(i); + int last; + Table *h; + if (n == 0) { + n = cast_int(L->top - ra) - 1; + L->top = L->ci->top; + } + if (c == 0) c = cast_int(*pc++); + runtime_check(L, ttistable(ra)); + h = hvalue(ra); + last = ((c-1)*LFIELDS_PER_FLUSH) + n; + if (last > h->sizearray) /* needs more space? */ + luaH_resizearray(L, h, last); /* pre-alloc it at once */ + for (; n > 0; n--) { + TValue *val = ra+n; + setobj2t(L, luaH_setnum(L, h, last--), val); + luaC_barriert(L, h, val); + } + continue; + } + case OP_CLOSE: { + luaF_close(L, ra); + continue; + } + case OP_CLOSURE: { + Proto *p; + Closure *ncl; + int nup, j; + p = cl->p->p[GETARG_Bx(i)]; + nup = p->nups; + ncl = luaF_newLclosure(L, nup, cl->env); + ncl->l.p = p; + for (j=0; jl.upvals[j] = cl->upvals[GETARG_B(*pc)]; + else { + lua_assert(GET_OPCODE(*pc) == OP_MOVE); + ncl->l.upvals[j] = luaF_findupval(L, base + GETARG_B(*pc)); + } + } + setclvalue(L, ra, ncl); + Protect(luaC_checkGC(L)); + continue; + } + case OP_VARARG: { + int b = GETARG_B(i) - 1; + int j; + CallInfo *ci = L->ci; + int n = cast_int(ci->base - ci->func) - cl->p->numparams - 1; + if (b == LUA_MULTRET) { + Protect(luaD_checkstack(L, n)); + ra = RA(i); /* previous call may change the stack */ + b = n; + L->top = ra + n; + } + for (j = 0; j < b; j++) { + if (j < n) { + setobjs2s(L, ra + j, ci->base - n + j); + } + else { + setnilvalue(ra + j); + } + } + continue; + } + } + } +} + diff --git a/include/lua/lvm.h b/include/lua/lvm.h new file mode 100644 index 0000000..bfe4f56 --- /dev/null +++ b/include/lua/lvm.h @@ -0,0 +1,36 @@ +/* +** $Id: lvm.h,v 2.5.1.1 2007/12/27 13:02:25 roberto Exp $ +** Lua virtual machine +** See Copyright Notice in lua.h +*/ + +#ifndef lvm_h +#define lvm_h + + +#include "ldo.h" +#include "lobject.h" +#include "ltm.h" + + +#define tostring(L,o) ((ttype(o) == LUA_TSTRING) || (luaV_tostring(L, o))) + +#define tonumber(o,n) (ttype(o) == LUA_TNUMBER || \ + (((o) = luaV_tonumber(o,n)) != NULL)) + +#define equalobj(L,o1,o2) \ + (ttype(o1) == ttype(o2) && luaV_equalval(L, o1, o2)) + + +LUAI_FUNC int luaV_lessthan (lua_State *L, const TValue *l, const TValue *r); +LUAI_FUNC int luaV_equalval (lua_State *L, const TValue *t1, const TValue *t2); +LUAI_FUNC const TValue *luaV_tonumber (const TValue *obj, TValue *n); +LUAI_FUNC int luaV_tostring (lua_State *L, StkId obj); +LUAI_FUNC void luaV_gettable (lua_State *L, const TValue *t, TValue *key, + StkId val); +LUAI_FUNC void luaV_settable (lua_State *L, const TValue *t, TValue *key, + StkId val); +LUAI_FUNC void luaV_execute (lua_State *L, int nexeccalls); +LUAI_FUNC void luaV_concat (lua_State *L, int total, int last); + +#endif diff --git a/include/lua/lzio.c b/include/lua/lzio.c new file mode 100644 index 0000000..293edd5 --- /dev/null +++ b/include/lua/lzio.c @@ -0,0 +1,82 @@ +/* +** $Id: lzio.c,v 1.31.1.1 2007/12/27 13:02:25 roberto Exp $ +** a generic input stream interface +** See Copyright Notice in lua.h +*/ + + +#include + +#define lzio_c +#define LUA_CORE + +#include "lua.h" + +#include "llimits.h" +#include "lmem.h" +#include "lstate.h" +#include "lzio.h" + + +int luaZ_fill (ZIO *z) { + size_t size; + lua_State *L = z->L; + const char *buff; + lua_unlock(L); + buff = z->reader(L, z->data, &size); + lua_lock(L); + if (buff == NULL || size == 0) return EOZ; + z->n = size - 1; + z->p = buff; + return char2int(*(z->p++)); +} + + +int luaZ_lookahead (ZIO *z) { + if (z->n == 0) { + if (luaZ_fill(z) == EOZ) + return EOZ; + else { + z->n++; /* luaZ_fill removed first byte; put back it */ + z->p--; + } + } + return char2int(*z->p); +} + + +void luaZ_init (lua_State *L, ZIO *z, lua_Reader reader, void *data) { + z->L = L; + z->reader = reader; + z->data = data; + z->n = 0; + z->p = NULL; +} + + +/* --------------------------------------------------------------- read --- */ +size_t luaZ_read (ZIO *z, void *b, size_t n) { + while (n) { + size_t m; + if (luaZ_lookahead(z) == EOZ) + return n; /* return number of missing bytes */ + m = (n <= z->n) ? n : z->n; /* min. between n and z->n */ + memcpy(b, z->p, m); + z->n -= m; + z->p += m; + b = (char *)b + m; + n -= m; + } + return 0; +} + +/* ------------------------------------------------------------------------ */ +char *luaZ_openspace (lua_State *L, Mbuffer *buff, size_t n) { + if (n > buff->buffsize) { + if (n < LUA_MINBUFFER) n = LUA_MINBUFFER; + luaZ_resizebuffer(L, buff, n); + } + return buff->buffer; +} + + diff --git a/include/lua/lzio.h b/include/lua/lzio.h new file mode 100644 index 0000000..51d695d --- /dev/null +++ b/include/lua/lzio.h @@ -0,0 +1,67 @@ +/* +** $Id: lzio.h,v 1.21.1.1 2007/12/27 13:02:25 roberto Exp $ +** Buffered streams +** See Copyright Notice in lua.h +*/ + + +#ifndef lzio_h +#define lzio_h + +#include "lua.h" + +#include "lmem.h" + + +#define EOZ (-1) /* end of stream */ + +typedef struct Zio ZIO; + +#define char2int(c) cast(int, cast(unsigned char, (c))) + +#define zgetc(z) (((z)->n--)>0 ? char2int(*(z)->p++) : luaZ_fill(z)) + +typedef struct Mbuffer { + char *buffer; + size_t n; + size_t buffsize; +} Mbuffer; + +#define luaZ_initbuffer(L, buff) ((buff)->buffer = NULL, (buff)->buffsize = 0) + +#define luaZ_buffer(buff) ((buff)->buffer) +#define luaZ_sizebuffer(buff) ((buff)->buffsize) +#define luaZ_bufflen(buff) ((buff)->n) + +#define luaZ_resetbuffer(buff) ((buff)->n = 0) + + +#define luaZ_resizebuffer(L, buff, size) \ + (luaM_reallocvector(L, (buff)->buffer, (buff)->buffsize, size, char), \ + (buff)->buffsize = size) + +#define luaZ_freebuffer(L, buff) luaZ_resizebuffer(L, buff, 0) + + +LUAI_FUNC char *luaZ_openspace (lua_State *L, Mbuffer *buff, size_t n); +LUAI_FUNC void luaZ_init (lua_State *L, ZIO *z, lua_Reader reader, + void *data); +LUAI_FUNC size_t luaZ_read (ZIO* z, void* b, size_t n); /* read next n bytes */ +LUAI_FUNC int luaZ_lookahead (ZIO *z); + + + +/* --------- Private Part ------------------ */ + +struct Zio { + size_t n; /* bytes still unread */ + const char *p; /* current position in buffer */ + lua_Reader reader; + void* data; /* additional data */ + lua_State *L; /* Lua state (for reader) */ +}; + + +LUAI_FUNC int luaZ_fill (ZIO *z); + +#endif diff --git a/include/lua/print.c b/include/lua/print.c new file mode 100644 index 0000000..e240cfc --- /dev/null +++ b/include/lua/print.c @@ -0,0 +1,227 @@ +/* +** $Id: print.c,v 1.55a 2006/05/31 13:30:05 lhf Exp $ +** print bytecodes +** See Copyright Notice in lua.h +*/ + +#include +#include + +#define luac_c +#define LUA_CORE + +#include "ldebug.h" +#include "lobject.h" +#include "lopcodes.h" +#include "lundump.h" + +#define PrintFunction luaU_print + +#define Sizeof(x) ((int)sizeof(x)) +#define VOID(p) ((const void*)(p)) + +static void PrintString(const TString* ts) +{ + const char* s=getstr(ts); + size_t i,n=ts->tsv.len; + putchar('"'); + for (i=0; ik[i]; + switch (ttype(o)) + { + case LUA_TNIL: + printf("nil"); + break; + case LUA_TBOOLEAN: + printf(bvalue(o) ? "true" : "false"); + break; + case LUA_TNUMBER: + printf(LUA_NUMBER_FMT,nvalue(o)); + break; + case LUA_TSTRING: + PrintString(rawtsvalue(o)); + break; + default: /* cannot happen */ + printf("? type=%d",ttype(o)); + break; + } +} + +static void PrintCode(const Proto* f) +{ + const Instruction* code=f->code; + int pc,n=f->sizecode; + for (pc=0; pc0) printf("[%d]\t",line); else printf("[-]\t"); + printf("%-9s\t",luaP_opnames[o]); + switch (getOpMode(o)) + { + case iABC: + printf("%d",a); + if (getBMode(o)!=OpArgN) printf(" %d",ISK(b) ? (-1-INDEXK(b)) : b); + if (getCMode(o)!=OpArgN) printf(" %d",ISK(c) ? (-1-INDEXK(c)) : c); + break; + case iABx: + if (getBMode(o)==OpArgK) printf("%d %d",a,-1-bx); else printf("%d %d",a,bx); + break; + case iAsBx: + if (o==OP_JMP) printf("%d",sbx); else printf("%d %d",a,sbx); + break; + } + switch (o) + { + case OP_LOADK: + printf("\t; "); PrintConstant(f,bx); + break; + case OP_GETUPVAL: + case OP_SETUPVAL: + printf("\t; %s", (f->sizeupvalues>0) ? getstr(f->upvalues[b]) : "-"); + break; + case OP_GETGLOBAL: + case OP_SETGLOBAL: + printf("\t; %s",svalue(&f->k[bx])); + break; + case OP_GETTABLE: + case OP_SELF: + if (ISK(c)) { printf("\t; "); PrintConstant(f,INDEXK(c)); } + break; + case OP_SETTABLE: + case OP_ADD: + case OP_SUB: + case OP_MUL: + case OP_DIV: + case OP_POW: + case OP_EQ: + case OP_LT: + case OP_LE: + if (ISK(b) || ISK(c)) + { + printf("\t; "); + if (ISK(b)) PrintConstant(f,INDEXK(b)); else printf("-"); + printf(" "); + if (ISK(c)) PrintConstant(f,INDEXK(c)); else printf("-"); + } + break; + case OP_JMP: + case OP_FORLOOP: + case OP_FORPREP: + printf("\t; to %d",sbx+pc+2); + break; + case OP_CLOSURE: + printf("\t; %p",VOID(f->p[bx])); + break; + case OP_SETLIST: + if (c==0) printf("\t; %d",(int)code[++pc]); + else printf("\t; %d",c); + break; + default: + break; + } + printf("\n"); + } +} + +#define SS(x) (x==1)?"":"s" +#define S(x) x,SS(x) + +static void PrintHeader(const Proto* f) +{ + const char* s=getstr(f->source); + if (*s=='@' || *s=='=') + s++; + else if (*s==LUA_SIGNATURE[0]) + s="(bstring)"; + else + s="(string)"; + printf("\n%s <%s:%d,%d> (%d instruction%s, %d bytes at %p)\n", + (f->linedefined==0)?"main":"function",s, + f->linedefined,f->lastlinedefined, + S(f->sizecode),f->sizecode*Sizeof(Instruction),VOID(f)); + printf("%d%s param%s, %d slot%s, %d upvalue%s, ", + f->numparams,f->is_vararg?"+":"",SS(f->numparams), + S(f->maxstacksize),S(f->nups)); + printf("%d local%s, %d constant%s, %d function%s\n", + S(f->sizelocvars),S(f->sizek),S(f->sizep)); +} + +static void PrintConstants(const Proto* f) +{ + int i,n=f->sizek; + printf("constants (%d) for %p:\n",n,VOID(f)); + for (i=0; isizelocvars; + printf("locals (%d) for %p:\n",n,VOID(f)); + for (i=0; ilocvars[i].varname),f->locvars[i].startpc+1,f->locvars[i].endpc+1); + } +} + +static void PrintUpvalues(const Proto* f) +{ + int i,n=f->sizeupvalues; + printf("upvalues (%d) for %p:\n",n,VOID(f)); + if (f->upvalues==NULL) return; + for (i=0; iupvalues[i])); + } +} + +void PrintFunction(const Proto* f, int full) +{ + int i,n=f->sizep; + PrintHeader(f); + PrintCode(f); + if (full) + { + PrintConstants(f); + PrintLocals(f); + PrintUpvalues(f); + } + for (i=0; ip[i],full); +} diff --git a/include/luaconf.h b/include/luaconf.h new file mode 100644 index 0000000..e2cb261 --- /dev/null +++ b/include/luaconf.h @@ -0,0 +1,763 @@ +/* +** $Id: luaconf.h,v 1.82.1.7 2008/02/11 16:25:08 roberto Exp $ +** Configuration file for Lua +** See Copyright Notice in lua.h +*/ + + +#ifndef lconfig_h +#define lconfig_h + +#include +#include + + +/* +** ================================================================== +** Search for "@@" to find all configurable definitions. +** =================================================================== +*/ + + +/* +@@ LUA_ANSI controls the use of non-ansi features. +** CHANGE it (define it) if you want Lua to avoid the use of any +** non-ansi feature or library. +*/ +#if defined(__STRICT_ANSI__) +#define LUA_ANSI +#endif + + +#if !defined(LUA_ANSI) && defined(_WIN32) +#define LUA_WIN +#endif + +#if defined(LUA_USE_LINUX) +#define LUA_USE_POSIX +#define LUA_USE_DLOPEN /* needs an extra library: -ldl */ +#define LUA_USE_READLINE /* needs some extra libraries */ +#endif + +#if defined(LUA_USE_MACOSX) +#define LUA_USE_POSIX +#define LUA_DL_DYLD /* does not need extra library */ +#endif + + + +/* +@@ LUA_USE_POSIX includes all functionallity listed as X/Open System +@* Interfaces Extension (XSI). +** CHANGE it (define it) if your system is XSI compatible. +*/ +#if defined(LUA_USE_POSIX) +#define LUA_USE_MKSTEMP +#define LUA_USE_ISATTY +#define LUA_USE_POPEN +#define LUA_USE_ULONGJMP +#endif + + +/* +@@ LUA_PATH and LUA_CPATH are the names of the environment variables that +@* Lua check to set its paths. +@@ LUA_INIT is the name of the environment variable that Lua +@* checks for initialization code. +** CHANGE them if you want different names. +*/ +#define LUA_PATH "LUA_PATH" +#define LUA_CPATH "LUA_CPATH" +#define LUA_INIT "LUA_INIT" + + +/* +@@ LUA_PATH_DEFAULT is the default path that Lua uses to look for +@* Lua libraries. +@@ LUA_CPATH_DEFAULT is the default path that Lua uses to look for +@* C libraries. +** CHANGE them if your machine has a non-conventional directory +** hierarchy or if you want to install your libraries in +** non-conventional directories. +*/ +#if defined(_WIN32) +/* +** In Windows, any exclamation mark ('!') in the path is replaced by the +** path of the directory of the executable file of the current process. +*/ +#define LUA_LDIR "!\\lua\\" +#define LUA_CDIR "!\\" +#define LUA_PATH_DEFAULT \ + ".\\?.lua;" LUA_LDIR"?.lua;" LUA_LDIR"?\\init.lua;" \ + LUA_CDIR"?.lua;" LUA_CDIR"?\\init.lua" +#define LUA_CPATH_DEFAULT \ + ".\\?.dll;" LUA_CDIR"?.dll;" LUA_CDIR"loadall.dll" + +#else +#define LUA_ROOT "/usr/local/" +#define LUA_LDIR LUA_ROOT "share/lua/5.1/" +#define LUA_CDIR LUA_ROOT "lib/lua/5.1/" +#define LUA_PATH_DEFAULT \ + "./?.lua;" LUA_LDIR"?.lua;" LUA_LDIR"?/init.lua;" \ + LUA_CDIR"?.lua;" LUA_CDIR"?/init.lua" +#define LUA_CPATH_DEFAULT \ + "./?.so;" LUA_CDIR"?.so;" LUA_CDIR"loadall.so" +#endif + + +/* +@@ LUA_DIRSEP is the directory separator (for submodules). +** CHANGE it if your machine does not use "/" as the directory separator +** and is not Windows. (On Windows Lua automatically uses "\".) +*/ +#if defined(_WIN32) +#define LUA_DIRSEP "\\" +#else +#define LUA_DIRSEP "/" +#endif + + +/* +@@ LUA_PATHSEP is the character that separates templates in a path. +@@ LUA_PATH_MARK is the string that marks the substitution points in a +@* template. +@@ LUA_EXECDIR in a Windows path is replaced by the executable's +@* directory. +@@ LUA_IGMARK is a mark to ignore all before it when bulding the +@* luaopen_ function name. +** CHANGE them if for some reason your system cannot use those +** characters. (E.g., if one of those characters is a common character +** in file/directory names.) Probably you do not need to change them. +*/ +#define LUA_PATHSEP ";" +#define LUA_PATH_MARK "?" +#define LUA_EXECDIR "!" +#define LUA_IGMARK "-" + + +/* +@@ LUA_INTEGER is the integral type used by lua_pushinteger/lua_tointeger. +** CHANGE that if ptrdiff_t is not adequate on your machine. (On most +** machines, ptrdiff_t gives a good choice between int or long.) +*/ +#define LUA_INTEGER ptrdiff_t + + +/* +@@ LUA_API is a mark for all core API functions. +@@ LUALIB_API is a mark for all standard library functions. +** CHANGE them if you need to define those functions in some special way. +** For instance, if you want to create one Windows DLL with the core and +** the libraries, you may want to use the following definition (define +** LUA_BUILD_AS_DLL to get it). +*/ +#if defined(LUA_BUILD_AS_DLL) + +#if defined(LUA_CORE) || defined(LUA_LIB) +#define LUA_API __declspec(dllexport) +#else +#define LUA_API __declspec(dllimport) +#endif + +#else + +#define LUA_API extern + +#endif + +/* more often than not the libs go together with the core */ +#define LUALIB_API LUA_API + + +/* +@@ LUAI_FUNC is a mark for all extern functions that are not to be +@* exported to outside modules. +@@ LUAI_DATA is a mark for all extern (const) variables that are not to +@* be exported to outside modules. +** CHANGE them if you need to mark them in some special way. Elf/gcc +** (versions 3.2 and later) mark them as "hidden" to optimize access +** when Lua is compiled as a shared library. +*/ +#if defined(luaall_c) +#define LUAI_FUNC static +#define LUAI_DATA /* empty */ + +#elif defined(__GNUC__) && ((__GNUC__*100 + __GNUC_MINOR__) >= 302) && \ + defined(__ELF__) +#define LUAI_FUNC __attribute__((visibility("hidden"))) extern +#define LUAI_DATA LUAI_FUNC + +#else +#define LUAI_FUNC extern +#define LUAI_DATA extern +#endif + + + +/* +@@ LUA_QL describes how error messages quote program elements. +** CHANGE it if you want a different appearance. +*/ +#define LUA_QL(x) "'" x "'" +#define LUA_QS LUA_QL("%s") + + +/* +@@ LUA_IDSIZE gives the maximum size for the description of the source +@* of a function in debug information. +** CHANGE it if you want a different size. +*/ +#define LUA_IDSIZE 60 + + +/* +** {================================================================== +** Stand-alone configuration +** =================================================================== +*/ + +#if defined(lua_c) || defined(luaall_c) + +/* +@@ lua_stdin_is_tty detects whether the standard input is a 'tty' (that +@* is, whether we're running lua interactively). +** CHANGE it if you have a better definition for non-POSIX/non-Windows +** systems. +*/ +#if defined(LUA_USE_ISATTY) +#include +#define lua_stdin_is_tty() isatty(0) +#elif defined(LUA_WIN) +#include +#include +#define lua_stdin_is_tty() _isatty(_fileno(stdin)) +#else +#define lua_stdin_is_tty() 1 /* assume stdin is a tty */ +#endif + + +/* +@@ LUA_PROMPT is the default prompt used by stand-alone Lua. +@@ LUA_PROMPT2 is the default continuation prompt used by stand-alone Lua. +** CHANGE them if you want different prompts. (You can also change the +** prompts dynamically, assigning to globals _PROMPT/_PROMPT2.) +*/ +#define LUA_PROMPT "> " +#define LUA_PROMPT2 ">> " + + +/* +@@ LUA_PROGNAME is the default name for the stand-alone Lua program. +** CHANGE it if your stand-alone interpreter has a different name and +** your system is not able to detect that name automatically. +*/ +#define LUA_PROGNAME "lua" + + +/* +@@ LUA_MAXINPUT is the maximum length for an input line in the +@* stand-alone interpreter. +** CHANGE it if you need longer lines. +*/ +#define LUA_MAXINPUT 512 + + +/* +@@ lua_readline defines how to show a prompt and then read a line from +@* the standard input. +@@ lua_saveline defines how to "save" a read line in a "history". +@@ lua_freeline defines how to free a line read by lua_readline. +** CHANGE them if you want to improve this functionality (e.g., by using +** GNU readline and history facilities). +*/ +#if defined(LUA_USE_READLINE) +#include +#include +#include +#define lua_readline(L,b,p) ((void)L, ((b)=readline(p)) != NULL) +#define lua_saveline(L,idx) \ + if (lua_strlen(L,idx) > 0) /* non-empty line? */ \ + add_history(lua_tostring(L, idx)); /* add it to history */ +#define lua_freeline(L,b) ((void)L, free(b)) +#else +#define lua_readline(L,b,p) \ + ((void)L, fputs(p, stdout), fflush(stdout), /* show prompt */ \ + fgets(b, LUA_MAXINPUT, stdin) != NULL) /* get line */ +#define lua_saveline(L,idx) { (void)L; (void)idx; } +#define lua_freeline(L,b) { (void)L; (void)b; } +#endif + +#endif + +/* }================================================================== */ + + +/* +@@ LUAI_GCPAUSE defines the default pause between garbage-collector cycles +@* as a percentage. +** CHANGE it if you want the GC to run faster or slower (higher values +** mean larger pauses which mean slower collection.) You can also change +** this value dynamically. +*/ +#define LUAI_GCPAUSE 200 /* 200% (wait memory to double before next GC) */ + + +/* +@@ LUAI_GCMUL defines the default speed of garbage collection relative to +@* memory allocation as a percentage. +** CHANGE it if you want to change the granularity of the garbage +** collection. (Higher values mean coarser collections. 0 represents +** infinity, where each step performs a full collection.) You can also +** change this value dynamically. +*/ +#define LUAI_GCMUL 200 /* GC runs 'twice the speed' of memory allocation */ + + + +/* +@@ LUA_COMPAT_GETN controls compatibility with old getn behavior. +** CHANGE it (define it) if you want exact compatibility with the +** behavior of setn/getn in Lua 5.0. +*/ +#undef LUA_COMPAT_GETN + +/* +@@ LUA_COMPAT_LOADLIB controls compatibility about global loadlib. +** CHANGE it to undefined as soon as you do not need a global 'loadlib' +** function (the function is still available as 'package.loadlib'). +*/ +#undef LUA_COMPAT_LOADLIB + +/* +@@ LUA_COMPAT_VARARG controls compatibility with old vararg feature. +** CHANGE it to undefined as soon as your programs use only '...' to +** access vararg parameters (instead of the old 'arg' table). +*/ +#define LUA_COMPAT_VARARG + +/* +@@ LUA_COMPAT_MOD controls compatibility with old math.mod function. +** CHANGE it to undefined as soon as your programs use 'math.fmod' or +** the new '%' operator instead of 'math.mod'. +*/ +#define LUA_COMPAT_MOD + +/* +@@ LUA_COMPAT_LSTR controls compatibility with old long string nesting +@* facility. +** CHANGE it to 2 if you want the old behaviour, or undefine it to turn +** off the advisory error when nesting [[...]]. +*/ +#define LUA_COMPAT_LSTR 1 + +/* +@@ LUA_COMPAT_GFIND controls compatibility with old 'string.gfind' name. +** CHANGE it to undefined as soon as you rename 'string.gfind' to +** 'string.gmatch'. +*/ +#define LUA_COMPAT_GFIND + +/* +@@ LUA_COMPAT_OPENLIB controls compatibility with old 'luaL_openlib' +@* behavior. +** CHANGE it to undefined as soon as you replace to 'luaL_register' +** your uses of 'luaL_openlib' +*/ +#define LUA_COMPAT_OPENLIB + + + +/* +@@ luai_apicheck is the assert macro used by the Lua-C API. +** CHANGE luai_apicheck if you want Lua to perform some checks in the +** parameters it gets from API calls. This may slow down the interpreter +** a bit, but may be quite useful when debugging C code that interfaces +** with Lua. A useful redefinition is to use assert.h. +*/ +#if defined(LUA_USE_APICHECK) +#include +#define luai_apicheck(L,o) { (void)L; assert(o); } +#else +#define luai_apicheck(L,o) { (void)L; } +#endif + + +/* +@@ LUAI_BITSINT defines the number of bits in an int. +** CHANGE here if Lua cannot automatically detect the number of bits of +** your machine. Probably you do not need to change this. +*/ +/* avoid overflows in comparison */ +#if INT_MAX-20 < 32760 +#define LUAI_BITSINT 16 +#elif INT_MAX > 2147483640L +/* int has at least 32 bits */ +#define LUAI_BITSINT 32 +#else +#error "you must define LUA_BITSINT with number of bits in an integer" +#endif + + +/* +@@ LUAI_UINT32 is an unsigned integer with at least 32 bits. +@@ LUAI_INT32 is an signed integer with at least 32 bits. +@@ LUAI_UMEM is an unsigned integer big enough to count the total +@* memory used by Lua. +@@ LUAI_MEM is a signed integer big enough to count the total memory +@* used by Lua. +** CHANGE here if for some weird reason the default definitions are not +** good enough for your machine. (The definitions in the 'else' +** part always works, but may waste space on machines with 64-bit +** longs.) Probably you do not need to change this. +*/ +#if LUAI_BITSINT >= 32 +#define LUAI_UINT32 unsigned int +#define LUAI_INT32 int +#define LUAI_MAXINT32 INT_MAX +#define LUAI_UMEM size_t +#define LUAI_MEM ptrdiff_t +#else +/* 16-bit ints */ +#define LUAI_UINT32 unsigned long +#define LUAI_INT32 long +#define LUAI_MAXINT32 LONG_MAX +#define LUAI_UMEM unsigned long +#define LUAI_MEM long +#endif + + +/* +@@ LUAI_MAXCALLS limits the number of nested calls. +** CHANGE it if you need really deep recursive calls. This limit is +** arbitrary; its only purpose is to stop infinite recursion before +** exhausting memory. +*/ +#define LUAI_MAXCALLS 20000 + + +/* +@@ LUAI_MAXCSTACK limits the number of Lua stack slots that a C function +@* can use. +** CHANGE it if you need lots of (Lua) stack space for your C +** functions. This limit is arbitrary; its only purpose is to stop C +** functions to consume unlimited stack space. (must be smaller than +** -LUA_REGISTRYINDEX) +*/ +#define LUAI_MAXCSTACK 8000 + + + +/* +** {================================================================== +** CHANGE (to smaller values) the following definitions if your system +** has a small C stack. (Or you may want to change them to larger +** values if your system has a large C stack and these limits are +** too rigid for you.) Some of these constants control the size of +** stack-allocated arrays used by the compiler or the interpreter, while +** others limit the maximum number of recursive calls that the compiler +** or the interpreter can perform. Values too large may cause a C stack +** overflow for some forms of deep constructs. +** =================================================================== +*/ + + +/* +@@ LUAI_MAXCCALLS is the maximum depth for nested C calls (short) and +@* syntactical nested non-terminals in a program. +*/ +#define LUAI_MAXCCALLS 200 + + +/* +@@ LUAI_MAXVARS is the maximum number of local variables per function +@* (must be smaller than 250). +*/ +#define LUAI_MAXVARS 200 + + +/* +@@ LUAI_MAXUPVALUES is the maximum number of upvalues per function +@* (must be smaller than 250). +*/ +#define LUAI_MAXUPVALUES 60 + + +/* +@@ LUAL_BUFFERSIZE is the buffer size used by the lauxlib buffer system. +*/ +#define LUAL_BUFFERSIZE BUFSIZ + +/* }================================================================== */ + + + + +/* +** {================================================================== +@@ LUA_NUMBER is the type of numbers in Lua. +** CHANGE the following definitions only if you want to build Lua +** with a number type different from double. You may also need to +** change lua_number2int & lua_number2integer. +** =================================================================== +*/ + +#define LUA_NUMBER_DOUBLE +#define LUA_NUMBER double + +/* +@@ LUAI_UACNUMBER is the result of an 'usual argument conversion' +@* over a number. +*/ +#define LUAI_UACNUMBER double + + +/* +@@ LUA_NUMBER_SCAN is the format for reading numbers. +@@ LUA_NUMBER_FMT is the format for writing numbers. +@@ lua_number2str converts a number to a string. +@@ LUAI_MAXNUMBER2STR is maximum size of previous conversion. +@@ lua_str2number converts a string to a number. +*/ +#define LUA_NUMBER_SCAN "%lf" +#define LUA_NUMBER_FMT "%.14g" +#define lua_number2str(s,n) sprintf((s), LUA_NUMBER_FMT, (n)) +#define LUAI_MAXNUMBER2STR 32 /* 16 digits, sign, point, and \0 */ +#define lua_str2number(s,p) strtod((s), (p)) + + +/* +@@ The luai_num* macros define the primitive operations over numbers. +*/ +#if defined(LUA_CORE) +#include +#define luai_numadd(a,b) ((a)+(b)) +#define luai_numsub(a,b) ((a)-(b)) +#define luai_nummul(a,b) ((a)*(b)) +#define luai_numdiv(a,b) ((a)/(b)) +#define luai_nummod(a,b) ((a) - floor((a)/(b))*(b)) +#define luai_numpow(a,b) (pow(a,b)) +#define luai_numunm(a) (-(a)) +#define luai_numeq(a,b) ((a)==(b)) +#define luai_numlt(a,b) ((a)<(b)) +#define luai_numle(a,b) ((a)<=(b)) +#define luai_numisnan(a) (!luai_numeq((a), (a))) +#endif + + +/* +@@ lua_number2int is a macro to convert lua_Number to int. +@@ lua_number2integer is a macro to convert lua_Number to lua_Integer. +** CHANGE them if you know a faster way to convert a lua_Number to +** int (with any rounding method and without throwing errors) in your +** system. In Pentium machines, a naive typecast from double to int +** in C is extremely slow, so any alternative is worth trying. +*/ + +/* On a Pentium, resort to a trick */ +#if defined(LUA_NUMBER_DOUBLE) && !defined(LUA_ANSI) && !defined(__SSE2__) && \ + (defined(__i386) || defined (_M_IX86) || defined(__i386__)) + +/* On a Microsoft compiler, use assembler */ +#if defined(_MSC_VER) + +#define lua_number2int(i,d) __asm fld d __asm fistp i +#define lua_number2integer(i,n) lua_number2int(i, n) + +/* the next trick should work on any Pentium, but sometimes clashes + with a DirectX idiosyncrasy */ +#else + +union luai_Cast { double l_d; long l_l; }; +#define lua_number2int(i,d) \ + { volatile union luai_Cast u; u.l_d = (d) + 6755399441055744.0; (i) = u.l_l; } +#define lua_number2integer(i,n) lua_number2int(i, n) + +#endif + + +/* this option always works, but may be slow */ +#else +#define lua_number2int(i,d) ((i)=(int)(d)) +#define lua_number2integer(i,d) ((i)=(lua_Integer)(d)) + +#endif + +/* }================================================================== */ + + +/* +@@ LUAI_USER_ALIGNMENT_T is a type that requires maximum alignment. +** CHANGE it if your system requires alignments larger than double. (For +** instance, if your system supports long doubles and they must be +** aligned in 16-byte boundaries, then you should add long double in the +** union.) Probably you do not need to change this. +*/ +#define LUAI_USER_ALIGNMENT_T union { double u; void *s; long l; } + + +/* +@@ LUAI_THROW/LUAI_TRY define how Lua does exception handling. +** CHANGE them if you prefer to use longjmp/setjmp even with C++ +** or if want/don't to use _longjmp/_setjmp instead of regular +** longjmp/setjmp. By default, Lua handles errors with exceptions when +** compiling as C++ code, with _longjmp/_setjmp when asked to use them, +** and with longjmp/setjmp otherwise. +*/ +#if defined(__cplusplus) +/* C++ exceptions */ +#define LUAI_THROW(L,c) throw(c) +#define LUAI_TRY(L,c,a) try { a } catch(...) \ + { if ((c)->status == 0) (c)->status = -1; } +#define luai_jmpbuf int /* dummy variable */ + +#elif defined(LUA_USE_ULONGJMP) +/* in Unix, try _longjmp/_setjmp (more efficient) */ +#define LUAI_THROW(L,c) _longjmp((c)->b, 1) +#define LUAI_TRY(L,c,a) if (_setjmp((c)->b) == 0) { a } +#define luai_jmpbuf jmp_buf + +#else +/* default handling with long jumps */ +#define LUAI_THROW(L,c) longjmp((c)->b, 1) +#define LUAI_TRY(L,c,a) if (setjmp((c)->b) == 0) { a } +#define luai_jmpbuf jmp_buf + +#endif + + +/* +@@ LUA_MAXCAPTURES is the maximum number of captures that a pattern +@* can do during pattern-matching. +** CHANGE it if you need more captures. This limit is arbitrary. +*/ +#define LUA_MAXCAPTURES 32 + + +/* +@@ lua_tmpnam is the function that the OS library uses to create a +@* temporary name. +@@ LUA_TMPNAMBUFSIZE is the maximum size of a name created by lua_tmpnam. +** CHANGE them if you have an alternative to tmpnam (which is considered +** insecure) or if you want the original tmpnam anyway. By default, Lua +** uses tmpnam except when POSIX is available, where it uses mkstemp. +*/ +#if defined(loslib_c) || defined(luaall_c) + +#if defined(LUA_USE_MKSTEMP) +#include +#define LUA_TMPNAMBUFSIZE 32 +#define lua_tmpnam(b,e) { \ + strcpy(b, "/tmp/lua_XXXXXX"); \ + e = mkstemp(b); \ + if (e != -1) close(e); \ + e = (e == -1); } + +#else +#define LUA_TMPNAMBUFSIZE L_tmpnam +#define lua_tmpnam(b,e) { e = (tmpnam(b) == NULL); } +#endif + +#endif + + +/* +@@ lua_popen spawns a new process connected to the current one through +@* the file streams. +** CHANGE it if you have a way to implement it in your system. +*/ +#if defined(LUA_USE_POPEN) + +#define lua_popen(L,c,m) ((void)L, fflush(NULL), popen(c,m)) +#define lua_pclose(L,file) ((void)L, (pclose(file) != -1)) + +#elif defined(LUA_WIN) + +#define lua_popen(L,c,m) ((void)L, _popen(c,m)) +#define lua_pclose(L,file) ((void)L, (_pclose(file) != -1)) + +#else + +#define lua_popen(L,c,m) ((void)((void)c, m), \ + luaL_error(L, LUA_QL("popen") " not supported"), (FILE*)0) +#define lua_pclose(L,file) ((void)((void)L, file), 0) + +#endif + +/* +@@ LUA_DL_* define which dynamic-library system Lua should use. +** CHANGE here if Lua has problems choosing the appropriate +** dynamic-library system for your platform (either Windows' DLL, Mac's +** dyld, or Unix's dlopen). If your system is some kind of Unix, there +** is a good chance that it has dlopen, so LUA_DL_DLOPEN will work for +** it. To use dlopen you also need to adapt the src/Makefile (probably +** adding -ldl to the linker options), so Lua does not select it +** automatically. (When you change the makefile to add -ldl, you must +** also add -DLUA_USE_DLOPEN.) +** If you do not want any kind of dynamic library, undefine all these +** options. +** By default, _WIN32 gets LUA_DL_DLL and MAC OS X gets LUA_DL_DYLD. +*/ +#if defined(LUA_USE_DLOPEN) +#define LUA_DL_DLOPEN +#endif + +#if defined(LUA_WIN) +#define LUA_DL_DLL +#endif + + +/* +@@ LUAI_EXTRASPACE allows you to add user-specific data in a lua_State +@* (the data goes just *before* the lua_State pointer). +** CHANGE (define) this if you really need that. This value must be +** a multiple of the maximum alignment required for your machine. +*/ +#define LUAI_EXTRASPACE 0 + + +/* +@@ luai_userstate* allow user-specific actions on threads. +** CHANGE them if you defined LUAI_EXTRASPACE and need to do something +** extra when a thread is created/deleted/resumed/yielded. +*/ +#define luai_userstateopen(L) ((void)L) +#define luai_userstateclose(L) ((void)L) +#define luai_userstatethread(L,L1) ((void)L) +#define luai_userstatefree(L) ((void)L) +#define luai_userstateresume(L,n) ((void)L) +#define luai_userstateyield(L,n) ((void)L) + + +/* +@@ LUA_INTFRMLEN is the length modifier for integer conversions +@* in 'string.format'. +@@ LUA_INTFRM_T is the integer type correspoding to the previous length +@* modifier. +** CHANGE them if your system supports long long or does not support long. +*/ + +#if defined(LUA_USELONGLONG) + +#define LUA_INTFRMLEN "ll" +#define LUA_INTFRM_T long long + +#else + +#define LUA_INTFRMLEN "l" +#define LUA_INTFRM_T long + +#endif + + + +/* =================================================================== */ + +/* +** Local configuration. You can use this space to add your redefinitions +** without modifying the main part of the file. +*/ + + + +#endif + diff --git a/include/lualib.h b/include/lualib.h new file mode 100644 index 0000000..469417f --- /dev/null +++ b/include/lualib.h @@ -0,0 +1,53 @@ +/* +** $Id: lualib.h,v 1.36.1.1 2007/12/27 13:02:25 roberto Exp $ +** Lua standard libraries +** See Copyright Notice in lua.h +*/ + + +#ifndef lualib_h +#define lualib_h + +#include "lua.h" + + +/* Key to file-handle type */ +#define LUA_FILEHANDLE "FILE*" + + +#define LUA_COLIBNAME "coroutine" +LUALIB_API int (luaopen_base) (lua_State *L); + +#define LUA_TABLIBNAME "table" +LUALIB_API int (luaopen_table) (lua_State *L); + +#define LUA_IOLIBNAME "io" +LUALIB_API int (luaopen_io) (lua_State *L); + +#define LUA_OSLIBNAME "os" +LUALIB_API int (luaopen_os) (lua_State *L); + +#define LUA_STRLIBNAME "string" +LUALIB_API int (luaopen_string) (lua_State *L); + +#define LUA_MATHLIBNAME "math" +LUALIB_API int (luaopen_math) (lua_State *L); + +#define LUA_DBLIBNAME "debug" +LUALIB_API int (luaopen_debug) (lua_State *L); + +#define LUA_LOADLIBNAME "package" +LUALIB_API int (luaopen_package) (lua_State *L); + + +/* open all previous libraries */ +LUALIB_API void (luaL_openlibs) (lua_State *L); + + + +#ifndef lua_assert +#define lua_assert(x) ((void)0) +#endif + + +#endif diff --git a/include/lundump.h b/include/lundump.h new file mode 100644 index 0000000..c80189d --- /dev/null +++ b/include/lundump.h @@ -0,0 +1,36 @@ +/* +** $Id: lundump.h,v 1.37.1.1 2007/12/27 13:02:25 roberto Exp $ +** load precompiled Lua chunks +** See Copyright Notice in lua.h +*/ + +#ifndef lundump_h +#define lundump_h + +#include "lobject.h" +#include "lzio.h" + +/* load one chunk; from lundump.c */ +LUAI_FUNC Proto* luaU_undump (lua_State* L, ZIO* Z, Mbuffer* buff, const char* name); + +/* make header; from lundump.c */ +LUAI_FUNC void luaU_header (char* h); + +/* dump one chunk; from ldump.c */ +LUAI_FUNC int luaU_dump (lua_State* L, const Proto* f, lua_Writer w, void* data, int strip); + +#ifdef luac_c +/* print one chunk; from print.c */ +LUAI_FUNC void luaU_print (const Proto* f, int full); +#endif + +/* for header of binary files -- this is Lua 5.1 */ +#define LUAC_VERSION 0x51 + +/* for header of binary files -- this is the official format */ +#define LUAC_FORMAT 0 + +/* size of header of binary files */ +#define LUAC_HEADERSIZE 12 + +#endif diff --git a/include/lvm.h b/include/lvm.h new file mode 100644 index 0000000..bfe4f56 --- /dev/null +++ b/include/lvm.h @@ -0,0 +1,36 @@ +/* +** $Id: lvm.h,v 2.5.1.1 2007/12/27 13:02:25 roberto Exp $ +** Lua virtual machine +** See Copyright Notice in lua.h +*/ + +#ifndef lvm_h +#define lvm_h + + +#include "ldo.h" +#include "lobject.h" +#include "ltm.h" + + +#define tostring(L,o) ((ttype(o) == LUA_TSTRING) || (luaV_tostring(L, o))) + +#define tonumber(o,n) (ttype(o) == LUA_TNUMBER || \ + (((o) = luaV_tonumber(o,n)) != NULL)) + +#define equalobj(L,o1,o2) \ + (ttype(o1) == ttype(o2) && luaV_equalval(L, o1, o2)) + + +LUAI_FUNC int luaV_lessthan (lua_State *L, const TValue *l, const TValue *r); +LUAI_FUNC int luaV_equalval (lua_State *L, const TValue *t1, const TValue *t2); +LUAI_FUNC const TValue *luaV_tonumber (const TValue *obj, TValue *n); +LUAI_FUNC int luaV_tostring (lua_State *L, StkId obj); +LUAI_FUNC void luaV_gettable (lua_State *L, const TValue *t, TValue *key, + StkId val); +LUAI_FUNC void luaV_settable (lua_State *L, const TValue *t, TValue *key, + StkId val); +LUAI_FUNC void luaV_execute (lua_State *L, int nexeccalls); +LUAI_FUNC void luaV_concat (lua_State *L, int total, int last); + +#endif diff --git a/include/lzio.h b/include/lzio.h new file mode 100644 index 0000000..51d695d --- /dev/null +++ b/include/lzio.h @@ -0,0 +1,67 @@ +/* +** $Id: lzio.h,v 1.21.1.1 2007/12/27 13:02:25 roberto Exp $ +** Buffered streams +** See Copyright Notice in lua.h +*/ + + +#ifndef lzio_h +#define lzio_h + +#include "lua.h" + +#include "lmem.h" + + +#define EOZ (-1) /* end of stream */ + +typedef struct Zio ZIO; + +#define char2int(c) cast(int, cast(unsigned char, (c))) + +#define zgetc(z) (((z)->n--)>0 ? char2int(*(z)->p++) : luaZ_fill(z)) + +typedef struct Mbuffer { + char *buffer; + size_t n; + size_t buffsize; +} Mbuffer; + +#define luaZ_initbuffer(L, buff) ((buff)->buffer = NULL, (buff)->buffsize = 0) + +#define luaZ_buffer(buff) ((buff)->buffer) +#define luaZ_sizebuffer(buff) ((buff)->buffsize) +#define luaZ_bufflen(buff) ((buff)->n) + +#define luaZ_resetbuffer(buff) ((buff)->n = 0) + + +#define luaZ_resizebuffer(L, buff, size) \ + (luaM_reallocvector(L, (buff)->buffer, (buff)->buffsize, size, char), \ + (buff)->buffsize = size) + +#define luaZ_freebuffer(L, buff) luaZ_resizebuffer(L, buff, 0) + + +LUAI_FUNC char *luaZ_openspace (lua_State *L, Mbuffer *buff, size_t n); +LUAI_FUNC void luaZ_init (lua_State *L, ZIO *z, lua_Reader reader, + void *data); +LUAI_FUNC size_t luaZ_read (ZIO* z, void* b, size_t n); /* read next n bytes */ +LUAI_FUNC int luaZ_lookahead (ZIO *z); + + + +/* --------- Private Part ------------------ */ + +struct Zio { + size_t n; /* bytes still unread */ + const char *p; /* current position in buffer */ + lua_Reader reader; + void* data; /* additional data */ + lua_State *L; /* Lua state (for reader) */ +}; + + +LUAI_FUNC int luaZ_fill (ZIO *z); + +#endif diff --git a/include/magic.h b/include/magic.h new file mode 100644 index 0000000..ef56015 --- /dev/null +++ b/include/magic.h @@ -0,0 +1,67 @@ +#ifndef __MAGIC_H__ +#define __MAGIC_H__ + +/* */ +int MAGIC_Use( int charaindex, int haveitemindex, int toindex); +int MAGIC_Recovery( int charaindex, int toindex,int marray, int mp ); +int MAGIC_OtherRecovery( int charaindex, int toindex, int marray, int mp ); +int MAGIC_FieldAttChange( int charaindex, int toindex, int marray, int mp ); +int MAGIC_StatusChange( int charaindex, int toindex, int marray, int mp ); +#ifdef _MAGIC_DEEPPOISON +int MAGIC_StatusChange2( int charaindex, int toindex, int marray, int mp ); +#endif +int MAGIC_StatusRecovery( int charaindex, int toindex, int marray, int mp ); +int MAGIC_MagicDef( int charaindex, int toindex, int marray, int mp ); +int MAGIC_Ressurect( int charaindex, int toindex, int marray, int mp ); +int MAGIC_AttReverse( int charaindex, int toindex, int marray, int mp ); +int MAGIC_ResAndDef( int charaindex, int toindex, int marray, int mp ); +#ifdef _OTHER_MAGICSTAUTS +int MAGIC_MagicStatusChange( int charaindex, int toindex, int marray, int mp ); +#endif +#ifdef _ATTACK_MAGIC +int MAGIC_AttMagic( int charaindex , int toindex , int marray , int mp ); +#endif +#ifdef _ITEM_METAMO +int MAGIC_Metamo( int charaindex, int toindex,int marray, int mp ); +#endif + +#ifdef _ITEM_ATTSKILLMAGIC +int MAGIC_AttSkill( int charaindex, int toindex,int marray, int mp ); +#endif +#ifdef _MAGIC_WEAKEN// vincent : +int MAGIC_Weaken( int charaindex, int toindex, int marray, int mp ); +#endif +#ifdef _MAGIC_BARRIER// vincent :ħ +int MAGIC_Barrier( int charaindex, int toindex, int marray, int mp ); +#endif +#ifdef _MAGIC_NOCAST// vincent :Ĭ +int MAGIC_Nocast( int charaindex, int toindex, int marray, int mp ); +#endif +#ifdef _MAGIC_TOCALL +int MAGIC_ToCallDragon( int charaindex, int toindex,int marray, int mp ); +#endif + +//---------------------------------------------------------------------- +// ʧ ة įë߯ +// +int MAGIC_GetArrayNo( + int charaindex, // ƽҷ̼͵ + int haveitemindex // Ȼʧ ة +); +// +//---------------------------------------------------------------------- +//------------------------------------------------------------------- +// +// ë +// +int MAGIC_DirectUse( + int charaindex, // ƽҷ¼̼͵ + int marray, // ̼͵ + int toindex, // + int itemnum +); +// +//------------------------------------------------------------------- + +#endif + diff --git a/include/magic_base.h b/include/magic_base.h new file mode 100644 index 0000000..a8d4f36 --- /dev/null +++ b/include/magic_base.h @@ -0,0 +1,142 @@ +#ifndef __MAGIC_BASE_H__ +#define __MAGIC_BASE_H__ + +#include "util.h" + +typedef enum +{ + MAGIC_FIELD_ALL, /* ͻƥ */ + MAGIC_FIELD_BATTLE, /* */ + MAGIC_FIELD_MAP, /* ɧѨ */ + +}MAGIC_FIELDTYPE; + +typedef enum +{ + MAGIC_TARGET_MYSELF, /* м */ + MAGIC_TARGET_OTHER, /* ְ ֳ) */ + MAGIC_TARGET_ALLMYSIDE, /* */ + MAGIC_TARGET_ALLOTHERSIDE, /* 촡 */ + MAGIC_TARGET_ALL, /* 廯 */ + MAGIC_TARGET_NONE, /* ּ ئУ ֧׻ */ + MAGIC_TARGET_OTHERWITHOUTMYSELF,/* ְ ֳئ) */ + MAGIC_TARGET_WITHOUTMYSELFANDPET, /* ʸ½ */ + MAGIC_TARGET_WHOLEOTHERSIDE,/* */ + +#ifdef _ATTACK_MAGIC + + MAGIC_TARGET_SINGLE, // Եзijһ + MAGIC_TARGET_ONE_ROW, // Եзijһ + MAGIC_TARGET_ALL_ROWS, // Եз + +#endif +}MAGIC_TARGETTYPE; + +typedef enum +{ + MAGIC_ID, /* į */ + MAGIC_FIELD, /* */ + MAGIC_TARGET, /* */ + MAGIC_TARGET_DEADFLG, /* Ϸַָޱֳ¾ */ +#ifdef _ATTACK_MAGIC + MAGIC_IDX , +#endif + MAGIC_DATAINTNUM, +}MAGIC_DATAINT; + +typedef enum +{ + MAGIC_NAME, /* */ + MAGIC_COMMENT, /* 춪*/ + MAGIC_FUNCNAME, /* */ + MAGIC_OPTION, /* */ + MAGIC_DATACHARNUM, +}MAGIC_DATACHAR; + +typedef struct tagMagic +{ + int data[MAGIC_DATAINTNUM]; + STRING64 string[MAGIC_DATACHARNUM]; + +}Magic; + +#ifdef _ATTACK_MAGIC + +typedef struct tagAttMagic +{ + unsigned int uiSpriteNum;// Spr_x.binı + unsigned int uiAttackType;// ķʽˣ( ) , ( ) , ( ͬʱ ) , ȫ( ) , ȫ( ͬʱ ) + unsigned int uiSliceTime;// ʱʱ + unsigned int uiShowType; // ʾλ÷ʽ롢ָ + int siSx; // ʾλ - X + int siSy; // ʾλ - Y + unsigned int uiShowBehindChar; // ʾǰ· + unsigned int uiShakeScreen; // Ƿ𶯻 + unsigned int uiShakeFrom; // 𶯻ʼʱ( ) + unsigned int uiShakeTo; // 𶯻Ľʱ( _ + unsigned int uiPrevMagicNum; // ǰ( 0XFFFFFFFFFF ʾǰ ) + int siPrevMagicSx; // ǰʾλ - X + int siPrevMagicSy; // ǰʾλ - Y + int siPrevMagicOnChar; // ǰʾǰ· + unsigned int uiPostMagicNum; // ( 0XFFFFFFFF ʾ ) + int siPostMagicSx; // ʾλ - X + int siPostMagicSy; // ʾλ - Y + int siPostMagicOnChar; // ʾǰ· + int siField[3][5]; // +}AttMagic; + +#endif + +#ifdef _MAGIC_TOCALL + +typedef struct tagToCallMagic +{ + unsigned int uiSpriteNum;// Spr_x.binı + unsigned int uiAttackType;// ķʽˣ( ) , ( ) , ( ͬʱ ) , ȫ( ) , ȫ( ͬʱ ) + unsigned int uiSliceTime;// ʱʱ + unsigned int uiShowType; // ʾλ÷ʽ롢ָ + int siSx; // ʾλ - X + int siSy; // ʾλ - Y + unsigned int uiShowBehindChar; // ʾǰ· + unsigned int uiShakeScreen; // Ƿ𶯻 + unsigned int uiShakeFrom; // 𶯻ʼʱ( ) + unsigned int uiShakeTo; // 𶯻Ľʱ( _ + unsigned int uiPrevMagicNum; // ǰ( 0XFFFFFFFFFF ʾǰ ) + int siPrevMagicSx; // ǰʾλ - X + int siPrevMagicSy; // ǰʾλ - Y + int siPrevMagicOnChar; // ǰʾǰ· + unsigned int uiPostMagicNum; // ( 0XFFFFFFFF ʾ ) + int siPostMagicSx; // ʾλ - X + int siPostMagicSy; // ʾλ - Y + int siPostMagicOnChar; // ʾǰ· + int isPostDisappear; // һ㹥ʱǷʧ + int ToCallMagicNo; // ٻı +}ToCallMagic; + +#endif + +typedef int (*MAGIC_CALLFUNC)( int, int, int, int ); + +INLINE BOOL MAGIC_CHECKINDEX( int index ); +INLINE int MAGIC_getInt( int index, MAGIC_DATAINT element); +INLINE int MAGIC_setInt( int index, MAGIC_DATAINT element, int data); +INLINE char* MAGIC_getChar( int index, MAGIC_DATACHAR element); +INLINE BOOL MAGIC_setChar( int index ,MAGIC_DATACHAR element, char* new ); +int MAGIC_getMagicNum( void); +BOOL MAGIC_initMagic( char *filename); +BOOL MAGIC_reinitMagic( void ); + +#ifdef _ATTACK_MAGIC + +BOOL ATTMAGIC_initMagic( char *filename ); +BOOL ATTMAGIC_reinitMagic( void ); + +#endif + +int MAGIC_getMagicArray( int magicid); +MAGIC_CALLFUNC MAGIC_getMagicFuncPointer(char* name); +// Nuke +1 08/23 : For checking the validity of magic target +int MAGIC_isTargetValid( int magicid, int toindex); + +#endif + diff --git a/include/magic_field.h b/include/magic_field.h new file mode 100644 index 0000000..414195f --- /dev/null +++ b/include/magic_field.h @@ -0,0 +1,10 @@ +#ifndef __MAGIC_FIELD_H__ +#define __MAGIC_FIELD_H__ + +/* ūƥ */ + +int MAGIC_Recovery_Field( int charaindex, int magicindex); +int MAGIC_OtherRecovery_Field( int charaindex, int toindex, int magicindex); + +#endif + diff --git a/include/map_deal.h b/include/map_deal.h new file mode 100644 index 0000000..b9f3cb7 --- /dev/null +++ b/include/map_deal.h @@ -0,0 +1,15 @@ +#ifndef __MAP_DEAL_H__ +#define __MAP_DEAL_H__ +BOOL MAP_walkAbleFromPoint( int ff, int fx, int fy, BOOL isfly ); +BOOL MAP_walkAble( int index,int ff, int fx, int fy); +void MAP_preovered( int index ); +void MAP_postovered( int index ); +BOOL MAP_sendArroundCharNeedFD( int fd,int charaindex ); +BOOL MAP_sendArroundChar(int charaindex); + +#ifdef _CAX_LNS_NLGSUOXU +int QuBiao (int MapId); +#endif + +#endif + diff --git a/include/map_util.h b/include/map_util.h new file mode 100644 index 0000000..77e4b7a --- /dev/null +++ b/include/map_util.h @@ -0,0 +1,7 @@ +#ifndef __MAP_UTIL_H__ +#define __MAP_UTIL_H__ + +BOOL MAP_getMapDataFromCharIndex( int index , int* map ); +BOOL MAP_getMapDataFromFXY( int f , int x , int y, int* map ); + +#endif diff --git a/include/map_warppoint.h b/include/map_warppoint.h new file mode 100644 index 0000000..8337f75 --- /dev/null +++ b/include/map_warppoint.h @@ -0,0 +1,26 @@ +#ifndef __MAPWARPPOINT_H__ +#define __MAPWARPPOINT_H__ + +#include "common.h" +#include "util.h" + +int MAPPOINT_InitMapWarpPoint( void); +void MAPPOINT_resetMapWarpPoint( int flg); +int MAPPOINT_loadMapWarpPoint( void); + +BOOL MAPPOINT_CHECKINDEX( int ps); +int MAPPOINT_getMPointEVType( int ps); + +int MAPPOINT_creatMapWarpObj( int pointindex, char *buf, int objtype); +int MAPPOINT_setMapWarpGoal( int ps, char *buf); +int MAPPOINT_setMapWarpFrom( int ps, char *buf); +int MAPPOINT_getMapWarpGoal( int ps, int ofl, int ox, int oy, int *fl, int *x, int *y); + +void MAPPOINT_MapWarpHandle( int charaindex, int ps, int ofl, int ox, int oy ); + +#ifdef _CAX_LNS_MAPSUOXU +int DelMapPoint( int ps); +int SetMapPoint( char* buf); +#endif + +#endif diff --git a/include/mclient.h b/include/mclient.h new file mode 100644 index 0000000..553de42 --- /dev/null +++ b/include/mclient.h @@ -0,0 +1,51 @@ +#ifndef __MCLIENT_H__ +#define __MCLIENT_H__ + +#define MSPERSIONALKEY "20020729" + + +#define MPROTO_QUE_SEND 1001 +#define MPROTO_QUE_RECV 1002 + +#define MPROTO_NOTALK_RECV 1004 +#define MPROTO_GMTALK_SEND 1005 +#define MPROTO_GMTALK_RECV 1006 +#define MPROTO_HELLO_SEND 1007 +#define MPROTO_HELLO_RECV 1008 +#define MPROTO_WAEIKICK_SEND 1009 +#define MPROTO_WAEIKICK_RECV 1010 + +#define MPROTO_JAIL_RECV 1012 +#define MPROTO_MESSAGE_RECV 1014 + +#define MPROTO_TYPE_SEND 1016 + +#ifdef _GSERVER_RUNTIME //GSERVERִжʱMSERVER +#define MPROTO_RECALL_GSERVER_RUNTIME 1026 +#endif + +int mproto_ClientDispatchMessage(int fd,char* data); + +void mproto_Que_Recv(int fd,char* uid,int userfdid,char* ans); +void mproto_Que_Send( int fd, int uid, int index, char* question); + +void mproto_NoTalk_Recv(int fd,char* uid,int userfdid,int nTime); +void mproto_GMTalk_Recv(int fd,char* uid,int ntime,char* data); +void mproto_WaeiKick_Recv(int fd,char* uid,int userfdid); +void mproto_Jail_Recv(int fd,char* uid,int userfdid); + +void mproto_Message_Recv(int fd,char* uid,int userfdid,char* ans); + +int connectmServer(char* hostname,unsigned short port); +void mproto_Type_Send( int fd, int playernum, int itemuse); + +#ifdef _RECAL_ASK_PLAYER // WON Ҫ +void mproto_RECALL_ASK_PLAYER_Recv(int fd, char *uid, int userfdid, int GmCliId, char *id, int char_num, int date, int backup_flag); +void mproto_RECALL_BACKUP_PLAYER_Recv(int fd, char *uid, int userfdid, int GmCliId, char *id, int char_num, int date, char *char_data, int backup_flag); +#endif + +#ifdef _GSERVER_RUNTIME +void gserver_runtime(); +#endif + +#endif diff --git a/include/msignal.h b/include/msignal.h new file mode 100644 index 0000000..452994b --- /dev/null +++ b/include/msignal.h @@ -0,0 +1,8 @@ +#ifndef __SIGNAL_H__ +#define __SIGNAL_H__ + +void signalset( void ); +void shutdownProgram( void ); +void sigshutdown( int number ); + +#endif diff --git a/include/mylua/ablua.h b/include/mylua/ablua.h new file mode 100644 index 0000000..d5e85a6 --- /dev/null +++ b/include/mylua/ablua.h @@ -0,0 +1,8 @@ +#ifndef __ABLUA_H__ +#define __ABLUA_H__ + +void LoadAllbluesLUA(char *path); +void ReLoadAllbluesLUA(); +void NewLoadAllbluesLUA(char *filename); + +#endif diff --git a/include/mylua/base.h b/include/mylua/base.h new file mode 100644 index 0000000..f85e74b --- /dev/null +++ b/include/mylua/base.h @@ -0,0 +1,46 @@ +#ifndef __CHARBASE_H__ +#define __CHARBASE_H__ +#include "char_base.h" +#include "lua.h" + +#include "lauxlib.h" +#include "lualib.h" + +typedef struct tagCharBase +{ + char field[128]; + int element; +}CharBase; + +const int getCharBaseValue(lua_State *L, int narg, CharBase *charbase, int num); + +LUALIB_API int luaopen_Char (lua_State *L); +LUALIB_API int luaopen_NPC (lua_State *L); +LUALIB_API int luaopen_Lssproto (lua_State *L); +LUALIB_API int luaopen_Battle (lua_State *L); +LUALIB_API int luaopen_Object (lua_State *L); + +#ifdef _ALLBLUES_LUA_1_1 +LUALIB_API int luaopen_Map (lua_State *L); +LUALIB_API int luaopen_Other (lua_State *L); +LUALIB_API int luaopen_Config (lua_State *L); +#endif +#ifdef _ALLBLUES_LUA_1_2 +LUALIB_API int luaopen_Item (lua_State *L); +LUALIB_API int luaopen_Magic (lua_State *L); +#endif +#ifdef _ALLBLUES_LUA_1_2 +LUALIB_API int luaopen_Offline (lua_State *L); +#endif +#ifdef _ALLBLUES_LUA_1_4 +LUALIB_API int luaopen_Enemytemp (lua_State *L); +LUALIB_API int luaopen_Sasql (lua_State *L); +#endif + +LUALIB_API int luaopen_Net (lua_State *L); + +LUALIB_API int luaopen_Saacproto (lua_State *L); + +LUALIB_API int luaopen_Family (lua_State *L); +LUALIB_API int luaopen_PetSkill (lua_State *L); +#endif diff --git a/include/mylua/function.h b/include/mylua/function.h new file mode 100644 index 0000000..964101e --- /dev/null +++ b/include/mylua/function.h @@ -0,0 +1,63 @@ + +#ifndef __MYLUA_FUNCTION_H__ +#define __MYLUA_FUNCTION_H__ + +BOOL RunCharTalkedEvent(int meindex, int toindex, char *messageeraseescape, int color, int channel); +BOOL RunCharLoopEvent(int meindex); +BOOL RunCharOverlapEvent( int meindex, int toindex); +BOOL RunCharBattleOverEvent( int meindex, int toindex, int iswin); +BOOL RunCharWindowTalked( int meindex, int talkerindex, int seqno, int select, char *data); + +#ifdef _ALLBLUES_LUA_1_2 +BOOL RunItemUseEvent( int itemindex, int charaindex, int toindex, int haveitemindex ); +BOOL RunItemDieReLifeEvent( int toindex, int itemindex, int haveitemindex ); +BOOL RunItemDetachEvent( int charaindex, int itemindex ); +BOOL RunItemAttachEvent( int charaindex, int itemindex ); +BOOL RunItemPickupEvent( int charaindex, int itemindex ); +BOOL RunItemPostOverEvent( int itemindex, int charaindex ); +BOOL RunItemPreOverEvent( int itemindex, int charaindex ); +BOOL RunItemDropEvent( int charaindex, int itemindex ); +BOOL RunUseChatMagic( int charaindex, char *data, lua_State *lua); +#endif +#ifdef _PETSKILL_SHOP_LUA +BOOL FreePetSkillShop( int talkerindex, int petindex, int oldSkillID, int newSkillID); +#endif +//#ifdef _PETSKILL_SHOP_LUA +//BOOL OffLineCommand( int battleindex, int charindex, int side); +//#endif +#ifdef _ALLBLUES_LUA_1_4 +BOOL BattleFinish( int battleindex, int charaindex); +BOOL BattleEscape( int battleindex, int charaindex); +BOOL RunCharLogOutEvent( int charaindex); +#endif +#ifdef _ALLBLUES_LUA_1_5 +BOOL FreePartyJoin( int charaindex, int toindex ); +BOOL FreeVsPlayer( int charaindex, int toindex ); +BOOL FreeCharLogin( int charaindex ); +BOOL FreeCharCreate( int charaindex ); +BOOL NetLoopFunction( void ); +#endif +#ifdef _ALLBLUES_LUA_1_6 +BOOL FamilyRideFunction( int meindex, int petindex, int petid ); +BOOL CharTalkFunction( int charaindex, char *message, int color ); +#endif +#ifdef _ALLBLUES_LUA_1_7 +BOOL CharVsEnemyFunction( int charaindex ); +#endif +#ifdef _ALLBLUES_LUA_1_8 +BOOL CaptureOkFunction( int attackindex, int defindex ); +BOOL CaptureCheckFunction( int attackindex, int defindex ); +#endif +#ifdef _ALLBLUES_LUA_1_9 +BOOL SetBattleEnmeyFunction(int meindex, int enemyindex, int id ); +BOOL BattleFinishFunction( int charaindex, int battletime, int battleturn, int battletype ); +#endif +#ifdef _ALLBLUES_LUA_2_0 +BOOL fameButton( int index); //ťӿ +BOOL FreeSamenu(int* function,int id, int charaindex ); //ESC +BOOL FreeLoginCheck(int fd);//ҵ½ص +BOOL TeacherButton(int* function,int charaindex );//ʦťص +BOOL FreeCharExpSave(int charaindex, int exp ); +BOOL FreeModeExp(int charaindex, int exp );//ص +#endif +#endif diff --git a/include/mylua/mylua.h b/include/mylua/mylua.h new file mode 100644 index 0000000..968c2d1 --- /dev/null +++ b/include/mylua/mylua.h @@ -0,0 +1,53 @@ +#define __MYLUA__H__ +#ifdef __MYLUA__H__ + +#include "lua.h" + +#include "lauxlib.h" +#include "lualib.h" +int myluaload (char *filename); +int remyluaload (char *filename); +int closemyluaload(); +void CryptoAllbluesLUA(char *path, int flg, int id); +int dofile (lua_State *L, const char *name); +int docall (lua_State *L, int narg, int clear); +int getArrayInt(lua_State *L, int idx); +LUALIB_API void luaAB_openlibs (lua_State *L); + +typedef struct tagMYLua +{ + lua_State *lua; + char *luapath; + struct tagMYLua *next; +}MY_Lua; + +#endif + + +//һintLUA +#define LRetInt(L, i) \ +{ \ + lua_pushinteger(L, i); \ + LRet(1); \ +} + +#define LRet(r) \ +{ \ + NPC_Lua_SetErrorStr(NULL); \ + return r; \ +} + +#define CheckEx2(L, t, n) \ +{ \ + if(lua_gettop(L) < (t) || lua_gettop(L) > n) \ + { \ + luaL_argerror(L, 1, ""); \ + } \ +} + +//һBOOLLUA +#define LRetBool(L, b) \ +{ \ + lua_pushboolean(L, b); \ + LRet(1); \ +} diff --git a/include/net.h b/include/net.h new file mode 100644 index 0000000..07f2f06 --- /dev/null +++ b/include/net.h @@ -0,0 +1,310 @@ +#ifndef __NET_H__ +#define __NET_H__ + +#include "common.h" + +#include +#include +// Nuke +1 0902: For queuing control +#include + +#include + +#include "link.h" + + +#undef EXTERN +#ifdef __NET_C__ +#define EXTERN +#else +#define EXTERN extern +#endif + + + +/* + * ̼ƻئУ ̼ƻ£ ̼ ƽҷԻ + * ʧ ( Ƥ ) , ʧ ( ʧ ) + * N NOT W WHILE , UL UNLOCK + */ +typedef enum +{ + NOTLOGIN, /* ̼ƻئ */ + LOGIN, /* ̼ */ + WHILELOGIN, /* ̼ƻ */ + WHILECREATE, /* Ȼ */ + WHILELOGOUTSAVE, /* ʧƤ */ + WHILECANNOTLOGIN, /* ̼ƥئݼʧ */ + WHILECHARDELETE, /* ƽҷ´ */ + WHILEDOWNLOADCHARLIST, /* ƽҷĸ */ + WHILECHANGEPASSWD, /* ɵ */ + + WHILELOSTCHARSAVE, /* ƥƽҷ±Ƥ */ + WHILELOSTCHARDELETE,/* ƥƽҷ */ + + WHILECLOSEALLSOCKETSSAVE, /* closeallsockets ƥƽҷ±Ƥ */ + WHILESAVEWAIT, /* ʧƤ󡼰 */ +}LoginType; + +/* ƻئУʧӡͷʧʧة */ +typedef enum +{ + NOTDETECTED,AC,CLI,ADM +}ConnectType; + + +/* ӡﻥƻӮ */ +#define CDKEYLEN 16 +#define PASSWDLEN 16 +/* ľ ʷص(ئ Char STRING64 ئԻ³*/ +#define CHARNAMELEN 32 + +#define CLITIMEOUT_SEC 120 /* ͷʧreadئգ + ƥةʧʧ */ + +#define NET_STRING_SUCCESSFULL "successful" +#define NET_STRING_FAILED "failed" + +// ׹ ݷ +#define RBSIZE (1024*64*8) +#define WBSIZE (1024*64*8) +// ʧӡ + +//#define AC_RBSIZE (65536*48) +//#define AC_RBSIZE (65536*32) +#define AC_RBSIZE (1024*64*8) +//ttom modify because the second version had this +//#define AC_WBSIZE (65536*16) +extern int AC_WBSIZE; + +EXTERN int bindedfd; /*лʧ̼ĩ*/ +EXTERN int acfd; /*ʧӡĩ*/ +EXTERN int ConnectLen; /*ƱӮ*/ +#define CONNECT_WINDOWBUFSIZE 7 + +/* */ +BOOL initConnect( int size ); +void endConnect( void ); +#define CONNECT_endOne( sockfd, lin) \ + _CONNECT_endOne( __FILE__, __LINE__, sockfd, lin) +BOOL _CONNECT_endOne( char *file, int fromline, int sockfd , int lin); +#define CONNECT_attendOne( sockfd, lin) \ + _CONNECT_attendOne( __FILE__, __LINE__, sockfd, lin) +BOOL _CONNECT_attendOne( char *file, int fromline, int sockfd , int lin); +BOOL netloop( void ); +BOOL netloop_faster( void ); +int lsrpcClientWriteFunc( int fd , char* buf , int size ); +char* GetOneLine( int fd ); +BOOL initConnectOne( int sockfd, struct sockaddr_in* sin ,int len ); + +#ifdef _CAX_LNS_NLSUOXU +void SetTimerLua( void ); +BOOL DelTimer_net(int ID); +#endif + +/* CA , CD */ +void CAcheck( void ); +void CAflush( int charaindex ); +void CAsend( int fd ); +void CDcheck( void ); +void CDflush( int charaindex ); +void CDsend( int fd ); +BOOL CONNECT_appendCAbuf( int fd , char* data, int size ); +BOOL CONNECT_appendCDbuf( int fd , char* data, int size ); + +/* Serverstate */ +void SERVSTATE_decrementCloseallsocketnum(void); +int SERVSTATE_getCloseallsocketnum( void ); +int SERVSTATE_SetAcceptMore( int nvalue ); +int SERVSTATE_getShutdown(void); +void SERVSTATE_setShutdown(int a); +int SERVSTATE_getLimittime(void); +int SERVSTATE_getDsptime(void); +void SERVSTATE_setDsptime(int a); +void SERVSTATE_setLimittime(int a); + + +/* þ */ +void outputNetProcLog( int fd, int mode); +void chardatasavecheck( void ); +void closeAllConnectionandSaveData( void ); +BOOL SetShutdown( BOOL nvalue ); +int GetShutdown( void ); + +/* ƻ */ +int getfdFromCdkey( char* cd ); +int getfdFromCharaIndex( int charaindex ); +int getcdkeyFromCharaIndex( int charaindex , char *out, int outlen ); +int getCharindexFromFdid( int fdid ); +int getFdidFromCharaIndex( int charind ); +int getfdFromFdid( int fdid ); +int getfdFromCdkeyWithLogin( char* cd ); + + +/* */ +INLINE int CONNECT_checkfd( int fd ); +BOOL CONNECT_isCLI( int fd ); +BOOL CONNECT_isAC( int fd ); +BOOL CONNECT_isUnderLogin( int fd ); +BOOL CONNECT_isWhileLogout( int fd ); +BOOL CONNECT_isWhileLogin( int fd ); +BOOL CONNECT_isNOTLOGIN( int fd ); +BOOL CONNECT_isLOGIN( int fd ); + +int CONNECT_getUse( int fd ); +int CONNECT_getUse_debug( int fd, int i ); + +void CONNECT_setCharaindex( int fd, int a ); +int CONNECT_getCharaindex( int fd ); +void CONNECT_getCdkey( int fd , char *out, int outlen ); +void CONNECT_setCdkey( int fd , char *in); +void CONNECT_getPcid( int fd , char *out, int outlen ); +void CONNECT_setPcid( int sockfd, char *pcid ); +#ifdef _CAX_NEWMAC_LOGIN +void CONNECT_getMAC( int fd , char *out, int outlen ); +void CONNECT_setMAC( int sockfd, char *mac ); +#endif +void CONNECT_getOldPcid( int fd , char *out, int outlen ); +void CONNECT_setOldPcid( int sockfd, char *pcid ); +void CONNECT_getDefaultKey( int fd , char *out, int outlen ); +void CONNECT_setDefaultKey( int sockfd, char *defaultkey ); +void CONNECT_getPasswd( int fd , char *out, int outlen ); +void CONNECT_setPasswd( int fd, char *in ); +void CONNECT_getCharname( int fd , char *out, int outlen ); +void CONNECT_setCharname( int fd, char *in ); +int CONNECT_getFdid( int fd ); +int CONNECT_getCtype( int fd ); +void CONNECT_setCtype( int fd , int a ); +void CONNECT_setDuelcharaindex( int fd, int i , int a ); +int CONNECT_getDuelcharaindex( int fd, int i ); +void CONNECT_setBattlecharaindex( int fd, int i , int a ); +int CONNECT_getBattlecharaindex( int fd, int i ); +void CONNECT_setJoinpartycharaindex( int fd, int i , int a); +int CONNECT_getJoinpartycharaindex( int fd, int i ); +void CONNECT_setTradecardcharaindex( int fd, int i , int a ); +int CONNECT_getTradecardcharaindex( int fd, int i ); +/* MTѨͷ */ +#define CONNECT_endOne_debug(a) CONNECT_endOne( (a) , __LINE__ ) +#define CONNECT_attendOne_debug(a) CONNECT_attendOne( (a) , __LINE__ ) +/* (ľɱ) */ +void CONNECT_setCDKEY( int sockfd, char *cd ); +void CONNECT_getCDKEY( int sockfd , char *out, int outlen ); +void CONNECT_setState( int fd, int s ); +int CONNECT_getState( int fd ); +void CONNECT_checkStatecount( int a ); +int CONNECT_checkStateSomeOne( int a, int maxcount); + +BOOL CONNECT_acfdInitRB( int fd ); +BOOL CONNECT_acfdInitWB( int fd ); + +// Nuke +3 +int checkWalkTime(int fd); +int setBtime(int fd); + +#ifdef _BATTLE_TIMESPEED +//void setDefBTime( int fd, unsigned int times); +//unsigned int getDefBTime( int fd); +BOOL CheckDefBTime( int charaindex, int fd, unsigned int lowTime, unsigned int battletime, unsigned int addTime); +#endif + +#ifdef _TYPE_TOXICATION +void setToxication( int fd, int flg); +int getToxication( int fd); +#endif +int checkBEOTime(int fd); +void sigusr1(int i); +void sigusr2(int i); // Arminius 6.26 signal +//ttom start +void CONNECT_set_watchmode(int fd, BOOL B_Watch); +BOOL CONNECT_get_watchmode(int fd); +void CONNECT_set_shutup(int fd,BOOL b_shut);//the avoid the user wash the screen +BOOL CONNECT_get_shutup(int fd); +unsigned long CONNECT_get_userip(int fd); +void CONNECT_set_pass(int fd,BOOL b_ps); +BOOL CONNECT_get_pass(int fd); +void CONNECT_set_state_trans(int fd,int a); +int CONNECT_get_state_trans(int fd); +//ttom end + +// CoolFish: +9 2001/4/18 +void CONNECT_setCloseRequest( int fd, int count); +void CONNECT_set_first_warp(int fd, BOOL b_ps); +BOOL CONNECT_get_first_warp(int fd); +int isDie(int fd); +void setDie(int fd); + +// Arminius 6/22 encounter +int CONNECT_get_CEP(int fd); +void CONNECT_set_CEP(int fd, int cep); + +// Arminius 7.12 login announce +int CONNECT_get_announced(int fd); +void CONNECT_set_announced(int fd, int a); + +// shan trade(DoubleCheck) begin +int CONNECT_get_confirm(int fd); +void CONNECT_set_confirm(int fd, BOOL b); +// end + +void CONNECT_setTradecharaindex( int fd, int i , int a); + +void CONNECT_setLastrecvtime( int fd, struct timeval *a ); +void CONNECT_getLastrecvtime( int fd, struct timeval *a ); +void CONNECT_setLastrecvtime_D( int fd, struct timeval *a ); +void CONNECT_getLastrecvtime_D( int fd, struct timeval *a ); +void CONNECT_SetBattleRecvTime( int fd, struct timeval *a ); +void CONNECT_GetBattleRecvTime( int fd, struct timeval *a ); +void CONNECT_setTradeTmp(int fd, char* a); +void CONNECT_getTradeTmp(int fd, char *trademsg, int trademsglen); +int checkNu(int fd); + +#ifdef _NO_WARP +// shan hjj add Begin +int CONNECT_get_seqno(int fd); +void CONNECT_set_seqno(int fd,int a); +int CONNECT_get_selectbutton(int fd); +void CONNECT_set_selectbutton(int fd, int a); +// shan End +#endif + +// Arminius 7.2 Ra's amulet +void setNoenemy(int fd); +void clearNoenemy(int fd); +int getNoenemy(int fd); +void setEqNoenemy(int fd, int level); +void clearEqNoenemy(int fd); +int getEqNoenemy(int fd); + +#ifdef _Item_MoonAct +void setEqRandenemy(int fd, int level); +void clearEqRandenemy(int fd); +int getEqRandenemy(int fd); +#endif + +#ifdef _CHIKULA_STONE +void setChiStone(int fd, int nums); +int getChiStone(int fd); +#endif + +// Arminius 7.31 cursed stone +void setStayEncount(int fd); +void clearStayEncount(int fd); +int getStayEncount(int fd); +void CONNECT_setBDTime( int fd, int nums); +int CONNECT_getBDTime( int fd); + +// Arminius debug +void CONNECT_setUse( int fd , int a); +void CONNECT_setStarttime( int fd , int a); +#ifdef _ITEM_PILEFORTRADE +void CONNECT_setTradeList( int fd, int num); +int CONNECT_getTradeList(int fd); +#endif + +#define QUEUE_LENGTH1 6 +#define QUEUE_LENGTH2 7 + +BOOL MSBUF_CHECKbuflen( int size, float defp); + +void SetTcpBuf( int sockfd); +#endif diff --git a/include/npc_Dengon.h b/include/npc_Dengon.h new file mode 100644 index 0000000..b8835a1 --- /dev/null +++ b/include/npc_Dengon.h @@ -0,0 +1,10 @@ +#ifndef __NPC_DENGON_H__ +#define __NPC_DENGON_H__ +BOOL NPC_DengonInit( int meindex ); +//void NPC_DengonSpecialTalked( int index, int talker, char *msg, int color ); +void NPC_DengonLooked( int meindex, int lookedindex ); +void NPC_DengonWindowTalked( int index, int talker, + int seqno, int select, char *data); + +#endif + diff --git a/include/npc_action.h b/include/npc_action.h new file mode 100644 index 0000000..f19d6df --- /dev/null +++ b/include/npc_action.h @@ -0,0 +1,12 @@ +#ifndef __NPC_ACTION_H__ +#define __NPC_ACTION_H__ + +void NPC_ActionTalked( int meindex , int talkerindex , char *msg , + int color ); + +BOOL NPC_ActionInit( int meindex ); +void NPC_ActionWatch( int meobjindex, int objindex, CHAR_ACTION act, + int x,int y,int dir, int* opt,int optlen ); + +#endif + diff --git a/include/npc_airplane.h b/include/npc_airplane.h new file mode 100644 index 0000000..6e02872 --- /dev/null +++ b/include/npc_airplane.h @@ -0,0 +1,12 @@ +#ifndef __NPC_AIRPLANE_H__ +#define __NPC_AIRPLANE_H__ + +BOOL NPC_AirInit( int meindex ); +void NPC_AirLoop( int meindex ); +void NPC_AirTalked( int meindex , int talkerindex , char *szMes , + int color ); +BOOL NPC_AirCheckAllowItem( int meindex, int charaindex, BOOL pickupmode); +BOOL NPC_AirCheckJoinParty( int meindex, int charaindex, BOOL msgflg); + +#endif +/*__NPC_AIRPLANE_H__*/ diff --git a/include/npc_alldoman.h b/include/npc_alldoman.h new file mode 100644 index 0000000..bc879a1 --- /dev/null +++ b/include/npc_alldoman.h @@ -0,0 +1,10 @@ +#ifndef __NPC_ALLDOMAN_H__ +#define __NPC_ALLDOMAN_H__ + +BOOL NPC_AlldomanInit( int meindex ); +void NPC_AlldomanTalked( int meindex , int talker , char *msg ,int color ); +void NPC_AlldomanWindowTalked(int meindex, int talkerindex, int seqno, int select,char *data); +void NPC_AlldomanWriteStele( char *token ) ; +void NPC_Alldoman_S_WriteStele( char *ocdkey , char *oname , char *ncdkey , + char *nname , char *title , int level , int trns , int floor ) ; +#endif diff --git a/include/npc_auctioneer.h b/include/npc_auctioneer.h new file mode 100644 index 0000000..dc9f331 --- /dev/null +++ b/include/npc_auctioneer.h @@ -0,0 +1,377 @@ +0031:npc_autopk.h:0302:1:14=48041e4b:16=47d21313:#ifndef _AUTO_PK_H +#define _AUTO_PK_H + +void NPC_AutoPkTalked( int meindex, int talkerindex, char *msg, int color ); +BOOL NPC_AutoPkInit( int meindex ); +void NPC_AutoPkWindowTalked( int meindex, int talkerindex, int seqno, int select, char *data); +void NPC_AutoPkLoop( void ); +void AutoPk_PKSystemTalk( char *token1, char *token2 ); +void AutoPk_PKSystemInfo(); +void AutoPk_PKTimeSet( int pktime ); +int AutoPk_PKTimeGet( void ); +void AutoPk_AwardSet( int petid, char *pet, int itemid, char *item ); +void AutoPk_ChampionShipSet( char *cdkey, char *name, int winnum, int win ); +void NPC_AUTOPKHealerTalked( int meindex ); +void AutoPk_SetHistoryStr( void ); +void AutoPk_SetAwardStr( char *token ); +BOOL AutoPk_GetAwardStr( void ); +void AutoPk_GetChampionShip( void ); +#endif +0032:npc_bankman.h:0163:1:14=48041e4b:16=47d21313:#ifndef __NPC_BANKMAN_H__ +#define __NPC_BANKMAN_H__ + +void NPC_BankmanTalked( int meindex , int talkerindex , char *msg , + int color ); + +BOOL NPC_BankmanInit( int meindex ); +void NPC_BankmanLooked( int meindex, int lookedindex ); +void NPC_BankmanWindowTalked( int meindex, int talkerindex, int seqno, int select, char *data); + +#endif + +0037:npc_bigsmallmaster.h:00:1:14=48041e4b:16=47d21313:0034:npc_bigsmallpet.h:00:1:14=48041e4b:16=47d21313:0034:npc_blackmarket.h:00:1:14=48041e4b:16=47d21313:0032:npc_bodylan.h:0166:1:14=48041e4b:16=47d21313:#ifndef __NPC_BODYLAN_H__ +#define __NPC_BODYLAN_H__ + +void NPC_BodyLanTalked( int meindex , int talkerindex , char *msg , + int color ); +BOOL NPC_BodyLanInit( int meindex ); +void NPC_BodyLanWatch( int meindex , int lookedindex); +void NPC_BodyLanWindowTalked( + int meindex, + int talkerindex, + int seqno, + int select, + char *data +); + +#endif +002E:npc_bus.h:016E:1:14=48041e4b:16=47d21313:#ifndef __NPC_BUS_H__ +#define __NPC_BUS_H__ + +BOOL NPC_BusInit( int meindex ); +void NPC_BusLoop( int meindex ); +void NPC_BusTalked( int meindex , int talkerindex , char *szMes , + int color ); +BOOL NPC_BusCheckAllowItem( int meindex, int charaindex, BOOL pickupmode); +BOOL NPC_BusCheckJoinParty( int meindex, int charaindex, BOOL msgflg); + +#endif + +0030:npc_charm.h:0156:1:14=48041e4b:16=47d21313:#ifndef __NPC_CHARM_H__ +#define __NPC_CHARM_H__ + +void NPC_CharmTalked( int meindex , int talkerindex , char *msg , + int color ); +BOOL NPC_CharmInit( int meindex ); +void NPC_CharmWindowTalked( int meindex, int talkerindex, int seqno, int select, char *data); +void NPC_CharmLooked( int meindex , int lookedindex); + +#endif + +0033:npc_checkman.h:0167:1:14=48041e4b:16=47d21313:#ifndef __NPC_CHECKMAN_H__ +#define __NPC_CHECKMAN_H__ + +void NPC_CheckManTalked( int meindex , int talkerindex , char *msg , + int color ); +BOOL NPC_CheckManInit( int meindex ); +void NPC_CheckManWindowTalked( int meindex, int talkerindex, int seqno, int select, char *data); +void NPC_CheckManLooked( int meindex , int lookedindex); + +#endif + +0031:npc_Dengon.h:0146:1:14=48041e4b:16=47d21313:#ifndef __NPC_DENGON_H__ +#define __NPC_DENGON_H__ +BOOL NPC_DengonInit( int meindex ); +//void NPC_DengonSpecialTalked( int index, int talker, char *msg, int color ); +void NPC_DengonLooked( int meindex, int lookedindex ); +void NPC_DengonWindowTalked( int index, int talker, + int seqno, int select, char *data); + +#endif + +002F:npc_door.h:0470:1:14=48041e4b:16=47d21313:#ifndef __NPC_DOOR_H__ +#define __NPC_DOOR_H__ + +BOOL NPC_DoorInit(int meindex ); +void NPC_DoorTalked( int meindex , int talkerindex , char *msg , int color ); +void NPC_DoorPreAttacked(int meindex , int attacker , float *dm); +void NPC_DoorPostOver( int meindex , int movedindex ); +void NPC_DoorOff( int meindex , int movedindex ); +void NPC_DoorWatch( int meindex, int moveindex, CHAR_ACTION act, + int x, int y, int dir, int* opt, int optlen ); +int NPC_DoorSearchByName( char *name ); +int NPC_DoorSearchByPosition( int fl , int x, int y ); +void NPC_DoorLooked( int meindex , int lookedindex ); +BOOL NPC_DoorRefreshOverFlg( int meind ); + + +/* ְNPCճ۽ľãNPC年л npc_stepswitch.cëǷ */ +int NPC_DoorSetPasswd( int meindex, char *pas ); +int NPC_DoorGetPasswd( int meindex, char *out , int len ); +void NPC_DoorFlip(int meindex , int doindex); +void NPC_DoorClose(int meindex , int doindex); +void NPC_DoorOpen(int meindex , int doindex ); +void NPC_DoorAddSwitchCounter( int meindex , int i , int talker ); +void NPC_DoorSetSwitchCounter( int meindex, int i , int doindex ); + +#endif + + + + + +0031:npc_doorman.h:0CA:1:14=48041e4b:16=47d21313:#ifndef __NPC_DOORMAN_H__ +#define __NPC_DOORMAN_H__ + +BOOL NPC_DoormanInit( int meindex ); +void NPC_DoormanTalked( int meindex , int talkerindex , char *msg , + int color ); + +#endif + +0036:npc_duelranking.h:01AD:1:14=48041e4b:16=47d21313:#ifndef __NPC_DUELRANKING_H__ +#define __NPC_DUELRANKING_H__ + +BOOL NPC_DuelrankingInit( int meindex ); +void NPC_DuelrankingLooked( int meindex, int lookedindex ); +void NPC_DuelrankingWindowTalked( int meindex, int talkerindex, int seqno, int select, char *data); +void NPC_Duelranking_PrintRanking( char *data, int count_start, int fdid, int msgid2); +void NPC_Duelranking_CallMyRanking( int count, int msgid, int msgid2); + +#endif + +0037:npc_eventaction.h:01505:1:14=48041e4b:16=47d21313:#ifndef _PRO_NPCFIX_H +#define _PRO_NPCFIX_H +//ANDY_Edit +BOOL ActionNpc_CheckMenuFree( int meindex, int toindex, char *npcarg, int nums); +BOOL ActionNpc_CheckFree( int meindex, int toindex, char *npcarg); +BOOL Action_RunDoEventAction( int meindex, int toindex, char *buf1); +BOOL ActionNpc_WarpPoint(int meindex,int talker,char *npcarg); +BOOL Action_PartyCheck( int meindex, int talker); +BOOL NPC_ActionAddGold( int talker, int Golds); +BOOL NPC_ActionDelGold( int talker,char *buf); +BOOL NPC_ActionDelFame( int talker,char *buf); +BOOL NPC_ActionAddFame( int talker,char *buf); +#ifdef _MOMENTUM_NPC +BOOL NPC_ActionMomentum( int talker,char *buf); +#endif +#ifdef _DP_NPC +BOOL NPC_ActionDP( int talker,char *buf); +#endif +#ifdef _VIP_SHOP +BOOL NPC_ActionDelVipPoint( int talker,char *buf); +#endif +#ifdef _TRANS_7_NPC +BOOL NPC_ActionTrans7( int talker, char *buf); +BOOL NPC_ActionTransNew7( int talker, char *buf); +BOOL NPC_ActionTransNewSeven( int talker, char *buf); +#endif +// WON ADD +BOOL NPC_ActionAddGold2( int talker,char *buf); +BOOL NPC_ActionDelPet( int toindex,char *buf); +#ifdef _NPC_NewDelPet +BOOL NPC_ActionNewDelPet( int talker,char *msg); +#endif +BOOL NPC_ActionAddPet( int talker, char *buf); +BOOL NPC_ActionDelItem( int talker,char *buf); +BOOL NPC_ActionAddItem( int talker, char *buf); +BOOL NPC_ActionSetEend( int talkerindex, char * buf); +BOOL NPC_ActionSetNow( int toindex, char * buf); +BOOL NPC_ActionClearEvent( int toindex, char * buf); + +BOOL NPC_ActionCheckTrans(int meindex,int talker,int trans,int flg); +#ifdef _VIP_SHOP +BOOL NPC_ActionVipPointCheck(int meindex,int talker,int point,int flg); +#endif +#ifdef _VIP_RIDE +BOOL NPC_ActionVipCheck(int meindex,int talker,int vip,int flg); +#endif +#ifdef _VIP_SHOP +BOOL NPC_ActionNewVipPointCheck(int meindex,int talker,int point,int flg); +#endif +#ifdef _MOMENTUM_NPC +BOOL NPC_ActionMomentumCheck(int meindex,int talker,int Momentum,int flg); +#endif +#ifdef _DP_NPC +BOOL NPC_ActionDPCheck(int meindex,int talker,int DP,int flg); +#endif +BOOL NPC_ActionLevelCheck(int meindex,int talker,int level,int flg); + +#ifdef _PROFESSION_SKILL // WON ADD ְҵ +BOOL NPC_ActionClassCheck( int meindex,int talker,int p_class,int flg); + +BOOL NPC_ActionSkillCheck( int meindex,int talker,int skillId,int flg); +BOOL NPC_ActionSkillNumCheck( int meindex,int talker,int sknum,int flg); + +BOOL NPC_ActionSkillPointAndSkillCheck( int meindex,int talker,int sknum,int flg); + +BOOL NPC_ActionCheckSkup(int meindex,int talker,int skup,int flg); +BOOL NPC_ActionCheckSafe(int meindex,int talker,int safe,int flg); + +BOOL NPC_ActionCleanProfession( int toindex, char *buf); +BOOL NPC_ActionAddProfessionSkillPoint( int toindex, char *buf ); +#endif + +BOOL NPC_ActionGoldCheck(int meindex,int talker,int Golds,int flg); +BOOL NPC_ActionPartyCheck( int toindex, int nums, int flg); +BOOL NPC_ActionReItemCheck( int toindex, int nums, int flg); +BOOL NPC_ActionRePetCheck( int toindex, int nums, int flg); +BOOL ActionCheckMyPet( int meindex, int talker, int petLv, int flg, int petid); +BOOL NPC_ActionBigSmallLastCheck(int point1,int mypoint,int flg); + +BOOL NPC_ActionItemCheck(int meindex,int talker,int itemNo, int flg); +BOOL NPC_ActioneEquitCheck(int meindex,int talker,int itemNo, int flg); + +BOOL NPC_ActionFreeIfCheck(int meindex,int talker, char* buf, char *opt, int kosuu,int flg, int temp); + +BOOL NPC_ActionBigSmallCheck(int meindex,int talker,char* buf); +BOOL NPC_ActionPassCheck( int meindex, int talker, char *buf); +BOOL NPC_ActionWarpManReduce(int meindex,int talker,char *buf); +#ifdef _NPC_ActionFreeCmp +BOOL NPC_ActionWarpManReduce2(int meindex,int talker,char *buf); +#endif +#ifdef _NPCCHANGE_PLAYERIMG //andy +BOOL NPC_ActionChangePlayerBBI( int meindex, int charindex, char *Img); +BOOL NPC_CheckPlayerBBI( int meindex, int charindex, int BBI, int flg); +#endif + +BOOL showString( int meindex, char *showstr,int flg); +BOOL NPC_getTimeXYPoint( int meindex, int Mode); +BOOL NPC_getTimeData( int meindex, char *npcarg, int *born, int *dead, int loopspeed); +void NPC_TimeDefineDo( int meindex, int born, int dead, int typeMode); +BOOL NPC_CheckTimeDefine( char *timetype); + +void GetRand_WarpPoint( char *buf, int *fl, int *x, int *y ); +#ifdef _EMENY_CHANCEMAN +int NPC_EmenyChanceCheck( int meindex, int charaindex, char *arg); +int NPC_DischargePartyForSex( int meindex, int charaindex, int fl, int x, int y, int fsex); +#endif + +BOOL NPC_ActionDuelRankCheck(int meindex,int talker,int rank,int flg); +BOOL NPC_ActionDuelPointCheck(int meindex,int talker,int rank,int flg); + +#ifdef _TREASURE_BOX +BOOL NPC_ActionTreasureTypeCheck( int meindex, int level, int type, int flg); +#endif +BOOL NPC_ActionTreasureRandItemGet(int meidex,int talker,int rand_j,char *buf); +void NPC_ActionLevelAndTransUp( int meindex, int charindex, int level, + int skillpoint, int exp, int ridepet); +#ifdef _ITEM_PILENUMS +BOOL NPC_ActionDoPileDelItem( int toindex, int itemID, int num); +BOOL NPC_DelItem( int toindex, int ti, int num); +#endif +void NPC_ActionDoPileClearItem( int toindex, int itemID); + + +#ifdef _PROFESSION_SKILL // WON ADD ְҵ +int PROFESSION_RESTORE_POINT( int charaindex ); +#endif + + +#ifdef _NPC_ADDWARPMAN1 +BOOL NPC_ActionPartyCountCheck( int toindex, int nums, int flg); +BOOL NPC_ActionManCountCheck( int toindex, int nums, int flg);// +BOOL NPC_ActionWomanCountCheck( int toindex, int nums, int flg);//Ů +#endif + +#endif +0036:npc_exchangeman.h:0235:1:14=48041e4b:16=47d21313:#ifndef __NPC_EXCHANGEMAN_H__ +#define __NPC_EXCHANGEMAN_H__ + +void NPC_ExChangeManTalked( int meindex , int talkerindex , char *msg , + int color ); +BOOL NPC_ExChangeManInit( int meindex ); +void NPC_ExChangeManWindowTalked( int meindex, int talkerindex, int seqno, int select, char *data); + + + +BOOL NPC_EventCheckFlg( int talker, int shiftbit); +BOOL NPC_NowEventCheckFlg( int talker, int shiftbit); + +// Arminius 8.14 move from .c (for pet talk) +BOOL NPC_EventBigSmallCheck(int meindex,int talker,char* buf); + +#endif + + + /*__NPC_EXCHANGEMAN_H__*/ + + +0034:npc_familyman.h:0187:1:14=48041e4b:16=47d21313:#ifndef __NPC_FAMILYMAN_H__ +#define __NPC_FAMILYMAN_H__ + +void NPC_FamilymanTalked( int meindex , int talkerindex , char *msg , + int color ); + +BOOL NPC_FamilymanInit( int meindex ); +void NPC_FamilymanLooked( int meindex, int lookedindex ); +void NPC_FamilymanWindowTalked( int meindex, int talkerindex, int seqno, int select, char *data); + +#endif + +/*__NPC_FAMILYMAN_H__*/ +0033:npc_fmdengon.h:0111:1:14=48041e4b:16=47d21313:#ifndef __NPC_FMDENGON_H__ +#define __NPC_FMDENGON_H__ + +BOOL NPC_FmDengonInit( int meindex ); +void NPC_FmDengonLooked( int meindex, int lookedindex ); +void NPC_FmDengonWindowTalked( int index, int talker, int seqno, int select, char *data); + +#endif + +/*__NPC_FMDENGON_H__*/ +0032:npc_fmhealer.h:0E4:1:14=48041e4b:16=47d21313:#ifndef __NPC_FMHEALER_H__ +#define __NPC_FMHEALER_H__ + +void NPC_FmHealerTalked( int meindex , int talkerindex , char *msg , + int color ); +BOOL NPC_FmHealerInit( int meindex ); + +#endif +/*__NPC_FMHEALER_H__*/ +0033:npc_fmletter.h:0180:1:14=48041e4b:16=47d21313:#ifndef __NPC_FMLETTER_H__ +#define __NPC_FMLETTER_H__ + +void NPC_FmLetterTalked( int meindex , int talkerindex , char *msg , + int color ); + +BOOL NPC_FmLetterInit( int meindex ); +void NPC_FmLetterLooked( int meindex, int lookedindex ); +void NPC_FmLetterWindowTalked( int meindex, int talkerindex, int seqno, int select, char *data); + +#endif + +/*__NPC_FMLETTER_H__*/ +0036:npc_fmpkcallman.h:013B:1:14=48041e4b:16=47d21313:#ifndef __NPC_FMPKCALLMAN_H__ +#define __NPC_FMPKCALLMAN_H__ + +void NPC_FMPKCallManTalked(int meindex, int talkerindex, char *msg, int color); +BOOL NPC_FMPKCallManInit(int meindex); +void NPC_FMPKCallManWindowTalked(int meindex, int talkerindex, int seqno, + int select, char *data); + +#endif +/*__NPC_FMPKCALLMAN_H__*/ +0032:npc_fmpkman.h:0123:1:14=48041e4b:16=47d21313:#ifndef __NPC_FMPKMAN_H__ +#define __NPC_FMPKMAN_H__ + +void NPC_FMPKManTalked(int meindex, int talkerindex, char *msg, int color); +BOOL NPC_FMPKManInit(int meindex); +void NPC_FMPKManWindowTalked(int meindex, int talkerindex, int seqno, + int select, char *data); + +#endif +/*__NPC_FMPKMAN_H__*/ +0034:npc_fmwarpman.h:01A6:1:14=48041e4b:16=47d21313:#ifndef __NPC_FMWARPMAN_H__ +#define __NPC_FMWARPMAN_H__ + +void NPC_FMWarpManTalked(int meindex, int talkerindex, char *msg, int color); +BOOL NPC_FMWarpManInit(int meindex); +void NPC_FMWarpManWindowTalked(int meindex, int talkerindex, int seqno, + int select, char *data); +void NPC_FMWarpManLoop(int meindex); +void NPC_GetPKFMNum(int floor, int fmindex1, int fmindex2, int *num1, int *num2); + +#endif +/*__NPC_FMWARPMAN_H__*/ +003B:npc_freepetskillshop.h:01C4:1:14=48041e4b:16=47d21313: \ No newline at end of file diff --git a/include/npc_autopk.h b/include/npc_autopk.h new file mode 100644 index 0000000..9c972f0 --- /dev/null +++ b/include/npc_autopk.h @@ -0,0 +1,21 @@ +#ifndef _AUTO_PK_H +#define _AUTO_PK_H + +void NPC_AutoPkTalked( int meindex, int talkerindex, char *msg, int color ); +BOOL NPC_AutoPkInit( int meindex ); +void NPC_AutoPkWindowTalked( int meindex, int talkerindex, int seqno, int select, char *data); +void NPC_AutoPkLoop( void ); +void AutoPk_PKSystemTalk( char *token1, char *token2 ); +void AutoPk_PKSystemInfo(); +void AutoPk_PKTimeSet( int pktime ); +void AutoPk_PKTimeSetOnly( int pktime ); +int AutoPk_PKTimeGet( void ); +void AutoPk_AwardSet( int petid, char *pet, int itemid, char *item ); +void AutoPk_ChampionShipSet( char *cdkey, char *name, int winnum, int win ); +void NPC_AUTOPKHealerTalked( int meindex ); +void AutoPk_SetHistoryStr( void ); +void AutoPk_SetAwardStr( char *token ); +BOOL AutoPk_GetAwardStr( void ); +void AutoPk_GetChampionShip( void ); +void AutoPk_PKSystemStart( void ); +#endif diff --git a/include/npc_bankman.h b/include/npc_bankman.h new file mode 100644 index 0000000..8cd40c7 --- /dev/null +++ b/include/npc_bankman.h @@ -0,0 +1,12 @@ +#ifndef __NPC_BANKMAN_H__ +#define __NPC_BANKMAN_H__ + +void NPC_BankmanTalked( int meindex , int talkerindex , char *msg , + int color ); + +BOOL NPC_BankmanInit( int meindex ); +void NPC_BankmanLooked( int meindex, int lookedindex ); +void NPC_BankmanWindowTalked( int meindex, int talkerindex, int seqno, int select, char *data); + +#endif + diff --git a/include/npc_bigsmallmaster.h b/include/npc_bigsmallmaster.h new file mode 100644 index 0000000..53ba813 --- /dev/null +++ b/include/npc_bigsmallmaster.h @@ -0,0 +1,346 @@ +0034:npc_bigsmallpet.h:00:1:14=48041e4b:16=47d21313:0034:npc_blackmarket.h:00:1:14=48041e4b:16=47d21313:0032:npc_bodylan.h:0166:1:14=48041e4b:16=47d21313:#ifndef __NPC_BODYLAN_H__ +#define __NPC_BODYLAN_H__ + +void NPC_BodyLanTalked( int meindex , int talkerindex , char *msg , + int color ); +BOOL NPC_BodyLanInit( int meindex ); +void NPC_BodyLanWatch( int meindex , int lookedindex); +void NPC_BodyLanWindowTalked( + int meindex, + int talkerindex, + int seqno, + int select, + char *data +); + +#endif +002E:npc_bus.h:016E:1:14=48041e4b:16=47d21313:#ifndef __NPC_BUS_H__ +#define __NPC_BUS_H__ + +BOOL NPC_BusInit( int meindex ); +void NPC_BusLoop( int meindex ); +void NPC_BusTalked( int meindex , int talkerindex , char *szMes , + int color ); +BOOL NPC_BusCheckAllowItem( int meindex, int charaindex, BOOL pickupmode); +BOOL NPC_BusCheckJoinParty( int meindex, int charaindex, BOOL msgflg); + +#endif + +0030:npc_charm.h:0156:1:14=48041e4b:16=47d21313:#ifndef __NPC_CHARM_H__ +#define __NPC_CHARM_H__ + +void NPC_CharmTalked( int meindex , int talkerindex , char *msg , + int color ); +BOOL NPC_CharmInit( int meindex ); +void NPC_CharmWindowTalked( int meindex, int talkerindex, int seqno, int select, char *data); +void NPC_CharmLooked( int meindex , int lookedindex); + +#endif + +0033:npc_checkman.h:0167:1:14=48041e4b:16=47d21313:#ifndef __NPC_CHECKMAN_H__ +#define __NPC_CHECKMAN_H__ + +void NPC_CheckManTalked( int meindex , int talkerindex , char *msg , + int color ); +BOOL NPC_CheckManInit( int meindex ); +void NPC_CheckManWindowTalked( int meindex, int talkerindex, int seqno, int select, char *data); +void NPC_CheckManLooked( int meindex , int lookedindex); + +#endif + +0031:npc_Dengon.h:0146:1:14=48041e4b:16=47d21313:#ifndef __NPC_DENGON_H__ +#define __NPC_DENGON_H__ +BOOL NPC_DengonInit( int meindex ); +//void NPC_DengonSpecialTalked( int index, int talker, char *msg, int color ); +void NPC_DengonLooked( int meindex, int lookedindex ); +void NPC_DengonWindowTalked( int index, int talker, + int seqno, int select, char *data); + +#endif + +002F:npc_door.h:0470:1:14=48041e4b:16=47d21313:#ifndef __NPC_DOOR_H__ +#define __NPC_DOOR_H__ + +BOOL NPC_DoorInit(int meindex ); +void NPC_DoorTalked( int meindex , int talkerindex , char *msg , int color ); +void NPC_DoorPreAttacked(int meindex , int attacker , float *dm); +void NPC_DoorPostOver( int meindex , int movedindex ); +void NPC_DoorOff( int meindex , int movedindex ); +void NPC_DoorWatch( int meindex, int moveindex, CHAR_ACTION act, + int x, int y, int dir, int* opt, int optlen ); +int NPC_DoorSearchByName( char *name ); +int NPC_DoorSearchByPosition( int fl , int x, int y ); +void NPC_DoorLooked( int meindex , int lookedindex ); +BOOL NPC_DoorRefreshOverFlg( int meind ); + + +/* ְNPCճ۽ľãNPC年л npc_stepswitch.cëǷ */ +int NPC_DoorSetPasswd( int meindex, char *pas ); +int NPC_DoorGetPasswd( int meindex, char *out , int len ); +void NPC_DoorFlip(int meindex , int doindex); +void NPC_DoorClose(int meindex , int doindex); +void NPC_DoorOpen(int meindex , int doindex ); +void NPC_DoorAddSwitchCounter( int meindex , int i , int talker ); +void NPC_DoorSetSwitchCounter( int meindex, int i , int doindex ); + +#endif + + + + + +0031:npc_doorman.h:0CA:1:14=48041e4b:16=47d21313:#ifndef __NPC_DOORMAN_H__ +#define __NPC_DOORMAN_H__ + +BOOL NPC_DoormanInit( int meindex ); +void NPC_DoormanTalked( int meindex , int talkerindex , char *msg , + int color ); + +#endif + +0036:npc_duelranking.h:01AD:1:14=48041e4b:16=47d21313:#ifndef __NPC_DUELRANKING_H__ +#define __NPC_DUELRANKING_H__ + +BOOL NPC_DuelrankingInit( int meindex ); +void NPC_DuelrankingLooked( int meindex, int lookedindex ); +void NPC_DuelrankingWindowTalked( int meindex, int talkerindex, int seqno, int select, char *data); +void NPC_Duelranking_PrintRanking( char *data, int count_start, int fdid, int msgid2); +void NPC_Duelranking_CallMyRanking( int count, int msgid, int msgid2); + +#endif + +0037:npc_eventaction.h:01505:1:14=48041e4b:16=47d21313:#ifndef _PRO_NPCFIX_H +#define _PRO_NPCFIX_H +//ANDY_Edit +BOOL ActionNpc_CheckMenuFree( int meindex, int toindex, char *npcarg, int nums); +BOOL ActionNpc_CheckFree( int meindex, int toindex, char *npcarg); +BOOL Action_RunDoEventAction( int meindex, int toindex, char *buf1); +BOOL ActionNpc_WarpPoint(int meindex,int talker,char *npcarg); +BOOL Action_PartyCheck( int meindex, int talker); +BOOL NPC_ActionAddGold( int talker, int Golds); +BOOL NPC_ActionDelGold( int talker,char *buf); +BOOL NPC_ActionDelFame( int talker,char *buf); +BOOL NPC_ActionAddFame( int talker,char *buf); +#ifdef _MOMENTUM_NPC +BOOL NPC_ActionMomentum( int talker,char *buf); +#endif +#ifdef _DP_NPC +BOOL NPC_ActionDP( int talker,char *buf); +#endif +#ifdef _VIP_SHOP +BOOL NPC_ActionDelVipPoint( int talker,char *buf); +#endif +#ifdef _TRANS_7_NPC +BOOL NPC_ActionTrans7( int talker, char *buf); +BOOL NPC_ActionTransNew7( int talker, char *buf); +BOOL NPC_ActionTransNewSeven( int talker, char *buf); +#endif +// WON ADD +BOOL NPC_ActionAddGold2( int talker,char *buf); +BOOL NPC_ActionDelPet( int toindex,char *buf); +#ifdef _NPC_NewDelPet +BOOL NPC_ActionNewDelPet( int talker,char *msg); +#endif +BOOL NPC_ActionAddPet( int talker, char *buf); +BOOL NPC_ActionDelItem( int talker,char *buf); +BOOL NPC_ActionAddItem( int talker, char *buf); +BOOL NPC_ActionSetEend( int talkerindex, char * buf); +BOOL NPC_ActionSetNow( int toindex, char * buf); +BOOL NPC_ActionClearEvent( int toindex, char * buf); + +BOOL NPC_ActionCheckTrans(int meindex,int talker,int trans,int flg); +#ifdef _VIP_SHOP +BOOL NPC_ActionVipPointCheck(int meindex,int talker,int point,int flg); +#endif +#ifdef _VIP_RIDE +BOOL NPC_ActionVipCheck(int meindex,int talker,int vip,int flg); +#endif +#ifdef _VIP_SHOP +BOOL NPC_ActionNewVipPointCheck(int meindex,int talker,int point,int flg); +#endif +#ifdef _MOMENTUM_NPC +BOOL NPC_ActionMomentumCheck(int meindex,int talker,int Momentum,int flg); +#endif +#ifdef _DP_NPC +BOOL NPC_ActionDPCheck(int meindex,int talker,int DP,int flg); +#endif +BOOL NPC_ActionLevelCheck(int meindex,int talker,int level,int flg); + +#ifdef _PROFESSION_SKILL // WON ADD ְҵ +BOOL NPC_ActionClassCheck( int meindex,int talker,int p_class,int flg); + +BOOL NPC_ActionSkillCheck( int meindex,int talker,int skillId,int flg); +BOOL NPC_ActionSkillNumCheck( int meindex,int talker,int sknum,int flg); + +BOOL NPC_ActionSkillPointAndSkillCheck( int meindex,int talker,int sknum,int flg); + +BOOL NPC_ActionCheckSkup(int meindex,int talker,int skup,int flg); +BOOL NPC_ActionCheckSafe(int meindex,int talker,int safe,int flg); + +BOOL NPC_ActionCleanProfession( int toindex, char *buf); +BOOL NPC_ActionAddProfessionSkillPoint( int toindex, char *buf ); +#endif + +BOOL NPC_ActionGoldCheck(int meindex,int talker,int Golds,int flg); +BOOL NPC_ActionPartyCheck( int toindex, int nums, int flg); +BOOL NPC_ActionReItemCheck( int toindex, int nums, int flg); +BOOL NPC_ActionRePetCheck( int toindex, int nums, int flg); +BOOL ActionCheckMyPet( int meindex, int talker, int petLv, int flg, int petid); +BOOL NPC_ActionBigSmallLastCheck(int point1,int mypoint,int flg); + +BOOL NPC_ActionItemCheck(int meindex,int talker,int itemNo, int flg); +BOOL NPC_ActioneEquitCheck(int meindex,int talker,int itemNo, int flg); + +BOOL NPC_ActionFreeIfCheck(int meindex,int talker, char* buf, char *opt, int kosuu,int flg, int temp); + +BOOL NPC_ActionBigSmallCheck(int meindex,int talker,char* buf); +BOOL NPC_ActionPassCheck( int meindex, int talker, char *buf); +BOOL NPC_ActionWarpManReduce(int meindex,int talker,char *buf); +#ifdef _NPC_ActionFreeCmp +BOOL NPC_ActionWarpManReduce2(int meindex,int talker,char *buf); +#endif +#ifdef _NPCCHANGE_PLAYERIMG //andy +BOOL NPC_ActionChangePlayerBBI( int meindex, int charindex, char *Img); +BOOL NPC_CheckPlayerBBI( int meindex, int charindex, int BBI, int flg); +#endif + +BOOL showString( int meindex, char *showstr,int flg); +BOOL NPC_getTimeXYPoint( int meindex, int Mode); +BOOL NPC_getTimeData( int meindex, char *npcarg, int *born, int *dead, int loopspeed); +void NPC_TimeDefineDo( int meindex, int born, int dead, int typeMode); +BOOL NPC_CheckTimeDefine( char *timetype); + +void GetRand_WarpPoint( char *buf, int *fl, int *x, int *y ); +#ifdef _EMENY_CHANCEMAN +int NPC_EmenyChanceCheck( int meindex, int charaindex, char *arg); +int NPC_DischargePartyForSex( int meindex, int charaindex, int fl, int x, int y, int fsex); +#endif + +BOOL NPC_ActionDuelRankCheck(int meindex,int talker,int rank,int flg); +BOOL NPC_ActionDuelPointCheck(int meindex,int talker,int rank,int flg); + +#ifdef _TREASURE_BOX +BOOL NPC_ActionTreasureTypeCheck( int meindex, int level, int type, int flg); +#endif +BOOL NPC_ActionTreasureRandItemGet(int meidex,int talker,int rand_j,char *buf); +void NPC_ActionLevelAndTransUp( int meindex, int charindex, int level, + int skillpoint, int exp, int ridepet); +#ifdef _ITEM_PILENUMS +BOOL NPC_ActionDoPileDelItem( int toindex, int itemID, int num); +BOOL NPC_DelItem( int toindex, int ti, int num); +#endif +void NPC_ActionDoPileClearItem( int toindex, int itemID); + + +#ifdef _PROFESSION_SKILL // WON ADD ְҵ +int PROFESSION_RESTORE_POINT( int charaindex ); +#endif + + +#ifdef _NPC_ADDWARPMAN1 +BOOL NPC_ActionPartyCountCheck( int toindex, int nums, int flg); +BOOL NPC_ActionManCountCheck( int toindex, int nums, int flg);// +BOOL NPC_ActionWomanCountCheck( int toindex, int nums, int flg);//Ů +#endif + +#endif +0036:npc_exchangeman.h:0235:1:14=48041e4b:16=47d21313:#ifndef __NPC_EXCHANGEMAN_H__ +#define __NPC_EXCHANGEMAN_H__ + +void NPC_ExChangeManTalked( int meindex , int talkerindex , char *msg , + int color ); +BOOL NPC_ExChangeManInit( int meindex ); +void NPC_ExChangeManWindowTalked( int meindex, int talkerindex, int seqno, int select, char *data); + + + +BOOL NPC_EventCheckFlg( int talker, int shiftbit); +BOOL NPC_NowEventCheckFlg( int talker, int shiftbit); + +// Arminius 8.14 move from .c (for pet talk) +BOOL NPC_EventBigSmallCheck(int meindex,int talker,char* buf); + +#endif + + + /*__NPC_EXCHANGEMAN_H__*/ + + +0034:npc_familyman.h:0187:1:14=48041e4b:16=47d21313:#ifndef __NPC_FAMILYMAN_H__ +#define __NPC_FAMILYMAN_H__ + +void NPC_FamilymanTalked( int meindex , int talkerindex , char *msg , + int color ); + +BOOL NPC_FamilymanInit( int meindex ); +void NPC_FamilymanLooked( int meindex, int lookedindex ); +void NPC_FamilymanWindowTalked( int meindex, int talkerindex, int seqno, int select, char *data); + +#endif + +/*__NPC_FAMILYMAN_H__*/ +0033:npc_fmdengon.h:0111:1:14=48041e4b:16=47d21313:#ifndef __NPC_FMDENGON_H__ +#define __NPC_FMDENGON_H__ + +BOOL NPC_FmDengonInit( int meindex ); +void NPC_FmDengonLooked( int meindex, int lookedindex ); +void NPC_FmDengonWindowTalked( int index, int talker, int seqno, int select, char *data); + +#endif + +/*__NPC_FMDENGON_H__*/ +0032:npc_fmhealer.h:0E4:1:14=48041e4b:16=47d21313:#ifndef __NPC_FMHEALER_H__ +#define __NPC_FMHEALER_H__ + +void NPC_FmHealerTalked( int meindex , int talkerindex , char *msg , + int color ); +BOOL NPC_FmHealerInit( int meindex ); + +#endif +/*__NPC_FMHEALER_H__*/ +0033:npc_fmletter.h:0180:1:14=48041e4b:16=47d21313:#ifndef __NPC_FMLETTER_H__ +#define __NPC_FMLETTER_H__ + +void NPC_FmLetterTalked( int meindex , int talkerindex , char *msg , + int color ); + +BOOL NPC_FmLetterInit( int meindex ); +void NPC_FmLetterLooked( int meindex, int lookedindex ); +void NPC_FmLetterWindowTalked( int meindex, int talkerindex, int seqno, int select, char *data); + +#endif + +/*__NPC_FMLETTER_H__*/ +0036:npc_fmpkcallman.h:013B:1:14=48041e4b:16=47d21313:#ifndef __NPC_FMPKCALLMAN_H__ +#define __NPC_FMPKCALLMAN_H__ + +void NPC_FMPKCallManTalked(int meindex, int talkerindex, char *msg, int color); +BOOL NPC_FMPKCallManInit(int meindex); +void NPC_FMPKCallManWindowTalked(int meindex, int talkerindex, int seqno, + int select, char *data); + +#endif +/*__NPC_FMPKCALLMAN_H__*/ +0032:npc_fmpkman.h:0123:1:14=48041e4b:16=47d21313:#ifndef __NPC_FMPKMAN_H__ +#define __NPC_FMPKMAN_H__ + +void NPC_FMPKManTalked(int meindex, int talkerindex, char *msg, int color); +BOOL NPC_FMPKManInit(int meindex); +void NPC_FMPKManWindowTalked(int meindex, int talkerindex, int seqno, + int select, char *data); + +#endif +/*__NPC_FMPKMAN_H__*/ +0034:npc_fmwarpman.h:01A6:1:14=48041e4b:16=47d21313:#ifndef __NPC_FMWARPMAN_H__ +#define __NPC_FMWARPMAN_H__ + +void NPC_FMWarpManTalked(int meindex, int talkerindex, char *msg, int color); +BOOL NPC_FMWarpManInit(int meindex); +void NPC_FMWarpManWindowTalked(int meindex, int talkerindex, int seqno, + int select, char *data); +void NPC_FMWarpManLoop(int meindex); +void NPC_GetPKFMNum(int floor, int fmindex1, int fmindex2, int *num1, int *num2); + +#endif +/*__NPC_FMWARPMAN_H__*/ +003B:npc_freepetskillshop.h:01C4:1:14=48041e4b:16=47d21313: \ No newline at end of file diff --git a/include/npc_bigsmallpet.h b/include/npc_bigsmallpet.h new file mode 100644 index 0000000..3d6a851 --- /dev/null +++ b/include/npc_bigsmallpet.h @@ -0,0 +1,346 @@ +0034:npc_blackmarket.h:00:1:14=48041e4b:16=47d21313:0032:npc_bodylan.h:0166:1:14=48041e4b:16=47d21313:#ifndef __NPC_BODYLAN_H__ +#define __NPC_BODYLAN_H__ + +void NPC_BodyLanTalked( int meindex , int talkerindex , char *msg , + int color ); +BOOL NPC_BodyLanInit( int meindex ); +void NPC_BodyLanWatch( int meindex , int lookedindex); +void NPC_BodyLanWindowTalked( + int meindex, + int talkerindex, + int seqno, + int select, + char *data +); + +#endif +002E:npc_bus.h:016E:1:14=48041e4b:16=47d21313:#ifndef __NPC_BUS_H__ +#define __NPC_BUS_H__ + +BOOL NPC_BusInit( int meindex ); +void NPC_BusLoop( int meindex ); +void NPC_BusTalked( int meindex , int talkerindex , char *szMes , + int color ); +BOOL NPC_BusCheckAllowItem( int meindex, int charaindex, BOOL pickupmode); +BOOL NPC_BusCheckJoinParty( int meindex, int charaindex, BOOL msgflg); + +#endif + +0030:npc_charm.h:0156:1:14=48041e4b:16=47d21313:#ifndef __NPC_CHARM_H__ +#define __NPC_CHARM_H__ + +void NPC_CharmTalked( int meindex , int talkerindex , char *msg , + int color ); +BOOL NPC_CharmInit( int meindex ); +void NPC_CharmWindowTalked( int meindex, int talkerindex, int seqno, int select, char *data); +void NPC_CharmLooked( int meindex , int lookedindex); + +#endif + +0033:npc_checkman.h:0167:1:14=48041e4b:16=47d21313:#ifndef __NPC_CHECKMAN_H__ +#define __NPC_CHECKMAN_H__ + +void NPC_CheckManTalked( int meindex , int talkerindex , char *msg , + int color ); +BOOL NPC_CheckManInit( int meindex ); +void NPC_CheckManWindowTalked( int meindex, int talkerindex, int seqno, int select, char *data); +void NPC_CheckManLooked( int meindex , int lookedindex); + +#endif + +0031:npc_Dengon.h:0146:1:14=48041e4b:16=47d21313:#ifndef __NPC_DENGON_H__ +#define __NPC_DENGON_H__ +BOOL NPC_DengonInit( int meindex ); +//void NPC_DengonSpecialTalked( int index, int talker, char *msg, int color ); +void NPC_DengonLooked( int meindex, int lookedindex ); +void NPC_DengonWindowTalked( int index, int talker, + int seqno, int select, char *data); + +#endif + +002F:npc_door.h:0470:1:14=48041e4b:16=47d21313:#ifndef __NPC_DOOR_H__ +#define __NPC_DOOR_H__ + +BOOL NPC_DoorInit(int meindex ); +void NPC_DoorTalked( int meindex , int talkerindex , char *msg , int color ); +void NPC_DoorPreAttacked(int meindex , int attacker , float *dm); +void NPC_DoorPostOver( int meindex , int movedindex ); +void NPC_DoorOff( int meindex , int movedindex ); +void NPC_DoorWatch( int meindex, int moveindex, CHAR_ACTION act, + int x, int y, int dir, int* opt, int optlen ); +int NPC_DoorSearchByName( char *name ); +int NPC_DoorSearchByPosition( int fl , int x, int y ); +void NPC_DoorLooked( int meindex , int lookedindex ); +BOOL NPC_DoorRefreshOverFlg( int meind ); + + +/* ְNPCճ۽ľãNPC年л npc_stepswitch.cëǷ */ +int NPC_DoorSetPasswd( int meindex, char *pas ); +int NPC_DoorGetPasswd( int meindex, char *out , int len ); +void NPC_DoorFlip(int meindex , int doindex); +void NPC_DoorClose(int meindex , int doindex); +void NPC_DoorOpen(int meindex , int doindex ); +void NPC_DoorAddSwitchCounter( int meindex , int i , int talker ); +void NPC_DoorSetSwitchCounter( int meindex, int i , int doindex ); + +#endif + + + + + +0031:npc_doorman.h:0CA:1:14=48041e4b:16=47d21313:#ifndef __NPC_DOORMAN_H__ +#define __NPC_DOORMAN_H__ + +BOOL NPC_DoormanInit( int meindex ); +void NPC_DoormanTalked( int meindex , int talkerindex , char *msg , + int color ); + +#endif + +0036:npc_duelranking.h:01AD:1:14=48041e4b:16=47d21313:#ifndef __NPC_DUELRANKING_H__ +#define __NPC_DUELRANKING_H__ + +BOOL NPC_DuelrankingInit( int meindex ); +void NPC_DuelrankingLooked( int meindex, int lookedindex ); +void NPC_DuelrankingWindowTalked( int meindex, int talkerindex, int seqno, int select, char *data); +void NPC_Duelranking_PrintRanking( char *data, int count_start, int fdid, int msgid2); +void NPC_Duelranking_CallMyRanking( int count, int msgid, int msgid2); + +#endif + +0037:npc_eventaction.h:01505:1:14=48041e4b:16=47d21313:#ifndef _PRO_NPCFIX_H +#define _PRO_NPCFIX_H +//ANDY_Edit +BOOL ActionNpc_CheckMenuFree( int meindex, int toindex, char *npcarg, int nums); +BOOL ActionNpc_CheckFree( int meindex, int toindex, char *npcarg); +BOOL Action_RunDoEventAction( int meindex, int toindex, char *buf1); +BOOL ActionNpc_WarpPoint(int meindex,int talker,char *npcarg); +BOOL Action_PartyCheck( int meindex, int talker); +BOOL NPC_ActionAddGold( int talker, int Golds); +BOOL NPC_ActionDelGold( int talker,char *buf); +BOOL NPC_ActionDelFame( int talker,char *buf); +BOOL NPC_ActionAddFame( int talker,char *buf); +#ifdef _MOMENTUM_NPC +BOOL NPC_ActionMomentum( int talker,char *buf); +#endif +#ifdef _DP_NPC +BOOL NPC_ActionDP( int talker,char *buf); +#endif +#ifdef _VIP_SHOP +BOOL NPC_ActionDelVipPoint( int talker,char *buf); +#endif +#ifdef _TRANS_7_NPC +BOOL NPC_ActionTrans7( int talker, char *buf); +BOOL NPC_ActionTransNew7( int talker, char *buf); +BOOL NPC_ActionTransNewSeven( int talker, char *buf); +#endif +// WON ADD +BOOL NPC_ActionAddGold2( int talker,char *buf); +BOOL NPC_ActionDelPet( int toindex,char *buf); +#ifdef _NPC_NewDelPet +BOOL NPC_ActionNewDelPet( int talker,char *msg); +#endif +BOOL NPC_ActionAddPet( int talker, char *buf); +BOOL NPC_ActionDelItem( int talker,char *buf); +BOOL NPC_ActionAddItem( int talker, char *buf); +BOOL NPC_ActionSetEend( int talkerindex, char * buf); +BOOL NPC_ActionSetNow( int toindex, char * buf); +BOOL NPC_ActionClearEvent( int toindex, char * buf); + +BOOL NPC_ActionCheckTrans(int meindex,int talker,int trans,int flg); +#ifdef _VIP_SHOP +BOOL NPC_ActionVipPointCheck(int meindex,int talker,int point,int flg); +#endif +#ifdef _VIP_RIDE +BOOL NPC_ActionVipCheck(int meindex,int talker,int vip,int flg); +#endif +#ifdef _VIP_SHOP +BOOL NPC_ActionNewVipPointCheck(int meindex,int talker,int point,int flg); +#endif +#ifdef _MOMENTUM_NPC +BOOL NPC_ActionMomentumCheck(int meindex,int talker,int Momentum,int flg); +#endif +#ifdef _DP_NPC +BOOL NPC_ActionDPCheck(int meindex,int talker,int DP,int flg); +#endif +BOOL NPC_ActionLevelCheck(int meindex,int talker,int level,int flg); + +#ifdef _PROFESSION_SKILL // WON ADD ְҵ +BOOL NPC_ActionClassCheck( int meindex,int talker,int p_class,int flg); + +BOOL NPC_ActionSkillCheck( int meindex,int talker,int skillId,int flg); +BOOL NPC_ActionSkillNumCheck( int meindex,int talker,int sknum,int flg); + +BOOL NPC_ActionSkillPointAndSkillCheck( int meindex,int talker,int sknum,int flg); + +BOOL NPC_ActionCheckSkup(int meindex,int talker,int skup,int flg); +BOOL NPC_ActionCheckSafe(int meindex,int talker,int safe,int flg); + +BOOL NPC_ActionCleanProfession( int toindex, char *buf); +BOOL NPC_ActionAddProfessionSkillPoint( int toindex, char *buf ); +#endif + +BOOL NPC_ActionGoldCheck(int meindex,int talker,int Golds,int flg); +BOOL NPC_ActionPartyCheck( int toindex, int nums, int flg); +BOOL NPC_ActionReItemCheck( int toindex, int nums, int flg); +BOOL NPC_ActionRePetCheck( int toindex, int nums, int flg); +BOOL ActionCheckMyPet( int meindex, int talker, int petLv, int flg, int petid); +BOOL NPC_ActionBigSmallLastCheck(int point1,int mypoint,int flg); + +BOOL NPC_ActionItemCheck(int meindex,int talker,int itemNo, int flg); +BOOL NPC_ActioneEquitCheck(int meindex,int talker,int itemNo, int flg); + +BOOL NPC_ActionFreeIfCheck(int meindex,int talker, char* buf, char *opt, int kosuu,int flg, int temp); + +BOOL NPC_ActionBigSmallCheck(int meindex,int talker,char* buf); +BOOL NPC_ActionPassCheck( int meindex, int talker, char *buf); +BOOL NPC_ActionWarpManReduce(int meindex,int talker,char *buf); +#ifdef _NPC_ActionFreeCmp +BOOL NPC_ActionWarpManReduce2(int meindex,int talker,char *buf); +#endif +#ifdef _NPCCHANGE_PLAYERIMG //andy +BOOL NPC_ActionChangePlayerBBI( int meindex, int charindex, char *Img); +BOOL NPC_CheckPlayerBBI( int meindex, int charindex, int BBI, int flg); +#endif + +BOOL showString( int meindex, char *showstr,int flg); +BOOL NPC_getTimeXYPoint( int meindex, int Mode); +BOOL NPC_getTimeData( int meindex, char *npcarg, int *born, int *dead, int loopspeed); +void NPC_TimeDefineDo( int meindex, int born, int dead, int typeMode); +BOOL NPC_CheckTimeDefine( char *timetype); + +void GetRand_WarpPoint( char *buf, int *fl, int *x, int *y ); +#ifdef _EMENY_CHANCEMAN +int NPC_EmenyChanceCheck( int meindex, int charaindex, char *arg); +int NPC_DischargePartyForSex( int meindex, int charaindex, int fl, int x, int y, int fsex); +#endif + +BOOL NPC_ActionDuelRankCheck(int meindex,int talker,int rank,int flg); +BOOL NPC_ActionDuelPointCheck(int meindex,int talker,int rank,int flg); + +#ifdef _TREASURE_BOX +BOOL NPC_ActionTreasureTypeCheck( int meindex, int level, int type, int flg); +#endif +BOOL NPC_ActionTreasureRandItemGet(int meidex,int talker,int rand_j,char *buf); +void NPC_ActionLevelAndTransUp( int meindex, int charindex, int level, + int skillpoint, int exp, int ridepet); +#ifdef _ITEM_PILENUMS +BOOL NPC_ActionDoPileDelItem( int toindex, int itemID, int num); +BOOL NPC_DelItem( int toindex, int ti, int num); +#endif +void NPC_ActionDoPileClearItem( int toindex, int itemID); + + +#ifdef _PROFESSION_SKILL // WON ADD ְҵ +int PROFESSION_RESTORE_POINT( int charaindex ); +#endif + + +#ifdef _NPC_ADDWARPMAN1 +BOOL NPC_ActionPartyCountCheck( int toindex, int nums, int flg); +BOOL NPC_ActionManCountCheck( int toindex, int nums, int flg);// +BOOL NPC_ActionWomanCountCheck( int toindex, int nums, int flg);//Ů +#endif + +#endif +0036:npc_exchangeman.h:0235:1:14=48041e4b:16=47d21313:#ifndef __NPC_EXCHANGEMAN_H__ +#define __NPC_EXCHANGEMAN_H__ + +void NPC_ExChangeManTalked( int meindex , int talkerindex , char *msg , + int color ); +BOOL NPC_ExChangeManInit( int meindex ); +void NPC_ExChangeManWindowTalked( int meindex, int talkerindex, int seqno, int select, char *data); + + + +BOOL NPC_EventCheckFlg( int talker, int shiftbit); +BOOL NPC_NowEventCheckFlg( int talker, int shiftbit); + +// Arminius 8.14 move from .c (for pet talk) +BOOL NPC_EventBigSmallCheck(int meindex,int talker,char* buf); + +#endif + + + /*__NPC_EXCHANGEMAN_H__*/ + + +0034:npc_familyman.h:0187:1:14=48041e4b:16=47d21313:#ifndef __NPC_FAMILYMAN_H__ +#define __NPC_FAMILYMAN_H__ + +void NPC_FamilymanTalked( int meindex , int talkerindex , char *msg , + int color ); + +BOOL NPC_FamilymanInit( int meindex ); +void NPC_FamilymanLooked( int meindex, int lookedindex ); +void NPC_FamilymanWindowTalked( int meindex, int talkerindex, int seqno, int select, char *data); + +#endif + +/*__NPC_FAMILYMAN_H__*/ +0033:npc_fmdengon.h:0111:1:14=48041e4b:16=47d21313:#ifndef __NPC_FMDENGON_H__ +#define __NPC_FMDENGON_H__ + +BOOL NPC_FmDengonInit( int meindex ); +void NPC_FmDengonLooked( int meindex, int lookedindex ); +void NPC_FmDengonWindowTalked( int index, int talker, int seqno, int select, char *data); + +#endif + +/*__NPC_FMDENGON_H__*/ +0032:npc_fmhealer.h:0E4:1:14=48041e4b:16=47d21313:#ifndef __NPC_FMHEALER_H__ +#define __NPC_FMHEALER_H__ + +void NPC_FmHealerTalked( int meindex , int talkerindex , char *msg , + int color ); +BOOL NPC_FmHealerInit( int meindex ); + +#endif +/*__NPC_FMHEALER_H__*/ +0033:npc_fmletter.h:0180:1:14=48041e4b:16=47d21313:#ifndef __NPC_FMLETTER_H__ +#define __NPC_FMLETTER_H__ + +void NPC_FmLetterTalked( int meindex , int talkerindex , char *msg , + int color ); + +BOOL NPC_FmLetterInit( int meindex ); +void NPC_FmLetterLooked( int meindex, int lookedindex ); +void NPC_FmLetterWindowTalked( int meindex, int talkerindex, int seqno, int select, char *data); + +#endif + +/*__NPC_FMLETTER_H__*/ +0036:npc_fmpkcallman.h:013B:1:14=48041e4b:16=47d21313:#ifndef __NPC_FMPKCALLMAN_H__ +#define __NPC_FMPKCALLMAN_H__ + +void NPC_FMPKCallManTalked(int meindex, int talkerindex, char *msg, int color); +BOOL NPC_FMPKCallManInit(int meindex); +void NPC_FMPKCallManWindowTalked(int meindex, int talkerindex, int seqno, + int select, char *data); + +#endif +/*__NPC_FMPKCALLMAN_H__*/ +0032:npc_fmpkman.h:0123:1:14=48041e4b:16=47d21313:#ifndef __NPC_FMPKMAN_H__ +#define __NPC_FMPKMAN_H__ + +void NPC_FMPKManTalked(int meindex, int talkerindex, char *msg, int color); +BOOL NPC_FMPKManInit(int meindex); +void NPC_FMPKManWindowTalked(int meindex, int talkerindex, int seqno, + int select, char *data); + +#endif +/*__NPC_FMPKMAN_H__*/ +0034:npc_fmwarpman.h:01A6:1:14=48041e4b:16=47d21313:#ifndef __NPC_FMWARPMAN_H__ +#define __NPC_FMWARPMAN_H__ + +void NPC_FMWarpManTalked(int meindex, int talkerindex, char *msg, int color); +BOOL NPC_FMWarpManInit(int meindex); +void NPC_FMWarpManWindowTalked(int meindex, int talkerindex, int seqno, + int select, char *data); +void NPC_FMWarpManLoop(int meindex); +void NPC_GetPKFMNum(int floor, int fmindex1, int fmindex2, int *num1, int *num2); + +#endif +/*__NPC_FMWARPMAN_H__*/ +003B:npc_freepetskillshop.h:01C4:1:14=48041e4b:16=47d21313: \ No newline at end of file diff --git a/include/npc_blackmarket.h b/include/npc_blackmarket.h new file mode 100644 index 0000000..2a3347a --- /dev/null +++ b/include/npc_blackmarket.h @@ -0,0 +1,346 @@ +0032:npc_bodylan.h:0166:1:14=48041e4b:16=47d21313:#ifndef __NPC_BODYLAN_H__ +#define __NPC_BODYLAN_H__ + +void NPC_BodyLanTalked( int meindex , int talkerindex , char *msg , + int color ); +BOOL NPC_BodyLanInit( int meindex ); +void NPC_BodyLanWatch( int meindex , int lookedindex); +void NPC_BodyLanWindowTalked( + int meindex, + int talkerindex, + int seqno, + int select, + char *data +); + +#endif +002E:npc_bus.h:016E:1:14=48041e4b:16=47d21313:#ifndef __NPC_BUS_H__ +#define __NPC_BUS_H__ + +BOOL NPC_BusInit( int meindex ); +void NPC_BusLoop( int meindex ); +void NPC_BusTalked( int meindex , int talkerindex , char *szMes , + int color ); +BOOL NPC_BusCheckAllowItem( int meindex, int charaindex, BOOL pickupmode); +BOOL NPC_BusCheckJoinParty( int meindex, int charaindex, BOOL msgflg); + +#endif + +0030:npc_charm.h:0156:1:14=48041e4b:16=47d21313:#ifndef __NPC_CHARM_H__ +#define __NPC_CHARM_H__ + +void NPC_CharmTalked( int meindex , int talkerindex , char *msg , + int color ); +BOOL NPC_CharmInit( int meindex ); +void NPC_CharmWindowTalked( int meindex, int talkerindex, int seqno, int select, char *data); +void NPC_CharmLooked( int meindex , int lookedindex); + +#endif + +0033:npc_checkman.h:0167:1:14=48041e4b:16=47d21313:#ifndef __NPC_CHECKMAN_H__ +#define __NPC_CHECKMAN_H__ + +void NPC_CheckManTalked( int meindex , int talkerindex , char *msg , + int color ); +BOOL NPC_CheckManInit( int meindex ); +void NPC_CheckManWindowTalked( int meindex, int talkerindex, int seqno, int select, char *data); +void NPC_CheckManLooked( int meindex , int lookedindex); + +#endif + +0031:npc_Dengon.h:0146:1:14=48041e4b:16=47d21313:#ifndef __NPC_DENGON_H__ +#define __NPC_DENGON_H__ +BOOL NPC_DengonInit( int meindex ); +//void NPC_DengonSpecialTalked( int index, int talker, char *msg, int color ); +void NPC_DengonLooked( int meindex, int lookedindex ); +void NPC_DengonWindowTalked( int index, int talker, + int seqno, int select, char *data); + +#endif + +002F:npc_door.h:0470:1:14=48041e4b:16=47d21313:#ifndef __NPC_DOOR_H__ +#define __NPC_DOOR_H__ + +BOOL NPC_DoorInit(int meindex ); +void NPC_DoorTalked( int meindex , int talkerindex , char *msg , int color ); +void NPC_DoorPreAttacked(int meindex , int attacker , float *dm); +void NPC_DoorPostOver( int meindex , int movedindex ); +void NPC_DoorOff( int meindex , int movedindex ); +void NPC_DoorWatch( int meindex, int moveindex, CHAR_ACTION act, + int x, int y, int dir, int* opt, int optlen ); +int NPC_DoorSearchByName( char *name ); +int NPC_DoorSearchByPosition( int fl , int x, int y ); +void NPC_DoorLooked( int meindex , int lookedindex ); +BOOL NPC_DoorRefreshOverFlg( int meind ); + + +/* ְNPCճ۽ľãNPC年л npc_stepswitch.cëǷ */ +int NPC_DoorSetPasswd( int meindex, char *pas ); +int NPC_DoorGetPasswd( int meindex, char *out , int len ); +void NPC_DoorFlip(int meindex , int doindex); +void NPC_DoorClose(int meindex , int doindex); +void NPC_DoorOpen(int meindex , int doindex ); +void NPC_DoorAddSwitchCounter( int meindex , int i , int talker ); +void NPC_DoorSetSwitchCounter( int meindex, int i , int doindex ); + +#endif + + + + + +0031:npc_doorman.h:0CA:1:14=48041e4b:16=47d21313:#ifndef __NPC_DOORMAN_H__ +#define __NPC_DOORMAN_H__ + +BOOL NPC_DoormanInit( int meindex ); +void NPC_DoormanTalked( int meindex , int talkerindex , char *msg , + int color ); + +#endif + +0036:npc_duelranking.h:01AD:1:14=48041e4b:16=47d21313:#ifndef __NPC_DUELRANKING_H__ +#define __NPC_DUELRANKING_H__ + +BOOL NPC_DuelrankingInit( int meindex ); +void NPC_DuelrankingLooked( int meindex, int lookedindex ); +void NPC_DuelrankingWindowTalked( int meindex, int talkerindex, int seqno, int select, char *data); +void NPC_Duelranking_PrintRanking( char *data, int count_start, int fdid, int msgid2); +void NPC_Duelranking_CallMyRanking( int count, int msgid, int msgid2); + +#endif + +0037:npc_eventaction.h:01505:1:14=48041e4b:16=47d21313:#ifndef _PRO_NPCFIX_H +#define _PRO_NPCFIX_H +//ANDY_Edit +BOOL ActionNpc_CheckMenuFree( int meindex, int toindex, char *npcarg, int nums); +BOOL ActionNpc_CheckFree( int meindex, int toindex, char *npcarg); +BOOL Action_RunDoEventAction( int meindex, int toindex, char *buf1); +BOOL ActionNpc_WarpPoint(int meindex,int talker,char *npcarg); +BOOL Action_PartyCheck( int meindex, int talker); +BOOL NPC_ActionAddGold( int talker, int Golds); +BOOL NPC_ActionDelGold( int talker,char *buf); +BOOL NPC_ActionDelFame( int talker,char *buf); +BOOL NPC_ActionAddFame( int talker,char *buf); +#ifdef _MOMENTUM_NPC +BOOL NPC_ActionMomentum( int talker,char *buf); +#endif +#ifdef _DP_NPC +BOOL NPC_ActionDP( int talker,char *buf); +#endif +#ifdef _VIP_SHOP +BOOL NPC_ActionDelVipPoint( int talker,char *buf); +#endif +#ifdef _TRANS_7_NPC +BOOL NPC_ActionTrans7( int talker, char *buf); +BOOL NPC_ActionTransNew7( int talker, char *buf); +BOOL NPC_ActionTransNewSeven( int talker, char *buf); +#endif +// WON ADD +BOOL NPC_ActionAddGold2( int talker,char *buf); +BOOL NPC_ActionDelPet( int toindex,char *buf); +#ifdef _NPC_NewDelPet +BOOL NPC_ActionNewDelPet( int talker,char *msg); +#endif +BOOL NPC_ActionAddPet( int talker, char *buf); +BOOL NPC_ActionDelItem( int talker,char *buf); +BOOL NPC_ActionAddItem( int talker, char *buf); +BOOL NPC_ActionSetEend( int talkerindex, char * buf); +BOOL NPC_ActionSetNow( int toindex, char * buf); +BOOL NPC_ActionClearEvent( int toindex, char * buf); + +BOOL NPC_ActionCheckTrans(int meindex,int talker,int trans,int flg); +#ifdef _VIP_SHOP +BOOL NPC_ActionVipPointCheck(int meindex,int talker,int point,int flg); +#endif +#ifdef _VIP_RIDE +BOOL NPC_ActionVipCheck(int meindex,int talker,int vip,int flg); +#endif +#ifdef _VIP_SHOP +BOOL NPC_ActionNewVipPointCheck(int meindex,int talker,int point,int flg); +#endif +#ifdef _MOMENTUM_NPC +BOOL NPC_ActionMomentumCheck(int meindex,int talker,int Momentum,int flg); +#endif +#ifdef _DP_NPC +BOOL NPC_ActionDPCheck(int meindex,int talker,int DP,int flg); +#endif +BOOL NPC_ActionLevelCheck(int meindex,int talker,int level,int flg); + +#ifdef _PROFESSION_SKILL // WON ADD ְҵ +BOOL NPC_ActionClassCheck( int meindex,int talker,int p_class,int flg); + +BOOL NPC_ActionSkillCheck( int meindex,int talker,int skillId,int flg); +BOOL NPC_ActionSkillNumCheck( int meindex,int talker,int sknum,int flg); + +BOOL NPC_ActionSkillPointAndSkillCheck( int meindex,int talker,int sknum,int flg); + +BOOL NPC_ActionCheckSkup(int meindex,int talker,int skup,int flg); +BOOL NPC_ActionCheckSafe(int meindex,int talker,int safe,int flg); + +BOOL NPC_ActionCleanProfession( int toindex, char *buf); +BOOL NPC_ActionAddProfessionSkillPoint( int toindex, char *buf ); +#endif + +BOOL NPC_ActionGoldCheck(int meindex,int talker,int Golds,int flg); +BOOL NPC_ActionPartyCheck( int toindex, int nums, int flg); +BOOL NPC_ActionReItemCheck( int toindex, int nums, int flg); +BOOL NPC_ActionRePetCheck( int toindex, int nums, int flg); +BOOL ActionCheckMyPet( int meindex, int talker, int petLv, int flg, int petid); +BOOL NPC_ActionBigSmallLastCheck(int point1,int mypoint,int flg); + +BOOL NPC_ActionItemCheck(int meindex,int talker,int itemNo, int flg); +BOOL NPC_ActioneEquitCheck(int meindex,int talker,int itemNo, int flg); + +BOOL NPC_ActionFreeIfCheck(int meindex,int talker, char* buf, char *opt, int kosuu,int flg, int temp); + +BOOL NPC_ActionBigSmallCheck(int meindex,int talker,char* buf); +BOOL NPC_ActionPassCheck( int meindex, int talker, char *buf); +BOOL NPC_ActionWarpManReduce(int meindex,int talker,char *buf); +#ifdef _NPC_ActionFreeCmp +BOOL NPC_ActionWarpManReduce2(int meindex,int talker,char *buf); +#endif +#ifdef _NPCCHANGE_PLAYERIMG //andy +BOOL NPC_ActionChangePlayerBBI( int meindex, int charindex, char *Img); +BOOL NPC_CheckPlayerBBI( int meindex, int charindex, int BBI, int flg); +#endif + +BOOL showString( int meindex, char *showstr,int flg); +BOOL NPC_getTimeXYPoint( int meindex, int Mode); +BOOL NPC_getTimeData( int meindex, char *npcarg, int *born, int *dead, int loopspeed); +void NPC_TimeDefineDo( int meindex, int born, int dead, int typeMode); +BOOL NPC_CheckTimeDefine( char *timetype); + +void GetRand_WarpPoint( char *buf, int *fl, int *x, int *y ); +#ifdef _EMENY_CHANCEMAN +int NPC_EmenyChanceCheck( int meindex, int charaindex, char *arg); +int NPC_DischargePartyForSex( int meindex, int charaindex, int fl, int x, int y, int fsex); +#endif + +BOOL NPC_ActionDuelRankCheck(int meindex,int talker,int rank,int flg); +BOOL NPC_ActionDuelPointCheck(int meindex,int talker,int rank,int flg); + +#ifdef _TREASURE_BOX +BOOL NPC_ActionTreasureTypeCheck( int meindex, int level, int type, int flg); +#endif +BOOL NPC_ActionTreasureRandItemGet(int meidex,int talker,int rand_j,char *buf); +void NPC_ActionLevelAndTransUp( int meindex, int charindex, int level, + int skillpoint, int exp, int ridepet); +#ifdef _ITEM_PILENUMS +BOOL NPC_ActionDoPileDelItem( int toindex, int itemID, int num); +BOOL NPC_DelItem( int toindex, int ti, int num); +#endif +void NPC_ActionDoPileClearItem( int toindex, int itemID); + + +#ifdef _PROFESSION_SKILL // WON ADD ְҵ +int PROFESSION_RESTORE_POINT( int charaindex ); +#endif + + +#ifdef _NPC_ADDWARPMAN1 +BOOL NPC_ActionPartyCountCheck( int toindex, int nums, int flg); +BOOL NPC_ActionManCountCheck( int toindex, int nums, int flg);// +BOOL NPC_ActionWomanCountCheck( int toindex, int nums, int flg);//Ů +#endif + +#endif +0036:npc_exchangeman.h:0235:1:14=48041e4b:16=47d21313:#ifndef __NPC_EXCHANGEMAN_H__ +#define __NPC_EXCHANGEMAN_H__ + +void NPC_ExChangeManTalked( int meindex , int talkerindex , char *msg , + int color ); +BOOL NPC_ExChangeManInit( int meindex ); +void NPC_ExChangeManWindowTalked( int meindex, int talkerindex, int seqno, int select, char *data); + + + +BOOL NPC_EventCheckFlg( int talker, int shiftbit); +BOOL NPC_NowEventCheckFlg( int talker, int shiftbit); + +// Arminius 8.14 move from .c (for pet talk) +BOOL NPC_EventBigSmallCheck(int meindex,int talker,char* buf); + +#endif + + + /*__NPC_EXCHANGEMAN_H__*/ + + +0034:npc_familyman.h:0187:1:14=48041e4b:16=47d21313:#ifndef __NPC_FAMILYMAN_H__ +#define __NPC_FAMILYMAN_H__ + +void NPC_FamilymanTalked( int meindex , int talkerindex , char *msg , + int color ); + +BOOL NPC_FamilymanInit( int meindex ); +void NPC_FamilymanLooked( int meindex, int lookedindex ); +void NPC_FamilymanWindowTalked( int meindex, int talkerindex, int seqno, int select, char *data); + +#endif + +/*__NPC_FAMILYMAN_H__*/ +0033:npc_fmdengon.h:0111:1:14=48041e4b:16=47d21313:#ifndef __NPC_FMDENGON_H__ +#define __NPC_FMDENGON_H__ + +BOOL NPC_FmDengonInit( int meindex ); +void NPC_FmDengonLooked( int meindex, int lookedindex ); +void NPC_FmDengonWindowTalked( int index, int talker, int seqno, int select, char *data); + +#endif + +/*__NPC_FMDENGON_H__*/ +0032:npc_fmhealer.h:0E4:1:14=48041e4b:16=47d21313:#ifndef __NPC_FMHEALER_H__ +#define __NPC_FMHEALER_H__ + +void NPC_FmHealerTalked( int meindex , int talkerindex , char *msg , + int color ); +BOOL NPC_FmHealerInit( int meindex ); + +#endif +/*__NPC_FMHEALER_H__*/ +0033:npc_fmletter.h:0180:1:14=48041e4b:16=47d21313:#ifndef __NPC_FMLETTER_H__ +#define __NPC_FMLETTER_H__ + +void NPC_FmLetterTalked( int meindex , int talkerindex , char *msg , + int color ); + +BOOL NPC_FmLetterInit( int meindex ); +void NPC_FmLetterLooked( int meindex, int lookedindex ); +void NPC_FmLetterWindowTalked( int meindex, int talkerindex, int seqno, int select, char *data); + +#endif + +/*__NPC_FMLETTER_H__*/ +0036:npc_fmpkcallman.h:013B:1:14=48041e4b:16=47d21313:#ifndef __NPC_FMPKCALLMAN_H__ +#define __NPC_FMPKCALLMAN_H__ + +void NPC_FMPKCallManTalked(int meindex, int talkerindex, char *msg, int color); +BOOL NPC_FMPKCallManInit(int meindex); +void NPC_FMPKCallManWindowTalked(int meindex, int talkerindex, int seqno, + int select, char *data); + +#endif +/*__NPC_FMPKCALLMAN_H__*/ +0032:npc_fmpkman.h:0123:1:14=48041e4b:16=47d21313:#ifndef __NPC_FMPKMAN_H__ +#define __NPC_FMPKMAN_H__ + +void NPC_FMPKManTalked(int meindex, int talkerindex, char *msg, int color); +BOOL NPC_FMPKManInit(int meindex); +void NPC_FMPKManWindowTalked(int meindex, int talkerindex, int seqno, + int select, char *data); + +#endif +/*__NPC_FMPKMAN_H__*/ +0034:npc_fmwarpman.h:01A6:1:14=48041e4b:16=47d21313:#ifndef __NPC_FMWARPMAN_H__ +#define __NPC_FMWARPMAN_H__ + +void NPC_FMWarpManTalked(int meindex, int talkerindex, char *msg, int color); +BOOL NPC_FMWarpManInit(int meindex); +void NPC_FMWarpManWindowTalked(int meindex, int talkerindex, int seqno, + int select, char *data); +void NPC_FMWarpManLoop(int meindex); +void NPC_GetPKFMNum(int floor, int fmindex1, int fmindex2, int *num1, int *num2); + +#endif +/*__NPC_FMWARPMAN_H__*/ +003B:npc_freepetskillshop.h:01C4:1:14=48041e4b:16=47d21313: \ No newline at end of file diff --git a/include/npc_bodylan.h b/include/npc_bodylan.h new file mode 100644 index 0000000..57f2e30 --- /dev/null +++ b/include/npc_bodylan.h @@ -0,0 +1,16 @@ +#ifndef __NPC_BODYLAN_H__ +#define __NPC_BODYLAN_H__ + +void NPC_BodyLanTalked( int meindex , int talkerindex , char *msg , + int color ); +BOOL NPC_BodyLanInit( int meindex ); +void NPC_BodyLanWatch( int meindex , int lookedindex); +void NPC_BodyLanWindowTalked( + int meindex, + int talkerindex, + int seqno, + int select, + char *data +); + +#endif diff --git a/include/npc_bus.h b/include/npc_bus.h new file mode 100644 index 0000000..98d5d6a --- /dev/null +++ b/include/npc_bus.h @@ -0,0 +1,12 @@ +#ifndef __NPC_BUS_H__ +#define __NPC_BUS_H__ + +BOOL NPC_BusInit( int meindex ); +void NPC_BusLoop( int meindex ); +void NPC_BusTalked( int meindex , int talkerindex , char *szMes , + int color ); +BOOL NPC_BusCheckAllowItem( int meindex, int charaindex, BOOL pickupmode); +BOOL NPC_BusCheckJoinParty( int meindex, int charaindex, BOOL msgflg); + +#endif + diff --git a/include/npc_charm.h b/include/npc_charm.h new file mode 100644 index 0000000..73785a7 --- /dev/null +++ b/include/npc_charm.h @@ -0,0 +1,11 @@ +#ifndef __NPC_CHARM_H__ +#define __NPC_CHARM_H__ + +void NPC_CharmTalked( int meindex , int talkerindex , char *msg , + int color ); +BOOL NPC_CharmInit( int meindex ); +void NPC_CharmWindowTalked( int meindex, int talkerindex, int seqno, int select, char *data); +void NPC_CharmLooked( int meindex , int lookedindex); + +#endif + diff --git a/include/npc_checkman.h b/include/npc_checkman.h new file mode 100644 index 0000000..77fbf31 --- /dev/null +++ b/include/npc_checkman.h @@ -0,0 +1,11 @@ +#ifndef __NPC_CHECKMAN_H__ +#define __NPC_CHECKMAN_H__ + +void NPC_CheckManTalked( int meindex , int talkerindex , char *msg , + int color ); +BOOL NPC_CheckManInit( int meindex ); +void NPC_CheckManWindowTalked( int meindex, int talkerindex, int seqno, int select, char *data); +void NPC_CheckManLooked( int meindex , int lookedindex); + +#endif + diff --git a/include/npc_door.h b/include/npc_door.h new file mode 100644 index 0000000..003c71a --- /dev/null +++ b/include/npc_door.h @@ -0,0 +1,31 @@ +#ifndef __NPC_DOOR_H__ +#define __NPC_DOOR_H__ + +BOOL NPC_DoorInit(int meindex ); +void NPC_DoorTalked( int meindex , int talkerindex , char *msg , int color ); +void NPC_DoorPreAttacked(int meindex , int attacker , float *dm); +void NPC_DoorPostOver( int meindex , int movedindex ); +void NPC_DoorOff( int meindex , int movedindex ); +void NPC_DoorWatch( int meindex, int moveindex, CHAR_ACTION act, + int x, int y, int dir, int* opt, int optlen ); +int NPC_DoorSearchByName( char *name ); +int NPC_DoorSearchByPosition( int fl , int x, int y ); +void NPC_DoorLooked( int meindex , int lookedindex ); +BOOL NPC_DoorRefreshOverFlg( int meind ); + + +/* ְNPCճ۽ľãNPC年л npc_stepswitch.cëǷ */ +int NPC_DoorSetPasswd( int meindex, char *pas ); +int NPC_DoorGetPasswd( int meindex, char *out , int len ); +void NPC_DoorFlip(int meindex , int doindex); +void NPC_DoorClose(int meindex , int doindex); +void NPC_DoorOpen(int meindex , int doindex ); +void NPC_DoorAddSwitchCounter( int meindex , int i , int talker ); +void NPC_DoorSetSwitchCounter( int meindex, int i , int doindex ); + +#endif + + + + + diff --git a/include/npc_doorman.h b/include/npc_doorman.h new file mode 100644 index 0000000..52e32de --- /dev/null +++ b/include/npc_doorman.h @@ -0,0 +1,9 @@ +#ifndef __NPC_DOORMAN_H__ +#define __NPC_DOORMAN_H__ + +BOOL NPC_DoormanInit( int meindex ); +void NPC_DoormanTalked( int meindex , int talkerindex , char *msg , + int color ); + +#endif + diff --git a/include/npc_duelranking.h b/include/npc_duelranking.h new file mode 100644 index 0000000..74dbe35 --- /dev/null +++ b/include/npc_duelranking.h @@ -0,0 +1,11 @@ +#ifndef __NPC_DUELRANKING_H__ +#define __NPC_DUELRANKING_H__ + +BOOL NPC_DuelrankingInit( int meindex ); +void NPC_DuelrankingLooked( int meindex, int lookedindex ); +void NPC_DuelrankingWindowTalked( int meindex, int talkerindex, int seqno, int select, char *data); +void NPC_Duelranking_PrintRanking( char *data, int count_start, int fdid, int msgid2); +void NPC_Duelranking_CallMyRanking( int count, int msgid, int msgid2); + +#endif + diff --git a/include/npc_eventaction.h b/include/npc_eventaction.h new file mode 100644 index 0000000..4f264bd --- /dev/null +++ b/include/npc_eventaction.h @@ -0,0 +1,137 @@ +#ifndef _PRO_NPCFIX_H +#define _PRO_NPCFIX_H +//ANDY_Edit +BOOL ActionNpc_CheckMenuFree( int meindex, int toindex, char *npcarg, int nums); +BOOL ActionNpc_CheckFree( int meindex, int toindex, char *npcarg); +BOOL Action_RunDoEventAction( int meindex, int toindex, char *buf1); +BOOL ActionNpc_WarpPoint(int meindex,int talker,char *npcarg); +BOOL Action_PartyCheck( int meindex, int talker); +BOOL NPC_ActionAddGold( int talker, int Golds); +BOOL NPC_ActionDelGold( int talker,char *buf); +BOOL NPC_ActionDelFame( int talker,char *buf); +BOOL NPC_ActionAddFame( int talker,char *buf); +#ifdef _MOMENTUM_NPC +BOOL NPC_ActionMomentum( int talker,char *buf); +#endif +#ifdef _DP_NPC +BOOL NPC_ActionDP( int talker,char *buf); +#endif +#ifdef _VIP_SHOP +BOOL NPC_ActionDelVipPoint( int talker,char *buf); +#endif +#ifdef _TRANS_7_NPC +BOOL NPC_ActionTrans7( int talker, char *buf); +BOOL NPC_ActionTransNew7( int talker, char *buf); +BOOL NPC_ActionTransNewSeven( int talker, char *buf); +#endif +// WON ADD +BOOL NPC_ActionAddGold2( int talker,char *buf); +BOOL NPC_ActionDelPet( int toindex,char *buf); +#ifdef _NPC_NewDelPet +BOOL NPC_ActionNewDelPet( int talker,char *msg); +#endif +BOOL NPC_ActionAddPet( int talker, char *buf); +BOOL NPC_ActionDelItem( int talker,char *buf); +BOOL NPC_ActionAddItem( int talker, char *buf); +BOOL NPC_ActionSetEend( int talkerindex, char * buf); +BOOL NPC_ActionSetNow( int toindex, char * buf); +BOOL NPC_ActionClearEvent( int toindex, char * buf); + +BOOL NPC_ActionCheckTrans(int meindex,int talker,int trans,int flg); +#ifdef _VIP_SHOP +BOOL NPC_ActionVipPointCheck(int meindex,int talker,int point,int flg); +#endif +#ifdef _VIP_RIDE +BOOL NPC_ActionVipCheck(int meindex,int talker,int vip,int flg); +#endif +#ifdef _VIP_SHOP +BOOL NPC_ActionNewVipPointCheck(int meindex,int talker,int point,int flg); +#endif +#ifdef _MOMENTUM_NPC +BOOL NPC_ActionMomentumCheck(int meindex,int talker,int Momentum,int flg); +#endif +#ifdef _DP_NPC +BOOL NPC_ActionDPCheck(int meindex,int talker,int DP,int flg); +#endif +BOOL NPC_ActionLevelCheck(int meindex,int talker,int level,int flg); + +#ifdef _PROFESSION_SKILL // WON ADD ְҵ +BOOL NPC_ActionClassCheck( int meindex,int talker,int p_class,int flg); + +BOOL NPC_ActionSkillCheck( int meindex,int talker,int skillId,int flg); +BOOL NPC_ActionSkillNumCheck( int meindex,int talker,int sknum,int flg); + +BOOL NPC_ActionSkillPointAndSkillCheck( int meindex,int talker,int sknum,int flg); + +BOOL NPC_ActionCheckSkup(int meindex,int talker,int skup,int flg); +BOOL NPC_ActionCheckSafe(int meindex,int talker,int safe,int flg); + +BOOL NPC_ActionCleanProfession( int toindex, char *buf); +BOOL NPC_ActionAddProfessionSkillPoint( int toindex, char *buf ); +#endif + +BOOL NPC_ActionGoldCheck(int meindex,int talker,int Golds,int flg); +BOOL NPC_ActionPartyCheck( int toindex, int nums, int flg); +BOOL NPC_ActionReItemCheck( int toindex, int nums, int flg); +BOOL NPC_ActionRePetCheck( int toindex, int nums, int flg); +BOOL ActionCheckMyPet( int meindex, int talker, int petLv, int flg, int petid); +BOOL NPC_ActionBigSmallLastCheck(int point1,int mypoint,int flg); + +BOOL NPC_ActionItemCheck(int meindex,int talker,int itemNo, int flg); +BOOL NPC_ActioneEquitCheck(int meindex,int talker,int itemNo, int flg); + +BOOL NPC_ActionFreeIfCheck(int meindex,int talker, char* buf, char *opt, int kosuu,int flg, int temp); + +BOOL NPC_ActionBigSmallCheck(int meindex,int talker,char* buf); +BOOL NPC_ActionPassCheck( int meindex, int talker, char *buf); +BOOL NPC_ActionWarpManReduce(int meindex,int talker,char *buf); +#ifdef _NPC_ActionFreeCmp +BOOL NPC_ActionWarpManReduce2(int meindex,int talker,char *buf); +#endif +#ifdef _NPCCHANGE_PLAYERIMG //andy +BOOL NPC_ActionChangePlayerBBI( int meindex, int charindex, char *Img); +BOOL NPC_CheckPlayerBBI( int meindex, int charindex, int BBI, int flg); +#endif + +BOOL showString( int meindex, char *showstr,int flg); +BOOL NPC_getTimeXYPoint( int meindex, int Mode); +BOOL NPC_getTimeData( int meindex, char *npcarg, int *born, int *dead, int loopspeed); +void NPC_TimeDefineDo( int meindex, int born, int dead, int typeMode); +BOOL NPC_CheckTimeDefine( char *timetype); + +void GetRand_WarpPoint( char *buf, int *fl, int *x, int *y ); +#ifdef _EMENY_CHANCEMAN +int NPC_EmenyChanceCheck( int meindex, int charaindex, char *arg); +int NPC_DischargePartyForSex( int meindex, int charaindex, int fl, int x, int y, int fsex); +#endif + +BOOL NPC_ActionDuelRankCheck(int meindex,int talker,int rank,int flg); +BOOL NPC_ActionDuelPointCheck(int meindex,int talker,int rank,int flg); + +#ifdef _TREASURE_BOX +BOOL NPC_ActionTreasureTypeCheck( int meindex, int level, int type, int flg); +#endif +BOOL NPC_ActionTreasureRandItemGet(int meidex,int talker,int rand_j,char *buf); +void NPC_ActionLevelAndTransUp( int meindex, int charindex, int level, + int skillpoint, int exp, int ridepet); +#ifdef _ITEM_PILENUMS +BOOL NPC_ActionDoPileDelItem( int toindex, int itemID, int num); +BOOL NPC_DelItem( int toindex, int ti, int num); +#endif +void NPC_ActionDoPileClearItem( int toindex, int itemID); + + +#ifdef _PROFESSION_SKILL // WON ADD ְҵ +int PROFESSION_RESTORE_POINT( int charaindex ); +#endif + + +#ifdef _NPC_ADDWARPMAN1 +BOOL NPC_ActionPartyCountCheck( int toindex, int nums, int flg); +BOOL NPC_ActionManCountCheck( int toindex, int nums, int flg);// +BOOL NPC_ActionWomanCountCheck( int toindex, int nums, int flg);//Ů +#endif + +BOOL NPC_ActionWarpNpc(int meindex,char *buf); + +#endif diff --git a/include/npc_exchangeman.h b/include/npc_exchangeman.h new file mode 100644 index 0000000..b3faa4a --- /dev/null +++ b/include/npc_exchangeman.h @@ -0,0 +1,22 @@ +#ifndef __NPC_EXCHANGEMAN_H__ +#define __NPC_EXCHANGEMAN_H__ +BOOL NPC_TypeCheck(int meindex,int talker,char *szMes); +void NPC_ExChangeManTalked( int meindex , int talkerindex , char *msg , + int color ); +BOOL NPC_ExChangeManInit( int meindex ); +void NPC_ExChangeManWindowTalked( int meindex, int talkerindex, int seqno, int select, char *data); + + + +BOOL NPC_EventCheckFlg( int talker, int shiftbit); +BOOL NPC_NowEventCheckFlg( int talker, int shiftbit); + +// Arminius 8.14 move from .c (for pet talk) +BOOL NPC_EventBigSmallCheck(int meindex,int talker,char* buf); + +#endif + + + /*__NPC_EXCHANGEMAN_H__*/ + + diff --git a/include/npc_familyman.h b/include/npc_familyman.h new file mode 100644 index 0000000..57e08d4 --- /dev/null +++ b/include/npc_familyman.h @@ -0,0 +1,13 @@ +#ifndef __NPC_FAMILYMAN_H__ +#define __NPC_FAMILYMAN_H__ + +void NPC_FamilymanTalked( int meindex , int talkerindex , char *msg , + int color ); + +BOOL NPC_FamilymanInit( int meindex ); +void NPC_FamilymanLooked( int meindex, int lookedindex ); +void NPC_FamilymanWindowTalked( int meindex, int talkerindex, int seqno, int select, char *data); + +#endif + +/*__NPC_FAMILYMAN_H__*/ diff --git a/include/npc_fmdengon.h b/include/npc_fmdengon.h new file mode 100644 index 0000000..858f170 --- /dev/null +++ b/include/npc_fmdengon.h @@ -0,0 +1,10 @@ +#ifndef __NPC_FMDENGON_H__ +#define __NPC_FMDENGON_H__ + +BOOL NPC_FmDengonInit( int meindex ); +void NPC_FmDengonLooked( int meindex, int lookedindex ); +void NPC_FmDengonWindowTalked( int index, int talker, int seqno, int select, char *data); + +#endif + +/*__NPC_FMDENGON_H__*/ diff --git a/include/npc_fmhealer.h b/include/npc_fmhealer.h new file mode 100644 index 0000000..2c62fce --- /dev/null +++ b/include/npc_fmhealer.h @@ -0,0 +1,9 @@ +#ifndef __NPC_FMHEALER_H__ +#define __NPC_FMHEALER_H__ + +void NPC_FmHealerTalked( int meindex , int talkerindex , char *msg , + int color ); +BOOL NPC_FmHealerInit( int meindex ); + +#endif +/*__NPC_FMHEALER_H__*/ diff --git a/include/npc_fmletter.h b/include/npc_fmletter.h new file mode 100644 index 0000000..f60aef5 --- /dev/null +++ b/include/npc_fmletter.h @@ -0,0 +1,13 @@ +#ifndef __NPC_FMLETTER_H__ +#define __NPC_FMLETTER_H__ + +void NPC_FmLetterTalked( int meindex , int talkerindex , char *msg , + int color ); + +BOOL NPC_FmLetterInit( int meindex ); +void NPC_FmLetterLooked( int meindex, int lookedindex ); +void NPC_FmLetterWindowTalked( int meindex, int talkerindex, int seqno, int select, char *data); + +#endif + +/*__NPC_FMLETTER_H__*/ diff --git a/include/npc_fmlookwar.h b/include/npc_fmlookwar.h new file mode 100644 index 0000000..2a7f8a5 --- /dev/null +++ b/include/npc_fmlookwar.h @@ -0,0 +1,6 @@ +#ifdef _FM_NPC_LOOK_WAR +void NPC_FmLookWarManTalked( int meindex, int talkerindex, char *msg, int color ); +BOOL NPC_FmLookWarManInit( int meindex ); +void NPC_FmLookWarManWindowTalked( int meindex, int talkerindex, int seqno, int select, char *data); +void NPC_FmLookWarManLoop( int meindex); +#endif diff --git a/include/npc_fmlookwar1.h b/include/npc_fmlookwar1.h new file mode 100644 index 0000000..35f1142 --- /dev/null +++ b/include/npc_fmlookwar1.h @@ -0,0 +1,6 @@ +#ifdef _FM_NPC_LOOK_WAR1 +void NPC_FmLookWarMan1Talked( int meindex, int talkerindex, char *msg, int color ); +BOOL NPC_FmLookWarMan1Init( int meindex ); +void NPC_FmLookWarMan1WindowTalked( int meindex, int talkerindex, int seqno, int select, char *data); +void NPC_FmLookWarMan1Loop( int meindex); +#endif diff --git a/include/npc_fmpkcallman.h b/include/npc_fmpkcallman.h new file mode 100644 index 0000000..8702b1c --- /dev/null +++ b/include/npc_fmpkcallman.h @@ -0,0 +1,10 @@ +#ifndef __NPC_FMPKCALLMAN_H__ +#define __NPC_FMPKCALLMAN_H__ + +void NPC_FMPKCallManTalked(int meindex, int talkerindex, char *msg, int color); +BOOL NPC_FMPKCallManInit(int meindex); +void NPC_FMPKCallManWindowTalked(int meindex, int talkerindex, int seqno, + int select, char *data); + +#endif +/*__NPC_FMPKCALLMAN_H__*/ diff --git a/include/npc_fmpkman.h b/include/npc_fmpkman.h new file mode 100644 index 0000000..2053f02 --- /dev/null +++ b/include/npc_fmpkman.h @@ -0,0 +1,10 @@ +#ifndef __NPC_FMPKMAN_H__ +#define __NPC_FMPKMAN_H__ + +void NPC_FMPKManTalked(int meindex, int talkerindex, char *msg, int color); +BOOL NPC_FMPKManInit(int meindex); +void NPC_FMPKManWindowTalked(int meindex, int talkerindex, int seqno, + int select, char *data); + +#endif +/*__NPC_FMPKMAN_H__*/ diff --git a/include/npc_fmrank.h b/include/npc_fmrank.h new file mode 100644 index 0000000..7af32fc --- /dev/null +++ b/include/npc_fmrank.h @@ -0,0 +1,4 @@ +void NPC_FmRankTalked( int meindex, int talkerindex, char *msg, int color ); +BOOL NPC_FmRankInit( int meindex ); +void NPC_FmRankWindowTalked( int meindex, int talkerindex, int seqno, int select, char *data); +void NPC_FmRankLoop( void ); diff --git a/include/npc_fmwarpman.h b/include/npc_fmwarpman.h new file mode 100644 index 0000000..5b8e4ac --- /dev/null +++ b/include/npc_fmwarpman.h @@ -0,0 +1,12 @@ +#ifndef __NPC_FMWARPMAN_H__ +#define __NPC_FMWARPMAN_H__ + +void NPC_FMWarpManTalked(int meindex, int talkerindex, char *msg, int color); +BOOL NPC_FMWarpManInit(int meindex); +void NPC_FMWarpManWindowTalked(int meindex, int talkerindex, int seqno, + int select, char *data); +void NPC_FMWarpManLoop(int meindex); +void NPC_GetPKFMNum(int floor, int fmindex1, int fmindex2, int *num1, int *num2); + +#endif +/*__NPC_FMWARPMAN_H__*/ diff --git a/include/npc_freepetskillshop.h b/include/npc_freepetskillshop.h new file mode 100644 index 0000000..73bc822 --- /dev/null +++ b/include/npc_freepetskillshop.h @@ -0,0 +1,10 @@ +#ifndef __NPC_FREEPETSKILLSHOP_H__ +#define __NPC_FREEPETSKILLSHOP_H__ + +BOOL NPC_FreePetSkillShopInit( int meindex ); +void NPC_FreePetSkillShopTalked( int meindex , int talkerindex , char *msg , int color ); +void NPC_FreePetSkillShopWindowTalked( int meindex, int talkerindex, int seqno, int select, char *data); +//void NPC_PetSkillShopLooked( int meindex , int lookedindex); +BOOL NPC_CHECKFREEPETSKILL( int toindex, int petindex, int skillID); +#endif + diff --git a/include/npc_gamblebank.h b/include/npc_gamblebank.h new file mode 100644 index 0000000..017f2c1 --- /dev/null +++ b/include/npc_gamblebank.h @@ -0,0 +1,9 @@ +#ifndef __NPC_GAMBLEBANK_H__ +#define __NPC_GAMBLEBANK_H__ +BOOL NPC_GambleBankInit( int meindex ); +void NPC_GambleBankLoop( int meindex); +void NPC_GambleBankTalked( int meindex , int talkerindex , char *msg , int color ); +void NPC_GambleBankWindowTalked( int meindex, int talkerindex, int seqno, int select, char *data); +#endif + + diff --git a/include/npc_gamblemaster.h b/include/npc_gamblemaster.h new file mode 100644 index 0000000..9c28474 --- /dev/null +++ b/include/npc_gamblemaster.h @@ -0,0 +1,9 @@ +#ifndef NPC_Gamble_Master_ +#define NPC_Gamble_Master_ + +BOOL NPC_Gamble_MasterInit( int meindex ); +void NPC_Gamble_MasterLoop( int meindex ); +void NPC_Gamble_MasterWindowTalked( int meindex, int talkerindex, int seqno, int select, char *data); +void NPC_Gamble_MasterTalked( int meindex , int talkerindex , char *szMes , int color ); +#endif + diff --git a/include/npc_gambleroulette.h b/include/npc_gambleroulette.h new file mode 100644 index 0000000..0dacc59 --- /dev/null +++ b/include/npc_gambleroulette.h @@ -0,0 +1,9 @@ +#ifndef NPC_Gamble_Roulette_ +#define NPC_Gamble_Roulette_ + +BOOL NPC_Gamble_RouletteInit( int meindex ); +void NPC_Gamble_RouletteLoop( int meindex ); +void NPC_Gamble_RouletteWindowTalked( int meindex, int talkerindex, int seqno, int select, char *data); +void NPC_Gamble_RouletteTalked( int meindex , int talkerindex , char *szMes , int color ); +#endif + diff --git a/include/npc_healer.h b/include/npc_healer.h new file mode 100644 index 0000000..70ff815 --- /dev/null +++ b/include/npc_healer.h @@ -0,0 +1,10 @@ +#ifndef __NPC_HEALER_H__ +#define __NPC_HEALER_H__ + +void NPC_HealerTalked( int meindex , int talkerindex , char *msg , + int color ); + +BOOL NPC_HealerInit( int meindex ); + +#endif + /*__NPC_HEALER_H__*/ diff --git a/include/npc_itemchange.h b/include/npc_itemchange.h new file mode 100644 index 0000000..63ac849 --- /dev/null +++ b/include/npc_itemchange.h @@ -0,0 +1,12 @@ +#ifndef _ITEM_CHANGE_ +#define _ITEM_CHANGE_ + +//#ifdef _CFREE_petskill +BOOL NPC_ItemchangeManInit( int meindex ); +void NPC_ItemchangeManTalked( int meindex, int talkerindex, char *msg, int color ); +void NPC_ItemchangeManWindowTalked( int meindex, int talkerindex, int seqno, + int select, char *data); +void NPC_ItemchangeManLoop( int meindex); + +#endif + diff --git a/include/npc_itemshop.h b/include/npc_itemshop.h new file mode 100644 index 0000000..f6d757b --- /dev/null +++ b/include/npc_itemshop.h @@ -0,0 +1,12 @@ +#ifndef __NPC_ITEMSHOP_H__ +#define __NPC_ITEMSHOP_H__ + +void NPC_ItemShopTalked( int meindex , int talkerindex , char *msg , + int color ); +BOOL NPC_ItemShopInit( int meindex ); +void NPC_ItemShopWindowTalked( int meindex, int talkerindex, int seqno, int select, char *data); +void NPC_ItemShopLooked( int meindex , int lookedindex); + + +#endif + /*__NPC_ITEMSHOP_H__*/ diff --git a/include/npc_itemup.h b/include/npc_itemup.h new file mode 100644 index 0000000..4309579 --- /dev/null +++ b/include/npc_itemup.h @@ -0,0 +1,7 @@ +BOOL NPC_ItemupManInit( int meindex ); +void NPC_ItemupManTalked( int meindex, int talkerindex, char *msg, int color ); +void NPC_ItemupManWindowTalked( int meindex, int talkerindex, int seqno, + int select, char *data); +void NPC_ItemupManLoop( int meindex); + + diff --git a/include/npc_itemvippointshop.h b/include/npc_itemvippointshop.h new file mode 100644 index 0000000..9312879 --- /dev/null +++ b/include/npc_itemvippointshop.h @@ -0,0 +1,10 @@ + + +void NPC_ItemVippointShopTalked( int meindex , int talkerindex , char *msg , + int color ); +BOOL NPC_ItemVippointShopInit( int meindex ); +void NPC_ItemVippointShopWindowTalked( int meindex, int talkerindex, int seqno, int select, char *data); +void NPC_ItemVippointShopLooked( int meindex , int lookedindex); + + + /*__NPC_ITEMSHOP_H__*/ diff --git a/include/npc_janken.h b/include/npc_janken.h new file mode 100644 index 0000000..411abb8 --- /dev/null +++ b/include/npc_janken.h @@ -0,0 +1,10 @@ +#ifndef __NPC_JANKEN_H__ +#define __NPC_JANKEN_H__ + +void NPC_JankenTalked( int meindex , int talkerindex , char *msg , + int color ); +BOOL NPC_JankenInit( int meindex ); +void NPC_JankenWindowTalked( int meindex, int talkerindex, int seqno, int select, char *data); + +#endif + /*__NPC_JANKEN_H__*/ diff --git a/include/npc_lua.h b/include/npc_lua.h new file mode 100644 index 0000000..ce22cae --- /dev/null +++ b/include/npc_lua.h @@ -0,0 +1,516 @@ +#ifndef __NPC_LUA__ +#define __NPC_LUA__ + +#include "npc_lua_interface.h" +#include "../lua/lua.h" +#include "../lua/lauxlib.h" +#include +#include +#include +#include + +#define LUA_DATALINE0 0 +#define LUA_DATALINE1 2000 +#define LUA_DATALINE2 4000 +#define LUA_DATALINE3 6000 +#define LUA_DATALINE4 8000 +#define LUA_DATALINE5 10000 + +typedef struct __CREATEENEMY +{ + int EnemyId; + int BaseLevel; + int SkillType; +}CREATEENEMY,*PCREATEENEMY; + +typedef struct __SCRIPTREGLIB +{ + const char *LibName; // + luaL_reg *FuncRegList; //Ҫעĺ⺯б +}SCRIPTREGLIB,*PSCRIPTREGLIB; + +typedef struct __SCRIPTREGCLASS +{ + const char *ClassName; // + PSCRIPTREGLIB NewLib; //ʵ SCRIPTREGLIB + luaL_reg *FuncRegList; //Ҫעຯб +}SCRIPTREGCLASS,*PSCRIPTREGCLASS; + +typedef struct __SCRIPTREGARRAY +{ + const char *ArrayName; // + const char **SetMetaTable; //Ӧ + const char **SetFuncName; //Ӧĺ + PSCRIPTREGLIB FuncList; //ӦӦ SetMetaTable Ĵб +}SCRIPTREGARRAY,*PSCRIPTREGARRAY; + +typedef struct __ARRAY_NTINT +{ + size_t Size; + int Num[1]; +}ARRAY_NTINT,*PARRAY_NTINT; + +//NPC-NPCΨһ +int NPC_Lua_Create(const char *_DoFile, const char *_InitFuncName, char *_seek, BOOL _IsFly); + +//ɾNPC NPCΨһ +int NPC_Lua_Del(int _index); + +//ս +int NPC_Lua_CreateVsEnemy(lua_State *_NLL, int _CharaIndex, int _NpcIndex, const char *_DoFunc, PCREATEENEMY _CreateEnemy, int _ARLen, int _Flg); + +const char *NPC_Lua_SetErrorStr(const char *ErrStr); + +//עչýӿ +int NPC_Lua_RegCallEx(lua_State * _NLL, luaL_Reg *_RegList); +//עչӿ +int NPC_Lua_RegLibEx(lua_State * _NLL, PSCRIPTREGLIB _RegLib); +//עչӿ +int NPC_Lua_RegClassEx(lua_State * _NLL, PSCRIPTREGCLASS _RegClass); +//עչӿ +int NPC_Lua_RegArrayEx(lua_State * _NLL, PSCRIPTREGARRAY _RegArray); + +//չͽӿں +//NTInt +int NPC_Lua_NTInt_New(lua_State *_NLL); +int NPC_Lua_NTInt_Get(lua_State *_NLL); +int NPC_Lua_NTInt_Set(lua_State *_NLL); +int NPC_Lua_NTInt_Len(lua_State *_NLL); + +//ӿں +////////////////////////////////////////////////NL///////////////////////////////////////////////// +int NPC_Lua_NL_GetErrorStr(lua_State *_NLL); //شϢ +int NPC_Lua_NL_CreateNpc(lua_State *_NLL); //NPC +int NPC_Lua_NL_DelNpc(lua_State *_NLL); //ɾNPC +int NPC_Lua_NL_Mod(lua_State *_NLL); // +int NPC_Lua_NL_GetStringFromIndexWithDelim(lua_State *_NLL); //ʹַַָָصָindexλõַ +//int NPC_Lua_NL_ANSI_PlayerLoop(lua_State *_NLL); //д +int NPC_Lua_NL_PetLoopGetNext(lua_State *_NLL); //дڳس дƶʱ +int NPC_Lua_NL_ItemLoopGetNext(lua_State *_NLL); //дڵߣص +int NPC_Lua_NL_PlayerLoopGetNext(lua_State *_NLL); //д +int NPC_Lua_NL_GetConfigLineType(lua_State *_NLL); //0ΪַΡ1ΪSHORTΡ2ΪINT͡3ΪDOUBLE͡ڸֶΣ-1. +int NPC_Lua_NL_GetConfigLineVal(lua_State *_NLL); //Ƿ[ַ]ҪתΪ֣tonumber()Ҳֶηnil +BOOL NPC_Lua_CheckNpcEventFree(lua_State *_NLL); //Ƿij +int NPC_Lua_DoNpcEventAction(lua_State *_NLL); //ִNPCű +int NPC_Lua_NL_SetTimer(lua_State *_NLL); //趨һʱĺ趨ļʱڵá +int NPC_Lua_NL_DelTimer(lua_State *_NLL); //ɾһʱһʱɾͲٱڵã +int NPC_Lua_NL_RunSaFuncII(lua_State *_NLL); //һڶõ2INTĺ +int NPC_Lua_NL_RunSaFuncIII(lua_State *_NLL); //һڶõ3INTĺ(ITEM_USEʹõߺĻص +int NPC_Lua_NL_ANSI_PlayerLoop(lua_State *_NLL); //д +int NPC_Lua_NL_ANSI_PetLoop(lua_State *_NLL); //дڳ +int NPC_Lua_NL_ANSI_ItemLoop(lua_State *_NLL); //дڵߣ +int NPC_Lua_NL_ClsMk(lua_State *_NLL); +int NPC_Lua_NL_AddCheckNum(lua_State *_NLL); +int NPC_Lua_NL_Mkstring(lua_State *_NLL); +int NPC_Lua_NL_Mkint(lua_State *_NLL); +int NPC_Lua_NL_SendMesg(lua_State *_NLL); + +////////////////////////////////////////////////NLG//////////////////////////////////////////////// +//ܽӿ +int NPC_Lua_NLG_UpItem(lua_State *_NLL); +int NPC_Lua_NLG_GiveItemOne(lua_State *_NLL); +int NPC_Lua_NLG_GivePetOne(lua_State *_NLL); +int NPC_Lua_NLG_DelItemByIndex(lua_State *_NLL); +int NPC_Lua_NLG_FindPet(lua_State *_NLL); //ҳλ +int NPC_Lua_NLG_GetMap(lua_State *_NLL); //õǰλõĽ +int NPC_Lua_NLG_PetUp(lua_State *_NLL); // +int NPC_Lua_NLG_AddSk(lua_State *_NLL); //ְҵ +int NPC_Lua_NLG_SetZy(lua_State *_NLL); //趨ְҵ +int NPC_Lua_Char_GetPlayerMaxNum(lua_State *_NLL); //ȡ +int NPC_Lua_NLG_GetXY(lua_State *_NLL); //ȡһͼ +int NPC_Lua_NLG_WalkJc(lua_State *_NLL); //ϰ +int NPC_Lua_NLG_KickPlayer(lua_State *_NLL); //Tָ +int NPC_Lua_NLG_HealOne(lua_State *_NLL); //ָһ ظHP MP +int NPC_Lua_NLG_HealAll(lua_State *_NLL); //ָһMP ظаHP +int NPC_Lua_NLG_LevelUpTo(lua_State *_NLL); //ĵȼ +int NPC_Lua_NLG_AddExp(lua_State *_NLL); //һ顣 +int NPC_Lua_NLG_UpPet(lua_State *_NLL); //¶ijڸ¡ͻˡݣijЩ̨Ա޸ĵ²ܰѸݷ͵ǰ̨ +int NPC_Lua_NLG_DelPetByPos(lua_State *_NLL); //ɾ ָλij +int NPC_Lua_NLG_DelPetByIndex(lua_State *_NLL); //ɾ ָţIDij +int NPC_Lua_NLG_GivePetByIndex(lua_State *_NLL); //һָֻŵijָ سλ +int NPC_Lua_NLG_GiveItemByIndex(lua_State *_NLL); //һindexָ صλ +int NPC_Lua_NLG_WarpToSpecificPoint(lua_State *_NLL); //ƶNPC ƶ +BOOL NPC_Lua_NLG_UpSkillupPoint(lua_State *_NLL); // +int NPC_Lua_NLG_StayEncount(lua_State *_NLL); //ԭ + +int NPC_Lua_NLG_CheckInFront(lua_State *_NLL); //ڼijǷijǰ +int NPC_Lua_NLG_CheckObj(lua_State *_NLL); //ijͼλǷж +int NPC_Lua_NLG_CharLook(lua_State *_NLL); //﷽(͸·) +int NPC_Lua_NLG_CreateBattle(lua_State *_NLL); //ս +int NPC_Lua_NLG_InputCard(lua_State *_NLL); //һԻ⿨ +int NPC_Lua_NLG_CreateBattlePvP(lua_State *_NLL); + +int NPC_Lua_NLG_SearchWatchBattleRandIndex(lua_State *_NLL); + +int NPC_Lua_NLG_DelPet(lua_State *_NLL); //ɾָҳһ +int NPC_Lua_NLG_DelHaveIndexPet(lua_State *_NLL); +int NPC_Lua_NLG_DelItem(lua_State *_NLL); //ɾָҵһ +int NPC_Lua_NLG_DelItemByPos(lua_State *_NLL); //ɾָҵһ +int NPC_Lua_NLG_DischargeParty(lua_State *_NLL); //ɢ Ŷ + +int NPC_Lua_NLG_GivePet(lua_State *_NLL); //ָһ +int NPC_Lua_NLG_GiveOnePet(lua_State *_NLL); //ָһ +int NPC_Lua_NLG_GiveItem(lua_State *_NLL); //ָһ +int NPC_Lua_NLG_GiveOneItem(lua_State *_NLL); //ָһ +int NPC_Lua_NLG_GiveRandItem(lua_State *_NLL); +int NPC_Lua_Char_GetOnLinePlayer(lua_State *_NLL); //ȡǰ + +int NPC_Lua_NLG_ShowWindowTalked(lua_State *_NLL); //ָҿͻʾָݡ͵ĶԻ +int NPC_Lua_NLG_SetAction(lua_State *_NLL); //öĶ + +int NPC_Lua_NLG_TalkToCli(lua_State *_NLL); //ͨ˵Զȫ˵ +int NPC_Lua_NLG_TalkToFloor(lua_State *_NLL); //ijһָͼڵ˵ + +int NPC_Lua_NLG_UpChar(lua_State *_NLL); //NPCΧҷNPCݸ· +int NPC_Lua_NLG_UpStateBySecond(lua_State *_NLL); //ָҷ͵2״̬· +int NPC_Lua_NLG_UpStateByThird(lua_State *_NLL); //ָҷ͵3״̬· +int NPC_Lua_NLG_Update_Party(lua_State *_NLL); //ڵŶӳԱҵ״̬· + +int NPC_Lua_NLG_Warp(lua_State *_NLL); //һ +int NPC_Lua_NLG_WalkMove(lua_State *_NLL); //ƶһ +int NPC_Lua_NLG_WatchEntry(lua_State *_NLL); //ս +int NPC_Lua_NLG_HealerAllHeal(lua_State *_NLL); //Ѫ +int NPC_Lua_NLG_GetMaxPlayNum(lua_State *_NLL); //ȡ +int NPC_Lua_NLG_CheckPlayIndex(lua_State *_NLL); //Ƿ +int NPC_Lua_NLG_Save(lua_State *_NLL); +////add by mo +int NPC_Lua_NLG_SetExp(lua_State *_NLL); //÷鱶 +int NPC_Lua_NLG_GetExp(lua_State *_NLL); //ȡ鱶 +#ifdef _PETTRANS_RANGE +int NPC_Lua_NLG_SetPetTransRange(lua_State *_NLL); //óתΧ +int NPC_Lua_NLG_GetPetTransRange(lua_State *_NLL); //óתΧ +#endif +///////////////////////////////////////////////Char//////////////////////////////////////////////// +//ݵĽӿ +int NPC_Lua_Char_ClrEvtEnd(lua_State *_NLL); //־ +int NPC_Lua_Char_ClrEvtNow(lua_State *_NLL); //־ +int NPC_Lua_Char_ClrEvt(lua_State *_NLL); //־ +int NPC_Lua_Char_GetAllocPoint(lua_State *_NLL); //ȡCharIndexάɳ +int NPC_Lua_Char_GetDataFromEnemyBase(lua_State *_NLL); //ȡӦ ־ ijģݣenemybaseX.txt +int NPC_Lua_Char_GetPlayerIndex(lua_State *_NLL); // +int NPC_Lua_Char_FindItemIndex(lua_State *_NLL); //ָǷӵijΪָ +int NPC_Lua_Char_FindPetIndex(lua_State *_NLL); //ָǷӵгΪָ +int NPC_Lua_CHAR_CHECKINDEX(lua_State *_NLL); // +int NPC_Lua_Char_GetPetSkill(lua_State *_NLL); //ȡóָļܱ +int NPC_Lua_Char_GetPetSkillNo(lua_State *_NLL); //ȡChar +int NPC_Lua_Char_RidNo(lua_State *_NLL); //־ +int NPC_Lua_Char_GetEmptyItemBoxNum(lua_State *_NLL); //ָϵλ +int NPC_Lua_Char_GetEmptyPetBoxNum(lua_State *_NLL); //ָϳλ +int NPC_Lua_Char_GetPlayerItemNum(lua_State *_NLL); //ָΪijIDĵߵ +int NPC_Lua_Char_GetPlayerPetNum(lua_State *_NLL); //ָΪijIDij +int NPC_ABLua_char_getPlayerMaxNum(lua_State *_NLL); // +int NPC_ABLua_char_getBattleexp(lua_State *_NLL); //ս鱶 +int NPC_Lua_Char_SetPetSkill(lua_State *_NLL); //óָļܱ +int NPC_Lua_Char_SetPetSkillNo(lua_State *_NLL); +int NPC_Lua_Char_ComplianceParameter(lua_State *_NLL); //ݶ¼㲢WORKԣԴﵽЧĿġ +int NPC_Lua_Char_HcItemId(lua_State *_NLL); //ϳõϷƷ +int NPC_Lua_Char_DelHcItem(lua_State *_NLL); //ɾijλõƷ +int NPC_Lua_Char_GETFM(lua_State *_NLL); //ȡ ʽ +int NPC_Lua_Char_FindPetEnemyBaseId(lua_State *_NLL); //ָǷӵгEnemyBaseļĶӦID +int NPC_Lua_Char_ITEMID_NAME(lua_State *_NLL); //ָID +int NPC_Lua_Char_ITEMID_NAME2(lua_State *_NLL); //ָID˵ +int NPC_Lua_Char_ITEMID_LEVEL(lua_State *_NLL); //ָIDĵȼ +int NPC_Lua_Char_ITEMID_GOLD(lua_State *_NLL); //ָIDļ۸ +int NPC_Lua_Char_ITEMID_RANO(lua_State *_NLL); //ָIDͼ +//int NPC_Lua_Char_CharRidNo(lua_State *_NLL); //ǷѾij֤ +int NPC_Lua_Char_GetPetOwner(lua_State *_NLL); //ó˵ +int NPC_Lua_Char_GetEnemyBaseIdFromEnemyId(lua_State *_NLL); //ͨenemy.txtõijenemybase.txt趨ijš +int NPC_Lua_Char_GetEnemyIdFromEnemyBaseId(lua_State *_NLL); //ͨenemybase.txtõijenemy.txt趨ijš +int NPC_Lua_Char_GetIp(lua_State *_NLL); //ȡָIPַ +int NPC_Lua_Char_SetAllocPoint(lua_State *_NLL); //óCharIndexάɳ +int NPC_Lua_Char_GetMaxPetIndex(lua_State *_NLL); //ȡ +int NPC_Lua_Char_GetMaxPlayerIndex(lua_State *_NLL); //ȡ +int NPC_Lua_Char_SavePetToString(lua_State *_NLL); //һַ +int NPC_Lua_Char_LoadPetFromString(lua_State *_NLL); //һַһ +int NPC_Lua_Char_GetPlayerFromAccAndName(lua_State *_NLL);//ҵʺźѰҡʺźҲɲҡɶ +int NPC_Lua_Char_CheckPet(lua_State *_NLL); //ǷЧ +int NPC_Lua_Char_CheckPlayer(lua_State *_NLL); //ǷЧ +BOOL NPC_Lua_Char_JoinParty(lua_State *_NLL); //Ŷ +int NPC_Lua_Char_getFamilyPlayIndex(lua_State *_NLL); //ü + +int NPC_Lua_Char_SetEvtEnd(lua_State *_NLL); //־Ϊ״̬ +int NPC_Lua_Char_SetEvtNow(lua_State *_NLL); //־Ϊ״̬ +int NPC_Lua_Char_SetData(lua_State *_NLL); //Char + +int NPC_Lua_Char_getVipPoint(lua_State *_NLL); //Ա +int NPC_Lua_Char_getjfPoint(lua_State *_NLL); //ָ +int NPC_Lua_Char_getxjPoint(lua_State *_NLL); //ֽ +int NPC_Lua_Char_setVipPoint(lua_State *_NLL); //Ա +int NPC_Lua_Char_setjfPoint(lua_State *_NLL); //ֲ +int NPC_Lua_Char_setxjPoint(lua_State *_NLL); //ֽ + +//¼õĽӿ +int NPC_Lua_Char_SetWalkPreEvent(lua_State *_NLL); //WalkPre¼Ӧ +int NPC_Lua_Char_SetWalkPostEvent(lua_State *_NLL); //WalkPost¼Ӧ +int NPC_Lua_Char_SetPreOverEvent(lua_State *_NLL); //PreOver¼Ӧ +int NPC_Lua_Char_SetPostOverEvent(lua_State *_NLL); //PostOver¼Ӧ +int NPC_Lua_Char_SetWatchEvent(lua_State *_NLL); //Watch¼Ӧ +int NPC_Lua_Char_SetLoopEvent(lua_State *_NLL); //Loop¼Ӧ +int NPC_Lua_Char_SetTalkedEvent(lua_State *_NLL); //Talked¼Ӧ +int NPC_Lua_Char_SetOFFEvent(lua_State *_NLL); //OFF¼Ӧ +int NPC_Lua_Char_SetLookedEvent(lua_State *_NLL); //Looked¼Ӧ +int NPC_Lua_Char_SetItemPutEvent(lua_State *_NLL); //ItemPut¼Ӧ +int NPC_Lua_Char_SetWindowTalkedEvent(lua_State *_NLL); //WindowTalked¼Ӧ +#ifdef _USER_CHARLOOPS +int NPC_Lua_Char_SetCharLoopsEvent(lua_State *_NLL); //CharLoops¼Ӧ +int NPC_Lua_Char_SetBattleProPertyEvent(lua_State *_NLL);//BattleProPerty¼Ӧ +#endif + +//ȡݵĽӿ +int NPC_Lua_Char_IsEventEnd(lua_State *_NLL); //Ƿ־ +int NPC_Lua_Char_IsEventNow(lua_State *_NLL); //Ƿ־ + +int NPC_Lua_Char_FindItemId(lua_State *_NLL); //ָǷӵijID +int NPC_Lua_Char_FindPetEnemyId(lua_State *_NLL); //ָǷӵгEnemyļĶӦID + +int NPC_Lua_Char_GetData(lua_State *_NLL); //ȡChar +int NPC_Lua_Char_GetItemId(lua_State *_NLL); //ȡָָλõĵID +int NPC_Lua_Char_GetPetEnemyId(lua_State *_NLL); //ȡָָλõijEnemyļĶӦID +int NPC_Lua_Char_GetItemIndex(lua_State *_NLL); //ȡָָλõĵ +int NPC_Lua_Char_GetPetIndex(lua_State *_NLL); //ȡָָλõij +int NPC_Lua_Char_GetTeamIndex(lua_State *_NLL); //ȡԱĶ +int NPC_Lua_Char_GetPlayerIndexByCdkey(lua_State *_NLL); //ͨʺŲѯ +int NPC_Lua_Char_VipPoint(lua_State *_NLL); +int NPC_Lua_Char_HealAll(lua_State *_NLL); +int NPC_Lua_Char_GetPetSkillId(lua_State *_NLL); +int NPC_Lua_Char_GetPetSkillName(lua_State *_NLL); +int NPC_Lua_Char_GetPetSkillMsg(lua_State *_NLL); +int NPC_Lua_Char_SetPetSkill(lua_State *_NLL); +int NPC_Lua_Char_RandMsg(lua_State *_NLL); +int NPC_Lua_Char_GetBeatitudeNum(lua_State *_NLL); +///////////////////////////////////////////////GAME//////////////////////////////////////////////// +int NPC_Lua_Game_FMPOINT_GetData(lua_State *_NLL); //ׯ԰ݵϢ +int NPC_Lua_Game_FMPOINT_ACSetFMPoint(lua_State *_NLL); //趨ݵϢݵδռʱЧ +int NPC_Lua_Game_FMPOINT_ACFixFMPoint(lua_State *_NLL); //޸ļݵϢơһս +int NPC_Lua_Game_FMPOINT_ACCleanFMPoint(lua_State *_NLL); //ݵ㡣 +///////////////////////////////////////////////Item//////////////////////////////////////////////// +//ȡݵĽӿ +int NPC_Lua_Item_GetData(lua_State *_NLL); //ȡ +int NPC_Lua_Item_GetDataFromItemSet(lua_State *_NLL); //ȡITEMSETXļ +//ݵĽӿ +int NPC_Lua_Item_SetData(lua_State *_NLL); //ȡ + +//¼õĽӿ +int NPC_Lua_Item_SetPreOverEvent(lua_State *_NLL); //PreOver¼Ӧ +int NPC_Lua_Item_SetPostOverEvent(lua_State *_NLL); //PostOver¼Ӧ +int NPC_Lua_Item_SetWatchEvent(lua_State *_NLL); //Watch¼Ӧ +int NPC_Lua_Item_SetUseEvent(lua_State *_NLL); //Use¼Ӧ +int NPC_Lua_Item_SetAttachEvent(lua_State *_NLL); //Attach¼Ӧ +int NPC_Lua_Item_SetDetachEvent(lua_State *_NLL); //Detach¼Ӧ +int NPC_Lua_Item_SetDropEvent(lua_State *_NLL); //Drop¼Ӧ +int NPC_Lua_Item_SetPickUPEvent(lua_State *_NLL); //PickUP¼Ӧ +#ifdef _Item_ReLifeAct +int NPC_Lua_Item_SetDieReLifeEvent(lua_State *_NLL); //DieReLife¼Ӧ +#endif +///////////////////////////////////////////////BIT/////////////////////////////////////////////// +int NPC_Lua_Bit_band(lua_State *_NLL); +int NPC_Lua_Bit_bor(lua_State *_NLL); +int NPC_Lua_Bit_bxor(lua_State *_NLL); +int NPC_Lua_Bit_lshift(lua_State *_NLL); +int NPC_Lua_Bit_rshift(lua_State *_NLL); +///////////////////////////////////////////////Obj//////////////////////////////////////////////// +//ȡݵĽӿ +int NPC_Lua_Obj_GetType(lua_State *_NLL); //ȡOBJ +/* +int NPC_Lua_Obj_GetName(lua_State *_NLL); //ȡOBJ +int NPC_Lua_Obj_GetDIR(lua_State *_NLL); //ȡOBJķ +int NPC_Lua_Obj_GetImageNum(lua_State *_NLL); //ȡOBJ +*/ +int NPC_Lua_Obj_GetCharType(lua_State *_NLL); //ȡOBJӦCharݽṹ +int NPC_Lua_Obj_GetCharIndex(lua_State *_NLL); //ȡOBJӦCharݽṹ +int NPC_Lua_Obj_GetX(lua_State *_NLL); //ȡOBJX +int NPC_Lua_Obj_GetY(lua_State *_NLL); //ȡOBJY +int NPC_Lua_Obj_GetFloor(lua_State *_NLL); //ȡOBJڵĵͼ +//int NPC_Lua_Obj_GetDelTime(lua_State *_NLL); //ȡOBJɾʱ + +int NPC_Lua_Obj_SetType(lua_State *_NLL); //ȡOBJ +/* +int NPC_Lua_Obj_SetName(lua_State *_NLL); //ȡOBJ +int NPC_Lua_Obj_SetDIR(lua_State *_NLL); //ȡOBJķ +int NPC_Lua_Obj_SetImageNum(lua_State *_NLL); //ȡOBJ +*/ +int NPC_Lua_Obj_SetCharType(lua_State *_NLL); //ȡOBJӦCharݽṹ +int NPC_Lua_Obj_SetX(lua_State *_NLL); //ȡOBJX +int NPC_Lua_Obj_SetY(lua_State *_NLL); //ȡOBJY +int NPC_Lua_Obj_SetFloor(lua_State *_NLL); //ȡOBJڵĵͼ +//int NPC_Lua_Obj_SetDelTime(lua_State *_NLL); //ȡOBJɾʱ + +//////////////////////////////////////////////Battle/////////////////////////////////////////////// +//ȡݵĽӿ +int NPC_Lua_Battle_GetPlayIndex(lua_State *_NLL); //ȡսе +int NPC_Lua_Battle_GetData(lua_State *_NLL); //ȡս +int NPC_Lua_Battle_SetData(lua_State *_NLL); //ս +int NPC_Lua_Battle_IndexToNo(lua_State *_NLL); //ͨȡڵս +int NPC_Lua_Battle_NoToIndex(lua_State *_NLL); //ͨսŻȡ +int NPC_Lua_Battle_CheckIndex(lua_State *_NLL); //սǷЧ +//ݵĽӿ +int NPC_Lua_Battle_SetNORisk(lua_State *_NLL); //Ƿ޷ģʽ +int NPC_Lua_Battle_SetMod(lua_State *_NLL); //սģʽ־ +int NPC_Lua_Battle_SetType(lua_State *_NLL); //ս +int NPC_Lua_Battle_Exit(lua_State *_NLL); //˳ս +//¼õĽӿ +int NPC_Lua_Battle_SetWinEvent(lua_State *_NLL); //Win¼Ӧ +int NPC_Lua_Battle_SetEndEvent(lua_State *_NLL); //Win¼Ӧ +///////////////////////////////////////////////Other/////////////////////////////////////////////// +int NPC_Lua_GetFuncPoint(lua_State *_NLL); //ȡָ + +////////////////////////////////////////////////////////////////////// +///////////////////////////////////////////////MAP//////////////////////////////////////////////// +int NPC_Lua_Map_CheckCoordinates(lua_State *_NLL); //ijǷڵͼΧڡ +int NPC_Lua_Map_GetExitFloorXY(lua_State *_NLL); //ͼǷֵ֧dz +int NPC_Lua_Map_GetfloorX(lua_State *_NLL); //ȡͼX +int NPC_Lua_Map_GetfloorY(lua_State *_NLL); //ȡͼY +int NPC_Lua_Map_GetTileAndObjId(lua_State *_NLL); //ȡͼijĵذװβ +int NPC_Lua_Map_SetTileAndObjId(lua_State *_NLL); //õͼijĵذװβ +int NPC_Lua_Map_GetWalkAbleFromPoint(lua_State *_NLL); //ȡijǷ +int NPC_Lua_Map_GetImageData(lua_State *_NLL); //ȡͼƬ +int NPC_Lua_Map_SetImageData(lua_State *_NLL); //ͼƬ +int NPC_Lua_Map_GetTopObj(lua_State *_NLL); //ȡͼij϶ +int NPC_Lua_Map_GetNextObj(lua_State *_NLL); //ȡһ +int NPC_Lua_Map_CheckImageIndex(lua_State *_NLL); //ijͼͼƬǷ +int NPC_Lua_Map_CheckIndex(lua_State *_NLL); //ijͼŵͼǷ +int NPC_Lua_Map_MakeNewMap(lua_State *_NLL); //һµĵͼ صͼID +int NPC_Lua_Map_DelNewMap(lua_State *_NLL); //ɾһͼ +int NPC_Lua_Map_SetExWarp(lua_State *_NLL); //dzͼĴ͵ +int NPC_Lua_Map_SetMapPoint(lua_State *_NLL); //ӵͼ͵ +int NPC_Lua_Map_DelMapPoint(lua_State *_NLL); //ɾͼ͵ +int NPC_Lua_Map_getFloorName(lua_State *_NLL); //õͼ +int NPC_Lua_Map_Upmap(lua_State *_NLL); //µͼ +///////////////////////////////////////////////MAP//////////////////////////////////////////////// +///////////////////////////////////////////////Spell//////////////////////////////////////////////// +int NPC_Lua_Spell_PETSKILL_GetData(lua_State *_NLL); //ȡ\ID +int NPC_Lua_Spell_PROFESSION_GetData(lua_State *_NLL); //ȡְҵID +int NPC_Lua_Spell_MAGIC_GetData(lua_State *_NLL); //ȡ鼼ID +int NPC_Lua_Spell_PETSKILL_SetData(lua_State *_NLL); //öӦIDļݣ +int NPC_Lua_Spell_PROFESSION_SetData(lua_State *_NLL); //öӦIDļݣ +int NPC_Lua_Spell_MAGIC_SetData(lua_State *_NLL); //öӦIDļݣ +///////////////////////////////////////////////Spell//////////////////////////////////////////////// +///////////////////////////////////////////////SQL///////////////////////////////////////////////// +int NPC_Lua_SQL_Push(lua_State *_NLL); //MySQLָ +int NPC_Lua_SQL_PushPop(lua_State *_NLL); //MySQLָӦ +int NPC_Lua_SQL_PushPopAdv(lua_State *_NLL); //SAACһSQLѯ󣬲ָSAACشʱԽдĻص,úصһнͷŽ +int NPC_Lua_SQL_QueryFirstRow(lua_State *_NLL); //ص,úصһнͷŽ +int NPC_Lua_SQL_FetchRow(lua_State *_NLL); //һ +int NPC_Lua_SQL_FreeResult(lua_State *_NLL); //ͷŽ +///////////////////////////////////////////////SQL/////////////////////////////////////////////// +#define LRet(r) \ +{ \ + NPC_Lua_SetErrorStr(NULL); \ + return r; \ +} + +#define LRetErr(c,r) \ +{ \ + NPC_Lua_SetErrorStr(c); \ + return r; \ +} + +////////////////////////////////////////////////////////////////////// +//һnil +#define LRetNull(L) \ +{ \ + lua_pushnil(L); \ + LRet(1); \ +} + +//һBOOLLUA +#define LRetBool(L, b) \ +{ \ + lua_pushboolean(L, b); \ + LRet(1); \ +} + +//һintLUA +#define LRetInt(L, i) \ +{ \ + lua_pushinteger(L, i); \ + LRet(1); \ +} + +#define LRetMsg(L, c) \ +{ \ + lua_pushstring(L, c); \ + LRet(1); \ +} +//////////////////////////////////////////////////////////////////// +//һ״̬һϢ +#define LRetErrInt(L, i, c) \ +{ \ + lua_pushinteger(L, i); \ + LRetErr(c,1); \ +} + +//һַLUA +#define LRetErrNull(L, c) \ +{ \ + lua_pushnil(L); \ + LRetErr(c,1); \ +} + +//һַLUA +#define LRetErrMsg(L, c) \ +{ \ + lua_pushstring(L, c); \ + LRetErr(c,1); \ +} + +//ڼǷ㹻 +#define CheckEx(L, n) \ +{ \ + if(lua_gettop(L) != n) \ + { \ + luaL_argerror(L, 1, ""); \ + } \ +} + +#define CheckEx2(L, t, n) \ +{ \ + if(lua_gettop(L) < (t) || lua_gettop(L) > n) \ + { \ + luaL_argerror(L, 1, ""); \ + } \ +} + +#define CheckIndexNull(L, n) \ +{ \ + if(lua_isnil((L), (n))) \ + { \ + luaL_argerror((L), 1, "Ϊnil"); \ + } \ +} + +#define CheckBattleIndexNull(L, n) \ +{ \ + if(lua_isnil((L), (n))) \ + { \ + luaL_argerror((L), 1, "սΪnil"); \ + } \ +} + +#define CheckItemIndexNull(L, n) \ +{ \ + if(lua_isnil((L), (n))) \ + { \ + luaL_argerror((L), 1, "Ϊnil"); \ + } \ +} + +#define CheckObjIndexNull(L, n) \ +{ \ + if(lua_isnil((L), (n))) \ + { \ + luaL_argerror((L), 1, "Ϊnil"); \ + } \ +} + +#define LRetArray(L, Array, num) \ +{ \ + Lua_ReturnArray(L, Array, num); \ + LRet(1); \ +} + +#ifdef _LUA_Debug +int pcall_callback_err_fun(lua_State* L,const char *_InitFuncName); //LUAűϢ +#endif + +#endif //#ifndef __NPC_LUA__ diff --git a/include/npc_lua_interface.h b/include/npc_lua_interface.h new file mode 100644 index 0000000..4e301af --- /dev/null +++ b/include/npc_lua_interface.h @@ -0,0 +1,121 @@ +#ifndef __NPC_LUA_INTERFACE__ +#define __NPC_LUA_INTERFACE__ + +#include "version.h" +#include "common.h" + +/////////////////////////////////////////ⲿӿ///////////////////////////////////////////////////////////////// +#define FUNCNAME_INITCALLBACK "NPC_Lua_InitCallBack" //CHAR_INITFUNC +#define FUNCNAME_WALKPRECALLBACK "NPC_Lua_WalkPreCallBack" //CHAR_WALKPREFUNC +#define FUNCNAME_WALKPOSTCALLBACK "NPC_Lua_WalkPostCallBack" //CHAR_WALKPOSTFUNC +#define FUNCNAME_PREOVERCALLBACK "NPC_Lua_PreOverCallBack" //CHAR_PREOVERFUNC +#define FUNCNAME_POSTOVERCALLBACK "NPC_Lua_PostOverCallBack" //CHAR_POSTOVERFUNC +#define FUNCNAME_WATCHCALLBACK "NPC_Lua_WatchCallBack" //CHAR_WATCHFUNC +#define FUNCNAME_LOOPCALLBACK "NPC_Lua_LoopCallBack" //CHAR_LOOPFUNC +#define FUNCNAME_TALKEDCALLBACK "NPC_Lua_TalkedCallBack" //CHAR_TALKEDFUNC +#define FUNCNAME_OFFCALLBACK "NPC_Lua_OFFCallBack" //CHAR_OFFFUNC +#define FUNCNAME_LOOKEDCALLBACK "NPC_Lua_LookedCallBack" //CHAR_LOOKEDFUNC +#define FUNCNAME_ITEMPUTCALLBACK "NPC_Lua_ItemPutCallBack" //CHAR_ITEMPUTFUNC +#define FUNCNAME_WINDOWTALKEDCALLBACK "NPC_Lua_WindowTalkedCallBack" //CHAR_WINDOWTALKEDFUNC +#ifdef _USER_CHARLOOPS +#define FUNCNAME_CHARLOOPSCALLBACK "NPC_Lua_CharLoopsCallBack" //CHAR_LOOPFUNCTEMP1 ﵰιҩԭеLOOP +#define FUNCNAME_BATTLEPROPERTYCALLBACK "NPC_Lua_BattleProPertyCallBack" //CHAR_BATTLEPROPERTY +#endif +/* + CHAR_DYINGFUNC, + , + CHAR_PREATTACKEDFUNC, + CHAR_POSTATTACKEDFUNC, + + CHAR_SPECIALTALKEDFUNC, + , +#ifdef _USER_CHARLOOPS + , + CHAR_LOOPFUNCTEMP2, + , +#endif +*/ +#define FUNCNAME_ITEMPEROVERCALLBACK "NPC_Lua_ItemPerOverCallBack" //LUAITEM_PREOVERFUNC = ITEM_PREOVERFUNC +#define FUNCNAME_ITEMPOSTOVERCALLBACK "NPC_Lua_ItemPostOverCallBack" //LUAITEM_POSTOVERFUNC = ITEM_POSTOVERFUNC +#define FUNCNAME_ITEMWATCHCALLBACK "NPC_Lua_ItemWatchCallBack" //LUAITEM_WATCHFUNC = ITEM_WATCHFUNC +#define FUNCNAME_ITEMUSECALLBACK "NPC_Lua_ItemUseCallBack" //LUAITEM_USEFUNC = ITEM_USEFUNC +#define FUNCNAME_ITEMATTACHCALLBACK "NPC_Lua_ItemAttachCallBack" //LUAITEM_ATTACHFUNC = ITEM_ATTACHFUNC +#define FUNCNAME_ITEMDETACHCALLBACK "NPC_Lua_ItemDetachCallBack" //LUAITEM_DETACHFUNC = ITEM_DETACHFUNC +#define FUNCNAME_ITEMDROPCALLBACK "NPC_Lua_ItemDropCallBack" //LUAITEM_DROPFUNC = ITEM_DROPFUNC +#define FUNCNAME_ITEMPICKUPCALLBACK "NPC_Lua_ItemPickUPCallBack" //LUAITEM_PICKUPFUNC = ITEM_PICKUPFUNC +#ifdef _Item_ReLifeAct +#define FUNCNAME_ITEMDIERELIFECALLBACK "NPC_Lua_ItemDieReLifeCallBack" //LUAITEM_DIERELIFEFUNC = ITEM_DIERELIFEFUNC +#endif + +#define FUNCNAME_BATTLEWINCALLBACK "NPC_Lua_BattleWinCallBack" //BATTLE WinFunc +#define FUNCNAME_BATTLEENDCALLBACK "NPC_Lua_BattleEndCallBack" //BATTLE WinFunc +//ʼLUA +int NPC_Lua_Init(const char *_DoFile); + +//رLUA +int NPC_Lua_Close(void); + +//̬ؽűļ +int NPC_Lua_DoFile(const char *_DoFile); + +//LUAűջһ +const char *NPC_Lua_popstring(int _ArgNum); + +//ָĽű +const char *NPC_Lua_CallFunc(const char *_FuncName, char *_RetBuff, size_t _n, int index); + +//ս +int NPC_Lua_getBattleFieldNo(int _Floor, int _X, int _Y); + +//ȡ +int NPC_GivePet(int charaindex, int lv, int enemyid); +//ȡ +int NPC_GiveItem(int charaindex, int itemid); +//ɾ +int NPC_DelPet(int charaindex, int petsel); + +//ص +BOOL NPC_Lua_InitCallBack(int _meindex); +BOOL NPC_Lua_WalkPreCallBack(int _meindex, int *_dir, int *_mode); +void NPC_Lua_WalkPostCallBack(int _meindex); +void NPC_Lua_PreOverCallBack(int _meindex, int _desindex); +void NPC_Lua_PostOverCallBack(int _meindex, int _desindex); +void NPC_Lua_WatchCallBack(int _meindex, int _objindex, int _chac, int _x, int _y, int _dir, int *_watchopt, int _watchoptlen); +int NPC_Lua_LoopCallBack(int _meindex); +void NPC_Lua_TalkedCallBack(int _meindex, int _tomeindex,const char *_messageeraseescape, int _color, int _channel); +void NPC_Lua_OFFCallBack(int _meindex, int _desindex); +void NPC_Lua_LookedCallBack(int _meindex, int _desindex); +BOOL NPC_Lua_ItemPutCallBack(int _meindex, int _itemindex); +void NPC_Lua_WindowTalkedCallBack(int _meindex, int _talkindex, int _seqno, int _select,const char *_data); +#ifdef _USER_CHARLOOPS +int NPC_Lua_CharLoopsCallBack( int _meindex); +int NPC_Lua_BattleProPertyCallBack(int _attackindex, int _defindex, int *_damage, int *_powarray, int _arraynum); +#endif + +/* ʱδʹõ¼ +int NPC_Lua_DyingCallBack(int meindex); +NPC_Lua_PreAttackedCallBack +NPC_Lua_PostAttackedCallBack +NPC_Lua_SpecialTalkedCallBack +*/ + +void NPC_Lua_ItemPerOverCallBack(int _itemindex, int _playindex); +void NPC_Lua_ItemPostOverCallBack(int _itemindex, int _playindex); +void NPC_Lua_ItemWatchCallBack(int _meindex, int _objindex, int _chac, int _x, int _y, int _dir, int *_watchopt, int _watchoptlen); +void NPC_Lua_ItemUseCallBack(int _playindex, int _to_charindex, int _haveitemindex); +void NPC_Lua_ItemAttachCallBack(int _playindex, int _itemindex); +void NPC_Lua_ItemDetachCallBack(int _playindex, int _itemindex); +void NPC_Lua_ItemDropCallBack(int _playindex, int _itemindex); +void NPC_Lua_ItemPickUPCallBack(int _playindex, int _itemindex); +#ifdef _Item_ReLifeAct +void NPC_Lua_ItemDieReLifeCallBack(int _playindex, int _itemindex, int _haveitem); +#endif + +void NPC_Lua_BattleWinCallBack(int _battleindex, int _createindex); +void NPC_Lua_BattleEndCallBack(int _battleindex); +#ifdef _CAX_LNS_MYSQLSUOXU +void NPC_Lua_SQLPushCallBack(char* _result,char* _filename,char* _function,int _npcindex,int _playerindex, char* _msg); +void NPC_Lua_SQLPushAdvCallBack(int luaresult,int luaflg,int luaerrnono,char* luaerrstr,int luafileCount,int rowCount,int rowAt,char* row,char* _filename,char* _function,int npcindex,int charaindex,char* msg); +#endif +////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +#endif //#ifndef __NPC_LUA_INTERFACE__ diff --git a/include/npc_luckyman.h b/include/npc_luckyman.h new file mode 100644 index 0000000..36c4db4 --- /dev/null +++ b/include/npc_luckyman.h @@ -0,0 +1,10 @@ +#ifndef __NPC_LUCKYMAN_H__ +#define __NPC_LUCKYMAN_H__ + +void NPC_LuckyManTalked( int meindex , int talkerindex , char *msg , + int color ); +BOOL NPC_LuckyManInit( int meindex ); +void NPC_LuckyManWindowTalked( int meindex, int talkerindex, int seqno, int select, char *data); + +#endif +/*__NPC_LUCKYMAN_H__*/ diff --git a/include/npc_makepair.h b/include/npc_makepair.h new file mode 100644 index 0000000..f0d775d --- /dev/null +++ b/include/npc_makepair.h @@ -0,0 +1,22 @@ +#ifndef _MAKEPAIR_MAN_H +#define _MAKEPAIR_MAN_H + +void NPC_MakePairManTalked( int meindex, int talkerindex, char *msg, int color ); +BOOL NPC_MakePairManInit( int meindex ); +void NPC_MakePairManWindowTalked( int meindex, int talkerindex, int seqno, int select, char *data); +void NPC_MakePairManLoop( int meindex); + +typedef struct _tagPairMenu{ + char cdKey[256]; + char name[256]; + int pindex; + int forindex; + int code; + int use; +}PairMenu; + + + +#endif + + diff --git a/include/npc_manorsman.h b/include/npc_manorsman.h new file mode 100644 index 0000000..ce84694 --- /dev/null +++ b/include/npc_manorsman.h @@ -0,0 +1,19 @@ +#ifndef __NPC_MANORSMAN_H__ +#define __NPC_MANORSMAN_H__ +#include +BOOL NPC_ManorSmanInit(int meindex); +void NPC_ManorSmanTalked(int meindex, int talkerindex, char *msg, int color); +void NPC_ManorSmanWindowTalked(int meindex, int talkerindex, + int seqno, int select, char *data); +void NPC_ManorSmanLoop(int meindex); +//andy_123 +int NPC_getManorsmanListIndex( int ID); +#ifndef _NEW_MANOR_LAW +void NPC_ManorSavePKSchedule(int meindex, int toindex, int flg); +#else +void NPC_ManorSavePKSchedule(int meindex, int toindex, int flg,int setTime,struct tm tm1); +void NPC_ManorAddToSchedule(int meindex,int charaindex); +#endif + +#endif +/*__NPC_MANORSMAN_H__*/ diff --git a/include/npc_mic.h b/include/npc_mic.h new file mode 100644 index 0000000..501e0d4 --- /dev/null +++ b/include/npc_mic.h @@ -0,0 +1,9 @@ +#ifndef __NPC_MIC_H__ +#define __NPC_MIC_H__ + +BOOL NPC_MicInit(int meindex ); +void NPC_MicTalked( int meindex , int talkerindex , char *msg , int color ); + +#endif + /*__NPC_MIC_H__*/ + diff --git a/include/npc_msg.h b/include/npc_msg.h new file mode 100644 index 0000000..f0f875b --- /dev/null +++ b/include/npc_msg.h @@ -0,0 +1,9 @@ +#ifndef _NPC_MSG_H_ +#define _NPC_MSG_H_ + +BOOL NPC_MsgInit( int meindex ); +void NPC_MsgLooked( int meindex , int lookedindex ); + + +#endif + diff --git a/include/npc_mtradenpcman.h b/include/npc_mtradenpcman.h new file mode 100644 index 0000000..93135bf --- /dev/null +++ b/include/npc_mtradenpcman.h @@ -0,0 +1,10 @@ +#ifndef __NPC_MAPTRADEMAN_H__ +#define __NPC_MAPTRADEMAN_H__ + +BOOL MapTradeManInit( int meindex ); +void MapTradeManLoop( int meindex); +void MapTradeManTalked( int meindex , int talkerindex , char *msg , int color ); +void MapTradeManWindowTalked( int meindex, int talkerindex, int seqno, int select, char *data); + +#endif + diff --git a/include/npc_newnpcman.h b/include/npc_newnpcman.h new file mode 100644 index 0000000..9ad31b7 --- /dev/null +++ b/include/npc_newnpcman.h @@ -0,0 +1,8 @@ +#ifndef __NPC_NEWNPCMAN_H__ +#define __NPC_NEWNPCMAN_H__ +BOOL NPC_NewNpcManInit( int meindex ); +void NPC_NewNpcManLoop( int meindex); +void NPC_NewNpcManTalked( int meindex , int talkerindex , char *msg , int color ); +void NPC_NewNpcManWindowTalked( int meindex, int talkerindex, int seqno, int select, char *data); +#endif + diff --git a/include/npc_newvipshop.h b/include/npc_newvipshop.h new file mode 100644 index 0000000..afcb6de --- /dev/null +++ b/include/npc_newvipshop.h @@ -0,0 +1,8 @@ + + +void NPC_NewVipshopTalked( int meindex, int talkerindex, char *msg, int color ); +BOOL NPC_NewVipshopInit( int meindex ); +void NPC_NewVipshopWindowTalked( int meindex, int talkerindex, int seqno, int select, char *data); +void NPC_NewVipshopLoop( int meindex); + + diff --git a/include/npc_npcenemy.h b/include/npc_npcenemy.h new file mode 100644 index 0000000..62134e4 --- /dev/null +++ b/include/npc_npcenemy.h @@ -0,0 +1,17 @@ +#ifndef __NPC_NPCENEMY_H__ +#define __NPC_NPCENEMY_H__ + +void NPC_NPCEnemyTalked( int meindex , int talkerindex , char *msg , + int color ); + +BOOL NPC_NPCEnemyInit( int meindex ); +int NPC_NPCEnemy_Dying( int battleindex, int meindex ); +int NPC_NPCEnemy_Encount( int meindex, int charaindex, int mode); +void NPC_NPCEnemyWatch( int meobjindex, int objindex, CHAR_ACTION act, + int x,int y,int dir, int* opt,int optlen ); +void NPC_NPCEnemyLoop( int meindex ); +BOOL NPC_NPCEnemy_BattleIn( int meindex, int charaindex); +void NPC_NPCEnemyWindowTalked( int meindex, int talkerindex, int seqno, int select, char *data); + +#endif + /*__NPC_NPCENEMY_H__*/ diff --git a/include/npc_oldman.h b/include/npc_oldman.h new file mode 100644 index 0000000..2b457b9 --- /dev/null +++ b/include/npc_oldman.h @@ -0,0 +1,12 @@ +#ifndef __NPC_OLDMAN_H__ +#define __NPC_OLDMAN_H__ + + +void NPC_OldmanTalked( int meindex , int talkerindex , char *msg , + int color ); + +BOOL NPC_OldmanInit( int meindex ); + + +#endif +/*__NPC_OLDMAN_H__*/ diff --git a/include/npc_pauctionman.h b/include/npc_pauctionman.h new file mode 100644 index 0000000..8fbaeb2 --- /dev/null +++ b/include/npc_pauctionman.h @@ -0,0 +1,372 @@ +0034:npc_petfusion.h:014E:1:14=48041e4b:16=47d21313:#ifndef __NPC_PETFUSION_H__ +#define __NPC_PETFUSION_H__ + + +void NPC_PetFusionManTalked( int meindex, int talkerindex, char *msg, int color ); +BOOL NPC_PetFusionManInit( int meindex ); +void NPC_PetFusionManWindowTalked( int meindex, int talkerindex, int seqno, int select, char *data); +void NPC_PetFusionManLoop( int meindex); + +#endif + +0032:npc_petmaker.h:0E4:1:14=48041e4b:16=47d21313:#ifndef __NPC_PETMAKER_H__ +#define __NPC_PETMAKER_H__ + +void NPC_PetMakerTalked( int meindex , int talkerindex , char *msg , + int color ); +BOOL NPC_PetMakerInit( int meindex ); + +#endif + /*__NPC_PETMAKER_H__*/ +0038:npc_petracemaster.h:0156:1:14=48041e4b:16=47d21313:#ifndef NPC_PetRace_Master_ +#define NPC_PetRace_Master_ + +BOOL NPC_PetRaceMasterInit( int meindex ); +void NPC_PetRaceMasterLoop( int meindex ); +void NPC_PetRaceMasterTalked( int meindex , int talkerindex , char *szMes , int color ); +void NPC_PetRaceMasterWindowTalked(int meindex, int talkerindex, int seqno, int select, char *data); + +#endif + +0034:npc_petracepet.h:0E2:1:14=48041e4b:16=47d21313:#ifndef NPC_PetRace_Pet_ +#define NPC_PetRace_Pet_ + +BOOL NPC_PetRacePetInit( int meindex ); +void NPC_PetRacePetLoop( int meindex ); +void NPC_PetRacePetTalked( int meindex , int talkerindex , char *szMes , int color ); + +#endif + +0032:npc_petshop.h:0178:1:14=48041e4b:16=47d21313:#ifndef __NPC_PETSHOP_H__ +#define __NPC_PETSHOP_H__ + +void NPC_PetShopTalked( int meindex , int talkerindex , char *msg , + int color ); +BOOL NPC_PetShopInit( int meindex ); +void NPC_PetShopWindowTalked( int meindex, int talkerindex, int seqno, int select, char *data); +void NPC_PetShopLooked( int meindex , int lookedindex); + + +#endif +/*__NPC_PETSHOP_H__*/ +0037:npc_petskillshop.h:01E1:1:14=48041e4b:16=47d21313:#ifndef __NPC_PETSKILLSHOP_H__ +#define __NPC_PETSKILLSHOP_H__ + +void NPC_PetSkillShopTalked( int meindex , int talkerindex , char *msg , + int color ); +BOOL NPC_PetSkillShopInit( int meindex ); +void NPC_PetSkillShopWindowTalked( int meindex, int talkerindex, int seqno, int select, char *data); +void NPC_PetSkillShopLooked( int meindex , int lookedindex); + +void NPC_PetSkillMakeStr(int meindex,int toindex,int select); + +#endif + /*__NPC_WINDOWPETSKILLSHOP_H__*/ +0036:npc_pettransman.h:0206:1:14=48041e4b:16=47d21313:#ifndef __NPC_PETTRANSMAN_H__ +#define __NPC_PETTRANSMAN_H__ + +BOOL NPC_PetTransManInit(int meindex); +void NPC_PetTransMan_selectWindow(int meindex,int toindex,int num,int select); +void NPC_PetTransManWindowTalked(int meindex,int talkerindex,int seqno,int select,char *data); +void NPC_PetTransManTalked(int meindex,int talkerindex,char *szMes,int color); +int NPC_PetTransManCheck( int meindex, int toindex, int select); +BOOL NPC_PetTransManStatus( int meindex, int toindex, int petNo); +#endif + /*__NPC_PETTRANSMAN_H__*/ +0032:npc_pkpetshop.h:00:1:14=48041e4b:16=47d21313:0037:npc_poolitemshop.h:0184:1:14=48041e4b:16=47d21313:#ifndef __NPC_POOLITEMSHOP_H__ +#define __NPC_POOLITEMSHOP_H__ + + +void NPC_PoolItemShopLoop( int meindex); +BOOL NPC_PoolItemShopInit( int meindex); +void NPC_PoolItemShopTalked( int meindex , int talkerindex , + char *szMes ,int color ); +void NPC_PoolItemShopWindowTalked( int meindex, int talkerindex, + int seqno, int select, char *data); + + +#endif + /*__NPC_POOLITEMSHOP_H__*/ +002F:npc_quiz.h:02C0:1:14=48041e4b:16=47d21313:#ifndef __NPC_QUIZ_H__ +#define __NPC_QUIZ_H__ + +typedef struct NPC_Quiz{ + + int no; // į + int type; // ءة ̡֭) + int level; // ì + int answertype; //̫( ǩѨ + int answerNo; // + char question[512]; // + char select1[128]; // 1 + char select2[128]; // 2 + char select3[128]; // 3 + +}NPC_QUIZ; + + +void NPC_QuizTalked( int meindex , int talkerindex , char *msg , + int color ); +BOOL NPC_QuizInit( int meindex ); +void NPC_QuizWindowTalked( int meindex, int talkerindex, int seqno, int select, char *data); + +BOOL QUIZ_initQuiz( char *filename); + + +#endif + +/*__NPC_QUIZ_H__*/ +0033:npc_riderman.h:017F:1:14=48041e4b:16=47d21313:#ifndef __NPC_RIDERMAN_H__ +#define __NPC_RIDERMAN_H__ + +void NPC_RidermanTalked( int meindex , int talkerindex , char *msg , + int color ); + +BOOL NPC_RidermanInit( int meindex ); +void NPC_RidermanLooked( int meindex, int lookedindex ); +void NPC_RidermanWindowTalked( int meindex, int talkerindex, int seqno, int select, char *data); + +#endif + /*__NPC_RIDERMAN_H__*/ +0037:npc_roomadminnew.h:03CA:1:14=48041e4b:16=47d21313:#ifndef __NPC_ROOMADMINNEW_H__ +#define __NPC_ROOMADMINNEW_H__ + + +void NPC_RoomAdminNewTalked( int meindex , int talkerindex , char *msg , int color ); +void NPC_RoomAdminNewLoop( int meindex ); +BOOL NPC_RoomAdminNewInit( int meindex ); + +BOOL NPC_RankingInit( int meindex ); +void NPC_RankingTalked( int meindex , int talkerindex , char *msg ,int color ); + +BOOL NPC_PrintpassmanInit( int meindex ); +void NPC_PrintpassmanTalked( int meindex , int talkerindex , char *msg ,int color ); + +typedef struct npc_roomadminnew_tag { + int expire; + char cdkey[CDKEYLEN]; + char charaname[32]; + char passwd[9]; +}NPC_ROOMINFO; + +typedef struct npc_roomadminnew_ranking_tag { + int gold; /* ڿź */ + int biddate; /* ڿ */ + char cdkey[CDKEYLEN]; /* м ƽ */ + char charaname[32]; /* м */ + char owntitle[32]; /* į*/ + +}NPC_RANKING_INFO; + +#endif /*__NPC_ROOMADMINNEW_H__*/ + +BOOL NPC_RoomAdminNew_ReadFile( char *roomname, NPC_ROOMINFO *data); +0030:npc_sample.h:075:1:14=48041e4b:16=47d21313:#ifndef __NPC_SAMPLE_H__ +#define __NPC_SAMPLE_H__ + +void NPC_SampleLoop( int index ); + +#endif + + /*__NPC_SAMPLE_H__*/ +0034:npc_savepoint.h:014F:1:14=48041e4b:16=47d21313:#ifndef __NPC_SAVEPOINT_H__ +#define __NPC_SAVEPOINT_H__ + + +void NPC_SavePointTalked( int meindex , int talkerindex , char *msg , + int color ); + +BOOL NPC_SavePointInit( int meindex ); +void NPC_SavePointWindowTalked( int meindex, int talkerindex, int seqno, int select, char *data); + + +#endif + +/*__NPC_SAVEPOINT_H__*/ +0036:npc_scheduleman.h:0A5A:1:14=48041e4b:16=47d21313:#ifndef __NPC_SCHEDULEMAN_H__ +#define __NPC_SCHEDULEMAN_H__ + +#define CHARNAME_MAX 32 + +// scheduleman +#ifdef _FAMILY_MANORNUM_CHANGE +#define MAX_SCHEDULEMAN 20 +#else +#define MAX_SCHEDULEMAN 12 +#endif + +// ÿһ scheduleman عܵ schedule +#define MAX_SCHEDULE 24 + +// schedule бһҳг +#define MAXSCHEDULEINONEWINDOW 10 + +// family бһҳг +#define MAXFAMILYINONEWINDOW 10 + +// ÿһ scheduleman ʹõ schedule λ +// Ӧ fmpks ID*MAX_SCHEDULE (ID=0~MAX_SCHEDULEMAN-1) +// ID д data/npc ָ "id:" ֵ + +// dueltime = (?10000:0) + (Сʱ*100) + +typedef struct tagFamilyPKSchedule { + int dueltime; // ʱ + int host_index; // Ӽ + char host_name[CHARNAME_MAX]; // Ӽ + int guest_index; // ͶӼ + char guest_name[CHARNAME_MAX]; // ͶӼ + int prepare_time; // ׼ʱ (1~40 ) + int max_player; // (1~) + int flag; // ״̬ + int win; // ʤ趨 + int challenge_timeout; // սʱ + int setting_timeout; // 趨״̬ timeout + char gmsv_name[256]; +} FamilyPKSchedule; + +// ¼ FamilyPKSchedule (fmpks) flag ֵ +#define FMPKS_FLAG_NONE -1 // ûκų +#define FMPKS_FLAG_CHALLENGE 0 // ȴͶͬ +#define FMPKS_FLAG_SETTING 1 // 趨ų (ȡʱ NONE) +#define FMPKS_FLAG_CONFIRMING 2 // Ͷͬ +#define FMPKS_FLAG_SCHEDULED 3 // Ѿźų̣δ +#define FMPKS_FLAG_DUEL 4 // +#define FMPKS_FLAG_HOSTWIN 5 // ʤ +#define FMPKS_FLAG_GUESTWIN 6 // Ͷʤ +#define FMPKS_FLAG_MANOR_BATTLEBEGIN 7 // ׯ԰ս ս +#define FMPKS_FLAG_MANOR_PREPARE 8 // ׯ԰ս ׼ +#define FMPKS_FLAG_MANOR_PEACE 9 // ׯ԰ս ս +#define FMPKS_FLAG_MANOR_OTHERPLANET 10 // ׯ԰ս ڱս +#define FMPKS_FLAG_MANOR_BATTLEEND 11 // ׯ԰ս ս +#define FMPKS_FLAG_MANOR_PEACE_SAVE 12 // ׯ԰ս浵 +#define FMPKS_FLAG_MANOR_READYTOFIGHT 13 // (GM: manorpk) ȫϵɿԼս״̬ +#define FMPKS_FLAG_MANOR_CLEANFLAG 14 // (GM: manorpk) ״̬ +#ifdef _NEW_MANOR_LAW +#define FMPKS_FLAG_WAIT 15 // ս,Ѽ¼,ȴսų +#endif + +// client flag +#define FLAG_NONE -1 +#define FLAG_MODIFY 0 +#define FLAG_ACCEPT 1 +#define FLAG_SETTING 2 +#define FLAG_CONFIRM 3 +#define FLAG_SCHEDULED 4 + +extern FamilyPKSchedule fmpks[MAX_SCHEDULE*MAX_SCHEDULEMAN]; + +BOOL NPC_SchedulemanInit(int meindex); +void NPC_SchedulemanTalked(int meindex, int talkerindex, char *msg, int color); +void NPC_SchedulemanWindowTalked(int meindex, int talkerindex, + int seqno, int select, char *data); +void NPC_SchedulemanLoop(int meindex); + +#endif + +/*__NPC_SCHEDULEMAN_H__*/ +0035:npc_sellsthman.h:013A:1:14=48041e4b:16=47d21313:#ifndef _SELLSTH_MAN_H +#define _SELLSTH_MAN_H + +void NPC_SellsthManTalked( int meindex, int talkerindex, char *msg, int color ); +BOOL NPC_SellsthManInit( int meindex ); +void NPC_SellsthManWindowTalked( int meindex, int talkerindex, int seqno, int select, char *data); +void NPC_SellsthManLoop( int meindex); + +#endif +0034:npc_signboard.h:0124:1:14=48041e4b:16=47d21313:#ifndef __NPC_SIGNBOARD_H__ +#define __NPC_SIGNBOARD_H__ + + +BOOL NPC_SignBoardInit( int meindex ); +void NPC_SignBoardWindowTalked( int meindex, int talkerindex, int seqno, int select, char *data); +void NPC_SignBoardLooked( int meindex , int lookedindex); + + +#endif + /*__NPC_WINDOWSIGNBOAD_H__*/ +0035:npc_simpleshop.h:0176:1:14=48041e4b:16=47d21313:#ifndef __NPC_SIMPLESHOP_H__ +#define __NPC_SIMPLESHOP_H__ + +void NPC_SimpleShopTalked( int index, int talker, char *msg, int color ); +void NPC_SimpleShopSpecialTalked( int index, int talker, char *msg, int color ); +void NPC_LimitBuyInShopSpecialTalked( int index, int talker, char *msg, int color ); +void NPC_SimpleShopInit( int meindex ); + +#endif + /*__NPC_SIMPLESHOP_H__*/ +003A:npc_stoneserviceman.h:02AE:1:14=48041e4b:16=47d21313:#ifndef __NPC_STONESERVICEMAN_H__ +#define __NPC_STONESERVICEMAN_H__ + +// ϴ +typedef struct _List +{ + char Data[32]; // + struct _List *Next; // ָһList +}List,*LPList; + +BOOL NPC_StoneServiceManInit(int meindex); +void NPC_StoneServiceManLoop(int meindex); +void NPC_StoneServiceManTalked(int meindex,int talkerindex,char *msg,int color); +void NPC_StoneServiceManWindowTalked(int meindex,int talkerindex,int seqno, + int select,char *data); +int SendToAP(int nAid,int nIndex,int nLen,void *Data1,void *Data2); +int RecvFromAP(int *nAid,int nIndex,int *nLen,LPList *Data); +int GetMsg(int meindex); +int ConnectToAP(void); +#endif +0035:npc_storyteller.h:0B9:1:14=48041e4b:16=47d21313:#ifndef _NPC_STORYTELLER_H_ +#define _NPC_STORYTELLER_H_ + +BOOL NPC_StoryTellerInit( int meindex ); +void NPC_StoryTellerTalked( int meindex , int talker , char *msg , int col ); + +#endif + +0031:npc_sysinfo.h:0E4:1:14=48041e4b:16=47d21313:#ifndef __NPC_SYSINFO_H__ +#define __NPC_SYSINFO_H__ + +BOOL NPC_SysinfoInit( int meindex ); +void NPC_SysinfoLoop( int meindex ); +void NPC_SysinfoTalked( int meindex, int tindex, char *msg, int color); +#endif /*__NPC_SYSINFO_H__*/ +0032:npc_timeman.h:0167:1:14=48041e4b:16=47d21313:#ifndef __NPC_TIMEMAN_H__ +#define __NPC_TIMEMAN_H__ + + +void NPC_TimeManTalked( int meindex , int talkerindex , char *msg , + int color ); + +BOOL NPC_TimeManInit( int meindex ); + +void NPC_TimeManWatch( int meobjindex, int objindex, CHAR_ACTION act, + int x,int y,int dir, int* opt,int optlen ); + +#endif /*__NPC_TIMEMAN_H__*/ +0034:npc_townpeople.h:0D1:1:14=48041e4b:16=47d21313:#ifndef __NPC_TOWNPEOPLE_H__ +#define __NPC_TOWNPEOPLE_H__ + +void NPC_TownPeopleTalked( int index, int talker, char *msg, int color ); +void NPC_TownPeopleInit( int meindex ); + +#endif /* __NPC_TOWNPEOPLE_H__ */ +0035:npc_transerman.h:013A:1:14=48041e4b:16=47d21313:#ifndef _TRANSER_MAN_H +#define _TRANSER_MAN_H + +void NPC_TranserManTalked( int meindex, int talkerindex, char *msg, int color ); +BOOL NPC_TranserManInit( int meindex ); +void NPC_TranserManWindowTalked( int meindex, int talkerindex, int seqno, int select, char *data); +void NPC_TranserManLoop( int meindex); + +#endif +0039:npc_transmigration.h:016A:1:14=48041e4b:16=47d21313:#ifndef __NPC_TRANSMIGRATION_H__ +#define __NPC_TRANSMIGRATION_H__ + +void NPC_TransmigrationTalked( int meindex , int talkerindex , char *msg , + int color ); +BOOL NPC_TransmigrationInit( int meindex ); +void NPC_TransmigrationWindowTalked( int meindex, int talkerindex, int seqno, int select, char *data); + +#endif + +/*__NPC_TRANSMIGRATION_H__*/ diff --git a/include/npc_petfusion.h b/include/npc_petfusion.h new file mode 100644 index 0000000..3fbe665 --- /dev/null +++ b/include/npc_petfusion.h @@ -0,0 +1,11 @@ +#ifndef __NPC_PETFUSION_H__ +#define __NPC_PETFUSION_H__ + + +void NPC_PetFusionManTalked( int meindex, int talkerindex, char *msg, int color ); +BOOL NPC_PetFusionManInit( int meindex ); +void NPC_PetFusionManWindowTalked( int meindex, int talkerindex, int seqno, int select, char *data); +void NPC_PetFusionManLoop( int meindex); + +#endif + diff --git a/include/npc_petmaker.h b/include/npc_petmaker.h new file mode 100644 index 0000000..2754e9b --- /dev/null +++ b/include/npc_petmaker.h @@ -0,0 +1,9 @@ +#ifndef __NPC_PETMAKER_H__ +#define __NPC_PETMAKER_H__ + +void NPC_PetMakerTalked( int meindex , int talkerindex , char *msg , + int color ); +BOOL NPC_PetMakerInit( int meindex ); + +#endif + /*__NPC_PETMAKER_H__*/ diff --git a/include/npc_petracemaster.h b/include/npc_petracemaster.h new file mode 100644 index 0000000..c8caa27 --- /dev/null +++ b/include/npc_petracemaster.h @@ -0,0 +1,10 @@ +#ifndef NPC_PetRace_Master_ +#define NPC_PetRace_Master_ + +BOOL NPC_PetRaceMasterInit( int meindex ); +void NPC_PetRaceMasterLoop( int meindex ); +void NPC_PetRaceMasterTalked( int meindex , int talkerindex , char *szMes , int color ); +void NPC_PetRaceMasterWindowTalked(int meindex, int talkerindex, int seqno, int select, char *data); + +#endif + diff --git a/include/npc_petracepet.h b/include/npc_petracepet.h new file mode 100644 index 0000000..f421126 --- /dev/null +++ b/include/npc_petracepet.h @@ -0,0 +1,9 @@ +#ifndef NPC_PetRace_Pet_ +#define NPC_PetRace_Pet_ + +BOOL NPC_PetRacePetInit( int meindex ); +void NPC_PetRacePetLoop( int meindex ); +void NPC_PetRacePetTalked( int meindex , int talkerindex , char *szMes , int color ); + +#endif + diff --git a/include/npc_petshop.h b/include/npc_petshop.h new file mode 100644 index 0000000..7b985ca --- /dev/null +++ b/include/npc_petshop.h @@ -0,0 +1,12 @@ +#ifndef __NPC_PETSHOP_H__ +#define __NPC_PETSHOP_H__ + +void NPC_PetShopTalked( int meindex , int talkerindex , char *msg , + int color ); +BOOL NPC_PetShopInit( int meindex ); +void NPC_PetShopWindowTalked( int meindex, int talkerindex, int seqno, int select, char *data); +void NPC_PetShopLooked( int meindex , int lookedindex); + + +#endif +/*__NPC_PETSHOP_H__*/ diff --git a/include/npc_petskilldelshop.h b/include/npc_petskilldelshop.h new file mode 100644 index 0000000..56654e9 --- /dev/null +++ b/include/npc_petskilldelshop.h @@ -0,0 +1,10 @@ + +void NPC_PetSkillDelShopTalked( int meindex , int talkerindex , char *msg , + int color ); +BOOL NPC_PetSkillDelShopInit( int meindex ); +void NPC_PetSkillDelShopWindowTalked( int meindex, int talkerindex, int seqno, int select, char *data); +void NPC_PetSkillDelShopLooked( int meindex , int lookedindex); + +void NPC_PetSkillDelMakeStr(int meindex,int toindex,int select); + + /*__NPC_WINDOWPETSKILLSHOP_H__*/ diff --git a/include/npc_petskillshop.h b/include/npc_petskillshop.h new file mode 100644 index 0000000..ca603bb --- /dev/null +++ b/include/npc_petskillshop.h @@ -0,0 +1,13 @@ +#ifndef __NPC_PETSKILLSHOP_H__ +#define __NPC_PETSKILLSHOP_H__ + +void NPC_PetSkillShopTalked( int meindex , int talkerindex , char *msg , + int color ); +BOOL NPC_PetSkillShopInit( int meindex ); +void NPC_PetSkillShopWindowTalked( int meindex, int talkerindex, int seqno, int select, char *data); +void NPC_PetSkillShopLooked( int meindex , int lookedindex); + +void NPC_PetSkillMakeStr(int meindex,int toindex,int select); + +#endif + /*__NPC_WINDOWPETSKILLSHOP_H__*/ diff --git a/include/npc_pettransman.h b/include/npc_pettransman.h new file mode 100644 index 0000000..c840706 --- /dev/null +++ b/include/npc_pettransman.h @@ -0,0 +1,11 @@ +#ifndef __NPC_PETTRANSMAN_H__ +#define __NPC_PETTRANSMAN_H__ + +BOOL NPC_PetTransManInit(int meindex); +void NPC_PetTransMan_selectWindow(int meindex,int toindex,int num,int select); +void NPC_PetTransManWindowTalked(int meindex,int talkerindex,int seqno,int select,char *data); +void NPC_PetTransManTalked(int meindex,int talkerindex,char *szMes,int color); +int NPC_PetTransManCheck( int meindex, int toindex, int select); +BOOL NPC_PetTransManStatus( int meindex, int toindex, int petNo); +#endif + /*__NPC_PETTRANSMAN_H__*/ diff --git a/include/npc_pkpetshop.h b/include/npc_pkpetshop.h new file mode 100644 index 0000000..8e29511 --- /dev/null +++ b/include/npc_pkpetshop.h @@ -0,0 +1,297 @@ +0037:npc_poolitemshop.h:0184:1:14=48041e4b:16=47d21313:#ifndef __NPC_POOLITEMSHOP_H__ +#define __NPC_POOLITEMSHOP_H__ + + +void NPC_PoolItemShopLoop( int meindex); +BOOL NPC_PoolItemShopInit( int meindex); +void NPC_PoolItemShopTalked( int meindex , int talkerindex , + char *szMes ,int color ); +void NPC_PoolItemShopWindowTalked( int meindex, int talkerindex, + int seqno, int select, char *data); + + +#endif + /*__NPC_POOLITEMSHOP_H__*/ +002F:npc_quiz.h:02C0:1:14=48041e4b:16=47d21313:#ifndef __NPC_QUIZ_H__ +#define __NPC_QUIZ_H__ + +typedef struct NPC_Quiz{ + + int no; // į + int type; // ءة ̡֭) + int level; // ì + int answertype; //̫( ǩѨ + int answerNo; // + char question[512]; // + char select1[128]; // 1 + char select2[128]; // 2 + char select3[128]; // 3 + +}NPC_QUIZ; + + +void NPC_QuizTalked( int meindex , int talkerindex , char *msg , + int color ); +BOOL NPC_QuizInit( int meindex ); +void NPC_QuizWindowTalked( int meindex, int talkerindex, int seqno, int select, char *data); + +BOOL QUIZ_initQuiz( char *filename); + + +#endif + +/*__NPC_QUIZ_H__*/ +0033:npc_riderman.h:017F:1:14=48041e4b:16=47d21313:#ifndef __NPC_RIDERMAN_H__ +#define __NPC_RIDERMAN_H__ + +void NPC_RidermanTalked( int meindex , int talkerindex , char *msg , + int color ); + +BOOL NPC_RidermanInit( int meindex ); +void NPC_RidermanLooked( int meindex, int lookedindex ); +void NPC_RidermanWindowTalked( int meindex, int talkerindex, int seqno, int select, char *data); + +#endif + /*__NPC_RIDERMAN_H__*/ +0037:npc_roomadminnew.h:03CA:1:14=48041e4b:16=47d21313:#ifndef __NPC_ROOMADMINNEW_H__ +#define __NPC_ROOMADMINNEW_H__ + + +void NPC_RoomAdminNewTalked( int meindex , int talkerindex , char *msg , int color ); +void NPC_RoomAdminNewLoop( int meindex ); +BOOL NPC_RoomAdminNewInit( int meindex ); + +BOOL NPC_RankingInit( int meindex ); +void NPC_RankingTalked( int meindex , int talkerindex , char *msg ,int color ); + +BOOL NPC_PrintpassmanInit( int meindex ); +void NPC_PrintpassmanTalked( int meindex , int talkerindex , char *msg ,int color ); + +typedef struct npc_roomadminnew_tag { + int expire; + char cdkey[CDKEYLEN]; + char charaname[32]; + char passwd[9]; +}NPC_ROOMINFO; + +typedef struct npc_roomadminnew_ranking_tag { + int gold; /* ڿź */ + int biddate; /* ڿ */ + char cdkey[CDKEYLEN]; /* м ƽ */ + char charaname[32]; /* м */ + char owntitle[32]; /* į*/ + +}NPC_RANKING_INFO; + +#endif /*__NPC_ROOMADMINNEW_H__*/ + +BOOL NPC_RoomAdminNew_ReadFile( char *roomname, NPC_ROOMINFO *data); +0030:npc_sample.h:075:1:14=48041e4b:16=47d21313:#ifndef __NPC_SAMPLE_H__ +#define __NPC_SAMPLE_H__ + +void NPC_SampleLoop( int index ); + +#endif + + /*__NPC_SAMPLE_H__*/ +0034:npc_savepoint.h:014F:1:14=48041e4b:16=47d21313:#ifndef __NPC_SAVEPOINT_H__ +#define __NPC_SAVEPOINT_H__ + + +void NPC_SavePointTalked( int meindex , int talkerindex , char *msg , + int color ); + +BOOL NPC_SavePointInit( int meindex ); +void NPC_SavePointWindowTalked( int meindex, int talkerindex, int seqno, int select, char *data); + + +#endif + +/*__NPC_SAVEPOINT_H__*/ +0036:npc_scheduleman.h:0A5A:1:14=48041e4b:16=47d21313:#ifndef __NPC_SCHEDULEMAN_H__ +#define __NPC_SCHEDULEMAN_H__ + +#define CHARNAME_MAX 32 + +// scheduleman +#ifdef _FAMILY_MANORNUM_CHANGE +#define MAX_SCHEDULEMAN 20 +#else +#define MAX_SCHEDULEMAN 12 +#endif + +// ÿһ scheduleman عܵ schedule +#define MAX_SCHEDULE 24 + +// schedule бһҳг +#define MAXSCHEDULEINONEWINDOW 10 + +// family бһҳг +#define MAXFAMILYINONEWINDOW 10 + +// ÿһ scheduleman ʹõ schedule λ +// Ӧ fmpks ID*MAX_SCHEDULE (ID=0~MAX_SCHEDULEMAN-1) +// ID д data/npc ָ "id:" ֵ + +// dueltime = (?10000:0) + (Сʱ*100) + +typedef struct tagFamilyPKSchedule { + int dueltime; // ʱ + int host_index; // Ӽ + char host_name[CHARNAME_MAX]; // Ӽ + int guest_index; // ͶӼ + char guest_name[CHARNAME_MAX]; // ͶӼ + int prepare_time; // ׼ʱ (1~40 ) + int max_player; // (1~) + int flag; // ״̬ + int win; // ʤ趨 + int challenge_timeout; // սʱ + int setting_timeout; // 趨״̬ timeout + char gmsv_name[256]; +} FamilyPKSchedule; + +// ¼ FamilyPKSchedule (fmpks) flag ֵ +#define FMPKS_FLAG_NONE -1 // ûκų +#define FMPKS_FLAG_CHALLENGE 0 // ȴͶͬ +#define FMPKS_FLAG_SETTING 1 // 趨ų (ȡʱ NONE) +#define FMPKS_FLAG_CONFIRMING 2 // Ͷͬ +#define FMPKS_FLAG_SCHEDULED 3 // Ѿźų̣δ +#define FMPKS_FLAG_DUEL 4 // +#define FMPKS_FLAG_HOSTWIN 5 // ʤ +#define FMPKS_FLAG_GUESTWIN 6 // Ͷʤ +#define FMPKS_FLAG_MANOR_BATTLEBEGIN 7 // ׯ԰ս ս +#define FMPKS_FLAG_MANOR_PREPARE 8 // ׯ԰ս ׼ +#define FMPKS_FLAG_MANOR_PEACE 9 // ׯ԰ս ս +#define FMPKS_FLAG_MANOR_OTHERPLANET 10 // ׯ԰ս ڱս +#define FMPKS_FLAG_MANOR_BATTLEEND 11 // ׯ԰ս ս +#define FMPKS_FLAG_MANOR_PEACE_SAVE 12 // ׯ԰ս浵 +#define FMPKS_FLAG_MANOR_READYTOFIGHT 13 // (GM: manorpk) ȫϵɿԼս״̬ +#define FMPKS_FLAG_MANOR_CLEANFLAG 14 // (GM: manorpk) ״̬ +#ifdef _NEW_MANOR_LAW +#define FMPKS_FLAG_WAIT 15 // ս,Ѽ¼,ȴսų +#endif + +// client flag +#define FLAG_NONE -1 +#define FLAG_MODIFY 0 +#define FLAG_ACCEPT 1 +#define FLAG_SETTING 2 +#define FLAG_CONFIRM 3 +#define FLAG_SCHEDULED 4 + +extern FamilyPKSchedule fmpks[MAX_SCHEDULE*MAX_SCHEDULEMAN]; + +BOOL NPC_SchedulemanInit(int meindex); +void NPC_SchedulemanTalked(int meindex, int talkerindex, char *msg, int color); +void NPC_SchedulemanWindowTalked(int meindex, int talkerindex, + int seqno, int select, char *data); +void NPC_SchedulemanLoop(int meindex); + +#endif + +/*__NPC_SCHEDULEMAN_H__*/ +0035:npc_sellsthman.h:013A:1:14=48041e4b:16=47d21313:#ifndef _SELLSTH_MAN_H +#define _SELLSTH_MAN_H + +void NPC_SellsthManTalked( int meindex, int talkerindex, char *msg, int color ); +BOOL NPC_SellsthManInit( int meindex ); +void NPC_SellsthManWindowTalked( int meindex, int talkerindex, int seqno, int select, char *data); +void NPC_SellsthManLoop( int meindex); + +#endif +0034:npc_signboard.h:0124:1:14=48041e4b:16=47d21313:#ifndef __NPC_SIGNBOARD_H__ +#define __NPC_SIGNBOARD_H__ + + +BOOL NPC_SignBoardInit( int meindex ); +void NPC_SignBoardWindowTalked( int meindex, int talkerindex, int seqno, int select, char *data); +void NPC_SignBoardLooked( int meindex , int lookedindex); + + +#endif + /*__NPC_WINDOWSIGNBOAD_H__*/ +0035:npc_simpleshop.h:0176:1:14=48041e4b:16=47d21313:#ifndef __NPC_SIMPLESHOP_H__ +#define __NPC_SIMPLESHOP_H__ + +void NPC_SimpleShopTalked( int index, int talker, char *msg, int color ); +void NPC_SimpleShopSpecialTalked( int index, int talker, char *msg, int color ); +void NPC_LimitBuyInShopSpecialTalked( int index, int talker, char *msg, int color ); +void NPC_SimpleShopInit( int meindex ); + +#endif + /*__NPC_SIMPLESHOP_H__*/ +003A:npc_stoneserviceman.h:02AE:1:14=48041e4b:16=47d21313:#ifndef __NPC_STONESERVICEMAN_H__ +#define __NPC_STONESERVICEMAN_H__ + +// ϴ +typedef struct _List +{ + char Data[32]; // + struct _List *Next; // ָһList +}List,*LPList; + +BOOL NPC_StoneServiceManInit(int meindex); +void NPC_StoneServiceManLoop(int meindex); +void NPC_StoneServiceManTalked(int meindex,int talkerindex,char *msg,int color); +void NPC_StoneServiceManWindowTalked(int meindex,int talkerindex,int seqno, + int select,char *data); +int SendToAP(int nAid,int nIndex,int nLen,void *Data1,void *Data2); +int RecvFromAP(int *nAid,int nIndex,int *nLen,LPList *Data); +int GetMsg(int meindex); +int ConnectToAP(void); +#endif +0035:npc_storyteller.h:0B9:1:14=48041e4b:16=47d21313:#ifndef _NPC_STORYTELLER_H_ +#define _NPC_STORYTELLER_H_ + +BOOL NPC_StoryTellerInit( int meindex ); +void NPC_StoryTellerTalked( int meindex , int talker , char *msg , int col ); + +#endif + +0031:npc_sysinfo.h:0E4:1:14=48041e4b:16=47d21313:#ifndef __NPC_SYSINFO_H__ +#define __NPC_SYSINFO_H__ + +BOOL NPC_SysinfoInit( int meindex ); +void NPC_SysinfoLoop( int meindex ); +void NPC_SysinfoTalked( int meindex, int tindex, char *msg, int color); +#endif /*__NPC_SYSINFO_H__*/ +0032:npc_timeman.h:0167:1:14=48041e4b:16=47d21313:#ifndef __NPC_TIMEMAN_H__ +#define __NPC_TIMEMAN_H__ + + +void NPC_TimeManTalked( int meindex , int talkerindex , char *msg , + int color ); + +BOOL NPC_TimeManInit( int meindex ); + +void NPC_TimeManWatch( int meobjindex, int objindex, CHAR_ACTION act, + int x,int y,int dir, int* opt,int optlen ); + +#endif /*__NPC_TIMEMAN_H__*/ +0034:npc_townpeople.h:0D1:1:14=48041e4b:16=47d21313:#ifndef __NPC_TOWNPEOPLE_H__ +#define __NPC_TOWNPEOPLE_H__ + +void NPC_TownPeopleTalked( int index, int talker, char *msg, int color ); +void NPC_TownPeopleInit( int meindex ); + +#endif /* __NPC_TOWNPEOPLE_H__ */ +0035:npc_transerman.h:013A:1:14=48041e4b:16=47d21313:#ifndef _TRANSER_MAN_H +#define _TRANSER_MAN_H + +void NPC_TranserManTalked( int meindex, int talkerindex, char *msg, int color ); +BOOL NPC_TranserManInit( int meindex ); +void NPC_TranserManWindowTalked( int meindex, int talkerindex, int seqno, int select, char *data); +void NPC_TranserManLoop( int meindex); + +#endif +0039:npc_transmigration.h:016A:1:14=48041e4b:16=47d21313:#ifndef __NPC_TRANSMIGRATION_H__ +#define __NPC_TRANSMIGRATION_H__ + +void NPC_TransmigrationTalked( int meindex , int talkerindex , char *msg , + int color ); +BOOL NPC_TransmigrationInit( int meindex ); +void NPC_TransmigrationWindowTalked( int meindex, int talkerindex, int seqno, int select, char *data); + +#endif + +/*__NPC_TRANSMIGRATION_H__*/ diff --git a/include/npc_poolitemshop.h b/include/npc_poolitemshop.h new file mode 100644 index 0000000..11d7e43 --- /dev/null +++ b/include/npc_poolitemshop.h @@ -0,0 +1,14 @@ +#ifndef __NPC_POOLITEMSHOP_H__ +#define __NPC_POOLITEMSHOP_H__ + + +void NPC_PoolItemShopLoop( int meindex); +BOOL NPC_PoolItemShopInit( int meindex); +void NPC_PoolItemShopTalked( int meindex , int talkerindex , + char *szMes ,int color ); +void NPC_PoolItemShopWindowTalked( int meindex, int talkerindex, + int seqno, int select, char *data); + + +#endif + /*__NPC_POOLITEMSHOP_H__*/ diff --git a/include/npc_quiz.h b/include/npc_quiz.h new file mode 100644 index 0000000..31290c1 --- /dev/null +++ b/include/npc_quiz.h @@ -0,0 +1,29 @@ +#ifndef __NPC_QUIZ_H__ +#define __NPC_QUIZ_H__ + +typedef struct NPC_Quiz{ + + int no; // į + int type; // ءة ̡֭) + int level; // ì + int answertype; //̫( ǩѨ + int answerNo; // + char question[512]; // + char select1[128]; // 1 + char select2[128]; // 2 + char select3[128]; // 3 + +}NPC_QUIZ; + + +void NPC_QuizTalked( int meindex , int talkerindex , char *msg , + int color ); +BOOL NPC_QuizInit( int meindex ); +void NPC_QuizWindowTalked( int meindex, int talkerindex, int seqno, int select, char *data); + +BOOL QUIZ_initQuiz( char *filename); + + +#endif + +/*__NPC_QUIZ_H__*/ diff --git a/include/npc_riderman.h b/include/npc_riderman.h new file mode 100644 index 0000000..bfaa48f --- /dev/null +++ b/include/npc_riderman.h @@ -0,0 +1,12 @@ +#ifndef __NPC_RIDERMAN_H__ +#define __NPC_RIDERMAN_H__ + +void NPC_RidermanTalked( int meindex , int talkerindex , char *msg , + int color ); + +BOOL NPC_RidermanInit( int meindex ); +void NPC_RidermanLooked( int meindex, int lookedindex ); +void NPC_RidermanWindowTalked( int meindex, int talkerindex, int seqno, int select, char *data); + +#endif + /*__NPC_RIDERMAN_H__*/ diff --git a/include/npc_rmbshop.h b/include/npc_rmbshop.h new file mode 100644 index 0000000..68c3406 --- /dev/null +++ b/include/npc_rmbshop.h @@ -0,0 +1,4 @@ +void NPC_RmbshopTalked( int meindex, int talkerindex, char *msg, int color ); +BOOL NPC_RmbshopInit( int meindex ); +void NPC_RmbshopWindowTalked( int meindex, int talkerindex, int seqno, int select, char *data); +void NPC_RmbshopLoop( int meindex); diff --git a/include/npc_roomadminnew.h b/include/npc_roomadminnew.h new file mode 100644 index 0000000..a89c700 --- /dev/null +++ b/include/npc_roomadminnew.h @@ -0,0 +1,33 @@ +#ifndef __NPC_ROOMADMINNEW_H__ +#define __NPC_ROOMADMINNEW_H__ + + +void NPC_RoomAdminNewTalked( int meindex , int talkerindex , char *msg , int color ); +void NPC_RoomAdminNewLoop( int meindex ); +BOOL NPC_RoomAdminNewInit( int meindex ); + +BOOL NPC_RankingInit( int meindex ); +void NPC_RankingTalked( int meindex , int talkerindex , char *msg ,int color ); + +BOOL NPC_PrintpassmanInit( int meindex ); +void NPC_PrintpassmanTalked( int meindex , int talkerindex , char *msg ,int color ); + +typedef struct npc_roomadminnew_tag { + int expire; + char cdkey[CDKEYLEN]; + char charaname[32]; + char passwd[9]; +}NPC_ROOMINFO; + +typedef struct npc_roomadminnew_ranking_tag { + int gold; /* ڿź */ + int biddate; /* ڿ */ + char cdkey[CDKEYLEN]; /* м ƽ */ + char charaname[32]; /* м */ + char owntitle[32]; /* į*/ + +}NPC_RANKING_INFO; + +#endif /*__NPC_ROOMADMINNEW_H__*/ + +BOOL NPC_RoomAdminNew_ReadFile( char *roomname, NPC_ROOMINFO *data); diff --git a/include/npc_sample.h b/include/npc_sample.h new file mode 100644 index 0000000..b648598 --- /dev/null +++ b/include/npc_sample.h @@ -0,0 +1,8 @@ +#ifndef __NPC_SAMPLE_H__ +#define __NPC_SAMPLE_H__ + +void NPC_SampleLoop( int index ); + +#endif + + /*__NPC_SAMPLE_H__*/ diff --git a/include/npc_savepoint.h b/include/npc_savepoint.h new file mode 100644 index 0000000..80edab6 --- /dev/null +++ b/include/npc_savepoint.h @@ -0,0 +1,14 @@ +#ifndef __NPC_SAVEPOINT_H__ +#define __NPC_SAVEPOINT_H__ + + +void NPC_SavePointTalked( int meindex , int talkerindex , char *msg , + int color ); + +BOOL NPC_SavePointInit( int meindex ); +void NPC_SavePointWindowTalked( int meindex, int talkerindex, int seqno, int select, char *data); + + +#endif + +/*__NPC_SAVEPOINT_H__*/ diff --git a/include/npc_scheduleman.h b/include/npc_scheduleman.h new file mode 100644 index 0000000..fd23c3a --- /dev/null +++ b/include/npc_scheduleman.h @@ -0,0 +1,82 @@ +#ifndef __NPC_SCHEDULEMAN_H__ +#define __NPC_SCHEDULEMAN_H__ + +#define CHARNAME_MAX 32 + +// scheduleman +#ifdef _FAMILY_MANORNUM_CHANGE +#define MAX_SCHEDULEMAN 20 +#else +#define MAX_SCHEDULEMAN 12 +#endif + +// ÿһ scheduleman عܵ schedule +#define MAX_SCHEDULE 24 + +// schedule бһҳг +#define MAXSCHEDULEINONEWINDOW 10 + +// family бһҳг +#define MAXFAMILYINONEWINDOW 10 + +// ÿһ scheduleman ʹõ schedule λ +// Ӧ fmpks ID*MAX_SCHEDULE (ID=0~MAX_SCHEDULEMAN-1) +// ID д data/npc ָ "id:" ֵ + +// dueltime = (?10000:0) + (Сʱ*100) + +typedef struct tagFamilyPKSchedule { + int dueltime; // ʱ + int host_index; // Ӽ + char host_name[CHARNAME_MAX]; // Ӽ + int guest_index; // ͶӼ + char guest_name[CHARNAME_MAX]; // ͶӼ + int prepare_time; // ׼ʱ (1~40 ) + int max_player; // (1~) + int flag; // ״̬ + int win; // ʤ趨 + int challenge_timeout; // սʱ + int setting_timeout; // 趨״̬ timeout + char gmsv_name[256]; +} FamilyPKSchedule; + +// ¼ FamilyPKSchedule (fmpks) flag ֵ +#define FMPKS_FLAG_NONE -1 // ûκų +#define FMPKS_FLAG_CHALLENGE 0 // ȴͶͬ +#define FMPKS_FLAG_SETTING 1 // 趨ų (ȡʱ NONE) +#define FMPKS_FLAG_CONFIRMING 2 // Ͷͬ +#define FMPKS_FLAG_SCHEDULED 3 // Ѿźų̣δ +#define FMPKS_FLAG_DUEL 4 // +#define FMPKS_FLAG_HOSTWIN 5 // ʤ +#define FMPKS_FLAG_GUESTWIN 6 // Ͷʤ +#define FMPKS_FLAG_MANOR_BATTLEBEGIN 7 // ׯ԰ս ս +#define FMPKS_FLAG_MANOR_PREPARE 8 // ׯ԰ս ׼ +#define FMPKS_FLAG_MANOR_PEACE 9 // ׯ԰ս ս +#define FMPKS_FLAG_MANOR_OTHERPLANET 10 // ׯ԰ս ڱս +#define FMPKS_FLAG_MANOR_BATTLEEND 11 // ׯ԰ս ս +#define FMPKS_FLAG_MANOR_PEACE_SAVE 12 // ׯ԰ս浵 +#define FMPKS_FLAG_MANOR_READYTOFIGHT 13 // (GM: manorpk) ȫϵɿԼս״̬ +#define FMPKS_FLAG_MANOR_CLEANFLAG 14 // (GM: manorpk) ״̬ +#ifdef _NEW_MANOR_LAW +#define FMPKS_FLAG_WAIT 15 // ս,Ѽ¼,ȴսų +#endif + +// client flag +#define FLAG_NONE -1 +#define FLAG_MODIFY 0 +#define FLAG_ACCEPT 1 +#define FLAG_SETTING 2 +#define FLAG_CONFIRM 3 +#define FLAG_SCHEDULED 4 + +extern FamilyPKSchedule fmpks[MAX_SCHEDULE*MAX_SCHEDULEMAN]; + +BOOL NPC_SchedulemanInit(int meindex); +void NPC_SchedulemanTalked(int meindex, int talkerindex, char *msg, int color); +void NPC_SchedulemanWindowTalked(int meindex, int talkerindex, + int seqno, int select, char *data); +void NPC_SchedulemanLoop(int meindex); + +#endif + +/*__NPC_SCHEDULEMAN_H__*/ diff --git a/include/npc_sellsthman.h b/include/npc_sellsthman.h new file mode 100644 index 0000000..6ce6165 --- /dev/null +++ b/include/npc_sellsthman.h @@ -0,0 +1,9 @@ +#ifndef _SELLSTH_MAN_H +#define _SELLSTH_MAN_H + +void NPC_SellsthManTalked( int meindex, int talkerindex, char *msg, int color ); +BOOL NPC_SellsthManInit( int meindex ); +void NPC_SellsthManWindowTalked( int meindex, int talkerindex, int seqno, int select, char *data); +void NPC_SellsthManLoop( int meindex); + +#endif diff --git a/include/npc_signboard.h b/include/npc_signboard.h new file mode 100644 index 0000000..ed96680 --- /dev/null +++ b/include/npc_signboard.h @@ -0,0 +1,11 @@ +#ifndef __NPC_SIGNBOARD_H__ +#define __NPC_SIGNBOARD_H__ + + +BOOL NPC_SignBoardInit( int meindex ); +void NPC_SignBoardWindowTalked( int meindex, int talkerindex, int seqno, int select, char *data); +void NPC_SignBoardLooked( int meindex , int lookedindex); + + +#endif + /*__NPC_WINDOWSIGNBOAD_H__*/ diff --git a/include/npc_simpleshop.h b/include/npc_simpleshop.h new file mode 100644 index 0000000..3b0da80 --- /dev/null +++ b/include/npc_simpleshop.h @@ -0,0 +1,10 @@ +#ifndef __NPC_SIMPLESHOP_H__ +#define __NPC_SIMPLESHOP_H__ + +void NPC_SimpleShopTalked( int index, int talker, char *msg, int color ); +void NPC_SimpleShopSpecialTalked( int index, int talker, char *msg, int color ); +void NPC_LimitBuyInShopSpecialTalked( int index, int talker, char *msg, int color ); +void NPC_SimpleShopInit( int meindex ); + +#endif + /*__NPC_SIMPLESHOP_H__*/ diff --git a/include/npc_stoneserviceman.h b/include/npc_stoneserviceman.h new file mode 100644 index 0000000..9d9feb1 --- /dev/null +++ b/include/npc_stoneserviceman.h @@ -0,0 +1,20 @@ +#ifndef __NPC_STONESERVICEMAN_H__ +#define __NPC_STONESERVICEMAN_H__ + +// ϴ +typedef struct _List +{ + char Data[32]; // + struct _List *Next; // ָһList +}List,*LPList; + +BOOL NPC_StoneServiceManInit(int meindex); +void NPC_StoneServiceManLoop(int meindex); +void NPC_StoneServiceManTalked(int meindex,int talkerindex,char *msg,int color); +void NPC_StoneServiceManWindowTalked(int meindex,int talkerindex,int seqno, + int select,char *data); +int SendToAP(int nAid,int nIndex,int nLen,void *Data1,void *Data2); +int RecvFromAP(int *nAid,int nIndex,int *nLen,LPList *Data); +int GetMsg(int meindex); +int ConnectToAP(void); +#endif diff --git a/include/npc_storyteller.h b/include/npc_storyteller.h new file mode 100644 index 0000000..a8a17cf --- /dev/null +++ b/include/npc_storyteller.h @@ -0,0 +1,8 @@ +#ifndef _NPC_STORYTELLER_H_ +#define _NPC_STORYTELLER_H_ + +BOOL NPC_StoryTellerInit( int meindex ); +void NPC_StoryTellerTalked( int meindex , int talker , char *msg , int col ); + +#endif + diff --git a/include/npc_stushop.h b/include/npc_stushop.h new file mode 100644 index 0000000..b9ebff2 --- /dev/null +++ b/include/npc_stushop.h @@ -0,0 +1,9 @@ +#ifndef _STU_SHOP_H +#define _STU_SHOP_H + +void NPC_StushopTalked( int meindex, int talkerindex, char *msg, int color ); +BOOL NPC_StushopInit( int meindex ); +void NPC_StushopWindowTalked( int meindex, int talkerindex, int seqno, int select, char *data); +void NPC_StushopLoop( int meindex); + +#endif diff --git a/include/npc_sysinfo.h b/include/npc_sysinfo.h new file mode 100644 index 0000000..37b6b4b --- /dev/null +++ b/include/npc_sysinfo.h @@ -0,0 +1,7 @@ +#ifndef __NPC_SYSINFO_H__ +#define __NPC_SYSINFO_H__ + +BOOL NPC_SysinfoInit( int meindex ); +void NPC_SysinfoLoop( int meindex ); +void NPC_SysinfoTalked( int meindex, int tindex, char *msg, int color); +#endif /*__NPC_SYSINFO_H__*/ diff --git a/include/npc_timeman.h b/include/npc_timeman.h new file mode 100644 index 0000000..0611141 --- /dev/null +++ b/include/npc_timeman.h @@ -0,0 +1,13 @@ +#ifndef __NPC_TIMEMAN_H__ +#define __NPC_TIMEMAN_H__ + + +void NPC_TimeManTalked( int meindex , int talkerindex , char *msg , + int color ); + +BOOL NPC_TimeManInit( int meindex ); + +void NPC_TimeManWatch( int meobjindex, int objindex, CHAR_ACTION act, + int x,int y,int dir, int* opt,int optlen ); + +#endif /*__NPC_TIMEMAN_H__*/ diff --git a/include/npc_townpeople.h b/include/npc_townpeople.h new file mode 100644 index 0000000..745317b --- /dev/null +++ b/include/npc_townpeople.h @@ -0,0 +1,7 @@ +#ifndef __NPC_TOWNPEOPLE_H__ +#define __NPC_TOWNPEOPLE_H__ + +void NPC_TownPeopleTalked( int index, int talker, char *msg, int color ); +void NPC_TownPeopleInit( int meindex ); + +#endif /* __NPC_TOWNPEOPLE_H__ */ diff --git a/include/npc_transerman.h b/include/npc_transerman.h new file mode 100644 index 0000000..2acca4e --- /dev/null +++ b/include/npc_transerman.h @@ -0,0 +1,9 @@ +#ifndef _TRANSER_MAN_H +#define _TRANSER_MAN_H + +void NPC_TranserManTalked( int meindex, int talkerindex, char *msg, int color ); +BOOL NPC_TranserManInit( int meindex ); +void NPC_TranserManWindowTalked( int meindex, int talkerindex, int seqno, int select, char *data); +void NPC_TranserManLoop( int meindex); + +#endif diff --git a/include/npc_transmigration.h b/include/npc_transmigration.h new file mode 100644 index 0000000..b5040fe --- /dev/null +++ b/include/npc_transmigration.h @@ -0,0 +1,11 @@ +#ifndef __NPC_TRANSMIGRATION_H__ +#define __NPC_TRANSMIGRATION_H__ + +void NPC_TransmigrationTalked( int meindex , int talkerindex , char *msg , + int color ); +BOOL NPC_TransmigrationInit( int meindex ); +void NPC_TransmigrationWindowTalked( int meindex, int talkerindex, int seqno, int select, char *data); + +#endif + +/*__NPC_TRANSMIGRATION_H__*/ diff --git a/include/npc_verywelfare.h b/include/npc_verywelfare.h new file mode 100644 index 0000000..af1c468 --- /dev/null +++ b/include/npc_verywelfare.h @@ -0,0 +1,80 @@ +0034:npc_vigorshop.h:013D:1:14=48041e4b:16=47d21313: +void NPC_ItemVigorShopTalked( int meindex , int talkerindex , char *msg , + int color ); +BOOL NPC_ItemVigorShopInit( int meindex ); +void NPC_ItemVigorShopWindowTalked( int meindex, int talkerindex, int seqno, int select, char *data); +void NPC_ItemVigorShopLooked( int meindex , int lookedindex); + +0038:npc_vigorshop.h.bak:017F:1:14=48041e4b:16=47d21313:#ifndef __NPC_ITEMSHOP_H__ +#define __NPC_ITEMSHOP_H__ + +void NPC_ItemShopTalked( int meindex , int talkerindex , char *msg , + int color ); +BOOL NPC_ItemShopInit( int meindex ); +void NPC_ItemShopWindowTalked( int meindex, int talkerindex, int seqno, int select, char *data); +void NPC_ItemShopLooked( int meindex , int lookedindex); + + +#endif + /*__NPC_ITEMSHOP_H__*/ +0033:npc_vippoint.h:0128:1:14=48041e4b:16=47d21313:#ifndef _VIP_SHOP_H +#define _VIP_SHOP_H + +void NPC_VipshopTalked( int meindex, int talkerindex, char *msg, int color ); +BOOL NPC_VipshopInit( int meindex ); +void NPC_VipshopWindowTalked( int meindex, int talkerindex, int seqno, int select, char *data); +void NPC_VipshopLoop( int meindex); + +#endif +0032:npc_vipshop.h:0128:1:14=48041e4b:16=47d21313:#ifndef _VIP_SHOP_H +#define _VIP_SHOP_H + +void NPC_VipshopTalked( int meindex, int talkerindex, char *msg, int color ); +BOOL NPC_VipshopInit( int meindex ); +void NPC_VipshopWindowTalked( int meindex, int talkerindex, int seqno, int select, char *data); +void NPC_VipshopLoop( int meindex); + +#endif +002F:npc_warp.h:019C:1:14=48041e4b:16=47d21313:#ifndef __NPC_WARP_H__ +#define __NPC_WARP_H__ +BOOL NPC_WarpInit( int charaindex ); +void NPC_WarpPostOver( int meindex,int charaindex ); +void NPC_WarpWatch( int meobjindex, int objindex, CHAR_ACTION act, + int x,int y,int dir, int* opt,int optlen ); +int NPC_WarpSearchByPosition( int fl , int x, int y); +void NPC_WarpWarpCharacter( int warpnpcindex, int charaindex ); +#endif + /*__NPC_WARP_H__*/ +0032:npc_warpman.h:021D:1:14=48041e4b:16=47d21313:#ifndef __NPC_WARPMAN_H__ +#define __NPC_WARPMAN_H__ + +void NPC_WarpManTalked( int meindex , int talkerindex , char *msg , + int color ); +BOOL NPC_WarpManInit( int meindex ); +void NPC_WarpManWindowTalked( int meindex, int talkerindex, int seqno, int select, char *data); +void NPC_GetDuelRank(int rank,int msgid,int msgid2); +void NPC_WarpManLoop( int meindex); +void NPC_WarpManWatch( int meobjindex, int objindex, CHAR_ACTION act, + int x,int y,int dir, int* opt,int optlen ); +#endif +/*__NPC_WARPMAN_H__*/ +0032:npc_welfare.h:0149:1:14=48041e4b:16=47d21313:#ifndef __NPC_WELFARE_H__ +#define __NPC_WELFARE_H__ + +BOOL NPC_WelfareInit( int meindex ); +void NPC_WelfareTalked( int meindex , int talker , char *msg ,int color ); +void NPC_WelfareWindowTalked(int meindex, int talkerindex, int seqno, int select,char *data); +void NPC_WelfareMakeStr(int meindex,int toindex,int select); + + +#endif +0033:npc_welfare2.h:014E:1:14=48041e4b:16=47d21313:#ifndef __NPC_WELFARE2_H__ +#define __NPC_WELFARE2_H__ + +BOOL NPC_WelfareInit2( int meindex ); +void NPC_WelfareTalked2( int meindex , int talker , char *msg ,int color ); +void NPC_WelfareWindowTalked2(int meindex, int talkerindex, int seqno, int select,char *data); +void NPC_WelfareMakeStr2(int meindex,int toindex,int select); + +#endif +0037:npc_windowhealer.h:019A:1:14=48041e4b:16=47d21313: \ No newline at end of file diff --git a/include/npc_vigorshop.h b/include/npc_vigorshop.h new file mode 100644 index 0000000..4c38453 --- /dev/null +++ b/include/npc_vigorshop.h @@ -0,0 +1,7 @@ + +void NPC_ItemVigorShopTalked( int meindex , int talkerindex , char *msg , + int color ); +BOOL NPC_ItemVigorShopInit( int meindex ); +void NPC_ItemVigorShopWindowTalked( int meindex, int talkerindex, int seqno, int select, char *data); +void NPC_ItemVigorShopLooked( int meindex , int lookedindex); + diff --git a/include/npc_vipshop.h b/include/npc_vipshop.h new file mode 100644 index 0000000..01133ff --- /dev/null +++ b/include/npc_vipshop.h @@ -0,0 +1,9 @@ +#ifndef _VIP_SHOP_H +#define _VIP_SHOP_H + +void NPC_VipshopTalked( int meindex, int talkerindex, char *msg, int color ); +BOOL NPC_VipshopInit( int meindex ); +void NPC_VipshopWindowTalked( int meindex, int talkerindex, int seqno, int select, char *data); +void NPC_VipshopLoop( int meindex); + +#endif diff --git a/include/npc_warp.h b/include/npc_warp.h new file mode 100644 index 0000000..4caafbc --- /dev/null +++ b/include/npc_warp.h @@ -0,0 +1,10 @@ +#ifndef __NPC_WARP_H__ +#define __NPC_WARP_H__ +BOOL NPC_WarpInit( int charaindex ); +void NPC_WarpPostOver( int meindex,int charaindex ); +void NPC_WarpWatch( int meobjindex, int objindex, CHAR_ACTION act, + int x,int y,int dir, int* opt,int optlen ); +int NPC_WarpSearchByPosition( int fl , int x, int y); +void NPC_WarpWarpCharacter( int warpnpcindex, int charaindex ); +#endif + /*__NPC_WARP_H__*/ diff --git a/include/npc_warpman.h b/include/npc_warpman.h new file mode 100644 index 0000000..ee48e0a --- /dev/null +++ b/include/npc_warpman.h @@ -0,0 +1,13 @@ +#ifndef __NPC_WARPMAN_H__ +#define __NPC_WARPMAN_H__ + +void NPC_WarpManTalked( int meindex , int talkerindex , char *msg , + int color ); +BOOL NPC_WarpManInit( int meindex ); +void NPC_WarpManWindowTalked( int meindex, int talkerindex, int seqno, int select, char *data); +void NPC_GetDuelRank(int rank,int msgid,int msgid2); +void NPC_WarpManLoop( int meindex); +void NPC_WarpManWatch( int meobjindex, int objindex, CHAR_ACTION act, + int x,int y,int dir, int* opt,int optlen ); +#endif +/*__NPC_WARPMAN_H__*/ diff --git a/include/npc_welfare.h b/include/npc_welfare.h new file mode 100644 index 0000000..4aa9037 --- /dev/null +++ b/include/npc_welfare.h @@ -0,0 +1,10 @@ +#ifndef __NPC_WELFARE_H__ +#define __NPC_WELFARE_H__ + +BOOL NPC_WelfareInit( int meindex ); +void NPC_WelfareTalked( int meindex , int talker , char *msg ,int color ); +void NPC_WelfareWindowTalked(int meindex, int talkerindex, int seqno, int select,char *data); +void NPC_WelfareMakeStr(int meindex,int toindex,int select); + + +#endif diff --git a/include/npc_welfare2.h b/include/npc_welfare2.h new file mode 100644 index 0000000..0bbb309 --- /dev/null +++ b/include/npc_welfare2.h @@ -0,0 +1,9 @@ +#ifndef __NPC_WELFARE2_H__ +#define __NPC_WELFARE2_H__ + +BOOL NPC_WelfareInit2( int meindex ); +void NPC_WelfareTalked2( int meindex , int talker , char *msg ,int color ); +void NPC_WelfareWindowTalked2(int meindex, int talkerindex, int seqno, int select,char *data); +void NPC_WelfareMakeStr2(int meindex,int toindex,int select); + +#endif diff --git a/include/npc_windowhealer.h b/include/npc_windowhealer.h new file mode 100644 index 0000000..2c8f62a --- /dev/null +++ b/include/npc_windowhealer.h @@ -0,0 +1,11 @@ +#ifndef __NPC_WINDOWHEALER_H__ +#define __NPC_WINDOWHEALER_H__ + +void NPC_WindowHealerTalked( int meindex , int talkerindex , char *msg , + int color ); +BOOL NPC_WindowHealerInit( int meindex ); +void NPC_WindowHealerWindowTalked( int meindex, int talkerindex, int seqno, int select, char *data); +void NPC_WindowHealerLooked( int meindex , int lookedindex); + +#endif + /*__NPC_WINDOWHEALER_H__*/ diff --git a/include/npc_windowman.h b/include/npc_windowman.h new file mode 100644 index 0000000..3cf1dde --- /dev/null +++ b/include/npc_windowman.h @@ -0,0 +1,16 @@ +#ifndef __NPC_WINDOWMAN_H__ +#define __NPC_WINDOWMAN_H__ + +void NPC_WindowmanTalked( int meindex , int talkerindex , char *msg , + int color ); + +BOOL NPC_WindowmanInit( int meindex ); +void NPC_WindowmanLooked( int meindex, int lookedindex ); +void NPC_WindowmanWindowTalked( int meindex, int talkerindex, int seqno, int select, char *data); + +void NPC_Windowman_selectWindow( int meindex, int toindex, int num); +BOOL NPC_Windowman_readData( int meindex, int windowno, BOOL chkflg); +int NPC_Windowman_restoreButtontype( char *data ); + +#endif +/*__NPC_WINDOWMAN_H__*/ diff --git a/include/npccreate.h b/include/npccreate.h new file mode 100644 index 0000000..7109410 --- /dev/null +++ b/include/npccreate.h @@ -0,0 +1,93 @@ +#ifndef __READNPCCREATE_H__ +#define __READNPCCREATE_H__ + +#include "util.h" + +#define NPC_CREATEFILEMAGIC "NPCCREATE\n" + + +#undef EXTERN +#ifdef __NPCCREATE__ +#define EXTERN +#else +#define EXTERN extern +#endif /*__NPCCREATE__*/ + + +typedef enum +{ + NPC_CREATEFLOORID, /* ׷ʧID */ + NPC_CREATEBORNLEFTUPX, /* X */ + NPC_CREATEBORNLEFTUPY, /* Y */ + NPC_CREATEBORNRIGHTDOWNX, /* ƱX */ + NPC_CREATEBORNRIGHTDOWNY, /* ƱY */ + + NPC_CREATEMOVELEFTUPX, /* X */ + NPC_CREATEMOVELEFTUPY, /* Y */ + NPC_CREATEMOVERIGHTDOWNX, /* ƱX */ + NPC_CREATEMOVERIGHTDOWNY, /* ƱY */ + + NPC_CREATEDIR, /* ݼ */ + NPC_CREATEBASEIMAGENUMBER, /* template ɬë̤ + į */ + NPC_CREATETIME, /* */ + NPC_CREATEBORNNUM, /* ؽ */ + + NPC_CREATEENEMYNUM, /* ļ */ + NPC_CREATEBOUNDARY, + NPC_CREATEDATE, + NPC_CREATEIGNOREINVINCIBLE, + NPC_CREATEFAMILY, // Robin 0731 Family +#ifdef _ADD_ACTION //jeffrey 1231 npcaction + NPC_CREATEACTION, +#endif + NPC_CREATEINTNUM, + +}NPC_CREATEINT; + +typedef enum +{ + NPC_CREATENAME, /* templateë̤¾ľئ */ + NPC_CREATECHARNUM, +}NPC_CREATECHAR; + + +typedef enum +{ + NPC_CREATEWORKENEMYNUM, + NPC_CREATEWORKMAKESTARTSEC, + NPC_CREATEWORKMAKESTARTUSEC, + NPC_CREATEWORKNEVERMAKE, + NPC_CREATEWORKNUM, + +}NPC_CREATEWORK; + +typedef struct tagNPC_Create +{ + int intdata[NPC_CREATEINTNUM]; + STRING64 chardata[NPC_CREATECHARNUM]; + int workdata[NPC_CREATEWORKNUM]; + int templateindex[8]; + STRING64 arg[8]; +}NPC_Create; + + +EXTERN NPC_Create* NPC_create; +EXTERN int NPC_createnum; +EXTERN int NPC_create_readindex; + +INLINE int NPC_CHECKCREATEINDEX(int index); + +BOOL NPC_isBoundarySet( int createindex ); +BOOL NPC_createGetRECT( int createindex,RECT* r ); +BOOL NPC_readNPCCreateFiles( char* topdirectory ,int createsize); +int NPC_getCreateInt( int index , NPC_CREATEINT element ); + +BOOL NPC_createCheckGenerateFromTime( int tindex ); +void NPC_createInitTime( int index ); +void NPC_createIncreaseEnemynum( int index ); +void NPC_createDecreaseEnemynum( int index ); +BOOL NPC_createCheckMaxEnemynum( int index ); + +#endif +/*__READNPCCREATE_H__*/ diff --git a/include/npcgen.h b/include/npcgen.h new file mode 100644 index 0000000..f7ab71a --- /dev/null +++ b/include/npcgen.h @@ -0,0 +1,13 @@ +#ifndef __NPCGEN_H__ +#define __NPCGEN_H__ + + +void NPC_generateLoop( BOOL FlgInit ); + +EXTERN int all_nosee; /* ༰ݣ廯ë no_see */ +EXTERN int all_nobody; /* ༰ݣ廯ë no_body */ +EXTERN int one_loop_born; /* ƥ Ϸ oneloop_born */ + + +#endif +/*__NPCGEN_H__*/ diff --git a/include/npcserver.h b/include/npcserver.h new file mode 100644 index 0000000..2798a55 --- /dev/null +++ b/include/npcserver.h @@ -0,0 +1,38 @@ +#ifndef _NPCSERVER_H +#define _NPCSERVER_H + + +int NSproto_DispatchMessage(int fd,char* encoded); +int connectNpcServer(char* hostname,unsigned short port); +void NPCS_SendProbe( int fd); + +typedef struct _NPCMessCommand +{ + char buf[4096]; + int len; + struct _NPCMessCommand *next; +}NPCMessC; + +BOOL NPCMESS_setChar( char *buf); +BOOL NPCMESS_getChar( char *buf, int len); +NPCMessC *MESS_getNew(); + + +void NPCS_AskNpcList_recv( int fd, char *Nlist); +void NPCS_AskNpcList_send( int fd); + +void NPCS_NpcSLogin_recv( int fd, char *Mess); +void NPCS_NpcSLogin_send( int fd); + +void NPCS_AskNpcTalk_send( int objindex, int npcsindex, int charaindex, char *Nlist); + +void NPCS_NpcTalkMess_recv( int npcobjindex, int charaindex, int charobjindex, char *TalkMess, int Color); +void NPCS_NpcWinMess_recv( int npcobjindex, int charaindex, int charobjindex, char *WinMess, + int seqno, int windowtype, int buttontype, int page); +void NPCS_NpcWinMess_send( int npcobjindex, int npcindex, int charaindex, char *WinMess, + int seqno, int select); +void NPCS_NpcCheckFreeMess_recv( int npcobjindex, int charaindex, int charobjindex, + char *CheckfreeMess); + +#endif + diff --git a/include/npcshandle.h b/include/npcshandle.h new file mode 100644 index 0000000..f4ad347 --- /dev/null +++ b/include/npcshandle.h @@ -0,0 +1,198 @@ +0032:npctemplate.h:0DDE:1:14=48041e4b:16=47d21313:#ifndef __READNPCTEMPLATE_H__ +#define __READNPCTEMPLATE_H__ + +#include "util.h" +#include "char_base.h" + +#define NPC_TEMPLATEFILEMAGIC "NPCTEMPLATE\n" + +#undef EXTERN +#ifdef __NPCTEMPLATE__ +#define EXTERN +#else +#define EXTERN extern +#endif /*__NPCTEMPLATE__*/ + + + +typedef struct tagNPC_haveItem +{ + int itemnumber; + int haverate; + int havenum; +}NPC_haveItem; + +typedef enum +{ + NPC_TEMPLATENAME, /* */ + NPC_TEMPLATECHARNAME, /* */ + + NPC_TEMPLATEINITFUNC, /* CHAR_INITFUNC */ + NPC_TEMPLATEWALKPREFUNC, /* CHAR_WALKPREFUNC */ + NPC_TEMPLATEWALKPOSTFUNC, /* CHAR_WALKPOSTFUNC */ + NPC_TEMPLATEPREOVERFUNC, /* CHAR_PREOVERFUNC */ + NPC_TEMPLATEPOSTOVERFUNC, /* CHAR_POSTOVERFUNC */ + NPC_TEMPLATEWATCHFUNC, /* CHAR_WATCHFUNC */ + NPC_TEMPLATELOOPFUNC, /* CHAR_LOOPFUNC */ + NPC_TEMPLATEDYINGFUNC, /* CHAR_DYINGFUNC */ + NPC_TEMPLATETALKEDFUNC, /* CHAR_TALKEDFUNC */ + + NPC_TEMPLATEPREATTACKEDFUNC, /* CHAR_PREATTACKEDFUNC */ + NPC_TEMPLATEPOSTATTACKEDFUNC, /* CHAR_POSTATTACKEDFUNC */ + + NPC_TEMPLATEOFFFUNC, /* CHAR_OFFFUNC */ + NPC_TEMPLATELOOKEDFUNC, /* CHAR_LOOKEDFUNC */ + NPC_TEMPLATEITEMPUTFUNC, /* CHAR_ITEMPUTFUNC */ + + NPC_TEMPLATESPECIALTALKEDFUNC, /* CHAR_SPECIALTALKEDFUNC */ + NPC_TEMPLATEWINDOWTALKEDFUNC, /* CHAR_WINDOWTALKEDFUNC */ +#ifdef _USER_CHARLOOPS + NPC_TEMPLATELOOPFUNCTEMP1, //CHAR_LOOPFUNCTEMP1, + NPC_TEMPLATELOOPFUNCTEMP2, //CHAR_LOOPFUNCTEMP2, + NPC_TEMPLATEBATTLEPROPERTY, //CHAR_BATTLEPROPERTY, +#endif + NPC_TEMPLATECHARNUM, +}NPC_TEMPLATECHAR; + +typedef enum +{ + NPC_TEMPLATEMAKEATNOBODY, /* ئݱ¾ */ + NPC_TEMPLATEMAKEATNOSEE, /* έئƥ¾ */ + NPC_TEMPLATEIMAGENUMBER, /* į */ + NPC_TEMPLATETYPE, /* 裻ݱ裻 */ + + NPC_TEMPLATEMINHP, /* HP */ + + NPC_TEMPLATEMINMP, /* MP */ + + NPC_TEMPLATEMINSTR, /* STR */ + + NPC_TEMPLATEMINTOUGH, /* TOUGH */ + + NPC_TEMPLATEISFLYING, /* ƥ¾ */ + + NPC_TEMPLATEITEMNUM, /* еʧ ة */ + + NPC_TEMPLATELOOPFUNCTIME, /* + * + * ëپ + */ + NPC_TEMPLATEFUNCTIONINDEX, /* + * fucntionSet + * ̼͵ + */ + + NPC_TEMPLATEINTNUM, +}NPC_TEMPLATEINT; + +typedef struct tagNPC_Template +{ + STRING64 chardata[NPC_TEMPLATECHARNUM]; + int intdata[NPC_TEMPLATEINTNUM]; + int randomdata[NPC_TEMPLATEINTNUM]; /* ¼ĸة + Ȼ */ + int hash; + NPC_haveItem* haveitem; +}NPC_Template; + + +EXTERN NPC_Template* NPC_template; +EXTERN int NPC_templatenum; +EXTERN int NPC_template_readindex; + +INLINE int NPC_CHECKTEMPLATEINDEX(int index); + +BOOL NPC_copyFunctionSetToChar( int id, Char* ch ); + +BOOL NPC_readNPCTemplateFiles( char* topdirectory ,int templatesize); +int NPC_templateGetTemplateIndex( char* templatename ); + +#endif + /*__READNPCTEMPLATE_H__*/ +002E:npcutil.h:0D63:1:14=48041e4b:16=47d21313:#ifndef _NPCUTIL_H_ +#define _NPCUTIL_H_ + +BOOL NPC_Util_AddOneTitle( int charindex, int titleindex ); +BOOL NPC_Util_HaveTitle( int charindex , int titleindex ); +BOOL NPC_Util_Nearby( int x1 , int y1, int x2 , int y2 ); +BOOL NPC_Util_CharNearby(int ind1,int ind2); +int NPC_Util_YN(char *input ); +int NPC_Util_getDirFromTwoPoint( POINT* pstart, POINT* pend ); +int NPC_Util_countHaveItem( int meindex , int itemid ); +BOOL NPC_Util_isBackContact( int frontindex , int backindex ); + +void NPC_Util_AnnounceFloor( int floorid , char *msg ); + + +BOOL NPC_Util_moveItemToChar( int charindex, int itemindex,BOOL net ); +BOOL NPC_Util_createItemToChar( int charindex, int itemid , BOOL net); +int NPC_Util_CharDistance( int index1, int index2 ); +int NPC_Util_SearchNear( int meindex, int maxlen, int type ); +int NPC_Util_SearchNearPlayer( int meindex, int maxlen ); +int NPC_Util_SearchNearEnemy( int meindex, int maxlen ); +int NPC_Util_SuberiWalk( int index, int dir ); +int NPC_Util_GetNumFromArg( int meindex, char* in); + +int NPC_Util_GetDirCharToChar( int fromindex, int toindex, int mode); +int NPC_Util_WalkCharToChar( int fromindex, int toindex, int mode, int suberi); +BOOL NPC_Util_isFaceToFace( int index1, int index2, int distance ); +BOOL NPC_Util_isFaceToChara( int index1, int index2, int distance ); +BOOL NPC_Util_charIsInFrontOfChar( int index1, int index2, int distance ); + +int NPC_Util_SearchItemInChar( int charindex , int itemindex); +int NPC_Util_GiveAllItemToChar( int give , int take ); +/* +int NPC_Util_ControlOtherNPC( CHAR_TYPE chartype , + char *npcname, + char *command ); +*/ +void NPC_Util_NPCDelete( int srcindex ); +BOOL NPC_Util_moveItemToMap( int itemindex , int fl , int x , int y, + BOOL net ); +char *NPC_Util_GetArgStr( int index, char *argstr, int len); +int NPC_Util_GetNumFromStrWithDelim( char *srcstr, char* in); +char *NPC_Util_GetStrFromStrWithDelim( char *srcstr, char *srhstr, + char *buf, int len); +inline double NPC_Util_sellRate( int seller ); +inline double NPC_Util_buyRate( int buyer ); +BOOL NPC_Util_IsVisiblePlayer( int meindex); +BOOL NPC_Util_WordInclude( char *text , char *word ); +void NPC_Util_RandomToken(char *in, char *out, int outbufsize ); + +void cutDotsTail( char *s ); +int NPC_Util_FrontItem( int meindex ); +void NPC_Util_Boss2KingStart( int bossindex ); +int NPC_Util_FrontChar( int meindex ); +int *NPC_Util_getEnemy( int meindex, int charaindex); + +void NPC_NowEndEventSetFlgCls(int talker,int shiftbit); +void NPC_EventSetFlg(int talker,int shiftbit); +BOOL NPC_EventCheckFlg(int point,int shiftbit); +void NPC_NowEventSetFlg(int talker,int shiftbit); +void NPC_NowEventSetFlgCls(int talker,int shiftbit); +BOOL NPC_NowEventCheckFlg(int point,int shiftbit); +void NPC_EndEventSetFlgCls(int talker,int shiftbit); +char *NPC_Util_CheckAssignArgFile( int index, char *filename); + +// CoolFish: Family Adv 2001/8/4 +void AddFMAdv(int talker, int shiftbit); + +// Robin 0817 family income +int addNpcFamilyTax( int meindex, int talkerindex, int income ); + +#define NPC_ENEMY_ENEMYNUMBER 10 /* س */ + +/* ¦Ѱ̻ ļ漰 ٯ */ +#define NPC_UTIL_GETARGSTR_LINEMAX 4096 +/* ¦Ѱ̻P */ +#ifdef _NEWEVENT +//#define NPC_UTIL_GETARGSTR_BUFSIZE 1024*1200 +#define NPC_UTIL_GETARGSTR_BUFSIZE 1024*32 +#else +#define NPC_UTIL_GETARGSTR_BUFSIZE 1024*12 +#endif +#endif + + + +0031:npc_action.h:014C:1:14=48041e4b:16=47d21313: \ No newline at end of file diff --git a/include/npctemplate.h b/include/npctemplate.h new file mode 100644 index 0000000..48aa0f8 --- /dev/null +++ b/include/npctemplate.h @@ -0,0 +1,111 @@ +#ifndef __READNPCTEMPLATE_H__ +#define __READNPCTEMPLATE_H__ + +#include "util.h" +#include "char_base.h" + +#define NPC_TEMPLATEFILEMAGIC "NPCTEMPLATE\n" + +#undef EXTERN +#ifdef __NPCTEMPLATE__ +#define EXTERN +#else +#define EXTERN extern +#endif /*__NPCTEMPLATE__*/ + + + +typedef struct tagNPC_haveItem +{ + int itemnumber; + int haverate; + int havenum; +}NPC_haveItem; + +typedef enum +{ + NPC_TEMPLATENAME, /* */ + NPC_TEMPLATECHARNAME, /* */ + + NPC_TEMPLATEINITFUNC, /* CHAR_INITFUNC */ + NPC_TEMPLATEWALKPREFUNC, /* CHAR_WALKPREFUNC */ + NPC_TEMPLATEWALKPOSTFUNC, /* CHAR_WALKPOSTFUNC */ + NPC_TEMPLATEPREOVERFUNC, /* CHAR_PREOVERFUNC */ + NPC_TEMPLATEPOSTOVERFUNC, /* CHAR_POSTOVERFUNC */ + NPC_TEMPLATEWATCHFUNC, /* CHAR_WATCHFUNC */ + NPC_TEMPLATELOOPFUNC, /* CHAR_LOOPFUNC */ + NPC_TEMPLATEDYINGFUNC, /* CHAR_DYINGFUNC */ + NPC_TEMPLATETALKEDFUNC, /* CHAR_TALKEDFUNC */ + + NPC_TEMPLATEPREATTACKEDFUNC, /* CHAR_PREATTACKEDFUNC */ + NPC_TEMPLATEPOSTATTACKEDFUNC, /* CHAR_POSTATTACKEDFUNC */ + + NPC_TEMPLATEOFFFUNC, /* CHAR_OFFFUNC */ + NPC_TEMPLATELOOKEDFUNC, /* CHAR_LOOKEDFUNC */ + NPC_TEMPLATEITEMPUTFUNC, /* CHAR_ITEMPUTFUNC */ + + NPC_TEMPLATESPECIALTALKEDFUNC, /* CHAR_SPECIALTALKEDFUNC */ + NPC_TEMPLATEWINDOWTALKEDFUNC, /* CHAR_WINDOWTALKEDFUNC */ +#ifdef _USER_CHARLOOPS + NPC_TEMPLATELOOPFUNCTEMP1, //CHAR_LOOPFUNCTEMP1, + NPC_TEMPLATELOOPFUNCTEMP2, //CHAR_LOOPFUNCTEMP2, + NPC_TEMPLATEBATTLEPROPERTY, //CHAR_BATTLEPROPERTY, +#endif + NPC_TEMPLATECHARNUM, +}NPC_TEMPLATECHAR; + +typedef enum +{ + NPC_TEMPLATEMAKEATNOBODY, /* ئݱ¾ */ + NPC_TEMPLATEMAKEATNOSEE, /* έئƥ¾ */ + NPC_TEMPLATEIMAGENUMBER, /* į */ + NPC_TEMPLATETYPE, /* 裻ݱ裻 */ + + NPC_TEMPLATEMINHP, /* HP */ + + NPC_TEMPLATEMINMP, /* MP */ + + NPC_TEMPLATEMINSTR, /* STR */ + + NPC_TEMPLATEMINTOUGH, /* TOUGH */ + + NPC_TEMPLATEISFLYING, /* ƥ¾ */ + + NPC_TEMPLATEITEMNUM, /* еʧ ة */ + + NPC_TEMPLATELOOPFUNCTIME, /* + * + * ëپ + */ + NPC_TEMPLATEFUNCTIONINDEX, /* + * fucntionSet + * ̼͵ + */ + + NPC_TEMPLATEINTNUM, +}NPC_TEMPLATEINT; + +typedef struct tagNPC_Template +{ + STRING64 chardata[NPC_TEMPLATECHARNUM]; + int intdata[NPC_TEMPLATEINTNUM]; + int randomdata[NPC_TEMPLATEINTNUM]; /* ¼ĸة + Ȼ */ + int hash; + NPC_haveItem* haveitem; +}NPC_Template; + + +EXTERN NPC_Template* NPC_template; +EXTERN int NPC_templatenum; +EXTERN int NPC_template_readindex; + +INLINE int NPC_CHECKTEMPLATEINDEX(int index); + +BOOL NPC_copyFunctionSetToChar( int id, Char* ch ); + +BOOL NPC_readNPCTemplateFiles( char* topdirectory ,int templatesize); +int NPC_templateGetTemplateIndex( char* templatename ); + +#endif + /*__READNPCTEMPLATE_H__*/ diff --git a/include/npcutil.h b/include/npcutil.h new file mode 100644 index 0000000..22cc817 --- /dev/null +++ b/include/npcutil.h @@ -0,0 +1,86 @@ +#ifndef _NPCUTIL_H_ +#define _NPCUTIL_H_ + +BOOL NPC_Util_AddOneTitle( int charindex, int titleindex ); +BOOL NPC_Util_HaveTitle( int charindex , int titleindex ); +BOOL NPC_Util_Nearby( int x1 , int y1, int x2 , int y2 ); +BOOL NPC_Util_CharNearby(int ind1,int ind2); +int NPC_Util_YN(char *input ); +int NPC_Util_getDirFromTwoPoint( POINT* pstart, POINT* pend ); +int NPC_Util_countHaveItem( int meindex , int itemid ); +BOOL NPC_Util_isBackContact( int frontindex , int backindex ); + +void NPC_Util_AnnounceFloor( int floorid , char *msg ); + + +BOOL NPC_Util_moveItemToChar( int charindex, int itemindex,BOOL net ); +BOOL NPC_Util_createItemToChar( int charindex, int itemid , BOOL net); +int NPC_Util_CharDistance( int index1, int index2 ); +int NPC_Util_SearchNear( int meindex, int maxlen, int type ); +int NPC_Util_SearchNearPlayer( int meindex, int maxlen ); +int NPC_Util_SearchNearEnemy( int meindex, int maxlen ); +int NPC_Util_SuberiWalk( int index, int dir ); +int NPC_Util_GetNumFromArg( int meindex, char* in); + +int NPC_Util_GetDirCharToChar( int fromindex, int toindex, int mode); +int NPC_Util_WalkCharToChar( int fromindex, int toindex, int mode, int suberi); +BOOL NPC_Util_isFaceToFace( int index1, int index2, int distance ); +BOOL NPC_Util_isFaceToChara( int index1, int index2, int distance ); +BOOL NPC_Util_charIsInFrontOfChar( int index1, int index2, int distance ); + +int NPC_Util_SearchItemInChar( int charindex , int itemindex); +int NPC_Util_GiveAllItemToChar( int give , int take ); +/* +int NPC_Util_ControlOtherNPC( CHAR_TYPE chartype , + char *npcname, + char *command ); +*/ +void NPC_Util_NPCDelete( int srcindex ); +BOOL NPC_Util_moveItemToMap( int itemindex , int fl , int x , int y, + BOOL net ); +char *NPC_Util_GetArgStr( int index, char *argstr, int len); +int NPC_Util_GetNumFromStrWithDelim( char *srcstr, char* in); +char *NPC_Util_GetStrFromStrWithDelim( char *srcstr, char *srhstr, + char *buf, int len); +inline double NPC_Util_sellRate( int seller ); +inline double NPC_Util_buyRate( int buyer ); +BOOL NPC_Util_IsVisiblePlayer( int meindex); +BOOL NPC_Util_WordInclude( char *text , char *word ); +void NPC_Util_RandomToken(char *in, char *out, int outbufsize ); + +void cutDotsTail( char *s ); +int NPC_Util_FrontItem( int meindex ); +void NPC_Util_Boss2KingStart( int bossindex ); +int NPC_Util_FrontChar( int meindex ); +int *NPC_Util_getEnemy( int meindex, int charaindex); + +void NPC_NowEndEventSetFlgCls(int talker,int shiftbit); +void NPC_EventSetFlg(int talker,int shiftbit); +BOOL NPC_EventCheckFlg(int point,int shiftbit); +void NPC_NowEventSetFlg(int talker,int shiftbit); +void NPC_NowEventSetFlgCls(int talker,int shiftbit); +BOOL NPC_NowEventCheckFlg(int point,int shiftbit); +void NPC_EndEventSetFlgCls(int talker,int shiftbit); +char *NPC_Util_CheckAssignArgFile( int index, char *filename); + +// CoolFish: Family Adv 2001/8/4 +void AddFMAdv(int talker, int shiftbit); + +// Robin 0817 family income +int addNpcFamilyTax( int meindex, int talkerindex, int income ); + +#define NPC_ENEMY_ENEMYNUMBER 10 /* س */ + +/* ¦Ѱ̻ ļ漰 ٯ */ +#define NPC_UTIL_GETARGSTR_LINEMAX 4096 +/* ¦Ѱ̻P */ +#ifdef _NEWEVENT +//#define NPC_UTIL_GETARGSTR_BUFSIZE 1024*1200 +#define NPC_UTIL_GETARGSTR_BUFSIZE 1024*32 +#else +#define NPC_UTIL_GETARGSTR_BUFSIZE 1024*12 +#endif +#endif + + + diff --git a/include/object.h b/include/object.h new file mode 100644 index 0000000..c6b9cff --- /dev/null +++ b/include/object.h @@ -0,0 +1,75 @@ +#ifndef __OBJECT_h__ +#define __OBJECT_h__ + +#include "common.h" + +typedef enum +{ + OBJTYPE_NOUSE, /* ̼͵Ȼئеë*/ + OBJTYPE_CHARA, /* ƽҷ CHAR_chara߼̼͵ */ + OBJTYPE_ITEM, /* ʧ ة ITEM_item ߼̼͵ */ + OBJTYPE_GOLD, /* żڻindex Ȼ */ + OBJTYPE_NPCSCHARA, +#ifdef _MAP_WARPPOINT + OBJTYPE_WARPPOINT, +#endif + OBJTYPE_NUM +}OBJTYPE; + +typedef struct tagObject +{ + OBJTYPE type; + + char objname[256]; + int npcsindex; + int dir; + int imagenum; + + int chartype; + int index; + int x; + int y; + int floor; +#ifdef _DEL_DROP_GOLD + int time; +#endif +}Object; + +BOOL CHECKOBJECT( int index ); +BOOL CHECKOBJECTUSE( int index ); +BOOL initObjectArray( int num ); +BOOL endObjectArray( void ); + +INLINE int _initObjectOne( char *file, int line, Object* ob ); +#define initObjectOne( ob ) _initObjectOne( __FILE__, __LINE__, ob) + +void endObjectOne( int index ); +int initObjectFromObjectMember(OBJTYPE type, int index, int x, int y , int floor ); + +INLINE int OBJECT_getType( int index ); +INLINE int OBJECT_setType( int index, int newvalue ); +INLINE int OBJECT_getFloor( int index ); +INLINE int OBJECT_setFloor( int index, int newvalue ); +INLINE int OBJECT_getX( int index ); +INLINE int OBJECT_setX( int index, int newvalue ); +INLINE int OBJECT_getY( int index ); +INLINE int OBJECT_setY( int index, int newvalue ); +INLINE int OBJECT_getIndex( int index ); +INLINE int OBJECT_setIndex( int index, int newvalue ); +INLINE int OBJECT_getNum( void ); + +INLINE int OBJECT_getchartype( int index ); +INLINE void OBJECT_setchartype( int index, int flg); + +#ifdef _PET_ITEM +BOOL storeObjects( char* dirname ); +BOOL restoreObjects( char* dirname ); +#endif + +int searchObjectFromCharaIndex( int index ); +#ifdef _CAX_LNS_MAPSUOXU +INLINE int get_mappointindex( int fl, int x,int y ); +#endif + +#endif +/*__OBJECT_h__*/ diff --git a/include/pet.h b/include/pet.h new file mode 100644 index 0000000..73770f4 --- /dev/null +++ b/include/pet.h @@ -0,0 +1,51 @@ +#ifndef __PET_H__ +#define __PET_H__ + +/* + * ʸ ɬƥʣ + */ +#include "version.h" +#include "common.h" + +#define PETFEEDTIME 60*60 // ﵰιʱ() +//#define PETFEEDTIME 5 // ﵰιʱ() + +int PET_DEBUG_initPetOne( int charaindex); +int PET_dropPet( int charaindex, int havepetindex); +int PET_dropPetFollow( int charaindex, int havepetindex, int fl, int x, int y); +int PET_dropPetFLXY( int charaindex, int havepetindex, int fl, int x, int y); +int PET_dropPetAbsolute( int petindex, int floor, int x, int y,BOOL net); +int PET_createPetFromCharaIndex( int charaindex, int enemyindex); +BOOL PET_SelectBattleEntryPet( int charaindex, int petarray); +int PET_initCharOneArray( Char *ch); +BOOL PET_isPutPoint( int fl,int x, int y); + + +BOOL PET_getBaseForAllocpoint( int toindex, int *work); +void PET_showEditBaseMsg( int charaindex, int toindex, int itemindex, int *work); + +#ifdef _PET_EVOLUTION +BOOL PET_getBaseAndSkill( int charaindex, int baseindex, int *base, int *skill, int flg); +#endif +BOOL CHAR_DelPetForIndex( int charaindex, int petindex); + +#endif + +#ifdef _PET_AMOI__E +//typedef enum +//{ +// PET_NOT_LIMIT = 0,// +// PET_NOT_DropTradeStreetVandor = 1,//ɶɽ +// PET_NOT_Drop = 2,//ɶ +// PET_NOT_Trade = 3,//ɽ +// PET_NOT_StreetVandor = 4,//ô˿ +// PET_NOT_TradeAndStreetVandor = 5,//ô˿ +//}PET_DUALTYPE; + +#define PET_NOT_LIMIT 0x00000000 +#define PET_NOT_DROP 0x00000010 +#define PET_NOT_STREETVANDOR 0x00000100 +#define PET_NOT_TRADE 0x00001000 +#define PET_NOT_MAIL 0x00010000 + +#endif diff --git a/include/pet_event.h b/include/pet_event.h new file mode 100644 index 0000000..bce25ff --- /dev/null +++ b/include/pet_event.h @@ -0,0 +1,18 @@ +#ifndef __PET_EVENT_H__ +#define __PET_EVENT_H__ + +/* + * ʸ ɬƥʣ + * ʸì + */ + +void PET_Talkfunc( int meindex, int talkerindex, char *msg, int color); + +void PET_Watchfunc( int objmeindex, int objmoveindex, + CHAR_ACTION act, int x, int y, int dir, + int* opt, int optlen ); +int PET_CleanPetdeletetime( int objmeindex); +void PET_CleanFreePetAll(); + + +#endif diff --git a/include/pet_skill.h b/include/pet_skill.h new file mode 100644 index 0000000..e45425f --- /dev/null +++ b/include/pet_skill.h @@ -0,0 +1,542 @@ +#ifndef __PET_SKILL_H__ +#define __PET_SKILL_H__ + +#include "util.h" + +typedef enum +{ + PETSKILL_FIELD_ALL, /* ͻƥ */ + PETSKILL_FIELD_BATTLE, /* */ + PETSKILL_FIELD_MAP, /* ɧѨ */ + +}PETSKILL_FIELDTYPE; + +typedef enum +{ + PETSKILL_TARGET_MYSELF, /* м */ + PETSKILL_TARGET_OTHER, /* ְ ֳ) */ + PETSKILL_TARGET_ALLMYSIDE, /* */ + PETSKILL_TARGET_ALLOTHERSIDE, /* 촡 */ + PETSKILL_TARGET_ALL, /* 廯 */ + PETSKILL_TARGET_NONE, /* ּ ئУ ֧׻ */ + PETSKILL_TARGET_OTHERWITHOUTMYSELF,/* ְ ֳئ) */ + PETSKILL_TARGET_WITHOUTMYSELFANDPET, /* ʸ½ */ +}PETSKILL_TARGETTYPE; + +typedef enum +{ + PETSKILL_ID, + PETSKILL_FIELD, + PETSKILL_TARGET, +#ifdef _PETSKILL2_TXT + PETSKILL_USETYPE, +#endif + PETSKILL_COST, + PETSKILL_ILLEGAL, + PETSKILL_DATAINTNUM, +}PETSKILL_DATAINT; + +typedef enum +{ + PETSKILL_NAME, /* */ + PETSKILL_COMMENT, /* 춪*/ + PETSKILL_FUNCNAME, /* */ + PETSKILL_OPTION, /* */ +#ifdef _CFREE_petskill + PETSKILL_FREE, /**/ + PETSKILL_KINDCODE, /**/ +#endif + + PETSKILL_DATACHARNUM, +}PETSKILL_DATACHAR; + +typedef struct tagPetskill +{ + int data[PETSKILL_DATAINTNUM]; + STRING64 string[PETSKILL_DATACHARNUM]; + +}Petskill; + +typedef int (*PETSKILL_CALLFUNC)( int, int, int, char * ); + +INLINE BOOL PETSKILL_CHECKINDEX( int index ); +INLINE int PETSKILL_getInt( int index, PETSKILL_DATAINT element); +INLINE int PETSKILL_setInt( int index, PETSKILL_DATAINT element, int data); +INLINE char* PETSKILL_getChar( int index, PETSKILL_DATACHAR element); +INLINE BOOL PETSKILL_setChar( int index ,PETSKILL_DATACHAR element, char* new ); +int PETSKILL_getPetskillNum( void); + +#define PETSKILL_GetArray( charaindex, havepetskill) _PETSKILL_GetArray( __FILE__, __LINE__, charaindex, havepetskill) +int _PETSKILL_GetArray( char *file, int line, int charaindex, int havepetskill ); + +BOOL PETSKILL_initPetskill( char *filename); +BOOL PETSKILL_reinitPetskill( void ); +int PETSKILL_getPetskillArray( int petskillid); +PETSKILL_CALLFUNC PETSKILL_getPetskillFuncPointer(char* name); + +int PETSKILL_Use( + int charaindex, + int toindex, + int array, + char *data + //BOOL isCLI // Robin 2001/02/26 if owner is player +); + +int PETSKILL_ContinuationAttack( + int charaindex, + int toindex, + int array, + char *data +); +int PETSKILL_ChargeAttack( + int charaindex, + int toindex, + int array, + char *data +); + + +#define PETSKILL_ID_GBREAK 0 // Ƥ +#define PETSKILL_ID_RENZOKU 1 // +#define PETSKILL_ID_GUARDIAN 2 // ˦ +#define PETSKILL_ID_CHARGE 3 // ҡ +#define PETSKILL_ID_ICHIGEKI 100 // ڽ +#define PETSKILL_ID_POWERBALANCE 110 // + +//********************************************************************** +// +// -- ְëԻئ +// +int PETSKILL_Guardian( + int charaindex, + int toindex, + int array, + char *data +); +// +//********************************************************************** + +int PETSKILL_PowerBalance( + int charaindex, + int toindex, + int array, + char *data +); + +//********************************************************************** +// +// -- ֻ ľ¸ +// +int PETSKILL_Mighty( + int charaindex, + int toindex, + int array, + char *data +); +// +//********************************************************************** + + +//********************************************************************** +// +// -- +// +int PETSKILL_StatusChange( + int charaindex, + int toindex, + int array, + char *data + +); +// +//********************************************************************** + + +//******************************************************* +// +// -- ɧ +// +int PETSKILL_NormalAttack( + int charaindex, + int toindex, + int array, + char *data + +); +// +//******************************************************* + +//******************************************************* +// +// -- ɧ +// +int PETSKILL_NormalGuard( + int charaindex, + int toindex, + int array, + char *data + +); +// +//******************************************************* + +//******************************************************* +// -- (ئ) +// +int PETSKILL_None( + int charaindex, + int toindex, + int array, + char *data + +); +// +//******************************************************* + +//******************************************************* +// -- (ľ 켰 ) +// +int PETSKILL_EarthRound( + int charaindex, + int toNo, + int array, + char *data + +); +// +//******************************************************* + +//******************************************************* +// -- Ƥ +// +int PETSKILL_GuardBreak( + int charaindex, + int toNo, + int array, + char *data + +); +/////////////////////////////////////////// +#ifdef _SKILL_GUARDBREAK2//Ƴ2 vincent add 2002/05/20 +int PETSKILL_GuardBreak2( + int charaindex, + int toNo, + int array, + char *data + +); +#endif +// +//******************************************************* +//******************************************************* +// -- ľ +// +int PETSKILL_Abduct( + int charaindex, + int toNo, + int array, + char *data + +); +// +//******************************************************* +//******************************************************* +// -- +int PETSKILL_Steal( + int charaindex, + int toNo, + int array, + char *data + +); +//******************************************************* +#ifdef _BATTLESTEAL_FIX +int PETSKILL_StealMoney( + int charaindex, + int toNo, + int array, + char *data + +); +#endif + +#ifdef _ITEM_INSLAY +int PETSKILL_Inslay( + int index, + int toNo, + int array, + char *data + +); +#endif + +#ifdef _PETSKILL_FIXITEM +int PETSKILL_Fixitem( + int index, + int toNo, + int array, + char *data + +); +#endif + +// -- ʧ ة +// +int PETSKILL_Merge( + int charaindex, + int toNo, + int array, + char *data + +); +// +//******************************************************* + +//******************************************************* +// -- á +// +int PETSKILL_NoGuard( + int charaindex, + int toNo, + int array, + char *data + +); +// +//******************************************************* + + + +// Terry add 2001/11/05 +#ifdef _ATTACK_MAGIC +int PETSKILL_AttackMagic( + int charaindex, + int toindex, + int array, + char *data +); +#endif + +#ifdef _VARY_WOLF +int PETSKILL_Vary( int cindex, int tindex, int id, char* data); +#endif + +#ifdef _SKILL_WILDVIOLENT_ATT +//vincent add 2002/05/16 +int PETSKILL_WildViolentAttack( + int charaindex, + int toindex, + int array, + char *data +); +#endif + +#ifdef _SKILL_SPEEDY_ATT +//vincent add 2002/05/16 +int PETSKILL_SpeedyAttack( + int charaindex, + int toindex, + int array, + char *data +); +#endif + +#ifdef _SKILL_SACRIFICE +//vincent add 2002/05/30 +int PETSKILL_Sacrifice( + int charaindex, + int toindex, + int array, + char *data +); +#endif + +#ifdef _SKILL_REFRESH +//vincent add 2002/08/08 +int PETSKILL_Refresh( + int charaindex, + int toindex, + int array, + char *data +); +#endif + +#ifdef _SKILL_WEAKEN //vincent輼: +int PETSKILL_Weaken( + int charaindex, + int toindex, + int array, + char *data +); +#endif + +#ifdef _SKILL_DEEPPOISON //vincent輼:綾 +int PETSKILL_Deeppoison( + int charaindex, + int toindex, + int array, + char *data +); +#endif + +#ifdef _SKILL_BARRIER //vincent輼:ħ +int PETSKILL_Barrier( + int charaindex, + int toindex, + int array, + char *data +); +#endif + +#ifdef _SKILL_NOCAST //vincent輼:Ĭ +int PETSKILL_Nocast( + int charaindex, + int toindex, + int array, + char *data +); +#endif + +#ifdef _SKILL_ROAR //vincent輼: +int PETSKILL_Roar( + int charaindex, + int toindex, + int array, + char *data +); +#endif + +#ifdef _PSKILL_FALLGROUND +int PETSKILL_FallGround( int charaindex, int toNo, int array, char *data ); +#endif +#ifdef _PRO_BATTLEENEMYSKILL +int ENEMYSKILL_ReLife( int enemyindex, int toNo, int array, char *data ); +int ENEMYSKILL_ReHP( int enemyindex, int toNo, int array, char *data ); + +int ENEMYSKILL_EnemyHelp( int enemyindex, int toNo, int array, char *data ); +#endif + +#ifdef _SKILL_DAMAGETOHP +int PETSKILL_DamageToHp( int charaindex, int toNo, int array, char *data ); +#endif + +#ifdef _PETSKILL_TIMID +int PETSKILL_BattleTimid( int charaindex, int toNo, int array, char *data ); +#endif +#ifdef _PETSKILL_2TIMID +int PETSKILL_2BattleTimid( int charaindex, int toNo, int array, char *data ); +#endif +#ifdef _PETSKILL_ANTINTER +int PETSKILL_AntInter(int charaindex, int toindex, int array, char* data); // \սģ +#endif + +#ifdef _PETSKILL_PROPERTY +int PETSKILL_BattleProperty( int charaindex, int toNo, int array, char *data ); +#endif + +#ifdef _PETSKILL_TEAR +int PETSKILL_BattleTearDamage( int charaindex, int toNo, int array, char *data ); +#endif + +#ifdef _BATTLE_LIGHTTAKE +int PETSKILL_Lighttakeed( int charaindex, int toNo, int array, char *data ); +#endif + +#ifdef _BATTLE_ATTCRAZED +int PETSKILL_AttackCrazed( int charaindex, int toNo, int array, char *data ); +#endif + +#ifdef _SHOOTCHESTNUT // Syu ADD 輼 +int PETSKILL_AttackShoot( int charaindex, int toNo, int array, char *data ); +#endif + +#ifdef _Skill_MPDAMAGE +int PETSKILL_MpDamage( int charaindex, int toNo, int array, char *data ); +#endif + +#ifdef _PETSKILL_SETDUCK +int PETSKILL_SetDuck( int charaindex, int toNo, int array, char *data ); +#endif + +#ifdef _MAGICPET_SKILL +int PETSKILL_SetMagicPet( int charaindex, int toNo, int array, char *data ); +#endif + +#ifdef _SKILL_TOOTH +int PETSKILL_ToothCrushe( int charaindex, int toNo, int array, char *data ); +#endif + +#ifdef _PSKILL_MODIFY +int PETSKILL_Modifyattack( int charaindex, int toNo, int array, char *data ); +#endif + +#ifdef _PSKILL_MDFYATTACK +int PETSKILL_Mdfyattack( int charaindex, int toNo, int array, char *data ); +#endif + + +#ifdef _MAGIC_SUPERWALL +int PETSKILL_MagicStatusChange( int charaindex, int toindex, int array, char *data ); +#endif + +#ifdef _PET_SKILL_SARS // WON ADD ɷ +int PETSKILL_Sars( int charaindex, int toNo, int array, char *data ); +#endif + +#ifdef _SONIC_ATTACK // WON ADD +int PETSKILL_Sonic( int charaindex, int toNo, int array, char *data ); +#endif +#ifdef _PETSKILL_REGRET +int PETSKILL_Regret( int charaindex, int toNo, int array, char *data ); +#endif + +#ifdef _PETSKILL_GYRATE +int PETSKILL_Gyrate( int charaindex, int toNo, int array, char *data ); +#endif + +#ifdef _PETSKILL_ACUPUNCTURE //Ƥ +int PETSKILL_Acupuncture( int charaindex, int toNo, int array, char *data ); +#endif + +#ifdef _PETSKILL_RETRACE +int PETSKILL_Retrace( int charaindex, int toNo, int array, char *data ); +#endif + +#ifdef _PETSKILL_HECTOR +int PETSKILL_Hector( int charaindex, int toNo, int array, char *data ); +#endif +int PETSKILL_ZiYun1( int charaindex, int toNo, int array, char *data ); +#ifdef _PETSKILL_FIREKILL +int PETSKILL_Firekill( int charaindex, int toNo, int array, char *data ); +#endif + +#ifdef _PETSKILL_DAMAGETOHP //¿(Ѫı) +int PETSKILL_DamageToHp2( int charaindex, int toNo, int array, char *data ); +#endif + +#ifdef _PETSKILL_BECOMEFOX +int PETSKILL_BecomeFox( int charaindex, int toNo, int array, char* data); +#endif + +#ifdef _PETSKILL_BECOMEPIG +int PETSKILL_BecomePig( int charaindex, int toNo, int array, char* data); +#endif + +#ifdef _PETSKILL_SHOWMERCY +int PETSKILL_ShowMercy(int charaindex, int toNo, int array, char* data); +#endif + +#ifdef _PETSKILL_COMBINED +int PETSKILL_Combined(int charaindex, int toNo, int array, char* data); +#endif + +#ifdef _PETSKILL_LER +int PETSKILL_BatFly(int charaindex, int toNo, int array, char* data); // ׶ - ȺĴ +int PETSKILL_DivideAttack(int charaindex, int toNo, int array, char* data); // ׶ - +#endif + +#ifdef _PETSKILL_BATTLE_MODEL +int PETSKILL_BattleModel(int charaindex, int toindex, int array, char* data); // \սģ +#endif + +#endif diff --git a/include/pet_skillinfo.h b/include/pet_skillinfo.h new file mode 100644 index 0000000..db735e1 --- /dev/null +++ b/include/pet_skillinfo.h @@ -0,0 +1,139 @@ +/* generated by makedefs.perl */ +#include "version.h" + +#define PETSKILL_NONE ( 0 ) +#define PETSKILL_NORMALATTACK ( 1 ) +#define PETSKILL_NORMALGUARD ( 2 ) +#define PETSKILL_GUARDBREAK ( 3 ) +#define PETSKILL_CONTINUATIONATTACK1 ( 10 ) +#define PETSKILL_CONTINUATIONATTACK2 ( 11 ) +#define PETSKILL_CONTINUATIONATTACK3 ( 12 ) +#define PETSKILL_CONTINUATIONATTACK4 ( 13 ) +#define PETSKILL_GUARDIAN ( 25 ) +#define PETSKILL_CHARGE1 ( 30 ) +#define PETSKILL_CHARGE2 ( 31 ) +#define PETSKILL_MIGHTY1 ( 40 ) +#define PETSKILL_MIGHTY2 ( 41 ) +#define PETSKILL_POWERBALANCE1 ( 50 ) +#define PETSKILL_POWERBALANCE2 ( 51 ) +#define PETSKILL_POWERBALANCE3 ( 52 ) +#define PETSKILL_POISON_ATTACK1 ( 60 ) +#define PETSKILL_POISON_ATTACK2 ( 61 ) +#define PETSKILL_STONE ( 80 ) +#define PETSKILL_CONFUSION_ATTACK ( 90 ) +#define PETSKILL_DRUNK_ATTACK ( 100 ) +#define PETSKILL_SLEEP_ATTACK ( 110 ) +#define PETSKILL_EARTHROUND1 ( 120 ) +#define PETSKILL_Abduct ( 130 ) +#define PETSKILL_STEAL ( 140 ) +#define PETSKILL_NOGUARD1 ( 150 ) +#define PETSKILL_NOGUARD2 ( 151 ) +#define PETSKILL_NOGUARD3 ( 152 ) +#define PETSKILL_MERGE ( 200 ) +#define PETSKILL_MERGE2 ( 201 ) +#ifdef _ALCHEMIST +#define PETSKILL_ALCHEMIST ( 202 ) +#endif +#ifdef _PSKILL_FALLGROUND +#define PETSKILL_FALLGROUND ( 210 ) +#endif +#ifdef _BATTLESTEAL_FIX +#define PETSKILL_STEALMONEY ( 211 ) +#endif +#ifdef _PRO_BATTLEENEMYSKILL +#define ENEMYSKILL_RELIFES ( 500 ) +#define ENEMYSKILL_RELIFHP ( 501 ) +#define ENEMYSKILL_HELP ( 502 ) +#endif +#ifdef _SKILL_DAMAGETOHP +#define PETSKILL_DAMAGETOHP ( 503) +#endif +#ifdef _Skill_MPDAMAGE +#define PETSKILL_MPDAMAGE ( 504) +#endif +#ifdef _SKILL_WILDVIOLENT_ATT +#define PETSKILL_WILDVIOLENTATTACK ( 540)// vincent add 2002/05/16 +#endif +#ifdef _SKILL_SPEEDY_ATT +#define PETSKILL_SPEEDYATTACK ( 541) // vincent add 2002/05/16 +#endif +#ifdef _SKILL_GUARDBREAK2 +#define PETSKILL_GUARDBREAK2 ( 542) //Ƴ2 vincent add 2002/05/20 +#endif +#ifdef _SKILL_SACRIFICE +#define PETSKILL_SACRIFICE ( 543) //Ԯ vincent add 2002/05/30 +#endif + +#ifdef _SKILL_WEAKEN +#define PETSKILL_WEAKEN ( 544) // vincent add 2002/07/11 +#endif + +#ifdef _SKILL_DEEPPOISON +#define PETSKILL_DEEPPOISON ( 545) //綾 vincent add 2002/07/16 +#endif + +#ifdef _SKILL_BARRIER +#define PETSKILL_BARRIER ( 546) //ħ vincent add 2002/07/16 +#endif + +#ifdef _SKILL_NOCAST +#define PETSKILL_NOCAST ( 547) //Ĭ vincent add 2002/07/16 +#endif + + +#ifdef _SKILL_ROAR +#define PETSKILL_ROAR ( 548) // vincent add 2002/07/11 +#endif + +#ifdef _ITEM_INSLAY +#define PETSKILL_INSLAY (572) +#endif + +#ifdef _PETSKILL_FIXITEM +#define PETSKILL_FIXITEM (573) +#endif + +#ifdef _SKILL_TOOTH +#define PETSKILL_TOOTHCRUSHE (574) +#endif + +#ifdef _SKILL_REFRESH +#define PETSKILL_REFRESH ( 575) //vincent add 2002/08/08 +#endif + +#ifdef _VARY_WOLF +#define PETSKILL_VARY ( 600 ) +#endif + +#ifdef _PETSKILL_SETDUCK +#define PETSKILL_SETDUCK ( 600 ) +#endif + +#ifdef _MAGICPET_SKILL +#define PETSKILL_SETMAGICPET ( 601 ) +#endif + +#ifdef _BATTLE_LIGHTTAKE +#define PETSKILL_Light ( 608) +#endif + +#ifdef _BATTLE_ATTCRAZED +#define PETSKILL_AttCrazed ( 608) +#endif + +#ifdef _SHOOTCHESTNUT // Syu ADD 輼 +#define PETSKILL_AttShoot ( 609 ) +#endif + +#ifdef _PETSKILL_BECOMEPIG +#define PETSKILL_BECOMEPIG ( 628 ) +#endif + +#ifdef _PETSKILL_LER +#define PETSKILL_BATFLY ( 633 ) +#define PETSKILL_DIVIDEATTACK ( 634 ) +#endif + +#ifdef _PETSKILL_BATTLE_MODEL +#define PETSKILL_BATTLE_MODEL ( 635 ) +#endif diff --git a/include/petmail.h b/include/petmail.h new file mode 100644 index 0000000..8a18fab --- /dev/null +++ b/include/petmail.h @@ -0,0 +1,57 @@ +#ifndef __PETMAIL_H__ +#define __PETMAIL_H__ +#include "version.h" +/* + * ʸ ɬƥʣ + */ +#define PETMAIL_OFFMSG_MAX 10000 +#define PETMAIL_OFFMSG_TIMEOUT ( 3 * 24 * 3600 ) +#define PETMAIL_CHECK_OFFMSG_EXPIRE_INTERVAL 3600 +#define PETMAIL_OFFMSG_TEXTLEN 512 + +/* ʸPضѣ ˼ѷԻئ³ */ +#define PETMAIL_EFFECTMAX 1 + +#define PETMAIL_SPOOLFLOOR 777 +#define PETMAIL_SPOOLX 30 +#define PETMAIL_SPOOLY 30 + +#define PETMAIL_LOOPINTERVAL1 500 +#define PETMAIL_LOOPINTERVAL2 5000 + +/* ׷̼ƽҷ³߼ë */ +typedef struct +{ + int use; + time_t send_tm; /* ǻë˪+TIMEOUT */ + int color; /* ƽ */ + char text[PETMAIL_OFFMSG_TEXTLEN]; /* ƽ */ + char destcd[CDKEYLEN]; /* ˪CDKEY */ + char destcharname[CHARNAMELEN]; /* ˪Ƽƽҷ */ + char srccd[CDKEYLEN]; /* ˪缰cdkey */ + char srccharname[CHARNAMELEN]; /* ˪缰ƽҷ */ + +} PETMAIL_offmsg; + +void PETMAIL_Loopfunc( int index); +BOOL PETMAIL_CheckPlayerExist( int index, int mode); + +BOOL PETMAIL_initOffmsgBuffer( int count ); +BOOL PETMAIL_addOffmsg( int fromindex, char *tocdkey, char *tocharaname, + char *text, int color ); +PETMAIL_offmsg *PETMAIL_getOffmsg( int offmsgindex); +BOOL PETMAIL_deleteOffmsg( int offmsgindex); +void PETMAIL_proc( void ); +BOOL storePetmail( void); +BOOL PETMAIL_sendPetMail( int cindex, int aindex, + int havepetindex, int haveitemindex, char* text , int color ); + +#ifdef _PETMAIL_DEFNUMS +void CHAR_AutoPickupMailPet( int charaindex, int petindex ); +#endif +int PETMAIL_getPetMailTotalnums( void); +void PETMAIL_delPetMailTotalnums( int numflg); +void PETMAIL_setPetMailTotalnums( int numflg); +int PETMAIL_CheckIsMyOffmsg( int fromindex, char *tocdkey, char *tocharaname); + +#endif diff --git a/include/profession_skill.h b/include/profession_skill.h new file mode 100644 index 0000000..3606c73 --- /dev/null +++ b/include/profession_skill.h @@ -0,0 +1,165 @@ +#include "version.h" + +#ifdef _PROFESSION_SKILL // WON ADD ְҵ +#include "common.h" +#include "util.h" +#include "skill.h" + +#define PROFESSION_MAX_LEVEL 26 // ְҵȼ 26 +#define PROFESSION_SKILL_MAX_LEVEL 100 // ܵȼ 100 +#define PROFESSION_SKILL_ADD_POINT 1 // 춨ͨӾֵ +// ְҵ +typedef enum +{ + PROFESSION_CLASS_NONE=0, // ְҵ + PROFESSION_CLASS_FIGHTER, // ʿ + PROFESSION_CLASS_WIZARD, // ʦ + PROFESSION_CLASS_HUNTER, // + PROFESSION_CLASS_NUM, +}PROFESSION_CLASS_TYPE; + +typedef enum +{ + PROFESSION_SKILL_NAME, // + PROFESSION_SKILL_TXT, // ˵ + PROFESSION_SKILL_FUNCNAME, // ʹú + PROFESSION_SKILL_OPTION, // + PROFESSION_SKILL_DATACHARNUM, +}PROFESSION_SKILL_DATACHAR; + + +typedef enum +{ + PROFESSION_SKILL_ID, // ܱ + PROFESSION_SKILL_PROFESSION_CLASS, // ְҵ + PROFESSION_SKILL_TARGET, // Ŀ + PROFESSION_SKILL_COST_MP, // ķMP + PROFESSION_SKILL_USE_FLAG, // ʹ + PROFESSION_SKILL_KIND, // + PROFESSION_SKILL_ICON, // ICONͼ + PROFESSION_SKILL_IMG_1, // ǰͼ(״̬) + PROFESSION_SKILL_IMG_2, // ͼ() + PROFESSION_SKILL_COST, // + PROFESSION_SKILL_FIX_VALUE, // ֵ + + //ɫѧϰ趨Ⱦﵽʱſѧϰ + PROFESSION_SKILL_LIMIT1, // ޼ 1 + PROFESSION_SKILL_PERCENT1, // ޼Ӧ% 1 + PROFESSION_SKILL_LIMIT2, // ޼ 2 + PROFESSION_SKILL_PERCENT2, // ޼Ӧ% 2 + PROFESSION_SKILL_LIMIT3, // ޼ 3 + PROFESSION_SKILL_PERCENT3, // ޼Ӧ% 3 + PROFESSION_SKILL_LIMIT4, // ޼ 4 + PROFESSION_SKILL_PERCENT4, // ޼Ӧ% 4 + PROFESSION_SKILL_DATAINTNUM, +}PROFESSION_SKILL_DATAINT; + + +typedef struct tagProfessionkill +{ + STRING64 string[PROFESSION_SKILL_DATACHARNUM]; + int data[PROFESSION_SKILL_DATAINTNUM]; +}Professionskill; + + +//---------------------------------------------------------------------------- +typedef int (*PROFESSION_SKILL_CALLFUNC)( int, int, int, char *, int ); +BOOL PROFESSION_initSkill( char *filename); +void rePROFESSION_initSkill(); + +//---------------------------------------------------------------------------- +INLINE BOOL PROFESSION_SKILL_CHECKINDEX( int index ); +INLINE int PROFESSION_SKILL_getInt( int index, PROFESSION_SKILL_DATAINT element); +INLINE int PROFESSION_SKILL_setInt( int index, PROFESSION_SKILL_DATAINT element, int data); +INLINE char* PROFESSION_SKILL_getChar( int index, PROFESSION_SKILL_DATACHAR element); +INLINE BOOL PROFESSION_SKILL_setChar( int index ,PROFESSION_SKILL_DATACHAR element, char* new ); +int PROFESSION_SKILL_getskillNum( void ); + +//---------------------------------------------------------------------------- +int PROFESSION_SKILL_getskillArray( int skillid); +PROFESSION_SKILL_CALLFUNC PROFESSION_SKILL_getskillFuncPointer(char* name ); +#define PROFESSION_SKILL_GetArray( charaindex, skill) _PROFESSION_SKILL_GetArray( __FILE__, __LINE__, charaindex, skill) +int _PROFESSION_SKILL_GetArray( char *file, int line, int charaindex, int skill ); +int PROFESSION_SKILL_Use( int charaindex, int skill, int toNo, char *data ); +void PROFESSION_SKILL_LVEVEL_UP( int charaindex, char *name ); +void PROFESSION_LEVEL_CHECK_UP( int charaindex ); +void PROFESSION_NORMAL_SKILL_LEVLE_UP(Skill* skill, int Pskillid, int charaindex ); +void PROFESSION_SKILL_WEAPON_FOCUS_LVEVEL_UP( int charaindex, char *name ); +void PROFESSION_SKILL_DUAL_WEAPON_LVEVEL_UP( int charaindex, char *name ); +int PROFESSION_SKILL_DEC_COST_MP( int charaindex, int skill, int Pskillid, int skill_level ); +int PROFESSION_SKILL_ADDSK( int charaindex, int skill, int level ); + +//---------------------------------------------------------------------------- +// ְҵ +void profession_common_fun( int charaindex, int toNo, int skill_level, int array, int com1 ); +int PROFESSION_brust( int charaindex, int toindex, int array, char *data, int skill_level ); +int PROFESSION_chain_atk( int charaindex, int toindex, int array, char *data, int skill_level ); +int PROFESSION_avoid( int charaindex, int toindex, int array, char *data, int skill_level ); +int PROFESSION_recovery( int charaindex, int toindex, int array, char *data, int skill_level ); +int PROFESSION_weapon_focus( int charaindex, int toindex, int array, char *data, int skill_level ); +int PROFESSION_volcano_springs( int charaindex, int toindex, int array, char *data, int skill_level ); +int PROFESSION_fire_ball( int charaindex, int toindex, int array, char *data, int skill_level ); +int PROFESSION_fire_spear( int charaindex, int toindex, int array, char *data, int skill_level ); +int PROFESSION_summon_thunder( int charaindex, int toindex, int array, char *data, int skill_level ); +int PROFESSION_current( int charaindex, int toindex, int array, char *data, int skill_level ); +int PROFESSION_storm( int charaindex, int toindex, int array, char *data, int skill_level ); +int PROFESSION_ice_arrow( int charaindex, int toindex, int array, char *data, int skill_level ); +int PROFESSION_ice_crack( int charaindex, int toindex, int array, char *data, int skill_level ); +int PROFESSION_ice_mirror( int charaindex, int toindex, int array, char *data, int skill_level ); +int PROFESSION_doom( int charaindex, int toindex, int array, char *data, int skill_level ); +int PROFESSION_blood( int charaindex, int toindex, int array, char *data, int skill_level ); +int PROFESSION_blood_worms( int charaindex, int toindex, int array, char *data, int skill_level ); +int PROFESSION_sign( int charaindex, int toindex, int array, char *data, int skill_level ); +int PROFESSION_fire_enclose( int charaindex, int toindex, int array, char *data, int skill_level ); +int PROFESSION_ice_eclose( int charaindex, int toindex, int array, char *data, int skill_level ); +int PROFESSION_thunder_enclose( int charaindex, int toindex, int array, char *data, int skill_level ); +int PROFESSION_fire_practice( int charaindex, int toindex, int array, char *data, int skill_level ); +int PROFESSION_ice_practice( int charaindex, int toindex, int array, char *data, int skill_level ); +int PROFESSION_thunder_practice( int charaindex, int toindex, int array, char *data, int skill_level ); +int PROFESSION_enclose( int charaindex, int toindex, int array, char *data, int skill_level ); +int PROFESSION_transpose( int charaindex, int toindex, int array, char *data, int skill_level ); +int PROFESSION_reback( int charaindex, int toindex, int array, char *data, int skill_level ); +int PROFESSION_chain_atk_2( int charaindex, int toindex, int array, char *data, int skill_level ); +int PROFESSION_scapegoat( int charaindex, int toindex, int array, char *data, int skill_level ); +int PROFESSION_enrage( int charaindex, int toindex, int array, char *data, int skill_level ); +int PROFESSION_energy_collect( int charaindex, int toindex, int array, char *data, int skill_level ); +int PROFESSION_focus( int charaindex, int toindex, int array, char *data, int skill_level ); +int PROFESSION_shield_attack( int charaindex, int toindex, int array, char *data, int skill_level ); +int PROFESSION_dual_weapon( int charaindex, int toindex, int array, char *data, int skill_level ); +int PROFESSION_deflect( int charaindex, int toindex, int array, char *data, int skill_level ); +int PROFESSION_through_attack( int charaindex, int toindex, int array, char *data, int skill_level ); +int PROFESSION_cavalry( int charaindex, int toindex, int array, char *data, int skill_level ); +int PROFESSION_dead_attack( int charaindex, int toindex, int array, char *data, int skill_level ); +int PROFESSION_convolute( int charaindex, int toindex, int array, char *data, int skill_level ); +int PROFESSION_chaos( int charaindex, int toindex, int array, char *data, int skill_level ); +int PROFESSION_docile( int charaindex, int toindex, int array, char *data, int skill_level ); +int PROFESSION_trap( int charaindex, int toindex, int array, char *data, int skill_level ); +int PROFESSION_enrage_pet( int charaindex, int toindex, int array, char *data, int skill_level ); +int PROFESSION_dragnet( int charaindex, int toindex, int array, char *data, int skill_level ); +int PROFESSION_entwine( int charaindex, int toindex, int array, char *data, int skill_level ); +int PROFESSION_autarky( int charaindex, int toindex, int array, char *data, int skill_level ); +int PROFESSION_plunder( int charaindex, int toindex, int array, char *data, int skill_level ); +int PROFESSION_toxin_weapon( int charaindex, int toindex, int array, char *data, int skill_level ); +int PROFESSION_resist_fire( int charaindex, int toindex, int array, char *data, int skill_level ); +int PROFESSION_resist_ice( int charaindex, int toindex, int array, char *data, int skill_level ); +int PROFESSION_resist_thunder( int charaindex, int toindex, int array, char *data, int skill_level ); +#ifdef _PROFESSION_ADDSKILL +int PROFESSION_resist_f_i_t( int charaindex, int toindex, int array, char *data, int skill_level ); +int PROFESSION_call_nature( int charaindex, int toindex, int array, char *data, int skill_level ); +int PROFESSION_boundary( int charaindex, int toindex, int array, char *data, int skill_level ); +#endif +int PROFESSION_attack_weak( int charaindex, int toindex, int array, char *data, int skill_level ); +int PROFESSION_instigate( int charaindex, int toindex, int array, char *data, int skill_level ); +int PROFESSION_track( int charaindex, int toindex, int array, char *data, int skill_level ); +int PROFESSION_oblivion( int charaindex, int toindex, int array, char *data, int skill_level ); +int PROFESSION_full_mp( int charaindex, int toindex, int array, char *data, int skill_level ); +int PROFESSION_strong_back( int charaindex, int toindex, int array, char *data, int skill_level ); +int PROFESSION_strengthen( int charaindex, int toindex, int array, char *data, int skill_level ); +int PROFESSION_escape( int charaindex, int toNo, int array, char *data, int skill_level ); +int PROFESSION_g_resist_fire( int charaindex, int toNo, int array, char *data, int skill_level ); +int PROFESSION_g_resist_ice( int charaindex, int toNo, int array, char *data, int skill_level ); +int PROFESSION_g_resist_thunder( int charaindex, int toNo, int array, char *data, int skill_level ); + +//---------------------------------------------------------------------------- + +#endif diff --git a/include/readmap.h b/include/readmap.h new file mode 100644 index 0000000..1391f3a --- /dev/null +++ b/include/readmap.h @@ -0,0 +1,140 @@ +#ifndef __MAP_H__ +#define __MAP_H__ +#include "common.h" +#include "util.h" + +typedef struct tagMAP_Objlink +{ + int objindex; + struct tagMAP_Objlink* next; +}MAP_Objlink, *OBJECT; + +#define GET_OBJINDEX(x) ((x)->objindex) +#define NEXT_OBJECT(x) ((x)->next) + +typedef struct tagMAP_Map +{ + int id; /* ID */ + int xsiz,ysiz; /* */ + char string[64]; /* ʾ */ + unsigned short* tile; /* */ + unsigned short* obj; /* */ + MAP_Objlink** olink; +#ifdef _MAP_NOEXIT + unsigned int startpoint; + int MapType; +#endif +}MAP_Map; + + +typedef enum +{ + MAP_WALKABLE, /* + * + * ? Q 0 + * ? M 1 + * ? M 2 + */ + MAP_HAVEHEIGHT, /* 0 0 */ + MAP_DEFENCE, /* \ ر0 \ */ + + MAP_INTODAMAGE, /* ʱ HP ? */ + MAP_OUTOFDAMAGE, /* ʱ HP ? */ + + MAP_SETED_BATTLEMAP, /* 趨? */ + MAP_BATTLEMAP, /* A */ + MAP_BATTLEMAP2, /* A */ + MAP_BATTLEMAP3, /* A */ + +/* ̣ӣ ʹ ӣ ʹ (? X ? @) */ + + MAP_INTODARKNESS, /* ʱ */ + MAP_INTOCONFUSION, /* ʱ ? */ + + MAP_OUTOFPOISON, /* ʱ */ + MAP_OUTOFPARALYSIS, /* ʱ */ + MAP_OUTOFSILENCE, /* ʱ ? */ + MAP_OUTOFSTONE, /* ʱ ʯ */ + MAP_OUTOFDARKNESS, /* ʱ */ + MAP_OUTOFCONFUSION, /* ʱ ? */ + + MAP_DATAINT_NUM, +}MAP_DATAINT; +typedef enum +{ + MAP_DATACHAR_NUM, +}MAP_DATACHAR; +typedef struct tagMAP_ImageData +{ + int data[MAP_DATAINT_NUM]; + STRING32 string[MAP_DATACHAR_NUM]; +}MAP_ImageData; + +typedef enum +{ + MAP_KINDWALKABLE, /* ? F 1 */ + + MAP_KINDNUM, +}MAP_kind; + + +INLINE int MAP_getfloorIndex( int floorid ); +int MAP_getfloorX( int floorid ); +int MAP_getfloorY( int floorid ); + +BOOL MAP_initReadMap( char* maptilefile , char* mapdir ); +BOOL MAP_initMapArray( int num ); +void MAP_endMapArray( void ); + +char* MAP_getdataFromRECT( int floor, RECT* seekr, RECT* realr ); +char *MAP_getChecksumFromRECT( int floor, RECT* seekr, RECT* realr, + int *tilesum, int *objsum, int *eventsum ); + +BOOL MAP_checkCoordinates( int mapid, int x, int y ); + +BOOL MAP_setTileAndObjData( int ff ,int fx, int fy, int tile, int obj); +BOOL MAP_getTileAndObjData( int ff ,int fx, int fy, int* tile, int* obj); +void MAP_sendAroundMapdata( int fl, int x, int y); +int MAP_getImageInt( int imagenumber, int element ); +BOOL MAP_setImageInt( int imagenumber, int element, int value ); +BOOL IsValidImagenumber( int imagenumber ); + +char* MAP_getfloorShowstring( int floorid ); +BOOL MAP_makeVariousMap(char* atile, char* aobj, int floor, int startx, int starty, int xsiz, int ysiz, MAP_kind kind ); +BOOL MAP_makeWalkableMap( char* data, int floor, int startx, int starty,int xsiz, int ysiz ); +BOOL MAP_IsThereSpecificFloorid( int floorid ); +BOOL MAP_IsValidCoordinate( int floorid, int x, int y ); + +BOOL MAP_addNewObj( int floor, int x, int y, int objindex ); +BOOL MAP_removeObj( int floor, int x, int y, int objindex ); +#define MAP_getTopObj( fl, x, y) _MAP_getTopObj( __FILE__, __LINE__, fl, x, y) +MAP_Objlink* _MAP_getTopObj( char *file, int line, int floor, int x, int y ); +#define MAP_objmove( objindex, of, ox, oy, nfl, nx, ny) _MAP_objmove( __FILE__, __LINE__, objindex, of, ox, oy, nfl, nx, ny) +BOOL _MAP_objmove( char *file, int line, int objindex, int ofloor, int ox, int oy, int nfloor, + int nx, int ny ); +char *MAP_getFloorName( int floor); +BOOL MAP_setObjData( int ff ,int fx, int fy, int obj, int objhp ); + +#ifdef _MAKE_MAP +int MAP_getFloorXY( int floor, int *x, int *y); +#endif + +#ifdef _STATUS_WATERWORD //ˮ״̬ +int MAP_getMapFloorType( int floor); +#endif + +#ifdef _MAP_NOEXIT +unsigned int MAP_getExFloor_XY( int floor , int *map_type); +BOOL CHECKFLOORID( int id); +#endif +int MAP_getMapNum(); +int MAP_getfloorId(int index); + +#ifdef _CAX_LNS_MAPSUOXU +BOOL MAP_SetExWarp(int mapid , int fl, int x, int y, int type); +BOOL MAP_DelMap(int mapid ); +int MAP_makenew( int mapid ,char* map_name); +#endif + +#endif +/*__MAP_H__*/ diff --git a/include/readnpc.h b/include/readnpc.h new file mode 100644 index 0000000..4356168 --- /dev/null +++ b/include/readnpc.h @@ -0,0 +1,6 @@ +#ifndef __READNPC_H__ +#define __READNPC_H__ +BOOL NPC_readNPCSettingFiles( char* topdirectory ,int templatesize,int createsize); +BOOL NPC_reloadNPC(void); +#endif + /*__READNPC_H__*/ diff --git a/include/saacproto_cli.h b/include/saacproto_cli.h new file mode 100644 index 0000000..cb757ba --- /dev/null +++ b/include/saacproto_cli.h @@ -0,0 +1,320 @@ +/* output by ../../bin/lsgen.perl 0.41 ( 1998 May) + * made Mon Oct 9 10:21:40 2000 + * user ttom + * host proxy1 + * file /home/ttom/gmsv2/src/gmsv/include/saacproto_cli.h + * util ./saacproto_util.c , include/saacproto_util.h + * src /home/ttom/gmsv2/src/gmsv/../../doc/saacproto.html + */ +#ifndef _SAACPROTOCLI_H_ +#define _SAACPROTOCLI_H_ +#include "version.h" +#include "saacproto_util.h" + +#ifdef MAXLSRPCARGS +#if ( MAXLSRPCARGS <= ( 7 + 1 ) ) +#undef MAXLSRPCARGS +#define MAXLSRPCARGS ( 7 + 1 ) +#endif +#else +#define MAXLSRPCARGS ( 7 + 1 ) +#endif + +#ifdef _ALLDOMAN // (ɿ) Syu ADD аNPC +void saacproto_UpdataStele_send( int fd , char *cdkey , char *name , char *title , int level , int trns , int time , int floor) ; +void saacproto_UpdataStele_recv( int fd , char *token) ; +void saacproto_S_UpdataStele_recv( int i , char *ocdkey , char *oname , char *ncdkey , + char *nname , char *title , int level , int trns , int floor ); +#endif + +void saacproto_ACGmsvDownRequest_recv( int fd,int min ) ; /* ../../doc/saacproto.html line 80 */ +void saacproto_ACServerLogin_send( int fd,char* servername,char* serverpas ) ; +void saacproto_ACServerLogin_recv( int fd,char* result,char* data ) ; /* ../../doc/saacproto.html line 101 */ +void saacproto_ACServerLogout_send( int fd ) ; /* ../../doc/saacproto.html line 114 */ + +#ifdef _PKSEVER_VER +void saacproto_ACCharList_send( int fd,char* id,char* pas,int mesgid, int star); +#else +void saacproto_ACCharList_send( int fd,char* id,char* pas,int mesgid ) ; /* ../../doc/saacproto.html line 123 */ +#endif + +void saacproto_ACCharList_recv( int fd,char* result,char* output,int id ) ; /* ../../doc/saacproto.html line 135 */ +void saacproto_ACCharLoad_send( int fd,char* id,char* pas,char* charname,int lock,char* opt,int mesgid,char* ip ) ; /* ../../doc/saacproto.html line 158 */ +void saacproto_ACCharLoad_recv( int fd,char* result,char* data,int id,int saveindex ) ; /* ../../doc/saacproto.html line 185 */ +#ifdef _NEWSAVE +void saacproto_ACCharSave_send( int fd,char* id,char* charname,char* opt,char* charinfo,int unlock,int mesgid,int saveindex ) ; /* ../../doc/saacproto.html line 201 */ +#else +void saacproto_ACCharSave_send( int fd,char* id,char* charname,char* opt,char* charinfo,int unlock,int mesgid ) ; /* ../../doc/saacproto.html line 201 */ +#endif +void saacproto_ACCharSave_recv( int fd,char* result,char* data,int id ) ; /* ../../doc/saacproto.html line 224 */ +void saacproto_ACCharDelete_send( int fd,char* id,char* passwd,char* charname,char* option,int mesgid, char* userip ) ; /* ../../doc/saacproto.html line 241 */ +void saacproto_ACCharDelete_recv( int fd,char* result,char* data,int id ) ; /* ../../doc/saacproto.html line 266 */ +void saacproto_ACLock_send( int fd,char* id,int lock,int mesgid ) ; /* ../../doc/saacproto.html line 281 */ +void saacproto_ACLock_recv( int fd,char* result,char* data,int id ) ; /* ../../doc/saacproto.html line 300 */ +void saacproto_ACUCheck_send( int fd,char* mem_id,int status ) ; /* ../../doc/saacproto.html line 314 */ +void saacproto_ACUCheck_recv( int fd,char* mem_id ) ; /* ../../doc/saacproto.html line 328 */ +void saacproto_DBUpdateEntryString_send( int fd,char* table,char* key,char* value,int msgid,int msgid2 ) ; /* ../../doc/saacproto.html line 339 */ +void saacproto_DBUpdateEntryString_recv( int fd,char* result,char* table,char* key,int msgid,int msgid2 ) ; /* ../../doc/saacproto.html line 354 */ +void saacproto_DBDeleteEntryString_send( int fd,char* table,char* key,int msgid,int msgid2 ) ; /* ../../doc/saacproto.html line 367 */ +void saacproto_DBDeleteEntryString_recv( int fd,char* result,char* table,char* key,int msgid,int msgid2 ) ; /* ../../doc/saacproto.html line 379 */ +void saacproto_DBGetEntryString_send( int fd,char* table,char* key,int msgid,int msgid2 ) ; /* ../../doc/saacproto.html line 394 */ +void saacproto_DBGetEntryString_recv( int fd,char* result,char* value,char* table,char* key,int msgid,int msgid2 ) ; /* ../../doc/saacproto.html line 406 */ +void saacproto_DBUpdateEntryInt_send( int fd,char* table,char* key,int value,char* info,int msgid,int msgid2 ) ; /* ../../doc/saacproto.html line 423 */ +void saacproto_DBUpdateEntryInt_recv( int fd,char* result,char* table,char* key,int msgid,int msgid2 ) ; /* ../../doc/saacproto.html line 445 */ +void saacproto_DBGetEntryRank_send( int fd,char* table,char* key,int msgid,int msgid2 ) ; /* ../../doc/saacproto.html line 459 */ +void saacproto_DBGetEntryRank_recv( int fd,char* result,int rank,int count,char* table,char* key,int msgid,int msgid2 ) ; /* ../../doc/saacproto.html line 473 */ +void saacproto_DBDeleteEntryInt_send( int fd,char* table,char* key,int msgid,int msgid2 ) ; /* ../../doc/saacproto.html line 492 */ +void saacproto_DBDeleteEntryInt_recv( int fd,char* result,char* table,char* key,int msgid,int msgid2 ) ; /* ../../doc/saacproto.html line 504 */ +void saacproto_DBGetEntryInt_send( int fd,char* table,char* key,int msgid,int msgid2 ) ; /* ../../doc/saacproto.html line 518 */ +void saacproto_DBGetEntryInt_recv( int fd,char* result,int value,char* table,char* key,int msgid,int msgid2 ) ; /* ../../doc/saacproto.html line 530 */ +void saacproto_DBGetEntryByRank_send( int fd,char* table,int rank_start,int rank_end,int msgid,int msgid2 ) ; /* ../../doc/saacproto.html line 547 */ +void saacproto_DBGetEntryByRank_recv( int fd,char* result,char* list,char* table,int msgid,int msgid2 ) ; /* ../../doc/saacproto.html line 562 */ +void saacproto_DBGetEntryByCount_send( int fd,char* table,int count_start,int num,int msgid,int msgid2 ) ; /* ../../doc/saacproto.html line 581 */ +void saacproto_DBGetEntryByCount_recv( int fd,char* result,char* list,char* table,int count_start,int msgid,int msgid2 ) ; /* ../../doc/saacproto.html line 593 */ +void saacproto_Broadcast_send( int fd,char* id,char* charname,char* message,int flag ) ; /* ../../doc/saacproto.html line 608 */ +void saacproto_Broadcast_recv( int fd,char* id,char* charname,char* message ) ; /* ../../doc/saacproto.html line 621 */ +void saacproto_Message_send( int fd,char* id_from,char* charname_from,char* id_to,char* charname_to,char* message,int option ) ; /* ../../doc/saacproto.html line 634 */ +void saacproto_Message_recv( int fd,char* id_from,char* charname_from,char* id_to,char* charname_to,char* message,int option,int mesgid ) ; /* ../../doc/saacproto.html line 652 */ +void saacproto_MessageAck_send( int fd,char* id,char* charname,char* result,int mesgid ) ; /* ../../doc/saacproto.html line 671 */ +void saacproto_MessageFlush_send( int fd,char* id,char* charname ) ; /* ../../doc/saacproto.html line 690 */ +int saacproto_InitClient( int(*)(int,char*,int) , int bufsiz , int fd); +void saacproto_SetClientLogFiles( char *read , char *write); +void saacproto_CleanupClient(void); +int saacproto_ClientDispatchMessage(int fd ,char*line); + +// +#ifdef _PERSONAL_FAME +void saacproto_ACAddFM_send(int fd, char *fmname, char *fmleadername, + char *fmleaderid, int fmleaderlv, char *petname, char *petarrt, + char *fmrule, int fmsprite, int fmleadergrano, int fame, int charfdid); +#else +void saacproto_ACAddFM_send(int fd, char *fmname, char *fmleadername, + char *fmleaderid, int fmleaderlv, char *petname, char *petarrt, + char *fmrule, int fmsprite, int fmleadergrano, int charfdid); +#endif +void saacproto_ACAddFM_recv(int fd, char *result, int fmindex, int index, + int charfdid); +// +// #ifdef _PERSONAL_FAME // Arminius: +void saacproto_ACJoinFM_send(int fd, char *fmname, int fmindex, char *charname, + char *charid, int charlv, int index, int fame, int charfdid); +// #else +// void saacproto_ACJoinFM_send(int fd, char *fmname, int fmindex, char *charname, +// char *charid, int charlv, int index, int charfdid); +// #endif +void saacproto_ACJoinFM_recv(int fd, char *result, int recv, int charfdid); +// ˳ +void saacproto_ACLeaveFM_send(int fd, char *fmname, int fmindex, char *charname, + char *charid, int index, int charfdid); +void saacproto_ACLeaveFM_recv(int fd, char *result, int resultflag, int charfdid); +// ɢ +void saacproto_ACDelFM_send(int fd, char *fmname, int fmindex, int index, + char *charname, char *charid, int charfdid); + +void saacproto_ACDelFM_recv(int fd, char *result, int charfdid); +// гб +void saacproto_ACShowFMList_send(int fd); +void saacproto_ACShowFMList_recv(int fd, char *result, int num, char *data); +// гԱб +void saacproto_ACShowMemberList_send(int fd, int index); +void saacproto_ACShowMemberList_recv(int fd, char *result, int index, int num, + int fmacceptflag, int fmjoinnum, char *data); +// гϸ +void saacproto_ACFMDetail_send(int fd, char *fmname, int fmindex, + int index, int charfdid); +void saacproto_ACFMDetail_recv(int fd, char *result, char *data, int charfdid); +//峤˳Ա塢޸ļԱְλ +#ifdef _FMVER21 +void saacproto_ACMemberJoinFM_send(int fd, char *fmname, int fmindex, char *charname, + int charindex, int index, int result, int meindex, int charfdid); +#else +void saacproto_ACMemberJoinFM_send(int fd, char *fmname, int fmindex, char *charname, + int charindex, int index, int result, int charfdid); +#endif +void saacproto_ACMemberJoinFM_recv(int fd, char *result, char *data, int charfdid); +//峤˳Ա뿪 +#ifdef _FMVER21 +void saacproto_ACMemberLeaveFM_send(int fd, char *fmname, int fmindex, char *charname, + int charindex, int index, int meindex, int charfdid); +#else +void saacproto_ACMemberLeaveFM_send(int fd, char *fmname, int fmindex, char *charname, + int charindex, int index, int charfdid); +#endif +void saacproto_ACMemberLeaveFM_recv(int fd, char *result, char *data, int charfdid); +// Login +#ifdef _FM_MODIFY +void saacproto_ACFMCharLogin_send(int fd, char *fmname, int fmindex, char *charname, + char *charid, int charlv, int eventflag, int charfdid,int gsnum); +#else + #ifdef _FMVER21 + void saacproto_ACFMCharLogin_send(int fd, char *fmname, int fmindex, char *charname, + char *charid, int result, int eventflag, int charfdid); + #else + void saacproto_ACFMCharLogin_send(int fd, char *fmname, int fmindex, char *charname, + char *charid, int result, int charfdid); + #endif +#endif +#ifdef _PERSONAL_FAME // Arminius: +void saacproto_ACFMCharLogin_recv(int fd, char *result, int index, int floor, + int fmdp, int joinflag, int fmsetupflag, int flag, int charindex, + int charfame, int charfdid +#ifdef _NEW_MANOR_LAW + ,int momentum +#endif + ); +#else +void saacproto_ACFMCharLogin_recv(int fd, char *result, int index, int floor, + int fmdp, int joinflag, int fmsetupflag, int flag, int charindex, + int charfdid); +#endif +// Logout +void saacproto_ACFMCharLogout_send(int fd, char *fmname, int fmindex, char *charname, + char *charid, int result, int index, int charfdid); +void saacproto_ACFMCharLogout_recv(int fd, char *result, int charfdid); +// г԰ +void saacproto_ACFMReadMemo_send(int fd, int index); +void saacproto_ACFMReadMemo_recv(int fd, char *result, int index, int num, + int dataindex, char *data); +// д԰ +void saacproto_ACFMWriteMemo_send(int fd, char *fmname, int fmindex, + char *data, int index); +void saacproto_ACFMWriteMemo_recv(int fd, char *result, int index); +// гݵ +void saacproto_ACFMPointList_send(int fd); +void saacproto_ACFMPointList_recv(int fd, char *result, char *data); + +// ݵ +void saacproto_ACSetFMPoint_send(int fd, char* fmname, int fmindex, int index, + int fmpointindex, int fl, int x, int y, int charfdid); +void saacproto_ACSetFMPoint_recv(int fd, char *result, int r, int charfdid); +// 趨ݵ +void saacproto_ACFixFMPoint_send(int fd, char *winfmname, int winfmindex, + int winindex, char *losefmname, int losefmindex, int loseindex, + int village); +void saacproto_ACFixFMPoint_recv(int fd, char *result, int r); +// 峤ϵԱ㲥 +// kindflag 1:峤㲥 2:屻ϵͳɾ 3:ϵͳ֪ͨѶϢ +void saacproto_ACFMAnnounce_send(int fd, char *fmname, int fmindex, int index, + char *data, int color); +void saacproto_ACFMAnnounce_recv(int fd, char *result, char *fmname, + int fmindex, int index, int kindflag, char *data, int color); +// г TOP 50 б +void saacproto_ACShowTopFMList_send(int fd, int kindflag); +void saacproto_ACShowTopFMList_recv(int fd, char *result, int kindflag, + int num, char *data); +// (ǷճԱ) +// flag 1:acceptjoinflag 2:dpchanged 3:change fmpet 4:change fminfo 5:predel FM Time +void saacproto_ACFixFMData_send(int fd, char *fmname, int fmindex, int index, + int kindflag,char *data1,char *data2,int charindex, int charfdid); + +void saacproto_ACFixFMData_recv(int fd, char *result, int kindflag, char *data1, + char *data2, int charfdid); + +// У¼ +void saacproto_ACFixFMPK_send(int fd, char *winfmname, int winfmindex, + int winindex, char *losefmname, int losefmindex, int loseindex); +void saacproto_ACFixFMPK_recv(int fd, char *result, int data, int winindex, + int loseindex); +// ȡü +// kindflag 1: +void saacproto_ACGetFMData_send(int fd, char *fmname, int fmindex, int index, + int kindflag, int charfdid); +void saacproto_ACGetFMData_recv(int fd, char *result, int kindflag, int data, + int charfdid); +// ǣ +void saacproto_ACGMFixFMData_send(int fd, int index, char *charid, char *cmd, + char *data, int charfdid); +void saacproto_ACGMFixFMData_recv(int fd, char *result, char *fmindex, int charfdid); +// ɾսų +void saacproto_ACFMClearPK_recv(int fd, char *result, char *fmname, int fmindex, + int index); + +// Arminius 7.26 manor pk acknowledge +void saacproto_ACManorPKAck_send(int fd, char *data); +void saacproto_ACManorPKAck_recv(int fd, char *data); + +void saacproto_ACreLoadFmData_send( int fd, int type, int data); + +#ifdef _ACFMPK_LIST +void saacproto_ACLoadFmPk_recv(int fd, char *data); +void saacproto_ACLoadFmPk_send(int fd, int fmpks_pos); +void saacproto_ACSendFmPk_recv( int fd, int toindex, int flg); +void saacproto_ACSendFmPk_send(int fd, int toindex, int PkFlg, int fmpks_pos, char *msg); +#endif + +void saacproto_ACAuctionSold_send(int fd, char *data); +void saacproto_ACAuctionSold_recv(int fd, char *data); + +#ifdef _WAEI_KICK // +void saacproto_ACKick_send( int fd, char* kickid,int kickfd, int flg); +void saacproto_ACKick_recv(int fd , int act, char* data ,int retfd); +#endif + +#ifdef _CHAR_POOLITEM +void saacproto_ACCharInsertPoolItem_send( int acfd, int charaindex, int clifdid, char *CdKey, char *Pooldataarg, int TYPE); + +void saacproto_ACCharSavePoolItem_recv(int fd ,char* result, char* data,int retfd); +void saacproto_ACCharSavePoolItem_send( int acfd, int charaindex, int clifdid, char *CdKey, char *Pooldataarg); + +void saacproto_ACCharGetPoolItem_recv(int fd ,char* result, char* data,int retfd, int meindex); +void saacproto_ACCharGetPoolItem_send( int acfd, int meindex, int charaindex, int clifdid, char * CdKey); +#endif + +#ifdef _CHAR_POOLPET +void saacproto_ACCharInsertPoolPet_send( int acfd, int charaindex, int clifdid, char *CdKey, char *Pooldataarg, int TYPE); + +void saacproto_ACCharSavePoolPet_recv(int fd ,char* result, char* data,int retfd); +void saacproto_ACCharSavePoolPet_send( int acfd, int charaindex, int clifdid, char *CdKey, char *Pooldataarg); + +void saacproto_ACCharGetPoolPet_recv(int fd ,char* result, char* data,int retfd, int meindex); +void saacproto_ACCharGetPoolPet_send( int acfd, int meindex, int charaindex, int clifdid, char * CdKey); +#endif + +#ifdef _ANGEL_SUMMON +void saacproto_ACMissionTable_recv( int fd, int num, int type, char *data, char* angelinfo); +void saacproto_ACMissionTable_send( int fd, int num, int type, char *data, char* angelinfo); +#endif + +#ifdef _TEACHER_SYSTEM +// RETURN_FUNCTION -> R_F_XXXXXXX +enum{ + R_F_TEACHER_SYSTEM, + R_F_END +}; +void saacproto_ACCheckCharacterOnLine_recv( int acfd, int charaindex, int iOnline,char *data,int flag); +void saacproto_ACCheckCharacterOnLine_send( int acfd, int charaindex, char *id, char *name, int flag); +#endif +void saacproto_ACCharLogin_recv(int fd , int clifd, int flag); +void saacproto_AddVipPoint_recv( int fd, char* id, int point, int charaindex ); + +void saacproto_QuerySafePasswd_recv( int fd, char* id, int res, int charaindex ); +void saacproto_AddSafePasswd_recv( int fd, char* id, int res, int charaindex ); + +void saacproto_PointCardSucces_recv( int fd, char* id, int res, int point, int charaindex ); +void saacproto_PointCardErr_recv( int fd, char* id, int res, int charaindex ); +void saacproto_LoginTime_recv( int fd, char* id, char* res, int charaindex ); +void saacproto_ACDelFmPoint_send(int fd, int fmindex); +#ifdef _ONLINE_SHOP +void saacproto_ACShop_recv( int fd, int charaindex, int shopnum, int vippoint, int piece, int pieces, int shopflag, char* res ); +void saacproto_ACShopBuy_recv( int charaindex, int shopflag, int shopno, int buynum ); +#endif +void saacproto_ACQuestion_recv(char* res); +#ifdef _ALL_ITEM +void saacproto_ACAllnum_recv(int flag,int allnum); +#endif +#endif +#ifdef _SQL_BUY_FUNC +void saacproto_OnlineBuy_send( int fd, char* id, char *costpasswd ); +void saacproto_OnlineBuy_recv(int fd, char *data); +#endif +void saacproto_ACFmPkOnlineSn_send( int acfd, int manorindex, int flag); +void saacproto_ACFmPkOnlineSn_recv(int manorindex,char* gsname, int flag); + +void saacproto_ACNewDelFM_send(int acfd, int index, int charfdid); +void saacproto_ACSystemAllTalk_send( int acfd, char *data); +void saacproto_ACSystemAllTalk_recv(char* data); +void saacproto_ACPlayerAllTalk_send( int acfd, char *servername,char *playname,char *data); +void saacproto_ACPlayerAllTalk_recv(char* servername,char* playername,char* data); +/* end of the generated client header code */ + + diff --git a/include/saacproto_util.h b/include/saacproto_util.h new file mode 100644 index 0000000..e65a2e2 --- /dev/null +++ b/include/saacproto_util.h @@ -0,0 +1,114 @@ +#ifndef _SAACPROTOUTIL_H_ +#define _SAACPROTOUTIL_H_ +#include +#include +#ifndef WIN32 +#include +#include +#endif +#define saacproto__NOENCRYPT +#define saacproto__NODEBUG +struct saacproto_ { + int (*write_func)(int,char*,int) ; /* write function */ + size_t workbufsize; /* size of work area */ + char *work,*arraywork,*escapework,*val_str,*ret_work; /* work areas which have same size */ + char *cryptwork,*jencodecopy,*jencodeout,*compresswork; /* these work has bigger size (3times)*/ + char** token_list; /* token list */ + unsigned long message_id; /*= 1, */ /* for generating message IDs */ + +}; +#ifdef _SAACPROTOUTIL_C_ +struct saacproto_ saacproto = { + NULL, + 0, + NULL,NULL,NULL,NULL,NULL, + NULL,NULL,NULL,NULL, + NULL, + 1, +}; +char **saacproto_stringwrapper; +char saacproto_readlogfilename[1024]; +char saacproto_writelogfilename[1024]; +#else +extern char **saacproto_stringwrapper; +extern struct saacproto_ saacproto; +extern char saacproto_readlogfilename[1024]; +extern char saacproto_writelogfilename[1024]; +#endif +char* saacproto_escapeString( char*a ); +char* saacproto_descapeString( char*a ); +void saacproto_splitString( char *src ); +void saacproto_strcpysafe( char *dest, char *src, int len ); +void saacproto_strcatsafe( char *dest , char *src , int maxlen ); +char*saacproto_mkstr_int( int i ); +char*saacproto_mkstr_u_int( unsigned int i ); +char*saacproto_mkstr_long( long l ); +char*saacproto_mkstr_u_long( unsigned long l ); +char*saacproto_mkstr_short( short s ); +char*saacproto_mkstr_u_short( short s ); +char*saacproto_mkstr_char( char c ); +char*saacproto_mkstr_u_char( char c); +char*saacproto_mkstr_string( char*a ); +char*saacproto_mkstr_float( float f ); +char*saacproto_mkstr_double( double d ); +char*saacproto_mkstr_int_array( int size , int *array ); +char*saacproto_mkstr_u_int_array( int size , int *array ); +char*saacproto_mkstr_short_array( int size , short *array ); +char*saacproto_mkstr_u_short_array(int size , short *array ); +char *saacproto_mkstr_char_array( int size , char *array ); +char *saacproto_mkstr_u_char_array( int size , unsigned char *array ); +char *saacproto_mkstr_float_array( int size , float *array ); +char *saacproto_mkstr_double_array( int size , double *array ); +int saacproto_demkstr_int( char*a ); +unsigned int saacproto_demkstr_u_int( char*a ); +long saacproto_demkstr_long( char*a ); +unsigned long saacproto_demkstr_u_long(char*a ); +short saacproto_demkstr_short( char*a ); +unsigned short saacproto_demkstr_u_short( char*a ); +char saacproto_demkstr_char( char*a ); +unsigned char saacproto_demkstr_u_char( char*a ); +float saacproto_demkstr_float( char*a ); +double saacproto_demkstr_double(char*a ); +char* saacproto_demkstr_string( char*a); +int *saacproto_demkstr_int_array( char**tk ,int *buf ,int start , int size ); +int *saacproto_demkstr_u_int_array( char **tk , int *buf , int start , int size ); +unsigned int *saacproto_demkstr_long_array( + char **tk , unsigned int *buf , int start , int size ); +unsigned long *saacproto_demkstr_u_long_array( + char **tk , unsigned long *buf , int start , int size ); +short *saacproto_demkstr_short_array( char **tk , short *buf , int start , int size ); +unsigned short*saacproto_demkstr_u_short_array( + char **tk , unsigned short *buf , int start , int size ); +char *saacproto_demkstr_char_array( char **tk , char *buf , int start , int size ); +unsigned char *saacproto_demkstr_u_char_array( + char **tk , unsigned char*buf , int start , int size ); +float *saacproto_demkstr_float_array( char **tk , float *buf , int start , int size ); +double *saacproto_demkstr_u_double_array( char **tk , double *buf , int start , int size ); +char *saacproto_wrapStringAddr( char *copy , int maxcopylen , char*src ); + +void saacproto_GetMessageInfo( int *id , char *funcname , int len,char **tk ); +int saacproto_ClientRead(void); +void saacproto_consumeLine(char *buf , int ofs ); +void saacproto_copyLine( char*src , char *out , int maxoutlen ); +void saacproto_Send( int fd , char *msg ); +int saacproto_AllocateCommonWork(int bufsiz); +int saacproto_StringRest(); + +// WON ADD +unsigned long saacproto_GetNewMessageID(void); + + +void saacproto_CreateHeader(char*out, char *fname ); +void saacproto_CreateHeaderID( char *out,unsigned long msgid , char *fname ); +int saacproto_default_write_wrap( int fd , char *buf , int size ); +void saacproto_bzero( char *b , int siz ); +void saacproto_bcopy(char*s , char *d , int siz ); +char *saacproto_Ltoa( long v ); +char *saacproto_Ultoa( unsigned long v ); +void saacproto_DebugSend( int fd , char *msg ); +/* Modified by ringo to fasten int type transfer */ +char *saacproto_cnv10to62( int a, char *out, int outlen ); +int saacproto_a62toi( char *a ); +extern int JENCODE_KEY; +#endif + diff --git a/include/sasql.h b/include/sasql.h new file mode 100644 index 0000000..307f1f0 --- /dev/null +++ b/include/sasql.h @@ -0,0 +1,128 @@ + + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + + +#define BOOL int +#define FALSE 0 +#define TRUE 1 + +void sasql_close( void ); +BOOL sasql_init( void ); +int sasql_query(char *nm, char *pas); +BOOL sasql_update(char *nm, char *path); +BOOL sasql_logindate(char *nm); +BOOL sasql_online( char *ID, char *NM, char *IP,int fame,int vigor, int flag ); +BOOL sasql_register(char *id, char *ps); +BOOL sasql_craete_userinfo( void ); +BOOL sasql_craete_lock( void ); +BOOL sasql_chehk_lock( char *idip ); +BOOL sasql_add_lock( char *idip ); +BOOL sasql_del_lock( char *idip ); +int sasql_vippoint( char *ID, int point,int flag ); +int sasql_query_safepasswd(char *id, char *safepasswd); +int sasql_add_safepasswd(char *id, char *safepasswd); +int sasql_load_query(char *nm, char *pas); +int sasql_del_query(char *nm, char *pas); +BOOL sasql_add_card(char *pas, int num); +void sasql_query_card(char *id, char *cardps,int charaindex); +#ifdef _ONLINE_SHOP +int sasql_chehk_shop( char *dataname ); +char* sasql_query_shop( char *dataname, int startrow, int shopnum ); +int sasql_buy_shop( char *dataname, int startrow, int shopnum, int shopno ); +#endif +#ifdef _ALL_ITEM +int sasql_allnum( int flag, int num, int flag1 ); +#endif +char* sasql_query_question(void); +#ifdef _SQL_BUY_FUNC +char *sasql_OnlineBuy( char *id, char *costpasswd ); +void sasql_OnlineBuy_add( char *coststr, int type, int num ); +#endif +#ifdef _PET_RESET +int sasql_resetpet_point(int petno); +int sasql_resetbdpet_point(int petno); +#endif +#ifdef _ZHIPIAO_SYSTEM +int sasql_zhipiao_insert(char *petno,char *cdkey,int point); +int sasql_zhipiao_query(char *piaono); +int sasql_zhipiao_update(char *cdkey,char *piaono,int checktype); +#endif +#ifdef _FMRANK_POINT +int sasql_fm_query(void); +int sasql_fmpoint_query(int fmindex); +int sasql_fmno_query(int fmindex); +int sasql_fmpoint_add(int fmindex,int point); +int sasql_fmindex_add(int fmindex,char *fmname,int point); +int sasql_fmindex_del(int fmindex); +#endif +#ifdef _ITEM_RESET +int sasql_itemreset_query(int itemid); +int sasql_itemdel_query(int itemid); +#endif +int sasql_cdkey_lock(char *cdkey,int locktype); +int sasql_ampoint( char *ID, int point, int flag ); +int sasql_cdkey_online( char *cdkey ); +int sasql_check_iponline( char *IP ); +#ifdef _EV_NUM +char* sasql_ev_npcmsg( int npcno ); +char* sasql_ev_item( void ); +char* sasql_ev_pet( void ); +#endif +#ifdef _RMB_SYSTEM +int sasql_rmbpoint( char *ID, int point, int flag ); +#endif +char* sasql_rand_buf( void ); +int sasql_check_lockip( char *IP ,int type); +int sasql_check_lockmac( char *mac); +int sasql_check_lockpcid( char *pcid); + +int sasql_add_lockip(char *IP,int type,int online,int mode); +int sasql_query_online_ip(char *IP); +int sasql_online_ip(char *cdkey,char *IP); +int sasql_offlinenum( char *IP ); +int sasql_offlinejqmnum( char *cdkey ); +char* sasql_ip( char *cdkey ); +BOOL sasql_online_jqm( char *ID, char *jqm, char *IP,int logintype ); +int sasql_onlinejqmnum( char *jqm, int flag ); +char* sasql_query_jqm( char *cdkey ); + +int sasql_getVipPoint( int charaindex ); +int sasql_setVipPoint( int charaindex, int point ); +int sasql_setVipPointForCdkey( char *id, int point ); +int sasql_getVipPointForCdkey( char *id ); +BOOL sasql_ckeckStrint( char *str ); +#ifdef _CARD_PRODUCTION +void sasql_OnlineCost_add( int cost, int num); +#endif + +int sasql_jifenPoint( int charaindex ); +int sasql_setJfPoint( int charaindex, int point ); +int sasql_xjPoint( int charaindex ); +int sasql_setxjPoint( int charaindex, int point ); + +#ifdef _CAX_LNS_MYSQLSUOXU +void sasql_LUASQLAdv(char* sqlstr,char* filepath,char* function,int npcindex ,int charaindex,char* msg,int flg); +void sasql_LUASQL(char* sqlstr,int row,char* filepath,char* function,int npcindex ,int charaindex,char* msg); + +char* sasql_Lua_QueryR(int row,char *sqlstr); +char* sasql_LuaAdv_QueryR(char *sqlstr,int flg); +#endif + +#ifdef _CAX_NEWMAC_LOGIN +char* sasql_query_mac( char *cdkey ); +BOOL sasql_online_mac( char *ID, char *mac, char *IP,int logintype ); +int sasql_onlinemacnum( char *mac, int flag ); +#endif diff --git a/include/skill.h b/include/skill.h new file mode 100644 index 0000000..9d41159 --- /dev/null +++ b/include/skill.h @@ -0,0 +1,121 @@ +#ifndef __SKILL_H__ +#define __SKILL_H__ + +#include "common.h" +#include "util.h" + +typedef struct tagSKILL_intDataSetting +{ + char *dumpskill; +}SKILL_intDataSetting; + +typedef struct tagSKILL_charDataSetting +{ + char *dumpskill; +}SKILL_charDataSetting; + + +typedef enum +{ +#ifdef _PROFESSION_SKILL // WON ADD ְҵ + SKILL_1, + SKILL_2, + SKILL_3, + SKILL_4, + SKILL_5, + SKILL_6, + SKILL_7, + SKILL_8, + SKILL_9, + SKILL_10, + SKILL_11, + SKILL_12, + SKILL_13, + SKILL_14, + SKILL_15, + SKILL_16, + SKILL_NUM +#else + SKILL_FIRE, + SKILL_MAGICIAN, + SKILL_PRIEST, + SKILL_ALOTOFTHINGS, + SKILL_AVOIDRATEUP, + SKILL_DETERMINEITEM, + SKILL_DETERMINEOTHERS, + SKILL_FIRECUT, + SKILL_THUNDERCUT, + SKILL_ICECUT, + SKILL_MERCHANT, + SKILL_HEALER, + SKILL_FIST, + SKILL_SWORD, + SKILL_AXE, + SKILL_SPEAR, + SKILL_BOW, + SKILL_CANE, + SKILL_LARGEVOICE, + SKILL_NUM +#endif +}SKILL_ID; + + +typedef struct tagSkillTable +{ + const int maxlevel; + void* effectfunc; +}SKILL_table; + + +typedef enum +{ + SKILL_LEVEL, // ܵȼ + SKILL_IDENTITY, // ܱ + SKILL_DATAINTNUM, +}SKILL_DATAINT; + +typedef enum +{ + SKILL_DATACHARNUM, +}SKILL_DATACHAR; + + +typedef struct tagSkill +{ + int data[SKILL_DATAINTNUM]; + STRING32 string[SKILL_DATACHARNUM]; +}Skill; + +char* SKILL_makeStringFromSkillData( Skill* sk ); +BOOL SKILL_makeSkillFromStringToArg( char* src, Skill* sk ); + +int SKILL_getInt( Skill* skill, int element); +int SKILL_setInt( Skill* skill, int element, int new); + +#ifdef _CHAR_PROFESSION // WON ADD ְҵ +char* SKILL_makeSkillStatusString( Skill* skill, int charaindex, int skill_num ); +#else +char* SKILL_makeSkillStatusString( Skill* skill ); +#endif + +char* SKILL_makeSkillFalseString( void ); + +BOOL SKILL_makeSkillData( Skill* sk ,int skid, int lev ); + +int SKILL_levelup( Skill* sk ); +int SKILL_getLevelFromSkillID( int charaindex, SKILL_ID id ); +BOOL SKILL_getUpableSkillID( int charaindex,char* buf, int buflen ); +void SKILL_skillEffect( int charaindex ); + +#ifdef _PROFESSION_SKILL // WON ADD ְҵ +int PROFESSION_MAGIC_COST_MP( int charaindex, int skill_num ); +INLINE int PROFESSION_CHANGE_SKILL_LEVEL_M( int skill_level ); +INLINE int PROFESSION_CHANGE_SKILL_LEVEL_A( int skill_level ); +INLINE int SKILL_getRealInt( Skill* skill, int element); +#endif + + +#endif +/*__SKILL_H__*/ + + diff --git a/include/sndcnf.h b/include/sndcnf.h new file mode 100644 index 0000000..449efd4 --- /dev/null +++ b/include/sndcnf.h @@ -0,0 +1,147 @@ +// į̻ ʾبة ǩ ׷º Ѩ޷ūƥέ춪 +// SA Serverƥƻϣ +// SE įñߣ + +SNDCONFIG sndconfig[] = +{ + // + { 1, "data\\se\\sap_01.wav", 85, 0, 0 /*, "aֿȭ"*/ }, + { 2, "data\\se\\sap_02.wav", 85, 0, 0 /*, "a"*/ }, + { 3, "data\\se\\sap_03.wav", 85, 0, 0 /*, "a"*/ }, + { 4, "data\\se\\sap_04.wav", 100, 0, 0 /*, "a"*/ }, + { 5, "data\\se\\sap_05.wav", 85, 0, 0 /*, "a"*/ }, + { 6, "data\\se\\sap_06.wav", 60, 0, 0 /*, "a"*/ }, + { 7, "data\\se\\sap_07.wav", 123, 0, 0 /*, "aͿռ"*/ }, + { 8, "data\\se\\sap_08.wav", 80, 0, 0 /*, ""*/ }, + { 9, "data\\se\\sap_09.wav", 80, 0, 0 /*, "aǹ"*/ }, + { 10, "data\\se\\sap_10.wav", 80, 0, 0 /*, "aʸ"*/ }, +//x { 11, "data\\se\\sap_11.wav", 105, 7, 0 /*, ""*/ }, + { 11, "data\\se\\sap_11.wav", 105, 0, 0 /*, ""*/ }, + { 12, "data\\se\\sap_14.wav", 100, 0, 0 /*, ""*/ }, + { 13, "data\\se\\sap_12.wav", 90, 0, 0 /*, ""*/ }, + { 14, "data\\se\\sap_13.wav", 105, 0, 0 /*, ""*/ }, + + // ƹ + { 51, "data\\se\\sae_01.wav", 123, 0, 0 /*, ""*/ }, + { 52, "data\\se\\sae_02.wav", 123, 0, 0 /*, ""*/ }, + { 53, "data\\se\\sae_03.wav", 123, 0, 0 /*, ""*/ }, + { 54, "data\\se\\sae_04.wav", 123, 0, 0 /*, ""*/ }, + { 55, "data\\se\\sae_05.wav", 123, 0, 0 /*, ""*/ }, + { 56, "data\\se\\sae_06.wav", 105, 0, 0 /*, "˹"*/ }, + { 57, "data\\se\\sae_07.wav", 80, 0, 0 /*, "˹ɫ"*/ }, + { 58, "data\\se\\sae_08.wav", 123, 0, 0 /*, ""*/ }, + { 59, "data\\se\\sae_09.wav", 123, 0, 0 /*, ""*/ }, + { 60, "data\\se\\sae_10.wav", 80, 0, 0 /*, "Ħ˹"*/ }, + { 61, "data\\se\\sae_11.wav", 123, 0, 0 /*, ""*/ }, + { 62, "data\\se\\sae_12.wav", 95, 0, 0 /*, "濨˹"*/ }, + { 63, "data\\se\\sae_13.wav", 80, 0, 0 /*, "˹̹˹"*/ }, + { 64, "data\\se\\sae_14.wav", 90, 0, 0 /*, ""*/ }, + { 65, "data\\se\\sae_15.wav", 95, 0, 0 /*, "³"*/ }, + { 66, "data\\se\\sae_16.wav", 95, 0, 0 /*, "ص"*/ }, + { 67, "data\\se\\sae_17.wav", 123, 0, 0 /*, ""*/ }, + { 68, "data\\se\\sae_18.wav", 123, 0, 0 /*, ""*/ }, + { 69, "data\\se\\sae_19.wav", 123, 0, 0 /*, ""*/ }, + { 70, "data\\se\\sae_20.wav", 123, 0, 0 /*, ""*/ }, + { 71, "data\\se\\sae_21.wav", 123, 0, 0 /*, ""*/ }, + { 72, "data\\se\\sae_22.wav", 123, 0, 0 /*, ""*/ }, + { 73, "data\\se\\sae_23.wav", 90, 0, 0 /*, ""*/ }, + { 74, "data\\se\\sae_24.wav", 90, 0, 0 /*, "Ұ"*/ }, + { 75, "data\\se\\sae_25.wav", 100, 0, 0 /*, "Ը"*/ }, + { 76, "data\\se\\sae_26.wav", 123, 0, 0 /*, ""*/ }, + { 77, "data\\se\\sae_27.wav", 123, 0, 0 /*, ""*/ }, + { 78, "data\\se\\sae_28.wav", 90, 0, 0 /*, ""*/ }, + { 79, "data\\se\\sae_29.wav", 123, 0, 0 /*, ""*/ }, + { 80, "data\\se\\sae_30.wav", 100, 0, 0 /*, "֮"*/ }, + { 81, "data\\se\\sae_31.wav", 123, 0, 0 /*, ""*/ }, + { 82, "data\\se\\sae_32.wav", 123, 0, 0 /*, ""*/ }, + + // ܷ + { 100, "data\\se\\sam_01.wav", 75, 0, 0 /*, "ʹ"*/ }, + { 101, "data\\se\\sam_02.wav", 75, 0, 0 /*, "ż"*/ }, + { 102, "data\\se\\sam_03.wav", 75, 0, 0 /*, "ָ"*/ }, + { 103, "data\\se\\sam_04.wav", 123, 0, 0 /*, "棨С"*/ }, + { 104, "data\\se\\sam_05.wav", 123, 0, 0 /*, "棨У"*/ }, + { 105, "data\\se\\sam_06.wav", 123, 0, 0 /*, "棨"*/ }, + { 106, "data\\se\\sam_07.wav", 123, 0, 0 /*, "С"*/ }, + { 107, "data\\se\\sam_08.wav", 123, 0, 0 /*, "У"*/ }, + { 108, "data\\se\\sam_09.wav", 123, 0, 0 /*, ""*/ }, + { 109, "data\\se\\sam_10.wav", 123, 0, 0 /*, "С"*/ }, + { 110, "data\\se\\sam_11.wav", 123, 0, 0 /*, "У"*/ }, + { 111, "data\\se\\sam_12.wav", 123, 0, 0 /*, ""*/ }, + { 112, "data\\se\\sam_13.wav", 123, 0, 0 /*, "׻С"*/ }, + { 113, "data\\se\\sam_14.wav", 123, 0, 0 /*, "׻У"*/ }, + { 114, "data\\se\\sam_15.wav", 85, 0, 0 /*, "׻ɱ"*/ }, + { 115, "data\\se\\sam_16.wav", 123, 0, 0 /*, ""*/ }, + { 116, "data\\se\\sam_17.wav", 123, 0, 0 /*, ""*/ }, + { 117, "data\\se\\sam_18.wav", 123, 0, 0 /*, ""*/ }, + { 118, "data\\se\\sam_19.wav", 123, 0, 0 /*, "Ѫ"*/ }, + { 119, "data\\se\\sam_20.wav", 123, 0, 0 /*, ""*/ }, + { 120, "data\\se\\sam_21.wav", 123, 0, 0 /*, "ʯ"*/ }, + { 121, "data\\se\\sam_22.wav", 123, 0, 0 /*, ""*/ }, + { 122, "data\\se\\sam_23.wav", 123, 0, 0 /*, "ħ"*/ }, + { 123, "data\\se\\sam_24.wav", 123, 0, 0 /*, ""*/ }, + + // +// { 151, "data\\se\\sak_01.wav", 121, 0, 1 /*, ""*/ }, +// { 152, "data\\se\\sak_02.wav", 121, 0, 1 /*, "Ǻ"*/ }, + { 151, "data\\se\\sak_01.wav", 127, 0, 1 /*, ""*/ }, +//x { 152, "data\\se\\sak_02.wav", 127, 4, 1 /*, ""*/ }, + { 152, "data\\se\\sak_02.wav", 127, 0, 1 /*, ""*/ }, + { 153, "data\\se\\sak_03.wav", 121, 0, 1 /*, ""*/ }, + { 154, "data\\se\\sak_04.wav", 90, 0, 1 /*, ""*/ }, + { 155, "data\\se\\sak_05.wav", 95, 0, 1 /*, "Ʈѩ"*/ }, + { 156, "data\\se\\sak_06.wav", 127, 0, 1 /*, ""*/ }, + { 157, "data\\se\\sak_07.wav", 125, 0, 1 /*, "ˮ"*/ }, + { 158, "data\\se\\sak_08.wav", 125, 0, 1 /*, ""*/ }, + { 159, "data\\se\\sak_09a.wav", 120, 0, 1 /*, ""*/ }, + { 160, "data\\se\\sak_10.wav", 115, 0, 1 /*, ""*/ }, + { 161, "data\\se\\sak_11.wav", 85, 0, 1 /*, "ˮ"*/ }, + { 162, "data\\se\\sak_12.wav", 120, 0, 1 /*, "糵"*/ }, + { 163, "data\\se\\sak_13.wav", 100, 0, 1 /*, "ˮ"*/ }, + { 164, "data\\se\\sak_14.wav", 127, 0, 1 /*, "ԭ"*/ }, + { 165, "data\\se\\sak_15.wav", 120, 0, 1 /*, ""*/ }, + { 166, "data\\se\\sak_16.wav", 120, 0, 1 /*, "ʯӵˮ"*/ }, + { 167, "data\\se\\sak_17.wav", 110, 0, 1 /*, "Ҷȡů"*/ }, + { 168, "data\\se\\sak_09b.wav", 120, 0, 1 /*, "ɭ֣"*/ }, + + // ˵ ة + { 201, "data\\se\\sas_01.wav", 90, 0, 0 /*, ""*/ }, + { 202, "data\\se\\sas_02.wav", 80, 0, 0 /*, "Ӵ"*/ }, + { 203, "data\\se\\sas_03.wav", 75, 0, 0 /*, "رӴ"*/ }, + { 204, "data\\se\\sas_04.wav", 80, 0, 0 /*, "Ӵ"*/ }, + { 205, "data\\se\\sas_05.wav", 80, 0, 0 /*, "رӴ"*/ }, + { 206, "data\\se\\sas_06.wav", 80, 0, 0 /*, ""*/ }, + { 207, "data\\se\\sas_07.wav", 123, 0, 0 /*, ""*/ }, + { 208, "data\\se\\sas_08.wav", 123, 0, 0 /*, ""*/ }, + { 209, "data\\se\\sas_09.wav", 123, 0, 0 /*, ""*/ }, + { 210, "data\\se\\sas_10.wav", 123, 0, 0 /*, ""*/ }, + { 211, "data\\se\\sas_11.wav", 65, 0, 0 /*, ìʧ""*/ }, + { 212, "data\\se\\sas_12.wav", 80, 0, 0 /*, "ʹĿ"*/ }, + { 213, "data\\se\\sas_13.wav", 123, 0, 0 /*, "Σdz"*/ }, +// { 214, "data\\se\\sas_14.wav", 127, 0, 0 /*, "ʤ"*/ }, + { 215, "data\\se\\sas_15.wav", 82, 0, 0 /*, ""*/ }, + { 216, "data\\se\\sas_16.wav", 110, 0, 0 /*, ""*/ }, + { 217, "data\\se\\sas_17.wav", 85, 0, 0 /*, "㻬"*/ }, + { 218, "data\\se\\sas_18.wav", 123, 0, 0 /*, ""*/ }, + { 219, "data\\se\\sas_19.wav", 82, 0, 0 /*, ""*/ }, + { 220, "data\\se\\sas_20.wav", 60, 0, 0 /*, "ΣǶ"*/ }, + { 221, "data\\se\\sas_21.wav", 123, 0, 0 /*, ""*/ }, + + // ĸ + { 250, "data\\se\\sad_01.wav", 85, 0, 0 /*, "𺦣ֿȭ"*/ }, + { 251, "data\\se\\sad_02.wav", 80, 0, 0 /*, "𺦣"*/ }, +//x { 252, "data\\se\\sad_03.wav", 95, -3, 0 /*, "𺦣ǹ"*/ }, + { 252, "data\\se\\sad_03.wav", 95, 0, 0 /*, "𺦣ǹ"*/ }, + { 253, "data\\se\\sad_04.wav", 85, 0, 0 /*, "𺦣"*/ }, + { 254, "data\\se\\sad_05.wav", 90, 0, 0 /*, "𺦣צ"*/ }, + + // BGM +// { 401, "data\\bgm\\ls2b_01.wav", 5 /*, "ģʽ֮"*/ }, +// { 402, "data\\bgm\\ls2b_02.wav", 5 /*, "Ϸе"*/ }, +// { 403, "data\\bgm\\ls2b_03.wav", 5 /*, "֮"*/ }, +// { 404, "data\\bgm\\ls2b_04.wav", 5 /*, "ͷĿ֮"*/ }, + + { -1 } // θį սئз +}; + + diff --git a/include/title.h b/include/title.h new file mode 100644 index 0000000..4fd63a1 --- /dev/null +++ b/include/title.h @@ -0,0 +1,21 @@ +#ifndef __TITLE_H__ +#define __TITLE_H__ + +#include "common.h" +#include "util.h" + +INLINE BOOL TITLE_CHECKTABLEINDEX( int index ); +int TITLE_getTitleIndex( int index); +#define TimeLimitLocal "2013-12-30 00:00:00" +char* TITLE_makeTitleStatusString( int charaindex, int havetitleindex ); +char* TITLE_makeSkillFalseString( void ); + +BOOL TITLE_addtitle( int charaindex, int titleindex ); +BOOL TITLE_deltitle( int charaindex, int titleindex ); +BOOL TITLE_initTitleName( char* filename ); +BOOL TITLE_reinitTitleName( void); +BOOL TITLE_initTitleConfig( char* filename ); +BOOL TITLE_TitleCheck( int charaindex, BOOL mode); +BOOL TITLE_TitleCheck_Nomsg( int charaindex, BOOL mode, int *addcnt, int *delcnt); +#endif + /*__TITLE_H__*/ diff --git a/include/trade.h b/include/trade.h new file mode 100644 index 0000000..3b0b6c5 --- /dev/null +++ b/include/trade.h @@ -0,0 +1,17 @@ +#ifndef __TRADE_H__ +#define __TRADE_H__ +#include "version.h" +#include "common.h" +#include "util.h" +#include "net.h" + +BOOL TRADE_Search(int fd, int meindex, char* message); + +void CHAR_Trade(int fd, int index, char* message); + +#ifdef _ITEM_PILEFORTRADE +void TRADE_InitTradeList( void); +#endif + +void TRADE_CheckTradeListUser( void); +#endif diff --git a/include/type_def.h b/include/type_def.h new file mode 100644 index 0000000..9b230f9 --- /dev/null +++ b/include/type_def.h @@ -0,0 +1,21 @@ +/////////////////////////////////////////////////////////////// +// : type_def.h +// ļ : һЩó, ṹ弰ضһЩƵ +// : ˫ȫ +// ʱ : 200692 +// Ŀ : DES㷨 +// ע : +// ʷ¼ : +/////////////////////////////////////////////////////////////// +#ifndef _TYPE_DEF_ +#define _TYPE_DEF_ + +//岿 +typedef unsigned char uint8; +typedef signed char int8; +typedef unsigned char BOOLEAN; + +#define TRUE 1 +#define FALSE 0 + +#endif diff --git a/include/util.h b/include/util.h new file mode 100644 index 0000000..946a8a8 --- /dev/null +++ b/include/util.h @@ -0,0 +1,142 @@ +#ifndef __UTIL_H__ +#define __UTIL_H__ + +#include +#include +#include + +#include "common.h" + + +typedef struct tagSTRING32 +{ + char string[32]; +}STRING32; +typedef struct tagSTRING64 +{ + char string[64]; +}STRING64; +typedef struct tagSTRING128 +{ + char string[128]; +}STRING128; + +typedef struct tagRECT +{ + int x; + int y; + int width; + int height; +}RECT; +typedef struct tagPOINT +{ + int x; + int y; +}POINT; + +/* strtol ɡñ */ +typedef enum +{ + CHAR,SHORT,INT,DOUBLE +}CTYPE; + +void chop( char* src ); +void dchop( char* src , char* del); +#define chomp(src) dchop(src,"\n"); +void chompex( char *buf ); +void pohcd( char* src , char* del); +void strcpysafe( char* dest ,size_t n,const char* src ); +void strncpysafe( char* dest ,const size_t n , + const char* src ,const int length ); +char* strcatsafe( char* src, int size, char* ap ); +BOOL strtolchecknum( char* arg , void* number,int base ,CTYPE type); +int strcmptail( char *s1 , char *s2 ); +int texttoiTail( char *hoge); +int textToInt( char *str ); +void deleteCharFromString( char* src , char* dels ); +void deleteCharFromStringNoEscape( char* src , char* dels ); +#define deleteWhiteSpace( src ) deleteCharFromStringNoEscape( src," \t" ) +char* replaceString( char* src, char oldc ,char newc ); + +char* escapeStrStr( char* src, char* needle ); +BOOL getStringFromIndexWithDelim_body( char* src ,char* delim ,int index, char* buf , int buflen, char *file, int line ); +#define getStringFromIndexWithDelim( src, delim, index, buf, buflen ) getStringFromIndexWithDelim_body( src, delim, index, buf, buflen, __FILE__, __LINE__ ) + +void getFourIntsFromString(char* src,int* int1,int* int2,int* int3, + int* int4); +void deleteSequentChar( char* src , char* dels ); +int hashpjw ( char* s ); +double gettimemillis( void ); +double gettimemicros( void ); + +int bindlocalhost( int port ); +int connectHost( char* hostname , unsigned short port ); +int existsNewLineCharacter( char* line ); +int hashpjw ( char* s ); +int charInclude( char* src, char* include ); +char* nindex( char* string, int c , int number ); +int rgetFileName( char* dirname , STRING64* string, int size); +//int RAND (int x,int y); +#define RAND(x,y) ((x-1)+1+ \ + (int)( (double)(y-(x-1))*rand()/(RAND_MAX+1.0)) ) +/*#define RAND(x,y) (x+(int)( (double)(y)*rand() / (RAND_MAX+1.0)) )*/ +void makeRandomString( char *cand , char *out , int len ); +BOOL checkStringsUnique( char** strings, int num ,int verbose); + +char* makeEscapeString( char* src , char* dest, int sizeofdest); +char* makeStringFromEscaped( char* src ); +INLINE double time_diff(struct timeval subtrahend,struct timeval subtractor); +BOOL PointInRect( RECT* rect, POINT* p ); +BOOL CoordinateInRect( RECT* rect, int x, int y); +int clipRect( RECT *rect1, RECT *rect2, RECT *ret ); +BOOL isstring1or0( char* string ); +void easyGetTokenFromString( char *src , int count , char*output , int len ); + +float linearDiv( float val1 , float val2 , float d ); +BOOL isExistFile( char* filename ); +char *cnv10to62( int a, char *out, int outlen ); +BOOL checkRedundancy( int *src, int srclen); +void shuffle_ints( int num, int *a, int t ); +unsigned short CheckCRC( unsigned char *p , int size ); +// Shan Add +INLINE double time_diff(struct timeval subtrahend,struct timeval subtractor); + + +/* ѨͷئԻ */ +#define ABS(x) ((x)>=0 ? (x) : -(x)) + +/* ë 0 - 7 姸 */ +#define VALIDATEDIR(x) ({(x)%=8;(x)=((x)+8)%8;}) + +/* 4ë2ƻ */ +#define GETLOWVALUE(x) ( (x)&0x0000ffff) +#define GETHIGHVALUE(x) ((((x)&0xffff0000)>>16)&0x0000ffff) +#define SETLOWVALUE(x,y) ((x)=((x)&0xffff0000)|( (y) &0x0000ffff)) +#define SETHIGHVALUE(x,y) ((x)=((x)&0x0000ffff)|(((y)<<16)&0xffff0000)) +#define MAKE2VALUE(x,y) ((((x)<<16)&0xffff0000)|((y)&0x0000ffff)) + +/* 4ë1*4ƻؤѨͷ */ +#define GETFIRSTVALUE(x) ( (x)&0x000000ff ) +#define GETSECONDVALUE(x) ((((x)&0x0000ff00)>>8 )&0x000000ff) +#define GETTHIRDVALUE(x) ((((x)&0x00ff0000)>>16)&0x000000ff) +#define GETFOURTHVALUE(x) ((((x)&0xff000000)>>24)&0x000000ff) + +#define SETFIRSTVALUE(x,y) ((x)=(((x)&0xffffff00)\ + |( y &0x000000ff))) +#define SETSECONDVALUE(x,y) ((x)=(((x)&0xffff00ff)\ + |(((y)<<8 )&0x0000ff00))) +#define SETTHIRDVALUE(x,y) ((x)=(((x)&0xff00ffff)\ + |(((y)<<16)&0x00ff0000))) +#define SETFOURTHVALUE(x,y) ((x)=(((x)&0x00ffffff)\ + |(((y)<<24)&0xff000000))) + +#define MAKE4VALUE(a,b,c,d) ( (((a)<<24)&0xff000000)\ + |(((b)<<16)&0x00ff0000)\ + |(((c)<< 8)&0x0000ff00)\ + |( (d) &0x000000ff)) + +#endif +char *strcpy_s(char *des, size_t n, const char *src); +char *replace(char *source,char *sub,char *rep); +int getHash ( char* s ); + /* __UTIL_H__ */ diff --git a/include/version.h b/include/version.h new file mode 100644 index 0000000..3ebe1f7 --- /dev/null +++ b/include/version.h @@ -0,0 +1,808 @@ +#include "sasql.h" +#ifndef __VERSION_H__ +#define __VERSION_H__ +#include "correct_bug.h" //BUG FIX + +/*Server 汾*/ +#define _NEW_SERVER_ +#define _SERVER_NUMS + +#define UNIQUE_KEYCODEITEM 100 +#define UNIQUE_KEYCODEPET "i" +//#define _DEFAULT_PKEY "Wonwonwon" // (ɿ)( ʯ 6.0 ) +//#define _RUNNING_KEY "11111111" // (ɿ)( ʯ 6.0 ) +//#define _DEFAULT_PKEY "ttttttttt" // (ɿ)( ʯ 6.0 ) +//#define _RUNNING_KEY "20041215" // (ɿ)( ʯ 6.0 ) + +/* ------------------------------------------------------------------- + * רׯ԰޸ ԱС褡ѫ־ΰС + */ + +/* +޸װ԰ʽ +Account Server ʽ: + acfamily.h MAX_FMPOINTҪ޸ +Account Server Ϸ: + saac/family/fmpoint/db_fmpointׯ԰趨 + ׯ԰ͼ|ׯ԰|ׯ԰|ׯ԰峤ͼ|ׯ԰ڽ֮ׯ|ռׯ԰֮ index|ռׯ԰֮ name|ռׯ԰֮ۺֵ + 磺 + 100|607|563|1041|1|3|shan|3132238 + 200|73|588|2031|2||| +Game Server ʽ + version.h FAMILY_MAXHOMEMANORNUMҪ + family.c FM_PKFLOOR սͼ + FAMILY_RidePet() 峤ͼ + FAMILY_LeaderFunc() 뺯id + npcutil.c addNpcFamilyTax function(ׯ԰ͼ%100)Ϊׯ԰˰ղ +Game Server Ϸ: + gmsv_v2/data/npc/family/manorsman.arg* id + gmsv_v2/data/npc/family/scheduleman.arg* id +*/ + +// ---------------------------BOXC޸---------------------------------------- +// --------------------------------------------------------------------------- +#define CAX_STOP_FUN // εһЩ,رմΪ +#ifndef CAX_STOP_FUN +#define CAX_RIDE_GENXIN // ·ɻ費 +#define _NO_QUICK_WAR // ֹ +#define _CAX_NPCTIME_OFF // ɾʱжNPC䣨CAX޸ģΪԵNPC䣬֧ijЩF +#endif + +#define _ITEM_COLOER // Ʒɫ +#define _SAME_IP_ONLINE_NUM // ͬIP½ +#define _CHECK_SEVER_IP // жϷIP +#define _FIX_CORE_LOOP // ޸CORE_LOOP +#define _FIX_CHAR_LOOP // ѭ +#define _FIX_SAVE_CHAR // 浵 +#define _CAX_ESC_FENGBAO // ESC +//#define _CAX_ESC_REPORT // ÿǩ +//#define _CAX_ESC_SAVE_DATA // ݱ +#define _FIX_COPY_MM_BUG // ޸MMBUG +//#define _TAKE_ITEMDAMAGE_FIX // װ +//#define _TAKE_ITEMDAMAGE_FOR_PET // װװ +#define _PETSKILL_SHOP_LUA // \̵LUA +#define _PLAYER_NPC // +#define _SERVER_DEF // ȫ +#define _CARD_PRODUCTION // 㿨[gm card ֵ]LNSֵӿ +#define _RECORD_IP // ¼IP +#define _CAX_FAMEBUTTON // ص-AB棬CFǷ񿪷 +#define _CAX_Mercenary // Ӷֶ +#define _PET_TRANS_ABILITY // ת +#define _PET_3TRANS // ת +#define _NO_MAGIC // ֹʹþͼ +#define _illegalpetskill_CF // ԶֹŴ\ +#define _FIX_SUPERPERSON_STRANS // ԼƷ˴ﵽ5תǿת6 +#define _CAX_LUA_BETT01 // LUAӽӿ +#define _LUA_Debug // LUA +#define _CAX_ADD_LUADX // LUAһЩչ +#define _CAX_PET_EVOLUTION // 2תںϿء// ںϳֵCF޸ // +#define _TRANS_7_COLOR // ͻǷPING// CFǷԻ +#define _CAX_PET_ITEMRIDE // װCF +#define _CAX_ZHUANGYUAN_QTJ // սʱֹʹõ߾ +#define _CAX_GM_RERIDE // ضride.exeļ +#define _CAX_GM_RESKILLCODE // ضskillcode.exeļ +#define _CAX_GM_RELEADERRIDE // ضleaderride.exeļ +#define _RIDEBUG // սBUGΪֹսͬһֻ +#define _DAMMAGE_CALC // Զ˺ +#define _FREE_SAVE // ¼ +#define _GM_SAVE_ALL_CHAR // GM浵 +#define _SPECIAL_SUIT // װ +#define _MANOR_EQUIP // ׯ԰רװ +#define _NULL_CHECK_ITEM // ͷ֧Ʊ +#define _RE_GM_COMMAND // ԶGM +#define _CAX_LNS_NLSUOXU // LNS-NL +#define _CAX_LNS_CHARSUOXU // LNS-CHAR +#define _CAX_LNS_NLGSUOXU // LNS-NLG +#define _CAX_LNS_MAPSUOXU // LNS-MAP +#define _CAX_LNS_MYSQLSUOXU // LNS-MYSQL +//#define _CAX_OFF_IPTABLES // ر˿Զǽã򿪴Ч +#define _CAX_FAME_KOUFEI // 10ÿ֤۷ +#define _CAX_ITEM_ADDEXP // Զǻ۹ʱ +//#define _CAX_FM_QISHINUM // رΪ1Ϊ2 #### 1.ǷΪС500ƹ 2.Ϊׯ԰ƵɣرΪ1Ϊ2 +//#define _CAX_METAMO_OFF // 򿪿ſͻ˱ɫ +#define _CAX_NEWMAC_LOGIN // 71ŷMACַ +#define _NO_STW_ENEMY // ֹҿ +#define _FM_FMPOINTPK_LIST // ׯ԰սб +#define _FM_NPC_LOOK_WAR // 岼Կսб,ۿսNPCBOXCɾĶսб +#define _FM_FMPOINTPK_LIST // ׯ԰սб +#define _CAX_NPCTIME_IF // NPCʱж +//########################CAXӶ0985ͻӦ޸################## +#define _CAX_TALK_LJIU // ֧˵ +#define _CAX_DENGON_GG // ֹ֧ +//###################################added by mo############################# +#define _SHARE_EXP // 鹲 +#define _TEAM_ADDEXP // Ӿӳ +#define _FIX_EARTHROUND // ޸һܳBUG +#define _FIX_ContinuationAttack //޸عĿ(3 5֮) +#define _TEAM_WARP // ޸ESCΪŶӴ +#define _FM_NPC_LOOK_WAR1 // 岼Կսб(Ӹ߰汾ׯ԰) +#define _DEX_FIX //ϵ +#define _LOCK_PET_ITEM // 󶨳 +//#define _PET_TRANS_SETANS //ֳ֧ת(ɾ˹) +#define _MAX_BEATITUDE_BUFF //ףӳ +#define _PETTRANS_RANGE //ֳ֧תΧ +#define _ITEM_LUA //LUA֧ +#define _FM_EXP_ADD //ׯ԰徭ӳ +#define _FIX_STW_SPEED_ENEMY // ޸ҿ +#define _NO_QUICK_WAR //ֹҿ +#define _FIX_LSSP_S_BUG //޸Sķֵͣ˵BUG +#define _UNLAW_THIS_LOGOUT // ֹԭ +#define _NO_JOINFLOOR //ֹӵͼ +#define _NO_HELP_MAP //ֹhelpͼ +#define _REGISTRATION_TIME //09ǩֶ +#define _FIX_TRADE_COPYPET //޸׸ƳBUG +#define _MO_LOGINCHECK //ֹСӹҵȷǷҵĵ¼֤ +#ifdef _MO_LOGINCHECK //XXTEA㷨һЩ +#define XXTEA_ROUND 8 // +#define XXTEA_KEY_1 1241503322 //key1 +#define XXTEA_KEY_2 1241503322 //key2 +#define XXTEA_KEY_3 1241503322 //key3 +#define XXTEA_KEY_4 1241503322 //key4 +#endif +#define _FIX_PLAYER_NPC_PET //ӼNPCɾĽӿ +#define _UNTEXT_TALK // ιؼ +#define _FIX_LONGCHARNAME_ATTACK //޸ֳ + +#define _AVOIEDamageCharName // ֹΣյ +#define _AVOIDATTACK_IN_CHAR_Talk_messageToLong // ֹ CHAR_Talk message ̫ +#define _AVOIDATTACK_IN_ADDRESSBOOK_sendMessage_textToLong // ֹ ADDRESSBOOK_sendMessage text ̫ +#define _AVOIDATTACK_IN_PETMAIL_sendPetMail_textToLong // ֹ PETMAIL_sendPetMail text ̫ +#define _AVOIDATTACK_IN_lssproto_WN_recv_dataToLong // ֹ lssproto_WN_recv data ̫ +#define _AVOIDATTACK_IN_ChatRoom_Create_messageToLong // ֹ ChatRoom_Create message ̫ +#define CC_ADD_ADDEXPCHECKDEGREE // (ɿ) ٷֱ ʱ:ͬɵ + + +//#define CXC_BOXC_WUGUA // ޹FãҵFر +#ifdef CXC_BOXC_WUGUA +#define _CAX_GUANZHAN // ޹Fʹõս /gz +#define _CAX_LVTISHI // ȼ1ijʾΪץȡԶɾ +#endif + +//##########ʯרԵdataʯҪر############################# +//#define _PET_AMOI__E // ٷļʽ +//#define _PETITEM__AMOI_E // ٷļʽ +//##################################################################################### +// +// + +// --------------------------------------------------------------------------- +// --------------------------------------------------------------------------- +#define _FAMILY_MANORNUM_CHANGE // CoolFish ޸װ԰(4.0) +#ifdef _FAMILY_MANORNUM_CHANGE +#ifdef CXC_BOXC_WUGUA +#define FAMILY_MAXHOME 2 // (4.0) ݵ +#define MANORNUM 2 // (4.0) ׯ԰ +#define FMPOINTNUM 2 // (4.0) оݵ +#else +#define FAMILY_MAXHOME 4 // (4.0) ݵ +#define MANORNUM 4 // (4.0) ׯ԰ +#define FMPOINTNUM 4 // (4.0) оݵ +#endif +#endif +#define _FMVER21 // (ɿ) ְƹ +#define _PERSONAL_FAME // (ɿ) Arminius 8.30 +// ------------------------------------------------------------------- +//רʯԶ Ա + +#define _EVERYONE_RIDE // (ɿ) Robin 0924 ƽ +// ------------------------------------------------------------------- +//ר Ա־ +#define _ATTACK_MAGIC // (ɿ) ṩսеĹ +#define _ADD_ACTION // (ɿ) һNPC״趨 + +// ------------------------------------------------------------------- +//ר߱ ԱС +#define _UNIQUE_P_I // (ɿ) CoolFish 2001/10/11 + +// ------------------------------------------------------------------- +//ר°ﴢpn ˷ 1018 Աѫ +#define _NEWSAVE // (ɿ) Robin +#define _STORECHAR // (ɿ) Robin +#define _DROPCHECK // (ɿ) Robin ֹظ +#define _DROPCHECK2 // (ɿ) Robin ֹظ +// ------------------------------------------------------------------- +//ר : Ա : +#define _PET_TRANS // (ɿ) ת +#define _NEW_WARPMAN // (ɿ) NPCWARP +#define _PET_TALK // (ɿ) Ի +#define _PET_LIMITLEVEL // (ɿ) () +#define _MAP_NOEXIT // (ɿ) ͼԭ&ԭǻָ +// ------------------------------------------------------------------- +// רGMָ㼶Reload ԱС +#define _GMRELOAD // (ɿ) CoolFish: 2001/11/12 +// ------------------------------------------------------------------- +// ר½ ԱС +#define _GAMBLE_ROULETTE // (ɿ) ij С +#define _FIX_GAMBLENUM // (ɿ) : ߿ۻ +#define _GAMBLE_BANK // (ɿ) ij +#define _DROPSTAKENEW // (ɿ) CoolFish: ijע +#define _PETRACE // (ɿ) CoolFish: 2001/12/3 ᄎٳ +#define _NEWEVENT // (ɿ) CoolFish: 2001/12/5 µ +// ------------------------------------------------------------------- +//ר Ա +#define _ITEM_FIRECRACKER // (ɿ) սʹñڿ԰ +// ------------------------------------------------------------------- +//¹ܣׯ԰PK(綨) Ա־ΰ־ +#define _MANOR_PKRULE // (ɿ) +// ------------------------------------------------------------------- +// ¹ܣ¹&\ Ա +#define _PSKILL_FALLGROUND // (ɿ) \ () +#define _ENEMY_FALLGROUND // (ɿ) NPC +#define _BATTLE_NEWPOWER // (ɿ) +#define _Item_MoonAct // (ɿ) ػ +#define _Item_DeathAct // (ɿ) ħ +#define _Item_PetAct // (ɿ) ѱ޽ָ +#define _Item_ReLifeAct // (ɿ) Ҫitemset1.txt ܿ) +#define _BATTLESTEAL_FIX // (ɿ) ͵ +#define _CFREE_petskill // (ɿ) Ҫpetskill1.txt ܿ) ѧϰ\ܼ +#define _data_newreadfile // (ɿ) µserver setup.cf itemset1.txt petskill1.txt µ +#define _ITEM_MAXUSERNUM // (ɿ) itemset1.txt ITEM ʹô +// ------------------------------------------------------------------- +//¹ܣ Ա +#define _PET_TALKPRO // (ɿ) Իǿ & END +#define _PRO_NPCFIX // (ɿ) NPCܼǿ +#define _PRO_BATTLEENEMYSKILL // (ɿ) սǿ NPCAI +#define _NEW_WARPPOINT // (ɿ) ͵жWARP +#define _FIX_CHECKITEM // (ɿ) ߲Ƿ +// ------------------------------------------------------------------- +//¹ܣ ԱС,WON +#define _ADD_ENCOUNT // (ɿ) WON ӵ޼ +#define _WON_PET_MAIL_LOG // (ɿ) WON Ҽij LOG +// ------------------------------------------------------------------- +// ¹ܣ 4.0 Ա, ־ΰ , , ־ +//#define _LOSE_FINCH_ // (ɿ) ANDY ȸ +#define _FIX_FAMILY_PK_LIMIT // (ɿ) WON սׯ԰ǰʮΪǰʮ +#define _ADD_POOL_ITEM // (ɿ) WON ӿɼķŵĵ +#define _ITEM_METAMO // (ɿ) shan metamo sprite. code:robin->shan +#define _ENEMY_ATTACK_AI // (ɿ) shan enemy attack mode. code:shan +#define _ITEM_TIME_LIMIT // (ɿ) shan time limit of item. code:shan +#define _MIND_ICON // (ɿ) shan show icon from char mind. code:shan +#define _BATTLENPC_WARP_PLAYER // (ɿ) shan npc warp player when n round. code:shan +#define _ITEM_WARP_FIX_BI // (ɿ) shan fix bbi to bi. code:shan +#define _SKILL_DAMAGETOHP // (ɿ) ANDY Ѫ +#define _Skill_MPDAMAGE // (ɿ) ANDY MP˺ +#define _WAEI_KICK // (ɿ) ANDY +#define _BATTLE_TIMESPEED // (ɿ) ANDY սʱ (ؿٹ) +#define _NEW_RIDEPETS // (ɿ) ANDY +#define _FIXBUG_ATTACKBOW // (ɿ) ANDY ʹͶbug +#define _NPCCHANGE_PLAYERIMG // (ɿ) ANDY NPCıͼ, ǿ,ͼ () +#define _ITEM_ATTSKILLMAGIC // (ɿ) ANDY ߼ +#define _EQUIT_DEFMAGIC // (ɿ) ANDY ħװ +#define _FIX_MAGICDAMAGE // (ɿ) ANDY ħʽ ڿ +#define _ITEM_CONSTITUTION // (ɿ) ANDY +#define _MAGIC_REHPAI // (ɿ) ANDY ѪAI +#define _TRANSER_MAN // (ɿ) ANDY ʦ +#define _TAKE_ITEMDAMAGE // (ɿ) ANDY ITEMSET2 +#define _FIX_FIRECRACKER // (ɿ) ANDY +#define _FIX_ITEMPROB // (ɿ) ANDY +#define _ADD_DEAMGEDEFC // (ɿ) ANDY ˺ & ӹ ITEMSET2 +#define _FIX_MAXCHARMP // (ɿ) ANDY MP +#define _ITEM_INSLAY // (ɿ) ANDY ⱦʯ +#define _ITEMSET2_ITEM // (ɿ) ANDY ITEMSET2 +#define _ITEM_NPCCHANGE // (ɿ) ANDY (, ) +#define _PETSKILL_FIXITEM // (ɿ) ANDY ޸ && ͬ +#define _FIX_SETWORKINT // (ɿ) ANDY (FIXWORKINT) +#define _ITEM_ADDEXP // (ɿ) vincent :ָʱӾֵ +#define _ITEM_ADDEXP2 // ǹʱۼ Robin +#define _FIX_METAMORIDE // (ɿ) ANDY +#define _CHECK_ITEMDAMAGE // (ɿ) 7/26 +#define _SKILL_WILDVIOLENT_ATT // (ɿ) vincent 輼:񱩹 +#define _MAGIC_WEAKEN // (ɿ) vincent : +#define _SKILL_WEAKEN // (ɿ) vincent 輼://Ҫ#define _MAGIC_WEAKEN +#define _SKILL_SPEEDY_ATT // (ɿ) vincent 輼:ٹ +#define _SKILL_GUARDBREAK2 // (ɿ) vincent 輼:Ƴ2 +#define _SKILL_SACRIFICE // (ɿ) vincent 輼:Ԯ +#define _PSKILL_MODIFY // (ɿ) ANDY ǿ +#define _PSKILL_MDFYATTACK // (ɿ) ANDY ת +#define _MAGIC_DEFMAGICATT // (ɿ) ANDY ħ +#define _MAGIC_SUPERWALL // (ɿ) ANDY ڷ +#define _OTHER_MAGICSTAUTS // (ɿ) ANDY +#define _SKILL_TOOTH // (ɿ) ANDY +#define _MAGIC_DEEPPOISON // (ɿ) vincent :綾 +#define _MAGIC_BARRIER // (ɿ) vincent :ħ +#define _MAGIC_NOCAST // (ɿ) vincent :Ĭ +#define _ITEM_CRACKER // (ɿ) vincent : //Ҫ#define _MIND_ICON +#define _SKILL_DEEPPOISON // (ɿ) vincent 輼:綾 //Ҫ#define _MAGIC_DEEPPOISON +#define _SKILL_BARRIER // (ɿ) vincent 輼:ħ //Ҫ#define _MAGIC_BARRIER +#define _SKILL_NOCAST // (ɿ) vincent 輼:Ĭ //Ҫ#define _MAGIC_NOCAST +#define _SKILL_ROAR // (ɿ) vincent 輼:() +#define _SKILL_REFRESH // (ɿ) vincent 輼:쳣״̬ +#define _ITEM_REFRESH // (ɿ) vincent 쳣״̬ +#define _MAGIC_TOCALL // (ɿ) kjl ٻ 02/06/20 kjl + +// ------------------------------------------------------------------- +// ¹ܣ Ա +#define _ITEMSET3_ITEM // (ɿ) ANDY itemset3.txt +#define _SUIT_ITEM // (ɿ) ANDY (װ) itemset3.txt +#define _PETSKILL_SETDUCK // (ɿ) ANDY 漼 +#define _VARY_WOLF // (ɿ) pet skill : vary wolf. code:shan +// ------------------------------------------------------------------- +// ¹ܣר5.0 Ա +#define _USEWARP_FORNUM // (ɿ) ANDY ë +#define _IMPRECATE_ITEM // (ɿ) ANDY +#define _MAGICPET_SKILL // (ɿ) ANDY ħ輼 +#define _ITEM_CHECKWARES // (ɿ) ANDY Ͳ +#define _NPC_REPLACEMENT // (ɿ) ANDY ûսnpc +#define _EMENY_CHANCEMAN // (ɿ) ANDY EMENY ѡ +#define _TYPE_TOXICATION // (ɿ) ANDY ж޷Ѫ +#define _PET_FUSION // (ɿ) ANDY ں enemybase1.txt +#define _NPC_FUSION // (ɿ) ANDY NPCں +#define _ITEM_EDITBASES // (ɿ) ANDY Ӫ +#define _PET_EVOLUTION // (ɿ) ANDY + +// ------------------------------------------------------------------- +// ¹ܣ5.0׷Ӳ Ա +#define _AVID_TRADETRYBUG // (ɿ) ANDY ֹж/ ()ʼ ʯ +#define _ASSESS_SYSEFFICACY // (ɿ) ANDY ϵͳЧ 12/04 +#define _ASSESS_SYSEFFICACY_SUB // (ɿ) Robin ϵͳЧ ӼڻȦ +#define _PREVENT_TEAMATTACK // (ɿ) ANDY ֹͬӻ 12/04 +#define _ITEM_ORNAMENTS // (ɿ) ANDY װε 12/04 //沿 +#define _CHIKULA_STONE // (ɿ) ANDY ֮ʯ 12/04 // +#define _SEND_EFFECT // (ɿ) WON ACѩЧ 12/04 +#define _PETMAIL_DEFNUMS // (ɿ) ANDY ʼ +#define _TEAM_KICKPARTY // (ɿ) ANDY ӳ(ս״̬) +#define _PETSKILL_TIMID // (ɿ) ANDY 輼-ս +#define _PETS_SELECTCON // (ɿ) ANDY ﲻɵѡս +#define _CHRISTMAS_REDSOCKS // (ɿ) ANDY ʥ +#define _FIX_ARRAYBUG // (ɿ) ANDY array λ +#define _USER_CHARLOOPS // (ɿ) ANDY LOOP +#define _BATTLE_PROPERTY // (ɿ) ANDY ս +#define _PETSKILL_PROPERTY // (ɿ) ANDY ħ޳輼 +#define _ITEM_FIXALLBASE // (ɿ) ANDY ޸֮ʯ +#define _ITEM_LOVERPARTY // (ɿ) ANDY ˽ڵ +#define _ITEM_FORUSERNAMES // (ɿ) ANDY +#define _BATTLECOMMAND_TIME // (ɿ) ANDY ֹҿ(غսʱ) +#define _NPCENEMY_ADDPOWER // (ɿ) ANDY ޸Ĺֵ + + +// ------------------------------------------------------------------- +// ¹ܣר6.0 Ա +// +#define _PETSKILL_CANNEDFOOD // (ɿ) ANDY \ܹͷ for 6.0 +#define _TEST_DROPITEMS // (ɿ) ANDY Զ +#define _MAP_WARPPOINT // (ɿ) ANDY Map WarpPoint +#define _TREASURE_BOX // (ɿ) ANDY +#define _BENEMY_EVENTRUN // (ɿ) ANDY սnpc +#define _BATTLE_ABDUCTII // (ɿ) ANDY ;ⷰ2 +#define _BATTLE_LIGHTTAKE // (ɿ) ANDY ɹ +#define _BATTLE_ATTCRAZED // (ɿ) ANDY +#define _STATUS_WATERWORD // (ɿ) ANDY ˮ״̬ +#define _ITEM_WATERWORDSTATUS // (ɿ) ANDY ˮ״̬ +#define _CAPTURE_FREES // (ɿ) ANDY ץ +#define _THROWITEM_ITEMS // (ɿ) нƷ +#define _OBJSEND_C // (ɿ) ANDY _OBJSEND_C +#define _ADD_SHOW_ITEMDAMAGE // (ɿ) WON ʾƷ;ö + +//-------------------------------------------------------------------------- +//ר 7.0 ְҵϵͳ Ա ־ + +#define _CHANGETRADERULE // (ɿ) Syu ADD ׹޶ +#define _TRADE_SHOWHP // (ɿ) Syu ADD ʾѪ +#define _SHOOTCHESTNUT // (ɿ) Syu ADD 輼 +#define _SKILLLIMIT // (ɿ) Syu ADD ùҷ +#define _TRADESYSTEM2 // (ɿ) Syu ADD ½ϵͳ +#define _NPC_NOSAVEPOINT // (ɿ) ANDY ¼㲻 +#define _ACFMPK_LIST // (ɿ) ANDY սб +#define _PETSKILL2_TXT // (ɿ) ANDY petskill2.txt +#define _PETSKILL_CHECKTYPE // (ɿ) ANDY \ʹʱ +#define _PETSKILL_TEAR // (ɿ) ANDY 輼 ˺˿ +#define _NPC_MAKEPAIR // (ɿ) ANDY NPC +#define _ITEMSET4_TXT // (ɿ) ANDY itemset4.txt +#define _ITEM_PILENUMS // (ɿ) ANDY زĶѵ itemset4 +#define _ITEM_PILEFORTRADE // (ɿ) ANDY ׶ѵ +#define _ITEM_EQUITSPACE // (ɿ) ANDY װλ +#define _PET_LOSTPET // (ɿ) ANDY ʧѰƻ +#define _ITEMSET5_TXT // (ɿ) ANDY itemset5.txt +#define _ITEMSET6_TXT // (ɿ) ANDY itemset6.txt +#define _EQUIT_ARRANGE // (ɿ) ANDY Ҫ itemset5.txt +#define _EQUIT_SEQUENCE // (ɿ) ANDY ˳ Ҫ itemset5.txt +#define _EQUIT_ADDPILE // (ɿ) ANDY ӿɶѵ Ҫ itemset5.txt +#define _EQUIT_HITRIGHT // (ɿ) ANDY Ҫ itemset5.txt +#define _EQUIT_NEGLECTGUARD // (ɿ) ANDY Ŀ% Ҫ itemset6.txt +#define _EQUIT_NEWGLOVE // (ɿ) ANDY λ +#define _FIX_MAX_GOLD // (ɿ) WON ADD Ǯ +#define _PET_SKILL_SARS // (ɿ) WON ADD ɷ +#define _SONIC_ATTACK // (ɿ) WON ADD +#define _NET_REDUCESEND // (ɿ) ANDY DBϴ +#define _FEV_ADD_NEW_ITEM // (ɿ) Change Ӹؾ +#define _ALLDOMAN // (ɿ) Syu ADD аNPC +#define _LOCKHELP_OK // (ɿ) Syu ADD ɼս +#define _TELLCHANNEL // (ɿ) Syu ADD Ƶ +// ¹ܣְҵ +#define _NEWREQUESTPROTOCOL // (ɿ) Syu ADD ProtocolҪϸ +#define _OUTOFBATTLESKILL // (ɿ) Syu ADD սʱProtocol +#define _CHAR_PROFESSION // (ɿ) WON ADD ְҵλ +#define _PROFESSION_SKILL // (ɿ) WON ADD ְҵ +#define _NPC_WELFARE // (ɿ) WON ADD ְҵNPC +#define _NPC_ADDLEVELUP // (ɿ) ANDY NPCҵȼ +#define _CHAR_FIXDATADEF // (ɿ) ANDY ϳʼ +//ϵͳ +#define _SIMPLIFY_ITEMSTRING // (ɿ) ANDY 򻯵ִ +#define _CHAR_NEWLOGOUT // (ɿ) ANDY dz» +#define _CHATROOMPROTOCOL // (ɿ) Syu ADD Ƶ 8/27 + +#define _CHAR_POOLITEM // (ɿ) ANDY ֿ߲⹲ +#define _NPC_DEPOTITEM // (ɿ) ANDY ֿ߲⹲ + +#define _SIMPLIFY_PETSTRING // (ɿ) ANDY 򻯳浵ִ +#define _SIMPLIFY_ITEMSTRING2 // (ɿ) ANDY 򻯵ִ2 +#define _WOLF_TAKE_AXE // (ɿ) WON ADD ץ˫ͷǵ +#define _FIX_UNNECESSARY // (ɿ) ANDY Ҫж +#define _ITEM_MAGICRECOVERY // (ɿ) ANDY ¹⾵ +//9/17 +#define _PETSKILL_GYRATE // (ɿ) Change 輼: +#define _PETSKILL_ACUPUNCTURE // (ɿ) Change 輼:Ƥ (client˵_PETSKILL_ACUPUNCTUREҲҪ) +#define _PETSKILL_RETRACE // (ɿ) Change 輼:׷ +#define _PETSKILL_HECTOR // (ɿ) Change 輼: +//10/13 +#define _PETSKILL_FIREKILL // (ɿ) Change 輼:ɱ +#define _PETSKILL_DAMAGETOHP // (ɿ) Change 輼:¿(Ѫı) +#define _PETSKILL_BECOMEFOX // (ɿ) Change 輼:Ļ + +//11/12 +#define _PETSKILL_SHOWMERCY // (ɿ) Change 輼: +#define _NPC_ActionFreeCmp // (ɿ) Change NPCµıȽϷʽ +//-------------------------------------------------------------------------- + + +//11/26 +#define _NPC_ProfessionTrans // (ɿ) Change ְҵNPCжת +#define _NPC_NewDelPet // (ɿ) Change NPCɾ(ԭ,ֻwarpmanʹʱɹ,һһ) +#define _ALLDOMAN_DEBUG // (ɿ) Change serverаʧbug +//20031217 +#define _CHRISTMAS_REDSOCKS_NEW // (ɿ) Change ʥ +#define _PETSKILL_COMBINED // (ɿ) Change 輼:ѵúͿ [ۺħ(ȡħ)] +//˽ڻ +#define _NPC_ADDWARPMAN1 // (ɿ) Change npcgen_warpmanӹ(趨趨Ů) +#define _ITEM_QUITPARTY // (ɿ) Change ɢʱض߼ʧ +#define _ITEM_ADDEQUIPEXP // (ɿ) Change װᾭֵ +//2004/2/18 +#define _ITEM_LVUPUP // (ɿ) Change ͻƳȼƵҩ(ר) +//2004/02/25 +#define _PETSKILL_BECOMEPIG // (ɿ) Change 輼: +#define _ITEM_UNBECOMEPIG // (ɿ) Change Ľҩ +#define _PET_TALKBBI // (ɿ) Change жbbi +#define _ITEM_USEMAGIC // (ɿ) Change ɵʹħ +//2004/04/07 +#define _ITEM_PROPERTY // (ɿ) Change ıԵ +#define _SUIT_ADDENDUM // (ɿ) Change װӹ (_SUIT_ITEMҪ) +//2004/05/05 +#define _ITEM_CHECKDROPATLOGOUT // (ɿ) Change ؼ¼ʱ޵dzʧ,,ɻؼ¼ +#define _FM_MODIFY // 幦޸() +#define _CHANNEL_MODIFY // Ƶ() +#define _STANDBYPET // Robin +#define _PROSKILL_OPTIMUM // Robin ְҵܴѻ +#define _PETSKILL_OPTIMUM // Robin \ܴѻ +#define _MAGIC_OPTIMUM // Robin Magic table ѻ +#define _AC_PIORITY // Nuke ACȨ(ɿ) +//2004/05/12 +#define _CHAR_POOLPET // (ɿ) Robin ֿ⹲ +#define _NPC_DEPOTPET // (ɿ) Robin ֿ⹲ +#define _MAGIC_RESIST_EQUIT // (ɿ) WON ADD ְҵװ + +// ------------------------------------------------------------------- +// +#define _NEWOPEN_MAXEXP // (ɿ) ANDY MAXֵ +// ------------------------------------------------------------------- +// ¹ܣGMƵ +//̰ +#define _REDHAT_V9 //(ɿ) Change REDHAT9.0İ汾±ʱ +//-------------------------------------------------------------------------- +//ר 7.5 л Աѫ С +#define _NPC_EXCHANGEMANTRANS // (ɿ) Change exchangemanжת +#define _ANGEL_SUMMON // Robin ʹٻ +#ifdef _ANGEL_SUMMON + #define _ADD_NEWEVENT +#endif +// Terry define start ------------------------------------------------------------------- +#define _STREET_VENDOR // ̯() +#define _WATCH_EVENT // ѯ() +#define _NEW_MANOR_LAW // ׯ԰() +#define _MAP_TIME // ͼ,ᵹ() +#define _PETSKILL_LER // ׶() + +// Terry define end ------------------------------------------------------------------- +#define _FIX_MAGIC_RESIST // (ɿ) Change ְҵħ +#define _ADD_DUNGEON // (ɿ) Change ׷ӵ +#define _PROFESSION_ADDSKILL // (ɿ) Change ׷ְҵ +#define _ITEM_ADDPETEXP // (ɿ) Change ӳᆳֵ(ɳԴ˵߳,ƽɻþֵ) +#define _TRANS_6 // (ɿ) Change 6ת +#define _PET_2TRANS // (ɿ) Change 2ת +#define _PET_2LIMITLEVEL // (ɿ) Change 2ת +#define _MAGICSTAUTS_RESIST // (ɿ) Change ()Ծ +#define _EQUIT_RESIST // (ɿ) Change һװ(ɿһ쳣״̬)п ħ Ĭ +#define _SUIT_TWFWENDUM // (ɿ) Change װ (_SUIT_ITEMҪ) +#define _EXCHANGEMAN_REQUEST_DELPET // (ɿ) Change exchangemanTYPE:REQUESTɾ +//-------------------------------------------------------------------------- +#define _DEL_DROP_GOLD // ɾϹʱʯ Robin +#define _ITEM_STONE // cyg ֵʯͷ +#define _HELP_NEWHAND // cyg ´ɫֵ) +#define _DEF_GETYOU // cyg GMָ ѯԼ Χڵʺ +#define _DEF_NEWSEND // cyg GMָ ʱɼӾҲɲ +#define _DEF_SUPERSEND // cyg GMָ ɴijʺΪĸ3 +#define _SUIT_ADDPART3 // (ɿ) Change װܵ ر% Ĭ% % % % +#define _PETSKILL_2TIMID // (ɿ) Change սڶ(ʨŭ) +#define _SHOW_FUSION // (ɿ) Change ںϳCLIENTֻʾת,޸ΪںϳʾΪں(clientҲҪ) +#define _FONT_SIZE // (ɿ) Robin ʹС +#define _PROSK99 // (ɿ) Change ְȼͰ +#define _TIME_TICKET // Robin ʱ볡 ɭ׽ +#define _HALLOWEEN_EFFECT // ʥЧ +#define _ADD_STATUS_2 // ״̬ڶ +#define _ADD_reITEM // (ɿ) Change λո +#define _ADD_NOITEM_BATTLE // NPCû߻ս +#define _PETSKILL_BATTLE_MODEL // \սģ +#define _PETSKILL_ANTINTER // (ɿ) Change 輼:֮ ο_PETSKILL_2TIMID +#define _PETSKILL_REGRET // (ɿ) Change 輼:һ ο_SONIC_ATTACK +#define _SUIT_ADDPART4 // (ɿ) Change װܵĵ ж% ǿʦħ(30%) ֿʦħ + +//ͨ------------------------------------- +#define _PUB_ALL +#ifdef _PUB_ALL +//#define _PROSKILL_ERR_KICK // ǷԶT +#define _ITEM_SETLOVER // 鹦 +#define _CREATE_MM_1_2 // Ʒٷ +#define _SendTo // ͵ +#define _GET_BATTLE_EXP // +#define _NEW_PLAYER_CF // ״̬ +#define _USER_EXP_CF // ûԶ徭 +#define _TRANS_LEVEL_CF // תԽ160 +#define _UNLAW_WARP_FLOOR // ֹ͵ +#define _UNREG_NEMA // ֹ +#define _GM_ITEM // GMƷ +#define _GM_METAMO_RIDE // GMг +#define _GM_RIDE // GMȨ +#define _LOCK_IP // IP +#define _POINT // +#define _VIP_SERVER // Ա +#define _WATCH_FLOOR // Զɹսͼ +#define _BATTLE_FLOOR // Զǿսͼ +#define _VIP_SHOP // Ա̵ +#define _LOOP_ANNOUNCE // ѭ +#define _SKILLUPPOINT_CF // Զ +#define _RIDELEVEL // Զȼ +#define _REVLEVEL // Զԭȼ +#define _FM_ITEM // +#define _LUCK_ITEM // +#define _NEW_PLAYER_RIDE // +#define _FIX_CHARLOOPS // ħʯʱ +#define _PLAYER_ANNOUNCE // +#define _BATTLE_GOLD // ȡͬʱýǮ +#define _ITEM_GOLD // ǮƷ +#define _PLAYER_NUM // +#define _PET_MM // ʯMM +#define _MYSTERIOUS_GIFT // +#define _RELOAD_CF // ضCF +#define _PET_UP // ɼ˶ij +#define _TRANS // ת +#define _TRANS_7 // ʵ7ת +#define _RIDEMODE_20 // 2.0ģʽ +#define _TALK_ACTION // ˵ +#define _ENEMY_ACTION // Ҳл +#define _CHAR_CDKEY // ֹ +#define _GMSV_DEBUG // GMSVϢ +#define _CHECK_PEPEAT // Ƿ +#define _SILENTZERO // Ʒ +#define _SAVE_GAME_ID // ʾķ +#define _ANGLE_EMAIL // ٺԶƬ +#define _ALL_TALK // Ƶ +#endif +//Ա׷ӹ-------------------------------------- +#define _VIP_ALL +#ifdef _VIP_ALL +#define _VIP_RIDE // Աڼ +#define _AUTO_PK // ԶPKϵͳ +#define _FM_METAMO // רñָ +#define _ITEM_METAMO_TIME // ԶĽָ +#define _SHOW_VIP_CF // ԶVIPˣ壬ʾʽ +#define _GM_KING // GMħ +//#define _MULTI_THREAD_KERNEL // д̺߳ +#define _ANGEL_TIME // Զ徫ٻʱ +#define _FM_POINT_PK // ׯ԰廥ׯ԰ +#define _PLAYER_MOVE // ˳ƹ +#define _BATTLE_PK // ǿPKߣ˻ؼ¼ +#define _FUSIONBEIT_TRANS // ںϳת +#define _FUSIONBEIT_FIX // ȡںϳ +#define _TRANS_7_NPC // תNPC +#define _MOMENTUM_NPC // ƽű +#define _DP_NPC // DPű +#define _RIDE_CF // Զ +#define _PET_LEVEL_ITEM // ȼƷ +#define _FM_LEADER_RIDE // 峤ר +//#define _DBSAVE_CHAR // ˫浵 +#define _FM_JOINLIMIT // ٴμʱ +#define _PET_BEATITUDE // ף +#define _ITEM_EFMETAMO // ñָ +#define _OPEN_E_PETSKILL // ųE +#define _ITEM_RIDE // ѱװ +#define _MAKE_MAP // ͼ +#define _MAKE_PET_CF // Զɳ +#define _GET_MULTI_ITEM // һθƷ +#define _VIP_ANNOUNCE // Աϵͳ +#define _NOWEN_EV // ԶNOWEN +#define _NEW_NAME // Զƺ +#define _MAKE_PET_ABILITY // Χ +#define _ZANZHU_SERVER // ϵͳ +#define _TRADE_PK // IJPK +#define _JK_CF_DELPETITEM // ɾCFõij͵ +#define _SAFE_PASSWORD // ȫ +#define _POINT_CARD // ֵ +#define _NEED_ITEM_ENEMY // Զץ +#define _SUPER_MAN_ITEM // Ʒ˵ +#define _DIY_INSLAY // ԶװǶ +#define _MAP_HEAL // Զͼսָ +#define _NO_WARP +//#define _BATTLE_NO_WANG // ׶ħŲ +#define _LUCK_MAN // +#define _QUESTION_ONLINE // ʴ +#define _ONLINE_SHOP // ̳ +#define _SQL_BUY_FUNC // +#define _MYSQL_GMSV // MYSQL +#ifdef _MYSQL_GMSV + #define _SASQL +#endif +#define _8018_SA // 8018֧ +//ӹܿʼ +#define _NO_STREET_MAP // ɰ̯ͼ +#define _TRANS7_POINT // ת +#define _PET_BUG // BUG +//#define _JOB_AUTOPK // ְҵԶPK +#define _EV_NUM // ܻ +#define _ALL_ITEM // ȫֱ +#define _NOJOB_PK // ְҵPK +#define _NONUM_AUTOPK // ̭ԶPK +//#define _NO_ATTACK // CC +#define _NO_TRANS_ANGLE // 6ת辫ٻ +#define _VIGOR_SYS // ϵͳ +#define _OFFLINE_SYSTEM // ߹һ +#define _NPCENEMY_1 // NPCENEMY +#define _WAN_FIX // Ż޸ +#define _WARNPC_CTRL // ħϵͳٺͬһIPӣ +#define _ITEM_RESET // ߻¯ͻ +#define _NO_DAOLUAN // ֹϵͳ +#define _FMWAR_PLAYERNUM // Զս +#define _PETMAIL_LV // ʼʼijȼƺͿ +#define _FMZUZHANG_MSG // ׯ԰峤֪ͨ +#define _FM_WELFARE // ׯ԰帣 +#define _FMWAR_MSG // Զׯ԰սش +#define _ZHIPIAO_SYSTEM // ֧Ʊϵͳ +#define _FM_SERVERNO_SYS // ָ·崴ͽɢ +#define _BATTLEMAP_CTRL // ָͼսʱ +#define _STU_SYS // ʦͽϵͳǿ +#define _NPC_ITEMUP // NPC +#define _NO_DROPITEM // 󶨵ߣʱʾ +#define _PET_RESET // ¯ +#define _FMRANK_POINT // 徺 +#define _PETSKILL_DEL_SHOP // \ܻ¯ +#define _ASSA_TOP // С֧ +#define _NPC_PETSKILLUP // NPC\ܽ +#define _PETSKILL_BINDING // \ܰ󶨣żܵijﲻܽףӳ̯ +#define _PETSKILL_DEL_NPC // \ܻ¯ +#define _NO_FULLPLAYER_ATT // ˹ +#define _ATTREVERSE_FIX // Իԭ޸ +#define _NEWFM_GOLD // ½ҪǮ +#define _PSKILL_GYRATE // GYRATE\ǿ +#define _PSKILL_BATTLE_MODEL // Ⱥ\ǿ +#define _JOB_FIX // ְҵƽ +#define _RMB_SYSTEM // ֽ˻ϵͳ +#define _PET_STANDBY // սв +#define _MERGE_TIME // Զϳʱ +#define _EXP_TIME_OUT // ϢʾЧʱ +#define _PETUP_GET_EXP // ǿƶ131-140飬131ǰ60000 +//#define _MM_NO_JIAOBEN // ֹMMű +#define _CHANGE_PETNAME_FIX // ޸ݻBUG +#define _DP_ZHIPIAO_ITEM // DP֧Ʊ +#define _DP_140_160_MODE // ȡԭDPģʽΪ14010W160100W +//#define _NPC_RAND_MSG // NPCм֤Ӽж +#define _PETSKILL_NONO_FIX // ޸\صBUG +#define _LOOK_STREET_TIME // ̯ʱ䣬ֹ̯ +#define _BATTLE_EQUIT_OTHER // սǷɻԼƷ +#define _PK_LUCK_MAN // PK˶ +#define _SUPERMAN_FIX // Ʒ˵ʱ +#define _DROPITEM_COLOR // ʧĵ߸ıɫ +#define _ALL_RANDMODE // ű֤ģʽ +#define _PICKUP_ITEM_OTHER // ӵߺǷֻԼȡ +#define _FM_LIAOLI // ͿԼ +#define _TRADE_ITEM_FIX // ̯ʱʾʵ +#define _PETMAIL_TIME // ʼԶʱ䣨Ҳdzݣ +#define _GJS_TYPE // ⾵ǷԶԶԷʹ +#define _PET_BINDING // 󶨣*ֵijﲻܽףӳ̯ +//#define _NOT_PETRIDE // ƣ*ֵijﲻˣ +#define _BATTLEEND_FIX // ͼս˳ʱ䱣120 +#define _BIG_POOL_TYPE // ֻֿȡԴ +#define _ONLINENUM_FIX // ͻ1024 +#define _FLOOR_PARTY_CTRL // ָͼ +#define _NO_RIDE_ID // CFָﲻҪ֤ +#define _STREET_FAX // ̯˰ +#define _XC_CANGKU // ֿ +#endif + +//1717sq------------------------------------------ +//ABLUA------------------------------------------- +#define _ALLBLUES_LUA // ʹLUAű +#ifdef _ALLBLUES_LUA + #define _ALLBLUES_LUA_1_1 + #define _ALLBLUES_LUA_1_2 + #define _ALLBLUES_LUA_1_3 + #define _ALLBLUES_LUA_1_4 + #define _ALLBLUES_LUA_1_5 + #define _ALLBLUES_LUA_1_6 + #define _ALLBLUES_LUA_1_7 + #define _ALLBLUES_LUA_1_8 + #define _ALLBLUES_LUA_1_9 + #define _ALLBLUES_LUA_2_0 // LUA2.0 +#endif + +#define _NEW_CurrencyShow // µĻʾ +#define _CAMEO_MONEY // ֧ABֶ +#define _MISSION_TRAIN // ֧ABֶ +#define _PET_EVOLVE // ֧ABֶ +#define _FLOOR_DIFI_FIELD // ֧AB¥ֶ +#define _MISSION_TIME // ֧ABʱֶ +#define _PLAYER_TITLE // ֧ABƺŵȼֶ +#define _COWRIE // ֧ABֶ +#define _ONLINE_TIME // ֧ABʱֶ +#define _SPECIAL_COUNTER // ֧ABֶ +#define _SPECIAL_TIMER // ֧ABʱֶ +#define _setVipPointForCdkey // ֧ABsetVipPointForCdkeySQL(setVipPointgetVipPoint֧) +#define _VIP_BATTLE_EXP // Աս޸IJ +#define _ALLBLUES_LUA_NEWADD // ӵABLUAӿ +#ifdef _ALLBLUES_LUA_NEWADD + #define _AutoBattle_LUA // ԭ +#endif + + +//˽汾---------------------------------------- +#define _SA80 +#ifdef _SA80 +//#define _TEST +#ifndef _TEST +//#define _DEFAULT_PKEY "17csajkjz" // ( ʯ 8.0 ) +//#define _RUNNING_KEY "20081026" // ( ʯ 8.0 ) +//#define _SA_VERSION 'C' +#define _DEFAULT_PKEY "www.longzoro.com" // ( ʯ 8.0 ) +#define _RUNNING_KEY "www.longzoro.com" // ( ʯ 8.0 ) +#define _SA_VERSION 'L' +#define _ITEM_TYPETABLE // (ɿ) Change ׷typetable +#define _RIGHTCLICK // Robin Ҽ +#define _JOBDAILY // cyg ־ +#define _ALCHEMIST // Robin +#define _TEACHER_SYSTEM // ʦϵͳ() +#define _PET_ITEM // װ +#else +#define _SA_VERSION 'F' +#define _DEFAULT_PKEY "upupupupp"// ( ʯ 7.5 ) +#define _RUNNING_KEY "20060707" // ( ʯ 7.5 ) +#endif +#define SERVER_VERSION "GMSV-v1.0.0" +#else +//#define _SA75 +#ifdef _SA75 +#define _DEFAULT_PKEY "ttttttttt"// ( ʯ 7.5 ) +#define _RUNNING_KEY "20041215" // ( ʯ 7.5 ) +#else +#define _DEFAULT_PKEY "upupupupp"// ( ʯ 7.5 ) +#define _RUNNING_KEY "20060427" // ( ʯ 7.5 ) +#define _SA_VERSION_80 // ʯʱ8.0 İ汾 +#endif +#define _SA_VERSION 'F' +#define _FIX_FM_FMPOINT // ޸ļݵʾʽ +#define SERVER_VERSION "GMSV-v1.0.0" +#endif + +#define _JZ_NEWSCRIPT_LUA // LUAű + +//⹦ܿ---------------------------------------- +#define _YUANGUSA +#define _FreeServerVersion // Ź +#ifdef _FreeServerVersion + #define _NOT_POJIE // GM + #define _LUA_RootSSH // LUAȡroot(1717sqʾ:лʹõ) +#endif + + +//#define _DEBUG // +//#define _TEST_SERVER // Է +#endif + +#define _17CSA_VERSION "8002" +//#define _17CSA_YANZHENG //ǿ֤ diff --git a/include/version_pk.h b/include/version_pk.h new file mode 100644 index 0000000..dd5b101 --- /dev/null +++ b/include/version_pk.h @@ -0,0 +1,9 @@ +#ifndef _PKSERVER_VERSION_H_ +#define _PKSERVER_VERSION_H_ + +//#define _PKSEVER_VER // (ɿ) ϵpkŷ + +// +// +//ּ +#endif diff --git a/include/vssver.scc b/include/vssver.scc new file mode 100644 index 0000000..2902d88 Binary files /dev/null and b/include/vssver.scc differ diff --git a/init.c b/init.c new file mode 100644 index 0000000..89a0d9c --- /dev/null +++ b/init.c @@ -0,0 +1,814 @@ +#include "version.h" +#include +#include +#include +#include + + +#include "configfile.h" +#include "util.h" +#include "net.h" +#include "msignal.h" +#include "buf.h" +#include "object.h" +#include "char.h" +#include "char_data.h" +#include "item.h" +#include "readmap.h" +#include "function.h" +#include "saacproto_cli.h" +#include "lssproto_serv.h" +#include "readnpc.h" +#include "log.h" +#include "handletime.h" +#include "title.h" +#include "encount.h" +#include "enemy.h" +#include "battle.h" +#include "magic_base.h" +#include "pet_skill.h" +#include "item_gen.h" +#include "petmail.h" +#include "npc_quiz.h" +#ifdef _ALLBLUES_LUA +#include "mylua/mylua.h" +#endif +#ifdef _PROFESSION_SKILL // WON ADD ְҵ +#include "profession_skill.h" +#endif + +#ifdef _ITEM_QUITPARTY +#include "init.h" +//int itemquitparty_num = 0; +//static DisappearItem *Disappear_Item; +#endif + +#define MESSAGEFILE "hoge.txt" + +#define OPTIONSTRING "d:f:h" +#define usage() print( "Usage: %s ["OPTIONSTRING"]\n", getProgname() ); +extern int yzflg; +void printUsage( void ) +{ + usage(); + /*print( "Usage: %s ["OPTIONSTRING"]\n", progname );*/ + print( " [-d debuglevel] default value is 0\n" ); + print( " [-f configfilename] default value is setup.cf\n" + ); +} + +/* + * + * ¦ + * ߯Ի + * TRUE(1) ئѨ̼¦ѷ + * FALSE(0) ئѨ̼¦ѷ + */ +BOOL parseCommandLine( int argc , char** argv ) +{ + int c; /* getopt ƥ */ + extern char* optarg; /* getopt ƥ */ + + + while( ( c = getopt( argc, argv ,OPTIONSTRING )) != -1 ){ + switch( c ){ + case 'd': + { + int debuglevel; + if( !strtolchecknum( optarg, (int*)&debuglevel, 10, + INT)){ + print( "Specify digit number\n" ); + return FALSE; + } + setDebuglevel( debuglevel ); + break; + } + case 'f': + setConfigfilename( optarg ); + break; + case 'h': + printUsage(); + return FALSE; + break; + + default: + printUsage(); + return FALSE; + break; + + } + } + return TRUE; +} + + +/* + * ¦ + * + * ἰئ + */ +BOOL parseEnvironment( char** env ) +{ + if( getDebuglevel() >= 3 ){ + int index=0; + while( env[index] != NULL )print( "%s " , env[index++] ); + print( "\n" ); + } + return TRUE; +} + + + + +#define LSGENWORKINGBUFFER 65536*4 + + + +#define GOTORETURNFALSEIFFALSE(x) if(!(x))goto RETURNFALSE +/* + * + * ¦ + * argc argv + * argv Ѩ̼¦ + * ߯Ի + */ +BOOL init(int argc , char** argv , char** env ) +{ +#ifdef _ITEM_QUITPARTY + FILE *f; + int i; + char line[256]; +#endif + srand( getpid()); + print( "This Program is compiled at %s %s by gcc %s\n", + __DATE__ , __TIME__ , __VERSION__ ); + + defaultConfig( argv[0] ); + signalset(); + + GOTORETURNFALSEIFFALSE(parseCommandLine( argc , argv )); + GOTORETURNFALSEIFFALSE(parseEnvironment( env )); + + { + Char aho; + debug( sizeof( aho ), d); + debug( sizeof( aho.data ), d); + debug( sizeof( aho.string ), d); + debug( sizeof( aho.flg ),d); + debug( sizeof( aho.indexOfExistItems ), d); + debug( sizeof( aho.haveSkill ), d); + debug( sizeof( aho.indexOfHaveTitle ), d); + debug( sizeof( aho.addressBook ),d); + debug( sizeof( aho.workint ),d); + debug( sizeof( aho.workchar ),d); + } + + print( "ļ: %s\n" , getConfigfilename() ); + + GOTORETURNFALSEIFFALSE(readconfigfile( getConfigfilename() ) ); + + nice(getrunlevel()); + //ttom start + { int iWork = setEncodeKey(); + if( iWork == 0 ){ + // ޼ƽëɬ + printf( "----------------------------------------\n" ); + printf( "-------------[] ޷ %s\n", getConfigfilename() ); + printf( "----------------------------------------\n" ); + exit( 1 ); + }else{ + // ޼ƽëɬ + printf( " = %d\n", iWork ); + } + } + // AcWBuffëɬ + { int iWork = setAcWBSize(); + if( iWork == 0 ){ + printf( "----------------------------------------\n" ); + printf( "-------------[AC] ޷ %s\n", getConfigfilename() ); + printf( "----------------------------------------\n" ); + exit( 1 ); + }else{ + printf( "AC = %d\n", iWork ); + } + } + //ttom end + + if( getDebuglevel() >= 1 ){ +// print("ServerType: %d\n", getServerType() ); + print("Եȼ: %d\n", getDebuglevel() ); + print("еȼ: %d\n", getrunlevel() ); + print("ջ: %d\n", getrecvbuffer()*1024); + print("ͻ: %d\n", getsendbuffer()*1024); + print("ջ: %d\n", getrecvlowatbuffer()); + print("ڴ浥ԪС: %d\n", getMemoryunit() ); + print("ڴ浥Ԫ: %d\n", getMemoryunitnum() ); + + print("˺ŷַ: %s\n", getAccountservername() ); + print("˺ŷ˿: %d\n", getAccountserverport() ); + print("½: %s\n", + getGameservername()); + print("½: %s\n", getAccountserverpasswd()); + + print("ȴӶ˿: %d\n", getPortnumber() ); + + print("к: %d\n", getServernumber() ); + + print("ظַʹ: %d\n", getReuseaddr() ); + + + print(": %d\n", getFdnum() ); + print("߳: %d\n", getPetcharnum() ); + print("Ŀ: %d\n", getOtherscharnum() ); + print("Ŀ: %d\n", getObjnum() ); + print("ƷĿ: %d\n", getItemnum() ); + print("սĿ: %d\n", getBattlenum() ); + print("ļĿ¼: %s\n", getTopdir()); + print("ͼļĿ¼: %s\n", getMapdir()); + print("ͼʶļ: %s\n", getMaptilefile()); + print("Ʒļ: %s\n", getItemfile()); + print("սļ: %s\n", getInvfile()); + print("ʾλļ: %s\n", getAppearfile()); + print("ļ: %s\n", getEffectfile()); + print("ͷļ: %s\n", getTitleNamefile()); + print("ͷļ: %s\n", getTitleConfigfile()); + print("ļ: %s\n", getEncountfile()); + print("Ⱥļ: %s\n", getGroupfile()); + print("ļ: %s\n", getEnemyBasefile()); + print("ļ: %s\n", getEnemyfile()); + print("ħļ: %s\n", getMagicfile()); + +#ifdef _ATTACK_MAGIC + print("ħļ: %s\n", getAttMagicfileName() ); +#endif + + print("\ļ: %s\n", getPetskillfile()); + +#ifdef _PROFESSION_SKILL // WON ADD ְҵ + print("ְҵļ: %s\n", getProfession()); +#endif + + print("Ʒɷļ: %s\n", getItematomfile()); + print("ļ: %s\n", getQuizfile()); +#ifdef _GMRELOAD + print("G M ļ: %s\n", getGMSetfile()); +#endif + print("־¼ļ: %s\n", getLsgenlogfilename() ); + print("ԭĿ¼: %s\n", getStoredir()); + print("NPC Ŀ¼: %s\n", getNpcdir()); + print("־ļ: %s\n", getLogdir()); + print("־ļ: %s\n", getLogconffile() ); + print("GMָ: %s\n", getChatMagicPasswd() ); + print("ʹGMȨ: %d\n", getChatMagicCDKeyCheck() ); + + print("NPC ģĿ: %d\n", getNpctemplatenum() ); + print("NPC Ŀ: %d\n", getNpccreatenum() ); + + print("·ʱ: %d\n", getWalksendinterval()); + print("м: %d\n", getCAsendinterval_ms()); + print("Ŀ: %d\n", getCDsendinterval_ms()); + print("ִһʱ: %d\n", getOnelooptime_ms()); + print("ʱ: %d\n", getPetdeletetime()); + print("ʱ: %d\n", getItemdeletetime()); +#ifdef _DEL_DROP_GOLD + print("ʯʱ: %d\n", getGolddeletetime()); +#endif + print("ݱ: %d\n", getCharSavesendinterval()); + + print("ƬĿ: %d\n", getAddressbookoffmsgnum()); + print("ȡƵЭ: %d\n" ,getProtocolreadfrequency()); + + print("Ӵ: %d\n", getAllowerrornum()); +#ifdef _GET_BATTLE_EXP + print("ս鱶: %d\n", getBattleexp() ); +#endif +#ifdef _NEW_PLAYER_CF + print("ת: %dת\n", getNewplayertrans()); + print("ȼ: %d\n", getNewplayerlv()); + print("Ǯ: %d S\n", getNewplayergivegold()); + print("ȼ: %d\n", getNewplayerpetlv()); +#ifdef _VIP_SERVER + print("ӵе: %d\n", getNewplayergivevip()); +#endif + print("ȼ: %d\n", getRidePetLevel()); +#ifdef _NEW_PLAYER_RIDE + print(": %s\n", getPlayerRide()); +#endif + print("ӵг: NO1:%d NO2:%d NO3:%d NO4:%d NO5:%d\n",getNewplayergivepet(0), + getNewplayergivepet(1), + getNewplayergivepet(2), + getNewplayergivepet(3), + getNewplayergivepet(4)); + print("ӵƷ: ITEM1:%d ITEM2:%d ITEM3:%d ITEM4:%d ITEM5:%d\n" + "ITEM1:%d ITEM2:%d ITEM3:%d ITEM4:%d ITEM5:%d\n" + "ITEM1:%d ITEM2:%d ITEM3:%d ITEM4:%d ITEM5:%d\n" + ,getNewplayergiveitem(0) + ,getNewplayergiveitem(1) + ,getNewplayergiveitem(2) + ,getNewplayergiveitem(3) + ,getNewplayergiveitem(4) + ,getNewplayergiveitem(5) + ,getNewplayergiveitem(6) + ,getNewplayergiveitem(7) + ,getNewplayergiveitem(8) + ,getNewplayergiveitem(9) + ,getNewplayergiveitem(10) + ,getNewplayergiveitem(11) + ,getNewplayergiveitem(12) + ,getNewplayergiveitem(13) + ,getNewplayergiveitem(14)); +#endif +#ifdef _UNREG_NEMA + print("ֹ: 1:%s 2:%s 3:%s 4:%s 5:%s\n",getUnregname(0), + getUnregname(1), + getUnregname(2), + getUnregname(3), + getUnregname(4)); +#endif +#ifdef _UNLAW_WARP_FLOOR + print("ֹ͵ͼ: ͼ1:%d ͼ2:%d ͼ3:%d ͼ4:%d ͼ5:%d\n" + " ͼ1:%d ͼ2:%d ͼ3:%d ͼ4:%d ͼ5:%d\n",getUnlawwarpfloor(0), + getUnlawwarpfloor(1), + getUnlawwarpfloor(2), + getUnlawwarpfloor(3), + getUnlawwarpfloor(4), + getUnlawwarpfloor(5), + getUnlawwarpfloor(6), + getUnlawwarpfloor(7), + getUnlawwarpfloor(8), + getUnlawwarpfloor(9)); +#endif +#ifdef _WATCH_FLOOR + print("Ƿȫͼս: %s\n",getWatchFloorCF()); + if(strcmp(getWatchFloorCF(),"")) + print("սͼ: ͼ1:%d ͼ2:%d ͼ3:%d ͼ4:%d ͼ5:%d\n",getWatchFloor(1), + getWatchFloor(2), + getWatchFloor(3), + getWatchFloor(4), + getWatchFloor(5)); +#endif + +#ifdef _BATTLE_FLOOR + print("Ƿǿս: %s\n",getBattleFloorCF()); + if(strcmp(getBattleFloorCF(),"")) + print("ǿսͼ: ͼ1:%d ͼ2:%d ͼ3:%d ͼ4:%d ͼ5:%d\n",getBattleFloor(1), + getBattleFloor(2), + getBattleFloor(3), + getBattleFloor(4), + getBattleFloor(5)); +#endif + +#ifdef _TRANS_LEVEL_CF + print("ȼת: %d\n",getChartrans()); + print("ȼת: %d\n",getPettrans()); +#endif + +#ifdef _POINT + print("ֹ: %s\n",getPoint()); + if(strcmp(getPoint(),"")) + print("ÿת: 0ת:%d 1ת:%d 2ת:%d 3ת:%d 4ת:%d 5ת:%d 6ת:%d\n",getTransPoint(0), + getTransPoint(1), + getTransPoint(2), + getTransPoint(3), + getTransPoint(4), + getTransPoint(5), + getTransPoint(6)); +#endif +//#ifdef _PET_UP +// print("ܷ: %s\n",getPetup()); +//#endif +#ifdef _LOOP_ANNOUNCE + print("ѭ·: %s\n",getLoopAnnouncePath()); + print("ѭʱ: %d\n",getLoopAnnounceTime()); +#endif +#ifdef _SKILLUPPOINT_CF + print("ÿ: %d\n",getSkup()); +#endif + +#ifdef _RIDELEVEL + print("ȼ: %d\n",getRideLevel()); +#endif +#ifdef _REVLEVEL + print("ԭ޵ȼ: %s\n",getRevLevel()); +#endif +#ifdef _TRANS_LEVEL_CF + print("һȼ: %d\n",getYBLevel()); + print("ߵȼ: %d\n",getMaxLevel()); +#endif +#ifdef _FIX_CHARLOOPS + print("ħʱ䱶: %d\n",getCharloops()); +#endif +#ifdef _PLAYER_ANNOUNCE + if(getPAnnounce()==-1) + print("ĵ: رʹ\n"); + else + print("ĵ: %d\n",getPAnnounce()); +#endif +#ifdef _PLAYER_MOVE + if(getPMove()==-1) + print("˳ĵ: رʹ\n"); + else + print("˳ĵ: %d\n",getPMove()); +#endif +#ifdef _BATTLE_GOLD + print("սýǮ: %d%\n",getBattleGold()); +#endif +#ifdef _ANGEL_TIME + print("ٻʱ: (%d/)\n",getAngelPlayerTime()); + print("ٻ: %d\n",getAngelPlayerMun()); +#endif +#ifdef _RIDEMODE_20 + print("2.0 ģʽ: %d\n",getRideMode()); +#endif +#ifdef _FM_POINT_PK + print("ׯ԰ģʽ: %s\n",getFmPointPK()); +#endif +#ifdef _CAX_ESC_REPORT + print("ͨԱǩ: ITEM1:%d ITEM2:%d ITEM3:%d ITEM4:%d ITEM5:%d\n" + ,getReportItem(0) + ,getReportItem(1) + ,getReportItem(2) + ,getReportItem(3) + ,getReportItem(4)); + print("VIP Աǩ: ITEM1:%d ITEM2:%d ITEM3:%d ITEM4:%d ITEM5:%d\n" + ,getVipReportItem(0) + ,getVipReportItem(1) + ,getVipReportItem(2) + ,getVipReportItem(3) + ,getVipReportItem(4)); +#endif + } + + { //andy_add 2003/05/05 check GameServer Name + char *GameServerName; + GameServerName = getGameserverID(); + if( GameServerName == NULL || strlen( GameServerName) <= 0 ) + return FALSE; + print("\nϷID: %s\n", GameServerName ); + } + print("ʼʼ\n" ); + #ifdef _TRANS_7_COLOR + if(getping()) + { + print("ʾ\n"); + system("echo 1 > /proc/sys/net/ipv4/icmp_echo_ignore_all"); + }else + { + print("ʾ\n"); + system("echo 0 > /proc/sys/net/ipv4/icmp_echo_ignore_all"); + } +#endif +//#define DEBUG1( arg... ) if( getDebuglevel()>1 ){##arg} + print( "ڴռ..." ); + GOTORETURNFALSEIFFALSE(configmem( getMemoryunit(), + getMemoryunitnum() ) ); + GOTORETURNFALSEIFFALSE(memInit()); + print( "\n" ); + + print( "ʼջӿռ..." ); + if( !initConnect(getFdnum()) ) + goto MEMEND; + print( "\n" ); + while( 1 ){ + print( "԰󶨱ض˿ %d... " , getPortnumber()); + bindedfd = bindlocalhost( getPortnumber() ); + if( bindedfd == -1 ) + sleep( 10 ); + else + break; + } + print( "\n" ); + + print( "..." ); + if( !initObjectArray( getObjnum()) ) + goto CLOSEBIND; + print( "\n" ); + + print( "..." ); +#ifdef _OFFLINE_SYSTEM + if(!CHAR_initCharArray( getPlayercharnum(), getPetcharnum(),getOtherscharnum()) ) +#else + if(!CHAR_initCharArray( getFdnum(), getPetcharnum(),getOtherscharnum()) ) +#endif + goto CLOSEBIND; + print( "\n" ); + print( "Ʒ..."); + if(!ITEM_readItemConfFile( getItemfile()) ) + goto CLOSEBIND; + if(!ITEM_initExistItemsArray( getItemnum() ) ) + goto CLOSEBIND; + print( "\n" ); + + print( "ս..." ); + if(!BATTLE_initBattleArray( getBattlenum() ) ) + goto CLOSEBIND; + print( "\n" ); + + print( "ģ..." ); + if( !initFunctionTable() ) + goto CLOSEBIND; + print( "\n" ); + +// print("ʼ˺Űȫ..."); +// if( !cdkeyinit() ) +// goto CLOSEBIND; +// print( "\n" ); + + print( "ʼʼ..." ); + if( !PETMAIL_initOffmsgBuffer( getAddressbookoffmsgnum() )) + goto CLOSEBIND; + print( "\n" ); + + print( "ȡսļ..." ); + if( !CHAR_initInvinciblePlace( getInvfile() ) ) + goto CLOSEBIND; + print( "\n" ); + + print( "ȡʾλļ..." ); + if( !CHAR_initAppearPosition( getAppearfile() ) ) + goto CLOSEBIND; + print( "\n" ); + + print( "ȡͷļ..." ); + if( !TITLE_initTitleName( getTitleNamefile() ) ) + goto CLOSEBIND; + print( "\n" ); + + print( "ȡͷļ..." ); + if( !TITLE_initTitleConfig( getTitleConfigfile() ) ) + goto CLOSEBIND; + print( "\n" ); + + print( "ȡļ..." ); + if( !ENCOUNT_initEncount( getEncountfile() ) ) + goto CLOSEBIND; + print( "\n" ); + + print( "ȡļ..." ); + if( !ENEMYTEMP_initEnemy( getEnemyBasefile() ) ) + goto CLOSEBIND; + print( "\n" ); + + print( "ȡļ..." ); + if( !ENEMY_initEnemy( getEnemyfile() ) ) + goto CLOSEBIND; + print( "\n" ); + + print( "ȡȺļ..." ); + if( !GROUP_initGroup( getGroupfile() ) ) + goto CLOSEBIND; + print( "\n" ); + print( "ȡħļ..." ); + if( !MAGIC_initMagic( getMagicfile() ) ) + goto CLOSEBIND; + print( "\n" ); + + #ifdef _ATTACK_MAGIC + + print( "ȡħļ..." ); + + if( !ATTMAGIC_initMagic( getAttMagicfileName() ) ) +// if( !ATTMAGIC_initMagic( getMagicfile() ) ) + goto CLOSEBIND; + + print( "ħļ -->%s..." , getAttMagicfileName()); + print( "\n" ); + + #endif + + print( "ȡ\ļ..." ); + if( !PETSKILL_initPetskill( getPetskillfile() ) ) + goto CLOSEBIND; + print( "\n" ); + +#ifdef _PROFESSION_SKILL // WON ADD ְҵ + print( "ȡְҵļ..." ); + if( !PROFESSION_initSkill( getProfession() ) ){ + goto CLOSEBIND; + } + print( "\n" ); +#endif + + /* ʧ ة ë */ + print( "ȡƷɷļ..." ); + if( !ITEM_initItemAtom( getItematomfile()) ) + goto CLOSEBIND; + print("\n" ); + + print( "ʼϳƷ..." ); + if( !ITEM_initItemIngCache() ) + goto CLOSEBIND; + print("\n" ); + + print( "ʼϳ趨..." ); + if( !ITEM_initRandTable() ) + goto CLOSEBIND; + print("\n" ); + + print( "ȡļ..." ); + if( !CHAR_initEffectSetting( getEffectfile() ) ) + goto CLOSEBIND; + print( "\n" ); + print( "ȡļ..." ); + if( !QUIZ_initQuiz( getQuizfile() ) ) + goto CLOSEBIND; + print( "\n" ); +#ifdef _GMRELOAD + print( "ȡGMļ..." ); + if ( !LoadGMSet( getGMSetfile() ) ) + goto CLOSEBIND; + print( "\n" ); +#endif +#ifdef _UNTEXT_TALK + print("ȡֹؼļ..."); + if(!LoadUnText()) + goto CLOSEBIND; + print( "\n" ); +#endif +#ifdef _USER_EXP_CF + print( "ȡļ..." ); + if ( !LoadEXP( getEXPfile() ) ) + goto CLOSEBIND; + print("ߵȼ: %d...",getMaxLevel()); + print("һȼ: %d...",getYBLevel()); + print( "\n" ); +#endif + +#ifdef _ANGEL_SUMMON + print("ȡٻбļ..."); + if( !LoadMissionList( ) ) + goto CLOSEBIND; + print("\n"); +#endif + +#ifdef _JOBDAILY + print("ȡ־ļ..."); + if(!LoadJobdailyfile()) + print("...ʧ\n"); + else + print("\n"); +#endif + +#ifdef _LOOP_ANNOUNCE + print("ȡѭļ..."); + if(!loadLoopAnnounce()) + print("...ʧ\n"); + else + print("\n"); +#endif +#ifdef _RIDE_CF + print( "ȡԶļ..." ); + if(!CHAR_Ride_CF_init()) + print("...ʧ\n"); + print("\n"); +#endif +#ifdef _FM_LEADER_RIDE + print( "ȡׯ԰峤רļ..." ); + if(!CHAR_FmLeaderRide_init()) + print("...ʧ\n"); + print("\n"); +#endif +#ifdef _RE_GM_COMMAND + print( "ԶGMļ..." ); + if(!re_gm_command()) + print("...ʧ\n"); + print("\n"); +#endif +#ifdef _NEED_ITEM_ENEMY + print( "ȡץҪƷļ..." ); + if(!need_item_eneny_init()) + print("...ʧ\n"); + print("\n"); +#endif + print( "ͼ..." ); + if( !MAP_initReadMap( getMaptilefile() , getMapdir() )) + goto CLOSEBIND; + print( "\n" ); + print( "ȡNPCļ..." ); + if( !NPC_readNPCSettingFiles( getNpcdir(), getNpctemplatenum(), + getNpccreatenum() ) ) + goto CLOSEBIND; + print( "\n" ); + print( "ʼ NPC ... " ); + if( lssproto_InitServer( lsrpcClientWriteFunc, LSGENWORKINGBUFFER ) < 0 ) + goto CLOSEBIND; + print( "\n" ); + print( "˺ŷ... " ); + acfd = connectHost( getAccountservername(), getAccountserverport()); + if(acfd == -1) + goto CLOSEBIND; + +/* + { + int errorcode; + int errorcodelen; + int qs; + + errorcodelen = sizeof(errorcode); + qs = getsockopt( acfd, SOL_SOCKET, SO_RCVBUF , &errorcode, &errorcodelen); + //andy_log + print("\n\n GETSOCKOPT SO_RCVBUF: [ %d, %d, %d] \n", qs, errorcode, errorcodelen); + } +*/ + + print( "\n" ); + initConnectOne( acfd, NULL , 0 ); + if( !CONNECT_acfdInitRB( acfd)) goto CLOSEAC; + if( !CONNECT_acfdInitWB( acfd)) goto CLOSEAC; + CONNECT_setCtype( acfd, AC ); + + print( "ʼ NPC ͻ ... " ); + /* rpc(client) */ + if( saacproto_InitClient( lsrpcClientWriteFunc,LSGENWORKINGBUFFER, acfd) < 0) + goto CLOSEAC; + print( "\n" ); + + print( "˺ŷ͵½... " ); + /* ̼ۢë */ + { + char buff[50]; +#ifdef _TEST_SERVER + sprintf(buff,"ziyunjack8-%s-%d",getAccountserverpasswd(),987); + saacproto_ACServerLogin_send(acfd, getGameservername(), buff); +#else + sprintf(buff,"ziyunjack8-%s-%d",getAccountserverpasswd(),789); + saacproto_ACServerLogin_send(acfd, getGameservername(), buff); +#endif + } + print( "\n" ); + // if (strcmp(getlocaltime(), TimeLimitLocal)>0)exit(0); + if( isExistFile( getLsgenlogfilename() ) ){ + lssproto_SetServerLogFiles( getLsgenlogfilename(), + getLsgenlogfilename() ); + saacproto_SetClientLogFiles( getLsgenlogfilename(), + getLsgenlogfilename() ); + } + + + print( "ʼ\n" ); + + print( "ʼʼ־\n" ); + { + char logconffile[512]; + snprintf( logconffile, sizeof( logconffile), "%s/%s" , + getLogdir(), getLogconffile() ); + if( !initLog( logconffile ) ) + goto CLOSEAC; + } +#ifdef _PET_ITEM + restoreObjects( getStoredir() ); +#endif +#ifdef _ITEM_QUITPARTY + print( "ȡɢƷʧļ..." ); + + //ȡ + f = fopen( getitemquitparty(), "r" ); + if( f != NULL ){ + while( fgets( line, sizeof( line ), f ) ){ + if( line[0] == '#' )continue; + if( line[0] == '\n' )continue; + chomp( line ); + itemquitparty_num++; + } + if( fseek( f, 0, SEEK_SET ) == -1 ){ + print( "Ʒ¼Ҵ\n" ); + fclose(f); + goto CLOSEAC; + } + // + Disappear_Item = allocateMemory( sizeof(struct tagDisappearItem) * itemquitparty_num ); + if( Disappear_Item == NULL ){ + print( "޷ڴ %d\n", sizeof(struct tagDisappearItem) * itemquitparty_num ); + fclose( f ); + goto CLOSEAC; + } + + i = 0; + //߱Ŵ Disappear_Item.string + while( fgets( line, sizeof( line ), f ) ){ + if( line[0] == '#' )continue; + if( line[0] == '\n' )continue; + chomp( line ); + sprintf( Disappear_Item[i].string,"%s",line ); + print("\n߱:%s", Disappear_Item[i].string ); + i++; + } + fclose(f); + } +#endif + + DEBUG_ADJUSTTIME = 0; + print( "\n" ); + return TRUE; + +CLOSEAC: + close( acfd ); +CLOSEBIND: + close( bindedfd ); + endConnect(); +MEMEND: + memEnd(); +RETURNFALSE: + return FALSE; +} + diff --git a/item/item.c b/item/item.c new file mode 100644 index 0000000..e3d4364 --- /dev/null +++ b/item/item.c @@ -0,0 +1,2402 @@ +#include "version.h" +#include +#include +#include +#include +#include +#include "common.h" +#include "char.h" +#include "char_data.h" +#include "battle.h" +#include "item.h" +#include "buf.h" +#include "function.h" +#include "magic_base.h" + +#ifdef _PROFESSION_SKILL // WON ADD ְҵ +#include "profession_skill.h" +#endif +#ifdef _ALLBLUES_LUA_1_2 +ITEM_LuaFunc ITEM_luaFunc; +#endif + +static int ITEM_tblen = 0; +static ITEM_exists* ITEM_item; +static int ITEM_itemnum; +static int ITEM_UseItemnum=0; +static char* ITEM_checkString( char* string ); +static int ITEM_getRandomValue( char* string,int* randomwidth, int num ); +static int ITEM_isstring1or0( char* string,int* randomwidth, int num ); + +#ifdef _SIMPLIFY_ITEMSTRING +typedef struct ITEM_tag_intDataSetting +{ + char* dumpchar; + int defaults; + int table; +}ITEM_intDataSetting; + +typedef struct ITEM_tag_charDataSetting +{ + char* dumpchar; + char* defaults; + int table; +}ITEM_charDataSetting; + +static ITEM_intDataSetting ITEM_setintdata[]={ + {"id", 0, ITEM_ID }, + {"bi", 0, ITEM_BASEIMAGENUMBER }, + {"cs", 0, ITEM_COST }, + {"ep", ITEM_OTHER, ITEM_TYPE }, + {"ft", 0, ITEM_ABLEUSEFIELD }, + {"tg", 0, ITEM_TARGET }, + {"lv", 0, ITEM_LEVEL }, +#ifdef _ITEM_MAXUSERNUM + {"dib", -1, ITEM_DAMAGEBREAK }, +#endif +#ifdef _ITEMSET4_TXT + {"upin", 1, ITEM_USEPILENUMS }, + {"canpile", 0, ITEM_CANBEPILE }, + {"nestr", 0, ITEM_NEEDSTR }, + {"nedex", 0, ITEM_NEEDDEX }, + {"netra", 0, ITEM_NEEDTRANS }, + {"neprof", 0, ITEM_NEEDPROFESSION }, +#endif +#ifdef _TAKE_ITEMDAMAGE + {"dmce", 0, ITEM_DAMAGECRUSHE }, + {"mdmce", 0, ITEM_MAXDAMAGECRUSHE }, +#endif +#ifdef _ADD_DEAMGEDEFC + {"otdmag", 0, ITEM_OTHERDAMAGE }, + {"otdefc", 0, ITEM_OTHERDEFC }, +#endif +#ifdef _SUIT_ITEM + {"nsuit", 0, ITEM_SUITCODE }, +#endif + {"ann", 0, ITEM_ATTACKNUM_MIN }, + {"anx", 0, ITEM_ATTACKNUM_MAX }, + {"ma", 0, ITEM_MODIFYATTACK }, + {"md", 0, ITEM_MODIFYDEFENCE }, + + {"mh", 0, ITEM_MODIFYQUICK}, //ITEM_MODIFYHP }, ITEM_MODIFYQUICK + {"mm", 0, ITEM_MODIFYHP}, //ITEM_MODIFYMP }, ITEM_MODIFYHP + {"mq", 0, ITEM_MODIFYMP}, //ITEM_MODIFYQUICK }, ITEM_MODIFYMP + {"ml", 0, ITEM_MODIFYLUCK }, + {"mc", 0, ITEM_MODIFYCHARM }, + {"mv", 0, ITEM_MODIFYAVOID }, + {"mat", 0, ITEM_MODIFYATTRIB }, + {"mav", 0, ITEM_MODIFYATTRIBVALUE }, + {"mid", -1, ITEM_MAGICID }, + {"mpr", 0, ITEM_MAGICPROB }, + {"mu", 0, ITEM_MAGICUSEMP }, +#ifdef _ITEMSET5_TXT + {"arr", 0, ITEM_MODIFYARRANGE }, + {"seqce", 0, ITEM_MODIFYSEQUENCE }, + {"iapi", 0, ITEM_ATTACHPILE }, + {"hirt", 0, ITEM_HITRIGHT }, +#endif + +#ifdef _ITEMSET6_TXT + {"neguard", 0, ITEM_NEGLECTGUARD}, +#endif + {"mrf", 0, ITEM_MERGEFLG}, + {"itime", 0, ITEM_TIME}, +#ifdef _ITEM_COLOER + {"coloer", 0, ITEM_COLOER }, /* ITEM_COLOER */ +#endif +}; + +static ITEM_charDataSetting ITEM_setchardata[]={ + {"na", "", ITEM_NAME }, /* ITEM_NAME */ + {"sn", "", ITEM_SECRETNAME }, /* ITEM_SCRETNAME */ + {"en", "", ITEM_EFFECTSTRING }, /* ITEM_EFFECTSTRING */ + {"ar", "", ITEM_ARGUMENT }, /* ITEM_ARGUMENT */ +#ifdef _ITEM_INSLAY + {"acode", "", ITEM_TYPECODE }, /*ITEM_TYPECODE,*/ + {"inlaycode", "", ITEM_INLAYCODE}, /*ITEM_INLAYCODE,*/ +#endif + {"cdk", "", ITEM_CDKEY }, /* ITEM_CDKEY */ +#ifdef _ITEM_FORUSERNAMES + {"forname", "", ITEM_FORUSERNAME }, //ITEM_FORUSERNAME, + {"forcdkey", "", ITEM_FORUSERCDKEY }, //ITEM_FORUSERCDKEY +#endif + +#ifdef _ANGEL_SUMMON + {"mindex", "", ITEM_ANGELMISSION}, + {"angel", "", ITEM_ANGELINFO}, + {"hero", "", ITEM_HEROINFO}, +#endif + +#ifdef _UNIQUE_P_I + {"ucode", "", ITEM_UNIQUECODE}, /* ITEM_UNIQUECODE */ +#endif +}; + +static ITEM_charDataSetting ITEM_setmemdata={ + "", "", -1 /* ITEM_MEMO */ +}; + + +#else +typedef struct ITEM_tag_intDataSetting +{ + char* dumpchar; + int defaults; +}ITEM_intDataSetting; + +typedef struct ITEM_tag_charDataSetting +{ + char* dumpchar; + char* defaults; +}ITEM_charDataSetting; + +static ITEM_intDataSetting ITEM_setintdata[ITEM_DATAINTNUM]={ + {"id", 0}, /* ITEM_ID */ + {"bi", 0}, /* ITEM_ITEMBASEIMAGENUMBER */ + {"cs", 0}, /* ITEM_COST */ + {"ep", ITEM_OTHER}, /* ITEM_TYPE */ + {"ft", 0}, /* ITEM_ABLEUSEFIELD */ + {"tg", 0}, /* ITEM_TARGET */ + {"lv", 0}, /* ITEM_LEVEL */ + +#ifdef _ITEM_MAXUSERNUM + {"dib", -1}, /*ITEM_DAMAGEBREAK*/ +#endif + +#ifdef _ITEMSET4_TXT + {"upin", 1}, //ITEM_USEPILENUMS, + {"canpile", 0}, //ITEM_CANBEPILE + {"nestr", 0}, //ITEM_NEEDSTR, + {"nedex", 0}, //ITEM_NEEDDEX, + {"netra", 0}, //ITEM_NEEDTRANS, + {"neprof", 0}, //ITEM_NEEDPROFESSION, +#endif + +#ifdef _TAKE_ITEMDAMAGE + {"dmce", 0}, /*ITEM_DAMAGECRUSHE*/ + {"mdmce",0}, //ITEM_MAXDAMAGECRUSHE +#endif + +#ifdef _ADD_DEAMGEDEFC + {"otdmag", 0}, //ITEM_OTHERDAMAGE, + {"otdefc", 0}, //ITEM_OTHERDEFC, +#endif + +#ifdef _SUIT_ITEM + {"nsuit", 0}, //ITEM_SUITCODE, +#endif + {"ann", 0}, /* ITEM_ATTACKNUM_MIN */ + {"anx", 0}, /* ITEM_ATTACKNUM_MAX */ + {"ma", 0}, /* ITEM_MODIFYATTACK */ + {"md", 0}, /* ITEM_MODIFYDEFENCE */ + {"mh", 0}, /* ITEM_MODIFYHP */ + {"mm", 0}, /* ITEM_MODIFYMP */ + + {"mq", 0}, /* ITEM_MODIFYQUICK */ + + {"ml", 0}, /* ITEM_MODIFYLUCK */ + {"mc", 0}, /* ITEM_MODIFYCHARM */ + {"mv", 0}, /* ITEM_MODIFYAVOID */ + {"mat", 0}, /* ITEM_MODIFYATTRIB */ + {"mav", 0}, /* ITEM_MODIFYATTRIBVALUE */ + + {"mid", -1}, /* ITEM_MAGICID */ + {"mpr", 0}, /* ITEM_MAGICPROB */ + {"mu", 0}, /* ITEM_MAGICUSEMP */ +#ifdef _ITEMSET5_TXT + {"arr", 0}, /*ITEM_MODIFYARRANGE*/ + {"seqce", 0}, //ITEM_MODIFYSEQUENCE, + {"iapi", 0}, //ITEM_ATTACHPILE + {"hirt", 0}, //ITEM_HITRIGHT // +#endif + +#ifdef _ITEMSET6_TXT + {"neguard", 0}, //ITEM_NEGLECTGUARD +// {"bemerge", 0}, //ITEM_BEMERGE +#endif + {"mpo", 0}, /* ITEM_POISON */ + {"mpa", 0}, /* ITEM_PARALYSIS */ + {"msl", 0}, /* ITEM_SLEEP */ + {"mst", 0}, /* ITEM_STONE */ + {"mdr", 0}, /* ITEM_DRUNK */ + {"mco", 0}, /* ITEM_CONFUSION */ + + {"mcr", 0}, /* ITEM_CRITICAL */ + + {"ua", -1}, /* ITEM_USEACTION */ + {"drlo",FALSE}, /* ITEM_DROPATLOGOUT */ + {"valo",FALSE}, /* ITEM_VANISHATLOGOUT */ + {"ioed",TRUE}, /* ITEM_ISOVERED */ + {"cpm", TRUE}, /* ITEM_CANPETMAIL */ + {"cmf", TRUE}, /* ITEM_CANMERGEFROM */ + {"cmt", TRUE}, /* ITEM_CANMERGETO */ + + {"ingv0",0}, /* ITEM_INGVALUE0 */ + {"ingv1",0}, + {"ingv2",0}, + {"ingv3",0}, + {"ingv4",0}, + + {"ipt", 0}, /* ITEM_PUTTIME */ + {"ll", 0}, /* ITEM_LEAKLEVEL */ + {"mrf", 0}, /* ITEM_MERGEFLG */ + {"clv", 0}, /* ITEM_CRUSHLEVEL */ + + {"v1", 0}, /* ITEM_VAR1 */ + {"v2", 0}, /* ITEM_VAR2 */ + {"v3", 0}, /* ITEM_VAR3 */ + {"v4", 0}, /* ITEM_VAR4 */ + {"itime", 0}, +}; + +static ITEM_charDataSetting ITEM_setchardata[ITEM_DATACHARNUM]={ + {"na", ""}, /* ITEM_NAME */ + {"sn", ""}, /* ITEM_SCRETNAME */ + {"en", ""}, /* ITEM_EFFECTSTRING */ + {"ar", ""}, /* ITEM_ARGUMENT */ +#ifdef _ITEM_INSLAY + {"acode", ""}, /*ITEM_TYPECODE,*/ + {"inlaycode", ""}, /*ITEM_INLAYCODE,*/ +#endif + {"cdk", ""}, /* ITEM_CDKEY */ +#ifdef _ITEM_FORUSERNAMES + {"forname", ""}, //ITEM_FORUSERNAME, + {"forcdkey", ""}, //ITEM_FORUSERCDKEY +#endif +// CoolFish: 2001/10/11 +#ifdef _UNIQUE_P_I + {"ucode", ""}, /* ITEM_UNIQUECODE */ +#endif + {"ingn0", ""}, /* ITEM_INGNAME0 */ + {"ingn1", ""}, + {"ingn2", ""}, + {"ingn3", ""}, + {"ingn4", ""}, + + {"inif", ""}, /* ITEM_PREOVERFUNC */ + {"preof", ""}, /* ITEM_PREOVERFUNC */ + {"posof", ""}, /* ITEM_POSTOVERFUNC */ + {"wf", "ITEM_DeleteTimeWatched"}, /* ITEM_WATCHFUNC */ + {"usef", ""}, /* ITEM_USEFUNC */ + {"atchf", ""}, /* ITEM_ATTACH */ + {"dtchf", ""}, /* ITEM_DETACH */ + {"attaf", ""}, /* ITEM_ATTACKFUNC */ + {"pickupf", ""}, /* ITEM_PICKUPFUNC */ +#ifdef _Item_ReLifeAct + {"relifes", ""}, /*ITEM_DIERELIFEFUNC*/ +#endif +#ifdef _PICKUP_ITEM_OTHER + {"fromcd", ""}, +#endif + +}; + +static ITEM_charDataSetting ITEM_setmemdata={ + "", "" /* ITEM_MEMO */ +}; +#endif + +typedef enum +{ + ITEM_INTENTRY=0, + ITEM_CHARENTRY=1, + ITEM_INTFUNC=2, + ITEM_CHARFUNC=3, +}ITEM_DATATYPECATEGORY; + +static struct ITEM_itemconfentry +{ + char* entryname; + ITEM_DATATYPECATEGORY type; + int index; + void* func; +}ITEM_itemconfentries[]={ + {"name", ITEM_CHARFUNC, ITEM_NAME, ITEM_checkString}, + {"secretname", ITEM_CHARFUNC, ITEM_SECRETNAME, ITEM_checkString}, + {"effectstring",ITEM_CHARFUNC, ITEM_EFFECTSTRING, ITEM_checkString}, + {"argument", ITEM_CHARENTRY, ITEM_ARGUMENT, NULL}, +#ifdef _ITEM_INSLAY + {"acode", ITEM_CHARENTRY, ITEM_TYPECODE, NULL}, + {"inlaycode", ITEM_CHARENTRY, ITEM_INLAYCODE, NULL}, +#endif + {"initfunc", ITEM_CHARENTRY, ITEM_INITFUNC, NULL}, + {"preoverfunc", ITEM_CHARENTRY, ITEM_PREOVERFUNC, NULL}, + {"postoverfunc",ITEM_CHARENTRY, ITEM_POSTOVERFUNC, NULL}, + {"watchfunc", ITEM_CHARENTRY, ITEM_WATCHFUNC, NULL}, + {"usefunc", ITEM_CHARENTRY, ITEM_USEFUNC, NULL}, + {"attachfunc", ITEM_CHARENTRY, ITEM_ATTACHFUNC, NULL}, + {"detachfunc", ITEM_CHARENTRY, ITEM_DETACHFUNC, NULL}, + {"dropfunc", ITEM_CHARENTRY, ITEM_DROPFUNC, NULL}, + {"pickupfunc", ITEM_CHARENTRY, ITEM_PICKUPFUNC, NULL}, +#ifdef _Item_ReLifeAct + {"relifefunc", ITEM_CHARENTRY, ITEM_DIERELIFEFUNC, NULL}, +#endif + {"id", ITEM_INTENTRY, ITEM_ID, NULL}, + {"imagenumber", ITEM_INTENTRY, ITEM_BASEIMAGENUMBER, NULL}, + {"cost", ITEM_INTENTRY, ITEM_COST, NULL}, + {"type", ITEM_INTENTRY, ITEM_TYPE, NULL}, + {"fieldtype", ITEM_INTENTRY, ITEM_ABLEUSEFIELD, NULL}, + {"target", ITEM_INTENTRY, ITEM_TARGET, NULL}, + + {"level", ITEM_INTENTRY, ITEM_LEVEL, NULL}, +#ifdef _ITEM_MAXUSERNUM + {"dambreak", ITEM_INTENTRY, ITEM_DAMAGEBREAK, NULL}, +#endif + +#ifdef _ITEMSET4_TXT + {"upinums", ITEM_INTENTRY, ITEM_USEPILENUMS, NULL}, + {"campile", ITEM_INTENTRY, ITEM_CANBEPILE, NULL}, + {"nestr", ITEM_INTENTRY, ITEM_NEEDSTR, NULL}, + {"nedex", ITEM_INTENTRY, ITEM_NEEDDEX, NULL}, + {"netra", ITEM_INTENTRY, ITEM_NEEDTRANS, NULL}, + {"neprof", ITEM_INTENTRY, ITEM_NEEDPROFESSION, NULL}, +#endif + +#ifdef _TAKE_ITEMDAMAGE + {"damcrushe", ITEM_INTENTRY, ITEM_DAMAGECRUSHE, NULL}, + {"maxdmce", ITEM_INTENTRY, ITEM_MAXDAMAGECRUSHE, NULL}, +#endif + +#ifdef _ADD_DEAMGEDEFC + {"otdmags", ITEM_INTENTRY, ITEM_OTHERDAMAGE, NULL}, + {"otdefcs", ITEM_INTENTRY, ITEM_OTHERDEFC, NULL}, +#endif +#ifdef _SUIT_ITEM + {"nsuit", ITEM_INTENTRY, ITEM_SUITCODE, NULL}, //ITEM_SUITCODE, +#endif + {"attacknum_min",ITEM_INTENTRY, ITEM_ATTACKNUM_MIN, NULL}, + {"attacknum_max",ITEM_INTENTRY, ITEM_ATTACKNUM_MAX, NULL}, + {"attack", ITEM_INTFUNC, ITEM_MODIFYATTACK, ITEM_getRandomValue}, + {"defence", ITEM_INTFUNC, ITEM_MODIFYDEFENCE, ITEM_getRandomValue}, + {"quick", ITEM_INTFUNC, ITEM_MODIFYQUICK, ITEM_getRandomValue}, + + {"hp", ITEM_INTFUNC, ITEM_MODIFYHP, ITEM_getRandomValue}, + {"mp", ITEM_INTFUNC, ITEM_MODIFYMP, ITEM_getRandomValue}, + {"luck", ITEM_INTFUNC, ITEM_MODIFYLUCK, ITEM_getRandomValue}, + {"charm", ITEM_INTFUNC, ITEM_MODIFYCHARM, ITEM_getRandomValue}, + {"avoid", ITEM_INTFUNC, ITEM_MODIFYAVOID, ITEM_getRandomValue}, + {"attrib", ITEM_INTENTRY, ITEM_MODIFYATTRIB, NULL}, + {"attribvalue", ITEM_INTENTRY, ITEM_MODIFYATTRIBVALUE,NULL}, + + {"magicid", ITEM_INTENTRY, ITEM_MAGICID, NULL}, + {"magicprob", ITEM_INTENTRY, ITEM_MAGICPROB, NULL}, + {"magicusemp", ITEM_INTENTRY, ITEM_MAGICUSEMP, NULL}, +#ifdef _ITEMSET5_TXT + {"arr", ITEM_INTENTRY, ITEM_MODIFYARRANGE, NULL}, + {"seqce", ITEM_INTENTRY, ITEM_MODIFYSEQUENCE, NULL}, + {"iapi", ITEM_INTENTRY, ITEM_ATTACHPILE, NULL}, + {"hirt", ITEM_INTENTRY, ITEM_HITRIGHT, NULL}, +#endif +#ifdef _ITEMSET6_TXT + {"neguard", ITEM_INTENTRY, ITEM_NEGLECTGUARD, NULL}, +// {"bemerge", ITEM_INTENTRY, ITEM_BEMERGE, NULL}, +#endif +#ifdef _PETITEM__AMOI_E + {"petfix0", ITEM_INTENTRY, ITEM_PETFIX0, NULL}, + {"petfix1", ITEM_INTENTRY, ITEM_PETFIX1, NULL}, + {"petfix2", ITEM_INTENTRY, ITEM_PETFIX2, NULL}, + {"petfix3", ITEM_INTENTRY, ITEM_PETFIX3, NULL}, + {"petfix4", ITEM_INTENTRY, ITEM_PETFIX4, NULL}, + {"petfix5", ITEM_INTENTRY, ITEM_PETFIX5, NULL}, + {"petfix6", ITEM_INTENTRY, ITEM_PETFIX6, NULL}, + {"petfix7", ITEM_INTENTRY, ITEM_PETFIX7, NULL}, + {"petequitallow", ITEM_CHARENTRY, ITEM_PETEQUITALLOW, NULL}, + {"petequitforbit", ITEM_CHARENTRY, ITEM_PETEQUITFORBIT, NULL}, +#endif + {"poison", ITEM_INTFUNC, ITEM_POISON, ITEM_getRandomValue}, + {"paralysis", ITEM_INTFUNC, ITEM_PARALYSIS, ITEM_getRandomValue}, + {"sleep", ITEM_INTFUNC, ITEM_SLEEP, ITEM_getRandomValue}, + {"stone", ITEM_INTFUNC, ITEM_STONE, ITEM_getRandomValue}, + {"drunk", ITEM_INTFUNC, ITEM_DRUNK, ITEM_getRandomValue}, + {"confusion", ITEM_INTFUNC, ITEM_CONFUSION, ITEM_getRandomValue}, + + {"critical", ITEM_INTFUNC, ITEM_CRITICAL, ITEM_getRandomValue}, + + {"useaction", ITEM_INTENTRY, ITEM_USEACTION, NULL}, + + {"dropatlogout",ITEM_INTFUNC, ITEM_DROPATLOGOUT, ITEM_isstring1or0}, + {"vanishatdrop",ITEM_INTFUNC, ITEM_VANISHATDROP, ITEM_isstring1or0}, + {"isovered", ITEM_INTFUNC, ITEM_ISOVERED, ITEM_isstring1or0}, + {"canpetmail", ITEM_INTFUNC, ITEM_CANPETMAIL, ITEM_isstring1or0}, + {"canmergefrom",ITEM_INTFUNC, ITEM_CANMERGEFROM, ITEM_isstring1or0}, + {"canmergeto", ITEM_INTFUNC, ITEM_CANMERGETO, ITEM_isstring1or0}, + + {"ingname0", ITEM_CHARENTRY, ITEM_INGNAME0, NULL}, + {"ingvalue0", ITEM_INTENTRY, ITEM_INGVALUE0, NULL}, + {"ingname1", ITEM_CHARENTRY, ITEM_INGNAME1, NULL}, + {"ingvalue1", ITEM_INTENTRY, ITEM_INGVALUE1, NULL}, + {"ingname2", ITEM_CHARENTRY, ITEM_INGNAME2, NULL}, + {"ingvalue2", ITEM_INTENTRY, ITEM_INGVALUE2, NULL}, + {"ingname3", ITEM_CHARENTRY, ITEM_INGNAME3, NULL}, + {"ingvalue3", ITEM_INTENTRY, ITEM_INGVALUE3, NULL}, + {"ingname4", ITEM_CHARENTRY, ITEM_INGNAME4, NULL}, + {"ingvalue4", ITEM_INTENTRY, ITEM_INGVALUE4, NULL}, +#ifdef _PETITEM__AMOI_E + {"shopitem", ITEM_INTENTRY, ITEM_TYPEOFITEM, NULL}, +#endif +}; + + +#ifdef _ITEMTBL_STAIC +ITEM_table ITEM_tbl[24000]; +#else +ITEM_table* ITEM_tbl=NULL; +#endif + +static INLINE BOOL ITEM_CHECKARRAYINDEX(int index) +{ + if( ITEM_itemnum<=(index) || (index)<0 )return FALSE; + return TRUE; +} + +INLINE BOOL _ITEM_CHECKINDEX( char *file, int line, int index) +{ + if( !ITEM_CHECKARRAYINDEX(index) ) { + if( index != -1 ) { + print( "err %s:%d \n", file, line); + } + return FALSE; + } + if( ITEM_item[index].use == FALSE ) { + return FALSE; + } + return TRUE; +} + +static INLINE int ITEM_CHECKINTDATAINDEX(int index) +{ + if( ITEM_DATAINTNUM <= index || index < 0 )return FALSE; + return TRUE; +} + +static INLINE int ITEM_CHECKCHARDATAINDEX(int index) +{ + if( ITEM_DATACHARNUM<=index || index<0 )return FALSE; + return TRUE; +} + +BOOL ITEM_initExistItemsArray( int num ) +{ + int i; + + BOOL ITEM_checksetdata( void ); + if( ITEM_checksetdata() == FALSE )return FALSE; + + ITEM_itemnum = num; + + ITEM_item = allocateMemory( sizeof( ITEM_exists ) * num ); + if( ITEM_item == NULL ) return FALSE; + +#ifdef _ALLBLUES_LUA_1_2 + memset( &ITEM_luaFunc, 0 , sizeof( ITEM_LuaFunc )); +#endif + + for( i = 0 ; i < num ; i ++ ){ + memset( &ITEM_item[i], 0 , sizeof( ITEM_exists )); + ITEM_item[i].use = FALSE; + } + print("ڶη %4.2f MB ռ...", sizeof( ITEM_exists ) * num /1024.0/1024.0); + return TRUE; +} + +BOOL ITEM_endExistItemsArray( void ) +{ + freeMemory( ITEM_item ); + return TRUE; +} + +int _ITEM_initExistItemsOne( char *file, int line, ITEM_Item* itm ) +{ + int i; + int itemID=-1; + static int Sindex=1; + itemID = itm->data[ITEM_ID]; + if( ITEM_CHECKITEMTABLE(itm->data[ITEM_ID] ) == FALSE){ + print("CHAR itemData err Item_id:%d=%s%d!!\n", itm->data[ITEM_ID], file, line); + return -1; + } + for( i = 0 ; i < ITEM_itemnum ; i ++ ) { + Sindex++; + if( Sindex >= ITEM_itemnum ) Sindex = 1; + if( Sindex < 1 ) Sindex = 1; + if( !ITEM_item[Sindex].use){ + int charaindex; + charaindex = ITEM_item[Sindex].itm.workint[ITEM_WORKCHARAINDEX]; + if( CHAR_CHECKINDEX( charaindex) && + CHAR_getInt( charaindex, CHAR_WHICHTYPE) == CHAR_TYPEPLAYER ) { + int j; + for( j = 0; j < CHAR_MAXITEMHAVE; j ++ ) { + if( CHAR_getItemIndex( charaindex, j) == Sindex) { + print( "item.c: error! chara have this item charaindex[%d] " + "itemindex[%d] Name(%s)POS(%d)NAME(%s)\n", + charaindex, Sindex, + CHAR_getUseName( charaindex ), j, + ITEM_item[Sindex].itm.string[ITEM_NAME].string ); + print( "from %s:%d\n", file, line); + ITEM_item[Sindex].use = TRUE; + break; + } + } + if( j != CHAR_MAXITEMHAVE ) continue; + } + memcpy( &ITEM_item[Sindex].itm , itm , sizeof( ITEM_Item ) ); + ITEM_item[Sindex].use = TRUE; + { + BOOL (*initfunc)(ITEM_Item*)=NULL; + initfunc = (BOOL(*)(ITEM_Item*)) getFunctionPointerFromName( itm->string[ITEM_INITFUNC].string ); + if( initfunc ){ + if( initfunc( &ITEM_item[Sindex].itm ) == FALSE ){ + ITEM_item[Sindex].use = FALSE; + fprint( "Error:Can't init item\n" ); + return -1; + } + } + } + ITEM_UseItemnum++; + ITEM_constructFunctable( Sindex); + return Sindex; + } + } + fprint( "Ʒ\n" ); + return -1; +} + +void _ITEM_endExistItemsOne( int index , char *file, int line) +{ + int i,j; + int hitcnt = 0; + int playernum = CHAR_getPlayerMaxNum(); + + if( !ITEM_CHECKINDEX(index)) return; + + for( i = 0; i < playernum; i ++ ) { + if( CHAR_CHECKINDEX( i)) { + for( j = 0; j < CHAR_MAXITEMHAVE; j ++ ) { + if( CHAR_getItemIndex( i, j) == index) { + print( "warning !! player have this item:%d call from [%s:%d](%s)(%s)\n", + index, file,line, CHAR_getUseName(i),ITEM_item[index].itm.string[ITEM_NAME].string ); + hitcnt ++; + if( hitcnt > 1 ) { + print( "ITEM_INDEX(%d) duplicate!!\n", index); + } + } + } + } + } + + if( hitcnt < 1 ){ + ITEM_item[index].use = FALSE; + ITEM_item[index].itm.workint[ITEM_WORKCHARAINDEX] = -1; + ITEM_UseItemnum--; + } +} + +INLINE int ITEM_getIntStrict( int index ,ITEM_DATAINT element,int* error) +{ + if(!ITEM_CHECKINDEX(index))return *error=FALSE; + if(!ITEM_CHECKINTDATAINDEX(element))return *error=FALSE; + return ITEM_item[index].itm.data[element]; +} + +INLINE int _ITEM_getInt( char *file, int line, int index ,ITEM_DATAINT element) +{ + if(!ITEM_CHECKINDEX(index)){ + return -1; + } + if(!ITEM_CHECKINTDATAINDEX(element)) { + return -1; + } + return ITEM_item[index].itm.data[element]; +} + +INLINE int ITEM_setIntStrict( int index ,ITEM_DATAINT element,int data, + int* error) +{ + int buf; + if(!ITEM_CHECKINDEX(index)) + return *error=FALSE; + if(!ITEM_CHECKINTDATAINDEX(element)) + return *error=FALSE; + buf = ITEM_item[index].itm.data[element]; + ITEM_item[index].itm.data[element] = data; + return buf; +} + +INLINE int _ITEM_setInt( char *file, int line, int index ,ITEM_DATAINT element, int data) +{ + int buf; + if( !ITEM_CHECKINDEX( index) ){ + return -1; + } + + if( !ITEM_CHECKINTDATAINDEX( element) ){ + return -1; + } + + buf = ITEM_item[ index].itm.data[ element]; + ITEM_item[ index].itm.data[ element] = data; + return buf; +} + +INLINE char* ITEM_getChar( int index ,ITEM_DATACHAR element ) +{ + if(!ITEM_CHECKINDEX(index))return "\0"; + if(!ITEM_CHECKCHARDATAINDEX(element))return "\0"; + return ITEM_item[index].itm.string[element].string; +} + +INLINE BOOL ITEM_setChar( int index ,ITEM_DATACHAR element , char* new) +{ + if(!ITEM_CHECKINDEX(index))return FALSE; + if(!ITEM_CHECKCHARDATAINDEX(element))return FALSE; + strcpysafe( ITEM_item[index].itm.string[element].string, + sizeof( ITEM_item[index].itm.string[element].string ), + new ); + return TRUE; +} + +INLINE int ITEM_getWorkInt( int index ,ITEM_WORKDATAINT element) +{ + if( !ITEM_CHECKINDEX(index) ) return -1; + if( element >= ITEM_WORKDATAINTNUM || element < 0 ) return -1; + return ITEM_item[index].itm.workint[element]; +} + +INLINE int ITEM_setWorkInt( int index ,ITEM_WORKDATAINT element, int data) +{ + int buf; + if( !ITEM_CHECKINDEX( index) ) return -1; + if( element >= ITEM_WORKDATAINTNUM || element < 0 ) return -1; + + buf = ITEM_item[index].itm.workint[element]; + ITEM_item[index].itm.workint[element] = data; + return buf; +} + +INLINE int ITEM_getITEM_itemnum( void ) +{ + return ITEM_itemnum; +} + +INLINE int ITEM_getITEM_UseItemnum( void ) +{ + return ITEM_UseItemnum; +} + + +INLINE BOOL ITEM_getITEM_use( int index ) +{ + if( !ITEM_CHECKINDEX(index))return FALSE; + return ITEM_item[index].use; +} + +void ITEM_constructFunctable( int itemindex ) +{ + int i; + if( !ITEM_CHECKINDEX(itemindex))return; + + for( i=ITEM_FIRSTFUNCTION; i < ITEM_LASTFUNCTION ; i++ ) { + ITEM_item[itemindex].itm.functable[i-ITEM_FIRSTFUNCTION] + = getFunctionPointerFromName( ITEM_getChar( itemindex,i ) ); +#ifdef _ALLBLUES_LUA_1_2 + if(ITEM_item[itemindex].itm.functable[i-ITEM_FIRSTFUNCTION] == NULL){ + ITEM_setLUAFunction(itemindex, i, ITEM_getChar( itemindex,i )); + } +#endif + } +} + +void* ITEM_getFunctionPointer( int itemindex, int functype ) +{ + if( !ITEM_CHECKINDEX(itemindex) )return NULL; + if( functype < ITEM_FIRSTFUNCTION || functype >= ITEM_LASTFUNCTION ){ + print( "ʹ:%d\n", functype); + return NULL; + } + return ITEM_item[itemindex].itm. + functable[functype-ITEM_FIRSTFUNCTION]; +} + +#ifdef _ALLBLUES_LUA_1_2 +INLINE BOOL ITEM_setLUAFunction( int itemindex, int functype, const char *luafuncname) +{ + if( !ITEM_CHECKINDEX(itemindex) )return FALSE; + if( functype < ITEM_FIRSTFUNCTION || functype >= ITEM_LASTFUNCTION ){ + print( "ʹ1:%d\n", functype); + return FALSE; + } + ITEM_LuaFunc *luaFunc = &ITEM_luaFunc; + + while(luaFunc->next != NULL){ + if(strcmp(luaFunc->luafuncname, luafuncname) == 0){ + ITEM_item[itemindex].itm.lua[functype-ITEM_FIRSTFUNCTION] = luaFunc->lua; + ITEM_item[itemindex].itm.luafunctable[functype-ITEM_FIRSTFUNCTION] = allocateMemory( strlen(luaFunc->luafunctable) ); + memset(ITEM_item[itemindex].itm.luafunctable[functype-ITEM_FIRSTFUNCTION], 0, strlen(luaFunc->luafunctable)); + strcpy(ITEM_item[itemindex].itm.luafunctable[functype-ITEM_FIRSTFUNCTION], luaFunc->luafunctable); + return TRUE; + } + luaFunc = luaFunc->next; + } + + ITEM_item[itemindex].itm.lua[functype-ITEM_FIRSTFUNCTION] = NULL; + ITEM_item[itemindex].itm.luafunctable[functype-ITEM_FIRSTFUNCTION] = NULL; + + return FALSE; +} + +BOOL ITEM_addLUAListFunction( lua_State *L, const char *luafuncname, const char *luafunctable ) +{ + ITEM_LuaFunc *luaFunc = &ITEM_luaFunc; + + while(luaFunc->next != NULL){ + luaFunc = luaFunc->next; + } + + luaFunc->next = allocateMemory( sizeof(ITEM_LuaFunc) ); + memset( luaFunc->next, 0 , sizeof(ITEM_luaFunc) ); + if(luaFunc->next == NULL)return FALSE; + + luaFunc->lua = L; + strcpysafe( luaFunc->luafuncname, 128, luafuncname ); + strcpysafe( luaFunc->luafunctable, 128, luafunctable ); + + return TRUE; +} + + +INLINE lua_State *ITEM_getLUAFunction( int itemindex, int functype) +{ + if( !ITEM_CHECKINDEX(itemindex) )return NULL; + if( functype < ITEM_FIRSTFUNCTION || functype >= ITEM_LASTFUNCTION ){ + print( "ʹ2:%d\n", functype); + return NULL; + } + + if(ITEM_item[itemindex].itm.lua[functype-ITEM_FIRSTFUNCTION] == NULL){ + return NULL; + } + + lua_getglobal( ITEM_item[itemindex].itm.lua[functype-ITEM_FIRSTFUNCTION], ITEM_item[itemindex].itm.luafunctable[functype-ITEM_FIRSTFUNCTION]); + + return ITEM_item[itemindex].itm.lua[functype-ITEM_FIRSTFUNCTION]; +} + +#endif + +int ITEM_getItemMaxIdNum( void) +{ + return ITEM_tblen; +} + +BOOL ITEM_checksetdata( void ) +{ + int i; + char* strings[ITEM_DATAINTNUM + ITEM_DATACHARNUM + 1]; +#ifdef _SIMPLIFY_ITEMSTRING + int num=0; + for(i = 0; i < arraysizeof( ITEM_setintdata) ; i ++ ) + strings[ num++ ] = ITEM_setintdata[i].dumpchar; + for( i = 0 ; i < arraysizeof( ITEM_setchardata) ; i ++ ) + strings[ num++ ] = ITEM_setchardata[i].dumpchar; + strings[ITEM_DATAINTNUM+ITEM_DATACHARNUM] = ITEM_setmemdata.dumpchar; + + if( ! checkStringsUnique( strings, num,1 ) ){ + fprint( "ITEM_set????data is overlapped.\nIt is not allowed\n"); + return FALSE; + } +#else + for(i = 0; i < ITEM_DATAINTNUM ; i ++ ) + strings[i] = ITEM_setintdata[i].dumpchar; + for( i = 0 ; i < ITEM_DATACHARNUM ; i ++ ) + strings[ITEM_DATAINTNUM+i] = ITEM_setchardata[i].dumpchar; + + + strings[ITEM_DATAINTNUM+ITEM_DATACHARNUM] = ITEM_setmemdata.dumpchar; + + if( ! checkStringsUnique( strings, arraysizeof( strings ),1 ) ){ + fprint( "ITEM_set????data is overlapped.\nIt is not allowed\n"); + return FALSE; + } +#endif + return TRUE; +} + +static char ITEM_dataString[STRINGBUFSIZ]; +char* ITEM_makeStringFromItemIndex( int index, int mode ) +{ + if( 0 <= index && index < ITEM_itemnum && ITEM_item[index].use == TRUE) + ; + else + return "\0"; + return ITEM_makeStringFromItemData( &ITEM_item[index].itm, mode ); +} + +#ifdef _SIMPLIFY_ITEMSTRING2 +BOOL CHECK_HaveBeSave( int itemID, int oneNum, int type ) +{ + if( ITEM_ID == type ) return TRUE; + if( ITEMTBL_getInt( itemID, type) == oneNum ) return FALSE; + return TRUE; +} +#endif + +char* ITEM_makeStringFromItemData( ITEM_Item* one, int mode ) +{ + int i; + char delim1 = '\0'; + char delim2 = '\0'; + int strlength=0; + +#ifdef _SIMPLIFY_ITEMSTRING2 + int itemID = one->data[ ITEM_ID]; + if( !ITEM_CHECKITEMTABLE( itemID) ) return "\0"; +#endif + if( mode == 0 ) { + delim1 = '='; delim2 = '|'; + }else { + delim1 = ':'; delim2 = ','; + } + +#ifdef _SIMPLIFY_ITEMSTRING + for(i = 0; i < arraysizeof( ITEM_setintdata) ; i ++ ){ + char linedata[128]; +#ifdef _SIMPLIFY_ITEMSTRING2 + if( !CHECK_HaveBeSave( itemID, one->data[ ITEM_setintdata[i].table], ITEM_setintdata[i].table) ) continue; +#endif + snprintf( linedata , sizeof(linedata), + "%s%c%d%c", ITEM_setintdata[i].dumpchar, delim1, + one->data[ ITEM_setintdata[i].table], delim2 ); + strcpysafe( &ITEM_dataString[strlength], sizeof( ITEM_dataString ) - strlength, linedata ); + strlength += strlen( linedata ); + } + + for( i = 0 ; i < arraysizeof( ITEM_setchardata) ; i ++ ){ + char linedata[128]; + char escapebuffer[128]; + if( strlen( one->string[ ITEM_setchardata[i].table].string) == 0 ) continue; + + snprintf( linedata , sizeof(linedata), + "%s%c%s%c", ITEM_setchardata[i].dumpchar,delim1, + makeEscapeString( one->string[ITEM_setchardata[i].table].string, escapebuffer, + sizeof(escapebuffer)), delim2); + strcpysafe( &ITEM_dataString[strlength], sizeof( ITEM_dataString ) - strlength, linedata ); + strlength += strlen( linedata ); + } +#else + for( i = 0 ; i < ITEM_DATAINTNUM ; i ++ ) { + char linedata[128]; + snprintf( linedata , sizeof(linedata), + "%s%c%d%c", ITEM_setintdata[i].dumpchar, delim1, one->data[i], delim2 ); + strcpysafe( &ITEM_dataString[strlength], sizeof( ITEM_dataString ) - strlength, linedata ); + strlength += strlen( linedata ); + } + + for( i = 0 ; i < ITEM_DATACHARNUM ; i ++ ){ + char linedata[128]; + char escapebuffer[128]; + if( strlen( one->string[i].string) != 0 ) { + snprintf( linedata , sizeof(linedata), + "%s%c%s%c", ITEM_setchardata[i].dumpchar,delim1, + makeEscapeString(one->string[i].string,escapebuffer, + sizeof(escapebuffer)), delim2); + strcpysafe( &ITEM_dataString[strlength], sizeof( ITEM_dataString ) - strlength, linedata ); + strlength += strlen( linedata ); + } + } +#endif + dchop( ITEM_dataString, (mode == 0 ) ? "|" : ","); + return ITEM_dataString; +} + +BOOL ITEM_makeExistItemsFromStringToArg( char* src , ITEM_Item* item, int mode ) +{ + int readindex=1; + char delim1[2]; + char delim2[2]; + + if( mode == 0 ) { + strcpy( delim1, "="); + strcpy( delim2, "|"); + } + else { + strcpy( delim1, ":"); + strcpy( delim2, ","); + } +#ifdef _SIMPLIFY_ITEMSTRING + { + + int itemID=-1; + while( 1 ){ + char linebuf[512]; + char firstToken[256]; + char secondToken[256]; + if( getStringFromIndexWithDelim( src ,delim2 , readindex, linebuf, sizeof( linebuf)) == FALSE ) break; + + readindex++; + if( getStringFromIndexWithDelim( linebuf, delim1, 1, firstToken, sizeof( firstToken )) == FALSE )return FALSE; + if( strcmp( firstToken, "id" ) ) continue; + strcpysafe( secondToken , sizeof( secondToken ), linebuf + strlen( firstToken) + strlen( delim1) ); + itemID = atoi( secondToken); + if( !ITEM_CHECKITEMTABLE( itemID) ) return FALSE; + ITEM_getDefaultItemData( itemID, item); + break; + } + readindex =1; + } +#else + ITEM_getDefaultItemSetting(item); +#endif + + while( 1 ){ + BOOL ret; + char linebuf[512]; + + char firstToken[256]; + char secondToken[256]; + int i; + + ret = getStringFromIndexWithDelim( src ,delim2 , readindex,linebuf, sizeof(linebuf) ); + if( ret == FALSE ) + break; + ret = getStringFromIndexWithDelim( linebuf, delim1, 1, firstToken, sizeof( firstToken ) ); + if( ret == FALSE ) return FALSE; + strcpysafe( secondToken , sizeof( secondToken ), + linebuf + strlen(firstToken) + strlen(delim1) ); +#ifdef _SIMPLIFY_ITEMSTRING + for(i = 0; i < arraysizeof( ITEM_setintdata) ; i ++ ){ + if( strcmp( firstToken , ITEM_setintdata[i].dumpchar) ) continue; + item->data[ITEM_setintdata[i].table] = atoi( secondToken ); + goto NEXT; + } + + for(i = 0; i < arraysizeof( ITEM_setchardata) ; i ++ ){ + if( strcmp(firstToken ,ITEM_setchardata[i].dumpchar ) ) continue; + strcpysafe( item->string[ ITEM_setchardata[i].table].string, + sizeof(item->string[ITEM_setchardata[i].table].string), + makeStringFromEscaped(secondToken)); + goto NEXT; + } +#else + for( i = 0 ; i < ITEM_DATAINTNUM ; i ++ ){ + if( strcmp(firstToken ,ITEM_setintdata[i].dumpchar) == 0 ){ + item->data[i] = atoi( secondToken ); + goto NEXT; + } + } + + for( i = 0 ; i < ITEM_DATACHARNUM ; i ++ ){ + if( strcmp(firstToken ,ITEM_setchardata[i].dumpchar ) == 0 ){ + strcpysafe( item->string[i].string, + sizeof(item->string[i].string), + makeStringFromEscaped(secondToken)); + goto NEXT; + } + } +#endif + fprint( "??? : %s[%s]\n" , src , firstToken ); + + NEXT: + readindex++; + } + + return TRUE; +} + +void ITEM_getDefaultItemSetting(ITEM_Item* itm) +{ + int i; + memset( itm, 0 , sizeof( ITEM_Item )); +#ifdef _SIMPLIFY_ITEMSTRING + for(i = 0; i < arraysizeof( ITEM_setintdata) ; i ++ ){ + itm->data[ITEM_setintdata[i].table] = ITEM_setintdata[i].defaults; + } + for(i = 0; i < arraysizeof( ITEM_setchardata) ; i ++ ){ + strcpysafe( itm->string[ITEM_setchardata[i].table].string, + sizeof( itm->string[ITEM_setchardata[i].table].string), + ITEM_setchardata[i].defaults); + } +#else + for(i=0;idata[i] = ITEM_setintdata[i].defaults; + for(i=0;istring[i].string, + sizeof(itm->string[i].string), + ITEM_setchardata[i].defaults); +#endif + + strcpysafe( itm->string[ITEM_WATCHFUNC].string, + sizeof(itm->string[ITEM_WATCHFUNC].string), "ITEM_DeleteTimeWatched" ); + + + for(i=0;iworkint[i] = -1; + } + +} + +#ifdef _SIMPLIFY_ITEMSTRING +void ITEM_getDefaultItemData( int itemID, ITEM_Item* itm) +{ + int i; +// memset( itm, 0 , sizeof( ITEM_Item )); + + for(i=0;idata[i] = ITEMTBL_getInt( itemID, i); + } + for(i=0;istring[i].string, sizeof( itm->string[i].string), + ITEMTBL_getChar( itemID, i) ); + } + for(i=0;iworkint[i] = -1; + } + + strcpysafe( itm->string[ITEM_WATCHFUNC].string, sizeof( itm->string[ITEM_WATCHFUNC].string), + "ITEM_DeleteTimeWatched" ); + +} +#endif + +static int ITEM_getRandomValue( char* string,int* randomwidth, int num ) +{ + int minvalue; + int maxvalue; + char token[64]; + int ret; +#if 1 + *randomwidth = 0; + + ret = getStringFromIndexWithDelim( string,",",num -1,token, sizeof( token)); + if( ret == FALSE ) { + return 0; + } + minvalue = atoi( token); + ret = getStringFromIndexWithDelim( string,",",num ,token, sizeof( token)); + if( ret == FALSE ) { + return minvalue; + } + maxvalue = atoi( token); + *randomwidth = ABS( maxvalue - minvalue); + return min( minvalue, maxvalue); + +#else + minvalue = atoi( string ); + startmax = index( string,',' ); + if( startmax != NULL ){ + maxvalue = atoi(startmax+1); + *randomwidth = ABS(maxvalue - minvalue); + return min(minvalue,maxvalue); + } + *randomwidth = 0; + return minvalue; +#endif +} +static int ITEM_isstring1or0( char* string,int* randomwidth, int num ) +{ + char token[64]; + int ret; + + ret = getStringFromIndexWithDelim( string,",",num -1,token, sizeof( token)); + if( ret == FALSE ) { + return FALSE; + } + + return isstring1or0( token); +} + +static char* ITEM_checkString( char* string ) +{ +#define ITEM_STRINGLEN 64 + if( strlen(string) >= ITEM_STRINGLEN ) + print( "Over %d:[%s]\n",ITEM_STRINGLEN ,string ); + return string; +#undef ITEM_STRINGLEN +} + +BOOL ITEM_readItemConfFile( char* filename ) +{ + FILE* f; + char line[512]; + char token[64]; + int linenum=0; + int i; + int maxid=0, itemid; + int ret; + int intdata[ITEM_DATAINTNUM]; + + f = fopen(filename,"r"); + if( f == NULL ){ + print( "ܴļ\n"); + return FALSE; + } +#ifdef _ITEMSET2_ITEM + +#define ITEM_ID_TOKEN_INDEX 17 + +#else + +#ifdef _ITEM_MAXUSERNUM +#define ITEM_ID_TOKEN_INDEX 15 +#endif + +#endif + while( fgets( line, sizeof( line ), f ) ){ + linenum ++; + if( line[0] == '#' )continue; /* comment */ + if( line[0] == '\n' )continue; /* none */ + chomp( line ); + + ret = getStringFromIndexWithDelim( line, ",", ITEM_ID_TOKEN_INDEX, token, sizeof(token)); + if( ret == FALSE ){ + fprint("ļ:%s :%d\n",filename,linenum); + continue; + } + itemid = atoi( token); + if( itemid > maxid ){ + maxid = itemid; + } + } + + if( maxid <=0 ) { + print( "ID\n"); + fclose(f); + return FALSE; + } + + if( fseek( f, 0, SEEK_SET ) == -1 ){ + fprint( "\n" ); + fclose(f); + return FALSE; + } + print( "ƷID %d...", maxid); + ITEM_tblen = maxid + 1; +#ifdef _ITEMTBL_STAIC + for( i = 0 ; i < 24000 ; i ++ ) { + ITEM_tbl[i].use = FALSE; + } +#else + if( ITEM_tbl != NULL ) + freeMemory( ITEM_tbl); + ITEM_tbl = allocateMemory( sizeof(ITEM_table) * ITEM_tblen ); + + if( ITEM_tbl == NULL ){ + fprint( "޷ڴ %d\n" , sizeof(ITEM_table)*ITEM_tblen ); + fclose( f ); + return FALSE; + } + + print("һη %4.2f MB ռ...", sizeof(ITEM_table) * ITEM_tblen /1024.0/1024.0); + for( i = 0 ; i < ITEM_tblen ; i ++ ) { + ITEM_tbl[i].use = FALSE; + } +#endif + linenum = 0; + while( fgets( line, sizeof( line ), f ) ){ + linenum ++; + if( line[0] == '#' )continue; /* comment */ + if( line[0] == '\n' )continue; /* none */ + chomp( line ); + replaceString( line, '\t' , ' ' ); + +{ + char buf[256]; + for( i = 0; i < strlen( line); i ++) { + if( line[i] != ' ' ) { + break; + } + strcpy( buf, &line[i]); + } + if( i != 0 ) { + strcpy( line, buf); + } +} +{ + char token[256]; + int ret; + int readpos = 1; + BOOL dataerror = FALSE; + ITEM_Item itm; + + ITEM_getDefaultItemSetting(&itm); + + for( i=0 ; i< ITEM_DATAINTNUM ; i++ ) { + intdata[i] = 0; + } + itemid = 0; + for( i = 0 ; i < arraysizeof( ITEM_itemconfentries) ; i ++ ){ + ret = getStringFromIndexWithDelim( line,",",readpos,token, sizeof(token)); + if( ret == FALSE ) { +#ifdef _Item_ReLifeAct + { + char buf[256]; + char buf1[256]; + sscanf( line,"%s,%s", buf, buf1); + print("[ITEM data Error] tbl=%d:%s line:%d[%s]\n", + readpos, ITEM_itemconfentries[i].entryname, linenum, line); + } +#else + fprint("Syntax Error tki:%d file:%s line:%d[%s]\n", + i , filename,linenum,line); +#endif + dataerror = TRUE; + break; + } + + if( readpos == ITEM_ID_TOKEN_INDEX ) + itemid = atoi( token); + + readpos ++; + + if( strlen( token ) != 0 ) { + switch(ITEM_itemconfentries[i].type){ + case ITEM_INTENTRY: + itm.data[ITEM_itemconfentries[i].index] = atoi( token ); + break; + case ITEM_CHARENTRY: + strcpysafe( itm.string[ITEM_itemconfentries[i].index].string, + sizeof(itm.string[ITEM_itemconfentries[i].index].string), + token); + break; + case ITEM_INTFUNC: + { + int (*intfunction)(char*,int*, int ); + intfunction = ITEM_itemconfentries[i].func; + itm.data[ITEM_itemconfentries[i].index] + = intfunction(line, + &intdata[ITEM_itemconfentries[i].index],readpos); + if( intfunction == ITEM_getRandomValue) readpos ++; + + } + break; + case ITEM_CHARFUNC: + { + char* (*charfunction)(char* ); + charfunction = ITEM_itemconfentries[i].func; + strcpysafe( itm.string[ITEM_itemconfentries[i].index].string, + sizeof(itm.string[ITEM_itemconfentries[i].index].string), + charfunction( token)); + break; + } + default: + break; + } + } + } + if( !dataerror) { + if( itemid >= ITEM_tblen ){ + print( "ITEM_tbl full:%d err !!\n" , itemid ); + }else if( ITEM_tbl[itemid].use == TRUE ) { + fprint( "Duplicate Itemid %d.ignore\n" , itemid ); + }else{ + if( itm.string[ITEM_SECRETNAME].string[0] == '\0') { + fprint( "ERROR: ID %d item doesn't have secretname\n" + ,itemid ); + memcpy( &itm.string[ITEM_SECRETNAME].string, + &itm.string[ITEM_NAME].string, + sizeof(itm.string[ITEM_NAME].string)); + } +{ + int attacknum_min, attacknum_max; + attacknum_min = itm.data[ITEM_ATTACKNUM_MIN]; + attacknum_max = itm.data[ITEM_ATTACKNUM_MAX]; + if( attacknum_min == 0 ) attacknum_min = attacknum_max; + itm.data[ITEM_ATTACKNUM_MIN] = min( attacknum_min, + attacknum_max); + itm.data[ITEM_ATTACKNUM_MAX] = max( attacknum_min, + attacknum_max); +} + memcpy( &ITEM_tbl[itemid].itm, &itm, sizeof(ITEM_Item)); + ITEM_tbl[itemid].use = TRUE; + + for( i=0 ; i< ITEM_DATAINTNUM ; i++ ){ + ITEM_tbl[itemid].randomdata[i] = intdata[i]; + } + } + } +} + } + fclose(f); + return TRUE; +} + +CHAR_EquipPlace ITEM_getEquipPlace( int charaindex, int itmid ) +{ + ITEM_CATEGORY cat; + cat = ITEM_getInt( itmid , ITEM_TYPE ); + switch( cat ){ + case ITEM_FIST: + case ITEM_SPEAR: + case ITEM_AXE: + case ITEM_CLUB: +// case ITEM_SHIELD: + case ITEM_BOOMERANG: + case ITEM_BREAKTHROW: + case ITEM_BOUNDTHROW: + +#ifdef _PROFESSION_SKILL // WON ADD ְҵ + { + int i=0; + + // ʿְҵܶ + for( i=0; i 0 ) return -1; +#endif + return CHAR_ARM; + break; + +#ifdef _ITEM_EQUITSPACE + case ITEM_WBELT: + return CHAR_EQBELT; + break; + case ITEM_WSHIELD: + if( BATTLE_GetWepon( charaindex ) != ITEM_BOW ) + return CHAR_EQSHIELD; + break; + case ITEM_WSHOES: + return CHAR_EQSHOES; + break; +#endif + +#ifdef _EQUIT_NEWGLOVE + case ITEM_WGLOVE: + return CHAR_EQGLOVE; + break; +#endif + default: + break; + } + return -1; +} +#define ITEMSTRINGBUFSIZ 512 +static char ITEM_itemStatusStringBuffer[ITEMSTRINGBUFSIZ]; +char* ITEM_makeItemStatusString( int haveitemindex, int itemindex ) +{ + char escapename[256]; + char escapeeffectstring[256]; + char paramshow[256]; + int leaklevel; + int itemcolor = 0; + int flg; + + if( !ITEM_CHECKINDEX(itemindex) ) return "\0"; + leaklevel = ITEM_getInt(itemindex,ITEM_LEAKLEVEL); + + //if( leaklevel >= 1 ) // Nuke debug + { + makeEscapeString( ITEM_getChar(itemindex, ITEM_SECRETNAME), + escapename, sizeof(escapename) ); + /*if( leaklevel >= 2 ) + { + static struct Showparamint{ + char* name; + int intindex; + }showparamint[]={ + { "ATK" , ITEM_MODIFYATTACK }, + { "DEF" , ITEM_MODIFYDEFENCE }, + { "HP" , ITEM_MODIFYHP }, + { "MP" , ITEM_MODIFYMP }, + { "QUICK" , ITEM_MODIFYQUICK }, + { "LUCK" , ITEM_MODIFYLUCK }, + { "CHARM" , ITEM_MODIFYCHARM }, + }; + int i; + int stringlen=0; + + paramshow[0] = '\0'; + + for( i = 0 ; i < arraysizeof( showparamint ); i ++ ){ + int value; + char sign; + char tmpbuf[128]; + value = ITEM_getInt(itemindex,showparamint[i].intindex); + +#ifdef _PROFESSION_SKILL // WON ADD ְҵ + + + +#endif + + if( value == 0 )continue; + else if( value > 0 ) sign = '+'; + else sign = '-'; + + snprintf( tmpbuf,sizeof( tmpbuf ), "%s%c%d ", + showparamint[i].name,sign,ABS(value) ); + + strcpysafe( paramshow + stringlen , + sizeof(paramshow) - stringlen, tmpbuf ); + stringlen +=strlen(tmpbuf); + if( stringlen >= arraysizeof( paramshow )) + break; + } + dchop( paramshow , " " ); + } + else*/ + paramshow[0] = '\0'; + + } + /*else{ + if(strlen(ITEM_getChar(itemindex,ITEM_SECRETNAME)) > 0){ + makeEscapeString(ITEM_getChar(itemindex,ITEM_SECRETNAME),escapename,sizeof(escapename)); + } + else makeEscapeString( ITEM_getChar(itemindex,ITEM_NAME),escapename,sizeof(escapename)); + paramshow[0] = '\0'; + }*/ + makeEscapeString( ITEM_getChar( itemindex, ITEM_EFFECTSTRING), + escapeeffectstring, + sizeof(escapeeffectstring)); + int itemtime = ITEM_getInt(itemindex,ITEM_TIME); + if(itemtime>0){ + time_t timep; + struct tm *p; + timep = itemtime; + p=localtime(&timep); + int year=1900+p->tm_year; + int mon=1+p->tm_mon; + int date=p->tm_mday; + int hour=p->tm_hour; + int min=p->tm_min; + int sec=p->tm_sec; + char monbuf[5],datebuf[5],hourbuf[5],minbuf[5],secbuf[5]; + if(mon<10) sprintf(monbuf,"0%d",mon); + else sprintf(monbuf,"%d",mon); + if(date<10) sprintf(datebuf,"0%d",date); + else sprintf(datebuf,"%d",date); + if(hour<10) sprintf(hourbuf,"0%d",hour); + else sprintf(hourbuf,"%d",hour); + if(min<10) sprintf(minbuf,"0%d",min); + else sprintf(minbuf,"%d",min); + if(sec<10) sprintf(secbuf,"0%d",sec); + else sprintf(secbuf,"%d",sec); + char tmbuf[256]; + strcpy(tmbuf,escapeeffectstring); + sprintf(escapeeffectstring,"Ч:%d.%s.%s %s:%s:%s %s",year,monbuf,datebuf,hourbuf,minbuf,secbuf,tmbuf); + } +#ifdef _ITEM_COLOER + itemcolor = ITEM_getInt( itemindex, ITEM_COLOER); +#else + itemcolor = CHAR_COLORWHITE; +#endif + if( strlen( ITEM_getChar( itemindex, ITEM_CDKEY)) != 0 ) { + itemcolor = CHAR_COLORGREEN; + }else { + if( ITEM_getInt( itemindex, ITEM_MERGEFLG) ) { + itemcolor = CHAR_COLORYELLOW; + } + } +#ifdef _DROPITEM_COLOR + if(ITEM_getInt( itemindex, ITEM_VANISHATDROP) == 1 ){ + itemcolor = CHAR_COLORGREEN2; + } +#endif + flg = 0; + if( ITEM_getInt( itemindex, ITEM_CANPETMAIL)) { + flg |= 1 << 0; + } + if( ITEM_getInt( itemindex, ITEM_CANMERGEFROM)) { + flg |= 1 << 1; + } + if( ITEM_getInt( itemindex, ITEM_TYPE) == ITEM_DISH ) { + flg |= 1 << 2; + } +#ifdef _ITEM_INSLAY + if( ITEM_getInt( itemindex, ITEM_TYPE) == ITEM_METAL ) { + flg |= 1 << 3; + }else if( ITEM_getInt( itemindex, ITEM_TYPE) == ITEM_JEWEL ) { + flg |= 1 << 4; + } +#endif +#ifdef _PETSKILL_FIXITEM + if( ITEM_getInt( itemindex, ITEM_DAMAGECRUSHE) + != ITEM_getInt( itemindex, ITEM_MAXDAMAGECRUSHE) ){ + flg |= 1 << 5; + } +#endif + +#ifdef _ALCHEMIST + char INGNAME0[16]; + char INGNAME1[16]; + strcpy( INGNAME0, ITEM_getChar( itemindex, ITEM_INGNAME0) ); + strcpy( INGNAME1, ITEM_getChar( itemindex, ITEM_INGNAME1) ); + if( (INGNAME0[0] != '\0' && INGNAME1[0] != '\0') || (INGNAME0[0] == '\0') ) { + strcpy( INGNAME0, "" ); + } +#endif + + if( haveitemindex == -1 ) { +#ifdef _ADD_SHOW_ITEMDAMAGE // WON ADD ʾƷ;ö + char buff1[256]; + int crushe = ITEM_getInt( itemindex, ITEM_DAMAGECRUSHE); + int maxcrushe = ITEM_getInt( itemindex, ITEM_MAXDAMAGECRUSHE); + if(crushe < 1) crushe = 1; + if(maxcrushe < 1){ + sprintf(buff1, ""); // + }else{ + maxcrushe = maxcrushe/1000; + crushe = crushe/1000; + if( maxcrushe <= 0 ) maxcrushe = 1; + snprintf(buff1, sizeof(buff1), "%d%%", (int)((crushe*100)/maxcrushe) ); + } + + snprintf(ITEM_itemStatusStringBuffer, + sizeof( ITEM_itemStatusStringBuffer), + +#ifdef _ITEM_PILENUMS +#ifdef _PET_ITEM + "%s|%s|%d|%s|%d|%d|%d|%d|%d|%s|%d|%s|%d|", +#else +#ifdef _ALCHEMIST + "%s|%s|%d|%s|%d|%d|%d|%d|%d|%s|%d|%s", +#else + "%s|%s|%d|%s|%d|%d|%d|%d|%d|%s|%d", +#endif +#endif +#else + "%s|%s|%d|%s|%d|%d|%d|%d|%d|%s", +#endif + escapename, paramshow, + itemcolor, escapeeffectstring , + ITEM_getInt( itemindex, ITEM_BASEIMAGENUMBER), + ITEM_getInt( itemindex, ITEM_ABLEUSEFIELD), + ITEM_getInt( itemindex, ITEM_TARGET), + ITEM_getInt( itemindex, ITEM_LEVEL), + flg, + buff1 +#ifdef _ITEM_PILENUMS + ,ITEM_getInt( itemindex, ITEM_USEPILENUMS) +#ifdef _ALCHEMIST + ,INGNAME0 //,ITEM_getInt( itemindex, ITEM_ALCHEMIST) +#ifdef _PET_ITEM + , ITEM_getInt( itemindex, ITEM_TYPE) +#endif +#endif +#endif + ); +#else + snprintf(ITEM_itemStatusStringBuffer, + sizeof( ITEM_itemStatusStringBuffer), + "%s|%s|%d|%s|%d|%d|%d|%d|%d", + escapename, paramshow, + itemcolor, escapeeffectstring , + ITEM_getInt( itemindex, ITEM_BASEIMAGENUMBER), + ITEM_getInt( itemindex, ITEM_ABLEUSEFIELD), + ITEM_getInt( itemindex, ITEM_TARGET), + ITEM_getInt( itemindex, ITEM_LEVEL), + flg + ); +#endif + }else { +#ifdef _ADD_SHOW_ITEMDAMAGE // WON ADD ʾƷ;ö + char buff1[256]; + int crushe = ITEM_getInt( itemindex, ITEM_DAMAGECRUSHE); + int maxcrushe = ITEM_getInt( itemindex, ITEM_MAXDAMAGECRUSHE); + if(crushe < 1) crushe = 1; + if(maxcrushe < 1){ + sprintf(buff1, ""); // + }else{ + maxcrushe = maxcrushe/1000; + crushe = crushe/1000; + if( maxcrushe <= 0 ) maxcrushe = 1; + snprintf(buff1, sizeof(buff1), "%d%%", (int)((crushe*100)/maxcrushe) ); + } + snprintf(ITEM_itemStatusStringBuffer, sizeof( ITEM_itemStatusStringBuffer), + +#ifdef _ITEM_PILENUMS +#ifdef _PET_ITEM + "%s|%s|%d|%s|%d|%d|%d|%d|%d|%s|%d|%s|%d|", +#else +#ifdef _ALCHEMIST + "%s|%s|%d|%s|%d|%d|%d|%d|%d|%s|%d|%s", +#else + "%s|%s|%d|%s|%d|%d|%d|%d|%d|%s|%d", +#endif +#endif +#else + "%s|%s|%d|%s|%d|%d|%d|%d|%d|%s", +#endif + escapename, paramshow, + itemcolor, escapeeffectstring , + ITEM_getInt( itemindex, ITEM_BASEIMAGENUMBER), + ITEM_getInt( itemindex, ITEM_ABLEUSEFIELD), + ITEM_getInt( itemindex, ITEM_TARGET), + ITEM_getInt( itemindex, ITEM_LEVEL), + flg, + buff1 +#ifdef _ITEM_PILENUMS + ,ITEM_getInt( itemindex, ITEM_USEPILENUMS) +#ifdef _ALCHEMIST + ,INGNAME0 //,ITEM_getInt( itemindex, ITEM_ALCHEMIST) +#ifdef _PET_ITEM + , ITEM_getInt( itemindex, ITEM_TYPE) +#endif +#endif +#endif + ); +#else + snprintf(ITEM_itemStatusStringBuffer, + sizeof( ITEM_itemStatusStringBuffer), + "%d|%s|%s|%d|%s|%d|%d|%d|%d|%d", + haveitemindex, + escapename, paramshow, + itemcolor, escapeeffectstring , + ITEM_getInt( itemindex, ITEM_BASEIMAGENUMBER), + ITEM_getInt( itemindex, ITEM_ABLEUSEFIELD), + ITEM_getInt( itemindex, ITEM_TARGET), + ITEM_getInt( itemindex, ITEM_LEVEL), + flg + ); +#endif + } + + return ITEM_itemStatusStringBuffer; +} + +char* ITEM_makeItemFalseString( void ) +{ + +#ifdef _ADD_SHOW_ITEMDAMAGE // WON ADD ʾƷ;ö + strcpysafe( ITEM_itemStatusStringBuffer, + sizeof( ITEM_itemStatusStringBuffer), +#ifdef _ITEM_PILENUMS +#ifdef _ALCHEMIST +#ifdef _PET_ITEM + "|||||||||||||" +#else + "|||||||||||" +#endif +#else + "||||||||||" +#endif +#else + "|||||||||" +#endif + ); + +#else + strcpysafe( ITEM_itemStatusStringBuffer, + sizeof( ITEM_itemStatusStringBuffer), + "||||||||" ); +#endif + return ITEM_itemStatusStringBuffer; +} + +char* ITEM_makeItemFalseStringWithNum( int haveitemindex ) +{ +#ifdef _ADD_SHOW_ITEMDAMAGE // WON ADD ʾƷ;ö + snprintf( ITEM_itemStatusStringBuffer, sizeof( ITEM_itemStatusStringBuffer), + +#ifdef _ITEM_PILENUMS +#ifdef _ALCHEMIST + "%d||||||||||||", +#else + "%d|||||||||||", +#endif +#else + "%d||||||||||", +#endif + haveitemindex ); +#else + snprintf( ITEM_itemStatusStringBuffer, sizeof( ITEM_itemStatusStringBuffer), + "%d|||||||||", haveitemindex); +#endif + return ITEM_itemStatusStringBuffer; +} + +BOOL ITEM_makeItem( ITEM_Item* itm, int number ) +{ + int i; + if( ITEM_CHECKITEMTABLE(number) == FALSE ){ + print(" Can't makeItem for itemid:%d!!\n", number); + return FALSE; + } + memcpy( itm, &ITEM_tbl[number].itm , sizeof( ITEM_Item ) ); //new + for( i=0 ; idata[i] = ITEM_tbl[number].itm.data[i] + randomvalue; //new + } + itm->data[ITEM_LEAKLEVEL] = 1; + return TRUE; +} + +int ITEM_makeItemAndRegist( int number ) +{ + ITEM_Item itm; + memset( &itm, 0, sizeof( itm)); + if( ITEM_makeItem( &itm, number ) == FALSE ) + return -1; + return ITEM_initExistItemsOne( &itm ); +} + +#define EQUIP_FIX_MAX 10000000 +void ITEM_equipEffect( int index ) +{ + int i; + int attribaccum[4] = { 0,0,0,0}; +#ifdef _ANGEL_SUMMON + int angelmode, angelequip =0; +#endif + static struct itmeffectstruct{ + int itemdataintindex; + int charmodifyparamindex; + int accumulation; + int min; + int max; + int type; + }itemEffect[]={ + { ITEM_MODIFYATTACK, CHAR_WORKATTACKPOWER, 0, 0, EQUIP_FIX_MAX, 0}, + { ITEM_MODIFYDEFENCE, CHAR_WORKDEFENCEPOWER, -100, 0, EQUIP_FIX_MAX, 0}, + { ITEM_MODIFYQUICK, CHAR_WORKQUICK, -100, 0, EQUIP_FIX_MAX, 0}, + { ITEM_MODIFYHP, CHAR_WORKMAXHP, 0, 0, EQUIP_FIX_MAX, 0}, + { ITEM_MODIFYMP, CHAR_WORKMAXMP, 0, 0, 1000, 0}, // MP 100ƥ + + { ITEM_MODIFYLUCK, CHAR_WORKFIXLUCK, 0, 1, 5, 0}, + { ITEM_MODIFYCHARM, CHAR_WORKFIXCHARM, 0, 0, 100, 0}, + { ITEM_MODIFYAVOID, CHAR_WORKFIXAVOID, 0, 0, EQUIP_FIX_MAX, 0}, + { ITEM_POISON, CHAR_WORKMODPOISON, 0, -100, 100, 0}, + { ITEM_PARALYSIS, CHAR_WORKMODPARALYSIS, 0, -100, 100, 0}, + { ITEM_SLEEP, CHAR_WORKMODSLEEP, 0, -100, 100, 0}, + { ITEM_STONE, CHAR_WORKMODSTONE, 0, -100, 100, 0}, + { ITEM_DRUNK, CHAR_WORKMODDRUNK, 0, -100, 100, 0}, + { ITEM_CONFUSION, CHAR_WORKMODCONFUSION, 0, -100, 100, 0}, + { ITEM_CRITICAL, CHAR_WORKMODCRITICAL, 0, -100, 100, 0}, +#ifdef _ADD_DEAMGEDEFC + { ITEM_OTHERDAMAGE, CHAR_WORKOTHERDMAGE, 0, -100, 100, 0}, + { ITEM_OTHERDEFC, CHAR_WORKOTHERDEFC, 0, -100, 100, 0}, +#endif + +#ifdef _ITEMSET5_TXT + { ITEM_MODIFYARRANGE, CHAR_WORKFIXARRANGE, 0, 0, 1000, 0}, + { ITEM_MODIFYSEQUENCE, CHAR_WORKFIXSEQUENCE, 0, 0, 100, 1}, + { ITEM_ATTACHPILE, CHAR_WORKATTACHPILE, 0, 0, 10, 1}, + { ITEM_HITRIGHT, CHAR_WORKHITRIGHT, 0, 0, 40, 1}, +#endif +#ifdef _ITEMSET6_TXT + { ITEM_NEGLECTGUARD, CHAR_WORKNEGLECTGUARD, 0, 0, 30, 1}, +#endif + }; + + for( i = 0 ; i < arraysizeof( itemEffect ); i ++ ) + itemEffect[i].accumulation = 0; + + if( !CHAR_CHECKINDEX(index) )return; + +#ifdef _ANGEL_SUMMON + angelmode = CHAR_getWorkInt( index, CHAR_WORKANGELMODE); +#endif + + for( i = 0 ; i < CHAR_EQUIPPLACENUM ; i ++ ){ + +#ifdef _ALLBLUES_LUA_1_9 + if( CHAR_getInt( index, CHAR_WHICHTYPE) == CHAR_TYPEPLAYER ){ + if(EquipEffectFunction(index, i) == FALSE){ + continue; + } + } + +#endif + + int id = CHAR_getItemIndex(index,i); + if( ITEM_CHECKINDEX(id) ){ + int j; + int attrib = 0; + +#ifdef _PROFESSION_SKILL // WON ADD ְҵ + if( i == CHAR_ARM +#ifdef _WAN_FIX + && CHAR_getWorkInt(index,CHAR_WORKBATTLEINDEX)==-1 +#endif + ){ +#ifdef _WAN_FIX + if(CHAR_getWorkInt(index,CHAR_WORKBATTLEPROTYPE)==1) + CHAR_setWorkInt(index,CHAR_WORKBATTLEPROTYPE,0); + else +#endif + CHAR_sendStatusString( index , "S"); + } +#endif + + + + for( j=0; j < arraysizeof( itemEffect ); j ++ ) { +#ifdef _PROFESSION_SKILL // WON ADD ְҵ + + if( i == CHAR_EQSHIELD && CHAR_getInt( index, CHAR_WHICHTYPE) != CHAR_TYPEPET){ + int item_type = ITEM_FIST; + item_type = ITEM_getInt( id, ITEM_TYPE ); + + // װʱ + if( item_type != ITEM_WSHIELD ){ + int k; + // ʿְҵܶ + for( k=0; kskill, SKILL_LEVEL); + skill_level = PROFESSION_CHANGE_SKILL_LEVEL_A( skill_level ); + rate = (skill_level * 3 + 20); + value = ITEM_getInt( id, itemEffect[j].itemdataintindex ) * rate / 100; + itemEffect[j].accumulation += value; + } + } + }else + itemEffect[j].accumulation += ITEM_getInt( id, itemEffect[j].itemdataintindex ); + }else +#endif + itemEffect[j].accumulation += ITEM_getInt( id, itemEffect[j].itemdataintindex ); + } + + attrib = ITEM_getInt( id, ITEM_MODIFYATTRIB); + if( attrib > 0 && attrib < 5) { + attribaccum[attrib - 1] += ITEM_getInt( id, ITEM_MODIFYATTRIBVALUE); + } + +#ifdef _ANGEL_SUMMON + //if( !strcmp( ITEM_getChar( id, ITEM_USEFUNC), "ITEM_AngelToken") ) { + if( ITEM_getInt( id, ITEM_ID) == ANGELITEM ) { + //print(" ʹװ "); + angelequip = TRUE; + } +#endif + + + } + } + +#ifdef _WAN_FIX + if(CHAR_getWorkInt(index,CHAR_WORKBATTLEPROTYPE)==1 && CHAR_getWorkInt(index,CHAR_WORKBATTLEINDEX)==-1) + CHAR_setWorkInt(index,CHAR_WORKBATTLEPROTYPE,0); +#endif + +#ifdef _ANGEL_SUMMON + if( angelmode == TRUE && angelequip == FALSE ) { + CHAR_setWorkInt( index, CHAR_WORKANGELMODE, FALSE); + CHAR_sendAngelMark( CHAR_getWorkInt( index, CHAR_WORKOBJINDEX), 0); + print(" жʹ "); + } + if( angelmode == FALSE && angelequip == TRUE ) { + CHAR_setWorkInt( index, CHAR_WORKANGELMODE, TRUE); + CHAR_sendAngelMark( CHAR_getWorkInt( index, CHAR_WORKOBJINDEX), 1); + CHAR_talkToCli( index, -1, "ܵ˾鱣ᱻ˹", CHAR_COLORYELLOW ); + print(" װʹ "); + } +#endif + +#ifdef _FIX_MAXCHARMP + for(i = 3 ; i < arraysizeof( itemEffect ) ; i ++ ){ +#else + for(i = 5 ; i < arraysizeof( itemEffect ) ; i ++ ){ +#endif + int work=0; + if( itemEffect[i].type == 1 ){ + work = itemEffect[i].accumulation; + }else{ + work = CHAR_getWorkInt(index,itemEffect[i].charmodifyparamindex) + itemEffect[i].accumulation; + work = min( itemEffect[i].max, work ); + work = max( itemEffect[i].min, work ); + } + CHAR_setWorkInt( index, itemEffect[i].charmodifyparamindex, work ); + } + + for( i = 0; i < 4; i ++ ) { + CHAR_setWorkInt( index, CHAR_WORKFIXEARTHAT + i, + CHAR_getWorkInt( index, CHAR_WORKFIXEARTHAT + i) + + attribaccum[i]); + } + + for( i = 0; i < 4; i ++ ) { + int j; + for( j = 0; j < 4; j ++ ) { + if( i != j ) { + CHAR_setWorkInt( index, CHAR_WORKFIXEARTHAT + j, + CHAR_getWorkInt(index, CHAR_WORKFIXEARTHAT + j) - attribaccum[i]); + } + } + } + + for( i = 0; i < 4; i ++ ) { + if( CHAR_getWorkInt( index, CHAR_WORKFIXEARTHAT + i) > CHAR_MAXATTRIB) { + CHAR_setWorkInt( index, CHAR_WORKFIXEARTHAT + i, CHAR_MAXATTRIB); + } + } + + { + int work; + work = CHAR_getWorkInt(index,CHAR_WORKFIXSTR)+ itemEffect[0].accumulation; + CHAR_setWorkInt( index, CHAR_WORKFIXSTR, max( 0, work ) ); + work = CHAR_getWorkInt(index,CHAR_WORKFIXTOUGH) + itemEffect[1].accumulation; + CHAR_setWorkInt( index, CHAR_WORKFIXTOUGH, max( -100, work ) ); + work = CHAR_getWorkInt( index, CHAR_WORKFIXDEX) + itemEffect[2].accumulation; + CHAR_setWorkInt( index, CHAR_WORKFIXDEX, max( -100, work ) ); + } + +} + +void Other_DefcharWorkInt( int index) +{ + +#ifdef _SUIT_ITEM + int mfix,mtgh,mdex,mods,maxhp; + mfix = CHAR_getWorkInt( index, CHAR_WORKFIXSTR); + mtgh = CHAR_getWorkInt( index, CHAR_WORKFIXTOUGH); + mdex = CHAR_getWorkInt( index, CHAR_WORKFIXDEX); + maxhp = CHAR_getWorkInt( index, CHAR_WORKMAXHP); + + mods = CHAR_getWorkInt( index, CHAR_WORKSUITMODSTR); + mfix = mfix+((mfix*mods)/100); + CHAR_setWorkInt( index, CHAR_WORKFIXSTR, mfix+CHAR_getWorkInt( index, CHAR_WORKSUITSTR)); + CHAR_setWorkInt( index, CHAR_WORKFIXTOUGH, mtgh+CHAR_getWorkInt( index, CHAR_WORKSUITTGH)); + CHAR_setWorkInt( index, CHAR_WORKFIXDEX, mdex+CHAR_getWorkInt( index, CHAR_WORKSUITDEX)); + CHAR_setWorkInt( index, CHAR_WORKMAXHP, maxhp+ CHAR_getWorkInt( index, CHAR_WORKSUITVIT)); +#ifdef _SUIT_ADDPART3 + if( mfix > 0 ) + CHAR_setWorkInt( index, CHAR_WORKFIXSTR, CHAR_getWorkInt( index, CHAR_WORKFIXSTR)+mfix*CHAR_getWorkInt( index, CHAR_WORKSUITSTR_P)/100.0); + if( mtgh > 0 ) + CHAR_setWorkInt( index, CHAR_WORKFIXTOUGH, CHAR_getWorkInt( index, CHAR_WORKFIXTOUGH)+mtgh*CHAR_getWorkInt( index, CHAR_WORKSUITTGH_P)/100.0); + if( mdex > 0) + CHAR_setWorkInt( index, CHAR_WORKFIXDEX, CHAR_getWorkInt( index, CHAR_WORKFIXDEX)+mdex*CHAR_getWorkInt( index, CHAR_WORKSUITDEX_P)/100.0); +#endif +#endif//_SUIT_ITEM + +#ifdef _MAGIC_RESIST_EQUIT // WON ADD ְҵװ + /*{ + int f_res = -1, i_res = -1, t_res = -1; + f_res = CHAR_getWorkInt( index, CHAR_WORK_F_RESIST ); + i_res = CHAR_getWorkInt( index, CHAR_WORK_I_RESIST ); + t_res = CHAR_getWorkInt( index, CHAR_WORK_T_RESIST ); + + CHAR_setWorkInt( index, CHAR_WORK_F_RESIST, f_res+CHAR_getWorkInt( index, CHAR_WORK_F_SUIT ) ); + CHAR_setWorkInt( index, CHAR_WORK_I_RESIST, i_res+CHAR_getWorkInt( index, CHAR_WORK_I_SUIT ) ); + CHAR_setWorkInt( index, CHAR_WORK_T_RESIST, t_res+CHAR_getWorkInt( index, CHAR_WORK_T_SUIT ) ); + }*/ +#endif + + +#ifdef _PETSKILL_SETDUCK + //profession fix + //ʹûرʽʱ,Ὣֵȥ30%Ȼ趨ɻرֵ,ֵ趨,Ҳԭ趨Ļرֵûһ,(Change)Ȱõ + /*if( CHAR_getWorkInt( index, CHAR_MYSKILLDUCK) > 0 ){ + int mtgh = CHAR_getWorkInt( index, CHAR_WORKFIXTOUGH); + mtgh -= (mtgh*30)/100; + if( mtgh < 0 ) mtgh=0; + CHAR_setWorkInt( index, CHAR_MYSKILLDUCKPOWER, mtgh); + }*/ +#endif +#ifdef _MAGICPET_SKILL + if( CHAR_getWorkInt( index, CHAR_MYSKILLSTR) > 0 ){ + int mpower, mdef; + mpower = CHAR_getWorkInt( index, CHAR_WORKFIXSTR); + mdef = CHAR_getWorkInt( index, CHAR_MYSKILLSTRPOWER); + mpower += (mtgh*mdef)/100; + if( mtgh < 0 ) mtgh=0; + CHAR_setWorkInt( index, CHAR_WORKFIXSTR, mpower); + } + if( CHAR_getWorkInt( index, CHAR_MYSKILLTGH) > 0 ){ + int mpower, mdef; + mpower = CHAR_getWorkInt( index, CHAR_WORKFIXTOUGH); + mdef = CHAR_getWorkInt( index, CHAR_MYSKILLTGHPOWER); + mpower += (mtgh*mdef)/100; + if( mtgh < 0 ) mtgh=0; + CHAR_setWorkInt( index, CHAR_WORKFIXTOUGH, mpower); + } + if( CHAR_getWorkInt( index, CHAR_MYSKILLDEX) > 0 ){ + int mpower, mdef; + mpower = CHAR_getWorkInt( index, CHAR_WORKFIXDEX); + mdef = CHAR_getWorkInt( index, CHAR_MYSKILLDEXPOWER); + mpower += (mtgh*mdef)/100; + if( mtgh < 0 ) mtgh=0; + CHAR_setWorkInt( index, CHAR_WORKFIXDEX, mpower); + } +#endif + +#ifdef _PROFESSION_SKILL // WON ADD ְҵ + if( CHAR_getWorkInt( index, CHAR_MYSKILLHIT) > 0 ){ + int mpower, mdef; + mpower = CHAR_getWorkInt( index, CHAR_MYSKILLHIT); + mdef = CHAR_getWorkInt( index, CHAR_WORKHITRIGHT); + mpower += (mtgh*mdef)/100; + if( mtgh < 0 ) mtgh=0; + CHAR_setWorkInt( index, CHAR_MYSKILLHIT, mpower); + } + if( CHAR_getWorkInt( index, CHAR_WORK_WEAPON) > 0 ){ // ר + int mpower, mdef; + mpower = CHAR_getWorkInt( index, CHAR_WORKFIXSTR); + mdef = CHAR_getWorkInt( index, CHAR_WORKMOD_WEAPON); + mpower = mpower * ( 100 + mdef ) /100; + if( mtgh < 0 ) mtgh=0; + CHAR_setWorkInt( index, CHAR_WORKFIXSTR, mpower); + } +#endif + +#ifdef _VARY_WOLF + if(CHAR_getInt( index, CHAR_BASEIMAGENUMBER)==101428){ + int Rands=0, power; + Rands = CHAR_getWorkInt( index, CHAR_SKILLSTRPOWER); + power = CHAR_getWorkInt( index, CHAR_WORKFIXSTR); + power = power + (power*Rands)/100; + CHAR_setWorkInt( index, CHAR_WORKFIXSTR, power); + + Rands = CHAR_getWorkInt( index, CHAR_SKILLDEXPOWER); + power = CHAR_getWorkInt( index, CHAR_WORKFIXDEX); + power = power + (power*Rands)/100; + CHAR_setWorkInt( index, CHAR_WORKFIXDEX, power); + } +#endif + +#ifdef _PROFESSION_ADDSKILL + if( CHAR_getWorkInt( index, CHAR_WORKFEAR ) > 0 ){ + CHAR_setWorkInt( index, CHAR_WORKFIXSTR, CHAR_getWorkInt( index, CHAR_WORKFIXSTR ) - mfix*0.1 ); + CHAR_setWorkInt( index, CHAR_WORKFIXTOUGH, CHAR_getWorkInt( index, CHAR_WORKFIXTOUGH ) - mtgh*0.1 ); + CHAR_setWorkInt( index, CHAR_WORKFIXDEX, CHAR_getWorkInt( index, CHAR_WORKFIXDEX ) - mdex*0.2 ); + } +#endif + +#ifdef _MAGIC_WEAKEN + if(CHAR_getWorkInt(index,CHAR_WORKWEAKEN)>0){ + CHAR_setWorkInt( index, CHAR_WORKFIXSTR, CHAR_getWorkInt( index, CHAR_WORKFIXSTR)*0.8); + CHAR_setWorkInt( index, CHAR_WORKFIXTOUGH, CHAR_getWorkInt( index, CHAR_WORKFIXTOUGH)*0.8); + CHAR_setWorkInt( index, CHAR_WORKFIXDEX, CHAR_getWorkInt( index, CHAR_WORKFIXDEX)*0.8); + CHAR_setWorkInt( index, CHAR_WORKWEAKEN, CHAR_getWorkInt( index, CHAR_WORKWEAKEN)-1); + } +#endif +#ifdef _MAGIC_BARRIER// vincent :ħ + if( CHAR_getWorkInt( index, CHAR_WORKBARRIER) > 0){ + CHAR_setWorkInt( index, CHAR_WORKBARRIER, CHAR_getWorkInt( index, CHAR_WORKBARRIER) - 1); + } +#endif + + CHAR_setWorkInt(index, CHAR_WORKATTACKPOWER, CHAR_getWorkInt( index, CHAR_WORKFIXSTR ) ); + CHAR_setWorkInt(index, CHAR_WORKDEFENCEPOWER, CHAR_getWorkInt( index, CHAR_WORKFIXTOUGH ) ); + CHAR_setWorkInt(index, CHAR_WORKQUICK, CHAR_getWorkInt( index, CHAR_WORKFIXDEX ) ); +} + +char* ITEM_getAppropriateName(int itemindex) +{ + int nameindex; + if( !ITEM_CHECKINDEX(itemindex ) )return "\0"; + if( ITEM_getInt(itemindex,ITEM_LEAKLEVEL) <= 0 ) + nameindex = ITEM_NAME; + else + nameindex = ITEM_SECRETNAME; + return ITEM_getChar(itemindex,nameindex); + +} + +char* ITEM_getEffectString( int itemindex ) +{ + if( !ITEM_CHECKINDEX(itemindex))return "\0"; + return ITEM_item[itemindex].itm.string[ITEM_EFFECTSTRING].string; +} + +char *ITEM_getItemInfoFromNumber( int itemid ) +{ + return ITEMTBL_getChar( itemid, ITEM_EFFECTSTRING); +} + +INLINE char* _ITEM_getNameFromNumber( char *file, int line, int itemid ) +{ + if( ITEM_CHECKITEMTABLE(itemid) == FALSE ){ + print("Can't Get ItemTable for:%d! - %s:%d\n",itemid, file, line); + return "\0"; + } + return ITEMTBL_getChar( itemid, ITEM_NAME); +} + +int ITEM_getcostFromITEMtabl( int itemid ) +{ + return ITEMTBL_getInt( itemid, ITEM_COST); +} + +int ITEM_getlevelFromITEMtabl( int itemid ) +{ + return ITEMTBL_getInt( itemid, ITEM_LEVEL); +} + +int ITEM_getgraNoFromITEMtabl( int itemid ) +{ + return ITEMTBL_getInt( itemid, ITEM_BASEIMAGENUMBER); +} + +int ITEM_getcanpetmailFromITEMtabl( int itemid ) +{ + return ITEMTBL_getInt( itemid, ITEM_CANPETMAIL); +} + +int ITEM_getvanishatdropFromITEMtabl( int itemid ) +{ + return ITEMTBL_getInt( itemid, ITEM_VANISHATDROP); +} + +int ITEM_getdropatlogoutFromITEMtabl( int itemid ) +{ + return ITEMTBL_getInt( itemid, ITEM_DROPATLOGOUT); +} + +int ITEM_getmergeItemFromFromITEMtabl( int itemid ) +{ + return ITEMTBL_getInt( itemid, ITEM_CANMERGEFROM); +} + +BOOL ITEM_canuseMagic( int itemindex) +{ + if( !ITEM_CHECKINDEX(itemindex))return FALSE; + if( MAGIC_getMagicArray( ITEM_item[itemindex].itm.data[ITEM_MAGICID]) != -1 ) { + return TRUE; + } + return FALSE; +} + +INLINE ITEM_Item *ITEM_getItemPointer( int index ) +{ + if(!ITEM_CHECKINDEX(index))return NULL; + return &ITEM_item[index].itm; +} + +int ITEM_isTargetValid( int charaindex, int itemindex, int toindex) +{ + int itemtarget; + int Myside; + itemtarget = ITEM_getInt( itemindex, ITEM_TARGET ); + + Myside = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLESIDE ); + if ((toindex >= 0x0) && (toindex <= 0x13)) return 0; + + if (toindex == 0x14) {//20 ȫ 0 + if (itemtarget == ITEM_TARGET_ALLMYSIDE){ + if( Myside == 0 )return 0; + }else if(itemtarget == ITEM_TARGET_ALLOTHERSIDE ){ + if( Myside == 1 )return 0; + } + }else if (toindex == 0x15) {//21 ȫ 1 + if (itemtarget == ITEM_TARGET_ALLMYSIDE){ + if( Myside == 1 )return 0; + }else if( itemtarget == ITEM_TARGET_ALLOTHERSIDE ){ + if( Myside == 0 )return 0; + } + }else if (toindex == 0x16) { + if (itemtarget == ITEM_TARGET_ALL) + return 0; + } + return -1; +} +// Nuke end + + +#ifdef _ITEM_CHECKWARES +BOOL CHAR_CheckInItemForWares( int charaindex, int flg) +{ + int itemindex, i; + char token[256]; + + for( i=0; i<24; i++) { + itemindex = CHAR_getItemIndex( charaindex, i); + if( !ITEM_CHECKINDEX( itemindex) ) continue; + if( ITEM_getInt( itemindex, ITEM_TYPE) == ITEM_WARES ) { + if( flg == 0 ){ + return FALSE; + } + sprintf(token,"%s",ITEM_getChar( itemindex, ITEM_NAME)); + CHAR_talkToCli( charaindex, -1, token, CHAR_COLORYELLOW); + + CHAR_setItemIndex( charaindex, i ,-1); + ITEM_endExistItemsOne( itemindex); + CHAR_sendItemDataOne( charaindex, i); + } + } + return TRUE; +} +#endif + +int ITEMTBL_getInt( int ItemID, ITEM_DATAINT datatype) +{ + if( datatype >= ITEM_DATAINTNUM || datatype < 0 ) return -1; + if( ITEM_CHECKITEMTABLE(ItemID) == FALSE )return -1; + return ITEM_tbl[ItemID].itm.data[datatype]; //new +} + +char *ITEMTBL_getChar( int ItemID, ITEM_DATACHAR datatype) +{ + if( datatype >= ITEM_DATACHARNUM || datatype < 0 ) return "\0"; + if( ITEM_CHECKITEMTABLE(ItemID) == FALSE )return "\0"; + return ITEM_tbl[ItemID].itm.string[datatype].string; //new +} + +INLINE BOOL ITEM_CHECKITEMTABLE( int number ) +{ + if( number < 0 || number >= ITEM_tblen ){ + //andy_log + print("ITEM_CHECKITEMTABLE() number:%d ITEM_tblen:%d !!\n", number, ITEM_tblen ); + return FALSE; + } + return ITEM_tbl[number].use; //new +} + +int ITEM_getItemDamageCrusheED( int itemindex) +{ + int crushe = ITEM_getInt( itemindex, ITEM_DAMAGECRUSHE); + int maxcrushe = ITEM_getInt( itemindex, ITEM_MAXDAMAGECRUSHE); + if(maxcrushe < 1)return -1; + if( maxcrushe > 1000000) maxcrushe = 1000000; + if( crushe > 1000000) crushe = 1000000; + + return ((int) (crushe*100)/maxcrushe); +} + +void ITEM_RsetEquit( int charaindex) +{ + int i, itemindex, ti=-1; + for( i=0; i /* strstr */ +#include /* isdigit, isalnum */ +#include "common.h" +#include "char.h" +#include "char_base.h" +#include "char_data.h" +#include "configfile.h" +#include "item.h" +#include "item_event.h" +#include "object.h" +#include "anim_tbl.h" +#include "magic.h" +#include "handletime.h" +#include "log.h" +#include "util.h" +#include "encount.h" +#include "battle.h" +#include "battle_item.h" +#include "lssproto_serv.h" +#include "net.h" +#include "pet.h" +#include "npcutil.h" +#include "enemy.h" +#ifdef _Item_ReLifeAct +#include "battle_magic.h" +#endif +#ifdef _ITEM_WARP_FIX_BI +extern tagRidePetTable ridePetTable[296]; +#endif +#include "pet_skill.h" + +#ifdef _CFREE_petskill +#include "npc_freepetskillshop.h" +#endif +#ifdef _ALLBLUES_LUA +#include "mylua/function.h" +#endif +#ifdef _PROFESSION_SKILL // WON ADD ְҵ +#include "profession_skill.h" +#endif +#include "sasql.h" + +#ifdef _ITEM_LUA +#include "npc_lua.h" +#include "npc_lua_interface.h" +#endif +extern int playeronlinenum; +extern char hanzibuf[5000][8]; +int ITEM_TimeDelCheck( int itemindex ) +{ + int icnt, jcnt, playernum; + playernum = CHAR_getPlayerMaxNum(); + for( icnt = 0; icnt < playernum; icnt ++ ) { + if( CHAR_CHECKINDEX( icnt ) ) { + for( jcnt = 0; jcnt < CHAR_MAXITEMHAVE; jcnt ++ ) { + if( CHAR_getItemIndex( icnt, jcnt ) == itemindex ) { + print( "Чʱѵֵߴ(%s)(%s)\n", + CHAR_getUseName(icnt),ITEM_getAppropriateName(itemindex) ); + return FALSE; + } + } + } + } + return TRUE; +} + +int ITEM_eventDrop( int itemindex, int charaindex, int itemcharaindex ) +{ + typedef void (*DROPF)(int,int); + char szBuffer[256]=""; + DROPF dropfunc=NULL; + + if( ITEM_CHECKINDEX(itemindex) == FALSE )return -1; + + dropfunc=(DROPF)ITEM_getFunctionPointer( itemindex, ITEM_DROPFUNC ); + if( dropfunc ){ + dropfunc( charaindex, itemindex ); + } +#ifdef _ALLBLUES_LUA_1_2 + else{ + RunItemDropEvent(charaindex, itemindex ); + } +#endif + if( ITEM_getInt( itemindex, ITEM_VANISHATDROP) != 1 && ITEM_getInt( itemindex, ITEM_TIME) < 1)return 0; + snprintf( szBuffer, sizeof( szBuffer), "%s ˡ", + ITEM_getAppropriateName(itemindex) ); + CHAR_talkToCli( charaindex, -1, szBuffer, CHAR_COLORWHITE ); + + { + LogItem( + CHAR_getChar( charaindex, CHAR_NAME ), /* ƽҷ */ + CHAR_getChar( charaindex, CHAR_CDKEY ), +#ifdef _add_item_log_name // WON ADD itemlogitem + itemindex, +#else + ITEM_getInt( itemindex, ITEM_ID ), /* ʧ ة į */ +#endif + "Drop&Delete(ʧ)", + CHAR_getInt( charaindex,CHAR_FLOOR), + CHAR_getInt( charaindex,CHAR_X ), + CHAR_getInt( charaindex,CHAR_Y ), + ITEM_getChar( itemindex, ITEM_UNIQUECODE), + ITEM_getChar( itemindex, ITEM_NAME), + ITEM_getInt( itemindex, ITEM_ID) + ); + } + CHAR_setItemIndex( charaindex, itemcharaindex, -1); + ITEM_endExistItemsOne( itemindex ); + return 1; +} + +#undef UNDEF +#define UNDEF (-1) + +typedef struct { + char* cmd; /* ġ ٯ */ + char* onmessage; /* ٯ */ + char* offmessage; /* ٯ */ + int element; /* ޱئۢ */ + int maxElement; /* elementƥ϶ýľۢټ ëֹۢ */ +} ITEM_EFFECTPARAM; +static ITEM_EFFECTPARAM ITEM_restorableParam[] = { + {"hp", "HPظˡ", "HPˡ",CHAR_HP, CHAR_WORKMAXHP}, + {"mp", "MPظˡ", "MPˡ",CHAR_MP, CHAR_WORKMAXMP}, +}; +static ITEM_EFFECTPARAM ITEM_statusParam[] = { + {"po", CHAR_POISONSTRING, CHAR_RECOVERPOISONSTRING, + CHAR_POISON, UNDEF}, + + {"pa", CHAR_PARALYSISSTRING, CHAR_RECOVERPARALYSISSTRING, + CHAR_PARALYSIS, UNDEF}, + + {"si", CHAR_SILENCESTRING, CHAR_RECOVERSILENCESTRING, + CHAR_SLEEP,UNDEF}, + + {"st", CHAR_STONESTRING, CHAR_RECOVERSTONESTRING, CHAR_STONE, UNDEF}, + + {"da", CHAR_DARKNESSSTRING, CHAR_RECOVERDARKNESSSTRING, + CHAR_DRUNK,UNDEF}, + + {"co", CHAR_CONFUSIONSTRING,CHAR_RECOVERCONFUSIONSTRING, + CHAR_CONFUSION, UNDEF}, +}; + +/*#define LOCAL_DEBUG*/ +#ifdef LOCAL_DEBUG +#define DOUTFILE "doutfile" +#include +#include +static int eprintf(char* format, ...){ + va_list arg; + long len; + FILE* fp; + fp = fopen(DOUTFILE, "a"); + va_start(arg, format); + len = vfprintf(stderr, format, arg); + if(fp){ vfprintf(fp, format, arg); fclose(fp); } + va_end(arg); + return len; +} + +#define fprint eprintf +#endif + +static BOOL ITEM_isValidEffect(char* cmd, int value){ + int i; + + for(i=0; istring[ITEM_ARGUMENT].string; + if(* effectarg == '\0') return TRUE; + for(p=effectarg; *p != '\0'; ){ + int i; + if(*p == SEPARATORI) p++; + for(q=cmd, i=0; isalnum(*p) && i 0 ) + onoroff=ITEM_restorableParam[i].onmessage; + else if( amount < 0 ) + onoroff=ITEM_restorableParam[i].offmessage; + else + return FALSE; + strcpysafe( ansmsg, sizeof(ansmsg), onoroff ); + CHAR_talkToCli( charaindex, -1, ansmsg, CHAR_COLORWHITE); + return TRUE; +#else + if(value == ITEM_EFFECT_RESTORE_NORMAL){ + int maxv, curv, amount; + maxv =CHAR_getWorkInt(charaindex, ITEM_restorableParam[i].maxElement); + curv =CHAR_getInt(charaindex, ITEM_restorableParam[i].element); + amount = 30; + if(curv + amount < 0) amount = -curv; + CHAR_setInt(charaindex, ITEM_restorableParam[i].element, min((curv+amount), maxv)); + snprintf( ansmsg, sizeof(ansmsg), "%sظˡ", + ITEM_restorableParam[i].onmessage ); + CHAR_talkToCli( charaindex, -1, ansmsg, CHAR_COLORWHITE); + return TRUE; + }else if(value == ITEM_EFFECT_RESTORE_COMPLETE){ + int maxv; + maxv =CHAR_getWorkInt(charaindex, ITEM_restorableParam[i].maxElement); + CHAR_setInt(charaindex, ITEM_restorableParam[i].element, maxv); + snprintf( ansmsg, sizeof(ansmsg), "%sȫظ", ITEM_restorableParam[i].onmessage ); + CHAR_talkToCli( charaindex, -1, ansmsg, CHAR_COLORWHITE ); + return TRUE; + }else + return FALSE; +#endif + + } + } + if( value >= 0 ){ + int found = 0; + for(i=0; i (int)( itemputtime + getItemdeletetime() ) ) { + if( ITEM_TimeDelCheck( itemindex ) == FALSE ){ + return ; + } + { + LogItem( + "NULL", + "NULL", +#ifdef _add_item_log_name // WON ADD itemlogitem + itemindex, +#else + ITEM_getInt( itemindex, ITEM_ID ), +#endif + "TiemDelete", + OBJECT_getFloor( objindex ), + OBJECT_getX( objindex ), + OBJECT_getY( objindex ), + ITEM_getChar( itemindex, ITEM_UNIQUECODE), + ITEM_getChar( itemindex, ITEM_NAME), + ITEM_getInt( itemindex, ITEM_ID) + ); + } + ITEM_endExistItemsOne(itemindex); + CHAR_ObjectDelete(objindex); + } +} + +void ITEM_useEffectTohelos( int charaindex, int to_charaindex, int haveitemindex) +{ + char buf[64]; + char msgbuf[64]; + int ret; + int itemindex; + int cutrate, limitcount; + int per; + int sendcharaindex = charaindex; + + itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + if(!ITEM_CHECKINDEX(itemindex)) return; + + CHAR_setItemIndex(charaindex, haveitemindex ,-1); + CHAR_sendItemDataOne( charaindex, haveitemindex); + ret = getStringFromIndexWithDelim( ITEM_getChar(itemindex, ITEM_ARGUMENT) , + "|", 1, buf, sizeof( buf)); + if( ret != TRUE ) { + { + LogItem( + CHAR_getChar( charaindex, CHAR_NAME ), + CHAR_getChar( charaindex, CHAR_CDKEY ), +#ifdef _add_item_log_name // WON ADD itemlogitem + itemindex, +#else + ITEM_getInt( itemindex, ITEM_ID ), +#endif + "FieldErrorUse", + CHAR_getInt( charaindex,CHAR_FLOOR), + CHAR_getInt( charaindex,CHAR_X ), + CHAR_getInt( charaindex,CHAR_Y ), + ITEM_getChar( itemindex, ITEM_UNIQUECODE), + ITEM_getChar( itemindex, ITEM_NAME), + ITEM_getInt( itemindex, ITEM_ID) + ); + } + ITEM_endExistItemsOne( itemindex); + return; + } + cutrate = atoi( buf); + if( cutrate < 0 ) cutrate = 0; + ret = getStringFromIndexWithDelim( ITEM_getChar(itemindex, ITEM_ARGUMENT) , + "|", 2, buf, sizeof( buf)); + if( ret != TRUE ) { + { + LogItem( + CHAR_getChar( charaindex, CHAR_NAME ), + CHAR_getChar( charaindex, CHAR_CDKEY ), +#ifdef _add_item_log_name // WON ADD itemlogitem + itemindex, +#else + ITEM_getInt( itemindex, ITEM_ID ), +#endif + "FieldUse", + CHAR_getInt( charaindex,CHAR_FLOOR), + CHAR_getInt( charaindex,CHAR_X ), + CHAR_getInt( charaindex,CHAR_Y ), + ITEM_getChar( itemindex, ITEM_UNIQUECODE), + ITEM_getChar( itemindex, ITEM_NAME), + ITEM_getInt( itemindex, ITEM_ID) + ); + } + ITEM_endExistItemsOne( itemindex); + return; + } + limitcount = atoi( buf); + if( limitcount < 0) limitcount = 0; + if( CHAR_getWorkInt( charaindex, CHAR_WORKPARTYMODE) == CHAR_PARTY_CLIENT) { + sendcharaindex = CHAR_getWorkInt( charaindex, CHAR_WORKPARTYINDEX1); + } + CHAR_setWorkInt( sendcharaindex, CHAR_WORK_TOHELOS_CUTRATE, cutrate); + CHAR_setWorkInt( sendcharaindex, CHAR_WORK_TOHELOS_COUNT, limitcount); + + snprintf( msgbuf, sizeof(msgbuf), + "ץ%s ", ITEM_getChar(itemindex, ITEM_NAME) ); + CHAR_talkToCli( charaindex, -1, msgbuf, CHAR_COLORWHITE ); + + if( sendcharaindex != charaindex ) { + snprintf( msgbuf, sizeof(msgbuf), + "%s ץ %s ", + CHAR_getChar( charaindex, CHAR_NAME), + ITEM_getChar( itemindex, ITEM_NAME) ); + CHAR_talkToCli( sendcharaindex, -1, msgbuf, CHAR_COLORWHITE ); + } + + { + LogItem( + CHAR_getChar( charaindex, CHAR_NAME ), + CHAR_getChar( charaindex, CHAR_CDKEY ), +#ifdef _add_item_log_name // WON ADD itemlogitem + itemindex, +#else + ITEM_getInt( itemindex, ITEM_ID ), +#endif + "FieldUse", + CHAR_getInt( charaindex,CHAR_FLOOR), + CHAR_getInt( charaindex,CHAR_X ), + CHAR_getInt( charaindex,CHAR_Y ), + ITEM_getChar( itemindex, ITEM_UNIQUECODE), + ITEM_getChar( itemindex, ITEM_NAME), + ITEM_getInt( itemindex, ITEM_ID) + ); + } + ITEM_endExistItemsOne( itemindex); + per = ENCOUNT_getEncountPercentMin( sendcharaindex, + CHAR_getInt( sendcharaindex, CHAR_FLOOR), + CHAR_getInt( sendcharaindex, CHAR_X), + CHAR_getInt( sendcharaindex, CHAR_Y)); + if( per != -1) { + CHAR_setWorkInt( sendcharaindex, CHAR_WORKENCOUNTPROBABILITY_MIN, per); + } + per = ENCOUNT_getEncountPercentMax( sendcharaindex, + CHAR_getInt( sendcharaindex, CHAR_FLOOR), + CHAR_getInt( sendcharaindex, CHAR_X), + CHAR_getInt( sendcharaindex, CHAR_Y)); + if( per != -1) { + CHAR_setWorkInt( sendcharaindex, CHAR_WORKENCOUNTPROBABILITY_MAX, per); + } + CHAR_sendStatusString( sendcharaindex, "E" ); +} + +void ITEM_dropMic( int charaindex , int itemindex ) +{ + if( !ITEM_CHECKINDEX( itemindex )) return; + + CHAR_setWorkInt( charaindex, CHAR_WORKFLG, + CHAR_getWorkInt( charaindex, CHAR_WORKFLG ) & ~WORKFLG_MICMODE ); +} + +void ITEM_useMic_Field( int charaindex, int to_charaindex, int haveitemindex ) +{ + if( CHAR_getWorkInt( charaindex, CHAR_WORKFLG ) & WORKFLG_MICMODE ){ + CHAR_setWorkInt( charaindex, CHAR_WORKFLG, + CHAR_getWorkInt( charaindex, CHAR_WORKFLG ) & ~WORKFLG_MICMODE ); + CHAR_talkToCli( charaindex, -1, "˷趨ΪOFF", CHAR_COLORWHITE); + }else{ + CHAR_setWorkInt( charaindex, CHAR_WORKFLG, + CHAR_getWorkInt( charaindex, CHAR_WORKFLG ) | WORKFLG_MICMODE ); + CHAR_talkToCli( charaindex, -1, "˷趨ΪON", CHAR_COLORWHITE); + } +} +#if 1 +char *aszHealStringByOwn[] = { + "%s;ظ%d", + "%sظ%d", + "%s%d", + "%sҳ϶%d", + "" +}; + +char *aszDownStringByOwn[] = { + "%s;%d", + "%s%d", + "%s½%d", + "%sҳ϶½%d", + "" +}; + +char *aszHealStringByOther[] = { + "%s%s;ظ%d", + "%s%sظ%d", + "%s%s%d", + "%s%sҳ϶%d", + "" +}; + +char *aszDownStringByOther[] = { + "%s%s;%d", + "%s%s%d", + "%s%s%d", + "%s%sҳ϶ȼ%d", + "" +}; + +char *aszKeyString[] = {"", "", "", "", ""}; +int aHealInt[] = { CHAR_HP, CHAR_MP, CHAR_CHARM, CHAR_VARIABLEAI, -1 }; +int aHealMaxWork[] = { CHAR_WORKMAXHP, CHAR_WORKMAXMP, -1, -1, -1 }; + +void ITEM_useRecovery_Field( + int charaindex, + int toindex, + int haveitemindex +){ + int work, workmax, workmin; + int power[BD_KIND_END] = {0,0,0}, + prevhp = 0, + workhp = 0, + recovery[BD_KIND_END] = {0,0,0}; + int itemindex, kind = BD_KIND_HP, HealFlg = 0, j; + char *p = NULL, *arg, msgbuf[256]; + itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + if( !ITEM_CHECKINDEX(itemindex) ) return; + if( CHAR_CHECKINDEX( toindex ) == FALSE )return ; + arg = ITEM_getChar(itemindex, ITEM_ARGUMENT ); + if( arg == "\0" ) return; + +#ifdef _ITEM_UNBECOMEPIG + if( (p = strstr( arg, "" )) != NULL ){ + if( CHAR_getInt( toindex, CHAR_BECOMEPIG ) > -1 ){ + CHAR_setInt( toindex, CHAR_BECOMEPIG, -1 ); + CHAR_complianceParameter( toindex ); + CHAR_sendCToArroundCharacter( CHAR_getWorkInt( toindex , CHAR_WORKOBJINDEX )); + CHAR_send_P_StatusString( toindex , CHAR_P_STRING_BASEBASEIMAGENUMBER); + CHAR_talkToCli( toindex,-1,"ʧЧˡ",CHAR_COLORWHITE); + CHAR_DelItemMess( charaindex, haveitemindex, 0); + } + return; + } +#endif +#ifdef _ITEM_LVUPUP + if( (p = strstr( arg, "LVUPUP" ) ) != NULL ){ + if (CHAR_getInt(toindex, CHAR_WHICHTYPE)==CHAR_TYPEPET){ + int pidx=0,lvup=0,lv=0; + sprintf( msgbuf, "%s", p+7 ); + pidx = atoi( strtok( msgbuf, " " ) ); + if( pidx != CHAR_getInt( toindex, CHAR_PETID) || CHAR_getInt(toindex, CHAR_LIMITLEVEL) == 0 ){ + CHAR_talkToCli( charaindex,-1,"޷ʹ",CHAR_COLORWHITE); + return; + } + lv = CHAR_getInt( toindex, CHAR_LV ); + if( lv < 10 || lv >= 140 ){ + CHAR_talkToCli( charaindex,-1,"Ŀǰȼ޷ʹ",CHAR_COLORWHITE); + return; + } + if( (p = strstr( arg, "" )) != NULL ) + lvup=2; + if( (p = strstr( arg, "ˮ" )) != NULL ) + lvup=3; + if( (p = strstr( arg, "" )) != NULL ) + lvup=0; + if( (p = strstr( arg, "" )) != NULL ) + lvup=1; + if( lv%4 != lvup || CHAR_getInt(toindex, CHAR_LIMITLEVEL)-lv >= 1 ){// + CHAR_talkToCli( charaindex,-1,"Ƴӡʧ",CHAR_COLORWHITE); + CHAR_DelItemMess( charaindex, haveitemindex, 0); + return; + } + CHAR_setInt(toindex, CHAR_LIMITLEVEL, CHAR_getInt(toindex, CHAR_LIMITLEVEL)+1); + CHAR_talkToCli( charaindex,-1,"ӡħߵȼ",CHAR_COLORWHITE); + if( CHAR_getInt(toindex, CHAR_LIMITLEVEL) == 140 ){ + CHAR_setInt(toindex, CHAR_LIMITLEVEL, 0); + CHAR_talkToCli( charaindex,-1,"ӡħ",CHAR_COLORWHITE); + } + CHAR_DelItemMess( charaindex, haveitemindex, 0); + CHAR_complianceParameter( toindex ); + CHAR_sendCToArroundCharacter( CHAR_getWorkInt( toindex , CHAR_WORKOBJINDEX )); + } + return; + } + if( (p = strstr( arg, "UPUPLV" ) ) != NULL ){ + if (CHAR_getInt(toindex, CHAR_WHICHTYPE)==CHAR_TYPEPET){ + int pidx=0,lv=0; + sprintf( msgbuf, "%s", p+7 ); + pidx = atoi( strtok( msgbuf, " " ) ); + if( pidx != CHAR_getInt( toindex, CHAR_PETID) || CHAR_getInt(toindex, CHAR_LIMITLEVEL) == 0 ){ + CHAR_talkToCli( charaindex,-1,"޷ʹ",CHAR_COLORWHITE); + return; + } + lv = CHAR_getInt( toindex, CHAR_LV ); + if( lv < 125 || lv > 140 ){ + CHAR_talkToCli( charaindex,-1,"Ŀǰȼ޷ʹ",CHAR_COLORWHITE); + return; + } + CHAR_setInt(toindex, CHAR_LIMITLEVEL, 0); + CHAR_talkToCli( charaindex,-1,"ӡħ",CHAR_COLORWHITE); + CHAR_DelItemMess( charaindex, haveitemindex, 0); + CHAR_complianceParameter( toindex ); + CHAR_sendCToArroundCharacter( CHAR_getWorkInt( toindex , CHAR_WORKOBJINDEX )); + } + return; + } +#endif +#ifdef _ITEM_PROPERTY + if( (p = strstr( arg, "PROPERTY" ) ) != NULL ){ + //print("ˮ:%s", arg ); + if (CHAR_getInt(toindex, CHAR_WHICHTYPE)!=CHAR_TYPEPLAYER) + return; + if( (p = strstr( arg, "+" ) ) != NULL ){//ת ת + if( CHAR_getInt( toindex, CHAR_EARTHAT ) == 100 ) + CHAR_setInt( toindex, CHAR_EARTHAT, CHAR_getInt( toindex, CHAR_EARTHAT )-10 ), + CHAR_setInt( toindex, CHAR_WATERAT, CHAR_getInt( toindex, CHAR_WATERAT )+10 ); + else if( CHAR_getInt( toindex, CHAR_WATERAT ) == 100 ) + CHAR_setInt( toindex, CHAR_WATERAT, CHAR_getInt( toindex, CHAR_WATERAT )-10 ), + CHAR_setInt( toindex, CHAR_FIREAT, CHAR_getInt( toindex, CHAR_FIREAT )+10 ); + else if( CHAR_getInt( toindex, CHAR_FIREAT ) == 100 ) + CHAR_setInt( toindex, CHAR_FIREAT, CHAR_getInt( toindex, CHAR_FIREAT )-10 ), + CHAR_setInt( toindex, CHAR_WINDAT, CHAR_getInt( toindex, CHAR_WINDAT )+10 ); + else if( CHAR_getInt( toindex, CHAR_WINDAT ) == 100 ) + CHAR_setInt( toindex, CHAR_WINDAT, CHAR_getInt( toindex, CHAR_WINDAT )-10 ), + CHAR_setInt( toindex, CHAR_EARTHAT, CHAR_getInt( toindex, CHAR_EARTHAT )+10 ); + else if( CHAR_getInt( toindex, CHAR_EARTHAT ) > 0 && CHAR_getInt( toindex, CHAR_WATERAT ) > 0 ) + CHAR_setInt( toindex, CHAR_EARTHAT, CHAR_getInt( toindex, CHAR_EARTHAT )-10 ), + CHAR_setInt( toindex, CHAR_WATERAT, CHAR_getInt( toindex, CHAR_WATERAT )+10 ); + else if( CHAR_getInt( toindex, CHAR_WATERAT ) > 0 && CHAR_getInt( toindex, CHAR_FIREAT ) > 0 ) + CHAR_setInt( toindex, CHAR_WATERAT, CHAR_getInt( toindex, CHAR_WATERAT )-10 ), + CHAR_setInt( toindex, CHAR_FIREAT, CHAR_getInt( toindex, CHAR_FIREAT )+10 ); + else if( CHAR_getInt( toindex, CHAR_FIREAT ) > 0 && CHAR_getInt( toindex, CHAR_WINDAT ) > 0 ) + CHAR_setInt( toindex, CHAR_FIREAT, CHAR_getInt( toindex, CHAR_FIREAT )-10 ), + CHAR_setInt( toindex, CHAR_WINDAT, CHAR_getInt( toindex, CHAR_WINDAT )+10 ); + else if( CHAR_getInt( toindex, CHAR_WINDAT ) > 0 && CHAR_getInt( toindex, CHAR_EARTHAT ) > 0 ) + CHAR_setInt( toindex, CHAR_WINDAT, CHAR_getInt( toindex, CHAR_WINDAT )-10 ), + CHAR_setInt( toindex, CHAR_EARTHAT, CHAR_getInt( toindex, CHAR_EARTHAT )+10 ); + } + if( (p = strstr( arg, "-" ) ) != NULL ){//ת ת + if( CHAR_getInt( toindex, CHAR_EARTHAT ) == 100 ) + CHAR_setInt( toindex, CHAR_EARTHAT, CHAR_getInt( toindex, CHAR_EARTHAT )-10 ), + CHAR_setInt( toindex, CHAR_WINDAT, CHAR_getInt( toindex, CHAR_WINDAT )+10 ); + else if( CHAR_getInt( toindex, CHAR_WATERAT ) == 100 ) + CHAR_setInt( toindex, CHAR_WATERAT, CHAR_getInt( toindex, CHAR_WATERAT )-10 ), + CHAR_setInt( toindex, CHAR_EARTHAT, CHAR_getInt( toindex, CHAR_EARTHAT )+10 ); + else if( CHAR_getInt( toindex, CHAR_FIREAT ) == 100 ) + CHAR_setInt( toindex, CHAR_FIREAT, CHAR_getInt( toindex, CHAR_FIREAT )-10 ), + CHAR_setInt( toindex, CHAR_WATERAT, CHAR_getInt( toindex, CHAR_WATERAT )+10 ); + else if( CHAR_getInt( toindex, CHAR_WINDAT ) == 100 ) + CHAR_setInt( toindex, CHAR_WINDAT, CHAR_getInt( toindex, CHAR_WINDAT )-10 ), + CHAR_setInt( toindex, CHAR_FIREAT, CHAR_getInt( toindex, CHAR_FIREAT )+10 ); + else if( CHAR_getInt( toindex, CHAR_EARTHAT ) > 0 && CHAR_getInt( toindex, CHAR_WATERAT ) > 0 ) + CHAR_setInt( toindex, CHAR_EARTHAT, CHAR_getInt( toindex, CHAR_EARTHAT )+10 ), + CHAR_setInt( toindex, CHAR_WATERAT, CHAR_getInt( toindex, CHAR_WATERAT )-10 ); + else if( CHAR_getInt( toindex, CHAR_WATERAT ) > 0 && CHAR_getInt( toindex, CHAR_FIREAT ) > 0 ) + CHAR_setInt( toindex, CHAR_WATERAT, CHAR_getInt( toindex, CHAR_WATERAT )+10 ), + CHAR_setInt( toindex, CHAR_FIREAT, CHAR_getInt( toindex, CHAR_FIREAT )-10 ); + else if( CHAR_getInt( toindex, CHAR_FIREAT ) > 0 && CHAR_getInt( toindex, CHAR_WINDAT ) > 0 ) + CHAR_setInt( toindex, CHAR_FIREAT, CHAR_getInt( toindex, CHAR_FIREAT )+10 ), + CHAR_setInt( toindex, CHAR_WINDAT, CHAR_getInt( toindex, CHAR_WINDAT )-10 ); + else if( CHAR_getInt( toindex, CHAR_WINDAT ) > 0 && CHAR_getInt( toindex, CHAR_EARTHAT ) > 0 ) + CHAR_setInt( toindex, CHAR_WINDAT, CHAR_getInt( toindex, CHAR_WINDAT )+10 ), + CHAR_setInt( toindex, CHAR_EARTHAT, CHAR_getInt( toindex, CHAR_EARTHAT )-10 ); + } + CHAR_DelItemMess( charaindex, haveitemindex, 0); + CHAR_complianceParameter( toindex ); + CHAR_sendCToArroundCharacter( CHAR_getWorkInt( toindex , CHAR_WORKOBJINDEX )); + CHAR_send_P_StatusString( toindex , + CHAR_P_STRING_EARTH | + CHAR_P_STRING_WATER | + CHAR_P_STRING_FIRE | + CHAR_P_STRING_WIND + ); + return; + } +#endif +#ifdef _ITEM_PROPERTY + if( (p = strstr( arg, "PROPETPERTY" ) ) != NULL ){ + //print("ˮ:%s", arg ); + if (CHAR_getInt(toindex, CHAR_WHICHTYPE)!=CHAR_TYPEPET) + return; + if( (p = strstr( arg, "+" ) ) != NULL ){//ת ת + if( CHAR_getInt( toindex, CHAR_EARTHAT ) == 100 ) + CHAR_setInt( toindex, CHAR_EARTHAT, CHAR_getInt( toindex, CHAR_EARTHAT )-10 ), + CHAR_setInt( toindex, CHAR_WATERAT, CHAR_getInt( toindex, CHAR_WATERAT )+10 ); + else if( CHAR_getInt( toindex, CHAR_WATERAT ) == 100 ) + CHAR_setInt( toindex, CHAR_WATERAT, CHAR_getInt( toindex, CHAR_WATERAT )-10 ), + CHAR_setInt( toindex, CHAR_FIREAT, CHAR_getInt( toindex, CHAR_FIREAT )+10 ); + else if( CHAR_getInt( toindex, CHAR_FIREAT ) == 100 ) + CHAR_setInt( toindex, CHAR_FIREAT, CHAR_getInt( toindex, CHAR_FIREAT )-10 ), + CHAR_setInt( toindex, CHAR_WINDAT, CHAR_getInt( toindex, CHAR_WINDAT )+10 ); + else if( CHAR_getInt( toindex, CHAR_WINDAT ) == 100 ) + CHAR_setInt( toindex, CHAR_WINDAT, CHAR_getInt( toindex, CHAR_WINDAT )-10 ), + CHAR_setInt( toindex, CHAR_EARTHAT, CHAR_getInt( toindex, CHAR_EARTHAT )+10 ); + else if( CHAR_getInt( toindex, CHAR_EARTHAT ) > 0 && CHAR_getInt( toindex, CHAR_WATERAT ) > 0 ) + CHAR_setInt( toindex, CHAR_EARTHAT, CHAR_getInt( toindex, CHAR_EARTHAT )-10 ), + CHAR_setInt( toindex, CHAR_WATERAT, CHAR_getInt( toindex, CHAR_WATERAT )+10 ); + else if( CHAR_getInt( toindex, CHAR_WATERAT ) > 0 && CHAR_getInt( toindex, CHAR_FIREAT ) > 0 ) + CHAR_setInt( toindex, CHAR_WATERAT, CHAR_getInt( toindex, CHAR_WATERAT )-10 ), + CHAR_setInt( toindex, CHAR_FIREAT, CHAR_getInt( toindex, CHAR_FIREAT )+10 ); + else if( CHAR_getInt( toindex, CHAR_FIREAT ) > 0 && CHAR_getInt( toindex, CHAR_WINDAT ) > 0 ) + CHAR_setInt( toindex, CHAR_FIREAT, CHAR_getInt( toindex, CHAR_FIREAT )-10 ), + CHAR_setInt( toindex, CHAR_WINDAT, CHAR_getInt( toindex, CHAR_WINDAT )+10 ); + else if( CHAR_getInt( toindex, CHAR_WINDAT ) > 0 && CHAR_getInt( toindex, CHAR_EARTHAT ) > 0 ) + CHAR_setInt( toindex, CHAR_WINDAT, CHAR_getInt( toindex, CHAR_WINDAT )-10 ), + CHAR_setInt( toindex, CHAR_EARTHAT, CHAR_getInt( toindex, CHAR_EARTHAT )+10 ); + } + if( (p = strstr( arg, "-" ) ) != NULL ){//ת ת + if( CHAR_getInt( toindex, CHAR_EARTHAT ) == 100 ) + CHAR_setInt( toindex, CHAR_EARTHAT, CHAR_getInt( toindex, CHAR_EARTHAT )-10 ), + CHAR_setInt( toindex, CHAR_WINDAT, CHAR_getInt( toindex, CHAR_WINDAT )+10 ); + else if( CHAR_getInt( toindex, CHAR_WATERAT ) == 100 ) + CHAR_setInt( toindex, CHAR_WATERAT, CHAR_getInt( toindex, CHAR_WATERAT )-10 ), + CHAR_setInt( toindex, CHAR_EARTHAT, CHAR_getInt( toindex, CHAR_EARTHAT )+10 ); + else if( CHAR_getInt( toindex, CHAR_FIREAT ) == 100 ) + CHAR_setInt( toindex, CHAR_FIREAT, CHAR_getInt( toindex, CHAR_FIREAT )-10 ), + CHAR_setInt( toindex, CHAR_WATERAT, CHAR_getInt( toindex, CHAR_WATERAT )+10 ); + else if( CHAR_getInt( toindex, CHAR_WINDAT ) == 100 ) + CHAR_setInt( toindex, CHAR_WINDAT, CHAR_getInt( toindex, CHAR_WINDAT )-10 ), + CHAR_setInt( toindex, CHAR_FIREAT, CHAR_getInt( toindex, CHAR_FIREAT )+10 ); + else if( CHAR_getInt( toindex, CHAR_EARTHAT ) > 0 && CHAR_getInt( toindex, CHAR_WATERAT ) > 0 ) + CHAR_setInt( toindex, CHAR_EARTHAT, CHAR_getInt( toindex, CHAR_EARTHAT )+10 ), + CHAR_setInt( toindex, CHAR_WATERAT, CHAR_getInt( toindex, CHAR_WATERAT )-10 ); + else if( CHAR_getInt( toindex, CHAR_WATERAT ) > 0 && CHAR_getInt( toindex, CHAR_FIREAT ) > 0 ) + CHAR_setInt( toindex, CHAR_WATERAT, CHAR_getInt( toindex, CHAR_WATERAT )+10 ), + CHAR_setInt( toindex, CHAR_FIREAT, CHAR_getInt( toindex, CHAR_FIREAT )-10 ); + else if( CHAR_getInt( toindex, CHAR_FIREAT ) > 0 && CHAR_getInt( toindex, CHAR_WINDAT ) > 0 ) + CHAR_setInt( toindex, CHAR_FIREAT, CHAR_getInt( toindex, CHAR_FIREAT )+10 ), + CHAR_setInt( toindex, CHAR_WINDAT, CHAR_getInt( toindex, CHAR_WINDAT )-10 ); + else if( CHAR_getInt( toindex, CHAR_WINDAT ) > 0 && CHAR_getInt( toindex, CHAR_EARTHAT ) > 0 ) + CHAR_setInt( toindex, CHAR_WINDAT, CHAR_getInt( toindex, CHAR_WINDAT )+10 ), + CHAR_setInt( toindex, CHAR_EARTHAT, CHAR_getInt( toindex, CHAR_EARTHAT )-10 ); + } + CHAR_DelItemMess( charaindex, haveitemindex, 0); + CHAR_complianceParameter( toindex ); + CHAR_sendCToArroundCharacter( CHAR_getWorkInt( toindex , CHAR_WORKOBJINDEX )); +// CHAR_complianceParameter( charaindex ); +// CHAR_sendCToArroundCharacter( CHAR_getWorkInt( charaindex , CHAR_WORKOBJINDEX )); + int z; + for( z = 0; z < CHAR_MAXPETHAVE; z ++ ) { + int workpetindex = CHAR_getCharPet( charaindex, z ); + if( workpetindex == toindex ){ + CHAR_send_K_StatusString( charaindex, z, CHAR_K_STRING_EARTH|CHAR_K_STRING_WATER|CHAR_K_STRING_FIRE|CHAR_K_STRING_WIND); + } + } + return; + } +#endif +#ifdef _PET_RESET + if( (p = strstr( arg, "RESETPET" ) ) != NULL ){ + if (CHAR_getInt(toindex, CHAR_WHICHTYPE)!=CHAR_TYPEPET) + return; + if(CHAR_getInt(toindex, CHAR_PETENEMYID)<=0){ + CHAR_talkToCli( charaindex,-1,"˳ϻ޷¯",CHAR_COLORRED); + return; + } + int petpoint = sasql_resetpet_point(CHAR_getInt(toindex, CHAR_PETENEMYID)); + if(petpoint<0){ + CHAR_talkToCli( charaindex,-1,"˳޷¯",CHAR_COLORRED); + return; + }else{ + CHAR_setWorkInt(charaindex,CHAR_WORKRESETPETINDEX,toindex); + int fd = getfdFromCharaIndex( charaindex); + char petbuf[512]; + sprintf(petbuf,"Ҫ¯ֻ%s\n" + "¯ֻҪʷѣ%d\n\n" + "رע\n" + "1¯ɾԭһֻ\n" + "2¯зգɳδҪϸġ",CHAR_getChar(toindex,CHAR_NAME),petpoint); + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_YESNO, + CHAR_WINDOWTYPE_RESETPET, + -1, + petbuf); + } + CHAR_DelItemMess( charaindex, haveitemindex, 0); + CHAR_complianceParameter( charaindex ); + CHAR_sendCToArroundCharacter( CHAR_getWorkInt( charaindex , CHAR_WORKOBJINDEX )); + return; + } + + if( (p = strstr( arg, "RESETBDPET" ) ) != NULL ){ + if (CHAR_getInt(toindex, CHAR_WHICHTYPE)!=CHAR_TYPEPET) + return; + if(CHAR_getInt(toindex, CHAR_PETENEMYID)<=0){ + CHAR_talkToCli( charaindex,-1,"˳ϻ޷¯",CHAR_COLORRED); + return; + } + int petpoint = sasql_resetbdpet_point(CHAR_getInt(toindex, CHAR_PETENEMYID)); + if(petpoint<0){ + CHAR_talkToCli( charaindex,-1,"˳޷¯",CHAR_COLORRED); + return; + }else{ + CHAR_setWorkInt(charaindex,CHAR_WORKRESETPETINDEX,toindex); + int fd = getfdFromCharaIndex( charaindex); + char petbuf[512]; + sprintf(petbuf,"Ҫ󶨻¯ֻ%s\n" + "󶨻¯ֻҪʷѣ%d\n\n" + "رע\n" + "1¯ɾԭһֻ\n" + "2¯зգɳδҪϸġ\n" + "3󶨻¯󣬸ó޷װ̯",CHAR_getChar(toindex,CHAR_NAME),petpoint); + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_YESNO, + CHAR_WINDOWTYPE_RESETBDPET, + -1, + petbuf); + } + CHAR_DelItemMess( charaindex, haveitemindex, 0); + CHAR_complianceParameter( charaindex ); + CHAR_sendCToArroundCharacter( CHAR_getWorkInt( charaindex , CHAR_WORKOBJINDEX )); + return; + } +#endif +#ifdef _ITEM_ADDPETEXP + if( (p = strstr( arg, "GETEXP" )) != NULL ){ + if (CHAR_getInt(toindex, CHAR_WHICHTYPE)==CHAR_TYPEPET){ + getStringFromIndexWithDelim( arg, "|", 2, msgbuf,sizeof( msgbuf));// + if( atoi(msgbuf) == CHAR_getInt( toindex, CHAR_PETID) ){ + getStringFromIndexWithDelim( arg, "|", 3, msgbuf,sizeof( msgbuf));//ȼ(ȼſ) + if( CHAR_getInt( toindex, CHAR_LV ) >= atoi(msgbuf) ){ + getStringFromIndexWithDelim( arg, "|", 4, msgbuf,sizeof( msgbuf));//ֵ + if( CHAR_getInt( toindex, CHAR_LV) < CHAR_MAXUPLEVEL ){ + int UpLevel = 0; + CHAR_setWorkInt( toindex, CHAR_WORKGETEXP, atoi(msgbuf) );//شCHAR_WORKGETEXP + CHAR_AddMaxExp( toindex, CHAR_getWorkInt( toindex, CHAR_WORKGETEXP ) ); + sprintf( msgbuf,"ʯͷ治֪ʲĿҿ(Ӿ%d)", CHAR_getWorkInt( toindex, CHAR_WORKGETEXP ) ); + CHAR_talkToCli( charaindex,-1,msgbuf,CHAR_COLORWHITE); + UpLevel = CHAR_LevelUpCheck( toindex , charaindex); + if( UpLevel > 0 ){ + if( getBattleDebugMsg( ) != 0 ){ + snprintf( msgbuf, sizeof(msgbuf), + "(%s) %d", + CHAR_getUseName( toindex ), + CHAR_getInt( toindex, CHAR_LV ) ); + BATTLE_talkToCli( charaindex, msgbuf, CHAR_COLORYELLOW ); + } + } + for( j = 0; j < UpLevel; j ++ ){ + CHAR_PetLevelUp( toindex ); + CHAR_PetAddVariableAi( toindex, AI_FIX_PETLEVELUP ); + } + CHAR_complianceParameter( toindex ); + } + else{ + CHAR_talkToCli( charaindex,-1,"ʹ",CHAR_COLORWHITE); + } + /*CHAR_send_P_StatusString( charindex, CHAR_P_STRING_DUELPOINT| + CHAR_P_STRING_TRANSMIGRATION| CHAR_P_STRING_RIDEPET| + CHAR_P_STRING_BASEBASEIMAGENUMBER| CHAR_P_STRING_GOLD| + CHAR_P_STRING_EXP| CHAR_P_STRING_LV| CHAR_P_STRING_HP|CHAR_P_STRING_LEARNRIDE); + */ + } + else + CHAR_talkToCli( charaindex,-1,"ʯͷ....(޷б޷Ӿ)",CHAR_COLORWHITE); + } + CHAR_DelItemMess( charaindex, haveitemindex, 0); + CHAR_complianceParameter( toindex ); + CHAR_sendCToArroundCharacter( CHAR_getWorkInt( toindex , CHAR_WORKOBJINDEX )); + return; + } + else{ + CHAR_talkToCli( charaindex,-1,"ʹ",CHAR_COLORWHITE); + } + } +#endif + for( j = 0; j < BD_KIND_END; j ++ ){ + power[j] = 0; + recovery[j] = 0; + } + if( (p = strstr( arg, "ȫ" )) != NULL ){ + HealFlg = ( 1 << BD_KIND_HP ); + if( CHAR_getInt( toindex, CHAR_WHICHTYPE) == CHAR_TYPEPET ){ + }else{ + HealFlg |= ( 1 << BD_KIND_MP ); + } + power[BD_KIND_HP] = 10000000; + power[BD_KIND_MP] = 100; + } + kind = BD_KIND_HP; + if( (p = strstr( arg, aszKeyString[kind] )) != NULL ){ + HealFlg |= ( 1 << kind ); + if( sscanf( p+2, "%d", &work ) != 1 ){ + power[kind] = 1; + }else{ + power[kind] = RAND( (work*0.9), (work*1.1) ); + } +#ifndef _MAGIC_REHPAI + power[kind] *= GetRecoveryRate( toindex ); +#endif + } + kind = BD_KIND_MP; + if( (p = strstr( arg, aszKeyString[kind] )) != NULL + && CHAR_getInt( toindex, CHAR_WHICHTYPE) == CHAR_TYPEPLAYER){ + HealFlg |= ( 1 << kind ); + if( sscanf( p+2, "%d", &work ) != 1 ){ + power[kind] = 1; + }else{ + power[kind] = RAND( (work*0.9), (work*1.1) ); + } + } + kind = BD_KIND_AI; + if( (p = strstr( arg, aszKeyString[kind] )) != NULL + && CHAR_getInt( toindex, CHAR_WHICHTYPE) == CHAR_TYPEPET){ + HealFlg |= ( 1 << kind ); + if( sscanf( p+2, "%d", &work ) != 1 ){ + power[kind] = 1; + }else{ + power[kind] = RAND( (work*0.9), (work*1.1) ); + } + power[kind] *= 100; + } + kind = BD_KIND_CHARM; + if( (p = strstr( arg, aszKeyString[kind] )) != NULL + && CHAR_getInt( toindex, CHAR_WHICHTYPE) == CHAR_TYPEPLAYER ){ + HealFlg |= ( 1 << kind ); + if( sscanf( p+2, "%d", &work ) != 1 ){ + power[kind] = 1; + }else{ + power[kind] = RAND( (work*0.9), (work*1.1) ); + } + } + if( HealFlg == 0 )return; +#ifdef _TYPE_TOXICATION + if( CHAR_CanCureFlg( toindex, "HP") == FALSE )return; +#endif + + for( j = 0; j < BD_KIND_END; j ++ ){ + if( ( HealFlg & ( 1 << j ) ) == 0 )continue; + prevhp = CHAR_getInt( toindex, aHealInt[j] ); + workhp = prevhp + (int)power[j]; + + if( j == BD_KIND_CHARM ){ + workmax = 100; + workmin = 0; + }else + if( j == BD_KIND_AI ){ + workmax = 10000; + workmin = -10000; + }else{ + workmax = CHAR_getWorkInt( toindex, aHealMaxWork[j] ); + workmin = 1; + } + workhp = min( workhp, workmax ); + workhp = max( workhp, workmin ); + CHAR_setInt( toindex, aHealInt[j], workhp ); + recovery[j] = workhp - prevhp; + if( j == BD_KIND_AI ){ + recovery[j] *= 0.01; + } + } + CHAR_complianceParameter( toindex ); + + if( CHAR_getInt( toindex, CHAR_WHICHTYPE) == CHAR_TYPEPLAYER) { + if( charaindex != toindex ) { + CHAR_send_P_StatusString( toindex, CHAR_P_STRING_HP|CHAR_P_STRING_MP|CHAR_P_STRING_CHARM); + } + } + CHAR_send_P_StatusString( charaindex, CHAR_P_STRING_HP|CHAR_P_STRING_MP|CHAR_P_STRING_CHARM); + if( CHAR_getInt( toindex, CHAR_WHICHTYPE) == CHAR_TYPEPLAYER && + CHAR_getWorkInt( charaindex, CHAR_WORKPARTYMODE) != CHAR_PARTY_NONE ){ + CHAR_PartyUpdate( toindex, CHAR_N_STRING_HP|CHAR_N_STRING_MP ); + } + if( CHAR_getInt( toindex, CHAR_WHICHTYPE) == CHAR_TYPEPET ){ + int i; + for( i = 0; i < CHAR_MAXPETHAVE; i ++ ) { + int workindex = CHAR_getCharPet( charaindex, i ); + if( workindex == toindex ){ + CHAR_send_K_StatusString( charaindex, i, CHAR_K_STRING_HP|CHAR_K_STRING_AI); + } + } + } + + + for( j = 0; j < BD_KIND_END; j ++ ){ + if( ( HealFlg & ( 1 << j ) ) == 0 )continue; + if( charaindex != toindex) { + if( power[j] >= 0 ){ + snprintf( msgbuf, sizeof( msgbuf), + aszHealStringByOwn[j], + CHAR_getUseName( toindex ), recovery[j] ); + }else{ + snprintf( msgbuf, sizeof( msgbuf), + aszDownStringByOwn[j], + CHAR_getUseName( toindex ), -recovery[j] ); + } + CHAR_talkToCli( charaindex, -1, msgbuf, CHAR_COLORWHITE); + if( CHAR_getInt( toindex, CHAR_WHICHTYPE) == CHAR_TYPEPLAYER) { + if( power[j] >= 0 ){ + snprintf( msgbuf, sizeof( msgbuf), + aszHealStringByOther[j], + CHAR_getUseName( charaindex ), + CHAR_getUseName( toindex ), recovery[j] ); + }else{ + snprintf( msgbuf, sizeof( msgbuf), + aszDownStringByOther[j], + CHAR_getUseName( charaindex ), + CHAR_getUseName( toindex ), -recovery[j] ); + } + CHAR_talkToCli( toindex, -1, msgbuf, CHAR_COLORWHITE); + } + }else { + if( power[j] >= 0 ){ + snprintf( msgbuf, sizeof( msgbuf), + aszHealStringByOwn[j], + CHAR_getUseName( charaindex ), recovery[j] ); + }else{ + snprintf( msgbuf, sizeof( msgbuf), + aszDownStringByOwn[j], + CHAR_getUseName( charaindex ), -recovery[j] ); + } + CHAR_talkToCli( charaindex, -1, msgbuf, CHAR_COLORWHITE); + } + } + { + LogItem( + CHAR_getChar( charaindex, CHAR_NAME ), + CHAR_getChar( charaindex, CHAR_CDKEY ), +#ifdef _add_item_log_name // WON ADD itemlogitem + itemindex, +#else + ITEM_getInt( itemindex, ITEM_ID ), +#endif + "FieldUse", + CHAR_getInt( charaindex,CHAR_FLOOR), + CHAR_getInt( charaindex,CHAR_X ), + CHAR_getInt( charaindex,CHAR_Y ), + ITEM_getChar( itemindex, ITEM_UNIQUECODE), + ITEM_getChar( itemindex, ITEM_NAME), + ITEM_getInt( itemindex, ITEM_ID) + ); + } + CHAR_DelItemMess( charaindex, haveitemindex, 0); + +} + +#endif + +void ITEM_useRecovery( int charaindex, int toindex, int haveitemindex) +{ + int battlemode; + if( CHAR_CHECKINDEX( charaindex ) == FALSE )return ; + battlemode = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE ); + if( battlemode == BATTLE_CHARMODE_INIT ){ + }else + if( battlemode ){ + ITEM_useRecovery_Battle( charaindex, toindex, haveitemindex ); + }else{ + ITEM_useRecovery_Field( charaindex, toindex, haveitemindex ); + } + +} + +#ifdef _ITEM_MAGICRECOVERY +void ITEM_useMRecovery( int charaindex, int toindex, int haveitemindex) +{ + int battlemode; + if( CHAR_CHECKINDEX( charaindex ) == FALSE )return ; + battlemode = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE ); + if( battlemode == BATTLE_CHARMODE_INIT ){ + }else + if( battlemode ){ + ITEM_useMRecovery_Battle( charaindex, toindex, haveitemindex ); + }else{ +// ITEM_useRecovery_Field( charaindex, toindex, haveitemindex ); + } + +} + +#endif + +#ifdef _ITEM_USEMAGIC +void ITEM_useMagic( int charaindex, int toindex, int haveitemindex) +{ + int battlemode; + if( CHAR_CHECKINDEX( charaindex ) == FALSE )return ; + battlemode = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE ); + if( battlemode == BATTLE_CHARMODE_INIT ){ + }else + if( battlemode ){ + ITEM_useMagic_Battle( charaindex, toindex, haveitemindex ); + } +} +#endif + +#ifdef _PET_LIMITLEVEL +void ITEM_useOtherEditBase( int charaindex, int toindex, int haveitemindex) +{ + int itemindex,i; + int work[4]; + int num=-1,type; + int LevelUpPoint,petrank; + char buf1[256]; + char buf2[][32]={"ɳ",";ɳ","ٶȳɳ","ɳ",""}; + char buf3[][32]={"","Ϊ","Ϊ"}; + if( !CHAR_CHECKINDEX( charaindex ) ) return; + if( !CHAR_CHECKINDEX( toindex ) ) return; +#define RAND(x,y) ((x-1)+1+ (int)( (double)(y-(x-1))*rand()/(RAND_MAX+1.0)) ) + itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + if( !ITEM_CHECKINDEX(itemindex) ) return; + if( CHAR_getInt( toindex, CHAR_PETID) == 718 +#ifdef _PET_2LIMITLEVEL + || CHAR_getInt( toindex, CHAR_PETID) == 401 +#endif +#ifdef _PET_3TRANS + || CHAR_getInt( toindex, CHAR_PETID) == getMMPETID2() +#endif + ) { + + int maxnums=50; + + if( CHAR_getInt( toindex,CHAR_LV ) < 74 ) { + sprintf(buf1,"ҵ𣿺ร˱仯"); + CHAR_talkToCli( charaindex, toindex, buf1, CHAR_COLORWHITE); + num = ITEM_MODIFYATTACK; + LevelUpPoint = CHAR_getInt( toindex, CHAR_ALLOCPOINT ); + petrank = CHAR_getInt( toindex, CHAR_PETRANK ); + work[3] =(( LevelUpPoint >> 24 ) & 0xFF); + work[0] = (( LevelUpPoint >> 16 ) & 0xFF); + work[1] = (( LevelUpPoint >> 8 ) & 0xFF); + work[2] = (( LevelUpPoint >> 0 ) & 0xFF); + for( i=0; i<4; i++) { + type = ITEM_getInt( itemindex, (num + i)); + work[i] += type; + strcpy( buf1,"\0"); + if( work[i] > maxnums ) { + sprintf(buf1,"%s Ѿﵽˡ", buf2[i]); + work[i] = maxnums; + }else if( work[i] < 0 ) { + sprintf(buf1,"%s ѾΪˡ", buf2[i]); + work[i] = 0; + }else { + if( type > 0 ) { + if( type > 2 ) + sprintf(buf1,"%s %s %s", buf2[i], buf3[0], ""); + else + sprintf(buf1,"%s %s %s", buf2[i], buf3[1], ""); + }else if( type < 0 ){ + sprintf(buf1,"%s %s %s", buf2[i], buf3[2], ""); + } + } + if( strcmp( buf1, "\0")) { + CHAR_talkToCli( charaindex, toindex, buf1, CHAR_COLORWHITE); + } + } + + LevelUpPoint = ( work[3]<< 24) + ( work[0]<< 16) + ( work[1]<< 8) + ( work[2]<< 0); + CHAR_setInt( toindex, CHAR_ALLOCPOINT, LevelUpPoint); + CHAR_setInt( toindex, CHAR_PETRANK, petrank); + LogPetPointChange( + CHAR_getChar( charaindex, CHAR_NAME ), + CHAR_getChar( charaindex, CHAR_CDKEY ), + CHAR_getChar( charaindex, CHAR_NAME), + toindex, 4, + CHAR_getInt( toindex, CHAR_LV), + "item_use", + CHAR_getInt( charaindex, CHAR_FLOOR), + CHAR_getInt( charaindex, CHAR_X ), + CHAR_getInt( charaindex, CHAR_Y ) + ); + } + + }else { + sprintf(buf1,""); + } + CHAR_DelItem( charaindex, haveitemindex); + return; +} +#endif + +void ITEM_useStatusChange( int charaindex, int toindex, int haveitemindex) +{ + int battlemode; + if( CHAR_CHECKINDEX( charaindex ) == FALSE )return ; // + battlemode = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE ); + if( battlemode == BATTLE_CHARMODE_INIT ){ + }else + if( battlemode ){ + ITEM_useStatusChange_Battle( charaindex, toindex, haveitemindex ); + }else{ + } + +} + +void ITEM_useStatusRecovery( int charaindex, int toindex, int haveitemindex) +{ + int battlemode; + if( CHAR_CHECKINDEX( charaindex ) == FALSE )return ; // + battlemode = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE ); + if( battlemode == BATTLE_CHARMODE_INIT ){ + }else + if( battlemode ){ + ITEM_useStatusRecovery_Battle( charaindex, toindex, haveitemindex ); + }else{ + } +} + +void ITEM_useMagicDef( int charaindex, int toindex, int haveitemindex) +{ + int battlemode; + if( CHAR_CHECKINDEX( charaindex ) == FALSE )return; + battlemode = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE ); + if( battlemode == BATTLE_CHARMODE_INIT ){ + }else + if( battlemode ){ + ITEM_useMagicDef_Battle( charaindex, toindex, haveitemindex ); + }else{ + } + +} + +void ITEM_useParamChange( int charaindex, int toindex, int haveitemindex) +{ + int battlemode; + if( CHAR_CHECKINDEX( charaindex ) == FALSE )return ; + battlemode = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE ); + if( battlemode == BATTLE_CHARMODE_INIT ){ + }else + if( battlemode ){ + ITEM_useParamChange_Battle( charaindex, toindex, haveitemindex ); + } +} + +void ITEM_useFieldChange( int charaindex, int toindex, int haveitemindex) +{ + int battlemode; + if( CHAR_CHECKINDEX( charaindex ) == FALSE )return ; + battlemode = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE ); + if( battlemode == BATTLE_CHARMODE_INIT ){ + }else + if( battlemode ){ + ITEM_useFieldChange_Battle( charaindex, toindex, haveitemindex ); + } +} + +void ITEM_useAttReverse( int charaindex, int toindex, int haveitemindex) +{ + int battlemode; + if( CHAR_CHECKINDEX( charaindex ) == FALSE )return; + battlemode = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE ); + if( battlemode == BATTLE_CHARMODE_INIT ){ + }else + if( battlemode ){ + ITEM_useAttReverse_Battle( charaindex, toindex, haveitemindex ); + }else{ + } +} + +void ITEM_useMic( int charaindex, int toindex, int haveitemindex) +{ + int battlemode; + if( CHAR_CHECKINDEX( charaindex ) == FALSE )return; + battlemode = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE ); + if( battlemode == BATTLE_CHARMODE_INIT ){ + }else + if( battlemode ){ + }else{ + ITEM_useMic_Field( charaindex, toindex, haveitemindex ); + } + +} + +void ITEM_useCaptureUp( int charaindex, int toindex, int haveitemindex) +{ + int battlemode; + if( CHAR_CHECKINDEX( charaindex ) == FALSE )return ; // + + battlemode = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE ); + if( battlemode == BATTLE_CHARMODE_INIT ){ + }else + if( battlemode ){ + ITEM_useCaptureUp_Battle( charaindex, toindex, haveitemindex ); + }else{ + } + +} + +#ifdef _PETSKILL_CANNEDFOOD +static void ITEM_usePetSkillCanned_PrintWindow( int charaindex, int flg) +{ + int fd; + char message[256], buf[2048]; + if( !CHAR_CHECKINDEX( charaindex )) return; + fd = getfdFromCharaIndex( charaindex); + if( fd == - 1 ) return; + + sprintf( message, "%d", flg); + lssproto_WN_send( fd, WINDOWS_MESSAGETYPE_PETSKILLSHOW, + WINDOW_BUTTONTYPE_NONE, + ITEM_WINDOWTYPE_SELECTPETSKILL_SELECT, + -1, + makeEscapeString( message, buf, sizeof( buf))); +} + +void ITEM_usePetSkillCanned_WindowResult( int charaindex, int seqno, int select, char * data) +{ + int itemindex=-1, itemNo, petindex=-1, petNo; + int SkillNo, SkillID; + char buf1[256]; + char *skillarg=NULL; + + petNo = CHAR_getWorkInt( charaindex, CHAR_WORKRENAMEITEMNUM); + itemNo = CHAR_getWorkInt( charaindex, CHAR_WORKRENAMEITEMINDEX); + + + itemindex = CHAR_getItemIndex( charaindex, itemNo); + if( !ITEM_CHECKINDEX( itemindex) ) return; + petindex = CHAR_getCharPet( charaindex, petNo); + if( !CHAR_CHECKINDEX(petindex) ) return; + SkillNo = atoi( data); + if( SkillNo < 0 || SkillNo >= CHAR_MAXPETSKILLHAVE ) return; + + if(strcmp(ITEM_getChar( itemindex, ITEM_USEFUNC),"ITEM_useSkillCanned")){ + CHAR_talkToCli( charaindex, -1, "ֹǷѧϰ\ܣ", CHAR_COLORRED); + return; + } + + skillarg = ITEM_getChar( itemindex, ITEM_ARGUMENT); + SkillID = atoi( skillarg); + +#ifdef _PETSKILL_SHOP_LUA + if(FreePetSkillShop(charaindex, petindex, CHAR_getPetSkill(petindex, SkillNo), SkillID) == FALSE ) { + return; + } +#endif +#ifdef _CFREE_petskill + if( NPC_CHECKFREEPETSKILL( charaindex, petindex, SkillID) == FALSE ){ + CHAR_talkToCli( charaindex, -1, "ó޷ѧϰܣ", CHAR_COLORYELLOW); + return; + } +#endif + + CHAR_setPetSkill( petindex, SkillNo, SkillID); + snprintf( buf1, sizeof( buf1 ), "W%d", petNo); + CHAR_sendStatusString( charaindex, buf1 ); + CHAR_sendStatusString( charaindex, "P"); + { + int skillarray = PETSKILL_getPetskillArray( SkillID); + sprintf( buf1, "%sѧϰ%s %sʧˡ", + CHAR_getUseName( petindex), PETSKILL_getChar( skillarray, PETSKILL_NAME), + ITEM_getChar( itemindex, ITEM_NAME) ); + } + + CHAR_talkToCli( charaindex, -1, buf1, CHAR_COLORYELLOW); + CHAR_setItemIndex( charaindex, itemNo ,-1); + CHAR_sendItemDataOne( charaindex, itemNo); + ITEM_endExistItemsOne( itemindex); +} + +#endif + +static void ITEM_useRenameItem_PrintWindow( int charaindex, int page) +{ + int fd; + int pos = 0; + int i; + int btntype = WINDOW_BUTTONTYPE_CANCEL; + char message[1024]; + char msgwk[1024]; + char buf[2048]; + + if( !CHAR_CHECKINDEX( charaindex )) return; + if( page < 0 || page > 3 ) { + print( "%s:%d err\n", __FILE__, __LINE__); + return; + } + fd = getfdFromCharaIndex( charaindex); + if( fd == - 1 ) return; + + snprintf( message, sizeof( message), + "2\n ҪǸĿ\n" + " Page:%d\n", page +1); + + for( i = page *5; i < page *5 +5; i ++ ) { + int itemindex = CHAR_getItemIndex( charaindex, i); + BOOL flg = FALSE; + while( 1 ) { + char *cdkey; + if( !ITEM_CHECKINDEX( itemindex)) break; + cdkey = ITEM_getChar( itemindex, ITEM_CDKEY); + if( !cdkey) { + print( "%s:%d err\n", __FILE__, __LINE__); + break; + } + if( ITEM_getInt( itemindex, ITEM_MERGEFLG) != 1) break; + if( ITEM_getInt( itemindex, ITEM_TYPE) == ITEM_DISH) break; + if( ITEM_getInt( itemindex, ITEM_CRUSHLEVEL) != 0 ) break; + if( strlen( cdkey) != 0 ) { + if( strcmp( cdkey, CHAR_getChar( charaindex, CHAR_CDKEY)) != 0 ) { + break; + } + } + flg = TRUE; + break; + } + if( flg ) { + char *nm = ITEM_getChar( itemindex, ITEM_SECRETNAME); + char wk[256]; + if( pos +strlen( nm) +1 > sizeof( msgwk)) { + print( "buffer over error %s:%d\n", __FILE__, __LINE__); + break; + } + snprintf( wk, sizeof( wk), "%s\n", nm); + strncpy( &msgwk[pos], wk, sizeof( msgwk) -pos -1); + pos += strlen( wk); + } + else { + if( pos +2 > sizeof( msgwk)) { + print( "buffer over error %s:%d\n", __FILE__, __LINE__); + break; + } + strncpy( &msgwk[pos], "\n", sizeof( msgwk) -pos -1 ); + pos += 1; + } + } + strcat( message, msgwk); + switch( page){ + case 0: + btntype |= WINDOW_BUTTONTYPE_NEXT; + break; + case 3: + btntype |= WINDOW_BUTTONTYPE_PREV; + break; + case 1: + case 2: + btntype |= WINDOW_BUTTONTYPE_PREV|WINDOW_BUTTONTYPE_NEXT; + break; + } + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_SELECT, + btntype, + CHAR_WINDOWTYPE_SELECTRENAMEITEM_PAGE1+page, + -1, + makeEscapeString( message, buf, sizeof(buf))); +} + +void ITEM_useRenameItem( int charaindex, int toindex, int haveitemindex) +{ + + ITEM_useRenameItem_PrintWindow( charaindex, 0); + + CHAR_setWorkInt( charaindex, CHAR_WORKRENAMEITEMNUM, -1); + CHAR_setWorkInt( charaindex, CHAR_WORKRENAMEITEMINDEX, haveitemindex); +/* + char buf[256]; + int itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + if( !ITEM_CHECKINDEX( itemindex) ) return; + sprintf( buf, "%sѱȡ", ITEM_getChar( itemindex, ITEM_NAME)); + CHAR_talkToCli( charaindex, -1, "ѱȡ", CHAR_COLORRED ); + + { + LogItem( + CHAR_getChar( charaindex, CHAR_NAME ), + CHAR_getChar( charaindex, CHAR_CDKEY ), + itemindex, + "ħDEL", + CHAR_getInt( charaindex, CHAR_FLOOR), + CHAR_getInt( charaindex, CHAR_X ), + CHAR_getInt( charaindex, CHAR_Y ), + ITEM_getChar( itemindex, ITEM_UNIQUECODE), + ITEM_getChar( itemindex, ITEM_NAME), + ITEM_getInt( itemindex, ITEM_ID) + ); + } + + CHAR_setItemIndex( charaindex, haveitemindex, -1); + CHAR_sendItemDataOne( charaindex, haveitemindex); + ITEM_endExistItemsOne( itemindex ); +*/ +} + +void ITEM_useRenameItem_WindowResult( int charaindex, int seqno, int select, char * data) +{ + int page = 0; + int fd; + if( select == WINDOW_BUTTONTYPE_CANCEL) return; + + fd = getfdFromCharaIndex( charaindex); + if( fd == - 1 ) return; + if( seqno != CHAR_WINDOWTYPE_SELECTRENAMEITEM_RENAME ) { + if( select == WINDOW_BUTTONTYPE_NEXT ) page = 1; + else if( select == WINDOW_BUTTONTYPE_PREV ) page = -1; + if( select == WINDOW_BUTTONTYPE_NEXT || select == WINDOW_BUTTONTYPE_PREV ) { + int winno = seqno - CHAR_WINDOWTYPE_SELECTRENAMEITEM_PAGE1; + winno += page; + if( winno < 0 ) winno = 0; + if( winno > 3 ) winno = 3; + ITEM_useRenameItem_PrintWindow( charaindex, winno); + }else { + char message[1024]; + char buf[2048]; + char haveitemindex = CHAR_getWorkInt( charaindex, CHAR_WORKRENAMEITEMNUM); + int itemindex; + if( haveitemindex == -1 ) { + haveitemindex = (seqno - CHAR_WINDOWTYPE_SELECTRENAMEITEM_PAGE1) * 5 + + ( atoi(data)-1); + CHAR_setWorkInt( charaindex, CHAR_WORKRENAMEITEMNUM, haveitemindex); + } + itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + + snprintf( message, sizeof( message), + "%s Ҫ\n" + "\n" + "ȫ13, 26", + ITEM_getChar( itemindex, ITEM_NAME)); + + + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGEANDLINEINPUT, + WINDOW_BUTTONTYPE_OKCANCEL, + CHAR_WINDOWTYPE_SELECTRENAMEITEM_RENAME, + -1, + makeEscapeString( message, buf, sizeof(buf))); + + } + } + else { + BOOL flg = FALSE; + char message[1024]; + char buf[2048]; + while( 1 ) { + char *p; + if( strlen( data) > 26 || strlen( data) < 1) { + if( strlen( data) > 26 ) { + strcpy( message, ""); + }else { + strcpy( message, "һ"); + } + break; + } + + // WON ADD ħʸ + flg = TRUE; + + for( p = data; *p ; p ++) { + if( *p == ' '){ + strcpy( message, "ɿհ"); + flg = FALSE; + break; + } + if( strncmp( p, "",2) == 0 ) { + strcpy( message, "ɿհ"); + flg = FALSE; + break; + } + if( *p == '|'){ + strcpy( message, ""); + flg = FALSE; + break; + } + } + + break; + } + + + if( !flg ) { + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + CHAR_WINDOWTYPE_SELECTRENAMEITEM_RENAME_ATTENTION, + -1, + makeEscapeString( message, buf, sizeof(buf))); + } + else { + char haveitemindex = CHAR_getWorkInt( charaindex, CHAR_WORKRENAMEITEMNUM); + int itemindex; + int renameitemindex; + int renameitemhaveindex; + int remain; + char msgbuf[128]; + + itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + if( !ITEM_CHECKINDEX( itemindex)) { + print( "%s %d err\n", __FILE__, __LINE__); + return; + } + ITEM_setChar( itemindex, ITEM_SECRETNAME, data); + ITEM_setChar( itemindex, ITEM_CDKEY, + CHAR_getChar( charaindex, CHAR_CDKEY)); + CHAR_sendItemDataOne( charaindex, haveitemindex); + snprintf( msgbuf, sizeof(msgbuf)," %s %s ", + ITEM_getChar( itemindex, ITEM_NAME), data); + CHAR_talkToCli( charaindex, -1, msgbuf, CHAR_COLORYELLOW); + renameitemhaveindex = CHAR_getWorkInt( charaindex, CHAR_WORKRENAMEITEMINDEX); + renameitemindex = CHAR_getItemIndex( charaindex, renameitemhaveindex); + if( !ITEM_CHECKINDEX( renameitemindex)) { + print( "%s %d err\n", __FILE__, __LINE__); + return; + } + remain = atoi( ITEM_getChar( renameitemindex, ITEM_ARGUMENT)); + if( remain != 0 ) { + remain --; + if( remain <= 0 ) { + snprintf( msgbuf, sizeof(msgbuf),"%s ʧ", + ITEM_getChar( renameitemindex, ITEM_NAME)); + CHAR_talkToCli( charaindex, -1, msgbuf, CHAR_COLORYELLOW); + CHAR_setItemIndex( charaindex, renameitemhaveindex, -1); + CHAR_sendItemDataOne( charaindex, renameitemhaveindex); + ITEM_endExistItemsOne( renameitemindex ); + }else { + char buf[32]; + snprintf( buf, sizeof( buf),"%d", remain); + ITEM_setChar( renameitemindex, ITEM_ARGUMENT, buf); + } + } + } + } +} + +//------------------------------------------------------------------------- +// гǷë ѣ +// ݱݷ¼ĸة ë̫ įë £ +//------------------------------------------------------------------------- +void ITEM_dropDice( int charaindex, int itemindex) +{ + char *dicename[] = { "һ", "", "", "", "", ""}; + int diceimagenumber[] = { 24298,24299,24300,24301,24302,24303}; + int r = RAND( 0,5); + + // įë + ITEM_setInt( itemindex, ITEM_VAR1, ITEM_getInt( itemindex, ITEM_BASEIMAGENUMBER)); + // įޥ + ITEM_setInt( itemindex, ITEM_BASEIMAGENUMBER, diceimagenumber[r]); + // ޥ + ITEM_setChar( itemindex, ITEM_SECRETNAME, dicename[r]); + + // ͷʧ߼˪ƥ浤ƥݳƥ֧ئУ +} +//------------------------------------------------------------------------- +// гǷë ѣ +// ݱ įë ʣ +//------------------------------------------------------------------------- +void ITEM_pickupDice( int charaindex, int itemindex) +{ + // įë ʣ + ITEM_setInt( itemindex, ITEM_BASEIMAGENUMBER, ITEM_getInt( itemindex, ITEM_VAR1)); + // + ITEM_setChar( itemindex, ITEM_SECRETNAME, ITEM_getChar( itemindex, ITEM_NAME)); +} +enum { + ITEM_LOTTERY_1ST, // 1 + ITEM_LOTTERY_2ND, + ITEM_LOTTERY_3RD, + ITEM_LOTTERY_4TH, + ITEM_LOTTERY_5TH, // 5 + ITEM_LOTTERY_6TH, // 6 + ITEM_LOTTERY_NONE, // ½ľ + ITEM_LOTTERY_NUM, +}; +//------------------------------------------------------------------------- +// Ԫľݼѣ +// ƥٱئ¾ë裻£ +// ƱɧԻ + +#define PRE_6 (10000) +#define PRE_5 (1300 + PRE_6) +#define PRE_4 (600 + PRE_5) +#define PRE_3 (300 + PRE_4) +#define PRE_2 (8 + PRE_3) +#define PRE_1 (1 + PRE_2) + + +//#define PRE_5 (13000) +//#define PRE_4 (2300 + PRE_5) +//#define PRE_3 (540 + PRE_4) +//#define PRE_2 (8 + PRE_3) +//#define PRE_1 (1 + PRE_2) + + +//#define PRE_5 (16000) +//#define PRE_4 (2500 + PRE_5) +//#define PRE_3 (400 + PRE_4) +//#define PRE_2 (10 + PRE_3) +//#define PRE_1 (1 + PRE_2) +//#define PRE_5 (27000) +//#define PRE_4 (4000 + PRE_5) +//#define PRE_3 (400 + PRE_4) +//#define PRE_2 (10 + PRE_3) +//#define PRE_1 (1 + PRE_2) +// +//------------------------------------------------------------------------- +BOOL ITEM_initLottery(ITEM_Item* itm) +{ + int r = RAND( 0, 49999); + int hit = ITEM_LOTTERY_NONE; // + char result[7]; // + int countnum[6]; + int count; + int i; + int len; + // Ȼ¼ƥ۷ 羮Իئƽľئз + if( itm->data[ITEM_VAR3] == 1 ) return TRUE; + + // £ + if( r < PRE_6 ) hit = ITEM_LOTTERY_6TH; + else if( r < PRE_5 ) hit = ITEM_LOTTERY_5TH; + else if( r < PRE_4 ) hit = ITEM_LOTTERY_4TH; + else if( r < PRE_3 ) hit = ITEM_LOTTERY_3RD; + else if( r < PRE_2 ) hit = ITEM_LOTTERY_2ND; + else if( r < PRE_1 ) hit = ITEM_LOTTERY_1ST; + else hit = ITEM_LOTTERY_NONE; + + // ë£ + count = 0; + if( hit != ITEM_LOTTERY_NONE ) { + // Իë + result[0] = result[1] = result[2] = hit+1; + count = 3; + countnum[hit] = 3; + } + while( count < 6 ) { + int r = RAND( ITEM_LOTTERY_1ST, ITEM_LOTTERY_6TH); + if( countnum[r] >= 2 ) continue; + // 2/3м ƥְ½ľ ë֧£ + // + if( ( hit != ITEM_LOTTERY_NONE && count == 3 ) + || ( hit == ITEM_LOTTERY_NONE && count == 0 ) ) + { + if( RAND( 0,2)) { + result[count] = result[count+1] = r+1; + countnum[r] += 2; + count += 2; + continue; + } + } + countnum[r] ++; + result[count] = r+1; + count++; + } + // ë׻£ + // Իݷ2/3 ƥԻٯë Ƿ£ + // ƽƽëѵУ + len = sizeof( result)-2; + if( hit != ITEM_LOTTERY_NONE ) { + if( RAND( 0,2) ) { + // Իٯë Ƿ + char s = result[0]; + result[0] = result[5]; + result[5] = s; + len = sizeof( result)-3; + } + } + for( i = 0; i < 10; i ++) { + int x = RAND( 0, len); + int y = RAND( 0, len); + int s; + s = result[x]; + result[x] = result[y]; + result[y] = s; + } + // ׻ ٯ бƻʣ + result[sizeof(result)-1] = '\0'; + itm->data[ITEM_VAR1] = hit; + // + itm->data[ITEM_VAR2] = 0; + itm->data[ITEM_VAR3] = 1; + memcpy( itm->string[ITEM_ARGUMENT].string, result, sizeof( result)); + + return TRUE; +} +//------------------------------------------------------------------------- +// Ԫëݼѣ +// پʧ ة £ +//------------------------------------------------------------------------- +void ITEM_useLottery( int charaindex, int toindex, int haveitemindex) +{ + int i,j; + int itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + int count = ITEM_getInt( itemindex, ITEM_VAR2); + int hit = ITEM_getInt( itemindex, ITEM_VAR1); + char buff[1024]; + char num[6][3] = { {""},{""},{""},{""},{""}, {""}}; + char numbuff[128]; + char *n; + int result; + BOOL flg; + if( !ITEM_CHECKINDEX( itemindex) ) return; + if( count == 0 ) { + ITEM_setChar( itemindex, ITEM_EFFECTSTRING, ""); + } + // ÷½ľƾؤԻ ئмƥݳƥʧ ةë + else if( count == 6 ) { + CHAR_setItemIndex( charaindex , haveitemindex, -1 ); + CHAR_sendItemDataOne( charaindex, haveitemindex); + ITEM_endExistItemsOne( itemindex ); + return; + } + n = ITEM_getChar( itemindex, ITEM_ARGUMENT); + // for debug + result = (int)n[count]-1; + // Ʃ + flg = FALSE; + for( i = 0; i < count+1 && flg == FALSE; i ++ ) { + for( j = i+1; j < count+1 && flg == FALSE; j ++ ) { + if( i != j ) { + if( n[i] == n[j] ) { + flg = TRUE; + } + } + } + } + memcpy( numbuff, ITEM_getChar( itemindex, ITEM_EFFECTSTRING), (count)*2); + // ٯ ëʣ + snprintf( buff, sizeof( buff), "%s%s", numbuff, num[result]); + count ++; + ITEM_setInt( itemindex, ITEM_VAR2, count); + // ƥԻئԻʧ ة ʣ½ľئ½ľ + // ݼĸƤƥʣ + if( count >= 6 ) { + // Ի + if( hit != ITEM_LOTTERY_NONE ) { + int newitemindex; + char strbuff[1024]; + char msgbuff[1024]; + // ƻ + CHAR_setItemIndex( charaindex , haveitemindex, -1 ); + ITEM_endExistItemsOne( itemindex ); + // 2729 - 2734 Ԫ1 6 + newitemindex = ITEM_makeItemAndRegist( 2729 + hit); + CHAR_setItemIndex( charaindex , haveitemindex, newitemindex ); + // + snprintf( strbuff, sizeof( strbuff), "%s %s", buff, + ITEM_getChar( newitemindex, ITEM_EFFECTSTRING)); + ITEM_setChar( newitemindex, ITEM_EFFECTSTRING, strbuff); + CHAR_sendItemDataOne( charaindex, haveitemindex); + snprintf( msgbuff, sizeof( msgbuff), "˵%d", hit+1 ); + CHAR_talkToCli( charaindex, -1, + msgbuff, + CHAR_COLORYELLOW ); + } + // ½ľ + else { +// CHAR_setItemIndex( charaindex , haveitemindex, -1 ); + // + char strbuff[1024]; + snprintf( strbuff, sizeof( strbuff), "%s û,´", buff); + ITEM_setChar( itemindex, ITEM_EFFECTSTRING, strbuff); + CHAR_sendItemDataOne( charaindex, haveitemindex); +// ITEM_endExistItemsOne( itemindex ); +// CHAR_talkToCli( charaindex, -1, +// "ľ", +// CHAR_COLORWHITE ); + } + } + // Ԫ ݷݷë˪Իئʷ + else { + char strbuff[1024]; + if( flg) { + // ʸң + // ʧ ة 춪ݨ ٯƥ + // ʸëȻݱƻ£ + int spc = 16 + ( 6-count)*2; + char space[17]; + space[spc] = '\0'; + snprintf( strbuff, sizeof( strbuff), "%s%s", buff, space); + } + else { + strcpy( strbuff, buff); + } + ITEM_setChar( itemindex, ITEM_EFFECTSTRING, strbuff); + CHAR_sendItemDataOne( charaindex, haveitemindex); + } +} + +void ITEM_WarpDelErrorItem( int charaindex ) +{ + int j; + for(j=0; j= 12 ){ + CHAR_talkToCli(charaindex, -1, "˴޷ʹá", CHAR_COLORYELLOW); + return; + } + sprintf( buf, "%d %d %d %d", flg, Mf, Mx, My); + ITEM_setChar(itemindex, ITEM_ARGUMENT, buf); + ITEM_setInt( itemindex, ITEM_DAMAGEBREAK, usenum); + sprintf( buf, "м¼(%s,%d,%d)", MapString[i], Mx, My); + ITEM_setChar( itemindex, ITEM_EFFECTSTRING, buf); + CHAR_talkToCli(charaindex, -1, buf, CHAR_COLORYELLOW); + CHAR_sendItemDataOne( charaindex, haveitemindex); + } + + // WON ADD + if( ITEM_WarpForAny(charaindex, haveitemindex, ff, fx, fy, flg) == FALSE ) + return; +} +#endif + +// Robin 0707 petFollow +void ITEM_petFollow( int charaindex, int toindex, int haveitemindex ) +{ + char *arg; + int itemindex, followLv, haveindex, i; + //print(" PetFollow_toindex:%d ", toindex); + if( CHAR_getWorkInt( charaindex, CHAR_WORKPETFOLLOW ) != -1 ){ + if( CHAR_CHECKINDEX( CHAR_getWorkInt( charaindex, CHAR_WORKPETFOLLOW ) ) ){ + CHAR_talkToCli( charaindex, -1, "ջطųij", CHAR_COLORWHITE ); + return; + } + CHAR_setWorkInt( charaindex, CHAR_WORKPETFOLLOW, -1); + } +#ifdef _FIX_METAMORIDE + if( CHAR_CHECKJOINENEMY( charaindex) == TRUE ){ + CHAR_talkToCli( charaindex, -1, "޷ʹã", CHAR_COLORWHITE ); + return; + } +#endif + + if( CHAR_CHECKINDEX( toindex ) == FALSE ) return; + itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + if(!ITEM_CHECKINDEX(itemindex)) return; + arg = ITEM_getChar(itemindex, ITEM_ARGUMENT ); + if( arg == "\0" )return; + + if( sscanf( arg, "%d", &followLv) != 1 ) + return; + if( CHAR_getInt( toindex, CHAR_LV ) > followLv ){ + CHAR_talkToCli( charaindex, -1, "ߵĵȼ㣡", CHAR_COLORWHITE ); + return; + } + if( CHAR_getWorkInt( toindex, CHAR_WORKFIXAI ) < 80 ) + { + //CHAR_talkToCli( charaindex, -1, "ҳ϶Ȳ㣡", CHAR_COLORWHITE ); + //return; + } + + + haveindex = -1; + for( i = 0; i < 5; i++ ) + { + if( CHAR_getCharPet( charaindex, i) == toindex ) { + haveindex = i; + break; + } + } + if( haveindex == -1) return; +#ifdef _MM_NO_JIAOBEN +if(getNoMMJiaoben()==1){ + if(CHAR_getInt(toindex,CHAR_PETID)==718 || CHAR_getInt(toindex,CHAR_PETID)==401){ + if(getMmType()==0){ + CHAR_talkToCli(charaindex, -1, getMmMsg(), CHAR_COLORRED); + return; + } + time_t timep; + struct tm *p; + time(&timep); + p=localtime(&timep); + timep = mktime(p); + char *randtypetime = CHAR_getChar(charaindex,CHAR_RANDTYPE); + char tempbuff[64]; + int randtype = 0; + int randtime = 0; + int randwrong = 0; + if(strlen(randtypetime)>2){ + if(getStringFromIndexWithDelim(randtypetime,"-", 3, tempbuff, sizeof(tempbuff)) != FALSE){ + if(getStringFromIndexWithDelim(randtypetime,"-", 1, tempbuff, sizeof(tempbuff))== FALSE) + return; + randwrong = atoi(tempbuff); + if(getStringFromIndexWithDelim(randtypetime,"-", 2, tempbuff, sizeof(tempbuff))== FALSE) + return; + randtype = atoi(tempbuff); + if(getStringFromIndexWithDelim(randtypetime,"-", 3, tempbuff, sizeof(tempbuff))== FALSE) + return; + randtime = atoi(tempbuff); + if(timep - randtime < getEditBaseTime()*randwrong){ + char errbuf[256]; + sprintf(errbuf,"%dſԼ˲",getEditBaseTime()*randwrong-(timep - randtime)); + CHAR_talkToCli(charaindex, -1, errbuf, CHAR_COLORRED); + return; + } + } + } +// if(timep-CHAR_getWorkInt(charaindex,CHAR_WORKRANDEDITBASETIME)>=getEditBaseTime()) +// CHAR_setWorkInt(charaindex,CHAR_WORKRANDEDITBASETIME,timep); +// else{ +// char errbuf[256]; +// sprintf(errbuf,"%dſԼ˲",getEditBaseTime()-(timep-CHAR_getWorkInt(charaindex,CHAR_WORKRANDEDITBASETIME))); +// CHAR_talkToCli(charaindex, -1, errbuf, CHAR_COLORRED); +// return; +// } + int fd = getfdFromCharaIndex( charaindex); + char arg[255]; + char buf[128]; + char jiabuf[][5]={"","","","","","ʮ",""}; + char jianbuf[][5]={"","һ","-","","-","",""}; + char chengbuf[][5]={"","*","x","X","","",""}; + char numbuf[][5]={"","","","","","","","","",""}; + int i,j,k,l,m; + i = RAND(30,70); + j = RAND(1,29); + l = RAND(1,7); + m = RAND(1,3); + char *typebuf; +// if(randtype == 0){ +// randtype = RAND(1,10); +// if(randtype<=5){ +// randtype = RAND(1,10); +// if(randtype<=3) randtype=1; +// else randtype=2; +// }else{ +// randtype = RAND(1,10); +// if(randtype<=3) randtype=3; +// else randtype=4; +// } +// } + randtype = 4; + if(randtype==1){ + if(m==1){ + typebuf=jiabuf[l-1]; + k = i+j; + }else{ + typebuf=jianbuf[l-1]; + k = i-j; + } + char ibuf[10],jbuf[10]; + if(i<10){ + sprintf(ibuf,"%s",numbuf[i]); + }else{ + int ia,ib; + ia = i/10; + ib = i - ia*10; + sprintf(ibuf,"%s",numbuf[ia]); + strcat(ibuf,numbuf[ib]); + } + if(j<10){ + sprintf(jbuf,"%s",numbuf[j]); + }else{ + int ja,jb; + ja = j/10; + jb = j - ja*10; + sprintf(jbuf,"%s",numbuf[ja]); + strcat(jbuf,numbuf[jb]); + } + sprintf(arg,"%d|%d",haveindex,k); + CHAR_setWorkChar(charaindex, CHAR_WORKDROPMM, arg); + sprintf(buf,"ʽĽ(%s%s%s=?)",ibuf,typebuf,jbuf); + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGEANDLINEINPUT, + WINDOW_BUTTONTYPE_OK, + CHAR_WINDOWTYPE_RAND1_FLLOWMM, + -1, + buf); + }else if(randtype==2){ + if(m==1){ + typebuf=jiabuf[l-1]; + k = i+j; + }else if(m==2){ + typebuf=jianbuf[l-1]; + k = i-j; + }else{ + typebuf=chengbuf[l-1]; + k = i*j; + } + char ibuf[10],jbuf[10]; + if(i<10){ + sprintf(ibuf,"%s",numbuf[i]); + }else{ + int ia,ib; + ia = i/10; + ib = i - ia*10; + sprintf(ibuf,"%s",numbuf[ia]); + strcat(ibuf,numbuf[ib]); + } + if(j<10){ + sprintf(jbuf,"%s",numbuf[j]); + }else{ + int ja,jb; + ja = j/10; + jb = j - ja*10; + sprintf(jbuf,"%s",numbuf[ja]); + strcat(jbuf,numbuf[jb]); + } + int n; + int randnum1; + char tempret[5][32]; + randnum1 = RAND(1,5); + int randnumbuf[4]; + int tmpi=0; + while(tmpi<100){ + randnumbuf[0] = RAND(1,100); + randnumbuf[1] = RAND(1,100); + randnumbuf[2] = RAND(1,100); + randnumbuf[3] = RAND(1,100); + if(randnumbuf[0]!=randnumbuf[1]!=randnumbuf[2]!=randnumbuf[3]!=k){ + break; + } + tmpi++; + } + tmpi=0; + for(n=1;n<=5;n++){ + if(n==randnum1){ + sprintf(tempret[n-1],"%d",k); + }else if(tmpi<4){ + sprintf(tempret[n-1],"%d",randnumbuf[tmpi]); + tmpi++; + } + } + sprintf(arg,"%d|%d",haveindex,randnum1); + CHAR_setWorkChar(charaindex, CHAR_WORKDROPMM, arg); + sprintf(buf,"3\nѡʽĽ(%s%s%s=?)\n \n \nѡһ%s\nѡ%s\nѡ%s\nѡģ%s\nѡ壺%s\n",ibuf,typebuf,jbuf,tempret[0],tempret[1],tempret[2],tempret[3],tempret[4]); + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_SELECT, + WINDOW_BUTTONTYPE_OK, + CHAR_WINDOWTYPE_RAND2_FLLOWMM, + -1, + buf); + }else if(randtype==3){ + sprintf(arg,"%s",sasql_rand_buf()); + if(strcmp(arg,"err")==0) return; + char tempbuf[64]; + char randquestion[64]; + char randrightanswer[64]; + if(getStringFromIndexWithDelim(arg,"|", 1, tempbuf, sizeof(tempbuf)) == FALSE) + return; + strcpy(randquestion,tempbuf); + if(getStringFromIndexWithDelim(arg,"|", 2, tempbuf, sizeof(tempbuf)) == FALSE) + return; + strcpy(randrightanswer,tempbuf); + sprintf(arg,"%d|%s",haveindex,randrightanswer); + CHAR_setWorkChar(charaindex, CHAR_WORKDROPMM, arg); + sprintf(buf,"%s:",randquestion); + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGEANDLINEINPUT, + WINDOW_BUTTONTYPE_OK, + CHAR_WINDOWTYPE_RAND3_FLLOWMM, + -1, + buf); + }else{ +// sprintf(arg,"%s",sasql_rand_buf()); +// if(strcmp(arg,"err")==0) return; + char tempbuf[64]; + char randquestion[64]; + char randrightanswer[64]; + char randwronganswer1[64]; + char randwronganswer2[64]; + char randwronganswer3[64]; + char randwronganswer4[64]; +// if(getStringFromIndexWithDelim(arg,"|", 1, tempbuf, sizeof(tempbuf)) == FALSE) +// return; +// strcpy(randquestion,tempbuf); +// if(getStringFromIndexWithDelim(arg,"|", 2, tempbuf, sizeof(tempbuf)) == FALSE) +// return; +// strcpy(randrightanswer,tempbuf); +// if(getStringFromIndexWithDelim(arg,"|", 3, tempbuf, sizeof(tempbuf)) == FALSE) +// return; +// strcpy(randwronganswer1,tempbuf); +// if(getStringFromIndexWithDelim(arg,"|", 4, tempbuf, sizeof(tempbuf)) == FALSE) +// return; +// strcpy(randwronganswer2,tempbuf); +// if(getStringFromIndexWithDelim(arg,"|", 5, tempbuf, sizeof(tempbuf)) == FALSE) +// return; +// strcpy(randwronganswer3,tempbuf); +// if(getStringFromIndexWithDelim(arg,"|", 6, tempbuf, sizeof(tempbuf)) == FALSE) +// return; +// strcpy(randwronganswer4,tempbuf); + memset(tempbuf, 0, sizeof(tempbuf)); + memset(randquestion, 0, sizeof(randquestion)); + memset(randrightanswer, 0, sizeof(randrightanswer)); + memset(randwronganswer1, 0, sizeof(randwronganswer1)); + memset(randwronganswer2, 0, sizeof(randwronganswer2)); + memset(randwronganswer3, 0, sizeof(randwronganswer3)); + memset(randwronganswer4, 0, sizeof(randwronganswer4)); + if(RAND(1,100)<=75){ + char randtmpbuf[4][10]; + sprintf(randtmpbuf[0],"%s",hanzibuf[RAND(1,5000)-1]); + sprintf(randtmpbuf[1],"%s",hanzibuf[RAND(1,5000)-1]); + sprintf(randtmpbuf[2],"%s",hanzibuf[RAND(1,5000)-1]); + sprintf(randtmpbuf[3],"%s",hanzibuf[RAND(1,5000)-1]); + sprintf(randquestion,"%s",str_hanzi_ganrao(randtmpbuf[0],randtmpbuf[1],randtmpbuf[2],randtmpbuf[3],0,0,0,0,0,0)); + strcat(randquestion,"ҳͬ飩"); + int newrand1 = RAND(1,100)-1; + int newrand2 = RAND(1,100)-1; + int newrand3 = RAND(1,100)-1; + int newrand4 = RAND(1,100)-1; + int newrand5 = RAND(1,100)-1; + sprintf(randrightanswer,"%s",str_hanzi_ganrao(randtmpbuf[0],randtmpbuf[1],randtmpbuf[2],randtmpbuf[3],1,newrand1,newrand2,newrand3,newrand4,newrand5)); + sprintf(randwronganswer1,"%s",str_hanzi_ganrao(randtmpbuf[0],randtmpbuf[1],randtmpbuf[3],randtmpbuf[2],1,newrand1,newrand2,newrand3,newrand4,newrand5)); + sprintf(randwronganswer2,"%s",str_hanzi_ganrao(randtmpbuf[3],randtmpbuf[1],randtmpbuf[2],randtmpbuf[0],1,newrand1,newrand2,newrand3,newrand4,newrand5)); + sprintf(randwronganswer3,"%s",str_hanzi_ganrao(randtmpbuf[1],randtmpbuf[0],randtmpbuf[2],randtmpbuf[3],1,newrand1,newrand2,newrand3,newrand4,newrand5)); + sprintf(randwronganswer4,"%s",str_hanzi_ganrao(randtmpbuf[2],randtmpbuf[3],randtmpbuf[0],randtmpbuf[1],1,newrand1,newrand2,newrand3,newrand4,newrand5)); + + }else{ + int tii; + char timubuf[36][5] = {"a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","0","1","2","3","4","5","6","7","8","9"}; + for(tii=0;tii<5;tii++){ + if(tii==0) + strcpy(tempbuf,timubuf[RAND(1,36)-1]); + else{ + int timunum = 0; + while(1){ + timunum = RAND(1,36)-1; + if(strstr(tempbuf,timubuf[timunum])==NULL) + break; + } + strcat(tempbuf,timubuf[timunum]); + } + + } + sprintf(randwronganswer1,"[%c%c%c%c%c]",tempbuf[0],tempbuf[2],tempbuf[1],tempbuf[3],tempbuf[4]); + sprintf(randwronganswer2,"[%c%c%c%c%c]",tempbuf[0],tempbuf[1],tempbuf[4],tempbuf[2],tempbuf[3]); + sprintf(randwronganswer3,"[%c%c%c%c%c]",tempbuf[4],tempbuf[1],tempbuf[2],tempbuf[0],tempbuf[3]); + sprintf(randwronganswer4,"[%c%c%c%c%c]",tempbuf[1],tempbuf[0],tempbuf[2],tempbuf[3],tempbuf[4]); + sprintf(randquestion,"[%s]ҳͬӢģ",tempbuf); + sprintf(randrightanswer,"[%s]",tempbuf); + char* randstr = NULL; + randstr = str_ganrao(randquestion); + strcpy(randquestion,randstr); + randstr = str_ganraoan(randrightanswer); + strcpy(randrightanswer,randstr); + randstr = str_ganraoan(randwronganswer1); + strcpy(randwronganswer1,randstr); + randstr = str_ganraoan(randwronganswer2); + strcpy(randwronganswer2,randstr); + randstr = str_ganraoan(randwronganswer3); + strcpy(randwronganswer3,randstr); + randstr = str_ganraoan(randwronganswer4); + strcpy(randwronganswer4,randstr); + } + int n; + int randnum1; + m=1; + char tempret[5][64]; + randnum1 = RAND(1,5); + int rightnum,wrongnum1,wrongnum2,wrongnum3,wrongnum4; + rightnum = RAND(getRandMin(),getRandMax()); + wrongnum1 = RAND(getRandMin(),getRandMax()); + wrongnum2 = RAND(getRandMin(),getRandMax()); + wrongnum3 = RAND(getRandMin(),getRandMax()); + wrongnum4 = RAND(getRandMin(),getRandMax()); + //char *tempbuff2 = "ABCDE"; + int qianhounum = RAND(1,100); + for(n=1;n<=5;n++){ + if(n==randnum1){ + if(qianhounum<=30) + sprintf(tempret[n-1],"ѡ( %d %s )",rightnum,randrightanswer); + else + sprintf(tempret[n-1],"ѡ( %s %d )",randrightanswer,rightnum); + }else{ + if(m==1){ + if(qianhounum<=50) + sprintf(tempret[n-1],"ѡ( %d %s )",wrongnum1,randwronganswer1); + else + sprintf(tempret[n-1],"ѡ( %s %d )",randwronganswer1,wrongnum1); + m = 2; + }else if(m==2){ + if(qianhounum<=50) + sprintf(tempret[n-1],"ѡ( %d %s )",wrongnum2,randwronganswer2); + else + sprintf(tempret[n-1],"ѡ( %s %d )",randwronganswer2,wrongnum2); + m = 3; + }else if(m==3){ + if(qianhounum<=50) + sprintf(tempret[n-1],"ѡ( %d %s )",wrongnum3,randwronganswer3); + else + sprintf(tempret[n-1],"ѡ( %s %d )",randwronganswer3,wrongnum3); + m = 4; + }else if(m==4){ + if(qianhounum<=50) + sprintf(tempret[n-1],"ѡ( %d %s )",wrongnum4,randwronganswer4); + else + sprintf(tempret[n-1],"ѡ( %s %d )",randwronganswer4,wrongnum4); + m = 5; + } + } + } + int windowtype = 0; + int selecttype = RAND(1,100); + if(selecttype<=50){ + sprintf(arg,"%d|%d|%d",haveindex,rightnum); + windowtype = WINDOW_MESSAGETYPE_MESSAGEANDLINEINPUT; + }else{ + sprintf(arg,"%d|%d|%d",haveindex,randnum1); + windowtype = WINDOW_MESSAGETYPE_SELECT; + } + CHAR_setWorkChar(charaindex, CHAR_WORKDROPMM, arg); + sprintf(buf,"%s\n%s\n%s\n%s\n%s\n%s\nȷڵ5λֻߵѡ",randquestion,tempret[0],tempret[1],tempret[2],tempret[3],tempret[4]); + lssproto_WN_send( fd, windowtype, + WINDOW_BUTTONTYPE_OK, + CHAR_WINDOWTYPE_RAND4_FLLOWMM, + -1, + buf); + CHAR_setWorkInt(charaindex,CHAR_WORKLUANPCINT,0); + } + if(randwrong<=0){ + sprintf(tempbuff,"1-%d-%d",randtype,timep); + }else{ + sprintf(tempbuff,"%d-%d-%d",randwrong*3,randtype,timep); + } + CHAR_setChar(charaindex,CHAR_RANDTYPE,tempbuff); + return; + } +} +#endif + + + if( !PET_dropPetFollow( charaindex, haveindex, -1, -1, -1 ) ) { + CHAR_talkToCli( charaindex, -1, "ʧܣ", CHAR_COLORWHITE ); + return; + } + +} + +// Nuke start 0624: Hero's bless +void ITEM_useSkup( int charaindex, int toindex, int haveitemindex) +{ + int itemindex; + itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + if(!ITEM_CHECKINDEX(itemindex)) return; + if(CHAR_getInt(charaindex,CHAR_SUPER)==1) + { + CHAR_talkToCli(charaindex, -1, "Ʒ޷ʹøõߣ", CHAR_COLORRED); + return; + } + CHAR_setInt(charaindex,CHAR_SKILLUPPOINT, + CHAR_getInt(charaindex,CHAR_SKILLUPPOINT)+1); + CHAR_Skillupsend(charaindex); + CHAR_talkToCli(charaindex, -1, "ܵԼˡ", CHAR_COLORWHITE); + + CHAR_DelItem( charaindex, haveitemindex); +} +// Nuke end +extern void setNoenemy(); +// Nuke start 0626: Dragon's bless +void ITEM_useNoenemy( int charaindex, int toindex, int haveitemindex) +{ + int itemindex,fd; + itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + if(!ITEM_CHECKINDEX(itemindex)) return; + fd=CHAR_getWorkInt( charaindex, CHAR_WORKFD); + setNoenemy(fd); + CHAR_talkToCli(charaindex, -1, "ܱܵߵɱʧˡ", CHAR_COLORWHITE); + CHAR_DelItem( charaindex, haveitemindex); + +} +// Nuke end + +// Arminius 7.2: Ra's amulet +void ITEM_equipNoenemy( int charaindex, int itemindex ) +{ + char buf[4096]; + int evadelevel; + int fl,fd; + + if( ITEM_CHECKINDEX(itemindex) == FALSE )return; + + if( ITEM_getArgument( ITEM_getChar(itemindex,ITEM_ARGUMENT),"noen", buf, sizeof(buf) ) + == FALSE ){ + return; + } + + evadelevel=atoi(buf); + fl=CHAR_getInt(charaindex, CHAR_FLOOR); + fd=CHAR_getWorkInt( charaindex, CHAR_WORKFD); + if (evadelevel>=200) { + setEqNoenemy(fd, 200); + CHAR_talkToCli(charaindex, -1, "һĹâ١", CHAR_COLORWHITE); + return; + } else if (evadelevel>=120) { + setEqNoenemy(fd, 120); + + if ( (fl==100)||(fl==200)||(fl==300)||(fl==400)||(fl==500) ){ + CHAR_talkToCli(charaindex, -1, "һĹâ١", CHAR_COLORWHITE); + return; + } + } else if (evadelevel>=80) { + setEqNoenemy(fd, 80); + if ( (fl==100)||(fl==200)||(fl==300)||(fl==400) ){ + + CHAR_talkToCli(charaindex, -1, "һĹâ١", CHAR_COLORWHITE); + return; + } + } else if (evadelevel>=40) { + setEqNoenemy(fd, 40); + if ( (fl==100)||(fl==200) ) { + CHAR_talkToCli(charaindex, -1, "һĹâ١", CHAR_COLORWHITE); + return; + } + } + CHAR_talkToCli(charaindex, -1, "ʲҲûз", CHAR_COLORWHITE); +} + +#ifdef _Item_MoonAct +void ITEM_randEnemyEquipOne( int charaindex, int toindex, int haveitemindex) +{ + int itemindex, RandNum=0; + char buf[256]; + + itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + if( !ITEM_CHECKINDEX( itemindex)) return; + + if( ITEM_getArgument( ITEM_getChar( itemindex,ITEM_ARGUMENT), "rand", buf, sizeof(buf) ) == FALSE ){ + return; + } + + if( (RandNum=atoi( buf)) > 0 ){ + int fd = CHAR_getWorkInt( charaindex, CHAR_WORKFD); + setEqRandenemy(fd, RandNum); + CHAR_talkToCli(charaindex, -1, "ʽˡ", CHAR_COLORWHITE); + sprintf( buf, " %sʧˡ", ITEM_getChar( itemindex, ITEM_NAME) ); + CHAR_talkToCli( charaindex, -1, buf, CHAR_COLORYELLOW); + CHAR_DelItem( charaindex, haveitemindex); + return; + } + + +} + +void ITEM_randEnemyEquip( int charaindex, int itemindex) +{ + char buf[4096]; + int RandNum=0; + int fd; + + if( ITEM_CHECKINDEX(itemindex) == FALSE )return; + if( ITEM_getArgument( ITEM_getChar(itemindex,ITEM_ARGUMENT),"rand", buf, sizeof(buf) ) + == FALSE ){ + return; + } + + RandNum=atoi( buf); + fd=CHAR_getWorkInt( charaindex, CHAR_WORKFD); + if (RandNum > 0 ) { + setEqRandenemy(fd, RandNum); + CHAR_talkToCli(charaindex, -1, "ʽˡ", CHAR_COLORWHITE); + return; + } + +} +void ITEM_RerandEnemyEquip( int charaindex, int itemindex) +{ + int RandNum=0; + int fd; + + if( ITEM_CHECKINDEX(itemindex) == FALSE )return; + + fd=CHAR_getWorkInt( charaindex, CHAR_WORKFD); + RandNum = getEqRandenemy( fd); + + if (RandNum > 0 ) { + clearEqRandenemy( fd); + CHAR_talkToCli(charaindex, -1, "ʻظ", CHAR_COLORWHITE); + return; + } +} +#endif + +#ifdef _ITEM_WATERWORDSTATUS +void ITEM_WaterWordStatus( int charaindex, int toindex, int haveitemindex) +{ + int itemindex; + char itemarg[256]; + + if( !CHAR_CHECKINDEX( charaindex) ){ + return; + } + itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + if( !ITEM_CHECKINDEX( itemindex) ){ + return; + } + + if( ITEM_getArgument( ITEM_getChar( itemindex, ITEM_ARGUMENT),"time", itemarg, sizeof(itemarg) ) != FALSE ){ + char token[256]; + int nums = CHAR_getWorkInt( charaindex, CHAR_WORKSTATUSWATER); + if( nums < 0 ) nums = 0; + if( nums > 0 ){ + CHAR_talkToCli( charaindex, -1, "ˮкʱ䲻ۻ", CHAR_COLORYELLOW); + return; + } + CHAR_setWorkInt( charaindex, CHAR_WORKSTATUSWATER, nums+atoi(itemarg)); + CHAR_setItemIndex(charaindex, haveitemindex ,-1); + CHAR_sendItemDataOne( charaindex, haveitemindex); + ITEM_endExistItemsOne(itemindex); + + sprintf( token, "ˮкʱ%d֣ܼ%d֡", atoi(itemarg), + CHAR_getWorkInt( charaindex, CHAR_WORKSTATUSWATER)); + CHAR_talkToCli( charaindex, -1, token, CHAR_COLORYELLOW); + }else{ + CHAR_talkToCli(charaindex, -1, "ʲҲû", CHAR_COLORYELLOW); + } +} +#endif + +#ifdef _CHIKULA_STONE +void ITEM_ChikulaStone( int charaindex, int toindex, int haveitemindex) +{ + int itemindex,fd; + char itemarg[256]; + + if( !CHAR_CHECKINDEX( charaindex) ) return; + itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + if( !ITEM_CHECKINDEX( itemindex) ) return; + + fd = CHAR_getWorkInt( charaindex, CHAR_WORKFD); + CHAR_setWorkInt( charaindex, CHAR_WORKCHIKULAHP, 0 ); + CHAR_setWorkInt( charaindex, CHAR_WORKCHIKULAMP, 0 ); + setChiStone( fd, 0); //1hp 2mp + + if( ITEM_getArgument( ITEM_getChar( itemindex, ITEM_ARGUMENT),"hp", itemarg, sizeof(itemarg) ) != FALSE ){ + setChiStone( fd, 1); + CHAR_setWorkInt( charaindex, CHAR_WORKCHIKULAHP, atoi( itemarg) ); + }else if( ITEM_getArgument( ITEM_getChar( itemindex, ITEM_ARGUMENT),"mp", itemarg, sizeof(itemarg) ) != FALSE ){ + setChiStone( fd, 2); + CHAR_setWorkInt( charaindex, CHAR_WORKCHIKULAMP, atoi( itemarg) ); + }else{ + } + + CHAR_talkToCli(charaindex, -1, "ף", CHAR_COLORWHITE); + CHAR_setItemIndex(charaindex, haveitemindex ,-1); + CHAR_sendItemDataOne( charaindex, haveitemindex); + ITEM_endExistItemsOne(itemindex); +} +#endif + +#ifdef _ITEM_ORNAMENTS +void ITEM_PutOrnaments( int charaindex, int itemindex) +{ + char *arg=NULL; + char itemname[256]; + int bbnums=0; + if( !CHAR_CHECKINDEX( charaindex) ) return; + if( !ITEM_CHECKINDEX( itemindex) ) return; + arg = ITEM_getChar( itemindex, ITEM_ARGUMENT); + if( arg == "\0" ) return;//ITEM_BASEIMAGENUMBER + bbnums = atoi( arg); + ITEM_setInt( itemindex, ITEM_BASEIMAGENUMBER, bbnums); + ITEM_setWorkInt( itemindex, ITEM_CANPICKUP, 1); + + sprintf( itemname,"%s%s%s",CHAR_getChar( charaindex, CHAR_NAME), "", ITEM_getChar( itemindex, ITEM_SECRETNAME)); + ITEM_setChar( itemindex, ITEM_SECRETNAME, itemname); +} +#endif + +#ifdef _SUIT_ITEM + +/* +#ifdef _SUIT_TWFWENDUM + #define MAX_SUITTYPE 18 +#else + #ifdef _SUIT_ADDENDUM + #define MAX_SUITTYPE 14 + #else + #ifdef _MAGIC_RESIST_EQUIT // WON ADD ְҵװ + #define MAX_SUITTYPE 11 + #else + #define MAX_SUITTYPE 8 + #endif//_MAGIC_RESIST_EQUIT + #endif//_SUIT_ADDENDUM +#endif//_SUIT_TWFWENDUM +*/ +void ITEM_CheckSuitEquip( int charaindex) +{ + int i, j, itemindex, defCode=-1, same=0; + int nItem[CHAR_STARTITEMARRAY]; + int maxitem; + struct tagIntSuit{ + char fun[256]; + int intfun; //CHAR_getInt + }; + struct tagIntSuit ListSuit[]={ + {"VIT",CHAR_WORKSUITVIT}, + {"FSTR",CHAR_WORKSUITMODSTR}, + {"MSTR",CHAR_WORKSUITSTR}, + {"MTGH",CHAR_WORKSUITTGH}, + {"MDEX",CHAR_WORKSUITDEX}, + {"WAST",CHAR_WORKSTATUSWATER}, + {"HP", CHAR_WORKROUNDHP}, + {"MP", CHAR_WORKROUNDMP} +#ifdef _MAGIC_RESIST_EQUIT // WON ADD ְҵװ + ,{"FRES", CHAR_WORK_F_SUIT}, + {"IRES", CHAR_WORK_I_SUIT}, + {"TRES", CHAR_WORK_T_SUIT} +#endif +#ifdef _SUIT_ADDENDUM + ,{"RESIST",CHAR_WORKRESIST}, //쳣 + {"COUNTER",CHAR_WORKCOUNTER}, // + {"M_POW",CHAR_WORKMPOWER} //ǿʦħ +#endif +#ifdef _SUIT_TWFWENDUM + ,{"EARTH",CHAR_WORK_EA}, // + {"WRITER",CHAR_WORK_WR}, //ˮ + {"FIRE",CHAR_WORK_FI}, // + {"WIND",CHAR_WORK_WI} // +#endif +#ifdef _SUIT_ADDPART3 + ,{"WDUCKPOWER",CHAR_WORKDUCKPOWER},//װر + {"RENOCASE",CHAR_WORKRENOCAST}, //Ĭ + {"SUITSTRP",CHAR_WORKSUITSTR_P},// λΪ% + {"SUITTGH_P",CHAR_WORKSUITTGH_P},// λΪ% + {"SUITDEXP",CHAR_WORKSUITDEX_P}// λΪ% +#endif +#ifdef _SUIT_ADDPART4 + ,{"SUITPOISON",CHAR_SUITPOISON},//װ + {"M2_POW",CHAR_WORKMPOWER2}, //ǿʦħ,M_POWͬ(30%) + {"UN_POW_M",CHAR_WORKUNMPOWER} //ֿʦħ +#endif + }; + maxitem = sizeof(ListSuit)/sizeof(ListSuit[0]); + CHAR_setWorkInt( charaindex, CHAR_WORKSUITITEM, 0); + for( i=0; i=0; k-- ){ + if( nItem[i] == nItem[k] ) same++; + } + if( same >= 3 && nItem[i] != 0 )defCode = nItem[i]; + } + if( defCode == -1 ) return; + CHAR_setWorkInt( charaindex, CHAR_WORKSUITITEM, defCode); + for( i=0; i=200) { + CHAR_talkToCli(charaindex, -1, "Ĺâʧˡ", CHAR_COLORWHITE); + return; + } else if (el>=120) { + if ( (fl==100)||(fl==200)||(fl==300)||(fl==400)||(fl==500) ) { + CHAR_talkToCli(charaindex, -1, "Ĺâʧˡ", CHAR_COLORWHITE); + return; + } + } else if (el>=80) { + if ( (fl==100)||(fl==200)||(fl==300)||(fl==400) ) { + CHAR_talkToCli(charaindex, -1, "Ĺâʧˡ", CHAR_COLORWHITE); + return; + } + } else if (el>=40) { + if ( (fl==100)||(fl==200) ) { + CHAR_talkToCli(charaindex, -1, "Ĺâʧˡ", CHAR_COLORWHITE); + return; + } + } + CHAR_talkToCli(charaindex, -1, "ʲҲûз", CHAR_COLORWHITE); +} + +extern void setStayEncount(int fd); +void ITEM_useEncounter( int charaindex, int toindex, int haveitemindex) +{ + int itemindex,fd; + itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + if(!ITEM_CHECKINDEX(itemindex)) return; + + fd=CHAR_getWorkInt( charaindex, CHAR_WORKFD); + setStayEncount(fd); +#ifdef _USER_CHARLOOPS + { + Char *ch; + ch = CHAR_getCharPointer( charaindex); + if( ch == NULL ) return; + strcpysafe( ch->charfunctable[CHAR_LOOPFUNCTEMP1].string, + sizeof( ch->charfunctable[CHAR_LOOPFUNCTEMP1]), "CHAR_BattleStayLoop");//ս + CHAR_setInt( charaindex, CHAR_LOOPINTERVAL, 2500); + CHAR_constructFunctable( charaindex); + } +#endif + CHAR_talkToCli(charaindex, -1, "ܱܵͻȻɱ", CHAR_COLORYELLOW); + CHAR_DelItem( charaindex, haveitemindex); + +} + +#ifdef _Item_DeathAct +void ITEM_UseDeathCounter( int charaindex, int toindex, int haveitemindex) +{ + int itemindex,fd; + int itemmaxuse=-1; + char buf1[256]; + char *itemarg; + char itemnumstr[32]; + int okfloor = 0; + BOOL Useflag=FALSE; + int i = 1; + + itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + if(!ITEM_CHECKINDEX(itemindex)) return; + +#ifdef _ITEM_STONE + itemarg = ITEM_getChar(itemindex,ITEM_ARGUMENT); + while(1){ + if( getStringFromIndexWithDelim( itemarg, "|", i , itemnumstr, sizeof( itemnumstr)) == FALSE ) + break; + okfloor = atoi(itemnumstr); + if( CHAR_getInt( charaindex, CHAR_FLOOR ) == okfloor ){ + Useflag = TRUE; + break; + } + i++; + } + if(okfloor != 0){ // ֵʯͷ + itemmaxuse = ITEM_getInt( itemindex, ITEM_DAMAGEBREAK); + if( itemmaxuse != -1 ) { + itemmaxuse--; + ITEM_setInt( itemindex, ITEM_DAMAGEBREAK, itemmaxuse); + if( itemmaxuse < 1 ) { + sprintf( buf1, "%sʧˡ", ITEM_getChar( itemindex, ITEM_NAME) ); + CHAR_talkToCli(charaindex, -1, buf1, CHAR_COLORYELLOW); + CHAR_DelItem( charaindex, haveitemindex); + if(Useflag==FALSE) { + CHAR_talkToCli(charaindex, -1, "ûзκ飡", CHAR_COLORYELLOW); + return; + } + }else{ + sprintf( buf1, "ԭУʹôʣ%dΡ", itemmaxuse); + ITEM_setChar( itemindex, ITEM_EFFECTSTRING, buf1); + CHAR_sendItemDataOne( charaindex, haveitemindex); + if(Useflag==FALSE) { + CHAR_talkToCli(charaindex, -1, "ûзκ飡", CHAR_COLORYELLOW); + return; + } + } + fd = CHAR_getWorkInt( charaindex, CHAR_WORKFD); + setStayEncount(fd); + CHAR_talkToCli(charaindex, -1, "Ϣ", CHAR_COLORYELLOW); + }else{ + sprintf( buf1, "%sʧˡ", ITEM_getChar( itemindex, ITEM_NAME) ); + CHAR_talkToCli(charaindex, -1, buf1, CHAR_COLORYELLOW); + CHAR_DelItem( charaindex, haveitemindex); + if(Useflag==FALSE) { + CHAR_talkToCli(charaindex, -1, "ûзκ飡", CHAR_COLORYELLOW); + return; + } + fd = CHAR_getWorkInt( charaindex, CHAR_WORKFD); + setStayEncount(fd); + CHAR_talkToCli(charaindex, -1, "Ϣ", CHAR_COLORYELLOW); + } + }else{ //ħʯ +#endif +#ifdef _ITEM_MAXUSERNUM + itemmaxuse = ITEM_getInt( itemindex, ITEM_DAMAGEBREAK); + if( itemmaxuse != -1 ) { + itemmaxuse--; + ITEM_setInt( itemindex, ITEM_DAMAGEBREAK, itemmaxuse); + if( itemmaxuse < 1 ) { + sprintf( buf1, " %sʧˡ", ITEM_getChar( itemindex, ITEM_NAME) ); + CHAR_talkToCli(charaindex, -1, buf1, CHAR_COLORYELLOW); + CHAR_DelItem( charaindex, haveitemindex); + }else{ + sprintf( buf1, "ԭУʹôʣ%dΡ", itemmaxuse); + ITEM_setChar( itemindex, ITEM_EFFECTSTRING, buf1); + CHAR_sendItemDataOne( charaindex, haveitemindex); + } + fd = CHAR_getWorkInt( charaindex, CHAR_WORKFD); + setStayEncount(fd); + CHAR_talkToCli(charaindex, -1, "ܱܵͻȻɱ", CHAR_COLORYELLOW); + }else{ + CHAR_DelItem( charaindex, haveitemindex); + return; + } +#else + fd = CHAR_getWorkInt( charaindex, CHAR_WORKFD); + setStayEncount(fd); + sprintf( buf1, " %sʧˡ", ITEM_getChar( itemindex, ITEM_NAME) ); + CHAR_talkToCli(charaindex, -1, buf1, CHAR_COLORYELLOW); + CHAR_DelItem( charaindex, haveitemindex); +#endif +#ifdef _ITEM_STONE + } +#endif +#ifdef _USER_CHARLOOPS + { + Char *ch; + ch = CHAR_getCharPointer( charaindex); + if( ch == NULL ) return; + strcpysafe( ch->charfunctable[CHAR_LOOPFUNCTEMP1].string, + sizeof( ch->charfunctable[CHAR_LOOPFUNCTEMP1]), "CHAR_BattleStayLoop");//ս + CHAR_setInt( charaindex, CHAR_LOOPINTERVAL, 2500); + CHAR_constructFunctable( charaindex); + } +#endif +} +#endif + +#ifdef _CHRISTMAS_REDSOCKS +void ITEM_useMaxRedSocks( int charaindex, int toindex, int haveitemindex) +{ + int itemtimes = -1, itemindex; + char *itemarg=NULL; + int present[13]={ 13061, 13062, 13063, 13064, 13088, 13089, 13090, 13091, //1. + 14756, 17256, + 13092,19692,20594}; + int nowtimes = time( NULL); + + itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + if(!ITEM_CHECKINDEX(itemindex)) return; + + itemarg = ITEM_getChar( itemindex, ITEM_ARGUMENT); + if( itemarg == "\0" ) { + CHAR_talkToCli(charaindex, -1, "Ч!", CHAR_COLORYELLOW); + return; + } + itemtimes = atoi( itemarg); + if( nowtimes >= itemtimes && nowtimes <= itemtimes+(60*60*24) ){ //ʱڿɻ + int si=0, ret; + char token[256]; + //ɾ + CHAR_setItemIndex(charaindex, haveitemindex ,-1); + CHAR_sendItemDataOne( charaindex, haveitemindex); + ITEM_endExistItemsOne(itemindex); + itemindex = -1; + // + si = rand()%100; + if( si > 70 ){ + si = rand()%3+10; + }else if( si > 60 ){ + si = rand()%2+8; + }else { + si = rand()%8; + } + itemindex = ITEM_makeItemAndRegist( present[ si]); + if( !ITEM_CHECKINDEX( itemindex)){ + CHAR_talkToCli(charaindex, -1, "Ч!", CHAR_COLORYELLOW); + return; + } + ret = CHAR_addItemSpecificItemIndex( charaindex, itemindex); + if( ret < 0 || ret >= CHAR_MAXITEMHAVE ) { + ITEM_endExistItemsOne( itemindex); + CHAR_talkToCli(charaindex, -1, "÷λ!", CHAR_COLORYELLOW); + return; + } + sprintf( token,"õ%s",ITEM_getChar( itemindex, ITEM_NAME)); + CHAR_talkToCli( charaindex, -1, token, CHAR_COLORYELLOW ); + CHAR_sendItemDataOne( charaindex, ret); + }else{ + char token[256]; + if( nowtimes < itemtimes ){ + int days, hours, minute, second; + int defTimes = itemtimes - nowtimes; + + days = defTimes/(24*60*60); + defTimes = defTimes-( days*(24*60*60)); + hours = defTimes/(60*60); + defTimes = defTimes-( hours*(60*60)); + minute = defTimes/60; + defTimes = defTimes-( minute*60); + second = defTimes; + sprintf( token,"%s%d%dСʱ%d%dſʹ!", + ITEM_getChar( itemindex, ITEM_NAME), days, hours, minute, second); + CHAR_talkToCli( charaindex, -1, token, CHAR_COLORYELLOW ); + }else if( nowtimes > itemtimes+(60*60*24) ){ + sprintf( token,"%sʹѹ!", ITEM_getChar( itemindex, ITEM_NAME)); + CHAR_talkToCli( charaindex, -1, token, CHAR_COLORYELLOW ); + } + } +} +#endif + +#ifdef _CHRISTMAS_REDSOCKS_NEW +void ITEM_useMaxRedSocksNew( int charaindex, int toindex, int haveitemindex) +{ + int itemindex; + char *itemarg=NULL; + char itemnumstr[32]; + int itemnum=0; + int present[20]; + int si=0, ret,i; + char token[256]; + + itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + if(!ITEM_CHECKINDEX(itemindex)) return; + + itemarg = ITEM_getChar( itemindex, ITEM_ARGUMENT); + if( itemarg == "\0" ){ + CHAR_talkToCli(charaindex, -1, "Ǹʥ!", CHAR_COLORYELLOW); + return; + } + + // + if( getStringFromIndexWithDelim( itemarg, "|", 1, itemnumstr, sizeof( itemnumstr)) == FALSE ) + return; + itemnum = atoi(itemnumstr); + if( itemnum > 20 ) + itemnum = 20; + for(i=0;i= CHAR_MAXITEMHAVE ) { + ITEM_endExistItemsOne( itemindex); + CHAR_talkToCli(charaindex, -1, "÷λ!", CHAR_COLORYELLOW); + return; + } + sprintf( token,"õ%s",ITEM_getChar( itemindex, ITEM_NAME)); + CHAR_talkToCli( charaindex, -1, token, CHAR_COLORYELLOW ); + CHAR_sendItemDataOne( charaindex, ret); + +} +#endif + +#ifdef _PETSKILL_CANNEDFOOD +void ITEM_useSkillCanned( int charaindex, int toindex, int itemNo) +{ + int itemindex; + char buf1[256]; + itemindex = CHAR_getItemIndex( charaindex, itemNo); + if(!ITEM_CHECKINDEX( itemindex)) return; + if( !CHAR_CHECKINDEX( toindex) ) return; + if( CHAR_getInt( toindex, CHAR_WHICHTYPE) == CHAR_TYPEPET) { + int i, petNo=-1; + for( i=0; i -1 ){// + CHAR_talkToCli( charaindex, -1, "޷вܱ", CHAR_COLORYELLOW ); + return; + } +#endif + + +#ifdef _FIXBUG_ATTACKBOW + { + int armindex = CHAR_getItemIndex( charaindex, CHAR_ARM); + if( ITEM_CHECKINDEX( armindex) == TRUE ) { + int armtype = BATTLE_GetWepon( charaindex); + if( armtype == ITEM_BOW || armtype == ITEM_BOUNDTHROW || + armtype == ITEM_BREAKTHROW || armtype == ITEM_BOOMERANG) { + CHAR_talkToCli( charaindex, -1, "ʹԶ޷", CHAR_COLORYELLOW ); + return; + } + } + } +#endif + + battlemode = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE ); + // ݷ + if( battlemode == BATTLE_CHARMODE_INIT ){ + return; + } + // + if( IsBATTLING( charaindex ) == TRUE ){ + toindex = BATTLE_No2Index(CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEINDEX ), toindex ); + + } + + if( CHAR_CHECKINDEX( toindex ) == FALSE ) return; + + haveindex = -1; + for( i = 0; i < 5; i++ ){ + if( CHAR_getCharPet( charaindex, i) == toindex ) { + haveindex = i; + break; + } + } + if( haveindex == -1 && charaindex != toindex ){ + CHAR_talkToCli( charaindex, -1, "޷ֻܱԼij", CHAR_COLORYELLOW ); + return; + } + + itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + if(!ITEM_CHECKINDEX(itemindex)) return; + + arg = ITEM_getChar(itemindex, ITEM_ARGUMENT ); + if( arg == "\0" )return; + if( sscanf( arg, "%d", &metamoTime) != 1 ) + return; + + + if( toindex != charaindex ){ + CHAR_setWorkInt( charaindex, CHAR_WORKITEMMETAMO, NowTime.tv_sec +metamoTime); + sprintf( msg, "%s", CHAR_getChar( toindex, CHAR_NAME) ); + } + else { + CHAR_setWorkInt( charaindex, CHAR_WORKITEMMETAMO, 0); + sprintf( msg, "Լ"); + } + CHAR_talkToCli( charaindex, -1, msg, CHAR_COLORYELLOW ); + + CHAR_setInt( charaindex, CHAR_BASEIMAGENUMBER, CHAR_getInt( toindex, CHAR_BASEBASEIMAGENUMBER) ); + CHAR_complianceParameter( charaindex); + CHAR_sendCToArroundCharacter( CHAR_getWorkInt( charaindex , CHAR_WORKOBJINDEX )); + CHAR_send_P_StatusString( charaindex , CHAR_P_STRING_BASEBASEIMAGENUMBER); + + CHAR_DelItem( charaindex, haveitemindex); + +} +#endif +#ifdef _ITEM_CRACKER +void ITEM_Cracker(int charaindex,int toindex,int haveitemindex) +{ + int battlemode; + // ǷЧ + if(CHAR_CHECKINDEX(charaindex) == FALSE) return; //ʧ + battlemode = CHAR_getWorkInt(charaindex,CHAR_WORKBATTLEMODE); + // սʹЧ + if(!battlemode) ITEM_useCracker_Effect(charaindex,toindex,haveitemindex); + else CHAR_talkToCli(charaindex,-1,"ʲҲû",CHAR_COLORWHITE); +} +#endif + +void ITEM_AddPRSkillPercent( int charaindex,int toindex,int haveitemindex) +{ +#ifdef _PROFESSION_SKILL // WON ADD ְҵ + int level; + char token[64]; + int MySKPercent=0, itemindex=-1, i; + + if( !CHAR_CHECKINDEX( charaindex) ) return; + if( CHAR_getInt( charaindex, PROFESSION_CLASS ) == 0 ) return; + + itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + if( !ITEM_CHECKINDEX( itemindex) )return; + level=atoi(ITEM_getChar(itemindex,ITEM_ARGUMENT)); + + for( i=0; i 10000 ) MySKPercent = 10000; + CHAR_setIntPSkill( charaindex, i, SKILL_LEVEL, MySKPercent); + } + + CHAR_setItemIndex( charaindex, haveitemindex ,-1); + CHAR_sendItemDataOne( charaindex, haveitemindex); + ITEM_endExistItemsOne( itemindex ); + CHAR_sendStatusString( charaindex , "S"); + CHAR_sendCToArroundCharacter( CHAR_getWorkInt( charaindex , CHAR_WORKOBJINDEX )); + sprintf( token, "ְҵ%d", level); + CHAR_talkToCli( charaindex, -1, token, CHAR_COLORYELLOW); +#endif +} + +void ITEM_AddPRSkillPoint( int charaindex,int toindex,int haveitemindex) +{ +#ifdef _PROFESSION_SKILL // WON ADD ְҵ + int point; + char token[64]; + int MyPRpoint=0, itemindex=-1; + if( !CHAR_CHECKINDEX( charaindex) ) return; + if( CHAR_getInt( charaindex, PROFESSION_CLASS ) == 0 ) return; + + itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + if( !ITEM_CHECKINDEX( itemindex) )return; + point=atoi(ITEM_getChar(itemindex,ITEM_ARGUMENT)); + + MyPRpoint = CHAR_getInt( charaindex, PROFESSION_SKILL_POINT); + CHAR_setInt( charaindex, PROFESSION_SKILL_POINT, MyPRpoint+point ); + + + CHAR_setItemIndex( charaindex, haveitemindex ,-1); + CHAR_sendItemDataOne( charaindex, haveitemindex); + ITEM_endExistItemsOne( itemindex ); + + CHAR_sendCToArroundCharacter( CHAR_getWorkInt( charaindex , CHAR_WORKOBJINDEX )); + + CHAR_talkToCli( charaindex, -1, "һְҵܵ", CHAR_COLORYELLOW); + sprintf( token, "%dְҵܵ", point); + CHAR_talkToCli( charaindex, -1, token, CHAR_COLORYELLOW); +#endif +} + +#ifdef _ITEM_ADDEXP //vincent +void ITEM_Addexp(int charaindex,int toindex,int haveitemindex) +{ + // ǷЧ + if(CHAR_CHECKINDEX(charaindex) == FALSE) return; //ʧ +#if 1 + ITEM_useAddexp_Effect(charaindex,toindex,haveitemindex); +#else + if( !CHAR_getInt(charaindex,CHAR_ADDEXPPOWER)){ + ITEM_useAddexp_Effect(charaindex,toindex,haveitemindex); + }else{ + CHAR_talkToCli(charaindex,-1,"ǰʹ֮ҩЧȻ",CHAR_COLORYELLOW); + } +#endif +} +#endif + +#ifdef _ITEM_REFRESH //vincent 쳣״̬ +void ITEM_Refresh(int charaindex,int toindex,int haveitemindex) +{ + int battlemode,itemindex; +print("\nvincent--ITEM_Refresh"); + // ǷЧ + if(CHAR_CHECKINDEX(charaindex) == FALSE) + { +print("\nvincent--(charaindex) == FALSE"); + return; //ʧ + } + itemindex = CHAR_getItemIndex(charaindex,haveitemindex); + + battlemode = CHAR_getWorkInt(charaindex,CHAR_WORKBATTLEMODE); + if(battlemode) + { +print("\nvincent--enter ITEM_useAddexp_Effect"); +print("\nvincent-->charaindex:%d,toindex:%d",charaindex,toindex); + ITEM_useRefresh_Effect(charaindex,toindex,haveitemindex); + } + else CHAR_talkToCli(charaindex,-1,"ʲҲû",CHAR_COLORWHITE); + + /* ƽҷ ջ */ + CHAR_setItemIndex(charaindex, haveitemindex ,-1); + CHAR_sendItemDataOne( charaindex, haveitemindex);/* ʧ ةޥ */ + /* */ + ITEM_endExistItemsOne( itemindex ); +} +#endif +//Terry 2001/12/21 +#ifdef _ITEM_FIRECRACKER +void ITEM_firecracker(int charaindex,int toindex,int haveitemindex) +{ + int battlemode; + + // ǷЧ + if(CHAR_CHECKINDEX(charaindex) == FALSE) return; //ʧ + + battlemode = CHAR_getWorkInt(charaindex,CHAR_WORKBATTLEMODE); + + if( battlemode // Ƿս +#ifdef _PETSKILL_BECOMEPIG + && CHAR_getInt( charaindex, CHAR_BECOMEPIG) == -1 +#endif + ) + ITEM_useFirecracker_Battle(charaindex,toindex,haveitemindex); + else + CHAR_talkToCli(charaindex,-1,"ʲҲû",CHAR_COLORWHITE); +} +#endif +//Terry end + + +void ITEM_WearEquip( int charaindex, int itemindex) +{ + // WON ADD +// if( ITEM_getInt(itemindex,ITEM_ID) == 20130 ){ + CHAR_setWorkInt( charaindex, CHAR_PickAllPet, TRUE); +/// } + return; +} +void ITEM_ReWearEquip( int charaindex, int itemindex) +{ + CHAR_setWorkInt( charaindex, CHAR_PickAllPet, FALSE); + return; +} + + +#ifdef _Item_ReLifeAct +void ITEM_DIErelife( int charaindex, int itemindex, int eqw) +{ + int ReceveEffect=-1; + int toNo; + int battleindex=-1; + int attackNo=-1; + int WORK_HP=1; + char buf[256]; + battleindex = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEINDEX ); + if( BATTLE_CHECKINDEX( battleindex ) == FALSE ) { + print("\n battleindex =%d return", battleindex); + return; + } + if( CHAR_CHECKINDEX( charaindex) == FALSE ) + return; + if( ITEM_CHECKINDEX( itemindex) == FALSE ) + return; +#ifdef _DUMMYDIE + if( CHAR_getFlg( charaindex, CHAR_ISDUMMYDIE) == FALSE ) { +#else + if( CHAR_getFlg( charaindex, CHAR_ISDIE) == FALSE ) { +#endif + print("\n [ %d, CHAR_ISDIE DUMMY FALSE] return !", charaindex); + return; + } + + if( ITEM_getArgument( ITEM_getChar(itemindex,ITEM_ARGUMENT),"HP", buf, sizeof(buf) ) + == FALSE ){ + WORK_HP = 1; + }else { + if( !strcmp( buf, "FULL") ) { + WORK_HP = CHAR_getWorkInt( charaindex, CHAR_WORKMAXHP ); + }else { + WORK_HP=atoi( buf); + } + } + + ReceveEffect = SPR_fukkatu3; + toNo = BATTLE_Index2No( battleindex, charaindex ); + attackNo = -1; + + BATTLE_MultiReLife( battleindex, attackNo, toNo, WORK_HP, ReceveEffect ); + CHAR_setItemIndex( charaindex, eqw ,-1); + ITEM_endExistItemsOne( itemindex); + CHAR_sendItemDataOne( charaindex, eqw); + return; +} +#endif + +#ifdef _EQUIT_DEFMAGIC +void ITEM_MagicEquitWear( int charaindex, int itemindex) +{ + char buf[256]; + char *itemarg; + char Free[][128]={"EA","WA","FI","WI","QU"}; + int index=0; + int dMagic=0; + itemarg = ITEM_getChar(itemindex,ITEM_ARGUMENT); + if( itemarg == "\0" ) return; + while( index < arraysizeof( Free) ) { + if( ITEM_getArgument( itemarg, Free[ index], buf, sizeof(buf)) == TRUE ) { + dMagic = atoi( buf); + if( dMagic <= 100 && dMagic >= -100 ) { + int def_magic = CHAR_getWorkInt( charaindex, CHAR_EQUITDEFMAGIC_E+index); + CHAR_setWorkInt( charaindex, CHAR_EQUITDEFMAGIC_E+index, def_magic + dMagic); + } + dMagic = 0; + } + index++; + if( (CHAR_EQUITDEFMAGIC_E+index) > CHAR_EQUITQUIMAGIC ) + break; + } + + return; +} + +void ITEM_MagicEquitReWear( int charaindex, int itemindex){ + char buf[256]; + char *itemarg; + char Free[][128]={"EA","WA","FI","WI","QU"}; + int index=0; + int dMagic=0; + + itemarg = ITEM_getChar(itemindex,ITEM_ARGUMENT); + if( itemarg == "\0" ) return; + while( index < arraysizeof( Free) ) { + if( ITEM_getArgument( itemarg, Free[ index], buf, sizeof(buf)) == TRUE ) { + dMagic = atoi( buf); + if( dMagic <= 100 && dMagic >= -100 ) { + int def_magic = CHAR_getWorkInt( charaindex, CHAR_EQUITDEFMAGIC_E+index); + CHAR_setWorkInt( charaindex, CHAR_EQUITDEFMAGIC_E+index, def_magic - dMagic); + } + dMagic = 0; + } + index++; + if( (CHAR_EQUITDEFMAGIC_E+index) > CHAR_EQUITQUIMAGIC ) + break; + } + + return; +} +#endif + +#ifdef _EQUIT_RESIST +void ITEM_MagicResist( int charaindex, int itemindex) +{ + char *itemarg,*p=NULL; + itemarg = ITEM_getChar(itemindex,ITEM_ARGUMENT); + if( itemarg == "\0" ) return; + if( strstr( itemarg, "" ) ){ + p = itemarg; + CHAR_setWorkInt( charaindex, CHAR_WORKEQUITFIRE, atoi( p+4 ) ); + } + else if( strstr( itemarg, "" ) ){ + p = itemarg; + CHAR_setWorkInt( charaindex, CHAR_WORKEQUITTHUNDER, atoi( p+4 ) ); + } + else if( strstr( itemarg, "" ) ){ + p = itemarg; + CHAR_setWorkInt( charaindex, CHAR_WORKEQUITICE, atoi( p+4 ) ); + } + else if( strstr( itemarg, "" ) ){ + p = itemarg; + CHAR_setWorkInt( charaindex, CHAR_WORKEQUITWEAKEN, atoi( p+4 ) ); + } + else if( strstr( itemarg, "ħ" ) ){ + p = itemarg; + CHAR_setWorkInt( charaindex, CHAR_WORKEQUITBARRIER, atoi( p+4 ) ); + } + else if( strstr( itemarg, "Ĭ" ) ){ + p = itemarg; + CHAR_setWorkInt( charaindex, CHAR_WORKEQUITNOCAST, atoi( p+4 ) ); + } + else if( strstr( itemarg, "" ) ){ + p = itemarg; + CHAR_setWorkInt( charaindex, CHAR_WORKEQUITFALLRIDE, atoi( p+4 ) ); + } + +} + +void ITEM_MagicReResist( int charaindex, int itemindex) +{ + char *itemarg,*p=NULL; + itemarg = ITEM_getChar(itemindex,ITEM_ARGUMENT); + if( itemarg == "\0" ) return; + if( strstr( itemarg, "" ) ){ + p = itemarg; + CHAR_setWorkInt( charaindex, CHAR_WORKEQUITFIRE, 0 ); + } + else if( strstr( itemarg, "" ) ){ + p = itemarg; + CHAR_setWorkInt( charaindex, CHAR_WORKEQUITFIRE, 0 ); + } + else if( strstr( itemarg, "" ) ){ + p = itemarg; + CHAR_setWorkInt( charaindex, CHAR_WORKEQUITFIRE, 0 ); + } + else if( strstr( itemarg, "" ) ){ + p = itemarg; + CHAR_setWorkInt( charaindex, CHAR_WORKEQUITFIRE, 0 ); + } + else if( strstr( itemarg, "ħ" ) ){ + p = itemarg; + CHAR_setWorkInt( charaindex, CHAR_WORKEQUITFIRE, 0 ); + } + else if( strstr( itemarg, "Ĭ" ) ){ + p = itemarg; + CHAR_setWorkInt( charaindex, CHAR_WORKEQUITFIRE, 0 ); + } + else if( strstr( itemarg, "" ) ){ + p = itemarg; + CHAR_setWorkInt( charaindex, CHAR_WORKEQUITFIRE, 0 ); + } +} +#endif + +#ifdef _MAGIC_RESIST_EQUIT // WON ADD ְҵװ +void ITEM_P_MagicEquitWear( int charaindex, int itemindex ) +{ + char buf[256] = {0}; + char *itemarg; + char Free[][128]={"FR","IR","TR"}; + int dMagic=0; + int i; + + itemarg = ITEM_getChar(itemindex,ITEM_ARGUMENT); + if( itemarg == "\0" ) return; + +// print("\n won test 10.0 ==> itemarg(%s)", itemarg ); + + for( i=0; i<3; i++ ){ + if( ITEM_getArgument( itemarg, Free[ i ], buf, sizeof(buf)) == TRUE ) { + dMagic = atoi( buf); +// print("\n won test 10.1 ==> i(%d) dMagic(%d)", i, dMagic ); + + if( dMagic <= 100 && dMagic >= -100 ){ + int def_magic = CHAR_getWorkInt( charaindex, CHAR_WORK_F_SUIT+i ); + CHAR_setWorkInt( charaindex, CHAR_WORK_F_SUIT+i, def_magic + dMagic); + +// print("\n won test 10.2 ==> i(%d)(%d)", i, CHAR_getWorkInt( charaindex, CHAR_WORK_F_SUIT+i ) ); + } + dMagic = 0; + } + } + + return; +} + + +void ITEM_P_MagicEquitReWear( int charaindex, int itemindex ) +{ + char buf[256] = {0}; + char *itemarg; + char Free[][128]={"FR","IR","TR"}; + int dMagic=0; + int i; + + itemarg = ITEM_getChar(itemindex,ITEM_ARGUMENT); + if( itemarg == "\0" ) return; + +// print("\n won test 10.0 ==> itemarg(%s)", itemarg ); + + for( i=0; i<3; i++ ){ + if( ITEM_getArgument( itemarg, Free[ i ], buf, sizeof(buf)) == TRUE ) { + dMagic = atoi( buf); +// print("\n won test 10.1 ==> i(%d) dMagic(%d)", i, dMagic ); + + if( dMagic <= 100 && dMagic >= -100 ){ + int def_magic = CHAR_getWorkInt( charaindex, CHAR_WORK_F_SUIT+i ); + CHAR_setWorkInt( charaindex, CHAR_WORK_F_SUIT+i, def_magic - dMagic); + +// print("\n won test 10.2 ==> i(%d)(%d)", i, CHAR_getWorkInt( charaindex, CHAR_WORK_F_SUIT+i ) ); + } + dMagic = 0; + } + } + + return; + +} +#endif + + + +#ifdef _ITEM_WARP_FIX_BI +void recoverbi(int index) +{ + int eBbi=-1, eArm=-1, eNum=-1, eBi=-1, bi=-1; + + bi = CHAR_getInt( index, CHAR_BASEIMAGENUMBER); + eBbi = CHAR_getInt( index, CHAR_BASEBASEIMAGENUMBER); + eArm = CHAR_getItemIndex( index, CHAR_ARM); + eNum = ITEM_FIST; + if(ITEM_CHECKINDEX(eArm)) + eNum = ITEM_getInt( eArm, ITEM_TYPE); + + eBi = CHAR_getNewImagenumberFromEquip( eBbi, eNum); + + if(CHAR_getInt( index, CHAR_RIDEPET)!=-1) // + CHAR_complianceParameter(index); + else // + if((eBi!=-1)&&(eBi!=bi)) + CHAR_setInt( index, CHAR_BASEIMAGENUMBER, eBi); +} +#endif + +#ifdef _ITEM_TIME_LIMIT +void ITEM_TimeLimit( int charaindex) +{ + int i = 0; + int iid = 0; + long lTime = 0; + char buff[256]; + + if( !CHAR_CHECKINDEX( charaindex) ) return; + for( i=0; i < CHAR_MAXITEMHAVE ; i++ ){ + int itemindex = CHAR_getItemIndex( charaindex , i ); + if( !ITEM_CHECKINDEX( itemindex ) ) continue; + lTime = ITEM_getWorkInt( itemindex, ITEM_WORKTIMELIMIT); + if( ITEM_getInt( itemindex, ITEM_ID) == 20173 //ȼջ + || ITEM_getInt( itemindex, ITEM_ID) == 20704 ){ + if( lTime > 0 && NowTime.tv_sec > lTime ){ + iid = ITEM_getInt( itemindex, ITEM_ID) + 1; + snprintf( buff, sizeof( buff), "%sЧʧ..", ITEM_getChar( itemindex, ITEM_NAME)); + CHAR_talkToCli( charaindex, -1, buff, CHAR_COLORGREEN); + CHAR_DelItemMess( charaindex, i, 0); + itemindex = ITEM_makeItemAndRegist( iid); + if(itemindex!=-1){ + CHAR_setItemIndex( charaindex, i, itemindex); + ITEM_setWorkInt( itemindex, ITEM_WORKOBJINDEX, -1); + ITEM_setWorkInt( itemindex, ITEM_WORKCHARAINDEX, charaindex); + CHAR_sendItemDataOne( charaindex, i); + } + } + } + } + +} +#endif + +#ifdef _ITEM_CONSTITUTION +void ITEM_Constitution( int charaindex, int toindex, int haveitemindex) +{ + char buf[256]; + char *itemarg; + char Free[][128]={"VI","ST","TG","DE"}; + int index=0, FixPoint=0, itemindex; + BOOL FIXs=FALSE; + int AllPoint=0; + + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE) != CHAR_TYPEPLAYER ) + return; + itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + if(!ITEM_CHECKINDEX(itemindex)) return; + + itemarg = ITEM_getChar( itemindex, ITEM_ARGUMENT); + if( itemarg == "\0" ) return; + + AllPoint = CHAR_getInt( charaindex, CHAR_VITAL) + +CHAR_getInt( charaindex, CHAR_VITAL+1) + +CHAR_getInt( charaindex, CHAR_VITAL+2) + +CHAR_getInt( charaindex, CHAR_VITAL+3); + + while( index < arraysizeof( Free) ) { + if( ITEM_getArgument( itemarg, Free[ index], buf, sizeof(buf)) == TRUE ) { + FixPoint = atoi( buf); + if( FixPoint <= 100 && FixPoint > 0 ) { + int points = CHAR_getInt( charaindex, CHAR_VITAL+index); + //Change Fix + //if( points < (FixPoint*100) ) break; + if( points < (FixPoint*100) || AllPoint-(FixPoint*100) <= 0 ) + { + CHAR_talkToCli( charaindex, -1, "ƷЧ", CHAR_COLORYELLOW); + return; + } + CHAR_setInt( charaindex, CHAR_VITAL+index, (points-(FixPoint*100))); + CHAR_setInt( charaindex, CHAR_SKILLUPPOINT, CHAR_getInt( charaindex, CHAR_SKILLUPPOINT) + FixPoint); + FIXs = TRUE; + } + FixPoint = 0; + } + index++; + if( (CHAR_VITAL+index) > CHAR_DEX ) + break; + } + CHAR_complianceParameter( charaindex); + CHAR_send_P_StatusString( charaindex, + CHAR_P_STRING_MAXHP|CHAR_P_STRING_HP|CHAR_P_STRING_LV|CHAR_P_STRING_EXP| + CHAR_P_STRING_ATK|CHAR_P_STRING_DEF|CHAR_P_STRING_QUICK| + CHAR_P_STRING_VITAL|CHAR_P_STRING_STR|CHAR_P_STRING_TOUGH|CHAR_P_STRING_DEX); + + CHAR_Skillupsend( charaindex); + if( FIXs == TRUE ) { + sprintf( buf, "%s", "е仯"); + }else { + sprintf( buf, "%s", "ƷЧ"); + } + CHAR_talkToCli( charaindex, -1, buf, CHAR_COLORYELLOW); + CHAR_DelItem( charaindex, haveitemindex); +} +#endif + +#ifdef _NEW_RIDEPETS +void ITEM_useLearnRideCode( int charaindex, int toindex, int haveitemindex) +{//CHAR_LOWRIDEPETS + + if(getRideMode()==2){ + CHAR_talkToCli( charaindex, -1, "Ϊ2.0֤ģʽ޷ʹøƷ", CHAR_COLORYELLOW); + return; + } + int itemindex, i; + char buf1[256]; + char *itemarg=NULL; + int ridetrans; + typedef struct{ + char arg[32]; + int Code; + }tagNewRideCode; + tagNewRideCode NewRides[]={ + { "RIDE_PET0", RIDE_PET0}, { "RIDE_PET1", RIDE_PET1}, { "RIDE_PET2", RIDE_PET2}, + { "RIDE_PET3", RIDE_PET3}, { "RIDE_PET4", RIDE_PET4}, { "RIDE_PET5", RIDE_PET5}, + { "RIDE_PET6", RIDE_PET6}, { "RIDE_PET7", RIDE_PET7}, { "RIDE_PET8", RIDE_PET8}, + { "RIDE_PET9", RIDE_PET9}, { "RIDE_PET10", RIDE_PET10}, { "RIDE_PET11", RIDE_PET11}, + { "RIDE_PET12", RIDE_PET12}, { "RIDE_PET13", RIDE_PET13}, { "RIDE_PET14", RIDE_PET14}, +#ifdef _RIDE_CF + { "RIDE_PET15", RIDE_PET15}, { "RIDE_PET16", RIDE_PET16}, { "RIDE_PET17", RIDE_PET17}, + { "RIDE_PET18", RIDE_PET18}, { "RIDE_PET19", RIDE_PET19}, { "RIDE_PET20", RIDE_PET20}, + { "RIDE_PET21", RIDE_PET21}, { "RIDE_PET22", RIDE_PET22}, { "RIDE_PET23", RIDE_PET23}, + { "RIDE_PET24", RIDE_PET24}, { "RIDE_PET25", RIDE_PET25}, { "RIDE_PET26", RIDE_PET26}, + { "RIDE_PET27", RIDE_PET27}, { "RIDE_PET28", RIDE_PET28}, { "RIDE_PET29", RIDE_PET29}, + { "RIDE_PET30", RIDE_PET30}, { "RIDE_PET31", RIDE_PET31}, + { "RIDE_PET32", RIDE_PET0 }, { "RIDE_PET33", RIDE_PET1 }, { "RIDE_PET34", RIDE_PET2 }, + { "RIDE_PET35", RIDE_PET3 }, { "RIDE_PET36", RIDE_PET4 }, { "RIDE_PET37", RIDE_PET5 }, + { "RIDE_PET38", RIDE_PET6 }, { "RIDE_PET39", RIDE_PET7 }, { "RIDE_PET40", RIDE_PET8 }, + { "RIDE_PET41", RIDE_PET9 }, { "RIDE_PET42", RIDE_PET10}, { "RIDE_PET43", RIDE_PET11}, + { "RIDE_PET44", RIDE_PET12}, { "RIDE_PET45", RIDE_PET13}, { "RIDE_PET46", RIDE_PET14}, + { "RIDE_PET47", RIDE_PET15}, { "RIDE_PET48", RIDE_PET16}, { "RIDE_PET49", RIDE_PET17}, + { "RIDE_PET50", RIDE_PET18}, { "RIDE_PET51", RIDE_PET19}, { "RIDE_PET52", RIDE_PET20}, + { "RIDE_PET53", RIDE_PET21}, { "RIDE_PET54", RIDE_PET22}, { "RIDE_PET55", RIDE_PET23}, + { "RIDE_PET56", RIDE_PET24}, { "RIDE_PET57", RIDE_PET25}, { "RIDE_PET58", RIDE_PET26}, + { "RIDE_PET59", RIDE_PET27}, { "RIDE_PET60", RIDE_PET28}, { "RIDE_PET61", RIDE_PET29}, + { "RIDE_PET62", RIDE_PET30}, { "RIDE_PET63", RIDE_PET31}, + { "RIDE_PET64", RIDE_PET0 }, { "RIDE_PET65", RIDE_PET1 }, { "RIDE_PET66", RIDE_PET2 }, + { "RIDE_PET67", RIDE_PET3 }, { "RIDE_PET68", RIDE_PET4 }, { "RIDE_PET69", RIDE_PET5 }, + { "RIDE_PET70", RIDE_PET6 }, { "RIDE_PET71", RIDE_PET7 }, { "RIDE_PET72", RIDE_PET8 }, + { "RIDE_PET73", RIDE_PET9 }, { "RIDE_PET74", RIDE_PET10}, { "RIDE_PET75", RIDE_PET11}, + { "RIDE_PET76", RIDE_PET12}, { "RIDE_PET77", RIDE_PET13}, { "RIDE_PET78", RIDE_PET14}, + { "RIDE_PET79", RIDE_PET15}, { "RIDE_PET80", RIDE_PET16}, { "RIDE_PET81", RIDE_PET17}, + { "RIDE_PET82", RIDE_PET18}, { "RIDE_PET83", RIDE_PET19}, { "RIDE_PET84", RIDE_PET20}, + { "RIDE_PET85", RIDE_PET21}, { "RIDE_PET86", RIDE_PET22}, { "RIDE_PET87", RIDE_PET23}, + { "RIDE_PET88", RIDE_PET24}, { "RIDE_PET89", RIDE_PET25}, { "RIDE_PET90", RIDE_PET26}, + { "RIDE_PET91", RIDE_PET27}, { "RIDE_PET92", RIDE_PET28}, { "RIDE_PET93", RIDE_PET29}, + { "RIDE_PET94", RIDE_PET30}, { "RIDE_PET95", RIDE_PET31} +#endif + }; + + itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + if(!ITEM_CHECKINDEX(itemindex)) return; + itemarg = ITEM_getChar( itemindex, ITEM_ARGUMENT); + if( itemarg == "\0" ) return; + + if( getStringFromIndexWithDelim(itemarg,"|", 3, buf1, sizeof(buf1)) == FALSE ) + ridetrans=0; + else + ridetrans=atoi(buf1); + if( getStringFromIndexWithDelim(itemarg,"|", 1, buf1, sizeof(buf1)) == FALSE ) + return; + for( i=0; i=1 && + CHAR_getInt( toindex, CHAR_FUSIONRAISE) > 0 ){//ǷΪںϳ + int time_l; + int nowTime; // Robin fix + time_l = CHAR_getInt( toindex, CHAR_FUSIONTIMELIMIT); + nowTime = (int)time(NULL); +#if 1 // ҩ + { + char *arg = NULL; + char deltime[8]; + char msg[1024]; + arg = ITEM_getChar( itemindex, ITEM_ARGUMENT); + if( arg != "\0" && !strncmp( arg, "", 2) ) { +// sscanf( arg, " %d", &deltime); + getStringFromIndexWithDelim( arg, "|", 2, deltime, sizeof( deltime)); + time_l -= (atoi(deltime)*60); + CHAR_setInt( toindex, CHAR_FUSIONTIMELIMIT, time_l); + CHAR_DelItem( charaindex, haveitemindex); + sprintf( msg, "ӿﵰٶ %s ӡ", deltime); + CHAR_talkToCli( charaindex, -1, msg, CHAR_COLORYELLOW); + if( (time_l + anhour) <= nowTime ) { + int min, sec, deftime; + deftime = nowTime - (time_l + anhour); + min = deftime/60; + sec = deftime%60; + sprintf( msg, "ﵰѾιʳˣιʳʱ%d%d롣", min, sec); + CHAR_talkToCli( charaindex, -1, msg, CHAR_COLORYELLOW); + return; + } + } + } +#endif + if( (time_l + anhour) > nowTime ){ //ڵʱҪ(time_l+anhour)ſ ʳ + char Mess1[256]; + int min, sec, deftime; + //int nowTime = (int)time(NULL); + deftime = (time_l + anhour) - nowTime; + min = deftime/60; + sec = deftime%60; + sprintf( Mess1, "ﵰ%d%dſιʳ", min, sec); + CHAR_talkToCli( charaindex, -1, Mess1, CHAR_COLORYELLOW); + return; + } +//--------------------------------------------- + work[3] = CHAR_getInt( toindex, CHAR_EVOLUTIONBASEVTL); + work[0] = CHAR_getInt( toindex, CHAR_EVOLUTIONBASESTR); + work[1] = CHAR_getInt( toindex, CHAR_EVOLUTIONBASETGH); + work[2] = CHAR_getInt( toindex, CHAR_EVOLUTIONBASEDEX); + PET_showEditBaseMsg( charaindex, toindex, itemindex, work); + CHAR_setInt( toindex, CHAR_EVOLUTIONBASEVTL, work[3]); + CHAR_setInt( toindex, CHAR_EVOLUTIONBASESTR, work[0]); + CHAR_setInt( toindex, CHAR_EVOLUTIONBASETGH, work[1]); + CHAR_setInt( toindex, CHAR_EVOLUTIONBASEDEX, work[2]); +//--------------------------------------------- + LogPetPointChange( + CHAR_getChar( charaindex, CHAR_NAME ), + CHAR_getChar( charaindex, CHAR_CDKEY ), + CHAR_getChar( charaindex, CHAR_NAME), + toindex, 4, + CHAR_getInt( toindex, CHAR_LV), + "item_use", + CHAR_getInt( charaindex, CHAR_FLOOR), + CHAR_getInt( charaindex, CHAR_X ), + CHAR_getInt( charaindex, CHAR_Y ) + ); + + LogPetFeed( + CHAR_getChar( charaindex, CHAR_NAME), + CHAR_getChar( charaindex, CHAR_CDKEY), + CHAR_getChar( toindex, CHAR_NAME), + toindex, + CHAR_getInt( toindex, CHAR_LV), + ITEM_getChar( itemindex, CHAR_NAME), // Key + CHAR_getInt( charaindex, CHAR_FLOOR), + CHAR_getInt( charaindex, CHAR_X), + CHAR_getInt( charaindex, CHAR_Y), + CHAR_getChar( toindex, CHAR_UNIQUECODE) ); + +#ifdef _PET_EVOLUTION + { + int raise = CHAR_getInt( toindex, CHAR_FUSIONRAISE); + CHAR_setInt( toindex, CHAR_FUSIONRAISE, --raise); + CHAR_setInt( toindex, CHAR_FUSIONTIMELIMIT, nowTime); + if( CHAR_getInt( toindex, CHAR_FUSIONRAISE) <= 0 ){// + char buf[256], buf1[256]; + int newindex; + sprintf( buf, "%s", CHAR_getUseName( toindex )); + + newindex = EVOLUTION_createPetFromEnemyIndex( charaindex, toindex, 1); + if( !CHAR_CHECKINDEX( newindex) ){ + CHAR_talkToCli( charaindex, -1, "", CHAR_COLORYELLOW); + return; + } + sprintf( buf1, "%s", CHAR_getChar( newindex, CHAR_NAME)); + strcat( buf, buf1); + CHAR_talkToCli( charaindex, -1, buf, CHAR_COLORYELLOW); + + LogPetFeed( + CHAR_getChar( charaindex, CHAR_NAME), + CHAR_getChar( charaindex, CHAR_CDKEY), + CHAR_getChar( toindex, CHAR_NAME), + toindex, + CHAR_getInt( toindex, CHAR_LV), + buf, // Key + CHAR_getInt( charaindex, CHAR_FLOOR), + CHAR_getInt( charaindex, CHAR_X), + CHAR_getInt( charaindex, CHAR_Y), + CHAR_getChar( toindex, CHAR_UNIQUECODE) ); + + } + } +#endif + }else { + CHAR_talkToCli( charaindex, -1, "", CHAR_COLORYELLOW); + } + CHAR_DelItem( charaindex, haveitemindex); + return; +} +#endif + +#ifdef _THROWITEM_ITEMS +static int Niceitem = 0; + int golds[3]={ 10000, 20000, 50000}; + int items1[18] = { 13092, 13091, 20439, 20417, 1284, 20172, 18210, 19014, 18360, 18362, 18364, + 18359, 18356, 18357, 18510, 20418, 20419, 1452}; + int items2[11] = { 15842, 16136, 14334, 14034, 14634, 14934, 15534, 14934, 16432, 17057, 19695}; + + int items3[10] = { 16014, 16314, 14515, 14215, 14815, 15115, 15715, 15295, 16552, 17157}; + + int items4[18] = { 14516, 14513, 14216, 14213, 14816, 14813, 15116, 15716, 15415, 17360, 20279, + 20282, 20276, 20270, 20288, 20290, 20291, 20289}; + int items5[5] = { 20280, 20283, 20277, 20271, 20274}; + int items6[5] = { 20284, 20272, 20275, 20281, 20278}; +void ITEM_ThrowItemBox( int charaindex, int toindex, int haveitemindex) +{ + int i, ret, Iindex, ItemID=-1, itemindex; + char token[256]; + + if( !CHAR_CHECKINDEX(charaindex) ) return; + itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + if( !ITEM_CHECKINDEX(itemindex) ) return; + + if( Niceitem > 10 ) ret = rand()%920; + else ret = rand()%1000; + + for( i = CHAR_STARTITEMARRAY ; i < CHAR_MAXITEMHAVE ; i++ ){ + Iindex = CHAR_getItemIndex( charaindex , i ); + if( !ITEM_CHECKINDEX(itemindex) ) continue; + if( itemindex == Iindex ){ + CHAR_DelItem( charaindex, i); + + LogItem( + CHAR_getChar( charaindex, CHAR_NAME ), CHAR_getChar( charaindex, CHAR_CDKEY ), +#ifdef _add_item_log_name // WON ADD itemlogitem + itemindex, +#else + ITEM_getInt( itemindex, ITEM_ID), +#endif + "WarpManDelItem", + CHAR_getInt( charaindex, CHAR_FLOOR), CHAR_getInt( charaindex, CHAR_X ), + CHAR_getInt( charaindex, CHAR_Y ), ITEM_getChar( itemindex, ITEM_UNIQUECODE), + ITEM_getChar( itemindex, ITEM_NAME), + ITEM_getInt( itemindex, ITEM_ID) + ); + break; + } + } + if( i >= CHAR_MAXITEMHAVE ){ + return; + } + + if( ret <= 774 ){ + int Golds=0; + Golds = golds[ RAND(0,2)]; + CHAR_AddGold( charaindex, Golds); + }else { + if( ret < 924 ){ + ItemID = items1[RAND(0,17)]; + }else if( ret < 964 ){ + ItemID = items2[RAND(0,10)]; + }else if( ret < 984 ){ + ItemID = items3[RAND(0,9)]; + Niceitem++; + }else if( ret < 994 ){ + ItemID = items4[RAND(0,17)]; + Niceitem++; + }else if( ret < 999 ){ + ItemID = items5[RAND(0,4)]; + Niceitem++; + }else { + ItemID = items6[RAND(0,4)]; + Niceitem++; + } + + Iindex = ITEM_makeItemAndRegist( ItemID); + if( !ITEM_CHECKINDEX( Iindex) ){ + return; + } + ret = CHAR_addItemSpecificItemIndex( charaindex, Iindex); + if( ret < 0 || ret >= CHAR_MAXITEMHAVE ) { + ITEM_endExistItemsOne( Iindex); + return; + } + sprintf( token,"õ%s", ITEM_getChar( Iindex, ITEM_NAME)); + CHAR_talkToCli( charaindex, -1, token, CHAR_COLORYELLOW ); + CHAR_sendItemDataOne( charaindex, ret); + } +} +#endif + +#ifdef _ITEM_LOVERPARTY +void ITEM_LoverSelectUser( int charaindex, int toindex, int haveitemindex) +{ + int itemindex, i; + int playernum = CHAR_getPlayerMaxNum(); + + if( !CHAR_CHECKINDEX( charaindex ) ) return; + if( !CHAR_CHECKINDEX( toindex ) ) return; + if( CHAR_getInt( toindex, CHAR_WHICHTYPE) != CHAR_TYPEPLAYER){ + CHAR_talkToCli( charaindex, -1, "Ʒʹá", CHAR_COLORYELLOW); + return; + } + itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + if( !ITEM_CHECKINDEX(itemindex) ) return; + if( ITEM_getInt( itemindex, ITEM_TYPE) != 16 ){ + ITEM_setInt( itemindex, ITEM_TYPE, 16); + return; + } + if( !strcmp( ITEM_getChar( itemindex, ITEM_FORUSERNAME), "") || + !strcmp( ITEM_getChar( itemindex, ITEM_FORUSERCDKEY), "") ){//Ѱ趨 + if( charaindex == toindex ){ + CHAR_talkToCli( charaindex, -1, "ѡԼʹá", CHAR_COLORYELLOW); + return; + } + ITEM_setChar( itemindex, ITEM_FORUSERNAME, CHAR_getChar( toindex, CHAR_NAME) ); + ITEM_setChar( itemindex, ITEM_FORUSERCDKEY, CHAR_getChar( toindex, CHAR_CDKEY) ); + ITEM_setInt( itemindex, ITEM_TARGET, 0); + { + char token[256]; + sprintf( token, "%s(%s)", + ITEM_getChar( itemindex, ITEM_SECRETNAME), CHAR_getChar( toindex, CHAR_NAME)); + ITEM_setChar( itemindex, ITEM_SECRETNAME, token); + sprintf( token, "Ͷ趨Ϊ%s", CHAR_getChar( toindex, CHAR_NAME)); + CHAR_talkToCli( charaindex, -1, token, CHAR_COLORYELLOW); + } + CHAR_sendItemDataOne( charaindex, haveitemindex); + }else{ + char buf1[256]; + //if( CHAR_getInt( charaindex, CHAR_FLOOR) == 117 || CHAR_getInt( charaindex, CHAR_FLOOR) == 887 || + //CHAR_getInt( charaindex, CHAR_FLOOR) == 1042 || CHAR_getInt( charaindex, CHAR_FLOOR) == 2032 || + //CHAR_getInt( charaindex, CHAR_FLOOR) == 3032 || CHAR_getInt( charaindex, CHAR_FLOOR) == 4032 || + //CHAR_getInt( charaindex, CHAR_FLOOR) == 5032 || CHAR_getInt( charaindex, CHAR_FLOOR) == 6032 || + //CHAR_getInt( charaindex, CHAR_FLOOR) == 7032 || CHAR_getInt( charaindex, CHAR_FLOOR) == 8032 || + //CHAR_getInt( charaindex, CHAR_FLOOR) == 9032 ){ + if( checkUnlawWarpFloor( CHAR_getInt( charaindex, CHAR_FLOOR) ) ) { + CHAR_talkToCli( charaindex, -1, "λ޷͡", CHAR_COLORYELLOW ); + return; + } + + for( i=0; i= 10000) continue; + + if( (int)NowTime.tv_sec > (int)( OBJECT_getTime( objindex) + getGolddeletetime() ) ) { + + LogStone( + -1, + "NULL", + "NULL", + amount, + 0, + "Del(ɾʱǮ)", + OBJECT_getFloor( objindex ), + OBJECT_getX( objindex ), + OBJECT_getY( objindex ) + ); + + CHAR_ObjectDelete(objindex); + } + } +} + +void GOLD_DeleteTimeCheckOne( int objindex) +{ + int amount; + + if( CHECKOBJECT( objindex ) == FALSE ) return; + if( OBJECT_getType( objindex) != OBJTYPE_GOLD) return; + +// amount = OBJECT_getIndex( objindex); +// if( amount >= 10000) return; + + if( (int)NowTime.tv_sec > (int)( OBJECT_getTime( objindex) + getGolddeletetime() ) ) { + + LogStone( + -1, + "NULL", + "NULL", + amount, + 0, + "Del(ɾʱǮ)", + OBJECT_getFloor( objindex ), + OBJECT_getX( objindex ), + OBJECT_getY( objindex ) + ); + + CHAR_ObjectDelete(objindex); + } + +} + +#endif + +#ifdef _TIME_TICKET +void ITEM_timeticketEx( int charaindex, int toindex, int haveitemindex, int flag); +void ITEM_timeticket( int charaindex, int toindex, int haveitemindex) +{ + if(getTicketCf()==1){ + CHAR_talkToCli( charaindex, -1, getTicketMsg(), CHAR_COLORYELLOW); + return; + } + if( check_TimeTicketMap( CHAR_getInt( charaindex, CHAR_FLOOR)) == FALSE){ + CHAR_setWorkInt( charaindex, CHAR_WORKTICKETTIME, 0); + CHAR_setWorkInt( charaindex, CHAR_WORKTICKETTIMESTART, 0); + CHAR_warpToSpecificPoint( charaindex, 7025, 143, 134 ); + } + ITEM_timeticketEx( charaindex, toindex, haveitemindex, 0); +} + +void ITEM_timeticketEx( int charaindex, int toindex, int haveitemindex, int flag) +{ + int itemindex; + int addtime; + int nowtime = time(NULL); + int tickettime; + int lefttime; + char msg[1024]; + + if( !CHAR_CHECKINDEX( charaindex ) ) return; + + if( check_TimeTicketMap( CHAR_getInt( charaindex, CHAR_FLOOR)) == FALSE + && flag == 0 ) { + CHAR_talkToCli( charaindex, -1, "ص㲻ʹá", CHAR_COLORYELLOW); + return; + } + + itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + if( !ITEM_CHECKINDEX(itemindex) ) return; + + tickettime = CHAR_getWorkInt( charaindex, CHAR_WORKTICKETTIME); + if( tickettime > nowtime+20 ) { + CHAR_talkToCli( charaindex, -1, "ʱʣ£ڲſʹá", CHAR_COLORYELLOW); + return; + } + // һʹõĻ + if( tickettime == 0 ) { + tickettime = nowtime; + CHAR_setWorkInt( charaindex, CHAR_WORKTICKETTIMESTART, nowtime); + } + // սҳʱʱʹ + //if( CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE) != BATTLE_CHARMODE_NONE + // && tickettime < nowtime ) { + //tickettime = nowtime; + // sprintf(msg, "ʱ䲻%d롣", nowtime - tickettime ); + // CHAR_talkToCli( charaindex, -1, msg, CHAR_COLORYELLOW); + //} + + addtime = atoi( ITEM_getChar( itemindex, ITEM_ARGUMENT)); + tickettime += addtime; + CHAR_setWorkInt( charaindex, CHAR_WORKTICKETTIME, tickettime ); + lefttime = tickettime - nowtime; + if( lefttime > 0 ) + sprintf(msg, "ʱ%d룬ʣ%d%d롣", addtime, lefttime/60, lefttime%60 ); + else + sprintf(msg, "ʱ%d룬%d%d롣", addtime, (-lefttime)/60, (-lefttime)%60 ); + CHAR_talkToCli( charaindex, -1, msg, CHAR_COLORYELLOW); + CHAR_DelItem( charaindex, haveitemindex); +} +#endif +#ifdef _ITEM_SETLOVER +void ITEM_SetLoverUser( int charaindex, int toindex, int haveitemindex) +{ + int itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + int playernum = CHAR_getPlayerMaxNum(); + char token[256], szMsg[128]; + int floor = CHAR_getInt(charaindex,CHAR_FLOOR); + + if( !strcmp( CHAR_getChar( charaindex, CHAR_LOVE), "YES")) + { + CHAR_talkToCli( charaindex, -1, "ػΥģѾŶ~", CHAR_COLORYELLOW); + return; + } + if( !CHAR_CHECKINDEX( charaindex ) ) return; + if( !CHAR_CHECKINDEX( toindex ) ) return; + if( CHAR_getInt( toindex, CHAR_WHICHTYPE) != CHAR_TYPEPLAYER) + { + CHAR_talkToCli( charaindex, -1, "ֻܺҽŶ", CHAR_COLORYELLOW); + return; + } + if( CHAR_getInt(charaindex,CHAR_TRANSMIGRATION)<3 ||CHAR_getInt(toindex,CHAR_TRANSMIGRATION)<3) + { + CHAR_talkToCli( charaindex, -1, "Ļ˫3תŶ~", CHAR_COLORYELLOW); + return; + } + if( charaindex == toindex ) + { + CHAR_talkToCli( charaindex, -1, "ѵԼ", CHAR_COLORYELLOW); + return; + } + if ( IsMale(charaindex)==IsMale(toindex)) + { + CHAR_talkToCli( charaindex, -1, "ͬôأ", CHAR_COLORYELLOW); + return; + } + if( !ITEM_CHECKINDEX(itemindex) ) return; + int id = ITEM_getInt( itemindex, ITEM_ID); + itemindex = ITEM_makeItemAndRegist( id ); + + if( strcmp( CHAR_getChar( charaindex, CHAR_LOVE), "YES") && + strcmp( CHAR_getChar( toindex, CHAR_LOVE), "YES"))//ڶж˫ǷѾ + { + if( itemindex != -1 ){ + CHAR_setChar( charaindex, CHAR_LOVERID, CHAR_getChar( toindex, CHAR_CDKEY) ); + CHAR_setChar( charaindex, CHAR_LOVERNAME, CHAR_getChar( toindex, CHAR_NAME) ); + if (strcmp(CHAR_getChar( toindex, CHAR_LOVERID), CHAR_getChar( charaindex, CHAR_CDKEY))==0 && + strcmp(CHAR_getChar( toindex, CHAR_LOVERNAME), CHAR_getChar( charaindex, CHAR_NAME))==0){ + int i; + sprintf( token, "ѾӦ%s", CHAR_getChar( toindex, CHAR_NAME)); + CHAR_talkToCli( charaindex, -1, token, CHAR_COLORYELLOW); + sprintf( token, "%sѾӦ", CHAR_getChar( charaindex, CHAR_NAME)); + CHAR_talkToCli( toindex, -1, token, CHAR_COLORYELLOW); + CHAR_setChar( toindex, CHAR_LOVE,"YES"); + CHAR_setChar( charaindex, CHAR_LOVE,"YES"); + CHAR_setChar( charaindex, CHAR_LOVERID, CHAR_getChar( toindex, CHAR_CDKEY) ); + CHAR_setChar( charaindex, CHAR_LOVERNAME, CHAR_getChar( toindex, CHAR_NAME) ); + CHAR_setChar( toindex, CHAR_LOVERID, CHAR_getChar( charaindex, CHAR_CDKEY) ); + CHAR_setChar( toindex, CHAR_LOVERNAME, CHAR_getChar( charaindex, CHAR_NAME) ); + sprintf(szMsg,"%d 8 101883",floor); + CHAR_CHAT_DEBUG_effect(charaindex,szMsg); + CHAR_DelItem( charaindex, haveitemindex); + for(i=0;i=playernum) + { + CHAR_talkToCli( charaindex, -1, "ܱǸİ˲Ŷ~", CHAR_COLORYELLOW ); + return; + } + + if( !CHAR_CHECKINDEX( charaindex ) ) return; + if( !CHAR_CHECKINDEX( i ) ) return; + + itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + if( !ITEM_CHECKINDEX(itemindex) ) return; + + if( checkUnlawWarpFloor( CHAR_getInt( charaindex, CHAR_FLOOR) ) ) { + CHAR_talkToCli( charaindex, -1, "ܱǸİңԶط޷͡", CHAR_COLORYELLOW ); + return; + }//UNWARPͼֹʹ + if( checkUnlawWarpFloor( CHAR_getInt( i, CHAR_FLOOR) ) ) { + CHAR_talkToCli( charaindex, -1, "ܱǸİңԶط޷͡", CHAR_COLORYELLOW ); + return; + }//UNWARPͼֹʹ + if(strcmp(CHAR_getChar(i,CHAR_LOVERID),CHAR_getChar(charaindex,CHAR_CDKEY)) == 0 && + strcmp(CHAR_getChar(i,CHAR_LOVERNAME),CHAR_getChar(charaindex,CHAR_NAME)) == 0) + { + CHAR_DischargePartyNoMsg( charaindex);//ɢŶ + int floor, x, y; + char token[256]; + floor = CHAR_getInt( i, CHAR_FLOOR); + x = CHAR_getInt( i, CHAR_X); + y = CHAR_getInt( i, CHAR_Y); + + CHAR_warpToSpecificPoint( charaindex, floor, x, y ); + sprintf( token, "%s:װģˣ", CHAR_getChar( charaindex, CHAR_NAME)); + CHAR_talkToCli( i, -1, token, CHAR_COLORYELLOW ); + sprintf( token, "Ѵ͵%sߣ", CHAR_getChar( i, CHAR_NAME)); + CHAR_talkToCli( charaindex, -1, token, CHAR_COLORYELLOW ); + print("\n%s ͵%s", CHAR_getChar( charaindex, CHAR_NAME),CHAR_getChar(i, CHAR_NAME)); + return; + } + }else + CHAR_talkToCli( charaindex, -1, "ûнŶ~", CHAR_COLORYELLOW ); +} + +void ITEM_LoverUnmarry( int charaindex, int toindex, int haveitemindex) +{ + int itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + int i; + char token[256]; + int playernum = CHAR_getPlayerMaxNum(); + //Ƿ + if( !strcmp( CHAR_getChar( charaindex, CHAR_LOVE), "YES")) + { + for(i=0;i=playernum) + { + CHAR_talkToCli( charaindex, -1, "ܱǸİ˲Ŷ~", CHAR_COLORYELLOW ); + return; + } + + if( !CHAR_CHECKINDEX( charaindex ) ) return; + if( !CHAR_CHECKINDEX( i ) ) return; + if( !ITEM_CHECKINDEX(itemindex) ) return; + + if(strcmp(ITEM_getChar( itemindex, ITEM_SECRETNAME), "ָͬ")){ + int id = ITEM_getInt( itemindex, ITEM_ID); + itemindex = ITEM_makeItemAndRegist( id ); + + if( itemindex != -1 ){ + + int emptyitemindexinchara = CHAR_findEmptyItemBox( toindex ); + + if( emptyitemindexinchara < 0 ){ + sprintf( token, "%sƷʧ" , CHAR_getChar( i, CHAR_NAME)); + CHAR_talkToCli( charaindex, -1, token, CHAR_COLORYELLOW); + sprintf( token, "%s飬Ʒ" , CHAR_getChar( charaindex, CHAR_NAME)); + CHAR_talkToCli( i, -1, token, CHAR_COLORYELLOW);} + else{ + CHAR_setItemIndex( i, emptyitemindexinchara, itemindex); + ITEM_setChar( itemindex, ITEM_NAME, "ָͬ"); + ITEM_setChar( itemindex, ITEM_SECRETNAME, "ָͬ"); + sprintf( token, "%s飬ͬʹøýָ!", CHAR_getChar( charaindex, CHAR_NAME)); + ITEM_setChar( itemindex, ITEM_EFFECTSTRING, token); + CHAR_sendItemDataOne( i, emptyitemindexinchara); + ITEM_endExistItemsOne(itemindex); + sprintf( token, " %s鲢 %s 㣡", CHAR_getChar( charaindex, CHAR_NAME),ITEM_getChar( itemindex, ITEM_NAME)); + CHAR_talkToCli( i, -1, token, CHAR_COLORYELLOW); + sprintf( token, "Ѿ%s", CHAR_getChar( i, CHAR_NAME)); + CHAR_talkToCli( charaindex, -1, token, CHAR_COLORYELLOW); + CHAR_DelItem( charaindex, haveitemindex); + return;}} + }else{ + CHAR_setChar( i, CHAR_LOVE,""); + CHAR_setChar( i, CHAR_LOVERID,""); + CHAR_setChar( i, CHAR_LOVERNAME,""); + CHAR_setChar( charaindex, CHAR_LOVE,""); + CHAR_setChar( charaindex, CHAR_LOVERID,""); + CHAR_setChar( charaindex, CHAR_LOVERNAME,""); + CHAR_talkToCli( i, -1, "˫ɹ", CHAR_COLORYELLOW); + CHAR_talkToCli( charaindex, -1, "˫ɹ", CHAR_COLORYELLOW);} + CHAR_DelItem( charaindex, haveitemindex); + }else + CHAR_talkToCli( charaindex, -1, "ûнŶ~", CHAR_COLORYELLOW ); +} + +void ITEM_LoverForceUnmarry( int charaindex, int toindex, int haveitemindex) //ǿ +{ + int itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + char token[256]; + //Ƿ + if( !strcmp( CHAR_getChar( charaindex, CHAR_LOVE), "YES")) + { + CHAR_setChar( charaindex, CHAR_LOVE,""); + CHAR_setChar( charaindex, CHAR_LOVERID,""); + CHAR_setChar( charaindex, CHAR_LOVERNAME,""); + CHAR_talkToCli( charaindex, -1, "Ѿǿɹ!", CHAR_COLORYELLOW); + CHAR_DelItem( charaindex, haveitemindex); + }else + CHAR_talkToCli( charaindex, -1, "ûнŶ~", CHAR_COLORYELLOW ); +} + +#endif + +#ifdef _ITEM_METAMO +void ITEM_ColorMetamo( int charaindex, int toindex, int haveitemindex) +{ + int MetamoList[13][7]={ + /*{ , , , , , , }, //Ϊ˵*/ + { 100000, 100000, 100005, 100010, 100015, 100700, 100705}, //С + { 100020, 100025, 100030, 100035, 100020, 100710, 100715}, // + { 100040, 100055, 100050, 100045, 100040, 100720, 100725}, //к + { 100060, 100060, 100065, 100070, 100075, 100730, 100735}, // + { 100080, 100095, 100085, 100090, 100080, 100740, 100745}, //Ƥ + { 100100, 100100, 100115, 100110, 100105, 100750, 100755}, // + { 100120, 100135, 100120, 100125, 100130, 100760, 100765}, //С + { 100140, 100145, 100140, 100150, 100155, 100770, 100775}, //Ƥ + { 100160, 100165, 100170, 100160, 100175, 100780, 100785}, //ñ + { 100180, 100190, 100195, 100185, 100180, 100790, 100795}, //̷ + { 100200, 100200, 100210, 100215, 100205, 100800, 100805}, //Ů + { 100220, 100230, 100225, 100220, 100235, 100810, 100815}, // + { 100240, 0 , 0 , 0 , 0 , 100820, 0 }, // + }; + int itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + char *itemarg="\0"; + int OldMetamoId, NewMetamoId, i; + itemarg=ITEM_getChar(itemindex,ITEM_ARGUMENT); + if( itemarg == "\0" ) return; + OldMetamoId=CHAR_getInt( charaindex, CHAR_BASEBASEIMAGENUMBER); + for(i=0;i<12;i++) + if((OldMetamoId>=MetamoList[i][0] && OldMetamoId=MetamoList[i][5] && OldMetamoId= 100000 && OldMetamoId < 100240 ) + || (OldMetamoId >= 100700 && OldMetamoId < 100820)){ + if( strstr( itemarg, "" ) && OldMetamoId >= 100000 && OldMetamoId < 100120){ + CHAR_talkToCli( charaindex, -1, "Ϊ", CHAR_COLORYELLOW); + NewMetamoId=MetamoList[0][rand()%4+1]; + }else if( strstr( itemarg, "" ) && OldMetamoId >= 100000 && OldMetamoId < 100120){ + CHAR_talkToCli( charaindex, -1, "Ϊ", CHAR_COLORYELLOW); + NewMetamoId=MetamoList[1][rand()%4+1]; + }else if( strstr( itemarg, "к" ) && OldMetamoId >= 100000 && OldMetamoId < 100120){ + CHAR_talkToCli( charaindex, -1, "Ϊк", CHAR_COLORYELLOW); + NewMetamoId=MetamoList[2][rand()%4+1]; + }else if( strstr( itemarg, "" ) && OldMetamoId >= 100000 && OldMetamoId < 100120){ + CHAR_talkToCli( charaindex, -1, "Ϊ", CHAR_COLORYELLOW); + NewMetamoId=MetamoList[3][rand()%4+1]; + }else if( strstr( itemarg, "Ƥ" ) && OldMetamoId >= 100000 && OldMetamoId < 100120){ + CHAR_talkToCli( charaindex, -1, "ΪƤ", CHAR_COLORYELLOW); + NewMetamoId=MetamoList[4][rand()%4+1]; + }else if( strstr( itemarg, "ֻ" ) && OldMetamoId >= 100000 && OldMetamoId < 100120){ + CHAR_talkToCli( charaindex, -1, "Ϊֻ", CHAR_COLORYELLOW); + NewMetamoId=MetamoList[5][rand()%4+1]; + }else if( strstr( itemarg, "" ) && OldMetamoId >= 100120 && OldMetamoId < 100240){ + CHAR_talkToCli( charaindex, -1, "Ϊ", CHAR_COLORYELLOW); + NewMetamoId=MetamoList[6][rand()%4+1]; + }else if( strstr( itemarg, "Ƥ" ) && OldMetamoId >= 100120 && OldMetamoId < 100240){ + CHAR_talkToCli( charaindex, -1, "ΪƤ", CHAR_COLORYELLOW); + NewMetamoId=MetamoList[7][rand()%4+1]; + }else if( strstr( itemarg, "ñ" ) && OldMetamoId >= 100120 && OldMetamoId < 100240){ + CHAR_talkToCli( charaindex, -1, "Ϊñ", CHAR_COLORYELLOW); + NewMetamoId=MetamoList[8][rand()%4+1]; + }else if( strstr( itemarg, "̷" ) && OldMetamoId >= 100120 && OldMetamoId < 100240){ + CHAR_talkToCli( charaindex, -1, "Ϊ̷", CHAR_COLORYELLOW); + NewMetamoId=MetamoList[9][rand()%4+1]; + }else if( strstr( itemarg, "Ů" ) && OldMetamoId >= 100120 && OldMetamoId < 100240){ + CHAR_talkToCli( charaindex, -1, "ΪŮ", CHAR_COLORYELLOW); + NewMetamoId=MetamoList[10][rand()%4+1]; + }else if( strstr( itemarg, "" ) && OldMetamoId >= 100120 && OldMetamoId < 100240){ + CHAR_talkToCli( charaindex, -1, "Ϊ", CHAR_COLORYELLOW); + NewMetamoId=MetamoList[11][rand()%4+1]; + }else if( strstr( itemarg, "" ) && OldMetamoId >= 100700 && OldMetamoId < 100760){ + CHAR_talkToCli( charaindex, -1, "Ϊ", CHAR_COLORYELLOW); + if( ( OldMetamoId - 100700 ) % 10 == 0 ) + NewMetamoId=MetamoList[0][5]; + else if( ( OldMetamoId - 100700 ) % 10 == 5 ) + NewMetamoId=MetamoList[0][6]; + }else if( strstr( itemarg, "" ) && OldMetamoId >= 100700 && OldMetamoId < 100760){ + CHAR_talkToCli( charaindex, -1, "Ϊ", CHAR_COLORYELLOW); + if( ( OldMetamoId - 100700 ) % 10 == 0 ) + NewMetamoId=MetamoList[1][5]; + else if( ( OldMetamoId - 100700 ) % 10 == 5 ) + NewMetamoId=MetamoList[1][6]; + }else if( strstr( itemarg, "к" ) && OldMetamoId >= 100700 && OldMetamoId < 100760){ + CHAR_talkToCli( charaindex, -1, "Ϊк", CHAR_COLORYELLOW); + if( ( OldMetamoId - 100700 ) % 10 == 0 ) + NewMetamoId=MetamoList[2][5]; + else if( ( OldMetamoId - 100700 ) % 10 == 5 ) + NewMetamoId=MetamoList[2][6]; + }else if( strstr( itemarg, "" ) && OldMetamoId >= 100700 && OldMetamoId < 100760){ + CHAR_talkToCli( charaindex, -1, "Ϊ", CHAR_COLORYELLOW); + if( ( OldMetamoId - 100700 ) % 10 == 0 ) + NewMetamoId=MetamoList[3][5]; + else if( ( OldMetamoId - 100700 ) % 10 == 5 ) + NewMetamoId=MetamoList[3][6]; + }else if( strstr( itemarg, "Ƥ" ) && OldMetamoId >= 100700 && OldMetamoId < 100760){ + CHAR_talkToCli( charaindex, -1, "ΪƤ", CHAR_COLORYELLOW); + if( ( OldMetamoId - 100700 ) % 10 == 0 ) + NewMetamoId=MetamoList[4][5]; + else if( ( OldMetamoId - 100700 ) % 10 == 5 ) + NewMetamoId=MetamoList[4][6]; + }else if( strstr( itemarg, "ֻ" ) && OldMetamoId >= 100700 && OldMetamoId < 100760){ + CHAR_talkToCli( charaindex, -1, "Ϊֻ", CHAR_COLORYELLOW); + if( ( OldMetamoId - 100700 ) % 10 == 0 ) + NewMetamoId=MetamoList[5][5]; + else if( ( OldMetamoId - 100700 ) % 10 == 5 ) + NewMetamoId=MetamoList[5][6]; + }else if( strstr( itemarg, "" ) && OldMetamoId >= 100760 && OldMetamoId < 100820){ + CHAR_talkToCli( charaindex, -1, "Ϊ", CHAR_COLORYELLOW); + if( ( OldMetamoId - 100700 ) % 10 == 0 ) + NewMetamoId=MetamoList[6][6]; + else if( ( OldMetamoId - 100700 ) % 10 == 5 ) + NewMetamoId=MetamoList[6][6]; + }else if( strstr( itemarg, "Ƥ" ) && OldMetamoId >= 100760 && OldMetamoId < 100820){ + CHAR_talkToCli( charaindex, -1, "ΪƤ", CHAR_COLORYELLOW); + if( ( OldMetamoId - 100700 ) % 10 == 0 ) + NewMetamoId=MetamoList[7][5]; + else if( ( OldMetamoId - 100700 ) % 10 == 5 ) + NewMetamoId=MetamoList[7][6]; + }else if( strstr( itemarg, "ñ" ) && OldMetamoId >= 100760 && OldMetamoId < 100820){ + CHAR_talkToCli( charaindex, -1, "Ϊñ", CHAR_COLORYELLOW); + if( ( OldMetamoId - 100700 ) % 10 == 0 ) + NewMetamoId=MetamoList[8][5]; + else if( ( OldMetamoId - 100700 ) % 10 == 5 ) + NewMetamoId=MetamoList[8][6]; + }else if( strstr( itemarg, "̷" ) && OldMetamoId >= 100760 && OldMetamoId < 100820){ + CHAR_talkToCli( charaindex, -1, "Ϊ̷", CHAR_COLORYELLOW); + if( ( OldMetamoId - 100700 ) % 10 == 0 ) + NewMetamoId=MetamoList[9][5]; + else if( ( OldMetamoId - 100700 ) % 10 == 5 ) + NewMetamoId=MetamoList[9][6]; + }else if( strstr( itemarg, "Ů" ) && OldMetamoId >= 100760 && OldMetamoId < 100820){ + CHAR_talkToCli( charaindex, -1, "ΪŮ", CHAR_COLORYELLOW); + if( ( OldMetamoId - 100700 ) % 10 == 0 ) + NewMetamoId=MetamoList[10][5]; + else if( ( OldMetamoId - 100700 ) % 10 == 5 ) + NewMetamoId=MetamoList[10][6]; + }else if( strstr( itemarg, "" ) && OldMetamoId >= 100760 && OldMetamoId < 100820){ + CHAR_talkToCli( charaindex, -1, "Ϊ", CHAR_COLORYELLOW); + if( ( OldMetamoId - 100700 ) % 10 == 0 ) + NewMetamoId=MetamoList[11][5]; + else if( ( OldMetamoId - 100700 ) % 10 == 5 ) + NewMetamoId=MetamoList[11][6]; + }else if( strstr( itemarg, "" ) && OldMetamoId >= 100000 && OldMetamoId < 100240){ + do + if( OldMetamoId >= 100000 && OldMetamoId < 100120 ){ + NewMetamoId=MetamoList[rand()%6][rand()%4+1]; + }else if( OldMetamoId >= 100120 && OldMetamoId < 100240 ){ + NewMetamoId=MetamoList[rand()%6+6][rand()%4+1]; + }else if( OldMetamoId >= 100700 && OldMetamoId < 100760 ){ + if( ( OldMetamoId - 100700 ) % 10 == 0 ) + NewMetamoId=MetamoList[rand()%6][5]; + else if( ( OldMetamoId - 100700 ) % 10 == 5 ) + NewMetamoId=MetamoList[rand()%6][6]; + }else if( OldMetamoId >= 100760 && OldMetamoId < 100820 ){ + if( ( OldMetamoId - 100700 ) % 10 == 0 ) + NewMetamoId=MetamoList[rand()%6+6][5]; + else if( ( OldMetamoId - 100700 ) % 10 == 5 ) + NewMetamoId=MetamoList[rand()%6+6][6]; + } + while(NewMetamoId==OldMetamoId); + CHAR_talkToCli( charaindex, -1, "ͳɹ", CHAR_COLORYELLOW); + } + }else{ + CHAR_talkToCli( charaindex, -1, "㲢!", CHAR_COLORYELLOW); + return; + } + if(NewMetamoId==0){ + CHAR_talkToCli( charaindex, -1, "ԱͬûĴ!", CHAR_COLORYELLOW); + return;} + CHAR_setInt( charaindex , CHAR_BASEIMAGENUMBER , NewMetamoId ); + CHAR_setInt( charaindex , CHAR_BASEBASEIMAGENUMBER , NewMetamoId ); + + CHAR_complianceParameter( charaindex ); + CHAR_sendCToArroundCharacter( CHAR_getWorkInt( charaindex , CHAR_WORKOBJINDEX )); + CHAR_send_P_StatusString( charaindex , CHAR_P_STRING_BASEBASEIMAGENUMBER); + CHAR_DelItem( charaindex, haveitemindex); +} + +void ITEM_SexMetamo( int charaindex, int toindex, int haveitemindex) +{ + int OldMetamoId, NewMetamoId; + OldMetamoId=CHAR_getInt( charaindex, CHAR_BASEBASEIMAGENUMBER); + if(OldMetamoId >=100000 && OldMetamoId <100020){ // + NewMetamoId=OldMetamoId+120; + CHAR_talkToCli( charaindex, -1, "ϲԳɶ!", CHAR_COLORYELLOW); + }else if(OldMetamoId>=100020 && OldMetamoId <100040){ // + NewMetamoId=OldMetamoId+160; + CHAR_talkToCli( charaindex, -1, "ϲԳɶ̷!", CHAR_COLORYELLOW); + }else if(OldMetamoId>=100040 && OldMetamoId <100060){ //к + NewMetamoId=OldMetamoId+120; + CHAR_talkToCli( charaindex, -1, "ϲԳñ!", CHAR_COLORYELLOW); + }else if(OldMetamoId>=100060 && OldMetamoId <100080){ // + NewMetamoId=OldMetamoId+160; + CHAR_talkToCli( charaindex, -1, "ϲԳ!", CHAR_COLORYELLOW); + }else if(OldMetamoId>=100080 && OldMetamoId <100100){ //Ƥ + NewMetamoId=OldMetamoId+60; + CHAR_talkToCli( charaindex, -1, "ϲԳƤ!", CHAR_COLORYELLOW); + }else if(OldMetamoId>=100100 && OldMetamoId <100120){ //ֻ + NewMetamoId=OldMetamoId+100; + CHAR_talkToCli( charaindex, -1, "ϲԳŮ!", CHAR_COLORYELLOW); + }else if(OldMetamoId>=100120 && OldMetamoId <100140){ // + NewMetamoId=OldMetamoId-120; + CHAR_talkToCli( charaindex, -1, "ϲԳɶ!", CHAR_COLORYELLOW); + }else if(OldMetamoId>=100140 && OldMetamoId <100160){ //Ƥ + NewMetamoId=OldMetamoId-60; + CHAR_talkToCli( charaindex, -1, "ϲԳƤ!", CHAR_COLORYELLOW); + }else if(OldMetamoId>=100160 && OldMetamoId <100180){ //ñ + NewMetamoId=OldMetamoId-120; + CHAR_talkToCli( charaindex, -1, "ϲԳɱк!", CHAR_COLORYELLOW); + }else if(OldMetamoId>=100180 && OldMetamoId <100200){ //̷ + NewMetamoId=OldMetamoId-160; + CHAR_talkToCli( charaindex, -1, "ϲԳ!", CHAR_COLORYELLOW); + }else if(OldMetamoId>=100200 && OldMetamoId <100220){ //Ů + NewMetamoId=OldMetamoId-100; + CHAR_talkToCli( charaindex, -1, "ϲԳɴֻ!", CHAR_COLORYELLOW); + }else if(OldMetamoId>=100220 && OldMetamoId <100240){ // + NewMetamoId=OldMetamoId-160; + CHAR_talkToCli( charaindex, -1, "ϲԳɿ!", CHAR_COLORYELLOW); + }else if(OldMetamoId >=100700 && OldMetamoId <100710){ // + NewMetamoId=OldMetamoId+60; + CHAR_talkToCli( charaindex, -1, "ϲԳɶ!", CHAR_COLORYELLOW); + }else if(OldMetamoId>=100710 && OldMetamoId <100720){ // + NewMetamoId=OldMetamoId+80; + CHAR_talkToCli( charaindex, -1, "ϲԳɶ̷!", CHAR_COLORYELLOW); + }else if(OldMetamoId>=100720 && OldMetamoId <100730){ //к + NewMetamoId=OldMetamoId+60; + CHAR_talkToCli( charaindex, -1, "ϲԳñ!", CHAR_COLORYELLOW); + }else if(OldMetamoId>=100730 && OldMetamoId <100740){ // + NewMetamoId=OldMetamoId+80; + CHAR_talkToCli( charaindex, -1, "ϲԳ!", CHAR_COLORYELLOW); + }else if(OldMetamoId>=100740 && OldMetamoId <100750){ //Ƥ + NewMetamoId=OldMetamoId+30; + CHAR_talkToCli( charaindex, -1, "ϲԳƤ!", CHAR_COLORYELLOW); + }else if(OldMetamoId>=100750 && OldMetamoId <100760){ //ֻ + NewMetamoId=OldMetamoId+50; + CHAR_talkToCli( charaindex, -1, "ϲԳŮ!", CHAR_COLORYELLOW); + }else if(OldMetamoId>=100760 && OldMetamoId <100770){ // + NewMetamoId=OldMetamoId-60; + CHAR_talkToCli( charaindex, -1, "ϲԳɶ!", CHAR_COLORYELLOW); + }else if(OldMetamoId>=100770 && OldMetamoId <100780){ //Ƥ + NewMetamoId=OldMetamoId-30; + CHAR_talkToCli( charaindex, -1, "ϲԳƤ!", CHAR_COLORYELLOW); + }else if(OldMetamoId>=100780 && OldMetamoId <100790){ //ñ + NewMetamoId=OldMetamoId-60; + CHAR_talkToCli( charaindex, -1, "ϲԳɱк!", CHAR_COLORYELLOW); + }else if(OldMetamoId>=100790 && OldMetamoId <100800){ //̷ + NewMetamoId=OldMetamoId-80; + CHAR_talkToCli( charaindex, -1, "ϲԳ!", CHAR_COLORYELLOW); + }else if(OldMetamoId>=100810 && OldMetamoId <100820){ //Ů + NewMetamoId=OldMetamoId-50; + CHAR_talkToCli( charaindex, -1, "ϲԳɴֻ!", CHAR_COLORYELLOW); + }else if(OldMetamoId>=100820 && OldMetamoId <100830){ // + NewMetamoId=OldMetamoId-80; + CHAR_talkToCli( charaindex, -1, "ϲԳɿ!", CHAR_COLORYELLOW); + }else{ + CHAR_talkToCli( charaindex, -1, "㲢ͣ޷!", CHAR_COLORYELLOW); + return;} + if(NewMetamoId==0)return; + CHAR_setInt( charaindex , CHAR_BASEIMAGENUMBER , NewMetamoId ); + CHAR_setInt( charaindex , CHAR_BASEBASEIMAGENUMBER , NewMetamoId ); + + CHAR_complianceParameter( charaindex ); + CHAR_sendCToArroundCharacter( CHAR_getWorkInt( charaindex , CHAR_WORKOBJINDEX )); + CHAR_send_P_StatusString( charaindex , CHAR_P_STRING_BASEBASEIMAGENUMBER); + CHAR_DelItem( charaindex, haveitemindex); +} +#endif + +#ifdef _GM_ITEM +void ITEM_GMFUNCTION( int charaindex, int toindex, int haveitemindex) +{ + int itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + char *itemarg="\0"; + char gmtime[16]; + char gmfunction[16]; + char token[64]; + itemarg=ITEM_getChar(itemindex,ITEM_ARGUMENT); + if( itemarg == "\0" ) return; + + getStringFromIndexWithDelim(itemarg,"|", 1, gmfunction, sizeof(gmfunction)); + getStringFromIndexWithDelim(itemarg,"|", 2, gmtime, sizeof(gmtime)); + CHAR_setChar( charaindex , CHAR_GMFUNCTION, gmfunction ); + CHAR_setInt( charaindex , CHAR_GMTIME, atoi(gmtime) ); + sprintf( token, "ʹ%sȨ%d!", gmfunction, atoi(gmtime)); + CHAR_talkToCli( charaindex, -1, token, CHAR_COLORYELLOW); + sprintf( token, "ʹ鿴[help %s]GM!",CHAR_getChar( charaindex, CHAR_GMFUNCTION)); + CHAR_talkToCli( charaindex, -1, token, CHAR_COLORYELLOW ); + CHAR_DelItem( charaindex, haveitemindex); +} +#endif + +#ifdef _VIP_SERVER +void ITEM_AddMemberPoint( int charaindex, int toindex, int haveitemindex) +{ + int itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + char *itemarg="\0"; + char token[64]; + int point=sasql_ampoint( CHAR_getChar(charaindex,CHAR_CDKEY), 0,0); + itemarg=ITEM_getChar(itemindex,ITEM_ARGUMENT); + if( itemarg == "\0" ) return; + sasql_ampoint( CHAR_getChar(charaindex,CHAR_CDKEY), atoi(itemarg),1); + sprintf( token, "û%d,ĿǰӵлΪ%d!", atoi(itemarg),point+atoi(itemarg)); + CHAR_talkToCli( charaindex, -1, token, CHAR_COLORYELLOW ); + CHAR_DelItem( charaindex, haveitemindex); +} +#endif + +#ifdef _VIP_SERVER +void ITEM_AddVipPoint( int charaindex, int toindex, int haveitemindex) +{ + int itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + char *itemarg="\0"; + char token[64]; + int fd = getfdFromCharaIndex( charaindex); + char* id = CHAR_getChar( charaindex, CHAR_CDKEY ); + itemarg=ITEM_getChar(itemindex,ITEM_ARGUMENT); + int point = atoi(itemarg); + if( itemarg == "\0" ) return; + sprintf( token, "ûԱ%d!", point); + CHAR_talkToCli( charaindex, -1, token, CHAR_COLORYELLOW ); + sasql_vippoint( id, point, 1 ); + CHAR_DelItem( charaindex, haveitemindex); +} +#endif + +#ifdef _NEW_NAME //Զƺ +void ITEM_NewName( int charaindex, int toindex, int haveitemindex) +{ + int itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + char *itemarg="\0"; + char token[64]; + //char MyNewName=CHAR_getChar( charaindex , CHAR_NEWNAME); + itemarg=ITEM_getChar(itemindex,ITEM_ARGUMENT); + if( itemarg == "\0" ) return; + CHAR_setChar( charaindex , CHAR_NEWNAME, itemarg); + sprintf( token, "ϲ,ѻá%s³ƺ!", itemarg); + CHAR_talkToCli( charaindex, -1, token, CHAR_COLORYELLOW ); + int i; + int playernum = CHAR_getPlayerMaxNum(); + char NameMsg[256]; + char *MyName = CHAR_getChar( charaindex,CHAR_NAME ); + for( i = 0 ; i < playernum ; i++) + { + sprintf( NameMsg, "ϲҡ%sá%s۳ƺ!", MyName, itemarg ); + CHAR_talkToCli( i, -1, NameMsg, CHAR_COLORBLUE2); + } + CHAR_DelItem( charaindex, haveitemindex); +} +#endif + +#ifdef _VIP_RIDE //Ա֤ +void ITEM_VipRide( int charaindex, int toindex, int haveitemindex) +{ + int itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + char *itemarg="\0"; + char buf[32]; + int viptype; + int viptime; + itemarg=ITEM_getChar(itemindex,ITEM_ARGUMENT); + if( itemarg == "\0" ) return; + int fd = getfdFromCharaIndex( charaindex); + if(getStringFromIndexWithDelim(itemarg,"|", 1, buf, sizeof(buf)) == FALSE) + return; + viptype = atoi(buf); + if(getStringFromIndexWithDelim(itemarg,"|", 2, buf, sizeof(buf)) == FALSE) + return; + viptime = atoi(buf); + time_t timep; + struct tm *p; + time(&timep); + p=localtime(&timep); + timep = mktime(p); + if(viptime!=0) + { + viptime = 60*60*24*viptime; + } + if(CHAR_getInt( charaindex , CHAR_VIPRIDE)0) + CHAR_setInt( charaindex , CHAR_VIPTIME, timep+viptime); + if(viptype==1) + CHAR_talkToCli( charaindex, -1, "ϲ㣬ѳΪʽԱˣ", CHAR_COLORYELLOW ); + if(viptype==2) + CHAR_talkToCli( charaindex, -1, "ϲ㣬ѳΪƽԱˣ", CHAR_COLORYELLOW ); + if(viptype==3) + CHAR_talkToCli( charaindex, -1, "ϲ㣬ѳΪʯԱˣ", CHAR_COLORYELLOW ); + CHAR_DelItem( charaindex, haveitemindex); + }else{ + if(CHAR_getInt( charaindex , CHAR_VIPRIDE)==viptype && CHAR_getInt( charaindex , CHAR_VIPTIME)>0 && viptime>0){ + CHAR_setInt( charaindex , CHAR_VIPTIME, CHAR_getInt( charaindex , CHAR_VIPTIME)+viptime); + CHAR_talkToCli( charaindex, -1, "ĻԱʱѾӣ", CHAR_COLORRED ); + CHAR_DelItem( charaindex, haveitemindex); + }else if(CHAR_getInt( charaindex , CHAR_VIPRIDE)0){ + CHAR_setInt( charaindex , CHAR_VIPTIME, timep+viptime); + } + CHAR_setInt( charaindex , CHAR_VIPRIDE, viptype); + if(viptype==1) + CHAR_talkToCli( charaindex, -1, "ϲ㣬ѳΪʽԱˣ", CHAR_COLORYELLOW ); + if(viptype==2) + CHAR_talkToCli( charaindex, -1, "ϲ㣬ѳΪƽԱˣ", CHAR_COLORYELLOW ); + if(viptype==3) + CHAR_talkToCli( charaindex, -1, "ϲ㣬ѳΪʯԱˣ", CHAR_COLORYELLOW ); + CHAR_DelItem( charaindex, haveitemindex); + }else{ + CHAR_talkToCli( charaindex, -1, "ǻԱˣûҪʹã", CHAR_COLORRED ); + } + } +} +#endif + +#ifdef _VIP_RIDE //SQLԱת +void ITEM_OldToNew( int charaindex, int toindex, int haveitemindex) +{ + int point = CHAR_getInt( charaindex , CHAR_AMPOINT); + if(point>0){ + int fd = getfdFromCharaIndex( charaindex); + char* id = CHAR_getChar( charaindex, CHAR_CDKEY ); + char tmg[256]; + sprintf(tmg,"%dϸ˻תݿУ",point); + CHAR_talkToCli( charaindex, -1, tmg, CHAR_COLORYELLOW ); + CHAR_setInt( charaindex, CHAR_AMPOINT, 0); + sasql_ampoint(id, point, 1); + CHAR_DelItem( charaindex, haveitemindex); + }else + CHAR_talkToCli( charaindex, -1, "ûϸ˻ֿת", CHAR_COLORRED ); +} +#endif + +#ifdef _SAFE_PASSWORD //ȫ +void ITEM_ItemPetLocked( int charaindex, int toindex, int haveitemindex) +{ + int safemode = CHAR_getInt( charaindex , CHAR_LOCK); + if(safemode==0){ + CHAR_UnSafePassword(charaindex); + }else{ + CHAR_setWorkInt( charaindex , CHAR_WORKSAFEMODE, 0); + CHAR_setInt( charaindex , CHAR_LOCK, 0); + CHAR_talkToCli( charaindex, -1, "ϵͳѾΪϰȫ", CHAR_COLORRED ); + } +} +#endif + +#ifdef _FM_ITEM //ָ +void ITEM_AddFame( int charaindex, int toindex, int haveitemindex) +{ + int itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + char *itemarg="\0"; + char token[64]; + int fame=CHAR_getInt( charaindex , CHAR_FAME); + itemarg=ITEM_getChar(itemindex,ITEM_ARGUMENT); + if( itemarg == "\0" ) return; + if(fame < 100000000) + { + int NewFame = fame+atoi(itemarg)*100; + if(NewFame < 100000000) + { + CHAR_setInt( charaindex , CHAR_FAME, NewFame); + sprintf( token, "%d,Ŀǰ%d!", atoi(itemarg),NewFame/100); + CHAR_talkToCli( charaindex, -1, token, CHAR_COLORYELLOW ); + CHAR_DelItem( charaindex, haveitemindex); + }else + { + sprintf( token, ",100W!"); + CHAR_talkToCli( charaindex, -1, token, CHAR_COLORRED ); + } + }else + { + sprintf( token, "Ѿ100W!"); + CHAR_talkToCli( charaindex, -1, token, CHAR_COLORRED ); + } + +} +#endif + +#ifdef _LUCK_ITEM //ָ +void ITEM_Luck( int charaindex, int toindex, int haveitemindex) +{ + int itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + int i; + char *itemarg="\0"; + char token[64]; + char luck[][5]={"","һ","С","м",""}; + itemarg=ITEM_getChar(itemindex,ITEM_ARGUMENT); + for(i=0;i<5;i++) + if(strstr( itemarg, luck[i])) + break; + if(i==6)i=0; + CHAR_setInt( charaindex , CHAR_LUCK, i+1); + sprintf( token, "ڵΪ%s", luck[i]); + CHAR_talkToCli( charaindex, -1, token, CHAR_COLORYELLOW ); + CHAR_DelItem( charaindex, haveitemindex); +} +#endif + +#ifdef _ITEM_METAMO_TIME +void ITEM_MetamoTime( int charaindex, int toindex, int haveitemindex ) +{ + char *itemarg="\0", msg[128], buff[32]; + int itemindex, metamoTime, battlemode, metamoNo; + + if( CHAR_CHECKINDEX( charaindex ) == FALSE ) return; + //print(" PetMetamo_toindex:%d ", toindex); + + if( CHAR_getInt( charaindex, CHAR_RIDEPET ) != -1 ){ + CHAR_talkToCli( charaindex, -1, "޷вܱ", CHAR_COLORYELLOW ); + return; + } +#ifdef _FIX_METAMORIDE + if( CHAR_CHECKJOINENEMY( charaindex) == TRUE ){ + CHAR_talkToCli( charaindex, -1, "޷вܱ", CHAR_COLORYELLOW ); + return; + } +#else + if( CHAR_getInt( charaindex, CHAR_BASEIMAGENUMBER) == 100259 ){ + CHAR_talkToCli( charaindex, -1, "޷вܱ", CHAR_COLORYELLOW ); + return; + } +#endif +#ifdef _PETSKILL_BECOMEPIG + if( CHAR_getInt( charaindex, CHAR_BECOMEPIG) > -1 ){// + CHAR_talkToCli( charaindex, -1, "޷вܱ", CHAR_COLORYELLOW ); + return; + } +#endif + + +#ifdef _FIXBUG_ATTACKBOW + { + int armindex = CHAR_getItemIndex( charaindex, CHAR_ARM); + if( ITEM_CHECKINDEX( armindex) == TRUE ) { + int armtype = BATTLE_GetWepon( charaindex); + if( armtype == ITEM_BOW || armtype == ITEM_BOUNDTHROW || + armtype == ITEM_BREAKTHROW || armtype == ITEM_BOOMERANG) { + CHAR_talkToCli( charaindex, -1, "ʹԶ޷", CHAR_COLORYELLOW ); + return; + } + } + } +#endif + + battlemode = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE ); + // ݷ + if( battlemode == BATTLE_CHARMODE_INIT ){ + return; + } + itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + if(!ITEM_CHECKINDEX(itemindex)) return; + itemarg = ITEM_getChar(itemindex, ITEM_ARGUMENT ); + if( itemarg == "\0" )return; + if( getStringFromIndexWithDelim(itemarg,"|", 1, buff, sizeof(buff)) ) + metamoNo=atoi(buff); + if( getStringFromIndexWithDelim(itemarg,"|", 2, buff, sizeof(buff)) ) + metamoTime=atoi(buff); + getStringFromIndexWithDelim(itemarg,"|", 3, buff, sizeof(buff)); + + CHAR_setWorkInt( charaindex, CHAR_WORKITEMMETAMO, NowTime.tv_sec + metamoTime); + if(metamoTime>60) + sprintf( msg, "%sɳ%dСʱ", buff, metamoTime / 60 ); + else + sprintf( msg, "%sɳ%dӣ", buff, metamoTime ); + + CHAR_talkToCli( charaindex, -1, msg, CHAR_COLORYELLOW ); + + CHAR_setInt( charaindex, CHAR_BASEIMAGENUMBER, metamoNo ); + CHAR_complianceParameter( charaindex); + CHAR_sendCToArroundCharacter( CHAR_getWorkInt( charaindex , CHAR_WORKOBJINDEX )); + CHAR_send_P_StatusString( charaindex , CHAR_P_STRING_BASEBASEIMAGENUMBER); + + CHAR_DelItem( charaindex, haveitemindex); + +} +#endif + +#ifdef _ITEM_GOLD +void ITEM_Gold( int charaindex, int toindex, int haveitemindex) +{ + int itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + char itemarg[10]; + char token[64]; + int gold=CHAR_getInt( charaindex , CHAR_GOLD); + strcpy(itemarg,ITEM_getChar(itemindex,ITEM_ARGUMENT)); + gold+=atoi(itemarg); + if(gold>CHAR_MAXGOLDHAVE) + gold=CHAR_MAXGOLDHAVE; + CHAR_setInt( charaindex , CHAR_GOLD, gold); + CHAR_complianceParameter( charaindex); + CHAR_send_P_StatusString( charaindex, CHAR_P_STRING_GOLD); + sprintf( token, "ʯ%dS", atoi(itemarg)); + CHAR_talkToCli( charaindex, -1, token, CHAR_COLORYELLOW ); + CHAR_DelItem( charaindex, haveitemindex); +} +#endif + + +#ifdef _MYSTERIOUS_GIFT +void ITEM_MysteriousGift( int charaindex, int toindex, int haveitemindex) +{ + int itemindex; + char *itemarg=NULL; + char petnumstr[32]; + int petnum=0; + int present[20]={0}; + int si=0, ret,i; + char token[256]; + + itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + if(!ITEM_CHECKINDEX(itemindex)) return; + + itemarg = ITEM_getChar( itemindex, ITEM_ARGUMENT); + if( itemarg == "" ){ + CHAR_talkToCli(charaindex, -1, "Ǹ!", CHAR_COLORYELLOW); + return; + } + + if( getStringFromIndexWithDelim( itemarg, "|", 1, petnumstr, sizeof( petnumstr)) == FALSE ) + return; + petnum = atoi(petnumstr); + if( petnum > 20 ) + petnum = 20; + for(i=0;i0 && CHAR_getInt(toindex, CHAR_LIMITLEVEL)=atoi(hight) || CHAR_getInt(toindex, CHAR_LIMITLEVEL)>=atoi(hight)){ + CHAR_talkToCli( charaindex, -1, "ĿǰijﲻʹøƷ", CHAR_COLORYELLOW); + return; + } + CHAR_setInt(toindex, CHAR_LIMITLEVEL, atoi(hight)); + if(CHAR_getInt( toindex, CHAR_EXP)<0){ + int nextexp = CHAR_GetLevelExp( toindex, CHAR_getInt(toindex, CHAR_LV)); + CHAR_setInt( charaindex, CHAR_EXP , nextexp ); + } + + char token[256]; + sprintf(token, "%sȼͻ%d",CHAR_getChar( toindex, CHAR_NAME), atoi(hight)); + CHAR_talkToCli( charaindex, -1, token, CHAR_COLORYELLOW); + CHAR_DelItem( charaindex, haveitemindex); +} +#endif + +#ifdef _ITEM_EFMETAMO +void ITEM_efMetamo( int charaindex, int toindex, int haveitemindex) +{ + int itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + if(!ITEM_CHECKINDEX(itemindex)) return; + + char *itemarg = ITEM_getChar( itemindex, ITEM_ARGUMENT); + if( itemarg == "" ){ + CHAR_talkToCli(charaindex, -1, "Ǹñָ!", CHAR_COLORYELLOW); + return; + } + CHAR_setInt( charaindex , CHAR_BASEIMAGENUMBER , atoi(itemarg) ); + CHAR_setInt( charaindex , CHAR_BASEBASEIMAGENUMBER , atoi(itemarg)); + + CHAR_complianceParameter( charaindex ); + CHAR_sendCToArroundCharacter( CHAR_getWorkInt( charaindex , CHAR_WORKOBJINDEX )); + CHAR_send_P_StatusString( charaindex , CHAR_P_STRING_BASEBASEIMAGENUMBER); + CHAR_DelItem( charaindex, haveitemindex); +} +#endif + +#ifdef _PET_BEATITUDE +void PET_BEATITUDE( int charaindex, int toindex, int haveitemindex) +{ + if( !CHAR_CHECKINDEX( charaindex ) ) return; + if( !CHAR_CHECKINDEX( toindex ) ) return; + if( CHAR_getInt( toindex, CHAR_WHICHTYPE) == CHAR_TYPEPLAYER) + { + CHAR_talkToCli( charaindex, -1, "Ʒֻܸʹã", CHAR_COLORYELLOW); + return; + } + if( CHAR_getInt( toindex, CHAR_PETID) == 718 || CHAR_getInt( toindex, CHAR_PETID) == 401 +#ifdef _PET_3TRANS + || CHAR_getInt( toindex, CHAR_PETID) == getMMPETID2() +#endif + ) + { + CHAR_talkToCli( charaindex, -1, "ƷܸMMʹã", CHAR_COLORYELLOW); + return; + } + int itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + if(!ITEM_CHECKINDEX(itemindex)) return; + char *itemarg = ITEM_getChar( itemindex, ITEM_ARGUMENT); + //|2500|777 + char beatitude[12],mun[12],buf1[256]; + int targetpetid=-1; + getStringFromIndexWithDelim( itemarg, "|", 1, beatitude, sizeof(beatitude)); + getStringFromIndexWithDelim( itemarg, "|", 2, mun, sizeof(mun)); + if( getStringFromIndexWithDelim(itemarg,"|", 3, buf1, sizeof(buf1)) == FALSE ) + targetpetid=-1; + else + targetpetid=atoi(buf1); + + if( CHAR_getInt( toindex, CHAR_PETID) != targetpetid) + { + CHAR_talkToCli( charaindex, -1, "ףͲƥ䣡", CHAR_COLORYELLOW); + return; + } + + char token[256]; + int beat=CHAR_getInt( toindex, CHAR_BEATITUDE); + if(strcmp( beatitude, "")==0){ + if(CHAR_getInt( toindex, CHAR_BEATITUDE)&BEATITUDE_VITAL){ + CHAR_talkToCli( charaindex, -1, "ijˣ", CHAR_COLORYELLOW); + return; + }else{ + sprintf(token, "%s%d", CHAR_getChar( toindex, CHAR_NAME),atoi(mun)); + CHAR_setInt( toindex, CHAR_VITAL,(CHAR_getInt( toindex, CHAR_VITAL)+atoi(mun))); + beat|=BEATITUDE_VITAL; + } + }else if(strcmp( beatitude, "")==0){ + if(CHAR_getInt( toindex, CHAR_BEATITUDE)&BEATITUDE_STR){ + CHAR_talkToCli( charaindex, -1, "ijˣ", CHAR_COLORYELLOW); + return; + }else{ + sprintf(token, "%s%d", CHAR_getChar( toindex, CHAR_NAME),atoi(mun)); + CHAR_setInt( toindex, CHAR_STR, (CHAR_getInt( toindex, CHAR_STR)+atoi(mun))); + beat|=BEATITUDE_STR; + } + }else if(strcmp( beatitude, "")==0){ + if(CHAR_getInt( toindex, CHAR_BEATITUDE)&BEATITUDE_TOUGH){ + CHAR_talkToCli( charaindex, -1, "ijˣ", CHAR_COLORYELLOW); + return; + }else{ + sprintf(token, "%s%d", CHAR_getChar( toindex, CHAR_NAME),atoi(mun)); + CHAR_setInt( toindex, CHAR_TOUGH, (CHAR_getInt( toindex, CHAR_TOUGH)+atoi(mun))); + beat|=BEATITUDE_TOUGH; + } + }else if(strcmp( beatitude, "")==0){ + if(CHAR_getInt( toindex, CHAR_BEATITUDE)&BEATITUDE_DEX){ + CHAR_talkToCli( charaindex, -1, "ijˣ", CHAR_COLORYELLOW); + return; + }else{ + sprintf(token, "%s%d", CHAR_getChar( toindex, CHAR_NAME),atoi(mun)); + CHAR_setInt( toindex, CHAR_DEX, (CHAR_getInt( toindex, CHAR_DEX)+atoi(mun))); + beat|=BEATITUDE_DEX; + } + }else{ + sprintf(token, "%sǰΪ:%d,:%d,:%d,:%d", CHAR_getChar( toindex, CHAR_NAME), + CHAR_getInt( toindex, CHAR_VITAL), + CHAR_getInt( toindex, CHAR_STR), + CHAR_getInt( toindex, CHAR_TOUGH), + CHAR_getInt( toindex, CHAR_DEX)); + CHAR_talkToCli( charaindex, -1, token, CHAR_COLORYELLOW); + return; + } + CHAR_talkToCli( charaindex, -1, "ˣⶫ̫ˣѳˣ", CHAR_COLORYELLOW); + CHAR_setInt( toindex, CHAR_BEATITUDE,beat); + CHAR_talkToCli( charaindex, -1, token, CHAR_COLORYELLOW); + int i; + for( i = 0; i < CHAR_MAXPETHAVE; i ++ ){ + if( CHAR_getCharPet( charaindex, i ) == toindex )break; + } + if( i == CHAR_MAXPETHAVE )return; + CHAR_complianceParameter( toindex ); + snprintf( token, sizeof( token ), "K%d", i ); + CHAR_sendStatusString( charaindex, token ); + snprintf( token, sizeof( token ), "W%d", i ); + CHAR_sendStatusString( charaindex, token ); + + CHAR_talkToCli( charaindex, -1, token, CHAR_COLORYELLOW); + CHAR_DelItem( charaindex, haveitemindex); + + + int mybeatitude = CHAR_getInt( toindex, CHAR_BEATITUDE); + if(mybeatitude&BEATITUDE_VITAL && mybeatitude&BEATITUDE_STR && mybeatitude&BEATITUDE_TOUGH && mybeatitude&BEATITUDE_DEX){ + CHAR_talkToCli( charaindex, -1, "ijˣ", CHAR_COLORYELLOW); + sprintf(token, "%s%d", CHAR_getChar( toindex, CHAR_NAME),atoi(mun)); + CHAR_setInt( toindex, CHAR_VITAL,(CHAR_getInt( toindex, CHAR_VITAL)+atoi(mun))); + beat|=BEATITUDE_VITAL; + return; + } + +} +#endif + + + + +#ifdef _GET_MULTI_ITEM +void ITEM_GetMultiItem( int charaindex, int toindex, int haveitemindex) +{ + int itemindex; + char *itemarg=NULL; + char buf[32]; + int itemnum=0; + int itemid={-1}; + char itemname[512]=""; + int si=0, ret,i; + char token[256]; + + itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + if(!ITEM_CHECKINDEX(itemindex)) return; + + itemarg = ITEM_getChar( itemindex, ITEM_ARGUMENT); + if( itemarg == "" ){ + CHAR_talkToCli(charaindex, -1, "Ǹպ!", CHAR_COLORYELLOW); + return; + } + + if( getStringFromIndexWithDelim( itemarg, "|", 1, buf, sizeof( buf)) == FALSE ){ + CHAR_talkToCli(charaindex, -1, "!", CHAR_COLORYELLOW); + return; + } + itemnum = atoi(buf); + if( itemnum > 10 ){ + itemnum = 10; + }else if( itemnum < 0 ){ + CHAR_talkToCli(charaindex, -1, "Ǹպ!", CHAR_COLORYELLOW); + return; + } + if( (itemnum - 1) <= CHAR_findSurplusItemBox( charaindex )){ + CHAR_DelItem( charaindex, haveitemindex); + }else{ + sprintf( token, "%dƷƷλ㡣", itemnum); + CHAR_talkToCli( charaindex, -1, token, CHAR_COLORYELLOW); + return; + } + + for(i=0;i -1){ + if( CHAR_getCharPetElement( charaindex) < 0 ) { + CHAR_talkToCli( charaindex, -1, "ϳλ", CHAR_COLORYELLOW); + return; + } + int i,j,enemynum,ret; + enemynum = ENEMY_getEnemyNum(); + for( i = 0; i < enemynum; i ++ ) { + if( ENEMY_getInt( i, ENEMY_ID) == enemyid) { + break; + } + } + if( i == enemynum )return; + + ret = ENEMY_createPetFromEnemyIndex( charaindex, i); + if( !CHAR_CHECKINDEX( ret))return; + for( i = 0; i < CHAR_MAXPETHAVE; i ++ ){ + if( CHAR_getCharPet( charaindex, i ) == ret )break; + } + if( i == CHAR_MAXPETHAVE )return; + + if( CHAR_CHECKINDEX( ret ) == TRUE ){ + CHAR_setMaxExpFromLevel( ret, CHAR_getInt( ret, CHAR_LV )); + CHAR_setInt(ret,CHAR_VARIABLEAI,10000); + } + CHAR_setInt( ret, CHAR_HP, CHAR_getWorkInt( ret, CHAR_WORKMAXHP )); + CHAR_complianceParameter( ret ); + char token[128]; + snprintf( token, sizeof( token ), "K%d", i ); + CHAR_sendStatusString( charaindex, token ); + snprintf( token, sizeof( token ), "W%d", i ); + CHAR_sendStatusString( charaindex, token ); + } + CHAR_DelItem( charaindex, haveitemindex); + CHAR_setInt(charaindex, CHAR_TRANSMIGRATION, supertrans); + CHAR_setInt(charaindex, CHAR_LV, superlevel); + CHAR_setInt(charaindex, CHAR_VITAL, 1000); + CHAR_setInt(charaindex, CHAR_STR, 0); + CHAR_setInt(charaindex, CHAR_TOUGH, 0); + CHAR_setInt(charaindex, CHAR_DEX, 0); + CHAR_setInt(charaindex, CHAR_SKILLUPPOINT, superpoint-10); + CHAR_setInt(charaindex, CHAR_SUPER, 1); + + int shiftbit[] = {4,39,40,41,42,46,49,50,69,70}; + int index; + for(index=0;index<10;index++){ + int point=0; + int array; + int shift; + array = shiftbit[index] / 32; + shift = shiftbit[index] % 32; + point = CHAR_getInt( charaindex, CHAR_ENDEVENT+array); + point = point | (1 << shift); + CHAR_setInt( charaindex, CHAR_ENDEVENT+array, point); + } + + lssproto_SKUP_send( fd, superpoint-10 ); + CHAR_complianceParameter( charaindex ); + CHAR_send_P_StatusString( charaindex, + CHAR_P_STRING_DUELPOINT| + CHAR_P_STRING_VITAL| + CHAR_P_STRING_STR| + CHAR_P_STRING_TOUGH| + CHAR_P_STRING_DEX + ); + CHAR_talkToCli( charaindex, -1, "ѾΪƷˣ", CHAR_COLORYELLOW ); + CHAR_talkToCli( charaindex, -1, "ɡ񡿡ĴѨ񡿺͡MMת񡿣", CHAR_COLORYELLOW ); +} +#endif + +void ITEM_CharSave( int charaindex, int toindex, int haveitemindex) +{ + int savetime; + savetime = CHAR_getWorkInt( charaindex, CHAR_WORKSAVETIME)+(60*30); + time_t timep; + struct tm *p; + time(&timep); + p=localtime(&timep); + timep = mktime(p); + if(savetime>timep) + { + CHAR_talkToCli( charaindex, -1, "洢ʱδ", CHAR_COLORRED ); + return; + } + else + { + //int fd = getfdFromCharaIndex( charaindex); + CHAR_charSaveFromConnect(charaindex, FALSE); + CHAR_setWorkInt(charaindex,CHAR_WORKSAVETIME,timep); + CHAR_talkToCli(charaindex, -1, "ϵͳΪԶ浵", CHAR_COLORRED); + } +} + +void ITEM_NoDelWarp( int charaindex, int toindex, int haveitemindex ) +{ + char *arg; + int itemindex, warp_t, warp_fl, warp_x, warp_y; + itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + if(!ITEM_CHECKINDEX(itemindex)) return; + +#ifdef _ITEM_CHECKWARES + if( CHAR_CheckInItemForWares( charaindex, 0) == FALSE ){ + CHAR_talkToCli(charaindex, -1, "Я޷ʹá", CHAR_COLORYELLOW); + return; + } +#endif + arg = ITEM_getChar(itemindex, ITEM_ARGUMENT ); + if( arg == "\0" ) return; + if( sscanf( arg, "%d %d %d %d", &warp_t, &warp_fl, &warp_x, &warp_y) != 4 ) + return; + if( ITEM_WarpForAny(charaindex, haveitemindex, warp_fl, warp_x, warp_y, warp_t) == FALSE ) + return; + CHAR_sendStatusString(charaindex, "P"); +} + +void ITEM_RandWarp( int charaindex, int toindex, int haveitemindex) +{ + int fd = getfdFromCharaIndex( charaindex); + int itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + char arg[255]; + int len=4; + int id,j; + char pass[len]; + char *password= "0123456789"; + char buf[255]; + char *buff = (char *)malloc(len + 1); + srand((unsigned)time(NULL)); + for(j=0; j < len; j++) + { + id = rand() % strlen(password); + pass[j] = password[id]; /**/ + } + buff = pass; + buff[j]= 0; + sprintf(arg,"%d|%d|%s",haveitemindex,atoi(buff),ITEM_getChar(itemindex, ITEM_ARGUMENT )); + CHAR_setWorkChar(charaindex, CHAR_WORKRANDMSG, arg); + sprintf(buf,"Сڵ֤(%d)",atoi(buff)); + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGEANDLINEINPUT, + WINDOW_BUTTONTYPE_OKCANCEL, + CHAR_WINDOWTYPE_RAND_WARP, + -1, + buf); +} + +void ITEM_RandMsg( int charaindex, int toindex, int haveitemindex) +{ + int fd = getfdFromCharaIndex( charaindex); + int itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + char arg[255]; + int len=4; + int id,j; + char pass[len]; + char *password= "0123456789"; + char buf[255]; + char *buff = (char *)malloc(len + 1); + srand((unsigned)time(NULL)); + for(j=0; j < len; j++) + { + id = rand() % strlen(password); + pass[j] = password[id]; /**/ + } + buff = pass; + buff[j]= 0; + sprintf(arg,"%d|%d|%s",haveitemindex,atoi(buff),ITEM_getChar(itemindex, ITEM_ARGUMENT )); + CHAR_setWorkChar(charaindex, CHAR_WORKRANDMSG, arg); + sprintf(buf,"Сڵ֤(%d)",atoi(buff)); + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGEANDLINEINPUT, + WINDOW_BUTTONTYPE_OKCANCEL, + CHAR_WINDOWTYPE_RAND_MSG, + -1, + buf); +} + +#ifdef _SQL_BUY_FUNC +void ITEM_OnlineBuy_recv( int charaindex, int toindex, int haveitemindex) +{ + char buf[256]; + int fd = getfdFromCharaIndex( charaindex); + if( fd == - 1 ) return; + int i; + int petindex; + for( i = 0; i < CHAR_MAXPETHAVE; i ++ ){ + petindex = CHAR_getCharPet( charaindex, i); + if( petindex == -1 ) + break; + } + if( i == CHAR_MAXPETHAVE ){ + CHAR_talkToCli( charaindex, -1, "ʾΪ˱֤Ԥһλ", CHAR_COLORYELLOW ); + return; + } + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGEANDLINEINPUT, + WINDOW_BUTTONTYPE_OKCANCEL, + CHAR_WINDOWTYPE_ONLINE_BUY, + -1, + makeEscapeString( "봮\n", buf, sizeof(buf))); + + CHAR_DelItem( charaindex, haveitemindex); +} +#endif + +#ifdef _JOB_AUTOPK +void ITEM_JobPk( int charaindex, int toindex, int haveitemindex) +{ + int itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + char buf[32]; + int fd = getfdFromCharaIndex( charaindex); + if( fd == - 1 ) return; + char *itemarg="\0"; + int jobmode,jobtime; + itemarg=ITEM_getChar(itemindex,ITEM_ARGUMENT); + if(getStringFromIndexWithDelim(itemarg,"|", 1, buf, sizeof(buf)) == FALSE) + return; + jobmode = atoi(buf); + if(getStringFromIndexWithDelim(itemarg,"|", 2, buf, sizeof(buf)) == FALSE) + return; + jobtime = atoi(buf); + CHAR_setInt(charaindex,CHAR_JOBPKMODE,jobmode); + time_t timep; + struct tm *p; + time(&timep); + p=localtime(&timep); + timep = mktime(p); + jobtime = timep + jobtime*60*24*60; + CHAR_setInt(charaindex,CHAR_JOBPKTIME,jobtime); + + CHAR_DelItem( charaindex, haveitemindex); +} +#endif + +void ITEM_SeeEquip( int charaindex, int toindex, int haveitemindex) +{ + int ix,iy,iPlayerNum,objbuf[16];; + CHAR_getCoordinationDir(CHAR_getInt(charaindex,CHAR_DIR),CHAR_getInt(charaindex,CHAR_X), + CHAR_getInt(charaindex,CHAR_Y),1,&ix,&iy); + iPlayerNum = CHAR_getSameCoordinateObjects(objbuf,arraysizeof(objbuf),CHAR_getInt(charaindex,CHAR_FLOOR),ix,iy); + if(iPlayerNum <= 0){ + CHAR_talkToCli(charaindex, -1, "ǰûˡ", CHAR_COLORRED); + }else if(iPlayerNum == 1){ + int objindex,index,itemindex; + char equipbuf[256]; + objindex = objbuf[0]; + index = OBJECT_getIndex(objindex); + itemindex = CHAR_getItemIndex(index,CHAR_HEAD); + if(itemindex>0){ + sprintf(equipbuf,"ͷ:%s:%s",ITEM_getChar(itemindex,ITEM_NAME),ITEM_getChar( itemindex, ITEM_EFFECTSTRING)); + CHAR_talkToCli(charaindex, -1, equipbuf, CHAR_COLORGREEN); + }else{ + CHAR_talkToCli(charaindex, -1, "ͷ:", CHAR_COLORGREEN); + } + itemindex = CHAR_getItemIndex(index,CHAR_BODY); + if(itemindex>0){ + sprintf(equipbuf,":%s:%s",ITEM_getChar(itemindex,ITEM_NAME),ITEM_getChar( itemindex, ITEM_EFFECTSTRING)); + CHAR_talkToCli(charaindex, -1, equipbuf, CHAR_COLORGREEN); + }else{ + CHAR_talkToCli(charaindex, -1, ":", CHAR_COLORGREEN); + } + itemindex = CHAR_getItemIndex(index,CHAR_EQSHIELD); + if(itemindex>0){ + sprintf(equipbuf,":%s:%s",ITEM_getChar(itemindex,ITEM_NAME),ITEM_getChar( itemindex, ITEM_EFFECTSTRING)); + CHAR_talkToCli(charaindex, -1, equipbuf, CHAR_COLORGREEN); + }else{ + CHAR_talkToCli(charaindex, -1, ":", CHAR_COLORGREEN); + } + itemindex = CHAR_getItemIndex(index,CHAR_DECORATION1); + if(itemindex>0){ + sprintf(equipbuf,":%s:%s",ITEM_getChar(itemindex,ITEM_NAME),ITEM_getChar( itemindex, ITEM_EFFECTSTRING)); + CHAR_talkToCli(charaindex, -1, equipbuf, CHAR_COLORGREEN); + }else{ + CHAR_talkToCli(charaindex, -1, ":", CHAR_COLORGREEN); + } + itemindex = CHAR_getItemIndex(index,CHAR_DECORATION2); + if(itemindex>0){ + sprintf(equipbuf,":%s:%s",ITEM_getChar(itemindex,ITEM_NAME),ITEM_getChar( itemindex, ITEM_EFFECTSTRING)); + CHAR_talkToCli(charaindex, -1, equipbuf, CHAR_COLORGREEN); + }else{ + CHAR_talkToCli(charaindex, -1, ":", CHAR_COLORGREEN); + } + itemindex = CHAR_getItemIndex(index,CHAR_ARM); + if(itemindex>0){ + sprintf(equipbuf,":%s:%s",ITEM_getChar(itemindex,ITEM_NAME),ITEM_getChar( itemindex, ITEM_EFFECTSTRING)); + CHAR_talkToCli(charaindex, -1, equipbuf, CHAR_COLORGREEN); + }else{ + CHAR_talkToCli(charaindex, -1, ":", CHAR_COLORGREEN); + } + itemindex = CHAR_getItemIndex(index,CHAR_EQGLOVE); + if(itemindex>0){ + sprintf(equipbuf,":%s:%s",ITEM_getChar(itemindex,ITEM_NAME),ITEM_getChar( itemindex, ITEM_EFFECTSTRING)); + CHAR_talkToCli(charaindex, -1, equipbuf, CHAR_COLORGREEN); + }else{ + CHAR_talkToCli(charaindex, -1, ":", CHAR_COLORGREEN); + } + itemindex = CHAR_getItemIndex(index,CHAR_EQBELT); + if(itemindex>0){ + sprintf(equipbuf,":%s:%s",ITEM_getChar(itemindex,ITEM_NAME),ITEM_getChar( itemindex, ITEM_EFFECTSTRING)); + CHAR_talkToCli(charaindex, -1, equipbuf, CHAR_COLORGREEN); + }else{ + CHAR_talkToCli(charaindex, -1, ":", CHAR_COLORGREEN); + } + itemindex = CHAR_getItemIndex(index,CHAR_EQSHOES); + if(itemindex>0){ + sprintf(equipbuf,"Ь:%s:%s",ITEM_getChar(itemindex,ITEM_NAME),ITEM_getChar( itemindex, ITEM_EFFECTSTRING)); + CHAR_talkToCli(charaindex, -1, equipbuf, CHAR_COLORGREEN); + }else{ + CHAR_talkToCli(charaindex, -1, "Ь:", CHAR_COLORGREEN); + } + }else{ + CHAR_talkToCli(charaindex, -1, "ǰֻһˡ", CHAR_COLORRED); + } +} + +#ifdef _VIGOR_SYS +void ITEM_VigorSave( int charaindex, int toindex, int haveitemindex) +{ + int fd = getfdFromCharaIndex( charaindex); + char vigormsg[256]; + if(CHAR_getInt(charaindex,CHAR_VIPRIDE)>0 && getVigorTime(CHAR_getInt(charaindex,CHAR_TRANSMIGRATION))>0){ + if(CHAR_getInt(charaindex,CHAR_VIGOR)=getVigorTime(CHAR_getInt(charaindex,CHAR_TRANSMIGRATION))){ + CHAR_setInt(charaindex,CHAR_VIGOR,min(CHAR_getInt(charaindex,CHAR_VIGOR)+(int)(curtime/getVigorTime(CHAR_getInt(charaindex,CHAR_TRANSMIGRATION))*2),getVigorMax())); + //CHAR_setWorkInt(charaindex,CHAR_WORKVIGORTIME,CHAR_getWorkInt(charaindex,CHAR_WORKVIGORTIME)+(int)(curtime/getVigorTime(CHAR_getInt(charaindex,CHAR_TRANSMIGRATION)))*getVigorTime(CHAR_getInt(charaindex,CHAR_TRANSMIGRATION))); + CHAR_setWorkInt(charaindex,CHAR_WORKVIGORTIME,timep); + sprintf(vigormsg,"ֵѸ£ĿǰĻֵΪ%dϵͳԶΪ浵",CHAR_getInt(charaindex,CHAR_VIGOR)); + CHAR_talkToCli(charaindex, -1, vigormsg, CHAR_COLORRED); + CHAR_charSaveFromConnect(charaindex, FALSE); + }else{ + CHAR_talkToCli(charaindex, -1, "ȡʱ̣Ժԣ", CHAR_COLORRED); + } + }else{ + CHAR_talkToCli(charaindex, -1, "ĻѾֵ", CHAR_COLORRED); + } + }else if(CHAR_getInt(charaindex,CHAR_VIPRIDE)<=0 && getVigorTime(CHAR_getInt(charaindex,CHAR_TRANSMIGRATION))>0){ + if(CHAR_getInt(charaindex,CHAR_VIGOR)=getVigorTime(0)){ + CHAR_setInt(charaindex,CHAR_VIGOR,min(CHAR_getInt(charaindex,CHAR_VIGOR)+(int)(curtime/getVigorTime(CHAR_getInt(charaindex,CHAR_TRANSMIGRATION))),getVigorMax())); + //CHAR_setWorkInt(charaindex,CHAR_WORKVIGORTIME,CHAR_getWorkInt(charaindex,CHAR_WORKVIGORTIME)+(int)(curtime/getVigorTime(CHAR_getInt(charaindex,CHAR_TRANSMIGRATION)))*getVigorTime(CHAR_getInt(charaindex,CHAR_TRANSMIGRATION))); + CHAR_setWorkInt(charaindex,CHAR_WORKVIGORTIME,timep); + sprintf(vigormsg,"ֵѸ£ĿǰĻֵΪ%dϵͳԶΪ浵",CHAR_getInt(charaindex,CHAR_VIGOR)); + CHAR_talkToCli(charaindex, -1, vigormsg, CHAR_COLORRED); + CHAR_charSaveFromConnect(charaindex, FALSE); + }else{ + CHAR_talkToCli(charaindex, -1, "ȡʱ̣Ժԣ", CHAR_COLORRED); + } + }else{ + CHAR_talkToCli(charaindex, -1, "ĻѾֵ", CHAR_COLORRED); + } + }else{ + CHAR_talkToCli(charaindex, -1, "Ŀǰ޷ȡֵ", CHAR_COLORRED); + } +} +#endif + +#ifdef _EV_NUM +void ITEM_EvItem( int charaindex, int toindex, int haveitemindex) +{ + int itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + char buf[256]; + int fd = getfdFromCharaIndex( charaindex); + if( fd == - 1 ) return; + CHAR_talkToCli(charaindex, -1, "ʾΪֹűɫΪȷɫΪ", CHAR_COLORYELLOW); + int i = RAND(1,2); + int evitem = CHAR_getInt(charaindex,CHAR_EVITEM); + int evi,evj; + if(i==1){ + if(evitem>0){ + sprintf(buf,"뵽%sҪ<%s>",ITEM_getChar(itemindex,ITEM_ARGUMENT),ITEM_getNameFromNumber( evitem)); + CHAR_talkToCli(charaindex, -1, buf, CHAR_COLORGREEN); + evi = RAND(32700,32714); + evj = RAND(32750,32799); + sprintf(buf,"뵽%sҪ<%s>",ITEMTBL_getChar(evj,ITEM_ARGUMENT),ITEM_getNameFromNumber( evi)); + CHAR_talkToCli(charaindex, -1, buf, CHAR_COLORRED); + }else{ + sprintf(buf,"뵽%s",ITEM_getChar(itemindex,ITEM_ARGUMENT)); + CHAR_talkToCli(charaindex, -1, buf, CHAR_COLORGREEN); + evi = RAND(32700,32714); + evj = RAND(32750,32799); + sprintf(buf,"뵽%sҪ<%s>",ITEMTBL_getChar(evj,ITEM_ARGUMENT),ITEM_getNameFromNumber( evi)); + CHAR_talkToCli(charaindex, -1, buf, CHAR_COLORRED); + } + }else{ + if(evitem>0){ + evi = RAND(32700,32714); + evj = RAND(32750,32799); + sprintf(buf,"뵽%sҪ<%s>",ITEMTBL_getChar(evj,ITEM_ARGUMENT),ITEM_getNameFromNumber( evi)); + CHAR_talkToCli(charaindex, -1, buf, CHAR_COLORRED); + sprintf(buf,"뵽%sҪ<%s>",ITEM_getChar(itemindex,ITEM_ARGUMENT),ITEM_getNameFromNumber( evitem)); + CHAR_talkToCli(charaindex, -1, buf, CHAR_COLORGREEN); + }else{ + evi = RAND(32700,32714); + evj = RAND(32750,32799); + sprintf(buf,"뵽%sҪ<%s>",ITEMTBL_getChar(evj,ITEM_ARGUMENT),ITEM_getNameFromNumber( evi)); + CHAR_talkToCli(charaindex, -1, buf, CHAR_COLORRED); + sprintf(buf,"뵽%s",ITEM_getChar(itemindex,ITEM_ARGUMENT)); + CHAR_talkToCli(charaindex, -1, buf, CHAR_COLORGREEN); + } + } +} +#endif + +#ifdef _OFFLINE_SYSTEM +void ITEM_OFFLINE( int charaindex, int toindex, int haveitemindex) +{ + int itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + char buf[256]; + int fd = getfdFromCharaIndex( charaindex); + if( fd == - 1 ) return; + int offtime=atoi(ITEM_getChar(itemindex,ITEM_ARGUMENT)); + int myofftime = offtime+CHAR_getInt(charaindex,CHAR_OFFTIME); + if(myofftime >= 60*60*24*300){ + CHAR_talkToCli(charaindex, -1, "ʱѾֵ޷ʹøõߡ", CHAR_COLORRED); + return; + } + CHAR_setInt(charaindex,CHAR_OFFTIME,myofftime); + sprintf(buf,"ʱ%dӡ",(int)(offtime/60)); + CHAR_talkToCli(charaindex, -1, buf, CHAR_COLORYELLOW); + CHAR_DelItem( charaindex, haveitemindex); +} +#endif + +void ITEM_AddProfessionLevel( int charaindex, int toindex, int haveitemindex) +{ + int itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + char buf[256]; + int fd = getfdFromCharaIndex( charaindex); + if( fd == - 1 ) return; + int addprolv=atoi(ITEM_getChar(itemindex,ITEM_ARGUMENT)); + int myprolv = CHAR_getInt( charaindex, PROFESSION_LEVEL ); + if(CHAR_getInt( charaindex, PROFESSION_CLASS ) == PROFESSION_CLASS_NONE){ + CHAR_talkToCli(charaindex, -1, "㻹ûоְ", CHAR_COLORRED); + return; + } + if(myprolv + addprolv > PROFESSION_MAX_LEVEL){ + CHAR_talkToCli(charaindex, -1, "ĵȼְҵȼ", CHAR_COLORRED); + return; + }else{ + CHAR_setInt( charaindex, PROFESSION_LEVEL, myprolv + addprolv ); + CHAR_sendCToArroundCharacter( CHAR_getWorkInt( charaindex , CHAR_WORKOBJINDEX )); + sprintf(buf,"ְҵȼɹ%d",CHAR_getInt( charaindex, PROFESSION_LEVEL )); + CHAR_talkToCli(charaindex, -1, buf, CHAR_COLORYELLOW); + } + CHAR_DelItem( charaindex, haveitemindex); +} +#ifdef _ZHIPIAO_SYSTEM +void ITEM_ZhiPiao( int charaindex, int toindex, int haveitemindex) +{ + int itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + char buf[256]; + int fd = getfdFromCharaIndex( charaindex); + if( fd == - 1 ) return; + int zhipiaoindex=atoi(ITEM_getChar(itemindex,ITEM_ARGUMENT)); + if(zhipiaoindex == -1){ + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGEANDLINEINPUT, + WINDOW_BUTTONTYPE_OKCANCEL, + CHAR_WINDOWTYPE_ZHIPIAO_1, + -1, + makeEscapeString( "ҪһĻԱ\n", buf, sizeof(buf))); + CHAR_setWorkInt(charaindex,CHAR_WORKZHIPIAOITEM,haveitemindex); + }else{ + int vippoint = sasql_zhipiao_query(ITEM_getChar(itemindex,ITEM_UNIQUECODE)); + if(vippoint>0){ + char piaomsg[256]; + sprintf(piaomsg,"\nȷҪ֧Ʊô\n\n֧ƱֺԻ%d\n\nȷĻ[OK]\n",vippoint); + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OKCANCEL, + CHAR_WINDOWTYPE_ZHIPIAO_3, + -1, + piaomsg); + CHAR_setWorkInt(charaindex,CHAR_WORKZHIPIAOITEM,haveitemindex); + }else if(vippoint==0){ + CHAR_talkToCli(charaindex, -1, "֧ƱѾ֧ȡظ֧ȡ", CHAR_COLORRED); + CHAR_DelItem( charaindex, haveitemindex); + return; + } + } +} +#endif + +#ifdef _ALL_RANDMODE +void ITEM_useRandEditBase( int charaindex, int toindex, int haveitemindex) +{ + if(getMmType()==0){ + CHAR_talkToCli(charaindex, -1, getMmMsg(), CHAR_COLORRED); + return; + } + int fd = getfdFromCharaIndex( charaindex); + int itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + time_t timep; + struct tm *p; + time(&timep); + p=localtime(&timep); + timep = mktime(p); + char *randtypetime = CHAR_getChar(charaindex,CHAR_RANDTYPE); + char tempbuff[64]; + int randtype = 0; + int randtime = 0; + int randwrong = 0; + if(strlen(randtypetime)>2){ + if(getStringFromIndexWithDelim(randtypetime,"-", 3, tempbuff, sizeof(tempbuff)) != FALSE){ + if(getStringFromIndexWithDelim(randtypetime,"-", 1, tempbuff, sizeof(tempbuff))== FALSE) + return; + randwrong = atoi(tempbuff); + if(getStringFromIndexWithDelim(randtypetime,"-", 2, tempbuff, sizeof(tempbuff))== FALSE) + return; + randtype = atoi(tempbuff); + if(getStringFromIndexWithDelim(randtypetime,"-", 3, tempbuff, sizeof(tempbuff))== FALSE) + return; + randtime = atoi(tempbuff); +#ifdef _MM_NO_JIAOBEN + if(timep - randtime < getEditBaseTime()*randwrong){ + char errbuf[256]; + sprintf(errbuf,"%dſԼ˲",getEditBaseTime()*randwrong-(timep - randtime)); + CHAR_talkToCli(charaindex, -1, errbuf, CHAR_COLORRED); + return; + } +#endif + } + } +// if(timep-CHAR_getWorkInt(charaindex,CHAR_WORKRANDEDITBASETIME)>=getEditBaseTime()) +// CHAR_setWorkInt(charaindex,CHAR_WORKRANDEDITBASETIME,timep); +// else{ +// char errbuf[256]; +// sprintf(errbuf,"%dſԼ˲",getEditBaseTime()-(timep-CHAR_getWorkInt(charaindex,CHAR_WORKRANDEDITBASETIME))); +// CHAR_talkToCli(charaindex, -1, errbuf, CHAR_COLORRED); +// return; +// } + char arg[255]; + char buf[128]; + char jiabuf[][5]={"","","","","","ʮ",""}; + char jianbuf[][5]={"","һ","-","","-","",""}; + char chengbuf[][5]={"","*","x","X","","",""}; + char numbuf[][5]={"","","","","","","","","",""}; + int i,j,k,l,m; +// if(randtype == 0){ +// randtype = RAND(1,10); +// if(randtype<=5){ +// randtype = RAND(1,10); +// if(randtype<=3) randtype=1; +// else randtype=2; +// }else{ +// randtype = RAND(1,10); +// if(randtype<=3) randtype=3; +// else randtype=4; +// } +// } + randtype = 4; + if(randtype==1){ + i = RAND(30,70); + j = RAND(1,29); + l = RAND(1,7); + m = RAND(1,3); + char *typebuf; + if(m==1){ + typebuf=jiabuf[l-1]; + k = i+j; + }else{ + typebuf=jianbuf[l-1]; + k = i-j; + } + char ibuf[10],jbuf[10]; + if(i<10){ + sprintf(ibuf,"%s",numbuf[i]); + }else{ + int ia,ib; + ia = i/10; + ib = i - ia*10; + sprintf(ibuf,"%s",numbuf[ia]); + strcat(ibuf,numbuf[ib]); + } + if(j<10){ + sprintf(jbuf,"%s",numbuf[j]); + }else{ + int ja,jb; + ja = j/10; + jb = j - ja*10; + sprintf(jbuf,"%s",numbuf[ja]); + strcat(jbuf,numbuf[jb]); + } + sprintf(arg,"%d|%d|%d|%d",itemindex,toindex,haveitemindex,k); + CHAR_setWorkChar(charaindex, CHAR_WORKRANDEDITBASE, arg); + sprintf(buf,"ʽĽ(%s%s%s=?)",ibuf,typebuf,jbuf); + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGEANDLINEINPUT, + WINDOW_BUTTONTYPE_OK, + CHAR_WINDOWTYPE_RAND1_EDITBASE, + -1, + buf); + }else if(randtype==2){ + i = RAND(30,70); + j = RAND(1,29); + l = RAND(1,7); + m = RAND(1,3); + char *typebuf; + if(m==1){ + typebuf=jiabuf[l-1]; + k = i+j; + }else if(m==2){ + typebuf=jianbuf[l-1]; + k = i-j; + }else{ + typebuf=chengbuf[l-1]; + k = i*j; + } + char ibuf[10],jbuf[10]; + if(i<10){ + sprintf(ibuf,"%s",numbuf[i]); + }else{ + int ia,ib; + ia = i/10; + ib = i - ia*10; + sprintf(ibuf,"%s",numbuf[ia]); + strcat(ibuf,numbuf[ib]); + } + if(j<10){ + sprintf(jbuf,"%s",numbuf[j]); + }else{ + int ja,jb; + ja = j/10; + jb = j - ja*10; + sprintf(jbuf,"%s",numbuf[ja]); + strcat(jbuf,numbuf[jb]); + } + int n; + int randnum1; + char tempret[5][32]; + randnum1 = RAND(1,5); + int randnumbuf[4]; + int tmpi=0; + while(tmpi<100){ + randnumbuf[0] = RAND(1,100); + randnumbuf[1] = RAND(1,100); + randnumbuf[2] = RAND(1,100); + randnumbuf[3] = RAND(1,100); + if(randnumbuf[0]!=randnumbuf[1]!=randnumbuf[2]!=randnumbuf[3]!=k){ + break; + } + tmpi++; + } + tmpi=0; + for(n=1;n<=5;n++){ + if(n==randnum1){ + sprintf(tempret[n-1],"%d",k); + }else if(tmpi<4){ + sprintf(tempret[n-1],"%d",randnumbuf[tmpi]); + tmpi++; + } + } + sprintf(arg,"%d|%d|%d|%d",itemindex,toindex,haveitemindex,randnum1); + CHAR_setWorkChar(charaindex, CHAR_WORKRANDEDITBASE, arg); + sprintf(buf,"3\nѡʽĽ(%s%s%s=?)\n \n \nѡһ%s\nѡ%s\nѡ%s\nѡģ%s\nѡ壺%s\n",ibuf,typebuf,jbuf,tempret[0],tempret[1],tempret[2],tempret[3],tempret[4]); + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_SELECT, + WINDOW_BUTTONTYPE_OK, + CHAR_WINDOWTYPE_RAND2_EDITBASE, + -1, + buf); + }else if(randtype==3){ + sprintf(arg,"%s",sasql_rand_buf()); + if(strcmp(arg,"err")==0) return; + char tempbuf[64]; + char randquestion[64]; + char randrightanswer[64]; + if(getStringFromIndexWithDelim(arg,"|", 1, tempbuf, sizeof(tempbuf)) == FALSE) + return; + strcpy(randquestion,tempbuf); + if(getStringFromIndexWithDelim(arg,"|", 2, tempbuf, sizeof(tempbuf)) == FALSE) + return; + strcpy(randrightanswer,tempbuf); + sprintf(arg,"%d|%d|%d|%s",itemindex,toindex,haveitemindex,randrightanswer); + CHAR_setWorkChar(charaindex, CHAR_WORKRANDEDITBASE, arg); + sprintf(buf,"%s:",randquestion); + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGEANDLINEINPUT, + WINDOW_BUTTONTYPE_OK, + CHAR_WINDOWTYPE_RAND3_EDITBASE, + -1, + buf); + }else{ +// sprintf(arg,"%s",sasql_rand_buf()); +// if(strcmp(arg,"err")==0) return; + char tempbuf[64]; + char randquestion[64]; + char randrightanswer[64]; + char randwronganswer1[64]; + char randwronganswer2[64]; + char randwronganswer3[64]; + char randwronganswer4[64]; +// if(getStringFromIndexWithDelim(arg,"|", 1, tempbuf, sizeof(tempbuf)) == FALSE) +// return; +// strcpy(randquestion,tempbuf); +// if(getStringFromIndexWithDelim(arg,"|", 2, tempbuf, sizeof(tempbuf)) == FALSE) +// return; +// strcpy(randrightanswer,tempbuf); +// if(getStringFromIndexWithDelim(arg,"|", 3, tempbuf, sizeof(tempbuf)) == FALSE) +// return; +// strcpy(randwronganswer1,tempbuf); +// if(getStringFromIndexWithDelim(arg,"|", 4, tempbuf, sizeof(tempbuf)) == FALSE) +// return; +// strcpy(randwronganswer2,tempbuf); +// if(getStringFromIndexWithDelim(arg,"|", 5, tempbuf, sizeof(tempbuf)) == FALSE) +// return; +// strcpy(randwronganswer3,tempbuf); +// if(getStringFromIndexWithDelim(arg,"|", 6, tempbuf, sizeof(tempbuf)) == FALSE) +// return; +// strcpy(randwronganswer4,tempbuf); + memset(tempbuf, 0, sizeof(tempbuf)); + memset(randquestion, 0, sizeof(randquestion)); + memset(randrightanswer, 0, sizeof(randrightanswer)); + memset(randwronganswer1, 0, sizeof(randwronganswer1)); + memset(randwronganswer2, 0, sizeof(randwronganswer2)); + memset(randwronganswer3, 0, sizeof(randwronganswer3)); + memset(randwronganswer4, 0, sizeof(randwronganswer4)); + if(RAND(1,100)<=75){ + char randtmpbuf[4][10]; + sprintf(randtmpbuf[0],"%s",hanzibuf[RAND(1,5000)-1]); + sprintf(randtmpbuf[1],"%s",hanzibuf[RAND(1,5000)-1]); + sprintf(randtmpbuf[2],"%s",hanzibuf[RAND(1,5000)-1]); + sprintf(randtmpbuf[3],"%s",hanzibuf[RAND(1,5000)-1]); + sprintf(randquestion,"%s",str_hanzi_ganrao(randtmpbuf[0],randtmpbuf[1],randtmpbuf[2],randtmpbuf[3],0,0,0,0,0,0)); + strcat(randquestion,"ҳͬ飩"); + int newrand1 = RAND(1,100)-1; + int newrand2 = RAND(1,100)-1; + int newrand3 = RAND(1,100)-1; + int newrand4 = RAND(1,100)-1; + int newrand5 = RAND(1,100)-1; + sprintf(randrightanswer,"%s",str_hanzi_ganrao(randtmpbuf[0],randtmpbuf[1],randtmpbuf[2],randtmpbuf[3],1,newrand1,newrand2,newrand3,newrand4,newrand5)); + sprintf(randwronganswer1,"%s",str_hanzi_ganrao(randtmpbuf[0],randtmpbuf[1],randtmpbuf[3],randtmpbuf[2],1,newrand1,newrand2,newrand3,newrand4,newrand5)); + sprintf(randwronganswer2,"%s",str_hanzi_ganrao(randtmpbuf[3],randtmpbuf[1],randtmpbuf[2],randtmpbuf[0],1,newrand1,newrand2,newrand3,newrand4,newrand5)); + sprintf(randwronganswer3,"%s",str_hanzi_ganrao(randtmpbuf[1],randtmpbuf[0],randtmpbuf[2],randtmpbuf[3],1,newrand1,newrand2,newrand3,newrand4,newrand5)); + sprintf(randwronganswer4,"%s",str_hanzi_ganrao(randtmpbuf[2],randtmpbuf[3],randtmpbuf[0],randtmpbuf[1],1,newrand1,newrand2,newrand3,newrand4,newrand5)); + + }else{ + int tii; + char timubuf[36][5] = {"a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","0","1","2","3","4","5","6","7","8","9"}; + for(tii=0;tii<5;tii++){ + if(tii==0) + strcpy(tempbuf,timubuf[RAND(1,36)-1]); + else{ + int timunum = 0; + while(1){ + timunum = RAND(1,36)-1; + if(strstr(tempbuf,timubuf[timunum])==NULL) + break; + } + strcat(tempbuf,timubuf[timunum]); + } + } + sprintf(randwronganswer1,"[%c%c%c%c%c]",tempbuf[0],tempbuf[2],tempbuf[1],tempbuf[3],tempbuf[4]); + sprintf(randwronganswer2,"[%c%c%c%c%c]",tempbuf[0],tempbuf[1],tempbuf[4],tempbuf[2],tempbuf[3]); + sprintf(randwronganswer3,"[%c%c%c%c%c]",tempbuf[4],tempbuf[1],tempbuf[2],tempbuf[0],tempbuf[3]); + sprintf(randwronganswer4,"[%c%c%c%c%c]",tempbuf[1],tempbuf[0],tempbuf[2],tempbuf[3],tempbuf[4]); + sprintf(randquestion,"[%s]ҳͬӢģ",tempbuf); + sprintf(randrightanswer,"[%s]",tempbuf); + char* randstr = NULL; + randstr = str_ganrao(randquestion); + strcpy(randquestion,randstr); + randstr = str_ganraoan(randrightanswer); + strcpy(randrightanswer,randstr); + randstr = str_ganraoan(randwronganswer1); + strcpy(randwronganswer1,randstr); + randstr = str_ganraoan(randwronganswer2); + strcpy(randwronganswer2,randstr); + randstr = str_ganraoan(randwronganswer3); + strcpy(randwronganswer3,randstr); + randstr = str_ganraoan(randwronganswer4); + strcpy(randwronganswer4,randstr); + } + int n; + int randnum1; + m=1; + char tempret[5][64]; + randnum1 = RAND(1,5); + int rightnum,wrongnum1,wrongnum2,wrongnum3,wrongnum4; + rightnum = RAND(getRandMin(),getRandMax()); + wrongnum1 = RAND(getRandMin(),getRandMax()); + wrongnum2 = RAND(getRandMin(),getRandMax()); + wrongnum3 = RAND(getRandMin(),getRandMax()); + wrongnum4 = RAND(getRandMin(),getRandMax()); + //char *tempbuff2 = "ABCDE"; + int qianhounum = RAND(1,100); + for(n=1;n<=5;n++){ + if(n==randnum1){ + if(qianhounum<=30) + sprintf(tempret[n-1],"ѡ( %d %s )",rightnum,randrightanswer); + else + sprintf(tempret[n-1],"ѡ( %s %d )",randrightanswer,rightnum); + }else{ + if(m==1){ + if(qianhounum<=50) + sprintf(tempret[n-1],"ѡ( %d %s )",wrongnum1,randwronganswer1); + else + sprintf(tempret[n-1],"ѡ( %s %d )",randwronganswer1,wrongnum1); + m = 2; + }else if(m==2){ + if(qianhounum<=50) + sprintf(tempret[n-1],"ѡ( %d %s )",wrongnum2,randwronganswer2); + else + sprintf(tempret[n-1],"ѡ( %s %d )",randwronganswer2,wrongnum2); + m = 3; + }else if(m==3){ + if(qianhounum<=50) + sprintf(tempret[n-1],"ѡ( %d %s )",wrongnum3,randwronganswer3); + else + sprintf(tempret[n-1],"ѡ( %s %d )",randwronganswer3,wrongnum3); + m = 4; + }else if(m==4){ + if(qianhounum<=50) + sprintf(tempret[n-1],"ѡ( %d %s )",wrongnum4,randwronganswer4); + else + sprintf(tempret[n-1],"ѡ( %s %d )",randwronganswer4,wrongnum4); + m = 5; + } + } + } + int windowtype = 0; + int selecttype = RAND(1,100); + if(selecttype<=50){ + sprintf(arg,"%d|%d|%d|%d",itemindex,toindex,haveitemindex,rightnum); + windowtype = WINDOW_MESSAGETYPE_MESSAGEANDLINEINPUT; + }else{ + sprintf(arg,"%d|%d|%d|%d",itemindex,toindex,haveitemindex,randnum1); + windowtype = WINDOW_MESSAGETYPE_SELECT; + } + CHAR_setWorkChar(charaindex, CHAR_WORKRANDEDITBASE, arg); + sprintf(buf,"%s\n%s\n%s\n%s\n%s\n%s\nȷڵ5λֻߵѡ",randquestion,tempret[0],tempret[1],tempret[2],tempret[3],tempret[4]); + lssproto_WN_send( fd, windowtype, + WINDOW_BUTTONTYPE_OK, + CHAR_WINDOWTYPE_RAND4_EDITBASE, + -1, + buf); + CHAR_setWorkInt(charaindex,CHAR_WORKLUANPCINT,0); + } + if(randwrong<=0){ + sprintf(tempbuff,"1-%d-%d",randtype,timep); + }else{ + sprintf(tempbuff,"%d-%d-%d",randwrong*3,randtype,timep); + } + CHAR_setChar(charaindex,CHAR_RANDTYPE,tempbuff); +} +#endif +#ifdef _DP_ZHIPIAO_ITEM +void ITEM_DpZhiPiao( int charaindex, int toindex, int haveitemindex) +{ + int itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + char buf[256]; + char tmpbuf[10]; + int itemtype,itemdp=0; + int fd = getfdFromCharaIndex( charaindex); + if( fd == - 1 ) return; + char *itemarg = ITEM_getChar(itemindex,ITEM_ARGUMENT); + if(strlen(itemarg)<1) return; + if(getStringFromIndexWithDelim(itemarg,"|", 1, tmpbuf, sizeof(tmpbuf)) == FALSE) + return; + itemtype = atoi(tmpbuf); + if(getStringFromIndexWithDelim(itemarg,"|", 2, tmpbuf, sizeof(tmpbuf)) == FALSE) + return; + itemdp = atoi(tmpbuf); + if(itemdp<0) return; + if(itemtype==0){ + char jiabuf[][5]={"","","","","","ʮ",""}; + char jianbuf[][5]={"","һ","-","","-","","",}; + char numbuf[][5]={"","","","","","","","","",""}; + int i,j,k,l,m; + i = RAND(30,70); + j = RAND(1,29); + l = RAND(1,7); + m = RAND(1,3); + char *typebuf; + if(m==1){ + typebuf=jiabuf[l-1]; + k = i+j; + }else{ + typebuf=jianbuf[l-1]; + k = i-j; + } + char ibuf[10],jbuf[10]; + if(i<10){ + sprintf(ibuf,"%s",numbuf[i]); + }else{ + int ia,ib; + ia = i/10; + ib = i - ia*10; + sprintf(ibuf,"%s",numbuf[ia]); + strcat(ibuf,numbuf[ib]); + } + if(j<10){ + sprintf(jbuf,"%s",numbuf[j]); + }else{ + int ja,jb; + ja = j/10; + jb = j - ja*10; + sprintf(jbuf,"%s",numbuf[ja]); + strcat(jbuf,numbuf[jb]); + } + sprintf(buf,"ʽĽ(%s%s%s=?)",ibuf,typebuf,jbuf); + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGEANDLINEINPUT, + WINDOW_BUTTONTYPE_OKCANCEL, + CHAR_WINDOWTYPE_DPZHIPIAO_1, + -1, + buf); + CHAR_setWorkInt(charaindex,CHAR_WORKDPZHIPIAOITEM,haveitemindex); + CHAR_setWorkInt(charaindex,CHAR_WORKDPZHIPIAOSHUI,itemdp); + CHAR_setWorkInt(charaindex,CHAR_WORKDPZHIPIAORAND,k); + }else{ + CHAR_setInt(charaindex,CHAR_DUELPOINT,min(CHAR_getInt(charaindex,CHAR_DUELPOINT)+itemdp,CHAR_MAXDUELPOINT)); + CHAR_DelItem( charaindex, haveitemindex); + sprintf(buf,"%dDP",itemdp); + CHAR_talkToCli(charaindex, -1, buf, CHAR_COLORYELLOW); + CHAR_send_P_StatusString( charaindex ,CHAR_P_STRING_DUELPOINT); + CHAR_send_DpDBUpdate_AddressBook( charaindex, TRUE ); + CHAR_charSaveFromConnect(charaindex, FALSE); + CHAR_talkToCli(charaindex, -1, "ϵͳΪԶ浵", CHAR_COLORRED); + } +} +#endif + +void ITEM_UpPointResetItem( int charaindex, int toindex, int haveitemindex) +{ + int itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + char buf[32]; + int fd = getfdFromCharaIndex( charaindex); + int vital,str,tough,dex,uppoint; + CHAR_DelItem( charaindex, haveitemindex); + vital = CHAR_getInt(charaindex, CHAR_VITAL)/100; + str = CHAR_getInt(charaindex, CHAR_STR)/100; + tough = CHAR_getInt(charaindex, CHAR_TOUGH)/100; + dex = CHAR_getInt(charaindex, CHAR_DEX)/100; + uppoint = CHAR_getInt(charaindex, CHAR_SKILLUPPOINT)+vital+str+tough+dex; + CHAR_setInt(charaindex, CHAR_VITAL, CHAR_getInt(charaindex, CHAR_VITAL)-vital*100); + CHAR_setInt(charaindex, CHAR_STR, CHAR_getInt(charaindex, CHAR_STR)-str*100); + CHAR_setInt(charaindex, CHAR_TOUGH, CHAR_getInt(charaindex, CHAR_TOUGH)-tough*100); + CHAR_setInt(charaindex, CHAR_DEX, CHAR_getInt(charaindex, CHAR_DEX)-dex*100); + CHAR_setInt(charaindex, CHAR_SKILLUPPOINT, CHAR_getInt(charaindex, CHAR_SKILLUPPOINT)+vital+str+tough+dex); + lssproto_SKUP_send( fd, uppoint ); + CHAR_complianceParameter( charaindex ); + CHAR_send_P_StatusString( charaindex, + CHAR_P_STRING_DUELPOINT| + CHAR_P_STRING_VITAL| + CHAR_P_STRING_STR| + CHAR_P_STRING_TOUGH| + CHAR_P_STRING_DEX + ); + CHAR_talkToCli( charaindex, -1, "ϴɣ¼ӵ㣡", CHAR_COLORYELLOW ); + CHAR_charSaveFromConnect(charaindex, FALSE); + CHAR_talkToCli(charaindex, -1, "ϵͳΪԶ浵", CHAR_COLORRED); +} +#ifdef _XC_CANGKU +extern int ickmeindex; +extern int pckmeindex; +void NPC_PoolItemShop_printWindow_Start( int meindex, int talkerindex); +void NPC_PetShop_selectWindow1( int meindex, int toindex, int num,int select); +void ITEM_ICK( int charaindex, int toindex, int haveitemindex) +{ + NPC_PoolItemShop_printWindow_Start(ickmeindex, charaindex); +} +void ITEM_PCK( int charaindex, int toindex, int haveitemindex) +{ + CHAR_setWorkInt(charaindex,CHAR_WORKSHOPRELEVANT,0); + NPC_PetShop_selectWindow1(pckmeindex, charaindex,0,-1); +} +#endif +void ITEM_MM( int charaindex, int toindex, int haveitemindex) +{ + int itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + int fd = getfdFromCharaIndex( charaindex); + int i,j,petindex,petid,ret; + int mmtype=atoi(ITEM_getChar(itemindex,ITEM_ARGUMENT)); + char msgbuf[64]; + for( i = 0 ;i < CHAR_MAXPETHAVE ; i++) { + petindex = CHAR_getCharPet( charaindex, i); + if( petindex == -1 ) + break; + } + + if( i == CHAR_MAXPETHAVE ){ + snprintf( msgbuf,sizeof( msgbuf), ""); + CHAR_talkToCli( charaindex, -1, msgbuf, CHAR_COLORYELLOW); + return; + } + + if(mmtype==1) + petid = 1479; + else if(mmtype==2) + petid = 2547; + else + return; + + int enemynum = ENEMY_getEnemyNum(); + + for( i = 0; i < enemynum; i ++ ) { + if( ENEMY_getInt( i, ENEMY_ID ) == petid ) + //if( ENEMY_getInt( i, ENEMY_TEMPNO ) == petid ) + break; + } + + if( i == enemynum ) + return; + + ret = ENEMY_createPetFromEnemyIndex( charaindex, i); + for( i = 0; i < CHAR_MAXPETHAVE; i ++ ) { + if( CHAR_getCharPet( charaindex, i ) == ret ) + break; + } + if( i == CHAR_MAXPETHAVE ) + i = 0; + if( CHAR_CHECKINDEX( ret ) == TRUE ){ + while(CHAR_getInt( ret, CHAR_LV)<79){ // + int LevelUpPoint; + LevelUpPoint = ( 50<< 24) + ( 50<< 16) + ( 50<< 8) + ( 50<< 0); + CHAR_setInt( ret, CHAR_ALLOCPOINT, LevelUpPoint); + CHAR_PetLevelUp( ret ); + CHAR_PetAddVariableAi( ret, AI_FIX_PETLEVELUP ); + CHAR_setInt( ret, CHAR_LV, CHAR_getInt( ret, CHAR_LV) +1 ); + } + CHAR_setInt( ret, CHAR_HP, CHAR_getWorkInt( ret, CHAR_WORKMAXHP )); + CHAR_setMaxExpFromLevel( ret, CHAR_getInt( ret, CHAR_LV )); + CHAR_setInt(ret,CHAR_VARIABLEAI,10000); + } + + int petindex2 = CHAR_getCharPet(charaindex, i); + if( !CHAR_CHECKINDEX( petindex2) ) + return; + snprintf( msgbuf,sizeof( msgbuf), "õ%s", CHAR_getChar(petindex2,CHAR_NAME)); + CHAR_talkToCli( charaindex, -1, msgbuf, CHAR_COLORYELLOW); + for(j = 0; j < CHAR_MAXPETHAVE; j++){ + petindex = CHAR_getCharPet(charaindex, j); + if( !CHAR_CHECKINDEX( petindex) ) + continue; + CHAR_complianceParameter( petindex ); + snprintf( msgbuf, sizeof( msgbuf ), "K%d", j ); + CHAR_sendStatusString( charaindex, msgbuf ); + snprintf( msgbuf, sizeof( msgbuf ), "W%d", j ); + CHAR_sendStatusString( charaindex, msgbuf ); + } + CHAR_DelItem( charaindex, haveitemindex); + CHAR_charSaveFromConnect(charaindex, FALSE); + CHAR_talkToCli(charaindex, -1, "ϵͳΪԶ浵", CHAR_COLORRED); + LogPet( + CHAR_getChar( charaindex, CHAR_NAME ), + CHAR_getChar( charaindex, CHAR_CDKEY ), + CHAR_getChar( petindex2, CHAR_NAME), + CHAR_getInt( petindex2, CHAR_LV), + "MMGet", + CHAR_getInt( charaindex,CHAR_FLOOR), + CHAR_getInt( charaindex,CHAR_X ), + CHAR_getInt( charaindex,CHAR_Y ), + CHAR_getChar( petindex2, CHAR_UNIQUECODE) // shan 2001/12/14 + ); +} + +void ITEM_MakePet( int charaindex, int toindex, int haveitemindex) +{ + int itemindex; + char *itemarg=NULL; + int ret,i; + char pettemp[32]; + char token[256]; + int petid,pethp,petvital,petstr,pettgh,petdex,petlv,pettrn; + + itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + if(!ITEM_CHECKINDEX(itemindex)) return; + + itemarg = ITEM_getChar( itemindex, ITEM_ARGUMENT); + if( itemarg == "" ){ + CHAR_talkToCli(charaindex, -1, "Ǹ!", CHAR_COLORYELLOW); + return; + } + + if( getStringFromIndexWithDelim( itemarg, "|", 1, pettemp, sizeof( pettemp)) == FALSE ) + return; + petid = atoi(pettemp); + if( getStringFromIndexWithDelim( itemarg, "|", 2, pettemp, sizeof( pettemp)) == FALSE ) + return; + petlv = atoi(pettemp); + if( getStringFromIndexWithDelim( itemarg, "|", 3, pettemp, sizeof( pettemp)) == FALSE ) + return; + pettrn = atoi(pettemp); + if( getStringFromIndexWithDelim( itemarg, "|", 4, pettemp, sizeof( pettemp)) == FALSE ) + return; + pethp = atoi(pettemp); + if( getStringFromIndexWithDelim( itemarg, "|", 5, pettemp, sizeof( pettemp)) == FALSE ) + return; + petvital = atoi(pettemp); + if( getStringFromIndexWithDelim( itemarg, "|", 6, pettemp, sizeof( pettemp)) == FALSE ) + return; + petstr = atoi(pettemp); + if( getStringFromIndexWithDelim( itemarg, "|", 7, pettemp, sizeof( pettemp)) == FALSE ) + return; + pettgh = atoi(pettemp); + if( getStringFromIndexWithDelim( itemarg, "|", 8, pettemp, sizeof( pettemp)) == FALSE ) + return; + petdex = atoi(pettemp); + + for( i = 0 ;i < CHAR_MAXPETHAVE ; i++) { + if( CHAR_getCharPet( charaindex, i) == -1 ) + break; + } + + if( i == CHAR_MAXPETHAVE ){ + snprintf( token,sizeof( token), ""); + CHAR_talkToCli( charaindex, -1, token, CHAR_COLORYELLOW); + return; + } + + int enemynum = ENEMY_getEnemyNum(); + for( i = 0; i < enemynum; i ++ ) { + if( ENEMY_getInt( i, ENEMY_ID) == petid) { + break; + } + } + + if( i == enemynum )return; + + ret = ENEMY_createPetFromEnemyIndex( charaindex, i); + if(!CHAR_CHECKINDEX( ret)) + return; + + sprintf( token,"õ%s",ENEMY_getChar( i, ENEMY_NAME)); + CHAR_talkToCli( charaindex, -1, token, CHAR_COLORYELLOW ); + + for( i = 0; i < CHAR_MAXPETHAVE; i ++ ){ + if( CHAR_getCharPet( charaindex, i ) == ret )break; + } + if( i == CHAR_MAXPETHAVE )i = 0; + + CHAR_setInt(ret,CHAR_LV,petlv); + CHAR_setInt(ret,CHAR_TRANSMIGRATION,pettrn); + CHAR_setInt(ret,CHAR_VITAL,petvital); + CHAR_setInt(ret,CHAR_STR,petstr); + CHAR_setInt(ret,CHAR_TOUGH,pettgh); + CHAR_setInt(ret,CHAR_DEX,petdex); + CHAR_setInt(ret,CHAR_HP,pethp); + CHAR_setInt(ret,CHAR_VARIABLEAI,10000); + CHAR_complianceParameter( ret ); + snprintf( token, sizeof( token ), "K%d", i ); + CHAR_sendStatusString( charaindex, token ); + snprintf( token, sizeof( token ), "W%d", i ); + CHAR_sendStatusString( charaindex, token ); + CHAR_DelItem( charaindex, haveitemindex); +} + +void PET_OTHERBEATITUDE( int charaindex, int toindex, int haveitemindex) +{ + if( !CHAR_CHECKINDEX( charaindex ) ) return; + if( !CHAR_CHECKINDEX( toindex ) ) return; + if( CHAR_getInt( toindex, CHAR_WHICHTYPE) == CHAR_TYPEPLAYER) + { + CHAR_talkToCli( charaindex, -1, "Ʒֻܸʹã", CHAR_COLORYELLOW); + return; + } + if( CHAR_getInt( toindex, CHAR_PETID) == 718 || CHAR_getInt( toindex, CHAR_PETID) == 401 +#ifdef _PET_3TRANS + || CHAR_getInt( toindex, CHAR_PETID) == getMMPETID2() +#endif + ) + { + CHAR_talkToCli( charaindex, -1, "ƷܸMMʹã", CHAR_COLORYELLOW); + return; + } + + if( CHAR_getInt( toindex, CHAR_LV) <140) + { + CHAR_talkToCli( charaindex, -1, "Ʒֻܸ140ʹã", CHAR_COLORYELLOW); + return; + } + int itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + if(!ITEM_CHECKINDEX(itemindex)) return; + //91-95|Ѫ-3000|XX-XX-XX-XX + char *itemarg = ITEM_getChar( itemindex, ITEM_ARGUMENT); + char beatitude[12],mun[12],petid[64],otherbuf[32],maxbuf[32]; + getStringFromIndexWithDelim( itemarg, "|", 1, petid, sizeof(petid)); + getStringFromIndexWithDelim( itemarg, "|", 2, otherbuf, sizeof(otherbuf)); + getStringFromIndexWithDelim( itemarg, "|", 3, maxbuf, sizeof(maxbuf)); + + char fromid[12],toid[12]; + getStringFromIndexWithDelim( petid, "-", 1, fromid, sizeof(fromid)); + getStringFromIndexWithDelim( petid, "-", 2, toid, sizeof(toid)); + +/* + if(strstr(petid,temppetid)==NULL){ + CHAR_talkToCli( charaindex, -1, "Ʒܸ˳ʹã", CHAR_COLORYELLOW); + return; + } +*/ + if(CHAR_getInt( toindex, CHAR_PETID)atoi(toid) ){ + CHAR_talkToCli( charaindex, -1, "Ʒܸ˳ʹã", CHAR_COLORYELLOW); + return; + } + + getStringFromIndexWithDelim( otherbuf, "-", 1, beatitude, sizeof(beatitude)); + getStringFromIndexWithDelim( otherbuf, "-", 2, mun, sizeof(mun)); + char token[256]; + int beat=CHAR_getInt( toindex, CHAR_BEATITUDE); + if(strcmp( beatitude, "")==0){ + if(CHAR_getInt( toindex, CHAR_BEATITUDE)&BEATITUDE_VITAL){ + CHAR_talkToCli( charaindex, -1, "ijˣ", CHAR_COLORYELLOW); + return; + }else{ + sprintf(token, "%s%d", CHAR_getChar( toindex, CHAR_NAME),atoi(mun)); + CHAR_setInt( toindex, CHAR_VITAL,(CHAR_getInt( toindex, CHAR_VITAL)+atoi(mun)*100)); + beat|=BEATITUDE_VITAL; + } + }else if(strcmp( beatitude, "")==0){ + if(CHAR_getInt( toindex, CHAR_BEATITUDE)&BEATITUDE_STR){ + CHAR_talkToCli( charaindex, -1, "ijˣ", CHAR_COLORYELLOW); + return; + }else{ + sprintf(token, "%s%d", CHAR_getChar( toindex, CHAR_NAME),atoi(mun)); + CHAR_setInt( toindex, CHAR_STR, (CHAR_getInt( toindex, CHAR_STR)+atoi(mun)*100)); + beat|=BEATITUDE_STR; + } + }else if(strcmp( beatitude, "")==0){ + if(CHAR_getInt( toindex, CHAR_BEATITUDE)&BEATITUDE_TOUGH){ + CHAR_talkToCli( charaindex, -1, "ijˣ", CHAR_COLORYELLOW); + return; + }else{ + sprintf(token, "%s%d", CHAR_getChar( toindex, CHAR_NAME),atoi(mun)); + CHAR_setInt( toindex, CHAR_TOUGH, (CHAR_getInt( toindex, CHAR_TOUGH)+atoi(mun)*100)); + beat|=BEATITUDE_TOUGH; + } + }else if(strcmp( beatitude, "")==0){ + if(CHAR_getInt( toindex, CHAR_BEATITUDE)&BEATITUDE_DEX){ + CHAR_talkToCli( charaindex, -1, "ijˣ", CHAR_COLORYELLOW); + return; + }else{ + sprintf(token, "%sٶ%d", CHAR_getChar( toindex, CHAR_NAME),atoi(mun)); + CHAR_setInt( toindex, CHAR_DEX, (CHAR_getInt( toindex, CHAR_DEX)+atoi(mun)*100)); + beat|=BEATITUDE_DEX; + } + }else{ + sprintf(token, "%sǰΪ:%d,:%d,:%d,:%d", CHAR_getChar( toindex, CHAR_NAME), + CHAR_getInt( toindex, CHAR_VITAL), + CHAR_getInt( toindex, CHAR_STR), + CHAR_getInt( toindex, CHAR_TOUGH), + CHAR_getInt( toindex, CHAR_DEX)); + CHAR_talkToCli( charaindex, -1, token, CHAR_COLORYELLOW); + return; + } + CHAR_talkToCli( charaindex, -1, "ˣⶫ̫ˣѳˣ", CHAR_COLORYELLOW); + CHAR_setInt( toindex, CHAR_BEATITUDE,beat); + CHAR_talkToCli( charaindex, -1, token, CHAR_COLORYELLOW); + int i; + for( i = 0; i < CHAR_MAXPETHAVE; i ++ ){ + if( CHAR_getCharPet( charaindex, i ) == toindex )break; + } + if( i == CHAR_MAXPETHAVE )return; + if(strstr(CHAR_getChar(toindex,CHAR_NAME),"+")==NULL){ + char petnamebuf[64]; + sprintf(petnamebuf,"%s+",CHAR_getChar(toindex,CHAR_NAME)); + CHAR_setChar(toindex,CHAR_NAME,petnamebuf); + } + CHAR_complianceParameter( toindex ); + snprintf( token, sizeof( token ), "K%d", i ); + CHAR_sendStatusString( charaindex, token ); + snprintf( token, sizeof( token ), "W%d", i ); + CHAR_sendStatusString( charaindex, token ); + + //CHAR_talkToCli( charaindex, -1, token, CHAR_COLORYELLOW); + CHAR_DelItem( charaindex, haveitemindex); + +#ifdef _MAX_BEATITUDE_BUFF + int mybeati = CHAR_getInt( toindex, CHAR_BEATITUDE); + int mypetid = CHAR_getInt( toindex, CHAR_PETID); + char ex_vit[12],ex_str[12],ex_tou[12],ex_dex[12]; + getStringFromIndexWithDelim( maxbuf, "-", 1, ex_vit, sizeof(ex_vit)); + getStringFromIndexWithDelim( maxbuf, "-", 2, ex_str, sizeof(ex_str)); + getStringFromIndexWithDelim( maxbuf, "-", 3, ex_tou, sizeof(ex_tou)); + getStringFromIndexWithDelim( maxbuf, "-", 4, ex_dex, sizeof(ex_dex)); + + + if(mybeati&BEATITUDE_VITAL && mybeati&BEATITUDE_STR && mybeati&BEATITUDE_TOUGH && mybeati&BEATITUDE_DEX){ + + //sprintf(token, "%s%d", CHAR_getChar( toindex, CHAR_NAME),atoi(ex_vit)); + CHAR_setInt( toindex, CHAR_VITAL,(CHAR_getInt( toindex, CHAR_VITAL)+atoi(ex_vit)*100)); + + //sprintf(token, "%s%d", CHAR_getChar( toindex, CHAR_NAME),atoi(ex_str)); + CHAR_setInt( toindex, CHAR_STR, (CHAR_getInt( toindex, CHAR_STR)+atoi(ex_str)*100)); + + //sprintf(token, "%s%d", CHAR_getChar( toindex, CHAR_NAME),atoi(ex_tou)); + CHAR_setInt( toindex, CHAR_TOUGH, (CHAR_getInt( toindex, CHAR_TOUGH)+atoi(ex_tou)*100)); + + //sprintf(token, "%sٶ%d", CHAR_getChar( toindex, CHAR_NAME),atoi(ex_dex)); + CHAR_setInt( toindex, CHAR_DEX, (CHAR_getInt( toindex, CHAR_DEX)+atoi(ex_dex)*100)); + + CHAR_talkToCli( charaindex, -1, "ףBUFFЧԭʼˣ", CHAR_COLORRED); + + int j; + for( j = 0; j < CHAR_MAXPETHAVE; j ++ ){ + if( CHAR_getCharPet( charaindex, j ) == toindex )break; + } + if( j == CHAR_MAXPETHAVE )return; + if(strstr(CHAR_getChar(toindex,CHAR_NAME),"++")==NULL){ + char petnamebuf[64]; + sprintf(petnamebuf,"%s+",CHAR_getChar(toindex,CHAR_NAME)); + CHAR_setChar(toindex,CHAR_NAME,petnamebuf); + } + CHAR_complianceParameter( toindex ); + snprintf( token, sizeof( token ), "K%d", j ); + CHAR_sendStatusString( charaindex, token ); + snprintf( token, sizeof( token ), "W%d", j ); + CHAR_sendStatusString( charaindex, token ); + } + +#endif +} + +void PET_MYBEATITUDE( int charaindex, int toindex, int haveitemindex) +{ + if( !CHAR_CHECKINDEX( charaindex ) ) return; + if( !CHAR_CHECKINDEX( toindex ) ) return; + if( CHAR_getInt( toindex, CHAR_WHICHTYPE) == CHAR_TYPEPLAYER) + { + CHAR_talkToCli( charaindex, -1, "Ʒֻܸʹã", CHAR_COLORYELLOW); + return; + } + if( CHAR_getInt( toindex, CHAR_PETID) == 718 || CHAR_getInt( toindex, CHAR_PETID) == 401 +#ifdef _PET_3TRANS + || CHAR_getInt( toindex, CHAR_PETID) == getMMPETID2() +#endif + ) + { + CHAR_talkToCli( charaindex, -1, "ƷܸMMʹã", CHAR_COLORYELLOW); + return; + } + + if( CHAR_getInt( toindex, CHAR_LV) < 140) + { + CHAR_talkToCli( charaindex, -1, "Ʒֻܸ140ʹã", CHAR_COLORYELLOW); + return; + } + int itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + if(!ITEM_CHECKINDEX(itemindex)) return; + //91-95|Ѫ-3000|XX-XX-XX-XX + char *itemarg = ITEM_getChar( itemindex, ITEM_ARGUMENT); + char beatitude[12],mun[12],petid[64],otherbuf[32],maxbuf[32]; + getStringFromIndexWithDelim( itemarg, "|", 1, petid, sizeof(petid)); + getStringFromIndexWithDelim( itemarg, "|", 2, otherbuf, sizeof(otherbuf)); + getStringFromIndexWithDelim( itemarg, "|", 3, maxbuf, sizeof(maxbuf)); + + char fromid[12],toid[12]; + getStringFromIndexWithDelim( petid, "-", 1, fromid, sizeof(fromid)); + getStringFromIndexWithDelim( petid, "-", 2, toid, sizeof(toid)); + +/* + if(strstr(petid,temppetid)==NULL){ + CHAR_talkToCli( charaindex, -1, "Ʒܸ˳ʹã", CHAR_COLORYELLOW); + return; + } +*/ + if(CHAR_getInt( toindex, CHAR_PETID)atoi(toid) ){ + CHAR_talkToCli( charaindex, -1, "Ʒܸ˳ʹã", CHAR_COLORYELLOW); + return; + } + + getStringFromIndexWithDelim( otherbuf, "-", 1, beatitude, sizeof(beatitude)); + getStringFromIndexWithDelim( otherbuf, "-", 2, mun, sizeof(mun)); + char token[256]; + int beat=CHAR_getInt( toindex, CHAR_BEATITUDE); + if(strcmp( beatitude, "")==0){ + if(CHAR_getInt( toindex, CHAR_BEATITUDE)&BEATITUDE_VITAL){ + CHAR_talkToCli( charaindex, -1, "ijˣ", CHAR_COLORYELLOW); + return; + }else{ + sprintf(token, "%s%d", CHAR_getChar( toindex, CHAR_NAME),atoi(mun)); + CHAR_setInt( toindex, CHAR_VITAL,(CHAR_getInt( toindex, CHAR_VITAL)+atoi(mun)*100)); + CHAR_setInt( toindex, CHAR_STR,(CHAR_getInt( toindex, CHAR_STR)-atoi(mun)*10)); + CHAR_setInt( toindex, CHAR_TOUGH,(CHAR_getInt( toindex, CHAR_TOUGH)-atoi(mun)*10)); + CHAR_setInt( toindex, CHAR_VITAL,(CHAR_getInt( toindex, CHAR_VITAL)+atoi(mun)*5)); + beat|=BEATITUDE_VITAL; + } + }else if(strcmp( beatitude, "")==0){ + if(CHAR_getInt( toindex, CHAR_BEATITUDE)&BEATITUDE_STR){ + CHAR_talkToCli( charaindex, -1, "ijˣ", CHAR_COLORYELLOW); + return; + }else{ + sprintf(token, "%s%d", CHAR_getChar( toindex, CHAR_NAME),atoi(mun)); + CHAR_setInt( toindex, CHAR_STR, (CHAR_getInt( toindex, CHAR_STR)+atoi(mun)*100)); + CHAR_setInt( toindex, CHAR_TOUGH,(CHAR_getInt( toindex, CHAR_TOUGH)-atoi(mun)*10)); + CHAR_setInt( toindex, CHAR_VITAL,(CHAR_getInt( toindex, CHAR_VITAL)+atoi(mun)*3)); + beat|=BEATITUDE_STR; + } + }else if(strcmp( beatitude, "")==0){ + if(CHAR_getInt( toindex, CHAR_BEATITUDE)&BEATITUDE_TOUGH){ + CHAR_talkToCli( charaindex, -1, "ijˣ", CHAR_COLORYELLOW); + return; + }else{ + sprintf(token, "%s%d", CHAR_getChar( toindex, CHAR_NAME),atoi(mun)); + CHAR_setInt( toindex, CHAR_TOUGH, (CHAR_getInt( toindex, CHAR_TOUGH)+atoi(mun)*100)); + CHAR_setInt( toindex, CHAR_STR,(CHAR_getInt( toindex, CHAR_STR)-atoi(mun)*10)); + CHAR_setInt( toindex, CHAR_VITAL,(CHAR_getInt( toindex, CHAR_VITAL)+atoi(mun)*3)); + beat|=BEATITUDE_TOUGH; + } + }else if(strcmp( beatitude, "")==0){ + if(CHAR_getInt( toindex, CHAR_BEATITUDE)&BEATITUDE_DEX){ + CHAR_talkToCli( charaindex, -1, "ijˣ", CHAR_COLORYELLOW); + return; + }else{ + sprintf(token, "%sٶ%d", CHAR_getChar( toindex, CHAR_NAME),atoi(mun)); + CHAR_setInt( toindex, CHAR_DEX, (CHAR_getInt( toindex, CHAR_DEX)+atoi(mun)*100)); + beat|=BEATITUDE_DEX; + } + }else{ + sprintf(token, "%sǰΪ:%d,:%d,:%d,:%d", CHAR_getChar( toindex, CHAR_NAME), + CHAR_getInt( toindex, CHAR_VITAL), + CHAR_getInt( toindex, CHAR_STR), + CHAR_getInt( toindex, CHAR_TOUGH), + CHAR_getInt( toindex, CHAR_DEX)); + CHAR_talkToCli( charaindex, -1, token, CHAR_COLORYELLOW); + return; + } + CHAR_talkToCli( charaindex, -1, "׳ʿˮ", CHAR_COLORYELLOW); + CHAR_setInt( toindex, CHAR_BEATITUDE,beat); + CHAR_talkToCli( charaindex, -1, token, CHAR_COLORYELLOW); + int i; + for( i = 0; i < CHAR_MAXPETHAVE; i ++ ){ + if( CHAR_getCharPet( charaindex, i ) == toindex )break; + } + if( i == CHAR_MAXPETHAVE )return; + if(strstr(CHAR_getChar(toindex,CHAR_NAME),"")==NULL){ + char petnamebuf[64]; + sprintf(petnamebuf,"%s",CHAR_getChar(toindex,CHAR_NAME)); + CHAR_setChar(toindex,CHAR_NAME,petnamebuf); + } + CHAR_complianceParameter( toindex ); + snprintf( token, sizeof( token ), "K%d", i ); + CHAR_sendStatusString( charaindex, token ); + snprintf( token, sizeof( token ), "W%d", i ); + CHAR_sendStatusString( charaindex, token ); + + //CHAR_talkToCli( charaindex, -1, token, CHAR_COLORYELLOW); + CHAR_DelItem( charaindex, haveitemindex); + +#ifdef _MAX_BEATITUDE_BUFF + int mybeati = CHAR_getInt( toindex, CHAR_BEATITUDE); + int mypetid = CHAR_getInt( toindex, CHAR_PETID); + char ex_vit[12],ex_str[12],ex_tou[12],ex_dex[12]; + getStringFromIndexWithDelim( maxbuf, "-", 1, ex_vit, sizeof(ex_vit)); + getStringFromIndexWithDelim( maxbuf, "-", 2, ex_str, sizeof(ex_str)); + getStringFromIndexWithDelim( maxbuf, "-", 3, ex_tou, sizeof(ex_tou)); + getStringFromIndexWithDelim( maxbuf, "-", 4, ex_dex, sizeof(ex_dex)); + + + if(mybeati&BEATITUDE_VITAL && mybeati&BEATITUDE_STR && mybeati&BEATITUDE_TOUGH && mybeati&BEATITUDE_DEX){ + + //sprintf(token, "%s%d", CHAR_getChar( toindex, CHAR_NAME),atoi(ex_vit)); + CHAR_setInt( toindex, CHAR_VITAL,(CHAR_getInt( toindex, CHAR_VITAL)+atoi(ex_vit)*100)); + + //sprintf(token, "%s%d", CHAR_getChar( toindex, CHAR_NAME),atoi(ex_str)); + CHAR_setInt( toindex, CHAR_STR, (CHAR_getInt( toindex, CHAR_STR)+atoi(ex_str)*100)); + + //sprintf(token, "%s%d", CHAR_getChar( toindex, CHAR_NAME),atoi(ex_tou)); + CHAR_setInt( toindex, CHAR_TOUGH, (CHAR_getInt( toindex, CHAR_TOUGH)+atoi(ex_tou)*100)); + + //sprintf(token, "%sٶ%d", CHAR_getChar( toindex, CHAR_NAME),atoi(ex_dex)); + CHAR_setInt( toindex, CHAR_DEX, (CHAR_getInt( toindex, CHAR_DEX)+atoi(ex_dex)*100)); + + CHAR_talkToCli( charaindex, -1, "ףBUFFЧԭʼˣ", CHAR_COLORRED); + + int j; + for( j = 0; j < CHAR_MAXPETHAVE; j ++ ){ + if( CHAR_getCharPet( charaindex, j ) == toindex )break; + } + if( j == CHAR_MAXPETHAVE )return; + if(strstr(CHAR_getChar(toindex,CHAR_NAME),"")==NULL){ + char petnamebuf[64]; + sprintf(petnamebuf,"%s",CHAR_getChar(toindex,CHAR_NAME)); + CHAR_setChar(toindex,CHAR_NAME,petnamebuf); + } + CHAR_complianceParameter( toindex ); + snprintf( token, sizeof( token ), "K%d", j ); + CHAR_sendStatusString( charaindex, token ); + snprintf( token, sizeof( token ), "W%d", j ); + CHAR_sendStatusString( charaindex, token ); + } + +#endif +} + +void ITEM_useDelRenameItem( int charaindex, int toindex, int haveitemindex) +{ + int itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + if(!ITEM_CHECKINDEX(itemindex)) return; + int toitemindex = CHAR_getItemIndex( charaindex, 9); + if(!ITEM_CHECKINDEX(toitemindex)) return; + if(strcmp(ITEM_getChar(toitemindex,ITEM_SECRETNAME),ITEM_getChar(toitemindex,ITEM_NAME))!=0){ + ITEM_setChar(toitemindex,ITEM_SECRETNAME,ITEM_getChar(toitemindex,ITEM_NAME)); + ITEM_setChar(toitemindex,ITEM_CDKEY,""); + CHAR_sendItemDataOne( charaindex, 9); + CHAR_DelItem( charaindex, haveitemindex); + CHAR_talkToCli( charaindex, -1, "ĵһԶѻԭɹʹħٴԶơ", CHAR_COLORYELLOW); + }else{ + CHAR_talkToCli( charaindex, -1, "ĵһԶƣ޷лԭ", CHAR_COLORYELLOW); + } +} + +void ITEM_DANMM( int charaindex, int toindex, int haveitemindex) +{ + int itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + int fd = getfdFromCharaIndex( charaindex); + int i,j,petindex,petid,ret,mmtype; + char *itemarg = ITEM_getChar(itemindex,ITEM_ARGUMENT); + char itembuf[64],itembuff[64]; + getStringFromIndexWithDelim( itemarg, "|", 1, itembuf, sizeof(itembuf)); + mmtype=atoi(itembuf); + getStringFromIndexWithDelim( itemarg, "|", 2, itembuf, sizeof(itembuf)); + strcpy(itembuff,itembuf); + char msgbuf[64]; + for( i = 0 ;i < CHAR_MAXPETHAVE ; i++) { + petindex = CHAR_getCharPet( charaindex, i); + if( petindex == -1 ) + break; + } + + if( i == CHAR_MAXPETHAVE ){ + snprintf( msgbuf,sizeof( msgbuf), ""); + CHAR_talkToCli( charaindex, -1, msgbuf, CHAR_COLORYELLOW); + return; + } + + if(mmtype==1) + petid = 1479; + else if(mmtype==2) + petid = 2547; + else + return; + + int enemynum = ENEMY_getEnemyNum(); + + for( i = 0; i < enemynum; i ++ ) { + if( ENEMY_getInt( i, ENEMY_ID ) == petid ) + //if( ENEMY_getInt( i, ENEMY_TEMPNO ) == petid ) + break; + } + + if( i == enemynum ) + return; + + ret = ENEMY_createPetFromEnemyIndex( charaindex, i); + for( i = 0; i < CHAR_MAXPETHAVE; i ++ ) { + if( CHAR_getCharPet( charaindex, i ) == ret ) + break; + } + if( i == CHAR_MAXPETHAVE ) + i = 0; + int petwork[4] = {0,0,0,0}; + if(strstr(itembuff,"")!=NULL) petwork[3]=50; + if(strstr(itembuff,"")!=NULL) petwork[0]=50; + if(strstr(itembuff,"")!=NULL) petwork[1]=50; + if(strstr(itembuff,"")!=NULL) petwork[2]=50; + if( CHAR_CHECKINDEX( ret ) == TRUE ){ + while(CHAR_getInt( ret, CHAR_LV)<79){ // + int LevelUpPoint; + LevelUpPoint = ( petwork[3]<< 24) + ( petwork[0]<< 16) + ( petwork[1]<< 8) + ( petwork[2]<< 0); + CHAR_setInt( ret, CHAR_ALLOCPOINT, LevelUpPoint); + CHAR_PetLevelUp( ret ); + CHAR_PetAddVariableAi( ret, AI_FIX_PETLEVELUP ); + CHAR_setInt( ret, CHAR_LV, CHAR_getInt( ret, CHAR_LV) +1 ); + } + CHAR_setInt( ret, CHAR_HP, CHAR_getWorkInt( ret, CHAR_WORKMAXHP )); + CHAR_setMaxExpFromLevel( ret, CHAR_getInt( ret, CHAR_LV )); + CHAR_setInt(ret,CHAR_VARIABLEAI,10000); + } + + int petindex2 = CHAR_getCharPet(charaindex, i); + if( !CHAR_CHECKINDEX( petindex2) ) + return; + snprintf( msgbuf,sizeof( msgbuf), "õ%s", CHAR_getChar(petindex2,CHAR_NAME)); + CHAR_talkToCli( charaindex, -1, msgbuf, CHAR_COLORYELLOW); + for(j = 0; j < CHAR_MAXPETHAVE; j++){ + petindex = CHAR_getCharPet(charaindex, j); + if( !CHAR_CHECKINDEX( petindex) ) + continue; + CHAR_complianceParameter( petindex ); + snprintf( msgbuf, sizeof( msgbuf ), "K%d", j ); + CHAR_sendStatusString( charaindex, msgbuf ); + snprintf( msgbuf, sizeof( msgbuf ), "W%d", j ); + CHAR_sendStatusString( charaindex, msgbuf ); + } + CHAR_DelItem( charaindex, haveitemindex); + CHAR_charSaveFromConnect(charaindex, FALSE); + CHAR_talkToCli(charaindex, -1, "ϵͳΪԶ浵", CHAR_COLORRED); + LogPet( + CHAR_getChar( charaindex, CHAR_NAME ), + CHAR_getChar( charaindex, CHAR_CDKEY ), + CHAR_getChar( petindex2, CHAR_NAME), + CHAR_getInt( petindex2, CHAR_LV), + "MMGet", + CHAR_getInt( charaindex,CHAR_FLOOR), + CHAR_getInt( charaindex,CHAR_X ), + CHAR_getInt( charaindex,CHAR_Y ), + CHAR_getChar( petindex2, CHAR_UNIQUECODE) // shan 2001/12/14 + ); +} + +void ITEM_ExpLvBase( int charaindex, int exp) +{ + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE) == CHAR_TYPEPLAYER && CHAR_getInt( charaindex, CHAR_LV) >= 140 ){ + char token[256]; + int toitemindex = -1; + toitemindex = CHAR_getItemIndex( charaindex, 9); + if(ITEM_CHECKINDEX(toitemindex)){ + if( strlen(ITEM_getChar( toitemindex, ITEM_USEFUNC))>0 && strcmp(ITEM_getChar( toitemindex, ITEM_USEFUNC),"ITEM_useExpLv")==0 ){ + char* itemarg = ITEM_getChar(toitemindex,ITEM_ARGUMENT); + char buftest[128]; + int itemlv = 0; + int itemexp = 0; + int itembase = 0; + int itemlvmax = 0; + if(getStringFromIndexWithDelim(itemarg,"|", 1, buftest, sizeof(buftest)) == FALSE) + return; + itemlv = atoi(buftest); + if(getStringFromIndexWithDelim(itemarg,"|", 2, buftest, sizeof(buftest)) == FALSE) + return; + itemexp = atoi(buftest); + if(getStringFromIndexWithDelim(itemarg,"|", 3, buftest, sizeof(buftest)) == FALSE) + return; + itembase = atoi(buftest); + if(getStringFromIndexWithDelim(itemarg,"|", 4, buftest, sizeof(buftest)) == FALSE) + return; + itemlvmax = atoi(buftest); + if(itemlv>=itemlvmax){ + if(RAND(1,10)==1){ + sprintf(token,"ǰ鵤ȼLv%d޷澭顣",itemlv); + CHAR_talkToCli( charaindex, -1, token, CHAR_COLORYELLOW); + } + return; + } + itemexp = itemexp + exp/100*itembase; + int nextexp = 0; + int uplvtype = 0; + while(1){ + if(itemlv>=itemlvmax){ + break; + } + nextexp = getNeedLevelUpTbls(itemlv+1); + if(itemexp>=nextexp){ + itemlv = itemlv + 1; + itemexp = itemexp - nextexp; + uplvtype = 1; + }else{ + break; + } + } + char newitembuf[256]; + sprintf(newitembuf,"%d|%d|%d|%d",itemlv,itemexp,itembase,itemlvmax); + ITEM_setChar(toitemindex,ITEM_ARGUMENT,newitembuf); + sprintf(newitembuf,"%s[Lv%d]",ITEM_getChar(toitemindex,ITEM_NAME),itemlv); + ITEM_setChar(toitemindex,ITEM_SECRETNAME,newitembuf); + CHAR_sendItemDataOne( charaindex, 9); + if(RAND(1,10)==1){ + sprintf(token,"ǰ鵤ȼLv%dǷ飺%d",itemlv,nextexp-itemexp); + CHAR_talkToCli( charaindex, -1, token, CHAR_COLORYELLOW); + } + if(uplvtype == 1){ + sprintf(token,"鵤ĿǰĵȼLv%dٽŶ",itemlv); + CHAR_talkToCli( charaindex, -1, token, CHAR_COLORYELLOW); + } + } + } + } +} + +void ITEM_useExpLv( int charaindex, int toindex, int haveitemindex) +{ + int itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + if(!ITEM_CHECKINDEX(itemindex)) return; + if( !CHAR_CHECKINDEX( charaindex ) ) return; + if( !CHAR_CHECKINDEX( toindex ) ) return; + char *itemarg = ITEM_getChar( itemindex, ITEM_ARGUMENT); + char buftest[128]; + int itemlevel; + char token[256]; + if(getStringFromIndexWithDelim(itemarg,"|", 1, buftest, sizeof(buftest)) == FALSE) + return; + itemlevel = atoi(buftest); + if( CHAR_getInt( toindex, CHAR_WHICHTYPE) == CHAR_TYPEPLAYER) + { + /* + int myupcnt = itemlevel - CHAR_getInt( toindex, CHAR_LV); + if(myupcnt<=0){ + CHAR_talkToCli( charaindex, -1, "˾鵤ĵȼûҪõŶ", CHAR_COLORYELLOW); + return; + } + if(CHAR_GetLevelExp(toindex,itemlevel)<0){ + sprintf(token,"Ŀǰ㲻%dȼþ鵤޷ʹá",itemlevel); + CHAR_talkToCli( charaindex, -1, token, CHAR_COLORYELLOW); + return; + } + CHAR_setInt(toindex,CHAR_LV,itemlevel); + CHAR_setInt( toindex, CHAR_SKILLUPPOINT, + CHAR_getInt( toindex, CHAR_SKILLUPPOINT) + myupcnt*getSkup()); + CHAR_setInt(toindex,CHAR_EXP,RAND(100,20000)); + CHAR_complianceParameter( toindex ); + CHAR_send_P_StatusString( toindex , + CHAR_P_STRING_LV|CHAR_P_STRING_NEXTEXP|CHAR_P_STRING_DUELPOINT + ); + sprintf(token,"ϲѾͨ鵤[Lv%d]ѸLv%d",itemlevel,CHAR_getInt( toindex, CHAR_LV)); + CHAR_talkToCli( charaindex, -1, token, CHAR_COLORYELLOW); + */ + CHAR_talkToCli( charaindex, -1, "Ʒֻܸʹã", CHAR_COLORYELLOW); + return; + }else{ + if( CHAR_getInt( toindex, CHAR_PETID) == 718 || CHAR_getInt( toindex, CHAR_PETID) == 401 +#ifdef _PET_3TRANS + || CHAR_getInt( toindex, CHAR_PETID) == getMMPETID2() +#endif + ) + { + CHAR_talkToCli( charaindex, -1, "ƷܸMMʹã", CHAR_COLORYELLOW); + return; + } + int myupcnt = itemlevel - CHAR_getInt( toindex, CHAR_LV); + if(myupcnt<=0){ + CHAR_talkToCli( charaindex, -1, "˾鵤ĵȼûҪõŶ", CHAR_COLORYELLOW); + return; + } + if(CHAR_GetLevelExp(toindex,itemlevel)<0){ + sprintf(token,"Ŀǰijﲻ%dȼþ鵤޷ʹá",itemlevel); + CHAR_talkToCli( charaindex, -1, token, CHAR_COLORYELLOW); + return; + } + int j; + for( j = 1; j <= myupcnt; j ++ ){ // + CHAR_setWorkInt(toindex,CHAR_WORKJILU,1); + CHAR_PetLevelUp( toindex ); + CHAR_PetAddVariableAi( toindex, AI_FIX_PETLEVELUP ); + CHAR_setInt( toindex, CHAR_LV, CHAR_getInt( toindex, CHAR_LV) +1 ); + } + CHAR_setWorkInt(toindex,CHAR_WORKJILU,0); + CHAR_setInt(toindex,CHAR_EXP,RAND(100,20000)); + int i; + for( i = 0; i < CHAR_MAXPETHAVE; i ++ ) { + int workindex = CHAR_getCharPet( charaindex, i ); + if( workindex == toindex ){ + char token[64]; + CHAR_complianceParameter( toindex ); + snprintf( token, sizeof( token ), "K%d", i ); + CHAR_sendStatusString( charaindex, token ); + snprintf( token, sizeof( token ), "W%d", i ); + CHAR_sendStatusString( charaindex, token ); + CHAR_setInt( toindex , CHAR_HP ,CHAR_getWorkInt( toindex, CHAR_WORKMAXHP ) ); + CHAR_setInt( toindex , CHAR_MP ,CHAR_getWorkInt( toindex, CHAR_WORKMAXMP ) ); + CHAR_complianceParameter( toindex ); + snprintf( token, sizeof( token ), "K%d", i ); + CHAR_sendStatusString( charaindex, token ); + snprintf( token, sizeof( token ), "W%d", i ); + CHAR_sendStatusString( charaindex, token ); + break; + } + } + sprintf(token,"ϲij[%s]Ѿͨ鵤[Lv%d]ѸLv%d",CHAR_getChar( toindex, CHAR_NAME),itemlevel,CHAR_getInt( toindex, CHAR_LV)); + CHAR_talkToCli( charaindex, -1, token, CHAR_COLORYELLOW); + } + + CHAR_DelItem( charaindex, haveitemindex); +} + +typedef enum +{ + LUAITEM_PREOVERFUNC = ITEM_PREOVERFUNC - ITEM_FIRSTFUNCTION, + LUAITEM_POSTOVERFUNC = ITEM_POSTOVERFUNC - ITEM_FIRSTFUNCTION, + LUAITEM_WATCHFUNC = ITEM_WATCHFUNC - ITEM_FIRSTFUNCTION, + LUAITEM_USEFUNC = ITEM_USEFUNC - ITEM_FIRSTFUNCTION, + LUAITEM_ATTACHFUNC = ITEM_ATTACHFUNC - ITEM_FIRSTFUNCTION, + LUAITEM_DETACHFUNC = ITEM_DETACHFUNC - ITEM_FIRSTFUNCTION, + LUAITEM_DROPFUNC = ITEM_DROPFUNC - ITEM_FIRSTFUNCTION, + LUAITEM_PICKUPFUNC = ITEM_PICKUPFUNC - ITEM_FIRSTFUNCTION, +#ifdef _Item_ReLifeAct + LUAITEM_DIERELIFEFUNC = ITEM_DIERELIFEFUNC - ITEM_FIRSTFUNCTION, +#endif +}LUAITEM_FUNC; + +#ifdef _ITEM_LUA +void ITEM_Lua(int charaindex, int toindex, int haveitemindex){ + int itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + ITEM_Item *TM_Item = ITEM_getItemPointer(itemindex); + char funcname[48]; + memcpy(&funcname[0],ITEM_getChar(itemindex,ITEM_ARGUMENT), sizeof(funcname) ); + NPC_Lua_DoFile( getitemluafile() ); + + if(TM_Item->functable[LUAITEM_USEFUNC] != (void *)NPC_Lua_ItemUseCallBack) + { + if(TM_Item->functable[LUAITEM_USEFUNC] != NULL) + { + TM_Item->sur_functable[LUAITEM_USEFUNC] = TM_Item->functable[LUAITEM_USEFUNC]; + strcpy_s(TM_Item->sur_charfunctable[LUAITEM_USEFUNC].string, sizeof(TM_Item->sur_charfunctable[LUAITEM_USEFUNC].string), TM_Item->string[ITEM_USEFUNC].string); + }else + { + TM_Item->sur_functable[LUAITEM_USEFUNC] = (void *)NULL; + TM_Item->sur_charfunctable[LUAITEM_USEFUNC].string[0] = '\0'; + } + TM_Item->functable[LUAITEM_USEFUNC] = (void *)NPC_Lua_ItemUseCallBack; + strcpy_s(TM_Item->lua_charfunctable[LUAITEM_USEFUNC].string, sizeof(TM_Item->lua_charfunctable[LUAITEM_USEFUNC].string), funcname); + strcpy_s(TM_Item->string[ITEM_USEFUNC].string, sizeof(TM_Item->string[ITEM_USEFUNC].string), FUNCNAME_ITEMUSECALLBACK); + } + + NPC_Lua_ItemUseCallBack(charaindex, toindex, haveitemindex); +} +#endif + +#ifdef _SPECIAL_SUIT +void ITEM_SpecialCheckSuitEquip( int charaindex, int itemindex) +{ + int i, num=0; + int defCode = ITEM_getInt( itemindex, ITEM_SUITCODE); + + for( i=0; i=5){ + if(defCode>=100000){ + CHAR_setInt( charaindex , CHAR_BASEIMAGENUMBER , defCode ); + + CHAR_complianceParameter( charaindex ); + CHAR_sendCToArroundCharacter( CHAR_getWorkInt( charaindex , CHAR_WORKOBJINDEX )); + CHAR_send_P_StatusString( charaindex , CHAR_P_STRING_BASEBASEIMAGENUMBER); + } + }else{ + CHAR_setInt( charaindex, CHAR_BASEIMAGENUMBER, CHAR_getInt( charaindex, CHAR_BASEBASEIMAGENUMBER) ); + + CHAR_complianceParameter( charaindex ); + CHAR_sendCToArroundCharacter( CHAR_getWorkInt( charaindex , CHAR_WORKOBJINDEX )); + CHAR_send_P_StatusString( charaindex , CHAR_P_STRING_BASEBASEIMAGENUMBER); + } + } +} + +void ITEM_SpecialSuitEquip( int charaindex, int itemindex) +{ + int ff=0, fx=0, fy=0; + char buf[256]; + char *arg = ITEM_getChar(itemindex, ITEM_ARGUMENT ); + + if( sscanf( arg, "%d %d %d", &ff, &fx, &fy) != 3 ){ + ff = CHAR_getInt( charaindex, CHAR_FLOOR ); + fx = CHAR_getInt( charaindex, CHAR_X ); + fy = CHAR_getInt( charaindex, CHAR_Y ); + // WON ADD + if( checkUnlawWarpFloor( ff) ) { + CHAR_talkToCli(charaindex, -1, "˴޷ʹá", CHAR_COLORYELLOW); + return; + } + + sprintf( buf, "%d %d %d", ff, fx, fy); + ITEM_setChar(itemindex, ITEM_ARGUMENT, buf); + + } + char escapeshowstring[64]; + char *showstr = MAP_getfloorShowstring(ff); + if( checkUnlawWarpFloor( ff) ) { + CHAR_talkToCli(charaindex, -1, "˴޷ʹá", CHAR_COLORYELLOW); + return; + } + getStringFromIndexWithDelim( showstr, "|", 1, escapeshowstring, sizeof( escapeshowstring)); + sprintf( buf, "װ¼λ(%s,%d,%d)", escapeshowstring, fx, fy); + CHAR_talkToCli(charaindex, -1, buf, CHAR_COLORYELLOW); + + ITEM_SpecialCheckSuitEquip( charaindex, itemindex); +} + +void ITEM_SpecialResuitEquip( int charaindex, int itemindex) +{ + ITEM_SpecialCheckSuitEquip( charaindex, itemindex); +} +#endif + +#ifdef _MANOR_EQUIP +void ITEM_CheckManorEquip( int charaindex, int itemindex) +{ + int floor = CHAR_getWorkInt( charaindex, CHAR_WORKFMFLOOR); + + if(floor == ITEM_getInt( itemindex, ITEM_SUITCODE)){ + char *arg = ITEM_getChar(itemindex, ITEM_ARGUMENT ); + ITEM_setInt( itemindex, ITEM_MAGICID, atoi(arg)); + }else{ + ITEM_setInt( itemindex, ITEM_MAGICID, -1); + } + int i; + for(i=0;i0){ + CHAR_setInt( charaindex , CHAR_AMPOINT, CHAR_getInt( charaindex , CHAR_AMPOINT)+atoi(itemarg)); + +#ifdef _AMPOINT_LOG + LogAmPoint(CHAR_getChar( charaindex, CHAR_NAME ), + CHAR_getChar( charaindex, CHAR_CDKEY ), + atoi(itemarg), + CHAR_getInt( charaindex, CHAR_AMPOINT ), + "(֧Ʊ)", + CHAR_getInt( charaindex,CHAR_FLOOR), + CHAR_getInt( charaindex,CHAR_X ), + CHAR_getInt( charaindex,CHAR_Y )); +#endif + + sprintf( token, "ûֵ%d,ĿǰӵлֵΪ%d!", atoi(itemarg), CHAR_getInt( charaindex , CHAR_AMPOINT)); + CHAR_talkToCli( charaindex, -1, token, CHAR_COLORYELLOW ); + + CHAR_DelItem( charaindex, haveitemindex); + }else{ + char buf[256]; + int fd = getfdFromCharaIndex(charaindex); + + CHAR_setWorkInt(charaindex, CHAR_WORKITEMINDEX, itemindex); + + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGEANDLINEINPUT, + WINDOW_BUTTONTYPE_OKCANCEL, + CHAR_WINDOWTYPE_NULL_CHECK, + -1, + makeEscapeString( "ҪдĻ֧Ʊ(ַֹ֣)\n", buf, sizeof(buf))); + } +} +#endif diff --git a/item/item_gen.c b/item/item_gen.c new file mode 100644 index 0000000..382db45 --- /dev/null +++ b/item/item_gen.c @@ -0,0 +1,1524 @@ +/*********************************************** + * ʧ ة + **********************************************/ +#include "version.h" +#include +#include +#include +#include +#include +#include +#include + +#include "configfile.h" +#include "util.h" +#include "buf.h" + +#include "char.h" +#include "item.h" +#include "item_gen.h" +#include "enemy.h" +#include "log.h" +#include "saacproto_cli.h" +#include "family.h" +#include "magic_base.h" + +#define DEBUGPRINT 0 +#define DEBUGPRINT_DETAIL 0 + +// shan begin +#define FOOD_HP_RATE 200 +#define FOOD_MP_RATE 200 +#define FOOD_SUCCESS_RATE 150 +#define FOOD_TURN_ADDPOINT 1 +// shan end + +static int ITEM_getTableNum( int num); + +/* ټ㼰MAX */ +#define ITEM_ATOMIND_MAX 1000 +// shan add +#define ITEM_ATOMIND_FM_MAX 4000 + +#define ITEM_RANDRANGEDOM 1000 +#define ITEM_RANDRANGEDOM_BASE 0 +// shan add +#define ITEM_FM_RANDRANGEDOM 4000 + +/*********************************************** + * (ITEM_GEN_RAND_MIN/1000) * ITEN_GEN_SEARCH_MIN + * - (ITEM_GEN_RAND_MAX/1000) * ITEN_GEN_SEARCH_MAX + * ľ꼰༰ټ㼰 ëԻDZئ£ + **********************************************/ + +/* ټ㼰 ¼ĸة༰ ߨߨ */ +#define ITEM_GEN_RAND_MIN 700 +#define ITEM_GEN_RAND_MAX 1200 + +/* ʧ ةëټ㼰༰ (double) */ +#define ITEN_GEN_SEARCH_MIN (0.7) +#define ITEN_GEN_SEARCH_MAX (1.10) + +static struct tagItemSearchRangeTable { + double searchmin; + double searchmax; +}ItemSearchTable[2] = { +// { 0.7, 1.1}, +// shan add +// { 0.7, 1.3}, +// { 0.5, 1.5} + { 0.8, 1.2}, + { 0.7, 1.3} +}; + +static struct tagItemRandRangeTable { + int randmin; + int randmax; +}ItemRandTable[2] = { +// { 700, 1200}, + { 700, 1300}, + { 900, 1100} +}; + +#define ITEM_GEN_RATE 0.7 + +static struct _tagItemRandRangeTableForItem { + int num; /* ټ㼰¼ͼ */ + int minnum; /* ¼ Ի°Min */ + int maxnum; /* ¼ Ի°MAX num +ݼ¼ͼ*ITEM_GEN_RATE) */ + double rate; /* maxnum / num*/ +}ItemRandTableForItem[] = { + { 10, 0,0,0 }, + { 30, 0,0,0 }, + { 65, 0,0,0 }, + { 125, 0,0,0 }, + { 205, 0,0,0 }, + { 305, 0,0,0 }, + { 425, 0,0,0 }, + { 565, 0,0,0 }, + { 725, 0,0,0 }, + { 905, 0,0,0 }, + { 1125, 0,0,0 }, // shan add + { 1354, 0,0,0 }, + { 1594, 0,0,0 }, + { 1825, 0,0,0 }, + { 2105, 0,0,0 }, + { 2405, 0,0,0 }, + { 2725, 0,0,0 }, + { 3065, 0,0,0 }, + { 3425, 0,0,0 }, + { 3805, 0,0,0 } +}; + +#define ATOM_LEVEL_MAX 16 +struct item_atom +{ + char name[32]; + unsigned int name_hash; + int magicflg; +}; + + +struct item_atom *item_atoms; +int item_atoms_size; +#define MAX_ITEM_ATOMS_SIZE 256 + +struct item_ingindtable { + double data[MAX_ITEM_ATOMS_SIZE]; + int index; + int num; +}; + +static int ITEM_getAtomIndexByName( char *nm ) // زȡزindex +{ + int i; + unsigned int h = hashpjw( nm ); + for( i = 0; i < item_atoms_size; i ++ ){ + if( item_atoms[i].name_hash == h && + strcmp( item_atoms[i].name, nm) == 0 ){ + return i; + } + } + return -1; +} + +#ifdef _ITEMTBL_STAIC +extern ITEM_table ITEM_tbl[24000]; +#else +extern ITEM_table *ITEM_tbl; +#endif + +struct ingcache +{ + int use; +#define MAXING_ONE 5 + int inguse; + int canmergefrom; + int canmergeto; + int hitnum; + int ingind[MAXING_ONE]; + int ingval[MAXING_ONE]; +}; + +int ITEM_initRandTable( void) +{ + int i; + for( i = 0; i < arraysizeof( ItemRandTableForItem); i ++) { + if( i == 0 ) ItemRandTableForItem[i].minnum = 0; + else { + ItemRandTableForItem[i].minnum = ItemRandTableForItem[i-1].maxnum+1; + } + if( i + 1 != arraysizeof( ItemRandTableForItem)) { + ItemRandTableForItem[i].maxnum = + ItemRandTableForItem[i].num + + (ItemRandTableForItem[i+1].num - ItemRandTableForItem[i].num) + *ITEM_GEN_RATE; + + } + else { + // shan add + ItemRandTableForItem[i].maxnum = 4000; + //ItemRandTableForItem[i].maxnum = 1000; + } + ItemRandTableForItem[i].rate = ItemRandTableForItem[i].maxnum + / (double)ItemRandTableForItem[i].num; + } + /*for( i = 0; i < arraysizeof( ItemRandTableForItem); i ++) { + print( "\ntable num:[%d] min:[%d] max:[%d] rate:[%3.3f] ", + ItemRandTableForItem[i].num, + ItemRandTableForItem[i].minnum, + ItemRandTableForItem[i].maxnum, + ItemRandTableForItem[i].rate); + }*/ + return TRUE; +} + +static struct ingcache *icache; +int icache_num; + +int ITEM_initItemIngCache( void ) +{ + int i; +// print ( "\nʼƷ: Ʒ:%d ", ITEM_getItemMaxIdNum() ); + icache_num = ITEM_getItemMaxIdNum( ); + print(" :%d ", icache_num); + icache = calloc(1, sizeof( struct ingcache ) * icache_num ); + if( icache == NULL ){ + print( "ʼƷ: ûƷ\n" ); + return FALSE; + } + + print(" %4.2f MB ռ...", sizeof( struct ingcache ) * icache_num /1024.0/1024.0); + + remove( "old_icache.txt"); + memset( icache, 0, icache_num * sizeof( struct ingcache) ); + for( i=0; i= MAX_ITEM_ATOMS_SIZE ){ + print( "ʼƷɷ: Ʒɷ̫\n" ); + return FALSE; + } + + item_atoms_size = count; + print( "ʼƷɷ: ȡ %d Ʒɷ...", count ); + + return TRUE; +} + +/* + + Ѽ + + base 100 ƥ min 0.7 ƥ max 1.3 գ + 70 ~ 130 £Իؤ + ԪئԻ¾ľئмƥ + ʧ ةûƻ by ringo 1999Oct1 + 1000мmin_rate,max_rateƥ + double ֧float ֧֧мƥئУ + */ +static int +ITEM_randRange( int base, int min_rate , int max_rate ) +{ + int minnum; + int maxnum; + int range; + + if( min_rate > max_rate) { + int tmp; + tmp = min_rate; + min_rate = max_rate; + max_rate = tmp; + } + minnum = rint((double)base / ITEM_RANDRANGEDOM * min_rate); + maxnum = rint((double)base / ITEM_RANDRANGEDOM * max_rate); + range = ( maxnum - minnum ); + + if( min_rate == max_rate && min_rate == 0 ) return 0; + if( range == 0 ) return base; + if( range < 0 ) return 0; + return minnum + RAND( 0, range); +} + +typedef int (*FUNC)( const void *, const void * ); + +static int cmprutine( double *p1, double *p2) +{ + if( *p1 < *p2 ) return -1; + if( *p1 > *p2 ) return 1; + return 0; +} +/* + * мؤ + * ߯Ի ʹئ׾ + * ĩƻͻ + * table Уƻʣ + */ + +static void ITEM_simplify_atoms( struct item_ingindtable *inds, int num, + int *retinds, int *retvals, int petindex, int alchemist) +{ + //int newinds[MAX_ITEM_ATOMS_SIZE]; + //int newvals[MAX_ITEM_ATOMS_SIZE]; + int i; + double oddstable[] = { + 0.1, + 0.25, + 0.35, + 0.4, + 0.42, + 0.44, + 0.46, + 0.47, + 0.48, + 0.49, + 0.5, + 0.51, + 0.52, + 0.53 + }; + + for( i = 0; i < num; i ++ ) { + int datacnt = (inds + i)->num; + if( datacnt > 1 ) { + int j; + qsort( (inds + i)->data, datacnt, + sizeof( double ), (FUNC)cmprutine); + for( j = 1; j < datacnt; j ++ ) { + int tablenum; + double rate; + tablenum = ITEM_getTableNum( (inds + i)->data[j-1]); + rate = ItemRandTableForItem[tablenum].rate / ItemRandTableForItem[0].rate; + (inds + i)->data[j] += (inds + i)->data[j-1] * oddstable[j-1] * rate; + } + } + *(retinds + i) = ( inds + i)->index; + *(retvals + i) = (int)( inds + i)->data[ datacnt-1]; + // shan add begin + if( petindex != -1 ){ + if (CHAR_getInt(petindex, CHAR_PETFAMILY) == 1){ + if( *( retvals + i) > ITEM_ATOMIND_FM_MAX ){ + *( retvals + i) = ITEM_ATOMIND_FM_MAX; + } + }else{ + if( *( retvals + i) > ITEM_ATOMIND_MAX ){ + *( retvals + i) = ITEM_ATOMIND_MAX; + } + } + } + // shan end + } +} + +/* +PET_ADD_INGRED( nm,vl1,vl2,vl3) +{ + if( strlen( ENEMYTEMP_getChar( petarray, nm)) != 0 ) + { + fixatom[ingnum] =ITEM_getAtomIndexByName( ENEMYTEMP_getChar( petarray, nm) ); + if( fixatom[ingnum] < 0 ) + { + print( "\nfucking atom:[%s] for pet id %d", ENEMYTEMP_getChar( petarray, nm), petid ); + continue; + } + + baseup[ingnum] = ENEMYTEMP_getInt( petarray, vl1); + minadd[ingnum] = ENEMYTEMP_getInt( petarray, vl2); + maxadd[ingnum] = ENEMYTEMP_getInt( petarray, vl3); + + if( petindex != -1) + { + if( CHAR_getInt(petindex, CHAR_PETFAMILY) == 1 ) + { + int ownerindex = CHAR_getWorkInt(petindex, CHAR_WORKPLAYERINDEX); + if (!CHAR_CHECKINDEX(ownerindex)) + { + print("ownerindex err!\n"); + return; + } + if( CHAR_getInt( ownerindex, CHAR_FMLEADERFLAG) != FMMEMBER_LEADER) + { + print("\n Pet Ownerindex Error"); + return; + } + baseup[ingnum] = PetLv[getFmLv(ownerindex)]; + } + } + + if( minadd[ingnum] > maxadd[ingnum] ) + { + int tmp = minadd[ingnum]; + minadd[ingnum] = maxadd[ingnum];maxadd[ingnum] = tmp; + } + + if( CHAR_getInt(petid, CHAR_PETFAMILY) == 1 ) + { + if( minadd[ingnum]<0 ) + minadd[ingnum] = ITEM_FM_RANDRANGEDOM; + if( maxadd[ingnum]<0 ) + maxadd[ingnum] = ITEM_FM_RANDRANGEDOM; + } + else + { + if( minadd[ingnum]<0 ) + minadd[ingnum] = ITEM_RANDRANGEDOM; + if( maxadd[ingnum]<0 ) + maxadd[ingnum] = ITEM_RANDRANGEDOM; + } + ingnum++; + } +} +*/ + +/* + ʸIDգѼĤɬëԻʣ + + int *fixuse : ¦ѣ ëԻëľ + + int *fixatom : ټ帲Ĥئ + int *baseup : µң + int *minadd : ң µң + int *maxadd : ң µң + + */ + +static void +ITEM_merge_getPetFix( int petid, int *fixuse, int *fixatom, + int *baseup, + int *minadd, + int *maxadd, + int petindex, + int *fm_fix) +{ + int i; + int ingnum = 0; + int petarray; + +// shan begin +#define FamilyLv 11 + //int PetLv[FamilyLv]; + //for(i=0; i maxadd[ingnum] ) { int tmp = minadd[ingnum];minadd[ingnum] = maxadd[ingnum];maxadd[ingnum] = tmp;}if( CHAR_getInt(petid, CHAR_PETFAMILY) == 1 ){if( minadd[ingnum]<0 ) minadd[ingnum] = ITEM_FM_RANDRANGEDOM;if( maxadd[ingnum]<0 ) maxadd[ingnum] = ITEM_FM_RANDRANGEDOM;}else{if( minadd[ingnum]<0 ) minadd[ingnum] = ITEM_RANDRANGEDOM;if( maxadd[ingnum]<0 ) maxadd[ingnum] = ITEM_RANDRANGEDOM;}ingnum++;} +#define PET_ADD_INGRED( nm,vl1,vl2,vl3) if( strlen( ENEMYTEMP_getChar( petarray, nm)) != 0 ) { fixatom[ingnum] =ITEM_getAtomIndexByName( ENEMYTEMP_getChar( petarray, nm) ); if( fixatom[ingnum] < 0 ){ print( "\nfucking atom:[%s] for pet id %d", ENEMYTEMP_getChar( petarray, nm), petid ); continue;} baseup[ingnum] = ENEMYTEMP_getInt( petarray, vl1); minadd[ingnum] = ITEM_RANDRANGEDOM_BASE + ENEMYTEMP_getInt( petarray, vl2); maxadd[ingnum] = ITEM_RANDRANGEDOM_BASE + ENEMYTEMP_getInt( petarray, vl3); if( petindex != -1){ if( CHAR_getInt(petindex, CHAR_PETFAMILY) == 1 ){ int ownerindex = CHAR_getWorkInt(petindex, CHAR_WORKPLAYERINDEX); if (!CHAR_CHECKINDEX(ownerindex)){print("ownerindex err!\n");return;}if( CHAR_getInt( ownerindex, CHAR_FMLEADERFLAG) != FMMEMBER_LEADER){print("\n Pet Ownerindex Error");return;}baseup[ingnum] = PetLv[getFmLv(ownerindex)];}}if( minadd[ingnum] > maxadd[ingnum] ) { int tmp = minadd[ingnum];minadd[ingnum] = maxadd[ingnum];maxadd[ingnum] = tmp;}if( CHAR_getInt(petid, CHAR_PETFAMILY) == 1 ){if( minadd[ingnum]<0 ) minadd[ingnum] = ITEM_FM_RANDRANGEDOM;if( maxadd[ingnum]<0 ) maxadd[ingnum] = ITEM_FM_RANDRANGEDOM;}else{if( minadd[ingnum]<0 ) minadd[ingnum] = ITEM_RANDRANGEDOM;if( maxadd[ingnum]<0 ) maxadd[ingnum] = ITEM_RANDRANGEDOM;}ingnum++;} +#else +#define PET_ADD_INGRED( nm,vl1,vl2,vl3) if( strlen( ENEMYTEMP_getChar( petarray, nm)) != 0 ) { fixatom[ingnum] =ITEM_getAtomIndexByName( ENEMYTEMP_getChar( petarray, nm) ); if( fixatom[ingnum] < 0 ){ print( "\nfucking atom:[%s] for pet id %d", ENEMYTEMP_getChar( petarray, nm), petid ); continue;} baseup[ingnum] = ENEMYTEMP_getInt( petarray, vl1); minadd[ingnum] = ENEMYTEMP_getInt( petarray, vl2); maxadd[ingnum] = ENEMYTEMP_getInt( petarray, vl3); if( petindex != -1){ if( CHAR_getInt(petindex, CHAR_PETFAMILY) == 1 ){ int ownerindex = CHAR_getWorkInt(petindex, CHAR_WORKPLAYERINDEX); if (!CHAR_CHECKINDEX(ownerindex)){print("ownerindex err!\n");return;}if( CHAR_getInt( ownerindex, CHAR_FMLEADERFLAG) != 1){print("\n Pet Ownerindex Error");return;}baseup[ingnum] = PetLv[getFmLv(ownerindex)];}}if( minadd[ingnum] > maxadd[ingnum] ) {int tmp = minadd[ingnum];minadd[ingnum] = maxadd[ingnum];maxadd[ingnum] = tmp;}if( CHAR_getInt(petid, CHAR_PETFAMILY) == 1 ){if( minadd[ingnum]<0 ) minadd[ingnum] = ITEM_FM_RANDRANGEDOM;if( maxadd[ingnum]<0 ) maxadd[ingnum] = ITEM_FM_RANDRANGEDOM;}else{if( minadd[ingnum]<0 ) minadd[ingnum] = ITEM_RANDRANGEDOM;if( maxadd[ingnum]<0 ) maxadd[ingnum] = ITEM_RANDRANGEDOM;}ingnum++;} +#endif + + PET_ADD_INGRED( E_T_ATOMFIXNAME1, E_T_ATOMBASEADD1, E_T_ATOMFIXMIN1, E_T_ATOMFIXMAX1); + PET_ADD_INGRED( E_T_ATOMFIXNAME2, E_T_ATOMBASEADD2, E_T_ATOMFIXMIN2, E_T_ATOMFIXMAX2); + PET_ADD_INGRED( E_T_ATOMFIXNAME3, E_T_ATOMBASEADD3, E_T_ATOMFIXMIN3, E_T_ATOMFIXMAX3); + PET_ADD_INGRED( E_T_ATOMFIXNAME4, E_T_ATOMBASEADD4, E_T_ATOMFIXMIN4, E_T_ATOMFIXMAX4); + PET_ADD_INGRED( E_T_ATOMFIXNAME5, E_T_ATOMBASEADD5, E_T_ATOMFIXMIN5, E_T_ATOMFIXMAX5); + } + + if( CHAR_getInt(petindex, CHAR_PETFAMILY) == 1 ) { + int ownerindex = CHAR_getWorkInt(petindex, CHAR_WORKPLAYERINDEX); + if( CHAR_CHECKINDEX(ownerindex) ) { + *fm_fix = PetLv[getFmLv(ownerindex)]; + } + } + + *fixuse = ingnum; + return; +} + +/* + * ʧ ةؤFALSEë߯ + */ + +static BOOL ITEM_merge_checkitem( ITEM_Item *items, int itemsnum, int id) +{ + int loop; + for( loop = 0; loop < itemsnum; loop ++ ) { + if( items[loop].data[ITEM_ID] == id ) break; + } + if( loop == itemsnum ) return TRUE; + return FALSE; +} + +static int ITEM_merge_with_retry( ITEM_Item *items,int itemsnum, + int *ingindtable, int ingnum, + int *ingtable, int searchtable, int petindex ) +{ + + int ideal; + int idel_num[5][5] = { { 0}, + { 250,0 }, + { 400,150,0}, + { 700,260,70,0}, + { 740,500,200,40,0} + }; + int endflg[5]; + BOOL first = TRUE; + int extractcnt = 0; +#define MAXMATCH 2048 + int matchid[MAXMATCH]; + int i,j,k; + if( ingnum > 5 ) ideal = 5; + else ideal = ingnum; + memset( endflg, 0, sizeof( endflg)); + while( 1 ) { + int r = RAND( 0, 999); + int extractnum; + int match = 0; + if( extractcnt >= ideal ) break; + // ϳɵߵı + for( extractnum = 0; extractnum < ideal; extractnum ++ ) { + if( r >= idel_num[ideal-1][extractnum] ) { + break; + } + } + if( endflg[extractnum] == TRUE ) continue; + endflg[extractnum] = TRUE; + extractcnt++; + extractnum = ideal - ( extractnum ); + + if( first ) { + for( i = 0; i < icache_num; i++ ){ // ѰȫITEM + if( icache[i].use && icache[i].canmergeto) { // ǿɺϳɵITEM + icache[i].hitnum = 0; + for( j = 0; j < icache[i].inguse; j ++ ) { // ITEMIJ + for( k = 0; k < ingnum ; k ++){ // ϳɵIJ + if( icache[i].ingind[j] == ingindtable[k] ) { // Ϸ + if( searchtable == 0 ) { // ߺϳɵĻ + int tablenum = ITEM_getTableNum( ingtable[k]); // ϵȼ + // shan begin + if( petindex != -1){ + if( CHAR_getInt(petindex, CHAR_PETFAMILY) == 1 ){ // ػ޵Ļ + int ownerindex = CHAR_getWorkInt(petindex, CHAR_WORKPLAYERINDEX); + int familyLevel = getFmLv(ownerindex); + if (!CHAR_CHECKINDEX(ownerindex)){ + print("!\n"); + return -1; + } +#ifdef _FMVER21 + if( CHAR_getInt( ownerindex, CHAR_FMLEADERFLAG) != FMMEMBER_LEADER){ +#else + if( CHAR_getInt( ownerindex, CHAR_FMLEADERFLAG) != 1){ +#endif + print("\n "); + return -1; + } + // + if( icache[i].ingval[j] <= ingtable[k]*ItemRandTableForItem[tablenum].rate && + icache[i].ingval[j] >= ingtable[k]*(1/ItemRandTableForItem[tablenum].rate) && + icache[i].ingval[j] <= ItemRandTableForItem[familyLevel+9].maxnum) { + icache[i].hitnum++; + break; + } + }else{ // ػ޵Ļ + float toplimit = ingtable[k]*ItemRandTableForItem[tablenum].rate; + if( toplimit > 1000) toplimit = 1000; + // + if( icache[i].ingval[j] <= toplimit && + icache[i].ingval[j] >= ingtable[k]*(1/ItemRandTableForItem[tablenum].rate)){ + icache[i].hitnum++; + break; + } + } + } + // shan end + }else { // ʳϳɵĻ + // shan begin + if( CHAR_getInt(petindex, CHAR_PETFAMILY) == 1 ){ + int ownerindex = CHAR_getWorkInt(petindex, CHAR_WORKPLAYERINDEX); + int familyLevel = getFmLv(ownerindex); + if (!CHAR_CHECKINDEX(ownerindex)){ + print("!\n"); + return -1; + } +#ifdef _FMVER21 + if( CHAR_getInt( ownerindex, CHAR_FMLEADERFLAG) != FMMEMBER_LEADER){ +#else + if( CHAR_getInt( ownerindex, CHAR_FMLEADERFLAG) != 1){ +#endif + print("\n "); + return -1; + } + if( ingtable[k] > ItemRandTableForItem[familyLevel+9].maxnum / + ItemSearchTable[searchtable].searchmax ){ + ingtable[k] = ItemRandTableForItem[familyLevel+9].maxnum / + ItemSearchTable[searchtable].searchmax; + } + }else{ + if( ingtable[k] > ItemRandTableForItem[9].maxnum / + ItemSearchTable[searchtable].searchmax ){ + ingtable[k] = ItemRandTableForItem[9].maxnum / + ItemSearchTable[searchtable].searchmax; + } + } + // shan end + + if( icache[i].ingval[j] <= ingtable[k]*ItemSearchTable[searchtable].searchmax && + icache[i].ingval[j] >= ingtable[k]*ItemSearchTable[searchtable].searchmin){ + icache[i].hitnum++; + break; + } + } + } + } + } + // ϵIJͬ + if( icache[i].hitnum == icache[i].inguse && icache[i].hitnum == extractnum ){ + if( ITEM_merge_checkitem(items,itemsnum,i)) { + matchid[match++] = i; + } + } + } + } + first = FALSE; + }else { + for( i = 0; i < icache_num; i++ ){ + if( icache[i].use && icache[i].canmergeto) { + if( icache[i].hitnum == icache[i].inguse && icache[i].hitnum == extractnum ){ + if( ITEM_merge_checkitem(items,itemsnum,i)) { + matchid[match++] = i; + } + } + } + } + } + if( match > 0 ) { + return matchid[ random() % match ]; + }else { + + } + } + return -1; + +} + +#ifdef _NEW_MANOR_LAW +extern struct FM_POINTLIST fmpointlist; +#endif + +int ITEM_mergeItem( int charaindex, ITEM_Item *items, int num , int money, int petid, int searchtable, int petindex, int alchemist) +{ + int i; + // shan add + int item_type = -1; + int ingnum =0; + struct item_ingindtable ingindtable[MAX_ITEM_ATOMS_SIZE]; + int sortedingindtable[MAX_ITEM_ATOMS_SIZE]; + int sortedingtable[MAX_ITEM_ATOMS_SIZE]; + /* ʸ巽Ĥ */ + int pet_fixatom[MAX_ITEM_ATOMS_SIZE]; + int pet_baseup[MAX_ITEM_ATOMS_SIZE]; + int pet_minadd[MAX_ITEM_ATOMS_SIZE]; + int pet_maxadd[MAX_ITEM_ATOMS_SIZE]; + int pet_fixuse = MAX_ITEM_ATOMS_SIZE; + int fm_fix; + int nowtime; + + nowtime = time( NULL); + // ϳɷƵ... + if( nowtime - CHAR_getWorkInt( charaindex, CHAR_WORKLASTMERGETIME) < +#ifdef _MERGE_TIME + getMergeTime() +#else + 5 +#endif + +(num-2) ) { + CHAR_setWorkInt( charaindex, CHAR_WORKLASTMERGETIME, nowtime); + CHAR_talkToCli( charaindex, -1 ,"ϳƵϢһ±ȽϺӴ", CHAR_COLORRED); + //print(" ϳƵ "); + return items[RAND( 0, (num-1))].data[ITEM_ID]; + } + CHAR_setWorkInt( charaindex, CHAR_WORKLASTMERGETIME, nowtime); + for( i = 0; i < arraysizeof( ingindtable); i ++ ) { + int j; + for( j = 0; j < MAX_ITEM_ATOMS_SIZE; j ++ ) { + ingindtable[i].data[j] = 0.0; + } + ingindtable[i].num = 0; + ingindtable[i].index = -1; + } + for(i=0; i ItemRandTableForItem[familyLevel+9].maxnum ){ + sortedingtable[i] = RAND(ItemRandTableForItem[familyLevel+9].minnum, + ItemRandTableForItem[familyLevel+9].maxnum); + } + }else{ + sortedingtable[i] = ITEM_randRange( sortedingtable[i], + ItemRandTable[searchtable].randmin , + ItemRandTable[searchtable].randmax); + } + } + else{ + if( searchtable == 0 ) { + sortedingtable[i] = ITEM_randRange( sortedingtable[i], + ((1/ItemRandTableForItem[tablenum].rate)*ITEM_MERGE_RANGEWIDTH_FORMIN) + * ITEM_RANDRANGEDOM, + ItemRandTableForItem[tablenum].rate * ITEM_MERGE_RANGEWIDTH_FORMAX + * ITEM_RANDRANGEDOM); + if(sortedingtable[i] > 905) sortedingtable[i] = 905; + } + else { + sortedingtable[i] = ITEM_randRange( sortedingtable[i], + ItemRandTable[searchtable].randmin , + ItemRandTable[searchtable].randmax); + } + } + } + // shan end + } + } + + if( ingnum == 0 ) + return -1; + { + int created; + for( i = 0 ; i < 5; i++ ) { + created = ITEM_merge_with_retry( items, num, sortedingindtable,ingnum, + sortedingtable, searchtable, petindex); + if( created >= 0 ) { + // shan begin + if( petindex != -1){ +#ifdef _FMVER21 +#else + if( CHAR_getInt( CHAR_getWorkInt(petindex, CHAR_WORKPLAYERINDEX), CHAR_FMLEADERFLAG ) > 0 ){ +#endif + int kind_num = 0; + int syndp = 0; + int fooddp = 0; + int ownerindex = CHAR_getWorkInt(petindex, CHAR_WORKPLAYERINDEX); + if (!CHAR_CHECKINDEX(ownerindex)){ + print("ownerindex err!\n"); + return -1; + } + if( searchtable == 1 ){ + + if( ITEMTBL_getInt( created, ITEM_INGVALUE0) != 0 ) kind_num++; + if( ITEMTBL_getInt( created, ITEM_INGVALUE1) != 0 ) kind_num++; + if( ITEMTBL_getInt( created, ITEM_INGVALUE2) != 0 ) kind_num++; + if( ITEMTBL_getInt( created, ITEM_INGVALUE3) != 0 ) kind_num++; + if( ITEMTBL_getInt( created, ITEM_INGVALUE4) != 0 ) kind_num++; + + fooddp = ITEMTBL_getInt( created, ITEM_INGVALUE0) + + ITEMTBL_getInt( created, ITEM_INGVALUE1) + + ITEMTBL_getInt( created, ITEM_INGVALUE2) + + ITEMTBL_getInt( created, ITEM_INGVALUE3) + + ITEMTBL_getInt( created, ITEM_INGVALUE4); +#ifndef _NEW_MANOR_LAW + #ifdef _PERSONAL_FAME // Arminius: + fooddp = sqrt(fooddp) * pow(2,kind_num-2) * RAND(0,6) / 200; + #else + fooddp = sqrt(fooddp) * pow(2,kind_num-2) * RAND(0,6) / 100; + #endif + print("FoodDP: num->%d sumdp->%d", kind_num, fooddp); + sprintf(buf, "%d", fooddp); + + #ifdef _PERSONAL_FAME // Arminius 8.30: + CHAR_earnFame(ownerindex, fooddp); + #endif + + #ifdef _FMVER21 + if( CHAR_getInt( CHAR_getWorkInt(petindex, CHAR_WORKPLAYERINDEX), CHAR_FMLEADERFLAG ) > 0 && + CHAR_getInt( CHAR_getWorkInt(petindex, CHAR_WORKPLAYERINDEX), CHAR_FMLEADERFLAG ) != FMMEMBER_APPLY ) + { + // CoolFish: 2001/10/03 + int fd = getfdFromCharaIndex(ownerindex); + saacproto_ACFixFMData_send(acfd, + CHAR_getChar(ownerindex, CHAR_FMNAME), + CHAR_getInt(ownerindex, CHAR_FMINDEX), + CHAR_getWorkInt(ownerindex, CHAR_WORKFMINDEXI), + FM_FIX_FMDEALFOOD, buf, "", + // CoolFish: 2001/10/03 + CHAR_getWorkInt(ownerindex, CHAR_WORKFMCHARINDEX), + CONNECT_getFdid(fd)); + // CHAR_getWorkInt(ownerindex, CHAR_WORKFMCHARINDEX), 0); + } + #else + saacproto_ACFixFMData_send(acfd, + CHAR_getChar(ownerindex, CHAR_FMNAME), + CHAR_getInt(ownerindex, CHAR_FMINDEX), + CHAR_getWorkInt(ownerindex, CHAR_WORKFMINDEXI), + FM_FIX_FMDEALFOOD, buf, "", + CHAR_getWorkInt(ownerindex, CHAR_WORKFMCHARINDEX), 0); + #endif +#endif + }else{ + syndp = ITEMTBL_getInt( created, ITEM_INGVALUE0) + + ITEMTBL_getInt( created, ITEM_INGVALUE1) + + ITEMTBL_getInt( created, ITEM_INGVALUE2) + + ITEMTBL_getInt( created, ITEM_INGVALUE3) + + ITEMTBL_getInt( created, ITEM_INGVALUE4); +#ifndef _NEW_MANOR_LAW + #ifdef _PERSONAL_FAME // Arminius: + syndp = syndp / 200; + #else + syndp = syndp / 100; + #endif + sprintf(buf, "%d", syndp); + + #ifdef _PERSONAL_FAME // Arminius 8.30: + CHAR_earnFame(ownerindex, syndp); + #endif + + #ifdef _FMVER21 + if( CHAR_getInt( CHAR_getWorkInt(petindex, CHAR_WORKPLAYERINDEX), CHAR_FMLEADERFLAG ) > 0 && + CHAR_getInt( CHAR_getWorkInt(petindex, CHAR_WORKPLAYERINDEX), CHAR_FMLEADERFLAG ) != FMMEMBER_APPLY ) + { + // CoolFish: 2001/10/03 + int fd = getfdFromCharaIndex(ownerindex); + saacproto_ACFixFMData_send(acfd, + CHAR_getChar(ownerindex, CHAR_FMNAME), + CHAR_getInt(ownerindex, CHAR_FMINDEX), + CHAR_getWorkInt(ownerindex, CHAR_WORKFMINDEXI), + FM_FIX_FMSYNTHESIZE, buf, "", + // CoolFish: 2001/10/03 + CHAR_getWorkInt(ownerindex, CHAR_WORKFMCHARINDEX), + CONNECT_getFdid(fd)); + } + #else + saacproto_ACFixFMData_send(acfd, + CHAR_getChar(ownerindex, CHAR_FMNAME), + CHAR_getInt(ownerindex, CHAR_FMINDEX), + CHAR_getWorkInt(ownerindex, CHAR_WORKFMINDEXI), + FM_FIX_FMSYNTHESIZE, buf, "", + CHAR_getWorkInt(ownerindex, CHAR_WORKFMCHARINDEX), 0); + #endif +#endif + } +#ifdef _FMVER21 +#else + } +#endif + } + return created; + } + } + return items[RAND( 0, (num-1))].data[ITEM_ID]; + } + return -3; +} + +int ITEM_canDigest( ITEM_Item *itm ) +{ + /* 1 󡻥ɬýľ1 + ƥئئ0 */ + if( itm->string[ITEM_INGNAME0].string[0] ) return 1; else return 0; +} + + + +int ITEM_merge_test(void) +{ + int iid,i,k; + ITEM_Item itm[1]; + + for( k = 0 ; k < 10 ; k ++ ){ + iid = 1; + for( i = 0 ; i < 20 ; i ++ ){ + ITEM_makeItem( &itm[0] , iid ); + print( "%d RETURN: %d\n", i, + // shan + iid = ITEM_mergeItem( -1, itm, 1 , 0, -1,0,-1,0) ); + } + print( "------\n" ); + } + return 0; +} + +int ITEM_mergeItem_merge( int charaindex, int petid, char *data, int petindex, int alchemist) +{ + BOOL result = FALSE; + int i; + int ret; + int cnt = 0; + int itemindexs[CHAR_MAXITEMHAVE - CHAR_STARTITEMARRAY]; + int haveitemindexs[CHAR_MAXITEMHAVE - CHAR_STARTITEMARRAY]; + // Nuke +2 1026: Avoid merge cheat + int itemflag[CHAR_MAXITEMHAVE - CHAR_STARTITEMARRAY]; + int j,collision=0; + + char buff[64]; + + ITEM_Item items[CHAR_MAXITEMHAVE - CHAR_STARTITEMARRAY]; + // Nuke +1 1026 + memset(itemflag,0,sizeof(itemflag)); + + { + int emptyindex = CHAR_findEmptyItemBox( charaindex ); + if( emptyindex == -1 ){ + CHAR_talkToCli( charaindex, -1, "ϳʱһƷλ", CHAR_COLORYELLOW); + return -1; + } + } + + for( i = CHAR_STARTITEMARRAY; i < CHAR_MAXITEMHAVE; i ++ ) { + int haveitemindex; + ret = getStringFromIndexWithDelim( data , "|", + i - CHAR_STARTITEMARRAY+1, + buff, sizeof( buff ) ); + if( ret == FALSE ) break; + haveitemindex = atoi( buff); + if( CHAR_CHECKITEMINDEX( charaindex, haveitemindex) ) { + int itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + if( ITEM_CHECKINDEX( itemindex)) { + if(ITEM_getInt(itemindex,ITEM_TIME)>0){ + CHAR_talkToCli( charaindex, -1, "ʱ޷ϳɻ", CHAR_COLORYELLOW); + return FALSE; + } +#ifdef _ITEM_INSLAY + char *code; + if( (code = ITEM_getChar( itemindex, ITEM_TYPECODE)) == "\0" ) { + if( strcmp( code, "\0") ) { + char token[256]; + snprintf( token, sizeof( token), "ƺ%sûȤ", + ITEM_getChar( itemindex, ITEM_NAME)); + CHAR_talkToCli( charaindex, -1, token, CHAR_COLORYELLOW); + return FALSE; + } + } +#endif + if( ITEM_getmergeItemFromFromITEMtabl( ITEM_getInt( itemindex, ITEM_ID)) == TRUE ){ //Ƿɺϳ + ITEM_Item *itm; + itm = ITEM_getItemPointer(itemindex); + if( itm != NULL ) { + ITEM_makeItem( &items[cnt], ITEM_getInt( itemindex, ITEM_ID)); + itemindexs[cnt] = itemindex; + haveitemindexs[cnt] = haveitemindex; + // Nuke start 1026 + for (j=0;j 1 ) { + int randtable = 0; + if( items[0].data[ITEM_TYPE] == ITEM_DISH ) { + randtable = 1; + } + ret = ITEM_mergeItem( charaindex, items, cnt, 0, petid, randtable, petindex, alchemist); + if( ret == -10) + CHAR_talkToCli( charaindex, -1, "Ƿĺϳɷ", CHAR_COLORWHITE); + CHAR_setInt( charaindex, CHAR_MERGEITEMCOUNT, + CHAR_getInt( charaindex, CHAR_MERGEITEMCOUNT)+1); + for( i = 0; i < cnt; i ++ ) { +#ifdef _ITEM_PILENUMS + int pilenum=0; + int itemindex = CHAR_getItemIndex( charaindex, haveitemindexs[i]); + if( !ITEM_CHECKINDEX( itemindex) ) continue; + pilenum = ITEM_getInt( itemindex, ITEM_USEPILENUMS); + pilenum -= 1; + ITEM_setInt( itemindex, ITEM_USEPILENUMS, pilenum); + if( pilenum <= 0 ){ +#endif + CHAR_setItemIndex( charaindex, haveitemindexs[i], -1); + CHAR_sendItemDataOne( charaindex, haveitemindexs[i]); + LogItem( + CHAR_getChar( charaindex, CHAR_NAME ), /* ƽҷ */ + CHAR_getChar( charaindex, CHAR_CDKEY ), +#ifdef _add_item_log_name // WON ADD itemlogitem + itemindexs[i], +#else + ITEM_getInt( itemindexs[i], ITEM_ID), /* ʧ ة į */ +#endif + "mergedel(ϳɾĵ)", + CHAR_getInt( charaindex,CHAR_FLOOR), + CHAR_getInt( charaindex,CHAR_X ), + CHAR_getInt( charaindex,CHAR_Y ), + ITEM_getChar( itemindexs[i], ITEM_UNIQUECODE), + ITEM_getChar( itemindexs[i], ITEM_NAME), + ITEM_getInt( itemindexs[i], ITEM_ID) + ); + ITEM_endExistItemsOne( itemindexs[i]); +#ifdef _ITEM_PILENUMS + } +#endif + } + CHAR_sendItemData( charaindex, haveitemindexs, cnt); + if( ret >= 0 ) { + int rc; + int createitemindex = ITEM_makeItemAndRegist( ret); + // shan begin + if( createitemindex != -1 ){ + if( petindex != -1){ +#ifdef _FM_LIAOLI + if(getFmLiaoLiType()==1 || CHAR_getInt(petindex, CHAR_PETFAMILY) == 1){ +#else + if( CHAR_getInt(petindex, CHAR_PETFAMILY) == 1 ){ +#endif + int ownerindex = CHAR_getWorkInt(petindex, CHAR_WORKPLAYERINDEX); + if (!CHAR_CHECKINDEX(ownerindex)){ + print("ownerindex err!\n"); + return -1; + } +#ifdef _FM_LIAOLI + if(getFmLiaoLiType()!=1 && CHAR_getInt( ownerindex, CHAR_FMLEADERFLAG) != FMMEMBER_LEADER){ +#else +#ifdef _FMVER21 + if( CHAR_getInt( ownerindex, CHAR_FMLEADERFLAG) != FMMEMBER_LEADER){ +#else + if( CHAR_getInt( ownerindex, CHAR_FMLEADERFLAG) != 1){ +#endif +#endif + print("\n Pet Ownerindex Error"); + return -1; + } + if( randtable == 1){ + char *p; + char charbuf1[512]="",charbuf2[1024]="",charbuf[128]=""; + char argbuf[256]; + int arg1 = 0, arg2 = 0; + if( ITEM_getInt( createitemindex, ITEM_TYPE) == 20){ + if( (p = strstr( ITEM_getChar(createitemindex, ITEM_ARGUMENT), "")) ){ + strcpy( argbuf, (p+2)); + arg1 = atoi(argbuf); + arg1 = arg1 * FOOD_MP_RATE / 100; + } + if( (p = strstr( ITEM_getChar(createitemindex, ITEM_ARGUMENT), "")) ){ + strcpy( argbuf, (p+2)); + arg2 = atoi(argbuf); + arg2 = arg2 * FOOD_HP_RATE / 100; + } + if( arg1 != 0 && arg2 != 0 ){ + sprintf( charbuf1, "%d%d", arg1, arg2); + } + else if( arg1 != 0){ + sprintf( charbuf1, "%d", arg1); + } + else if( arg2 != 0){ + sprintf( charbuf1, "%d", arg2); + } + if(arg1!=0 || arg2!=0){ +#ifdef _FM_LIAOLI + sprintf( charbuf, "(Ч)"); +#else + sprintf( charbuf, "()"); +#endif + strcpy( charbuf2, ITEM_getChar( createitemindex, ITEM_EFFECTSTRING)); + strncat( charbuf2, charbuf, 10); + ITEM_setChar( createitemindex, ITEM_ARGUMENT, charbuf1); + ITEM_setChar( createitemindex, ITEM_EFFECTSTRING, charbuf2); + } + } + } + } + } + } + // shan end + ITEM_setInt( createitemindex, ITEM_MERGEFLG, TRUE); + if( createitemindex != -1 ) { + rc = CHAR_addItemSpecificItemIndex( charaindex, createitemindex); + if( rc >= 0 && rc < CHAR_MAXITEMHAVE) { + CHAR_sendItemDataOne( charaindex, rc); + LogItem( + CHAR_getChar( charaindex, CHAR_NAME ), + CHAR_getChar( charaindex, CHAR_CDKEY ), +#ifdef _add_item_log_name // WON ADD itemlogitem + createitemindex, +#else + ITEM_getInt( createitemindex, ITEM_ID), +#endif + "mergeadd(ϳɳĵ)", + CHAR_getInt( charaindex,CHAR_FLOOR), + CHAR_getInt( charaindex,CHAR_X ), + CHAR_getInt( charaindex,CHAR_Y ), + ITEM_getChar( createitemindex, ITEM_UNIQUECODE), + ITEM_getChar( createitemindex, ITEM_NAME), + ITEM_getInt( createitemindex, ITEM_ID) + ); + result = TRUE; + } + else { + ITEM_endExistItemsOne( createitemindex); + } + } + } + } + return result; +} + +static int ITEM_getTableNum( int num) +{ + int i; + for( i = 0; i < arraysizeof( ItemRandTableForItem); i ++) { + if( num <= ItemRandTableForItem[i].maxnum ) { + break; + } + } + if( i == arraysizeof( ItemRandTableForItem)) i--; + return i; +} + +#ifdef _ITEM_INSLAY +int PETSKILL_ITEM_inslay( int charindex, int inslayindex, int itemindex) +{ + char *inslaystr , *code=NULL; + char codeTemp[][32]={ "NULL", "NULL", "NULL"}; + char codeTemp1[][32]={ "NULL", "NULL", "NULL", "NULL"}; + char codeTemp2[][32]={ "NULL", "NULL", "NULL", "NULL", "NULL"}; + char buf1[256], buf2[256]; + char TypeName[][256]={ + "", "", "", "HP", "MP", "", "", "", "ħID" + }; + int worktyp[] = { + ITEM_MODIFYATTACK, ITEM_MODIFYDEFENCE, ITEM_MODIFYQUICK, + ITEM_MODIFYHP, ITEM_MODIFYMP, ITEM_MODIFYLUCK, + ITEM_OTHERDAMAGE, ITEM_OTHERDEFC, ITEM_MAGICID + }; + int worknum[ arraysizeof(worktyp)]; + + int i; +#ifdef _DIY_INSLAY +int MAXCANINSLAY=getInslayNum(); +#else +int MAXCANINSLAY=3; +#endif + + memset( worknum, 0, sizeof( worknum)); + if( !CHAR_CHECKINDEX( charindex) ) return FALSE; + if( !ITEM_CHECKINDEX( inslayindex) ) return FALSE; + if( !ITEM_CHECKINDEX( itemindex) ) return FALSE; + if( itemindex == inslayindex ) return FALSE; + if( ITEM_getInt(itemindex,ITEM_TIME)>0 || ITEM_getInt(inslayindex,ITEM_TIME)>0){ + CHAR_talkToCli( charindex, -1, "ʱ޷ϳɻ", CHAR_COLORYELLOW); + return FALSE; + } + if( (code = ITEM_getChar( itemindex, ITEM_TYPECODE)) == "\0" ) { + print(" ITEM_TYPECODE == NULL error !!\n"); + return FALSE; + } + if( !strcmp( code, "NULL" ) ) return FALSE; + if( (inslaystr = ITEM_getChar( inslayindex, ITEM_INLAYCODE)) == "\0" ) { + print(" ITEM_INLAYCODE == NULL error !!\n"); + return FALSE; + } + + for( i = 0; i < MAXCANINSLAY; i ++ ) { + if( getStringFromIndexWithDelim( inslaystr , "|", i+1, buf1, sizeof( buf1 ) ) == TRUE ){ + if( strcmp( buf1, "\0")){ + if(MAXCANINSLAY == 4){ + sprintf( codeTemp1[i], "%s", buf1); + }else if(MAXCANINSLAY == 5){ + sprintf( codeTemp2[i], "%s", buf1); + }else{ + sprintf( codeTemp[i], "%s", buf1); + } + } + continue; + } + break; + } + + for( i = 0; i < MAXCANINSLAY; i ++ ) { + if(MAXCANINSLAY == 4){ + if( strcmp( codeTemp1[i], "NULL") ) continue; + sprintf( codeTemp1[i], "%s", code); + break; + }else if(MAXCANINSLAY == 5){ + if( strcmp( codeTemp2[i], "NULL") ) continue; + sprintf( codeTemp2[i], "%s", code); + break; + }else{ + if( strcmp( codeTemp[i], "NULL") ) continue; + sprintf( codeTemp[i], "%s", code); + break; + } + } + if( i == MAXCANINSLAY ) { + CHAR_talkToCli( charindex, -1, "Ѿˡ", CHAR_COLORYELLOW); + return FALSE; + } + memset( buf2, 0, sizeof( buf2)); + if(MAXCANINSLAY==4){ + sprintf( buf2, "%s|%s|%s|%s", codeTemp1[0], codeTemp1[1], codeTemp1[2], codeTemp1[3]); + }else if(MAXCANINSLAY==5){ + sprintf( buf2, "%s|%s|%s|%s|%s", codeTemp2[0], codeTemp2[1], codeTemp2[2], codeTemp2[3], codeTemp2[4]); + }else{ + sprintf( buf2, "%s|%s|%s", codeTemp[0], codeTemp[1], codeTemp[2]); + } +// sprintf( buf2, "%s|%s|%s", codeTemp[0], codeTemp[1], codeTemp[2]); +// print("buf2:%s\n", buf2); + ITEM_setChar( inslayindex, ITEM_INLAYCODE, buf2); + + for( i=0; i 0 ) { //ħ ID + int magicid,mp; + magicid = ITEM_getInt( itemindex, ITEM_MAGICID); + ITEM_setInt( inslayindex, ITEM_MAGICID, magicid); + mp = ITEM_getInt( itemindex, ITEM_MAGICUSEMP ); + ITEM_setInt( inslayindex, ITEM_MAGICUSEMP, mp); + } + for( i=ITEM_FIRSTFUNCTION; i 0 ) { //ȡħ + int marray = MAGIC_getMagicArray( ITEM_getInt( inslayindex, ITEM_MAGICID)); + if( marray != -1 ){ + if( (magicname = MAGIC_getChar( marray, MAGIC_NAME)) != NULL ){ + sprintf( Mname, "%s", magicname); + } + } + ITEM_setInt( inslayindex, ITEM_MAGICID, ITEM_getInt( inslayindex, ITEM_MAGICID)); + } + sprintf( secretname, "%s%s%d %s%s%d %s%s%d %s%s%d %s%s%d %s%s%d %s%s%d %s", + TypeName[0],(worknum[0]>=0)?"+":"",worknum[0], + TypeName[1],(worknum[1]>=0)?"+":"",worknum[1], + TypeName[2],(worknum[2]>=0)?"+":"",worknum[2], + TypeName[3],(worknum[3]>=0)?"+":"",worknum[3], + TypeName[4],(worknum[4]>=0)?"+":"",worknum[4], + TypeName[6],(worknum[6]>=0)?"+":"",worknum[6], + TypeName[7],(worknum[7]>=0)?"+":"",worknum[7], Mname); + ITEM_setChar( inslayindex, ITEM_EFFECTSTRING, secretname); + } + + return TRUE; +} + +#endif + +#ifdef _PETSKILL_FIXITEM +int PETSKILL_ITEM_FixItem( int charindex, int fixindex, int *itemindex) +{ + int index, i; + char *buf2; + int crushes, maxcrushes; +#define MAXFIXNUM 2 + index = 0; + for( i=0; i= 5 ){ +#ifdef _ITEM_FIXALLBASE + char *ITEM_ARG = ITEM_getChar( index, ITEM_ARGUMENT); + if( ITEM_ARG != "\0" && !strcmp( ITEM_ARG, "FIXITEMALL") ){ + }else{ +#endif + CHAR_talkToCli( charindex, -1, "ϲ", CHAR_COLORYELLOW); + return FALSE; +#ifdef _ITEM_FIXALLBASE + } +#endif + } + + crushes = ITEM_getInt( fixindex, ITEM_DAMAGECRUSHE); + maxcrushes = ITEM_getInt( fixindex, ITEM_MAXDAMAGECRUSHE); + if( crushes >= (maxcrushes*0.80) ) { + char buff[256]; + sprintf( buff, "%sû𻵵Ҫ޸", ITEM_getChar( fixindex, ITEM_NAME)); + CHAR_talkToCli( charindex, -1, buff, CHAR_COLORYELLOW); + return FALSE; + }else { + char *buf1; + if( maxcrushes < 500 ){ + CHAR_talkToCli( charindex, -1, "ƷѲ޸", CHAR_COLORYELLOW); + return FALSE; + } + if( crushes <= 0 ) return FALSE; + maxcrushes = maxcrushes*0.85; + crushes = maxcrushes; + ITEM_setInt( fixindex, ITEM_DAMAGECRUSHE, crushes); + ITEM_setInt( fixindex, ITEM_MAXDAMAGECRUSHE, maxcrushes); + // + buf1 = ITEM_getChar( fixindex, ITEM_SECRETNAME); + if( strstr( buf1, "(") != 0 ) { + char buf5[256]; + if( getStringFromIndexWithDelim( buf1,"(",1, buf5, sizeof( buf5)) != FALSE ) { + sprintf( buf1, buf5); + } + } + ITEM_setChar( fixindex, ITEM_SECRETNAME, buf1); + ITEM_setInt( fixindex, ITEM_CRUSHLEVEL, 0); + } + return TRUE; +} +#endif + + + diff --git a/item/item_trade.c b/item/item_trade.c new file mode 100644 index 0000000..e69de29 diff --git a/item/makefile b/item/makefile new file mode 100644 index 0000000..16e2669 --- /dev/null +++ b/item/makefile @@ -0,0 +1,216 @@ +export CC=gcc +export RM=rm -f +export AR=ar cr +export MV=mv +export RANLIB=ranlib +export SED=sed + + +export SHELL=/bin/sh + +INCFLAGS=-I. -I../include + +CFLAGS=-O3 -w $(INCFLAGS) +#Pentium 4 (Intel) +#CFLAGS=-march=pentium4 -O3 -pipe -fomit-frame-pointer $(INCFLAGS) +#Athlon XP (AMD) +#CFLAGS="-march=athlon-xp -O3 -pipe -fomit-frame-pointer" $(INCFLAGS) +#Athlon64£º +#CFLAGS="-O2 -march=athlon64 -ftracer -fprefetch-loop-arrays -pipe" $(INCFLAGS) + +PROG=libitem.a + +SRC=item.c item_event.c item_gen.c item_trade.c item_contract.c +OBJ=$(SRC:.c=.o) + +ifeq (0,$(MAKELEVEL)) +CC=gcc +RM=rm -f +AR=ar cr +MV=mv +RANLIB=ranlib +SED=sed +SHELL=/bin/sh +endif + +all: $(PROG) + +$(PROG): $(OBJ) + $(RM) $(PROG) + $(AR) $(PROG) $(OBJ) + $(RANLIB) $(PROG) + +depend: + $(MV) makefile makefile.bak + $(SED) -ne '1,/^# DO NOT DELETE THIS LINE/p' makefile.bak>makefile + $(CC) $(INCFLAGS) -M $(SRC) >> makefile + +clean: + $(RM) $(PROG) + $(RM) $(OBJ) + $(RM) *~ + +distclean: + $(RM) $(PROG) + $(RM) $(OBJ) + $(RM) *~ + $(MV) makefile Makefile.bak + $(SED) -ne '1,/^# DO NOT DELETE THIS LINE/p' makefile.bak>makefile + $(RM) makefile.bak + +# DO NOT DELETE THIS LINE +item.o: item.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/common.h \ + ../include/char.h ../include/common.h ../include/char_base.h \ + ../include/version.h ../include/skill.h ../include/util.h \ + ../include/title.h ../include/addressbook.h ../include/net.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/char_data.h ../include/battle.h ../include/item.h \ + ../include/buf.h ../include/function.h ../include/magic_base.h \ + ../include/profession_skill.h +item_event.o: item_event.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h /usr/include/ctype.h \ + ../include/common.h ../include/char.h ../include/common.h \ + ../include/char_base.h ../include/version.h ../include/skill.h \ + ../include/util.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/char_base.h ../include/char_data.h ../include/configfile.h \ + ../include/item.h ../include/item_event.h ../include/object.h \ + ../include/anim_tbl.h ../include/magic.h ../include/handletime.h \ + ../include/log.h ../include/util.h ../include/encount.h \ + ../include/battle.h ../include/battle_item.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h ../include/net.h ../include/pet.h \ + ../include/npcutil.h ../include/enemy.h ../include/battle_magic.h \ + ../include/pet_skill.h ../include/npc_freepetskillshop.h \ + ../include/mylua/function.h ../include/profession_skill.h \ + ../include/sasql.h ../include/npc_lua.h ../include/npc_lua_interface.h \ + ../include/../lua/lua.h ../include/../lua/lauxlib.h \ + /usr/include/assert.h ../include/npc_lua_interface.h +item_gen.o: item_gen.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h /usr/include/ctype.h \ + /usr/include/math.h /usr/include/bits/huge_val.h \ + /usr/include/bits/mathdef.h /usr/include/bits/mathcalls.h \ + ../include/configfile.h ../include/common.h ../include/util.h \ + ../include/buf.h ../include/char.h ../include/char_base.h \ + ../include/version.h ../include/skill.h ../include/util.h \ + ../include/title.h ../include/addressbook.h ../include/net.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/item.h ../include/item_gen.h ../include/enemy.h \ + ../include/log.h ../include/saacproto_cli.h ../include/saacproto_util.h \ + ../include/family.h ../include/magic_base.h +item_trade.o: item_trade.c +item_contract.o: item_contract.c diff --git a/item/makefile.bak b/item/makefile.bak new file mode 100644 index 0000000..16e2669 --- /dev/null +++ b/item/makefile.bak @@ -0,0 +1,216 @@ +export CC=gcc +export RM=rm -f +export AR=ar cr +export MV=mv +export RANLIB=ranlib +export SED=sed + + +export SHELL=/bin/sh + +INCFLAGS=-I. -I../include + +CFLAGS=-O3 -w $(INCFLAGS) +#Pentium 4 (Intel) +#CFLAGS=-march=pentium4 -O3 -pipe -fomit-frame-pointer $(INCFLAGS) +#Athlon XP (AMD) +#CFLAGS="-march=athlon-xp -O3 -pipe -fomit-frame-pointer" $(INCFLAGS) +#Athlon64£º +#CFLAGS="-O2 -march=athlon64 -ftracer -fprefetch-loop-arrays -pipe" $(INCFLAGS) + +PROG=libitem.a + +SRC=item.c item_event.c item_gen.c item_trade.c item_contract.c +OBJ=$(SRC:.c=.o) + +ifeq (0,$(MAKELEVEL)) +CC=gcc +RM=rm -f +AR=ar cr +MV=mv +RANLIB=ranlib +SED=sed +SHELL=/bin/sh +endif + +all: $(PROG) + +$(PROG): $(OBJ) + $(RM) $(PROG) + $(AR) $(PROG) $(OBJ) + $(RANLIB) $(PROG) + +depend: + $(MV) makefile makefile.bak + $(SED) -ne '1,/^# DO NOT DELETE THIS LINE/p' makefile.bak>makefile + $(CC) $(INCFLAGS) -M $(SRC) >> makefile + +clean: + $(RM) $(PROG) + $(RM) $(OBJ) + $(RM) *~ + +distclean: + $(RM) $(PROG) + $(RM) $(OBJ) + $(RM) *~ + $(MV) makefile Makefile.bak + $(SED) -ne '1,/^# DO NOT DELETE THIS LINE/p' makefile.bak>makefile + $(RM) makefile.bak + +# DO NOT DELETE THIS LINE +item.o: item.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/common.h \ + ../include/char.h ../include/common.h ../include/char_base.h \ + ../include/version.h ../include/skill.h ../include/util.h \ + ../include/title.h ../include/addressbook.h ../include/net.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/char_data.h ../include/battle.h ../include/item.h \ + ../include/buf.h ../include/function.h ../include/magic_base.h \ + ../include/profession_skill.h +item_event.o: item_event.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h /usr/include/ctype.h \ + ../include/common.h ../include/char.h ../include/common.h \ + ../include/char_base.h ../include/version.h ../include/skill.h \ + ../include/util.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/char_base.h ../include/char_data.h ../include/configfile.h \ + ../include/item.h ../include/item_event.h ../include/object.h \ + ../include/anim_tbl.h ../include/magic.h ../include/handletime.h \ + ../include/log.h ../include/util.h ../include/encount.h \ + ../include/battle.h ../include/battle_item.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h ../include/net.h ../include/pet.h \ + ../include/npcutil.h ../include/enemy.h ../include/battle_magic.h \ + ../include/pet_skill.h ../include/npc_freepetskillshop.h \ + ../include/mylua/function.h ../include/profession_skill.h \ + ../include/sasql.h ../include/npc_lua.h ../include/npc_lua_interface.h \ + ../include/../lua/lua.h ../include/../lua/lauxlib.h \ + /usr/include/assert.h ../include/npc_lua_interface.h +item_gen.o: item_gen.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h /usr/include/ctype.h \ + /usr/include/math.h /usr/include/bits/huge_val.h \ + /usr/include/bits/mathdef.h /usr/include/bits/mathcalls.h \ + ../include/configfile.h ../include/common.h ../include/util.h \ + ../include/buf.h ../include/char.h ../include/char_base.h \ + ../include/version.h ../include/skill.h ../include/util.h \ + ../include/title.h ../include/addressbook.h ../include/net.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/item.h ../include/item_gen.h ../include/enemy.h \ + ../include/log.h ../include/saacproto_cli.h ../include/saacproto_util.h \ + ../include/family.h ../include/magic_base.h +item_trade.o: item_trade.c +item_contract.o: item_contract.c diff --git a/link.c b/link.c new file mode 100644 index 0000000..8bd2066 --- /dev/null +++ b/link.c @@ -0,0 +1,135 @@ +#include +#include "version.h" +#include "link.h" +#include "buf.h" + +/* + * ¦ + * top á + * ߯Ի + */ +BOOL Nodeappendtail( Node** top , Node* add ) +{ + Node* c; /**/ + Node* next; /*ޥá*/ + + /*NULL*/ + if( *top == NULL ){ + *top = allocateMemory( sizeof( Node ) ); + if( *top== NULL ) return FALSE; + (*top)->next = NULL; /*巴 */ + (*top)->size = add->size; /*Ӯ綰*/ + (*top)->val = add->val; /*̼*/ + return TRUE; + } + + for( c = *top ; c->next ; c = c->next ); /* c ë */ + next = allocateMemory( sizeof(Node) ); + if( next == NULL )return FALSE; + c->next = next; /* nextëɬ */ + next->next = NULL; /*巴 */ + next->val = add->val; /*̼*/ + next->size = add->size; /*Ӯ綰*/ + return TRUE; +} + + + + +/* + * ͼ年 + * ¦ + * top á + * ߯Ի + */ +BOOL Nodeappendhead( Node** nowtop , Node* add ) +{ + Node* newtop; /*ޥ */ + + /*NULL*/ + if( *nowtop == NULL ){ + *nowtop = allocateMemory( sizeof( Node ) ); + if( *nowtop == NULL ) return FALSE; + (*nowtop)->next = NULL; /*巴 */ + (*nowtop)->size = add->size; /*Ӯ綰*/ + (*nowtop)->val = add->val; /*̼*/ + return TRUE; + } + + /* + * ޥáë + */ + newtop = allocateMemory( sizeof(Node) ); + newtop->next = *nowtop; + newtop->val = add->val; + newtop->size = add->size; + *nowtop = newtop; + return TRUE; +} + + + + +/* + * ¦ + * ret Իá + * ߯Ի + */ +BOOL Noderemovehead( Node** top , Node* ret) +{ + Node* newtop; /*ޥ ئá*/ + + if( *top == NULL )return FALSE; + + ret->val = (*top)->val; + ret->size = (*top)->size; + newtop = (*top)->next; + freeMemory( *top ); + *top = newtop; + + return TRUE; +} + + + + + +/* + * ¦ + * ret Իá + * ߯Ի + */ +BOOL Noderemovetail( Node** top , Node* ret) +{ + Node* c; /**/ + Node* c1; /* йƥ c->nextë϶*/ + + if( *top == NULL )return FALSE; + + c = *top; /*ɬ*/ + c1 = c->next; /*ɬ*/ + while(1){ + if( c1->next == NULL ) + /* + * ƥ c1 + * | + * | next |---->+------+ + * |------| | next |---->NULL + * | | +------+ + * +------+ | | + * +------+ + *ئȻ + */ + break; + c=c->next; + c1=c->next; + } + c->next = NULL; /*c1ؤּë¼ƥnextNULL*/ + /**/ + ret->val = c1->val; + ret->size = c1->size; + + freeMemory( c1 ); + + return TRUE; +} diff --git a/log.c b/log.c new file mode 100644 index 0000000..858ab62 --- /dev/null +++ b/log.c @@ -0,0 +1,942 @@ +#include "version.h" +#include +#include +#include +#include + +#include "common.h" +#include "util.h" +#include "log.h" +#include "handletime.h" +#include "net.h" +#include "char_base.h" + +/* + * + * ƥئּ̤ļ̫fopen(..,"w") + * by ringo + */ + +struct tagLogconf{ + char* label; + char* entry; + char filename[256]; + FILE* f; + BOOL append; /* append ¾̤ļ̫SEEK_SET¾ */ +}LogConf[LOG_TYPE_NUM]={ + { "TALK: ", "talklog" ,"", NULL , TRUE}, + { "PROC: ", "proc" , "" , NULL , FALSE}, + { "ITEM: ", "itemlog" ,"", NULL , TRUE}, + { "STONE: ", "stonelog" ,"", NULL , TRUE}, + { "PET: ", "petlog" ,"", NULL , TRUE}, + { "TENSEI: ", "tenseilog" ,"", NULL , TRUE}, + { "KILL: ", "killlog","",NULL,TRUE}, + // CoolFish: 2001/4/19 + { "TRADE: ", "tradelog", "", NULL, TRUE}, + // Arminius: 2001/6/14 + { "HACK: ", "hacklog", "", NULL, TRUE}, + // Nuke: 0626 Speed + { "SPEED: ", "speedlog", "", NULL, TRUE}, + // CoolFish: FMPopular 2001/9/12 + { "FMPOP: ", "fmpoplog", "", NULL, TRUE}, + // Robin 10/02 + { "FAMILY: ", "familylog", "", NULL, TRUE}, + // Shan 11/02 + { "GM: ", "gmlog", "", NULL, TRUE}, + +#ifdef _GAMBLE_ROULETTE + { "", "gamblelog", "", NULL, TRUE}, +#endif + { "LOGIN: ", "loginlog", "", NULL, TRUE}, + { "", "pettranslog", "", NULL, TRUE}, +//Syu ׯ԰սʤLog + { "FMPKRESULT: ", "fmpkresultlog" ,"", NULL , TRUE}, + +// Syu ADD дȡLog () + { "BANKSTONELOG: ", "bankstonelog" ,"", NULL , TRUE}, + + { "ACMESSAGE: ", "acmessagelog" ,"", NULL , TRUE}, + { "PKCONTEND:", "pkcontendlog", "", NULL, TRUE}, +#ifdef _STREET_VENDOR + { "STREETVENDOR: ", "StreetVendorlog" ,"", NULL , TRUE}, +#endif +#ifdef _ANGEL_SUMMON + { "ANGEL: ", "angellog" ,"", NULL , TRUE}, +#endif +#ifdef _NEW_MANOR_LAW + { "FMPKGETMONEY: ","FMPKGetMoneylog","",NULL,TRUE}, + { "FMFAMESHOP: ","FMFameShoplog","",NULL,TRUE}, +#endif + + { "LOGOUT: ", "logoutlog", "", NULL, TRUE}, +}; + +tagWarplog warplog[MAXMAPNUM]; +tagWarpCount warpCount[MAXMAPLINK]; + +/*------------------------------------------------------------ + * ¦ + * ߯Ի + ------------------------------------------------------------*/ +static BOOL readLogConfFile( char* filename ) +{ + FILE* f; + char line[256]; + char basedir[256]; + int linenum=0; + + { + char* r; + r = rindex( filename, '/' ); + if( r == NULL )snprintf(basedir,sizeof(basedir),"." ); + else{ + memcpy( basedir,filename,r-filename ); + basedir[r-filename] = '\0'; + } + } + + f = fopen( filename , "r"); + if( f == NULL ){ + print( "Can't open %s\n" , filename ); + return FALSE; + } + while( fgets( line, sizeof( line ) ,f ) ){ + char firstToken[256]; + int i; + BOOL ret; + + linenum++; + deleteWhiteSpace(line); /* remove whitespace */ + if( line[0] == '#' )continue; /* comment */ + if( line[0] == '\n' )continue; /* none */ + chomp( line ); /* remove tail newline */ + ret = getStringFromIndexWithDelim( line , "=", 1, firstToken, sizeof(firstToken) ); + if( ret == FALSE ){ + print( "Find error at %s in line %d. Ignore\n", + filename , linenum); + continue; + } + for( i=0 ; i= LOG_TYPE_NUM )return; + if( LogConf[logtype].append ){ + if( !LogConf[logtype].f )return; + fputs( LogConf[logtype].label, LogConf[logtype].f); + va_start(arg,format); + vfprintf( LogConf[logtype].f,format,arg ); + va_end( arg ); + fputc( '\n', LogConf[logtype].f ); + } else { + FILE *f = fopen( LogConf[logtype].filename ,"w" ); + if( !f ) return; + fputs(LogConf[logtype].label , f ); + va_start(arg,format); + vfprintf( f , format,arg); + va_end(arg); + fputc( '\n' , f); + fclose(f); + } +} + +BOOL initLog( char* filename ) +{ + if( readLogConfFile( filename ) == FALSE )return FALSE; + openAllLogFile(); + return TRUE; +} + +//Syu ׯ԰սʤLog +void Logfmpk( + char *winner, int winnerindex, int num1, + char *loser, int loserindex, int num2, + char *date, char *buf1, char *buf2, int flg) +{ + switch( flg){ + case 1: + { + struct tm tm1; + char buf[256]; + memcpy( &tm1, localtime( (time_t *)&NowTime.tv_sec), sizeof( tm1)); + sprintf( buf, " (%d:%d)", tm1.tm_hour, tm1.tm_min); + printl( LOG_FMPKRESULT, "\nFMPK: [%s]ص:%s %s(%d) ԼսҪ %s(%d) time:%s", + buf1, buf2, + winner, winnerindex, loser, loserindex, buf); + } + break; + case 2: + printl( LOG_FMPKRESULT, "\nFMPK: Winner %s(%d)=>%d Loser %s(%d)=>%d time:%s", + winner, winnerindex, num1, + loser, loserindex, num2 ,date); + break; + } +} + +void Logfmpk_war(int dueltime,int mytime){ + printl( LOG_FMPKRESULT, "\nFMPK_WAR: dueltime=%d,mytime=%d", + dueltime,mytime); +} + +#ifdef _NEW_MANOR_LAW +void LogFMPKGetMomey(char *szFMName,char *szID,char *szCharName,int iMomentum,int iGetMoney,int iDest) +{ + struct tm tm1; + char szDest[3][6] = {"","",""}; + + if(iDest < 0 || iDest > 1) iDest = 2; + memcpy(&tm1,localtime((time_t*)&NowTime.tv_sec),sizeof(tm1)); + printl(LOG_FMPK_GETMONEY,"FMName:%s\tID:%s\tName:%s\tMomentum:%d\tGetMoney:%d\tAddTo:%s\t(%d:%d)", + szFMName,szID,szCharName,iMomentum,iGetMoney,szDest[iDest],tm1.tm_hour,tm1.tm_min); +} + +void LogFMFameShop(char *szFMName,char *szID,char *szCharName,int iFame,int iCostFame) +{ + struct tm tm1; + + memcpy(&tm1,localtime((time_t*)&NowTime.tv_sec),sizeof(tm1)); + printl(LOG_FM_FAME_SHOP,"FMName:%s\tID:%s\tName:%s\tFame:%d\tCostFame:%d\t(%d:%d)", + szFMName,szID,szCharName,iFame,iCostFame,tm1.tm_hour,tm1.tm_min); +} +#endif + +void LogAcMess( int fd, char *type, char *mess ) +{ + struct tm tm1; + memcpy( &tm1, localtime( (time_t *)&NowTime.tv_sec), sizeof( tm1)); + if( strstr( mess, "Broadcast") != NULL ) return; + printl( LOG_ACMESS, "%d %s [%s] (%d:%d)" , fd, type, mess, tm1.tm_hour, tm1.tm_min); +} + +void LogItem( + char *CharName, /* ƽҷ */ + char *CharID, /* ƽҷID */ + int ItemNo, /* ʧ ة į */ + char *Key, /* ƽ */ + int floor, /* */ + int x, + int y, + char *uniquecode, // shan 2001/12/14 + char *itemname, int itemID +){ + struct tm tm1; + memcpy( &tm1, localtime( (time_t *)&NowTime.tv_sec), sizeof( tm1)); + + printl( LOG_ITEM, "%s\t%s\t%d(%s)=%s,(%d,%d,%d)(%d:%d),%s" , CharName, CharID, + itemID, itemname, + Key, floor, x, y, tm1.tm_hour, tm1.tm_min, uniquecode ); + + +} +void LogPkContend( char *teamname1, char *teamname2, + int floor, + int x, + int y, + int flg +) +{ + struct tm tm1; + memcpy( &tm1, localtime( (time_t *)&NowTime.tv_sec), sizeof( tm1)); + + if( flg == 0 ) { + printl( LOG_PKCONTEND, "[%32s ʤ %32s],(%5d,%4d,%4d)(%d:%d)" , + teamname1, teamname2, + floor, x, y, tm1.tm_hour, tm1.tm_min); + }else{ + printl( LOG_PKCONTEND, "Msg:[%s],(%5d,%4d,%4d)(%d:%d)" , + teamname1, floor, x, y, tm1.tm_hour, tm1.tm_min); + } + +} + +void LogPetTrans( + char *cdkey, char *uniwuecde, char *uniwuecde2, + char *CharName, int floor, int x, int y, + int petID1, char *PetName1, int petLV, int petrank, int vital1, int str1, int tgh1, int dex1, int total1, + int petID2, char *PetName2, int vital2, int str2, int tgh2, int dex2, int total2, + int work0, int work1, int work2, int work3, int ans, int trans + ){ + struct tm tm1; + memcpy( &tm1, localtime( (time_t *)&NowTime.tv_sec), sizeof( tm1)); + printl( PETTRANS, "\n*PETTRANS cdkey=%s unid=%s munid=%s %s (%d:%d) %d=%s LV:%d rand:%d trans:%d :[ %d, %d, %d, %d]=%d %d=%s :[ %d, %d, %d, %d]=%d [ %d, %d, %d, %d]=%d\n", + cdkey, uniwuecde, uniwuecde2, + CharName, tm1.tm_hour, tm1.tm_min, + petID1, PetName1, petLV, petrank, trans, vital1, str1, tgh1, dex1, total1, + petID2, PetName2, vital2, str2, tgh2, dex2, total2, + work0, work1, work2, work3, ans ); +} +/*------------------------------------------------------------ + * + * ʸë + * +-------------------------------------------------------------*/ +void LogPet( + char *CharName, /* ƽҷ */ + char *CharID, + char *PetName, + int PetLv, + char *Key, /* ƽ */ + int floor, /* */ + int x, + int y, + char *uniquecode // shan 2001/12/14 +){ + struct tm tm1; + memcpy( &tm1, localtime( (time_t *)&NowTime.tv_sec), sizeof( tm1)); + // shan 2001/12/14 + //printl( LOG_PET, "%s\t%s\t%s:%d=%s,(%d,%d,%d)(%d:%d)" , CharName, CharID, + // PetName, PetLv, + // Key, + // floor, x, y, tm1.tm_hour, tm1.tm_min ); + printl( LOG_PET, "%s\t%s\t%s:%d=%s,(%d,%d,%d)(%d:%d),%s" , CharName, CharID, + PetName, PetLv, + Key, + floor, x, y, tm1.tm_hour, tm1.tm_min, uniquecode); +} + +#ifdef _STREET_VENDOR +void LogStreetVendor( + char *SellName, + char *SellID, + char *BuyName, + char *BuyID, + char *ItemPetName, + int PetLv, //ǵߴֵΪ -1 + int iPrice, + char *Key, + int Sfloor, + int Sx, + int Sy, + int Bfloor, + int Bx, + int By, + char *uniquecode, + int streettype +){ + struct tm tm1; + memcpy(&tm1,localtime((time_t *)&NowTime.tv_sec),sizeof(tm1)); + char *streetmsg=NULL; + if (streettype==0) streetmsg="ʯ"; + if (streettype==1) streetmsg=""; + if (streettype==2) streetmsg="Ա"; + if (streettype==3) streetmsg=""; + if (streettype==4) streetmsg=""; + printl(LOG_STREET_VENDOR,"type:%s Sell:%s\t%s\tBuy:%s\t%s\tName=%s:Lv=%d|Price:%d,%s,SXY(%d,%d,%d)BXY(%d,%d,%d)(%d%d%d %d:%d),%s",streetmsg,SellName,SellID,BuyName,BuyID, + ItemPetName,PetLv,iPrice,Key,Sfloor,Sx,Sy,Bfloor,Bx,By,tm1.tm_year+1900,tm1.tm_mon+1,tm1.tm_mday,tm1.tm_hour,tm1.tm_min,uniquecode); +} +#endif + +void LogBankStone( + char *CharName, /* ƽҷ */ + char *CharId, /* ǡID */ + int meindex, + int Gold, /* ź */ + char *Key, /* ƽ */ + int floor, /* */ + int x, + int y, + int my_gold, + int my_personagold + +){ + struct tm tm1; + + memcpy( &tm1, localtime( (time_t *)&NowTime.tv_sec), sizeof( tm1)); + printl( LOG_STONE, "%s:%s\ts:%d=%s,(%d,%d,%d)(%d:%d) <>" , + CharId, CharName, Gold, Key, + floor, x, y, tm1.tm_hour, tm1.tm_min , my_gold, my_personagold ); +} + +void LogPetPointChange( + char * CharName, char *CharID, char *PetName, int petindex, int errtype, + int PetLv, char *Key,int floor, int x, int y) { + + struct tm tm1; + int vit,str,tgh,dex; + int l_vit,l_str,l_tgh,l_dex; + int pet_ID, levellvup; + + pet_ID = CHAR_getInt( petindex, CHAR_PETID ); + vit = CHAR_getInt( petindex, CHAR_VITAL ); + str = CHAR_getInt( petindex, CHAR_STR ); + tgh = CHAR_getInt( petindex, CHAR_TOUGH ); + dex = CHAR_getInt( petindex, CHAR_DEX ); + levellvup = CHAR_getInt( petindex, CHAR_ALLOCPOINT); + + l_vit = (levellvup >> 24); + l_str = (levellvup >> 16)&0xff; + l_tgh = (levellvup >> 8 )&0xff; + l_dex = (levellvup >> 0 )&0xff; + + memcpy( &tm1, localtime( (time_t *)&NowTime.tv_sec), sizeof( tm1)); + printl( LOG_PET, "%s\t%s\t%s:%d=%s,(%d,%d,%d)(%d:%d),err:%d %d<<%d,%d,%d,%d>>lvup<<%d,%d,%d,%d>>" , + CharName, CharID, PetName, PetLv, Key, floor, x, y, tm1.tm_hour, tm1.tm_min , errtype, + pet_ID ,vit,str,tgh,dex,l_vit,l_str,l_tgh,l_dex); +} + +/*------------------------------------------------------------ + * + * Ϸë + * +-------------------------------------------------------------*/ +void LogTensei( + char *CharName, /* ƽҷ */ + char *CharID, + char *Key, /* ƽ */ + int level, //ì + int transNum, //Ϸ + int quest, //;޵ + int home, //컩 + int item, // ʧ ة Ի + int pet, // ʸ Ի + int vital, // Vital + int b_vital, // vital + int str, // str + int b_str, // str + int tgh, // + int b_tgh, // + int dex, // + int b_dex // +){ + struct tm tm1; + memcpy( &tm1, localtime( (time_t *)&NowTime.tv_sec), sizeof( tm1)); + printl( LOG_TENSEI, "%s\t%s\t%s=(%d,%d,%d,%d,%d,%d),(vi=%d->%d,str=%d->%d,tgh=%d->%d,dex=%d->%d),(%d,%d)" + ,CharName, + CharID, + Key, + level, + transNum, + quest, + home, + item, + pet, + vital, + b_vital, + str, + b_str, + tgh, + b_tgh, + dex, + b_dex, + tm1.tm_hour, tm1.tm_min + ); +} + +// LOG_TALK +void LogTalk( + char *CharName, /* ƽҷ */ + char *CharID, + int floor, /* */ + int x, + int y, + char *message +){ + struct tm tm1; + memcpy( &tm1, localtime( (time_t *)&NowTime.tv_sec), sizeof( tm1)); + + printl( LOG_TALK, "%2d:%2d\t%s\t%s\t%d_%d_%d\tT=%s" , + tm1.tm_hour, tm1.tm_min, + (CharID==NULL) ? "(null)" :CharID, + (CharName==NULL) ? "(null)" :CharName, + floor, x, y, + message ); + + +} +/*------------------------------------------------------------ + * ɬñ׻Ȼͻ̻ëʧ + * ̻ﷴͷľئľͷ + * ¦ struct tm + * ئ + * ߯Ի + * װ̻P + ------------------------------------------------------------*/ +void backupAllLogFile( struct tm *ptm ) +{ + int i; + char szBuffer[256]; + + for( i=0 ; itm_year+1900, ptm->tm_mon+1, ptm->tm_mday ); + + if( LogConf[i].f != NULL ){ + /* ľͷ */ + fclose( LogConf[i].f ); + /* ة */ + rename( LogConf[i].filename, szBuffer ); + /* ̫ */ + LogConf[i].f = fopen( LogConf[i].filename , "a" ); + + }else{ + /* ة */ + rename( LogConf[i].filename, szBuffer ); + /* ̫ */ + LogConf[i].f = fopen( LogConf[i].filename , "a" ); + + } + } +} +/*------------------------------------------------------------ +* +* ë +* +-------------------------------------------------------------*/ +// Syu ADD дȡLog () +void LogFamilyBankStone( + char *CharName, + char *CharId, + int Gold, + int MyGold, + char *Key, + int floor, + int x, + int y, + int banksum +){ + struct tm tm1; + memcpy( &tm1, localtime( (time_t *)&NowTime.tv_sec), sizeof( tm1)); + printl( LOG_BANKSTONELOG, "%s:%s\t%d=%s [%d] CHAR_GOLD(%d),(%d,%d,%d)(%d:%d)" , CharId, CharName, Gold, Key,banksum, + MyGold, floor, x, y, tm1.tm_hour, tm1.tm_min ); + print("\n%s:%s\t%d=%s [%d] CHAR_GOLD(%d),(%d,%d,%d)(%d:%d)\n" , CharId, CharName, Gold, Key,banksum, + MyGold, floor, x, y, tm1.tm_hour, tm1.tm_min ); +} + +void LogStone( + int TotalGold, + char *CharName, /* ƽҷ */ + char *CharId, /* ǡID */ + int Gold, /* ź */ + int MyGold, + char *Key, /* ƽ */ + int floor, /* */ + int x, + int y +){ + struct tm tm1; + memcpy( &tm1, localtime( (time_t *)&NowTime.tv_sec), sizeof( tm1)); + if(TotalGold == -1){ + printl( LOG_STONE, "%s:%s\t%d=%s TOTAL_GOLD(%d),CHAR_GOLD(%d),(%d,%d,%d)(%d:%d)" , CharId, CharName, Gold, Key,TotalGold, + MyGold, floor, x, y, tm1.tm_hour, tm1.tm_min ); + } + else{ + printl( LOG_STONE, "%s:%s\t%d=%s CHAR_GOLD(%d),(%d,%d,%d)(%d:%d)" , CharId, CharName, Gold, Key, + MyGold, floor, x, y, tm1.tm_hour, tm1.tm_min ); + } +} + +//ttom 12/26/2000 print the kill log +void LogKill( + char *CharName, + char *CharId, + char *CharPet_Item +){ + struct tm tm1; + memcpy( &tm1, localtime( (time_t *)&NowTime.tv_sec), sizeof( tm1)); + printl( LOG_KILL, "Name=%s:ID=%s\t%s (%d:%d)" ,CharName,CharId, CharPet_Item, + tm1.tm_hour, tm1.tm_min ); +} +//ttom + +// CoolFish: Trade 2001/4/19 +void LogTrade(char *message) +{ + struct tm tm1; + memcpy( &tm1, localtime( (time_t *)&NowTime.tv_sec), sizeof( tm1)); + printl( LOG_TRADE, "%s (%d%d%d %d:%d)" , message, tm1.tm_year+1900,tm1.tm_mon+1,tm1.tm_mday,tm1.tm_hour, tm1.tm_min ); +} + +// CoolFish: Family Popular 2001/9/12 +void LogFMPOP(char *message) +{ + struct tm tm1; + memcpy( &tm1, localtime( (time_t *)&NowTime.tv_sec), sizeof( tm1)); + + printl( LOG_FMPOP, "%s (%d:%d)" , message, tm1.tm_hour, tm1.tm_min ); +} + +// Arminius 2001/6/14 +char hackmsg[HACK_TYPE_NUM][4096]= + { "??? ʲҲûз", + "޷ȡͨѶЭ", + "յ޷ʶͨѶЭ", + "", + "HPΪ", + "˺ŷ", + }; + +void logHack(int fd, int errcode) +{ + struct tm tm1; + char cdkey[4096]; + char charname[4096]; + unsigned long ip; + char ipstr[4096]; + + memcpy( &tm1, localtime( (time_t *)&NowTime.tv_sec), sizeof( tm1)); + CONNECT_getCdkey( fd, cdkey, 4096); + CONNECT_getCharname( fd, charname, 4096); + ip=CONNECT_get_userip(fd); + sprintf(ipstr,"%d.%d.%d.%d", + ((unsigned char *)&ip)[0], + ((unsigned char *)&ip)[1], + ((unsigned char *)&ip)[2], + ((unsigned char *)&ip)[3]); + if ((errcode<0) || (errcode>=HACK_TYPE_NUM)) errcode=HACK_NOTHING; + + printl( LOG_HACK, "(%d:%d) %s ip=%s cdkey=%s charname=%s", + tm1.tm_hour, tm1.tm_min, hackmsg[errcode], ipstr, cdkey, charname); +} + +void logHackKick(int fd) +{ + struct tm tm1; + char cdkey[4096]; + + memcpy( &tm1, localtime( (time_t *)&NowTime.tv_sec), sizeof( tm1)); + CONNECT_getCdkey( fd, cdkey, 4096); + if(strlen(cdkey)<1) + strcpy(cdkey,""); + printl( LOG_LOGIN, "hack:(%d%d%d %d:%d) cdkey=%s ", + tm1.tm_year+1900,tm1.tm_mon+1,tm1.tm_mday,tm1.tm_hour, tm1.tm_min, cdkey); +} + +void logKong(char *ip) +{ + struct tm tm1; + memcpy( &tm1, localtime( (time_t *)&NowTime.tv_sec), sizeof( tm1)); + printl( LOG_HACK, "(%d%d%d %d:%d) ӱ,IP=%s ", + tm1.tm_year+1900,tm1.tm_mon+1,tm1.tm_mday,tm1.tm_hour, tm1.tm_min,ip); +} + +void logCC(char *ip) +{ + struct tm tm1; + memcpy( &tm1, localtime( (time_t *)&NowTime.tv_sec), sizeof( tm1)); + printl( LOG_HACK, "(%d%d%d %d:%d) ,IP=%s ", + tm1.tm_year+1900,tm1.tm_mon+1,tm1.tm_mday,tm1.tm_hour, tm1.tm_min,ip); +} + +void logWrongCdkey(char *ip) +{ + struct tm tm1; + memcpy( &tm1, localtime( (time_t *)&NowTime.tv_sec), sizeof( tm1)); + printl( LOG_HACK, "(%d%d%d %d:%d) ˺,IP=%s ", + tm1.tm_year+1900,tm1.tm_mon+1,tm1.tm_mday,tm1.tm_hour, tm1.tm_min,ip); +} + +void logWrongBao(char *ip) +{ + struct tm tm1; + memcpy( &tm1, localtime( (time_t *)&NowTime.tv_sec), sizeof( tm1)); + printl( LOG_HACK, "(%d%d%d %d:%d) ,IP=%s ", + tm1.tm_year+1900,tm1.tm_mon+1,tm1.tm_mday,tm1.tm_hour, tm1.tm_min,ip); +} + +void logRightBao(char *ip,int baolen) +{ + struct tm tm1; + memcpy( &tm1, localtime( (time_t *)&NowTime.tv_sec), sizeof( tm1)); + printl( LOG_HACK, "(%d%d%d %d:%d) ȷ,IP=%s,len=%d ", + tm1.tm_year+1900,tm1.tm_mon+1,tm1.tm_mday,tm1.tm_hour, tm1.tm_min,ip,baolen); +} + +void logBigBao(char *ip,int baolen) +{ + struct tm tm1; + memcpy( &tm1, localtime( (time_t *)&NowTime.tv_sec), sizeof( tm1)); + printl( LOG_HACK, "(%d%d%d %d:%d) ,IP=%s,len=%d ", + tm1.tm_year+1900,tm1.tm_mon+1,tm1.tm_mday,tm1.tm_hour, tm1.tm_min,ip,baolen); +} + +void logFengBao(int clifd,char *cdkey,int funcid,char *buf) +{ + /* + int clicharaindex = CONNECT_getCharaindex( clifd ); + if(CHAR_getWorkInt(clicharaindex,CHAR_WORKJILU)==1){ + struct tm tm1; + memcpy( &tm1, localtime( (time_t *)&NowTime.tv_sec), sizeof( tm1)); + printl( LOG_HACK, "(%d%d%d %d:%d) ȡ,cdkey=%s,funcid=%d,buf=%s ", + tm1.tm_year+1900,tm1.tm_mon+1,tm1.tm_mday,tm1.tm_hour, tm1.tm_min,cdkey,funcid,buf); + } + */ + struct tm tm1; + memcpy( &tm1, localtime( (time_t *)&NowTime.tv_sec), sizeof( tm1)); + printl( LOG_HACK, "(%d%d%d %d:%d) ȡ,cdkey=%s,funcid=%d,buf=%s ", + tm1.tm_year+1900,tm1.tm_mon+1,tm1.tm_mday,tm1.tm_hour, tm1.tm_min,cdkey,funcid,buf); + +} + +// Nuke 0626 +void logSpeed(int fd) +{ + struct tm tm1; + char cdkey[4096]; + char charname[4096]; + unsigned long ip; + char ipstr[4096]; + + memcpy( &tm1, localtime( (time_t *)&NowTime.tv_sec), sizeof( tm1)); + CONNECT_getCdkey( fd, cdkey, 4096); + CONNECT_getCharname( fd, charname, 4096); + ip=CONNECT_get_userip(fd); + sprintf(ipstr,"%d.%d.%d.%d", + ((unsigned char *)&ip)[0], + ((unsigned char *)&ip)[1], + ((unsigned char *)&ip)[2], + ((unsigned char *)&ip)[3]); + printl( LOG_SPEED, "(%d:%d) ip=%s cdkey=%s charname=%s", + tm1.tm_hour, tm1.tm_min, ipstr, cdkey, charname); +} + +// Shan +void LogGM( + char *CharName, //ɫ + char *CharID, //ID + char *Message, //ָ + int floor, + int x, + int y +) +{ + struct tm tm1; + + memcpy(&tm1,localtime((time_t *)&NowTime.tv_sec),sizeof(tm1)); + printl(LOG_GM,"%s\t%s\t%s\t(%d,%d,%d)\t(%d%d%d %d:%d)", + CharName,CharID,Message,floor,x,y,tm1.tm_year+1900,tm1.tm_mon+1,tm1.tm_mday,tm1.tm_hour,tm1.tm_min); +} + +// Robin 10/02 +void LogFamily( + char *FMName, + int fmindex, + char *charName, + char *charID, + char *keyWord, + char *data +){ + struct tm tm1; + memcpy( &tm1, localtime( (time_t *)&NowTime.tv_sec), sizeof( tm1)); + // CoolFish: 2001/10/11 log time + printl( LOG_FAMILY, "%s\t%d\t%s\t%s\t= %s, %s (%d:%d)", + FMName, fmindex, charName, charID, + keyWord, data, tm1.tm_hour, tm1.tm_min ); +} + +#ifdef _GAMBLE_ROULETTE +void LogGamble( + char *CharName, //ɫ + char *CharID, //ID + char *Key, //˵ + int floor, + int x, + int y, + int player_stone, //ӵнǮ + int Gamble_stone, //ע + int get_stone, // + int Gamble_num, + int flg //flg = 1 2 ׯ +) +{ + struct tm tm1; + memcpy(&tm1,localtime((time_t *)&NowTime.tv_sec),sizeof(tm1)); + + if( flg == 1 ) { + printl(LOG_GAMBLE,"%s\t%s\t TYPE:%s <>\t(%d,%d,%d)-(%d:%d) GAMBLENUM=%d", + CharName,CharID,Key, player_stone, Gamble_stone, get_stone, floor,x,y,tm1.tm_hour,tm1.tm_min, Gamble_num); + }else if( flg == 2 ) { + printl(LOG_GAMBLE,"%s\tROULETTE MASTER\t TYPE:%s <>\t(%d,%d,%d)-(%d:%d)", + CharName,Key, player_stone, floor,x,y,tm1.tm_hour,tm1.tm_min); + } +} + +#endif + +void LogLogin( + char *CharID, //ID + char *CharName, //ɫ + int saveIndex, + char *ipadress,char *pcid +) +{ + struct tm tm1; + + memcpy(&tm1,localtime((time_t *)&NowTime.tv_sec),sizeof(tm1)); + + printl(LOG_LOGIN,"%s\t%s\ti=%d\t%s\tPCID=%s\t(%d%d%d %d:%d)", + CharID,CharName,saveIndex,ipadress,pcid,tm1.tm_year+1900,tm1.tm_mon+1,tm1.tm_mday,tm1.tm_hour,tm1.tm_min); + +} + +void LogLogout( + char *CharID, //ID + char *CharName, //ɫ + int floor, + int hp, + char *file, + int line +) +{ + struct tm tm1; + + memcpy(&tm1,localtime((time_t *)&NowTime.tv_sec),sizeof(tm1)); + + printl(LOG_LOGIN,"%s\t%s\tfloor=%d\thp=%d\t(%d%d%d %d:%d)\tfile=%s%d", + CharID,CharName,floor,hp,tm1.tm_year+1900,tm1.tm_mon+1,tm1.tm_mday,tm1.tm_hour,tm1.tm_min,file,line); + +} + + + +void warplog_to_file() +{ + int i =0; + char outbuf[128]; + FILE *f; + f = fopen("log/warp1.log" ,"w" ); + if( !f ) return; + + for( i=0; i +#include +#include + + +void lssproto_SetServerLogFiles( char *r , char *w ) +{ + lssproto_strcpysafe( lssproto_writelogfilename , w , sizeof(lssproto_writelogfilename )); + lssproto_strcpysafe( lssproto_readlogfilename , r , sizeof(lssproto_readlogfilename )); +} +int lssproto_InitServer( int (*writefunc)(int,char*,int) , int worksiz ) +{ + int i; + if( (void*)writefunc == NULL) { + lssproto.write_func = lssproto_default_write_wrap; + } else { + lssproto.write_func = writefunc; + } + lssproto_AllocateCommonWork(worksiz); + lssproto_stringwrapper = (char**)calloc( 1,sizeof(char*) * MAXLSRPCARGS); + if(lssproto_stringwrapper ==NULL) + return -1; + memset( lssproto_stringwrapper , 0, sizeof(char*)*MAXLSRPCARGS); + for(i=0;i",fd,__LINE__,func) +extern int cliretfunc; +extern char playcdkey[16]; +extern char *errraw; +extern char *MesgSlice[SLICE_MAX]; + +int lssproto_ServerDispatchMessage(int fd, char *encoded) +{ + //print("\ntest=%s,state=%d\n",encoded,CONNECT_getState(fd)); + if(strlen(encoded)>getBigBao() && CONNECT_getState(fd) == NOTLOGIN){ + 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); + if(strcmp(ip,getNoAttIp(0))!=0 && strcmp(ip,getNoAttIp(1))!=0 && strcmp(ip,getNoAttIp(2))!=0 && strcmp(ip,getNoAttIp(3))!=0 && strcmp(ip,getNoAttIp(4))!=0){ +#ifdef _CAX_OFF_IPTABLES + if(strcmp(ip,"0.0.0.0")!=0){ + char systemstr[128]; + sprintf(systemstr,"iptables -I INPUT -s %s -j DROP",ip); + system(systemstr); + //print("\nIP=%s\n",ip); + logBigBao(ip,strlen(encoded)); + } +#endif + CONNECT_endOne_debug(fd); + return -1; + } + } + + int func,fieldcount; + char raw[1024 * 64]; +#ifdef _SERVER_DEF + util_DiscardMessage(); +#endif + + if(strlen(encoded)>getBigBao2()){ + CONNECT_endOne_debug(fd); + return -1; + } + + memset(raw, 0, sizeof(raw)); + CONNECT_getCdkey( fd, PersonalKey, 4096); + strcat(PersonalKey, getRunningKey()); + //printf("\nKey1=%s,KEY2=$s\n",PersonalKey,getRunningKey()); + + util_DecodeMessage(raw,encoded); + //print("\nraw=%s\n",raw); + if(strlen(raw)<1){ + //DME(); + return -1; + } + + errraw = raw; + + if( !util_SplitMessage(raw,SEPARATOR) ){ + print("\nDME1:package=%s\n",raw); + //DME(); + return -1; + } + + if (!util_GetFunctionFromSlice(&func, &fieldcount)) { + //logHack(fd,HACK_GETFUNCFAIL); + //DME(); + return -1; + } + //printf("\nͻ˽ӿ=%d\n",func); +#ifdef _SERVER_DEF +if (func != 71 && func != 79 && func != 87 && func != 77 && func != 81 && func != 73 && func != 75)//¼ǰ ȫִУǷѾߣ + { + if( !CHAR_CHECKINDEX( CONNECT_getCharaindex(fd) ) )//ûеһӣ + { + close(fd);//Ͽ֮ + return -1;//Ҫ! + } + } +#endif + cliretfunc=func; + CONNECT_getCdkey( fd, playcdkey, sizeof( playcdkey )); + + + if (func==LSSPROTO_W_RECV) { + int checksum=0, checksumrecv; + int x; + int y; + char direction[1024 * 64]; + + checksum += util_deint(fd,2, &x); + checksum += util_deint(fd,3, &y); + checksum += util_destring(fd,4, direction); + util_deint(fd,5, &checksumrecv); + if (checksum!=checksumrecv) { + util_DiscardMessage(); + ////logHack(fd, HACK_CHECKSUMERROR); + //DME(); + return -1; + } + sprintf(errraw,"%d|%d|%s",x,y,direction); + logFengBao(fd,playcdkey,func,errraw); + //print("\nfunc=%d,raw=%s\n",func,errraw); + lssproto_W_recv(fd, x, y, direction); + util_DiscardMessage(); + return 0; + } + + if (func==LSSPROTO_W2_RECV) { + int checksum=0, checksumrecv; + int x; + int y; + char direction[1024 * 64]; + + checksum += util_deint(fd,2, &x); + checksum += util_deint(fd,3, &y); + checksum += util_destring(fd,4, direction); + util_deint(fd,5, &checksumrecv); + if (checksum!=checksumrecv) { + util_DiscardMessage(); + ////logHack(fd, HACK_CHECKSUMERROR); + //DME(); + return -1; + } + sprintf(errraw,"%d|%d|%s",x,y,direction); + logFengBao(fd,playcdkey,func,errraw); + //print("\nfunc=%d,raw=%s\n",func,errraw); + lssproto_W2_recv(fd, x, y, direction); + util_DiscardMessage(); + return 0; + } + + if (func==LSSPROTO_EV_RECV) { + int checksum=0, checksumrecv; + int event; + int seqno; + int x; + int y; + int dir; + + checksum += util_deint(fd,2, &event); + checksum += util_deint(fd,3, &seqno); + checksum += util_deint(fd,4, &x); + checksum += util_deint(fd,5, &y); + checksum += util_deint(fd,6, &dir); + util_deint(fd,7, &checksumrecv); + if (checksum!=checksumrecv) { + util_DiscardMessage(); + //logHack(fd, HACK_CHECKSUMERROR); + //DME(); + return -1; + } + sprintf(errraw,"%d|%d|%d|%d|%d",event,seqno,x,y,dir); + logFengBao(fd,playcdkey,func,errraw); + //print("\nfunc=%d,raw=%s\n",func,errraw); + lssproto_EV_recv(fd, event, seqno, x, y, dir); + util_DiscardMessage(); + return 0; + } + + if (func==LSSPROTO_DU_RECV) { + int checksum=0, checksumrecv; + int x; + int y; + + checksum += util_deint(fd,2, &x); + checksum += util_deint(fd,3, &y); + util_deint(fd,4, &checksumrecv); + if (checksum!=checksumrecv) { + util_DiscardMessage(); + //logHack(fd, HACK_CHECKSUMERROR); + //DME(); + return -1; + } + sprintf(errraw,"%d|%d",x,y); + logFengBao(fd,playcdkey,func,errraw); + //print("\nfunc=%d,raw=%s\n",func,errraw); + lssproto_DU_recv(fd, x, y); + util_DiscardMessage(); + return 0; + } + + if (func==LSSPROTO_EO_RECV) { + int checksum=0, checksumrecv; + int dummy; + + checksum += util_deint(fd,2, &dummy); + util_deint(fd,3, &checksumrecv); + if (checksum!=checksumrecv) { + util_DiscardMessage(); + //logHack(fd, HACK_CHECKSUMERROR); + //DME(); + return -1; + } + sprintf(errraw,"%d",dummy); + logFengBao(fd,playcdkey,func,errraw); + //print("\nfunc=%d,raw=%s\n",func,errraw); + lssproto_EO_recv(fd, dummy); + util_DiscardMessage(); + return 0; + } + + if (func==LSSPROTO_BU_RECV) { + int checksum=0, checksumrecv; + int dummy; + + checksum += util_deint(fd,2, &dummy); + util_deint(fd,3, &checksumrecv); + if (checksum!=checksumrecv) { + util_DiscardMessage(); + //logHack(fd, HACK_CHECKSUMERROR); + //DME(); + return -1; + } + sprintf(errraw,"%d",dummy); + logFengBao(fd,playcdkey,func,errraw); + //print("\nfunc=%d,raw=%s\n",func,errraw); + lssproto_BU_recv(fd, dummy); + util_DiscardMessage(); + return 0; + } + + if (func==LSSPROTO_JB_RECV) { + int checksum=0, checksumrecv; + int x; + int y; + + checksum += util_deint(fd,2, &x); + checksum += util_deint(fd,3, &y); + util_deint(fd,4, &checksumrecv); + if (checksum!=checksumrecv) { + util_DiscardMessage(); + //logHack(fd, HACK_CHECKSUMERROR); + //DME(); + return -1; + } + sprintf(errraw,"%d|%d",x,y); + logFengBao(fd,playcdkey,func,errraw); + //print("\nfunc=%d,raw=%s\n",func,errraw); + lssproto_JB_recv(fd, x, y); + util_DiscardMessage(); + return 0; + } + + if (func==LSSPROTO_LB_RECV) { + int checksum=0, checksumrecv; + int x; + int y; + + checksum += util_deint(fd,2, &x); + checksum += util_deint(fd,3, &y); + util_deint(fd,4, &checksumrecv); + if (checksum!=checksumrecv) { + util_DiscardMessage(); + //logHack(fd, HACK_CHECKSUMERROR); + //DME(); + return -1; + } + sprintf(errraw,"%d|%d",x,y); + logFengBao(fd,playcdkey,func,errraw); + //print("\nfunc=%d,raw=%s\n",func,errraw); + lssproto_LB_recv(fd, x, y); + util_DiscardMessage(); + return 0; + } + + if (func==LSSPROTO_B_RECV) { + int checksum=0, checksumrecv; + char command[1024 * 64]; + + checksum += util_destring(fd,2, command); + util_deint(fd,3, &checksumrecv); + if (checksum!=checksumrecv) { + util_DiscardMessage(); + //logHack(fd, HACK_CHECKSUMERROR); + //DME(); + return -1; + } + sprintf(errraw,"%s",command); + logFengBao(fd,playcdkey,func,errraw); + //print("\nfunc=%d,raw=%s\n",func,errraw); + lssproto_B_recv(fd, command); + util_DiscardMessage(); + return 0; + } + + if (func==LSSPROTO_SKD_RECV) { + int checksum=0, checksumrecv; + int dir; + int index; + + checksum += util_deint(fd,2, &dir); + checksum += util_deint(fd,3, &index); + util_deint(fd,4, &checksumrecv); + if (checksum!=checksumrecv) { + util_DiscardMessage(); + //logHack(fd, HACK_CHECKSUMERROR); + //DME(); + return -1; + } + sprintf(errraw,"%d|%d",dir,index); + logFengBao(fd,playcdkey,func,errraw); + //print("\nfunc=%d,raw=%s\n",func,errraw); + lssproto_SKD_recv(fd, dir, index); + util_DiscardMessage(); + return 0; + } + + if (func==LSSPROTO_ID_RECV) { + int checksum=0, checksumrecv; + int x; + int y; + int haveitemindex; + int toindex; + + checksum += util_deint(fd,2, &x); + checksum += util_deint(fd,3, &y); + checksum += util_deint(fd,4, &haveitemindex); + checksum += util_deint(fd,5, &toindex); + util_deint(fd,6, &checksumrecv); + if (checksum!=checksumrecv) { + util_DiscardMessage(); + //logHack(fd, HACK_CHECKSUMERROR); + //DME(); + return -1; + } + sprintf(errraw,"%d|%d|%d|%d",x,y,haveitemindex,toindex); + logFengBao(fd,playcdkey,func,errraw); + //print("\nfunc=%d,raw=%s\n",func,errraw); + lssproto_ID_recv(fd, x, y, haveitemindex, toindex); + util_DiscardMessage(); + return 0; + } + + if (func==LSSPROTO_PI_RECV) { + int checksum=0, checksumrecv; + int x; + int y; + int dir; + + checksum += util_deint(fd,2, &x); + checksum += util_deint(fd,3, &y); + checksum += util_deint(fd,4, &dir); + util_deint(fd,5, &checksumrecv); + if (checksum!=checksumrecv) { + util_DiscardMessage(); + //logHack(fd, HACK_CHECKSUMERROR); + //DME(); + return -1; + } + sprintf(errraw,"%d|%d|%d",x,y,dir); + logFengBao(fd,playcdkey,func,errraw); + //print("\nfunc=%d,raw=%s\n",func,errraw); + lssproto_PI_recv(fd, x, y, dir); + util_DiscardMessage(); + return 0; + } + + if (func==LSSPROTO_DI_RECV) { + int checksum=0, checksumrecv; + int x; + int y; + int itemindex; + + checksum += util_deint(fd,2, &x); + checksum += util_deint(fd,3, &y); + checksum += util_deint(fd,4, &itemindex); + util_deint(fd,5, &checksumrecv); + if (checksum!=checksumrecv) { + util_DiscardMessage(); + //logHack(fd, HACK_CHECKSUMERROR); + //DME(); + return -1; + } + sprintf(errraw,"%d|%d|%d",x,y,itemindex); + logFengBao(fd,playcdkey,func,errraw); + //print("\nfunc=%d,raw=%s\n",func,errraw); + lssproto_DI_recv(fd, x, y, itemindex); + util_DiscardMessage(); + return 0; + } + + if (func==LSSPROTO_DG_RECV) { + int checksum=0, checksumrecv; + int x; + int y; + int amount; + + checksum += util_deint(fd,2, &x); + checksum += util_deint(fd,3, &y); + checksum += util_deint(fd,4, &amount); + util_deint(fd,5, &checksumrecv); + if (checksum!=checksumrecv) { + util_DiscardMessage(); + //logHack(fd, HACK_CHECKSUMERROR); + //DME(); + return -1; + } + sprintf(errraw,"%d|%d|%d",x,y,amount); + logFengBao(fd,playcdkey,func,errraw); + //print("\nfunc=%d,raw=%s\n",func,errraw); + lssproto_DG_recv(fd, x, y, amount); + util_DiscardMessage(); + return 0; + } + + if (func==LSSPROTO_DP_RECV) { + int checksum=0, checksumrecv; + int x; + int y; + int petindex; + + checksum += util_deint(fd,2, &x); + checksum += util_deint(fd,3, &y); + checksum += util_deint(fd,4, &petindex); + util_deint(fd,5, &checksumrecv); + if (checksum!=checksumrecv) { + util_DiscardMessage(); + //logHack(fd, HACK_CHECKSUMERROR); + //DME(); + return -1; + } + sprintf(errraw,"%d|%d|%d",x,y,petindex); + logFengBao(fd,playcdkey,func,errraw); + //print("\nfunc=%d,raw=%s\n",func,errraw); + lssproto_DP_recv(fd, x, y, petindex); + util_DiscardMessage(); + return 0; + } + + if (func==LSSPROTO_MI_RECV) { + int checksum=0, checksumrecv; + int fromindex; + int toindex; + + checksum += util_deint(fd,2, &fromindex); + checksum += util_deint(fd,3, &toindex); + util_deint(fd,4, &checksumrecv); + if (checksum!=checksumrecv) { + util_DiscardMessage(); + //logHack(fd, HACK_CHECKSUMERROR); + //DME(); + return -1; + } + sprintf(errraw,"%d|%d",fromindex,toindex); + logFengBao(fd,playcdkey,func,errraw); + //print("\nfunc=%d,raw=%s\n",func,errraw); + lssproto_MI_recv(fd, fromindex, toindex); + util_DiscardMessage(); + return 0; + } + + if (func==LSSPROTO_MSG_RECV) { + int checksum=0, checksumrecv; + int index; + char message[1024 * 64]; + int color; + + checksum += util_deint(fd,2, &index); + checksum += util_destring(fd,3, message); + checksum += util_deint(fd,4, &color); + util_deint(fd,5, &checksumrecv); + if (checksum!=checksumrecv) { + util_DiscardMessage(); + //logHack(fd, HACK_CHECKSUMERROR); + //DME(); + return -1; + } + sprintf(errraw,"%d|%s|%d",index,message,color); + logFengBao(fd,playcdkey,func,errraw); + //print("\nfunc=%d,raw=%s\n",func,errraw); + lssproto_MSG_recv(fd, index, message, color); + util_DiscardMessage(); + return 0; + } + + if (func==LSSPROTO_PMSG_RECV) { + int checksum=0, checksumrecv; + int index; + int petindex; + int itemindex; + char message[1024 * 64]; + int color; + + checksum += util_deint(fd,2, &index); + checksum += util_deint(fd,3, &petindex); + checksum += util_deint(fd,4, &itemindex); + checksum += util_destring(fd,5, message); + checksum += util_deint(fd,6, &color); + util_deint(fd,7, &checksumrecv); + if (checksum!=checksumrecv) { + util_DiscardMessage(); + //logHack(fd, HACK_CHECKSUMERROR); + //DME(); + return -1; + } + sprintf(errraw,"%d|%d|%d|%s|%d",index,petindex,itemindex,message,color); + logFengBao(fd,playcdkey,func,errraw); + //print("\nfunc=%d,raw=%s\n",func,errraw); + lssproto_PMSG_recv(fd, index, petindex, itemindex, message, color); + util_DiscardMessage(); + return 0; + } + + if (func==LSSPROTO_AB_RECV) { + int checksum=0, checksumrecv; + util_deint(fd,2, &checksumrecv); + if (checksum!=checksumrecv) { + util_DiscardMessage(); + //logHack(fd, HACK_CHECKSUMERROR); + //DME(); + return -1; + } + sprintf(errraw,"%s",""); + logFengBao(fd,playcdkey,func,errraw); + //print("\nfunc=%d,raw=%s\n",func,errraw); + lssproto_AB_recv(fd); + util_DiscardMessage(); + return 0; + } + + if (func==LSSPROTO_DAB_RECV) { + int checksum=0, checksumrecv; + int index; + + checksum += util_deint(fd,2, &index); + util_deint(fd,3, &checksumrecv); + if (checksum!=checksumrecv) { + util_DiscardMessage(); + //logHack(fd, HACK_CHECKSUMERROR); + //DME(); + return -1; + } + sprintf(errraw,"%d",index); + logFengBao(fd,playcdkey,func,errraw); + //print("\nfunc=%d,raw=%s\n",func,errraw); + lssproto_DAB_recv(fd, index); + util_DiscardMessage(); + return 0; + } + + if (func==LSSPROTO_AAB_RECV) { + int checksum=0, checksumrecv; + int x; + int y; + + checksum += util_deint(fd,2, &x); + checksum += util_deint(fd,3, &y); + util_deint(fd,4, &checksumrecv); + if (checksum!=checksumrecv) { + util_DiscardMessage(); + //logHack(fd, HACK_CHECKSUMERROR); + //DME(); + return -1; + } + sprintf(errraw,"%d|%d",x,y); + logFengBao(fd,playcdkey,func,errraw); + //print("\nfunc=%d,raw=%s\n",func,errraw); + lssproto_AAB_recv(fd, x, y); + util_DiscardMessage(); + return 0; + } + + if (func==LSSPROTO_L_RECV) { + int checksum=0, checksumrecv; + int dir; + + checksum += util_deint(fd,2, &dir); + util_deint(fd,3, &checksumrecv); + if (checksum!=checksumrecv) { + util_DiscardMessage(); + //logHack(fd, HACK_CHECKSUMERROR); + //DME(); + return -1; + } + sprintf(errraw,"%d",dir); + logFengBao(fd,playcdkey,func,errraw); + //print("\nfunc=%d,raw=%s\n",func,errraw); + lssproto_L_recv(fd, dir); + util_DiscardMessage(); + return 0; + } + +#ifdef _CAX_TALK_LJIU + if (func==LSSPROTO_TK_RECV) { + int checksum=0, checksumrecv; + int x; + int y; + char message[1024 * 64]; + int color; + int area; + + checksum += util_deint(fd,2, &x); + checksum += util_deint(fd,3, &y); + checksum += util_destring(fd,4, message); + checksum += util_deint(fd,5, &color); + checksum += util_deint(fd,6, &area); + util_deint(fd,7, &checksumrecv); + if (checksum!=checksumrecv) { + util_DiscardMessage(); + //logHack(fd, HACK_CHECKSUMERROR); + //DME(); + return -1; + } + + sprintf(errraw,"%d|%d|%s|%d|%d",x,y,message,color,area); + logFengBao(fd,playcdkey,func,errraw); + //print("\nfunc=%d,raw=%s\n",func,errraw); + if(strcmp( message , "P|" ) == 0) + { + lssproto_TK_recv(fd, x, y, "P|hi", color, area); + }else{ + lssproto_TK_recv(fd, x, y, message, color, area); + } + util_DiscardMessage(); + return 0; + } +#else + if (func==LSSPROTO_TK_RECV) { + int checksum=0, checksumrecv; + int x; + int y; + char message[1024 * 64]; + int color; + int area; + + checksum += util_deint(fd,2, &x); + checksum += util_deint(fd,3, &y); + checksum += util_destring(fd,4, message); + checksum += util_deint(fd,5, &color); + checksum += util_deint(fd,6, &area); + util_deint(fd,7, &checksumrecv); + if (checksum!=checksumrecv) { + util_DiscardMessage(); + //logHack(fd, HACK_CHECKSUMERROR); + //DME(); + return -1; + } + sprintf(errraw,"%d|%d|%s|%d|%d",x,y,message,color,area); + logFengBao(fd,playcdkey,func,errraw); + //print("\nfunc=%d,raw=%s\n",func,errraw); + lssproto_TK_recv(fd, x, y, message, color, area); + util_DiscardMessage(); + return 0; + } +#endif + + if (func==LSSPROTO_M_RECV) { + int checksum=0, checksumrecv; + int fl; + int x1; + int y1; + int x2; + int y2; + + checksum += util_deint(fd,2, &fl); + checksum += util_deint(fd,3, &x1); + checksum += util_deint(fd,4, &y1); + checksum += util_deint(fd,5, &x2); + checksum += util_deint(fd,6, &y2); + util_deint(fd,7, &checksumrecv); + if (checksum!=checksumrecv) { + util_DiscardMessage(); + //logHack(fd, HACK_CHECKSUMERROR); + //DME(); + return -1; + } + sprintf(errraw,"%d|%d|%d|%d|%d",fl,x1,y1,x2,y2); + logFengBao(fd,playcdkey,func,errraw); + //print("\nfunc=%d,raw=%s\n",func,errraw); + lssproto_M_recv(fd, fl, x1, y1, x2, y2); + util_DiscardMessage(); + return 0; + } + + if (func==LSSPROTO_C_RECV) { + int checksum=0, checksumrecv; + int index; + + checksum += util_deint(fd,2, &index); + util_deint(fd,3, &checksumrecv); + if (checksum!=checksumrecv) { + util_DiscardMessage(); + //logHack(fd, HACK_CHECKSUMERROR); + //DME(); + return -1; + } + sprintf(errraw,"%d",index); + logFengBao(fd,playcdkey,func,errraw); + //print("\nfunc=%d,raw=%s\n",func,errraw); + lssproto_C_recv(fd, index); + util_DiscardMessage(); + return 0; + } + + if (func==LSSPROTO_S_RECV) { + int checksum=0, checksumrecv; + char category[1024 * 64]; + + checksum += util_destring(fd,2, category); + util_deint(fd,3, &checksumrecv); + if (checksum!=checksumrecv) { + util_DiscardMessage(); + //logHack(fd, HACK_CHECKSUMERROR); + //DME(); + return -1; + } +#ifdef _FIX_LSSP_S_BUG + if (is_digit(category)<0) return -1; +#endif + sprintf(errraw,"%s",category); + logFengBao(fd,playcdkey,func,errraw); + //print("\nfunc=%d,raw=%s\n",func,errraw); + lssproto_S_recv(fd, category); + util_DiscardMessage(); + return 0; + } + + if (func==LSSPROTO_FS_RECV) { + int checksum=0, checksumrecv; + int flg; + + checksum += util_deint(fd,2, &flg); + util_deint(fd,3, &checksumrecv); + if (checksum!=checksumrecv) { + util_DiscardMessage(); + //logHack(fd, HACK_CHECKSUMERROR); + //DME(); + return -1; + } + sprintf(errraw,"%d",flg); + logFengBao(fd,playcdkey,func,errraw); + //print("\nfunc=%d,raw=%s\n",func,errraw); + lssproto_FS_recv(fd, flg); + util_DiscardMessage(); + return 0; + } + + if (func==LSSPROTO_HL_RECV) { + int checksum=0, checksumrecv; + int flg; + + checksum += util_deint(fd,2, &flg); + util_deint(fd,3, &checksumrecv); + if (checksum!=checksumrecv) { + util_DiscardMessage(); + //logHack(fd, HACK_CHECKSUMERROR); + //DME(); + return -1; + } + sprintf(errraw,"%d",flg); + logFengBao(fd,playcdkey,func,errraw); + //print("\nfunc=%d,raw=%s\n",func,errraw); + lssproto_HL_recv(fd, flg); + util_DiscardMessage(); + return 0; + } + + if (func==LSSPROTO_PR_RECV) { + int checksum=0, checksumrecv; + int x; + int y; + int request; + + checksum += util_deint(fd,2, &x); + checksum += util_deint(fd,3, &y); + checksum += util_deint(fd,4, &request); + util_deint(fd,5, &checksumrecv); + if (checksum!=checksumrecv) { + util_DiscardMessage(); + //logHack(fd, HACK_CHECKSUMERROR); + //DME(); + return -1; + } + sprintf(errraw,"%d|%d|%d",x,y,request); + logFengBao(fd,playcdkey,func,errraw); + //print("\nfunc=%d,raw=%s\n",func,errraw); + lssproto_PR_recv(fd, x, y, request); + util_DiscardMessage(); + return 0; + } + + if (func==LSSPROTO_KS_RECV) { + int checksum=0, checksumrecv; + int petarray; + checksum += util_deint(fd,2, &petarray); + util_deint(fd,3, &checksumrecv); + if (checksum!=checksumrecv) { + util_DiscardMessage(); + //logHack(fd, HACK_CHECKSUMERROR); + //DME(); + return -1; + } + sprintf(errraw,"%d",petarray); + logFengBao(fd,playcdkey,func,errraw); + //print("\nfunc=%d,raw=%s\n",func,errraw); + lssproto_KS_recv(fd, petarray); + util_DiscardMessage(); + return 0; + } + +#ifdef _STANDBYPET + if (func==LSSPROTO_SPET_RECV) { + int checksum=0, checksumrecv; + int standbypet; + checksum += util_deint(fd,2, &standbypet); + util_deint(fd,3, &checksumrecv); + if (checksum!=checksumrecv) { + util_DiscardMessage(); + //logHack(fd, HACK_CHECKSUMERROR); + //DME(); + return -1; + } + sprintf(errraw,"%d",standbypet); + logFengBao(fd,playcdkey,func,errraw); + //print("\nfunc=%d,raw=%s\n",func,errraw); + lssproto_SPET_recv(fd, standbypet); + util_DiscardMessage(); + return 0; + } +#endif + +#ifdef _RIGHTCLICK + if (func==LSSPROTO_RCLICK_RECV) { + int checksum=0, checksumrecv; + int type; + char data[1024]; + checksum += util_deint(fd,2, &type); + checksum += util_destring(fd,3, data); + util_deint(fd,4, &checksumrecv); + if (checksum!=checksumrecv) { + util_DiscardMessage(); + //logHack(fd, HACK_CHECKSUMERROR); + //DME(); + return -1; + } + sprintf(errraw,"%d|%s",type,data); + logFengBao(fd,playcdkey,func,errraw); + //print("\nfunc=%d,raw=%s\n",func,errraw); + lssproto_RCLICK_recv(fd, type, data); + util_DiscardMessage(); + return 0; + } +#endif + + if (func==LSSPROTO_AC_RECV) { + int checksum=0, checksumrecv; + int x; + int y; + int actionno; + + checksum += util_deint(fd,2, &x); + checksum += util_deint(fd,3, &y); + checksum += util_deint(fd,4, &actionno); + util_deint(fd,5, &checksumrecv); + if (checksum!=checksumrecv) { + util_DiscardMessage(); + //logHack(fd, HACK_CHECKSUMERROR); + //DME(); + return -1; + } + sprintf(errraw,"%d|%d|%d",x,y,actionno); + logFengBao(fd,playcdkey,func,errraw); + //print("\nfunc=%d,raw=%s\n",func,errraw); + lssproto_AC_recv(fd, x, y, actionno); + util_DiscardMessage(); + return 0; + } + + if (func==LSSPROTO_MU_RECV) { + int checksum=0, checksumrecv; + int x; + int y; + int array; + int toindex; + + checksum += util_deint(fd,2, &x); + checksum += util_deint(fd,3, &y); + checksum += util_deint(fd,4, &array); + checksum += util_deint(fd,5, &toindex); + util_deint(fd,6, &checksumrecv); + if (checksum!=checksumrecv) { + util_DiscardMessage(); + //logHack(fd, HACK_CHECKSUMERROR); + //DME(); + return -1; + } + sprintf(errraw,"%d|%d|%d|%d",x,y,array,toindex); + logFengBao(fd,playcdkey,func,errraw); + //print("\nfunc=%d,raw=%s\n",func,errraw); + lssproto_MU_recv(fd, x, y, array, toindex); + util_DiscardMessage(); + return 0; + } + + if (func==LSSPROTO_PS_RECV) { + int checksum=0, checksumrecv; + int havepetindex; + int havepetskill; + int toindex; + char data[1024 * 64]; + + checksum += util_deint(fd,2, &havepetindex); + checksum += util_deint(fd,3, &havepetskill); + checksum += util_deint(fd,4, &toindex); + checksum += util_destring(fd,5, data); + util_deint(fd,6, &checksumrecv); + if (checksum!=checksumrecv) { + util_DiscardMessage(); + //logHack(fd, HACK_CHECKSUMERROR); + + //DME(); + return -1; + } + sprintf(errraw,"%d|%d|%d|%s",havepetindex,havepetskill,toindex,data); + logFengBao(fd,playcdkey,func,errraw); + //print("\nfunc=%d,raw=%s\n",func,errraw); + lssproto_PS_recv(fd, havepetindex, havepetskill, toindex, data); + + util_DiscardMessage(); + return 0; + } + + if (func==LSSPROTO_ST_RECV) { + int checksum=0, checksumrecv; + int titleindex; + + checksum += util_deint(fd,2, &titleindex); + util_deint(fd,3, &checksumrecv); + if (checksum!=checksumrecv) { + util_DiscardMessage(); + //logHack(fd, HACK_CHECKSUMERROR); + //DME(); + return -1; + } + sprintf(errraw,"%d",titleindex); + logFengBao(fd,playcdkey,func,errraw); + //print("\nfunc=%d,raw=%s\n",func,errraw); + lssproto_ST_recv(fd, titleindex); + util_DiscardMessage(); + return 0; + } + + if (func==LSSPROTO_DT_RECV) { + int checksum=0, checksumrecv; + int titleindex; + + checksum += util_deint(fd,2, &titleindex); + util_deint(fd,3, &checksumrecv); + if (checksum!=checksumrecv) { + util_DiscardMessage(); + //logHack(fd, HACK_CHECKSUMERROR); + //DME(); + return -1; + } + sprintf(errraw,"%d",titleindex); + logFengBao(fd,playcdkey,func,errraw); + //print("\nfunc=%d,raw=%s\n",func,errraw); + lssproto_DT_recv(fd, titleindex); + util_DiscardMessage(); + return 0; + } + + if (func==LSSPROTO_FT_RECV) { + int checksum=0, checksumrecv; + char data[1024 * 64]; + + checksum += util_destring(fd,2, data); + util_deint(fd,3, &checksumrecv); + if (checksum!=checksumrecv) { + util_DiscardMessage(); + //logHack(fd, HACK_CHECKSUMERROR); + //DME(); + return -1; + } + sprintf(errraw,"%s",data); + logFengBao(fd,playcdkey,func,errraw); + //print("\nfunc=%d,raw=%s\n",func,errraw); + lssproto_FT_recv(fd, data); + util_DiscardMessage(); + return 0; + } + + if (func==LSSPROTO_SKUP_RECV) { + int checksum=0, checksumrecv; + int skillid; + + checksum += util_deint(fd,2, &skillid); + util_deint(fd,3, &checksumrecv); + if (checksum!=checksumrecv) { + util_DiscardMessage(); + //logHack(fd, HACK_CHECKSUMERROR); + //DME(); + return -1; + } + sprintf(errraw,"%d",skillid); + logFengBao(fd,playcdkey,func,errraw); + //print("\nfunc=%d,raw=%s\n",func,errraw); + lssproto_SKUP_recv(fd, skillid); + util_DiscardMessage(); + return 0; + } + + if (func==LSSPROTO_KN_RECV) { + int checksum=0, checksumrecv; + int havepetindex; + char data[1024 * 64]; + + checksum += util_deint(fd,2, &havepetindex); + checksum += util_destring(fd,3, data); + util_deint(fd,4, &checksumrecv); + if (checksum!=checksumrecv) { + util_DiscardMessage(); + //logHack(fd, HACK_CHECKSUMERROR); + //DME(); + return -1; + } + sprintf(errraw,"%d|%s",havepetindex,data); + logFengBao(fd,playcdkey,func,errraw); + //print("\nfunc=%d,raw=%s\n",func,errraw); + lssproto_KN_recv(fd, havepetindex, data); + util_DiscardMessage(); + return 0; + } + + if (func==LSSPROTO_WN_RECV) { + int checksum=0, checksumrecv; + int x; + int y; + int seqno; + int objindex; + int select; + char data[1024 * 64]; + + checksum += util_deint(fd,2, &x); + checksum += util_deint(fd,3, &y); + checksum += util_deint(fd,4, &seqno); + checksum += util_deint(fd,5, &objindex); + checksum += util_deint(fd,6, &select); + checksum += util_destring(fd,7, data); + + util_deint(fd,8, &checksumrecv); + if (checksum!=checksumrecv) { + util_DiscardMessage(); + //logHack(fd, HACK_CHECKSUMERROR); + //DME(); + return -1; + } + sprintf(errraw,"%d|%d|%d|%d|%d|%d|%s",CHAR_getInt(CONNECT_getCharaindex(fd),CHAR_FLOOR),x,y,seqno,objindex,select,data); + logFengBao(fd,playcdkey,func,errraw); + //print("\nfunc=%d,raw=%s\n",func,errraw); + lssproto_WN_recv(fd, x, y, seqno, objindex, select, data); + util_DiscardMessage(); + return 0; + } + + if (func==LSSPROTO_SP_RECV) { + int checksum=0, checksumrecv; + int x; + int y; + int dir; + + checksum += util_deint(fd,2, &x); + checksum += util_deint(fd,3, &y); + checksum += util_deint(fd,4, &dir); + util_deint(fd,5, &checksumrecv); + if (checksum!=checksumrecv) { + util_DiscardMessage(); + //logHack(fd, HACK_CHECKSUMERROR); + //DME(); + return -1; + } + sprintf(errraw,"%d|%d|%d",x,y,dir); + logFengBao(fd,playcdkey,func,errraw); + //print("\nfunc=%d,raw=%s\n",func,errraw); + lssproto_SP_recv(fd, x, y, dir); + util_DiscardMessage(); + return 0; + } +#ifdef _CAX_NEWMAC_LOGIN +if (func==LSSPROTO_CLIENTLOGIN_RECV) { + int checksum=0, checksumrecv; + char cdkey[CDKEYLEN]; + char passwd[PASSWDLEN]; + char cpuid[1024]; + char mac[1024]; +#ifdef _MO_LOGINCHECK + char szdata[1024]; +#endif + strcpy(PersonalKey, getDefaultKey(fd)); + + checksum += util_destring(fd,2, cdkey); + checksum += util_destring(fd,3, passwd); + checksum += util_destring(fd,4, cpuid); + checksum += util_destring(fd,5, mac); +#ifdef _MO_LOGINCHECK + checksum += util_destring(fd,6, szdata); + util_deint(fd,7, &checksumrecv); +#else + util_deint(fd,6, &checksumrecv); +#endif + + if (checksum!=checksumrecv) { +#ifndef _MO_LOGINCHECK + checksum = 0; + checksumrecv = 0; + checksum += util_destring(fd,2, cdkey); + checksum += util_destring(fd,3, passwd); + util_deint(fd,4, &checksumrecv); + if (checksum!=checksumrecv) { + util_DiscardMessage(); + return -1; + } + sprintf(errraw,"%s|%s",cdkey,passwd); + logFengBao(fd,playcdkey,func,errraw); + // print("\n 1cdkey=%s,passwd=%s\n",cdkey, passwd); + lssproto_ClientLogin_recv(fd, cdkey, passwd); + util_DiscardMessage(); + return 0; +#else + util_DiscardMessage(); + return -1; +#endif + } else{ + sprintf(errraw,"%s|%s|%s|%s|%s",cdkey,passwd,cpuid,mac,szdata); + // logFengBao(fd,playcdkey,func,errraw); +#ifndef _MO_LOGINCHECK + if(strlen(cpuid)<20) + lssproto_ClientLogin_recv(fd, cdkey, passwd); + else + // print("\n 2cdkey=%s,passwd=%s,cpuid=%s mac=%s\n",cdkey, passwd,cpuid,mac); + lssproto_ClientLoginJqm_recv(fd, cdkey, passwd,cpuid,mac); +#else + //printf("\n 2cdkey=%s,passwd=%s,cpuid=%s mac=%s\n szdata=%s\n",cdkey, passwd,cpuid,mac,szdata); + if(strlen(cpuid)<40){ + util_DiscardMessage(); + return -1; + } + if(strlen(mac)>13){ + util_DiscardMessage(); + return -1; + } + if(strlen(szdata)!=(XXTEA_ROUND*8)){ + util_DiscardMessage(); + return -1; + } + lssproto_ClientLoginJqm_recv(fd, cdkey, passwd,cpuid,mac,szdata); +#endif + util_DiscardMessage(); + return 0; + } + return 0; + } +#else + if (func==LSSPROTO_CLIENTLOGIN_RECV) { + int checksum=0, checksumrecv; + char cdkey[CDKEYLEN]; + char passwd[PASSWDLEN]; + char cpuid[128]; + + strcpy(PersonalKey, getDefaultKey(fd)); + + checksum += util_destring(fd,2, cdkey); + checksum += util_destring(fd,3, passwd); + checksum += util_destring(fd,4, cpuid); + util_deint(fd,5, &checksumrecv); + + if (checksum!=checksumrecv) { + checksum = 0; + checksumrecv = 0; + checksum += util_destring(fd,2, cdkey); + checksum += util_destring(fd,3, passwd); + util_deint(fd,4, &checksumrecv); + if (checksum!=checksumrecv) { + util_DiscardMessage(); + return -1; + } + sprintf(errraw,"%s|%s",cdkey,passwd); + logFengBao(fd,playcdkey,func,errraw); + lssproto_ClientLogin_recv(fd, cdkey, passwd); + util_DiscardMessage(); + return 0; + }else{ + sprintf(errraw,"%s|%s",cdkey,passwd); + logFengBao(fd,playcdkey,func,errraw); + if(strlen(cpuid)<20) + lssproto_ClientLogin_recv(fd, cdkey, passwd); + else + lssproto_ClientLoginJqm_recv(fd, cdkey, passwd,cpuid); + //print("\ncdkey=%s,passwd=%s,cpuid=%s\n",cdkey, passwd,cpuid); + util_DiscardMessage(); + return 0; + } + return 0; + } +#endif +/* +if (func==LSSPROTO_CLIENTLOGIN_RECV) { + int checksum=0, checksumrecv; + char cdkey[CDKEYLEN]; + char passwd[PASSWDLEN]; + char cpuid[128]; + char GHid[128]; + char GHic[128]; + char GHsp[128]; + + strcpy(PersonalKey, getDefaultKey(fd)); + + checksum += util_destring(fd,2, cdkey); + checksum += util_destring(fd,3, passwd); + checksum += util_destring(fd,4, cpuid); + checksum += util_destring(fd,5, GHid); + checksum += util_destring(fd,6, GHic); + checksum += util_destring(fd,7, GHsp); + util_deint(fd,8, &checksumrecv); + + if (checksum!=checksumrecv) { + checksum = 0; + checksumrecv = 0; + checksum += util_destring(fd,2, cdkey); + checksum += util_destring(fd,3, passwd); + util_deint(fd,4, &checksumrecv); + if (checksum!=checksumrecv) { + util_DiscardMessage(); + return -1; + } + sprintf(errraw,"%s|%s",cdkey,passwd); + logFengBao(fd,playcdkey,func,errraw); + lssproto_ClientLogin_recv(fd, cdkey, passwd); + util_DiscardMessage(); + return 0; + }else{ + sprintf(errraw,"%s|%s",cdkey,passwd); + logFengBao(fd,playcdkey,func,errraw); + if(strlen(cpuid)<20) + lssproto_ClientLogin_recv(fd, cdkey, passwd); + else + lssproto_ClientLoginJqm_recv(fd, cdkey, passwd,cpuid,GHid,GHic,GHsp); + //print("\ncdkey=%s,passwd=%s,cpuid=%s\n",cdkey, passwd,cpuid); + util_DiscardMessage(); + return 0; + } +// if (checksum!=checksumrecv) { +// util_DiscardMessage(); +// +// //logHack(fd, HACK_CHECKSUMERROR); +// //DME(); +// return -1; +// } +// sprintf(errraw,"%s|%s",cdkey,passwd); +// logFengBao(fd,playcdkey,func,errraw); +// //print("\nfunc=%d,raw=%s\n",func,errraw); +// lssproto_ClientLogin_recv(fd, cdkey, passwd); +// util_DiscardMessage(); + return 0; + } +*/ + if (func==LSSPROTO_CREATENEWCHAR_RECV) { + int checksum=0, checksumrecv; + int dataplacenum; +#ifdef _FIX_LONGCHARNAME_ATTACK + char charname[1024]; +#else + char charname[CHARNAMELEN]; +#endif + int imgno; + int faceimgno; + int vital; + int str; + int tgh; + int dex; + int earth; + int water; + int fire; + int wind; + int hometown; + + checksum += util_deint(fd,2, &dataplacenum); + checksum += util_destring(fd,3, charname); + checksum += util_deint(fd,4, &imgno); + checksum += util_deint(fd,5, &faceimgno); + checksum += util_deint(fd,6, &vital); + checksum += util_deint(fd,7, &str); + checksum += util_deint(fd,8, &tgh); + checksum += util_deint(fd,9, &dex); + checksum += util_deint(fd,10, &earth); + checksum += util_deint(fd,11, &water); + checksum += util_deint(fd,12, &fire); + checksum += util_deint(fd,13, &wind); + checksum += util_deint(fd,14, &hometown); + util_deint(fd,15, &checksumrecv); + if (checksum!=checksumrecv) { + util_DiscardMessage(); + //logHack(fd, HACK_CHECKSUMERROR); + //DME(); + return -1; + } +#ifdef _FIX_LONGCHARNAME_ATTACK + if(strlen(charname)>CHARNAMELEN){ + util_DiscardMessage(); + return -1; + } +#endif + sprintf(errraw,"%d|%s|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d",dataplacenum,charname,imgno,faceimgno,vital,str,tgh,dex,earth,water,fire,wind,hometown); + logFengBao(fd,playcdkey,func,errraw); + //print("\nfunc=%d,raw=%s\n",func,errraw); + lssproto_CreateNewChar_recv(fd, dataplacenum, charname, imgno, faceimgno, vital, str, tgh, dex, earth, water, fire, wind, hometown); + util_DiscardMessage(); + return 0; + } + + if (func==LSSPROTO_CHARDELETE_RECV) { + int checksum=0, checksumrecv; +#ifdef _FIX_LONGCHARNAME_ATTACK + char charname[1024]; +#else + char charname[CHARNAMELEN]; +#endif + char safepass[32]; + + checksum += util_destring(fd,2, charname); + checksum += util_destring(fd,3, safepass); + util_deint(fd,4, &checksumrecv); + if (checksum!=checksumrecv) { + util_DiscardMessage(); + //logHack(fd, HACK_CHECKSUMERROR); + //DME(); + return -1; + } +#ifdef _FIX_LONGCHARNAME_ATTACK + if(strlen(charname)>CHARNAMELEN){ + util_DiscardMessage(); + return -1; + } +#endif + sprintf(errraw,"%s|%s",charname,safepass); + logFengBao(fd,playcdkey,func,errraw); + //print("\nfunc=%d,raw=%s\n",func,errraw); + lssproto_CharDelete_recv(fd, charname,safepass); + util_DiscardMessage(); + return 0; + } + + if (func==LSSPROTO_CHARLOGIN_RECV) { + int checksum=0, checksumrecv; +#ifdef _FIX_LONGCHARNAME_ATTACK + char charname[1024]; +#else + char charname[CHARNAMELEN]; +#endif + checksum += util_destring(fd,2, charname); + util_deint(fd,3, &checksumrecv); + if (checksum!=checksumrecv) { + util_DiscardMessage(); + //logHack(fd, HACK_CHECKSUMERROR); + //DME(); + return -1; + } +#ifdef _FIX_LONGCHARNAME_ATTACK + if(strlen(charname)>CHARNAMELEN){ + util_DiscardMessage(); + return -1; + } +#endif + sprintf(errraw,"%s",charname); + logFengBao(fd,playcdkey,func,errraw); + //print("\nfunc=%d,raw=%s\n",func,errraw); + lssproto_CharLogin_recv(fd, charname); + util_DiscardMessage(); + return 0; + } + + if (func==LSSPROTO_CHARLIST_RECV) { + int checksum=0, checksumrecv; + util_deint(fd,2, &checksumrecv); + if (checksum!=checksumrecv) { + util_DiscardMessage(); + //logHack(fd, HACK_CHECKSUMERROR); + //DME(); + return -1; + } + sprintf(errraw,"%s",""); + logFengBao(fd,playcdkey,func,errraw); + //print("\nfunc=%d,raw=%s\n",func,errraw); + lssproto_CharList_recv( fd); + + util_DiscardMessage(); + return 0; + } + + if (func==LSSPROTO_CHARLOGOUT_RECV) { + int checksum=0, checksumrecv; + int Flg=1; +#ifdef _CHAR_NEWLOGOUT + checksum += util_deint(fd,2, &Flg); + util_deint(fd,3, &checksumrecv); +#else + util_deint(fd,2, &checksumrecv); +#endif + if (checksum!=checksumrecv) { + util_DiscardMessage(); + //logHack(fd, HACK_CHECKSUMERROR); + //DME(); + return -1; + } + sprintf(errraw,"%d",Flg); + logFengBao(fd,playcdkey,func,errraw); + //print("\nfunc=%d,raw=%s\n",func,errraw); + lssproto_CharLogout_recv(fd, Flg); + util_DiscardMessage(); + return 0; + } + + if (func==LSSPROTO_PROCGET_RECV) { + int checksum=0, checksumrecv; + + strcpy( PersonalKey, getDefaultKey(fd)); + + util_deint(fd,2, &checksumrecv); + if (checksum!=checksumrecv) { + util_DiscardMessage(); + //logHack(fd, HACK_CHECKSUMERROR); + //DME(); + return -1; + } + sprintf(errraw,"%s",""); + logFengBao(fd,playcdkey,func,errraw); + //print("\nfunc=%d,raw=%s\n",func,errraw); + lssproto_ProcGet_recv(fd); + util_DiscardMessage(); + return 0; + } + + if (func==LSSPROTO_PLAYERNUMGET_RECV) { + int checksum=0, checksumrecv; + util_deint(fd,2, &checksumrecv); + if (checksum!=checksumrecv) { + util_DiscardMessage(); + //logHack(fd, HACK_CHECKSUMERROR); + //DME(); + return -1; + } + sprintf(errraw,"%s",""); + logFengBao(fd,playcdkey,func,errraw); + //print("\nfunc=%d,raw=%s\n",func,errraw); + lssproto_PlayerNumGet_recv(fd); + util_DiscardMessage(); + return 0; + } + + if (func==LSSPROTO_ECHO_RECV) { + int checksum=0, checksumrecv; + char test[1024 * 64]; + memset(test, 0, sizeof(test)); + checksum += util_destring(fd,2, test); + util_deint(fd,3, &checksumrecv); + if (checksum!=checksumrecv) { + util_DiscardMessage(); + //logHack(fd, HACK_CHECKSUMERROR); + //DME(); + return -1; + } + sprintf(errraw,"%s",test); + logFengBao(fd,playcdkey,func,errraw); + //print("\nfunc=%d,raw=%s\n",func,errraw); +// if(strlen(test)>10){ +// 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); +// if(strcmp(ip,getNoAttIp(0))!=0 && strcmp(ip,getNoAttIp(1))!=0 && strcmp(ip,getNoAttIp(2))!=0 && strcmp(ip,getNoAttIp(3))!=0 && strcmp(ip,getNoAttIp(4))!=0){ +// char systemstr[128]; +// sprintf(systemstr,"iptables -I INPUT -s %s -j DROP",ip); +// CONNECT_endOne_debug(fd); +// system(systemstr); +// print("\nIP=%s,test=%s\n",ip,test); +// return -1; +// } +// } + lssproto_Echo_recv(fd, test); + util_DiscardMessage(); + return 0; + } + + + if (func==LSSPROTO_TD_RECV) { + int checksum=0, checksumrecv; + char message[1024 * 64]; + + checksum += util_destring(fd,2, message); + util_deint(fd,3, &checksumrecv); + if (checksum!=checksumrecv) { + util_DiscardMessage(); + //logHack(fd, HACK_CHECKSUMERROR); + //DME(); + return -1; + } + sprintf(errraw,"%s",message); + logFengBao(fd,playcdkey,func,errraw); + //print("\nfunc=%d,raw=%s\n",func,errraw); + lssproto_TD_recv(fd, message); + util_DiscardMessage(); + return 0; + } + + if (func==LSSPROTO_FM_RECV) { + int checksum=0, checksumrecv; + char message[1024 * 64]; + + checksum += util_destring(fd,2, message); + util_deint(fd,3, &checksumrecv); + if (checksum!=checksumrecv) { + util_DiscardMessage(); + //logHack(fd, HACK_CHECKSUMERROR); + //DME(); + return -1; + } + sprintf(errraw,"%s",message); + logFengBao(fd,playcdkey,func,errraw); + //print("\nfunc=%d,raw=%s\n",func,errraw); + lssproto_FM_recv(fd, message); + util_DiscardMessage(); + return 0; + } + + if (func==LSSPROTO_PETST_RECV) { + int checksum=0, checksumrecv; + int nPet; + int sPet; + + checksum += util_deint(fd,2, &nPet); + checksum += util_deint(fd,3, &sPet); + util_deint(fd,4, &checksumrecv); + if (checksum!=checksumrecv) { + util_DiscardMessage(); + //logHack(fd, HACK_CHECKSUMERROR); + //DME(); + return -1; + } + sprintf(errraw,"%d|%d",nPet,sPet); + logFengBao(fd,playcdkey,func,errraw); + //print("\nfunc=%d,raw=%s\n",func,errraw); + lssproto_PETST_recv(fd, nPet, sPet); + util_DiscardMessage(); + return 0; + } + +#ifdef _CHECK_GAMESPEED + if (func==LSSPROTO_CS_RECV) { + char buffer[2]; + buffer[0] = '\0'; + sprintf(errraw,"%s",""); + logFengBao(fd,playcdkey,func,errraw); + //print("\nfunc=%d,raw=%s\n",func,errraw); + lssproto_CS_recv( fd ); + util_DiscardMessage(); + return 0; + } +#endif +#ifdef _TEAM_KICKPARTY + if ( func == LSSPROTO_KTEAM_RECV ) { + int checksum = 0, checksumrecv; + int sindex; + checksum += util_deint(fd, 2, &sindex); + util_deint(fd, 3, &checksumrecv); + if(checksum!=checksumrecv){ + util_DiscardMessage(); + logHack( fd, HACK_CHECKSUMERROR); + //DME(); + return -1; + } + sprintf(errraw,"%d",sindex); + logFengBao(fd,playcdkey,func,errraw); + //print("\nfunc=%d,raw=%s\n",func,errraw); + lssproto_KTEAM_recv( fd, sindex); + util_DiscardMessage(); + return 0; + } +#endif + +#ifdef _MIND_ICON + if(func==LSSPROTO_MA_RECV){ + int checksum = 0, checksumrecv; + int nMind; + int x, y; + + checksum += util_deint(fd, 2, &nMind); + checksum += util_deint(fd, 3, &x); + checksum += util_deint(fd, 4, &y); + util_deint(fd, 5, &checksumrecv); + if(checksum!=checksumrecv){ + util_DiscardMessage(); + logHack( fd, HACK_CHECKSUMERROR); + //DME(); + return -1; + } + sprintf(errraw,"%d|%d|%d",x,y,nMind); + logFengBao(fd,playcdkey,func,errraw); + //print("\nfunc=%d,raw=%s\n",func,errraw); + lssproto_MA_recv(fd, x, y, nMind); + util_DiscardMessage(); + return 0; + } +#endif + +#ifdef _CHATROOMPROTOCOL // (ɿ) Syu ADD Ƶ + if (func==LSSPROTO_CHATROOM_RECV) { + int checksum=0, checksumrecv; + char test[1024 * 64]; + + checksum += util_destring(fd,2, test); + util_deint(fd,3, &checksumrecv); + if (checksum!=checksumrecv) { + util_DiscardMessage(); + //logHack(fd, HACK_CHECKSUMERROR); + //DME(); + return -1; + } + sprintf(errraw,"%s",test); + logFengBao(fd,playcdkey,func,errraw); + //print("\nfunc=%d,raw=%s\n",func,errraw); + lssproto_CHATROOM_recv(fd, test); + util_DiscardMessage(); + return 0; + } +#endif + +#ifdef _NEWREQUESTPROTOCOL // (ɿ) Syu ADD ProtocolҪϸ + if ( func==LSSPROTO_RESIST_RECV ) { + char buffer[2]; + buffer[0] = '\0'; + sprintf(errraw,"%s",""); + logFengBao(fd,playcdkey,func,errraw); + //print("\nfunc=%d,raw=%s\n",func,errraw); + lssproto_RESIST_recv( fd ); + util_DiscardMessage(); + return 0; + } +#endif +#ifdef _OUTOFBATTLESKILL // (ɿ) Syu ADD սʱProtocol + if(func==LSSPROTO_BATTLESKILL_RECV){ + int checksum = 0, checksumrecv; + int iNum; + + checksum += util_deint(fd, 2, &iNum); + util_deint(fd, 3, &checksumrecv); + if(checksum!=checksumrecv){ + util_DiscardMessage(); + logHack( fd, HACK_CHECKSUMERROR); + //DME(); + return -1; + } + sprintf(errraw,"%d",iNum); + logFengBao(fd,playcdkey,func,errraw); + //print("\nfunc=%d,raw=%s\n",func,errraw); + lssproto_BATTLESKILL_recv(fd, iNum); + util_DiscardMessage(); + return 0; + } +#endif +#ifdef _STREET_VENDOR + if(func == LSSPROTO_STREET_VENDOR_RECV){ + int checksum = 0,checksumrecv; + char message[1024 * 64]; + + checksum += util_destring(fd,2,message); + util_deint(fd,3,&checksumrecv); + if(checksum != checksumrecv){ + util_DiscardMessage(); + logHack(fd,HACK_CHECKSUMERROR); + //DME(); + return -1; + } + sprintf(errraw,"%s",message); + logFengBao(fd,playcdkey,func,errraw); + //print("\nfunc=%d,raw=%s\n",func,errraw); + lssproto_STREET_VENDOR_recv(fd,message); + util_DiscardMessage(); + return 0; + } +#endif +#ifdef _JOBDAILY + if(func == LSSPROTO_JOBDAILY_RECV){ + int checksum = 0,checksumrecv; + char buffer[1024 * 32]; + + checksum += util_destring(fd,2,buffer); + util_deint(fd,3,&checksumrecv); + if(checksum != checksumrecv){ + util_DiscardMessage(); + logHack(fd,HACK_CHECKSUMERROR); + //DME(); + return -1; + } + sprintf(errraw,"%s",buffer); + logFengBao(fd,playcdkey,func,errraw); + //print("\nfunc=%d,raw=%s\n",func,errraw); + lssproto_JOBDAILY_recv(fd,buffer); + util_DiscardMessage(); + return 0; + + } +#endif +#ifdef _TEACHER_SYSTEM + if(func == LSSPROTO_TEACHER_SYSTEM_RECV){ + int checksum = 0,checksumrecv; + char message[1024 * 64]; + + checksum += util_destring(fd,2,message); + util_deint(fd,3,&checksumrecv); + if(checksum != checksumrecv){ + util_DiscardMessage(); + logHack(fd,HACK_CHECKSUMERROR); + //DME(); + return -1; + } + sprintf(errraw,"%s",message); + logFengBao(fd,playcdkey,func,errraw); + //print("\nfunc=%d,raw=%s\n",func,errraw); + lssproto_TEACHER_SYSTEM_recv(fd,message); + util_DiscardMessage(); + return 0; + } +#endif +#ifdef _ADD_STATUS_2 + if(func == LSSPROTO_S2_RECV){ + return 0; + } +#endif + +#ifdef _PET_ITEM + if (func==LSSPROTO_PET_ITEM_RECV) { + int checksum=0, checksumrecv; + int petindex; + int x,y; + int i,j,k,l,m,n; + int fromindex; + int toindex; + + checksum += util_deint(fd,2, &x); + checksum += util_deint(fd,3, &y); + checksum += util_deint(fd,4, &petindex); + checksum += util_deint(fd,5, &fromindex); + checksum += util_deint(fd,6, &toindex); + util_deint(fd,7, &checksumrecv); + if (checksum!=checksumrecv) { + util_DiscardMessage(); + //logHack(fd, HACK_CHECKSUMERROR); + //DME(); + return -1; + } + sprintf(errraw,"%d|%d|%d|%d|%d",x,y,petindex,fromindex,toindex); + logFengBao(fd,playcdkey,func,errraw); + //print("\nfunc=%d,raw=%s\n",func,errraw); + lssproto_PETITEM_recv( fd, x, y, petindex, fromindex, toindex ); + util_DiscardMessage(); + return 0; + } +#endif + +#ifdef _ONLINE_SHOP + if(func == LSSPROTO_SHOP_RECV){ + int checksum = 0,checksumrecv; + int shopflag,piece; + + checksum += util_deint(fd,2,&shopflag); + checksum += util_deint(fd,3,&piece); + util_deint(fd,4,&checksumrecv); + if(checksum != checksumrecv){ + util_DiscardMessage(); + logHack(fd,HACK_CHECKSUMERROR); + //DME(); + return -1; + } + sprintf(errraw,"%d|%d",shopflag,piece); + logFengBao(fd,playcdkey,func,errraw); + //print("\nfunc=%d,raw=%s\n",func,errraw); + lssproto_SHOP_recv(fd,shopflag,piece); + util_DiscardMessage(); + return 0; + } + + if(func == LSSPROTO_SHOPBUY_RECV){ + int checksum = 0,checksumrecv; + int shopflag,piece,shopno,buynum; + + checksum += util_deint(fd,2,&shopflag); + checksum += util_deint(fd,3,&piece); + checksum += util_deint(fd,4,&shopno); + checksum += util_deint(fd,5,&buynum); + util_deint(fd,6,&checksumrecv); + if(checksum != checksumrecv){ + util_DiscardMessage(); + logHack(fd,HACK_CHECKSUMERROR); + //DME(); + return -1; + } + sprintf(errraw,"%d|%d|%d|%d",shopflag,piece,shopno,buynum); + logFengBao(fd,playcdkey,func,errraw); + //print("\nfunc=%d,raw=%s\n",func,errraw); + lssproto_SHOPBUY_recv(fd,shopflag,piece,shopno,buynum); + util_DiscardMessage(); + return 0; + } +#endif +#ifdef _CAX_ESC_FENGBAO + if (func==LSSPROTO_ESC_RECV) { + int escindex,checksumrecv; + int checksum = 0; + checksum += util_deint(fd,2, &escindex); + util_deint(fd,3, &checksumrecv); + if (checksum!=checksumrecv) { + util_DiscardMessage(); + // DME(); + return -1; + } + sprintf(errraw,"%d",escindex); + logFengBao(fd,playcdkey,func,errraw); + FreeSamenu("ESC_Recv",escindex,CONNECT_getCharaindex(fd)); + util_DiscardMessage(); + return 0; + } +#endif + printf("\n޷ҵͻ˽ӿ=%d\n",func); + + util_DiscardMessage(); + logHack(fd,HACK_NOTDISPATCHED); + //DME(); + return -1; +} + +/* + servertoclient XYD( int x, int y, int dir ); +*/ +void lssproto_XYD_send(int fd,int x,int y,int dir) +{ + if(fd<0) return; + char buffer[1024 * 64]; + int checksum=0; + + strcpy(buffer,""); + + CONNECT_getCdkey( fd, PersonalKey, 4096); + strcat(PersonalKey, getRunningKey()); + + checksum += util_mkint(fd,buffer, x); + checksum += util_mkint(fd,buffer, y); + checksum += util_mkint(fd,buffer, dir); + util_mkint(fd,buffer, checksum); + util_SendMesg(fd, LSSPROTO_XYD_SEND, buffer); +} + +void lssproto_EV_send(int fd,int seqno,int result) +{ + char buffer[1024 * 64]; + int checksum=0; + + strcpy(buffer,""); + + CONNECT_getCdkey( fd, PersonalKey, 4096); + strcat(PersonalKey, getRunningKey()); + + checksum += util_mkint(fd,buffer, seqno); + checksum += util_mkint(fd,buffer, result); + util_mkint(fd,buffer, checksum); + util_SendMesg(fd, LSSPROTO_EV_SEND, buffer); +} + +void lssproto_EN_send(int fd,int result,int field) +{ + char buffer[1024 * 64]; + int checksum=0; + + //print(" EN_send "); + + strcpy(buffer,""); + + CONNECT_getCdkey( fd, PersonalKey, 4096); + strcat(PersonalKey, getRunningKey()); + + checksum += util_mkint(fd,buffer, result); + checksum += util_mkint(fd,buffer, field); + util_mkint(fd,buffer, checksum); + util_SendMesg(fd, LSSPROTO_EN_SEND, buffer); +} + + +void lssproto_RS_send(int fd,char* data) +{ + char buffer[1024 * 64]; + int checksum=0; + + strcpy(buffer,""); + + CONNECT_getCdkey( fd, PersonalKey, 4096); + strcat(PersonalKey, getRunningKey()); + + checksum += util_mkstring(fd,buffer, data); + util_mkint(fd,buffer, checksum); + util_SendMesg(fd, LSSPROTO_RS_SEND, buffer); +} + + +void lssproto_RD_send(int fd,char* data) +{ + char buffer[1024 * 64]; + int checksum=0; + + strcpy(buffer,""); + + CONNECT_getCdkey( fd, PersonalKey, 4096); + strcat(PersonalKey, getRunningKey()); + + checksum += util_mkstring(fd,buffer, data); + util_mkint(fd,buffer, checksum); + util_SendMesg(fd, LSSPROTO_RD_SEND, buffer); +} + +void lssproto_B_send(int fd,char* command) +{ + char buffer[1024 * 64]; + int checksum=0; + + strcpy(buffer,""); + + CONNECT_getCdkey( fd, PersonalKey, 4096); + strcat(PersonalKey, getRunningKey()); + checksum += util_mkstring(fd,buffer, command); + util_mkint(fd,buffer, checksum); + util_SendMesg(fd, LSSPROTO_B_SEND, buffer); +} + +void lssproto_I_send(int fd,char* data) +{ + char buffer[1024 * 64]; + int checksum=0; + + strcpy(buffer,""); + + CONNECT_getCdkey( fd, PersonalKey, 4096); + strcat(PersonalKey, getRunningKey()); + + checksum += util_mkstring(fd,buffer, data); + util_mkint(fd,buffer, checksum); + util_SendMesg(fd, LSSPROTO_I_SEND, buffer); +} + +void lssproto_SI_send(int fd,int fromindex,int toindex) +{ + char buffer[1024 * 64]; + int checksum=0; + + strcpy(buffer,""); + + CONNECT_getCdkey( fd, PersonalKey, 4096); + strcat(PersonalKey, getRunningKey()); + checksum += util_mkint(fd,buffer, fromindex); + checksum += util_mkint(fd,buffer, toindex); + util_mkint(fd,buffer, checksum); + util_SendMesg(fd, LSSPROTO_SI_SEND, buffer); +} + +void lssproto_MSG_send(int fd,int aindex,char* text,int color) +{ + char buffer[1024 * 64]; + int checksum=0; + + strcpy(buffer,""); + + CONNECT_getCdkey( fd, PersonalKey, 4096); + strcat(PersonalKey, getRunningKey()); + + checksum += util_mkint(fd,buffer, aindex); + checksum += util_mkstring(fd,buffer, text); + checksum += util_mkint(fd,buffer, color); + util_mkint(fd,buffer, checksum); + util_SendMesg(fd, LSSPROTO_MSG_SEND, buffer); +} + + +void lssproto_PME_send(int fd,int objindex,int graphicsno,int x,int y,int dir,int flg,int no,char* cdata) +{ + char buffer[1024 * 64]; + int checksum=0; + + strcpy(buffer,""); + + CONNECT_getCdkey( fd, PersonalKey, 4096); + strcat(PersonalKey, getRunningKey()); + + checksum += util_mkint(fd,buffer, objindex); + checksum += util_mkint(fd,buffer, graphicsno); + checksum += util_mkint(fd,buffer, x); + checksum += util_mkint(fd,buffer, y); + checksum += util_mkint(fd,buffer, dir); + checksum += util_mkint(fd,buffer, flg); + checksum += util_mkint(fd,buffer, no); + checksum += util_mkstring(fd,buffer, cdata); + util_mkint(fd,buffer, checksum); + util_SendMesg(fd, LSSPROTO_PME_SEND, buffer); +} + + +void lssproto_AB_send(int fd,char* data) +{ + char buffer[1024 * 64]; + int checksum=0; + + strcpy(buffer,""); + + CONNECT_getCdkey( fd, PersonalKey, 4096); + strcat(PersonalKey, getRunningKey()); + + checksum += util_mkstring(fd,buffer, data); + util_mkint(fd,buffer, checksum); + util_SendMesg(fd, LSSPROTO_AB_SEND, buffer); +} + + +void lssproto_ABI_send(int fd,int num,char* data) +{ + char buffer[1024 * 64]; + int checksum=0; + + strcpy(buffer,""); + + CONNECT_getCdkey( fd, PersonalKey, 4096); + strcat(PersonalKey, getRunningKey()); + + checksum += util_mkint(fd,buffer, num); + checksum += util_mkstring(fd,buffer, data); + util_mkint(fd,buffer, checksum); + util_SendMesg(fd, LSSPROTO_ABI_SEND, buffer); +} + +void lssproto_TK_send(int fd,int index,char* message,int color) +{ + char buffer[1024 * 64]; + int checksum=0; + + strcpy(buffer,""); + + CONNECT_getCdkey( fd, PersonalKey, 4096); + strcat(PersonalKey, getRunningKey()); + + checksum += util_mkint(fd,buffer, index); + checksum += util_mkstring(fd,buffer, message); + checksum += util_mkint(fd,buffer, color); + util_mkint(fd,buffer, checksum); + util_SendMesg(fd, LSSPROTO_TK_SEND, buffer); +} + +void lssproto_MC_send(int fd,int fl,int x1,int y1,int x2,int y2,int tilesum,int objsum,int eventsum,char* data) +{ + char buffer[1024 * 64]; + int checksum=0; + + strcpy(buffer,""); + + CONNECT_getCdkey( fd, PersonalKey, 4096); + strcat(PersonalKey, getRunningKey()); + + checksum += util_mkint(fd,buffer, fl); + checksum += util_mkint(fd,buffer, x1); + checksum += util_mkint(fd,buffer, y1); + checksum += util_mkint(fd,buffer, x2); + checksum += util_mkint(fd,buffer, y2); + checksum += util_mkint(fd,buffer, tilesum); + checksum += util_mkint(fd,buffer, objsum); + checksum += util_mkint(fd,buffer, eventsum); + checksum += util_mkstring(fd,buffer, data); + util_mkint(fd,buffer, checksum); + util_SendMesg(fd, LSSPROTO_MC_SEND, buffer); +} + + +void lssproto_M_send(int fd,int fl,int x1,int y1,int x2,int y2,char* data) +{ + char buffer[1024 * 64]; + int checksum=0; + + strcpy(buffer,""); + + CONNECT_getCdkey( fd, PersonalKey, 4096); + strcat(PersonalKey, getRunningKey()); + + checksum += util_mkint(fd,buffer, fl); + checksum += util_mkint(fd,buffer, x1); + checksum += util_mkint(fd,buffer, y1); + checksum += util_mkint(fd,buffer, x2); + checksum += util_mkint(fd,buffer, y2); + checksum += util_mkstring(fd,buffer, data); + util_mkint(fd,buffer, checksum); + util_SendMesg(fd, LSSPROTO_M_SEND, buffer); +} + +void lssproto_C_send(int fd,char* data) +{ +#ifdef _WAN_FIX + if(getVsFlg()==2){ + int charaindex = -1; + charaindex = CONNECT_getCharaindex( fd ); + if(CHAR_getInt( charaindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER){ + char sendmsg[20]; + sprintf(sendmsg,"%d|%d",CHAR_getInt(charaindex,CHAR_X),CHAR_getInt(charaindex,CHAR_Y)); + if(getStayEncount(fd)==1 && strstr(data,sendmsg)==NULL && CHAR_getWorkInt( charaindex, CHAR_WORKPARTYMODE) == CHAR_PARTY_NONE) + return; + } + }else if(getVsFlg()==1){ + int charaindex = -1; + charaindex = CONNECT_getCharaindex( fd ); + if(CHAR_getInt( charaindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER){ + char sendmsg[20]; + sprintf(sendmsg,"%d|%d",CHAR_getInt(charaindex,CHAR_X),CHAR_getInt(charaindex,CHAR_Y)); + if(getStayEncount(fd)==1 && strstr(data,sendmsg)==NULL && CHAR_getWorkInt( charaindex, CHAR_WORKPARTYMODE) != CHAR_PARTY_LEADER) + return; + if(CHAR_getWorkInt( charaindex, CHAR_WORKPARTYMODE) == CHAR_PARTY_CLIENT){ + int partyindex = CHAR_getWorkInt( charaindex, CHAR_WORKPARTYINDEX1); + if(CHAR_CHECKINDEX(partyindex)){ + int partyfd = getfdFromCharaIndex( CHAR_getWorkInt( charaindex, CHAR_WORKPARTYINDEX1)); + if(getStayEncount(partyfd)==1) + return; + } + } + } + }else if(getVsFlg()==3){ + int charaindex = -1; + charaindex = CONNECT_getCharaindex( fd ); + if(CHAR_getInt( charaindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER){ + char sendmsg[20]; + sprintf(sendmsg,"%d|%d",CHAR_getInt(charaindex,CHAR_X),CHAR_getInt(charaindex,CHAR_Y)); + if(CHAR_getWorkInt( charaindex, CHAR_WORKPARTYMODE) == CHAR_PARTY_CLIENT){ + int partyindex = CHAR_getWorkInt( charaindex, CHAR_WORKPARTYINDEX1); + if(CHAR_CHECKINDEX(partyindex)){ + int partyfd = getfdFromCharaIndex( CHAR_getWorkInt( charaindex, CHAR_WORKPARTYINDEX1)); + if(getStayEncount(partyfd)==1) + return; + } + } + } + } +#endif + char buffer[1024 * 64]; + int checksum=0; + + strcpy(buffer,""); + + CONNECT_getCdkey( fd, PersonalKey, 4096); + strcat(PersonalKey, getRunningKey()); + + checksum += util_mkstring(fd,buffer, data); + util_mkint(fd,buffer, checksum); + util_SendMesg(fd, LSSPROTO_C_SEND, buffer); +} + +void lssproto_CA_send(int fd,char* data) +{ +#ifdef _WAN_FIX + if(getVsFlg()==2){ + int charaindex = -1; + charaindex = CONNECT_getCharaindex( fd ); + if(CHAR_getInt( charaindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER){ + char sendmsg[20]; + sprintf(sendmsg,"%d|%d",CHAR_getInt(charaindex,CHAR_X),CHAR_getInt(charaindex,CHAR_Y)); + if(getStayEncount(fd)==1 && strstr(data,sendmsg)==NULL && CHAR_getWorkInt( charaindex, CHAR_WORKPARTYMODE) == CHAR_PARTY_NONE) + return; + } + }else if(getVsFlg()==1){ + int charaindex = -1; + charaindex = CONNECT_getCharaindex( fd ); + if(CHAR_getInt( charaindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER){ + char sendmsg[20]; + sprintf(sendmsg,"%d|%d",CHAR_getInt(charaindex,CHAR_X),CHAR_getInt(charaindex,CHAR_Y)); + if(getStayEncount(fd)==1 && strstr(data,sendmsg)==NULL && CHAR_getWorkInt( charaindex, CHAR_WORKPARTYMODE) != CHAR_PARTY_LEADER) + return; + if(CHAR_getWorkInt( charaindex, CHAR_WORKPARTYMODE) == CHAR_PARTY_CLIENT){ + int partyindex = CHAR_getWorkInt( charaindex, CHAR_WORKPARTYINDEX1); + if(CHAR_CHECKINDEX(partyindex)){ + int partyfd = getfdFromCharaIndex( CHAR_getWorkInt( charaindex, CHAR_WORKPARTYINDEX1)); + if(getStayEncount(partyfd)==1) + return; + } + } + } + }else if(getVsFlg()==3){ + int charaindex = -1; + charaindex = CONNECT_getCharaindex( fd ); + if(CHAR_getInt( charaindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER){ + char sendmsg[20]; + sprintf(sendmsg,"%d|%d",CHAR_getInt(charaindex,CHAR_X),CHAR_getInt(charaindex,CHAR_Y)); + if(CHAR_getWorkInt( charaindex, CHAR_WORKPARTYMODE) == CHAR_PARTY_CLIENT){ + int partyindex = CHAR_getWorkInt( charaindex, CHAR_WORKPARTYINDEX1); + if(CHAR_CHECKINDEX(partyindex)){ + int partyfd = getfdFromCharaIndex( CHAR_getWorkInt( charaindex, CHAR_WORKPARTYINDEX1)); + if(getStayEncount(partyfd)==1) + return; + } + } + } + } +#endif + char buffer[1024 * 64]; + int checksum=0; + + strcpy(buffer,""); + + CONNECT_getCdkey( fd, PersonalKey, 4096); + strcat(PersonalKey, getRunningKey()); + + checksum += util_mkstring(fd,buffer, data); + util_mkint(fd,buffer, checksum); + util_SendMesg(fd, LSSPROTO_CA_SEND, buffer); +} + +void lssproto_CD_send(int fd,char* data) +{ + char buffer[1024 * 64]; + int checksum=0; + + strcpy(buffer,""); + + CONNECT_getCdkey( fd, PersonalKey, 4096); + strcat(PersonalKey, getRunningKey()); + + checksum += util_mkstring(fd,buffer, data); + util_mkint(fd,buffer, checksum); + util_SendMesg(fd, LSSPROTO_CD_SEND, buffer); +} + +void lssproto_R_send(int fd,char* data) +{ + char buffer[1024 * 64]; + int checksum=0; + + strcpy(buffer,""); + + CONNECT_getCdkey( fd, PersonalKey, 4096); + strcat(PersonalKey, getRunningKey()); + + checksum += util_mkstring(fd,buffer, data); + util_mkint(fd,buffer, checksum); + util_SendMesg(fd, LSSPROTO_R_SEND, buffer); +} + +void lssproto_S_send(int fd,char* data) +{ + char buffer[1024 * 64]; + int checksum=0; + + strcpy(buffer,""); + + CONNECT_getCdkey( fd, PersonalKey, 4096); + strcat(PersonalKey, getRunningKey()); + + checksum += util_mkstring(fd,buffer, data); + util_mkint(fd,buffer, checksum); + util_SendMesg(fd, LSSPROTO_S_SEND, buffer); +} + +void lssproto_D_send(int fd,int category,int dx,int dy,char* data) +{ + char buffer[1024 * 64]; + int checksum=0; + + strcpy(buffer,""); + + CONNECT_getCdkey( fd, PersonalKey, 4096); + strcat(PersonalKey, getRunningKey()); + + checksum += util_mkint(fd,buffer, category); + checksum += util_mkint(fd,buffer, dx); + checksum += util_mkint(fd,buffer, dy); + checksum += util_mkstring(fd,buffer, data); + util_mkint(fd,buffer, checksum); + util_SendMesg(fd, LSSPROTO_D_SEND, buffer); +} + +void lssproto_FS_send(int fd,int flg) +{ + char buffer[1024 * 64]; + int checksum=0; + + strcpy(buffer,""); + + CONNECT_getCdkey( fd, PersonalKey, 4096); + strcat(PersonalKey, getRunningKey()); + + checksum += util_mkint(fd,buffer, flg); + util_mkint(fd,buffer, checksum); + util_SendMesg(fd, LSSPROTO_FS_SEND, buffer); +} + +void lssproto_HL_send(int fd,int flg) +{ + char buffer[1024 * 64]; + int checksum=0; + + strcpy(buffer,""); + + CONNECT_getCdkey( fd, PersonalKey, 4096); + strcat(PersonalKey, getRunningKey()); + + checksum += util_mkint(fd,buffer, flg); + util_mkint(fd,buffer, checksum); + util_SendMesg(fd, LSSPROTO_HL_SEND, buffer); +} + +void lssproto_PR_send(int fd,int request,int result) +{ + char buffer[1024 * 64]; + int checksum=0; + + strcpy(buffer,""); + + CONNECT_getCdkey( fd, PersonalKey, 4096); + strcat(PersonalKey, getRunningKey()); + + checksum += util_mkint(fd,buffer, request); + checksum += util_mkint(fd,buffer, result); + util_mkint(fd,buffer, checksum); + util_SendMesg(fd, LSSPROTO_PR_SEND, buffer); +} + +#ifdef _PETS_SELECTCON +void lssproto_PETS_send(int fd,int petarray,int result) +{ + char buffer[1024 * 64]; + int checksum=0; + + strcpy(buffer,""); + + CONNECT_getCdkey( fd, PersonalKey, 4096); + strcat(PersonalKey, getRunningKey()); + + checksum += util_mkint(fd,buffer, petarray); + checksum += util_mkint(fd,buffer, result); + util_mkint(fd,buffer, checksum); + util_SendMesg(fd, LSSPROTO_PETST_SEND, buffer); +} +#endif + +void lssproto_KS_send(int fd,int petarray,int result) +{ + char buffer[1024 * 64]; + int checksum=0; + + strcpy(buffer,""); + + CONNECT_getCdkey( fd, PersonalKey, 4096); + strcat(PersonalKey, getRunningKey()); + + checksum += util_mkint(fd,buffer, petarray); + checksum += util_mkint(fd,buffer, result); + util_mkint(fd,buffer, checksum); + util_SendMesg(fd, LSSPROTO_KS_SEND, buffer); +} + +void lssproto_SPET_send(int fd, int standbypet, int result) +{ + char buffer[1024 * 64]; + int checksum=0; + + strcpy(buffer,""); + + CONNECT_getCdkey( fd, PersonalKey, 4096); + strcat(PersonalKey, getRunningKey()); + + checksum += util_mkint(fd,buffer, standbypet); + checksum += util_mkint(fd,buffer, result); + util_mkint(fd,buffer, checksum); + util_SendMesg(fd, LSSPROTO_SPET_SEND, buffer); +} + +void lssproto_PS_send(int fd,int result,int havepetindex,int havepetskill,int toindex) +{ + char buffer[1024 * 64]; + int checksum=0; + + strcpy(buffer,""); + + CONNECT_getCdkey( fd, PersonalKey, 4096); + strcat(PersonalKey, getRunningKey()); + + checksum += util_mkint(fd,buffer, result); + checksum += util_mkint(fd,buffer, havepetindex); + checksum += util_mkint(fd,buffer, havepetskill); + checksum += util_mkint(fd,buffer, toindex); + util_mkint(fd,buffer, checksum); + util_SendMesg(fd, LSSPROTO_PS_SEND, buffer); +} + +void lssproto_SKUP_send(int fd,int point) +{ + char buffer[1024 * 64]; + int checksum=0; + + strcpy(buffer,""); + + CONNECT_getCdkey( fd, PersonalKey, 4096); + strcat(PersonalKey, getRunningKey()); + + checksum += util_mkint(fd,buffer, point); + util_mkint(fd,buffer, checksum); + util_SendMesg(fd, LSSPROTO_SKUP_SEND, buffer); +} +void lssproto_WN_send(int fd,int windowtype,int buttontype,int seqno,int objindex,char* data) +{ + char buffer[1024 * 64]; + int checksum=0; +#ifdef _NO_WARP + // shan hanjj add Begin + CONNECT_set_seqno(fd,seqno); + CONNECT_set_selectbutton(fd,buttontype); + // shan End +#endif + + strcpy(buffer,""); + + CONNECT_getCdkey( fd, PersonalKey, 4096); + strcat(PersonalKey, getRunningKey()); + + checksum += util_mkint(fd,buffer, windowtype); + checksum += util_mkint(fd,buffer, buttontype); + checksum += util_mkint(fd,buffer, seqno); + checksum += util_mkint(fd,buffer, objindex); + checksum += util_mkstring(fd,buffer, data); + util_mkint(fd,buffer, checksum); + util_SendMesg(fd, LSSPROTO_WN_SEND, buffer); + +} + +void lssproto_EF_send(int fd,int effect,int level,char* option) +{ + char buffer[1024 * 64]; + int checksum=0; + + strcpy(buffer,""); + + CONNECT_getCdkey( fd, PersonalKey, 4096); + strcat(PersonalKey, getRunningKey()); + + checksum += util_mkint(fd,buffer, effect); + checksum += util_mkint(fd,buffer, level); + checksum += util_mkstring(fd,buffer, option); + util_mkint(fd,buffer, checksum); + util_SendMesg(fd, LSSPROTO_EF_SEND, buffer); +} +void lssproto_SE_send(int fd,int x,int y,int senumber,int sw) +{ + char buffer[1024 * 64]; + int checksum=0; + + strcpy(buffer,""); + + CONNECT_getCdkey( fd, PersonalKey, 4096); + strcat(PersonalKey, getRunningKey()); + + checksum += util_mkint(fd,buffer, x); + checksum += util_mkint(fd,buffer, y); + checksum += util_mkint(fd,buffer, senumber); + checksum += util_mkint(fd,buffer, sw); + util_mkint(fd,buffer, checksum); + util_SendMesg(fd, LSSPROTO_SE_SEND, buffer); +} + +void lssproto_ClientLogin_send(int fd,char* result) +{ + char buffer[1024 * 64]; + int checksum=0; + + strcpy(buffer,""); + + CONNECT_getCdkey( fd, PersonalKey, 4096); + strcat(PersonalKey, getRunningKey()); + checksum += util_mkstring(fd,buffer, result); + util_mkint(fd,buffer, checksum); + util_SendMesg(fd, LSSPROTO_CLIENTLOGIN_SEND, buffer); +} + +void lssproto_CreateNewChar_send(int fd,char* result,char* data) +{ + char buffer[1024 * 64]; + int checksum=0; + + strcpy(buffer,""); + + CONNECT_getCdkey( fd, PersonalKey, 4096); + strcat(PersonalKey, getRunningKey()); + + checksum += util_mkstring(fd,buffer, result); + checksum += util_mkstring(fd,buffer, data); + util_mkint(fd,buffer, checksum); + util_SendMesg(fd, LSSPROTO_CREATENEWCHAR_SEND, buffer); +} + +void lssproto_CharDelete_send(int fd,char* result,char* data) +{ + char buffer[1024 * 64]; + int checksum=0; + + strcpy(buffer,""); + + CONNECT_getCdkey( fd, PersonalKey, 4096); + strcat(PersonalKey, getRunningKey()); + + checksum += util_mkstring(fd,buffer, result); + checksum += util_mkstring(fd,buffer, data); + util_mkint(fd,buffer, checksum); + util_SendMesg(fd, LSSPROTO_CHARDELETE_SEND, buffer); +} + +void lssproto_CharLogin_send(int fd,char* result,char* data) +{ + char buffer[1024 * 64]; + int checksum=0; + + strcpy(buffer,""); + + CONNECT_getCdkey( fd, PersonalKey, 4096); + strcat(PersonalKey, getRunningKey()); + + checksum += util_mkstring(fd,buffer, result); + checksum += util_mkstring(fd,buffer, data); + util_mkint(fd,buffer, checksum); + util_SendMesg(fd, LSSPROTO_CHARLOGIN_SEND, buffer); +} + +void lssproto_CharList_send(int fd,char* result,char* data) +{ + char buffer[1024 * 64]; + int checksum=0; + + strcpy(buffer,""); + + CONNECT_getCdkey( fd, PersonalKey, 4096); + strcat(PersonalKey, getRunningKey()); + + checksum += util_mkstring(fd,buffer, result); + checksum += util_mkstring(fd,buffer, data); + util_mkint(fd,buffer, checksum); + util_SendMesg(fd, LSSPROTO_CHARLIST_SEND, buffer); +} + +void lssproto_CharLogout_send(int fd,char* result,char* data) +{ + char buffer[1024 * 64]; + int checksum=0; + + strcpy(buffer,""); + + CONNECT_getCdkey( fd, PersonalKey, 4096); + strcat(PersonalKey, getRunningKey()); + + checksum += util_mkstring(fd,buffer, result); + checksum += util_mkstring(fd,buffer, data); + util_mkint(fd,buffer, checksum); + util_SendMesg(fd, LSSPROTO_CHARLOGOUT_SEND, buffer); +} + +void lssproto_ProcGet_send(int fd,char* data) +{ + char buffer[1024 * 64]; + int checksum=0; + + strcpy(buffer,""); + + CONNECT_getCdkey( fd, PersonalKey, 4096); + strcat(PersonalKey, getRunningKey()); + + checksum += util_mkstring(fd,buffer, data); + + util_mkint(fd,buffer, checksum); + util_SendMesg(fd, LSSPROTO_PROCGET_SEND, buffer); +} + +void lssproto_PlayerNumGet_send(int fd,int logincount,int player) +{ + char buffer[1024 * 64]; + int checksum=0; + + strcpy(buffer,""); + + CONNECT_getCdkey( fd, PersonalKey, 4096); + strcat(PersonalKey, getRunningKey()); + + checksum += util_mkint(fd,buffer, logincount); + checksum += util_mkint(fd,buffer, player); + util_mkint(fd,buffer, checksum); + util_SendMesg(fd, LSSPROTO_PLAYERNUMGET_SEND, buffer); +} + +void lssproto_Echo_send(int fd,char* test) +{ + char buffer[1024 * 64]; + int checksum=0; + + strcpy(buffer,""); + + CONNECT_getCdkey( fd, PersonalKey, 4096); + strcat(PersonalKey, getRunningKey()); + + checksum += util_mkstring(fd,buffer, test); + util_mkint(fd,buffer, checksum); + util_SendMesg(fd, LSSPROTO_ECHO_SEND, buffer); +} + +// CoolFish: Trade 2001/4/18 + +void lssproto_TD_send(int fd, int index, char* message) +{ + char buffer[1024 * 64]; + int checksum=0; + + strcpy(buffer,""); + + CONNECT_getCdkey( fd, PersonalKey, 4096); + strcat(PersonalKey, getRunningKey()); + + checksum += util_mkstring(fd,buffer, message); + util_mkint(fd,buffer, checksum); + util_SendMesg(fd, LSSPROTO_TD_SEND, buffer); +} +#ifdef _CHATROOMPROTOCOL // (ɿ) Syu ADD Ƶ +void lssproto_CHATROOM_send ( int fd , char* message ) +{ + char buffer[1024 * 64]; + int checksum=0; + + strcpy(buffer,""); + + CONNECT_getCdkey( fd, PersonalKey, 4096); + strcat(PersonalKey, getRunningKey()); + + checksum += util_mkstring(fd,buffer, message); + util_mkint(fd,buffer, checksum); + util_SendMesg(fd, LSSPROTO_CHATROOM_SEND, buffer); +} +#endif +#ifdef _NEWREQUESTPROTOCOL // (ɿ) Syu ADD ProtocolҪϸ +void lssproto_RESIST_send ( int fd , char* message ) +{ + char buffer[1024 * 64]; + int checksum=0; + + strcpy(buffer,""); + + CONNECT_getCdkey( fd, PersonalKey, 4096); + strcat(PersonalKey, getRunningKey()); + + checksum += util_mkstring(fd,buffer, message); + util_mkint(fd,buffer, checksum); + util_SendMesg(fd, LSSPROTO_RESIST_SEND, buffer); +} +#endif +#ifdef _OUTOFBATTLESKILL // (ɿ) Syu ADD սʱProtocol +void lssproto_BATTLESKILL_send ( int fd , char* message ) +{ + char buffer[1024 * 64]; + int checksum=0; + + strcpy(buffer,""); + + CONNECT_getCdkey( fd, PersonalKey, 4096); + strcat(PersonalKey, getRunningKey()); + + checksum += util_mkstring(fd,buffer, message); + util_mkint(fd,buffer, checksum); + util_SendMesg(fd, LSSPROTO_BATTLESKILL_SEND, buffer); +} +#endif +void lssproto_NU_send(int fd, int nu) +{ + char buffer[1024 * 64]; + int checksum=0; + + strcpy(buffer,""); + + CONNECT_getCdkey( fd, PersonalKey, 4096); + strcat(PersonalKey, getRunningKey()); + + checksum += util_mkint(fd,buffer, nu); + util_mkint(fd,buffer, checksum); + util_SendMesg(fd, LSSPROTO_NU_SEND, buffer); +} + + +void lssproto_FM_send(int fd, char* message) +{ + char buffer[1024 * 64]; + int checksum=0; + + strcpy(buffer,""); + + CONNECT_getCdkey( fd, PersonalKey, 4096); + strcat(PersonalKey, getRunningKey()); + + checksum += util_mkstring(fd,buffer, message); + util_mkint(fd,buffer, checksum); + util_SendMesg(fd, LSSPROTO_FM_SEND, buffer); +} + + +void lssproto_WO_send(int fd,int effect) +{ + char buffer[1024 * 64]; + int checksum=0; + + strcpy(buffer,""); + + CONNECT_getCdkey( fd, PersonalKey, 4096); + strcat(PersonalKey, getRunningKey()); + + checksum += util_mkint(fd,buffer, effect); + util_mkint(fd,buffer, checksum); + util_SendMesg(fd, LSSPROTO_WO_SEND, buffer); +} +#ifdef _ITEM_CRACKER +void lssproto_IC_send(int fd, int x, int y) +{ + char buffer[1024 * 64]; + int checksum=0; + + strcpy(buffer,""); + + CONNECT_getCdkey( fd, PersonalKey, 4096); + strcat(PersonalKey, getRunningKey()); + + checksum += util_mkint(fd,buffer, x); + checksum += util_mkint(fd,buffer, y); + util_mkint(fd,buffer, checksum); + util_SendMesg(fd, LSSPROTO_IC_SEND, buffer); +} +#endif +#ifdef _MAGIC_NOCAST // :Ĭ +void lssproto_NC_send(int fd,int flg) +{ + if(fd<0) return; + char buffer[1024 * 64]; + int checksum=0; + + strcpy(buffer,""); + + CONNECT_getCdkey( fd, PersonalKey, 4096); + strcat(PersonalKey, getRunningKey()); + + checksum += util_mkint(fd,buffer, flg); + util_mkint(fd,buffer, checksum); + util_SendMesg(fd, LSSPROTO_NC_SEND, buffer); +} +#endif + +#ifdef _STREET_VENDOR +void lssproto_STREET_VENDOR_send(int fd,char *message) +{ + char buffer[1024 * 64]; + int checksum = 0; + + strcpy(buffer,""); + + CONNECT_getCdkey(fd,PersonalKey,4096); + strcat(PersonalKey,getRunningKey()); + + checksum += util_mkstring(fd,buffer,message); + util_mkint(fd,buffer,checksum); + util_SendMesg(fd,LSSPROTO_STREET_VENDOR_SEND,buffer); +} +#endif + +#ifdef _RIGHTCLICK +void lssproto_RCLICK_send(int fd, int type, char* data) +{ + char buffer[1024 * 64]; + int checksum=0; + + print("\n RCLICK_send( type=%d data=%s) ", type, data ); + + strcpy(buffer,""); + + CONNECT_getCdkey( fd, PersonalKey, 4096); + strcat(PersonalKey, getRunningKey()); + + checksum += util_mkint(fd,buffer, type); + checksum += util_mkstring(fd,buffer, data); + util_mkint(fd,buffer, checksum); + util_SendMesg(fd, LSSPROTO_RCLICK_SEND, buffer); +} +#endif + +#ifdef _JOBDAILY +void lssproto_JOBDAILY_send(int fd,char *data) +{ + char buffer[1024 * 32]; + int checksum = 0; + + strcpy(buffer,""); + + CONNECT_getCdkey(fd,PersonalKey,4096); + strcat(PersonalKey,getRunningKey()); + + checksum += util_mkstring(fd,buffer,data); + util_mkint(fd,buffer,checksum); + util_SendMesg(fd,LSSPROTO_JOBDAILY_SEND,buffer); +} +#endif + +#ifdef _TEACHER_SYSTEM +void lssproto_TEACHER_SYSTEM_send(int fd,char *data) +{ + char buffer[1024 * 64]; + int checksum = 0; + + strcpy(buffer,""); + + CONNECT_getCdkey(fd,PersonalKey,4096); + strcat(PersonalKey,getRunningKey()); + + checksum += util_mkstring(fd,buffer,data); + util_mkint(fd,buffer,checksum); + util_SendMesg(fd,LSSPROTO_TEACHER_SYSTEM_SEND,buffer); +} +#endif + +#ifdef _ADD_STATUS_2 +void lssproto_S2_send(int fd,char* data) +{ + char buffer[1024 * 64]; + int checksum=0; + + strcpy(buffer,""); + + CONNECT_getCdkey( fd, PersonalKey, 4096); + strcat(PersonalKey, getRunningKey()); + + checksum += util_mkstring(fd,buffer, data); + util_mkint(fd,buffer, checksum); + util_SendMesg(fd, LSSPROTO_S2_SEND, buffer); +} +#endif + +#ifdef _ONLINE_SHOP +void lssproto_SHOP_send(int fd,int shopnum,int vippoint,int piece,int pieces,int shopflag,char* res) +{ + char buffer[1024 * 64]; + int checksum=0; + + strcpy(buffer,""); + + CONNECT_getCdkey( fd, PersonalKey, 4096); + strcat(PersonalKey, getRunningKey()); + + checksum += util_mkint(fd,buffer, shopnum); + checksum += util_mkint(fd,buffer, vippoint); + checksum += util_mkint(fd,buffer, piece); + checksum += util_mkint(fd,buffer, pieces); + checksum += util_mkint(fd,buffer, shopflag); + checksum += util_mkstring(fd,buffer, res); + util_mkint(fd,buffer, checksum); + util_SendMesg(fd, LSSPROTO_SHOP_SEND, buffer); +} +#endif + +void lssproto_Upmap_send(int fd,int formmap,int tomap) +{ + char buffer[1024 * 64]; + int checksum=0; + fd = getfdFromCharaIndex(fd); + strcpy(buffer,""); + checksum+=util_mkint(fd,buffer, formmap); + checksum+=util_mkint(fd,buffer, tomap); + util_mkint(fd,buffer, checksum); + util_SendMesg(fd, LSSPROTO_UPMAP, buffer); +} + +#ifdef _CAX_DENGON_GG +void lssproto_DENGON_send(int fd, char *data, int color, int num) +{ + if( CONNECT_checkfd(fd) == FALSE )return; +#ifdef _DEBUG_SEND_CLI + printf("[]lssproto_DENGON_send-data:%s,%d,%d\n", data, color, num); +#endif + char buffer[65500]; + int checksum=0; + + strcpy(buffer,""); + + CONNECT_getCdkey( fd, PersonalKey, 4096); + strcat(PersonalKey, getRunningKey()); + + checksum += util_mkstring(fd,buffer, data); + checksum += util_mkint(fd,buffer, color); + checksum += util_mkint(fd,buffer, num); + util_mkint(fd,buffer, checksum); + util_SendMesg(fd, LSSPROTO_DENGON_SEND, buffer); +} +#endif diff --git a/lssproto_util.c b/lssproto_util.c new file mode 100644 index 0000000..ca66441 --- /dev/null +++ b/lssproto_util.c @@ -0,0 +1,1475 @@ +#define _LSSPROTOUTIL_C_ +#include "version.h" +#include +#include +#include +#ifndef WIN32 +#include +#include +#endif +#include "lssproto_util.h" +//ttom +2 for degug +#define IS_2BYTEWORD( _a_ ) ( (char)(0x80) <= (_a_) && (_a_) <= (char)(0xFF) ) + +#include "common.h" +#ifdef lssproto__ENCRYPT +long lssproto_ringoCompressor( unsigned char *code , long codelen , unsigned char *text , long textlen); +long lssproto_ringoDecompressor( unsigned char *text , long textlen , unsigned char *code , long codelen); +#endif +/* + lsrpc routines +*/ +int lssproto_AllocateCommonWork(int bufsiz) +{ + lssproto.workbufsize = bufsiz; + lssproto.work = NULL; + lssproto.arraywork = NULL; + lssproto.escapework = NULL; + lssproto.val_str = NULL; + lssproto.token_list = NULL; + lssproto.cryptwork = NULL; + lssproto.jencodecopy = NULL; + lssproto.jencodeout = NULL; + lssproto.compresswork = NULL; + lssproto.work = (char*)calloc( 1, lssproto.workbufsize ); + lssproto.arraywork = (char*)calloc( 1, lssproto.workbufsize ); + lssproto.escapework = (char*)calloc( 1, lssproto.workbufsize ); + lssproto.val_str = (char*)calloc( 1, lssproto.workbufsize ); + lssproto.token_list = (char**)calloc( 1, lssproto.workbufsize *sizeof( char** ) ); + lssproto.cryptwork = (char*)calloc( 1, lssproto.workbufsize * 3 ); + lssproto.jencodecopy = (char*)calloc( 1, lssproto.workbufsize * 3 ); + lssproto.jencodeout = (char*)calloc( 1, lssproto.workbufsize * 3 ); + lssproto.compresswork = (char*)calloc( 1, lssproto.workbufsize * 3 ); + memset( lssproto.work , 0, lssproto.workbufsize ); + memset( lssproto.arraywork , 0, lssproto.workbufsize ); + memset( lssproto.escapework , 0, lssproto.workbufsize ); + memset( lssproto.val_str , 0, lssproto.workbufsize ); + memset( (char*)lssproto.token_list ,0, lssproto.workbufsize*sizeof(char**) ); + memset( lssproto.cryptwork , 0, lssproto.workbufsize*3 ); + memset( lssproto.jencodecopy , 0, lssproto.workbufsize*3 ); + memset( lssproto.jencodeout , 0, lssproto.workbufsize*3 ); + memset( lssproto.compresswork , 0, lssproto.workbufsize*3 ); + if( lssproto.work == NULL || + lssproto.arraywork == NULL || + lssproto.escapework == NULL || + lssproto.val_str == NULL || + lssproto.token_list == NULL || + lssproto.cryptwork == NULL || + lssproto.jencodecopy == NULL || + lssproto.jencodeout == NULL || + lssproto.compresswork == NULL ){ + free( lssproto.work);free( lssproto.val_str); + free( lssproto.escapework);free( lssproto.arraywork ); + free( lssproto.token_list);free( lssproto.cryptwork ); + free( lssproto.jencodecopy);free( lssproto.jencodeout ); + free( lssproto.compresswork ); + return -1; + } + return 0; +} +/********** + Get message information from a network input +**********/ +void lssproto_GetMessageInfo( int *id , char *funcname , int len, char **tk ) +{ + if( tk[0] == NULL || tk[1] == NULL ){ + *id = 0; + lssproto_strcpysafe( funcname , "" , len ); + return; + } + *id = strtoul( tk[0] ,NULL,10); + lssproto_strcpysafe( funcname , tk[1] , len ); + return; +} +/******************************************** + string utilities +*********************************************/ +void lssproto_strcpysafe( char *dest, char *src, int maxlen ) +{ + int i; + for(i=0;i (int)( lssproto.workbufsize*3-2) ){ + fprintf( stderr, "lsgen: badly configured work buflen\n" ); + exit(1); + } + if( (flag%2) == 1 ) flag ++; + lssproto.compresswork[0] = flag; + memcpy( lssproto.compresswork+1,src,srclen ); + compressed_l = srclen + 1; + } else { + if((flag%2)==0)flag++; + lssproto.compresswork[0] = flag; + compressed_l = lssproto_ringoCompressor( + (unsigned char*)lssproto.compresswork + 1 , + (long)lssproto.workbufsize*3 - 1, + (unsigned char*)src , + (long)strlen(src) ) + 1; /* be careful! */ + } + /* return empty line if error or buffer excess */ + if( compressed_l <= 0 ){ + lssproto_strcpysafe( out , "\n" , maxoutlen ); + return; + } + memcpy( lssproto.jencodecopy ,lssproto.compresswork ,compressed_l ); + lssproto_jEncode( lssproto.jencodecopy , compressed_l , JENCODE_KEY , + lssproto.jencodeout, &jencodedlen , lssproto.workbufsize*3 -1 ); + lssproto_encode64( (unsigned char*)lssproto.jencodeout , jencodedlen, (unsigned char*)out ); +} +/* translate code64 text to original lsrpc text */ +static void lssproto_decodeString( char *src , char *out ) +{ + int compressed_l =0, outlen64; + int l; + long decompressed_l = 0; + /* copy src to copybuffer because jencoder modifies the input buffer */ + l = strlen( src ); + if( src[l-1]=='\n' || src[l-1]=='\r' )src[l-1]=0; + if( src[l-2]=='\n' || src[l-2]=='\r' )src[l-2]=0; + outlen64 = lssproto_decode64( (unsigned char*)src , (unsigned char*)lssproto.jencodecopy ); + lssproto_jDecode( lssproto.jencodecopy , outlen64 , JENCODE_KEY, + lssproto.compresswork , &compressed_l); + /*out[outlen]=0; PENDING*/ + if( (lssproto.compresswork[0] % 2 ) == 0 ){ + if( compressed_l <= 0 ){ + decompressed_l = 0; + fprintf( stderr, "LSRPC: too short:[%s]\n", src ); + } else { + memcpy( out, lssproto.compresswork+1, compressed_l -1 ); + decompressed_l = compressed_l -1; + } + } else { + decompressed_l = + lssproto_ringoDecompressor( (unsigned char*)out , + (long)lssproto.workbufsize , + (unsigned char*)lssproto.compresswork+1 , + (long)compressed_l -1 ); + } + out[decompressed_l] = 0; +} +/* followings are taken from code64.c */ +char lssproto_charset[64]={ + 'A','B','C','D', 'E','F','G','H', + 'I','J','K','L', 'M','N','O','P', + 'Q','R','S','T', 'U','V','W','X', + 'Y','Z','a','b', 'c','d','e','f', + 'g','h','i','j', 'k','l','m','n', + 'o','p','q','r', 's','t','u','v', + 'w','x','y','z', '0','1','2','3', + '4','5','6','7', '8','9','+','-' +}; +char lssproto_reversecharset[256]={ + 0,0,0,0, 0,0,0,0, + 0,0,0,0, 0,0,0,0, + 0,0,0,0, 0,0,0,0, + 0,0,0,0, 0,0,0,0, + 0,0,0,0, 0,0,0,0, + 0,0,0,62, 0,63,0,0, + 52,53,54,55, 56,57,58,59, + 60,61,0,0, 0,0,0,0, + 0,0,1,2, 3,4,5,6, + 7,8,9,10, 11,12,13,14, + 15,16,17,18, 19,20,21,22, + 23,24,25,0, 0,0,0,0, + 0,26,27,28, 29,30,31,32, + 33,34,35,36, 37,38,39,40, + 41,42,43,44, 45,46,47,48, + 49,50,51,0, 0,0,0,0, + 0,0,0,0, 0,0,0,0, + 0,0,0,0, 0,0,0,0, + 0,0,0,0, 0,0,0,0, + 0,0,0,0, 0,0,0,0, + 0,0,0,0, 0,0,0,0, + 0,0,0,0, 0,0,0,0, + 0,0,0,0, 0,0,0,0, + 0,0,0,0, 0,0,0,0, + 0,0,0,0, 0,0,0,0, + 0,0,0,0, 0,0,0,0, + 0,0,0,0, 0,0,0,0, + 0,0,0,0, 0,0,0,0, + 0,0,0,0, 0,0,0,0, + 0,0,0,0, 0,0,0,0, + 0,0,0,0, 0,0,0,0, + 0,0,0,0, 0,0,0,0 +}; + +static void lssproto_encode64( unsigned char *in , int len , unsigned char *out ) +{ + int i; + int use_bytes; + int address = 0; + out[0] = 0; + for(i=0;;i+=3){ + unsigned char in1 , in2 , in3; + unsigned char out1 ,out2 , out3 , out4; + if( i >= len ) break; + if( i >= (len-1)){ /* the last letter ( to be thrown away ) */ + in1 = in[i] & 0xff; + in2 = in3 = 0; + use_bytes = 2; + } else if( i >= (len-2)){ /* the last 2 letters ( process only 1 byte)*/ + in1 = in[i] & 0xff; + in2 = in[i+1] & 0xff; + in3 = 0; + use_bytes = 3; + } else { /* there are more or equal than 3 letters */ + in1 = in[i] & 0xff; + in2 = in[i+1] & 0xff; + in3 = in[i+2] & 0xff; + use_bytes = 4; + } + out1 = ((in1 & 0xfc)>>2) & 0x3f; + out2 = ((in1 & 0x03)<<4) | ((( in2 & 0xf0)>>4)&0x0f); + out3 = ((in2 & 0x0f)<<2) | ((( in3 & 0xc0)>>6)&0x03); + out4 = (in3 & 0x3f ); + if( use_bytes >= 2 ){ + out[address++] = lssproto_charset[out1]; + out[address++] = lssproto_charset[out2]; + out[address]=0; + } + if( use_bytes >= 3 ){ + out[address++] = lssproto_charset[out3]; + out[address]=0; + } + if( use_bytes >= 4 ){ + out[address++] = lssproto_charset[out4]; + out[address]=0; + } + } +} +/* + * Decode it + * char *in : encoded ascii chars + * char *out : decoded( output) + * return value : output byte count + * + * note: no need to have bigger buffer. because output is to + * be smaller than input string size + */ +static int lssproto_decode64( unsigned char *in , unsigned char *out ) +{ + unsigned char in1 , in2 , in3 , in4; + unsigned char out1 , out2 , out3; + int use_bytes; + int address= 0; + int i; + for(i=0;;i+=4 ){ + if( in[i] == 0 ){ + break; + } else if( in[i+1] == 0 ){ /* the last letter */ + break; + } else if( in[i+2] == 0 ){ /* the last 2 letters */ + in1 = lssproto_reversecharset[in[i]]; + in2 = lssproto_reversecharset[in[i+1]]; + in3 = in4 = 0; + use_bytes = 1; + } else if( in[i+3] == 0 ){ /* the last 3 letters */ + in1 = lssproto_reversecharset[in[i]]; + in2 = lssproto_reversecharset[in[i+1]]; + in3 = lssproto_reversecharset[in[i+2]]; + in4 = 0; + use_bytes = 2; + } else { /* process 4 letters */ + in1 = lssproto_reversecharset[in[i]]; + in2 = lssproto_reversecharset[in[i+1]]; + in3 = lssproto_reversecharset[in[i+2]]; + in4 = lssproto_reversecharset[in[i+3]]; + use_bytes = 3; + } + out1 = (in1<<2) | (((in2 & 0x30)>>4)&0x0f) ; + out2 = ((in2 & 0x0f )<<4) | ((( in3 & 0x3c)>>2)&0x0f); + out3 = ( (in3 &0x03)<<6) | ( in4 & 0x3f ); + if( use_bytes >= 1 ){ + out[address++] = out1; + } + if( use_bytes >= 2 ){ + out[address++] = out2; + } + if( use_bytes >= 3 ){ + out[address++] = out3; + } + if( use_bytes != 3 ){ + break; + } + } + return address; +} + +/* followings are taken from Jencode.c by jun */ +static void lssproto_jEncode(char *src,int srclen,int key,char *encoded,int *encodedlen,int maxencodedlen) +{ + char sum=0; + int i; + if(srclen+1 > maxencodedlen){ + *encodedlen = maxencodedlen; + for(i=0;i<(*encodedlen);i++)encoded[i] = src[i]; + } + if(srclen+1 <= maxencodedlen){ + *encodedlen=srclen+1; + for(i=0;i i) encoded[i] = src[i] + sum*((i*i)%3); + if(abs((key%srclen)) == i) encoded[i] = sum; + if(abs((key%srclen)) < i) encoded[i] = src[i-1] + sum*((i*i)%7); + } + } +} +static void lssproto_jDecode(char *src,int srclen,int key,char *decoded,int *decodedlen) +{ + char sum=0; + int i; + *decodedlen=srclen-1; + if( *decodedlen == 0 ){ + return; /* return error if length is 0 */ + } + sum = src[abs(key%(*decodedlen))]; + for(i=0;i i) decoded[i] = src[i] - sum*((i*i)%3); + if(abs((key%(*decodedlen))) < i) decoded[i-1] = src[i] - sum*((i*i)%7); + } + for(i=0;i<(*decodedlen);i++){ + if(((key%7) == (i%5))||((key%2) == (i%2)))decoded[i] = ~decoded[i]; + } +} + +/*****************************************************************/ +/* Compress / Decompress routine */ +/*****************************************************************/ +#define B00000000 0 +#define B00000001 1 +#define B00000010 2 +#define B00000011 3 +#define B00000100 4 +#define B00000101 5 +#define B00000110 6 +#define B00000111 7 +#define B00001000 8 +#define B00001001 9 +#define B00001010 10 +#define B00001011 11 +#define B00001100 12 +#define B00001101 13 +#define B00001110 14 +#define B00001111 15 +#define B00010000 16 +#define B00010001 17 +#define B00010010 18 +#define B00010011 19 +#define B00010100 20 +#define B00010101 21 +#define B00010110 22 +#define B00010111 23 +#define B00011000 24 +#define B00011001 25 +#define B00011010 26 +#define B00011011 27 +#define B00011100 28 +#define B00011101 29 +#define B00011110 30 +#define B00011111 31 +#define B00100000 32 +#define B00100001 33 +#define B00100010 34 +#define B00100011 35 +#define B00100100 36 +#define B00100101 37 +#define B00100110 38 +#define B00100111 39 +#define B00101000 40 +#define B00101001 41 +#define B00101010 42 +#define B00101011 43 +#define B00101100 44 +#define B00101101 45 +#define B00101110 46 +#define B00101111 47 +#define B00110000 48 +#define B00110001 49 +#define B00110010 50 +#define B00110011 51 +#define B00110100 52 +#define B00110101 53 +#define B00110110 54 +#define B00110111 55 +#define B00111000 56 +#define B00111001 57 +#define B00111010 58 +#define B00111011 59 +#define B00111100 60 +#define B00111101 61 +#define B00111110 62 +#define B00111111 63 +#define B01000000 64 +#define B01000001 65 +#define B01000010 66 +#define B01000011 67 +#define B01000100 68 +#define B01000101 69 +#define B01000110 70 +#define B01000111 71 +#define B01001000 72 +#define B01001001 73 +#define B01001010 74 +#define B01001011 75 +#define B01001100 76 +#define B01001101 77 +#define B01001110 78 +#define B01001111 79 +#define B01010000 80 +#define B01010001 81 +#define B01010010 82 +#define B01010011 83 +#define B01010100 84 +#define B01010101 85 +#define B01010110 86 +#define B01010111 87 +#define B01011000 88 +#define B01011001 89 +#define B01011010 90 +#define B01011011 91 +#define B01011100 92 +#define B01011101 93 +#define B01011110 94 +#define B01011111 95 +#define B01100000 96 +#define B01100001 97 +#define B01100010 98 +#define B01100011 99 +#define B01100100 100 +#define B01100101 101 +#define B01100110 102 +#define B01100111 103 +#define B01101000 104 +#define B01101001 105 +#define B01101010 106 +#define B01101011 107 +#define B01101100 108 +#define B01101101 109 +#define B01101110 110 +#define B01101111 111 +#define B01110000 112 +#define B01110001 113 +#define B01110010 114 +#define B01110011 115 +#define B01110100 116 +#define B01110101 117 +#define B01110110 118 +#define B01110111 119 +#define B01111000 120 +#define B01111001 121 +#define B01111010 122 +#define B01111011 123 +#define B01111100 124 +#define B01111101 125 +#define B01111110 126 +#define B01111111 127 +#define B10000000 128 +#define B10000001 129 +#define B10000010 130 +#define B10000011 131 +#define B10000100 132 +#define B10000101 133 +#define B10000110 134 +#define B10000111 135 +#define B10001000 136 +#define B10001001 137 +#define B10001010 138 +#define B10001011 139 +#define B10001100 140 +#define B10001101 141 +#define B10001110 142 +#define B10001111 143 +#define B10010000 144 +#define B10010001 145 +#define B10010010 146 +#define B10010011 147 +#define B10010100 148 +#define B10010101 149 +#define B10010110 150 +#define B10010111 151 +#define B10011000 152 +#define B10011001 153 +#define B10011010 154 +#define B10011011 155 +#define B10011100 156 +#define B10011101 157 +#define B10011110 158 +#define B10011111 159 +#define B10100000 160 +#define B10100001 161 +#define B10100010 162 +#define B10100011 163 +#define B10100100 164 +#define B10100101 165 +#define B10100110 166 +#define B10100111 167 +#define B10101000 168 +#define B10101001 169 +#define B10101010 170 +#define B10101011 171 +#define B10101100 172 +#define B10101101 173 +#define B10101110 174 +#define B10101111 175 +#define B10110000 176 +#define B10110001 177 +#define B10110010 178 +#define B10110011 179 +#define B10110100 180 +#define B10110101 181 +#define B10110110 182 +#define B10110111 183 +#define B10111000 184 +#define B10111001 185 +#define B10111010 186 +#define B10111011 187 +#define B10111100 188 +#define B10111101 189 +#define B10111110 190 +#define B10111111 191 +#define B11000000 192 +#define B11000001 193 +#define B11000010 194 +#define B11000011 195 +#define B11000100 196 +#define B11000101 197 +#define B11000110 198 +#define B11000111 199 +#define B11001000 200 +#define B11001001 201 +#define B11001010 202 +#define B11001011 203 +#define B11001100 204 +#define B11001101 205 +#define B11001110 206 +#define B11001111 207 +#define B11010000 208 +#define B11010001 209 +#define B11010010 210 +#define B11010011 211 +#define B11010100 212 +#define B11010101 213 +#define B11010110 214 +#define B11010111 215 +#define B11011000 216 +#define B11011001 217 +#define B11011010 218 +#define B11011011 219 +#define B11011100 220 +#define B11011101 221 +#define B11011110 222 +#define B11011111 223 +#define B11100000 224 +#define B11100001 225 +#define B11100010 226 +#define B11100011 227 +#define B11100100 228 +#define B11100101 229 +#define B11100110 230 +#define B11100111 231 +#define B11101000 232 +#define B11101001 233 +#define B11101010 234 +#define B11101011 235 +#define B11101100 236 +#define B11101101 237 +#define B11101110 238 +#define B11101111 239 +#define B11110000 240 +#define B11110001 241 +#define B11110010 242 +#define B11110011 243 +#define B11110100 244 +#define B11110101 245 +#define B11110110 246 +#define B11110111 247 +#define B11111000 248 +#define B11111001 249 +#define B11111010 250 +#define B11111011 251 +#define B11111100 252 +#define B11111101 253 +#define B11111110 254 +#define B11111111 255 +/* masks for first byte ( write )*/ +int lssproto_modifymask_first[8][9]={ + {0, B00000001,B00000011,B00000111,B00001111,B00011111,B00111111,B01111111,B11111111},/* mod 0*/ + {0, B00000011,B00000111,B00001111,B00011111,B00111111,B01111111,B11111111,B11111111},/* mod 1*/ + {0, B00000111,B00001111,B00011111,B00111111,B01111111,B11111111,B11111111,B11111111},/* mod 2*/ + {0, B00001111,B00011111,B00111111,B01111111,B11111111,B11111111,B11111111,B11111111},/* mod 3*/ + {0, B00011111,B00111111,B01111111,B11111111,B11111111,B11111111,B11111111,B11111111},/* mod 4*/ + {0, B00111111,B01111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111},/* mod 5*/ + {0, B01111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111},/* mod 6*/ + {0, B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111},/* mod 7*/ +}; +/* masks for second byte ( write ) */ +int lssproto_modifymask_second[8][9]={ + {0, B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000},/* mod 0 */ + {0, B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000001},/* mod 1 */ + {0, B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000001,B00000011},/* mod 2 */ + {0, B00000000,B00000000,B00000000,B00000000,B00000000,B00000001,B00000011,B00000111},/* mod 3 */ + {0, B00000000,B00000000,B00000000,B00000000,B00000001,B00000011,B00000111,B00001111},/* mod 4 */ + {0, B00000000,B00000000,B00000000,B00000001,B00000011,B00000111,B00001111,B00011111},/* mod 5 */ + {0, B00000000,B00000000,B00000001,B00000011,B00000111,B00001111,B00011111,B00111111},/* mod 6 */ + {0, B00000000,B00000001,B00000011,B00000111,B00001111,B00011111,B00111111,B01111111},/* mod 7 */ +}; +/* + * used by bitstream routines + */ +int bitstream_maxbyte, bitstream_bitaddr ; +char *bitstream_buf; +/* initialize bitstream for output */ +static int initOutputBitStream( char *buf ,int buflen) +{ + bitstream_bitaddr = 0; + bitstream_maxbyte = buflen; + bitstream_buf = buf; + memset( buf,0, buflen); + return 0; +} +/* initialize bitstream for input */ +static int initInputBitStream( char *buf , int buflen) +{ + bitstream_bitaddr = 0; + bitstream_maxbyte = buflen; + bitstream_buf = buf; + return 0; +} +/* + * read from bit stream. used only from 1 bit to 8 bits + * this is a base routine + */ +static unsigned int readInputBitStreamBody( int bwidth ) +{ + int mod = bitstream_bitaddr % 8; + int byteaddr = bitstream_bitaddr / 8; + /* return if excess */ + if( byteaddr >= bitstream_maxbyte)return 0; + if( bwidth >= 1 && bwidth <= 8){ + int b1 = (( bitstream_buf[byteaddr] & lssproto_modifymask_first[mod][bwidth] )>>mod); + int b2 = (( bitstream_buf[byteaddr+1] & lssproto_modifymask_second[mod][bwidth])<<(8-mod)); + bitstream_bitaddr += bwidth; + return b1 | b2; + } else { + return 0; + } +} +/* + * read from bit stream. used from 1 bit to 32 bits + * + */ +static unsigned int readInputBitStream( int bwidth ) +{ + if( bwidth <= 0 ){ + return 0; + } else if( bwidth >= 1 && bwidth <= 8 ){ + return readInputBitStreamBody( bwidth ); + } else if( bwidth >= 9 && bwidth <= 16 ){ + unsigned int first = readInputBitStreamBody(8); + unsigned int second = readInputBitStreamBody( bwidth-8); + return first + (second << 8 ); + } else if( bwidth >= 17 && bwidth <= 24 ){ + unsigned int first = readInputBitStreamBody(8); + unsigned int second = readInputBitStreamBody(8); + unsigned int third = readInputBitStreamBody(bwidth-8); + return first + ( second << 8 ) + ( third << 16 ); + } else if( bwidth >= 25 && bwidth <= 32 ){ + unsigned int first = readInputBitStreamBody(8); + unsigned int second = readInputBitStreamBody(8); + unsigned int third = readInputBitStreamBody(8); + unsigned int forth = readInputBitStreamBody(bwidth-8); + return first + ( second << 8 ) + ( third << 16 ) + ( forth << 24 ); + } + return 0; +} +/* + * write to a bitstream. only used from 1 bit to 8 bits + * this is a base routine. + */ +static int writeOutputBitStreamBody( int bwidth , unsigned char b) +{ + int mod = bitstream_bitaddr % 8; + int byteaddr = bitstream_bitaddr / 8; + /* return error if excess */ + if( bitstream_maxbyte <= (byteaddr+1)) return -1; + bitstream_buf[byteaddr] &= lssproto_modifymask_first[mod][bwidth]; + bitstream_buf[byteaddr] |= (b << mod) & lssproto_modifymask_first[mod][bwidth]; + bitstream_buf[byteaddr+1] &= lssproto_modifymask_second[mod][bwidth]; + bitstream_buf[byteaddr+1] |= (b>>(8-mod))& lssproto_modifymask_second[mod][bwidth]; + bitstream_bitaddr += bwidth; + return byteaddr+1; +} +/* + * write to a bitstream. used from 1 bits to 32 bits + * returns -1 if error or buffer excession + */ +static int writeOutputBitStream( int bwidth, unsigned int dat) +{ + int ret; + if( bwidth <= 0){ + return -1; + } else if( bwidth >= 1 && bwidth <= 8 ){ + if((ret=writeOutputBitStreamBody( bwidth , (unsigned char)dat))<0)return -1; + } else if( bwidth > 8 && bwidth <= 16 ){ + if(writeOutputBitStreamBody( 8 , (unsigned char)(dat&0xff))<0)return -1; + if((ret=writeOutputBitStreamBody( bwidth - 8 , ( unsigned char)((dat>>8)&0xff)))<0)return -1; + } else if( bwidth > 16 && bwidth <= 24 ){ + if(writeOutputBitStreamBody( 8 , (unsigned char)(dat&0xff))<0)return -1; + if(writeOutputBitStreamBody( 8 , (unsigned char)((dat>>8)&0xff))<0)return -1; + if((ret=writeOutputBitStreamBody( bwidth-16,(unsigned char)((dat>>16)&0xff)))<0)return -1; + } else if( bwidth > 24 && bwidth <= 32 ){ + if(writeOutputBitStreamBody( 8 , (unsigned char)(dat&0xff))<0)return -1; + if(writeOutputBitStreamBody( 8 , (unsigned char)((dat>>8)&0xff))<0)return -1; + if(writeOutputBitStreamBody( 8 , (unsigned char)((dat>>16)&0xff))<0)return -1; + if((ret=writeOutputBitStreamBody( bwidth-24,(unsigned char)((dat>>24)&0xff)))<0)return -1; + } else { + return -1; + } + return ret; +} +#define CHAR_SIZE 256 +#define NODE_SIZE 512 +#define BITS_LEN 9 /* 9 bit lzw compression */ +typedef struct { + unsigned char chr; + int parent; + int brother; + int child; +}NODE; +long lssproto_ringoCompressor( unsigned char *code , long codelen , + unsigned char *text , long textlen) +{ + NODE node[NODE_SIZE]; + int freeNode; + int w,k; /* used in this algo */ + int textind; /* index to text buffer */ + int i; + int position = 0; /* indicates the last byte of code buffer */ + if( textlen <= 0 ) return -1; + initOutputBitStream((char*) code,codelen); + /* fill characters ( 0 ~ 255 ) in the beggining part of + Node list */ + for(i=0; i<= CHAR_SIZE; i++){ + node[i].chr = (unsigned char)i; + node[i].brother = i + 1; + node[i].parent = 0; + node[i].child = 0; + } + node[CHAR_SIZE].brother = 0; + freeNode = CHAR_SIZE + 1; + w = text[0]; + textind = 1; + while(1){ + int rv; + if( textind >= textlen ){ + k = CHAR_SIZE; /* indicates EOF */ + } else { + k = text[textind]; + } + /* search if pattern 'wk' is registered or not. */ + rv = node[w].child; + while(1){ + if( rv <= 0 ) break; + if( node[rv].chr == k ) break; + rv = node[rv].brother; + } + if( rv > 0 ){ + /* found it */ + w = rv; + } else { + position = writeOutputBitStream( BITS_LEN ,w ); + /* return if buffer excession */ + if( position > codelen ) return -1; + /* register pattern 'wk' in the dictionary */ + if( freeNode < NODE_SIZE ){ + node[freeNode].parent = w; + node[freeNode].chr = k; + node[freeNode].brother = node[w].child; + node[freeNode].child = 0; + node[w].child = freeNode; + freeNode++; + } + w = k; + } + if( textind == ( textlen + 1 ) ) break; + textind++; + } + return position; +} + +/* + * Decoder. + * return -1 if buffer excession. Notice buffer text + * is modified . + */ +long lssproto_ringoDecompressor( unsigned char *text , long textlen , + unsigned char *code , long codelen) +{ + NODE node[NODE_SIZE]; + int stack[NODE_SIZE]; + int sp; + int freeNode; + int len; + int i; + int k = 0; + int w = 0; + if( codelen <= 0 ) return -1; + initInputBitStream( (char*)code , codelen ); + for(i=0;i= freeNode ){ + stack[sp++] = k; /* exception */ + if( sp >=( sizeof( stack ) /sizeof(stack[0] )) )return -1; + k = w; + } else { + k = rv; + } + while(k> CHAR_SIZE ){ + if( k >= (sizeof(node)/sizeof(node[0]))) return -1; + stack[sp++] = node[k].chr; + k = node[k].parent; + if( sp >=( sizeof( stack ) /sizeof(stack[0] )) ) return -1; + } + stack[sp++] = k; + if( sp >= ( sizeof( stack ) /sizeof(stack[0] )) ) return -1; + /* output to text buffer from stack.*/ + while(sp){ + if( ++len > textlen ) return -1; + *text++ = stack[--sp]; + } + /* register the pattern 'wk'*/ + if( len > 1 && freeNode < NODE_SIZE ){ + node[freeNode].parent = w; + node[freeNode].chr = k; + if( w >= (sizeof(node)/sizeof(node[0])))return -1; + node[freeNode].brother = node[w].child; + node[freeNode].child = 0; + node[w].child = freeNode; + freeNode++; + } + w = rv; + } + return len; +} +#endif /* ifdef lssproto__ENCRYPT */ + +/* Convert 62-base digits to 10 digits */ +int lssproto_a62toi( char *a ) +{ + int ret = 0; + int minus ; + if( a[0] == '-' ){ + minus = -1; + a++; + } else { + minus = 1; + } + + while( *a != '\0' ) + { + ret *= 62; + if( '0' <= (*a) && (*a) <= '9' ) + ret += (*a)-'0'; + else + if( 'a' <= (*a) && (*a) <= 'z' ) + ret += (*a)-'a'+10; + else + if( 'A' <= (*a) && (*a) <= 'Z' ) + ret += (*a)-'A'+36; + else + return 0; + a++; + } + return ret * minus; +} + +/* Convert 10-base digits into 62-base digits. */ +char *lssproto_cnv10to62( int a, char *out, int outlen ) +{ + int i, j; + char base[] = { "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"}; + int tmp[64]; + int src; + int minus; + int baselen = sizeof( base)-1; + if( a < 0 ){ + minus = 1; + a *= -1; + } else { + minus = 0; + } + /* special case */ + if( a < baselen) { + if( minus ){ + *(out) = '-'; + *(out+1) = base[a]; + *(out+2) = '\0'; + return (out); + } else { + *out = base[a]; + *(out+1) = '\0'; + return( out); + } + } + src = a; + for( i = 0; src >= baselen; i ++ ) { + tmp[i] = src % baselen; + src /= baselen; + } + i--; + if( minus ){ + *out = '-'; + *(out+1) = base[src]; + for( j = 2; i >= 0; i --, j ++ ) { + if( j > outlen - 2 ) return NULL; + *(out+j) = base[tmp[i]]; + } + } else { + *out = base[src]; + for( j = 1; i >= 0; i --, j ++ ) { + if( j > outlen - 2 ) return NULL; + *(out+j) = base[tmp[i]]; + } + } + *(out+j) = '\0'; + return( out); +} diff --git a/lua/Makefile b/lua/Makefile new file mode 100644 index 0000000..f3d644d --- /dev/null +++ b/lua/Makefile @@ -0,0 +1,184 @@ +# makefile for building Lua +# see ../INSTALL for installation instructions +# see ../Makefile and luaconf.h for further customization + +# == CHANGE THE SETTINGS BELOW TO SUIT YOUR ENVIRONMENT ======================= + +# Your platform. See PLATS for possible values. +PLAT= none + +INCFLAGS=-Iinclude + +CC= gcc +CFLAGS= -O3 -w -pipe $(INCFLAGS) $(MYCFLAGS) +AR= ar rcu +RANLIB= ranlib +RM= rm -f +LIBS= -lm $(MYLIBS) + +MYCFLAGS= +MYLDFLAGS= +MYLIBS= + +# == END OF USER SETTINGS. NO NEED TO CHANGE ANYTHING BELOW THIS LINE ========= + +PLATS= aix ansi bsd freebsd generic linux macosx mingw posix solaris + +LUA_A= liblua.a +CORE_O= lapi.o lcode.o ldebug.o ldo.o ldump.o lfunc.o lgc.o llex.o lmem.o \ + lobject.o lopcodes.o lparser.o lstate.o lstring.o ltable.o ltm.o \ + lundump.o lvm.o lzio.o +LIB_O= lauxlib.o lbaselib.o ldblib.o liolib.o lmathlib.o loslib.o ltablib.o \ + lstrlib.o loadlib.o linit.o + +LUA_T= lua +LUA_O= lua.o + +LUAC_T= luac +LUAC_O= luac.o print.o + +ALL_O= $(CORE_O) $(LIB_O) $(LUA_O) $(LUAC_O) +ALL_T= $(LUA_A) $(LUA_T) $(LUAC_T) +ALL_A= $(LUA_A) + +default: $(PLAT) + +all: $(ALL_T) + +o: $(ALL_O) + +a: $(ALL_A) + +$(LUA_A): $(CORE_O) $(LIB_O) + $(AR) $@ $? + $(RANLIB) $@ + +$(LUA_T): $(LUA_O) $(LUA_A) + $(CC) -o $@ $(MYLDFLAGS) $(LUA_O) $(LUA_A) $(LIBS) + +$(LUAC_T): $(LUAC_O) $(LUA_A) + $(CC) -o $@ $(MYLDFLAGS) $(LUAC_O) $(LUA_A) $(LIBS) + +clean: + $(RM) $(ALL_T) $(ALL_O) + +depend: + @$(CC) $(CFLAGS) -MM l*.c print.c + +echo: + @echo "PLAT = $(PLAT)" + @echo "CC = $(CC)" + @echo "CFLAGS = $(CFLAGS)" + @echo "AR = $(AR)" + @echo "RANLIB = $(RANLIB)" + @echo "RM = $(RM)" + @echo "MYCFLAGS = $(MYCFLAGS)" + @echo "MYLDFLAGS = $(MYLDFLAGS)" + @echo "MYLIBS = $(MYLIBS)" + +# convenience targets for popular platforms + +none: + @echo "Please choose a platform:" + @echo " $(PLATS)" + +aix: + $(MAKE) all CC="xlc" CFLAGS="-O2 -DLUA_USE_POSIX -DLUA_USE_DLOPEN" MYLIBS="-ldl" MYLDFLAGS="-brtl -bexpall" + +ansi: + $(MAKE) all MYCFLAGS=-DLUA_ANSI + +bsd: + $(MAKE) all MYCFLAGS="-DLUA_USE_POSIX -DLUA_USE_DLOPEN" MYLIBS="-Wl,-E" + +freebsd: + $(MAKE) all MYCFLAGS="-DLUA_USE_LINUX" MYLIBS="-Wl,-E -lreadline" + +generic: + $(MAKE) all MYCFLAGS= + +linux: + $(MAKE) all MYCFLAGS=-DLUA_USE_LINUX MYLIBS="-Wl,-E -ldl -lreadline -lhistory -lncurses" + +macosx: + $(MAKE) all MYCFLAGS=-DLUA_USE_LINUX MYLIBS="-lreadline" +# use this on Mac OS X 10.3- +# $(MAKE) all MYCFLAGS=-DLUA_USE_MACOSX + +mingw: + $(MAKE) "LUA_A=lua51.dll" "LUA_T=lua.exe" \ + "AR=$(CC) -shared -o" "RANLIB=strip --strip-unneeded" \ + "MYCFLAGS=-DLUA_BUILD_AS_DLL" "MYLIBS=" "MYLDFLAGS=-s" lua.exe + $(MAKE) "LUAC_T=luac.exe" luac.exe + +posix: + $(MAKE) all MYCFLAGS=-DLUA_USE_POSIX + +solaris: + $(MAKE) all MYCFLAGS="-DLUA_USE_POSIX -DLUA_USE_DLOPEN" MYLIBS="-ldl" + +# list targets that do not create files (but not all makes understand .PHONY) +.PHONY: all $(PLATS) default o a clean depend echo none + +# DO NOT DELETE + +lapi.o: lapi.c lua.h luaconf.h lapi.h lobject.h llimits.h ldebug.h \ + lstate.h ltm.h lzio.h lmem.h ldo.h lfunc.h lgc.h lstring.h ltable.h \ + lundump.h lvm.h +lauxlib.o: lauxlib.c lua.h luaconf.h lauxlib.h +lbaselib.o: lbaselib.c lua.h luaconf.h lauxlib.h lualib.h +lcode.o: lcode.c lua.h luaconf.h lcode.h llex.h lobject.h llimits.h \ + lzio.h lmem.h lopcodes.h lparser.h ldebug.h lstate.h ltm.h ldo.h lgc.h \ + ltable.h +ldblib.o: ldblib.c lua.h luaconf.h lauxlib.h lualib.h +ldebug.o: ldebug.c lua.h luaconf.h lapi.h lobject.h llimits.h lcode.h \ + llex.h lzio.h lmem.h lopcodes.h lparser.h ldebug.h lstate.h ltm.h ldo.h \ + lfunc.h lstring.h lgc.h ltable.h lvm.h +ldo.o: ldo.c lua.h luaconf.h ldebug.h lstate.h lobject.h llimits.h ltm.h \ + lzio.h lmem.h ldo.h lfunc.h lgc.h lopcodes.h lparser.h lstring.h \ + ltable.h lundump.h lvm.h +ldump.o: ldump.c lua.h luaconf.h lobject.h llimits.h lstate.h ltm.h \ + lzio.h lmem.h lundump.h +lfunc.o: lfunc.c lua.h luaconf.h lfunc.h lobject.h llimits.h lgc.h lmem.h \ + lstate.h ltm.h lzio.h +lgc.o: lgc.c lua.h luaconf.h ldebug.h lstate.h lobject.h llimits.h ltm.h \ + lzio.h lmem.h ldo.h lfunc.h lgc.h lstring.h ltable.h +linit.o: linit.c lua.h luaconf.h lualib.h lauxlib.h +liolib.o: liolib.c lua.h luaconf.h lauxlib.h lualib.h +llex.o: llex.c lua.h luaconf.h ldo.h lobject.h llimits.h lstate.h ltm.h \ + lzio.h lmem.h llex.h lparser.h lstring.h lgc.h ltable.h +lmathlib.o: lmathlib.c lua.h luaconf.h lauxlib.h lualib.h +lmem.o: lmem.c lua.h luaconf.h ldebug.h lstate.h lobject.h llimits.h \ + ltm.h lzio.h lmem.h ldo.h +loadlib.o: loadlib.c lua.h luaconf.h lauxlib.h lualib.h +lobject.o: lobject.c lua.h luaconf.h ldo.h lobject.h llimits.h lstate.h \ + ltm.h lzio.h lmem.h lstring.h lgc.h lvm.h +lopcodes.o: lopcodes.c lopcodes.h llimits.h lua.h luaconf.h +loslib.o: loslib.c lua.h luaconf.h lauxlib.h lualib.h +lparser.o: lparser.c lua.h luaconf.h lcode.h llex.h lobject.h llimits.h \ + lzio.h lmem.h lopcodes.h lparser.h ldebug.h lstate.h ltm.h ldo.h \ + lfunc.h lstring.h lgc.h ltable.h +lstate.o: lstate.c lua.h luaconf.h ldebug.h lstate.h lobject.h llimits.h \ + ltm.h lzio.h lmem.h ldo.h lfunc.h lgc.h llex.h lstring.h ltable.h +lstring.o: lstring.c lua.h luaconf.h lmem.h llimits.h lobject.h lstate.h \ + ltm.h lzio.h lstring.h lgc.h +lstrlib.o: lstrlib.c lua.h luaconf.h lauxlib.h lualib.h +ltable.o: ltable.c lua.h luaconf.h ldebug.h lstate.h lobject.h llimits.h \ + ltm.h lzio.h lmem.h ldo.h lgc.h ltable.h +ltablib.o: ltablib.c lua.h luaconf.h lauxlib.h lualib.h +ltm.o: ltm.c lua.h luaconf.h lobject.h llimits.h lstate.h ltm.h lzio.h \ + lmem.h lstring.h lgc.h ltable.h +lua.o: lua.c lua.h luaconf.h lauxlib.h lualib.h +luac.o: luac.c lua.h luaconf.h lauxlib.h ldo.h lobject.h llimits.h \ + lstate.h ltm.h lzio.h lmem.h lfunc.h lopcodes.h lstring.h lgc.h \ + lundump.h +lundump.o: lundump.c lua.h luaconf.h ldebug.h lstate.h lobject.h \ + llimits.h ltm.h lzio.h lmem.h ldo.h lfunc.h lstring.h lgc.h lundump.h +lvm.o: lvm.c lua.h luaconf.h ldebug.h lstate.h lobject.h llimits.h ltm.h \ + lzio.h lmem.h ldo.h lfunc.h lgc.h lopcodes.h lstring.h ltable.h lvm.h +lzio.o: lzio.c lua.h luaconf.h llimits.h lmem.h lstate.h lobject.h ltm.h \ + lzio.h +print.o: print.c ldebug.h lstate.h lua.h luaconf.h lobject.h llimits.h \ + ltm.h lzio.h lmem.h lopcodes.h lundump.h + +# (end of Makefile) diff --git a/lua/ReadMe.txt b/lua/ReadMe.txt new file mode 100644 index 0000000..8a04ce9 --- /dev/null +++ b/lua/ReadMe.txt @@ -0,0 +1,25 @@ +======================================================================== + 静态库:lua 项目概述 +======================================================================== + +应用程序向导已为您创建了此 lua 库项目。 + +本文件概要介绍组成 lua 应用程序的每个文件的内容。 + + +lua.vcproj + 这是使用应用程序向导生成的 VC++ 项目的主项目文件, + 其中包含生成该文件的 Visual C++ 的版本信息,以及有关使用应用程序向导选择的平台、配置和项目功能的信息。 + + +///////////////////////////////////////////////////////////////////////////// + +StdAfx.h, StdAfx.cpp + 这些文件用于生成名为 lua.pch 的预编译头 (PCH) 文件和名为 StdAfx.obj 的预编译类型文件。 + +///////////////////////////////////////////////////////////////////////////// +其他注释: + +应用程序向导使用“TODO:”注释来指示应添加或自定义的源代码部分。 + +///////////////////////////////////////////////////////////////////////////// \ No newline at end of file diff --git a/lua/lapi.c b/lua/lapi.c new file mode 100644 index 0000000..84113dd --- /dev/null +++ b/lua/lapi.c @@ -0,0 +1,1100 @@ +/* +** $Id: lapi.c,v 2.55.1.5 2008/07/04 18:41:18 roberto Exp $ +** Lua API +** See Copyright Notice in lua.h +*/ + + +#include +#include +#include +#include + +#define lapi_c +#define LUA_CORE + +#include "lua.h" + +#include "lapi.h" +#include "ldebug.h" +#include "ldo.h" +#include "lfunc.h" +#include "lgc.h" +#include "lmem.h" +#include "lobject.h" +#include "lstate.h" +#include "lstring.h" +#include "ltable.h" +#include "ltm.h" +#include "lundump.h" +#include "lvm.h" + + + +const char lua_ident[] = + "$Lua: " LUA_RELEASE " " LUA_COPYRIGHT " $\n" + "$Authors: " LUA_AUTHORS " $\n" + "$URL: www.lua.org $\n"; + + + +#define api_checknelems(L, n) api_check(L, (n) <= (L->top - L->base)) + +#define api_checkvalidindex(L, i) api_check(L, (i) != luaO_nilobject) + +#define api_incr_top(L) {api_check(L, L->top < L->ci->top); L->top++;} + + + +static TValue *index2adr (lua_State *L, int idx) { + if (idx > 0) { + TValue *o = L->base + (idx - 1); + api_check(L, idx <= L->ci->top - L->base); + if (o >= L->top) return cast(TValue *, luaO_nilobject); + else return o; + } + else if (idx > LUA_REGISTRYINDEX) { + api_check(L, idx != 0 && -idx <= L->top - L->base); + return L->top + idx; + } + else switch (idx) { /* pseudo-indices */ + case LUA_REGISTRYINDEX: return registry(L); + case LUA_ENVIRONINDEX: { + Closure *func = curr_func(L); + sethvalue(L, &L->env, func->c.env); + return &L->env; + } + case LUA_GLOBALSINDEX: return gt(L); + default: { + Closure *func = curr_func(L); + idx = LUA_GLOBALSINDEX - idx; + return (idx <= func->c.nupvalues) + ? &func->c.upvalue[idx-1] + : cast(TValue *, luaO_nilobject); + } + } +} + + +static Table *getcurrenv (lua_State *L) { + if (L->ci == L->base_ci) /* no enclosing function? */ + return hvalue(gt(L)); /* use global table as environment */ + else { + Closure *func = curr_func(L); + return func->c.env; + } +} + + +void luaA_pushobject (lua_State *L, const TValue *o) { + setobj2s(L, L->top, o); + api_incr_top(L); +} + + +LUA_API int lua_checkstack (lua_State *L, int size) { + int res = 1; + lua_lock(L); + if (size > LUAI_MAXCSTACK || (L->top - L->base + size) > LUAI_MAXCSTACK) + res = 0; /* stack overflow */ + else if (size > 0) { + luaD_checkstack(L, size); + if (L->ci->top < L->top + size) + L->ci->top = L->top + size; + } + lua_unlock(L); + return res; +} + + +LUA_API void lua_xmove (lua_State *from, lua_State *to, int n) { + int i; + if (from == to) return; + lua_lock(to); + api_checknelems(from, n); + api_check(from, G(from) == G(to)); + api_check(from, to->ci->top - to->top >= n); + from->top -= n; + for (i = 0; i < n; i++) { + setobj2s(to, to->top++, from->top + i); + } + lua_unlock(to); +} + + +LUA_API void lua_setlevel (lua_State *from, lua_State *to) { + to->nCcalls = from->nCcalls; +} + + +LUA_API lua_CFunction lua_atpanic (lua_State *L, lua_CFunction panicf) { + lua_CFunction old; + lua_lock(L); + old = G(L)->panic; + G(L)->panic = panicf; + lua_unlock(L); + return old; +} + + +LUA_API lua_State *lua_newthread (lua_State *L) { + lua_State *L1; + lua_lock(L); + luaC_checkGC(L); + L1 = luaE_newthread(L); + setthvalue(L, L->top, L1); + api_incr_top(L); + lua_unlock(L); + luai_userstatethread(L, L1); + return L1; +} + + + +/* +** basic stack manipulation +*/ + + +LUA_API int lua_gettop (lua_State *L) { + return cast_int(L->top - L->base); +} + + +LUA_API void lua_settop (lua_State *L, int idx) { + lua_lock(L); + if (idx >= 0) { + api_check(L, idx <= L->stack_last - L->base); + while (L->top < L->base + idx) + setnilvalue(L->top++); + L->top = L->base + idx; + } + else { + api_check(L, -(idx+1) <= (L->top - L->base)); + L->top += idx+1; /* `subtract' index (index is negative) */ + } + lua_unlock(L); +} + + +LUA_API void lua_remove (lua_State *L, int idx) { + StkId p; + lua_lock(L); + p = index2adr(L, idx); + api_checkvalidindex(L, p); + while (++p < L->top) setobjs2s(L, p-1, p); + L->top--; + lua_unlock(L); +} + + +LUA_API void lua_insert (lua_State *L, int idx) { + StkId p; + StkId q; + lua_lock(L); + p = index2adr(L, idx); + api_checkvalidindex(L, p); + for (q = L->top; q>p; q--) setobjs2s(L, q, q-1); + setobjs2s(L, p, L->top); + lua_unlock(L); +} + + +LUA_API void lua_replace (lua_State *L, int idx) { + StkId o; + lua_lock(L); + /* explicit test for incompatible code */ + if (idx == LUA_ENVIRONINDEX && L->ci == L->base_ci) + luaG_runerror(L, "no calling environment"); + api_checknelems(L, 1); + o = index2adr(L, idx); + api_checkvalidindex(L, o); + if (idx == LUA_ENVIRONINDEX) { + Closure *func = curr_func(L); + api_check(L, ttistable(L->top - 1)); + func->c.env = hvalue(L->top - 1); + luaC_barrier(L, func, L->top - 1); + } + else { + setobj(L, o, L->top - 1); + if (idx < LUA_GLOBALSINDEX) /* function upvalue? */ + luaC_barrier(L, curr_func(L), L->top - 1); + } + L->top--; + lua_unlock(L); +} + + +LUA_API void lua_pushvalue (lua_State *L, int idx) { + lua_lock(L); + setobj2s(L, L->top, index2adr(L, idx)); + api_incr_top(L); + lua_unlock(L); +} + + + +/* +** access functions (stack -> C) +*/ + + +LUA_API int lua_type (lua_State *L, int idx) { + StkId o = index2adr(L, idx); + return (o == luaO_nilobject) ? LUA_TNONE : ttype(o); +} + + +LUA_API const char *lua_typename (lua_State *L, int t) { + UNUSED(L); + return (t == LUA_TNONE) ? "no value" : luaT_typenames[t]; +} + + +LUA_API int lua_iscfunction (lua_State *L, int idx) { + StkId o = index2adr(L, idx); + return iscfunction(o); +} + + +LUA_API int lua_isnumber (lua_State *L, int idx) { + TValue n; + const TValue *o = index2adr(L, idx); + return tonumber(o, &n); +} + + +LUA_API int lua_isstring (lua_State *L, int idx) { + int t = lua_type(L, idx); + return (t == LUA_TSTRING || t == LUA_TNUMBER); +} + + +LUA_API int lua_isuserdata (lua_State *L, int idx) { + const TValue *o = index2adr(L, idx); + return (ttisuserdata(o) || ttislightuserdata(o)); +} + + +LUA_API int lua_rawequal (lua_State *L, int index1, int index2) { + StkId o1 = index2adr(L, index1); + StkId o2 = index2adr(L, index2); + return (o1 == luaO_nilobject || o2 == luaO_nilobject) ? 0 + : luaO_rawequalObj(o1, o2); +} + + +LUA_API int lua_equal (lua_State *L, int index1, int index2) { + StkId o1, o2; + int i; + lua_lock(L); /* may call tag method */ + o1 = index2adr(L, index1); + o2 = index2adr(L, index2); + i = (o1 == luaO_nilobject || o2 == luaO_nilobject) ? 0 : equalobj(L, o1, o2); + lua_unlock(L); + return i; +} + + +LUA_API int lua_lessthan (lua_State *L, int index1, int index2) { + StkId o1, o2; + int i; + lua_lock(L); /* may call tag method */ + o1 = index2adr(L, index1); + o2 = index2adr(L, index2); + i = (o1 == luaO_nilobject || o2 == luaO_nilobject) ? 0 + : luaV_lessthan(L, o1, o2); + lua_unlock(L); + return i; +} + + + +LUA_API lua_Number lua_tonumber (lua_State *L, int idx) { + TValue n; + const TValue *o = index2adr(L, idx); + if (tonumber(o, &n)) + return nvalue(o); + else + return 0; +} + + +LUA_API lua_Integer lua_tointeger (lua_State *L, int idx) { + TValue n; + const TValue *o = index2adr(L, idx); + if (tonumber(o, &n)) { + lua_Integer res; + lua_Number num = nvalue(o); + lua_number2integer(res, num); + return res; + } + else + return 0; +} + + +LUA_API int lua_toboolean (lua_State *L, int idx) { + const TValue *o = index2adr(L, idx); + return !l_isfalse(o); +} + + +LUA_API const char *lua_tolstring (lua_State *L, int idx, size_t *len) { + StkId o = index2adr(L, idx); + if (!ttisstring(o)) { + lua_lock(L); /* `luaV_tostring' may create a new string */ + if (!luaV_tostring(L, o)) { /* conversion failed? */ + if (len != NULL) *len = 0; + lua_unlock(L); + return NULL; + } + luaC_checkGC(L); + o = index2adr(L, idx); /* previous call may reallocate the stack */ + lua_unlock(L); + } + if (len != NULL) *len = tsvalue(o)->len; + return svalue(o); +} + + +LUA_API size_t lua_objlen (lua_State *L, int idx) { + StkId o = index2adr(L, idx); + switch (ttype(o)) { + case LUA_TSTRING: return tsvalue(o)->len; + case LUA_TUSERDATA: return uvalue(o)->len; + case LUA_TTABLE: return luaH_getn(hvalue(o)); + case LUA_TNUMBER: { + size_t l; + lua_lock(L); /* `luaV_tostring' may create a new string */ + l = (luaV_tostring(L, o) ? tsvalue(o)->len : 0); + lua_unlock(L); + return l; + } + default: return 0; + } +} + + +LUA_API lua_CFunction lua_tocfunction (lua_State *L, int idx) { + StkId o = index2adr(L, idx); + return (!iscfunction(o)) ? NULL : clvalue(o)->c.f; +} + + +LUA_API void *lua_touserdata (lua_State *L, int idx) { + StkId o = index2adr(L, idx); + switch (ttype(o)) { + case LUA_TUSERDATA: return (rawuvalue(o) + 1); + case LUA_TLIGHTUSERDATA: return pvalue(o); + default: return NULL; + } +} + + +LUA_API lua_State *lua_tothread (lua_State *L, int idx) { + StkId o = index2adr(L, idx); + return (!ttisthread(o)) ? NULL : thvalue(o); +} + + +LUA_API const void *lua_topointer (lua_State *L, int idx) { + StkId o = index2adr(L, idx); + switch (ttype(o)) { + case LUA_TTABLE: return hvalue(o); + case LUA_TFUNCTION: return clvalue(o); + case LUA_TTHREAD: return thvalue(o); + case LUA_TUSERDATA: + case LUA_TLIGHTUSERDATA: + return lua_touserdata(L, idx); + default: return NULL; + } +} + + + +/* +** push functions (C -> stack) +*/ + + +LUA_API void lua_pushnil (lua_State *L) { + lua_lock(L); + setnilvalue(L->top); + api_incr_top(L); + lua_unlock(L); +} + + +LUA_API void lua_pushnumber (lua_State *L, lua_Number n) { + lua_lock(L); + setnvalue(L->top, n); + api_incr_top(L); + lua_unlock(L); +} + + +LUA_API void lua_pushinteger (lua_State *L, lua_Integer n) { + lua_lock(L); + setnvalue(L->top, cast_num(n)); + api_incr_top(L); + lua_unlock(L); +} + + +LUA_API void lua_pushlstring (lua_State *L, const char *s, size_t len) { + lua_lock(L); + luaC_checkGC(L); + setsvalue2s(L, L->top, luaS_newlstr(L, s, len)); + api_incr_top(L); + lua_unlock(L); +} + + +LUA_API void lua_pushstring (lua_State *L, const char *s) { + if (s == NULL) + lua_pushnil(L); + else + lua_pushlstring(L, s, strlen(s)); +} + + +LUA_API const char *lua_pushvfstring (lua_State *L, const char *fmt, + va_list argp) { + const char *ret; + lua_lock(L); + luaC_checkGC(L); + ret = luaO_pushvfstring(L, fmt, argp); + lua_unlock(L); + return ret; +} + + +LUA_API const char *lua_pushfstring (lua_State *L, const char *fmt, ...) { + const char *ret; + va_list argp; + lua_lock(L); + luaC_checkGC(L); + va_start(argp, fmt); + ret = luaO_pushvfstring(L, fmt, argp); + va_end(argp); + lua_unlock(L); + return ret; +} + + +LUA_API void lua_pushcclosure (lua_State *L, lua_CFunction fn, int n) { + Closure *cl; + lua_lock(L); + luaC_checkGC(L); + api_checknelems(L, n); + cl = luaF_newCclosure(L, n, getcurrenv(L)); + cl->c.f = fn; + L->top -= n; + while (n--) + setobj2n(L, &cl->c.upvalue[n], L->top+n); + setclvalue(L, L->top, cl); + lua_assert(iswhite(obj2gco(cl))); + api_incr_top(L); + lua_unlock(L); +} + + +LUA_API void lua_pushboolean (lua_State *L, int b) { + lua_lock(L); + setbvalue(L->top, (b != 0)); /* ensure that true is 1 */ + api_incr_top(L); + lua_unlock(L); +} + + +LUA_API void lua_pushlightuserdata (lua_State *L, void *p) { + lua_lock(L); + setpvalue(L->top, p); + api_incr_top(L); + lua_unlock(L); +} + + +LUA_API int lua_pushthread (lua_State *L) { + lua_lock(L); + setthvalue(L, L->top, L); + api_incr_top(L); + lua_unlock(L); + return (G(L)->mainthread == L); +} + + + +/* +** get functions (Lua -> stack) +*/ + + +LUA_API void lua_gettable (lua_State *L, int idx) { + StkId t; + lua_lock(L); + t = index2adr(L, idx); + api_checkvalidindex(L, t); + luaV_gettable(L, t, L->top - 1, L->top - 1); + lua_unlock(L); +} + + +LUA_API void lua_getfield (lua_State *L, int idx, const char *k) { + StkId t; + TValue key; + lua_lock(L); + t = index2adr(L, idx); + api_checkvalidindex(L, t); + setsvalue(L, &key, luaS_new(L, k)); + luaV_gettable(L, t, &key, L->top); + api_incr_top(L); + lua_unlock(L); +} + + +LUA_API void lua_rawget (lua_State *L, int idx) { + StkId t; + lua_lock(L); + t = index2adr(L, idx); + api_check(L, ttistable(t)); + setobj2s(L, L->top - 1, luaH_get(hvalue(t), L->top - 1)); + lua_unlock(L); +} + + +LUA_API void lua_rawgeti (lua_State *L, int idx, int n) { + StkId o; + lua_lock(L); + o = index2adr(L, idx); + api_check(L, ttistable(o)); + setobj2s(L, L->top, luaH_getnum(hvalue(o), n)); + api_incr_top(L); + lua_unlock(L); +} + + +LUA_API void lua_createtable (lua_State *L, int narray, int nrec) { + lua_lock(L); + luaC_checkGC(L); + sethvalue(L, L->top, luaH_new(L, narray, nrec)); + api_incr_top(L); + lua_unlock(L); +} + + +LUA_API int lua_getmetatable (lua_State *L, int objindex) { + const TValue *obj; + Table *mt = NULL; + int res; + lua_lock(L); + obj = index2adr(L, objindex); + switch (ttype(obj)) { + case LUA_TTABLE: + mt = hvalue(obj)->metatable; + break; + case LUA_TUSERDATA: + mt = uvalue(obj)->metatable; + break; + default: + mt = G(L)->mt[ttype(obj)]; + break; + } + if (mt == NULL) + res = 0; + else { + sethvalue(L, L->top, mt); + api_incr_top(L); + res = 1; + } + lua_unlock(L); + return res; +} + + +LUA_API void lua_getfenv (lua_State *L, int idx) { + StkId o; + lua_lock(L); + o = index2adr(L, idx); + api_checkvalidindex(L, o); + switch (ttype(o)) { + case LUA_TFUNCTION: + sethvalue(L, L->top, clvalue(o)->c.env); + break; + case LUA_TUSERDATA: + sethvalue(L, L->top, uvalue(o)->env); + break; + case LUA_TTHREAD: + setobj2s(L, L->top, gt(thvalue(o))); + break; + default: + setnilvalue(L->top); + break; + } + api_incr_top(L); + lua_unlock(L); +} + + +/* +** set functions (stack -> Lua) +*/ + + +LUA_API void lua_settable (lua_State *L, int idx) { + StkId t; + lua_lock(L); + api_checknelems(L, 2); + t = index2adr(L, idx); + api_checkvalidindex(L, t); + luaV_settable(L, t, L->top - 2, L->top - 1); + L->top -= 2; /* pop index and value */ + lua_unlock(L); +} + + +LUA_API void lua_setfield (lua_State *L, int idx, const char *k) { + StkId t; + TValue key; + lua_lock(L); + api_checknelems(L, 1); + t = index2adr(L, idx); + api_checkvalidindex(L, t); + setsvalue(L, &key, luaS_new(L, k)); + luaV_settable(L, t, &key, L->top - 1); + L->top--; /* pop value */ + lua_unlock(L); +} + + +LUA_API void lua_rawset (lua_State *L, int idx) { + StkId t; + lua_lock(L); + api_checknelems(L, 2); + t = index2adr(L, idx); + api_check(L, ttistable(t)); + setobj2t(L, luaH_set(L, hvalue(t), L->top-2), L->top-1); + luaC_barriert(L, hvalue(t), L->top-1); + L->top -= 2; + lua_unlock(L); +} + + +LUA_API void lua_rawseti (lua_State *L, int idx, int n) { + StkId o; + lua_lock(L); + api_checknelems(L, 1); + o = index2adr(L, idx); + api_check(L, ttistable(o)); + setobj2t(L, luaH_setnum(L, hvalue(o), n), L->top-1); + luaC_barriert(L, hvalue(o), L->top-1); + L->top--; + lua_unlock(L); +} + + +LUA_API int lua_setmetatable (lua_State *L, int objindex) { + TValue *obj; + Table *mt; + lua_lock(L); + api_checknelems(L, 1); + obj = index2adr(L, objindex); + api_checkvalidindex(L, obj); + if (ttisnil(L->top - 1)) + mt = NULL; + else { + api_check(L, ttistable(L->top - 1)); + mt = hvalue(L->top - 1); + } + switch (ttype(obj)) { + case LUA_TTABLE: { + hvalue(obj)->metatable = mt; + if (mt) + luaC_objbarriert(L, hvalue(obj), mt); + break; + } + case LUA_TUSERDATA: { + uvalue(obj)->metatable = mt; + if (mt) + luaC_objbarrier(L, rawuvalue(obj), mt); + break; + } + default: { + G(L)->mt[ttype(obj)] = mt; + break; + } + } + L->top--; + lua_unlock(L); + return 1; +} + + +LUA_API int lua_setfenv (lua_State *L, int idx) { + StkId o; + int res = 1; + lua_lock(L); + api_checknelems(L, 1); + o = index2adr(L, idx); + api_checkvalidindex(L, o); + api_check(L, ttistable(L->top - 1)); + switch (ttype(o)) { + case LUA_TFUNCTION: + clvalue(o)->c.env = hvalue(L->top - 1); + break; + case LUA_TUSERDATA: + uvalue(o)->env = hvalue(L->top - 1); + break; + case LUA_TTHREAD: + sethvalue(L, gt(thvalue(o)), hvalue(L->top - 1)); + break; + default: + res = 0; + break; + } + if (res) luaC_objbarrier(L, gcvalue(o), hvalue(L->top - 1)); + L->top--; + lua_unlock(L); + return res; +} + + +/* +** `load' and `call' functions (run Lua code) +*/ + + +#define adjustresults(L,nres) \ + { if (nres == LUA_MULTRET && L->top >= L->ci->top) L->ci->top = L->top; } + + +#define checkresults(L,na,nr) \ + api_check(L, (nr) == LUA_MULTRET || (L->ci->top - L->top >= (nr) - (na))) + + +LUA_API void lua_call (lua_State *L, int nargs, int nresults) { + StkId func; + lua_lock(L); + api_checknelems(L, nargs+1); + checkresults(L, nargs, nresults); + func = L->top - (nargs+1); + luaD_call(L, func, nresults); + adjustresults(L, nresults); + lua_unlock(L); +} + + + +/* +** Execute a protected call. +*/ +struct CallS { /* data to `f_call' */ + StkId func; + int nresults; +}; + + +static void f_call (lua_State *L, void *ud) { + struct CallS *c = cast(struct CallS *, ud); + luaD_call(L, c->func, c->nresults); +} + + + +LUA_API int lua_pcall (lua_State *L, int nargs, int nresults, int errfunc) { + struct CallS c; + int status; + ptrdiff_t func; + lua_lock(L); + api_checknelems(L, nargs+1); + checkresults(L, nargs, nresults); + if (errfunc == 0) + func = 0; + else { + StkId o = index2adr(L, errfunc); + api_checkvalidindex(L, o); + func = savestack(L, o); + } + c.func = L->top - (nargs+1); /* function to be called */ + c.nresults = nresults; + status = luaD_pcall(L, f_call, &c, savestack(L, c.func), func); + adjustresults(L, nresults); + lua_unlock(L); + return status; +} + + +/* +** Execute a protected C call. +*/ +struct CCallS { /* data to `f_Ccall' */ + lua_CFunction func; + void *ud; +}; + + +static void f_Ccall (lua_State *L, void *ud) { + struct CCallS *c = cast(struct CCallS *, ud); + Closure *cl; + cl = luaF_newCclosure(L, 0, getcurrenv(L)); + cl->c.f = c->func; + setclvalue(L, L->top, cl); /* push function */ + api_incr_top(L); + setpvalue(L->top, c->ud); /* push only argument */ + api_incr_top(L); + luaD_call(L, L->top - 2, 0); +} + + +LUA_API int lua_cpcall (lua_State *L, lua_CFunction func, void *ud) { + struct CCallS c; + int status; + lua_lock(L); + c.func = func; + c.ud = ud; + status = luaD_pcall(L, f_Ccall, &c, savestack(L, L->top), 0); + lua_unlock(L); + return status; +} + + +LUA_API int lua_load (lua_State *L, lua_Reader reader, void *data, + const char *chunkname) { + ZIO z; + int status; + lua_lock(L); + if (!chunkname) chunkname = "?"; + luaZ_init(L, &z, reader, data); + status = luaD_protectedparser(L, &z, chunkname); + lua_unlock(L); + return status; +} + + +LUA_API int lua_dump (lua_State *L, lua_Writer writer, void *data) { + int status; + TValue *o; + lua_lock(L); + api_checknelems(L, 1); + o = L->top - 1; + if (isLfunction(o)) + status = luaU_dump(L, clvalue(o)->l.p, writer, data, 0); + else + status = 1; + lua_unlock(L); + return status; +} + + +LUA_API int lua_status (lua_State *L) { + return L->status; +} + + +/* +** Garbage-collection function +*/ + +LUA_API int lua_gc (lua_State *L, int what, int data) { + int res = 0; + global_State *g; + lua_lock(L); + g = G(L); + switch (what) { + case LUA_GCSTOP: { + g->GCthreshold = MAX_LUMEM; + break; + } + case LUA_GCRESTART: { + g->GCthreshold = g->totalbytes; + break; + } + case LUA_GCCOLLECT: { + luaC_fullgc(L); + break; + } + case LUA_GCCOUNT: { + /* GC values are expressed in Kbytes: #bytes/2^10 */ + res = cast_int(g->totalbytes >> 10); + break; + } + case LUA_GCCOUNTB: { + res = cast_int(g->totalbytes & 0x3ff); + break; + } + case LUA_GCSTEP: { + lu_mem a = (cast(lu_mem, data) << 10); + if (a <= g->totalbytes) + g->GCthreshold = g->totalbytes - a; + else + g->GCthreshold = 0; + while (g->GCthreshold <= g->totalbytes) { + luaC_step(L); + if (g->gcstate == GCSpause) { /* end of cycle? */ + res = 1; /* signal it */ + break; + } + } + break; + } + case LUA_GCSETPAUSE: { + res = g->gcpause; + g->gcpause = data; + break; + } + case LUA_GCSETSTEPMUL: { + res = g->gcstepmul; + g->gcstepmul = data; + break; + } + default: res = -1; /* invalid option */ + } + lua_unlock(L); + return res; +} + + + +/* +** miscellaneous functions +*/ + + +LUA_API int lua_error (lua_State *L) { + lua_lock(L); + api_checknelems(L, 1); + luaG_errormsg(L); + lua_unlock(L); + return 0; /* to avoid warnings */ +} + + +LUA_API int lua_next (lua_State *L, int idx) { + StkId t; + int more; + lua_lock(L); + t = index2adr(L, idx); + api_check(L, ttistable(t)); + more = luaH_next(L, hvalue(t), L->top - 1); + if (more) { + api_incr_top(L); + } + else /* no more elements */ + L->top -= 1; /* remove key */ + lua_unlock(L); + return more; +} + + +LUA_API void lua_concat (lua_State *L, int n) { + lua_lock(L); + api_checknelems(L, n); + if (n >= 2) { + luaC_checkGC(L); + luaV_concat(L, n, cast_int(L->top - L->base) - 1); + L->top -= (n-1); + } + else if (n == 0) { /* push empty string */ + setsvalue2s(L, L->top, luaS_newlstr(L, "", 0)); + api_incr_top(L); + } + /* else n == 1; nothing to do */ + lua_unlock(L); +} + + +LUA_API lua_Alloc lua_getallocf (lua_State *L, void **ud) { + lua_Alloc f; + lua_lock(L); + if (ud) *ud = G(L)->ud; + f = G(L)->frealloc; + lua_unlock(L); + return f; +} + + +LUA_API void lua_setallocf (lua_State *L, lua_Alloc f, void *ud) { + lua_lock(L); + G(L)->ud = ud; + G(L)->frealloc = f; + lua_unlock(L); +} + + +LUA_API void *lua_newuserdata (lua_State *L, size_t size) { + Udata *u; + lua_lock(L); + luaC_checkGC(L); + u = luaS_newudata(L, size, getcurrenv(L)); + setuvalue(L, L->top, u); + api_incr_top(L); + lua_unlock(L); + return u + 1; +} + + + + +static const char *aux_upvalue (StkId fi, int n, TValue **val) { + Closure *f; + if (!ttisfunction(fi)) return NULL; + f = clvalue(fi); + if (f->c.isC) { + if (!(1 <= n && n <= f->c.nupvalues)) return NULL; + *val = &f->c.upvalue[n-1]; + return ""; + } + else { + Proto *p = f->l.p; + if (!(1 <= n && n <= p->sizeupvalues)) return NULL; + *val = f->l.upvals[n-1]->v; + return getstr(p->upvalues[n-1]); + } +} + + +LUA_API const char *lua_getupvalue (lua_State *L, int funcindex, int n) { + const char *name; + TValue *val; + lua_lock(L); + name = aux_upvalue(index2adr(L, funcindex), n, &val); + if (name) { + setobj2s(L, L->top, val); + api_incr_top(L); + } + lua_unlock(L); + return name; +} + + +LUA_API const char *lua_setupvalue (lua_State *L, int funcindex, int n) { + const char *name; + TValue *val; + StkId fi; + lua_lock(L); + fi = index2adr(L, funcindex); + api_checknelems(L, 1); + name = aux_upvalue(fi, n, &val); + if (name) { + L->top--; + setobj(L, val, L->top); + luaC_barrier(L, clvalue(fi), L->top); + } + lua_unlock(L); + return name; +} + + +LUA_API void Lua_ReturnArray(lua_State *L,int Array[],int num) +{ + lua_newtable( L ); + int i; + for (i=0;i +#include +#include +#include +#include +#include + + +/* This file uses only the official API of Lua. +** Any function declared here could be written as an application function. +*/ + +#define lauxlib_c +#define LUA_LIB + +#include "lua.h" + +#include "lauxlib.h" + + +#define FREELIST_REF 0 /* free list of references */ + + +/* convert a stack index to positive */ +#define abs_index(L, i) ((i) > 0 || (i) <= LUA_REGISTRYINDEX ? (i) : \ + lua_gettop(L) + (i) + 1) + + +/* +** {====================================================== +** Error-report functions +** ======================================================= +*/ + + +LUALIB_API int luaL_argerror (lua_State *L, int narg, const char *extramsg) { + lua_Debug ar; + if (!lua_getstack(L, 0, &ar)) /* no stack frame? */ + return luaL_error(L, "bad argument #%d (%s)", narg, extramsg); + lua_getinfo(L, "n", &ar); + if (strcmp(ar.namewhat, "method") == 0) { + narg--; /* do not count `self' */ + if (narg == 0) /* error is in the self argument itself? */ + return luaL_error(L, "calling " LUA_QS " on bad self (%s)", + ar.name, extramsg); + } + if (ar.name == NULL) + ar.name = "?"; + return luaL_error(L, "bad argument #%d to " LUA_QS " (%s)", + narg, ar.name, extramsg); +} + + +LUALIB_API int luaL_typerror (lua_State *L, int narg, const char *tname) { + const char *msg = lua_pushfstring(L, "%s expected, got %s", + tname, luaL_typename(L, narg)); + return luaL_argerror(L, narg, msg); +} + + +static void tag_error (lua_State *L, int narg, int tag) { + luaL_typerror(L, narg, lua_typename(L, tag)); +} + + +LUALIB_API void luaL_where (lua_State *L, int level) { + lua_Debug ar; + if (lua_getstack(L, level, &ar)) { /* check function at level */ + lua_getinfo(L, "Sl", &ar); /* get info about it */ + if (ar.currentline > 0) { /* is there info? */ + lua_pushfstring(L, "%s:%d: ", ar.short_src, ar.currentline); + return; + } + } + lua_pushliteral(L, ""); /* else, no information available... */ +} + + +LUALIB_API int luaL_error (lua_State *L, const char *fmt, ...) { + va_list argp; + va_start(argp, fmt); + luaL_where(L, 1); + lua_pushvfstring(L, fmt, argp); + va_end(argp); + lua_concat(L, 2); + return lua_error(L); +} + +/* }====================================================== */ + + +LUALIB_API int luaL_checkoption (lua_State *L, int narg, const char *def, + const char *const lst[]) { + const char *name = (def) ? luaL_optstring(L, narg, def) : + luaL_checkstring(L, narg); + int i; + for (i=0; lst[i]; i++) + if (strcmp(lst[i], name) == 0) + return i; + return luaL_argerror(L, narg, + lua_pushfstring(L, "invalid option " LUA_QS, name)); +} + + +LUALIB_API int luaL_newmetatable (lua_State *L, const char *tname) { + lua_getfield(L, LUA_REGISTRYINDEX, tname); /* get registry.name */ + if (!lua_isnil(L, -1)) /* name already in use? */ + return 0; /* leave previous value on top, but return 0 */ + lua_pop(L, 1); + lua_newtable(L); /* create metatable */ + lua_pushvalue(L, -1); + lua_setfield(L, LUA_REGISTRYINDEX, tname); /* registry.name = metatable */ + return 1; +} + + +LUALIB_API void *luaL_checkudata (lua_State *L, int ud, const char *tname) { + void *p = lua_touserdata(L, ud); + if (p != NULL) { /* value is a userdata? */ + if (lua_getmetatable(L, ud)) { /* does it have a metatable? */ + lua_getfield(L, LUA_REGISTRYINDEX, tname); /* get correct metatable */ + if (lua_rawequal(L, -1, -2)) { /* does it have the correct mt? */ + lua_pop(L, 2); /* remove both metatables */ + return p; + } + } + } + luaL_typerror(L, ud, tname); /* else error */ + return NULL; /* to avoid warnings */ +} + + +LUALIB_API void luaL_checkstack (lua_State *L, int space, const char *mes) { + if (!lua_checkstack(L, space)) + luaL_error(L, "stack overflow (%s)", mes); +} + + +LUALIB_API void luaL_checktype (lua_State *L, int narg, int t) { + if (lua_type(L, narg) != t) + tag_error(L, narg, t); +} + + +LUALIB_API void luaL_checkany (lua_State *L, int narg) { + if (lua_type(L, narg) == LUA_TNONE) + luaL_argerror(L, narg, "value expected"); +} + + +LUALIB_API const char *luaL_checklstring (lua_State *L, int narg, size_t *len) { + const char *s = lua_tolstring(L, narg, len); + if (!s) tag_error(L, narg, LUA_TSTRING); + return s; +} + + +LUALIB_API const char *luaL_optlstring (lua_State *L, int narg, + const char *def, size_t *len) { + if (lua_isnoneornil(L, narg)) { + if (len) + *len = (def ? strlen(def) : 0); + return def; + } + else return luaL_checklstring(L, narg, len); +} + + +LUALIB_API lua_Number luaL_checknumber (lua_State *L, int narg) { + lua_Number d = lua_tonumber(L, narg); + if (d == 0 && !lua_isnumber(L, narg)) /* avoid extra test when d is not 0 */ + tag_error(L, narg, LUA_TNUMBER); + return d; +} + + +LUALIB_API lua_Number luaL_optnumber (lua_State *L, int narg, lua_Number def) { + return luaL_opt(L, luaL_checknumber, narg, def); +} + + +LUALIB_API lua_Integer luaL_checkinteger (lua_State *L, int narg) { + lua_Integer d = lua_tointeger(L, narg); + if (d == 0 && !lua_isnumber(L, narg)) /* avoid extra test when d is not 0 */ + tag_error(L, narg, LUA_TNUMBER); + return d; +} + + +LUALIB_API lua_Integer luaL_optinteger (lua_State *L, int narg, + lua_Integer def) { + return luaL_opt(L, luaL_checkinteger, narg, def); +} + + +LUALIB_API int luaL_getmetafield (lua_State *L, int obj, const char *event) { + if (!lua_getmetatable(L, obj)) /* no metatable? */ + return 0; + lua_pushstring(L, event); + lua_rawget(L, -2); + if (lua_isnil(L, -1)) { + lua_pop(L, 2); /* remove metatable and metafield */ + return 0; + } + else { + lua_remove(L, -2); /* remove only metatable */ + return 1; + } +} + + +LUALIB_API int luaL_callmeta (lua_State *L, int obj, const char *event) { + obj = abs_index(L, obj); + if (!luaL_getmetafield(L, obj, event)) /* no metafield? */ + return 0; + lua_pushvalue(L, obj); + lua_call(L, 1, 1); + return 1; +} + + +LUALIB_API void (luaL_register) (lua_State *L, const char *libname, + const luaL_Reg *l) { + luaI_openlib(L, libname, l, 0); +} + + +static int libsize (const luaL_Reg *l) { + int size = 0; + for (; l->name; l++) size++; + return size; +} + + +LUALIB_API void luaI_openlib (lua_State *L, const char *libname, + const luaL_Reg *l, int nup) { + if (libname) { + int size = libsize(l); + /* check whether lib already exists */ + luaL_findtable(L, LUA_REGISTRYINDEX, "_LOADED", 1); + lua_getfield(L, -1, libname); /* get _LOADED[libname] */ + if (!lua_istable(L, -1)) { /* not found? */ + lua_pop(L, 1); /* remove previous result */ + /* try global variable (and create one if it does not exist) */ + if (luaL_findtable(L, LUA_GLOBALSINDEX, libname, size) != NULL) + luaL_error(L, "name conflict for module " LUA_QS, libname); + lua_pushvalue(L, -1); + lua_setfield(L, -3, libname); /* _LOADED[libname] = new table */ + } + lua_remove(L, -2); /* remove _LOADED table */ + lua_insert(L, -(nup+1)); /* move library table to below upvalues */ + } + for (; l->name; l++) { + int i; + for (i=0; ifunc, nup); + lua_setfield(L, -(nup+2), l->name); + } + lua_pop(L, nup); /* remove upvalues */ +} + + + +/* +** {====================================================== +** getn-setn: size for arrays +** ======================================================= +*/ + +#if defined(LUA_COMPAT_GETN) + +static int checkint (lua_State *L, int topop) { + int n = (lua_type(L, -1) == LUA_TNUMBER) ? lua_tointeger(L, -1) : -1; + lua_pop(L, topop); + return n; +} + + +static void getsizes (lua_State *L) { + lua_getfield(L, LUA_REGISTRYINDEX, "LUA_SIZES"); + if (lua_isnil(L, -1)) { /* no `size' table? */ + lua_pop(L, 1); /* remove nil */ + lua_newtable(L); /* create it */ + lua_pushvalue(L, -1); /* `size' will be its own metatable */ + lua_setmetatable(L, -2); + lua_pushliteral(L, "kv"); + lua_setfield(L, -2, "__mode"); /* metatable(N).__mode = "kv" */ + lua_pushvalue(L, -1); + lua_setfield(L, LUA_REGISTRYINDEX, "LUA_SIZES"); /* store in register */ + } +} + + +LUALIB_API void luaL_setn (lua_State *L, int t, int n) { + t = abs_index(L, t); + lua_pushliteral(L, "n"); + lua_rawget(L, t); + if (checkint(L, 1) >= 0) { /* is there a numeric field `n'? */ + lua_pushliteral(L, "n"); /* use it */ + lua_pushinteger(L, n); + lua_rawset(L, t); + } + else { /* use `sizes' */ + getsizes(L); + lua_pushvalue(L, t); + lua_pushinteger(L, n); + lua_rawset(L, -3); /* sizes[t] = n */ + lua_pop(L, 1); /* remove `sizes' */ + } +} + + +LUALIB_API int luaL_getn (lua_State *L, int t) { + int n; + t = abs_index(L, t); + lua_pushliteral(L, "n"); /* try t.n */ + lua_rawget(L, t); + if ((n = checkint(L, 1)) >= 0) return n; + getsizes(L); /* else try sizes[t] */ + lua_pushvalue(L, t); + lua_rawget(L, -2); + if ((n = checkint(L, 2)) >= 0) return n; + return (int)lua_objlen(L, t); +} + +#endif + +/* }====================================================== */ + + + +LUALIB_API const char *luaL_gsub (lua_State *L, const char *s, const char *p, + const char *r) { + const char *wild; + size_t l = strlen(p); + luaL_Buffer b; + luaL_buffinit(L, &b); + while ((wild = strstr(s, p)) != NULL) { + luaL_addlstring(&b, s, wild - s); /* push prefix */ + luaL_addstring(&b, r); /* push replacement in place of pattern */ + s = wild + l; /* continue after `p' */ + } + luaL_addstring(&b, s); /* push last suffix */ + luaL_pushresult(&b); + return lua_tostring(L, -1); +} + + +LUALIB_API const char *luaL_findtable (lua_State *L, int idx, + const char *fname, int szhint) { + const char *e; + lua_pushvalue(L, idx); + do { + e = strchr(fname, '.'); + if (e == NULL) e = fname + strlen(fname); + lua_pushlstring(L, fname, e - fname); + lua_rawget(L, -2); + if (lua_isnil(L, -1)) { /* no such field? */ + lua_pop(L, 1); /* remove this nil */ + lua_createtable(L, 0, (*e == '.' ? 1 : szhint)); /* new table for field */ + lua_pushlstring(L, fname, e - fname); + lua_pushvalue(L, -2); + lua_settable(L, -4); /* set new table into field */ + } + else if (!lua_istable(L, -1)) { /* field has a non-table value? */ + lua_pop(L, 2); /* remove table and value */ + return fname; /* return problematic part of the name */ + } + lua_remove(L, -2); /* remove previous table */ + fname = e + 1; + } while (*e == '.'); + return NULL; +} + + + +/* +** {====================================================== +** Generic Buffer manipulation +** ======================================================= +*/ + + +#define bufflen(B) ((B)->p - (B)->buffer) +#define bufffree(B) ((size_t)(LUAL_BUFFERSIZE - bufflen(B))) + +#define LIMIT (LUA_MINSTACK/2) + + +static int emptybuffer (luaL_Buffer *B) { + size_t l = bufflen(B); + if (l == 0) return 0; /* put nothing on stack */ + else { + lua_pushlstring(B->L, B->buffer, l); + B->p = B->buffer; + B->lvl++; + return 1; + } +} + + +static void adjuststack (luaL_Buffer *B) { + if (B->lvl > 1) { + lua_State *L = B->L; + int toget = 1; /* number of levels to concat */ + size_t toplen = lua_strlen(L, -1); + do { + size_t l = lua_strlen(L, -(toget+1)); + if (B->lvl - toget + 1 >= LIMIT || toplen > l) { + toplen += l; + toget++; + } + else break; + } while (toget < B->lvl); + lua_concat(L, toget); + B->lvl = B->lvl - toget + 1; + } +} + + +LUALIB_API char *luaL_prepbuffer (luaL_Buffer *B) { + if (emptybuffer(B)) + adjuststack(B); + return B->buffer; +} + + +LUALIB_API void luaL_addlstring (luaL_Buffer *B, const char *s, size_t l) { + while (l--) + luaL_addchar(B, *s++); +} + + +LUALIB_API void luaL_addstring (luaL_Buffer *B, const char *s) { + luaL_addlstring(B, s, strlen(s)); +} + + +LUALIB_API void luaL_pushresult (luaL_Buffer *B) { + emptybuffer(B); + lua_concat(B->L, B->lvl); + B->lvl = 1; +} + + +LUALIB_API void luaL_addvalue (luaL_Buffer *B) { + lua_State *L = B->L; + size_t vl; + const char *s = lua_tolstring(L, -1, &vl); + if (vl <= bufffree(B)) { /* fit into buffer? */ + memcpy(B->p, s, vl); /* put it there */ + B->p += vl; + lua_pop(L, 1); /* remove from stack */ + } + else { + if (emptybuffer(B)) + lua_insert(L, -2); /* put buffer before new value */ + B->lvl++; /* add new value into B stack */ + adjuststack(B); + } +} + + +LUALIB_API void luaL_buffinit (lua_State *L, luaL_Buffer *B) { + B->L = L; + B->p = B->buffer; + B->lvl = 0; +} + +/* }====================================================== */ + + +LUALIB_API int luaL_ref (lua_State *L, int t) { + int ref; + t = abs_index(L, t); + if (lua_isnil(L, -1)) { + lua_pop(L, 1); /* remove from stack */ + return LUA_REFNIL; /* `nil' has a unique fixed reference */ + } + lua_rawgeti(L, t, FREELIST_REF); /* get first free element */ + ref = (int)lua_tointeger(L, -1); /* ref = t[FREELIST_REF] */ + lua_pop(L, 1); /* remove it from stack */ + if (ref != 0) { /* any free element? */ + lua_rawgeti(L, t, ref); /* remove it from list */ + lua_rawseti(L, t, FREELIST_REF); /* (t[FREELIST_REF] = t[ref]) */ + } + else { /* no free elements */ + ref = (int)lua_objlen(L, t); + ref++; /* create new reference */ + } + lua_rawseti(L, t, ref); + return ref; +} + + +LUALIB_API void luaL_unref (lua_State *L, int t, int ref) { + if (ref >= 0) { + t = abs_index(L, t); + lua_rawgeti(L, t, FREELIST_REF); + lua_rawseti(L, t, ref); /* t[ref] = t[FREELIST_REF] */ + lua_pushinteger(L, ref); + lua_rawseti(L, t, FREELIST_REF); /* t[FREELIST_REF] = ref */ + } +} + + + +/* +** {====================================================== +** Load functions +** ======================================================= +*/ + +typedef struct LoadF { + int extraline; + FILE *f; + char buff[LUAL_BUFFERSIZE]; +} LoadF; + + +static const char *getF (lua_State *L, void *ud, size_t *size) { + LoadF *lf = (LoadF *)ud; + (void)L; + if (lf->extraline) { + lf->extraline = 0; + *size = 1; + return "\n"; + } + if (feof(lf->f)) return NULL; + *size = fread(lf->buff, 1, sizeof(lf->buff), lf->f); + return (*size > 0) ? lf->buff : NULL; +} + + +static int errfile (lua_State *L, const char *what, int fnameindex) { + const char *serr = strerror(errno); + const char *filename = lua_tostring(L, fnameindex) + 1; + lua_pushfstring(L, "cannot %s %s: %s", what, filename, serr); + lua_remove(L, fnameindex); + return LUA_ERRFILE; +} + + +LUALIB_API int luaL_loadfile (lua_State *L, const char *filename) { + LoadF lf; + int status, readstatus; + int c; + int fnameindex = lua_gettop(L) + 1; /* index of filename on the stack */ + lf.extraline = 0; + if (filename == NULL) { + lua_pushliteral(L, "=stdin"); + lf.f = stdin; + } + else { + lua_pushfstring(L, "@%s", filename); + lf.f = fopen(filename, "r"); + if (lf.f == NULL) return errfile(L, "open", fnameindex); + } + c = getc(lf.f); + if (c == '#') { /* Unix exec. file? */ + lf.extraline = 1; + while ((c = getc(lf.f)) != EOF && c != '\n') ; /* skip first line */ + if (c == '\n') c = getc(lf.f); + } + if (c == LUA_SIGNATURE[0] && filename) { /* binary file? */ + lf.f = freopen(filename, "rb", lf.f); /* reopen in binary mode */ + if (lf.f == NULL) return errfile(L, "reopen", fnameindex); + /* skip eventual `#!...' */ + while ((c = getc(lf.f)) != EOF && c != LUA_SIGNATURE[0]) ; + lf.extraline = 0; + } + ungetc(c, lf.f); + status = lua_load(L, getF, &lf, lua_tostring(L, -1)); + readstatus = ferror(lf.f); + if (filename) fclose(lf.f); /* close file (even in case of errors) */ + if (readstatus) { + lua_settop(L, fnameindex); /* ignore results from `lua_load' */ + return errfile(L, "read", fnameindex); + } + lua_remove(L, fnameindex); + return status; +} + + +typedef struct LoadS { + const char *s; + size_t size; +} LoadS; + + +static const char *getS (lua_State *L, void *ud, size_t *size) { + LoadS *ls = (LoadS *)ud; + (void)L; + if (ls->size == 0) return NULL; + *size = ls->size; + ls->size = 0; + return ls->s; +} + + +LUALIB_API int luaL_loadbuffer (lua_State *L, const char *buff, size_t size, + const char *name) { + LoadS ls; + ls.s = buff; + ls.size = size; + return lua_load(L, getS, &ls, name); +} + + +LUALIB_API int (luaL_loadstring) (lua_State *L, const char *s) { + return luaL_loadbuffer(L, s, strlen(s), s); +} + + + +/* }====================================================== */ + + +static void *l_alloc (void *ud, void *ptr, size_t osize, size_t nsize) { + (void)ud; + (void)osize; + if (nsize == 0) { + free(ptr); + return NULL; + } + else + return realloc(ptr, nsize); +} + + +static int panic (lua_State *L) { + (void)L; /* to avoid warnings */ + fprintf(stderr, "PANIC: unprotected error in call to Lua API (%s)\n", + lua_tostring(L, -1)); + return 0; +} + + +LUALIB_API lua_State *luaL_newstate (void) { + lua_State *L = lua_newstate(l_alloc, NULL); + if (L) lua_atpanic(L, &panic); + return L; +} + diff --git a/lua/lauxlib.h b/lua/lauxlib.h new file mode 100644 index 0000000..3425823 --- /dev/null +++ b/lua/lauxlib.h @@ -0,0 +1,174 @@ +/* +** $Id: lauxlib.h,v 1.88.1.1 2007/12/27 13:02:25 roberto Exp $ +** Auxiliary functions for building Lua libraries +** See Copyright Notice in lua.h +*/ + + +#ifndef lauxlib_h +#define lauxlib_h + + +#include +#include + +#include "lua.h" + + +#if defined(LUA_COMPAT_GETN) +LUALIB_API int (luaL_getn) (lua_State *L, int t); +LUALIB_API void (luaL_setn) (lua_State *L, int t, int n); +#else +#define luaL_getn(L,i) ((int)lua_objlen(L, i)) +#define luaL_setn(L,i,j) ((void)0) /* no op! */ +#endif + +#if defined(LUA_COMPAT_OPENLIB) +#define luaI_openlib luaL_openlib +#endif + + +/* extra error code for `luaL_load' */ +#define LUA_ERRFILE (LUA_ERRERR+1) + + +typedef struct luaL_Reg { + const char *name; + lua_CFunction func; +} luaL_Reg; + + + +LUALIB_API void (luaI_openlib) (lua_State *L, const char *libname, + const luaL_Reg *l, int nup); +LUALIB_API void (luaL_register) (lua_State *L, const char *libname, + const luaL_Reg *l); +LUALIB_API int (luaL_getmetafield) (lua_State *L, int obj, const char *e); +LUALIB_API int (luaL_callmeta) (lua_State *L, int obj, const char *e); +LUALIB_API int (luaL_typerror) (lua_State *L, int narg, const char *tname); +LUALIB_API int (luaL_argerror) (lua_State *L, int numarg, const char *extramsg); +LUALIB_API const char *(luaL_checklstring) (lua_State *L, int numArg, + size_t *l); +LUALIB_API const char *(luaL_optlstring) (lua_State *L, int numArg, + const char *def, size_t *l); +LUALIB_API lua_Number (luaL_checknumber) (lua_State *L, int numArg); +LUALIB_API lua_Number (luaL_optnumber) (lua_State *L, int nArg, lua_Number def); + +LUALIB_API lua_Integer (luaL_checkinteger) (lua_State *L, int numArg); +LUALIB_API lua_Integer (luaL_optinteger) (lua_State *L, int nArg, + lua_Integer def); + +LUALIB_API void (luaL_checkstack) (lua_State *L, int sz, const char *msg); +LUALIB_API void (luaL_checktype) (lua_State *L, int narg, int t); +LUALIB_API void (luaL_checkany) (lua_State *L, int narg); + +LUALIB_API int (luaL_newmetatable) (lua_State *L, const char *tname); +LUALIB_API void *(luaL_checkudata) (lua_State *L, int ud, const char *tname); + +LUALIB_API void (luaL_where) (lua_State *L, int lvl); +LUALIB_API int (luaL_error) (lua_State *L, const char *fmt, ...); + +LUALIB_API int (luaL_checkoption) (lua_State *L, int narg, const char *def, + const char *const lst[]); + +LUALIB_API int (luaL_ref) (lua_State *L, int t); +LUALIB_API void (luaL_unref) (lua_State *L, int t, int ref); + +LUALIB_API int (luaL_loadfile) (lua_State *L, const char *filename); +LUALIB_API int (luaL_loadbuffer) (lua_State *L, const char *buff, size_t sz, + const char *name); +LUALIB_API int (luaL_loadstring) (lua_State *L, const char *s); + +LUALIB_API lua_State *(luaL_newstate) (void); + + +LUALIB_API const char *(luaL_gsub) (lua_State *L, const char *s, const char *p, + const char *r); + +LUALIB_API const char *(luaL_findtable) (lua_State *L, int idx, + const char *fname, int szhint); + + + + +/* +** =============================================================== +** some useful macros +** =============================================================== +*/ + +#define luaL_argcheck(L, cond,numarg,extramsg) \ + ((void)((cond) || luaL_argerror(L, (numarg), (extramsg)))) +#define luaL_checkstring(L,n) (luaL_checklstring(L, (n), NULL)) +#define luaL_optstring(L,n,d) (luaL_optlstring(L, (n), (d), NULL)) +#define luaL_checkint(L,n) ((int)luaL_checkinteger(L, (n))) +#define luaL_optint(L,n,d) ((int)luaL_optinteger(L, (n), (d))) +#define luaL_checklong(L,n) ((long)luaL_checkinteger(L, (n))) +#define luaL_optlong(L,n,d) ((long)luaL_optinteger(L, (n), (d))) + +#define luaL_typename(L,i) lua_typename(L, lua_type(L,(i))) + +#define luaL_dofile(L, fn) \ + (luaL_loadfile(L, fn) || lua_pcall(L, 0, LUA_MULTRET, 0)) + +#define luaL_dostring(L, s) \ + (luaL_loadstring(L, s) || lua_pcall(L, 0, LUA_MULTRET, 0)) + +#define luaL_getmetatable(L,n) (lua_getfield(L, LUA_REGISTRYINDEX, (n))) + +#define luaL_opt(L,f,n,d) (lua_isnoneornil(L,(n)) ? (d) : f(L,(n))) + +/* +** {====================================================== +** Generic Buffer manipulation +** ======================================================= +*/ + + + +typedef struct luaL_Buffer { + char *p; /* current position in buffer */ + int lvl; /* number of strings in the stack (level) */ + lua_State *L; + char buffer[LUAL_BUFFERSIZE]; +} luaL_Buffer; + +#define luaL_addchar(B,c) \ + ((void)((B)->p < ((B)->buffer+LUAL_BUFFERSIZE) || luaL_prepbuffer(B)), \ + (*(B)->p++ = (char)(c))) + +/* compatibility only */ +#define luaL_putchar(B,c) luaL_addchar(B,c) + +#define luaL_addsize(B,n) ((B)->p += (n)) + +LUALIB_API void (luaL_buffinit) (lua_State *L, luaL_Buffer *B); +LUALIB_API char *(luaL_prepbuffer) (luaL_Buffer *B); +LUALIB_API void (luaL_addlstring) (luaL_Buffer *B, const char *s, size_t l); +LUALIB_API void (luaL_addstring) (luaL_Buffer *B, const char *s); +LUALIB_API void (luaL_addvalue) (luaL_Buffer *B); +LUALIB_API void (luaL_pushresult) (luaL_Buffer *B); + + +/* }====================================================== */ + + +/* compatibility with ref system */ + +/* pre-defined references */ +#define LUA_NOREF (-2) +#define LUA_REFNIL (-1) + +#define lua_ref(L,lock) ((lock) ? luaL_ref(L, LUA_REGISTRYINDEX) : \ + (lua_pushstring(L, "unlocked references are obsolete"), lua_error(L), 0)) + +#define lua_unref(L,ref) luaL_unref(L, LUA_REGISTRYINDEX, (ref)) + +#define lua_getref(L,ref) lua_rawgeti(L, LUA_REGISTRYINDEX, (ref)) + + +#define luaL_reg luaL_Reg + +#endif + + diff --git a/lua/lbaselib.c b/lua/lbaselib.c new file mode 100644 index 0000000..2a4c079 --- /dev/null +++ b/lua/lbaselib.c @@ -0,0 +1,653 @@ +/* +** $Id: lbaselib.c,v 1.191.1.6 2008/02/14 16:46:22 roberto Exp $ +** Basic library +** See Copyright Notice in lua.h +*/ + + + +#include +#include +#include +#include + +#define lbaselib_c +#define LUA_LIB + +#include "lua.h" + +#include "lauxlib.h" +#include "lualib.h" + + + + +/* +** If your system does not support `stdout', you can just remove this function. +** If you need, you can define your own `print' function, following this +** model but changing `fputs' to put the strings at a proper place +** (a console window or a log file, for instance). +*/ +static int luaB_print (lua_State *L) { + int n = lua_gettop(L); /* number of arguments */ + int i; + lua_getglobal(L, "tostring"); + for (i=1; i<=n; i++) { + const char *s; + lua_pushvalue(L, -1); /* function to be called */ + lua_pushvalue(L, i); /* value to print */ + lua_call(L, 1, 1); + s = lua_tostring(L, -1); /* get result */ + if (s == NULL) + return luaL_error(L, LUA_QL("tostring") " must return a string to " + LUA_QL("print")); + if (i>1) fputs("\t", stdout); + fputs(s, stdout); + lua_pop(L, 1); /* pop result */ + } + fputs("\n", stdout); + return 0; +} + + +static int luaB_tonumber (lua_State *L) { + int base = luaL_optint(L, 2, 10); + if (base == 10) { /* standard conversion */ + luaL_checkany(L, 1); + if (lua_isnumber(L, 1)) { + lua_pushnumber(L, lua_tonumber(L, 1)); + return 1; + } + } + else { + const char *s1 = luaL_checkstring(L, 1); + char *s2; + unsigned long n; + luaL_argcheck(L, 2 <= base && base <= 36, 2, "base out of range"); + n = strtoul(s1, &s2, base); + if (s1 != s2) { /* at least one valid digit? */ + while (isspace((unsigned char)(*s2))) s2++; /* skip trailing spaces */ + if (*s2 == '\0') { /* no invalid trailing characters? */ + lua_pushnumber(L, (lua_Number)n); + return 1; + } + } + } + lua_pushnil(L); /* else not a number */ + return 1; +} + + +static int luaB_error (lua_State *L) { + int level = luaL_optint(L, 2, 1); + lua_settop(L, 1); + if (lua_isstring(L, 1) && level > 0) { /* add extra information? */ + luaL_where(L, level); + lua_pushvalue(L, 1); + lua_concat(L, 2); + } + return lua_error(L); +} + + +static int luaB_getmetatable (lua_State *L) { + luaL_checkany(L, 1); + if (!lua_getmetatable(L, 1)) { + lua_pushnil(L); + return 1; /* no metatable */ + } + luaL_getmetafield(L, 1, "__metatable"); + return 1; /* returns either __metatable field (if present) or metatable */ +} + + +static int luaB_setmetatable (lua_State *L) { + int t = lua_type(L, 2); + luaL_checktype(L, 1, LUA_TTABLE); + luaL_argcheck(L, t == LUA_TNIL || t == LUA_TTABLE, 2, + "nil or table expected"); + if (luaL_getmetafield(L, 1, "__metatable")) + luaL_error(L, "cannot change a protected metatable"); + lua_settop(L, 2); + lua_setmetatable(L, 1); + return 1; +} + + +static void getfunc (lua_State *L, int opt) { + if (lua_isfunction(L, 1)) lua_pushvalue(L, 1); + else { + lua_Debug ar; + int level = opt ? luaL_optint(L, 1, 1) : luaL_checkint(L, 1); + luaL_argcheck(L, level >= 0, 1, "level must be non-negative"); + if (lua_getstack(L, level, &ar) == 0) + luaL_argerror(L, 1, "invalid level"); + lua_getinfo(L, "f", &ar); + if (lua_isnil(L, -1)) + luaL_error(L, "no function environment for tail call at level %d", + level); + } +} + + +static int luaB_getfenv (lua_State *L) { + getfunc(L, 1); + if (lua_iscfunction(L, -1)) /* is a C function? */ + lua_pushvalue(L, LUA_GLOBALSINDEX); /* return the thread's global env. */ + else + lua_getfenv(L, -1); + return 1; +} + + +static int luaB_setfenv (lua_State *L) { + luaL_checktype(L, 2, LUA_TTABLE); + getfunc(L, 0); + lua_pushvalue(L, 2); + if (lua_isnumber(L, 1) && lua_tonumber(L, 1) == 0) { + /* change environment of current thread */ + lua_pushthread(L); + lua_insert(L, -2); + lua_setfenv(L, -2); + return 0; + } + else if (lua_iscfunction(L, -2) || lua_setfenv(L, -2) == 0) + luaL_error(L, + LUA_QL("setfenv") " cannot change environment of given object"); + return 1; +} + + +static int luaB_rawequal (lua_State *L) { + luaL_checkany(L, 1); + luaL_checkany(L, 2); + lua_pushboolean(L, lua_rawequal(L, 1, 2)); + return 1; +} + + +static int luaB_rawget (lua_State *L) { + luaL_checktype(L, 1, LUA_TTABLE); + luaL_checkany(L, 2); + lua_settop(L, 2); + lua_rawget(L, 1); + return 1; +} + +static int luaB_rawset (lua_State *L) { + luaL_checktype(L, 1, LUA_TTABLE); + luaL_checkany(L, 2); + luaL_checkany(L, 3); + lua_settop(L, 3); + lua_rawset(L, 1); + return 1; +} + + +static int luaB_gcinfo (lua_State *L) { + lua_pushinteger(L, lua_getgccount(L)); + return 1; +} + + +static int luaB_collectgarbage (lua_State *L) { + static const char *const opts[] = {"stop", "restart", "collect", + "count", "step", "setpause", "setstepmul", NULL}; + static const int optsnum[] = {LUA_GCSTOP, LUA_GCRESTART, LUA_GCCOLLECT, + LUA_GCCOUNT, LUA_GCSTEP, LUA_GCSETPAUSE, LUA_GCSETSTEPMUL}; + int o = luaL_checkoption(L, 1, "collect", opts); + int ex = luaL_optint(L, 2, 0); + int res = lua_gc(L, optsnum[o], ex); + switch (optsnum[o]) { + case LUA_GCCOUNT: { + int b = lua_gc(L, LUA_GCCOUNTB, 0); + lua_pushnumber(L, res + ((lua_Number)b/1024)); + return 1; + } + case LUA_GCSTEP: { + lua_pushboolean(L, res); + return 1; + } + default: { + lua_pushnumber(L, res); + return 1; + } + } +} + + +static int luaB_type (lua_State *L) { + luaL_checkany(L, 1); + lua_pushstring(L, luaL_typename(L, 1)); + return 1; +} + + +static int luaB_next (lua_State *L) { + luaL_checktype(L, 1, LUA_TTABLE); + lua_settop(L, 2); /* create a 2nd argument if there isn't one */ + if (lua_next(L, 1)) + return 2; + else { + lua_pushnil(L); + return 1; + } +} + + +static int luaB_pairs (lua_State *L) { + luaL_checktype(L, 1, LUA_TTABLE); + lua_pushvalue(L, lua_upvalueindex(1)); /* return generator, */ + lua_pushvalue(L, 1); /* state, */ + lua_pushnil(L); /* and initial value */ + return 3; +} + + +static int ipairsaux (lua_State *L) { + int i = luaL_checkint(L, 2); + luaL_checktype(L, 1, LUA_TTABLE); + i++; /* next value */ + lua_pushinteger(L, i); + lua_rawgeti(L, 1, i); + return (lua_isnil(L, -1)) ? 0 : 2; +} + + +static int luaB_ipairs (lua_State *L) { + luaL_checktype(L, 1, LUA_TTABLE); + lua_pushvalue(L, lua_upvalueindex(1)); /* return generator, */ + lua_pushvalue(L, 1); /* state, */ + lua_pushinteger(L, 0); /* and initial value */ + return 3; +} + + +static int load_aux (lua_State *L, int status) { + if (status == 0) /* OK? */ + return 1; + else { + lua_pushnil(L); + lua_insert(L, -2); /* put before error message */ + return 2; /* return nil plus error message */ + } +} + + +static int luaB_loadstring (lua_State *L) { + size_t l; + const char *s = luaL_checklstring(L, 1, &l); + const char *chunkname = luaL_optstring(L, 2, s); + return load_aux(L, luaL_loadbuffer(L, s, l, chunkname)); +} + + +static int luaB_loadfile (lua_State *L) { + const char *fname = luaL_optstring(L, 1, NULL); + return load_aux(L, luaL_loadfile(L, fname)); +} + + +/* +** Reader for generic `load' function: `lua_load' uses the +** stack for internal stuff, so the reader cannot change the +** stack top. Instead, it keeps its resulting string in a +** reserved slot inside the stack. +*/ +static const char *generic_reader (lua_State *L, void *ud, size_t *size) { + (void)ud; /* to avoid warnings */ + luaL_checkstack(L, 2, "too many nested functions"); + lua_pushvalue(L, 1); /* get function */ + lua_call(L, 0, 1); /* call it */ + if (lua_isnil(L, -1)) { + *size = 0; + return NULL; + } + else if (lua_isstring(L, -1)) { + lua_replace(L, 3); /* save string in a reserved stack slot */ + return lua_tolstring(L, 3, size); + } + else luaL_error(L, "reader function must return a string"); + return NULL; /* to avoid warnings */ +} + + +static int luaB_load (lua_State *L) { + int status; + const char *cname = luaL_optstring(L, 2, "=(load)"); + luaL_checktype(L, 1, LUA_TFUNCTION); + lua_settop(L, 3); /* function, eventual name, plus one reserved slot */ + status = lua_load(L, generic_reader, NULL, cname); + return load_aux(L, status); +} + + +static int luaB_dofile (lua_State *L) { + const char *fname = luaL_optstring(L, 1, NULL); + int n = lua_gettop(L); + if (luaL_loadfile(L, fname) != 0) lua_error(L); + lua_call(L, 0, LUA_MULTRET); + return lua_gettop(L) - n; +} + + +static int luaB_assert (lua_State *L) { + luaL_checkany(L, 1); + if (!lua_toboolean(L, 1)) + return luaL_error(L, "%s", luaL_optstring(L, 2, "assertion failed!")); + return lua_gettop(L); +} + + +static int luaB_unpack (lua_State *L) { + int i, e, n; + luaL_checktype(L, 1, LUA_TTABLE); + i = luaL_optint(L, 2, 1); + e = luaL_opt(L, luaL_checkint, 3, luaL_getn(L, 1)); + if (i > e) return 0; /* empty range */ + n = e - i + 1; /* number of elements */ + if (n <= 0 || !lua_checkstack(L, n)) /* n <= 0 means arith. overflow */ + return luaL_error(L, "too many results to unpack"); + lua_rawgeti(L, 1, i); /* push arg[i] (avoiding overflow problems) */ + while (i++ < e) /* push arg[i + 1...e] */ + lua_rawgeti(L, 1, i); + return n; +} + + +static int luaB_select (lua_State *L) { + int n = lua_gettop(L); + if (lua_type(L, 1) == LUA_TSTRING && *lua_tostring(L, 1) == '#') { + lua_pushinteger(L, n-1); + return 1; + } + else { + int i = luaL_checkint(L, 1); + if (i < 0) i = n + i; + else if (i > n) i = n; + luaL_argcheck(L, 1 <= i, 1, "index out of range"); + return n - i; + } +} + + +static int luaB_pcall (lua_State *L) { + int status; + luaL_checkany(L, 1); + status = lua_pcall(L, lua_gettop(L) - 1, LUA_MULTRET, 0); + lua_pushboolean(L, (status == 0)); + lua_insert(L, 1); + return lua_gettop(L); /* return status + all results */ +} + + +static int luaB_xpcall (lua_State *L) { + int status; + luaL_checkany(L, 2); + lua_settop(L, 2); + lua_insert(L, 1); /* put error function under function to be called */ + status = lua_pcall(L, 0, LUA_MULTRET, 1); + lua_pushboolean(L, (status == 0)); + lua_replace(L, 1); + return lua_gettop(L); /* return status + all results */ +} + + +static int luaB_tostring (lua_State *L) { + luaL_checkany(L, 1); + if (luaL_callmeta(L, 1, "__tostring")) /* is there a metafield? */ + return 1; /* use its value */ + switch (lua_type(L, 1)) { + case LUA_TNUMBER: + lua_pushstring(L, lua_tostring(L, 1)); + break; + case LUA_TSTRING: + lua_pushvalue(L, 1); + break; + case LUA_TBOOLEAN: + lua_pushstring(L, (lua_toboolean(L, 1) ? "true" : "false")); + break; + case LUA_TNIL: + lua_pushliteral(L, "nil"); + break; + default: + lua_pushfstring(L, "%s: %p", luaL_typename(L, 1), lua_topointer(L, 1)); + break; + } + return 1; +} + + +static int luaB_newproxy (lua_State *L) { + lua_settop(L, 1); + lua_newuserdata(L, 0); /* create proxy */ + if (lua_toboolean(L, 1) == 0) + return 1; /* no metatable */ + else if (lua_isboolean(L, 1)) { + lua_newtable(L); /* create a new metatable `m' ... */ + lua_pushvalue(L, -1); /* ... and mark `m' as a valid metatable */ + lua_pushboolean(L, 1); + lua_rawset(L, lua_upvalueindex(1)); /* weaktable[m] = true */ + } + else { + int validproxy = 0; /* to check if weaktable[metatable(u)] == true */ + if (lua_getmetatable(L, 1)) { + lua_rawget(L, lua_upvalueindex(1)); + validproxy = lua_toboolean(L, -1); + lua_pop(L, 1); /* remove value */ + } + luaL_argcheck(L, validproxy, 1, "boolean or proxy expected"); + lua_getmetatable(L, 1); /* metatable is valid; get it */ + } + lua_setmetatable(L, 2); + return 1; +} + + +static const luaL_Reg base_funcs[] = { + {"assert", luaB_assert}, + {"collectgarbage", luaB_collectgarbage}, + {"dofile", luaB_dofile}, + {"error", luaB_error}, + {"gcinfo", luaB_gcinfo}, + {"getfenv", luaB_getfenv}, + {"getmetatable", luaB_getmetatable}, + {"loadfile", luaB_loadfile}, + {"load", luaB_load}, + {"loadstring", luaB_loadstring}, + {"next", luaB_next}, + {"pcall", luaB_pcall}, + {"print", luaB_print}, + {"rawequal", luaB_rawequal}, + {"rawget", luaB_rawget}, + {"rawset", luaB_rawset}, + {"select", luaB_select}, + {"setfenv", luaB_setfenv}, + {"setmetatable", luaB_setmetatable}, + {"tonumber", luaB_tonumber}, + {"tostring", luaB_tostring}, + {"type", luaB_type}, + {"unpack", luaB_unpack}, + {"xpcall", luaB_xpcall}, + {NULL, NULL} +}; + + +/* +** {====================================================== +** Coroutine library +** ======================================================= +*/ + +#define CO_RUN 0 /* running */ +#define CO_SUS 1 /* suspended */ +#define CO_NOR 2 /* 'normal' (it resumed another coroutine) */ +#define CO_DEAD 3 + +static const char *const statnames[] = + {"running", "suspended", "normal", "dead"}; + +static int costatus (lua_State *L, lua_State *co) { + if (L == co) return CO_RUN; + switch (lua_status(co)) { + case LUA_YIELD: + return CO_SUS; + case 0: { + lua_Debug ar; + if (lua_getstack(co, 0, &ar) > 0) /* does it have frames? */ + return CO_NOR; /* it is running */ + else if (lua_gettop(co) == 0) + return CO_DEAD; + else + return CO_SUS; /* initial state */ + } + default: /* some error occured */ + return CO_DEAD; + } +} + + +static int luaB_costatus (lua_State *L) { + lua_State *co = lua_tothread(L, 1); + luaL_argcheck(L, co, 1, "coroutine expected"); + lua_pushstring(L, statnames[costatus(L, co)]); + return 1; +} + + +static int auxresume (lua_State *L, lua_State *co, int narg) { + int status = costatus(L, co); + if (!lua_checkstack(co, narg)) + luaL_error(L, "too many arguments to resume"); + if (status != CO_SUS) { + lua_pushfstring(L, "cannot resume %s coroutine", statnames[status]); + return -1; /* error flag */ + } + lua_xmove(L, co, narg); + lua_setlevel(L, co); + status = lua_resume(co, narg); + if (status == 0 || status == LUA_YIELD) { + int nres = lua_gettop(co); + if (!lua_checkstack(L, nres + 1)) + luaL_error(L, "too many results to resume"); + lua_xmove(co, L, nres); /* move yielded values */ + return nres; + } + else { + lua_xmove(co, L, 1); /* move error message */ + return -1; /* error flag */ + } +} + + +static int luaB_coresume (lua_State *L) { + lua_State *co = lua_tothread(L, 1); + int r; + luaL_argcheck(L, co, 1, "coroutine expected"); + r = auxresume(L, co, lua_gettop(L) - 1); + if (r < 0) { + lua_pushboolean(L, 0); + lua_insert(L, -2); + return 2; /* return false + error message */ + } + else { + lua_pushboolean(L, 1); + lua_insert(L, -(r + 1)); + return r + 1; /* return true + `resume' returns */ + } +} + + +static int luaB_auxwrap (lua_State *L) { + lua_State *co = lua_tothread(L, lua_upvalueindex(1)); + int r = auxresume(L, co, lua_gettop(L)); + if (r < 0) { + if (lua_isstring(L, -1)) { /* error object is a string? */ + luaL_where(L, 1); /* add extra info */ + lua_insert(L, -2); + lua_concat(L, 2); + } + lua_error(L); /* propagate error */ + } + return r; +} + + +static int luaB_cocreate (lua_State *L) { + lua_State *NL = lua_newthread(L); + luaL_argcheck(L, lua_isfunction(L, 1) && !lua_iscfunction(L, 1), 1, + "Lua function expected"); + lua_pushvalue(L, 1); /* move function to top */ + lua_xmove(L, NL, 1); /* move function from L to NL */ + return 1; +} + + +static int luaB_cowrap (lua_State *L) { + luaB_cocreate(L); + lua_pushcclosure(L, luaB_auxwrap, 1); + return 1; +} + + +static int luaB_yield (lua_State *L) { + return lua_yield(L, lua_gettop(L)); +} + + +static int luaB_corunning (lua_State *L) { + if (lua_pushthread(L)) + lua_pushnil(L); /* main thread is not a coroutine */ + return 1; +} + + +static const luaL_Reg co_funcs[] = { + {"create", luaB_cocreate}, + {"resume", luaB_coresume}, + {"running", luaB_corunning}, + {"status", luaB_costatus}, + {"wrap", luaB_cowrap}, + {"yield", luaB_yield}, + {NULL, NULL} +}; + +/* }====================================================== */ + + +static void auxopen (lua_State *L, const char *name, + lua_CFunction f, lua_CFunction u) { + lua_pushcfunction(L, u); + lua_pushcclosure(L, f, 1); + lua_setfield(L, -2, name); +} + + +static void base_open (lua_State *L) { + /* set global _G */ + lua_pushvalue(L, LUA_GLOBALSINDEX); + lua_setglobal(L, "_G"); + /* open lib into global table */ + luaL_register(L, "_G", base_funcs); + lua_pushliteral(L, LUA_VERSION); + lua_setglobal(L, "_VERSION"); /* set global _VERSION */ + /* `ipairs' and `pairs' need auxliliary functions as upvalues */ + auxopen(L, "ipairs", luaB_ipairs, ipairsaux); + auxopen(L, "pairs", luaB_pairs, luaB_next); + /* `newproxy' needs a weaktable as upvalue */ + lua_createtable(L, 0, 1); /* new table `w' */ + lua_pushvalue(L, -1); /* `w' will be its own metatable */ + lua_setmetatable(L, -2); + lua_pushliteral(L, "kv"); + lua_setfield(L, -2, "__mode"); /* metatable(w).__mode = "kv" */ + lua_pushcclosure(L, luaB_newproxy, 1); + lua_setglobal(L, "newproxy"); /* set global `newproxy' */ +} + + +LUALIB_API int luaopen_base (lua_State *L) { + base_open(L); + luaL_register(L, LUA_COLIBNAME, co_funcs); + return 2; +} + diff --git a/lua/lcode.c b/lua/lcode.c new file mode 100644 index 0000000..cff626b --- /dev/null +++ b/lua/lcode.c @@ -0,0 +1,839 @@ +/* +** $Id: lcode.c,v 2.25.1.3 2007/12/28 15:32:23 roberto Exp $ +** Code generator for Lua +** See Copyright Notice in lua.h +*/ + + +#include + +#define lcode_c +#define LUA_CORE + +#include "lua.h" + +#include "lcode.h" +#include "ldebug.h" +#include "ldo.h" +#include "lgc.h" +#include "llex.h" +#include "lmem.h" +#include "lobject.h" +#include "lopcodes.h" +#include "lparser.h" +#include "ltable.h" + + +#define hasjumps(e) ((e)->t != (e)->f) + + +static int isnumeral(expdesc *e) { + return (e->k == VKNUM && e->t == NO_JUMP && e->f == NO_JUMP); +} + + +void luaK_nil (FuncState *fs, int from, int n) { + Instruction *previous; + if (fs->pc > fs->lasttarget) { /* no jumps to current position? */ + if (fs->pc == 0) { /* function start? */ + if (from >= fs->nactvar) + return; /* positions are already clean */ + } + else { + previous = &fs->f->code[fs->pc-1]; + if (GET_OPCODE(*previous) == OP_LOADNIL) { + int pfrom = GETARG_A(*previous); + int pto = GETARG_B(*previous); + if (pfrom <= from && from <= pto+1) { /* can connect both? */ + if (from+n-1 > pto) + SETARG_B(*previous, from+n-1); + return; + } + } + } + } + luaK_codeABC(fs, OP_LOADNIL, from, from+n-1, 0); /* else no optimization */ +} + + +int luaK_jump (FuncState *fs) { + int jpc = fs->jpc; /* save list of jumps to here */ + int j; + fs->jpc = NO_JUMP; + j = luaK_codeAsBx(fs, OP_JMP, 0, NO_JUMP); + luaK_concat(fs, &j, jpc); /* keep them on hold */ + return j; +} + + +void luaK_ret (FuncState *fs, int first, int nret) { + luaK_codeABC(fs, OP_RETURN, first, nret+1, 0); +} + + +static int condjump (FuncState *fs, OpCode op, int A, int B, int C) { + luaK_codeABC(fs, op, A, B, C); + return luaK_jump(fs); +} + + +static void fixjump (FuncState *fs, int pc, int dest) { + Instruction *jmp = &fs->f->code[pc]; + int offset = dest-(pc+1); + lua_assert(dest != NO_JUMP); + if (abs(offset) > MAXARG_sBx) + luaX_syntaxerror(fs->ls, "control structure too long"); + SETARG_sBx(*jmp, offset); +} + + +/* +** returns current `pc' and marks it as a jump target (to avoid wrong +** optimizations with consecutive instructions not in the same basic block). +*/ +int luaK_getlabel (FuncState *fs) { + fs->lasttarget = fs->pc; + return fs->pc; +} + + +static int getjump (FuncState *fs, int pc) { + int offset = GETARG_sBx(fs->f->code[pc]); + if (offset == NO_JUMP) /* point to itself represents end of list */ + return NO_JUMP; /* end of list */ + else + return (pc+1)+offset; /* turn offset into absolute position */ +} + + +static Instruction *getjumpcontrol (FuncState *fs, int pc) { + Instruction *pi = &fs->f->code[pc]; + if (pc >= 1 && testTMode(GET_OPCODE(*(pi-1)))) + return pi-1; + else + return pi; +} + + +/* +** check whether list has any jump that do not produce a value +** (or produce an inverted value) +*/ +static int need_value (FuncState *fs, int list) { + for (; list != NO_JUMP; list = getjump(fs, list)) { + Instruction i = *getjumpcontrol(fs, list); + if (GET_OPCODE(i) != OP_TESTSET) return 1; + } + return 0; /* not found */ +} + + +static int patchtestreg (FuncState *fs, int node, int reg) { + Instruction *i = getjumpcontrol(fs, node); + if (GET_OPCODE(*i) != OP_TESTSET) + return 0; /* cannot patch other instructions */ + if (reg != NO_REG && reg != GETARG_B(*i)) + SETARG_A(*i, reg); + else /* no register to put value or register already has the value */ + *i = CREATE_ABC(OP_TEST, GETARG_B(*i), 0, GETARG_C(*i)); + + return 1; +} + + +static void removevalues (FuncState *fs, int list) { + for (; list != NO_JUMP; list = getjump(fs, list)) + patchtestreg(fs, list, NO_REG); +} + + +static void patchlistaux (FuncState *fs, int list, int vtarget, int reg, + int dtarget) { + while (list != NO_JUMP) { + int next = getjump(fs, list); + if (patchtestreg(fs, list, reg)) + fixjump(fs, list, vtarget); + else + fixjump(fs, list, dtarget); /* jump to default target */ + list = next; + } +} + + +static void dischargejpc (FuncState *fs) { + patchlistaux(fs, fs->jpc, fs->pc, NO_REG, fs->pc); + fs->jpc = NO_JUMP; +} + + +void luaK_patchlist (FuncState *fs, int list, int target) { + if (target == fs->pc) + luaK_patchtohere(fs, list); + else { + lua_assert(target < fs->pc); + patchlistaux(fs, list, target, NO_REG, target); + } +} + + +void luaK_patchtohere (FuncState *fs, int list) { + luaK_getlabel(fs); + luaK_concat(fs, &fs->jpc, list); +} + + +void luaK_concat (FuncState *fs, int *l1, int l2) { + if (l2 == NO_JUMP) return; + else if (*l1 == NO_JUMP) + *l1 = l2; + else { + int list = *l1; + int next; + while ((next = getjump(fs, list)) != NO_JUMP) /* find last element */ + list = next; + fixjump(fs, list, l2); + } +} + + +void luaK_checkstack (FuncState *fs, int n) { + int newstack = fs->freereg + n; + if (newstack > fs->f->maxstacksize) { + if (newstack >= MAXSTACK) + luaX_syntaxerror(fs->ls, "function or expression too complex"); + fs->f->maxstacksize = cast_byte(newstack); + } +} + + +void luaK_reserveregs (FuncState *fs, int n) { + luaK_checkstack(fs, n); + fs->freereg += n; +} + + +static void freereg (FuncState *fs, int reg) { + if (!ISK(reg) && reg >= fs->nactvar) { + fs->freereg--; + lua_assert(reg == fs->freereg); + } +} + + +static void freeexp (FuncState *fs, expdesc *e) { + if (e->k == VNONRELOC) + freereg(fs, e->u.s.info); +} + + +static int addk (FuncState *fs, TValue *k, TValue *v) { + lua_State *L = fs->L; + TValue *idx = luaH_set(L, fs->h, k); + Proto *f = fs->f; + int oldsize = f->sizek; + if (ttisnumber(idx)) { + lua_assert(luaO_rawequalObj(&fs->f->k[cast_int(nvalue(idx))], v)); + return cast_int(nvalue(idx)); + } + else { /* constant not found; create a new entry */ + setnvalue(idx, cast_num(fs->nk)); + luaM_growvector(L, f->k, fs->nk, f->sizek, TValue, + MAXARG_Bx, "constant table overflow"); + while (oldsize < f->sizek) setnilvalue(&f->k[oldsize++]); + setobj(L, &f->k[fs->nk], v); + luaC_barrier(L, f, v); + return fs->nk++; + } +} + + +int luaK_stringK (FuncState *fs, TString *s) { + TValue o; + setsvalue(fs->L, &o, s); + return addk(fs, &o, &o); +} + + +int luaK_numberK (FuncState *fs, lua_Number r) { + TValue o; + setnvalue(&o, r); + return addk(fs, &o, &o); +} + + +static int boolK (FuncState *fs, int b) { + TValue o; + setbvalue(&o, b); + return addk(fs, &o, &o); +} + + +static int nilK (FuncState *fs) { + TValue k, v; + setnilvalue(&v); + /* cannot use nil as key; instead use table itself to represent nil */ + sethvalue(fs->L, &k, fs->h); + return addk(fs, &k, &v); +} + + +void luaK_setreturns (FuncState *fs, expdesc *e, int nresults) { + if (e->k == VCALL) { /* expression is an open function call? */ + SETARG_C(getcode(fs, e), nresults+1); + } + else if (e->k == VVARARG) { + SETARG_B(getcode(fs, e), nresults+1); + SETARG_A(getcode(fs, e), fs->freereg); + luaK_reserveregs(fs, 1); + } +} + + +void luaK_setoneret (FuncState *fs, expdesc *e) { + if (e->k == VCALL) { /* expression is an open function call? */ + e->k = VNONRELOC; + e->u.s.info = GETARG_A(getcode(fs, e)); + } + else if (e->k == VVARARG) { + SETARG_B(getcode(fs, e), 2); + e->k = VRELOCABLE; /* can relocate its simple result */ + } +} + + +void luaK_dischargevars (FuncState *fs, expdesc *e) { + switch (e->k) { + case VLOCAL: { + e->k = VNONRELOC; + break; + } + case VUPVAL: { + e->u.s.info = luaK_codeABC(fs, OP_GETUPVAL, 0, e->u.s.info, 0); + e->k = VRELOCABLE; + break; + } + case VGLOBAL: { + e->u.s.info = luaK_codeABx(fs, OP_GETGLOBAL, 0, e->u.s.info); + e->k = VRELOCABLE; + break; + } + case VINDEXED: { + freereg(fs, e->u.s.aux); + freereg(fs, e->u.s.info); + e->u.s.info = luaK_codeABC(fs, OP_GETTABLE, 0, e->u.s.info, e->u.s.aux); + e->k = VRELOCABLE; + break; + } + case VVARARG: + case VCALL: { + luaK_setoneret(fs, e); + break; + } + default: break; /* there is one value available (somewhere) */ + } +} + + +static int code_label (FuncState *fs, int A, int b, int jump) { + luaK_getlabel(fs); /* those instructions may be jump targets */ + return luaK_codeABC(fs, OP_LOADBOOL, A, b, jump); +} + + +static void discharge2reg (FuncState *fs, expdesc *e, int reg) { + luaK_dischargevars(fs, e); + switch (e->k) { + case VNIL: { + luaK_nil(fs, reg, 1); + break; + } + case VFALSE: case VTRUE: { + luaK_codeABC(fs, OP_LOADBOOL, reg, e->k == VTRUE, 0); + break; + } + case VK: { + luaK_codeABx(fs, OP_LOADK, reg, e->u.s.info); + break; + } + case VKNUM: { + luaK_codeABx(fs, OP_LOADK, reg, luaK_numberK(fs, e->u.nval)); + break; + } + case VRELOCABLE: { + Instruction *pc = &getcode(fs, e); + SETARG_A(*pc, reg); + break; + } + case VNONRELOC: { + if (reg != e->u.s.info) + luaK_codeABC(fs, OP_MOVE, reg, e->u.s.info, 0); + break; + } + default: { + lua_assert(e->k == VVOID || e->k == VJMP); + return; /* nothing to do... */ + } + } + e->u.s.info = reg; + e->k = VNONRELOC; +} + + +static void discharge2anyreg (FuncState *fs, expdesc *e) { + if (e->k != VNONRELOC) { + luaK_reserveregs(fs, 1); + discharge2reg(fs, e, fs->freereg-1); + } +} + + +static void exp2reg (FuncState *fs, expdesc *e, int reg) { + discharge2reg(fs, e, reg); + if (e->k == VJMP) + luaK_concat(fs, &e->t, e->u.s.info); /* put this jump in `t' list */ + if (hasjumps(e)) { + int final; /* position after whole expression */ + int p_f = NO_JUMP; /* position of an eventual LOAD false */ + int p_t = NO_JUMP; /* position of an eventual LOAD true */ + if (need_value(fs, e->t) || need_value(fs, e->f)) { + int fj = (e->k == VJMP) ? NO_JUMP : luaK_jump(fs); + p_f = code_label(fs, reg, 0, 1); + p_t = code_label(fs, reg, 1, 0); + luaK_patchtohere(fs, fj); + } + final = luaK_getlabel(fs); + patchlistaux(fs, e->f, final, reg, p_f); + patchlistaux(fs, e->t, final, reg, p_t); + } + e->f = e->t = NO_JUMP; + e->u.s.info = reg; + e->k = VNONRELOC; +} + + +void luaK_exp2nextreg (FuncState *fs, expdesc *e) { + luaK_dischargevars(fs, e); + freeexp(fs, e); + luaK_reserveregs(fs, 1); + exp2reg(fs, e, fs->freereg - 1); +} + + +int luaK_exp2anyreg (FuncState *fs, expdesc *e) { + luaK_dischargevars(fs, e); + if (e->k == VNONRELOC) { + if (!hasjumps(e)) return e->u.s.info; /* exp is already in a register */ + if (e->u.s.info >= fs->nactvar) { /* reg. is not a local? */ + exp2reg(fs, e, e->u.s.info); /* put value on it */ + return e->u.s.info; + } + } + luaK_exp2nextreg(fs, e); /* default */ + return e->u.s.info; +} + + +void luaK_exp2val (FuncState *fs, expdesc *e) { + if (hasjumps(e)) + luaK_exp2anyreg(fs, e); + else + luaK_dischargevars(fs, e); +} + + +int luaK_exp2RK (FuncState *fs, expdesc *e) { + luaK_exp2val(fs, e); + switch (e->k) { + case VKNUM: + case VTRUE: + case VFALSE: + case VNIL: { + if (fs->nk <= MAXINDEXRK) { /* constant fit in RK operand? */ + e->u.s.info = (e->k == VNIL) ? nilK(fs) : + (e->k == VKNUM) ? luaK_numberK(fs, e->u.nval) : + boolK(fs, (e->k == VTRUE)); + e->k = VK; + return RKASK(e->u.s.info); + } + else break; + } + case VK: { + if (e->u.s.info <= MAXINDEXRK) /* constant fit in argC? */ + return RKASK(e->u.s.info); + else break; + } + default: break; + } + /* not a constant in the right range: put it in a register */ + return luaK_exp2anyreg(fs, e); +} + + +void luaK_storevar (FuncState *fs, expdesc *var, expdesc *ex) { + switch (var->k) { + case VLOCAL: { + freeexp(fs, ex); + exp2reg(fs, ex, var->u.s.info); + return; + } + case VUPVAL: { + int e = luaK_exp2anyreg(fs, ex); + luaK_codeABC(fs, OP_SETUPVAL, e, var->u.s.info, 0); + break; + } + case VGLOBAL: { + int e = luaK_exp2anyreg(fs, ex); + luaK_codeABx(fs, OP_SETGLOBAL, e, var->u.s.info); + break; + } + case VINDEXED: { + int e = luaK_exp2RK(fs, ex); + luaK_codeABC(fs, OP_SETTABLE, var->u.s.info, var->u.s.aux, e); + break; + } + default: { + lua_assert(0); /* invalid var kind to store */ + break; + } + } + freeexp(fs, ex); +} + + +void luaK_self (FuncState *fs, expdesc *e, expdesc *key) { + int func; + luaK_exp2anyreg(fs, e); + freeexp(fs, e); + func = fs->freereg; + luaK_reserveregs(fs, 2); + luaK_codeABC(fs, OP_SELF, func, e->u.s.info, luaK_exp2RK(fs, key)); + freeexp(fs, key); + e->u.s.info = func; + e->k = VNONRELOC; +} + + +static void invertjump (FuncState *fs, expdesc *e) { + Instruction *pc = getjumpcontrol(fs, e->u.s.info); + lua_assert(testTMode(GET_OPCODE(*pc)) && GET_OPCODE(*pc) != OP_TESTSET && + GET_OPCODE(*pc) != OP_TEST); + SETARG_A(*pc, !(GETARG_A(*pc))); +} + + +static int jumponcond (FuncState *fs, expdesc *e, int cond) { + if (e->k == VRELOCABLE) { + Instruction ie = getcode(fs, e); + if (GET_OPCODE(ie) == OP_NOT) { + fs->pc--; /* remove previous OP_NOT */ + return condjump(fs, OP_TEST, GETARG_B(ie), 0, !cond); + } + /* else go through */ + } + discharge2anyreg(fs, e); + freeexp(fs, e); + return condjump(fs, OP_TESTSET, NO_REG, e->u.s.info, cond); +} + + +void luaK_goiftrue (FuncState *fs, expdesc *e) { + int pc; /* pc of last jump */ + luaK_dischargevars(fs, e); + switch (e->k) { + case VK: case VKNUM: case VTRUE: { + pc = NO_JUMP; /* always true; do nothing */ + break; + } + case VFALSE: { + pc = luaK_jump(fs); /* always jump */ + break; + } + case VJMP: { + invertjump(fs, e); + pc = e->u.s.info; + break; + } + default: { + pc = jumponcond(fs, e, 0); + break; + } + } + luaK_concat(fs, &e->f, pc); /* insert last jump in `f' list */ + luaK_patchtohere(fs, e->t); + e->t = NO_JUMP; +} + + +static void luaK_goiffalse (FuncState *fs, expdesc *e) { + int pc; /* pc of last jump */ + luaK_dischargevars(fs, e); + switch (e->k) { + case VNIL: case VFALSE: { + pc = NO_JUMP; /* always false; do nothing */ + break; + } + case VTRUE: { + pc = luaK_jump(fs); /* always jump */ + break; + } + case VJMP: { + pc = e->u.s.info; + break; + } + default: { + pc = jumponcond(fs, e, 1); + break; + } + } + luaK_concat(fs, &e->t, pc); /* insert last jump in `t' list */ + luaK_patchtohere(fs, e->f); + e->f = NO_JUMP; +} + + +static void codenot (FuncState *fs, expdesc *e) { + luaK_dischargevars(fs, e); + switch (e->k) { + case VNIL: case VFALSE: { + e->k = VTRUE; + break; + } + case VK: case VKNUM: case VTRUE: { + e->k = VFALSE; + break; + } + case VJMP: { + invertjump(fs, e); + break; + } + case VRELOCABLE: + case VNONRELOC: { + discharge2anyreg(fs, e); + freeexp(fs, e); + e->u.s.info = luaK_codeABC(fs, OP_NOT, 0, e->u.s.info, 0); + e->k = VRELOCABLE; + break; + } + default: { + lua_assert(0); /* cannot happen */ + break; + } + } + /* interchange true and false lists */ + { int temp = e->f; e->f = e->t; e->t = temp; } + removevalues(fs, e->f); + removevalues(fs, e->t); +} + + +void luaK_indexed (FuncState *fs, expdesc *t, expdesc *k) { + t->u.s.aux = luaK_exp2RK(fs, k); + t->k = VINDEXED; +} + + +static int constfolding (OpCode op, expdesc *e1, expdesc *e2) { + lua_Number v1, v2, r; + if (!isnumeral(e1) || !isnumeral(e2)) return 0; + v1 = e1->u.nval; + v2 = e2->u.nval; + switch (op) { + case OP_ADD: r = luai_numadd(v1, v2); break; + case OP_SUB: r = luai_numsub(v1, v2); break; + case OP_MUL: r = luai_nummul(v1, v2); break; + case OP_DIV: + if (v2 == 0) return 0; /* do not attempt to divide by 0 */ + r = luai_numdiv(v1, v2); break; + case OP_MOD: + if (v2 == 0) return 0; /* do not attempt to divide by 0 */ + r = luai_nummod(v1, v2); break; + case OP_POW: r = luai_numpow(v1, v2); break; + case OP_UNM: r = luai_numunm(v1); break; + case OP_LEN: return 0; /* no constant folding for 'len' */ + default: lua_assert(0); r = 0; break; + } + if (luai_numisnan(r)) return 0; /* do not attempt to produce NaN */ + e1->u.nval = r; + return 1; +} + + +static void codearith (FuncState *fs, OpCode op, expdesc *e1, expdesc *e2) { + if (constfolding(op, e1, e2)) + return; + else { + int o2 = (op != OP_UNM && op != OP_LEN) ? luaK_exp2RK(fs, e2) : 0; + int o1 = luaK_exp2RK(fs, e1); + if (o1 > o2) { + freeexp(fs, e1); + freeexp(fs, e2); + } + else { + freeexp(fs, e2); + freeexp(fs, e1); + } + e1->u.s.info = luaK_codeABC(fs, op, 0, o1, o2); + e1->k = VRELOCABLE; + } +} + + +static void codecomp (FuncState *fs, OpCode op, int cond, expdesc *e1, + expdesc *e2) { + int o1 = luaK_exp2RK(fs, e1); + int o2 = luaK_exp2RK(fs, e2); + freeexp(fs, e2); + freeexp(fs, e1); + if (cond == 0 && op != OP_EQ) { + int temp; /* exchange args to replace by `<' or `<=' */ + temp = o1; o1 = o2; o2 = temp; /* o1 <==> o2 */ + cond = 1; + } + e1->u.s.info = condjump(fs, op, cond, o1, o2); + e1->k = VJMP; +} + + +void luaK_prefix (FuncState *fs, UnOpr op, expdesc *e) { + expdesc e2; + e2.t = e2.f = NO_JUMP; e2.k = VKNUM; e2.u.nval = 0; + switch (op) { + case OPR_MINUS: { + if (!isnumeral(e)) + luaK_exp2anyreg(fs, e); /* cannot operate on non-numeric constants */ + codearith(fs, OP_UNM, e, &e2); + break; + } + case OPR_NOT: codenot(fs, e); break; + case OPR_LEN: { + luaK_exp2anyreg(fs, e); /* cannot operate on constants */ + codearith(fs, OP_LEN, e, &e2); + break; + } + default: lua_assert(0); + } +} + + +void luaK_infix (FuncState *fs, BinOpr op, expdesc *v) { + switch (op) { + case OPR_AND: { + luaK_goiftrue(fs, v); + break; + } + case OPR_OR: { + luaK_goiffalse(fs, v); + break; + } + case OPR_CONCAT: { + luaK_exp2nextreg(fs, v); /* operand must be on the `stack' */ + break; + } + case OPR_ADD: case OPR_SUB: case OPR_MUL: case OPR_DIV: + case OPR_MOD: case OPR_POW: { + if (!isnumeral(v)) luaK_exp2RK(fs, v); + break; + } + default: { + luaK_exp2RK(fs, v); + break; + } + } +} + + +void luaK_posfix (FuncState *fs, BinOpr op, expdesc *e1, expdesc *e2) { + switch (op) { + case OPR_AND: { + lua_assert(e1->t == NO_JUMP); /* list must be closed */ + luaK_dischargevars(fs, e2); + luaK_concat(fs, &e2->f, e1->f); + *e1 = *e2; + break; + } + case OPR_OR: { + lua_assert(e1->f == NO_JUMP); /* list must be closed */ + luaK_dischargevars(fs, e2); + luaK_concat(fs, &e2->t, e1->t); + *e1 = *e2; + break; + } + case OPR_CONCAT: { + luaK_exp2val(fs, e2); + if (e2->k == VRELOCABLE && GET_OPCODE(getcode(fs, e2)) == OP_CONCAT) { + lua_assert(e1->u.s.info == GETARG_B(getcode(fs, e2))-1); + freeexp(fs, e1); + SETARG_B(getcode(fs, e2), e1->u.s.info); + e1->k = VRELOCABLE; e1->u.s.info = e2->u.s.info; + } + else { + luaK_exp2nextreg(fs, e2); /* operand must be on the 'stack' */ + codearith(fs, OP_CONCAT, e1, e2); + } + break; + } + case OPR_ADD: codearith(fs, OP_ADD, e1, e2); break; + case OPR_SUB: codearith(fs, OP_SUB, e1, e2); break; + case OPR_MUL: codearith(fs, OP_MUL, e1, e2); break; + case OPR_DIV: codearith(fs, OP_DIV, e1, e2); break; + case OPR_MOD: codearith(fs, OP_MOD, e1, e2); break; + case OPR_POW: codearith(fs, OP_POW, e1, e2); break; + case OPR_EQ: codecomp(fs, OP_EQ, 1, e1, e2); break; + case OPR_NE: codecomp(fs, OP_EQ, 0, e1, e2); break; + case OPR_LT: codecomp(fs, OP_LT, 1, e1, e2); break; + case OPR_LE: codecomp(fs, OP_LE, 1, e1, e2); break; + case OPR_GT: codecomp(fs, OP_LT, 0, e1, e2); break; + case OPR_GE: codecomp(fs, OP_LE, 0, e1, e2); break; + default: lua_assert(0); + } +} + + +void luaK_fixline (FuncState *fs, int line) { + fs->f->lineinfo[fs->pc - 1] = line; +} + + +static int luaK_code (FuncState *fs, Instruction i, int line) { + Proto *f = fs->f; + dischargejpc(fs); /* `pc' will change */ + /* put new instruction in code array */ + luaM_growvector(fs->L, f->code, fs->pc, f->sizecode, Instruction, + MAX_INT, "code size overflow"); + f->code[fs->pc] = i; + /* save corresponding line information */ + luaM_growvector(fs->L, f->lineinfo, fs->pc, f->sizelineinfo, int, + MAX_INT, "code size overflow"); + f->lineinfo[fs->pc] = line; + return fs->pc++; +} + + +int luaK_codeABC (FuncState *fs, OpCode o, int a, int b, int c) { + lua_assert(getOpMode(o) == iABC); + lua_assert(getBMode(o) != OpArgN || b == 0); + lua_assert(getCMode(o) != OpArgN || c == 0); + return luaK_code(fs, CREATE_ABC(o, a, b, c), fs->ls->lastline); +} + + +int luaK_codeABx (FuncState *fs, OpCode o, int a, unsigned int bc) { + lua_assert(getOpMode(o) == iABx || getOpMode(o) == iAsBx); + lua_assert(getCMode(o) == OpArgN); + return luaK_code(fs, CREATE_ABx(o, a, bc), fs->ls->lastline); +} + + +void luaK_setlist (FuncState *fs, int base, int nelems, int tostore) { + int c = (nelems - 1)/LFIELDS_PER_FLUSH + 1; + int b = (tostore == LUA_MULTRET) ? 0 : tostore; + lua_assert(tostore != 0); + if (c <= MAXARG_C) + luaK_codeABC(fs, OP_SETLIST, base, b, c); + else { + luaK_codeABC(fs, OP_SETLIST, base, b, 0); + luaK_code(fs, cast(Instruction, c), fs->ls->lastline); + } + fs->freereg = base + 1; /* free registers with list values */ +} + diff --git a/lua/lcode.h b/lua/lcode.h new file mode 100644 index 0000000..b941c60 --- /dev/null +++ b/lua/lcode.h @@ -0,0 +1,76 @@ +/* +** $Id: lcode.h,v 1.48.1.1 2007/12/27 13:02:25 roberto Exp $ +** Code generator for Lua +** See Copyright Notice in lua.h +*/ + +#ifndef lcode_h +#define lcode_h + +#include "llex.h" +#include "lobject.h" +#include "lopcodes.h" +#include "lparser.h" + + +/* +** Marks the end of a patch list. It is an invalid value both as an absolute +** address, and as a list link (would link an element to itself). +*/ +#define NO_JUMP (-1) + + +/* +** grep "ORDER OPR" if you change these enums +*/ +typedef enum BinOpr { + OPR_ADD, OPR_SUB, OPR_MUL, OPR_DIV, OPR_MOD, OPR_POW, + OPR_CONCAT, + OPR_NE, OPR_EQ, + OPR_LT, OPR_LE, OPR_GT, OPR_GE, + OPR_AND, OPR_OR, + OPR_NOBINOPR +} BinOpr; + + +typedef enum UnOpr { OPR_MINUS, OPR_NOT, OPR_LEN, OPR_NOUNOPR } UnOpr; + + +#define getcode(fs,e) ((fs)->f->code[(e)->u.s.info]) + +#define luaK_codeAsBx(fs,o,A,sBx) luaK_codeABx(fs,o,A,(sBx)+MAXARG_sBx) + +#define luaK_setmultret(fs,e) luaK_setreturns(fs, e, LUA_MULTRET) + +LUAI_FUNC int luaK_codeABx (FuncState *fs, OpCode o, int A, unsigned int Bx); +LUAI_FUNC int luaK_codeABC (FuncState *fs, OpCode o, int A, int B, int C); +LUAI_FUNC void luaK_fixline (FuncState *fs, int line); +LUAI_FUNC void luaK_nil (FuncState *fs, int from, int n); +LUAI_FUNC void luaK_reserveregs (FuncState *fs, int n); +LUAI_FUNC void luaK_checkstack (FuncState *fs, int n); +LUAI_FUNC int luaK_stringK (FuncState *fs, TString *s); +LUAI_FUNC int luaK_numberK (FuncState *fs, lua_Number r); +LUAI_FUNC void luaK_dischargevars (FuncState *fs, expdesc *e); +LUAI_FUNC int luaK_exp2anyreg (FuncState *fs, expdesc *e); +LUAI_FUNC void luaK_exp2nextreg (FuncState *fs, expdesc *e); +LUAI_FUNC void luaK_exp2val (FuncState *fs, expdesc *e); +LUAI_FUNC int luaK_exp2RK (FuncState *fs, expdesc *e); +LUAI_FUNC void luaK_self (FuncState *fs, expdesc *e, expdesc *key); +LUAI_FUNC void luaK_indexed (FuncState *fs, expdesc *t, expdesc *k); +LUAI_FUNC void luaK_goiftrue (FuncState *fs, expdesc *e); +LUAI_FUNC void luaK_storevar (FuncState *fs, expdesc *var, expdesc *e); +LUAI_FUNC void luaK_setreturns (FuncState *fs, expdesc *e, int nresults); +LUAI_FUNC void luaK_setoneret (FuncState *fs, expdesc *e); +LUAI_FUNC int luaK_jump (FuncState *fs); +LUAI_FUNC void luaK_ret (FuncState *fs, int first, int nret); +LUAI_FUNC void luaK_patchlist (FuncState *fs, int list, int target); +LUAI_FUNC void luaK_patchtohere (FuncState *fs, int list); +LUAI_FUNC void luaK_concat (FuncState *fs, int *l1, int l2); +LUAI_FUNC int luaK_getlabel (FuncState *fs); +LUAI_FUNC void luaK_prefix (FuncState *fs, UnOpr op, expdesc *v); +LUAI_FUNC void luaK_infix (FuncState *fs, BinOpr op, expdesc *v); +LUAI_FUNC void luaK_posfix (FuncState *fs, BinOpr op, expdesc *v1, expdesc *v2); +LUAI_FUNC void luaK_setlist (FuncState *fs, int base, int nelems, int tostore); + + +#endif diff --git a/lua/ldblib.c b/lua/ldblib.c new file mode 100644 index 0000000..67de122 --- /dev/null +++ b/lua/ldblib.c @@ -0,0 +1,397 @@ +/* +** $Id: ldblib.c,v 1.104.1.3 2008/01/21 13:11:21 roberto Exp $ +** Interface from Lua to its debug API +** See Copyright Notice in lua.h +*/ + + +#include +#include +#include + +#define ldblib_c +#define LUA_LIB + +#include "lua.h" + +#include "lauxlib.h" +#include "lualib.h" + + + +static int db_getregistry (lua_State *L) { + lua_pushvalue(L, LUA_REGISTRYINDEX); + return 1; +} + + +static int db_getmetatable (lua_State *L) { + luaL_checkany(L, 1); + if (!lua_getmetatable(L, 1)) { + lua_pushnil(L); /* no metatable */ + } + return 1; +} + + +static int db_setmetatable (lua_State *L) { + int t = lua_type(L, 2); + luaL_argcheck(L, t == LUA_TNIL || t == LUA_TTABLE, 2, + "nil or table expected"); + lua_settop(L, 2); + lua_pushboolean(L, lua_setmetatable(L, 1)); + return 1; +} + + +static int db_getfenv (lua_State *L) { + lua_getfenv(L, 1); + return 1; +} + + +static int db_setfenv (lua_State *L) { + luaL_checktype(L, 2, LUA_TTABLE); + lua_settop(L, 2); + if (lua_setfenv(L, 1) == 0) + luaL_error(L, LUA_QL("setfenv") + " cannot change environment of given object"); + return 1; +} + + +static void settabss (lua_State *L, const char *i, const char *v) { + lua_pushstring(L, v); + lua_setfield(L, -2, i); +} + + +static void settabsi (lua_State *L, const char *i, int v) { + lua_pushinteger(L, v); + lua_setfield(L, -2, i); +} + + +static lua_State *getthread (lua_State *L, int *arg) { + if (lua_isthread(L, 1)) { + *arg = 1; + return lua_tothread(L, 1); + } + else { + *arg = 0; + return L; + } +} + + +static void treatstackoption (lua_State *L, lua_State *L1, const char *fname) { + if (L == L1) { + lua_pushvalue(L, -2); + lua_remove(L, -3); + } + else + lua_xmove(L1, L, 1); + lua_setfield(L, -2, fname); +} + + +static int db_getinfo (lua_State *L) { + lua_Debug ar; + int arg; + lua_State *L1 = getthread(L, &arg); + const char *options = luaL_optstring(L, arg+2, "flnSu"); + if (lua_isnumber(L, arg+1)) { + if (!lua_getstack(L1, (int)lua_tointeger(L, arg+1), &ar)) { + lua_pushnil(L); /* level out of range */ + return 1; + } + } + else if (lua_isfunction(L, arg+1)) { + lua_pushfstring(L, ">%s", options); + options = lua_tostring(L, -1); + lua_pushvalue(L, arg+1); + lua_xmove(L, L1, 1); + } + else + return luaL_argerror(L, arg+1, "function or level expected"); + if (!lua_getinfo(L1, options, &ar)) + return luaL_argerror(L, arg+2, "invalid option"); + lua_createtable(L, 0, 2); + if (strchr(options, 'S')) { + settabss(L, "source", ar.source); + settabss(L, "short_src", ar.short_src); + settabsi(L, "linedefined", ar.linedefined); + settabsi(L, "lastlinedefined", ar.lastlinedefined); + settabss(L, "what", ar.what); + } + if (strchr(options, 'l')) + settabsi(L, "currentline", ar.currentline); + if (strchr(options, 'u')) + settabsi(L, "nups", ar.nups); + if (strchr(options, 'n')) { + settabss(L, "name", ar.name); + settabss(L, "namewhat", ar.namewhat); + } + if (strchr(options, 'L')) + treatstackoption(L, L1, "activelines"); + if (strchr(options, 'f')) + treatstackoption(L, L1, "func"); + return 1; /* return table */ +} + + +static int db_getlocal (lua_State *L) { + int arg; + lua_State *L1 = getthread(L, &arg); + lua_Debug ar; + const char *name; + if (!lua_getstack(L1, luaL_checkint(L, arg+1), &ar)) /* out of range? */ + return luaL_argerror(L, arg+1, "level out of range"); + name = lua_getlocal(L1, &ar, luaL_checkint(L, arg+2)); + if (name) { + lua_xmove(L1, L, 1); + lua_pushstring(L, name); + lua_pushvalue(L, -2); + return 2; + } + else { + lua_pushnil(L); + return 1; + } +} + + +static int db_setlocal (lua_State *L) { + int arg; + lua_State *L1 = getthread(L, &arg); + lua_Debug ar; + if (!lua_getstack(L1, luaL_checkint(L, arg+1), &ar)) /* out of range? */ + return luaL_argerror(L, arg+1, "level out of range"); + luaL_checkany(L, arg+3); + lua_settop(L, arg+3); + lua_xmove(L, L1, 1); + lua_pushstring(L, lua_setlocal(L1, &ar, luaL_checkint(L, arg+2))); + return 1; +} + + +static int auxupvalue (lua_State *L, int get) { + const char *name; + int n = luaL_checkint(L, 2); + luaL_checktype(L, 1, LUA_TFUNCTION); + if (lua_iscfunction(L, 1)) return 0; /* cannot touch C upvalues from Lua */ + name = get ? lua_getupvalue(L, 1, n) : lua_setupvalue(L, 1, n); + if (name == NULL) return 0; + lua_pushstring(L, name); + lua_insert(L, -(get+1)); + return get + 1; +} + + +static int db_getupvalue (lua_State *L) { + return auxupvalue(L, 1); +} + + +static int db_setupvalue (lua_State *L) { + luaL_checkany(L, 3); + return auxupvalue(L, 0); +} + + + +static const char KEY_HOOK = 'h'; + + +static void hookf (lua_State *L, lua_Debug *ar) { + static const char *const hooknames[] = + {"call", "return", "line", "count", "tail return"}; + lua_pushlightuserdata(L, (void *)&KEY_HOOK); + lua_rawget(L, LUA_REGISTRYINDEX); + lua_pushlightuserdata(L, L); + lua_rawget(L, -2); + if (lua_isfunction(L, -1)) { + lua_pushstring(L, hooknames[(int)ar->event]); + if (ar->currentline >= 0) + lua_pushinteger(L, ar->currentline); + else lua_pushnil(L); + lua_assert(lua_getinfo(L, "lS", ar)); + lua_call(L, 2, 0); + } +} + + +static int makemask (const char *smask, int count) { + int mask = 0; + if (strchr(smask, 'c')) mask |= LUA_MASKCALL; + if (strchr(smask, 'r')) mask |= LUA_MASKRET; + if (strchr(smask, 'l')) mask |= LUA_MASKLINE; + if (count > 0) mask |= LUA_MASKCOUNT; + return mask; +} + + +static char *unmakemask (int mask, char *smask) { + int i = 0; + if (mask & LUA_MASKCALL) smask[i++] = 'c'; + if (mask & LUA_MASKRET) smask[i++] = 'r'; + if (mask & LUA_MASKLINE) smask[i++] = 'l'; + smask[i] = '\0'; + return smask; +} + + +static void gethooktable (lua_State *L) { + lua_pushlightuserdata(L, (void *)&KEY_HOOK); + lua_rawget(L, LUA_REGISTRYINDEX); + if (!lua_istable(L, -1)) { + lua_pop(L, 1); + lua_createtable(L, 0, 1); + lua_pushlightuserdata(L, (void *)&KEY_HOOK); + lua_pushvalue(L, -2); + lua_rawset(L, LUA_REGISTRYINDEX); + } +} + + +static int db_sethook (lua_State *L) { + int arg, mask, count; + lua_Hook func; + lua_State *L1 = getthread(L, &arg); + if (lua_isnoneornil(L, arg+1)) { + lua_settop(L, arg+1); + func = NULL; mask = 0; count = 0; /* turn off hooks */ + } + else { + const char *smask = luaL_checkstring(L, arg+2); + luaL_checktype(L, arg+1, LUA_TFUNCTION); + count = luaL_optint(L, arg+3, 0); + func = hookf; mask = makemask(smask, count); + } + gethooktable(L); + lua_pushlightuserdata(L, L1); + lua_pushvalue(L, arg+1); + lua_rawset(L, -3); /* set new hook */ + lua_pop(L, 1); /* remove hook table */ + lua_sethook(L1, func, mask, count); /* set hooks */ + return 0; +} + + +static int db_gethook (lua_State *L) { + int arg; + lua_State *L1 = getthread(L, &arg); + char buff[5]; + int mask = lua_gethookmask(L1); + lua_Hook hook = lua_gethook(L1); + if (hook != NULL && hook != hookf) /* external hook? */ + lua_pushliteral(L, "external hook"); + else { + gethooktable(L); + lua_pushlightuserdata(L, L1); + lua_rawget(L, -2); /* get hook */ + lua_remove(L, -2); /* remove hook table */ + } + lua_pushstring(L, unmakemask(mask, buff)); + lua_pushinteger(L, lua_gethookcount(L1)); + return 3; +} + + +static int db_debug (lua_State *L) { + for (;;) { + char buffer[250]; + fputs("lua_debug> ", stderr); + if (fgets(buffer, sizeof(buffer), stdin) == 0 || + strcmp(buffer, "cont\n") == 0) + return 0; + if (luaL_loadbuffer(L, buffer, strlen(buffer), "=(debug command)") || + lua_pcall(L, 0, 0, 0)) { + fputs(lua_tostring(L, -1), stderr); + fputs("\n", stderr); + } + lua_settop(L, 0); /* remove eventual returns */ + } +} + + +#define LEVELS1 12 /* size of the first part of the stack */ +#define LEVELS2 10 /* size of the second part of the stack */ + +static int db_errorfb (lua_State *L) { + int level; + int firstpart = 1; /* still before eventual `...' */ + int arg; + lua_State *L1 = getthread(L, &arg); + lua_Debug ar; + if (lua_isnumber(L, arg+2)) { + level = (int)lua_tointeger(L, arg+2); + lua_pop(L, 1); + } + else + level = (L == L1) ? 1 : 0; /* level 0 may be this own function */ + if (lua_gettop(L) == arg) + lua_pushliteral(L, ""); + else if (!lua_isstring(L, arg+1)) return 1; /* message is not a string */ + else lua_pushliteral(L, "\n"); + lua_pushliteral(L, "stack traceback:"); + while (lua_getstack(L1, level++, &ar)) { + if (level > LEVELS1 && firstpart) { + /* no more than `LEVELS2' more levels? */ + if (!lua_getstack(L1, level+LEVELS2, &ar)) + level--; /* keep going */ + else { + lua_pushliteral(L, "\n\t..."); /* too many levels */ + while (lua_getstack(L1, level+LEVELS2, &ar)) /* find last levels */ + level++; + } + firstpart = 0; + continue; + } + lua_pushliteral(L, "\n\t"); + lua_getinfo(L1, "Snl", &ar); + lua_pushfstring(L, "%s:", ar.short_src); + if (ar.currentline > 0) + lua_pushfstring(L, "%d:", ar.currentline); + if (*ar.namewhat != '\0') /* is there a name? */ + lua_pushfstring(L, " in function " LUA_QS, ar.name); + else { + if (*ar.what == 'm') /* main? */ + lua_pushfstring(L, " in main chunk"); + else if (*ar.what == 'C' || *ar.what == 't') + lua_pushliteral(L, " ?"); /* C function or tail call */ + else + lua_pushfstring(L, " in function <%s:%d>", + ar.short_src, ar.linedefined); + } + lua_concat(L, lua_gettop(L) - arg); + } + lua_concat(L, lua_gettop(L) - arg); + return 1; +} + + +static const luaL_Reg dblib[] = { + {"debug", db_debug}, + {"getfenv", db_getfenv}, + {"gethook", db_gethook}, + {"getinfo", db_getinfo}, + {"getlocal", db_getlocal}, + {"getregistry", db_getregistry}, + {"getmetatable", db_getmetatable}, + {"getupvalue", db_getupvalue}, + {"setfenv", db_setfenv}, + {"sethook", db_sethook}, + {"setlocal", db_setlocal}, + {"setmetatable", db_setmetatable}, + {"setupvalue", db_setupvalue}, + {"traceback", db_errorfb}, + {NULL, NULL} +}; + + +LUALIB_API int luaopen_debug (lua_State *L) { + luaL_register(L, LUA_DBLIBNAME, dblib); + return 1; +} + diff --git a/lua/ldebug.c b/lua/ldebug.c new file mode 100644 index 0000000..50ad3d3 --- /dev/null +++ b/lua/ldebug.c @@ -0,0 +1,638 @@ +/* +** $Id: ldebug.c,v 2.29.1.6 2008/05/08 16:56:26 roberto Exp $ +** Debug Interface +** See Copyright Notice in lua.h +*/ + + +#include +#include +#include + + +#define ldebug_c +#define LUA_CORE + +#include "lua.h" + +#include "lapi.h" +#include "lcode.h" +#include "ldebug.h" +#include "ldo.h" +#include "lfunc.h" +#include "lobject.h" +#include "lopcodes.h" +#include "lstate.h" +#include "lstring.h" +#include "ltable.h" +#include "ltm.h" +#include "lvm.h" + + + +static const char *getfuncname (lua_State *L, CallInfo *ci, const char **name); + + +static int currentpc (lua_State *L, CallInfo *ci) { + if (!isLua(ci)) return -1; /* function is not a Lua function? */ + if (ci == L->ci) + ci->savedpc = L->savedpc; + return pcRel(ci->savedpc, ci_func(ci)->l.p); +} + + +static int currentline (lua_State *L, CallInfo *ci) { + int pc = currentpc(L, ci); + if (pc < 0) + return -1; /* only active lua functions have current-line information */ + else + return getline(ci_func(ci)->l.p, pc); +} + + +/* +** this function can be called asynchronous (e.g. during a signal) +*/ +LUA_API int lua_sethook (lua_State *L, lua_Hook func, int mask, int count) { + if (func == NULL || mask == 0) { /* turn off hooks? */ + mask = 0; + func = NULL; + } + L->hook = func; + L->basehookcount = count; + resethookcount(L); + L->hookmask = cast_byte(mask); + return 1; +} + + +LUA_API lua_Hook lua_gethook (lua_State *L) { + return L->hook; +} + + +LUA_API int lua_gethookmask (lua_State *L) { + return L->hookmask; +} + + +LUA_API int lua_gethookcount (lua_State *L) { + return L->basehookcount; +} + + +LUA_API int lua_getstack (lua_State *L, int level, lua_Debug *ar) { + int status; + CallInfo *ci; + lua_lock(L); + for (ci = L->ci; level > 0 && ci > L->base_ci; ci--) { + level--; + if (f_isLua(ci)) /* Lua function? */ + level -= ci->tailcalls; /* skip lost tail calls */ + } + if (level == 0 && ci > L->base_ci) { /* level found? */ + status = 1; + ar->i_ci = cast_int(ci - L->base_ci); + } + else if (level < 0) { /* level is of a lost tail call? */ + status = 1; + ar->i_ci = 0; + } + else status = 0; /* no such level */ + lua_unlock(L); + return status; +} + + +static Proto *getluaproto (CallInfo *ci) { + return (isLua(ci) ? ci_func(ci)->l.p : NULL); +} + + +static const char *findlocal (lua_State *L, CallInfo *ci, int n) { + const char *name; + Proto *fp = getluaproto(ci); + if (fp && (name = luaF_getlocalname(fp, n, currentpc(L, ci))) != NULL) + return name; /* is a local variable in a Lua function */ + else { + StkId limit = (ci == L->ci) ? L->top : (ci+1)->func; + if (limit - ci->base >= n && n > 0) /* is 'n' inside 'ci' stack? */ + return "(*temporary)"; + else + return NULL; + } +} + + +LUA_API const char *lua_getlocal (lua_State *L, const lua_Debug *ar, int n) { + CallInfo *ci = L->base_ci + ar->i_ci; + const char *name = findlocal(L, ci, n); + lua_lock(L); + if (name) + luaA_pushobject(L, ci->base + (n - 1)); + lua_unlock(L); + return name; +} + + +LUA_API const char *lua_setlocal (lua_State *L, const lua_Debug *ar, int n) { + CallInfo *ci = L->base_ci + ar->i_ci; + const char *name = findlocal(L, ci, n); + lua_lock(L); + if (name) + setobjs2s(L, ci->base + (n - 1), L->top - 1); + L->top--; /* pop value */ + lua_unlock(L); + return name; +} + + +static void funcinfo (lua_Debug *ar, Closure *cl) { + if (cl->c.isC) { + ar->source = "=[C]"; + ar->linedefined = -1; + ar->lastlinedefined = -1; + ar->what = "C"; + } + else { + ar->source = getstr(cl->l.p->source); + ar->linedefined = cl->l.p->linedefined; + ar->lastlinedefined = cl->l.p->lastlinedefined; + ar->what = (ar->linedefined == 0) ? "main" : "Lua"; + } + luaO_chunkid(ar->short_src, ar->source, LUA_IDSIZE); +} + + +static void info_tailcall (lua_Debug *ar) { + ar->name = ar->namewhat = ""; + ar->what = "tail"; + ar->lastlinedefined = ar->linedefined = ar->currentline = -1; + ar->source = "=(tail call)"; + luaO_chunkid(ar->short_src, ar->source, LUA_IDSIZE); + ar->nups = 0; +} + + +static void collectvalidlines (lua_State *L, Closure *f) { + if (f == NULL || f->c.isC) { + setnilvalue(L->top); + } + else { + Table *t = luaH_new(L, 0, 0); + int *lineinfo = f->l.p->lineinfo; + int i; + for (i=0; il.p->sizelineinfo; i++) + setbvalue(luaH_setnum(L, t, lineinfo[i]), 1); + sethvalue(L, L->top, t); + } + incr_top(L); +} + + +static int auxgetinfo (lua_State *L, const char *what, lua_Debug *ar, + Closure *f, CallInfo *ci) { + int status = 1; + if (f == NULL) { + info_tailcall(ar); + return status; + } + for (; *what; what++) { + switch (*what) { + case 'S': { + funcinfo(ar, f); + break; + } + case 'l': { + ar->currentline = (ci) ? currentline(L, ci) : -1; + break; + } + case 'u': { + ar->nups = f->c.nupvalues; + break; + } + case 'n': { + ar->namewhat = (ci) ? getfuncname(L, ci, &ar->name) : NULL; + if (ar->namewhat == NULL) { + ar->namewhat = ""; /* not found */ + ar->name = NULL; + } + break; + } + case 'L': + case 'f': /* handled by lua_getinfo */ + break; + default: status = 0; /* invalid option */ + } + } + return status; +} + + +LUA_API int lua_getinfo (lua_State *L, const char *what, lua_Debug *ar) { + int status; + Closure *f = NULL; + CallInfo *ci = NULL; + lua_lock(L); + if (*what == '>') { + StkId func = L->top - 1; + luai_apicheck(L, ttisfunction(func)); + what++; /* skip the '>' */ + f = clvalue(func); + L->top--; /* pop function */ + } + else if (ar->i_ci != 0) { /* no tail call? */ + ci = L->base_ci + ar->i_ci; + lua_assert(ttisfunction(ci->func)); + f = clvalue(ci->func); + } + status = auxgetinfo(L, what, ar, f, ci); + if (strchr(what, 'f')) { + if (f == NULL) setnilvalue(L->top); + else setclvalue(L, L->top, f); + incr_top(L); + } + if (strchr(what, 'L')) + collectvalidlines(L, f); + lua_unlock(L); + return status; +} + + +/* +** {====================================================== +** Symbolic Execution and code checker +** ======================================================= +*/ + +#define check(x) if (!(x)) return 0; + +#define checkjump(pt,pc) check(0 <= pc && pc < pt->sizecode) + +#define checkreg(pt,reg) check((reg) < (pt)->maxstacksize) + + + +static int precheck (const Proto *pt) { + check(pt->maxstacksize <= MAXSTACK); + check(pt->numparams+(pt->is_vararg & VARARG_HASARG) <= pt->maxstacksize); + check(!(pt->is_vararg & VARARG_NEEDSARG) || + (pt->is_vararg & VARARG_HASARG)); + check(pt->sizeupvalues <= pt->nups); + check(pt->sizelineinfo == pt->sizecode || pt->sizelineinfo == 0); + check(pt->sizecode > 0 && GET_OPCODE(pt->code[pt->sizecode-1]) == OP_RETURN); + return 1; +} + + +#define checkopenop(pt,pc) luaG_checkopenop((pt)->code[(pc)+1]) + +int luaG_checkopenop (Instruction i) { + switch (GET_OPCODE(i)) { + case OP_CALL: + case OP_TAILCALL: + case OP_RETURN: + case OP_SETLIST: { + check(GETARG_B(i) == 0); + return 1; + } + default: return 0; /* invalid instruction after an open call */ + } +} + + +static int checkArgMode (const Proto *pt, int r, enum OpArgMask mode) { + switch (mode) { + case OpArgN: check(r == 0); break; + case OpArgU: break; + case OpArgR: checkreg(pt, r); break; + case OpArgK: + check(ISK(r) ? INDEXK(r) < pt->sizek : r < pt->maxstacksize); + break; + } + return 1; +} + + +static Instruction symbexec (const Proto *pt, int lastpc, int reg) { + int pc; + int last; /* stores position of last instruction that changed `reg' */ + last = pt->sizecode-1; /* points to final return (a `neutral' instruction) */ + check(precheck(pt)); + for (pc = 0; pc < lastpc; pc++) { + Instruction i = pt->code[pc]; + OpCode op = GET_OPCODE(i); + int a = GETARG_A(i); + int b = 0; + int c = 0; + check(op < NUM_OPCODES); + checkreg(pt, a); + switch (getOpMode(op)) { + case iABC: { + b = GETARG_B(i); + c = GETARG_C(i); + check(checkArgMode(pt, b, getBMode(op))); + check(checkArgMode(pt, c, getCMode(op))); + break; + } + case iABx: { + b = GETARG_Bx(i); + if (getBMode(op) == OpArgK) check(b < pt->sizek); + break; + } + case iAsBx: { + b = GETARG_sBx(i); + if (getBMode(op) == OpArgR) { + int dest = pc+1+b; + check(0 <= dest && dest < pt->sizecode); + if (dest > 0) { + int j; + /* check that it does not jump to a setlist count; this + is tricky, because the count from a previous setlist may + have the same value of an invalid setlist; so, we must + go all the way back to the first of them (if any) */ + for (j = 0; j < dest; j++) { + Instruction d = pt->code[dest-1-j]; + if (!(GET_OPCODE(d) == OP_SETLIST && GETARG_C(d) == 0)) break; + } + /* if 'j' is even, previous value is not a setlist (even if + it looks like one) */ + check((j&1) == 0); + } + } + break; + } + } + if (testAMode(op)) { + if (a == reg) last = pc; /* change register `a' */ + } + if (testTMode(op)) { + check(pc+2 < pt->sizecode); /* check skip */ + check(GET_OPCODE(pt->code[pc+1]) == OP_JMP); + } + switch (op) { + case OP_LOADBOOL: { + if (c == 1) { /* does it jump? */ + check(pc+2 < pt->sizecode); /* check its jump */ + check(GET_OPCODE(pt->code[pc+1]) != OP_SETLIST || + GETARG_C(pt->code[pc+1]) != 0); + } + break; + } + case OP_LOADNIL: { + if (a <= reg && reg <= b) + last = pc; /* set registers from `a' to `b' */ + break; + } + case OP_GETUPVAL: + case OP_SETUPVAL: { + check(b < pt->nups); + break; + } + case OP_GETGLOBAL: + case OP_SETGLOBAL: { + check(ttisstring(&pt->k[b])); + break; + } + case OP_SELF: { + checkreg(pt, a+1); + if (reg == a+1) last = pc; + break; + } + case OP_CONCAT: { + check(b < c); /* at least two operands */ + break; + } + case OP_TFORLOOP: { + check(c >= 1); /* at least one result (control variable) */ + checkreg(pt, a+2+c); /* space for results */ + if (reg >= a+2) last = pc; /* affect all regs above its base */ + break; + } + case OP_FORLOOP: + case OP_FORPREP: + checkreg(pt, a+3); + /* go through */ + case OP_JMP: { + int dest = pc+1+b; + /* not full check and jump is forward and do not skip `lastpc'? */ + if (reg != NO_REG && pc < dest && dest <= lastpc) + pc += b; /* do the jump */ + break; + } + case OP_CALL: + case OP_TAILCALL: { + if (b != 0) { + checkreg(pt, a+b-1); + } + c--; /* c = num. returns */ + if (c == LUA_MULTRET) { + check(checkopenop(pt, pc)); + } + else if (c != 0) + checkreg(pt, a+c-1); + if (reg >= a) last = pc; /* affect all registers above base */ + break; + } + case OP_RETURN: { + b--; /* b = num. returns */ + if (b > 0) checkreg(pt, a+b-1); + break; + } + case OP_SETLIST: { + if (b > 0) checkreg(pt, a + b); + if (c == 0) { + pc++; + check(pc < pt->sizecode - 1); + } + break; + } + case OP_CLOSURE: { + int nup, j; + check(b < pt->sizep); + nup = pt->p[b]->nups; + check(pc + nup < pt->sizecode); + for (j = 1; j <= nup; j++) { + OpCode op1 = GET_OPCODE(pt->code[pc + j]); + check(op1 == OP_GETUPVAL || op1 == OP_MOVE); + } + if (reg != NO_REG) /* tracing? */ + pc += nup; /* do not 'execute' these pseudo-instructions */ + break; + } + case OP_VARARG: { + check((pt->is_vararg & VARARG_ISVARARG) && + !(pt->is_vararg & VARARG_NEEDSARG)); + b--; + if (b == LUA_MULTRET) check(checkopenop(pt, pc)); + checkreg(pt, a+b-1); + break; + } + default: break; + } + } + return pt->code[last]; +} + +#undef check +#undef checkjump +#undef checkreg + +/* }====================================================== */ + + +int luaG_checkcode (const Proto *pt) { + return (symbexec(pt, pt->sizecode, NO_REG) != 0); +} + + +static const char *kname (Proto *p, int c) { + if (ISK(c) && ttisstring(&p->k[INDEXK(c)])) + return svalue(&p->k[INDEXK(c)]); + else + return "?"; +} + + +static const char *getobjname (lua_State *L, CallInfo *ci, int stackpos, + const char **name) { + if (isLua(ci)) { /* a Lua function? */ + Proto *p = ci_func(ci)->l.p; + int pc = currentpc(L, ci); + Instruction i; + *name = luaF_getlocalname(p, stackpos+1, pc); + if (*name) /* is a local? */ + return "local"; + i = symbexec(p, pc, stackpos); /* try symbolic execution */ + lua_assert(pc != -1); + switch (GET_OPCODE(i)) { + case OP_GETGLOBAL: { + int g = GETARG_Bx(i); /* global index */ + lua_assert(ttisstring(&p->k[g])); + *name = svalue(&p->k[g]); + return "global"; + } + case OP_MOVE: { + int a = GETARG_A(i); + int b = GETARG_B(i); /* move from `b' to `a' */ + if (b < a) + return getobjname(L, ci, b, name); /* get name for `b' */ + break; + } + case OP_GETTABLE: { + int k = GETARG_C(i); /* key index */ + *name = kname(p, k); + return "field"; + } + case OP_GETUPVAL: { + int u = GETARG_B(i); /* upvalue index */ + *name = p->upvalues ? getstr(p->upvalues[u]) : "?"; + return "upvalue"; + } + case OP_SELF: { + int k = GETARG_C(i); /* key index */ + *name = kname(p, k); + return "method"; + } + default: break; + } + } + return NULL; /* no useful name found */ +} + + +static const char *getfuncname (lua_State *L, CallInfo *ci, const char **name) { + Instruction i; + if ((isLua(ci) && ci->tailcalls > 0) || !isLua(ci - 1)) + return NULL; /* calling function is not Lua (or is unknown) */ + ci--; /* calling function */ + i = ci_func(ci)->l.p->code[currentpc(L, ci)]; + if (GET_OPCODE(i) == OP_CALL || GET_OPCODE(i) == OP_TAILCALL || + GET_OPCODE(i) == OP_TFORLOOP) + return getobjname(L, ci, GETARG_A(i), name); + else + return NULL; /* no useful name can be found */ +} + + +/* only ANSI way to check whether a pointer points to an array */ +static int isinstack (CallInfo *ci, const TValue *o) { + StkId p; + for (p = ci->base; p < ci->top; p++) + if (o == p) return 1; + return 0; +} + + +void luaG_typeerror (lua_State *L, const TValue *o, const char *op) { + const char *name = NULL; + const char *t = luaT_typenames[ttype(o)]; + const char *kind = (isinstack(L->ci, o)) ? + getobjname(L, L->ci, cast_int(o - L->base), &name) : + NULL; + if (kind) + luaG_runerror(L, "attempt to %s %s " LUA_QS " (a %s value)", + op, kind, name, t); + else + luaG_runerror(L, "attempt to %s a %s value", op, t); +} + + +void luaG_concaterror (lua_State *L, StkId p1, StkId p2) { + if (ttisstring(p1) || ttisnumber(p1)) p1 = p2; + lua_assert(!ttisstring(p1) && !ttisnumber(p1)); + luaG_typeerror(L, p1, "concatenate"); +} + + +void luaG_aritherror (lua_State *L, const TValue *p1, const TValue *p2) { + TValue temp; + if (luaV_tonumber(p1, &temp) == NULL) + p2 = p1; /* first operand is wrong */ + luaG_typeerror(L, p2, "perform arithmetic on"); +} + + +int luaG_ordererror (lua_State *L, const TValue *p1, const TValue *p2) { + const char *t1 = luaT_typenames[ttype(p1)]; + const char *t2 = luaT_typenames[ttype(p2)]; + if (t1[2] == t2[2]) + luaG_runerror(L, "attempt to compare two %s values", t1); + else + luaG_runerror(L, "attempt to compare %s with %s", t1, t2); + return 0; +} + + +static void addinfo (lua_State *L, const char *msg) { + CallInfo *ci = L->ci; + if (isLua(ci)) { /* is Lua code? */ + char buff[LUA_IDSIZE]; /* add file:line information */ + int line = currentline(L, ci); + luaO_chunkid(buff, getstr(getluaproto(ci)->source), LUA_IDSIZE); + luaO_pushfstring(L, "%s:%d: %s", buff, line, msg); + } +} + + +void luaG_errormsg (lua_State *L) { + if (L->errfunc != 0) { /* is there an error handling function? */ + StkId errfunc = restorestack(L, L->errfunc); + if (!ttisfunction(errfunc)) luaD_throw(L, LUA_ERRERR); + setobjs2s(L, L->top, L->top - 1); /* move argument */ + setobjs2s(L, L->top - 1, errfunc); /* push function */ + incr_top(L); + luaD_call(L, L->top - 2, 1); /* call it */ + } + luaD_throw(L, LUA_ERRRUN); +} + + +void luaG_runerror (lua_State *L, const char *fmt, ...) { + va_list argp; + va_start(argp, fmt); + addinfo(L, luaO_pushvfstring(L, fmt, argp)); + va_end(argp); + luaG_errormsg(L); +} + diff --git a/lua/ldebug.h b/lua/ldebug.h new file mode 100644 index 0000000..ba28a97 --- /dev/null +++ b/lua/ldebug.h @@ -0,0 +1,33 @@ +/* +** $Id: ldebug.h,v 2.3.1.1 2007/12/27 13:02:25 roberto Exp $ +** Auxiliary functions from Debug Interface module +** See Copyright Notice in lua.h +*/ + +#ifndef ldebug_h +#define ldebug_h + + +#include "lstate.h" + + +#define pcRel(pc, p) (cast(int, (pc) - (p)->code) - 1) + +#define getline(f,pc) (((f)->lineinfo) ? (f)->lineinfo[pc] : 0) + +#define resethookcount(L) (L->hookcount = L->basehookcount) + + +LUAI_FUNC void luaG_typeerror (lua_State *L, const TValue *o, + const char *opname); +LUAI_FUNC void luaG_concaterror (lua_State *L, StkId p1, StkId p2); +LUAI_FUNC void luaG_aritherror (lua_State *L, const TValue *p1, + const TValue *p2); +LUAI_FUNC int luaG_ordererror (lua_State *L, const TValue *p1, + const TValue *p2); +LUAI_FUNC void luaG_runerror (lua_State *L, const char *fmt, ...); +LUAI_FUNC void luaG_errormsg (lua_State *L); +LUAI_FUNC int luaG_checkcode (const Proto *pt); +LUAI_FUNC int luaG_checkopenop (Instruction i); + +#endif diff --git a/lua/ldo.c b/lua/ldo.c new file mode 100644 index 0000000..a8b6ca4 --- /dev/null +++ b/lua/ldo.c @@ -0,0 +1,527 @@ +/* +** $Id: ldo.c,v 2.38.1.3 2008/01/18 22:31:22 roberto Exp $ +** Stack and Call structure of Lua +** See Copyright Notice in lua.h +*/ + + +#include +#include +#include + +#define ldo_c +#define LUA_CORE + +#include "lua.h" + +#include "ldebug.h" +#include "ldo.h" +#include "lfunc.h" +#include "lgc.h" +#include "lmem.h" +#include "lobject.h" +#include "lopcodes.h" +#include "lparser.h" +#include "lstate.h" +#include "lstring.h" +#include "ltable.h" +#include "ltm.h" +#include "lundump.h" +#include "lvm.h" +#include "lzio.h" + + + + +/* +** {====================================================== +** Error-recovery functions +** ======================================================= +*/ + + +/* chain list of long jump buffers */ +struct lua_longjmp { + struct lua_longjmp *previous; + luai_jmpbuf b; + volatile int status; /* error code */ +}; + + +void luaD_seterrorobj (lua_State *L, int errcode, StkId oldtop) { + switch (errcode) { + case LUA_ERRMEM: { + setsvalue2s(L, oldtop, luaS_newliteral(L, MEMERRMSG)); + break; + } + case LUA_ERRERR: { + setsvalue2s(L, oldtop, luaS_newliteral(L, "error in error handling")); + break; + } + case LUA_ERRSYNTAX: + case LUA_ERRRUN: { + setobjs2s(L, oldtop, L->top - 1); /* error message on current top */ + break; + } + } + L->top = oldtop + 1; +} + + +static void restore_stack_limit (lua_State *L) { + lua_assert(L->stack_last - L->stack == L->stacksize - EXTRA_STACK - 1); + if (L->size_ci > LUAI_MAXCALLS) { /* there was an overflow? */ + int inuse = cast_int(L->ci - L->base_ci); + if (inuse + 1 < LUAI_MAXCALLS) /* can `undo' overflow? */ + luaD_reallocCI(L, LUAI_MAXCALLS); + } +} + + +static void resetstack (lua_State *L, int status) { + L->ci = L->base_ci; + L->base = L->ci->base; + luaF_close(L, L->base); /* close eventual pending closures */ + luaD_seterrorobj(L, status, L->base); + L->nCcalls = L->baseCcalls; + L->allowhook = 1; + restore_stack_limit(L); + L->errfunc = 0; + L->errorJmp = NULL; +} + + +void luaD_throw (lua_State *L, int errcode) { + if (L->errorJmp) { + L->errorJmp->status = errcode; + LUAI_THROW(L, L->errorJmp); + } + else { + L->status = cast_byte(errcode); + if (G(L)->panic) { + resetstack(L, errcode); + lua_unlock(L); + G(L)->panic(L); + } + exit(EXIT_FAILURE); + } +} + + +int luaD_rawrunprotected (lua_State *L, Pfunc f, void *ud) { + struct lua_longjmp lj; + lj.status = 0; + lj.previous = L->errorJmp; /* chain new error handler */ + L->errorJmp = &lj; + LUAI_TRY(L, &lj, + (*f)(L, ud); + ); + L->errorJmp = lj.previous; /* restore old error handler */ + return lj.status; +} + +/* }====================================================== */ + + +static void correctstack (lua_State *L, TValue *oldstack) { + CallInfo *ci; + GCObject *up; + L->top = (L->top - oldstack) + L->stack; + for (up = L->openupval; up != NULL; up = up->gch.next) + gco2uv(up)->v = (gco2uv(up)->v - oldstack) + L->stack; + for (ci = L->base_ci; ci <= L->ci; ci++) { + ci->top = (ci->top - oldstack) + L->stack; + ci->base = (ci->base - oldstack) + L->stack; + ci->func = (ci->func - oldstack) + L->stack; + } + L->base = (L->base - oldstack) + L->stack; +} + + +void luaD_reallocstack (lua_State *L, int newsize) { + TValue *oldstack = L->stack; + int realsize = newsize + 1 + EXTRA_STACK; + lua_assert(L->stack_last - L->stack == L->stacksize - EXTRA_STACK - 1); + luaM_reallocvector(L, L->stack, L->stacksize, realsize, TValue); + L->stacksize = realsize; + L->stack_last = L->stack+newsize; + correctstack(L, oldstack); +} + + +void luaD_reallocCI (lua_State *L, int newsize) { + CallInfo *oldci = L->base_ci; + luaM_reallocvector(L, L->base_ci, L->size_ci, newsize, CallInfo); + L->size_ci = newsize; + L->ci = (L->ci - oldci) + L->base_ci; + L->end_ci = L->base_ci + L->size_ci - 1; +} + + +void luaD_growstack (lua_State *L, int n) { + if (n <= L->stacksize) /* double size is enough? */ + luaD_reallocstack(L, 2*L->stacksize); + else + luaD_reallocstack(L, L->stacksize + n); +} + + +static CallInfo *growCI (lua_State *L) { + if (L->size_ci > LUAI_MAXCALLS) /* overflow while handling overflow? */ + luaD_throw(L, LUA_ERRERR); + else { + luaD_reallocCI(L, 2*L->size_ci); + if (L->size_ci > LUAI_MAXCALLS) + luaG_runerror(L, "stack overflow"); + } + return ++L->ci; +} + + +void luaD_callhook (lua_State *L, int event, int line) { + lua_Hook hook = L->hook; + if (hook && L->allowhook) { + ptrdiff_t top = savestack(L, L->top); + ptrdiff_t ci_top = savestack(L, L->ci->top); + lua_Debug ar; + ar.event = event; + ar.currentline = line; + if (event == LUA_HOOKTAILRET) + ar.i_ci = 0; /* tail call; no debug information about it */ + else + ar.i_ci = cast_int(L->ci - L->base_ci); + luaD_checkstack(L, LUA_MINSTACK); /* ensure minimum stack size */ + L->ci->top = L->top + LUA_MINSTACK; + lua_assert(L->ci->top <= L->stack_last); + L->allowhook = 0; /* cannot call hooks inside a hook */ + lua_unlock(L); + (*hook)(L, &ar); + lua_lock(L); + lua_assert(!L->allowhook); + L->allowhook = 1; + L->ci->top = restorestack(L, ci_top); + L->top = restorestack(L, top); + } +} + + +static StkId adjust_varargs (lua_State *L, Proto *p, int actual) { + int i; + int nfixargs = p->numparams; + Table *htab = NULL; + StkId base, fixed; + for (; actual < nfixargs; ++actual) + setnilvalue(L->top++); +#if defined(LUA_COMPAT_VARARG) + if (p->is_vararg & VARARG_NEEDSARG) { /* compat. with old-style vararg? */ + int nvar = actual - nfixargs; /* number of extra arguments */ + lua_assert(p->is_vararg & VARARG_HASARG); + luaC_checkGC(L); + htab = luaH_new(L, nvar, 1); /* create `arg' table */ + for (i=0; itop - nvar + i); + /* store counter in field `n' */ + setnvalue(luaH_setstr(L, htab, luaS_newliteral(L, "n")), cast_num(nvar)); + } +#endif + /* move fixed parameters to final position */ + fixed = L->top - actual; /* first fixed argument */ + base = L->top; /* final position of first argument */ + for (i=0; itop++, fixed+i); + setnilvalue(fixed+i); + } + /* add `arg' parameter */ + if (htab) { + sethvalue(L, L->top++, htab); + lua_assert(iswhite(obj2gco(htab))); + } + return base; +} + + +static StkId tryfuncTM (lua_State *L, StkId func) { + const TValue *tm = luaT_gettmbyobj(L, func, TM_CALL); + StkId p; + ptrdiff_t funcr = savestack(L, func); + if (!ttisfunction(tm)) + luaG_typeerror(L, func, "call"); + /* Open a hole inside the stack at `func' */ + for (p = L->top; p > func; p--) setobjs2s(L, p, p-1); + incr_top(L); + func = restorestack(L, funcr); /* previous call may change stack */ + setobj2s(L, func, tm); /* tag method is the new function to be called */ + return func; +} + + + +#define inc_ci(L) \ + ((L->ci == L->end_ci) ? growCI(L) : \ + (condhardstacktests(luaD_reallocCI(L, L->size_ci)), ++L->ci)) + + +int luaD_precall (lua_State *L, StkId func, int nresults) { + LClosure *cl; + ptrdiff_t funcr; + if (!ttisfunction(func)) /* `func' is not a function? */ + func = tryfuncTM(L, func); /* check the `function' tag method */ + funcr = savestack(L, func); + cl = &clvalue(func)->l; + L->ci->savedpc = L->savedpc; + if (!cl->isC) { /* Lua function? prepare its call */ + CallInfo *ci; + StkId st, base; + Proto *p = cl->p; + luaD_checkstack(L, p->maxstacksize); + func = restorestack(L, funcr); + if (!p->is_vararg) { /* no varargs? */ + base = func + 1; + if (L->top > base + p->numparams) + L->top = base + p->numparams; + } + else { /* vararg function */ + int nargs = cast_int(L->top - func) - 1; + base = adjust_varargs(L, p, nargs); + func = restorestack(L, funcr); /* previous call may change the stack */ + } + ci = inc_ci(L); /* now `enter' new function */ + ci->func = func; + L->base = ci->base = base; + ci->top = L->base + p->maxstacksize; + lua_assert(ci->top <= L->stack_last); + L->savedpc = p->code; /* starting point */ + ci->tailcalls = 0; + ci->nresults = nresults; + for (st = L->top; st < ci->top; st++) + setnilvalue(st); + L->top = ci->top; + if (L->hookmask & LUA_MASKCALL) { + L->savedpc++; /* hooks assume 'pc' is already incremented */ + luaD_callhook(L, LUA_HOOKCALL, -1); + L->savedpc--; /* correct 'pc' */ + } + return PCRLUA; + } + else { /* if is a C function, call it */ + CallInfo *ci; + int n; + luaD_checkstack(L, LUA_MINSTACK); /* ensure minimum stack size */ + ci = inc_ci(L); /* now `enter' new function */ + ci->func = restorestack(L, funcr); + L->base = ci->base = ci->func + 1; + ci->top = L->top + LUA_MINSTACK; + lua_assert(ci->top <= L->stack_last); + ci->nresults = nresults; + if (L->hookmask & LUA_MASKCALL) + luaD_callhook(L, LUA_HOOKCALL, -1); + lua_unlock(L); + n = (*curr_func(L)->c.f)(L); /* do the actual call */ + lua_lock(L); + if (n < 0) /* yielding? */ + return PCRYIELD; + else { + luaD_poscall(L, L->top - n); + return PCRC; + } + } +} + + +static StkId callrethooks (lua_State *L, StkId firstResult) { + ptrdiff_t fr = savestack(L, firstResult); /* next call may change stack */ + luaD_callhook(L, LUA_HOOKRET, -1); + if (f_isLua(L->ci)) { /* Lua function? */ + while ((L->hookmask & LUA_MASKRET) && L->ci->tailcalls--) /* tail calls */ + luaD_callhook(L, LUA_HOOKTAILRET, -1); + } + return restorestack(L, fr); +} + + +int luaD_poscall (lua_State *L, StkId firstResult) { + StkId res; + int wanted, i; + CallInfo *ci; + if (L->hookmask & LUA_MASKRET) + firstResult = callrethooks(L, firstResult); + ci = L->ci--; + res = ci->func; /* res == final position of 1st result */ + wanted = ci->nresults; + L->base = (ci - 1)->base; /* restore base */ + L->savedpc = (ci - 1)->savedpc; /* restore savedpc */ + /* move results to correct place */ + for (i = wanted; i != 0 && firstResult < L->top; i--) + setobjs2s(L, res++, firstResult++); + while (i-- > 0) + setnilvalue(res++); + L->top = res; + return (wanted - LUA_MULTRET); /* 0 iff wanted == LUA_MULTRET */ +} + + +/* +** Call a function (C or Lua). The function to be called is at *func. +** The arguments are on the stack, right after the function. +** When returns, all the results are on the stack, starting at the original +** function position. +*/ +void luaD_call (lua_State *L, StkId func, int nResults) { + if (++L->nCcalls >= LUAI_MAXCCALLS) { + if (L->nCcalls == LUAI_MAXCCALLS) + luaG_runerror(L, "C stack overflow"); + else if (L->nCcalls >= (LUAI_MAXCCALLS + (LUAI_MAXCCALLS>>3))) + luaD_throw(L, LUA_ERRERR); /* error while handing stack error */ + } + if (luaD_precall(L, func, nResults) == PCRLUA) /* is a Lua function? */ + luaV_execute(L, 1); /* call it */ + L->nCcalls--; + luaC_checkGC(L); +} + + +static void resume (lua_State *L, void *ud) { + StkId firstArg = cast(StkId, ud); + CallInfo *ci = L->ci; + if (L->status == 0) { /* start coroutine? */ + lua_assert(ci == L->base_ci && firstArg > L->base); + if (luaD_precall(L, firstArg - 1, LUA_MULTRET) != PCRLUA) + return; + } + else { /* resuming from previous yield */ + lua_assert(L->status == LUA_YIELD); + L->status = 0; + if (!f_isLua(ci)) { /* `common' yield? */ + /* finish interrupted execution of `OP_CALL' */ + lua_assert(GET_OPCODE(*((ci-1)->savedpc - 1)) == OP_CALL || + GET_OPCODE(*((ci-1)->savedpc - 1)) == OP_TAILCALL); + if (luaD_poscall(L, firstArg)) /* complete it... */ + L->top = L->ci->top; /* and correct top if not multiple results */ + } + else /* yielded inside a hook: just continue its execution */ + L->base = L->ci->base; + } + luaV_execute(L, cast_int(L->ci - L->base_ci)); +} + + +static int resume_error (lua_State *L, const char *msg) { + L->top = L->ci->base; + setsvalue2s(L, L->top, luaS_new(L, msg)); + incr_top(L); + lua_unlock(L); + return LUA_ERRRUN; +} + + +LUA_API int lua_resume (lua_State *L, int nargs) { + int status; + lua_lock(L); + if (L->status != LUA_YIELD && (L->status != 0 || L->ci != L->base_ci)) + return resume_error(L, "cannot resume non-suspended coroutine"); + if (L->nCcalls >= LUAI_MAXCCALLS) + return resume_error(L, "C stack overflow"); + luai_userstateresume(L, nargs); + lua_assert(L->errfunc == 0); + L->baseCcalls = ++L->nCcalls; + status = luaD_rawrunprotected(L, resume, L->top - nargs); + if (status != 0) { /* error? */ + L->status = cast_byte(status); /* mark thread as `dead' */ + luaD_seterrorobj(L, status, L->top); + L->ci->top = L->top; + } + else { + lua_assert(L->nCcalls == L->baseCcalls); + status = L->status; + } + --L->nCcalls; + lua_unlock(L); + return status; +} + + +LUA_API int lua_yield (lua_State *L, int nresults) { + luai_userstateyield(L, nresults); + lua_lock(L); + if (L->nCcalls > L->baseCcalls) + luaG_runerror(L, "attempt to yield across metamethod/C-call boundary"); + L->base = L->top - nresults; /* protect stack slots below */ + L->status = LUA_YIELD; + lua_unlock(L); + return -1; +} + + +#ifdef _JZ_LUA_CODE +LUA_API int lua_setconstlist(lua_State *L, lua_const *constlist) +{ + L->constlist = constlist; + return 0; +} +#endif + + +int luaD_pcall (lua_State *L, Pfunc func, void *u, + ptrdiff_t old_top, ptrdiff_t ef) { + int status; + unsigned short oldnCcalls = L->nCcalls; + ptrdiff_t old_ci = saveci(L, L->ci); + lu_byte old_allowhooks = L->allowhook; + ptrdiff_t old_errfunc = L->errfunc; + L->errfunc = ef; + status = luaD_rawrunprotected(L, func, u); + if (status != 0) { /* an error occurred? */ + StkId oldtop = restorestack(L, old_top); + luaF_close(L, oldtop); /* close eventual pending closures */ + luaD_seterrorobj(L, status, oldtop); + L->nCcalls = oldnCcalls; + L->ci = restoreci(L, old_ci); + L->base = L->ci->base; + L->savedpc = L->ci->savedpc; + L->allowhook = old_allowhooks; + restore_stack_limit(L); + } + L->errfunc = old_errfunc; + return status; +} + + + +/* +** Execute a protected parser. +*/ +struct SParser { /* data to `f_parser' */ + ZIO *z; + Mbuffer buff; /* buffer to be used by the scanner */ + const char *name; +}; + +static void f_parser (lua_State *L, void *ud) { + int i; + Proto *tf; + Closure *cl; + struct SParser *p = cast(struct SParser *, ud); + int c = luaZ_lookahead(p->z); + luaC_checkGC(L); + tf = ((c == LUA_SIGNATURE[0]) ? luaU_undump : luaY_parser)(L, p->z, + &p->buff, p->name); + cl = luaF_newLclosure(L, tf->nups, hvalue(gt(L))); + cl->l.p = tf; + for (i = 0; i < tf->nups; i++) /* initialize eventual upvalues */ + cl->l.upvals[i] = luaF_newupval(L); + setclvalue(L, L->top, cl); + incr_top(L); +} + + +int luaD_protectedparser (lua_State *L, ZIO *z, const char *name) { + struct SParser p; + int status; + p.z = z; p.name = name; + luaZ_initbuffer(L, &p.buff); + status = luaD_pcall(L, f_parser, &p, savestack(L, L->top), L->errfunc); + luaZ_freebuffer(L, &p.buff); + return status; +} + + diff --git a/lua/ldo.h b/lua/ldo.h new file mode 100644 index 0000000..98fddac --- /dev/null +++ b/lua/ldo.h @@ -0,0 +1,57 @@ +/* +** $Id: ldo.h,v 2.7.1.1 2007/12/27 13:02:25 roberto Exp $ +** Stack and Call structure of Lua +** See Copyright Notice in lua.h +*/ + +#ifndef ldo_h +#define ldo_h + + +#include "lobject.h" +#include "lstate.h" +#include "lzio.h" + + +#define luaD_checkstack(L,n) \ + if ((char *)L->stack_last - (char *)L->top <= (n)*(int)sizeof(TValue)) \ + luaD_growstack(L, n); \ + else condhardstacktests(luaD_reallocstack(L, L->stacksize - EXTRA_STACK - 1)); + + +#define incr_top(L) {luaD_checkstack(L,1); L->top++;} + +#define savestack(L,p) ((char *)(p) - (char *)L->stack) +#define restorestack(L,n) ((TValue *)((char *)L->stack + (n))) + +#define saveci(L,p) ((char *)(p) - (char *)L->base_ci) +#define restoreci(L,n) ((CallInfo *)((char *)L->base_ci + (n))) + + +/* results from luaD_precall */ +#define PCRLUA 0 /* initiated a call to a Lua function */ +#define PCRC 1 /* did a call to a C function */ +#define PCRYIELD 2 /* C funtion yielded */ + + +/* type of protected functions, to be ran by `runprotected' */ +typedef void (*Pfunc) (lua_State *L, void *ud); + +LUAI_FUNC int luaD_protectedparser (lua_State *L, ZIO *z, const char *name); +LUAI_FUNC void luaD_callhook (lua_State *L, int event, int line); +LUAI_FUNC int luaD_precall (lua_State *L, StkId func, int nresults); +LUAI_FUNC void luaD_call (lua_State *L, StkId func, int nResults); +LUAI_FUNC int luaD_pcall (lua_State *L, Pfunc func, void *u, + ptrdiff_t oldtop, ptrdiff_t ef); +LUAI_FUNC int luaD_poscall (lua_State *L, StkId firstResult); +LUAI_FUNC void luaD_reallocCI (lua_State *L, int newsize); +LUAI_FUNC void luaD_reallocstack (lua_State *L, int newsize); +LUAI_FUNC void luaD_growstack (lua_State *L, int n); + +LUAI_FUNC void luaD_throw (lua_State *L, int errcode); +LUAI_FUNC int luaD_rawrunprotected (lua_State *L, Pfunc f, void *ud); + +LUAI_FUNC void luaD_seterrorobj (lua_State *L, int errcode, StkId oldtop); + +#endif + diff --git a/lua/ldump.c b/lua/ldump.c new file mode 100644 index 0000000..c9d3d48 --- /dev/null +++ b/lua/ldump.c @@ -0,0 +1,164 @@ +/* +** $Id: ldump.c,v 2.8.1.1 2007/12/27 13:02:25 roberto Exp $ +** save precompiled Lua chunks +** See Copyright Notice in lua.h +*/ + +#include + +#define ldump_c +#define LUA_CORE + +#include "lua.h" + +#include "lobject.h" +#include "lstate.h" +#include "lundump.h" + +typedef struct { + lua_State* L; + lua_Writer writer; + void* data; + int strip; + int status; +} DumpState; + +#define DumpMem(b,n,size,D) DumpBlock(b,(n)*(size),D) +#define DumpVar(x,D) DumpMem(&x,1,sizeof(x),D) + +static void DumpBlock(const void* b, size_t size, DumpState* D) +{ + if (D->status==0) + { + lua_unlock(D->L); + D->status=(*D->writer)(D->L,b,size,D->data); + lua_lock(D->L); + } +} + +static void DumpChar(int y, DumpState* D) +{ + char x=(char)y; + DumpVar(x,D); +} + +static void DumpInt(int x, DumpState* D) +{ + DumpVar(x,D); +} + +static void DumpNumber(lua_Number x, DumpState* D) +{ + DumpVar(x,D); +} + +static void DumpVector(const void* b, int n, size_t size, DumpState* D) +{ + DumpInt(n,D); + DumpMem(b,n,size,D); +} + +static void DumpString(const TString* s, DumpState* D) +{ + if (s==NULL || getstr(s)==NULL) + { + size_t size=0; + DumpVar(size,D); + } + else + { + size_t size=s->tsv.len+1; /* include trailing '\0' */ + DumpVar(size,D); + DumpBlock(getstr(s),size,D); + } +} + +#define DumpCode(f,D) DumpVector(f->code,f->sizecode,sizeof(Instruction),D) + +static void DumpFunction(const Proto* f, const TString* p, DumpState* D); + +static void DumpConstants(const Proto* f, DumpState* D) +{ + int i,n=f->sizek; + DumpInt(n,D); + for (i=0; ik[i]; + DumpChar(ttype(o),D); + switch (ttype(o)) + { + case LUA_TNIL: + break; + case LUA_TBOOLEAN: + DumpChar(bvalue(o),D); + break; + case LUA_TNUMBER: + DumpNumber(nvalue(o),D); + break; + case LUA_TSTRING: + DumpString(rawtsvalue(o),D); + break; + default: + lua_assert(0); /* cannot happen */ + break; + } + } + n=f->sizep; + DumpInt(n,D); + for (i=0; ip[i],f->source,D); +} + +static void DumpDebug(const Proto* f, DumpState* D) +{ + int i,n; + n= (D->strip) ? 0 : f->sizelineinfo; + DumpVector(f->lineinfo,n,sizeof(int),D); + n= (D->strip) ? 0 : f->sizelocvars; + DumpInt(n,D); + for (i=0; ilocvars[i].varname,D); + DumpInt(f->locvars[i].startpc,D); + DumpInt(f->locvars[i].endpc,D); + } + n= (D->strip) ? 0 : f->sizeupvalues; + DumpInt(n,D); + for (i=0; iupvalues[i],D); +} + +static void DumpFunction(const Proto* f, const TString* p, DumpState* D) +{ + DumpString((f->source==p || D->strip) ? NULL : f->source,D); + DumpInt(f->linedefined,D); + DumpInt(f->lastlinedefined,D); + DumpChar(f->nups,D); + DumpChar(f->numparams,D); + DumpChar(f->is_vararg,D); + DumpChar(f->maxstacksize,D); + DumpCode(f,D); + DumpConstants(f,D); + DumpDebug(f,D); +} + +static void DumpHeader(DumpState* D) +{ + char h[LUAC_HEADERSIZE]; + luaU_header(h); + DumpBlock(h,LUAC_HEADERSIZE,D); +} + +/* +** dump Lua function as precompiled chunk +*/ +int luaU_dump (lua_State* L, const Proto* f, lua_Writer w, void* data, int strip) +{ + DumpState D; + D.L=L; + D.writer=w; + D.data=data; + D.strip=strip; + D.status=0; + DumpHeader(&D); + DumpFunction(f,NULL,&D); + return D.status; +} diff --git a/lua/lfunc.c b/lua/lfunc.c new file mode 100644 index 0000000..813e88f --- /dev/null +++ b/lua/lfunc.c @@ -0,0 +1,174 @@ +/* +** $Id: lfunc.c,v 2.12.1.2 2007/12/28 14:58:43 roberto Exp $ +** Auxiliary functions to manipulate prototypes and closures +** See Copyright Notice in lua.h +*/ + + +#include + +#define lfunc_c +#define LUA_CORE + +#include "lua.h" + +#include "lfunc.h" +#include "lgc.h" +#include "lmem.h" +#include "lobject.h" +#include "lstate.h" + + + +Closure *luaF_newCclosure (lua_State *L, int nelems, Table *e) { + Closure *c = cast(Closure *, luaM_malloc(L, sizeCclosure(nelems))); + luaC_link(L, obj2gco(c), LUA_TFUNCTION); + c->c.isC = 1; + c->c.env = e; + c->c.nupvalues = cast_byte(nelems); + return c; +} + + +Closure *luaF_newLclosure (lua_State *L, int nelems, Table *e) { + Closure *c = cast(Closure *, luaM_malloc(L, sizeLclosure(nelems))); + luaC_link(L, obj2gco(c), LUA_TFUNCTION); + c->l.isC = 0; + c->l.env = e; + c->l.nupvalues = cast_byte(nelems); + while (nelems--) c->l.upvals[nelems] = NULL; + return c; +} + + +UpVal *luaF_newupval (lua_State *L) { + UpVal *uv = luaM_new(L, UpVal); + luaC_link(L, obj2gco(uv), LUA_TUPVAL); + uv->v = &uv->u.value; + setnilvalue(uv->v); + return uv; +} + + +UpVal *luaF_findupval (lua_State *L, StkId level) { + global_State *g = G(L); + GCObject **pp = &L->openupval; + UpVal *p; + UpVal *uv; + while (*pp != NULL && (p = ngcotouv(*pp))->v >= level) { + lua_assert(p->v != &p->u.value); + if (p->v == level) { /* found a corresponding upvalue? */ + if (isdead(g, obj2gco(p))) /* is it dead? */ + changewhite(obj2gco(p)); /* ressurect it */ + return p; + } + pp = &p->next; + } + uv = luaM_new(L, UpVal); /* not found: create a new one */ + uv->tt = LUA_TUPVAL; + uv->marked = luaC_white(g); + uv->v = level; /* current value lives in the stack */ + uv->next = *pp; /* chain it in the proper position */ + *pp = obj2gco(uv); + uv->u.l.prev = &g->uvhead; /* double link it in `uvhead' list */ + uv->u.l.next = g->uvhead.u.l.next; + uv->u.l.next->u.l.prev = uv; + g->uvhead.u.l.next = uv; + lua_assert(uv->u.l.next->u.l.prev == uv && uv->u.l.prev->u.l.next == uv); + return uv; +} + + +static void unlinkupval (UpVal *uv) { + lua_assert(uv->u.l.next->u.l.prev == uv && uv->u.l.prev->u.l.next == uv); + uv->u.l.next->u.l.prev = uv->u.l.prev; /* remove from `uvhead' list */ + uv->u.l.prev->u.l.next = uv->u.l.next; +} + + +void luaF_freeupval (lua_State *L, UpVal *uv) { + if (uv->v != &uv->u.value) /* is it open? */ + unlinkupval(uv); /* remove from open list */ + luaM_free(L, uv); /* free upvalue */ +} + + +void luaF_close (lua_State *L, StkId level) { + UpVal *uv; + global_State *g = G(L); + while (L->openupval != NULL && (uv = ngcotouv(L->openupval))->v >= level) { + GCObject *o = obj2gco(uv); + lua_assert(!isblack(o) && uv->v != &uv->u.value); + L->openupval = uv->next; /* remove from `open' list */ + if (isdead(g, o)) + luaF_freeupval(L, uv); /* free upvalue */ + else { + unlinkupval(uv); + setobj(L, &uv->u.value, uv->v); + uv->v = &uv->u.value; /* now current value lives here */ + luaC_linkupval(L, uv); /* link upvalue into `gcroot' list */ + } + } +} + + +Proto *luaF_newproto (lua_State *L) { + Proto *f = luaM_new(L, Proto); + luaC_link(L, obj2gco(f), LUA_TPROTO); + f->k = NULL; + f->sizek = 0; + f->p = NULL; + f->sizep = 0; + f->code = NULL; + f->sizecode = 0; + f->sizelineinfo = 0; + f->sizeupvalues = 0; + f->nups = 0; + f->upvalues = NULL; + f->numparams = 0; + f->is_vararg = 0; + f->maxstacksize = 0; + f->lineinfo = NULL; + f->sizelocvars = 0; + f->locvars = NULL; + f->linedefined = 0; + f->lastlinedefined = 0; + f->source = NULL; + return f; +} + + +void luaF_freeproto (lua_State *L, Proto *f) { + luaM_freearray(L, f->code, f->sizecode, Instruction); + luaM_freearray(L, f->p, f->sizep, Proto *); + luaM_freearray(L, f->k, f->sizek, TValue); + luaM_freearray(L, f->lineinfo, f->sizelineinfo, int); + luaM_freearray(L, f->locvars, f->sizelocvars, struct LocVar); + luaM_freearray(L, f->upvalues, f->sizeupvalues, TString *); + luaM_free(L, f); +} + + +void luaF_freeclosure (lua_State *L, Closure *c) { + int size = (c->c.isC) ? sizeCclosure(c->c.nupvalues) : + sizeLclosure(c->l.nupvalues); + luaM_freemem(L, c, size); +} + + +/* +** Look for n-th local variable at line `line' in function `func'. +** Returns NULL if not found. +*/ +const char *luaF_getlocalname (const Proto *f, int local_number, int pc) { + int i; + for (i = 0; isizelocvars && f->locvars[i].startpc <= pc; i++) { + if (pc < f->locvars[i].endpc) { /* is variable active? */ + local_number--; + if (local_number == 0) + return getstr(f->locvars[i].varname); + } + } + return NULL; /* not found */ +} + diff --git a/lua/lfunc.h b/lua/lfunc.h new file mode 100644 index 0000000..a68cf51 --- /dev/null +++ b/lua/lfunc.h @@ -0,0 +1,34 @@ +/* +** $Id: lfunc.h,v 2.4.1.1 2007/12/27 13:02:25 roberto Exp $ +** Auxiliary functions to manipulate prototypes and closures +** See Copyright Notice in lua.h +*/ + +#ifndef lfunc_h +#define lfunc_h + + +#include "lobject.h" + + +#define sizeCclosure(n) (cast(int, sizeof(CClosure)) + \ + cast(int, sizeof(TValue)*((n)-1))) + +#define sizeLclosure(n) (cast(int, sizeof(LClosure)) + \ + cast(int, sizeof(TValue *)*((n)-1))) + + +LUAI_FUNC Proto *luaF_newproto (lua_State *L); +LUAI_FUNC Closure *luaF_newCclosure (lua_State *L, int nelems, Table *e); +LUAI_FUNC Closure *luaF_newLclosure (lua_State *L, int nelems, Table *e); +LUAI_FUNC UpVal *luaF_newupval (lua_State *L); +LUAI_FUNC UpVal *luaF_findupval (lua_State *L, StkId level); +LUAI_FUNC void luaF_close (lua_State *L, StkId level); +LUAI_FUNC void luaF_freeproto (lua_State *L, Proto *f); +LUAI_FUNC void luaF_freeclosure (lua_State *L, Closure *c); +LUAI_FUNC void luaF_freeupval (lua_State *L, UpVal *uv); +LUAI_FUNC const char *luaF_getlocalname (const Proto *func, int local_number, + int pc); + + +#endif diff --git a/lua/lgc.c b/lua/lgc.c new file mode 100644 index 0000000..d9e0b78 --- /dev/null +++ b/lua/lgc.c @@ -0,0 +1,711 @@ +/* +** $Id: lgc.c,v 2.38.1.1 2007/12/27 13:02:25 roberto Exp $ +** Garbage Collector +** See Copyright Notice in lua.h +*/ + +#include + +#define lgc_c +#define LUA_CORE + +#include "lua.h" + +#include "ldebug.h" +#include "ldo.h" +#include "lfunc.h" +#include "lgc.h" +#include "lmem.h" +#include "lobject.h" +#include "lstate.h" +#include "lstring.h" +#include "ltable.h" +#include "ltm.h" + + +#define GCSTEPSIZE 1024u +#define GCSWEEPMAX 40 +#define GCSWEEPCOST 10 +#define GCFINALIZECOST 100 + + +#define maskmarks cast_byte(~(bitmask(BLACKBIT)|WHITEBITS)) + +#define makewhite(g,x) \ + ((x)->gch.marked = cast_byte(((x)->gch.marked & maskmarks) | luaC_white(g))) + +#define white2gray(x) reset2bits((x)->gch.marked, WHITE0BIT, WHITE1BIT) +#define black2gray(x) resetbit((x)->gch.marked, BLACKBIT) + +#define stringmark(s) reset2bits((s)->tsv.marked, WHITE0BIT, WHITE1BIT) + + +#define isfinalized(u) testbit((u)->marked, FINALIZEDBIT) +#define markfinalized(u) l_setbit((u)->marked, FINALIZEDBIT) + + +#define KEYWEAK bitmask(KEYWEAKBIT) +#define VALUEWEAK bitmask(VALUEWEAKBIT) + + + +#define markvalue(g,o) { checkconsistency(o); \ + if (iscollectable(o) && iswhite(gcvalue(o))) reallymarkobject(g,gcvalue(o)); } + +#define markobject(g,t) { if (iswhite(obj2gco(t))) \ + reallymarkobject(g, obj2gco(t)); } + + +#define setthreshold(g) (g->GCthreshold = (g->estimate/100) * g->gcpause) + + +static void removeentry (Node *n) { + lua_assert(ttisnil(gval(n))); + if (iscollectable(gkey(n))) + setttype(gkey(n), LUA_TDEADKEY); /* dead key; remove it */ +} + + +static void reallymarkobject (global_State *g, GCObject *o) { + lua_assert(iswhite(o) && !isdead(g, o)); + white2gray(o); + switch (o->gch.tt) { + case LUA_TSTRING: { + return; + } + case LUA_TUSERDATA: { + Table *mt = gco2u(o)->metatable; + gray2black(o); /* udata are never gray */ + if (mt) markobject(g, mt); + markobject(g, gco2u(o)->env); + return; + } + case LUA_TUPVAL: { + UpVal *uv = gco2uv(o); + markvalue(g, uv->v); + if (uv->v == &uv->u.value) /* closed? */ + gray2black(o); /* open upvalues are never black */ + return; + } + case LUA_TFUNCTION: { + gco2cl(o)->c.gclist = g->gray; + g->gray = o; + break; + } + case LUA_TTABLE: { + gco2h(o)->gclist = g->gray; + g->gray = o; + break; + } + case LUA_TTHREAD: { + gco2th(o)->gclist = g->gray; + g->gray = o; + break; + } + case LUA_TPROTO: { + gco2p(o)->gclist = g->gray; + g->gray = o; + break; + } + default: lua_assert(0); + } +} + + +static void marktmu (global_State *g) { + GCObject *u = g->tmudata; + if (u) { + do { + u = u->gch.next; + makewhite(g, u); /* may be marked, if left from previous GC */ + reallymarkobject(g, u); + } while (u != g->tmudata); + } +} + + +/* move `dead' udata that need finalization to list `tmudata' */ +size_t luaC_separateudata (lua_State *L, int all) { + global_State *g = G(L); + size_t deadmem = 0; + GCObject **p = &g->mainthread->next; + GCObject *curr; + while ((curr = *p) != NULL) { + if (!(iswhite(curr) || all) || isfinalized(gco2u(curr))) + p = &curr->gch.next; /* don't bother with them */ + else if (fasttm(L, gco2u(curr)->metatable, TM_GC) == NULL) { + markfinalized(gco2u(curr)); /* don't need finalization */ + p = &curr->gch.next; + } + else { /* must call its gc method */ + deadmem += sizeudata(gco2u(curr)); + markfinalized(gco2u(curr)); + *p = curr->gch.next; + /* link `curr' at the end of `tmudata' list */ + if (g->tmudata == NULL) /* list is empty? */ + g->tmudata = curr->gch.next = curr; /* creates a circular list */ + else { + curr->gch.next = g->tmudata->gch.next; + g->tmudata->gch.next = curr; + g->tmudata = curr; + } + } + } + return deadmem; +} + + +static int traversetable (global_State *g, Table *h) { + int i; + int weakkey = 0; + int weakvalue = 0; + const TValue *mode; + if (h->metatable) + markobject(g, h->metatable); + mode = gfasttm(g, h->metatable, TM_MODE); + if (mode && ttisstring(mode)) { /* is there a weak mode? */ + weakkey = (strchr(svalue(mode), 'k') != NULL); + weakvalue = (strchr(svalue(mode), 'v') != NULL); + if (weakkey || weakvalue) { /* is really weak? */ + h->marked &= ~(KEYWEAK | VALUEWEAK); /* clear bits */ + h->marked |= cast_byte((weakkey << KEYWEAKBIT) | + (weakvalue << VALUEWEAKBIT)); + h->gclist = g->weak; /* must be cleared after GC, ... */ + g->weak = obj2gco(h); /* ... so put in the appropriate list */ + } + } + if (weakkey && weakvalue) return 1; + if (!weakvalue) { + i = h->sizearray; + while (i--) + markvalue(g, &h->array[i]); + } + i = sizenode(h); + while (i--) { + Node *n = gnode(h, i); + lua_assert(ttype(gkey(n)) != LUA_TDEADKEY || ttisnil(gval(n))); + if (ttisnil(gval(n))) + removeentry(n); /* remove empty entries */ + else { + lua_assert(!ttisnil(gkey(n))); + if (!weakkey) markvalue(g, gkey(n)); + if (!weakvalue) markvalue(g, gval(n)); + } + } + return weakkey || weakvalue; +} + + +/* +** All marks are conditional because a GC may happen while the +** prototype is still being created +*/ +static void traverseproto (global_State *g, Proto *f) { + int i; + if (f->source) stringmark(f->source); + for (i=0; isizek; i++) /* mark literals */ + markvalue(g, &f->k[i]); + for (i=0; isizeupvalues; i++) { /* mark upvalue names */ + if (f->upvalues[i]) + stringmark(f->upvalues[i]); + } + for (i=0; isizep; i++) { /* mark nested protos */ + if (f->p[i]) + markobject(g, f->p[i]); + } + for (i=0; isizelocvars; i++) { /* mark local-variable names */ + if (f->locvars[i].varname) + stringmark(f->locvars[i].varname); + } +} + + + +static void traverseclosure (global_State *g, Closure *cl) { + markobject(g, cl->c.env); + if (cl->c.isC) { + int i; + for (i=0; ic.nupvalues; i++) /* mark its upvalues */ + markvalue(g, &cl->c.upvalue[i]); + } + else { + int i; + lua_assert(cl->l.nupvalues == cl->l.p->nups); + markobject(g, cl->l.p); + for (i=0; il.nupvalues; i++) /* mark its upvalues */ + markobject(g, cl->l.upvals[i]); + } +} + + +static void checkstacksizes (lua_State *L, StkId max) { + int ci_used = cast_int(L->ci - L->base_ci); /* number of `ci' in use */ + int s_used = cast_int(max - L->stack); /* part of stack in use */ + if (L->size_ci > LUAI_MAXCALLS) /* handling overflow? */ + return; /* do not touch the stacks */ + if (4*ci_used < L->size_ci && 2*BASIC_CI_SIZE < L->size_ci) + luaD_reallocCI(L, L->size_ci/2); /* still big enough... */ + condhardstacktests(luaD_reallocCI(L, ci_used + 1)); + if (4*s_used < L->stacksize && + 2*(BASIC_STACK_SIZE+EXTRA_STACK) < L->stacksize) + luaD_reallocstack(L, L->stacksize/2); /* still big enough... */ + condhardstacktests(luaD_reallocstack(L, s_used)); +} + + +static void traversestack (global_State *g, lua_State *l) { + StkId o, lim; + CallInfo *ci; + markvalue(g, gt(l)); + lim = l->top; + for (ci = l->base_ci; ci <= l->ci; ci++) { + lua_assert(ci->top <= l->stack_last); + if (lim < ci->top) lim = ci->top; + } + for (o = l->stack; o < l->top; o++) + markvalue(g, o); + for (; o <= lim; o++) + setnilvalue(o); + checkstacksizes(l, lim); +} + + +/* +** traverse one gray object, turning it to black. +** Returns `quantity' traversed. +*/ +static l_mem propagatemark (global_State *g) { + GCObject *o = g->gray; + lua_assert(isgray(o)); + gray2black(o); + switch (o->gch.tt) { + case LUA_TTABLE: { + Table *h = gco2h(o); + g->gray = h->gclist; + if (traversetable(g, h)) /* table is weak? */ + black2gray(o); /* keep it gray */ + return sizeof(Table) + sizeof(TValue) * h->sizearray + + sizeof(Node) * sizenode(h); + } + case LUA_TFUNCTION: { + Closure *cl = gco2cl(o); + g->gray = cl->c.gclist; + traverseclosure(g, cl); + return (cl->c.isC) ? sizeCclosure(cl->c.nupvalues) : + sizeLclosure(cl->l.nupvalues); + } + case LUA_TTHREAD: { + lua_State *th = gco2th(o); + g->gray = th->gclist; + th->gclist = g->grayagain; + g->grayagain = o; + black2gray(o); + traversestack(g, th); + return sizeof(lua_State) + sizeof(TValue) * th->stacksize + + sizeof(CallInfo) * th->size_ci; + } + case LUA_TPROTO: { + Proto *p = gco2p(o); + g->gray = p->gclist; + traverseproto(g, p); + return sizeof(Proto) + sizeof(Instruction) * p->sizecode + + sizeof(Proto *) * p->sizep + + sizeof(TValue) * p->sizek + + sizeof(int) * p->sizelineinfo + + sizeof(LocVar) * p->sizelocvars + + sizeof(TString *) * p->sizeupvalues; + } + default: lua_assert(0); return 0; + } +} + + +static size_t propagateall (global_State *g) { + size_t m = 0; + while (g->gray) m += propagatemark(g); + return m; +} + + +/* +** The next function tells whether a key or value can be cleared from +** a weak table. Non-collectable objects are never removed from weak +** tables. Strings behave as `values', so are never removed too. for +** other objects: if really collected, cannot keep them; for userdata +** being finalized, keep them in keys, but not in values +*/ +static int iscleared (const TValue *o, int iskey) { + if (!iscollectable(o)) return 0; + if (ttisstring(o)) { + stringmark(rawtsvalue(o)); /* strings are `values', so are never weak */ + return 0; + } + return iswhite(gcvalue(o)) || + (ttisuserdata(o) && (!iskey && isfinalized(uvalue(o)))); +} + + +/* +** clear collected entries from weaktables +*/ +static void cleartable (GCObject *l) { + while (l) { + Table *h = gco2h(l); + int i = h->sizearray; + lua_assert(testbit(h->marked, VALUEWEAKBIT) || + testbit(h->marked, KEYWEAKBIT)); + if (testbit(h->marked, VALUEWEAKBIT)) { + while (i--) { + TValue *o = &h->array[i]; + if (iscleared(o, 0)) /* value was collected? */ + setnilvalue(o); /* remove value */ + } + } + i = sizenode(h); + while (i--) { + Node *n = gnode(h, i); + if (!ttisnil(gval(n)) && /* non-empty entry? */ + (iscleared(key2tval(n), 1) || iscleared(gval(n), 0))) { + setnilvalue(gval(n)); /* remove value ... */ + removeentry(n); /* remove entry from table */ + } + } + l = h->gclist; + } +} + + +static void freeobj (lua_State *L, GCObject *o) { + switch (o->gch.tt) { + case LUA_TPROTO: luaF_freeproto(L, gco2p(o)); break; + case LUA_TFUNCTION: luaF_freeclosure(L, gco2cl(o)); break; + case LUA_TUPVAL: luaF_freeupval(L, gco2uv(o)); break; + case LUA_TTABLE: luaH_free(L, gco2h(o)); break; + case LUA_TTHREAD: { + lua_assert(gco2th(o) != L && gco2th(o) != G(L)->mainthread); + luaE_freethread(L, gco2th(o)); + break; + } + case LUA_TSTRING: { + G(L)->strt.nuse--; + luaM_freemem(L, o, sizestring(gco2ts(o))); + break; + } + case LUA_TUSERDATA: { + luaM_freemem(L, o, sizeudata(gco2u(o))); + break; + } + default: lua_assert(0); + } +} + + + +#define sweepwholelist(L,p) sweeplist(L,p,MAX_LUMEM) + + +static GCObject **sweeplist (lua_State *L, GCObject **p, lu_mem count) { + GCObject *curr; + global_State *g = G(L); + int deadmask = otherwhite(g); + while ((curr = *p) != NULL && count-- > 0) { + if (curr->gch.tt == LUA_TTHREAD) /* sweep open upvalues of each thread */ + sweepwholelist(L, &gco2th(curr)->openupval); + if ((curr->gch.marked ^ WHITEBITS) & deadmask) { /* not dead? */ + lua_assert(!isdead(g, curr) || testbit(curr->gch.marked, FIXEDBIT)); + makewhite(g, curr); /* make it white (for next cycle) */ + p = &curr->gch.next; + } + else { /* must erase `curr' */ + lua_assert(isdead(g, curr) || deadmask == bitmask(SFIXEDBIT)); + *p = curr->gch.next; + if (curr == g->rootgc) /* is the first element of the list? */ + g->rootgc = curr->gch.next; /* adjust first */ + freeobj(L, curr); + } + } + return p; +} + + +static void checkSizes (lua_State *L) { + global_State *g = G(L); + /* check size of string hash */ + if (g->strt.nuse < cast(lu_int32, g->strt.size/4) && + g->strt.size > MINSTRTABSIZE*2) + luaS_resize(L, g->strt.size/2); /* table is too big */ + /* check size of buffer */ + if (luaZ_sizebuffer(&g->buff) > LUA_MINBUFFER*2) { /* buffer too big? */ + size_t newsize = luaZ_sizebuffer(&g->buff) / 2; + luaZ_resizebuffer(L, &g->buff, newsize); + } +} + + +static void GCTM (lua_State *L) { + global_State *g = G(L); + GCObject *o = g->tmudata->gch.next; /* get first element */ + Udata *udata = rawgco2u(o); + const TValue *tm; + /* remove udata from `tmudata' */ + if (o == g->tmudata) /* last element? */ + g->tmudata = NULL; + else + g->tmudata->gch.next = udata->uv.next; + udata->uv.next = g->mainthread->next; /* return it to `root' list */ + g->mainthread->next = o; + makewhite(g, o); + tm = fasttm(L, udata->uv.metatable, TM_GC); + if (tm != NULL) { + lu_byte oldah = L->allowhook; + lu_mem oldt = g->GCthreshold; + L->allowhook = 0; /* stop debug hooks during GC tag method */ + g->GCthreshold = 2*g->totalbytes; /* avoid GC steps */ + setobj2s(L, L->top, tm); + setuvalue(L, L->top+1, udata); + L->top += 2; + luaD_call(L, L->top - 2, 0); + L->allowhook = oldah; /* restore hooks */ + g->GCthreshold = oldt; /* restore threshold */ + } +} + + +/* +** Call all GC tag methods +*/ +void luaC_callGCTM (lua_State *L) { + while (G(L)->tmudata) + GCTM(L); +} + + +void luaC_freeall (lua_State *L) { + global_State *g = G(L); + int i; + g->currentwhite = WHITEBITS | bitmask(SFIXEDBIT); /* mask to collect all elements */ + sweepwholelist(L, &g->rootgc); + for (i = 0; i < g->strt.size; i++) /* free all string lists */ + sweepwholelist(L, &g->strt.hash[i]); +} + + +static void markmt (global_State *g) { + int i; + for (i=0; imt[i]) markobject(g, g->mt[i]); +} + + +/* mark root set */ +static void markroot (lua_State *L) { + global_State *g = G(L); + g->gray = NULL; + g->grayagain = NULL; + g->weak = NULL; + markobject(g, g->mainthread); + /* make global table be traversed before main stack */ + markvalue(g, gt(g->mainthread)); + markvalue(g, registry(L)); + markmt(g); + g->gcstate = GCSpropagate; +} + + +static void remarkupvals (global_State *g) { + UpVal *uv; + for (uv = g->uvhead.u.l.next; uv != &g->uvhead; uv = uv->u.l.next) { + lua_assert(uv->u.l.next->u.l.prev == uv && uv->u.l.prev->u.l.next == uv); + if (isgray(obj2gco(uv))) + markvalue(g, uv->v); + } +} + + +static void atomic (lua_State *L) { + global_State *g = G(L); + size_t udsize; /* total size of userdata to be finalized */ + /* remark occasional upvalues of (maybe) dead threads */ + remarkupvals(g); + /* traverse objects cautch by write barrier and by 'remarkupvals' */ + propagateall(g); + /* remark weak tables */ + g->gray = g->weak; + g->weak = NULL; + lua_assert(!iswhite(obj2gco(g->mainthread))); + markobject(g, L); /* mark running thread */ + markmt(g); /* mark basic metatables (again) */ + propagateall(g); + /* remark gray again */ + g->gray = g->grayagain; + g->grayagain = NULL; + propagateall(g); + udsize = luaC_separateudata(L, 0); /* separate userdata to be finalized */ + marktmu(g); /* mark `preserved' userdata */ + udsize += propagateall(g); /* remark, to propagate `preserveness' */ + cleartable(g->weak); /* remove collected objects from weak tables */ + /* flip current white */ + g->currentwhite = cast_byte(otherwhite(g)); + g->sweepstrgc = 0; + g->sweepgc = &g->rootgc; + g->gcstate = GCSsweepstring; + g->estimate = g->totalbytes - udsize; /* first estimate */ +} + + +static l_mem singlestep (lua_State *L) { + global_State *g = G(L); + /*lua_checkmemory(L);*/ + switch (g->gcstate) { + case GCSpause: { + markroot(L); /* start a new collection */ + return 0; + } + case GCSpropagate: { + if (g->gray) + return propagatemark(g); + else { /* no more `gray' objects */ + atomic(L); /* finish mark phase */ + return 0; + } + } + case GCSsweepstring: { + lu_mem old = g->totalbytes; + sweepwholelist(L, &g->strt.hash[g->sweepstrgc++]); + if (g->sweepstrgc >= g->strt.size) /* nothing more to sweep? */ + g->gcstate = GCSsweep; /* end sweep-string phase */ + lua_assert(old >= g->totalbytes); + g->estimate -= old - g->totalbytes; + return GCSWEEPCOST; + } + case GCSsweep: { + lu_mem old = g->totalbytes; + g->sweepgc = sweeplist(L, g->sweepgc, GCSWEEPMAX); + if (*g->sweepgc == NULL) { /* nothing more to sweep? */ + checkSizes(L); + g->gcstate = GCSfinalize; /* end sweep phase */ + } + lua_assert(old >= g->totalbytes); + g->estimate -= old - g->totalbytes; + return GCSWEEPMAX*GCSWEEPCOST; + } + case GCSfinalize: { + if (g->tmudata) { + GCTM(L); + if (g->estimate > GCFINALIZECOST) + g->estimate -= GCFINALIZECOST; + return GCFINALIZECOST; + } + else { + g->gcstate = GCSpause; /* end collection */ + g->gcdept = 0; + return 0; + } + } + default: lua_assert(0); return 0; + } +} + + +void luaC_step (lua_State *L) { + global_State *g = G(L); + l_mem lim = (GCSTEPSIZE/100) * g->gcstepmul; + if (lim == 0) + lim = (MAX_LUMEM-1)/2; /* no limit */ + g->gcdept += g->totalbytes - g->GCthreshold; + do { + lim -= singlestep(L); + if (g->gcstate == GCSpause) + break; + } while (lim > 0); + if (g->gcstate != GCSpause) { + if (g->gcdept < GCSTEPSIZE) + g->GCthreshold = g->totalbytes + GCSTEPSIZE; /* - lim/g->gcstepmul;*/ + else { + g->gcdept -= GCSTEPSIZE; + g->GCthreshold = g->totalbytes; + } + } + else { + lua_assert(g->totalbytes >= g->estimate); + setthreshold(g); + } +} + + +void luaC_fullgc (lua_State *L) { + global_State *g = G(L); + if (g->gcstate <= GCSpropagate) { + /* reset sweep marks to sweep all elements (returning them to white) */ + g->sweepstrgc = 0; + g->sweepgc = &g->rootgc; + /* reset other collector lists */ + g->gray = NULL; + g->grayagain = NULL; + g->weak = NULL; + g->gcstate = GCSsweepstring; + } + lua_assert(g->gcstate != GCSpause && g->gcstate != GCSpropagate); + /* finish any pending sweep phase */ + while (g->gcstate != GCSfinalize) { + lua_assert(g->gcstate == GCSsweepstring || g->gcstate == GCSsweep); + singlestep(L); + } + markroot(L); + while (g->gcstate != GCSpause) { + singlestep(L); + } + setthreshold(g); +} + + +void luaC_barrierf (lua_State *L, GCObject *o, GCObject *v) { + global_State *g = G(L); + lua_assert(isblack(o) && iswhite(v) && !isdead(g, v) && !isdead(g, o)); + lua_assert(g->gcstate != GCSfinalize && g->gcstate != GCSpause); + lua_assert(ttype(&o->gch) != LUA_TTABLE); + /* must keep invariant? */ + if (g->gcstate == GCSpropagate) + reallymarkobject(g, v); /* restore invariant */ + else /* don't mind */ + makewhite(g, o); /* mark as white just to avoid other barriers */ +} + + +void luaC_barrierback (lua_State *L, Table *t) { + global_State *g = G(L); + GCObject *o = obj2gco(t); + lua_assert(isblack(o) && !isdead(g, o)); + lua_assert(g->gcstate != GCSfinalize && g->gcstate != GCSpause); + black2gray(o); /* make table gray (again) */ + t->gclist = g->grayagain; + g->grayagain = o; +} + + +void luaC_link (lua_State *L, GCObject *o, lu_byte tt) { + global_State *g = G(L); + o->gch.next = g->rootgc; + g->rootgc = o; + o->gch.marked = luaC_white(g); + o->gch.tt = tt; +} + + +void luaC_linkupval (lua_State *L, UpVal *uv) { + global_State *g = G(L); + GCObject *o = obj2gco(uv); + o->gch.next = g->rootgc; /* link upvalue into `rootgc' list */ + g->rootgc = o; + if (isgray(o)) { + if (g->gcstate == GCSpropagate) { + gray2black(o); /* closed upvalues need barrier */ + luaC_barrier(L, uv, uv->v); + } + else { /* sweep phase: sweep it (turning it into white) */ + makewhite(g, o); + lua_assert(g->gcstate != GCSfinalize && g->gcstate != GCSpause); + } + } +} + diff --git a/lua/lgc.h b/lua/lgc.h new file mode 100644 index 0000000..5a8dc60 --- /dev/null +++ b/lua/lgc.h @@ -0,0 +1,110 @@ +/* +** $Id: lgc.h,v 2.15.1.1 2007/12/27 13:02:25 roberto Exp $ +** Garbage Collector +** See Copyright Notice in lua.h +*/ + +#ifndef lgc_h +#define lgc_h + + +#include "lobject.h" + + +/* +** Possible states of the Garbage Collector +*/ +#define GCSpause 0 +#define GCSpropagate 1 +#define GCSsweepstring 2 +#define GCSsweep 3 +#define GCSfinalize 4 + + +/* +** some userful bit tricks +*/ +#define resetbits(x,m) ((x) &= cast(lu_byte, ~(m))) +#define setbits(x,m) ((x) |= (m)) +#define testbits(x,m) ((x) & (m)) +#define bitmask(b) (1<<(b)) +#define bit2mask(b1,b2) (bitmask(b1) | bitmask(b2)) +#define l_setbit(x,b) setbits(x, bitmask(b)) +#define resetbit(x,b) resetbits(x, bitmask(b)) +#define testbit(x,b) testbits(x, bitmask(b)) +#define set2bits(x,b1,b2) setbits(x, (bit2mask(b1, b2))) +#define reset2bits(x,b1,b2) resetbits(x, (bit2mask(b1, b2))) +#define test2bits(x,b1,b2) testbits(x, (bit2mask(b1, b2))) + + + +/* +** Layout for bit use in `marked' field: +** bit 0 - object is white (type 0) +** bit 1 - object is white (type 1) +** bit 2 - object is black +** bit 3 - for userdata: has been finalized +** bit 3 - for tables: has weak keys +** bit 4 - for tables: has weak values +** bit 5 - object is fixed (should not be collected) +** bit 6 - object is "super" fixed (only the main thread) +*/ + + +#define WHITE0BIT 0 +#define WHITE1BIT 1 +#define BLACKBIT 2 +#define FINALIZEDBIT 3 +#define KEYWEAKBIT 3 +#define VALUEWEAKBIT 4 +#define FIXEDBIT 5 +#define SFIXEDBIT 6 +#define WHITEBITS bit2mask(WHITE0BIT, WHITE1BIT) + + +#define iswhite(x) test2bits((x)->gch.marked, WHITE0BIT, WHITE1BIT) +#define isblack(x) testbit((x)->gch.marked, BLACKBIT) +#define isgray(x) (!isblack(x) && !iswhite(x)) + +#define otherwhite(g) (g->currentwhite ^ WHITEBITS) +#define isdead(g,v) ((v)->gch.marked & otherwhite(g) & WHITEBITS) + +#define changewhite(x) ((x)->gch.marked ^= WHITEBITS) +#define gray2black(x) l_setbit((x)->gch.marked, BLACKBIT) + +#define valiswhite(x) (iscollectable(x) && iswhite(gcvalue(x))) + +#define luaC_white(g) cast(lu_byte, (g)->currentwhite & WHITEBITS) + + +#define luaC_checkGC(L) { \ + condhardstacktests(luaD_reallocstack(L, L->stacksize - EXTRA_STACK - 1)); \ + if (G(L)->totalbytes >= G(L)->GCthreshold) \ + luaC_step(L); } + + +#define luaC_barrier(L,p,v) { if (valiswhite(v) && isblack(obj2gco(p))) \ + luaC_barrierf(L,obj2gco(p),gcvalue(v)); } + +#define luaC_barriert(L,t,v) { if (valiswhite(v) && isblack(obj2gco(t))) \ + luaC_barrierback(L,t); } + +#define luaC_objbarrier(L,p,o) \ + { if (iswhite(obj2gco(o)) && isblack(obj2gco(p))) \ + luaC_barrierf(L,obj2gco(p),obj2gco(o)); } + +#define luaC_objbarriert(L,t,o) \ + { if (iswhite(obj2gco(o)) && isblack(obj2gco(t))) luaC_barrierback(L,t); } + +LUAI_FUNC size_t luaC_separateudata (lua_State *L, int all); +LUAI_FUNC void luaC_callGCTM (lua_State *L); +LUAI_FUNC void luaC_freeall (lua_State *L); +LUAI_FUNC void luaC_step (lua_State *L); +LUAI_FUNC void luaC_fullgc (lua_State *L); +LUAI_FUNC void luaC_link (lua_State *L, GCObject *o, lu_byte tt); +LUAI_FUNC void luaC_linkupval (lua_State *L, UpVal *uv); +LUAI_FUNC void luaC_barrierf (lua_State *L, GCObject *o, GCObject *v); +LUAI_FUNC void luaC_barrierback (lua_State *L, Table *t); + + +#endif diff --git a/lua/linit.c b/lua/linit.c new file mode 100644 index 0000000..16c72ac --- /dev/null +++ b/lua/linit.c @@ -0,0 +1,37 @@ +/* +** $Id: linit.c,v 1.14.1.1 2007/12/27 13:02:25 roberto Exp $ +** Initialization of libraries for lua.c +** See Copyright Notice in lua.h +*/ + + +#define linit_c +#define LUA_LIB + +#include "lua.h" + +#include "lualib.h" +#include "lauxlib.h" + + +static const luaL_Reg lualibs[] = { + {"", luaopen_base}, + {LUA_LOADLIBNAME, luaopen_package}, + {LUA_TABLIBNAME, luaopen_table}, + {LUA_IOLIBNAME, luaopen_io}, + {LUA_OSLIBNAME, luaopen_os}, + {LUA_STRLIBNAME, luaopen_string}, + {LUA_MATHLIBNAME, luaopen_math}, + {LUA_DBLIBNAME, luaopen_debug}, + {NULL, NULL} +}; + + +LUALIB_API void luaL_openlibs (lua_State *L) { + const luaL_Reg *lib = lualibs; + for (; lib->func; lib++) { + lua_pushcfunction(L, lib->func); + lua_pushstring(L, lib->name); + lua_call(L, 1, 0); + } +} diff --git a/lua/liolib.c b/lua/liolib.c new file mode 100644 index 0000000..e79ed1c --- /dev/null +++ b/lua/liolib.c @@ -0,0 +1,553 @@ +/* +** $Id: liolib.c,v 2.73.1.3 2008/01/18 17:47:43 roberto Exp $ +** Standard I/O (and system) library +** See Copyright Notice in lua.h +*/ + + +#include +#include +#include +#include + +#define liolib_c +#define LUA_LIB + +#include "lua.h" + +#include "lauxlib.h" +#include "lualib.h" + + + +#define IO_INPUT 1 +#define IO_OUTPUT 2 + + +static const char *const fnames[] = {"input", "output"}; + + +static int pushresult (lua_State *L, int i, const char *filename) { + int en = errno; /* calls to Lua API may change this value */ + if (i) { + lua_pushboolean(L, 1); + return 1; + } + else { + lua_pushnil(L); + if (filename) + lua_pushfstring(L, "%s: %s", filename, strerror(en)); + else + lua_pushfstring(L, "%s", strerror(en)); + lua_pushinteger(L, en); + return 3; + } +} + + +static void fileerror (lua_State *L, int arg, const char *filename) { + lua_pushfstring(L, "%s: %s", filename, strerror(errno)); + luaL_argerror(L, arg, lua_tostring(L, -1)); +} + + +#define tofilep(L) ((FILE **)luaL_checkudata(L, 1, LUA_FILEHANDLE)) + + +static int io_type (lua_State *L) { + void *ud; + luaL_checkany(L, 1); + ud = lua_touserdata(L, 1); + lua_getfield(L, LUA_REGISTRYINDEX, LUA_FILEHANDLE); + if (ud == NULL || !lua_getmetatable(L, 1) || !lua_rawequal(L, -2, -1)) + lua_pushnil(L); /* not a file */ + else if (*((FILE **)ud) == NULL) + lua_pushliteral(L, "closed file"); + else + lua_pushliteral(L, "file"); + return 1; +} + + +static FILE *tofile (lua_State *L) { + FILE **f = tofilep(L); + if (*f == NULL) + luaL_error(L, "attempt to use a closed file"); + return *f; +} + + + +/* +** When creating file handles, always creates a `closed' file handle +** before opening the actual file; so, if there is a memory error, the +** file is not left opened. +*/ +static FILE **newfile (lua_State *L) { + FILE **pf = (FILE **)lua_newuserdata(L, sizeof(FILE *)); + *pf = NULL; /* file handle is currently `closed' */ + luaL_getmetatable(L, LUA_FILEHANDLE); + lua_setmetatable(L, -2); + return pf; +} + + +/* +** function to (not) close the standard files stdin, stdout, and stderr +*/ +static int io_noclose (lua_State *L) { + lua_pushnil(L); + lua_pushliteral(L, "cannot close standard file"); + return 2; +} + + +/* +** function to close 'popen' files +*/ +static int io_pclose (lua_State *L) { + FILE **p = tofilep(L); + int ok = lua_pclose(L, *p); + *p = NULL; + return pushresult(L, ok, NULL); +} + + +/* +** function to close regular files +*/ +static int io_fclose (lua_State *L) { + FILE **p = tofilep(L); + int ok = (fclose(*p) == 0); + *p = NULL; + return pushresult(L, ok, NULL); +} + + +static int aux_close (lua_State *L) { + lua_getfenv(L, 1); + lua_getfield(L, -1, "__close"); + return (lua_tocfunction(L, -1))(L); +} + + +static int io_close (lua_State *L) { + if (lua_isnone(L, 1)) + lua_rawgeti(L, LUA_ENVIRONINDEX, IO_OUTPUT); + tofile(L); /* make sure argument is a file */ + return aux_close(L); +} + + +static int io_gc (lua_State *L) { + FILE *f = *tofilep(L); + /* ignore closed files */ + if (f != NULL) + aux_close(L); + return 0; +} + + +static int io_tostring (lua_State *L) { + FILE *f = *tofilep(L); + if (f == NULL) + lua_pushliteral(L, "file (closed)"); + else + lua_pushfstring(L, "file (%p)", f); + return 1; +} + + +static int io_open (lua_State *L) { + const char *filename = luaL_checkstring(L, 1); + const char *mode = luaL_optstring(L, 2, "r"); + FILE **pf = newfile(L); + *pf = fopen(filename, mode); + return (*pf == NULL) ? pushresult(L, 0, filename) : 1; +} + + +/* +** this function has a separated environment, which defines the +** correct __close for 'popen' files +*/ +static int io_popen (lua_State *L) { + const char *filename = luaL_checkstring(L, 1); + const char *mode = luaL_optstring(L, 2, "r"); + FILE **pf = newfile(L); + *pf = lua_popen(L, filename, mode); + return (*pf == NULL) ? pushresult(L, 0, filename) : 1; +} + + +static int io_tmpfile (lua_State *L) { + FILE **pf = newfile(L); + *pf = tmpfile(); + return (*pf == NULL) ? pushresult(L, 0, NULL) : 1; +} + + +static FILE *getiofile (lua_State *L, int findex) { + FILE *f; + lua_rawgeti(L, LUA_ENVIRONINDEX, findex); + f = *(FILE **)lua_touserdata(L, -1); + if (f == NULL) + luaL_error(L, "standard %s file is closed", fnames[findex - 1]); + return f; +} + + +static int g_iofile (lua_State *L, int f, const char *mode) { + if (!lua_isnoneornil(L, 1)) { + const char *filename = lua_tostring(L, 1); + if (filename) { + FILE **pf = newfile(L); + *pf = fopen(filename, mode); + if (*pf == NULL) + fileerror(L, 1, filename); + } + else { + tofile(L); /* check that it's a valid file handle */ + lua_pushvalue(L, 1); + } + lua_rawseti(L, LUA_ENVIRONINDEX, f); + } + /* return current value */ + lua_rawgeti(L, LUA_ENVIRONINDEX, f); + return 1; +} + + +static int io_input (lua_State *L) { + return g_iofile(L, IO_INPUT, "r"); +} + + +static int io_output (lua_State *L) { + return g_iofile(L, IO_OUTPUT, "w"); +} + + +static int io_readline (lua_State *L); + + +static void aux_lines (lua_State *L, int idx, int toclose) { + lua_pushvalue(L, idx); + lua_pushboolean(L, toclose); /* close/not close file when finished */ + lua_pushcclosure(L, io_readline, 2); +} + + +static int f_lines (lua_State *L) { + tofile(L); /* check that it's a valid file handle */ + aux_lines(L, 1, 0); + return 1; +} + + +static int io_lines (lua_State *L) { + if (lua_isnoneornil(L, 1)) { /* no arguments? */ + /* will iterate over default input */ + lua_rawgeti(L, LUA_ENVIRONINDEX, IO_INPUT); + return f_lines(L); + } + else { + const char *filename = luaL_checkstring(L, 1); + FILE **pf = newfile(L); + *pf = fopen(filename, "r"); + if (*pf == NULL) + fileerror(L, 1, filename); + aux_lines(L, lua_gettop(L), 1); + return 1; + } +} + + +/* +** {====================================================== +** READ +** ======================================================= +*/ + + +static int read_number (lua_State *L, FILE *f) { + lua_Number d; + if (fscanf(f, LUA_NUMBER_SCAN, &d) == 1) { + lua_pushnumber(L, d); + return 1; + } + else return 0; /* read fails */ +} + + +static int test_eof (lua_State *L, FILE *f) { + int c = getc(f); + ungetc(c, f); + lua_pushlstring(L, NULL, 0); + return (c != EOF); +} + + +static int read_line (lua_State *L, FILE *f) { + luaL_Buffer b; + luaL_buffinit(L, &b); + for (;;) { + size_t l; + char *p = luaL_prepbuffer(&b); + if (fgets(p, LUAL_BUFFERSIZE, f) == NULL) { /* eof? */ + luaL_pushresult(&b); /* close buffer */ + return (lua_objlen(L, -1) > 0); /* check whether read something */ + } + l = strlen(p); + if (l == 0 || p[l-1] != '\n') + luaL_addsize(&b, l); + else { + luaL_addsize(&b, l - 1); /* do not include `eol' */ + luaL_pushresult(&b); /* close buffer */ + return 1; /* read at least an `eol' */ + } + } +} + + +static int read_chars (lua_State *L, FILE *f, size_t n) { + size_t rlen; /* how much to read */ + size_t nr; /* number of chars actually read */ + luaL_Buffer b; + luaL_buffinit(L, &b); + rlen = LUAL_BUFFERSIZE; /* try to read that much each time */ + do { + char *p = luaL_prepbuffer(&b); + if (rlen > n) rlen = n; /* cannot read more than asked */ + nr = fread(p, sizeof(char), rlen, f); + luaL_addsize(&b, nr); + n -= nr; /* still have to read `n' chars */ + } while (n > 0 && nr == rlen); /* until end of count or eof */ + luaL_pushresult(&b); /* close buffer */ + return (n == 0 || lua_objlen(L, -1) > 0); +} + + +static int g_read (lua_State *L, FILE *f, int first) { + int nargs = lua_gettop(L) - 1; + int success; + int n; + clearerr(f); + if (nargs == 0) { /* no arguments? */ + success = read_line(L, f); + n = first+1; /* to return 1 result */ + } + else { /* ensure stack space for all results and for auxlib's buffer */ + luaL_checkstack(L, nargs+LUA_MINSTACK, "too many arguments"); + success = 1; + for (n = first; nargs-- && success; n++) { + if (lua_type(L, n) == LUA_TNUMBER) { + size_t l = (size_t)lua_tointeger(L, n); + success = (l == 0) ? test_eof(L, f) : read_chars(L, f, l); + } + else { + const char *p = lua_tostring(L, n); + luaL_argcheck(L, p && p[0] == '*', n, "invalid option"); + switch (p[1]) { + case 'n': /* number */ + success = read_number(L, f); + break; + case 'l': /* line */ + success = read_line(L, f); + break; + case 'a': /* file */ + read_chars(L, f, ~((size_t)0)); /* read MAX_SIZE_T chars */ + success = 1; /* always success */ + break; + default: + return luaL_argerror(L, n, "invalid format"); + } + } + } + } + if (ferror(f)) + return pushresult(L, 0, NULL); + if (!success) { + lua_pop(L, 1); /* remove last result */ + lua_pushnil(L); /* push nil instead */ + } + return n - first; +} + + +static int io_read (lua_State *L) { + return g_read(L, getiofile(L, IO_INPUT), 1); +} + + +static int f_read (lua_State *L) { + return g_read(L, tofile(L), 2); +} + + +static int io_readline (lua_State *L) { + FILE *f = *(FILE **)lua_touserdata(L, lua_upvalueindex(1)); + int sucess; + if (f == NULL) /* file is already closed? */ + luaL_error(L, "file is already closed"); + sucess = read_line(L, f); + if (ferror(f)) + return luaL_error(L, "%s", strerror(errno)); + if (sucess) return 1; + else { /* EOF */ + if (lua_toboolean(L, lua_upvalueindex(2))) { /* generator created file? */ + lua_settop(L, 0); + lua_pushvalue(L, lua_upvalueindex(1)); + aux_close(L); /* close it */ + } + return 0; + } +} + +/* }====================================================== */ + + +static int g_write (lua_State *L, FILE *f, int arg) { + int nargs = lua_gettop(L) - 1; + int status = 1; + for (; nargs--; arg++) { + if (lua_type(L, arg) == LUA_TNUMBER) { + /* optimization: could be done exactly as for strings */ + status = status && + fprintf(f, LUA_NUMBER_FMT, lua_tonumber(L, arg)) > 0; + } + else { + size_t l; + const char *s = luaL_checklstring(L, arg, &l); + status = status && (fwrite(s, sizeof(char), l, f) == l); + } + } + return pushresult(L, status, NULL); +} + + +static int io_write (lua_State *L) { + return g_write(L, getiofile(L, IO_OUTPUT), 1); +} + + +static int f_write (lua_State *L) { + return g_write(L, tofile(L), 2); +} + + +static int f_seek (lua_State *L) { + static const int mode[] = {SEEK_SET, SEEK_CUR, SEEK_END}; + static const char *const modenames[] = {"set", "cur", "end", NULL}; + FILE *f = tofile(L); + int op = luaL_checkoption(L, 2, "cur", modenames); + long offset = luaL_optlong(L, 3, 0); + op = fseek(f, offset, mode[op]); + if (op) + return pushresult(L, 0, NULL); /* error */ + else { + lua_pushinteger(L, ftell(f)); + return 1; + } +} + + +static int f_setvbuf (lua_State *L) { + static const int mode[] = {_IONBF, _IOFBF, _IOLBF}; + static const char *const modenames[] = {"no", "full", "line", NULL}; + FILE *f = tofile(L); + int op = luaL_checkoption(L, 2, NULL, modenames); + lua_Integer sz = luaL_optinteger(L, 3, LUAL_BUFFERSIZE); + int res = setvbuf(f, NULL, mode[op], sz); + return pushresult(L, res == 0, NULL); +} + + + +static int io_flush (lua_State *L) { + return pushresult(L, fflush(getiofile(L, IO_OUTPUT)) == 0, NULL); +} + + +static int f_flush (lua_State *L) { + return pushresult(L, fflush(tofile(L)) == 0, NULL); +} + + +static const luaL_Reg iolib[] = { + {"close", io_close}, + {"flush", io_flush}, + {"input", io_input}, + {"lines", io_lines}, + {"open", io_open}, + {"output", io_output}, + {"popen", io_popen}, + {"read", io_read}, + {"tmpfile", io_tmpfile}, + {"type", io_type}, + {"write", io_write}, + {NULL, NULL} +}; + + +static const luaL_Reg flib[] = { + {"close", io_close}, + {"flush", f_flush}, + {"lines", f_lines}, + {"read", f_read}, + {"seek", f_seek}, + {"setvbuf", f_setvbuf}, + {"write", f_write}, + {"__gc", io_gc}, + {"__tostring", io_tostring}, + {NULL, NULL} +}; + + +static void createmeta (lua_State *L) { + luaL_newmetatable(L, LUA_FILEHANDLE); /* create metatable for file handles */ + lua_pushvalue(L, -1); /* push metatable */ + lua_setfield(L, -2, "__index"); /* metatable.__index = metatable */ + luaL_register(L, NULL, flib); /* file methods */ +} + + +static void createstdfile (lua_State *L, FILE *f, int k, const char *fname) { + *newfile(L) = f; + if (k > 0) { + lua_pushvalue(L, -1); + lua_rawseti(L, LUA_ENVIRONINDEX, k); + } + lua_pushvalue(L, -2); /* copy environment */ + lua_setfenv(L, -2); /* set it */ + lua_setfield(L, -3, fname); +} + + +static void newfenv (lua_State *L, lua_CFunction cls) { + lua_createtable(L, 0, 1); + lua_pushcfunction(L, cls); + lua_setfield(L, -2, "__close"); +} + + +LUALIB_API int luaopen_io (lua_State *L) { + createmeta(L); + /* create (private) environment (with fields IO_INPUT, IO_OUTPUT, __close) */ + newfenv(L, io_fclose); + lua_replace(L, LUA_ENVIRONINDEX); + /* open library */ + luaL_register(L, LUA_IOLIBNAME, iolib); + /* create (and set) default files */ + newfenv(L, io_noclose); /* close function for default files */ + createstdfile(L, stdin, IO_INPUT, "stdin"); + createstdfile(L, stdout, IO_OUTPUT, "stdout"); + createstdfile(L, stderr, 0, "stderr"); + lua_pop(L, 1); /* pop environment for default files */ + lua_getfield(L, -1, "popen"); + newfenv(L, io_pclose); /* create environment for 'popen' */ + lua_setfenv(L, -2); /* set fenv for 'popen' */ + lua_pop(L, 1); /* pop 'popen' */ + return 1; +} + diff --git a/lua/llex.c b/lua/llex.c new file mode 100644 index 0000000..1cb43ae --- /dev/null +++ b/lua/llex.c @@ -0,0 +1,486 @@ +/* +** $Id: llex.c,v 2.20.1.1 2007/12/27 13:02:25 roberto Exp $ +** Lexical Analyzer +** See Copyright Notice in lua.h +*/ + + +#include +#include +#include + +#define llex_c +#define LUA_CORE + +#include "lua.h" + +#include "ldo.h" +#include "llex.h" +#include "lobject.h" +#include "lparser.h" +#include "lstate.h" +#include "lstring.h" +#include "ltable.h" +#include "lzio.h" + + + +#define next(ls) (ls->current = zgetc(ls->z)) + + + + +#define currIsNewline(ls) (ls->current == '\n' || ls->current == '\r') + + +/* ORDER RESERVED */ +const char *const luaX_tokens [] = { + "and", "break", "do", "else", "elseif", + "end", "false", "for", "function", "if", + "in", "local", "nil", "not", "or", "repeat", + "return", "then", "true", "until", "while", + "..", "...", "==", ">=", "<=", "~=", + "", "", "", "", + NULL +}; + + +#define save_and_next(ls) (save(ls, ls->current), next(ls)) + + +static void save (LexState *ls, int c) { + Mbuffer *b = ls->buff; + if (b->n + 1 > b->buffsize) { + size_t newsize; + if (b->buffsize >= MAX_SIZET/2) + luaX_lexerror(ls, "lexical element too long", 0); + newsize = b->buffsize * 2; + luaZ_resizebuffer(ls->L, b, newsize); + } + b->buffer[b->n++] = cast(char, c); +} + + +void luaX_init (lua_State *L) { + int i; + for (i=0; itsv.reserved = cast_byte(i+1); /* reserved word */ + } +} + + +#define MAXSRC 80 + + +const char *luaX_token2str (LexState *ls, int token) { + if (token < FIRST_RESERVED) { + lua_assert(token == cast(unsigned char, token)); + return (iscntrl(token)) ? luaO_pushfstring(ls->L, "char(%d)", token) : + luaO_pushfstring(ls->L, "%c", token); + } + else + return luaX_tokens[token-FIRST_RESERVED]; +} + + +static const char *txtToken (LexState *ls, int token) { + switch (token) { + case TK_NAME: + case TK_STRING: + case TK_NUMBER: + save(ls, '\0'); + return luaZ_buffer(ls->buff); + default: + return luaX_token2str(ls, token); + } +} + + +void luaX_lexerror (LexState *ls, const char *msg, int token) { + char buff[MAXSRC]; + luaO_chunkid(buff, getstr(ls->source), MAXSRC); + msg = luaO_pushfstring(ls->L, "%s:%d: %s", buff, ls->linenumber, msg); + if (token) + luaO_pushfstring(ls->L, "%s near " LUA_QS, msg, txtToken(ls, token)); + luaD_throw(ls->L, LUA_ERRSYNTAX); +} + + +void luaX_syntaxerror (LexState *ls, const char *msg) { + luaX_lexerror(ls, msg, ls->t.token); +} + + +TString *luaX_newstring (LexState *ls, const char *str, size_t l) { + lua_State *L = ls->L; + TString *ts = luaS_newlstr(L, str, l); + TValue *o = luaH_setstr(L, ls->fs->h, ts); /* entry for `str' */ + if (ttisnil(o)) + setbvalue(o, 1); /* make sure `str' will not be collected */ + return ts; +} + + +static void inclinenumber (LexState *ls) { + int old = ls->current; + lua_assert(currIsNewline(ls)); + next(ls); /* skip `\n' or `\r' */ + if (currIsNewline(ls) && ls->current != old) + next(ls); /* skip `\n\r' or `\r\n' */ + if (++ls->linenumber >= MAX_INT) + luaX_syntaxerror(ls, "chunk has too many lines"); +} + + +void luaX_setinput (lua_State *L, LexState *ls, ZIO *z, TString *source) { + ls->decpoint = '.'; + ls->L = L; + ls->lookahead.token = TK_EOS; /* no look-ahead token */ + ls->z = z; + ls->fs = NULL; + ls->linenumber = 1; + ls->lastline = 1; + ls->source = source; + luaZ_resizebuffer(ls->L, ls->buff, LUA_MINBUFFER); /* initialize buffer */ + next(ls); /* read first char */ +} + + + +/* +** ======================================================= +** LEXICAL ANALYZER +** ======================================================= +*/ + + + +static int check_next (LexState *ls, const char *set) { + if (!strchr(set, ls->current)) + return 0; + save_and_next(ls); + return 1; +} + + +static void buffreplace (LexState *ls, char from, char to) { + size_t n = luaZ_bufflen(ls->buff); + char *p = luaZ_buffer(ls->buff); + while (n--) + if (p[n] == from) p[n] = to; +} + + +static void trydecpoint (LexState *ls, SemInfo *seminfo) { + /* format error: try to update decimal point separator */ + struct lconv *cv = localeconv(); + char old = ls->decpoint; + ls->decpoint = (cv ? cv->decimal_point[0] : '.'); + buffreplace(ls, old, ls->decpoint); /* try updated decimal separator */ + if (!luaO_str2d(luaZ_buffer(ls->buff), &seminfo->r)) { + /* format error with correct decimal point: no more options */ + buffreplace(ls, ls->decpoint, '.'); /* undo change (for error message) */ + luaX_lexerror(ls, "malformed number", TK_NUMBER); + } +} + + +/* LUA_NUMBER */ +static void read_numeral (LexState *ls, SemInfo *seminfo) { + lua_assert(isdigit(ls->current)); + do { + save_and_next(ls); + } while (isdigit(ls->current) || ls->current == '.'); + if (check_next(ls, "Ee")) /* `E'? */ + check_next(ls, "+-"); /* optional exponent sign */ + while (isalnum(ls->current) || ls->current == '_') + save_and_next(ls); + save(ls, '\0'); + buffreplace(ls, '.', ls->decpoint); /* follow locale for decimal point */ + if (!luaO_str2d(luaZ_buffer(ls->buff), &seminfo->r)) /* format error? */ + trydecpoint(ls, seminfo); /* try to update decimal point separator */ +} + + +static int skip_sep (LexState *ls) { + int count = 0; + int s = ls->current; + lua_assert(s == '[' || s == ']'); + save_and_next(ls); + while (ls->current == '=') { + save_and_next(ls); + count++; + } + return (ls->current == s) ? count : (-count) - 1; +} + + +static void read_long_string (LexState *ls, SemInfo *seminfo, int sep) { + int cont = 0; + (void)(cont); /* avoid warnings when `cont' is not used */ + save_and_next(ls); /* skip 2nd `[' */ + if (currIsNewline(ls)) /* string starts with a newline? */ + inclinenumber(ls); /* skip it */ + for (;;) { + switch (ls->current) { + case EOZ: + luaX_lexerror(ls, (seminfo) ? "unfinished long string" : + "unfinished long comment", TK_EOS); + break; /* to avoid warnings */ +#if defined(LUA_COMPAT_LSTR) + case '[': { + if (skip_sep(ls) == sep) { + save_and_next(ls); /* skip 2nd `[' */ + cont++; +#if LUA_COMPAT_LSTR == 1 + if (sep == 0) + luaX_lexerror(ls, "nesting of [[...]] is deprecated", '['); +#endif + } + break; + } +#endif + case ']': { + if (skip_sep(ls) == sep) { + save_and_next(ls); /* skip 2nd `]' */ +#if defined(LUA_COMPAT_LSTR) && LUA_COMPAT_LSTR == 2 + cont--; + if (sep == 0 && cont >= 0) break; +#endif + goto endloop; + } + break; + } + case '\n': + case '\r': { + save(ls, '\n'); + inclinenumber(ls); + if (!seminfo) luaZ_resetbuffer(ls->buff); /* avoid wasting space */ + break; + } + default: { + if (seminfo) save_and_next(ls); + else next(ls); + } + } + } endloop: + if (seminfo) + seminfo->ts = luaX_newstring(ls, luaZ_buffer(ls->buff) + (2 + sep), + luaZ_bufflen(ls->buff) - 2*(2 + sep)); +} + + +static void read_string (LexState *ls, int del, SemInfo *seminfo) { + save_and_next(ls); + while (ls->current != del) { + switch (ls->current) { + case EOZ: + luaX_lexerror(ls, "unfinished string", TK_EOS); + continue; /* to avoid warnings */ + case '\n': + case '\r': + luaX_lexerror(ls, "unfinished string", TK_STRING); + continue; /* to avoid warnings */ + case '\\': { + int c; + next(ls); /* do not save the `\' */ + switch (ls->current) { + case 'a': c = '\a'; break; + case 'b': c = '\b'; break; + case 'f': c = '\f'; break; + case 'n': c = '\n'; break; + case 'r': c = '\r'; break; + case 't': c = '\t'; break; + case 'v': c = '\v'; break; + case '\n': /* go through */ + case '\r': save(ls, '\n'); inclinenumber(ls); continue; + case EOZ: continue; /* will raise an error next loop */ + default: { + if (!isdigit(ls->current)) + save_and_next(ls); /* handles \\, \", \', and \? */ + else { /* \xxx */ + int i = 0; + c = 0; + do { + c = 10*c + (ls->current-'0'); + next(ls); + } while (++i<3 && isdigit(ls->current)); + if (c > UCHAR_MAX) + luaX_lexerror(ls, "escape sequence too large", TK_STRING); + save(ls, c); + } + continue; + } + } + save(ls, c); + next(ls); + continue; + } + default: + save_and_next(ls); + } + } + save_and_next(ls); /* skip delimiter */ + seminfo->ts = luaX_newstring(ls, luaZ_buffer(ls->buff) + 1, + luaZ_bufflen(ls->buff) - 2); +} + + +static int llex (LexState *ls, SemInfo *seminfo) { + luaZ_resetbuffer(ls->buff); + for (;;) { + switch (ls->current) { + case '\n': + case '\r': { + inclinenumber(ls); + continue; + } + case '-': { + next(ls); + if (ls->current != '-') return '-'; + /* else is a comment */ + next(ls); + if (ls->current == '[') { + int sep = skip_sep(ls); + luaZ_resetbuffer(ls->buff); /* `skip_sep' may dirty the buffer */ + if (sep >= 0) { + read_long_string(ls, NULL, sep); /* long comment */ + luaZ_resetbuffer(ls->buff); + continue; + } + } + /* else short comment */ + while (!currIsNewline(ls) && ls->current != EOZ) + next(ls); + continue; + } + case '[': { + int sep = skip_sep(ls); + if (sep >= 0) { + read_long_string(ls, seminfo, sep); + return TK_STRING; + } + else if (sep == -1) return '['; + else luaX_lexerror(ls, "invalid long string delimiter", TK_STRING); + } + case '=': { + next(ls); + if (ls->current != '=') return '='; + else { next(ls); return TK_EQ; } + } + case '<': { + next(ls); + if (ls->current != '=') return '<'; + else { next(ls); return TK_LE; } + } + case '>': { + next(ls); + if (ls->current != '=') return '>'; + else { next(ls); return TK_GE; } + } + case '~': { + next(ls); + if (ls->current != '=') return '~'; + else { next(ls); return TK_NE; } + } + case '"': + case '\'': { + read_string(ls, ls->current, seminfo); + return TK_STRING; + } +#ifdef _JZ_LUA_CODE + case '%': { + lua_const *tm_constlist = ls->L->constlist; + unsigned int i = 0; + if(tm_constlist != NULL) + { + while(tm_constlist->name != NULL) + { + if(tm_constlist->size < ls->z->n) + { + if(memcmp(ls->z->p, tm_constlist->name, tm_constlist->size - 1) == 0) + { + for(i = 0; i < tm_constlist->size; i++) + { + save_and_next(ls); + } + seminfo->r = tm_constlist->vl; + return TK_NUMBER; + } + } + tm_constlist++; + } + } + } +#endif + case '.': { + save_and_next(ls); + if (check_next(ls, ".")) { + if (check_next(ls, ".")) + return TK_DOTS; /* ... */ + else return TK_CONCAT; /* .. */ + } + else if (!isdigit(ls->current)) return '.'; + else { + read_numeral(ls, seminfo); + return TK_NUMBER; + } + } + case EOZ: { + return TK_EOS; + } + default: { + if (isspace(ls->current)) { + lua_assert(!currIsNewline(ls)); + next(ls); + continue; + } + else if (isdigit(ls->current)) { + read_numeral(ls, seminfo); + return TK_NUMBER; + } + else if (isalpha(ls->current) || ls->current == '_') { + /* identifier or reserved word */ + TString *ts; + do { + save_and_next(ls); + } while (isalnum(ls->current) || ls->current == '_'); + ts = luaX_newstring(ls, luaZ_buffer(ls->buff), + luaZ_bufflen(ls->buff)); + if (ts->tsv.reserved > 0) /* reserved word? */ + return ts->tsv.reserved - 1 + FIRST_RESERVED; + else { + seminfo->ts = ts; + return TK_NAME; + } + } + else { + int c = ls->current; + next(ls); + return c; /* single-char tokens (+ - / ...) */ + } + } + } + } +} + + +void luaX_next (LexState *ls) { + ls->lastline = ls->linenumber; + if (ls->lookahead.token != TK_EOS) { /* is there a look-ahead token? */ + ls->t = ls->lookahead; /* use this one */ + ls->lookahead.token = TK_EOS; /* and discharge it */ + } + else + ls->t.token = llex(ls, &ls->t.seminfo); /* read next token */ +} + + +void luaX_lookahead (LexState *ls) { + lua_assert(ls->lookahead.token == TK_EOS); + ls->lookahead.token = llex(ls, &ls->lookahead.seminfo); +} + diff --git a/lua/llex.h b/lua/llex.h new file mode 100644 index 0000000..a9201ce --- /dev/null +++ b/lua/llex.h @@ -0,0 +1,81 @@ +/* +** $Id: llex.h,v 1.58.1.1 2007/12/27 13:02:25 roberto Exp $ +** Lexical Analyzer +** See Copyright Notice in lua.h +*/ + +#ifndef llex_h +#define llex_h + +#include "lobject.h" +#include "lzio.h" + + +#define FIRST_RESERVED 257 + +/* maximum length of a reserved word */ +#define TOKEN_LEN (sizeof("function")/sizeof(char)) + + +/* +* WARNING: if you change the order of this enumeration, +* grep "ORDER RESERVED" +*/ +enum RESERVED { + /* terminal symbols denoted by reserved words */ + TK_AND = FIRST_RESERVED, TK_BREAK, + TK_DO, TK_ELSE, TK_ELSEIF, TK_END, TK_FALSE, TK_FOR, TK_FUNCTION, + TK_IF, TK_IN, TK_LOCAL, TK_NIL, TK_NOT, TK_OR, TK_REPEAT, + TK_RETURN, TK_THEN, TK_TRUE, TK_UNTIL, TK_WHILE, + /* other terminal symbols */ + TK_CONCAT, TK_DOTS, TK_EQ, TK_GE, TK_LE, TK_NE, TK_NUMBER, + TK_NAME, TK_STRING, TK_EOS +}; + +/* number of reserved words */ +#define NUM_RESERVED (cast(int, TK_WHILE-FIRST_RESERVED+1)) + + +/* array with token `names' */ +LUAI_DATA const char *const luaX_tokens []; + + +typedef union { + lua_Number r; + TString *ts; +} SemInfo; /* semantics information */ + + +typedef struct Token { + int token; + SemInfo seminfo; +} Token; + + +typedef struct LexState { + int current; /* current character (charint) */ + int linenumber; /* input line counter */ + int lastline; /* line of last token `consumed' */ + Token t; /* current token */ + Token lookahead; /* look ahead token */ + struct FuncState *fs; /* `FuncState' is private to the parser */ + struct lua_State *L; + ZIO *z; /* input stream */ + Mbuffer *buff; /* buffer for tokens */ + TString *source; /* current source name */ + char decpoint; /* locale decimal point */ +} LexState; + + +LUAI_FUNC void luaX_init (lua_State *L); +LUAI_FUNC void luaX_setinput (lua_State *L, LexState *ls, ZIO *z, + TString *source); +LUAI_FUNC TString *luaX_newstring (LexState *ls, const char *str, size_t l); +LUAI_FUNC void luaX_next (LexState *ls); +LUAI_FUNC void luaX_lookahead (LexState *ls); +LUAI_FUNC void luaX_lexerror (LexState *ls, const char *msg, int token); +LUAI_FUNC void luaX_syntaxerror (LexState *ls, const char *s); +LUAI_FUNC const char *luaX_token2str (LexState *ls, int token); + + +#endif diff --git a/lua/llimits.h b/lua/llimits.h new file mode 100644 index 0000000..ca8dcb7 --- /dev/null +++ b/lua/llimits.h @@ -0,0 +1,128 @@ +/* +** $Id: llimits.h,v 1.69.1.1 2007/12/27 13:02:25 roberto Exp $ +** Limits, basic types, and some other `installation-dependent' definitions +** See Copyright Notice in lua.h +*/ + +#ifndef llimits_h +#define llimits_h + + +#include +#include + + +#include "lua.h" + + +typedef LUAI_UINT32 lu_int32; + +typedef LUAI_UMEM lu_mem; + +typedef LUAI_MEM l_mem; + + + +/* chars used as small naturals (so that `char' is reserved for characters) */ +typedef unsigned char lu_byte; + + +#define MAX_SIZET ((size_t)(~(size_t)0)-2) + +#define MAX_LUMEM ((lu_mem)(~(lu_mem)0)-2) + + +#define MAX_INT (INT_MAX-2) /* maximum value of an int (-2 for safety) */ + +/* +** conversion of pointer to integer +** this is for hashing only; there is no problem if the integer +** cannot hold the whole pointer value +*/ +#define IntPoint(p) ((unsigned int)(lu_mem)(p)) + + + +/* type to ensure maximum alignment */ +typedef LUAI_USER_ALIGNMENT_T L_Umaxalign; + + +/* result of a `usual argument conversion' over lua_Number */ +typedef LUAI_UACNUMBER l_uacNumber; + + +/* internal assertions for in-house debugging */ +#ifdef lua_assert + +#define check_exp(c,e) (lua_assert(c), (e)) +#define api_check(l,e) lua_assert(e) + +#else + +#define lua_assert(c) ((void)0) +#define check_exp(c,e) (e) +#define api_check luai_apicheck + +#endif + + +#ifndef UNUSED +#define UNUSED(x) ((void)(x)) /* to avoid warnings */ +#endif + + +#ifndef cast +#define cast(t, exp) ((t)(exp)) +#endif + +#define cast_byte(i) cast(lu_byte, (i)) +#define cast_num(i) cast(lua_Number, (i)) +#define cast_int(i) cast(int, (i)) + + + +/* +** type for virtual-machine instructions +** must be an unsigned with (at least) 4 bytes (see details in lopcodes.h) +*/ +typedef lu_int32 Instruction; + + + +/* maximum stack for a Lua function */ +#define MAXSTACK 250 + + + +/* minimum size for the string table (must be power of 2) */ +#ifndef MINSTRTABSIZE +#define MINSTRTABSIZE 32 +#endif + + +/* minimum size for string buffer */ +#ifndef LUA_MINBUFFER +#define LUA_MINBUFFER 32 +#endif + + +#ifndef lua_lock +#define lua_lock(L) ((void) 0) +#define lua_unlock(L) ((void) 0) +#endif + +#ifndef luai_threadyield +#define luai_threadyield(L) {lua_unlock(L); lua_lock(L);} +#endif + + +/* +** macro to control inclusion of some hard tests on stack reallocation +*/ +#ifndef HARDSTACKTESTS +#define condhardstacktests(x) ((void)0) +#else +#define condhardstacktests(x) x +#endif + +#endif diff --git a/lua/lmathlib.c b/lua/lmathlib.c new file mode 100644 index 0000000..441fbf7 --- /dev/null +++ b/lua/lmathlib.c @@ -0,0 +1,263 @@ +/* +** $Id: lmathlib.c,v 1.67.1.1 2007/12/27 13:02:25 roberto Exp $ +** Standard mathematical library +** See Copyright Notice in lua.h +*/ + + +#include +#include + +#define lmathlib_c +#define LUA_LIB + +#include "lua.h" + +#include "lauxlib.h" +#include "lualib.h" + + +#undef PI +#define PI (3.14159265358979323846) +#define RADIANS_PER_DEGREE (PI/180.0) + + + +static int math_abs (lua_State *L) { + lua_pushnumber(L, fabs(luaL_checknumber(L, 1))); + return 1; +} + +static int math_sin (lua_State *L) { + lua_pushnumber(L, sin(luaL_checknumber(L, 1))); + return 1; +} + +static int math_sinh (lua_State *L) { + lua_pushnumber(L, sinh(luaL_checknumber(L, 1))); + return 1; +} + +static int math_cos (lua_State *L) { + lua_pushnumber(L, cos(luaL_checknumber(L, 1))); + return 1; +} + +static int math_cosh (lua_State *L) { + lua_pushnumber(L, cosh(luaL_checknumber(L, 1))); + return 1; +} + +static int math_tan (lua_State *L) { + lua_pushnumber(L, tan(luaL_checknumber(L, 1))); + return 1; +} + +static int math_tanh (lua_State *L) { + lua_pushnumber(L, tanh(luaL_checknumber(L, 1))); + return 1; +} + +static int math_asin (lua_State *L) { + lua_pushnumber(L, asin(luaL_checknumber(L, 1))); + return 1; +} + +static int math_acos (lua_State *L) { + lua_pushnumber(L, acos(luaL_checknumber(L, 1))); + return 1; +} + +static int math_atan (lua_State *L) { + lua_pushnumber(L, atan(luaL_checknumber(L, 1))); + return 1; +} + +static int math_atan2 (lua_State *L) { + lua_pushnumber(L, atan2(luaL_checknumber(L, 1), luaL_checknumber(L, 2))); + return 1; +} + +static int math_ceil (lua_State *L) { + lua_pushnumber(L, ceil(luaL_checknumber(L, 1))); + return 1; +} + +static int math_floor (lua_State *L) { + lua_pushnumber(L, floor(luaL_checknumber(L, 1))); + return 1; +} + +static int math_fmod (lua_State *L) { + lua_pushnumber(L, fmod(luaL_checknumber(L, 1), luaL_checknumber(L, 2))); + return 1; +} + +static int math_modf (lua_State *L) { + double ip; + double fp = modf(luaL_checknumber(L, 1), &ip); + lua_pushnumber(L, ip); + lua_pushnumber(L, fp); + return 2; +} + +static int math_sqrt (lua_State *L) { + lua_pushnumber(L, sqrt(luaL_checknumber(L, 1))); + return 1; +} + +static int math_pow (lua_State *L) { + lua_pushnumber(L, pow(luaL_checknumber(L, 1), luaL_checknumber(L, 2))); + return 1; +} + +static int math_log (lua_State *L) { + lua_pushnumber(L, log(luaL_checknumber(L, 1))); + return 1; +} + +static int math_log10 (lua_State *L) { + lua_pushnumber(L, log10(luaL_checknumber(L, 1))); + return 1; +} + +static int math_exp (lua_State *L) { + lua_pushnumber(L, exp(luaL_checknumber(L, 1))); + return 1; +} + +static int math_deg (lua_State *L) { + lua_pushnumber(L, luaL_checknumber(L, 1)/RADIANS_PER_DEGREE); + return 1; +} + +static int math_rad (lua_State *L) { + lua_pushnumber(L, luaL_checknumber(L, 1)*RADIANS_PER_DEGREE); + return 1; +} + +static int math_frexp (lua_State *L) { + int e; + lua_pushnumber(L, frexp(luaL_checknumber(L, 1), &e)); + lua_pushinteger(L, e); + return 2; +} + +static int math_ldexp (lua_State *L) { + lua_pushnumber(L, ldexp(luaL_checknumber(L, 1), luaL_checkint(L, 2))); + return 1; +} + + + +static int math_min (lua_State *L) { + int n = lua_gettop(L); /* number of arguments */ + lua_Number dmin = luaL_checknumber(L, 1); + int i; + for (i=2; i<=n; i++) { + lua_Number d = luaL_checknumber(L, i); + if (d < dmin) + dmin = d; + } + lua_pushnumber(L, dmin); + return 1; +} + + +static int math_max (lua_State *L) { + int n = lua_gettop(L); /* number of arguments */ + lua_Number dmax = luaL_checknumber(L, 1); + int i; + for (i=2; i<=n; i++) { + lua_Number d = luaL_checknumber(L, i); + if (d > dmax) + dmax = d; + } + lua_pushnumber(L, dmax); + return 1; +} + + +static int math_random (lua_State *L) { + /* the `%' avoids the (rare) case of r==1, and is needed also because on + some systems (SunOS!) `rand()' may return a value larger than RAND_MAX */ + lua_Number r = (lua_Number)(rand()%RAND_MAX) / (lua_Number)RAND_MAX; + switch (lua_gettop(L)) { /* check number of arguments */ + case 0: { /* no arguments */ + lua_pushnumber(L, r); /* Number between 0 and 1 */ + break; + } + case 1: { /* only upper limit */ + int u = luaL_checkint(L, 1); + luaL_argcheck(L, 1<=u, 1, "interval is empty"); + lua_pushnumber(L, floor(r*u)+1); /* int between 1 and `u' */ + break; + } + case 2: { /* lower and upper limits */ + int l = luaL_checkint(L, 1); + int u = luaL_checkint(L, 2); + luaL_argcheck(L, l<=u, 2, "interval is empty"); + lua_pushnumber(L, floor(r*(u-l+1))+l); /* int between `l' and `u' */ + break; + } + default: return luaL_error(L, "wrong number of arguments"); + } + return 1; +} + + +static int math_randomseed (lua_State *L) { + srand(luaL_checkint(L, 1)); + return 0; +} + + +static const luaL_Reg mathlib[] = { + {"abs", math_abs}, + {"acos", math_acos}, + {"asin", math_asin}, + {"atan2", math_atan2}, + {"atan", math_atan}, + {"ceil", math_ceil}, + {"cosh", math_cosh}, + {"cos", math_cos}, + {"deg", math_deg}, + {"exp", math_exp}, + {"floor", math_floor}, + {"fmod", math_fmod}, + {"frexp", math_frexp}, + {"ldexp", math_ldexp}, + {"log10", math_log10}, + {"log", math_log}, + {"max", math_max}, + {"min", math_min}, + {"modf", math_modf}, + {"pow", math_pow}, + {"rad", math_rad}, + {"random", math_random}, + {"randomseed", math_randomseed}, + {"sinh", math_sinh}, + {"sin", math_sin}, + {"sqrt", math_sqrt}, + {"tanh", math_tanh}, + {"tan", math_tan}, + {NULL, NULL} +}; + + +/* +** Open math library +*/ +LUALIB_API int luaopen_math (lua_State *L) { + luaL_register(L, LUA_MATHLIBNAME, mathlib); + lua_pushnumber(L, PI); + lua_setfield(L, -2, "pi"); + lua_pushnumber(L, HUGE_VAL); + lua_setfield(L, -2, "huge"); +#if defined(LUA_COMPAT_MOD) + lua_getfield(L, -1, "fmod"); + lua_setfield(L, -2, "mod"); +#endif + return 1; +} + diff --git a/lua/lmem.c b/lua/lmem.c new file mode 100644 index 0000000..ae7d8c9 --- /dev/null +++ b/lua/lmem.c @@ -0,0 +1,86 @@ +/* +** $Id: lmem.c,v 1.70.1.1 2007/12/27 13:02:25 roberto Exp $ +** Interface to Memory Manager +** See Copyright Notice in lua.h +*/ + + +#include + +#define lmem_c +#define LUA_CORE + +#include "lua.h" + +#include "ldebug.h" +#include "ldo.h" +#include "lmem.h" +#include "lobject.h" +#include "lstate.h" + + + +/* +** About the realloc function: +** void * frealloc (void *ud, void *ptr, size_t osize, size_t nsize); +** (`osize' is the old size, `nsize' is the new size) +** +** Lua ensures that (ptr == NULL) iff (osize == 0). +** +** * frealloc(ud, NULL, 0, x) creates a new block of size `x' +** +** * frealloc(ud, p, x, 0) frees the block `p' +** (in this specific case, frealloc must return NULL). +** particularly, frealloc(ud, NULL, 0, 0) does nothing +** (which is equivalent to free(NULL) in ANSI C) +** +** frealloc returns NULL if it cannot create or reallocate the area +** (any reallocation to an equal or smaller size cannot fail!) +*/ + + + +#define MINSIZEARRAY 4 + + +void *luaM_growaux_ (lua_State *L, void *block, int *size, size_t size_elems, + int limit, const char *errormsg) { + void *newblock; + int newsize; + if (*size >= limit/2) { /* cannot double it? */ + if (*size >= limit) /* cannot grow even a little? */ + luaG_runerror(L, errormsg); + newsize = limit; /* still have at least one free place */ + } + else { + newsize = (*size)*2; + if (newsize < MINSIZEARRAY) + newsize = MINSIZEARRAY; /* minimum size */ + } + newblock = luaM_reallocv(L, block, *size, newsize, size_elems); + *size = newsize; /* update only when everything else is OK */ + return newblock; +} + + +void *luaM_toobig (lua_State *L) { + luaG_runerror(L, "memory allocation error: block too big"); + return NULL; /* to avoid warnings */ +} + + + +/* +** generic allocation routine. +*/ +void *luaM_realloc_ (lua_State *L, void *block, size_t osize, size_t nsize) { + global_State *g = G(L); + lua_assert((osize == 0) == (block == NULL)); + block = (*g->frealloc)(g->ud, block, osize, nsize); + if (block == NULL && nsize > 0) + luaD_throw(L, LUA_ERRMEM); + lua_assert((nsize == 0) == (block == NULL)); + g->totalbytes = (g->totalbytes - osize) + nsize; + return block; +} + diff --git a/lua/lmem.h b/lua/lmem.h new file mode 100644 index 0000000..7c2dcb3 --- /dev/null +++ b/lua/lmem.h @@ -0,0 +1,49 @@ +/* +** $Id: lmem.h,v 1.31.1.1 2007/12/27 13:02:25 roberto Exp $ +** Interface to Memory Manager +** See Copyright Notice in lua.h +*/ + +#ifndef lmem_h +#define lmem_h + + +#include + +#include "llimits.h" +#include "lua.h" + +#define MEMERRMSG "not enough memory" + + +#define luaM_reallocv(L,b,on,n,e) \ + ((cast(size_t, (n)+1) <= MAX_SIZET/(e)) ? /* +1 to avoid warnings */ \ + luaM_realloc_(L, (b), (on)*(e), (n)*(e)) : \ + luaM_toobig(L)) + +#define luaM_freemem(L, b, s) luaM_realloc_(L, (b), (s), 0) +#define luaM_free(L, b) luaM_realloc_(L, (b), sizeof(*(b)), 0) +#define luaM_freearray(L, b, n, t) luaM_reallocv(L, (b), n, 0, sizeof(t)) + +#define luaM_malloc(L,t) luaM_realloc_(L, NULL, 0, (t)) +#define luaM_new(L,t) cast(t *, luaM_malloc(L, sizeof(t))) +#define luaM_newvector(L,n,t) \ + cast(t *, luaM_reallocv(L, NULL, 0, n, sizeof(t))) + +#define luaM_growvector(L,v,nelems,size,t,limit,e) \ + if ((nelems)+1 > (size)) \ + ((v)=cast(t *, luaM_growaux_(L,v,&(size),sizeof(t),limit,e))) + +#define luaM_reallocvector(L, v,oldn,n,t) \ + ((v)=cast(t *, luaM_reallocv(L, v, oldn, n, sizeof(t)))) + + +LUAI_FUNC void *luaM_realloc_ (lua_State *L, void *block, size_t oldsize, + size_t size); +LUAI_FUNC void *luaM_toobig (lua_State *L); +LUAI_FUNC void *luaM_growaux_ (lua_State *L, void *block, int *size, + size_t size_elem, int limit, + const char *errormsg); + +#endif + diff --git a/lua/loadlib.c b/lua/loadlib.c new file mode 100644 index 0000000..0d401eb --- /dev/null +++ b/lua/loadlib.c @@ -0,0 +1,666 @@ +/* +** $Id: loadlib.c,v 1.52.1.3 2008/08/06 13:29:28 roberto Exp $ +** Dynamic library loader for Lua +** See Copyright Notice in lua.h +** +** This module contains an implementation of loadlib for Unix systems +** that have dlfcn, an implementation for Darwin (Mac OS X), an +** implementation for Windows, and a stub for other systems. +*/ + + +#include +#include + + +#define loadlib_c +#define LUA_LIB + +#include "lua.h" + +#include "lauxlib.h" +#include "lualib.h" + + +/* prefix for open functions in C libraries */ +#define LUA_POF "luaopen_" + +/* separator for open functions in C libraries */ +#define LUA_OFSEP "_" + + +#define LIBPREFIX "LOADLIB: " + +#define POF LUA_POF +#define LIB_FAIL "open" + + +/* error codes for ll_loadfunc */ +#define ERRLIB 1 +#define ERRFUNC 2 + +#define setprogdir(L) ((void)0) + + +static void ll_unloadlib (void *lib); +static void *ll_load (lua_State *L, const char *path); +static lua_CFunction ll_sym (lua_State *L, void *lib, const char *sym); + + + +#if defined(LUA_DL_DLOPEN) +/* +** {======================================================================== +** This is an implementation of loadlib based on the dlfcn interface. +** The dlfcn interface is available in Linux, SunOS, Solaris, IRIX, FreeBSD, +** NetBSD, AIX 4.2, HPUX 11, and probably most other Unix flavors, at least +** as an emulation layer on top of native functions. +** ========================================================================= +*/ + +#include + +static void ll_unloadlib (void *lib) { + dlclose(lib); +} + + +static void *ll_load (lua_State *L, const char *path) { + void *lib = dlopen(path, RTLD_NOW); + if (lib == NULL) lua_pushstring(L, dlerror()); + return lib; +} + + +static lua_CFunction ll_sym (lua_State *L, void *lib, const char *sym) { + lua_CFunction f = (lua_CFunction)dlsym(lib, sym); + if (f == NULL) lua_pushstring(L, dlerror()); + return f; +} + +/* }====================================================== */ + + + +#elif defined(LUA_DL_DLL) +/* +** {====================================================================== +** This is an implementation of loadlib for Windows using native functions. +** ======================================================================= +*/ + +#include + + +#undef setprogdir + +static void setprogdir (lua_State *L) { + char buff[MAX_PATH + 1]; + char *lb; + DWORD nsize = sizeof(buff)/sizeof(char); + DWORD n = GetModuleFileNameA(NULL, buff, nsize); + if (n == 0 || n == nsize || (lb = strrchr(buff, '\\')) == NULL) + luaL_error(L, "unable to get ModuleFileName"); + else { + *lb = '\0'; + luaL_gsub(L, lua_tostring(L, -1), LUA_EXECDIR, buff); + lua_remove(L, -2); /* remove original string */ + } +} + + +static void pusherror (lua_State *L) { + int error = GetLastError(); + char buffer[128]; + if (FormatMessageA(FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_FROM_SYSTEM, + NULL, error, 0, buffer, sizeof(buffer), NULL)) + lua_pushstring(L, buffer); + else + lua_pushfstring(L, "system error %d\n", error); +} + +static void ll_unloadlib (void *lib) { + FreeLibrary((HINSTANCE)lib); +} + + +static void *ll_load (lua_State *L, const char *path) { + HINSTANCE lib = LoadLibraryA(path); + if (lib == NULL) pusherror(L); + return lib; +} + + +static lua_CFunction ll_sym (lua_State *L, void *lib, const char *sym) { + lua_CFunction f = (lua_CFunction)GetProcAddress((HINSTANCE)lib, sym); + if (f == NULL) pusherror(L); + return f; +} + +/* }====================================================== */ + + + +#elif defined(LUA_DL_DYLD) +/* +** {====================================================================== +** Native Mac OS X / Darwin Implementation +** ======================================================================= +*/ + +#include + + +/* Mac appends a `_' before C function names */ +#undef POF +#define POF "_" LUA_POF + + +static void pusherror (lua_State *L) { + const char *err_str; + const char *err_file; + NSLinkEditErrors err; + int err_num; + NSLinkEditError(&err, &err_num, &err_file, &err_str); + lua_pushstring(L, err_str); +} + + +static const char *errorfromcode (NSObjectFileImageReturnCode ret) { + switch (ret) { + case NSObjectFileImageInappropriateFile: + return "file is not a bundle"; + case NSObjectFileImageArch: + return "library is for wrong CPU type"; + case NSObjectFileImageFormat: + return "bad format"; + case NSObjectFileImageAccess: + return "cannot access file"; + case NSObjectFileImageFailure: + default: + return "unable to load library"; + } +} + + +static void ll_unloadlib (void *lib) { + NSUnLinkModule((NSModule)lib, NSUNLINKMODULE_OPTION_RESET_LAZY_REFERENCES); +} + + +static void *ll_load (lua_State *L, const char *path) { + NSObjectFileImage img; + NSObjectFileImageReturnCode ret; + /* this would be a rare case, but prevents crashing if it happens */ + if(!_dyld_present()) { + lua_pushliteral(L, "dyld not present"); + return NULL; + } + ret = NSCreateObjectFileImageFromFile(path, &img); + if (ret == NSObjectFileImageSuccess) { + NSModule mod = NSLinkModule(img, path, NSLINKMODULE_OPTION_PRIVATE | + NSLINKMODULE_OPTION_RETURN_ON_ERROR); + NSDestroyObjectFileImage(img); + if (mod == NULL) pusherror(L); + return mod; + } + lua_pushstring(L, errorfromcode(ret)); + return NULL; +} + + +static lua_CFunction ll_sym (lua_State *L, void *lib, const char *sym) { + NSSymbol nss = NSLookupSymbolInModule((NSModule)lib, sym); + if (nss == NULL) { + lua_pushfstring(L, "symbol " LUA_QS " not found", sym); + return NULL; + } + return (lua_CFunction)NSAddressOfSymbol(nss); +} + +/* }====================================================== */ + + + +#else +/* +** {====================================================== +** Fallback for other systems +** ======================================================= +*/ + +#undef LIB_FAIL +#define LIB_FAIL "absent" + + +#define DLMSG "dynamic libraries not enabled; check your Lua installation" + + +static void ll_unloadlib (void *lib) { + (void)lib; /* to avoid warnings */ +} + + +static void *ll_load (lua_State *L, const char *path) { + (void)path; /* to avoid warnings */ + lua_pushliteral(L, DLMSG); + return NULL; +} + + +static lua_CFunction ll_sym (lua_State *L, void *lib, const char *sym) { + (void)lib; (void)sym; /* to avoid warnings */ + lua_pushliteral(L, DLMSG); + return NULL; +} + +/* }====================================================== */ +#endif + + + +static void **ll_register (lua_State *L, const char *path) { + void **plib; + lua_pushfstring(L, "%s%s", LIBPREFIX, path); + lua_gettable(L, LUA_REGISTRYINDEX); /* check library in registry? */ + if (!lua_isnil(L, -1)) /* is there an entry? */ + plib = (void **)lua_touserdata(L, -1); + else { /* no entry yet; create one */ + lua_pop(L, 1); + plib = (void **)lua_newuserdata(L, sizeof(const void *)); + *plib = NULL; + luaL_getmetatable(L, "_LOADLIB"); + lua_setmetatable(L, -2); + lua_pushfstring(L, "%s%s", LIBPREFIX, path); + lua_pushvalue(L, -2); + lua_settable(L, LUA_REGISTRYINDEX); + } + return plib; +} + + +/* +** __gc tag method: calls library's `ll_unloadlib' function with the lib +** handle +*/ +static int gctm (lua_State *L) { + void **lib = (void **)luaL_checkudata(L, 1, "_LOADLIB"); + if (*lib) ll_unloadlib(*lib); + *lib = NULL; /* mark library as closed */ + return 0; +} + + +static int ll_loadfunc (lua_State *L, const char *path, const char *sym) { + void **reg = ll_register(L, path); + if (*reg == NULL) *reg = ll_load(L, path); + if (*reg == NULL) + return ERRLIB; /* unable to load library */ + else { + lua_CFunction f = ll_sym(L, *reg, sym); + if (f == NULL) + return ERRFUNC; /* unable to find function */ + lua_pushcfunction(L, f); + return 0; /* return function */ + } +} + + +static int ll_loadlib (lua_State *L) { + const char *path = luaL_checkstring(L, 1); + const char *init = luaL_checkstring(L, 2); + int stat = ll_loadfunc(L, path, init); + if (stat == 0) /* no errors? */ + return 1; /* return the loaded function */ + else { /* error; error message is on stack top */ + lua_pushnil(L); + lua_insert(L, -2); + lua_pushstring(L, (stat == ERRLIB) ? LIB_FAIL : "init"); + return 3; /* return nil, error message, and where */ + } +} + + + +/* +** {====================================================== +** 'require' function +** ======================================================= +*/ + + +static int readable (const char *filename) { + FILE *f = fopen(filename, "r"); /* try to open file */ + if (f == NULL) return 0; /* open failed */ + fclose(f); + return 1; +} + + +static const char *pushnexttemplate (lua_State *L, const char *path) { + const char *l; + while (*path == *LUA_PATHSEP) path++; /* skip separators */ + if (*path == '\0') return NULL; /* no more templates */ + l = strchr(path, *LUA_PATHSEP); /* find next separator */ + if (l == NULL) l = path + strlen(path); + lua_pushlstring(L, path, l - path); /* template */ + return l; +} + + +static const char *findfile (lua_State *L, const char *name, + const char *pname) { + const char *path; + name = luaL_gsub(L, name, ".", LUA_DIRSEP); + lua_getfield(L, LUA_ENVIRONINDEX, pname); + path = lua_tostring(L, -1); + if (path == NULL) + luaL_error(L, LUA_QL("package.%s") " must be a string", pname); + lua_pushliteral(L, ""); /* error accumulator */ + while ((path = pushnexttemplate(L, path)) != NULL) { + const char *filename; + filename = luaL_gsub(L, lua_tostring(L, -1), LUA_PATH_MARK, name); + lua_remove(L, -2); /* remove path template */ + if (readable(filename)) /* does file exist and is readable? */ + return filename; /* return that file name */ + lua_pushfstring(L, "\n\tno file " LUA_QS, filename); + lua_remove(L, -2); /* remove file name */ + lua_concat(L, 2); /* add entry to possible error message */ + } + return NULL; /* not found */ +} + + +static void loaderror (lua_State *L, const char *filename) { + luaL_error(L, "error loading module " LUA_QS " from file " LUA_QS ":\n\t%s", + lua_tostring(L, 1), filename, lua_tostring(L, -1)); +} + + +static int loader_Lua (lua_State *L) { + const char *filename; + const char *name = luaL_checkstring(L, 1); + filename = findfile(L, name, "path"); + if (filename == NULL) return 1; /* library not found in this path */ + if (luaL_loadfile(L, filename) != 0) + loaderror(L, filename); + return 1; /* library loaded successfully */ +} + + +static const char *mkfuncname (lua_State *L, const char *modname) { + const char *funcname; + const char *mark = strchr(modname, *LUA_IGMARK); + if (mark) modname = mark + 1; + funcname = luaL_gsub(L, modname, ".", LUA_OFSEP); + funcname = lua_pushfstring(L, POF"%s", funcname); + lua_remove(L, -2); /* remove 'gsub' result */ + return funcname; +} + + +static int loader_C (lua_State *L) { + const char *funcname; + const char *name = luaL_checkstring(L, 1); + const char *filename = findfile(L, name, "cpath"); + if (filename == NULL) return 1; /* library not found in this path */ + funcname = mkfuncname(L, name); + if (ll_loadfunc(L, filename, funcname) != 0) + loaderror(L, filename); + return 1; /* library loaded successfully */ +} + + +static int loader_Croot (lua_State *L) { + const char *funcname; + const char *filename; + const char *name = luaL_checkstring(L, 1); + const char *p = strchr(name, '.'); + int stat; + if (p == NULL) return 0; /* is root */ + lua_pushlstring(L, name, p - name); + filename = findfile(L, lua_tostring(L, -1), "cpath"); + if (filename == NULL) return 1; /* root not found */ + funcname = mkfuncname(L, name); + if ((stat = ll_loadfunc(L, filename, funcname)) != 0) { + if (stat != ERRFUNC) loaderror(L, filename); /* real error */ + lua_pushfstring(L, "\n\tno module " LUA_QS " in file " LUA_QS, + name, filename); + return 1; /* function not found */ + } + return 1; +} + + +static int loader_preload (lua_State *L) { + const char *name = luaL_checkstring(L, 1); + lua_getfield(L, LUA_ENVIRONINDEX, "preload"); + if (!lua_istable(L, -1)) + luaL_error(L, LUA_QL("package.preload") " must be a table"); + lua_getfield(L, -1, name); + if (lua_isnil(L, -1)) /* not found? */ + lua_pushfstring(L, "\n\tno field package.preload['%s']", name); + return 1; +} + + +static const int sentinel_ = 0; +#define sentinel ((void *)&sentinel_) + + +static int ll_require (lua_State *L) { + const char *name = luaL_checkstring(L, 1); + int i; + lua_settop(L, 1); /* _LOADED table will be at index 2 */ + lua_getfield(L, LUA_REGISTRYINDEX, "_LOADED"); + lua_getfield(L, 2, name); + if (lua_toboolean(L, -1)) { /* is it there? */ + if (lua_touserdata(L, -1) == sentinel) /* check loops */ + luaL_error(L, "loop or previous error loading module " LUA_QS, name); + return 1; /* package is already loaded */ + } + /* else must load it; iterate over available loaders */ + lua_getfield(L, LUA_ENVIRONINDEX, "loaders"); + if (!lua_istable(L, -1)) + luaL_error(L, LUA_QL("package.loaders") " must be a table"); + lua_pushliteral(L, ""); /* error message accumulator */ + for (i=1; ; i++) { + lua_rawgeti(L, -2, i); /* get a loader */ + if (lua_isnil(L, -1)) + luaL_error(L, "module " LUA_QS " not found:%s", + name, lua_tostring(L, -2)); + lua_pushstring(L, name); + lua_call(L, 1, 1); /* call it */ + if (lua_isfunction(L, -1)) /* did it find module? */ + break; /* module loaded successfully */ + else if (lua_isstring(L, -1)) /* loader returned error message? */ + lua_concat(L, 2); /* accumulate it */ + else + lua_pop(L, 1); + } + lua_pushlightuserdata(L, sentinel); + lua_setfield(L, 2, name); /* _LOADED[name] = sentinel */ + lua_pushstring(L, name); /* pass name as argument to module */ + lua_call(L, 1, 1); /* run loaded module */ + if (!lua_isnil(L, -1)) /* non-nil return? */ + lua_setfield(L, 2, name); /* _LOADED[name] = returned value */ + lua_getfield(L, 2, name); + if (lua_touserdata(L, -1) == sentinel) { /* module did not set a value? */ + lua_pushboolean(L, 1); /* use true as result */ + lua_pushvalue(L, -1); /* extra copy to be returned */ + lua_setfield(L, 2, name); /* _LOADED[name] = true */ + } + return 1; +} + +/* }====================================================== */ + + + +/* +** {====================================================== +** 'module' function +** ======================================================= +*/ + + +static void setfenv (lua_State *L) { + lua_Debug ar; + if (lua_getstack(L, 1, &ar) == 0 || + lua_getinfo(L, "f", &ar) == 0 || /* get calling function */ + lua_iscfunction(L, -1)) + luaL_error(L, LUA_QL("module") " not called from a Lua function"); + lua_pushvalue(L, -2); + lua_setfenv(L, -2); + lua_pop(L, 1); +} + + +static void dooptions (lua_State *L, int n) { + int i; + for (i = 2; i <= n; i++) { + lua_pushvalue(L, i); /* get option (a function) */ + lua_pushvalue(L, -2); /* module */ + lua_call(L, 1, 0); + } +} + + +static void modinit (lua_State *L, const char *modname) { + const char *dot; + lua_pushvalue(L, -1); + lua_setfield(L, -2, "_M"); /* module._M = module */ + lua_pushstring(L, modname); + lua_setfield(L, -2, "_NAME"); + dot = strrchr(modname, '.'); /* look for last dot in module name */ + if (dot == NULL) dot = modname; + else dot++; + /* set _PACKAGE as package name (full module name minus last part) */ + lua_pushlstring(L, modname, dot - modname); + lua_setfield(L, -2, "_PACKAGE"); +} + + +static int ll_module (lua_State *L) { + const char *modname = luaL_checkstring(L, 1); + int loaded = lua_gettop(L) + 1; /* index of _LOADED table */ + lua_getfield(L, LUA_REGISTRYINDEX, "_LOADED"); + lua_getfield(L, loaded, modname); /* get _LOADED[modname] */ + if (!lua_istable(L, -1)) { /* not found? */ + lua_pop(L, 1); /* remove previous result */ + /* try global variable (and create one if it does not exist) */ + if (luaL_findtable(L, LUA_GLOBALSINDEX, modname, 1) != NULL) + return luaL_error(L, "name conflict for module " LUA_QS, modname); + lua_pushvalue(L, -1); + lua_setfield(L, loaded, modname); /* _LOADED[modname] = new table */ + } + /* check whether table already has a _NAME field */ + lua_getfield(L, -1, "_NAME"); + if (!lua_isnil(L, -1)) /* is table an initialized module? */ + lua_pop(L, 1); + else { /* no; initialize it */ + lua_pop(L, 1); + modinit(L, modname); + } + lua_pushvalue(L, -1); + setfenv(L); + dooptions(L, loaded - 1); + return 0; +} + + +static int ll_seeall (lua_State *L) { + luaL_checktype(L, 1, LUA_TTABLE); + if (!lua_getmetatable(L, 1)) { + lua_createtable(L, 0, 1); /* create new metatable */ + lua_pushvalue(L, -1); + lua_setmetatable(L, 1); + } + lua_pushvalue(L, LUA_GLOBALSINDEX); + lua_setfield(L, -2, "__index"); /* mt.__index = _G */ + return 0; +} + + +/* }====================================================== */ + + + +/* auxiliary mark (for internal use) */ +#define AUXMARK "\1" + +static void setpath (lua_State *L, const char *fieldname, const char *envname, + const char *def) { + const char *path = getenv(envname); + if (path == NULL) /* no environment variable? */ + lua_pushstring(L, def); /* use default */ + else { + /* replace ";;" by ";AUXMARK;" and then AUXMARK by default path */ + path = luaL_gsub(L, path, LUA_PATHSEP LUA_PATHSEP, + LUA_PATHSEP AUXMARK LUA_PATHSEP); + luaL_gsub(L, path, AUXMARK, def); + lua_remove(L, -2); + } + setprogdir(L); + lua_setfield(L, -2, fieldname); +} + + +static const luaL_Reg pk_funcs[] = { + {"loadlib", ll_loadlib}, + {"seeall", ll_seeall}, + {NULL, NULL} +}; + + +static const luaL_Reg ll_funcs[] = { + {"module", ll_module}, + {"require", ll_require}, + {NULL, NULL} +}; + + +static const lua_CFunction loaders[] = + {loader_preload, loader_Lua, loader_C, loader_Croot, NULL}; + + +LUALIB_API int luaopen_package (lua_State *L) { + int i; + /* create new type _LOADLIB */ + luaL_newmetatable(L, "_LOADLIB"); + lua_pushcfunction(L, gctm); + lua_setfield(L, -2, "__gc"); + /* create `package' table */ + luaL_register(L, LUA_LOADLIBNAME, pk_funcs); +#if defined(LUA_COMPAT_LOADLIB) + lua_getfield(L, -1, "loadlib"); + lua_setfield(L, LUA_GLOBALSINDEX, "loadlib"); +#endif + lua_pushvalue(L, -1); + lua_replace(L, LUA_ENVIRONINDEX); + /* create `loaders' table */ + lua_createtable(L, 0, sizeof(loaders)/sizeof(loaders[0]) - 1); + /* fill it with pre-defined loaders */ + for (i=0; loaders[i] != NULL; i++) { + lua_pushcfunction(L, loaders[i]); + lua_rawseti(L, -2, i+1); + } + lua_setfield(L, -2, "loaders"); /* put it in field `loaders' */ + setpath(L, "path", LUA_PATH, LUA_PATH_DEFAULT); /* set field `path' */ + setpath(L, "cpath", LUA_CPATH, LUA_CPATH_DEFAULT); /* set field `cpath' */ + /* store config information */ + lua_pushliteral(L, LUA_DIRSEP "\n" LUA_PATHSEP "\n" LUA_PATH_MARK "\n" + LUA_EXECDIR "\n" LUA_IGMARK); + lua_setfield(L, -2, "config"); + /* set field `loaded' */ + luaL_findtable(L, LUA_REGISTRYINDEX, "_LOADED", 2); + lua_setfield(L, -2, "loaded"); + /* set field `preload' */ + lua_newtable(L); + lua_setfield(L, -2, "preload"); + lua_pushvalue(L, LUA_GLOBALSINDEX); + luaL_register(L, NULL, ll_funcs); /* open lib into global table */ + lua_pop(L, 1); + return 1; /* return 'package' table */ +} + diff --git a/lua/lobject.c b/lua/lobject.c new file mode 100644 index 0000000..4ff5073 --- /dev/null +++ b/lua/lobject.c @@ -0,0 +1,214 @@ +/* +** $Id: lobject.c,v 2.22.1.1 2007/12/27 13:02:25 roberto Exp $ +** Some generic functions over Lua objects +** See Copyright Notice in lua.h +*/ + +#include +#include +#include +#include +#include + +#define lobject_c +#define LUA_CORE + +#include "lua.h" + +#include "ldo.h" +#include "lmem.h" +#include "lobject.h" +#include "lstate.h" +#include "lstring.h" +#include "lvm.h" + + + +const TValue luaO_nilobject_ = {{NULL}, LUA_TNIL}; + + +/* +** converts an integer to a "floating point byte", represented as +** (eeeeexxx), where the real value is (1xxx) * 2^(eeeee - 1) if +** eeeee != 0 and (xxx) otherwise. +*/ +int luaO_int2fb (unsigned int x) { + int e = 0; /* expoent */ + while (x >= 16) { + x = (x+1) >> 1; + e++; + } + if (x < 8) return x; + else return ((e+1) << 3) | (cast_int(x) - 8); +} + + +/* converts back */ +int luaO_fb2int (int x) { + int e = (x >> 3) & 31; + if (e == 0) return x; + else return ((x & 7)+8) << (e - 1); +} + + +int luaO_log2 (unsigned int x) { + static const lu_byte log_2[256] = { + 0,1,2,2,3,3,3,3,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5, + 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6, + 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, + 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, + 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, + 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, + 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, + 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8 + }; + int l = -1; + while (x >= 256) { l += 8; x >>= 8; } + return l + log_2[x]; + +} + + +int luaO_rawequalObj (const TValue *t1, const TValue *t2) { + if (ttype(t1) != ttype(t2)) return 0; + else switch (ttype(t1)) { + case LUA_TNIL: + return 1; + case LUA_TNUMBER: + return luai_numeq(nvalue(t1), nvalue(t2)); + case LUA_TBOOLEAN: + return bvalue(t1) == bvalue(t2); /* boolean true must be 1 !! */ + case LUA_TLIGHTUSERDATA: + return pvalue(t1) == pvalue(t2); + default: + lua_assert(iscollectable(t1)); + return gcvalue(t1) == gcvalue(t2); + } +} + + +int luaO_str2d (const char *s, lua_Number *result) { + char *endptr; + *result = lua_str2number(s, &endptr); + if (endptr == s) return 0; /* conversion failed */ + if (*endptr == 'x' || *endptr == 'X') /* maybe an hexadecimal constant? */ + *result = cast_num(strtoul(s, &endptr, 16)); + if (*endptr == '\0') return 1; /* most common case */ + while (isspace(cast(unsigned char, *endptr))) endptr++; + if (*endptr != '\0') return 0; /* invalid trailing characters? */ + return 1; +} + + + +static void pushstr (lua_State *L, const char *str) { + setsvalue2s(L, L->top, luaS_new(L, str)); + incr_top(L); +} + + +/* this function handles only `%d', `%c', %f, %p, and `%s' formats */ +const char *luaO_pushvfstring (lua_State *L, const char *fmt, va_list argp) { + int n = 1; + pushstr(L, ""); + for (;;) { + const char *e = strchr(fmt, '%'); + if (e == NULL) break; + setsvalue2s(L, L->top, luaS_newlstr(L, fmt, e-fmt)); + incr_top(L); + switch (*(e+1)) { + case 's': { + const char *s = va_arg(argp, char *); + if (s == NULL) s = "(null)"; + pushstr(L, s); + break; + } + case 'c': { + char buff[2]; + buff[0] = cast(char, va_arg(argp, int)); + buff[1] = '\0'; + pushstr(L, buff); + break; + } + case 'd': { + setnvalue(L->top, cast_num(va_arg(argp, int))); + incr_top(L); + break; + } + case 'f': { + setnvalue(L->top, cast_num(va_arg(argp, l_uacNumber))); + incr_top(L); + break; + } + case 'p': { + char buff[4*sizeof(void *) + 8]; /* should be enough space for a `%p' */ + sprintf(buff, "%p", va_arg(argp, void *)); + pushstr(L, buff); + break; + } + case '%': { + pushstr(L, "%"); + break; + } + default: { + char buff[3]; + buff[0] = '%'; + buff[1] = *(e+1); + buff[2] = '\0'; + pushstr(L, buff); + break; + } + } + n += 2; + fmt = e+2; + } + pushstr(L, fmt); + luaV_concat(L, n+1, cast_int(L->top - L->base) - 1); + L->top -= n; + return svalue(L->top - 1); +} + + +const char *luaO_pushfstring (lua_State *L, const char *fmt, ...) { + const char *msg; + va_list argp; + va_start(argp, fmt); + msg = luaO_pushvfstring(L, fmt, argp); + va_end(argp); + return msg; +} + + +void luaO_chunkid (char *out, const char *source, size_t bufflen) { + if (*source == '=') { + strncpy(out, source+1, bufflen); /* remove first char */ + out[bufflen-1] = '\0'; /* ensures null termination */ + } + else { /* out = "source", or "...source" */ + if (*source == '@') { + size_t l; + source++; /* skip the `@' */ + bufflen -= sizeof(" '...' "); + l = strlen(source); + strcpy(out, ""); + if (l > bufflen) { + source += (l-bufflen); /* get last part of file name */ + strcat(out, "..."); + } + strcat(out, source); + } + else { /* out = [string "string"] */ + size_t len = strcspn(source, "\n\r"); /* stop at first newline */ + bufflen -= sizeof(" [string \"...\"] "); + if (len > bufflen) len = bufflen; + strcpy(out, "[string \""); + if (source[len] != '\0') { /* must truncate? */ + strncat(out, source, len); + strcat(out, "..."); + } + else + strcat(out, source); + strcat(out, "\"]"); + } + } +} diff --git a/lua/lobject.h b/lua/lobject.h new file mode 100644 index 0000000..f1e447e --- /dev/null +++ b/lua/lobject.h @@ -0,0 +1,381 @@ +/* +** $Id: lobject.h,v 2.20.1.2 2008/08/06 13:29:48 roberto Exp $ +** Type definitions for Lua objects +** See Copyright Notice in lua.h +*/ + + +#ifndef lobject_h +#define lobject_h + + +#include + + +#include "llimits.h" +#include "lua.h" + + +/* tags for values visible from Lua */ +#define LAST_TAG LUA_TTHREAD + +#define NUM_TAGS (LAST_TAG+1) + + +/* +** Extra tags for non-values +*/ +#define LUA_TPROTO (LAST_TAG+1) +#define LUA_TUPVAL (LAST_TAG+2) +#define LUA_TDEADKEY (LAST_TAG+3) + + +/* +** Union of all collectable objects +*/ +typedef union GCObject GCObject; + + +/* +** Common Header for all collectable objects (in macro form, to be +** included in other objects) +*/ +#define CommonHeader GCObject *next; lu_byte tt; lu_byte marked + + +/* +** Common header in struct form +*/ +typedef struct GCheader { + CommonHeader; +} GCheader; + + + + +/* +** Union of all Lua values +*/ +typedef union { + GCObject *gc; + void *p; + lua_Number n; + int b; +} Value; + + +/* +** Tagged Values +*/ + +#define TValuefields Value value; int tt + +typedef struct lua_TValue { + TValuefields; +} TValue; + + +/* Macros to test type */ +#define ttisnil(o) (ttype(o) == LUA_TNIL) +#define ttisnumber(o) (ttype(o) == LUA_TNUMBER) +#define ttisstring(o) (ttype(o) == LUA_TSTRING) +#define ttistable(o) (ttype(o) == LUA_TTABLE) +#define ttisfunction(o) (ttype(o) == LUA_TFUNCTION) +#define ttisboolean(o) (ttype(o) == LUA_TBOOLEAN) +#define ttisuserdata(o) (ttype(o) == LUA_TUSERDATA) +#define ttisthread(o) (ttype(o) == LUA_TTHREAD) +#define ttislightuserdata(o) (ttype(o) == LUA_TLIGHTUSERDATA) + +/* Macros to access values */ +#define ttype(o) ((o)->tt) +#define gcvalue(o) check_exp(iscollectable(o), (o)->value.gc) +#define pvalue(o) check_exp(ttislightuserdata(o), (o)->value.p) +#define nvalue(o) check_exp(ttisnumber(o), (o)->value.n) +#define rawtsvalue(o) check_exp(ttisstring(o), &(o)->value.gc->ts) +#define tsvalue(o) (&rawtsvalue(o)->tsv) +#define rawuvalue(o) check_exp(ttisuserdata(o), &(o)->value.gc->u) +#define uvalue(o) (&rawuvalue(o)->uv) +#define clvalue(o) check_exp(ttisfunction(o), &(o)->value.gc->cl) +#define hvalue(o) check_exp(ttistable(o), &(o)->value.gc->h) +#define bvalue(o) check_exp(ttisboolean(o), (o)->value.b) +#define thvalue(o) check_exp(ttisthread(o), &(o)->value.gc->th) + +#define l_isfalse(o) (ttisnil(o) || (ttisboolean(o) && bvalue(o) == 0)) + +/* +** for internal debug only +*/ +#define checkconsistency(obj) \ + lua_assert(!iscollectable(obj) || (ttype(obj) == (obj)->value.gc->gch.tt)) + +#define checkliveness(g,obj) \ + lua_assert(!iscollectable(obj) || \ + ((ttype(obj) == (obj)->value.gc->gch.tt) && !isdead(g, (obj)->value.gc))) + + +/* Macros to set values */ +#define setnilvalue(obj) ((obj)->tt=LUA_TNIL) + +#define setnvalue(obj,x) \ + { TValue *i_o=(obj); i_o->value.n=(x); i_o->tt=LUA_TNUMBER; } + +#define setpvalue(obj,x) \ + { TValue *i_o=(obj); i_o->value.p=(x); i_o->tt=LUA_TLIGHTUSERDATA; } + +#define setbvalue(obj,x) \ + { TValue *i_o=(obj); i_o->value.b=(x); i_o->tt=LUA_TBOOLEAN; } + +#define setsvalue(L,obj,x) \ + { TValue *i_o=(obj); \ + i_o->value.gc=cast(GCObject *, (x)); i_o->tt=LUA_TSTRING; \ + checkliveness(G(L),i_o); } + +#define setuvalue(L,obj,x) \ + { TValue *i_o=(obj); \ + i_o->value.gc=cast(GCObject *, (x)); i_o->tt=LUA_TUSERDATA; \ + checkliveness(G(L),i_o); } + +#define setthvalue(L,obj,x) \ + { TValue *i_o=(obj); \ + i_o->value.gc=cast(GCObject *, (x)); i_o->tt=LUA_TTHREAD; \ + checkliveness(G(L),i_o); } + +#define setclvalue(L,obj,x) \ + { TValue *i_o=(obj); \ + i_o->value.gc=cast(GCObject *, (x)); i_o->tt=LUA_TFUNCTION; \ + checkliveness(G(L),i_o); } + +#define sethvalue(L,obj,x) \ + { TValue *i_o=(obj); \ + i_o->value.gc=cast(GCObject *, (x)); i_o->tt=LUA_TTABLE; \ + checkliveness(G(L),i_o); } + +#define setptvalue(L,obj,x) \ + { TValue *i_o=(obj); \ + i_o->value.gc=cast(GCObject *, (x)); i_o->tt=LUA_TPROTO; \ + checkliveness(G(L),i_o); } + + + + +#define setobj(L,obj1,obj2) \ + { const TValue *o2=(obj2); TValue *o1=(obj1); \ + o1->value = o2->value; o1->tt=o2->tt; \ + checkliveness(G(L),o1); } + + +/* +** different types of sets, according to destination +*/ + +/* from stack to (same) stack */ +#define setobjs2s setobj +/* to stack (not from same stack) */ +#define setobj2s setobj +#define setsvalue2s setsvalue +#define sethvalue2s sethvalue +#define setptvalue2s setptvalue +/* from table to same table */ +#define setobjt2t setobj +/* to table */ +#define setobj2t setobj +/* to new object */ +#define setobj2n setobj +#define setsvalue2n setsvalue + +#define setttype(obj, tt) (ttype(obj) = (tt)) + + +#define iscollectable(o) (ttype(o) >= LUA_TSTRING) + + + +typedef TValue *StkId; /* index to stack elements */ + + +/* +** String headers for string table +*/ +typedef union TString { + L_Umaxalign dummy; /* ensures maximum alignment for strings */ + struct { + CommonHeader; + lu_byte reserved; + unsigned int hash; + size_t len; + } tsv; +} TString; + + +#define getstr(ts) cast(const char *, (ts) + 1) +#define svalue(o) getstr(rawtsvalue(o)) + + + +typedef union Udata { + L_Umaxalign dummy; /* ensures maximum alignment for `local' udata */ + struct { + CommonHeader; + struct Table *metatable; + struct Table *env; + size_t len; + } uv; +} Udata; + + + + +/* +** Function Prototypes +*/ +typedef struct Proto { + CommonHeader; + TValue *k; /* constants used by the function */ + Instruction *code; + struct Proto **p; /* functions defined inside the function */ + int *lineinfo; /* map from opcodes to source lines */ + struct LocVar *locvars; /* information about local variables */ + TString **upvalues; /* upvalue names */ + TString *source; + int sizeupvalues; + int sizek; /* size of `k' */ + int sizecode; + int sizelineinfo; + int sizep; /* size of `p' */ + int sizelocvars; + int linedefined; + int lastlinedefined; + GCObject *gclist; + lu_byte nups; /* number of upvalues */ + lu_byte numparams; + lu_byte is_vararg; + lu_byte maxstacksize; +} Proto; + + +/* masks for new-style vararg */ +#define VARARG_HASARG 1 +#define VARARG_ISVARARG 2 +#define VARARG_NEEDSARG 4 + + +typedef struct LocVar { + TString *varname; + int startpc; /* first point where variable is active */ + int endpc; /* first point where variable is dead */ +} LocVar; + + + +/* +** Upvalues +*/ + +typedef struct UpVal { + CommonHeader; + TValue *v; /* points to stack or to its own value */ + union { + TValue value; /* the value (when closed) */ + struct { /* double linked list (when open) */ + struct UpVal *prev; + struct UpVal *next; + } l; + } u; +} UpVal; + + +/* +** Closures +*/ + +#define ClosureHeader \ + CommonHeader; lu_byte isC; lu_byte nupvalues; GCObject *gclist; \ + struct Table *env + +typedef struct CClosure { + ClosureHeader; + lua_CFunction f; + TValue upvalue[1]; +} CClosure; + + +typedef struct LClosure { + ClosureHeader; + struct Proto *p; + UpVal *upvals[1]; +} LClosure; + + +typedef union Closure { + CClosure c; + LClosure l; +} Closure; + + +#define iscfunction(o) (ttype(o) == LUA_TFUNCTION && clvalue(o)->c.isC) +#define isLfunction(o) (ttype(o) == LUA_TFUNCTION && !clvalue(o)->c.isC) + + +/* +** Tables +*/ + +typedef union TKey { + struct { + TValuefields; + struct Node *next; /* for chaining */ + } nk; + TValue tvk; +} TKey; + + +typedef struct Node { + TValue i_val; + TKey i_key; +} Node; + + +typedef struct Table { + CommonHeader; + lu_byte flags; /* 1<

lsizenode)) + + +#define luaO_nilobject (&luaO_nilobject_) + +LUAI_DATA const TValue luaO_nilobject_; + +#define ceillog2(x) (luaO_log2((x)-1) + 1) + +LUAI_FUNC int luaO_log2 (unsigned int x); +LUAI_FUNC int luaO_int2fb (unsigned int x); +LUAI_FUNC int luaO_fb2int (int x); +LUAI_FUNC int luaO_rawequalObj (const TValue *t1, const TValue *t2); +LUAI_FUNC int luaO_str2d (const char *s, lua_Number *result); +LUAI_FUNC const char *luaO_pushvfstring (lua_State *L, const char *fmt, + va_list argp); +LUAI_FUNC const char *luaO_pushfstring (lua_State *L, const char *fmt, ...); +LUAI_FUNC void luaO_chunkid (char *out, const char *source, size_t len); + + +#endif + diff --git a/lua/lopcodes.c b/lua/lopcodes.c new file mode 100644 index 0000000..4cc7452 --- /dev/null +++ b/lua/lopcodes.c @@ -0,0 +1,102 @@ +/* +** $Id: lopcodes.c,v 1.37.1.1 2007/12/27 13:02:25 roberto Exp $ +** See Copyright Notice in lua.h +*/ + + +#define lopcodes_c +#define LUA_CORE + + +#include "lopcodes.h" + + +/* ORDER OP */ + +const char *const luaP_opnames[NUM_OPCODES+1] = { + "MOVE", + "LOADK", + "LOADBOOL", + "LOADNIL", + "GETUPVAL", + "GETGLOBAL", + "GETTABLE", + "SETGLOBAL", + "SETUPVAL", + "SETTABLE", + "NEWTABLE", + "SELF", + "ADD", + "SUB", + "MUL", + "DIV", + "MOD", + "POW", + "UNM", + "NOT", + "LEN", + "CONCAT", + "JMP", + "EQ", + "LT", + "LE", + "TEST", + "TESTSET", + "CALL", + "TAILCALL", + "RETURN", + "FORLOOP", + "FORPREP", + "TFORLOOP", + "SETLIST", + "CLOSE", + "CLOSURE", + "VARARG", + NULL +}; + + +#define opmode(t,a,b,c,m) (((t)<<7) | ((a)<<6) | ((b)<<4) | ((c)<<2) | (m)) + +const lu_byte luaP_opmodes[NUM_OPCODES] = { +/* T A B C mode opcode */ + opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_MOVE */ + ,opmode(0, 1, OpArgK, OpArgN, iABx) /* OP_LOADK */ + ,opmode(0, 1, OpArgU, OpArgU, iABC) /* OP_LOADBOOL */ + ,opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_LOADNIL */ + ,opmode(0, 1, OpArgU, OpArgN, iABC) /* OP_GETUPVAL */ + ,opmode(0, 1, OpArgK, OpArgN, iABx) /* OP_GETGLOBAL */ + ,opmode(0, 1, OpArgR, OpArgK, iABC) /* OP_GETTABLE */ + ,opmode(0, 0, OpArgK, OpArgN, iABx) /* OP_SETGLOBAL */ + ,opmode(0, 0, OpArgU, OpArgN, iABC) /* OP_SETUPVAL */ + ,opmode(0, 0, OpArgK, OpArgK, iABC) /* OP_SETTABLE */ + ,opmode(0, 1, OpArgU, OpArgU, iABC) /* OP_NEWTABLE */ + ,opmode(0, 1, OpArgR, OpArgK, iABC) /* OP_SELF */ + ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_ADD */ + ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_SUB */ + ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_MUL */ + ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_DIV */ + ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_MOD */ + ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_POW */ + ,opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_UNM */ + ,opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_NOT */ + ,opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_LEN */ + ,opmode(0, 1, OpArgR, OpArgR, iABC) /* OP_CONCAT */ + ,opmode(0, 0, OpArgR, OpArgN, iAsBx) /* OP_JMP */ + ,opmode(1, 0, OpArgK, OpArgK, iABC) /* OP_EQ */ + ,opmode(1, 0, OpArgK, OpArgK, iABC) /* OP_LT */ + ,opmode(1, 0, OpArgK, OpArgK, iABC) /* OP_LE */ + ,opmode(1, 1, OpArgR, OpArgU, iABC) /* OP_TEST */ + ,opmode(1, 1, OpArgR, OpArgU, iABC) /* OP_TESTSET */ + ,opmode(0, 1, OpArgU, OpArgU, iABC) /* OP_CALL */ + ,opmode(0, 1, OpArgU, OpArgU, iABC) /* OP_TAILCALL */ + ,opmode(0, 0, OpArgU, OpArgN, iABC) /* OP_RETURN */ + ,opmode(0, 1, OpArgR, OpArgN, iAsBx) /* OP_FORLOOP */ + ,opmode(0, 1, OpArgR, OpArgN, iAsBx) /* OP_FORPREP */ + ,opmode(1, 0, OpArgN, OpArgU, iABC) /* OP_TFORLOOP */ + ,opmode(0, 0, OpArgU, OpArgU, iABC) /* OP_SETLIST */ + ,opmode(0, 0, OpArgN, OpArgN, iABC) /* OP_CLOSE */ + ,opmode(0, 1, OpArgU, OpArgN, iABx) /* OP_CLOSURE */ + ,opmode(0, 1, OpArgU, OpArgN, iABC) /* OP_VARARG */ +}; + diff --git a/lua/lopcodes.h b/lua/lopcodes.h new file mode 100644 index 0000000..41224d6 --- /dev/null +++ b/lua/lopcodes.h @@ -0,0 +1,268 @@ +/* +** $Id: lopcodes.h,v 1.125.1.1 2007/12/27 13:02:25 roberto Exp $ +** Opcodes for Lua virtual machine +** See Copyright Notice in lua.h +*/ + +#ifndef lopcodes_h +#define lopcodes_h + +#include "llimits.h" + + +/*=========================================================================== + We assume that instructions are unsigned numbers. + All instructions have an opcode in the first 6 bits. + Instructions can have the following fields: + `A' : 8 bits + `B' : 9 bits + `C' : 9 bits + `Bx' : 18 bits (`B' and `C' together) + `sBx' : signed Bx + + A signed argument is represented in excess K; that is, the number + value is the unsigned value minus K. K is exactly the maximum value + for that argument (so that -max is represented by 0, and +max is + represented by 2*max), which is half the maximum for the corresponding + unsigned argument. +===========================================================================*/ + + +enum OpMode {iABC, iABx, iAsBx}; /* basic instruction format */ + + +/* +** size and position of opcode arguments. +*/ +#define SIZE_C 9 +#define SIZE_B 9 +#define SIZE_Bx (SIZE_C + SIZE_B) +#define SIZE_A 8 + +#define SIZE_OP 6 + +#define POS_OP 0 +#define POS_A (POS_OP + SIZE_OP) +#define POS_C (POS_A + SIZE_A) +#define POS_B (POS_C + SIZE_C) +#define POS_Bx POS_C + + +/* +** limits for opcode arguments. +** we use (signed) int to manipulate most arguments, +** so they must fit in LUAI_BITSINT-1 bits (-1 for sign) +*/ +#if SIZE_Bx < LUAI_BITSINT-1 +#define MAXARG_Bx ((1<>1) /* `sBx' is signed */ +#else +#define MAXARG_Bx MAX_INT +#define MAXARG_sBx MAX_INT +#endif + + +#define MAXARG_A ((1<>POS_OP) & MASK1(SIZE_OP,0))) +#define SET_OPCODE(i,o) ((i) = (((i)&MASK0(SIZE_OP,POS_OP)) | \ + ((cast(Instruction, o)<>POS_A) & MASK1(SIZE_A,0))) +#define SETARG_A(i,u) ((i) = (((i)&MASK0(SIZE_A,POS_A)) | \ + ((cast(Instruction, u)<>POS_B) & MASK1(SIZE_B,0))) +#define SETARG_B(i,b) ((i) = (((i)&MASK0(SIZE_B,POS_B)) | \ + ((cast(Instruction, b)<>POS_C) & MASK1(SIZE_C,0))) +#define SETARG_C(i,b) ((i) = (((i)&MASK0(SIZE_C,POS_C)) | \ + ((cast(Instruction, b)<>POS_Bx) & MASK1(SIZE_Bx,0))) +#define SETARG_Bx(i,b) ((i) = (((i)&MASK0(SIZE_Bx,POS_Bx)) | \ + ((cast(Instruction, b)< C) then pc++ */ +OP_TESTSET,/* A B C if (R(B) <=> C) then R(A) := R(B) else pc++ */ + +OP_CALL,/* A B C R(A), ... ,R(A+C-2) := R(A)(R(A+1), ... ,R(A+B-1)) */ +OP_TAILCALL,/* A B C return R(A)(R(A+1), ... ,R(A+B-1)) */ +OP_RETURN,/* A B return R(A), ... ,R(A+B-2) (see note) */ + +OP_FORLOOP,/* A sBx R(A)+=R(A+2); + if R(A) =) R(A)*/ +OP_CLOSURE,/* A Bx R(A) := closure(KPROTO[Bx], R(A), ... ,R(A+n)) */ + +OP_VARARG/* A B R(A), R(A+1), ..., R(A+B-1) = vararg */ +} OpCode; + + +#define NUM_OPCODES (cast(int, OP_VARARG) + 1) + + + +/*=========================================================================== + Notes: + (*) In OP_CALL, if (B == 0) then B = top. C is the number of returns - 1, + and can be 0: OP_CALL then sets `top' to last_result+1, so + next open instruction (OP_CALL, OP_RETURN, OP_SETLIST) may use `top'. + + (*) In OP_VARARG, if (B == 0) then use actual number of varargs and + set top (like in OP_CALL with C == 0). + + (*) In OP_RETURN, if (B == 0) then return up to `top' + + (*) In OP_SETLIST, if (B == 0) then B = `top'; + if (C == 0) then next `instruction' is real C + + (*) For comparisons, A specifies what condition the test should accept + (true or false). + + (*) All `skips' (pc++) assume that next instruction is a jump +===========================================================================*/ + + +/* +** masks for instruction properties. The format is: +** bits 0-1: op mode +** bits 2-3: C arg mode +** bits 4-5: B arg mode +** bit 6: instruction set register A +** bit 7: operator is a test +*/ + +enum OpArgMask { + OpArgN, /* argument is not used */ + OpArgU, /* argument is used */ + OpArgR, /* argument is a register or a jump offset */ + OpArgK /* argument is a constant or register/constant */ +}; + +LUAI_DATA const lu_byte luaP_opmodes[NUM_OPCODES]; + +#define getOpMode(m) (cast(enum OpMode, luaP_opmodes[m] & 3)) +#define getBMode(m) (cast(enum OpArgMask, (luaP_opmodes[m] >> 4) & 3)) +#define getCMode(m) (cast(enum OpArgMask, (luaP_opmodes[m] >> 2) & 3)) +#define testAMode(m) (luaP_opmodes[m] & (1 << 6)) +#define testTMode(m) (luaP_opmodes[m] & (1 << 7)) + + +LUAI_DATA const char *const luaP_opnames[NUM_OPCODES+1]; /* opcode names */ + + +/* number of list items to accumulate before a SETLIST instruction */ +#define LFIELDS_PER_FLUSH 50 + + +#endif diff --git a/lua/loslib.c b/lua/loslib.c new file mode 100644 index 0000000..da06a57 --- /dev/null +++ b/lua/loslib.c @@ -0,0 +1,243 @@ +/* +** $Id: loslib.c,v 1.19.1.3 2008/01/18 16:38:18 roberto Exp $ +** Standard Operating System library +** See Copyright Notice in lua.h +*/ + + +#include +#include +#include +#include +#include + +#define loslib_c +#define LUA_LIB + +#include "lua.h" + +#include "lauxlib.h" +#include "lualib.h" + + +static int os_pushresult (lua_State *L, int i, const char *filename) { + int en = errno; /* calls to Lua API may change this value */ + if (i) { + lua_pushboolean(L, 1); + return 1; + } + else { + lua_pushnil(L); + lua_pushfstring(L, "%s: %s", filename, strerror(en)); + lua_pushinteger(L, en); + return 3; + } +} + + +static int os_execute (lua_State *L) { + lua_pushinteger(L, system(luaL_optstring(L, 1, NULL))); + return 1; +} + + +static int os_remove (lua_State *L) { + const char *filename = luaL_checkstring(L, 1); + return os_pushresult(L, remove(filename) == 0, filename); +} + + +static int os_rename (lua_State *L) { + const char *fromname = luaL_checkstring(L, 1); + const char *toname = luaL_checkstring(L, 2); + return os_pushresult(L, rename(fromname, toname) == 0, fromname); +} + + +static int os_tmpname (lua_State *L) { + char buff[LUA_TMPNAMBUFSIZE]; + int err; + lua_tmpnam(buff, err); + if (err) + return luaL_error(L, "unable to generate a unique filename"); + lua_pushstring(L, buff); + return 1; +} + + +static int os_getenv (lua_State *L) { + lua_pushstring(L, getenv(luaL_checkstring(L, 1))); /* if NULL push nil */ + return 1; +} + + +static int os_clock (lua_State *L) { + lua_pushnumber(L, ((lua_Number)clock())/(lua_Number)CLOCKS_PER_SEC); + return 1; +} + + +/* +** {====================================================== +** Time/Date operations +** { year=%Y, month=%m, day=%d, hour=%H, min=%M, sec=%S, +** wday=%w+1, yday=%j, isdst=? } +** ======================================================= +*/ + +static void setfield (lua_State *L, const char *key, int value) { + lua_pushinteger(L, value); + lua_setfield(L, -2, key); +} + +static void setboolfield (lua_State *L, const char *key, int value) { + if (value < 0) /* undefined? */ + return; /* does not set field */ + lua_pushboolean(L, value); + lua_setfield(L, -2, key); +} + +static int getboolfield (lua_State *L, const char *key) { + int res; + lua_getfield(L, -1, key); + res = lua_isnil(L, -1) ? -1 : lua_toboolean(L, -1); + lua_pop(L, 1); + return res; +} + + +static int getfield (lua_State *L, const char *key, int d) { + int res; + lua_getfield(L, -1, key); + if (lua_isnumber(L, -1)) + res = (int)lua_tointeger(L, -1); + else { + if (d < 0) + return luaL_error(L, "field " LUA_QS " missing in date table", key); + res = d; + } + lua_pop(L, 1); + return res; +} + + +static int os_date (lua_State *L) { + const char *s = luaL_optstring(L, 1, "%c"); + time_t t = luaL_opt(L, (time_t)luaL_checknumber, 2, time(NULL)); + struct tm *stm; + if (*s == '!') { /* UTC? */ + stm = gmtime(&t); + s++; /* skip `!' */ + } + else + stm = localtime(&t); + if (stm == NULL) /* invalid date? */ + lua_pushnil(L); + else if (strcmp(s, "*t") == 0) { + lua_createtable(L, 0, 9); /* 9 = number of fields */ + setfield(L, "sec", stm->tm_sec); + setfield(L, "min", stm->tm_min); + setfield(L, "hour", stm->tm_hour); + setfield(L, "day", stm->tm_mday); + setfield(L, "month", stm->tm_mon+1); + setfield(L, "year", stm->tm_year+1900); + setfield(L, "wday", stm->tm_wday+1); + setfield(L, "yday", stm->tm_yday+1); + setboolfield(L, "isdst", stm->tm_isdst); + } + else { + char cc[3]; + luaL_Buffer b; + cc[0] = '%'; cc[2] = '\0'; + luaL_buffinit(L, &b); + for (; *s; s++) { + if (*s != '%' || *(s + 1) == '\0') /* no conversion specifier? */ + luaL_addchar(&b, *s); + else { + size_t reslen; + char buff[200]; /* should be big enough for any conversion result */ + cc[1] = *(++s); + reslen = strftime(buff, sizeof(buff), cc, stm); + luaL_addlstring(&b, buff, reslen); + } + } + luaL_pushresult(&b); + } + return 1; +} + + +static int os_time (lua_State *L) { + time_t t; + if (lua_isnoneornil(L, 1)) /* called without args? */ + t = time(NULL); /* get current time */ + else { + struct tm ts; + luaL_checktype(L, 1, LUA_TTABLE); + lua_settop(L, 1); /* make sure table is at the top */ + ts.tm_sec = getfield(L, "sec", 0); + ts.tm_min = getfield(L, "min", 0); + ts.tm_hour = getfield(L, "hour", 12); + ts.tm_mday = getfield(L, "day", -1); + ts.tm_mon = getfield(L, "month", -1) - 1; + ts.tm_year = getfield(L, "year", -1) - 1900; + ts.tm_isdst = getboolfield(L, "isdst"); + t = mktime(&ts); + } + if (t == (time_t)(-1)) + lua_pushnil(L); + else + lua_pushnumber(L, (lua_Number)t); + return 1; +} + + +static int os_difftime (lua_State *L) { + lua_pushnumber(L, difftime((time_t)(luaL_checknumber(L, 1)), + (time_t)(luaL_optnumber(L, 2, 0)))); + return 1; +} + +/* }====================================================== */ + + +static int os_setlocale (lua_State *L) { + static const int cat[] = {LC_ALL, LC_COLLATE, LC_CTYPE, LC_MONETARY, + LC_NUMERIC, LC_TIME}; + static const char *const catnames[] = {"all", "collate", "ctype", "monetary", + "numeric", "time", NULL}; + const char *l = luaL_optstring(L, 1, NULL); + int op = luaL_checkoption(L, 2, "all", catnames); + lua_pushstring(L, setlocale(cat[op], l)); + return 1; +} + + +static int os_exit (lua_State *L) { + exit(luaL_optint(L, 1, EXIT_SUCCESS)); +} + +static const luaL_Reg syslib[] = { + {"clock", os_clock}, + {"date", os_date}, + {"difftime", os_difftime}, + {"execute", os_execute}, + {"exit", os_exit}, + {"getenv", os_getenv}, + {"remove", os_remove}, + {"rename", os_rename}, + {"setlocale", os_setlocale}, + {"time", os_time}, + {"tmpname", os_tmpname}, + {NULL, NULL} +}; + +/* }====================================================== */ + + + +LUALIB_API int luaopen_os (lua_State *L) { + luaL_register(L, LUA_OSLIBNAME, syslib); + return 1; +} + diff --git a/lua/lparser.c b/lua/lparser.c new file mode 100644 index 0000000..1e2a9a8 --- /dev/null +++ b/lua/lparser.c @@ -0,0 +1,1339 @@ +/* +** $Id: lparser.c,v 2.42.1.3 2007/12/28 15:32:23 roberto Exp $ +** Lua Parser +** See Copyright Notice in lua.h +*/ + + +#include + +#define lparser_c +#define LUA_CORE + +#include "lua.h" + +#include "lcode.h" +#include "ldebug.h" +#include "ldo.h" +#include "lfunc.h" +#include "llex.h" +#include "lmem.h" +#include "lobject.h" +#include "lopcodes.h" +#include "lparser.h" +#include "lstate.h" +#include "lstring.h" +#include "ltable.h" + + + +#define hasmultret(k) ((k) == VCALL || (k) == VVARARG) + +#define getlocvar(fs, i) ((fs)->f->locvars[(fs)->actvar[i]]) + +#define luaY_checklimit(fs,v,l,m) if ((v)>(l)) errorlimit(fs,l,m) + + +/* +** nodes for block list (list of active blocks) +*/ +typedef struct BlockCnt { + struct BlockCnt *previous; /* chain */ + int breaklist; /* list of jumps out of this loop */ + lu_byte nactvar; /* # active locals outside the breakable structure */ + lu_byte upval; /* true if some variable in the block is an upvalue */ + lu_byte isbreakable; /* true if `block' is a loop */ +} BlockCnt; + + + +/* +** prototypes for recursive non-terminal functions +*/ +static void chunk (LexState *ls); +static void expr (LexState *ls, expdesc *v); + + +static void anchor_token (LexState *ls) { + if (ls->t.token == TK_NAME || ls->t.token == TK_STRING) { + TString *ts = ls->t.seminfo.ts; + luaX_newstring(ls, getstr(ts), ts->tsv.len); + } +} + + +static void error_expected (LexState *ls, int token) { + luaX_syntaxerror(ls, + luaO_pushfstring(ls->L, LUA_QS " expected", luaX_token2str(ls, token))); +} + + +static void errorlimit (FuncState *fs, int limit, const char *what) { + const char *msg = (fs->f->linedefined == 0) ? + luaO_pushfstring(fs->L, "main function has more than %d %s", limit, what) : + luaO_pushfstring(fs->L, "function at line %d has more than %d %s", + fs->f->linedefined, limit, what); + luaX_lexerror(fs->ls, msg, 0); +} + + +static int testnext (LexState *ls, int c) { + if (ls->t.token == c) { + luaX_next(ls); + return 1; + } + else return 0; +} + + +static void check (LexState *ls, int c) { + if (ls->t.token != c) + error_expected(ls, c); +} + +static void checknext (LexState *ls, int c) { + check(ls, c); + luaX_next(ls); +} + + +#define check_condition(ls,c,msg) { if (!(c)) luaX_syntaxerror(ls, msg); } + + + +static void check_match (LexState *ls, int what, int who, int where) { + if (!testnext(ls, what)) { + if (where == ls->linenumber) + error_expected(ls, what); + else { + luaX_syntaxerror(ls, luaO_pushfstring(ls->L, + LUA_QS " expected (to close " LUA_QS " at line %d)", + luaX_token2str(ls, what), luaX_token2str(ls, who), where)); + } + } +} + + +static TString *str_checkname (LexState *ls) { + TString *ts; + check(ls, TK_NAME); + ts = ls->t.seminfo.ts; + luaX_next(ls); + return ts; +} + + +static void init_exp (expdesc *e, expkind k, int i) { + e->f = e->t = NO_JUMP; + e->k = k; + e->u.s.info = i; +} + + +static void codestring (LexState *ls, expdesc *e, TString *s) { + init_exp(e, VK, luaK_stringK(ls->fs, s)); +} + + +static void checkname(LexState *ls, expdesc *e) { + codestring(ls, e, str_checkname(ls)); +} + + +static int registerlocalvar (LexState *ls, TString *varname) { + FuncState *fs = ls->fs; + Proto *f = fs->f; + int oldsize = f->sizelocvars; + luaM_growvector(ls->L, f->locvars, fs->nlocvars, f->sizelocvars, + LocVar, SHRT_MAX, "too many local variables"); + while (oldsize < f->sizelocvars) f->locvars[oldsize++].varname = NULL; + f->locvars[fs->nlocvars].varname = varname; + luaC_objbarrier(ls->L, f, varname); + return fs->nlocvars++; +} + + +#define new_localvarliteral(ls,v,n) \ + new_localvar(ls, luaX_newstring(ls, "" v, (sizeof(v)/sizeof(char))-1), n) + + +static void new_localvar (LexState *ls, TString *name, int n) { + FuncState *fs = ls->fs; + luaY_checklimit(fs, fs->nactvar+n+1, LUAI_MAXVARS, "local variables"); + fs->actvar[fs->nactvar+n] = cast(unsigned short, registerlocalvar(ls, name)); +} + + +static void adjustlocalvars (LexState *ls, int nvars) { + FuncState *fs = ls->fs; + fs->nactvar = cast_byte(fs->nactvar + nvars); + for (; nvars; nvars--) { + getlocvar(fs, fs->nactvar - nvars).startpc = fs->pc; + } +} + + +static void removevars (LexState *ls, int tolevel) { + FuncState *fs = ls->fs; + while (fs->nactvar > tolevel) + getlocvar(fs, --fs->nactvar).endpc = fs->pc; +} + + +static int indexupvalue (FuncState *fs, TString *name, expdesc *v) { + int i; + Proto *f = fs->f; + int oldsize = f->sizeupvalues; + for (i=0; inups; i++) { + if (fs->upvalues[i].k == v->k && fs->upvalues[i].info == v->u.s.info) { + lua_assert(f->upvalues[i] == name); + return i; + } + } + /* new one */ + luaY_checklimit(fs, f->nups + 1, LUAI_MAXUPVALUES, "upvalues"); + luaM_growvector(fs->L, f->upvalues, f->nups, f->sizeupvalues, + TString *, MAX_INT, ""); + while (oldsize < f->sizeupvalues) f->upvalues[oldsize++] = NULL; + f->upvalues[f->nups] = name; + luaC_objbarrier(fs->L, f, name); + lua_assert(v->k == VLOCAL || v->k == VUPVAL); + fs->upvalues[f->nups].k = cast_byte(v->k); + fs->upvalues[f->nups].info = cast_byte(v->u.s.info); + return f->nups++; +} + + +static int searchvar (FuncState *fs, TString *n) { + int i; + for (i=fs->nactvar-1; i >= 0; i--) { + if (n == getlocvar(fs, i).varname) + return i; + } + return -1; /* not found */ +} + + +static void markupval (FuncState *fs, int level) { + BlockCnt *bl = fs->bl; + while (bl && bl->nactvar > level) bl = bl->previous; + if (bl) bl->upval = 1; +} + + +static int singlevaraux (FuncState *fs, TString *n, expdesc *var, int base) { + if (fs == NULL) { /* no more levels? */ + init_exp(var, VGLOBAL, NO_REG); /* default is global variable */ + return VGLOBAL; + } + else { + int v = searchvar(fs, n); /* look up at current level */ + if (v >= 0) { + init_exp(var, VLOCAL, v); + if (!base) + markupval(fs, v); /* local will be used as an upval */ + return VLOCAL; + } + else { /* not found at current level; try upper one */ + if (singlevaraux(fs->prev, n, var, 0) == VGLOBAL) + return VGLOBAL; + var->u.s.info = indexupvalue(fs, n, var); /* else was LOCAL or UPVAL */ + var->k = VUPVAL; /* upvalue in this level */ + return VUPVAL; + } + } +} + + +static void singlevar (LexState *ls, expdesc *var) { + TString *varname = str_checkname(ls); + FuncState *fs = ls->fs; + if (singlevaraux(fs, varname, var, 1) == VGLOBAL) + var->u.s.info = luaK_stringK(fs, varname); /* info points to global name */ +} + + +static void adjust_assign (LexState *ls, int nvars, int nexps, expdesc *e) { + FuncState *fs = ls->fs; + int extra = nvars - nexps; + if (hasmultret(e->k)) { + extra++; /* includes call itself */ + if (extra < 0) extra = 0; + luaK_setreturns(fs, e, extra); /* last exp. provides the difference */ + if (extra > 1) luaK_reserveregs(fs, extra-1); + } + else { + if (e->k != VVOID) luaK_exp2nextreg(fs, e); /* close last expression */ + if (extra > 0) { + int reg = fs->freereg; + luaK_reserveregs(fs, extra); + luaK_nil(fs, reg, extra); + } + } +} + + +static void enterlevel (LexState *ls) { + if (++ls->L->nCcalls > LUAI_MAXCCALLS) + luaX_lexerror(ls, "chunk has too many syntax levels", 0); +} + + +#define leavelevel(ls) ((ls)->L->nCcalls--) + + +static void enterblock (FuncState *fs, BlockCnt *bl, lu_byte isbreakable) { + bl->breaklist = NO_JUMP; + bl->isbreakable = isbreakable; + bl->nactvar = fs->nactvar; + bl->upval = 0; + bl->previous = fs->bl; + fs->bl = bl; + lua_assert(fs->freereg == fs->nactvar); +} + + +static void leaveblock (FuncState *fs) { + BlockCnt *bl = fs->bl; + fs->bl = bl->previous; + removevars(fs->ls, bl->nactvar); + if (bl->upval) + luaK_codeABC(fs, OP_CLOSE, bl->nactvar, 0, 0); + /* a block either controls scope or breaks (never both) */ + lua_assert(!bl->isbreakable || !bl->upval); + lua_assert(bl->nactvar == fs->nactvar); + fs->freereg = fs->nactvar; /* free registers */ + luaK_patchtohere(fs, bl->breaklist); +} + + +static void pushclosure (LexState *ls, FuncState *func, expdesc *v) { + FuncState *fs = ls->fs; + Proto *f = fs->f; + int oldsize = f->sizep; + int i; + luaM_growvector(ls->L, f->p, fs->np, f->sizep, Proto *, + MAXARG_Bx, "constant table overflow"); + while (oldsize < f->sizep) f->p[oldsize++] = NULL; + f->p[fs->np++] = func->f; + luaC_objbarrier(ls->L, f, func->f); + init_exp(v, VRELOCABLE, luaK_codeABx(fs, OP_CLOSURE, 0, fs->np-1)); + for (i=0; if->nups; i++) { + OpCode o = (func->upvalues[i].k == VLOCAL) ? OP_MOVE : OP_GETUPVAL; + luaK_codeABC(fs, o, 0, func->upvalues[i].info, 0); + } +} + + +static void open_func (LexState *ls, FuncState *fs) { + lua_State *L = ls->L; + Proto *f = luaF_newproto(L); + fs->f = f; + fs->prev = ls->fs; /* linked list of funcstates */ + fs->ls = ls; + fs->L = L; + ls->fs = fs; + fs->pc = 0; + fs->lasttarget = -1; + fs->jpc = NO_JUMP; + fs->freereg = 0; + fs->nk = 0; + fs->np = 0; + fs->nlocvars = 0; + fs->nactvar = 0; + fs->bl = NULL; + f->source = ls->source; + f->maxstacksize = 2; /* registers 0/1 are always valid */ + fs->h = luaH_new(L, 0, 0); + /* anchor table of constants and prototype (to avoid being collected) */ + sethvalue2s(L, L->top, fs->h); + incr_top(L); + setptvalue2s(L, L->top, f); + incr_top(L); +} + + +static void close_func (LexState *ls) { + lua_State *L = ls->L; + FuncState *fs = ls->fs; + Proto *f = fs->f; + removevars(ls, 0); + luaK_ret(fs, 0, 0); /* final return */ + luaM_reallocvector(L, f->code, f->sizecode, fs->pc, Instruction); + f->sizecode = fs->pc; + luaM_reallocvector(L, f->lineinfo, f->sizelineinfo, fs->pc, int); + f->sizelineinfo = fs->pc; + luaM_reallocvector(L, f->k, f->sizek, fs->nk, TValue); + f->sizek = fs->nk; + luaM_reallocvector(L, f->p, f->sizep, fs->np, Proto *); + f->sizep = fs->np; + luaM_reallocvector(L, f->locvars, f->sizelocvars, fs->nlocvars, LocVar); + f->sizelocvars = fs->nlocvars; + luaM_reallocvector(L, f->upvalues, f->sizeupvalues, f->nups, TString *); + f->sizeupvalues = f->nups; + lua_assert(luaG_checkcode(f)); + lua_assert(fs->bl == NULL); + ls->fs = fs->prev; + L->top -= 2; /* remove table and prototype from the stack */ + /* last token read was anchored in defunct function; must reanchor it */ + if (fs) anchor_token(ls); +} + + +Proto *luaY_parser (lua_State *L, ZIO *z, Mbuffer *buff, const char *name) { + struct LexState lexstate; + struct FuncState funcstate; + lexstate.buff = buff; + luaX_setinput(L, &lexstate, z, luaS_new(L, name)); + open_func(&lexstate, &funcstate); + funcstate.f->is_vararg = VARARG_ISVARARG; /* main func. is always vararg */ + luaX_next(&lexstate); /* read first token */ + chunk(&lexstate); + check(&lexstate, TK_EOS); + close_func(&lexstate); + lua_assert(funcstate.prev == NULL); + lua_assert(funcstate.f->nups == 0); + lua_assert(lexstate.fs == NULL); + return funcstate.f; +} + + + +/*============================================================*/ +/* GRAMMAR RULES */ +/*============================================================*/ + + +static void field (LexState *ls, expdesc *v) { + /* field -> ['.' | ':'] NAME */ + FuncState *fs = ls->fs; + expdesc key; + luaK_exp2anyreg(fs, v); + luaX_next(ls); /* skip the dot or colon */ + checkname(ls, &key); + luaK_indexed(fs, v, &key); +} + + +static void yindex (LexState *ls, expdesc *v) { + /* index -> '[' expr ']' */ + luaX_next(ls); /* skip the '[' */ + expr(ls, v); + luaK_exp2val(ls->fs, v); + checknext(ls, ']'); +} + + +/* +** {====================================================================== +** Rules for Constructors +** ======================================================================= +*/ + + +struct ConsControl { + expdesc v; /* last list item read */ + expdesc *t; /* table descriptor */ + int nh; /* total number of `record' elements */ + int na; /* total number of array elements */ + int tostore; /* number of array elements pending to be stored */ +}; + + +static void recfield (LexState *ls, struct ConsControl *cc) { + /* recfield -> (NAME | `['exp1`]') = exp1 */ + FuncState *fs = ls->fs; + int reg = ls->fs->freereg; + expdesc key, val; + int rkkey; + if (ls->t.token == TK_NAME) { + luaY_checklimit(fs, cc->nh, MAX_INT, "items in a constructor"); + checkname(ls, &key); + } + else /* ls->t.token == '[' */ + yindex(ls, &key); + cc->nh++; + checknext(ls, '='); + rkkey = luaK_exp2RK(fs, &key); + expr(ls, &val); + luaK_codeABC(fs, OP_SETTABLE, cc->t->u.s.info, rkkey, luaK_exp2RK(fs, &val)); + fs->freereg = reg; /* free registers */ +} + + +static void closelistfield (FuncState *fs, struct ConsControl *cc) { + if (cc->v.k == VVOID) return; /* there is no list item */ + luaK_exp2nextreg(fs, &cc->v); + cc->v.k = VVOID; + if (cc->tostore == LFIELDS_PER_FLUSH) { + luaK_setlist(fs, cc->t->u.s.info, cc->na, cc->tostore); /* flush */ + cc->tostore = 0; /* no more items pending */ + } +} + + +static void lastlistfield (FuncState *fs, struct ConsControl *cc) { + if (cc->tostore == 0) return; + if (hasmultret(cc->v.k)) { + luaK_setmultret(fs, &cc->v); + luaK_setlist(fs, cc->t->u.s.info, cc->na, LUA_MULTRET); + cc->na--; /* do not count last expression (unknown number of elements) */ + } + else { + if (cc->v.k != VVOID) + luaK_exp2nextreg(fs, &cc->v); + luaK_setlist(fs, cc->t->u.s.info, cc->na, cc->tostore); + } +} + + +static void listfield (LexState *ls, struct ConsControl *cc) { + expr(ls, &cc->v); + luaY_checklimit(ls->fs, cc->na, MAX_INT, "items in a constructor"); + cc->na++; + cc->tostore++; +} + + +static void constructor (LexState *ls, expdesc *t) { + /* constructor -> ?? */ + FuncState *fs = ls->fs; + int line = ls->linenumber; + int pc = luaK_codeABC(fs, OP_NEWTABLE, 0, 0, 0); + struct ConsControl cc; + cc.na = cc.nh = cc.tostore = 0; + cc.t = t; + init_exp(t, VRELOCABLE, pc); + init_exp(&cc.v, VVOID, 0); /* no value (yet) */ + luaK_exp2nextreg(ls->fs, t); /* fix it at stack top (for gc) */ + checknext(ls, '{'); + do { + lua_assert(cc.v.k == VVOID || cc.tostore > 0); + if (ls->t.token == '}') break; + closelistfield(fs, &cc); + switch(ls->t.token) { + case TK_NAME: { /* may be listfields or recfields */ + luaX_lookahead(ls); + if (ls->lookahead.token != '=') /* expression? */ + listfield(ls, &cc); + else + recfield(ls, &cc); + break; + } + case '[': { /* constructor_item -> recfield */ + recfield(ls, &cc); + break; + } + default: { /* constructor_part -> listfield */ + listfield(ls, &cc); + break; + } + } + } while (testnext(ls, ',') || testnext(ls, ';')); + check_match(ls, '}', '{', line); + lastlistfield(fs, &cc); + SETARG_B(fs->f->code[pc], luaO_int2fb(cc.na)); /* set initial array size */ + SETARG_C(fs->f->code[pc], luaO_int2fb(cc.nh)); /* set initial table size */ +} + +/* }====================================================================== */ + + + +static void parlist (LexState *ls) { + /* parlist -> [ param { `,' param } ] */ + FuncState *fs = ls->fs; + Proto *f = fs->f; + int nparams = 0; + f->is_vararg = 0; + if (ls->t.token != ')') { /* is `parlist' not empty? */ + do { + switch (ls->t.token) { + case TK_NAME: { /* param -> NAME */ + new_localvar(ls, str_checkname(ls), nparams++); + break; + } + case TK_DOTS: { /* param -> `...' */ + luaX_next(ls); +#if defined(LUA_COMPAT_VARARG) + /* use `arg' as default name */ + new_localvarliteral(ls, "arg", nparams++); + f->is_vararg = VARARG_HASARG | VARARG_NEEDSARG; +#endif + f->is_vararg |= VARARG_ISVARARG; + break; + } + default: luaX_syntaxerror(ls, " or " LUA_QL("...") " expected"); + } + } while (!f->is_vararg && testnext(ls, ',')); + } + adjustlocalvars(ls, nparams); + f->numparams = cast_byte(fs->nactvar - (f->is_vararg & VARARG_HASARG)); + luaK_reserveregs(fs, fs->nactvar); /* reserve register for parameters */ +} + + +static void body (LexState *ls, expdesc *e, int needself, int line) { + /* body -> `(' parlist `)' chunk END */ + FuncState new_fs; + open_func(ls, &new_fs); + new_fs.f->linedefined = line; + checknext(ls, '('); + if (needself) { + new_localvarliteral(ls, "self", 0); + adjustlocalvars(ls, 1); + } + parlist(ls); + checknext(ls, ')'); + chunk(ls); + new_fs.f->lastlinedefined = ls->linenumber; + check_match(ls, TK_END, TK_FUNCTION, line); + close_func(ls); + pushclosure(ls, &new_fs, e); +} + + +static int explist1 (LexState *ls, expdesc *v) { + /* explist1 -> expr { `,' expr } */ + int n = 1; /* at least one expression */ + expr(ls, v); + while (testnext(ls, ',')) { + luaK_exp2nextreg(ls->fs, v); + expr(ls, v); + n++; + } + return n; +} + + +static void funcargs (LexState *ls, expdesc *f) { + FuncState *fs = ls->fs; + expdesc args; + int base, nparams; + int line = ls->linenumber; + switch (ls->t.token) { + case '(': { /* funcargs -> `(' [ explist1 ] `)' */ + if (line != ls->lastline) + luaX_syntaxerror(ls,"ambiguous syntax (function call x new statement)"); + luaX_next(ls); + if (ls->t.token == ')') /* arg list is empty? */ + args.k = VVOID; + else { + explist1(ls, &args); + luaK_setmultret(fs, &args); + } + check_match(ls, ')', '(', line); + break; + } + case '{': { /* funcargs -> constructor */ + constructor(ls, &args); + break; + } + case TK_STRING: { /* funcargs -> STRING */ + codestring(ls, &args, ls->t.seminfo.ts); + luaX_next(ls); /* must use `seminfo' before `next' */ + break; + } + default: { + luaX_syntaxerror(ls, "function arguments expected"); + return; + } + } + lua_assert(f->k == VNONRELOC); + base = f->u.s.info; /* base register for call */ + if (hasmultret(args.k)) + nparams = LUA_MULTRET; /* open call */ + else { + if (args.k != VVOID) + luaK_exp2nextreg(fs, &args); /* close last argument */ + nparams = fs->freereg - (base+1); + } + init_exp(f, VCALL, luaK_codeABC(fs, OP_CALL, base, nparams+1, 2)); + luaK_fixline(fs, line); + fs->freereg = base+1; /* call remove function and arguments and leaves + (unless changed) one result */ +} + + + + +/* +** {====================================================================== +** Expression parsing +** ======================================================================= +*/ + + +static void prefixexp (LexState *ls, expdesc *v) { + /* prefixexp -> NAME | '(' expr ')' */ + switch (ls->t.token) { + case '(': { + int line = ls->linenumber; + luaX_next(ls); + expr(ls, v); + check_match(ls, ')', '(', line); + luaK_dischargevars(ls->fs, v); + return; + } + case TK_NAME: { + singlevar(ls, v); + return; + } + default: { + luaX_syntaxerror(ls, "unexpected symbol"); + return; + } + } +} + + +static void primaryexp (LexState *ls, expdesc *v) { + /* primaryexp -> + prefixexp { `.' NAME | `[' exp `]' | `:' NAME funcargs | funcargs } */ + FuncState *fs = ls->fs; + prefixexp(ls, v); + for (;;) { + switch (ls->t.token) { + case '.': { /* field */ + field(ls, v); + break; + } + case '[': { /* `[' exp1 `]' */ + expdesc key; + luaK_exp2anyreg(fs, v); + yindex(ls, &key); + luaK_indexed(fs, v, &key); + break; + } + case ':': { /* `:' NAME funcargs */ + expdesc key; + luaX_next(ls); + checkname(ls, &key); + luaK_self(fs, v, &key); + funcargs(ls, v); + break; + } + case '(': case TK_STRING: case '{': { /* funcargs */ + luaK_exp2nextreg(fs, v); + funcargs(ls, v); + break; + } + default: return; + } + } +} + + +static void simpleexp (LexState *ls, expdesc *v) { + /* simpleexp -> NUMBER | STRING | NIL | true | false | ... | + constructor | FUNCTION body | primaryexp */ + switch (ls->t.token) { + case TK_NUMBER: { + init_exp(v, VKNUM, 0); + v->u.nval = ls->t.seminfo.r; + break; + } + case TK_STRING: { + codestring(ls, v, ls->t.seminfo.ts); + break; + } + case TK_NIL: { + init_exp(v, VNIL, 0); + break; + } + case TK_TRUE: { + init_exp(v, VTRUE, 0); + break; + } + case TK_FALSE: { + init_exp(v, VFALSE, 0); + break; + } + case TK_DOTS: { /* vararg */ + FuncState *fs = ls->fs; + check_condition(ls, fs->f->is_vararg, + "cannot use " LUA_QL("...") " outside a vararg function"); + fs->f->is_vararg &= ~VARARG_NEEDSARG; /* don't need 'arg' */ + init_exp(v, VVARARG, luaK_codeABC(fs, OP_VARARG, 0, 1, 0)); + break; + } + case '{': { /* constructor */ + constructor(ls, v); + return; + } + case TK_FUNCTION: { + luaX_next(ls); + body(ls, v, 0, ls->linenumber); + return; + } + default: { + primaryexp(ls, v); + return; + } + } + luaX_next(ls); +} + + +static UnOpr getunopr (int op) { + switch (op) { + case TK_NOT: return OPR_NOT; + case '-': return OPR_MINUS; + case '#': return OPR_LEN; + default: return OPR_NOUNOPR; + } +} + + +static BinOpr getbinopr (int op) { + switch (op) { + case '+': return OPR_ADD; + case '-': return OPR_SUB; + case '*': return OPR_MUL; + case '/': return OPR_DIV; + case '%': return OPR_MOD; + case '^': return OPR_POW; + case TK_CONCAT: return OPR_CONCAT; + case TK_NE: return OPR_NE; + case TK_EQ: return OPR_EQ; + case '<': return OPR_LT; + case TK_LE: return OPR_LE; + case '>': return OPR_GT; + case TK_GE: return OPR_GE; + case TK_AND: return OPR_AND; + case TK_OR: return OPR_OR; + default: return OPR_NOBINOPR; + } +} + + +static const struct { + lu_byte left; /* left priority for each binary operator */ + lu_byte right; /* right priority */ +} priority[] = { /* ORDER OPR */ + {6, 6}, {6, 6}, {7, 7}, {7, 7}, {7, 7}, /* `+' `-' `/' `%' */ + {10, 9}, {5, 4}, /* power and concat (right associative) */ + {3, 3}, {3, 3}, /* equality and inequality */ + {3, 3}, {3, 3}, {3, 3}, {3, 3}, /* order */ + {2, 2}, {1, 1} /* logical (and/or) */ +}; + +#define UNARY_PRIORITY 8 /* priority for unary operators */ + + +/* +** subexpr -> (simpleexp | unop subexpr) { binop subexpr } +** where `binop' is any binary operator with a priority higher than `limit' +*/ +static BinOpr subexpr (LexState *ls, expdesc *v, unsigned int limit) { + BinOpr op; + UnOpr uop; + enterlevel(ls); + uop = getunopr(ls->t.token); + if (uop != OPR_NOUNOPR) { + luaX_next(ls); + subexpr(ls, v, UNARY_PRIORITY); + luaK_prefix(ls->fs, uop, v); + } + else simpleexp(ls, v); + /* expand while operators have priorities higher than `limit' */ + op = getbinopr(ls->t.token); + while (op != OPR_NOBINOPR && priority[op].left > limit) { + expdesc v2; + BinOpr nextop; + luaX_next(ls); + luaK_infix(ls->fs, op, v); + /* read sub-expression with higher priority */ + nextop = subexpr(ls, &v2, priority[op].right); + luaK_posfix(ls->fs, op, v, &v2); + op = nextop; + } + leavelevel(ls); + return op; /* return first untreated operator */ +} + + +static void expr (LexState *ls, expdesc *v) { + subexpr(ls, v, 0); +} + +/* }==================================================================== */ + + + +/* +** {====================================================================== +** Rules for Statements +** ======================================================================= +*/ + + +static int block_follow (int token) { + switch (token) { + case TK_ELSE: case TK_ELSEIF: case TK_END: + case TK_UNTIL: case TK_EOS: + return 1; + default: return 0; + } +} + + +static void block (LexState *ls) { + /* block -> chunk */ + FuncState *fs = ls->fs; + BlockCnt bl; + enterblock(fs, &bl, 0); + chunk(ls); + lua_assert(bl.breaklist == NO_JUMP); + leaveblock(fs); +} + + +/* +** structure to chain all variables in the left-hand side of an +** assignment +*/ +struct LHS_assign { + struct LHS_assign *prev; + expdesc v; /* variable (global, local, upvalue, or indexed) */ +}; + + +/* +** check whether, in an assignment to a local variable, the local variable +** is needed in a previous assignment (to a table). If so, save original +** local value in a safe place and use this safe copy in the previous +** assignment. +*/ +static void check_conflict (LexState *ls, struct LHS_assign *lh, expdesc *v) { + FuncState *fs = ls->fs; + int extra = fs->freereg; /* eventual position to save local variable */ + int conflict = 0; + for (; lh; lh = lh->prev) { + if (lh->v.k == VINDEXED) { + if (lh->v.u.s.info == v->u.s.info) { /* conflict? */ + conflict = 1; + lh->v.u.s.info = extra; /* previous assignment will use safe copy */ + } + if (lh->v.u.s.aux == v->u.s.info) { /* conflict? */ + conflict = 1; + lh->v.u.s.aux = extra; /* previous assignment will use safe copy */ + } + } + } + if (conflict) { + luaK_codeABC(fs, OP_MOVE, fs->freereg, v->u.s.info, 0); /* make copy */ + luaK_reserveregs(fs, 1); + } +} + + +static void assignment (LexState *ls, struct LHS_assign *lh, int nvars) { + expdesc e; + check_condition(ls, VLOCAL <= lh->v.k && lh->v.k <= VINDEXED, + "syntax error"); + if (testnext(ls, ',')) { /* assignment -> `,' primaryexp assignment */ + struct LHS_assign nv; + nv.prev = lh; + primaryexp(ls, &nv.v); + if (nv.v.k == VLOCAL) + check_conflict(ls, lh, &nv.v); + luaY_checklimit(ls->fs, nvars, LUAI_MAXCCALLS - ls->L->nCcalls, + "variables in assignment"); + assignment(ls, &nv, nvars+1); + } + else { /* assignment -> `=' explist1 */ + int nexps; + checknext(ls, '='); + nexps = explist1(ls, &e); + if (nexps != nvars) { + adjust_assign(ls, nvars, nexps, &e); + if (nexps > nvars) + ls->fs->freereg -= nexps - nvars; /* remove extra values */ + } + else { + luaK_setoneret(ls->fs, &e); /* close last expression */ + luaK_storevar(ls->fs, &lh->v, &e); + return; /* avoid default */ + } + } + init_exp(&e, VNONRELOC, ls->fs->freereg-1); /* default assignment */ + luaK_storevar(ls->fs, &lh->v, &e); +} + + +static int cond (LexState *ls) { + /* cond -> exp */ + expdesc v; + expr(ls, &v); /* read condition */ + if (v.k == VNIL) v.k = VFALSE; /* `falses' are all equal here */ + luaK_goiftrue(ls->fs, &v); + return v.f; +} + + +static void breakstat (LexState *ls) { + FuncState *fs = ls->fs; + BlockCnt *bl = fs->bl; + int upval = 0; + while (bl && !bl->isbreakable) { + upval |= bl->upval; + bl = bl->previous; + } + if (!bl) + luaX_syntaxerror(ls, "no loop to break"); + if (upval) + luaK_codeABC(fs, OP_CLOSE, bl->nactvar, 0, 0); + luaK_concat(fs, &bl->breaklist, luaK_jump(fs)); +} + + +static void whilestat (LexState *ls, int line) { + /* whilestat -> WHILE cond DO block END */ + FuncState *fs = ls->fs; + int whileinit; + int condexit; + BlockCnt bl; + luaX_next(ls); /* skip WHILE */ + whileinit = luaK_getlabel(fs); + condexit = cond(ls); + enterblock(fs, &bl, 1); + checknext(ls, TK_DO); + block(ls); + luaK_patchlist(fs, luaK_jump(fs), whileinit); + check_match(ls, TK_END, TK_WHILE, line); + leaveblock(fs); + luaK_patchtohere(fs, condexit); /* false conditions finish the loop */ +} + + +static void repeatstat (LexState *ls, int line) { + /* repeatstat -> REPEAT block UNTIL cond */ + int condexit; + FuncState *fs = ls->fs; + int repeat_init = luaK_getlabel(fs); + BlockCnt bl1, bl2; + enterblock(fs, &bl1, 1); /* loop block */ + enterblock(fs, &bl2, 0); /* scope block */ + luaX_next(ls); /* skip REPEAT */ + chunk(ls); + check_match(ls, TK_UNTIL, TK_REPEAT, line); + condexit = cond(ls); /* read condition (inside scope block) */ + if (!bl2.upval) { /* no upvalues? */ + leaveblock(fs); /* finish scope */ + luaK_patchlist(ls->fs, condexit, repeat_init); /* close the loop */ + } + else { /* complete semantics when there are upvalues */ + breakstat(ls); /* if condition then break */ + luaK_patchtohere(ls->fs, condexit); /* else... */ + leaveblock(fs); /* finish scope... */ + luaK_patchlist(ls->fs, luaK_jump(fs), repeat_init); /* and repeat */ + } + leaveblock(fs); /* finish loop */ +} + + +static int exp1 (LexState *ls) { + expdesc e; + int k; + expr(ls, &e); + k = e.k; + luaK_exp2nextreg(ls->fs, &e); + return k; +} + + +static void forbody (LexState *ls, int base, int line, int nvars, int isnum) { + /* forbody -> DO block */ + BlockCnt bl; + FuncState *fs = ls->fs; + int prep, endfor; + adjustlocalvars(ls, 3); /* control variables */ + checknext(ls, TK_DO); + prep = isnum ? luaK_codeAsBx(fs, OP_FORPREP, base, NO_JUMP) : luaK_jump(fs); + enterblock(fs, &bl, 0); /* scope for declared variables */ + adjustlocalvars(ls, nvars); + luaK_reserveregs(fs, nvars); + block(ls); + leaveblock(fs); /* end of scope for declared variables */ + luaK_patchtohere(fs, prep); + endfor = (isnum) ? luaK_codeAsBx(fs, OP_FORLOOP, base, NO_JUMP) : + luaK_codeABC(fs, OP_TFORLOOP, base, 0, nvars); + luaK_fixline(fs, line); /* pretend that `OP_FOR' starts the loop */ + luaK_patchlist(fs, (isnum ? endfor : luaK_jump(fs)), prep + 1); +} + + +static void fornum (LexState *ls, TString *varname, int line) { + /* fornum -> NAME = exp1,exp1[,exp1] forbody */ + FuncState *fs = ls->fs; + int base = fs->freereg; + new_localvarliteral(ls, "(for index)", 0); + new_localvarliteral(ls, "(for limit)", 1); + new_localvarliteral(ls, "(for step)", 2); + new_localvar(ls, varname, 3); + checknext(ls, '='); + exp1(ls); /* initial value */ + checknext(ls, ','); + exp1(ls); /* limit */ + if (testnext(ls, ',')) + exp1(ls); /* optional step */ + else { /* default step = 1 */ + luaK_codeABx(fs, OP_LOADK, fs->freereg, luaK_numberK(fs, 1)); + luaK_reserveregs(fs, 1); + } + forbody(ls, base, line, 1, 1); +} + + +static void forlist (LexState *ls, TString *indexname) { + /* forlist -> NAME {,NAME} IN explist1 forbody */ + FuncState *fs = ls->fs; + expdesc e; + int nvars = 0; + int line; + int base = fs->freereg; + /* create control variables */ + new_localvarliteral(ls, "(for generator)", nvars++); + new_localvarliteral(ls, "(for state)", nvars++); + new_localvarliteral(ls, "(for control)", nvars++); + /* create declared variables */ + new_localvar(ls, indexname, nvars++); + while (testnext(ls, ',')) + new_localvar(ls, str_checkname(ls), nvars++); + checknext(ls, TK_IN); + line = ls->linenumber; + adjust_assign(ls, 3, explist1(ls, &e), &e); + luaK_checkstack(fs, 3); /* extra space to call generator */ + forbody(ls, base, line, nvars - 3, 0); +} + + +static void forstat (LexState *ls, int line) { + /* forstat -> FOR (fornum | forlist) END */ + FuncState *fs = ls->fs; + TString *varname; + BlockCnt bl; + enterblock(fs, &bl, 1); /* scope for loop and control variables */ + luaX_next(ls); /* skip `for' */ + varname = str_checkname(ls); /* first variable name */ + switch (ls->t.token) { + case '=': fornum(ls, varname, line); break; + case ',': case TK_IN: forlist(ls, varname); break; + default: luaX_syntaxerror(ls, LUA_QL("=") " or " LUA_QL("in") " expected"); + } + check_match(ls, TK_END, TK_FOR, line); + leaveblock(fs); /* loop scope (`break' jumps to this point) */ +} + + +static int test_then_block (LexState *ls) { + /* test_then_block -> [IF | ELSEIF] cond THEN block */ + int condexit; + luaX_next(ls); /* skip IF or ELSEIF */ + condexit = cond(ls); + checknext(ls, TK_THEN); + block(ls); /* `then' part */ + return condexit; +} + + +static void ifstat (LexState *ls, int line) { + /* ifstat -> IF cond THEN block {ELSEIF cond THEN block} [ELSE block] END */ + FuncState *fs = ls->fs; + int flist; + int escapelist = NO_JUMP; + flist = test_then_block(ls); /* IF cond THEN block */ + while (ls->t.token == TK_ELSEIF) { + luaK_concat(fs, &escapelist, luaK_jump(fs)); + luaK_patchtohere(fs, flist); + flist = test_then_block(ls); /* ELSEIF cond THEN block */ + } + if (ls->t.token == TK_ELSE) { + luaK_concat(fs, &escapelist, luaK_jump(fs)); + luaK_patchtohere(fs, flist); + luaX_next(ls); /* skip ELSE (after patch, for correct line info) */ + block(ls); /* `else' part */ + } + else + luaK_concat(fs, &escapelist, flist); + luaK_patchtohere(fs, escapelist); + check_match(ls, TK_END, TK_IF, line); +} + + +static void localfunc (LexState *ls) { + expdesc v, b; + FuncState *fs = ls->fs; + new_localvar(ls, str_checkname(ls), 0); + init_exp(&v, VLOCAL, fs->freereg); + luaK_reserveregs(fs, 1); + adjustlocalvars(ls, 1); + body(ls, &b, 0, ls->linenumber); + luaK_storevar(fs, &v, &b); + /* debug information will only see the variable after this point! */ + getlocvar(fs, fs->nactvar - 1).startpc = fs->pc; +} + + +static void localstat (LexState *ls) { + /* stat -> LOCAL NAME {`,' NAME} [`=' explist1] */ + int nvars = 0; + int nexps; + expdesc e; + do { + new_localvar(ls, str_checkname(ls), nvars++); + } while (testnext(ls, ',')); + if (testnext(ls, '=')) + nexps = explist1(ls, &e); + else { + e.k = VVOID; + nexps = 0; + } + adjust_assign(ls, nvars, nexps, &e); + adjustlocalvars(ls, nvars); +} + + +static int funcname (LexState *ls, expdesc *v) { + /* funcname -> NAME {field} [`:' NAME] */ + int needself = 0; + singlevar(ls, v); + while (ls->t.token == '.') + field(ls, v); + if (ls->t.token == ':') { + needself = 1; + field(ls, v); + } + return needself; +} + + +static void funcstat (LexState *ls, int line) { + /* funcstat -> FUNCTION funcname body */ + int needself; + expdesc v, b; + luaX_next(ls); /* skip FUNCTION */ + needself = funcname(ls, &v); + body(ls, &b, needself, line); + luaK_storevar(ls->fs, &v, &b); + luaK_fixline(ls->fs, line); /* definition `happens' in the first line */ +} + + +static void exprstat (LexState *ls) { + /* stat -> func | assignment */ + FuncState *fs = ls->fs; + struct LHS_assign v; + primaryexp(ls, &v.v); + if (v.v.k == VCALL) /* stat -> func */ + SETARG_C(getcode(fs, &v.v), 1); /* call statement uses no results */ + else { /* stat -> assignment */ + v.prev = NULL; + assignment(ls, &v, 1); + } +} + + +static void retstat (LexState *ls) { + /* stat -> RETURN explist */ + FuncState *fs = ls->fs; + expdesc e; + int first, nret; /* registers with returned values */ + luaX_next(ls); /* skip RETURN */ + if (block_follow(ls->t.token) || ls->t.token == ';') + first = nret = 0; /* return no values */ + else { + nret = explist1(ls, &e); /* optional return values */ + if (hasmultret(e.k)) { + luaK_setmultret(fs, &e); + if (e.k == VCALL && nret == 1) { /* tail call? */ + SET_OPCODE(getcode(fs,&e), OP_TAILCALL); + lua_assert(GETARG_A(getcode(fs,&e)) == fs->nactvar); + } + first = fs->nactvar; + nret = LUA_MULTRET; /* return all values */ + } + else { + if (nret == 1) /* only one single value? */ + first = luaK_exp2anyreg(fs, &e); + else { + luaK_exp2nextreg(fs, &e); /* values must go to the `stack' */ + first = fs->nactvar; /* return all `active' values */ + lua_assert(nret == fs->freereg - first); + } + } + } + luaK_ret(fs, first, nret); +} + + +static int statement (LexState *ls) { + int line = ls->linenumber; /* may be needed for error messages */ + switch (ls->t.token) { + case TK_IF: { /* stat -> ifstat */ + ifstat(ls, line); + return 0; + } + case TK_WHILE: { /* stat -> whilestat */ + whilestat(ls, line); + return 0; + } + case TK_DO: { /* stat -> DO block END */ + luaX_next(ls); /* skip DO */ + block(ls); + check_match(ls, TK_END, TK_DO, line); + return 0; + } + case TK_FOR: { /* stat -> forstat */ + forstat(ls, line); + return 0; + } + case TK_REPEAT: { /* stat -> repeatstat */ + repeatstat(ls, line); + return 0; + } + case TK_FUNCTION: { + funcstat(ls, line); /* stat -> funcstat */ + return 0; + } + case TK_LOCAL: { /* stat -> localstat */ + luaX_next(ls); /* skip LOCAL */ + if (testnext(ls, TK_FUNCTION)) /* local function? */ + localfunc(ls); + else + localstat(ls); + return 0; + } + case TK_RETURN: { /* stat -> retstat */ + retstat(ls); + return 1; /* must be last statement */ + } + case TK_BREAK: { /* stat -> breakstat */ + luaX_next(ls); /* skip BREAK */ + breakstat(ls); + return 1; /* must be last statement */ + } + default: { + exprstat(ls); + return 0; /* to avoid warnings */ + } + } +} + + +static void chunk (LexState *ls) { + /* chunk -> { stat [`;'] } */ + int islast = 0; + enterlevel(ls); + while (!islast && !block_follow(ls->t.token)) { + islast = statement(ls); + testnext(ls, ';'); + lua_assert(ls->fs->f->maxstacksize >= ls->fs->freereg && + ls->fs->freereg >= ls->fs->nactvar); + ls->fs->freereg = ls->fs->nactvar; /* free registers */ + } + leavelevel(ls); +} + +/* }====================================================================== */ diff --git a/lua/lparser.h b/lua/lparser.h new file mode 100644 index 0000000..18836af --- /dev/null +++ b/lua/lparser.h @@ -0,0 +1,82 @@ +/* +** $Id: lparser.h,v 1.57.1.1 2007/12/27 13:02:25 roberto Exp $ +** Lua Parser +** See Copyright Notice in lua.h +*/ + +#ifndef lparser_h +#define lparser_h + +#include "llimits.h" +#include "lobject.h" +#include "lzio.h" + + +/* +** Expression descriptor +*/ + +typedef enum { + VVOID, /* no value */ + VNIL, + VTRUE, + VFALSE, + VK, /* info = index of constant in `k' */ + VKNUM, /* nval = numerical value */ + VLOCAL, /* info = local register */ + VUPVAL, /* info = index of upvalue in `upvalues' */ + VGLOBAL, /* info = index of table; aux = index of global name in `k' */ + VINDEXED, /* info = table register; aux = index register (or `k') */ + VJMP, /* info = instruction pc */ + VRELOCABLE, /* info = instruction pc */ + VNONRELOC, /* info = result register */ + VCALL, /* info = instruction pc */ + VVARARG /* info = instruction pc */ +} expkind; + +typedef struct expdesc { + expkind k; + union { + struct { int info, aux; } s; + lua_Number nval; + } u; + int t; /* patch list of `exit when true' */ + int f; /* patch list of `exit when false' */ +} expdesc; + + +typedef struct upvaldesc { + lu_byte k; + lu_byte info; +} upvaldesc; + + +struct BlockCnt; /* defined in lparser.c */ + + +/* state needed to generate code for a given function */ +typedef struct FuncState { + Proto *f; /* current function header */ + Table *h; /* table to find (and reuse) elements in `k' */ + struct FuncState *prev; /* enclosing function */ + struct LexState *ls; /* lexical state */ + struct lua_State *L; /* copy of the Lua state */ + struct BlockCnt *bl; /* chain of current blocks */ + int pc; /* next position to code (equivalent to `ncode') */ + int lasttarget; /* `pc' of last `jump target' */ + int jpc; /* list of pending jumps to `pc' */ + int freereg; /* first free register */ + int nk; /* number of elements in `k' */ + int np; /* number of elements in `p' */ + short nlocvars; /* number of elements in `locvars' */ + lu_byte nactvar; /* number of active local variables */ + upvaldesc upvalues[LUAI_MAXUPVALUES]; /* upvalues */ + unsigned short actvar[LUAI_MAXVARS]; /* declared-variable stack */ +} FuncState; + + +LUAI_FUNC Proto *luaY_parser (lua_State *L, ZIO *z, Mbuffer *buff, + const char *name); + + +#endif diff --git a/lua/lstate.c b/lua/lstate.c new file mode 100644 index 0000000..fcb9d90 --- /dev/null +++ b/lua/lstate.c @@ -0,0 +1,217 @@ +/* +** $Id: lstate.c,v 2.36.1.2 2008/01/03 15:20:39 roberto Exp $ +** Global State +** See Copyright Notice in lua.h +*/ + + +#include + +#define lstate_c +#define LUA_CORE + +#include "lua.h" + +#include "ldebug.h" +#include "ldo.h" +#include "lfunc.h" +#include "lgc.h" +#include "llex.h" +#include "lmem.h" +#include "lstate.h" +#include "lstring.h" +#include "ltable.h" +#include "ltm.h" + + +#define state_size(x) (sizeof(x) + LUAI_EXTRASPACE) +#define fromstate(l) (cast(lu_byte *, (l)) - LUAI_EXTRASPACE) +#define tostate(l) (cast(lua_State *, cast(lu_byte *, l) + LUAI_EXTRASPACE)) + + +/* +** Main thread combines a thread state and the global state +*/ +typedef struct LG { + lua_State l; + global_State g; +} LG; + + + +static void stack_init (lua_State *L1, lua_State *L) { + /* initialize CallInfo array */ + L1->base_ci = luaM_newvector(L, BASIC_CI_SIZE, CallInfo); + L1->ci = L1->base_ci; + L1->size_ci = BASIC_CI_SIZE; + L1->end_ci = L1->base_ci + L1->size_ci - 1; + /* initialize stack array */ + L1->stack = luaM_newvector(L, BASIC_STACK_SIZE + EXTRA_STACK, TValue); + L1->stacksize = BASIC_STACK_SIZE + EXTRA_STACK; + L1->top = L1->stack; + L1->stack_last = L1->stack+(L1->stacksize - EXTRA_STACK)-1; + /* initialize first ci */ + L1->ci->func = L1->top; + setnilvalue(L1->top++); /* `function' entry for this `ci' */ + L1->base = L1->ci->base = L1->top; + L1->ci->top = L1->top + LUA_MINSTACK; +} + + +static void freestack (lua_State *L, lua_State *L1) { + luaM_freearray(L, L1->base_ci, L1->size_ci, CallInfo); + luaM_freearray(L, L1->stack, L1->stacksize, TValue); +} + + +/* +** open parts that may cause memory-allocation errors +*/ +static void f_luaopen (lua_State *L, void *ud) { + global_State *g = G(L); + UNUSED(ud); + stack_init(L, L); /* init stack */ + sethvalue(L, gt(L), luaH_new(L, 0, 2)); /* table of globals */ + sethvalue(L, registry(L), luaH_new(L, 0, 2)); /* registry */ + luaS_resize(L, MINSTRTABSIZE); /* initial size of string table */ + luaT_init(L); + luaX_init(L); + luaS_fix(luaS_newliteral(L, MEMERRMSG)); + g->GCthreshold = 4*g->totalbytes; +} + + +static void preinit_state (lua_State *L, global_State *g) { + G(L) = g; + L->stack = NULL; + L->stacksize = 0; + L->errorJmp = NULL; + L->hook = NULL; + L->hookmask = 0; + L->basehookcount = 0; + L->allowhook = 1; + resethookcount(L); + L->openupval = NULL; + L->size_ci = 0; + L->nCcalls = L->baseCcalls = 0; + L->status = 0; + L->base_ci = L->ci = NULL; + L->savedpc = NULL; + L->errfunc = 0; + setnilvalue(gt(L)); +} + + +static void close_state (lua_State *L) { + global_State *g = G(L); + luaF_close(L, L->stack); /* close all upvalues for this thread */ + luaC_freeall(L); /* collect all objects */ + lua_assert(g->rootgc == obj2gco(L)); + lua_assert(g->strt.nuse == 0); + luaM_freearray(L, G(L)->strt.hash, G(L)->strt.size, TString *); + luaZ_freebuffer(L, &g->buff); + freestack(L, L); + lua_assert(g->totalbytes == sizeof(LG)); + (*g->frealloc)(g->ud, fromstate(L), state_size(LG), 0); +} + + +lua_State *luaE_newthread (lua_State *L) { + lua_State *L1 = tostate(luaM_malloc(L, state_size(lua_State))); + luaC_link(L, obj2gco(L1), LUA_TTHREAD); + preinit_state(L1, G(L)); + stack_init(L1, L); /* init stack */ + setobj2n(L, gt(L1), gt(L)); /* share table of globals */ + L1->hookmask = L->hookmask; + L1->basehookcount = L->basehookcount; + L1->hook = L->hook; + resethookcount(L1); + lua_assert(iswhite(obj2gco(L1))); + return L1; +} + + +void luaE_freethread (lua_State *L, lua_State *L1) { + luaF_close(L1, L1->stack); /* close all upvalues for this thread */ + lua_assert(L1->openupval == NULL); + luai_userstatefree(L1); + freestack(L, L1); + luaM_freemem(L, fromstate(L1), state_size(lua_State)); +} + + +LUA_API lua_State *lua_newstate (lua_Alloc f, void *ud) { + int i; + lua_State *L; + global_State *g; + void *l = (*f)(ud, NULL, 0, state_size(LG)); + if (l == NULL) return NULL; + L = tostate(l); + g = &((LG *)L)->g; + L->next = NULL; +#ifdef _JZ_LUA_CODE + L->constlist = NULL; +#endif + L->tt = LUA_TTHREAD; + g->currentwhite = bit2mask(WHITE0BIT, FIXEDBIT); + L->marked = luaC_white(g); + set2bits(L->marked, FIXEDBIT, SFIXEDBIT); + preinit_state(L, g); + g->frealloc = f; + g->ud = ud; + g->mainthread = L; + g->uvhead.u.l.prev = &g->uvhead; + g->uvhead.u.l.next = &g->uvhead; + g->GCthreshold = 0; /* mark it as unfinished state */ + g->strt.size = 0; + g->strt.nuse = 0; + g->strt.hash = NULL; + setnilvalue(registry(L)); + luaZ_initbuffer(L, &g->buff); + g->panic = NULL; + g->gcstate = GCSpause; + g->rootgc = obj2gco(L); + g->sweepstrgc = 0; + g->sweepgc = &g->rootgc; + g->gray = NULL; + g->grayagain = NULL; + g->weak = NULL; + g->tmudata = NULL; + g->totalbytes = sizeof(LG); + g->gcpause = LUAI_GCPAUSE; + g->gcstepmul = LUAI_GCMUL; + g->gcdept = 0; + for (i=0; imt[i] = NULL; + if (luaD_rawrunprotected(L, f_luaopen, NULL) != 0) { + /* memory allocation error: free partial state */ + close_state(L); + L = NULL; + } + else + luai_userstateopen(L); + return L; +} + + +static void callallgcTM (lua_State *L, void *ud) { + UNUSED(ud); + luaC_callGCTM(L); /* call GC metamethods for all udata */ +} + + +LUA_API void lua_close (lua_State *L) { + L = G(L)->mainthread; /* only the main thread can be closed */ + lua_lock(L); + luaF_close(L, L->stack); /* close all upvalues for this thread */ + luaC_separateudata(L, 1); /* separate udata that have GC metamethods */ + L->errfunc = 0; /* no error function during GC metamethods */ + do { /* repeat until no more errors */ + L->ci = L->base_ci; + L->base = L->top = L->ci->base; + L->nCcalls = L->baseCcalls = 0; + } while (luaD_rawrunprotected(L, callallgcTM, NULL) != 0); + lua_assert(G(L)->tmudata == NULL); + luai_userstateclose(L); + close_state(L); +} + diff --git a/lua/lstate.h b/lua/lstate.h new file mode 100644 index 0000000..13281ca --- /dev/null +++ b/lua/lstate.h @@ -0,0 +1,172 @@ +/* +** $Id: lstate.h,v 2.24.1.2 2008/01/03 15:20:39 roberto Exp $ +** Global State +** See Copyright Notice in lua.h +*/ + +#ifndef lstate_h +#define lstate_h + +#include "lua.h" + +#include "lobject.h" +#include "ltm.h" +#include "lzio.h" + + + +struct lua_longjmp; /* defined in ldo.c */ + + +/* table of globals */ +#define gt(L) (&L->l_gt) + +/* registry */ +#define registry(L) (&G(L)->l_registry) + + +/* extra stack space to handle TM calls and some other extras */ +#define EXTRA_STACK 5 + + +#define BASIC_CI_SIZE 8 + +#define BASIC_STACK_SIZE (2*LUA_MINSTACK) + + + +typedef struct stringtable { + GCObject **hash; + lu_int32 nuse; /* number of elements */ + int size; +} stringtable; + + +/* +** informations about a call +*/ +typedef struct CallInfo { + StkId base; /* base for this function */ + StkId func; /* function index in the stack */ + StkId top; /* top for this function */ + const Instruction *savedpc; + int nresults; /* expected number of results from this function */ + int tailcalls; /* number of tail calls lost under this entry */ +} CallInfo; + + + +#define curr_func(L) (clvalue(L->ci->func)) +#define ci_func(ci) (clvalue((ci)->func)) +#define f_isLua(ci) (!ci_func(ci)->c.isC) +#define isLua(ci) (ttisfunction((ci)->func) && f_isLua(ci)) + + +/* +** `global state', shared by all threads of this state +*/ +typedef struct global_State { + stringtable strt; /* hash table for strings */ + lua_Alloc frealloc; /* function to reallocate memory */ + void *ud; /* auxiliary data to `frealloc' */ + lu_byte currentwhite; + lu_byte gcstate; /* state of garbage collector */ + int sweepstrgc; /* position of sweep in `strt' */ + GCObject *rootgc; /* list of all collectable objects */ + GCObject **sweepgc; /* position of sweep in `rootgc' */ + GCObject *gray; /* list of gray objects */ + GCObject *grayagain; /* list of objects to be traversed atomically */ + GCObject *weak; /* list of weak tables (to be cleared) */ + GCObject *tmudata; /* last element of list of userdata to be GC */ + Mbuffer buff; /* temporary buffer for string concatentation */ + lu_mem GCthreshold; + lu_mem totalbytes; /* number of bytes currently allocated */ + lu_mem estimate; /* an estimate of number of bytes actually in use */ + lu_mem gcdept; /* how much GC is `behind schedule' */ + int gcpause; /* size of pause between successive GCs */ + int gcstepmul; /* GC `granularity' */ + lua_CFunction panic; /* to be called in unprotected errors */ + TValue l_registry; + struct lua_State *mainthread; + UpVal uvhead; /* head of double-linked list of all open upvalues */ + struct Table *mt[NUM_TAGS]; /* metatables for basic types */ + TString *tmname[TM_N]; /* array with tag-method names */ +} global_State; + + +/* +** `per thread' state +*/ +struct lua_State { + CommonHeader; + lu_byte status; + StkId top; /* first free slot in the stack */ + StkId base; /* base of current function */ + global_State *l_G; + CallInfo *ci; /* call info for current function */ + const Instruction *savedpc; /* `savedpc' of current function */ + StkId stack_last; /* last free slot in the stack */ + StkId stack; /* stack base */ + CallInfo *end_ci; /* points after end of ci array*/ + CallInfo *base_ci; /* array of CallInfo's */ + int stacksize; + int size_ci; /* size of array `base_ci' */ + unsigned short nCcalls; /* number of nested C calls */ + unsigned short baseCcalls; /* nested C calls when resuming coroutine */ + lu_byte hookmask; + lu_byte allowhook; + int basehookcount; + int hookcount; + lua_Hook hook; + TValue l_gt; /* table of globals */ + TValue env; /* temporary place for environments */ + GCObject *openupval; /* list of open upvalues in this stack */ + GCObject *gclist; + struct lua_longjmp *errorJmp; /* current error recover point */ + ptrdiff_t errfunc; /* current error handling function (stack index) */ +#ifdef _JZ_LUA_CODE + lua_const *constlist; +#endif +}; + + +#define G(L) (L->l_G) + + +/* +** Union of all collectable objects +*/ +union GCObject { + GCheader gch; + union TString ts; + union Udata u; + union Closure cl; + struct Table h; + struct Proto p; + struct UpVal uv; + struct lua_State th; /* thread */ +}; + + +/* macros to convert a GCObject into a specific value */ +#define rawgco2ts(o) check_exp((o)->gch.tt == LUA_TSTRING, &((o)->ts)) +#define gco2ts(o) (&rawgco2ts(o)->tsv) +#define rawgco2u(o) check_exp((o)->gch.tt == LUA_TUSERDATA, &((o)->u)) +#define gco2u(o) (&rawgco2u(o)->uv) +#define gco2cl(o) check_exp((o)->gch.tt == LUA_TFUNCTION, &((o)->cl)) +#define gco2h(o) check_exp((o)->gch.tt == LUA_TTABLE, &((o)->h)) +#define gco2p(o) check_exp((o)->gch.tt == LUA_TPROTO, &((o)->p)) +#define gco2uv(o) check_exp((o)->gch.tt == LUA_TUPVAL, &((o)->uv)) +#define ngcotouv(o) \ + check_exp((o) == NULL || (o)->gch.tt == LUA_TUPVAL, &((o)->uv)) +#define gco2th(o) check_exp((o)->gch.tt == LUA_TTHREAD, &((o)->th)) + +/* macro to convert any Lua object into a GCObject */ +#define obj2gco(v) (cast(GCObject *, (v))) + + +LUAI_FUNC lua_State *luaE_newthread (lua_State *L); +LUAI_FUNC void luaE_freethread (lua_State *L, lua_State *L1); + +#endif + diff --git a/lua/lstring.c b/lua/lstring.c new file mode 100644 index 0000000..4911315 --- /dev/null +++ b/lua/lstring.c @@ -0,0 +1,111 @@ +/* +** $Id: lstring.c,v 2.8.1.1 2007/12/27 13:02:25 roberto Exp $ +** String table (keeps all strings handled by Lua) +** See Copyright Notice in lua.h +*/ + + +#include + +#define lstring_c +#define LUA_CORE + +#include "lua.h" + +#include "lmem.h" +#include "lobject.h" +#include "lstate.h" +#include "lstring.h" + + + +void luaS_resize (lua_State *L, int newsize) { + GCObject **newhash; + stringtable *tb; + int i; + if (G(L)->gcstate == GCSsweepstring) + return; /* cannot resize during GC traverse */ + newhash = luaM_newvector(L, newsize, GCObject *); + tb = &G(L)->strt; + for (i=0; isize; i++) { + GCObject *p = tb->hash[i]; + while (p) { /* for each node in the list */ + GCObject *next = p->gch.next; /* save next */ + unsigned int h = gco2ts(p)->hash; + int h1 = lmod(h, newsize); /* new position */ + lua_assert(cast_int(h%newsize) == lmod(h, newsize)); + p->gch.next = newhash[h1]; /* chain it */ + newhash[h1] = p; + p = next; + } + } + luaM_freearray(L, tb->hash, tb->size, TString *); + tb->size = newsize; + tb->hash = newhash; +} + + +static TString *newlstr (lua_State *L, const char *str, size_t l, + unsigned int h) { + TString *ts; + stringtable *tb; + if (l+1 > (MAX_SIZET - sizeof(TString))/sizeof(char)) + luaM_toobig(L); + ts = cast(TString *, luaM_malloc(L, (l+1)*sizeof(char)+sizeof(TString))); + ts->tsv.len = l; + ts->tsv.hash = h; + ts->tsv.marked = luaC_white(G(L)); + ts->tsv.tt = LUA_TSTRING; + ts->tsv.reserved = 0; + memcpy(ts+1, str, l*sizeof(char)); + ((char *)(ts+1))[l] = '\0'; /* ending 0 */ + tb = &G(L)->strt; + h = lmod(h, tb->size); + ts->tsv.next = tb->hash[h]; /* chain new entry */ + tb->hash[h] = obj2gco(ts); + tb->nuse++; + if (tb->nuse > cast(lu_int32, tb->size) && tb->size <= MAX_INT/2) + luaS_resize(L, tb->size*2); /* too crowded */ + return ts; +} + + +TString *luaS_newlstr (lua_State *L, const char *str, size_t l) { + GCObject *o; + unsigned int h = cast(unsigned int, l); /* seed */ + size_t step = (l>>5)+1; /* if string is too long, don't hash all its chars */ + size_t l1; + for (l1=l; l1>=step; l1-=step) /* compute hash */ + h = h ^ ((h<<5)+(h>>2)+cast(unsigned char, str[l1-1])); + for (o = G(L)->strt.hash[lmod(h, G(L)->strt.size)]; + o != NULL; + o = o->gch.next) { + TString *ts = rawgco2ts(o); + if (ts->tsv.len == l && (memcmp(str, getstr(ts), l) == 0)) { + /* string may be dead */ + if (isdead(G(L), o)) changewhite(o); + return ts; + } + } + return newlstr(L, str, l, h); /* not found */ +} + + +Udata *luaS_newudata (lua_State *L, size_t s, Table *e) { + Udata *u; + if (s > MAX_SIZET - sizeof(Udata)) + luaM_toobig(L); + u = cast(Udata *, luaM_malloc(L, s + sizeof(Udata))); + u->uv.marked = luaC_white(G(L)); /* is not finalized */ + u->uv.tt = LUA_TUSERDATA; + u->uv.len = s; + u->uv.metatable = NULL; + u->uv.env = e; + /* chain it on udata list (after main thread) */ + u->uv.next = G(L)->mainthread->next; + G(L)->mainthread->next = obj2gco(u); + return u; +} + diff --git a/lua/lstring.h b/lua/lstring.h new file mode 100644 index 0000000..73a2ff8 --- /dev/null +++ b/lua/lstring.h @@ -0,0 +1,31 @@ +/* +** $Id: lstring.h,v 1.43.1.1 2007/12/27 13:02:25 roberto Exp $ +** String table (keep all strings handled by Lua) +** See Copyright Notice in lua.h +*/ + +#ifndef lstring_h +#define lstring_h + + +#include "lgc.h" +#include "lobject.h" +#include "lstate.h" + + +#define sizestring(s) (sizeof(union TString)+((s)->len+1)*sizeof(char)) + +#define sizeudata(u) (sizeof(union Udata)+(u)->len) + +#define luaS_new(L, s) (luaS_newlstr(L, s, strlen(s))) +#define luaS_newliteral(L, s) (luaS_newlstr(L, "" s, \ + (sizeof(s)/sizeof(char))-1)) + +#define luaS_fix(s) l_setbit((s)->tsv.marked, FIXEDBIT) + +LUAI_FUNC void luaS_resize (lua_State *L, int newsize); +LUAI_FUNC Udata *luaS_newudata (lua_State *L, size_t s, Table *e); +LUAI_FUNC TString *luaS_newlstr (lua_State *L, const char *str, size_t l); + + +#endif diff --git a/lua/lstrlib.c b/lua/lstrlib.c new file mode 100644 index 0000000..1b4763d --- /dev/null +++ b/lua/lstrlib.c @@ -0,0 +1,869 @@ +/* +** $Id: lstrlib.c,v 1.132.1.4 2008/07/11 17:27:21 roberto Exp $ +** Standard library for string operations and pattern-matching +** See Copyright Notice in lua.h +*/ + + +#include +#include +#include +#include +#include + +#define lstrlib_c +#define LUA_LIB + +#include "lua.h" + +#include "lauxlib.h" +#include "lualib.h" + + +/* macro to `unsign' a character */ +#define uchar(c) ((unsigned char)(c)) + + + +static int str_len (lua_State *L) { + size_t l; + luaL_checklstring(L, 1, &l); + lua_pushinteger(L, l); + return 1; +} + + +static ptrdiff_t posrelat (ptrdiff_t pos, size_t len) { + /* relative string position: negative means back from end */ + if (pos < 0) pos += (ptrdiff_t)len + 1; + return (pos >= 0) ? pos : 0; +} + + +static int str_sub (lua_State *L) { + size_t l; + const char *s = luaL_checklstring(L, 1, &l); + ptrdiff_t start = posrelat(luaL_checkinteger(L, 2), l); + ptrdiff_t end = posrelat(luaL_optinteger(L, 3, -1), l); + if (start < 1) start = 1; + if (end > (ptrdiff_t)l) end = (ptrdiff_t)l; + if (start <= end) + lua_pushlstring(L, s+start-1, end-start+1); + else lua_pushliteral(L, ""); + return 1; +} + + +static int str_reverse (lua_State *L) { + size_t l; + luaL_Buffer b; + const char *s = luaL_checklstring(L, 1, &l); + luaL_buffinit(L, &b); + while (l--) luaL_addchar(&b, s[l]); + luaL_pushresult(&b); + return 1; +} + + +static int str_lower (lua_State *L) { + size_t l; + size_t i; + luaL_Buffer b; + const char *s = luaL_checklstring(L, 1, &l); + luaL_buffinit(L, &b); + for (i=0; i 0) + luaL_addlstring(&b, s, l); + luaL_pushresult(&b); + return 1; +} + + +static int str_byte (lua_State *L) { + size_t l; + const char *s = luaL_checklstring(L, 1, &l); + ptrdiff_t posi = posrelat(luaL_optinteger(L, 2, 1), l); + ptrdiff_t pose = posrelat(luaL_optinteger(L, 3, posi), l); + int n, i; + if (posi <= 0) posi = 1; + if ((size_t)pose > l) pose = l; + if (posi > pose) return 0; /* empty interval; return no values */ + n = (int)(pose - posi + 1); + if (posi + n <= pose) /* overflow? */ + luaL_error(L, "string slice too long"); + luaL_checkstack(L, n, "string slice too long"); + for (i=0; i= ms->level || ms->capture[l].len == CAP_UNFINISHED) + return luaL_error(ms->L, "invalid capture index"); + return l; +} + + +static int capture_to_close (MatchState *ms) { + int level = ms->level; + for (level--; level>=0; level--) + if (ms->capture[level].len == CAP_UNFINISHED) return level; + return luaL_error(ms->L, "invalid pattern capture"); +} + + +static const char *classend (MatchState *ms, const char *p) { + switch (*p++) { + case L_ESC: { + if (*p == '\0') + luaL_error(ms->L, "malformed pattern (ends with " LUA_QL("%%") ")"); + return p+1; + } + case '[': { + if (*p == '^') p++; + do { /* look for a `]' */ + if (*p == '\0') + luaL_error(ms->L, "malformed pattern (missing " LUA_QL("]") ")"); + if (*(p++) == L_ESC && *p != '\0') + p++; /* skip escapes (e.g. `%]') */ + } while (*p != ']'); + return p+1; + } + default: { + return p; + } + } +} + + +static int match_class (int c, int cl) { + int res; + switch (tolower(cl)) { + case 'a' : res = isalpha(c); break; + case 'c' : res = iscntrl(c); break; + case 'd' : res = isdigit(c); break; + case 'l' : res = islower(c); break; + case 'p' : res = ispunct(c); break; + case 's' : res = isspace(c); break; + case 'u' : res = isupper(c); break; + case 'w' : res = isalnum(c); break; + case 'x' : res = isxdigit(c); break; + case 'z' : res = (c == 0); break; + default: return (cl == c); + } + return (islower(cl) ? res : !res); +} + + +static int matchbracketclass (int c, const char *p, const char *ec) { + int sig = 1; + if (*(p+1) == '^') { + sig = 0; + p++; /* skip the `^' */ + } + while (++p < ec) { + if (*p == L_ESC) { + p++; + if (match_class(c, uchar(*p))) + return sig; + } + else if ((*(p+1) == '-') && (p+2 < ec)) { + p+=2; + if (uchar(*(p-2)) <= c && c <= uchar(*p)) + return sig; + } + else if (uchar(*p) == c) return sig; + } + return !sig; +} + + +static int singlematch (int c, const char *p, const char *ep) { + switch (*p) { + case '.': return 1; /* matches any char */ + case L_ESC: return match_class(c, uchar(*(p+1))); + case '[': return matchbracketclass(c, p, ep-1); + default: return (uchar(*p) == c); + } +} + + +static const char *match (MatchState *ms, const char *s, const char *p); + + +static const char *matchbalance (MatchState *ms, const char *s, + const char *p) { + if (*p == 0 || *(p+1) == 0) + luaL_error(ms->L, "unbalanced pattern"); + if (*s != *p) return NULL; + else { + int b = *p; + int e = *(p+1); + int cont = 1; + while (++s < ms->src_end) { + if (*s == e) { + if (--cont == 0) return s+1; + } + else if (*s == b) cont++; + } + } + return NULL; /* string ends out of balance */ +} + + +static const char *max_expand (MatchState *ms, const char *s, + const char *p, const char *ep) { + ptrdiff_t i = 0; /* counts maximum expand for item */ + while ((s+i)src_end && singlematch(uchar(*(s+i)), p, ep)) + i++; + /* keeps trying to match with the maximum repetitions */ + while (i>=0) { + const char *res = match(ms, (s+i), ep+1); + if (res) return res; + i--; /* else didn't match; reduce 1 repetition to try again */ + } + return NULL; +} + + +static const char *min_expand (MatchState *ms, const char *s, + const char *p, const char *ep) { + for (;;) { + const char *res = match(ms, s, ep+1); + if (res != NULL) + return res; + else if (ssrc_end && singlematch(uchar(*s), p, ep)) + s++; /* try with one more repetition */ + else return NULL; + } +} + + +static const char *start_capture (MatchState *ms, const char *s, + const char *p, int what) { + const char *res; + int level = ms->level; + if (level >= LUA_MAXCAPTURES) luaL_error(ms->L, "too many captures"); + ms->capture[level].init = s; + ms->capture[level].len = what; + ms->level = level+1; + if ((res=match(ms, s, p)) == NULL) /* match failed? */ + ms->level--; /* undo capture */ + return res; +} + + +static const char *end_capture (MatchState *ms, const char *s, + const char *p) { + int l = capture_to_close(ms); + const char *res; + ms->capture[l].len = s - ms->capture[l].init; /* close capture */ + if ((res = match(ms, s, p)) == NULL) /* match failed? */ + ms->capture[l].len = CAP_UNFINISHED; /* undo capture */ + return res; +} + + +static const char *match_capture (MatchState *ms, const char *s, int l) { + size_t len; + l = check_capture(ms, l); + len = ms->capture[l].len; + if ((size_t)(ms->src_end-s) >= len && + memcmp(ms->capture[l].init, s, len) == 0) + return s+len; + else return NULL; +} + + +static const char *match (MatchState *ms, const char *s, const char *p) { + init: /* using goto's to optimize tail recursion */ + switch (*p) { + case '(': { /* start capture */ + if (*(p+1) == ')') /* position capture? */ + return start_capture(ms, s, p+2, CAP_POSITION); + else + return start_capture(ms, s, p+1, CAP_UNFINISHED); + } + case ')': { /* end capture */ + return end_capture(ms, s, p+1); + } + case L_ESC: { + switch (*(p+1)) { + case 'b': { /* balanced string? */ + s = matchbalance(ms, s, p+2); + if (s == NULL) return NULL; + p+=4; goto init; /* else return match(ms, s, p+4); */ + } + case 'f': { /* frontier? */ + const char *ep; char previous; + p += 2; + if (*p != '[') + luaL_error(ms->L, "missing " LUA_QL("[") " after " + LUA_QL("%%f") " in pattern"); + ep = classend(ms, p); /* points to what is next */ + previous = (s == ms->src_init) ? '\0' : *(s-1); + if (matchbracketclass(uchar(previous), p, ep-1) || + !matchbracketclass(uchar(*s), p, ep-1)) return NULL; + p=ep; goto init; /* else return match(ms, s, ep); */ + } + default: { + if (isdigit(uchar(*(p+1)))) { /* capture results (%0-%9)? */ + s = match_capture(ms, s, uchar(*(p+1))); + if (s == NULL) return NULL; + p+=2; goto init; /* else return match(ms, s, p+2) */ + } + goto dflt; /* case default */ + } + } + } + case '\0': { /* end of pattern */ + return s; /* match succeeded */ + } + case '$': { + if (*(p+1) == '\0') /* is the `$' the last char in pattern? */ + return (s == ms->src_end) ? s : NULL; /* check end of string */ + else goto dflt; + } + default: dflt: { /* it is a pattern item */ + const char *ep = classend(ms, p); /* points to what is next */ + int m = ssrc_end && singlematch(uchar(*s), p, ep); + switch (*ep) { + case '?': { /* optional */ + const char *res; + if (m && ((res=match(ms, s+1, ep+1)) != NULL)) + return res; + p=ep+1; goto init; /* else return match(ms, s, ep+1); */ + } + case '*': { /* 0 or more repetitions */ + return max_expand(ms, s, p, ep); + } + case '+': { /* 1 or more repetitions */ + return (m ? max_expand(ms, s+1, p, ep) : NULL); + } + case '-': { /* 0 or more repetitions (minimum) */ + return min_expand(ms, s, p, ep); + } + default: { + if (!m) return NULL; + s++; p=ep; goto init; /* else return match(ms, s+1, ep); */ + } + } + } + } +} + + + +static const char *lmemfind (const char *s1, size_t l1, + const char *s2, size_t l2) { + if (l2 == 0) return s1; /* empty strings are everywhere */ + else if (l2 > l1) return NULL; /* avoids a negative `l1' */ + else { + const char *init; /* to search for a `*s2' inside `s1' */ + l2--; /* 1st char will be checked by `memchr' */ + l1 = l1-l2; /* `s2' cannot be found after that */ + while (l1 > 0 && (init = (const char *)memchr(s1, *s2, l1)) != NULL) { + init++; /* 1st char is already checked */ + if (memcmp(init, s2+1, l2) == 0) + return init-1; + else { /* correct `l1' and `s1' to try again */ + l1 -= init-s1; + s1 = init; + } + } + return NULL; /* not found */ + } +} + + +static void push_onecapture (MatchState *ms, int i, const char *s, + const char *e) { + if (i >= ms->level) { + if (i == 0) /* ms->level == 0, too */ + lua_pushlstring(ms->L, s, e - s); /* add whole match */ + else + luaL_error(ms->L, "invalid capture index"); + } + else { + ptrdiff_t l = ms->capture[i].len; + if (l == CAP_UNFINISHED) luaL_error(ms->L, "unfinished capture"); + if (l == CAP_POSITION) + lua_pushinteger(ms->L, ms->capture[i].init - ms->src_init + 1); + else + lua_pushlstring(ms->L, ms->capture[i].init, l); + } +} + + +static int push_captures (MatchState *ms, const char *s, const char *e) { + int i; + int nlevels = (ms->level == 0 && s) ? 1 : ms->level; + luaL_checkstack(ms->L, nlevels, "too many captures"); + for (i = 0; i < nlevels; i++) + push_onecapture(ms, i, s, e); + return nlevels; /* number of strings pushed */ +} + + +static int str_find_aux (lua_State *L, int find) { + size_t l1, l2; + const char *s = luaL_checklstring(L, 1, &l1); + const char *p = luaL_checklstring(L, 2, &l2); + ptrdiff_t init = posrelat(luaL_optinteger(L, 3, 1), l1) - 1; + if (init < 0) init = 0; + else if ((size_t)(init) > l1) init = (ptrdiff_t)l1; + if (find && (lua_toboolean(L, 4) || /* explicit request? */ + strpbrk(p, SPECIALS) == NULL)) { /* or no special characters? */ + /* do a plain search */ + const char *s2 = lmemfind(s+init, l1-init, p, l2); + if (s2) { + lua_pushinteger(L, s2-s+1); + lua_pushinteger(L, s2-s+l2); + return 2; + } + } + else { + MatchState ms; + int anchor = (*p == '^') ? (p++, 1) : 0; + const char *s1=s+init; + ms.L = L; + ms.src_init = s; + ms.src_end = s+l1; + do { + const char *res; + ms.level = 0; + if ((res=match(&ms, s1, p)) != NULL) { + if (find) { + lua_pushinteger(L, s1-s+1); /* start */ + lua_pushinteger(L, res-s); /* end */ + return push_captures(&ms, NULL, 0) + 2; + } + else + return push_captures(&ms, s1, res); + } + } while (s1++ < ms.src_end && !anchor); + } + lua_pushnil(L); /* not found */ + return 1; +} + + +static int str_find (lua_State *L) { + return str_find_aux(L, 1); +} + + +static int str_match (lua_State *L) { + return str_find_aux(L, 0); +} + + +static int gmatch_aux (lua_State *L) { + MatchState ms; + size_t ls; + const char *s = lua_tolstring(L, lua_upvalueindex(1), &ls); + const char *p = lua_tostring(L, lua_upvalueindex(2)); + const char *src; + ms.L = L; + ms.src_init = s; + ms.src_end = s+ls; + for (src = s + (size_t)lua_tointeger(L, lua_upvalueindex(3)); + src <= ms.src_end; + src++) { + const char *e; + ms.level = 0; + if ((e = match(&ms, src, p)) != NULL) { + lua_Integer newstart = e-s; + if (e == src) newstart++; /* empty match? go at least one position */ + lua_pushinteger(L, newstart); + lua_replace(L, lua_upvalueindex(3)); + return push_captures(&ms, src, e); + } + } + return 0; /* not found */ +} + + +static int gmatch (lua_State *L) { + luaL_checkstring(L, 1); + luaL_checkstring(L, 2); + lua_settop(L, 2); + lua_pushinteger(L, 0); + lua_pushcclosure(L, gmatch_aux, 3); + return 1; +} + + +static int gfind_nodef (lua_State *L) { + return luaL_error(L, LUA_QL("string.gfind") " was renamed to " + LUA_QL("string.gmatch")); +} + + +static void add_s (MatchState *ms, luaL_Buffer *b, const char *s, + const char *e) { + size_t l, i; + const char *news = lua_tolstring(ms->L, 3, &l); + for (i = 0; i < l; i++) { + if (news[i] != L_ESC) + luaL_addchar(b, news[i]); + else { + i++; /* skip ESC */ + if (!isdigit(uchar(news[i]))) + luaL_addchar(b, news[i]); + else if (news[i] == '0') + luaL_addlstring(b, s, e - s); + else { + push_onecapture(ms, news[i] - '1', s, e); + luaL_addvalue(b); /* add capture to accumulated result */ + } + } + } +} + + +static void add_value (MatchState *ms, luaL_Buffer *b, const char *s, + const char *e) { + lua_State *L = ms->L; + switch (lua_type(L, 3)) { + case LUA_TNUMBER: + case LUA_TSTRING: { + add_s(ms, b, s, e); + return; + } + case LUA_TFUNCTION: { + int n; + lua_pushvalue(L, 3); + n = push_captures(ms, s, e); + lua_call(L, n, 1); + break; + } + case LUA_TTABLE: { + push_onecapture(ms, 0, s, e); + lua_gettable(L, 3); + break; + } + } + if (!lua_toboolean(L, -1)) { /* nil or false? */ + lua_pop(L, 1); + lua_pushlstring(L, s, e - s); /* keep original text */ + } + else if (!lua_isstring(L, -1)) + luaL_error(L, "invalid replacement value (a %s)", luaL_typename(L, -1)); + luaL_addvalue(b); /* add result to accumulator */ +} + + +static int str_gsub (lua_State *L) { + size_t srcl; + const char *src = luaL_checklstring(L, 1, &srcl); + const char *p = luaL_checkstring(L, 2); + int tr = lua_type(L, 3); + int max_s = luaL_optint(L, 4, srcl+1); + int anchor = (*p == '^') ? (p++, 1) : 0; + int n = 0; + MatchState ms; + luaL_Buffer b; + luaL_argcheck(L, tr == LUA_TNUMBER || tr == LUA_TSTRING || + tr == LUA_TFUNCTION || tr == LUA_TTABLE, 3, + "string/function/table expected"); + luaL_buffinit(L, &b); + ms.L = L; + ms.src_init = src; + ms.src_end = src+srcl; + while (n < max_s) { + const char *e; + ms.level = 0; + e = match(&ms, src, p); + if (e) { + n++; + add_value(&ms, &b, src, e); + } + if (e && e>src) /* non empty match? */ + src = e; /* skip it */ + else if (src < ms.src_end) + luaL_addchar(&b, *src++); + else break; + if (anchor) break; + } + luaL_addlstring(&b, src, ms.src_end-src); + luaL_pushresult(&b); + lua_pushinteger(L, n); /* number of substitutions */ + return 2; +} + +/* }====================================================== */ + + +/* maximum size of each formatted item (> len(format('%99.99f', -1e308))) */ +#define MAX_ITEM 512 +/* valid flags in a format specification */ +#define FLAGS "-+ #0" +/* +** maximum size of each format specification (such as '%-099.99d') +** (+10 accounts for %99.99x plus margin of error) +*/ +#define MAX_FORMAT (sizeof(FLAGS) + sizeof(LUA_INTFRMLEN) + 10) + + +static void addquoted (lua_State *L, luaL_Buffer *b, int arg) { + size_t l; + const char *s = luaL_checklstring(L, arg, &l); + luaL_addchar(b, '"'); + while (l--) { + switch (*s) { + case '"': case '\\': case '\n': { + luaL_addchar(b, '\\'); + luaL_addchar(b, *s); + break; + } + case '\r': { + luaL_addlstring(b, "\\r", 2); + break; + } + case '\0': { + luaL_addlstring(b, "\\000", 4); + break; + } + default: { + luaL_addchar(b, *s); + break; + } + } + s++; + } + luaL_addchar(b, '"'); +} + +static const char *scanformat (lua_State *L, const char *strfrmt, char *form) { + const char *p = strfrmt; + while (*p != '\0' && strchr(FLAGS, *p) != NULL) p++; /* skip flags */ + if ((size_t)(p - strfrmt) >= sizeof(FLAGS)) + luaL_error(L, "invalid format (repeated flags)"); + if (isdigit(uchar(*p))) p++; /* skip width */ + if (isdigit(uchar(*p))) p++; /* (2 digits at most) */ + if (*p == '.') { + p++; + if (isdigit(uchar(*p))) p++; /* skip precision */ + if (isdigit(uchar(*p))) p++; /* (2 digits at most) */ + } + if (isdigit(uchar(*p))) + luaL_error(L, "invalid format (width or precision too long)"); + *(form++) = '%'; + strncpy(form, strfrmt, p - strfrmt + 1); + form += p - strfrmt + 1; + *form = '\0'; + return p; +} + + +static void addintlen (char *form) { + size_t l = strlen(form); + char spec = form[l - 1]; + strcpy(form + l - 1, LUA_INTFRMLEN); + form[l + sizeof(LUA_INTFRMLEN) - 2] = spec; + form[l + sizeof(LUA_INTFRMLEN) - 1] = '\0'; +} + + +static int str_format (lua_State *L) { + int arg = 1; + size_t sfl; + const char *strfrmt = luaL_checklstring(L, arg, &sfl); + const char *strfrmt_end = strfrmt+sfl; + luaL_Buffer b; + luaL_buffinit(L, &b); + while (strfrmt < strfrmt_end) { + if (*strfrmt != L_ESC) + luaL_addchar(&b, *strfrmt++); + else if (*++strfrmt == L_ESC) + luaL_addchar(&b, *strfrmt++); /* %% */ + else { /* format item */ + char form[MAX_FORMAT]; /* to store the format (`%...') */ + char buff[MAX_ITEM]; /* to store the formatted item */ + arg++; + strfrmt = scanformat(L, strfrmt, form); + switch (*strfrmt++) { + case 'c': { + sprintf(buff, form, (int)luaL_checknumber(L, arg)); + break; + } + case 'd': case 'i': { + addintlen(form); + sprintf(buff, form, (LUA_INTFRM_T)luaL_checknumber(L, arg)); + break; + } + case 'o': case 'u': case 'x': case 'X': { + addintlen(form); + sprintf(buff, form, (unsigned LUA_INTFRM_T)luaL_checknumber(L, arg)); + break; + } + case 'e': case 'E': case 'f': + case 'g': case 'G': { + sprintf(buff, form, (double)luaL_checknumber(L, arg)); + break; + } + case 'q': { + addquoted(L, &b, arg); + continue; /* skip the 'addsize' at the end */ + } + case 's': { + size_t l; + const char *s = luaL_checklstring(L, arg, &l); + if (!strchr(form, '.') && l >= 100) { + /* no precision and string is too long to be formatted; + keep original string */ + lua_pushvalue(L, arg); + luaL_addvalue(&b); + continue; /* skip the `addsize' at the end */ + } + else { + sprintf(buff, form, s); + break; + } + } + default: { /* also treat cases `pnLlh' */ + return luaL_error(L, "invalid option " LUA_QL("%%%c") " to " + LUA_QL("format"), *(strfrmt - 1)); + } + } + luaL_addlstring(&b, buff, strlen(buff)); + } + } + luaL_pushresult(&b); + return 1; +} + + +static const luaL_Reg strlib[] = { + {"byte", str_byte}, + {"char", str_char}, + {"dump", str_dump}, + {"find", str_find}, + {"format", str_format}, + {"gfind", gfind_nodef}, + {"gmatch", gmatch}, + {"gsub", str_gsub}, + {"len", str_len}, + {"lower", str_lower}, + {"match", str_match}, + {"rep", str_rep}, + {"reverse", str_reverse}, + {"sub", str_sub}, + {"upper", str_upper}, + {NULL, NULL} +}; + + +static void createmetatable (lua_State *L) { + lua_createtable(L, 0, 1); /* create metatable for strings */ + lua_pushliteral(L, ""); /* dummy string */ + lua_pushvalue(L, -2); + lua_setmetatable(L, -2); /* set string metatable */ + lua_pop(L, 1); /* pop dummy string */ + lua_pushvalue(L, -2); /* string library... */ + lua_setfield(L, -2, "__index"); /* ...is the __index metamethod */ + lua_pop(L, 1); /* pop metatable */ +} + + +/* +** Open string library +*/ +LUALIB_API int luaopen_string (lua_State *L) { + luaL_register(L, LUA_STRLIBNAME, strlib); +#if defined(LUA_COMPAT_GFIND) + lua_getfield(L, -1, "gmatch"); + lua_setfield(L, -2, "gfind"); +#endif + createmetatable(L); + return 1; +} + diff --git a/lua/ltable.c b/lua/ltable.c new file mode 100644 index 0000000..ec84f4f --- /dev/null +++ b/lua/ltable.c @@ -0,0 +1,588 @@ +/* +** $Id: ltable.c,v 2.32.1.2 2007/12/28 15:32:23 roberto Exp $ +** Lua tables (hash) +** See Copyright Notice in lua.h +*/ + + +/* +** Implementation of tables (aka arrays, objects, or hash tables). +** Tables keep its elements in two parts: an array part and a hash part. +** Non-negative integer keys are all candidates to be kept in the array +** part. The actual size of the array is the largest `n' such that at +** least half the slots between 0 and n are in use. +** Hash uses a mix of chained scatter table with Brent's variation. +** A main invariant of these tables is that, if an element is not +** in its main position (i.e. the `original' position that its hash gives +** to it), then the colliding element is in its own main position. +** Hence even when the load factor reaches 100%, performance remains good. +*/ + +#include +#include + +#define ltable_c +#define LUA_CORE + +#include "lua.h" + +#include "ldebug.h" +#include "ldo.h" +#include "lgc.h" +#include "lmem.h" +#include "lobject.h" +#include "lstate.h" +#include "ltable.h" + + +/* +** max size of array part is 2^MAXBITS +*/ +#if LUAI_BITSINT > 26 +#define MAXBITS 26 +#else +#define MAXBITS (LUAI_BITSINT-2) +#endif + +#define MAXASIZE (1 << MAXBITS) + + +#define hashpow2(t,n) (gnode(t, lmod((n), sizenode(t)))) + +#define hashstr(t,str) hashpow2(t, (str)->tsv.hash) +#define hashboolean(t,p) hashpow2(t, p) + + +/* +** for some types, it is better to avoid modulus by power of 2, as +** they tend to have many 2 factors. +*/ +#define hashmod(t,n) (gnode(t, ((n) % ((sizenode(t)-1)|1)))) + + +#define hashpointer(t,p) hashmod(t, IntPoint(p)) + + +/* +** number of ints inside a lua_Number +*/ +#define numints cast_int(sizeof(lua_Number)/sizeof(int)) + + + +#define dummynode (&dummynode_) + +static const Node dummynode_ = { + {{NULL}, LUA_TNIL}, /* value */ + {{{NULL}, LUA_TNIL, NULL}} /* key */ +}; + + +/* +** hash for lua_Numbers +*/ +static Node *hashnum (const Table *t, lua_Number n) { + unsigned int a[numints]; + int i; + if (luai_numeq(n, 0)) /* avoid problems with -0 */ + return gnode(t, 0); + memcpy(a, &n, sizeof(a)); + for (i = 1; i < numints; i++) a[0] += a[i]; + return hashmod(t, a[0]); +} + + + +/* +** returns the `main' position of an element in a table (that is, the index +** of its hash value) +*/ +static Node *mainposition (const Table *t, const TValue *key) { + switch (ttype(key)) { + case LUA_TNUMBER: + return hashnum(t, nvalue(key)); + case LUA_TSTRING: + return hashstr(t, rawtsvalue(key)); + case LUA_TBOOLEAN: + return hashboolean(t, bvalue(key)); + case LUA_TLIGHTUSERDATA: + return hashpointer(t, pvalue(key)); + default: + return hashpointer(t, gcvalue(key)); + } +} + + +/* +** returns the index for `key' if `key' is an appropriate key to live in +** the array part of the table, -1 otherwise. +*/ +static int arrayindex (const TValue *key) { + if (ttisnumber(key)) { + lua_Number n = nvalue(key); + int k; + lua_number2int(k, n); + if (luai_numeq(cast_num(k), n)) + return k; + } + return -1; /* `key' did not match some condition */ +} + + +/* +** returns the index of a `key' for table traversals. First goes all +** elements in the array part, then elements in the hash part. The +** beginning of a traversal is signalled by -1. +*/ +static int findindex (lua_State *L, Table *t, StkId key) { + int i; + if (ttisnil(key)) return -1; /* first iteration */ + i = arrayindex(key); + if (0 < i && i <= t->sizearray) /* is `key' inside array part? */ + return i-1; /* yes; that's the index (corrected to C) */ + else { + Node *n = mainposition(t, key); + do { /* check whether `key' is somewhere in the chain */ + /* key may be dead already, but it is ok to use it in `next' */ + if (luaO_rawequalObj(key2tval(n), key) || + (ttype(gkey(n)) == LUA_TDEADKEY && iscollectable(key) && + gcvalue(gkey(n)) == gcvalue(key))) { + i = cast_int(n - gnode(t, 0)); /* key index in hash table */ + /* hash elements are numbered after array ones */ + return i + t->sizearray; + } + else n = gnext(n); + } while (n); + luaG_runerror(L, "invalid key to " LUA_QL("next")); /* key not found */ + return 0; /* to avoid warnings */ + } +} + + +int luaH_next (lua_State *L, Table *t, StkId key) { + int i = findindex(L, t, key); /* find original element */ + for (i++; i < t->sizearray; i++) { /* try first array part */ + if (!ttisnil(&t->array[i])) { /* a non-nil value? */ + setnvalue(key, cast_num(i+1)); + setobj2s(L, key+1, &t->array[i]); + return 1; + } + } + for (i -= t->sizearray; i < sizenode(t); i++) { /* then hash part */ + if (!ttisnil(gval(gnode(t, i)))) { /* a non-nil value? */ + setobj2s(L, key, key2tval(gnode(t, i))); + setobj2s(L, key+1, gval(gnode(t, i))); + return 1; + } + } + return 0; /* no more elements */ +} + + +/* +** {============================================================= +** Rehash +** ============================================================== +*/ + + +static int computesizes (int nums[], int *narray) { + int i; + int twotoi; /* 2^i */ + int a = 0; /* number of elements smaller than 2^i */ + int na = 0; /* number of elements to go to array part */ + int n = 0; /* optimal size for array part */ + for (i = 0, twotoi = 1; twotoi/2 < *narray; i++, twotoi *= 2) { + if (nums[i] > 0) { + a += nums[i]; + if (a > twotoi/2) { /* more than half elements present? */ + n = twotoi; /* optimal size (till now) */ + na = a; /* all elements smaller than n will go to array part */ + } + } + if (a == *narray) break; /* all elements already counted */ + } + *narray = n; + lua_assert(*narray/2 <= na && na <= *narray); + return na; +} + + +static int countint (const TValue *key, int *nums) { + int k = arrayindex(key); + if (0 < k && k <= MAXASIZE) { /* is `key' an appropriate array index? */ + nums[ceillog2(k)]++; /* count as such */ + return 1; + } + else + return 0; +} + + +static int numusearray (const Table *t, int *nums) { + int lg; + int ttlg; /* 2^lg */ + int ause = 0; /* summation of `nums' */ + int i = 1; /* count to traverse all array keys */ + for (lg=0, ttlg=1; lg<=MAXBITS; lg++, ttlg*=2) { /* for each slice */ + int lc = 0; /* counter */ + int lim = ttlg; + if (lim > t->sizearray) { + lim = t->sizearray; /* adjust upper limit */ + if (i > lim) + break; /* no more elements to count */ + } + /* count elements in range (2^(lg-1), 2^lg] */ + for (; i <= lim; i++) { + if (!ttisnil(&t->array[i-1])) + lc++; + } + nums[lg] += lc; + ause += lc; + } + return ause; +} + + +static int numusehash (const Table *t, int *nums, int *pnasize) { + int totaluse = 0; /* total number of elements */ + int ause = 0; /* summation of `nums' */ + int i = sizenode(t); + while (i--) { + Node *n = &t->node[i]; + if (!ttisnil(gval(n))) { + ause += countint(key2tval(n), nums); + totaluse++; + } + } + *pnasize += ause; + return totaluse; +} + + +static void setarrayvector (lua_State *L, Table *t, int size) { + int i; + luaM_reallocvector(L, t->array, t->sizearray, size, TValue); + for (i=t->sizearray; iarray[i]); + t->sizearray = size; +} + + +static void setnodevector (lua_State *L, Table *t, int size) { + int lsize; + if (size == 0) { /* no elements to hash part? */ + t->node = cast(Node *, dummynode); /* use common `dummynode' */ + lsize = 0; + } + else { + int i; + lsize = ceillog2(size); + if (lsize > MAXBITS) + luaG_runerror(L, "table overflow"); + size = twoto(lsize); + t->node = luaM_newvector(L, size, Node); + for (i=0; ilsizenode = cast_byte(lsize); + t->lastfree = gnode(t, size); /* all positions are free */ +} + + +static void resize (lua_State *L, Table *t, int nasize, int nhsize) { + int i; + int oldasize = t->sizearray; + int oldhsize = t->lsizenode; + Node *nold = t->node; /* save old hash ... */ + if (nasize > oldasize) /* array part must grow? */ + setarrayvector(L, t, nasize); + /* create new hash part with appropriate size */ + setnodevector(L, t, nhsize); + if (nasize < oldasize) { /* array part must shrink? */ + t->sizearray = nasize; + /* re-insert elements from vanishing slice */ + for (i=nasize; iarray[i])) + setobjt2t(L, luaH_setnum(L, t, i+1), &t->array[i]); + } + /* shrink array */ + luaM_reallocvector(L, t->array, oldasize, nasize, TValue); + } + /* re-insert elements from hash part */ + for (i = twoto(oldhsize) - 1; i >= 0; i--) { + Node *old = nold+i; + if (!ttisnil(gval(old))) + setobjt2t(L, luaH_set(L, t, key2tval(old)), gval(old)); + } + if (nold != dummynode) + luaM_freearray(L, nold, twoto(oldhsize), Node); /* free old array */ +} + + +void luaH_resizearray (lua_State *L, Table *t, int nasize) { + int nsize = (t->node == dummynode) ? 0 : sizenode(t); + resize(L, t, nasize, nsize); +} + + +static void rehash (lua_State *L, Table *t, const TValue *ek) { + int nasize, na; + int nums[MAXBITS+1]; /* nums[i] = number of keys between 2^(i-1) and 2^i */ + int i; + int totaluse; + for (i=0; i<=MAXBITS; i++) nums[i] = 0; /* reset counts */ + nasize = numusearray(t, nums); /* count keys in array part */ + totaluse = nasize; /* all those keys are integer keys */ + totaluse += numusehash(t, nums, &nasize); /* count keys in hash part */ + /* count extra key */ + nasize += countint(ek, nums); + totaluse++; + /* compute new size for array part */ + na = computesizes(nums, &nasize); + /* resize the table to new computed sizes */ + resize(L, t, nasize, totaluse - na); +} + + + +/* +** }============================================================= +*/ + + +Table *luaH_new (lua_State *L, int narray, int nhash) { + Table *t = luaM_new(L, Table); + luaC_link(L, obj2gco(t), LUA_TTABLE); + t->metatable = NULL; + t->flags = cast_byte(~0); + /* temporary values (kept only if some malloc fails) */ + t->array = NULL; + t->sizearray = 0; + t->lsizenode = 0; + t->node = cast(Node *, dummynode); + setarrayvector(L, t, narray); + setnodevector(L, t, nhash); + return t; +} + + +void luaH_free (lua_State *L, Table *t) { + if (t->node != dummynode) + luaM_freearray(L, t->node, sizenode(t), Node); + luaM_freearray(L, t->array, t->sizearray, TValue); + luaM_free(L, t); +} + + +static Node *getfreepos (Table *t) { + while (t->lastfree-- > t->node) { + if (ttisnil(gkey(t->lastfree))) + return t->lastfree; + } + return NULL; /* could not find a free place */ +} + + + +/* +** inserts a new key into a hash table; first, check whether key's main +** position is free. If not, check whether colliding node is in its main +** position or not: if it is not, move colliding node to an empty place and +** put new key in its main position; otherwise (colliding node is in its main +** position), new key goes to an empty position. +*/ +static TValue *newkey (lua_State *L, Table *t, const TValue *key) { + Node *mp = mainposition(t, key); + if (!ttisnil(gval(mp)) || mp == dummynode) { + Node *othern; + Node *n = getfreepos(t); /* get a free place */ + if (n == NULL) { /* cannot find a free place? */ + rehash(L, t, key); /* grow table */ + return luaH_set(L, t, key); /* re-insert key into grown table */ + } + lua_assert(n != dummynode); + othern = mainposition(t, key2tval(mp)); + if (othern != mp) { /* is colliding node out of its main position? */ + /* yes; move colliding node into free position */ + while (gnext(othern) != mp) othern = gnext(othern); /* find previous */ + gnext(othern) = n; /* redo the chain with `n' in place of `mp' */ + *n = *mp; /* copy colliding node into free pos. (mp->next also goes) */ + gnext(mp) = NULL; /* now `mp' is free */ + setnilvalue(gval(mp)); + } + else { /* colliding node is in its own main position */ + /* new node will go into free position */ + gnext(n) = gnext(mp); /* chain new position */ + gnext(mp) = n; + mp = n; + } + } + gkey(mp)->value = key->value; gkey(mp)->tt = key->tt; + luaC_barriert(L, t, key); + lua_assert(ttisnil(gval(mp))); + return gval(mp); +} + + +/* +** search function for integers +*/ +const TValue *luaH_getnum (Table *t, int key) { + /* (1 <= key && key <= t->sizearray) */ + if (cast(unsigned int, key-1) < cast(unsigned int, t->sizearray)) + return &t->array[key-1]; + else { + lua_Number nk = cast_num(key); + Node *n = hashnum(t, nk); + do { /* check whether `key' is somewhere in the chain */ + if (ttisnumber(gkey(n)) && luai_numeq(nvalue(gkey(n)), nk)) + return gval(n); /* that's it */ + else n = gnext(n); + } while (n); + return luaO_nilobject; + } +} + + +/* +** search function for strings +*/ +const TValue *luaH_getstr (Table *t, TString *key) { + Node *n = hashstr(t, key); + do { /* check whether `key' is somewhere in the chain */ + if (ttisstring(gkey(n)) && rawtsvalue(gkey(n)) == key) + return gval(n); /* that's it */ + else n = gnext(n); + } while (n); + return luaO_nilobject; +} + + +/* +** main search function +*/ +const TValue *luaH_get (Table *t, const TValue *key) { + switch (ttype(key)) { + case LUA_TNIL: return luaO_nilobject; + case LUA_TSTRING: return luaH_getstr(t, rawtsvalue(key)); + case LUA_TNUMBER: { + int k; + lua_Number n = nvalue(key); + lua_number2int(k, n); + if (luai_numeq(cast_num(k), nvalue(key))) /* index is int? */ + return luaH_getnum(t, k); /* use specialized version */ + /* else go through */ + } + default: { + Node *n = mainposition(t, key); + do { /* check whether `key' is somewhere in the chain */ + if (luaO_rawequalObj(key2tval(n), key)) + return gval(n); /* that's it */ + else n = gnext(n); + } while (n); + return luaO_nilobject; + } + } +} + + +TValue *luaH_set (lua_State *L, Table *t, const TValue *key) { + const TValue *p = luaH_get(t, key); + t->flags = 0; + if (p != luaO_nilobject) + return cast(TValue *, p); + else { + if (ttisnil(key)) luaG_runerror(L, "table index is nil"); + else if (ttisnumber(key) && luai_numisnan(nvalue(key))) + luaG_runerror(L, "table index is NaN"); + return newkey(L, t, key); + } +} + + +TValue *luaH_setnum (lua_State *L, Table *t, int key) { + const TValue *p = luaH_getnum(t, key); + if (p != luaO_nilobject) + return cast(TValue *, p); + else { + TValue k; + setnvalue(&k, cast_num(key)); + return newkey(L, t, &k); + } +} + + +TValue *luaH_setstr (lua_State *L, Table *t, TString *key) { + const TValue *p = luaH_getstr(t, key); + if (p != luaO_nilobject) + return cast(TValue *, p); + else { + TValue k; + setsvalue(L, &k, key); + return newkey(L, t, &k); + } +} + + +static int unbound_search (Table *t, unsigned int j) { + unsigned int i = j; /* i is zero or a present index */ + j++; + /* find `i' and `j' such that i is present and j is not */ + while (!ttisnil(luaH_getnum(t, j))) { + i = j; + j *= 2; + if (j > cast(unsigned int, MAX_INT)) { /* overflow? */ + /* table was built with bad purposes: resort to linear search */ + i = 1; + while (!ttisnil(luaH_getnum(t, i))) i++; + return i - 1; + } + } + /* now do a binary search between them */ + while (j - i > 1) { + unsigned int m = (i+j)/2; + if (ttisnil(luaH_getnum(t, m))) j = m; + else i = m; + } + return i; +} + + +/* +** Try to find a boundary in table `t'. A `boundary' is an integer index +** such that t[i] is non-nil and t[i+1] is nil (and 0 if t[1] is nil). +*/ +int luaH_getn (Table *t) { + unsigned int j = t->sizearray; + if (j > 0 && ttisnil(&t->array[j - 1])) { + /* there is a boundary in the array part: (binary) search for it */ + unsigned int i = 0; + while (j - i > 1) { + unsigned int m = (i+j)/2; + if (ttisnil(&t->array[m - 1])) j = m; + else i = m; + } + return i; + } + /* else must find a boundary in hash part */ + else if (t->node == dummynode) /* hash part is empty? */ + return j; /* that is easy... */ + else return unbound_search(t, j); +} + + + +#if defined(LUA_DEBUG) + +Node *luaH_mainposition (const Table *t, const TValue *key) { + return mainposition(t, key); +} + +int luaH_isdummy (Node *n) { return n == dummynode; } + +#endif diff --git a/lua/ltable.h b/lua/ltable.h new file mode 100644 index 0000000..f5b9d5e --- /dev/null +++ b/lua/ltable.h @@ -0,0 +1,40 @@ +/* +** $Id: ltable.h,v 2.10.1.1 2007/12/27 13:02:25 roberto Exp $ +** Lua tables (hash) +** See Copyright Notice in lua.h +*/ + +#ifndef ltable_h +#define ltable_h + +#include "lobject.h" + + +#define gnode(t,i) (&(t)->node[i]) +#define gkey(n) (&(n)->i_key.nk) +#define gval(n) (&(n)->i_val) +#define gnext(n) ((n)->i_key.nk.next) + +#define key2tval(n) (&(n)->i_key.tvk) + + +LUAI_FUNC const TValue *luaH_getnum (Table *t, int key); +LUAI_FUNC TValue *luaH_setnum (lua_State *L, Table *t, int key); +LUAI_FUNC const TValue *luaH_getstr (Table *t, TString *key); +LUAI_FUNC TValue *luaH_setstr (lua_State *L, Table *t, TString *key); +LUAI_FUNC const TValue *luaH_get (Table *t, const TValue *key); +LUAI_FUNC TValue *luaH_set (lua_State *L, Table *t, const TValue *key); +LUAI_FUNC Table *luaH_new (lua_State *L, int narray, int lnhash); +LUAI_FUNC void luaH_resizearray (lua_State *L, Table *t, int nasize); +LUAI_FUNC void luaH_free (lua_State *L, Table *t); +LUAI_FUNC int luaH_next (lua_State *L, Table *t, StkId key); +LUAI_FUNC int luaH_getn (Table *t); + + +#if defined(LUA_DEBUG) +LUAI_FUNC Node *luaH_mainposition (const Table *t, const TValue *key); +LUAI_FUNC int luaH_isdummy (Node *n); +#endif + + +#endif diff --git a/lua/ltablib.c b/lua/ltablib.c new file mode 100644 index 0000000..b6d9cb4 --- /dev/null +++ b/lua/ltablib.c @@ -0,0 +1,287 @@ +/* +** $Id: ltablib.c,v 1.38.1.3 2008/02/14 16:46:58 roberto Exp $ +** Library for Table Manipulation +** See Copyright Notice in lua.h +*/ + + +#include + +#define ltablib_c +#define LUA_LIB + +#include "lua.h" + +#include "lauxlib.h" +#include "lualib.h" + + +#define aux_getn(L,n) (luaL_checktype(L, n, LUA_TTABLE), luaL_getn(L, n)) + + +static int foreachi (lua_State *L) { + int i; + int n = aux_getn(L, 1); + luaL_checktype(L, 2, LUA_TFUNCTION); + for (i=1; i <= n; i++) { + lua_pushvalue(L, 2); /* function */ + lua_pushinteger(L, i); /* 1st argument */ + lua_rawgeti(L, 1, i); /* 2nd argument */ + lua_call(L, 2, 1); + if (!lua_isnil(L, -1)) + return 1; + lua_pop(L, 1); /* remove nil result */ + } + return 0; +} + + +static int foreach (lua_State *L) { + luaL_checktype(L, 1, LUA_TTABLE); + luaL_checktype(L, 2, LUA_TFUNCTION); + lua_pushnil(L); /* first key */ + while (lua_next(L, 1)) { + lua_pushvalue(L, 2); /* function */ + lua_pushvalue(L, -3); /* key */ + lua_pushvalue(L, -3); /* value */ + lua_call(L, 2, 1); + if (!lua_isnil(L, -1)) + return 1; + lua_pop(L, 2); /* remove value and result */ + } + return 0; +} + + +static int maxn (lua_State *L) { + lua_Number max = 0; + luaL_checktype(L, 1, LUA_TTABLE); + lua_pushnil(L); /* first key */ + while (lua_next(L, 1)) { + lua_pop(L, 1); /* remove value */ + if (lua_type(L, -1) == LUA_TNUMBER) { + lua_Number v = lua_tonumber(L, -1); + if (v > max) max = v; + } + } + lua_pushnumber(L, max); + return 1; +} + + +static int getn (lua_State *L) { + lua_pushinteger(L, aux_getn(L, 1)); + return 1; +} + + +static int setn (lua_State *L) { + luaL_checktype(L, 1, LUA_TTABLE); +#ifndef luaL_setn + luaL_setn(L, 1, luaL_checkint(L, 2)); +#else + luaL_error(L, LUA_QL("setn") " is obsolete"); +#endif + lua_pushvalue(L, 1); + return 1; +} + + +static int tinsert (lua_State *L) { + int e = aux_getn(L, 1) + 1; /* first empty element */ + int pos; /* where to insert new element */ + switch (lua_gettop(L)) { + case 2: { /* called with only 2 arguments */ + pos = e; /* insert new element at the end */ + break; + } + case 3: { + int i; + pos = luaL_checkint(L, 2); /* 2nd argument is the position */ + if (pos > e) e = pos; /* `grow' array if necessary */ + for (i = e; i > pos; i--) { /* move up elements */ + lua_rawgeti(L, 1, i-1); + lua_rawseti(L, 1, i); /* t[i] = t[i-1] */ + } + break; + } + default: { + return luaL_error(L, "wrong number of arguments to " LUA_QL("insert")); + } + } + luaL_setn(L, 1, e); /* new size */ + lua_rawseti(L, 1, pos); /* t[pos] = v */ + return 0; +} + + +static int tremove (lua_State *L) { + int e = aux_getn(L, 1); + int pos = luaL_optint(L, 2, e); + if (!(1 <= pos && pos <= e)) /* position is outside bounds? */ + return 0; /* nothing to remove */ + luaL_setn(L, 1, e - 1); /* t.n = n-1 */ + lua_rawgeti(L, 1, pos); /* result = t[pos] */ + for ( ;pos= P */ + while (lua_rawgeti(L, 1, ++i), sort_comp(L, -1, -2)) { + if (i>u) luaL_error(L, "invalid order function for sorting"); + lua_pop(L, 1); /* remove a[i] */ + } + /* repeat --j until a[j] <= P */ + while (lua_rawgeti(L, 1, --j), sort_comp(L, -3, -1)) { + if (j + +#define ltm_c +#define LUA_CORE + +#include "lua.h" + +#include "lobject.h" +#include "lstate.h" +#include "lstring.h" +#include "ltable.h" +#include "ltm.h" + + + +const char *const luaT_typenames[] = { + "nil", "boolean", "userdata", "number", + "string", "table", "function", "userdata", "thread", + "proto", "upval" +}; + + +void luaT_init (lua_State *L) { + static const char *const luaT_eventname[] = { /* ORDER TM */ + "__index", "__newindex", + "__gc", "__mode", "__eq", + "__add", "__sub", "__mul", "__div", "__mod", + "__pow", "__unm", "__len", "__lt", "__le", + "__concat", "__call" + }; + int i; + for (i=0; itmname[i] = luaS_new(L, luaT_eventname[i]); + luaS_fix(G(L)->tmname[i]); /* never collect these names */ + } +} + + +/* +** function to be used with macro "fasttm": optimized for absence of +** tag methods +*/ +const TValue *luaT_gettm (Table *events, TMS event, TString *ename) { + const TValue *tm = luaH_getstr(events, ename); + lua_assert(event <= TM_EQ); + if (ttisnil(tm)) { /* no tag method? */ + events->flags |= cast_byte(1u<metatable; + break; + case LUA_TUSERDATA: + mt = uvalue(o)->metatable; + break; + default: + mt = G(L)->mt[ttype(o)]; + } + return (mt ? luaH_getstr(mt, G(L)->tmname[event]) : luaO_nilobject); +} + diff --git a/lua/ltm.h b/lua/ltm.h new file mode 100644 index 0000000..64343b7 --- /dev/null +++ b/lua/ltm.h @@ -0,0 +1,54 @@ +/* +** $Id: ltm.h,v 2.6.1.1 2007/12/27 13:02:25 roberto Exp $ +** Tag methods +** See Copyright Notice in lua.h +*/ + +#ifndef ltm_h +#define ltm_h + + +#include "lobject.h" + + +/* +* WARNING: if you change the order of this enumeration, +* grep "ORDER TM" +*/ +typedef enum { + TM_INDEX, + TM_NEWINDEX, + TM_GC, + TM_MODE, + TM_EQ, /* last tag method with `fast' access */ + TM_ADD, + TM_SUB, + TM_MUL, + TM_DIV, + TM_MOD, + TM_POW, + TM_UNM, + TM_LEN, + TM_LT, + TM_LE, + TM_CONCAT, + TM_CALL, + TM_N /* number of elements in the enum */ +} TMS; + + + +#define gfasttm(g,et,e) ((et) == NULL ? NULL : \ + ((et)->flags & (1u<<(e))) ? NULL : luaT_gettm(et, e, (g)->tmname[e])) + +#define fasttm(l,et,e) gfasttm(G(l), et, e) + +LUAI_DATA const char *const luaT_typenames[]; + + +LUAI_FUNC const TValue *luaT_gettm (Table *events, TMS event, TString *ename); +LUAI_FUNC const TValue *luaT_gettmbyobj (lua_State *L, const TValue *o, + TMS event); +LUAI_FUNC void luaT_init (lua_State *L); + +#endif diff --git a/lua/lua.c b/lua/lua.c new file mode 100644 index 0000000..3a46609 --- /dev/null +++ b/lua/lua.c @@ -0,0 +1,392 @@ +/* +** $Id: lua.c,v 1.160.1.2 2007/12/28 15:32:23 roberto Exp $ +** Lua stand-alone interpreter +** See Copyright Notice in lua.h +*/ + + +#include +#include +#include +#include + +#define lua_c + +#include "lua.h" + +#include "lauxlib.h" +#include "lualib.h" + + + +static lua_State *globalL = NULL; + +static const char *progname = LUA_PROGNAME; + + + +static void lstop (lua_State *L, lua_Debug *ar) { + (void)ar; /* unused arg. */ + lua_sethook(L, NULL, 0, 0); + luaL_error(L, "interrupted!"); +} + + +static void laction (int i) { + signal(i, SIG_DFL); /* if another SIGINT happens before lstop, + terminate process (default action) */ + lua_sethook(globalL, lstop, LUA_MASKCALL | LUA_MASKRET | LUA_MASKCOUNT, 1); +} + + +static void print_usage (void) { + fprintf(stderr, + "usage: %s [options] [script [args]].\n" + "Available options are:\n" + " -e stat execute string " LUA_QL("stat") "\n" + " -l name require library " LUA_QL("name") "\n" + " -i enter interactive mode after executing " LUA_QL("script") "\n" + " -v show version information\n" + " -- stop handling options\n" + " - execute stdin and stop handling options\n" + , + progname); + fflush(stderr); +} + + +static void l_message (const char *pname, const char *msg) { + if (pname) fprintf(stderr, "%s: ", pname); + fprintf(stderr, "%s\n", msg); + fflush(stderr); +} + + +static int report (lua_State *L, int status) { + if (status && !lua_isnil(L, -1)) { + const char *msg = lua_tostring(L, -1); + if (msg == NULL) msg = "(error object is not a string)"; + l_message(progname, msg); + lua_pop(L, 1); + } + return status; +} + + +static int traceback (lua_State *L) { + if (!lua_isstring(L, 1)) /* 'message' not a string? */ + return 1; /* keep it intact */ + lua_getfield(L, LUA_GLOBALSINDEX, "debug"); + if (!lua_istable(L, -1)) { + lua_pop(L, 1); + return 1; + } + lua_getfield(L, -1, "traceback"); + if (!lua_isfunction(L, -1)) { + lua_pop(L, 2); + return 1; + } + lua_pushvalue(L, 1); /* pass error message */ + lua_pushinteger(L, 2); /* skip this function and traceback */ + lua_call(L, 2, 1); /* call debug.traceback */ + return 1; +} + + +static int docall (lua_State *L, int narg, int clear) { + int status; + int base = lua_gettop(L) - narg; /* function index */ + lua_pushcfunction(L, traceback); /* push traceback function */ + lua_insert(L, base); /* put it under chunk and args */ + signal(SIGINT, laction); + status = lua_pcall(L, narg, (clear ? 0 : LUA_MULTRET), base); + signal(SIGINT, SIG_DFL); + lua_remove(L, base); /* remove traceback function */ + /* force a complete garbage collection in case of errors */ + if (status != 0) lua_gc(L, LUA_GCCOLLECT, 0); + return status; +} + + +static void print_version (void) { + l_message(NULL, LUA_RELEASE " " LUA_COPYRIGHT); +} + + +static int getargs (lua_State *L, char **argv, int n) { + int narg; + int i; + int argc = 0; + while (argv[argc]) argc++; /* count total number of arguments */ + narg = argc - (n + 1); /* number of arguments to the script */ + luaL_checkstack(L, narg + 3, "too many arguments to script"); + for (i=n+1; i < argc; i++) + lua_pushstring(L, argv[i]); + lua_createtable(L, narg, n + 1); + for (i=0; i < argc; i++) { + lua_pushstring(L, argv[i]); + lua_rawseti(L, -2, i - n); + } + return narg; +} + + +static int dofile (lua_State *L, const char *name) { + int status = luaL_loadfile(L, name) || docall(L, 0, 1); + return report(L, status); +} + + +static int dostring (lua_State *L, const char *s, const char *name) { + int status = luaL_loadbuffer(L, s, strlen(s), name) || docall(L, 0, 1); + return report(L, status); +} + + +static int dolibrary (lua_State *L, const char *name) { + lua_getglobal(L, "require"); + lua_pushstring(L, name); + return report(L, docall(L, 1, 1)); +} + + +static const char *get_prompt (lua_State *L, int firstline) { + const char *p; + lua_getfield(L, LUA_GLOBALSINDEX, firstline ? "_PROMPT" : "_PROMPT2"); + p = lua_tostring(L, -1); + if (p == NULL) p = (firstline ? LUA_PROMPT : LUA_PROMPT2); + lua_pop(L, 1); /* remove global */ + return p; +} + + +static int incomplete (lua_State *L, int status) { + if (status == LUA_ERRSYNTAX) { + size_t lmsg; + const char *msg = lua_tolstring(L, -1, &lmsg); + const char *tp = msg + lmsg - (sizeof(LUA_QL("")) - 1); + if (strstr(msg, LUA_QL("")) == tp) { + lua_pop(L, 1); + return 1; + } + } + return 0; /* else... */ +} + + +static int pushline (lua_State *L, int firstline) { + char buffer[LUA_MAXINPUT]; + char *b = buffer; + size_t l; + const char *prmt = get_prompt(L, firstline); + if (lua_readline(L, b, prmt) == 0) + return 0; /* no input */ + l = strlen(b); + if (l > 0 && b[l-1] == '\n') /* line ends with newline? */ + b[l-1] = '\0'; /* remove it */ + if (firstline && b[0] == '=') /* first line starts with `=' ? */ + lua_pushfstring(L, "return %s", b+1); /* change it to `return' */ + else + lua_pushstring(L, b); + lua_freeline(L, b); + return 1; +} + + +static int loadline (lua_State *L) { + int status; + lua_settop(L, 0); + if (!pushline(L, 1)) + return -1; /* no input */ + for (;;) { /* repeat until gets a complete line */ + status = luaL_loadbuffer(L, lua_tostring(L, 1), lua_strlen(L, 1), "=stdin"); + if (!incomplete(L, status)) break; /* cannot try to add lines? */ + if (!pushline(L, 0)) /* no more input? */ + return -1; + lua_pushliteral(L, "\n"); /* add a new line... */ + lua_insert(L, -2); /* ...between the two lines */ + lua_concat(L, 3); /* join them */ + } + lua_saveline(L, 1); + lua_remove(L, 1); /* remove line */ + return status; +} + + +static void dotty (lua_State *L) { + int status; + const char *oldprogname = progname; + progname = NULL; + while ((status = loadline(L)) != -1) { + if (status == 0) status = docall(L, 0, 0); + report(L, status); + if (status == 0 && lua_gettop(L) > 0) { /* any result to print? */ + lua_getglobal(L, "print"); + lua_insert(L, 1); + if (lua_pcall(L, lua_gettop(L)-1, 0, 0) != 0) + l_message(progname, lua_pushfstring(L, + "error calling " LUA_QL("print") " (%s)", + lua_tostring(L, -1))); + } + } + lua_settop(L, 0); /* clear stack */ + fputs("\n", stdout); + fflush(stdout); + progname = oldprogname; +} + + +static int handle_script (lua_State *L, char **argv, int n) { + int status; + const char *fname; + int narg = getargs(L, argv, n); /* collect arguments */ + lua_setglobal(L, "arg"); + fname = argv[n]; + if (strcmp(fname, "-") == 0 && strcmp(argv[n-1], "--") != 0) + fname = NULL; /* stdin */ + status = luaL_loadfile(L, fname); + lua_insert(L, -(narg+1)); + if (status == 0) + status = docall(L, narg, 0); + else + lua_pop(L, narg); + return report(L, status); +} + + +/* check that argument has no extra characters at the end */ +#define notail(x) {if ((x)[2] != '\0') return -1;} + + +static int collectargs (char **argv, int *pi, int *pv, int *pe) { + int i; + for (i = 1; argv[i] != NULL; i++) { + if (argv[i][0] != '-') /* not an option? */ + return i; + switch (argv[i][1]) { /* option */ + case '-': + notail(argv[i]); + return (argv[i+1] != NULL ? i+1 : 0); + case '\0': + return i; + case 'i': + notail(argv[i]); + *pi = 1; /* go through */ + case 'v': + notail(argv[i]); + *pv = 1; + break; + case 'e': + *pe = 1; /* go through */ + case 'l': + if (argv[i][2] == '\0') { + i++; + if (argv[i] == NULL) return -1; + } + break; + default: return -1; /* invalid option */ + } + } + return 0; +} + + +static int runargs (lua_State *L, char **argv, int n) { + int i; + for (i = 1; i < n; i++) { + if (argv[i] == NULL) continue; + lua_assert(argv[i][0] == '-'); + switch (argv[i][1]) { /* option */ + case 'e': { + const char *chunk = argv[i] + 2; + if (*chunk == '\0') chunk = argv[++i]; + lua_assert(chunk != NULL); + if (dostring(L, chunk, "=(command line)") != 0) + return 1; + break; + } + case 'l': { + const char *filename = argv[i] + 2; + if (*filename == '\0') filename = argv[++i]; + lua_assert(filename != NULL); + if (dolibrary(L, filename)) + return 1; /* stop if file fails */ + break; + } + default: break; + } + } + return 0; +} + + +static int handle_luainit (lua_State *L) { + const char *init = getenv(LUA_INIT); + if (init == NULL) return 0; /* status OK */ + else if (init[0] == '@') + return dofile(L, init+1); + else + return dostring(L, init, "=" LUA_INIT); +} + + +struct Smain { + int argc; + char **argv; + int status; +}; + + +static int pmain (lua_State *L) { + struct Smain *s = (struct Smain *)lua_touserdata(L, 1); + char **argv = s->argv; + int script; + int has_i = 0, has_v = 0, has_e = 0; + globalL = L; + if (argv[0] && argv[0][0]) progname = argv[0]; + lua_gc(L, LUA_GCSTOP, 0); /* stop collector during initialization */ + luaL_openlibs(L); /* open libraries */ + lua_gc(L, LUA_GCRESTART, 0); + s->status = handle_luainit(L); + if (s->status != 0) return 0; + script = collectargs(argv, &has_i, &has_v, &has_e); + if (script < 0) { /* invalid args? */ + print_usage(); + s->status = 1; + return 0; + } + if (has_v) print_version(); + s->status = runargs(L, argv, (script > 0) ? script : s->argc); + if (s->status != 0) return 0; + if (script) + s->status = handle_script(L, argv, script); + if (s->status != 0) return 0; + if (has_i) + dotty(L); + else if (script == 0 && !has_e && !has_v) { + if (lua_stdin_is_tty()) { + print_version(); + dotty(L); + } + else dofile(L, NULL); /* executes stdin as a file */ + } + return 0; +} + + +int main (int argc, char **argv) { + int status; + struct Smain s; + lua_State *L = lua_open(); /* create state */ + if (L == NULL) { + l_message(argv[0], "cannot create state: not enough memory"); + return EXIT_FAILURE; + } + s.argc = argc; + s.argv = argv; + status = lua_cpcall(L, &pmain, &s); + report(L, status); + lua_close(L); + return (status || s.status) ? EXIT_FAILURE : EXIT_SUCCESS; +} + diff --git a/lua/lua.h b/lua/lua.h new file mode 100644 index 0000000..1cc26e9 --- /dev/null +++ b/lua/lua.h @@ -0,0 +1,398 @@ +/* +** $Id: lua.h,v 1.218.1.5 2008/08/06 13:30:12 roberto Exp $ +** Lua - An Extensible Extension Language +** Lua.org, PUC-Rio, Brazil (http://www.lua.org) +** See Copyright Notice at the end of this file +*/ + + +#ifndef lua_h +#define lua_h + +#include +#include + + +#include "luaconf.h" + + +#define LUA_VERSION "Lua 5.1" +#define LUA_RELEASE "Lua 5.1.4" +#define LUA_VERSION_NUM 501 +#define LUA_COPYRIGHT "Copyright (C) 1994-2008 Lua.org, PUC-Rio" +#define LUA_AUTHORS "R. Ierusalimschy, L. H. de Figueiredo & W. Celes" + + +/* mark for precompiled code (`Lua') */ +#define LUA_SIGNATURE "\033Lua" + +/* option for multiple returns in `lua_pcall' and `lua_call' */ +#define LUA_MULTRET (-1) + + +/* +** pseudo-indices +*/ +#define LUA_REGISTRYINDEX (-10000) +#define LUA_ENVIRONINDEX (-10001) +#define LUA_GLOBALSINDEX (-10002) +#define lua_upvalueindex(i) (LUA_GLOBALSINDEX-(i)) + + +/* thread status; 0 is OK */ +#define LUA_YIELD 1 +#define LUA_ERRRUN 2 +#define LUA_ERRSYNTAX 3 +#define LUA_ERRMEM 4 +#define LUA_ERRERR 5 + + +typedef struct lua_State lua_State; + +typedef int (*lua_CFunction) (lua_State *L); + + +/* +** functions that read/write blocks when loading/dumping Lua chunks +*/ +typedef const char * (*lua_Reader) (lua_State *L, void *ud, size_t *sz); + +typedef int (*lua_Writer) (lua_State *L, const void* p, size_t sz, void* ud); + + +/* +** prototype for memory-allocation functions +*/ +typedef void * (*lua_Alloc) (void *ud, void *ptr, size_t osize, size_t nsize); + + +/* +** basic types +*/ +#define LUA_TNONE (-1) + +#define LUA_TNIL 0 +#define LUA_TBOOLEAN 1 +#define LUA_TLIGHTUSERDATA 2 +#define LUA_TNUMBER 3 +#define LUA_TSTRING 4 +#define LUA_TTABLE 5 +#define LUA_TFUNCTION 6 +#define LUA_TUSERDATA 7 +#define LUA_TTHREAD 8 + + + +/* minimum Lua stack available to a C function */ +#define LUA_MINSTACK 20 + + +/* +** generic extra include file +*/ +#if defined(LUA_USER_H) +#include LUA_USER_H +#endif + + +/* type of numbers in Lua */ +typedef LUA_NUMBER lua_Number; + + +/* type for integer functions */ +typedef LUA_INTEGER lua_Integer; + + + +/* +** state manipulation +*/ +LUA_API lua_State *(lua_newstate) (lua_Alloc f, void *ud); +LUA_API void (lua_close) (lua_State *L); +LUA_API lua_State *(lua_newthread) (lua_State *L); + +LUA_API lua_CFunction (lua_atpanic) (lua_State *L, lua_CFunction panicf); + + +/* +** basic stack manipulation +*/ +LUA_API int (lua_gettop) (lua_State *L); +LUA_API void (lua_settop) (lua_State *L, int idx); +LUA_API void (lua_pushvalue) (lua_State *L, int idx); +LUA_API void (lua_remove) (lua_State *L, int idx); +LUA_API void (lua_insert) (lua_State *L, int idx); +LUA_API void (lua_replace) (lua_State *L, int idx); +LUA_API int (lua_checkstack) (lua_State *L, int sz); + +LUA_API void (lua_xmove) (lua_State *from, lua_State *to, int n); + + +/* +** access functions (stack -> C) +*/ + +LUA_API int (lua_isnumber) (lua_State *L, int idx); +LUA_API int (lua_isstring) (lua_State *L, int idx); +LUA_API int (lua_iscfunction) (lua_State *L, int idx); +LUA_API int (lua_isuserdata) (lua_State *L, int idx); +LUA_API int (lua_type) (lua_State *L, int idx); +LUA_API const char *(lua_typename) (lua_State *L, int tp); + +LUA_API int (lua_equal) (lua_State *L, int idx1, int idx2); +LUA_API int (lua_rawequal) (lua_State *L, int idx1, int idx2); +LUA_API int (lua_lessthan) (lua_State *L, int idx1, int idx2); + +LUA_API lua_Number (lua_tonumber) (lua_State *L, int idx); +LUA_API lua_Integer (lua_tointeger) (lua_State *L, int idx); +LUA_API int (lua_toboolean) (lua_State *L, int idx); +LUA_API const char *(lua_tolstring) (lua_State *L, int idx, size_t *len); +LUA_API size_t (lua_objlen) (lua_State *L, int idx); +LUA_API lua_CFunction (lua_tocfunction) (lua_State *L, int idx); +LUA_API void *(lua_touserdata) (lua_State *L, int idx); +LUA_API lua_State *(lua_tothread) (lua_State *L, int idx); +LUA_API const void *(lua_topointer) (lua_State *L, int idx); + + +/* +** push functions (C -> stack) +*/ +LUA_API void (lua_pushnil) (lua_State *L); +LUA_API void (lua_pushnumber) (lua_State *L, lua_Number n); +LUA_API void (lua_pushinteger) (lua_State *L, lua_Integer n); +LUA_API void (lua_pushlstring) (lua_State *L, const char *s, size_t l); +LUA_API void (lua_pushstring) (lua_State *L, const char *s); +LUA_API const char *(lua_pushvfstring) (lua_State *L, const char *fmt, + va_list argp); +LUA_API const char *(lua_pushfstring) (lua_State *L, const char *fmt, ...); +LUA_API void (lua_pushcclosure) (lua_State *L, lua_CFunction fn, int n); +LUA_API void (lua_pushboolean) (lua_State *L, int b); +LUA_API void (lua_pushlightuserdata) (lua_State *L, void *p); +LUA_API int (lua_pushthread) (lua_State *L); + + +/* +** get functions (Lua -> stack) +*/ +LUA_API void (lua_gettable) (lua_State *L, int idx); +LUA_API void (lua_getfield) (lua_State *L, int idx, const char *k); +LUA_API void (lua_rawget) (lua_State *L, int idx); +LUA_API void (lua_rawgeti) (lua_State *L, int idx, int n); +LUA_API void (lua_createtable) (lua_State *L, int narr, int nrec); +LUA_API void *(lua_newuserdata) (lua_State *L, size_t sz); +LUA_API int (lua_getmetatable) (lua_State *L, int objindex); +LUA_API void (lua_getfenv) (lua_State *L, int idx); + + +/* +** set functions (stack -> Lua) +*/ +LUA_API void (lua_settable) (lua_State *L, int idx); +LUA_API void (lua_setfield) (lua_State *L, int idx, const char *k); +LUA_API void (lua_rawset) (lua_State *L, int idx); +LUA_API void (lua_rawseti) (lua_State *L, int idx, int n); +LUA_API int (lua_setmetatable) (lua_State *L, int objindex); +LUA_API int (lua_setfenv) (lua_State *L, int idx); + + +/* +** `load' and `call' functions (load and run Lua code) +*/ +LUA_API void (lua_call) (lua_State *L, int nargs, int nresults); +LUA_API int (lua_pcall) (lua_State *L, int nargs, int nresults, int errfunc); +LUA_API int (lua_cpcall) (lua_State *L, lua_CFunction func, void *ud); +LUA_API int (lua_load) (lua_State *L, lua_Reader reader, void *dt, + const char *chunkname); + +LUA_API int (lua_dump) (lua_State *L, lua_Writer writer, void *data); + + +/* +** coroutine functions +*/ +LUA_API int (lua_yield) (lua_State *L, int nresults); +LUA_API int (lua_resume) (lua_State *L, int narg); +LUA_API int (lua_status) (lua_State *L); + +/* +** garbage-collection function and options +*/ + +#define LUA_GCSTOP 0 +#define LUA_GCRESTART 1 +#define LUA_GCCOLLECT 2 +#define LUA_GCCOUNT 3 +#define LUA_GCCOUNTB 4 +#define LUA_GCSTEP 5 +#define LUA_GCSETPAUSE 6 +#define LUA_GCSETSTEPMUL 7 + +LUA_API int (lua_gc) (lua_State *L, int what, int data); + + +/* +** miscellaneous functions +*/ + +LUA_API int (lua_error) (lua_State *L); + +LUA_API int (lua_next) (lua_State *L, int idx); + +LUA_API void (lua_concat) (lua_State *L, int n); + +LUA_API lua_Alloc (lua_getallocf) (lua_State *L, void **ud); +LUA_API void lua_setallocf (lua_State *L, lua_Alloc f, void *ud); + + + +/* +** =============================================================== +** some useful macros +** =============================================================== +*/ + +#define lua_pop(L,n) lua_settop(L, -(n)-1) + +#define lua_newtable(L) lua_createtable(L, 0, 0) + +#define lua_register(L,n,f) (lua_pushcfunction(L, (f)), lua_setglobal(L, (n))) + +#define lua_pushcfunction(L,f) lua_pushcclosure(L, (f), 0) + +#define lua_strlen(L,i) lua_objlen(L, (i)) + +#define lua_isfunction(L,n) (lua_type(L, (n)) == LUA_TFUNCTION) +#define lua_istable(L,n) (lua_type(L, (n)) == LUA_TTABLE) +#define lua_islightuserdata(L,n) (lua_type(L, (n)) == LUA_TLIGHTUSERDATA) +#define lua_isnil(L,n) (lua_type(L, (n)) == LUA_TNIL) +#define lua_isboolean(L,n) (lua_type(L, (n)) == LUA_TBOOLEAN) +#define lua_isthread(L,n) (lua_type(L, (n)) == LUA_TTHREAD) +#define lua_isnone(L,n) (lua_type(L, (n)) == LUA_TNONE) +#define lua_isnoneornil(L, n) (lua_type(L, (n)) <= 0) + +#define lua_pushliteral(L, s) \ + lua_pushlstring(L, "" s, (sizeof(s)/sizeof(char))-1) + +#define lua_setglobal(L,s) lua_setfield(L, LUA_GLOBALSINDEX, (s)) +#define lua_getglobal(L,s) lua_getfield(L, LUA_GLOBALSINDEX, (s)) + +#define lua_tostring(L,i) lua_tolstring(L, (i), NULL) + + + +/* +** compatibility macros and functions +*/ + +#define lua_open() luaL_newstate() + +#define lua_getregistry(L) lua_pushvalue(L, LUA_REGISTRYINDEX) + +#define lua_getgccount(L) lua_gc(L, LUA_GCCOUNT, 0) + +#define lua_Chunkreader lua_Reader +#define lua_Chunkwriter lua_Writer + + +/* hack */ +LUA_API void lua_setlevel (lua_State *from, lua_State *to); + + +/* +** {====================================================================== +** Debug API +** ======================================================================= +*/ + + +/* +** Event codes +*/ +#define LUA_HOOKCALL 0 +#define LUA_HOOKRET 1 +#define LUA_HOOKLINE 2 +#define LUA_HOOKCOUNT 3 +#define LUA_HOOKTAILRET 4 + + +/* +** Event masks +*/ +#define LUA_MASKCALL (1 << LUA_HOOKCALL) +#define LUA_MASKRET (1 << LUA_HOOKRET) +#define LUA_MASKLINE (1 << LUA_HOOKLINE) +#define LUA_MASKCOUNT (1 << LUA_HOOKCOUNT) + +typedef struct lua_Debug lua_Debug; /* activation record */ + + +/* Functions to be called by the debuger in specific events */ +typedef void (*lua_Hook) (lua_State *L, lua_Debug *ar); + + +LUA_API int lua_getstack (lua_State *L, int level, lua_Debug *ar); +LUA_API int lua_getinfo (lua_State *L, const char *what, lua_Debug *ar); +LUA_API const char *lua_getlocal (lua_State *L, const lua_Debug *ar, int n); +LUA_API const char *lua_setlocal (lua_State *L, const lua_Debug *ar, int n); +LUA_API const char *lua_getupvalue (lua_State *L, int funcindex, int n); +LUA_API const char *lua_setupvalue (lua_State *L, int funcindex, int n); + +LUA_API int lua_sethook (lua_State *L, lua_Hook func, int mask, int count); +LUA_API lua_Hook lua_gethook (lua_State *L); +LUA_API int lua_gethookmask (lua_State *L); +LUA_API int lua_gethookcount (lua_State *L); + +#define _JZ_LUA_CODE +#ifdef _JZ_LUA_CODE +typedef struct __lua_const { + const char *name; + unsigned int size; + int vl; +}lua_const; + +LUA_API int lua_setconstlist(lua_State *L, lua_const *constlist); +#endif + +struct lua_Debug { + int event; + const char *name; /* (n) */ + const char *namewhat; /* (n) `global', `local', `field', `method' */ + const char *what; /* (S) `Lua', `C', `main', `tail' */ + const char *source; /* (S) */ + int currentline; /* (l) */ + int nups; /* (u) number of upvalues */ + int linedefined; /* (S) */ + int lastlinedefined; /* (S) */ + char short_src[LUA_IDSIZE]; /* (S) */ + /* private part */ + int i_ci; /* active function */ +}; + +/* }====================================================================== */ + + +/****************************************************************************** +* Copyright (C) 1994-2008 Lua.org, PUC-Rio. All rights reserved. +* +* Permission is hereby granted, free of charge, to any person obtaining +* a copy of this software and associated documentation files (the +* "Software"), to deal in the Software without restriction, including +* without limitation the rights to use, copy, modify, merge, publish, +* distribute, sublicense, and/or sell copies of the Software, and to +* permit persons to whom the Software is furnished to do so, subject to +* the following conditions: +* +* The above copyright notice and this permission notice shall be +* included in all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +******************************************************************************/ + + +#endif diff --git a/lua/luac.c b/lua/luac.c new file mode 100644 index 0000000..d070173 --- /dev/null +++ b/lua/luac.c @@ -0,0 +1,200 @@ +/* +** $Id: luac.c,v 1.54 2006/06/02 17:37:11 lhf Exp $ +** Lua compiler (saves bytecodes to files; also list bytecodes) +** See Copyright Notice in lua.h +*/ + +#include +#include +#include +#include + +#define luac_c +#define LUA_CORE + +#include "lua.h" +#include "lauxlib.h" + +#include "ldo.h" +#include "lfunc.h" +#include "lmem.h" +#include "lobject.h" +#include "lopcodes.h" +#include "lstring.h" +#include "lundump.h" + +#define PROGNAME "luac" /* default program name */ +#define OUTPUT PROGNAME ".out" /* default output file */ + +static int listing=0; /* list bytecodes? */ +static int dumping=1; /* dump bytecodes? */ +static int stripping=0; /* strip debug information? */ +static char Output[]={ OUTPUT }; /* default output file name */ +static const char* output=Output; /* actual output file name */ +static const char* progname=PROGNAME; /* actual program name */ + +static void fatal(const char* message) +{ + fprintf(stderr,"%s: %s\n",progname,message); + exit(EXIT_FAILURE); +} + +static void cannot(const char* what) +{ + fprintf(stderr,"%s: cannot %s %s: %s\n",progname,what,output,strerror(errno)); + exit(EXIT_FAILURE); +} + +static void usage(const char* message) +{ + if (*message=='-') + fprintf(stderr,"%s: unrecognized option " LUA_QS "\n",progname,message); + else + fprintf(stderr,"%s: %s\n",progname,message); + fprintf(stderr, + "usage: %s [options] [filenames].\n" + "Available options are:\n" + " - process stdin\n" + " -l list\n" + " -o name output to file " LUA_QL("name") " (default is \"%s\")\n" + " -p parse only\n" + " -s strip debug information\n" + " -v show version information\n" + " -- stop handling options\n", + progname,Output); + exit(EXIT_FAILURE); +} + +#define IS(s) (strcmp(argv[i],s)==0) + +static int doargs(int argc, char* argv[]) +{ + int i; + int version=0; + if (argv[0]!=NULL && *argv[0]!=0) progname=argv[0]; + for (i=1; itop+(i))->l.p) + +static const Proto* combine(lua_State* L, int n) +{ + if (n==1) + return toproto(L,-1); + else + { + int i,pc; + Proto* f=luaF_newproto(L); + setptvalue2s(L,L->top,f); incr_top(L); + f->source=luaS_newliteral(L,"=(" PROGNAME ")"); + f->maxstacksize=1; + pc=2*n+1; + f->code=luaM_newvector(L,pc,Instruction); + f->sizecode=pc; + f->p=luaM_newvector(L,n,Proto*); + f->sizep=n; + pc=0; + for (i=0; ip[i]=toproto(L,i-n-1); + f->code[pc++]=CREATE_ABx(OP_CLOSURE,0,i); + f->code[pc++]=CREATE_ABC(OP_CALL,0,1,1); + } + f->code[pc++]=CREATE_ABC(OP_RETURN,0,1,0); + return f; + } +} + +static int writer(lua_State* L, const void* p, size_t size, void* u) +{ + UNUSED(L); + return (fwrite(p,size,1,(FILE*)u)!=1) && (size!=0); +} + +struct Smain { + int argc; + char** argv; +}; + +static int pmain(lua_State* L) +{ + struct Smain* s = (struct Smain*)lua_touserdata(L, 1); + int argc=s->argc; + char** argv=s->argv; + const Proto* f; + int i; + if (!lua_checkstack(L,argc)) fatal("too many input files"); + for (i=0; i1); + if (dumping) + { + FILE* D= (output==NULL) ? stdout : fopen(output,"wb"); + if (D==NULL) cannot("open"); + lua_lock(L); + luaU_dump(L,f,writer,D,stripping); + lua_unlock(L); + if (ferror(D)) cannot("write"); + if (fclose(D)) cannot("close"); + } + return 0; +} + +int main(int argc, char* argv[]) +{ + lua_State* L; + struct Smain s; + int i=doargs(argc,argv); + argc-=i; argv+=i; + if (argc<=0) usage("no input files given"); + L=lua_open(); + if (L==NULL) fatal("not enough memory for state"); + s.argc=argc; + s.argv=argv; + if (lua_cpcall(L,pmain,&s)!=0) fatal(lua_tostring(L,-1)); + lua_close(L); + return EXIT_SUCCESS; +} diff --git a/lua/luaconf.h b/lua/luaconf.h new file mode 100644 index 0000000..e2cb261 --- /dev/null +++ b/lua/luaconf.h @@ -0,0 +1,763 @@ +/* +** $Id: luaconf.h,v 1.82.1.7 2008/02/11 16:25:08 roberto Exp $ +** Configuration file for Lua +** See Copyright Notice in lua.h +*/ + + +#ifndef lconfig_h +#define lconfig_h + +#include +#include + + +/* +** ================================================================== +** Search for "@@" to find all configurable definitions. +** =================================================================== +*/ + + +/* +@@ LUA_ANSI controls the use of non-ansi features. +** CHANGE it (define it) if you want Lua to avoid the use of any +** non-ansi feature or library. +*/ +#if defined(__STRICT_ANSI__) +#define LUA_ANSI +#endif + + +#if !defined(LUA_ANSI) && defined(_WIN32) +#define LUA_WIN +#endif + +#if defined(LUA_USE_LINUX) +#define LUA_USE_POSIX +#define LUA_USE_DLOPEN /* needs an extra library: -ldl */ +#define LUA_USE_READLINE /* needs some extra libraries */ +#endif + +#if defined(LUA_USE_MACOSX) +#define LUA_USE_POSIX +#define LUA_DL_DYLD /* does not need extra library */ +#endif + + + +/* +@@ LUA_USE_POSIX includes all functionallity listed as X/Open System +@* Interfaces Extension (XSI). +** CHANGE it (define it) if your system is XSI compatible. +*/ +#if defined(LUA_USE_POSIX) +#define LUA_USE_MKSTEMP +#define LUA_USE_ISATTY +#define LUA_USE_POPEN +#define LUA_USE_ULONGJMP +#endif + + +/* +@@ LUA_PATH and LUA_CPATH are the names of the environment variables that +@* Lua check to set its paths. +@@ LUA_INIT is the name of the environment variable that Lua +@* checks for initialization code. +** CHANGE them if you want different names. +*/ +#define LUA_PATH "LUA_PATH" +#define LUA_CPATH "LUA_CPATH" +#define LUA_INIT "LUA_INIT" + + +/* +@@ LUA_PATH_DEFAULT is the default path that Lua uses to look for +@* Lua libraries. +@@ LUA_CPATH_DEFAULT is the default path that Lua uses to look for +@* C libraries. +** CHANGE them if your machine has a non-conventional directory +** hierarchy or if you want to install your libraries in +** non-conventional directories. +*/ +#if defined(_WIN32) +/* +** In Windows, any exclamation mark ('!') in the path is replaced by the +** path of the directory of the executable file of the current process. +*/ +#define LUA_LDIR "!\\lua\\" +#define LUA_CDIR "!\\" +#define LUA_PATH_DEFAULT \ + ".\\?.lua;" LUA_LDIR"?.lua;" LUA_LDIR"?\\init.lua;" \ + LUA_CDIR"?.lua;" LUA_CDIR"?\\init.lua" +#define LUA_CPATH_DEFAULT \ + ".\\?.dll;" LUA_CDIR"?.dll;" LUA_CDIR"loadall.dll" + +#else +#define LUA_ROOT "/usr/local/" +#define LUA_LDIR LUA_ROOT "share/lua/5.1/" +#define LUA_CDIR LUA_ROOT "lib/lua/5.1/" +#define LUA_PATH_DEFAULT \ + "./?.lua;" LUA_LDIR"?.lua;" LUA_LDIR"?/init.lua;" \ + LUA_CDIR"?.lua;" LUA_CDIR"?/init.lua" +#define LUA_CPATH_DEFAULT \ + "./?.so;" LUA_CDIR"?.so;" LUA_CDIR"loadall.so" +#endif + + +/* +@@ LUA_DIRSEP is the directory separator (for submodules). +** CHANGE it if your machine does not use "/" as the directory separator +** and is not Windows. (On Windows Lua automatically uses "\".) +*/ +#if defined(_WIN32) +#define LUA_DIRSEP "\\" +#else +#define LUA_DIRSEP "/" +#endif + + +/* +@@ LUA_PATHSEP is the character that separates templates in a path. +@@ LUA_PATH_MARK is the string that marks the substitution points in a +@* template. +@@ LUA_EXECDIR in a Windows path is replaced by the executable's +@* directory. +@@ LUA_IGMARK is a mark to ignore all before it when bulding the +@* luaopen_ function name. +** CHANGE them if for some reason your system cannot use those +** characters. (E.g., if one of those characters is a common character +** in file/directory names.) Probably you do not need to change them. +*/ +#define LUA_PATHSEP ";" +#define LUA_PATH_MARK "?" +#define LUA_EXECDIR "!" +#define LUA_IGMARK "-" + + +/* +@@ LUA_INTEGER is the integral type used by lua_pushinteger/lua_tointeger. +** CHANGE that if ptrdiff_t is not adequate on your machine. (On most +** machines, ptrdiff_t gives a good choice between int or long.) +*/ +#define LUA_INTEGER ptrdiff_t + + +/* +@@ LUA_API is a mark for all core API functions. +@@ LUALIB_API is a mark for all standard library functions. +** CHANGE them if you need to define those functions in some special way. +** For instance, if you want to create one Windows DLL with the core and +** the libraries, you may want to use the following definition (define +** LUA_BUILD_AS_DLL to get it). +*/ +#if defined(LUA_BUILD_AS_DLL) + +#if defined(LUA_CORE) || defined(LUA_LIB) +#define LUA_API __declspec(dllexport) +#else +#define LUA_API __declspec(dllimport) +#endif + +#else + +#define LUA_API extern + +#endif + +/* more often than not the libs go together with the core */ +#define LUALIB_API LUA_API + + +/* +@@ LUAI_FUNC is a mark for all extern functions that are not to be +@* exported to outside modules. +@@ LUAI_DATA is a mark for all extern (const) variables that are not to +@* be exported to outside modules. +** CHANGE them if you need to mark them in some special way. Elf/gcc +** (versions 3.2 and later) mark them as "hidden" to optimize access +** when Lua is compiled as a shared library. +*/ +#if defined(luaall_c) +#define LUAI_FUNC static +#define LUAI_DATA /* empty */ + +#elif defined(__GNUC__) && ((__GNUC__*100 + __GNUC_MINOR__) >= 302) && \ + defined(__ELF__) +#define LUAI_FUNC __attribute__((visibility("hidden"))) extern +#define LUAI_DATA LUAI_FUNC + +#else +#define LUAI_FUNC extern +#define LUAI_DATA extern +#endif + + + +/* +@@ LUA_QL describes how error messages quote program elements. +** CHANGE it if you want a different appearance. +*/ +#define LUA_QL(x) "'" x "'" +#define LUA_QS LUA_QL("%s") + + +/* +@@ LUA_IDSIZE gives the maximum size for the description of the source +@* of a function in debug information. +** CHANGE it if you want a different size. +*/ +#define LUA_IDSIZE 60 + + +/* +** {================================================================== +** Stand-alone configuration +** =================================================================== +*/ + +#if defined(lua_c) || defined(luaall_c) + +/* +@@ lua_stdin_is_tty detects whether the standard input is a 'tty' (that +@* is, whether we're running lua interactively). +** CHANGE it if you have a better definition for non-POSIX/non-Windows +** systems. +*/ +#if defined(LUA_USE_ISATTY) +#include +#define lua_stdin_is_tty() isatty(0) +#elif defined(LUA_WIN) +#include +#include +#define lua_stdin_is_tty() _isatty(_fileno(stdin)) +#else +#define lua_stdin_is_tty() 1 /* assume stdin is a tty */ +#endif + + +/* +@@ LUA_PROMPT is the default prompt used by stand-alone Lua. +@@ LUA_PROMPT2 is the default continuation prompt used by stand-alone Lua. +** CHANGE them if you want different prompts. (You can also change the +** prompts dynamically, assigning to globals _PROMPT/_PROMPT2.) +*/ +#define LUA_PROMPT "> " +#define LUA_PROMPT2 ">> " + + +/* +@@ LUA_PROGNAME is the default name for the stand-alone Lua program. +** CHANGE it if your stand-alone interpreter has a different name and +** your system is not able to detect that name automatically. +*/ +#define LUA_PROGNAME "lua" + + +/* +@@ LUA_MAXINPUT is the maximum length for an input line in the +@* stand-alone interpreter. +** CHANGE it if you need longer lines. +*/ +#define LUA_MAXINPUT 512 + + +/* +@@ lua_readline defines how to show a prompt and then read a line from +@* the standard input. +@@ lua_saveline defines how to "save" a read line in a "history". +@@ lua_freeline defines how to free a line read by lua_readline. +** CHANGE them if you want to improve this functionality (e.g., by using +** GNU readline and history facilities). +*/ +#if defined(LUA_USE_READLINE) +#include +#include +#include +#define lua_readline(L,b,p) ((void)L, ((b)=readline(p)) != NULL) +#define lua_saveline(L,idx) \ + if (lua_strlen(L,idx) > 0) /* non-empty line? */ \ + add_history(lua_tostring(L, idx)); /* add it to history */ +#define lua_freeline(L,b) ((void)L, free(b)) +#else +#define lua_readline(L,b,p) \ + ((void)L, fputs(p, stdout), fflush(stdout), /* show prompt */ \ + fgets(b, LUA_MAXINPUT, stdin) != NULL) /* get line */ +#define lua_saveline(L,idx) { (void)L; (void)idx; } +#define lua_freeline(L,b) { (void)L; (void)b; } +#endif + +#endif + +/* }================================================================== */ + + +/* +@@ LUAI_GCPAUSE defines the default pause between garbage-collector cycles +@* as a percentage. +** CHANGE it if you want the GC to run faster or slower (higher values +** mean larger pauses which mean slower collection.) You can also change +** this value dynamically. +*/ +#define LUAI_GCPAUSE 200 /* 200% (wait memory to double before next GC) */ + + +/* +@@ LUAI_GCMUL defines the default speed of garbage collection relative to +@* memory allocation as a percentage. +** CHANGE it if you want to change the granularity of the garbage +** collection. (Higher values mean coarser collections. 0 represents +** infinity, where each step performs a full collection.) You can also +** change this value dynamically. +*/ +#define LUAI_GCMUL 200 /* GC runs 'twice the speed' of memory allocation */ + + + +/* +@@ LUA_COMPAT_GETN controls compatibility with old getn behavior. +** CHANGE it (define it) if you want exact compatibility with the +** behavior of setn/getn in Lua 5.0. +*/ +#undef LUA_COMPAT_GETN + +/* +@@ LUA_COMPAT_LOADLIB controls compatibility about global loadlib. +** CHANGE it to undefined as soon as you do not need a global 'loadlib' +** function (the function is still available as 'package.loadlib'). +*/ +#undef LUA_COMPAT_LOADLIB + +/* +@@ LUA_COMPAT_VARARG controls compatibility with old vararg feature. +** CHANGE it to undefined as soon as your programs use only '...' to +** access vararg parameters (instead of the old 'arg' table). +*/ +#define LUA_COMPAT_VARARG + +/* +@@ LUA_COMPAT_MOD controls compatibility with old math.mod function. +** CHANGE it to undefined as soon as your programs use 'math.fmod' or +** the new '%' operator instead of 'math.mod'. +*/ +#define LUA_COMPAT_MOD + +/* +@@ LUA_COMPAT_LSTR controls compatibility with old long string nesting +@* facility. +** CHANGE it to 2 if you want the old behaviour, or undefine it to turn +** off the advisory error when nesting [[...]]. +*/ +#define LUA_COMPAT_LSTR 1 + +/* +@@ LUA_COMPAT_GFIND controls compatibility with old 'string.gfind' name. +** CHANGE it to undefined as soon as you rename 'string.gfind' to +** 'string.gmatch'. +*/ +#define LUA_COMPAT_GFIND + +/* +@@ LUA_COMPAT_OPENLIB controls compatibility with old 'luaL_openlib' +@* behavior. +** CHANGE it to undefined as soon as you replace to 'luaL_register' +** your uses of 'luaL_openlib' +*/ +#define LUA_COMPAT_OPENLIB + + + +/* +@@ luai_apicheck is the assert macro used by the Lua-C API. +** CHANGE luai_apicheck if you want Lua to perform some checks in the +** parameters it gets from API calls. This may slow down the interpreter +** a bit, but may be quite useful when debugging C code that interfaces +** with Lua. A useful redefinition is to use assert.h. +*/ +#if defined(LUA_USE_APICHECK) +#include +#define luai_apicheck(L,o) { (void)L; assert(o); } +#else +#define luai_apicheck(L,o) { (void)L; } +#endif + + +/* +@@ LUAI_BITSINT defines the number of bits in an int. +** CHANGE here if Lua cannot automatically detect the number of bits of +** your machine. Probably you do not need to change this. +*/ +/* avoid overflows in comparison */ +#if INT_MAX-20 < 32760 +#define LUAI_BITSINT 16 +#elif INT_MAX > 2147483640L +/* int has at least 32 bits */ +#define LUAI_BITSINT 32 +#else +#error "you must define LUA_BITSINT with number of bits in an integer" +#endif + + +/* +@@ LUAI_UINT32 is an unsigned integer with at least 32 bits. +@@ LUAI_INT32 is an signed integer with at least 32 bits. +@@ LUAI_UMEM is an unsigned integer big enough to count the total +@* memory used by Lua. +@@ LUAI_MEM is a signed integer big enough to count the total memory +@* used by Lua. +** CHANGE here if for some weird reason the default definitions are not +** good enough for your machine. (The definitions in the 'else' +** part always works, but may waste space on machines with 64-bit +** longs.) Probably you do not need to change this. +*/ +#if LUAI_BITSINT >= 32 +#define LUAI_UINT32 unsigned int +#define LUAI_INT32 int +#define LUAI_MAXINT32 INT_MAX +#define LUAI_UMEM size_t +#define LUAI_MEM ptrdiff_t +#else +/* 16-bit ints */ +#define LUAI_UINT32 unsigned long +#define LUAI_INT32 long +#define LUAI_MAXINT32 LONG_MAX +#define LUAI_UMEM unsigned long +#define LUAI_MEM long +#endif + + +/* +@@ LUAI_MAXCALLS limits the number of nested calls. +** CHANGE it if you need really deep recursive calls. This limit is +** arbitrary; its only purpose is to stop infinite recursion before +** exhausting memory. +*/ +#define LUAI_MAXCALLS 20000 + + +/* +@@ LUAI_MAXCSTACK limits the number of Lua stack slots that a C function +@* can use. +** CHANGE it if you need lots of (Lua) stack space for your C +** functions. This limit is arbitrary; its only purpose is to stop C +** functions to consume unlimited stack space. (must be smaller than +** -LUA_REGISTRYINDEX) +*/ +#define LUAI_MAXCSTACK 8000 + + + +/* +** {================================================================== +** CHANGE (to smaller values) the following definitions if your system +** has a small C stack. (Or you may want to change them to larger +** values if your system has a large C stack and these limits are +** too rigid for you.) Some of these constants control the size of +** stack-allocated arrays used by the compiler or the interpreter, while +** others limit the maximum number of recursive calls that the compiler +** or the interpreter can perform. Values too large may cause a C stack +** overflow for some forms of deep constructs. +** =================================================================== +*/ + + +/* +@@ LUAI_MAXCCALLS is the maximum depth for nested C calls (short) and +@* syntactical nested non-terminals in a program. +*/ +#define LUAI_MAXCCALLS 200 + + +/* +@@ LUAI_MAXVARS is the maximum number of local variables per function +@* (must be smaller than 250). +*/ +#define LUAI_MAXVARS 200 + + +/* +@@ LUAI_MAXUPVALUES is the maximum number of upvalues per function +@* (must be smaller than 250). +*/ +#define LUAI_MAXUPVALUES 60 + + +/* +@@ LUAL_BUFFERSIZE is the buffer size used by the lauxlib buffer system. +*/ +#define LUAL_BUFFERSIZE BUFSIZ + +/* }================================================================== */ + + + + +/* +** {================================================================== +@@ LUA_NUMBER is the type of numbers in Lua. +** CHANGE the following definitions only if you want to build Lua +** with a number type different from double. You may also need to +** change lua_number2int & lua_number2integer. +** =================================================================== +*/ + +#define LUA_NUMBER_DOUBLE +#define LUA_NUMBER double + +/* +@@ LUAI_UACNUMBER is the result of an 'usual argument conversion' +@* over a number. +*/ +#define LUAI_UACNUMBER double + + +/* +@@ LUA_NUMBER_SCAN is the format for reading numbers. +@@ LUA_NUMBER_FMT is the format for writing numbers. +@@ lua_number2str converts a number to a string. +@@ LUAI_MAXNUMBER2STR is maximum size of previous conversion. +@@ lua_str2number converts a string to a number. +*/ +#define LUA_NUMBER_SCAN "%lf" +#define LUA_NUMBER_FMT "%.14g" +#define lua_number2str(s,n) sprintf((s), LUA_NUMBER_FMT, (n)) +#define LUAI_MAXNUMBER2STR 32 /* 16 digits, sign, point, and \0 */ +#define lua_str2number(s,p) strtod((s), (p)) + + +/* +@@ The luai_num* macros define the primitive operations over numbers. +*/ +#if defined(LUA_CORE) +#include +#define luai_numadd(a,b) ((a)+(b)) +#define luai_numsub(a,b) ((a)-(b)) +#define luai_nummul(a,b) ((a)*(b)) +#define luai_numdiv(a,b) ((a)/(b)) +#define luai_nummod(a,b) ((a) - floor((a)/(b))*(b)) +#define luai_numpow(a,b) (pow(a,b)) +#define luai_numunm(a) (-(a)) +#define luai_numeq(a,b) ((a)==(b)) +#define luai_numlt(a,b) ((a)<(b)) +#define luai_numle(a,b) ((a)<=(b)) +#define luai_numisnan(a) (!luai_numeq((a), (a))) +#endif + + +/* +@@ lua_number2int is a macro to convert lua_Number to int. +@@ lua_number2integer is a macro to convert lua_Number to lua_Integer. +** CHANGE them if you know a faster way to convert a lua_Number to +** int (with any rounding method and without throwing errors) in your +** system. In Pentium machines, a naive typecast from double to int +** in C is extremely slow, so any alternative is worth trying. +*/ + +/* On a Pentium, resort to a trick */ +#if defined(LUA_NUMBER_DOUBLE) && !defined(LUA_ANSI) && !defined(__SSE2__) && \ + (defined(__i386) || defined (_M_IX86) || defined(__i386__)) + +/* On a Microsoft compiler, use assembler */ +#if defined(_MSC_VER) + +#define lua_number2int(i,d) __asm fld d __asm fistp i +#define lua_number2integer(i,n) lua_number2int(i, n) + +/* the next trick should work on any Pentium, but sometimes clashes + with a DirectX idiosyncrasy */ +#else + +union luai_Cast { double l_d; long l_l; }; +#define lua_number2int(i,d) \ + { volatile union luai_Cast u; u.l_d = (d) + 6755399441055744.0; (i) = u.l_l; } +#define lua_number2integer(i,n) lua_number2int(i, n) + +#endif + + +/* this option always works, but may be slow */ +#else +#define lua_number2int(i,d) ((i)=(int)(d)) +#define lua_number2integer(i,d) ((i)=(lua_Integer)(d)) + +#endif + +/* }================================================================== */ + + +/* +@@ LUAI_USER_ALIGNMENT_T is a type that requires maximum alignment. +** CHANGE it if your system requires alignments larger than double. (For +** instance, if your system supports long doubles and they must be +** aligned in 16-byte boundaries, then you should add long double in the +** union.) Probably you do not need to change this. +*/ +#define LUAI_USER_ALIGNMENT_T union { double u; void *s; long l; } + + +/* +@@ LUAI_THROW/LUAI_TRY define how Lua does exception handling. +** CHANGE them if you prefer to use longjmp/setjmp even with C++ +** or if want/don't to use _longjmp/_setjmp instead of regular +** longjmp/setjmp. By default, Lua handles errors with exceptions when +** compiling as C++ code, with _longjmp/_setjmp when asked to use them, +** and with longjmp/setjmp otherwise. +*/ +#if defined(__cplusplus) +/* C++ exceptions */ +#define LUAI_THROW(L,c) throw(c) +#define LUAI_TRY(L,c,a) try { a } catch(...) \ + { if ((c)->status == 0) (c)->status = -1; } +#define luai_jmpbuf int /* dummy variable */ + +#elif defined(LUA_USE_ULONGJMP) +/* in Unix, try _longjmp/_setjmp (more efficient) */ +#define LUAI_THROW(L,c) _longjmp((c)->b, 1) +#define LUAI_TRY(L,c,a) if (_setjmp((c)->b) == 0) { a } +#define luai_jmpbuf jmp_buf + +#else +/* default handling with long jumps */ +#define LUAI_THROW(L,c) longjmp((c)->b, 1) +#define LUAI_TRY(L,c,a) if (setjmp((c)->b) == 0) { a } +#define luai_jmpbuf jmp_buf + +#endif + + +/* +@@ LUA_MAXCAPTURES is the maximum number of captures that a pattern +@* can do during pattern-matching. +** CHANGE it if you need more captures. This limit is arbitrary. +*/ +#define LUA_MAXCAPTURES 32 + + +/* +@@ lua_tmpnam is the function that the OS library uses to create a +@* temporary name. +@@ LUA_TMPNAMBUFSIZE is the maximum size of a name created by lua_tmpnam. +** CHANGE them if you have an alternative to tmpnam (which is considered +** insecure) or if you want the original tmpnam anyway. By default, Lua +** uses tmpnam except when POSIX is available, where it uses mkstemp. +*/ +#if defined(loslib_c) || defined(luaall_c) + +#if defined(LUA_USE_MKSTEMP) +#include +#define LUA_TMPNAMBUFSIZE 32 +#define lua_tmpnam(b,e) { \ + strcpy(b, "/tmp/lua_XXXXXX"); \ + e = mkstemp(b); \ + if (e != -1) close(e); \ + e = (e == -1); } + +#else +#define LUA_TMPNAMBUFSIZE L_tmpnam +#define lua_tmpnam(b,e) { e = (tmpnam(b) == NULL); } +#endif + +#endif + + +/* +@@ lua_popen spawns a new process connected to the current one through +@* the file streams. +** CHANGE it if you have a way to implement it in your system. +*/ +#if defined(LUA_USE_POPEN) + +#define lua_popen(L,c,m) ((void)L, fflush(NULL), popen(c,m)) +#define lua_pclose(L,file) ((void)L, (pclose(file) != -1)) + +#elif defined(LUA_WIN) + +#define lua_popen(L,c,m) ((void)L, _popen(c,m)) +#define lua_pclose(L,file) ((void)L, (_pclose(file) != -1)) + +#else + +#define lua_popen(L,c,m) ((void)((void)c, m), \ + luaL_error(L, LUA_QL("popen") " not supported"), (FILE*)0) +#define lua_pclose(L,file) ((void)((void)L, file), 0) + +#endif + +/* +@@ LUA_DL_* define which dynamic-library system Lua should use. +** CHANGE here if Lua has problems choosing the appropriate +** dynamic-library system for your platform (either Windows' DLL, Mac's +** dyld, or Unix's dlopen). If your system is some kind of Unix, there +** is a good chance that it has dlopen, so LUA_DL_DLOPEN will work for +** it. To use dlopen you also need to adapt the src/Makefile (probably +** adding -ldl to the linker options), so Lua does not select it +** automatically. (When you change the makefile to add -ldl, you must +** also add -DLUA_USE_DLOPEN.) +** If you do not want any kind of dynamic library, undefine all these +** options. +** By default, _WIN32 gets LUA_DL_DLL and MAC OS X gets LUA_DL_DYLD. +*/ +#if defined(LUA_USE_DLOPEN) +#define LUA_DL_DLOPEN +#endif + +#if defined(LUA_WIN) +#define LUA_DL_DLL +#endif + + +/* +@@ LUAI_EXTRASPACE allows you to add user-specific data in a lua_State +@* (the data goes just *before* the lua_State pointer). +** CHANGE (define) this if you really need that. This value must be +** a multiple of the maximum alignment required for your machine. +*/ +#define LUAI_EXTRASPACE 0 + + +/* +@@ luai_userstate* allow user-specific actions on threads. +** CHANGE them if you defined LUAI_EXTRASPACE and need to do something +** extra when a thread is created/deleted/resumed/yielded. +*/ +#define luai_userstateopen(L) ((void)L) +#define luai_userstateclose(L) ((void)L) +#define luai_userstatethread(L,L1) ((void)L) +#define luai_userstatefree(L) ((void)L) +#define luai_userstateresume(L,n) ((void)L) +#define luai_userstateyield(L,n) ((void)L) + + +/* +@@ LUA_INTFRMLEN is the length modifier for integer conversions +@* in 'string.format'. +@@ LUA_INTFRM_T is the integer type correspoding to the previous length +@* modifier. +** CHANGE them if your system supports long long or does not support long. +*/ + +#if defined(LUA_USELONGLONG) + +#define LUA_INTFRMLEN "ll" +#define LUA_INTFRM_T long long + +#else + +#define LUA_INTFRMLEN "l" +#define LUA_INTFRM_T long + +#endif + + + +/* =================================================================== */ + +/* +** Local configuration. You can use this space to add your redefinitions +** without modifying the main part of the file. +*/ + + + +#endif + diff --git a/lua/lualib.h b/lua/lualib.h new file mode 100644 index 0000000..469417f --- /dev/null +++ b/lua/lualib.h @@ -0,0 +1,53 @@ +/* +** $Id: lualib.h,v 1.36.1.1 2007/12/27 13:02:25 roberto Exp $ +** Lua standard libraries +** See Copyright Notice in lua.h +*/ + + +#ifndef lualib_h +#define lualib_h + +#include "lua.h" + + +/* Key to file-handle type */ +#define LUA_FILEHANDLE "FILE*" + + +#define LUA_COLIBNAME "coroutine" +LUALIB_API int (luaopen_base) (lua_State *L); + +#define LUA_TABLIBNAME "table" +LUALIB_API int (luaopen_table) (lua_State *L); + +#define LUA_IOLIBNAME "io" +LUALIB_API int (luaopen_io) (lua_State *L); + +#define LUA_OSLIBNAME "os" +LUALIB_API int (luaopen_os) (lua_State *L); + +#define LUA_STRLIBNAME "string" +LUALIB_API int (luaopen_string) (lua_State *L); + +#define LUA_MATHLIBNAME "math" +LUALIB_API int (luaopen_math) (lua_State *L); + +#define LUA_DBLIBNAME "debug" +LUALIB_API int (luaopen_debug) (lua_State *L); + +#define LUA_LOADLIBNAME "package" +LUALIB_API int (luaopen_package) (lua_State *L); + + +/* open all previous libraries */ +LUALIB_API void (luaL_openlibs) (lua_State *L); + + + +#ifndef lua_assert +#define lua_assert(x) ((void)0) +#endif + + +#endif diff --git a/lua/lundump.c b/lua/lundump.c new file mode 100644 index 0000000..8010a45 --- /dev/null +++ b/lua/lundump.c @@ -0,0 +1,227 @@ +/* +** $Id: lundump.c,v 2.7.1.4 2008/04/04 19:51:41 roberto Exp $ +** load precompiled Lua chunks +** See Copyright Notice in lua.h +*/ + +#include + +#define lundump_c +#define LUA_CORE + +#include "lua.h" + +#include "ldebug.h" +#include "ldo.h" +#include "lfunc.h" +#include "lmem.h" +#include "lobject.h" +#include "lstring.h" +#include "lundump.h" +#include "lzio.h" + +typedef struct { + lua_State* L; + ZIO* Z; + Mbuffer* b; + const char* name; +} LoadState; + +#ifdef LUAC_TRUST_BINARIES +#define IF(c,s) +#define error(S,s) +#else +#define IF(c,s) if (c) error(S,s) + +static void error(LoadState* S, const char* why) +{ + luaO_pushfstring(S->L,"%s: %s in precompiled chunk",S->name,why); + luaD_throw(S->L,LUA_ERRSYNTAX); +} +#endif + +#define LoadMem(S,b,n,size) LoadBlock(S,b,(n)*(size)) +#define LoadByte(S) (lu_byte)LoadChar(S) +#define LoadVar(S,x) LoadMem(S,&x,1,sizeof(x)) +#define LoadVector(S,b,n,size) LoadMem(S,b,n,size) + +static void LoadBlock(LoadState* S, void* b, size_t size) +{ + size_t r=luaZ_read(S->Z,b,size); + IF (r!=0, "unexpected end"); +} + +static int LoadChar(LoadState* S) +{ + char x; + LoadVar(S,x); + return x; +} + +static int LoadInt(LoadState* S) +{ + int x; + LoadVar(S,x); + IF (x<0, "bad integer"); + return x; +} + +static lua_Number LoadNumber(LoadState* S) +{ + lua_Number x; + LoadVar(S,x); + return x; +} + +static TString* LoadString(LoadState* S) +{ + size_t size; + LoadVar(S,size); + if (size==0) + return NULL; + else + { + char* s=luaZ_openspace(S->L,S->b,size); + LoadBlock(S,s,size); + return luaS_newlstr(S->L,s,size-1); /* remove trailing '\0' */ + } +} + +static void LoadCode(LoadState* S, Proto* f) +{ + int n=LoadInt(S); + f->code=luaM_newvector(S->L,n,Instruction); + f->sizecode=n; + LoadVector(S,f->code,n,sizeof(Instruction)); +} + +static Proto* LoadFunction(LoadState* S, TString* p); + +static void LoadConstants(LoadState* S, Proto* f) +{ + int i,n; + n=LoadInt(S); + f->k=luaM_newvector(S->L,n,TValue); + f->sizek=n; + for (i=0; ik[i]); + for (i=0; ik[i]; + int t=LoadChar(S); + switch (t) + { + case LUA_TNIL: + setnilvalue(o); + break; + case LUA_TBOOLEAN: + setbvalue(o,LoadChar(S)!=0); + break; + case LUA_TNUMBER: + setnvalue(o,LoadNumber(S)); + break; + case LUA_TSTRING: + setsvalue2n(S->L,o,LoadString(S)); + break; + default: + error(S,"bad constant"); + break; + } + } + n=LoadInt(S); + f->p=luaM_newvector(S->L,n,Proto*); + f->sizep=n; + for (i=0; ip[i]=NULL; + for (i=0; ip[i]=LoadFunction(S,f->source); +} + +static void LoadDebug(LoadState* S, Proto* f) +{ + int i,n; + n=LoadInt(S); + f->lineinfo=luaM_newvector(S->L,n,int); + f->sizelineinfo=n; + LoadVector(S,f->lineinfo,n,sizeof(int)); + n=LoadInt(S); + f->locvars=luaM_newvector(S->L,n,LocVar); + f->sizelocvars=n; + for (i=0; ilocvars[i].varname=NULL; + for (i=0; ilocvars[i].varname=LoadString(S); + f->locvars[i].startpc=LoadInt(S); + f->locvars[i].endpc=LoadInt(S); + } + n=LoadInt(S); + f->upvalues=luaM_newvector(S->L,n,TString*); + f->sizeupvalues=n; + for (i=0; iupvalues[i]=NULL; + for (i=0; iupvalues[i]=LoadString(S); +} + +static Proto* LoadFunction(LoadState* S, TString* p) +{ + Proto* f; + if (++S->L->nCcalls > LUAI_MAXCCALLS) error(S,"code too deep"); + f=luaF_newproto(S->L); + setptvalue2s(S->L,S->L->top,f); incr_top(S->L); + f->source=LoadString(S); if (f->source==NULL) f->source=p; + f->linedefined=LoadInt(S); + f->lastlinedefined=LoadInt(S); + f->nups=LoadByte(S); + f->numparams=LoadByte(S); + f->is_vararg=LoadByte(S); + f->maxstacksize=LoadByte(S); + LoadCode(S,f); + LoadConstants(S,f); + LoadDebug(S,f); + IF (!luaG_checkcode(f), "bad code"); + S->L->top--; + S->L->nCcalls--; + return f; +} + +static void LoadHeader(LoadState* S) +{ + char h[LUAC_HEADERSIZE]; + char s[LUAC_HEADERSIZE]; + luaU_header(h); + LoadBlock(S,s,LUAC_HEADERSIZE); + IF (memcmp(h,s,LUAC_HEADERSIZE)!=0, "bad header"); +} + +/* +** load precompiled chunk +*/ +Proto* luaU_undump (lua_State* L, ZIO* Z, Mbuffer* buff, const char* name) +{ + LoadState S; + if (*name=='@' || *name=='=') + S.name=name+1; + else if (*name==LUA_SIGNATURE[0]) + S.name="binary string"; + else + S.name=name; + S.L=L; + S.Z=Z; + S.b=buff; + LoadHeader(&S); + return LoadFunction(&S,luaS_newliteral(L,"=?")); +} + +/* +* make header +*/ +void luaU_header (char* h) +{ + int x=1; + memcpy(h,LUA_SIGNATURE,sizeof(LUA_SIGNATURE)-1); + h+=sizeof(LUA_SIGNATURE)-1; + *h++=(char)LUAC_VERSION; + *h++=(char)LUAC_FORMAT; + *h++=(char)*(char*)&x; /* endianness */ + *h++=(char)sizeof(int); + *h++=(char)sizeof(size_t); + *h++=(char)sizeof(Instruction); + *h++=(char)sizeof(lua_Number); + *h++=(char)(((lua_Number)0.5)==0); /* is lua_Number integral? */ +} diff --git a/lua/lundump.h b/lua/lundump.h new file mode 100644 index 0000000..c80189d --- /dev/null +++ b/lua/lundump.h @@ -0,0 +1,36 @@ +/* +** $Id: lundump.h,v 1.37.1.1 2007/12/27 13:02:25 roberto Exp $ +** load precompiled Lua chunks +** See Copyright Notice in lua.h +*/ + +#ifndef lundump_h +#define lundump_h + +#include "lobject.h" +#include "lzio.h" + +/* load one chunk; from lundump.c */ +LUAI_FUNC Proto* luaU_undump (lua_State* L, ZIO* Z, Mbuffer* buff, const char* name); + +/* make header; from lundump.c */ +LUAI_FUNC void luaU_header (char* h); + +/* dump one chunk; from ldump.c */ +LUAI_FUNC int luaU_dump (lua_State* L, const Proto* f, lua_Writer w, void* data, int strip); + +#ifdef luac_c +/* print one chunk; from print.c */ +LUAI_FUNC void luaU_print (const Proto* f, int full); +#endif + +/* for header of binary files -- this is Lua 5.1 */ +#define LUAC_VERSION 0x51 + +/* for header of binary files -- this is the official format */ +#define LUAC_FORMAT 0 + +/* size of header of binary files */ +#define LUAC_HEADERSIZE 12 + +#endif diff --git a/lua/lvm.c b/lua/lvm.c new file mode 100644 index 0000000..ee3256a --- /dev/null +++ b/lua/lvm.c @@ -0,0 +1,763 @@ +/* +** $Id: lvm.c,v 2.63.1.3 2007/12/28 15:32:23 roberto Exp $ +** Lua virtual machine +** See Copyright Notice in lua.h +*/ + + +#include +#include +#include + +#define lvm_c +#define LUA_CORE + +#include "lua.h" + +#include "ldebug.h" +#include "ldo.h" +#include "lfunc.h" +#include "lgc.h" +#include "lobject.h" +#include "lopcodes.h" +#include "lstate.h" +#include "lstring.h" +#include "ltable.h" +#include "ltm.h" +#include "lvm.h" + + + +/* limit for table tag-method chains (to avoid loops) */ +#define MAXTAGLOOP 100 + + +const TValue *luaV_tonumber (const TValue *obj, TValue *n) { + lua_Number num; + if (ttisnumber(obj)) return obj; + if (ttisstring(obj) && luaO_str2d(svalue(obj), &num)) { + setnvalue(n, num); + return n; + } + else + return NULL; +} + + +int luaV_tostring (lua_State *L, StkId obj) { + if (!ttisnumber(obj)) + return 0; + else { + char s[LUAI_MAXNUMBER2STR]; + lua_Number n = nvalue(obj); + lua_number2str(s, n); + setsvalue2s(L, obj, luaS_new(L, s)); + return 1; + } +} + + +static void traceexec (lua_State *L, const Instruction *pc) { + lu_byte mask = L->hookmask; + const Instruction *oldpc = L->savedpc; + L->savedpc = pc; + if ((mask & LUA_MASKCOUNT) && L->hookcount == 0) { + resethookcount(L); + luaD_callhook(L, LUA_HOOKCOUNT, -1); + } + if (mask & LUA_MASKLINE) { + Proto *p = ci_func(L->ci)->l.p; + int npc = pcRel(pc, p); + int newline = getline(p, npc); + /* call linehook when enter a new function, when jump back (loop), + or when enter a new line */ + if (npc == 0 || pc <= oldpc || newline != getline(p, pcRel(oldpc, p))) + luaD_callhook(L, LUA_HOOKLINE, newline); + } +} + + +static void callTMres (lua_State *L, StkId res, const TValue *f, + const TValue *p1, const TValue *p2) { + ptrdiff_t result = savestack(L, res); + setobj2s(L, L->top, f); /* push function */ + setobj2s(L, L->top+1, p1); /* 1st argument */ + setobj2s(L, L->top+2, p2); /* 2nd argument */ + luaD_checkstack(L, 3); + L->top += 3; + luaD_call(L, L->top - 3, 1); + res = restorestack(L, result); + L->top--; + setobjs2s(L, res, L->top); +} + + + +static void callTM (lua_State *L, const TValue *f, const TValue *p1, + const TValue *p2, const TValue *p3) { + setobj2s(L, L->top, f); /* push function */ + setobj2s(L, L->top+1, p1); /* 1st argument */ + setobj2s(L, L->top+2, p2); /* 2nd argument */ + setobj2s(L, L->top+3, p3); /* 3th argument */ + luaD_checkstack(L, 4); + L->top += 4; + luaD_call(L, L->top - 4, 0); +} + + +void luaV_gettable (lua_State *L, const TValue *t, TValue *key, StkId val) { + int loop; + for (loop = 0; loop < MAXTAGLOOP; loop++) { + const TValue *tm; + if (ttistable(t)) { /* `t' is a table? */ + Table *h = hvalue(t); + const TValue *res = luaH_get(h, key); /* do a primitive get */ + if (!ttisnil(res) || /* result is no nil? */ + (tm = fasttm(L, h->metatable, TM_INDEX)) == NULL) { /* or no TM? */ + setobj2s(L, val, res); + return; + } + /* else will try the tag method */ + } + else if (ttisnil(tm = luaT_gettmbyobj(L, t, TM_INDEX))) + luaG_typeerror(L, t, "index"); + if (ttisfunction(tm)) { + callTMres(L, val, tm, t, key); + return; + } + t = tm; /* else repeat with `tm' */ + } + luaG_runerror(L, "loop in gettable"); +} + + +void luaV_settable (lua_State *L, const TValue *t, TValue *key, StkId val) { + int loop; + for (loop = 0; loop < MAXTAGLOOP; loop++) { + const TValue *tm; + if (ttistable(t)) { /* `t' is a table? */ + Table *h = hvalue(t); + TValue *oldval = luaH_set(L, h, key); /* do a primitive set */ + if (!ttisnil(oldval) || /* result is no nil? */ + (tm = fasttm(L, h->metatable, TM_NEWINDEX)) == NULL) { /* or no TM? */ + setobj2t(L, oldval, val); + luaC_barriert(L, h, val); + return; + } + /* else will try the tag method */ + } + else if (ttisnil(tm = luaT_gettmbyobj(L, t, TM_NEWINDEX))) + luaG_typeerror(L, t, "index"); + if (ttisfunction(tm)) { + callTM(L, tm, t, key, val); + return; + } + t = tm; /* else repeat with `tm' */ + } + luaG_runerror(L, "loop in settable"); +} + + +static int call_binTM (lua_State *L, const TValue *p1, const TValue *p2, + StkId res, TMS event) { + const TValue *tm = luaT_gettmbyobj(L, p1, event); /* try first operand */ + if (ttisnil(tm)) + tm = luaT_gettmbyobj(L, p2, event); /* try second operand */ + if (ttisnil(tm)) return 0; + callTMres(L, res, tm, p1, p2); + return 1; +} + + +static const TValue *get_compTM (lua_State *L, Table *mt1, Table *mt2, + TMS event) { + const TValue *tm1 = fasttm(L, mt1, event); + const TValue *tm2; + if (tm1 == NULL) return NULL; /* no metamethod */ + if (mt1 == mt2) return tm1; /* same metatables => same metamethods */ + tm2 = fasttm(L, mt2, event); + if (tm2 == NULL) return NULL; /* no metamethod */ + if (luaO_rawequalObj(tm1, tm2)) /* same metamethods? */ + return tm1; + return NULL; +} + + +static int call_orderTM (lua_State *L, const TValue *p1, const TValue *p2, + TMS event) { + const TValue *tm1 = luaT_gettmbyobj(L, p1, event); + const TValue *tm2; + if (ttisnil(tm1)) return -1; /* no metamethod? */ + tm2 = luaT_gettmbyobj(L, p2, event); + if (!luaO_rawequalObj(tm1, tm2)) /* different metamethods? */ + return -1; + callTMres(L, L->top, tm1, p1, p2); + return !l_isfalse(L->top); +} + + +static int l_strcmp (const TString *ls, const TString *rs) { + const char *l = getstr(ls); + size_t ll = ls->tsv.len; + const char *r = getstr(rs); + size_t lr = rs->tsv.len; + for (;;) { + int temp = strcoll(l, r); + if (temp != 0) return temp; + else { /* strings are equal up to a `\0' */ + size_t len = strlen(l); /* index of first `\0' in both strings */ + if (len == lr) /* r is finished? */ + return (len == ll) ? 0 : 1; + else if (len == ll) /* l is finished? */ + return -1; /* l is smaller than r (because r is not finished) */ + /* both strings longer than `len'; go on comparing (after the `\0') */ + len++; + l += len; ll -= len; r += len; lr -= len; + } + } +} + + +int luaV_lessthan (lua_State *L, const TValue *l, const TValue *r) { + int res; + if (ttype(l) != ttype(r)) + return luaG_ordererror(L, l, r); + else if (ttisnumber(l)) + return luai_numlt(nvalue(l), nvalue(r)); + else if (ttisstring(l)) + return l_strcmp(rawtsvalue(l), rawtsvalue(r)) < 0; + else if ((res = call_orderTM(L, l, r, TM_LT)) != -1) + return res; + return luaG_ordererror(L, l, r); +} + + +static int lessequal (lua_State *L, const TValue *l, const TValue *r) { + int res; + if (ttype(l) != ttype(r)) + return luaG_ordererror(L, l, r); + else if (ttisnumber(l)) + return luai_numle(nvalue(l), nvalue(r)); + else if (ttisstring(l)) + return l_strcmp(rawtsvalue(l), rawtsvalue(r)) <= 0; + else if ((res = call_orderTM(L, l, r, TM_LE)) != -1) /* first try `le' */ + return res; + else if ((res = call_orderTM(L, r, l, TM_LT)) != -1) /* else try `lt' */ + return !res; + return luaG_ordererror(L, l, r); +} + + +int luaV_equalval (lua_State *L, const TValue *t1, const TValue *t2) { + const TValue *tm; + lua_assert(ttype(t1) == ttype(t2)); + switch (ttype(t1)) { + case LUA_TNIL: return 1; + case LUA_TNUMBER: return luai_numeq(nvalue(t1), nvalue(t2)); + case LUA_TBOOLEAN: return bvalue(t1) == bvalue(t2); /* true must be 1 !! */ + case LUA_TLIGHTUSERDATA: return pvalue(t1) == pvalue(t2); + case LUA_TUSERDATA: { + if (uvalue(t1) == uvalue(t2)) return 1; + tm = get_compTM(L, uvalue(t1)->metatable, uvalue(t2)->metatable, + TM_EQ); + break; /* will try TM */ + } + case LUA_TTABLE: { + if (hvalue(t1) == hvalue(t2)) return 1; + tm = get_compTM(L, hvalue(t1)->metatable, hvalue(t2)->metatable, TM_EQ); + break; /* will try TM */ + } + default: return gcvalue(t1) == gcvalue(t2); + } + if (tm == NULL) return 0; /* no TM? */ + callTMres(L, L->top, tm, t1, t2); /* call TM */ + return !l_isfalse(L->top); +} + + +void luaV_concat (lua_State *L, int total, int last) { + do { + StkId top = L->base + last + 1; + int n = 2; /* number of elements handled in this pass (at least 2) */ + if (!(ttisstring(top-2) || ttisnumber(top-2)) || !tostring(L, top-1)) { + if (!call_binTM(L, top-2, top-1, top-2, TM_CONCAT)) + luaG_concaterror(L, top-2, top-1); + } else if (tsvalue(top-1)->len == 0) /* second op is empty? */ + (void)tostring(L, top - 2); /* result is first op (as string) */ + else { + /* at least two string values; get as many as possible */ + size_t tl = tsvalue(top-1)->len; + char *buffer; + int i; + /* collect total length */ + for (n = 1; n < total && tostring(L, top-n-1); n++) { + size_t l = tsvalue(top-n-1)->len; + if (l >= MAX_SIZET - tl) luaG_runerror(L, "string length overflow"); + tl += l; + } + buffer = luaZ_openspace(L, &G(L)->buff, tl); + tl = 0; + for (i=n; i>0; i--) { /* concat all strings */ + size_t l = tsvalue(top-i)->len; + memcpy(buffer+tl, svalue(top-i), l); + tl += l; + } + setsvalue2s(L, top-n, luaS_newlstr(L, buffer, tl)); + } + total -= n-1; /* got `n' strings to create 1 new */ + last -= n-1; + } while (total > 1); /* repeat until only 1 result left */ +} + + +static void Arith (lua_State *L, StkId ra, const TValue *rb, + const TValue *rc, TMS op) { + TValue tempb, tempc; + const TValue *b, *c; + if ((b = luaV_tonumber(rb, &tempb)) != NULL && + (c = luaV_tonumber(rc, &tempc)) != NULL) { + lua_Number nb = nvalue(b), nc = nvalue(c); + switch (op) { + case TM_ADD: setnvalue(ra, luai_numadd(nb, nc)); break; + case TM_SUB: setnvalue(ra, luai_numsub(nb, nc)); break; + case TM_MUL: setnvalue(ra, luai_nummul(nb, nc)); break; + case TM_DIV: setnvalue(ra, luai_numdiv(nb, nc)); break; + case TM_MOD: setnvalue(ra, luai_nummod(nb, nc)); break; + case TM_POW: setnvalue(ra, luai_numpow(nb, nc)); break; + case TM_UNM: setnvalue(ra, luai_numunm(nb)); break; + default: lua_assert(0); break; + } + } + else if (!call_binTM(L, rb, rc, ra, op)) + luaG_aritherror(L, rb, rc); +} + + + +/* +** some macros for common tasks in `luaV_execute' +*/ + +#define runtime_check(L, c) { if (!(c)) break; } + +#define RA(i) (base+GETARG_A(i)) +/* to be used after possible stack reallocation */ +#define RB(i) check_exp(getBMode(GET_OPCODE(i)) == OpArgR, base+GETARG_B(i)) +#define RC(i) check_exp(getCMode(GET_OPCODE(i)) == OpArgR, base+GETARG_C(i)) +#define RKB(i) check_exp(getBMode(GET_OPCODE(i)) == OpArgK, \ + ISK(GETARG_B(i)) ? k+INDEXK(GETARG_B(i)) : base+GETARG_B(i)) +#define RKC(i) check_exp(getCMode(GET_OPCODE(i)) == OpArgK, \ + ISK(GETARG_C(i)) ? k+INDEXK(GETARG_C(i)) : base+GETARG_C(i)) +#define KBx(i) check_exp(getBMode(GET_OPCODE(i)) == OpArgK, k+GETARG_Bx(i)) + + +#define dojump(L,pc,i) {(pc) += (i); luai_threadyield(L);} + + +#define Protect(x) { L->savedpc = pc; {x;}; base = L->base; } + + +#define arith_op(op,tm) { \ + TValue *rb = RKB(i); \ + TValue *rc = RKC(i); \ + if (ttisnumber(rb) && ttisnumber(rc)) { \ + lua_Number nb = nvalue(rb), nc = nvalue(rc); \ + setnvalue(ra, op(nb, nc)); \ + } \ + else \ + Protect(Arith(L, ra, rb, rc, tm)); \ + } + + + +void luaV_execute (lua_State *L, int nexeccalls) { + LClosure *cl; + StkId base; + TValue *k; + const Instruction *pc; + reentry: /* entry point */ + lua_assert(isLua(L->ci)); + pc = L->savedpc; + cl = &clvalue(L->ci->func)->l; + base = L->base; + k = cl->p->k; + /* main loop of interpreter */ + for (;;) { + const Instruction i = *pc++; + StkId ra; + if ((L->hookmask & (LUA_MASKLINE | LUA_MASKCOUNT)) && + (--L->hookcount == 0 || L->hookmask & LUA_MASKLINE)) { + traceexec(L, pc); + if (L->status == LUA_YIELD) { /* did hook yield? */ + L->savedpc = pc - 1; + return; + } + base = L->base; + } + /* warning!! several calls may realloc the stack and invalidate `ra' */ + ra = RA(i); + lua_assert(base == L->base && L->base == L->ci->base); + lua_assert(base <= L->top && L->top <= L->stack + L->stacksize); + lua_assert(L->top == L->ci->top || luaG_checkopenop(i)); + switch (GET_OPCODE(i)) { + case OP_MOVE: { + setobjs2s(L, ra, RB(i)); + continue; + } + case OP_LOADK: { + setobj2s(L, ra, KBx(i)); + continue; + } + case OP_LOADBOOL: { + setbvalue(ra, GETARG_B(i)); + if (GETARG_C(i)) pc++; /* skip next instruction (if C) */ + continue; + } + case OP_LOADNIL: { + TValue *rb = RB(i); + do { + setnilvalue(rb--); + } while (rb >= ra); + continue; + } + case OP_GETUPVAL: { + int b = GETARG_B(i); + setobj2s(L, ra, cl->upvals[b]->v); + continue; + } + case OP_GETGLOBAL: { + TValue g; + TValue *rb = KBx(i); + sethvalue(L, &g, cl->env); + lua_assert(ttisstring(rb)); + Protect(luaV_gettable(L, &g, rb, ra)); + continue; + } + case OP_GETTABLE: { + Protect(luaV_gettable(L, RB(i), RKC(i), ra)); + continue; + } + case OP_SETGLOBAL: { + TValue g; + sethvalue(L, &g, cl->env); + lua_assert(ttisstring(KBx(i))); + Protect(luaV_settable(L, &g, KBx(i), ra)); + continue; + } + case OP_SETUPVAL: { + UpVal *uv = cl->upvals[GETARG_B(i)]; + setobj(L, uv->v, ra); + luaC_barrier(L, uv, ra); + continue; + } + case OP_SETTABLE: { + Protect(luaV_settable(L, ra, RKB(i), RKC(i))); + continue; + } + case OP_NEWTABLE: { + int b = GETARG_B(i); + int c = GETARG_C(i); + sethvalue(L, ra, luaH_new(L, luaO_fb2int(b), luaO_fb2int(c))); + Protect(luaC_checkGC(L)); + continue; + } + case OP_SELF: { + StkId rb = RB(i); + setobjs2s(L, ra+1, rb); + Protect(luaV_gettable(L, rb, RKC(i), ra)); + continue; + } + case OP_ADD: { + arith_op(luai_numadd, TM_ADD); + continue; + } + case OP_SUB: { + arith_op(luai_numsub, TM_SUB); + continue; + } + case OP_MUL: { + arith_op(luai_nummul, TM_MUL); + continue; + } + case OP_DIV: { + arith_op(luai_numdiv, TM_DIV); + continue; + } + case OP_MOD: { + arith_op(luai_nummod, TM_MOD); + continue; + } + case OP_POW: { + arith_op(luai_numpow, TM_POW); + continue; + } + case OP_UNM: { + TValue *rb = RB(i); + if (ttisnumber(rb)) { + lua_Number nb = nvalue(rb); + setnvalue(ra, luai_numunm(nb)); + } + else { + Protect(Arith(L, ra, rb, rb, TM_UNM)); + } + continue; + } + case OP_NOT: { + int res = l_isfalse(RB(i)); /* next assignment may change this value */ + setbvalue(ra, res); + continue; + } + case OP_LEN: { + const TValue *rb = RB(i); + switch (ttype(rb)) { + case LUA_TTABLE: { + setnvalue(ra, cast_num(luaH_getn(hvalue(rb)))); + break; + } + case LUA_TSTRING: { + setnvalue(ra, cast_num(tsvalue(rb)->len)); + break; + } + default: { /* try metamethod */ + Protect( + if (!call_binTM(L, rb, luaO_nilobject, ra, TM_LEN)) + luaG_typeerror(L, rb, "get length of"); + ) + } + } + continue; + } + case OP_CONCAT: { + int b = GETARG_B(i); + int c = GETARG_C(i); + Protect(luaV_concat(L, c-b+1, c); luaC_checkGC(L)); + setobjs2s(L, RA(i), base+b); + continue; + } + case OP_JMP: { + dojump(L, pc, GETARG_sBx(i)); + continue; + } + case OP_EQ: { + TValue *rb = RKB(i); + TValue *rc = RKC(i); + Protect( + if (equalobj(L, rb, rc) == GETARG_A(i)) + dojump(L, pc, GETARG_sBx(*pc)); + ) + pc++; + continue; + } + case OP_LT: { + Protect( + if (luaV_lessthan(L, RKB(i), RKC(i)) == GETARG_A(i)) + dojump(L, pc, GETARG_sBx(*pc)); + ) + pc++; + continue; + } + case OP_LE: { + Protect( + if (lessequal(L, RKB(i), RKC(i)) == GETARG_A(i)) + dojump(L, pc, GETARG_sBx(*pc)); + ) + pc++; + continue; + } + case OP_TEST: { + if (l_isfalse(ra) != GETARG_C(i)) + dojump(L, pc, GETARG_sBx(*pc)); + pc++; + continue; + } + case OP_TESTSET: { + TValue *rb = RB(i); + if (l_isfalse(rb) != GETARG_C(i)) { + setobjs2s(L, ra, rb); + dojump(L, pc, GETARG_sBx(*pc)); + } + pc++; + continue; + } + case OP_CALL: { + int b = GETARG_B(i); + int nresults = GETARG_C(i) - 1; + if (b != 0) L->top = ra+b; /* else previous instruction set top */ + L->savedpc = pc; + switch (luaD_precall(L, ra, nresults)) { + case PCRLUA: { + nexeccalls++; + goto reentry; /* restart luaV_execute over new Lua function */ + } + case PCRC: { + /* it was a C function (`precall' called it); adjust results */ + if (nresults >= 0) L->top = L->ci->top; + base = L->base; + continue; + } + default: { + return; /* yield */ + } + } + } + case OP_TAILCALL: { + int b = GETARG_B(i); + if (b != 0) L->top = ra+b; /* else previous instruction set top */ + L->savedpc = pc; + lua_assert(GETARG_C(i) - 1 == LUA_MULTRET); + switch (luaD_precall(L, ra, LUA_MULTRET)) { + case PCRLUA: { + /* tail call: put new frame in place of previous one */ + CallInfo *ci = L->ci - 1; /* previous frame */ + int aux; + StkId func = ci->func; + StkId pfunc = (ci+1)->func; /* previous function index */ + if (L->openupval) luaF_close(L, ci->base); + L->base = ci->base = ci->func + ((ci+1)->base - pfunc); + for (aux = 0; pfunc+aux < L->top; aux++) /* move frame down */ + setobjs2s(L, func+aux, pfunc+aux); + ci->top = L->top = func+aux; /* correct top */ + lua_assert(L->top == L->base + clvalue(func)->l.p->maxstacksize); + ci->savedpc = L->savedpc; + ci->tailcalls++; /* one more call lost */ + L->ci--; /* remove new frame */ + goto reentry; + } + case PCRC: { /* it was a C function (`precall' called it) */ + base = L->base; + continue; + } + default: { + return; /* yield */ + } + } + } + case OP_RETURN: { + int b = GETARG_B(i); + if (b != 0) L->top = ra+b-1; + if (L->openupval) luaF_close(L, base); + L->savedpc = pc; + b = luaD_poscall(L, ra); + if (--nexeccalls == 0) /* was previous function running `here'? */ + return; /* no: return */ + else { /* yes: continue its execution */ + if (b) L->top = L->ci->top; + lua_assert(isLua(L->ci)); + lua_assert(GET_OPCODE(*((L->ci)->savedpc - 1)) == OP_CALL); + goto reentry; + } + } + case OP_FORLOOP: { + lua_Number step = nvalue(ra+2); + lua_Number idx = luai_numadd(nvalue(ra), step); /* increment index */ + lua_Number limit = nvalue(ra+1); + if (luai_numlt(0, step) ? luai_numle(idx, limit) + : luai_numle(limit, idx)) { + dojump(L, pc, GETARG_sBx(i)); /* jump back */ + setnvalue(ra, idx); /* update internal index... */ + setnvalue(ra+3, idx); /* ...and external index */ + } + continue; + } + case OP_FORPREP: { + const TValue *init = ra; + const TValue *plimit = ra+1; + const TValue *pstep = ra+2; + L->savedpc = pc; /* next steps may throw errors */ + if (!tonumber(init, ra)) + luaG_runerror(L, LUA_QL("for") " initial value must be a number"); + else if (!tonumber(plimit, ra+1)) + luaG_runerror(L, LUA_QL("for") " limit must be a number"); + else if (!tonumber(pstep, ra+2)) + luaG_runerror(L, LUA_QL("for") " step must be a number"); + setnvalue(ra, luai_numsub(nvalue(ra), nvalue(pstep))); + dojump(L, pc, GETARG_sBx(i)); + continue; + } + case OP_TFORLOOP: { + StkId cb = ra + 3; /* call base */ + setobjs2s(L, cb+2, ra+2); + setobjs2s(L, cb+1, ra+1); + setobjs2s(L, cb, ra); + L->top = cb+3; /* func. + 2 args (state and index) */ + Protect(luaD_call(L, cb, GETARG_C(i))); + L->top = L->ci->top; + cb = RA(i) + 3; /* previous call may change the stack */ + if (!ttisnil(cb)) { /* continue loop? */ + setobjs2s(L, cb-1, cb); /* save control variable */ + dojump(L, pc, GETARG_sBx(*pc)); /* jump back */ + } + pc++; + continue; + } + case OP_SETLIST: { + int n = GETARG_B(i); + int c = GETARG_C(i); + int last; + Table *h; + if (n == 0) { + n = cast_int(L->top - ra) - 1; + L->top = L->ci->top; + } + if (c == 0) c = cast_int(*pc++); + runtime_check(L, ttistable(ra)); + h = hvalue(ra); + last = ((c-1)*LFIELDS_PER_FLUSH) + n; + if (last > h->sizearray) /* needs more space? */ + luaH_resizearray(L, h, last); /* pre-alloc it at once */ + for (; n > 0; n--) { + TValue *val = ra+n; + setobj2t(L, luaH_setnum(L, h, last--), val); + luaC_barriert(L, h, val); + } + continue; + } + case OP_CLOSE: { + luaF_close(L, ra); + continue; + } + case OP_CLOSURE: { + Proto *p; + Closure *ncl; + int nup, j; + p = cl->p->p[GETARG_Bx(i)]; + nup = p->nups; + ncl = luaF_newLclosure(L, nup, cl->env); + ncl->l.p = p; + for (j=0; jl.upvals[j] = cl->upvals[GETARG_B(*pc)]; + else { + lua_assert(GET_OPCODE(*pc) == OP_MOVE); + ncl->l.upvals[j] = luaF_findupval(L, base + GETARG_B(*pc)); + } + } + setclvalue(L, ra, ncl); + Protect(luaC_checkGC(L)); + continue; + } + case OP_VARARG: { + int b = GETARG_B(i) - 1; + int j; + CallInfo *ci = L->ci; + int n = cast_int(ci->base - ci->func) - cl->p->numparams - 1; + if (b == LUA_MULTRET) { + Protect(luaD_checkstack(L, n)); + ra = RA(i); /* previous call may change the stack */ + b = n; + L->top = ra + n; + } + for (j = 0; j < b; j++) { + if (j < n) { + setobjs2s(L, ra + j, ci->base - n + j); + } + else { + setnilvalue(ra + j); + } + } + continue; + } + } + } +} + diff --git a/lua/lvm.h b/lua/lvm.h new file mode 100644 index 0000000..bfe4f56 --- /dev/null +++ b/lua/lvm.h @@ -0,0 +1,36 @@ +/* +** $Id: lvm.h,v 2.5.1.1 2007/12/27 13:02:25 roberto Exp $ +** Lua virtual machine +** See Copyright Notice in lua.h +*/ + +#ifndef lvm_h +#define lvm_h + + +#include "ldo.h" +#include "lobject.h" +#include "ltm.h" + + +#define tostring(L,o) ((ttype(o) == LUA_TSTRING) || (luaV_tostring(L, o))) + +#define tonumber(o,n) (ttype(o) == LUA_TNUMBER || \ + (((o) = luaV_tonumber(o,n)) != NULL)) + +#define equalobj(L,o1,o2) \ + (ttype(o1) == ttype(o2) && luaV_equalval(L, o1, o2)) + + +LUAI_FUNC int luaV_lessthan (lua_State *L, const TValue *l, const TValue *r); +LUAI_FUNC int luaV_equalval (lua_State *L, const TValue *t1, const TValue *t2); +LUAI_FUNC const TValue *luaV_tonumber (const TValue *obj, TValue *n); +LUAI_FUNC int luaV_tostring (lua_State *L, StkId obj); +LUAI_FUNC void luaV_gettable (lua_State *L, const TValue *t, TValue *key, + StkId val); +LUAI_FUNC void luaV_settable (lua_State *L, const TValue *t, TValue *key, + StkId val); +LUAI_FUNC void luaV_execute (lua_State *L, int nexeccalls); +LUAI_FUNC void luaV_concat (lua_State *L, int total, int last); + +#endif diff --git a/lua/lzio.c b/lua/lzio.c new file mode 100644 index 0000000..293edd5 --- /dev/null +++ b/lua/lzio.c @@ -0,0 +1,82 @@ +/* +** $Id: lzio.c,v 1.31.1.1 2007/12/27 13:02:25 roberto Exp $ +** a generic input stream interface +** See Copyright Notice in lua.h +*/ + + +#include + +#define lzio_c +#define LUA_CORE + +#include "lua.h" + +#include "llimits.h" +#include "lmem.h" +#include "lstate.h" +#include "lzio.h" + + +int luaZ_fill (ZIO *z) { + size_t size; + lua_State *L = z->L; + const char *buff; + lua_unlock(L); + buff = z->reader(L, z->data, &size); + lua_lock(L); + if (buff == NULL || size == 0) return EOZ; + z->n = size - 1; + z->p = buff; + return char2int(*(z->p++)); +} + + +int luaZ_lookahead (ZIO *z) { + if (z->n == 0) { + if (luaZ_fill(z) == EOZ) + return EOZ; + else { + z->n++; /* luaZ_fill removed first byte; put back it */ + z->p--; + } + } + return char2int(*z->p); +} + + +void luaZ_init (lua_State *L, ZIO *z, lua_Reader reader, void *data) { + z->L = L; + z->reader = reader; + z->data = data; + z->n = 0; + z->p = NULL; +} + + +/* --------------------------------------------------------------- read --- */ +size_t luaZ_read (ZIO *z, void *b, size_t n) { + while (n) { + size_t m; + if (luaZ_lookahead(z) == EOZ) + return n; /* return number of missing bytes */ + m = (n <= z->n) ? n : z->n; /* min. between n and z->n */ + memcpy(b, z->p, m); + z->n -= m; + z->p += m; + b = (char *)b + m; + n -= m; + } + return 0; +} + +/* ------------------------------------------------------------------------ */ +char *luaZ_openspace (lua_State *L, Mbuffer *buff, size_t n) { + if (n > buff->buffsize) { + if (n < LUA_MINBUFFER) n = LUA_MINBUFFER; + luaZ_resizebuffer(L, buff, n); + } + return buff->buffer; +} + + diff --git a/lua/lzio.h b/lua/lzio.h new file mode 100644 index 0000000..51d695d --- /dev/null +++ b/lua/lzio.h @@ -0,0 +1,67 @@ +/* +** $Id: lzio.h,v 1.21.1.1 2007/12/27 13:02:25 roberto Exp $ +** Buffered streams +** See Copyright Notice in lua.h +*/ + + +#ifndef lzio_h +#define lzio_h + +#include "lua.h" + +#include "lmem.h" + + +#define EOZ (-1) /* end of stream */ + +typedef struct Zio ZIO; + +#define char2int(c) cast(int, cast(unsigned char, (c))) + +#define zgetc(z) (((z)->n--)>0 ? char2int(*(z)->p++) : luaZ_fill(z)) + +typedef struct Mbuffer { + char *buffer; + size_t n; + size_t buffsize; +} Mbuffer; + +#define luaZ_initbuffer(L, buff) ((buff)->buffer = NULL, (buff)->buffsize = 0) + +#define luaZ_buffer(buff) ((buff)->buffer) +#define luaZ_sizebuffer(buff) ((buff)->buffsize) +#define luaZ_bufflen(buff) ((buff)->n) + +#define luaZ_resetbuffer(buff) ((buff)->n = 0) + + +#define luaZ_resizebuffer(L, buff, size) \ + (luaM_reallocvector(L, (buff)->buffer, (buff)->buffsize, size, char), \ + (buff)->buffsize = size) + +#define luaZ_freebuffer(L, buff) luaZ_resizebuffer(L, buff, 0) + + +LUAI_FUNC char *luaZ_openspace (lua_State *L, Mbuffer *buff, size_t n); +LUAI_FUNC void luaZ_init (lua_State *L, ZIO *z, lua_Reader reader, + void *data); +LUAI_FUNC size_t luaZ_read (ZIO* z, void* b, size_t n); /* read next n bytes */ +LUAI_FUNC int luaZ_lookahead (ZIO *z); + + + +/* --------- Private Part ------------------ */ + +struct Zio { + size_t n; /* bytes still unread */ + const char *p; /* current position in buffer */ + lua_Reader reader; + void* data; /* additional data */ + lua_State *L; /* Lua state (for reader) */ +}; + + +LUAI_FUNC int luaZ_fill (ZIO *z); + +#endif diff --git a/lua/print.c b/lua/print.c new file mode 100644 index 0000000..e240cfc --- /dev/null +++ b/lua/print.c @@ -0,0 +1,227 @@ +/* +** $Id: print.c,v 1.55a 2006/05/31 13:30:05 lhf Exp $ +** print bytecodes +** See Copyright Notice in lua.h +*/ + +#include +#include + +#define luac_c +#define LUA_CORE + +#include "ldebug.h" +#include "lobject.h" +#include "lopcodes.h" +#include "lundump.h" + +#define PrintFunction luaU_print + +#define Sizeof(x) ((int)sizeof(x)) +#define VOID(p) ((const void*)(p)) + +static void PrintString(const TString* ts) +{ + const char* s=getstr(ts); + size_t i,n=ts->tsv.len; + putchar('"'); + for (i=0; ik[i]; + switch (ttype(o)) + { + case LUA_TNIL: + printf("nil"); + break; + case LUA_TBOOLEAN: + printf(bvalue(o) ? "true" : "false"); + break; + case LUA_TNUMBER: + printf(LUA_NUMBER_FMT,nvalue(o)); + break; + case LUA_TSTRING: + PrintString(rawtsvalue(o)); + break; + default: /* cannot happen */ + printf("? type=%d",ttype(o)); + break; + } +} + +static void PrintCode(const Proto* f) +{ + const Instruction* code=f->code; + int pc,n=f->sizecode; + for (pc=0; pc0) printf("[%d]\t",line); else printf("[-]\t"); + printf("%-9s\t",luaP_opnames[o]); + switch (getOpMode(o)) + { + case iABC: + printf("%d",a); + if (getBMode(o)!=OpArgN) printf(" %d",ISK(b) ? (-1-INDEXK(b)) : b); + if (getCMode(o)!=OpArgN) printf(" %d",ISK(c) ? (-1-INDEXK(c)) : c); + break; + case iABx: + if (getBMode(o)==OpArgK) printf("%d %d",a,-1-bx); else printf("%d %d",a,bx); + break; + case iAsBx: + if (o==OP_JMP) printf("%d",sbx); else printf("%d %d",a,sbx); + break; + } + switch (o) + { + case OP_LOADK: + printf("\t; "); PrintConstant(f,bx); + break; + case OP_GETUPVAL: + case OP_SETUPVAL: + printf("\t; %s", (f->sizeupvalues>0) ? getstr(f->upvalues[b]) : "-"); + break; + case OP_GETGLOBAL: + case OP_SETGLOBAL: + printf("\t; %s",svalue(&f->k[bx])); + break; + case OP_GETTABLE: + case OP_SELF: + if (ISK(c)) { printf("\t; "); PrintConstant(f,INDEXK(c)); } + break; + case OP_SETTABLE: + case OP_ADD: + case OP_SUB: + case OP_MUL: + case OP_DIV: + case OP_POW: + case OP_EQ: + case OP_LT: + case OP_LE: + if (ISK(b) || ISK(c)) + { + printf("\t; "); + if (ISK(b)) PrintConstant(f,INDEXK(b)); else printf("-"); + printf(" "); + if (ISK(c)) PrintConstant(f,INDEXK(c)); else printf("-"); + } + break; + case OP_JMP: + case OP_FORLOOP: + case OP_FORPREP: + printf("\t; to %d",sbx+pc+2); + break; + case OP_CLOSURE: + printf("\t; %p",VOID(f->p[bx])); + break; + case OP_SETLIST: + if (c==0) printf("\t; %d",(int)code[++pc]); + else printf("\t; %d",c); + break; + default: + break; + } + printf("\n"); + } +} + +#define SS(x) (x==1)?"":"s" +#define S(x) x,SS(x) + +static void PrintHeader(const Proto* f) +{ + const char* s=getstr(f->source); + if (*s=='@' || *s=='=') + s++; + else if (*s==LUA_SIGNATURE[0]) + s="(bstring)"; + else + s="(string)"; + printf("\n%s <%s:%d,%d> (%d instruction%s, %d bytes at %p)\n", + (f->linedefined==0)?"main":"function",s, + f->linedefined,f->lastlinedefined, + S(f->sizecode),f->sizecode*Sizeof(Instruction),VOID(f)); + printf("%d%s param%s, %d slot%s, %d upvalue%s, ", + f->numparams,f->is_vararg?"+":"",SS(f->numparams), + S(f->maxstacksize),S(f->nups)); + printf("%d local%s, %d constant%s, %d function%s\n", + S(f->sizelocvars),S(f->sizek),S(f->sizep)); +} + +static void PrintConstants(const Proto* f) +{ + int i,n=f->sizek; + printf("constants (%d) for %p:\n",n,VOID(f)); + for (i=0; isizelocvars; + printf("locals (%d) for %p:\n",n,VOID(f)); + for (i=0; ilocvars[i].varname),f->locvars[i].startpc+1,f->locvars[i].endpc+1); + } +} + +static void PrintUpvalues(const Proto* f) +{ + int i,n=f->sizeupvalues; + printf("upvalues (%d) for %p:\n",n,VOID(f)); + if (f->upvalues==NULL) return; + for (i=0; iupvalues[i])); + } +} + +void PrintFunction(const Proto* f, int full) +{ + int i,n=f->sizep; + PrintHeader(f); + PrintCode(f); + if (full) + { + PrintConstants(f); + PrintLocals(f); + PrintUpvalues(f); + } + for (i=0; ip[i],full); +} diff --git a/lua/stdafx.cpp b/lua/stdafx.cpp new file mode 100644 index 0000000..e9688b2 --- /dev/null +++ b/lua/stdafx.cpp @@ -0,0 +1,8 @@ +// stdafx.cpp : ֻ׼ļԴļ +// lua.pch ΪԤͷ +// stdafx.obj ԤϢ + +#include "stdafx.h" + +// TODO: STDAFX.H +// κĸͷļڴļ diff --git a/lua/stdafx.h b/lua/stdafx.h new file mode 100644 index 0000000..a767d59 --- /dev/null +++ b/lua/stdafx.h @@ -0,0 +1,14 @@ +// stdafx.h : ׼ϵͳļİļ +// Ǿʹõĵ +// ضĿİļ +// + +#pragma once + +#include "targetver.h" + +#define WIN32_LEAN_AND_MEAN // Windows ͷųʹõ + + + +// TODO: ڴ˴óҪͷļ diff --git a/lua/targetver.h b/lua/targetver.h new file mode 100644 index 0000000..91794a5 --- /dev/null +++ b/lua/targetver.h @@ -0,0 +1,13 @@ +#pragma once + +// º궨Ҫƽ̨Ҫƽ̨ +// ǾӦó蹦ܵ WindowsInternet Explorer ȲƷ +// 汾ָͨ汾Ͱ汾ƽ̨пõĹܣ +// + +// ҪԵָ汾ƽ̨޸ж塣 +// йزͬƽ̨ӦֵϢο MSDN +#ifndef _WIN32_WINNT // ָҪƽ̨ Windows Vista +#define _WIN32_WINNT 0x0600 // ֵΪӦֵ Windows 汾 +#endif + diff --git a/magic/magic.c b/magic/magic.c new file mode 100644 index 0000000..9d11a35 --- /dev/null +++ b/magic/magic.c @@ -0,0 +1,906 @@ +#include "version.h" +#include +#include + +#include "common.h" +#include "char_base.h" +#include "char_data.h" +#include "item.h" +#include "battle.h" +#include "magic_base.h" +#include "magic.h" +#include "magic_field.h" +#include "family.h" +#include "handletime.h" +#include "battle_magic.h" +#include "battle_event.h" +#include"lssproto_serv.h" +#ifdef _ITEM_ATTSKILLMAGIC +#include "pet_skill.h" +#endif +//#include "battle_event.h" +// shan add code +#define MP_RATE 0.7 + +int MAGIC_Use( int charaindex, int haveitemindex, int toindex) +{ + int itemindex; + int magicid,marray,mp; + int ret; + MAGIC_CALLFUNC func; + + itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + if( !ITEM_CHECKINDEX( itemindex) ) return FALSE; + magicid = ITEM_getInt( itemindex, ITEM_MAGICID); + marray = MAGIC_getMagicArray( magicid); + if( marray == -1 ) return FALSE; + + func = MAGIC_getMagicFuncPointer( MAGIC_getChar( marray, MAGIC_FUNCNAME));//MAGIC_NAME + if( (mp = ITEM_getInt( itemindex, ITEM_MAGICUSEMP)) < 0 ){ + print("err mp:%d -%s-%d\n", mp, ITEM_getChar( itemindex, ITEM_NAME), + ITEM_getInt( itemindex, ITEM_ID) ); + + } + + if(CHAR_getInt(charaindex,CHAR_LV)<100 && CHAR_getInt(charaindex,CHAR_TRANSMIGRATION)<1){ //CFָ0ת100֮ǰ + char magictmpbuf[32]; + sprintf(magictmpbuf,",%d,",ITEM_getInt( itemindex, ITEM_MAGICID)); + if(strstr(getNoMpMagic(),magictmpbuf)!=NULL){ + mp = 0; + } + } + + // shan add begin + if( CHAR_getInt( charaindex, CHAR_FMINDEX ) >= 1 ){ + // ⾫ + if( CHAR_getInt( charaindex, CHAR_FMSPRITE ) == 0){ + + // if( (marray >=0 && marray <=121) || (marray >= 190 && marray <=300 )){ + mp *= atof(getFmMagicMpRate(0)); + //printf("\n⵽壡mp=%d",mp); + + // } + //if(strstr(MAGIC_getChar( marray, MAGIC_COMMENT),"[]")!=NULL){ + //mp *= atof(getFmMagicMpRate(0)); + // } + + } + // + if( CHAR_getInt( charaindex, CHAR_FMSPRITE ) == 1){ + // if( (marray >=130 && marray <=189) || (marray >= 300 && marray <=500 )){ + mp *= atof(getFmMagicMpRate(1)); + // printf("\n⵽ڰ壡mp=%d",mp); + // } + // if(strstr(MAGIC_getChar( marray, MAGIC_COMMENT),"[]")!=NULL){ + // mp *= atof(getFmMagicMpRate(1)); + // } + } + } + // shan end + if( func ) { + ret = func( charaindex, toindex, marray, mp ); + }else { + ret = FALSE; + } + return ret; +} + +int MAGIC_GetArrayNo( int charaindex, int haveitemindex) +{ + int itemindex; + int magicid; + itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + if( !ITEM_CHECKINDEX( itemindex) ) return FALSE; + + magicid = ITEM_getInt( itemindex, ITEM_MAGICID); + + return magicid; +} +int MAGIC_DirectUse( + int charaindex, + int magicid, + int toindex, + int itemnum +) +{ + MAGIC_CALLFUNC func; + int mp=0, ret, marray=0; + int itemindex=-1; +#ifdef _MAGIC_NOCAST//Ĭ״̬޷ʩ + if( CHAR_getWorkInt( charaindex, CHAR_WORKNOCAST ) > 0 ){ + CHAR_talkToCli(charaindex, -1, "Ĭ޷", CHAR_COLORYELLOW); + return FALSE; + } +#endif +#ifdef _NO_MAGIC + int nomagicmap = CHAR_getInt(charaindex,CHAR_FLOOR); + int max; + for( max = 0 ; max < 30 ; max++){ + if (nomagicmap == getnomagicmap(max)){ + CHAR_talkToCli(charaindex, -1, "޷ʹκξ", CHAR_COLORYELLOW); + return FALSE; + } + } +#endif + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE) == CHAR_TYPEPLAYER){ + itemindex = CHAR_getItemIndex( charaindex, itemnum); + if( !ITEM_CHECKINDEX( itemindex) ){ + //print("ANDY err MAGIC_DirectUse() itemindex:%d !\n", itemindex); + return FALSE; + } + }else{ + itemindex = itemnum; + } + marray = MAGIC_getMagicArray( magicid ); + func = MAGIC_getMagicFuncPointer( MAGIC_getChar( marray, MAGIC_FUNCNAME ) ); + if( (mp = ITEM_getInt( itemindex, ITEM_MAGICUSEMP )) < 0 ){ + //return FALSE; + } + // shan add begin + if(CHAR_getInt(charaindex,CHAR_LV)<100 && CHAR_getInt(charaindex,CHAR_TRANSMIGRATION)<1){ //CFָ0ת100֮ǰ + char magictmpbuf[32]; + sprintf(magictmpbuf,",%d,",ITEM_getInt( itemindex, ITEM_MAGICID)); + //print("\nid=%s\n",magictmpbuf); + if(strstr(getNoMpMagic(),magictmpbuf)!=NULL){ + mp = 0; + } + } + if( CHAR_getInt( charaindex, CHAR_FMINDEX ) >= 1 ){ + if( CHAR_getInt( charaindex, CHAR_FMSPRITE ) == 0){ + mp *= atof(getFmMagicMpRate(0)); + } + if( CHAR_getInt( charaindex, CHAR_FMSPRITE ) == 1){ + mp *= atof(getFmMagicMpRate(1)); + } + } + /* + if( CHAR_getInt( charaindex, CHAR_FMINDEX ) >= 1 ){ + // ⾫ + if( CHAR_getInt( charaindex, CHAR_FMSPRITE ) == 0){ + //if( (marray >=0 && marray <=31) ){ + //mp *= MP_RATE; + // } + if(strstr(MAGIC_getChar( marray, MAGIC_COMMENT),"[]")!=NULL){ + mp *= atof(getFmMagicMpRate(0)); + } + } + // + if( CHAR_getInt( charaindex, CHAR_FMSPRITE ) == 1){ + //if( marray >=32 && marray <=81 ){ + //mp *= MP_RATE; + // } + if(strstr(MAGIC_getChar( marray, MAGIC_COMMENT),"[]")!=NULL){ + mp *= atof(getFmMagicMpRate(1)); + } + } + } + */ + if( func ) { + ret = func( charaindex, toindex, marray, mp ); + } + else { + ret = FALSE; + } + return ret; +} + +int MAGIC_Recovery( int charaindex, int toindex, int marray, int mp ) +{ + int battlemode; + if( CHAR_CHECKINDEX( charaindex ) == FALSE )return FALSE; + battlemode = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE ); + if( battlemode == BATTLE_CHARMODE_INIT ){ + return FALSE; + } + + + if( CHAR_getInt( charaindex, CHAR_MP ) < mp )return FALSE; + CHAR_setInt( charaindex, CHAR_MP, + CHAR_getInt( charaindex, CHAR_MP ) - mp ); + if( IsBATTLING( charaindex ) == TRUE ){ +#ifdef _PREVENT_TEAMATTACK //ݲ ʹõз + int battleindex = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEINDEX ); + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER && + BattleArray[battleindex].type != BATTLE_TYPE_P_vs_P ){ + + if( BATTLE_CheckSameSide( charaindex, toindex) == 0 ){//ͬ + int battleindex = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEINDEX ); + BATTLE_NoAction( battleindex, BATTLE_Index2No( battleindex, charaindex) ); + CHAR_talkToCli( charaindex, -1, "ݾ..ʩҵз", CHAR_COLORYELLOW); + return FALSE; + } + } +#endif + if (toindex==22){print("jinchao err\n");return FALSE;} // shan(ȫʹħbug)޸jinchao+2001/12/07 + MAGIC_Recovery_Battle( charaindex, toindex, marray, mp ); + }else{ + if( CHAR_CHECKINDEX( toindex ) == FALSE )return FALSE; // shan(ȫʹħbug)޸jinchao+2001/12/07 + MAGIC_Recovery_Field( charaindex, marray); + } + + return TRUE; +} + +int MAGIC_OtherRecovery( int charaindex, int toindex, int marray, int mp ) +{ + int battlemode; + if( CHAR_CHECKINDEX( charaindex ) == FALSE )return FALSE; // + battlemode = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE ); + if( battlemode == BATTLE_CHARMODE_INIT ){ + return FALSE; + } + + if( CHAR_getInt( charaindex, CHAR_MP ) < mp )return FALSE; // ĸ + CHAR_setInt( charaindex, CHAR_MP, + CHAR_getInt( charaindex, CHAR_MP ) - mp ); + if( IsBATTLING( charaindex ) == TRUE ){ +#ifdef _PREVENT_TEAMATTACK // ʹõз + int battleindex = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEINDEX ); + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER && + BattleArray[battleindex].type != BATTLE_TYPE_P_vs_P ){ + if( BATTLE_CheckSameSide( charaindex, toindex) == 0 ){//ͬ + int battleindex = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEINDEX ); + BATTLE_NoAction( battleindex, BATTLE_Index2No( battleindex, charaindex) ); + CHAR_talkToCli( charaindex, -1, "..ʩҵз", CHAR_COLORYELLOW); + return FALSE; + } + } +#endif + MAGIC_Recovery_Battle( charaindex, toindex, marray, mp ); + }else{ + if( CHAR_CHECKINDEX( toindex ) == FALSE )return FALSE; // + MAGIC_OtherRecovery_Field( charaindex, toindex, marray); + } + return TRUE; +} + +// ūë ܷ +int MAGIC_FieldAttChange( int charaindex, int toindex, int marray, int mp ) +{ + int battlemode; + + // INDEX + if( CHAR_CHECKINDEX( charaindex ) == FALSE )return FALSE; // + + battlemode = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE ); + + // ݷ + if( battlemode == BATTLE_CHARMODE_INIT ){ + return FALSE; + } + + // + if( CHAR_getInt( charaindex, CHAR_MP ) < mp )return FALSE; // ĸ + // ܷ ɧ ƻ УѨ̹ϵئ³練 + CHAR_setInt( charaindex, CHAR_MP, + CHAR_getInt( charaindex, CHAR_MP ) - mp ); + + // + if( IsBATTLING( charaindex ) == TRUE ){ + return MAGIC_FieldAttChange_Battle( charaindex, toindex, marray, mp ); + }else{ + // ƥئ + return FALSE; + } +} +int MAGIC_StatusChange( int charaindex, int toindex, int marray, int mp ) +{ + int battlemode; + if( CHAR_CHECKINDEX( charaindex ) == FALSE )return FALSE; + battlemode = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE ); + if( battlemode == BATTLE_CHARMODE_INIT ){ + return FALSE; + } + + if( CHAR_getInt( charaindex, CHAR_MP ) < mp )return FALSE; + CHAR_setInt( charaindex, CHAR_MP, CHAR_getInt( charaindex, CHAR_MP ) - mp ); + if( IsBATTLING( charaindex ) == TRUE ){ +#ifdef _PREVENT_TEAMATTACK //쳣״̬ʹѷ + int battleindex = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEINDEX ); + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER && + BattleArray[battleindex].type != BATTLE_TYPE_P_vs_P ){ + if( BATTLE_CheckSameSide( charaindex, toindex) == 1 ){//ͬ + int battleindex = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEINDEX ); + BATTLE_NoAction( battleindex, BATTLE_Index2No( battleindex, charaindex) ); + CHAR_talkToCli( charaindex, -1, "쳣״̬..ʩѷ", CHAR_COLORYELLOW); + return FALSE; + } + } +#endif + return MAGIC_StatusChange_Battle( charaindex, toindex, marray, mp ); + }else{ + return FALSE; + } +} + +#ifdef _OTHER_MAGICSTAUTS +int MAGIC_MagicStatusChange( int charaindex, int toindex, int marray, int mp ) +{ + int battlemode; + if( CHAR_CHECKINDEX( charaindex ) == FALSE ) return FALSE; + + battlemode = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE ); + if( battlemode == BATTLE_CHARMODE_INIT ){ + return FALSE; + } + if( CHAR_getInt( charaindex, CHAR_MP ) < mp )return FALSE; + CHAR_setInt( charaindex, CHAR_MP, CHAR_getInt( charaindex, CHAR_MP ) - mp ); + if( IsBATTLING( charaindex ) == TRUE ){ + return MAGIC_MagicStatusChange_Battle( charaindex, toindex, marray, mp ); + }else{ + return FALSE; + } +} +#endif + +#ifdef _MAGIC_DEEPPOISON//ver2,Ҫ趨״̬5δʱ +// ëܸ ܷ +int MAGIC_StatusChange2( int charaindex, int toindex, int marray, int mp ) +{ + int battlemode; + + // INDEX + if( CHAR_CHECKINDEX( charaindex ) == FALSE )return FALSE; // + + battlemode = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE ); + + // ݷ + if( battlemode == BATTLE_CHARMODE_INIT ){ + return FALSE; + } + + // + if( CHAR_getInt( charaindex, CHAR_MP ) < mp )return FALSE; + + CHAR_setInt( charaindex, CHAR_MP, + CHAR_getInt( charaindex, CHAR_MP ) - mp ); + + //call func + if( IsBATTLING( charaindex ) == TRUE ){ + return MAGIC_StatusChange_Battle2( charaindex, toindex, marray, mp ); + }else{ + return FALSE; + } +} +#endif +// ټ ܷ +int MAGIC_StatusRecovery( int charaindex, int toindex, int marray, int mp ) +{ + int battlemode; + + // INDEX + if( CHAR_CHECKINDEX( charaindex ) == FALSE )return FALSE; // + + battlemode = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE ); + + // ݷ + if( battlemode == BATTLE_CHARMODE_INIT ){ + return FALSE; + } + + // + if( CHAR_getInt( charaindex, CHAR_MP ) < mp )return FALSE; // ĸ + // ܷ ɧ ƻ УѨ̹ϵئ³練 + CHAR_setInt( charaindex, CHAR_MP, + CHAR_getInt( charaindex, CHAR_MP ) - mp ); + + // + if( IsBATTLING( charaindex ) == TRUE ){ + return MAGIC_StatusRecovery_Battle( charaindex, toindex, marray, mp ); + }else{ + // ƥئ + return FALSE; + } +} + +int MAGIC_MagicDef( int charaindex, int toindex, int marray, int mp ) +{ + int battlemode; + if( CHAR_CHECKINDEX( charaindex ) == FALSE )return FALSE; + battlemode = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE ); + if( battlemode == BATTLE_CHARMODE_INIT ){ + return FALSE; + } + + if( CHAR_getInt( charaindex, CHAR_MP ) < mp )return FALSE; + CHAR_setInt( charaindex, CHAR_MP, CHAR_getInt( charaindex, CHAR_MP ) - mp ); + if( IsBATTLING( charaindex ) == TRUE ){ +#ifdef _PREVENT_TEAMATTACK //⾵..ʹõз +#ifdef _GJS_TYPE + if(getGjsType()==0){ +#endif + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER + /*&& BattleArray[battleindex].type != BATTLE_TYPE_P_vs_P*/ ){ + if( BATTLE_CheckSameSide( charaindex, toindex) == 0 ){//ͬ + int battleindex = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEINDEX ); + BATTLE_NoAction( battleindex, BATTLE_Index2No( battleindex, charaindex) ); + CHAR_talkToCli( charaindex, -1, "⾵..ʩз", CHAR_COLORYELLOW); + return FALSE; + } + } +#ifdef _GJS_TYPE + } +#endif +#endif + return MAGIC_MagicDef_Battle( charaindex, toindex, marray, mp ); + }else{ + return FALSE; + } +} + + +// 姾ٽ ܷ +int MAGIC_Ressurect( int charaindex, int toindex, int marray, int mp ) +{ + int battlemode; + + // INDEX + if( CHAR_CHECKINDEX( charaindex ) == FALSE )return FALSE; // + + battlemode = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE ); + + // ݷ + if( battlemode == BATTLE_CHARMODE_INIT ){ + return FALSE; + } + + // + if( CHAR_getInt( charaindex, CHAR_MP ) < mp )return FALSE; // ĸ + // ܷ ɧ ƻ УѨ̹ϵئ³練 + CHAR_setInt( charaindex, CHAR_MP, + CHAR_getInt( charaindex, CHAR_MP ) - mp ); + + // + if( IsBATTLING( charaindex ) == TRUE ){ + return MAGIC_Ressurect_Battle( charaindex, toindex, marray, mp ); + }else{ + // ƥئ + return FALSE; + } +} + +// ë ܷ +int MAGIC_AttReverse( int charaindex, int toindex, int marray, int mp ) +{ + int battlemode; + + // INDEX + if( CHAR_CHECKINDEX( charaindex ) == FALSE )return FALSE; // + + battlemode = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE ); + + // ݷ + if( battlemode == BATTLE_CHARMODE_INIT ){ + return FALSE; + } + + // + if( CHAR_getInt( charaindex, CHAR_MP ) < mp )return FALSE; // ĸ + // ܷ ɧ ƻ УѨ̹ϵئ³練 + CHAR_setInt( charaindex, CHAR_MP, + CHAR_getInt( charaindex, CHAR_MP ) - mp ); + + // + if( IsBATTLING( charaindex ) == TRUE ){ + return MAGIC_AttReverse_Battle( charaindex, toindex, marray, mp ); + }else{ + // ƥئ + return FALSE; + } +} + + + +// 姾١ ܷ +int MAGIC_ResAndDef( int charaindex, int toindex, int marray, int mp ) +{ + int battlemode; + + // INDEX + if( CHAR_CHECKINDEX( charaindex ) == FALSE )return FALSE; // + + battlemode = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE ); + + // ݷ + if( battlemode == BATTLE_CHARMODE_INIT ){ + return FALSE; + } + + // + if( CHAR_getInt( charaindex, CHAR_MP ) < mp )return FALSE; // ĸ + // ܷ ɧ ƻ УѨ̹ϵئ³練 + CHAR_setInt( charaindex, CHAR_MP, + CHAR_getInt( charaindex, CHAR_MP ) - mp ); + + // + if( IsBATTLING( charaindex ) == TRUE ){ + return MAGIC_ResAndDef_Battle( charaindex, toindex, marray, mp ); + }else{ + // ƥئ + return FALSE; + } +} + + + +#ifdef _ATTACK_MAGIC + +int MAGIC_AttMagic( int charaindex , int toindex , int marray , int mp ) +{ + int battlemode; + + if( FALSE == CHAR_CHECKINDEX( charaindex ) ) + return FALSE; + + battlemode = CHAR_getWorkInt( charaindex , CHAR_WORKBATTLEMODE ); + if( BATTLE_CHARMODE_INIT == battlemode ) + return FALSE; + // dzħ,mp + if(CHAR_getInt(charaindex,CHAR_WHICHTYPE) == CHAR_TYPEPLAYER) + { + if( CHAR_getInt( charaindex , CHAR_MP ) < mp ) + return FALSE; + + CHAR_setInt( charaindex , CHAR_MP , CHAR_getInt( charaindex , CHAR_MP ) - mp ); + } + + if( TRUE == IsBATTLING( charaindex ) ) + return MAGIC_AttMagic_Battle( charaindex , toindex , marray , mp ); + + return FALSE; + +} + +#endif + +#ifdef _ITEM_METAMO +int MAGIC_Metamo( int charaindex, int toindex, int marray, int mp ) +{ + int battlemode, haveindex, power, i; + char msg[128]; + + if( CHAR_CHECKINDEX( charaindex ) == FALSE ) return FALSE; + + battlemode = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE ); + // ݷ + if( battlemode == BATTLE_CHARMODE_INIT ){ + return FALSE; + } + // + if( IsBATTLING( charaindex ) == TRUE ){ + //MAGIC_Recovery_Battle( charaindex, toindex, marray, mp ); + //return FALSE; + toindex = BATTLE_No2Index( + CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEINDEX ), toindex ); + //print(" battle_metamo:%d ", toindex); + } + + if( CHAR_CHECKINDEX( toindex ) == FALSE ) return FALSE; + + if( CHAR_getInt( charaindex, CHAR_RIDEPET ) != -1 ){ + CHAR_talkToCli( charaindex, -1, "޷вܱ", CHAR_COLORWHITE ); + return FALSE; + } +#ifdef _FIX_METAMORIDE + if( CHAR_CHECKJOINENEMY( charaindex) == TRUE ){ + CHAR_talkToCli( charaindex, -1, "޷вܱ", CHAR_COLORYELLOW ); + return FALSE; + } +#else + if( CHAR_getInt( charaindex, CHAR_BASEIMAGENUMBER) == 100259 ){ + CHAR_talkToCli( charaindex, -1, "޷вܱ", CHAR_COLORWHITE ); + return FALSE; + } +#endif +#ifdef _FIXBUG_ATTACKBOW + { + int armindex = CHAR_getItemIndex( charaindex, CHAR_ARM); + if( ITEM_CHECKINDEX( armindex) == TRUE ) { + int armtype = BATTLE_GetWepon( charaindex); + if( armtype == ITEM_BOW || armtype == ITEM_BOUNDTHROW || + armtype == ITEM_BREAKTHROW || armtype == ITEM_BOOMERANG) { + CHAR_talkToCli( charaindex, -1, "ʹԶ޷", CHAR_COLORYELLOW ); + return FALSE; + } + } + } +#endif + haveindex = -1; + for( i = 0; i < 5; i++ ) + { + if( CHAR_getCharPet( charaindex, i) == toindex ) { + haveindex = i; + break; + } + } + if( haveindex == -1 && charaindex != toindex ) + { + CHAR_talkToCli( charaindex, -1, "޷ֻܱԼij", CHAR_COLORWHITE ); + return FALSE; + } + + if( CHAR_getInt( toindex, CHAR_BASEIMAGENUMBER) == 100259 ){ + CHAR_talkToCli( charaindex, -1, "ܱɼ", CHAR_COLORWHITE ); + return FALSE; + } + + power = atoi(MAGIC_getChar( marray, MAGIC_OPTION )); + + if( CHAR_getInt( charaindex, CHAR_MP ) < mp )return FALSE; + CHAR_setInt( charaindex, CHAR_MP, + CHAR_getInt( charaindex, CHAR_MP ) - mp ); + CHAR_send_P_StatusString( charaindex , CHAR_P_STRING_MP); + + if( toindex != charaindex ) { + CHAR_setWorkInt( charaindex, CHAR_WORKITEMMETAMO, NowTime.tv_sec +power); + sprintf( msg, "%s", CHAR_getChar( toindex, CHAR_NAME) ); + } + else { + CHAR_setWorkInt( charaindex, CHAR_WORKITEMMETAMO, 0); + sprintf( msg, "Լ"); + } + CHAR_talkToCli( charaindex, -1, msg, CHAR_COLORWHITE ); + + CHAR_setInt( charaindex, CHAR_BASEIMAGENUMBER, + CHAR_getInt( toindex, CHAR_BASEBASEIMAGENUMBER) ); + CHAR_complianceParameter( charaindex); + CHAR_sendCToArroundCharacter( CHAR_getWorkInt( charaindex , CHAR_WORKOBJINDEX )); + CHAR_send_P_StatusString( charaindex , CHAR_P_STRING_BASEBASEIMAGENUMBER); +//#endif + + return TRUE; +} +#endif + +#ifdef _ITEM_ATTSKILLMAGIC +int MAGIC_AttSkill( int charaindex, int toindex,int marray, int mp ) +{ + int battlemode; + int battleindex=-1; + char *magicarg, funName[256]; + int skillID=-1; + PETSKILL_CALLFUNC func; + if( CHAR_CHECKINDEX( charaindex ) == FALSE ) return FALSE; + if( IsBATTLING( charaindex ) == FALSE ) return FALSE; + battleindex = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEINDEX ); + if( BATTLE_CHECKINDEX( battleindex ) == FALSE ) return FALSE; + + battlemode = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE ); + if( battlemode == BATTLE_CHARMODE_INIT ) return FALSE; + if( toindex < 0 || toindex > 19 ) return FALSE; + if( CHAR_getInt( charaindex, CHAR_MP ) < mp ) return FALSE; + + memset( funName, 0, sizeof( char)*256 ); + //MAGIC_Recovery_Battle( charaindex, toindex, marray, mp ); + magicarg = MAGIC_getChar( marray, MAGIC_OPTION ); + if ( magicarg == "\0") return FALSE; + if( strstr( magicarg, ";" ) != NULL ) { + char buff1[256]; + if( getStringFromIndexWithDelim( magicarg, ";", 1, buff1, sizeof( buff1)) == FALSE ) + return FALSE; + snprintf( funName, sizeof(funName), buff1); + if( getStringFromIndexWithDelim( magicarg, ";", 2, buff1, sizeof( buff1)) == FALSE ) + return FALSE; + skillID = atoi( buff1); + }else + return FALSE; + func = PETSKILL_getPetskillFuncPointer( funName); + if( !func ){ + print("\n *func not FOUND !!"); + return FALSE; + } + if( func( charaindex, toindex, skillID, "MAGICSKILL" ) == FALSE ) return FALSE; + CHAR_setInt( charaindex, CHAR_MP, CHAR_getInt( charaindex, CHAR_MP ) - mp ); + return TRUE; + +} +#endif +#ifdef _MAGIC_BARRIER// vincent :ħ +int MAGIC_Barrier( int charaindex, int toindex, int marray, int mp ) +{ + + int battlemode; + int i,turn,perStatus; + int ToList[SIDE_OFFSET*2+1]; + char *magicarg; + int attackNo=0; + int battleindex,Success = 0; + char szTurn[] = "turn"; + char szSuccess[] = ""; + char *pszP; + + //check index + if( CHAR_CHECKINDEX( charaindex ) == FALSE )return FALSE; + + battlemode = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE ); + + // ݷ //?? + if( battlemode == BATTLE_CHARMODE_INIT ){ + return FALSE; + } + + //mp + if( CHAR_getInt( charaindex, CHAR_MP ) < mp )return FALSE; + //mp + CHAR_setInt( charaindex, CHAR_MP, + CHAR_getInt( charaindex, CHAR_MP ) - mp ); + //ħ + magicarg = MAGIC_getChar( marray, MAGIC_OPTION ); + if( magicarg == "\0" ) { + print("\n magicarg == NULL "); + return FALSE; + } + pszP = magicarg; + + //ȡûغ + if( ( pszP = strstr( pszP, szTurn ) ) != NULL){ + pszP += sizeof( szTurn ); + sscanf( pszP, "%d", &turn ); + } + // ɬ// + if( ( pszP = strstr( pszP, szSuccess ) ) != NULL){ + pszP += sizeof( szSuccess ); + sscanf( pszP, "%d", &Success ); + } + + battleindex = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEINDEX ); + attackNo = BATTLE_Index2No( battleindex, charaindex ); + BATTLE_MultiList( battleindex, toindex, ToList ); +//ʩħЧ + BATTLE_MagicEffect(battleindex, attackNo, ToList, MAGIC_EFFECT_USER, SPR_hoshi); + + charaindex = BATTLE_No2Index( battleindex, attackNo ); + //checkǷս + if( IsBATTLING( charaindex ) == TRUE ) + { + + for( i = 0; ToList[i] != -1; i ++ ) + { + toindex = BATTLE_No2Index( battleindex, ToList[i] ); + if( BATTLE_StatusAttackCheck( charaindex,toindex, BATTLE_ST_BARRIER, Success, 30, 1.0, &perStatus ) == TRUE ) + { + CHAR_setWorkInt( toindex, CHAR_WORKBARRIER, turn+1 ); +// BATTLE_BadStatusString( ToList[i], BATTLE_ST_BARRIER ); + } + } + return TRUE; + }else{ + return FALSE; + } +} +#endif +#ifdef _MAGIC_NOCAST// vincent :Ĭ +int MAGIC_Nocast( int charaindex, int toindex, int marray, int mp ) +{ + + int battlemode; + int i,turn,perStatus; + int ToList[SIDE_OFFSET*2+1]; + char *magicarg; + int attackNo=0; + int battleindex,Success = 0; + char szTurn[] = "turn"; + char szSuccess[] = ""; + char *pszP; + + //check index + if( CHAR_CHECKINDEX( charaindex ) == FALSE )return FALSE; + + battlemode = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE ); + + // ݷ //?? + if( battlemode == BATTLE_CHARMODE_INIT ){ + return FALSE; + } + + //mp + if( CHAR_getInt( charaindex, CHAR_MP ) < mp )return FALSE; + //mp + CHAR_setInt( charaindex, CHAR_MP, + CHAR_getInt( charaindex, CHAR_MP ) - mp ); + //ħ + magicarg = MAGIC_getChar( marray, MAGIC_OPTION ); + if( magicarg == "\0" ) { + print("\n magicarg == NULL "); + return FALSE; + } + pszP = magicarg; + + //ȡûغ + if( ( pszP = strstr( pszP, szTurn ) ) != NULL){ + pszP += sizeof( szTurn ); + sscanf( pszP, "%d", &turn ); + } + // ɬ// + if( ( pszP = strstr( pszP, szSuccess ) ) != NULL){ + pszP += sizeof( szSuccess ); + sscanf( pszP, "%d", &Success ); + } +// print("\nvincent-->MAGIC_Nocast use"); + battleindex = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEINDEX ); + attackNo = BATTLE_Index2No( battleindex, charaindex ); + BATTLE_MultiList( battleindex, toindex, ToList ); +//ʩħЧ + BATTLE_MagicEffect(battleindex, attackNo, ToList, MAGIC_EFFECT_USER, SPR_hoshi); + charaindex = BATTLE_No2Index( battleindex, attackNo ); + //checkǷս + if( IsBATTLING( charaindex ) == TRUE ) + { + + for( i = 0; ToList[i] != -1; i ++ ) + { + toindex = BATTLE_No2Index( battleindex, ToList[i] ); + if( BATTLE_StatusAttackCheck( charaindex,toindex, BATTLE_ST_NOCAST, Success, 30, 1.0, &perStatus ) == TRUE + && CHAR_getInt( toindex, CHAR_WHICHTYPE) != CHAR_TYPEPET) + { + CHAR_setWorkInt( toindex, CHAR_WORKNOCAST, turn ); +//޷չҳ + lssproto_NC_send( getfdFromCharaIndex( toindex ), 1); + //print("\nvincent-->NOCASTING2"); +// BATTLE_BadStatusString( ToList[i], BATTLE_ST_NOCAST ); + } + } + return TRUE; + }else{ + return FALSE; + } +} +#endif + +#ifdef _MAGIC_WEAKEN// vincent : +int MAGIC_Weaken( int charaindex, int toindex, int marray, int mp ) +{ + + int battlemode; + //check index + if( CHAR_CHECKINDEX( charaindex ) == FALSE )return FALSE; + + battlemode = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE ); + + // ݷ //?? + if( battlemode == BATTLE_CHARMODE_INIT ){ + return FALSE; + } + + //mp + if( CHAR_getInt( charaindex, CHAR_MP ) < mp )return FALSE; + //mp + CHAR_setInt( charaindex, CHAR_MP, + CHAR_getInt( charaindex, CHAR_MP ) - mp ); + + //checkǷս + if( IsBATTLING( charaindex ) == TRUE ){ + return MAGIC_ParamChange_Turn_Battle( charaindex, toindex, marray, mp ); + }else{ + return FALSE; + } +} +#endif + +#ifdef _MAGIC_TOCALL +int MAGIC_ToCallDragon( int charaindex, int toindex,int marray, int mp ) +{ + int battlemode; + + //print("MAGIC_ToCallDragon in .................\n"); + if( FALSE == CHAR_CHECKINDEX( charaindex ) ) + return FALSE; + + battlemode = CHAR_getWorkInt( charaindex , CHAR_WORKBATTLEMODE ); + if( BATTLE_CHARMODE_INIT == battlemode ) + return FALSE; + if( CHAR_getInt( charaindex , CHAR_MP ) < mp ) + return FALSE; + + CHAR_setInt( charaindex , CHAR_MP , CHAR_getInt( charaindex , CHAR_MP ) - mp ); + + if( TRUE == IsBATTLING( charaindex ) ) + return MAGIC_ToCallDragon_Battle( charaindex , toindex , marray , mp ); + + return FALSE; +} +#endif + + + + diff --git a/magic/magic_base.c b/magic/magic_base.c new file mode 100644 index 0000000..04e43a3 --- /dev/null +++ b/magic/magic_base.c @@ -0,0 +1,509 @@ +#include "version.h" +#include +#include + +#include "common.h" +#include "buf.h" +#include "configfile.h" +#include "magic_base.h" +#include "magic.h" + +static Magic *MAGIC_magic; +static int MAGIC_magicnum; + + + +#ifdef _ATTACK_MAGIC + +AttMagic *ATTMAGIC_magic; +int ATTMAGIC_magicnum; + +#endif + + + +typedef struct tagMagic_MagicFunctionTable +{ + char *functionname; /* ɬð̻̤Ѽ */ + MAGIC_CALLFUNC func; /* ˱̫ľ */ + int hash; /* hash */ +}MAGIC_MagicFunctionTable; + +/* ë ֧ճ */ +static MAGIC_MagicFunctionTable MAGIC_functbl[] = { + { "MAGIC_Recovery", MAGIC_Recovery, 0}, + { "MAGIC_OtherRecovery", MAGIC_OtherRecovery, 0}, + { "MAGIC_FieldAttChange", MAGIC_FieldAttChange, 0}, + { "MAGIC_StatusChange", MAGIC_StatusChange, 0}, + { "MAGIC_MagicDef", MAGIC_MagicDef, 0}, + { "MAGIC_StatusRecovery", MAGIC_StatusRecovery, 0}, + { "MAGIC_Ressurect", MAGIC_Ressurect, 0}, + { "MAGIC_AttReverse", MAGIC_AttReverse, 0}, + { "MAGIC_ResAndDef", MAGIC_ResAndDef, 0}, + +#ifdef _ATTACK_MAGIC + { "MAGIC_AttMagic" , MAGIC_AttMagic , 0 }, +#endif +#ifdef _OTHER_MAGICSTAUTS + { "MAGIC_MagicStatusChange", MAGIC_MagicStatusChange, 0}, +#endif +#ifdef _ITEM_METAMO + { "MAGIC_Metamo", MAGIC_Metamo, 0}, +#endif +#ifdef _ITEM_ATTSKILLMAGIC + //{ "MAGIC_AttSkill", MAGIC_AttSkill, 0}, +#endif +#ifdef _MAGIC_WEAKEN // vincent : + { "MAGIC_Weaken", MAGIC_Weaken, 0}, +#endif +#ifdef _MAGIC_DEEPPOISON // vincent :綾 + { "MAGIC_StatusChange2", MAGIC_StatusChange2,0}, +#endif +#ifdef _MAGIC_BARRIER // vincent :ħ + { "MAGIC_Barrier", MAGIC_Barrier, 0}, +#endif +#ifdef _MAGIC_NOCAST // vincent :Ĭ + { "MAGIC_Nocast", MAGIC_Nocast, 0}, +#endif +#ifdef _MAGIC_TOCALL // + { "MAGIC_ToCallDragon", MAGIC_ToCallDragon, 0}, +#endif +}; + +/*----------------------------------------------------------------------*/ + + +/* ͣʧͱ */ +/*----------------------------------------------------------------------*/ +INLINE BOOL MAGIC_CHECKINDEX( int index ) +{ + if( MAGIC_magicnum<=index || index<0 )return FALSE; + return TRUE; +} +/*----------------------------------------------------------------------*/ +static INLINE BOOL MAGIC_CHECKINTDATAINDEX( int index) +{ + if( MAGIC_DATAINTNUM <= index || index < 0 ) return FALSE; + return TRUE; +} +/*----------------------------------------------------------------------*/ +static INLINE BOOL MAGIC_CHECKCHARDATAINDEX( int index) +{ + if( MAGIC_DATACHARNUM <= index || index < 0 ) return FALSE; + return TRUE; +} +/*----------------------------------------------------------------------*/ +INLINE int MAGIC_getInt( int index, MAGIC_DATAINT element) +{ + return MAGIC_magic[index].data[element]; +} +/*----------------------------------------------------------------------*/ +INLINE int MAGIC_setInt( int index, MAGIC_DATAINT element, int data) +{ + int buf; + buf = MAGIC_magic[index].data[element]; + MAGIC_magic[index].data[element]=data; + return buf; +} +/*----------------------------------------------------------------------*/ +INLINE char* MAGIC_getChar( int index, MAGIC_DATACHAR element) +{ + if( !MAGIC_CHECKINDEX( index)) return "\0"; + if( !MAGIC_CHECKCHARDATAINDEX( element)) return "\0"; + return MAGIC_magic[index].string[element].string; +} + +/*----------------------------------------------------------------------*/ +INLINE BOOL MAGIC_setChar( int index ,MAGIC_DATACHAR element, char* new ) +{ + if(!MAGIC_CHECKINDEX(index))return FALSE; + if(!MAGIC_CHECKCHARDATAINDEX(element))return FALSE; + strcpysafe( MAGIC_magic[index].string[element].string, + sizeof(MAGIC_magic[index].string[element].string), + new ); + return TRUE; +} +/*---------------------------------------------------------------------- + * ܷë£ + *---------------------------------------------------------------------*/ +int MAGIC_getMagicNum( void) +{ + return MAGIC_magicnum; +} + +/*---------------------------------------------------------------------- + * ܷɬð̻ë + *---------------------------------------------------------------------*/ +BOOL MAGIC_initMagic( char *filename) +{ + FILE* f; + char line[256]; + int linenum=0; + int magic_readlen=0; + int i,j; + + int max_magicid =0; + char token[256]; + + f = fopen(filename,"r"); + if( f == NULL ){ + print( "ļʧ\n"); + return FALSE; + } + + MAGIC_magicnum=0; + + /* ئ滥ϵؤ¾Ʃ */ + while( fgets( line, sizeof( line ), f ) ){ + linenum ++; + if( line[0] == '#' )continue; /* comment */ + if( line[0] == '\n' )continue; /* none */ + chomp( line ); + +#ifdef _MAGIC_OPTIMUM // Robin ȡMAGIC ID + if( getStringFromIndexWithDelim( line, ",", MAGIC_DATACHARNUM+MAGIC_ID+1, + token, sizeof(token)) == FALSE ) + continue; + max_magicid = max( atoi( token), max_magicid); +#endif + + MAGIC_magicnum++; + } + +#ifdef _MAGIC_OPTIMUM + print("Чħ:%d ħ:%d ...", MAGIC_magicnum, max_magicid); + MAGIC_magicnum = max_magicid +1; +#endif + + if( fseek( f, 0, SEEK_SET ) == -1 ){ + fprint( "\n" ); + fclose(f); + return FALSE; + } + + MAGIC_magic = allocateMemory( sizeof(struct tagMagic) + * MAGIC_magicnum ); + if( MAGIC_magic == NULL ){ + fprint( "޷ڴ %d\n" , + sizeof(struct tagMagic)*MAGIC_magicnum); + fclose( f ); + return FALSE; + } + + /* */ + for( i = 0; i < MAGIC_magicnum; i ++ ) { + for( j = 0; j < MAGIC_DATAINTNUM; j ++ ) { + MAGIC_setInt( i,j,-1); + } + for( j = 0; j < MAGIC_DATACHARNUM; j ++ ) { + MAGIC_setChar( i,j,""); + } + } + + /* */ + linenum = 0; + while( fgets( line, sizeof( line ), f ) ){ + linenum ++; + if( line[0] == '#' )continue; /* comment */ + if( line[0] == '\n' )continue; /* none */ + chomp( line ); + + /* ë */ + /* tab ë " " 徧 */ + replaceString( line, '\t' , ' ' ); + /* ʸë£*/ +{ + char buf[256]; + for( i = 0; i < strlen( line); i ++) { + if( line[i] != ' ' ) { + break; + } + strcpy( buf, &line[i]); + } + if( i != 0 ) { + strcpy( line, buf); + } +} +{ + char token[256]; + int ret; + +#ifdef _MAGIC_OPTIMUM + if( getStringFromIndexWithDelim( line, ",", MAGIC_DATACHARNUM+MAGIC_ID+1, + token, sizeof(token)) == FALSE ) + continue; + magic_readlen = atoi( token); +#endif + + for( i = 0; i < MAGIC_DATACHARNUM; i ++ ) { + + /* ٯ ͼëέ */ + ret = getStringFromIndexWithDelim( line,",", + i + 1, + token,sizeof(token)); + if( ret==FALSE ){ + fprint("ļ﷨:%s %d\n",filename,linenum); + break; + } + MAGIC_setChar( magic_readlen, i, token); + } + /* 4 ϷѰ */ +#define MAGIC_STARTINTNUM 5 + for( i = MAGIC_STARTINTNUM; i < MAGIC_DATAINTNUM+MAGIC_STARTINTNUM; i ++ ) { + ret = getStringFromIndexWithDelim( line,",",i,token, + sizeof(token)); + +#ifdef _ATTACK_MAGIC + + if( FALSE == ret ) + + break; + + if( 0 != strlen( token ) ) + { + MAGIC_setInt( magic_readlen , i - MAGIC_STARTINTNUM , atoi( token ) ); + } + +#else + + if( ret==FALSE ){ + fprint("ļ﷨:%s %d\n",filename,linenum); + break; + } + if( strlen( token) != 0 ) { + MAGIC_setInt( magic_readlen, i - MAGIC_STARTINTNUM, atoi( token)); + } + + #endif + } + +#ifdef _ATTACK_MAGIC + + if( i != MAGIC_STARTINTNUM + MAGIC_IDX && i != MAGIC_DATAINTNUM + MAGIC_STARTINTNUM ) + continue; + +#else + + if( i < MAGIC_DATAINTNUM+MAGIC_STARTINTNUM ) + continue; + +#endif + /* нسƶ£ */ + if( MAGIC_getInt( magic_readlen, MAGIC_TARGET_DEADFLG) == 1 ) { + MAGIC_setInt( magic_readlen, MAGIC_TARGET, + MAGIC_getInt( magic_readlen, MAGIC_TARGET)+100); + } + + magic_readlen ++; +} + } + fclose(f); + + MAGIC_magicnum = magic_readlen; + + + print( "Чħ %d...", MAGIC_magicnum ); + + /* hash */ + for( i = 0; i < arraysizeof( MAGIC_functbl); i ++ ) { + MAGIC_functbl[i].hash = hashpjw( MAGIC_functbl[i].functionname); + } + return TRUE; +} +/*------------------------------------------------------------------------ + * Magicɬð̻ + *-----------------------------------------------------------------------*/ +BOOL MAGIC_reinitMagic( void ) +{ + freeMemory( MAGIC_magic); + return( MAGIC_initMagic( getMagicfile())); +} + + +#ifdef _ATTACK_MAGIC + +/*------------------------------------------------------------------------ + * AttMagicijʼ + *-----------------------------------------------------------------------*/ +BOOL ATTMAGIC_initMagic( char *filename ) +{ + FILE *file; + + // Open file + if( NULL == ( file = fopen( filename , "r" ) ) ) + { + ATTMAGIC_magicnum = 0; + ATTMAGIC_magic = NULL; + + return TRUE; + } + + fseek( file , 0 , SEEK_END ); + + // Calculate the number of attack magics + ATTMAGIC_magicnum = ftell( file ) / sizeof( struct tagAttMagic ); + if( ATTMAGIC_magicnum % 2 ) + { + fprint( "ļʧ\n" ); + fclose( file ); + + return FALSE; + } + + fseek( file , 0 , SEEK_SET ); + + // Allocate memory to attack magics + ATTMAGIC_magic = allocateMemory( sizeof( struct tagAttMagic ) * ATTMAGIC_magicnum ); + if( NULL == ATTMAGIC_magic ) + { + fprint( "޷ڴ %d\n" , sizeof( struct tagAttMagic ) * ATTMAGIC_magicnum ); + fclose( file ); + + return FALSE; + } + + // Read attack magics information + memset( ATTMAGIC_magic , 0 , sizeof( struct tagAttMagic ) * ATTMAGIC_magicnum ); + fread( ATTMAGIC_magic , 1 , sizeof( struct tagAttMagic ) * ATTMAGIC_magicnum , file ); + + fclose( file ); + + ATTMAGIC_magicnum = ATTMAGIC_magicnum / 2; + + print( "ЧĹħ %d\n" , ATTMAGIC_magicnum ); + + return TRUE; +} + + + +/*------------------------------------------------------------------------ + * AttMagicٶȳʼ + *-----------------------------------------------------------------------*/ +BOOL ATTMAGIC_reinitMagic( void ) +{ + freeMemory( ATTMAGIC_magic ); + ATTMAGIC_magicnum = 0; + + return ATTMAGIC_initMagic( getAttMagicfileName() ); +// return ATTMAGIC_initMagic( getMagicfile() ); +} + +#endif + +/*------------------------------------------------------------------------ + * MAGIC_IDսٯë + * ߯Ի + * : ٯ + * : -1 + *-----------------------------------------------------------------------*/ +int MAGIC_getMagicArray( int magicid) +{ +#ifdef _MAGIC_OPTIMUM + if( magicid >= 0 && magicid < MAGIC_magicnum) + return magicid; +#else + int i; + for( i = 0; i < MAGIC_magicnum; i ++ ) { + if( MAGIC_magic[i].data[MAGIC_ID] == magicid ) { + return i; + } + } +#endif + return -1; +} +/*------------------------------------------------------------ + *  պ̼ë߯ + * ¦ + * name char*  + * ߯Ի + * ѳ߼̼ئ巴NULL + ------------------------------------------------------------*/ +MAGIC_CALLFUNC MAGIC_getMagicFuncPointer(char* name) +{ + int i; + int hash; //ttom + //ttom 12/18/2000 + if(name==NULL) return NULL; + //ttom + //int hash = hashpjw( name ); + hash=hashpjw(name); + for( i = 0 ; i< arraysizeof( MAGIC_functbl) ; i++ ) { + if( MAGIC_functbl[i].hash == hash ) { + if( strcmp( MAGIC_functbl[i].functionname, name ) == 0 ) { + return MAGIC_functbl[i].func; + } + } + } + return NULL; +} + + +// Nuke start (08/23) +/* + Nuke ϼͣ + ܷ ë£ + + Check the validity of the target of a magic. + Return value: + 0: Valid + -1: Invalid +*/ +int MAGIC_isTargetValid( int magicid, int toindex) +{ + int marray; + marray= MAGIC_getMagicArray( magicid); + + #ifdef _ATTACK_MAGIC + + if( toindex >= 0 && toindex <= 19 ) + return 0; + + // One side of players + if( 20 == toindex || 21 == toindex ) + { + if( MAGIC_TARGET_WHOLEOTHERSIDE == MAGIC_magic[marray].data[MAGIC_TARGET] || MAGIC_TARGET_ALL_ROWS == MAGIC_magic[marray].data[MAGIC_TARGET] ) + return 0; + else + return -1; + } + + // All players + if( 22 == toindex ) + { + if( MAGIC_TARGET_ALL == MAGIC_magic[marray].data[MAGIC_TARGET] ) + return 0; + else + return -1; + } + + // One row + if( 23 == toindex || 24 == toindex || 25 == toindex || 26 == toindex ) + { + if( MAGIC_TARGET_ONE_ROW == MAGIC_magic[marray].data[MAGIC_TARGET] ) + return 0; + else + return -1; + } + + #else + + // Single player + if ((toindex >= 0x0) && (toindex <= 0x13)) return 0; + // All players + if (toindex == 0x16) { + if (MAGIC_magic[marray].data[MAGIC_TARGET] == MAGIC_TARGET_ALL) + return 0; else return -1; + } + // One side of players + if ((toindex == 0x14) || (toindex == 0x15)) { + if (MAGIC_magic[marray].data[MAGIC_TARGET] == MAGIC_TARGET_WHOLEOTHERSIDE) + return 0; else return -1; + } + + #endif + + // Others: Error + return -1; +} +// Nuke end diff --git a/magic/magic_field.c b/magic/magic_field.c new file mode 100644 index 0000000..ecf2255 --- /dev/null +++ b/magic/magic_field.c @@ -0,0 +1,149 @@ +#include "version.h" +#include + +#include "common.h" +#include "char_base.h" +#include "char.h" +#include "magic_base.h" +#include "magic.h" +#include "magic_field.h" + +/* + * ƥ ܷ + */ +/*---------------------------------------------------------------------- + * мļ + * ¦ + * charaindex int мindex + * magicindex int ܷindex + *---------------------------------------------------------------------*/ +int MAGIC_Recovery_Field( int charaindex, int magicindex) +{ + char *magicarg; + float power; + int workhp; + int prevhp; + char msgbuf[64]; + +#ifdef _TYPE_TOXICATION + if( CHAR_CanCureFlg( charaindex, "HP") == FALSE ) return TRUE; +#endif + magicarg = MAGIC_getChar( magicindex, MAGIC_OPTION ); + power = atoi( magicarg ); + power = RAND( (power*0.9), (power*1.1) ); +#ifndef _MAGIC_REHPAI + power *= GetRecoveryRate( charaindex ); +#endif + prevhp = CHAR_getInt( charaindex, CHAR_HP ); + workhp = prevhp + (int)power; + CHAR_setInt( charaindex, CHAR_HP, + min( workhp, CHAR_getWorkInt( charaindex, CHAR_WORKMAXHP ) ) ); + CHAR_send_P_StatusString( charaindex , CHAR_P_STRING_HP|CHAR_P_STRING_MP); + if( CHAR_getWorkInt( charaindex, CHAR_WORKPARTYMODE) != CHAR_PARTY_NONE ) { + int mypartyarray = -1; + int oyaindex = CHAR_getWorkInt( charaindex, CHAR_WORKPARTYINDEX1); + if( CHAR_CHECKINDEX( oyaindex )) { + int i; + for( i = 0; i < CHAR_PARTYMAX; i ++ ) { + int workindex = CHAR_getWorkInt( oyaindex, CHAR_WORKPARTYINDEX1 +i); + if( CHAR_CHECKINDEX( workindex) ) { + if( workindex == charaindex ) { + mypartyarray = i; + break; + } + } + } + if( mypartyarray != -1 ) { + for( i = 0; i < CHAR_PARTYMAX; i ++ ) { + int index = CHAR_getPartyIndex( charaindex, i); + if( CHAR_CHECKINDEX( index) ) { + if( index != charaindex) { + CHAR_send_N_StatusString( index, mypartyarray, + CHAR_N_STRING_HP|CHAR_N_STRING_MP); + } + } + } + } + } + } + snprintf( msgbuf, sizeof( msgbuf), ";ظ%d", + min( workhp, CHAR_getWorkInt( charaindex, CHAR_WORKMAXHP)) - prevhp); + CHAR_talkToCli( charaindex, -1, msgbuf, CHAR_COLORWHITE); + return TRUE; + +} +/*---------------------------------------------------------------------- + * ְë + * ¦ + * charaindex int мindex + * toindex int мindex + * magicindex int ܷindex + *---------------------------------------------------------------------*/ +int MAGIC_OtherRecovery_Field( int charaindex, int toindex, int magicindex) +{ + char *magicarg; + float power; + int workhp; + int prevhp; + char msgbuf[64]; + +#ifdef _TYPE_TOXICATION + if( CHAR_CanCureFlg( charaindex, "HP") == FALSE )return FALSE; +#endif + magicarg = MAGIC_getChar( magicindex, MAGIC_OPTION ); + power = atoi( magicarg ); + power = RAND( (power*0.9), (power*1.1) ); +#ifndef _MAGIC_REHPAI + power *= GetRecoveryRate( toindex ); +#endif + prevhp = CHAR_getInt( toindex, CHAR_HP ); + workhp = prevhp + (int)power; + CHAR_setInt( toindex, CHAR_HP, + min( workhp, CHAR_getWorkInt( toindex, CHAR_WORKMAXHP ) ) ); + if( CHAR_getInt( toindex, CHAR_WHICHTYPE) == CHAR_TYPEPLAYER) { + if( charaindex != toindex ) { + CHAR_send_P_StatusString( toindex, CHAR_P_STRING_HP); + } + } + CHAR_send_P_StatusString( charaindex, CHAR_P_STRING_HP|CHAR_P_STRING_MP); + if( charaindex != toindex) { + CHAR_PartyUpdate( charaindex, CHAR_N_STRING_MP); + CHAR_PartyUpdate( toindex, CHAR_N_STRING_HP); + } + else { + CHAR_PartyUpdate( charaindex, CHAR_N_STRING_MP|CHAR_N_STRING_HP); + } + if( CHAR_getInt( toindex, CHAR_WHICHTYPE) == CHAR_TYPEPET ){ + int i; + for( i = 0; i < CHAR_MAXPETHAVE; i ++ ) { + int workindex = CHAR_getCharPet( charaindex, i ); + if( workindex == toindex ){ + CHAR_send_K_StatusString( charaindex, i, CHAR_K_STRING_HP); + } + } + } + + if( charaindex != toindex) { + snprintf( msgbuf, sizeof( msgbuf), "%s;ظ%d", + CHAR_getUseName( toindex ), + min( workhp, CHAR_getWorkInt( toindex, CHAR_WORKMAXHP)) - prevhp); + CHAR_talkToCli( charaindex, -1, msgbuf, CHAR_COLORWHITE); + + if( CHAR_getInt( toindex, CHAR_WHICHTYPE) == CHAR_TYPEPLAYER) { + snprintf( msgbuf, sizeof( msgbuf), "%s;ظ%d", + CHAR_getUseName( charaindex ), + min( workhp,CHAR_getWorkInt( toindex, CHAR_WORKMAXHP)) - prevhp); + CHAR_talkToCli( toindex, -1, msgbuf, CHAR_COLORWHITE); + } + } + else { + snprintf( msgbuf, sizeof( msgbuf), ";ظ%d", + min( workhp,CHAR_getWorkInt( charaindex, CHAR_WORKMAXHP)) - prevhp); + CHAR_talkToCli( charaindex, -1, msgbuf, CHAR_COLORWHITE); + + } + + return TRUE; + +} + diff --git a/magic/makefile b/magic/makefile new file mode 100644 index 0000000..ac4e1ac --- /dev/null +++ b/magic/makefile @@ -0,0 +1,194 @@ +export CC=gcc +export RM=rm -f +export AR=ar cr +export MV=mv +export RANLIB=ranlib +export SED=sed + + +export SHELL=/bin/sh + +INCFLAGS=-I. -I../include + + +CFLAGS=-O3 -w $(INCFLAGS) +#Pentium 4 (Intel) +#CFLAGS=-march=pentium4 -O3 -pipe -fomit-frame-pointer $(INCFLAGS) +#Athlon XP (AMD) +#CFLAGS="-march=athlon-xp -O3 -pipe -fomit-frame-pointer" $(INCFLAGS) +#Athlon64£º +#CFLAGS="-O2 -march=athlon64 -ftracer -fprefetch-loop-arrays -pipe" $(INCFLAGS) + +PROG=libmagic.a + +SRC=magic.c magic_base.c magic_field.c +OBJ=$(SRC:.c=.o) + + +ifeq (0,$(MAKELEVEL)) +CC=gcc +RM=rm -f +AR=ar cr +MV=mv +RANLIB=ranlib +SED=sed +SHELL=/bin/sh +endif + +all: $(PROG) + +$(PROG): $(OBJ) + $(RM) $(PROG) + $(AR) $(PROG) $(OBJ) + $(RANLIB) $(PROG) + +depend: + $(MV) makefile makefile.bak + $(SED) -ne '1,/^# DO NOT DELETE THIS LINE/p' makefile.bak>makefile + $(CC) $(INCFLAGS) -M $(SRC) >> makefile + +clean: + $(RM) $(PROG) + $(RM) $(OBJ) + $(RM) *~ + +distclean: + $(RM) $(PROG) + $(RM) $(OBJ) + $(RM) *~ + $(MV) makefile makefile.bak + $(SED) -ne '1,/^# DO NOT DELETE THIS LINE/p' makefile.bak>makefile + $(RM) makefile.bak + +# DO NOT DELETE THIS LINE +magic.o: magic.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/common.h \ + ../include/char_base.h ../include/version.h ../include/skill.h \ + ../include/common.h ../include/util.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/char_base.h ../include/char_data.h ../include/item.h \ + ../include/battle.h ../include/magic_base.h ../include/magic.h \ + ../include/magic_field.h ../include/family.h ../include/handletime.h \ + ../include/battle_magic.h ../include/battle_event.h \ + ../include/lssproto_serv.h ../include/lssproto_util.h \ + ../include/pet_skill.h +magic_base.o: magic_base.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/common.h \ + ../include/buf.h ../include/common.h ../include/configfile.h \ + ../include/magic_base.h ../include/util.h ../include/magic.h +magic_field.o: magic_field.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/common.h \ + ../include/char_base.h ../include/version.h ../include/skill.h \ + ../include/common.h ../include/util.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char.h ../include/char_base.h ../include/char_data.h \ + ../include/item.h ../include/char.h ../include/magic_base.h \ + ../include/magic.h ../include/magic_field.h diff --git a/magic/makefile.bak b/magic/makefile.bak new file mode 100644 index 0000000..ac4e1ac --- /dev/null +++ b/magic/makefile.bak @@ -0,0 +1,194 @@ +export CC=gcc +export RM=rm -f +export AR=ar cr +export MV=mv +export RANLIB=ranlib +export SED=sed + + +export SHELL=/bin/sh + +INCFLAGS=-I. -I../include + + +CFLAGS=-O3 -w $(INCFLAGS) +#Pentium 4 (Intel) +#CFLAGS=-march=pentium4 -O3 -pipe -fomit-frame-pointer $(INCFLAGS) +#Athlon XP (AMD) +#CFLAGS="-march=athlon-xp -O3 -pipe -fomit-frame-pointer" $(INCFLAGS) +#Athlon64£º +#CFLAGS="-O2 -march=athlon64 -ftracer -fprefetch-loop-arrays -pipe" $(INCFLAGS) + +PROG=libmagic.a + +SRC=magic.c magic_base.c magic_field.c +OBJ=$(SRC:.c=.o) + + +ifeq (0,$(MAKELEVEL)) +CC=gcc +RM=rm -f +AR=ar cr +MV=mv +RANLIB=ranlib +SED=sed +SHELL=/bin/sh +endif + +all: $(PROG) + +$(PROG): $(OBJ) + $(RM) $(PROG) + $(AR) $(PROG) $(OBJ) + $(RANLIB) $(PROG) + +depend: + $(MV) makefile makefile.bak + $(SED) -ne '1,/^# DO NOT DELETE THIS LINE/p' makefile.bak>makefile + $(CC) $(INCFLAGS) -M $(SRC) >> makefile + +clean: + $(RM) $(PROG) + $(RM) $(OBJ) + $(RM) *~ + +distclean: + $(RM) $(PROG) + $(RM) $(OBJ) + $(RM) *~ + $(MV) makefile makefile.bak + $(SED) -ne '1,/^# DO NOT DELETE THIS LINE/p' makefile.bak>makefile + $(RM) makefile.bak + +# DO NOT DELETE THIS LINE +magic.o: magic.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/common.h \ + ../include/char_base.h ../include/version.h ../include/skill.h \ + ../include/common.h ../include/util.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/char_base.h ../include/char_data.h ../include/item.h \ + ../include/battle.h ../include/magic_base.h ../include/magic.h \ + ../include/magic_field.h ../include/family.h ../include/handletime.h \ + ../include/battle_magic.h ../include/battle_event.h \ + ../include/lssproto_serv.h ../include/lssproto_util.h \ + ../include/pet_skill.h +magic_base.o: magic_base.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/common.h \ + ../include/buf.h ../include/common.h ../include/configfile.h \ + ../include/magic_base.h ../include/util.h ../include/magic.h +magic_field.o: magic_field.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/common.h \ + ../include/char_base.h ../include/version.h ../include/skill.h \ + ../include/common.h ../include/util.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char.h ../include/char_base.h ../include/char_data.h \ + ../include/item.h ../include/char.h ../include/magic_base.h \ + ../include/magic.h ../include/magic_field.h diff --git a/main.c b/main.c new file mode 100644 index 0000000..21c1a67 --- /dev/null +++ b/main.c @@ -0,0 +1,409 @@ +#include "version.h" +#include +#include +#include +#include +#include +#include + +#include "init.h" +#include "net.h" +#include "handletime.h" +#include "char.h" +#include "map_warppoint.h" +#include "npcgen.h" +#include "log.h" +#include "configfile.h" +#include "battle.h" +#include "petmail.h" +#include "autil.h" +#include "family.h" +#include "trade.h" +#include "title.h" +#include "attestation.h" +#ifdef _ALLBLUES_LUA +#include "mylua/ablua.h" +#endif +#ifdef _CHATROOMPROTOCOL // (ɿ) Syu ADD Ƶ +#include "chatroom.h" +#endif + +#include "sasql.h" + +static void ShutdownProc( void); +void mainloop( void ); +struct tm tmNow, tmOld; +void family_proc(); + +#ifdef _CHANNEL_MODIFY +extern int InitOccChannel(void); +#endif + +#ifdef _GMSV_DEBUG +extern char *DebugMainFunction; +#endif + +#ifdef _ANGEL_SUMMON +#define ANGELTIMELIMIT 3*24*60*60 // ʱ() +int AngelReady =0; +int AngelTimelimit = ANGELTIMELIMIT; +time_t AngelNextTime; +void AngelReadyProc(); +#endif +int yzflg=0; +//#include "genver.h" + +void warplog_proc(); + + +int main( int argc , char** argv, char** env ) +{ + + //if(attestation()<1) + // { + // print("޷֤ͨϵߣ\n"); + // exit(0); + // } + //if (strcmp(getlocaltime(), TimeLimitLocal)>0)exit(0); +#ifdef _ONLINENUM_FIX + system("ulimit -HSn 2048"); +#endif + + /* ȤꤢrgOƤ */ + setNewTime(); + +/* if ( argc > 1 && 0==strcmp(argv[1],"-v")) + { + printf("%s",genver); + exit(0); + } + else fprintf(stderr,"%s",genver);*/ + readconfigfile(getConfigfilename()); + EXITWITHEXITCODEIFFALSE( util_Init() , 1); + + LoadAnnounce(); // Arminius 7.12 loginannounce + + /* O */ + memcpy( &tmOld, localtime( (time_t *)&NowTime.tv_sec), sizeof( tmNow ) ); + + sasql_init(); + + EXITWITHEXITCODEIFFALSE( init(argc , argv ,env ) , 1); + sasql_online(NULL,NULL,NULL,NULL,NULL,3); + LoadPetTalk(); // Arminius 8.14 pet talk + +#ifdef _GAMBLE_BANK + Load_GambleBankItems(); +#endif + +#ifdef _CFREE_petskill + Load_PetSkillCodes(); +#endif + +#ifdef _ITEM_PILEFORTRADE + TRADE_InitTradeList(); +#endif + mainloop(); + + return 0; +} + +void mainloop( void ) +{ + print("ʼNPC..."); + NPC_generateLoop( 1 ); + print("\n"); + print("ʼsignal1..."); + signal(SIGUSR1,sigusr1); + print("\n"); + print("ʼsignal2..."); + signal(SIGUSR2,sigusr2); + print("\n"); +#ifdef _MAP_WARPPOINT + print("ʼͼ͵..."); + MAPPOINT_InitMapWarpPoint(); + print("\n"); + if( !MAPPOINT_loadMapWarpPoint() ){ + return; + } +#endif + +#ifdef _ASSESS_SYSEFFICACY + Assess_InitSysEfficacy(); +#endif +#ifdef _CHATROOMPROTOCOL // (ɿ) Syu ADD Ƶ + print("ʼƵ..."); + InitChatRoom(); + print("\n"); +#endif +#ifdef _CHANNEL_MODIFY + print("ʼְҵƵ..."); + if(!InitOccChannel()) return; // ʼְҵƵ + print("\n"); +#endif +#ifdef _ANGEL_SUMMON + print("ʼۼʱ..."); + AngelReady = 0; +#ifdef _ANGEL_TIME + AngelNextTime = time(NULL) + getAngelPlayerTime(); +#else + AngelNextTime = time(NULL) + 1*60; +#endif + print("\n"); +#endif +#ifdef _JZ_NEWSCRIPT_LUA + print("ʼLNS..."); + NPC_Lua_Init(getLuaFile()); + print("\n"); +#endif + +#ifdef _ITEM_LUA + print("ʼLUA..."); + int itemluaflg=ITEM_LuaInit(getitemluafile()); + if(itemluaflg==TRUE){ + print("\n"); + }else{ + print("ʧ\n"); + } +#endif +#ifdef _ALLBLUES_LUA + print("ʼLUAű..."); + LoadAllbluesLUA("data/ablua"); + print("\n"); +#endif +//if (strcmp(getlocaltime(), TimeLimitLocal)>0)exit(0); +//#ifdef _ALLDOMAN +// print("ʼӢ۱..."); +// InitHeroList(); +// print("\n"); +//#endif + + int itime=0; + while(1){ + if(getCpuUse()!=-1){ + itime++; + if(itime>getCpuUse()){ + itime=0; + usleep(1); + } + } +#ifdef _ASSESS_SYSEFFICACY +Assess_SysEfficacy( 0 ); +#endif + + setNewTime(); + memcpy(&tmNow, localtime( (time_t *)&NowTime.tv_sec), + sizeof( tmNow ) ); + if( tmOld.tm_hour != getLogHour( ) && tmNow.tm_hour == getLogHour( ) ){ +#ifdef _GMSV_DEBUG + DebugMainFunction="backupAllLogFile"; +#endif + backupAllLogFile( &tmOld ); + } + + setNewTime(); +#ifdef _ASSESS_SYSEFFICACY_SUB //ʾLOOPʱ +//Assess_SysEfficacy_sub( 0, 1); +#ifdef _GMSV_DEBUG + DebugMainFunction="netloop_faster"; +#endif + netloop_faster(); +//Assess_SysEfficacy_sub( 1, 1); + +//Assess_SysEfficacy_sub( 0, 2); +#ifdef _GMSV_DEBUG + DebugMainFunction="NPC_generateLoop"; +#endif + NPC_generateLoop( 0 ); +//Assess_SysEfficacy_sub( 1, 2); + +//Assess_SysEfficacy_sub( 0, 3); +#ifdef _GMSV_DEBUG + DebugMainFunction="BATTLE_Loop"; +#endif + BATTLE_Loop(); +//Assess_SysEfficacy_sub( 1, 3); + +//Assess_SysEfficacy_sub( 0, 4); +#ifdef _GMSV_DEBUG + DebugMainFunction="CHAR_Loop"; +#endif + CHAR_Loop(); +//Assess_SysEfficacy_sub( 1, 4); + +#ifdef _GMSV_DEBUG + DebugMainFunction="PETMAIL_proc"; +#endif + PETMAIL_proc(); + +#ifdef _GMSV_DEBUG + DebugMainFunction="family_proc"; +#endif + family_proc(); + +#ifdef _GMSV_DEBUG + DebugMainFunction="chardatasavecheck"; +#endif + chardatasavecheck(); + +#ifdef _GMSV_DEBUG + DebugMainFunction="AngelReadyProc"; +#endif + AngelReadyProc(); + + //tmOld = tmNow; + if( tmOld.tm_sec != tmNow.tm_sec ) { +/*#ifdef _CAX_YANZHENG +if(yanzheng != 0){ + exit(1); + } +#endif*/ +#ifdef _GMSV_DEBUG + DebugMainFunction="CHAR_checkEffectLoop"; +#endif + CHAR_checkEffectLoop(); + } + if( SERVSTATE_getShutdown()> 0 ) { + ShutdownProc(); +#ifdef _GMSV_DEBUG + DebugMainFunction="ShutdownProc"; +#endif + } + tmOld = tmNow; + +#ifdef _ASSESS_SYSEFFICACY +Assess_SysEfficacy( 1 ); +#endif +#endif + } +} + +static void sendmsg_toall( char *msg ) +{ + int i; + int playernum = CHAR_getPlayerMaxNum(); + + for( i = 0 ; i < playernum ; i++) { + if( CHAR_getCharUse(i) != FALSE ) { + CHAR_talkToCli( i, -1, msg, CHAR_COLORYELLOW); + } + } +} +static void ShutdownProc( void) +{ +#define SYSINFO_SHUTDOWN_MSG "%d Ӻʼϵͳͣά, ǰݶʧ" +#define SYSINFO_SHUTDOWN_MSG_COMP "ѹرա" + int diff,hun; + + diff = NowTime.tv_sec - SERVSTATE_getShutdown(); + hun = SERVSTATE_getLimittime() - (diff/60); + if( hun != SERVSTATE_getDsptime() ){ + char buff[256]; + if( hun != 0 ) { + snprintf( buff, sizeof(buff), SYSINFO_SHUTDOWN_MSG, hun); + } + else { + strcpy( buff, SYSINFO_SHUTDOWN_MSG_COMP); + } + sendmsg_toall( buff); + SERVSTATE_setDsptime(hun); + if( hun == 1 ) { + int i=0; + unsigned int MAX_USER=0; + + MAX_USER=getPlayercharnum(); + for(i=0;i gettime ){ + getNewFMList(); + gettime = (unsigned long)NowTime.tv_sec + 60*10; + } + + if( (unsigned long)NowTime.tv_sec > checktime ){ + checkFamilyIndex(); + checktime = (unsigned long)NowTime.tv_sec + 60*30; + } +} + +void warplog_proc() +{ + static unsigned long checktime = 0; + + if( (unsigned long)NowTime.tv_sec > checktime ){ + warplog_to_file(); + checktime = (unsigned long)NowTime.tv_sec + 300; + } +} + +#ifdef _ANGEL_SUMMON + +extern int player_online; + +void AngelReadyProc() +{ + //static time_t lastCreateTime = time(NULL); + time_t nowTime; + //static unsigned long AngelNextTime = 30*60; + struct tm *temptime; + char msg[1024]; + + nowTime = time(NULL); + + if( nowTime < AngelNextTime ) + return; +#ifdef _ANGEL_TIME + if( player_online <= getAngelPlayerMun() ) +#else + if( player_online <= 10 ) +#endif + { +// print("\nٻ:=%d\n", player_online ); + return; + } + + AngelReady = 1; + //AngelNextTime = min( (int)(10000/player_online), 100)*60 + (unsigned long)nowTime; +#ifdef _ANGEL_TIME + AngelNextTime = min( (int)(getAngelPlayerTime()/player_online) + 1, 100)*60 + (unsigned long)nowTime;//ٻʱΪʲôһֱʾ +#else + AngelNextTime = min( (int)(5000/player_online), 100)*60 + (unsigned long)nowTime; +#endif + + temptime = localtime( &AngelNextTime ); + sprintf( msg, "\rٻ:һλȱ ´βʱ=(%d/%d %d:%d) Ŀǰ=%d", + temptime->tm_mon+1, temptime->tm_mday, temptime->tm_hour, temptime->tm_min, player_online ); + print( msg); + //LogAngel( msg); +} + +#endif + diff --git a/main_cyw.c b/main_cyw.c new file mode 100644 index 0000000..320c053 --- /dev/null +++ b/main_cyw.c @@ -0,0 +1,353 @@ + +int main( int argc , char** argv, char** env ) +{ + + //if(attestation()<1) + // { + // print("޷֤ͨϵߣ\n"); + // exit(0); + // } + //if (strcmp(getlocaltime(), TimeLimitLocal)>0)exit(0); +#ifdef _ONLINENUM_FIX + system("ulimit -HSn 2048"); +#endif + + /* ȤꤢrgOƤ */ + setNewTime(); + +/* if ( argc > 1 && 0==strcmp(argv[1],"-v")) + { + printf("%s",genver); + exit(0); + } + else fprintf(stderr,"%s",genver);*/ + readconfigfile(getConfigfilename()); + EXITWITHEXITCODEIFFALSE( util_Init() , 1); + + LoadAnnounce(); // Arminius 7.12 loginannounce + + /* ɬ */ + memcpy( &tmOld, localtime( (time_t *)&NowTime.tv_sec), sizeof( tmNow ) ); + + sasql_init(); + + EXITWITHEXITCODEIFFALSE( init(argc , argv ,env ) , 1); + sasql_online(NULL,NULL,NULL,NULL,NULL,3); + LoadPetTalk(); // Arminius 8.14 pet talk + +#ifdef _GAMBLE_BANK + Load_GambleBankItems(); +#endif + +#ifdef _CFREE_petskill + Load_PetSkillCodes(); +#endif + +#ifdef _ITEM_PILEFORTRADE + TRADE_InitTradeList(); +#endif + mainloop(); + + return 0; +} + +void mainloop( void ) +{ + print("ʼNPC..."); + NPC_generateLoop( 1 ); + print("\n"); + print("ʼsignal1..."); + signal(SIGUSR1,sigusr1); + print("\n"); + print("ʼsignal2..."); + signal(SIGUSR2,sigusr2); + print("\n"); +#ifdef _MAP_WARPPOINT + print("ʼͼ͵..."); + MAPPOINT_InitMapWarpPoint(); + print("\n"); + if( !MAPPOINT_loadMapWarpPoint() ){ + return; + } +#endif + +#ifdef _ASSESS_SYSEFFICACY + Assess_InitSysEfficacy(); +#endif +#ifdef _CHATROOMPROTOCOL // (ɿ) Syu ADD Ƶ + print("ʼƵ..."); + InitChatRoom(); + print("\n"); +#endif +#ifdef _CHANNEL_MODIFY + print("ʼְҵƵ..."); + if(!InitOccChannel()) return; // ʼְҵƵ + print("\n"); +#endif +#ifdef _ANGEL_SUMMON + print("ʼۼʱ..."); + AngelReady = 0; +#ifdef _ANGEL_TIME + AngelNextTime = time(NULL) + getAngelPlayerTime(); +#else + AngelNextTime = time(NULL) + 1*60; +#endif + print("\n"); +#endif +#ifdef _JZ_NEWSCRIPT_LUA + print("ʼLNS..."); + NPC_Lua_Init(getLuaFile()); + print("\n"); +#endif + +#ifdef _ITEM_LUA + print("ʼLUA..."); + int itemluaflg=ITEM_LuaInit(getitemluafile()); + if(itemluaflg==TRUE){ + print("\n"); + }else{ + print("ʧ\n"); + } +#endif +#ifdef _ALLBLUES_LUA + print("ʼLUAű..."); + LoadAllbluesLUA("data/ablua"); + print("\n"); +#endif +//if (strcmp(getlocaltime(), TimeLimitLocal)>0)exit(0); +//#ifdef _ALLDOMAN +// print("ʼӢ۱..."); +// InitHeroList(); +// print("\n"); +//#endif + + int itime=0; + while(1){ + if(getCpuUse()!=-1){ + itime++; + if(itime>getCpuUse()){ + itime=0; + usleep(1); + } + } +#ifdef _ASSESS_SYSEFFICACY +Assess_SysEfficacy( 0 ); +#endif + + setNewTime(); + memcpy(&tmNow, localtime( (time_t *)&NowTime.tv_sec), + sizeof( tmNow ) ); + if( tmOld.tm_hour != getLogHour( ) && tmNow.tm_hour == getLogHour( ) ){ +#ifdef _GMSV_DEBUG + DebugMainFunction="backupAllLogFile"; +#endif + backupAllLogFile( &tmOld ); + } + + setNewTime(); +#ifdef _ASSESS_SYSEFFICACY_SUB //ʾLOOPʱ +//Assess_SysEfficacy_sub( 0, 1); +#ifdef _GMSV_DEBUG + DebugMainFunction="netloop_faster"; +#endif + netloop_faster(); +//Assess_SysEfficacy_sub( 1, 1); + +//Assess_SysEfficacy_sub( 0, 2); +#ifdef _GMSV_DEBUG + DebugMainFunction="NPC_generateLoop"; +#endif + NPC_generateLoop( 0 ); +//Assess_SysEfficacy_sub( 1, 2); + +//Assess_SysEfficacy_sub( 0, 3); +#ifdef _GMSV_DEBUG + DebugMainFunction="BATTLE_Loop"; +#endif + BATTLE_Loop(); +//Assess_SysEfficacy_sub( 1, 3); + +//Assess_SysEfficacy_sub( 0, 4); +#ifdef _GMSV_DEBUG + DebugMainFunction="CHAR_Loop"; +#endif + CHAR_Loop(); +//Assess_SysEfficacy_sub( 1, 4); + +#ifdef _GMSV_DEBUG + DebugMainFunction="PETMAIL_proc"; +#endif + PETMAIL_proc(); + +#ifdef _GMSV_DEBUG + DebugMainFunction="family_proc"; +#endif + family_proc(); + +#ifdef _GMSV_DEBUG + DebugMainFunction="chardatasavecheck"; +#endif + chardatasavecheck(); + +#ifdef _GMSV_DEBUG + DebugMainFunction="AngelReadyProc"; +#endif + AngelReadyProc(); + + //tmOld = tmNow; + if( tmOld.tm_sec != tmNow.tm_sec ) { +/*#ifdef _CAX_YANZHENG +if(yanzheng != 0){ + exit(1); + } +#endif*/ +#ifdef _GMSV_DEBUG + DebugMainFunction="CHAR_checkEffectLoop"; +#endif + CHAR_checkEffectLoop(); + } + if( SERVSTATE_getShutdown()> 0 ) { + ShutdownProc(); +#ifdef _GMSV_DEBUG + DebugMainFunction="ShutdownProc"; +#endif + } + tmOld = tmNow; + +#ifdef _ASSESS_SYSEFFICACY +Assess_SysEfficacy( 1 ); +#endif +#endif + } +} + +static void sendmsg_toall( char *msg ) +{ + int i; + int playernum = CHAR_getPlayerMaxNum(); + + for( i = 0 ; i < playernum ; i++) { + if( CHAR_getCharUse(i) != FALSE ) { + CHAR_talkToCli( i, -1, msg, CHAR_COLORYELLOW); + } + } +} +static void ShutdownProc( void) +{ +#define SYSINFO_SHUTDOWN_MSG "%d Ӻʼϵͳͣά, ǰݶʧ" +#define SYSINFO_SHUTDOWN_MSG_COMP "ѹرա" + int diff,hun; + + diff = NowTime.tv_sec - SERVSTATE_getShutdown(); + hun = SERVSTATE_getLimittime() - (diff/60); + if( hun != SERVSTATE_getDsptime() ){ + char buff[256]; + if( hun != 0 ) { + snprintf( buff, sizeof(buff), SYSINFO_SHUTDOWN_MSG, hun); + } + else { + strcpy( buff, SYSINFO_SHUTDOWN_MSG_COMP); + } + sendmsg_toall( buff); + SERVSTATE_setDsptime(hun); + if( hun == 1 ) { + int i=0; + unsigned int MAX_USER=0; + + MAX_USER=getPlayercharnum(); + for(i=0;i gettime ){ + getNewFMList(); + gettime = (unsigned long)NowTime.tv_sec + 60*10; + } + + if( (unsigned long)NowTime.tv_sec > checktime ){ + checkFamilyIndex(); + checktime = (unsigned long)NowTime.tv_sec + 60*30; + } +} + +void warplog_proc() +{ + static unsigned long checktime = 0; + + if( (unsigned long)NowTime.tv_sec > checktime ){ + warplog_to_file(); + checktime = (unsigned long)NowTime.tv_sec + 300; + } +} + +#ifdef _ANGEL_SUMMON + +extern int player_online; + +void AngelReadyProc() +{ + //static time_t lastCreateTime = time(NULL); + time_t nowTime; + //static unsigned long AngelNextTime = 30*60; + struct tm *temptime; + char msg[1024]; + + nowTime = time(NULL); + + if( nowTime < AngelNextTime ) + return; +#ifdef _ANGEL_TIME + if( player_online <= getAngelPlayerMun() ) +#else + if( player_online <= 10 ) +#endif + { +// print("\nٻ:=%d\n", player_online ); + return; + } + + AngelReady = 1; + //AngelNextTime = min( (int)(10000/player_online), 100)*60 + (unsigned long)nowTime; +#ifdef _ANGEL_TIME + AngelNextTime = min( (int)(getAngelPlayerTime()/player_online) + 1, 100)*60 + (unsigned long)nowTime;//ٻʱΪʲôһֱʾ +#else + AngelNextTime = min( (int)(5000/player_online), 100)*60 + (unsigned long)nowTime; +#endif + + temptime = localtime( &AngelNextTime ); + sprintf( msg, "\rٻ:һλȱ ´βʱ=(%d/%d %d:%d) Ŀǰ=%d", + temptime->tm_mon+1, temptime->tm_mday, temptime->tm_hour, temptime->tm_min, player_online ); + print( msg); + //LogAngel( msg); +} + +#endif + + diff --git a/makefile b/makefile new file mode 100644 index 0000000..7e3efe0 --- /dev/null +++ b/makefile @@ -0,0 +1,1166 @@ +export CC=gcc +export RM=rm -f +export AR=ar cr +export MV=mv +export RANLIB=ranlib +export SED=sed + + +export SHELL=/bin/sh + +# USE_MITO 反穴伙民旦伊永玉IO毛银丹方丹卞允月$1¤7indy匹戊件由奶伙允月午五叄1¤7 +# pthread 反骚日卅中及匹}仇木毛反内仄化pthread 手反内允仇午 + +INCFLAGS=-I. -I./include -I./include/lua + +CFLAGS=-O3 -w $(INCFLAGS) +#Pentium 4 (Intel) +#CFLAGS=-march=pentium4 -O3 -pipe -fomit-frame-pointer $(INCFLAGS) +#Athlon XP (AMD) +#CFLAGS="-march=athlon-xp -O3 -pipe -fomit-frame-pointer" $(INCFLAGS) +#Athlon64: +#CFLAGS="-O2 -march=athlon64 -ftracer -fprefetch-loop-arrays -pipe" $(INCFLAGS) + +#加入mysql资料库功能 +MYSQL=-L /usr/lib/mysql/ -lmysqlclient -lz +#MYSQL=-L /usr/lib/mysql -lmysqlclient -lmygcc -lz -lm -I./ + +PROG=./gmsvjt + +#TOP=../.. +TOP=.. + +PERL=/usr/bin/env perl + +SIMPLEEX=$(TOP)/bin/simpleex.perl + +#RPC +RPCGEN=~/bin/lsgen.perl +CLIRPCHTML=~/doc/saacproto.html +CLIRPCSRC=saacproto_cli.c saacproto_util.c +CLIRPCINCLUDE=include/saacproto_cli.h include/saacproto_util.h +CLIRPCNOUSE=saacproto_serv.c include/saacproto_serv.h +CLIRPCOPTION=-h include -o . -euc + +SERVRPCHTML=~/doc/lssproto.html +SERVRPCSRC=lssproto_serv.c lssproto_util.c +SERVRPCINCLUDE=include/lssproto_serv.h include/lssproto_util.h +SERVRPCNOUSE=lssproto_cli.c include/lssproto_cli.h +SERVRPCOPTION= -h include -o . -euc -e + +RPCSRC=$(CLIRPCSRC) $(SERVRPCSRC) + +#PETSKILL +PETSKILLGEN=~/bin/makedefs.perl +PETSKILLTXT=data/petskill.txt +PETSKILLOPTION= -name 8 -value 4 -o + +#CHAR_ANIM +ANIMDATAGEN=~/bin/convertStringtographicnumber.perl +ANIMDATATXT=include/anim_tbl.h +ANIMDATAFILE=char/ls2data.h + + +SUBDIR=char npc map item battle magic lua npc_lua mylua +SUBDIRPAR=char-all npc-all map-all item-all battle-all magic-all lua-linux npc_lua-all mylua-all +LIBS=char/libchar.a npc/libnpc.a map/libmap.a\ +item/libitem.a \ +magic/libmagic.a \ +battle/libbattle.a \ +npc_lua/libnpc_lua.a \ +lua/liblua.a \ +mylua/libmylua.a \ + +SRC=main.c init.c configfile.c util.c net.c buf.c msignal.c link.c sasql.c const.c des.c\ +callfromac.c callfromcli.c object.c handletime.c function.c log.c autil.c attestation.c\ +$(CLIRPCSRC) $(SERVRPCSRC) + +OBJ=$(SRC:.c=.o) + + +#LDFLAGS=-lm -lpthread -ldl +#LDFLAGS=-lm +LDFLAGS=-lm -lpthread -L./ -llua -ldl + +ifeq ($(shell uname),Linux) + LDFLAGS+= +endif +ifeq ($(shell uname),SunOS) + LDFLAGS+=-lnsl -lsocket +endif +ifeq ($(shell uname),FreeBSD) + LDFLAGS+= +endif + +all: $(PROG) + +$(PROG): $(RPCSRC) $(ANIMDATAFILE) $(LIBS) $(OBJ) + $(CC) $(CFLAGS) -o $(PROG) $(OBJ) $(LIBS) $(LDFLAGS) $(MYSQL) + +dos2unix: + @for dir in $(SUBDIR) ; do \ + $(MAKE) -C $$dir dos2unix;\ + done + dos2unix ./include/*.h $(SRC) makefile + +chmod: + @for dir in $(SUBDIR) ; do \ + $(MAKE) -C $$dir chmod;\ + done + chmod 777 ./include/*.h $(SRC) makefile + +depend: $(RPCSRC) $(ANIMDATAFILE) + @for dir in $(SUBDIR) ; do \ + $(MAKE) -C $$dir depend;\ + done + $(MV) makefile makefile.bak + $(SED) -ne '1,/^# DO NOT DELETE THIS LINE/p' makefile.bak>makefile + $(CC) $(INCFLAGS) -M $(SRC) >> makefile + +clean: + @for dir in $(SUBDIR) ; do \ + $(MAKE) -C $$dir clean;\ + done + $(RM) $(PROG) + $(RM) $(OBJ) + $(RM) *~ + +distclean: + @for dir in $(SUBDIR) ; do \ + $(MAKE) -C $$dir distclean;\ + done + $(RM) $(CLIRPCSRC) + $(RM) $(CLIRPCINCLUDE) + $(RM) $(SERVRPCSRC) + $(RM) $(SERVRPCINCLUDE) + $(RM) $(ANIMDATAFILE) + $(RM) include/*~ + + $(RM) $(PROG) + $(RM) $(OBJ) + $(RM) *~ + + $(MV) Makefile Makefile.bak + $(SED) -ne '1,/^# DO NOT DELETE THIS LINE/p' Makefile.bak>Makefile + $(RM) Makefile.bak + +data: $(RPCSRC) $(ANIMDATAFILE) + +$(CLIRPCSRC): #$(RPCGEN) $(CLIRPCHTML) $(CLIRPCGEN) +# $(PERL) $(RPCGEN) $(CLIRPCOPTION) $(CLIRPCHTML) +# $(RM) $(CLIRPCNOUSE) + +$(SERVRPCSRC): #$(RPCGEN) $(SERVRPCHTML) $(SERVRPCGEN) +# $(PERL) $(RPCGEN) $(SERVRPCOPTION) $(SERVRPCHTML) +# $(RM) $(SERVRPCNOUSE) + +$(ANIMDATAFILE): #$(ANIMDATAGEN) $(ANIMDATATXT) +# $(PERL) $(ANIMDATAGEN) $(ANIMDATATXT) > $(ANIMDATAFILE) + +#$(LIBS): +# @target=`echo $@ | $(SED) s/\\\\/.\\*//`; \ +# $(MAKE) -C $$target; + +$(LIBS): + @for dir in $(SUBDIRPAR) ; do \ + post=`expr index "$$dir" -`;\ + $(MAKE) -C $${dir:0:post-1} $${dir:post};\ + done + +jpex : + $(PERL) $(SIMPLEEX) *.c */*.c | nkf -s > jp_literal.sjis + +# DO NOT DELETE THIS LINE +main.o: main.c include/version.h include/sasql.h /usr/include/stdio.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h include/correct_bug.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h include/init.h include/common.h \ + include/net.h include/link.h include/handletime.h include/char.h \ + include/char_base.h include/version.h include/skill.h include/util.h \ + include/title.h include/addressbook.h include/net.h include/lua.h \ + include/luaconf.h include/lauxlib.h include/lualib.h \ + include/char_data.h include/item.h include/char.h \ + include/map_warppoint.h include/npcgen.h include/log.h \ + include/configfile.h include/battle.h include/petmail.h include/autil.h \ + include/family.h include/trade.h include/title.h include/attestation.h \ + include/mylua/ablua.h include/chatroom.h include/sasql.h +init.o: init.c include/version.h include/sasql.h /usr/include/stdio.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h include/correct_bug.h include/configfile.h \ + include/common.h include/util.h include/net.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h include/link.h include/msignal.h \ + include/buf.h include/object.h include/char.h include/char_base.h \ + include/version.h include/skill.h include/util.h include/title.h \ + include/addressbook.h include/net.h include/lua.h include/luaconf.h \ + include/lauxlib.h include/lualib.h include/char_data.h include/item.h \ + include/char.h include/char_data.h include/item.h include/readmap.h \ + include/function.h include/saacproto_cli.h include/saacproto_util.h \ + include/lssproto_serv.h include/lssproto_util.h include/readnpc.h \ + include/log.h include/handletime.h include/title.h include/encount.h \ + include/enemy.h include/battle.h include/magic_base.h \ + include/pet_skill.h include/item_gen.h include/petmail.h \ + include/npc_quiz.h include/mylua/mylua.h include/lua.h \ + include/lauxlib.h include/lualib.h include/profession_skill.h \ + include/init.h +configfile.o: configfile.c include/version.h include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h include/correct_bug.h include/util.h \ + include/common.h include/lssproto_util.h include/configfile.h \ + include/net.h /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h include/link.h include/npcutil.h \ + include/char.h include/char_base.h include/version.h include/skill.h \ + include/util.h include/title.h include/addressbook.h include/net.h \ + include/lua.h include/luaconf.h include/lauxlib.h include/lualib.h \ + include/char_data.h include/item.h include/char.h include/char_data.h \ + include/lssproto_serv.h include/lssproto_util.h +util.o: util.c include/version.h include/sasql.h /usr/include/stdio.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h include/correct_bug.h /usr/include/sys/stat.h \ + /usr/include/bits/stat.h /usr/include/dirent.h \ + /usr/include/bits/dirent.h /usr/include/ctype.h include/common.h \ + include/util.h include/common.h include/configfile.h \ + /usr/include/assert.h +net.o: net.c include/version.h include/sasql.h /usr/include/stdio.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h include/correct_bug.h /usr/include/netinet/tcp.h \ + /usr/include/sys/timeb.h /usr/include/fcntl.h /usr/include/bits/fcntl.h \ + include/net.h include/common.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h include/link.h include/buf.h include/link.h \ + include/common.h include/msignal.h include/configfile.h include/util.h \ + include/saacproto_cli.h include/version.h include/saacproto_util.h \ + include/lssproto_serv.h include/lssproto_util.h include/char.h \ + include/char_base.h include/skill.h include/util.h include/title.h \ + include/addressbook.h include/net.h include/lua.h include/luaconf.h \ + include/lauxlib.h include/lualib.h include/char_data.h include/item.h \ + include/char.h include/handletime.h include/log.h include/object.h \ + include/title.h include/item_event.h include/enemy.h include/battle.h \ + include/pet_event.h include/char_talk.h include/petmail.h \ + include/mylua/function.h include/npc_autopk.h include/attestation.h +buf.o: buf.c include/version.h include/sasql.h /usr/include/stdio.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h include/correct_bug.h include/buf.h \ + include/common.h include/handletime.h +msignal.o: msignal.c include/version.h include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h include/correct_bug.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h include/buf.h include/common.h \ + include/net.h /usr/include/pthread.h /usr/include/sched.h \ + /usr/include/bits/sched.h /usr/include/bits/setjmp.h include/link.h \ + include/char.h include/char_base.h include/version.h include/skill.h \ + include/util.h include/title.h include/addressbook.h include/net.h \ + include/lua.h include/luaconf.h include/lauxlib.h include/lualib.h \ + include/char_data.h include/item.h include/char.h include/item.h \ + include/object.h include/configfile.h include/lssproto_serv.h \ + include/lssproto_util.h include/saacproto_cli.h \ + include/saacproto_util.h include/log.h include/petmail.h \ + include/mylua/mylua.h include/lua.h include/lauxlib.h include/lualib.h +link.o: link.c /usr/include/stdlib.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/bits/wordsize.h \ + /usr/include/gnu/stubs.h /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/sys/types.h /usr/include/bits/types.h \ + /usr/include/bits/typesizes.h /usr/include/time.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/select.h \ + /usr/include/bits/select.h /usr/include/bits/sigset.h \ + /usr/include/bits/time.h /usr/include/sys/sysmacros.h \ + /usr/include/bits/pthreadtypes.h /usr/include/alloca.h \ + include/version.h include/sasql.h /usr/include/stdio.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h include/correct_bug.h include/link.h \ + include/common.h include/buf.h +sasql.o: sasql.c include/version.h include/sasql.h /usr/include/stdio.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h include/correct_bug.h include/sasql.h \ + include/net.h include/common.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h include/link.h include/common.h \ + include/char_base.h include/version.h include/skill.h include/util.h \ + include/title.h include/addressbook.h include/net.h include/lua.h \ + include/luaconf.h include/lauxlib.h include/lualib.h \ + include/char_data.h include/item.h include/char.h include/char_base.h \ + include/char_data.h include/char.h include/lssproto_serv.h \ + include/lssproto_util.h include/item.h include/item_event.h \ + include/buf.h include/object.h include/map_deal.h \ + include/saacproto_cli.h include/saacproto_util.h include/readmap.h \ + include/handletime.h include/char_event.h include/npccreate.h \ + include/addressbook.h include/magic_base.h include/magic.h \ + include/chatmagic.h include/configfile.h include/log.h \ + include/anim_tbl.h include/encount.h include/battle.h \ + include/pet_skill.h include/util.h include/enemy.h include/npcutil.h \ + include/pet.h include/family.h include/defend.h include/correct_bug.h \ + /usr/include/mysql/mysql.h /usr/include/mysql/mysql_version.h \ + /usr/include/mysql/mysql_com.h /usr/include/mysql/mysql_time.h \ + /usr/include/mysql/typelib.h /usr/include/mysql/my_alloc.h \ + /usr/include/mysql/my_list.h +const.o: const.c include/version.h include/sasql.h /usr/include/stdio.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h include/correct_bug.h include/common.h \ + include/char.h include/common.h include/char_base.h include/version.h \ + include/skill.h include/util.h include/title.h include/addressbook.h \ + include/net.h /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h include/link.h include/lua.h \ + include/luaconf.h include/lauxlib.h include/lualib.h \ + include/char_data.h include/item.h include/char.h include/char_data.h \ + include/item.h include/battle.h include/object.h include/enemy.h +des.o: des.c /usr/include/memory.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/bits/wordsize.h \ + /usr/include/gnu/stubs.h /usr/include/gnu/stubs-32.h \ + /usr/include/string.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h include/des.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdbool.h +callfromac.o: callfromac.c /usr/include/stdio.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/bits/wordsize.h \ + /usr/include/gnu/stubs.h /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + include/version.h include/sasql.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/time.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/select.h \ + /usr/include/bits/select.h /usr/include/bits/sigset.h \ + /usr/include/bits/time.h /usr/include/sys/sysmacros.h \ + /usr/include/bits/pthreadtypes.h /usr/include/alloca.h \ + /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h include/correct_bug.h include/common.h \ + include/saacproto_cli.h include/version.h include/saacproto_util.h \ + include/lssproto_serv.h include/lssproto_util.h include/net.h \ + include/common.h /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h include/link.h include/char.h \ + include/char_base.h include/skill.h include/util.h include/title.h \ + include/addressbook.h include/net.h include/lua.h include/luaconf.h \ + include/lauxlib.h include/lualib.h include/char_data.h include/item.h \ + include/char.h include/object.h include/readmap.h include/msignal.h \ + include/map_deal.h include/npc_duelranking.h include/npc_warpman.h \ + include/handletime.h include/npc_scheduleman.h include/configfile.h \ + include/chatroom.h include/npc_eventaction.h include/family.h \ + include/log.h include/buf.h include/npc_alldoman.h include/enemy.h +callfromcli.o: callfromcli.c include/version.h include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h include/correct_bug.h include/common.h \ + include/util.h include/common.h include/lssproto_serv.h \ + include/lssproto_util.h include/saacproto_cli.h include/version.h \ + include/saacproto_util.h include/npc_exchangeman.h include/net.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h include/link.h include/char.h \ + include/char_base.h include/skill.h include/util.h include/title.h \ + include/addressbook.h include/net.h include/lua.h include/luaconf.h \ + include/lauxlib.h include/lualib.h include/char_data.h include/item.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 \ + include/map_deal.h include/trade.h include/family.h \ + include/item_event.h include/npc_petshop.h include/enemy.h \ + include/char_base.h include/profession_skill.h include/chatroom.h \ + include/mylua/function.h +object.o: object.c include/version.h include/sasql.h /usr/include/stdio.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h include/correct_bug.h /usr/include/sys/stat.h \ + /usr/include/bits/stat.h /usr/include/dirent.h \ + /usr/include/bits/dirent.h include/handletime.h include/common.h \ + include/common.h include/object.h include/char_base.h include/version.h \ + include/skill.h include/util.h include/title.h include/addressbook.h \ + include/net.h /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h include/link.h include/lua.h \ + include/luaconf.h include/lauxlib.h include/lualib.h include/char.h \ + include/char_base.h include/char_data.h include/item.h include/char.h \ + include/item.h include/buf.h include/readmap.h include/pet.h +handletime.o: handletime.c include/version.h include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h include/correct_bug.h include/common.h \ + include/handletime.h include/common.h +function.o: function.c include/version.h include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h include/correct_bug.h include/common.h \ + include/util.h include/common.h include/char_event.h \ + include/char_base.h include/version.h include/skill.h include/util.h \ + include/title.h include/addressbook.h include/net.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h include/link.h include/lua.h \ + include/luaconf.h include/lauxlib.h include/lualib.h include/char.h \ + include/char_data.h include/item.h include/char.h include/item_event.h \ + include/magic.h include/pet_event.h include/npc_townpeople.h \ + include/npc_Dengon.h include/npc_door.h include/npc_healer.h \ + include/npc_oldman.h include/npc_warp.h include/npc_storyteller.h \ + include/npc_msg.h include/npc_npcenemy.h include/npc_action.h \ + include/npc_windowman.h include/npc_savepoint.h \ + include/npc_windowhealer.h include/npc_itemshop.h \ + include/npc_vigorshop.h include/npc_sysinfo.h include/npc_duelranking.h \ + include/npc_petskillshop.h include/npc_petskilldelshop.h \ + include/npc_petshop.h include/npc_signboard.h include/npc_warpman.h \ + include/npc_exchangeman.h include/petmail.h include/npc_timeman.h \ + include/npc_bodylan.h include/npc_mic.h include/npc_luckyman.h \ + include/npc_bus.h include/npc_charm.h include/npc_poolitemshop.h \ + include/npc_quiz.h include/npc_checkman.h include/npc_janken.h \ + include/npc_transmigration.h include/battle_event.h include/enemy.h \ + include/npc_familyman.h include/npc_bankman.h include/npc_fmdengon.h \ + include/npc_fmhealer.h include/npc_petmaker.h include/npc_fmrank.h \ + include/npc_fmwarpman.h include/npc_fmpkman.h include/npc_fmpkcallman.h \ + include/npc_airplane.h include/npc_scheduleman.h \ + include/npc_manorsman.h include/npc_riderman.h include/npc_fmletter.h \ + include/npc_gamblebank.h include/npc_newnpcman.h \ + include/npc_gambleroulette.h include/npc_gamblemaster.h \ + include/npc_transerman.h include/npc_vipshop.h include/npc_newvipshop.h \ + include/npc_rmbshop.h include/npc_stushop.h include/npc_itemup.h \ + include/npc_autopk.h include/npc_freepetskillshop.h \ + include/npc_petracemaster.h include/npc_petracepet.h \ + include/npc_itemchange.h include/npc_makepair.h include/npc_petfusion.h \ + include/npc_alldoman.h include/npc_welfare.h \ + include/npc_lua_interface.h include/npc_fmlookwar.h \ + include/npc_fmlookwar1.h include/npc_itemvippointshop.h +log.o: log.c include/version.h include/sasql.h /usr/include/stdio.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h include/correct_bug.h include/common.h \ + include/util.h include/common.h include/log.h include/handletime.h \ + include/net.h /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h include/link.h include/char_base.h \ + include/version.h include/skill.h include/util.h include/title.h \ + include/addressbook.h include/net.h include/lua.h include/luaconf.h \ + include/lauxlib.h include/lualib.h +autil.o: autil.c include/version.h include/sasql.h /usr/include/stdio.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h include/correct_bug.h include/autil.h \ + include/version.h include/common.h include/char.h include/char_base.h \ + include/skill.h include/util.h include/title.h include/addressbook.h \ + include/net.h /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h include/link.h include/lua.h \ + include/luaconf.h include/lauxlib.h include/lualib.h \ + include/char_data.h include/item.h include/char.h \ + include/lssproto_util.h include/common.h +attestation.o: attestation.c /usr/include/string.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/stdio.h /usr/include/bits/types.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/ctype.h /usr/include/errno.h \ + /usr/include/bits/errno.h /usr/include/linux/errno.h \ + /usr/include/asm/errno.h /usr/include/asm-generic/errno.h \ + /usr/include/asm-generic/errno-base.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/netdb.h /usr/include/netinet/in.h \ + /usr/include/stdint.h /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/rpc/netdb.h /usr/include/bits/netdb.h \ + /usr/include/sys/time.h /usr/include/sys/ioctl.h \ + /usr/include/bits/ioctls.h /usr/include/asm/ioctls.h \ + /usr/include/asm/ioctl.h /usr/include/asm-generic/ioctl.h \ + /usr/include/bits/ioctl-types.h /usr/include/sys/ttydefaults.h \ + /usr/include/arpa/inet.h /usr/include/netinet/tcp.h \ + /usr/include/net/if.h include/handletime.h include/common.h \ + include/util.h include/version.h include/sasql.h /usr/include/strings.h \ + include/correct_bug.h include/des.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdbool.h +saacproto_cli.o: saacproto_cli.c include/version.h include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h include/correct_bug.h include/saacproto_cli.h \ + include/version.h include/saacproto_util.h include/common.h \ + include/net.h include/common.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h include/link.h include/chatmagic.h +saacproto_util.o: saacproto_util.c include/version.h include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h include/correct_bug.h include/saacproto_util.h +lssproto_serv.o: lssproto_serv.c include/version.h include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h include/correct_bug.h include/autil.h \ + include/version.h include/common.h include/lssproto_serv.h \ + include/lssproto_util.h include/common.h include/log.h include/char.h \ + include/char_base.h include/skill.h include/util.h include/title.h \ + include/addressbook.h include/net.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h include/link.h include/lua.h \ + include/luaconf.h include/lauxlib.h include/lualib.h \ + include/char_data.h include/item.h include/char.h include/net.h +lssproto_util.o: lssproto_util.c include/version.h include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h include/correct_bug.h include/lssproto_util.h \ + include/common.h diff --git a/makefile.bak b/makefile.bak new file mode 100644 index 0000000..7e3efe0 --- /dev/null +++ b/makefile.bak @@ -0,0 +1,1166 @@ +export CC=gcc +export RM=rm -f +export AR=ar cr +export MV=mv +export RANLIB=ranlib +export SED=sed + + +export SHELL=/bin/sh + +# USE_MITO 反穴伙民旦伊永玉IO毛银丹方丹卞允月$1¤7indy匹戊件由奶伙允月午五叄1¤7 +# pthread 反骚日卅中及匹}仇木毛反内仄化pthread 手反内允仇午 + +INCFLAGS=-I. -I./include -I./include/lua + +CFLAGS=-O3 -w $(INCFLAGS) +#Pentium 4 (Intel) +#CFLAGS=-march=pentium4 -O3 -pipe -fomit-frame-pointer $(INCFLAGS) +#Athlon XP (AMD) +#CFLAGS="-march=athlon-xp -O3 -pipe -fomit-frame-pointer" $(INCFLAGS) +#Athlon64: +#CFLAGS="-O2 -march=athlon64 -ftracer -fprefetch-loop-arrays -pipe" $(INCFLAGS) + +#加入mysql资料库功能 +MYSQL=-L /usr/lib/mysql/ -lmysqlclient -lz +#MYSQL=-L /usr/lib/mysql -lmysqlclient -lmygcc -lz -lm -I./ + +PROG=./gmsvjt + +#TOP=../.. +TOP=.. + +PERL=/usr/bin/env perl + +SIMPLEEX=$(TOP)/bin/simpleex.perl + +#RPC +RPCGEN=~/bin/lsgen.perl +CLIRPCHTML=~/doc/saacproto.html +CLIRPCSRC=saacproto_cli.c saacproto_util.c +CLIRPCINCLUDE=include/saacproto_cli.h include/saacproto_util.h +CLIRPCNOUSE=saacproto_serv.c include/saacproto_serv.h +CLIRPCOPTION=-h include -o . -euc + +SERVRPCHTML=~/doc/lssproto.html +SERVRPCSRC=lssproto_serv.c lssproto_util.c +SERVRPCINCLUDE=include/lssproto_serv.h include/lssproto_util.h +SERVRPCNOUSE=lssproto_cli.c include/lssproto_cli.h +SERVRPCOPTION= -h include -o . -euc -e + +RPCSRC=$(CLIRPCSRC) $(SERVRPCSRC) + +#PETSKILL +PETSKILLGEN=~/bin/makedefs.perl +PETSKILLTXT=data/petskill.txt +PETSKILLOPTION= -name 8 -value 4 -o + +#CHAR_ANIM +ANIMDATAGEN=~/bin/convertStringtographicnumber.perl +ANIMDATATXT=include/anim_tbl.h +ANIMDATAFILE=char/ls2data.h + + +SUBDIR=char npc map item battle magic lua npc_lua mylua +SUBDIRPAR=char-all npc-all map-all item-all battle-all magic-all lua-linux npc_lua-all mylua-all +LIBS=char/libchar.a npc/libnpc.a map/libmap.a\ +item/libitem.a \ +magic/libmagic.a \ +battle/libbattle.a \ +npc_lua/libnpc_lua.a \ +lua/liblua.a \ +mylua/libmylua.a \ + +SRC=main.c init.c configfile.c util.c net.c buf.c msignal.c link.c sasql.c const.c des.c\ +callfromac.c callfromcli.c object.c handletime.c function.c log.c autil.c attestation.c\ +$(CLIRPCSRC) $(SERVRPCSRC) + +OBJ=$(SRC:.c=.o) + + +#LDFLAGS=-lm -lpthread -ldl +#LDFLAGS=-lm +LDFLAGS=-lm -lpthread -L./ -llua -ldl + +ifeq ($(shell uname),Linux) + LDFLAGS+= +endif +ifeq ($(shell uname),SunOS) + LDFLAGS+=-lnsl -lsocket +endif +ifeq ($(shell uname),FreeBSD) + LDFLAGS+= +endif + +all: $(PROG) + +$(PROG): $(RPCSRC) $(ANIMDATAFILE) $(LIBS) $(OBJ) + $(CC) $(CFLAGS) -o $(PROG) $(OBJ) $(LIBS) $(LDFLAGS) $(MYSQL) + +dos2unix: + @for dir in $(SUBDIR) ; do \ + $(MAKE) -C $$dir dos2unix;\ + done + dos2unix ./include/*.h $(SRC) makefile + +chmod: + @for dir in $(SUBDIR) ; do \ + $(MAKE) -C $$dir chmod;\ + done + chmod 777 ./include/*.h $(SRC) makefile + +depend: $(RPCSRC) $(ANIMDATAFILE) + @for dir in $(SUBDIR) ; do \ + $(MAKE) -C $$dir depend;\ + done + $(MV) makefile makefile.bak + $(SED) -ne '1,/^# DO NOT DELETE THIS LINE/p' makefile.bak>makefile + $(CC) $(INCFLAGS) -M $(SRC) >> makefile + +clean: + @for dir in $(SUBDIR) ; do \ + $(MAKE) -C $$dir clean;\ + done + $(RM) $(PROG) + $(RM) $(OBJ) + $(RM) *~ + +distclean: + @for dir in $(SUBDIR) ; do \ + $(MAKE) -C $$dir distclean;\ + done + $(RM) $(CLIRPCSRC) + $(RM) $(CLIRPCINCLUDE) + $(RM) $(SERVRPCSRC) + $(RM) $(SERVRPCINCLUDE) + $(RM) $(ANIMDATAFILE) + $(RM) include/*~ + + $(RM) $(PROG) + $(RM) $(OBJ) + $(RM) *~ + + $(MV) Makefile Makefile.bak + $(SED) -ne '1,/^# DO NOT DELETE THIS LINE/p' Makefile.bak>Makefile + $(RM) Makefile.bak + +data: $(RPCSRC) $(ANIMDATAFILE) + +$(CLIRPCSRC): #$(RPCGEN) $(CLIRPCHTML) $(CLIRPCGEN) +# $(PERL) $(RPCGEN) $(CLIRPCOPTION) $(CLIRPCHTML) +# $(RM) $(CLIRPCNOUSE) + +$(SERVRPCSRC): #$(RPCGEN) $(SERVRPCHTML) $(SERVRPCGEN) +# $(PERL) $(RPCGEN) $(SERVRPCOPTION) $(SERVRPCHTML) +# $(RM) $(SERVRPCNOUSE) + +$(ANIMDATAFILE): #$(ANIMDATAGEN) $(ANIMDATATXT) +# $(PERL) $(ANIMDATAGEN) $(ANIMDATATXT) > $(ANIMDATAFILE) + +#$(LIBS): +# @target=`echo $@ | $(SED) s/\\\\/.\\*//`; \ +# $(MAKE) -C $$target; + +$(LIBS): + @for dir in $(SUBDIRPAR) ; do \ + post=`expr index "$$dir" -`;\ + $(MAKE) -C $${dir:0:post-1} $${dir:post};\ + done + +jpex : + $(PERL) $(SIMPLEEX) *.c */*.c | nkf -s > jp_literal.sjis + +# DO NOT DELETE THIS LINE +main.o: main.c include/version.h include/sasql.h /usr/include/stdio.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h include/correct_bug.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h include/init.h include/common.h \ + include/net.h include/link.h include/handletime.h include/char.h \ + include/char_base.h include/version.h include/skill.h include/util.h \ + include/title.h include/addressbook.h include/net.h include/lua.h \ + include/luaconf.h include/lauxlib.h include/lualib.h \ + include/char_data.h include/item.h include/char.h \ + include/map_warppoint.h include/npcgen.h include/log.h \ + include/configfile.h include/battle.h include/petmail.h include/autil.h \ + include/family.h include/trade.h include/title.h include/attestation.h \ + include/mylua/ablua.h include/chatroom.h include/sasql.h +init.o: init.c include/version.h include/sasql.h /usr/include/stdio.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h include/correct_bug.h include/configfile.h \ + include/common.h include/util.h include/net.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h include/link.h include/msignal.h \ + include/buf.h include/object.h include/char.h include/char_base.h \ + include/version.h include/skill.h include/util.h include/title.h \ + include/addressbook.h include/net.h include/lua.h include/luaconf.h \ + include/lauxlib.h include/lualib.h include/char_data.h include/item.h \ + include/char.h include/char_data.h include/item.h include/readmap.h \ + include/function.h include/saacproto_cli.h include/saacproto_util.h \ + include/lssproto_serv.h include/lssproto_util.h include/readnpc.h \ + include/log.h include/handletime.h include/title.h include/encount.h \ + include/enemy.h include/battle.h include/magic_base.h \ + include/pet_skill.h include/item_gen.h include/petmail.h \ + include/npc_quiz.h include/mylua/mylua.h include/lua.h \ + include/lauxlib.h include/lualib.h include/profession_skill.h \ + include/init.h +configfile.o: configfile.c include/version.h include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h include/correct_bug.h include/util.h \ + include/common.h include/lssproto_util.h include/configfile.h \ + include/net.h /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h include/link.h include/npcutil.h \ + include/char.h include/char_base.h include/version.h include/skill.h \ + include/util.h include/title.h include/addressbook.h include/net.h \ + include/lua.h include/luaconf.h include/lauxlib.h include/lualib.h \ + include/char_data.h include/item.h include/char.h include/char_data.h \ + include/lssproto_serv.h include/lssproto_util.h +util.o: util.c include/version.h include/sasql.h /usr/include/stdio.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h include/correct_bug.h /usr/include/sys/stat.h \ + /usr/include/bits/stat.h /usr/include/dirent.h \ + /usr/include/bits/dirent.h /usr/include/ctype.h include/common.h \ + include/util.h include/common.h include/configfile.h \ + /usr/include/assert.h +net.o: net.c include/version.h include/sasql.h /usr/include/stdio.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h include/correct_bug.h /usr/include/netinet/tcp.h \ + /usr/include/sys/timeb.h /usr/include/fcntl.h /usr/include/bits/fcntl.h \ + include/net.h include/common.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h include/link.h include/buf.h include/link.h \ + include/common.h include/msignal.h include/configfile.h include/util.h \ + include/saacproto_cli.h include/version.h include/saacproto_util.h \ + include/lssproto_serv.h include/lssproto_util.h include/char.h \ + include/char_base.h include/skill.h include/util.h include/title.h \ + include/addressbook.h include/net.h include/lua.h include/luaconf.h \ + include/lauxlib.h include/lualib.h include/char_data.h include/item.h \ + include/char.h include/handletime.h include/log.h include/object.h \ + include/title.h include/item_event.h include/enemy.h include/battle.h \ + include/pet_event.h include/char_talk.h include/petmail.h \ + include/mylua/function.h include/npc_autopk.h include/attestation.h +buf.o: buf.c include/version.h include/sasql.h /usr/include/stdio.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h include/correct_bug.h include/buf.h \ + include/common.h include/handletime.h +msignal.o: msignal.c include/version.h include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h include/correct_bug.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h include/buf.h include/common.h \ + include/net.h /usr/include/pthread.h /usr/include/sched.h \ + /usr/include/bits/sched.h /usr/include/bits/setjmp.h include/link.h \ + include/char.h include/char_base.h include/version.h include/skill.h \ + include/util.h include/title.h include/addressbook.h include/net.h \ + include/lua.h include/luaconf.h include/lauxlib.h include/lualib.h \ + include/char_data.h include/item.h include/char.h include/item.h \ + include/object.h include/configfile.h include/lssproto_serv.h \ + include/lssproto_util.h include/saacproto_cli.h \ + include/saacproto_util.h include/log.h include/petmail.h \ + include/mylua/mylua.h include/lua.h include/lauxlib.h include/lualib.h +link.o: link.c /usr/include/stdlib.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/bits/wordsize.h \ + /usr/include/gnu/stubs.h /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/sys/types.h /usr/include/bits/types.h \ + /usr/include/bits/typesizes.h /usr/include/time.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/select.h \ + /usr/include/bits/select.h /usr/include/bits/sigset.h \ + /usr/include/bits/time.h /usr/include/sys/sysmacros.h \ + /usr/include/bits/pthreadtypes.h /usr/include/alloca.h \ + include/version.h include/sasql.h /usr/include/stdio.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h include/correct_bug.h include/link.h \ + include/common.h include/buf.h +sasql.o: sasql.c include/version.h include/sasql.h /usr/include/stdio.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h include/correct_bug.h include/sasql.h \ + include/net.h include/common.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h include/link.h include/common.h \ + include/char_base.h include/version.h include/skill.h include/util.h \ + include/title.h include/addressbook.h include/net.h include/lua.h \ + include/luaconf.h include/lauxlib.h include/lualib.h \ + include/char_data.h include/item.h include/char.h include/char_base.h \ + include/char_data.h include/char.h include/lssproto_serv.h \ + include/lssproto_util.h include/item.h include/item_event.h \ + include/buf.h include/object.h include/map_deal.h \ + include/saacproto_cli.h include/saacproto_util.h include/readmap.h \ + include/handletime.h include/char_event.h include/npccreate.h \ + include/addressbook.h include/magic_base.h include/magic.h \ + include/chatmagic.h include/configfile.h include/log.h \ + include/anim_tbl.h include/encount.h include/battle.h \ + include/pet_skill.h include/util.h include/enemy.h include/npcutil.h \ + include/pet.h include/family.h include/defend.h include/correct_bug.h \ + /usr/include/mysql/mysql.h /usr/include/mysql/mysql_version.h \ + /usr/include/mysql/mysql_com.h /usr/include/mysql/mysql_time.h \ + /usr/include/mysql/typelib.h /usr/include/mysql/my_alloc.h \ + /usr/include/mysql/my_list.h +const.o: const.c include/version.h include/sasql.h /usr/include/stdio.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h include/correct_bug.h include/common.h \ + include/char.h include/common.h include/char_base.h include/version.h \ + include/skill.h include/util.h include/title.h include/addressbook.h \ + include/net.h /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h include/link.h include/lua.h \ + include/luaconf.h include/lauxlib.h include/lualib.h \ + include/char_data.h include/item.h include/char.h include/char_data.h \ + include/item.h include/battle.h include/object.h include/enemy.h +des.o: des.c /usr/include/memory.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/bits/wordsize.h \ + /usr/include/gnu/stubs.h /usr/include/gnu/stubs-32.h \ + /usr/include/string.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h include/des.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdbool.h +callfromac.o: callfromac.c /usr/include/stdio.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/bits/wordsize.h \ + /usr/include/gnu/stubs.h /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + include/version.h include/sasql.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/time.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/select.h \ + /usr/include/bits/select.h /usr/include/bits/sigset.h \ + /usr/include/bits/time.h /usr/include/sys/sysmacros.h \ + /usr/include/bits/pthreadtypes.h /usr/include/alloca.h \ + /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h include/correct_bug.h include/common.h \ + include/saacproto_cli.h include/version.h include/saacproto_util.h \ + include/lssproto_serv.h include/lssproto_util.h include/net.h \ + include/common.h /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h include/link.h include/char.h \ + include/char_base.h include/skill.h include/util.h include/title.h \ + include/addressbook.h include/net.h include/lua.h include/luaconf.h \ + include/lauxlib.h include/lualib.h include/char_data.h include/item.h \ + include/char.h include/object.h include/readmap.h include/msignal.h \ + include/map_deal.h include/npc_duelranking.h include/npc_warpman.h \ + include/handletime.h include/npc_scheduleman.h include/configfile.h \ + include/chatroom.h include/npc_eventaction.h include/family.h \ + include/log.h include/buf.h include/npc_alldoman.h include/enemy.h +callfromcli.o: callfromcli.c include/version.h include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h include/correct_bug.h include/common.h \ + include/util.h include/common.h include/lssproto_serv.h \ + include/lssproto_util.h include/saacproto_cli.h include/version.h \ + include/saacproto_util.h include/npc_exchangeman.h include/net.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h include/link.h include/char.h \ + include/char_base.h include/skill.h include/util.h include/title.h \ + include/addressbook.h include/net.h include/lua.h include/luaconf.h \ + include/lauxlib.h include/lualib.h include/char_data.h include/item.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 \ + include/map_deal.h include/trade.h include/family.h \ + include/item_event.h include/npc_petshop.h include/enemy.h \ + include/char_base.h include/profession_skill.h include/chatroom.h \ + include/mylua/function.h +object.o: object.c include/version.h include/sasql.h /usr/include/stdio.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h include/correct_bug.h /usr/include/sys/stat.h \ + /usr/include/bits/stat.h /usr/include/dirent.h \ + /usr/include/bits/dirent.h include/handletime.h include/common.h \ + include/common.h include/object.h include/char_base.h include/version.h \ + include/skill.h include/util.h include/title.h include/addressbook.h \ + include/net.h /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h include/link.h include/lua.h \ + include/luaconf.h include/lauxlib.h include/lualib.h include/char.h \ + include/char_base.h include/char_data.h include/item.h include/char.h \ + include/item.h include/buf.h include/readmap.h include/pet.h +handletime.o: handletime.c include/version.h include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h include/correct_bug.h include/common.h \ + include/handletime.h include/common.h +function.o: function.c include/version.h include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h include/correct_bug.h include/common.h \ + include/util.h include/common.h include/char_event.h \ + include/char_base.h include/version.h include/skill.h include/util.h \ + include/title.h include/addressbook.h include/net.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h include/link.h include/lua.h \ + include/luaconf.h include/lauxlib.h include/lualib.h include/char.h \ + include/char_data.h include/item.h include/char.h include/item_event.h \ + include/magic.h include/pet_event.h include/npc_townpeople.h \ + include/npc_Dengon.h include/npc_door.h include/npc_healer.h \ + include/npc_oldman.h include/npc_warp.h include/npc_storyteller.h \ + include/npc_msg.h include/npc_npcenemy.h include/npc_action.h \ + include/npc_windowman.h include/npc_savepoint.h \ + include/npc_windowhealer.h include/npc_itemshop.h \ + include/npc_vigorshop.h include/npc_sysinfo.h include/npc_duelranking.h \ + include/npc_petskillshop.h include/npc_petskilldelshop.h \ + include/npc_petshop.h include/npc_signboard.h include/npc_warpman.h \ + include/npc_exchangeman.h include/petmail.h include/npc_timeman.h \ + include/npc_bodylan.h include/npc_mic.h include/npc_luckyman.h \ + include/npc_bus.h include/npc_charm.h include/npc_poolitemshop.h \ + include/npc_quiz.h include/npc_checkman.h include/npc_janken.h \ + include/npc_transmigration.h include/battle_event.h include/enemy.h \ + include/npc_familyman.h include/npc_bankman.h include/npc_fmdengon.h \ + include/npc_fmhealer.h include/npc_petmaker.h include/npc_fmrank.h \ + include/npc_fmwarpman.h include/npc_fmpkman.h include/npc_fmpkcallman.h \ + include/npc_airplane.h include/npc_scheduleman.h \ + include/npc_manorsman.h include/npc_riderman.h include/npc_fmletter.h \ + include/npc_gamblebank.h include/npc_newnpcman.h \ + include/npc_gambleroulette.h include/npc_gamblemaster.h \ + include/npc_transerman.h include/npc_vipshop.h include/npc_newvipshop.h \ + include/npc_rmbshop.h include/npc_stushop.h include/npc_itemup.h \ + include/npc_autopk.h include/npc_freepetskillshop.h \ + include/npc_petracemaster.h include/npc_petracepet.h \ + include/npc_itemchange.h include/npc_makepair.h include/npc_petfusion.h \ + include/npc_alldoman.h include/npc_welfare.h \ + include/npc_lua_interface.h include/npc_fmlookwar.h \ + include/npc_fmlookwar1.h include/npc_itemvippointshop.h +log.o: log.c include/version.h include/sasql.h /usr/include/stdio.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h include/correct_bug.h include/common.h \ + include/util.h include/common.h include/log.h include/handletime.h \ + include/net.h /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h include/link.h include/char_base.h \ + include/version.h include/skill.h include/util.h include/title.h \ + include/addressbook.h include/net.h include/lua.h include/luaconf.h \ + include/lauxlib.h include/lualib.h +autil.o: autil.c include/version.h include/sasql.h /usr/include/stdio.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h include/correct_bug.h include/autil.h \ + include/version.h include/common.h include/char.h include/char_base.h \ + include/skill.h include/util.h include/title.h include/addressbook.h \ + include/net.h /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h include/link.h include/lua.h \ + include/luaconf.h include/lauxlib.h include/lualib.h \ + include/char_data.h include/item.h include/char.h \ + include/lssproto_util.h include/common.h +attestation.o: attestation.c /usr/include/string.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/stdio.h /usr/include/bits/types.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/ctype.h /usr/include/errno.h \ + /usr/include/bits/errno.h /usr/include/linux/errno.h \ + /usr/include/asm/errno.h /usr/include/asm-generic/errno.h \ + /usr/include/asm-generic/errno-base.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/netdb.h /usr/include/netinet/in.h \ + /usr/include/stdint.h /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/rpc/netdb.h /usr/include/bits/netdb.h \ + /usr/include/sys/time.h /usr/include/sys/ioctl.h \ + /usr/include/bits/ioctls.h /usr/include/asm/ioctls.h \ + /usr/include/asm/ioctl.h /usr/include/asm-generic/ioctl.h \ + /usr/include/bits/ioctl-types.h /usr/include/sys/ttydefaults.h \ + /usr/include/arpa/inet.h /usr/include/netinet/tcp.h \ + /usr/include/net/if.h include/handletime.h include/common.h \ + include/util.h include/version.h include/sasql.h /usr/include/strings.h \ + include/correct_bug.h include/des.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdbool.h +saacproto_cli.o: saacproto_cli.c include/version.h include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h include/correct_bug.h include/saacproto_cli.h \ + include/version.h include/saacproto_util.h include/common.h \ + include/net.h include/common.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h include/link.h include/chatmagic.h +saacproto_util.o: saacproto_util.c include/version.h include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h include/correct_bug.h include/saacproto_util.h +lssproto_serv.o: lssproto_serv.c include/version.h include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h include/correct_bug.h include/autil.h \ + include/version.h include/common.h include/lssproto_serv.h \ + include/lssproto_util.h include/common.h include/log.h include/char.h \ + include/char_base.h include/skill.h include/util.h include/title.h \ + include/addressbook.h include/net.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h include/link.h include/lua.h \ + include/luaconf.h include/lauxlib.h include/lualib.h \ + include/char_data.h include/item.h include/char.h include/net.h +lssproto_util.o: lssproto_util.c include/version.h include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h include/correct_bug.h include/lssproto_util.h \ + include/common.h diff --git a/map/makefile b/map/makefile new file mode 100644 index 0000000..94e6912 --- /dev/null +++ b/map/makefile @@ -0,0 +1,249 @@ +export CC=gcc +export RM=rm -f +export AR=ar cr +export MV=mv +export RANLIB=ranlib +export SED=sed + + +export SHELL=/bin/sh + +INCFLAGS=-I.. -I../include + + +CFLAGS=-O3 -w $(INCFLAGS) +#Pentium 4 (Intel) +#CFLAGS=-march=pentium4 -O3 -pipe -fomit-frame-pointer $(INCFLAGS) +#Athlon XP (AMD) +#CFLAGS="-march=athlon-xp -O3 -pipe -fomit-frame-pointer" $(INCFLAGS) +#Athlon64£º +#CFLAGS="-O2 -march=athlon64 -ftracer -fprefetch-loop-arrays -pipe" $(INCFLAGS) + +PROG=libmap.a + +SRC=readmap.c map_deal.c map_util.c map_warppoint.c +OBJ=$(SRC:.c=.o) + +ifeq (0,$(MAKELEVEL)) +CC=gcc +RM=rm -f +AR=ar cr +MV=mv +RANLIB=ranlib +SED=sed +SHELL=/bin/sh +endif + +all: $(PROG) + +$(PROG): $(OBJ) + $(RM) $(PROG) + $(AR) $(PROG) $(OBJ) + $(RANLIB) $(PROG) + +depend: + $(MV) makefile makefile.bak + $(SED) -ne '1,/^# DO NOT DELETE THIS LINE/p' makefile.bak>makefile + $(CC) $(INCFLAGS) -M $(SRC) >> makefile + +clean: + $(RM) $(PROG) + $(RM) $(OBJ) + $(RM) *~ + +distclean: + $(RM) $(PROG) + $(RM) $(OBJ) + $(RM) *~ + $(MV) makefile makefile.bak + $(SED) -ne '1,/^# DO NOT DELETE THIS LINE/p' makefile.bak>makefile + $(RM) makefile.bak + +# DO NOT DELETE THIS LINE +readmap.o: readmap.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h /usr/include/dirent.h \ + /usr/include/bits/dirent.h /usr/include/sys/stat.h \ + /usr/include/bits/stat.h ../include/common.h ../include/object.h \ + ../include/common.h ../include/readmap.h ../include/util.h \ + ../include/buf.h ../include/util.h ../include/char.h \ + ../include/char_base.h ../include/version.h ../include/skill.h \ + ../include/title.h ../include/addressbook.h ../include/net.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/lssproto_serv.h ../include/lssproto_util.h \ + ../include/configfile.h +map_deal.o: map_deal.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/common.h \ + ../include/readmap.h ../include/common.h ../include/util.h \ + ../include/char.h ../include/char_base.h ../include/version.h \ + ../include/skill.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/map_util.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h ../include/net.h ../include/anim_tbl.h +map_util.o: map_util.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/common.h \ + ../include/char.h ../include/common.h ../include/char_base.h \ + ../include/version.h ../include/skill.h ../include/util.h \ + ../include/title.h ../include/addressbook.h ../include/net.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/readmap.h +map_warppoint.o: map_warppoint.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/common.h \ + ../include/char.h ../include/common.h ../include/char_base.h \ + ../include/version.h ../include/skill.h ../include/util.h \ + ../include/title.h ../include/addressbook.h ../include/net.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/char_base.h ../include/object.h ../include/buf.h \ + ../include/util.h ../include/configfile.h ../include/readmap.h \ + ../include/map_warppoint.h diff --git a/map/makefile.bak b/map/makefile.bak new file mode 100644 index 0000000..94e6912 --- /dev/null +++ b/map/makefile.bak @@ -0,0 +1,249 @@ +export CC=gcc +export RM=rm -f +export AR=ar cr +export MV=mv +export RANLIB=ranlib +export SED=sed + + +export SHELL=/bin/sh + +INCFLAGS=-I.. -I../include + + +CFLAGS=-O3 -w $(INCFLAGS) +#Pentium 4 (Intel) +#CFLAGS=-march=pentium4 -O3 -pipe -fomit-frame-pointer $(INCFLAGS) +#Athlon XP (AMD) +#CFLAGS="-march=athlon-xp -O3 -pipe -fomit-frame-pointer" $(INCFLAGS) +#Athlon64£º +#CFLAGS="-O2 -march=athlon64 -ftracer -fprefetch-loop-arrays -pipe" $(INCFLAGS) + +PROG=libmap.a + +SRC=readmap.c map_deal.c map_util.c map_warppoint.c +OBJ=$(SRC:.c=.o) + +ifeq (0,$(MAKELEVEL)) +CC=gcc +RM=rm -f +AR=ar cr +MV=mv +RANLIB=ranlib +SED=sed +SHELL=/bin/sh +endif + +all: $(PROG) + +$(PROG): $(OBJ) + $(RM) $(PROG) + $(AR) $(PROG) $(OBJ) + $(RANLIB) $(PROG) + +depend: + $(MV) makefile makefile.bak + $(SED) -ne '1,/^# DO NOT DELETE THIS LINE/p' makefile.bak>makefile + $(CC) $(INCFLAGS) -M $(SRC) >> makefile + +clean: + $(RM) $(PROG) + $(RM) $(OBJ) + $(RM) *~ + +distclean: + $(RM) $(PROG) + $(RM) $(OBJ) + $(RM) *~ + $(MV) makefile makefile.bak + $(SED) -ne '1,/^# DO NOT DELETE THIS LINE/p' makefile.bak>makefile + $(RM) makefile.bak + +# DO NOT DELETE THIS LINE +readmap.o: readmap.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h /usr/include/dirent.h \ + /usr/include/bits/dirent.h /usr/include/sys/stat.h \ + /usr/include/bits/stat.h ../include/common.h ../include/object.h \ + ../include/common.h ../include/readmap.h ../include/util.h \ + ../include/buf.h ../include/util.h ../include/char.h \ + ../include/char_base.h ../include/version.h ../include/skill.h \ + ../include/title.h ../include/addressbook.h ../include/net.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/lssproto_serv.h ../include/lssproto_util.h \ + ../include/configfile.h +map_deal.o: map_deal.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/common.h \ + ../include/readmap.h ../include/common.h ../include/util.h \ + ../include/char.h ../include/char_base.h ../include/version.h \ + ../include/skill.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/map_util.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h ../include/net.h ../include/anim_tbl.h +map_util.o: map_util.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/common.h \ + ../include/char.h ../include/common.h ../include/char_base.h \ + ../include/version.h ../include/skill.h ../include/util.h \ + ../include/title.h ../include/addressbook.h ../include/net.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/readmap.h +map_warppoint.o: map_warppoint.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/common.h \ + ../include/char.h ../include/common.h ../include/char_base.h \ + ../include/version.h ../include/skill.h ../include/util.h \ + ../include/title.h ../include/addressbook.h ../include/net.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/char_base.h ../include/object.h ../include/buf.h \ + ../include/util.h ../include/configfile.h ../include/readmap.h \ + ../include/map_warppoint.h diff --git a/map/map_deal.c b/map/map_deal.c new file mode 100644 index 0000000..9f9b129 --- /dev/null +++ b/map/map_deal.c @@ -0,0 +1,401 @@ +#include "version.h" +#include "common.h" +#include "readmap.h" +#include "char.h" +#include "map_util.h" +#include "lssproto_serv.h" +#include "net.h" +#include "anim_tbl.h" + +/*#define MAPEDITORTROUBLE*/ +#define SPR_kmydamY CG_HIT_MARK_10 // anim_tbl.h ľƥ ް + +/*------------------------------------------------------------ + * ¾ Ӭ£ƽҷ» ƥ¾¦ѻؤ£ + * ¦ + * ff int floor + * fx int x + * fy int y + * isfly int ƥ¾ + * ߯Ի + * TRUE(1) + * ئ FALSE(0) + ------------------------------------------------------------*/ +BOOL MAP_walkAbleFromPoint( int ff, int fx, int fy, BOOL isfly ) +{ + int map[2]; + + if( !MAP_getTileAndObjData( ff,fx,fy, &map[0], &map[1] ) ){ + return FALSE; + } + + if( isfly ){ + int i; + for( i = 0 ; i < 2 ; i ++ ) + if( MAP_getImageInt( map[i], MAP_HAVEHEIGHT ) == TRUE ){ + return FALSE; + } + return TRUE; + }else{ + switch( MAP_getImageInt( map[1], MAP_WALKABLE ) ){ + case 0: + return FALSE; + break; + case 1: + if( MAP_getImageInt( map[0], MAP_WALKABLE ) == 1 ){ + return TRUE; + }else{ + return FALSE; + } + break; + case 2: + return TRUE; + break; + default: + return FALSE; + break; + } + } + return FALSE; +} + + + +/*------------------------------------------------------------ + * ¾ Ӭ£ + * ¦ + * index int Char ƥ Index + * ff int floor id + * fx int x + * fy int y + * ߯Ի + * л TRUE(1) + * лĸ FALSE(0) + ------------------------------------------------------------*/ +BOOL MAP_walkAble( int index,int ff, int fx, int fy) +{ + /* ƽҷئOK */ + if( CHAR_getFlg( index, CHAR_ISTRANSPARENT ) ) return TRUE; + + // Arminius 7.9 Airplane ok + if( CHAR_getInt( index, CHAR_WHICHTYPE ) == CHAR_TYPEBUS) return TRUE; + if( CHAR_getWorkInt( index, CHAR_WORKPARTYMODE) == CHAR_PARTY_CLIENT ) { + int oyaindex = CHAR_getWorkInt( index, CHAR_WORKPARTYINDEX1); + if( CHAR_CHECKINDEX( oyaindex)) { + if (CHAR_getInt( oyaindex, CHAR_WHICHTYPE ) == CHAR_TYPEBUS) return TRUE; + } + } + + return MAP_walkAbleFromPoint( ff,fx,fy,CHAR_getFlg(index,CHAR_ISFLYING)|CHAR_getWorkInt(index,CHAR_WORKSKYWALKER) ); +} + +/*------------------------------------------------------------ + * ë϶ƻƤνؤ¾ + * ¦ + * fl int ׷ʧ + * x int x + * y int y + * ߯Ի + * νؤ TRUE + * νئ FALSE + ------------------------------------------------------------*/ +BOOL MAP_haveHeight( int fl, int x, int y ) +{ + int map[2]; + + /* Ѩ󷸡ë */ + if( !MAP_getTileAndObjData( fl,x,y, &map[0], &map[1] ) ) + return FALSE; + + return MAP_getImageInt( map[1], MAP_HAVEHEIGHT ); +} + +/*------------------------------------------------------------ + * Map ì pre postë + * ¦ + * index int Ƿƻƽҷ¼̼͵ + * mode BOOL TRUEݷin FALSEݷ out 帲ɱ + * ߯Իئ + ------------------------------------------------------------*/ +static void MAP_dealprepostevent( int index, BOOL mode ) +{ + int map[2]; + int i; + int damaged=FALSE; + + if( CHAR_getFlg(index,CHAR_ISFLYING) ) + /* ƥ֧巴ئ */ + return; + + if( !MAP_getMapDataFromCharIndex( index , map ) ) return; + + for( i = 0 ; i < 2 ; i ++ ){ + /* damage */ + int damage; + damage = MAP_getImageInt(map[i], + mode ? MAP_INTODAMAGE : MAP_OUTOFDAMAGE); + if( damage != 0 ){ + /* ĸëƥ ¼ƥ į ľ׸ */ + int opt[2]={SPR_kmydamY,-damage}; + damaged=TRUE; + CHAR_setInt(index, CHAR_HP, + CHAR_getInt(index,CHAR_HP) + damage ); + CHAR_complianceParameter(index); + /* ĸⰾ׾ް */ + CHAR_sendWatchEvent(CHAR_getWorkInt(index,CHAR_WORKOBJINDEX), + CHAR_ACTDAMAGE,opt,2,TRUE); + } + } + if( damaged ) + CHAR_sendStatusString(index,"M"); +} + + +/*---------------------------------------- + * ̻ľ£۳ƥתxxx̼ + * ë £ + * ¦ + * index int Ƿƻƽҷ¼̼͵ + * flooor int ׷ʧID + * fx int x + * fy int y + * ߯Ի + * ئ + ----------------------------------------*/ +void MAP_preovered( int index ) +{ + MAP_dealprepostevent( index, FALSE ); +} + +/*---------------------------------------- + * ̻ ľ£ + * ¦ + * index int Ƿƻƽҷ¼̼͵ + * ߯Ի + * ئ + ----------------------------------------*/ +void MAP_postovered( int index ) +{ + MAP_dealprepostevent( index, TRUE ); +} + + +/*---------------------------------------- + * ƽҷ¼ԻѨëͻ˪ + * ¦ + * fd int + * charaindex int ƽҷ¼̼͵ + * ߯Ի + * TRUE(1) + * FALSE(0) + ----------------------------------------*/ +BOOL MAP_sendArroundCharNeedFD( int fd,int charaindex ) +{ + char* stringdata; + int x=CHAR_getInt(charaindex,CHAR_X); + int y=CHAR_getInt(charaindex,CHAR_Y); + int fl=CHAR_getInt(charaindex,CHAR_FLOOR); + int size=MAP_CHAR_DEFAULTSEESIZ; + RECT seekr,retr; + seekr.x = x - (int)(size/2); + seekr.y = y - (int)(size/2); + seekr.width = size; + seekr.height = size; +#if 1 +{ + int tilesum, objsum, eventsum; + stringdata = MAP_getChecksumFromRECT(fl,&seekr,&retr, &tilesum,&objsum,&eventsum); + if( stringdata == NULL ) + return FALSE; + + lssproto_MC_send(fd,fl, + retr.x, retr.y, + retr.x + retr.width, retr.y + retr.height, + tilesum, + objsum, + eventsum, + stringdata ); +} +#else + stringdata = MAP_getdataFromRECT(fl,&seekr,&retr); + if( stringdata == NULL ) + return FALSE; + + lssproto_M_send(fd,fl, + retr.x, retr.y, + retr.x + retr.width, retr.y + retr.height, + stringdata ); +#endif + return TRUE; +} + + +/*---------------------------------------- + * Ѩ󷸡ë £ + * ¦ + * charaindex int ƽҷ¼̼͵ + * ߯Ի + * TRUE(1) + * FALSE(0) + ----------------------------------------*/ +BOOL MAP_sendArroundChar(int charaindex) +{ + int fd; + fd = getfdFromCharaIndex( charaindex ); + if( fd == -1 )return FALSE; + + return MAP_sendArroundCharNeedFD(fd, charaindex); +} + +#ifdef _CAX_LNS_NLGSUOXU +static int YCXX[] = {39,40,40,40,40,40,40,40,40,41,41,41,41,41,41,41,41,41,41,41,42,42,42,42,42,42,42,42,42,42,43,43,43,43,44,44,44,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,46,46,46,46,46,46,46,46,46,46,47,47,47,47,47,47,47,47,47,47,47,47,48,48,48,48,48,48,48,48,48,48,48,49,49,49,49,49,49,49,49,49,50,50,50,50,50,50,50,50,50,50,50,51,51,51,51,51,51,51,51,51,51,51,52,52,52,52,52,52,52,52,52,52,52,52,52,53,53,53,53,53,53,53,53,53,53,53,53,53,53,54,54,54,54,54,54,54,54,54,55,55,55,55,55,55,55,55,55,55,55,55,55,55,55,55,55,55,55,55,55,55,55,55,56,56,56,56,56,56,56,56,56,56,56,56,56,56,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,58,58,58,58,58,58,58,58,58,58,58,58,58,58,58,58,58,58,58,58,58,58,58,58,58,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,63,63,63,63,63,63,63,63,63,63,63,63,63,63,63,63,63,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,67,67,67,67,67,67,67,67,67,67,67,67,67,67,67,67,67,67,67,67,67,67,67,68,68,68,68,68,68,68,68,68,68,68,68,68,68,68,68,68,68,69,69,69,69,69,69,69,69,69,69,69,69,69,69,69,69,69,69,69,69,69,69,69,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,72,72,72,72,72,72,72,72,72,72,72,72,72,72,72,73,73,73,73,73,73,73,73,73,73,73,73,73,73,73,73,73,73,73,73,73,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,76,76,76,76,76,76,76,76,76,76,76,76,76,76,76,76,76,76,77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,78,78,78,78,78,78,78,78,78,78,78,78,78,78,78,78,78,78,78,78,78,78,78,79,79,79,79,79,79,79,79,79,79,79,79,79,79,79,79,79,79,79,79,79,79,79,79,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,81,81,81,81,81,81,81,81,81,81,81,81,81,81,81,81,81,81,81,81,82,82,82,82,82,82,82,82,82,82,82,82,82,82,82,82,82,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,84,84,84,84,84,84,84,84,84,84,84,84,84,84,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,86,86,86,86,86,86,86,86,86,86,86,87,87,87,87,87,87,87,87,87,87,87,88,88,88,88,88,88,88,88,88,88,88,88,88,89,89,89,89,89,89,89,89,89,89,89,89,89,90,90,90,90,90,90,90,90,90,90,90,91,91,91,91,91,91,91,91,91,91,92,92,92,92,92,92,92,92,92,92,92,92,93,93,93,93,93,93,93,93,93,93,93,93,93,93,94,94,94,94,94,94,94,95,95,95,95,95,95,95,96,96,96,96,96,96,96,96,96,96,96,96,96,97,97,97,97,97,97,97,97,97,97,97,98,98,98,98,98,98,99,99,99,99,99,99,100,100,100,100,100,100,100,100,100,100,101,101,101,101,101,101,102,102,102,102,102,103,103,103,103,103,104,104,104,104,104,105,105,105,105,105,105,105,105,105,106,106,106,106,106,106,106,106,106,106,106,106,106,106,106,106,107,107,107,107 +}; + +static int YCXY[] = {39,39,40,64,65,66,76,77,78,40,41,63,66,67,73,74,75,79,82,83,40,61,62,68,70,71,72,80,81,83,39,60,69,83,40,60,83,41,47,59,63,64,65,66,67,68,69,70,71,72,78,82,40,47,48,60,63,73,76,77,78,81,39,40,44,45,46,49,60,63,74,76,78,82,40,45,46,47,48,50,60,63,75,78,83,40,48,51,55,59,60,62,78,84,40,49,50,52,55,56,57,58,61,79,85,40,50,52,54,60,72,73,75,80,81,86,40,48,49,50,51,52,53,60,72,76,77,82,87,40,47,48,49,50,51,52,59,72,78,83,88,89,90,40,52,58,72,78,84,91,92,93,40,52,57,60,61,62,63,64,65,66,67,68,69,70,71,72,74,75,76,79,85,94,95,96,40,53,57,60,73,77,80,86,97,98,99,108,109,110,40,54,57,59,72,77,78,81,87,91,92,100,107,108,109,110,111,40,54,57,59,71,77,79,82,83,88,89,90,93,98,99,101,102,103,104,105,106,107,111,112,113,39,54,57,58,59,60,61,62,63,64,65,66,70,76,77,80,84,94,95,96,97,100,101,106,112,114,38,53,56,57,60,67,71,75,77,79,85,86,93,94,99,100,101,102,106,112,114,37,53,55,56,57,61,68,72,73,74,75,76,77,78,87,88,91,92,95,96,97,98,101,103,106,112,115,120,34,35,36,53,54,62,69,73,77,89,90,102,103,106,113,116,119,121,34,52,53,54,63,68,72,77,89,90,102,103,106,113,117,118,120,34,39,48,49,50,51,52,53,63,68,69,70,71,77,90,91,102,104,105,106,113,118,119,34,39,40,41,46,47,48,49,50,51,63,67,68,77,90,92,93,94,95,96,102,104,105,106,107,112,113,118,119,34,39,42,45,46,51,63,66,72,73,74,77,91,92,93,96,99,100,101,102,103,104,107,112,114,118,34,39,43,44,45,51,64,70,71,75,77,93,95,98,102,107,108,109,110,111,112,115,118,35,39,45,51,52,53,65,69,75,77,93,94,97,103,112,115,119,121,36,39,45,53,54,66,67,68,75,77,92,93,96,97,98,99,100,101,104,112,115,119,121,36,37,38,39,40,45,54,67,75,77,91,93,95,96,100,105,108,109,110,111,112,113,114,115,116,117,118,120,121,40,45,55,75,78,90,93,94,96,99,106,108,114,115,119,120,121,41,45,56,57,58,75,79,90,93,96,98,107,114,115,119,44,55,56,57,59,76,80,85,86,87,89,92,93,96,98,111,112,113,114,115,118,41,42,43,54,57,60,61,77,81,84,87,89,91,93,96,97,111,115,117,118,119,120,121,41,42,43,54,58,59,60,61,62,63,64,78,81,83,87,88,90,93,96,111,116,117,120,41,44,52,53,54,64,65,79,80,83,86,87,89,93,95,96,112,117,45,52,64,66,79,80,83,84,85,86,87,88,89,90,91,92,93,94,96,113,114,117,45,49,50,51,64,66,69,70,71,72,75,76,78,79,80,81,84,86,88,93,96,113,118,45,49,64,66,68,72,73,74,77,78,81,82,83,84,86,88,89,90,91,92,96,111,112,119,45,48,64,66,68,79,81,83,85,86,87,88,91,93,96,105,106,107,108,109,110,111,119,45,46,47,64,65,66,67,79,80,81,82,87,90,94,96,102,103,104,109,119,64,65,78,81,82,87,90,94,96,98,99,100,101,102,105,109,118,64,65,78,79,80,81,82,87,90,94,95,97,100,106,108,109,110,111,112,113,114,115,117,63,64,65,81,87,90,93,95,96,99,106,108,115,116,62,63,64,65,66,81,87,89,90,91,92,95,97,98,106,107,108,116,62,65,66,81,86,87,89,91,96,97,116,61,66,67,81,85,87,89,92,97,98,116,62,64,67,68,81,84,87,88,93,97,98,99,116,62,63,65,68,69,81,83,86,88,94,97,98,99,63,66,70,81,82,86,87,93,97,98,99,63,64,67,80,81,85,93,97,98,99,64,65,68,69,80,81,84,85,93,97,98,99,64,65,69,80,81,82,83,84,94,95,96,97,98,99,69,80,81,82,84,97,98,70,80,81,82,84,96,98,70,71,72,73,74,75,76,80,81,82,84,96,98,73,74,75,76,77,80,82,84,95,97,98,73,80,82,84,94,96,73,80,82,83,95,98,71,72,80,82,83,91,92,94,96,97,70,81,82,90,93,96,69,81,83,89,95,69,83,84,88,94,69,85,86,87,94,70,80,81,82,83,93,94,95,96,71,72,73,74,75,76,77,78,79,80,84,89,90,91,92,94,85,86,87,88 +}; + +static int JJXX[] = {54,55,55,56,56,56,56,57,57,57,58,58,58,58,58,58,58,58,59,59,59,60,60,60,60,60,60,60,61,61,61,61,61,61,62,62,62,62,62,63,63,63,63,63,63,64,64,64,64,64,65,65,65,65,65,65,65,65,66,66,66,66,66,67,67,67,67,67,67,67,67,67,67,68,68,68,68,68,68,68,68,69,69,69,69,69,70,70,70,70,70,70,70,70,70,70,71,71,71,71,72,72,72,72,72,72,72,72,72,72,72,73,73,73,73,73,73,74,74,74,74,74,75,75,75,75,75,75,75,75,75,76,76,76,76,76,76,77,77,77,77,77,77,78,78,78,78,78,78,79,79,79,79,79,79,79,79,79,79,79,79,79,80,80,80,80,80,80,80,80,81,81,81,81,81,81,81,81,82,82,82,82,82,82,82,82,83,83,83,83,83,83,83,83,84,84,84,84,84,84,84,84,84,85,85,85,85,85,85,85,86,86,86,86,86,86,86,87,87,87,87,87,87,87,87,87,88,88,88,88,88,88,88,88,88,88,88,88,88,88,89,89,89,89,89,89,89,89,89,89,89,90,90,90,90,90,91,91,91,91,91,91,91,91,92,92,92,92,92,92,92,92,93,93,93,93,93,93,93,93,93,94,94,94,94,94,94,94,95,95,95,95,95,95,96,96,96,96,96,96,96,96,96,96,96,96,97,97,97,97,97,97,97,97,97,97,97,97,98,98,98,98,98,98,98,98,98,98,98,98,98,98,99,99,99,99,99,99,99,99,99,99,99,99,100,100,100,100,100,100,100,100,100,100,100,100,100,101,101,101,101,101,101,101,101,101,101,102,102,102,102,102,102,102,102,102,102,102,102,103,103,103,103,103,103,103,103,103,103,104,104,104,104,104,104,104,104,104,104,104,104,104,104,105,105,105,105,105,105,105,105,105,105,105,106,106,106,106,106,106,106,106,106,107,107,107,107,107,107,107,108,108,108,108,109,109,109,109,109,110,110,111,111,111,111,111,111,111,112,112,113,113,113,114,114,115 +}; + +static int JJXY[] = {107,106,107,98,99,100,106,99,101,105,100,101,102,103,104,115,116,117,103,114,118,102,104,112,113,114,119,123,101,104,112,120,122,124,99,100,103,112,121,96,97,98,103,112,118,96,103,112,117,119,95,103,111,116,117,118,119,120,95,104,110,115,124,95,104,108,109,110,111,112,113,114,123,95,105,106,107,108,109,110,122,90,91,92,94,121,89,93,113,114,115,116,117,118,119,120,88,92,94,112,89,90,92,94,102,103,104,105,106,107,111,91,92,94,101,107,111,94,100,101,107,111,56,57,58,94,99,102,103,107,110,56,59,94,103,107,110,56,60,94,103,107,110,56,60,94,103,107,110,57,60,95,96,97,98,99,100,101,102,103,107,110,58,61,93,94,95,96,107,111,58,61,92,96,97,98,108,111,59,61,78,79,92,99,109,111,60,62,77,80,92,100,109,111,61,62,75,76,81,82,93,100,110,62,63,74,83,94,100,110,63,64,73,84,95,99,111,63,65,71,72,85,86,96,99,112,63,66,67,68,70,87,88,89,90,91,92,95,98,113,62,69,89,90,92,93,94,95,96,97,114,62,86,87,88,115,62,87,93,94,95,96,97,116,62,66,88,93,94,95,96,116,62,65,67,68,88,93,94,95,116,62,65,69,88,89,92,115,62,65,70,90,91,115,62,65,70,90,91,92,104,105,106,107,108,114,63,64,65,66,70,87,88,89,93,103,108,113,66,67,70,87,88,89,94,95,101,102,106,107,108,113,67,68,70,85,87,88,89,90,96,100,106,113,68,70,84,86,91,97,98,99,100,101,102,106,114,70,83,87,88,92,98,103,104,106,114,70,74,75,84,89,90,91,93,97,105,106,114,70,73,76,84,92,94,96,105,107,114,70,73,77,85,93,94,95,104,108,109,110,111,112,114,69,73,78,79,84,86,96,97,104,113,114,69,73,80,82,83,85,86,98,104,68,73,80,81,86,99,103,68,73,100,103,68,72,101,102,103,68,71,64,65,66,67,68,69,70,66,67,66,67,68,66,67,66 +}; + +static int KLXX[] = {34,35,36,36,36,36,36,37,37,37,37,37,37,38,38,38,38,38,38,38,38,38,38,38,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,40,40,40,40,40,40,41,41,41,41,41,42,43,44,45,46,47,48,49,49,50,50,50,51,51,51,51,51,51,51,51,51,51,51,51,51,52,52,52,52,52,52,52,52,52,52,52,52,52,52,52,52,52,52,52,52,52,52,52,53,53,53,53,53,53,53,53,53,53,53,53,53,53,53,53,53,53,53,53,53,53,53,53,53,53,53,53,53,53,53,53,53,53,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,55,55,55,55,55,55,55,55,55,55,55,55,55,55,55,55,55,56,56,56,56,56,56,56,56,56,56,56,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,58,58,58,58,58,58,58,58,58,58,59,59,59,59,59,59,59,59,59,59,59,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,63,63,63,63,63,63,63,63,63,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,65,65,65,65,65,65,65,65,65,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,67,67,67,67,67,67,67,67,67,67,67,67,67,67,67,67,67,68,68,68,68,68,68,68,68,68,68,68,68,68,68,68,68,68,68,68,68,68,68,68,68,68,68,68,68,69,69,69,69,69,69,69,69,69,69,69,69,69,69,69,69,69,69,69,69,69,69,69,69,69,69,69,69,69,69,69,69,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,72,72,72,72,72,72,72,72,72,72,72,72,72,72,72,72,72,72,72,72,72,72,72,72,72,72,72,72,72,72,73,73,73,73,73,73,73,73,73,73,74,74,74,74,74,74,74,74,74,75,75,75,75,75,75,75,76,76,76,76,76,76,76,76,76,76,76,77,77,77,77,77,77,77,77,77,77,78,78,78,78,78,78,78,78,78,78,79,79,79,79,79,79,79,79,79,79,79,79,79,79,79,79,79,79,79,79,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,81,81,81,81,81,81,81,81,81,81,81,81,81,81,81,82,82,82,82,82,82,82,82,82,82,83,83,83,83,83,83,83,83,83,83,83,84,84,84,84,84,84,84,85,85,85,85,85,85,86,86,86,86,86,86,86,86,86,87,87,87,87,87,87,87,87,88,88,88,88,88,88,88,88,88,88,89,89,89,89,89,89,89,89,90,90,90,90,90,90,91,91,91,91,91,91,92,92,92,92,92,92,92,92,92,92,92,92,93,93,93,93,93,93,93,93,93,93,93,93,93,93,93,93,93,94,94,94,94,94,94,94,94,94,94,94,94,94,94,94,94,94,95,95,95,95,95,95,95,95,95,96,96,96,96,96,96,96,96,96,96,96,97,97,97,97,97,97,97,97,97,97,97,97,97,97,97,98,98,98,98,98,98,98,98,98,98,98,98,98,99,99,99,99,99,99,99,99,99,100,100,100,100,100,101,101,101,101,101,101,102,102,102,102,102,103,103,103,103,103,104,104,105,105,106,106,106 +}; + +static int KLXY[] = {62,62,62,71,72,73,74,61,62,69,70,75,77,60,61,63,64,65,66,68,75,76,77,78,59,60,63,64,65,66,67,68,69,70,71,72,73,74,78,59,62,63,64,65,66,60,61,62,63,64,61,61,61,61,61,61,61,60,61,59,60,61,58,59,61,66,67,68,92,93,105,109,110,111,112,47,48,57,62,65,66,69,70,71,72,93,94,95,101,102,103,104,105,106,107,109,112,113,48,49,50,51,52,53,54,55,56,57,59,60,61,62,63,64,65,66,67,68,69,70,71,72,93,95,96,102,103,104,107,109,110,114,37,48,49,58,63,65,70,93,96,97,103,105,106,107,108,109,110,111,112,114,37,38,47,48,58,59,62,64,65,70,71,93,96,106,110,112,114,37,62,63,70,71,93,96,107,110,113,114,37,38,70,71,93,94,95,106,107,108,109,110,111,112,114,38,70,71,92,93,106,107,109,112,114,37,38,39,71,93,94,105,106,107,109,113,33,34,35,36,37,39,40,41,69,70,72,93,94,105,106,110,111,112,35,37,40,41,42,43,54,55,68,73,74,93,94,105,106,34,37,38,42,43,44,45,46,54,55,68,74,75,93,94,105,35,37,46,55,68,76,93,94,105,36,37,38,47,48,49,50,51,52,53,54,55,56,68,77,78,79,92,93,94,105,37,48,54,57,68,79,92,94,105,37,38,48,57,58,68,79,90,91,92,93,94,95,104,105,38,39,48,58,59,68,69,73,79,88,89,91,92,94,96,104,105,39,48,58,59,60,61,62,63,64,65,66,67,69,70,72,74,79,88,91,92,93,94,95,97,103,104,105,106,39,40,41,42,48,58,59,60,61,62,63,64,65,66,67,68,69,70,71,74,78,79,89,91,92,94,95,98,100,101,102,106,48,58,59,60,71,72,73,74,75,76,77,78,87,88,89,90,92,94,96,99,106,48,58,59,71,72,73,74,75,77,78,79,80,81,82,83,84,85,86,87,92,94,96,107,48,58,59,72,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,108,109,110,111,47,58,85,86,87,88,92,95,96,110,48,58,84,85,89,90,91,97,109,48,53,58,85,86,97,108,49,53,58,85,86,87,88,96,97,98,107,50,53,58,84,87,95,96,99,100,107,50,52,53,58,84,86,95,96,101,107,50,52,53,57,58,84,86,95,96,97,98,102,103,104,105,106,107,108,109,110,50,52,53,54,55,56,57,59,84,85,86,96,97,100,101,102,50,53,54,56,57,58,59,60,61,84,85,97,98,99,102,49,56,61,62,63,84,85,97,98,101,49,56,61,64,65,84,85,97,98,99,101,48,62,65,85,97,98,100,48,62,65,85,97,100,44,45,46,47,63,65,96,98,100,45,63,65,95,96,98,99,100,46,63,65,93,94,95,96,97,99,100,47,64,65,93,94,95,99,101,48,63,65,95,99,101,49,63,65,96,99,100,50,51,62,65,69,70,71,72,96,97,98,99,52,57,58,59,60,61,65,69,73,74,75,82,83,84,96,97,98,53,54,55,56,64,65,68,75,76,77,78,79,80,81,85,96,97,62,63,67,70,71,72,86,96,97,62,65,66,70,73,80,81,82,83,87,96,63,64,67,68,69,70,74,75,76,77,78,79,84,85,88,63,69,70,74,75,76,77,79,80,81,82,86,88,62,63,69,70,71,72,74,87,88,62,69,70,86,88,61,62,69,70,86,87,61,62,69,85,87,61,69,84,85,86,61,69,69,70,70,71,72 +}; + +static int SCXX[] = {27,27,27,27,27,28,28,28,29,29,29,29,29,29,29,29,29,29,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,31,31,32,32,33,33,33,33,33,33,33,34,34,34,34,34,34,34,34,34,34,34,34,35,35,35,35,35,35,36,36,36,36,36,36,36,36,36,36,36,36,37,37,37,37,37,37,37,37,38,38,38,38,38,38,38,39,39,39,39,39,39,39,40,40,40,40,40,40,40,40,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,42,42,42,42,42,42,42,42,43,43,43,43,43,43,43,43,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,45,45,45,45,45,45,45,45,45,46,46,46,46,46,46,46,47,47,47,47,47,48,48,48,48,48,48,48,49,49,49,49,49,50,50,50,50,50,50,50,51,51,51,51,51,51,51,51,51,51,52,52,52,52,52,52,52,52,52,53,53,53,53,53,53,53,53,53,53,54,54,54,54,54,54,54,54,54,54,55,55,55,55,55,55,55,55,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,58,58,58,58,58,58,58,58,58,58,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,63,63,63,63,63,63,63,63,63,63,63,64,64,64,64,64,64,64,64,65,65,65,65,65,65,65,65,65,65,65,65,66,66,66,66,66,66,66,67,67,67,67,67,67,67,68,68,68,68,68,68,68,69,69,69,69,69,69,69,69,69,69,69,69,69,69,69,70,70,70,70,70,70,70,70,70,70,71,71,71,71,71,71,71,71,71,71,72,72,72,72,72,72,72,72,72,73,73,73,73,73,73,73,73,73,74,74,74,74,74,74,74,74,74,74,74,74,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,76,76,76,76,76,76,76,76,76,76,76,76,76,76,77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,78,78,78,78,78,78,78,78,78,78,78,78,78,79,79,79,79,79,79,79,79,79,79,79,79,79,80,80,80,80,80,80,80,80,80,80,80,80,80,81,81,81,81,81,81,81,81,81,81,81,81,81,81,81,81,81,82,82,82,82,82,82,82,82,82,82,82,82,82,83,83,83,83,83,83,83,83,83,83,83,83,83,83,84,84,84,84,84,84,84,84,84,84,84,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,87,87,87,87,87,87,87,87,87,87,87,87,87,87,87,87,87,87,87,88,88,88,88,88,88,88,88,88,88,88,88,88,88,88,88,88,88,88,88,88,88,88,88,89,89,89,89,89,89,89,89,89,89,89,90,90,90,90,90,90,90,91,91,91,91,91,91,91,92,92,92,92,92,92,92,92,92,93,93,93,93,93,93,93,93,93,93,93,93,93,93,93,93,94,94,94,94,94,94,94,94,94,94,94,95,95,95,95,95,95,95,95,95,95,95,96,96,96,96,96,96,96,96,96,97,97,97,97,97,97,98,98,98,98,98,98,99,99,99,99,99,99,99,99,99,99,99,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,101,101,101,101,101,101,101,101,101,101,101,101,101,102,102,102,102,102,102,102,102,102,102,102,102,102,102,102,102,102,102,102,102,102,102,103,103,103,103,103,103,103,103,103,104,104,104,104,104,104,104,104,104,105,105,105,105,105,105,105,105,105,105,105,106,106,106,106,106,106,106,106,106,106,106,106,107,107,107,107,107,107,107,107,107,107,107,107,107,107,107,107,107,107,107,107,107,107,107,107,107,107,107,107,107,107,107,107,107,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,109,109,109,109,109,109,109,109,109,109,109,109,109,109,109,109,109,110,110,110,110,110,110,110,110,111,111,111,111,111,111,111,111,112,112,112,112,112,112,112,112,112,113,113,113,113,113,113,113,113,113,114,114,114,114,114,114,115,115,115,115,115,115,115,115,115,115,115,115,115,115,115,115,115,115,115,115,115,116,116,116,116,116,116,116,116,116,116,116,116,116,116,116,116,116,116,116,116,116,116,117,117,117,117,117,117,118,118,118,118,118,118,118,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,120,120,120,120,120,120,120,120,120,120,120,120,120,120 +}; + +static int SCXY[] = {67,68,69,70,71,65,66,72,64,73,78,79,80,81,82,83,84,85,53,54,55,56,57,58,59,60,61,62,63,74,75,76,77,85,52,86,51,87,51,60,61,73,74,75,88,51,59,61,74,75,76,77,78,79,80,81,89,51,58,62,75,82,90,47,48,49,50,51,57,62,75,83,86,87,90,49,56,62,76,83,85,86,90,49,55,62,76,83,85,90,49,54,61,76,82,85,90,49,54,61,76,81,85,86,90,48,49,54,61,73,74,75,76,77,78,79,80,81,85,87,90,48,54,62,73,76,85,88,90,48,54,62,72,76,85,89,90,48,54,55,56,63,66,67,68,69,70,71,76,77,85,90,91,48,57,64,65,66,78,86,90,91,48,58,59,79,87,90,91,48,60,80,88,91,48,61,62,63,64,81,89,48,65,82,90,101,48,66,83,91,100,102,110,48,66,84,92,93,99,103,108,109,111,48,66,84,85,94,98,103,107,112,48,66,83,90,95,96,97,103,106,113,47,66,82,89,103,105,113,119,120,121,47,66,82,88,104,114,118,122,47,66,82,87,90,91,92,93,94,95,96,97,98,99,100,115,116,117,123,124,47,66,82,86,91,92,101,102,103,104,105,106,107,108,124,46,65,83,84,85,93,101,102,109,124,45,64,82,83,84,94,100,103,110,111,112,113,114,115,116,117,118,119,120,124,44,63,81,82,85,94,99,104,112,113,114,115,116,117,118,124,43,62,83,86,87,88,89,90,91,92,93,94,95,96,97,98,104,105,106,107,108,109,112,124,42,55,56,57,58,59,60,61,84,85,94,104,110,111,124,41,54,76,77,78,79,80,81,86,94,124,40,52,53,75,82,87,94,125,39,46,47,48,49,50,51,75,83,88,94,126,39,46,75,84,89,94,127,39,45,75,84,89,94,128,39,45,74,84,89,94,128,39,45,49,50,51,52,53,54,55,56,74,84,90,94,127,38,44,50,57,73,85,86,90,94,126,37,44,51,58,72,87,90,94,95,125,36,43,51,59,72,88,91,96,125,35,43,52,60,72,89,92,97,125,35,43,53,61,62,63,72,89,93,94,98,125,35,38,43,52,53,63,64,72,74,75,76,77,78,89,94,99,125,35,38,43,51,65,66,71,73,79,89,95,96,100,125,35,38,39,43,50,67,71,72,80,89,97,98,101,102,103,104,125,35,38,39,43,49,68,70,72,80,90,99,105,125,35,38,39,43,49,68,69,72,81,91,100,106,125,35,38,40,43,49,68,69,72,81,92,101,106,124,35,38,41,42,49,68,69,72,81,93,98,99,100,101,102,106,124,34,38,39,49,68,72,73,81,93,96,97,106,123,32,33,39,49,68,73,81,93,94,95,106,120,121,122,31,39,48,49,67,73,81,92,93,107,120,31,38,47,59,60,61,62,63,64,65,66,74,81,90,91,92,97,98,99,107,120,31,32,37,38,39,40,41,42,43,44,45,46,50,51,52,53,54,55,56,57,59,66,75,76,77,78,79,80,81,82,88,89,90,91,96,100,108,120,32,49,50,58,59,65,79,83,84,95,101,102,103,104,105,106,107,109,120,33,43,44,45,46,47,48,62,63,64,78,85,86,87,88,89,90,91,92,93,94,108,110,119,34,35,43,61,62,77,109,111,112,113,118,35,43,60,76,110,113,118,34,42,59,76,111,113,118,34,41,55,56,58,76,111,112,118,35,40,43,44,45,46,47,48,54,57,76,83,84,85,111,118,35,39,41,42,49,50,54,76,82,86,117,34,38,39,40,51,54,76,80,81,87,116,34,52,54,76,77,78,79,87,116,33,53,54,76,87,116,33,53,54,76,87,116,33,53,54,75,76,87,116,117,127,128,129,33,53,54,55,74,77,88,117,118,119,120,121,122,123,126,129,32,54,55,64,65,73,77,89,90,91,124,125,129,32,53,54,65,72,77,92,93,94,95,96,97,98,99,100,101,102,124,125,126,127,128,31,53,54,66,71,77,78,103,124,31,53,54,66,67,70,78,104,123,30,37,51,52,53,65,68,69,78,105,123,29,36,38,49,50,52,65,71,72,78,105,123,28,34,35,38,44,45,46,47,48,49,50,51,52,63,64,65,71,72,78,105,111,112,113,114,115,116,117,118,119,120,121,122,123,28,31,32,33,39,44,49,52,61,62,63,71,72,78,105,111,29,30,31,39,44,49,61,72,73,74,75,76,77,78,104,105,111,29,40,44,49,61,73,103,111,29,40,44,49,61,74,103,111,28,29,40,44,50,61,75,102,110,29,41,42,43,50,61,75,102,109,28,49,62,75,102,108,28,49,62,75,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,107,29,43,44,45,46,47,48,62,64,65,66,67,68,69,70,71,72,73,74,75,86,107,29,42,62,64,86,107,29,30,41,62,64,87,107,31,32,33,34,35,40,62,64,65,66,67,68,69,70,87,107,32,33,34,35,36,37,38,39,40,58,62,70,88,107 +}; + +static int FCXX[] = {28,29,29,29,30,30,31,31,31,31,31,32,32,32,32,33,33,33,33,33,33,33,33,34,34,34,34,34,34,34,34,34,35,35,35,35,35,35,35,35,35,35,36,36,36,36,37,37,37,37,37,38,38,38,38,38,38,39,39,39,39,39,39,39,40,40,40,40,40,40,40,40,40,40,40,41,41,41,41,41,41,41,41,41,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,46,46,46,46,46,46,46,46,46,46,46,46,46,46,46,46,46,46,46,46,46,46,46,46,46,46,47,47,47,47,47,47,47,47,47,47,47,47,47,47,47,47,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,49,49,49,49,49,49,49,49,49,49,50,50,50,50,50,50,50,50,50,50,50,50,50,50,51,51,51,51,51,51,51,52,52,52,52,52,52,52,53,53,54,54,54,55,55,55,55,55,56,56 +}; + +static int FCXY[] = {33,33,34,37,35,36,35,51,52,53,54,35,36,50,54,34,36,37,38,39,40,50,54,33,34,40,41,42,43,50,53,54,33,34,43,44,48,49,50,51,52,53,33,34,51,52,33,34,52,53,54,34,35,52,53,55,56,34,35,51,52,53,54,56,27,28,29,32,33,36,51,54,56,58,59,29,30,31,37,51,52,54,56,59,29,32,33,34,35,36,38,47,48,49,50,51,52,53,54,56,59,60,61,62,29,32,36,38,44,45,46,47,49,50,51,53,56,57,58,59,60,61,23,24,25,28,29,31,36,38,43,45,46,47,48,49,50,51,53,54,55,56,59,61,22,26,27,28,29,30,32,36,39,40,41,42,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,20,21,22,23,26,27,31,32,33,34,35,36,39,40,41,42,43,44,47,48,49,51,55,56,57,60,23,27,32,35,36,37,38,42,47,49,50,51,55,56,57,60,23,26,31,32,33,34,35,40,41,48,49,50,51,59,60,23,25,29,30,31,36,37,38,39,59,23,25,26,27,28,29,30,31,32,33,34,35,36,37,23,24,25,29,33,34,35,23,26,28,29,30,31,32,23,26,22,25,26,22,23,24,25,26,25,26 +}; + +static int QGGXX[] = {42,42,42,42,42,42,42,43,43,43,43,43,44,44,44,44,44,44,44,44,44,44,45,45,45,45,45,45,46,46,46,46,46,47,47,47,47,47,47,47,47,47,47,47,47,47,47,47,48,48,48,48,48,48,48,48,48,48,48,48,48,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,51,51,51,51,51,51,51,51,51,51,51,51,52,52,52,52,52,52,52,52,52,52,52,52,52,52,52,53,53,53,53,53,53,53,53,53,53,53,54,54,54,54,54,54,54,54,54,54,54,55,55,55,55,55,55,55,55,55,55,55,55,56,56,56,56,56,56,56,56,56,56,57,57,57,57,57,57,57,57,57,57,58,58,58,58,58,58,58,58,58,58,58,58,58,58,58,59,59,59,59,59,59,59,59,59,59,59,59,59,59,60,60,60,60,60,60,60,60,60,60,60,60,60,61,61,61,61,61,61,61,61,61,62,62,62,62,62,62,62,63,63,63,64,64,65,65,65,66,66,66,66,66,66,66,67,67,67,67,67,67,67,67,67,67,68,68,68,68,68,68,68,69,69 +}; + +static int QGGXY[] = {52,53,54,55,56,58,59,52,55,57,58,59,51,52,53,54,55,56,57,59,61,62,50,51,58,59,60,62,49,50,58,59,62,48,49,59,61,64,65,66,67,68,71,72,73,74,75,83,49,50,59,61,64,69,70,76,78,79,80,81,82,43,44,45,46,47,49,51,59,62,63,68,69,70,71,72,73,74,75,76,77,80,43,48,51,59,66,67,68,70,71,72,73,74,75,76,77,78,79,43,50,52,58,59,60,61,63,64,65,69,79,43,49,50,52,53,54,55,56,57,58,61,62,68,79,80,42,51,52,55,56,58,67,68,79,80,81,42,51,52,53,54,56,57,58,67,79,81,42,50,52,54,55,57,58,59,67,79,80,81,43,44,49,50,51,53,56,59,67,79,45,48,51,52,53,54,55,58,66,79,42,43,44,47,48,51,52,58,66,68,74,75,76,77,78,42,43,44,45,46,48,50,51,58,66,68,69,72,73,42,44,45,46,47,48,49,50,58,66,67,70,72,42,45,46,49,50,58,66,70,72,43,44,47,48,50,58,71,48,51,58,52,58,52,57,58,52,55,56,57,58,59,60,50,51,52,53,54,55,59,60,61,62,50,54,55,56,57,58,61,54,57 +}; + +static int DNXX[] = {22,23,23,23,24,24,25,25,26,26,26,26,27,27,27,27,27,28,28,28,28,29,29,29,29,29,29,30,30,30,30,30,30,30,30,30,30,30,30,31,31,31,31,31,32,32,32,32,32,33,33,33,33,33,33,33,33,33,34,34,34,34,34,34,34,34,35,35,35,35,35,35,35,35,35,36,36,36,36,36,36,36,36,36,36,36,36,36,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,38,38,38,38,38,38,38,38,38,38,38,38,38,38,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,40,40,40,40,40,40,40,40,40,40,40,40,40,40,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,42,42,42,42,42,42,42,42,42,42,42,43,43,43,43,43,44,44,44,44,44,45,45,45,45,45,45,46,46,46,47,47 +}; + +static int DNXY[] = {33,32,33,34,31,35,31,36,31,32,36,37,31,33,34,35,37,31,33,34,37,30,33,34,35,36,39,26,27,28,29,30,34,35,36,37,38,39,40,31,37,40,41,42,32,37,39,40,42,28,31,36,37,38,39,40,41,43,28,29,30,35,36,40,42,44,31,34,35,36,40,42,44,47,48,30,32,34,35,36,40,41,42,43,44,45,46,48,29,31,32,33,34,36,37,38,39,40,41,42,43,44,45,46,47,29,33,34,35,36,37,39,40,41,42,44,45,46,48,29,30,31,32,33,34,37,38,39,41,43,44,45,46,47,48,49,51,52,31,32,34,37,38,39,40,43,44,45,46,49,50,51,32,33,34,37,38,39,40,41,42,43,44,45,46,48,49,50,51,32,33,37,38,39,41,44,48,49,50,51,37,38,39,41,51,36,38,39,40,41,36,37,38,39,40,41,37,38,40,38,39 +}; + +static int KAXX[] = {32,33,34,34,34,34,34,34,35,35,35,35,35,35,35,35,35,35,35,36,36,36,36,36,37,37,37,37,38,38,38,38,38,38,38,38,38,38,38,39,39,39,39,39,39,39,39,39,40,40,40,40,40,40,40,40,41,41,41,41,41,41,41,41,41,42,42,42,42,42,42,42,42,42,42,42,42,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,46,46,46,46,46,46,46,46,46,46,46,46,46,46,46,46,46,46,46,46,46,46,46,46,46,46,46,47,47,47,47,47,47,47,47,47,47,47,47,47,47,47,47,47,47,47,47,47,47,47,47,47,47,47,47,47,47,47,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,51,51,51,51,51,51,51,51,51,51,51,51,51,51,51,51,51,51,51,51,51,51,52,52,52,52,52,52,52,52,52,52,52,52,52,52,52,52,52,52,52,52,52,53,53,53,53,53,53,53,53,53,53,53,53,53,53,53,53,53,53,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,55,55,55,55,55,55,55,55,55,55,55,55,55,55,55,55,55,55,55,55,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,58,58,58,58,58,58,58,58,58,58,58,58,58,58,58,58,58,58,58,58,58,58,58,58,58,58,58,58,58,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,63,63,63,63,63,63,63,63,63,63,63,63,63,63,63,63,63,63,63,63,63,63,63,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,67,67,67,67,67,67,67,67,67,67,67,67,67,67,67,67,67,67,67,67,67,67,67,67,68,68,68,68,68,68,68,68,68,68,68,68,68,68,68,68,68,68,68,68,68,68,68,68,68,68,68,69,69,69,69,69,69,69,69,69,69,69,69,69,69,69,69,69,69,69,69,69,69,69,69,69,69,69,69,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,72,72,72,72,72,72,72,72,72,72,72,72,72,72,72,72,72,72,72,72,72,72,72,72,72,72,72,72,73,73,73,73,73,73,73,73,73,73,73,73,73,73,73,73,73,73,73,73,73,73,73,73,73,73,73,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,76,76,76,76,76,76,76,76,76,76,76,76,76,76,76,76,76,76,76,76,76,76,76,76,76,76,76,76,76,76,76,76,76,76,76,77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,78,78,78,78,78,78,78,78,78,78,78,78,78,78,78,78,78,78,78,78,78,78,78,78,79,79,79,79,79,79,79,79,79,79,79,79,79,79,79,79,79,79,79,79,79,79,79,79,79,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,81,81,81,81,81,81,81,81,81,81,81,81,81,81,81,81,81,81,81,81,81,81,81,81,81,81,81,81,81,81,82,82,82,82,82,82,82,82,82,82,82,82,82,82,82,82,82,82,82,82,82,82,82,82,82,82,82,82,82,82,82,82,82,82,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,87,87,87,87,87,87,87,87,87,87,87,88,88,88,88,88,88,88,88,88,88,88,89,89,89,89,89,89,89,89,89,89,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,91,91,91,91,91,91,91,91,91,91,91,91,92,92,92,92,92,92,92,92,92,92,93,93,93,93,93,93,93,94,94,94,94,94,94,94,94,95,95,95,95,95,95,95,95,95,95,95,95,95,95,95,95,96,96,96,96,96,96,96,96,96,96,96,97,97,97,97,97,97,97,97,97,98,98,98,98,98,98,98,98,99,99,99,99,99,99,99,99,99,100,100,100,100,101,101,101 +}; + +static int KAXY[] = {65,65,60,61,62,63,64,66,37,38,39,40,41,42,43,44,45,59,67,36,46,58,68,69,35,47,58,70,35,48,58,60,61,62,63,64,65,66,71,35,48,58,60,67,72,99,100,101,35,48,58,60,68,73,98,101,35,48,58,60,61,69,74,97,102,34,49,58,60,61,62,67,70,74,96,97,102,34,50,51,57,60,61,63,66,68,71,75,89,90,91,92,93,94,95,96,97,102,33,48,52,53,54,55,56,60,61,64,65,69,72,76,90,96,98,99,100,101,32,38,39,40,41,42,43,46,47,49,59,61,64,65,70,73,76,82,83,91,96,33,34,37,44,45,50,53,54,55,56,57,58,61,64,71,74,77,78,79,80,81,84,88,89,90,91,96,35,36,50,52,61,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,85,87,91,92,97,104,105,106,107,108,38,39,40,41,50,52,61,64,73,76,79,86,93,98,103,108,37,39,42,50,51,61,65,73,77,78,94,99,101,102,107,37,39,40,41,42,43,44,45,46,47,50,52,61,66,73,77,78,81,94,100,102,106,116,37,40,43,48,50,52,55,56,57,61,65,73,76,79,81,95,101,103,105,114,115,116,37,40,43,49,50,52,53,55,58,61,64,74,75,80,81,95,100,104,112,113,115,38,40,44,49,51,52,55,58,61,63,74,75,76,81,96,100,111,115,38,40,44,48,49,51,55,59,61,62,73,77,81,96,100,104,105,106,107,108,109,110,115,116,37,40,44,48,49,51,52,53,54,55,59,61,62,73,78,81,96,100,103,117,36,40,41,44,48,49,59,60,63,69,72,77,81,96,100,102,116,37,40,45,47,50,58,60,62,68,69,73,76,81,96,99,101,110,116,38,39,40,41,42,43,44,45,46,51,52,53,54,55,56,57,59,62,67,70,74,75,80,81,95,98,100,110,115,40,45,58,62,66,69,74,75,79,90,91,92,93,94,98,100,110,111,114,36,40,41,42,43,44,45,46,47,57,62,65,68,74,76,77,78,90,98,100,110,111,114,36,37,44,47,48,49,50,51,52,53,54,55,56,61,64,67,74,76,78,90,99,101,111,113,36,38,42,43,46,47,53,54,55,56,57,58,59,60,61,63,66,73,76,79,90,99,101,102,111,112,113,36,39,40,41,46,47,52,62,67,69,70,71,72,77,80,81,82,90,100,101,102,112,113,37,41,45,47,51,60,61,68,77,82,83,84,85,86,87,88,89,90,101,102,112,38,45,48,50,59,68,69,70,71,72,73,74,75,76,77,78,88,89,90,91,92,93,94,95,96,97,102,103,113,39,40,44,48,50,58,63,67,70,78,79,80,88,97,102,104,105,106,107,108,109,110,114,37,40,41,43,44,47,50,56,57,58,62,64,65,66,70,79,80,81,88,97,98,102,110,114,37,38,39,41,42,43,44,47,50,51,52,53,54,55,56,61,64,65,70,80,81,82,88,99,102,110,114,37,38,39,40,44,46,47,49,50,57,58,59,60,63,66,70,81,82,83,84,85,88,90,91,100,102,110,114,40,41,42,43,44,45,47,48,49,55,56,62,67,70,81,83,85,86,87,90,91,99,102,110,114,35,41,43,45,46,49,53,54,63,67,70,80,84,85,87,90,91,97,98,99,102,107,110,114,35,37,38,39,40,41,42,46,49,54,63,67,71,79,85,86,87,89,91,94,95,96,103,106,108,109,111,114,35,36,37,39,40,41,46,49,55,63,67,72,79,84,85,86,87,88,91,93,94,103,104,105,109,112,115,46,50,56,63,67,73,75,79,83,87,91,95,96,97,98,99,100,101,109,113,116,46,51,52,57,64,68,74,75,76,79,82,88,89,90,91,101,109,112,115,117,47,53,58,65,69,74,75,77,78,79,81,84,85,86,87,88,89,90,91,96,97,98,101,106,107,108,109,110,111,112,113,114,118,119,120,47,54,59,60,65,70,74,75,80,83,90,91,95,99,101,105,109,111,113,120,47,53,54,55,56,57,61,65,71,74,75,79,82,90,95,100,101,105,109,110,112,115,116,120,47,52,54,58,62,65,71,74,75,76,77,78,81,90,94,101,105,108,110,111,112,113,114,117,121,47,51,53,59,63,65,71,73,77,80,90,92,93,96,97,98,101,105,107,110,111,117,121,46,50,51,52,60,64,65,70,72,73,77,80,90,91,92,93,96,99,105,106,109,110,111,112,113,114,115,116,117,121,46,54,55,56,57,61,65,69,71,73,77,80,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,107,108,120,46,51,52,53,58,62,68,70,72,76,80,86,90,95,96,99,100,101,105,107,108,118,119,120,46,48,49,50,59,63,67,69,71,75,81,85,90,96,98,99,101,104,106,109,117,46,47,60,63,64,65,66,68,71,74,76,77,78,79,80,81,84,89,97,99,100,102,103,104,105,109,116,60,63,67,70,72,73,74,75,76,77,81,82,83,87,88,96,99,101,102,109,116,60,64,65,66,69,73,86,96,101,108,116,61,62,63,68,74,75,86,97,100,107,116,61,62,67,75,86,98,99,100,107,116,62,67,76,86,87,89,90,91,92,93,94,95,96,97,98,107,116,63,67,76,86,87,88,107,111,112,113,114,115,63,64,67,76,85,86,87,88,107,110,64,67,76,84,87,107,109,64,65,66,75,83,88,107,109,63,66,72,73,74,80,81,82,83,84,85,86,87,88,108,109,62,65,67,68,69,70,71,79,82,108,109,62,63,64,70,72,77,78,80,81,61,62,63,70,71,73,77,79,61,62,72,73,74,75,76,77,78,61,62,73,77,74,75,76 +}; + +static int TMXX[] = {33,33,34,34,34,34,34,34,35,35,35,35,35,35,35,35,35,35,35,35,35,36,36,36,36,36,36,36,36,36,36,37,37,37,37,37,37,37,37,37,37,38,38,38,38,38,38,38,38,38,38,38,38,38,38,38,38,38,38,38,38,38,39,39,39,39,39,39,39,39,40,40,40,40,40,40,40,40,40,41,41,41,41,41,41,41,41,41,41,42,42,42,42,42,42,42,43,43,43,43,43,43,43,43,44,44,44,44,44,44,44,44,45,45,45,45,45,45,45,45,46,46,46,46,46,46,46,46,46,47,47,47,47,47,47,47,47,47,47,47,47,47,47,47,47,47,47,47,47,47,47,47,47,47,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,49,49,49,49,49,49,49,49,49,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,51,51,51,51,51,51,51,51,51,51,51,51,51,51,51,51,51,51,51,52,52,52,52,52,52,52,52,52,52,52,52,52,52,52,52,52,52,52,52,52,52,52,52,52,52,53,53,53,53,53,53,53,53,53,53,53,53,53,53,53,53,53,53,53,53,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,55,55,55,55,55,55,55,55,55,55,55,55,55,55,55,55,55,55,55,55,55,55,55,55,55,55,55,55,55,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,58,58,58,58,58,58,58,58,58,58,58,58,58,58,58,58,58,58,58,58,58,58,58,58,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,63,63,63,63,63,63,63,63,63,63,63,63,63,63,63,63,63,63,63,63,63,63,63,63,63,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,67,67,67,67,67,67,67,67,67,67,67,67,67,67,67,67,67,67,68,68,68,68,68,68,68,68,68,68,68,68,68,68,68,68,68,68,68,68,68,69,69,69,69,69,69,69,69,69,69,69,69,69,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,71,71,71,71,71,71,71,71,71,72,72,72,72,72,72,73,73,73,73,73,74,74,74,74,74,75,75,75,75,75,75,75,75,75,75,75,75,76,76,76,76,76,76,76,76,76,76,76,76,76,76,77,77,77,77,77,77,78,78,78,78,78,78,78,78,78,79,79,79,79,79,79,79,80,80,80,80,80,80,80,80,80,81,81,81,81,81,81,81,81,81,81,81,81,81,82,82,82,82,82,82,82,83,83,83,83,83,83,83,83,83,83,84,84,84,84,84,84,84 +}; + +static int TMXY[] = {78,85,58,77,79,84,85,86,56,57,58,74,75,76,80,81,83,87,88,89,90,57,58,73,74,82,86,87,88,90,91,57,59,60,61,62,63,73,85,89,91,57,59,64,65,66,67,68,69,70,71,72,77,78,79,80,81,82,83,84,90,91,57,61,74,75,76,84,85,91,55,56,57,60,61,74,84,86,92,51,52,54,55,59,61,74,84,87,88,48,55,58,61,73,84,88,47,48,55,57,61,72,84,88,47,48,56,57,61,71,84,88,47,48,56,57,61,71,84,88,47,48,57,58,60,61,71,84,88,42,43,44,47,57,59,60,61,62,63,64,65,66,67,71,79,80,81,82,83,84,85,86,87,89,39,40,41,44,45,46,47,48,49,50,51,52,53,54,55,56,61,67,71,79,80,81,83,84,90,39,61,67,71,79,81,82,85,90,36,37,38,47,48,49,50,51,60,67,70,78,79,81,86,87,90,37,46,47,48,49,51,52,59,63,64,65,66,67,70,78,79,81,87,91,37,41,45,49,50,51,52,57,58,62,67,68,69,70,71,72,73,74,75,76,78,79,80,81,88,91,37,40,41,42,44,49,52,53,54,57,61,67,70,76,79,80,81,82,89,91,35,36,38,39,40,41,42,43,44,45,48,49,52,53,54,55,57,60,62,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,82,90,92,35,39,40,41,43,44,45,46,47,48,49,50,51,54,55,57,60,63,65,67,71,74,77,78,80,81,82,91,92,35,38,39,40,42,48,49,50,51,54,55,57,58,59,64,67,71,73,76,77,81,91,92,33,34,37,38,39,40,41,48,51,52,53,54,55,56,57,58,63,64,65,67,71,73,75,80,91,92,33,36,37,38,39,40,49,52,55,56,57,58,67,68,69,70,71,72,73,74,78,79,80,92,33,34,35,36,37,38,40,49,50,55,56,57,70,71,72,73,76,77,82,83,84,85,86,87,92,33,37,38,39,40,41,49,50,52,55,56,57,69,70,72,73,74,75,80,81,87,33,37,38,39,40,41,48,50,51,52,53,54,55,56,57,58,69,72,73,74,75,78,79,80,87,33,34,38,39,42,48,49,50,51,52,53,54,55,57,68,69,76,77,87,34,35,37,38,39,40,41,42,44,45,46,47,48,49,50,54,55,56,57,68,69,77,78,84,87,35,38,39,40,41,42,43,44,45,48,53,57,58,68,77,79,80,84,85,88,34,40,41,42,44,45,46,51,52,57,58,68,69,77,80,83,85,89,90,91,31,32,33,40,42,43,44,50,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,69,77,79,83,85,86,88,30,31,39,40,41,42,43,48,49,52,59,62,67,77,78,82,86,88,30,33,42,43,44,45,46,47,48,49,50,51,59,63,67,76,77,81,86,87,88,30,31,32,60,64,68,75,76,77,80,81,85,86,61,65,69,70,71,72,73,74,75,76,77,79,80,81,82,83,84,86,62,66,73,76,77,78,84,85,86,63,67,73,78,82,86,64,68,71,72,78,65,69,70,71,78,66,70,71,72,73,74,75,76,77,78,79,80,66,68,69,70,71,72,73,74,75,76,77,78,79,80,67,68,70,71,75,79,68,69,70,71,72,73,74,75,80,68,71,74,76,78,80,81,68,72,75,77,79,82,83,84,85,68,69,70,71,72,73,76,78,79,80,82,83,86,68,72,81,82,83,84,86,73,74,75,76,77,78,79,80,81,86,73,74,82,83,84,85,86 +}; + +static int KTXX[] = {62,62,62,62,62,62,62,63,63,63,64,64,64,64,64,64,64,64,64,65,65,65,65,65,65,65,65,65,65,65,65,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,67,67,67,67,67,67,67,67,67,67,68,68,68,68,68,68,68,68,68,68,68,68,68,69,69,69,69,69,69,69,69,69,69,69,69,69,69,69,69,69,69,69,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,72,72,72,72,72,72,72,72,72,72,72,72,72,72,72,72,72,72,72,72,72,72,72,72,73,73,73,73,73,73,73,73,73,73,73,73,73,73,73,73,73,73,73,74,74,74,74,74,74,74,74,74,74,74,74,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,76,76,76,76,76,76,76,76,76,76,76,76,76,76,76,76,77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,78,78,78,78,78,78,78,78,78,78,78,78,78,78,78,78,79,79,79,79,79,79,79,79,79,79,79,79,79,79,79,79,79,79,79,79,79,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,81,81,81,81,81,81,81,81,81,81,81,81,81,81,82,82,82,82,82,82,82,82,82,82,82,82,82,82,82,82,82,82,82,82,82,82,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,87,87,87,87,87,87,87,87,87,87,87,87,87,87,87,87,87,87,87,87,87,88,88,88,88,88,88,88,88,88,88,88,88,88,88,88,88,88,88,89,89,89,89,89,89,89,89,89,89,89,89,89,90,90,90,90,90,90,90,90,90,90,90,91,91,91,91,91,91,91,91,91,92,92,92,92,92,92,92,92,92,92,92,92,92,92,92,92,92,92,92,92,93,93,93,93,93,93,93,94,94,94,94,94,94,94,94,94,94,94,94,94,94,95,95,95,95,95,95,95,95,95,95,95,95,95,95,95,95,96,96,96,96,96,96,96,96,96,97,97,97,97,97,97,97,97,97,97,97,97,98,98,98,98,98,98,98,98,98,98,98,98,98,99,99,99,99,99,99,99,99,99,99,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,101,101,101,101,101,102,102,102,102,102,102,102,103,103,103,103,103,103,103,103,104,104,104,104,104,104,104,104,104,104,105,105,105,105,105,105,105,105,105,105,105,105,105,105,106,106,106,106,106,106,106,106,107,107,107,107,107,107,107,108,108,108,108,109,109,109,109,109,109,110,110,110,110,110,110,110,110 +}; + +static int KTXY[] = {90,91,92,93,94,95,96,90,96,105,90,96,97,98,99,100,102,104,105,88,89,90,91,92,100,102,103,105,106,109,110,83,84,85,86,87,88,90,91,99,102,104,105,106,107,108,109,82,87,90,99,102,105,108,110,111,112,81,87,90,98,99,100,101,103,105,106,107,109,112,74,75,76,77,78,79,80,84,85,86,87,91,97,100,102,104,105,110,112,74,75,83,85,88,89,92,96,100,102,104,105,110,111,112,113,114,115,75,77,78,82,85,90,91,92,93,94,95,96,100,101,103,104,105,106,107,108,109,110,111,113,114,115,75,77,79,80,81,82,83,84,91,94,96,97,98,99,100,101,102,103,108,109,110,113,114,115,75,77,80,91,94,97,99,100,101,102,103,104,105,106,107,110,111,112,113,75,78,80,91,94,96,100,101,110,112,113,116,73,74,78,79,92,95,99,100,106,109,110,113,114,115,116,72,76,77,78,91,94,96,98,100,107,108,110,112,113,114,116,71,75,76,77,80,81,82,83,84,85,86,87,88,89,90,93,95,97,99,106,107,110,114,116,71,74,75,78,79,92,94,96,97,98,105,106,111,112,115,117,71,73,74,75,79,80,81,82,83,84,92,95,96,98,104,105,111,112,113,115,117,71,74,85,86,87,88,89,90,91,93,95,96,97,98,99,100,111,113,115,117,72,74,91,92,94,95,97,98,99,101,111,113,115,117,72,74,84,85,86,87,88,90,94,95,96,97,98,99,100,101,102,111,113,114,116,117,72,74,83,89,94,101,102,103,104,105,106,107,108,109,111,113,114,115,116,71,72,73,74,80,81,83,88,90,94,95,96,97,99,100,101,102,104,105,110,111,112,113,114,115,70,71,74,79,82,83,84,85,86,87,89,90,91,92,93,94,102,103,104,105,108,109,110,111,115,69,70,71,72,73,74,75,76,78,82,83,85,88,89,90,94,102,104,105,106,107,108,109,111,115,67,68,75,76,77,78,79,80,81,86,94,102,104,107,109,110,111,112,113,114,116,67,77,78,85,87,88,89,90,91,95,101,102,104,107,109,114,115,116,67,77,78,85,92,95,100,102,103,104,105,106,109,67,76,77,78,85,93,95,100,103,108,109,67,77,85,93,95,100,102,107,108,67,68,69,70,71,72,73,74,77,85,94,95,100,101,102,103,104,105,106,107,75,86,94,95,100,102,106,75,79,80,81,82,83,87,94,96,99,100,101,104,105,74,75,76,77,78,79,84,88,94,96,98,99,100,103,104,106,85,89,94,96,97,99,102,103,107,85,89,94,95,98,99,100,101,102,103,104,108,86,88,94,95,96,97,98,101,102,103,105,106,109,86,88,93,97,101,102,106,107,108,109,86,87,88,89,90,91,92,93,94,95,96,97,98,99,101,102,109,86,87,93,101,110,85,88,92,93,94,101,110,85,86,87,88,89,90,91,100,85,86,88,89,91,92,93,98,99,100,85,86,87,88,89,90,91,92,93,94,95,96,97,98,83,84,85,89,94,95,96,98,82,83,84,85,96,97,98,80,81,82,83,76,77,78,79,81,83,75,76,77,78,79,80,81,83 +}; + + +static int WLXX[] = {44,44,44,44,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,46,46,46,46,46,46,46,46,46,46,46,46,47,47,47,47,47,47,47,47,47,47,47,47,47,47,47,47,47,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,49,49,49,49,49,49,49,49,49,49,49,49,49,50,50,50,50,50,50,50,50,50,50,50,50,50,50,51,51,51,51,51,51,51,51,51,51,52,52,52,52,52,52,52,52,52,53,53,53,53,53,53,53,53,53,53,53,53,53,53,53,53,53,53,53,53,53,53,53,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,55,55,55,55,55,55,55,55,55,55,55,55,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,58,58,58,58,58,58,58,58,58,58,58,58,58,58,58,58,58,58,58,58,58,58,58,58,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,63,63,63,63,63,63,63,63,63,63,63,63,63,63,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,65,65,65,65,65,65,65,65,65,65,65,66,66,66,66,66,66,66,66,66,66,67,67,67,67,67,67,67,67,67,67,67,68,68,68,68,68,68,68,68,68,68,68,68,68,68,69,69,69,69,69,70,70,70,70,70,70,71,71,71,71,71,71,72,72,72 +}; + +static int WLXY[] = {63,64,65,66,40,41,42,43,44,46,47,48,52,53,54,55,59,60,61,62,67,68,39,40,44,45,49,50,51,55,56,57,58,68,38,39,44,45,46,47,48,49,50,51,57,58,59,64,65,66,68,37,38,41,42,43,45,51,55,56,60,61,64,66,67,68,37,39,40,41,42,43,44,45,52,55,61,67,68,37,43,53,55,61,67,68,69,70,72,73,74,75,76,37,44,51,52,53,54,61,67,71,77,37,44,51,52,53,55,61,67,77,36,44,46,50,51,55,56,57,58,59,60,61,66,67,68,69,70,71,72,73,74,75,77,35,44,45,47,48,49,50,51,56,57,61,62,63,66,67,76,77,35,44,45,47,51,54,55,57,61,64,65,76,35,44,45,46,47,48,49,50,51,52,53,58,60,61,62,63,64,65,76,77,35,43,44,47,50,51,53,54,55,56,58,59,60,61,63,65,76,77,36,43,44,45,46,48,49,51,52,53,55,56,57,61,62,64,66,71,72,73,74,75,76,77,36,37,42,43,44,47,49,51,53,54,57,58,61,62,65,67,70,72,73,77,37,38,39,40,41,42,43,49,50,52,53,54,55,57,62,65,68,69,71,74,75,76,77,37,38,39,40,41,43,49,53,54,55,57,62,65,66,67,69,71,39,42,43,49,50,51,52,53,54,55,57,62,64,65,69,71,39,40,41,48,51,53,55,56,57,62,65,66,69,71,40,47,48,50,51,52,53,54,56,57,58,59,60,61,62,66,67,68,71,47,49,50,51,52,54,56,57,68,69,70,45,46,47,48,49,50,51,53,55,57,43,44,45,46,48,49,52,53,54,57,58,42,43,44,45,46,47,48,49,50,51,53,54,55,56,42,45,46,49,50,43,44,45,47,48,49,43,44,46,47,48,49,43,45,49 +}; + +static int HETXX[] = {16,16,16,16,16,16,16,16,16,16,16,16,16,16,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,18,18,18,18,18,19,19,19,19,19,19,19,19,19,19,19,19,20,20,20,20,20,20,20,20,20,21,21,21,21,21,22,22,22,22,23,23,23,23,23,23,23,23,23,24,24,24,24,24,24,24,24,24,24,24,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,30,30,30,30,30,30,30,30,30,30,30,30,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,32,32,32,32,32,32,32,32,32,32,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,34,34,34,34,34,34,34,34,34,34,34,34,34,34,34,35,35,35,35,35,35,35,35,35,35,35,35,36,36,36,36,36,36,36,36,36,36,36,36,36,36,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,38,38,38,38,38,38,38,38,38,38,38,38,38,38,38,39,39,39,39,39,39,39,39,39,39,39,39,39,39,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,44,44,44,44,44,44,44,44,44,44,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,46,46,46,46,46,46,46,46,46,46,46,46,46,46,46,46,47,47,47,47,47,47,47,47,47,47,47,47,47,47,47,47,47,47,47,47,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,51,51,51,51,51,51,51,51,51,51,51,51,51,51,51,51,51,51,51,51,51,51,51,51,51,51,51,52,52,52,52,52,52,52,52,52,52,52,52,52,52,52,52,52,52,52,52,52,52,52,52,53,53,53,53,53,53,53,53,53,53,53,53,53,53,53,53,53,53,53,53,53,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,55,55,55,55,55,55,55,55,55,55,55,55,55,55,55,56,56,56,56,56,56,56,56,56,56,56,56,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,58,58,58,58,58,58,58,58,58,58,58,58,58,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,63,63,63,63,63,63,63,63,63,63,63,63,63,63,63,63,63,63,63,63,63,63,63,63,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,67,67,67,67,67,67,67,67,67,67,67,67,67,67,67,67,67,67,67,67,67,67,67,67,67,67,67,67,67,68,68,68,68,68,68,68,68,68,68,68,68,68,68,68,68,68,68,68,69,69,69,69,69,69,69,69,69,69,69,69,69,69,69,69,69,69,70,70,70,70,70,70,70,70,71,71,71,71,71,71,71,72,72,72,72,72,73,73,73,73,73,73,73,74,74,74,74,75,75,75,75,76,76,77,77,77,77,77,77,78,78,79,79,80,80,80,81,81,81,82,82,82,82,83,83,83,83,83,83,83,84,84,84,84,84,84,85,85,85 +}; + +static int HETXY[] = {18,19,20,25,26,27,28,29,36,37,38,39,40,41,17,21,22,23,24,30,31,32,33,34,35,42,43,47,48,16,44,45,46,48,16,28,33,34,35,36,37,38,39,40,41,48,17,27,29,30,31,32,42,43,48,17,18,26,43,48,18,26,43,48,18,26,30,31,32,33,44,48,59,18,26,30,34,44,47,59,60,65,66,67,18,19,26,30,35,44,46,47,57,58,59,61,62,63,64,68,18,20,21,26,30,36,37,44,48,49,50,51,52,53,54,55,56,63,69,70,17,22,26,29,31,32,38,39,40,41,42,43,44,54,55,56,57,58,63,64,71,72,73,26,29,32,33,34,35,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,65,66,73,26,28,32,36,37,38,39,40,41,46,54,63,67,68,69,73,26,28,32,42,43,44,47,54,64,65,69,73,18,19,20,21,22,23,24,25,26,28,29,30,31,44,48,49,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,73,19,28,44,50,52,54,66,67,70,73,20,28,29,44,49,52,55,56,57,58,59,67,70,71,73,21,28,30,31,32,33,34,45,48,52,60,66,70,71,73,22,28,35,45,47,52,56,61,66,69,71,73,22,28,36,44,45,47,52,56,57,61,65,68,71,73,23,28,35,36,37,38,39,40,41,42,43,47,51,56,58,61,64,68,71,73,23,28,34,36,37,47,50,56,59,60,61,63,68,71,73,24,25,29,34,38,46,49,56,61,62,69,71,73,81,26,30,31,32,35,39,40,41,42,43,44,45,49,53,54,55,56,60,66,70,71,74,80,81,27,32,35,43,44,48,53,55,57,58,59,65,67,71,72,75,76,77,78,79,81,27,32,35,43,45,48,53,54,58,59,60,61,62,63,64,67,71,72,81,27,31,35,43,46,47,51,52,53,54,58,67,71,72,81,27,30,35,47,51,54,57,67,72,81,28,31,32,34,43,47,48,49,51,54,57,62,67,72,73,74,75,80,28,33,34,43,44,47,50,51,54,56,61,62,67,72,75,79,29,36,37,38,39,40,41,42,43,44,48,51,55,56,60,63,67,72,75,79,30,31,32,33,34,36,40,44,47,50,51,55,56,59,63,68,69,70,72,75,80,30,31,34,36,39,44,45,46,49,51,52,53,54,57,58,64,69,72,75,81,30,31,34,36,39,43,44,47,48,57,58,64,68,71,75,81,29,30,31,32,33,34,36,38,42,44,46,47,48,56,59,60,61,62,63,64,67,70,71,72,73,75,81,27,28,31,32,35,39,40,41,43,45,47,48,49,50,51,55,64,65,67,69,70,74,75,80,27,32,34,36,38,39,43,44,46,47,50,52,54,62,63,66,67,68,70,76,79,28,29,30,31,33,34,35,36,37,38,39,40,41,42,43,44,45,46,51,52,53,54,55,56,57,58,59,60,61,65,67,68,70,79,29,30,31,32,35,36,41,43,45,53,64,67,68,70,79,30,31,36,40,43,44,53,64,67,68,70,79,30,31,36,37,38,39,40,41,42,43,53,54,64,67,68,70,79,29,30,31,36,39,44,53,54,64,67,68,70,78,28,30,32,36,38,39,45,46,53,54,65,67,68,70,77,27,29,30,31,32,33,34,35,36,37,38,40,47,48,49,50,51,52,53,54,66,67,68,70,76,27,29,30,31,36,39,41,42,46,54,55,56,57,58,59,60,61,62,63,64,65,66,68,69,75,27,28,30,31,32,33,35,38,40,43,45,46,49,50,51,54,55,65,68,74,27,28,29,32,33,34,35,36,37,41,42,43,44,47,48,50,53,56,64,67,68,71,72,73,27,28,30,31,35,44,46,47,49,53,57,58,60,61,62,63,64,65,66,68,71,24,25,26,27,29,32,35,43,45,48,49,52,54,55,56,57,58,59,62,68,70,23,24,25,26,29,33,34,35,44,48,49,51,53,60,61,67,70,25,26,27,29,35,36,42,43,48,49,51,52,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,25,28,36,42,48,50,51,53,56,57,58,59,60,62,63,64,65,66,67,25,26,27,28,36,37,38,41,49,52,53,54,55,56,60,61,66,67,37,39,40,41,48,49,52,53,37,40,48,49,50,51,53,37,40,48,49,53,37,39,48,49,50,51,52,37,40,48,49,37,41,42,43,37,43,36,38,39,40,41,42,36,38,35,39,35,40,41,33,34,41,32,34,35,41,31,34,36,37,38,39,41,30,32,33,39,40,41,30,31,32 +}; + +static int DDXX[] = {30,31,31,32,32,33,33,33,33,33,33,34,34,34,34,34,34,34,35,35,35,35,35,35,36,36,36,36,37,37,37,37,37,37,37,38,38,38,38,38,39,39,39,39,39,40,40,40,40,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,43,43,43,43,43,43,43,43,43,44,44,44,44,44,44,45,45,45,45,45,45,45,45,45,45,45,46,46,46,46,46,46,46,46,47,47,47,47,47,47,47,47,47,47,48,48,48,48,48,48,48,48,48,49,49,49,49,49,49,49,49,49,49,49,49,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,51,51,51,51,51,51,51,51,51,51,51,51,51,51,51,51,52,52,52,52,52,52,52,52,52,52,52,52,52,52,52,52,52,52,52,52,52,52,53,53,53,53,53,53,53,53,53,53,53,53,53,53,53,53,53,53,54,54,54,54,54,54,54,54,54,54,54,54,54,54,55,55,55,55,55,55,55,55,55,55,55,55,56,56,56,56,56,56,56,56,56,56,56,56,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,58,58,58,58,58,58,58,58,58,58,58,59,59,59,59,59,59,59,59,60,60,60,60,60,60,61,61,61,61,61,62,62,62,63,63,63,64,64,64,64,64,64,64,64,65,65,65,65,65,65,65,65,65,65,65,65,66,66,66,66,66,66,66,66,67,67,68,68,68,68,68,68,68,68,68,68,69,69,69,69,69,69,69,69,69,70,70,70,70,70,70,70,70,70,70,70,71,71,71,71,71,71,71,71,71,72,72,72,72,72,72,72,72,72,72,72,72,72,72,72,72,73,73,73,73,73,73,73,73,73,73,73,74,74,74,74,74,74,74,74,75,75,75,75,75,75,75,75,75,75,76,76,76,76,76,76,76,76,76,77,77,77,77,77,77,77,77,78,78,78,78,78,79,79,80,80,80,81,81,81,81,81,81,81,82,82,82,83,83,84,84,84,84,84,84,84,85,85,85,85,85,85,85,86,86,86,86,87,87, +}; + +static int DDXY[] = {46,45,46,44,45,44,46,49,50,51,52,44,45,47,48,50,51,53,45,46,47,49,52,53,45,48,52,53,45,46,47,48,49,51,52,44,45,50,51,52,43,44,45,50,52,45,50,51,52,45,49,50,53,54,55,56,57,58,59,62,63,64,65,69,70,71,72,45,48,57,58,59,60,61,62,66,67,68,72,73,74,75,45,47,58,59,63,66,67,76,77,45,46,59,63,64,76,45,51,52,53,54,58,60,63,65,75,76,45,50,55,58,60,64,65,76,44,46,49,55,58,63,64,65,66,76,44,47,49,56,57,63,65,67,76,44,47,48,49,50,51,56,57,62,65,67,76,45,48,50,51,52,53,54,55,56,57,58,63,65,67,68,69,70,74,75,46,47,48,49,50,58,59,60,61,62,63,64,65,68,69,74,41,42,43,46,48,49,51,56,59,60,61,62,65,66,67,70,71,72,73,75,76,77,41,43,45,46,47,50,51,52,55,57,58,67,68,72,73,74,76,77,40,41,43,44,46,47,50,51,53,54,68,69,73,76,41,42,43,48,50,52,58,59,70,71,73,75,42,43,44,49,50,52,57,59,71,72,73,75,44,45,46,47,48,49,50,51,53,56,59,70,73,74,75,45,46,50,52,53,55,58,59,69,73,75,47,48,49,50,53,54,58,69,50,53,54,56,57,69,50,51,52,55,69,51,52,69,51,52,69,51,52,66,67,68,69,70,71,52,64,65,68,69,70,71,72,73,74,75,76,52,61,62,63,66,67,68,75,52,61,50,51,52,53,54,55,56,57,58,61,50,51,53,54,55,56,57,59,61,49,50,52,53,54,55,56,57,58,60,61,41,47,48,49,52,54,57,59,60,41,42,45,46,47,48,50,51,53,54,55,56,57,58,59,60,42,43,44,49,51,52,54,55,57,59,60,42,43,49,51,52,55,58,60,42,44,49,50,51,52,55,57,58,60,42,44,49,50,52,55,56,58,60,43,44,49,50,51,55,58,59,43,44,55,58,61,58,61,58,59,61,55,56,57,58,59,60,61,54,55,58,53,59,52,53,56,57,58,60,61,51,52,54,55,58,59,60,52,53,58,59,57,58, +}; + +static int SMDXX[] = {17,17,17,17,17,18,18,18,18,18,18,19,19,19,19,19,19,19,19,19,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,21,21,21,21,21,21,21,21,22,22,22,22,22,22,22,23,23,23,23,23,23,23,24,24,24,24,24,24,24,25,25,25,25,25,25,25,25,26,26,26,26,26,26,26,27,27,27,27,27,27,27,27,27,27,28,28,28,28,28,28,29,29,29,29,29,29,29,29,29,29,29,29,29,29,30,30,30,30,30,30,30,30,31,31,31,31,31,31,31,31,31,31,32,32,32,32,32,32,32,33,33,33,33,33,33,33,33,34,34,34,34,34,34,35,35,35,35,35,35,36,36,36,36,36,36,36,36,36,36,36,36,37,37,37,37,37,37,37,37,37,37,37,38,38,38,38,38,38,39,39,39,39,39,39,40,40,40,40,40,40,40,41,41,41,41,41,41,41,41,42,42,42,42,42,42,42,43,43,43,43,43,43,44,44,44,44,44,44,44,44,44,44,45,45,45,45,45,45,45,45,45,46,46,46,46,46,46,46,46,46,46,46,47,47,47,47,47,47,47,47,47,47,47,48,48,48,48,48,48,48,48,48,48,48,48,48,48,49,49,49,49,49,49,49,49,50,50,50,50,50,50,51,51,51,51,51,51,52,52,52,52,52,52,52,52,52,52,52,52,52,53,53,53,53,53,53,53,54,54,54,54,54,54,55,55,55,55,55,55,55,55,55,55,56,56,56,56,56,56,56,56,56,56,56,56,56,57,57,57,57,57,57,57,57,58,58,58,58,58,58,58,58,59,59,59,59,59,59,59,60,60,60,60,60,61,61,61,61,62,62,62,62,62,62,62,62,63,63,63,63,63,63,63,63,63,63,64,64,64,64,64,64,64,64,64,64,64,65,65,65,65,65,65,66,66,66,66,66,66,67,67,67,67,67,68,68,68,68,68,68,68,68,69,69,69,69,69,69,69,69,70,70,70,70,70,70,70,70,70,71,71,71,71,71,71,71,72,72,72,72,72,72,72,72,72,72,72,72,72,72,72,72,73,73,73,73,73,73,73,73,73,73,73,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,75,75,75,75,75,75,75,75,75,75,75,75,76,76,76,76,76,76,76,76,76,76,76,77,77,77,77,77,77,77,77,77,77,77,77,78,78,78,78,78,78,78,78,78,78,78,78,78,78,78,78,78,78,78,78,78,79,79,79,79,79,79,79,79,79,79,79,79,79,79,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,81,81,81,81,81,81,81,81,81,81,81,81,81,81,81,81,81,81,81,81,81,81,81,81,81,82,82,82,82,82,82,82,82,82,82,82,82,82,82,82,82,82,82,82,82,82,82,82,82,82,82,82,82,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,87,87,87,87,87,87,87,87,87,87,87,87,87,87,87,87,88,88,88,88,88,88,88,88,88,88,88,88,88,88,88,88,89,89,89,89,89,89,89,89,89,89,89,90,90,90,90,90,90,90,90,90,90,91,91,91,91,91,91,91,91,91,92,92,92,92,92,92,92,92,92,93,93,93,93,93,93,93,93,94,94,94,94,94,94,94,94,94,95,95,95,95,95,95,95,95,95,95,95,95,96,96,96,96,96,96,96,96,96,96,96,96,96,96,96,97,97,97,97,97,97,97,97,97,97,97,97,97,98,98,98,98,98,98,98,98,98,98,98,98,99,99,99,99,99,99,99,99,99,99,99,99,100,100,100,100,100,100,100,100,100,100,100,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,102,102,102,102,102,102,102,102,102,102,102,102,102,102,102,102,102,102,102,102,103,103,103,103,103,103,103,103,103,104,104,104,104,104,104,104,104,105,105,105,105,105,105,105,105,106,106,106,106,106,106,106,106,106,107,107,107,107,107,107,107,107,107,107,107,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,109,109,109,109,109,109,109,109,109,109,109,109,109,109,109,109,109,109,109,109,110,110,110,110,110,110,110,110,110,110,110,110,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,113,113,113,113,113,113,113,113,113,113,113,113,113,113,113,114,114,114,114,114,114,114,114,114,115,115,115,115,115,115,115,115,115,115,115,115,116,116,116,116,116,116,116,116,116,116,116,116,116,116,116,116,116,116,116,116,116,117,117,117,117,117,117,117,117,117,117,117,117,117,117,117,118,118,118,118,118,118,118,118,118,118,118,118,118,119,119,119,119,119,119,119,119,119,119,119,119,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,121,121,121,121,121,121,121,121,121,121,121,121,121,121,121,121,122,122,122,122,122,122,122,122,122,122,122,122,123,123,123,123,123,123,123,123,123,124,124,124,124,124,124,124,124,124,124,124,125,125,125,125,125,125,125,125,125,125,126,126,126,126,126,126,126,126,126,126,127,127,127,127,127,127,127,127,127,127,127,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,129,129,129,129,129,129,129,129,129,129,129,130,130,130,130,130,130,130,130,130,131,131,131,131,131,131,131,132,132,132,132,133,133,133,133,133,133,133,133,133,133,134,134,135,135,135,135,135,135,135,135,135,135,135,135 +}; + +static int SMDXY[] = {81,82,83,84,85,78,79,80,86,100,101,76,77,87,88,89,90,91,99,102,74,75,78,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,103,72,73,77,79,80,83,93,103,70,71,76,81,82,94,103,69,75,95,99,100,101,104,69,75,95,100,102,105,106,68,76,95,100,103,107,108,109,67,75,76,95,101,104,109,67,74,95,96,97,98,99,102,105,109,66,74,99,103,105,110,66,69,70,71,72,73,74,99,104,105,111,112,113,114,65,66,67,68,99,104,106,115,64,65,100,104,107,108,109,110,111,116,63,64,100,104,111,117,118,62,64,101,104,111,119,120,121,61,64,101,104,111,120,60,64,100,104,111,119,54,55,56,57,60,64,100,105,111,114,115,119,54,58,59,63,99,106,111,112,113,115,119,53,62,99,107,115,119,52,61,100,108,115,119,51,60,101,102,109,115,120,50,59,103,110,115,121,122,123,49,58,104,105,110,115,124,48,57,105,110,115,125,47,56,106,110,114,115,116,117,118,125,43,44,45,46,56,107,110,119,124,41,42,50,51,52,53,56,107,111,120,123,40,48,49,53,54,55,56,107,111,119,122,38,39,41,42,43,44,45,46,47,56,107,112,118,121,36,37,40,107,112,116,117,120,35,39,107,112,115,119,34,39,107,112,114,119,31,32,33,34,35,36,37,38,39,108,112,114,119,30,31,108,111,114,118,119,29,31,107,111,114,117,21,22,23,24,28,31,106,111,114,116,20,24,26,27,28,29,30,31,32,106,111,113,115,21,23,25,26,105,111,113,115,22,23,24,25,105,110,112,115,21,22,105,109,110,111,115,21,106,108,110,115,21,107,111,114,18,19,20,21,22,107,111,114,16,17,18,19,21,23,106,107,110,114,19,20,21,22,102,103,104,105,107,110,114,20,21,102,107,110,114,21,102,103,107,111,114,21,104,107,111,114,21,40,41,42,105,107,110,113,21,38,39,42,106,107,110,113,18,19,20,38,43,105,107,110,113,19,37,42,105,107,110,114,18,20,33,34,35,36,37,38,39,40,41,105,108,109,115,116,19,21,31,32,36,37,105,109,110,117,118,20,22,23,24,25,26,27,28,29,30,32,36,37,38,105,109,111,118,20,25,29,33,35,38,39,105,106,109,112,118,21,24,26,29,32,35,39,107,109,113,118,22,24,27,29,32,35,36,40,108,109,114,119,23,24,28,29,31,35,36,39,41,108,109,115,116,117,118,119,120,121,122,123,124,29,31,32,33,34,35,36,39,42,108,109,112,120,124,38,42,43,44,45,46,47,48,49,50,51,52,53,54,55,72,73,76,82,83,84,85,86,87,107,108,109,111,113,114,121,123,124,125,37,41,44,48,49,50,51,55,72,74,75,76,82,84,85,86,106,109,110,115,120,121,122,124,126,36,40,45,46,47,51,52,53,54,55,72,74,75,76,82,83,105,106,109,110,113,116,117,118,120,121,123,126,35,36,37,38,39,72,73,82,104,108,109,112,114,119,120,122,123,126,71,72,76,77,78,79,80,81,82,101,102,103,107,108,111,115,116,117,118,119,120,121,123,126,71,74,75,76,82,103,106,107,111,120,121,122,123,124,125,126,127,128,129,69,70,73,75,77,78,82,104,111,120,122,123,125,129,130,67,68,72,74,77,78,82,104,109,110,120,122,123,124,126,129,68,69,71,73,74,76,78,82,103,107,108,121,123,125,127,128,70,71,72,75,78,81,102,106,122,126,127,71,74,77,78,80,101,105,123,125,126,71,73,76,78,80,101,105,123,124,71,72,75,78,80,101,105,122,124,71,74,77,80,100,105,122,124,70,71,74,77,80,100,105,122,123,48,49,50,51,69,71,74,76,80,100,104,122,48,50,52,69,71,72,73,74,75,79,101,102,103,104,122,48,50,52,68,70,71,72,74,76,77,78,122,123,48,50,52,67,69,70,72,73,74,75,122,124,48,49,50,53,66,67,68,69,72,74,122,124,49,50,51,54,55,65,68,72,74,122,124,50,52,55,56,57,58,59,60,61,62,63,64,69,72,73,122,124,50,51,53,54,55,56,57,58,63,64,65,69,72,73,117,118,119,120,121,124,51,52,53,54,66,69,72,116,123,51,52,53,66,69,72,116,122,51,52,53,67,69,72,116,121,51,52,53,67,70,72,89,116,120,50,51,52,53,68,71,72,73,89,116,119,44,45,49,50,51,52,53,54,67,70,72,74,88,89,116,118,45,46,47,48,49,50,52,53,54,55,56,67,68,69,73,75,87,89,116,118,46,47,48,49,50,56,74,76,86,88,115,119,47,48,49,50,51,52,53,54,55,56,75,77,85,88,110,111,112,113,114,118,119,120,50,52,53,54,55,56,76,78,79,80,81,82,83,84,88,110,117,121,122,49,50,51,52,76,79,80,87,109,116,122,123,124,125,126,76,79,80,84,85,86,108,110,116,76,78,81,84,92,93,102,107,108,109,111,117,75,78,82,83,84,85,86,87,90,91,94,100,101,103,104,105,106,108,112,113,117,75,77,78,82,83,84,87,91,95,99,108,109,114,115,116,75,76,77,81,83,84,87,92,96,97,98,108,109,81,82,83,84,87,92,101,102,103,107,108,110,83,85,87,90,91,92,95,96,97,100,104,105,106,108,111,83,84,85,86,87,88,89,93,94,95,96,97,98,99,108,112,84,85,87,92,95,99,100,101,102,103,108,113,84,85,87,91,92,95,100,108,114,84,85,87,93,94,95,99,108,110,111,114,85,88,95,96,100,105,106,109,111,114,85,89,90,95,97,100,104,107,111,113,85,91,92,95,97,101,103,108,109,111,113,85,86,87,88,89,90,91,92,93,94,95,98,99,102,110,113,85,87,94,100,101,102,103,104,105,106,112,85,88,89,90,91,92,95,107,112,85,93,94,96,108,109,111,95,97,98,110,95,99,100,101,102,103,104,105,106,107,96,107,97,98,99,100,101,102,103,104,105,106,107,108 +}; + +int QuBiao (int MapId) +{ + int Xy = -1; + int biao = -1; + + if (MapId == 2000) {// + Xy = rand()%1019; + biao = YCXX[Xy]*1000; + biao += YCXY[Xy]; + }else if (MapId == 3000) {//ӼӴ + Xy = rand()%456; + biao = JJXX[Xy]*1000; + biao += JJXY[Xy]; + }else if (MapId == 1000) {// + Xy = rand()%790; + biao = KLXX[Xy]*1000; + biao += KLXY[Xy]; + }else if (MapId == 4000) {// + Xy = rand()%1109; + biao = SCXX[Xy]*1000; + biao += SCXY[Xy]; + }else if (MapId == 5000) {// + Xy = rand()%280; + biao = FCXX[Xy]*1000; + biao += FCXY[Xy]; + }else if (MapId == 3400) {//濩 + Xy = rand()%272; + biao = QGGXX[Xy]*1000; + biao += QGGXY[Xy]; + }else if (MapId == 5100) {// + Xy = rand()%201; + biao = DNXX[Xy]*1000; + biao += DNXY[Xy]; + }else if (MapId == 1100) {//ɰ´ + Xy = rand()%1263; + biao = KAXX[Xy]*1000; + biao += KAXY[Xy]; + }else if (MapId == 3100) {//ķ + Xy = rand()%783; + biao = TMXX[Xy]*1000; + biao += TMXY[Xy]; + }else if (MapId == 1400) {//̹ + Xy = rand()%697; + biao = KTXX[Xy]*1000; + biao += KTXY[Xy]; + }else if (MapId == 3300) {//³ + Xy = rand()%401; + biao = WLXX[Xy]*1000; + biao += WLXY[Xy]; + }else if (MapId == 1300) {//ش + Xy = rand()%1016; + biao = HETXX[Xy]*1000; + biao += HETXY[Xy]; + }else if (MapId == 3200) {// + Xy = rand()%484; + biao = DDXX[Xy]*1000; + biao += DDXY[Xy]; + }else if (MapId == 400) {//ɳķ + Xy = rand()%1330; + biao = SMDXX[Xy]*1000; + biao += SMDXY[Xy]; + } + + return biao; +} +#endif diff --git a/map/map_util.c b/map/map_util.c new file mode 100644 index 0000000..ead0a3f --- /dev/null +++ b/map/map_util.c @@ -0,0 +1,35 @@ +#include "version.h" +#include "common.h" +#include "char.h" +#include "readmap.h" + + +#define MAP_CHARFLOOR(x) CHAR_getInt(x,CHAR_FLOOR) +#define MAP_CHARX(x) CHAR_getInt(x,CHAR_X) +#define MAP_CHARY(x) CHAR_getInt(x,CHAR_Y) + +BOOL MAP_getMapDataFromCharIndex( int index , int* map ) +{ + int mapdata[2]; + int ret; + + ret = MAP_getTileAndObjData(MAP_CHARFLOOR(index), + MAP_CHARX(index), + MAP_CHARY(index), + &mapdata[0],&mapdata[1] ); + map[0] = mapdata[0]; + map[1] = mapdata[1]; + return ret; +} + +BOOL MAP_getMapDataFromFXY( int f , int x , int y, int* map ) +{ + int mapdata[2]; + int ret; + + ret = MAP_getTileAndObjData(f,x,y,&mapdata[0],&mapdata[1] ); + map[0] = mapdata[0]; + map[1] = mapdata[1]; + return ret; +} + diff --git a/map/map_warppoint.c b/map/map_warppoint.c new file mode 100644 index 0000000..0a3281f --- /dev/null +++ b/map/map_warppoint.c @@ -0,0 +1,387 @@ +#include "version.h" + +#include +#include "common.h" +#include "char.h" +#include "char_base.h" +#include "object.h" +#include "buf.h" +#include "util.h" +#include "configfile.h" +#include "readmap.h" +#include "map_warppoint.h" + +#ifdef _MAP_WARPPOINT +#define MAP_MAXWARPPOINT 6000 + +typedef struct _tagMAPwarpPoints{ + int use; + int ofloor; + int ox; + int oy; + + int floor; + int x; + int y; + int type; +}_MAPwarpPoints; + +_MAPwarpPoints *MapWarppoint; +static int MapWarpPoints=0; +char PointType[3][256]={ "NONE", "FREE", "ERROR"}; + +char Filename[256]; +int resetmappointtime = 0; +int MAPPOINT_InitMapWarpPoint() +{ + MapWarppoint = ( _MAPwarpPoints *)calloc( 1, sizeof( struct _tagMAPwarpPoints)*MAP_MAXWARPPOINT); + if( MapWarppoint == NULL ) return 0; + + sprintf(Filename, "%s/mapwarp.txt", getMapdir()); + MAPPOINT_resetMapWarpPoint( 0); + return MAP_MAXWARPPOINT; +} +/* +void MAPPOINT_checkMapWarpPoint( int floor, int x, int y) +{ + OBJECT object; + + for( object = MAP_getTopObj(fl,x,y) ; object ; + object = NEXT_OBJECT(object) ){ + int o = GET_OBJINDEX(object); + if( OBJECT_getType(o) == OBJTYPE_WARPPOINT){ + if( !MAPPOINT_CHECKINDEX( OBJECT_getIndex( o)) ) continue; + if( OBJECT_getchartype( o) != event ) continue; + MAPPOINT_MapWarpHandle( charaindex, OBJECT_getIndex( o), fl, x, y ); + found = TRUE; + break; + } + +} +*/ +void MAPPOINT_resetMapWarpPoint( int flg) +{ + int i; + if( MapWarppoint == NULL ) return; + for( i=0; i= MAP_MAXWARPPOINT ) + return FALSE; + + return MapWarppoint[ ps].use; +} + +int MAPPOINT_getMPointEVType( int ps) +{ + if( !MAPPOINT_CHECKINDEX( ps) ) + return -1; + return MapWarppoint[ ps].type; +} + +int MAPPOINT_setMapWarpFrom( int ps, char *buf) +{ + char buf1[256]; + + if( MAPPOINT_CHECKINDEX( ps) ){ + print(" ô͵ %s !!\n", buf); + return -1; + } + + memset( buf1, 0, sizeof( buf1)); + if( getStringFromIndexWithDelim( buf, ",", 1, buf1, sizeof(buf1)) ==FALSE ) return -1;//ԭ + MapWarppoint[ps].ofloor = atoi( buf1); + if( getStringFromIndexWithDelim( buf, ",", 2, buf1, sizeof(buf1)) ==FALSE ) return -1;//ԭ + MapWarppoint[ps].ox = atoi( buf1); + if( getStringFromIndexWithDelim( buf, ",", 3, buf1, sizeof(buf1)) ==FALSE ) return -1;//ԭ + MapWarppoint[ps].oy = atoi( buf1); + return 1; +} + +int MAPPOINT_setMapWarpGoal( int ps, char *buf) +{ + char buf1[256]; + if( MAPPOINT_CHECKINDEX( ps) ){ + print(" ô͵ :%s!!\n", buf); + return -1; + } + + memset( buf1, 0, sizeof( buf1)); + if( getStringFromIndexWithDelim( buf, ",", 1, buf1, sizeof(buf1)) ==FALSE ) return -1;//ԭ + MapWarppoint[ps].floor = atoi( buf1); + if( getStringFromIndexWithDelim( buf, ",", 2, buf1, sizeof(buf1)) ==FALSE ) return -1;//ԭ + MapWarppoint[ps].x = atoi( buf1); + if( getStringFromIndexWithDelim( buf, ",", 3, buf1, sizeof(buf1)) ==FALSE ) return -1;//ԭ + MapWarppoint[ps].y = atoi( buf1); + return 1; +} + +int MAPPOINT_getMapWarpGoal( int ps, int ofl, int ox, int oy, int *fl, int *x, int *y) +{ + if( !MAPPOINT_CHECKINDEX( ps) ){ + print("ȡ͵PS:%d !!\n", ps); + return -1; + } + + if( MapWarppoint[ps].ofloor != ofl || + MapWarppoint[ps].ox != ox || MapWarppoint[ps].oy != oy ){ + print( "͵: ɵ⴫͵ %d %d %d !!\n" , ofl,ox,oy ); + int newmappointtime = time(NULL); + if(newmappointtime-resetmappointtime>=60){ + MAPPOINT_resetMapWarpPoint( 1); + MAPPOINT_loadMapWarpPoint(); + resetmappointtime = newmappointtime; + } + return -1; + } + //ɼж + if( MAP_IsValidCoordinate( MapWarppoint[ps].floor, MapWarppoint[ps].x, MapWarppoint[ps].y)== FALSE ){ + print( "͵: %d %d %d !!\n" , + MapWarppoint[ps].floor,MapWarppoint[ps].x, MapWarppoint[ps].y ); + return -1; + } + *fl = MapWarppoint[ps].floor; + *x = MapWarppoint[ps].x; + *y = MapWarppoint[ps].y; + return 1; +} + +int MAPPOINT_loadMapWarpPoint( ) +{ + int i=0, ps=0, objtype; + FILE *fp=NULL; + char buf[256], buf1[256]; + + if( Filename == NULL ) return -1; + fp = fopen( Filename, "r"); + if( fp == NULL ){ + return 0; + } + while( fgets( buf, sizeof( buf)-1, fp) != NULL ){ + if( strstr( buf, "#") != 0 ) continue; + if( getStringFromIndexWithDelim( buf, ":", 1, buf1, sizeof(buf1)) ==FALSE ) + continue; + for( i=0; i= arraysizeof( PointType) ){ + print(" 1.map ͵ %s \n", buf); + continue; + } + MapWarppoint[ps].type = i; + if( getStringFromIndexWithDelim( buf, ":", 2, buf1, sizeof(buf1)) ==FALSE ) continue; + objtype = CHAR_EVENT_WARP; + if( !strcmp( buf1, "NULL")){ + }else if( !strcmp( buf1, "M")){ + objtype = CHAR_EVENT_WARP_MORNING; + }else if( !strcmp( buf1, "N")){ + objtype = CHAR_EVENT_WARP_NIGHT; + }else if( !strcmp( buf1, "A")){ + objtype = CHAR_EVENT_WARP_NOON; + } + memset( buf1, 0, sizeof(buf1)); + if( getStringFromIndexWithDelim( buf, ":", 3, buf1, sizeof(buf1)) ==FALSE )continue; + + if( MAPPOINT_setMapWarpFrom( ps, buf1) == -1){ + print(" 2-1.map ͵ %s [%s] \n", buf, buf1); + continue; + } + if( MAPPOINT_creatMapWarpObj( ps, buf1, objtype) == -1 ){ + print(" 2.map ͵ %s [%s] \n", buf, buf1); + continue; + } + memset( buf1, 0, sizeof(buf1)); + if( getStringFromIndexWithDelim( buf, ":", 4, buf1, sizeof(buf1)) ==FALSE ){ + print(" 3.map ͵ %s [%s] \n", buf, buf1); + continue; + } + if( MAPPOINT_setMapWarpGoal( ps, buf1) == -1 ){ + print(" 4.map ͵ %s \n", buf); + continue; + } + memset( buf1, 0, sizeof(buf1)); + if( getStringFromIndexWithDelim( buf, ":", 5, buf1, sizeof(buf1)) ==FALSE ){ + print(" 5.map ͵ %s [%s] \n", buf, buf1); + continue; + } + MapWarppoint[ps].use = 1; + MapWarpPoints++; + ps++; + if( ps >= MAP_MAXWARPPOINT ){ + break; + } + } + //andy_log + print("ʼ %d ͼ͵...", MapWarpPoints); + fclose( fp); + print("\n"); + return 1; +} + +void MAPPOINT_MapWarpHandle( int charaindex, int ps, int ofl, int ox, int oy ) +{ + int floor, x, y; + if( MAPPOINT_getMapWarpGoal( ps, ofl, ox, oy, &floor, &x, &y) == -1 ){ + //andy_log + print( "ȡ͵( %d, %d,%d,%d)!!\n", ps, ofl, ox, oy); + return; + } + if( floor == 777 ) return; + CHAR_warpToSpecificPoint( charaindex, floor, x, y); + if( CHAR_getWorkInt( charaindex, CHAR_WORKPARTYMODE ) == CHAR_PARTY_LEADER ) { + int i; + for( i = 1; i < CHAR_PARTYMAX; i ++ ) { + int index = CHAR_getWorkInt( charaindex, i + CHAR_WORKPARTYINDEX1); + if( CHAR_CHECKINDEX(index) ) { + CHAR_warpToSpecificPoint( index, floor, x, y); + } + } + } +} +#endif + + +#ifdef _CAX_LNS_MAPSUOXU +int DelMapPoint( int ps)//жصͼ͵ +{ + if (MapWarppoint[ps].use != 1) return FALSE; + MapWarppoint[ps].type = 0;//õͼĴ͵ + endObjectOne(get_mappointindex(MapWarppoint[ps].ofloor,MapWarppoint[ps].ox,MapWarppoint[ps].oy));//obj + MapWarppoint[ps].ofloor = -1;//õͼĴ͵ + MapWarppoint[ps].ox = -1;//õͼĴ͵ + MapWarppoint[ps].oy = -1;//õͼĴ͵ + MapWarppoint[ps].floor = -1;//õͼĴ͵ + MapWarppoint[ps].x = -1;//õͼĴ͵ + MapWarppoint[ps].y = -1;//õͼĴ͵ + MapWarppoint[ps].use = 0; + MapWarppoint[ps].type = 0; + return TRUE;//עô͵ʱȼǷԭд͵ +} + +int SetMapPoint( char* buf)//صͼ͵ +{ // "͵:NULL:2000,50,50:2006,20,20:" + if( MapWarpPoints >= MAP_MAXWARPPOINT ){ + print(" ͵Ѵޣ\n"); + return -1; + } + char buf1[256]; + char buf2[256]; + int objtype,i; + if( getStringFromIndexWithDelim( buf, ":", 1, buf1, sizeof(buf1)) ==FALSE )//ҳ͵ + { + return -2; + } + for( i=0; i= arraysizeof( PointType) ){//͵ʹ + return -3 ; + } + MapWarppoint[MapWarpPoints].type = i;//õͼĴ͵ + if( getStringFromIndexWithDelim( buf, ":", 2, buf1, sizeof(buf1)) ==FALSE ) //ҳ͵Чʱ + { + return -4 ; + } + objtype = CHAR_EVENT_WARP;//öΪ͵ + if( !strcmp( buf1, "NULL")){ + }else if( !strcmp( buf1, "M")){ + objtype = CHAR_EVENT_WARP_MORNING;//öΪ糿͵ + }else if( !strcmp( buf1, "N")){ + objtype = CHAR_EVENT_WARP_NIGHT;//öΪϴ͵ + }else if( !strcmp( buf1, "A")){ + objtype = CHAR_EVENT_WARP_NOON;//öΪ紫͵ + } + memset( buf1, 0, sizeof(buf1)); + if( getStringFromIndexWithDelim( buf, ":", 3, buf1, sizeof(buf1)) ==FALSE )//ҳԭ + { + return -5 ; + } + int fl = -1,x = -1,y = -1; + if( getStringFromIndexWithDelim( buf1, ",", 1, buf2, sizeof(buf1)) !=FALSE )//ҳԭ + { + fl = atoi(buf2); + } + if( getStringFromIndexWithDelim( buf1, ",", 2, buf2, sizeof(buf1)) !=FALSE )//ҳԭ + { + x = atoi(buf2); + } + if( getStringFromIndexWithDelim( buf1, ",", 3, buf2, sizeof(buf1)) !=FALSE )//ҳԭ + { + y = atoi(buf2); + } + if (fl == -1 || x == -1 || y == -1) return -5; + if (get_mappointindex( fl,x, y) != -1) return -5;//ù͵㣡 + for (i=0;i= MapWarpPoints) MapWarpPoints++;//ǰ͵ѾԤһ͵㡣 + return i; +} +#endif diff --git a/map/readmap.c b/map/readmap.c new file mode 100644 index 0000000..3ad1eb1 --- /dev/null +++ b/map/readmap.c @@ -0,0 +1,1621 @@ +#include "version.h" +#include +#include +#include +#include +#include +#include + +#include +#include + +#include "common.h" +#include "object.h" +#include "readmap.h" +#include "buf.h" +#include "util.h" +#include "char.h" +#include "lssproto_serv.h" +#include "configfile.h" + +#define MAP_MAGIC "LS2MAP" + +static void MAP_makeDefaultImageData( MAP_ImageData* one ) +{ + one->data[MAP_WALKABLE] = TRUE; + one->data[MAP_HAVEHEIGHT] = FALSE; + one->data[MAP_DEFENCE] = 0; + one->data[MAP_INTODAMAGE] = 0; + one->data[MAP_OUTOFDAMAGE] = 0; + + one->data[MAP_SETED_BATTLEMAP] = 0; + one->data[MAP_BATTLEMAP] = 0; + one->data[MAP_BATTLEMAP2] = 0; + one->data[MAP_BATTLEMAP3] = 0; + one->data[MAP_INTODARKNESS] = 0; + one->data[MAP_INTOCONFUSION] = 0; + + one->data[MAP_OUTOFPOISON] = 0; + one->data[MAP_OUTOFPARALYSIS] = 0; + one->data[MAP_OUTOFSILENCE] = 0; + one->data[MAP_OUTOFSTONE] = 0; + one->data[MAP_OUTOFDARKNESS] = 0; + one->data[MAP_OUTOFCONFUSION] = 0; + +} + +static int MAP_flgSet( char* string ) +{ + int tmp; + tmp = atoi(string); + if( tmp == 0 ) + return 0; + return 1; +} +typedef enum +{ + MAP_INTENTRY=0, + MAP_CHARENTRY=1, + MAP_INTFUNC=2, + MAP_CHARFUNC=3, +}MAP_DATATYPECATEGORY; +static struct MAP_itemconfentry +{ + int type; + int index; + void* func; +}MAP_confentries[MAP_DATAINT_NUM+MAP_DATACHAR_NUM]={ + {MAP_INTENTRY, MAP_WALKABLE, MAP_flgSet}, + {MAP_INTENTRY, MAP_HAVEHEIGHT, MAP_flgSet}, + {MAP_INTENTRY, MAP_DEFENCE, NULL}, + {MAP_INTENTRY, MAP_INTODAMAGE, NULL}, + {MAP_INTENTRY, MAP_OUTOFDAMAGE, NULL}, + + {MAP_INTENTRY, MAP_SETED_BATTLEMAP, NULL}, + {MAP_INTENTRY, MAP_BATTLEMAP, NULL}, + {MAP_INTENTRY, MAP_BATTLEMAP2, NULL}, + {MAP_INTENTRY, MAP_BATTLEMAP3, NULL}, + {MAP_INTENTRY, MAP_INTODARKNESS, NULL}, + {MAP_INTENTRY, MAP_INTOCONFUSION, NULL}, + + {MAP_INTENTRY, MAP_OUTOFPOISON, NULL}, + {MAP_INTENTRY, MAP_OUTOFPARALYSIS, NULL}, + {MAP_INTENTRY, MAP_OUTOFSILENCE, NULL}, + {MAP_INTENTRY, MAP_OUTOFSTONE, NULL}, + {MAP_INTENTRY, MAP_OUTOFDARKNESS, NULL}, + {MAP_INTENTRY, MAP_OUTOFCONFUSION, NULL}, + +}; + +static MAP_ImageData* MAP_imagedata; +static unsigned int MAP_imagedatanum; +static int MAP_imgfilt[65535]; +#ifdef _CAX_LNS_MAPSUOXU +static int fbmap[10000]; +#endif + +BOOL MAP_readMapConfFile( char* filename ) +{ + FILE* file; + char line[512]; + int maximagenumber=0; + int i; + int linenum=0; + int imgdataindex=0; + + file = fopen( filename , "r" ); + if( file == NULL ){ + fprint( "޷ļ %s\n", filename ); + return FALSE; + } + while( fgets( line , sizeof( line ) , file ) ){ + char imgnum[16]; + BOOL ret; + int imgnumber; + deleteSequentChar( line, " \t" ); + pohcd( line, " \t" ); + dchop(line, " \t"); + + if( line[0] == '#' )continue; + if( line[0] == '\n' )continue; + chomp( line ); + ret = getStringFromIndexWithDelim( line , " " , 1 , imgnum , sizeof( imgnum ) ); + if( ret == FALSE )continue; + imgnumber = atoi(imgnum); + maximagenumber = max( maximagenumber , imgnumber ); + } + + MAP_imagedatanum = maximagenumber + 1; + MAP_imagedata=allocateMemory(sizeof(MAP_ImageData)*MAP_imagedatanum); + if( MAP_imagedata == NULL ){ + fprint("޷ͼݴС=%d\n",MAP_imagedatanum); + return FALSE; + } + + for( i = 0; i data[MAP_confentries[i].index] + = atoi( token ); + break; + case MAP_CHARENTRY: + strcpysafe( one->string[MAP_confentries[i].index].string, + sizeof( one->string[MAP_confentries[i].index]. + string), + token); + break; + case MAP_INTFUNC: + { + int (*intfunction)(char* ); + intfunction = MAP_confentries[i].func; + one->data[MAP_confentries[i].index] + = intfunction(token); + break; + } + case MAP_CHARFUNC: + { + char* (*charfunction)(char* ); + charfunction = MAP_confentries[i].func; + + strcpysafe( one->string[MAP_confentries[i].index].string, + sizeof(one->string[MAP_confentries[i].index]. + string), + charfunction(token)); + break; + } + default: + break; + } + } + } + + fclose( file ); + return TRUE; +} + +#if 1 +BOOL MAP_readBattleMapConfFile( char* filename ) +{ + FILE* file; + char line[512]; + + int i, j; + int linenum=0; + int BattleMapNo[3], iRet, iWork, iPre[3],iFirst, iLast; + + file = fopen( filename , "r" ); + if( file == NULL ){ + fprint( "޷ %s\n", filename ); + return FALSE; + } + + BattleMapNo[0] = 0; + BattleMapNo[1] = 0; + BattleMapNo[2] = 0; + while( fgets( line , sizeof( line ) , file ) ){ + char *p; + linenum++; + + pohcd( line, " \t" ); + dchop(line, " \t"); + + if( line[0] == '#' )continue; + if( line[0] == '\n' )continue; + chomp( line ); + + if( line[0] == '$' ){ + iRet = sscanf( line+1, "%d %d %d", &iPre[0], &iPre[1], &iPre[2] ); + BattleMapNo[0] = BattleMapNo[1] = BattleMapNo[2] = iPre[0]; + if( iRet < 1 ){ + print( "!!!!! ޷ȡսͼ(%s)( line %d )\n", filename, linenum ); + } + for( i = 0; i < iRet; i ++ ){ + BattleMapNo[i] = iPre[i]; + if( BattleMapNo[i] < 0 ){ + print( "!!!!! սͼΪֵ (%s)( line %d )\n", filename, linenum ); + } + } + + continue; + + } + if( sscanf( line, "%d", &iWork ) != 1 ){ + continue; + } + if( iWork < 0 ){ + print( "!!!!! ǮΪֵ (%s)( line %d )\n", filename, linenum ); + continue; + } + iFirst = iWork; + p = strstr( line, "to" ); + if( p != NULL ){ + if( sscanf( p+2, "%d", &iWork ) != 1 ){ + iLast = iFirst; + }else{ + iLast = iWork; + } + if( iWork < 0 ){ + print( "!!!!! ǮΪֵ (%s)( line %d )\n", filename, linenum ); + continue; + } + }else{ + iLast = iFirst; + } + + for( i = iFirst; i <= iLast; i ++ ){ + if( MAP_getImageInt( i, MAP_SETED_BATTLEMAP ) > 0 ){ + print( "!!!!! ͬǮظ趨(%s)( line %d )(%d)(%d & %d)\n", + filename, linenum, i, + MAP_getImageInt( i, MAP_BATTLEMAP ), + BattleMapNo[0] ); + } + + // įо + if( IsValidImagenumber( i ) == FALSE ){ + continue; + } + MAP_setImageInt( i, MAP_BATTLEMAP, BattleMapNo[0] ); + MAP_setImageInt( i, MAP_BATTLEMAP2, BattleMapNo[1] ); + MAP_setImageInt( i, MAP_BATTLEMAP3, BattleMapNo[2] ); + MAP_setImageInt( i, MAP_SETED_BATTLEMAP, 1 ); + } + + } + fclose( file ); + + for( j = 0; j < arraysizeof( MAP_imgfilt ); j ++ ){ + if( MAP_imgfilt[j] == -1 )continue; + if( MAP_getImageInt( j, MAP_SETED_BATTLEMAP ) == 0 ){ + print( "!!!!! Ǯ(%d)δ趨 (%s)\n", j, filename ); + } + } + return TRUE; +} +#endif + +BOOL IsValidImagenumber( int imagenumber ) +{ + if( imagenumber < 0 || imagenumber >= arraysizeof( MAP_imgfilt ) ) + return FALSE; + + if( MAP_imgfilt[imagenumber] == -1 ) + return FALSE; + return TRUE; +} + +int MAP_getImageInt( int imagenumber, int element ) +{ + if( imagenumber < 0 || imagenumber >= arraysizeof( MAP_imgfilt )) + return FALSE; + + if( MAP_imgfilt[imagenumber] == -1 )return FALSE; + return MAP_imagedata[MAP_imgfilt[imagenumber]].data[element]; +} + +BOOL MAP_setImageInt( int imagenumber, int element, int value ) +{ + if( imagenumber < 0 || imagenumber >= arraysizeof( MAP_imgfilt )) + return FALSE; + + if( MAP_imgfilt[imagenumber] == -1 )return FALSE; + MAP_imagedata[MAP_imgfilt[imagenumber]].data[element] = value; + + return TRUE; +} + +static MAP_Map* MAP_map; +static unsigned int MAP_mapnum; +static unsigned int MAP_mapnum_index; + + +static int* MAP_idjumptbl; +static int MAP_idtblsize; + +BOOL MAP_initMapArray( int num ) +{ + MAP_mapnum = num ; + + MAP_map = allocateMemory( sizeof( MAP_Map ) * MAP_mapnum ); + if( MAP_map == NULL )return FALSE; + + MAP_mapnum_index = 0; + + return TRUE; +} + +void MAP_endMapArray( void ) +{ + int i; + for( i = 0 ; i < MAP_mapnum ; i ++ ){ + if( MAP_map[i].tile != NULL ) + freeMemory( MAP_map[i].tile ); + + if( MAP_map[i].obj != NULL) + freeMemory( MAP_map[i].obj ); + + } + MAP_mapnum = 0; + MAP_mapnum_index = 0; + freeMemory( MAP_map ); + MAP_map = NULL; +} + +static BOOL MAP_IsMapFile( char* filename ) +{ + FILE* f; + char buf[16]; + int ret; + + f = fopen(filename, "r"); + if( f == NULL ){ + errorprint; + return FALSE; + } + + ret = fread( buf , sizeof( char ) , 6 , f); + if( ret != 6 ) + goto FCLOSERETURNFALSE; + buf[ret] = '\0'; + + if( strcmp( buf , MAP_MAGIC ) != 0 ) + goto FCLOSERETURNFALSE; + else + goto FCLOSERETURNTRUE; + +FCLOSERETURNFALSE: + fclose(f); + return FALSE; +FCLOSERETURNTRUE: + fclose(f); + return TRUE; +} + +static BOOL MAP_readMapOne( char* filename ) +{ + FILE* f; /* ̻ */ + char buf[16]; /* Ѩ͹ϼ */ + short data[1024]; /* */ + int ret; /* ߯ԻԻ */ + int i; /* */ + int mapindex; + + int id=0,xsiz=0,ysiz=0; /* Ѩ󷸡ɡ */ + + short *tile=NULL; + short *obj=NULL; + MAP_Objlink** olink=NULL; + char showstring[32]; /* Ѩ󷸡ɡ */ + struct stat filestat; /* ñ */ + BOOL invaliddata=FALSE; + if( MAP_mapnum_index >= MAP_mapnum ){ + fprint( "û㹻ռװصͼ.\n" ); + return FALSE; + } + mapindex=MAP_mapnum_index; + f = fopen(filename, "r"); + if( f == NULL ){ + errorprint; + return FALSE; + } + if( fstat( fileno(f) , &filestat ) != 0 ){ + errorprint; + goto FCLOSERETURNFALSE; + } + + ret = fread( buf , sizeof( char ) , 6 , f); + if( ret != 6 ){ + errorprint; + goto FCLOSERETURNFALSE; + } + buf[ret] = '\0'; + + if( strcmp( buf , MAP_MAGIC ) != 0 ) + goto FCLOSERETURNFALSE; + ret = fread( data , sizeof( short ) , 1 , f); + if( ret != 1 ){ + errorprint; + goto FCLOSERETURNFALSE; + } + id = ntohs( data[0] ); + + ret = fread( showstring , sizeof(char), arraysizeof(showstring), f); + if( ret != arraysizeof(showstring) ){ + errorprint; + goto FCLOSERETURNFALSE; + } + showstring[arraysizeof(showstring)-1] = '\0'; + ret = fread( data, sizeof( short ) , 1 , f); + if( ret != 1 ){ + errorprint; + goto FCLOSERETURNFALSE; + } + xsiz = ntohs( data[0] ); + ret = fread( data, sizeof( short ) , 1 , f); + if( ret != 1 ){ + errorprint; + goto FCLOSERETURNFALSE; + } + ysiz = ntohs( data[0] ); + tile = allocateMemory( sizeof( short ) * xsiz * ysiz ); + if( tile == NULL ){ + fprint( "޷ڴͼ:%s xsiz:%d ysiz:%d\n", filename, xsiz, ysiz); + goto FREEOBJHP; + } + + obj = allocateMemory( sizeof( short ) * xsiz * ysiz ); + if( obj == NULL ){ + fprint( "޷ڴ\n"); + goto FREETILE; + } + + olink = allocateMemory( sizeof(MAP_Objlink*) * xsiz * ysiz ); + if( olink == NULL ){ + fprint( "޷ڴ\n"); + goto FREEOBJ; + } + + ret = fread( tile , sizeof( short )*xsiz*ysiz,1,f ); + if( ret != 1 ){ + errorprint; + goto FREELINK; + } +// for( i = 0 ; i < xsiz * ysiz ; i ++ ) +// tile[i] = ntohs( tile[i] ); + for( i = 0 ; i < xsiz * ysiz ; i ++ ){ + tile[i] = ntohs( tile[i] ); + if( !IsValidImagenumber( tile[i] ) ){ + fprint("1ͼͼƬ:%d x:%d y:%d :%d\n", + id, i % xsiz, (int)(i / xsiz) , tile[i]); + invaliddata = TRUE; + } + } + ret = fread( obj , sizeof( short )*xsiz*ysiz,1,f ); + if( ret != 1 ){ + errorprint; + goto FREELINK; + } +// for( i = 0 ; i < xsiz * ysiz ; i ++ ) +// obj[i] = ntohs( obj[i] ); + for( i = 0 ; i < xsiz * ysiz ; i ++ ){ + obj[i] = ntohs( obj[i] ); + if( !IsValidImagenumber( obj[i] ) ){ + fprint( + "2ͼͼƬ:%d x:%d y:%d :%d\n", + id, i % xsiz, (int)(i / xsiz) , obj[i]); + invaliddata = TRUE; + } + } + if( invaliddata )goto FREELINK; +/* if( ftell(f) != filestat.st_size) + fprintf(stderr,"ļСȷ(%s). ĿļС:%" +#ifdef linux + "l" +#elif __FreeBSD__ + "ll" +#endif + "d ʵʴС:%ld\n", + filename, filestat.st_size,ftell(f)); +*/ + + for( i=0 ; i< xsiz*ysiz ; i ++ ) + olink[i] = NULL; + + MAP_map[mapindex].id = id; + MAP_map[mapindex].xsiz = xsiz; + MAP_map[mapindex].ysiz = ysiz; + strcpysafe( MAP_map[mapindex].string , + sizeof(MAP_map[mapindex].string), + showstring ); + MAP_map[mapindex].tile = tile; + MAP_map[mapindex].obj = obj; + MAP_map[mapindex].olink = olink; +#ifdef _MAP_NOEXIT + { + FILE *fp; + char mpexit[128]; + int floorID=0,exfloor=0,ex_X=0,ex_Y=0; + int map_type=0; + MAP_map[mapindex].startpoint = 0; + fp = fopen( "./data/map/map_noexit.txt","r"); + if( fp != NULL ){ + while( fgets(mpexit, 128, fp) != NULL ) { + sscanf( mpexit,"%d %d %d %d %d", &floorID, &exfloor, &ex_X, &ex_Y, &map_type); + if( strstr( mpexit, "#" ) != NULL) + continue; + if( floorID == id) { + MAP_map[mapindex].startpoint = (exfloor<<16)+(ex_X << 8)+(ex_Y<<0); + MAP_map[mapindex].MapType = map_type; + } + } + // Nuke 1204: Bug fix + fclose(fp); + }else { + print("\n **** Ҳ map_noexit.txt ļ!!!"); + } + } +#endif + goto FCLOSERETURNTRUE; + +FCLOSERETURNTRUE: + MAP_mapnum_index++; + fclose(f); + return TRUE; + +FREELINK: + freeMemory( olink ); +FREEOBJ: + freeMemory( obj ); +FREETILE: + freeMemory( tile ); +FREEOBJHP: +FCLOSERETURNFALSE: + fclose(f); + return FALSE; +} +#ifdef _MAP_NOEXIT +unsigned int MAP_getExFloor_XY( int floor, int *map_type) +{ + int i; + int exfloor; + for( i=0; i 0 ) { + exfloor = (MAP_map[i].startpoint>>16)&0xffffff; + if( exfloor >= 0 ) { + *map_type = MAP_map[i].MapType; + return MAP_map[i].startpoint ; + } + } + } + } + return 0; +} +BOOL CHECKFLOORID( id) +{ + int i; + + if( id < 0 ) + return FALSE; + + for( i=0; i MAP_getfloorX(mapid) || + y < 0 || y > MAP_getfloorY(mapid)) + return FALSE; + + return TRUE; +} + +#define MAP_GETMAXSIZE 45 +static char MAP_dataString[STRINGBUFSIZ*3]; +static int MAP_workdatabuffer[MAP_GETMAXSIZE*MAP_GETMAXSIZE]; +#define MAP_DATADELIMITER "," + +char* MAP_getdataFromRECT( int floor, RECT* seekr, RECT* realr ) +{ + int floorindex; + int stringlength=0; + char tmpbuffer[128]; + int i,j; + int floorx; + int databufferindex=0; + RECT scr; + char escapebuffer[128]; + + floorindex = MAP_getfloorIndex( floor ); + if( floorindex == -1 ) { + print( "%s:%d:err\n", __FILE__, __LINE__); + return NULL; + } + if( seekr->width < 0 || seekr->height < 0 || + MAP_GETMAXSIZE < seekr->width || MAP_GETMAXSIZE < seekr->height ){ + print( "%s:%d:err\n", __FILE__, __LINE__); + return NULL; + } + snprintf( tmpbuffer,sizeof(tmpbuffer), + "%s|" , + makeEscapeString( MAP_map[floorindex].string, + escapebuffer,sizeof(escapebuffer))); + + strcpysafe( MAP_dataString, sizeof( MAP_dataString ), tmpbuffer ); + stringlength = strlen( tmpbuffer ); + + floorx = MAP_map[floorindex].xsiz; + scr.x = 0; + scr.y = 0; + scr.width = floorx; + scr.height= MAP_map[floorindex].ysiz; + + if( clipRect( seekr,&scr,realr ) == FALSE ){ + realr->x=realr->y=realr->width=realr->height=0; + return MAP_dataString; + } + for( i = realr->y ; i < realr->y + realr->height ; i ++ ){ + for( j = realr->x ; j < realr->x + realr->width ; j ++ ){ + MAP_workdatabuffer[databufferindex++] + = MAP_map[floorindex].tile[i*floorx+j]; + } + } + for( i = 0 ; i < databufferindex ; i ++ ){ + char buf[64]; + snprintf( tmpbuffer,sizeof(tmpbuffer),"%s" MAP_DATADELIMITER , + cnv10to62( MAP_workdatabuffer[i], buf, sizeof( buf)) ); + strcpysafe( &MAP_dataString[stringlength] , + sizeof( MAP_dataString ) - stringlength, + tmpbuffer ); + stringlength += strlen( tmpbuffer ); + } + if( stringlength < sizeof( MAP_dataString ) ) + MAP_dataString[stringlength-1] = NONCHAR_DELIMITER[0]; + databufferindex=0; + for( i = realr->y ; i < realr->y + realr->height ; i ++ ){ + for( j = realr->x ; j < realr->x + realr->width ; j ++ ){ + MAP_workdatabuffer[databufferindex++] + = MAP_map[floorindex].obj[i*floorx+j]; + } + } + for( i = 0 ; i < databufferindex ; i ++ ){ + char buf[64]; + if( MAP_workdatabuffer[i] == 0 ) buf[0] = '\0'; + else cnv10to62( MAP_workdatabuffer[i], buf, sizeof( buf)); + snprintf( tmpbuffer,sizeof(tmpbuffer),"%s" MAP_DATADELIMITER , + buf ); + strcpysafe( &MAP_dataString[stringlength] , + sizeof( MAP_dataString ) - stringlength, + tmpbuffer ); + stringlength += strlen( tmpbuffer ); + } + + if( stringlength < sizeof( MAP_dataString ) ) + MAP_dataString[stringlength-1] = NONCHAR_DELIMITER[0]; + + databufferindex=0; + for( i = realr->y ; i < realr->y + realr->height ; i ++ ){ + for( j = realr->x ; j < realr->x + realr->width ; j ++ ){ + OBJECT object; + BOOL found = FALSE; + for( object = MAP_getTopObj(floor,j,i) ; object ; + object = NEXT_OBJECT(object) ){ + int o = GET_OBJINDEX(object); + if( OBJECT_getType(o) == OBJTYPE_CHARA ){ + int etype; + int charaindex=OBJECT_getIndex(o); + if( !CHAR_CHECKINDEX(charaindex) )continue; + etype = CHAR_getWorkInt( charaindex, CHAR_WORKEVENTTYPE); + if( etype != CHAR_EVENT_NONE ) { + MAP_workdatabuffer[databufferindex++] = etype; + found = TRUE; + break; + } + } +#ifdef _MAP_WARPPOINT + else if( OBJECT_getType(o) == OBJTYPE_WARPPOINT ){ + int etype = OBJECT_getchartype( o); + if( etype != CHAR_EVENT_NONE ) { + MAP_workdatabuffer[databufferindex++] = (unsigned short)etype; + found = TRUE; + break; + } + } +#endif + } + if( !found ) { + MAP_workdatabuffer[databufferindex++] + = CHAR_EVENT_NONE; + } + } + } + for( i = 0 ; i < databufferindex ; i ++ ){ + char buf[64]; + if( MAP_workdatabuffer[i] == 0 ) buf[0] = '\0'; + else cnv10to62( MAP_workdatabuffer[i], buf, sizeof( buf)); + + snprintf( tmpbuffer,sizeof(tmpbuffer),"%s" MAP_DATADELIMITER, buf); + strcpysafe( &MAP_dataString[stringlength] , + sizeof( MAP_dataString ) - stringlength, tmpbuffer ); + stringlength += strlen( tmpbuffer ); + } + dchop( MAP_dataString, MAP_DATADELIMITER ); + return MAP_dataString; +} + +char *MAP_getChecksumFromRECT( int floor, RECT* seekr, RECT* realr, + int *tilesum, int *objsum, int *eventsum ) +{ + int floorindex; + int i,j; + int floorx; + int databufferindex=0; + RECT scr; + char escapebuffer[128]; + unsigned short eventbuf[MAP_CHAR_DEFAULTSEESIZ * MAP_CHAR_DEFAULTSEESIZ]; + unsigned short tilebuf[ MAP_CHAR_DEFAULTSEESIZ * MAP_CHAR_DEFAULTSEESIZ]; + unsigned short objbuf[ MAP_CHAR_DEFAULTSEESIZ * MAP_CHAR_DEFAULTSEESIZ]; + + floorindex = MAP_getfloorIndex( floor ); + if( floorindex == -1 ) return NULL; + if( seekr->width < 0 || seekr->height < 0 || + MAP_GETMAXSIZE < seekr->width || MAP_GETMAXSIZE < seekr->height ) + return NULL; + + strcpysafe( MAP_dataString, sizeof( MAP_dataString ), + makeEscapeString( MAP_map[floorindex].string, + escapebuffer,sizeof(escapebuffer))); + + floorx = MAP_map[floorindex].xsiz; + scr.x = 0; + scr.y = 0; + scr.width = floorx; + scr.height= MAP_map[floorindex].ysiz; + + if( clipRect( seekr,&scr,realr ) == FALSE ){ + realr->x=realr->y=realr->width=realr->height=0; + return MAP_dataString; + } + + *tilesum = 0; + *objsum =0; + *eventsum = 0; + memset( tilebuf, 0, sizeof( tilebuf)); + memset( objbuf, 0, sizeof( objbuf)); + memset( eventbuf, 0, sizeof( eventbuf)); + for( i = realr->y ; i < realr->y + realr->height ; i ++ ){ + for( j = realr->x ; j < realr->x + realr->width ; j ++ ){ + OBJECT object; + //BOOL found = FALSE; + for( object = MAP_getTopObj(floor,j,i) ; object ; + object = NEXT_OBJECT(object) ){ + int o = GET_OBJINDEX(object); + if( OBJECT_getType(o) == OBJTYPE_CHARA ){ + int etype; + int charaindex=OBJECT_getIndex(o); + if( !CHAR_CHECKINDEX(charaindex) )continue; + etype = CHAR_getWorkInt( charaindex, CHAR_WORKEVENTTYPE); + if( etype != CHAR_EVENT_NONE ) { + eventbuf[databufferindex] = (unsigned short)etype; + break; + } + } +#ifdef _MAP_WARPPOINT + else if( OBJECT_getType(o) == OBJTYPE_WARPPOINT ){ + int etype = OBJECT_getchartype( o); + if( etype != CHAR_EVENT_NONE ) { + eventbuf[databufferindex] = (unsigned short)etype; + break; + } + } +#endif + } + tilebuf[databufferindex] = (unsigned short)MAP_map[floorindex].tile[i*floorx+j]; + objbuf[databufferindex] = (unsigned short)MAP_map[floorindex].obj[i*floorx+j]; + databufferindex++; + } + } + *tilesum = CheckCRC( (unsigned char*)tilebuf, sizeof( tilebuf)); + *objsum = CheckCRC( (unsigned char*)objbuf, sizeof( objbuf)); + *eventsum = CheckCRC( (unsigned char*)eventbuf, sizeof( eventbuf)); + + return MAP_dataString; +} + +BOOL MAP_getTileAndObjData( int ff ,int fx, int fy, int* tile, int* obj) +{ + int floorindex,xsiz; + floorindex = MAP_getfloorIndex( ff ); + if( floorindex == -1 ) { + print( "%s:%d:err\n", __FILE__, __LINE__); + return FALSE; + } + xsiz = MAP_map[floorindex].xsiz; + + if( fx < 0 || fx >= xsiz ) { + return FALSE; + } + if( fy < 0 || fy >= MAP_map[floorindex].ysiz ) { + return FALSE; + } + + if( tile ) + *tile = MAP_map[floorindex].tile[fy*xsiz+fx]; + if( obj ) + *obj = MAP_map[floorindex].obj[fy*xsiz+fx]; + + return TRUE; +} + +BOOL MAP_setTileAndObjData( int ff ,int fx, int fy, int tile, int obj) +{ + int floorindex,xsiz; + floorindex = MAP_getfloorIndex( ff ); + if( floorindex == -1 ) { + print( "%s:%d:err\n", __FILE__, __LINE__); + return FALSE; + } + xsiz = MAP_map[floorindex].xsiz; + if( fx < 0 || fx >= xsiz ) { + return FALSE; + } + if( fy < 0 || fy >= MAP_map[floorindex].ysiz ) { + return FALSE; + } + if( tile != -1 ) + MAP_map[floorindex].tile[fy*xsiz+fx] = tile; + if( obj != -1) + MAP_map[floorindex].obj[fy*xsiz+fx] = obj; + return TRUE; +} + +BOOL MAP_initReadMap( char* maptilefile , char* mapdir ) +{ + print("\n"); + if( !MAP_readMapConfFile(maptilefile) ) + return FALSE; + if( !MAP_readBattleMapConfFile( getBattleMapfile( ) ) ) + return FALSE; + if( !MAP_readMapDir(mapdir) ) + return FALSE; + return TRUE; +} + +static int MAP_coKindAndInt[MAP_KINDNUM]= +{ + MAP_WALKABLE, +}; + +BOOL MAP_makeVariousMap(char* atile, char* aobj, int floor, int startx, + int starty, int xsiz, int ysiz, MAP_kind kind ) +{ + int i,j; + int findex; + int fxsiz; + int startpoint; + + if( atile == NULL || aobj == NULL || kind < 0 || kind >= MAP_KINDNUM ) { + print( "%s:%d:err\n", __FILE__, __LINE__); + return FALSE; + } + findex = MAP_getfloorIndex( floor ); + if( findex == -1 ) { + print( "%s:%d:err\n", __FILE__, __LINE__); + return FALSE; + } + fxsiz = MAP_map[findex].xsiz; + startpoint = startx + starty * fxsiz ; + + for( i = 0 ; i < ysiz ; i ++ ){ + for( j = 0 ; j < xsiz ; j ++ ){ + atile[i*xsiz+j] = MAP_getImageInt( MAP_map[findex].tile[ + startpoint + i*xsiz + j],MAP_coKindAndInt[kind] ) + ? 1 : 0; + + aobj[i*xsiz+j] = MAP_getImageInt( MAP_map[findex].obj[ + startpoint + i*xsiz + j],MAP_coKindAndInt[kind] ) + ? 1 : 0; + } + } + return TRUE; +} + +BOOL MAP_makeWalkableMap( char* data, int floor, int startx, int starty, + int xsiz, int ysiz ) +{ + int i,j; + char* obj; + obj = allocateMemory(xsiz*ysiz*sizeof(char)); + if( obj == NULL )return FALSE; + + if( MAP_makeVariousMap( data, obj, floor, startx, starty, xsiz, ysiz, + MAP_KINDWALKABLE ) == FALSE ){ + freeMemory( obj ); + return FALSE; + } + + for( i = 0 ; i < ysiz ; i ++ ) + for( j = 0 ; j < xsiz ; j ++ ) + data[j+i*ysiz] = data[j+i*ysiz] & obj[j+i*ysiz]; + +#ifdef DEBUG + for( i = 0 ; i < ysiz ; i ++ ){ + for( j = 0 ; j < xsiz ; j ++ ) + if( data[j+i*ysiz] ){ + print(" "); + }else + print("O"); + print("\n"); + } +#endif /*DEBUG*/ + + return TRUE; +} + +BOOL MAP_IsThereSpecificFloorid( int floorid ) +{ + if( MAP_getfloorIndex(floorid)== -1)return FALSE; + else return TRUE; +} + +BOOL MAP_IsValidCoordinate( int floor, int x, int y ) +{ + if( MAP_IsThereSpecificFloorid(floor)==FALSE )return FALSE; + if( x < 0 || MAP_getfloorX(floor)<=x )return FALSE; + if( y < 0 || MAP_getfloorY(floor)<=y )return FALSE; + return TRUE; +} + +int MAP_attackSpecificPoint( int floor, int x, int y, int damage , + int charaindex ) +{ +#if 0 + int mapindex; + int xsiz; + int objimagenumber; + + mapindex = MAP_getfloorIndex(floor); + if( mapindex == -1 ) { + print( "%s:%d:err\n", __FILE__, __LINE__); + return 5; + } + xsiz = MAP_map[mapindex].xsiz; + if( 0 > x || x >= xsiz || 0 >y || y >= MAP_map[mapindex].ysiz ) { + print( "%s:%d:err\n", __FILE__, __LINE__); + return 5; + } + if( damage <= 0 )return 5; + + objimagenumber = MAP_map[mapindex].obj[x+y*xsiz]; + + if( MAP_getImageInt( objimagenumber,MAP_DEFENCE ) > 0 ){ + MAP_map[mapindex].objhp[x+y*xsiz] -= damage; + if( MAP_map[mapindex].objhp[x+y*xsiz] < 0 ){ + MAP_map[mapindex].obj[x+y*xsiz] = 0; +#if 1 + { + char *stringdata; + RECT seekr , retr; + seekr.x = x; + seekr.y = y; + seekr.width = 1; + seekr.height = 1; + stringdata = MAP_getdataFromRECT(floor,&seekr,&retr); + if( stringdata ){ + print("RINGO: RETR: %d %d %d %d\n", + retr.x,retr.y,retr.width,retr.height); + if( CHAR_getInt( charaindex , CHAR_WHICHTYPE ) + == CHAR_TYPEPLAYER ){ + int fd = getfdFromCharaIndex( charaindex ); + lssproto_M_send(fd,floor, retr.x, retr.y, + retr.x + retr.width, retr.y + retr.height, + stringdata ); + } + } else { + print("RINGO: bad stringdata. %d %d %d %d\n", + seekr.x,seekr.y,seekr.width,seekr.height); + + } + + } +#endif + return 1; + } + return 2; + } + + if( MAP_getImageInt(MAP_map[mapindex].obj[y*xsiz+x],MAP_HAVEHEIGHT ) + == 0 ) + return 4; +#endif + return 3; +} +BOOL MAP_appendTailObj( int floor, int x, int y, int objindex ) +{ + int mapindex; + int xsiz; + int dataindex; + MAP_Objlink* c; + MAP_Objlink* top; + + mapindex = MAP_getfloorIndex( floor ); + if( mapindex == -1 ) { + //print( "%s:%d:err(fl=%d,x=%d,y=%d)\n", __FILE__, __LINE__, floor, x, y ); + return FALSE; + } + xsiz = MAP_map[mapindex].xsiz; + if( 0 > x || x >= xsiz || 0 >y || y >= MAP_map[mapindex].ysiz ) { + //print( "%s:%d:err(fl=%d,x=%d,y=%d)\n", __FILE__, __LINE__, floor, x, y); + return FALSE; + } + dataindex = y*xsiz+x; + top = MAP_map[mapindex].olink[dataindex]; + if( top == NULL ){ + top = allocateMemory( sizeof(MAP_Objlink) ); + if( top == NULL ) { + //print( "%s:%d:err(fl=%d,x=%d,y=%d)\n", __FILE__, __LINE__, floor, x, y); + return FALSE; + } + top->next = NULL; + top->objindex = objindex; + MAP_map[mapindex].olink[dataindex] = top; + return TRUE; + } + for( c=top ; c->next ; c = c->next ); + c->next = allocateMemory(sizeof(MAP_Objlink)); + if( c->next == NULL )return FALSE; + c->next->next = NULL; + c->next->objindex = objindex; + return TRUE; +} + +BOOL MAP_removeObj( int floor, int x, int y, int objindex ) +{ + int mapindex; + int xsiz; + int dataindex; + MAP_Objlink* c; + MAP_Objlink* last=NULL; + + mapindex = MAP_getfloorIndex( floor ); + if( mapindex == -1 ) { + print( "%s:%d:\n", __FILE__, __LINE__); + return FALSE; + } + xsiz = MAP_map[mapindex].xsiz; + if( 0 > x || x >= xsiz || 0 >y || y >= MAP_map[mapindex].ysiz ) { + print( "%s:%d: ͼ[%d] x:[%d] y:[%d]\n", __FILE__, __LINE__, floor, x, y); + return FALSE; + } + dataindex = y*xsiz+x; + c = MAP_map[mapindex].olink[dataindex]; + while( c ){ + if( c->objindex == objindex ){ + if( last ) + last->next = c->next; + else + MAP_map[mapindex].olink[dataindex] = c->next; + freeMemory( c ); + return TRUE; + } + last = c; + c = c->next; + } + print( "%s:%d:\n", __FILE__, __LINE__); + return FALSE; +} + +BOOL _MAP_objmove( char *file, int line, int objindex, int ofloor, int ox, int oy, int nfloor, + int nx, int ny ) +{ +#if 1 + + int oldmapindex; + int oldxsiz; + + int dataindex; + MAP_Objlink* c; + MAP_Objlink* last=NULL; + MAP_Objlink* pointer=NULL; + + oldmapindex = MAP_getfloorIndex( ofloor ); + if( oldmapindex == -1 ) { + print( "%s:%d: ͼ[%d] x:[%d] y:[%d]\n", __FILE__, __LINE__, + ofloor, ox, oy); + return FALSE; + } + oldxsiz = MAP_map[oldmapindex].xsiz; + if( 0 > ox || ox >= oldxsiz + || 0 >oy || oy >= MAP_map[oldmapindex].ysiz ) + { + print( "%s:%d: ͼ[%d] x:[%d] y:[%d]\n", __FILE__, __LINE__, + ofloor, ox, oy); + return FALSE; + } + dataindex = oy*oldxsiz+ox; + c = MAP_map[oldmapindex].olink[dataindex]; + while( c ){ + if( c->objindex == objindex ){ + if( last ) + last->next = c->next; + else + MAP_map[oldmapindex].olink[dataindex] = c->next; + + pointer = c; + pointer->next = NULL; + break; + } + last = c; + c = c->next; + } + if( !pointer ) { + print( "\n%s:%d:( %d,%d,%d )->(%d,%d,%d)\n", __FILE__, __LINE__, + ofloor, ox, oy, nfloor, nx, ny ); + return FALSE; + } + { + int newmapindex; + int newxsiz; + MAP_Objlink* top; + + if( ofloor == nfloor ){ + newmapindex = oldmapindex; + newxsiz = oldxsiz; + }else{ + newmapindex = MAP_getfloorIndex( nfloor ); + if( newmapindex == -1 ) { + print( "%s:%d: ͼ[%d] x:[%d] y:[%d]\n", __FILE__, __LINE__, + nfloor, nx, ny); + return FALSE; + } + newxsiz = MAP_map[newmapindex].xsiz; + } + if( 0 > nx || nx >= newxsiz + || 0 >ny || ny >= MAP_map[newmapindex].ysiz ) + { + print( "%s:%d: ͼ[%d] x:[%d] y:[%d]\n", __FILE__, __LINE__, + nfloor, nx, ny); + return FALSE; + } + + dataindex = ny*newxsiz+nx; + top = MAP_map[newmapindex].olink[dataindex]; + if( top == NULL ){ + top = MAP_map[newmapindex].olink[dataindex] = pointer; + top->next = NULL; + return TRUE; + } + + for( c=top ; c->next ; c = c->next ); + c->next = pointer; + c->next->next = NULL; + return TRUE; + } +#else + if( MAP_removeObj( ofloor,ox,oy,objindex) + && MAP_appendTailObj( nfloor, nx ,ny, objindex ) ) + return TRUE; +#endif + print( "%s:%d:\n", __FILE__, __LINE__); + return FALSE; +} + +MAP_Objlink* _MAP_getTopObj( char *file, int line,int floor, int x, int y ) +{ + int mapindex; + int xsiz; + + mapindex = MAP_getfloorIndex( floor ); + if( mapindex == -1 ) { + //print( "callfrom[%s:%d] %s:%d:err floor(%d,%d,%d)\n", file, line, __FILE__, __LINE__, + // floor, x, y ); + return NULL; + } + + xsiz = MAP_map[mapindex].xsiz; + +#if 1 + if( x >= xsiz) return NULL; + if( y >= MAP_map[mapindex].ysiz ) return NULL; + if( x < 0 ) return NULL; + if( y < 0 ) return NULL; + return MAP_map[mapindex].olink[y*xsiz+x]; +#else + if( 0 <= x && x < xsiz && 0 <= y && y < MAP_map[mapindex].ysiz ) + return MAP_map[mapindex].olink[y*xsiz+x]; + else + return NULL; +#endif +} + +BOOL MAP_addNewObj( int floor, int x, int y, int objindex ) +{ + OBJECT map; + BOOL ret; + + for( map=MAP_getTopObj(floor,x,y) ; map ; map = NEXT_OBJECT(map)) { + if( GET_OBJINDEX(map) == objindex ) { + print( "%s:%d:err\n", __FILE__, __LINE__); + return 0; + } + } + ret = MAP_appendTailObj( floor, x, y, objindex ); + if( ret )return 1; + else return -1; +} + +char *MAP_getFloorName( int floor) +{ + int floorindex; + floorindex = MAP_getfloorIndex( floor ); + if( floorindex == -1 ) { + print( "%s:%d:err\n", __FILE__, __LINE__); + return NULL; + } + return MAP_map[floorindex].string; +} + +#ifdef _MAKE_MAP +int MAP_getFloorXY( int floor, int *x, int *y) +{ + int floorindex; + floorindex = MAP_getfloorIndex( floor ); + if( floorindex == -1 ) { + print( "%s:%d:err\n", __FILE__, __LINE__); + return FALSE; + } + *x=MAP_map[floorindex].xsiz; + *y=MAP_map[floorindex].ysiz; + return TRUE; +} +#endif + +BOOL MAP_setObjData( int ff ,int fx, int fy, int obj, int objhp ) +{ + int floorindex,xsiz; + + floorindex = MAP_getfloorIndex( ff ); + if( floorindex == -1 ) { + print( "%s:%d:err\n", __FILE__, __LINE__); + return FALSE; + } + xsiz = MAP_map[floorindex].xsiz; + if( fx < 0 || fx >= xsiz ) { + return FALSE; + } + if( fy < 0 || fy >= MAP_map[floorindex].ysiz ) { + return FALSE; + } + MAP_map[floorindex].obj[fy*xsiz+fx] = obj; + return TRUE; +} + +void MAP_sendAroundMapdata( int fl, int fromx, int fromy) +{ + char* mapdata; + RECT seek,ret; + int i,j; + seek.x = fromx; + seek.y = fromy; + seek.width = seek.height = 1; + mapdata = MAP_getdataFromRECT(fl,&seek,&ret); + if( mapdata != NULL ) { + int x = fromx; + int y = fromy; + + for( i =x-MAP_CHAR_DEFAULTSEESIZ/2 ; i <= x+MAP_CHAR_DEFAULTSEESIZ/2 ; i++ ){ + for( j = y-MAP_CHAR_DEFAULTSEESIZ/2 ; j <= y+MAP_CHAR_DEFAULTSEESIZ/2 ; + j ++ ){ + OBJECT object; + for( object = MAP_getTopObj(fl,i,j) ; + object ; + object = NEXT_OBJECT(object ) ){ + int objindex = GET_OBJINDEX(object); + if( OBJECT_getType(objindex) == OBJTYPE_NOUSE ) continue; + if( OBJECT_getType(objindex) == OBJTYPE_CHARA ) { + int index = OBJECT_getIndex( objindex); + if( CHAR_getInt( index, CHAR_WHICHTYPE) == CHAR_TYPEPLAYER) { + int fd = getfdFromCharaIndex( index ); + if( fd != -1 ) { + lssproto_M_send( fd, fl, ret.x,ret.y, + ret.x+ret.width, ret.y+ret.height, + mapdata ); + } + } + } + } + } + } + }else { + print( "ͼݴ %s:%d \n" , __FILE__, __LINE__); + } +} + +#ifdef _STATUS_WATERWORD //ˮ״̬ +int MAP_getMapFloorType( int floor) +{ + int i=0; + int WaterWord[]={8101,8015,8029,8028,8027,817,8007,8100,151,160,161,-1}; + while( WaterWord[i] != -1 ){ + if( floor == WaterWord[i] ){ + return 1; + } + i++; + } + return 0; +} +#endif + + +int MAP_getMapNum() +{ + return MAP_mapnum; +} + +int MAP_getfloorId(int index) +{ + if( MAP_mapnum<=(index) || (index)<0 ) + return -1; + return MAP_map[index].id; +} + + +#ifdef _CAX_LNS_MAPSUOXU +BOOL MAP_SetExWarp(int mapid , int fl, int x, int y, int type) +{ + int tomapindex = MAP_getfloorIndex(mapid); + if (tomapindex == -1) + { + print( "ҲĿͼȷϵͼIDǷȷ\n"); + return FALSE; + } + + MAP_map[tomapindex].startpoint = (fl<<16)+(x << 8)+(y<<0); + MAP_map[tomapindex].MapType = type;//ͼͣ Ŀǰ ޸ĵȨ + return TRUE; +} + +int MAP_makenew( int mapid ,char* map_name) +{ + int mymapid = -1; + int tomapindex = -1,makemapindex = -1,i,j; + if ((tomapindex = MAP_getfloorIndex(mapid)) == -1) + { + print( "ҲĿͼȷϵͼIDǷȷ\n"); + return -1; + } + int mapstartid = getCopymapstartingID();//øͼʼID + for (j=mapstartid;j= MAP_mapnum ){//û㹻Ŀռװµĵͼ10µĿռװµͼ +// print( "û㹻ڴ棬·ڴ档\n"); + MAP_Map* MAP_map2;// + MAP_map2 = allocateMemory( sizeof( MAP_Map ) * MAP_mapnum); + if( MAP_map2 == 0 ){ + print( "ͼʧܣ\n"); + return -1; + } + memcpy( MAP_map2 , MAP_map ,sizeof(MAP_Map) * MAP_mapnum);//֮ǰ + freeMemory( MAP_map );//ͷŵ + MAP_map = 0; + MAP_mapnum += 100; + MAP_map = allocateMemory( sizeof( MAP_Map ) * MAP_mapnum);//¸ͼڴ + if( MAP_map == 0 ){ + print( "·ͼڴʧܣ\n"); + return -1; + } +// print( "·ͼڴɹ\n"); + memcpy( MAP_map , MAP_map2 ,sizeof(MAP_Map) * (MAP_mapnum-100));//֮ǰ + freeMemory( MAP_map2 ); + MAP_map2 = 0; + } + short *tile=0; + short *obj=0; + MAP_Objlink** olink; + int xy = MAP_map[tomapindex].xsiz * MAP_map[tomapindex].ysiz; + tile = allocateMemory( sizeof( short ) * MAP_map[tomapindex].xsiz * MAP_map[tomapindex].ysiz );//ͼڴ + if( tile == NULL ){ + print( "޷ڴͼͼ\n"); + return -1; + } + + obj = allocateMemory( sizeof( short ) * MAP_map[tomapindex].xsiz * MAP_map[tomapindex].ysiz );//ͼڴ + if( obj == NULL ){ + print( "޷ڴͼ\n"); + freeMemory( tile ); + return -1; + } + + olink = allocateMemory( sizeof(MAP_Objlink*) * MAP_map[tomapindex].xsiz * MAP_map[tomapindex].ysiz );//ͼڴ + if( olink == 0 ){ + print( "޷ڴͼ\n"); + freeMemory( obj ); + return -1; + } + memcpy( &tile , &MAP_map[tomapindex].tile ,sizeof(MAP_map[tomapindex].tile)); + memcpy( &obj , &MAP_map[tomapindex].obj ,sizeof(MAP_map[tomapindex].obj)); + for( i=0 ; i< xy ; i ++ ){ + olink[i] = 0; + } + MAP_map[makemapindex].id = mymapid; + MAP_map[makemapindex].xsiz = MAP_map[tomapindex].xsiz; + MAP_map[makemapindex].ysiz = MAP_map[tomapindex].ysiz; + if (strcmp(map_name,"")!=0 ){ + strcpysafe( MAP_map[makemapindex].string , + sizeof(MAP_map[makemapindex].string), + map_name ); + }else { + strcpysafe( MAP_map[makemapindex].string , + sizeof(MAP_map[makemapindex].string), + MAP_map[tomapindex].string ); + } + + MAP_map[makemapindex].tile = tile; + MAP_map[makemapindex].obj = obj; + MAP_map[makemapindex].olink = olink; + MAP_map[makemapindex].startpoint = (2006<<16)+(20 << 8)+(15<<0);//ĬΪͻ峤 + MAP_map[makemapindex].MapType = 0; + + MAP_idjumptbl[mymapid] = makemapindex; + if ( makemapindex >= MAP_mapnum_index) MAP_mapnum_index = makemapindex+1; +fbmap[mymapid-mapstartid] = mapid; +return mymapid; +} + +BOOL MAP_DelMap(int mapid ) +{ + int tomapindex = -1; + if ((tomapindex = MAP_getfloorIndex(mapid)) == -1) + { + print( "ҲĿͼȷϵͼIDǷȷ\n"); + return FALSE; + } + int mapstartid = getCopymapstartingID();//øͼʼID + if (mapid > mapstartid+9999 || mapid < mapstartid) { + print( "ֻͷŸͼ(%d-%d)\n",mapstartid,mapstartid+9999); + return FALSE; + } + MAP_map[tomapindex].id = 0; + if (MAP_map[tomapindex].tile != 0) freeMemory( MAP_map[tomapindex].tile );//ͷŵ + if (MAP_map[tomapindex].obj != 0) freeMemory( MAP_map[tomapindex].obj );//ͷŵ + freeMemory( MAP_map[tomapindex].olink );//ͷŵ + MAP_map[tomapindex].startpoint = -1;//ͷ˳ͼ͵ + MAP_map[tomapindex].MapType = 0;//ͼͣ Ŀǰ + MAP_idjumptbl[mapid] = -1;//ͼ + return TRUE; +} +#endif diff --git a/mclient.c b/mclient.c new file mode 100644 index 0000000..500fd7f --- /dev/null +++ b/mclient.c @@ -0,0 +1,45 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "autil.h" +#include "util.h" +#include "net.h" +#include "char.h" +#include "char_base.h" +#include "mclient.h" +#include "log.h" +#include "handletime.h" +#include "chatmagic.h" + +#ifdef _GSERVER_RUNTIME //GSERVERִжʱMSERVER +void gserver_runtime() +{ + int checksum=0; + char buffer[1024]; + time_t starttime1; + + if(mfd == -1) return; + if( gserver_runtime_starttime0_flag ){ + gserver_runtime_starttime0_flag = FALSE; + gserver_runtime_starttime0 = time(NULL); + } + print("\nChange->ʱmserver\n"); + strcpy(buffer, ""); + strcpy(PersonalKey, MSPERSIONALKEY); + starttime1 = time(NULL); + checksum += util_mkint(-1,buffer, (int)difftime(starttime1,gserver_runtime_starttime0));//͵ĵλΪ + util_mkint(-1,buffer, checksum); + util_SendMesg(mfd, MPROTO_RECALL_GSERVER_RUNTIME, buffer); +} +#endif diff --git a/msignal.c b/msignal.c new file mode 100644 index 0000000..3431045 --- /dev/null +++ b/msignal.c @@ -0,0 +1,155 @@ +#include "version.h" +#include +#include +#include + +#include + +#include "buf.h" +#include "net.h" +#include "char.h" +#include "item.h" +#include "object.h" +#include "configfile.h" +#include "lssproto_serv.h" +#include "saacproto_cli.h" +#include "log.h" +#include "petmail.h" +#ifdef _ALLBLUES_LUA +#include "mylua/mylua.h" +#endif +/*------------------------------------------------------------ + * ئ + ------------------------------------------------------------*/ +static void endlsprotocol( void ) +{ + lssproto_CleanupServer(); + saacproto_CleanupClient(); +} + +/*------------------------------------------------------------ + * ͻئľئئзëĸ + * ئ + ------------------------------------------------------------*/ +static void allDataDump( void ) +{ + closeAllLogFile(); +#ifdef _PET_ITEM + storeObjects( getStoredir() ); + storePetmail(); +#endif +#ifdef _ALLBLUES_LUA + closemyluaload(); +#endif + storeCharaData(); +} + +/*------------------------------------------------------------ + * ئ + ------------------------------------------------------------*/ +void shutdownProgram( void ) +{ + printf("رSAAC:%d\n",acfd); + printf("رհ󶨶˿:%d\n",bindedfd); + close( acfd ); + close( bindedfd ); + memEnd(); +} +#ifdef _GMSV_DEBUG +char *DebugMainFunction = NULL; +extern time_t initTime; +#endif +extern int player_online; +extern int player_maxonline; +char saacretfunc[255]=""; +char *saacsendfunc = NULL; +int cliretfunc=0; +int clisendfunc=0; +char playcdkey[16] = ""; +char *errraw = NULL; +void sigshutdown( int number ) +{ + if( number == 0 ){ + print( "\nGMSVر\n" ); + }else{ + print( "\n=========Ƿԭ=========\n"); + print( "׼Ϣ: %d\n" , number ); +#ifdef _GMSV_DEBUG + print( " : %s\n", DebugMainFunction ); +#endif + print( ": %d\n", player_online); + print( ": %d\n", player_maxonline); + print( "SAAC: %s\n", saacretfunc); + print( "SAAC: %s\n", saacsendfunc); + print( "cli : %d\n", cliretfunc); + print( "cli : %d\n", clisendfunc); + print( "˺: %s\n", playcdkey); + print( ": %s\n", errraw); +#ifdef _GMSV_DEBUG + { + time_t new_t; + int dd,hh,mm,ss; + char buf[128]; + time(&new_t); + if(initTime==0){ + print( "ʱ: δʼ\n" ); + }else{ + new_t-=initTime; + + dd=(int) new_t / 86400; new_t=new_t % 86400; + hh=(int) new_t / 3600; new_t=new_t % 3600; + mm=(int) new_t / 60; new_t=new_t % 60; + ss=(int) new_t; + + if (dd>0) { + snprintf( buf, sizeof( buf ) , " %d %d Сʱ %d %d 롣",dd,hh,mm,ss); + } else if (hh>0) { + snprintf( buf, sizeof( buf ) , " %d Сʱ %d %d 롣",hh,mm,ss); + } else { + snprintf( buf, sizeof( buf ) , " %d %d 롣",mm,ss); + } + print( "ʱ: %s\n", buf ); + } + } +#endif + print( "=========Ƿԭ=========\n"); + } + remove( "gmsvlog.err2"); + rename( "gmsvlog.err1", "gmsvlog.err2" ); + rename( "gmsvlog.err", "gmsvlog.err1" ); + rename( "gmsvlog", "gmsvlog.err" ); + + allDataDump(); + + signal( SIGINT , SIG_IGN ); + signal( SIGQUIT, SIG_IGN ); + signal( SIGKILL, SIG_IGN ); + signal( SIGSEGV, SIG_IGN ); + signal( SIGPIPE, SIG_IGN ); + signal( SIGTERM, SIG_IGN ); + + shutdownProgram(); + exit(number); +} + + + +void signalset( void ) +{ + // CoolFish: Test Signal 2001/10/26 + print("\nʼȡź..\n"); + + print("SIGINT:%d\n", SIGINT); + print("SIGQUIT:%d\n", SIGQUIT); + print("SIGKILL:%d\n", SIGKILL); + print("SIGSEGV:%d\n", SIGSEGV); + print("SIGPIPE:%d\n", SIGPIPE); + print("SIGTERM:%d\n", SIGTERM); + + signal( SIGINT , sigshutdown ); + signal( SIGQUIT, sigshutdown ); + signal( SIGKILL, sigshutdown ); + signal( SIGSEGV, sigshutdown ); + signal( SIGPIPE, SIG_IGN ); + signal( SIGTERM, sigshutdown ); +} diff --git a/mylua/ablua.c b/mylua/ablua.c new file mode 100644 index 0000000..93ea89a --- /dev/null +++ b/mylua/ablua.c @@ -0,0 +1,97 @@ +#include +#include +#include +#include +#include +#include +#include "autil.h" +#include "util.h" +#include "mylua/mylua.h" +#include "mylua/base.h" +#include "version.h" + +#ifdef _ALLBLUES_LUA + +extern MY_Lua MYLua; + +void LoadAllbluesLUA(char *path) +{ + struct dirent* ent = NULL; + char filename[256]; + DIR *pDir; + pDir=opendir(path); + + while(NULL != (ent=readdir(pDir))) + { + if(ent->d_name[0] == '.')continue; + if (ent->d_type==8){ + if( strcmptail( ent->d_name, ".allblues" ) == 0 +#ifndef _NOT_NOCRYPTO_LUA + || strcmptail( ent->d_name, ".lua" ) == 0 +#endif + ){ + char filename[256]; + memset(filename, 0, 256); + sprintf(filename, "%s/%s", path, ent->d_name); + + myluaload(filename); + } + }else{ + sprintf(filename, "%s/%s", path, ent->d_name); + LoadAllbluesLUA(filename); + } + } +} + +void ReLoadAllbluesLUA(char *filename) +{ + remyluaload(filename); +} + +void NewLoadAllbluesLUA(char *filename) +{ + char token[256]; + if(strlen(filename)>0){ + sprintf(token, "data/ablua/%s", filename); + myluaload(token); + }else{ + LoadAllbluesLUA("data/ablua"); + } +} + +const int getCharBaseValue(lua_State *L, int narg, CharBase *charbase, int num) +{ + if(!lua_isnumber(L, narg)){ + size_t l; + const char *data = luaL_checklstring(L, narg, &l); + + if( data == NULL || data[0] == '\0' ){ + return -1; + } + char field[64]; + int line = 1; + int i; + int value = 0; + while(getStringFromIndexWithDelim( data, "|", line, field, sizeof( field)) == TRUE) + { + for( i=0 ; i < num; i++ ){ + if( strcmp( charbase[i].field, field ) == 0 ){ + value |= charbase[i].element; + break; + } + } + + if(i == num){ + return -1; + } + line++; + } + + return value; + }else{ + return luaL_checkint(L, narg); + } +} + +#endif + diff --git a/mylua/battlebase.c b/mylua/battlebase.c new file mode 100644 index 0000000..abfb103 --- /dev/null +++ b/mylua/battlebase.c @@ -0,0 +1,261 @@ +#include +#include "version.h" +#include "char_base.h" +#include "enemy.h" +#include "object.h" +#include "char.h" +#include "lssproto_serv.h" +#include "battle.h" +#include "battle_command.h" +#include "lua.h" +#include "lauxlib.h" +#include "lualib.h" +#include "mylua/mylua.h" +#include "mylua/base.h" +#ifdef _ALLBLUES_LUA + +static int CreateVsEnemy (lua_State *L) +{ + const int charaindex = luaL_checkint(L, 1); + const int npcindex = luaL_checkint(L, 2); + int enemytable[11]; + int i; + for( i = 0; i < 11; i ++ ) { + enemytable[i] = -1; + } + luaL_checktype(L, 3, LUA_TTABLE); + int n = luaL_getn(L, 3); + int id = 0; + for(i = 0; i < n; i++){ + int enemyid = getArrayInt(L, i); + int curEnemy = ENEMY_getEnemyArrayFromId( enemyid ); + + if( ENEMY_CHECKINDEX( curEnemy) ) { + enemytable[id++] = curEnemy; + }else{ + enemytable[i] = -1; + } + } + int ret = BATTLE_CreateVsEnemyNew(charaindex, npcindex, enemytable); + if( ret == 0 ) { + if(npcindex>-1){ + CHAR_setWorkInt( npcindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_INIT ); + CHAR_sendBattleEffect( npcindex, ON); + } + lua_pushinteger(L, CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEINDEX)); + return 1; + }else{ + return 0; + } +} + +static int getCharOne(lua_State *L) +{ + const int battle = luaL_checkint(L, 1); + const int num = luaL_checkint(L, 2); + const int side = luaL_checkint(L, 3); + + lua_pushinteger(L, BattleArray[battle].Side[side].Entry[num].charaindex); + + return 1; +} + + +#ifdef _ALLBLUES_LUA_1_4 +static CharBase BattleBaseEvent[] = { + {{"¼"}, BATTLE_FINISH} + ,{{"¼"}, BATTLE_ESCAPE} +}; + +static int CreateRandVsPlayer (lua_State *L) +{ + const int floorid = luaL_checkint(L, 1); + int charaindex1 = -1, charaindex2 = -1; + int num = 0; + int i = 0; + int playernum = CHAR_getPlayerMaxNum(); + for (i = 0; i < playernum; i++){ + if (CHAR_getCharUse(i) == FALSE) continue; + if ( !CHAR_CHECKINDEX( i ) )continue; + if ( CHAR_getInt( i, CHAR_FLOOR ) == floorid ) { + if (CHAR_getWorkInt(i, CHAR_WORKBATTLEMODE) == BATTLE_CHARMODE_NONE){ + if(charaindex1 == -1){ + charaindex1 = i; + }else{ + charaindex2 = i; + } + if(CHAR_CHECKINDEX( charaindex1 ) && CHAR_CHECKINDEX( charaindex2 ) ){ + BATTLE_CreateVsPlayer(charaindex1, charaindex2); + num ++; + } + } + } + } + + lua_pushinteger(L, num); + + return 1; +} + +static int CreateVsPlayer(lua_State *L) +{ + const int charaindex1 = luaL_checkint(L, 1); + const int charaindex2 = luaL_checkint(L, 2); + + if(CHAR_CHECKINDEX( charaindex1 ) && CHAR_CHECKINDEX( charaindex2 ) ){ + if( CHAR_getWorkInt( charaindex1, CHAR_WORKBATTLEMODE ) == BATTLE_CHARMODE_NONE + && CHAR_getWorkInt( charaindex2, CHAR_WORKBATTLEMODE ) == BATTLE_CHARMODE_NONE ){ + if(BATTLE_CreateVsPlayer(charaindex1, charaindex2) == 0){ + lua_pushinteger(L, CHAR_getWorkInt( charaindex1, CHAR_WORKBATTLEINDEX)); + return 1; + } + } + } + lua_pushinteger(L, -1); + return 1; +} + +static int setLUAFunctionPointer(lua_State *L) +{ + size_t l; + const int battleindex = luaL_checkint(L, 1); + const int functype = getCharBaseValue(L, 2, BattleBaseEvent, arraysizeof(BattleBaseEvent)); + char *luafunctable=luaL_checklstring(L, 3, &l); + + BATTLE_setLUAFunction(battleindex, functype, L, luafunctable); + + return 1; +} + +static int WatchEntry(lua_State *L) +{ + const int meindex = luaL_checkint(L, 1); + const int toindex = luaL_checkint(L, 2); + + BATTLE_WatchEntry(meindex, toindex); + + return 1; +} + +static int NewEntry(lua_State *L) +{ + const int charaindex = luaL_checkint(L, 1); + const int battleindex = luaL_checkint(L, 2); + const int side = luaL_checkint(L, 3); + int fd = getfdFromCharaIndex(charaindex); + int iRet = BATTLE_NewEntry(charaindex, battleindex, side); + if( iRet == 0 ){ + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_RESCUE ); + iRet = BATTLE_PetDefaultEntry( + charaindex, + battleindex, + side + ); + } + if( iRet == 0 ){ + int flg; + if( CHAR_getInt( charaindex, CHAR_DEFAULTPET ) >= 0 ){ + int pindex = CHAR_getCharPet( charaindex, CHAR_getInt( charaindex, CHAR_DEFAULTPET ) ); + CHAR_setWorkInt( pindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_RESCUE ); + } + if( fd != -1 ){ + lssproto_EN_send( fd, BattleArray[battleindex].type, BattleArray[battleindex].field_no ); + } + flg = (BattleArray[battleindex].Side[side].flg & BSIDE_FLG_HELP_OK)? TRUE:FALSE; + lssproto_HL_send( fd, flg); + char szBuffer[256]; + sprintf( szBuffer, "BP|%X|%X|%X", + BATTLE_Index2No( battleindex, charaindex ), BP_FLG_JOIN, CHAR_getInt(charaindex, CHAR_MP ) ); + BATTLE_CommandSend( charaindex, szBuffer ); + lua_pushinteger(L, 1); + }else{ + if( fd != -1 ){ + lssproto_EN_send( fd, FALSE, BattleArray[battleindex].field_no ); + } + lua_pushinteger(L, 0); + } + + return 1; +} +#endif + +#ifdef _ALLBLUES_LUA_1_9 +static int CreateForWatcher(lua_State *L) +{ + const int meindex = luaL_checkint(L, 1); + const int baatleindex = luaL_checkint(L, 2); + + BATTLE_CreateForWatcher(meindex, baatleindex); + + return 1; +} + +static int checkindex(lua_State *L) +{ + const int baatleindex = luaL_checkint(L, 1); + + lua_pushinteger(L, BATTLE_CHECKINDEX(baatleindex)); + + return 1; +} + +static int getType(lua_State *L) +{ + const int baatleindex = luaL_checkint(L, 1); + + lua_pushinteger(L, BATTLE_getType(baatleindex)); + + return 1; +} + +#ifdef _BATTLE_TIMESPEED +static int getCreateTime(lua_State *L) +{ + const int baatleindex = luaL_checkint(L, 1); + + lua_pushinteger(L, BATTLE_getCreateTime(baatleindex)); + + return 1; +} +#endif + +static int getBattleFloor(lua_State *L) +{ + const int baatleindex = luaL_checkint(L, 1); + + lua_pushinteger(L, BATTLE_getBattleFloor(baatleindex)); + + return 1; +} +#endif + +static const luaL_Reg battlelib[] = { + {"CreateVsEnemy", CreateVsEnemy}, + {"getCharOne", getCharOne}, +#ifdef _ALLBLUES_LUA_1_4 + {"CreateRandVsPlayer", CreateRandVsPlayer}, + {"CreateVsPlayer", CreateVsPlayer}, + {"setLUAFunctionPointer", setLUAFunctionPointer}, + {"WatchEntry", WatchEntry}, + {"NewEntry", NewEntry}, +#endif +#ifdef _ALLBLUES_LUA_1_9 + {"CreateForWatcher", CreateForWatcher}, + {"checkindex", checkindex}, + {"getType", getType}, +#ifdef _BATTLE_TIMESPEED + {"getCreateTime", getCreateTime}, +#endif + {"getBattleFloor", getBattleFloor}, +#endif + {NULL, NULL} +}; + + +LUALIB_API int luaopen_Battle (lua_State *L) { + luaL_register(L, "battle", battlelib); + return 1; +} + +#endif + diff --git a/mylua/charbase.c b/mylua/charbase.c new file mode 100644 index 0000000..12d8093 --- /dev/null +++ b/mylua/charbase.c @@ -0,0 +1,1999 @@ +#include +#include "char.h" +#include "battle.h" +#include "object.h" +#include "char_base.h" +#include "enemy.h" +#include "mylua/base.h" +#include "npcutil.h" +#include "readmap.h" +#include "log.h" +#include "pet.h" +#include "lua.h" +#include "lauxlib.h" +#include "lualib.h" +#include "version.h" +#include "handletime.h" +#include "item_event.h" +#include "lssproto_serv.h" +#ifdef _ALLBLUES_LUA +#include "mylua/mylua.h" +extern MY_Lua MYLua; +static CharBase CharBaseWorkInt[] = { + {{""}, CHAR_WORKOBJINDEX} +#ifdef _FONT_SIZE + ,{{"ֺ"}, CHAR_WORKFONTSIZE} +#endif + ,{{"ս"}, CHAR_WORKBATTLEMODE} + ,{{""}, CHAR_WORKPARTYMODE} + ,{{"ս"}, CHAR_WORKBATTLEINDEX} + ,{{"NPCʱ1"}, CHAR_NPCWORKINT1} + ,{{"NPCʱ2"}, CHAR_NPCWORKINT2} + ,{{"NPCʱ3"}, CHAR_NPCWORKINT3} + ,{{"NPCʱ4"}, CHAR_NPCWORKINT4} + ,{{"NPCʱ5"}, CHAR_NPCWORKINT5} + ,{{"NPCʱ6"}, CHAR_NPCWORKINT6} + ,{{"NPCʱ7"}, CHAR_NPCWORKINT7} + ,{{"NPCʱ8"}, CHAR_NPCWORKINT8} + ,{{"NPCʱ9"}, CHAR_NPCWORKINT9} + ,{{"NPCʱ10"}, CHAR_NPCWORKINT10} + ,{{"NPCʱ11"}, CHAR_NPCWORKINT11} + ,{{"NPCʱ12"}, CHAR_NPCWORKINT12} + ,{{"NPCʱ13"}, CHAR_NPCWORKINT13} + ,{{"ģʽ"}, CHAR_WORKPETFOLLOWMODE} + ,{{"Ա1"}, CHAR_WORKPARTYINDEX1} + ,{{"Ա2"}, CHAR_WORKPARTYINDEX2} + ,{{"Ա3"}, CHAR_WORKPARTYINDEX3} + ,{{"Ա4"}, CHAR_WORKPARTYINDEX4} + ,{{"Ա5"}, CHAR_WORKPARTYINDEX5} + ,{{"HP"}, CHAR_WORKMAXHP} + ,{{"MP"}, CHAR_WORKMAXMP} + ,{{""}, CHAR_WORKATTACKPOWER} + ,{{""}, CHAR_WORKDEFENCEPOWER} + ,{{""}, CHAR_WORKQUICK} + ,{{""}, CHAR_WORKFIXVITAL} + ,{{""}, CHAR_WORKFIXSTR} + ,{{""}, CHAR_WORKFIXTOUGH} + ,{{"ٶ"}, CHAR_WORKFIXDEX} + ,{{"ͼ"}, CHAR_WORKFMFLOOR} + ,{{""}, CHAR_WORKATTACKPOWER} + ,{{""}, CHAR_WORKDEFENCEPOWER} + ,{{""}, CHAR_WORKQUICK} + ,{{""}, CHAR_WORKDBATTLEESCAPE} +#ifdef _OFFLINE_SYSTEM + ,{{""}, CHAR_WORK_OFFLINE} +#endif + ,{{"þ"}, CHAR_WORKGETEXP} +#ifdef _AUTO_PK + ,{{"ԶPK"}, CHAR_WORK_AUTOPK} + ,{{"ԶPK"}, CHAR_WORK_AUTOPK_DEAD} +#endif +#ifdef _SPECIAL_COUNTER + ,{{""}, CHAR_WORK_COUNTER} +#endif +#ifdef _SPECIAL_TIMER + ,{{"ʱ"}, CHAR_WORK_TIMER} +#endif +#ifdef _STREET_VENDOR + ,{{"̯"}, CHAR_WORKSTREETVENDOR} +#endif +#ifdef _RECORD_IP + ,{{"IP"}, CHAR_WORK_RECORD_IP} +#endif +#ifdef _ONLINE_TIME + ,{{"½ʱ"}, CHAR_WORK_LOGIN_TIME} +#endif + // ,{{"ӳ"}, CHAR_WORKITEM_ADDEXP} + // ,{{"ʱЧ"}, CHAR_WORKITEM_ADDEXPTIME} +}; + +static CharBase CharBaseWorkChar[] = { + {{"NPCʱ1"}, CHAR_NPCWORKCHAR1} + ,{{"NPCʱ2"}, CHAR_NPCWORKCHAR2} + ,{{"NPCʱ3"}, CHAR_NPCWORKCHAR3} + ,{{"NPCʱ4"}, CHAR_NPCWORKCHAR4} + ,{{"NPCʱ5"}, CHAR_NPCWORKCHAR5} + ,{{"NPCʱ6"}, CHAR_NPCWORKCHAR6} +#ifdef _STREET_VENDOR + ,{{"̯"}, CHAR_STREETVENDOR_NAME} +#endif +}; + +static CharBase CharBaseValue[] = { + {{""}, 0} + ,{{""}, 1} + ,{{""}, 2} + ,{{""}, 3} + ,{{""}, 4} + ,{{""}, 5} + ,{{""}, 6} + ,{{""}, 7} + ,{{""}, CHAR_TYPENONE} + ,{{""}, CHAR_TYPEPLAYER} + ,{{""}, CHAR_TYPEENEMY} + ,{{""}, CHAR_TYPEPET} +#ifdef _ALLBLUES_LUA + ,{{"LUA"}, CHAR_TYPELUANPC} +#endif +#ifdef _PLAYER_NPC + ,{{""}, CHAR_TYPEPLAYERNPC} + ,{{""}, CHAR_TYPEPLAYERPETNPC} +#endif +}; + +static CharBase CharBaseWorkValue[] = { + {{""}, CHAR_PARTY_NONE} + ,{{"ӳ"}, CHAR_PARTY_LEADER} + ,{{"Ա"}, CHAR_PARTY_CLIENT} + ,{{"ս"}, BATTLE_CHARMODE_NONE} + ,{{"սʼ"}, BATTLE_CHARMODE_INIT} + ,{{"ȴս"}, BATTLE_CHARMODE_C_WAIT} + ,{{"ȷս"}, BATTLE_CHARMODE_C_OK} + ,{{"ս"}, BATTLE_CHARMODE_RESCUE} + ,{{"ս"}, BATTLE_CHARMODE_FINAL} + ,{{"սʼ"}, BATTLE_CHARMODE_WATCHINIT} + ,{{"ûм"}, FMMEMBER_NONE} + ,{{""}, FMMEMBER_APPLY} + ,{{"峤"}, FMMEMBER_LEADER} + ,{{"Ա"}, FMMEMBER_MEMBER} + ,{{""}, FMMEMBER_ELDER} +}; + +static CharBase CharBaseInt[] = { + {{"ͼ"}, CHAR_BASEIMAGENUMBER} + ,{{"ԭͼ"}, CHAR_BASEBASEIMAGENUMBER} + ,{{"ͼ"}, CHAR_FLOOR} + ,{{"X"}, CHAR_X} + ,{{"Y"}, CHAR_Y} + ,{{""}, CHAR_DIR} + ,{{"ȼ"}, CHAR_LV} + ,{{"ʯ"}, CHAR_GOLD} + ,{{"HP"}, CHAR_HP} + ,{{"MP"}, CHAR_MP} + ,{{"MP"}, CHAR_MAXMP} + ,{{""}, CHAR_VITAL} + ,{{""}, CHAR_STR} + ,{{""}, CHAR_TOUGH} + ,{{"ٶ"}, CHAR_DEX} + ,{{""}, CHAR_EARTHAT} + ,{{"ˮ"}, CHAR_WATERAT} + ,{{""}, CHAR_FIREAT} + ,{{""}, CHAR_WINDAT} + ,{{"ս"}, CHAR_DEFAULTPET} + ,{{""}, CHAR_CHARM} + ,{{""}, CHAR_LUCK} + ,{{""}, CHAR_DEADCOUNT} + ,{{"·"}, CHAR_WALKCOUNT} + ,{{"˵"}, CHAR_TALKCOUNT} + ,{{"𻵴"}, CHAR_DAMAGECOUNT} + ,{{""}, CHAR_GETPETCOUNT} + ,{{"ɱ"}, CHAR_KILLPETCOUNT} + ,{{""}, CHAR_DEADPETCOUNT} + ,{{"ʼ"}, CHAR_SENDMAILCOUNT} + ,{{"ϳɴ"}, CHAR_MERGEITEMCOUNT} + ,{{"PK"}, CHAR_DUELBATTLECOUNT} + ,{{"PKӮ"}, CHAR_DUELWINCOUNT} + ,{{"PK"}, CHAR_DUELLOSECOUNT} + ,{{"PKʤ"}, CHAR_DUELSTWINCOUNT} + ,{{"PKʤ"}, CHAR_DUELMAXSTWINCOUNT} + ,{{""}, CHAR_WHICHTYPE} + ,{{"ѭ¼ʱ"}, CHAR_LOOPINTERVAL} +#ifdef _NEWOPEN_MAXEXP + ,{{"ܾ"}, CHAR_OLDEXP} +#endif + ,{{"ǰ"}, CHAR_EXP} + ,{{"ܵ"}, CHAR_SKILLUPPOINT} + ,{{""}, CHAR_LEVELUPPOINT} + ,{{"DP"}, CHAR_DUELPOINT} + ,{{""}, CHAR_EXP} + ,{{""}, CHAR_LASTTALKELDER} + ,{{"ת"}, CHAR_TRANSMIGRATION} + ,{{""}, CHAR_SILENT} + ,{{""}, CHAR_FMINDEX} + ,{{"λ"}, CHAR_FMLEADERFLAG} + ,{{""}, CHAR_BANKGOLD} + ,{{""}, CHAR_RIDEPET} + ,{{""}, CHAR_CRITIAL} + ,{{""}, CHAR_COUNTER} +#ifdef _GAMBLE_BANK +// ,{{"ij"}, CHAR_RIDEPET} +#endif +#ifdef _DROPSTAKENEW + ,{{"ij"}, CHAR_GAMBLENUM} +#endif +#ifdef _PERSONAL_FAME // Arminius 8.30: + ,{{""}, CHAR_FAME} +#endif +#ifdef _ATTACK_MAGIC + ,{{"ħ"}, CHAR_EARTH_EXP} + ,{{"ˮħ"}, CHAR_WATER_EXP} + ,{{"ħ"}, CHAR_FIRE_EXP} + ,{{"ħ"}, CHAR_WIND_EXP} + ,{{"ħ"}, CHAR_EARTH_RESIST} + ,{{"ˮħ"}, CHAR_WATER_RESIST} + ,{{"ħ"}, CHAR_FIRE_RESIST} + ,{{"ħ"}, CHAR_WIND_RESIST} + ,{{"ħȾ"}, CHAR_EARTH_ATTMAGIC_EXP} + ,{{"ˮħȾ"}, CHAR_WATER_ATTMAGIC_EXP} + ,{{"ħȾ"}, CHAR_FIRE_ATTMAGIC_EXP} + ,{{"ħȾ"}, CHAR_WIND_ATTMAGIC_EXP} + ,{{"ħԾֵ"}, CHAR_EARTH_DEFMAGIC_EXP} + ,{{"ˮħԾֵ"}, CHAR_WATER_DEFMAGIC_EXP} + ,{{"ħԾֵ"}, CHAR_FIRE_DEFMAGIC_EXP} + ,{{"ħԾֵ"}, CHAR_WIND_DEFMAGIC_EXP} +#endif +#ifdef _CHAR_PROFESSION // WON ADD ְҵ + ,{{"ְҵ"}, PROFESSION_CLASS} + ,{{"ְҵȼ"}, PROFESSION_LEVEL} + ,{{"ܵ"}, PROFESSION_SKILL_POINT} + ,{{"Ӷѵ"}, ATTACHPILE} + ,{{""}, PROFESSION_FIRE_P} + ,{{""}, PROFESSION_ICE_P} + ,{{""}, PROFESSION_THUNDER_P} + ,{{""}, PROFESSION_FIRE_R} + ,{{""}, PROFESSION_ICE_R} + ,{{"׿"}, PROFESSION_THUNDER_R} +#endif +#ifdef _NEW_MANOR_LAW + ,{{""}, CHAR_MOMENTUM} +#endif +//#ifdef _VIP_SERVER +// ,{{""}, CHAR_AMPOINT} +//#endif +#ifdef _VIP_RIDE + ,{{"Ա"}, CHAR_VIPRIDE} + ,{{"ԱЧ"}, CHAR_VIPTIME} +#endif +#ifdef _ITEM_PET_LOCKED + ,{{"ȫ"}, CHAR_LOCKED} +#endif +#ifdef _ONLINE_SHOP + ,{{""}, CHAR_BJ} +#endif +#ifdef _CAX_ESC_REPORT + ,{{"ǩ"}, CHAR_REPORT} +#endif + ,{{"ģʽAI"}, CHAR_MODAI} + ,{{"ɱAI"}, CHAR_VARIABLEAI} + ,{{"輼λ"}, CHAR_SLOT} + ,{{"ID"}, CHAR_PETID} + ,{{"ID"}, CHAR_PETENEMYID} + ,{{"ػ"}, CHAR_PETFAMILY} + ,{{"ֵ"}, CHAR_ALLOCPOINT} + ,{{"ɳ"}, CHAR_PETRANK} + ,{{"Ƶȼ"}, CHAR_LIMITLEVEL} + +/*char.setInt( petindex, "ںϱ", PetCode) + char.setInt( petindex, "ת", 2) + char.setInt( petindex, "ں", 3) + char.setInt( petindex, "ںϱ", -1) + char.setInt( petindex, "װ", -1) + char.setInt( petindex, "ιʳ", 30 ) + char.setInt( petindex, "ںϳ", 1) + char.setInt( petindex, "ιʳʱ", other.time()) + char.setInt( petindex, "ں", 0) + char.setInt( petindex, "ں", 0) + char.setInt( petindex, "ں", 0) + char.setInt( petindex, "ںٶ", 0)*/ +// ,{{"ں"}, CHAR_FUSIONCODE}//CHAR_FUSIONBEIT + ,{{"ںϱ"}, CHAR_FUSIONINDEX}//ںϱ-- + ,{{"ںϱ"}, CHAR_FUSIONCODE}//- + ,{{"ιʳ"}, CHAR_FUSIONRAISE} //- + ,{{"ںϳ"}, CHAR_FUSIONBEIT}// - + ,{{"ιʳʱ"}, CHAR_FUSIONTIMELIMIT}// + ,{{"ں"}, CHAR_EVOLUTIONBASEVTL}// + ,{{"ں"}, CHAR_EVOLUTIONBASESTR}// + ,{{"ں"}, CHAR_EVOLUTIONBASETGH}// + ,{{"ںٶ"}, CHAR_EVOLUTIONBASEDEX}// + + +#ifdef _PET_BEATITUDE + ,{{"ֵ"}, CHAR_BEATITUDE} +#endif +#ifdef _CAMEO_MONEY + ,{{""}, CHAR_CAMEO} +#endif +#ifdef _MISSION_TRAIN + ,{{""}, CHAR_MISSIONTRAIN_NUM} + ,{{"ʱ"}, CHAR_MISSIONTRAIN_TIME} +#endif +#ifdef _PET_EVOLVE + ,{{""}, CHAR_EVOLVE} +#endif +#ifdef _ONLINE_TIME + ,{{"ʱ"}, CHAR_ONLINE_TIME} +#endif + ,{{"ʱ"}, CHAR_OFFTIME} +#ifdef _FLOOR_DIFI_FIELD + ,{{"¥ʱ"}, CHAR_FLOORDIFI_TIME} +#endif +//#ifdef _ACTIVE_GAME +// ,{{""}, CHAR_ACTIVE} +//#endif + ,{{"ӳ"}, CHAR_ADDEXPPOWER} //ӳ + ,{{"ʱЧ"}, CHAR_ADDEXPTIME} //ʱЧ /60 + ,{{""}, CHAR_VIGOR} + ,{{""}, CHAR_EVNUM} + ,{{"1"}, CHAR_LUASAVE_WORKINT_1} //lua洢 + ,{{"2"}, CHAR_LUASAVE_WORKINT_2} //lua洢 + ,{{"3"}, CHAR_LUASAVE_WORKINT_3} //lua洢 + ,{{"洢1"}, CHAR_LUASAVE_INT_1} //洢浵1-3 + ,{{"洢2"}, CHAR_LUASAVE_INT_2} //洢浵1-3 + ,{{"洢3"}, CHAR_LUASAVE_INT_3} //洢浵1-3 +#ifdef _CAX_Mercenary + ,{{"Ӷ"}, CHAR_MERCENARY} //Ӷ +#endif +#ifdef _SUPER + ,{{"Ʒ"}, CHAR_SUPER} +#endif +#ifdef _ALLDOMAN + ,{{"Ӣ۳ƺ"}, CHAR_HEROFLOOR} +#endif + +#ifdef _PLAYER_TITLE + ,{{"ƺŵȼ"}, CHAR_TITLE_LV} + ,{{"ƺʱ"}, CHAR_TITLE_TIME} +#endif +#ifdef _MISSION_TIME + ,{{"ʱ"}, CHAR_MISSION_TIME} +#endif +#ifdef _REGISTRATION_TIME + ,{{"ǩʱ"}, CHAR_REGISTRATION_TIME} + ,{{"ǩ"}, CHAR_REGISTRATION_COUNT} + ,{{"ǩʱ"}, CHAR_REGISTRATION_ONLINE_TIME} +#endif + ,{{"֤"}, CHAR_LOWRIDEPETS} + ,{{"֤1"}, CHAR_LOWRIDEPETS1} + ,{{"֤2"}, CHAR_HIGHRIDEPETS2} +}; + +static CharBase CharBaseChar[] = { + {{""}, CHAR_NAME} + ,{{"dz"}, CHAR_OWNTITLE} + ,{{""}, CHAR_USERPETNAME} + ,{{"˺"}, CHAR_CDKEY} + ,{{""}, CHAR_FMNAME} +#ifdef _TEACHER_SYSTEM + ,{{"ʦʺ"}, CHAR_TEACHER_ID} + ,{{"ʦ"}, CHAR_TEACHER_NAME} +#endif +#ifdef _ITEM_SETLOVER + ,{{"˺"}, CHAR_LOVERID} + ,{{""}, CHAR_LOVERNAME} +#endif +#ifdef _NEW_NAME + ,{{"ƺ"}, CHAR_NEWNAME} +#endif +#ifdef _LOTTERY_SYSTEM + ,{{"Ʊ"}, CHAR_LOTTERY_VALUE} +#endif + ,{{"˺"}, CHAR_OWNERCDKEY} + ,{{""}, CHAR_OWNERCHARANAME} +}; + + +static CharBase CharBaseEvent[] = { + {{"ʼ¼"}, CHAR_INITFUNC} + //,{{"¼"}, CHAR_WALKPREFUNC} + //,{{"ߺ¼"}, CHAR_WALKPOSTFUNC} + //,{{"δ֪¼"}, CHAR_PREOVERFUNC} + //,{{"δ֪¼"}, CHAR_POSTOVERFUNC} + //,{{"ۿ¼"}, CHAR_WATCHFUNC} + ,{{"ѭ¼"}, CHAR_LOOPFUNC} + //,{{"¼"}, CHAR_DYINGFUNC} + ,{{"Ի¼"}, CHAR_TALKEDFUNC} + //,{{"¼"}, CHAR_PREATTACKEDFUNC} + //,{{"¼"}, CHAR_POSTATTACKEDFUNC} + //,{{"뿪¼"}, CHAR_OFFFUNC} + //,{{"¼"}, CHAR_LOOKEDFUNC} + //,{{"¼"}, CHAR_ITEMPUTFUNC} + //,{{"Ի¼"}, CHAR_SPECIALTALKEDFUNC} + ,{{"¼"}, CHAR_WINDOWTALKEDFUNC} +#ifdef _USER_CHARLOOPS + //,{{"ѭ¼1"}, CHAR_LOOPFUNCTEMP1} + //,{{"ѭ¼2"}, CHAR_LOOPFUNCTEMP2} + //,{{"δ֪¼"}, CHAR_BATTLEPROPERTY} +#endif + ,{{"ص¼"}, CHAR_OVERLAPEDFUNC} + ,{{"ս¼"}, CHAR_BATTLEOVERDFUNC} +#ifdef _ALLBLUES_LUA_1_4 + ,{{"dz¼"}, CHAR_LOGINOUTFUNC} +#endif +#ifdef _ALLBLUES_LUA_1_9 + ,{{"ս¼"}, CHAR_BATTLESETFUNC} +#endif +}; + +static CharBase CharBaseColor[] = { + {{"ɫ"}, CHAR_COLORWHITE} + ,{{"ɫ"}, CHAR_COLORCYAN} + ,{{"ɫ"}, CHAR_COLORPURPLE} + ,{{"ɫ"}, CHAR_COLORBLUE} + ,{{"ɫ"}, CHAR_COLORYELLOW} + ,{{"ɫ"}, CHAR_COLORGREEN} + ,{{"ɫ"}, CHAR_COLORRED} + ,{{"Ұɫ"}, CHAR_COLORGRAY} + ,{{"ɫ"}, CHAR_COLORBLUE2} + ,{{"ɫ"}, CHAR_COLORGREEN2} +}; + +static CharBase CharBaseUpdata[] = { + {{"HP"}, CHAR_P_STRING_HP} + ,{{"MAXHP"}, CHAR_P_STRING_MAXHP} + ,{{"MP"}, CHAR_P_STRING_MP} + ,{{"MAXMP"}, CHAR_P_STRING_MAXMP} + ,{{""}, CHAR_P_STRING_VITAL} + ,{{""}, CHAR_P_STRING_STR} + ,{{""}, CHAR_P_STRING_TOUGH} + ,{{"ٶ"}, CHAR_P_STRING_DEX} + ,{{""}, CHAR_P_STRING_EXP} + ,{{"һ"}, CHAR_P_STRING_NEXTEXP} + ,{{"ȼ"}, CHAR_P_STRING_LV} + ,{{""}, CHAR_P_STRING_ATK} + ,{{""}, CHAR_P_STRING_DEF} + ,{{""}, CHAR_P_STRING_QUICK} + ,{{""}, CHAR_P_STRING_CHARM} + ,{{""}, CHAR_P_STRING_LUCK} + ,{{""}, CHAR_P_STRING_EARTH} + ,{{"ˮ"}, CHAR_P_STRING_WATER} + ,{{""}, CHAR_P_STRING_FIRE} + ,{{""}, CHAR_P_STRING_WIND} + ,{{"ʯ"}, CHAR_P_STRING_GOLD} + ,{{""}, CHAR_P_STRING_TITLE} + ,{{"DP"}, CHAR_P_STRING_DUELPOINT} + ,{{"ת"}, CHAR_P_STRING_TRANSMIGRATION} + ,{{""}, CHAR_P_STRING_NAME} + ,{{"dz"}, CHAR_P_STRING_OWNTITLE} + ,{{""}, CHAR_P_STRING_RIDEPET} + ,{{"ѧ"}, CHAR_P_STRING_LEARNRIDE} + ,{{"ͼ"}, CHAR_P_STRING_BASEBASEIMAGENUMBER} + ,{{""}, CHAR_P_STRING_SKYWALKER} + ,{{"ģʽ"}, CHAR_P_STRING_DEBUGMODE} +}; + +static CharBase CharBaseFlg[] = { + {{"ɼ"}, CHAR_ISVISIBLE} + ,{{"͸"}, CHAR_ISTRANSPARENT} + ,{{""}, CHAR_ISFLYING} + ,{{""}, CHAR_ISDIE} + ,{{""}, CHAR_ISPARTY} + ,{{""}, CHAR_ISDUEL} + ,{{"Ƭ"}, CHAR_ISTRADECARD} + ,{{""}, CHAR_ISTRADE} +#ifdef _CHANNEL_MODIFY + ,{{"Ƶ"}, CHAR_ISTELL} + ,{{"Ƶ"}, CHAR_ISFM} + ,{{"ְҵƵ"}, CHAR_ISOCC} + ,{{"Ի"}, CHAR_ISSAVE} + ,{{""}, CHAR_ISCHAT} +#ifdef _CHATROOMPROTOCOL +#ifdef _THE_WORLD_SEND + ,{{"Ƶ"}, CHAR_ISWORLD} +#endif +#ifdef _ONLINE_TALK_IP + ,{{"ٱƵ"}, CHAR_ISTALKIP} +#endif +#endif +#endif +}; + +static CharBase CharBaseAction[] = { + {{"վ"}, CHAR_ACTSTAND} + ,{{"߶"}, CHAR_ACTWALK} + ,{{""}, CHAR_ACTATTACK} + ,{{"Ͷ"}, CHAR_ACTTHROW} + ,{{""}, CHAR_ACTDAMAGE} + ,{{""}, CHAR_ACTDEAD} + ,{{"ħ"}, CHAR_ACTMAGIC} + ,{{""}, CHAR_ACTITEM} + ,{{"Ч"}, CHAR_ACTEFFECT} + ,{{""}, CHAR_ACTDOWN} + ,{{""}, CHAR_ACTSIT} + ,{{""}, CHAR_ACTHAND} + ,{{""}, CHAR_ACTPLEASURE} + ,{{"ŭ"}, CHAR_ACTANGRY} + ,{{""}, CHAR_ACTSAD} + ,{{""}, CHAR_ACTGUARD} + ,{{"·"}, CHAR_ACTACTIONWALK} + ,{{"ͷ"}, CHAR_ACTNOD} + ,{{"վ"}, CHAR_ACTACTIONSTAND} + ,{{"ս"}, CHAR_ACTBATTLE} + ,{{""}, CHAR_ACTLEADER} + ,{{"ս"}, CHAR_ACTBATTLEWATCH} + ,{{"δ֪"}, CHAR_ACTPOPUPNAME} + ,{{"ת"}, CHAR_ACTTURN} + ,{{""}, CHAR_ACTWARP} + ,{{""}, CHAR_ACTTRADE} +#ifdef _ANGEL_SUMMON + ,{{"ʹ"}, CHAR_ACTANGEL} +#endif + +#ifdef _MIND_ICON + ,{{"˼"}, CHAR_MIND} +#endif +#ifdef _STREET_VENDOR + ,{{"̯̲"}, CHAR_STREETVENDOR_OPEN} + ,{{"ر̯̲"}, CHAR_STREETVENDOR_CLOSE} +#endif +}; + + +static int getCharNum (lua_State *L) +{ + lua_pushinteger(L, CHAR_getCharNum()); + + return 1; +} + +static int getPlayerMaxNum (lua_State *L) +{ + lua_pushinteger(L, CHAR_getPlayerMaxNum()); + + return 1; +} + +static int getPetMaxNum (lua_State *L) +{ + lua_pushinteger(L, CHAR_getPetMaxNum()); + + return 1; +} + +static int getOthersMaxNum (lua_State *L) +{ + lua_pushinteger(L, CHAR_getOthersMaxNum()); + + return 1; +} + + +static int check (lua_State *L) +{ + const int index = luaL_checkint(L, 1); + lua_pushinteger(L, CHAR_CHECKINDEX(index)); + + return 1; +} + +static int setFlg (lua_State *L) +{ + const int index = luaL_checkint(L, 1); + const int element = getCharBaseValue(L, 2, CharBaseFlg, arraysizeof(CharBaseFlg)); + const int data = luaL_checkint(L, 3); + if(CHAR_setFlg(index, element, data) == -1){ + return 0; + }else{ + return 1; + } +} + +static int getFlg (lua_State *L) +{ + const int index = luaL_checkint(L, 1); + const int element = getCharBaseValue(L, 2, CharBaseFlg, arraysizeof(CharBaseFlg)); + + lua_pushinteger(L, CHAR_getFlg(index, element)); + return 1; +} + +static int setWorkChar (lua_State *L) +{ + size_t l; + const int index = luaL_checkint(L, 1); + const int element = getCharBaseValue(L, 2, CharBaseWorkChar, arraysizeof(CharBaseWorkChar)); + char *data = luaL_checklstring(L, 3, &l); + if(CHAR_setWorkChar(index, element, data) == -1){ + return 0; + }else{ + return 1; + } +} + +static int getWorkChar (lua_State *L) +{ + const int index = luaL_checkint(L, 1); + const int element = getCharBaseValue(L, 2, CharBaseWorkChar, arraysizeof(CharBaseWorkChar)); + lua_pushstring(L, CHAR_getWorkChar(index, element)); + return 1; +} + + +static int setWorkInt (lua_State *L) +{ + const int index = luaL_checkint(L, 1); + const int element = getCharBaseValue(L, 2, CharBaseWorkInt, arraysizeof(CharBaseWorkInt)); + const int data = getCharBaseValue(L, 3, CharBaseWorkValue, arraysizeof(CharBaseWorkValue)); + //print("index = %d element =%d data =%d \n ",index,element,data); + if(CHAR_setWorkInt(index, element, data) == -1){ + return 0; + }else{ + return 1; + } +} + +static int getWorkInt (lua_State *L) +{ + const int index = luaL_checkint(L, 1); + const int element = getCharBaseValue(L, 2, CharBaseWorkInt, arraysizeof(CharBaseWorkInt)); + lua_pushinteger(L, CHAR_getWorkInt(index, element)); + return 1; +} + +static int setChar (lua_State *L) +{ + size_t l; + const int index = luaL_checkint(L, 1); + const int element = getCharBaseValue(L, 2, CharBaseChar, arraysizeof(CharBaseChar)); + char *data = luaL_checklstring(L, 3, &l); + if(CHAR_setChar(index, element, data) == -1){ + return 0; + }else{ + return 1; + } +} + +static int getChar (lua_State *L) +{ + const int index = luaL_checkint(L, 1); + const int element = getCharBaseValue(L, 2, CharBaseChar, arraysizeof(CharBaseChar)); + lua_pushstring(L, CHAR_getChar(index, element)); + return 1; +} + +static int setInt (lua_State *L) +{ + const int index = luaL_checkint(L, 1); + const int element = getCharBaseValue(L, 2, CharBaseInt, arraysizeof(CharBaseInt)); + const int data = getCharBaseValue(L, 3, CharBaseValue, arraysizeof(CharBaseValue)); + if(CHAR_setInt(index, element, data) == -1){ + return 0; + }else{ + return 1; + } +} + +static int getInt (lua_State *L) +{ + const int index = luaL_checkint(L, 1); + const int element = getCharBaseValue(L, 2, CharBaseInt, arraysizeof(CharBaseInt)); + lua_pushinteger(L, CHAR_getInt(index, element)); + return 1; +} + +static int setFunctionPointer(lua_State *L) +{ + size_t l; + const int index = luaL_checkint(L, 1); + const int functype = getCharBaseValue(L, 2, CharBaseEvent, arraysizeof(CharBaseEvent)); + char *luafunctable=luaL_checklstring(L, 3, &l); + char *luafunctablepath=luaL_checklstring(L, 4, &l); + if(strlen(luafunctablepath) > 0){ + MY_Lua *mylua = &MYLua; + while(mylua->next != NULL){ + if(strcmp(mylua->luapath, luafunctablepath) == 0){ + return CHAR_setLUAFunction( index, functype, mylua->lua, luafunctable ); + } + mylua = mylua->next; + } + }else{ + return CHAR_setLUAFunction( index, functype, L, luafunctable ); + } + return 1; +} + +static int delFunctionPointer(lua_State *L) +{ + const int index = luaL_checkint(L, 1); + const int functype = getCharBaseValue(L, 2, CharBaseEvent, arraysizeof(CharBaseEvent)); + + return CHAR_delLUAFunction( index, functype ); +} + +static int TalkToCli(lua_State *L) +{ + size_t l; + const int talkedcharaindex = luaL_checkint(L, 1); + const int talkcharaindex = luaL_checkint(L, 2); + char *message=luaL_checklstring(L, 3, &l); + const int color = getCharBaseValue(L, 4, CharBaseColor, arraysizeof(CharBaseColor)); + CHAR_talkToCli(talkedcharaindex, talkcharaindex, message, color); + return 1; +} + +static int TalkToRound(lua_State *L) +{ + size_t l; + const int talkedcharaindex = luaL_checkint(L, 1); + char *message=luaL_checklstring(L, 2, &l); + const int color = getCharBaseValue(L, 3, CharBaseColor, arraysizeof(CharBaseColor)); + + int fl = CHAR_getInt( talkedcharaindex, CHAR_FLOOR) ; + int x = CHAR_getInt( talkedcharaindex, CHAR_X) ; + int y = CHAR_getInt( talkedcharaindex, CHAR_Y) ; + + int i,j; + + int range = 8; + + for( i=x-range ; i<=x+range ; i++ ){ + for( j=y-range ; j<=y+range ; j++ ){ + OBJECT object; + for( object = MAP_getTopObj( fl,i,j ) ; object ; object = NEXT_OBJECT(object) ){ + int objindex = GET_OBJINDEX(object); + int toindex = OBJECT_getIndex( objindex); + if( OBJECT_getType(objindex) == OBJTYPE_CHARA && toindex != talkedcharaindex ){ + if( CHAR_getInt(toindex, CHAR_WHICHTYPE) == CHAR_TYPEPLAYER){ + typedef void (*TALKF)(int,int,char*,int,int); + TALKF talkedfunc=NULL; + talkedfunc = (TALKF)CHAR_getFunctionPointer( toindex, CHAR_TALKEDFUNC); + if( talkedfunc ) { + talkedfunc(toindex, talkedcharaindex, message, color, -1); + } + } + } + } + } + } + + return 1; +} + +static int WalkPoint(lua_State *L) +{ + const int index = luaL_checkint(L, 1); + if( CHAR_getWorkInt( index, CHAR_WORKBATTLEMODE ) != BATTLE_CHARMODE_NONE ) return 0; + + const int x = luaL_checkint(L, 2); + const int y = luaL_checkint(L, 3); + + POINT start, end; + + start.x = CHAR_getInt( index, CHAR_X); + start.y = CHAR_getInt( index, CHAR_Y); + + end.x = x; + end.y = y; + + int pos = NPC_Util_getDirFromTwoPoint( &start, &end); + if( pos != - 1 ) { + CHAR_walk( index, pos, 0); + } + return 1; +} + +static int Walk(lua_State *L) +{ + const int index = luaL_checkint(L, 1); + if( CHAR_getWorkInt( index, CHAR_WORKBATTLEMODE ) != BATTLE_CHARMODE_NONE ) return 0; + + const int dir = luaL_checkint(L, 2); + const int step = luaL_checkint(L, 3); + + POINT start, end; + + start.x = CHAR_getInt( index, CHAR_X); + start.y = CHAR_getInt( index, CHAR_Y); + + end.x = start.x; + end.y = start.y; + switch(dir){ + case 0: + { + end.x = start.x - step; + break; + } + case 1: + { + end.x = start.x + step; + end.y = start.y - step; + break; + } + case 2: + { + end.x = start.x + step; + break; + } + case 3: + { + end.x = start.x + step; + end.y = start.y + step; + + break; + } + case 4: + { + end.y = start.y + step; + break; + } + case 5: + { + end.x = start.x - step; + end.y = start.y + step; + break; + } + case 6: + { + end.y = start.y - step; + break; + } + case 7: + { + end.x = start.x - step; + end.y = start.y - step; + break; + } + } + + int pos = NPC_Util_getDirFromTwoPoint( &start, &end); + if( dir != - 1 ) { + CHAR_walk( index, pos, 0); + } + return 1; +} + +static int BoundRandWalk(lua_State *L) +{ + const int index = luaL_checkint(L, 1); + if( CHAR_getWorkInt( index, CHAR_WORKBATTLEMODE ) != BATTLE_CHARMODE_NONE ) return 0; + + const int minX = min(luaL_checkint(L, 2), luaL_checkint(L, 4)); + const int minY = min(luaL_checkint(L, 3), luaL_checkint(L, 5)); + const int maxX = max(luaL_checkint(L, 2), luaL_checkint(L, 4)); + const int maxY = max(luaL_checkint(L, 3), luaL_checkint(L, 5)); + + POINT start, end; + int stepX = (rand() % 10) - 5; + int stepY = (rand() % 10) - 5; + + start.x = CHAR_getInt( index, CHAR_X); + start.y = CHAR_getInt( index, CHAR_Y); + + end.x = start.x + stepX; + if(end.x>maxX)end.x=maxX; + else if(end.xmaxY)end.y=maxY; + else if(end.y -1 ){ + CHAR_setCharPet( index, havepetelement, petindex); + CHAR_setWorkInt( petindex, CHAR_WORKPLAYERINDEX, index); + } + + lua_pushinteger(L, havepetelement); + + return 1; +} + +static int getCharPet(lua_State *L) +{ + const int index = luaL_checkint(L, 1); + const int havepetid = luaL_checkint(L, 2); + + lua_pushinteger(L, CHAR_getCharPet( index, havepetid)); + + return 1; +} + +static int DelItem(lua_State *L) +{ + const int charaindex = luaL_checkint(L, 1); + const int itemindex = luaL_checkint(L, 2); + + CHAR_DelItem( charaindex, itemindex); + + return 1; +} + +static int getFd(lua_State *L) +{ + const int charaindex = luaL_checkint(L, 1); + + lua_pushinteger(L, getfdFromCharaIndex(charaindex)); + return 1; +} + +static int Updata(lua_State *L) +{ + const int charaindex = luaL_checkint(L, 1); + const int indextable = getCharBaseValue(L, 2, CharBaseUpdata, arraysizeof(CharBaseUpdata)); + + CHAR_send_P_StatusString( charaindex , indextable); + return 1; +} + +static int Additem(lua_State *L) +{ + const int charaindex = luaL_checkint(L, 1); + const int itemid = luaL_checkint(L, 2); + int itemindex = -1; + int emptyitemindexinchara = CHAR_findEmptyItemBox( charaindex ); + + if( emptyitemindexinchara >= 0 ){ + itemindex = ITEM_makeItemAndRegist( itemid ); + + if( itemindex > -1 ){ + CHAR_setItemIndex( charaindex, emptyitemindexinchara, itemindex ); + ITEM_setWorkInt(itemindex, ITEM_WORKOBJINDEX, -1); + ITEM_setWorkInt(itemindex, ITEM_WORKCHARAINDEX, charaindex); + CHAR_sendItemDataOne( charaindex, emptyitemindexinchara); + LogItem( + CHAR_getChar( charaindex, CHAR_NAME ), + CHAR_getChar( charaindex, CHAR_CDKEY ), +#ifdef _add_item_log_name // WON ADD itemlogitem + itemindex, +#else + atoi( message), +#endif + "AddItem(LUA)", + CHAR_getInt( charaindex,CHAR_FLOOR), + CHAR_getInt( charaindex,CHAR_X ), + CHAR_getInt( charaindex,CHAR_Y ), + ITEM_getChar( itemindex, ITEM_UNIQUECODE), + ITEM_getChar( itemindex, ITEM_NAME), + ITEM_getInt( itemindex, ITEM_ID) + + ); + } + } + lua_pushinteger(L, itemindex); + return 1; +} + +static int Finditem(lua_State *L) +{ + const int charaindex = luaL_checkint(L, 1); + const int itemid = luaL_checkint(L, 2); + int i; + int itemindex=-1; + int id; + for( i=CHAR_STARTITEMARRAY;i> (4 - flg) * 8) & 0xFF); + + return 1; +} + +static int getLiftTo8(lua_State *L) +{ + const int value = luaL_checkint(L, 1); + const int flg = luaL_checkint(L, 2); + + lua_pushinteger(L, (value << (4 - flg) * 8)); + + return 1; +} + +static int complianceParameter(lua_State *L) +{ + const int index = luaL_checkint(L, 1); + + CHAR_complianceParameter(index); + + return 1; +} + + +static int sendStatusString(lua_State *L) +{ + size_t l; + const int index = luaL_checkint(L, 1); + char *data=luaL_checklstring(L, 2, &l); + + CHAR_sendStatusString( index, data ); + + return 1; +} + +static int sendBattleEffect(lua_State *L) +{ + const int index = luaL_checkint(L, 1); + const int val = luaL_checkint(L, 2); + + CHAR_sendBattleEffect( index, val ); + + return 1; +} + +static int sendWatchEvent(lua_State *L) +{ + const int objindex = luaL_checkint(L, 1); + const int action = getCharBaseValue(L, 2, CharBaseAction, arraysizeof(CharBaseAction)); + const int flg = luaL_checkint(L, 3); + + luaL_checktype(L, 4, LUA_TTABLE); + int n = luaL_getn(L, 4); + int *opt = (int *) malloc(n * sizeof(int)); + int i; + + for(i = 0; i < n; i++){ + opt[i] = getArrayInt(L, i); + } + + CHAR_sendWatchEvent( objindex, action, opt, n, flg); + + return 1; +} + +static int dropPetAbsolute(lua_State *L) +{ + const int index = luaL_checkint(L, 1); + const int fl = luaL_checkint(L, 2); + const int fx = luaL_checkint(L, 3); + const int fy = luaL_checkint(L, 4); + const int dir = luaL_checkint(L, 5); + const int val = luaL_checkint(L, 6); + int dirx[9],diry[9]; + int floor, x, y, i; + + for( i = 0 ; i < 7 ; i ++ ){ + dirx[i+2] = CHAR_getDX(dir + i+1); + diry[i+2] = CHAR_getDY(dir + i+1); + } + dirx[0] = CHAR_getDX(dir); + diry[0] = CHAR_getDY(dir); + dirx[1] = 0; + diry[1] = 0; + floor = fl; + for( i = 0 ; i < 9 ; i ++ ){ + int x=fx+dirx[i]; + int y=fy+diry[i]; + if( PET_isPutPoint( floor, x, y ) == TRUE ) { + break; + } + } + if( i == 9 ) i = 1; + x = fx+dirx[i]; + y = fy+diry[i]; + + int objindex = PET_dropPetAbsolute( index, floor, x, y, val ); + + if( objindex == -1 ){ + return 1; + } + + CHAR_setWorkInt( index, CHAR_WORKOBJINDEX, objindex ); + CHAR_setInt( index, CHAR_FLOOR, floor); + CHAR_setInt( index, CHAR_X, x); + CHAR_setInt( index, CHAR_Y, y); + CHAR_setInt( index, CHAR_PUTPETTIME, NowTime.tv_sec); + + CHAR_sendCToArroundCharacter( objindex); + + return 1; +} + +static int AllWarpToSpecificPoint(lua_State *L) +{ + const int charaindex = luaL_checkint(L, 1); + const int floor = luaL_checkint(L, 2); + const int x = luaL_checkint(L, 3); + const int y = luaL_checkint(L, 4); + + if( CHAR_getWorkInt( charaindex, CHAR_WORKPARTYMODE ) == CHAR_PARTY_LEADER ){ + int i; + for( i = 0; i < CHAR_PARTYMAX; i ++ ){ + int subindex = CHAR_getWorkInt( charaindex, CHAR_WORKPARTYINDEX1+i ); + if( CHAR_CHECKINDEX( subindex ) == FALSE ) continue; + CHAR_warpToSpecificPoint( subindex, floor, x, y ); + ITEM_WarpDelErrorItem( subindex ); + } + }else if( CHAR_getWorkInt( charaindex, CHAR_WORKPARTYMODE ) == CHAR_PARTY_CLIENT ){ + CHAR_talkToCli(charaindex, -1, "Ա޷ʹá", CHAR_COLORYELLOW); + return FALSE; + }else if( CHAR_getWorkInt( charaindex, CHAR_WORKPARTYMODE ) == CHAR_PARTY_NONE ){ + ITEM_WarpDelErrorItem( charaindex ); + CHAR_warpToSpecificPoint( charaindex, floor, x, y ); + } + + + return 1; +} + +static int Findpet(lua_State *L) +{ + const int charaindex = luaL_checkint(L, 1); + const int petid = luaL_checkint(L, 2); + const int lv = luaL_checkint(L, 3); + int i; + + for( i = 0; i < CHAR_MAXPETHAVE; i ++ ){ + int petindex = CHAR_getCharPet( charaindex, i ); + if(!CHAR_CHECKINDEX( petindex))continue; + if( CHAR_getInt(petindex, CHAR_PETID) == petid ){ + if(lv > 0){ + if( CHAR_getInt(petindex, CHAR_LV) != lv){ + continue; + } + } + lua_pushinteger(L, petindex); + return 1; + } + } + + lua_pushinteger(L, -1); + return 1; +} + +static int FindPetFormMatemo(lua_State *L) +{ + const int charaindex = luaL_checkint(L, 1); + const int metamo = luaL_checkint(L, 2); + const int lv = luaL_checkint(L, 3); + int i; + + for( i = 0; i < CHAR_MAXPETHAVE; i ++ ){ + int petindex = CHAR_getCharPet( charaindex, i ); + if(!CHAR_CHECKINDEX( petindex))continue; + if( CHAR_getInt(petindex, CHAR_BASEBASEIMAGENUMBER) == metamo ){ + if(lv > 0){ + if( CHAR_getInt(petindex, CHAR_LV) != lv){ + continue; + } + } + lua_pushinteger(L, petindex); + return 1; + } + } + + lua_pushinteger(L, -1); + return 1; +} + +static int FindPetFormEnemyTempID(lua_State *L) +{ + size_t l; + const int charaindex = luaL_checkint(L, 1); + char *data=luaL_checklstring(L, 2, &l); + char token[64]; + int enemytempid = -1, lv = 0; + int i; + + if(getStringFromIndexWithDelim(data, "-", 1, token, sizeof(token)) == TRUE){ + lv = atoi(token); + }else{ + lua_pushinteger(L, -1); + } + + if(getStringFromIndexWithDelim(data, "-", 2, token, sizeof(token)) == TRUE){ + enemytempid = atoi(token); + }else{ + lua_pushinteger(L, -1); + } + + for( i = 0; i < CHAR_MAXPETHAVE; i ++ ){ + int petindex = CHAR_getCharPet( charaindex, i ); + if(!CHAR_CHECKINDEX( petindex))continue; + + if( CHAR_getInt( petindex, CHAR_PETID) == enemytempid ){ + if(lv > 0){ + if( CHAR_getInt(petindex, CHAR_LV) != lv){ + continue; + } + } + lua_pushinteger(L, petindex); + return 1; + } + } + + lua_pushinteger(L, -1); + return 1; +} + +static int DelPet(lua_State *L) +{ + const int charaindex = luaL_checkint(L, 1); + const int petindex = luaL_checkint(L, 2); + int i; + char category[12]; + + for( i = 0; i < CHAR_MAXPETHAVE; i ++ ){ + if( petindex == CHAR_getCharPet( charaindex, i ) ){ + if( CHAR_getInt( charaindex, CHAR_RIDEPET) == i ) { + CHAR_setInt( charaindex, CHAR_RIDEPET, -1); + CHAR_send_P_StatusString( charaindex, CHAR_P_STRING_RIDEPET ); + CHAR_complianceParameter( charaindex ); + CHAR_sendCToArroundCharacter( CHAR_getWorkInt( charaindex , CHAR_WORKOBJINDEX )); + } + + CHAR_endCharOneArray( petindex ); + CHAR_setCharPet( charaindex, i, -1); + snprintf( category, sizeof( category), "K%d",i); + CHAR_sendStatusString( charaindex, category ); + break; + } + } + return 1; +} + +#endif + +#ifdef _ALLBLUES_LUA_1_7 +static int findEmptyItemBox(lua_State *L) +{ + const int charaindex = luaL_checkint(L, 1); + + lua_pushinteger(L, CHAR_findEmptyItemBox(charaindex)); + return 1; +} + +static int findEmptyPetBox(lua_State *L) +{ + const int charaindex = luaL_checkint(L, 1); + int num = 0; + int i; + for( i = 0; i < CHAR_MAXPETHAVE; i ++ ){ + int petindex = CHAR_getCharPet( charaindex, i ); + if(!CHAR_CHECKINDEX(petindex)){ + num ++ ; + } + } + lua_pushinteger(L, num); + return 1; +} + +static int dropPetFollow(lua_State *L) +{ + const int charaindex = luaL_checkint(L, 1); + const int havepetindex = luaL_checkint(L, 2); + char szPet[128]; + int dirx[9],diry[9]; + int i; + int objindex=-1; + int floor,x,y; + int petindex; + + if( CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE) + != BATTLE_CHARMODE_NONE) return FALSE; + petindex = CHAR_getCharPet(charaindex,havepetindex); + if( petindex == -1 ) return FALSE; + if( !CHAR_CHECKINDEX( charaindex ) )return FALSE; + if( CHAR_CHECKINDEX( petindex) == FALSE ) return FALSE; + + if (CHAR_getInt(petindex, CHAR_PETFAMILY) == 1){ + CHAR_talkToCli(charaindex, -1, "ػ޷", CHAR_COLORYELLOW); + return FALSE; + } + if (CHAR_getInt(charaindex, CHAR_RIDEPET) == havepetindex){ + CHAR_talkToCli(charaindex, -1, "еij޷棡", CHAR_COLORYELLOW); + return FALSE; + } + + for( i = 0 ; i < 7 ; i ++ ){ + dirx[i+2] = CHAR_getDX(CHAR_getInt(charaindex,CHAR_DIR) + i+1); + diry[i+2] = CHAR_getDY(CHAR_getInt(charaindex,CHAR_DIR) + i+1); + } + dirx[0] = CHAR_getDX(CHAR_getInt(charaindex,CHAR_DIR)); + diry[0] = CHAR_getDY(CHAR_getInt(charaindex,CHAR_DIR)); + dirx[1] = 0; + diry[1] = 0; + + floor = CHAR_getInt( charaindex,CHAR_FLOOR ); + for( i = 0 ; i < 9 ; i ++ ){ + int x=CHAR_getInt(charaindex,CHAR_X)+dirx[i]; + int y=CHAR_getInt(charaindex,CHAR_Y)+diry[i]; + if( PET_isPutPoint( floor, x, y ) == TRUE ) { + break; + } + } + if( i == 9 ) i = 1; + + x=CHAR_getInt(charaindex,CHAR_X)+dirx[i]; + y=CHAR_getInt(charaindex,CHAR_Y)+diry[i]; + + objindex = PET_dropPetAbsolute( petindex,floor,x,y, FALSE ); + if( objindex == -1 ) return FALSE; + + CHAR_setWorkInt( petindex,CHAR_WORKOBJINDEX,objindex ); + CHAR_setCharPet( charaindex, havepetindex, -1); + CHAR_setInt( petindex, CHAR_FLOOR, floor); + CHAR_setInt( petindex, CHAR_X, x); + CHAR_setInt( petindex, CHAR_Y, y); + CHAR_setInt( petindex, CHAR_PUTPETTIME, NowTime.tv_sec); + if( havepetindex == CHAR_getInt( charaindex, CHAR_DEFAULTPET)) { + int fd; + CHAR_setInt( charaindex, CHAR_DEFAULTPET, -1); + fd = getfdFromCharaIndex( charaindex); + lssproto_KS_send( fd, havepetindex, 0); + + } + CHAR_sendCToArroundCharacter( objindex); + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE) == CHAR_TYPEPLAYER){ +#ifdef _PET_ITEM + CHAR_sendPetItemData( charaindex, havepetindex); +#endif + snprintf( szPet, sizeof( szPet ), "K%d", havepetindex ); + CHAR_sendStatusString( charaindex, szPet ); + } + + CHAR_setWorkInt( charaindex, CHAR_WORKPETFOLLOW, petindex); + CHAR_setWorkInt( petindex, CHAR_WORKPETFOLLOWMODE, CHAR_PETFOLLOW_NOW); + CHAR_setWorkInt( petindex, CHAR_WORKPETFOLLOWCOUNT, 0); + CHAR_setInt( petindex, CHAR_PUTPETTIME, (int)(NowTime.tv_sec)); + CHAR_setInt( petindex, CHAR_WORKPLAYERINDEX, charaindex); + LogPet( + CHAR_getChar( charaindex, CHAR_NAME ), + CHAR_getChar( charaindex, CHAR_CDKEY ), + CHAR_getChar( petindex, CHAR_NAME), + CHAR_getInt( petindex, CHAR_LV), + "Follow(lua)", + CHAR_getInt( charaindex,CHAR_FLOOR), + CHAR_getInt( charaindex,CHAR_X ), + CHAR_getInt( charaindex,CHAR_Y ), + CHAR_getChar( petindex, CHAR_UNIQUECODE) + ); + return 1; +} + +static int getItemIndex(lua_State *L) +{ + const int charaindex = luaL_checkint(L, 1); + const int haveitemindex = luaL_checkint(L, 2); + + lua_pushinteger(L, CHAR_getItemIndex( charaindex, haveitemindex )); + return 1; + +} + +static int charSaveFromConnect(lua_State *L) +{ + const int charaindex = luaL_checkint(L, 1); + if( CHAR_getCharUse(charaindex) != FALSE ){ + CHAR_charSaveFromConnect( charaindex, FALSE ); + } + return 1; +} + +#ifdef _RECORD_IP +static int userip(lua_State *L) +{ + const int charaindex = luaL_checkint(L, 1); + + unsigned long ip; + int a,b,c,d; + char strIP[32]; + + ip = CHAR_getWorkInt(charaindex, CHAR_WORK_RECORD_IP); + + a=(ip % 0x100); ip=ip / 0x100; + b=(ip % 0x100); ip=ip / 0x100; + c=(ip % 0x100); ip=ip / 0x100; + d=(ip % 0x100); + + sprintf(strIP, "%d.%d.%d.%d", a, b, c, d); + + lua_pushstring(L, strIP); + return 1; +} +#endif + +static int DischargeParty(lua_State *L) +{ + const int charaindex = luaL_checkint(L, 1); + const int flg = luaL_checkint(L, 2); + CHAR_DischargeParty(charaindex, flg); + return 1; +} + + +static int Skillupsend(lua_State *L) +{ + const int charaindex = luaL_checkint(L, 1); + + CHAR_Skillupsend(charaindex); + return 1; +} +#endif + +#ifdef _ALLBLUES_LUA_1_9 +static int logou(lua_State *L) +{ + const int charaindex = luaL_checkint(L, 1); + + CHAR_logout(charaindex, TRUE); + return 1; +} +#endif +//void CHAR_WXSYSCMD_setStayEncount(int charaindex, char* message ) +#ifdef _ALLBLUES_LUA_2_0 +static int Encounter(lua_State *L) +{ + const int charaindex = luaL_checkint(L, 1); + if(CHAR_CHECKINDEX(charaindex) == FALSE) return 0; + int fd=CHAR_getWorkInt( charaindex, CHAR_WORKFD); + setStayEncount(fd); +#ifdef _USER_CHARLOOPS + { + Char *ch; + ch = CHAR_getCharPointer( charaindex); + if( ch == NULL ) return; + strcpysafe( ch->charfunctable[CHAR_LOOPFUNCTEMP1].string, + sizeof( ch->charfunctable[CHAR_LOOPFUNCTEMP1]), "CHAR_BattleStayLoop");//ս + CHAR_setInt( charaindex, CHAR_LOOPINTERVAL, 2500); + CHAR_constructFunctable( charaindex); + } +#endif +} + +static int GetOldLevelExp(lua_State *L) +{ + size_t l; + const int level = luaL_checkint(L, 1); + CHAR_GetOldLevelExp(level); + return 1; +} +#endif +#ifdef _AutoBattle_LUA +static int gcgc(lua_State *L) +{ + const int charaindex = luaL_checkint(L, 1); + + Enemy_setStayLoop(charaindex); + return 1; +} +#endif + +#ifdef _FIX_PLAYER_NPC_PET +static int DelNpcPetByIndex(lua_State *L) +{ + const int petindex = luaL_checkint(L, 1); + CHAR_endCharOneArray( petindex ); + return 1; +} + +#endif + +static const luaL_Reg charlib[] = { + {"getCharNum", getCharNum}, + {"getPlayerMaxNum", getPlayerMaxNum}, + {"getPetMaxNum", getPetMaxNum}, + {"getOthersMaxNum", getOthersMaxNum}, + {"check", check}, + {"setWorkChar", setWorkChar}, + {"getWorkChar", getWorkChar}, + {"setWorkInt", setWorkInt}, + {"getWorkInt", getWorkInt}, + {"setChar", setChar}, + {"getChar", getChar}, + {"setInt", setInt}, + {"getInt", getInt}, + {"setFlg", setFlg}, + {"getFlg", getFlg}, + {"setFunctionPointer", setFunctionPointer}, + {"delFunctionPointer", delFunctionPointer}, + {"TalkToCli", TalkToCli}, + {"TalkToRound", TalkToRound}, + {"talkToFloor", talkToFloor}, + {"talkToParty", talkToParty}, + {"talkToServer", talkToServer}, + {"BoundRandWalk", BoundRandWalk}, + {"ToAroundChar", ToAroundChar}, +#ifdef _ALLBLUES_LUA_1_1 + {"Walk", Walk}, + {"WalkPoint", WalkPoint}, + {"WarpToSpecificPoint", WarpToSpecificPoint}, + {"MapAllWarp", MapAllWarp}, + {"RandRandWalk", RandRandWalk}, +#endif +#ifdef _ALLBLUES_LUA_1_3 + {"createPet", createPet}, + {"setCharPet", setCharPet}, + {"getCharPet", getCharPet}, + {"DelItem", DelItem}, + {"getFd", getFd}, + {"Updata", Updata}, + {"Additem", Additem}, + {"AddPet", AddPet}, + {"Finditem", Finditem}, +#ifdef _PLAYER_NPC + {"setPlayerNpc", setPlayerNpc}, +#endif + {"Coordinate", Coordinate}, + {"setPetSkill", setPetSkill}, + {"getPetSkill", getPetSkill}, + {"PetLevelUp", PetLevelUp}, + {"JoinParty", JoinParty}, +#endif +#ifdef _ALLBLUES_LUA_1_4 + {"getLiftTo8", getLiftTo8}, + {"getRightTo8", getRightTo8}, + {"complianceParameter", complianceParameter}, + {"sendStatusString", sendStatusString}, + {"sendBattleEffect", sendBattleEffect}, + {"dropPetAbsolute", dropPetAbsolute}, + {"AddPetCf", AddPetCf}, + {"sendWatchEvent", sendWatchEvent}, + {"AllWarpToSpecificPoint",AllWarpToSpecificPoint}, + {"Findpet", Findpet}, + {"DelPet", DelPet}, + {"FindPetFormEnemyTempID",FindPetFormEnemyTempID}, + {"FindPetFormMatemo", FindPetFormMatemo}, +#endif +#ifdef _PETSKILL_SHOP_LUA + {"FreePetSkill", FreePetSkill}, +#endif +#ifdef _ALLBLUES_LUA_1_7 + {"findEmptyPetBox", findEmptyPetBox}, + {"findEmptyItemBox", findEmptyItemBox}, + {"dropPetFollow", dropPetFollow}, + {"getItemIndex", getItemIndex}, + {"charSaveFromConnect", charSaveFromConnect}, + {"DischargeParty", DischargeParty}, + {"Skillupsend", Skillupsend}, +#ifdef _RECORD_IP + {"userip", userip}, +#endif +#endif +#ifdef _ALLBLUES_LUA_1_9 + {"logou", logou}, +#endif +#ifdef _ALLBLUES_LUA_2_0 + {"Encounter", Encounter}, + {"GetOldLevelExp", GetOldLevelExp}, +#endif +#ifdef _AutoBattle_LUA + {"gcgc", gcgc}, +#endif +#ifdef _FIX_PLAYER_NPC_PET + {"DelNpcPetByIndex", DelNpcPetByIndex}, +#endif + {NULL, NULL} +}; + +LUALIB_API int luaopen_Char (lua_State *L) { + luaL_register(L, "char", charlib); + return 1; +} + +#endif diff --git a/mylua/configbase.c b/mylua/configbase.c new file mode 100644 index 0000000..b0cd8bc --- /dev/null +++ b/mylua/configbase.c @@ -0,0 +1,82 @@ +#include +#include +#include +#include "char.h" +#include "char_base.h" +#include "mylua/base.h" +#include "mylua/mylua.h" +#include "lua.h" +#include "lauxlib.h" +#include "lualib.h" +#include "configfile.h" + +#ifdef _ALLBLUES_LUA + +#ifdef _ALLBLUES_LUA_1_1 +static int set(lua_State *L) +{ + size_t l; + char *data=luaL_checklstring(L, 1, &l); + luareadconfigfile(data); + return 1; +} + +static int checkIp(lua_State *L) +{ + int ip = luaL_checkint(L, 1); + + lua_pushinteger(L, checkServerIp(ip)); + return 1; +} + +static int config_getBattleexp(lua_State *_NLL) +{ + LRetInt(_NLL, getBattleexp()); +} + +#ifdef _ALLBLUES_LUA_2_0 +static int ABLUA_getGameservername(lua_State *L) +{ + char* name = getGameservername(); + lua_pushstring(L, name); + return 1; +} + +static int ABLUAgetFdnum(lua_State *L) +{ + int playnum = getFdnum(); + lua_pushinteger(L, playnum); + return 1; +} +#endif + +#ifdef _FM_EXP_ADD +static int getfmexp(lua_State *L) +{ + lua_pushinteger(L, getFmAddExp()); + return 1; +} +#endif + +static const luaL_Reg configlib[] = { + {"set", set}, + {"checkIp", checkIp}, + {"getBattleexp", config_getBattleexp}, +#ifdef _FM_EXP_ADD + {"getFmExp", getfmexp}, +#endif +#ifdef _ALLBLUES_LUA_2_0 + {"getGameservername", ABLUA_getGameservername}, + {"getFdnum", ABLUAgetFdnum}, +#endif + {NULL, NULL} +}; + +LUALIB_API int luaopen_Config (lua_State *L) { + luaL_register(L, "config", configlib); + return 1; +} +#endif + +#endif + diff --git a/mylua/enemytempbase.c b/mylua/enemytempbase.c new file mode 100644 index 0000000..4a29d95 --- /dev/null +++ b/mylua/enemytempbase.c @@ -0,0 +1,156 @@ +#include +#include +#include "char.h" +#include "readmap.h" +#include "map_deal.h" +#include "char_base.h" +#include "enemy.h" +#include "mylua/base.h" +#include "lua.h" +#include "lauxlib.h" +#include "lualib.h" +#include "lssproto_serv.h" + +#ifdef _ALLBLUES_LUA +#ifdef _ALLBLUES_LUA_1_4 + +static CharBase EnemytempBaseInt[] = { + {{""}, E_T_TEMPNO} + ,{{"ʼֵ"}, E_T_INITNUM} + ,{{"ɳ"}, E_T_LVUPPOINT} + ,{{""}, E_T_BASEVITAL} + ,{{""}, E_T_BASESTR} + ,{{""}, E_T_BASETGH} + ,{{"ٶ"}, E_T_BASEDEX} + ,{{""}, E_T_MODAI} + ,{{""}, E_T_GET} + ,{{""}, E_T_EARTHAT} + ,{{"ˮ"}, E_T_WATERAT} + ,{{""}, E_T_FIREAT} + ,{{""}, E_T_WINDAT} + ,{{""}, E_T_POISON} + ,{{"鿹"}, E_T_PARALYSIS} + ,{{"˯"}, E_T_SLEEP} + ,{{"ʯ"}, E_T_STONE} + ,{{"ƿ"}, E_T_DRUNK} + ,{{"쿹"}, E_T_CONFUSION} + ,{{"1"}, E_T_PETSKILL1} + ,{{"2"}, E_T_PETSKILL2} + ,{{"3"}, E_T_PETSKILL3} + ,{{"4"}, E_T_PETSKILL4} + ,{{"5"}, E_T_PETSKILL5} + ,{{"6"}, E_T_PETSKILL6} + ,{{"7"}, E_T_PETSKILL7} + ,{{""}, E_T_RARE} + ,{{""}, E_T_CRITICAL} + ,{{""}, E_T_COUNTER} + ,{{""}, E_T_SLOT} + ,{{""}, E_T_IMGNUMBER} + ,{{"ȼ"}, E_T_LIMITLEVEL} +}; + +static CharBase EnemytempBaseChar[] = { + {{""}, E_T_NAME} +}; + +static int getInt (lua_State *L) +{ + const int array = luaL_checkint(L, 1); + const int element = getCharBaseValue(L, 2, EnemytempBaseInt, arraysizeof(EnemytempBaseInt)); + lua_pushinteger(L, ENEMYTEMP_getInt(array, element)); + return 1; +} + +static int getChar (lua_State *L) +{ + const int array = luaL_checkint(L, 1); + const int element = getCharBaseValue(L, 2, EnemytempBaseChar, arraysizeof(EnemytempBaseChar)); + lua_pushstring(L, ENEMYTEMP_getChar(array, element)); + return 1; +} + +static int getEnemyTempArray(lua_State *L) +{ + const int enemyid = luaL_checkint(L, 1); + lua_pushinteger(L, ENEMYTEMP_getEnemyTempArray(enemyid)); + return 1; +} + + +static int getEnemyTempArrayFromTempNo(lua_State *L) +{ + const int array = luaL_checkint(L, 1); + lua_pushinteger(L, ENEMYTEMP_getEnemyTempArrayFromTempNo(array)); + return 1; +} + +static int getEnemyTempArrayFromInitnum(lua_State *L) +{ + const int array = luaL_checkint(L, 1); + lua_pushinteger(L, ENEMYTEMP_getEnemyTempArrayFromInitnum(array)); + return 1; +} + +static int getEnemyTempNameFromEnemyID(lua_State *L) +{ + const int enemyid = luaL_checkint(L, 1); + int i; + for( i = 0; i < ENEMY_getEnemyNum(); i ++ ) { + if( ENEMY_getInt( i, ENEMY_ID) == enemyid) { + break; + } + } + if( i == ENEMY_getEnemyNum() ){ + lua_pushstring(L, ""); + return 1; + } + int tarray = ENEMYTEMP_getEnemyTempArray( i ); + + if( !ENEMYTEMP_CHECKINDEX( tarray)) { + lua_pushstring(L, ""); + }else{ + lua_pushstring(L, ENEMYTEMP_getChar(tarray, E_T_NAME)); + } + return 1; +} + + +static int getEnemyTempIDFromEnemyID(lua_State *L) +{ + const int enemyid = luaL_checkint(L, 1); + int i; + for( i = 0; i < ENEMY_getEnemyNum(); i ++ ) { + if( ENEMY_getInt( i, ENEMY_ID) == enemyid) { + break; + } + } + if( i == ENEMY_getEnemyNum() ){ + lua_pushinteger(L, -1); + return 1; + } + lua_pushinteger(L, ENEMY_getInt( i, ENEMY_TEMPNO)); + return 1; +} + + + + +static const luaL_Reg enemytemplib[] = { + {"getInt", getInt}, + {"getChar", getChar}, + {"getEnemyTempArray", getEnemyTempArray}, + {"getEnemyTempArrayFromTempNo", getEnemyTempArrayFromTempNo}, + {"getEnemyTempArrayFromInitnum", getEnemyTempArrayFromInitnum}, + {"getEnemyTempNameFromEnemyID", getEnemyTempNameFromEnemyID}, + {"getEnemyTempIDFromEnemyID", getEnemyTempIDFromEnemyID}, + {NULL, NULL} +}; + +LUALIB_API int luaopen_Enemytemp (lua_State *L) { + luaL_register(L, "enemytemp", enemytemplib); + return 1; +} +#endif + +#endif + diff --git a/mylua/family.c b/mylua/family.c new file mode 100644 index 0000000..f6b2175 --- /dev/null +++ b/mylua/family.c @@ -0,0 +1,39 @@ +#include +#include "char.h" +#include "char_base.h" +#include "family.h" +#include "mylua/base.h" +#include "lua.h" +#include "lauxlib.h" +#include "lualib.h" +#include "saacproto_cli.h" + +#ifdef _ALLBLUES_LUA + +extern char familyListBuf[MAXFAMILYLIST]; + +static int ShowFamilyList(lua_State *L) +{ + size_t l; + const int index = luaL_checkint(L, 1); + char subbuf[256]; + if( getStringFromIndexWithDelim( familyListBuf, "|", index, subbuf, sizeof(subbuf) ) == TRUE){ + lua_pushstring(L, subbuf); + }else{ + lua_pushstring(L, ""); + } + return 1; +} + +static const luaL_Reg Familylib[] = { + {"ShowFamilyList", ShowFamilyList}, + {NULL, NULL} +}; + +LUALIB_API int luaopen_Family (lua_State *L) { + luaL_register(L, "family", Familylib); + return 1; +} + +#endif + diff --git a/mylua/function.c b/mylua/function.c new file mode 100644 index 0000000..bab7692 --- /dev/null +++ b/mylua/function.c @@ -0,0 +1,1177 @@ +#include +#include "common.h" +#include "char_base.h" +#include "item.h" +#include "configfile.h" +#include "battle.h" +#include "mylua/base.h" +#include "version.h" +#include "lua.h" +#include "lauxlib.h" +#include "lualib.h" +#include "mylua/mylua.h" +#include "mylua/function.h" +#include "char.h" + + +#ifdef _ALLBLUES_LUA +extern MY_Lua MYLua; + +//lua_State *M_Script_Lua = NULL; //ʵ + +lua_State *FindLua(char *filename) +{ + MY_Lua *mylua = &MYLua; + char newfilename[256]; + while(mylua->next != NULL){ + if(strcmptail( mylua->luapath, ".allblues" ) == 0 ){ + sprintf(newfilename, "%s.allblues", filename); + }else{ + sprintf(newfilename, "%s", filename); + } + + if(strcmp(newfilename, mylua->luapath) == 0){ + return mylua->lua; + } + mylua = mylua->next; + } + + return NULL; +} + +#ifdef _ALLBLUES_LUA_1_9 +BOOL EquipEffectFunction( int charaindex, int id ) +{ + static lua_State *lua; + + if (lua == NULL){ + lua = FindLua("data/ablua/equipeffectfunction.lua"); + if (lua == NULL)return TRUE; + } + + lua_getglobal(lua, "EquipEffectFunction"); + + if (!lua_isfunction(lua, -1)) { + lua_pop(lua, 1); + return TRUE; + } + + //η + lua_pushnumber(lua,charaindex); + lua_pushnumber(lua,id); + + if (lua_pcall(lua, 2, 1, 0) != 0) + error(lua, "error running function `f': %s", lua_tostring(lua, -1)); + + if (!lua_isnumber(lua, -1)) + error(lua, "function `f' must return a number"); + + int ret = lua_tonumber(lua, -1); + lua_pop(lua, 1); + return ret; +} + +BOOL WalkFunction( int charaindex ) +{ + MY_Lua *mylua = &MYLua; + while(mylua->lua != NULL){ + lua_getglobal(mylua->lua, "WalkFunction"); + + if (!lua_isfunction(mylua->lua, -1)) { + lua_pop(mylua->lua, 1); + mylua = mylua->next; + continue; + } + + lua_pushnumber(mylua->lua,charaindex); + + if (lua_pcall(mylua->lua, 1, 1, 0) != 0) + error(mylua->lua, "error running function `f': %s", lua_tostring(mylua->lua, -1)); + + if (!lua_isnumber(mylua->lua, -1)) + error(mylua->lua, "function `f' must return a number"); + + int ret = lua_tonumber(mylua->lua, -1); + lua_pop(mylua->lua, 1); + if(ret == TRUE){ + return TRUE; + } + + mylua = mylua->next; + } + + return FALSE; +} +#ifdef _ITEM_OVER_LAP +BOOL ItemOverlapFunction( int charindex, int fromitemindex, int toitemindex ) +{ + MY_Lua *mylua = &MYLua; + while(mylua->lua != NULL){ + lua_getglobal(mylua->lua, "ItemOverlapFunction"); + + if (!lua_isfunction(mylua->lua, -1)) { + lua_pop(mylua->lua, 1); + mylua = mylua->next; + continue; + } + //η + lua_pushnumber(mylua->lua,charindex); + lua_pushnumber(mylua->lua,fromitemindex); + lua_pushnumber(mylua->lua,toitemindex); + + lua_pcall(mylua->lua, 3, 1, 0); + + lua_isnumber(mylua->lua, -1); + + int ret = lua_tonumber(mylua->lua, -1); + lua_pop(mylua->lua, 1); + if(ret == 1){ + mylua = mylua->next; + continue; + } + return ret; + } + + return TRUE; +} + +BOOL ItemOverlapedFunction( int charindex, int fromitemindex, int fromid, int toitemindex, int toid) +{ + MY_Lua *mylua = &MYLua; + while(mylua->lua != NULL){ + lua_getglobal(mylua->lua, "ItemOverlapedFunction"); + + if (!lua_isfunction(mylua->lua, -1)) { + lua_pop(mylua->lua, 1); + mylua = mylua->next; + continue; + } + //η + lua_pushnumber(mylua->lua,charindex); + lua_pushnumber(mylua->lua,fromitemindex); + lua_pushnumber(mylua->lua,fromid); + lua_pushnumber(mylua->lua,toitemindex); + lua_pushnumber(mylua->lua,toid); + + docall(mylua->lua, 5, 1); + mylua = mylua->next; + } + + return TRUE; +} +#endif + +BOOL BattleFinishFunction( int charaindex, int battletime, int battleturn, int battletype ) +{ + static lua_State *lua; + + if (lua == NULL){ + lua = FindLua("data/ablua/battlefinishfunction.lua"); + if (lua == NULL)return TRUE; + } + + lua_getglobal(lua, "BattleFinishFunction"); + + if (!lua_isfunction(lua, -1)) { + lua_pop(lua, 1); + return TRUE; + } + + //η + lua_pushnumber(lua,charaindex); + lua_pushnumber(lua,battletime); + lua_pushnumber(lua,battleturn); + lua_pushnumber(lua,battletype); + + docall(lua, 4, 1); + + return TRUE; +} + +BOOL SetBattleEnmeyFunction(int meindex, int enemyindex, int id ) +{ + lua_State *lua = CHAR_getLUAFunction(meindex, CHAR_BATTLESETFUNC); + if ( lua == NULL) { + return FALSE; + } + + //η + lua_pushnumber(lua, meindex); + lua_pushnumber(lua, enemyindex); + lua_pushnumber(lua, id); + docall(lua, 3, 1); + + return TRUE; +} + +#endif + +#ifdef _ALLBLUES_LUA_1_8 +BOOL CaptureOkFunction( int attackindex, int defindex ) +{ + MY_Lua *mylua = &MYLua; + while(mylua->lua != NULL){ + lua_getglobal(mylua->lua, "CaptureOkFunction"); + + if (!lua_isfunction(mylua->lua, -1)) { + lua_pop(mylua->lua, 1); + mylua = mylua->next; + continue; + } + //η + lua_pushnumber(mylua->lua,attackindex); + lua_pushnumber(mylua->lua,defindex); + + docall(mylua->lua, 2, 1); + mylua = mylua->next; + } + + return TRUE; +} + +BOOL CaptureCheckFunction( int attackindex, int defindex ) +{ + static lua_State *lua; + + if (lua == NULL){ + lua = FindLua("data/ablua/capturefunction.lua"); + if (lua == NULL)return TRUE; + } + + lua_getglobal(lua, "CaptureCheckFunction"); + + if (!lua_isfunction(lua, -1)) { + lua_pop(lua, 1); + return TRUE; + } + + //η + lua_pushnumber(lua,attackindex); + lua_pushnumber(lua,defindex); + + if (lua_pcall(lua, 2, 1, 0) != 0) + error(lua, "error running function `f': %s", lua_tostring(lua, -1)); + + if (!lua_isnumber(lua, -1)) + error(lua, "function `f' must return a number"); + + int ret = lua_tonumber(lua, -1); + lua_pop(lua, 1); + return ret; +} +#endif + +#ifdef _ALLBLUES_LUA_1_7 +BOOL CharVsEnemyFunction( int charaindex ) +{ + MY_Lua *mylua = &MYLua; + while(mylua->lua != NULL){ + lua_getglobal(mylua->lua, "CharVsEnemyFunction"); + + if (!lua_isfunction(mylua->lua, -1)) { + lua_pop(mylua->lua, 1); + mylua = mylua->next; + continue; + } + + lua_pushnumber(mylua->lua,charaindex); + + if (lua_pcall(mylua->lua, 1, 1, 0) != 0) + error(mylua->lua, "error running function `f': %s", lua_tostring(mylua->lua, -1)); + + if (!lua_isnumber(mylua->lua, -1)) + error(mylua->lua, "function `f' must return a number"); + + int ret = lua_tonumber(mylua->lua, -1); + lua_pop(mylua->lua, 1); + if(ret == TRUE){ + return TRUE; + } + + mylua = mylua->next; + } + + return FALSE; +} +#endif + +#ifdef _ALLBLUES_LUA_1_6 +BOOL CharTalkFunction( int charaindex, char *message, int color ) +{ + static lua_State *lua; + + if (lua == NULL){ + lua = FindLua("data/ablua/chartalkfunction.lua"); + if (lua == NULL)return FALSE; + } + + lua_getglobal(lua, "CharTalkFunction"); + + if (!lua_isfunction(lua, -1)) { + lua_pop(lua, 1); + return FALSE; + } + + //η + lua_pushnumber(lua,charaindex); + lua_pushstring(lua,message); + lua_pushnumber(lua,color); + + if (lua_pcall(lua, 3, 1, 0) != 0) + error(lua, "error running function `f': %s", lua_tostring(lua, -1)); + + if (!lua_isnumber(lua, -1)) + error(lua, "function `f' must return a number"); + + int ret = lua_tonumber(lua, -1); + lua_pop(lua, 1); + return ret; +} + +BOOL FamilyRideFunction( int meindex, int petindex, int petid ) +{ + static lua_State *lua; + + if (lua == NULL){ + lua = FindLua("data/ablua/familyridefunction.lua"); + if (lua == NULL)return FALSE; + } + + lua_getglobal(lua, "FamilyRideFunction"); + + if (!lua_isfunction(lua, -1)) { + lua_pop(lua, 1); + return FALSE; + } + + //η + lua_pushnumber(lua,meindex); + lua_pushnumber(lua,petindex); + lua_pushnumber(lua,petid); + + if (lua_pcall(lua, 3, 1, 0) != 0) + error(lua, "error running function `f': %s", lua_tostring(lua, -1)); + + if (!lua_isnumber(lua, -1)) + error(lua, "function `f' must return a number"); + + int ret = lua_tonumber(lua, -1); + lua_pop(lua, 1); + return ret; +} +#endif + +#ifdef _ALLBLUES_LUA_1_5 +BOOL NetLoopFunction( void ) +{ + MY_Lua *mylua = &MYLua; + while(mylua->lua != NULL){ + lua_getglobal(mylua->lua, "NetLoopFunction"); + + if (!lua_isfunction(mylua->lua, -1)) { + lua_pop(mylua->lua, 1); + mylua = mylua->next; + continue; + } + docall(mylua->lua, 0, 1); + mylua = mylua->next; + } + + return TRUE; +} + +BOOL FreeCharCreate( int charaindex ) +{ + static lua_State *lua; + + + if (lua == NULL){ + lua = FindLua("data/ablua/freecharcreate.lua"); + if (lua == NULL)return FALSE; + } + + lua_getglobal(lua, "FreeCharCreate"); + + if (!lua_isfunction(lua, -1)) { + lua_pop(lua, 1); + return FALSE; + } + //η + lua_pushnumber(lua,charaindex); + + docall(lua, 1, 1); + + return TRUE; +} + +BOOL FreeCharLogin( int charaindex ) +{ + static lua_State *lua; + + + if (lua == NULL){ + lua = FindLua("data/ablua/freecharlogin.lua"); + if (lua == NULL)return FALSE; + } + + lua_getglobal(lua, "FreeCharLogin"); + + if (!lua_isfunction(lua, -1)) { + lua_pop(lua, 1); + return FALSE; + } + //η + lua_pushnumber(lua,charaindex); + + docall(lua, 1, 1); + + return TRUE; +} + + +BOOL FreeVsPlayer( int charaindex, int toindex ) +{ + static lua_State *lua; + + if (lua == NULL){ + lua = FindLua("data/ablua/freevsplayer.lua"); + if (lua == NULL)return FALSE; + } + + lua_getglobal(lua, "FreeVsPlayer"); + + if (!lua_isfunction(lua, -1)) { + lua_pop(lua, 1); + return FALSE; + } + //η + lua_pushnumber(lua,charaindex); + lua_pushnumber(lua,toindex); + + if (lua_pcall(lua, 2, 1, 0) != 0) + error(lua, "error running function `f': %s", lua_tostring(lua, -1)); + + if (!lua_isnumber(lua, -1)) + error(lua, "function `f' must return a number"); + + int ret = lua_tonumber(lua, -1); + lua_pop(lua, 1); + return ret; +} + +BOOL FreePartyJoin( int charaindex, int toindex ) +{ + MY_Lua *mylua = &MYLua; + while(mylua->lua != NULL){ + lua_getglobal(mylua->lua, "FreePartyJoin"); + + if (!lua_isfunction(mylua->lua, -1)) { + lua_pop(mylua->lua, 1); + mylua = mylua->next; + continue; + } + //η + lua_pushnumber(mylua->lua,charaindex); + lua_pushnumber(mylua->lua,toindex); + + if (lua_pcall(mylua->lua, 2, 1, 0) != 0) + error(mylua->lua, "error running function `f': %s", lua_tostring(mylua->lua, -1)); + + + if (!lua_isnumber(mylua->lua, -1)) + error(mylua->lua, "function `f' must return a number"); + + int ret = lua_tonumber(mylua->lua, -1); + lua_pop(mylua->lua, 1); + if(ret == FALSE){ + return FALSE; + } + + mylua = mylua->next; + } + + return TRUE; +} +#endif + +#ifdef _ALLBLUES_LUA_1_4 + +BOOL RunCharLogOutEvent( int charaindex) +{ + lua_State *lua = CHAR_getLUAFunction(charaindex, CHAR_LOGINOUTFUNC); + if ( lua == NULL) { + return FALSE; + } + + //η + lua_pushnumber(lua, charaindex); + + docall(lua, 1, 1); + + return TRUE; +} + +BOOL BattleFinish( int battleindex, int charaindex) +{ + lua_State *lua = BATTLE_getLUAFunction(battleindex, BATTLE_FINISH); + if ( lua == NULL) { + return FALSE; + } + + //η + lua_pushnumber(lua, charaindex); + + docall(lua, 1, 1); + + return TRUE; +} + +BOOL BattleEscape( int battleindex, int charaindex) +{ + lua_State *lua = BATTLE_getLUAFunction(battleindex, BATTLE_ESCAPE); + if ( lua == NULL) { + return FALSE; + } + + //η + lua_pushnumber(lua, charaindex); + + docall(lua, 1, 1); + + return TRUE; +} +#endif +/* +#ifdef _OFFLINE_SYSTEM +BOOL OffLineCommand( int battleindex, int charaindex, int side) +{ + static lua_State *lua; + + if (lua == NULL){ + lua = FindLua("data/ablua/offlinecommand.lua"); + if (lua == NULL)return FALSE; + } + + lua_getglobal(lua, "OffLineCommand"); + + if (!lua_isfunction(lua, -1)) { + lua_pop(lua, 1); + return TRUE; + } + //η + lua_pushnumber(lua,battleindex); + lua_pushnumber(lua,charaindex); + lua_pushnumber(lua,side); + + docall(lua, 3, 1); + + return TRUE; +} +#endif +*/ +#ifdef _PETSKILL_SHOP_LUA +BOOL FreePetSkillShop( int talkerindex, int petindex, int oldSkillID, int newSkillID) +{ + static lua_State *lua; + + if (lua == NULL){ + lua = FindLua("data/ablua/freepetskillshop.lua"); + if (lua == NULL)return TRUE; + } + + lua_getglobal(lua, "FreePetSkillShop"); + + if (!lua_isfunction(lua, -1)) { + return TRUE; + } + //η + lua_pushnumber(lua,talkerindex); + lua_pushnumber(lua,petindex); + lua_pushnumber(lua,oldSkillID); + lua_pushnumber(lua,newSkillID); + + if (lua_pcall(lua, 4, 1, 0) != 0) + error(lua, "error running function `f': %s", lua_tostring(lua, -1)); + + if (!lua_isnumber(lua, -1)) + error(lua, "function `f' must return a number"); + + int ret = lua_tonumber(lua, -1); + lua_pop(lua, 1); + return ret; +} +#endif + +#ifdef _ALLBLUES_LUA_1_2 +BOOL RunUseChatMagic( int charaindex, char *data, lua_State *lua) +{ + if(lua == NULL)return FALSE; + + //η + lua_pushnumber(lua, charaindex); + lua_pushstring(lua, data); + + docall(lua, 2, 1); + + return TRUE; +} + + +BOOL RunItemUseEvent( int itemindex, int charaindex, int toindex, int haveitemindex ) +{ + lua_State *lua = ITEM_getLUAFunction(itemindex, ITEM_USEFUNC); + if ( lua == NULL) { + return FALSE; + } + + //ηĸ + lua_pushnumber(lua, itemindex); + lua_pushnumber(lua, charaindex); + lua_pushnumber(lua, toindex); + lua_pushnumber(lua, haveitemindex); + + docall(lua, 4, 1); + + return TRUE; +} + +BOOL RunItemDieReLifeEvent( int charaindex, int itemindex, int haveitemindex ) +{ + lua_State *lua = ITEM_getLUAFunction(itemindex, ITEM_DIERELIFEFUNC); + if ( lua == NULL) { + return FALSE; + } + + //η + lua_pushnumber(lua, charaindex); + lua_pushnumber(lua, itemindex); + lua_pushnumber(lua, haveitemindex); + + docall(lua, 3, 1); + + return TRUE; +} + +BOOL RunItemDetachEvent( int charaindex, int itemindex ) +{ + lua_State *lua = ITEM_getLUAFunction(itemindex, ITEM_DETACHFUNC); + if ( lua == NULL) { + return FALSE; + } + + //η + lua_pushnumber(lua, charaindex); + lua_pushnumber(lua, itemindex); + + docall(lua, 2, 1); + + return TRUE; +} + +BOOL RunItemAttachEvent( int charaindex, int itemindex ) +{ + lua_State *lua = ITEM_getLUAFunction(itemindex, ITEM_ATTACHFUNC); + if ( lua == NULL) { + return FALSE; + } + + //η + lua_pushnumber(lua, charaindex); + lua_pushnumber(lua, itemindex); + + docall(lua, 2, 1); + + return TRUE; +} + +BOOL RunItemPickupEvent( int charaindex, int itemindex ) +{ + lua_State *lua = ITEM_getLUAFunction(itemindex, ITEM_PICKUPFUNC); + if ( lua == NULL) { + return FALSE; + } + + //η + lua_pushnumber(lua, charaindex); + lua_pushnumber(lua, itemindex); + + docall(lua, 2, 1); + + return TRUE; +} + +BOOL RunItemPostOverEvent( int itemindex, int charaindex ) +{ + lua_State *lua = ITEM_getLUAFunction(itemindex, ITEM_POSTOVERFUNC); + if ( lua == NULL) { + return FALSE; + } + //η + lua_pushnumber(lua, charaindex); + lua_pushnumber(lua, itemindex); + + docall(lua, 2, 1); + + return TRUE; +} + +BOOL RunItemPreOverEvent( int itemindex, int charaindex ) +{ + lua_State *lua = ITEM_getLUAFunction(itemindex, ITEM_PREOVERFUNC); + if ( lua == NULL) { + return FALSE; + } + //η + lua_pushnumber(lua, charaindex); + lua_pushnumber(lua, itemindex); + + docall(lua, 2, 1); + + return TRUE; +} + +BOOL RunItemDropEvent( int charaindex, int itemindex ) +{ + lua_State *lua = ITEM_getLUAFunction(itemindex, ITEM_DROPFUNC); + if ( lua == NULL) { + return FALSE; + } + + //η + lua_pushnumber(lua, charaindex); + lua_pushnumber(lua, itemindex); + + docall(lua, 2, 1); + + return TRUE; +} + +#endif + + +BOOL RunCharTalkedEvent(int meindex, int toindex, char *messageeraseescape, int color, int channel) +{ + lua_State *lua = CHAR_getLUAFunction(meindex, CHAR_TALKEDFUNC); + if ( lua == NULL) { + return FALSE; + } + + //η + lua_pushnumber(lua,meindex); + lua_pushnumber(lua,toindex); + lua_pushstring(lua,messageeraseescape); + lua_pushnumber(lua,color); + lua_pushnumber(lua,channel); + + docall(lua, 5, 1); + + return TRUE; +} + + +BOOL RunCharLoopEvent(int meindex) +{ + lua_State *lua = CHAR_getLUAFunction(meindex, CHAR_LOOPFUNC); + if ( lua == NULL) { + return FALSE; + } + + //ηһ + lua_pushnumber(lua,meindex); + docall(lua, 1, 1); + + return TRUE; +} + +BOOL RunCharOverlapEvent( int meindex, int toindex) +{ + lua_State *lua = CHAR_getLUAFunction(meindex, CHAR_OVERLAPEDFUNC); + if ( lua == NULL) { + return FALSE; + } + + //η + lua_pushnumber(lua, meindex); + lua_pushnumber(lua, toindex); + docall(lua, 2, 1); + + return TRUE; +} + +BOOL RunCharBattleOverEvent( int meindex, int battleindex, int iswin) +{ + lua_State *lua = CHAR_getLUAFunction(meindex, CHAR_BATTLEOVERDFUNC); + if ( lua == NULL) { + return FALSE; + } + + //η + lua_pushnumber(lua, meindex); + lua_pushnumber(lua, battleindex); + lua_pushnumber(lua, iswin); + docall(lua, 3, 1); + + return TRUE; +} + +BOOL RunCharWindowTalked( int meindex, int talkerindex, int seqno, int select, char *data) +{ + lua_State *lua = CHAR_getLUAFunction(meindex, CHAR_WINDOWTALKEDFUNC); + if ( lua == NULL) { + return FALSE; + } + + //η + lua_pushnumber(lua, meindex); + lua_pushnumber(lua, talkerindex); + lua_pushnumber(lua, seqno); + lua_pushnumber(lua, select); + lua_pushstring(lua, data); + + docall(lua, 5, 1); + + return TRUE; +} + +BOOL fameButton( int index) +{ + static lua_State *lua; + + if (lua == NULL){ + lua = FindLua("data/ablua/fameButton.lua"); + if (lua == NULL)return FALSE; + } + + lua_getglobal(lua, "fameButton"); + + if (!lua_isfunction(lua, -1)) { + lua_pop(lua, 1); + return FALSE; + } + //η1 + lua_pushnumber(lua,index); + + if (lua_pcall(lua, 1, 1, 0) != 0) + error(lua, "error running function `f': %s", lua_tostring(lua, -1)); + + BOOL ret = (BOOL)lua_toboolean(lua, -1); + lua_pop(lua, 1); + return ret; + +} + +#ifdef _ALLBLUES_LUA_2_0 + +BOOL FreeModeExp(int charaindex, int exp ) +{ + //printf("exp1 = %d \n",exp); + static lua_State *lua; + if (lua == NULL){ + lua = FindLua("data/ablua/freemodeexp.lua"); + if (lua == NULL)return FALSE; + } + lua_getglobal(lua, "FreeModeExp"); + + if (!lua_isfunction(lua, -1)) { + lua_pop(lua, 1); + return TRUE; + } + int TM_Ret = 0; + + lua_pushnumber(lua,charaindex); + lua_pushinteger(lua, (lua_Integer)exp); + + TM_Ret = lua_pcall(lua, 2, 0, 0); + if(TM_Ret != 0) + { + print("FreeCharExpSave Lua Err :%d(%s)\n", TM_Ret, lua_tostring(lua, -1)); + lua_pop(lua, 1); + + exp = &TM_Ret; + return exp; + + } +} + +/* +BOOL FreeModeExp(int charaindex,int* addexp, int getexp, int modexp ) +{ + static lua_State *lua; + if (lua == NULL){ + lua = FindLua("data/ablua/freemodeexp.lua"); + if (lua == NULL)return FALSE; + } + + lua_getglobal(lua, "FreeModeExp"); + + if (!lua_isfunction(lua, -1)) { + lua_pop(lua, 1); + return TRUE; + } + lua_pushnumber(lua,charaindex); + lua_pushnumber(lua,getexp); + lua_pushnumber(lua,modexp); + + if (lua_pcall(lua, 3, 1, 0) != 0) + error(lua, "error running function `f': %s", lua_tostring(lua, -1)); + + if (!lua_isnumber(lua, -1)) + error(lua, "function `f' must return a number"); + + int ret = -1; + ret = lua_tonumber(lua, -1); + + lua_pop(lua, 1); + if(ret == -1 || ret == 0 ) return FALSE; + else{ + addexp = &ret; + return TRUE; + } +} +*/ +/*BOOL FreeLoginCheck(int fd) +{ + static lua_State *lua; + if (lua == NULL){ + lua = FindLua("data/ablua/freelogincheck.lua"); + if (lua == NULL)return FALSE; + } + + lua_getglobal(lua, "FreeLoginCheck"); + + if (!lua_isfunction(lua, -1)) { + lua_pop(lua, 1); + return FALSE; + } + lua_pushnumber(lua,fd); + + if (lua_pcall(lua, 1, 1, 0) != 0) + error(lua, "error running function `f': %s", lua_tostring(lua, -1)); + + BOOL ret = (BOOL)lua_toboolean(lua, -1); + lua_pop(lua, 1); + return ret; +} +*/ + +#ifdef _CAX_ESC_REPORT +void report1( int charaindex ){ + int fd,itemindex,emptyitemindexinchara,count,countReport = 0,i; + char token[256]; + if( (fd = getfdFromCharaIndex( charaindex)) == -1 ) return; + if(CHAR_getInt(charaindex,CHAR_TRANSMIGRATION) < getReportTa() || + (CHAR_getInt(charaindex,CHAR_TRANSMIGRATION) >= getReportTa() && CHAR_getInt(charaindex,CHAR_LV) < getReportLv())){ + sprintf( token, "\n\n\n ÿǩֻ%dת%dϵҿš", getReportTa(),getReportLv()); + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE,WINDOW_BUTTONTYPE_OK,-1,-1,token); + return; + } + //жǷǩ + int day; + time_t t; + struct tm *local; + t=time(NULL); + local=localtime(&t); + day = (local->tm_year+1900) * 10000 + (local->tm_mon+1) * 100 + local->tm_mday; + if(CHAR_getInt(charaindex,CHAR_REPORT) == day){//Ѿǩ + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE,WINDOW_BUTTONTYPE_OK,-1,-1,"\n\n\n Ѿǩˣ"); + return; + } + + //========ͨǩ========= + if(CHAR_getInt( charaindex , CHAR_VIPRIDE)== 0){ + //ұո + count = CHAR_findSurplusItemBox( charaindex ); + //Ʒ + for (i = 0; i < 10; i++) { + if(getReportItem(i) !=-1){ + countReport++; + } + } + if(count < countReport){ + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE,WINDOW_BUTTONTYPE_OK,-1,-1,"\n\n\n ռλ㡣"); + return; + } + for (i = 0; i < 10; i++) { + if(getReportItem(i) !=-1){ + #ifdef _ITEM_UP + itemindex = ITEM_makeItemAndRegist( getReportItem(i) , charaindex);//ȡһ + #else + itemindex = ITEM_makeItemAndRegist( getReportItem(i) );//ȡһ + #endif + if( itemindex != -1 ){ + emptyitemindexinchara = CHAR_findEmptyItemBox( charaindex );//ȡռ + if( emptyitemindexinchara < 0 ){ + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE,WINDOW_BUTTONTYPE_OK,-1,-1,"\n\n\n ռλ㡣"); + return; + } + CHAR_setItemIndex(charaindex, emptyitemindexinchara, itemindex ); + ITEM_setWorkInt(itemindex, ITEM_WORKOBJINDEX,-1); + ITEM_setWorkInt(itemindex, ITEM_WORKCHARAINDEX,charaindex); + CHAR_sendItemDataOne( charaindex, emptyitemindexinchara); + sprintf( token, "%s", ITEM_getChar( itemindex, ITEM_NAME)); + CHAR_talkToCli( charaindex, -1, token, CHAR_COLORYELLOW); + CHAR_setInt(charaindex,CHAR_REPORT,day); + } + } + } + }else{ + //========VIPǩ========= + //ұո + count = CHAR_findSurplusItemBox( charaindex ); + //Ʒ + for (i = 0; i < 10; i++) { + if(getVipReportItem(i) !=-1){ + countReport++; + } + } + if(count < countReport){ + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE,WINDOW_BUTTONTYPE_OK,-1,-1,"\n\n\n ռλ㡣"); + return; + } + for (i = 0; i < 10; i++) { + if(getVipReportItem(i) !=-1){ + #ifdef _ITEM_UP + itemindex = ITEM_makeItemAndRegist( getVipReportItem(i) , charaindex );//ȡһ + #else + itemindex = ITEM_makeItemAndRegist( getVipReportItem(i) );//ȡһ + #endif + if( itemindex != -1 ){ + emptyitemindexinchara = CHAR_findEmptyItemBox( charaindex );//ȡռ + if( emptyitemindexinchara < 0 ){ + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE,WINDOW_BUTTONTYPE_OK,-1,-1,"\n\n\n ռλ㡣"); + return; + } + CHAR_setItemIndex(charaindex, emptyitemindexinchara, itemindex ); + ITEM_setWorkInt(itemindex, ITEM_WORKOBJINDEX,-1); + ITEM_setWorkInt(itemindex, ITEM_WORKCHARAINDEX,charaindex); + CHAR_sendItemDataOne( charaindex, emptyitemindexinchara); + sprintf( token, "õ%s", ITEM_getChar( itemindex, ITEM_NAME)); + CHAR_talkToCli( charaindex, -1, token, CHAR_COLORYELLOW); + CHAR_setInt(charaindex,CHAR_REPORT,day); + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE,WINDOW_BUTTONTYPE_OK,-1,-1,"\n\n\n ǩɹӭǩ"); + } + } + } + } + CHAR_charSaveFromConnect(fd,FALSE); + } +#endif + +#ifdef _CAX_ESC_SAVE_DATA +void SaveData(int charaindex){ + int fd; + if( (fd = getfdFromCharaIndex( charaindex)) == -1 ) return; + //int ownerindex = CHAR_getWorkInt(petindex, CHAR_WORKPLAYERINDEX); + CHAR_charSaveFromConnect(charaindex,FALSE); + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE,WINDOW_BUTTONTYPE_OK,-1,-1,"\n\nԶ浵ɹ"); +} +#endif + +BOOL FreeSamenu(int* function,int id, int charaindex ) +{ + static lua_State *lua; + + if (lua == NULL){ + lua = FindLua("data/ablua/freesamenu.lua"); + if (lua == NULL)return TRUE; + } + + lua_getglobal(lua, "ESC_Recv"); + + if (!lua_isfunction(lua, -1)) { + lua_pop(lua, 1); + return TRUE; + } + int TM_Ret = 0; +#ifdef _CAX_ESC_REPORT + if ( id == 6){ + report1(charaindex); + //CHAR_talkToCli(charaindex,-1,"Ƿڲִ",CHAR_COLORRED); + return; + } +#endif +#ifdef _CAX_ESC_SAVE_DATA + if ( id == 7){ + SaveData(charaindex); + //CHAR_talkToCli(charaindex,-1,"Ƿڲִ",CHAR_COLORRED); + return; + } +#endif + //η + //lua_pushstring(lua,message); + lua_getglobal(lua, (const char*)function); + lua_pushinteger(lua, (lua_Integer)id); + lua_pushnumber(lua,charaindex); + TM_Ret = lua_pcall(lua, 2, 0, 0); + if(TM_Ret != 0) + { + print("NPC_Lua_ESC_Recv Lua Err :%d(%s)\n", TM_Ret, lua_tostring(lua, -1)); + lua_pop(lua, 1); + return; + } +} +/* +BOOL TeacherButton(int* function,int charaindex ) +{ + static lua_State *lua; + + if (lua == NULL){ + lua = FindLua("data/ablua/TeacherButton.lua"); + if (lua == NULL)return TRUE; + } + + lua_getglobal(lua, "TeacherButton"); + + if (!lua_isfunction(lua, -1)) { + lua_pop(lua, 1); + return TRUE; + } + int TM_Ret = 0; + //η + //lua_pushstring(lua,message); + lua_getglobal(lua, (const char*)function); + lua_pushinteger(lua, (lua_Integer)charaindex); + TM_Ret = lua_pcall(lua, 1, 0, 0); + if(TM_Ret != 0) + { + print("TeacherButton Lua Err :%d(%s)\n", TM_Ret, lua_tostring(lua, -1)); + lua_pop(lua, 1); + return; + } +} + +*/ + +BOOL FreeCharExpSave(int charaindex, int exp ) +{ + //printf("exp1 = %d \n",exp); + static lua_State *lua; + if (lua == NULL){ + lua = FindLua("data/ablua/freecharexpsave.lua"); + if (lua == NULL)return FALSE; + } + lua_getglobal(lua, "FreeCharExpSave"); + + if (!lua_isfunction(lua, -1)) { + lua_pop(lua, 1); + return TRUE; + } + int TM_Ret = 0; + + lua_pushnumber(lua,charaindex); + lua_pushinteger(lua, (lua_Integer)exp); + + TM_Ret = lua_pcall(lua, 2, 0, 0); + if(TM_Ret != 0) + { + print("FreeCharExpSave Lua Err :%d(%s)\n", TM_Ret, lua_tostring(lua, -1)); + lua_pop(lua, 1); + return; + } +} + +#endif + +#endif + + diff --git a/mylua/init.c b/mylua/init.c new file mode 100644 index 0000000..79133d9 --- /dev/null +++ b/mylua/init.c @@ -0,0 +1,59 @@ +/* +** $Id: linit.c,v 1.14.1.1 2007/12/27 13:02:25 roberto Exp $ +** Initialization of libraries for lua.c +** See Copyright Notice in lua.h +*/ + + +#define linit_c +#define LUA_LIB + +#include "lua.h" + +#include "lualib.h" +#include "lauxlib.h" +#include "mylua/base.h" + +static const luaL_Reg lualibs[] = { + {"char", luaopen_Char}, + {"npc", luaopen_NPC}, + {"lssproto", luaopen_Lssproto}, + {"battle", luaopen_Battle}, + {"obj", luaopen_Object}, +#ifdef _ALLBLUES_LUA_1_1 + {"map", luaopen_Map}, + {"other", luaopen_Other}, + {"config", luaopen_Config}, +#endif +#ifdef _ALLBLUES_LUA_1_2 + {"item", luaopen_Item}, + {"magic", luaopen_Magic}, +#endif +#ifdef _OFFLINE_SYSTEM + {"offline", luaopen_Offline}, +#endif +#ifdef _ALLBLUES_LUA_1_4 + {"enemytemp", luaopen_Enemytemp}, +#ifdef _SASQL + {"sasql", luaopen_Sasql}, +#endif +#endif + {"net", luaopen_Net}, + {"saacproto", luaopen_Saacproto}, +#ifdef _ALLBLUES_LUA_1_8 + {"family", luaopen_Family}, + {"petskill", luaopen_PetSkill}, +#endif + {NULL, NULL} +}; + + +LUALIB_API void luaAB_openlibs (lua_State *L) { + const luaL_Reg *lib = lualibs; + for (; lib->func; lib++) { + lua_pushcfunction(L, lib->func); + lua_pushstring(L, lib->name); + lua_call(L, 1, 0); + } +} + diff --git a/mylua/itembase.c b/mylua/itembase.c new file mode 100644 index 0000000..11d4e53 --- /dev/null +++ b/mylua/itembase.c @@ -0,0 +1,360 @@ +#include +#include "common.h" +#include "char_base.h" +#include "mylua/base.h" +#include "char.h" +#include "item.h" +#include "lua.h" +#include "lauxlib.h" +#include "lualib.h" +#include "lssproto_serv.h" + +#ifdef _ALLBLUES_LUA_1_2 +#include "mylua/mylua.h" +extern MY_Lua MYLua; +static CharBase ItemBaseInt[] = { + {{""}, ITEM_ID} + ,{{"ͼ"}, ITEM_BASEIMAGENUMBER} + ,{{"ֵ"}, ITEM_COST} + ,{{""}, ITEM_TYPE} + ,{{"ʹ"}, ITEM_ABLEUSEFIELD} + ,{{"Ŀ"}, ITEM_TARGET} + ,{{"ȼ"}, ITEM_LEVEL} + ,{{""}, ITEM_DAMAGEBREAK} + ,{{"ѵ"}, ITEM_USEPILENUMS} + ,{{"ص"}, ITEM_CANBEPILE} + ,{{"蹥"}, ITEM_NEEDSTR} + ,{{""}, ITEM_NEEDDEX} + ,{{"ת"}, ITEM_NEEDTRANS} + ,{{"ְҵ"}, ITEM_NEEDPROFESSION} +#ifdef _TAKE_ITEMDAMAGE + ,{{"С"}, ITEM_DAMAGECRUSHE} + ,{{""}, ITEM_MAXDAMAGECRUSHE} +#endif + ,{{""}, ITEM_OTHERDAMAGE} + ,{{""}, ITEM_OTHERDEFC} + ,{{"װ"}, ITEM_SUITCODE} + ,{{"С"}, ITEM_ATTACKNUM_MIN} + ,{{"󹥻"}, ITEM_ATTACKNUM_MAX} + ,{{""}, ITEM_MODIFYATTACK} + ,{{""}, ITEM_MODIFYDEFENCE} + ,{{""}, ITEM_MODIFYQUICK} + ,{{"HP"}, ITEM_MODIFYHP} + ,{{"MP"}, ITEM_MODIFYMP} + ,{{""}, ITEM_MODIFYLUCK} + ,{{""}, ITEM_MODIFYCHARM} + ,{{"ر"}, ITEM_MODIFYAVOID} + ,{{""}, ITEM_MODIFYATTRIB} + ,{{"Ա"}, ITEM_MODIFYATTRIBVALUE} + ,{{""}, ITEM_MAGICID} + ,{{"о"}, ITEM_MAGICPROB} + ,{{"MP"}, ITEM_MAGICUSEMP} + ,{{""}, ITEM_MODIFYARRANGE} + ,{{""}, ITEM_MODIFYSEQUENCE} + ,{{""}, ITEM_ATTACHPILE} + ,{{""}, ITEM_HITRIGHT} + ,{{""}, ITEM_NEGLECTGUARD} + ,{{""}, ITEM_POISON} + ,{{""}, ITEM_PARALYSIS} + ,{{"˯"}, ITEM_SLEEP} + ,{{"ʯ"}, ITEM_STONE} + ,{{""}, ITEM_DRUNK} + ,{{""}, ITEM_CONFUSION} + ,{{""}, ITEM_CRITICAL} + ,{{""}, ITEM_USEACTION} + ,{{"dzʧ"}, ITEM_DROPATLOGOUT} + ,{{"ʧ"}, ITEM_VANISHATDROP} + ,{{""}, ITEM_ISOVERED} + ,{{"ʼ"}, ITEM_CANPETMAIL} + ,{{"ϳɴ"}, ITEM_CANMERGEFROM} + ,{{"ϳ"}, ITEM_CANMERGETO} + ,{{"0"}, ITEM_INGVALUE0} + ,{{"1"}, ITEM_INGVALUE1} + ,{{"2"}, ITEM_INGVALUE2} + ,{{"3"}, ITEM_INGVALUE3} + ,{{"4"}, ITEM_INGVALUE4} + ,{{"ɫ"}, ITEM_COLOER} + ,{{"Ʒȼ"}, ITEM_LEAKLEVEL} + +}; + +static CharBase ItemBaseChar[] = { + {{""}, ITEM_NAME} + ,{{"ʾ"}, ITEM_SECRETNAME} + ,{{"˵"}, ITEM_EFFECTSTRING} + ,{{"ֶ"}, ITEM_ARGUMENT} + ,{{"ɷ0"}, ITEM_INGNAME0} + ,{{"ɷ1"}, ITEM_INGNAME1} + ,{{"ɷ2"}, ITEM_INGNAME2} + ,{{"ɷ3"}, ITEM_INGNAME3} + ,{{"ɷ4"}, ITEM_INGNAME4} +#ifdef _ANGEL_SUMMON + ,{{""}, ITEM_ANGELMISSION} + ,{{"ʹ"}, ITEM_ANGELINFO} + ,{{"Ӣ"}, ITEM_HEROINFO} +#endif + +}; + +static CharBase ItemBaseValue[] = { + {{"צ"}, ITEM_FIST} + ,{{""}, ITEM_AXE} + ,{{""}, ITEM_CLUB} + ,{{"ǹ"}, ITEM_SPEAR} + ,{{""}, ITEM_BOW} + ,{{""}, ITEM_SHIELD} + ,{{""}, ITEM_HELM} + ,{{""}, ITEM_ARMOUR} + ,{{""}, ITEM_BRACELET} + ,{{""}, ITEM_MUSIC} + ,{{""}, ITEM_NECKLACE} + ,{{""}, ITEM_RING} + ,{{""}, ITEM_BELT} + ,{{""}, ITEM_EARRING} + ,{{"ǻ"}, ITEM_NOSERING} + ,{{""}, ITEM_AMULET} + ,{{""}, ITEM_OTHER} + ,{{""}, ITEM_BOOMERANG} + ,{{"Ͷ"}, ITEM_BOUNDTHROW} + ,{{"Ͷʯ"}, ITEM_BREAKTHROW} + ,{{""}, ITEM_DISH} +#ifdef _ITEM_INSLAY + ,{{""}, ITEM_METAL} + ,{{"ʯ"}, ITEM_JEWEL} +#endif +#ifdef _ITEM_CHECKWARES + ,{{""}, ITEM_WARES} +#endif +#ifdef _ITEM_EQUITSPACE + ,{{""}, ITEM_WBELT} + ,{{""}, ITEM_WSHIELD} + ,{{"Ь"}, ITEM_WSHOES} +#endif +#ifdef _EQUIT_NEWGLOVE + ,{{""}, ITEM_WGLOVE} +#endif +#ifdef _ALCHEMIST + ,{{""}, ITEM_ALCHEMIST} +#endif +#ifdef _PET_ITEM + ,{{"ͷ"}, ITEM_PET_HEAD} + ,{{""}, ITEM_PET_TOOTH} + ,{{"צ"}, ITEM_PET_CLAW} + ,{{""}, ITEM_PET_BREAST} + ,{{"豳"}, ITEM_PET_BACK} + ,{{""}, ITEM_PET_WING} + ,{{""}, ITEM_PET_FEET} +#endif +}; + +static CharBase ItemBaseWorkInt[] = { + {{""}, ITEM_WORKOBJINDEX} + ,{{""}, ITEM_WORKCHARAINDEX} +}; + +static CharBase ItemBaseEvent[] = { + {{"δ֪¼"}, ITEM_PREOVERFUNC} + ,{{"ʼ¼"}, ITEM_POSTOVERFUNC} + ,{{"ʹ¼"}, ITEM_USEFUNC} + ,{{"װ¼"}, ITEM_ATTACHFUNC} + ,{{"ж¼"}, ITEM_DETACHFUNC} + ,{{"¼"}, ITEM_DROPFUNC} + ,{{"¼"}, ITEM_PICKUPFUNC} + ,{{"¼"}, ITEM_DIERELIFEFUNC} +}; + +static int getInt(lua_State *L) +{ + const int index = luaL_checkint(L, 1); + const int element = getCharBaseValue(L, 2, ItemBaseInt, arraysizeof(ItemBaseInt)); + + lua_pushinteger(L, ITEM_getInt(index, element)); + return 1; +} + +static int setInt(lua_State *L) +{ + const int index = luaL_checkint(L, 1); + const int element = getCharBaseValue(L, 2, ItemBaseInt, arraysizeof(ItemBaseInt)); + const int data = luaL_checkint(L, 3); + + if(ITEM_setInt(index, element, data) == -1){ + return 0; + }else{ + return 1; + } +} + +static int getChar(lua_State *L) +{ + const int index = luaL_checkint(L, 1); + const int element = getCharBaseValue(L, 2, ItemBaseChar, arraysizeof(ItemBaseChar)); + + lua_pushstring(L, ITEM_getChar(index, element)); + return 1; +} + +static int setChar(lua_State *L) +{ + size_t l; + const int index = luaL_checkint(L, 1); + const int element = getCharBaseValue(L, 2, ItemBaseChar, arraysizeof(ItemBaseChar)); + char *data = luaL_checklstring(L, 3, &l); + + if(ITEM_setChar(index, element, data) == -1){ + return 0; + }else{ + return 1; + } +} + +static int getWorkInt(lua_State *L) +{ + const int index = luaL_checkint(L, 1); + const int element = getCharBaseValue(L, 2, ItemBaseWorkInt, arraysizeof(ItemBaseWorkInt)); + + lua_pushinteger(L, ITEM_getWorkInt(index, element)); + return 1; +} + +static int setWorkInt(lua_State *L) +{ + const int index = luaL_checkint(L, 1); + const int element = getCharBaseValue(L, 2, ItemBaseWorkInt, arraysizeof(ItemBaseWorkInt)); + const int data = luaL_checkint(L, 3); + + if(ITEM_setWorkInt(index, element, data) == -1){ + return 0; + }else{ + return 1; + } +} + +static int getNameFromNumber(lua_State *L) +{ + const int id = luaL_checkint(L, 1); + + lua_pushstring(L, ITEM_getNameFromNumber(id)); + + return 1; +} + +static int getcostFromITEMtabl(lua_State *L) +{ + const int id = luaL_checkint(L, 1); + + lua_pushinteger(L, ITEM_getcostFromITEMtabl(id)); + + return 1; +} + +static int getlevelFromITEMtabl(lua_State *L) +{ + const int id = luaL_checkint(L, 1); + + lua_pushinteger(L, ITEM_getlevelFromITEMtabl(id)); + + return 1; +} + +static int getgraNoFromITEMtabl(lua_State *L) +{ + const int id = luaL_checkint(L, 1); + + lua_pushinteger(L, ITEM_getgraNoFromITEMtabl(id)); + + return 1; +} + +static int getItemInfoFromNumber(lua_State *L) +{ + const int id = luaL_checkint(L, 1); + + lua_pushstring(L, ITEM_getItemInfoFromNumber(id)); + + return 1; +} + +static int setFunctionPointer(lua_State *L) +{ + size_t l; + const int index = luaL_checkint(L, 1); + const int functype = getCharBaseValue(L, 2, ItemBaseEvent, arraysizeof(ItemBaseEvent)); + char *luafuncname=luaL_checklstring(L, 3, &l); + + return ITEM_setLUAFunction( index, functype, luafuncname ); +} + +static int addLUAListFunction(lua_State *L) +{ + size_t l; + char *luafuncname=luaL_checklstring(L, 1, &l); + char *luafunctable=luaL_checklstring(L, 2, &l); + char *luafunctablepath=luaL_checklstring(L, 3, &l); + + if(strlen(luafunctablepath) > 0){ + MY_Lua *mylua = &MYLua; + while(mylua->next != NULL){ + if(strcmp(mylua->luapath, luafunctablepath) == 0){ + return ITEM_addLUAListFunction( mylua->lua, luafuncname, luafunctable); + } + mylua = mylua->next; + } + }else{ + return ITEM_addLUAListFunction( L, luafuncname, luafunctable ); + } + return 1; +} + +static int UpdataItemOne(lua_State *L) +{ + const int charaindex = luaL_checkint(L, 1); + const int itemindex = luaL_checkint(L, 2); + + int i; + for( i = 0; i < CHAR_MAXITEMHAVE ; i++ ){ + if(itemindex == CHAR_getItemIndex( charaindex , i )){ + CHAR_sendItemDataOne( charaindex, i); + break; + } + } + + return 1; +} + +static int UpdataHaveItemOne(lua_State *L) +{ + const int charaindex = luaL_checkint(L, 1); + const int haveitemindex = luaL_checkint(L, 2); + + CHAR_sendItemDataOne( charaindex, haveitemindex); + + return 1; +} + +static const luaL_Reg itemlib[] = { + {"getInt", getInt}, + {"setInt", setInt}, + {"getChar", getChar}, + {"setChar", setChar}, + {"getWorkInt", getWorkInt}, + {"setWorkInt", setWorkInt}, + {"setFunctionPointer", setFunctionPointer}, + {"addLUAListFunction", addLUAListFunction}, + {"getNameFromNumber", getNameFromNumber}, + {"getcostFromITEMtabl", getcostFromITEMtabl}, + {"getlevelFromITEMtabl", getlevelFromITEMtabl}, + {"getgraNoFromITEMtabl", getgraNoFromITEMtabl}, + {"getItemInfoFromNumber", getItemInfoFromNumber}, + {"UpdataItemOne", UpdataItemOne}, + {"UpdataHaveItemOne", UpdataHaveItemOne}, + {NULL, NULL} +}; + +LUALIB_API int luaopen_Item (lua_State *L) { + luaL_register(L, "item", itemlib); + return 1; +} + +#endif + diff --git a/mylua/lssprotobase.c b/mylua/lssprotobase.c new file mode 100644 index 0000000..38edf23 --- /dev/null +++ b/mylua/lssprotobase.c @@ -0,0 +1,196 @@ +#include +#include "char.h" +#include "char_base.h" +#include "mylua/base.h" +#include "lua.h" +#include "lauxlib.h" +#include "lualib.h" +#include "lssproto_serv.h" +#ifdef _ALLBLUES_LUA_2_0 +#include "autil.h" +#endif +#ifdef _ALLBLUES_LUA + + +#define WINDOW_BUTTONTYPE_NONE (0) +#define WINDOW_BUTTONTYPE_OK (1 << 0) +#define WINDOW_BUTTONTYPE_CANCEL (1 << 1) +#define WINDOW_BUTTONTYPE_YES (1 << 2) +#define WINDOW_BUTTONTYPE_NO (1 << 3) +#define WINDOW_BUTTONTYPE_PREV (1 << 4) +#define WINDOW_BUTTONTYPE_NEXT (1 << 5) + +#define WINDOW_BUTTONTYPE_OKCANCEL (WINDOW_BUTTONTYPE_OK | WINDOW_BUTTONTYPE_CANCEL) +#define WINDOW_BUTTONTYPE_YESNO (WINDOW_BUTTONTYPE_YES | WINDOW_BUTTONTYPE_NO) + + +static CharBase CharBaseWindow[] = { + {{"Ի"}, WINDOW_MESSAGETYPE_MESSAGE} + ,{{""}, WINDOW_MESSAGETYPE_MESSAGEANDLINEINPUT} + ,{{"ѡ"}, WINDOW_MESSAGETYPE_SELECT} + ,{{""}, WINDOW_MESSAGETYPE_PETSELECT} + ,{{"߿"}, WINDOW_MESSAGETYPE_ITEMSHOPMENU} + ,{{"߿"}, WINDOW_MESSAGETYPE_ITEMSHOPMAIN} + ,{{"ѧܿ"}, WINDOW_MESSAGETYPE_PETSKILLSHOP} +#ifdef _NEW_MANOR_LAW + ,{{"ʮƼ"}, WINDOW_FMMESSAGETYPE_10_MEMONTUM} + ,{{"б"}, WINDOW_FMMESSAGETYPE_FM_MEMONTUM} +#endif + ,{{"Աб"}, WINDOW_FMMESSAGETYPE_DENGON} + ,{{"ׯ԰б"}, WINDOW_FMMESSAGETYPE_POINTLIST} + ,{{"ǰб"}, WINDOW_FMMESSAGETYPE_TOP30DP} + ,{{"п"}, WINDOW_MESSAGETYPE_BANK} + ,{{"Ի"}, WINDOW_MESSAGETYPE_WIDEMESSAGE} + ,{{""}, WINDOW_MESSAGETYPE_WIDEMESSAGEANDLINEINPUT} + +}; + +static CharBase CharBaseButton[] = { + {{"ްť"}, WINDOW_BUTTONTYPE_NONE} + ,{{"ȷ"}, WINDOW_BUTTONTYPE_OK} + ,{{"ȡ"}, WINDOW_BUTTONTYPE_CANCEL} + ,{{"YES"}, WINDOW_BUTTONTYPE_YES} + ,{{"NO"}, WINDOW_BUTTONTYPE_NO} + ,{{"һҳ"}, WINDOW_BUTTONTYPE_PREV|WINDOW_BUTTONTYPE_CANCEL} + ,{{"һҳ"}, WINDOW_BUTTONTYPE_NEXT|WINDOW_BUTTONTYPE_CANCEL} +}; + +static CharBase CharBaseSeqNo[] = { + {{""}, -1} +#ifdef _NEW_STREET_VENDOR + ,{{"̯"}, CHAR_WINDOWTYPE_STREET_VENDOR_TYPE} +#endif +#ifdef _PETSKILL_CANNEDFOOD + ,{{"\ѡ"}, ITEM_WINDOWTYPE_SELECTPETSKILL_SELECT} +#endif +#ifdef _ITEM_OVER_LAP + ,{{"ص"}, CHAR_WINDOWTYPE_ITEMOVERLAP} +#endif +}; + + +static int windows_send(lua_State *L) +{ + size_t l; + const int index = luaL_checkint(L, 1); + if(CHAR_CHECKINDEX(index) == FALSE) return 0; + int fd = getfdFromCharaIndex( index); + const int windowtype = getCharBaseValue(L, 2, CharBaseWindow, arraysizeof(CharBaseWindow)); + const int buttontype = getCharBaseValue(L, 3, CharBaseButton, arraysizeof(CharBaseButton)); + const int seqno = getCharBaseValue(L, 4, CharBaseSeqNo, arraysizeof(CharBaseSeqNo)); + const int objindex=luaL_checkint(L, 5); + char *data=luaL_checklstring(L, 6, &l); + + + lssproto_WN_send(fd, windowtype, buttontype, seqno, objindex, data); + return 1; +} + +static int show(lua_State *L) +{ + size_t l; + const int index = luaL_checkint(L, 1); + if(CHAR_CHECKINDEX(index) == FALSE) return 0; + int fd = getfdFromCharaIndex( index); + char *data=luaL_checklstring(L, 2, &l); + + + lssproto_C_send(fd, data); + return 1; +} + +static int FM(lua_State *L) +{ + size_t l; + const int index = luaL_checkint(L, 1); + if(CHAR_CHECKINDEX(index) == FALSE) return 0; + int fd = getfdFromCharaIndex( index); + char *data=luaL_checklstring(L, 2, &l); + + lssproto_FM_send(fd, data); + return 1; +} + +static int S2(lua_State *L) +{ + size_t l; + const int index = luaL_checkint(L, 1); + if(CHAR_CHECKINDEX(index) == FALSE) return 0; + int fd = getfdFromCharaIndex( index); + char *data=luaL_checklstring(L, 2, &l); + + lssproto_S2_send(fd, data); + return 1; +} + +#ifdef _ALLBLUES_LUA_2_0 +/* +static int CharList(lua_State *L) +{ + int fd = luaL_checkint(L, 1); + size_t l; + char *data=luaL_checklstring(L, 2, &l); + char buffer[1024 * 64]; + int checksum=0; + + strcpy(buffer,""); + checksum += util_mkstring(fd,buffer, "failed"); + checksum += util_mkstring(fd,buffer, data); + util_mkint(fd,buffer, checksum); + printf("data = %s\n",data); + util_SendMesg(fd, LSSPROTO_CLIENTLOGIN_SEND, buffer); + return 1; +} +*/ +static int CharList(lua_State *L) +{ + size_t l; + const int fd = luaL_checkint(L, 1); + char *data=luaL_checklstring(L, 2, &l); + + lssproto_CharList_send(fd, FAILED, data); + return 1; +} + +#ifdef _CAX_DENGON_GG +static int dengon(lua_State *L) +{ + size_t l; + const int index = luaL_checkint(L, 1); + if(CHAR_CHECKINDEX(index) == FALSE) return 0; + int fd = getfdFromCharaIndex( index); + char *data=luaL_checklstring(L, 2, &l); + const int color=luaL_checkint(L, 3); + const int num=luaL_checkint(L, 4); + + lssproto_DENGON_send(fd, data, color, num); + return 1; +} +#endif + +#endif + + + + +static const luaL_Reg lssprotolib[] = { + {"windows", windows_send}, + {"show", show}, + {"FM", FM}, + {"S2", S2}, +#ifdef _ALLBLUES_LUA_2_0 + {"CharList", CharList}, +#ifdef _CAX_DENGON_GG + {"dengon", dengon}, +#endif +#endif + {NULL, NULL} +}; + +LUALIB_API int luaopen_Lssproto (lua_State *L) { + luaL_register(L, "lssproto", lssprotolib); + return 1; +} + +#endif + diff --git a/mylua/lua/Makefile b/mylua/lua/Makefile new file mode 100644 index 0000000..f7d884e --- /dev/null +++ b/mylua/lua/Makefile @@ -0,0 +1,182 @@ +# makefile for building Lua +# see ../INSTALL for installation instructions +# see ../Makefile and luaconf.h for further customization + +# == CHANGE THE SETTINGS BELOW TO SUIT YOUR ENVIRONMENT ======================= + +# Your platform. See PLATS for possible values. +PLAT= none + +CC= gcc +CFLAGS=-w -O3 -g -rdynamic $(INCFLAGS) +AR= ar rcu +RANLIB= ranlib +RM= rm -f +LIBS= -lm $(MYLIBS) + +MYCFLAGS= +MYLDFLAGS= +MYLIBS= + +# == END OF USER SETTINGS. NO NEED TO CHANGE ANYTHING BELOW THIS LINE ========= + +PLATS= aix ansi bsd freebsd generic linux macosx mingw posix solaris + +LUA_A= liblua.a +CORE_O= lapi.o lcode.o ldebug.o ldo.o ldump.o lfunc.o lgc.o llex.o lmem.o \ + lobject.o lopcodes.o lparser.o lstate.o lstring.o ltable.o ltm.o \ + lundump.o lvm.o lzio.o +LIB_O= lauxlib.o lbaselib.o ldblib.o liolib.o lmathlib.o loslib.o ltablib.o \ + lstrlib.o loadlib.o linit.o + +LUA_T= lua +LUA_O= lua.o + +LUAC_T= luac +LUAC_O= luac.o print.o + +ALL_O= $(CORE_O) $(LIB_O) $(LUA_O) $(LUAC_O) +ALL_T= $(LUA_A) $(LUA_T) $(LUAC_T) +ALL_A= $(LUA_A) + +default: $(PLAT) + +all: $(ALL_T) + +o: $(ALL_O) + +a: $(ALL_A) + +$(LUA_A): $(CORE_O) $(LIB_O) + $(AR) $@ $? + $(RANLIB) $@ + +$(LUA_T): $(LUA_O) $(LUA_A) + $(CC) -o $@ $(MYLDFLAGS) $(LUA_O) $(LUA_A) $(LIBS) + +$(LUAC_T): $(LUAC_O) $(LUA_A) + $(CC) -o $@ $(MYLDFLAGS) $(LUAC_O) $(LUA_A) $(LIBS) + +clean: + $(RM) $(ALL_T) $(ALL_O) + +depend: + @$(CC) $(CFLAGS) -MM l*.c print.c + +echo: + @echo "PLAT = $(PLAT)" + @echo "CC = $(CC)" + @echo "CFLAGS = $(CFLAGS)" + @echo "AR = $(AR)" + @echo "RANLIB = $(RANLIB)" + @echo "RM = $(RM)" + @echo "MYCFLAGS = $(MYCFLAGS)" + @echo "MYLDFLAGS = $(MYLDFLAGS)" + @echo "MYLIBS = $(MYLIBS)" + +# convenience targets for popular platforms + +none: + @echo "Please choose a platform:" + @echo " $(PLATS)" + +aix: + $(MAKE) all CC="xlc" CFLAGS="-O2 -DLUA_USE_POSIX -DLUA_USE_DLOPEN" MYLIBS="-ldl" MYLDFLAGS="-brtl -bexpall" + +ansi: + $(MAKE) all MYCFLAGS=-DLUA_ANSI + +bsd: + $(MAKE) all MYCFLAGS="-DLUA_USE_POSIX -DLUA_USE_DLOPEN" MYLIBS="-Wl,-E" + +freebsd: + $(MAKE) all MYCFLAGS="-DLUA_USE_LINUX" MYLIBS="-Wl,-E -lreadline" + +generic: + $(MAKE) all MYCFLAGS= + +linux: + $(MAKE) all MYCFLAGS=-DLUA_USE_LINUX MYLIBS="-Wl,-E -ldl -lreadline -lhistory -lncurses" + +macosx: + $(MAKE) all MYCFLAGS=-DLUA_USE_LINUX MYLIBS="-lreadline" +# use this on Mac OS X 10.3- +# $(MAKE) all MYCFLAGS=-DLUA_USE_MACOSX + +mingw: + $(MAKE) "LUA_A=lua51.dll" "LUA_T=lua.exe" \ + "AR=$(CC) -shared -o" "RANLIB=strip --strip-unneeded" \ + "MYCFLAGS=-DLUA_BUILD_AS_DLL" "MYLIBS=" "MYLDFLAGS=-s" lua.exe + $(MAKE) "LUAC_T=luac.exe" luac.exe + +posix: + $(MAKE) all MYCFLAGS=-DLUA_USE_POSIX + +solaris: + $(MAKE) all MYCFLAGS="-DLUA_USE_POSIX -DLUA_USE_DLOPEN" MYLIBS="-ldl" + +# list targets that do not create files (but not all makes understand .PHONY) +.PHONY: all $(PLATS) default o a clean depend echo none + +# DO NOT DELETE + +lapi.o: lapi.c lua.h luaconf.h lapi.h lobject.h llimits.h ldebug.h \ + lstate.h ltm.h lzio.h lmem.h ldo.h lfunc.h lgc.h lstring.h ltable.h \ + lundump.h lvm.h +lauxlib.o: lauxlib.c lua.h luaconf.h lauxlib.h +lbaselib.o: lbaselib.c lua.h luaconf.h lauxlib.h lualib.h +lcode.o: lcode.c lua.h luaconf.h lcode.h llex.h lobject.h llimits.h \ + lzio.h lmem.h lopcodes.h lparser.h ldebug.h lstate.h ltm.h ldo.h lgc.h \ + ltable.h +ldblib.o: ldblib.c lua.h luaconf.h lauxlib.h lualib.h +ldebug.o: ldebug.c lua.h luaconf.h lapi.h lobject.h llimits.h lcode.h \ + llex.h lzio.h lmem.h lopcodes.h lparser.h ldebug.h lstate.h ltm.h ldo.h \ + lfunc.h lstring.h lgc.h ltable.h lvm.h +ldo.o: ldo.c lua.h luaconf.h ldebug.h lstate.h lobject.h llimits.h ltm.h \ + lzio.h lmem.h ldo.h lfunc.h lgc.h lopcodes.h lparser.h lstring.h \ + ltable.h lundump.h lvm.h +ldump.o: ldump.c lua.h luaconf.h lobject.h llimits.h lstate.h ltm.h \ + lzio.h lmem.h lundump.h +lfunc.o: lfunc.c lua.h luaconf.h lfunc.h lobject.h llimits.h lgc.h lmem.h \ + lstate.h ltm.h lzio.h +lgc.o: lgc.c lua.h luaconf.h ldebug.h lstate.h lobject.h llimits.h ltm.h \ + lzio.h lmem.h ldo.h lfunc.h lgc.h lstring.h ltable.h +linit.o: linit.c lua.h luaconf.h lualib.h lauxlib.h +liolib.o: liolib.c lua.h luaconf.h lauxlib.h lualib.h +llex.o: llex.c lua.h luaconf.h ldo.h lobject.h llimits.h lstate.h ltm.h \ + lzio.h lmem.h llex.h lparser.h lstring.h lgc.h ltable.h +lmathlib.o: lmathlib.c lua.h luaconf.h lauxlib.h lualib.h +lmem.o: lmem.c lua.h luaconf.h ldebug.h lstate.h lobject.h llimits.h \ + ltm.h lzio.h lmem.h ldo.h +loadlib.o: loadlib.c lua.h luaconf.h lauxlib.h lualib.h +lobject.o: lobject.c lua.h luaconf.h ldo.h lobject.h llimits.h lstate.h \ + ltm.h lzio.h lmem.h lstring.h lgc.h lvm.h +lopcodes.o: lopcodes.c lopcodes.h llimits.h lua.h luaconf.h +loslib.o: loslib.c lua.h luaconf.h lauxlib.h lualib.h +lparser.o: lparser.c lua.h luaconf.h lcode.h llex.h lobject.h llimits.h \ + lzio.h lmem.h lopcodes.h lparser.h ldebug.h lstate.h ltm.h ldo.h \ + lfunc.h lstring.h lgc.h ltable.h +lstate.o: lstate.c lua.h luaconf.h ldebug.h lstate.h lobject.h llimits.h \ + ltm.h lzio.h lmem.h ldo.h lfunc.h lgc.h llex.h lstring.h ltable.h +lstring.o: lstring.c lua.h luaconf.h lmem.h llimits.h lobject.h lstate.h \ + ltm.h lzio.h lstring.h lgc.h +lstrlib.o: lstrlib.c lua.h luaconf.h lauxlib.h lualib.h +ltable.o: ltable.c lua.h luaconf.h ldebug.h lstate.h lobject.h llimits.h \ + ltm.h lzio.h lmem.h ldo.h lgc.h ltable.h +ltablib.o: ltablib.c lua.h luaconf.h lauxlib.h lualib.h +ltm.o: ltm.c lua.h luaconf.h lobject.h llimits.h lstate.h ltm.h lzio.h \ + lmem.h lstring.h lgc.h ltable.h +lua.o: lua.c lua.h luaconf.h lauxlib.h lualib.h +luac.o: luac.c lua.h luaconf.h lauxlib.h ldo.h lobject.h llimits.h \ + lstate.h ltm.h lzio.h lmem.h lfunc.h lopcodes.h lstring.h lgc.h \ + lundump.h +lundump.o: lundump.c lua.h luaconf.h ldebug.h lstate.h lobject.h \ + llimits.h ltm.h lzio.h lmem.h ldo.h lfunc.h lstring.h lgc.h lundump.h +lvm.o: lvm.c lua.h luaconf.h ldebug.h lstate.h lobject.h llimits.h ltm.h \ + lzio.h lmem.h ldo.h lfunc.h lgc.h lopcodes.h lstring.h ltable.h lvm.h +lzio.o: lzio.c lua.h luaconf.h llimits.h lmem.h lstate.h lobject.h ltm.h \ + lzio.h +print.o: print.c ldebug.h lstate.h lua.h luaconf.h lobject.h llimits.h \ + ltm.h lzio.h lmem.h lopcodes.h lundump.h + +# (end of Makefile) diff --git a/mylua/lua/lapi.c b/mylua/lua/lapi.c new file mode 100644 index 0000000..84113dd --- /dev/null +++ b/mylua/lua/lapi.c @@ -0,0 +1,1100 @@ +/* +** $Id: lapi.c,v 2.55.1.5 2008/07/04 18:41:18 roberto Exp $ +** Lua API +** See Copyright Notice in lua.h +*/ + + +#include +#include +#include +#include + +#define lapi_c +#define LUA_CORE + +#include "lua.h" + +#include "lapi.h" +#include "ldebug.h" +#include "ldo.h" +#include "lfunc.h" +#include "lgc.h" +#include "lmem.h" +#include "lobject.h" +#include "lstate.h" +#include "lstring.h" +#include "ltable.h" +#include "ltm.h" +#include "lundump.h" +#include "lvm.h" + + + +const char lua_ident[] = + "$Lua: " LUA_RELEASE " " LUA_COPYRIGHT " $\n" + "$Authors: " LUA_AUTHORS " $\n" + "$URL: www.lua.org $\n"; + + + +#define api_checknelems(L, n) api_check(L, (n) <= (L->top - L->base)) + +#define api_checkvalidindex(L, i) api_check(L, (i) != luaO_nilobject) + +#define api_incr_top(L) {api_check(L, L->top < L->ci->top); L->top++;} + + + +static TValue *index2adr (lua_State *L, int idx) { + if (idx > 0) { + TValue *o = L->base + (idx - 1); + api_check(L, idx <= L->ci->top - L->base); + if (o >= L->top) return cast(TValue *, luaO_nilobject); + else return o; + } + else if (idx > LUA_REGISTRYINDEX) { + api_check(L, idx != 0 && -idx <= L->top - L->base); + return L->top + idx; + } + else switch (idx) { /* pseudo-indices */ + case LUA_REGISTRYINDEX: return registry(L); + case LUA_ENVIRONINDEX: { + Closure *func = curr_func(L); + sethvalue(L, &L->env, func->c.env); + return &L->env; + } + case LUA_GLOBALSINDEX: return gt(L); + default: { + Closure *func = curr_func(L); + idx = LUA_GLOBALSINDEX - idx; + return (idx <= func->c.nupvalues) + ? &func->c.upvalue[idx-1] + : cast(TValue *, luaO_nilobject); + } + } +} + + +static Table *getcurrenv (lua_State *L) { + if (L->ci == L->base_ci) /* no enclosing function? */ + return hvalue(gt(L)); /* use global table as environment */ + else { + Closure *func = curr_func(L); + return func->c.env; + } +} + + +void luaA_pushobject (lua_State *L, const TValue *o) { + setobj2s(L, L->top, o); + api_incr_top(L); +} + + +LUA_API int lua_checkstack (lua_State *L, int size) { + int res = 1; + lua_lock(L); + if (size > LUAI_MAXCSTACK || (L->top - L->base + size) > LUAI_MAXCSTACK) + res = 0; /* stack overflow */ + else if (size > 0) { + luaD_checkstack(L, size); + if (L->ci->top < L->top + size) + L->ci->top = L->top + size; + } + lua_unlock(L); + return res; +} + + +LUA_API void lua_xmove (lua_State *from, lua_State *to, int n) { + int i; + if (from == to) return; + lua_lock(to); + api_checknelems(from, n); + api_check(from, G(from) == G(to)); + api_check(from, to->ci->top - to->top >= n); + from->top -= n; + for (i = 0; i < n; i++) { + setobj2s(to, to->top++, from->top + i); + } + lua_unlock(to); +} + + +LUA_API void lua_setlevel (lua_State *from, lua_State *to) { + to->nCcalls = from->nCcalls; +} + + +LUA_API lua_CFunction lua_atpanic (lua_State *L, lua_CFunction panicf) { + lua_CFunction old; + lua_lock(L); + old = G(L)->panic; + G(L)->panic = panicf; + lua_unlock(L); + return old; +} + + +LUA_API lua_State *lua_newthread (lua_State *L) { + lua_State *L1; + lua_lock(L); + luaC_checkGC(L); + L1 = luaE_newthread(L); + setthvalue(L, L->top, L1); + api_incr_top(L); + lua_unlock(L); + luai_userstatethread(L, L1); + return L1; +} + + + +/* +** basic stack manipulation +*/ + + +LUA_API int lua_gettop (lua_State *L) { + return cast_int(L->top - L->base); +} + + +LUA_API void lua_settop (lua_State *L, int idx) { + lua_lock(L); + if (idx >= 0) { + api_check(L, idx <= L->stack_last - L->base); + while (L->top < L->base + idx) + setnilvalue(L->top++); + L->top = L->base + idx; + } + else { + api_check(L, -(idx+1) <= (L->top - L->base)); + L->top += idx+1; /* `subtract' index (index is negative) */ + } + lua_unlock(L); +} + + +LUA_API void lua_remove (lua_State *L, int idx) { + StkId p; + lua_lock(L); + p = index2adr(L, idx); + api_checkvalidindex(L, p); + while (++p < L->top) setobjs2s(L, p-1, p); + L->top--; + lua_unlock(L); +} + + +LUA_API void lua_insert (lua_State *L, int idx) { + StkId p; + StkId q; + lua_lock(L); + p = index2adr(L, idx); + api_checkvalidindex(L, p); + for (q = L->top; q>p; q--) setobjs2s(L, q, q-1); + setobjs2s(L, p, L->top); + lua_unlock(L); +} + + +LUA_API void lua_replace (lua_State *L, int idx) { + StkId o; + lua_lock(L); + /* explicit test for incompatible code */ + if (idx == LUA_ENVIRONINDEX && L->ci == L->base_ci) + luaG_runerror(L, "no calling environment"); + api_checknelems(L, 1); + o = index2adr(L, idx); + api_checkvalidindex(L, o); + if (idx == LUA_ENVIRONINDEX) { + Closure *func = curr_func(L); + api_check(L, ttistable(L->top - 1)); + func->c.env = hvalue(L->top - 1); + luaC_barrier(L, func, L->top - 1); + } + else { + setobj(L, o, L->top - 1); + if (idx < LUA_GLOBALSINDEX) /* function upvalue? */ + luaC_barrier(L, curr_func(L), L->top - 1); + } + L->top--; + lua_unlock(L); +} + + +LUA_API void lua_pushvalue (lua_State *L, int idx) { + lua_lock(L); + setobj2s(L, L->top, index2adr(L, idx)); + api_incr_top(L); + lua_unlock(L); +} + + + +/* +** access functions (stack -> C) +*/ + + +LUA_API int lua_type (lua_State *L, int idx) { + StkId o = index2adr(L, idx); + return (o == luaO_nilobject) ? LUA_TNONE : ttype(o); +} + + +LUA_API const char *lua_typename (lua_State *L, int t) { + UNUSED(L); + return (t == LUA_TNONE) ? "no value" : luaT_typenames[t]; +} + + +LUA_API int lua_iscfunction (lua_State *L, int idx) { + StkId o = index2adr(L, idx); + return iscfunction(o); +} + + +LUA_API int lua_isnumber (lua_State *L, int idx) { + TValue n; + const TValue *o = index2adr(L, idx); + return tonumber(o, &n); +} + + +LUA_API int lua_isstring (lua_State *L, int idx) { + int t = lua_type(L, idx); + return (t == LUA_TSTRING || t == LUA_TNUMBER); +} + + +LUA_API int lua_isuserdata (lua_State *L, int idx) { + const TValue *o = index2adr(L, idx); + return (ttisuserdata(o) || ttislightuserdata(o)); +} + + +LUA_API int lua_rawequal (lua_State *L, int index1, int index2) { + StkId o1 = index2adr(L, index1); + StkId o2 = index2adr(L, index2); + return (o1 == luaO_nilobject || o2 == luaO_nilobject) ? 0 + : luaO_rawequalObj(o1, o2); +} + + +LUA_API int lua_equal (lua_State *L, int index1, int index2) { + StkId o1, o2; + int i; + lua_lock(L); /* may call tag method */ + o1 = index2adr(L, index1); + o2 = index2adr(L, index2); + i = (o1 == luaO_nilobject || o2 == luaO_nilobject) ? 0 : equalobj(L, o1, o2); + lua_unlock(L); + return i; +} + + +LUA_API int lua_lessthan (lua_State *L, int index1, int index2) { + StkId o1, o2; + int i; + lua_lock(L); /* may call tag method */ + o1 = index2adr(L, index1); + o2 = index2adr(L, index2); + i = (o1 == luaO_nilobject || o2 == luaO_nilobject) ? 0 + : luaV_lessthan(L, o1, o2); + lua_unlock(L); + return i; +} + + + +LUA_API lua_Number lua_tonumber (lua_State *L, int idx) { + TValue n; + const TValue *o = index2adr(L, idx); + if (tonumber(o, &n)) + return nvalue(o); + else + return 0; +} + + +LUA_API lua_Integer lua_tointeger (lua_State *L, int idx) { + TValue n; + const TValue *o = index2adr(L, idx); + if (tonumber(o, &n)) { + lua_Integer res; + lua_Number num = nvalue(o); + lua_number2integer(res, num); + return res; + } + else + return 0; +} + + +LUA_API int lua_toboolean (lua_State *L, int idx) { + const TValue *o = index2adr(L, idx); + return !l_isfalse(o); +} + + +LUA_API const char *lua_tolstring (lua_State *L, int idx, size_t *len) { + StkId o = index2adr(L, idx); + if (!ttisstring(o)) { + lua_lock(L); /* `luaV_tostring' may create a new string */ + if (!luaV_tostring(L, o)) { /* conversion failed? */ + if (len != NULL) *len = 0; + lua_unlock(L); + return NULL; + } + luaC_checkGC(L); + o = index2adr(L, idx); /* previous call may reallocate the stack */ + lua_unlock(L); + } + if (len != NULL) *len = tsvalue(o)->len; + return svalue(o); +} + + +LUA_API size_t lua_objlen (lua_State *L, int idx) { + StkId o = index2adr(L, idx); + switch (ttype(o)) { + case LUA_TSTRING: return tsvalue(o)->len; + case LUA_TUSERDATA: return uvalue(o)->len; + case LUA_TTABLE: return luaH_getn(hvalue(o)); + case LUA_TNUMBER: { + size_t l; + lua_lock(L); /* `luaV_tostring' may create a new string */ + l = (luaV_tostring(L, o) ? tsvalue(o)->len : 0); + lua_unlock(L); + return l; + } + default: return 0; + } +} + + +LUA_API lua_CFunction lua_tocfunction (lua_State *L, int idx) { + StkId o = index2adr(L, idx); + return (!iscfunction(o)) ? NULL : clvalue(o)->c.f; +} + + +LUA_API void *lua_touserdata (lua_State *L, int idx) { + StkId o = index2adr(L, idx); + switch (ttype(o)) { + case LUA_TUSERDATA: return (rawuvalue(o) + 1); + case LUA_TLIGHTUSERDATA: return pvalue(o); + default: return NULL; + } +} + + +LUA_API lua_State *lua_tothread (lua_State *L, int idx) { + StkId o = index2adr(L, idx); + return (!ttisthread(o)) ? NULL : thvalue(o); +} + + +LUA_API const void *lua_topointer (lua_State *L, int idx) { + StkId o = index2adr(L, idx); + switch (ttype(o)) { + case LUA_TTABLE: return hvalue(o); + case LUA_TFUNCTION: return clvalue(o); + case LUA_TTHREAD: return thvalue(o); + case LUA_TUSERDATA: + case LUA_TLIGHTUSERDATA: + return lua_touserdata(L, idx); + default: return NULL; + } +} + + + +/* +** push functions (C -> stack) +*/ + + +LUA_API void lua_pushnil (lua_State *L) { + lua_lock(L); + setnilvalue(L->top); + api_incr_top(L); + lua_unlock(L); +} + + +LUA_API void lua_pushnumber (lua_State *L, lua_Number n) { + lua_lock(L); + setnvalue(L->top, n); + api_incr_top(L); + lua_unlock(L); +} + + +LUA_API void lua_pushinteger (lua_State *L, lua_Integer n) { + lua_lock(L); + setnvalue(L->top, cast_num(n)); + api_incr_top(L); + lua_unlock(L); +} + + +LUA_API void lua_pushlstring (lua_State *L, const char *s, size_t len) { + lua_lock(L); + luaC_checkGC(L); + setsvalue2s(L, L->top, luaS_newlstr(L, s, len)); + api_incr_top(L); + lua_unlock(L); +} + + +LUA_API void lua_pushstring (lua_State *L, const char *s) { + if (s == NULL) + lua_pushnil(L); + else + lua_pushlstring(L, s, strlen(s)); +} + + +LUA_API const char *lua_pushvfstring (lua_State *L, const char *fmt, + va_list argp) { + const char *ret; + lua_lock(L); + luaC_checkGC(L); + ret = luaO_pushvfstring(L, fmt, argp); + lua_unlock(L); + return ret; +} + + +LUA_API const char *lua_pushfstring (lua_State *L, const char *fmt, ...) { + const char *ret; + va_list argp; + lua_lock(L); + luaC_checkGC(L); + va_start(argp, fmt); + ret = luaO_pushvfstring(L, fmt, argp); + va_end(argp); + lua_unlock(L); + return ret; +} + + +LUA_API void lua_pushcclosure (lua_State *L, lua_CFunction fn, int n) { + Closure *cl; + lua_lock(L); + luaC_checkGC(L); + api_checknelems(L, n); + cl = luaF_newCclosure(L, n, getcurrenv(L)); + cl->c.f = fn; + L->top -= n; + while (n--) + setobj2n(L, &cl->c.upvalue[n], L->top+n); + setclvalue(L, L->top, cl); + lua_assert(iswhite(obj2gco(cl))); + api_incr_top(L); + lua_unlock(L); +} + + +LUA_API void lua_pushboolean (lua_State *L, int b) { + lua_lock(L); + setbvalue(L->top, (b != 0)); /* ensure that true is 1 */ + api_incr_top(L); + lua_unlock(L); +} + + +LUA_API void lua_pushlightuserdata (lua_State *L, void *p) { + lua_lock(L); + setpvalue(L->top, p); + api_incr_top(L); + lua_unlock(L); +} + + +LUA_API int lua_pushthread (lua_State *L) { + lua_lock(L); + setthvalue(L, L->top, L); + api_incr_top(L); + lua_unlock(L); + return (G(L)->mainthread == L); +} + + + +/* +** get functions (Lua -> stack) +*/ + + +LUA_API void lua_gettable (lua_State *L, int idx) { + StkId t; + lua_lock(L); + t = index2adr(L, idx); + api_checkvalidindex(L, t); + luaV_gettable(L, t, L->top - 1, L->top - 1); + lua_unlock(L); +} + + +LUA_API void lua_getfield (lua_State *L, int idx, const char *k) { + StkId t; + TValue key; + lua_lock(L); + t = index2adr(L, idx); + api_checkvalidindex(L, t); + setsvalue(L, &key, luaS_new(L, k)); + luaV_gettable(L, t, &key, L->top); + api_incr_top(L); + lua_unlock(L); +} + + +LUA_API void lua_rawget (lua_State *L, int idx) { + StkId t; + lua_lock(L); + t = index2adr(L, idx); + api_check(L, ttistable(t)); + setobj2s(L, L->top - 1, luaH_get(hvalue(t), L->top - 1)); + lua_unlock(L); +} + + +LUA_API void lua_rawgeti (lua_State *L, int idx, int n) { + StkId o; + lua_lock(L); + o = index2adr(L, idx); + api_check(L, ttistable(o)); + setobj2s(L, L->top, luaH_getnum(hvalue(o), n)); + api_incr_top(L); + lua_unlock(L); +} + + +LUA_API void lua_createtable (lua_State *L, int narray, int nrec) { + lua_lock(L); + luaC_checkGC(L); + sethvalue(L, L->top, luaH_new(L, narray, nrec)); + api_incr_top(L); + lua_unlock(L); +} + + +LUA_API int lua_getmetatable (lua_State *L, int objindex) { + const TValue *obj; + Table *mt = NULL; + int res; + lua_lock(L); + obj = index2adr(L, objindex); + switch (ttype(obj)) { + case LUA_TTABLE: + mt = hvalue(obj)->metatable; + break; + case LUA_TUSERDATA: + mt = uvalue(obj)->metatable; + break; + default: + mt = G(L)->mt[ttype(obj)]; + break; + } + if (mt == NULL) + res = 0; + else { + sethvalue(L, L->top, mt); + api_incr_top(L); + res = 1; + } + lua_unlock(L); + return res; +} + + +LUA_API void lua_getfenv (lua_State *L, int idx) { + StkId o; + lua_lock(L); + o = index2adr(L, idx); + api_checkvalidindex(L, o); + switch (ttype(o)) { + case LUA_TFUNCTION: + sethvalue(L, L->top, clvalue(o)->c.env); + break; + case LUA_TUSERDATA: + sethvalue(L, L->top, uvalue(o)->env); + break; + case LUA_TTHREAD: + setobj2s(L, L->top, gt(thvalue(o))); + break; + default: + setnilvalue(L->top); + break; + } + api_incr_top(L); + lua_unlock(L); +} + + +/* +** set functions (stack -> Lua) +*/ + + +LUA_API void lua_settable (lua_State *L, int idx) { + StkId t; + lua_lock(L); + api_checknelems(L, 2); + t = index2adr(L, idx); + api_checkvalidindex(L, t); + luaV_settable(L, t, L->top - 2, L->top - 1); + L->top -= 2; /* pop index and value */ + lua_unlock(L); +} + + +LUA_API void lua_setfield (lua_State *L, int idx, const char *k) { + StkId t; + TValue key; + lua_lock(L); + api_checknelems(L, 1); + t = index2adr(L, idx); + api_checkvalidindex(L, t); + setsvalue(L, &key, luaS_new(L, k)); + luaV_settable(L, t, &key, L->top - 1); + L->top--; /* pop value */ + lua_unlock(L); +} + + +LUA_API void lua_rawset (lua_State *L, int idx) { + StkId t; + lua_lock(L); + api_checknelems(L, 2); + t = index2adr(L, idx); + api_check(L, ttistable(t)); + setobj2t(L, luaH_set(L, hvalue(t), L->top-2), L->top-1); + luaC_barriert(L, hvalue(t), L->top-1); + L->top -= 2; + lua_unlock(L); +} + + +LUA_API void lua_rawseti (lua_State *L, int idx, int n) { + StkId o; + lua_lock(L); + api_checknelems(L, 1); + o = index2adr(L, idx); + api_check(L, ttistable(o)); + setobj2t(L, luaH_setnum(L, hvalue(o), n), L->top-1); + luaC_barriert(L, hvalue(o), L->top-1); + L->top--; + lua_unlock(L); +} + + +LUA_API int lua_setmetatable (lua_State *L, int objindex) { + TValue *obj; + Table *mt; + lua_lock(L); + api_checknelems(L, 1); + obj = index2adr(L, objindex); + api_checkvalidindex(L, obj); + if (ttisnil(L->top - 1)) + mt = NULL; + else { + api_check(L, ttistable(L->top - 1)); + mt = hvalue(L->top - 1); + } + switch (ttype(obj)) { + case LUA_TTABLE: { + hvalue(obj)->metatable = mt; + if (mt) + luaC_objbarriert(L, hvalue(obj), mt); + break; + } + case LUA_TUSERDATA: { + uvalue(obj)->metatable = mt; + if (mt) + luaC_objbarrier(L, rawuvalue(obj), mt); + break; + } + default: { + G(L)->mt[ttype(obj)] = mt; + break; + } + } + L->top--; + lua_unlock(L); + return 1; +} + + +LUA_API int lua_setfenv (lua_State *L, int idx) { + StkId o; + int res = 1; + lua_lock(L); + api_checknelems(L, 1); + o = index2adr(L, idx); + api_checkvalidindex(L, o); + api_check(L, ttistable(L->top - 1)); + switch (ttype(o)) { + case LUA_TFUNCTION: + clvalue(o)->c.env = hvalue(L->top - 1); + break; + case LUA_TUSERDATA: + uvalue(o)->env = hvalue(L->top - 1); + break; + case LUA_TTHREAD: + sethvalue(L, gt(thvalue(o)), hvalue(L->top - 1)); + break; + default: + res = 0; + break; + } + if (res) luaC_objbarrier(L, gcvalue(o), hvalue(L->top - 1)); + L->top--; + lua_unlock(L); + return res; +} + + +/* +** `load' and `call' functions (run Lua code) +*/ + + +#define adjustresults(L,nres) \ + { if (nres == LUA_MULTRET && L->top >= L->ci->top) L->ci->top = L->top; } + + +#define checkresults(L,na,nr) \ + api_check(L, (nr) == LUA_MULTRET || (L->ci->top - L->top >= (nr) - (na))) + + +LUA_API void lua_call (lua_State *L, int nargs, int nresults) { + StkId func; + lua_lock(L); + api_checknelems(L, nargs+1); + checkresults(L, nargs, nresults); + func = L->top - (nargs+1); + luaD_call(L, func, nresults); + adjustresults(L, nresults); + lua_unlock(L); +} + + + +/* +** Execute a protected call. +*/ +struct CallS { /* data to `f_call' */ + StkId func; + int nresults; +}; + + +static void f_call (lua_State *L, void *ud) { + struct CallS *c = cast(struct CallS *, ud); + luaD_call(L, c->func, c->nresults); +} + + + +LUA_API int lua_pcall (lua_State *L, int nargs, int nresults, int errfunc) { + struct CallS c; + int status; + ptrdiff_t func; + lua_lock(L); + api_checknelems(L, nargs+1); + checkresults(L, nargs, nresults); + if (errfunc == 0) + func = 0; + else { + StkId o = index2adr(L, errfunc); + api_checkvalidindex(L, o); + func = savestack(L, o); + } + c.func = L->top - (nargs+1); /* function to be called */ + c.nresults = nresults; + status = luaD_pcall(L, f_call, &c, savestack(L, c.func), func); + adjustresults(L, nresults); + lua_unlock(L); + return status; +} + + +/* +** Execute a protected C call. +*/ +struct CCallS { /* data to `f_Ccall' */ + lua_CFunction func; + void *ud; +}; + + +static void f_Ccall (lua_State *L, void *ud) { + struct CCallS *c = cast(struct CCallS *, ud); + Closure *cl; + cl = luaF_newCclosure(L, 0, getcurrenv(L)); + cl->c.f = c->func; + setclvalue(L, L->top, cl); /* push function */ + api_incr_top(L); + setpvalue(L->top, c->ud); /* push only argument */ + api_incr_top(L); + luaD_call(L, L->top - 2, 0); +} + + +LUA_API int lua_cpcall (lua_State *L, lua_CFunction func, void *ud) { + struct CCallS c; + int status; + lua_lock(L); + c.func = func; + c.ud = ud; + status = luaD_pcall(L, f_Ccall, &c, savestack(L, L->top), 0); + lua_unlock(L); + return status; +} + + +LUA_API int lua_load (lua_State *L, lua_Reader reader, void *data, + const char *chunkname) { + ZIO z; + int status; + lua_lock(L); + if (!chunkname) chunkname = "?"; + luaZ_init(L, &z, reader, data); + status = luaD_protectedparser(L, &z, chunkname); + lua_unlock(L); + return status; +} + + +LUA_API int lua_dump (lua_State *L, lua_Writer writer, void *data) { + int status; + TValue *o; + lua_lock(L); + api_checknelems(L, 1); + o = L->top - 1; + if (isLfunction(o)) + status = luaU_dump(L, clvalue(o)->l.p, writer, data, 0); + else + status = 1; + lua_unlock(L); + return status; +} + + +LUA_API int lua_status (lua_State *L) { + return L->status; +} + + +/* +** Garbage-collection function +*/ + +LUA_API int lua_gc (lua_State *L, int what, int data) { + int res = 0; + global_State *g; + lua_lock(L); + g = G(L); + switch (what) { + case LUA_GCSTOP: { + g->GCthreshold = MAX_LUMEM; + break; + } + case LUA_GCRESTART: { + g->GCthreshold = g->totalbytes; + break; + } + case LUA_GCCOLLECT: { + luaC_fullgc(L); + break; + } + case LUA_GCCOUNT: { + /* GC values are expressed in Kbytes: #bytes/2^10 */ + res = cast_int(g->totalbytes >> 10); + break; + } + case LUA_GCCOUNTB: { + res = cast_int(g->totalbytes & 0x3ff); + break; + } + case LUA_GCSTEP: { + lu_mem a = (cast(lu_mem, data) << 10); + if (a <= g->totalbytes) + g->GCthreshold = g->totalbytes - a; + else + g->GCthreshold = 0; + while (g->GCthreshold <= g->totalbytes) { + luaC_step(L); + if (g->gcstate == GCSpause) { /* end of cycle? */ + res = 1; /* signal it */ + break; + } + } + break; + } + case LUA_GCSETPAUSE: { + res = g->gcpause; + g->gcpause = data; + break; + } + case LUA_GCSETSTEPMUL: { + res = g->gcstepmul; + g->gcstepmul = data; + break; + } + default: res = -1; /* invalid option */ + } + lua_unlock(L); + return res; +} + + + +/* +** miscellaneous functions +*/ + + +LUA_API int lua_error (lua_State *L) { + lua_lock(L); + api_checknelems(L, 1); + luaG_errormsg(L); + lua_unlock(L); + return 0; /* to avoid warnings */ +} + + +LUA_API int lua_next (lua_State *L, int idx) { + StkId t; + int more; + lua_lock(L); + t = index2adr(L, idx); + api_check(L, ttistable(t)); + more = luaH_next(L, hvalue(t), L->top - 1); + if (more) { + api_incr_top(L); + } + else /* no more elements */ + L->top -= 1; /* remove key */ + lua_unlock(L); + return more; +} + + +LUA_API void lua_concat (lua_State *L, int n) { + lua_lock(L); + api_checknelems(L, n); + if (n >= 2) { + luaC_checkGC(L); + luaV_concat(L, n, cast_int(L->top - L->base) - 1); + L->top -= (n-1); + } + else if (n == 0) { /* push empty string */ + setsvalue2s(L, L->top, luaS_newlstr(L, "", 0)); + api_incr_top(L); + } + /* else n == 1; nothing to do */ + lua_unlock(L); +} + + +LUA_API lua_Alloc lua_getallocf (lua_State *L, void **ud) { + lua_Alloc f; + lua_lock(L); + if (ud) *ud = G(L)->ud; + f = G(L)->frealloc; + lua_unlock(L); + return f; +} + + +LUA_API void lua_setallocf (lua_State *L, lua_Alloc f, void *ud) { + lua_lock(L); + G(L)->ud = ud; + G(L)->frealloc = f; + lua_unlock(L); +} + + +LUA_API void *lua_newuserdata (lua_State *L, size_t size) { + Udata *u; + lua_lock(L); + luaC_checkGC(L); + u = luaS_newudata(L, size, getcurrenv(L)); + setuvalue(L, L->top, u); + api_incr_top(L); + lua_unlock(L); + return u + 1; +} + + + + +static const char *aux_upvalue (StkId fi, int n, TValue **val) { + Closure *f; + if (!ttisfunction(fi)) return NULL; + f = clvalue(fi); + if (f->c.isC) { + if (!(1 <= n && n <= f->c.nupvalues)) return NULL; + *val = &f->c.upvalue[n-1]; + return ""; + } + else { + Proto *p = f->l.p; + if (!(1 <= n && n <= p->sizeupvalues)) return NULL; + *val = f->l.upvals[n-1]->v; + return getstr(p->upvalues[n-1]); + } +} + + +LUA_API const char *lua_getupvalue (lua_State *L, int funcindex, int n) { + const char *name; + TValue *val; + lua_lock(L); + name = aux_upvalue(index2adr(L, funcindex), n, &val); + if (name) { + setobj2s(L, L->top, val); + api_incr_top(L); + } + lua_unlock(L); + return name; +} + + +LUA_API const char *lua_setupvalue (lua_State *L, int funcindex, int n) { + const char *name; + TValue *val; + StkId fi; + lua_lock(L); + fi = index2adr(L, funcindex); + api_checknelems(L, 1); + name = aux_upvalue(fi, n, &val); + if (name) { + L->top--; + setobj(L, val, L->top); + luaC_barrier(L, clvalue(fi), L->top); + } + lua_unlock(L); + return name; +} + + +LUA_API void Lua_ReturnArray(lua_State *L,int Array[],int num) +{ + lua_newtable( L ); + int i; + for (i=0;i +#include +#include +#include +#include +#include + + +/* This file uses only the official API of Lua. +** Any function declared here could be written as an application function. +*/ + +#define lauxlib_c +#define LUA_LIB + +#include "lua.h" + +#include "lauxlib.h" + + +#define FREELIST_REF 0 /* free list of references */ + + +/* convert a stack index to positive */ +#define abs_index(L, i) ((i) > 0 || (i) <= LUA_REGISTRYINDEX ? (i) : \ + lua_gettop(L) + (i) + 1) + + +/* +** {====================================================== +** Error-report functions +** ======================================================= +*/ + + +LUALIB_API int luaL_argerror (lua_State *L, int narg, const char *extramsg) { + lua_Debug ar; + if (!lua_getstack(L, 0, &ar)) /* no stack frame? */ + return luaL_error(L, "bad argument #%d (%s)", narg, extramsg); + lua_getinfo(L, "n", &ar); + if (strcmp(ar.namewhat, "method") == 0) { + narg--; /* do not count `self' */ + if (narg == 0) /* error is in the self argument itself? */ + return luaL_error(L, "calling " LUA_QS " on bad self (%s)", + ar.name, extramsg); + } + if (ar.name == NULL) + ar.name = "?"; + return luaL_error(L, "bad argument #%d to " LUA_QS " (%s)", + narg, ar.name, extramsg); +} + + +LUALIB_API int luaL_typerror (lua_State *L, int narg, const char *tname) { + const char *msg = lua_pushfstring(L, "%s expected, got %s", + tname, luaL_typename(L, narg)); + return luaL_argerror(L, narg, msg); +} + + +static void tag_error (lua_State *L, int narg, int tag) { + luaL_typerror(L, narg, lua_typename(L, tag)); +} + + +LUALIB_API void luaL_where (lua_State *L, int level) { + lua_Debug ar; + if (lua_getstack(L, level, &ar)) { /* check function at level */ + lua_getinfo(L, "Sl", &ar); /* get info about it */ + if (ar.currentline > 0) { /* is there info? */ + lua_pushfstring(L, "%s:%d: ", ar.short_src, ar.currentline); + return; + } + } + lua_pushliteral(L, ""); /* else, no information available... */ +} + + +LUALIB_API int luaL_error (lua_State *L, const char *fmt, ...) { + va_list argp; + va_start(argp, fmt); + luaL_where(L, 1); + lua_pushvfstring(L, fmt, argp); + va_end(argp); + lua_concat(L, 2); + return lua_error(L); +} + +/* }====================================================== */ + + +LUALIB_API int luaL_checkoption (lua_State *L, int narg, const char *def, + const char *const lst[]) { + const char *name = (def) ? luaL_optstring(L, narg, def) : + luaL_checkstring(L, narg); + int i; + for (i=0; lst[i]; i++) + if (strcmp(lst[i], name) == 0) + return i; + return luaL_argerror(L, narg, + lua_pushfstring(L, "invalid option " LUA_QS, name)); +} + + +LUALIB_API int luaL_newmetatable (lua_State *L, const char *tname) { + lua_getfield(L, LUA_REGISTRYINDEX, tname); /* get registry.name */ + if (!lua_isnil(L, -1)) /* name already in use? */ + return 0; /* leave previous value on top, but return 0 */ + lua_pop(L, 1); + lua_newtable(L); /* create metatable */ + lua_pushvalue(L, -1); + lua_setfield(L, LUA_REGISTRYINDEX, tname); /* registry.name = metatable */ + return 1; +} + + +LUALIB_API void *luaL_checkudata (lua_State *L, int ud, const char *tname) { + void *p = lua_touserdata(L, ud); + if (p != NULL) { /* value is a userdata? */ + if (lua_getmetatable(L, ud)) { /* does it have a metatable? */ + lua_getfield(L, LUA_REGISTRYINDEX, tname); /* get correct metatable */ + if (lua_rawequal(L, -1, -2)) { /* does it have the correct mt? */ + lua_pop(L, 2); /* remove both metatables */ + return p; + } + } + } + luaL_typerror(L, ud, tname); /* else error */ + return NULL; /* to avoid warnings */ +} + + +LUALIB_API void luaL_checkstack (lua_State *L, int space, const char *mes) { + if (!lua_checkstack(L, space)) + luaL_error(L, "stack overflow (%s)", mes); +} + + +LUALIB_API void luaL_checktype (lua_State *L, int narg, int t) { + if (lua_type(L, narg) != t) + tag_error(L, narg, t); +} + + +LUALIB_API void luaL_checkany (lua_State *L, int narg) { + if (lua_type(L, narg) == LUA_TNONE) + luaL_argerror(L, narg, "value expected"); +} + + +LUALIB_API const char *luaL_checklstring (lua_State *L, int narg, size_t *len) { + const char *s = lua_tolstring(L, narg, len); + if (!s) tag_error(L, narg, LUA_TSTRING); + return s; +} + + +LUALIB_API const char *luaL_optlstring (lua_State *L, int narg, + const char *def, size_t *len) { + if (lua_isnoneornil(L, narg)) { + if (len) + *len = (def ? strlen(def) : 0); + return def; + } + else return luaL_checklstring(L, narg, len); +} + + +LUALIB_API lua_Number luaL_checknumber (lua_State *L, int narg) { + lua_Number d = lua_tonumber(L, narg); + if (d == 0 && !lua_isnumber(L, narg)) /* avoid extra test when d is not 0 */ + tag_error(L, narg, LUA_TNUMBER); + return d; +} + + +LUALIB_API lua_Number luaL_optnumber (lua_State *L, int narg, lua_Number def) { + return luaL_opt(L, luaL_checknumber, narg, def); +} + + +LUALIB_API lua_Integer luaL_checkinteger (lua_State *L, int narg) { + lua_Integer d = lua_tointeger(L, narg); + if (d == 0 && !lua_isnumber(L, narg)) /* avoid extra test when d is not 0 */ + tag_error(L, narg, LUA_TNUMBER); + return d; +} + + +LUALIB_API lua_Integer luaL_optinteger (lua_State *L, int narg, + lua_Integer def) { + return luaL_opt(L, luaL_checkinteger, narg, def); +} + + +LUALIB_API int luaL_getmetafield (lua_State *L, int obj, const char *event) { + if (!lua_getmetatable(L, obj)) /* no metatable? */ + return 0; + lua_pushstring(L, event); + lua_rawget(L, -2); + if (lua_isnil(L, -1)) { + lua_pop(L, 2); /* remove metatable and metafield */ + return 0; + } + else { + lua_remove(L, -2); /* remove only metatable */ + return 1; + } +} + + +LUALIB_API int luaL_callmeta (lua_State *L, int obj, const char *event) { + obj = abs_index(L, obj); + if (!luaL_getmetafield(L, obj, event)) /* no metafield? */ + return 0; + lua_pushvalue(L, obj); + lua_call(L, 1, 1); + return 1; +} + + +LUALIB_API void (luaL_register) (lua_State *L, const char *libname, + const luaL_Reg *l) { + luaI_openlib(L, libname, l, 0); +} + + +static int libsize (const luaL_Reg *l) { + int size = 0; + for (; l->name; l++) size++; + return size; +} + + +LUALIB_API void luaI_openlib (lua_State *L, const char *libname, + const luaL_Reg *l, int nup) { + if (libname) { + int size = libsize(l); + /* check whether lib already exists */ + luaL_findtable(L, LUA_REGISTRYINDEX, "_LOADED", 1); + lua_getfield(L, -1, libname); /* get _LOADED[libname] */ + if (!lua_istable(L, -1)) { /* not found? */ + lua_pop(L, 1); /* remove previous result */ + /* try global variable (and create one if it does not exist) */ + if (luaL_findtable(L, LUA_GLOBALSINDEX, libname, size) != NULL) + luaL_error(L, "name conflict for module " LUA_QS, libname); + lua_pushvalue(L, -1); + lua_setfield(L, -3, libname); /* _LOADED[libname] = new table */ + } + lua_remove(L, -2); /* remove _LOADED table */ + lua_insert(L, -(nup+1)); /* move library table to below upvalues */ + } + for (; l->name; l++) { + int i; + for (i=0; ifunc, nup); + lua_setfield(L, -(nup+2), l->name); + } + lua_pop(L, nup); /* remove upvalues */ +} + + + +/* +** {====================================================== +** getn-setn: size for arrays +** ======================================================= +*/ + +#if defined(LUA_COMPAT_GETN) + +static int checkint (lua_State *L, int topop) { + int n = (lua_type(L, -1) == LUA_TNUMBER) ? lua_tointeger(L, -1) : -1; + lua_pop(L, topop); + return n; +} + + +static void getsizes (lua_State *L) { + lua_getfield(L, LUA_REGISTRYINDEX, "LUA_SIZES"); + if (lua_isnil(L, -1)) { /* no `size' table? */ + lua_pop(L, 1); /* remove nil */ + lua_newtable(L); /* create it */ + lua_pushvalue(L, -1); /* `size' will be its own metatable */ + lua_setmetatable(L, -2); + lua_pushliteral(L, "kv"); + lua_setfield(L, -2, "__mode"); /* metatable(N).__mode = "kv" */ + lua_pushvalue(L, -1); + lua_setfield(L, LUA_REGISTRYINDEX, "LUA_SIZES"); /* store in register */ + } +} + + +LUALIB_API void luaL_setn (lua_State *L, int t, int n) { + t = abs_index(L, t); + lua_pushliteral(L, "n"); + lua_rawget(L, t); + if (checkint(L, 1) >= 0) { /* is there a numeric field `n'? */ + lua_pushliteral(L, "n"); /* use it */ + lua_pushinteger(L, n); + lua_rawset(L, t); + } + else { /* use `sizes' */ + getsizes(L); + lua_pushvalue(L, t); + lua_pushinteger(L, n); + lua_rawset(L, -3); /* sizes[t] = n */ + lua_pop(L, 1); /* remove `sizes' */ + } +} + + +LUALIB_API int luaL_getn (lua_State *L, int t) { + int n; + t = abs_index(L, t); + lua_pushliteral(L, "n"); /* try t.n */ + lua_rawget(L, t); + if ((n = checkint(L, 1)) >= 0) return n; + getsizes(L); /* else try sizes[t] */ + lua_pushvalue(L, t); + lua_rawget(L, -2); + if ((n = checkint(L, 2)) >= 0) return n; + return (int)lua_objlen(L, t); +} + +#endif + +/* }====================================================== */ + + + +LUALIB_API const char *luaL_gsub (lua_State *L, const char *s, const char *p, + const char *r) { + const char *wild; + size_t l = strlen(p); + luaL_Buffer b; + luaL_buffinit(L, &b); + while ((wild = strstr(s, p)) != NULL) { + luaL_addlstring(&b, s, wild - s); /* push prefix */ + luaL_addstring(&b, r); /* push replacement in place of pattern */ + s = wild + l; /* continue after `p' */ + } + luaL_addstring(&b, s); /* push last suffix */ + luaL_pushresult(&b); + return lua_tostring(L, -1); +} + + +LUALIB_API const char *luaL_findtable (lua_State *L, int idx, + const char *fname, int szhint) { + const char *e; + lua_pushvalue(L, idx); + do { + e = strchr(fname, '.'); + if (e == NULL) e = fname + strlen(fname); + lua_pushlstring(L, fname, e - fname); + lua_rawget(L, -2); + if (lua_isnil(L, -1)) { /* no such field? */ + lua_pop(L, 1); /* remove this nil */ + lua_createtable(L, 0, (*e == '.' ? 1 : szhint)); /* new table for field */ + lua_pushlstring(L, fname, e - fname); + lua_pushvalue(L, -2); + lua_settable(L, -4); /* set new table into field */ + } + else if (!lua_istable(L, -1)) { /* field has a non-table value? */ + lua_pop(L, 2); /* remove table and value */ + return fname; /* return problematic part of the name */ + } + lua_remove(L, -2); /* remove previous table */ + fname = e + 1; + } while (*e == '.'); + return NULL; +} + + + +/* +** {====================================================== +** Generic Buffer manipulation +** ======================================================= +*/ + + +#define bufflen(B) ((B)->p - (B)->buffer) +#define bufffree(B) ((size_t)(LUAL_BUFFERSIZE - bufflen(B))) + +#define LIMIT (LUA_MINSTACK/2) + + +static int emptybuffer (luaL_Buffer *B) { + size_t l = bufflen(B); + if (l == 0) return 0; /* put nothing on stack */ + else { + lua_pushlstring(B->L, B->buffer, l); + B->p = B->buffer; + B->lvl++; + return 1; + } +} + + +static void adjuststack (luaL_Buffer *B) { + if (B->lvl > 1) { + lua_State *L = B->L; + int toget = 1; /* number of levels to concat */ + size_t toplen = lua_strlen(L, -1); + do { + size_t l = lua_strlen(L, -(toget+1)); + if (B->lvl - toget + 1 >= LIMIT || toplen > l) { + toplen += l; + toget++; + } + else break; + } while (toget < B->lvl); + lua_concat(L, toget); + B->lvl = B->lvl - toget + 1; + } +} + + +LUALIB_API char *luaL_prepbuffer (luaL_Buffer *B) { + if (emptybuffer(B)) + adjuststack(B); + return B->buffer; +} + + +LUALIB_API void luaL_addlstring (luaL_Buffer *B, const char *s, size_t l) { + while (l--) + luaL_addchar(B, *s++); +} + + +LUALIB_API void luaL_addstring (luaL_Buffer *B, const char *s) { + luaL_addlstring(B, s, strlen(s)); +} + + +LUALIB_API void luaL_pushresult (luaL_Buffer *B) { + emptybuffer(B); + lua_concat(B->L, B->lvl); + B->lvl = 1; +} + + +LUALIB_API void luaL_addvalue (luaL_Buffer *B) { + lua_State *L = B->L; + size_t vl; + const char *s = lua_tolstring(L, -1, &vl); + if (vl <= bufffree(B)) { /* fit into buffer? */ + memcpy(B->p, s, vl); /* put it there */ + B->p += vl; + lua_pop(L, 1); /* remove from stack */ + } + else { + if (emptybuffer(B)) + lua_insert(L, -2); /* put buffer before new value */ + B->lvl++; /* add new value into B stack */ + adjuststack(B); + } +} + + +LUALIB_API void luaL_buffinit (lua_State *L, luaL_Buffer *B) { + B->L = L; + B->p = B->buffer; + B->lvl = 0; +} + +/* }====================================================== */ + + +LUALIB_API int luaL_ref (lua_State *L, int t) { + int ref; + t = abs_index(L, t); + if (lua_isnil(L, -1)) { + lua_pop(L, 1); /* remove from stack */ + return LUA_REFNIL; /* `nil' has a unique fixed reference */ + } + lua_rawgeti(L, t, FREELIST_REF); /* get first free element */ + ref = (int)lua_tointeger(L, -1); /* ref = t[FREELIST_REF] */ + lua_pop(L, 1); /* remove it from stack */ + if (ref != 0) { /* any free element? */ + lua_rawgeti(L, t, ref); /* remove it from list */ + lua_rawseti(L, t, FREELIST_REF); /* (t[FREELIST_REF] = t[ref]) */ + } + else { /* no free elements */ + ref = (int)lua_objlen(L, t); + ref++; /* create new reference */ + } + lua_rawseti(L, t, ref); + return ref; +} + + +LUALIB_API void luaL_unref (lua_State *L, int t, int ref) { + if (ref >= 0) { + t = abs_index(L, t); + lua_rawgeti(L, t, FREELIST_REF); + lua_rawseti(L, t, ref); /* t[ref] = t[FREELIST_REF] */ + lua_pushinteger(L, ref); + lua_rawseti(L, t, FREELIST_REF); /* t[FREELIST_REF] = ref */ + } +} + + + +/* +** {====================================================== +** Load functions +** ======================================================= +*/ + +typedef struct LoadF { + int extraline; + FILE *f; + char buff[LUAL_BUFFERSIZE]; +} LoadF; + + +static const char *getF (lua_State *L, void *ud, size_t *size) { + LoadF *lf = (LoadF *)ud; + (void)L; + if (lf->extraline) { + lf->extraline = 0; + *size = 1; + return "\n"; + } + if (feof(lf->f)) return NULL; + *size = fread(lf->buff, 1, sizeof(lf->buff), lf->f); + return (*size > 0) ? lf->buff : NULL; +} + + +static int errfile (lua_State *L, const char *what, int fnameindex) { + const char *serr = strerror(errno); + const char *filename = lua_tostring(L, fnameindex) + 1; + lua_pushfstring(L, "cannot %s %s: %s", what, filename, serr); + lua_remove(L, fnameindex); + return LUA_ERRFILE; +} + + +LUALIB_API int luaL_loadfile (lua_State *L, const char *filename) { + LoadF lf; + int status, readstatus; + int c; + int fnameindex = lua_gettop(L) + 1; /* index of filename on the stack */ + lf.extraline = 0; + if (filename == NULL) { + lua_pushliteral(L, "=stdin"); + lf.f = stdin; + } + else { + lua_pushfstring(L, "@%s", filename); + lf.f = fopen(filename, "r"); + if (lf.f == NULL) return errfile(L, "open", fnameindex); + } + c = getc(lf.f); + if (c == '#') { /* Unix exec. file? */ + lf.extraline = 1; + while ((c = getc(lf.f)) != EOF && c != '\n') ; /* skip first line */ + if (c == '\n') c = getc(lf.f); + } + if (c == LUA_SIGNATURE[0] && filename) { /* binary file? */ + lf.f = freopen(filename, "rb", lf.f); /* reopen in binary mode */ + if (lf.f == NULL) return errfile(L, "reopen", fnameindex); + /* skip eventual `#!...' */ + while ((c = getc(lf.f)) != EOF && c != LUA_SIGNATURE[0]) ; + lf.extraline = 0; + } + ungetc(c, lf.f); + status = lua_load(L, getF, &lf, lua_tostring(L, -1)); + readstatus = ferror(lf.f); + if (filename) fclose(lf.f); /* close file (even in case of errors) */ + if (readstatus) { + lua_settop(L, fnameindex); /* ignore results from `lua_load' */ + return errfile(L, "read", fnameindex); + } + lua_remove(L, fnameindex); + return status; +} + + +typedef struct LoadS { + const char *s; + size_t size; +} LoadS; + + +static const char *getS (lua_State *L, void *ud, size_t *size) { + LoadS *ls = (LoadS *)ud; + (void)L; + if (ls->size == 0) return NULL; + *size = ls->size; + ls->size = 0; + return ls->s; +} + + +LUALIB_API int luaL_loadbuffer (lua_State *L, const char *buff, size_t size, + const char *name) { + LoadS ls; + ls.s = buff; + ls.size = size; + return lua_load(L, getS, &ls, name); +} + + +LUALIB_API int (luaL_loadstring) (lua_State *L, const char *s) { + return luaL_loadbuffer(L, s, strlen(s), s); +} + + + +/* }====================================================== */ + + +static void *l_alloc (void *ud, void *ptr, size_t osize, size_t nsize) { + (void)ud; + (void)osize; + if (nsize == 0) { + free(ptr); + return NULL; + } + else + return realloc(ptr, nsize); +} + + +static int panic (lua_State *L) { + (void)L; /* to avoid warnings */ + fprintf(stderr, "PANIC: unprotected error in call to Lua API (%s)\n", + lua_tostring(L, -1)); + return 0; +} + + +LUALIB_API lua_State *luaL_newstate (void) { + lua_State *L = lua_newstate(l_alloc, NULL); + if (L) lua_atpanic(L, &panic); + return L; +} + diff --git a/mylua/lua/lauxlib.h b/mylua/lua/lauxlib.h new file mode 100644 index 0000000..3425823 --- /dev/null +++ b/mylua/lua/lauxlib.h @@ -0,0 +1,174 @@ +/* +** $Id: lauxlib.h,v 1.88.1.1 2007/12/27 13:02:25 roberto Exp $ +** Auxiliary functions for building Lua libraries +** See Copyright Notice in lua.h +*/ + + +#ifndef lauxlib_h +#define lauxlib_h + + +#include +#include + +#include "lua.h" + + +#if defined(LUA_COMPAT_GETN) +LUALIB_API int (luaL_getn) (lua_State *L, int t); +LUALIB_API void (luaL_setn) (lua_State *L, int t, int n); +#else +#define luaL_getn(L,i) ((int)lua_objlen(L, i)) +#define luaL_setn(L,i,j) ((void)0) /* no op! */ +#endif + +#if defined(LUA_COMPAT_OPENLIB) +#define luaI_openlib luaL_openlib +#endif + + +/* extra error code for `luaL_load' */ +#define LUA_ERRFILE (LUA_ERRERR+1) + + +typedef struct luaL_Reg { + const char *name; + lua_CFunction func; +} luaL_Reg; + + + +LUALIB_API void (luaI_openlib) (lua_State *L, const char *libname, + const luaL_Reg *l, int nup); +LUALIB_API void (luaL_register) (lua_State *L, const char *libname, + const luaL_Reg *l); +LUALIB_API int (luaL_getmetafield) (lua_State *L, int obj, const char *e); +LUALIB_API int (luaL_callmeta) (lua_State *L, int obj, const char *e); +LUALIB_API int (luaL_typerror) (lua_State *L, int narg, const char *tname); +LUALIB_API int (luaL_argerror) (lua_State *L, int numarg, const char *extramsg); +LUALIB_API const char *(luaL_checklstring) (lua_State *L, int numArg, + size_t *l); +LUALIB_API const char *(luaL_optlstring) (lua_State *L, int numArg, + const char *def, size_t *l); +LUALIB_API lua_Number (luaL_checknumber) (lua_State *L, int numArg); +LUALIB_API lua_Number (luaL_optnumber) (lua_State *L, int nArg, lua_Number def); + +LUALIB_API lua_Integer (luaL_checkinteger) (lua_State *L, int numArg); +LUALIB_API lua_Integer (luaL_optinteger) (lua_State *L, int nArg, + lua_Integer def); + +LUALIB_API void (luaL_checkstack) (lua_State *L, int sz, const char *msg); +LUALIB_API void (luaL_checktype) (lua_State *L, int narg, int t); +LUALIB_API void (luaL_checkany) (lua_State *L, int narg); + +LUALIB_API int (luaL_newmetatable) (lua_State *L, const char *tname); +LUALIB_API void *(luaL_checkudata) (lua_State *L, int ud, const char *tname); + +LUALIB_API void (luaL_where) (lua_State *L, int lvl); +LUALIB_API int (luaL_error) (lua_State *L, const char *fmt, ...); + +LUALIB_API int (luaL_checkoption) (lua_State *L, int narg, const char *def, + const char *const lst[]); + +LUALIB_API int (luaL_ref) (lua_State *L, int t); +LUALIB_API void (luaL_unref) (lua_State *L, int t, int ref); + +LUALIB_API int (luaL_loadfile) (lua_State *L, const char *filename); +LUALIB_API int (luaL_loadbuffer) (lua_State *L, const char *buff, size_t sz, + const char *name); +LUALIB_API int (luaL_loadstring) (lua_State *L, const char *s); + +LUALIB_API lua_State *(luaL_newstate) (void); + + +LUALIB_API const char *(luaL_gsub) (lua_State *L, const char *s, const char *p, + const char *r); + +LUALIB_API const char *(luaL_findtable) (lua_State *L, int idx, + const char *fname, int szhint); + + + + +/* +** =============================================================== +** some useful macros +** =============================================================== +*/ + +#define luaL_argcheck(L, cond,numarg,extramsg) \ + ((void)((cond) || luaL_argerror(L, (numarg), (extramsg)))) +#define luaL_checkstring(L,n) (luaL_checklstring(L, (n), NULL)) +#define luaL_optstring(L,n,d) (luaL_optlstring(L, (n), (d), NULL)) +#define luaL_checkint(L,n) ((int)luaL_checkinteger(L, (n))) +#define luaL_optint(L,n,d) ((int)luaL_optinteger(L, (n), (d))) +#define luaL_checklong(L,n) ((long)luaL_checkinteger(L, (n))) +#define luaL_optlong(L,n,d) ((long)luaL_optinteger(L, (n), (d))) + +#define luaL_typename(L,i) lua_typename(L, lua_type(L,(i))) + +#define luaL_dofile(L, fn) \ + (luaL_loadfile(L, fn) || lua_pcall(L, 0, LUA_MULTRET, 0)) + +#define luaL_dostring(L, s) \ + (luaL_loadstring(L, s) || lua_pcall(L, 0, LUA_MULTRET, 0)) + +#define luaL_getmetatable(L,n) (lua_getfield(L, LUA_REGISTRYINDEX, (n))) + +#define luaL_opt(L,f,n,d) (lua_isnoneornil(L,(n)) ? (d) : f(L,(n))) + +/* +** {====================================================== +** Generic Buffer manipulation +** ======================================================= +*/ + + + +typedef struct luaL_Buffer { + char *p; /* current position in buffer */ + int lvl; /* number of strings in the stack (level) */ + lua_State *L; + char buffer[LUAL_BUFFERSIZE]; +} luaL_Buffer; + +#define luaL_addchar(B,c) \ + ((void)((B)->p < ((B)->buffer+LUAL_BUFFERSIZE) || luaL_prepbuffer(B)), \ + (*(B)->p++ = (char)(c))) + +/* compatibility only */ +#define luaL_putchar(B,c) luaL_addchar(B,c) + +#define luaL_addsize(B,n) ((B)->p += (n)) + +LUALIB_API void (luaL_buffinit) (lua_State *L, luaL_Buffer *B); +LUALIB_API char *(luaL_prepbuffer) (luaL_Buffer *B); +LUALIB_API void (luaL_addlstring) (luaL_Buffer *B, const char *s, size_t l); +LUALIB_API void (luaL_addstring) (luaL_Buffer *B, const char *s); +LUALIB_API void (luaL_addvalue) (luaL_Buffer *B); +LUALIB_API void (luaL_pushresult) (luaL_Buffer *B); + + +/* }====================================================== */ + + +/* compatibility with ref system */ + +/* pre-defined references */ +#define LUA_NOREF (-2) +#define LUA_REFNIL (-1) + +#define lua_ref(L,lock) ((lock) ? luaL_ref(L, LUA_REGISTRYINDEX) : \ + (lua_pushstring(L, "unlocked references are obsolete"), lua_error(L), 0)) + +#define lua_unref(L,ref) luaL_unref(L, LUA_REGISTRYINDEX, (ref)) + +#define lua_getref(L,ref) lua_rawgeti(L, LUA_REGISTRYINDEX, (ref)) + + +#define luaL_reg luaL_Reg + +#endif + + diff --git a/mylua/lua/lbaselib.c b/mylua/lua/lbaselib.c new file mode 100644 index 0000000..2a4c079 --- /dev/null +++ b/mylua/lua/lbaselib.c @@ -0,0 +1,653 @@ +/* +** $Id: lbaselib.c,v 1.191.1.6 2008/02/14 16:46:22 roberto Exp $ +** Basic library +** See Copyright Notice in lua.h +*/ + + + +#include +#include +#include +#include + +#define lbaselib_c +#define LUA_LIB + +#include "lua.h" + +#include "lauxlib.h" +#include "lualib.h" + + + + +/* +** If your system does not support `stdout', you can just remove this function. +** If you need, you can define your own `print' function, following this +** model but changing `fputs' to put the strings at a proper place +** (a console window or a log file, for instance). +*/ +static int luaB_print (lua_State *L) { + int n = lua_gettop(L); /* number of arguments */ + int i; + lua_getglobal(L, "tostring"); + for (i=1; i<=n; i++) { + const char *s; + lua_pushvalue(L, -1); /* function to be called */ + lua_pushvalue(L, i); /* value to print */ + lua_call(L, 1, 1); + s = lua_tostring(L, -1); /* get result */ + if (s == NULL) + return luaL_error(L, LUA_QL("tostring") " must return a string to " + LUA_QL("print")); + if (i>1) fputs("\t", stdout); + fputs(s, stdout); + lua_pop(L, 1); /* pop result */ + } + fputs("\n", stdout); + return 0; +} + + +static int luaB_tonumber (lua_State *L) { + int base = luaL_optint(L, 2, 10); + if (base == 10) { /* standard conversion */ + luaL_checkany(L, 1); + if (lua_isnumber(L, 1)) { + lua_pushnumber(L, lua_tonumber(L, 1)); + return 1; + } + } + else { + const char *s1 = luaL_checkstring(L, 1); + char *s2; + unsigned long n; + luaL_argcheck(L, 2 <= base && base <= 36, 2, "base out of range"); + n = strtoul(s1, &s2, base); + if (s1 != s2) { /* at least one valid digit? */ + while (isspace((unsigned char)(*s2))) s2++; /* skip trailing spaces */ + if (*s2 == '\0') { /* no invalid trailing characters? */ + lua_pushnumber(L, (lua_Number)n); + return 1; + } + } + } + lua_pushnil(L); /* else not a number */ + return 1; +} + + +static int luaB_error (lua_State *L) { + int level = luaL_optint(L, 2, 1); + lua_settop(L, 1); + if (lua_isstring(L, 1) && level > 0) { /* add extra information? */ + luaL_where(L, level); + lua_pushvalue(L, 1); + lua_concat(L, 2); + } + return lua_error(L); +} + + +static int luaB_getmetatable (lua_State *L) { + luaL_checkany(L, 1); + if (!lua_getmetatable(L, 1)) { + lua_pushnil(L); + return 1; /* no metatable */ + } + luaL_getmetafield(L, 1, "__metatable"); + return 1; /* returns either __metatable field (if present) or metatable */ +} + + +static int luaB_setmetatable (lua_State *L) { + int t = lua_type(L, 2); + luaL_checktype(L, 1, LUA_TTABLE); + luaL_argcheck(L, t == LUA_TNIL || t == LUA_TTABLE, 2, + "nil or table expected"); + if (luaL_getmetafield(L, 1, "__metatable")) + luaL_error(L, "cannot change a protected metatable"); + lua_settop(L, 2); + lua_setmetatable(L, 1); + return 1; +} + + +static void getfunc (lua_State *L, int opt) { + if (lua_isfunction(L, 1)) lua_pushvalue(L, 1); + else { + lua_Debug ar; + int level = opt ? luaL_optint(L, 1, 1) : luaL_checkint(L, 1); + luaL_argcheck(L, level >= 0, 1, "level must be non-negative"); + if (lua_getstack(L, level, &ar) == 0) + luaL_argerror(L, 1, "invalid level"); + lua_getinfo(L, "f", &ar); + if (lua_isnil(L, -1)) + luaL_error(L, "no function environment for tail call at level %d", + level); + } +} + + +static int luaB_getfenv (lua_State *L) { + getfunc(L, 1); + if (lua_iscfunction(L, -1)) /* is a C function? */ + lua_pushvalue(L, LUA_GLOBALSINDEX); /* return the thread's global env. */ + else + lua_getfenv(L, -1); + return 1; +} + + +static int luaB_setfenv (lua_State *L) { + luaL_checktype(L, 2, LUA_TTABLE); + getfunc(L, 0); + lua_pushvalue(L, 2); + if (lua_isnumber(L, 1) && lua_tonumber(L, 1) == 0) { + /* change environment of current thread */ + lua_pushthread(L); + lua_insert(L, -2); + lua_setfenv(L, -2); + return 0; + } + else if (lua_iscfunction(L, -2) || lua_setfenv(L, -2) == 0) + luaL_error(L, + LUA_QL("setfenv") " cannot change environment of given object"); + return 1; +} + + +static int luaB_rawequal (lua_State *L) { + luaL_checkany(L, 1); + luaL_checkany(L, 2); + lua_pushboolean(L, lua_rawequal(L, 1, 2)); + return 1; +} + + +static int luaB_rawget (lua_State *L) { + luaL_checktype(L, 1, LUA_TTABLE); + luaL_checkany(L, 2); + lua_settop(L, 2); + lua_rawget(L, 1); + return 1; +} + +static int luaB_rawset (lua_State *L) { + luaL_checktype(L, 1, LUA_TTABLE); + luaL_checkany(L, 2); + luaL_checkany(L, 3); + lua_settop(L, 3); + lua_rawset(L, 1); + return 1; +} + + +static int luaB_gcinfo (lua_State *L) { + lua_pushinteger(L, lua_getgccount(L)); + return 1; +} + + +static int luaB_collectgarbage (lua_State *L) { + static const char *const opts[] = {"stop", "restart", "collect", + "count", "step", "setpause", "setstepmul", NULL}; + static const int optsnum[] = {LUA_GCSTOP, LUA_GCRESTART, LUA_GCCOLLECT, + LUA_GCCOUNT, LUA_GCSTEP, LUA_GCSETPAUSE, LUA_GCSETSTEPMUL}; + int o = luaL_checkoption(L, 1, "collect", opts); + int ex = luaL_optint(L, 2, 0); + int res = lua_gc(L, optsnum[o], ex); + switch (optsnum[o]) { + case LUA_GCCOUNT: { + int b = lua_gc(L, LUA_GCCOUNTB, 0); + lua_pushnumber(L, res + ((lua_Number)b/1024)); + return 1; + } + case LUA_GCSTEP: { + lua_pushboolean(L, res); + return 1; + } + default: { + lua_pushnumber(L, res); + return 1; + } + } +} + + +static int luaB_type (lua_State *L) { + luaL_checkany(L, 1); + lua_pushstring(L, luaL_typename(L, 1)); + return 1; +} + + +static int luaB_next (lua_State *L) { + luaL_checktype(L, 1, LUA_TTABLE); + lua_settop(L, 2); /* create a 2nd argument if there isn't one */ + if (lua_next(L, 1)) + return 2; + else { + lua_pushnil(L); + return 1; + } +} + + +static int luaB_pairs (lua_State *L) { + luaL_checktype(L, 1, LUA_TTABLE); + lua_pushvalue(L, lua_upvalueindex(1)); /* return generator, */ + lua_pushvalue(L, 1); /* state, */ + lua_pushnil(L); /* and initial value */ + return 3; +} + + +static int ipairsaux (lua_State *L) { + int i = luaL_checkint(L, 2); + luaL_checktype(L, 1, LUA_TTABLE); + i++; /* next value */ + lua_pushinteger(L, i); + lua_rawgeti(L, 1, i); + return (lua_isnil(L, -1)) ? 0 : 2; +} + + +static int luaB_ipairs (lua_State *L) { + luaL_checktype(L, 1, LUA_TTABLE); + lua_pushvalue(L, lua_upvalueindex(1)); /* return generator, */ + lua_pushvalue(L, 1); /* state, */ + lua_pushinteger(L, 0); /* and initial value */ + return 3; +} + + +static int load_aux (lua_State *L, int status) { + if (status == 0) /* OK? */ + return 1; + else { + lua_pushnil(L); + lua_insert(L, -2); /* put before error message */ + return 2; /* return nil plus error message */ + } +} + + +static int luaB_loadstring (lua_State *L) { + size_t l; + const char *s = luaL_checklstring(L, 1, &l); + const char *chunkname = luaL_optstring(L, 2, s); + return load_aux(L, luaL_loadbuffer(L, s, l, chunkname)); +} + + +static int luaB_loadfile (lua_State *L) { + const char *fname = luaL_optstring(L, 1, NULL); + return load_aux(L, luaL_loadfile(L, fname)); +} + + +/* +** Reader for generic `load' function: `lua_load' uses the +** stack for internal stuff, so the reader cannot change the +** stack top. Instead, it keeps its resulting string in a +** reserved slot inside the stack. +*/ +static const char *generic_reader (lua_State *L, void *ud, size_t *size) { + (void)ud; /* to avoid warnings */ + luaL_checkstack(L, 2, "too many nested functions"); + lua_pushvalue(L, 1); /* get function */ + lua_call(L, 0, 1); /* call it */ + if (lua_isnil(L, -1)) { + *size = 0; + return NULL; + } + else if (lua_isstring(L, -1)) { + lua_replace(L, 3); /* save string in a reserved stack slot */ + return lua_tolstring(L, 3, size); + } + else luaL_error(L, "reader function must return a string"); + return NULL; /* to avoid warnings */ +} + + +static int luaB_load (lua_State *L) { + int status; + const char *cname = luaL_optstring(L, 2, "=(load)"); + luaL_checktype(L, 1, LUA_TFUNCTION); + lua_settop(L, 3); /* function, eventual name, plus one reserved slot */ + status = lua_load(L, generic_reader, NULL, cname); + return load_aux(L, status); +} + + +static int luaB_dofile (lua_State *L) { + const char *fname = luaL_optstring(L, 1, NULL); + int n = lua_gettop(L); + if (luaL_loadfile(L, fname) != 0) lua_error(L); + lua_call(L, 0, LUA_MULTRET); + return lua_gettop(L) - n; +} + + +static int luaB_assert (lua_State *L) { + luaL_checkany(L, 1); + if (!lua_toboolean(L, 1)) + return luaL_error(L, "%s", luaL_optstring(L, 2, "assertion failed!")); + return lua_gettop(L); +} + + +static int luaB_unpack (lua_State *L) { + int i, e, n; + luaL_checktype(L, 1, LUA_TTABLE); + i = luaL_optint(L, 2, 1); + e = luaL_opt(L, luaL_checkint, 3, luaL_getn(L, 1)); + if (i > e) return 0; /* empty range */ + n = e - i + 1; /* number of elements */ + if (n <= 0 || !lua_checkstack(L, n)) /* n <= 0 means arith. overflow */ + return luaL_error(L, "too many results to unpack"); + lua_rawgeti(L, 1, i); /* push arg[i] (avoiding overflow problems) */ + while (i++ < e) /* push arg[i + 1...e] */ + lua_rawgeti(L, 1, i); + return n; +} + + +static int luaB_select (lua_State *L) { + int n = lua_gettop(L); + if (lua_type(L, 1) == LUA_TSTRING && *lua_tostring(L, 1) == '#') { + lua_pushinteger(L, n-1); + return 1; + } + else { + int i = luaL_checkint(L, 1); + if (i < 0) i = n + i; + else if (i > n) i = n; + luaL_argcheck(L, 1 <= i, 1, "index out of range"); + return n - i; + } +} + + +static int luaB_pcall (lua_State *L) { + int status; + luaL_checkany(L, 1); + status = lua_pcall(L, lua_gettop(L) - 1, LUA_MULTRET, 0); + lua_pushboolean(L, (status == 0)); + lua_insert(L, 1); + return lua_gettop(L); /* return status + all results */ +} + + +static int luaB_xpcall (lua_State *L) { + int status; + luaL_checkany(L, 2); + lua_settop(L, 2); + lua_insert(L, 1); /* put error function under function to be called */ + status = lua_pcall(L, 0, LUA_MULTRET, 1); + lua_pushboolean(L, (status == 0)); + lua_replace(L, 1); + return lua_gettop(L); /* return status + all results */ +} + + +static int luaB_tostring (lua_State *L) { + luaL_checkany(L, 1); + if (luaL_callmeta(L, 1, "__tostring")) /* is there a metafield? */ + return 1; /* use its value */ + switch (lua_type(L, 1)) { + case LUA_TNUMBER: + lua_pushstring(L, lua_tostring(L, 1)); + break; + case LUA_TSTRING: + lua_pushvalue(L, 1); + break; + case LUA_TBOOLEAN: + lua_pushstring(L, (lua_toboolean(L, 1) ? "true" : "false")); + break; + case LUA_TNIL: + lua_pushliteral(L, "nil"); + break; + default: + lua_pushfstring(L, "%s: %p", luaL_typename(L, 1), lua_topointer(L, 1)); + break; + } + return 1; +} + + +static int luaB_newproxy (lua_State *L) { + lua_settop(L, 1); + lua_newuserdata(L, 0); /* create proxy */ + if (lua_toboolean(L, 1) == 0) + return 1; /* no metatable */ + else if (lua_isboolean(L, 1)) { + lua_newtable(L); /* create a new metatable `m' ... */ + lua_pushvalue(L, -1); /* ... and mark `m' as a valid metatable */ + lua_pushboolean(L, 1); + lua_rawset(L, lua_upvalueindex(1)); /* weaktable[m] = true */ + } + else { + int validproxy = 0; /* to check if weaktable[metatable(u)] == true */ + if (lua_getmetatable(L, 1)) { + lua_rawget(L, lua_upvalueindex(1)); + validproxy = lua_toboolean(L, -1); + lua_pop(L, 1); /* remove value */ + } + luaL_argcheck(L, validproxy, 1, "boolean or proxy expected"); + lua_getmetatable(L, 1); /* metatable is valid; get it */ + } + lua_setmetatable(L, 2); + return 1; +} + + +static const luaL_Reg base_funcs[] = { + {"assert", luaB_assert}, + {"collectgarbage", luaB_collectgarbage}, + {"dofile", luaB_dofile}, + {"error", luaB_error}, + {"gcinfo", luaB_gcinfo}, + {"getfenv", luaB_getfenv}, + {"getmetatable", luaB_getmetatable}, + {"loadfile", luaB_loadfile}, + {"load", luaB_load}, + {"loadstring", luaB_loadstring}, + {"next", luaB_next}, + {"pcall", luaB_pcall}, + {"print", luaB_print}, + {"rawequal", luaB_rawequal}, + {"rawget", luaB_rawget}, + {"rawset", luaB_rawset}, + {"select", luaB_select}, + {"setfenv", luaB_setfenv}, + {"setmetatable", luaB_setmetatable}, + {"tonumber", luaB_tonumber}, + {"tostring", luaB_tostring}, + {"type", luaB_type}, + {"unpack", luaB_unpack}, + {"xpcall", luaB_xpcall}, + {NULL, NULL} +}; + + +/* +** {====================================================== +** Coroutine library +** ======================================================= +*/ + +#define CO_RUN 0 /* running */ +#define CO_SUS 1 /* suspended */ +#define CO_NOR 2 /* 'normal' (it resumed another coroutine) */ +#define CO_DEAD 3 + +static const char *const statnames[] = + {"running", "suspended", "normal", "dead"}; + +static int costatus (lua_State *L, lua_State *co) { + if (L == co) return CO_RUN; + switch (lua_status(co)) { + case LUA_YIELD: + return CO_SUS; + case 0: { + lua_Debug ar; + if (lua_getstack(co, 0, &ar) > 0) /* does it have frames? */ + return CO_NOR; /* it is running */ + else if (lua_gettop(co) == 0) + return CO_DEAD; + else + return CO_SUS; /* initial state */ + } + default: /* some error occured */ + return CO_DEAD; + } +} + + +static int luaB_costatus (lua_State *L) { + lua_State *co = lua_tothread(L, 1); + luaL_argcheck(L, co, 1, "coroutine expected"); + lua_pushstring(L, statnames[costatus(L, co)]); + return 1; +} + + +static int auxresume (lua_State *L, lua_State *co, int narg) { + int status = costatus(L, co); + if (!lua_checkstack(co, narg)) + luaL_error(L, "too many arguments to resume"); + if (status != CO_SUS) { + lua_pushfstring(L, "cannot resume %s coroutine", statnames[status]); + return -1; /* error flag */ + } + lua_xmove(L, co, narg); + lua_setlevel(L, co); + status = lua_resume(co, narg); + if (status == 0 || status == LUA_YIELD) { + int nres = lua_gettop(co); + if (!lua_checkstack(L, nres + 1)) + luaL_error(L, "too many results to resume"); + lua_xmove(co, L, nres); /* move yielded values */ + return nres; + } + else { + lua_xmove(co, L, 1); /* move error message */ + return -1; /* error flag */ + } +} + + +static int luaB_coresume (lua_State *L) { + lua_State *co = lua_tothread(L, 1); + int r; + luaL_argcheck(L, co, 1, "coroutine expected"); + r = auxresume(L, co, lua_gettop(L) - 1); + if (r < 0) { + lua_pushboolean(L, 0); + lua_insert(L, -2); + return 2; /* return false + error message */ + } + else { + lua_pushboolean(L, 1); + lua_insert(L, -(r + 1)); + return r + 1; /* return true + `resume' returns */ + } +} + + +static int luaB_auxwrap (lua_State *L) { + lua_State *co = lua_tothread(L, lua_upvalueindex(1)); + int r = auxresume(L, co, lua_gettop(L)); + if (r < 0) { + if (lua_isstring(L, -1)) { /* error object is a string? */ + luaL_where(L, 1); /* add extra info */ + lua_insert(L, -2); + lua_concat(L, 2); + } + lua_error(L); /* propagate error */ + } + return r; +} + + +static int luaB_cocreate (lua_State *L) { + lua_State *NL = lua_newthread(L); + luaL_argcheck(L, lua_isfunction(L, 1) && !lua_iscfunction(L, 1), 1, + "Lua function expected"); + lua_pushvalue(L, 1); /* move function to top */ + lua_xmove(L, NL, 1); /* move function from L to NL */ + return 1; +} + + +static int luaB_cowrap (lua_State *L) { + luaB_cocreate(L); + lua_pushcclosure(L, luaB_auxwrap, 1); + return 1; +} + + +static int luaB_yield (lua_State *L) { + return lua_yield(L, lua_gettop(L)); +} + + +static int luaB_corunning (lua_State *L) { + if (lua_pushthread(L)) + lua_pushnil(L); /* main thread is not a coroutine */ + return 1; +} + + +static const luaL_Reg co_funcs[] = { + {"create", luaB_cocreate}, + {"resume", luaB_coresume}, + {"running", luaB_corunning}, + {"status", luaB_costatus}, + {"wrap", luaB_cowrap}, + {"yield", luaB_yield}, + {NULL, NULL} +}; + +/* }====================================================== */ + + +static void auxopen (lua_State *L, const char *name, + lua_CFunction f, lua_CFunction u) { + lua_pushcfunction(L, u); + lua_pushcclosure(L, f, 1); + lua_setfield(L, -2, name); +} + + +static void base_open (lua_State *L) { + /* set global _G */ + lua_pushvalue(L, LUA_GLOBALSINDEX); + lua_setglobal(L, "_G"); + /* open lib into global table */ + luaL_register(L, "_G", base_funcs); + lua_pushliteral(L, LUA_VERSION); + lua_setglobal(L, "_VERSION"); /* set global _VERSION */ + /* `ipairs' and `pairs' need auxliliary functions as upvalues */ + auxopen(L, "ipairs", luaB_ipairs, ipairsaux); + auxopen(L, "pairs", luaB_pairs, luaB_next); + /* `newproxy' needs a weaktable as upvalue */ + lua_createtable(L, 0, 1); /* new table `w' */ + lua_pushvalue(L, -1); /* `w' will be its own metatable */ + lua_setmetatable(L, -2); + lua_pushliteral(L, "kv"); + lua_setfield(L, -2, "__mode"); /* metatable(w).__mode = "kv" */ + lua_pushcclosure(L, luaB_newproxy, 1); + lua_setglobal(L, "newproxy"); /* set global `newproxy' */ +} + + +LUALIB_API int luaopen_base (lua_State *L) { + base_open(L); + luaL_register(L, LUA_COLIBNAME, co_funcs); + return 2; +} + diff --git a/mylua/lua/lcode.c b/mylua/lua/lcode.c new file mode 100644 index 0000000..cff626b --- /dev/null +++ b/mylua/lua/lcode.c @@ -0,0 +1,839 @@ +/* +** $Id: lcode.c,v 2.25.1.3 2007/12/28 15:32:23 roberto Exp $ +** Code generator for Lua +** See Copyright Notice in lua.h +*/ + + +#include + +#define lcode_c +#define LUA_CORE + +#include "lua.h" + +#include "lcode.h" +#include "ldebug.h" +#include "ldo.h" +#include "lgc.h" +#include "llex.h" +#include "lmem.h" +#include "lobject.h" +#include "lopcodes.h" +#include "lparser.h" +#include "ltable.h" + + +#define hasjumps(e) ((e)->t != (e)->f) + + +static int isnumeral(expdesc *e) { + return (e->k == VKNUM && e->t == NO_JUMP && e->f == NO_JUMP); +} + + +void luaK_nil (FuncState *fs, int from, int n) { + Instruction *previous; + if (fs->pc > fs->lasttarget) { /* no jumps to current position? */ + if (fs->pc == 0) { /* function start? */ + if (from >= fs->nactvar) + return; /* positions are already clean */ + } + else { + previous = &fs->f->code[fs->pc-1]; + if (GET_OPCODE(*previous) == OP_LOADNIL) { + int pfrom = GETARG_A(*previous); + int pto = GETARG_B(*previous); + if (pfrom <= from && from <= pto+1) { /* can connect both? */ + if (from+n-1 > pto) + SETARG_B(*previous, from+n-1); + return; + } + } + } + } + luaK_codeABC(fs, OP_LOADNIL, from, from+n-1, 0); /* else no optimization */ +} + + +int luaK_jump (FuncState *fs) { + int jpc = fs->jpc; /* save list of jumps to here */ + int j; + fs->jpc = NO_JUMP; + j = luaK_codeAsBx(fs, OP_JMP, 0, NO_JUMP); + luaK_concat(fs, &j, jpc); /* keep them on hold */ + return j; +} + + +void luaK_ret (FuncState *fs, int first, int nret) { + luaK_codeABC(fs, OP_RETURN, first, nret+1, 0); +} + + +static int condjump (FuncState *fs, OpCode op, int A, int B, int C) { + luaK_codeABC(fs, op, A, B, C); + return luaK_jump(fs); +} + + +static void fixjump (FuncState *fs, int pc, int dest) { + Instruction *jmp = &fs->f->code[pc]; + int offset = dest-(pc+1); + lua_assert(dest != NO_JUMP); + if (abs(offset) > MAXARG_sBx) + luaX_syntaxerror(fs->ls, "control structure too long"); + SETARG_sBx(*jmp, offset); +} + + +/* +** returns current `pc' and marks it as a jump target (to avoid wrong +** optimizations with consecutive instructions not in the same basic block). +*/ +int luaK_getlabel (FuncState *fs) { + fs->lasttarget = fs->pc; + return fs->pc; +} + + +static int getjump (FuncState *fs, int pc) { + int offset = GETARG_sBx(fs->f->code[pc]); + if (offset == NO_JUMP) /* point to itself represents end of list */ + return NO_JUMP; /* end of list */ + else + return (pc+1)+offset; /* turn offset into absolute position */ +} + + +static Instruction *getjumpcontrol (FuncState *fs, int pc) { + Instruction *pi = &fs->f->code[pc]; + if (pc >= 1 && testTMode(GET_OPCODE(*(pi-1)))) + return pi-1; + else + return pi; +} + + +/* +** check whether list has any jump that do not produce a value +** (or produce an inverted value) +*/ +static int need_value (FuncState *fs, int list) { + for (; list != NO_JUMP; list = getjump(fs, list)) { + Instruction i = *getjumpcontrol(fs, list); + if (GET_OPCODE(i) != OP_TESTSET) return 1; + } + return 0; /* not found */ +} + + +static int patchtestreg (FuncState *fs, int node, int reg) { + Instruction *i = getjumpcontrol(fs, node); + if (GET_OPCODE(*i) != OP_TESTSET) + return 0; /* cannot patch other instructions */ + if (reg != NO_REG && reg != GETARG_B(*i)) + SETARG_A(*i, reg); + else /* no register to put value or register already has the value */ + *i = CREATE_ABC(OP_TEST, GETARG_B(*i), 0, GETARG_C(*i)); + + return 1; +} + + +static void removevalues (FuncState *fs, int list) { + for (; list != NO_JUMP; list = getjump(fs, list)) + patchtestreg(fs, list, NO_REG); +} + + +static void patchlistaux (FuncState *fs, int list, int vtarget, int reg, + int dtarget) { + while (list != NO_JUMP) { + int next = getjump(fs, list); + if (patchtestreg(fs, list, reg)) + fixjump(fs, list, vtarget); + else + fixjump(fs, list, dtarget); /* jump to default target */ + list = next; + } +} + + +static void dischargejpc (FuncState *fs) { + patchlistaux(fs, fs->jpc, fs->pc, NO_REG, fs->pc); + fs->jpc = NO_JUMP; +} + + +void luaK_patchlist (FuncState *fs, int list, int target) { + if (target == fs->pc) + luaK_patchtohere(fs, list); + else { + lua_assert(target < fs->pc); + patchlistaux(fs, list, target, NO_REG, target); + } +} + + +void luaK_patchtohere (FuncState *fs, int list) { + luaK_getlabel(fs); + luaK_concat(fs, &fs->jpc, list); +} + + +void luaK_concat (FuncState *fs, int *l1, int l2) { + if (l2 == NO_JUMP) return; + else if (*l1 == NO_JUMP) + *l1 = l2; + else { + int list = *l1; + int next; + while ((next = getjump(fs, list)) != NO_JUMP) /* find last element */ + list = next; + fixjump(fs, list, l2); + } +} + + +void luaK_checkstack (FuncState *fs, int n) { + int newstack = fs->freereg + n; + if (newstack > fs->f->maxstacksize) { + if (newstack >= MAXSTACK) + luaX_syntaxerror(fs->ls, "function or expression too complex"); + fs->f->maxstacksize = cast_byte(newstack); + } +} + + +void luaK_reserveregs (FuncState *fs, int n) { + luaK_checkstack(fs, n); + fs->freereg += n; +} + + +static void freereg (FuncState *fs, int reg) { + if (!ISK(reg) && reg >= fs->nactvar) { + fs->freereg--; + lua_assert(reg == fs->freereg); + } +} + + +static void freeexp (FuncState *fs, expdesc *e) { + if (e->k == VNONRELOC) + freereg(fs, e->u.s.info); +} + + +static int addk (FuncState *fs, TValue *k, TValue *v) { + lua_State *L = fs->L; + TValue *idx = luaH_set(L, fs->h, k); + Proto *f = fs->f; + int oldsize = f->sizek; + if (ttisnumber(idx)) { + lua_assert(luaO_rawequalObj(&fs->f->k[cast_int(nvalue(idx))], v)); + return cast_int(nvalue(idx)); + } + else { /* constant not found; create a new entry */ + setnvalue(idx, cast_num(fs->nk)); + luaM_growvector(L, f->k, fs->nk, f->sizek, TValue, + MAXARG_Bx, "constant table overflow"); + while (oldsize < f->sizek) setnilvalue(&f->k[oldsize++]); + setobj(L, &f->k[fs->nk], v); + luaC_barrier(L, f, v); + return fs->nk++; + } +} + + +int luaK_stringK (FuncState *fs, TString *s) { + TValue o; + setsvalue(fs->L, &o, s); + return addk(fs, &o, &o); +} + + +int luaK_numberK (FuncState *fs, lua_Number r) { + TValue o; + setnvalue(&o, r); + return addk(fs, &o, &o); +} + + +static int boolK (FuncState *fs, int b) { + TValue o; + setbvalue(&o, b); + return addk(fs, &o, &o); +} + + +static int nilK (FuncState *fs) { + TValue k, v; + setnilvalue(&v); + /* cannot use nil as key; instead use table itself to represent nil */ + sethvalue(fs->L, &k, fs->h); + return addk(fs, &k, &v); +} + + +void luaK_setreturns (FuncState *fs, expdesc *e, int nresults) { + if (e->k == VCALL) { /* expression is an open function call? */ + SETARG_C(getcode(fs, e), nresults+1); + } + else if (e->k == VVARARG) { + SETARG_B(getcode(fs, e), nresults+1); + SETARG_A(getcode(fs, e), fs->freereg); + luaK_reserveregs(fs, 1); + } +} + + +void luaK_setoneret (FuncState *fs, expdesc *e) { + if (e->k == VCALL) { /* expression is an open function call? */ + e->k = VNONRELOC; + e->u.s.info = GETARG_A(getcode(fs, e)); + } + else if (e->k == VVARARG) { + SETARG_B(getcode(fs, e), 2); + e->k = VRELOCABLE; /* can relocate its simple result */ + } +} + + +void luaK_dischargevars (FuncState *fs, expdesc *e) { + switch (e->k) { + case VLOCAL: { + e->k = VNONRELOC; + break; + } + case VUPVAL: { + e->u.s.info = luaK_codeABC(fs, OP_GETUPVAL, 0, e->u.s.info, 0); + e->k = VRELOCABLE; + break; + } + case VGLOBAL: { + e->u.s.info = luaK_codeABx(fs, OP_GETGLOBAL, 0, e->u.s.info); + e->k = VRELOCABLE; + break; + } + case VINDEXED: { + freereg(fs, e->u.s.aux); + freereg(fs, e->u.s.info); + e->u.s.info = luaK_codeABC(fs, OP_GETTABLE, 0, e->u.s.info, e->u.s.aux); + e->k = VRELOCABLE; + break; + } + case VVARARG: + case VCALL: { + luaK_setoneret(fs, e); + break; + } + default: break; /* there is one value available (somewhere) */ + } +} + + +static int code_label (FuncState *fs, int A, int b, int jump) { + luaK_getlabel(fs); /* those instructions may be jump targets */ + return luaK_codeABC(fs, OP_LOADBOOL, A, b, jump); +} + + +static void discharge2reg (FuncState *fs, expdesc *e, int reg) { + luaK_dischargevars(fs, e); + switch (e->k) { + case VNIL: { + luaK_nil(fs, reg, 1); + break; + } + case VFALSE: case VTRUE: { + luaK_codeABC(fs, OP_LOADBOOL, reg, e->k == VTRUE, 0); + break; + } + case VK: { + luaK_codeABx(fs, OP_LOADK, reg, e->u.s.info); + break; + } + case VKNUM: { + luaK_codeABx(fs, OP_LOADK, reg, luaK_numberK(fs, e->u.nval)); + break; + } + case VRELOCABLE: { + Instruction *pc = &getcode(fs, e); + SETARG_A(*pc, reg); + break; + } + case VNONRELOC: { + if (reg != e->u.s.info) + luaK_codeABC(fs, OP_MOVE, reg, e->u.s.info, 0); + break; + } + default: { + lua_assert(e->k == VVOID || e->k == VJMP); + return; /* nothing to do... */ + } + } + e->u.s.info = reg; + e->k = VNONRELOC; +} + + +static void discharge2anyreg (FuncState *fs, expdesc *e) { + if (e->k != VNONRELOC) { + luaK_reserveregs(fs, 1); + discharge2reg(fs, e, fs->freereg-1); + } +} + + +static void exp2reg (FuncState *fs, expdesc *e, int reg) { + discharge2reg(fs, e, reg); + if (e->k == VJMP) + luaK_concat(fs, &e->t, e->u.s.info); /* put this jump in `t' list */ + if (hasjumps(e)) { + int final; /* position after whole expression */ + int p_f = NO_JUMP; /* position of an eventual LOAD false */ + int p_t = NO_JUMP; /* position of an eventual LOAD true */ + if (need_value(fs, e->t) || need_value(fs, e->f)) { + int fj = (e->k == VJMP) ? NO_JUMP : luaK_jump(fs); + p_f = code_label(fs, reg, 0, 1); + p_t = code_label(fs, reg, 1, 0); + luaK_patchtohere(fs, fj); + } + final = luaK_getlabel(fs); + patchlistaux(fs, e->f, final, reg, p_f); + patchlistaux(fs, e->t, final, reg, p_t); + } + e->f = e->t = NO_JUMP; + e->u.s.info = reg; + e->k = VNONRELOC; +} + + +void luaK_exp2nextreg (FuncState *fs, expdesc *e) { + luaK_dischargevars(fs, e); + freeexp(fs, e); + luaK_reserveregs(fs, 1); + exp2reg(fs, e, fs->freereg - 1); +} + + +int luaK_exp2anyreg (FuncState *fs, expdesc *e) { + luaK_dischargevars(fs, e); + if (e->k == VNONRELOC) { + if (!hasjumps(e)) return e->u.s.info; /* exp is already in a register */ + if (e->u.s.info >= fs->nactvar) { /* reg. is not a local? */ + exp2reg(fs, e, e->u.s.info); /* put value on it */ + return e->u.s.info; + } + } + luaK_exp2nextreg(fs, e); /* default */ + return e->u.s.info; +} + + +void luaK_exp2val (FuncState *fs, expdesc *e) { + if (hasjumps(e)) + luaK_exp2anyreg(fs, e); + else + luaK_dischargevars(fs, e); +} + + +int luaK_exp2RK (FuncState *fs, expdesc *e) { + luaK_exp2val(fs, e); + switch (e->k) { + case VKNUM: + case VTRUE: + case VFALSE: + case VNIL: { + if (fs->nk <= MAXINDEXRK) { /* constant fit in RK operand? */ + e->u.s.info = (e->k == VNIL) ? nilK(fs) : + (e->k == VKNUM) ? luaK_numberK(fs, e->u.nval) : + boolK(fs, (e->k == VTRUE)); + e->k = VK; + return RKASK(e->u.s.info); + } + else break; + } + case VK: { + if (e->u.s.info <= MAXINDEXRK) /* constant fit in argC? */ + return RKASK(e->u.s.info); + else break; + } + default: break; + } + /* not a constant in the right range: put it in a register */ + return luaK_exp2anyreg(fs, e); +} + + +void luaK_storevar (FuncState *fs, expdesc *var, expdesc *ex) { + switch (var->k) { + case VLOCAL: { + freeexp(fs, ex); + exp2reg(fs, ex, var->u.s.info); + return; + } + case VUPVAL: { + int e = luaK_exp2anyreg(fs, ex); + luaK_codeABC(fs, OP_SETUPVAL, e, var->u.s.info, 0); + break; + } + case VGLOBAL: { + int e = luaK_exp2anyreg(fs, ex); + luaK_codeABx(fs, OP_SETGLOBAL, e, var->u.s.info); + break; + } + case VINDEXED: { + int e = luaK_exp2RK(fs, ex); + luaK_codeABC(fs, OP_SETTABLE, var->u.s.info, var->u.s.aux, e); + break; + } + default: { + lua_assert(0); /* invalid var kind to store */ + break; + } + } + freeexp(fs, ex); +} + + +void luaK_self (FuncState *fs, expdesc *e, expdesc *key) { + int func; + luaK_exp2anyreg(fs, e); + freeexp(fs, e); + func = fs->freereg; + luaK_reserveregs(fs, 2); + luaK_codeABC(fs, OP_SELF, func, e->u.s.info, luaK_exp2RK(fs, key)); + freeexp(fs, key); + e->u.s.info = func; + e->k = VNONRELOC; +} + + +static void invertjump (FuncState *fs, expdesc *e) { + Instruction *pc = getjumpcontrol(fs, e->u.s.info); + lua_assert(testTMode(GET_OPCODE(*pc)) && GET_OPCODE(*pc) != OP_TESTSET && + GET_OPCODE(*pc) != OP_TEST); + SETARG_A(*pc, !(GETARG_A(*pc))); +} + + +static int jumponcond (FuncState *fs, expdesc *e, int cond) { + if (e->k == VRELOCABLE) { + Instruction ie = getcode(fs, e); + if (GET_OPCODE(ie) == OP_NOT) { + fs->pc--; /* remove previous OP_NOT */ + return condjump(fs, OP_TEST, GETARG_B(ie), 0, !cond); + } + /* else go through */ + } + discharge2anyreg(fs, e); + freeexp(fs, e); + return condjump(fs, OP_TESTSET, NO_REG, e->u.s.info, cond); +} + + +void luaK_goiftrue (FuncState *fs, expdesc *e) { + int pc; /* pc of last jump */ + luaK_dischargevars(fs, e); + switch (e->k) { + case VK: case VKNUM: case VTRUE: { + pc = NO_JUMP; /* always true; do nothing */ + break; + } + case VFALSE: { + pc = luaK_jump(fs); /* always jump */ + break; + } + case VJMP: { + invertjump(fs, e); + pc = e->u.s.info; + break; + } + default: { + pc = jumponcond(fs, e, 0); + break; + } + } + luaK_concat(fs, &e->f, pc); /* insert last jump in `f' list */ + luaK_patchtohere(fs, e->t); + e->t = NO_JUMP; +} + + +static void luaK_goiffalse (FuncState *fs, expdesc *e) { + int pc; /* pc of last jump */ + luaK_dischargevars(fs, e); + switch (e->k) { + case VNIL: case VFALSE: { + pc = NO_JUMP; /* always false; do nothing */ + break; + } + case VTRUE: { + pc = luaK_jump(fs); /* always jump */ + break; + } + case VJMP: { + pc = e->u.s.info; + break; + } + default: { + pc = jumponcond(fs, e, 1); + break; + } + } + luaK_concat(fs, &e->t, pc); /* insert last jump in `t' list */ + luaK_patchtohere(fs, e->f); + e->f = NO_JUMP; +} + + +static void codenot (FuncState *fs, expdesc *e) { + luaK_dischargevars(fs, e); + switch (e->k) { + case VNIL: case VFALSE: { + e->k = VTRUE; + break; + } + case VK: case VKNUM: case VTRUE: { + e->k = VFALSE; + break; + } + case VJMP: { + invertjump(fs, e); + break; + } + case VRELOCABLE: + case VNONRELOC: { + discharge2anyreg(fs, e); + freeexp(fs, e); + e->u.s.info = luaK_codeABC(fs, OP_NOT, 0, e->u.s.info, 0); + e->k = VRELOCABLE; + break; + } + default: { + lua_assert(0); /* cannot happen */ + break; + } + } + /* interchange true and false lists */ + { int temp = e->f; e->f = e->t; e->t = temp; } + removevalues(fs, e->f); + removevalues(fs, e->t); +} + + +void luaK_indexed (FuncState *fs, expdesc *t, expdesc *k) { + t->u.s.aux = luaK_exp2RK(fs, k); + t->k = VINDEXED; +} + + +static int constfolding (OpCode op, expdesc *e1, expdesc *e2) { + lua_Number v1, v2, r; + if (!isnumeral(e1) || !isnumeral(e2)) return 0; + v1 = e1->u.nval; + v2 = e2->u.nval; + switch (op) { + case OP_ADD: r = luai_numadd(v1, v2); break; + case OP_SUB: r = luai_numsub(v1, v2); break; + case OP_MUL: r = luai_nummul(v1, v2); break; + case OP_DIV: + if (v2 == 0) return 0; /* do not attempt to divide by 0 */ + r = luai_numdiv(v1, v2); break; + case OP_MOD: + if (v2 == 0) return 0; /* do not attempt to divide by 0 */ + r = luai_nummod(v1, v2); break; + case OP_POW: r = luai_numpow(v1, v2); break; + case OP_UNM: r = luai_numunm(v1); break; + case OP_LEN: return 0; /* no constant folding for 'len' */ + default: lua_assert(0); r = 0; break; + } + if (luai_numisnan(r)) return 0; /* do not attempt to produce NaN */ + e1->u.nval = r; + return 1; +} + + +static void codearith (FuncState *fs, OpCode op, expdesc *e1, expdesc *e2) { + if (constfolding(op, e1, e2)) + return; + else { + int o2 = (op != OP_UNM && op != OP_LEN) ? luaK_exp2RK(fs, e2) : 0; + int o1 = luaK_exp2RK(fs, e1); + if (o1 > o2) { + freeexp(fs, e1); + freeexp(fs, e2); + } + else { + freeexp(fs, e2); + freeexp(fs, e1); + } + e1->u.s.info = luaK_codeABC(fs, op, 0, o1, o2); + e1->k = VRELOCABLE; + } +} + + +static void codecomp (FuncState *fs, OpCode op, int cond, expdesc *e1, + expdesc *e2) { + int o1 = luaK_exp2RK(fs, e1); + int o2 = luaK_exp2RK(fs, e2); + freeexp(fs, e2); + freeexp(fs, e1); + if (cond == 0 && op != OP_EQ) { + int temp; /* exchange args to replace by `<' or `<=' */ + temp = o1; o1 = o2; o2 = temp; /* o1 <==> o2 */ + cond = 1; + } + e1->u.s.info = condjump(fs, op, cond, o1, o2); + e1->k = VJMP; +} + + +void luaK_prefix (FuncState *fs, UnOpr op, expdesc *e) { + expdesc e2; + e2.t = e2.f = NO_JUMP; e2.k = VKNUM; e2.u.nval = 0; + switch (op) { + case OPR_MINUS: { + if (!isnumeral(e)) + luaK_exp2anyreg(fs, e); /* cannot operate on non-numeric constants */ + codearith(fs, OP_UNM, e, &e2); + break; + } + case OPR_NOT: codenot(fs, e); break; + case OPR_LEN: { + luaK_exp2anyreg(fs, e); /* cannot operate on constants */ + codearith(fs, OP_LEN, e, &e2); + break; + } + default: lua_assert(0); + } +} + + +void luaK_infix (FuncState *fs, BinOpr op, expdesc *v) { + switch (op) { + case OPR_AND: { + luaK_goiftrue(fs, v); + break; + } + case OPR_OR: { + luaK_goiffalse(fs, v); + break; + } + case OPR_CONCAT: { + luaK_exp2nextreg(fs, v); /* operand must be on the `stack' */ + break; + } + case OPR_ADD: case OPR_SUB: case OPR_MUL: case OPR_DIV: + case OPR_MOD: case OPR_POW: { + if (!isnumeral(v)) luaK_exp2RK(fs, v); + break; + } + default: { + luaK_exp2RK(fs, v); + break; + } + } +} + + +void luaK_posfix (FuncState *fs, BinOpr op, expdesc *e1, expdesc *e2) { + switch (op) { + case OPR_AND: { + lua_assert(e1->t == NO_JUMP); /* list must be closed */ + luaK_dischargevars(fs, e2); + luaK_concat(fs, &e2->f, e1->f); + *e1 = *e2; + break; + } + case OPR_OR: { + lua_assert(e1->f == NO_JUMP); /* list must be closed */ + luaK_dischargevars(fs, e2); + luaK_concat(fs, &e2->t, e1->t); + *e1 = *e2; + break; + } + case OPR_CONCAT: { + luaK_exp2val(fs, e2); + if (e2->k == VRELOCABLE && GET_OPCODE(getcode(fs, e2)) == OP_CONCAT) { + lua_assert(e1->u.s.info == GETARG_B(getcode(fs, e2))-1); + freeexp(fs, e1); + SETARG_B(getcode(fs, e2), e1->u.s.info); + e1->k = VRELOCABLE; e1->u.s.info = e2->u.s.info; + } + else { + luaK_exp2nextreg(fs, e2); /* operand must be on the 'stack' */ + codearith(fs, OP_CONCAT, e1, e2); + } + break; + } + case OPR_ADD: codearith(fs, OP_ADD, e1, e2); break; + case OPR_SUB: codearith(fs, OP_SUB, e1, e2); break; + case OPR_MUL: codearith(fs, OP_MUL, e1, e2); break; + case OPR_DIV: codearith(fs, OP_DIV, e1, e2); break; + case OPR_MOD: codearith(fs, OP_MOD, e1, e2); break; + case OPR_POW: codearith(fs, OP_POW, e1, e2); break; + case OPR_EQ: codecomp(fs, OP_EQ, 1, e1, e2); break; + case OPR_NE: codecomp(fs, OP_EQ, 0, e1, e2); break; + case OPR_LT: codecomp(fs, OP_LT, 1, e1, e2); break; + case OPR_LE: codecomp(fs, OP_LE, 1, e1, e2); break; + case OPR_GT: codecomp(fs, OP_LT, 0, e1, e2); break; + case OPR_GE: codecomp(fs, OP_LE, 0, e1, e2); break; + default: lua_assert(0); + } +} + + +void luaK_fixline (FuncState *fs, int line) { + fs->f->lineinfo[fs->pc - 1] = line; +} + + +static int luaK_code (FuncState *fs, Instruction i, int line) { + Proto *f = fs->f; + dischargejpc(fs); /* `pc' will change */ + /* put new instruction in code array */ + luaM_growvector(fs->L, f->code, fs->pc, f->sizecode, Instruction, + MAX_INT, "code size overflow"); + f->code[fs->pc] = i; + /* save corresponding line information */ + luaM_growvector(fs->L, f->lineinfo, fs->pc, f->sizelineinfo, int, + MAX_INT, "code size overflow"); + f->lineinfo[fs->pc] = line; + return fs->pc++; +} + + +int luaK_codeABC (FuncState *fs, OpCode o, int a, int b, int c) { + lua_assert(getOpMode(o) == iABC); + lua_assert(getBMode(o) != OpArgN || b == 0); + lua_assert(getCMode(o) != OpArgN || c == 0); + return luaK_code(fs, CREATE_ABC(o, a, b, c), fs->ls->lastline); +} + + +int luaK_codeABx (FuncState *fs, OpCode o, int a, unsigned int bc) { + lua_assert(getOpMode(o) == iABx || getOpMode(o) == iAsBx); + lua_assert(getCMode(o) == OpArgN); + return luaK_code(fs, CREATE_ABx(o, a, bc), fs->ls->lastline); +} + + +void luaK_setlist (FuncState *fs, int base, int nelems, int tostore) { + int c = (nelems - 1)/LFIELDS_PER_FLUSH + 1; + int b = (tostore == LUA_MULTRET) ? 0 : tostore; + lua_assert(tostore != 0); + if (c <= MAXARG_C) + luaK_codeABC(fs, OP_SETLIST, base, b, c); + else { + luaK_codeABC(fs, OP_SETLIST, base, b, 0); + luaK_code(fs, cast(Instruction, c), fs->ls->lastline); + } + fs->freereg = base + 1; /* free registers with list values */ +} + diff --git a/mylua/lua/lcode.h b/mylua/lua/lcode.h new file mode 100644 index 0000000..b941c60 --- /dev/null +++ b/mylua/lua/lcode.h @@ -0,0 +1,76 @@ +/* +** $Id: lcode.h,v 1.48.1.1 2007/12/27 13:02:25 roberto Exp $ +** Code generator for Lua +** See Copyright Notice in lua.h +*/ + +#ifndef lcode_h +#define lcode_h + +#include "llex.h" +#include "lobject.h" +#include "lopcodes.h" +#include "lparser.h" + + +/* +** Marks the end of a patch list. It is an invalid value both as an absolute +** address, and as a list link (would link an element to itself). +*/ +#define NO_JUMP (-1) + + +/* +** grep "ORDER OPR" if you change these enums +*/ +typedef enum BinOpr { + OPR_ADD, OPR_SUB, OPR_MUL, OPR_DIV, OPR_MOD, OPR_POW, + OPR_CONCAT, + OPR_NE, OPR_EQ, + OPR_LT, OPR_LE, OPR_GT, OPR_GE, + OPR_AND, OPR_OR, + OPR_NOBINOPR +} BinOpr; + + +typedef enum UnOpr { OPR_MINUS, OPR_NOT, OPR_LEN, OPR_NOUNOPR } UnOpr; + + +#define getcode(fs,e) ((fs)->f->code[(e)->u.s.info]) + +#define luaK_codeAsBx(fs,o,A,sBx) luaK_codeABx(fs,o,A,(sBx)+MAXARG_sBx) + +#define luaK_setmultret(fs,e) luaK_setreturns(fs, e, LUA_MULTRET) + +LUAI_FUNC int luaK_codeABx (FuncState *fs, OpCode o, int A, unsigned int Bx); +LUAI_FUNC int luaK_codeABC (FuncState *fs, OpCode o, int A, int B, int C); +LUAI_FUNC void luaK_fixline (FuncState *fs, int line); +LUAI_FUNC void luaK_nil (FuncState *fs, int from, int n); +LUAI_FUNC void luaK_reserveregs (FuncState *fs, int n); +LUAI_FUNC void luaK_checkstack (FuncState *fs, int n); +LUAI_FUNC int luaK_stringK (FuncState *fs, TString *s); +LUAI_FUNC int luaK_numberK (FuncState *fs, lua_Number r); +LUAI_FUNC void luaK_dischargevars (FuncState *fs, expdesc *e); +LUAI_FUNC int luaK_exp2anyreg (FuncState *fs, expdesc *e); +LUAI_FUNC void luaK_exp2nextreg (FuncState *fs, expdesc *e); +LUAI_FUNC void luaK_exp2val (FuncState *fs, expdesc *e); +LUAI_FUNC int luaK_exp2RK (FuncState *fs, expdesc *e); +LUAI_FUNC void luaK_self (FuncState *fs, expdesc *e, expdesc *key); +LUAI_FUNC void luaK_indexed (FuncState *fs, expdesc *t, expdesc *k); +LUAI_FUNC void luaK_goiftrue (FuncState *fs, expdesc *e); +LUAI_FUNC void luaK_storevar (FuncState *fs, expdesc *var, expdesc *e); +LUAI_FUNC void luaK_setreturns (FuncState *fs, expdesc *e, int nresults); +LUAI_FUNC void luaK_setoneret (FuncState *fs, expdesc *e); +LUAI_FUNC int luaK_jump (FuncState *fs); +LUAI_FUNC void luaK_ret (FuncState *fs, int first, int nret); +LUAI_FUNC void luaK_patchlist (FuncState *fs, int list, int target); +LUAI_FUNC void luaK_patchtohere (FuncState *fs, int list); +LUAI_FUNC void luaK_concat (FuncState *fs, int *l1, int l2); +LUAI_FUNC int luaK_getlabel (FuncState *fs); +LUAI_FUNC void luaK_prefix (FuncState *fs, UnOpr op, expdesc *v); +LUAI_FUNC void luaK_infix (FuncState *fs, BinOpr op, expdesc *v); +LUAI_FUNC void luaK_posfix (FuncState *fs, BinOpr op, expdesc *v1, expdesc *v2); +LUAI_FUNC void luaK_setlist (FuncState *fs, int base, int nelems, int tostore); + + +#endif diff --git a/mylua/lua/ldblib.c b/mylua/lua/ldblib.c new file mode 100644 index 0000000..67de122 --- /dev/null +++ b/mylua/lua/ldblib.c @@ -0,0 +1,397 @@ +/* +** $Id: ldblib.c,v 1.104.1.3 2008/01/21 13:11:21 roberto Exp $ +** Interface from Lua to its debug API +** See Copyright Notice in lua.h +*/ + + +#include +#include +#include + +#define ldblib_c +#define LUA_LIB + +#include "lua.h" + +#include "lauxlib.h" +#include "lualib.h" + + + +static int db_getregistry (lua_State *L) { + lua_pushvalue(L, LUA_REGISTRYINDEX); + return 1; +} + + +static int db_getmetatable (lua_State *L) { + luaL_checkany(L, 1); + if (!lua_getmetatable(L, 1)) { + lua_pushnil(L); /* no metatable */ + } + return 1; +} + + +static int db_setmetatable (lua_State *L) { + int t = lua_type(L, 2); + luaL_argcheck(L, t == LUA_TNIL || t == LUA_TTABLE, 2, + "nil or table expected"); + lua_settop(L, 2); + lua_pushboolean(L, lua_setmetatable(L, 1)); + return 1; +} + + +static int db_getfenv (lua_State *L) { + lua_getfenv(L, 1); + return 1; +} + + +static int db_setfenv (lua_State *L) { + luaL_checktype(L, 2, LUA_TTABLE); + lua_settop(L, 2); + if (lua_setfenv(L, 1) == 0) + luaL_error(L, LUA_QL("setfenv") + " cannot change environment of given object"); + return 1; +} + + +static void settabss (lua_State *L, const char *i, const char *v) { + lua_pushstring(L, v); + lua_setfield(L, -2, i); +} + + +static void settabsi (lua_State *L, const char *i, int v) { + lua_pushinteger(L, v); + lua_setfield(L, -2, i); +} + + +static lua_State *getthread (lua_State *L, int *arg) { + if (lua_isthread(L, 1)) { + *arg = 1; + return lua_tothread(L, 1); + } + else { + *arg = 0; + return L; + } +} + + +static void treatstackoption (lua_State *L, lua_State *L1, const char *fname) { + if (L == L1) { + lua_pushvalue(L, -2); + lua_remove(L, -3); + } + else + lua_xmove(L1, L, 1); + lua_setfield(L, -2, fname); +} + + +static int db_getinfo (lua_State *L) { + lua_Debug ar; + int arg; + lua_State *L1 = getthread(L, &arg); + const char *options = luaL_optstring(L, arg+2, "flnSu"); + if (lua_isnumber(L, arg+1)) { + if (!lua_getstack(L1, (int)lua_tointeger(L, arg+1), &ar)) { + lua_pushnil(L); /* level out of range */ + return 1; + } + } + else if (lua_isfunction(L, arg+1)) { + lua_pushfstring(L, ">%s", options); + options = lua_tostring(L, -1); + lua_pushvalue(L, arg+1); + lua_xmove(L, L1, 1); + } + else + return luaL_argerror(L, arg+1, "function or level expected"); + if (!lua_getinfo(L1, options, &ar)) + return luaL_argerror(L, arg+2, "invalid option"); + lua_createtable(L, 0, 2); + if (strchr(options, 'S')) { + settabss(L, "source", ar.source); + settabss(L, "short_src", ar.short_src); + settabsi(L, "linedefined", ar.linedefined); + settabsi(L, "lastlinedefined", ar.lastlinedefined); + settabss(L, "what", ar.what); + } + if (strchr(options, 'l')) + settabsi(L, "currentline", ar.currentline); + if (strchr(options, 'u')) + settabsi(L, "nups", ar.nups); + if (strchr(options, 'n')) { + settabss(L, "name", ar.name); + settabss(L, "namewhat", ar.namewhat); + } + if (strchr(options, 'L')) + treatstackoption(L, L1, "activelines"); + if (strchr(options, 'f')) + treatstackoption(L, L1, "func"); + return 1; /* return table */ +} + + +static int db_getlocal (lua_State *L) { + int arg; + lua_State *L1 = getthread(L, &arg); + lua_Debug ar; + const char *name; + if (!lua_getstack(L1, luaL_checkint(L, arg+1), &ar)) /* out of range? */ + return luaL_argerror(L, arg+1, "level out of range"); + name = lua_getlocal(L1, &ar, luaL_checkint(L, arg+2)); + if (name) { + lua_xmove(L1, L, 1); + lua_pushstring(L, name); + lua_pushvalue(L, -2); + return 2; + } + else { + lua_pushnil(L); + return 1; + } +} + + +static int db_setlocal (lua_State *L) { + int arg; + lua_State *L1 = getthread(L, &arg); + lua_Debug ar; + if (!lua_getstack(L1, luaL_checkint(L, arg+1), &ar)) /* out of range? */ + return luaL_argerror(L, arg+1, "level out of range"); + luaL_checkany(L, arg+3); + lua_settop(L, arg+3); + lua_xmove(L, L1, 1); + lua_pushstring(L, lua_setlocal(L1, &ar, luaL_checkint(L, arg+2))); + return 1; +} + + +static int auxupvalue (lua_State *L, int get) { + const char *name; + int n = luaL_checkint(L, 2); + luaL_checktype(L, 1, LUA_TFUNCTION); + if (lua_iscfunction(L, 1)) return 0; /* cannot touch C upvalues from Lua */ + name = get ? lua_getupvalue(L, 1, n) : lua_setupvalue(L, 1, n); + if (name == NULL) return 0; + lua_pushstring(L, name); + lua_insert(L, -(get+1)); + return get + 1; +} + + +static int db_getupvalue (lua_State *L) { + return auxupvalue(L, 1); +} + + +static int db_setupvalue (lua_State *L) { + luaL_checkany(L, 3); + return auxupvalue(L, 0); +} + + + +static const char KEY_HOOK = 'h'; + + +static void hookf (lua_State *L, lua_Debug *ar) { + static const char *const hooknames[] = + {"call", "return", "line", "count", "tail return"}; + lua_pushlightuserdata(L, (void *)&KEY_HOOK); + lua_rawget(L, LUA_REGISTRYINDEX); + lua_pushlightuserdata(L, L); + lua_rawget(L, -2); + if (lua_isfunction(L, -1)) { + lua_pushstring(L, hooknames[(int)ar->event]); + if (ar->currentline >= 0) + lua_pushinteger(L, ar->currentline); + else lua_pushnil(L); + lua_assert(lua_getinfo(L, "lS", ar)); + lua_call(L, 2, 0); + } +} + + +static int makemask (const char *smask, int count) { + int mask = 0; + if (strchr(smask, 'c')) mask |= LUA_MASKCALL; + if (strchr(smask, 'r')) mask |= LUA_MASKRET; + if (strchr(smask, 'l')) mask |= LUA_MASKLINE; + if (count > 0) mask |= LUA_MASKCOUNT; + return mask; +} + + +static char *unmakemask (int mask, char *smask) { + int i = 0; + if (mask & LUA_MASKCALL) smask[i++] = 'c'; + if (mask & LUA_MASKRET) smask[i++] = 'r'; + if (mask & LUA_MASKLINE) smask[i++] = 'l'; + smask[i] = '\0'; + return smask; +} + + +static void gethooktable (lua_State *L) { + lua_pushlightuserdata(L, (void *)&KEY_HOOK); + lua_rawget(L, LUA_REGISTRYINDEX); + if (!lua_istable(L, -1)) { + lua_pop(L, 1); + lua_createtable(L, 0, 1); + lua_pushlightuserdata(L, (void *)&KEY_HOOK); + lua_pushvalue(L, -2); + lua_rawset(L, LUA_REGISTRYINDEX); + } +} + + +static int db_sethook (lua_State *L) { + int arg, mask, count; + lua_Hook func; + lua_State *L1 = getthread(L, &arg); + if (lua_isnoneornil(L, arg+1)) { + lua_settop(L, arg+1); + func = NULL; mask = 0; count = 0; /* turn off hooks */ + } + else { + const char *smask = luaL_checkstring(L, arg+2); + luaL_checktype(L, arg+1, LUA_TFUNCTION); + count = luaL_optint(L, arg+3, 0); + func = hookf; mask = makemask(smask, count); + } + gethooktable(L); + lua_pushlightuserdata(L, L1); + lua_pushvalue(L, arg+1); + lua_rawset(L, -3); /* set new hook */ + lua_pop(L, 1); /* remove hook table */ + lua_sethook(L1, func, mask, count); /* set hooks */ + return 0; +} + + +static int db_gethook (lua_State *L) { + int arg; + lua_State *L1 = getthread(L, &arg); + char buff[5]; + int mask = lua_gethookmask(L1); + lua_Hook hook = lua_gethook(L1); + if (hook != NULL && hook != hookf) /* external hook? */ + lua_pushliteral(L, "external hook"); + else { + gethooktable(L); + lua_pushlightuserdata(L, L1); + lua_rawget(L, -2); /* get hook */ + lua_remove(L, -2); /* remove hook table */ + } + lua_pushstring(L, unmakemask(mask, buff)); + lua_pushinteger(L, lua_gethookcount(L1)); + return 3; +} + + +static int db_debug (lua_State *L) { + for (;;) { + char buffer[250]; + fputs("lua_debug> ", stderr); + if (fgets(buffer, sizeof(buffer), stdin) == 0 || + strcmp(buffer, "cont\n") == 0) + return 0; + if (luaL_loadbuffer(L, buffer, strlen(buffer), "=(debug command)") || + lua_pcall(L, 0, 0, 0)) { + fputs(lua_tostring(L, -1), stderr); + fputs("\n", stderr); + } + lua_settop(L, 0); /* remove eventual returns */ + } +} + + +#define LEVELS1 12 /* size of the first part of the stack */ +#define LEVELS2 10 /* size of the second part of the stack */ + +static int db_errorfb (lua_State *L) { + int level; + int firstpart = 1; /* still before eventual `...' */ + int arg; + lua_State *L1 = getthread(L, &arg); + lua_Debug ar; + if (lua_isnumber(L, arg+2)) { + level = (int)lua_tointeger(L, arg+2); + lua_pop(L, 1); + } + else + level = (L == L1) ? 1 : 0; /* level 0 may be this own function */ + if (lua_gettop(L) == arg) + lua_pushliteral(L, ""); + else if (!lua_isstring(L, arg+1)) return 1; /* message is not a string */ + else lua_pushliteral(L, "\n"); + lua_pushliteral(L, "stack traceback:"); + while (lua_getstack(L1, level++, &ar)) { + if (level > LEVELS1 && firstpart) { + /* no more than `LEVELS2' more levels? */ + if (!lua_getstack(L1, level+LEVELS2, &ar)) + level--; /* keep going */ + else { + lua_pushliteral(L, "\n\t..."); /* too many levels */ + while (lua_getstack(L1, level+LEVELS2, &ar)) /* find last levels */ + level++; + } + firstpart = 0; + continue; + } + lua_pushliteral(L, "\n\t"); + lua_getinfo(L1, "Snl", &ar); + lua_pushfstring(L, "%s:", ar.short_src); + if (ar.currentline > 0) + lua_pushfstring(L, "%d:", ar.currentline); + if (*ar.namewhat != '\0') /* is there a name? */ + lua_pushfstring(L, " in function " LUA_QS, ar.name); + else { + if (*ar.what == 'm') /* main? */ + lua_pushfstring(L, " in main chunk"); + else if (*ar.what == 'C' || *ar.what == 't') + lua_pushliteral(L, " ?"); /* C function or tail call */ + else + lua_pushfstring(L, " in function <%s:%d>", + ar.short_src, ar.linedefined); + } + lua_concat(L, lua_gettop(L) - arg); + } + lua_concat(L, lua_gettop(L) - arg); + return 1; +} + + +static const luaL_Reg dblib[] = { + {"debug", db_debug}, + {"getfenv", db_getfenv}, + {"gethook", db_gethook}, + {"getinfo", db_getinfo}, + {"getlocal", db_getlocal}, + {"getregistry", db_getregistry}, + {"getmetatable", db_getmetatable}, + {"getupvalue", db_getupvalue}, + {"setfenv", db_setfenv}, + {"sethook", db_sethook}, + {"setlocal", db_setlocal}, + {"setmetatable", db_setmetatable}, + {"setupvalue", db_setupvalue}, + {"traceback", db_errorfb}, + {NULL, NULL} +}; + + +LUALIB_API int luaopen_debug (lua_State *L) { + luaL_register(L, LUA_DBLIBNAME, dblib); + return 1; +} + diff --git a/mylua/lua/ldebug.c b/mylua/lua/ldebug.c new file mode 100644 index 0000000..50ad3d3 --- /dev/null +++ b/mylua/lua/ldebug.c @@ -0,0 +1,638 @@ +/* +** $Id: ldebug.c,v 2.29.1.6 2008/05/08 16:56:26 roberto Exp $ +** Debug Interface +** See Copyright Notice in lua.h +*/ + + +#include +#include +#include + + +#define ldebug_c +#define LUA_CORE + +#include "lua.h" + +#include "lapi.h" +#include "lcode.h" +#include "ldebug.h" +#include "ldo.h" +#include "lfunc.h" +#include "lobject.h" +#include "lopcodes.h" +#include "lstate.h" +#include "lstring.h" +#include "ltable.h" +#include "ltm.h" +#include "lvm.h" + + + +static const char *getfuncname (lua_State *L, CallInfo *ci, const char **name); + + +static int currentpc (lua_State *L, CallInfo *ci) { + if (!isLua(ci)) return -1; /* function is not a Lua function? */ + if (ci == L->ci) + ci->savedpc = L->savedpc; + return pcRel(ci->savedpc, ci_func(ci)->l.p); +} + + +static int currentline (lua_State *L, CallInfo *ci) { + int pc = currentpc(L, ci); + if (pc < 0) + return -1; /* only active lua functions have current-line information */ + else + return getline(ci_func(ci)->l.p, pc); +} + + +/* +** this function can be called asynchronous (e.g. during a signal) +*/ +LUA_API int lua_sethook (lua_State *L, lua_Hook func, int mask, int count) { + if (func == NULL || mask == 0) { /* turn off hooks? */ + mask = 0; + func = NULL; + } + L->hook = func; + L->basehookcount = count; + resethookcount(L); + L->hookmask = cast_byte(mask); + return 1; +} + + +LUA_API lua_Hook lua_gethook (lua_State *L) { + return L->hook; +} + + +LUA_API int lua_gethookmask (lua_State *L) { + return L->hookmask; +} + + +LUA_API int lua_gethookcount (lua_State *L) { + return L->basehookcount; +} + + +LUA_API int lua_getstack (lua_State *L, int level, lua_Debug *ar) { + int status; + CallInfo *ci; + lua_lock(L); + for (ci = L->ci; level > 0 && ci > L->base_ci; ci--) { + level--; + if (f_isLua(ci)) /* Lua function? */ + level -= ci->tailcalls; /* skip lost tail calls */ + } + if (level == 0 && ci > L->base_ci) { /* level found? */ + status = 1; + ar->i_ci = cast_int(ci - L->base_ci); + } + else if (level < 0) { /* level is of a lost tail call? */ + status = 1; + ar->i_ci = 0; + } + else status = 0; /* no such level */ + lua_unlock(L); + return status; +} + + +static Proto *getluaproto (CallInfo *ci) { + return (isLua(ci) ? ci_func(ci)->l.p : NULL); +} + + +static const char *findlocal (lua_State *L, CallInfo *ci, int n) { + const char *name; + Proto *fp = getluaproto(ci); + if (fp && (name = luaF_getlocalname(fp, n, currentpc(L, ci))) != NULL) + return name; /* is a local variable in a Lua function */ + else { + StkId limit = (ci == L->ci) ? L->top : (ci+1)->func; + if (limit - ci->base >= n && n > 0) /* is 'n' inside 'ci' stack? */ + return "(*temporary)"; + else + return NULL; + } +} + + +LUA_API const char *lua_getlocal (lua_State *L, const lua_Debug *ar, int n) { + CallInfo *ci = L->base_ci + ar->i_ci; + const char *name = findlocal(L, ci, n); + lua_lock(L); + if (name) + luaA_pushobject(L, ci->base + (n - 1)); + lua_unlock(L); + return name; +} + + +LUA_API const char *lua_setlocal (lua_State *L, const lua_Debug *ar, int n) { + CallInfo *ci = L->base_ci + ar->i_ci; + const char *name = findlocal(L, ci, n); + lua_lock(L); + if (name) + setobjs2s(L, ci->base + (n - 1), L->top - 1); + L->top--; /* pop value */ + lua_unlock(L); + return name; +} + + +static void funcinfo (lua_Debug *ar, Closure *cl) { + if (cl->c.isC) { + ar->source = "=[C]"; + ar->linedefined = -1; + ar->lastlinedefined = -1; + ar->what = "C"; + } + else { + ar->source = getstr(cl->l.p->source); + ar->linedefined = cl->l.p->linedefined; + ar->lastlinedefined = cl->l.p->lastlinedefined; + ar->what = (ar->linedefined == 0) ? "main" : "Lua"; + } + luaO_chunkid(ar->short_src, ar->source, LUA_IDSIZE); +} + + +static void info_tailcall (lua_Debug *ar) { + ar->name = ar->namewhat = ""; + ar->what = "tail"; + ar->lastlinedefined = ar->linedefined = ar->currentline = -1; + ar->source = "=(tail call)"; + luaO_chunkid(ar->short_src, ar->source, LUA_IDSIZE); + ar->nups = 0; +} + + +static void collectvalidlines (lua_State *L, Closure *f) { + if (f == NULL || f->c.isC) { + setnilvalue(L->top); + } + else { + Table *t = luaH_new(L, 0, 0); + int *lineinfo = f->l.p->lineinfo; + int i; + for (i=0; il.p->sizelineinfo; i++) + setbvalue(luaH_setnum(L, t, lineinfo[i]), 1); + sethvalue(L, L->top, t); + } + incr_top(L); +} + + +static int auxgetinfo (lua_State *L, const char *what, lua_Debug *ar, + Closure *f, CallInfo *ci) { + int status = 1; + if (f == NULL) { + info_tailcall(ar); + return status; + } + for (; *what; what++) { + switch (*what) { + case 'S': { + funcinfo(ar, f); + break; + } + case 'l': { + ar->currentline = (ci) ? currentline(L, ci) : -1; + break; + } + case 'u': { + ar->nups = f->c.nupvalues; + break; + } + case 'n': { + ar->namewhat = (ci) ? getfuncname(L, ci, &ar->name) : NULL; + if (ar->namewhat == NULL) { + ar->namewhat = ""; /* not found */ + ar->name = NULL; + } + break; + } + case 'L': + case 'f': /* handled by lua_getinfo */ + break; + default: status = 0; /* invalid option */ + } + } + return status; +} + + +LUA_API int lua_getinfo (lua_State *L, const char *what, lua_Debug *ar) { + int status; + Closure *f = NULL; + CallInfo *ci = NULL; + lua_lock(L); + if (*what == '>') { + StkId func = L->top - 1; + luai_apicheck(L, ttisfunction(func)); + what++; /* skip the '>' */ + f = clvalue(func); + L->top--; /* pop function */ + } + else if (ar->i_ci != 0) { /* no tail call? */ + ci = L->base_ci + ar->i_ci; + lua_assert(ttisfunction(ci->func)); + f = clvalue(ci->func); + } + status = auxgetinfo(L, what, ar, f, ci); + if (strchr(what, 'f')) { + if (f == NULL) setnilvalue(L->top); + else setclvalue(L, L->top, f); + incr_top(L); + } + if (strchr(what, 'L')) + collectvalidlines(L, f); + lua_unlock(L); + return status; +} + + +/* +** {====================================================== +** Symbolic Execution and code checker +** ======================================================= +*/ + +#define check(x) if (!(x)) return 0; + +#define checkjump(pt,pc) check(0 <= pc && pc < pt->sizecode) + +#define checkreg(pt,reg) check((reg) < (pt)->maxstacksize) + + + +static int precheck (const Proto *pt) { + check(pt->maxstacksize <= MAXSTACK); + check(pt->numparams+(pt->is_vararg & VARARG_HASARG) <= pt->maxstacksize); + check(!(pt->is_vararg & VARARG_NEEDSARG) || + (pt->is_vararg & VARARG_HASARG)); + check(pt->sizeupvalues <= pt->nups); + check(pt->sizelineinfo == pt->sizecode || pt->sizelineinfo == 0); + check(pt->sizecode > 0 && GET_OPCODE(pt->code[pt->sizecode-1]) == OP_RETURN); + return 1; +} + + +#define checkopenop(pt,pc) luaG_checkopenop((pt)->code[(pc)+1]) + +int luaG_checkopenop (Instruction i) { + switch (GET_OPCODE(i)) { + case OP_CALL: + case OP_TAILCALL: + case OP_RETURN: + case OP_SETLIST: { + check(GETARG_B(i) == 0); + return 1; + } + default: return 0; /* invalid instruction after an open call */ + } +} + + +static int checkArgMode (const Proto *pt, int r, enum OpArgMask mode) { + switch (mode) { + case OpArgN: check(r == 0); break; + case OpArgU: break; + case OpArgR: checkreg(pt, r); break; + case OpArgK: + check(ISK(r) ? INDEXK(r) < pt->sizek : r < pt->maxstacksize); + break; + } + return 1; +} + + +static Instruction symbexec (const Proto *pt, int lastpc, int reg) { + int pc; + int last; /* stores position of last instruction that changed `reg' */ + last = pt->sizecode-1; /* points to final return (a `neutral' instruction) */ + check(precheck(pt)); + for (pc = 0; pc < lastpc; pc++) { + Instruction i = pt->code[pc]; + OpCode op = GET_OPCODE(i); + int a = GETARG_A(i); + int b = 0; + int c = 0; + check(op < NUM_OPCODES); + checkreg(pt, a); + switch (getOpMode(op)) { + case iABC: { + b = GETARG_B(i); + c = GETARG_C(i); + check(checkArgMode(pt, b, getBMode(op))); + check(checkArgMode(pt, c, getCMode(op))); + break; + } + case iABx: { + b = GETARG_Bx(i); + if (getBMode(op) == OpArgK) check(b < pt->sizek); + break; + } + case iAsBx: { + b = GETARG_sBx(i); + if (getBMode(op) == OpArgR) { + int dest = pc+1+b; + check(0 <= dest && dest < pt->sizecode); + if (dest > 0) { + int j; + /* check that it does not jump to a setlist count; this + is tricky, because the count from a previous setlist may + have the same value of an invalid setlist; so, we must + go all the way back to the first of them (if any) */ + for (j = 0; j < dest; j++) { + Instruction d = pt->code[dest-1-j]; + if (!(GET_OPCODE(d) == OP_SETLIST && GETARG_C(d) == 0)) break; + } + /* if 'j' is even, previous value is not a setlist (even if + it looks like one) */ + check((j&1) == 0); + } + } + break; + } + } + if (testAMode(op)) { + if (a == reg) last = pc; /* change register `a' */ + } + if (testTMode(op)) { + check(pc+2 < pt->sizecode); /* check skip */ + check(GET_OPCODE(pt->code[pc+1]) == OP_JMP); + } + switch (op) { + case OP_LOADBOOL: { + if (c == 1) { /* does it jump? */ + check(pc+2 < pt->sizecode); /* check its jump */ + check(GET_OPCODE(pt->code[pc+1]) != OP_SETLIST || + GETARG_C(pt->code[pc+1]) != 0); + } + break; + } + case OP_LOADNIL: { + if (a <= reg && reg <= b) + last = pc; /* set registers from `a' to `b' */ + break; + } + case OP_GETUPVAL: + case OP_SETUPVAL: { + check(b < pt->nups); + break; + } + case OP_GETGLOBAL: + case OP_SETGLOBAL: { + check(ttisstring(&pt->k[b])); + break; + } + case OP_SELF: { + checkreg(pt, a+1); + if (reg == a+1) last = pc; + break; + } + case OP_CONCAT: { + check(b < c); /* at least two operands */ + break; + } + case OP_TFORLOOP: { + check(c >= 1); /* at least one result (control variable) */ + checkreg(pt, a+2+c); /* space for results */ + if (reg >= a+2) last = pc; /* affect all regs above its base */ + break; + } + case OP_FORLOOP: + case OP_FORPREP: + checkreg(pt, a+3); + /* go through */ + case OP_JMP: { + int dest = pc+1+b; + /* not full check and jump is forward and do not skip `lastpc'? */ + if (reg != NO_REG && pc < dest && dest <= lastpc) + pc += b; /* do the jump */ + break; + } + case OP_CALL: + case OP_TAILCALL: { + if (b != 0) { + checkreg(pt, a+b-1); + } + c--; /* c = num. returns */ + if (c == LUA_MULTRET) { + check(checkopenop(pt, pc)); + } + else if (c != 0) + checkreg(pt, a+c-1); + if (reg >= a) last = pc; /* affect all registers above base */ + break; + } + case OP_RETURN: { + b--; /* b = num. returns */ + if (b > 0) checkreg(pt, a+b-1); + break; + } + case OP_SETLIST: { + if (b > 0) checkreg(pt, a + b); + if (c == 0) { + pc++; + check(pc < pt->sizecode - 1); + } + break; + } + case OP_CLOSURE: { + int nup, j; + check(b < pt->sizep); + nup = pt->p[b]->nups; + check(pc + nup < pt->sizecode); + for (j = 1; j <= nup; j++) { + OpCode op1 = GET_OPCODE(pt->code[pc + j]); + check(op1 == OP_GETUPVAL || op1 == OP_MOVE); + } + if (reg != NO_REG) /* tracing? */ + pc += nup; /* do not 'execute' these pseudo-instructions */ + break; + } + case OP_VARARG: { + check((pt->is_vararg & VARARG_ISVARARG) && + !(pt->is_vararg & VARARG_NEEDSARG)); + b--; + if (b == LUA_MULTRET) check(checkopenop(pt, pc)); + checkreg(pt, a+b-1); + break; + } + default: break; + } + } + return pt->code[last]; +} + +#undef check +#undef checkjump +#undef checkreg + +/* }====================================================== */ + + +int luaG_checkcode (const Proto *pt) { + return (symbexec(pt, pt->sizecode, NO_REG) != 0); +} + + +static const char *kname (Proto *p, int c) { + if (ISK(c) && ttisstring(&p->k[INDEXK(c)])) + return svalue(&p->k[INDEXK(c)]); + else + return "?"; +} + + +static const char *getobjname (lua_State *L, CallInfo *ci, int stackpos, + const char **name) { + if (isLua(ci)) { /* a Lua function? */ + Proto *p = ci_func(ci)->l.p; + int pc = currentpc(L, ci); + Instruction i; + *name = luaF_getlocalname(p, stackpos+1, pc); + if (*name) /* is a local? */ + return "local"; + i = symbexec(p, pc, stackpos); /* try symbolic execution */ + lua_assert(pc != -1); + switch (GET_OPCODE(i)) { + case OP_GETGLOBAL: { + int g = GETARG_Bx(i); /* global index */ + lua_assert(ttisstring(&p->k[g])); + *name = svalue(&p->k[g]); + return "global"; + } + case OP_MOVE: { + int a = GETARG_A(i); + int b = GETARG_B(i); /* move from `b' to `a' */ + if (b < a) + return getobjname(L, ci, b, name); /* get name for `b' */ + break; + } + case OP_GETTABLE: { + int k = GETARG_C(i); /* key index */ + *name = kname(p, k); + return "field"; + } + case OP_GETUPVAL: { + int u = GETARG_B(i); /* upvalue index */ + *name = p->upvalues ? getstr(p->upvalues[u]) : "?"; + return "upvalue"; + } + case OP_SELF: { + int k = GETARG_C(i); /* key index */ + *name = kname(p, k); + return "method"; + } + default: break; + } + } + return NULL; /* no useful name found */ +} + + +static const char *getfuncname (lua_State *L, CallInfo *ci, const char **name) { + Instruction i; + if ((isLua(ci) && ci->tailcalls > 0) || !isLua(ci - 1)) + return NULL; /* calling function is not Lua (or is unknown) */ + ci--; /* calling function */ + i = ci_func(ci)->l.p->code[currentpc(L, ci)]; + if (GET_OPCODE(i) == OP_CALL || GET_OPCODE(i) == OP_TAILCALL || + GET_OPCODE(i) == OP_TFORLOOP) + return getobjname(L, ci, GETARG_A(i), name); + else + return NULL; /* no useful name can be found */ +} + + +/* only ANSI way to check whether a pointer points to an array */ +static int isinstack (CallInfo *ci, const TValue *o) { + StkId p; + for (p = ci->base; p < ci->top; p++) + if (o == p) return 1; + return 0; +} + + +void luaG_typeerror (lua_State *L, const TValue *o, const char *op) { + const char *name = NULL; + const char *t = luaT_typenames[ttype(o)]; + const char *kind = (isinstack(L->ci, o)) ? + getobjname(L, L->ci, cast_int(o - L->base), &name) : + NULL; + if (kind) + luaG_runerror(L, "attempt to %s %s " LUA_QS " (a %s value)", + op, kind, name, t); + else + luaG_runerror(L, "attempt to %s a %s value", op, t); +} + + +void luaG_concaterror (lua_State *L, StkId p1, StkId p2) { + if (ttisstring(p1) || ttisnumber(p1)) p1 = p2; + lua_assert(!ttisstring(p1) && !ttisnumber(p1)); + luaG_typeerror(L, p1, "concatenate"); +} + + +void luaG_aritherror (lua_State *L, const TValue *p1, const TValue *p2) { + TValue temp; + if (luaV_tonumber(p1, &temp) == NULL) + p2 = p1; /* first operand is wrong */ + luaG_typeerror(L, p2, "perform arithmetic on"); +} + + +int luaG_ordererror (lua_State *L, const TValue *p1, const TValue *p2) { + const char *t1 = luaT_typenames[ttype(p1)]; + const char *t2 = luaT_typenames[ttype(p2)]; + if (t1[2] == t2[2]) + luaG_runerror(L, "attempt to compare two %s values", t1); + else + luaG_runerror(L, "attempt to compare %s with %s", t1, t2); + return 0; +} + + +static void addinfo (lua_State *L, const char *msg) { + CallInfo *ci = L->ci; + if (isLua(ci)) { /* is Lua code? */ + char buff[LUA_IDSIZE]; /* add file:line information */ + int line = currentline(L, ci); + luaO_chunkid(buff, getstr(getluaproto(ci)->source), LUA_IDSIZE); + luaO_pushfstring(L, "%s:%d: %s", buff, line, msg); + } +} + + +void luaG_errormsg (lua_State *L) { + if (L->errfunc != 0) { /* is there an error handling function? */ + StkId errfunc = restorestack(L, L->errfunc); + if (!ttisfunction(errfunc)) luaD_throw(L, LUA_ERRERR); + setobjs2s(L, L->top, L->top - 1); /* move argument */ + setobjs2s(L, L->top - 1, errfunc); /* push function */ + incr_top(L); + luaD_call(L, L->top - 2, 1); /* call it */ + } + luaD_throw(L, LUA_ERRRUN); +} + + +void luaG_runerror (lua_State *L, const char *fmt, ...) { + va_list argp; + va_start(argp, fmt); + addinfo(L, luaO_pushvfstring(L, fmt, argp)); + va_end(argp); + luaG_errormsg(L); +} + diff --git a/mylua/lua/ldebug.h b/mylua/lua/ldebug.h new file mode 100644 index 0000000..ba28a97 --- /dev/null +++ b/mylua/lua/ldebug.h @@ -0,0 +1,33 @@ +/* +** $Id: ldebug.h,v 2.3.1.1 2007/12/27 13:02:25 roberto Exp $ +** Auxiliary functions from Debug Interface module +** See Copyright Notice in lua.h +*/ + +#ifndef ldebug_h +#define ldebug_h + + +#include "lstate.h" + + +#define pcRel(pc, p) (cast(int, (pc) - (p)->code) - 1) + +#define getline(f,pc) (((f)->lineinfo) ? (f)->lineinfo[pc] : 0) + +#define resethookcount(L) (L->hookcount = L->basehookcount) + + +LUAI_FUNC void luaG_typeerror (lua_State *L, const TValue *o, + const char *opname); +LUAI_FUNC void luaG_concaterror (lua_State *L, StkId p1, StkId p2); +LUAI_FUNC void luaG_aritherror (lua_State *L, const TValue *p1, + const TValue *p2); +LUAI_FUNC int luaG_ordererror (lua_State *L, const TValue *p1, + const TValue *p2); +LUAI_FUNC void luaG_runerror (lua_State *L, const char *fmt, ...); +LUAI_FUNC void luaG_errormsg (lua_State *L); +LUAI_FUNC int luaG_checkcode (const Proto *pt); +LUAI_FUNC int luaG_checkopenop (Instruction i); + +#endif diff --git a/mylua/lua/ldo.c b/mylua/lua/ldo.c new file mode 100644 index 0000000..8de05f7 --- /dev/null +++ b/mylua/lua/ldo.c @@ -0,0 +1,518 @@ +/* +** $Id: ldo.c,v 2.38.1.3 2008/01/18 22:31:22 roberto Exp $ +** Stack and Call structure of Lua +** See Copyright Notice in lua.h +*/ + + +#include +#include +#include + +#define ldo_c +#define LUA_CORE + +#include "lua.h" + +#include "ldebug.h" +#include "ldo.h" +#include "lfunc.h" +#include "lgc.h" +#include "lmem.h" +#include "lobject.h" +#include "lopcodes.h" +#include "lparser.h" +#include "lstate.h" +#include "lstring.h" +#include "ltable.h" +#include "ltm.h" +#include "lundump.h" +#include "lvm.h" +#include "lzio.h" + + + + +/* +** {====================================================== +** Error-recovery functions +** ======================================================= +*/ + + +/* chain list of long jump buffers */ +struct lua_longjmp { + struct lua_longjmp *previous; + luai_jmpbuf b; + volatile int status; /* error code */ +}; + + +void luaD_seterrorobj (lua_State *L, int errcode, StkId oldtop) { + switch (errcode) { + case LUA_ERRMEM: { + setsvalue2s(L, oldtop, luaS_newliteral(L, MEMERRMSG)); + break; + } + case LUA_ERRERR: { + setsvalue2s(L, oldtop, luaS_newliteral(L, "error in error handling")); + break; + } + case LUA_ERRSYNTAX: + case LUA_ERRRUN: { + setobjs2s(L, oldtop, L->top - 1); /* error message on current top */ + break; + } + } + L->top = oldtop + 1; +} + + +static void restore_stack_limit (lua_State *L) { + lua_assert(L->stack_last - L->stack == L->stacksize - EXTRA_STACK - 1); + if (L->size_ci > LUAI_MAXCALLS) { /* there was an overflow? */ + int inuse = cast_int(L->ci - L->base_ci); + if (inuse + 1 < LUAI_MAXCALLS) /* can `undo' overflow? */ + luaD_reallocCI(L, LUAI_MAXCALLS); + } +} + + +static void resetstack (lua_State *L, int status) { + L->ci = L->base_ci; + L->base = L->ci->base; + luaF_close(L, L->base); /* close eventual pending closures */ + luaD_seterrorobj(L, status, L->base); + L->nCcalls = L->baseCcalls; + L->allowhook = 1; + restore_stack_limit(L); + L->errfunc = 0; + L->errorJmp = NULL; +} + + +void luaD_throw (lua_State *L, int errcode) { + if (L->errorJmp) { + L->errorJmp->status = errcode; + LUAI_THROW(L, L->errorJmp); + } + else { + L->status = cast_byte(errcode); + if (G(L)->panic) { + resetstack(L, errcode); + lua_unlock(L); + G(L)->panic(L); + } + exit(EXIT_FAILURE); + } +} + + +int luaD_rawrunprotected (lua_State *L, Pfunc f, void *ud) { + struct lua_longjmp lj; + lj.status = 0; + lj.previous = L->errorJmp; /* chain new error handler */ + L->errorJmp = &lj; + LUAI_TRY(L, &lj, + (*f)(L, ud); + ); + L->errorJmp = lj.previous; /* restore old error handler */ + return lj.status; +} + +/* }====================================================== */ + + +static void correctstack (lua_State *L, TValue *oldstack) { + CallInfo *ci; + GCObject *up; + L->top = (L->top - oldstack) + L->stack; + for (up = L->openupval; up != NULL; up = up->gch.next) + gco2uv(up)->v = (gco2uv(up)->v - oldstack) + L->stack; + for (ci = L->base_ci; ci <= L->ci; ci++) { + ci->top = (ci->top - oldstack) + L->stack; + ci->base = (ci->base - oldstack) + L->stack; + ci->func = (ci->func - oldstack) + L->stack; + } + L->base = (L->base - oldstack) + L->stack; +} + + +void luaD_reallocstack (lua_State *L, int newsize) { + TValue *oldstack = L->stack; + int realsize = newsize + 1 + EXTRA_STACK; + lua_assert(L->stack_last - L->stack == L->stacksize - EXTRA_STACK - 1); + luaM_reallocvector(L, L->stack, L->stacksize, realsize, TValue); + L->stacksize = realsize; + L->stack_last = L->stack+newsize; + correctstack(L, oldstack); +} + + +void luaD_reallocCI (lua_State *L, int newsize) { + CallInfo *oldci = L->base_ci; + luaM_reallocvector(L, L->base_ci, L->size_ci, newsize, CallInfo); + L->size_ci = newsize; + L->ci = (L->ci - oldci) + L->base_ci; + L->end_ci = L->base_ci + L->size_ci - 1; +} + + +void luaD_growstack (lua_State *L, int n) { + if (n <= L->stacksize) /* double size is enough? */ + luaD_reallocstack(L, 2*L->stacksize); + else + luaD_reallocstack(L, L->stacksize + n); +} + + +static CallInfo *growCI (lua_State *L) { + if (L->size_ci > LUAI_MAXCALLS) /* overflow while handling overflow? */ + luaD_throw(L, LUA_ERRERR); + else { + luaD_reallocCI(L, 2*L->size_ci); + if (L->size_ci > LUAI_MAXCALLS) + luaG_runerror(L, "stack overflow"); + } + return ++L->ci; +} + + +void luaD_callhook (lua_State *L, int event, int line) { + lua_Hook hook = L->hook; + if (hook && L->allowhook) { + ptrdiff_t top = savestack(L, L->top); + ptrdiff_t ci_top = savestack(L, L->ci->top); + lua_Debug ar; + ar.event = event; + ar.currentline = line; + if (event == LUA_HOOKTAILRET) + ar.i_ci = 0; /* tail call; no debug information about it */ + else + ar.i_ci = cast_int(L->ci - L->base_ci); + luaD_checkstack(L, LUA_MINSTACK); /* ensure minimum stack size */ + L->ci->top = L->top + LUA_MINSTACK; + lua_assert(L->ci->top <= L->stack_last); + L->allowhook = 0; /* cannot call hooks inside a hook */ + lua_unlock(L); + (*hook)(L, &ar); + lua_lock(L); + lua_assert(!L->allowhook); + L->allowhook = 1; + L->ci->top = restorestack(L, ci_top); + L->top = restorestack(L, top); + } +} + + +static StkId adjust_varargs (lua_State *L, Proto *p, int actual) { + int i; + int nfixargs = p->numparams; + Table *htab = NULL; + StkId base, fixed; + for (; actual < nfixargs; ++actual) + setnilvalue(L->top++); +#if defined(LUA_COMPAT_VARARG) + if (p->is_vararg & VARARG_NEEDSARG) { /* compat. with old-style vararg? */ + int nvar = actual - nfixargs; /* number of extra arguments */ + lua_assert(p->is_vararg & VARARG_HASARG); + luaC_checkGC(L); + htab = luaH_new(L, nvar, 1); /* create `arg' table */ + for (i=0; itop - nvar + i); + /* store counter in field `n' */ + setnvalue(luaH_setstr(L, htab, luaS_newliteral(L, "n")), cast_num(nvar)); + } +#endif + /* move fixed parameters to final position */ + fixed = L->top - actual; /* first fixed argument */ + base = L->top; /* final position of first argument */ + for (i=0; itop++, fixed+i); + setnilvalue(fixed+i); + } + /* add `arg' parameter */ + if (htab) { + sethvalue(L, L->top++, htab); + lua_assert(iswhite(obj2gco(htab))); + } + return base; +} + + +static StkId tryfuncTM (lua_State *L, StkId func) { + const TValue *tm = luaT_gettmbyobj(L, func, TM_CALL); + StkId p; + ptrdiff_t funcr = savestack(L, func); + if (!ttisfunction(tm)) + luaG_typeerror(L, func, "call"); + /* Open a hole inside the stack at `func' */ + for (p = L->top; p > func; p--) setobjs2s(L, p, p-1); + incr_top(L); + func = restorestack(L, funcr); /* previous call may change stack */ + setobj2s(L, func, tm); /* tag method is the new function to be called */ + return func; +} + + + +#define inc_ci(L) \ + ((L->ci == L->end_ci) ? growCI(L) : \ + (condhardstacktests(luaD_reallocCI(L, L->size_ci)), ++L->ci)) + + +int luaD_precall (lua_State *L, StkId func, int nresults) { + LClosure *cl; + ptrdiff_t funcr; + if (!ttisfunction(func)) /* `func' is not a function? */ + func = tryfuncTM(L, func); /* check the `function' tag method */ + funcr = savestack(L, func); + cl = &clvalue(func)->l; + L->ci->savedpc = L->savedpc; + if (!cl->isC) { /* Lua function? prepare its call */ + CallInfo *ci; + StkId st, base; + Proto *p = cl->p; + luaD_checkstack(L, p->maxstacksize); + func = restorestack(L, funcr); + if (!p->is_vararg) { /* no varargs? */ + base = func + 1; + if (L->top > base + p->numparams) + L->top = base + p->numparams; + } + else { /* vararg function */ + int nargs = cast_int(L->top - func) - 1; + base = adjust_varargs(L, p, nargs); + func = restorestack(L, funcr); /* previous call may change the stack */ + } + ci = inc_ci(L); /* now `enter' new function */ + ci->func = func; + L->base = ci->base = base; + ci->top = L->base + p->maxstacksize; + lua_assert(ci->top <= L->stack_last); + L->savedpc = p->code; /* starting point */ + ci->tailcalls = 0; + ci->nresults = nresults; + for (st = L->top; st < ci->top; st++) + setnilvalue(st); + L->top = ci->top; + if (L->hookmask & LUA_MASKCALL) { + L->savedpc++; /* hooks assume 'pc' is already incremented */ + luaD_callhook(L, LUA_HOOKCALL, -1); + L->savedpc--; /* correct 'pc' */ + } + return PCRLUA; + } + else { /* if is a C function, call it */ + CallInfo *ci; + int n; + luaD_checkstack(L, LUA_MINSTACK); /* ensure minimum stack size */ + ci = inc_ci(L); /* now `enter' new function */ + ci->func = restorestack(L, funcr); + L->base = ci->base = ci->func + 1; + ci->top = L->top + LUA_MINSTACK; + lua_assert(ci->top <= L->stack_last); + ci->nresults = nresults; + if (L->hookmask & LUA_MASKCALL) + luaD_callhook(L, LUA_HOOKCALL, -1); + lua_unlock(L); + n = (*curr_func(L)->c.f)(L); /* do the actual call */ + lua_lock(L); + if (n < 0) /* yielding? */ + return PCRYIELD; + else { + luaD_poscall(L, L->top - n); + return PCRC; + } + } +} + + +static StkId callrethooks (lua_State *L, StkId firstResult) { + ptrdiff_t fr = savestack(L, firstResult); /* next call may change stack */ + luaD_callhook(L, LUA_HOOKRET, -1); + if (f_isLua(L->ci)) { /* Lua function? */ + while ((L->hookmask & LUA_MASKRET) && L->ci->tailcalls--) /* tail calls */ + luaD_callhook(L, LUA_HOOKTAILRET, -1); + } + return restorestack(L, fr); +} + + +int luaD_poscall (lua_State *L, StkId firstResult) { + StkId res; + int wanted, i; + CallInfo *ci; + if (L->hookmask & LUA_MASKRET) + firstResult = callrethooks(L, firstResult); + ci = L->ci--; + res = ci->func; /* res == final position of 1st result */ + wanted = ci->nresults; + L->base = (ci - 1)->base; /* restore base */ + L->savedpc = (ci - 1)->savedpc; /* restore savedpc */ + /* move results to correct place */ + for (i = wanted; i != 0 && firstResult < L->top; i--) + setobjs2s(L, res++, firstResult++); + while (i-- > 0) + setnilvalue(res++); + L->top = res; + return (wanted - LUA_MULTRET); /* 0 iff wanted == LUA_MULTRET */ +} + + +/* +** Call a function (C or Lua). The function to be called is at *func. +** The arguments are on the stack, right after the function. +** When returns, all the results are on the stack, starting at the original +** function position. +*/ +void luaD_call (lua_State *L, StkId func, int nResults) { + if (++L->nCcalls >= LUAI_MAXCCALLS) { + if (L->nCcalls == LUAI_MAXCCALLS) + luaG_runerror(L, "C stack overflow"); + else if (L->nCcalls >= (LUAI_MAXCCALLS + (LUAI_MAXCCALLS>>3))) + luaD_throw(L, LUA_ERRERR); /* error while handing stack error */ + } + if (luaD_precall(L, func, nResults) == PCRLUA) /* is a Lua function? */ + luaV_execute(L, 1); /* call it */ + L->nCcalls--; + luaC_checkGC(L); +} + + +static void resume (lua_State *L, void *ud) { + StkId firstArg = cast(StkId, ud); + CallInfo *ci = L->ci; + if (L->status == 0) { /* start coroutine? */ + lua_assert(ci == L->base_ci && firstArg > L->base); + if (luaD_precall(L, firstArg - 1, LUA_MULTRET) != PCRLUA) + return; + } + else { /* resuming from previous yield */ + lua_assert(L->status == LUA_YIELD); + L->status = 0; + if (!f_isLua(ci)) { /* `common' yield? */ + /* finish interrupted execution of `OP_CALL' */ + lua_assert(GET_OPCODE(*((ci-1)->savedpc - 1)) == OP_CALL || + GET_OPCODE(*((ci-1)->savedpc - 1)) == OP_TAILCALL); + if (luaD_poscall(L, firstArg)) /* complete it... */ + L->top = L->ci->top; /* and correct top if not multiple results */ + } + else /* yielded inside a hook: just continue its execution */ + L->base = L->ci->base; + } + luaV_execute(L, cast_int(L->ci - L->base_ci)); +} + + +static int resume_error (lua_State *L, const char *msg) { + L->top = L->ci->base; + setsvalue2s(L, L->top, luaS_new(L, msg)); + incr_top(L); + lua_unlock(L); + return LUA_ERRRUN; +} + + +LUA_API int lua_resume (lua_State *L, int nargs) { + int status; + lua_lock(L); + if (L->status != LUA_YIELD && (L->status != 0 || L->ci != L->base_ci)) + return resume_error(L, "cannot resume non-suspended coroutine"); + if (L->nCcalls >= LUAI_MAXCCALLS) + return resume_error(L, "C stack overflow"); + luai_userstateresume(L, nargs); + lua_assert(L->errfunc == 0); + L->baseCcalls = ++L->nCcalls; + status = luaD_rawrunprotected(L, resume, L->top - nargs); + if (status != 0) { /* error? */ + L->status = cast_byte(status); /* mark thread as `dead' */ + luaD_seterrorobj(L, status, L->top); + L->ci->top = L->top; + } + else { + lua_assert(L->nCcalls == L->baseCcalls); + status = L->status; + } + --L->nCcalls; + lua_unlock(L); + return status; +} + + +LUA_API int lua_yield (lua_State *L, int nresults) { + luai_userstateyield(L, nresults); + lua_lock(L); + if (L->nCcalls > L->baseCcalls) + luaG_runerror(L, "attempt to yield across metamethod/C-call boundary"); + L->base = L->top - nresults; /* protect stack slots below */ + L->status = LUA_YIELD; + lua_unlock(L); + return -1; +} + + +int luaD_pcall (lua_State *L, Pfunc func, void *u, + ptrdiff_t old_top, ptrdiff_t ef) { + int status; + unsigned short oldnCcalls = L->nCcalls; + ptrdiff_t old_ci = saveci(L, L->ci); + lu_byte old_allowhooks = L->allowhook; + ptrdiff_t old_errfunc = L->errfunc; + L->errfunc = ef; + status = luaD_rawrunprotected(L, func, u); + if (status != 0) { /* an error occurred? */ + StkId oldtop = restorestack(L, old_top); + luaF_close(L, oldtop); /* close eventual pending closures */ + luaD_seterrorobj(L, status, oldtop); + L->nCcalls = oldnCcalls; + L->ci = restoreci(L, old_ci); + L->base = L->ci->base; + L->savedpc = L->ci->savedpc; + L->allowhook = old_allowhooks; + restore_stack_limit(L); + } + L->errfunc = old_errfunc; + return status; +} + + + +/* +** Execute a protected parser. +*/ +struct SParser { /* data to `f_parser' */ + ZIO *z; + Mbuffer buff; /* buffer to be used by the scanner */ + const char *name; +}; + +static void f_parser (lua_State *L, void *ud) { + int i; + Proto *tf; + Closure *cl; + struct SParser *p = cast(struct SParser *, ud); + int c = luaZ_lookahead(p->z); + luaC_checkGC(L); + tf = ((c == LUA_SIGNATURE[0]) ? luaU_undump : luaY_parser)(L, p->z, + &p->buff, p->name); + cl = luaF_newLclosure(L, tf->nups, hvalue(gt(L))); + cl->l.p = tf; + for (i = 0; i < tf->nups; i++) /* initialize eventual upvalues */ + cl->l.upvals[i] = luaF_newupval(L); + setclvalue(L, L->top, cl); + incr_top(L); +} + + +int luaD_protectedparser (lua_State *L, ZIO *z, const char *name) { + struct SParser p; + int status; + p.z = z; p.name = name; + luaZ_initbuffer(L, &p.buff); + status = luaD_pcall(L, f_parser, &p, savestack(L, L->top), L->errfunc); + luaZ_freebuffer(L, &p.buff); + return status; +} + + diff --git a/mylua/lua/ldo.h b/mylua/lua/ldo.h new file mode 100644 index 0000000..98fddac --- /dev/null +++ b/mylua/lua/ldo.h @@ -0,0 +1,57 @@ +/* +** $Id: ldo.h,v 2.7.1.1 2007/12/27 13:02:25 roberto Exp $ +** Stack and Call structure of Lua +** See Copyright Notice in lua.h +*/ + +#ifndef ldo_h +#define ldo_h + + +#include "lobject.h" +#include "lstate.h" +#include "lzio.h" + + +#define luaD_checkstack(L,n) \ + if ((char *)L->stack_last - (char *)L->top <= (n)*(int)sizeof(TValue)) \ + luaD_growstack(L, n); \ + else condhardstacktests(luaD_reallocstack(L, L->stacksize - EXTRA_STACK - 1)); + + +#define incr_top(L) {luaD_checkstack(L,1); L->top++;} + +#define savestack(L,p) ((char *)(p) - (char *)L->stack) +#define restorestack(L,n) ((TValue *)((char *)L->stack + (n))) + +#define saveci(L,p) ((char *)(p) - (char *)L->base_ci) +#define restoreci(L,n) ((CallInfo *)((char *)L->base_ci + (n))) + + +/* results from luaD_precall */ +#define PCRLUA 0 /* initiated a call to a Lua function */ +#define PCRC 1 /* did a call to a C function */ +#define PCRYIELD 2 /* C funtion yielded */ + + +/* type of protected functions, to be ran by `runprotected' */ +typedef void (*Pfunc) (lua_State *L, void *ud); + +LUAI_FUNC int luaD_protectedparser (lua_State *L, ZIO *z, const char *name); +LUAI_FUNC void luaD_callhook (lua_State *L, int event, int line); +LUAI_FUNC int luaD_precall (lua_State *L, StkId func, int nresults); +LUAI_FUNC void luaD_call (lua_State *L, StkId func, int nResults); +LUAI_FUNC int luaD_pcall (lua_State *L, Pfunc func, void *u, + ptrdiff_t oldtop, ptrdiff_t ef); +LUAI_FUNC int luaD_poscall (lua_State *L, StkId firstResult); +LUAI_FUNC void luaD_reallocCI (lua_State *L, int newsize); +LUAI_FUNC void luaD_reallocstack (lua_State *L, int newsize); +LUAI_FUNC void luaD_growstack (lua_State *L, int n); + +LUAI_FUNC void luaD_throw (lua_State *L, int errcode); +LUAI_FUNC int luaD_rawrunprotected (lua_State *L, Pfunc f, void *ud); + +LUAI_FUNC void luaD_seterrorobj (lua_State *L, int errcode, StkId oldtop); + +#endif + diff --git a/mylua/lua/ldump.c b/mylua/lua/ldump.c new file mode 100644 index 0000000..c9d3d48 --- /dev/null +++ b/mylua/lua/ldump.c @@ -0,0 +1,164 @@ +/* +** $Id: ldump.c,v 2.8.1.1 2007/12/27 13:02:25 roberto Exp $ +** save precompiled Lua chunks +** See Copyright Notice in lua.h +*/ + +#include + +#define ldump_c +#define LUA_CORE + +#include "lua.h" + +#include "lobject.h" +#include "lstate.h" +#include "lundump.h" + +typedef struct { + lua_State* L; + lua_Writer writer; + void* data; + int strip; + int status; +} DumpState; + +#define DumpMem(b,n,size,D) DumpBlock(b,(n)*(size),D) +#define DumpVar(x,D) DumpMem(&x,1,sizeof(x),D) + +static void DumpBlock(const void* b, size_t size, DumpState* D) +{ + if (D->status==0) + { + lua_unlock(D->L); + D->status=(*D->writer)(D->L,b,size,D->data); + lua_lock(D->L); + } +} + +static void DumpChar(int y, DumpState* D) +{ + char x=(char)y; + DumpVar(x,D); +} + +static void DumpInt(int x, DumpState* D) +{ + DumpVar(x,D); +} + +static void DumpNumber(lua_Number x, DumpState* D) +{ + DumpVar(x,D); +} + +static void DumpVector(const void* b, int n, size_t size, DumpState* D) +{ + DumpInt(n,D); + DumpMem(b,n,size,D); +} + +static void DumpString(const TString* s, DumpState* D) +{ + if (s==NULL || getstr(s)==NULL) + { + size_t size=0; + DumpVar(size,D); + } + else + { + size_t size=s->tsv.len+1; /* include trailing '\0' */ + DumpVar(size,D); + DumpBlock(getstr(s),size,D); + } +} + +#define DumpCode(f,D) DumpVector(f->code,f->sizecode,sizeof(Instruction),D) + +static void DumpFunction(const Proto* f, const TString* p, DumpState* D); + +static void DumpConstants(const Proto* f, DumpState* D) +{ + int i,n=f->sizek; + DumpInt(n,D); + for (i=0; ik[i]; + DumpChar(ttype(o),D); + switch (ttype(o)) + { + case LUA_TNIL: + break; + case LUA_TBOOLEAN: + DumpChar(bvalue(o),D); + break; + case LUA_TNUMBER: + DumpNumber(nvalue(o),D); + break; + case LUA_TSTRING: + DumpString(rawtsvalue(o),D); + break; + default: + lua_assert(0); /* cannot happen */ + break; + } + } + n=f->sizep; + DumpInt(n,D); + for (i=0; ip[i],f->source,D); +} + +static void DumpDebug(const Proto* f, DumpState* D) +{ + int i,n; + n= (D->strip) ? 0 : f->sizelineinfo; + DumpVector(f->lineinfo,n,sizeof(int),D); + n= (D->strip) ? 0 : f->sizelocvars; + DumpInt(n,D); + for (i=0; ilocvars[i].varname,D); + DumpInt(f->locvars[i].startpc,D); + DumpInt(f->locvars[i].endpc,D); + } + n= (D->strip) ? 0 : f->sizeupvalues; + DumpInt(n,D); + for (i=0; iupvalues[i],D); +} + +static void DumpFunction(const Proto* f, const TString* p, DumpState* D) +{ + DumpString((f->source==p || D->strip) ? NULL : f->source,D); + DumpInt(f->linedefined,D); + DumpInt(f->lastlinedefined,D); + DumpChar(f->nups,D); + DumpChar(f->numparams,D); + DumpChar(f->is_vararg,D); + DumpChar(f->maxstacksize,D); + DumpCode(f,D); + DumpConstants(f,D); + DumpDebug(f,D); +} + +static void DumpHeader(DumpState* D) +{ + char h[LUAC_HEADERSIZE]; + luaU_header(h); + DumpBlock(h,LUAC_HEADERSIZE,D); +} + +/* +** dump Lua function as precompiled chunk +*/ +int luaU_dump (lua_State* L, const Proto* f, lua_Writer w, void* data, int strip) +{ + DumpState D; + D.L=L; + D.writer=w; + D.data=data; + D.strip=strip; + D.status=0; + DumpHeader(&D); + DumpFunction(f,NULL,&D); + return D.status; +} diff --git a/mylua/lua/lfunc.c b/mylua/lua/lfunc.c new file mode 100644 index 0000000..813e88f --- /dev/null +++ b/mylua/lua/lfunc.c @@ -0,0 +1,174 @@ +/* +** $Id: lfunc.c,v 2.12.1.2 2007/12/28 14:58:43 roberto Exp $ +** Auxiliary functions to manipulate prototypes and closures +** See Copyright Notice in lua.h +*/ + + +#include + +#define lfunc_c +#define LUA_CORE + +#include "lua.h" + +#include "lfunc.h" +#include "lgc.h" +#include "lmem.h" +#include "lobject.h" +#include "lstate.h" + + + +Closure *luaF_newCclosure (lua_State *L, int nelems, Table *e) { + Closure *c = cast(Closure *, luaM_malloc(L, sizeCclosure(nelems))); + luaC_link(L, obj2gco(c), LUA_TFUNCTION); + c->c.isC = 1; + c->c.env = e; + c->c.nupvalues = cast_byte(nelems); + return c; +} + + +Closure *luaF_newLclosure (lua_State *L, int nelems, Table *e) { + Closure *c = cast(Closure *, luaM_malloc(L, sizeLclosure(nelems))); + luaC_link(L, obj2gco(c), LUA_TFUNCTION); + c->l.isC = 0; + c->l.env = e; + c->l.nupvalues = cast_byte(nelems); + while (nelems--) c->l.upvals[nelems] = NULL; + return c; +} + + +UpVal *luaF_newupval (lua_State *L) { + UpVal *uv = luaM_new(L, UpVal); + luaC_link(L, obj2gco(uv), LUA_TUPVAL); + uv->v = &uv->u.value; + setnilvalue(uv->v); + return uv; +} + + +UpVal *luaF_findupval (lua_State *L, StkId level) { + global_State *g = G(L); + GCObject **pp = &L->openupval; + UpVal *p; + UpVal *uv; + while (*pp != NULL && (p = ngcotouv(*pp))->v >= level) { + lua_assert(p->v != &p->u.value); + if (p->v == level) { /* found a corresponding upvalue? */ + if (isdead(g, obj2gco(p))) /* is it dead? */ + changewhite(obj2gco(p)); /* ressurect it */ + return p; + } + pp = &p->next; + } + uv = luaM_new(L, UpVal); /* not found: create a new one */ + uv->tt = LUA_TUPVAL; + uv->marked = luaC_white(g); + uv->v = level; /* current value lives in the stack */ + uv->next = *pp; /* chain it in the proper position */ + *pp = obj2gco(uv); + uv->u.l.prev = &g->uvhead; /* double link it in `uvhead' list */ + uv->u.l.next = g->uvhead.u.l.next; + uv->u.l.next->u.l.prev = uv; + g->uvhead.u.l.next = uv; + lua_assert(uv->u.l.next->u.l.prev == uv && uv->u.l.prev->u.l.next == uv); + return uv; +} + + +static void unlinkupval (UpVal *uv) { + lua_assert(uv->u.l.next->u.l.prev == uv && uv->u.l.prev->u.l.next == uv); + uv->u.l.next->u.l.prev = uv->u.l.prev; /* remove from `uvhead' list */ + uv->u.l.prev->u.l.next = uv->u.l.next; +} + + +void luaF_freeupval (lua_State *L, UpVal *uv) { + if (uv->v != &uv->u.value) /* is it open? */ + unlinkupval(uv); /* remove from open list */ + luaM_free(L, uv); /* free upvalue */ +} + + +void luaF_close (lua_State *L, StkId level) { + UpVal *uv; + global_State *g = G(L); + while (L->openupval != NULL && (uv = ngcotouv(L->openupval))->v >= level) { + GCObject *o = obj2gco(uv); + lua_assert(!isblack(o) && uv->v != &uv->u.value); + L->openupval = uv->next; /* remove from `open' list */ + if (isdead(g, o)) + luaF_freeupval(L, uv); /* free upvalue */ + else { + unlinkupval(uv); + setobj(L, &uv->u.value, uv->v); + uv->v = &uv->u.value; /* now current value lives here */ + luaC_linkupval(L, uv); /* link upvalue into `gcroot' list */ + } + } +} + + +Proto *luaF_newproto (lua_State *L) { + Proto *f = luaM_new(L, Proto); + luaC_link(L, obj2gco(f), LUA_TPROTO); + f->k = NULL; + f->sizek = 0; + f->p = NULL; + f->sizep = 0; + f->code = NULL; + f->sizecode = 0; + f->sizelineinfo = 0; + f->sizeupvalues = 0; + f->nups = 0; + f->upvalues = NULL; + f->numparams = 0; + f->is_vararg = 0; + f->maxstacksize = 0; + f->lineinfo = NULL; + f->sizelocvars = 0; + f->locvars = NULL; + f->linedefined = 0; + f->lastlinedefined = 0; + f->source = NULL; + return f; +} + + +void luaF_freeproto (lua_State *L, Proto *f) { + luaM_freearray(L, f->code, f->sizecode, Instruction); + luaM_freearray(L, f->p, f->sizep, Proto *); + luaM_freearray(L, f->k, f->sizek, TValue); + luaM_freearray(L, f->lineinfo, f->sizelineinfo, int); + luaM_freearray(L, f->locvars, f->sizelocvars, struct LocVar); + luaM_freearray(L, f->upvalues, f->sizeupvalues, TString *); + luaM_free(L, f); +} + + +void luaF_freeclosure (lua_State *L, Closure *c) { + int size = (c->c.isC) ? sizeCclosure(c->c.nupvalues) : + sizeLclosure(c->l.nupvalues); + luaM_freemem(L, c, size); +} + + +/* +** Look for n-th local variable at line `line' in function `func'. +** Returns NULL if not found. +*/ +const char *luaF_getlocalname (const Proto *f, int local_number, int pc) { + int i; + for (i = 0; isizelocvars && f->locvars[i].startpc <= pc; i++) { + if (pc < f->locvars[i].endpc) { /* is variable active? */ + local_number--; + if (local_number == 0) + return getstr(f->locvars[i].varname); + } + } + return NULL; /* not found */ +} + diff --git a/mylua/lua/lfunc.h b/mylua/lua/lfunc.h new file mode 100644 index 0000000..a68cf51 --- /dev/null +++ b/mylua/lua/lfunc.h @@ -0,0 +1,34 @@ +/* +** $Id: lfunc.h,v 2.4.1.1 2007/12/27 13:02:25 roberto Exp $ +** Auxiliary functions to manipulate prototypes and closures +** See Copyright Notice in lua.h +*/ + +#ifndef lfunc_h +#define lfunc_h + + +#include "lobject.h" + + +#define sizeCclosure(n) (cast(int, sizeof(CClosure)) + \ + cast(int, sizeof(TValue)*((n)-1))) + +#define sizeLclosure(n) (cast(int, sizeof(LClosure)) + \ + cast(int, sizeof(TValue *)*((n)-1))) + + +LUAI_FUNC Proto *luaF_newproto (lua_State *L); +LUAI_FUNC Closure *luaF_newCclosure (lua_State *L, int nelems, Table *e); +LUAI_FUNC Closure *luaF_newLclosure (lua_State *L, int nelems, Table *e); +LUAI_FUNC UpVal *luaF_newupval (lua_State *L); +LUAI_FUNC UpVal *luaF_findupval (lua_State *L, StkId level); +LUAI_FUNC void luaF_close (lua_State *L, StkId level); +LUAI_FUNC void luaF_freeproto (lua_State *L, Proto *f); +LUAI_FUNC void luaF_freeclosure (lua_State *L, Closure *c); +LUAI_FUNC void luaF_freeupval (lua_State *L, UpVal *uv); +LUAI_FUNC const char *luaF_getlocalname (const Proto *func, int local_number, + int pc); + + +#endif diff --git a/mylua/lua/lgc.c b/mylua/lua/lgc.c new file mode 100644 index 0000000..d9e0b78 --- /dev/null +++ b/mylua/lua/lgc.c @@ -0,0 +1,711 @@ +/* +** $Id: lgc.c,v 2.38.1.1 2007/12/27 13:02:25 roberto Exp $ +** Garbage Collector +** See Copyright Notice in lua.h +*/ + +#include + +#define lgc_c +#define LUA_CORE + +#include "lua.h" + +#include "ldebug.h" +#include "ldo.h" +#include "lfunc.h" +#include "lgc.h" +#include "lmem.h" +#include "lobject.h" +#include "lstate.h" +#include "lstring.h" +#include "ltable.h" +#include "ltm.h" + + +#define GCSTEPSIZE 1024u +#define GCSWEEPMAX 40 +#define GCSWEEPCOST 10 +#define GCFINALIZECOST 100 + + +#define maskmarks cast_byte(~(bitmask(BLACKBIT)|WHITEBITS)) + +#define makewhite(g,x) \ + ((x)->gch.marked = cast_byte(((x)->gch.marked & maskmarks) | luaC_white(g))) + +#define white2gray(x) reset2bits((x)->gch.marked, WHITE0BIT, WHITE1BIT) +#define black2gray(x) resetbit((x)->gch.marked, BLACKBIT) + +#define stringmark(s) reset2bits((s)->tsv.marked, WHITE0BIT, WHITE1BIT) + + +#define isfinalized(u) testbit((u)->marked, FINALIZEDBIT) +#define markfinalized(u) l_setbit((u)->marked, FINALIZEDBIT) + + +#define KEYWEAK bitmask(KEYWEAKBIT) +#define VALUEWEAK bitmask(VALUEWEAKBIT) + + + +#define markvalue(g,o) { checkconsistency(o); \ + if (iscollectable(o) && iswhite(gcvalue(o))) reallymarkobject(g,gcvalue(o)); } + +#define markobject(g,t) { if (iswhite(obj2gco(t))) \ + reallymarkobject(g, obj2gco(t)); } + + +#define setthreshold(g) (g->GCthreshold = (g->estimate/100) * g->gcpause) + + +static void removeentry (Node *n) { + lua_assert(ttisnil(gval(n))); + if (iscollectable(gkey(n))) + setttype(gkey(n), LUA_TDEADKEY); /* dead key; remove it */ +} + + +static void reallymarkobject (global_State *g, GCObject *o) { + lua_assert(iswhite(o) && !isdead(g, o)); + white2gray(o); + switch (o->gch.tt) { + case LUA_TSTRING: { + return; + } + case LUA_TUSERDATA: { + Table *mt = gco2u(o)->metatable; + gray2black(o); /* udata are never gray */ + if (mt) markobject(g, mt); + markobject(g, gco2u(o)->env); + return; + } + case LUA_TUPVAL: { + UpVal *uv = gco2uv(o); + markvalue(g, uv->v); + if (uv->v == &uv->u.value) /* closed? */ + gray2black(o); /* open upvalues are never black */ + return; + } + case LUA_TFUNCTION: { + gco2cl(o)->c.gclist = g->gray; + g->gray = o; + break; + } + case LUA_TTABLE: { + gco2h(o)->gclist = g->gray; + g->gray = o; + break; + } + case LUA_TTHREAD: { + gco2th(o)->gclist = g->gray; + g->gray = o; + break; + } + case LUA_TPROTO: { + gco2p(o)->gclist = g->gray; + g->gray = o; + break; + } + default: lua_assert(0); + } +} + + +static void marktmu (global_State *g) { + GCObject *u = g->tmudata; + if (u) { + do { + u = u->gch.next; + makewhite(g, u); /* may be marked, if left from previous GC */ + reallymarkobject(g, u); + } while (u != g->tmudata); + } +} + + +/* move `dead' udata that need finalization to list `tmudata' */ +size_t luaC_separateudata (lua_State *L, int all) { + global_State *g = G(L); + size_t deadmem = 0; + GCObject **p = &g->mainthread->next; + GCObject *curr; + while ((curr = *p) != NULL) { + if (!(iswhite(curr) || all) || isfinalized(gco2u(curr))) + p = &curr->gch.next; /* don't bother with them */ + else if (fasttm(L, gco2u(curr)->metatable, TM_GC) == NULL) { + markfinalized(gco2u(curr)); /* don't need finalization */ + p = &curr->gch.next; + } + else { /* must call its gc method */ + deadmem += sizeudata(gco2u(curr)); + markfinalized(gco2u(curr)); + *p = curr->gch.next; + /* link `curr' at the end of `tmudata' list */ + if (g->tmudata == NULL) /* list is empty? */ + g->tmudata = curr->gch.next = curr; /* creates a circular list */ + else { + curr->gch.next = g->tmudata->gch.next; + g->tmudata->gch.next = curr; + g->tmudata = curr; + } + } + } + return deadmem; +} + + +static int traversetable (global_State *g, Table *h) { + int i; + int weakkey = 0; + int weakvalue = 0; + const TValue *mode; + if (h->metatable) + markobject(g, h->metatable); + mode = gfasttm(g, h->metatable, TM_MODE); + if (mode && ttisstring(mode)) { /* is there a weak mode? */ + weakkey = (strchr(svalue(mode), 'k') != NULL); + weakvalue = (strchr(svalue(mode), 'v') != NULL); + if (weakkey || weakvalue) { /* is really weak? */ + h->marked &= ~(KEYWEAK | VALUEWEAK); /* clear bits */ + h->marked |= cast_byte((weakkey << KEYWEAKBIT) | + (weakvalue << VALUEWEAKBIT)); + h->gclist = g->weak; /* must be cleared after GC, ... */ + g->weak = obj2gco(h); /* ... so put in the appropriate list */ + } + } + if (weakkey && weakvalue) return 1; + if (!weakvalue) { + i = h->sizearray; + while (i--) + markvalue(g, &h->array[i]); + } + i = sizenode(h); + while (i--) { + Node *n = gnode(h, i); + lua_assert(ttype(gkey(n)) != LUA_TDEADKEY || ttisnil(gval(n))); + if (ttisnil(gval(n))) + removeentry(n); /* remove empty entries */ + else { + lua_assert(!ttisnil(gkey(n))); + if (!weakkey) markvalue(g, gkey(n)); + if (!weakvalue) markvalue(g, gval(n)); + } + } + return weakkey || weakvalue; +} + + +/* +** All marks are conditional because a GC may happen while the +** prototype is still being created +*/ +static void traverseproto (global_State *g, Proto *f) { + int i; + if (f->source) stringmark(f->source); + for (i=0; isizek; i++) /* mark literals */ + markvalue(g, &f->k[i]); + for (i=0; isizeupvalues; i++) { /* mark upvalue names */ + if (f->upvalues[i]) + stringmark(f->upvalues[i]); + } + for (i=0; isizep; i++) { /* mark nested protos */ + if (f->p[i]) + markobject(g, f->p[i]); + } + for (i=0; isizelocvars; i++) { /* mark local-variable names */ + if (f->locvars[i].varname) + stringmark(f->locvars[i].varname); + } +} + + + +static void traverseclosure (global_State *g, Closure *cl) { + markobject(g, cl->c.env); + if (cl->c.isC) { + int i; + for (i=0; ic.nupvalues; i++) /* mark its upvalues */ + markvalue(g, &cl->c.upvalue[i]); + } + else { + int i; + lua_assert(cl->l.nupvalues == cl->l.p->nups); + markobject(g, cl->l.p); + for (i=0; il.nupvalues; i++) /* mark its upvalues */ + markobject(g, cl->l.upvals[i]); + } +} + + +static void checkstacksizes (lua_State *L, StkId max) { + int ci_used = cast_int(L->ci - L->base_ci); /* number of `ci' in use */ + int s_used = cast_int(max - L->stack); /* part of stack in use */ + if (L->size_ci > LUAI_MAXCALLS) /* handling overflow? */ + return; /* do not touch the stacks */ + if (4*ci_used < L->size_ci && 2*BASIC_CI_SIZE < L->size_ci) + luaD_reallocCI(L, L->size_ci/2); /* still big enough... */ + condhardstacktests(luaD_reallocCI(L, ci_used + 1)); + if (4*s_used < L->stacksize && + 2*(BASIC_STACK_SIZE+EXTRA_STACK) < L->stacksize) + luaD_reallocstack(L, L->stacksize/2); /* still big enough... */ + condhardstacktests(luaD_reallocstack(L, s_used)); +} + + +static void traversestack (global_State *g, lua_State *l) { + StkId o, lim; + CallInfo *ci; + markvalue(g, gt(l)); + lim = l->top; + for (ci = l->base_ci; ci <= l->ci; ci++) { + lua_assert(ci->top <= l->stack_last); + if (lim < ci->top) lim = ci->top; + } + for (o = l->stack; o < l->top; o++) + markvalue(g, o); + for (; o <= lim; o++) + setnilvalue(o); + checkstacksizes(l, lim); +} + + +/* +** traverse one gray object, turning it to black. +** Returns `quantity' traversed. +*/ +static l_mem propagatemark (global_State *g) { + GCObject *o = g->gray; + lua_assert(isgray(o)); + gray2black(o); + switch (o->gch.tt) { + case LUA_TTABLE: { + Table *h = gco2h(o); + g->gray = h->gclist; + if (traversetable(g, h)) /* table is weak? */ + black2gray(o); /* keep it gray */ + return sizeof(Table) + sizeof(TValue) * h->sizearray + + sizeof(Node) * sizenode(h); + } + case LUA_TFUNCTION: { + Closure *cl = gco2cl(o); + g->gray = cl->c.gclist; + traverseclosure(g, cl); + return (cl->c.isC) ? sizeCclosure(cl->c.nupvalues) : + sizeLclosure(cl->l.nupvalues); + } + case LUA_TTHREAD: { + lua_State *th = gco2th(o); + g->gray = th->gclist; + th->gclist = g->grayagain; + g->grayagain = o; + black2gray(o); + traversestack(g, th); + return sizeof(lua_State) + sizeof(TValue) * th->stacksize + + sizeof(CallInfo) * th->size_ci; + } + case LUA_TPROTO: { + Proto *p = gco2p(o); + g->gray = p->gclist; + traverseproto(g, p); + return sizeof(Proto) + sizeof(Instruction) * p->sizecode + + sizeof(Proto *) * p->sizep + + sizeof(TValue) * p->sizek + + sizeof(int) * p->sizelineinfo + + sizeof(LocVar) * p->sizelocvars + + sizeof(TString *) * p->sizeupvalues; + } + default: lua_assert(0); return 0; + } +} + + +static size_t propagateall (global_State *g) { + size_t m = 0; + while (g->gray) m += propagatemark(g); + return m; +} + + +/* +** The next function tells whether a key or value can be cleared from +** a weak table. Non-collectable objects are never removed from weak +** tables. Strings behave as `values', so are never removed too. for +** other objects: if really collected, cannot keep them; for userdata +** being finalized, keep them in keys, but not in values +*/ +static int iscleared (const TValue *o, int iskey) { + if (!iscollectable(o)) return 0; + if (ttisstring(o)) { + stringmark(rawtsvalue(o)); /* strings are `values', so are never weak */ + return 0; + } + return iswhite(gcvalue(o)) || + (ttisuserdata(o) && (!iskey && isfinalized(uvalue(o)))); +} + + +/* +** clear collected entries from weaktables +*/ +static void cleartable (GCObject *l) { + while (l) { + Table *h = gco2h(l); + int i = h->sizearray; + lua_assert(testbit(h->marked, VALUEWEAKBIT) || + testbit(h->marked, KEYWEAKBIT)); + if (testbit(h->marked, VALUEWEAKBIT)) { + while (i--) { + TValue *o = &h->array[i]; + if (iscleared(o, 0)) /* value was collected? */ + setnilvalue(o); /* remove value */ + } + } + i = sizenode(h); + while (i--) { + Node *n = gnode(h, i); + if (!ttisnil(gval(n)) && /* non-empty entry? */ + (iscleared(key2tval(n), 1) || iscleared(gval(n), 0))) { + setnilvalue(gval(n)); /* remove value ... */ + removeentry(n); /* remove entry from table */ + } + } + l = h->gclist; + } +} + + +static void freeobj (lua_State *L, GCObject *o) { + switch (o->gch.tt) { + case LUA_TPROTO: luaF_freeproto(L, gco2p(o)); break; + case LUA_TFUNCTION: luaF_freeclosure(L, gco2cl(o)); break; + case LUA_TUPVAL: luaF_freeupval(L, gco2uv(o)); break; + case LUA_TTABLE: luaH_free(L, gco2h(o)); break; + case LUA_TTHREAD: { + lua_assert(gco2th(o) != L && gco2th(o) != G(L)->mainthread); + luaE_freethread(L, gco2th(o)); + break; + } + case LUA_TSTRING: { + G(L)->strt.nuse--; + luaM_freemem(L, o, sizestring(gco2ts(o))); + break; + } + case LUA_TUSERDATA: { + luaM_freemem(L, o, sizeudata(gco2u(o))); + break; + } + default: lua_assert(0); + } +} + + + +#define sweepwholelist(L,p) sweeplist(L,p,MAX_LUMEM) + + +static GCObject **sweeplist (lua_State *L, GCObject **p, lu_mem count) { + GCObject *curr; + global_State *g = G(L); + int deadmask = otherwhite(g); + while ((curr = *p) != NULL && count-- > 0) { + if (curr->gch.tt == LUA_TTHREAD) /* sweep open upvalues of each thread */ + sweepwholelist(L, &gco2th(curr)->openupval); + if ((curr->gch.marked ^ WHITEBITS) & deadmask) { /* not dead? */ + lua_assert(!isdead(g, curr) || testbit(curr->gch.marked, FIXEDBIT)); + makewhite(g, curr); /* make it white (for next cycle) */ + p = &curr->gch.next; + } + else { /* must erase `curr' */ + lua_assert(isdead(g, curr) || deadmask == bitmask(SFIXEDBIT)); + *p = curr->gch.next; + if (curr == g->rootgc) /* is the first element of the list? */ + g->rootgc = curr->gch.next; /* adjust first */ + freeobj(L, curr); + } + } + return p; +} + + +static void checkSizes (lua_State *L) { + global_State *g = G(L); + /* check size of string hash */ + if (g->strt.nuse < cast(lu_int32, g->strt.size/4) && + g->strt.size > MINSTRTABSIZE*2) + luaS_resize(L, g->strt.size/2); /* table is too big */ + /* check size of buffer */ + if (luaZ_sizebuffer(&g->buff) > LUA_MINBUFFER*2) { /* buffer too big? */ + size_t newsize = luaZ_sizebuffer(&g->buff) / 2; + luaZ_resizebuffer(L, &g->buff, newsize); + } +} + + +static void GCTM (lua_State *L) { + global_State *g = G(L); + GCObject *o = g->tmudata->gch.next; /* get first element */ + Udata *udata = rawgco2u(o); + const TValue *tm; + /* remove udata from `tmudata' */ + if (o == g->tmudata) /* last element? */ + g->tmudata = NULL; + else + g->tmudata->gch.next = udata->uv.next; + udata->uv.next = g->mainthread->next; /* return it to `root' list */ + g->mainthread->next = o; + makewhite(g, o); + tm = fasttm(L, udata->uv.metatable, TM_GC); + if (tm != NULL) { + lu_byte oldah = L->allowhook; + lu_mem oldt = g->GCthreshold; + L->allowhook = 0; /* stop debug hooks during GC tag method */ + g->GCthreshold = 2*g->totalbytes; /* avoid GC steps */ + setobj2s(L, L->top, tm); + setuvalue(L, L->top+1, udata); + L->top += 2; + luaD_call(L, L->top - 2, 0); + L->allowhook = oldah; /* restore hooks */ + g->GCthreshold = oldt; /* restore threshold */ + } +} + + +/* +** Call all GC tag methods +*/ +void luaC_callGCTM (lua_State *L) { + while (G(L)->tmudata) + GCTM(L); +} + + +void luaC_freeall (lua_State *L) { + global_State *g = G(L); + int i; + g->currentwhite = WHITEBITS | bitmask(SFIXEDBIT); /* mask to collect all elements */ + sweepwholelist(L, &g->rootgc); + for (i = 0; i < g->strt.size; i++) /* free all string lists */ + sweepwholelist(L, &g->strt.hash[i]); +} + + +static void markmt (global_State *g) { + int i; + for (i=0; imt[i]) markobject(g, g->mt[i]); +} + + +/* mark root set */ +static void markroot (lua_State *L) { + global_State *g = G(L); + g->gray = NULL; + g->grayagain = NULL; + g->weak = NULL; + markobject(g, g->mainthread); + /* make global table be traversed before main stack */ + markvalue(g, gt(g->mainthread)); + markvalue(g, registry(L)); + markmt(g); + g->gcstate = GCSpropagate; +} + + +static void remarkupvals (global_State *g) { + UpVal *uv; + for (uv = g->uvhead.u.l.next; uv != &g->uvhead; uv = uv->u.l.next) { + lua_assert(uv->u.l.next->u.l.prev == uv && uv->u.l.prev->u.l.next == uv); + if (isgray(obj2gco(uv))) + markvalue(g, uv->v); + } +} + + +static void atomic (lua_State *L) { + global_State *g = G(L); + size_t udsize; /* total size of userdata to be finalized */ + /* remark occasional upvalues of (maybe) dead threads */ + remarkupvals(g); + /* traverse objects cautch by write barrier and by 'remarkupvals' */ + propagateall(g); + /* remark weak tables */ + g->gray = g->weak; + g->weak = NULL; + lua_assert(!iswhite(obj2gco(g->mainthread))); + markobject(g, L); /* mark running thread */ + markmt(g); /* mark basic metatables (again) */ + propagateall(g); + /* remark gray again */ + g->gray = g->grayagain; + g->grayagain = NULL; + propagateall(g); + udsize = luaC_separateudata(L, 0); /* separate userdata to be finalized */ + marktmu(g); /* mark `preserved' userdata */ + udsize += propagateall(g); /* remark, to propagate `preserveness' */ + cleartable(g->weak); /* remove collected objects from weak tables */ + /* flip current white */ + g->currentwhite = cast_byte(otherwhite(g)); + g->sweepstrgc = 0; + g->sweepgc = &g->rootgc; + g->gcstate = GCSsweepstring; + g->estimate = g->totalbytes - udsize; /* first estimate */ +} + + +static l_mem singlestep (lua_State *L) { + global_State *g = G(L); + /*lua_checkmemory(L);*/ + switch (g->gcstate) { + case GCSpause: { + markroot(L); /* start a new collection */ + return 0; + } + case GCSpropagate: { + if (g->gray) + return propagatemark(g); + else { /* no more `gray' objects */ + atomic(L); /* finish mark phase */ + return 0; + } + } + case GCSsweepstring: { + lu_mem old = g->totalbytes; + sweepwholelist(L, &g->strt.hash[g->sweepstrgc++]); + if (g->sweepstrgc >= g->strt.size) /* nothing more to sweep? */ + g->gcstate = GCSsweep; /* end sweep-string phase */ + lua_assert(old >= g->totalbytes); + g->estimate -= old - g->totalbytes; + return GCSWEEPCOST; + } + case GCSsweep: { + lu_mem old = g->totalbytes; + g->sweepgc = sweeplist(L, g->sweepgc, GCSWEEPMAX); + if (*g->sweepgc == NULL) { /* nothing more to sweep? */ + checkSizes(L); + g->gcstate = GCSfinalize; /* end sweep phase */ + } + lua_assert(old >= g->totalbytes); + g->estimate -= old - g->totalbytes; + return GCSWEEPMAX*GCSWEEPCOST; + } + case GCSfinalize: { + if (g->tmudata) { + GCTM(L); + if (g->estimate > GCFINALIZECOST) + g->estimate -= GCFINALIZECOST; + return GCFINALIZECOST; + } + else { + g->gcstate = GCSpause; /* end collection */ + g->gcdept = 0; + return 0; + } + } + default: lua_assert(0); return 0; + } +} + + +void luaC_step (lua_State *L) { + global_State *g = G(L); + l_mem lim = (GCSTEPSIZE/100) * g->gcstepmul; + if (lim == 0) + lim = (MAX_LUMEM-1)/2; /* no limit */ + g->gcdept += g->totalbytes - g->GCthreshold; + do { + lim -= singlestep(L); + if (g->gcstate == GCSpause) + break; + } while (lim > 0); + if (g->gcstate != GCSpause) { + if (g->gcdept < GCSTEPSIZE) + g->GCthreshold = g->totalbytes + GCSTEPSIZE; /* - lim/g->gcstepmul;*/ + else { + g->gcdept -= GCSTEPSIZE; + g->GCthreshold = g->totalbytes; + } + } + else { + lua_assert(g->totalbytes >= g->estimate); + setthreshold(g); + } +} + + +void luaC_fullgc (lua_State *L) { + global_State *g = G(L); + if (g->gcstate <= GCSpropagate) { + /* reset sweep marks to sweep all elements (returning them to white) */ + g->sweepstrgc = 0; + g->sweepgc = &g->rootgc; + /* reset other collector lists */ + g->gray = NULL; + g->grayagain = NULL; + g->weak = NULL; + g->gcstate = GCSsweepstring; + } + lua_assert(g->gcstate != GCSpause && g->gcstate != GCSpropagate); + /* finish any pending sweep phase */ + while (g->gcstate != GCSfinalize) { + lua_assert(g->gcstate == GCSsweepstring || g->gcstate == GCSsweep); + singlestep(L); + } + markroot(L); + while (g->gcstate != GCSpause) { + singlestep(L); + } + setthreshold(g); +} + + +void luaC_barrierf (lua_State *L, GCObject *o, GCObject *v) { + global_State *g = G(L); + lua_assert(isblack(o) && iswhite(v) && !isdead(g, v) && !isdead(g, o)); + lua_assert(g->gcstate != GCSfinalize && g->gcstate != GCSpause); + lua_assert(ttype(&o->gch) != LUA_TTABLE); + /* must keep invariant? */ + if (g->gcstate == GCSpropagate) + reallymarkobject(g, v); /* restore invariant */ + else /* don't mind */ + makewhite(g, o); /* mark as white just to avoid other barriers */ +} + + +void luaC_barrierback (lua_State *L, Table *t) { + global_State *g = G(L); + GCObject *o = obj2gco(t); + lua_assert(isblack(o) && !isdead(g, o)); + lua_assert(g->gcstate != GCSfinalize && g->gcstate != GCSpause); + black2gray(o); /* make table gray (again) */ + t->gclist = g->grayagain; + g->grayagain = o; +} + + +void luaC_link (lua_State *L, GCObject *o, lu_byte tt) { + global_State *g = G(L); + o->gch.next = g->rootgc; + g->rootgc = o; + o->gch.marked = luaC_white(g); + o->gch.tt = tt; +} + + +void luaC_linkupval (lua_State *L, UpVal *uv) { + global_State *g = G(L); + GCObject *o = obj2gco(uv); + o->gch.next = g->rootgc; /* link upvalue into `rootgc' list */ + g->rootgc = o; + if (isgray(o)) { + if (g->gcstate == GCSpropagate) { + gray2black(o); /* closed upvalues need barrier */ + luaC_barrier(L, uv, uv->v); + } + else { /* sweep phase: sweep it (turning it into white) */ + makewhite(g, o); + lua_assert(g->gcstate != GCSfinalize && g->gcstate != GCSpause); + } + } +} + diff --git a/mylua/lua/lgc.h b/mylua/lua/lgc.h new file mode 100644 index 0000000..5a8dc60 --- /dev/null +++ b/mylua/lua/lgc.h @@ -0,0 +1,110 @@ +/* +** $Id: lgc.h,v 2.15.1.1 2007/12/27 13:02:25 roberto Exp $ +** Garbage Collector +** See Copyright Notice in lua.h +*/ + +#ifndef lgc_h +#define lgc_h + + +#include "lobject.h" + + +/* +** Possible states of the Garbage Collector +*/ +#define GCSpause 0 +#define GCSpropagate 1 +#define GCSsweepstring 2 +#define GCSsweep 3 +#define GCSfinalize 4 + + +/* +** some userful bit tricks +*/ +#define resetbits(x,m) ((x) &= cast(lu_byte, ~(m))) +#define setbits(x,m) ((x) |= (m)) +#define testbits(x,m) ((x) & (m)) +#define bitmask(b) (1<<(b)) +#define bit2mask(b1,b2) (bitmask(b1) | bitmask(b2)) +#define l_setbit(x,b) setbits(x, bitmask(b)) +#define resetbit(x,b) resetbits(x, bitmask(b)) +#define testbit(x,b) testbits(x, bitmask(b)) +#define set2bits(x,b1,b2) setbits(x, (bit2mask(b1, b2))) +#define reset2bits(x,b1,b2) resetbits(x, (bit2mask(b1, b2))) +#define test2bits(x,b1,b2) testbits(x, (bit2mask(b1, b2))) + + + +/* +** Layout for bit use in `marked' field: +** bit 0 - object is white (type 0) +** bit 1 - object is white (type 1) +** bit 2 - object is black +** bit 3 - for userdata: has been finalized +** bit 3 - for tables: has weak keys +** bit 4 - for tables: has weak values +** bit 5 - object is fixed (should not be collected) +** bit 6 - object is "super" fixed (only the main thread) +*/ + + +#define WHITE0BIT 0 +#define WHITE1BIT 1 +#define BLACKBIT 2 +#define FINALIZEDBIT 3 +#define KEYWEAKBIT 3 +#define VALUEWEAKBIT 4 +#define FIXEDBIT 5 +#define SFIXEDBIT 6 +#define WHITEBITS bit2mask(WHITE0BIT, WHITE1BIT) + + +#define iswhite(x) test2bits((x)->gch.marked, WHITE0BIT, WHITE1BIT) +#define isblack(x) testbit((x)->gch.marked, BLACKBIT) +#define isgray(x) (!isblack(x) && !iswhite(x)) + +#define otherwhite(g) (g->currentwhite ^ WHITEBITS) +#define isdead(g,v) ((v)->gch.marked & otherwhite(g) & WHITEBITS) + +#define changewhite(x) ((x)->gch.marked ^= WHITEBITS) +#define gray2black(x) l_setbit((x)->gch.marked, BLACKBIT) + +#define valiswhite(x) (iscollectable(x) && iswhite(gcvalue(x))) + +#define luaC_white(g) cast(lu_byte, (g)->currentwhite & WHITEBITS) + + +#define luaC_checkGC(L) { \ + condhardstacktests(luaD_reallocstack(L, L->stacksize - EXTRA_STACK - 1)); \ + if (G(L)->totalbytes >= G(L)->GCthreshold) \ + luaC_step(L); } + + +#define luaC_barrier(L,p,v) { if (valiswhite(v) && isblack(obj2gco(p))) \ + luaC_barrierf(L,obj2gco(p),gcvalue(v)); } + +#define luaC_barriert(L,t,v) { if (valiswhite(v) && isblack(obj2gco(t))) \ + luaC_barrierback(L,t); } + +#define luaC_objbarrier(L,p,o) \ + { if (iswhite(obj2gco(o)) && isblack(obj2gco(p))) \ + luaC_barrierf(L,obj2gco(p),obj2gco(o)); } + +#define luaC_objbarriert(L,t,o) \ + { if (iswhite(obj2gco(o)) && isblack(obj2gco(t))) luaC_barrierback(L,t); } + +LUAI_FUNC size_t luaC_separateudata (lua_State *L, int all); +LUAI_FUNC void luaC_callGCTM (lua_State *L); +LUAI_FUNC void luaC_freeall (lua_State *L); +LUAI_FUNC void luaC_step (lua_State *L); +LUAI_FUNC void luaC_fullgc (lua_State *L); +LUAI_FUNC void luaC_link (lua_State *L, GCObject *o, lu_byte tt); +LUAI_FUNC void luaC_linkupval (lua_State *L, UpVal *uv); +LUAI_FUNC void luaC_barrierf (lua_State *L, GCObject *o, GCObject *v); +LUAI_FUNC void luaC_barrierback (lua_State *L, Table *t); + + +#endif diff --git a/mylua/lua/linit.c b/mylua/lua/linit.c new file mode 100644 index 0000000..c1f90df --- /dev/null +++ b/mylua/lua/linit.c @@ -0,0 +1,38 @@ +/* +** $Id: linit.c,v 1.14.1.1 2007/12/27 13:02:25 roberto Exp $ +** Initialization of libraries for lua.c +** See Copyright Notice in lua.h +*/ + + +#define linit_c +#define LUA_LIB + +#include "lua.h" + +#include "lualib.h" +#include "lauxlib.h" + + +static const luaL_Reg lualibs[] = { + {"", luaopen_base}, + {LUA_LOADLIBNAME, luaopen_package}, + {LUA_TABLIBNAME, luaopen_table}, + {LUA_IOLIBNAME, luaopen_io}, + {LUA_OSLIBNAME, luaopen_os}, + {LUA_STRLIBNAME, luaopen_string}, + {LUA_MATHLIBNAME, luaopen_math}, + {LUA_DBLIBNAME, luaopen_debug}, + {NULL, NULL} +}; + + +LUALIB_API void luaL_openlibs (lua_State *L) { + const luaL_Reg *lib = lualibs; + for (; lib->func; lib++) { + lua_pushcfunction(L, lib->func); + lua_pushstring(L, lib->name); + lua_call(L, 1, 0); + } +} + diff --git a/mylua/lua/liolib.c b/mylua/lua/liolib.c new file mode 100644 index 0000000..e79ed1c --- /dev/null +++ b/mylua/lua/liolib.c @@ -0,0 +1,553 @@ +/* +** $Id: liolib.c,v 2.73.1.3 2008/01/18 17:47:43 roberto Exp $ +** Standard I/O (and system) library +** See Copyright Notice in lua.h +*/ + + +#include +#include +#include +#include + +#define liolib_c +#define LUA_LIB + +#include "lua.h" + +#include "lauxlib.h" +#include "lualib.h" + + + +#define IO_INPUT 1 +#define IO_OUTPUT 2 + + +static const char *const fnames[] = {"input", "output"}; + + +static int pushresult (lua_State *L, int i, const char *filename) { + int en = errno; /* calls to Lua API may change this value */ + if (i) { + lua_pushboolean(L, 1); + return 1; + } + else { + lua_pushnil(L); + if (filename) + lua_pushfstring(L, "%s: %s", filename, strerror(en)); + else + lua_pushfstring(L, "%s", strerror(en)); + lua_pushinteger(L, en); + return 3; + } +} + + +static void fileerror (lua_State *L, int arg, const char *filename) { + lua_pushfstring(L, "%s: %s", filename, strerror(errno)); + luaL_argerror(L, arg, lua_tostring(L, -1)); +} + + +#define tofilep(L) ((FILE **)luaL_checkudata(L, 1, LUA_FILEHANDLE)) + + +static int io_type (lua_State *L) { + void *ud; + luaL_checkany(L, 1); + ud = lua_touserdata(L, 1); + lua_getfield(L, LUA_REGISTRYINDEX, LUA_FILEHANDLE); + if (ud == NULL || !lua_getmetatable(L, 1) || !lua_rawequal(L, -2, -1)) + lua_pushnil(L); /* not a file */ + else if (*((FILE **)ud) == NULL) + lua_pushliteral(L, "closed file"); + else + lua_pushliteral(L, "file"); + return 1; +} + + +static FILE *tofile (lua_State *L) { + FILE **f = tofilep(L); + if (*f == NULL) + luaL_error(L, "attempt to use a closed file"); + return *f; +} + + + +/* +** When creating file handles, always creates a `closed' file handle +** before opening the actual file; so, if there is a memory error, the +** file is not left opened. +*/ +static FILE **newfile (lua_State *L) { + FILE **pf = (FILE **)lua_newuserdata(L, sizeof(FILE *)); + *pf = NULL; /* file handle is currently `closed' */ + luaL_getmetatable(L, LUA_FILEHANDLE); + lua_setmetatable(L, -2); + return pf; +} + + +/* +** function to (not) close the standard files stdin, stdout, and stderr +*/ +static int io_noclose (lua_State *L) { + lua_pushnil(L); + lua_pushliteral(L, "cannot close standard file"); + return 2; +} + + +/* +** function to close 'popen' files +*/ +static int io_pclose (lua_State *L) { + FILE **p = tofilep(L); + int ok = lua_pclose(L, *p); + *p = NULL; + return pushresult(L, ok, NULL); +} + + +/* +** function to close regular files +*/ +static int io_fclose (lua_State *L) { + FILE **p = tofilep(L); + int ok = (fclose(*p) == 0); + *p = NULL; + return pushresult(L, ok, NULL); +} + + +static int aux_close (lua_State *L) { + lua_getfenv(L, 1); + lua_getfield(L, -1, "__close"); + return (lua_tocfunction(L, -1))(L); +} + + +static int io_close (lua_State *L) { + if (lua_isnone(L, 1)) + lua_rawgeti(L, LUA_ENVIRONINDEX, IO_OUTPUT); + tofile(L); /* make sure argument is a file */ + return aux_close(L); +} + + +static int io_gc (lua_State *L) { + FILE *f = *tofilep(L); + /* ignore closed files */ + if (f != NULL) + aux_close(L); + return 0; +} + + +static int io_tostring (lua_State *L) { + FILE *f = *tofilep(L); + if (f == NULL) + lua_pushliteral(L, "file (closed)"); + else + lua_pushfstring(L, "file (%p)", f); + return 1; +} + + +static int io_open (lua_State *L) { + const char *filename = luaL_checkstring(L, 1); + const char *mode = luaL_optstring(L, 2, "r"); + FILE **pf = newfile(L); + *pf = fopen(filename, mode); + return (*pf == NULL) ? pushresult(L, 0, filename) : 1; +} + + +/* +** this function has a separated environment, which defines the +** correct __close for 'popen' files +*/ +static int io_popen (lua_State *L) { + const char *filename = luaL_checkstring(L, 1); + const char *mode = luaL_optstring(L, 2, "r"); + FILE **pf = newfile(L); + *pf = lua_popen(L, filename, mode); + return (*pf == NULL) ? pushresult(L, 0, filename) : 1; +} + + +static int io_tmpfile (lua_State *L) { + FILE **pf = newfile(L); + *pf = tmpfile(); + return (*pf == NULL) ? pushresult(L, 0, NULL) : 1; +} + + +static FILE *getiofile (lua_State *L, int findex) { + FILE *f; + lua_rawgeti(L, LUA_ENVIRONINDEX, findex); + f = *(FILE **)lua_touserdata(L, -1); + if (f == NULL) + luaL_error(L, "standard %s file is closed", fnames[findex - 1]); + return f; +} + + +static int g_iofile (lua_State *L, int f, const char *mode) { + if (!lua_isnoneornil(L, 1)) { + const char *filename = lua_tostring(L, 1); + if (filename) { + FILE **pf = newfile(L); + *pf = fopen(filename, mode); + if (*pf == NULL) + fileerror(L, 1, filename); + } + else { + tofile(L); /* check that it's a valid file handle */ + lua_pushvalue(L, 1); + } + lua_rawseti(L, LUA_ENVIRONINDEX, f); + } + /* return current value */ + lua_rawgeti(L, LUA_ENVIRONINDEX, f); + return 1; +} + + +static int io_input (lua_State *L) { + return g_iofile(L, IO_INPUT, "r"); +} + + +static int io_output (lua_State *L) { + return g_iofile(L, IO_OUTPUT, "w"); +} + + +static int io_readline (lua_State *L); + + +static void aux_lines (lua_State *L, int idx, int toclose) { + lua_pushvalue(L, idx); + lua_pushboolean(L, toclose); /* close/not close file when finished */ + lua_pushcclosure(L, io_readline, 2); +} + + +static int f_lines (lua_State *L) { + tofile(L); /* check that it's a valid file handle */ + aux_lines(L, 1, 0); + return 1; +} + + +static int io_lines (lua_State *L) { + if (lua_isnoneornil(L, 1)) { /* no arguments? */ + /* will iterate over default input */ + lua_rawgeti(L, LUA_ENVIRONINDEX, IO_INPUT); + return f_lines(L); + } + else { + const char *filename = luaL_checkstring(L, 1); + FILE **pf = newfile(L); + *pf = fopen(filename, "r"); + if (*pf == NULL) + fileerror(L, 1, filename); + aux_lines(L, lua_gettop(L), 1); + return 1; + } +} + + +/* +** {====================================================== +** READ +** ======================================================= +*/ + + +static int read_number (lua_State *L, FILE *f) { + lua_Number d; + if (fscanf(f, LUA_NUMBER_SCAN, &d) == 1) { + lua_pushnumber(L, d); + return 1; + } + else return 0; /* read fails */ +} + + +static int test_eof (lua_State *L, FILE *f) { + int c = getc(f); + ungetc(c, f); + lua_pushlstring(L, NULL, 0); + return (c != EOF); +} + + +static int read_line (lua_State *L, FILE *f) { + luaL_Buffer b; + luaL_buffinit(L, &b); + for (;;) { + size_t l; + char *p = luaL_prepbuffer(&b); + if (fgets(p, LUAL_BUFFERSIZE, f) == NULL) { /* eof? */ + luaL_pushresult(&b); /* close buffer */ + return (lua_objlen(L, -1) > 0); /* check whether read something */ + } + l = strlen(p); + if (l == 0 || p[l-1] != '\n') + luaL_addsize(&b, l); + else { + luaL_addsize(&b, l - 1); /* do not include `eol' */ + luaL_pushresult(&b); /* close buffer */ + return 1; /* read at least an `eol' */ + } + } +} + + +static int read_chars (lua_State *L, FILE *f, size_t n) { + size_t rlen; /* how much to read */ + size_t nr; /* number of chars actually read */ + luaL_Buffer b; + luaL_buffinit(L, &b); + rlen = LUAL_BUFFERSIZE; /* try to read that much each time */ + do { + char *p = luaL_prepbuffer(&b); + if (rlen > n) rlen = n; /* cannot read more than asked */ + nr = fread(p, sizeof(char), rlen, f); + luaL_addsize(&b, nr); + n -= nr; /* still have to read `n' chars */ + } while (n > 0 && nr == rlen); /* until end of count or eof */ + luaL_pushresult(&b); /* close buffer */ + return (n == 0 || lua_objlen(L, -1) > 0); +} + + +static int g_read (lua_State *L, FILE *f, int first) { + int nargs = lua_gettop(L) - 1; + int success; + int n; + clearerr(f); + if (nargs == 0) { /* no arguments? */ + success = read_line(L, f); + n = first+1; /* to return 1 result */ + } + else { /* ensure stack space for all results and for auxlib's buffer */ + luaL_checkstack(L, nargs+LUA_MINSTACK, "too many arguments"); + success = 1; + for (n = first; nargs-- && success; n++) { + if (lua_type(L, n) == LUA_TNUMBER) { + size_t l = (size_t)lua_tointeger(L, n); + success = (l == 0) ? test_eof(L, f) : read_chars(L, f, l); + } + else { + const char *p = lua_tostring(L, n); + luaL_argcheck(L, p && p[0] == '*', n, "invalid option"); + switch (p[1]) { + case 'n': /* number */ + success = read_number(L, f); + break; + case 'l': /* line */ + success = read_line(L, f); + break; + case 'a': /* file */ + read_chars(L, f, ~((size_t)0)); /* read MAX_SIZE_T chars */ + success = 1; /* always success */ + break; + default: + return luaL_argerror(L, n, "invalid format"); + } + } + } + } + if (ferror(f)) + return pushresult(L, 0, NULL); + if (!success) { + lua_pop(L, 1); /* remove last result */ + lua_pushnil(L); /* push nil instead */ + } + return n - first; +} + + +static int io_read (lua_State *L) { + return g_read(L, getiofile(L, IO_INPUT), 1); +} + + +static int f_read (lua_State *L) { + return g_read(L, tofile(L), 2); +} + + +static int io_readline (lua_State *L) { + FILE *f = *(FILE **)lua_touserdata(L, lua_upvalueindex(1)); + int sucess; + if (f == NULL) /* file is already closed? */ + luaL_error(L, "file is already closed"); + sucess = read_line(L, f); + if (ferror(f)) + return luaL_error(L, "%s", strerror(errno)); + if (sucess) return 1; + else { /* EOF */ + if (lua_toboolean(L, lua_upvalueindex(2))) { /* generator created file? */ + lua_settop(L, 0); + lua_pushvalue(L, lua_upvalueindex(1)); + aux_close(L); /* close it */ + } + return 0; + } +} + +/* }====================================================== */ + + +static int g_write (lua_State *L, FILE *f, int arg) { + int nargs = lua_gettop(L) - 1; + int status = 1; + for (; nargs--; arg++) { + if (lua_type(L, arg) == LUA_TNUMBER) { + /* optimization: could be done exactly as for strings */ + status = status && + fprintf(f, LUA_NUMBER_FMT, lua_tonumber(L, arg)) > 0; + } + else { + size_t l; + const char *s = luaL_checklstring(L, arg, &l); + status = status && (fwrite(s, sizeof(char), l, f) == l); + } + } + return pushresult(L, status, NULL); +} + + +static int io_write (lua_State *L) { + return g_write(L, getiofile(L, IO_OUTPUT), 1); +} + + +static int f_write (lua_State *L) { + return g_write(L, tofile(L), 2); +} + + +static int f_seek (lua_State *L) { + static const int mode[] = {SEEK_SET, SEEK_CUR, SEEK_END}; + static const char *const modenames[] = {"set", "cur", "end", NULL}; + FILE *f = tofile(L); + int op = luaL_checkoption(L, 2, "cur", modenames); + long offset = luaL_optlong(L, 3, 0); + op = fseek(f, offset, mode[op]); + if (op) + return pushresult(L, 0, NULL); /* error */ + else { + lua_pushinteger(L, ftell(f)); + return 1; + } +} + + +static int f_setvbuf (lua_State *L) { + static const int mode[] = {_IONBF, _IOFBF, _IOLBF}; + static const char *const modenames[] = {"no", "full", "line", NULL}; + FILE *f = tofile(L); + int op = luaL_checkoption(L, 2, NULL, modenames); + lua_Integer sz = luaL_optinteger(L, 3, LUAL_BUFFERSIZE); + int res = setvbuf(f, NULL, mode[op], sz); + return pushresult(L, res == 0, NULL); +} + + + +static int io_flush (lua_State *L) { + return pushresult(L, fflush(getiofile(L, IO_OUTPUT)) == 0, NULL); +} + + +static int f_flush (lua_State *L) { + return pushresult(L, fflush(tofile(L)) == 0, NULL); +} + + +static const luaL_Reg iolib[] = { + {"close", io_close}, + {"flush", io_flush}, + {"input", io_input}, + {"lines", io_lines}, + {"open", io_open}, + {"output", io_output}, + {"popen", io_popen}, + {"read", io_read}, + {"tmpfile", io_tmpfile}, + {"type", io_type}, + {"write", io_write}, + {NULL, NULL} +}; + + +static const luaL_Reg flib[] = { + {"close", io_close}, + {"flush", f_flush}, + {"lines", f_lines}, + {"read", f_read}, + {"seek", f_seek}, + {"setvbuf", f_setvbuf}, + {"write", f_write}, + {"__gc", io_gc}, + {"__tostring", io_tostring}, + {NULL, NULL} +}; + + +static void createmeta (lua_State *L) { + luaL_newmetatable(L, LUA_FILEHANDLE); /* create metatable for file handles */ + lua_pushvalue(L, -1); /* push metatable */ + lua_setfield(L, -2, "__index"); /* metatable.__index = metatable */ + luaL_register(L, NULL, flib); /* file methods */ +} + + +static void createstdfile (lua_State *L, FILE *f, int k, const char *fname) { + *newfile(L) = f; + if (k > 0) { + lua_pushvalue(L, -1); + lua_rawseti(L, LUA_ENVIRONINDEX, k); + } + lua_pushvalue(L, -2); /* copy environment */ + lua_setfenv(L, -2); /* set it */ + lua_setfield(L, -3, fname); +} + + +static void newfenv (lua_State *L, lua_CFunction cls) { + lua_createtable(L, 0, 1); + lua_pushcfunction(L, cls); + lua_setfield(L, -2, "__close"); +} + + +LUALIB_API int luaopen_io (lua_State *L) { + createmeta(L); + /* create (private) environment (with fields IO_INPUT, IO_OUTPUT, __close) */ + newfenv(L, io_fclose); + lua_replace(L, LUA_ENVIRONINDEX); + /* open library */ + luaL_register(L, LUA_IOLIBNAME, iolib); + /* create (and set) default files */ + newfenv(L, io_noclose); /* close function for default files */ + createstdfile(L, stdin, IO_INPUT, "stdin"); + createstdfile(L, stdout, IO_OUTPUT, "stdout"); + createstdfile(L, stderr, 0, "stderr"); + lua_pop(L, 1); /* pop environment for default files */ + lua_getfield(L, -1, "popen"); + newfenv(L, io_pclose); /* create environment for 'popen' */ + lua_setfenv(L, -2); /* set fenv for 'popen' */ + lua_pop(L, 1); /* pop 'popen' */ + return 1; +} + diff --git a/mylua/lua/llex.c b/mylua/lua/llex.c new file mode 100644 index 0000000..6dc3193 --- /dev/null +++ b/mylua/lua/llex.c @@ -0,0 +1,461 @@ +/* +** $Id: llex.c,v 2.20.1.1 2007/12/27 13:02:25 roberto Exp $ +** Lexical Analyzer +** See Copyright Notice in lua.h +*/ + + +#include +#include +#include + +#define llex_c +#define LUA_CORE + +#include "lua.h" + +#include "ldo.h" +#include "llex.h" +#include "lobject.h" +#include "lparser.h" +#include "lstate.h" +#include "lstring.h" +#include "ltable.h" +#include "lzio.h" + + + +#define next(ls) (ls->current = zgetc(ls->z)) + + + + +#define currIsNewline(ls) (ls->current == '\n' || ls->current == '\r') + + +/* ORDER RESERVED */ +const char *const luaX_tokens [] = { + "and", "break", "do", "else", "elseif", + "end", "false", "for", "function", "if", + "in", "local", "nil", "not", "or", "repeat", + "return", "then", "true", "until", "while", + "..", "...", "==", ">=", "<=", "~=", + "", "", "", "", + NULL +}; + + +#define save_and_next(ls) (save(ls, ls->current), next(ls)) + + +static void save (LexState *ls, int c) { + Mbuffer *b = ls->buff; + if (b->n + 1 > b->buffsize) { + size_t newsize; + if (b->buffsize >= MAX_SIZET/2) + luaX_lexerror(ls, "lexical element too long", 0); + newsize = b->buffsize * 2; + luaZ_resizebuffer(ls->L, b, newsize); + } + b->buffer[b->n++] = cast(char, c); +} + + +void luaX_init (lua_State *L) { + int i; + for (i=0; itsv.reserved = cast_byte(i+1); /* reserved word */ + } +} + + +#define MAXSRC 80 + + +const char *luaX_token2str (LexState *ls, int token) { + if (token < FIRST_RESERVED) { + lua_assert(token == cast(unsigned char, token)); + return (iscntrl(token)) ? luaO_pushfstring(ls->L, "char(%d)", token) : + luaO_pushfstring(ls->L, "%c", token); + } + else + return luaX_tokens[token-FIRST_RESERVED]; +} + + +static const char *txtToken (LexState *ls, int token) { + switch (token) { + case TK_NAME: + case TK_STRING: + case TK_NUMBER: + save(ls, '\0'); + return luaZ_buffer(ls->buff); + default: + return luaX_token2str(ls, token); + } +} + + +void luaX_lexerror (LexState *ls, const char *msg, int token) { + char buff[MAXSRC]; + luaO_chunkid(buff, getstr(ls->source), MAXSRC); + msg = luaO_pushfstring(ls->L, "%s:%d: %s", buff, ls->linenumber, msg); + if (token) + luaO_pushfstring(ls->L, "%s near " LUA_QS, msg, txtToken(ls, token)); + luaD_throw(ls->L, LUA_ERRSYNTAX); +} + + +void luaX_syntaxerror (LexState *ls, const char *msg) { + luaX_lexerror(ls, msg, ls->t.token); +} + + +TString *luaX_newstring (LexState *ls, const char *str, size_t l) { + lua_State *L = ls->L; + TString *ts = luaS_newlstr(L, str, l); + TValue *o = luaH_setstr(L, ls->fs->h, ts); /* entry for `str' */ + if (ttisnil(o)) + setbvalue(o, 1); /* make sure `str' will not be collected */ + return ts; +} + + +static void inclinenumber (LexState *ls) { + int old = ls->current; + lua_assert(currIsNewline(ls)); + next(ls); /* skip `\n' or `\r' */ + if (currIsNewline(ls) && ls->current != old) + next(ls); /* skip `\n\r' or `\r\n' */ + if (++ls->linenumber >= MAX_INT) + luaX_syntaxerror(ls, "chunk has too many lines"); +} + + +void luaX_setinput (lua_State *L, LexState *ls, ZIO *z, TString *source) { + ls->decpoint = '.'; + ls->L = L; + ls->lookahead.token = TK_EOS; /* no look-ahead token */ + ls->z = z; + ls->fs = NULL; + ls->linenumber = 1; + ls->lastline = 1; + ls->source = source; + luaZ_resizebuffer(ls->L, ls->buff, LUA_MINBUFFER); /* initialize buffer */ + next(ls); /* read first char */ +} + + + +/* +** ======================================================= +** LEXICAL ANALYZER +** ======================================================= +*/ + + + +static int check_next (LexState *ls, const char *set) { + if (!strchr(set, ls->current)) + return 0; + save_and_next(ls); + return 1; +} + + +static void buffreplace (LexState *ls, char from, char to) { + size_t n = luaZ_bufflen(ls->buff); + char *p = luaZ_buffer(ls->buff); + while (n--) + if (p[n] == from) p[n] = to; +} + + +static void trydecpoint (LexState *ls, SemInfo *seminfo) { + /* format error: try to update decimal point separator */ + struct lconv *cv = localeconv(); + char old = ls->decpoint; + ls->decpoint = (cv ? cv->decimal_point[0] : '.'); + buffreplace(ls, old, ls->decpoint); /* try updated decimal separator */ + if (!luaO_str2d(luaZ_buffer(ls->buff), &seminfo->r)) { + /* format error with correct decimal point: no more options */ + buffreplace(ls, ls->decpoint, '.'); /* undo change (for error message) */ + luaX_lexerror(ls, "malformed number", TK_NUMBER); + } +} + + +/* LUA_NUMBER */ +static void read_numeral (LexState *ls, SemInfo *seminfo) { + lua_assert(isdigit(ls->current)); + do { + save_and_next(ls); + } while (isdigit(ls->current) || ls->current == '.'); + if (check_next(ls, "Ee")) /* `E'? */ + check_next(ls, "+-"); /* optional exponent sign */ + while (isalnum(ls->current) || ls->current == '_') + save_and_next(ls); + save(ls, '\0'); + buffreplace(ls, '.', ls->decpoint); /* follow locale for decimal point */ + if (!luaO_str2d(luaZ_buffer(ls->buff), &seminfo->r)) /* format error? */ + trydecpoint(ls, seminfo); /* try to update decimal point separator */ +} + + +static int skip_sep (LexState *ls) { + int count = 0; + int s = ls->current; + lua_assert(s == '[' || s == ']'); + save_and_next(ls); + while (ls->current == '=') { + save_and_next(ls); + count++; + } + return (ls->current == s) ? count : (-count) - 1; +} + + +static void read_long_string (LexState *ls, SemInfo *seminfo, int sep) { + int cont = 0; + (void)(cont); /* avoid warnings when `cont' is not used */ + save_and_next(ls); /* skip 2nd `[' */ + if (currIsNewline(ls)) /* string starts with a newline? */ + inclinenumber(ls); /* skip it */ + for (;;) { + switch (ls->current) { + case EOZ: + luaX_lexerror(ls, (seminfo) ? "unfinished long string" : + "unfinished long comment", TK_EOS); + break; /* to avoid warnings */ +#if defined(LUA_COMPAT_LSTR) + case '[': { + if (skip_sep(ls) == sep) { + save_and_next(ls); /* skip 2nd `[' */ + cont++; +#if LUA_COMPAT_LSTR == 1 + if (sep == 0) + luaX_lexerror(ls, "nesting of [[...]] is deprecated", '['); +#endif + } + break; + } +#endif + case ']': { + if (skip_sep(ls) == sep) { + save_and_next(ls); /* skip 2nd `]' */ +#if defined(LUA_COMPAT_LSTR) && LUA_COMPAT_LSTR == 2 + cont--; + if (sep == 0 && cont >= 0) break; +#endif + goto endloop; + } + break; + } + case '\n': + case '\r': { + save(ls, '\n'); + inclinenumber(ls); + if (!seminfo) luaZ_resetbuffer(ls->buff); /* avoid wasting space */ + break; + } + default: { + if (seminfo) save_and_next(ls); + else next(ls); + } + } + } endloop: + if (seminfo) + seminfo->ts = luaX_newstring(ls, luaZ_buffer(ls->buff) + (2 + sep), + luaZ_bufflen(ls->buff) - 2*(2 + sep)); +} + + +static void read_string (LexState *ls, int del, SemInfo *seminfo) { + save_and_next(ls); + while (ls->current != del) { + switch (ls->current) { + case EOZ: + luaX_lexerror(ls, "unfinished string", TK_EOS); + continue; /* to avoid warnings */ + case '\n': + case '\r': + luaX_lexerror(ls, "unfinished string", TK_STRING); + continue; /* to avoid warnings */ + case '\\': { + int c; + next(ls); /* do not save the `\' */ + switch (ls->current) { + case 'a': c = '\a'; break; + case 'b': c = '\b'; break; + case 'f': c = '\f'; break; + case 'n': c = '\n'; break; + case 'r': c = '\r'; break; + case 't': c = '\t'; break; + case 'v': c = '\v'; break; + case '\n': /* go through */ + case '\r': save(ls, '\n'); inclinenumber(ls); continue; + case EOZ: continue; /* will raise an error next loop */ + default: { + if (!isdigit(ls->current)) + save_and_next(ls); /* handles \\, \", \', and \? */ + else { /* \xxx */ + int i = 0; + c = 0; + do { + c = 10*c + (ls->current-'0'); + next(ls); + } while (++i<3 && isdigit(ls->current)); + if (c > UCHAR_MAX) + luaX_lexerror(ls, "escape sequence too large", TK_STRING); + save(ls, c); + } + continue; + } + } + save(ls, c); + next(ls); + continue; + } + default: + save_and_next(ls); + } + } + save_and_next(ls); /* skip delimiter */ + seminfo->ts = luaX_newstring(ls, luaZ_buffer(ls->buff) + 1, + luaZ_bufflen(ls->buff) - 2); +} + + +static int llex (LexState *ls, SemInfo *seminfo) { + luaZ_resetbuffer(ls->buff); + for (;;) { + switch (ls->current) { + case '\n': + case '\r': { + inclinenumber(ls); + continue; + } + case '-': { + next(ls); + if (ls->current != '-') return '-'; + /* else is a comment */ + next(ls); + if (ls->current == '[') { + int sep = skip_sep(ls); + luaZ_resetbuffer(ls->buff); /* `skip_sep' may dirty the buffer */ + if (sep >= 0) { + read_long_string(ls, NULL, sep); /* long comment */ + luaZ_resetbuffer(ls->buff); + continue; + } + } + /* else short comment */ + while (!currIsNewline(ls) && ls->current != EOZ) + next(ls); + continue; + } + case '[': { + int sep = skip_sep(ls); + if (sep >= 0) { + read_long_string(ls, seminfo, sep); + return TK_STRING; + } + else if (sep == -1) return '['; + else luaX_lexerror(ls, "invalid long string delimiter", TK_STRING); + } + case '=': { + next(ls); + if (ls->current != '=') return '='; + else { next(ls); return TK_EQ; } + } + case '<': { + next(ls); + if (ls->current != '=') return '<'; + else { next(ls); return TK_LE; } + } + case '>': { + next(ls); + if (ls->current != '=') return '>'; + else { next(ls); return TK_GE; } + } + case '~': { + next(ls); + if (ls->current != '=') return '~'; + else { next(ls); return TK_NE; } + } + case '"': + case '\'': { + read_string(ls, ls->current, seminfo); + return TK_STRING; + } + case '.': { + save_and_next(ls); + if (check_next(ls, ".")) { + if (check_next(ls, ".")) + return TK_DOTS; /* ... */ + else return TK_CONCAT; /* .. */ + } + else if (!isdigit(ls->current)) return '.'; + else { + read_numeral(ls, seminfo); + return TK_NUMBER; + } + } + case EOZ: { + return TK_EOS; + } + default: { + if (isspace(ls->current)) { + lua_assert(!currIsNewline(ls)); + next(ls); + continue; + } + else if (isdigit(ls->current)) { + read_numeral(ls, seminfo); + return TK_NUMBER; + } + else if (isalpha(ls->current) || ls->current == '_') { + /* identifier or reserved word */ + TString *ts; + do { + save_and_next(ls); + } while (isalnum(ls->current) || ls->current == '_'); + ts = luaX_newstring(ls, luaZ_buffer(ls->buff), + luaZ_bufflen(ls->buff)); + if (ts->tsv.reserved > 0) /* reserved word? */ + return ts->tsv.reserved - 1 + FIRST_RESERVED; + else { + seminfo->ts = ts; + return TK_NAME; + } + } + else { + int c = ls->current; + next(ls); + return c; /* single-char tokens (+ - / ...) */ + } + } + } + } +} + + +void luaX_next (LexState *ls) { + ls->lastline = ls->linenumber; + if (ls->lookahead.token != TK_EOS) { /* is there a look-ahead token? */ + ls->t = ls->lookahead; /* use this one */ + ls->lookahead.token = TK_EOS; /* and discharge it */ + } + else + ls->t.token = llex(ls, &ls->t.seminfo); /* read next token */ +} + + +void luaX_lookahead (LexState *ls) { + lua_assert(ls->lookahead.token == TK_EOS); + ls->lookahead.token = llex(ls, &ls->lookahead.seminfo); +} + diff --git a/mylua/lua/llex.h b/mylua/lua/llex.h new file mode 100644 index 0000000..a9201ce --- /dev/null +++ b/mylua/lua/llex.h @@ -0,0 +1,81 @@ +/* +** $Id: llex.h,v 1.58.1.1 2007/12/27 13:02:25 roberto Exp $ +** Lexical Analyzer +** See Copyright Notice in lua.h +*/ + +#ifndef llex_h +#define llex_h + +#include "lobject.h" +#include "lzio.h" + + +#define FIRST_RESERVED 257 + +/* maximum length of a reserved word */ +#define TOKEN_LEN (sizeof("function")/sizeof(char)) + + +/* +* WARNING: if you change the order of this enumeration, +* grep "ORDER RESERVED" +*/ +enum RESERVED { + /* terminal symbols denoted by reserved words */ + TK_AND = FIRST_RESERVED, TK_BREAK, + TK_DO, TK_ELSE, TK_ELSEIF, TK_END, TK_FALSE, TK_FOR, TK_FUNCTION, + TK_IF, TK_IN, TK_LOCAL, TK_NIL, TK_NOT, TK_OR, TK_REPEAT, + TK_RETURN, TK_THEN, TK_TRUE, TK_UNTIL, TK_WHILE, + /* other terminal symbols */ + TK_CONCAT, TK_DOTS, TK_EQ, TK_GE, TK_LE, TK_NE, TK_NUMBER, + TK_NAME, TK_STRING, TK_EOS +}; + +/* number of reserved words */ +#define NUM_RESERVED (cast(int, TK_WHILE-FIRST_RESERVED+1)) + + +/* array with token `names' */ +LUAI_DATA const char *const luaX_tokens []; + + +typedef union { + lua_Number r; + TString *ts; +} SemInfo; /* semantics information */ + + +typedef struct Token { + int token; + SemInfo seminfo; +} Token; + + +typedef struct LexState { + int current; /* current character (charint) */ + int linenumber; /* input line counter */ + int lastline; /* line of last token `consumed' */ + Token t; /* current token */ + Token lookahead; /* look ahead token */ + struct FuncState *fs; /* `FuncState' is private to the parser */ + struct lua_State *L; + ZIO *z; /* input stream */ + Mbuffer *buff; /* buffer for tokens */ + TString *source; /* current source name */ + char decpoint; /* locale decimal point */ +} LexState; + + +LUAI_FUNC void luaX_init (lua_State *L); +LUAI_FUNC void luaX_setinput (lua_State *L, LexState *ls, ZIO *z, + TString *source); +LUAI_FUNC TString *luaX_newstring (LexState *ls, const char *str, size_t l); +LUAI_FUNC void luaX_next (LexState *ls); +LUAI_FUNC void luaX_lookahead (LexState *ls); +LUAI_FUNC void luaX_lexerror (LexState *ls, const char *msg, int token); +LUAI_FUNC void luaX_syntaxerror (LexState *ls, const char *s); +LUAI_FUNC const char *luaX_token2str (LexState *ls, int token); + + +#endif diff --git a/mylua/lua/llimits.h b/mylua/lua/llimits.h new file mode 100644 index 0000000..ca8dcb7 --- /dev/null +++ b/mylua/lua/llimits.h @@ -0,0 +1,128 @@ +/* +** $Id: llimits.h,v 1.69.1.1 2007/12/27 13:02:25 roberto Exp $ +** Limits, basic types, and some other `installation-dependent' definitions +** See Copyright Notice in lua.h +*/ + +#ifndef llimits_h +#define llimits_h + + +#include +#include + + +#include "lua.h" + + +typedef LUAI_UINT32 lu_int32; + +typedef LUAI_UMEM lu_mem; + +typedef LUAI_MEM l_mem; + + + +/* chars used as small naturals (so that `char' is reserved for characters) */ +typedef unsigned char lu_byte; + + +#define MAX_SIZET ((size_t)(~(size_t)0)-2) + +#define MAX_LUMEM ((lu_mem)(~(lu_mem)0)-2) + + +#define MAX_INT (INT_MAX-2) /* maximum value of an int (-2 for safety) */ + +/* +** conversion of pointer to integer +** this is for hashing only; there is no problem if the integer +** cannot hold the whole pointer value +*/ +#define IntPoint(p) ((unsigned int)(lu_mem)(p)) + + + +/* type to ensure maximum alignment */ +typedef LUAI_USER_ALIGNMENT_T L_Umaxalign; + + +/* result of a `usual argument conversion' over lua_Number */ +typedef LUAI_UACNUMBER l_uacNumber; + + +/* internal assertions for in-house debugging */ +#ifdef lua_assert + +#define check_exp(c,e) (lua_assert(c), (e)) +#define api_check(l,e) lua_assert(e) + +#else + +#define lua_assert(c) ((void)0) +#define check_exp(c,e) (e) +#define api_check luai_apicheck + +#endif + + +#ifndef UNUSED +#define UNUSED(x) ((void)(x)) /* to avoid warnings */ +#endif + + +#ifndef cast +#define cast(t, exp) ((t)(exp)) +#endif + +#define cast_byte(i) cast(lu_byte, (i)) +#define cast_num(i) cast(lua_Number, (i)) +#define cast_int(i) cast(int, (i)) + + + +/* +** type for virtual-machine instructions +** must be an unsigned with (at least) 4 bytes (see details in lopcodes.h) +*/ +typedef lu_int32 Instruction; + + + +/* maximum stack for a Lua function */ +#define MAXSTACK 250 + + + +/* minimum size for the string table (must be power of 2) */ +#ifndef MINSTRTABSIZE +#define MINSTRTABSIZE 32 +#endif + + +/* minimum size for string buffer */ +#ifndef LUA_MINBUFFER +#define LUA_MINBUFFER 32 +#endif + + +#ifndef lua_lock +#define lua_lock(L) ((void) 0) +#define lua_unlock(L) ((void) 0) +#endif + +#ifndef luai_threadyield +#define luai_threadyield(L) {lua_unlock(L); lua_lock(L);} +#endif + + +/* +** macro to control inclusion of some hard tests on stack reallocation +*/ +#ifndef HARDSTACKTESTS +#define condhardstacktests(x) ((void)0) +#else +#define condhardstacktests(x) x +#endif + +#endif diff --git a/mylua/lua/lmathlib.c b/mylua/lua/lmathlib.c new file mode 100644 index 0000000..441fbf7 --- /dev/null +++ b/mylua/lua/lmathlib.c @@ -0,0 +1,263 @@ +/* +** $Id: lmathlib.c,v 1.67.1.1 2007/12/27 13:02:25 roberto Exp $ +** Standard mathematical library +** See Copyright Notice in lua.h +*/ + + +#include +#include + +#define lmathlib_c +#define LUA_LIB + +#include "lua.h" + +#include "lauxlib.h" +#include "lualib.h" + + +#undef PI +#define PI (3.14159265358979323846) +#define RADIANS_PER_DEGREE (PI/180.0) + + + +static int math_abs (lua_State *L) { + lua_pushnumber(L, fabs(luaL_checknumber(L, 1))); + return 1; +} + +static int math_sin (lua_State *L) { + lua_pushnumber(L, sin(luaL_checknumber(L, 1))); + return 1; +} + +static int math_sinh (lua_State *L) { + lua_pushnumber(L, sinh(luaL_checknumber(L, 1))); + return 1; +} + +static int math_cos (lua_State *L) { + lua_pushnumber(L, cos(luaL_checknumber(L, 1))); + return 1; +} + +static int math_cosh (lua_State *L) { + lua_pushnumber(L, cosh(luaL_checknumber(L, 1))); + return 1; +} + +static int math_tan (lua_State *L) { + lua_pushnumber(L, tan(luaL_checknumber(L, 1))); + return 1; +} + +static int math_tanh (lua_State *L) { + lua_pushnumber(L, tanh(luaL_checknumber(L, 1))); + return 1; +} + +static int math_asin (lua_State *L) { + lua_pushnumber(L, asin(luaL_checknumber(L, 1))); + return 1; +} + +static int math_acos (lua_State *L) { + lua_pushnumber(L, acos(luaL_checknumber(L, 1))); + return 1; +} + +static int math_atan (lua_State *L) { + lua_pushnumber(L, atan(luaL_checknumber(L, 1))); + return 1; +} + +static int math_atan2 (lua_State *L) { + lua_pushnumber(L, atan2(luaL_checknumber(L, 1), luaL_checknumber(L, 2))); + return 1; +} + +static int math_ceil (lua_State *L) { + lua_pushnumber(L, ceil(luaL_checknumber(L, 1))); + return 1; +} + +static int math_floor (lua_State *L) { + lua_pushnumber(L, floor(luaL_checknumber(L, 1))); + return 1; +} + +static int math_fmod (lua_State *L) { + lua_pushnumber(L, fmod(luaL_checknumber(L, 1), luaL_checknumber(L, 2))); + return 1; +} + +static int math_modf (lua_State *L) { + double ip; + double fp = modf(luaL_checknumber(L, 1), &ip); + lua_pushnumber(L, ip); + lua_pushnumber(L, fp); + return 2; +} + +static int math_sqrt (lua_State *L) { + lua_pushnumber(L, sqrt(luaL_checknumber(L, 1))); + return 1; +} + +static int math_pow (lua_State *L) { + lua_pushnumber(L, pow(luaL_checknumber(L, 1), luaL_checknumber(L, 2))); + return 1; +} + +static int math_log (lua_State *L) { + lua_pushnumber(L, log(luaL_checknumber(L, 1))); + return 1; +} + +static int math_log10 (lua_State *L) { + lua_pushnumber(L, log10(luaL_checknumber(L, 1))); + return 1; +} + +static int math_exp (lua_State *L) { + lua_pushnumber(L, exp(luaL_checknumber(L, 1))); + return 1; +} + +static int math_deg (lua_State *L) { + lua_pushnumber(L, luaL_checknumber(L, 1)/RADIANS_PER_DEGREE); + return 1; +} + +static int math_rad (lua_State *L) { + lua_pushnumber(L, luaL_checknumber(L, 1)*RADIANS_PER_DEGREE); + return 1; +} + +static int math_frexp (lua_State *L) { + int e; + lua_pushnumber(L, frexp(luaL_checknumber(L, 1), &e)); + lua_pushinteger(L, e); + return 2; +} + +static int math_ldexp (lua_State *L) { + lua_pushnumber(L, ldexp(luaL_checknumber(L, 1), luaL_checkint(L, 2))); + return 1; +} + + + +static int math_min (lua_State *L) { + int n = lua_gettop(L); /* number of arguments */ + lua_Number dmin = luaL_checknumber(L, 1); + int i; + for (i=2; i<=n; i++) { + lua_Number d = luaL_checknumber(L, i); + if (d < dmin) + dmin = d; + } + lua_pushnumber(L, dmin); + return 1; +} + + +static int math_max (lua_State *L) { + int n = lua_gettop(L); /* number of arguments */ + lua_Number dmax = luaL_checknumber(L, 1); + int i; + for (i=2; i<=n; i++) { + lua_Number d = luaL_checknumber(L, i); + if (d > dmax) + dmax = d; + } + lua_pushnumber(L, dmax); + return 1; +} + + +static int math_random (lua_State *L) { + /* the `%' avoids the (rare) case of r==1, and is needed also because on + some systems (SunOS!) `rand()' may return a value larger than RAND_MAX */ + lua_Number r = (lua_Number)(rand()%RAND_MAX) / (lua_Number)RAND_MAX; + switch (lua_gettop(L)) { /* check number of arguments */ + case 0: { /* no arguments */ + lua_pushnumber(L, r); /* Number between 0 and 1 */ + break; + } + case 1: { /* only upper limit */ + int u = luaL_checkint(L, 1); + luaL_argcheck(L, 1<=u, 1, "interval is empty"); + lua_pushnumber(L, floor(r*u)+1); /* int between 1 and `u' */ + break; + } + case 2: { /* lower and upper limits */ + int l = luaL_checkint(L, 1); + int u = luaL_checkint(L, 2); + luaL_argcheck(L, l<=u, 2, "interval is empty"); + lua_pushnumber(L, floor(r*(u-l+1))+l); /* int between `l' and `u' */ + break; + } + default: return luaL_error(L, "wrong number of arguments"); + } + return 1; +} + + +static int math_randomseed (lua_State *L) { + srand(luaL_checkint(L, 1)); + return 0; +} + + +static const luaL_Reg mathlib[] = { + {"abs", math_abs}, + {"acos", math_acos}, + {"asin", math_asin}, + {"atan2", math_atan2}, + {"atan", math_atan}, + {"ceil", math_ceil}, + {"cosh", math_cosh}, + {"cos", math_cos}, + {"deg", math_deg}, + {"exp", math_exp}, + {"floor", math_floor}, + {"fmod", math_fmod}, + {"frexp", math_frexp}, + {"ldexp", math_ldexp}, + {"log10", math_log10}, + {"log", math_log}, + {"max", math_max}, + {"min", math_min}, + {"modf", math_modf}, + {"pow", math_pow}, + {"rad", math_rad}, + {"random", math_random}, + {"randomseed", math_randomseed}, + {"sinh", math_sinh}, + {"sin", math_sin}, + {"sqrt", math_sqrt}, + {"tanh", math_tanh}, + {"tan", math_tan}, + {NULL, NULL} +}; + + +/* +** Open math library +*/ +LUALIB_API int luaopen_math (lua_State *L) { + luaL_register(L, LUA_MATHLIBNAME, mathlib); + lua_pushnumber(L, PI); + lua_setfield(L, -2, "pi"); + lua_pushnumber(L, HUGE_VAL); + lua_setfield(L, -2, "huge"); +#if defined(LUA_COMPAT_MOD) + lua_getfield(L, -1, "fmod"); + lua_setfield(L, -2, "mod"); +#endif + return 1; +} + diff --git a/mylua/lua/lmem.c b/mylua/lua/lmem.c new file mode 100644 index 0000000..ae7d8c9 --- /dev/null +++ b/mylua/lua/lmem.c @@ -0,0 +1,86 @@ +/* +** $Id: lmem.c,v 1.70.1.1 2007/12/27 13:02:25 roberto Exp $ +** Interface to Memory Manager +** See Copyright Notice in lua.h +*/ + + +#include + +#define lmem_c +#define LUA_CORE + +#include "lua.h" + +#include "ldebug.h" +#include "ldo.h" +#include "lmem.h" +#include "lobject.h" +#include "lstate.h" + + + +/* +** About the realloc function: +** void * frealloc (void *ud, void *ptr, size_t osize, size_t nsize); +** (`osize' is the old size, `nsize' is the new size) +** +** Lua ensures that (ptr == NULL) iff (osize == 0). +** +** * frealloc(ud, NULL, 0, x) creates a new block of size `x' +** +** * frealloc(ud, p, x, 0) frees the block `p' +** (in this specific case, frealloc must return NULL). +** particularly, frealloc(ud, NULL, 0, 0) does nothing +** (which is equivalent to free(NULL) in ANSI C) +** +** frealloc returns NULL if it cannot create or reallocate the area +** (any reallocation to an equal or smaller size cannot fail!) +*/ + + + +#define MINSIZEARRAY 4 + + +void *luaM_growaux_ (lua_State *L, void *block, int *size, size_t size_elems, + int limit, const char *errormsg) { + void *newblock; + int newsize; + if (*size >= limit/2) { /* cannot double it? */ + if (*size >= limit) /* cannot grow even a little? */ + luaG_runerror(L, errormsg); + newsize = limit; /* still have at least one free place */ + } + else { + newsize = (*size)*2; + if (newsize < MINSIZEARRAY) + newsize = MINSIZEARRAY; /* minimum size */ + } + newblock = luaM_reallocv(L, block, *size, newsize, size_elems); + *size = newsize; /* update only when everything else is OK */ + return newblock; +} + + +void *luaM_toobig (lua_State *L) { + luaG_runerror(L, "memory allocation error: block too big"); + return NULL; /* to avoid warnings */ +} + + + +/* +** generic allocation routine. +*/ +void *luaM_realloc_ (lua_State *L, void *block, size_t osize, size_t nsize) { + global_State *g = G(L); + lua_assert((osize == 0) == (block == NULL)); + block = (*g->frealloc)(g->ud, block, osize, nsize); + if (block == NULL && nsize > 0) + luaD_throw(L, LUA_ERRMEM); + lua_assert((nsize == 0) == (block == NULL)); + g->totalbytes = (g->totalbytes - osize) + nsize; + return block; +} + diff --git a/mylua/lua/lmem.h b/mylua/lua/lmem.h new file mode 100644 index 0000000..7c2dcb3 --- /dev/null +++ b/mylua/lua/lmem.h @@ -0,0 +1,49 @@ +/* +** $Id: lmem.h,v 1.31.1.1 2007/12/27 13:02:25 roberto Exp $ +** Interface to Memory Manager +** See Copyright Notice in lua.h +*/ + +#ifndef lmem_h +#define lmem_h + + +#include + +#include "llimits.h" +#include "lua.h" + +#define MEMERRMSG "not enough memory" + + +#define luaM_reallocv(L,b,on,n,e) \ + ((cast(size_t, (n)+1) <= MAX_SIZET/(e)) ? /* +1 to avoid warnings */ \ + luaM_realloc_(L, (b), (on)*(e), (n)*(e)) : \ + luaM_toobig(L)) + +#define luaM_freemem(L, b, s) luaM_realloc_(L, (b), (s), 0) +#define luaM_free(L, b) luaM_realloc_(L, (b), sizeof(*(b)), 0) +#define luaM_freearray(L, b, n, t) luaM_reallocv(L, (b), n, 0, sizeof(t)) + +#define luaM_malloc(L,t) luaM_realloc_(L, NULL, 0, (t)) +#define luaM_new(L,t) cast(t *, luaM_malloc(L, sizeof(t))) +#define luaM_newvector(L,n,t) \ + cast(t *, luaM_reallocv(L, NULL, 0, n, sizeof(t))) + +#define luaM_growvector(L,v,nelems,size,t,limit,e) \ + if ((nelems)+1 > (size)) \ + ((v)=cast(t *, luaM_growaux_(L,v,&(size),sizeof(t),limit,e))) + +#define luaM_reallocvector(L, v,oldn,n,t) \ + ((v)=cast(t *, luaM_reallocv(L, v, oldn, n, sizeof(t)))) + + +LUAI_FUNC void *luaM_realloc_ (lua_State *L, void *block, size_t oldsize, + size_t size); +LUAI_FUNC void *luaM_toobig (lua_State *L); +LUAI_FUNC void *luaM_growaux_ (lua_State *L, void *block, int *size, + size_t size_elem, int limit, + const char *errormsg); + +#endif + diff --git a/mylua/lua/loadlib.c b/mylua/lua/loadlib.c new file mode 100644 index 0000000..cbcaf9d --- /dev/null +++ b/mylua/lua/loadlib.c @@ -0,0 +1,667 @@ +/* +** $Id: loadlib.c,v 1.52.1.3 2008/08/06 13:29:28 roberto Exp $ +** Dynamic library loader for Lua +** See Copyright Notice in lua.h +** +** This module contains an implementation of loadlib for Unix systems +** that have dlfcn, an implementation for Darwin (Mac OS X), an +** implementation for Windows, and a stub for other systems. +*/ + + +#include +#include +#include + + +#define loadlib_c +#define LUA_LIB + +#include "lua.h" + +#include "lauxlib.h" +#include "lualib.h" + + +/* prefix for open functions in C libraries */ +#define LUA_POF "luaopen_" + +/* separator for open functions in C libraries */ +#define LUA_OFSEP "_" + + +#define LIBPREFIX "LOADLIB: " + +#define POF LUA_POF +#define LIB_FAIL "open" + + +/* error codes for ll_loadfunc */ +#define ERRLIB 1 +#define ERRFUNC 2 + +#define setprogdir(L) ((void)0) + + +static void ll_unloadlib (void *lib); +static void *ll_load (lua_State *L, const char *path); +static lua_CFunction ll_sym (lua_State *L, void *lib, const char *sym); + + + +#if defined(LUA_DL_DLOPEN) +/* +** {======================================================================== +** This is an implementation of loadlib based on the dlfcn interface. +** The dlfcn interface is available in Linux, SunOS, Solaris, IRIX, FreeBSD, +** NetBSD, AIX 4.2, HPUX 11, and probably most other Unix flavors, at least +** as an emulation layer on top of native functions. +** ========================================================================= +*/ + +#include + +static void ll_unloadlib (void *lib) { + dlclose(lib); +} + + +static void *ll_load (lua_State *L, const char *path) { + void *lib = dlopen(path, RTLD_NOW); + if (lib == NULL) lua_pushstring(L, dlerror()); + return lib; +} + + +static lua_CFunction ll_sym (lua_State *L, void *lib, const char *sym) { + lua_CFunction f = (lua_CFunction)dlsym(lib, sym); + if (f == NULL) lua_pushstring(L, dlerror()); + return f; +} + +/* }====================================================== */ + + + +#elif defined(LUA_DL_DLL) +/* +** {====================================================================== +** This is an implementation of loadlib for Windows using native functions. +** ======================================================================= +*/ + +#include + + +#undef setprogdir + +static void setprogdir (lua_State *L) { + char buff[MAX_PATH + 1]; + char *lb; + DWORD nsize = sizeof(buff)/sizeof(char); + DWORD n = GetModuleFileNameA(NULL, buff, nsize); + if (n == 0 || n == nsize || (lb = strrchr(buff, '\\')) == NULL) + luaL_error(L, "unable to get ModuleFileName"); + else { + *lb = '\0'; + luaL_gsub(L, lua_tostring(L, -1), LUA_EXECDIR, buff); + lua_remove(L, -2); /* remove original string */ + } +} + + +static void pusherror (lua_State *L) { + int error = GetLastError(); + char buffer[128]; + if (FormatMessageA(FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_FROM_SYSTEM, + NULL, error, 0, buffer, sizeof(buffer), NULL)) + lua_pushstring(L, buffer); + else + lua_pushfstring(L, "system error %d\n", error); +} + +static void ll_unloadlib (void *lib) { + FreeLibrary((HINSTANCE)lib); +} + + +static void *ll_load (lua_State *L, const char *path) { + HINSTANCE lib = LoadLibraryA(path); + if (lib == NULL) pusherror(L); + return lib; +} + + +static lua_CFunction ll_sym (lua_State *L, void *lib, const char *sym) { + lua_CFunction f = (lua_CFunction)GetProcAddress((HINSTANCE)lib, sym); + if (f == NULL) pusherror(L); + return f; +} + +/* }====================================================== */ + + + +#elif defined(LUA_DL_DYLD) +/* +** {====================================================================== +** Native Mac OS X / Darwin Implementation +** ======================================================================= +*/ + +#include + + +/* Mac appends a `_' before C function names */ +#undef POF +#define POF "_" LUA_POF + + +static void pusherror (lua_State *L) { + const char *err_str; + const char *err_file; + NSLinkEditErrors err; + int err_num; + NSLinkEditError(&err, &err_num, &err_file, &err_str); + lua_pushstring(L, err_str); +} + + +static const char *errorfromcode (NSObjectFileImageReturnCode ret) { + switch (ret) { + case NSObjectFileImageInappropriateFile: + return "file is not a bundle"; + case NSObjectFileImageArch: + return "library is for wrong CPU type"; + case NSObjectFileImageFormat: + return "bad format"; + case NSObjectFileImageAccess: + return "cannot access file"; + case NSObjectFileImageFailure: + default: + return "unable to load library"; + } +} + + +static void ll_unloadlib (void *lib) { + NSUnLinkModule((NSModule)lib, NSUNLINKMODULE_OPTION_RESET_LAZY_REFERENCES); +} + + +static void *ll_load (lua_State *L, const char *path) { + NSObjectFileImage img; + NSObjectFileImageReturnCode ret; + /* this would be a rare case, but prevents crashing if it happens */ + if(!_dyld_present()) { + lua_pushliteral(L, "dyld not present"); + return NULL; + } + ret = NSCreateObjectFileImageFromFile(path, &img); + if (ret == NSObjectFileImageSuccess) { + NSModule mod = NSLinkModule(img, path, NSLINKMODULE_OPTION_PRIVATE | + NSLINKMODULE_OPTION_RETURN_ON_ERROR); + NSDestroyObjectFileImage(img); + if (mod == NULL) pusherror(L); + return mod; + } + lua_pushstring(L, errorfromcode(ret)); + return NULL; +} + + +static lua_CFunction ll_sym (lua_State *L, void *lib, const char *sym) { + NSSymbol nss = NSLookupSymbolInModule((NSModule)lib, sym); + if (nss == NULL) { + lua_pushfstring(L, "symbol " LUA_QS " not found", sym); + return NULL; + } + return (lua_CFunction)NSAddressOfSymbol(nss); +} + +/* }====================================================== */ + + + +#else +/* +** {====================================================== +** Fallback for other systems +** ======================================================= +*/ + +#undef LIB_FAIL +#define LIB_FAIL "absent" + + +#define DLMSG "dynamic libraries not enabled; check your Lua installation" + + +static void ll_unloadlib (void *lib) { + (void)lib; /* to avoid warnings */ +} + + +static void *ll_load (lua_State *L, const char *path) { + (void)path; /* to avoid warnings */ + lua_pushliteral(L, DLMSG); + return NULL; +} + + +static lua_CFunction ll_sym (lua_State *L, void *lib, const char *sym) { + (void)lib; (void)sym; /* to avoid warnings */ + lua_pushliteral(L, DLMSG); + return NULL; +} + +/* }====================================================== */ +#endif + + + +static void **ll_register (lua_State *L, const char *path) { + void **plib; + lua_pushfstring(L, "%s%s", LIBPREFIX, path); + lua_gettable(L, LUA_REGISTRYINDEX); /* check library in registry? */ + if (!lua_isnil(L, -1)) /* is there an entry? */ + plib = (void **)lua_touserdata(L, -1); + else { /* no entry yet; create one */ + lua_pop(L, 1); + plib = (void **)lua_newuserdata(L, sizeof(const void *)); + *plib = NULL; + luaL_getmetatable(L, "_LOADLIB"); + lua_setmetatable(L, -2); + lua_pushfstring(L, "%s%s", LIBPREFIX, path); + lua_pushvalue(L, -2); + lua_settable(L, LUA_REGISTRYINDEX); + } + return plib; +} + + +/* +** __gc tag method: calls library's `ll_unloadlib' function with the lib +** handle +*/ +static int gctm (lua_State *L) { + void **lib = (void **)luaL_checkudata(L, 1, "_LOADLIB"); + if (*lib) ll_unloadlib(*lib); + *lib = NULL; /* mark library as closed */ + return 0; +} + + +static int ll_loadfunc (lua_State *L, const char *path, const char *sym) { + void **reg = ll_register(L, path); + if (*reg == NULL) *reg = ll_load(L, path); + if (*reg == NULL) + return ERRLIB; /* unable to load library */ + else { + lua_CFunction f = ll_sym(L, *reg, sym); + if (f == NULL) + return ERRFUNC; /* unable to find function */ + lua_pushcfunction(L, f); + return 0; /* return function */ + } +} + + +static int ll_loadlib (lua_State *L) { + const char *path = luaL_checkstring(L, 1); + const char *init = luaL_checkstring(L, 2); + int stat = ll_loadfunc(L, path, init); + if (stat == 0) /* no errors? */ + return 1; /* return the loaded function */ + else { /* error; error message is on stack top */ + lua_pushnil(L); + lua_insert(L, -2); + lua_pushstring(L, (stat == ERRLIB) ? LIB_FAIL : "init"); + return 3; /* return nil, error message, and where */ + } +} + + + +/* +** {====================================================== +** 'require' function +** ======================================================= +*/ + + +static int readable (const char *filename) { + FILE *f = fopen(filename, "r"); /* try to open file */ + if (f == NULL) return 0; /* open failed */ + fclose(f); + return 1; +} + + +static const char *pushnexttemplate (lua_State *L, const char *path) { + const char *l; + while (*path == *LUA_PATHSEP) path++; /* skip separators */ + if (*path == '\0') return NULL; /* no more templates */ + l = strchr(path, *LUA_PATHSEP); /* find next separator */ + if (l == NULL) l = path + strlen(path); + lua_pushlstring(L, path, l - path); /* template */ + return l; +} + + +static const char *findfile (lua_State *L, const char *name, + const char *pname) { + const char *path; + name = luaL_gsub(L, name, ".", LUA_DIRSEP); + lua_getfield(L, LUA_ENVIRONINDEX, pname); + path = lua_tostring(L, -1); + if (path == NULL) + luaL_error(L, LUA_QL("package.%s") " must be a string", pname); + lua_pushliteral(L, ""); /* error accumulator */ + while ((path = pushnexttemplate(L, path)) != NULL) { + const char *filename; + filename = luaL_gsub(L, lua_tostring(L, -1), LUA_PATH_MARK, name); + lua_remove(L, -2); /* remove path template */ + if (readable(filename)) /* does file exist and is readable? */ + return filename; /* return that file name */ + lua_pushfstring(L, "\n\tno file " LUA_QS, filename); + lua_remove(L, -2); /* remove file name */ + lua_concat(L, 2); /* add entry to possible error message */ + } + return NULL; /* not found */ +} + + +static void loaderror (lua_State *L, const char *filename) { + luaL_error(L, "error loading module " LUA_QS " from file " LUA_QS ":\n\t%s", + lua_tostring(L, 1), filename, lua_tostring(L, -1)); +} + + +static int loader_Lua (lua_State *L) { + const char *filename; + const char *name = luaL_checkstring(L, 1); + filename = findfile(L, name, "path"); + if (filename == NULL) return 1; /* library not found in this path */ + if (luaL_loadfile(L, filename) != 0) + loaderror(L, filename); + return 1; /* library loaded successfully */ +} + + +static const char *mkfuncname (lua_State *L, const char *modname) { + const char *funcname; + const char *mark = strchr(modname, *LUA_IGMARK); + if (mark) modname = mark + 1; + funcname = luaL_gsub(L, modname, ".", LUA_OFSEP); + funcname = lua_pushfstring(L, POF"%s", funcname); + lua_remove(L, -2); /* remove 'gsub' result */ + return funcname; +} + + +static int loader_C (lua_State *L) { + const char *funcname; + const char *name = luaL_checkstring(L, 1); + const char *filename = findfile(L, name, "cpath"); + if (filename == NULL) return 1; /* library not found in this path */ + funcname = mkfuncname(L, name); + if (ll_loadfunc(L, filename, funcname) != 0) + loaderror(L, filename); + return 1; /* library loaded successfully */ +} + + +static int loader_Croot (lua_State *L) { + const char *funcname; + const char *filename; + const char *name = luaL_checkstring(L, 1); + const char *p = strchr(name, '.'); + int stat; + if (p == NULL) return 0; /* is root */ + lua_pushlstring(L, name, p - name); + filename = findfile(L, lua_tostring(L, -1), "cpath"); + if (filename == NULL) return 1; /* root not found */ + funcname = mkfuncname(L, name); + if ((stat = ll_loadfunc(L, filename, funcname)) != 0) { + if (stat != ERRFUNC) loaderror(L, filename); /* real error */ + lua_pushfstring(L, "\n\tno module " LUA_QS " in file " LUA_QS, + name, filename); + return 1; /* function not found */ + } + return 1; +} + + +static int loader_preload (lua_State *L) { + const char *name = luaL_checkstring(L, 1); + lua_getfield(L, LUA_ENVIRONINDEX, "preload"); + if (!lua_istable(L, -1)) + luaL_error(L, LUA_QL("package.preload") " must be a table"); + lua_getfield(L, -1, name); + if (lua_isnil(L, -1)) /* not found? */ + lua_pushfstring(L, "\n\tno field package.preload['%s']", name); + return 1; +} + + +static const int sentinel_ = 0; +#define sentinel ((void *)&sentinel_) + + +static int ll_require (lua_State *L) { + const char *name = luaL_checkstring(L, 1); + int i; + lua_settop(L, 1); /* _LOADED table will be at index 2 */ + lua_getfield(L, LUA_REGISTRYINDEX, "_LOADED"); + lua_getfield(L, 2, name); + if (lua_toboolean(L, -1)) { /* is it there? */ + if (lua_touserdata(L, -1) == sentinel) /* check loops */ + luaL_error(L, "loop or previous error loading module " LUA_QS, name); + return 1; /* package is already loaded */ + } + /* else must load it; iterate over available loaders */ + lua_getfield(L, LUA_ENVIRONINDEX, "loaders"); + if (!lua_istable(L, -1)) + luaL_error(L, LUA_QL("package.loaders") " must be a table"); + lua_pushliteral(L, ""); /* error message accumulator */ + for (i=1; ; i++) { + lua_rawgeti(L, -2, i); /* get a loader */ + if (lua_isnil(L, -1)) + luaL_error(L, "module " LUA_QS " not found:%s", + name, lua_tostring(L, -2)); + lua_pushstring(L, name); + lua_call(L, 1, 1); /* call it */ + if (lua_isfunction(L, -1)) /* did it find module? */ + break; /* module loaded successfully */ + else if (lua_isstring(L, -1)) /* loader returned error message? */ + lua_concat(L, 2); /* accumulate it */ + else + lua_pop(L, 1); + } + lua_pushlightuserdata(L, sentinel); + lua_setfield(L, 2, name); /* _LOADED[name] = sentinel */ + lua_pushstring(L, name); /* pass name as argument to module */ + lua_call(L, 1, 1); /* run loaded module */ + if (!lua_isnil(L, -1)) /* non-nil return? */ + lua_setfield(L, 2, name); /* _LOADED[name] = returned value */ + lua_getfield(L, 2, name); + if (lua_touserdata(L, -1) == sentinel) { /* module did not set a value? */ + lua_pushboolean(L, 1); /* use true as result */ + lua_pushvalue(L, -1); /* extra copy to be returned */ + lua_setfield(L, 2, name); /* _LOADED[name] = true */ + } + return 1; +} + +/* }====================================================== */ + + + +/* +** {====================================================== +** 'module' function +** ======================================================= +*/ + + +static void setfenv (lua_State *L) { + lua_Debug ar; + if (lua_getstack(L, 1, &ar) == 0 || + lua_getinfo(L, "f", &ar) == 0 || /* get calling function */ + lua_iscfunction(L, -1)) + luaL_error(L, LUA_QL("module") " not called from a Lua function"); + lua_pushvalue(L, -2); + lua_setfenv(L, -2); + lua_pop(L, 1); +} + + +static void dooptions (lua_State *L, int n) { + int i; + for (i = 2; i <= n; i++) { + lua_pushvalue(L, i); /* get option (a function) */ + lua_pushvalue(L, -2); /* module */ + lua_call(L, 1, 0); + } +} + + +static void modinit (lua_State *L, const char *modname) { + const char *dot; + lua_pushvalue(L, -1); + lua_setfield(L, -2, "_M"); /* module._M = module */ + lua_pushstring(L, modname); + lua_setfield(L, -2, "_NAME"); + dot = strrchr(modname, '.'); /* look for last dot in module name */ + if (dot == NULL) dot = modname; + else dot++; + /* set _PACKAGE as package name (full module name minus last part) */ + lua_pushlstring(L, modname, dot - modname); + lua_setfield(L, -2, "_PACKAGE"); +} + + +static int ll_module (lua_State *L) { + const char *modname = luaL_checkstring(L, 1); + int loaded = lua_gettop(L) + 1; /* index of _LOADED table */ + lua_getfield(L, LUA_REGISTRYINDEX, "_LOADED"); + lua_getfield(L, loaded, modname); /* get _LOADED[modname] */ + if (!lua_istable(L, -1)) { /* not found? */ + lua_pop(L, 1); /* remove previous result */ + /* try global variable (and create one if it does not exist) */ + if (luaL_findtable(L, LUA_GLOBALSINDEX, modname, 1) != NULL) + return luaL_error(L, "name conflict for module " LUA_QS, modname); + lua_pushvalue(L, -1); + lua_setfield(L, loaded, modname); /* _LOADED[modname] = new table */ + } + /* check whether table already has a _NAME field */ + lua_getfield(L, -1, "_NAME"); + if (!lua_isnil(L, -1)) /* is table an initialized module? */ + lua_pop(L, 1); + else { /* no; initialize it */ + lua_pop(L, 1); + modinit(L, modname); + } + lua_pushvalue(L, -1); + setfenv(L); + dooptions(L, loaded - 1); + return 0; +} + + +static int ll_seeall (lua_State *L) { + luaL_checktype(L, 1, LUA_TTABLE); + if (!lua_getmetatable(L, 1)) { + lua_createtable(L, 0, 1); /* create new metatable */ + lua_pushvalue(L, -1); + lua_setmetatable(L, 1); + } + lua_pushvalue(L, LUA_GLOBALSINDEX); + lua_setfield(L, -2, "__index"); /* mt.__index = _G */ + return 0; +} + + +/* }====================================================== */ + + + +/* auxiliary mark (for internal use) */ +#define AUXMARK "\1" + +static void setpath (lua_State *L, const char *fieldname, const char *envname, + const char *def) { + const char *path = getenv(envname); + if (path == NULL) /* no environment variable? */ + lua_pushstring(L, def); /* use default */ + else { + /* replace ";;" by ";AUXMARK;" and then AUXMARK by default path */ + path = luaL_gsub(L, path, LUA_PATHSEP LUA_PATHSEP, + LUA_PATHSEP AUXMARK LUA_PATHSEP); + luaL_gsub(L, path, AUXMARK, def); + lua_remove(L, -2); + } + setprogdir(L); + lua_setfield(L, -2, fieldname); +} + + +static const luaL_Reg pk_funcs[] = { + {"loadlib", ll_loadlib}, + {"seeall", ll_seeall}, + {NULL, NULL} +}; + + +static const luaL_Reg ll_funcs[] = { + {"module", ll_module}, + {"require", ll_require}, + {NULL, NULL} +}; + + +static const lua_CFunction loaders[] = + {loader_preload, loader_Lua, loader_C, loader_Croot, NULL}; + + +LUALIB_API int luaopen_package (lua_State *L) { + int i; + /* create new type _LOADLIB */ + luaL_newmetatable(L, "_LOADLIB"); + lua_pushcfunction(L, gctm); + lua_setfield(L, -2, "__gc"); + /* create `package' table */ + luaL_register(L, LUA_LOADLIBNAME, pk_funcs); +#if defined(LUA_COMPAT_LOADLIB) + lua_getfield(L, -1, "loadlib"); + lua_setfield(L, LUA_GLOBALSINDEX, "loadlib"); +#endif + lua_pushvalue(L, -1); + lua_replace(L, LUA_ENVIRONINDEX); + /* create `loaders' table */ + lua_createtable(L, 0, sizeof(loaders)/sizeof(loaders[0]) - 1); + /* fill it with pre-defined loaders */ + for (i=0; loaders[i] != NULL; i++) { + lua_pushcfunction(L, loaders[i]); + lua_rawseti(L, -2, i+1); + } + lua_setfield(L, -2, "loaders"); /* put it in field `loaders' */ + setpath(L, "path", LUA_PATH, LUA_PATH_DEFAULT); /* set field `path' */ + setpath(L, "cpath", LUA_CPATH, LUA_CPATH_DEFAULT); /* set field `cpath' */ + /* store config information */ + lua_pushliteral(L, LUA_DIRSEP "\n" LUA_PATHSEP "\n" LUA_PATH_MARK "\n" + LUA_EXECDIR "\n" LUA_IGMARK); + lua_setfield(L, -2, "config"); + /* set field `loaded' */ + luaL_findtable(L, LUA_REGISTRYINDEX, "_LOADED", 2); + lua_setfield(L, -2, "loaded"); + /* set field `preload' */ + lua_newtable(L); + lua_setfield(L, -2, "preload"); + lua_pushvalue(L, LUA_GLOBALSINDEX); + luaL_register(L, NULL, ll_funcs); /* open lib into global table */ + lua_pop(L, 1); + return 1; /* return 'package' table */ +} + diff --git a/mylua/lua/lobject.c b/mylua/lua/lobject.c new file mode 100644 index 0000000..4ff5073 --- /dev/null +++ b/mylua/lua/lobject.c @@ -0,0 +1,214 @@ +/* +** $Id: lobject.c,v 2.22.1.1 2007/12/27 13:02:25 roberto Exp $ +** Some generic functions over Lua objects +** See Copyright Notice in lua.h +*/ + +#include +#include +#include +#include +#include + +#define lobject_c +#define LUA_CORE + +#include "lua.h" + +#include "ldo.h" +#include "lmem.h" +#include "lobject.h" +#include "lstate.h" +#include "lstring.h" +#include "lvm.h" + + + +const TValue luaO_nilobject_ = {{NULL}, LUA_TNIL}; + + +/* +** converts an integer to a "floating point byte", represented as +** (eeeeexxx), where the real value is (1xxx) * 2^(eeeee - 1) if +** eeeee != 0 and (xxx) otherwise. +*/ +int luaO_int2fb (unsigned int x) { + int e = 0; /* expoent */ + while (x >= 16) { + x = (x+1) >> 1; + e++; + } + if (x < 8) return x; + else return ((e+1) << 3) | (cast_int(x) - 8); +} + + +/* converts back */ +int luaO_fb2int (int x) { + int e = (x >> 3) & 31; + if (e == 0) return x; + else return ((x & 7)+8) << (e - 1); +} + + +int luaO_log2 (unsigned int x) { + static const lu_byte log_2[256] = { + 0,1,2,2,3,3,3,3,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5, + 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6, + 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, + 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, + 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, + 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, + 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, + 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8 + }; + int l = -1; + while (x >= 256) { l += 8; x >>= 8; } + return l + log_2[x]; + +} + + +int luaO_rawequalObj (const TValue *t1, const TValue *t2) { + if (ttype(t1) != ttype(t2)) return 0; + else switch (ttype(t1)) { + case LUA_TNIL: + return 1; + case LUA_TNUMBER: + return luai_numeq(nvalue(t1), nvalue(t2)); + case LUA_TBOOLEAN: + return bvalue(t1) == bvalue(t2); /* boolean true must be 1 !! */ + case LUA_TLIGHTUSERDATA: + return pvalue(t1) == pvalue(t2); + default: + lua_assert(iscollectable(t1)); + return gcvalue(t1) == gcvalue(t2); + } +} + + +int luaO_str2d (const char *s, lua_Number *result) { + char *endptr; + *result = lua_str2number(s, &endptr); + if (endptr == s) return 0; /* conversion failed */ + if (*endptr == 'x' || *endptr == 'X') /* maybe an hexadecimal constant? */ + *result = cast_num(strtoul(s, &endptr, 16)); + if (*endptr == '\0') return 1; /* most common case */ + while (isspace(cast(unsigned char, *endptr))) endptr++; + if (*endptr != '\0') return 0; /* invalid trailing characters? */ + return 1; +} + + + +static void pushstr (lua_State *L, const char *str) { + setsvalue2s(L, L->top, luaS_new(L, str)); + incr_top(L); +} + + +/* this function handles only `%d', `%c', %f, %p, and `%s' formats */ +const char *luaO_pushvfstring (lua_State *L, const char *fmt, va_list argp) { + int n = 1; + pushstr(L, ""); + for (;;) { + const char *e = strchr(fmt, '%'); + if (e == NULL) break; + setsvalue2s(L, L->top, luaS_newlstr(L, fmt, e-fmt)); + incr_top(L); + switch (*(e+1)) { + case 's': { + const char *s = va_arg(argp, char *); + if (s == NULL) s = "(null)"; + pushstr(L, s); + break; + } + case 'c': { + char buff[2]; + buff[0] = cast(char, va_arg(argp, int)); + buff[1] = '\0'; + pushstr(L, buff); + break; + } + case 'd': { + setnvalue(L->top, cast_num(va_arg(argp, int))); + incr_top(L); + break; + } + case 'f': { + setnvalue(L->top, cast_num(va_arg(argp, l_uacNumber))); + incr_top(L); + break; + } + case 'p': { + char buff[4*sizeof(void *) + 8]; /* should be enough space for a `%p' */ + sprintf(buff, "%p", va_arg(argp, void *)); + pushstr(L, buff); + break; + } + case '%': { + pushstr(L, "%"); + break; + } + default: { + char buff[3]; + buff[0] = '%'; + buff[1] = *(e+1); + buff[2] = '\0'; + pushstr(L, buff); + break; + } + } + n += 2; + fmt = e+2; + } + pushstr(L, fmt); + luaV_concat(L, n+1, cast_int(L->top - L->base) - 1); + L->top -= n; + return svalue(L->top - 1); +} + + +const char *luaO_pushfstring (lua_State *L, const char *fmt, ...) { + const char *msg; + va_list argp; + va_start(argp, fmt); + msg = luaO_pushvfstring(L, fmt, argp); + va_end(argp); + return msg; +} + + +void luaO_chunkid (char *out, const char *source, size_t bufflen) { + if (*source == '=') { + strncpy(out, source+1, bufflen); /* remove first char */ + out[bufflen-1] = '\0'; /* ensures null termination */ + } + else { /* out = "source", or "...source" */ + if (*source == '@') { + size_t l; + source++; /* skip the `@' */ + bufflen -= sizeof(" '...' "); + l = strlen(source); + strcpy(out, ""); + if (l > bufflen) { + source += (l-bufflen); /* get last part of file name */ + strcat(out, "..."); + } + strcat(out, source); + } + else { /* out = [string "string"] */ + size_t len = strcspn(source, "\n\r"); /* stop at first newline */ + bufflen -= sizeof(" [string \"...\"] "); + if (len > bufflen) len = bufflen; + strcpy(out, "[string \""); + if (source[len] != '\0') { /* must truncate? */ + strncat(out, source, len); + strcat(out, "..."); + } + else + strcat(out, source); + strcat(out, "\"]"); + } + } +} diff --git a/mylua/lua/lobject.h b/mylua/lua/lobject.h new file mode 100644 index 0000000..f1e447e --- /dev/null +++ b/mylua/lua/lobject.h @@ -0,0 +1,381 @@ +/* +** $Id: lobject.h,v 2.20.1.2 2008/08/06 13:29:48 roberto Exp $ +** Type definitions for Lua objects +** See Copyright Notice in lua.h +*/ + + +#ifndef lobject_h +#define lobject_h + + +#include + + +#include "llimits.h" +#include "lua.h" + + +/* tags for values visible from Lua */ +#define LAST_TAG LUA_TTHREAD + +#define NUM_TAGS (LAST_TAG+1) + + +/* +** Extra tags for non-values +*/ +#define LUA_TPROTO (LAST_TAG+1) +#define LUA_TUPVAL (LAST_TAG+2) +#define LUA_TDEADKEY (LAST_TAG+3) + + +/* +** Union of all collectable objects +*/ +typedef union GCObject GCObject; + + +/* +** Common Header for all collectable objects (in macro form, to be +** included in other objects) +*/ +#define CommonHeader GCObject *next; lu_byte tt; lu_byte marked + + +/* +** Common header in struct form +*/ +typedef struct GCheader { + CommonHeader; +} GCheader; + + + + +/* +** Union of all Lua values +*/ +typedef union { + GCObject *gc; + void *p; + lua_Number n; + int b; +} Value; + + +/* +** Tagged Values +*/ + +#define TValuefields Value value; int tt + +typedef struct lua_TValue { + TValuefields; +} TValue; + + +/* Macros to test type */ +#define ttisnil(o) (ttype(o) == LUA_TNIL) +#define ttisnumber(o) (ttype(o) == LUA_TNUMBER) +#define ttisstring(o) (ttype(o) == LUA_TSTRING) +#define ttistable(o) (ttype(o) == LUA_TTABLE) +#define ttisfunction(o) (ttype(o) == LUA_TFUNCTION) +#define ttisboolean(o) (ttype(o) == LUA_TBOOLEAN) +#define ttisuserdata(o) (ttype(o) == LUA_TUSERDATA) +#define ttisthread(o) (ttype(o) == LUA_TTHREAD) +#define ttislightuserdata(o) (ttype(o) == LUA_TLIGHTUSERDATA) + +/* Macros to access values */ +#define ttype(o) ((o)->tt) +#define gcvalue(o) check_exp(iscollectable(o), (o)->value.gc) +#define pvalue(o) check_exp(ttislightuserdata(o), (o)->value.p) +#define nvalue(o) check_exp(ttisnumber(o), (o)->value.n) +#define rawtsvalue(o) check_exp(ttisstring(o), &(o)->value.gc->ts) +#define tsvalue(o) (&rawtsvalue(o)->tsv) +#define rawuvalue(o) check_exp(ttisuserdata(o), &(o)->value.gc->u) +#define uvalue(o) (&rawuvalue(o)->uv) +#define clvalue(o) check_exp(ttisfunction(o), &(o)->value.gc->cl) +#define hvalue(o) check_exp(ttistable(o), &(o)->value.gc->h) +#define bvalue(o) check_exp(ttisboolean(o), (o)->value.b) +#define thvalue(o) check_exp(ttisthread(o), &(o)->value.gc->th) + +#define l_isfalse(o) (ttisnil(o) || (ttisboolean(o) && bvalue(o) == 0)) + +/* +** for internal debug only +*/ +#define checkconsistency(obj) \ + lua_assert(!iscollectable(obj) || (ttype(obj) == (obj)->value.gc->gch.tt)) + +#define checkliveness(g,obj) \ + lua_assert(!iscollectable(obj) || \ + ((ttype(obj) == (obj)->value.gc->gch.tt) && !isdead(g, (obj)->value.gc))) + + +/* Macros to set values */ +#define setnilvalue(obj) ((obj)->tt=LUA_TNIL) + +#define setnvalue(obj,x) \ + { TValue *i_o=(obj); i_o->value.n=(x); i_o->tt=LUA_TNUMBER; } + +#define setpvalue(obj,x) \ + { TValue *i_o=(obj); i_o->value.p=(x); i_o->tt=LUA_TLIGHTUSERDATA; } + +#define setbvalue(obj,x) \ + { TValue *i_o=(obj); i_o->value.b=(x); i_o->tt=LUA_TBOOLEAN; } + +#define setsvalue(L,obj,x) \ + { TValue *i_o=(obj); \ + i_o->value.gc=cast(GCObject *, (x)); i_o->tt=LUA_TSTRING; \ + checkliveness(G(L),i_o); } + +#define setuvalue(L,obj,x) \ + { TValue *i_o=(obj); \ + i_o->value.gc=cast(GCObject *, (x)); i_o->tt=LUA_TUSERDATA; \ + checkliveness(G(L),i_o); } + +#define setthvalue(L,obj,x) \ + { TValue *i_o=(obj); \ + i_o->value.gc=cast(GCObject *, (x)); i_o->tt=LUA_TTHREAD; \ + checkliveness(G(L),i_o); } + +#define setclvalue(L,obj,x) \ + { TValue *i_o=(obj); \ + i_o->value.gc=cast(GCObject *, (x)); i_o->tt=LUA_TFUNCTION; \ + checkliveness(G(L),i_o); } + +#define sethvalue(L,obj,x) \ + { TValue *i_o=(obj); \ + i_o->value.gc=cast(GCObject *, (x)); i_o->tt=LUA_TTABLE; \ + checkliveness(G(L),i_o); } + +#define setptvalue(L,obj,x) \ + { TValue *i_o=(obj); \ + i_o->value.gc=cast(GCObject *, (x)); i_o->tt=LUA_TPROTO; \ + checkliveness(G(L),i_o); } + + + + +#define setobj(L,obj1,obj2) \ + { const TValue *o2=(obj2); TValue *o1=(obj1); \ + o1->value = o2->value; o1->tt=o2->tt; \ + checkliveness(G(L),o1); } + + +/* +** different types of sets, according to destination +*/ + +/* from stack to (same) stack */ +#define setobjs2s setobj +/* to stack (not from same stack) */ +#define setobj2s setobj +#define setsvalue2s setsvalue +#define sethvalue2s sethvalue +#define setptvalue2s setptvalue +/* from table to same table */ +#define setobjt2t setobj +/* to table */ +#define setobj2t setobj +/* to new object */ +#define setobj2n setobj +#define setsvalue2n setsvalue + +#define setttype(obj, tt) (ttype(obj) = (tt)) + + +#define iscollectable(o) (ttype(o) >= LUA_TSTRING) + + + +typedef TValue *StkId; /* index to stack elements */ + + +/* +** String headers for string table +*/ +typedef union TString { + L_Umaxalign dummy; /* ensures maximum alignment for strings */ + struct { + CommonHeader; + lu_byte reserved; + unsigned int hash; + size_t len; + } tsv; +} TString; + + +#define getstr(ts) cast(const char *, (ts) + 1) +#define svalue(o) getstr(rawtsvalue(o)) + + + +typedef union Udata { + L_Umaxalign dummy; /* ensures maximum alignment for `local' udata */ + struct { + CommonHeader; + struct Table *metatable; + struct Table *env; + size_t len; + } uv; +} Udata; + + + + +/* +** Function Prototypes +*/ +typedef struct Proto { + CommonHeader; + TValue *k; /* constants used by the function */ + Instruction *code; + struct Proto **p; /* functions defined inside the function */ + int *lineinfo; /* map from opcodes to source lines */ + struct LocVar *locvars; /* information about local variables */ + TString **upvalues; /* upvalue names */ + TString *source; + int sizeupvalues; + int sizek; /* size of `k' */ + int sizecode; + int sizelineinfo; + int sizep; /* size of `p' */ + int sizelocvars; + int linedefined; + int lastlinedefined; + GCObject *gclist; + lu_byte nups; /* number of upvalues */ + lu_byte numparams; + lu_byte is_vararg; + lu_byte maxstacksize; +} Proto; + + +/* masks for new-style vararg */ +#define VARARG_HASARG 1 +#define VARARG_ISVARARG 2 +#define VARARG_NEEDSARG 4 + + +typedef struct LocVar { + TString *varname; + int startpc; /* first point where variable is active */ + int endpc; /* first point where variable is dead */ +} LocVar; + + + +/* +** Upvalues +*/ + +typedef struct UpVal { + CommonHeader; + TValue *v; /* points to stack or to its own value */ + union { + TValue value; /* the value (when closed) */ + struct { /* double linked list (when open) */ + struct UpVal *prev; + struct UpVal *next; + } l; + } u; +} UpVal; + + +/* +** Closures +*/ + +#define ClosureHeader \ + CommonHeader; lu_byte isC; lu_byte nupvalues; GCObject *gclist; \ + struct Table *env + +typedef struct CClosure { + ClosureHeader; + lua_CFunction f; + TValue upvalue[1]; +} CClosure; + + +typedef struct LClosure { + ClosureHeader; + struct Proto *p; + UpVal *upvals[1]; +} LClosure; + + +typedef union Closure { + CClosure c; + LClosure l; +} Closure; + + +#define iscfunction(o) (ttype(o) == LUA_TFUNCTION && clvalue(o)->c.isC) +#define isLfunction(o) (ttype(o) == LUA_TFUNCTION && !clvalue(o)->c.isC) + + +/* +** Tables +*/ + +typedef union TKey { + struct { + TValuefields; + struct Node *next; /* for chaining */ + } nk; + TValue tvk; +} TKey; + + +typedef struct Node { + TValue i_val; + TKey i_key; +} Node; + + +typedef struct Table { + CommonHeader; + lu_byte flags; /* 1<

lsizenode)) + + +#define luaO_nilobject (&luaO_nilobject_) + +LUAI_DATA const TValue luaO_nilobject_; + +#define ceillog2(x) (luaO_log2((x)-1) + 1) + +LUAI_FUNC int luaO_log2 (unsigned int x); +LUAI_FUNC int luaO_int2fb (unsigned int x); +LUAI_FUNC int luaO_fb2int (int x); +LUAI_FUNC int luaO_rawequalObj (const TValue *t1, const TValue *t2); +LUAI_FUNC int luaO_str2d (const char *s, lua_Number *result); +LUAI_FUNC const char *luaO_pushvfstring (lua_State *L, const char *fmt, + va_list argp); +LUAI_FUNC const char *luaO_pushfstring (lua_State *L, const char *fmt, ...); +LUAI_FUNC void luaO_chunkid (char *out, const char *source, size_t len); + + +#endif + diff --git a/mylua/lua/lopcodes.c b/mylua/lua/lopcodes.c new file mode 100644 index 0000000..4cc7452 --- /dev/null +++ b/mylua/lua/lopcodes.c @@ -0,0 +1,102 @@ +/* +** $Id: lopcodes.c,v 1.37.1.1 2007/12/27 13:02:25 roberto Exp $ +** See Copyright Notice in lua.h +*/ + + +#define lopcodes_c +#define LUA_CORE + + +#include "lopcodes.h" + + +/* ORDER OP */ + +const char *const luaP_opnames[NUM_OPCODES+1] = { + "MOVE", + "LOADK", + "LOADBOOL", + "LOADNIL", + "GETUPVAL", + "GETGLOBAL", + "GETTABLE", + "SETGLOBAL", + "SETUPVAL", + "SETTABLE", + "NEWTABLE", + "SELF", + "ADD", + "SUB", + "MUL", + "DIV", + "MOD", + "POW", + "UNM", + "NOT", + "LEN", + "CONCAT", + "JMP", + "EQ", + "LT", + "LE", + "TEST", + "TESTSET", + "CALL", + "TAILCALL", + "RETURN", + "FORLOOP", + "FORPREP", + "TFORLOOP", + "SETLIST", + "CLOSE", + "CLOSURE", + "VARARG", + NULL +}; + + +#define opmode(t,a,b,c,m) (((t)<<7) | ((a)<<6) | ((b)<<4) | ((c)<<2) | (m)) + +const lu_byte luaP_opmodes[NUM_OPCODES] = { +/* T A B C mode opcode */ + opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_MOVE */ + ,opmode(0, 1, OpArgK, OpArgN, iABx) /* OP_LOADK */ + ,opmode(0, 1, OpArgU, OpArgU, iABC) /* OP_LOADBOOL */ + ,opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_LOADNIL */ + ,opmode(0, 1, OpArgU, OpArgN, iABC) /* OP_GETUPVAL */ + ,opmode(0, 1, OpArgK, OpArgN, iABx) /* OP_GETGLOBAL */ + ,opmode(0, 1, OpArgR, OpArgK, iABC) /* OP_GETTABLE */ + ,opmode(0, 0, OpArgK, OpArgN, iABx) /* OP_SETGLOBAL */ + ,opmode(0, 0, OpArgU, OpArgN, iABC) /* OP_SETUPVAL */ + ,opmode(0, 0, OpArgK, OpArgK, iABC) /* OP_SETTABLE */ + ,opmode(0, 1, OpArgU, OpArgU, iABC) /* OP_NEWTABLE */ + ,opmode(0, 1, OpArgR, OpArgK, iABC) /* OP_SELF */ + ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_ADD */ + ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_SUB */ + ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_MUL */ + ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_DIV */ + ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_MOD */ + ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_POW */ + ,opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_UNM */ + ,opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_NOT */ + ,opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_LEN */ + ,opmode(0, 1, OpArgR, OpArgR, iABC) /* OP_CONCAT */ + ,opmode(0, 0, OpArgR, OpArgN, iAsBx) /* OP_JMP */ + ,opmode(1, 0, OpArgK, OpArgK, iABC) /* OP_EQ */ + ,opmode(1, 0, OpArgK, OpArgK, iABC) /* OP_LT */ + ,opmode(1, 0, OpArgK, OpArgK, iABC) /* OP_LE */ + ,opmode(1, 1, OpArgR, OpArgU, iABC) /* OP_TEST */ + ,opmode(1, 1, OpArgR, OpArgU, iABC) /* OP_TESTSET */ + ,opmode(0, 1, OpArgU, OpArgU, iABC) /* OP_CALL */ + ,opmode(0, 1, OpArgU, OpArgU, iABC) /* OP_TAILCALL */ + ,opmode(0, 0, OpArgU, OpArgN, iABC) /* OP_RETURN */ + ,opmode(0, 1, OpArgR, OpArgN, iAsBx) /* OP_FORLOOP */ + ,opmode(0, 1, OpArgR, OpArgN, iAsBx) /* OP_FORPREP */ + ,opmode(1, 0, OpArgN, OpArgU, iABC) /* OP_TFORLOOP */ + ,opmode(0, 0, OpArgU, OpArgU, iABC) /* OP_SETLIST */ + ,opmode(0, 0, OpArgN, OpArgN, iABC) /* OP_CLOSE */ + ,opmode(0, 1, OpArgU, OpArgN, iABx) /* OP_CLOSURE */ + ,opmode(0, 1, OpArgU, OpArgN, iABC) /* OP_VARARG */ +}; + diff --git a/mylua/lua/lopcodes.h b/mylua/lua/lopcodes.h new file mode 100644 index 0000000..41224d6 --- /dev/null +++ b/mylua/lua/lopcodes.h @@ -0,0 +1,268 @@ +/* +** $Id: lopcodes.h,v 1.125.1.1 2007/12/27 13:02:25 roberto Exp $ +** Opcodes for Lua virtual machine +** See Copyright Notice in lua.h +*/ + +#ifndef lopcodes_h +#define lopcodes_h + +#include "llimits.h" + + +/*=========================================================================== + We assume that instructions are unsigned numbers. + All instructions have an opcode in the first 6 bits. + Instructions can have the following fields: + `A' : 8 bits + `B' : 9 bits + `C' : 9 bits + `Bx' : 18 bits (`B' and `C' together) + `sBx' : signed Bx + + A signed argument is represented in excess K; that is, the number + value is the unsigned value minus K. K is exactly the maximum value + for that argument (so that -max is represented by 0, and +max is + represented by 2*max), which is half the maximum for the corresponding + unsigned argument. +===========================================================================*/ + + +enum OpMode {iABC, iABx, iAsBx}; /* basic instruction format */ + + +/* +** size and position of opcode arguments. +*/ +#define SIZE_C 9 +#define SIZE_B 9 +#define SIZE_Bx (SIZE_C + SIZE_B) +#define SIZE_A 8 + +#define SIZE_OP 6 + +#define POS_OP 0 +#define POS_A (POS_OP + SIZE_OP) +#define POS_C (POS_A + SIZE_A) +#define POS_B (POS_C + SIZE_C) +#define POS_Bx POS_C + + +/* +** limits for opcode arguments. +** we use (signed) int to manipulate most arguments, +** so they must fit in LUAI_BITSINT-1 bits (-1 for sign) +*/ +#if SIZE_Bx < LUAI_BITSINT-1 +#define MAXARG_Bx ((1<>1) /* `sBx' is signed */ +#else +#define MAXARG_Bx MAX_INT +#define MAXARG_sBx MAX_INT +#endif + + +#define MAXARG_A ((1<>POS_OP) & MASK1(SIZE_OP,0))) +#define SET_OPCODE(i,o) ((i) = (((i)&MASK0(SIZE_OP,POS_OP)) | \ + ((cast(Instruction, o)<>POS_A) & MASK1(SIZE_A,0))) +#define SETARG_A(i,u) ((i) = (((i)&MASK0(SIZE_A,POS_A)) | \ + ((cast(Instruction, u)<>POS_B) & MASK1(SIZE_B,0))) +#define SETARG_B(i,b) ((i) = (((i)&MASK0(SIZE_B,POS_B)) | \ + ((cast(Instruction, b)<>POS_C) & MASK1(SIZE_C,0))) +#define SETARG_C(i,b) ((i) = (((i)&MASK0(SIZE_C,POS_C)) | \ + ((cast(Instruction, b)<>POS_Bx) & MASK1(SIZE_Bx,0))) +#define SETARG_Bx(i,b) ((i) = (((i)&MASK0(SIZE_Bx,POS_Bx)) | \ + ((cast(Instruction, b)< C) then pc++ */ +OP_TESTSET,/* A B C if (R(B) <=> C) then R(A) := R(B) else pc++ */ + +OP_CALL,/* A B C R(A), ... ,R(A+C-2) := R(A)(R(A+1), ... ,R(A+B-1)) */ +OP_TAILCALL,/* A B C return R(A)(R(A+1), ... ,R(A+B-1)) */ +OP_RETURN,/* A B return R(A), ... ,R(A+B-2) (see note) */ + +OP_FORLOOP,/* A sBx R(A)+=R(A+2); + if R(A) =) R(A)*/ +OP_CLOSURE,/* A Bx R(A) := closure(KPROTO[Bx], R(A), ... ,R(A+n)) */ + +OP_VARARG/* A B R(A), R(A+1), ..., R(A+B-1) = vararg */ +} OpCode; + + +#define NUM_OPCODES (cast(int, OP_VARARG) + 1) + + + +/*=========================================================================== + Notes: + (*) In OP_CALL, if (B == 0) then B = top. C is the number of returns - 1, + and can be 0: OP_CALL then sets `top' to last_result+1, so + next open instruction (OP_CALL, OP_RETURN, OP_SETLIST) may use `top'. + + (*) In OP_VARARG, if (B == 0) then use actual number of varargs and + set top (like in OP_CALL with C == 0). + + (*) In OP_RETURN, if (B == 0) then return up to `top' + + (*) In OP_SETLIST, if (B == 0) then B = `top'; + if (C == 0) then next `instruction' is real C + + (*) For comparisons, A specifies what condition the test should accept + (true or false). + + (*) All `skips' (pc++) assume that next instruction is a jump +===========================================================================*/ + + +/* +** masks for instruction properties. The format is: +** bits 0-1: op mode +** bits 2-3: C arg mode +** bits 4-5: B arg mode +** bit 6: instruction set register A +** bit 7: operator is a test +*/ + +enum OpArgMask { + OpArgN, /* argument is not used */ + OpArgU, /* argument is used */ + OpArgR, /* argument is a register or a jump offset */ + OpArgK /* argument is a constant or register/constant */ +}; + +LUAI_DATA const lu_byte luaP_opmodes[NUM_OPCODES]; + +#define getOpMode(m) (cast(enum OpMode, luaP_opmodes[m] & 3)) +#define getBMode(m) (cast(enum OpArgMask, (luaP_opmodes[m] >> 4) & 3)) +#define getCMode(m) (cast(enum OpArgMask, (luaP_opmodes[m] >> 2) & 3)) +#define testAMode(m) (luaP_opmodes[m] & (1 << 6)) +#define testTMode(m) (luaP_opmodes[m] & (1 << 7)) + + +LUAI_DATA const char *const luaP_opnames[NUM_OPCODES+1]; /* opcode names */ + + +/* number of list items to accumulate before a SETLIST instruction */ +#define LFIELDS_PER_FLUSH 50 + + +#endif diff --git a/mylua/lua/loslib.c b/mylua/lua/loslib.c new file mode 100644 index 0000000..da06a57 --- /dev/null +++ b/mylua/lua/loslib.c @@ -0,0 +1,243 @@ +/* +** $Id: loslib.c,v 1.19.1.3 2008/01/18 16:38:18 roberto Exp $ +** Standard Operating System library +** See Copyright Notice in lua.h +*/ + + +#include +#include +#include +#include +#include + +#define loslib_c +#define LUA_LIB + +#include "lua.h" + +#include "lauxlib.h" +#include "lualib.h" + + +static int os_pushresult (lua_State *L, int i, const char *filename) { + int en = errno; /* calls to Lua API may change this value */ + if (i) { + lua_pushboolean(L, 1); + return 1; + } + else { + lua_pushnil(L); + lua_pushfstring(L, "%s: %s", filename, strerror(en)); + lua_pushinteger(L, en); + return 3; + } +} + + +static int os_execute (lua_State *L) { + lua_pushinteger(L, system(luaL_optstring(L, 1, NULL))); + return 1; +} + + +static int os_remove (lua_State *L) { + const char *filename = luaL_checkstring(L, 1); + return os_pushresult(L, remove(filename) == 0, filename); +} + + +static int os_rename (lua_State *L) { + const char *fromname = luaL_checkstring(L, 1); + const char *toname = luaL_checkstring(L, 2); + return os_pushresult(L, rename(fromname, toname) == 0, fromname); +} + + +static int os_tmpname (lua_State *L) { + char buff[LUA_TMPNAMBUFSIZE]; + int err; + lua_tmpnam(buff, err); + if (err) + return luaL_error(L, "unable to generate a unique filename"); + lua_pushstring(L, buff); + return 1; +} + + +static int os_getenv (lua_State *L) { + lua_pushstring(L, getenv(luaL_checkstring(L, 1))); /* if NULL push nil */ + return 1; +} + + +static int os_clock (lua_State *L) { + lua_pushnumber(L, ((lua_Number)clock())/(lua_Number)CLOCKS_PER_SEC); + return 1; +} + + +/* +** {====================================================== +** Time/Date operations +** { year=%Y, month=%m, day=%d, hour=%H, min=%M, sec=%S, +** wday=%w+1, yday=%j, isdst=? } +** ======================================================= +*/ + +static void setfield (lua_State *L, const char *key, int value) { + lua_pushinteger(L, value); + lua_setfield(L, -2, key); +} + +static void setboolfield (lua_State *L, const char *key, int value) { + if (value < 0) /* undefined? */ + return; /* does not set field */ + lua_pushboolean(L, value); + lua_setfield(L, -2, key); +} + +static int getboolfield (lua_State *L, const char *key) { + int res; + lua_getfield(L, -1, key); + res = lua_isnil(L, -1) ? -1 : lua_toboolean(L, -1); + lua_pop(L, 1); + return res; +} + + +static int getfield (lua_State *L, const char *key, int d) { + int res; + lua_getfield(L, -1, key); + if (lua_isnumber(L, -1)) + res = (int)lua_tointeger(L, -1); + else { + if (d < 0) + return luaL_error(L, "field " LUA_QS " missing in date table", key); + res = d; + } + lua_pop(L, 1); + return res; +} + + +static int os_date (lua_State *L) { + const char *s = luaL_optstring(L, 1, "%c"); + time_t t = luaL_opt(L, (time_t)luaL_checknumber, 2, time(NULL)); + struct tm *stm; + if (*s == '!') { /* UTC? */ + stm = gmtime(&t); + s++; /* skip `!' */ + } + else + stm = localtime(&t); + if (stm == NULL) /* invalid date? */ + lua_pushnil(L); + else if (strcmp(s, "*t") == 0) { + lua_createtable(L, 0, 9); /* 9 = number of fields */ + setfield(L, "sec", stm->tm_sec); + setfield(L, "min", stm->tm_min); + setfield(L, "hour", stm->tm_hour); + setfield(L, "day", stm->tm_mday); + setfield(L, "month", stm->tm_mon+1); + setfield(L, "year", stm->tm_year+1900); + setfield(L, "wday", stm->tm_wday+1); + setfield(L, "yday", stm->tm_yday+1); + setboolfield(L, "isdst", stm->tm_isdst); + } + else { + char cc[3]; + luaL_Buffer b; + cc[0] = '%'; cc[2] = '\0'; + luaL_buffinit(L, &b); + for (; *s; s++) { + if (*s != '%' || *(s + 1) == '\0') /* no conversion specifier? */ + luaL_addchar(&b, *s); + else { + size_t reslen; + char buff[200]; /* should be big enough for any conversion result */ + cc[1] = *(++s); + reslen = strftime(buff, sizeof(buff), cc, stm); + luaL_addlstring(&b, buff, reslen); + } + } + luaL_pushresult(&b); + } + return 1; +} + + +static int os_time (lua_State *L) { + time_t t; + if (lua_isnoneornil(L, 1)) /* called without args? */ + t = time(NULL); /* get current time */ + else { + struct tm ts; + luaL_checktype(L, 1, LUA_TTABLE); + lua_settop(L, 1); /* make sure table is at the top */ + ts.tm_sec = getfield(L, "sec", 0); + ts.tm_min = getfield(L, "min", 0); + ts.tm_hour = getfield(L, "hour", 12); + ts.tm_mday = getfield(L, "day", -1); + ts.tm_mon = getfield(L, "month", -1) - 1; + ts.tm_year = getfield(L, "year", -1) - 1900; + ts.tm_isdst = getboolfield(L, "isdst"); + t = mktime(&ts); + } + if (t == (time_t)(-1)) + lua_pushnil(L); + else + lua_pushnumber(L, (lua_Number)t); + return 1; +} + + +static int os_difftime (lua_State *L) { + lua_pushnumber(L, difftime((time_t)(luaL_checknumber(L, 1)), + (time_t)(luaL_optnumber(L, 2, 0)))); + return 1; +} + +/* }====================================================== */ + + +static int os_setlocale (lua_State *L) { + static const int cat[] = {LC_ALL, LC_COLLATE, LC_CTYPE, LC_MONETARY, + LC_NUMERIC, LC_TIME}; + static const char *const catnames[] = {"all", "collate", "ctype", "monetary", + "numeric", "time", NULL}; + const char *l = luaL_optstring(L, 1, NULL); + int op = luaL_checkoption(L, 2, "all", catnames); + lua_pushstring(L, setlocale(cat[op], l)); + return 1; +} + + +static int os_exit (lua_State *L) { + exit(luaL_optint(L, 1, EXIT_SUCCESS)); +} + +static const luaL_Reg syslib[] = { + {"clock", os_clock}, + {"date", os_date}, + {"difftime", os_difftime}, + {"execute", os_execute}, + {"exit", os_exit}, + {"getenv", os_getenv}, + {"remove", os_remove}, + {"rename", os_rename}, + {"setlocale", os_setlocale}, + {"time", os_time}, + {"tmpname", os_tmpname}, + {NULL, NULL} +}; + +/* }====================================================== */ + + + +LUALIB_API int luaopen_os (lua_State *L) { + luaL_register(L, LUA_OSLIBNAME, syslib); + return 1; +} + diff --git a/mylua/lua/lparser.c b/mylua/lua/lparser.c new file mode 100644 index 0000000..1e2a9a8 --- /dev/null +++ b/mylua/lua/lparser.c @@ -0,0 +1,1339 @@ +/* +** $Id: lparser.c,v 2.42.1.3 2007/12/28 15:32:23 roberto Exp $ +** Lua Parser +** See Copyright Notice in lua.h +*/ + + +#include + +#define lparser_c +#define LUA_CORE + +#include "lua.h" + +#include "lcode.h" +#include "ldebug.h" +#include "ldo.h" +#include "lfunc.h" +#include "llex.h" +#include "lmem.h" +#include "lobject.h" +#include "lopcodes.h" +#include "lparser.h" +#include "lstate.h" +#include "lstring.h" +#include "ltable.h" + + + +#define hasmultret(k) ((k) == VCALL || (k) == VVARARG) + +#define getlocvar(fs, i) ((fs)->f->locvars[(fs)->actvar[i]]) + +#define luaY_checklimit(fs,v,l,m) if ((v)>(l)) errorlimit(fs,l,m) + + +/* +** nodes for block list (list of active blocks) +*/ +typedef struct BlockCnt { + struct BlockCnt *previous; /* chain */ + int breaklist; /* list of jumps out of this loop */ + lu_byte nactvar; /* # active locals outside the breakable structure */ + lu_byte upval; /* true if some variable in the block is an upvalue */ + lu_byte isbreakable; /* true if `block' is a loop */ +} BlockCnt; + + + +/* +** prototypes for recursive non-terminal functions +*/ +static void chunk (LexState *ls); +static void expr (LexState *ls, expdesc *v); + + +static void anchor_token (LexState *ls) { + if (ls->t.token == TK_NAME || ls->t.token == TK_STRING) { + TString *ts = ls->t.seminfo.ts; + luaX_newstring(ls, getstr(ts), ts->tsv.len); + } +} + + +static void error_expected (LexState *ls, int token) { + luaX_syntaxerror(ls, + luaO_pushfstring(ls->L, LUA_QS " expected", luaX_token2str(ls, token))); +} + + +static void errorlimit (FuncState *fs, int limit, const char *what) { + const char *msg = (fs->f->linedefined == 0) ? + luaO_pushfstring(fs->L, "main function has more than %d %s", limit, what) : + luaO_pushfstring(fs->L, "function at line %d has more than %d %s", + fs->f->linedefined, limit, what); + luaX_lexerror(fs->ls, msg, 0); +} + + +static int testnext (LexState *ls, int c) { + if (ls->t.token == c) { + luaX_next(ls); + return 1; + } + else return 0; +} + + +static void check (LexState *ls, int c) { + if (ls->t.token != c) + error_expected(ls, c); +} + +static void checknext (LexState *ls, int c) { + check(ls, c); + luaX_next(ls); +} + + +#define check_condition(ls,c,msg) { if (!(c)) luaX_syntaxerror(ls, msg); } + + + +static void check_match (LexState *ls, int what, int who, int where) { + if (!testnext(ls, what)) { + if (where == ls->linenumber) + error_expected(ls, what); + else { + luaX_syntaxerror(ls, luaO_pushfstring(ls->L, + LUA_QS " expected (to close " LUA_QS " at line %d)", + luaX_token2str(ls, what), luaX_token2str(ls, who), where)); + } + } +} + + +static TString *str_checkname (LexState *ls) { + TString *ts; + check(ls, TK_NAME); + ts = ls->t.seminfo.ts; + luaX_next(ls); + return ts; +} + + +static void init_exp (expdesc *e, expkind k, int i) { + e->f = e->t = NO_JUMP; + e->k = k; + e->u.s.info = i; +} + + +static void codestring (LexState *ls, expdesc *e, TString *s) { + init_exp(e, VK, luaK_stringK(ls->fs, s)); +} + + +static void checkname(LexState *ls, expdesc *e) { + codestring(ls, e, str_checkname(ls)); +} + + +static int registerlocalvar (LexState *ls, TString *varname) { + FuncState *fs = ls->fs; + Proto *f = fs->f; + int oldsize = f->sizelocvars; + luaM_growvector(ls->L, f->locvars, fs->nlocvars, f->sizelocvars, + LocVar, SHRT_MAX, "too many local variables"); + while (oldsize < f->sizelocvars) f->locvars[oldsize++].varname = NULL; + f->locvars[fs->nlocvars].varname = varname; + luaC_objbarrier(ls->L, f, varname); + return fs->nlocvars++; +} + + +#define new_localvarliteral(ls,v,n) \ + new_localvar(ls, luaX_newstring(ls, "" v, (sizeof(v)/sizeof(char))-1), n) + + +static void new_localvar (LexState *ls, TString *name, int n) { + FuncState *fs = ls->fs; + luaY_checklimit(fs, fs->nactvar+n+1, LUAI_MAXVARS, "local variables"); + fs->actvar[fs->nactvar+n] = cast(unsigned short, registerlocalvar(ls, name)); +} + + +static void adjustlocalvars (LexState *ls, int nvars) { + FuncState *fs = ls->fs; + fs->nactvar = cast_byte(fs->nactvar + nvars); + for (; nvars; nvars--) { + getlocvar(fs, fs->nactvar - nvars).startpc = fs->pc; + } +} + + +static void removevars (LexState *ls, int tolevel) { + FuncState *fs = ls->fs; + while (fs->nactvar > tolevel) + getlocvar(fs, --fs->nactvar).endpc = fs->pc; +} + + +static int indexupvalue (FuncState *fs, TString *name, expdesc *v) { + int i; + Proto *f = fs->f; + int oldsize = f->sizeupvalues; + for (i=0; inups; i++) { + if (fs->upvalues[i].k == v->k && fs->upvalues[i].info == v->u.s.info) { + lua_assert(f->upvalues[i] == name); + return i; + } + } + /* new one */ + luaY_checklimit(fs, f->nups + 1, LUAI_MAXUPVALUES, "upvalues"); + luaM_growvector(fs->L, f->upvalues, f->nups, f->sizeupvalues, + TString *, MAX_INT, ""); + while (oldsize < f->sizeupvalues) f->upvalues[oldsize++] = NULL; + f->upvalues[f->nups] = name; + luaC_objbarrier(fs->L, f, name); + lua_assert(v->k == VLOCAL || v->k == VUPVAL); + fs->upvalues[f->nups].k = cast_byte(v->k); + fs->upvalues[f->nups].info = cast_byte(v->u.s.info); + return f->nups++; +} + + +static int searchvar (FuncState *fs, TString *n) { + int i; + for (i=fs->nactvar-1; i >= 0; i--) { + if (n == getlocvar(fs, i).varname) + return i; + } + return -1; /* not found */ +} + + +static void markupval (FuncState *fs, int level) { + BlockCnt *bl = fs->bl; + while (bl && bl->nactvar > level) bl = bl->previous; + if (bl) bl->upval = 1; +} + + +static int singlevaraux (FuncState *fs, TString *n, expdesc *var, int base) { + if (fs == NULL) { /* no more levels? */ + init_exp(var, VGLOBAL, NO_REG); /* default is global variable */ + return VGLOBAL; + } + else { + int v = searchvar(fs, n); /* look up at current level */ + if (v >= 0) { + init_exp(var, VLOCAL, v); + if (!base) + markupval(fs, v); /* local will be used as an upval */ + return VLOCAL; + } + else { /* not found at current level; try upper one */ + if (singlevaraux(fs->prev, n, var, 0) == VGLOBAL) + return VGLOBAL; + var->u.s.info = indexupvalue(fs, n, var); /* else was LOCAL or UPVAL */ + var->k = VUPVAL; /* upvalue in this level */ + return VUPVAL; + } + } +} + + +static void singlevar (LexState *ls, expdesc *var) { + TString *varname = str_checkname(ls); + FuncState *fs = ls->fs; + if (singlevaraux(fs, varname, var, 1) == VGLOBAL) + var->u.s.info = luaK_stringK(fs, varname); /* info points to global name */ +} + + +static void adjust_assign (LexState *ls, int nvars, int nexps, expdesc *e) { + FuncState *fs = ls->fs; + int extra = nvars - nexps; + if (hasmultret(e->k)) { + extra++; /* includes call itself */ + if (extra < 0) extra = 0; + luaK_setreturns(fs, e, extra); /* last exp. provides the difference */ + if (extra > 1) luaK_reserveregs(fs, extra-1); + } + else { + if (e->k != VVOID) luaK_exp2nextreg(fs, e); /* close last expression */ + if (extra > 0) { + int reg = fs->freereg; + luaK_reserveregs(fs, extra); + luaK_nil(fs, reg, extra); + } + } +} + + +static void enterlevel (LexState *ls) { + if (++ls->L->nCcalls > LUAI_MAXCCALLS) + luaX_lexerror(ls, "chunk has too many syntax levels", 0); +} + + +#define leavelevel(ls) ((ls)->L->nCcalls--) + + +static void enterblock (FuncState *fs, BlockCnt *bl, lu_byte isbreakable) { + bl->breaklist = NO_JUMP; + bl->isbreakable = isbreakable; + bl->nactvar = fs->nactvar; + bl->upval = 0; + bl->previous = fs->bl; + fs->bl = bl; + lua_assert(fs->freereg == fs->nactvar); +} + + +static void leaveblock (FuncState *fs) { + BlockCnt *bl = fs->bl; + fs->bl = bl->previous; + removevars(fs->ls, bl->nactvar); + if (bl->upval) + luaK_codeABC(fs, OP_CLOSE, bl->nactvar, 0, 0); + /* a block either controls scope or breaks (never both) */ + lua_assert(!bl->isbreakable || !bl->upval); + lua_assert(bl->nactvar == fs->nactvar); + fs->freereg = fs->nactvar; /* free registers */ + luaK_patchtohere(fs, bl->breaklist); +} + + +static void pushclosure (LexState *ls, FuncState *func, expdesc *v) { + FuncState *fs = ls->fs; + Proto *f = fs->f; + int oldsize = f->sizep; + int i; + luaM_growvector(ls->L, f->p, fs->np, f->sizep, Proto *, + MAXARG_Bx, "constant table overflow"); + while (oldsize < f->sizep) f->p[oldsize++] = NULL; + f->p[fs->np++] = func->f; + luaC_objbarrier(ls->L, f, func->f); + init_exp(v, VRELOCABLE, luaK_codeABx(fs, OP_CLOSURE, 0, fs->np-1)); + for (i=0; if->nups; i++) { + OpCode o = (func->upvalues[i].k == VLOCAL) ? OP_MOVE : OP_GETUPVAL; + luaK_codeABC(fs, o, 0, func->upvalues[i].info, 0); + } +} + + +static void open_func (LexState *ls, FuncState *fs) { + lua_State *L = ls->L; + Proto *f = luaF_newproto(L); + fs->f = f; + fs->prev = ls->fs; /* linked list of funcstates */ + fs->ls = ls; + fs->L = L; + ls->fs = fs; + fs->pc = 0; + fs->lasttarget = -1; + fs->jpc = NO_JUMP; + fs->freereg = 0; + fs->nk = 0; + fs->np = 0; + fs->nlocvars = 0; + fs->nactvar = 0; + fs->bl = NULL; + f->source = ls->source; + f->maxstacksize = 2; /* registers 0/1 are always valid */ + fs->h = luaH_new(L, 0, 0); + /* anchor table of constants and prototype (to avoid being collected) */ + sethvalue2s(L, L->top, fs->h); + incr_top(L); + setptvalue2s(L, L->top, f); + incr_top(L); +} + + +static void close_func (LexState *ls) { + lua_State *L = ls->L; + FuncState *fs = ls->fs; + Proto *f = fs->f; + removevars(ls, 0); + luaK_ret(fs, 0, 0); /* final return */ + luaM_reallocvector(L, f->code, f->sizecode, fs->pc, Instruction); + f->sizecode = fs->pc; + luaM_reallocvector(L, f->lineinfo, f->sizelineinfo, fs->pc, int); + f->sizelineinfo = fs->pc; + luaM_reallocvector(L, f->k, f->sizek, fs->nk, TValue); + f->sizek = fs->nk; + luaM_reallocvector(L, f->p, f->sizep, fs->np, Proto *); + f->sizep = fs->np; + luaM_reallocvector(L, f->locvars, f->sizelocvars, fs->nlocvars, LocVar); + f->sizelocvars = fs->nlocvars; + luaM_reallocvector(L, f->upvalues, f->sizeupvalues, f->nups, TString *); + f->sizeupvalues = f->nups; + lua_assert(luaG_checkcode(f)); + lua_assert(fs->bl == NULL); + ls->fs = fs->prev; + L->top -= 2; /* remove table and prototype from the stack */ + /* last token read was anchored in defunct function; must reanchor it */ + if (fs) anchor_token(ls); +} + + +Proto *luaY_parser (lua_State *L, ZIO *z, Mbuffer *buff, const char *name) { + struct LexState lexstate; + struct FuncState funcstate; + lexstate.buff = buff; + luaX_setinput(L, &lexstate, z, luaS_new(L, name)); + open_func(&lexstate, &funcstate); + funcstate.f->is_vararg = VARARG_ISVARARG; /* main func. is always vararg */ + luaX_next(&lexstate); /* read first token */ + chunk(&lexstate); + check(&lexstate, TK_EOS); + close_func(&lexstate); + lua_assert(funcstate.prev == NULL); + lua_assert(funcstate.f->nups == 0); + lua_assert(lexstate.fs == NULL); + return funcstate.f; +} + + + +/*============================================================*/ +/* GRAMMAR RULES */ +/*============================================================*/ + + +static void field (LexState *ls, expdesc *v) { + /* field -> ['.' | ':'] NAME */ + FuncState *fs = ls->fs; + expdesc key; + luaK_exp2anyreg(fs, v); + luaX_next(ls); /* skip the dot or colon */ + checkname(ls, &key); + luaK_indexed(fs, v, &key); +} + + +static void yindex (LexState *ls, expdesc *v) { + /* index -> '[' expr ']' */ + luaX_next(ls); /* skip the '[' */ + expr(ls, v); + luaK_exp2val(ls->fs, v); + checknext(ls, ']'); +} + + +/* +** {====================================================================== +** Rules for Constructors +** ======================================================================= +*/ + + +struct ConsControl { + expdesc v; /* last list item read */ + expdesc *t; /* table descriptor */ + int nh; /* total number of `record' elements */ + int na; /* total number of array elements */ + int tostore; /* number of array elements pending to be stored */ +}; + + +static void recfield (LexState *ls, struct ConsControl *cc) { + /* recfield -> (NAME | `['exp1`]') = exp1 */ + FuncState *fs = ls->fs; + int reg = ls->fs->freereg; + expdesc key, val; + int rkkey; + if (ls->t.token == TK_NAME) { + luaY_checklimit(fs, cc->nh, MAX_INT, "items in a constructor"); + checkname(ls, &key); + } + else /* ls->t.token == '[' */ + yindex(ls, &key); + cc->nh++; + checknext(ls, '='); + rkkey = luaK_exp2RK(fs, &key); + expr(ls, &val); + luaK_codeABC(fs, OP_SETTABLE, cc->t->u.s.info, rkkey, luaK_exp2RK(fs, &val)); + fs->freereg = reg; /* free registers */ +} + + +static void closelistfield (FuncState *fs, struct ConsControl *cc) { + if (cc->v.k == VVOID) return; /* there is no list item */ + luaK_exp2nextreg(fs, &cc->v); + cc->v.k = VVOID; + if (cc->tostore == LFIELDS_PER_FLUSH) { + luaK_setlist(fs, cc->t->u.s.info, cc->na, cc->tostore); /* flush */ + cc->tostore = 0; /* no more items pending */ + } +} + + +static void lastlistfield (FuncState *fs, struct ConsControl *cc) { + if (cc->tostore == 0) return; + if (hasmultret(cc->v.k)) { + luaK_setmultret(fs, &cc->v); + luaK_setlist(fs, cc->t->u.s.info, cc->na, LUA_MULTRET); + cc->na--; /* do not count last expression (unknown number of elements) */ + } + else { + if (cc->v.k != VVOID) + luaK_exp2nextreg(fs, &cc->v); + luaK_setlist(fs, cc->t->u.s.info, cc->na, cc->tostore); + } +} + + +static void listfield (LexState *ls, struct ConsControl *cc) { + expr(ls, &cc->v); + luaY_checklimit(ls->fs, cc->na, MAX_INT, "items in a constructor"); + cc->na++; + cc->tostore++; +} + + +static void constructor (LexState *ls, expdesc *t) { + /* constructor -> ?? */ + FuncState *fs = ls->fs; + int line = ls->linenumber; + int pc = luaK_codeABC(fs, OP_NEWTABLE, 0, 0, 0); + struct ConsControl cc; + cc.na = cc.nh = cc.tostore = 0; + cc.t = t; + init_exp(t, VRELOCABLE, pc); + init_exp(&cc.v, VVOID, 0); /* no value (yet) */ + luaK_exp2nextreg(ls->fs, t); /* fix it at stack top (for gc) */ + checknext(ls, '{'); + do { + lua_assert(cc.v.k == VVOID || cc.tostore > 0); + if (ls->t.token == '}') break; + closelistfield(fs, &cc); + switch(ls->t.token) { + case TK_NAME: { /* may be listfields or recfields */ + luaX_lookahead(ls); + if (ls->lookahead.token != '=') /* expression? */ + listfield(ls, &cc); + else + recfield(ls, &cc); + break; + } + case '[': { /* constructor_item -> recfield */ + recfield(ls, &cc); + break; + } + default: { /* constructor_part -> listfield */ + listfield(ls, &cc); + break; + } + } + } while (testnext(ls, ',') || testnext(ls, ';')); + check_match(ls, '}', '{', line); + lastlistfield(fs, &cc); + SETARG_B(fs->f->code[pc], luaO_int2fb(cc.na)); /* set initial array size */ + SETARG_C(fs->f->code[pc], luaO_int2fb(cc.nh)); /* set initial table size */ +} + +/* }====================================================================== */ + + + +static void parlist (LexState *ls) { + /* parlist -> [ param { `,' param } ] */ + FuncState *fs = ls->fs; + Proto *f = fs->f; + int nparams = 0; + f->is_vararg = 0; + if (ls->t.token != ')') { /* is `parlist' not empty? */ + do { + switch (ls->t.token) { + case TK_NAME: { /* param -> NAME */ + new_localvar(ls, str_checkname(ls), nparams++); + break; + } + case TK_DOTS: { /* param -> `...' */ + luaX_next(ls); +#if defined(LUA_COMPAT_VARARG) + /* use `arg' as default name */ + new_localvarliteral(ls, "arg", nparams++); + f->is_vararg = VARARG_HASARG | VARARG_NEEDSARG; +#endif + f->is_vararg |= VARARG_ISVARARG; + break; + } + default: luaX_syntaxerror(ls, " or " LUA_QL("...") " expected"); + } + } while (!f->is_vararg && testnext(ls, ',')); + } + adjustlocalvars(ls, nparams); + f->numparams = cast_byte(fs->nactvar - (f->is_vararg & VARARG_HASARG)); + luaK_reserveregs(fs, fs->nactvar); /* reserve register for parameters */ +} + + +static void body (LexState *ls, expdesc *e, int needself, int line) { + /* body -> `(' parlist `)' chunk END */ + FuncState new_fs; + open_func(ls, &new_fs); + new_fs.f->linedefined = line; + checknext(ls, '('); + if (needself) { + new_localvarliteral(ls, "self", 0); + adjustlocalvars(ls, 1); + } + parlist(ls); + checknext(ls, ')'); + chunk(ls); + new_fs.f->lastlinedefined = ls->linenumber; + check_match(ls, TK_END, TK_FUNCTION, line); + close_func(ls); + pushclosure(ls, &new_fs, e); +} + + +static int explist1 (LexState *ls, expdesc *v) { + /* explist1 -> expr { `,' expr } */ + int n = 1; /* at least one expression */ + expr(ls, v); + while (testnext(ls, ',')) { + luaK_exp2nextreg(ls->fs, v); + expr(ls, v); + n++; + } + return n; +} + + +static void funcargs (LexState *ls, expdesc *f) { + FuncState *fs = ls->fs; + expdesc args; + int base, nparams; + int line = ls->linenumber; + switch (ls->t.token) { + case '(': { /* funcargs -> `(' [ explist1 ] `)' */ + if (line != ls->lastline) + luaX_syntaxerror(ls,"ambiguous syntax (function call x new statement)"); + luaX_next(ls); + if (ls->t.token == ')') /* arg list is empty? */ + args.k = VVOID; + else { + explist1(ls, &args); + luaK_setmultret(fs, &args); + } + check_match(ls, ')', '(', line); + break; + } + case '{': { /* funcargs -> constructor */ + constructor(ls, &args); + break; + } + case TK_STRING: { /* funcargs -> STRING */ + codestring(ls, &args, ls->t.seminfo.ts); + luaX_next(ls); /* must use `seminfo' before `next' */ + break; + } + default: { + luaX_syntaxerror(ls, "function arguments expected"); + return; + } + } + lua_assert(f->k == VNONRELOC); + base = f->u.s.info; /* base register for call */ + if (hasmultret(args.k)) + nparams = LUA_MULTRET; /* open call */ + else { + if (args.k != VVOID) + luaK_exp2nextreg(fs, &args); /* close last argument */ + nparams = fs->freereg - (base+1); + } + init_exp(f, VCALL, luaK_codeABC(fs, OP_CALL, base, nparams+1, 2)); + luaK_fixline(fs, line); + fs->freereg = base+1; /* call remove function and arguments and leaves + (unless changed) one result */ +} + + + + +/* +** {====================================================================== +** Expression parsing +** ======================================================================= +*/ + + +static void prefixexp (LexState *ls, expdesc *v) { + /* prefixexp -> NAME | '(' expr ')' */ + switch (ls->t.token) { + case '(': { + int line = ls->linenumber; + luaX_next(ls); + expr(ls, v); + check_match(ls, ')', '(', line); + luaK_dischargevars(ls->fs, v); + return; + } + case TK_NAME: { + singlevar(ls, v); + return; + } + default: { + luaX_syntaxerror(ls, "unexpected symbol"); + return; + } + } +} + + +static void primaryexp (LexState *ls, expdesc *v) { + /* primaryexp -> + prefixexp { `.' NAME | `[' exp `]' | `:' NAME funcargs | funcargs } */ + FuncState *fs = ls->fs; + prefixexp(ls, v); + for (;;) { + switch (ls->t.token) { + case '.': { /* field */ + field(ls, v); + break; + } + case '[': { /* `[' exp1 `]' */ + expdesc key; + luaK_exp2anyreg(fs, v); + yindex(ls, &key); + luaK_indexed(fs, v, &key); + break; + } + case ':': { /* `:' NAME funcargs */ + expdesc key; + luaX_next(ls); + checkname(ls, &key); + luaK_self(fs, v, &key); + funcargs(ls, v); + break; + } + case '(': case TK_STRING: case '{': { /* funcargs */ + luaK_exp2nextreg(fs, v); + funcargs(ls, v); + break; + } + default: return; + } + } +} + + +static void simpleexp (LexState *ls, expdesc *v) { + /* simpleexp -> NUMBER | STRING | NIL | true | false | ... | + constructor | FUNCTION body | primaryexp */ + switch (ls->t.token) { + case TK_NUMBER: { + init_exp(v, VKNUM, 0); + v->u.nval = ls->t.seminfo.r; + break; + } + case TK_STRING: { + codestring(ls, v, ls->t.seminfo.ts); + break; + } + case TK_NIL: { + init_exp(v, VNIL, 0); + break; + } + case TK_TRUE: { + init_exp(v, VTRUE, 0); + break; + } + case TK_FALSE: { + init_exp(v, VFALSE, 0); + break; + } + case TK_DOTS: { /* vararg */ + FuncState *fs = ls->fs; + check_condition(ls, fs->f->is_vararg, + "cannot use " LUA_QL("...") " outside a vararg function"); + fs->f->is_vararg &= ~VARARG_NEEDSARG; /* don't need 'arg' */ + init_exp(v, VVARARG, luaK_codeABC(fs, OP_VARARG, 0, 1, 0)); + break; + } + case '{': { /* constructor */ + constructor(ls, v); + return; + } + case TK_FUNCTION: { + luaX_next(ls); + body(ls, v, 0, ls->linenumber); + return; + } + default: { + primaryexp(ls, v); + return; + } + } + luaX_next(ls); +} + + +static UnOpr getunopr (int op) { + switch (op) { + case TK_NOT: return OPR_NOT; + case '-': return OPR_MINUS; + case '#': return OPR_LEN; + default: return OPR_NOUNOPR; + } +} + + +static BinOpr getbinopr (int op) { + switch (op) { + case '+': return OPR_ADD; + case '-': return OPR_SUB; + case '*': return OPR_MUL; + case '/': return OPR_DIV; + case '%': return OPR_MOD; + case '^': return OPR_POW; + case TK_CONCAT: return OPR_CONCAT; + case TK_NE: return OPR_NE; + case TK_EQ: return OPR_EQ; + case '<': return OPR_LT; + case TK_LE: return OPR_LE; + case '>': return OPR_GT; + case TK_GE: return OPR_GE; + case TK_AND: return OPR_AND; + case TK_OR: return OPR_OR; + default: return OPR_NOBINOPR; + } +} + + +static const struct { + lu_byte left; /* left priority for each binary operator */ + lu_byte right; /* right priority */ +} priority[] = { /* ORDER OPR */ + {6, 6}, {6, 6}, {7, 7}, {7, 7}, {7, 7}, /* `+' `-' `/' `%' */ + {10, 9}, {5, 4}, /* power and concat (right associative) */ + {3, 3}, {3, 3}, /* equality and inequality */ + {3, 3}, {3, 3}, {3, 3}, {3, 3}, /* order */ + {2, 2}, {1, 1} /* logical (and/or) */ +}; + +#define UNARY_PRIORITY 8 /* priority for unary operators */ + + +/* +** subexpr -> (simpleexp | unop subexpr) { binop subexpr } +** where `binop' is any binary operator with a priority higher than `limit' +*/ +static BinOpr subexpr (LexState *ls, expdesc *v, unsigned int limit) { + BinOpr op; + UnOpr uop; + enterlevel(ls); + uop = getunopr(ls->t.token); + if (uop != OPR_NOUNOPR) { + luaX_next(ls); + subexpr(ls, v, UNARY_PRIORITY); + luaK_prefix(ls->fs, uop, v); + } + else simpleexp(ls, v); + /* expand while operators have priorities higher than `limit' */ + op = getbinopr(ls->t.token); + while (op != OPR_NOBINOPR && priority[op].left > limit) { + expdesc v2; + BinOpr nextop; + luaX_next(ls); + luaK_infix(ls->fs, op, v); + /* read sub-expression with higher priority */ + nextop = subexpr(ls, &v2, priority[op].right); + luaK_posfix(ls->fs, op, v, &v2); + op = nextop; + } + leavelevel(ls); + return op; /* return first untreated operator */ +} + + +static void expr (LexState *ls, expdesc *v) { + subexpr(ls, v, 0); +} + +/* }==================================================================== */ + + + +/* +** {====================================================================== +** Rules for Statements +** ======================================================================= +*/ + + +static int block_follow (int token) { + switch (token) { + case TK_ELSE: case TK_ELSEIF: case TK_END: + case TK_UNTIL: case TK_EOS: + return 1; + default: return 0; + } +} + + +static void block (LexState *ls) { + /* block -> chunk */ + FuncState *fs = ls->fs; + BlockCnt bl; + enterblock(fs, &bl, 0); + chunk(ls); + lua_assert(bl.breaklist == NO_JUMP); + leaveblock(fs); +} + + +/* +** structure to chain all variables in the left-hand side of an +** assignment +*/ +struct LHS_assign { + struct LHS_assign *prev; + expdesc v; /* variable (global, local, upvalue, or indexed) */ +}; + + +/* +** check whether, in an assignment to a local variable, the local variable +** is needed in a previous assignment (to a table). If so, save original +** local value in a safe place and use this safe copy in the previous +** assignment. +*/ +static void check_conflict (LexState *ls, struct LHS_assign *lh, expdesc *v) { + FuncState *fs = ls->fs; + int extra = fs->freereg; /* eventual position to save local variable */ + int conflict = 0; + for (; lh; lh = lh->prev) { + if (lh->v.k == VINDEXED) { + if (lh->v.u.s.info == v->u.s.info) { /* conflict? */ + conflict = 1; + lh->v.u.s.info = extra; /* previous assignment will use safe copy */ + } + if (lh->v.u.s.aux == v->u.s.info) { /* conflict? */ + conflict = 1; + lh->v.u.s.aux = extra; /* previous assignment will use safe copy */ + } + } + } + if (conflict) { + luaK_codeABC(fs, OP_MOVE, fs->freereg, v->u.s.info, 0); /* make copy */ + luaK_reserveregs(fs, 1); + } +} + + +static void assignment (LexState *ls, struct LHS_assign *lh, int nvars) { + expdesc e; + check_condition(ls, VLOCAL <= lh->v.k && lh->v.k <= VINDEXED, + "syntax error"); + if (testnext(ls, ',')) { /* assignment -> `,' primaryexp assignment */ + struct LHS_assign nv; + nv.prev = lh; + primaryexp(ls, &nv.v); + if (nv.v.k == VLOCAL) + check_conflict(ls, lh, &nv.v); + luaY_checklimit(ls->fs, nvars, LUAI_MAXCCALLS - ls->L->nCcalls, + "variables in assignment"); + assignment(ls, &nv, nvars+1); + } + else { /* assignment -> `=' explist1 */ + int nexps; + checknext(ls, '='); + nexps = explist1(ls, &e); + if (nexps != nvars) { + adjust_assign(ls, nvars, nexps, &e); + if (nexps > nvars) + ls->fs->freereg -= nexps - nvars; /* remove extra values */ + } + else { + luaK_setoneret(ls->fs, &e); /* close last expression */ + luaK_storevar(ls->fs, &lh->v, &e); + return; /* avoid default */ + } + } + init_exp(&e, VNONRELOC, ls->fs->freereg-1); /* default assignment */ + luaK_storevar(ls->fs, &lh->v, &e); +} + + +static int cond (LexState *ls) { + /* cond -> exp */ + expdesc v; + expr(ls, &v); /* read condition */ + if (v.k == VNIL) v.k = VFALSE; /* `falses' are all equal here */ + luaK_goiftrue(ls->fs, &v); + return v.f; +} + + +static void breakstat (LexState *ls) { + FuncState *fs = ls->fs; + BlockCnt *bl = fs->bl; + int upval = 0; + while (bl && !bl->isbreakable) { + upval |= bl->upval; + bl = bl->previous; + } + if (!bl) + luaX_syntaxerror(ls, "no loop to break"); + if (upval) + luaK_codeABC(fs, OP_CLOSE, bl->nactvar, 0, 0); + luaK_concat(fs, &bl->breaklist, luaK_jump(fs)); +} + + +static void whilestat (LexState *ls, int line) { + /* whilestat -> WHILE cond DO block END */ + FuncState *fs = ls->fs; + int whileinit; + int condexit; + BlockCnt bl; + luaX_next(ls); /* skip WHILE */ + whileinit = luaK_getlabel(fs); + condexit = cond(ls); + enterblock(fs, &bl, 1); + checknext(ls, TK_DO); + block(ls); + luaK_patchlist(fs, luaK_jump(fs), whileinit); + check_match(ls, TK_END, TK_WHILE, line); + leaveblock(fs); + luaK_patchtohere(fs, condexit); /* false conditions finish the loop */ +} + + +static void repeatstat (LexState *ls, int line) { + /* repeatstat -> REPEAT block UNTIL cond */ + int condexit; + FuncState *fs = ls->fs; + int repeat_init = luaK_getlabel(fs); + BlockCnt bl1, bl2; + enterblock(fs, &bl1, 1); /* loop block */ + enterblock(fs, &bl2, 0); /* scope block */ + luaX_next(ls); /* skip REPEAT */ + chunk(ls); + check_match(ls, TK_UNTIL, TK_REPEAT, line); + condexit = cond(ls); /* read condition (inside scope block) */ + if (!bl2.upval) { /* no upvalues? */ + leaveblock(fs); /* finish scope */ + luaK_patchlist(ls->fs, condexit, repeat_init); /* close the loop */ + } + else { /* complete semantics when there are upvalues */ + breakstat(ls); /* if condition then break */ + luaK_patchtohere(ls->fs, condexit); /* else... */ + leaveblock(fs); /* finish scope... */ + luaK_patchlist(ls->fs, luaK_jump(fs), repeat_init); /* and repeat */ + } + leaveblock(fs); /* finish loop */ +} + + +static int exp1 (LexState *ls) { + expdesc e; + int k; + expr(ls, &e); + k = e.k; + luaK_exp2nextreg(ls->fs, &e); + return k; +} + + +static void forbody (LexState *ls, int base, int line, int nvars, int isnum) { + /* forbody -> DO block */ + BlockCnt bl; + FuncState *fs = ls->fs; + int prep, endfor; + adjustlocalvars(ls, 3); /* control variables */ + checknext(ls, TK_DO); + prep = isnum ? luaK_codeAsBx(fs, OP_FORPREP, base, NO_JUMP) : luaK_jump(fs); + enterblock(fs, &bl, 0); /* scope for declared variables */ + adjustlocalvars(ls, nvars); + luaK_reserveregs(fs, nvars); + block(ls); + leaveblock(fs); /* end of scope for declared variables */ + luaK_patchtohere(fs, prep); + endfor = (isnum) ? luaK_codeAsBx(fs, OP_FORLOOP, base, NO_JUMP) : + luaK_codeABC(fs, OP_TFORLOOP, base, 0, nvars); + luaK_fixline(fs, line); /* pretend that `OP_FOR' starts the loop */ + luaK_patchlist(fs, (isnum ? endfor : luaK_jump(fs)), prep + 1); +} + + +static void fornum (LexState *ls, TString *varname, int line) { + /* fornum -> NAME = exp1,exp1[,exp1] forbody */ + FuncState *fs = ls->fs; + int base = fs->freereg; + new_localvarliteral(ls, "(for index)", 0); + new_localvarliteral(ls, "(for limit)", 1); + new_localvarliteral(ls, "(for step)", 2); + new_localvar(ls, varname, 3); + checknext(ls, '='); + exp1(ls); /* initial value */ + checknext(ls, ','); + exp1(ls); /* limit */ + if (testnext(ls, ',')) + exp1(ls); /* optional step */ + else { /* default step = 1 */ + luaK_codeABx(fs, OP_LOADK, fs->freereg, luaK_numberK(fs, 1)); + luaK_reserveregs(fs, 1); + } + forbody(ls, base, line, 1, 1); +} + + +static void forlist (LexState *ls, TString *indexname) { + /* forlist -> NAME {,NAME} IN explist1 forbody */ + FuncState *fs = ls->fs; + expdesc e; + int nvars = 0; + int line; + int base = fs->freereg; + /* create control variables */ + new_localvarliteral(ls, "(for generator)", nvars++); + new_localvarliteral(ls, "(for state)", nvars++); + new_localvarliteral(ls, "(for control)", nvars++); + /* create declared variables */ + new_localvar(ls, indexname, nvars++); + while (testnext(ls, ',')) + new_localvar(ls, str_checkname(ls), nvars++); + checknext(ls, TK_IN); + line = ls->linenumber; + adjust_assign(ls, 3, explist1(ls, &e), &e); + luaK_checkstack(fs, 3); /* extra space to call generator */ + forbody(ls, base, line, nvars - 3, 0); +} + + +static void forstat (LexState *ls, int line) { + /* forstat -> FOR (fornum | forlist) END */ + FuncState *fs = ls->fs; + TString *varname; + BlockCnt bl; + enterblock(fs, &bl, 1); /* scope for loop and control variables */ + luaX_next(ls); /* skip `for' */ + varname = str_checkname(ls); /* first variable name */ + switch (ls->t.token) { + case '=': fornum(ls, varname, line); break; + case ',': case TK_IN: forlist(ls, varname); break; + default: luaX_syntaxerror(ls, LUA_QL("=") " or " LUA_QL("in") " expected"); + } + check_match(ls, TK_END, TK_FOR, line); + leaveblock(fs); /* loop scope (`break' jumps to this point) */ +} + + +static int test_then_block (LexState *ls) { + /* test_then_block -> [IF | ELSEIF] cond THEN block */ + int condexit; + luaX_next(ls); /* skip IF or ELSEIF */ + condexit = cond(ls); + checknext(ls, TK_THEN); + block(ls); /* `then' part */ + return condexit; +} + + +static void ifstat (LexState *ls, int line) { + /* ifstat -> IF cond THEN block {ELSEIF cond THEN block} [ELSE block] END */ + FuncState *fs = ls->fs; + int flist; + int escapelist = NO_JUMP; + flist = test_then_block(ls); /* IF cond THEN block */ + while (ls->t.token == TK_ELSEIF) { + luaK_concat(fs, &escapelist, luaK_jump(fs)); + luaK_patchtohere(fs, flist); + flist = test_then_block(ls); /* ELSEIF cond THEN block */ + } + if (ls->t.token == TK_ELSE) { + luaK_concat(fs, &escapelist, luaK_jump(fs)); + luaK_patchtohere(fs, flist); + luaX_next(ls); /* skip ELSE (after patch, for correct line info) */ + block(ls); /* `else' part */ + } + else + luaK_concat(fs, &escapelist, flist); + luaK_patchtohere(fs, escapelist); + check_match(ls, TK_END, TK_IF, line); +} + + +static void localfunc (LexState *ls) { + expdesc v, b; + FuncState *fs = ls->fs; + new_localvar(ls, str_checkname(ls), 0); + init_exp(&v, VLOCAL, fs->freereg); + luaK_reserveregs(fs, 1); + adjustlocalvars(ls, 1); + body(ls, &b, 0, ls->linenumber); + luaK_storevar(fs, &v, &b); + /* debug information will only see the variable after this point! */ + getlocvar(fs, fs->nactvar - 1).startpc = fs->pc; +} + + +static void localstat (LexState *ls) { + /* stat -> LOCAL NAME {`,' NAME} [`=' explist1] */ + int nvars = 0; + int nexps; + expdesc e; + do { + new_localvar(ls, str_checkname(ls), nvars++); + } while (testnext(ls, ',')); + if (testnext(ls, '=')) + nexps = explist1(ls, &e); + else { + e.k = VVOID; + nexps = 0; + } + adjust_assign(ls, nvars, nexps, &e); + adjustlocalvars(ls, nvars); +} + + +static int funcname (LexState *ls, expdesc *v) { + /* funcname -> NAME {field} [`:' NAME] */ + int needself = 0; + singlevar(ls, v); + while (ls->t.token == '.') + field(ls, v); + if (ls->t.token == ':') { + needself = 1; + field(ls, v); + } + return needself; +} + + +static void funcstat (LexState *ls, int line) { + /* funcstat -> FUNCTION funcname body */ + int needself; + expdesc v, b; + luaX_next(ls); /* skip FUNCTION */ + needself = funcname(ls, &v); + body(ls, &b, needself, line); + luaK_storevar(ls->fs, &v, &b); + luaK_fixline(ls->fs, line); /* definition `happens' in the first line */ +} + + +static void exprstat (LexState *ls) { + /* stat -> func | assignment */ + FuncState *fs = ls->fs; + struct LHS_assign v; + primaryexp(ls, &v.v); + if (v.v.k == VCALL) /* stat -> func */ + SETARG_C(getcode(fs, &v.v), 1); /* call statement uses no results */ + else { /* stat -> assignment */ + v.prev = NULL; + assignment(ls, &v, 1); + } +} + + +static void retstat (LexState *ls) { + /* stat -> RETURN explist */ + FuncState *fs = ls->fs; + expdesc e; + int first, nret; /* registers with returned values */ + luaX_next(ls); /* skip RETURN */ + if (block_follow(ls->t.token) || ls->t.token == ';') + first = nret = 0; /* return no values */ + else { + nret = explist1(ls, &e); /* optional return values */ + if (hasmultret(e.k)) { + luaK_setmultret(fs, &e); + if (e.k == VCALL && nret == 1) { /* tail call? */ + SET_OPCODE(getcode(fs,&e), OP_TAILCALL); + lua_assert(GETARG_A(getcode(fs,&e)) == fs->nactvar); + } + first = fs->nactvar; + nret = LUA_MULTRET; /* return all values */ + } + else { + if (nret == 1) /* only one single value? */ + first = luaK_exp2anyreg(fs, &e); + else { + luaK_exp2nextreg(fs, &e); /* values must go to the `stack' */ + first = fs->nactvar; /* return all `active' values */ + lua_assert(nret == fs->freereg - first); + } + } + } + luaK_ret(fs, first, nret); +} + + +static int statement (LexState *ls) { + int line = ls->linenumber; /* may be needed for error messages */ + switch (ls->t.token) { + case TK_IF: { /* stat -> ifstat */ + ifstat(ls, line); + return 0; + } + case TK_WHILE: { /* stat -> whilestat */ + whilestat(ls, line); + return 0; + } + case TK_DO: { /* stat -> DO block END */ + luaX_next(ls); /* skip DO */ + block(ls); + check_match(ls, TK_END, TK_DO, line); + return 0; + } + case TK_FOR: { /* stat -> forstat */ + forstat(ls, line); + return 0; + } + case TK_REPEAT: { /* stat -> repeatstat */ + repeatstat(ls, line); + return 0; + } + case TK_FUNCTION: { + funcstat(ls, line); /* stat -> funcstat */ + return 0; + } + case TK_LOCAL: { /* stat -> localstat */ + luaX_next(ls); /* skip LOCAL */ + if (testnext(ls, TK_FUNCTION)) /* local function? */ + localfunc(ls); + else + localstat(ls); + return 0; + } + case TK_RETURN: { /* stat -> retstat */ + retstat(ls); + return 1; /* must be last statement */ + } + case TK_BREAK: { /* stat -> breakstat */ + luaX_next(ls); /* skip BREAK */ + breakstat(ls); + return 1; /* must be last statement */ + } + default: { + exprstat(ls); + return 0; /* to avoid warnings */ + } + } +} + + +static void chunk (LexState *ls) { + /* chunk -> { stat [`;'] } */ + int islast = 0; + enterlevel(ls); + while (!islast && !block_follow(ls->t.token)) { + islast = statement(ls); + testnext(ls, ';'); + lua_assert(ls->fs->f->maxstacksize >= ls->fs->freereg && + ls->fs->freereg >= ls->fs->nactvar); + ls->fs->freereg = ls->fs->nactvar; /* free registers */ + } + leavelevel(ls); +} + +/* }====================================================================== */ diff --git a/mylua/lua/lparser.h b/mylua/lua/lparser.h new file mode 100644 index 0000000..18836af --- /dev/null +++ b/mylua/lua/lparser.h @@ -0,0 +1,82 @@ +/* +** $Id: lparser.h,v 1.57.1.1 2007/12/27 13:02:25 roberto Exp $ +** Lua Parser +** See Copyright Notice in lua.h +*/ + +#ifndef lparser_h +#define lparser_h + +#include "llimits.h" +#include "lobject.h" +#include "lzio.h" + + +/* +** Expression descriptor +*/ + +typedef enum { + VVOID, /* no value */ + VNIL, + VTRUE, + VFALSE, + VK, /* info = index of constant in `k' */ + VKNUM, /* nval = numerical value */ + VLOCAL, /* info = local register */ + VUPVAL, /* info = index of upvalue in `upvalues' */ + VGLOBAL, /* info = index of table; aux = index of global name in `k' */ + VINDEXED, /* info = table register; aux = index register (or `k') */ + VJMP, /* info = instruction pc */ + VRELOCABLE, /* info = instruction pc */ + VNONRELOC, /* info = result register */ + VCALL, /* info = instruction pc */ + VVARARG /* info = instruction pc */ +} expkind; + +typedef struct expdesc { + expkind k; + union { + struct { int info, aux; } s; + lua_Number nval; + } u; + int t; /* patch list of `exit when true' */ + int f; /* patch list of `exit when false' */ +} expdesc; + + +typedef struct upvaldesc { + lu_byte k; + lu_byte info; +} upvaldesc; + + +struct BlockCnt; /* defined in lparser.c */ + + +/* state needed to generate code for a given function */ +typedef struct FuncState { + Proto *f; /* current function header */ + Table *h; /* table to find (and reuse) elements in `k' */ + struct FuncState *prev; /* enclosing function */ + struct LexState *ls; /* lexical state */ + struct lua_State *L; /* copy of the Lua state */ + struct BlockCnt *bl; /* chain of current blocks */ + int pc; /* next position to code (equivalent to `ncode') */ + int lasttarget; /* `pc' of last `jump target' */ + int jpc; /* list of pending jumps to `pc' */ + int freereg; /* first free register */ + int nk; /* number of elements in `k' */ + int np; /* number of elements in `p' */ + short nlocvars; /* number of elements in `locvars' */ + lu_byte nactvar; /* number of active local variables */ + upvaldesc upvalues[LUAI_MAXUPVALUES]; /* upvalues */ + unsigned short actvar[LUAI_MAXVARS]; /* declared-variable stack */ +} FuncState; + + +LUAI_FUNC Proto *luaY_parser (lua_State *L, ZIO *z, Mbuffer *buff, + const char *name); + + +#endif diff --git a/mylua/lua/lstate.c b/mylua/lua/lstate.c new file mode 100644 index 0000000..4313b83 --- /dev/null +++ b/mylua/lua/lstate.c @@ -0,0 +1,214 @@ +/* +** $Id: lstate.c,v 2.36.1.2 2008/01/03 15:20:39 roberto Exp $ +** Global State +** See Copyright Notice in lua.h +*/ + + +#include + +#define lstate_c +#define LUA_CORE + +#include "lua.h" + +#include "ldebug.h" +#include "ldo.h" +#include "lfunc.h" +#include "lgc.h" +#include "llex.h" +#include "lmem.h" +#include "lstate.h" +#include "lstring.h" +#include "ltable.h" +#include "ltm.h" + + +#define state_size(x) (sizeof(x) + LUAI_EXTRASPACE) +#define fromstate(l) (cast(lu_byte *, (l)) - LUAI_EXTRASPACE) +#define tostate(l) (cast(lua_State *, cast(lu_byte *, l) + LUAI_EXTRASPACE)) + + +/* +** Main thread combines a thread state and the global state +*/ +typedef struct LG { + lua_State l; + global_State g; +} LG; + + + +static void stack_init (lua_State *L1, lua_State *L) { + /* initialize CallInfo array */ + L1->base_ci = luaM_newvector(L, BASIC_CI_SIZE, CallInfo); + L1->ci = L1->base_ci; + L1->size_ci = BASIC_CI_SIZE; + L1->end_ci = L1->base_ci + L1->size_ci - 1; + /* initialize stack array */ + L1->stack = luaM_newvector(L, BASIC_STACK_SIZE + EXTRA_STACK, TValue); + L1->stacksize = BASIC_STACK_SIZE + EXTRA_STACK; + L1->top = L1->stack; + L1->stack_last = L1->stack+(L1->stacksize - EXTRA_STACK)-1; + /* initialize first ci */ + L1->ci->func = L1->top; + setnilvalue(L1->top++); /* `function' entry for this `ci' */ + L1->base = L1->ci->base = L1->top; + L1->ci->top = L1->top + LUA_MINSTACK; +} + + +static void freestack (lua_State *L, lua_State *L1) { + luaM_freearray(L, L1->base_ci, L1->size_ci, CallInfo); + luaM_freearray(L, L1->stack, L1->stacksize, TValue); +} + + +/* +** open parts that may cause memory-allocation errors +*/ +static void f_luaopen (lua_State *L, void *ud) { + global_State *g = G(L); + UNUSED(ud); + stack_init(L, L); /* init stack */ + sethvalue(L, gt(L), luaH_new(L, 0, 2)); /* table of globals */ + sethvalue(L, registry(L), luaH_new(L, 0, 2)); /* registry */ + luaS_resize(L, MINSTRTABSIZE); /* initial size of string table */ + luaT_init(L); + luaX_init(L); + luaS_fix(luaS_newliteral(L, MEMERRMSG)); + g->GCthreshold = 4*g->totalbytes; +} + + +static void preinit_state (lua_State *L, global_State *g) { + G(L) = g; + L->stack = NULL; + L->stacksize = 0; + L->errorJmp = NULL; + L->hook = NULL; + L->hookmask = 0; + L->basehookcount = 0; + L->allowhook = 1; + resethookcount(L); + L->openupval = NULL; + L->size_ci = 0; + L->nCcalls = L->baseCcalls = 0; + L->status = 0; + L->base_ci = L->ci = NULL; + L->savedpc = NULL; + L->errfunc = 0; + setnilvalue(gt(L)); +} + + +static void close_state (lua_State *L) { + global_State *g = G(L); + luaF_close(L, L->stack); /* close all upvalues for this thread */ + luaC_freeall(L); /* collect all objects */ + lua_assert(g->rootgc == obj2gco(L)); + lua_assert(g->strt.nuse == 0); + luaM_freearray(L, G(L)->strt.hash, G(L)->strt.size, TString *); + luaZ_freebuffer(L, &g->buff); + freestack(L, L); + lua_assert(g->totalbytes == sizeof(LG)); + (*g->frealloc)(g->ud, fromstate(L), state_size(LG), 0); +} + + +lua_State *luaE_newthread (lua_State *L) { + lua_State *L1 = tostate(luaM_malloc(L, state_size(lua_State))); + luaC_link(L, obj2gco(L1), LUA_TTHREAD); + preinit_state(L1, G(L)); + stack_init(L1, L); /* init stack */ + setobj2n(L, gt(L1), gt(L)); /* share table of globals */ + L1->hookmask = L->hookmask; + L1->basehookcount = L->basehookcount; + L1->hook = L->hook; + resethookcount(L1); + lua_assert(iswhite(obj2gco(L1))); + return L1; +} + + +void luaE_freethread (lua_State *L, lua_State *L1) { + luaF_close(L1, L1->stack); /* close all upvalues for this thread */ + lua_assert(L1->openupval == NULL); + luai_userstatefree(L1); + freestack(L, L1); + luaM_freemem(L, fromstate(L1), state_size(lua_State)); +} + + +LUA_API lua_State *lua_newstate (lua_Alloc f, void *ud) { + int i; + lua_State *L; + global_State *g; + void *l = (*f)(ud, NULL, 0, state_size(LG)); + if (l == NULL) return NULL; + L = tostate(l); + g = &((LG *)L)->g; + L->next = NULL; + L->tt = LUA_TTHREAD; + g->currentwhite = bit2mask(WHITE0BIT, FIXEDBIT); + L->marked = luaC_white(g); + set2bits(L->marked, FIXEDBIT, SFIXEDBIT); + preinit_state(L, g); + g->frealloc = f; + g->ud = ud; + g->mainthread = L; + g->uvhead.u.l.prev = &g->uvhead; + g->uvhead.u.l.next = &g->uvhead; + g->GCthreshold = 0; /* mark it as unfinished state */ + g->strt.size = 0; + g->strt.nuse = 0; + g->strt.hash = NULL; + setnilvalue(registry(L)); + luaZ_initbuffer(L, &g->buff); + g->panic = NULL; + g->gcstate = GCSpause; + g->rootgc = obj2gco(L); + g->sweepstrgc = 0; + g->sweepgc = &g->rootgc; + g->gray = NULL; + g->grayagain = NULL; + g->weak = NULL; + g->tmudata = NULL; + g->totalbytes = sizeof(LG); + g->gcpause = LUAI_GCPAUSE; + g->gcstepmul = LUAI_GCMUL; + g->gcdept = 0; + for (i=0; imt[i] = NULL; + if (luaD_rawrunprotected(L, f_luaopen, NULL) != 0) { + /* memory allocation error: free partial state */ + close_state(L); + L = NULL; + } + else + luai_userstateopen(L); + return L; +} + + +static void callallgcTM (lua_State *L, void *ud) { + UNUSED(ud); + luaC_callGCTM(L); /* call GC metamethods for all udata */ +} + + +LUA_API void lua_close (lua_State *L) { + L = G(L)->mainthread; /* only the main thread can be closed */ + lua_lock(L); + luaF_close(L, L->stack); /* close all upvalues for this thread */ + luaC_separateudata(L, 1); /* separate udata that have GC metamethods */ + L->errfunc = 0; /* no error function during GC metamethods */ + do { /* repeat until no more errors */ + L->ci = L->base_ci; + L->base = L->top = L->ci->base; + L->nCcalls = L->baseCcalls = 0; + } while (luaD_rawrunprotected(L, callallgcTM, NULL) != 0); + lua_assert(G(L)->tmudata == NULL); + luai_userstateclose(L); + close_state(L); +} + diff --git a/mylua/lua/lstate.h b/mylua/lua/lstate.h new file mode 100644 index 0000000..3bc575b --- /dev/null +++ b/mylua/lua/lstate.h @@ -0,0 +1,169 @@ +/* +** $Id: lstate.h,v 2.24.1.2 2008/01/03 15:20:39 roberto Exp $ +** Global State +** See Copyright Notice in lua.h +*/ + +#ifndef lstate_h +#define lstate_h + +#include "lua.h" + +#include "lobject.h" +#include "ltm.h" +#include "lzio.h" + + + +struct lua_longjmp; /* defined in ldo.c */ + + +/* table of globals */ +#define gt(L) (&L->l_gt) + +/* registry */ +#define registry(L) (&G(L)->l_registry) + + +/* extra stack space to handle TM calls and some other extras */ +#define EXTRA_STACK 5 + + +#define BASIC_CI_SIZE 8 + +#define BASIC_STACK_SIZE (2*LUA_MINSTACK) + + + +typedef struct stringtable { + GCObject **hash; + lu_int32 nuse; /* number of elements */ + int size; +} stringtable; + + +/* +** informations about a call +*/ +typedef struct CallInfo { + StkId base; /* base for this function */ + StkId func; /* function index in the stack */ + StkId top; /* top for this function */ + const Instruction *savedpc; + int nresults; /* expected number of results from this function */ + int tailcalls; /* number of tail calls lost under this entry */ +} CallInfo; + + + +#define curr_func(L) (clvalue(L->ci->func)) +#define ci_func(ci) (clvalue((ci)->func)) +#define f_isLua(ci) (!ci_func(ci)->c.isC) +#define isLua(ci) (ttisfunction((ci)->func) && f_isLua(ci)) + + +/* +** `global state', shared by all threads of this state +*/ +typedef struct global_State { + stringtable strt; /* hash table for strings */ + lua_Alloc frealloc; /* function to reallocate memory */ + void *ud; /* auxiliary data to `frealloc' */ + lu_byte currentwhite; + lu_byte gcstate; /* state of garbage collector */ + int sweepstrgc; /* position of sweep in `strt' */ + GCObject *rootgc; /* list of all collectable objects */ + GCObject **sweepgc; /* position of sweep in `rootgc' */ + GCObject *gray; /* list of gray objects */ + GCObject *grayagain; /* list of objects to be traversed atomically */ + GCObject *weak; /* list of weak tables (to be cleared) */ + GCObject *tmudata; /* last element of list of userdata to be GC */ + Mbuffer buff; /* temporary buffer for string concatentation */ + lu_mem GCthreshold; + lu_mem totalbytes; /* number of bytes currently allocated */ + lu_mem estimate; /* an estimate of number of bytes actually in use */ + lu_mem gcdept; /* how much GC is `behind schedule' */ + int gcpause; /* size of pause between successive GCs */ + int gcstepmul; /* GC `granularity' */ + lua_CFunction panic; /* to be called in unprotected errors */ + TValue l_registry; + struct lua_State *mainthread; + UpVal uvhead; /* head of double-linked list of all open upvalues */ + struct Table *mt[NUM_TAGS]; /* metatables for basic types */ + TString *tmname[TM_N]; /* array with tag-method names */ +} global_State; + + +/* +** `per thread' state +*/ +struct lua_State { + CommonHeader; + lu_byte status; + StkId top; /* first free slot in the stack */ + StkId base; /* base of current function */ + global_State *l_G; + CallInfo *ci; /* call info for current function */ + const Instruction *savedpc; /* `savedpc' of current function */ + StkId stack_last; /* last free slot in the stack */ + StkId stack; /* stack base */ + CallInfo *end_ci; /* points after end of ci array*/ + CallInfo *base_ci; /* array of CallInfo's */ + int stacksize; + int size_ci; /* size of array `base_ci' */ + unsigned short nCcalls; /* number of nested C calls */ + unsigned short baseCcalls; /* nested C calls when resuming coroutine */ + lu_byte hookmask; + lu_byte allowhook; + int basehookcount; + int hookcount; + lua_Hook hook; + TValue l_gt; /* table of globals */ + TValue env; /* temporary place for environments */ + GCObject *openupval; /* list of open upvalues in this stack */ + GCObject *gclist; + struct lua_longjmp *errorJmp; /* current error recover point */ + ptrdiff_t errfunc; /* current error handling function (stack index) */ +}; + + +#define G(L) (L->l_G) + + +/* +** Union of all collectable objects +*/ +union GCObject { + GCheader gch; + union TString ts; + union Udata u; + union Closure cl; + struct Table h; + struct Proto p; + struct UpVal uv; + struct lua_State th; /* thread */ +}; + + +/* macros to convert a GCObject into a specific value */ +#define rawgco2ts(o) check_exp((o)->gch.tt == LUA_TSTRING, &((o)->ts)) +#define gco2ts(o) (&rawgco2ts(o)->tsv) +#define rawgco2u(o) check_exp((o)->gch.tt == LUA_TUSERDATA, &((o)->u)) +#define gco2u(o) (&rawgco2u(o)->uv) +#define gco2cl(o) check_exp((o)->gch.tt == LUA_TFUNCTION, &((o)->cl)) +#define gco2h(o) check_exp((o)->gch.tt == LUA_TTABLE, &((o)->h)) +#define gco2p(o) check_exp((o)->gch.tt == LUA_TPROTO, &((o)->p)) +#define gco2uv(o) check_exp((o)->gch.tt == LUA_TUPVAL, &((o)->uv)) +#define ngcotouv(o) \ + check_exp((o) == NULL || (o)->gch.tt == LUA_TUPVAL, &((o)->uv)) +#define gco2th(o) check_exp((o)->gch.tt == LUA_TTHREAD, &((o)->th)) + +/* macro to convert any Lua object into a GCObject */ +#define obj2gco(v) (cast(GCObject *, (v))) + + +LUAI_FUNC lua_State *luaE_newthread (lua_State *L); +LUAI_FUNC void luaE_freethread (lua_State *L, lua_State *L1); + +#endif + diff --git a/mylua/lua/lstring.c b/mylua/lua/lstring.c new file mode 100644 index 0000000..4911315 --- /dev/null +++ b/mylua/lua/lstring.c @@ -0,0 +1,111 @@ +/* +** $Id: lstring.c,v 2.8.1.1 2007/12/27 13:02:25 roberto Exp $ +** String table (keeps all strings handled by Lua) +** See Copyright Notice in lua.h +*/ + + +#include + +#define lstring_c +#define LUA_CORE + +#include "lua.h" + +#include "lmem.h" +#include "lobject.h" +#include "lstate.h" +#include "lstring.h" + + + +void luaS_resize (lua_State *L, int newsize) { + GCObject **newhash; + stringtable *tb; + int i; + if (G(L)->gcstate == GCSsweepstring) + return; /* cannot resize during GC traverse */ + newhash = luaM_newvector(L, newsize, GCObject *); + tb = &G(L)->strt; + for (i=0; isize; i++) { + GCObject *p = tb->hash[i]; + while (p) { /* for each node in the list */ + GCObject *next = p->gch.next; /* save next */ + unsigned int h = gco2ts(p)->hash; + int h1 = lmod(h, newsize); /* new position */ + lua_assert(cast_int(h%newsize) == lmod(h, newsize)); + p->gch.next = newhash[h1]; /* chain it */ + newhash[h1] = p; + p = next; + } + } + luaM_freearray(L, tb->hash, tb->size, TString *); + tb->size = newsize; + tb->hash = newhash; +} + + +static TString *newlstr (lua_State *L, const char *str, size_t l, + unsigned int h) { + TString *ts; + stringtable *tb; + if (l+1 > (MAX_SIZET - sizeof(TString))/sizeof(char)) + luaM_toobig(L); + ts = cast(TString *, luaM_malloc(L, (l+1)*sizeof(char)+sizeof(TString))); + ts->tsv.len = l; + ts->tsv.hash = h; + ts->tsv.marked = luaC_white(G(L)); + ts->tsv.tt = LUA_TSTRING; + ts->tsv.reserved = 0; + memcpy(ts+1, str, l*sizeof(char)); + ((char *)(ts+1))[l] = '\0'; /* ending 0 */ + tb = &G(L)->strt; + h = lmod(h, tb->size); + ts->tsv.next = tb->hash[h]; /* chain new entry */ + tb->hash[h] = obj2gco(ts); + tb->nuse++; + if (tb->nuse > cast(lu_int32, tb->size) && tb->size <= MAX_INT/2) + luaS_resize(L, tb->size*2); /* too crowded */ + return ts; +} + + +TString *luaS_newlstr (lua_State *L, const char *str, size_t l) { + GCObject *o; + unsigned int h = cast(unsigned int, l); /* seed */ + size_t step = (l>>5)+1; /* if string is too long, don't hash all its chars */ + size_t l1; + for (l1=l; l1>=step; l1-=step) /* compute hash */ + h = h ^ ((h<<5)+(h>>2)+cast(unsigned char, str[l1-1])); + for (o = G(L)->strt.hash[lmod(h, G(L)->strt.size)]; + o != NULL; + o = o->gch.next) { + TString *ts = rawgco2ts(o); + if (ts->tsv.len == l && (memcmp(str, getstr(ts), l) == 0)) { + /* string may be dead */ + if (isdead(G(L), o)) changewhite(o); + return ts; + } + } + return newlstr(L, str, l, h); /* not found */ +} + + +Udata *luaS_newudata (lua_State *L, size_t s, Table *e) { + Udata *u; + if (s > MAX_SIZET - sizeof(Udata)) + luaM_toobig(L); + u = cast(Udata *, luaM_malloc(L, s + sizeof(Udata))); + u->uv.marked = luaC_white(G(L)); /* is not finalized */ + u->uv.tt = LUA_TUSERDATA; + u->uv.len = s; + u->uv.metatable = NULL; + u->uv.env = e; + /* chain it on udata list (after main thread) */ + u->uv.next = G(L)->mainthread->next; + G(L)->mainthread->next = obj2gco(u); + return u; +} + diff --git a/mylua/lua/lstring.h b/mylua/lua/lstring.h new file mode 100644 index 0000000..73a2ff8 --- /dev/null +++ b/mylua/lua/lstring.h @@ -0,0 +1,31 @@ +/* +** $Id: lstring.h,v 1.43.1.1 2007/12/27 13:02:25 roberto Exp $ +** String table (keep all strings handled by Lua) +** See Copyright Notice in lua.h +*/ + +#ifndef lstring_h +#define lstring_h + + +#include "lgc.h" +#include "lobject.h" +#include "lstate.h" + + +#define sizestring(s) (sizeof(union TString)+((s)->len+1)*sizeof(char)) + +#define sizeudata(u) (sizeof(union Udata)+(u)->len) + +#define luaS_new(L, s) (luaS_newlstr(L, s, strlen(s))) +#define luaS_newliteral(L, s) (luaS_newlstr(L, "" s, \ + (sizeof(s)/sizeof(char))-1)) + +#define luaS_fix(s) l_setbit((s)->tsv.marked, FIXEDBIT) + +LUAI_FUNC void luaS_resize (lua_State *L, int newsize); +LUAI_FUNC Udata *luaS_newudata (lua_State *L, size_t s, Table *e); +LUAI_FUNC TString *luaS_newlstr (lua_State *L, const char *str, size_t l); + + +#endif diff --git a/mylua/lua/lstrlib.c b/mylua/lua/lstrlib.c new file mode 100644 index 0000000..1b4763d --- /dev/null +++ b/mylua/lua/lstrlib.c @@ -0,0 +1,869 @@ +/* +** $Id: lstrlib.c,v 1.132.1.4 2008/07/11 17:27:21 roberto Exp $ +** Standard library for string operations and pattern-matching +** See Copyright Notice in lua.h +*/ + + +#include +#include +#include +#include +#include + +#define lstrlib_c +#define LUA_LIB + +#include "lua.h" + +#include "lauxlib.h" +#include "lualib.h" + + +/* macro to `unsign' a character */ +#define uchar(c) ((unsigned char)(c)) + + + +static int str_len (lua_State *L) { + size_t l; + luaL_checklstring(L, 1, &l); + lua_pushinteger(L, l); + return 1; +} + + +static ptrdiff_t posrelat (ptrdiff_t pos, size_t len) { + /* relative string position: negative means back from end */ + if (pos < 0) pos += (ptrdiff_t)len + 1; + return (pos >= 0) ? pos : 0; +} + + +static int str_sub (lua_State *L) { + size_t l; + const char *s = luaL_checklstring(L, 1, &l); + ptrdiff_t start = posrelat(luaL_checkinteger(L, 2), l); + ptrdiff_t end = posrelat(luaL_optinteger(L, 3, -1), l); + if (start < 1) start = 1; + if (end > (ptrdiff_t)l) end = (ptrdiff_t)l; + if (start <= end) + lua_pushlstring(L, s+start-1, end-start+1); + else lua_pushliteral(L, ""); + return 1; +} + + +static int str_reverse (lua_State *L) { + size_t l; + luaL_Buffer b; + const char *s = luaL_checklstring(L, 1, &l); + luaL_buffinit(L, &b); + while (l--) luaL_addchar(&b, s[l]); + luaL_pushresult(&b); + return 1; +} + + +static int str_lower (lua_State *L) { + size_t l; + size_t i; + luaL_Buffer b; + const char *s = luaL_checklstring(L, 1, &l); + luaL_buffinit(L, &b); + for (i=0; i 0) + luaL_addlstring(&b, s, l); + luaL_pushresult(&b); + return 1; +} + + +static int str_byte (lua_State *L) { + size_t l; + const char *s = luaL_checklstring(L, 1, &l); + ptrdiff_t posi = posrelat(luaL_optinteger(L, 2, 1), l); + ptrdiff_t pose = posrelat(luaL_optinteger(L, 3, posi), l); + int n, i; + if (posi <= 0) posi = 1; + if ((size_t)pose > l) pose = l; + if (posi > pose) return 0; /* empty interval; return no values */ + n = (int)(pose - posi + 1); + if (posi + n <= pose) /* overflow? */ + luaL_error(L, "string slice too long"); + luaL_checkstack(L, n, "string slice too long"); + for (i=0; i= ms->level || ms->capture[l].len == CAP_UNFINISHED) + return luaL_error(ms->L, "invalid capture index"); + return l; +} + + +static int capture_to_close (MatchState *ms) { + int level = ms->level; + for (level--; level>=0; level--) + if (ms->capture[level].len == CAP_UNFINISHED) return level; + return luaL_error(ms->L, "invalid pattern capture"); +} + + +static const char *classend (MatchState *ms, const char *p) { + switch (*p++) { + case L_ESC: { + if (*p == '\0') + luaL_error(ms->L, "malformed pattern (ends with " LUA_QL("%%") ")"); + return p+1; + } + case '[': { + if (*p == '^') p++; + do { /* look for a `]' */ + if (*p == '\0') + luaL_error(ms->L, "malformed pattern (missing " LUA_QL("]") ")"); + if (*(p++) == L_ESC && *p != '\0') + p++; /* skip escapes (e.g. `%]') */ + } while (*p != ']'); + return p+1; + } + default: { + return p; + } + } +} + + +static int match_class (int c, int cl) { + int res; + switch (tolower(cl)) { + case 'a' : res = isalpha(c); break; + case 'c' : res = iscntrl(c); break; + case 'd' : res = isdigit(c); break; + case 'l' : res = islower(c); break; + case 'p' : res = ispunct(c); break; + case 's' : res = isspace(c); break; + case 'u' : res = isupper(c); break; + case 'w' : res = isalnum(c); break; + case 'x' : res = isxdigit(c); break; + case 'z' : res = (c == 0); break; + default: return (cl == c); + } + return (islower(cl) ? res : !res); +} + + +static int matchbracketclass (int c, const char *p, const char *ec) { + int sig = 1; + if (*(p+1) == '^') { + sig = 0; + p++; /* skip the `^' */ + } + while (++p < ec) { + if (*p == L_ESC) { + p++; + if (match_class(c, uchar(*p))) + return sig; + } + else if ((*(p+1) == '-') && (p+2 < ec)) { + p+=2; + if (uchar(*(p-2)) <= c && c <= uchar(*p)) + return sig; + } + else if (uchar(*p) == c) return sig; + } + return !sig; +} + + +static int singlematch (int c, const char *p, const char *ep) { + switch (*p) { + case '.': return 1; /* matches any char */ + case L_ESC: return match_class(c, uchar(*(p+1))); + case '[': return matchbracketclass(c, p, ep-1); + default: return (uchar(*p) == c); + } +} + + +static const char *match (MatchState *ms, const char *s, const char *p); + + +static const char *matchbalance (MatchState *ms, const char *s, + const char *p) { + if (*p == 0 || *(p+1) == 0) + luaL_error(ms->L, "unbalanced pattern"); + if (*s != *p) return NULL; + else { + int b = *p; + int e = *(p+1); + int cont = 1; + while (++s < ms->src_end) { + if (*s == e) { + if (--cont == 0) return s+1; + } + else if (*s == b) cont++; + } + } + return NULL; /* string ends out of balance */ +} + + +static const char *max_expand (MatchState *ms, const char *s, + const char *p, const char *ep) { + ptrdiff_t i = 0; /* counts maximum expand for item */ + while ((s+i)src_end && singlematch(uchar(*(s+i)), p, ep)) + i++; + /* keeps trying to match with the maximum repetitions */ + while (i>=0) { + const char *res = match(ms, (s+i), ep+1); + if (res) return res; + i--; /* else didn't match; reduce 1 repetition to try again */ + } + return NULL; +} + + +static const char *min_expand (MatchState *ms, const char *s, + const char *p, const char *ep) { + for (;;) { + const char *res = match(ms, s, ep+1); + if (res != NULL) + return res; + else if (ssrc_end && singlematch(uchar(*s), p, ep)) + s++; /* try with one more repetition */ + else return NULL; + } +} + + +static const char *start_capture (MatchState *ms, const char *s, + const char *p, int what) { + const char *res; + int level = ms->level; + if (level >= LUA_MAXCAPTURES) luaL_error(ms->L, "too many captures"); + ms->capture[level].init = s; + ms->capture[level].len = what; + ms->level = level+1; + if ((res=match(ms, s, p)) == NULL) /* match failed? */ + ms->level--; /* undo capture */ + return res; +} + + +static const char *end_capture (MatchState *ms, const char *s, + const char *p) { + int l = capture_to_close(ms); + const char *res; + ms->capture[l].len = s - ms->capture[l].init; /* close capture */ + if ((res = match(ms, s, p)) == NULL) /* match failed? */ + ms->capture[l].len = CAP_UNFINISHED; /* undo capture */ + return res; +} + + +static const char *match_capture (MatchState *ms, const char *s, int l) { + size_t len; + l = check_capture(ms, l); + len = ms->capture[l].len; + if ((size_t)(ms->src_end-s) >= len && + memcmp(ms->capture[l].init, s, len) == 0) + return s+len; + else return NULL; +} + + +static const char *match (MatchState *ms, const char *s, const char *p) { + init: /* using goto's to optimize tail recursion */ + switch (*p) { + case '(': { /* start capture */ + if (*(p+1) == ')') /* position capture? */ + return start_capture(ms, s, p+2, CAP_POSITION); + else + return start_capture(ms, s, p+1, CAP_UNFINISHED); + } + case ')': { /* end capture */ + return end_capture(ms, s, p+1); + } + case L_ESC: { + switch (*(p+1)) { + case 'b': { /* balanced string? */ + s = matchbalance(ms, s, p+2); + if (s == NULL) return NULL; + p+=4; goto init; /* else return match(ms, s, p+4); */ + } + case 'f': { /* frontier? */ + const char *ep; char previous; + p += 2; + if (*p != '[') + luaL_error(ms->L, "missing " LUA_QL("[") " after " + LUA_QL("%%f") " in pattern"); + ep = classend(ms, p); /* points to what is next */ + previous = (s == ms->src_init) ? '\0' : *(s-1); + if (matchbracketclass(uchar(previous), p, ep-1) || + !matchbracketclass(uchar(*s), p, ep-1)) return NULL; + p=ep; goto init; /* else return match(ms, s, ep); */ + } + default: { + if (isdigit(uchar(*(p+1)))) { /* capture results (%0-%9)? */ + s = match_capture(ms, s, uchar(*(p+1))); + if (s == NULL) return NULL; + p+=2; goto init; /* else return match(ms, s, p+2) */ + } + goto dflt; /* case default */ + } + } + } + case '\0': { /* end of pattern */ + return s; /* match succeeded */ + } + case '$': { + if (*(p+1) == '\0') /* is the `$' the last char in pattern? */ + return (s == ms->src_end) ? s : NULL; /* check end of string */ + else goto dflt; + } + default: dflt: { /* it is a pattern item */ + const char *ep = classend(ms, p); /* points to what is next */ + int m = ssrc_end && singlematch(uchar(*s), p, ep); + switch (*ep) { + case '?': { /* optional */ + const char *res; + if (m && ((res=match(ms, s+1, ep+1)) != NULL)) + return res; + p=ep+1; goto init; /* else return match(ms, s, ep+1); */ + } + case '*': { /* 0 or more repetitions */ + return max_expand(ms, s, p, ep); + } + case '+': { /* 1 or more repetitions */ + return (m ? max_expand(ms, s+1, p, ep) : NULL); + } + case '-': { /* 0 or more repetitions (minimum) */ + return min_expand(ms, s, p, ep); + } + default: { + if (!m) return NULL; + s++; p=ep; goto init; /* else return match(ms, s+1, ep); */ + } + } + } + } +} + + + +static const char *lmemfind (const char *s1, size_t l1, + const char *s2, size_t l2) { + if (l2 == 0) return s1; /* empty strings are everywhere */ + else if (l2 > l1) return NULL; /* avoids a negative `l1' */ + else { + const char *init; /* to search for a `*s2' inside `s1' */ + l2--; /* 1st char will be checked by `memchr' */ + l1 = l1-l2; /* `s2' cannot be found after that */ + while (l1 > 0 && (init = (const char *)memchr(s1, *s2, l1)) != NULL) { + init++; /* 1st char is already checked */ + if (memcmp(init, s2+1, l2) == 0) + return init-1; + else { /* correct `l1' and `s1' to try again */ + l1 -= init-s1; + s1 = init; + } + } + return NULL; /* not found */ + } +} + + +static void push_onecapture (MatchState *ms, int i, const char *s, + const char *e) { + if (i >= ms->level) { + if (i == 0) /* ms->level == 0, too */ + lua_pushlstring(ms->L, s, e - s); /* add whole match */ + else + luaL_error(ms->L, "invalid capture index"); + } + else { + ptrdiff_t l = ms->capture[i].len; + if (l == CAP_UNFINISHED) luaL_error(ms->L, "unfinished capture"); + if (l == CAP_POSITION) + lua_pushinteger(ms->L, ms->capture[i].init - ms->src_init + 1); + else + lua_pushlstring(ms->L, ms->capture[i].init, l); + } +} + + +static int push_captures (MatchState *ms, const char *s, const char *e) { + int i; + int nlevels = (ms->level == 0 && s) ? 1 : ms->level; + luaL_checkstack(ms->L, nlevels, "too many captures"); + for (i = 0; i < nlevels; i++) + push_onecapture(ms, i, s, e); + return nlevels; /* number of strings pushed */ +} + + +static int str_find_aux (lua_State *L, int find) { + size_t l1, l2; + const char *s = luaL_checklstring(L, 1, &l1); + const char *p = luaL_checklstring(L, 2, &l2); + ptrdiff_t init = posrelat(luaL_optinteger(L, 3, 1), l1) - 1; + if (init < 0) init = 0; + else if ((size_t)(init) > l1) init = (ptrdiff_t)l1; + if (find && (lua_toboolean(L, 4) || /* explicit request? */ + strpbrk(p, SPECIALS) == NULL)) { /* or no special characters? */ + /* do a plain search */ + const char *s2 = lmemfind(s+init, l1-init, p, l2); + if (s2) { + lua_pushinteger(L, s2-s+1); + lua_pushinteger(L, s2-s+l2); + return 2; + } + } + else { + MatchState ms; + int anchor = (*p == '^') ? (p++, 1) : 0; + const char *s1=s+init; + ms.L = L; + ms.src_init = s; + ms.src_end = s+l1; + do { + const char *res; + ms.level = 0; + if ((res=match(&ms, s1, p)) != NULL) { + if (find) { + lua_pushinteger(L, s1-s+1); /* start */ + lua_pushinteger(L, res-s); /* end */ + return push_captures(&ms, NULL, 0) + 2; + } + else + return push_captures(&ms, s1, res); + } + } while (s1++ < ms.src_end && !anchor); + } + lua_pushnil(L); /* not found */ + return 1; +} + + +static int str_find (lua_State *L) { + return str_find_aux(L, 1); +} + + +static int str_match (lua_State *L) { + return str_find_aux(L, 0); +} + + +static int gmatch_aux (lua_State *L) { + MatchState ms; + size_t ls; + const char *s = lua_tolstring(L, lua_upvalueindex(1), &ls); + const char *p = lua_tostring(L, lua_upvalueindex(2)); + const char *src; + ms.L = L; + ms.src_init = s; + ms.src_end = s+ls; + for (src = s + (size_t)lua_tointeger(L, lua_upvalueindex(3)); + src <= ms.src_end; + src++) { + const char *e; + ms.level = 0; + if ((e = match(&ms, src, p)) != NULL) { + lua_Integer newstart = e-s; + if (e == src) newstart++; /* empty match? go at least one position */ + lua_pushinteger(L, newstart); + lua_replace(L, lua_upvalueindex(3)); + return push_captures(&ms, src, e); + } + } + return 0; /* not found */ +} + + +static int gmatch (lua_State *L) { + luaL_checkstring(L, 1); + luaL_checkstring(L, 2); + lua_settop(L, 2); + lua_pushinteger(L, 0); + lua_pushcclosure(L, gmatch_aux, 3); + return 1; +} + + +static int gfind_nodef (lua_State *L) { + return luaL_error(L, LUA_QL("string.gfind") " was renamed to " + LUA_QL("string.gmatch")); +} + + +static void add_s (MatchState *ms, luaL_Buffer *b, const char *s, + const char *e) { + size_t l, i; + const char *news = lua_tolstring(ms->L, 3, &l); + for (i = 0; i < l; i++) { + if (news[i] != L_ESC) + luaL_addchar(b, news[i]); + else { + i++; /* skip ESC */ + if (!isdigit(uchar(news[i]))) + luaL_addchar(b, news[i]); + else if (news[i] == '0') + luaL_addlstring(b, s, e - s); + else { + push_onecapture(ms, news[i] - '1', s, e); + luaL_addvalue(b); /* add capture to accumulated result */ + } + } + } +} + + +static void add_value (MatchState *ms, luaL_Buffer *b, const char *s, + const char *e) { + lua_State *L = ms->L; + switch (lua_type(L, 3)) { + case LUA_TNUMBER: + case LUA_TSTRING: { + add_s(ms, b, s, e); + return; + } + case LUA_TFUNCTION: { + int n; + lua_pushvalue(L, 3); + n = push_captures(ms, s, e); + lua_call(L, n, 1); + break; + } + case LUA_TTABLE: { + push_onecapture(ms, 0, s, e); + lua_gettable(L, 3); + break; + } + } + if (!lua_toboolean(L, -1)) { /* nil or false? */ + lua_pop(L, 1); + lua_pushlstring(L, s, e - s); /* keep original text */ + } + else if (!lua_isstring(L, -1)) + luaL_error(L, "invalid replacement value (a %s)", luaL_typename(L, -1)); + luaL_addvalue(b); /* add result to accumulator */ +} + + +static int str_gsub (lua_State *L) { + size_t srcl; + const char *src = luaL_checklstring(L, 1, &srcl); + const char *p = luaL_checkstring(L, 2); + int tr = lua_type(L, 3); + int max_s = luaL_optint(L, 4, srcl+1); + int anchor = (*p == '^') ? (p++, 1) : 0; + int n = 0; + MatchState ms; + luaL_Buffer b; + luaL_argcheck(L, tr == LUA_TNUMBER || tr == LUA_TSTRING || + tr == LUA_TFUNCTION || tr == LUA_TTABLE, 3, + "string/function/table expected"); + luaL_buffinit(L, &b); + ms.L = L; + ms.src_init = src; + ms.src_end = src+srcl; + while (n < max_s) { + const char *e; + ms.level = 0; + e = match(&ms, src, p); + if (e) { + n++; + add_value(&ms, &b, src, e); + } + if (e && e>src) /* non empty match? */ + src = e; /* skip it */ + else if (src < ms.src_end) + luaL_addchar(&b, *src++); + else break; + if (anchor) break; + } + luaL_addlstring(&b, src, ms.src_end-src); + luaL_pushresult(&b); + lua_pushinteger(L, n); /* number of substitutions */ + return 2; +} + +/* }====================================================== */ + + +/* maximum size of each formatted item (> len(format('%99.99f', -1e308))) */ +#define MAX_ITEM 512 +/* valid flags in a format specification */ +#define FLAGS "-+ #0" +/* +** maximum size of each format specification (such as '%-099.99d') +** (+10 accounts for %99.99x plus margin of error) +*/ +#define MAX_FORMAT (sizeof(FLAGS) + sizeof(LUA_INTFRMLEN) + 10) + + +static void addquoted (lua_State *L, luaL_Buffer *b, int arg) { + size_t l; + const char *s = luaL_checklstring(L, arg, &l); + luaL_addchar(b, '"'); + while (l--) { + switch (*s) { + case '"': case '\\': case '\n': { + luaL_addchar(b, '\\'); + luaL_addchar(b, *s); + break; + } + case '\r': { + luaL_addlstring(b, "\\r", 2); + break; + } + case '\0': { + luaL_addlstring(b, "\\000", 4); + break; + } + default: { + luaL_addchar(b, *s); + break; + } + } + s++; + } + luaL_addchar(b, '"'); +} + +static const char *scanformat (lua_State *L, const char *strfrmt, char *form) { + const char *p = strfrmt; + while (*p != '\0' && strchr(FLAGS, *p) != NULL) p++; /* skip flags */ + if ((size_t)(p - strfrmt) >= sizeof(FLAGS)) + luaL_error(L, "invalid format (repeated flags)"); + if (isdigit(uchar(*p))) p++; /* skip width */ + if (isdigit(uchar(*p))) p++; /* (2 digits at most) */ + if (*p == '.') { + p++; + if (isdigit(uchar(*p))) p++; /* skip precision */ + if (isdigit(uchar(*p))) p++; /* (2 digits at most) */ + } + if (isdigit(uchar(*p))) + luaL_error(L, "invalid format (width or precision too long)"); + *(form++) = '%'; + strncpy(form, strfrmt, p - strfrmt + 1); + form += p - strfrmt + 1; + *form = '\0'; + return p; +} + + +static void addintlen (char *form) { + size_t l = strlen(form); + char spec = form[l - 1]; + strcpy(form + l - 1, LUA_INTFRMLEN); + form[l + sizeof(LUA_INTFRMLEN) - 2] = spec; + form[l + sizeof(LUA_INTFRMLEN) - 1] = '\0'; +} + + +static int str_format (lua_State *L) { + int arg = 1; + size_t sfl; + const char *strfrmt = luaL_checklstring(L, arg, &sfl); + const char *strfrmt_end = strfrmt+sfl; + luaL_Buffer b; + luaL_buffinit(L, &b); + while (strfrmt < strfrmt_end) { + if (*strfrmt != L_ESC) + luaL_addchar(&b, *strfrmt++); + else if (*++strfrmt == L_ESC) + luaL_addchar(&b, *strfrmt++); /* %% */ + else { /* format item */ + char form[MAX_FORMAT]; /* to store the format (`%...') */ + char buff[MAX_ITEM]; /* to store the formatted item */ + arg++; + strfrmt = scanformat(L, strfrmt, form); + switch (*strfrmt++) { + case 'c': { + sprintf(buff, form, (int)luaL_checknumber(L, arg)); + break; + } + case 'd': case 'i': { + addintlen(form); + sprintf(buff, form, (LUA_INTFRM_T)luaL_checknumber(L, arg)); + break; + } + case 'o': case 'u': case 'x': case 'X': { + addintlen(form); + sprintf(buff, form, (unsigned LUA_INTFRM_T)luaL_checknumber(L, arg)); + break; + } + case 'e': case 'E': case 'f': + case 'g': case 'G': { + sprintf(buff, form, (double)luaL_checknumber(L, arg)); + break; + } + case 'q': { + addquoted(L, &b, arg); + continue; /* skip the 'addsize' at the end */ + } + case 's': { + size_t l; + const char *s = luaL_checklstring(L, arg, &l); + if (!strchr(form, '.') && l >= 100) { + /* no precision and string is too long to be formatted; + keep original string */ + lua_pushvalue(L, arg); + luaL_addvalue(&b); + continue; /* skip the `addsize' at the end */ + } + else { + sprintf(buff, form, s); + break; + } + } + default: { /* also treat cases `pnLlh' */ + return luaL_error(L, "invalid option " LUA_QL("%%%c") " to " + LUA_QL("format"), *(strfrmt - 1)); + } + } + luaL_addlstring(&b, buff, strlen(buff)); + } + } + luaL_pushresult(&b); + return 1; +} + + +static const luaL_Reg strlib[] = { + {"byte", str_byte}, + {"char", str_char}, + {"dump", str_dump}, + {"find", str_find}, + {"format", str_format}, + {"gfind", gfind_nodef}, + {"gmatch", gmatch}, + {"gsub", str_gsub}, + {"len", str_len}, + {"lower", str_lower}, + {"match", str_match}, + {"rep", str_rep}, + {"reverse", str_reverse}, + {"sub", str_sub}, + {"upper", str_upper}, + {NULL, NULL} +}; + + +static void createmetatable (lua_State *L) { + lua_createtable(L, 0, 1); /* create metatable for strings */ + lua_pushliteral(L, ""); /* dummy string */ + lua_pushvalue(L, -2); + lua_setmetatable(L, -2); /* set string metatable */ + lua_pop(L, 1); /* pop dummy string */ + lua_pushvalue(L, -2); /* string library... */ + lua_setfield(L, -2, "__index"); /* ...is the __index metamethod */ + lua_pop(L, 1); /* pop metatable */ +} + + +/* +** Open string library +*/ +LUALIB_API int luaopen_string (lua_State *L) { + luaL_register(L, LUA_STRLIBNAME, strlib); +#if defined(LUA_COMPAT_GFIND) + lua_getfield(L, -1, "gmatch"); + lua_setfield(L, -2, "gfind"); +#endif + createmetatable(L); + return 1; +} + diff --git a/mylua/lua/ltable.c b/mylua/lua/ltable.c new file mode 100644 index 0000000..ec84f4f --- /dev/null +++ b/mylua/lua/ltable.c @@ -0,0 +1,588 @@ +/* +** $Id: ltable.c,v 2.32.1.2 2007/12/28 15:32:23 roberto Exp $ +** Lua tables (hash) +** See Copyright Notice in lua.h +*/ + + +/* +** Implementation of tables (aka arrays, objects, or hash tables). +** Tables keep its elements in two parts: an array part and a hash part. +** Non-negative integer keys are all candidates to be kept in the array +** part. The actual size of the array is the largest `n' such that at +** least half the slots between 0 and n are in use. +** Hash uses a mix of chained scatter table with Brent's variation. +** A main invariant of these tables is that, if an element is not +** in its main position (i.e. the `original' position that its hash gives +** to it), then the colliding element is in its own main position. +** Hence even when the load factor reaches 100%, performance remains good. +*/ + +#include +#include + +#define ltable_c +#define LUA_CORE + +#include "lua.h" + +#include "ldebug.h" +#include "ldo.h" +#include "lgc.h" +#include "lmem.h" +#include "lobject.h" +#include "lstate.h" +#include "ltable.h" + + +/* +** max size of array part is 2^MAXBITS +*/ +#if LUAI_BITSINT > 26 +#define MAXBITS 26 +#else +#define MAXBITS (LUAI_BITSINT-2) +#endif + +#define MAXASIZE (1 << MAXBITS) + + +#define hashpow2(t,n) (gnode(t, lmod((n), sizenode(t)))) + +#define hashstr(t,str) hashpow2(t, (str)->tsv.hash) +#define hashboolean(t,p) hashpow2(t, p) + + +/* +** for some types, it is better to avoid modulus by power of 2, as +** they tend to have many 2 factors. +*/ +#define hashmod(t,n) (gnode(t, ((n) % ((sizenode(t)-1)|1)))) + + +#define hashpointer(t,p) hashmod(t, IntPoint(p)) + + +/* +** number of ints inside a lua_Number +*/ +#define numints cast_int(sizeof(lua_Number)/sizeof(int)) + + + +#define dummynode (&dummynode_) + +static const Node dummynode_ = { + {{NULL}, LUA_TNIL}, /* value */ + {{{NULL}, LUA_TNIL, NULL}} /* key */ +}; + + +/* +** hash for lua_Numbers +*/ +static Node *hashnum (const Table *t, lua_Number n) { + unsigned int a[numints]; + int i; + if (luai_numeq(n, 0)) /* avoid problems with -0 */ + return gnode(t, 0); + memcpy(a, &n, sizeof(a)); + for (i = 1; i < numints; i++) a[0] += a[i]; + return hashmod(t, a[0]); +} + + + +/* +** returns the `main' position of an element in a table (that is, the index +** of its hash value) +*/ +static Node *mainposition (const Table *t, const TValue *key) { + switch (ttype(key)) { + case LUA_TNUMBER: + return hashnum(t, nvalue(key)); + case LUA_TSTRING: + return hashstr(t, rawtsvalue(key)); + case LUA_TBOOLEAN: + return hashboolean(t, bvalue(key)); + case LUA_TLIGHTUSERDATA: + return hashpointer(t, pvalue(key)); + default: + return hashpointer(t, gcvalue(key)); + } +} + + +/* +** returns the index for `key' if `key' is an appropriate key to live in +** the array part of the table, -1 otherwise. +*/ +static int arrayindex (const TValue *key) { + if (ttisnumber(key)) { + lua_Number n = nvalue(key); + int k; + lua_number2int(k, n); + if (luai_numeq(cast_num(k), n)) + return k; + } + return -1; /* `key' did not match some condition */ +} + + +/* +** returns the index of a `key' for table traversals. First goes all +** elements in the array part, then elements in the hash part. The +** beginning of a traversal is signalled by -1. +*/ +static int findindex (lua_State *L, Table *t, StkId key) { + int i; + if (ttisnil(key)) return -1; /* first iteration */ + i = arrayindex(key); + if (0 < i && i <= t->sizearray) /* is `key' inside array part? */ + return i-1; /* yes; that's the index (corrected to C) */ + else { + Node *n = mainposition(t, key); + do { /* check whether `key' is somewhere in the chain */ + /* key may be dead already, but it is ok to use it in `next' */ + if (luaO_rawequalObj(key2tval(n), key) || + (ttype(gkey(n)) == LUA_TDEADKEY && iscollectable(key) && + gcvalue(gkey(n)) == gcvalue(key))) { + i = cast_int(n - gnode(t, 0)); /* key index in hash table */ + /* hash elements are numbered after array ones */ + return i + t->sizearray; + } + else n = gnext(n); + } while (n); + luaG_runerror(L, "invalid key to " LUA_QL("next")); /* key not found */ + return 0; /* to avoid warnings */ + } +} + + +int luaH_next (lua_State *L, Table *t, StkId key) { + int i = findindex(L, t, key); /* find original element */ + for (i++; i < t->sizearray; i++) { /* try first array part */ + if (!ttisnil(&t->array[i])) { /* a non-nil value? */ + setnvalue(key, cast_num(i+1)); + setobj2s(L, key+1, &t->array[i]); + return 1; + } + } + for (i -= t->sizearray; i < sizenode(t); i++) { /* then hash part */ + if (!ttisnil(gval(gnode(t, i)))) { /* a non-nil value? */ + setobj2s(L, key, key2tval(gnode(t, i))); + setobj2s(L, key+1, gval(gnode(t, i))); + return 1; + } + } + return 0; /* no more elements */ +} + + +/* +** {============================================================= +** Rehash +** ============================================================== +*/ + + +static int computesizes (int nums[], int *narray) { + int i; + int twotoi; /* 2^i */ + int a = 0; /* number of elements smaller than 2^i */ + int na = 0; /* number of elements to go to array part */ + int n = 0; /* optimal size for array part */ + for (i = 0, twotoi = 1; twotoi/2 < *narray; i++, twotoi *= 2) { + if (nums[i] > 0) { + a += nums[i]; + if (a > twotoi/2) { /* more than half elements present? */ + n = twotoi; /* optimal size (till now) */ + na = a; /* all elements smaller than n will go to array part */ + } + } + if (a == *narray) break; /* all elements already counted */ + } + *narray = n; + lua_assert(*narray/2 <= na && na <= *narray); + return na; +} + + +static int countint (const TValue *key, int *nums) { + int k = arrayindex(key); + if (0 < k && k <= MAXASIZE) { /* is `key' an appropriate array index? */ + nums[ceillog2(k)]++; /* count as such */ + return 1; + } + else + return 0; +} + + +static int numusearray (const Table *t, int *nums) { + int lg; + int ttlg; /* 2^lg */ + int ause = 0; /* summation of `nums' */ + int i = 1; /* count to traverse all array keys */ + for (lg=0, ttlg=1; lg<=MAXBITS; lg++, ttlg*=2) { /* for each slice */ + int lc = 0; /* counter */ + int lim = ttlg; + if (lim > t->sizearray) { + lim = t->sizearray; /* adjust upper limit */ + if (i > lim) + break; /* no more elements to count */ + } + /* count elements in range (2^(lg-1), 2^lg] */ + for (; i <= lim; i++) { + if (!ttisnil(&t->array[i-1])) + lc++; + } + nums[lg] += lc; + ause += lc; + } + return ause; +} + + +static int numusehash (const Table *t, int *nums, int *pnasize) { + int totaluse = 0; /* total number of elements */ + int ause = 0; /* summation of `nums' */ + int i = sizenode(t); + while (i--) { + Node *n = &t->node[i]; + if (!ttisnil(gval(n))) { + ause += countint(key2tval(n), nums); + totaluse++; + } + } + *pnasize += ause; + return totaluse; +} + + +static void setarrayvector (lua_State *L, Table *t, int size) { + int i; + luaM_reallocvector(L, t->array, t->sizearray, size, TValue); + for (i=t->sizearray; iarray[i]); + t->sizearray = size; +} + + +static void setnodevector (lua_State *L, Table *t, int size) { + int lsize; + if (size == 0) { /* no elements to hash part? */ + t->node = cast(Node *, dummynode); /* use common `dummynode' */ + lsize = 0; + } + else { + int i; + lsize = ceillog2(size); + if (lsize > MAXBITS) + luaG_runerror(L, "table overflow"); + size = twoto(lsize); + t->node = luaM_newvector(L, size, Node); + for (i=0; ilsizenode = cast_byte(lsize); + t->lastfree = gnode(t, size); /* all positions are free */ +} + + +static void resize (lua_State *L, Table *t, int nasize, int nhsize) { + int i; + int oldasize = t->sizearray; + int oldhsize = t->lsizenode; + Node *nold = t->node; /* save old hash ... */ + if (nasize > oldasize) /* array part must grow? */ + setarrayvector(L, t, nasize); + /* create new hash part with appropriate size */ + setnodevector(L, t, nhsize); + if (nasize < oldasize) { /* array part must shrink? */ + t->sizearray = nasize; + /* re-insert elements from vanishing slice */ + for (i=nasize; iarray[i])) + setobjt2t(L, luaH_setnum(L, t, i+1), &t->array[i]); + } + /* shrink array */ + luaM_reallocvector(L, t->array, oldasize, nasize, TValue); + } + /* re-insert elements from hash part */ + for (i = twoto(oldhsize) - 1; i >= 0; i--) { + Node *old = nold+i; + if (!ttisnil(gval(old))) + setobjt2t(L, luaH_set(L, t, key2tval(old)), gval(old)); + } + if (nold != dummynode) + luaM_freearray(L, nold, twoto(oldhsize), Node); /* free old array */ +} + + +void luaH_resizearray (lua_State *L, Table *t, int nasize) { + int nsize = (t->node == dummynode) ? 0 : sizenode(t); + resize(L, t, nasize, nsize); +} + + +static void rehash (lua_State *L, Table *t, const TValue *ek) { + int nasize, na; + int nums[MAXBITS+1]; /* nums[i] = number of keys between 2^(i-1) and 2^i */ + int i; + int totaluse; + for (i=0; i<=MAXBITS; i++) nums[i] = 0; /* reset counts */ + nasize = numusearray(t, nums); /* count keys in array part */ + totaluse = nasize; /* all those keys are integer keys */ + totaluse += numusehash(t, nums, &nasize); /* count keys in hash part */ + /* count extra key */ + nasize += countint(ek, nums); + totaluse++; + /* compute new size for array part */ + na = computesizes(nums, &nasize); + /* resize the table to new computed sizes */ + resize(L, t, nasize, totaluse - na); +} + + + +/* +** }============================================================= +*/ + + +Table *luaH_new (lua_State *L, int narray, int nhash) { + Table *t = luaM_new(L, Table); + luaC_link(L, obj2gco(t), LUA_TTABLE); + t->metatable = NULL; + t->flags = cast_byte(~0); + /* temporary values (kept only if some malloc fails) */ + t->array = NULL; + t->sizearray = 0; + t->lsizenode = 0; + t->node = cast(Node *, dummynode); + setarrayvector(L, t, narray); + setnodevector(L, t, nhash); + return t; +} + + +void luaH_free (lua_State *L, Table *t) { + if (t->node != dummynode) + luaM_freearray(L, t->node, sizenode(t), Node); + luaM_freearray(L, t->array, t->sizearray, TValue); + luaM_free(L, t); +} + + +static Node *getfreepos (Table *t) { + while (t->lastfree-- > t->node) { + if (ttisnil(gkey(t->lastfree))) + return t->lastfree; + } + return NULL; /* could not find a free place */ +} + + + +/* +** inserts a new key into a hash table; first, check whether key's main +** position is free. If not, check whether colliding node is in its main +** position or not: if it is not, move colliding node to an empty place and +** put new key in its main position; otherwise (colliding node is in its main +** position), new key goes to an empty position. +*/ +static TValue *newkey (lua_State *L, Table *t, const TValue *key) { + Node *mp = mainposition(t, key); + if (!ttisnil(gval(mp)) || mp == dummynode) { + Node *othern; + Node *n = getfreepos(t); /* get a free place */ + if (n == NULL) { /* cannot find a free place? */ + rehash(L, t, key); /* grow table */ + return luaH_set(L, t, key); /* re-insert key into grown table */ + } + lua_assert(n != dummynode); + othern = mainposition(t, key2tval(mp)); + if (othern != mp) { /* is colliding node out of its main position? */ + /* yes; move colliding node into free position */ + while (gnext(othern) != mp) othern = gnext(othern); /* find previous */ + gnext(othern) = n; /* redo the chain with `n' in place of `mp' */ + *n = *mp; /* copy colliding node into free pos. (mp->next also goes) */ + gnext(mp) = NULL; /* now `mp' is free */ + setnilvalue(gval(mp)); + } + else { /* colliding node is in its own main position */ + /* new node will go into free position */ + gnext(n) = gnext(mp); /* chain new position */ + gnext(mp) = n; + mp = n; + } + } + gkey(mp)->value = key->value; gkey(mp)->tt = key->tt; + luaC_barriert(L, t, key); + lua_assert(ttisnil(gval(mp))); + return gval(mp); +} + + +/* +** search function for integers +*/ +const TValue *luaH_getnum (Table *t, int key) { + /* (1 <= key && key <= t->sizearray) */ + if (cast(unsigned int, key-1) < cast(unsigned int, t->sizearray)) + return &t->array[key-1]; + else { + lua_Number nk = cast_num(key); + Node *n = hashnum(t, nk); + do { /* check whether `key' is somewhere in the chain */ + if (ttisnumber(gkey(n)) && luai_numeq(nvalue(gkey(n)), nk)) + return gval(n); /* that's it */ + else n = gnext(n); + } while (n); + return luaO_nilobject; + } +} + + +/* +** search function for strings +*/ +const TValue *luaH_getstr (Table *t, TString *key) { + Node *n = hashstr(t, key); + do { /* check whether `key' is somewhere in the chain */ + if (ttisstring(gkey(n)) && rawtsvalue(gkey(n)) == key) + return gval(n); /* that's it */ + else n = gnext(n); + } while (n); + return luaO_nilobject; +} + + +/* +** main search function +*/ +const TValue *luaH_get (Table *t, const TValue *key) { + switch (ttype(key)) { + case LUA_TNIL: return luaO_nilobject; + case LUA_TSTRING: return luaH_getstr(t, rawtsvalue(key)); + case LUA_TNUMBER: { + int k; + lua_Number n = nvalue(key); + lua_number2int(k, n); + if (luai_numeq(cast_num(k), nvalue(key))) /* index is int? */ + return luaH_getnum(t, k); /* use specialized version */ + /* else go through */ + } + default: { + Node *n = mainposition(t, key); + do { /* check whether `key' is somewhere in the chain */ + if (luaO_rawequalObj(key2tval(n), key)) + return gval(n); /* that's it */ + else n = gnext(n); + } while (n); + return luaO_nilobject; + } + } +} + + +TValue *luaH_set (lua_State *L, Table *t, const TValue *key) { + const TValue *p = luaH_get(t, key); + t->flags = 0; + if (p != luaO_nilobject) + return cast(TValue *, p); + else { + if (ttisnil(key)) luaG_runerror(L, "table index is nil"); + else if (ttisnumber(key) && luai_numisnan(nvalue(key))) + luaG_runerror(L, "table index is NaN"); + return newkey(L, t, key); + } +} + + +TValue *luaH_setnum (lua_State *L, Table *t, int key) { + const TValue *p = luaH_getnum(t, key); + if (p != luaO_nilobject) + return cast(TValue *, p); + else { + TValue k; + setnvalue(&k, cast_num(key)); + return newkey(L, t, &k); + } +} + + +TValue *luaH_setstr (lua_State *L, Table *t, TString *key) { + const TValue *p = luaH_getstr(t, key); + if (p != luaO_nilobject) + return cast(TValue *, p); + else { + TValue k; + setsvalue(L, &k, key); + return newkey(L, t, &k); + } +} + + +static int unbound_search (Table *t, unsigned int j) { + unsigned int i = j; /* i is zero or a present index */ + j++; + /* find `i' and `j' such that i is present and j is not */ + while (!ttisnil(luaH_getnum(t, j))) { + i = j; + j *= 2; + if (j > cast(unsigned int, MAX_INT)) { /* overflow? */ + /* table was built with bad purposes: resort to linear search */ + i = 1; + while (!ttisnil(luaH_getnum(t, i))) i++; + return i - 1; + } + } + /* now do a binary search between them */ + while (j - i > 1) { + unsigned int m = (i+j)/2; + if (ttisnil(luaH_getnum(t, m))) j = m; + else i = m; + } + return i; +} + + +/* +** Try to find a boundary in table `t'. A `boundary' is an integer index +** such that t[i] is non-nil and t[i+1] is nil (and 0 if t[1] is nil). +*/ +int luaH_getn (Table *t) { + unsigned int j = t->sizearray; + if (j > 0 && ttisnil(&t->array[j - 1])) { + /* there is a boundary in the array part: (binary) search for it */ + unsigned int i = 0; + while (j - i > 1) { + unsigned int m = (i+j)/2; + if (ttisnil(&t->array[m - 1])) j = m; + else i = m; + } + return i; + } + /* else must find a boundary in hash part */ + else if (t->node == dummynode) /* hash part is empty? */ + return j; /* that is easy... */ + else return unbound_search(t, j); +} + + + +#if defined(LUA_DEBUG) + +Node *luaH_mainposition (const Table *t, const TValue *key) { + return mainposition(t, key); +} + +int luaH_isdummy (Node *n) { return n == dummynode; } + +#endif diff --git a/mylua/lua/ltable.h b/mylua/lua/ltable.h new file mode 100644 index 0000000..f5b9d5e --- /dev/null +++ b/mylua/lua/ltable.h @@ -0,0 +1,40 @@ +/* +** $Id: ltable.h,v 2.10.1.1 2007/12/27 13:02:25 roberto Exp $ +** Lua tables (hash) +** See Copyright Notice in lua.h +*/ + +#ifndef ltable_h +#define ltable_h + +#include "lobject.h" + + +#define gnode(t,i) (&(t)->node[i]) +#define gkey(n) (&(n)->i_key.nk) +#define gval(n) (&(n)->i_val) +#define gnext(n) ((n)->i_key.nk.next) + +#define key2tval(n) (&(n)->i_key.tvk) + + +LUAI_FUNC const TValue *luaH_getnum (Table *t, int key); +LUAI_FUNC TValue *luaH_setnum (lua_State *L, Table *t, int key); +LUAI_FUNC const TValue *luaH_getstr (Table *t, TString *key); +LUAI_FUNC TValue *luaH_setstr (lua_State *L, Table *t, TString *key); +LUAI_FUNC const TValue *luaH_get (Table *t, const TValue *key); +LUAI_FUNC TValue *luaH_set (lua_State *L, Table *t, const TValue *key); +LUAI_FUNC Table *luaH_new (lua_State *L, int narray, int lnhash); +LUAI_FUNC void luaH_resizearray (lua_State *L, Table *t, int nasize); +LUAI_FUNC void luaH_free (lua_State *L, Table *t); +LUAI_FUNC int luaH_next (lua_State *L, Table *t, StkId key); +LUAI_FUNC int luaH_getn (Table *t); + + +#if defined(LUA_DEBUG) +LUAI_FUNC Node *luaH_mainposition (const Table *t, const TValue *key); +LUAI_FUNC int luaH_isdummy (Node *n); +#endif + + +#endif diff --git a/mylua/lua/ltablib.c b/mylua/lua/ltablib.c new file mode 100644 index 0000000..b6d9cb4 --- /dev/null +++ b/mylua/lua/ltablib.c @@ -0,0 +1,287 @@ +/* +** $Id: ltablib.c,v 1.38.1.3 2008/02/14 16:46:58 roberto Exp $ +** Library for Table Manipulation +** See Copyright Notice in lua.h +*/ + + +#include + +#define ltablib_c +#define LUA_LIB + +#include "lua.h" + +#include "lauxlib.h" +#include "lualib.h" + + +#define aux_getn(L,n) (luaL_checktype(L, n, LUA_TTABLE), luaL_getn(L, n)) + + +static int foreachi (lua_State *L) { + int i; + int n = aux_getn(L, 1); + luaL_checktype(L, 2, LUA_TFUNCTION); + for (i=1; i <= n; i++) { + lua_pushvalue(L, 2); /* function */ + lua_pushinteger(L, i); /* 1st argument */ + lua_rawgeti(L, 1, i); /* 2nd argument */ + lua_call(L, 2, 1); + if (!lua_isnil(L, -1)) + return 1; + lua_pop(L, 1); /* remove nil result */ + } + return 0; +} + + +static int foreach (lua_State *L) { + luaL_checktype(L, 1, LUA_TTABLE); + luaL_checktype(L, 2, LUA_TFUNCTION); + lua_pushnil(L); /* first key */ + while (lua_next(L, 1)) { + lua_pushvalue(L, 2); /* function */ + lua_pushvalue(L, -3); /* key */ + lua_pushvalue(L, -3); /* value */ + lua_call(L, 2, 1); + if (!lua_isnil(L, -1)) + return 1; + lua_pop(L, 2); /* remove value and result */ + } + return 0; +} + + +static int maxn (lua_State *L) { + lua_Number max = 0; + luaL_checktype(L, 1, LUA_TTABLE); + lua_pushnil(L); /* first key */ + while (lua_next(L, 1)) { + lua_pop(L, 1); /* remove value */ + if (lua_type(L, -1) == LUA_TNUMBER) { + lua_Number v = lua_tonumber(L, -1); + if (v > max) max = v; + } + } + lua_pushnumber(L, max); + return 1; +} + + +static int getn (lua_State *L) { + lua_pushinteger(L, aux_getn(L, 1)); + return 1; +} + + +static int setn (lua_State *L) { + luaL_checktype(L, 1, LUA_TTABLE); +#ifndef luaL_setn + luaL_setn(L, 1, luaL_checkint(L, 2)); +#else + luaL_error(L, LUA_QL("setn") " is obsolete"); +#endif + lua_pushvalue(L, 1); + return 1; +} + + +static int tinsert (lua_State *L) { + int e = aux_getn(L, 1) + 1; /* first empty element */ + int pos; /* where to insert new element */ + switch (lua_gettop(L)) { + case 2: { /* called with only 2 arguments */ + pos = e; /* insert new element at the end */ + break; + } + case 3: { + int i; + pos = luaL_checkint(L, 2); /* 2nd argument is the position */ + if (pos > e) e = pos; /* `grow' array if necessary */ + for (i = e; i > pos; i--) { /* move up elements */ + lua_rawgeti(L, 1, i-1); + lua_rawseti(L, 1, i); /* t[i] = t[i-1] */ + } + break; + } + default: { + return luaL_error(L, "wrong number of arguments to " LUA_QL("insert")); + } + } + luaL_setn(L, 1, e); /* new size */ + lua_rawseti(L, 1, pos); /* t[pos] = v */ + return 0; +} + + +static int tremove (lua_State *L) { + int e = aux_getn(L, 1); + int pos = luaL_optint(L, 2, e); + if (!(1 <= pos && pos <= e)) /* position is outside bounds? */ + return 0; /* nothing to remove */ + luaL_setn(L, 1, e - 1); /* t.n = n-1 */ + lua_rawgeti(L, 1, pos); /* result = t[pos] */ + for ( ;pos= P */ + while (lua_rawgeti(L, 1, ++i), sort_comp(L, -1, -2)) { + if (i>u) luaL_error(L, "invalid order function for sorting"); + lua_pop(L, 1); /* remove a[i] */ + } + /* repeat --j until a[j] <= P */ + while (lua_rawgeti(L, 1, --j), sort_comp(L, -3, -1)) { + if (j + +#define ltm_c +#define LUA_CORE + +#include "lua.h" + +#include "lobject.h" +#include "lstate.h" +#include "lstring.h" +#include "ltable.h" +#include "ltm.h" + + + +const char *const luaT_typenames[] = { + "nil", "boolean", "userdata", "number", + "string", "table", "function", "userdata", "thread", + "proto", "upval" +}; + + +void luaT_init (lua_State *L) { + static const char *const luaT_eventname[] = { /* ORDER TM */ + "__index", "__newindex", + "__gc", "__mode", "__eq", + "__add", "__sub", "__mul", "__div", "__mod", + "__pow", "__unm", "__len", "__lt", "__le", + "__concat", "__call" + }; + int i; + for (i=0; itmname[i] = luaS_new(L, luaT_eventname[i]); + luaS_fix(G(L)->tmname[i]); /* never collect these names */ + } +} + + +/* +** function to be used with macro "fasttm": optimized for absence of +** tag methods +*/ +const TValue *luaT_gettm (Table *events, TMS event, TString *ename) { + const TValue *tm = luaH_getstr(events, ename); + lua_assert(event <= TM_EQ); + if (ttisnil(tm)) { /* no tag method? */ + events->flags |= cast_byte(1u<metatable; + break; + case LUA_TUSERDATA: + mt = uvalue(o)->metatable; + break; + default: + mt = G(L)->mt[ttype(o)]; + } + return (mt ? luaH_getstr(mt, G(L)->tmname[event]) : luaO_nilobject); +} + diff --git a/mylua/lua/ltm.h b/mylua/lua/ltm.h new file mode 100644 index 0000000..64343b7 --- /dev/null +++ b/mylua/lua/ltm.h @@ -0,0 +1,54 @@ +/* +** $Id: ltm.h,v 2.6.1.1 2007/12/27 13:02:25 roberto Exp $ +** Tag methods +** See Copyright Notice in lua.h +*/ + +#ifndef ltm_h +#define ltm_h + + +#include "lobject.h" + + +/* +* WARNING: if you change the order of this enumeration, +* grep "ORDER TM" +*/ +typedef enum { + TM_INDEX, + TM_NEWINDEX, + TM_GC, + TM_MODE, + TM_EQ, /* last tag method with `fast' access */ + TM_ADD, + TM_SUB, + TM_MUL, + TM_DIV, + TM_MOD, + TM_POW, + TM_UNM, + TM_LEN, + TM_LT, + TM_LE, + TM_CONCAT, + TM_CALL, + TM_N /* number of elements in the enum */ +} TMS; + + + +#define gfasttm(g,et,e) ((et) == NULL ? NULL : \ + ((et)->flags & (1u<<(e))) ? NULL : luaT_gettm(et, e, (g)->tmname[e])) + +#define fasttm(l,et,e) gfasttm(G(l), et, e) + +LUAI_DATA const char *const luaT_typenames[]; + + +LUAI_FUNC const TValue *luaT_gettm (Table *events, TMS event, TString *ename); +LUAI_FUNC const TValue *luaT_gettmbyobj (lua_State *L, const TValue *o, + TMS event); +LUAI_FUNC void luaT_init (lua_State *L); + +#endif diff --git a/mylua/lua/lua b/mylua/lua/lua new file mode 100644 index 0000000..15e5189 Binary files /dev/null and b/mylua/lua/lua differ diff --git a/mylua/lua/lua.c b/mylua/lua/lua.c new file mode 100644 index 0000000..c28c8c0 --- /dev/null +++ b/mylua/lua/lua.c @@ -0,0 +1,391 @@ +/* +** $Id: lua.c,v 1.160.1.2 2007/12/28 15:32:23 roberto Exp $ +** Lua stand-alone interpreter +** See Copyright Notice in lua.h +*/ + + +#include +#include +#include +#include + +#define lua_c + +#include "lua.h" + +#include "lauxlib.h" +#include "lualib.h" + + + +static lua_State *globalL = NULL; + +static const char *progname = LUA_PROGNAME; + + + +static void lstop (lua_State *L, lua_Debug *ar) { + (void)ar; /* unused arg. */ + lua_sethook(L, NULL, 0, 0); + luaL_error(L, "interrupted!"); +} + + +static void laction (int i) { + signal(i, SIG_DFL); /* if another SIGINT happens before lstop, + terminate process (default action) */ + lua_sethook(globalL, lstop, LUA_MASKCALL | LUA_MASKRET | LUA_MASKCOUNT, 1); +} + + +static void print_usage (void) { + fprintf(stderr, + "usage: %s [options] [script [args]].\n" + "Available options are:\n" + " -e stat execute string " LUA_QL("stat") "\n" + " -l name require library " LUA_QL("name") "\n" + " -i enter interactive mode after executing " LUA_QL("script") "\n" + " -v show version information\n" + " -- stop handling options\n" + " - execute stdin and stop handling options\n" + , + progname); + fflush(stderr); +} + + +static void l_message (const char *pname, const char *msg) { + if (pname) fprintf(stderr, "%s: ", pname); + fprintf(stderr, "%s\n", msg); + fflush(stderr); +} + + +static int report (lua_State *L, int status) { + if (status && !lua_isnil(L, -1)) { + const char *msg = lua_tostring(L, -1); + if (msg == NULL) msg = "(error object is not a string)"; + l_message(progname, msg); + lua_pop(L, 1); + } + return status; +} + + +static int traceback (lua_State *L) { + if (!lua_isstring(L, 1)) /* 'message' not a string? */ + return 1; /* keep it intact */ + lua_getfield(L, LUA_GLOBALSINDEX, "debug"); + if (!lua_istable(L, -1)) { + lua_pop(L, 1); + return 1; + } + lua_getfield(L, -1, "traceback"); + if (!lua_isfunction(L, -1)) { + lua_pop(L, 2); + return 1; + } + lua_pushvalue(L, 1); /* pass error message */ + lua_pushinteger(L, 2); /* skip this function and traceback */ + lua_call(L, 2, 1); /* call debug.traceback */ + return 1; +} + + +static int docall (lua_State *L, int narg, int clear) { + int status; + int base = lua_gettop(L) - narg; /* function index */ + lua_pushcfunction(L, traceback); /* push traceback function */ + lua_insert(L, base); /* put it under chunk and args */ + signal(SIGINT, laction); + status = lua_pcall(L, narg, (clear ? 0 : LUA_MULTRET), base); + signal(SIGINT, SIG_DFL); + lua_remove(L, base); /* remove traceback function */ + /* force a complete garbage collection in case of errors */ + if (status != 0) lua_gc(L, LUA_GCCOLLECT, 0); + return status; +} + + +static void print_version (void) { + l_message(NULL, LUA_RELEASE " " LUA_COPYRIGHT); +} + + +static int getargs (lua_State *L, char **argv, int n) { + int narg; + int i; + int argc = 0; + while (argv[argc]) argc++; /* count total number of arguments */ + narg = argc - (n + 1); /* number of arguments to the script */ + luaL_checkstack(L, narg + 3, "too many arguments to script"); + for (i=n+1; i < argc; i++) + lua_pushstring(L, argv[i]); + lua_createtable(L, narg, n + 1); + for (i=0; i < argc; i++) { + lua_pushstring(L, argv[i]); + lua_rawseti(L, -2, i - n); + } + return narg; +} + + +static int dofile (lua_State *L, const char *name) { + int status = luaL_loadfile(L, name) || docall(L, 0, 1); + return report(L, status); +} + + +static int dostring (lua_State *L, const char *s, const char *name) { + int status = luaL_loadbuffer(L, s, strlen(s), name) || docall(L, 0, 1); + return report(L, status); +} + + +static int dolibrary (lua_State *L, const char *name) { + lua_getglobal(L, "require"); + lua_pushstring(L, name); + return report(L, docall(L, 1, 1)); +} + + +static const char *get_prompt (lua_State *L, int firstline) { + const char *p; + lua_getfield(L, LUA_GLOBALSINDEX, firstline ? "_PROMPT" : "_PROMPT2"); + p = lua_tostring(L, -1); + if (p == NULL) p = (firstline ? LUA_PROMPT : LUA_PROMPT2); + lua_pop(L, 1); /* remove global */ + return p; +} + + +static int incomplete (lua_State *L, int status) { + if (status == LUA_ERRSYNTAX) { + size_t lmsg; + const char *msg = lua_tolstring(L, -1, &lmsg); + const char *tp = msg + lmsg - (sizeof(LUA_QL("")) - 1); + if (strstr(msg, LUA_QL("")) == tp) { + lua_pop(L, 1); + return 1; + } + } + return 0; /* else... */ +} + + +static int pushline (lua_State *L, int firstline) { + char buffer[LUA_MAXINPUT]; + char *b = buffer; + size_t l; + const char *prmt = get_prompt(L, firstline); + if (lua_readline(L, b, prmt) == 0) + return 0; /* no input */ + l = strlen(b); + if (l > 0 && b[l-1] == '\n') /* line ends with newline? */ + b[l-1] = '\0'; /* remove it */ + if (firstline && b[0] == '=') /* first line starts with `=' ? */ + lua_pushfstring(L, "return %s", b+1); /* change it to `return' */ + else + lua_pushstring(L, b); + lua_freeline(L, b); + return 1; +} + + +static int loadline (lua_State *L) { + int status; + lua_settop(L, 0); + if (!pushline(L, 1)) + return -1; /* no input */ + for (;;) { /* repeat until gets a complete line */ + status = luaL_loadbuffer(L, lua_tostring(L, 1), lua_strlen(L, 1), "=stdin"); + if (!incomplete(L, status)) break; /* cannot try to add lines? */ + if (!pushline(L, 0)) /* no more input? */ + return -1; + lua_pushliteral(L, "\n"); /* add a new line... */ + lua_insert(L, -2); /* ...between the two lines */ + lua_concat(L, 3); /* join them */ + } + lua_saveline(L, 1); + lua_remove(L, 1); /* remove line */ + return status; +} + + +static void dotty (lua_State *L) { + int status; + const char *oldprogname = progname; + progname = NULL; + while ((status = loadline(L)) != -1) { + if (status == 0) status = docall(L, 0, 0); + report(L, status); + if (status == 0 && lua_gettop(L) > 0) { /* any result to print? */ + lua_getglobal(L, "print"); + lua_insert(L, 1); + if (lua_pcall(L, lua_gettop(L)-1, 0, 0) != 0) + l_message(progname, lua_pushfstring(L, + "error calling " LUA_QL("print") " (%s)", + lua_tostring(L, -1))); + } + } + lua_settop(L, 0); /* clear stack */ + fputs("\n", stdout); + fflush(stdout); + progname = oldprogname; +} + + +static int handle_script (lua_State *L, char **argv, int n) { + int status; + const char *fname; + int narg = getargs(L, argv, n); /* collect arguments */ + lua_setglobal(L, "arg"); + fname = argv[n]; + if (strcmp(fname, "-") == 0 && strcmp(argv[n-1], "--") != 0) + fname = NULL; /* stdin */ + status = luaL_loadfile(L, fname); + lua_insert(L, -(narg+1)); + if (status == 0) + status = docall(L, narg, 0); + else + lua_pop(L, narg); + return report(L, status); +} + + +/* check that argument has no extra characters at the end */ +#define notail(x) {if ((x)[2] != '\0') return -1;} + + +static int collectargs (char **argv, int *pi, int *pv, int *pe) { + int i; + for (i = 1; argv[i] != NULL; i++) { + if (argv[i][0] != '-') /* not an option? */ + return i; + switch (argv[i][1]) { /* option */ + case '-': + notail(argv[i]); + return (argv[i+1] != NULL ? i+1 : 0); + case '\0': + return i; + case 'i': + notail(argv[i]); + *pi = 1; /* go through */ + case 'v': + notail(argv[i]); + *pv = 1; + break; + case 'e': + *pe = 1; /* go through */ + case 'l': + if (argv[i][2] == '\0') { + i++; + if (argv[i] == NULL) return -1; + } + break; + default: return -1; /* invalid option */ + } + } + return 0; +} + + +static int runargs (lua_State *L, char **argv, int n) { + int i; + for (i = 1; i < n; i++) { + if (argv[i] == NULL) continue; + lua_assert(argv[i][0] == '-'); + switch (argv[i][1]) { /* option */ + case 'e': { + const char *chunk = argv[i] + 2; + if (*chunk == '\0') chunk = argv[++i]; + lua_assert(chunk != NULL); + if (dostring(L, chunk, "=(command line)") != 0) + return 1; + break; + } + case 'l': { + const char *filename = argv[i] + 2; + if (*filename == '\0') filename = argv[++i]; + lua_assert(filename != NULL); + if (dolibrary(L, filename)) + return 1; /* stop if file fails */ + break; + } + default: break; + } + } + return 0; +} + + +static int handle_luainit (lua_State *L) { + const char *init = getenv(LUA_INIT); + if (init == NULL) return 0; /* status OK */ + else if (init[0] == '@') + return dofile(L, init+1); + else + return dostring(L, init, "=" LUA_INIT); +} + + +struct Smain { + int argc; + char **argv; + int status; +}; + + +static int pmain (lua_State *L) { + struct Smain *s = (struct Smain *)lua_touserdata(L, 1); + char **argv = s->argv; + int script; + int has_i = 0, has_v = 0, has_e = 0; + globalL = L; + if (argv[0] && argv[0][0]) progname = argv[0]; + lua_gc(L, LUA_GCSTOP, 0); /* stop collector during initialization */ + luaL_openlibs(L); /* open libraries */ + lua_gc(L, LUA_GCRESTART, 0); + s->status = handle_luainit(L); + if (s->status != 0) return 0; + script = collectargs(argv, &has_i, &has_v, &has_e); + if (script < 0) { /* invalid args? */ + print_usage(); + s->status = 1; + return 0; + } + if (has_v) print_version(); + s->status = runargs(L, argv, (script > 0) ? script : s->argc); + if (s->status != 0) return 0; + if (script) + s->status = handle_script(L, argv, script); + if (s->status != 0) return 0; + if (has_i) + dotty(L); + else if (script == 0 && !has_e && !has_v) { + if (lua_stdin_is_tty()) { + print_version(); + dotty(L); + } + else dofile(L, NULL); /* executes stdin as a file */ + } + return 0; +} + +int main (int argc, char **argv) { + int status; + struct Smain s; + lua_State *L = lua_open(); /* create state */ + if (L == NULL) { + l_message(argv[0], "cannot create state: not enough memory"); + return EXIT_FAILURE; + } + s.argc = argc; + s.argv = argv; + status = lua_cpcall(L, &pmain, &s); + report(L, status); + lua_close(L); + return (status || s.status) ? EXIT_FAILURE : EXIT_SUCCESS; +} + diff --git a/mylua/lua/lua.h b/mylua/lua/lua.h new file mode 100644 index 0000000..e4bdfd3 --- /dev/null +++ b/mylua/lua/lua.h @@ -0,0 +1,388 @@ +/* +** $Id: lua.h,v 1.218.1.5 2008/08/06 13:30:12 roberto Exp $ +** Lua - An Extensible Extension Language +** Lua.org, PUC-Rio, Brazil (http://www.lua.org) +** See Copyright Notice at the end of this file +*/ + + +#ifndef lua_h +#define lua_h + +#include +#include + + +#include "luaconf.h" + + +#define LUA_VERSION "Lua 5.1" +#define LUA_RELEASE "Lua 5.1.4" +#define LUA_VERSION_NUM 501 +#define LUA_COPYRIGHT "Copyright (C) 1994-2008 Lua.org, PUC-Rio" +#define LUA_AUTHORS "R. Ierusalimschy, L. H. de Figueiredo & W. Celes" + + +/* mark for precompiled code (`Lua') */ +#define LUA_SIGNATURE "\033Lua" + +/* option for multiple returns in `lua_pcall' and `lua_call' */ +#define LUA_MULTRET (-1) + + +/* +** pseudo-indices +*/ +#define LUA_REGISTRYINDEX (-10000) +#define LUA_ENVIRONINDEX (-10001) +#define LUA_GLOBALSINDEX (-10002) +#define lua_upvalueindex(i) (LUA_GLOBALSINDEX-(i)) + + +/* thread status; 0 is OK */ +#define LUA_YIELD 1 +#define LUA_ERRRUN 2 +#define LUA_ERRSYNTAX 3 +#define LUA_ERRMEM 4 +#define LUA_ERRERR 5 + + +typedef struct lua_State lua_State; + +typedef int (*lua_CFunction) (lua_State *L); + + +/* +** functions that read/write blocks when loading/dumping Lua chunks +*/ +typedef const char * (*lua_Reader) (lua_State *L, void *ud, size_t *sz); + +typedef int (*lua_Writer) (lua_State *L, const void* p, size_t sz, void* ud); + + +/* +** prototype for memory-allocation functions +*/ +typedef void * (*lua_Alloc) (void *ud, void *ptr, size_t osize, size_t nsize); + + +/* +** basic types +*/ +#define LUA_TNONE (-1) + +#define LUA_TNIL 0 +#define LUA_TBOOLEAN 1 +#define LUA_TLIGHTUSERDATA 2 +#define LUA_TNUMBER 3 +#define LUA_TSTRING 4 +#define LUA_TTABLE 5 +#define LUA_TFUNCTION 6 +#define LUA_TUSERDATA 7 +#define LUA_TTHREAD 8 + + + +/* minimum Lua stack available to a C function */ +#define LUA_MINSTACK 20 + + +/* +** generic extra include file +*/ +#if defined(LUA_USER_H) +#include LUA_USER_H +#endif + + +/* type of numbers in Lua */ +typedef LUA_NUMBER lua_Number; + + +/* type for integer functions */ +typedef LUA_INTEGER lua_Integer; + + + +/* +** state manipulation +*/ +LUA_API lua_State *(lua_newstate) (lua_Alloc f, void *ud); +LUA_API void (lua_close) (lua_State *L); +LUA_API lua_State *(lua_newthread) (lua_State *L); + +LUA_API lua_CFunction (lua_atpanic) (lua_State *L, lua_CFunction panicf); + + +/* +** basic stack manipulation +*/ +LUA_API int (lua_gettop) (lua_State *L); +LUA_API void (lua_settop) (lua_State *L, int idx); +LUA_API void (lua_pushvalue) (lua_State *L, int idx); +LUA_API void (lua_remove) (lua_State *L, int idx); +LUA_API void (lua_insert) (lua_State *L, int idx); +LUA_API void (lua_replace) (lua_State *L, int idx); +LUA_API int (lua_checkstack) (lua_State *L, int sz); + +LUA_API void (lua_xmove) (lua_State *from, lua_State *to, int n); + + +/* +** access functions (stack -> C) +*/ + +LUA_API int (lua_isnumber) (lua_State *L, int idx); +LUA_API int (lua_isstring) (lua_State *L, int idx); +LUA_API int (lua_iscfunction) (lua_State *L, int idx); +LUA_API int (lua_isuserdata) (lua_State *L, int idx); +LUA_API int (lua_type) (lua_State *L, int idx); +LUA_API const char *(lua_typename) (lua_State *L, int tp); + +LUA_API int (lua_equal) (lua_State *L, int idx1, int idx2); +LUA_API int (lua_rawequal) (lua_State *L, int idx1, int idx2); +LUA_API int (lua_lessthan) (lua_State *L, int idx1, int idx2); + +LUA_API lua_Number (lua_tonumber) (lua_State *L, int idx); +LUA_API lua_Integer (lua_tointeger) (lua_State *L, int idx); +LUA_API int (lua_toboolean) (lua_State *L, int idx); +LUA_API const char *(lua_tolstring) (lua_State *L, int idx, size_t *len); +LUA_API size_t (lua_objlen) (lua_State *L, int idx); +LUA_API lua_CFunction (lua_tocfunction) (lua_State *L, int idx); +LUA_API void *(lua_touserdata) (lua_State *L, int idx); +LUA_API lua_State *(lua_tothread) (lua_State *L, int idx); +LUA_API const void *(lua_topointer) (lua_State *L, int idx); + + +/* +** push functions (C -> stack) +*/ +LUA_API void (lua_pushnil) (lua_State *L); +LUA_API void (lua_pushnumber) (lua_State *L, lua_Number n); +LUA_API void (lua_pushinteger) (lua_State *L, lua_Integer n); +LUA_API void (lua_pushlstring) (lua_State *L, const char *s, size_t l); +LUA_API void (lua_pushstring) (lua_State *L, const char *s); +LUA_API const char *(lua_pushvfstring) (lua_State *L, const char *fmt, + va_list argp); +LUA_API const char *(lua_pushfstring) (lua_State *L, const char *fmt, ...); +LUA_API void (lua_pushcclosure) (lua_State *L, lua_CFunction fn, int n); +LUA_API void (lua_pushboolean) (lua_State *L, int b); +LUA_API void (lua_pushlightuserdata) (lua_State *L, void *p); +LUA_API int (lua_pushthread) (lua_State *L); + + +/* +** get functions (Lua -> stack) +*/ +LUA_API void (lua_gettable) (lua_State *L, int idx); +LUA_API void (lua_getfield) (lua_State *L, int idx, const char *k); +LUA_API void (lua_rawget) (lua_State *L, int idx); +LUA_API void (lua_rawgeti) (lua_State *L, int idx, int n); +LUA_API void (lua_createtable) (lua_State *L, int narr, int nrec); +LUA_API void *(lua_newuserdata) (lua_State *L, size_t sz); +LUA_API int (lua_getmetatable) (lua_State *L, int objindex); +LUA_API void (lua_getfenv) (lua_State *L, int idx); + + +/* +** set functions (stack -> Lua) +*/ +LUA_API void (lua_settable) (lua_State *L, int idx); +LUA_API void (lua_setfield) (lua_State *L, int idx, const char *k); +LUA_API void (lua_rawset) (lua_State *L, int idx); +LUA_API void (lua_rawseti) (lua_State *L, int idx, int n); +LUA_API int (lua_setmetatable) (lua_State *L, int objindex); +LUA_API int (lua_setfenv) (lua_State *L, int idx); + + +/* +** `load' and `call' functions (load and run Lua code) +*/ +LUA_API void (lua_call) (lua_State *L, int nargs, int nresults); +LUA_API int (lua_pcall) (lua_State *L, int nargs, int nresults, int errfunc); +LUA_API int (lua_cpcall) (lua_State *L, lua_CFunction func, void *ud); +LUA_API int (lua_load) (lua_State *L, lua_Reader reader, void *dt, + const char *chunkname); + +LUA_API int (lua_dump) (lua_State *L, lua_Writer writer, void *data); + + +/* +** coroutine functions +*/ +LUA_API int (lua_yield) (lua_State *L, int nresults); +LUA_API int (lua_resume) (lua_State *L, int narg); +LUA_API int (lua_status) (lua_State *L); + +/* +** garbage-collection function and options +*/ + +#define LUA_GCSTOP 0 +#define LUA_GCRESTART 1 +#define LUA_GCCOLLECT 2 +#define LUA_GCCOUNT 3 +#define LUA_GCCOUNTB 4 +#define LUA_GCSTEP 5 +#define LUA_GCSETPAUSE 6 +#define LUA_GCSETSTEPMUL 7 + +LUA_API int (lua_gc) (lua_State *L, int what, int data); + + +/* +** miscellaneous functions +*/ + +LUA_API int (lua_error) (lua_State *L); + +LUA_API int (lua_next) (lua_State *L, int idx); + +LUA_API void (lua_concat) (lua_State *L, int n); + +LUA_API lua_Alloc (lua_getallocf) (lua_State *L, void **ud); +LUA_API void lua_setallocf (lua_State *L, lua_Alloc f, void *ud); + + + +/* +** =============================================================== +** some useful macros +** =============================================================== +*/ + +#define lua_pop(L,n) lua_settop(L, -(n)-1) + +#define lua_newtable(L) lua_createtable(L, 0, 0) + +#define lua_register(L,n,f) (lua_pushcfunction(L, (f)), lua_setglobal(L, (n))) + +#define lua_pushcfunction(L,f) lua_pushcclosure(L, (f), 0) + +#define lua_strlen(L,i) lua_objlen(L, (i)) + +#define lua_isfunction(L,n) (lua_type(L, (n)) == LUA_TFUNCTION) +#define lua_istable(L,n) (lua_type(L, (n)) == LUA_TTABLE) +#define lua_islightuserdata(L,n) (lua_type(L, (n)) == LUA_TLIGHTUSERDATA) +#define lua_isnil(L,n) (lua_type(L, (n)) == LUA_TNIL) +#define lua_isboolean(L,n) (lua_type(L, (n)) == LUA_TBOOLEAN) +#define lua_isthread(L,n) (lua_type(L, (n)) == LUA_TTHREAD) +#define lua_isnone(L,n) (lua_type(L, (n)) == LUA_TNONE) +#define lua_isnoneornil(L, n) (lua_type(L, (n)) <= 0) + +#define lua_pushliteral(L, s) \ + lua_pushlstring(L, "" s, (sizeof(s)/sizeof(char))-1) + +#define lua_setglobal(L,s) lua_setfield(L, LUA_GLOBALSINDEX, (s)) +#define lua_getglobal(L,s) lua_getfield(L, LUA_GLOBALSINDEX, (s)) + +#define lua_tostring(L,i) lua_tolstring(L, (i), NULL) + + + +/* +** compatibility macros and functions +*/ + +#define lua_open() luaL_newstate() + +#define lua_getregistry(L) lua_pushvalue(L, LUA_REGISTRYINDEX) + +#define lua_getgccount(L) lua_gc(L, LUA_GCCOUNT, 0) + +#define lua_Chunkreader lua_Reader +#define lua_Chunkwriter lua_Writer + + +/* hack */ +LUA_API void lua_setlevel (lua_State *from, lua_State *to); + + +/* +** {====================================================================== +** Debug API +** ======================================================================= +*/ + + +/* +** Event codes +*/ +#define LUA_HOOKCALL 0 +#define LUA_HOOKRET 1 +#define LUA_HOOKLINE 2 +#define LUA_HOOKCOUNT 3 +#define LUA_HOOKTAILRET 4 + + +/* +** Event masks +*/ +#define LUA_MASKCALL (1 << LUA_HOOKCALL) +#define LUA_MASKRET (1 << LUA_HOOKRET) +#define LUA_MASKLINE (1 << LUA_HOOKLINE) +#define LUA_MASKCOUNT (1 << LUA_HOOKCOUNT) + +typedef struct lua_Debug lua_Debug; /* activation record */ + + +/* Functions to be called by the debuger in specific events */ +typedef void (*lua_Hook) (lua_State *L, lua_Debug *ar); + + +LUA_API int lua_getstack (lua_State *L, int level, lua_Debug *ar); +LUA_API int lua_getinfo (lua_State *L, const char *what, lua_Debug *ar); +LUA_API const char *lua_getlocal (lua_State *L, const lua_Debug *ar, int n); +LUA_API const char *lua_setlocal (lua_State *L, const lua_Debug *ar, int n); +LUA_API const char *lua_getupvalue (lua_State *L, int funcindex, int n); +LUA_API const char *lua_setupvalue (lua_State *L, int funcindex, int n); + +LUA_API int lua_sethook (lua_State *L, lua_Hook func, int mask, int count); +LUA_API lua_Hook lua_gethook (lua_State *L); +LUA_API int lua_gethookmask (lua_State *L); +LUA_API int lua_gethookcount (lua_State *L); + + +struct lua_Debug { + int event; + const char *name; /* (n) */ + const char *namewhat; /* (n) `global', `local', `field', `method' */ + const char *what; /* (S) `Lua', `C', `main', `tail' */ + const char *source; /* (S) */ + int currentline; /* (l) */ + int nups; /* (u) number of upvalues */ + int linedefined; /* (S) */ + int lastlinedefined; /* (S) */ + char short_src[LUA_IDSIZE]; /* (S) */ + /* private part */ + int i_ci; /* active function */ +}; + +/* }====================================================================== */ + + +/****************************************************************************** +* Copyright (C) 1994-2008 Lua.org, PUC-Rio. All rights reserved. +* +* Permission is hereby granted, free of charge, to any person obtaining +* a copy of this software and associated documentation files (the +* "Software"), to deal in the Software without restriction, including +* without limitation the rights to use, copy, modify, merge, publish, +* distribute, sublicense, and/or sell copies of the Software, and to +* permit persons to whom the Software is furnished to do so, subject to +* the following conditions: +* +* The above copyright notice and this permission notice shall be +* included in all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +******************************************************************************/ + + +#endif diff --git a/mylua/lua/luac b/mylua/lua/luac new file mode 100644 index 0000000..7f204e8 Binary files /dev/null and b/mylua/lua/luac differ diff --git a/mylua/lua/luac.c b/mylua/lua/luac.c new file mode 100644 index 0000000..d070173 --- /dev/null +++ b/mylua/lua/luac.c @@ -0,0 +1,200 @@ +/* +** $Id: luac.c,v 1.54 2006/06/02 17:37:11 lhf Exp $ +** Lua compiler (saves bytecodes to files; also list bytecodes) +** See Copyright Notice in lua.h +*/ + +#include +#include +#include +#include + +#define luac_c +#define LUA_CORE + +#include "lua.h" +#include "lauxlib.h" + +#include "ldo.h" +#include "lfunc.h" +#include "lmem.h" +#include "lobject.h" +#include "lopcodes.h" +#include "lstring.h" +#include "lundump.h" + +#define PROGNAME "luac" /* default program name */ +#define OUTPUT PROGNAME ".out" /* default output file */ + +static int listing=0; /* list bytecodes? */ +static int dumping=1; /* dump bytecodes? */ +static int stripping=0; /* strip debug information? */ +static char Output[]={ OUTPUT }; /* default output file name */ +static const char* output=Output; /* actual output file name */ +static const char* progname=PROGNAME; /* actual program name */ + +static void fatal(const char* message) +{ + fprintf(stderr,"%s: %s\n",progname,message); + exit(EXIT_FAILURE); +} + +static void cannot(const char* what) +{ + fprintf(stderr,"%s: cannot %s %s: %s\n",progname,what,output,strerror(errno)); + exit(EXIT_FAILURE); +} + +static void usage(const char* message) +{ + if (*message=='-') + fprintf(stderr,"%s: unrecognized option " LUA_QS "\n",progname,message); + else + fprintf(stderr,"%s: %s\n",progname,message); + fprintf(stderr, + "usage: %s [options] [filenames].\n" + "Available options are:\n" + " - process stdin\n" + " -l list\n" + " -o name output to file " LUA_QL("name") " (default is \"%s\")\n" + " -p parse only\n" + " -s strip debug information\n" + " -v show version information\n" + " -- stop handling options\n", + progname,Output); + exit(EXIT_FAILURE); +} + +#define IS(s) (strcmp(argv[i],s)==0) + +static int doargs(int argc, char* argv[]) +{ + int i; + int version=0; + if (argv[0]!=NULL && *argv[0]!=0) progname=argv[0]; + for (i=1; itop+(i))->l.p) + +static const Proto* combine(lua_State* L, int n) +{ + if (n==1) + return toproto(L,-1); + else + { + int i,pc; + Proto* f=luaF_newproto(L); + setptvalue2s(L,L->top,f); incr_top(L); + f->source=luaS_newliteral(L,"=(" PROGNAME ")"); + f->maxstacksize=1; + pc=2*n+1; + f->code=luaM_newvector(L,pc,Instruction); + f->sizecode=pc; + f->p=luaM_newvector(L,n,Proto*); + f->sizep=n; + pc=0; + for (i=0; ip[i]=toproto(L,i-n-1); + f->code[pc++]=CREATE_ABx(OP_CLOSURE,0,i); + f->code[pc++]=CREATE_ABC(OP_CALL,0,1,1); + } + f->code[pc++]=CREATE_ABC(OP_RETURN,0,1,0); + return f; + } +} + +static int writer(lua_State* L, const void* p, size_t size, void* u) +{ + UNUSED(L); + return (fwrite(p,size,1,(FILE*)u)!=1) && (size!=0); +} + +struct Smain { + int argc; + char** argv; +}; + +static int pmain(lua_State* L) +{ + struct Smain* s = (struct Smain*)lua_touserdata(L, 1); + int argc=s->argc; + char** argv=s->argv; + const Proto* f; + int i; + if (!lua_checkstack(L,argc)) fatal("too many input files"); + for (i=0; i1); + if (dumping) + { + FILE* D= (output==NULL) ? stdout : fopen(output,"wb"); + if (D==NULL) cannot("open"); + lua_lock(L); + luaU_dump(L,f,writer,D,stripping); + lua_unlock(L); + if (ferror(D)) cannot("write"); + if (fclose(D)) cannot("close"); + } + return 0; +} + +int main(int argc, char* argv[]) +{ + lua_State* L; + struct Smain s; + int i=doargs(argc,argv); + argc-=i; argv+=i; + if (argc<=0) usage("no input files given"); + L=lua_open(); + if (L==NULL) fatal("not enough memory for state"); + s.argc=argc; + s.argv=argv; + if (lua_cpcall(L,pmain,&s)!=0) fatal(lua_tostring(L,-1)); + lua_close(L); + return EXIT_SUCCESS; +} diff --git a/mylua/lua/luaconf.h b/mylua/lua/luaconf.h new file mode 100644 index 0000000..e2cb261 --- /dev/null +++ b/mylua/lua/luaconf.h @@ -0,0 +1,763 @@ +/* +** $Id: luaconf.h,v 1.82.1.7 2008/02/11 16:25:08 roberto Exp $ +** Configuration file for Lua +** See Copyright Notice in lua.h +*/ + + +#ifndef lconfig_h +#define lconfig_h + +#include +#include + + +/* +** ================================================================== +** Search for "@@" to find all configurable definitions. +** =================================================================== +*/ + + +/* +@@ LUA_ANSI controls the use of non-ansi features. +** CHANGE it (define it) if you want Lua to avoid the use of any +** non-ansi feature or library. +*/ +#if defined(__STRICT_ANSI__) +#define LUA_ANSI +#endif + + +#if !defined(LUA_ANSI) && defined(_WIN32) +#define LUA_WIN +#endif + +#if defined(LUA_USE_LINUX) +#define LUA_USE_POSIX +#define LUA_USE_DLOPEN /* needs an extra library: -ldl */ +#define LUA_USE_READLINE /* needs some extra libraries */ +#endif + +#if defined(LUA_USE_MACOSX) +#define LUA_USE_POSIX +#define LUA_DL_DYLD /* does not need extra library */ +#endif + + + +/* +@@ LUA_USE_POSIX includes all functionallity listed as X/Open System +@* Interfaces Extension (XSI). +** CHANGE it (define it) if your system is XSI compatible. +*/ +#if defined(LUA_USE_POSIX) +#define LUA_USE_MKSTEMP +#define LUA_USE_ISATTY +#define LUA_USE_POPEN +#define LUA_USE_ULONGJMP +#endif + + +/* +@@ LUA_PATH and LUA_CPATH are the names of the environment variables that +@* Lua check to set its paths. +@@ LUA_INIT is the name of the environment variable that Lua +@* checks for initialization code. +** CHANGE them if you want different names. +*/ +#define LUA_PATH "LUA_PATH" +#define LUA_CPATH "LUA_CPATH" +#define LUA_INIT "LUA_INIT" + + +/* +@@ LUA_PATH_DEFAULT is the default path that Lua uses to look for +@* Lua libraries. +@@ LUA_CPATH_DEFAULT is the default path that Lua uses to look for +@* C libraries. +** CHANGE them if your machine has a non-conventional directory +** hierarchy or if you want to install your libraries in +** non-conventional directories. +*/ +#if defined(_WIN32) +/* +** In Windows, any exclamation mark ('!') in the path is replaced by the +** path of the directory of the executable file of the current process. +*/ +#define LUA_LDIR "!\\lua\\" +#define LUA_CDIR "!\\" +#define LUA_PATH_DEFAULT \ + ".\\?.lua;" LUA_LDIR"?.lua;" LUA_LDIR"?\\init.lua;" \ + LUA_CDIR"?.lua;" LUA_CDIR"?\\init.lua" +#define LUA_CPATH_DEFAULT \ + ".\\?.dll;" LUA_CDIR"?.dll;" LUA_CDIR"loadall.dll" + +#else +#define LUA_ROOT "/usr/local/" +#define LUA_LDIR LUA_ROOT "share/lua/5.1/" +#define LUA_CDIR LUA_ROOT "lib/lua/5.1/" +#define LUA_PATH_DEFAULT \ + "./?.lua;" LUA_LDIR"?.lua;" LUA_LDIR"?/init.lua;" \ + LUA_CDIR"?.lua;" LUA_CDIR"?/init.lua" +#define LUA_CPATH_DEFAULT \ + "./?.so;" LUA_CDIR"?.so;" LUA_CDIR"loadall.so" +#endif + + +/* +@@ LUA_DIRSEP is the directory separator (for submodules). +** CHANGE it if your machine does not use "/" as the directory separator +** and is not Windows. (On Windows Lua automatically uses "\".) +*/ +#if defined(_WIN32) +#define LUA_DIRSEP "\\" +#else +#define LUA_DIRSEP "/" +#endif + + +/* +@@ LUA_PATHSEP is the character that separates templates in a path. +@@ LUA_PATH_MARK is the string that marks the substitution points in a +@* template. +@@ LUA_EXECDIR in a Windows path is replaced by the executable's +@* directory. +@@ LUA_IGMARK is a mark to ignore all before it when bulding the +@* luaopen_ function name. +** CHANGE them if for some reason your system cannot use those +** characters. (E.g., if one of those characters is a common character +** in file/directory names.) Probably you do not need to change them. +*/ +#define LUA_PATHSEP ";" +#define LUA_PATH_MARK "?" +#define LUA_EXECDIR "!" +#define LUA_IGMARK "-" + + +/* +@@ LUA_INTEGER is the integral type used by lua_pushinteger/lua_tointeger. +** CHANGE that if ptrdiff_t is not adequate on your machine. (On most +** machines, ptrdiff_t gives a good choice between int or long.) +*/ +#define LUA_INTEGER ptrdiff_t + + +/* +@@ LUA_API is a mark for all core API functions. +@@ LUALIB_API is a mark for all standard library functions. +** CHANGE them if you need to define those functions in some special way. +** For instance, if you want to create one Windows DLL with the core and +** the libraries, you may want to use the following definition (define +** LUA_BUILD_AS_DLL to get it). +*/ +#if defined(LUA_BUILD_AS_DLL) + +#if defined(LUA_CORE) || defined(LUA_LIB) +#define LUA_API __declspec(dllexport) +#else +#define LUA_API __declspec(dllimport) +#endif + +#else + +#define LUA_API extern + +#endif + +/* more often than not the libs go together with the core */ +#define LUALIB_API LUA_API + + +/* +@@ LUAI_FUNC is a mark for all extern functions that are not to be +@* exported to outside modules. +@@ LUAI_DATA is a mark for all extern (const) variables that are not to +@* be exported to outside modules. +** CHANGE them if you need to mark them in some special way. Elf/gcc +** (versions 3.2 and later) mark them as "hidden" to optimize access +** when Lua is compiled as a shared library. +*/ +#if defined(luaall_c) +#define LUAI_FUNC static +#define LUAI_DATA /* empty */ + +#elif defined(__GNUC__) && ((__GNUC__*100 + __GNUC_MINOR__) >= 302) && \ + defined(__ELF__) +#define LUAI_FUNC __attribute__((visibility("hidden"))) extern +#define LUAI_DATA LUAI_FUNC + +#else +#define LUAI_FUNC extern +#define LUAI_DATA extern +#endif + + + +/* +@@ LUA_QL describes how error messages quote program elements. +** CHANGE it if you want a different appearance. +*/ +#define LUA_QL(x) "'" x "'" +#define LUA_QS LUA_QL("%s") + + +/* +@@ LUA_IDSIZE gives the maximum size for the description of the source +@* of a function in debug information. +** CHANGE it if you want a different size. +*/ +#define LUA_IDSIZE 60 + + +/* +** {================================================================== +** Stand-alone configuration +** =================================================================== +*/ + +#if defined(lua_c) || defined(luaall_c) + +/* +@@ lua_stdin_is_tty detects whether the standard input is a 'tty' (that +@* is, whether we're running lua interactively). +** CHANGE it if you have a better definition for non-POSIX/non-Windows +** systems. +*/ +#if defined(LUA_USE_ISATTY) +#include +#define lua_stdin_is_tty() isatty(0) +#elif defined(LUA_WIN) +#include +#include +#define lua_stdin_is_tty() _isatty(_fileno(stdin)) +#else +#define lua_stdin_is_tty() 1 /* assume stdin is a tty */ +#endif + + +/* +@@ LUA_PROMPT is the default prompt used by stand-alone Lua. +@@ LUA_PROMPT2 is the default continuation prompt used by stand-alone Lua. +** CHANGE them if you want different prompts. (You can also change the +** prompts dynamically, assigning to globals _PROMPT/_PROMPT2.) +*/ +#define LUA_PROMPT "> " +#define LUA_PROMPT2 ">> " + + +/* +@@ LUA_PROGNAME is the default name for the stand-alone Lua program. +** CHANGE it if your stand-alone interpreter has a different name and +** your system is not able to detect that name automatically. +*/ +#define LUA_PROGNAME "lua" + + +/* +@@ LUA_MAXINPUT is the maximum length for an input line in the +@* stand-alone interpreter. +** CHANGE it if you need longer lines. +*/ +#define LUA_MAXINPUT 512 + + +/* +@@ lua_readline defines how to show a prompt and then read a line from +@* the standard input. +@@ lua_saveline defines how to "save" a read line in a "history". +@@ lua_freeline defines how to free a line read by lua_readline. +** CHANGE them if you want to improve this functionality (e.g., by using +** GNU readline and history facilities). +*/ +#if defined(LUA_USE_READLINE) +#include +#include +#include +#define lua_readline(L,b,p) ((void)L, ((b)=readline(p)) != NULL) +#define lua_saveline(L,idx) \ + if (lua_strlen(L,idx) > 0) /* non-empty line? */ \ + add_history(lua_tostring(L, idx)); /* add it to history */ +#define lua_freeline(L,b) ((void)L, free(b)) +#else +#define lua_readline(L,b,p) \ + ((void)L, fputs(p, stdout), fflush(stdout), /* show prompt */ \ + fgets(b, LUA_MAXINPUT, stdin) != NULL) /* get line */ +#define lua_saveline(L,idx) { (void)L; (void)idx; } +#define lua_freeline(L,b) { (void)L; (void)b; } +#endif + +#endif + +/* }================================================================== */ + + +/* +@@ LUAI_GCPAUSE defines the default pause between garbage-collector cycles +@* as a percentage. +** CHANGE it if you want the GC to run faster or slower (higher values +** mean larger pauses which mean slower collection.) You can also change +** this value dynamically. +*/ +#define LUAI_GCPAUSE 200 /* 200% (wait memory to double before next GC) */ + + +/* +@@ LUAI_GCMUL defines the default speed of garbage collection relative to +@* memory allocation as a percentage. +** CHANGE it if you want to change the granularity of the garbage +** collection. (Higher values mean coarser collections. 0 represents +** infinity, where each step performs a full collection.) You can also +** change this value dynamically. +*/ +#define LUAI_GCMUL 200 /* GC runs 'twice the speed' of memory allocation */ + + + +/* +@@ LUA_COMPAT_GETN controls compatibility with old getn behavior. +** CHANGE it (define it) if you want exact compatibility with the +** behavior of setn/getn in Lua 5.0. +*/ +#undef LUA_COMPAT_GETN + +/* +@@ LUA_COMPAT_LOADLIB controls compatibility about global loadlib. +** CHANGE it to undefined as soon as you do not need a global 'loadlib' +** function (the function is still available as 'package.loadlib'). +*/ +#undef LUA_COMPAT_LOADLIB + +/* +@@ LUA_COMPAT_VARARG controls compatibility with old vararg feature. +** CHANGE it to undefined as soon as your programs use only '...' to +** access vararg parameters (instead of the old 'arg' table). +*/ +#define LUA_COMPAT_VARARG + +/* +@@ LUA_COMPAT_MOD controls compatibility with old math.mod function. +** CHANGE it to undefined as soon as your programs use 'math.fmod' or +** the new '%' operator instead of 'math.mod'. +*/ +#define LUA_COMPAT_MOD + +/* +@@ LUA_COMPAT_LSTR controls compatibility with old long string nesting +@* facility. +** CHANGE it to 2 if you want the old behaviour, or undefine it to turn +** off the advisory error when nesting [[...]]. +*/ +#define LUA_COMPAT_LSTR 1 + +/* +@@ LUA_COMPAT_GFIND controls compatibility with old 'string.gfind' name. +** CHANGE it to undefined as soon as you rename 'string.gfind' to +** 'string.gmatch'. +*/ +#define LUA_COMPAT_GFIND + +/* +@@ LUA_COMPAT_OPENLIB controls compatibility with old 'luaL_openlib' +@* behavior. +** CHANGE it to undefined as soon as you replace to 'luaL_register' +** your uses of 'luaL_openlib' +*/ +#define LUA_COMPAT_OPENLIB + + + +/* +@@ luai_apicheck is the assert macro used by the Lua-C API. +** CHANGE luai_apicheck if you want Lua to perform some checks in the +** parameters it gets from API calls. This may slow down the interpreter +** a bit, but may be quite useful when debugging C code that interfaces +** with Lua. A useful redefinition is to use assert.h. +*/ +#if defined(LUA_USE_APICHECK) +#include +#define luai_apicheck(L,o) { (void)L; assert(o); } +#else +#define luai_apicheck(L,o) { (void)L; } +#endif + + +/* +@@ LUAI_BITSINT defines the number of bits in an int. +** CHANGE here if Lua cannot automatically detect the number of bits of +** your machine. Probably you do not need to change this. +*/ +/* avoid overflows in comparison */ +#if INT_MAX-20 < 32760 +#define LUAI_BITSINT 16 +#elif INT_MAX > 2147483640L +/* int has at least 32 bits */ +#define LUAI_BITSINT 32 +#else +#error "you must define LUA_BITSINT with number of bits in an integer" +#endif + + +/* +@@ LUAI_UINT32 is an unsigned integer with at least 32 bits. +@@ LUAI_INT32 is an signed integer with at least 32 bits. +@@ LUAI_UMEM is an unsigned integer big enough to count the total +@* memory used by Lua. +@@ LUAI_MEM is a signed integer big enough to count the total memory +@* used by Lua. +** CHANGE here if for some weird reason the default definitions are not +** good enough for your machine. (The definitions in the 'else' +** part always works, but may waste space on machines with 64-bit +** longs.) Probably you do not need to change this. +*/ +#if LUAI_BITSINT >= 32 +#define LUAI_UINT32 unsigned int +#define LUAI_INT32 int +#define LUAI_MAXINT32 INT_MAX +#define LUAI_UMEM size_t +#define LUAI_MEM ptrdiff_t +#else +/* 16-bit ints */ +#define LUAI_UINT32 unsigned long +#define LUAI_INT32 long +#define LUAI_MAXINT32 LONG_MAX +#define LUAI_UMEM unsigned long +#define LUAI_MEM long +#endif + + +/* +@@ LUAI_MAXCALLS limits the number of nested calls. +** CHANGE it if you need really deep recursive calls. This limit is +** arbitrary; its only purpose is to stop infinite recursion before +** exhausting memory. +*/ +#define LUAI_MAXCALLS 20000 + + +/* +@@ LUAI_MAXCSTACK limits the number of Lua stack slots that a C function +@* can use. +** CHANGE it if you need lots of (Lua) stack space for your C +** functions. This limit is arbitrary; its only purpose is to stop C +** functions to consume unlimited stack space. (must be smaller than +** -LUA_REGISTRYINDEX) +*/ +#define LUAI_MAXCSTACK 8000 + + + +/* +** {================================================================== +** CHANGE (to smaller values) the following definitions if your system +** has a small C stack. (Or you may want to change them to larger +** values if your system has a large C stack and these limits are +** too rigid for you.) Some of these constants control the size of +** stack-allocated arrays used by the compiler or the interpreter, while +** others limit the maximum number of recursive calls that the compiler +** or the interpreter can perform. Values too large may cause a C stack +** overflow for some forms of deep constructs. +** =================================================================== +*/ + + +/* +@@ LUAI_MAXCCALLS is the maximum depth for nested C calls (short) and +@* syntactical nested non-terminals in a program. +*/ +#define LUAI_MAXCCALLS 200 + + +/* +@@ LUAI_MAXVARS is the maximum number of local variables per function +@* (must be smaller than 250). +*/ +#define LUAI_MAXVARS 200 + + +/* +@@ LUAI_MAXUPVALUES is the maximum number of upvalues per function +@* (must be smaller than 250). +*/ +#define LUAI_MAXUPVALUES 60 + + +/* +@@ LUAL_BUFFERSIZE is the buffer size used by the lauxlib buffer system. +*/ +#define LUAL_BUFFERSIZE BUFSIZ + +/* }================================================================== */ + + + + +/* +** {================================================================== +@@ LUA_NUMBER is the type of numbers in Lua. +** CHANGE the following definitions only if you want to build Lua +** with a number type different from double. You may also need to +** change lua_number2int & lua_number2integer. +** =================================================================== +*/ + +#define LUA_NUMBER_DOUBLE +#define LUA_NUMBER double + +/* +@@ LUAI_UACNUMBER is the result of an 'usual argument conversion' +@* over a number. +*/ +#define LUAI_UACNUMBER double + + +/* +@@ LUA_NUMBER_SCAN is the format for reading numbers. +@@ LUA_NUMBER_FMT is the format for writing numbers. +@@ lua_number2str converts a number to a string. +@@ LUAI_MAXNUMBER2STR is maximum size of previous conversion. +@@ lua_str2number converts a string to a number. +*/ +#define LUA_NUMBER_SCAN "%lf" +#define LUA_NUMBER_FMT "%.14g" +#define lua_number2str(s,n) sprintf((s), LUA_NUMBER_FMT, (n)) +#define LUAI_MAXNUMBER2STR 32 /* 16 digits, sign, point, and \0 */ +#define lua_str2number(s,p) strtod((s), (p)) + + +/* +@@ The luai_num* macros define the primitive operations over numbers. +*/ +#if defined(LUA_CORE) +#include +#define luai_numadd(a,b) ((a)+(b)) +#define luai_numsub(a,b) ((a)-(b)) +#define luai_nummul(a,b) ((a)*(b)) +#define luai_numdiv(a,b) ((a)/(b)) +#define luai_nummod(a,b) ((a) - floor((a)/(b))*(b)) +#define luai_numpow(a,b) (pow(a,b)) +#define luai_numunm(a) (-(a)) +#define luai_numeq(a,b) ((a)==(b)) +#define luai_numlt(a,b) ((a)<(b)) +#define luai_numle(a,b) ((a)<=(b)) +#define luai_numisnan(a) (!luai_numeq((a), (a))) +#endif + + +/* +@@ lua_number2int is a macro to convert lua_Number to int. +@@ lua_number2integer is a macro to convert lua_Number to lua_Integer. +** CHANGE them if you know a faster way to convert a lua_Number to +** int (with any rounding method and without throwing errors) in your +** system. In Pentium machines, a naive typecast from double to int +** in C is extremely slow, so any alternative is worth trying. +*/ + +/* On a Pentium, resort to a trick */ +#if defined(LUA_NUMBER_DOUBLE) && !defined(LUA_ANSI) && !defined(__SSE2__) && \ + (defined(__i386) || defined (_M_IX86) || defined(__i386__)) + +/* On a Microsoft compiler, use assembler */ +#if defined(_MSC_VER) + +#define lua_number2int(i,d) __asm fld d __asm fistp i +#define lua_number2integer(i,n) lua_number2int(i, n) + +/* the next trick should work on any Pentium, but sometimes clashes + with a DirectX idiosyncrasy */ +#else + +union luai_Cast { double l_d; long l_l; }; +#define lua_number2int(i,d) \ + { volatile union luai_Cast u; u.l_d = (d) + 6755399441055744.0; (i) = u.l_l; } +#define lua_number2integer(i,n) lua_number2int(i, n) + +#endif + + +/* this option always works, but may be slow */ +#else +#define lua_number2int(i,d) ((i)=(int)(d)) +#define lua_number2integer(i,d) ((i)=(lua_Integer)(d)) + +#endif + +/* }================================================================== */ + + +/* +@@ LUAI_USER_ALIGNMENT_T is a type that requires maximum alignment. +** CHANGE it if your system requires alignments larger than double. (For +** instance, if your system supports long doubles and they must be +** aligned in 16-byte boundaries, then you should add long double in the +** union.) Probably you do not need to change this. +*/ +#define LUAI_USER_ALIGNMENT_T union { double u; void *s; long l; } + + +/* +@@ LUAI_THROW/LUAI_TRY define how Lua does exception handling. +** CHANGE them if you prefer to use longjmp/setjmp even with C++ +** or if want/don't to use _longjmp/_setjmp instead of regular +** longjmp/setjmp. By default, Lua handles errors with exceptions when +** compiling as C++ code, with _longjmp/_setjmp when asked to use them, +** and with longjmp/setjmp otherwise. +*/ +#if defined(__cplusplus) +/* C++ exceptions */ +#define LUAI_THROW(L,c) throw(c) +#define LUAI_TRY(L,c,a) try { a } catch(...) \ + { if ((c)->status == 0) (c)->status = -1; } +#define luai_jmpbuf int /* dummy variable */ + +#elif defined(LUA_USE_ULONGJMP) +/* in Unix, try _longjmp/_setjmp (more efficient) */ +#define LUAI_THROW(L,c) _longjmp((c)->b, 1) +#define LUAI_TRY(L,c,a) if (_setjmp((c)->b) == 0) { a } +#define luai_jmpbuf jmp_buf + +#else +/* default handling with long jumps */ +#define LUAI_THROW(L,c) longjmp((c)->b, 1) +#define LUAI_TRY(L,c,a) if (setjmp((c)->b) == 0) { a } +#define luai_jmpbuf jmp_buf + +#endif + + +/* +@@ LUA_MAXCAPTURES is the maximum number of captures that a pattern +@* can do during pattern-matching. +** CHANGE it if you need more captures. This limit is arbitrary. +*/ +#define LUA_MAXCAPTURES 32 + + +/* +@@ lua_tmpnam is the function that the OS library uses to create a +@* temporary name. +@@ LUA_TMPNAMBUFSIZE is the maximum size of a name created by lua_tmpnam. +** CHANGE them if you have an alternative to tmpnam (which is considered +** insecure) or if you want the original tmpnam anyway. By default, Lua +** uses tmpnam except when POSIX is available, where it uses mkstemp. +*/ +#if defined(loslib_c) || defined(luaall_c) + +#if defined(LUA_USE_MKSTEMP) +#include +#define LUA_TMPNAMBUFSIZE 32 +#define lua_tmpnam(b,e) { \ + strcpy(b, "/tmp/lua_XXXXXX"); \ + e = mkstemp(b); \ + if (e != -1) close(e); \ + e = (e == -1); } + +#else +#define LUA_TMPNAMBUFSIZE L_tmpnam +#define lua_tmpnam(b,e) { e = (tmpnam(b) == NULL); } +#endif + +#endif + + +/* +@@ lua_popen spawns a new process connected to the current one through +@* the file streams. +** CHANGE it if you have a way to implement it in your system. +*/ +#if defined(LUA_USE_POPEN) + +#define lua_popen(L,c,m) ((void)L, fflush(NULL), popen(c,m)) +#define lua_pclose(L,file) ((void)L, (pclose(file) != -1)) + +#elif defined(LUA_WIN) + +#define lua_popen(L,c,m) ((void)L, _popen(c,m)) +#define lua_pclose(L,file) ((void)L, (_pclose(file) != -1)) + +#else + +#define lua_popen(L,c,m) ((void)((void)c, m), \ + luaL_error(L, LUA_QL("popen") " not supported"), (FILE*)0) +#define lua_pclose(L,file) ((void)((void)L, file), 0) + +#endif + +/* +@@ LUA_DL_* define which dynamic-library system Lua should use. +** CHANGE here if Lua has problems choosing the appropriate +** dynamic-library system for your platform (either Windows' DLL, Mac's +** dyld, or Unix's dlopen). If your system is some kind of Unix, there +** is a good chance that it has dlopen, so LUA_DL_DLOPEN will work for +** it. To use dlopen you also need to adapt the src/Makefile (probably +** adding -ldl to the linker options), so Lua does not select it +** automatically. (When you change the makefile to add -ldl, you must +** also add -DLUA_USE_DLOPEN.) +** If you do not want any kind of dynamic library, undefine all these +** options. +** By default, _WIN32 gets LUA_DL_DLL and MAC OS X gets LUA_DL_DYLD. +*/ +#if defined(LUA_USE_DLOPEN) +#define LUA_DL_DLOPEN +#endif + +#if defined(LUA_WIN) +#define LUA_DL_DLL +#endif + + +/* +@@ LUAI_EXTRASPACE allows you to add user-specific data in a lua_State +@* (the data goes just *before* the lua_State pointer). +** CHANGE (define) this if you really need that. This value must be +** a multiple of the maximum alignment required for your machine. +*/ +#define LUAI_EXTRASPACE 0 + + +/* +@@ luai_userstate* allow user-specific actions on threads. +** CHANGE them if you defined LUAI_EXTRASPACE and need to do something +** extra when a thread is created/deleted/resumed/yielded. +*/ +#define luai_userstateopen(L) ((void)L) +#define luai_userstateclose(L) ((void)L) +#define luai_userstatethread(L,L1) ((void)L) +#define luai_userstatefree(L) ((void)L) +#define luai_userstateresume(L,n) ((void)L) +#define luai_userstateyield(L,n) ((void)L) + + +/* +@@ LUA_INTFRMLEN is the length modifier for integer conversions +@* in 'string.format'. +@@ LUA_INTFRM_T is the integer type correspoding to the previous length +@* modifier. +** CHANGE them if your system supports long long or does not support long. +*/ + +#if defined(LUA_USELONGLONG) + +#define LUA_INTFRMLEN "ll" +#define LUA_INTFRM_T long long + +#else + +#define LUA_INTFRMLEN "l" +#define LUA_INTFRM_T long + +#endif + + + +/* =================================================================== */ + +/* +** Local configuration. You can use this space to add your redefinitions +** without modifying the main part of the file. +*/ + + + +#endif + diff --git a/mylua/lua/lualib.h b/mylua/lua/lualib.h new file mode 100644 index 0000000..469417f --- /dev/null +++ b/mylua/lua/lualib.h @@ -0,0 +1,53 @@ +/* +** $Id: lualib.h,v 1.36.1.1 2007/12/27 13:02:25 roberto Exp $ +** Lua standard libraries +** See Copyright Notice in lua.h +*/ + + +#ifndef lualib_h +#define lualib_h + +#include "lua.h" + + +/* Key to file-handle type */ +#define LUA_FILEHANDLE "FILE*" + + +#define LUA_COLIBNAME "coroutine" +LUALIB_API int (luaopen_base) (lua_State *L); + +#define LUA_TABLIBNAME "table" +LUALIB_API int (luaopen_table) (lua_State *L); + +#define LUA_IOLIBNAME "io" +LUALIB_API int (luaopen_io) (lua_State *L); + +#define LUA_OSLIBNAME "os" +LUALIB_API int (luaopen_os) (lua_State *L); + +#define LUA_STRLIBNAME "string" +LUALIB_API int (luaopen_string) (lua_State *L); + +#define LUA_MATHLIBNAME "math" +LUALIB_API int (luaopen_math) (lua_State *L); + +#define LUA_DBLIBNAME "debug" +LUALIB_API int (luaopen_debug) (lua_State *L); + +#define LUA_LOADLIBNAME "package" +LUALIB_API int (luaopen_package) (lua_State *L); + + +/* open all previous libraries */ +LUALIB_API void (luaL_openlibs) (lua_State *L); + + + +#ifndef lua_assert +#define lua_assert(x) ((void)0) +#endif + + +#endif diff --git a/mylua/lua/lundump.c b/mylua/lua/lundump.c new file mode 100644 index 0000000..8010a45 --- /dev/null +++ b/mylua/lua/lundump.c @@ -0,0 +1,227 @@ +/* +** $Id: lundump.c,v 2.7.1.4 2008/04/04 19:51:41 roberto Exp $ +** load precompiled Lua chunks +** See Copyright Notice in lua.h +*/ + +#include + +#define lundump_c +#define LUA_CORE + +#include "lua.h" + +#include "ldebug.h" +#include "ldo.h" +#include "lfunc.h" +#include "lmem.h" +#include "lobject.h" +#include "lstring.h" +#include "lundump.h" +#include "lzio.h" + +typedef struct { + lua_State* L; + ZIO* Z; + Mbuffer* b; + const char* name; +} LoadState; + +#ifdef LUAC_TRUST_BINARIES +#define IF(c,s) +#define error(S,s) +#else +#define IF(c,s) if (c) error(S,s) + +static void error(LoadState* S, const char* why) +{ + luaO_pushfstring(S->L,"%s: %s in precompiled chunk",S->name,why); + luaD_throw(S->L,LUA_ERRSYNTAX); +} +#endif + +#define LoadMem(S,b,n,size) LoadBlock(S,b,(n)*(size)) +#define LoadByte(S) (lu_byte)LoadChar(S) +#define LoadVar(S,x) LoadMem(S,&x,1,sizeof(x)) +#define LoadVector(S,b,n,size) LoadMem(S,b,n,size) + +static void LoadBlock(LoadState* S, void* b, size_t size) +{ + size_t r=luaZ_read(S->Z,b,size); + IF (r!=0, "unexpected end"); +} + +static int LoadChar(LoadState* S) +{ + char x; + LoadVar(S,x); + return x; +} + +static int LoadInt(LoadState* S) +{ + int x; + LoadVar(S,x); + IF (x<0, "bad integer"); + return x; +} + +static lua_Number LoadNumber(LoadState* S) +{ + lua_Number x; + LoadVar(S,x); + return x; +} + +static TString* LoadString(LoadState* S) +{ + size_t size; + LoadVar(S,size); + if (size==0) + return NULL; + else + { + char* s=luaZ_openspace(S->L,S->b,size); + LoadBlock(S,s,size); + return luaS_newlstr(S->L,s,size-1); /* remove trailing '\0' */ + } +} + +static void LoadCode(LoadState* S, Proto* f) +{ + int n=LoadInt(S); + f->code=luaM_newvector(S->L,n,Instruction); + f->sizecode=n; + LoadVector(S,f->code,n,sizeof(Instruction)); +} + +static Proto* LoadFunction(LoadState* S, TString* p); + +static void LoadConstants(LoadState* S, Proto* f) +{ + int i,n; + n=LoadInt(S); + f->k=luaM_newvector(S->L,n,TValue); + f->sizek=n; + for (i=0; ik[i]); + for (i=0; ik[i]; + int t=LoadChar(S); + switch (t) + { + case LUA_TNIL: + setnilvalue(o); + break; + case LUA_TBOOLEAN: + setbvalue(o,LoadChar(S)!=0); + break; + case LUA_TNUMBER: + setnvalue(o,LoadNumber(S)); + break; + case LUA_TSTRING: + setsvalue2n(S->L,o,LoadString(S)); + break; + default: + error(S,"bad constant"); + break; + } + } + n=LoadInt(S); + f->p=luaM_newvector(S->L,n,Proto*); + f->sizep=n; + for (i=0; ip[i]=NULL; + for (i=0; ip[i]=LoadFunction(S,f->source); +} + +static void LoadDebug(LoadState* S, Proto* f) +{ + int i,n; + n=LoadInt(S); + f->lineinfo=luaM_newvector(S->L,n,int); + f->sizelineinfo=n; + LoadVector(S,f->lineinfo,n,sizeof(int)); + n=LoadInt(S); + f->locvars=luaM_newvector(S->L,n,LocVar); + f->sizelocvars=n; + for (i=0; ilocvars[i].varname=NULL; + for (i=0; ilocvars[i].varname=LoadString(S); + f->locvars[i].startpc=LoadInt(S); + f->locvars[i].endpc=LoadInt(S); + } + n=LoadInt(S); + f->upvalues=luaM_newvector(S->L,n,TString*); + f->sizeupvalues=n; + for (i=0; iupvalues[i]=NULL; + for (i=0; iupvalues[i]=LoadString(S); +} + +static Proto* LoadFunction(LoadState* S, TString* p) +{ + Proto* f; + if (++S->L->nCcalls > LUAI_MAXCCALLS) error(S,"code too deep"); + f=luaF_newproto(S->L); + setptvalue2s(S->L,S->L->top,f); incr_top(S->L); + f->source=LoadString(S); if (f->source==NULL) f->source=p; + f->linedefined=LoadInt(S); + f->lastlinedefined=LoadInt(S); + f->nups=LoadByte(S); + f->numparams=LoadByte(S); + f->is_vararg=LoadByte(S); + f->maxstacksize=LoadByte(S); + LoadCode(S,f); + LoadConstants(S,f); + LoadDebug(S,f); + IF (!luaG_checkcode(f), "bad code"); + S->L->top--; + S->L->nCcalls--; + return f; +} + +static void LoadHeader(LoadState* S) +{ + char h[LUAC_HEADERSIZE]; + char s[LUAC_HEADERSIZE]; + luaU_header(h); + LoadBlock(S,s,LUAC_HEADERSIZE); + IF (memcmp(h,s,LUAC_HEADERSIZE)!=0, "bad header"); +} + +/* +** load precompiled chunk +*/ +Proto* luaU_undump (lua_State* L, ZIO* Z, Mbuffer* buff, const char* name) +{ + LoadState S; + if (*name=='@' || *name=='=') + S.name=name+1; + else if (*name==LUA_SIGNATURE[0]) + S.name="binary string"; + else + S.name=name; + S.L=L; + S.Z=Z; + S.b=buff; + LoadHeader(&S); + return LoadFunction(&S,luaS_newliteral(L,"=?")); +} + +/* +* make header +*/ +void luaU_header (char* h) +{ + int x=1; + memcpy(h,LUA_SIGNATURE,sizeof(LUA_SIGNATURE)-1); + h+=sizeof(LUA_SIGNATURE)-1; + *h++=(char)LUAC_VERSION; + *h++=(char)LUAC_FORMAT; + *h++=(char)*(char*)&x; /* endianness */ + *h++=(char)sizeof(int); + *h++=(char)sizeof(size_t); + *h++=(char)sizeof(Instruction); + *h++=(char)sizeof(lua_Number); + *h++=(char)(((lua_Number)0.5)==0); /* is lua_Number integral? */ +} diff --git a/mylua/lua/lundump.h b/mylua/lua/lundump.h new file mode 100644 index 0000000..c80189d --- /dev/null +++ b/mylua/lua/lundump.h @@ -0,0 +1,36 @@ +/* +** $Id: lundump.h,v 1.37.1.1 2007/12/27 13:02:25 roberto Exp $ +** load precompiled Lua chunks +** See Copyright Notice in lua.h +*/ + +#ifndef lundump_h +#define lundump_h + +#include "lobject.h" +#include "lzio.h" + +/* load one chunk; from lundump.c */ +LUAI_FUNC Proto* luaU_undump (lua_State* L, ZIO* Z, Mbuffer* buff, const char* name); + +/* make header; from lundump.c */ +LUAI_FUNC void luaU_header (char* h); + +/* dump one chunk; from ldump.c */ +LUAI_FUNC int luaU_dump (lua_State* L, const Proto* f, lua_Writer w, void* data, int strip); + +#ifdef luac_c +/* print one chunk; from print.c */ +LUAI_FUNC void luaU_print (const Proto* f, int full); +#endif + +/* for header of binary files -- this is Lua 5.1 */ +#define LUAC_VERSION 0x51 + +/* for header of binary files -- this is the official format */ +#define LUAC_FORMAT 0 + +/* size of header of binary files */ +#define LUAC_HEADERSIZE 12 + +#endif diff --git a/mylua/lua/lvm.c b/mylua/lua/lvm.c new file mode 100644 index 0000000..ee3256a --- /dev/null +++ b/mylua/lua/lvm.c @@ -0,0 +1,763 @@ +/* +** $Id: lvm.c,v 2.63.1.3 2007/12/28 15:32:23 roberto Exp $ +** Lua virtual machine +** See Copyright Notice in lua.h +*/ + + +#include +#include +#include + +#define lvm_c +#define LUA_CORE + +#include "lua.h" + +#include "ldebug.h" +#include "ldo.h" +#include "lfunc.h" +#include "lgc.h" +#include "lobject.h" +#include "lopcodes.h" +#include "lstate.h" +#include "lstring.h" +#include "ltable.h" +#include "ltm.h" +#include "lvm.h" + + + +/* limit for table tag-method chains (to avoid loops) */ +#define MAXTAGLOOP 100 + + +const TValue *luaV_tonumber (const TValue *obj, TValue *n) { + lua_Number num; + if (ttisnumber(obj)) return obj; + if (ttisstring(obj) && luaO_str2d(svalue(obj), &num)) { + setnvalue(n, num); + return n; + } + else + return NULL; +} + + +int luaV_tostring (lua_State *L, StkId obj) { + if (!ttisnumber(obj)) + return 0; + else { + char s[LUAI_MAXNUMBER2STR]; + lua_Number n = nvalue(obj); + lua_number2str(s, n); + setsvalue2s(L, obj, luaS_new(L, s)); + return 1; + } +} + + +static void traceexec (lua_State *L, const Instruction *pc) { + lu_byte mask = L->hookmask; + const Instruction *oldpc = L->savedpc; + L->savedpc = pc; + if ((mask & LUA_MASKCOUNT) && L->hookcount == 0) { + resethookcount(L); + luaD_callhook(L, LUA_HOOKCOUNT, -1); + } + if (mask & LUA_MASKLINE) { + Proto *p = ci_func(L->ci)->l.p; + int npc = pcRel(pc, p); + int newline = getline(p, npc); + /* call linehook when enter a new function, when jump back (loop), + or when enter a new line */ + if (npc == 0 || pc <= oldpc || newline != getline(p, pcRel(oldpc, p))) + luaD_callhook(L, LUA_HOOKLINE, newline); + } +} + + +static void callTMres (lua_State *L, StkId res, const TValue *f, + const TValue *p1, const TValue *p2) { + ptrdiff_t result = savestack(L, res); + setobj2s(L, L->top, f); /* push function */ + setobj2s(L, L->top+1, p1); /* 1st argument */ + setobj2s(L, L->top+2, p2); /* 2nd argument */ + luaD_checkstack(L, 3); + L->top += 3; + luaD_call(L, L->top - 3, 1); + res = restorestack(L, result); + L->top--; + setobjs2s(L, res, L->top); +} + + + +static void callTM (lua_State *L, const TValue *f, const TValue *p1, + const TValue *p2, const TValue *p3) { + setobj2s(L, L->top, f); /* push function */ + setobj2s(L, L->top+1, p1); /* 1st argument */ + setobj2s(L, L->top+2, p2); /* 2nd argument */ + setobj2s(L, L->top+3, p3); /* 3th argument */ + luaD_checkstack(L, 4); + L->top += 4; + luaD_call(L, L->top - 4, 0); +} + + +void luaV_gettable (lua_State *L, const TValue *t, TValue *key, StkId val) { + int loop; + for (loop = 0; loop < MAXTAGLOOP; loop++) { + const TValue *tm; + if (ttistable(t)) { /* `t' is a table? */ + Table *h = hvalue(t); + const TValue *res = luaH_get(h, key); /* do a primitive get */ + if (!ttisnil(res) || /* result is no nil? */ + (tm = fasttm(L, h->metatable, TM_INDEX)) == NULL) { /* or no TM? */ + setobj2s(L, val, res); + return; + } + /* else will try the tag method */ + } + else if (ttisnil(tm = luaT_gettmbyobj(L, t, TM_INDEX))) + luaG_typeerror(L, t, "index"); + if (ttisfunction(tm)) { + callTMres(L, val, tm, t, key); + return; + } + t = tm; /* else repeat with `tm' */ + } + luaG_runerror(L, "loop in gettable"); +} + + +void luaV_settable (lua_State *L, const TValue *t, TValue *key, StkId val) { + int loop; + for (loop = 0; loop < MAXTAGLOOP; loop++) { + const TValue *tm; + if (ttistable(t)) { /* `t' is a table? */ + Table *h = hvalue(t); + TValue *oldval = luaH_set(L, h, key); /* do a primitive set */ + if (!ttisnil(oldval) || /* result is no nil? */ + (tm = fasttm(L, h->metatable, TM_NEWINDEX)) == NULL) { /* or no TM? */ + setobj2t(L, oldval, val); + luaC_barriert(L, h, val); + return; + } + /* else will try the tag method */ + } + else if (ttisnil(tm = luaT_gettmbyobj(L, t, TM_NEWINDEX))) + luaG_typeerror(L, t, "index"); + if (ttisfunction(tm)) { + callTM(L, tm, t, key, val); + return; + } + t = tm; /* else repeat with `tm' */ + } + luaG_runerror(L, "loop in settable"); +} + + +static int call_binTM (lua_State *L, const TValue *p1, const TValue *p2, + StkId res, TMS event) { + const TValue *tm = luaT_gettmbyobj(L, p1, event); /* try first operand */ + if (ttisnil(tm)) + tm = luaT_gettmbyobj(L, p2, event); /* try second operand */ + if (ttisnil(tm)) return 0; + callTMres(L, res, tm, p1, p2); + return 1; +} + + +static const TValue *get_compTM (lua_State *L, Table *mt1, Table *mt2, + TMS event) { + const TValue *tm1 = fasttm(L, mt1, event); + const TValue *tm2; + if (tm1 == NULL) return NULL; /* no metamethod */ + if (mt1 == mt2) return tm1; /* same metatables => same metamethods */ + tm2 = fasttm(L, mt2, event); + if (tm2 == NULL) return NULL; /* no metamethod */ + if (luaO_rawequalObj(tm1, tm2)) /* same metamethods? */ + return tm1; + return NULL; +} + + +static int call_orderTM (lua_State *L, const TValue *p1, const TValue *p2, + TMS event) { + const TValue *tm1 = luaT_gettmbyobj(L, p1, event); + const TValue *tm2; + if (ttisnil(tm1)) return -1; /* no metamethod? */ + tm2 = luaT_gettmbyobj(L, p2, event); + if (!luaO_rawequalObj(tm1, tm2)) /* different metamethods? */ + return -1; + callTMres(L, L->top, tm1, p1, p2); + return !l_isfalse(L->top); +} + + +static int l_strcmp (const TString *ls, const TString *rs) { + const char *l = getstr(ls); + size_t ll = ls->tsv.len; + const char *r = getstr(rs); + size_t lr = rs->tsv.len; + for (;;) { + int temp = strcoll(l, r); + if (temp != 0) return temp; + else { /* strings are equal up to a `\0' */ + size_t len = strlen(l); /* index of first `\0' in both strings */ + if (len == lr) /* r is finished? */ + return (len == ll) ? 0 : 1; + else if (len == ll) /* l is finished? */ + return -1; /* l is smaller than r (because r is not finished) */ + /* both strings longer than `len'; go on comparing (after the `\0') */ + len++; + l += len; ll -= len; r += len; lr -= len; + } + } +} + + +int luaV_lessthan (lua_State *L, const TValue *l, const TValue *r) { + int res; + if (ttype(l) != ttype(r)) + return luaG_ordererror(L, l, r); + else if (ttisnumber(l)) + return luai_numlt(nvalue(l), nvalue(r)); + else if (ttisstring(l)) + return l_strcmp(rawtsvalue(l), rawtsvalue(r)) < 0; + else if ((res = call_orderTM(L, l, r, TM_LT)) != -1) + return res; + return luaG_ordererror(L, l, r); +} + + +static int lessequal (lua_State *L, const TValue *l, const TValue *r) { + int res; + if (ttype(l) != ttype(r)) + return luaG_ordererror(L, l, r); + else if (ttisnumber(l)) + return luai_numle(nvalue(l), nvalue(r)); + else if (ttisstring(l)) + return l_strcmp(rawtsvalue(l), rawtsvalue(r)) <= 0; + else if ((res = call_orderTM(L, l, r, TM_LE)) != -1) /* first try `le' */ + return res; + else if ((res = call_orderTM(L, r, l, TM_LT)) != -1) /* else try `lt' */ + return !res; + return luaG_ordererror(L, l, r); +} + + +int luaV_equalval (lua_State *L, const TValue *t1, const TValue *t2) { + const TValue *tm; + lua_assert(ttype(t1) == ttype(t2)); + switch (ttype(t1)) { + case LUA_TNIL: return 1; + case LUA_TNUMBER: return luai_numeq(nvalue(t1), nvalue(t2)); + case LUA_TBOOLEAN: return bvalue(t1) == bvalue(t2); /* true must be 1 !! */ + case LUA_TLIGHTUSERDATA: return pvalue(t1) == pvalue(t2); + case LUA_TUSERDATA: { + if (uvalue(t1) == uvalue(t2)) return 1; + tm = get_compTM(L, uvalue(t1)->metatable, uvalue(t2)->metatable, + TM_EQ); + break; /* will try TM */ + } + case LUA_TTABLE: { + if (hvalue(t1) == hvalue(t2)) return 1; + tm = get_compTM(L, hvalue(t1)->metatable, hvalue(t2)->metatable, TM_EQ); + break; /* will try TM */ + } + default: return gcvalue(t1) == gcvalue(t2); + } + if (tm == NULL) return 0; /* no TM? */ + callTMres(L, L->top, tm, t1, t2); /* call TM */ + return !l_isfalse(L->top); +} + + +void luaV_concat (lua_State *L, int total, int last) { + do { + StkId top = L->base + last + 1; + int n = 2; /* number of elements handled in this pass (at least 2) */ + if (!(ttisstring(top-2) || ttisnumber(top-2)) || !tostring(L, top-1)) { + if (!call_binTM(L, top-2, top-1, top-2, TM_CONCAT)) + luaG_concaterror(L, top-2, top-1); + } else if (tsvalue(top-1)->len == 0) /* second op is empty? */ + (void)tostring(L, top - 2); /* result is first op (as string) */ + else { + /* at least two string values; get as many as possible */ + size_t tl = tsvalue(top-1)->len; + char *buffer; + int i; + /* collect total length */ + for (n = 1; n < total && tostring(L, top-n-1); n++) { + size_t l = tsvalue(top-n-1)->len; + if (l >= MAX_SIZET - tl) luaG_runerror(L, "string length overflow"); + tl += l; + } + buffer = luaZ_openspace(L, &G(L)->buff, tl); + tl = 0; + for (i=n; i>0; i--) { /* concat all strings */ + size_t l = tsvalue(top-i)->len; + memcpy(buffer+tl, svalue(top-i), l); + tl += l; + } + setsvalue2s(L, top-n, luaS_newlstr(L, buffer, tl)); + } + total -= n-1; /* got `n' strings to create 1 new */ + last -= n-1; + } while (total > 1); /* repeat until only 1 result left */ +} + + +static void Arith (lua_State *L, StkId ra, const TValue *rb, + const TValue *rc, TMS op) { + TValue tempb, tempc; + const TValue *b, *c; + if ((b = luaV_tonumber(rb, &tempb)) != NULL && + (c = luaV_tonumber(rc, &tempc)) != NULL) { + lua_Number nb = nvalue(b), nc = nvalue(c); + switch (op) { + case TM_ADD: setnvalue(ra, luai_numadd(nb, nc)); break; + case TM_SUB: setnvalue(ra, luai_numsub(nb, nc)); break; + case TM_MUL: setnvalue(ra, luai_nummul(nb, nc)); break; + case TM_DIV: setnvalue(ra, luai_numdiv(nb, nc)); break; + case TM_MOD: setnvalue(ra, luai_nummod(nb, nc)); break; + case TM_POW: setnvalue(ra, luai_numpow(nb, nc)); break; + case TM_UNM: setnvalue(ra, luai_numunm(nb)); break; + default: lua_assert(0); break; + } + } + else if (!call_binTM(L, rb, rc, ra, op)) + luaG_aritherror(L, rb, rc); +} + + + +/* +** some macros for common tasks in `luaV_execute' +*/ + +#define runtime_check(L, c) { if (!(c)) break; } + +#define RA(i) (base+GETARG_A(i)) +/* to be used after possible stack reallocation */ +#define RB(i) check_exp(getBMode(GET_OPCODE(i)) == OpArgR, base+GETARG_B(i)) +#define RC(i) check_exp(getCMode(GET_OPCODE(i)) == OpArgR, base+GETARG_C(i)) +#define RKB(i) check_exp(getBMode(GET_OPCODE(i)) == OpArgK, \ + ISK(GETARG_B(i)) ? k+INDEXK(GETARG_B(i)) : base+GETARG_B(i)) +#define RKC(i) check_exp(getCMode(GET_OPCODE(i)) == OpArgK, \ + ISK(GETARG_C(i)) ? k+INDEXK(GETARG_C(i)) : base+GETARG_C(i)) +#define KBx(i) check_exp(getBMode(GET_OPCODE(i)) == OpArgK, k+GETARG_Bx(i)) + + +#define dojump(L,pc,i) {(pc) += (i); luai_threadyield(L);} + + +#define Protect(x) { L->savedpc = pc; {x;}; base = L->base; } + + +#define arith_op(op,tm) { \ + TValue *rb = RKB(i); \ + TValue *rc = RKC(i); \ + if (ttisnumber(rb) && ttisnumber(rc)) { \ + lua_Number nb = nvalue(rb), nc = nvalue(rc); \ + setnvalue(ra, op(nb, nc)); \ + } \ + else \ + Protect(Arith(L, ra, rb, rc, tm)); \ + } + + + +void luaV_execute (lua_State *L, int nexeccalls) { + LClosure *cl; + StkId base; + TValue *k; + const Instruction *pc; + reentry: /* entry point */ + lua_assert(isLua(L->ci)); + pc = L->savedpc; + cl = &clvalue(L->ci->func)->l; + base = L->base; + k = cl->p->k; + /* main loop of interpreter */ + for (;;) { + const Instruction i = *pc++; + StkId ra; + if ((L->hookmask & (LUA_MASKLINE | LUA_MASKCOUNT)) && + (--L->hookcount == 0 || L->hookmask & LUA_MASKLINE)) { + traceexec(L, pc); + if (L->status == LUA_YIELD) { /* did hook yield? */ + L->savedpc = pc - 1; + return; + } + base = L->base; + } + /* warning!! several calls may realloc the stack and invalidate `ra' */ + ra = RA(i); + lua_assert(base == L->base && L->base == L->ci->base); + lua_assert(base <= L->top && L->top <= L->stack + L->stacksize); + lua_assert(L->top == L->ci->top || luaG_checkopenop(i)); + switch (GET_OPCODE(i)) { + case OP_MOVE: { + setobjs2s(L, ra, RB(i)); + continue; + } + case OP_LOADK: { + setobj2s(L, ra, KBx(i)); + continue; + } + case OP_LOADBOOL: { + setbvalue(ra, GETARG_B(i)); + if (GETARG_C(i)) pc++; /* skip next instruction (if C) */ + continue; + } + case OP_LOADNIL: { + TValue *rb = RB(i); + do { + setnilvalue(rb--); + } while (rb >= ra); + continue; + } + case OP_GETUPVAL: { + int b = GETARG_B(i); + setobj2s(L, ra, cl->upvals[b]->v); + continue; + } + case OP_GETGLOBAL: { + TValue g; + TValue *rb = KBx(i); + sethvalue(L, &g, cl->env); + lua_assert(ttisstring(rb)); + Protect(luaV_gettable(L, &g, rb, ra)); + continue; + } + case OP_GETTABLE: { + Protect(luaV_gettable(L, RB(i), RKC(i), ra)); + continue; + } + case OP_SETGLOBAL: { + TValue g; + sethvalue(L, &g, cl->env); + lua_assert(ttisstring(KBx(i))); + Protect(luaV_settable(L, &g, KBx(i), ra)); + continue; + } + case OP_SETUPVAL: { + UpVal *uv = cl->upvals[GETARG_B(i)]; + setobj(L, uv->v, ra); + luaC_barrier(L, uv, ra); + continue; + } + case OP_SETTABLE: { + Protect(luaV_settable(L, ra, RKB(i), RKC(i))); + continue; + } + case OP_NEWTABLE: { + int b = GETARG_B(i); + int c = GETARG_C(i); + sethvalue(L, ra, luaH_new(L, luaO_fb2int(b), luaO_fb2int(c))); + Protect(luaC_checkGC(L)); + continue; + } + case OP_SELF: { + StkId rb = RB(i); + setobjs2s(L, ra+1, rb); + Protect(luaV_gettable(L, rb, RKC(i), ra)); + continue; + } + case OP_ADD: { + arith_op(luai_numadd, TM_ADD); + continue; + } + case OP_SUB: { + arith_op(luai_numsub, TM_SUB); + continue; + } + case OP_MUL: { + arith_op(luai_nummul, TM_MUL); + continue; + } + case OP_DIV: { + arith_op(luai_numdiv, TM_DIV); + continue; + } + case OP_MOD: { + arith_op(luai_nummod, TM_MOD); + continue; + } + case OP_POW: { + arith_op(luai_numpow, TM_POW); + continue; + } + case OP_UNM: { + TValue *rb = RB(i); + if (ttisnumber(rb)) { + lua_Number nb = nvalue(rb); + setnvalue(ra, luai_numunm(nb)); + } + else { + Protect(Arith(L, ra, rb, rb, TM_UNM)); + } + continue; + } + case OP_NOT: { + int res = l_isfalse(RB(i)); /* next assignment may change this value */ + setbvalue(ra, res); + continue; + } + case OP_LEN: { + const TValue *rb = RB(i); + switch (ttype(rb)) { + case LUA_TTABLE: { + setnvalue(ra, cast_num(luaH_getn(hvalue(rb)))); + break; + } + case LUA_TSTRING: { + setnvalue(ra, cast_num(tsvalue(rb)->len)); + break; + } + default: { /* try metamethod */ + Protect( + if (!call_binTM(L, rb, luaO_nilobject, ra, TM_LEN)) + luaG_typeerror(L, rb, "get length of"); + ) + } + } + continue; + } + case OP_CONCAT: { + int b = GETARG_B(i); + int c = GETARG_C(i); + Protect(luaV_concat(L, c-b+1, c); luaC_checkGC(L)); + setobjs2s(L, RA(i), base+b); + continue; + } + case OP_JMP: { + dojump(L, pc, GETARG_sBx(i)); + continue; + } + case OP_EQ: { + TValue *rb = RKB(i); + TValue *rc = RKC(i); + Protect( + if (equalobj(L, rb, rc) == GETARG_A(i)) + dojump(L, pc, GETARG_sBx(*pc)); + ) + pc++; + continue; + } + case OP_LT: { + Protect( + if (luaV_lessthan(L, RKB(i), RKC(i)) == GETARG_A(i)) + dojump(L, pc, GETARG_sBx(*pc)); + ) + pc++; + continue; + } + case OP_LE: { + Protect( + if (lessequal(L, RKB(i), RKC(i)) == GETARG_A(i)) + dojump(L, pc, GETARG_sBx(*pc)); + ) + pc++; + continue; + } + case OP_TEST: { + if (l_isfalse(ra) != GETARG_C(i)) + dojump(L, pc, GETARG_sBx(*pc)); + pc++; + continue; + } + case OP_TESTSET: { + TValue *rb = RB(i); + if (l_isfalse(rb) != GETARG_C(i)) { + setobjs2s(L, ra, rb); + dojump(L, pc, GETARG_sBx(*pc)); + } + pc++; + continue; + } + case OP_CALL: { + int b = GETARG_B(i); + int nresults = GETARG_C(i) - 1; + if (b != 0) L->top = ra+b; /* else previous instruction set top */ + L->savedpc = pc; + switch (luaD_precall(L, ra, nresults)) { + case PCRLUA: { + nexeccalls++; + goto reentry; /* restart luaV_execute over new Lua function */ + } + case PCRC: { + /* it was a C function (`precall' called it); adjust results */ + if (nresults >= 0) L->top = L->ci->top; + base = L->base; + continue; + } + default: { + return; /* yield */ + } + } + } + case OP_TAILCALL: { + int b = GETARG_B(i); + if (b != 0) L->top = ra+b; /* else previous instruction set top */ + L->savedpc = pc; + lua_assert(GETARG_C(i) - 1 == LUA_MULTRET); + switch (luaD_precall(L, ra, LUA_MULTRET)) { + case PCRLUA: { + /* tail call: put new frame in place of previous one */ + CallInfo *ci = L->ci - 1; /* previous frame */ + int aux; + StkId func = ci->func; + StkId pfunc = (ci+1)->func; /* previous function index */ + if (L->openupval) luaF_close(L, ci->base); + L->base = ci->base = ci->func + ((ci+1)->base - pfunc); + for (aux = 0; pfunc+aux < L->top; aux++) /* move frame down */ + setobjs2s(L, func+aux, pfunc+aux); + ci->top = L->top = func+aux; /* correct top */ + lua_assert(L->top == L->base + clvalue(func)->l.p->maxstacksize); + ci->savedpc = L->savedpc; + ci->tailcalls++; /* one more call lost */ + L->ci--; /* remove new frame */ + goto reentry; + } + case PCRC: { /* it was a C function (`precall' called it) */ + base = L->base; + continue; + } + default: { + return; /* yield */ + } + } + } + case OP_RETURN: { + int b = GETARG_B(i); + if (b != 0) L->top = ra+b-1; + if (L->openupval) luaF_close(L, base); + L->savedpc = pc; + b = luaD_poscall(L, ra); + if (--nexeccalls == 0) /* was previous function running `here'? */ + return; /* no: return */ + else { /* yes: continue its execution */ + if (b) L->top = L->ci->top; + lua_assert(isLua(L->ci)); + lua_assert(GET_OPCODE(*((L->ci)->savedpc - 1)) == OP_CALL); + goto reentry; + } + } + case OP_FORLOOP: { + lua_Number step = nvalue(ra+2); + lua_Number idx = luai_numadd(nvalue(ra), step); /* increment index */ + lua_Number limit = nvalue(ra+1); + if (luai_numlt(0, step) ? luai_numle(idx, limit) + : luai_numle(limit, idx)) { + dojump(L, pc, GETARG_sBx(i)); /* jump back */ + setnvalue(ra, idx); /* update internal index... */ + setnvalue(ra+3, idx); /* ...and external index */ + } + continue; + } + case OP_FORPREP: { + const TValue *init = ra; + const TValue *plimit = ra+1; + const TValue *pstep = ra+2; + L->savedpc = pc; /* next steps may throw errors */ + if (!tonumber(init, ra)) + luaG_runerror(L, LUA_QL("for") " initial value must be a number"); + else if (!tonumber(plimit, ra+1)) + luaG_runerror(L, LUA_QL("for") " limit must be a number"); + else if (!tonumber(pstep, ra+2)) + luaG_runerror(L, LUA_QL("for") " step must be a number"); + setnvalue(ra, luai_numsub(nvalue(ra), nvalue(pstep))); + dojump(L, pc, GETARG_sBx(i)); + continue; + } + case OP_TFORLOOP: { + StkId cb = ra + 3; /* call base */ + setobjs2s(L, cb+2, ra+2); + setobjs2s(L, cb+1, ra+1); + setobjs2s(L, cb, ra); + L->top = cb+3; /* func. + 2 args (state and index) */ + Protect(luaD_call(L, cb, GETARG_C(i))); + L->top = L->ci->top; + cb = RA(i) + 3; /* previous call may change the stack */ + if (!ttisnil(cb)) { /* continue loop? */ + setobjs2s(L, cb-1, cb); /* save control variable */ + dojump(L, pc, GETARG_sBx(*pc)); /* jump back */ + } + pc++; + continue; + } + case OP_SETLIST: { + int n = GETARG_B(i); + int c = GETARG_C(i); + int last; + Table *h; + if (n == 0) { + n = cast_int(L->top - ra) - 1; + L->top = L->ci->top; + } + if (c == 0) c = cast_int(*pc++); + runtime_check(L, ttistable(ra)); + h = hvalue(ra); + last = ((c-1)*LFIELDS_PER_FLUSH) + n; + if (last > h->sizearray) /* needs more space? */ + luaH_resizearray(L, h, last); /* pre-alloc it at once */ + for (; n > 0; n--) { + TValue *val = ra+n; + setobj2t(L, luaH_setnum(L, h, last--), val); + luaC_barriert(L, h, val); + } + continue; + } + case OP_CLOSE: { + luaF_close(L, ra); + continue; + } + case OP_CLOSURE: { + Proto *p; + Closure *ncl; + int nup, j; + p = cl->p->p[GETARG_Bx(i)]; + nup = p->nups; + ncl = luaF_newLclosure(L, nup, cl->env); + ncl->l.p = p; + for (j=0; jl.upvals[j] = cl->upvals[GETARG_B(*pc)]; + else { + lua_assert(GET_OPCODE(*pc) == OP_MOVE); + ncl->l.upvals[j] = luaF_findupval(L, base + GETARG_B(*pc)); + } + } + setclvalue(L, ra, ncl); + Protect(luaC_checkGC(L)); + continue; + } + case OP_VARARG: { + int b = GETARG_B(i) - 1; + int j; + CallInfo *ci = L->ci; + int n = cast_int(ci->base - ci->func) - cl->p->numparams - 1; + if (b == LUA_MULTRET) { + Protect(luaD_checkstack(L, n)); + ra = RA(i); /* previous call may change the stack */ + b = n; + L->top = ra + n; + } + for (j = 0; j < b; j++) { + if (j < n) { + setobjs2s(L, ra + j, ci->base - n + j); + } + else { + setnilvalue(ra + j); + } + } + continue; + } + } + } +} + diff --git a/mylua/lua/lvm.h b/mylua/lua/lvm.h new file mode 100644 index 0000000..bfe4f56 --- /dev/null +++ b/mylua/lua/lvm.h @@ -0,0 +1,36 @@ +/* +** $Id: lvm.h,v 2.5.1.1 2007/12/27 13:02:25 roberto Exp $ +** Lua virtual machine +** See Copyright Notice in lua.h +*/ + +#ifndef lvm_h +#define lvm_h + + +#include "ldo.h" +#include "lobject.h" +#include "ltm.h" + + +#define tostring(L,o) ((ttype(o) == LUA_TSTRING) || (luaV_tostring(L, o))) + +#define tonumber(o,n) (ttype(o) == LUA_TNUMBER || \ + (((o) = luaV_tonumber(o,n)) != NULL)) + +#define equalobj(L,o1,o2) \ + (ttype(o1) == ttype(o2) && luaV_equalval(L, o1, o2)) + + +LUAI_FUNC int luaV_lessthan (lua_State *L, const TValue *l, const TValue *r); +LUAI_FUNC int luaV_equalval (lua_State *L, const TValue *t1, const TValue *t2); +LUAI_FUNC const TValue *luaV_tonumber (const TValue *obj, TValue *n); +LUAI_FUNC int luaV_tostring (lua_State *L, StkId obj); +LUAI_FUNC void luaV_gettable (lua_State *L, const TValue *t, TValue *key, + StkId val); +LUAI_FUNC void luaV_settable (lua_State *L, const TValue *t, TValue *key, + StkId val); +LUAI_FUNC void luaV_execute (lua_State *L, int nexeccalls); +LUAI_FUNC void luaV_concat (lua_State *L, int total, int last); + +#endif diff --git a/mylua/lua/lzio.c b/mylua/lua/lzio.c new file mode 100644 index 0000000..293edd5 --- /dev/null +++ b/mylua/lua/lzio.c @@ -0,0 +1,82 @@ +/* +** $Id: lzio.c,v 1.31.1.1 2007/12/27 13:02:25 roberto Exp $ +** a generic input stream interface +** See Copyright Notice in lua.h +*/ + + +#include + +#define lzio_c +#define LUA_CORE + +#include "lua.h" + +#include "llimits.h" +#include "lmem.h" +#include "lstate.h" +#include "lzio.h" + + +int luaZ_fill (ZIO *z) { + size_t size; + lua_State *L = z->L; + const char *buff; + lua_unlock(L); + buff = z->reader(L, z->data, &size); + lua_lock(L); + if (buff == NULL || size == 0) return EOZ; + z->n = size - 1; + z->p = buff; + return char2int(*(z->p++)); +} + + +int luaZ_lookahead (ZIO *z) { + if (z->n == 0) { + if (luaZ_fill(z) == EOZ) + return EOZ; + else { + z->n++; /* luaZ_fill removed first byte; put back it */ + z->p--; + } + } + return char2int(*z->p); +} + + +void luaZ_init (lua_State *L, ZIO *z, lua_Reader reader, void *data) { + z->L = L; + z->reader = reader; + z->data = data; + z->n = 0; + z->p = NULL; +} + + +/* --------------------------------------------------------------- read --- */ +size_t luaZ_read (ZIO *z, void *b, size_t n) { + while (n) { + size_t m; + if (luaZ_lookahead(z) == EOZ) + return n; /* return number of missing bytes */ + m = (n <= z->n) ? n : z->n; /* min. between n and z->n */ + memcpy(b, z->p, m); + z->n -= m; + z->p += m; + b = (char *)b + m; + n -= m; + } + return 0; +} + +/* ------------------------------------------------------------------------ */ +char *luaZ_openspace (lua_State *L, Mbuffer *buff, size_t n) { + if (n > buff->buffsize) { + if (n < LUA_MINBUFFER) n = LUA_MINBUFFER; + luaZ_resizebuffer(L, buff, n); + } + return buff->buffer; +} + + diff --git a/mylua/lua/lzio.h b/mylua/lua/lzio.h new file mode 100644 index 0000000..51d695d --- /dev/null +++ b/mylua/lua/lzio.h @@ -0,0 +1,67 @@ +/* +** $Id: lzio.h,v 1.21.1.1 2007/12/27 13:02:25 roberto Exp $ +** Buffered streams +** See Copyright Notice in lua.h +*/ + + +#ifndef lzio_h +#define lzio_h + +#include "lua.h" + +#include "lmem.h" + + +#define EOZ (-1) /* end of stream */ + +typedef struct Zio ZIO; + +#define char2int(c) cast(int, cast(unsigned char, (c))) + +#define zgetc(z) (((z)->n--)>0 ? char2int(*(z)->p++) : luaZ_fill(z)) + +typedef struct Mbuffer { + char *buffer; + size_t n; + size_t buffsize; +} Mbuffer; + +#define luaZ_initbuffer(L, buff) ((buff)->buffer = NULL, (buff)->buffsize = 0) + +#define luaZ_buffer(buff) ((buff)->buffer) +#define luaZ_sizebuffer(buff) ((buff)->buffsize) +#define luaZ_bufflen(buff) ((buff)->n) + +#define luaZ_resetbuffer(buff) ((buff)->n = 0) + + +#define luaZ_resizebuffer(L, buff, size) \ + (luaM_reallocvector(L, (buff)->buffer, (buff)->buffsize, size, char), \ + (buff)->buffsize = size) + +#define luaZ_freebuffer(L, buff) luaZ_resizebuffer(L, buff, 0) + + +LUAI_FUNC char *luaZ_openspace (lua_State *L, Mbuffer *buff, size_t n); +LUAI_FUNC void luaZ_init (lua_State *L, ZIO *z, lua_Reader reader, + void *data); +LUAI_FUNC size_t luaZ_read (ZIO* z, void* b, size_t n); /* read next n bytes */ +LUAI_FUNC int luaZ_lookahead (ZIO *z); + + + +/* --------- Private Part ------------------ */ + +struct Zio { + size_t n; /* bytes still unread */ + const char *p; /* current position in buffer */ + lua_Reader reader; + void* data; /* additional data */ + lua_State *L; /* Lua state (for reader) */ +}; + + +LUAI_FUNC int luaZ_fill (ZIO *z); + +#endif diff --git a/mylua/lua/print.c b/mylua/lua/print.c new file mode 100644 index 0000000..e240cfc --- /dev/null +++ b/mylua/lua/print.c @@ -0,0 +1,227 @@ +/* +** $Id: print.c,v 1.55a 2006/05/31 13:30:05 lhf Exp $ +** print bytecodes +** See Copyright Notice in lua.h +*/ + +#include +#include + +#define luac_c +#define LUA_CORE + +#include "ldebug.h" +#include "lobject.h" +#include "lopcodes.h" +#include "lundump.h" + +#define PrintFunction luaU_print + +#define Sizeof(x) ((int)sizeof(x)) +#define VOID(p) ((const void*)(p)) + +static void PrintString(const TString* ts) +{ + const char* s=getstr(ts); + size_t i,n=ts->tsv.len; + putchar('"'); + for (i=0; ik[i]; + switch (ttype(o)) + { + case LUA_TNIL: + printf("nil"); + break; + case LUA_TBOOLEAN: + printf(bvalue(o) ? "true" : "false"); + break; + case LUA_TNUMBER: + printf(LUA_NUMBER_FMT,nvalue(o)); + break; + case LUA_TSTRING: + PrintString(rawtsvalue(o)); + break; + default: /* cannot happen */ + printf("? type=%d",ttype(o)); + break; + } +} + +static void PrintCode(const Proto* f) +{ + const Instruction* code=f->code; + int pc,n=f->sizecode; + for (pc=0; pc0) printf("[%d]\t",line); else printf("[-]\t"); + printf("%-9s\t",luaP_opnames[o]); + switch (getOpMode(o)) + { + case iABC: + printf("%d",a); + if (getBMode(o)!=OpArgN) printf(" %d",ISK(b) ? (-1-INDEXK(b)) : b); + if (getCMode(o)!=OpArgN) printf(" %d",ISK(c) ? (-1-INDEXK(c)) : c); + break; + case iABx: + if (getBMode(o)==OpArgK) printf("%d %d",a,-1-bx); else printf("%d %d",a,bx); + break; + case iAsBx: + if (o==OP_JMP) printf("%d",sbx); else printf("%d %d",a,sbx); + break; + } + switch (o) + { + case OP_LOADK: + printf("\t; "); PrintConstant(f,bx); + break; + case OP_GETUPVAL: + case OP_SETUPVAL: + printf("\t; %s", (f->sizeupvalues>0) ? getstr(f->upvalues[b]) : "-"); + break; + case OP_GETGLOBAL: + case OP_SETGLOBAL: + printf("\t; %s",svalue(&f->k[bx])); + break; + case OP_GETTABLE: + case OP_SELF: + if (ISK(c)) { printf("\t; "); PrintConstant(f,INDEXK(c)); } + break; + case OP_SETTABLE: + case OP_ADD: + case OP_SUB: + case OP_MUL: + case OP_DIV: + case OP_POW: + case OP_EQ: + case OP_LT: + case OP_LE: + if (ISK(b) || ISK(c)) + { + printf("\t; "); + if (ISK(b)) PrintConstant(f,INDEXK(b)); else printf("-"); + printf(" "); + if (ISK(c)) PrintConstant(f,INDEXK(c)); else printf("-"); + } + break; + case OP_JMP: + case OP_FORLOOP: + case OP_FORPREP: + printf("\t; to %d",sbx+pc+2); + break; + case OP_CLOSURE: + printf("\t; %p",VOID(f->p[bx])); + break; + case OP_SETLIST: + if (c==0) printf("\t; %d",(int)code[++pc]); + else printf("\t; %d",c); + break; + default: + break; + } + printf("\n"); + } +} + +#define SS(x) (x==1)?"":"s" +#define S(x) x,SS(x) + +static void PrintHeader(const Proto* f) +{ + const char* s=getstr(f->source); + if (*s=='@' || *s=='=') + s++; + else if (*s==LUA_SIGNATURE[0]) + s="(bstring)"; + else + s="(string)"; + printf("\n%s <%s:%d,%d> (%d instruction%s, %d bytes at %p)\n", + (f->linedefined==0)?"main":"function",s, + f->linedefined,f->lastlinedefined, + S(f->sizecode),f->sizecode*Sizeof(Instruction),VOID(f)); + printf("%d%s param%s, %d slot%s, %d upvalue%s, ", + f->numparams,f->is_vararg?"+":"",SS(f->numparams), + S(f->maxstacksize),S(f->nups)); + printf("%d local%s, %d constant%s, %d function%s\n", + S(f->sizelocvars),S(f->sizek),S(f->sizep)); +} + +static void PrintConstants(const Proto* f) +{ + int i,n=f->sizek; + printf("constants (%d) for %p:\n",n,VOID(f)); + for (i=0; isizelocvars; + printf("locals (%d) for %p:\n",n,VOID(f)); + for (i=0; ilocvars[i].varname),f->locvars[i].startpc+1,f->locvars[i].endpc+1); + } +} + +static void PrintUpvalues(const Proto* f) +{ + int i,n=f->sizeupvalues; + printf("upvalues (%d) for %p:\n",n,VOID(f)); + if (f->upvalues==NULL) return; + for (i=0; iupvalues[i])); + } +} + +void PrintFunction(const Proto* f, int full) +{ + int i,n=f->sizep; + PrintHeader(f); + PrintCode(f); + if (full) + { + PrintConstants(f); + PrintLocals(f); + PrintUpvalues(f); + } + for (i=0; ip[i],full); +} diff --git a/mylua/magicbase.c b/mylua/magicbase.c new file mode 100644 index 0000000..b01c18b --- /dev/null +++ b/mylua/magicbase.c @@ -0,0 +1,49 @@ +#include +#include "common.h" +#include "char_talk.h" +#include "mylua/base.h" +#include "lua.h" +#include "lauxlib.h" +#include "lualib.h" +#include "lssproto_serv.h" +#ifdef _ALLBLUES_LUA_1_2 +#include "mylua/mylua.h" +extern MY_Lua MYLua; + +static int addLUAListFunction(lua_State *L) +{ + size_t l; + char *luafuncname = luaL_checklstring(L, 1, &l); + char *luafunctable = luaL_checklstring(L, 2, &l); + char *luafunctablepath = luaL_checklstring(L, 3, &l); + const int gmlevel = luaL_checkint(L, 4); + char *usestring = luaL_checklstring(L, 5, &l); + + + if(strlen(luafunctablepath) > 0){ + MY_Lua *mylua = &MYLua; + while(mylua->next != NULL){ + if(strcmp(mylua->luapath, luafunctablepath) == 0){ + return MAGIC_addLUAListFunction( mylua->lua, luafuncname, luafunctable, gmlevel, usestring ); + } + mylua = mylua->next; + } + }else{ + return MAGIC_addLUAListFunction( L, luafuncname, luafunctable, gmlevel, usestring ); + } + return 1; + +} + +static const luaL_Reg magiclib[] = { + {"addLUAListFunction", addLUAListFunction}, + {NULL, NULL} +}; + +LUALIB_API int luaopen_Magic (lua_State *L) { + luaL_register(L, "magic", magiclib); + return 1; +} + +#endif + diff --git a/mylua/makefile b/mylua/makefile new file mode 100644 index 0000000..6c7033d --- /dev/null +++ b/mylua/makefile @@ -0,0 +1,1067 @@ +export CC=gcc +export RM=rm -f +export AR=ar cr +export MV=mv +export RANLIB=ranlib +export SED=sed + + +export SHELL=/bin/sh + +INCFLAGS=-I. -I../include -I../include/lua + +CFLAGS=-w -O3 -g -rdynamic $(INCFLAGS) +#Pentium 4 (Intel) +#CFLAGS=-march=pentium4 -O3 -pipe -fomit-frame-pointer $(INCFLAGS) +#Athlon XP (AMD) +#CFLAGS="-march=athlon-xp -O3 -pipe -fomit-frame-pointer" $(INCFLAGS) +#Athlon64 +#CFLAGS="-O2 -march=athlon64 -ftracer -fprefetch-loop-arrays -pipe" $(INCFLAGS) + +PROG=libmylua.a + +SRC=mylua.c ablua.c init.c charbase.c npcbase.c function.c lssprotobase.c battlebase.c objectbase.c mapbase.c otherbase.c configbase.c itembase.c magicbase.c offlinebase.c netbase.c enemytempbase.c sasqlbase.c saacproto.c family.c petskill.c + +OBJ=$(SRC:.c=.o) + +ifeq (0,$(MAKELEVEL)) +CC=gcc +RM=rm -f +AR=ar cr +MV=mv +RANLIB=ranlib +SED=sed +SHELL=/bin/sh +endif + +all: $(PROG) + +$(PROG): $(OBJ) + $(RM) $(PROG) + $(AR) $(PROG) $(OBJ) + $(RANLIB) $(PROG) + +dos2unix: + dos2unix $(SRC) makefile + +chmod: + chmod 777 $(SRC) makefile + +depend: + $(MV) makefile makefile.bak + $(SED) -ne '1,/^# DO NOT DELETE THIS LINE/p' makefile.bak>makefile + $(CC) $(INCFLAGS) -M $(SRC) >> makefile + chmod 777 makefile + +clean: + $(RM) $(PROG) + $(RM) $(OBJ) + $(RM) *~ + +distclean: + $(RM) $(PROG) + $(RM) $(OBJ) + $(RM) *~ + $(MV) makefile Makefile.bak + $(SED) -ne '1,/^# DO NOT DELETE THIS LINE/p' makefile.bak>makefile + $(RM) makefile.bak + +# DO NOT DELETE THIS LINE +mylua.o: mylua.c /usr/include/signal.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/bits/wordsize.h \ + /usr/include/gnu/stubs.h /usr/include/gnu/stubs-32.h \ + /usr/include/bits/sigset.h /usr/include/bits/types.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/typesizes.h /usr/include/bits/signum.h \ + /usr/include/time.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/pthreadtypes.h /usr/include/bits/sigthread.h \ + /usr/include/stdio.h /usr/include/libio.h /usr/include/_G_config.h \ + /usr/include/wchar.h /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/select.h \ + /usr/include/bits/select.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/alloca.h \ + /usr/include/string.h /usr/include/dirent.h /usr/include/bits/dirent.h \ + /usr/include/bits/posix1_lim.h /usr/include/bits/local_lim.h \ + /usr/include/linux/limits.h ../include/autil.h ../include/version.h \ + ../include/sasql.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix2_lim.h \ + /usr/include/bits/sockaddr.h /usr/include/asm/socket.h \ + /usr/include/asm/sockios.h /usr/include/bits/in.h \ + /usr/include/bits/byteswap.h /usr/include/arpa/inet.h \ + /usr/include/netdb.h /usr/include/rpc/netdb.h /usr/include/bits/netdb.h \ + /usr/include/unistd.h /usr/include/bits/posix_opt.h \ + /usr/include/bits/confname.h /usr/include/getopt.h \ + /usr/include/strings.h /usr/include/sys/time.h /usr/include/errno.h \ + /usr/include/bits/errno.h /usr/include/linux/errno.h \ + /usr/include/asm/errno.h /usr/include/asm-generic/errno.h \ + /usr/include/asm-generic/errno-base.h ../include/correct_bug.h \ + ../include/common.h ../include/buf.h ../include/util.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lua.h \ + ../include/lualib.h ../include/version.h ../include/mylua/mylua.h \ + ../include/lua.h ../include/lauxlib.h ../include/lualib.h +ablua.o: ablua.c /usr/include/pthread.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/bits/wordsize.h \ + /usr/include/gnu/stubs.h /usr/include/gnu/stubs-32.h \ + /usr/include/endian.h /usr/include/bits/endian.h /usr/include/sched.h \ + /usr/include/bits/types.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/typesizes.h /usr/include/time.h \ + /usr/include/bits/sched.h /usr/include/bits/time.h \ + /usr/include/signal.h /usr/include/bits/sigset.h \ + /usr/include/bits/pthreadtypes.h /usr/include/bits/setjmp.h \ + /usr/include/stdio.h /usr/include/libio.h /usr/include/_G_config.h \ + /usr/include/wchar.h /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/dirent.h /usr/include/bits/dirent.h \ + /usr/include/bits/posix1_lim.h /usr/include/bits/local_lim.h \ + /usr/include/linux/limits.h /usr/include/string.h \ + /usr/include/sys/types.h /usr/include/sys/select.h \ + /usr/include/bits/select.h /usr/include/sys/sysmacros.h \ + /usr/include/sys/stat.h /usr/include/bits/stat.h ../include/autil.h \ + ../include/version.h ../include/sasql.h /usr/include/stdlib.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix2_lim.h \ + /usr/include/bits/sockaddr.h /usr/include/asm/socket.h \ + /usr/include/asm/sockios.h /usr/include/bits/in.h \ + /usr/include/bits/byteswap.h /usr/include/arpa/inet.h \ + /usr/include/netdb.h /usr/include/rpc/netdb.h /usr/include/bits/netdb.h \ + /usr/include/unistd.h /usr/include/bits/posix_opt.h \ + /usr/include/bits/confname.h /usr/include/getopt.h \ + /usr/include/strings.h /usr/include/sys/time.h /usr/include/errno.h \ + /usr/include/bits/errno.h /usr/include/linux/errno.h \ + /usr/include/asm/errno.h /usr/include/asm-generic/errno.h \ + /usr/include/asm-generic/errno-base.h ../include/correct_bug.h \ + ../include/common.h ../include/util.h ../include/mylua/mylua.h \ + ../include/lua.h ../include/luaconf.h ../include/lauxlib.h \ + ../include/lua.h ../include/lualib.h ../include/mylua/base.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + ../include/title.h ../include/addressbook.h ../include/net.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h ../include/link.h ../include/lauxlib.h \ + ../include/lualib.h ../include/version.h +init.o: init.c ../include/lua.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + ../include/luaconf.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h ../include/lualib.h ../include/lua.h \ + ../include/lauxlib.h /usr/include/stdio.h /usr/include/bits/types.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h /usr/include/bits/stdio_lim.h \ + /usr/include/bits/sys_errlist.h ../include/mylua/base.h \ + ../include/char_base.h ../include/version.h ../include/sasql.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/include/bits/sockaddr.h /usr/include/asm/socket.h \ + /usr/include/asm/sockios.h /usr/include/bits/in.h \ + /usr/include/bits/byteswap.h /usr/include/arpa/inet.h \ + /usr/include/netdb.h /usr/include/rpc/netdb.h /usr/include/bits/netdb.h \ + /usr/include/unistd.h /usr/include/bits/posix_opt.h \ + /usr/include/bits/confname.h /usr/include/getopt.h \ + /usr/include/strings.h /usr/include/sys/time.h /usr/include/errno.h \ + /usr/include/bits/errno.h /usr/include/linux/errno.h \ + /usr/include/asm/errno.h /usr/include/asm-generic/errno.h \ + /usr/include/asm-generic/errno-base.h /usr/include/string.h \ + ../include/correct_bug.h ../include/skill.h ../include/common.h \ + ../include/util.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lauxlib.h \ + ../include/lualib.h ../include/lua.h ../include/lauxlib.h \ + ../include/lualib.h +charbase.o: charbase.c /usr/include/string.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/bits/wordsize.h \ + /usr/include/gnu/stubs.h /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h ../include/char.h \ + ../include/common.h /usr/include/stdio.h /usr/include/bits/types.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + ../include/char_base.h ../include/version.h ../include/sasql.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + ../include/correct_bug.h ../include/skill.h ../include/util.h \ + ../include/title.h ../include/addressbook.h ../include/net.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/battle.h ../include/object.h ../include/char_base.h \ + ../include/enemy.h ../include/mylua/base.h ../include/char_base.h \ + ../include/lua.h ../include/lauxlib.h ../include/lualib.h \ + ../include/npcutil.h ../include/readmap.h ../include/log.h \ + ../include/pet.h ../include/lua.h ../include/lauxlib.h \ + ../include/lualib.h ../include/version.h ../include/handletime.h \ + ../include/item_event.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h ../include/mylua/mylua.h +npcbase.o: npcbase.c /usr/include/string.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/bits/wordsize.h \ + /usr/include/gnu/stubs.h /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + ../include/battle.h ../include/net.h ../include/common.h \ + /usr/include/stdio.h /usr/include/bits/types.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/sys/time.h /usr/include/time.h /usr/include/bits/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/netinet/in.h \ + /usr/include/stdint.h /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/bits/pthreadtypes.h /usr/include/bits/uio.h \ + /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/char_base.h \ + ../include/version.h ../include/sasql.h /usr/include/stdlib.h \ + /usr/include/alloca.h /usr/include/arpa/inet.h /usr/include/netdb.h \ + /usr/include/rpc/netdb.h /usr/include/bits/netdb.h \ + /usr/include/unistd.h /usr/include/bits/posix_opt.h \ + /usr/include/bits/confname.h /usr/include/getopt.h \ + /usr/include/strings.h ../include/correct_bug.h ../include/skill.h \ + ../include/util.h ../include/title.h ../include/addressbook.h \ + ../include/lua.h ../include/luaconf.h ../include/lauxlib.h \ + ../include/lualib.h ../include/npccreate.h ../include/object.h \ + ../include/char.h ../include/char_base.h ../include/char_data.h \ + ../include/item.h ../include/char.h ../include/enemy.h \ + ../include/npc_eventaction.h ../include/lua.h ../include/version.h \ + ../include/lauxlib.h ../include/lualib.h ../include/npcutil.h \ + ../include/log.h +function.o: function.c /usr/include/string.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/bits/wordsize.h \ + /usr/include/gnu/stubs.h /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + ../include/common.h /usr/include/stdio.h /usr/include/bits/types.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + ../include/char_base.h ../include/version.h ../include/sasql.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + ../include/correct_bug.h ../include/skill.h ../include/common.h \ + ../include/util.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/item.h ../include/configfile.h ../include/battle.h \ + ../include/mylua/base.h ../include/char_base.h ../include/lua.h \ + ../include/lauxlib.h ../include/lualib.h ../include/version.h \ + ../include/lua.h ../include/lauxlib.h ../include/lualib.h \ + ../include/mylua/mylua.h ../include/mylua/function.h ../include/char.h \ + ../include/char_base.h ../include/char_data.h ../include/item.h \ + ../include/char.h +lssprotobase.o: lssprotobase.c /usr/include/string.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h ../include/char.h \ + ../include/common.h /usr/include/stdio.h /usr/include/bits/types.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + ../include/char_base.h ../include/version.h ../include/sasql.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + ../include/correct_bug.h ../include/skill.h ../include/util.h \ + ../include/title.h ../include/addressbook.h ../include/net.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/char_base.h ../include/mylua/base.h ../include/char_base.h \ + ../include/lua.h ../include/lauxlib.h ../include/lualib.h \ + ../include/lua.h ../include/lauxlib.h ../include/lualib.h \ + ../include/lssproto_serv.h ../include/lssproto_util.h \ + ../include/autil.h +battlebase.o: battlebase.c /usr/include/string.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/bits/wordsize.h \ + /usr/include/gnu/stubs.h /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + ../include/version.h ../include/sasql.h /usr/include/stdio.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + ../include/correct_bug.h ../include/char_base.h ../include/version.h \ + ../include/skill.h ../include/common.h ../include/util.h \ + ../include/title.h ../include/addressbook.h ../include/net.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/enemy.h ../include/object.h ../include/char.h \ + ../include/char_base.h ../include/char_data.h ../include/item.h \ + ../include/char.h ../include/lssproto_serv.h ../include/lssproto_util.h \ + ../include/battle.h ../include/battle_command.h ../include/lua.h \ + ../include/lauxlib.h ../include/lualib.h ../include/mylua/mylua.h \ + ../include/lua.h ../include/lauxlib.h ../include/lualib.h \ + ../include/mylua/base.h ../include/char_base.h +objectbase.o: objectbase.c /usr/include/string.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/bits/wordsize.h \ + /usr/include/gnu/stubs.h /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + ../include/char_base.h ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/bits/types.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + ../include/correct_bug.h ../include/skill.h ../include/common.h \ + ../include/util.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/object.h ../include/version.h ../include/lua.h \ + ../include/lauxlib.h ../include/lualib.h ../include/mylua/base.h \ + ../include/char_base.h ../include/lua.h ../include/lauxlib.h \ + ../include/lualib.h +mapbase.o: mapbase.c /usr/include/string.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/bits/wordsize.h \ + /usr/include/gnu/stubs.h /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/stdio.h /usr/include/bits/types.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + ../include/char.h ../include/common.h /usr/include/errno.h \ + /usr/include/bits/errno.h /usr/include/linux/errno.h \ + /usr/include/asm/errno.h /usr/include/asm-generic/errno.h \ + /usr/include/asm-generic/errno-base.h ../include/char_base.h \ + ../include/version.h ../include/sasql.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/time.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/select.h \ + /usr/include/bits/select.h /usr/include/bits/sigset.h \ + /usr/include/bits/time.h /usr/include/sys/sysmacros.h \ + /usr/include/bits/pthreadtypes.h /usr/include/alloca.h \ + /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + ../include/correct_bug.h ../include/skill.h ../include/util.h \ + ../include/title.h ../include/addressbook.h ../include/net.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/readmap.h ../include/map_deal.h ../include/char_base.h \ + ../include/mylua/base.h ../include/char_base.h ../include/lua.h \ + ../include/lauxlib.h ../include/lualib.h ../include/lua.h \ + ../include/lauxlib.h ../include/lualib.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h +otherbase.o: otherbase.c /usr/include/string.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/bits/wordsize.h \ + /usr/include/gnu/stubs.h /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/time.h /usr/include/bits/time.h /usr/include/bits/types.h \ + /usr/include/bits/typesizes.h /usr/include/sys/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h ../include/char.h ../include/common.h \ + /usr/include/stdio.h /usr/include/libio.h /usr/include/_G_config.h \ + /usr/include/wchar.h /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + ../include/char_base.h ../include/version.h ../include/sasql.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/bits/pthreadtypes.h /usr/include/alloca.h \ + /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h ../include/correct_bug.h \ + ../include/skill.h ../include/util.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/char_base.h ../include/mylua/base.h ../include/char_base.h \ + ../include/lua.h ../include/lauxlib.h ../include/lualib.h \ + ../include/util.h ../include/lua.h ../include/lauxlib.h \ + ../include/lualib.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h ../include/mylua/mylua.h +configbase.o: configbase.c /usr/include/string.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/bits/wordsize.h \ + /usr/include/gnu/stubs.h /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/stdio.h /usr/include/bits/types.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/math.h /usr/include/bits/huge_val.h \ + /usr/include/bits/mathdef.h /usr/include/bits/mathcalls.h \ + ../include/char.h ../include/common.h /usr/include/errno.h \ + /usr/include/bits/errno.h /usr/include/linux/errno.h \ + /usr/include/asm/errno.h /usr/include/asm-generic/errno.h \ + /usr/include/asm-generic/errno-base.h ../include/char_base.h \ + ../include/version.h ../include/sasql.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/time.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/select.h \ + /usr/include/bits/select.h /usr/include/bits/sigset.h \ + /usr/include/bits/time.h /usr/include/sys/sysmacros.h \ + /usr/include/bits/pthreadtypes.h /usr/include/alloca.h \ + /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + ../include/correct_bug.h ../include/skill.h ../include/util.h \ + ../include/title.h ../include/addressbook.h ../include/net.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/char_base.h ../include/mylua/base.h ../include/char_base.h \ + ../include/lua.h ../include/lauxlib.h ../include/lualib.h \ + ../include/mylua/mylua.h ../include/lua.h ../include/lauxlib.h \ + ../include/lualib.h ../include/configfile.h +itembase.o: itembase.c /usr/include/string.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/bits/wordsize.h \ + /usr/include/gnu/stubs.h /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + ../include/common.h /usr/include/stdio.h /usr/include/bits/types.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + ../include/char_base.h ../include/version.h ../include/sasql.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + ../include/correct_bug.h ../include/skill.h ../include/common.h \ + ../include/util.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/mylua/base.h ../include/char_base.h ../include/lua.h \ + ../include/lauxlib.h ../include/lualib.h ../include/char.h \ + ../include/char_base.h ../include/char_data.h ../include/item.h \ + ../include/char.h ../include/item.h ../include/lua.h \ + ../include/lauxlib.h ../include/lualib.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h ../include/mylua/mylua.h +magicbase.o: magicbase.c /usr/include/string.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/bits/wordsize.h \ + /usr/include/gnu/stubs.h /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + ../include/common.h /usr/include/stdio.h /usr/include/bits/types.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + ../include/char_talk.h ../include/common.h ../include/util.h \ + /usr/include/sys/time.h /usr/include/time.h /usr/include/bits/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/bits/pthreadtypes.h /usr/include/alloca.h ../include/net.h \ + /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/mylua/base.h \ + ../include/char_base.h ../include/version.h ../include/sasql.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h ../include/correct_bug.h \ + ../include/skill.h ../include/title.h ../include/addressbook.h \ + ../include/lua.h ../include/luaconf.h ../include/lauxlib.h \ + ../include/lualib.h ../include/lua.h ../include/lauxlib.h \ + ../include/lualib.h ../include/lua.h ../include/lauxlib.h \ + ../include/lualib.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h ../include/mylua/mylua.h +offlinebase.o: offlinebase.c /usr/include/string.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + ../include/version.h ../include/sasql.h /usr/include/stdio.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + ../include/correct_bug.h ../include/char_base.h ../include/version.h \ + ../include/skill.h ../include/common.h ../include/util.h \ + ../include/title.h ../include/addressbook.h ../include/net.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/enemy.h ../include/object.h ../include/char.h \ + ../include/char_base.h ../include/char_data.h ../include/item.h \ + ../include/char.h ../include/battle.h ../include/lua.h \ + ../include/lauxlib.h ../include/lualib.h ../include/mylua/mylua.h \ + ../include/lua.h ../include/lauxlib.h ../include/lualib.h +netbase.o: netbase.c /usr/include/string.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/bits/wordsize.h \ + /usr/include/gnu/stubs.h /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h ../include/lua.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + ../include/luaconf.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/bits/types.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h /usr/include/bits/stdio_lim.h \ + /usr/include/bits/sys_errlist.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/time.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/select.h \ + /usr/include/bits/select.h /usr/include/bits/sigset.h \ + /usr/include/bits/time.h /usr/include/sys/sysmacros.h \ + /usr/include/bits/pthreadtypes.h /usr/include/alloca.h \ + /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/include/bits/sockaddr.h /usr/include/asm/socket.h \ + /usr/include/asm/sockios.h /usr/include/bits/in.h \ + /usr/include/bits/byteswap.h /usr/include/arpa/inet.h \ + /usr/include/netdb.h /usr/include/rpc/netdb.h /usr/include/bits/netdb.h \ + /usr/include/unistd.h /usr/include/bits/posix_opt.h \ + /usr/include/bits/confname.h /usr/include/getopt.h \ + /usr/include/strings.h /usr/include/sys/time.h /usr/include/errno.h \ + /usr/include/bits/errno.h /usr/include/linux/errno.h \ + /usr/include/asm/errno.h /usr/include/asm-generic/errno.h \ + /usr/include/asm-generic/errno-base.h ../include/correct_bug.h \ + ../include/lauxlib.h ../include/lua.h ../include/lualib.h \ + ../include/net.h ../include/common.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/log.h +enemytempbase.o: enemytempbase.c /usr/include/string.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/stdio.h /usr/include/bits/types.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + ../include/char.h ../include/common.h /usr/include/errno.h \ + /usr/include/bits/errno.h /usr/include/linux/errno.h \ + /usr/include/asm/errno.h /usr/include/asm-generic/errno.h \ + /usr/include/asm-generic/errno-base.h ../include/char_base.h \ + ../include/version.h ../include/sasql.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/time.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/select.h \ + /usr/include/bits/select.h /usr/include/bits/sigset.h \ + /usr/include/bits/time.h /usr/include/sys/sysmacros.h \ + /usr/include/bits/pthreadtypes.h /usr/include/alloca.h \ + /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + ../include/correct_bug.h ../include/skill.h ../include/util.h \ + ../include/title.h ../include/addressbook.h ../include/net.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/readmap.h ../include/map_deal.h ../include/char_base.h \ + ../include/enemy.h ../include/mylua/base.h ../include/char_base.h \ + ../include/lua.h ../include/lauxlib.h ../include/lualib.h \ + ../include/lua.h ../include/lauxlib.h ../include/lualib.h \ + ../include/lssproto_serv.h ../include/lssproto_util.h +sasqlbase.o: sasqlbase.c /usr/include/string.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/bits/wordsize.h \ + /usr/include/gnu/stubs.h /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h ../include/lua.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + ../include/luaconf.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/bits/types.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h /usr/include/bits/stdio_lim.h \ + /usr/include/bits/sys_errlist.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/time.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/select.h \ + /usr/include/bits/select.h /usr/include/bits/sigset.h \ + /usr/include/bits/time.h /usr/include/sys/sysmacros.h \ + /usr/include/bits/pthreadtypes.h /usr/include/alloca.h \ + /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/include/bits/sockaddr.h /usr/include/asm/socket.h \ + /usr/include/asm/sockios.h /usr/include/bits/in.h \ + /usr/include/bits/byteswap.h /usr/include/arpa/inet.h \ + /usr/include/netdb.h /usr/include/rpc/netdb.h /usr/include/bits/netdb.h \ + /usr/include/unistd.h /usr/include/bits/posix_opt.h \ + /usr/include/bits/confname.h /usr/include/getopt.h \ + /usr/include/strings.h /usr/include/sys/time.h /usr/include/errno.h \ + /usr/include/bits/errno.h /usr/include/linux/errno.h \ + /usr/include/asm/errno.h /usr/include/asm-generic/errno.h \ + /usr/include/asm-generic/errno-base.h ../include/correct_bug.h \ + ../include/lauxlib.h ../include/lua.h ../include/lualib.h \ + ../include/net.h ../include/common.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/log.h \ + ../include/sasql.h /usr/include/mysql/mysql.h \ + /usr/include/mysql/mysql_version.h /usr/include/mysql/mysql_com.h \ + /usr/include/mysql/mysql_time.h /usr/include/mysql/typelib.h \ + /usr/include/mysql/my_alloc.h /usr/include/mysql/my_list.h +saacproto.o: saacproto.c /usr/include/string.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/bits/wordsize.h \ + /usr/include/gnu/stubs.h /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h ../include/char.h \ + ../include/common.h /usr/include/stdio.h /usr/include/bits/types.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + ../include/char_base.h ../include/version.h ../include/sasql.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + ../include/correct_bug.h ../include/skill.h ../include/util.h \ + ../include/title.h ../include/addressbook.h ../include/net.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/char_base.h ../include/mylua/base.h ../include/char_base.h \ + ../include/lua.h ../include/lauxlib.h ../include/lualib.h \ + ../include/lua.h ../include/lauxlib.h ../include/lualib.h \ + ../include/saacproto_cli.h ../include/saacproto_util.h +family.o: family.c /usr/include/string.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/bits/wordsize.h \ + /usr/include/gnu/stubs.h /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h ../include/char.h \ + ../include/common.h /usr/include/stdio.h /usr/include/bits/types.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + ../include/char_base.h ../include/version.h ../include/sasql.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + ../include/correct_bug.h ../include/skill.h ../include/util.h \ + ../include/title.h ../include/addressbook.h ../include/net.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/char_base.h ../include/family.h ../include/mylua/base.h \ + ../include/char_base.h ../include/lua.h ../include/lauxlib.h \ + ../include/lualib.h ../include/lua.h ../include/lauxlib.h \ + ../include/lualib.h ../include/saacproto_cli.h \ + ../include/saacproto_util.h +petskill.o: petskill.c /usr/include/string.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/bits/wordsize.h \ + /usr/include/gnu/stubs.h /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + ../include/common.h /usr/include/stdio.h /usr/include/bits/types.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + ../include/version.h ../include/sasql.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/time.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/select.h \ + /usr/include/bits/select.h /usr/include/bits/sigset.h \ + /usr/include/bits/time.h /usr/include/sys/sysmacros.h \ + /usr/include/bits/pthreadtypes.h /usr/include/alloca.h \ + /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + ../include/correct_bug.h ../include/pet_skill.h ../include/util.h \ + ../include/common.h ../include/mylua/base.h ../include/char_base.h \ + ../include/version.h ../include/skill.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/lua.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char.h ../include/char_base.h ../include/char_data.h \ + ../include/item.h ../include/char.h ../include/item.h ../include/lua.h \ + ../include/lauxlib.h ../include/lualib.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h ../include/mylua/mylua.h diff --git a/mylua/makefile.bak b/mylua/makefile.bak new file mode 100644 index 0000000..6c7033d --- /dev/null +++ b/mylua/makefile.bak @@ -0,0 +1,1067 @@ +export CC=gcc +export RM=rm -f +export AR=ar cr +export MV=mv +export RANLIB=ranlib +export SED=sed + + +export SHELL=/bin/sh + +INCFLAGS=-I. -I../include -I../include/lua + +CFLAGS=-w -O3 -g -rdynamic $(INCFLAGS) +#Pentium 4 (Intel) +#CFLAGS=-march=pentium4 -O3 -pipe -fomit-frame-pointer $(INCFLAGS) +#Athlon XP (AMD) +#CFLAGS="-march=athlon-xp -O3 -pipe -fomit-frame-pointer" $(INCFLAGS) +#Athlon64 +#CFLAGS="-O2 -march=athlon64 -ftracer -fprefetch-loop-arrays -pipe" $(INCFLAGS) + +PROG=libmylua.a + +SRC=mylua.c ablua.c init.c charbase.c npcbase.c function.c lssprotobase.c battlebase.c objectbase.c mapbase.c otherbase.c configbase.c itembase.c magicbase.c offlinebase.c netbase.c enemytempbase.c sasqlbase.c saacproto.c family.c petskill.c + +OBJ=$(SRC:.c=.o) + +ifeq (0,$(MAKELEVEL)) +CC=gcc +RM=rm -f +AR=ar cr +MV=mv +RANLIB=ranlib +SED=sed +SHELL=/bin/sh +endif + +all: $(PROG) + +$(PROG): $(OBJ) + $(RM) $(PROG) + $(AR) $(PROG) $(OBJ) + $(RANLIB) $(PROG) + +dos2unix: + dos2unix $(SRC) makefile + +chmod: + chmod 777 $(SRC) makefile + +depend: + $(MV) makefile makefile.bak + $(SED) -ne '1,/^# DO NOT DELETE THIS LINE/p' makefile.bak>makefile + $(CC) $(INCFLAGS) -M $(SRC) >> makefile + chmod 777 makefile + +clean: + $(RM) $(PROG) + $(RM) $(OBJ) + $(RM) *~ + +distclean: + $(RM) $(PROG) + $(RM) $(OBJ) + $(RM) *~ + $(MV) makefile Makefile.bak + $(SED) -ne '1,/^# DO NOT DELETE THIS LINE/p' makefile.bak>makefile + $(RM) makefile.bak + +# DO NOT DELETE THIS LINE +mylua.o: mylua.c /usr/include/signal.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/bits/wordsize.h \ + /usr/include/gnu/stubs.h /usr/include/gnu/stubs-32.h \ + /usr/include/bits/sigset.h /usr/include/bits/types.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/typesizes.h /usr/include/bits/signum.h \ + /usr/include/time.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/pthreadtypes.h /usr/include/bits/sigthread.h \ + /usr/include/stdio.h /usr/include/libio.h /usr/include/_G_config.h \ + /usr/include/wchar.h /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/select.h \ + /usr/include/bits/select.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/alloca.h \ + /usr/include/string.h /usr/include/dirent.h /usr/include/bits/dirent.h \ + /usr/include/bits/posix1_lim.h /usr/include/bits/local_lim.h \ + /usr/include/linux/limits.h ../include/autil.h ../include/version.h \ + ../include/sasql.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix2_lim.h \ + /usr/include/bits/sockaddr.h /usr/include/asm/socket.h \ + /usr/include/asm/sockios.h /usr/include/bits/in.h \ + /usr/include/bits/byteswap.h /usr/include/arpa/inet.h \ + /usr/include/netdb.h /usr/include/rpc/netdb.h /usr/include/bits/netdb.h \ + /usr/include/unistd.h /usr/include/bits/posix_opt.h \ + /usr/include/bits/confname.h /usr/include/getopt.h \ + /usr/include/strings.h /usr/include/sys/time.h /usr/include/errno.h \ + /usr/include/bits/errno.h /usr/include/linux/errno.h \ + /usr/include/asm/errno.h /usr/include/asm-generic/errno.h \ + /usr/include/asm-generic/errno-base.h ../include/correct_bug.h \ + ../include/common.h ../include/buf.h ../include/util.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lua.h \ + ../include/lualib.h ../include/version.h ../include/mylua/mylua.h \ + ../include/lua.h ../include/lauxlib.h ../include/lualib.h +ablua.o: ablua.c /usr/include/pthread.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/bits/wordsize.h \ + /usr/include/gnu/stubs.h /usr/include/gnu/stubs-32.h \ + /usr/include/endian.h /usr/include/bits/endian.h /usr/include/sched.h \ + /usr/include/bits/types.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/typesizes.h /usr/include/time.h \ + /usr/include/bits/sched.h /usr/include/bits/time.h \ + /usr/include/signal.h /usr/include/bits/sigset.h \ + /usr/include/bits/pthreadtypes.h /usr/include/bits/setjmp.h \ + /usr/include/stdio.h /usr/include/libio.h /usr/include/_G_config.h \ + /usr/include/wchar.h /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/dirent.h /usr/include/bits/dirent.h \ + /usr/include/bits/posix1_lim.h /usr/include/bits/local_lim.h \ + /usr/include/linux/limits.h /usr/include/string.h \ + /usr/include/sys/types.h /usr/include/sys/select.h \ + /usr/include/bits/select.h /usr/include/sys/sysmacros.h \ + /usr/include/sys/stat.h /usr/include/bits/stat.h ../include/autil.h \ + ../include/version.h ../include/sasql.h /usr/include/stdlib.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix2_lim.h \ + /usr/include/bits/sockaddr.h /usr/include/asm/socket.h \ + /usr/include/asm/sockios.h /usr/include/bits/in.h \ + /usr/include/bits/byteswap.h /usr/include/arpa/inet.h \ + /usr/include/netdb.h /usr/include/rpc/netdb.h /usr/include/bits/netdb.h \ + /usr/include/unistd.h /usr/include/bits/posix_opt.h \ + /usr/include/bits/confname.h /usr/include/getopt.h \ + /usr/include/strings.h /usr/include/sys/time.h /usr/include/errno.h \ + /usr/include/bits/errno.h /usr/include/linux/errno.h \ + /usr/include/asm/errno.h /usr/include/asm-generic/errno.h \ + /usr/include/asm-generic/errno-base.h ../include/correct_bug.h \ + ../include/common.h ../include/util.h ../include/mylua/mylua.h \ + ../include/lua.h ../include/luaconf.h ../include/lauxlib.h \ + ../include/lua.h ../include/lualib.h ../include/mylua/base.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + ../include/title.h ../include/addressbook.h ../include/net.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h ../include/link.h ../include/lauxlib.h \ + ../include/lualib.h ../include/version.h +init.o: init.c ../include/lua.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + ../include/luaconf.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h ../include/lualib.h ../include/lua.h \ + ../include/lauxlib.h /usr/include/stdio.h /usr/include/bits/types.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h /usr/include/bits/stdio_lim.h \ + /usr/include/bits/sys_errlist.h ../include/mylua/base.h \ + ../include/char_base.h ../include/version.h ../include/sasql.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/include/bits/sockaddr.h /usr/include/asm/socket.h \ + /usr/include/asm/sockios.h /usr/include/bits/in.h \ + /usr/include/bits/byteswap.h /usr/include/arpa/inet.h \ + /usr/include/netdb.h /usr/include/rpc/netdb.h /usr/include/bits/netdb.h \ + /usr/include/unistd.h /usr/include/bits/posix_opt.h \ + /usr/include/bits/confname.h /usr/include/getopt.h \ + /usr/include/strings.h /usr/include/sys/time.h /usr/include/errno.h \ + /usr/include/bits/errno.h /usr/include/linux/errno.h \ + /usr/include/asm/errno.h /usr/include/asm-generic/errno.h \ + /usr/include/asm-generic/errno-base.h /usr/include/string.h \ + ../include/correct_bug.h ../include/skill.h ../include/common.h \ + ../include/util.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lauxlib.h \ + ../include/lualib.h ../include/lua.h ../include/lauxlib.h \ + ../include/lualib.h +charbase.o: charbase.c /usr/include/string.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/bits/wordsize.h \ + /usr/include/gnu/stubs.h /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h ../include/char.h \ + ../include/common.h /usr/include/stdio.h /usr/include/bits/types.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + ../include/char_base.h ../include/version.h ../include/sasql.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + ../include/correct_bug.h ../include/skill.h ../include/util.h \ + ../include/title.h ../include/addressbook.h ../include/net.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/battle.h ../include/object.h ../include/char_base.h \ + ../include/enemy.h ../include/mylua/base.h ../include/char_base.h \ + ../include/lua.h ../include/lauxlib.h ../include/lualib.h \ + ../include/npcutil.h ../include/readmap.h ../include/log.h \ + ../include/pet.h ../include/lua.h ../include/lauxlib.h \ + ../include/lualib.h ../include/version.h ../include/handletime.h \ + ../include/item_event.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h ../include/mylua/mylua.h +npcbase.o: npcbase.c /usr/include/string.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/bits/wordsize.h \ + /usr/include/gnu/stubs.h /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + ../include/battle.h ../include/net.h ../include/common.h \ + /usr/include/stdio.h /usr/include/bits/types.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/sys/time.h /usr/include/time.h /usr/include/bits/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/netinet/in.h \ + /usr/include/stdint.h /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/bits/pthreadtypes.h /usr/include/bits/uio.h \ + /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/char_base.h \ + ../include/version.h ../include/sasql.h /usr/include/stdlib.h \ + /usr/include/alloca.h /usr/include/arpa/inet.h /usr/include/netdb.h \ + /usr/include/rpc/netdb.h /usr/include/bits/netdb.h \ + /usr/include/unistd.h /usr/include/bits/posix_opt.h \ + /usr/include/bits/confname.h /usr/include/getopt.h \ + /usr/include/strings.h ../include/correct_bug.h ../include/skill.h \ + ../include/util.h ../include/title.h ../include/addressbook.h \ + ../include/lua.h ../include/luaconf.h ../include/lauxlib.h \ + ../include/lualib.h ../include/npccreate.h ../include/object.h \ + ../include/char.h ../include/char_base.h ../include/char_data.h \ + ../include/item.h ../include/char.h ../include/enemy.h \ + ../include/npc_eventaction.h ../include/lua.h ../include/version.h \ + ../include/lauxlib.h ../include/lualib.h ../include/npcutil.h \ + ../include/log.h +function.o: function.c /usr/include/string.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/bits/wordsize.h \ + /usr/include/gnu/stubs.h /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + ../include/common.h /usr/include/stdio.h /usr/include/bits/types.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + ../include/char_base.h ../include/version.h ../include/sasql.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + ../include/correct_bug.h ../include/skill.h ../include/common.h \ + ../include/util.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/item.h ../include/configfile.h ../include/battle.h \ + ../include/mylua/base.h ../include/char_base.h ../include/lua.h \ + ../include/lauxlib.h ../include/lualib.h ../include/version.h \ + ../include/lua.h ../include/lauxlib.h ../include/lualib.h \ + ../include/mylua/mylua.h ../include/mylua/function.h ../include/char.h \ + ../include/char_base.h ../include/char_data.h ../include/item.h \ + ../include/char.h +lssprotobase.o: lssprotobase.c /usr/include/string.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h ../include/char.h \ + ../include/common.h /usr/include/stdio.h /usr/include/bits/types.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + ../include/char_base.h ../include/version.h ../include/sasql.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + ../include/correct_bug.h ../include/skill.h ../include/util.h \ + ../include/title.h ../include/addressbook.h ../include/net.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/char_base.h ../include/mylua/base.h ../include/char_base.h \ + ../include/lua.h ../include/lauxlib.h ../include/lualib.h \ + ../include/lua.h ../include/lauxlib.h ../include/lualib.h \ + ../include/lssproto_serv.h ../include/lssproto_util.h \ + ../include/autil.h +battlebase.o: battlebase.c /usr/include/string.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/bits/wordsize.h \ + /usr/include/gnu/stubs.h /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + ../include/version.h ../include/sasql.h /usr/include/stdio.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + ../include/correct_bug.h ../include/char_base.h ../include/version.h \ + ../include/skill.h ../include/common.h ../include/util.h \ + ../include/title.h ../include/addressbook.h ../include/net.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/enemy.h ../include/object.h ../include/char.h \ + ../include/char_base.h ../include/char_data.h ../include/item.h \ + ../include/char.h ../include/lssproto_serv.h ../include/lssproto_util.h \ + ../include/battle.h ../include/battle_command.h ../include/lua.h \ + ../include/lauxlib.h ../include/lualib.h ../include/mylua/mylua.h \ + ../include/lua.h ../include/lauxlib.h ../include/lualib.h \ + ../include/mylua/base.h ../include/char_base.h +objectbase.o: objectbase.c /usr/include/string.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/bits/wordsize.h \ + /usr/include/gnu/stubs.h /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + ../include/char_base.h ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/bits/types.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + ../include/correct_bug.h ../include/skill.h ../include/common.h \ + ../include/util.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/object.h ../include/version.h ../include/lua.h \ + ../include/lauxlib.h ../include/lualib.h ../include/mylua/base.h \ + ../include/char_base.h ../include/lua.h ../include/lauxlib.h \ + ../include/lualib.h +mapbase.o: mapbase.c /usr/include/string.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/bits/wordsize.h \ + /usr/include/gnu/stubs.h /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/stdio.h /usr/include/bits/types.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + ../include/char.h ../include/common.h /usr/include/errno.h \ + /usr/include/bits/errno.h /usr/include/linux/errno.h \ + /usr/include/asm/errno.h /usr/include/asm-generic/errno.h \ + /usr/include/asm-generic/errno-base.h ../include/char_base.h \ + ../include/version.h ../include/sasql.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/time.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/select.h \ + /usr/include/bits/select.h /usr/include/bits/sigset.h \ + /usr/include/bits/time.h /usr/include/sys/sysmacros.h \ + /usr/include/bits/pthreadtypes.h /usr/include/alloca.h \ + /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + ../include/correct_bug.h ../include/skill.h ../include/util.h \ + ../include/title.h ../include/addressbook.h ../include/net.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/readmap.h ../include/map_deal.h ../include/char_base.h \ + ../include/mylua/base.h ../include/char_base.h ../include/lua.h \ + ../include/lauxlib.h ../include/lualib.h ../include/lua.h \ + ../include/lauxlib.h ../include/lualib.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h +otherbase.o: otherbase.c /usr/include/string.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/bits/wordsize.h \ + /usr/include/gnu/stubs.h /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/time.h /usr/include/bits/time.h /usr/include/bits/types.h \ + /usr/include/bits/typesizes.h /usr/include/sys/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h ../include/char.h ../include/common.h \ + /usr/include/stdio.h /usr/include/libio.h /usr/include/_G_config.h \ + /usr/include/wchar.h /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + ../include/char_base.h ../include/version.h ../include/sasql.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/bits/pthreadtypes.h /usr/include/alloca.h \ + /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h ../include/correct_bug.h \ + ../include/skill.h ../include/util.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/char_base.h ../include/mylua/base.h ../include/char_base.h \ + ../include/lua.h ../include/lauxlib.h ../include/lualib.h \ + ../include/util.h ../include/lua.h ../include/lauxlib.h \ + ../include/lualib.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h ../include/mylua/mylua.h +configbase.o: configbase.c /usr/include/string.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/bits/wordsize.h \ + /usr/include/gnu/stubs.h /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/stdio.h /usr/include/bits/types.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/math.h /usr/include/bits/huge_val.h \ + /usr/include/bits/mathdef.h /usr/include/bits/mathcalls.h \ + ../include/char.h ../include/common.h /usr/include/errno.h \ + /usr/include/bits/errno.h /usr/include/linux/errno.h \ + /usr/include/asm/errno.h /usr/include/asm-generic/errno.h \ + /usr/include/asm-generic/errno-base.h ../include/char_base.h \ + ../include/version.h ../include/sasql.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/time.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/select.h \ + /usr/include/bits/select.h /usr/include/bits/sigset.h \ + /usr/include/bits/time.h /usr/include/sys/sysmacros.h \ + /usr/include/bits/pthreadtypes.h /usr/include/alloca.h \ + /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + ../include/correct_bug.h ../include/skill.h ../include/util.h \ + ../include/title.h ../include/addressbook.h ../include/net.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/char_base.h ../include/mylua/base.h ../include/char_base.h \ + ../include/lua.h ../include/lauxlib.h ../include/lualib.h \ + ../include/mylua/mylua.h ../include/lua.h ../include/lauxlib.h \ + ../include/lualib.h ../include/configfile.h +itembase.o: itembase.c /usr/include/string.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/bits/wordsize.h \ + /usr/include/gnu/stubs.h /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + ../include/common.h /usr/include/stdio.h /usr/include/bits/types.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + ../include/char_base.h ../include/version.h ../include/sasql.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + ../include/correct_bug.h ../include/skill.h ../include/common.h \ + ../include/util.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/mylua/base.h ../include/char_base.h ../include/lua.h \ + ../include/lauxlib.h ../include/lualib.h ../include/char.h \ + ../include/char_base.h ../include/char_data.h ../include/item.h \ + ../include/char.h ../include/item.h ../include/lua.h \ + ../include/lauxlib.h ../include/lualib.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h ../include/mylua/mylua.h +magicbase.o: magicbase.c /usr/include/string.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/bits/wordsize.h \ + /usr/include/gnu/stubs.h /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + ../include/common.h /usr/include/stdio.h /usr/include/bits/types.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + ../include/char_talk.h ../include/common.h ../include/util.h \ + /usr/include/sys/time.h /usr/include/time.h /usr/include/bits/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/bits/pthreadtypes.h /usr/include/alloca.h ../include/net.h \ + /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/mylua/base.h \ + ../include/char_base.h ../include/version.h ../include/sasql.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h ../include/correct_bug.h \ + ../include/skill.h ../include/title.h ../include/addressbook.h \ + ../include/lua.h ../include/luaconf.h ../include/lauxlib.h \ + ../include/lualib.h ../include/lua.h ../include/lauxlib.h \ + ../include/lualib.h ../include/lua.h ../include/lauxlib.h \ + ../include/lualib.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h ../include/mylua/mylua.h +offlinebase.o: offlinebase.c /usr/include/string.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + ../include/version.h ../include/sasql.h /usr/include/stdio.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + ../include/correct_bug.h ../include/char_base.h ../include/version.h \ + ../include/skill.h ../include/common.h ../include/util.h \ + ../include/title.h ../include/addressbook.h ../include/net.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/enemy.h ../include/object.h ../include/char.h \ + ../include/char_base.h ../include/char_data.h ../include/item.h \ + ../include/char.h ../include/battle.h ../include/lua.h \ + ../include/lauxlib.h ../include/lualib.h ../include/mylua/mylua.h \ + ../include/lua.h ../include/lauxlib.h ../include/lualib.h +netbase.o: netbase.c /usr/include/string.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/bits/wordsize.h \ + /usr/include/gnu/stubs.h /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h ../include/lua.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + ../include/luaconf.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/bits/types.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h /usr/include/bits/stdio_lim.h \ + /usr/include/bits/sys_errlist.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/time.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/select.h \ + /usr/include/bits/select.h /usr/include/bits/sigset.h \ + /usr/include/bits/time.h /usr/include/sys/sysmacros.h \ + /usr/include/bits/pthreadtypes.h /usr/include/alloca.h \ + /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/include/bits/sockaddr.h /usr/include/asm/socket.h \ + /usr/include/asm/sockios.h /usr/include/bits/in.h \ + /usr/include/bits/byteswap.h /usr/include/arpa/inet.h \ + /usr/include/netdb.h /usr/include/rpc/netdb.h /usr/include/bits/netdb.h \ + /usr/include/unistd.h /usr/include/bits/posix_opt.h \ + /usr/include/bits/confname.h /usr/include/getopt.h \ + /usr/include/strings.h /usr/include/sys/time.h /usr/include/errno.h \ + /usr/include/bits/errno.h /usr/include/linux/errno.h \ + /usr/include/asm/errno.h /usr/include/asm-generic/errno.h \ + /usr/include/asm-generic/errno-base.h ../include/correct_bug.h \ + ../include/lauxlib.h ../include/lua.h ../include/lualib.h \ + ../include/net.h ../include/common.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/log.h +enemytempbase.o: enemytempbase.c /usr/include/string.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/stdio.h /usr/include/bits/types.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + ../include/char.h ../include/common.h /usr/include/errno.h \ + /usr/include/bits/errno.h /usr/include/linux/errno.h \ + /usr/include/asm/errno.h /usr/include/asm-generic/errno.h \ + /usr/include/asm-generic/errno-base.h ../include/char_base.h \ + ../include/version.h ../include/sasql.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/time.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/select.h \ + /usr/include/bits/select.h /usr/include/bits/sigset.h \ + /usr/include/bits/time.h /usr/include/sys/sysmacros.h \ + /usr/include/bits/pthreadtypes.h /usr/include/alloca.h \ + /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + ../include/correct_bug.h ../include/skill.h ../include/util.h \ + ../include/title.h ../include/addressbook.h ../include/net.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/readmap.h ../include/map_deal.h ../include/char_base.h \ + ../include/enemy.h ../include/mylua/base.h ../include/char_base.h \ + ../include/lua.h ../include/lauxlib.h ../include/lualib.h \ + ../include/lua.h ../include/lauxlib.h ../include/lualib.h \ + ../include/lssproto_serv.h ../include/lssproto_util.h +sasqlbase.o: sasqlbase.c /usr/include/string.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/bits/wordsize.h \ + /usr/include/gnu/stubs.h /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h ../include/lua.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + ../include/luaconf.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/bits/types.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h /usr/include/bits/stdio_lim.h \ + /usr/include/bits/sys_errlist.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/time.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/select.h \ + /usr/include/bits/select.h /usr/include/bits/sigset.h \ + /usr/include/bits/time.h /usr/include/sys/sysmacros.h \ + /usr/include/bits/pthreadtypes.h /usr/include/alloca.h \ + /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/include/bits/sockaddr.h /usr/include/asm/socket.h \ + /usr/include/asm/sockios.h /usr/include/bits/in.h \ + /usr/include/bits/byteswap.h /usr/include/arpa/inet.h \ + /usr/include/netdb.h /usr/include/rpc/netdb.h /usr/include/bits/netdb.h \ + /usr/include/unistd.h /usr/include/bits/posix_opt.h \ + /usr/include/bits/confname.h /usr/include/getopt.h \ + /usr/include/strings.h /usr/include/sys/time.h /usr/include/errno.h \ + /usr/include/bits/errno.h /usr/include/linux/errno.h \ + /usr/include/asm/errno.h /usr/include/asm-generic/errno.h \ + /usr/include/asm-generic/errno-base.h ../include/correct_bug.h \ + ../include/lauxlib.h ../include/lua.h ../include/lualib.h \ + ../include/net.h ../include/common.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/log.h \ + ../include/sasql.h /usr/include/mysql/mysql.h \ + /usr/include/mysql/mysql_version.h /usr/include/mysql/mysql_com.h \ + /usr/include/mysql/mysql_time.h /usr/include/mysql/typelib.h \ + /usr/include/mysql/my_alloc.h /usr/include/mysql/my_list.h +saacproto.o: saacproto.c /usr/include/string.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/bits/wordsize.h \ + /usr/include/gnu/stubs.h /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h ../include/char.h \ + ../include/common.h /usr/include/stdio.h /usr/include/bits/types.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + ../include/char_base.h ../include/version.h ../include/sasql.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + ../include/correct_bug.h ../include/skill.h ../include/util.h \ + ../include/title.h ../include/addressbook.h ../include/net.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/char_base.h ../include/mylua/base.h ../include/char_base.h \ + ../include/lua.h ../include/lauxlib.h ../include/lualib.h \ + ../include/lua.h ../include/lauxlib.h ../include/lualib.h \ + ../include/saacproto_cli.h ../include/saacproto_util.h +family.o: family.c /usr/include/string.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/bits/wordsize.h \ + /usr/include/gnu/stubs.h /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h ../include/char.h \ + ../include/common.h /usr/include/stdio.h /usr/include/bits/types.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + ../include/char_base.h ../include/version.h ../include/sasql.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + ../include/correct_bug.h ../include/skill.h ../include/util.h \ + ../include/title.h ../include/addressbook.h ../include/net.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/char_base.h ../include/family.h ../include/mylua/base.h \ + ../include/char_base.h ../include/lua.h ../include/lauxlib.h \ + ../include/lualib.h ../include/lua.h ../include/lauxlib.h \ + ../include/lualib.h ../include/saacproto_cli.h \ + ../include/saacproto_util.h +petskill.o: petskill.c /usr/include/string.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/bits/wordsize.h \ + /usr/include/gnu/stubs.h /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + ../include/common.h /usr/include/stdio.h /usr/include/bits/types.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + ../include/version.h ../include/sasql.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/time.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/select.h \ + /usr/include/bits/select.h /usr/include/bits/sigset.h \ + /usr/include/bits/time.h /usr/include/sys/sysmacros.h \ + /usr/include/bits/pthreadtypes.h /usr/include/alloca.h \ + /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + ../include/correct_bug.h ../include/pet_skill.h ../include/util.h \ + ../include/common.h ../include/mylua/base.h ../include/char_base.h \ + ../include/version.h ../include/skill.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/lua.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char.h ../include/char_base.h ../include/char_data.h \ + ../include/item.h ../include/char.h ../include/item.h ../include/lua.h \ + ../include/lauxlib.h ../include/lualib.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h ../include/mylua/mylua.h diff --git a/mylua/mapbase.c b/mylua/mapbase.c new file mode 100644 index 0000000..51a02ae --- /dev/null +++ b/mylua/mapbase.c @@ -0,0 +1,97 @@ +#include +#include +#include "char.h" +#include "readmap.h" +#include "map_deal.h" +#include "char_base.h" +#include "mylua/base.h" +#include "lua.h" +#include "lauxlib.h" +#include "lualib.h" +#include "lssproto_serv.h" + +#ifdef _ALLBLUES_LUA +#ifdef _ALLBLUES_LUA_1_1 +static int RandMap(lua_State *L) +{ + lua_pushinteger(L, MAP_getfloorId(rand()% MAP_getMapNum())); + return 1; +} + +static int RandXAndY(lua_State *L) +{ + const int ff = luaL_checkint(L, 1); + int fx,fy; + int i; + for(i=0;i<50;i++){ + fx = rand() % MAP_getfloorX(ff); + fy = rand() % MAP_getfloorY(ff); + + if(MAP_walkAbleFromPoint( ff,fx,fy,0 )==TRUE){ + lua_pushinteger(L, (fx << 16)|fy ); + return 1; + } + } + lua_pushinteger(L, -1); + return 1; +} + +static int getX(lua_State *L) +{ + const int XandY = luaL_checkint(L, 1); + lua_pushinteger(L, (XandY >> 16)&0xFFFF ); + return 1; +} + +static int getY(lua_State *L) +{ + const int XandY = luaL_checkint(L, 1); + lua_pushinteger(L, XandY&0xFFFF ); + return 1; +} +static int getfloorX(lua_State *L) +{ + const int floorid = luaL_checkint(L, 1); + lua_pushinteger(L, MAP_getfloorX(floorid) ); + return 1; +} + +static int getfloorY(lua_State *L) +{ + const int floorid = luaL_checkint(L, 1); + lua_pushinteger(L, MAP_getfloorY(floorid) ); + return 1; +} + +static int getFloorName(lua_State *L) +{ + const int floorid = luaL_checkint(L, 1); + + char escapeshowstring[256]; + char *showstr = MAP_getfloorShowstring(floorid); + + getStringFromIndexWithDelim( showstr, "|", 1, escapeshowstring, sizeof( escapeshowstring)); + + lua_pushstring(L, escapeshowstring); + return 1; +} + +static const luaL_Reg maplib[] = { + {"RandMap", RandMap}, + {"RandXAndY", RandXAndY}, + {"getfloorX", getfloorX}, + {"getfloorY", getfloorY}, + {"getFloorName", getFloorName}, + {"getX", getX}, + {"getY", getY}, + {NULL, NULL} +}; + +LUALIB_API int luaopen_Map (lua_State *L) { + luaL_register(L, "map", maplib); + return 1; +} +#endif + +#endif + diff --git a/mylua/mylua.c b/mylua/mylua.c new file mode 100644 index 0000000..2dbc713 --- /dev/null +++ b/mylua/mylua.c @@ -0,0 +1,346 @@ +#include +#include +#include +#include +#include +#include "autil.h" +#include "buf.h" +#include "util.h" +#define lua_c +#include "lua.h" +#include "lauxlib.h" +#include "lualib.h" +#include "version.h" +#include "mylua/mylua.h" + + +#ifdef _ALLBLUES_LUA + +MY_Lua MYLua; + +static const char *progname = LUA_PROGNAME; + +int getArrayInt(lua_State *L, int idx) { + int result = 0; + lua_pushnumber(L, idx + 1); + lua_gettable(L, -2); + result = (int)lua_tonumber(L, -1); + lua_pop(L, 1); + return result; +} + + +static void l_message (const char *pname, const char *msg) { + if (pname) fprintf(stderr, "%s: ", pname); + fprintf(stderr, "%s\n", msg); + fflush(stderr); +} + + +static int report (lua_State *L, int status) { + if (status && !lua_isnil(L, -1)) { + const char *msg = lua_tostring(L, -1); + if (msg == NULL) msg = "(error object is not a string)"; + l_message(progname, msg); + lua_pop(L, 1); + } + return status; +} + + +static int traceback (lua_State *L) { + if (!lua_isstring(L, 1)) /* 'message' not a string? */ + return 1; /* keep it intact */ + lua_getfield(L, LUA_GLOBALSINDEX, "debug"); + if (!lua_istable(L, -1)) { + lua_pop(L, 1); + return 1; + } + lua_getfield(L, -1, "traceback"); + if (!lua_isfunction(L, -1)) { + lua_pop(L, 2); + return 1; + } + lua_pushvalue(L, 1); /* pass error message */ + lua_pushinteger(L, 2); /* skip this function and traceback */ + lua_call(L, 2, 1); /* call debug.traceback */ + return 1; +} + + +int docall (lua_State *L, int narg, int clear) { + int status; + int base = lua_gettop(L) - narg; /* function index */ + lua_pushcfunction(L, traceback); /* push traceback function */ + lua_insert(L, base); /* put it under chunk and args */ + + status = lua_pcall(L, narg, (clear ? 0 : LUA_MULTRET), base); + + lua_remove(L, base); /* remove traceback function */ + /* force a complete garbage collection in case of errors */ + if (status != 0) lua_gc(L, LUA_GCCOLLECT, 0); + return status; +} + + +int dofile (lua_State *L, const char *name) { + int status = luaL_loadfile(L, name) || docall(L, 0, 1); + return report(L, status); +} + +char crypto[]=DEFAULTTABLE; + +void DecryptLua(char* buff, int len, int id) +{ + + int i; + int cryptolen = strlen(crypto); + for(i=0;id_name[0] == '.')continue; + if (ent->d_type==8){ + + if( (strcmptail( ent->d_name, ".lua" ) == 0 && flg == 1) + || (strcmptail( ent->d_name, ".allblues") == 0 && flg == 0)){ + char filename[256]; + char token[256]; + sprintf(filename, "%s/%s", path, ent->d_name); + + char *luabuff = NULL; + int luamaxlen = 0; + + if ((f=fopen(filename,"r"))!=NULL) { + fseek(f,0,SEEK_END); + luamaxlen = ftell(f); + luabuff = (char*)malloc(luamaxlen + 1); + memset(luabuff, 0, luamaxlen); + fseek(f,0,SEEK_SET); + fread(luabuff, luamaxlen, 1, f); + fclose(f); + } + + if( flg == 1 ){ + CryptoLua(luabuff, luamaxlen, id); + sprintf(token, "%s.allblues", filename); + }else if( flg == 0 ){ + DecryptLua(luabuff, luamaxlen, id); + sprintf(token, "%s", filename); + + token[strlen(token)-9] = '\0'; + } + if ((f=fopen(token,"w+"))!=NULL) { + fwrite(luabuff,1,luamaxlen,f); + fclose(f); + } + free(luabuff); + } + }else{ + sprintf(filename, "%s/%s", path, ent->d_name); + CryptoAllbluesLUA(filename, flg, id); + } + } +} +#endif +void Cryptodofile(lua_State *L, char *filename) +{ + FILE *f; + + char *luabuff; + char *cfbuff = NULL; + char *buff; + int luamaxlen = 0; + int cfmaxlen = 0; + char head[]="\nfunction init()\n"; + char end[]="\nend\n"; + char filenamecf[256]; + char loadfilename[256]; + strcpy(loadfilename, filename); + + if ((f=fopen(loadfilename,"r"))!=NULL) { + fseek(f,0,SEEK_END); + luamaxlen = ftell(f); + luabuff = (char*)malloc(luamaxlen + 1); + memset(luabuff, 0, luamaxlen + 1); + fseek(f,0,SEEK_SET); + fread(luabuff, luamaxlen, 1, f); + fclose(f); + }else{ + return; + } +/* + CryptoLua(buff, maxlen, _ATTESTAION_ID); + char token[256]; + sprintf(token, "%s.allblues", filename); + if ((f=fopen(token,"w+"))!=NULL) { + fwrite(buff,1,maxlen,f); + fclose(f); + } +*/ + + + DecryptLua(luabuff, luamaxlen, 1); + loadfilename[strlen(loadfilename)-9] = '\0'; + + sprintf(filenamecf, "%s.cf", filename); + if ((f=fopen(filenamecf,"r"))!=NULL) { + fseek(f,0,SEEK_END); + cfmaxlen = ftell(f); + cfbuff = (char*)malloc(cfmaxlen + 1); + memset(cfbuff, 0, cfmaxlen + 1); + fseek(f,0,SEEK_SET); + fread(cfbuff, cfmaxlen, 1, f); + + fclose(f); + } + + int len = luamaxlen + cfmaxlen + strlen(head) + strlen(end) + 1; + buff = (char*)malloc(len); + memset(buff, 0, len); + len = 0; + memcpy( buff + len, head, strlen(head)); + len += strlen(head); + if(cfmaxlen > 0){ + memcpy( buff + len, cfbuff, cfmaxlen); + free(cfbuff); + } + len += cfmaxlen; + memcpy( buff + len, end, strlen(end)); + len += strlen(end); + memcpy( buff + len, luabuff, luamaxlen); + + luaL_dostring(L, buff); + + free(buff); + free(luabuff); +} + +int myluaload (char *filename) +{ + MY_Lua *mylua = &MYLua; + while(mylua->next!=NULL){ + if(strcmp(mylua->luapath, filename) == 0){ + return FALSE; + } + mylua = mylua->next; + } + mylua->luapath = allocateMemory( strlen(filename) ); + memset( mylua->luapath, 0 , strlen(filename) ); + strcpy(mylua->luapath, filename); + mylua->next = allocateMemory( sizeof(MY_Lua) ); + memset( mylua->next, 0 , sizeof(MY_Lua) ); + if(mylua->next == NULL)return EXIT_FAILURE; + + mylua->lua = lua_open(); /* create state */ + + if (mylua->lua == NULL) { + return FALSE; + } + + lua_gc(mylua->lua, LUA_GCSTOP, 0); /* stop collector during initialization */ + luaL_openlibs(mylua->lua); /* open libraries */ + luaAB_openlibs(mylua->lua); + lua_gc(mylua->lua, LUA_GCRESTART, 0); + + if(strcmptail( filename, ".allblues" ) == 0){ + Cryptodofile(mylua->lua, filename); + }else{ + dofile(mylua->lua, filename); + } + + lua_getglobal(mylua->lua, "init"); + if (lua_isfunction(mylua->lua, -1)) { + docall(mylua->lua, 0, 1); + } + + lua_getglobal(mylua->lua, "main"); + + if (lua_isfunction(mylua->lua, -1)) { + docall(mylua->lua, 0, 1); + } + + return TRUE; +} + +int remyluaload (char *filename) +{ + MY_Lua *mylua = &MYLua; + + while(mylua->next!=NULL){ + if(strlen(mylua->luapath) > 0){ + if(strlen(filename)>0){ + if(strstr(mylua->luapath, filename) == 0){ + mylua = mylua->next; + continue; + } + } + + lua_gc(mylua->lua, LUA_GCSTOP, 0); + luaL_openlibs(mylua->lua); + luaAB_openlibs(mylua->lua); + lua_gc(mylua->lua, LUA_GCRESTART, 0); + if(strcmptail( mylua->luapath, ".allblues" ) == 0){ + if ((fopen(mylua->luapath,"r"))==NULL) { + mylua = mylua->next; + continue; + } + Cryptodofile(mylua->lua, mylua->luapath); + }else{ + dofile(mylua->lua, mylua->luapath); + } + + lua_getglobal(mylua->lua, "data"); + + if (lua_isfunction(mylua->lua, -1)) { + docall(mylua->lua, 0, 1); + } + + } + mylua = mylua->next; + } + + return EXIT_SUCCESS; +} + + +int closemyluaload() +{ + MY_Lua *mylua = &MYLua; + while(mylua->next!=NULL){ + lua_pop(mylua->lua, 1); + lua_close(mylua->lua); + mylua = mylua->next; + } + + return EXIT_SUCCESS; +} + + +#endif + diff --git a/mylua/netbase.c b/mylua/netbase.c new file mode 100644 index 0000000..61ab702 --- /dev/null +++ b/mylua/netbase.c @@ -0,0 +1,87 @@ +#include +#include "lua.h" +#include "version.h" +#include "lauxlib.h" +#include "lualib.h" +#include "net.h" +#include "log.h" + +#ifdef _ALLBLUES_LUA + +static int endOne(lua_State *L) +{ + const int sockfd = luaL_checkint(L, 1); + + CONNECT_endOne_debug(sockfd); + + return 1; +} + +static int userip(lua_State *L) +{ + int charaindex = luaL_checkint(L, 1); + + int sockfd = getfdFromCharaIndex(charaindex); + + unsigned long ip; + int a,b,c,d; + char strIP[32]; + ip = CONNECT_get_userip(sockfd); + + a=(ip % 0x100); ip=ip / 0x100; + b=(ip % 0x100); ip=ip / 0x100; + c=(ip % 0x100); ip=ip / 0x100; + d=(ip % 0x100); + + sprintf(strIP, "%d.%d.%d.%d", a, b, c, d); + + lua_pushstring(L, strIP); + return 1; +} + +#ifdef _ALLBLUES_LUA_2_0 +static int getIP(lua_State *L) +{ + int sockfd = luaL_checkint(L, 1); + + unsigned long ip; + int a,b,c,d; + char strIP[32]; + ip = CONNECT_get_userip(sockfd); + + a=(ip % 0x100); ip=ip / 0x100; + b=(ip % 0x100); ip=ip / 0x100; + c=(ip % 0x100); ip=ip / 0x100; + d=(ip % 0x100); + + sprintf(strIP, "%d.%d.%d.%d", a, b, c, d); + + lua_pushstring(L, strIP); + return 1; +} + +static int getUse(lua_State *L) +{ + int fd = luaL_checkint(L, 1); + lua_pushboolean(L,CONNECT_getUse(fd )); + return 1; +} +#endif + +static const luaL_Reg netlib[] = { + {"endOne", endOne}, + {"userip", userip}, +#ifdef _ALLBLUES_LUA_2_0 + {"getIP", getIP}, + {"getUse", getUse}, +#endif + {NULL, NULL} +}; + + +LUALIB_API int luaopen_Net (lua_State *L) { + luaL_register(L, "net", netlib); + return 1; +} + +#endif diff --git a/mylua/npcbase.c b/mylua/npcbase.c new file mode 100644 index 0000000..d6bf534 --- /dev/null +++ b/mylua/npcbase.c @@ -0,0 +1,607 @@ +#include +#include "battle.h" +#include "char_base.h" +#include "npccreate.h" +#include "object.h" +#include "char.h" +#include "enemy.h" +#include "char_base.h" +#include "npc_eventaction.h" +#include "lua.h" +#include "version.h" +#include "lauxlib.h" +#include "lualib.h" +#include "npcutil.h" +#include "log.h" +#ifdef _ALLBLUES_LUA + +static int CreateNpc (lua_State *L) { + Char one; + size_t l; + CHAR_getDefaultChar( &one, 0); + one.data[CHAR_WHICHTYPE] = CHAR_TYPELUANPC; + char *Name = luaL_checklstring(L, 1, &l); + const int Image = luaL_checkinteger(L, 2); + const int Floor = luaL_checkinteger(L, 3); + const int x = luaL_checkinteger(L, 4); + const int y = luaL_checkinteger(L, 5); + const int dir = luaL_checkinteger(L, 6); + + strcpysafe( one.string[CHAR_NAME].string , + sizeof(one.string[CHAR_NAME].string), + Name); + one.data[CHAR_BASEBASEIMAGENUMBER] = Image; + one.data[CHAR_BASEIMAGENUMBER] = Image; + one.data[CHAR_FLOOR]=Floor; + one.data[CHAR_X]=x; + one.data[CHAR_Y]=y; + one.data[CHAR_DIR] = dir; + + int npcindex = CHAR_initCharOneArray(&one); + + if( npcindex < 0 ) { + print( "NPCʧܡ\n"); + } + + Object object; + int objindex; + + + object.type = OBJTYPE_CHARA; + object.index = npcindex; + object.x =CHAR_getInt(npcindex, CHAR_X); + object.y = CHAR_getInt(npcindex, CHAR_Y); + object.floor = CHAR_getInt(npcindex, CHAR_FLOOR); + + objindex = initObjectOne( &object ); + + if( objindex == -1 ) { + CHAR_endCharOneArray( npcindex ); + }else { + CHAR_setWorkInt( npcindex,CHAR_WORKOBJINDEX, objindex ); + CHAR_LoginBesideSetWorkInt( npcindex, -1 ); + } + + lua_pushinteger(L, npcindex); + return 1; +} + +#ifdef _DEL_FAME +static int DelFame (lua_State *L) +{ + size_t l; + const int index = luaL_checkint(L, 1); + char *data = luaL_checklstring(L, 2, &l); + + NPC_ActionDelFame(index, data); + return 1; +} +#endif +static int AddGold (lua_State *L) +{ + size_t l; + const int index = luaL_checkint(L, 1); + char *data = luaL_checklstring(L, 2, &l); + + NPC_ActionAddGold2(index, data); + return 1; +} + + +static int DelGold (lua_State *L) +{ + size_t l; + const int index = luaL_checkint(L, 1); + char *data = luaL_checklstring(L, 2, &l); + + NPC_ActionDelGold(index, data); + return 1; +} +#ifdef _MOMENTUM_NPC +static int DelMom (lua_State *L) +{ + size_t l; + const int index = luaL_checkint(L, 1); + char *data = luaL_checklstring(L, 2, &l); + + NPC_ActionMomentum(index, data); + return 1; +} +#endif +#ifdef _DP_NPC +static int DelDP (lua_State *L) +{ + size_t l; + const int index = luaL_checkint(L, 1); + char *data = luaL_checklstring(L, 2, &l); + + NPC_ActionDP(index, data); + return 1; +} +#endif +static int DelItem (lua_State *L) +{ + size_t l; + const int index = luaL_checkint(L, 1); + char *data = luaL_checklstring(L, 2, &l); + + NPC_ActionDelItem(index, data); + return 1; +} + + +static int AddItem (lua_State *L) +{ + size_t l; + const int index = luaL_checkint(L, 1); + char *data = luaL_checklstring(L, 2, &l); + + NPC_ActionAddItem(index, data); + return 1; +} + +static int AddPet (lua_State *L) +{ + size_t l; + const int index = luaL_checkint(L, 1); + char *data = luaL_checklstring(L, 2, &l); + + NPC_ActionAddPet(index, data); + return 1; +} + +static int EvEnd (lua_State *L) +{ + size_t l; + const int index = luaL_checkint(L, 1); + char *data = luaL_checklstring(L, 2, &l); + + NPC_ActionSetEend(index, data); + return 1; +} + +static int EvNow (lua_State *L) +{ + size_t l; + const int index = luaL_checkint(L, 1); + char *data = luaL_checklstring(L, 2, &l); + + NPC_ActionSetNow(index, data); + return 1; +} + +static int Event_End (lua_State *L) +{ + size_t l; + const int index = luaL_checkint(L, 1); + char *data = luaL_checklstring(L, 2, &l); + + NPC_ActionSetEend(index, data); + return 1; +} + +static int Event_Now (lua_State *L) +{ + size_t l; + const int index = luaL_checkint(L, 1); + char *data = luaL_checklstring(L, 2, &l); + + NPC_ActionSetNow(index, data); + return 1; +} + +static int EvClr (lua_State *L) +{ + size_t l; + const int index = luaL_checkint(L, 1); + char *data = luaL_checklstring(L, 2, &l); + + NPC_ActionClearEvent(index, data); + return 1; +} + +#ifdef _VIP_SHOP +static int VipItem (lua_State *L) +{ + size_t l; + const int index = luaL_checkint(L, 1); + char *data = luaL_checklstring(L, 2, &l); + + NPC_ActionVipItem(index, data); + return 1; +} + +static int VipPet (lua_State *L) +{ + size_t l; + const int index = luaL_checkint(L, 1); + char *data = luaL_checklstring(L, 2, &l); + + NPC_ActionVipPet(index, data); + return 1; +} +#endif + +#ifdef _NEW_VIP_SHOP +static int Vip_Item (lua_State *L) +{ + size_t l; + const int index = luaL_checkint(L, 1); + char *data = luaL_checklstring(L, 2, &l); + + NPC_ActionVipItem(index, data); + return 1; +} + +static int Vip_Pet (lua_State *L) +{ + size_t l; + const int index = luaL_checkint(L, 1); + char *data = luaL_checklstring(L, 2, &l); + + NPC_ActionVipPet(index, data); + return 1; +} +#endif + +#ifdef _NPC_ADDLEVELUP +static int SetLevel (lua_State *L) +{ + size_t l; + const int index = luaL_checkint(L, 1); + char *data = luaL_checklstring(L, 2, &l); + + NPC_ActionLevelAndTransUp( 0, index, atoi(data), 0, 0, -1); + return 1; +} + +static int AddExps (lua_State *L) +{ + size_t l; + const int index = luaL_checkint(L, 1); + char *data = luaL_checklstring(L, 2, &l); + + NPC_ActionLevelAndTransUp( 0, index, 0, 0, atoi(data), -1); + return 1; +} + +static int AddSkillPoint (lua_State *L) +{ + size_t l; + const int index = luaL_checkint(L, 1); + char *data = luaL_checklstring(L, 2, &l); + + NPC_ActionLevelAndTransUp( 0, index, 0, atoi(data), 0, -1); + return 1; +} + +static int SetRideType (lua_State *L) +{ + size_t l; + const int index = luaL_checkint(L, 1); + char *data = luaL_checklstring(L, 2, &l); + + NPC_ActionLevelAndTransUp( 0, index, 0, 0, 0, atoi(data)); + return 1; +} +#endif + +static int isFaceToFace (lua_State *L) +{ + const int meindex = luaL_checkint(L, 1); + const int talkerindex = luaL_checkint(L, 2); + + + if(NPC_Util_isFaceToFace( meindex ,talkerindex ,2)==FALSE){ + if( NPC_Util_CharDistance( talkerindex ,meindex ) > 1) { + lua_pushinteger(L, 0); + return 1; + } + } + + lua_pushinteger(L, 1); + return 1; +} + +static int ActionPassCheck (lua_State *L) +{ + size_t l; + const int meindex = luaL_checkint(L, 1); + const int toindex = luaL_checkint(L, 2); + char *data = luaL_checklstring(L, 3, &l); + + if( NPC_ActionPassCheck( meindex, toindex, data) == FALSE ) { + lua_pushinteger(L, 0); + return 1; + } + + lua_pushinteger(L, 1); + return 1; +} + + +#ifdef _ALLBLUES_LUA_1_1 +static int SetPoint (lua_State *L) +{ + const int meindex = luaL_checkint(L, 1); + const int ff = luaL_checkint(L, 2); + const int fx = luaL_checkint(L, 3); + const int fy = luaL_checkint(L, 4); + + OBJECT_setFloor(CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), ff); + OBJECT_setX(CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), fx); + OBJECT_setY(CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), fy); + CHAR_setInt(meindex, CHAR_FLOOR, ff); + CHAR_setInt(meindex, CHAR_X, fx); + CHAR_setInt(meindex, CHAR_Y, fy); + CHAR_sendCDArroundChar( ff, fx, fy, CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX)); + return 1; +} + + +static int DelItemNum (lua_State *L) +{ + size_t l; + const int index = luaL_checkint(L, 1); + char *data = luaL_checklstring(L, 2, &l); + char tmp[16]; + int itemID = 0; + int itemNUM = 0; + + if( getStringFromIndexWithDelim( data, ",", 1, tmp, sizeof( tmp)) != FALSE ){ + itemID = atoi(tmp); + } + + if( getStringFromIndexWithDelim( data, ",", 2, tmp, sizeof( tmp)) != FALSE ){ + itemNUM = atoi(tmp); + } + + int i, itemindex; + char token[256]; + int num=0; + + for( i = CHAR_STARTITEMARRAY ; i < CHAR_MAXITEMHAVE ; i++ ){ + if(num >= itemNUM)break; + itemindex = CHAR_getItemIndex( index , i ); + if( !ITEM_CHECKINDEX(itemindex) ) continue; + if( ITEM_getInt(itemindex, ITEM_ID) != itemID ) continue; + sprintf( token, "%s",ITEM_getChar( itemindex, ITEM_NAME)); + CHAR_talkToCli( index, -1, token, CHAR_COLORYELLOW); + + LogItem( + CHAR_getChar( index, CHAR_NAME ), + CHAR_getChar( index, CHAR_CDKEY ), +#ifdef _add_item_log_name // WON ADD itemlogitem + itemindex, +#else + ITEM_getInt( itemindex, ITEM_ID), +#endif + "ȡ", + CHAR_getInt( index,CHAR_FLOOR), + CHAR_getInt( index,CHAR_X ), + CHAR_getInt( index,CHAR_Y ), + ITEM_getChar( itemindex, ITEM_UNIQUECODE), + ITEM_getChar( itemindex, ITEM_NAME), + ITEM_getInt( itemindex, ITEM_ID) + ); + CHAR_setItemIndex( index, i, -1); + ITEM_endExistItemsOne( itemindex); + CHAR_sendItemDataOne( index, i); + num++; + } + + lua_pushinteger(L, num); + return 1; +} + +static int DelNpc (lua_State *L) +{ + const int index = luaL_checkint(L, 1); + + if( !CHAR_CHECKINDEX( index ) ){ + print( "ANDY index=%d err\n", index); + return 1; + } + + CHAR_ObjectDelete(CHAR_getWorkInt( index,CHAR_WORKOBJINDEX)); + + CHAR_endCharOneArray( index ); + return 1; +} + +#endif + + + +#ifdef _PLAYER_NPC +static int CreateSpecialNpc (lua_State *L) +{ + Char one; + size_t l; + CHAR_getDefaultChar( &one, 0); + one.data[CHAR_WHICHTYPE] = CHAR_TYPELUANPC; + char *Name = luaL_checklstring(L, 1, &l); + const int Image = luaL_checkinteger(L, 2); + const int Floor = luaL_checkinteger(L, 3); + const int x = luaL_checkinteger(L, 4); + const int y = luaL_checkinteger(L, 5); + const int dir = luaL_checkinteger(L, 6); + const int enemyid = luaL_checkint(L, 7); + const int UpLevel = luaL_checkinteger(L, 8); + int i; + for( i = 0; i < ENEMY_getEnemyNum(); i ++ ) { + if( ENEMY_getInt( i, ENEMY_ID) == enemyid) { + break; + } + } + if( i == ENEMY_getEnemyNum() ){ + lua_pushinteger(L, -1); + return 1; + } + + int npcindex = ENEMY_createEnemy( i, 0); + if( npcindex < 0 ) { + print( "NPCʧܡ\n"); + } + CHAR_setInt(npcindex, CHAR_WHICHTYPE, CHAR_TYPEPLAYERNPC); + CHAR_setChar(npcindex, CHAR_NAME, Name); + CHAR_setInt(npcindex, CHAR_BASEBASEIMAGENUMBER, Image); + CHAR_setInt(npcindex, CHAR_BASEIMAGENUMBER, Image); + CHAR_setInt(npcindex, CHAR_FLOOR, Floor); + CHAR_setInt(npcindex, CHAR_X, x); + CHAR_setInt(npcindex, CHAR_Y, y); + CHAR_setInt(npcindex, CHAR_DIR, dir); + + CHAR_setInt(npcindex, CHAR_MODAI, 10000); + CHAR_setInt(npcindex, CHAR_VARIABLEAI,10000); + + for( i = 0; i < UpLevel; i ++ ){ + CHAR_PetLevelUp( npcindex ); + CHAR_PetAddVariableAi( npcindex, AI_FIX_PETLEVELUP ); + } + CHAR_complianceParameter( npcindex ); + CHAR_setInt( npcindex, CHAR_HP, CHAR_getWorkInt( npcindex, CHAR_WORKMAXHP )); + Object object; + int objindex; + + object.type = OBJTYPE_CHARA; + object.index = npcindex; + object.x =CHAR_getInt(npcindex, CHAR_X); + object.y = CHAR_getInt(npcindex, CHAR_Y); + object.floor = CHAR_getInt(npcindex, CHAR_FLOOR); + + objindex = initObjectOne( &object ); + + if( objindex == -1 ) { + CHAR_endCharOneArray( npcindex ); + }else { + CHAR_setWorkInt( npcindex,CHAR_WORKOBJINDEX, objindex ); + CHAR_LoginBesideSetWorkInt( npcindex, -1 ); + } + + lua_pushinteger(L, npcindex); + return 1; +} +#endif + +#ifdef _ALLBLUES_LUA_1_4 +#ifdef _PLAYER_NPC +static int CreatePlayer (lua_State *L) { + Char one; + size_t l; + CHAR_getDefaultChar( &one, 0); + one.data[CHAR_WHICHTYPE] = CHAR_TYPEPLAYERNPC; + char *Name = luaL_checklstring(L, 1, &l); + const int Image = luaL_checkinteger(L, 2); + const int Floor = luaL_checkinteger(L, 3); + const int x = luaL_checkinteger(L, 4); + const int y = luaL_checkinteger(L, 5); + const int dir = luaL_checkinteger(L, 6); + + strcpysafe( one.string[CHAR_NAME].string , + sizeof(one.string[CHAR_NAME].string), + Name); + one.data[CHAR_BASEBASEIMAGENUMBER] = Image; + one.data[CHAR_BASEIMAGENUMBER] = Image; + one.data[CHAR_FLOOR]=Floor; + one.data[CHAR_X]=x; + one.data[CHAR_Y]=y; + one.data[CHAR_DIR] = dir; + + int npcindex = CHAR_initCharOneArray(&one); + + if( npcindex < 0 ) { + print( "NPCʧܡ\n"); + } + + Object object; + int objindex; + + + object.type = OBJTYPE_CHARA; + object.index = npcindex; + object.x =CHAR_getInt(npcindex, CHAR_X); + object.y = CHAR_getInt(npcindex, CHAR_Y); + object.floor = CHAR_getInt(npcindex, CHAR_FLOOR); + + objindex = initObjectOne( &object ); + + if( objindex == -1 ) { + CHAR_endCharOneArray( npcindex ); + lua_pushinteger(L, -1); + return 1; + } + + CHAR_setWorkInt( npcindex,CHAR_WORKOBJINDEX, objindex ); + CHAR_LoginBesideSetWorkInt( npcindex, -1 ); + + CHAR_setFlg( npcindex, CHAR_ISDUEL, 0); + CHAR_setFlg( npcindex, CHAR_ISTRADECARD, 0); + CHAR_setFlg( npcindex, CHAR_ISTRADE, 0); + CHAR_setFlg( npcindex, CHAR_ISPARTY, 0); + + lua_pushinteger(L, npcindex); + return 1; +} +#endif +#endif + + +static const luaL_Reg npclib[] = { + {"CreateNpc", CreateNpc}, +#ifdef _DEL_FAME + {"DelFame", DelFame}, +#endif + {"AddGold", AddGold}, + {"DelGold", DelGold}, +#ifdef _MOMENTUM_NPC + {"DelMom", DelMom}, +#endif +#ifdef _DP_NPC + {"DelDP", DelDP}, +#endif + {"DelItem", DelItem}, + {"AddItem", AddItem}, + {"AddPet", AddPet}, + {"EvEnd", EvEnd}, + {"EvNow", EvNow}, + {"Event_End", Event_End}, + {"Event_Now", Event_Now}, + {"EvClr", EvClr}, +#ifdef _VIP_SHOP + {"VipItem", VipItem}, + {"VipPet", VipPet}, +#endif +#ifdef _NEW_VIP_SHOP + {"Vip_Item", Vip_Item}, + {"Vip_Pet", Vip_Pet}, +#endif +#ifdef _NPC_ADDLEVELUP + {"SetLevel", SetLevel}, + {"AddExps", AddExps}, + {"AddSkillPoint", AddSkillPoint}, + {"SetRideType", SetRideType}, +#endif + {"isFaceToFace", isFaceToFace}, + {"Free", ActionPassCheck}, +#ifdef _ALLBLUES_LUA_1_1 + {"SetPoint", SetPoint}, + {"DelItemNum", DelItemNum}, + {"DelNpc", DelNpc}, +#endif +#ifdef _PLAYER_NPC + {"CreateSpecialNpc", CreateSpecialNpc}, +#ifdef _ALLBLUES_LUA_1_4 + {"CreatePlayer", CreatePlayer}, +#endif +#endif + {NULL, NULL} +}; + + +LUALIB_API int luaopen_NPC (lua_State *L) { + luaL_register(L, "npc", npclib); + return 1; +} + +#endif diff --git a/mylua/objectbase.c b/mylua/objectbase.c new file mode 100644 index 0000000..c96bc55 --- /dev/null +++ b/mylua/objectbase.c @@ -0,0 +1,140 @@ +#include +#include "char_base.h" +#include "object.h" +#include "version.h" +#include "lua.h" +#include "lauxlib.h" +#include "lualib.h" +#include "mylua/base.h" + +#ifdef _ALLBLUES_LUA + +static CharBase CharBaseObj[] = { + {{"ɫ"}, OBJTYPE_CHARA} + ,{{""}, OBJTYPE_ITEM} + ,{{""}, OBJTYPE_GOLD} + ,{{""}, OBJTYPE_WARPPOINT} +}; + +static int check (lua_State *L) { + const int index = luaL_checkint(L, 1); + lua_pushinteger(L, CHECKOBJECT(index)); + return 1; +} + +static int getType (lua_State *L) { + const int index = luaL_checkint(L, 1); + lua_pushinteger(L, OBJECT_getType(index)); + return 1; +} + +static int setType (lua_State *L) { + const int index = luaL_checkint(L, 1); + const int element = getCharBaseValue(L, 2, CharBaseObj, arraysizeof(CharBaseObj)); + OBJECT_setType(index, element); + return 1; +} + +static int getFloor (lua_State *L) { + const int index = luaL_checkint(L, 1); + lua_pushinteger(L, OBJECT_getFloor(index)); + return 1; +} + +static int setFloor (lua_State *L) { + const int index = luaL_checkint(L, 1); + const int floor = luaL_checkint(L, 2); + OBJECT_setFloor(index, floor); + return 1; +} + +static int getX (lua_State *L) { + const int index = luaL_checkint(L, 1); + lua_pushinteger(L, OBJECT_getX(index)); + return 1; +} + +static int setX (lua_State *L) { + const int index = luaL_checkint(L, 1); + const int x = luaL_checkint(L, 2); + OBJECT_setX(index, x); + return 1; +} + +static int getY (lua_State *L) { + const int index = luaL_checkint(L, 1); + lua_pushinteger(L, OBJECT_getY(index)); + return 1; +} + +static int setY (lua_State *L) { + const int index = luaL_checkint(L, 1); + const int y = luaL_checkint(L, 2); + OBJECT_setY(index, y); + return 1; +} + +static int getIndex (lua_State *L) { + const int index = luaL_checkint(L, 1); + lua_pushinteger(L, OBJECT_getIndex(index)); + return 1; +} + +static int getNum (lua_State *L) { + lua_pushinteger(L, OBJECT_getNum()); + return 1; +} +static int setIndex (lua_State *L) { + const int index = luaL_checkint(L, 1); + const int charaindex = luaL_checkint(L, 2); + OBJECT_setIndex(index, charaindex); + return 1; +} + +static int getchartype (lua_State *L) { + const int index = luaL_checkint(L, 1); + lua_pushinteger(L, OBJECT_getchartype(index)); + return 1; +} + +static int setchartype (lua_State *L) { + const int index = luaL_checkint(L, 1); + const int flg = luaL_checkint(L, 2); + OBJECT_setchartype(index, flg); + return 1; +} + +static int DelObjectOne (lua_State *L) { + const int index = luaL_checkint(L, 1); + endObjectOne(index); + return 1; +} + + +static const luaL_Reg objectlib[] = { + {"check", check}, + {"getType", getType}, + {"setType", setType}, + {"getFloor", getFloor}, + {"setFloor", setFloor}, + {"getX", getX}, + {"setX", setX}, + {"getY", getY}, + {"setY", setY}, + {"getIndex", getIndex}, + {"setIndex", setIndex}, + {"getNum", getNum}, + {"getchartype", getchartype}, + {"setchartype", setchartype}, + {"DelObjectOne", DelObjectOne}, + {NULL, NULL} +}; + + +LUALIB_API int luaopen_Object (lua_State *L) { + luaL_register(L, "obj", objectlib); + return 1; +} + +#endif + diff --git a/mylua/offlinebase.c b/mylua/offlinebase.c new file mode 100644 index 0000000..fcced2d --- /dev/null +++ b/mylua/offlinebase.c @@ -0,0 +1,89 @@ +#include +#include "version.h" +#include "char_base.h" +#include "enemy.h" +#include "object.h" +#include "char.h" +#include "battle.h" +#include "lua.h" +#include "lauxlib.h" +#include "lualib.h" +#include "mylua/mylua.h" + +#ifdef _OFFLINE_SYSTEM +static int Attack(lua_State *L) +{ + const int battleindex = luaL_checkint(L, 1); + const int charaindex = luaL_checkint(L, 2); + const int side = 1 - luaL_checkint(L, 3); + + + + BATTLE_ENTRY *pEntry = BattleArray[battleindex].Side[side].Entry; + int iNum[10] = {9,7,5,6,8,4,2,0,1,3}; + int i; + for( i = 0; i < 10; i ++ ){ + if( pEntry[iNum[i]].charaindex != -1 ){ + break; + } + } + + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_ATTACK ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, iNum[i] + side * BATTLE_ENTRY_MAX); + int At_SoubiIndex = CHAR_getItemIndex( charaindex, CHAR_ARM ); + if( ITEM_CHECKINDEX( At_SoubiIndex ) == TRUE ) + { + if( ITEM_getInt( At_SoubiIndex, ITEM_TYPE ) == ITEM_BOOMERANG ){ + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_BOOMERANG ); +#ifdef _PETSKILL_BECOMEFOX + if( CHAR_getInt( charaindex, CHAR_BASEIMAGENUMBER)==101749 + || CHAR_getWorkInt( charaindex, CHAR_WORKFOXROUND ) != -1 ){ //DZС겻ʹû + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_NONE ); + } +#endif +#ifdef _PETSKILL_BECOMEPIG + if( CHAR_getInt( charaindex, CHAR_BECOMEPIG) > -1 ){// + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_ATTACK ); + } +#endif + } + } + CHAR_SETWORKINT_LOW( charaindex, CHAR_WORKBATTLECOM3, 1 ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + + return 1; +} + +static int Recovery(lua_State *L) +{ + const int battleindex = luaL_checkint(L, 1); + const int charaindex = luaL_checkint(L, 2); + const int HP = luaL_checkint(L, 3); + + + int toNO = BATTLE_Index2No(battleindex, charaindex); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_S_OFFLINE_RECOVERY ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, toNO); + CHAR_SETWORKINT_LOW( charaindex, CHAR_WORKBATTLECOM3, HP ); + + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + + return 1; +} + + + +static const luaL_Reg offlinelib[] = { + {"Attack", Attack}, + {"Recovery", Recovery}, + {NULL, NULL} +}; + + +LUALIB_API int luaopen_Offline (lua_State *L) { + luaL_register(L, "offline", offlinelib); + return 1; +} + +#endif + diff --git a/mylua/otherbase.c b/mylua/otherbase.c new file mode 100644 index 0000000..9ec48fd --- /dev/null +++ b/mylua/otherbase.c @@ -0,0 +1,126 @@ +#include +#include +#include +#include "char.h" +#include "char_base.h" +#include "mylua/base.h" +#include "util.h" +#include "lua.h" +#include "lauxlib.h" +#include "lualib.h" +#include "lssproto_serv.h" +#include "mylua/mylua.h" + +#ifdef _ALLBLUES_LUA +extern MY_Lua MYLua; + +static int nowtime(lua_State *L) +{ + lua_pushinteger(L, (int) time( NULL )); + return 1; +} + +static int strtoi(lua_State *L) +{ + size_t l; + char *data=luaL_checklstring(L, 1, &l); + lua_pushinteger(L, atoi(data)); + return 1; +} + +static int getString(lua_State *L) +{ + size_t l; + char *data = luaL_checklstring(L, 1, &l); + char *delim = luaL_checklstring(L, 2, &l); + const int index = luaL_checkint(L, 3); + + char token[256]; + if(getStringFromIndexWithDelim( data, delim, index, token, sizeof( token))){ + lua_pushstring(L, token); + }else{ + lua_pushstring(L, ""); + } + return 1; +} + +static int CallFunction(lua_State *L) +{ + size_t l; + char *funcname = luaL_checklstring(L, 1, &l); + char *filename = luaL_checklstring(L, 2, &l); + char newfilename[256]; + luaL_checktype(L, 3, LUA_TTABLE); + int n = luaL_getn(L, 3); + + lua_State *lua = NULL; + + MY_Lua *mylua = &MYLua; + while(mylua->next != NULL){ + if(strcmptail( mylua->luapath, ".allblues" ) == 0 + && strcmptail( filename, ".lua" ) == 0 ){ + sprintf(newfilename, "%s.allblues", filename); + }else{ + sprintf(newfilename, "%s", filename); + } + + if(strcmp(newfilename, mylua->luapath) == 0){ + lua = mylua->lua; + break; + } + mylua = mylua->next; + } + if (lua == NULL) { + return FALSE; + } + + lua_getglobal(lua, funcname); + + if (!lua_isfunction(lua, -1)) { + return FALSE; + } + + int i; + + for(i = 0; i < n; i++){ + lua_pushnumber(lua, getArrayInt(L, i)); + } + + + lua_pcall(lua, n, 1, 0); + + lua_isnumber(lua, -1); + + int ret = lua_tonumber(lua, -1); + lua_pushinteger(L, ret); + return TRUE; +} + + +static int c10to62(lua_State *L) +{ + const int index = luaL_checkint(L, 1); + + char token[256]; + cnv10to62( index, token, sizeof(token)); + + lua_pushstring(L, token); + return 1; +} + +static const luaL_Reg otherlib[] = { + {"time", nowtime}, + {"atoi", strtoi}, + {"getString", getString}, + {"CallFunction", CallFunction}, + {"c10to62", c10to62}, + {NULL, NULL} +}; + +LUALIB_API int luaopen_Other (lua_State *L) { + luaL_register(L, "other", otherlib); + return 1; +} + +#endif + diff --git a/mylua/petskill.c b/mylua/petskill.c new file mode 100644 index 0000000..0299e49 --- /dev/null +++ b/mylua/petskill.c @@ -0,0 +1,115 @@ +#include +#include "common.h" +#include "version.h" +#include "pet_skill.h" +#include "mylua/base.h" +#include "char.h" +#include "item.h" +#include "lua.h" +#include "lauxlib.h" +#include "lualib.h" +#include "lssproto_serv.h" + +#ifdef _ALLBLUES_LUA_1_8 +#include "mylua/mylua.h" +extern MY_Lua MYLua; +static CharBase PetSkillBaseInt[] = { + {{""}, PETSKILL_ID} + ,{{"ֶ"}, PETSKILL_FIELD} + ,{{"Ŀ"}, PETSKILL_TARGET} +#ifdef _PETSKILL2_TXT + ,{{""}, PETSKILL_USETYPE} +#endif + ,{{"ֵ"}, PETSKILL_COST} + ,{{"Ƿ"}, PETSKILL_ILLEGAL} +}; + +static CharBase PetSkillBaseChar[] = { + {{""}, PETSKILL_NAME} + ,{{"ע"}, PETSKILL_COMMENT} + ,{{""}, PETSKILL_FUNCNAME} + ,{{"ѡ"}, PETSKILL_OPTION} +#ifdef _CFREE_petskill + ,{{""}, PETSKILL_FREE} + ,{{""}, PETSKILL_KINDCODE} +#endif +}; + +static int getInt(lua_State *L) +{ + const int index = luaL_checkint(L, 1); + const int element = getCharBaseValue(L, 2, PetSkillBaseInt, arraysizeof(PetSkillBaseInt)); + + lua_pushinteger(L, PETSKILL_getInt(index, element)); + return 1; +} + +static int setInt(lua_State *L) +{ + const int index = luaL_checkint(L, 1); + const int element = getCharBaseValue(L, 2, PetSkillBaseInt, arraysizeof(PetSkillBaseInt)); + const int data = luaL_checkint(L, 3); + + if(PETSKILL_setInt(index, element, data) == -1){ + return 0; + }else{ + return 1; + } +} + +static int getChar(lua_State *L) +{ + const int index = luaL_checkint(L, 1); + const int element = getCharBaseValue(L, 2, PetSkillBaseChar, arraysizeof(PetSkillBaseChar)); + + lua_pushstring(L, PETSKILL_getChar(index, element)); + return 1; +} + +static int setChar(lua_State *L) +{ + size_t l; + const int index = luaL_checkint(L, 1); + const int element = getCharBaseValue(L, 2, PetSkillBaseChar, arraysizeof(PetSkillBaseChar)); + char *data = luaL_checklstring(L, 3, &l); + + if(PETSKILL_setChar(index, element, data) == -1){ + return 0; + }else{ + return 1; + } +} + +static int check(lua_State *L) +{ + const int index = luaL_checkint(L, 1); + + lua_pushinteger(L, PETSKILL_CHECKINDEX(index)); + return 1; +} + +static int getPetskillArray(lua_State *L) +{ + const int index = luaL_checkint(L, 1); + + lua_pushinteger(L, PETSKILL_getPetskillArray(index)); + return 1; +} + +static const luaL_Reg petskilllib[] = { + {"getInt", getInt}, + {"setInt", setInt}, + {"getChar", getChar}, + {"setChar", setChar}, + {"check", check}, + {"getPetskillArray", getPetskillArray}, + {NULL, NULL} +}; + +LUALIB_API int luaopen_PetSkill (lua_State *L) { + luaL_register(L, "petskill", petskilllib); + return 1; +} + +#endif + diff --git a/mylua/saacproto.c b/mylua/saacproto.c new file mode 100644 index 0000000..986ff95 --- /dev/null +++ b/mylua/saacproto.c @@ -0,0 +1,51 @@ +#include +#include "char.h" +#include "char_base.h" +#include "mylua/base.h" +#include "lua.h" +#include "lauxlib.h" +#include "lualib.h" +#include "saacproto_cli.h" + +#ifdef _ALLBLUES_LUA +static int ACFixFMPoint(lua_State *L) +{ + size_t l; + char *winfmname=luaL_checklstring(L, 1, &l); + const int winfmindex = luaL_checkint(L, 2); + const int winindex = luaL_checkint(L, 3); + char *losefmname=luaL_checklstring(L, 4, &l); + const int losefmindex = luaL_checkint(L, 5); + const int loseindex = luaL_checkint(L, 6); + const int village = luaL_checkint(L, 7); + + saacproto_ACFixFMPoint_send(acfd, winfmname, winfmindex, winindex, losefmname, losefmindex, loseindex, village); + + return 1; +} + +static int ACFMDetail(lua_State *L) +{ + size_t l; + char *fmname=luaL_checklstring(L, 1, &l); + const int fmindex = luaL_checkint(L, 2); + const int tempindex = luaL_checkint(L, 3); + const int fd = luaL_checkint(L, 4); + saacproto_ACFMDetail_send( acfd, fmname, fmindex, tempindex, CONNECT_getFdid(fd)); + return 1; +} + +static const luaL_Reg Saacprotolib[] = { + {"ACFixFMPoint", ACFixFMPoint}, + {"ACFMDetail", ACFMDetail}, + + {NULL, NULL} +}; + +LUALIB_API int luaopen_Saacproto (lua_State *L) { + luaL_register(L, "saacproto", Saacprotolib); + return 1; +} + +#endif + diff --git a/mylua/sasqlbase.c b/mylua/sasqlbase.c new file mode 100644 index 0000000..48c2c1c --- /dev/null +++ b/mylua/sasqlbase.c @@ -0,0 +1,167 @@ +#include +#include "lua.h" +#include "version.h" +#include "lauxlib.h" +#include "lualib.h" +#include "net.h" +#include "log.h" +#include "sasql.h" + +#ifdef _ALLBLUES_LUA +#ifdef _ALLBLUES_LUA_1_4 +#ifdef _SASQL +#include +extern MYSQL mysql; +MYSQL_RES *mysql_result; +MYSQL_ROW mysql_row; +MYSQL_FIELD *fields; +int numrow = 0; +int numfields = 0; +static int setVipPoint(lua_State *L) +{ + const int charaindex = luaL_checkint(L, 1); + const int point = luaL_checkint(L, 2); + + sasql_setVipPoint(charaindex, point); + return 1; +} + +static int setJfPoint(lua_State *L) +{ + const int charaindex = luaL_checkint(L, 1); + const int point = luaL_checkint(L, 2); + + sasql_setJfPoint(charaindex, point); + return 1; +} + +static int setxjPoint(lua_State *L) +{ + const int charaindex = luaL_checkint(L, 1); + const int point = luaL_checkint(L, 2); + + sasql_setxjPoint(charaindex, point); + return 1; +} + +static int getVipPoint(lua_State *L) +{ + const int charaindex = luaL_checkint(L, 1); + + lua_pushinteger(L, sasql_getVipPoint(charaindex)); + return 1; +} + +static int getJfPoint(lua_State *L) +{ +// printf("һη\n"); + const int charaindex = luaL_checkint(L, 1); + + lua_pushinteger(L, sasql_jifenPoint(charaindex)); + return 1; +} + +static int getxjPoint(lua_State *L) +{ +// printf("һη\n"); + const int charaindex = luaL_checkint(L, 1); + + lua_pushinteger(L, sasql_xjPoint(charaindex)); + return 1; +} + +static int setVipPointForCdkey(lua_State *L) +{ + size_t l; + char *id=luaL_checklstring(L, 1, &l); + const int point = luaL_checkint(L, 2); + + sasql_setVipPointForCdkey(id, point); + return 1; +} + +static int getVipPointForCdkey(lua_State *L) +{ + size_t l; + char *id=luaL_checklstring(L, 1, &l); + lua_pushinteger(L, sasql_getVipPointForCdkey(id)); + return 1; +} + +static int query(lua_State *L) +{ + size_t l; + char *data=luaL_checklstring(L, 1, &l); + + if(!sasql_mysql_query(data)){ + lua_pushinteger(L, 1); + }else{ + lua_pushinteger(L, 0); + } + return 1; +} + +static int free_result(lua_State *L) +{ + mysql_free_result(mysql_result); + return 1; +} + +static int store_result(lua_State *L) +{ + mysql_result=mysql_store_result(&mysql); + return 1; +} + +static int num_rows(lua_State *L) +{ + numrow=mysql_num_rows(mysql_result); + lua_pushinteger(L, numrow); + return 1; +} + +static int num_fields(lua_State *L) +{ + lua_pushinteger(L, numfields); + return 1; +} + +static int fetch_row(lua_State *L) +{ + mysql_row = mysql_fetch_row(mysql_result); + return 1; +} + +static int data(lua_State *L) +{ + int id = luaL_checkint(L, 1) - 1; + lua_pushstring(L, mysql_row[id]); + return 1; +} + +static const luaL_Reg sasqllib[] = { + {"setVipPoint", setVipPoint}, + {"getVipPoint", getVipPoint}, + {"setJfPoint", setJfPoint}, + {"getJfPoint", getJfPoint}, + {"setxjPoint", setxjPoint}, + {"getxjPoint", getxjPoint}, + {"query", query}, + {"free_result", free_result}, + {"store_result", store_result}, + {"num_rows", num_rows}, + {"fetch_row", fetch_row}, + {"num_fields", num_fields}, + {"data", data}, + {"setVipPointForCdkey", setVipPointForCdkey}, + {"getVipPointForCdkey", getVipPointForCdkey}, + {NULL, NULL} +}; + +LUALIB_API int luaopen_Sasql (lua_State *L) { + luaL_register(L, "sasql", sasqllib); + return 1; +} +#endif +#endif +#endif diff --git a/net.c b/net.c new file mode 100644 index 0000000..665f23b --- /dev/null +++ b/net.c @@ -0,0 +1,4532 @@ +#define __NET_C__ +#include "version.h" +//#define __FD_SETSIZE 2048 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +//ttom+1 + +#include +#define _SOCKET_NONBLOCK +#ifdef _SOCKET_NONBLOCK +#include +#endif +#include "net.h" +#include "buf.h" +#include "link.h" +#include "common.h" +#include "msignal.h" +#include "configfile.h" +#include "util.h" +#include "saacproto_cli.h" +#include "lssproto_serv.h" +#include "char.h" +#include "handletime.h" +#include "log.h" +#include "object.h" +#include "title.h" +#include "item_event.h" +#include "enemy.h" +// Arminius 7.31 cursed stone +#include "battle.h" +#include "version.h" +#include "pet_event.h" +#include "char_talk.h" +#include "petmail.h" +#ifdef _ALLBLUES_LUA +#include "mylua/function.h" +#endif +#ifdef _AUTO_PK +#include "npc_autopk.h" +#endif +#include "attestation.h" + + +#define MIN(x,y) ( ( (x) < (y) ) ? (x) : (y) ) + +#ifdef _NEW_SERVER_ +BOOL bNewServer = TRUE; +#else +BOOL bNewServer = FALSE; +#endif + +// Nuke +1 0901: For state monitor +int StateTable[ WHILESAVEWAIT + 1 ]; + +int ITEM_getRatio(); +int CHAR_players(); +#define CONO_CHECK_LOGIN 0x001 +#define CONO_CHECK_ITEM 0x010 +#define CONO_CHECK_PET 0x100 +int cono_check = 0x111; +extern int questionstarttime; +extern int questionman; +extern char answer[64]; +int AC_WBSIZE = ( 1024*64*16 ); +//ttom+1 for the performatce +static unsigned int MAX_item_use = 0; +int i_shutdown_time = 0; //ttom +BOOL b_first_shutdown = FALSE; //ttom + +int mfdfulll = 0; +int yzcnt = 0; +unsigned int atttime=0; +#ifdef _NO_ATTACK +static unsigned long useripnum = 100000; +static unsigned long* userip = 0; +static unsigned long* userip_count_data = 0; +static unsigned long useripcount = 0; +static unsigned long* useriptime = 0; +#endif +#ifdef _PK_LUCK_MAN +int pkluckhour = -1; +int pkluckmin = -1; +int pklucknum = 0; +#endif +extern int autopkstart; +static int autopkend=0; +static int autopkone = 0; +extern char *DebugMainFunction; +/*------------------------------------------------------------ +* ӡP +------------------------------------------------------------*/ +typedef struct tag_serverState +{ + BOOL acceptmore; /* 1գaccept ؤ + нƥclose */ + unsigned int fdid; /* fd ɧԻ */ + unsigned int closeallsocketnum; /* closeallsocket Ի + */ + int shutdown; /* ӡëshutdownƹ + * 0:ɧ ľ½:ƹ + * ƹئ޻ Ȼ£ + */ + int dsptime; /* shutdown ƹ񼰷 */ + int limittime; /* ľ */ +}ServerState; + +#ifdef _CAX_LNS_NLSUOXU +typedef struct tagFuncKk +{ + char *FileName; /*ű·*/ + char *FuncName; /*ִк*/ + unsigned int EspTime; + unsigned int MespTime; + int ID; + unsigned int GetTime; +}FuncKk; + +FuncKk TimerLua[50]; +void SetTimerLua(void)//ʼLUAʱ +{ + int i; + for( i = 0 ; i < arraysizeof( TimerLua ) ; i ++ ){ + TimerLua[i].FileName = NULL; + TimerLua[i].FuncName = NULL; + TimerLua[i].EspTime = -1; + TimerLua[i].MespTime=-1; + TimerLua[i].ID = -1; + TimerLua[i].GetTime = -1; + } +} + +int SetTimer_net(char *FileName,char *FuncName,unsigned int EspTime) +{ + int i; + for( i = 0 ; i < arraysizeof( TimerLua ) ; i ++ ){ + if (TimerLua[i].ID == -1) break; + } + TimerLua[i].FileName = FileName; + TimerLua[i].FuncName = FuncName; + TimerLua[i].EspTime = NowTime.tv_sec; + TimerLua[i].MespTime= NowTime.tv_usec; + TimerLua[i].ID = i+1; + TimerLua[i].GetTime = EspTime*1024; + return i+1; +} +#endif + +typedef struct tagCONNECT +{ + BOOL use; + + char *rb; + int rbuse; + char *wb; + int wbuse; + int check_rb_oneline_b; + int check_rb_time; + pthread_mutex_t mutex; + + struct sockaddr_in sin; /* Ƽʧ */ + ConnectType ctype; /* ˒ */ + + char cdkey[ CDKEYLEN ]; /* CDKEY */ + char passwd[ PASSWDLEN ]; /* ɵ */ + LoginType state; /* ػ̼ */ + int nstatecount; + char charname[ CHARNAMELEN ]; /* ̼wƽҷ’o */ + int charaindex; /* char?d߼̼͵z + * ̼ԉɬýľ©z-1ɻ + * ?dئݩz + */ + char CAbuf[ 2048 ]; /* CA() ë¿м */ + int CAbufsiz; /* CAbuf */ + + struct timeval lastCAsendtime; /*ԉCAë˪ */ + + char CDbuf[ 2048 ]; /* CD() ë¿м */ + int CDbufsiz; /* CDbuf */ + + struct timeval lastCDsendtime; /*ԉCDë˪ */ + + struct timeval lastCharSaveTime; /* ԉƽҷ·ëƤ */ + + struct timeval lastprocesstime; /* ԉëʆA*/ + + struct timeval lastreadtime; /* ԉreadީz練л*/ + + // Nuke start 08/27 : For acceleration avoidance + // WALK_TOLERANCE: Permit n W messages in a second (3: is the most restricted) +#define WALK_TOLERANCE 4 +#define WALK_SPOOL 5 +#define WALK_RESTORE 100 + unsigned int Walktime; + unsigned int lastWalktime; + unsigned int Walkcount; + int Walkspool; // For walk burst after release key F10 + int Walkrestore; + // B3_TOLERANCE: Time distance between recently 3 B message (8: is the latgest) + // BEO_TOLERANCE: Time distance between the lastmost B and EO (5: is the largest) +#define B3_TOLERANCE 5 +#define BEO_TOLERANCE 3 +#define BEO_SPOOL 10 +#define BEO_RESTORE 100 + unsigned int Btime; + unsigned int lastBtime; + unsigned int lastlastBtime; + unsigned int EOtime; + +#ifdef _BATTLE_TIMESPEED + // unsigned int DefBtime; + int BDTime; + int CBTime; +#endif + +#ifdef _TYPE_TOXICATION + int toxication; +#endif + +#ifdef _ITEM_ADDEXP //vincent N + int EDTime; +#endif + // unsigned int BEO; + int BEOspool; + int BEOrestore; + // Nuke 0219: Avoid cheating + int die; + // Nuke end + // Nuke 0310 + int credit; + int fcold; + // Nuke 0406: New Flow Control + int nu; + int nu_decrease; + int ke; + // Nuke 1213: Flow Control 2 + int packetin; + + // Nuke 0624: Avoid Null Connection + unsigned int cotime; + // Nuke 0626: For no enemy + int noenemy; + // Arminius 7.2: Ra's amulet + int eqnoenemy; +#ifdef _Item_MoonAct + int eqrandenemy; +#endif + +#ifdef _CHIKULA_STONE + int chistone; +#endif + // Arminius 7.31: cursed stone + int stayencount; + + int battlecharaindex[ CONNECT_WINDOWBUFSIZE ]; + int duelcharaindex[ CONNECT_WINDOWBUFSIZE ]; + int tradecardcharaindex[ CONNECT_WINDOWBUFSIZE ]; + int joinpartycharaindex[ CONNECT_WINDOWBUFSIZE ]; + + // CoolFish: Trade 2001/4/18 + int tradecharaindex[ CONNECT_WINDOWBUFSIZE ]; + int errornum; + int rightnum; + int fdid; + + int close_request; //the second have this + + int appendwb_overflow_flag; /* 1ƥappendWb?1 */ + //ttom+1 avoidance the watch the battle be kept out + BOOL in_watch_mode; + BOOL b_shut_up; //for avoid the user wash the screen + BOOL b_pass; //for avoid the unlimited area + + struct timeval Wtime; + + struct timeval WLtime; + BOOL b_first_warp; + int state_trans; + + // CoolFish: Trade 2001/4/18 + char TradeTmp[ 256 ]; + +#ifdef _ITEM_PILEFORTRADE + int tradelist; +#endif + // Shan Recvdata Time + + struct timeval lastrecvtime; // 'FM' Stream Control time + + struct timeval lastrecvtime_d; // DENGON Talk Control time + + // Arminius: 6.22 encounter + int CEP; // Current Encounter Probability + // Arminius 7.12 login announce + int announced; + + // shan battle delay time 2001/12/26 + + struct timeval battle_recvtime; +#ifdef _NO_WARP + // shan hjj add Begin + int seqno; + int selectbutton; + // shan End +#endif + unsigned int starttime; + unsigned int connecttime; + char pcid[64]; + char oldpcid[64]; + char defaultkey[32]; + BOOL confirm_key; // shan trade(DoubleCheck) +#ifdef _CAX_NEWMAC_LOGIN + char mac[13]; +#endif +} +CONNECT; + +CONNECT *Connect; /*ͥݤ*/ + + +/* ؿƬˤĤƤ狼褦ˤΥޥ */ +#define SINGLETHREAD +#define MUTLITHREAD +#define ANYTHREAD + +ServerState servstate; + +pthread_mutex_t MTIO_servstate_m; +#define SERVSTATE_LOCK() pthread_mutex_lock( &MTIO_servstate_m ); +#define SERVSTATE_UNLOCK() pthread_mutex_unlock( &MTIO_servstate_m ); +#define CONNECT_LOCK_ARG2(i,j) pthread_mutex_lock( &Connect[i].mutex ); +#define CONNECT_UNLOCK_ARG2(i,j) pthread_mutex_unlock( &Connect[i].mutex ); +#define CONNECT_LOCK(i) pthread_mutex_lock( &Connect[i].mutex ); +#define CONNECT_UNLOCK(i) pthread_mutex_unlock( &Connect[i].mutex ); +/* +#define SERVSTATE_LOCK() +#define SERVSTATE_UNLOCK() +#define CONNECT_LOCK_ARG2(i,j) +#define CONNECT_UNLOCK_ARG2(i,j) +#define CONNECT_LOCK(i) +#define CONNECT_UNLOCK(i) +*/ +char* encrypt_key(char* ip)//ܺ +{ + int b[]={3,7,8,2,9,5,4}; + int i=0; + while(*ip!=NULL) + { + *ip+=b[i%7]; + if(*ip> 122) + *ip=*ip%122+32; + i++,ip++; + } + return ip; +} + +char* decrypt_key(char* id)//ܺ +{ + int b[]={3,7,8,2,9,5,4}; + int i=0; + while(*id!=NULL) + { + *id-=b[i%7]; + if(*id <32) + *id=*id-32+122; + i++,id++; + } + return id; +} +/*------------------------------------------------------------ +* servstateë©z +* ¦ѩy߯Ի +* ئ +------------------------------------------------------------*/ +ANYTHREAD static void SERVSTATE_initserverState( void ) +{ + SERVSTATE_LOCK(); + servstate.acceptmore = TRUE; + servstate.fdid = 0; + servstate.closeallsocketnum = -1; + servstate.shutdown = 0; + servstate.limittime = 0; + servstate.dsptime = 0; + SERVSTATE_UNLOCK(); +} + +ANYTHREAD int SERVSTATE_SetAcceptMore( int nvalue ) +{ + BOOL buf; + SERVSTATE_LOCK(); + buf = servstate.acceptmore; + servstate.acceptmore = nvalue; + SERVSTATE_UNLOCK(); + return buf; +} +ANYTHREAD static int SERVSTATE_incrementFdid( void ) +{ + int ret; + SERVSTATE_LOCK(); + ret = servstate.fdid++; + SERVSTATE_UNLOCK(); + return ret; +} +ANYTHREAD static void SERVSTATE_setCloseallsocketnum( int a ) +{ + SERVSTATE_LOCK(); + servstate.closeallsocketnum = a; + SERVSTATE_UNLOCK(); +} +ANYTHREAD static void SERVSTATE_incrementCloseallsocketnum(void) +{ + SERVSTATE_LOCK(); + servstate.closeallsocketnum ++; + SERVSTATE_UNLOCK(); +} +ANYTHREAD void SERVSTATE_decrementCloseallsocketnum(void) +{ + SERVSTATE_LOCK(); + servstate.closeallsocketnum --; + SERVSTATE_UNLOCK(); +} +ANYTHREAD int SERVSTATE_getCloseallsocketnum( void ) +{ + int a; + SERVSTATE_LOCK(); + a = servstate.closeallsocketnum; + SERVSTATE_UNLOCK(); + return a; +} + +ANYTHREAD static int SERVSTATE_getAcceptmore(void) +{ + int a; + SERVSTATE_LOCK(); + a = servstate.acceptmore; + SERVSTATE_UNLOCK(); + return a; +} +ANYTHREAD int SERVSTATE_getShutdown(void) +{ + int a; + SERVSTATE_LOCK(); + a = servstate.shutdown; + SERVSTATE_UNLOCK(); + return a; +} +ANYTHREAD void SERVSTATE_setShutdown(int a) +{ + SERVSTATE_LOCK(); + servstate.shutdown = a; + SERVSTATE_UNLOCK(); +} +ANYTHREAD int SERVSTATE_getLimittime(void) +{ + int a; + SERVSTATE_LOCK(); + a = servstate.limittime; + SERVSTATE_UNLOCK(); + return a; +} +ANYTHREAD void SERVSTATE_setLimittime(int a) +{ + SERVSTATE_LOCK(); + servstate.limittime = a; + SERVSTATE_UNLOCK(); +} +ANYTHREAD int SERVSTATE_getDsptime(void) +{ + int a; + SERVSTATE_LOCK(); + a = servstate.dsptime; + SERVSTATE_UNLOCK(); + return a; +} +ANYTHREAD void SERVSTATE_setDsptime(int a) +{ + SERVSTATE_LOCK(); + servstate.dsptime = a; + SERVSTATE_UNLOCK(); +} + +static int appendWB( int fd, char *buf, int size ) +{ + if ( fd != acfd ) { + if ( Connect[ fd ].wbuse + size >= WBSIZE ) { + //print( "appendWB:err buffer over[%d]:%s \n", + //Connect[ fd ].wbuse + size, Connect[ fd ].cdkey ); + return -1; + } + }else { + if ( Connect[ fd ].wbuse + size > AC_WBSIZE ) { + FILE * fp = NULL; + //print( "appendWB:err buffer over[%d+%d]:(SAAC) \n", Connect[ fd ].wbuse, size ); + + if ( ( fp = fopen( "appendWBerr.log", "a+" ) ) == NULL ) return -1; + + fprintf( fp, "(SAAC) appendWB:err buffer over[%d+%d/%d]:\n", Connect[ fd ].wbuse, size, AC_WBSIZE ); + + fclose( fp ); + + return -1; + } + } + + + + memcpy( Connect[ fd ].wb + Connect[ fd ].wbuse , + buf, size ); + Connect[ fd ].wbuse += size; + return size; +} +static int appendRB( int fd, char *buf, int size ) +{ + if ( fd != acfd ) { + if ( Connect[ fd ].rbuse + size > RBSIZE ) { + //print( "appendRB:OTHER(%d) err buffer over \n", fd ); + + return -1; + } + }else { + if ( strlen( buf ) > size ) { + //print( "appendRB AC buffer len err : %d/%d=\n(%s)!!\n", strlen( buf ), size, buf ); + } + + if ( Connect[ fd ].rbuse + size > AC_RBSIZE ) { + //print( "appendRB AC err buffer over:\n(%s)\n len:%d - rbuse:%d \n", + //buf, strlen( buf ), Connect[ fd ].rbuse ); + return -1; + } + } + + memcpy( Connect[ fd ].rb + Connect[ fd ].rbuse , buf, size ); + Connect[ fd ].rbuse += size; + return size; +} + +static int shiftWB( int fd, int len ) +{ + if ( Connect[ fd ].wbuse < len ) { + //print( "shiftWB: err\n" ); + return -1; + } + + memmove( Connect[ fd ].wb, Connect[ fd ].wb + len, Connect[ fd ].wbuse - len ); + Connect[ fd ].wbuse -= len; + + if ( Connect[ fd ].wbuse < 0 ) { + //print( "shiftWB:wbuse err\n" ); + Connect[ fd ].wbuse = 0; + } + + return len; +} + +static int shiftRB( int fd, int len ) +{ + if ( Connect[ fd ].rbuse < len ) { + //print( "shiftRB: err\n" ); + return -1; + } + + memmove( Connect[ fd ].rb, Connect[ fd ].rb + len, Connect[ fd ].rbuse - len ); + Connect[ fd ].rbuse -= len; + + if ( Connect[ fd ].rbuse < 0 ) { + //print( "shiftRB:rbuse err\n" ); + Connect[ fd ].rbuse = 0; + } + + return len; +} + +SINGLETHREAD int lsrpcClientWriteFunc( int fd , char* buf , int size ) +{ + int r; + + if ( Connect[ fd ].use == FALSE ) { + return FALSE; + } + + if ( Connect[ fd ].appendwb_overflow_flag ) { + //print( "lsrpcClientWriteFunc: buffer overflow fd:%d\n" , fd ); + return -1; + } + + r = appendWB( fd, buf , size ); + + // Nuke *1 0907: Ignore acfd from WB error + + if ( ( r < 0 ) && ( fd != acfd ) ) { + Connect[ fd ].appendwb_overflow_flag = 1; + //print("11111"); + CONNECT_endOne_debug( fd ); + // Nuke + 1 0901: Why close + // print("closed in lsrpcClientWriteFunc"); + } + + return r; +} + +static int logRBuseErr = 0; +SINGLETHREAD BOOL GetOneLine_fix( int fd, char *buf, int max ) +{ + int i; + + if ( Connect[ fd ].rbuse == 0 ) return FALSE; + + if ( Connect[ fd ].check_rb_oneline_b == 0 && + Connect[ fd ].check_rb_oneline_b == Connect[ fd ].rbuse ) { + return FALSE; + } + + + for ( i = 0; i < Connect[ fd ].rbuse && i < ( max - 1 ); i ++ ) { + if ( Connect[ fd ].rb[ i ] == '\n' ) { + memcpy( buf, Connect[ fd ].rb, i + 1 ); + buf[ i + 1 ] = '\0'; + shiftRB( fd, i + 1 ); + + //-------- + /* + //andy_log + if( strstr( Connect[fd].rb , "ACCharLoad") != NULL && + Connect[fd].check_rb_oneline_b != 0 )//Connect[fd].rb + LogAcMess( fd, "GetOne", Connect[fd].rb ); + */ + //-------- + logRBuseErr = 0; + Connect[ fd ].check_rb_oneline_b = 0; + Connect[ fd ].check_rb_time = 0; + return TRUE; + } + } + + //print("rbuse lens: %d!!\n", Connect[fd].rbuse); + logRBuseErr++; + + //-------- + //andy_log + if ( fd == acfd && strstr( Connect[ fd ].rb , "ACCharLoad" ) != NULL && + logRBuseErr >= 50 ) { //Connect[fd].rb + char buf[ AC_RBSIZE ]; + memcpy( buf, Connect[ fd ].rb, Connect[ fd ].rbuse + 1 ); + buf[ Connect[ fd ].rbuse + 1 ] = 0; + LogAcMess( fd, "RBUFFER", buf ); + logRBuseErr = 0; + } + + //-------- + Connect[ fd ].check_rb_oneline_b = Connect[ fd ].rbuse; + + return FALSE; +} + + +char *getRandStr(int num){ + char str[num+1]; + int i; + struct timeval tv; + struct timezone tz; + gettimeofday (&tv , &tz); + srand(tv.tv_usec); + for(i = 0; i < num; i++) + { + int a = 0; + a = ( rand() %2) ? ( rand() %26 + 65) : ( rand()% 10 + 48); + str[i] = a; + } + str[num] = '\0'; + return str; +} + +ANYTHREAD BOOL initConnectOne( int sockfd, struct sockaddr_in* sin ,int len ) +{ + CONNECT_LOCK( sockfd ); + + Connect[ sockfd ].use = TRUE; + Connect[ sockfd ].ctype = NOTDETECTED; + Connect[ sockfd ].wbuse = Connect[ sockfd ].rbuse = 0; + Connect[ sockfd ].check_rb_oneline_b = 0; + Connect[ sockfd ].check_rb_time = 0; + + memset( Connect[ sockfd ].cdkey , 0 , sizeof( Connect[ sockfd ].cdkey ) ); + memset( Connect[ sockfd ].passwd, 0 , sizeof( Connect[ sockfd ].passwd ) ); + + Connect[ sockfd ].state = NOTLOGIN; + Connect[ sockfd ].nstatecount = 0; + memset( Connect[ sockfd ].charname, 0, sizeof( Connect[ sockfd ].charname ) ); + Connect[ sockfd ].charaindex = -1; + + Connect[ sockfd ].CAbufsiz = 0; + Connect[ sockfd ].CDbufsiz = 0; + Connect[ sockfd ].rbuse = 0; + Connect[ sockfd ].wbuse = 0; + Connect[ sockfd ].check_rb_oneline_b = 0; + Connect[ sockfd ].check_rb_time = 0; + + Connect[ sockfd ].close_request = 0; /* Ӭۢư׷º */ + // Nuke 08/27 For acceleration avoidance + Connect[ sockfd ].Walktime = 0; + Connect[ sockfd ].lastWalktime = 0; + Connect[ sockfd ].Walkcount = 0; + Connect[ sockfd ].Walkspool = WALK_SPOOL; + Connect[ sockfd ].Walkrestore = WALK_RESTORE; + Connect[ sockfd ].Btime = 0; + Connect[ sockfd ].lastBtime = 0; + Connect[ sockfd ].lastlastBtime = 0; + Connect[ sockfd ].EOtime = 0; + Connect[ sockfd ].nu_decrease = 0; +#ifdef _BATTLE_TIMESPEED + // Connect[sockfd].DefBtime = 0; + Connect[ sockfd ].BDTime = 0; + Connect[ sockfd ].CBTime = 0; +#endif +#ifdef _TYPE_TOXICATION + Connect[ sockfd ].toxication = 0; +#endif +#ifdef _ITEM_ADDEXP //vincent + Connect[ sockfd ].EDTime = 0; +#endif + // Connect[sockfd].BEO = 0; + Connect[ sockfd ].BEOspool = BEO_SPOOL; + Connect[ sockfd ].BEOrestore = BEO_RESTORE; + //ttom + Connect[ sockfd ].b_shut_up = FALSE; + Connect[ sockfd ].Wtime.tv_sec = 0; // + Connect[ sockfd ].Wtime.tv_usec = 0; // + Connect[ sockfd ].WLtime.tv_sec = 0; // + Connect[ sockfd ].WLtime.tv_usec = 0; // + Connect[ sockfd ].b_first_warp = FALSE; + Connect[ sockfd ].state_trans = 0; //avoid the trans + // Nuke + Connect[ sockfd ].die = 0; + Connect[ sockfd ].credit = 3; + Connect[ sockfd ].fcold = 0; + // Nuke 0406: New Flow Control + Connect[ sockfd ].nu = 30; + Connect[ sockfd ].ke = 10; + // Nuke 1213: Flow Control 2 + Connect[ sockfd ].packetin = 30; // if 10x10 seconds no packet, drop the line + + // Nuke 0624: Avoid Useless Connection + Connect[ sockfd ].cotime = 0; + // Nuke 0626: For no enemy + Connect[ sockfd ].noenemy = 0; + // Arminius 7.2: Ra's amulet + Connect[ sockfd ].eqnoenemy = 0; + +#ifdef _Item_MoonAct + Connect[ sockfd ].eqrandenemy = 0; +#endif +#ifdef _CHIKULA_STONE + Connect[ sockfd ].chistone = 0; +#endif + // Arminius 7.31: cursed stone + Connect[ sockfd ].stayencount = 0; + + // CoolFish: Init Trade 2001/4/18 + memset( &Connect[ sockfd ].TradeTmp, 0, sizeof( Connect[ sockfd ].TradeTmp ) ); +#ifdef _ITEM_PILEFORTRADE + Connect[ sockfd ].tradelist = -1; +#endif + // Arminius 6.22 Encounter + Connect[ sockfd ].CEP = 0; + + // Arminius 7.12 login announce + Connect[ sockfd ].announced = 0; + +#ifdef _NO_WARP + // shan hjj add Begin + Connect[sockfd].seqno=-1; + Connect[sockfd].selectbutton=1; + // shan End +#endif + // ¼ʼʱ + time_t curtime; + struct tm *p; + time(&curtime); + p=localtime(&curtime); + curtime = mktime(p); + Connect[ sockfd ].starttime = curtime; + + memset( Connect[ sockfd ].pcid, 0 , sizeof( Connect[ sockfd ].pcid ) ); + memset( Connect[ sockfd ].oldpcid, 0 , sizeof( Connect[ sockfd ].oldpcid ) ); + Connect[ sockfd ].confirm_key = FALSE; // shan trade(DoubleCheck) + + if ( sin != NULL ) memcpy( &Connect[ sockfd ].sin , sin , len ); + + memset( &Connect[ sockfd ].lastprocesstime, 0 , + sizeof( Connect[ sockfd ].lastprocesstime ) ); + + memcpy( &Connect[ sockfd ].lastCAsendtime, &NowTime , + sizeof( Connect[ sockfd ].lastCAsendtime ) ); + + memcpy( &Connect[ sockfd ].lastCDsendtime, &NowTime , + sizeof( Connect[ sockfd ].lastCDsendtime ) ); + + memcpy( &Connect[ sockfd ].lastCharSaveTime, &NowTime , + sizeof( Connect[ sockfd ].lastCharSaveTime ) ); + + // Shan Add + memcpy( &Connect[ sockfd ].lastrecvtime, &NowTime , + sizeof( Connect[ sockfd ].lastrecvtime ) ); + + memcpy( &Connect[ sockfd ].lastrecvtime_d, &NowTime , + sizeof( Connect[ sockfd ].lastrecvtime_d ) ); + + memcpy( &Connect[ sockfd ].battle_recvtime, &NowTime , + sizeof( Connect[ sockfd ].battle_recvtime ) ); + + memcpy( &Connect[ sockfd ].lastreadtime , &NowTime, + + sizeof( struct timeval ) ); + + Connect[ sockfd ].lastreadtime.tv_sec -= DEBUG_ADJUSTTIME; + + Connect[ sockfd ].errornum = 0; + + Connect[ sockfd ].rightnum = 0; + + Connect[ sockfd ].fdid = SERVSTATE_incrementFdid(); + + CONNECT_UNLOCK( sockfd ); + + Connect[ sockfd ].appendwb_overflow_flag = 0; + + Connect[sockfd].connecttime = time(NULL); + + memset( Connect[ sockfd ].defaultkey , 0 , sizeof( Connect[ sockfd ].defaultkey ) ); + strcpy(Connect[ sockfd ].defaultkey,getRandStr(10)); + + return TRUE; +} + +ANYTHREAD BOOL _CONNECT_endOne( char *file, int fromline, int sockfd , int line ) +{ + if(errno==113 || errno==104){ + return; + } + CONNECT_LOCK_ARG2(sockfd,line); + + if( Connect[sockfd].use == FALSE ){ + CONNECT_UNLOCK_ARG2(sockfd,line); + //andy_log + //print("ѹر[%d]!!\n", sockfd ); + return TRUE; + } + Connect[sockfd].use = FALSE; + if( Connect[sockfd].ctype == CLI ){ + CONNECT_UNLOCK_ARG2( sockfd,line ); + if(Connect[sockfd].charaindex >= 0){ +#ifdef _OFFLINE_SYSTEM + if(CHAR_getWorkInt( Connect[sockfd].charaindex, CHAR_WORK_OFFLINE ) != 0){ + CHAR_setWorkInt( Connect[sockfd].charaindex, CHAR_WORKFD, -1); + }else +#endif + { + if( !CHAR_logout( Connect[sockfd].charaindex,TRUE )) { + //print( "err %s:%d from %s:%d \n", __FILE__, __LINE__, file, fromline); + } + //print("\ndrop line from %s:%d,__FD_SETSIZE=%d\n",file,fromline,__FD_SETSIZE); + sasql_online(Connect[sockfd].cdkey,NULL,NULL,NULL,NULL,0); + print( "˳˺=%s \n", Connect[sockfd].cdkey ); + } + Connect[sockfd].charaindex=-1; + }else{ + if(strlen(Connect[sockfd].cdkey)>0) + sasql_online(Connect[sockfd].cdkey,NULL,NULL,NULL,NULL,0); + } + CONNECT_LOCK_ARG2( sockfd ,line); + } +#ifdef _NO_ATTACK + else{ + if(strlen(Connect[sockfd].cdkey)<1){ + // ʱ + time_t curtime; + struct tm *p; + time(&curtime); + p=localtime(&curtime); + curtime = mktime(p); + if( curtime - Connect[sockfd].starttime <= getAttTime() ){ + unsigned long tmpip=CONNECT_get_userip(sockfd); + unsigned long i = 0; + int ipa,ipb,ipc,ipd; + char ip[32]; + ipa=(tmpip % 0x100); tmpip=tmpip / 0x100; + ipb=(tmpip % 0x100); tmpip=tmpip / 0x100; + ipc=(tmpip % 0x100); tmpip=tmpip / 0x100; + ipd=(tmpip % 0x100); + sprintf(ip,"%d.%d.%d.%d",ipa,ipb,ipc,ipd); + for(; i < useripcount; ++i ){ + if( userip[i] == tmpip ){ + if(userip_count_data[i]>=getAttCnt()){ + Connect[sockfd].wbuse = 0; + Connect[sockfd].rbuse = 0; + Connect[sockfd].CAbufsiz = 0; + Connect[sockfd].CDbufsiz = 0; + CONNECT_UNLOCK_ARG2(sockfd,line); + + print( "Ƿ=%d ǷIP=%s \n", sockfd, ip ); + close(sockfd); +#ifdef _CAX_OFF_IPTABLES + if(strcmp(ip,"0.0.0.0")!=0){ + char systemstr[256]; + sprintf(systemstr,"iptables -I INPUT -s %s -j DROP",ip); + system(systemstr); + } +#endif + userip_count_data[i] = 1; + useriptime[i] = curtime; + return TRUE; + } + if(curtime-useriptime[i]<=getAttSafeTime()){ + ++userip_count_data[i]; + break; + }else{ + useriptime[i]=curtime; + break; + } + } + } + if(strcmp(ip,getNoAttIp(0))!=0 && strcmp(ip,getNoAttIp(1))!=0 && strcmp(ip,getNoAttIp(2))!=0 && strcmp(ip,getNoAttIp(3))!=0 && strcmp(ip,getNoAttIp(4))!=0){ + if(i>= useripcount && useripcount= sizeof( Connect[ fd ].CAbuf ) ) { + CONNECT_UNLOCK( fd ); + return FALSE; + } + + memcpy( Connect[ fd ].CAbuf + Connect[ fd ].CAbufsiz , data , size ); + Connect[ fd ].CAbuf[ Connect[ fd ].CAbufsiz + size ] = ','; + Connect[ fd ].CAbufsiz += ( size + 1 ); + CONNECT_UNLOCK( fd ); + return TRUE; +} + +ANYTHREAD static int CONNECT_getCAbuf( int fd, char *out, int outmax, + int *outlen ) +{ + CONNECT_LOCK( fd ); + + if ( Connect[ fd ].use == TRUE ) { + int cplen = MIN( outmax, Connect[ fd ].CAbufsiz ); + memcpy( out, Connect[ fd ].CAbuf , cplen ); + *outlen = cplen; + CONNECT_UNLOCK( fd ); + return 0; + } else { + CONNECT_UNLOCK( fd ); + return -1; + } +} +ANYTHREAD static int CONNECT_getCDbuf( int fd, char *out, int outmax, + int *outlen ) +{ + if(fd<0) return 0; + CONNECT_LOCK( fd ); + + if ( Connect[ fd ].use == TRUE ) { + int cplen = MIN( outmax, Connect[ fd ].CDbufsiz ); + memcpy( out, Connect[ fd ].CDbuf, cplen ); + *outlen = cplen; + CONNECT_UNLOCK( fd ); + return 0; + } else { + CONNECT_UNLOCK( fd ); + return 0; + } +} + +ANYTHREAD static int CONNECT_setCAbufsiz( int fd, int len ) +{ + CONNECT_LOCK( fd ); + + if ( Connect[ fd ].use == TRUE ) { + Connect[ fd ].CAbufsiz = len; + CONNECT_UNLOCK( fd ); + return 0; + } else { + CONNECT_UNLOCK( fd ); + return -1; + } +} +ANYTHREAD static int CONNECT_setCDbufsiz( int fd, int len ) +{ + CONNECT_LOCK( fd ); + + if ( Connect[ fd ].use == TRUE ) { + Connect[ fd ].CDbufsiz = len; + CONNECT_UNLOCK( fd ); + return 0; + } else { + CONNECT_UNLOCK( fd ); + return -1; + } +} + +ANYTHREAD static void CONNECT_setLastCAsendtime( int fd, struct timeval *t) +{ + CONNECT_LOCK( fd ); + Connect[ fd ].lastCAsendtime = *t; + CONNECT_UNLOCK( fd ); +} +ANYTHREAD static void CONNECT_getLastCAsendtime( int fd, struct timeval *t ) +{ + CONNECT_LOCK( fd ); + *t = Connect[ fd ].lastCAsendtime; + CONNECT_UNLOCK( fd ); +} +ANYTHREAD static void CONNECT_setLastCDsendtime( int fd, struct timeval *t ) +{ + CONNECT_LOCK( fd ); + Connect[ fd ].lastCDsendtime = *t; + CONNECT_UNLOCK( fd ); +} +ANYTHREAD static void CONNECT_getLastCDsendtime( int fd, struct timeval *t ) +{ + CONNECT_LOCK( fd ); + *t = Connect[ fd ].lastCDsendtime; + CONNECT_UNLOCK( fd ); +} +ANYTHREAD int CONNECT_getUse_debug( int fd, int i ) +{ + int a; + CONNECT_LOCK_ARG2( fd, i ); + a = Connect[ fd ].use; + CONNECT_UNLOCK_ARG2( fd, i ); + return a; + +} + +ANYTHREAD int CONNECT_getUse( int fd ) +{ + int a; + CONNECT_LOCK( fd ); + a = Connect[ fd ].use; + CONNECT_UNLOCK( fd ); + return a; +} +void CONNECT_setUse( int fd , int a) +//ANYTHREAD static void CONNECT_setUse( int fd , int a) +{ + CONNECT_LOCK( fd ); + Connect[ fd ].use = a; + CONNECT_UNLOCK( fd ); +} + +void CONNECT_setStarttime( int fd , int a) +//ANYTHREAD static void CONNECT_setUse( int fd , int a) +{ + CONNECT_LOCK( fd ); + Connect[ fd ].starttime = a; + CONNECT_UNLOCK( fd ); +} + +ANYTHREAD void CONNECT_checkStatecount( int a ) +{ + int i; + int count = 0; + + for ( i = 0; i < ConnectLen; i++ ) { + if ( Connect[ i ].use == FALSE || Connect[ i ].state != a ) continue; + + if ( Connect[ i ].nstatecount <= 0 ) { + Connect[ i ].nstatecount = ( int ) time( NULL ) + 60; + }else{ + if ( Connect[ i ].nstatecount < ( int ) time( NULL ) ) { + //print("33333"); + CONNECT_endOne_debug( i ); + count++; + } + } + } + + { + memset( StateTable, 0, sizeof( StateTable ) ); + + for ( i = 0; i < ConnectLen; i++ ) + if ( Connect[ i ].use == TRUE ) + StateTable[ Connect[ i ].state ] ++; + } +} + +ANYTHREAD int CONNECT_checkStateSomeOne( int a, int maxcount) +{ + char temp[ 80 ], buffer[ 1024 ]; + int i, ret = 1; + + if ( StateTable[ a ] >= maxcount ) ret = -1; + + buffer[ 0 ] = 0; + + for ( i = 0; i <= WHILESAVEWAIT; i++ ) { + sprintf( temp, "%4d", StateTable[ i ] ); + strcat( buffer, temp ); + } + + //print( "\nNOW{{%s}}", buffer ); + return ret; +} + +ANYTHREAD void CONNECT_setState( int fd , int a) +{ + CONNECT_LOCK( fd ); + Connect[ fd ].state = a; + Connect[ fd ].nstatecount = 0; + + // Nuke start 0829: For debugging + { + char temp[80],buffer[128]; + int i; + memset( StateTable, 0, sizeof( StateTable ) ); + + for ( i = 0; i < ConnectLen; i++ ) + if ( Connect[ i ].use == TRUE ) + StateTable[ Connect[ i ].state ] ++; + + buffer[ 0 ] = 0; + + for ( i = 0; i <= WHILESAVEWAIT; i++ ) { + sprintf( temp, "%4d", StateTable[ i ] ); + strcat( buffer, temp ); + } + // print( "\nFILE:%s,LINE:%d", file,fromline ); + //print( "\n{{%s}}", buffer ); + } + // Nuke end + + CONNECT_UNLOCK( fd ); +} + +ANYTHREAD int CONNECT_getState( int fd ) +{ + int a; + CONNECT_LOCK( fd ); + a = Connect[ fd ].state; + CONNECT_UNLOCK( fd ); + return a; +} +ANYTHREAD void CONNECT_incrementErrornum(int fd ) +{ + CONNECT_LOCK( fd ); + Connect[ fd ].errornum ++; + CONNECT_UNLOCK( fd ); +} +ANYTHREAD void CONNECT_setCharaindex( int fd, int a ) +{ + CONNECT_LOCK( fd ); + Connect[ fd ].charaindex = a; + CONNECT_UNLOCK( fd ); +} +ANYTHREAD int CONNECT_getCharaindex( int fd ) +{ + int a; + CONNECT_LOCK( fd ); + a = Connect[ fd ].charaindex; + CONNECT_UNLOCK( fd ); + return a; +} +ANYTHREAD void CONNECT_getCdkey( int fd , char *out, int outlen ) +{ + CONNECT_LOCK( fd ); + strcpysafe( out, outlen, Connect[ fd ].cdkey ); + CONNECT_UNLOCK( fd ); +} + +ANYTHREAD void CONNECT_setCdkey( int sockfd, char *cd ) +{ + CONNECT_LOCK( sockfd ); + snprintf( Connect[ sockfd ].cdkey, sizeof( Connect[ sockfd ].cdkey ), "%s", + cd ); + CONNECT_UNLOCK( sockfd ); +} + +ANYTHREAD void CONNECT_getPcid( int fd , char *out, int outlen ) +{ + CONNECT_LOCK( fd ); + strcpysafe( out, outlen, Connect[ fd ].pcid ); + CONNECT_UNLOCK( fd ); +} + +ANYTHREAD void CONNECT_setPcid( int sockfd, char *pcid ) +{ + CONNECT_LOCK( sockfd ); + snprintf( Connect[ sockfd ].pcid, sizeof( Connect[ sockfd ].pcid ), "%s", + pcid ); + CONNECT_UNLOCK( sockfd ); +} + +#ifdef _CAX_NEWMAC_LOGIN +ANYTHREAD void CONNECT_getMAC( int fd , char *out, int outlen ) +{ + CONNECT_LOCK( fd ); + strcpysafe( out, outlen, Connect[ fd ].mac ); + CONNECT_UNLOCK( fd ); +} + +ANYTHREAD void CONNECT_setMAC( int sockfd, char *mac ) +{ + CONNECT_LOCK( sockfd ); + snprintf( Connect[ sockfd ].mac, sizeof( Connect[ sockfd ].mac ), "%s", mac ); + CONNECT_UNLOCK( sockfd ); +} +#endif + +ANYTHREAD void CONNECT_getOldPcid( int fd , char *out, int outlen ) +{ + CONNECT_LOCK( fd ); + strcpysafe( out, outlen, Connect[ fd ].oldpcid ); + CONNECT_UNLOCK( fd ); +} + +ANYTHREAD void CONNECT_setOldPcid( int sockfd, char *pcid ) +{ + CONNECT_LOCK( sockfd ); + snprintf( Connect[ sockfd ].oldpcid, sizeof( Connect[ sockfd ].oldpcid ), "%s", + pcid ); + CONNECT_UNLOCK( sockfd ); +} + +ANYTHREAD void CONNECT_getDefaultKey( int fd , char *out, int outlen ) +{ + CONNECT_LOCK( fd ); + strcpysafe( out, outlen, Connect[ fd ].defaultkey ); + CONNECT_UNLOCK( fd ); +} + +ANYTHREAD void CONNECT_setDefaultKey( int sockfd, char *defaultkey ) +{ + CONNECT_LOCK( sockfd ); + snprintf( Connect[ sockfd ].defaultkey, sizeof( Connect[ sockfd ].defaultkey ), "%s", + defaultkey ); + CONNECT_UNLOCK( sockfd ); +} + +ANYTHREAD void CONNECT_getPasswd( int fd , char *out, int outlen ) +{ + CONNECT_LOCK( fd ); + strcpysafe( out, outlen, Connect[ fd ].passwd ); + CONNECT_UNLOCK( fd ); +} +ANYTHREAD void CONNECT_setPasswd( int fd, char *in ) +{ + CONNECT_LOCK( fd ); + strcpysafe( Connect[ fd ].passwd, sizeof( Connect[ fd ].passwd ), in ); + CONNECT_UNLOCK( fd ); +} +ANYTHREAD int CONNECT_getCtype( int fd ) +{ + int a; + CONNECT_LOCK( fd ); + a = Connect[ fd ].ctype; + CONNECT_UNLOCK( fd ); + return a; +} +ANYTHREAD void CONNECT_setCtype( int fd , int a ) +{ + CONNECT_LOCK( fd ); + Connect[ fd ].ctype = a; + CONNECT_UNLOCK( fd ); +} + +ANYTHREAD void CONNECT_getCharname( int fd , char *out, int outlen ) +{ + CONNECT_LOCK( fd ); + strcpysafe( out, outlen, Connect[ fd ].charname ); + CONNECT_UNLOCK( fd ); +} +ANYTHREAD void CONNECT_setCharname( int fd, char *in ) +{ + CONNECT_LOCK( fd ); + strcpysafe( Connect[ fd ].charname, sizeof( Connect[ fd ].charname ), + in ); + CONNECT_UNLOCK( fd ); +} + +ANYTHREAD int CONNECT_getFdid( int fd ) +{ + if( fd < 0 || fd >= ConnectLen ){ + return -1; + } + int a; + CONNECT_LOCK( fd ); + a = Connect[ fd ].fdid; + CONNECT_UNLOCK( fd ); + return a; +} +ANYTHREAD void CONNECT_setDuelcharaindex( int fd, int i , int a ) +{ + CONNECT_LOCK( fd ); + Connect[ fd ].duelcharaindex[ i ] = a; + CONNECT_UNLOCK( fd ); +} +ANYTHREAD int CONNECT_getDuelcharaindex( int fd, int i ) +{ + int a; + CONNECT_LOCK( fd ); + a = Connect[ fd ].duelcharaindex[ i ]; + CONNECT_UNLOCK( fd ); + return a; +} +ANYTHREAD void CONNECT_setBattlecharaindex( int fd, int i , int a ) +{ + CONNECT_LOCK( fd ); + Connect[ fd ].battlecharaindex[ i ] = a; + CONNECT_UNLOCK( fd ); +} +ANYTHREAD int CONNECT_getBattlecharaindex( int fd, int i ) +{ + int a; + CONNECT_LOCK( fd ); + a = Connect[ fd ].battlecharaindex[ i ]; + CONNECT_UNLOCK( fd ); + return a; +} +ANYTHREAD void CONNECT_setJoinpartycharaindex( int fd, int i , int a) +{ + CONNECT_LOCK( fd ); + Connect[ fd ].joinpartycharaindex[ i ] = a; + CONNECT_UNLOCK( fd ); +} +ANYTHREAD int CONNECT_getJoinpartycharaindex( int fd, int i ) +{ + int a; + CONNECT_LOCK( fd ); + a = Connect[ fd ].joinpartycharaindex[ i ]; + CONNECT_UNLOCK( fd ); + return a; +} + +// CoolFish: Trade 2001/4/18 +ANYTHREAD void CONNECT_setTradecharaindex( int fd, int i , int a ) +{ + CONNECT_LOCK( fd ); + Connect[ fd ].tradecharaindex[ i ] = a; + CONNECT_UNLOCK( fd ); +} + +// Shan Begin +ANYTHREAD void CONNECT_setLastrecvtime( int fd, struct timeval *a ) +{ + CONNECT_LOCK(fd); + Connect[fd].lastrecvtime = *a; + CONNECT_UNLOCK(fd); +} +ANYTHREAD void CONNECT_getLastrecvtime( int fd, struct timeval *a ) +{ + CONNECT_LOCK(fd); + *a = Connect[fd].lastrecvtime; + CONNECT_UNLOCK(fd); +} + +ANYTHREAD void CONNECT_setLastrecvtime_D( int fd, struct timeval *a ) +{ + CONNECT_LOCK(fd); + Connect[fd].lastrecvtime_d = *a; + CONNECT_UNLOCK(fd); +} +ANYTHREAD void CONNECT_getLastrecvtime_D( int fd, struct timeval *a ) +{ + CONNECT_LOCK(fd); + *a = Connect[fd].lastrecvtime_d; + CONNECT_UNLOCK(fd); +} +// 2001/12/26 +ANYTHREAD void CONNECT_SetBattleRecvTime( int fd, struct timeval *a ) +{ + CONNECT_LOCK(fd); + Connect[fd].battle_recvtime = *a; + CONNECT_UNLOCK(fd); +} +ANYTHREAD void CONNECT_GetBattleRecvTime( int fd, struct timeval *a ) +{ + CONNECT_LOCK(fd); + *a = Connect[fd].battle_recvtime; + CONNECT_UNLOCK(fd); +} +// Shan End + + +#ifdef _ITEM_PILEFORTRADE +ANYTHREAD void CONNECT_setTradeList( int fd, int num) +{ + Connect[fd].tradelist = num; +} +ANYTHREAD int CONNECT_getTradeList(int fd) +{ + return Connect[fd].tradelist; +} +#endif + +ANYTHREAD void CONNECT_setTradeTmp(int fd, char* a) +{ + CONNECT_LOCK(fd); + strcpysafe( Connect[fd].TradeTmp, sizeof(Connect[fd].TradeTmp), a); + + CONNECT_UNLOCK(fd); +} +ANYTHREAD void CONNECT_getTradeTmp(int fd, char *trademsg, int trademsglen) +{ + CONNECT_LOCK(fd); + strcpysafe(trademsg, trademsglen, Connect[fd].TradeTmp); + CONNECT_UNLOCK(fd); +} + +ANYTHREAD void CONNECT_setTradecardcharaindex( int fd, int i , int a ) +{ + CONNECT_LOCK(fd); + Connect[fd].joinpartycharaindex[i] = a; + CONNECT_UNLOCK(fd); +} +ANYTHREAD int CONNECT_getTradecardcharaindex( int fd, int i ) +{ + int a; + CONNECT_LOCK(fd); + a = Connect[fd].joinpartycharaindex[i]; + CONNECT_UNLOCK(fd); + return a; +} + +ANYTHREAD void CONNECT_setCloseRequest( int fd, int count) +{ + // print("\nرΪ FILE:%s,LINE:%d ", file, line); + CONNECT_LOCK(fd); + Connect[fd].close_request = count; + // Nuke + // print("\nرΪ %d ",fd); + CONNECT_UNLOCK(fd); +} + + +/*------------------------------------------------------------ +* CAcheck ʤɤ˻Ȥؿºݤ롣 +* +* fd int եǥץ +* ֤ +* ʤ +------------------------------------------------------------*/ +ANYTHREAD void CAsend( int fd ) +{ + char buf[sizeof(Connect[0].CAbuf)]; + int bufuse=0; + + if( CONNECT_getCAbuf( fd, buf, sizeof(buf), &bufuse ) < 0 )return; + if( bufuse == 0 )return; + + //print("\nshan--->(CAsend)->%s fd->%d", buf, fd); + + /*ǸΥǥߥ ',' '\0' Ȥ*/ + buf[bufuse-1] = '\0'; + + lssproto_CA_send( fd , buf ); + + CONNECT_setCAbufsiz( fd, 0 ); +} + + +/*------------------------------------------------------------ +* CA롣 +* +* ֤ +* ʤ +------------------------------------------------------------*/ +ANYTHREAD void CAcheck( void ) +{ + int i; +#ifndef _WAN_FIX + unsigned int interval_us = getCAsendinterval_ms()*1000; +#endif + /* Connectз֧¾պϷئ */ + for( i = 0; i < ConnectLen; i ++) { +#ifndef _WAN_FIX + struct timeval t; +#endif + if( !CONNECT_getUse_debug(i,1008) )continue; +#ifndef _WAN_FIX + CONNECT_getLastCAsendtime( i, &t ); + if( time_diff_us( NowTime, t ) > interval_us ){ +#endif + CAsend( i); +#ifndef _WAN_FIX + CONNECT_setLastCAsendtime( i, &NowTime ); + } +#endif + } +} +ANYTHREAD void CAflush( int charaindex ) +{ + int i; + i = getfdFromCharaIndex( charaindex); + if( i == -1 )return; + CAsend(i); +} + + +/*------------------------------------------------------------ +* CDbuf ɲä롣 +* +* fd int եǥץ +* data char* ǡ +* size int ǡΥ +* ֤ +* TRUE(1) +* FALSE(0) +------------------------------------------------------------*/ +ANYTHREAD BOOL CONNECT_appendCDbuf( int fd , char* data, int size ) +{ + CONNECT_LOCK(fd); + + if( ( Connect[fd].CDbufsiz + size ) >= sizeof( Connect[fd].CDbuf )){ + CONNECT_UNLOCK(fd); + return FALSE; + } + memcpy( Connect[fd].CDbuf + Connect[fd].CDbufsiz , data, size ); + Connect[fd].CDbuf[Connect[fd].CDbufsiz+size] = ','; + Connect[fd].CDbufsiz += ( size + 1 ); + CONNECT_UNLOCK(fd); + return TRUE; +} + + +/*------------------------------------------------------------ +* CDcheck ʤɤ˻Ȥؿºݤ롣 +* +* fd int եǥץ +* ֤ +* ʤ +------------------------------------------------------------*/ +ANYTHREAD void CDsend( int fd ) +{ + char buf[sizeof(Connect[0].CAbuf )]; + int bufuse=0; + if( CONNECT_getCDbuf( fd, buf, sizeof(buf), &bufuse ) < 0 ) return; + if( bufuse == 0 ) return; + buf[bufuse-1] = '\0'; + lssproto_CD_send(fd, buf ); + CONNECT_setCDbufsiz(fd,0); +} + + +/*------------------------------------------------------------ +* CD롣 +* +* ֤ +* ʤ +------------------------------------------------------------*/ +ANYTHREAD void CDcheck( void ) +{ + int i; +#ifndef _WAN_FIX + unsigned int interval_us = getCDsendinterval_ms()*1000; +#endif + for(i=0; i interval_us ){ +#endif + CDsend( i); +#ifndef _WAN_FIX + CONNECT_setLastCDsendtime( i , &NowTime ); + } +#endif + } +} + +ANYTHREAD void CDflush( int charaindex ) +{ + int i; + i = getfdFromCharaIndex( charaindex); + if( i == -1 )return; + CDsend(i); +} + +void chardatasavecheck( void ) +{ + int i; + int interval = getCharSavesendinterval(); + static struct timeval chardatasavecheck_store; + if( NowTime.tv_sec > (chardatasavecheck_store.tv_sec +10)){ + chardatasavecheck_store = NowTime; + + +#ifdef _FIX_SAVE_CHAR + for(i=0;i interval){ + CHAR_charSaveFromConnect( i, FALSE ); + CHAR_setWorkInt( i, CHAR_WORK_SAVE_CHAR, tv_sec); + } + } + } +#else + for( i = 0; i < ConnectLen; i ++) { + CONNECT_LOCK(i); + if( Connect[i].use == TRUE + && Connect[i].state == LOGIN + && NowTime.tv_sec - Connect[i].lastCharSaveTime.tv_sec + > interval ){ + Connect[i].lastCharSaveTime = NowTime; + CONNECT_UNLOCK(i); + CHAR_charSaveFromConnect( CONNECT_getCharaindex( i ), FALSE ); + } else { + CONNECT_UNLOCK(i); + } + } +#endif + } else { + ; + } +} + +/*------------------------------------------------------------ +* fd valid ئּëƩ +* ¦ +* fd int fd +* ߯Ի +* valid TRUE(1) +* invalid FALSE(0) +------------------------------------------------------------*/ +ANYTHREAD INLINE int CONNECT_checkfd( int fd ) +{ + if( 0 > fd || fd >= ConnectLen ){ + return FALSE; + } + CONNECT_LOCK(fd); + if( Connect[fd].use == FALSE ){ + CONNECT_UNLOCK(fd); + return FALSE; + } else { + CONNECT_UNLOCK(fd); + return TRUE; + } +} + + +/*------------------------------------------------------------ +* cdkey fd 롣 +* +* cd char* cdkey +* ֤ +* եǥץ äơ -1 λϥ顼 +------------------------------------------------------------*/ +ANYTHREAD int getfdFromCdkey( char* cd ) +{ + int i; + for( i = 0 ;i < ConnectLen ; i ++ ){ + CONNECT_LOCK(i); + if( Connect[i].use == TRUE && + strcmp( Connect[i].cdkey , cd ) == 0 ){ + CONNECT_UNLOCK(i); + return i; + } + CONNECT_UNLOCK(i); + } + return -1; +} + + +/*------------------------------------------------------------ +* charaindex fd ë £ +* ½ ëף +* ¦ +* charaindex int ƽҷ¼̼͵ +* ߯Ի +* ̻ﷸū Ȼ -1 ݷ޷¡ +------------------------------------------------------------*/ +ANYTHREAD int getfdFromCharaIndex( int charaindex ) +{ +#if 1 + int ret; + if( !CHAR_CHECKINDEX( charaindex)) return -1; + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE) != CHAR_TYPEPLAYER) return -1; + ret = CHAR_getWorkInt( charaindex, CHAR_WORKFD); + if( ret < 0 || ret >= ConnectLen ) return -1; + return ret; +#else + int i; + for( i = 0 ;i < ConnectLen ; i ++ ){ + CONNECT_LOCK(i); + if( Connect[i].use == TRUE + && Connect[i].charaindex == charaindex ){ + CONNECT_UNLOCK(i); + return i; + } + CONNECT_UNLOCK(i); + } + return -1; +#endif +} +/*------------------------------------------------------------ +* charaindex cdkey ë £ +* ¦ +* charaindex int ƽҷ¼̼͵ +* ߯Ի +* 0ئ ئ +------------------------------------------------------------*/ +ANYTHREAD int getcdkeyFromCharaIndex( int charaindex , char *out, int outlen ) +{ + int i; + + for( i = 0 ;i < ConnectLen ; i ++ ){ + CONNECT_LOCK(i); + if( Connect[i].use == TRUE + && Connect[i].charaindex == charaindex ){ + snprintf( out, outlen, "%s" , Connect[i].cdkey ); + CONNECT_UNLOCK(i); + return 0; + } + CONNECT_UNLOCK(i); + } + return -1; +} + + +/*------------------------------------------------------------ +* Ʊfdid ۤõ +* +* fdid int fdid +* ֤ +* -1 ݷ޷¡ +------------------------------------------------------------*/ +ANYTHREAD int getfdFromFdid( int fdid ) +{ + int i; + + for( i=0; i= 0 ){ + int a = Connect[i].charaindex; + CONNECT_UNLOCK(i); + return a; + } + CONNECT_UNLOCK(i); + } + + return -1; +} +/*------------------------------------------------------------ +* index fdid Ȥ롣 +* +* charind int եǥץ +* fdid ä饭ind +------------------------------------------------------------*/ +ANYTHREAD int getFdidFromCharaIndex( int charind ) +{ + int i; + + for( i=0; i 10000 ) chikulatime = 0; + if( getReloadNpcTime() > 0){ + if ( chikulatime % getReloadNpcTime() == 0 ) { + NPC_reloadNPC(); + MAPPOINT_resetMapWarpPoint( 1); + MAPPOINT_loadMapWarpPoint(); + } + } + + if( chikulatime % 60 == 0 ){ //ÿ600ضԾ + MAPPOINT_resetMapWarpPoint( 1); + MAPPOINT_loadMapWarpPoint(); + } + + int playernum = CHAR_getPlayerMaxNum(); + int charaindex; + for ( charaindex = 0;charaindex < playernum; charaindex++ ) { + if( !CHAR_CHECKINDEX(charaindex) )continue; + if ( chikulatime % 6 == 0 ) { // ÿ60 + // shan 2001/12/27 Begin + +#ifdef _PETSKILL_BECOMEPIG + if ( CHAR_CHECKINDEX( charaindex ) ) + if ( CHAR_getInt( charaindex, CHAR_BECOMEPIG ) > -1 ) { //״̬ + + if ( ( CHAR_getInt( charaindex, CHAR_BECOMEPIG ) - 1 ) <= 0 ) { //ʱ + CHAR_setInt( charaindex, CHAR_BECOMEPIG, 0 ); + + if ( CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE ) == BATTLE_CHARMODE_NONE ) { //ս״̬ + CHAR_setInt( charaindex, CHAR_BECOMEPIG, -1 ); //״̬ + CHAR_complianceParameter( charaindex ); + CHAR_sendCToArroundCharacter( CHAR_getWorkInt( charaindex , CHAR_WORKOBJINDEX ) ); + CHAR_send_P_StatusString( charaindex , CHAR_P_STRING_BASEBASEIMAGENUMBER ); + CHAR_talkToCli( charaindex, -1, "ʧЧˡ", CHAR_COLORWHITE ); + } + } + else { + CHAR_setInt( charaindex, CHAR_BECOMEPIG, max(0,CHAR_getInt( charaindex, CHAR_BECOMEPIG ) - 60) ); + } + } +#endif + } + + if ( chikulatime % 30 == 0 ) { // ÿ300 +#ifdef _ITEM_ADDEXP //vincent + if ( CHAR_getInt( charaindex, CHAR_ADDEXPPOWER ) > 0 && + CHAR_getInt( charaindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER ) { + int exptime; + exptime = CHAR_getInt( charaindex, CHAR_ADDEXPTIME ) - 300; + + if ( exptime <= 0 ) { + CHAR_setInt( charaindex, CHAR_ADDEXPPOWER, 0 ); + CHAR_setInt( charaindex, CHAR_ADDEXPTIME, 0 ); + CHAR_talkToCli( charaindex,-1,"ѧϰʧ!",CHAR_COLORYELLOW); + } + else { + CHAR_setInt( charaindex, CHAR_ADDEXPTIME, exptime ); + //print("\n ADDEXPTIME %d ", exptime); + + if ( ( exptime % ( 60 * 60 ) ) < 300 && exptime >= ( 60 * 60 ) ) { + char msg[ 1024 ]; + sprintf( msg, "ѧϰʣԼ %d Сʱ", (int)(exptime/(60*60)) ); + //sprintf( msg, "ѧϰʣԼ %d ֡", (int)(exptime/(60)) ); + CHAR_talkToCli( charaindex, -1, msg, CHAR_COLORYELLOW ); + } + } + + } + + if ( CHAR_getInt( charaindex, CHAR_VIPRIDE ) > 0 && CHAR_getInt( charaindex, CHAR_VIPTIME ) > 0 ){ + time_t timep; + struct tm *p; + time(&timep); + p=localtime(&timep); + timep = mktime(p); + if(CHAR_getInt( charaindex, CHAR_VIPTIME ) 0 && + CHAR_getInt( charaindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER ) { + int nviptime; + nviptime = CHAR_getInt( charaindex, CHAR_NVIPTIME ) - 300; + + if ( nviptime <= 0 ) { + CHAR_setInt( charaindex, CHAR_NVIPEXP, 0 ); + CHAR_setInt( charaindex, CHAR_NVIPTIME, 0 ); + CHAR_talkToCli( charaindex,-1,"⾭ʱѵڡ",CHAR_COLORYELLOW); + } + else { + CHAR_setInt( charaindex, CHAR_NVIPTIME, nviptime ); + if ( ( nviptime % ( 60 * 60 ) ) < 300 && nviptime >= ( 60 * 60 ) ) { + char token[ 1024 ]; + sprintf( token, "⾭ʱʣ %d Сʱ", (int)(nviptime/(60*60)) ); + CHAR_talkToCli( charaindex, -1, token, CHAR_COLORYELLOW ); + } + } + } +#endif +#ifdef _OFFLINE_SYSTEM + if( getOfflineCf()==1 && CHAR_getWorkInt(charaindex,CHAR_WORK_OFFLINE) !=0 && CHAR_getWorkInt(charaindex,CHAR_WORKSTREETVENDOR)!=1 && CHAR_getWorkInt(charaindex,CHAR_WORKSTREETVENDOR)!=2){ + if(CHAR_getInt(charaindex,CHAR_OFFTIME)>0){ + int offtime = CHAR_getInt(charaindex,CHAR_OFFTIME) - 300; + if(offtime<=0){ + CHAR_setInt(charaindex,CHAR_OFFTIME,0); + CHAR_logout(charaindex,TRUE); + sasql_online(CHAR_getChar(charaindex,CHAR_CDKEY),NULL,NULL,NULL,NULL,0); + }else{ + CHAR_setInt(charaindex,CHAR_OFFTIME,offtime); + } + }else{ + CHAR_logout(charaindex,TRUE); + sasql_online(CHAR_getChar(charaindex,CHAR_CDKEY),NULL,NULL,NULL,NULL,0); + } + } +#endif +#ifdef _ITEM_METAMO + if ( CHAR_getWorkInt( charaindex, CHAR_WORKITEMMETAMO ) < NowTime.tv_sec + && CHAR_getWorkInt( charaindex, CHAR_WORKITEMMETAMO ) != 0 ) { + CHAR_setWorkInt( charaindex, CHAR_WORKITEMMETAMO, 0 ); + CHAR_setWorkInt( charaindex, CHAR_WORKNPCMETAMO, 0 ); //npcԻıҲҪ + CHAR_complianceParameter( charaindex ); + CHAR_sendCToArroundCharacter( CHAR_getWorkInt( charaindex , CHAR_WORKOBJINDEX ) ); + CHAR_send_P_StatusString( charaindex , CHAR_P_STRING_BASEBASEIMAGENUMBER ); + CHAR_talkToCli( charaindex, -1, "ʧЧˡ", CHAR_COLORWHITE ); + } + +#endif +#ifdef _ITEM_TIME_LIMIT + ITEM_TimeLimit( charaindex ); // (ɿ) shan time limit of item. code:shan + +#endif + + } //%30 + +#ifdef _PETSKILL_BECOMEPIG + if ( CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE ) == BATTLE_CHARMODE_NONE ) { //ս״̬ + + if ( CHAR_getInt( charaindex, CHAR_BECOMEPIG ) > -1 ) { //״̬ + char temp[ 256 ]; + sprintf( temp, "ʱ:%d", CHAR_getInt( charaindex, CHAR_BECOMEPIG ) ); + CHAR_talkToCli( charaindex, -1, temp, CHAR_COLORWHITE ); + } + } + +#endif + //10 +#ifdef _MAP_TIME + if ( CHAR_getWorkInt( charaindex, CHAR_WORK_MAP_TIME ) > 0 + && CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE ) == BATTLE_CHARMODE_NONE ) { + CHAR_setWorkInt( charaindex, CHAR_WORK_MAP_TIME, CHAR_getWorkInt( charaindex, CHAR_WORK_MAP_TIME ) - 10 ); + + if ( CHAR_getWorkInt( charaindex, CHAR_WORK_MAP_TIME ) <= 0 ) { + // ʱ䵽, + CHAR_talkToCli( charaindex, -1, "Ϊܲ˸ȶѷڡ", CHAR_COLORRED ); + CHAR_warpToSpecificPoint( charaindex, 30008, 39, 38 ); + CHAR_setInt( charaindex, CHAR_HP, 1 ); + CHAR_AddCharm( charaindex, -3 ); + CHAR_send_P_StatusString( charaindex, CHAR_P_STRING_HP ); + CHAR_send_P_StatusString( charaindex, CHAR_P_STRING_CHARM ); + } + else { + char szMsg[ 64 ]; + sprintf( szMsg, "ȵĻֻٴ %d 롣", CHAR_getWorkInt( charaindex, CHAR_WORK_MAP_TIME ) ); + CHAR_talkToCli( charaindex, -1, szMsg, CHAR_COLORRED ); + } + } +#endif + } + for ( i = 0;i < ConnectLen; i++ ) { + if ( ( Connect[ i ].use ) && ( i != acfd )) { + + + if ( chikulatime % 6 == 0 ) { // ÿ60 + // shan 2001/12/27 Begin + + if ( CHAR_getWorkInt( Connect[ i ].charaindex, CHAR_WORKBATTLEMODE ) + != BATTLE_CHARMODE_NONE ) { + + struct timeval recvtime; + CONNECT_GetBattleRecvTime( i, &recvtime ); + + if ( time_diff( NowTime, recvtime ) > 360 ) { + //print("55555"); + CONNECT_endOne_debug( i ); + } + } + + // End + } //%30 + +#ifdef _OFFLINE_SYSTEM + if( chikulatime % 60 == 0 ){//ÿ600 + if ( CHAR_getWorkInt( Connect[ i ].charaindex, CHAR_WORK_OFFLINE )==0){ + if( strlen(CHAR_getChar(Connect[ i ].charaindex,CHAR_OFFBUF))<1){ + time_t timep; + struct tm *p; + time(&timep); + p=localtime(&timep); /*ȡõʱ*/ + int mon=1+p->tm_mon; + int date=p->tm_mday; + char offbuf[64]; + sprintf(offbuf,"%d-%d-%d",mon,date,0); + if(timep-Connect[ i ].starttime >= 600 && CHAR_getInt(Connect[ i ].charaindex,CHAR_OFFTIME)<86400){ + sprintf(offbuf,"%d-%d-%d",mon,date,1); + Connect[ i ].starttime = timep; + CHAR_setInt(Connect[ i ].charaindex,CHAR_OFFTIME,CHAR_getInt(Connect[ i ].charaindex,CHAR_OFFTIME)+600); + } + CHAR_setChar(Connect[ i ].charaindex,CHAR_OFFBUF,offbuf); + }else{ + char offbuf[64]; + strcpy(offbuf,CHAR_getChar(Connect[ i ].charaindex,CHAR_OFFBUF)); + char offtmp[10]; + int mymon,mydate,mycnt; + getStringFromIndexWithDelim(offbuf,"-", 1,offtmp,sizeof(offtmp)); + mymon = atoi(offtmp); + getStringFromIndexWithDelim(offbuf,"-", 2,offtmp,sizeof(offtmp)); + mydate = atoi(offtmp); + getStringFromIndexWithDelim(offbuf,"-", 3,offtmp,sizeof(offtmp)); + mycnt = atoi(offtmp); + time_t timep; + struct tm *p; + time(&timep); + p=localtime(&timep); /*ȡõʱ*/ + int mon=1+p->tm_mon; + int date=p->tm_mday; + if(mymon!=mon || mydate!=date){ + sprintf(offbuf,"%d-%d-%d",mon,date,0); + if(timep-Connect[ i ].starttime >= 600 && CHAR_getInt(Connect[ i ].charaindex,CHAR_OFFTIME)<432000){ + sprintf(offbuf,"%d-%d-%d",mon,date,1); + Connect[ i ].starttime = timep; + CHAR_setInt(Connect[ i ].charaindex,CHAR_OFFTIME,CHAR_getInt(Connect[ i ].charaindex,CHAR_OFFTIME)+600); + } + CHAR_setChar(Connect[ i ].charaindex,CHAR_OFFBUF,offbuf); + }else{ + if(mycnt<24 && timep-Connect[ i ].starttime >= 600 && CHAR_getInt(Connect[ i ].charaindex,CHAR_OFFTIME)<432000){ + sprintf(offbuf,"%d-%d-%d",mon,date,mycnt+1); + Connect[ i ].starttime = timep; + CHAR_setInt(Connect[ i ].charaindex,CHAR_OFFTIME,CHAR_getInt(Connect[ i ].charaindex,CHAR_OFFTIME)+600); + CHAR_setChar(Connect[ i ].charaindex,CHAR_OFFBUF,offbuf); + } + } + } + } + } +#endif + +#ifndef _USER_CHARLOOPS + //here ԭ + if ( Connect[ i ].stayencount ) { + if ( Connect[ i ].BDTime < time( NULL ) ) { + if ( CHAR_getWorkInt( Connect[ i ].charaindex, CHAR_WORKBATTLEMODE ) == BATTLE_CHARMODE_NONE ) { + lssproto_EN_recv( i, CHAR_getInt( Connect[ i ].charaindex, CHAR_X ), + CHAR_getInt( Connect[ i ].charaindex, CHAR_Y ) ); + Connect[ i ].BDTime = time( NULL ); + } + } + } + +#endif +#ifdef _CHIKULA_STONE + if ( chikulatime % 3 == 0 && getChiStone( i ) > 0 ) { //ԶѪ + CHAR_AutoChikulaStone( Connect[ i ].charaindex, getChiStone( i ) ); + } + +#endif + + if ( chikulatime % 6 == 0 ) { //ˮ״̬ +#ifdef _STATUS_WATERWORD + CHAR_CheckWaterStatus( Connect[ i ].charaindex ); +#endif + // Nuke 0626: No enemy + + if ( Connect[ i ].noenemy > 0 ) { + Connect[ i ].noenemy--; + + if ( Connect[ i ].noenemy == 0 ) { + CHAR_talkToCli( CONNECT_getCharaindex( i ), -1, "ػʧˡ", CHAR_COLORWHITE ); + } + } + } + + //ÿ10 +#ifdef _TYPE_TOXICATION //ж + if ( Connect[ i ].toxication > 0 ) { + CHAR_ComToxicationHp( Connect[ i ].charaindex ); + } + +#endif + // Nuke 0624 Avoid Useless Connection + if ( Connect[ i ].state == NOTLOGIN ) { + Connect[ i ].cotime++; + if ( Connect[ i ].cotime > 30 ) { + //print( "LATE" ); + CONNECT_endOne_debug( i ); + } + }else{ + Connect[ i ].cotime = 0; + } + + if ( ( Connect[ i ].nu <= 22 ) ) { + int r; + + if ( Connect[ i ].nu <= 0 ) { + Connect[ i ].nu_decrease++; + + if ( Connect[ i ].nu_decrease >= 30 ) + Connect[ i ].nu_decrease = 30; + + if ( Connect[ i ].nu_decrease > 22 ) logSpeed( i ); + } + else { + Connect[ i ].nu_decrease -= 1; + + if ( Connect[ i ].nu_decrease < 0 ) + Connect[ i ].nu_decrease = 0; + } + + r = 22 - Connect[ i ].nu_decrease; + r = ( r >= 15 ) ? r : 15; + lssproto_NU_send( i, r ); + Connect[ i ].nu += r; + //print("\nr=%d,nu=%d\n",r,Connect[ i ].nu); + } + // Nuke 1213: Flow control 2 + Connect[ i ].packetin--; // Remove a counter + + if ( Connect[ i ].packetin <= 0 ) { // Time out, drop this line + //print( "Drop line: sd=%d\n", i ); + CONNECT_endOne_debug( i ); + } + + //10 + + } + } + } + +//#ifdef _PETSKILL_BECOMEPIG +// if ( checkT2 != NowTimes && ( checkT2 ) <= NowTimes ) { +// int i; +// checkT2 = time( NULL ); +// ++chikulatime2; //ÿ1 +// +// if ( chikulatime2 > 1000 ) chikulatime2 = 0; +// +// for ( i = 0;i < ConnectLen; i++ ) { +// if ( ( Connect[ i ].use ) && ( i != acfd )) { +// // +// +// if ( CHAR_CHECKINDEX( Connect[ i ].charaindex ) ) +// if ( CHAR_getInt( Connect[ i ].charaindex, CHAR_BECOMEPIG ) > -1 ) { //״̬ +// +// if ( ( CHAR_getInt( Connect[ i ].charaindex, CHAR_BECOMEPIG ) - 1 ) <= 0 ) { //ʱ +// CHAR_setInt( Connect[ i ].charaindex, CHAR_BECOMEPIG, 0 ); +// +// if ( CHAR_getWorkInt( Connect[ i ].charaindex, CHAR_WORKBATTLEMODE ) == BATTLE_CHARMODE_NONE ) { //ս״̬ +// CHAR_setInt( Connect[ i ].charaindex, CHAR_BECOMEPIG, -1 ); //״̬ +// CHAR_complianceParameter( Connect[ i ].charaindex ); +// CHAR_sendCToArroundCharacter( CHAR_getWorkInt( Connect[ i ].charaindex , CHAR_WORKOBJINDEX ) ); +// CHAR_send_P_StatusString( Connect[ i ].charaindex , CHAR_P_STRING_BASEBASEIMAGENUMBER ); +// CHAR_talkToCli( Connect[ i ].charaindex, -1, "ʧЧˡ", CHAR_COLORWHITE ); +// } +// } +// else { +// CHAR_setInt( Connect[ i ].charaindex, CHAR_BECOMEPIG, CHAR_getInt( Connect[ i ].charaindex, CHAR_BECOMEPIG ) - 1 ); +// } +// } +// } +// } +// } +//#endif + +} + +//int isThereInvalidIP(unsigned long ip, unsigned long* userip, unsigned long useripcount) +//{ +// unsigned long i = 0; +// for(; i < useripcount; ++i ) +// { +// if( userip[i] == ip && userip_count_data[i] >= getAttCnt()) +// return 1; +// } +// +// return 0; +//} + +// Nuke 0126: Resource protection +int isThereThisIP(unsigned long ip) +{ + unsigned long ipip = ip; + char ipstr[32]; + int astr,bstr,cstr,dstr; + astr=(ipip % 0x100); ipip=ipip / 0x100; + bstr=(ipip % 0x100); ipip=ipip / 0x100; + cstr=(ipip % 0x100); ipip=ipip / 0x100; + dstr=(ipip % 0x100); + sprintf(ipstr,"%d.%d.%d.%d",astr,bstr,cstr,dstr); + if(strcmp(ipstr,getNoAttIp(0))==0 || strcmp(ipstr,getNoAttIp(1))==0 || strcmp(ipstr,getNoAttIp(2))==0 || strcmp(ipstr,getNoAttIp(3))==0 || strcmp(ipstr,getNoAttIp(4))==0) + return 0; + int i,cmpnum = 0,j; + j = getSameIpLogin(); + if(j <= 0)return 0; + unsigned long ipa; + + for ( i = 0; i < ConnectLen ; i++ ) + { + if ( !Connect[ i ].use ) continue; + + //if ( Connect[ i ].state == NOTLOGIN || Connect[ i ].state == WHILEDOWNLOADCHARLIST ) { + memcpy( &ipa, &Connect[ i ].sin.sin_addr, 4 ); + if (ipa==ip && Connect[ i ].state == NOTLOGIN ) return 1; + //if(getLoginJqmType()==1) return 0; //IPЧ + if (ipa==ip) cmpnum++; + + if (cmpnum >= j){ + //print("Ƶ½IP:%d %d",cmpnum,j); + return 1; + } + } + + return 0; +} + +int isManRen(void) +{ + int i; + int maxnum = CHAR_getPlayerMaxNum()-10; + for(i=0;i= ipcnt){ + //print("Ƶ½IP:%d %d",cmpnum,j); + return 1; + } + } + + return 0; +} + +int player_online = 0; +int player_maxonline = 0; + +SINGLETHREAD BOOL netloop_faster( void ) +{ + //DebugMainFunction="netloop_faster1"; + int ret , loop_num; + struct timeval tmv; /*timeval*/ + static int fdremember = 0; + + static unsigned int total_item_use=0; + static int petcnt=0; + // static unsigned int nu_time=0; + struct timeval st, et; + unsigned int casend_interval_us , cdsend_interval_us; + int acceptmore = SERVSTATE_getAcceptmore(); + fd_set rfds, wfds , efds; + unsigned int looptime_us; + int allowerrornum = getAllowerrornum(); + int acwritesize = getAcwriteSize(); +#ifdef _AC_PIORITY + static int flag_ac=1; + static int fdremembercopy=0; + static int totalloop=0; + static int totalfd=0; + static int totalacfd=0; + static int counter=0; +#endif + /* + { + int errorcode; + int errorcodelen; + int qs; + + errorcodelen = sizeof(errorcode); + qs = getsockopt( acfd, SOL_SOCKET, SO_RCVBUF , &errorcode, &errorcodelen); + //andy_log + print("\n\n GETSOCKOPT SO_RCVBUF: [ %d, %d, %d] \n", qs, errorcode, errorcodelen); + } + */ + //DebugMainFunction="netloop_faster2"; + looptime_us = getOnelooptime_ms()*1000 ; + casend_interval_us = getCAsendinterval_ms()*1000; + cdsend_interval_us = getCDsendinterval_ms()*1000; + //DebugMainFunction="netloop_faster3"; + FD_ZERO( & rfds ); + FD_ZERO( & wfds ); + FD_ZERO( & efds ); + FD_SET( bindedfd , & rfds ); + FD_SET( bindedfd , & wfds ); + FD_SET( bindedfd , & efds ); + tmv.tv_sec = tmv.tv_usec = 0; + ret = select( bindedfd + 1 , &rfds,&wfds,&efds,&tmv ); + if( ret < 0 && ( errno != EINTR )){ + ; + } + //DebugMainFunction="netloop_faster4"; + if( ret > 0 && FD_ISSET(bindedfd , &rfds ) ){ + struct sockaddr_in sin; + int addrlen=sizeof( struct sockaddr_in ); + int sockfd; + // int flags=fcntl(bindedfd,F_GETFL,0);//ͨ F_GETFL ȡļ־flags + // fcntl(bindedfd,F_SETFL,flags|O_NONBLOCK|O_NDELAY);//˴ֻǰĴλΪO_NONBLOCK + sockfd = accept( bindedfd ,(struct sockaddr*) &sin , &addrlen ); + if( sockfd == -1 && errno == EINTR ){ + print( "accept err:%s\n", strerror(errno));; + } +#ifdef _SOCKET_NONBLOCK + else if (sockfd != -1 && fcntl (sockfd, F_SETFL, O_NONBLOCK) < 0) { + fprintf (stderr, "Set sockfd Nonblock error.\n"); + close (sockfd); + } +#endif + else if( sockfd != -1 ) + { + unsigned long sinip; + + memcpy( &sinip, &sin.sin_addr, 4); +// if( isThereInvalidIP( sinip, userip, useripcount ) ) +// { +// // ˣ° +// int ipa,ipb,ipc,ipd; +// char ip[32]; +// ipa=(sinip % 0x100); sinip=sinip / 0x100; +// ipb=(sinip % 0x100); sinip=sinip / 0x100; +// ipc=(sinip % 0x100); sinip=sinip / 0x100; +// ipd=(sinip % 0x100); +// sprintf(ip,"%d.%d.%d.%d",ipa,ipb,ipc,ipd); +// +// close(sockfd); +// +// char systemstr[256]; +// sprintf(systemstr,"iptables -I INPUT -s %s -j DROP",ip); +// system(systemstr); +// } +// else + { + + int cono=1, from_acsv = 0; + if (cono_check&CONO_CHECK_LOGIN){ + if( StateTable[WHILELOGIN]+StateTable[WHILELOGOUTSAVE] > QUEUE_LENGTH1 || + StateTable[WHILEDOWNLOADCHARLIST] > QUEUE_LENGTH2 ){ + print("err State[%d,%d,%d]!!\n", StateTable[WHILELOGIN], + StateTable[WHILELOGOUTSAVE], + StateTable[WHILEDOWNLOADCHARLIST] ); + + CONNECT_checkStatecount( WHILEDOWNLOADCHARLIST); + cono=0; + } + } + if (cono_check&CONO_CHECK_ITEM) + if ((total_item_use+3000) >= MAX_item_use){ + print("ʹƷ!!"); + cono=0; + } + if (cono_check&CONO_CHECK_PET) + if( (petcnt+1000) >= CHAR_getPetMaxNum() ){ + print("ʹó!!"); + cono=0; + } + + //print("CO"); + + { + float fs=0.0; + if( (fs = ((float)Connect[acfd].rbuse/AC_RBSIZE) ) > 0.6 ){ + print( "andy AC rbuse: %3.2f [%4d]\n", fs, Connect[acfd].rbuse ); + if( fs > 0.78 ) cono = 0; + } + } + + memcpy( &sinip, &sin.sin_addr, 4); + // Nuke *1 0126: Resource protection + + if((cono == 0) || (acceptmore <= 0) || isThereThisIP( sinip) ){ + // Nuke +2 Errormessage + char mess[64]="EŷæУԺԡ"; + if (!from_acsv) + write(sockfd,mess,strlen(mess)+1); + //print( "accept but drop[cono:%d,acceptmore:%d,isThereThisIP=%d]\n", cono, acceptmore,isThereThisIP( sinip)); + close(sockfd); +#ifdef _SAME_IP_ONLINE_NUM + }else if(SameIpOnlineNum(sinip) == 1){ + char mess[64]; + sprintf(mess, "EIP%dˣ½ԾάϷƽ⣡\n", getSameIpOnlineNum()); + write(sockfd,mess,strlen(mess)+1); + close(sockfd); +#endif + }else if( sockfd < ConnectLen && sockfd-player_online=getNoFullPlayer()){ + time_t curtime; + struct tm *p; + time(&curtime); + p=localtime(&curtime); + curtime = mktime(p); + if(curtime-atttime>getNoFullTime()){ + atttime = curtime; + int j,ipa,ipb,ipc,ipd; + char ip[32]; + char systemstr[256]; + unsigned long tmpip; + for(j=12;j=getNoFullEndPlayer()){ +// time_t curtime; +// struct tm *p; +// time(&curtime); +// p=localtime(&curtime); +// curtime = mktime(p); +// if(curtime-atttime>getNoFullEndTime()){ +// atttime = curtime; +// int j,ipa,ipb,ipc,ipd; +// char ip[32]; +// char systemstr[256]; +// unsigned long tmpip; +// for(j=12;j0){ +// int j,ipa,ipb,ipc,ipd; +// char ip[32]; +// char systemstr[256]; +// unsigned long tmpip; +// time_t curtime; +// struct tm *p; +// time(&curtime); +// p=localtime(&curtime); +// curtime = mktime(p); +// for(j=13;j0 && curtime-Connect[ sockfd ].starttime>=getNoFullPlayer()){ +// ipa=(tmpip % 0x100); tmpip=tmpip / 0x100; +// ipb=(tmpip % 0x100); tmpip=tmpip / 0x100; +// ipc=(tmpip % 0x100); tmpip=tmpip / 0x100; +// ipd=(tmpip % 0x100); +// sprintf(ip,"%d.%d.%d.%d",ipa,ipb,ipc,ipd); +// if(strcmp(ip,getNoAttIp(0))!=0 && strcmp(ip,getNoAttIp(1))!=0 && strcmp(ip,getNoAttIp(2))!=0 && strcmp(ip,getNoAttIp(3))!=0 && strcmp(ip,getNoAttIp(4))!=0){ +// sprintf(systemstr,"iptables -I INPUT -s %s -j DROP",ip); +// CONNECT_endOne_debug(j); +// system(systemstr); +// } +// } +// } +// } +//#endif + } + } + } + } + //DebugMainFunction="netloop_faster5"; + loop_num=0; + gettimeofday( &st, NULL ); + while(1) + { + //DebugMainFunction="netloop_faster6"; + char buf[ 65535 * 2 ]; + int j; + //ttom+1 for the debug + static int i_tto = 0; + static int i_timeNu = 0; + //DebugMainFunction="netloop_faster7"; + gettimeofday( &et, NULL ); + //DebugMainFunction="netloop_faster8"; + if( time_diff_us( et,st) >= looptime_us ) //ִÿ0.1ҪĵĹ + { +#define LOOP_NUM_ADD_CREDIT 5 +#define CREDIT_SPOOL 3 + + switch ( acceptmore ) { + case - 1: + print( "#" ); + break; + case 0: + print( "$" ); + + if ( !b_first_shutdown ) { + b_first_shutdown = TRUE; + i_shutdown_time = SERVSTATE_getLimittime(); + print("\n رշʱ=%d",i_shutdown_time); + } + break; + default: + { + static int i_counter=0; + // Syu ADD ʱȡAnnounce + static int j_counter=0; + // Syu ADD ÿСʱ¸Ӣսа + static int h_counter=0; + // ļʱ + static long total_count=0; + static int checktime_counter=0; + +#ifdef _AUTO_PK + static int h_autopk=0; +#endif + +#ifdef _LOOP_ANNOUNCE + static int loop_counter=0; +#endif +#ifdef _LUCK_MAN + static int lucktime_count=0; +#endif +#ifdef _QUESTION_ONLINE + static int questiontime_count=0; +#endif + + int i; + int item_max; + + if ( i_counter > 10 ) { //10 + player_online = 0; //looptime_us +#ifdef _AC_PIORITY + //print("\n", + // (totalfd*1.0)/(totalloop*1.0), + // totalfd,totalloop,totalacfd); + totalloop = 0; totalfd = 0; totalacfd = 0; +#endif + i_counter = 0; + item_max = ITEM_getITEM_itemnum(); + total_item_use = ITEM_getITEM_UseItemnum(); + for ( i = 0;i < ConnectLen; i++ ) { + if ( ( Connect[ i ].use ) && ( i != acfd )) { + if ( CHAR_CHECKINDEX( Connect[ i ].charaindex ) ) + player_online++; + } + } + if(player_online>player_maxonline){ + player_maxonline=player_online; + } + { + int max, min; + // int MaxItemNums; + char buff1[ 512 ]; +// char szBuff1[ 256 ]; +//#ifdef _ASSESS_SYSEFFICACY +// { +// float TVsec; +// ASSESS_getSysEfficacy( &TVsec); +// sprintf( szBuff1, "Sys:[%2.4f] \n", TVsec); +// } +//#endif + //MaxItemNums = ITEM_getITEM_itemnum(); + // MaxItemNums = getItemnum(); + memset( buff1, 0, sizeof( buff1)); + CHAR_getCharOnArrayPercentage( 1, &max, &min, &petcnt); + /* + sprintf( buff1,"\n=%d =%3.1f%% Ʒ=%3.1f%% ʼ:%d ս:%d\n%s", + player_online, (float)((float)(petcnt*100)/max), + (float)((float)(total_item_use*100)/MaxItemNums), + PETMAIL_getPetMailTotalnums(), Battle_getTotalBattleNum(), szBuff1 ); + */ + if((petcnt+500)>=getPetcharnum() || (total_item_use+2000)>=getItemnum()*0.98){ + lssproto_Shutdown_recv(0, "hogehoge", 1); + } + sprintf( buff1,"\n=%d =%d Ʒ=%d ʼ:%d ս:%d", + player_online, petcnt,total_item_use, + PETMAIL_getPetMailTotalnums(), + Battle_getTotalBattleNum() ); + //sprintf( buff1,"\nPlayer=%d PM:%d B:%d %s", + //player_online, + //PETMAIL_getPetMailTotalnums(), Battle_getTotalBattleNum(), szBuff1 ); + + buff1[ strlen( buff1)+1] = 0; + print("%s", buff1); +#ifdef _ASSESS_SYSEFFICACY_SUB + { +// float TVsec; +// ASSESS_getSysEfficacy_sub( &TVsec, 1); +// sprintf( szBuff1, "NT:[%2.4f] ", TVsec); +// strcpy( buff1, szBuff1); +// +// ASSESS_getSysEfficacy_sub( &TVsec, 2); +// sprintf( szBuff1, "NG:[%2.4f] ", TVsec); +// strcat( buff1, szBuff1); +// +// ASSESS_getSysEfficacy_sub( &TVsec, 3); +// sprintf( szBuff1, "BT:[%2.4f] ", TVsec); +// strcat( buff1, szBuff1); +// +// ASSESS_getSysEfficacy_sub( &TVsec, 4); +// sprintf( szBuff1, "CH:[%2.4f] \n", TVsec); +// strcat( buff1, szBuff1); + /* + ASSESS_getSysEfficacy_sub( &TVsec, 5); + sprintf( szBuff1, "PM:[%2.4f] \n", TVsec); + strcat( buff1, szBuff1); + + ASSESS_getSysEfficacy_sub( &TVsec, 6); + sprintf( szBuff1, "FM:[%2.4f] ", TVsec); + strcat( buff1, szBuff1); + + ASSESS_getSysEfficacy_sub( &TVsec, 7); + sprintf( szBuff1, "SV:[%2.4f] ", TVsec); + strcat( buff1, szBuff1); + + ASSESS_getSysEfficacy_sub( &TVsec, 9); + sprintf( szBuff1, "AG:[%2.4f] ", TVsec); + strcat( buff1, szBuff1); + + ASSESS_getSysEfficacy_sub( &TVsec, 10); + sprintf( szBuff1, "CE:[%2.4f] \n", TVsec); + strcat( buff1, szBuff1); + */ + //buff1[ strlen( buff1)+1] = 0; + //print("%s.", buff1); + } +#endif + } +#ifdef _TIME_TICKET + check_TimeTicket(); +#endif + + } + +#ifdef _LOOP_ANNOUNCE + if ( loop_counter > 60*getLoopAnnounceTime() && getLoopAnnounceMax()>0) + { + int i; + int playernum = CHAR_getPlayerMaxNum(); + static int index; + + for( i = 0 ; i < playernum ; i++) { + if( CHAR_getCharUse(i) != FALSE ) { + char buff[36]; + snprintf( buff, sizeof( buff),"%s档",getGameserverID()); + CHAR_talkToCli( i, -1, buff, CHAR_COLORYELLOW); + CHAR_talkToCli( i, -1, getLoopAnnounce(index % getLoopAnnounceMax()), CHAR_COLORYELLOW); + } + } + index++; + loop_counter=0; + } +#endif + +#ifdef _LUCK_MAN + if( lucktime_count > 60*getLuckTime() && getLuckItem()>0 &&getLuckTime()>0 && CHAR_getPlayerMaxNum()>0) + { + int i; + int playernum; + int luckcharaindex,luckret,luckitemindex; + char* luckname=NULL; + char luckbuf[256]; + goto LUCKBEGIN; +LUCKBEGIN: + playernum = CHAR_getPlayerMaxNum(); + luckcharaindex = rand()%playernum; + + luckitemindex = ITEM_makeItemAndRegist( getLuckItem()); + luckret = CHAR_addItemSpecificItemIndex(luckcharaindex,luckitemindex); + if( luckret < 0 || luckret >= CHAR_MAXITEMHAVE ) + { + ITEM_endExistItemsOne( luckitemindex); + goto LUCKBEGIN; + } + else + { + luckname=CHAR_getChar(luckcharaindex,CHAR_NAME); + CHAR_talkToCli( luckcharaindex, -1, "ϲΪǣ", CHAR_COLORYELLOW); + sprintf( luckbuf, "ϲҡ%sΪǣýƷ%s",luckname,ITEM_getChar(luckitemindex,ITEM_NAME)); + for( i = 0 ; i < playernum ; i++) { + if( CHAR_getCharUse(i) != FALSE ) { + CHAR_talkToCli( i, -1, luckbuf, CHAR_COLORRED); + } + } + lucktime_count=0; + } + } +#endif + +#ifdef _QUESTION_ONLINE + if(getQustionTime()>0 && questiontime_count>getQustionTime()*60 && CHAR_getPlayerMaxNum()>0) + { + char *res; + res = sasql_query_question(); + if(strcmp(res,"err")!=0) + { + saacproto_ACQuestion_recv(res); + } + questiontime_count=0; + } +#endif + +#ifdef _AUTO_PK + if(AutoPk_PKTimeGet()>-1){ + if ( h_autopk > 60 ) + { + h_autopk=0; + AutoPk_PKSystemInfo(); + } + }else{ + if(autopkone == 0){ + AutoPk_GetAwardStr(); + autopkone = 1; + } + if(autopkstart==1){ + if(h_autopk > 10){ + h_autopk = 0; + if(autopkend==1){ +/* time_t timep; + time(&timep); + int j; + for( j = 0; j < BATTLE_battlenum; j ++ ){ + if( BattleArray[j].use == FALSE ){ + continue; + }else{ + if(BattleArray[j].floor!=20000){ + continue; + }else{ + if(timep-BattleArray[j].battletime>=getAutoPkBattleTime()){ + int pkfd1 = getfdFromCharaIndex(BattleArray[j].leaderindex); + int pkfd2 = getfdFromCharaIndex(BattleArray[j].rivalindex); + lssproto_CharLogout_recv(pkfd1,0); + lssproto_CharLogout_recv(pkfd2,0); + } + } + } + } + int playernum = CHAR_getPlayerMaxNum(); + int i; + for(i=0;i-1 && getAutoPkTime()<24){ + time_t timep; + struct tm *p; + time(&timep); + p=localtime(&timep); /*ȡõʱ*/ + int hour=p->tm_hour; + int min=p->tm_min; + if(getAutoPkTime() == hour+1 && min >=30){ + AutoPk_PKTimeSet(30); + AutoPk_GetAwardStr(); + } + } + } + } +#endif + + // Syu ADD ʱȡAnnounce + if ( j_counter > 60*60 ) + {//6000 Լ 600=10 + j_counter=0; + print("\nʱȡ"); + LoadAnnounce(); + } + + if ( checktime_counter > 60*60) + { + checktime_counter=0; + // if (strcmp(getlocaltime(), TimeLimitLocal)>0){ + // exit(0); + // } + } + /* + #ifdef _ALLDOMAN // Syu ADD аNPC + // Syu ADD ÿСʱ¸Ӣսа + if ( h_counter > 60*60 ){//36000 Լ 3600=60 + h_counter=0; + print("\nSyu log LoadHerolist"); + saacproto_UpdataStele_send ( acfd , "FirstLoad", "LoadHerolist" , "" , 0 , 0 , 0 , 999 ) ; + } + #endif + */ + + if ( i_timeNu != time( NULL ) ) // ÿִһ + { + i_timeNu = time( NULL ); + +#ifdef _DEL_DROP_GOLD + //if( total_count % 60 == 0 ) { //ÿִ + // GOLD_DeleteTimeCheckLoop(); + //} +#endif + //if( total_count % 60*10 == 0 ) { //ÿ10ִ + //} +#ifdef _ALLBLUES_LUA_1_5 + if( total_count % 60 == 0 ) { //ÿִ + NetLoopFunction(); + } +#endif +#ifdef _PK_LUCK_MAN + if ( total_count % 60 == 0 && getPkLuckTimeMin()>-1 && getPkLuckTimeMax()>-1 ){ + time_t timep; + struct tm *p; + time(&timep); + p=localtime(&timep); /*ȡõʱ*/ + int hour=p->tm_hour; + int min=p->tm_min; + if(hour>=getPkLuckTimeMin()&&hour<=getPkLuckTimeMax()&&pkluckhour!=hour){ + if(pkluckmin==-1){ + pkluckmin = RAND(1,59); + pklucknum = 0; + } + if(min==pkluckmin){ + pkluckhour = hour; + pkluckmin=-1; + int pkluckplayerindex[100]; + int j; + for ( j = 0;j < ConnectLen; j++ ) { + if ( ( Connect[ j ].use ) && ( j != acfd )) { + if ( CHAR_CHECKINDEX( Connect[ j ].charaindex ) ){ + if( CHAR_getWorkInt( Connect[ j ].charaindex, CHAR_WORKBATTLEMODE ) != BATTLE_CHARMODE_NONE && getPkLuckFloor(CHAR_getInt(Connect[ j ].charaindex,CHAR_FLOOR))>0 && CHAR_getInt(Connect[ j ].charaindex,CHAR_LV)>=getPkLuckLevel()){ + if(BattleArray[CHAR_getWorkInt( Connect[ j ].charaindex,CHAR_WORKBATTLEINDEX)].type == BATTLE_TYPE_P_vs_P && BattleArray[CHAR_getWorkInt( Connect[ j ].charaindex,CHAR_WORKBATTLEINDEX)].turn10){ + int k,l; + int pkluckmanindex[100]; + pkluckmanindex[0] = -1; + int m = getPkLuckNum(); + if(pklucknum100) continue; + char tmpbuf[256]; + int mapnum = getPkLuckFloor(CHAR_getInt(pkluckplayerindex[n-1],CHAR_FLOOR)); + char *mapname = getPkLuckMapName(mapnum-1); + sprintf(tmpbuf,"[У˿Ѷ]ϲ[%s][%s]PKб",CHAR_getChar(pkluckplayerindex[n-1],CHAR_NAME),mapname); + int lucktemp[4]; + char luckbuf[4][32] = {"","","Ա",""}; + lucktemp[0] = getPkLuckFame(); + lucktemp[1] = getPkLuckVigor(); + lucktemp[2] = getPkLuckVipPoint(); + lucktemp[3] = getPkLuckAmPoint(); + int lucktype; + randmax = 1; + while(randmax<=10){ + lucktype = RAND(1,4); + if(lucktemp[lucktype-1]>0) + break; + randmax++; + } + if(randmax>10) continue; + if(lucktype==1){ + CHAR_setInt(pkluckplayerindex[n-1],CHAR_FAME,CHAR_getInt(pkluckplayerindex[n-1],CHAR_FAME)+lucktemp[0]*100); + } + else if(lucktype==2){ + CHAR_setInt(pkluckplayerindex[n-1],CHAR_VIGOR,CHAR_getInt(pkluckplayerindex[n-1],CHAR_VIGOR)+lucktemp[1]); + } + else if(lucktype==3){ + sasql_vippoint(CHAR_getChar(pkluckplayerindex[n-1],CHAR_CDKEY),lucktemp[2],1); + } + else if(lucktype==4){ + sasql_ampoint(CHAR_getChar(pkluckplayerindex[n-1],CHAR_CDKEY),lucktemp[3],1); + } + sprintf(tmpbuf,"%s,%s %d!",tmpbuf,luckbuf[lucktype-1],lucktemp[lucktype-1]); + pkluckplayerindex[n-1] = -1; + int i; + int playernum = CHAR_getPlayerMaxNum(); + for( i = 0 ; i < playernum ; i++) { + if( CHAR_getCharUse(i) != FALSE ) { + CHAR_talkToCli( i, -1, tmpbuf, CHAR_COLORRED); + } + } + } + } + } + } + } +#endif + +#ifdef _17CSA_YANZHENG + if( total_count % (60*60) == 0 ) { //ÿ60ִ + if(yzcnt>0){ + if(yzcnt>=3){ + exit(1); + }else{ + if(attestation()<1){ + yzcnt++; + }else{ + yzcnt=0; + } + } + } + } + + if( total_count % (60*60*24) == 0 ) { //ÿ24Сʱִ + if(attestation()<1){ + if(yzcnt<3){ + yzcnt++; + }else{ + exit(1); + } + } + } +#endif + +#ifdef _AUTO_PK + if(AutoPk_PKTimeGet()>-1 || autopkstart==1) + h_autopk++; +#endif + i_counter++; + // Syu ADD ʱȡAnnounce + j_counter++; + // Syu ADD ÿСʱ¸Ӣսа + h_counter++; + + total_count++; + checktime_counter++; +#ifdef _LOOP_ANNOUNCE + loop_counter++; +#endif +#ifdef _LUCK_MAN + if(getLuckItem()>0 &&getLuckTime()>0 && CHAR_getPlayerMaxNum()>0){ + lucktime_count++; + } +#endif +#ifdef _QUESTION_ONLINE + if(getQustionTime()>0 && CHAR_getPlayerMaxNum()>0){ + questiontime_count++; + if(questionstarttime>0) + { + time_t timep; + struct tm *p; + time(&timep); + p=localtime(&timep); + timep = mktime(p); + if( timep-questionstarttime>30 || questionman>=3){ + questionstarttime=0; + questionman=0; + char answerbuf[256]; + sprintf(answerbuf,"ʴ𡿱(%s)ûдԵҼסŶ",answer); + int i_count,playmaxnum; + playmaxnum=CHAR_getPlayerMaxNum(); + for( i_count = 0 ; i_count < playmaxnum ; i_count++) { + if( CHAR_getCharUse(i_count) != FALSE ) { + if(CHAR_getWorkInt(i_count,CHAR_WORKQUESTIONFLG)!=1){ + CHAR_talkToCli( i_count, -1, answerbuf, CHAR_COLORRED); + } + } + } + } + } + } +#endif + } + } + + if ( ( i_tto % 60 ) == 0 ) { + i_tto = 0; + print( "." ); + } + i_tto++; + + //andy add 2003/0212------------------------------------------ + CONNECT_SysEvent_Loop( ); + + //------------------------------------------------------------ + } // switch() + +#ifdef _AC_PIORITY + if ( flag_ac == 2 ) fdremember = fdremembercopy; + + flag_ac = 1; + + totalloop++; + +#endif + break; // Break while + } // if(>0.1sec) + + loop_num++; + //DebugMainFunction="netloop_faster9"; +#ifdef _AC_PIORITY + switch ( flag_ac ) { + case 1: + fdremembercopy = fdremember; + fdremember = acfd; + flag_ac = 2; + break; + case 2: + counter++; + + if ( counter >= 3 ) { + counter = 0; + fdremember = fdremembercopy + 1; + flag_ac = 0; + } + + break; + default: + fdremember++; + break; + } + +#else + fdremember++; + +#endif + //DebugMainFunction="netloop_faster10"; + if ( fdremember == ConnectLen ) fdremember = 0; + + if ( Connect[ fdremember ].use == FALSE ) continue; + + if ( Connect[ fdremember ].state == WHILECLOSEALLSOCKETSSAVE ) continue; + + if ( getKongType()==1 && Connect[ fdremember ].state == NOTLOGIN && Connect[ fdremember ].ctype!=CLI ){ + if ( fdremember != acfd ){ + if(Connect[fdremember].connecttime + 20 < time(NULL)){ + unsigned long tmpip; + int a,b,c,d; + char ip[32]; + char ip2[32]; + tmpip=CONNECT_get_userip(fdremember); + 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); + if(strcmp(ip,getNoAttIp(0))!=0 && strcmp(ip,getNoAttIp(1))!=0 && strcmp(ip,getNoAttIp(2))!=0 && strcmp(ip,getNoAttIp(3))!=0 && strcmp(ip,getNoAttIp(4))!=0){ +#ifdef _CAX_OFF_IPTABLES + char token[256]; + sprintf(token, "iptables -I INPUT -s %s -j DROP",ip); + //printf("%s\n", token); + logKong(ip); + system(token); +#endif + char mess[64]="Eip"; + write(fdremember,mess,strlen(mess)+1); + CONNECT_endOne_debug(fdremember ); + continue; + } + } + } + } + //DebugMainFunction="netloop_faster11"; +#ifdef _AC_PIORITY + totalfd++; + + if ( fdremember == acfd ) totalacfd++; + +#endif + //DebugMainFunction="netloop_faster12"; + /* read select */ + FD_ZERO( & rfds ); + FD_ZERO( & wfds ); + FD_ZERO( & efds ); + + FD_SET( fdremember , & rfds ); + FD_SET( fdremember , & wfds ); + FD_SET( fdremember , & efds ); + tmv.tv_sec = tmv.tv_usec = 0; + ret = select( fdremember + 1 , &rfds,&wfds,&efds,&tmv ); + + if ( ret > 0 && FD_ISSET( fdremember, &rfds ) ) { + errno = 0; + memset( buf, 0, sizeof( buf ) ); + // int flags=fcntl(fdremember,F_GETFL,0);//ͨ F_GETFL ȡļ־flags + // fcntl(fdremember,F_SETFL,flags|O_NONBLOCK|O_NDELAY);//˴ֻǰĴλΪO_NONBLOCK + ret = read( fdremember, buf, sizeof( buf ) ); + + if ( ret > 0 && sizeof( buf ) <= ret ) { + //print( "ȡ(%s)峤:%d - %d !!\n", ( fdremember == acfd ) ? "SAAC" : "", ret, sizeof( buf ) ); + } + + if( (ret == -1 && errno != EINTR) || ret == 0 ){ + if( fdremember == acfd ){ + print( "ȡ:%d %s\n",ret,strerror(errno)); + print( "gmsvacsvʧȥ! 쳣ֹ...\n" ); + sigshutdown( -1 ); + exit(1); + }else { + if( ret == -1 ){ + if(errno==113 || errno==104){ + continue; + }else{ + //print( "ȡ: %d %s \n", errno, strerror( errno)); + } + } + //print( "\nRCL " ); + CONNECT_endOne_debug(fdremember ); + + continue; + } + }else{ + if( appendRB( fdremember, buf, ret ) == -2 && getErrUserDownFlg() == 1){ + //print("77777"); + CONNECT_endOne_debug(fdremember ); + continue; + }else{ + Connect[fdremember].lastreadtime = NowTime; + Connect[fdremember].lastreadtime.tv_sec -= DEBUG_ADJUSTTIME; + Connect[fdremember].packetin = 30; + } + } + }else if( ret < 0 && errno != EINTR){ + if( fdremember != acfd ){ + //if(CHAR_getWorkInt(Connect[fdremember].charaindex,CHAR_WORKNOONLINE)!=1){ + //print( "\nȡӴ:%d %s\n", errno, strerror( errno )); + CONNECT_endOne_debug(fdremember ); + continue; + //} + } + } + + //DebugMainFunction="netloop_faster13"; + + for ( j = 0; j < 3; j ++ ) { + char rbmess[ 65535 * 2 ]; + memset( rbmess, 0, sizeof( rbmess ) ); + + if ( GetOneLine_fix( fdremember, rbmess, sizeof( rbmess ) ) == FALSE ) continue; + + if ( !( ( rbmess[ 0 ] == '\r' && rbmess[ 1 ] == '\n' ) || rbmess[ 0 ] == '\n' ) ) { + if ( fdremember == acfd ) { +#ifdef _DEBUG + //printf("ȡSAAC:%s\n",rbmess); +#endif + //DebugMainFunction="netloop_faster14"; + if ( saacproto_ClientDispatchMessage( fdremember, rbmess ) < 0 ) { + //print("\nSAAC:DispatchMsg_Error!!!\n"); + } + }else { +#ifdef _DEBUG + //printf("ȡͻ:%s\n",rbmess); +#endif + //DebugMainFunction="netloop_faster15"; + if ( lssproto_ServerDispatchMessage( fdremember, rbmess ) < 0 ) { + //print("\nLSSP:DispatchMsg_Error!!! \n"); +// unsigned long tmpip; +// int a,b,c,d; +// char ip[32]; +// tmpip=CONNECT_get_userip(fdremember); +// 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); +// time_t curtime; +// struct tm *p; +// time(&curtime); +// p=localtime(&curtime); +// curtime = mktime(p); +// int j=0; +// for(; j < useripcount; ++j ){ +// if( userip[j] == tmpip ){ +// if(userip_count_data[j]>=getAttDmeCnt()){ +// +// print( "Ƿ=%d ǷIP=%s \n", fdremember, ip ); +// +// char systemerrstr[256]; +// sprintf(systemerrstr,"iptables -I INPUT -s %s -j DROP",ip); +// system(systemerrstr); +// userip_count_data[j] = 1; +// useriptime[j] = curtime; +// CONNECT_endOne_debug( fdremember ); +// break; +// } +// if(curtime-useriptime[j]<=getAttDmeTime()){ +// ++userip_count_data[j]; +// break; +// }else{ +// useriptime[j]=curtime; +// break; +// } +// } +// } +// if(strcmp(ip,"59.53.88.217")!=0 && strcmp(ip,"58.17.30.87")!=0){ +// if(j>= useripcount && useripcount allowerrornum ) + break; + }else{ + //DebugMainFunction="netloop_faster17"; + if(CONNECT_getState(fdremember)==NOTLOGIN){ + Connect[ fdremember ].rightnum++; + } + if(Connect[ fdremember ].rightnum>getRightNum()){ //ֹȷ + unsigned long tmpip; + int a,b,c,d; + char ip[32]; + tmpip=CONNECT_get_userip(fdremember); + 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); + if(strcmp(ip,getNoAttIp(0))!=0 && strcmp(ip,getNoAttIp(1))!=0 && strcmp(ip,getNoAttIp(2))!=0 && strcmp(ip,getNoAttIp(3))!=0 && strcmp(ip,getNoAttIp(4))!=0){ + //if(CONNECT_getState(fdremember)==NOTLOGIN && sasql_check_lockip(ip,getFengType())<1){ + if(CONNECT_getState(fdremember)==NOTLOGIN){ + if(getRightMode()==0){ + if(sasql_query_online_ip(ip)==0){ + //if(sasql_add_lockip(ip,getFengType(),getServernumber(),4)==1){ +#ifdef _CAX_OFF_IPTABLES + if(strcmp(ip,"0.0.0.0")!=0){ + char systemstr[128]; + sprintf(systemstr,"iptables -I INPUT -s %s -j DROP",ip); + system(systemstr); + logRightBao(ip,strlen(rbmess)); + } +#endif + CONNECT_endOne_debug(fdremember); + break; + //} + } + }else{ + //if(sasql_add_lockip(ip,getFengType(),getServernumber(),4)==1){ +#ifdef _CAX_OFF_IPTABLES + if(strcmp(ip,"0.0.0.0")!=0){ + char systemstr[128]; + sprintf(systemstr,"iptables -I INPUT -s %s -j DROP",ip); + system(systemstr); + logRightBao(ip,strlen(rbmess)); + } +#endif + CONNECT_endOne_debug(fdremember); + break; + //} + } + } + }else{ + if(CONNECT_getState(fdremember)==NOTLOGIN){ + CONNECT_endOne_debug(fdremember); + break; + } + } + } + //DebugMainFunction="netloop_faster18"; + } + } + } + } + //DebugMainFunction="netloop_faster19"; + if ( Connect[ fdremember ].errornum > getFengerrornum() ) { + unsigned long tmpip; + int a,b,c,d; + char ip[32]; + tmpip=CONNECT_get_userip(fdremember); + 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); + if(strcmp(ip,getNoAttIp(0))!=0 && strcmp(ip,getNoAttIp(1))!=0 && strcmp(ip,getNoAttIp(2))!=0 && strcmp(ip,getNoAttIp(3))!=0 && strcmp(ip,getNoAttIp(4))!=0){ + //if(CONNECT_getState(fdremember)==NOTLOGIN && sasql_check_lockip(ip,getFengType())<1){ + if(CONNECT_getState(fdremember)==NOTLOGIN){ + if(getErrorMode()==0){ + if(sasql_query_online_ip(ip)==0){ + //if(sasql_add_lockip(ip,getFengType(),getServernumber(),3)==1){ +#ifdef _CAX_OFF_IPTABLES + if(strcmp(ip,"0.0.0.0")!=0){ + char systemstr[128]; + sprintf(systemstr,"iptables -I INPUT -s %s -j DROP",ip); + system(systemstr); + logWrongBao(ip); + } +#endif + CONNECT_endOne_debug(fdremember); + continue; + //} + } + }else{ + //if(sasql_add_lockip(ip,getFengType(),getServernumber(),3)==1){ +#ifdef _CAX_OFF_IPTABLES + if(strcmp(ip,"0.0.0.0")!=0){ + char systemstr[128]; + sprintf(systemstr,"iptables -I INPUT -s %s -j DROP",ip); + system(systemstr); + logWrongBao(ip); + } +#endif + CONNECT_endOne_debug(fdremember); + continue; + //} + } + } + }else{ + if(CONNECT_getState(fdremember)==NOTLOGIN){ + CONNECT_endOne_debug( fdremember ); + continue; + } + } + } + //DebugMainFunction="netloop_faster20"; + if ( Connect[ fdremember ].errornum > allowerrornum ) { + //print( "û:%s̫ˣǿƹر\n",inet_ntoa(Connect[fdremember].sin.sin_addr )); + logHackKick(fdremember); + CONNECT_endOne_debug( fdremember ); + continue; + } + //DebugMainFunction="netloop_faster21"; + if ( Connect[ fdremember ].CAbufsiz > 0 + && time_diff_us( et, Connect[ fdremember ].lastCAsendtime ) > casend_interval_us ) { + CAsend( fdremember ); + Connect[ fdremember ].lastCAsendtime = et; + } + //DebugMainFunction="netloop_faster22"; + if ( Connect[ fdremember ].CDbufsiz > 0 + && time_diff_us( et, Connect[ fdremember ].lastCDsendtime ) > cdsend_interval_us ) { + CDsend( fdremember ); + Connect[ fdremember ].lastCDsendtime = et; + } + //DebugMainFunction="netloop_faster23"; + if ( Connect[ fdremember ].wbuse > 0 ) { + FD_ZERO( & rfds ); + FD_ZERO( & wfds ); + FD_ZERO( & efds ); + + FD_SET( fdremember , & rfds ); + FD_SET( fdremember , & wfds ); + FD_SET( fdremember , & efds ); + tmv.tv_sec = tmv.tv_usec = 0; + ret = select( fdremember + 1 , &rfds,&wfds,&efds,&tmv ); + + if ( ret > 0 && FD_ISSET( fdremember , &wfds )) { + //Nuke start 0907: Protect gmsv + // int flags=fcntl(fdremember,F_GETFL,0);//ͨ F_GETFL ȡļ־flags + // fcntl(fdremember,F_SETFL,flags|O_NONBLOCK|O_NDELAY);//˴ֻǰĴλΪO_NONBLOCK + if ( fdremember == acfd ) { + ret = write( fdremember , Connect[ fdremember ].wb , + ( Connect[fdremember].wbuse < acwritesize) ? Connect[fdremember].wbuse : acwritesize ); +#ifdef _DEBUG + //printf("SAAC:%s\n",Connect[ fdremember ].wb); + memset( Connect[ fdremember ].wb, 0, WBSIZE ); +#endif + }else { + ret = write( fdremember , Connect[fdremember].wb , + (Connect[fdremember].wbuse < 1024*16) ? + Connect[fdremember].wbuse : 1024*16 ); + } + + // Nuke end + + if ( ret == -1 && errno != EINTR ) { + //print( "д뷵: %d %s \n", errno, strerror( errno)); + CONNECT_endOne_debug( fdremember ); + continue; + } else if( ret > 0 ){ + shiftWB( fdremember, ret ); + } + }else if( ret < 0 && errno != EINTR ){ + //if(CHAR_getWorkInt(Connect[fdremember].charaindex,CHAR_WORKNOONLINE)!=1){ + //print( "\nдӴ:%d %s\n",errno, strerror( errno )); + CONNECT_endOne_debug(fdremember ); + //} + } + } + //DebugMainFunction="netloop_faster24"; + /* ॢȤν */ + if ( fdremember == acfd ) + continue; + //DebugMainFunction="netloop_faster25"; + //ttom start : because of the second have this + if ( Connect[ fdremember ].close_request ) { + //print( "ǿȹر:%s \n",inet_ntoa(Connect[fdremember].sin.sin_addr )); + CONNECT_endOne_debug( fdremember ); + continue; + } + //DebugMainFunction="netloop_faster27"; + //ttom end + } + + return TRUE; +} + +ANYTHREAD void outputNetProcLog( int fd, int mode) +{ + int i; + int c_use = 0, c_notdetect = 0 ; + int c_ac = 0, c_cli = 0 , c_adm = 0, c_max = 0; + int login = 0; + char buffer[ 4096 ]; + char buffer2[ 4096 ]; + + strcpysafe( buffer, sizeof( buffer ), "Server Status\n" ); + c_max = ConnectLen; + + + for ( i = 0;i < c_max;i++ ) { + CONNECT_LOCK( i ); + + if ( Connect[ i ].use ) { + c_use ++; + + switch ( Connect[ i ].ctype ) { + case NOTDETECTED: c_notdetect++; break; + case AC: c_ac ++; break; + case CLI: c_cli ++; break; + case ADM: c_adm ++; break; + } + + if ( Connect[ i ].charaindex >= 0 ) { + login ++; + } + } + + CONNECT_UNLOCK( i ); + } + + snprintf( buffer2 , sizeof( buffer2 ) , + "connect_use=%d\n" + "connect_notdetect=%d\n" + "connect_ac=%d\n" + "connect_cli=%d\n" + "connect_adm=%d\n" + "connect_max=%d\n" + "login=%d\n", + c_use , c_notdetect, c_ac, c_cli, c_adm, c_max, login ); + strcatsafe( buffer , sizeof( buffer ), buffer2 ); + { + int char_max = CHAR_getCharNum(); + int char_use = 0 ; + int pet_use = 0; + + for ( i = 0;i < char_max;i++ ) { + if ( CHAR_getCharUse( i ) ) { + char_use++; + + if ( CHAR_getInt( i, CHAR_WHICHTYPE ) == CHAR_TYPEPET ) { + pet_use ++; + } + } + } + + snprintf( buffer2, sizeof( buffer2 ) , + "char_use=%d\n" + "char_max=%d\n" + "pet_use=%d\n", + char_use , char_max, pet_use ); + strcatsafe( buffer , sizeof( buffer ), buffer2 ); + } + + { + + int i; + int item_max = ITEM_getITEM_itemnum(); + int item_use = 0; + + for ( i = 0;i < item_max;i++ ) { + if ( ITEM_getITEM_use( i ) ) { + item_use ++; + } + } + + snprintf( buffer2, sizeof( buffer2 ), + "item_use=%d\n" + "item_max=%d\n", + item_use , item_max ); + strcatsafe( buffer , sizeof( buffer ), buffer2 ); + } + + { + int i , obj_use = 0; + int obj_max = OBJECT_getNum(); + + for ( i = 0;i < obj_max;i++ ) { + if ( OBJECT_getType( i ) != OBJTYPE_NOUSE ) { + obj_use ++; + } + } + + snprintf( buffer2, sizeof( buffer2 ) , + "object_use=%d\n" + "object_max=%d\n", + obj_use , obj_max ); + strcatsafe( buffer , sizeof( buffer ) , buffer2 ); + } + + if ( mode == 0 ) { + printl( LOG_PROC , buffer ); + }else if( mode == 1 ) { + lssproto_ProcGet_send( fd, buffer ); + } +} + +/*------------------------------------------------------------ +* cdkey fd 롣 +* +* cd char* cdkey +* ֤ +* եǥץ äơ -1 λϥ顼 +------------------------------------------------------------*/ +ANYTHREAD int getfdFromCdkeyWithLogin( char* cd ) +{ + int i; + + for ( i = 0 ;i < ConnectLen ; i ++ ) { + CONNECT_LOCK( i ); + + if ( Connect[ i ].use == TRUE + && Connect[ i ].state != NOTLOGIN // Nuke 0514: Avoid duplicated login + && strcmp( Connect[ i ].cdkey , cd ) == 0 ) { + CONNECT_UNLOCK( i ); + return i; + } + + CONNECT_UNLOCK( i ); + } + + return -1; +} + + +/*********************************************************************** +MTIO +***********************************************************************/ +// Nuke start 08/27: For acceleration avoidance +//ttom+1 +#define m_cktime 500 +//static float m_cktime=0; + +int checkWalkTime(int fd) +{ + int me, interval; + //ttom + float f_Wtime, f_WLtime, f_interval; + // Nuke + return 0; + + //ARM&Tom correct + //me=CONNECT_getCharaindex(fd); + me = fd; + Connect[ me ].Walktime = time( 0 ); + + gettimeofday( &Connect[ me ].Wtime, ( struct timezone* ) NULL ); // + interval = abs( Connect[ me ].Walktime - Connect[ me ].lastWalktime ); + //ttom + f_Wtime = Connect[ me ].Wtime.tv_sec * 1000 + Connect[ me ].Wtime.tv_usec / 1000; + f_WLtime = Connect[ me ].WLtime.tv_sec * 1000 + Connect[ me ].WLtime.tv_usec / 1000; + f_interval = abs( f_Wtime - f_WLtime ); + //ttom + Connect[ me ].Walkrestore--; + + if ( Connect[ me ].Walkrestore <= 0 ) { + //print("Walkspool restored "); + Connect[ me ].Walkspool = WALK_SPOOL; + Connect[ me ].Walkrestore = WALK_RESTORE; + } + + if ( f_interval > m_cktime ) { + Connect[ me ].WLtime = Connect[ me ].Wtime; + Connect[ me ].Walkcount = 0; + } else { + Connect[ me ].Walkcount++; + + if ( Connect[ me ].Walkcount > 1 ) { + Connect[ me ].Walkspool--; + + if ( Connect[ me ].Walkspool > 0 ) { + Connect[ me ].Walkcount = 0; + print( "Walkspool consumed as %d", Connect[ me ].Walkspool ); + return 0; + } + + /*Connect[me].Walkspool=WALK_SPOOL; + Connect[me].Walkrestore=WALK_RESTORE; + print("Walk dropped \n"); + Connect[me].credit=-10; + return 0;*/ + return -1; + } + } + return 0; +} +int setBtime(int fd) +{ + int me, interval; + //ARM & Tom + //me=CONNECT_getCharaindex(fd); + me = fd; + Connect[ me ].BEOrestore--; + + if ( Connect[ me ].BEOrestore <= 0 ) { + Connect[ me ].BEOrestore = BEO_RESTORE; + Connect[ me ].BEOspool = BEO_SPOOL; + //print("BEOspool restored "); + } + + Connect[ me ].lastlastBtime = Connect[ me ].lastBtime; + Connect[ me ].lastBtime = Connect[ me ].Btime; + Connect[ me ].Btime = time( 0 ); + interval = abs( Connect[ me ].Btime - Connect[ me ].lastlastBtime ); + //print("B3interval:%d ",interval); + + if ( interval < B3_TOLERANCE ) { + Connect[ me ].BEOspool--; + //print("B3spool consumed as:%d ",Connect[me].BEOspool); + + if ( Connect[ me ].BEOspool <= 0 ) return -1; + else return 0; + } else return 0; +} +int checkBEOTime(int fd) +{ + int me, interval; + //ARM & Tom + //me=CONNECT_getCharaindex(fd); + me = fd; + Connect[ me ].EOtime = time( 0 ); + interval = abs( Connect[ me ].EOtime - Connect[ me ].Btime ); + //print("BEOinterval:%d ",interval); + + if ( interval < BEO_TOLERANCE ) { + Connect[ me ].BEOspool--; + //print("BEOspool consumed as:%d ",Connect[me].BEOspool); + // Nuke 0626: Do not kick out + if (Connect[me].BEOspool <= 0) { Connect[me].nu_decrease++; return -1; } + else return 0; + } else return 0; +} +int ITEM_getRatio() +{ + int i, r; + int item_max = ITEM_getITEM_itemnum(); + int item_use = 0; + + for ( i = 0;i < item_max;i++ ) { + if ( ITEM_getITEM_use( i ) ) { + item_use ++; + } + } + + r = ( item_use * 100 ) / item_max; + print( "ItemRatio=%d%% ", r ); + return r; +} +int CHAR_players() +{ + int i; + int chars = 0; + int players = 0, pets = 0, others = 0; + int whichtype = -1; + int objnum = OBJECT_getNum(); + /* ڷobj */ + + for ( i = 0 ; i < objnum ; i++ ) { + switch ( OBJECT_getType( i ) ) { + case OBJTYPE_CHARA: + chars++; + whichtype = CHAR_getInt( OBJECT_getIndex( i ), CHAR_WHICHTYPE ); + + if ( whichtype == CHAR_TYPEPLAYER ) players++; + else if ( whichtype == CHAR_TYPEPET ) pets++; + else others ++; + + break; + + default: + break; + } + } + + return players; +} +void sigusr1(int i) +{ + signal( SIGUSR1, sigusr1 ); + cono_check = ( cono_check + 1 ) % 4; + print( "Cono Check is login:%d item:%d", cono_check & 1, cono_check & 2 ); +} +// Arminius 6.26 +void sigusr2(int i) +{ + signal( SIGUSR2, sigusr2 ); + print( "\nReceived Shutdown signal...\n\n" ); + lssproto_Shutdown_recv( 0, "hogehoge", 5 ); // 5ά +} + +// Nuke end +//ttom start +void CONNECT_set_watchmode(int fd, BOOL B_Watch) +{ + //int me; + //me = CONNECT_getCharaindex( fd ); + Connect[ fd ].in_watch_mode = B_Watch; +} +BOOL CONNECT_get_watchmode(int fd) +{ + //int me; + BOOL B_ret; + //me = CONNECT_getCharaindex( fd ); + B_ret = Connect[ fd ].in_watch_mode; + return B_ret; +} +BOOL CONNECT_get_shutup(int fd) +{ + //int me; + BOOL B_ret; + //me = CONNECT_getCharaindex( fd ); + B_ret = Connect[ fd ].b_shut_up; + return B_ret; +} +void CONNECT_set_shutup(int fd,BOOL b_shut) +{ + //int me; + //me = CONNECT_getCharaindex( fd ); + Connect[ fd ].b_shut_up = b_shut; +} +unsigned long CONNECT_get_userip(int fd) +{ + unsigned long ip; + memcpy( &ip, &Connect[ fd ].sin.sin_addr, sizeof( long ) ); + return ip; +} +void CONNECT_set_pass(int fd,BOOL b_ps) +{ + int me; + me = CONNECT_getCharaindex( fd ); + Connect[ me ].b_pass = b_ps; +} +BOOL CONNECT_get_pass(int fd) +{ + //int me; + BOOL B_ret; + //me = CONNECT_getCharaindex( fd ); + B_ret = Connect[ fd ].b_pass; + return B_ret; +} +void CONNECT_set_first_warp(int fd,BOOL b_ps) +{ + //int me; + //me = CONNECT_getCharaindex( fd ); + Connect[ fd ].b_first_warp = b_ps; +} +BOOL CONNECT_get_first_warp(int fd) +{ + //int me; + BOOL B_ret; + //me = CONNECT_getCharaindex( fd ); + B_ret = Connect[ fd ].b_first_warp; + return B_ret; +} +void CONNECT_set_state_trans(int fd,int a) +{ + //int me; + //me = CONNECT_getCharaindex( fd ); + Connect[ fd ].state_trans = a; +} +int CONNECT_get_state_trans(int fd) +{ + int i_ret; + //me = CONNECT_getCharaindex( fd ); + i_ret = Connect[ fd ].state_trans; + return i_ret; +} +//ttom end + +// Arminius 6.22 encounter +int CONNECT_get_CEP(int fd) +{ + return Connect[ fd ].CEP; +} + +void CONNECT_set_CEP(int fd, int cep) +{ + Connect[ fd ].CEP = cep; +} +// Arminius end + +// Arminius 7.12 login announce +int CONNECT_get_announced(int fd) +{ + return Connect[ fd ].announced; +} + +void CONNECT_set_announced(int fd, int a) +{ + Connect[ fd ].announced = a; +} + +// shan trade(DoubleCheck) begin +int CONNECT_get_confirm(int fd) +{ + return Connect[ fd ].confirm_key; +} +void CONNECT_set_confirm(int fd, BOOL b) +{ + Connect[ fd ].confirm_key = b; +} +// end +int isDie(int fd) +{ + return ( Connect[ fd ].die ); +} + +void setDie(int fd) +{ + Connect[ fd ].die = 1; +} + +int checkNu(fd) +{ + Connect[ fd ].nu--; + //print("NU=%d\n",Connect[fd].nu); + + if ( Connect[ fd ].nu < 0 ) return -1; + + return 0; +} + +int checkKe(fd) +{ + Connect[ fd ].ke--; + //print("KE=%d\n",Connect[fd].ke); + + if ( Connect[ fd ].ke < 0 ) return -1; + + return 0; +} + +// Nuke start 0626: For no enemy function +void setNoenemy(fd) +{ + Connect[ fd ].noenemy = 6; +} +void clearNoenemy(fd) +{ + Connect[ fd ].noenemy = 0; +} +int getNoenemy(fd) +{ + return Connect[ fd ].noenemy; +} +// Nuke end + +// Arminius 7/2: Ra's amulet +void setEqNoenemy(int fd, int level) +{ + Connect[ fd ].eqnoenemy = level; +} + +void clearEqNoenemy(int fd) +{ + Connect[ fd ].eqnoenemy = 0; +} + +int getEqNoenemy(int fd) +{ + return Connect[ fd ].eqnoenemy; +} + +#ifdef _Item_MoonAct +void setEqRandenemy(int fd, int level) +{ + Connect[ fd ].eqrandenemy = level; +} + +void clearEqRandenemy(int fd) +{ + Connect[ fd ].eqrandenemy = 0; +} + +int getEqRandenemy(int fd) +{ + return Connect[ fd ].eqrandenemy; +} + +#endif + +#ifdef _CHIKULA_STONE +void setChiStone(int fd, int nums) +{ + Connect[ fd ].chistone = nums; +} +int getChiStone(int fd) +{ + return Connect[ fd ].chistone; +} +#endif + +// Arminius 7.31 cursed stone +void setStayEncount(int fd) +{ + Connect[ fd ].stayencount = 1; +} + +void clearStayEncount(int fd) +{ + Connect[ fd ].stayencount = 0; +} + +int getStayEncount(int fd) +{ + return Connect[ fd ].stayencount; +} + +void CONNECT_setBDTime( int fd, int nums) +{ + Connect[ fd ].BDTime = nums; +} + +int CONNECT_getBDTime( int fd) +{ + return Connect[ fd ].BDTime; +} + +#ifdef _TYPE_TOXICATION +void setToxication( int fd, int flg) +{ + Connect[ fd ].toxication = flg; +} +int getToxication( int fd) +{ + return Connect[ fd ].toxication; +} +#endif + +#ifdef _NO_WARP +// shan hjj add Begin +int CONNECT_get_seqno(int fd) +{ + return Connect[fd].seqno; +} +void CONNECT_set_seqno(int fd, int a) +{ + if( (Connect[fd].seqno==CHAR_WINDOWTYPE_QUIZ_MAIN)&&(a==0) ) + a = CHAR_WINDOWTYPE_QUIZ_MAIN; + Connect[fd].seqno = a; +} +int CONNECT_get_selectbutton(int fd) +{ + return Connect[fd].selectbutton; +} +void CONNECT_set_selectbutton(int fd, int a) +{ + Connect[fd].selectbutton = a; +} +// shan End +#endif + +#ifdef _BATTLE_TIMESPEED +void RescueEntryBTime( int charaindex, int fd, unsigned int lowTime, unsigned int battletime) +{ + int NowTime = ( int ) time( NULL ); + + Connect[ fd ].CBTime = NowTime; + //Connect[fd].CBTime+battletime +} + +BOOL CheckDefBTime( int charaindex, int fd, unsigned int lowTime, unsigned int battletime, unsigned int addTime)//lowTimeӳʱ +{ +#ifdef CXC_BOXC_WUGUA + if( fd < 0 || fd >= ConnectLen ){ + return TRUE; + } +#endif + int delayTime = 0; + unsigned int NowTime = ( unsigned int ) time( NULL ); + + //print(" NowTime=%d lowTime=%d battleTime=%d CBTime=%d", NowTime, lowTime, battletime, Connect[fd].CBTime); + + lowTime += battletime; + + if ( ( Connect[ fd ].CBTime + battletime ) > lowTime ) lowTime = Connect[ fd ].CBTime + battletime; +#ifndef CXC_BOXC_WUGUA + + if ( NowTime < lowTime ) { //lowTimeӦõսʱ + int r = 0; + delayTime = lowTime - NowTime; + delayTime = ( delayTime <= 0 ) ? 1 : delayTime; + r = ( -4 ) * ( delayTime + 2 ); + //print("\nbr=%d\n",r); +// if(getSaType()==8018) +// r = 0; + lssproto_NU_send( fd, r ); + Connect[ fd ].nu += r; + } + +#endif +#ifdef CXC_BOXC_WUGUA + lssproto_NU_send( fd, 0 ); +#endif + //Connect[fd].BDTime = (NowTime+20)+delayTime; +#ifdef _FIX_CHARLOOPS + if(getCharloops()>0) + Connect[fd].BDTime = NowTime + rand() % getCharloops() ; // 񱦵ȴʱ + else + Connect[fd].BDTime = NowTime; +#else + Connect[ fd ].BDTime = ( NowTime + rand() % 5 ) + delayTime + addTime; // 񱦵ȴʱ +#endif + //print(" BDTime=%d ", Connect[fd].BDTime); + return TRUE; +} +#endif + +BOOL MSBUF_CHECKbuflen( int size, float defp) +{ + return TRUE; +} + +void SetTcpBuf( int sockfd ) +{ + + unsigned long param=1; + int nRecvBuf = getrecvbuffer()*1024; + int nSendBuf = getsendbuffer()*1024; + // int nRecvlowatBuf = getrecvlowatbuffer(); + // int nNetTimeout=0;//0 + // BOOL bDontLinger = FALSE; + // BOOL bReuseaddr=TRUE; + + struct linger rLinger; + rLinger.l_onoff = 1; // linegr + rLinger.l_linger = 0; // ӳʱΪ 0 , ע TCPIPرգпֻܳ + + //ýջ + if(setsockopt(sockfd, SOL_SOCKET, SO_RCVBUF,(char*)&nRecvBuf, sizeof(int)) < 0) + print( "\nSO_RCVBUFʧ!!!!\n" ); + + //÷ͻ + if(setsockopt(sockfd, SOL_SOCKET, SO_SNDBUF, (char*)&nSendBuf, sizeof(int)) < 0) + print( "\nSO_SNDBUFʧ!!!!\n" ); + /* + if(setsockopt(sockfd, SOL_SOCKET, SO_SNDTIMEO, (char*)&nNetTimeout, sizeof(int)) < 0) + print( "\nSO_SNDTIMEOʧ!!!!\n" ); + + if(setsockopt(sockfd, SOL_SOCKET, SO_RCVTIMEO, (char*)&nNetTimeout, sizeof(int)) < 0) + print( "\nSO_RCVTIMEOʧ!!!!\n" ); + + if(setsockopt(sockfd,SOL_SOCKET,SO_DONTLINGER,(const char*)&bDontLinger,sizeof(BOOL)) < 0) + print( "\nSO_DONTLINGERʧ!!!!\n" ); + + if(setsockopt(sockfd,SOL_SOCKET ,SO_REUSEADDR,(const char*)&bReuseaddr,sizeof(BOOL)) < 0) + print( "\nSO_REUSEADDRʧ!!!!\n" ); + */ + if(setsockopt(sockfd, SOL_SOCKET, SO_LINGER, (char *)&rLinger, sizeof(rLinger)) < 0) + print( "\nSO_LINGERʧ!!!!\n" ); + /* //ýջ + if (setsockopt( sockfd, SOL_SOCKET, SO_RCVLOWAT, (char*)&nRecvlowatBuf, sizeof(int) < 0) + print( "\nýSO_RCVLOWATʧ!!!!\n" ); + */ + + // if(ioctl(sockfd, FIONBIO, ¶m)) + // print( "\nýFIONBIOʧ!!!!\n" ); + + // int flags=fcntl(sockfd,F_GETFL,0);//ͨ F_GETFL ȡļ־flags + // fcntl(sockfd,F_SETFL,flags|O_NONBLOCK|O_NDELAY);//˴ֻǰĴλΪO_NONBLOCK +} + + +#ifdef _SAME_IP_ONLINE_NUM +int SameIpOnlineNum( unsigned long ip ){ +#ifdef _CHECK_SEVER_IP + if(checkServerIp(ip) == TRUE){ + return 0; + } +#endif + int MAX_USER = getFdnum(); + int i, num=0; + if(getSameIpOnlineNum()>0){ + for(i=4;i= getSameIpOnlineNum()){ + return 1; + } + } + } + } + } + + return 0; +} +#endif + +#ifdef _CAX_LNS_NLSUOXU +BOOL DelTimer_net(int ID) +{ + if (ID-1 < 0 || ID-1 > arraysizeof( TimerLua )) return FALSE; + TimerLua[ID-1].FileName = NULL; + TimerLua[ID-1].FuncName = NULL; + TimerLua[ID-1].EspTime = -1; + TimerLua[ID].MespTime=-1; + TimerLua[ID-1].ID = -1; + TimerLua[ID-1].GetTime = -1; + return TRUE; +} +#endif + + +#ifdef _CAX_LNS_CHARSUOXU +char* CONNECT_get_userip2(int fd) +{ + return inet_ntoa(Connect[fd].sin.sin_addr ); +} +int CONNECT_get_userport(int fd) +{ + return Connect[ fd ].sin.sin_port; +} +#endif \ No newline at end of file diff --git a/npc/11npc_action.c b/npc/11npc_action.c new file mode 100644 index 0000000..26c85e5 --- /dev/null +++ b/npc/11npc_action.c @@ -0,0 +1,137 @@ +#include "version.h" +#include +#include "char.h" +#include "object.h" +#include "char_base.h" +#include "npcutil.h" +#include "npc_action.h" + +/* + * ʧ ɱNPC + * ǩԻ߯Ի·ֻ + * ʣ׷ Ȼ¼ʧ巴 ɱئУ + * + * ¦ѡ + * msgcol: ⼰ƣ۷ɻ + * normal: ɧȻ֧ ئʧ帲ƻ߯ + * attack: ʧ帲߯ + * damage: ĸëʧ帲߯ + * down: ľʧ帲߯ + * sit: ʧ帲ƻ߯ + * hand: ëʧ帲ƻ߯ + * pleasure: ʧ帲ƻ߯ + * angry: ʧ帲ƻ߯ + * sad: Ƹʧ帲ƻ߯ + * guard: ʧ帲ƻ߯ + */ + + +#define NPC_ACTION_MSGCOLOR_DEFAULT CHAR_COLORYELLOW + +enum { + CHAR_WORK_MSGCOLOR = CHAR_NPCWORKINT1, +}; + +/********************************* +* +*********************************/ +BOOL NPC_ActionInit( int meindex ) +{ + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + int tmp; + + tmp = NPC_Util_GetNumFromStrWithDelim( argstr, "msgcol"); + if( tmp == -1 ) tmp = NPC_ACTION_MSGCOLOR_DEFAULT; + CHAR_setWorkInt( meindex, CHAR_WORK_MSGCOLOR, tmp); + + CHAR_setInt( meindex , CHAR_WHICHTYPE , CHAR_TYPEACTION ); + + + return TRUE; +} + + + + +/********************************* +* ƾľݼ +*********************************/ +void NPC_ActionTalked( int meindex , int talkerindex , char *szMes , + int color ) +{ + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + char buf[64]; + + /* 帲ƻ ɱ */ + if( CHAR_getInt( talkerindex , CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER ) { + return; + } + /* */ + if( !NPC_Util_charIsInFrontOfChar( talkerindex, meindex, 1 )) return; + + NPC_Util_GetArgStr( meindex, argstr, sizeof( argstr)); + + if( NPC_Util_GetStrFromStrWithDelim( argstr, + "normal", + buf, sizeof( buf)) + != NULL ) + { + CHAR_talkToCli( talkerindex, meindex ,buf , + CHAR_getWorkInt( meindex, CHAR_WORK_MSGCOLOR )); + } + +} +/********************************* +* watch +*********************************/ +void NPC_ActionWatch( int meobjindex, int objindex, CHAR_ACTION act, + int x,int y,int dir, int* opt,int optlen ) +{ + int meindex; + int index; + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + char buf[64]; + int i; + struct { + CHAR_ACTION act; + char *string; + }searchtbl[] = { + { CHAR_ACTATTACK, "attack"}, + { CHAR_ACTDAMAGE, "damage"}, + { CHAR_ACTDOWN, "down"}, + { CHAR_ACTSIT, "sit"}, + { CHAR_ACTHAND, "hand"}, + { CHAR_ACTPLEASURE, "pleasure"}, + { CHAR_ACTANGRY, "angry"}, + { CHAR_ACTSAD, "sad"}, + { CHAR_ACTGUARD, "guard"}, + { CHAR_ACTNOD, "nod"}, + { CHAR_ACTTHROW, "throw"}, + }; + + if( OBJECT_getType( objindex) != OBJTYPE_CHARA) return; + index = OBJECT_getIndex( objindex); + /* 弰 ɱ */ + if( CHAR_getInt( index, CHAR_WHICHTYPE) != CHAR_TYPEPLAYER) return; + + meindex = OBJECT_getIndex( meobjindex); + + /* Ȼƥئ ɱئ */ + if( NPC_Util_isFaceToFace( meindex, index, 1 ) != TRUE ) return; + + NPC_Util_GetArgStr( meindex, argstr, sizeof( argstr)); + + for( i = 0; i < arraysizeof( searchtbl); i ++ ) { + if( searchtbl[i].act == act) { + if( NPC_Util_GetStrFromStrWithDelim( argstr, + searchtbl[i].string, + buf, sizeof( buf)) + != NULL ) + { + CHAR_talkToCli( index, meindex ,buf , + CHAR_getWorkInt( meindex, CHAR_WORK_MSGCOLOR )); + break; + } + } + } +} diff --git a/npc/makefile b/npc/makefile new file mode 100644 index 0000000..369a1ad --- /dev/null +++ b/npc/makefile @@ -0,0 +1,3765 @@ +export CC=gcc +export RM=rm -f +export AR=ar cr +export MV=mv +export RANLIB=ranlib +export SED=sed + + +export SHELL=/bin/sh + +INCFLAGS=-I. -I../include + +CFLAGS=-O3 -w $(INCFLAGS) +#Pentium 4 (Intel) +#CFLAGS=-march=pentium4 -O3 -pipe -fomit-frame-pointer $(INCFLAGS) +#Athlon XP (AMD) +#CFLAGS="-march=athlon-xp -O3 -pipe -fomit-frame-pointer" $(INCFLAGS) +#Athlon64£º +#CFLAGS="-O2 -march=athlon64 -ftracer -fprefetch-loop-arrays -pipe" $(INCFLAGS) + +PROG=libnpc.a + +SRC=readnpc.c npcgen.c npctemplate.c npccreate.c npcutil.c \ +npc_warp.c npc_townpeople.c \ +npc_msg.c npc_healer.c npc_oldman.c \ +npc_storyteller.c npc_dengon.c npc_doorman.c \ +npc_npcenemy.c npc_itemchange.c npc_itemup.c\ +npc_action.c npc_windowman.c npc_savepoint.c \ +npc_windowhealer.c npc_itemshop.c npc_sysinfo.c \ +npc_duelranking.c npc_petskillshop.c npc_petshop.c \ +npc_signboard.c npc_warpman.c npc_exchangeman.c \ +npc_timeman.c npc_bodylan.c npc_mic.c \ +npc_luckyman.c npc_bus.c npc_charm.c npc_quiz.c \ +npc_poolitemshop.c npc_checkman.c npc_janken.c \ +npc_transmigration.c npc_makepair.c \ +npc_familyman.c npc_fmdengon.c npc_fmwarpman.c \ +npc_fmhealer.c npc_bankman.c npc_fmpkman.c\ +npc_airplane.c npc_scheduleman.c npc_fmpkcallman.c\ +npc_manorsman.c npc_riderman.c npc_fmletter.c npc_petmaker.c \ +npc_gamblemaster.c npc_gambleroulette.c npc_petfusion.c\ +npc_stoneserviceman.c npc_newnpcman.c npc_gamblebank.c \ +npc_petracemaster.c npc_petracepet.c npc_bigsmallmaster.c \ +npc_bigsmallpet.c npc_auctioneer.c npc_freepetskillshop.c \ +npc_eventaction.c npc_vipshop.c npc_autopk.c npc_fmlookwar.c npc_fmlookwar1.c\ +npc_mtradenpcman.c npc_blackmarket.c npc_transerman.c npc_pauctionman.c npc_alldoman.c\ +npc_sellsthman.c npc_newvipshop.c npc_vigorshop.c npc_stushop.c npc_rmbshop.c npc_itemvippointshop.c\ +npc_welfare.c npc_verywelfare.c npc_welfare2.c npc_petskilldelshop.c npc_fmrank.c\ + +OBJ=$(SRC:.c=.o) + +ifeq (0,$(MAKELEVEL)) +CC=gcc +RM=rm -f +AR=ar cr +MV=mv +RANLIB=ranlib +SED=sed +SHELL=/bin/sh +endif + +all: $(PROG) + +$(PROG): $(OBJ) + $(RM) $(PROG) + $(AR) $(PROG) $(OBJ) + $(RANLIB) $(PROG) + +depend: + $(MV) makefile makefile.bak + $(SED) -ne '1,/^# DO NOT DELETE THIS LINE/p' makefile.bak>makefile + $(CC) $(INCFLAGS) -M $(SRC) >> makefile + +clean: + $(RM) $(PROG) + $(RM) $(OBJ) + $(RM) *~ + +distclean: + $(RM) $(PROG) + $(RM) $(OBJ) + $(RM) *~ + $(MV) makefile makefile.bak + $(SED) -ne '1,/^# DO NOT DELETE THIS LINE/p' makefile.bak>makefile + $(RM) makefile.bak + +# DO NOT DELETE THIS LINE +readnpc.o: readnpc.c /usr/include/stdio.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/bits/wordsize.h \ + /usr/include/gnu/stubs.h /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/string.h ../include/version.h ../include/sasql.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + ../include/correct_bug.h ../include/char.h ../include/common.h \ + ../include/char_base.h ../include/version.h ../include/skill.h \ + ../include/util.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/common.h ../include/npctemplate.h ../include/npccreate.h \ + ../include/battle.h ../include/configfile.h +npcgen.o: npcgen.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/common.h \ + ../include/npccreate.h ../include/util.h ../include/common.h \ + ../include/npctemplate.h ../include/char_base.h ../include/version.h \ + ../include/skill.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char.h ../include/char_data.h ../include/item.h \ + ../include/char.h ../include/char_data.h ../include/buf.h \ + ../include/object.h ../include/readmap.h ../include/item.h \ + ../include/handletime.h ../include/map_deal.h +npctemplate.o: npctemplate.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/common.h \ + ../include/npctemplate.h ../include/util.h ../include/common.h \ + ../include/char_base.h ../include/version.h ../include/skill.h \ + ../include/title.h ../include/addressbook.h ../include/net.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/buf.h ../include/char_data.h ../include/item.h \ + ../include/char.h ../include/char_data.h ../include/util.h \ + ../include/handletime.h ../include/item.h ../include/anim_tbl.h \ + ../include/configfile.h +npccreate.o: npccreate.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/common.h \ + ../include/npccreate.h ../include/util.h ../include/common.h \ + ../include/npctemplate.h ../include/char_base.h ../include/version.h \ + ../include/skill.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/util.h ../include/buf.h ../include/readmap.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/char_data.h ../include/handletime.h ../include/configfile.h +npcutil.o: npcutil.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/common.h \ + ../include/char.h ../include/common.h ../include/char_base.h \ + ../include/version.h ../include/skill.h ../include/util.h \ + ../include/title.h ../include/addressbook.h ../include/net.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/char_base.h ../include/configfile.h ../include/object.h \ + ../include/item.h ../include/map_deal.h ../include/npcutil.h \ + ../include/npc_door.h ../include/readmap.h ../include/npccreate.h \ + ../include/enemy.h ../include/family.h ../include/saacproto_cli.h \ + ../include/saacproto_util.h +npc_warp.o: npc_warp.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/object.h \ + ../include/common.h ../include/char_base.h ../include/version.h \ + ../include/skill.h ../include/util.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char.h ../include/char_base.h ../include/char_data.h \ + ../include/item.h ../include/char.h ../include/map_deal.h \ + ../include/readmap.h ../include/npccreate.h ../include/npcutil.h \ + ../include/handletime.h ../include/npc_eventaction.h +npc_townpeople.o: npc_townpeople.c ../include/version.h \ + ../include/sasql.h /usr/include/stdio.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/bits/wordsize.h \ + /usr/include/gnu/stubs.h /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/object.h \ + ../include/common.h ../include/char_base.h ../include/version.h \ + ../include/skill.h ../include/util.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char.h ../include/char_base.h ../include/char_data.h \ + ../include/item.h ../include/char.h ../include/util.h \ + ../include/handletime.h ../include/anim_tbl.h ../include/npc_door.h \ + ../include/lssproto_serv.h ../include/lssproto_util.h \ + ../include/npcutil.h +npc_msg.o: npc_msg.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/char.h \ + ../include/common.h ../include/char_base.h ../include/version.h \ + ../include/skill.h ../include/util.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/char_base.h ../include/npcutil.h +npc_healer.o: npc_healer.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h /usr/include/ctype.h \ + ../include/object.h ../include/common.h ../include/char_base.h \ + ../include/version.h ../include/skill.h ../include/util.h \ + ../include/title.h ../include/addressbook.h ../include/net.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char.h ../include/char_base.h ../include/char_data.h \ + ../include/item.h ../include/char.h ../include/util.h \ + ../include/npcutil.h ../include/item.h ../include/readmap.h +npc_oldman.o: npc_oldman.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/object.h \ + ../include/common.h ../include/char_base.h ../include/version.h \ + ../include/skill.h ../include/util.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char.h ../include/char_base.h ../include/char_data.h \ + ../include/item.h ../include/char.h ../include/util.h \ + ../include/npcutil.h ../include/npc_oldman.h ../include/title.h \ + ../include/char_data.h ../include/readmap.h +npc_storyteller.o: npc_storyteller.c ../include/version.h \ + ../include/sasql.h /usr/include/stdio.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/bits/wordsize.h \ + /usr/include/gnu/stubs.h /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/char.h \ + ../include/common.h ../include/char_base.h ../include/version.h \ + ../include/skill.h ../include/util.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h +npc_dengon.o: npc_dengon.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/char.h \ + ../include/common.h ../include/char_base.h ../include/version.h \ + ../include/skill.h ../include/util.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/object.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h ../include/npcutil.h ../include/handletime.h +npc_doorman.o: npc_doorman.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/object.h \ + ../include/common.h ../include/char_base.h ../include/version.h \ + ../include/skill.h ../include/util.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char.h ../include/char_base.h ../include/char_data.h \ + ../include/item.h ../include/char.h ../include/item.h ../include/util.h \ + ../include/handletime.h ../include/npc_doorman.h ../include/npc_door.h \ + ../include/npcutil.h ../include/configfile.h +npc_npcenemy.o: npc_npcenemy.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/char.h \ + ../include/common.h ../include/char_base.h ../include/version.h \ + ../include/skill.h ../include/util.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/object.h ../include/char_base.h ../include/npcutil.h \ + ../include/npc_npcenemy.h ../include/battle.h ../include/enemy.h \ + ../include/readmap.h ../include/encount.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h ../include/configfile.h \ + ../include/anim_tbl.h ../include/handletime.h \ + ../include/npc_eventaction.h +npc_itemchange.o: npc_itemchange.c ../include/version.h \ + ../include/sasql.h /usr/include/stdio.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/bits/wordsize.h \ + /usr/include/gnu/stubs.h /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/char.h \ + ../include/common.h ../include/char_base.h ../include/version.h \ + ../include/skill.h ../include/util.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/object.h ../include/char_base.h ../include/npcutil.h \ + ../include/lssproto_serv.h ../include/lssproto_util.h \ + ../include/saacproto_cli.h ../include/saacproto_util.h \ + ../include/readmap.h ../include/battle.h ../include/log.h \ + ../include/enemy.h ../include/handletime.h ../include/npc_eventaction.h \ + ../include/npc_itemchange.h +npc_itemup.o: npc_itemup.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/char.h \ + ../include/common.h ../include/char_base.h ../include/version.h \ + ../include/skill.h ../include/util.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/object.h ../include/char_base.h ../include/npcutil.h \ + ../include/lssproto_serv.h ../include/lssproto_util.h \ + ../include/saacproto_cli.h ../include/saacproto_util.h \ + ../include/readmap.h ../include/battle.h ../include/log.h \ + ../include/enemy.h ../include/handletime.h ../include/npc_eventaction.h \ + ../include/npc_itemup.h +npc_action.o: npc_action.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/char.h \ + ../include/common.h ../include/char_base.h ../include/version.h \ + ../include/skill.h ../include/util.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/object.h ../include/char_base.h ../include/npcutil.h \ + ../include/npc_action.h +npc_windowman.o: npc_windowman.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/char.h \ + ../include/common.h ../include/char_base.h ../include/version.h \ + ../include/skill.h ../include/util.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/object.h ../include/char_base.h ../include/npcutil.h \ + ../include/configfile.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h ../include/npc_windowman.h +npc_savepoint.o: npc_savepoint.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/object.h \ + ../include/common.h ../include/char_base.h ../include/version.h \ + ../include/skill.h ../include/util.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char.h ../include/char_base.h ../include/char_data.h \ + ../include/item.h ../include/char.h ../include/util.h \ + ../include/npcutil.h ../include/npc_oldman.h ../include/title.h \ + ../include/char_data.h ../include/readmap.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h ../include/log.h +npc_windowhealer.o: npc_windowhealer.c ../include/version.h \ + ../include/sasql.h /usr/include/stdio.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/bits/wordsize.h \ + /usr/include/gnu/stubs.h /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/char.h \ + ../include/common.h ../include/char_base.h ../include/version.h \ + ../include/skill.h ../include/util.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/object.h ../include/char_base.h ../include/npcutil.h \ + ../include/lssproto_serv.h ../include/lssproto_util.h \ + ../include/npc_windowhealer.h +npc_itemshop.o: npc_itemshop.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/char.h \ + ../include/common.h ../include/char_base.h ../include/version.h \ + ../include/skill.h ../include/util.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/object.h ../include/char_base.h ../include/npcutil.h \ + ../include/lssproto_serv.h ../include/lssproto_util.h \ + ../include/pet_skill.h ../include/npc_eventaction.h \ + ../include/readmap.h ../include/log.h ../include/family.h +npc_sysinfo.o: npc_sysinfo.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/char.h \ + ../include/common.h ../include/char_base.h ../include/version.h \ + ../include/skill.h ../include/util.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/char_event.h ../include/object.h ../include/handletime.h \ + ../include/magic.h ../include/npcutil.h ../include/char_data.h \ + ../include/chatmagic.h ../include/net.h ../include/configfile.h \ + ../include/npcgen.h +npc_duelranking.o: npc_duelranking.c ../include/version.h \ + ../include/sasql.h /usr/include/stdio.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/bits/wordsize.h \ + /usr/include/gnu/stubs.h /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/char.h \ + ../include/common.h ../include/char_base.h ../include/version.h \ + ../include/skill.h ../include/util.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/object.h ../include/char_base.h ../include/npcutil.h \ + ../include/net.h ../include/lssproto_serv.h ../include/lssproto_util.h \ + ../include/saacproto_cli.h ../include/saacproto_util.h \ + ../include/npc_duelranking.h ../include/handletime.h +npc_petskillshop.o: npc_petskillshop.c ../include/version.h \ + ../include/sasql.h /usr/include/stdio.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/bits/wordsize.h \ + /usr/include/gnu/stubs.h /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/char.h \ + ../include/common.h ../include/char_base.h ../include/version.h \ + ../include/skill.h ../include/util.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/object.h ../include/char_base.h ../include/npcutil.h \ + ../include/lssproto_serv.h ../include/lssproto_util.h \ + ../include/pet_skill.h ../include/readmap.h ../include/battle.h \ + ../include/mylua/function.h +npc_petshop.o: npc_petshop.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/char.h \ + ../include/common.h ../include/char_base.h ../include/version.h \ + ../include/skill.h ../include/util.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/object.h ../include/char_base.h ../include/npcutil.h \ + ../include/lssproto_serv.h ../include/lssproto_util.h \ + ../include/pet_skill.h ../include/readmap.h ../include/battle.h \ + ../include/log.h +npc_signboard.o: npc_signboard.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/char.h \ + ../include/common.h ../include/char_base.h ../include/version.h \ + ../include/skill.h ../include/util.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/object.h ../include/char_base.h ../include/npcutil.h \ + ../include/lssproto_serv.h ../include/lssproto_util.h \ + ../include/readmap.h ../include/family.h +npc_warpman.o: npc_warpman.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/char.h \ + ../include/common.h ../include/char_base.h ../include/version.h \ + ../include/skill.h ../include/util.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/object.h ../include/char_base.h ../include/npcutil.h \ + ../include/lssproto_serv.h ../include/lssproto_util.h \ + ../include/saacproto_cli.h ../include/saacproto_util.h \ + ../include/npc_warpman.h ../include/map_deal.h ../include/readmap.h \ + ../include/battle.h ../include/npc_exchangeman.h ../include/log.h \ + ../include/enemy.h ../include/handletime.h ../include/npc_eventaction.h +npc_exchangeman.o: npc_exchangeman.c ../include/version.h \ + ../include/sasql.h /usr/include/stdio.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/bits/wordsize.h \ + /usr/include/gnu/stubs.h /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/char.h \ + ../include/common.h ../include/char_base.h ../include/version.h \ + ../include/skill.h ../include/util.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/object.h ../include/net.h ../include/char_base.h \ + ../include/npcutil.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h ../include/npc_exchangeman.h \ + ../include/npc_eventaction.h ../include/log.h ../include/battle.h \ + ../include/handletime.h ../include/enemy.h ../include/npc_warp.h +npc_timeman.o: npc_timeman.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/object.h \ + ../include/common.h ../include/char_base.h ../include/version.h \ + ../include/skill.h ../include/util.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char.h ../include/char_base.h ../include/char_data.h \ + ../include/item.h ../include/char.h ../include/util.h \ + ../include/npcutil.h ../include/npc_oldman.h ../include/title.h \ + ../include/char_data.h ../include/readmap.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h ../include/log.h ../include/handletime.h +npc_bodylan.o: npc_bodylan.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/char.h \ + ../include/common.h ../include/char_base.h ../include/version.h \ + ../include/skill.h ../include/util.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/object.h ../include/char_base.h ../include/npcutil.h \ + ../include/lssproto_serv.h ../include/lssproto_util.h \ + ../include/npc_windowhealer.h +npc_mic.o: npc_mic.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/common.h \ + ../include/char_base.h ../include/version.h ../include/skill.h \ + ../include/common.h ../include/util.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char.h ../include/char_base.h ../include/char_data.h \ + ../include/item.h ../include/char.h ../include/npcutil.h \ + ../include/npc_mic.h ../include/saacproto_cli.h \ + ../include/saacproto_util.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h ../include/battle.h +npc_luckyman.o: npc_luckyman.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/char.h \ + ../include/common.h ../include/char_base.h ../include/version.h \ + ../include/skill.h ../include/util.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/object.h ../include/char_base.h ../include/npcutil.h \ + ../include/lssproto_serv.h ../include/lssproto_util.h \ + ../include/npc_luckyman.h +npc_bus.o: npc_bus.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/char.h \ + ../include/common.h ../include/char_base.h ../include/version.h \ + ../include/skill.h ../include/util.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/object.h ../include/char_base.h ../include/npcutil.h \ + ../include/lssproto_serv.h ../include/lssproto_util.h \ + ../include/npc_bus.h ../include/handletime.h +npc_charm.o: npc_charm.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/char.h \ + ../include/common.h ../include/char_base.h ../include/version.h \ + ../include/skill.h ../include/util.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/object.h ../include/char_base.h ../include/npcutil.h \ + ../include/lssproto_serv.h ../include/lssproto_util.h \ + ../include/npc_charm.h +npc_quiz.o: npc_quiz.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/common.h \ + ../include/char_base.h ../include/version.h ../include/skill.h \ + ../include/common.h ../include/util.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/npc_quiz.h ../include/npcutil.h ../include/char.h \ + ../include/char_base.h ../include/char_data.h ../include/item.h \ + ../include/char.h ../include/lssproto_serv.h ../include/lssproto_util.h \ + ../include/buf.h ../include/function.h ../include/readmap.h \ + ../include/object.h ../include/log.h +npc_poolitemshop.o: npc_poolitemshop.c ../include/version.h \ + ../include/sasql.h /usr/include/stdio.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/bits/wordsize.h \ + /usr/include/gnu/stubs.h /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/char.h \ + ../include/common.h ../include/char_base.h ../include/version.h \ + ../include/skill.h ../include/util.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/lssproto_serv.h ../include/lssproto_util.h \ + ../include/npcutil.h ../include/npc_poolitemshop.h ../include/log.h \ + ../include/handletime.h +npc_checkman.o: npc_checkman.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/char.h \ + ../include/common.h ../include/char_base.h ../include/version.h \ + ../include/skill.h ../include/util.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/object.h ../include/char_base.h ../include/npcutil.h \ + ../include/lssproto_serv.h ../include/lssproto_util.h +npc_janken.o: npc_janken.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/common.h \ + ../include/char_base.h ../include/version.h ../include/skill.h \ + ../include/common.h ../include/util.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/npc_janken.h ../include/npcutil.h ../include/char.h \ + ../include/char_base.h ../include/char_data.h ../include/item.h \ + ../include/char.h ../include/lssproto_serv.h ../include/lssproto_util.h \ + ../include/buf.h ../include/function.h ../include/readmap.h \ + ../include/object.h ../include/log.h +npc_transmigration.o: npc_transmigration.c ../include/version.h \ + ../include/sasql.h /usr/include/stdio.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/bits/wordsize.h \ + /usr/include/gnu/stubs.h /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h /usr/include/math.h \ + /usr/include/bits/huge_val.h /usr/include/bits/mathdef.h \ + /usr/include/bits/mathcalls.h ../include/char.h ../include/common.h \ + ../include/char_base.h ../include/version.h ../include/skill.h \ + ../include/util.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/object.h ../include/char_base.h ../include/npcutil.h \ + ../include/lssproto_serv.h ../include/lssproto_util.h \ + ../include/enemy.h ../include/log.h ../include/battle.h \ + ../include/readmap.h ../include/npc_transmigration.h \ + ../include/configfile.h ../include/npc_pettransman.h +npc_makepair.o: npc_makepair.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/char.h \ + ../include/common.h ../include/char_base.h ../include/version.h \ + ../include/skill.h ../include/util.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/object.h ../include/char_base.h ../include/npcutil.h \ + ../include/npc_transerman.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h ../include/saacproto_cli.h \ + ../include/saacproto_util.h ../include/readmap.h ../include/battle.h \ + ../include/log.h ../include/enemy.h ../include/handletime.h \ + ../include/npc_makepair.h ../include/npc_eventaction.h +npc_familyman.o: npc_familyman.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/char.h \ + ../include/common.h ../include/char_base.h ../include/version.h \ + ../include/skill.h ../include/util.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/object.h ../include/char_base.h ../include/npcutil.h \ + ../include/configfile.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h ../include/saacproto_cli.h \ + ../include/saacproto_util.h ../include/npc_familyman.h \ + ../include/family.h +npc_fmdengon.o: npc_fmdengon.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/char.h \ + ../include/common.h ../include/char_base.h ../include/version.h \ + ../include/skill.h ../include/util.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/object.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h ../include/saacproto_cli.h \ + ../include/saacproto_util.h ../include/npcutil.h \ + ../include/handletime.h ../include/npc_fmdengon.h ../include/family.h \ + ../include/npc_scheduleman.h +npc_fmwarpman.o: npc_fmwarpman.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/char.h \ + ../include/common.h ../include/char_base.h ../include/version.h \ + ../include/skill.h ../include/util.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/object.h ../include/char_base.h ../include/npcutil.h \ + ../include/lssproto_serv.h ../include/lssproto_util.h \ + ../include/saacproto_cli.h ../include/saacproto_util.h \ + ../include/npc_fmwarpman.h ../include/npc_scheduleman.h \ + ../include/readmap.h ../include/log.h ../include/battle.h \ + ../include/handletime.h ../include/family.h ../include/configfile.h +npc_fmhealer.o: npc_fmhealer.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h /usr/include/ctype.h \ + ../include/object.h ../include/common.h ../include/char_base.h \ + ../include/version.h ../include/skill.h ../include/util.h \ + ../include/title.h ../include/addressbook.h ../include/net.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char.h ../include/char_base.h ../include/char_data.h \ + ../include/item.h ../include/char.h ../include/util.h \ + ../include/npcutil.h ../include/item.h ../include/readmap.h +npc_bankman.o: npc_bankman.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/char.h \ + ../include/common.h ../include/char_base.h ../include/version.h \ + ../include/skill.h ../include/util.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/object.h ../include/char_base.h ../include/npcutil.h \ + ../include/configfile.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h ../include/saacproto_cli.h \ + ../include/saacproto_util.h ../include/npc_bankman.h \ + ../include/family.h +npc_fmpkman.o: npc_fmpkman.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/char.h \ + ../include/common.h ../include/char_base.h ../include/version.h \ + ../include/skill.h ../include/util.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/object.h ../include/char_base.h ../include/npcutil.h \ + ../include/lssproto_serv.h ../include/lssproto_util.h \ + ../include/npc_fmpkman.h ../include/npc_scheduleman.h \ + ../include/npc_fmwarpman.h ../include/family.h ../include/readmap.h \ + ../include/battle.h ../include/log.h +npc_airplane.o: npc_airplane.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/char.h \ + ../include/common.h ../include/char_base.h ../include/version.h \ + ../include/skill.h ../include/util.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/object.h ../include/char_base.h ../include/npcutil.h \ + ../include/lssproto_serv.h ../include/lssproto_util.h \ + ../include/npc_airplane.h ../include/handletime.h +npc_scheduleman.o: npc_scheduleman.c ../include/version.h \ + ../include/sasql.h /usr/include/stdio.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/bits/wordsize.h \ + /usr/include/gnu/stubs.h /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/char.h \ + ../include/common.h ../include/char_base.h ../include/version.h \ + ../include/skill.h ../include/util.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/object.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h ../include/npcutil.h ../include/handletime.h \ + ../include/npc_scheduleman.h ../include/family.h +npc_fmpkcallman.o: npc_fmpkcallman.c ../include/version.h \ + ../include/sasql.h /usr/include/stdio.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/bits/wordsize.h \ + /usr/include/gnu/stubs.h /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/char.h \ + ../include/common.h ../include/char_base.h ../include/version.h \ + ../include/skill.h ../include/util.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/object.h ../include/char_base.h ../include/npcutil.h \ + ../include/lssproto_serv.h ../include/lssproto_util.h \ + ../include/npc_fmpkcallman.h ../include/family.h ../include/readmap.h \ + ../include/battle.h ../include/log.h ../include/npc_scheduleman.h \ + ../include/handletime.h +npc_manorsman.o: npc_manorsman.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/char.h \ + ../include/common.h ../include/char_base.h ../include/version.h \ + ../include/skill.h ../include/util.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/object.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h ../include/npcutil.h ../include/handletime.h \ + ../include/npc_scheduleman.h ../include/family.h \ + ../include/npc_manorsman.h ../include/saacproto_cli.h \ + ../include/saacproto_util.h ../include/net.h ../include/configfile.h \ + ../include/log.h +npc_riderman.o: npc_riderman.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/char.h \ + ../include/common.h ../include/char_base.h ../include/version.h \ + ../include/skill.h ../include/util.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/object.h ../include/char_base.h ../include/npcutil.h \ + ../include/configfile.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h ../include/saacproto_cli.h \ + ../include/saacproto_util.h ../include/npc_riderman.h \ + ../include/family.h ../include/log.h +npc_fmletter.o: npc_fmletter.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/char.h \ + ../include/common.h ../include/char_base.h ../include/version.h \ + ../include/skill.h ../include/util.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/object.h ../include/char_base.h ../include/npcutil.h \ + ../include/configfile.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h ../include/saacproto_cli.h \ + ../include/saacproto_util.h ../include/npc_fmletter.h \ + ../include/family.h ../include/log.h +npc_petmaker.o: npc_petmaker.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h /usr/include/ctype.h \ + ../include/object.h ../include/common.h ../include/char_base.h \ + ../include/version.h ../include/skill.h ../include/util.h \ + ../include/title.h ../include/addressbook.h ../include/net.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char.h ../include/char_base.h ../include/char_data.h \ + ../include/item.h ../include/char.h ../include/util.h \ + ../include/npcutil.h ../include/item.h ../include/readmap.h \ + ../include/enemy.h ../include/chatmagic.h ../include/log.h +npc_gamblemaster.o: npc_gamblemaster.c ../include/version.h \ + ../include/sasql.h /usr/include/stdio.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/bits/wordsize.h \ + /usr/include/gnu/stubs.h /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/char.h \ + ../include/common.h ../include/char_base.h ../include/version.h \ + ../include/skill.h ../include/util.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/object.h ../include/char_base.h ../include/npcutil.h \ + ../include/lssproto_serv.h ../include/lssproto_util.h \ + ../include/handletime.h ../include/readmap.h ../include/log.h \ + ../include/npc_eventaction.h ../include/npc_gamblemaster.h +npc_gambleroulette.o: npc_gambleroulette.c ../include/version.h \ + ../include/sasql.h /usr/include/stdio.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/bits/wordsize.h \ + /usr/include/gnu/stubs.h /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/char.h \ + ../include/common.h ../include/char_base.h ../include/version.h \ + ../include/skill.h ../include/util.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/object.h ../include/char_base.h ../include/npcutil.h \ + ../include/readmap.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h ../include/handletime.h \ + ../include/npc_gambleroulette.h +npc_petfusion.o: npc_petfusion.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/char.h \ + ../include/common.h ../include/char_base.h ../include/version.h \ + ../include/skill.h ../include/util.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/object.h ../include/char_base.h ../include/char_data.h \ + ../include/npcutil.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h ../include/saacproto_cli.h \ + ../include/saacproto_util.h ../include/readmap.h ../include/battle.h \ + ../include/log.h ../include/enemy.h ../include/handletime.h \ + ../include/npc_eventaction.h ../include/npc_petfusion.h \ + ../include/pet.h ../include/chatmagic.h +npc_stoneserviceman.o: npc_stoneserviceman.c +npc_newnpcman.o: npc_newnpcman.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h /usr/include/math.h \ + /usr/include/bits/huge_val.h /usr/include/bits/mathdef.h \ + /usr/include/bits/mathcalls.h ../include/char.h ../include/common.h \ + ../include/char_base.h ../include/version.h ../include/skill.h \ + ../include/util.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/object.h ../include/char_base.h ../include/npcutil.h \ + ../include/lssproto_serv.h ../include/lssproto_util.h \ + ../include/enemy.h ../include/log.h ../include/battle.h \ + ../include/readmap.h ../include/handletime.h \ + ../include/npc_eventaction.h ../include/npc_newnpcman.h \ + ../include/pet.h +npc_gamblebank.o: npc_gamblebank.c ../include/version.h \ + ../include/sasql.h /usr/include/stdio.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/bits/wordsize.h \ + /usr/include/gnu/stubs.h /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h /usr/include/math.h \ + /usr/include/bits/huge_val.h /usr/include/bits/mathdef.h \ + /usr/include/bits/mathcalls.h ../include/char.h ../include/common.h \ + ../include/char_base.h ../include/version.h ../include/skill.h \ + ../include/util.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/object.h ../include/char_base.h ../include/npcutil.h \ + ../include/lssproto_serv.h ../include/lssproto_util.h \ + ../include/enemy.h ../include/log.h ../include/battle.h \ + ../include/readmap.h ../include/handletime.h ../include/configfile.h \ + ../include/npc_gamblebank.h +npc_petracemaster.o: npc_petracemaster.c ../include/version.h \ + ../include/sasql.h /usr/include/stdio.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/bits/wordsize.h \ + /usr/include/gnu/stubs.h /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/char.h \ + ../include/common.h ../include/char_base.h ../include/version.h \ + ../include/skill.h ../include/util.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/object.h ../include/char_base.h ../include/npcutil.h \ + ../include/lssproto_serv.h ../include/lssproto_util.h \ + ../include/handletime.h ../include/npc_petracemaster.h +npc_petracepet.o: npc_petracepet.c ../include/version.h \ + ../include/sasql.h /usr/include/stdio.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/bits/wordsize.h \ + /usr/include/gnu/stubs.h /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/char.h \ + ../include/common.h ../include/char_base.h ../include/version.h \ + ../include/skill.h ../include/util.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/object.h ../include/char_base.h ../include/npcutil.h \ + ../include/lssproto_serv.h ../include/lssproto_util.h \ + ../include/handletime.h ../include/npc_petracepet.h +npc_bigsmallmaster.o: npc_bigsmallmaster.c +npc_bigsmallpet.o: npc_bigsmallpet.c +npc_auctioneer.o: npc_auctioneer.c +npc_freepetskillshop.o: npc_freepetskillshop.c ../include/version.h \ + ../include/sasql.h /usr/include/stdio.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/bits/wordsize.h \ + /usr/include/gnu/stubs.h /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/char.h \ + ../include/common.h ../include/char_base.h ../include/version.h \ + ../include/skill.h ../include/util.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/object.h ../include/char_base.h ../include/npcutil.h \ + ../include/lssproto_serv.h ../include/lssproto_util.h \ + ../include/pet_skill.h ../include/readmap.h ../include/battle.h \ + ../include/configfile.h ../include/util.h ../include/npc_eventaction.h \ + ../include/npc_freepetskillshop.h ../include/mylua/function.h +npc_eventaction.o: npc_eventaction.c ../include/version.h \ + ../include/sasql.h /usr/include/stdio.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/bits/wordsize.h \ + /usr/include/gnu/stubs.h /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/char.h \ + ../include/common.h ../include/char_base.h ../include/version.h \ + ../include/skill.h ../include/util.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/object.h ../include/char_base.h ../include/npcutil.h \ + ../include/lssproto_serv.h ../include/lssproto_util.h \ + ../include/saacproto_cli.h ../include/saacproto_util.h \ + ../include/map_deal.h ../include/readmap.h ../include/battle.h \ + ../include/log.h ../include/enemy.h ../include/handletime.h \ + ../include/npc_eventaction.h ../include/family.h \ + ../include/profession_skill.h ../include/chatmagic.h +npc_vipshop.o: npc_vipshop.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/char.h \ + ../include/common.h ../include/char_base.h ../include/version.h \ + ../include/skill.h ../include/util.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/object.h ../include/char_base.h ../include/npcutil.h \ + ../include/npc_vipshop.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h ../include/saacproto_cli.h \ + ../include/saacproto_util.h ../include/readmap.h ../include/battle.h \ + ../include/log.h ../include/enemy.h ../include/handletime.h \ + ../include/npc_eventaction.h +npc_autopk.o: npc_autopk.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/char.h \ + ../include/common.h ../include/char_base.h ../include/version.h \ + ../include/skill.h ../include/util.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/object.h ../include/char_base.h ../include/npcutil.h \ + ../include/npc_autopk.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h ../include/saacproto_cli.h \ + ../include/saacproto_util.h ../include/readmap.h ../include/battle.h \ + ../include/log.h ../include/enemy.h ../include/handletime.h \ + ../include/npc_eventaction.h ../include/npc_healer.h \ + ../include/configfile.h +npc_fmlookwar.o: npc_fmlookwar.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/char.h \ + ../include/common.h ../include/char_base.h ../include/version.h \ + ../include/skill.h ../include/util.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/object.h ../include/char_base.h ../include/npcutil.h \ + ../include/npc_fmlookwar.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h ../include/saacproto_cli.h \ + ../include/saacproto_util.h ../include/readmap.h ../include/battle.h \ + ../include/log.h ../include/enemy.h ../include/handletime.h \ + ../include/npc_eventaction.h +npc_fmlookwar1.o: npc_fmlookwar1.c ../include/version.h \ + ../include/sasql.h /usr/include/stdio.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/bits/wordsize.h \ + /usr/include/gnu/stubs.h /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/char.h \ + ../include/common.h ../include/char_base.h ../include/version.h \ + ../include/skill.h ../include/util.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/object.h ../include/char_base.h ../include/npcutil.h \ + ../include/npc_fmlookwar1.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h ../include/saacproto_cli.h \ + ../include/saacproto_util.h ../include/readmap.h ../include/battle.h \ + ../include/log.h ../include/enemy.h ../include/handletime.h \ + ../include/npc_eventaction.h +npc_mtradenpcman.o: npc_mtradenpcman.c +npc_blackmarket.o: npc_blackmarket.c +npc_transerman.o: npc_transerman.c ../include/version.h \ + ../include/sasql.h /usr/include/stdio.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/bits/wordsize.h \ + /usr/include/gnu/stubs.h /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/char.h \ + ../include/common.h ../include/char_base.h ../include/version.h \ + ../include/skill.h ../include/util.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/object.h ../include/char_base.h ../include/npcutil.h \ + ../include/npc_transerman.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h ../include/saacproto_cli.h \ + ../include/saacproto_util.h ../include/readmap.h ../include/battle.h \ + ../include/log.h ../include/enemy.h ../include/handletime.h \ + ../include/npc_eventaction.h +npc_pauctionman.o: npc_pauctionman.c +npc_alldoman.o: npc_alldoman.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h /usr/include/ctype.h \ + ../include/object.h ../include/common.h ../include/char_base.h \ + ../include/version.h ../include/skill.h ../include/util.h \ + ../include/title.h ../include/addressbook.h ../include/net.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char.h ../include/char_base.h ../include/char_data.h \ + ../include/item.h ../include/char.h ../include/util.h \ + ../include/npcutil.h ../include/item.h ../include/readmap.h \ + ../include/enemy.h ../include/chatmagic.h ../include/log.h \ + ../include/npc_itemchange.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h ../include/saacproto_cli.h \ + ../include/saacproto_util.h ../include/npc_eventaction.h \ + ../include/npc_charm.h ../include/npc_alldoman.h +npc_sellsthman.o: npc_sellsthman.c +npc_newvipshop.o: npc_newvipshop.c ../include/version.h \ + ../include/sasql.h /usr/include/stdio.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/bits/wordsize.h \ + /usr/include/gnu/stubs.h /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/char.h \ + ../include/common.h ../include/char_base.h ../include/version.h \ + ../include/skill.h ../include/util.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/object.h ../include/char_base.h ../include/npcutil.h \ + ../include/npc_newvipshop.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h ../include/saacproto_cli.h \ + ../include/saacproto_util.h ../include/readmap.h ../include/battle.h \ + ../include/log.h ../include/enemy.h ../include/handletime.h \ + ../include/npc_eventaction.h +npc_vigorshop.o: npc_vigorshop.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/char.h \ + ../include/common.h ../include/char_base.h ../include/version.h \ + ../include/skill.h ../include/util.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/object.h ../include/char_base.h ../include/npcutil.h \ + ../include/lssproto_serv.h ../include/lssproto_util.h \ + ../include/pet_skill.h ../include/npc_eventaction.h \ + ../include/readmap.h ../include/log.h ../include/family.h +npc_stushop.o: npc_stushop.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/char.h \ + ../include/common.h ../include/char_base.h ../include/version.h \ + ../include/skill.h ../include/util.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/object.h ../include/char_base.h ../include/npcutil.h \ + ../include/npc_stushop.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h ../include/saacproto_cli.h \ + ../include/saacproto_util.h ../include/readmap.h ../include/battle.h \ + ../include/log.h ../include/enemy.h ../include/handletime.h \ + ../include/npc_eventaction.h +npc_rmbshop.o: npc_rmbshop.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/char.h \ + ../include/common.h ../include/char_base.h ../include/version.h \ + ../include/skill.h ../include/util.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/object.h ../include/char_base.h ../include/npcutil.h \ + ../include/npc_rmbshop.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h ../include/saacproto_cli.h \ + ../include/saacproto_util.h ../include/readmap.h ../include/battle.h \ + ../include/log.h ../include/enemy.h ../include/handletime.h \ + ../include/npc_eventaction.h +npc_itemvippointshop.o: npc_itemvippointshop.c ../include/version.h \ + ../include/sasql.h /usr/include/stdio.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/bits/wordsize.h \ + /usr/include/gnu/stubs.h /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/char.h \ + ../include/common.h ../include/char_base.h ../include/version.h \ + ../include/skill.h ../include/util.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/object.h ../include/char_base.h ../include/npcutil.h \ + ../include/lssproto_serv.h ../include/lssproto_util.h \ + ../include/pet_skill.h ../include/npc_eventaction.h \ + ../include/readmap.h ../include/log.h ../include/family.h +npc_welfare.o: npc_welfare.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/char.h \ + ../include/common.h ../include/char_base.h ../include/version.h \ + ../include/skill.h ../include/util.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/object.h ../include/char_base.h ../include/npcutil.h \ + ../include/lssproto_serv.h ../include/lssproto_util.h \ + ../include/pet_skill.h ../include/readmap.h ../include/battle.h \ + ../include/profession_skill.h ../include/chatmagic.h \ + ../include/npc_welfare.h ../include/npc_exchangeman.h +npc_verywelfare.o: npc_verywelfare.c +npc_welfare2.o: npc_welfare2.c +npc_petskilldelshop.o: npc_petskilldelshop.c ../include/version.h \ + ../include/sasql.h /usr/include/stdio.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/bits/wordsize.h \ + /usr/include/gnu/stubs.h /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/char.h \ + ../include/common.h ../include/char_base.h ../include/version.h \ + ../include/skill.h ../include/util.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/object.h ../include/char_base.h ../include/npcutil.h \ + ../include/lssproto_serv.h ../include/lssproto_util.h \ + ../include/pet_skill.h ../include/readmap.h ../include/battle.h \ + ../include/mylua/function.h +npc_fmrank.o: npc_fmrank.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/char.h \ + ../include/common.h ../include/char_base.h ../include/version.h \ + ../include/skill.h ../include/util.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/object.h ../include/char_base.h ../include/npcutil.h \ + ../include/npc_fmrank.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h ../include/saacproto_cli.h \ + ../include/saacproto_util.h ../include/readmap.h ../include/battle.h \ + ../include/log.h ../include/enemy.h ../include/handletime.h \ + ../include/npc_eventaction.h ../include/npc_healer.h \ + ../include/configfile.h ../include/sasql.h diff --git a/npc/makefile.bak b/npc/makefile.bak new file mode 100644 index 0000000..369a1ad --- /dev/null +++ b/npc/makefile.bak @@ -0,0 +1,3765 @@ +export CC=gcc +export RM=rm -f +export AR=ar cr +export MV=mv +export RANLIB=ranlib +export SED=sed + + +export SHELL=/bin/sh + +INCFLAGS=-I. -I../include + +CFLAGS=-O3 -w $(INCFLAGS) +#Pentium 4 (Intel) +#CFLAGS=-march=pentium4 -O3 -pipe -fomit-frame-pointer $(INCFLAGS) +#Athlon XP (AMD) +#CFLAGS="-march=athlon-xp -O3 -pipe -fomit-frame-pointer" $(INCFLAGS) +#Athlon64£º +#CFLAGS="-O2 -march=athlon64 -ftracer -fprefetch-loop-arrays -pipe" $(INCFLAGS) + +PROG=libnpc.a + +SRC=readnpc.c npcgen.c npctemplate.c npccreate.c npcutil.c \ +npc_warp.c npc_townpeople.c \ +npc_msg.c npc_healer.c npc_oldman.c \ +npc_storyteller.c npc_dengon.c npc_doorman.c \ +npc_npcenemy.c npc_itemchange.c npc_itemup.c\ +npc_action.c npc_windowman.c npc_savepoint.c \ +npc_windowhealer.c npc_itemshop.c npc_sysinfo.c \ +npc_duelranking.c npc_petskillshop.c npc_petshop.c \ +npc_signboard.c npc_warpman.c npc_exchangeman.c \ +npc_timeman.c npc_bodylan.c npc_mic.c \ +npc_luckyman.c npc_bus.c npc_charm.c npc_quiz.c \ +npc_poolitemshop.c npc_checkman.c npc_janken.c \ +npc_transmigration.c npc_makepair.c \ +npc_familyman.c npc_fmdengon.c npc_fmwarpman.c \ +npc_fmhealer.c npc_bankman.c npc_fmpkman.c\ +npc_airplane.c npc_scheduleman.c npc_fmpkcallman.c\ +npc_manorsman.c npc_riderman.c npc_fmletter.c npc_petmaker.c \ +npc_gamblemaster.c npc_gambleroulette.c npc_petfusion.c\ +npc_stoneserviceman.c npc_newnpcman.c npc_gamblebank.c \ +npc_petracemaster.c npc_petracepet.c npc_bigsmallmaster.c \ +npc_bigsmallpet.c npc_auctioneer.c npc_freepetskillshop.c \ +npc_eventaction.c npc_vipshop.c npc_autopk.c npc_fmlookwar.c npc_fmlookwar1.c\ +npc_mtradenpcman.c npc_blackmarket.c npc_transerman.c npc_pauctionman.c npc_alldoman.c\ +npc_sellsthman.c npc_newvipshop.c npc_vigorshop.c npc_stushop.c npc_rmbshop.c npc_itemvippointshop.c\ +npc_welfare.c npc_verywelfare.c npc_welfare2.c npc_petskilldelshop.c npc_fmrank.c\ + +OBJ=$(SRC:.c=.o) + +ifeq (0,$(MAKELEVEL)) +CC=gcc +RM=rm -f +AR=ar cr +MV=mv +RANLIB=ranlib +SED=sed +SHELL=/bin/sh +endif + +all: $(PROG) + +$(PROG): $(OBJ) + $(RM) $(PROG) + $(AR) $(PROG) $(OBJ) + $(RANLIB) $(PROG) + +depend: + $(MV) makefile makefile.bak + $(SED) -ne '1,/^# DO NOT DELETE THIS LINE/p' makefile.bak>makefile + $(CC) $(INCFLAGS) -M $(SRC) >> makefile + +clean: + $(RM) $(PROG) + $(RM) $(OBJ) + $(RM) *~ + +distclean: + $(RM) $(PROG) + $(RM) $(OBJ) + $(RM) *~ + $(MV) makefile makefile.bak + $(SED) -ne '1,/^# DO NOT DELETE THIS LINE/p' makefile.bak>makefile + $(RM) makefile.bak + +# DO NOT DELETE THIS LINE +readnpc.o: readnpc.c /usr/include/stdio.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/bits/wordsize.h \ + /usr/include/gnu/stubs.h /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/string.h ../include/version.h ../include/sasql.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + ../include/correct_bug.h ../include/char.h ../include/common.h \ + ../include/char_base.h ../include/version.h ../include/skill.h \ + ../include/util.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/common.h ../include/npctemplate.h ../include/npccreate.h \ + ../include/battle.h ../include/configfile.h +npcgen.o: npcgen.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/common.h \ + ../include/npccreate.h ../include/util.h ../include/common.h \ + ../include/npctemplate.h ../include/char_base.h ../include/version.h \ + ../include/skill.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char.h ../include/char_data.h ../include/item.h \ + ../include/char.h ../include/char_data.h ../include/buf.h \ + ../include/object.h ../include/readmap.h ../include/item.h \ + ../include/handletime.h ../include/map_deal.h +npctemplate.o: npctemplate.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/common.h \ + ../include/npctemplate.h ../include/util.h ../include/common.h \ + ../include/char_base.h ../include/version.h ../include/skill.h \ + ../include/title.h ../include/addressbook.h ../include/net.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/buf.h ../include/char_data.h ../include/item.h \ + ../include/char.h ../include/char_data.h ../include/util.h \ + ../include/handletime.h ../include/item.h ../include/anim_tbl.h \ + ../include/configfile.h +npccreate.o: npccreate.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/common.h \ + ../include/npccreate.h ../include/util.h ../include/common.h \ + ../include/npctemplate.h ../include/char_base.h ../include/version.h \ + ../include/skill.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/util.h ../include/buf.h ../include/readmap.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/char_data.h ../include/handletime.h ../include/configfile.h +npcutil.o: npcutil.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/common.h \ + ../include/char.h ../include/common.h ../include/char_base.h \ + ../include/version.h ../include/skill.h ../include/util.h \ + ../include/title.h ../include/addressbook.h ../include/net.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/char_base.h ../include/configfile.h ../include/object.h \ + ../include/item.h ../include/map_deal.h ../include/npcutil.h \ + ../include/npc_door.h ../include/readmap.h ../include/npccreate.h \ + ../include/enemy.h ../include/family.h ../include/saacproto_cli.h \ + ../include/saacproto_util.h +npc_warp.o: npc_warp.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/object.h \ + ../include/common.h ../include/char_base.h ../include/version.h \ + ../include/skill.h ../include/util.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char.h ../include/char_base.h ../include/char_data.h \ + ../include/item.h ../include/char.h ../include/map_deal.h \ + ../include/readmap.h ../include/npccreate.h ../include/npcutil.h \ + ../include/handletime.h ../include/npc_eventaction.h +npc_townpeople.o: npc_townpeople.c ../include/version.h \ + ../include/sasql.h /usr/include/stdio.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/bits/wordsize.h \ + /usr/include/gnu/stubs.h /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/object.h \ + ../include/common.h ../include/char_base.h ../include/version.h \ + ../include/skill.h ../include/util.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char.h ../include/char_base.h ../include/char_data.h \ + ../include/item.h ../include/char.h ../include/util.h \ + ../include/handletime.h ../include/anim_tbl.h ../include/npc_door.h \ + ../include/lssproto_serv.h ../include/lssproto_util.h \ + ../include/npcutil.h +npc_msg.o: npc_msg.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/char.h \ + ../include/common.h ../include/char_base.h ../include/version.h \ + ../include/skill.h ../include/util.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/char_base.h ../include/npcutil.h +npc_healer.o: npc_healer.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h /usr/include/ctype.h \ + ../include/object.h ../include/common.h ../include/char_base.h \ + ../include/version.h ../include/skill.h ../include/util.h \ + ../include/title.h ../include/addressbook.h ../include/net.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char.h ../include/char_base.h ../include/char_data.h \ + ../include/item.h ../include/char.h ../include/util.h \ + ../include/npcutil.h ../include/item.h ../include/readmap.h +npc_oldman.o: npc_oldman.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/object.h \ + ../include/common.h ../include/char_base.h ../include/version.h \ + ../include/skill.h ../include/util.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char.h ../include/char_base.h ../include/char_data.h \ + ../include/item.h ../include/char.h ../include/util.h \ + ../include/npcutil.h ../include/npc_oldman.h ../include/title.h \ + ../include/char_data.h ../include/readmap.h +npc_storyteller.o: npc_storyteller.c ../include/version.h \ + ../include/sasql.h /usr/include/stdio.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/bits/wordsize.h \ + /usr/include/gnu/stubs.h /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/char.h \ + ../include/common.h ../include/char_base.h ../include/version.h \ + ../include/skill.h ../include/util.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h +npc_dengon.o: npc_dengon.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/char.h \ + ../include/common.h ../include/char_base.h ../include/version.h \ + ../include/skill.h ../include/util.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/object.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h ../include/npcutil.h ../include/handletime.h +npc_doorman.o: npc_doorman.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/object.h \ + ../include/common.h ../include/char_base.h ../include/version.h \ + ../include/skill.h ../include/util.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char.h ../include/char_base.h ../include/char_data.h \ + ../include/item.h ../include/char.h ../include/item.h ../include/util.h \ + ../include/handletime.h ../include/npc_doorman.h ../include/npc_door.h \ + ../include/npcutil.h ../include/configfile.h +npc_npcenemy.o: npc_npcenemy.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/char.h \ + ../include/common.h ../include/char_base.h ../include/version.h \ + ../include/skill.h ../include/util.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/object.h ../include/char_base.h ../include/npcutil.h \ + ../include/npc_npcenemy.h ../include/battle.h ../include/enemy.h \ + ../include/readmap.h ../include/encount.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h ../include/configfile.h \ + ../include/anim_tbl.h ../include/handletime.h \ + ../include/npc_eventaction.h +npc_itemchange.o: npc_itemchange.c ../include/version.h \ + ../include/sasql.h /usr/include/stdio.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/bits/wordsize.h \ + /usr/include/gnu/stubs.h /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/char.h \ + ../include/common.h ../include/char_base.h ../include/version.h \ + ../include/skill.h ../include/util.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/object.h ../include/char_base.h ../include/npcutil.h \ + ../include/lssproto_serv.h ../include/lssproto_util.h \ + ../include/saacproto_cli.h ../include/saacproto_util.h \ + ../include/readmap.h ../include/battle.h ../include/log.h \ + ../include/enemy.h ../include/handletime.h ../include/npc_eventaction.h \ + ../include/npc_itemchange.h +npc_itemup.o: npc_itemup.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/char.h \ + ../include/common.h ../include/char_base.h ../include/version.h \ + ../include/skill.h ../include/util.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/object.h ../include/char_base.h ../include/npcutil.h \ + ../include/lssproto_serv.h ../include/lssproto_util.h \ + ../include/saacproto_cli.h ../include/saacproto_util.h \ + ../include/readmap.h ../include/battle.h ../include/log.h \ + ../include/enemy.h ../include/handletime.h ../include/npc_eventaction.h \ + ../include/npc_itemup.h +npc_action.o: npc_action.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/char.h \ + ../include/common.h ../include/char_base.h ../include/version.h \ + ../include/skill.h ../include/util.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/object.h ../include/char_base.h ../include/npcutil.h \ + ../include/npc_action.h +npc_windowman.o: npc_windowman.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/char.h \ + ../include/common.h ../include/char_base.h ../include/version.h \ + ../include/skill.h ../include/util.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/object.h ../include/char_base.h ../include/npcutil.h \ + ../include/configfile.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h ../include/npc_windowman.h +npc_savepoint.o: npc_savepoint.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/object.h \ + ../include/common.h ../include/char_base.h ../include/version.h \ + ../include/skill.h ../include/util.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char.h ../include/char_base.h ../include/char_data.h \ + ../include/item.h ../include/char.h ../include/util.h \ + ../include/npcutil.h ../include/npc_oldman.h ../include/title.h \ + ../include/char_data.h ../include/readmap.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h ../include/log.h +npc_windowhealer.o: npc_windowhealer.c ../include/version.h \ + ../include/sasql.h /usr/include/stdio.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/bits/wordsize.h \ + /usr/include/gnu/stubs.h /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/char.h \ + ../include/common.h ../include/char_base.h ../include/version.h \ + ../include/skill.h ../include/util.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/object.h ../include/char_base.h ../include/npcutil.h \ + ../include/lssproto_serv.h ../include/lssproto_util.h \ + ../include/npc_windowhealer.h +npc_itemshop.o: npc_itemshop.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/char.h \ + ../include/common.h ../include/char_base.h ../include/version.h \ + ../include/skill.h ../include/util.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/object.h ../include/char_base.h ../include/npcutil.h \ + ../include/lssproto_serv.h ../include/lssproto_util.h \ + ../include/pet_skill.h ../include/npc_eventaction.h \ + ../include/readmap.h ../include/log.h ../include/family.h +npc_sysinfo.o: npc_sysinfo.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/char.h \ + ../include/common.h ../include/char_base.h ../include/version.h \ + ../include/skill.h ../include/util.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/char_event.h ../include/object.h ../include/handletime.h \ + ../include/magic.h ../include/npcutil.h ../include/char_data.h \ + ../include/chatmagic.h ../include/net.h ../include/configfile.h \ + ../include/npcgen.h +npc_duelranking.o: npc_duelranking.c ../include/version.h \ + ../include/sasql.h /usr/include/stdio.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/bits/wordsize.h \ + /usr/include/gnu/stubs.h /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/char.h \ + ../include/common.h ../include/char_base.h ../include/version.h \ + ../include/skill.h ../include/util.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/object.h ../include/char_base.h ../include/npcutil.h \ + ../include/net.h ../include/lssproto_serv.h ../include/lssproto_util.h \ + ../include/saacproto_cli.h ../include/saacproto_util.h \ + ../include/npc_duelranking.h ../include/handletime.h +npc_petskillshop.o: npc_petskillshop.c ../include/version.h \ + ../include/sasql.h /usr/include/stdio.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/bits/wordsize.h \ + /usr/include/gnu/stubs.h /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/char.h \ + ../include/common.h ../include/char_base.h ../include/version.h \ + ../include/skill.h ../include/util.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/object.h ../include/char_base.h ../include/npcutil.h \ + ../include/lssproto_serv.h ../include/lssproto_util.h \ + ../include/pet_skill.h ../include/readmap.h ../include/battle.h \ + ../include/mylua/function.h +npc_petshop.o: npc_petshop.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/char.h \ + ../include/common.h ../include/char_base.h ../include/version.h \ + ../include/skill.h ../include/util.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/object.h ../include/char_base.h ../include/npcutil.h \ + ../include/lssproto_serv.h ../include/lssproto_util.h \ + ../include/pet_skill.h ../include/readmap.h ../include/battle.h \ + ../include/log.h +npc_signboard.o: npc_signboard.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/char.h \ + ../include/common.h ../include/char_base.h ../include/version.h \ + ../include/skill.h ../include/util.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/object.h ../include/char_base.h ../include/npcutil.h \ + ../include/lssproto_serv.h ../include/lssproto_util.h \ + ../include/readmap.h ../include/family.h +npc_warpman.o: npc_warpman.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/char.h \ + ../include/common.h ../include/char_base.h ../include/version.h \ + ../include/skill.h ../include/util.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/object.h ../include/char_base.h ../include/npcutil.h \ + ../include/lssproto_serv.h ../include/lssproto_util.h \ + ../include/saacproto_cli.h ../include/saacproto_util.h \ + ../include/npc_warpman.h ../include/map_deal.h ../include/readmap.h \ + ../include/battle.h ../include/npc_exchangeman.h ../include/log.h \ + ../include/enemy.h ../include/handletime.h ../include/npc_eventaction.h +npc_exchangeman.o: npc_exchangeman.c ../include/version.h \ + ../include/sasql.h /usr/include/stdio.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/bits/wordsize.h \ + /usr/include/gnu/stubs.h /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/char.h \ + ../include/common.h ../include/char_base.h ../include/version.h \ + ../include/skill.h ../include/util.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/object.h ../include/net.h ../include/char_base.h \ + ../include/npcutil.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h ../include/npc_exchangeman.h \ + ../include/npc_eventaction.h ../include/log.h ../include/battle.h \ + ../include/handletime.h ../include/enemy.h ../include/npc_warp.h +npc_timeman.o: npc_timeman.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/object.h \ + ../include/common.h ../include/char_base.h ../include/version.h \ + ../include/skill.h ../include/util.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char.h ../include/char_base.h ../include/char_data.h \ + ../include/item.h ../include/char.h ../include/util.h \ + ../include/npcutil.h ../include/npc_oldman.h ../include/title.h \ + ../include/char_data.h ../include/readmap.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h ../include/log.h ../include/handletime.h +npc_bodylan.o: npc_bodylan.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/char.h \ + ../include/common.h ../include/char_base.h ../include/version.h \ + ../include/skill.h ../include/util.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/object.h ../include/char_base.h ../include/npcutil.h \ + ../include/lssproto_serv.h ../include/lssproto_util.h \ + ../include/npc_windowhealer.h +npc_mic.o: npc_mic.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/common.h \ + ../include/char_base.h ../include/version.h ../include/skill.h \ + ../include/common.h ../include/util.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char.h ../include/char_base.h ../include/char_data.h \ + ../include/item.h ../include/char.h ../include/npcutil.h \ + ../include/npc_mic.h ../include/saacproto_cli.h \ + ../include/saacproto_util.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h ../include/battle.h +npc_luckyman.o: npc_luckyman.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/char.h \ + ../include/common.h ../include/char_base.h ../include/version.h \ + ../include/skill.h ../include/util.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/object.h ../include/char_base.h ../include/npcutil.h \ + ../include/lssproto_serv.h ../include/lssproto_util.h \ + ../include/npc_luckyman.h +npc_bus.o: npc_bus.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/char.h \ + ../include/common.h ../include/char_base.h ../include/version.h \ + ../include/skill.h ../include/util.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/object.h ../include/char_base.h ../include/npcutil.h \ + ../include/lssproto_serv.h ../include/lssproto_util.h \ + ../include/npc_bus.h ../include/handletime.h +npc_charm.o: npc_charm.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/char.h \ + ../include/common.h ../include/char_base.h ../include/version.h \ + ../include/skill.h ../include/util.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/object.h ../include/char_base.h ../include/npcutil.h \ + ../include/lssproto_serv.h ../include/lssproto_util.h \ + ../include/npc_charm.h +npc_quiz.o: npc_quiz.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/common.h \ + ../include/char_base.h ../include/version.h ../include/skill.h \ + ../include/common.h ../include/util.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/npc_quiz.h ../include/npcutil.h ../include/char.h \ + ../include/char_base.h ../include/char_data.h ../include/item.h \ + ../include/char.h ../include/lssproto_serv.h ../include/lssproto_util.h \ + ../include/buf.h ../include/function.h ../include/readmap.h \ + ../include/object.h ../include/log.h +npc_poolitemshop.o: npc_poolitemshop.c ../include/version.h \ + ../include/sasql.h /usr/include/stdio.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/bits/wordsize.h \ + /usr/include/gnu/stubs.h /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/char.h \ + ../include/common.h ../include/char_base.h ../include/version.h \ + ../include/skill.h ../include/util.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/lssproto_serv.h ../include/lssproto_util.h \ + ../include/npcutil.h ../include/npc_poolitemshop.h ../include/log.h \ + ../include/handletime.h +npc_checkman.o: npc_checkman.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/char.h \ + ../include/common.h ../include/char_base.h ../include/version.h \ + ../include/skill.h ../include/util.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/object.h ../include/char_base.h ../include/npcutil.h \ + ../include/lssproto_serv.h ../include/lssproto_util.h +npc_janken.o: npc_janken.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/common.h \ + ../include/char_base.h ../include/version.h ../include/skill.h \ + ../include/common.h ../include/util.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/npc_janken.h ../include/npcutil.h ../include/char.h \ + ../include/char_base.h ../include/char_data.h ../include/item.h \ + ../include/char.h ../include/lssproto_serv.h ../include/lssproto_util.h \ + ../include/buf.h ../include/function.h ../include/readmap.h \ + ../include/object.h ../include/log.h +npc_transmigration.o: npc_transmigration.c ../include/version.h \ + ../include/sasql.h /usr/include/stdio.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/bits/wordsize.h \ + /usr/include/gnu/stubs.h /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h /usr/include/math.h \ + /usr/include/bits/huge_val.h /usr/include/bits/mathdef.h \ + /usr/include/bits/mathcalls.h ../include/char.h ../include/common.h \ + ../include/char_base.h ../include/version.h ../include/skill.h \ + ../include/util.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/object.h ../include/char_base.h ../include/npcutil.h \ + ../include/lssproto_serv.h ../include/lssproto_util.h \ + ../include/enemy.h ../include/log.h ../include/battle.h \ + ../include/readmap.h ../include/npc_transmigration.h \ + ../include/configfile.h ../include/npc_pettransman.h +npc_makepair.o: npc_makepair.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/char.h \ + ../include/common.h ../include/char_base.h ../include/version.h \ + ../include/skill.h ../include/util.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/object.h ../include/char_base.h ../include/npcutil.h \ + ../include/npc_transerman.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h ../include/saacproto_cli.h \ + ../include/saacproto_util.h ../include/readmap.h ../include/battle.h \ + ../include/log.h ../include/enemy.h ../include/handletime.h \ + ../include/npc_makepair.h ../include/npc_eventaction.h +npc_familyman.o: npc_familyman.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/char.h \ + ../include/common.h ../include/char_base.h ../include/version.h \ + ../include/skill.h ../include/util.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/object.h ../include/char_base.h ../include/npcutil.h \ + ../include/configfile.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h ../include/saacproto_cli.h \ + ../include/saacproto_util.h ../include/npc_familyman.h \ + ../include/family.h +npc_fmdengon.o: npc_fmdengon.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/char.h \ + ../include/common.h ../include/char_base.h ../include/version.h \ + ../include/skill.h ../include/util.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/object.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h ../include/saacproto_cli.h \ + ../include/saacproto_util.h ../include/npcutil.h \ + ../include/handletime.h ../include/npc_fmdengon.h ../include/family.h \ + ../include/npc_scheduleman.h +npc_fmwarpman.o: npc_fmwarpman.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/char.h \ + ../include/common.h ../include/char_base.h ../include/version.h \ + ../include/skill.h ../include/util.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/object.h ../include/char_base.h ../include/npcutil.h \ + ../include/lssproto_serv.h ../include/lssproto_util.h \ + ../include/saacproto_cli.h ../include/saacproto_util.h \ + ../include/npc_fmwarpman.h ../include/npc_scheduleman.h \ + ../include/readmap.h ../include/log.h ../include/battle.h \ + ../include/handletime.h ../include/family.h ../include/configfile.h +npc_fmhealer.o: npc_fmhealer.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h /usr/include/ctype.h \ + ../include/object.h ../include/common.h ../include/char_base.h \ + ../include/version.h ../include/skill.h ../include/util.h \ + ../include/title.h ../include/addressbook.h ../include/net.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char.h ../include/char_base.h ../include/char_data.h \ + ../include/item.h ../include/char.h ../include/util.h \ + ../include/npcutil.h ../include/item.h ../include/readmap.h +npc_bankman.o: npc_bankman.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/char.h \ + ../include/common.h ../include/char_base.h ../include/version.h \ + ../include/skill.h ../include/util.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/object.h ../include/char_base.h ../include/npcutil.h \ + ../include/configfile.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h ../include/saacproto_cli.h \ + ../include/saacproto_util.h ../include/npc_bankman.h \ + ../include/family.h +npc_fmpkman.o: npc_fmpkman.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/char.h \ + ../include/common.h ../include/char_base.h ../include/version.h \ + ../include/skill.h ../include/util.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/object.h ../include/char_base.h ../include/npcutil.h \ + ../include/lssproto_serv.h ../include/lssproto_util.h \ + ../include/npc_fmpkman.h ../include/npc_scheduleman.h \ + ../include/npc_fmwarpman.h ../include/family.h ../include/readmap.h \ + ../include/battle.h ../include/log.h +npc_airplane.o: npc_airplane.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/char.h \ + ../include/common.h ../include/char_base.h ../include/version.h \ + ../include/skill.h ../include/util.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/object.h ../include/char_base.h ../include/npcutil.h \ + ../include/lssproto_serv.h ../include/lssproto_util.h \ + ../include/npc_airplane.h ../include/handletime.h +npc_scheduleman.o: npc_scheduleman.c ../include/version.h \ + ../include/sasql.h /usr/include/stdio.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/bits/wordsize.h \ + /usr/include/gnu/stubs.h /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/char.h \ + ../include/common.h ../include/char_base.h ../include/version.h \ + ../include/skill.h ../include/util.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/object.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h ../include/npcutil.h ../include/handletime.h \ + ../include/npc_scheduleman.h ../include/family.h +npc_fmpkcallman.o: npc_fmpkcallman.c ../include/version.h \ + ../include/sasql.h /usr/include/stdio.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/bits/wordsize.h \ + /usr/include/gnu/stubs.h /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/char.h \ + ../include/common.h ../include/char_base.h ../include/version.h \ + ../include/skill.h ../include/util.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/object.h ../include/char_base.h ../include/npcutil.h \ + ../include/lssproto_serv.h ../include/lssproto_util.h \ + ../include/npc_fmpkcallman.h ../include/family.h ../include/readmap.h \ + ../include/battle.h ../include/log.h ../include/npc_scheduleman.h \ + ../include/handletime.h +npc_manorsman.o: npc_manorsman.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/char.h \ + ../include/common.h ../include/char_base.h ../include/version.h \ + ../include/skill.h ../include/util.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/object.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h ../include/npcutil.h ../include/handletime.h \ + ../include/npc_scheduleman.h ../include/family.h \ + ../include/npc_manorsman.h ../include/saacproto_cli.h \ + ../include/saacproto_util.h ../include/net.h ../include/configfile.h \ + ../include/log.h +npc_riderman.o: npc_riderman.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/char.h \ + ../include/common.h ../include/char_base.h ../include/version.h \ + ../include/skill.h ../include/util.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/object.h ../include/char_base.h ../include/npcutil.h \ + ../include/configfile.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h ../include/saacproto_cli.h \ + ../include/saacproto_util.h ../include/npc_riderman.h \ + ../include/family.h ../include/log.h +npc_fmletter.o: npc_fmletter.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/char.h \ + ../include/common.h ../include/char_base.h ../include/version.h \ + ../include/skill.h ../include/util.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/object.h ../include/char_base.h ../include/npcutil.h \ + ../include/configfile.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h ../include/saacproto_cli.h \ + ../include/saacproto_util.h ../include/npc_fmletter.h \ + ../include/family.h ../include/log.h +npc_petmaker.o: npc_petmaker.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h /usr/include/ctype.h \ + ../include/object.h ../include/common.h ../include/char_base.h \ + ../include/version.h ../include/skill.h ../include/util.h \ + ../include/title.h ../include/addressbook.h ../include/net.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char.h ../include/char_base.h ../include/char_data.h \ + ../include/item.h ../include/char.h ../include/util.h \ + ../include/npcutil.h ../include/item.h ../include/readmap.h \ + ../include/enemy.h ../include/chatmagic.h ../include/log.h +npc_gamblemaster.o: npc_gamblemaster.c ../include/version.h \ + ../include/sasql.h /usr/include/stdio.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/bits/wordsize.h \ + /usr/include/gnu/stubs.h /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/char.h \ + ../include/common.h ../include/char_base.h ../include/version.h \ + ../include/skill.h ../include/util.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/object.h ../include/char_base.h ../include/npcutil.h \ + ../include/lssproto_serv.h ../include/lssproto_util.h \ + ../include/handletime.h ../include/readmap.h ../include/log.h \ + ../include/npc_eventaction.h ../include/npc_gamblemaster.h +npc_gambleroulette.o: npc_gambleroulette.c ../include/version.h \ + ../include/sasql.h /usr/include/stdio.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/bits/wordsize.h \ + /usr/include/gnu/stubs.h /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/char.h \ + ../include/common.h ../include/char_base.h ../include/version.h \ + ../include/skill.h ../include/util.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/object.h ../include/char_base.h ../include/npcutil.h \ + ../include/readmap.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h ../include/handletime.h \ + ../include/npc_gambleroulette.h +npc_petfusion.o: npc_petfusion.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/char.h \ + ../include/common.h ../include/char_base.h ../include/version.h \ + ../include/skill.h ../include/util.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/object.h ../include/char_base.h ../include/char_data.h \ + ../include/npcutil.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h ../include/saacproto_cli.h \ + ../include/saacproto_util.h ../include/readmap.h ../include/battle.h \ + ../include/log.h ../include/enemy.h ../include/handletime.h \ + ../include/npc_eventaction.h ../include/npc_petfusion.h \ + ../include/pet.h ../include/chatmagic.h +npc_stoneserviceman.o: npc_stoneserviceman.c +npc_newnpcman.o: npc_newnpcman.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h /usr/include/math.h \ + /usr/include/bits/huge_val.h /usr/include/bits/mathdef.h \ + /usr/include/bits/mathcalls.h ../include/char.h ../include/common.h \ + ../include/char_base.h ../include/version.h ../include/skill.h \ + ../include/util.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/object.h ../include/char_base.h ../include/npcutil.h \ + ../include/lssproto_serv.h ../include/lssproto_util.h \ + ../include/enemy.h ../include/log.h ../include/battle.h \ + ../include/readmap.h ../include/handletime.h \ + ../include/npc_eventaction.h ../include/npc_newnpcman.h \ + ../include/pet.h +npc_gamblebank.o: npc_gamblebank.c ../include/version.h \ + ../include/sasql.h /usr/include/stdio.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/bits/wordsize.h \ + /usr/include/gnu/stubs.h /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h /usr/include/math.h \ + /usr/include/bits/huge_val.h /usr/include/bits/mathdef.h \ + /usr/include/bits/mathcalls.h ../include/char.h ../include/common.h \ + ../include/char_base.h ../include/version.h ../include/skill.h \ + ../include/util.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/object.h ../include/char_base.h ../include/npcutil.h \ + ../include/lssproto_serv.h ../include/lssproto_util.h \ + ../include/enemy.h ../include/log.h ../include/battle.h \ + ../include/readmap.h ../include/handletime.h ../include/configfile.h \ + ../include/npc_gamblebank.h +npc_petracemaster.o: npc_petracemaster.c ../include/version.h \ + ../include/sasql.h /usr/include/stdio.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/bits/wordsize.h \ + /usr/include/gnu/stubs.h /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/char.h \ + ../include/common.h ../include/char_base.h ../include/version.h \ + ../include/skill.h ../include/util.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/object.h ../include/char_base.h ../include/npcutil.h \ + ../include/lssproto_serv.h ../include/lssproto_util.h \ + ../include/handletime.h ../include/npc_petracemaster.h +npc_petracepet.o: npc_petracepet.c ../include/version.h \ + ../include/sasql.h /usr/include/stdio.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/bits/wordsize.h \ + /usr/include/gnu/stubs.h /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/char.h \ + ../include/common.h ../include/char_base.h ../include/version.h \ + ../include/skill.h ../include/util.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/object.h ../include/char_base.h ../include/npcutil.h \ + ../include/lssproto_serv.h ../include/lssproto_util.h \ + ../include/handletime.h ../include/npc_petracepet.h +npc_bigsmallmaster.o: npc_bigsmallmaster.c +npc_bigsmallpet.o: npc_bigsmallpet.c +npc_auctioneer.o: npc_auctioneer.c +npc_freepetskillshop.o: npc_freepetskillshop.c ../include/version.h \ + ../include/sasql.h /usr/include/stdio.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/bits/wordsize.h \ + /usr/include/gnu/stubs.h /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/char.h \ + ../include/common.h ../include/char_base.h ../include/version.h \ + ../include/skill.h ../include/util.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/object.h ../include/char_base.h ../include/npcutil.h \ + ../include/lssproto_serv.h ../include/lssproto_util.h \ + ../include/pet_skill.h ../include/readmap.h ../include/battle.h \ + ../include/configfile.h ../include/util.h ../include/npc_eventaction.h \ + ../include/npc_freepetskillshop.h ../include/mylua/function.h +npc_eventaction.o: npc_eventaction.c ../include/version.h \ + ../include/sasql.h /usr/include/stdio.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/bits/wordsize.h \ + /usr/include/gnu/stubs.h /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/char.h \ + ../include/common.h ../include/char_base.h ../include/version.h \ + ../include/skill.h ../include/util.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/object.h ../include/char_base.h ../include/npcutil.h \ + ../include/lssproto_serv.h ../include/lssproto_util.h \ + ../include/saacproto_cli.h ../include/saacproto_util.h \ + ../include/map_deal.h ../include/readmap.h ../include/battle.h \ + ../include/log.h ../include/enemy.h ../include/handletime.h \ + ../include/npc_eventaction.h ../include/family.h \ + ../include/profession_skill.h ../include/chatmagic.h +npc_vipshop.o: npc_vipshop.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/char.h \ + ../include/common.h ../include/char_base.h ../include/version.h \ + ../include/skill.h ../include/util.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/object.h ../include/char_base.h ../include/npcutil.h \ + ../include/npc_vipshop.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h ../include/saacproto_cli.h \ + ../include/saacproto_util.h ../include/readmap.h ../include/battle.h \ + ../include/log.h ../include/enemy.h ../include/handletime.h \ + ../include/npc_eventaction.h +npc_autopk.o: npc_autopk.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/char.h \ + ../include/common.h ../include/char_base.h ../include/version.h \ + ../include/skill.h ../include/util.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/object.h ../include/char_base.h ../include/npcutil.h \ + ../include/npc_autopk.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h ../include/saacproto_cli.h \ + ../include/saacproto_util.h ../include/readmap.h ../include/battle.h \ + ../include/log.h ../include/enemy.h ../include/handletime.h \ + ../include/npc_eventaction.h ../include/npc_healer.h \ + ../include/configfile.h +npc_fmlookwar.o: npc_fmlookwar.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/char.h \ + ../include/common.h ../include/char_base.h ../include/version.h \ + ../include/skill.h ../include/util.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/object.h ../include/char_base.h ../include/npcutil.h \ + ../include/npc_fmlookwar.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h ../include/saacproto_cli.h \ + ../include/saacproto_util.h ../include/readmap.h ../include/battle.h \ + ../include/log.h ../include/enemy.h ../include/handletime.h \ + ../include/npc_eventaction.h +npc_fmlookwar1.o: npc_fmlookwar1.c ../include/version.h \ + ../include/sasql.h /usr/include/stdio.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/bits/wordsize.h \ + /usr/include/gnu/stubs.h /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/char.h \ + ../include/common.h ../include/char_base.h ../include/version.h \ + ../include/skill.h ../include/util.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/object.h ../include/char_base.h ../include/npcutil.h \ + ../include/npc_fmlookwar1.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h ../include/saacproto_cli.h \ + ../include/saacproto_util.h ../include/readmap.h ../include/battle.h \ + ../include/log.h ../include/enemy.h ../include/handletime.h \ + ../include/npc_eventaction.h +npc_mtradenpcman.o: npc_mtradenpcman.c +npc_blackmarket.o: npc_blackmarket.c +npc_transerman.o: npc_transerman.c ../include/version.h \ + ../include/sasql.h /usr/include/stdio.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/bits/wordsize.h \ + /usr/include/gnu/stubs.h /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/char.h \ + ../include/common.h ../include/char_base.h ../include/version.h \ + ../include/skill.h ../include/util.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/object.h ../include/char_base.h ../include/npcutil.h \ + ../include/npc_transerman.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h ../include/saacproto_cli.h \ + ../include/saacproto_util.h ../include/readmap.h ../include/battle.h \ + ../include/log.h ../include/enemy.h ../include/handletime.h \ + ../include/npc_eventaction.h +npc_pauctionman.o: npc_pauctionman.c +npc_alldoman.o: npc_alldoman.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h /usr/include/ctype.h \ + ../include/object.h ../include/common.h ../include/char_base.h \ + ../include/version.h ../include/skill.h ../include/util.h \ + ../include/title.h ../include/addressbook.h ../include/net.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char.h ../include/char_base.h ../include/char_data.h \ + ../include/item.h ../include/char.h ../include/util.h \ + ../include/npcutil.h ../include/item.h ../include/readmap.h \ + ../include/enemy.h ../include/chatmagic.h ../include/log.h \ + ../include/npc_itemchange.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h ../include/saacproto_cli.h \ + ../include/saacproto_util.h ../include/npc_eventaction.h \ + ../include/npc_charm.h ../include/npc_alldoman.h +npc_sellsthman.o: npc_sellsthman.c +npc_newvipshop.o: npc_newvipshop.c ../include/version.h \ + ../include/sasql.h /usr/include/stdio.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/bits/wordsize.h \ + /usr/include/gnu/stubs.h /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/char.h \ + ../include/common.h ../include/char_base.h ../include/version.h \ + ../include/skill.h ../include/util.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/object.h ../include/char_base.h ../include/npcutil.h \ + ../include/npc_newvipshop.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h ../include/saacproto_cli.h \ + ../include/saacproto_util.h ../include/readmap.h ../include/battle.h \ + ../include/log.h ../include/enemy.h ../include/handletime.h \ + ../include/npc_eventaction.h +npc_vigorshop.o: npc_vigorshop.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/char.h \ + ../include/common.h ../include/char_base.h ../include/version.h \ + ../include/skill.h ../include/util.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/object.h ../include/char_base.h ../include/npcutil.h \ + ../include/lssproto_serv.h ../include/lssproto_util.h \ + ../include/pet_skill.h ../include/npc_eventaction.h \ + ../include/readmap.h ../include/log.h ../include/family.h +npc_stushop.o: npc_stushop.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/char.h \ + ../include/common.h ../include/char_base.h ../include/version.h \ + ../include/skill.h ../include/util.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/object.h ../include/char_base.h ../include/npcutil.h \ + ../include/npc_stushop.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h ../include/saacproto_cli.h \ + ../include/saacproto_util.h ../include/readmap.h ../include/battle.h \ + ../include/log.h ../include/enemy.h ../include/handletime.h \ + ../include/npc_eventaction.h +npc_rmbshop.o: npc_rmbshop.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/char.h \ + ../include/common.h ../include/char_base.h ../include/version.h \ + ../include/skill.h ../include/util.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/object.h ../include/char_base.h ../include/npcutil.h \ + ../include/npc_rmbshop.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h ../include/saacproto_cli.h \ + ../include/saacproto_util.h ../include/readmap.h ../include/battle.h \ + ../include/log.h ../include/enemy.h ../include/handletime.h \ + ../include/npc_eventaction.h +npc_itemvippointshop.o: npc_itemvippointshop.c ../include/version.h \ + ../include/sasql.h /usr/include/stdio.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/bits/wordsize.h \ + /usr/include/gnu/stubs.h /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/char.h \ + ../include/common.h ../include/char_base.h ../include/version.h \ + ../include/skill.h ../include/util.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/object.h ../include/char_base.h ../include/npcutil.h \ + ../include/lssproto_serv.h ../include/lssproto_util.h \ + ../include/pet_skill.h ../include/npc_eventaction.h \ + ../include/readmap.h ../include/log.h ../include/family.h +npc_welfare.o: npc_welfare.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/char.h \ + ../include/common.h ../include/char_base.h ../include/version.h \ + ../include/skill.h ../include/util.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/object.h ../include/char_base.h ../include/npcutil.h \ + ../include/lssproto_serv.h ../include/lssproto_util.h \ + ../include/pet_skill.h ../include/readmap.h ../include/battle.h \ + ../include/profession_skill.h ../include/chatmagic.h \ + ../include/npc_welfare.h ../include/npc_exchangeman.h +npc_verywelfare.o: npc_verywelfare.c +npc_welfare2.o: npc_welfare2.c +npc_petskilldelshop.o: npc_petskilldelshop.c ../include/version.h \ + ../include/sasql.h /usr/include/stdio.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/bits/wordsize.h \ + /usr/include/gnu/stubs.h /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/char.h \ + ../include/common.h ../include/char_base.h ../include/version.h \ + ../include/skill.h ../include/util.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/object.h ../include/char_base.h ../include/npcutil.h \ + ../include/lssproto_serv.h ../include/lssproto_util.h \ + ../include/pet_skill.h ../include/readmap.h ../include/battle.h \ + ../include/mylua/function.h +npc_fmrank.o: npc_fmrank.c ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/char.h \ + ../include/common.h ../include/char_base.h ../include/version.h \ + ../include/skill.h ../include/util.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/object.h ../include/char_base.h ../include/npcutil.h \ + ../include/npc_fmrank.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h ../include/saacproto_cli.h \ + ../include/saacproto_util.h ../include/readmap.h ../include/battle.h \ + ../include/log.h ../include/enemy.h ../include/handletime.h \ + ../include/npc_eventaction.h ../include/npc_healer.h \ + ../include/configfile.h ../include/sasql.h diff --git a/npc/npc_action.c b/npc/npc_action.c new file mode 100644 index 0000000..26c85e5 --- /dev/null +++ b/npc/npc_action.c @@ -0,0 +1,137 @@ +#include "version.h" +#include +#include "char.h" +#include "object.h" +#include "char_base.h" +#include "npcutil.h" +#include "npc_action.h" + +/* + * ʧ ɱNPC + * ǩԻ߯Ի·ֻ + * ʣ׷ Ȼ¼ʧ巴 ɱئУ + * + * ¦ѡ + * msgcol: ⼰ƣ۷ɻ + * normal: ɧȻ֧ ئʧ帲ƻ߯ + * attack: ʧ帲߯ + * damage: ĸëʧ帲߯ + * down: ľʧ帲߯ + * sit: ʧ帲ƻ߯ + * hand: ëʧ帲ƻ߯ + * pleasure: ʧ帲ƻ߯ + * angry: ʧ帲ƻ߯ + * sad: Ƹʧ帲ƻ߯ + * guard: ʧ帲ƻ߯ + */ + + +#define NPC_ACTION_MSGCOLOR_DEFAULT CHAR_COLORYELLOW + +enum { + CHAR_WORK_MSGCOLOR = CHAR_NPCWORKINT1, +}; + +/********************************* +* +*********************************/ +BOOL NPC_ActionInit( int meindex ) +{ + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + int tmp; + + tmp = NPC_Util_GetNumFromStrWithDelim( argstr, "msgcol"); + if( tmp == -1 ) tmp = NPC_ACTION_MSGCOLOR_DEFAULT; + CHAR_setWorkInt( meindex, CHAR_WORK_MSGCOLOR, tmp); + + CHAR_setInt( meindex , CHAR_WHICHTYPE , CHAR_TYPEACTION ); + + + return TRUE; +} + + + + +/********************************* +* ƾľݼ +*********************************/ +void NPC_ActionTalked( int meindex , int talkerindex , char *szMes , + int color ) +{ + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + char buf[64]; + + /* 帲ƻ ɱ */ + if( CHAR_getInt( talkerindex , CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER ) { + return; + } + /* */ + if( !NPC_Util_charIsInFrontOfChar( talkerindex, meindex, 1 )) return; + + NPC_Util_GetArgStr( meindex, argstr, sizeof( argstr)); + + if( NPC_Util_GetStrFromStrWithDelim( argstr, + "normal", + buf, sizeof( buf)) + != NULL ) + { + CHAR_talkToCli( talkerindex, meindex ,buf , + CHAR_getWorkInt( meindex, CHAR_WORK_MSGCOLOR )); + } + +} +/********************************* +* watch +*********************************/ +void NPC_ActionWatch( int meobjindex, int objindex, CHAR_ACTION act, + int x,int y,int dir, int* opt,int optlen ) +{ + int meindex; + int index; + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + char buf[64]; + int i; + struct { + CHAR_ACTION act; + char *string; + }searchtbl[] = { + { CHAR_ACTATTACK, "attack"}, + { CHAR_ACTDAMAGE, "damage"}, + { CHAR_ACTDOWN, "down"}, + { CHAR_ACTSIT, "sit"}, + { CHAR_ACTHAND, "hand"}, + { CHAR_ACTPLEASURE, "pleasure"}, + { CHAR_ACTANGRY, "angry"}, + { CHAR_ACTSAD, "sad"}, + { CHAR_ACTGUARD, "guard"}, + { CHAR_ACTNOD, "nod"}, + { CHAR_ACTTHROW, "throw"}, + }; + + if( OBJECT_getType( objindex) != OBJTYPE_CHARA) return; + index = OBJECT_getIndex( objindex); + /* 弰 ɱ */ + if( CHAR_getInt( index, CHAR_WHICHTYPE) != CHAR_TYPEPLAYER) return; + + meindex = OBJECT_getIndex( meobjindex); + + /* Ȼƥئ ɱئ */ + if( NPC_Util_isFaceToFace( meindex, index, 1 ) != TRUE ) return; + + NPC_Util_GetArgStr( meindex, argstr, sizeof( argstr)); + + for( i = 0; i < arraysizeof( searchtbl); i ++ ) { + if( searchtbl[i].act == act) { + if( NPC_Util_GetStrFromStrWithDelim( argstr, + searchtbl[i].string, + buf, sizeof( buf)) + != NULL ) + { + CHAR_talkToCli( index, meindex ,buf , + CHAR_getWorkInt( meindex, CHAR_WORK_MSGCOLOR )); + break; + } + } + } +} diff --git a/npc/npc_airplane.c b/npc/npc_airplane.c new file mode 100644 index 0000000..79a4462 --- /dev/null +++ b/npc/npc_airplane.c @@ -0,0 +1,760 @@ +#include "version.h" +#include +#include "char.h" +#include "object.h" +#include "char_base.h" +#include "npcutil.h" +#include "lssproto_serv.h" +#include "npc_airplane.h" +#include "handletime.h" + +/* + * (Made from Bus) + */ + +enum { + NPC_WORK_ROUTETOX = CHAR_NPCWORKINT1, /* ߣ */ + NPC_WORK_ROUTETOY = CHAR_NPCWORKINT2, /* ߣ */ + NPC_WORK_ROUTEPOINT = CHAR_NPCWORKINT3, /* */ + NPC_WORK_ROUNDTRIP = CHAR_NPCWORKINT4, /* 微Ի ߡ ࡰԻ */ + NPC_WORK_MODE = CHAR_NPCWORKINT5, + NPC_WORK_CURRENTROUTE = CHAR_NPCWORKINT6, + NPC_WORK_ROUTEMAX = CHAR_NPCWORKINT7, + NPC_WORK_WAITTIME = CHAR_NPCWORKINT8, + NPC_WORK_CURRENTTIME = CHAR_NPCWORKINT9, + NPC_WORK_SEFLG = CHAR_NPCWORKINT10, + NPC_WORK_ONEWAYFLG = CHAR_NPCWORKINT11, + NPC_WORK_RUNWAVE = CHAR_NPCWORKINT13, +}; + +/* ⼰enum */ +enum { + NPC_AIR_MSG_GETTINGON, + NPC_AIR_MSG_NOTPARTY, + NPC_AIR_MSG_OVERPARTY, + NPC_AIR_MSG_DENIEDITEM, + NPC_AIR_MSG_ALLOWITEM, + NPC_AIR_MSG_LEVEL, + NPC_AIR_MSG_GOLD, + NPC_AIR_MSG_EVENT, + NPC_AIR_MSG_START, + NPC_AIR_MSG_END, +}; +typedef struct { + char option[32]; + char defaultmsg[128]; +}NPC_AIR_MSG; +NPC_AIR_MSG airmsg[] = { + { "msg_gettingon", "PAON޷;ࡣ"}, + { "msg_notparty", "PAPAON޷ŶӼࡣ"}, + { "msg_overparty", "PAON"}, + { "msg_denieditem", "PAPAONҿɲҪߣ"}, + { "msg_allowitem", "~(ҪǸ߰!)"}, + { "msg_level", "PAPAONĵȼࡣ"}, + { "msg_stone", "PAPAONǮࡣ"}, + { "msg_event", "PAON޷ࡣ"}, + { "msg_start", "~()"}, + { "msg_end", "~()"} +}; + +static int NPC_AirSetPoint( int meindex, char *argstr); +static void NPC_AirSetDestPoint( int meindex, char *argstr); +static BOOL NPC_AirCheckDeniedItem( int meindex, int charaindex, char *argstr); +static BOOL NPC_AirCheckLevel( int meindex, int charaindex, char *argstr); +static int NPC_AirCheckStone( int meindex, int charaindex, char *argstr); +static void NPC_AirSendMsg( int meindex, int talkerindex, int tablenum); +static int NPC_AirGetRoutePointNum( int meindex, char *argstr ); +static void NPC_Air_walk( int meindex); + +#define NPC_AIR_LOOPTIME 20 +#define NPC_AIR_WAITTIME_DEFAULT 180 +#define NPC_AIR_WAITINGMODE_WAITTIME 5000 + +/********************************* +* +*********************************/ +BOOL NPC_AirInit( int meindex ) +{ + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE - 1024 * 20]; + int i; + char buf[256],buf1[256]; + int routenum; + int waittime; + int seflg; + int onewayflg; + + NPC_Util_GetArgStr( meindex, argstr, sizeof( argstr)); + + /* ئľئ¦Ѽ */ + routenum = NPC_Util_GetNumFromStrWithDelim( argstr, "routenum"); + if( routenum == -1 ) { + print( "npcair:nothing routenum \n"); + return FALSE; + } + CHAR_setWorkInt( meindex, NPC_WORK_ROUTEMAX, routenum); + + for( i = 1; i <= routenum; i ++ ) { + char routetostring[64]; + snprintf( routetostring, sizeof( routetostring), "routeto%d", i); + if( NPC_Util_GetStrFromStrWithDelim( argstr, routetostring,buf, sizeof(buf)) + == NULL ) + { + print( "npcair:nothing route to \n"); + return FALSE; + } + } + //ANDY_ADD NPC_WORK_RUNWAVE + if( NPC_Util_GetStrFromStrWithDelim( argstr, "WAVE",buf1, sizeof(buf1)) == NULL ) { + CHAR_setWorkInt( meindex, NPC_WORK_RUNWAVE, 77); + }else { + CHAR_setWorkInt( meindex, NPC_WORK_RUNWAVE, atoi( buf1) ); + } + + waittime = NPC_Util_GetNumFromStrWithDelim( argstr, "waittime"); + if( waittime == -1 ) waittime = NPC_AIR_WAITTIME_DEFAULT; + CHAR_setWorkInt( meindex, NPC_WORK_WAITTIME, waittime); + + seflg = NPC_Util_GetNumFromStrWithDelim( argstr, "seflg"); + if( seflg == -1 ) seflg = TRUE; + CHAR_setWorkInt( meindex, NPC_WORK_SEFLG, seflg); + + onewayflg = NPC_Util_GetNumFromStrWithDelim( argstr, "oneway"); + if( onewayflg == -1 ) onewayflg = FALSE; // default + CHAR_setWorkInt( meindex, NPC_WORK_ONEWAYFLG, onewayflg); + + CHAR_setInt( meindex , CHAR_WHICHTYPE , CHAR_TYPEBUS ); + + CHAR_setWorkInt( meindex, NPC_WORK_MODE, 0); + CHAR_setWorkInt( meindex, NPC_WORK_ROUTEPOINT, 2); + CHAR_setWorkInt( meindex, NPC_WORK_ROUNDTRIP, 0); + CHAR_setWorkInt( meindex, NPC_WORK_CURRENTROUTE, 0); + + CHAR_setInt( meindex, CHAR_LOOPINTERVAL, + NPC_AIR_WAITINGMODE_WAITTIME); + + /* ػë */ + CHAR_setWorkInt( meindex, NPC_WORK_CURRENTTIME, NowTime.tv_sec); + + for( i = 0; i < CHAR_PARTYMAX; i ++) { + CHAR_setWorkInt( meindex, CHAR_WORKPARTYINDEX1 + i, -1); + } + + /* */ +{ + int rev; + int r = CHAR_getWorkInt( meindex, NPC_WORK_ROUTEMAX); + CHAR_setWorkInt( meindex, NPC_WORK_CURRENTROUTE, RAND( 1, r)); + //print( "route:%d\n",CHAR_getWorkInt( meindex, NPC_WORK_CURRENTROUTE)); + + /* Ƿ */ + rev = NPC_Util_GetNumFromStrWithDelim( argstr, "reverse"); + if( rev == 1 ) { + int num = NPC_AirGetRoutePointNum( meindex, argstr); + if( num <= 0 ) { + print( "npcairplane:֣\n"); + return FALSE; + } + CHAR_setWorkInt( meindex, NPC_WORK_ROUTEPOINT, num-1); + CHAR_setWorkInt( meindex, NPC_WORK_ROUNDTRIP, 1); + } + /* ë */ + NPC_AirSetPoint( meindex, argstr); + /* ë */ + NPC_AirSetDestPoint( meindex, argstr); +} + + return TRUE; +} + + +/********************************* +* ƾľݼ +*********************************/ +void NPC_AirTalked( int meindex , int talkerindex , char *szMes , + int color ) +{ + int i; + int partyflg = FALSE; + int npc_wave = CHAR_getWorkInt( meindex, NPC_WORK_RUNWAVE); + + /* 帲ƻ ɱ */ + if( CHAR_getInt( talkerindex , CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER ) { + return; + } + /* мɡ ū Ʃ */ + for( i = 0; i < CHAR_PARTYMAX; i ++ ) { + int index = CHAR_getWorkInt( meindex, CHAR_WORKPARTYINDEX1+i); + if( CHAR_CHECKINDEX(index)){ + if( index == talkerindex) { + partyflg = TRUE; + } + } + } + if( !partyflg ) { + //NPC_AirCheckJoinParty( meindex, talkerindex, TRUE); + } + else { + if( CHAR_getWorkInt( meindex, NPC_WORK_MODE) == 0 ) { + int i; + // #define NPC_AIR_DEBUGROUTINTG "routingtable:" + if( strstr( szMes, "" ) || + strstr( szMes, "" ) || + strstr( szMes, "Go" ) || + strstr( szMes, "go" )) + { + CHAR_setWorkInt( meindex, NPC_WORK_MODE,1); + + /* Ѽëʻպ */ + CHAR_setInt( meindex, CHAR_LOOPINTERVAL, NPC_AIR_LOOPTIME); + + /* SE Ѩƹ̫ */ + if( CHAR_getWorkInt( meindex, NPC_WORK_SEFLG )) { + //andy_reEdit NPC_WORK_RUNWAVE + CHAR_sendSEoArroundCharacter( + CHAR_getInt( meindex, CHAR_FLOOR), + CHAR_getInt( meindex, CHAR_X), + CHAR_getInt( meindex, CHAR_Y), + npc_wave, + TRUE); + } + /* ݼ*/ + for( i = 1; i < CHAR_PARTYMAX; i ++ ) { + int partyindex = CHAR_getWorkInt( meindex, CHAR_WORKPARTYINDEX1+i); + if( CHAR_CHECKINDEX( partyindex)) { + NPC_AirSendMsg( meindex, partyindex, NPC_AIR_MSG_START); + } + } + } + } + } +} +/************************************** + * + **************************************/ +void NPC_AirLoop( int meindex) +{ + int i; + int npc_wave = CHAR_getWorkInt( meindex, NPC_WORK_RUNWAVE); + switch( CHAR_getWorkInt( meindex, NPC_WORK_MODE )) { + case 0: + /* ƹݣë */ + /* ޻׼ƥ */ + if( CHAR_getWorkInt( meindex, NPC_WORK_CURRENTTIME) + + CHAR_getWorkInt( meindex, NPC_WORK_WAITTIME) + < NowTime.tv_sec) + { + /* SE Ѩƹ̫ */ + if( CHAR_getWorkInt( meindex, NPC_WORK_SEFLG )) { + //ANDY_reEdit + CHAR_sendSEoArroundCharacter( + CHAR_getInt( meindex, CHAR_FLOOR), + CHAR_getInt( meindex, CHAR_X), + CHAR_getInt( meindex, CHAR_Y), + npc_wave, + TRUE); + } + /* ݼ*/ + for( i = 1; i < CHAR_PARTYMAX; i ++ ) { + int partyindex = CHAR_getWorkInt( meindex, CHAR_WORKPARTYINDEX1+i); + if( CHAR_CHECKINDEX( partyindex)) { + NPC_AirSendMsg( meindex, partyindex, NPC_AIR_MSG_START); + } + } + + CHAR_setWorkInt( meindex, NPC_WORK_MODE,1); + /* Ѽëʻպ */ + CHAR_setInt( meindex, CHAR_LOOPINTERVAL, NPC_AIR_LOOPTIME); + } + return; + case 1: + /* */ + NPC_Air_walk( meindex); + case 2: + /* Ȼƹ */ + /* ޻׼ƥ */ + if( CHAR_getWorkInt( meindex, NPC_WORK_CURRENTTIME) + + (CHAR_getWorkInt( meindex, NPC_WORK_WAITTIME) /3) + < NowTime.tv_sec) + { + CHAR_setWorkInt( meindex, NPC_WORK_MODE,1); + /* Ѽëʻպ */ + CHAR_setInt( meindex, CHAR_LOOPINTERVAL, NPC_AIR_LOOPTIME); + + } + return; + case 3: + /* ƻ֣ͷʧ мб + * Ƴƥëľ֧ + */ + if( CHAR_getWorkInt( meindex, NPC_WORK_CURRENTTIME) + 3 < NowTime.tv_sec){ + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE - 1024 * 20]; + NPC_Util_GetArgStr( meindex, argstr, sizeof( argstr)); + CHAR_setInt( meindex, CHAR_LOOPINTERVAL, NPC_AIR_WAITINGMODE_WAITTIME); + { + int r = CHAR_getWorkInt( meindex, NPC_WORK_ROUTEMAX); + CHAR_setWorkInt( meindex, NPC_WORK_CURRENTROUTE, RAND( 1, r)); + } + CHAR_setWorkInt( meindex, NPC_WORK_ROUNDTRIP, + CHAR_getWorkInt( meindex, NPC_WORK_ROUNDTRIP)^1); + if( CHAR_getWorkInt( meindex, NPC_WORK_ROUNDTRIP) == 1) { + int num = NPC_AirGetRoutePointNum( meindex, argstr); + CHAR_setWorkInt( meindex, NPC_WORK_ROUTEPOINT, num-1); + }else { + CHAR_setWorkInt( meindex, NPC_WORK_ROUTEPOINT, + CHAR_getWorkInt( meindex, NPC_WORK_ROUTEPOINT) +1); + } + NPC_AirSetPoint( meindex, argstr); + NPC_AirSetDestPoint( meindex, argstr); + CHAR_DischargeParty( meindex, 0); + CHAR_setWorkInt( meindex, NPC_WORK_CURRENTTIME, NowTime.tv_sec); + if ((CHAR_getWorkInt(meindex, NPC_WORK_ONEWAYFLG) == 1) && + (CHAR_getWorkInt(meindex, NPC_WORK_ROUNDTRIP) == 1) ){ + CHAR_setInt( meindex, CHAR_LOOPINTERVAL, NPC_AIR_LOOPTIME); + CHAR_setWorkInt( meindex, NPC_WORK_MODE, 1); + } else + CHAR_setWorkInt( meindex, NPC_WORK_MODE, 0); + } + return; + default: + break; + } +} +/************************************** + * ʣ + **************************************/ +static void NPC_Air_walk( int meindex) +{ + POINT start, end; + int dir; + int ret; + int i; + int npc_wave = CHAR_getWorkInt( meindex, NPC_WORK_RUNWAVE ); + + /* */ + /* ݼ */ + start.x = CHAR_getInt( meindex, CHAR_X); + start.y = CHAR_getInt( meindex, CHAR_Y); + end.x = CHAR_getWorkInt( meindex, NPC_WORK_ROUTETOX); + end.y = CHAR_getWorkInt( meindex, NPC_WORK_ROUTETOY); + + /* ׼ƥݼ̼ */ + if( start.x == end.x && start.y == end.y ) { + int add = 1; + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE - 1024 * 20]; + + NPC_Util_GetArgStr( meindex, argstr, sizeof( argstr)); + + if( CHAR_getWorkInt( meindex, NPC_WORK_ROUNDTRIP ) == 1 ) { + add *= -1; + } + CHAR_setWorkInt( meindex, NPC_WORK_ROUTEPOINT, + CHAR_getWorkInt( meindex, NPC_WORK_ROUTEPOINT) +add); + if( NPC_AirSetPoint( meindex, argstr) == FALSE ) { + /* */ + /* ƹ */ + CHAR_setWorkInt( meindex, NPC_WORK_MODE,3); + + /* SE Ѩƹ̫ */ + if( CHAR_getWorkInt( meindex, NPC_WORK_SEFLG )) { + //ANDY_reEdit + CHAR_sendSEoArroundCharacter( + CHAR_getInt( meindex, CHAR_FLOOR), + CHAR_getInt( meindex, CHAR_X), + CHAR_getInt( meindex, CHAR_Y), + npc_wave, + TRUE); + } + /* ݼ*/ + for( i = 1; i < CHAR_PARTYMAX; i ++ ) { + int partyindex = CHAR_getWorkInt( meindex, CHAR_WORKPARTYINDEX1+i); + if( CHAR_CHECKINDEX( partyindex)) { + NPC_AirSendMsg( meindex, partyindex, NPC_AIR_MSG_END); +#ifdef CAX_RIDE_GENXIN + CHAR_DischargePartyNoMsg( partyindex);//ɢŶ + CHAR_setInt( partyindex, CHAR_RIDEPET, -1); + CHAR_send_P_StatusString( partyindex, CHAR_P_STRING_RIDEPET); +#endif + } + } + /* ػë */ + CHAR_setWorkInt( meindex, NPC_WORK_CURRENTTIME, NowTime.tv_sec); + return; + } + else { + return; + } + } + /*-------------------------------------------------------*/ + /* ھ */ + + /* ëƻ */ + dir = NPC_Util_getDirFromTwoPoint( &start,&end ); + + /* ɡ ūƥ */ + end.x = CHAR_getInt( meindex, CHAR_X); + end.y = CHAR_getInt( meindex, CHAR_Y); + + if( dir >= 0 && dir <= 7 ) { + /* */ + ret = CHAR_walk( meindex, dir, 0); + + if( ret == CHAR_WALKSUCCESSED ) { + /* лئëھ */ + int i; + int mefl=CHAR_getInt( meindex, CHAR_FLOOR); + for( i = 1; i < CHAR_PARTYMAX; i ++ ) { + int toindex = CHAR_getWorkInt( meindex, i + CHAR_WORKPARTYINDEX1); + int fl = CHAR_getInt( toindex, CHAR_FLOOR); + int xx = CHAR_getInt( toindex, CHAR_X); + int yy = CHAR_getInt( toindex, CHAR_Y); + if( CHAR_CHECKINDEX(toindex) && + (mefl==fl) && (abs(xx-end.x)+abs(yy-end.y)<10) ) { + int parent_dir; + /* Ҽ ʼ󡼰 ëƻ */ + /* */ + start.x = xx; + start.y = yy; + parent_dir = NPC_Util_getDirFromTwoPoint( &start,&end ); + /* ·ūë ¿б + * ݼҷ󡼰Ҽ ëܰ + */ + end = start; + if( parent_dir != -1 ) { + CHAR_walk( toindex, parent_dir, 0); + } + } + } + } + } +} +/************************************** + * ݼë + **************************************/ +static int NPC_AirSetPoint( int meindex, char *argstr) +{ + char buf[4096]; + char buf2[256]; + char buf3[256]; + int floor,warpx,warpy; + int ret; + char routetostring[64]; + + snprintf( routetostring, sizeof( routetostring), "routeto%d", + CHAR_getWorkInt( meindex, NPC_WORK_CURRENTROUTE)); + + if( NPC_Util_GetStrFromStrWithDelim( argstr, routetostring,buf, sizeof(buf)) + == NULL ) + { + print( "npcair:nothing route \n"); + return FALSE; + } + + ret = getStringFromIndexWithDelim( buf, ";", + CHAR_getWorkInt( meindex, NPC_WORK_ROUTEPOINT), + buf2, sizeof(buf2)); + if( ret == FALSE ) return FALSE; + + // Arminius: add floor + + ret = getStringFromIndexWithDelim( buf2, ",", 1, + buf3, sizeof(buf3)); + if( ret == FALSE) return FALSE; + floor = atoi(buf3); + + ret = getStringFromIndexWithDelim( buf2, ",", 2, + buf3, sizeof(buf3)); + if( ret == FALSE) return FALSE; + CHAR_setWorkInt( meindex, NPC_WORK_ROUTETOX, atoi( buf3)); + warpx = atoi(buf3); + + ret = getStringFromIndexWithDelim( buf2, ",", 3, + buf3, sizeof(buf3)); + if( ret == FALSE) return FALSE; + CHAR_setWorkInt( meindex, NPC_WORK_ROUTETOY, atoi( buf3)); + warpy = atoi(buf3); + + if (floor!=CHAR_getInt(meindex, CHAR_FLOOR)) { + int i; + CHAR_warpToSpecificPoint(meindex, floor, warpx, warpy); + + for( i = 1; i < CHAR_PARTYMAX; i ++ ) { + int toindex = CHAR_getWorkInt( meindex, i + CHAR_WORKPARTYINDEX1); + if( CHAR_CHECKINDEX(toindex) ) { + CHAR_warpToSpecificPoint(toindex, floor, warpx, warpy); + } + } + CHAR_setWorkInt( meindex, NPC_WORK_ROUTETOX, warpx); + CHAR_setWorkInt( meindex, NPC_WORK_ROUTETOY, warpy); + } + + return TRUE; +} +/************************************** + * route įգ 󡻥ؤչľë + * į屾£ + **************************************/ +static void NPC_AirSetDestPoint( int meindex, char *argstr) +{ + char buf[256]; + char routename[256]; + + snprintf( routename, sizeof( routename), "routename%d", + CHAR_getWorkInt( meindex, NPC_WORK_CURRENTROUTE)); + + if( NPC_Util_GetStrFromStrWithDelim( argstr, routename, buf, sizeof( buf)) + != NULL ) + { + CHAR_setChar( meindex, CHAR_OWNTITLE, buf); + CHAR_sendCToArroundCharacter( CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX)); + } +} +/************************************** + * ϶ýľʧ ةë Ȼ¾ + * Ȼշֻ + **************************************/ +static BOOL NPC_AirCheckDeniedItem( int meindex, int charaindex, char *argstr) +{ + char buf[1024]; + BOOL found = TRUE; + + if( NPC_Util_GetStrFromStrWithDelim( argstr, "denieditem", buf, sizeof( buf)) + != NULL ) + { + int i; + int ret; + for( i = 1; ; i ++) { + int itemid; + char buf2[64]; + int j; + ret = getStringFromIndexWithDelim( buf, ",", i, buf2, sizeof(buf2)); + if( ret == FALSE ) break; + itemid = atoi( buf2); + for( j = 0; j < CHAR_MAXITEMHAVE; j ++) { + int itemindex = CHAR_getItemIndex( charaindex, j); + if( ITEM_CHECKINDEX( itemindex)) { + if( ITEM_getInt( itemindex, ITEM_ID) == itemid) { + found = FALSE; + break; + } + } + } + } + } + return found; +} +/************************************** + * ϶ýľʧ ةë Ȼ¾ + * Ȼئֻ + **************************************/ +BOOL NPC_AirCheckAllowItem( int meindex, int charaindex, BOOL pickupmode) +{ + char buf[1024]; + BOOL found = TRUE; + BOOL pickup = FALSE; + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE - 1024 * 20]; + + NPC_Util_GetArgStr( meindex, argstr, sizeof( argstr)); + + if( NPC_Util_GetStrFromStrWithDelim( argstr, "pickupitem", buf, sizeof( buf)) + != NULL ) + { + pickup = TRUE; + } + if( NPC_Util_GetStrFromStrWithDelim( argstr, "allowitem", buf, sizeof( buf)) + != NULL ) + { + int i; + int ret; + for( i = 1; ; i ++) { + int itemid; + char buf2[64]; + int j; + BOOL getflg; + ret = getStringFromIndexWithDelim( buf, ",", i, buf2, sizeof(buf2)); + if( ret == FALSE ) break; + itemid = atoi( buf2); + getflg = FALSE; + for( j = 0; j < CHAR_MAXITEMHAVE; j ++) { + int itemindex = CHAR_getItemIndex( charaindex, j); + if( ITEM_CHECKINDEX( itemindex)) { + if( ITEM_getInt( itemindex, ITEM_ID) == itemid) { + /* Ȼ¾գݹʧ ةë */ + if( pickupmode && pickup && !getflg) { + CHAR_DelItem( charaindex, j); + getflg = TRUE; + } + break; + } + } + } + if( j == CHAR_MAXITEMHAVE) { + found = FALSE; + break; + } + } + } + return found; +} + +/************************************** + * ϶ýľìﶯ + **************************************/ +static BOOL NPC_AirCheckLevel( int meindex, int charaindex, char *argstr) +{ + int level; + + /* ئľئ¦Ѽ */ + level = NPC_Util_GetNumFromStrWithDelim( argstr, "needlevel"); + if( level == -1 ) { + return TRUE; + } + if( CHAR_getInt( charaindex, CHAR_LV) >= level ) return TRUE; + + return FALSE; +} + +/************************************** + * ë + * -1 0 ݾ ۢStone + **************************************/ +static int NPC_AirCheckStone( int meindex, int charaindex, char *argstr) +{ + int gold; + + /* ئľئ¦Ѽ */ + gold = NPC_Util_GetNumFromStrWithDelim( argstr, "needstone"); + if( gold == -1 ) { + return 0; + } + if( CHAR_getInt( charaindex, CHAR_GOLD) >= gold ) return gold; + + return -1; +} +/************************************** + * ë˪ + * ¦Ѽ⻥ئľɷɻë˪ + **************************************/ +static void NPC_AirSendMsg( int meindex, int talkerindex, int tablenum) +{ + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE - 1024 * 20]; + char buf[256]; + char msg[256]; + if( tablenum < 0 || tablenum >= arraysizeof( airmsg)) return; + + NPC_Util_GetArgStr( meindex, argstr, sizeof( argstr)); + + if( NPC_Util_GetStrFromStrWithDelim( argstr, airmsg[tablenum].option, buf, sizeof( buf)) + != NULL ) + { + strcpy( msg, buf); + } + else { + snprintf( msg, sizeof(msg),airmsg[tablenum].defaultmsg); + } + CHAR_talkToCli( talkerindex, meindex, msg, CHAR_COLORYELLOW); +} +/************************************** + * ƤP̼ë + **************************************/ +static int NPC_AirGetRoutePointNum( int meindex, char *argstr ) +{ + int i; + char buf[4096]; + char buf2[256]; + int ret; + char routetostring[64]; + + snprintf( routetostring, sizeof( routetostring), "routeto%d", + CHAR_getWorkInt( meindex, NPC_WORK_CURRENTROUTE)); + + if( NPC_Util_GetStrFromStrWithDelim( argstr, routetostring,buf, sizeof(buf)) + == NULL ) + { + print( "npcair:nothing route \n"); + return -1; + } + for( i = 1; ; i ++ ) { + ret = getStringFromIndexWithDelim( buf, ";", i, buf2, sizeof(buf2)); + if( ret == FALSE) break; + } + return( i -1); +} +BOOL NPC_AirCheckJoinParty( int meindex, int charaindex, BOOL msgflg) +{ + //int fd; + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE - 1024 * 20]; + int ret; + NPC_Util_GetArgStr( meindex, argstr, sizeof( argstr)); + + /* */ + if( !NPC_Util_charIsInFrontOfChar( charaindex, meindex, 1 )) return FALSE; + /* ַ */ + if( CHAR_getWorkInt( meindex, NPC_WORK_MODE) != 0 ) { + if( msgflg) NPC_AirSendMsg( meindex, charaindex, NPC_AIR_MSG_GETTINGON); + return FALSE; + } + /* շֻ */ + if( CHAR_getWorkInt( charaindex, CHAR_WORKPARTYMODE ) != CHAR_PARTY_NONE) { + if( msgflg) NPC_AirSendMsg( meindex, charaindex, NPC_AIR_MSG_NOTPARTY); + return FALSE; + } + /* ɡ ūë */ + if( CHAR_getEmptyPartyArray( meindex) == -1 ) { + if( msgflg) NPC_AirSendMsg( meindex, charaindex, NPC_AIR_MSG_OVERPARTY); + return FALSE; + } + /* ʧ ةë(ʧ ة) */ + if( !NPC_AirCheckDeniedItem( meindex, charaindex, argstr)) { + if( msgflg) NPC_AirSendMsg( meindex, charaindex, NPC_AIR_MSG_DENIEDITEM); + return FALSE; + } +#ifdef _ITEM_CHECKWARES + if( CHAR_CheckInItemForWares( charaindex, 0) == FALSE ) { + CHAR_talkToCli( charaindex, -1, "޷Яϻ", CHAR_COLORYELLOW); + return FALSE; + } +#endif + + /* ʧ ةë( ۢʧ ة) */ + if( !NPC_AirCheckAllowItem( meindex, charaindex, FALSE)) { + if( msgflg) NPC_AirSendMsg( meindex, charaindex, NPC_AIR_MSG_ALLOWITEM); + return FALSE; + } + /* ìPë */ + if( !NPC_AirCheckLevel( meindex, charaindex, argstr)) { + if( msgflg) NPC_AirSendMsg( meindex, charaindex, NPC_AIR_MSG_LEVEL); + return FALSE; + } + /* ì */ +// if( CHAR_getInt( charaindex, CHAR_NOWEVENT) != 0 || +// CHAR_getInt( charaindex, CHAR_NOWEVENT2) != 0 || +// CHAR_getInt( charaindex, CHAR_NOWEVENT3) != 0 ) +// { +// if( msgflg) NPC_AirSendMsg( meindex, charaindex, NPC_AIR_MSG_EVENT); +// return FALSE; +// } + /* żë ë¼ƥ ͱ³ */ + ret = NPC_AirCheckStone( meindex, charaindex, argstr); + if( ret == -1 ) { + if( msgflg) NPC_AirSendMsg( meindex, charaindex, NPC_AIR_MSG_GOLD); + return FALSE; + } + if( ret != 0 ) { + char msgbuf[128]; + /* ë */ + CHAR_setInt( charaindex, CHAR_GOLD, + CHAR_getInt( charaindex, CHAR_GOLD) - ret); + /* ˪ */ + CHAR_send_P_StatusString( charaindex, CHAR_P_STRING_GOLD); + snprintf( msgbuf, sizeof( msgbuf), "֧%d Stone", ret); + CHAR_talkToCli( charaindex, -1, msgbuf, CHAR_COLORYELLOW); + } + /* ɡ ū */ + //CHAR_JoinParty_Main( charaindex, meindex); + + //fd = getfdFromCharaIndex( charaindex ); + + //lssproto_PR_send( fd, 1, 1); + + return TRUE; +} diff --git a/npc/npc_alldoman.c b/npc/npc_alldoman.c new file mode 100644 index 0000000..b024bf2 --- /dev/null +++ b/npc/npc_alldoman.c @@ -0,0 +1,392 @@ +#include "version.h" +#include +#include +#include +#include "object.h" +#include "char_base.h" +#include "char.h" +#include "util.h" +#include "npcutil.h" +#include "item.h" +#include "readmap.h" +#include "enemy.h" +#include "chatmagic.h" +#include "log.h" +#include "npc_itemchange.h" +#include "lssproto_serv.h" +#include "saacproto_cli.h" +#include "npc_eventaction.h" +#include "npc_charm.h" + +#ifdef _ALLDOMAN +#include "npc_alldoman.h" + +#define MAX_HERO_COLUMN 7 +#define MAX_HERO_LIST 100 +char Herolist[MAX_HERO_LIST][MAX_HERO_COLUMN][72]; + +int sort[MAX_HERO_LIST][2]; +int countnum = -1 ; +int showpage = 1 ; +int totalpage = 1; + +static void NPC_Alldoman_selectWindow( int meindex, int talker, int seqno,char *data); + +void NPC_AlldomanWindowTalked(int meindex, int talkerindex, int seqno, int select,char *data) +{ + char buf2[256]; + char buf[256]; + int i; + int playernum = CHAR_getPlayerMaxNum(); + //andy_log + print( "seqno:%d\n", seqno); + switch(seqno) + { + case NPC_ALLDOMAN_MAIN_WND: + if ( select == WINDOW_BUTTONTYPE_NEXT ) { + showpage ++ ; + NPC_Alldoman_selectWindow(meindex , talkerindex , 4 ,""); + } + if ( select == WINDOW_BUTTONTYPE_OK ) { + //CHAR_talkToCli(talkerindex,meindex,"ˣ",CHAR_COLORRED); + showpage = 1 ; + NPC_Alldoman_selectWindow(meindex , talkerindex, 5 ,""); + } + break; + case NPC_ALLDOMAN_SELECT_WND: + if(atoi(data)==2) { + //CHAR_talkToCli(talkerindex,meindex,"",CHAR_COLORRED); + if ( CHAR_getInt( talkerindex , CHAR_FLOOR ) != 8200 ) { + CHAR_talkToCli(talkerindex,-1,"ֻܸӢۿд",CHAR_COLORRED); + break; + } + if ( CHAR_getWorkInt( talkerindex , CHAR_WORKHEROFLOOR ) > 132 || + CHAR_getWorkInt( talkerindex , CHAR_WORKHEROFLOOR ) <= 0 ) { + CHAR_setWorkInt( talkerindex , CHAR_WORKHEROFLOOR , 0 ) ; + CHAR_talkToCli(talkerindex,-1,"ֻܸӢۿд",CHAR_COLORRED); + break; + } + sprintf( buf2 , "ó˴%3d֤ͼԼʯ" , CHAR_getWorkInt( talkerindex , CHAR_WORKHEROFLOOR ) ); + CHAR_talkToCli(talkerindex,-1,buf2,CHAR_COLORRED); + if ( CHAR_getWorkInt( talkerindex , CHAR_WORKHEROFLOOR ) == 132 ) { + sprintf( buf2 , "%s" , "˹½Ӣ" ) ; + //ﶥȫϵ㲥 + sprintf( buf , "%sӢսɷ֮齫Ϣ֪ͨȫ磬µӢ۵!!" , CHAR_getChar( talkerindex, CHAR_NAME ) ); + for( i = 0 ; i < playernum ; i++) { + if( CHAR_getCharUse(i) != FALSE ) { + CHAR_talkToCli( i, -1, buf, CHAR_COLORBLUE2); + } + } + } + else if ( CHAR_getWorkInt( talkerindex , CHAR_WORKHEROFLOOR ) >= 130 ) + sprintf( buf2 , "%s" , "˹½սʿ" ) ; + else if ( CHAR_getWorkInt( talkerindex , CHAR_WORKHEROFLOOR ) >= 125 ) + sprintf( buf2 , "%s" , "˹½ʿ" ) ; + else if ( CHAR_getWorkInt( talkerindex , CHAR_WORKHEROFLOOR ) >= 120 ) + sprintf( buf2 , "%s" , "˹Ӣ" ) ; + else if ( CHAR_getWorkInt( talkerindex , CHAR_WORKHEROFLOOR ) >= 115 ) + sprintf( buf2 , "%s" , "˹ʹսʿ" ) ; + else if ( CHAR_getWorkInt( talkerindex , CHAR_WORKHEROFLOOR ) >= 110 ) + sprintf( buf2 , "%s" , "ķսʿ" ) ; + else if ( CHAR_getWorkInt( talkerindex , CHAR_WORKHEROFLOOR ) >= 100 ) + sprintf( buf2 , "%s" , "˿սʿ" ) ; + else if ( CHAR_getWorkInt( talkerindex , CHAR_WORKHEROFLOOR ) >= 80 ) + sprintf( buf2 , "%s" , "̹սʿ" ) ; + else if ( CHAR_getWorkInt( talkerindex , CHAR_WORKHEROFLOOR ) >= 60 ) + sprintf( buf2 , "%s" , "ضսʿ" ) ; + else if ( CHAR_getWorkInt( talkerindex , CHAR_WORKHEROFLOOR ) >= 40 ) + sprintf( buf2 , "%s" , "ħʿ" ) ; + else if ( CHAR_getWorkInt( talkerindex , CHAR_WORKHEROFLOOR ) >= 20 ) + sprintf( buf2 , "%s" , "ʥʿ" ) ; + else if ( CHAR_getWorkInt( talkerindex , CHAR_WORKHEROFLOOR ) >= 1 ) + sprintf( buf2 , "%s" , "ʿ" ) ; + else + sprintf( buf2 , " " ); + saacproto_UpdataStele_send ( + acfd , + CHAR_getChar( talkerindex , CHAR_CDKEY ), + CHAR_getChar( talkerindex , CHAR_NAME ) , + buf2 , + CHAR_getInt( talkerindex , CHAR_LV ) , + CHAR_getInt( talkerindex , CHAR_TRANSMIGRATION) , + 10 , + CHAR_getWorkInt( talkerindex , CHAR_WORKHEROFLOOR ) + ) ; + //WorkFloor + CHAR_setWorkInt( talkerindex , CHAR_WORKHEROFLOOR , 0 ) ; + } + if(atoi(data)==4) { + //CHAR_talkToCli(talkerindex,meindex,"",CHAR_COLORRED); + showpage = 1 ; + NPC_Alldoman_selectWindow(meindex , talkerindex, 6 ,""); + } + if(atoi(data)==6) { + //CHAR_talkToCli(talkerindex,meindex,"",CHAR_COLORRED); + } + break; + case NPC_ALLDOMAN_LIST_WND: + if( select == WINDOW_BUTTONTYPE_OK ){ + print("\nSyu log FloorWorkint => %d" , CHAR_getWorkInt( talkerindex , CHAR_WORKHEROFLOOR )); + } + if( select == WINDOW_BUTTONTYPE_PREV && showpage > 1 ) { + showpage -- ; + NPC_Alldoman_selectWindow(meindex , talkerindex, 6 ,"" ); + } + if( select == WINDOW_BUTTONTYPE_NEXT && showpage < totalpage ) { + showpage ++ ; + NPC_Alldoman_selectWindow(meindex , talkerindex, 6 ,""); + } + break; + } +} + +static void NPC_Alldoman_selectWindow( int meindex, int talker, int num, char *data) +{ + int buttontype = 0,windowtype = 0,windowno = 0 , i ; + int fd = getfdFromCharaIndex( talker); + char token[1024]; + char token2[100 * 100]; + + + //andy_log + print( "NPC_Alldoman_selectWindow( num:%d)\n", num); + switch(num) + { + case 4: + if ( showpage == 1 ) { + buttontype = WINDOW_BUTTONTYPE_NEXT; + sprintf( token, "ʥʱ³ִУ֮һ⣬˹ijϴɹʶʿǰȺĻȺʿںڸȺսϣʵ⣬ʿأʿѡڻضͨ·"); + } + else if ( showpage == 2 ) { + buttontype = WINDOW_BUTTONTYPE_NEXT; + sprintf( token, "ĵĵֿ峤ټͨ³ĺͨڴӿǰڷ˵Ϊʥʱ죬Ϊʥʱʿʯ˵ضΪӢսЧҵоﵽǿǿ"); + } + else if ( showpage == 3) { + buttontype = WINDOW_BUTTONTYPE_OK; + sprintf( token, "ΪĿģ˹½ϢӢ´Ӣսģشگȫ˹Ӣۣ\n\n ӢսίԱ"); + } + windowtype = WINDOW_MESSAGETYPE_MESSAGE; + windowno = NPC_ALLDOMAN_MAIN_WND; + lssproto_WN_send(fd, windowtype, buttontype, windowno, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), token ); + break; + case 5: + buttontype = WINDOW_BUTTONTYPE_NONE; + windowtype = WINDOW_MESSAGETYPE_SELECT; + windowno = NPC_ALLDOMAN_SELECT_WND; + sprintf(token, + "0\n\n дʯ" + "\n\n " + "\n\n ȡ" + ); + lssproto_WN_send( fd, windowtype, buttontype, windowno, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX),token); + break; + case 6: + if ( totalpage != 1 && showpage == 1 ) + buttontype = WINDOW_BUTTONTYPE_OK | WINDOW_BUTTONTYPE_NEXT; + else if ( totalpage == 1 ) + buttontype = WINDOW_BUTTONTYPE_OK ; + else if ( totalpage != 1 && showpage == totalpage ) + buttontype = WINDOW_BUTTONTYPE_OK | WINDOW_BUTTONTYPE_PREV; + else if ( totalpage != 1 && showpage != 1 && showpage != totalpage ) + buttontype = WINDOW_BUTTONTYPE_OK | WINDOW_BUTTONTYPE_PREV | WINDOW_BUTTONTYPE_NEXT; + windowtype = WINDOW_MESSAGETYPE_WIDEMESSAGEANDLINEINPUT; + windowno = NPC_ALLDOMAN_LIST_WND; + sprintf ( token2 , " ͷ ¥ ȼ ת\n"); + for ( i=0+(showpage-1 )*15; i 1) return; + if( NPC_Util_isFaceToFace( talker, meindex , 1 ) == FALSE ) return; + showpage = 1 ; + NPC_Alldoman_selectWindow(meindex, talker , 4 ,""); +} +void NPC_AlldomanWriteStele ( char *token ) +{ + + int linenum = 0 , i , flag , temp , temp1 , j ; + int lens=0; + char *addr; + if( token == NULL || (lens = strlen( token)) <= 0 ) return; + while( linenum < 100 ){ + for ( i = 0 ; i < MAX_HERO_COLUMN ; i ++ ) { + if( getStringFromIndexWithDelim( token, "|", i + 1 , Herolist[ linenum ][ i ] , sizeof( Herolist[ linenum ][ i ] ) ) == FALSE ){ +#ifdef _ALLDOMAN_DEBUG + countnum = 0 ; + for ( i = 0 ; i < MAX_HERO_LIST ; i ++ ) { + sort[i][0] = atoi ( Herolist[i][6] ) ; + sort[i][1] = i ; + if ( sort[i][0] != 0 && sort[i][0] != -1 ) + countnum ++ ; + } + + for ( i = 0 ; i < MAX_HERO_LIST - 1 ; i ++ ) { + flag = 0 ; + for ( j = 0 ; j < MAX_HERO_LIST - 1 ; j ++ ) { + if ( sort[j][0] > sort[j+1][0] ){ + flag = 1 ; + temp = sort[j][0]; + temp1 = sort[j][1]; + sort[j][0] = sort[j + 1][0]; + sort[j][1] = sort[j + 1][1]; + sort[j+1][0] = temp; + sort[j+1][1] = temp1; + } + } + if ( flag != 1 ) + break; + } + totalpage = countnum / 15 ; + if ( ( countnum % 15 ) != 0 ) + totalpage ++; +#endif + return; + } + } + linenum ++; + + if ( (addr = strstr ( token , "\n" )) == NULL ) break; + strcpy ( token , addr + 1 ) ; + if( token == NULL || (lens = strlen( token)) <= 0 ) { +#ifdef _ALLDOMAN_DEBUG + countnum = 0 ; + for ( i = 0 ; i < MAX_HERO_LIST ; i ++ ) { + sort[i][0] = atoi ( Herolist[i][6] ) ; + sort[i][1] = i ; + if ( sort[i][0] != 0 && sort[i][0] != -1 ) + countnum ++ ; + } + for ( i = 0 ; i < MAX_HERO_LIST - 1 ; i ++ ) { + flag = 0 ; + for ( j = 0 ; j < MAX_HERO_LIST - 1 ; j ++ ) { + if ( sort[j][0] > sort[j+1][0] ){ + flag = 1 ; + temp = sort[j][0]; + temp1 = sort[j][1]; + sort[j][0] = sort[j + 1][0]; + sort[j][1] = sort[j + 1][1]; + sort[j+1][0] = temp; + sort[j+1][1] = temp1; + } + } + if ( flag != 1 ) + break; + } + totalpage = countnum / 15 ; + if ( ( countnum % 15 ) != 0 ) + totalpage ++; +#endif + return; + } + } + + countnum = 0 ; + for ( i = 0 ; i < MAX_HERO_LIST ; i ++ ) { + sort[i][0] = atoi ( Herolist[i][6] ) ; + sort[i][1] = i ; + if ( sort[i][0] != 0 && sort[i][0] != -1 ) + countnum ++ ; + } + + for ( i = 0 ; i < MAX_HERO_LIST - 1 ; i ++ ) { + flag = 0 ; + for ( j = 0 ; j < MAX_HERO_LIST - 1 ; j ++ ) { + if ( sort[j][0] > sort[j+1][0] ){ + flag = 1 ; + temp = sort[j][0]; + temp1 = sort[j][1]; + sort[j][0] = sort[j + 1][0]; + sort[j][1] = sort[j + 1][1]; + sort[j+1][0] = temp; + sort[j+1][1] = temp1; + } + } + if ( flag != 1 ) + break; + } + + + totalpage = countnum / 15 ; + if ( ( countnum % 15 ) != 0 ) + totalpage ++; +//#endif +} + +void NPC_Alldoman_S_WriteStele( char *ocdkey , char *oname , char *ncdkey , + char *nname , char *title , int level , int trns , int floor ) +{ + int i , j , temp , temp1 , flag ; + for ( i = 0 ; i < MAX_HERO_COLUMN ; i ++ ) { + if ( ( strcmp( Herolist[i][0] , ocdkey ) == 0 ) && ( strcmp( Herolist[i][1] , oname ) == 0 ) ) { + sprintf( Herolist[i][0] , "%s" , ncdkey ) ; + sprintf( Herolist[i][1] , "%s" , nname ) ; + sprintf( Herolist[i][2] , "%s" , title ) ; + sprintf( Herolist[i][3] , "%d" , level ) ; + sprintf( Herolist[i][4] , "%d" , trns ) ; + sprintf( Herolist[i][6] , "%d" , floor ) ; + break; + } + } + countnum = 0 ; + for ( i = 0 ; i < MAX_HERO_LIST ; i ++ ) { + sort[i][0] = atoi ( Herolist[i][6] ) ; + sort[i][1] = i ; + if ( sort[i][0] != 0 && sort[i][0] != -1 ) + countnum ++ ; + } + for ( i = 0 ; i < MAX_HERO_LIST - 1 ; i ++ ) { + flag = 0 ; + for ( j = 0 ; j < MAX_HERO_LIST - 1 ; j ++ ) { + if ( sort[j][0] > sort[j+1][0] ){ + flag = 1 ; + temp = sort[j][0]; + temp1 = sort[j][1]; + sort[j][0] = sort[j + 1][0]; + sort[j][1] = sort[j + 1][1]; + sort[j+1][0] = temp; + sort[j+1][1] = temp1; + } + } + if ( flag != 1 ) + break; + } + totalpage = countnum / 15 ; + if ( ( countnum % 15 ) != 0 ) + totalpage ++ ; +} + +#endif + diff --git a/npc/npc_auctioneer.c b/npc/npc_auctioneer.c new file mode 100644 index 0000000..e69de29 diff --git a/npc/npc_autopk.c b/npc/npc_autopk.c new file mode 100644 index 0000000..a6e7d4b --- /dev/null +++ b/npc/npc_autopk.c @@ -0,0 +1,992 @@ +#include "version.h" +#include +#include "char.h" +#include "object.h" +#include "char_base.h" +#include "npcutil.h" +#include "npc_autopk.h" +#include "lssproto_serv.h" +#include "saacproto_cli.h" +#include "readmap.h" +#include "battle.h" +#include "log.h" +#include "enemy.h" +#include "handletime.h" +#include "npc_eventaction.h" +#include "npc_healer.h" +#include "configfile.h" + +#ifdef _GMRELOAD + extern struct GMINFO gminfo[GMMAXNUM]; +#endif +#ifdef _JOB_AUTOPK + extern int jobautopk; +#endif +#ifdef _AUTO_PK + +#define AWARDNO (1 << 0) +#define AWARDPET (1 << 1) +#define AWARDITEM (1 << 2) +#define AWARDALL (AWARDPET|AWARDITEM) + +enum { + WINDOW_START=1, + WINDOW_SELECT, + WINDOW_JOINPK, + WINDOW_PKLIST, + WINDOW_PKINFO, + WINDOW_HISTORY, + WINDOW_HISTORY_NEXT, + WINDOW_HISTORY_PREV, + WINDOW_END, +}; + +typedef struct tagautopk +{ + int winnum; + char cdkey[CDKEYLEN]; + char name[CHARNAMELEN]; +}Autopk; + +typedef struct tagaward +{ + int awardpetid; + int awarditemid; + char awardpet[32]; + char awarditem[32]; + int draw; +}Award; + +static int baward = FALSE; + +Award award[5]; + +Autopk ship[5]; + +int autopklist; +static int autopktime=-1; +static int awardpetid=-1; +static int awarditemid=-1; +static char awardpet[32]; +static char awarditem[32]; +int autopkstart=0; +int autopkcnt=0; +int autopktype = 0; +enum { + NPC_WORK_CURRENTTIME = CHAR_NPCWORKINT1, + NPC_WORK_TIMEFLAG = CHAR_NPCWORKINT9, +/* + NPC_WORK_ROUTETOY = CHAR_NPCWORKINT2, + NPC_WORK_ROUTEPOINT = CHAR_NPCWORKINT3, + NPC_WORK_ROUNDTRIP = CHAR_NPCWORKINT4, + NPC_WORK_MODE = CHAR_NPCWORKINT5, + NPC_WORK_CURRENTROUTE = CHAR_NPCWORKINT6, + NPC_WORK_ROUTEMAX = CHAR_NPCWORKINT7, + NPC_WORK_WAITTIME = CHAR_NPCWORKINT8, + NPC_WORK_CURRENTTIME = CHAR_NPCWORKINT9, + NPC_WORK_SEFLG = CHAR_NPCWORKINT10, +*/ +}; +enum { + NPC_AUTOPK_START, + NPC_AUTOPK_SELECT, + NPC_AUTOPK_JOINPK, + NPC_AUTOPK_PKLIST, + NPC_AUTOPK_PKAWARD, + NPC_AUTOPK_HISTORY, + NPC_AUTOPK_OK, + NPC_AUTOPK_END, +}; +#define STANDBYTIME 50 + +static void NPC_AutoPk_selectWindow( int meindex, int toindex, int num,int select); +BOOL AutoPk_GetHistoryStr( char *token, int page ); +void AutoPk_PKNum( char *token ); +BOOL AutoPk_AddItem( int charindex, int index ); +BOOL AutoPk_AddPet( int charindex, int index ); + +BOOL NPC_AutoPkInit( int meindex ) +{ + char npcarg[NPC_UTIL_GETARGSTR_BUFSIZE]; + + if(NPC_Util_GetArgStr( meindex, npcarg, sizeof(npcarg))==NULL){ + print("TRANSER_MAN: GetArgStrErr!!"); + return FALSE; + } + +// CHAR_setInt( meindex, CHAR_WHICHTYPE, CHAR_TRANSERMANS); + + //CHAR_setInt( meindex, CHAR_LOOPINTERVAL, NEWNPCMAN_STANDBY); + CHAR_setWorkInt( meindex, NPC_WORK_CURRENTTIME, NowTime.tv_sec); + return TRUE; +} +//CHAR_setWorkInt(talkerindex,CHAR_WORKSHOPRELEVANT,1); +void NPC_AutoPkTalked( int meindex, int talkerindex, char *msg, int color ) +{ + if( CHAR_getInt( talkerindex , CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER ) + return; + if(NPC_Util_isFaceToFace( meindex ,talkerindex , 2) == FALSE) { + if(NPC_Util_isFaceToChara( talkerindex, meindex, 1) == FALSE) + return; + } + + CHAR_setWorkInt( talkerindex, CHAR_WORKSHOPRELEVANT, 0); + NPC_AutoPk_selectWindow( meindex, talkerindex, WINDOW_START, 0); +} + +void NPC_AutoPkWindowTalked( int meindex, int talkerindex, int seqno, + int select, char *data) +{ + char jiangbuf[256]; + memset(jiangbuf, 0, sizeof(jiangbuf)); + if( select == WINDOW_BUTTONTYPE_CANCEL || select == WINDOW_BUTTONTYPE_NO) + return; + switch( seqno) { + case NPC_AUTOPK_START: + break; + case NPC_AUTOPK_SELECT: + NPC_AutoPk_selectWindow( meindex, talkerindex, WINDOW_SELECT, atoi( data)); + break; + case NPC_AUTOPK_JOINPK: + if(autopktime>2 +#ifdef _JOB_AUTOPK + && CHAR_getInt( talkerindex, PROFESSION_CLASS ) == jobautopk +#endif + ){ + char buf1[128]; + char buf2[255]; + int i; + if(CHAR_getInt(talkerindex,CHAR_LV)0){ + AutoPk_PKSystemTalk(jiangbuf,jiangbuf); + } +// if(!strcmp(ship[3].cdkey, CHAR_getChar( talkerindex, CHAR_CDKEY)) +// && !strcmp(ship[3].name, CHAR_getChar( talkerindex, CHAR_NAME))){ +// if((award[3].draw&AWARDPET)!=AWARDPET) +// if(AutoPk_AddPet( talkerindex, 3 )) +// award[3].draw=award[3].draw|AWARDPET; +// if((award[3].draw&AWARDITEM)!=AWARDITEM) +// if(AutoPk_AddItem( talkerindex, 3 )) +// award[3].draw=award[3].draw|AWARDITEM; +// }else if(!strcmp(ship[4].cdkey, CHAR_getChar( talkerindex, CHAR_CDKEY)) +// && !strcmp(ship[4].name, CHAR_getChar( talkerindex, CHAR_NAME))){ +// if((award[4].draw&AWARDPET)!=AWARDPET) +// if(AutoPk_AddPet( talkerindex, 4 )) +// award[4].draw=award[4].draw|AWARDPET; +// if((award[4].draw&AWARDITEM)!=AWARDITEM) +// if(AutoPk_AddItem( talkerindex, 4 )) +// award[4].draw=award[4].draw|AWARDITEM; +// } + break; + case NPC_AUTOPK_HISTORY: + if( select == WINDOW_BUTTONTYPE_CANCEL ) + return; + if( select == WINDOW_BUTTONTYPE_NEXT ) + { + NPC_AutoPk_selectWindow( meindex, talkerindex, WINDOW_HISTORY_NEXT, atoi( data)); + return; + } + if( select == WINDOW_BUTTONTYPE_PREV ) + { + NPC_AutoPk_selectWindow( meindex, talkerindex, WINDOW_HISTORY_PREV, atoi( data)); + return; + } + break; + case NPC_AUTOPK_OK: + break; + case NPC_AUTOPK_END: + NPC_AutoPk_selectWindow( meindex, talkerindex, WINDOW_END, atoi( data)); + break; + } +} + +static void NPC_AutoPk_selectWindow( int meindex, int toindex, int num,int select) +{ + char npcarg[NPC_UTIL_GETARGSTR_BUFSIZE]; + char token[256]; + int buttontype = 0, windowtype = 0, windowno = 0; + int fd = getfdFromCharaIndex( toindex); + if(NPC_Util_isFaceToFace( meindex ,toindex , 2) == FALSE) { + if(NPC_Util_isFaceToChara( toindex, meindex, 1) == FALSE) + return; + } + + memset( npcarg, 0, sizeof( npcarg)); + if(NPC_Util_GetArgStr( meindex, npcarg, sizeof(npcarg))==NULL){ + print("TRANSER_MAN: GetArgStrErr!!"); + return; + } + memset( token, 0, sizeof( token)); + + switch( num) { + case WINDOW_START: + sprintf(token, "3\n񶷣УԱ\n\n" + "ʲôҪΪء\n" + "Ҫμӱ\n" + "鿴ѡ֡\n" + "ȡƷ\n" + "ʷ¼\n" + "ۿ"); + CHAR_setWorkInt( toindex, CHAR_WORKSHOPRELEVANT, WINDOW_START); + windowtype = WINDOW_MESSAGETYPE_SELECT; + buttontype = WINDOW_BUTTONTYPE_CANCEL; + windowno = NPC_AUTOPK_SELECT; + break; + case WINDOW_SELECT: + windowtype = WINDOW_MESSAGETYPE_MESSAGE; + if(select==1){ + if(autopktime>2){ + sprintf(token, " 񶷣УԱ\n\n" + "ǰʼʱ仹ʣ%dӣһ׼",autopktime); + buttontype = WINDOW_BUTTONTYPE_YESNO; + windowno = NPC_AUTOPK_JOINPK; + }else if(autopktime>0){ + sprintf(token, "񶷣УԱ\n\n" + "PK%dӺʼ!\n޷أ\n\nPS޷볡أ볡硣",autopktime); + buttontype = WINDOW_BUTTONTYPE_CANCEL; + }else{ + sprintf(token, " 񶷣УԱ\n\n" + "ĿǰδٰУ˱\n עУ˱Ϣ\n עٷ̳\n ʯ ʱ \n\n PS޷볡"); + buttontype = WINDOW_BUTTONTYPE_CANCEL; + } + }else if(select==2){ + sprintf(token, "񶷣У\n"); + strcat(token, "תȼҡ\n"); + AutoPk_PKNum(token); + buttontype = WINDOW_BUTTONTYPE_CANCEL; + windowno = NPC_AUTOPK_PKLIST; + }else if(select==3){ + AutoPk_GetAwardStr(); + char buff[64]; + sprintf(token, "񶷣УƷȡ\nʤڱȡ\n\n");; +// if(strlen(award[0].awardpet)>0) +// sprintf(buff, "ھ%s\n", award[0].awardpet); +// else +// sprintf(buff, "ھ\n"); +// strcat(token, buff); + if(strlen(award[0].awarditem)>0) + sprintf(buff, " %s\n", award[0].awarditem); + else + sprintf(buff, " \n"); + strcat(token, buff); +// if(strlen(award[1].awardpet)>0) +// sprintf(buff, "Ǿ%s\n", award[1].awardpet); +// else +// sprintf(buff, "Ǿ\n"); +// strcat(token, buff); + if(strlen(award[1].awarditem)>0) + sprintf(buff, " %s\n", award[1].awarditem); + else + sprintf(buff, " \n"); + strcat(token, buff); +// if(strlen(award[2].awardpet)>0) +// sprintf(buff, "%s\n", award[2].awardpet); +// else +// sprintf(buff, "\n"); +// strcat(token, buff); + if(strlen(award[2].awarditem)>0) + sprintf(buff, " %s\n", award[2].awarditem); + else + sprintf(buff, " \n"); + strcat(token, buff); + strcat(token,"\nΰɱ㣬ɱҪѸŶ"); +// if(strlen(award[3].awardpet)>0) +// sprintf(buff, "ʤ%s\n", award[3].awardpet); +// else +// sprintf(buff, "ʤ\n"); +// strcat(token, buff); +// if(strlen(award[3].awarditem)>0) +// sprintf(buff, "ʤƷ%s\n", award[3].awarditem); +// else +// sprintf(buff, "ʤƷ\n"); +// strcat(token, buff); +// if(strlen(award[4].awardpet)>0) +// sprintf(buff, "ʤ%s\n", award[4].awardpet); +// else +// sprintf(buff, "ʤ\n"); +// strcat(token, buff); +// if(strlen(award[4].awarditem)>0) +// sprintf(buff, "ʤƷ%s\n", award[4].awarditem); +// else +// sprintf(buff, "ʤƷ\n"); +// strcat(token, buff); + if(baward && (!strcmp(ship[0].cdkey, CHAR_getChar( toindex, CHAR_CDKEY)) + && !strcmp(ship[0].name, CHAR_getChar( toindex, CHAR_NAME)) + && (award[0].draw&AWARDITEM)!=AWARDITEM) + || (!strcmp(ship[1].cdkey, CHAR_getChar( toindex, CHAR_CDKEY)) + && !strcmp(ship[1].name, CHAR_getChar( toindex, CHAR_NAME)) + && (award[1].draw&AWARDITEM)!=AWARDITEM) + || (!strcmp(ship[2].cdkey, CHAR_getChar( toindex, CHAR_CDKEY)) + && !strcmp(ship[2].name, CHAR_getChar( toindex, CHAR_NAME)) + && (award[2].draw&AWARDITEM)!=AWARDITEM) && autopktype == 0) + buttontype = WINDOW_BUTTONTYPE_YESNO; + else + buttontype = WINDOW_BUTTONTYPE_CANCEL; + windowno = NPC_AUTOPK_PKAWARD; + }else if(select==4){ + CHAR_setWorkInt( toindex, CHAR_WORKLISTPAGE, 1); + if(AutoPk_GetHistoryStr(token,CHAR_getWorkInt( toindex, CHAR_WORKLISTPAGE))) + buttontype = WINDOW_BUTTONTYPE_CANCEL; + else + buttontype = WINDOW_BUTTONTYPE_CANCEL|WINDOW_BUTTONTYPE_NEXT; + windowno = NPC_AUTOPK_HISTORY; + }else if(select==5){ + CHAR_talkToCli( toindex, -1, "[ʾ]ʼ뵽ҽԺ<Զ̹սԱ>鿴Ŷ", CHAR_COLORRED ); + return; + } + break; + case WINDOW_HISTORY_NEXT: + windowtype = WINDOW_MESSAGETYPE_MESSAGE; + CHAR_setWorkInt( toindex, CHAR_WORKLISTPAGE,CHAR_getWorkInt( toindex, CHAR_WORKLISTPAGE)+1); + if(AutoPk_GetHistoryStr(token,CHAR_getWorkInt( toindex, CHAR_WORKLISTPAGE))) + buttontype = WINDOW_BUTTONTYPE_CANCEL|WINDOW_BUTTONTYPE_PREV; + else + buttontype = WINDOW_BUTTONTYPE_CANCEL|WINDOW_BUTTONTYPE_PREV|WINDOW_BUTTONTYPE_NEXT; + windowno = NPC_AUTOPK_HISTORY; + break; + case WINDOW_HISTORY_PREV: + windowtype = WINDOW_MESSAGETYPE_MESSAGE; + CHAR_setWorkInt( toindex, CHAR_WORKLISTPAGE,CHAR_getWorkInt( toindex, CHAR_WORKLISTPAGE)-1); + if(CHAR_getWorkInt( toindex, CHAR_WORKLISTPAGE)<1)CHAR_setWorkInt( toindex, CHAR_WORKLISTPAGE,1); + if(AutoPk_GetHistoryStr(token,CHAR_getWorkInt( toindex, CHAR_WORKLISTPAGE)) || CHAR_getWorkInt( toindex, CHAR_WORKLISTPAGE)==1) + buttontype = WINDOW_BUTTONTYPE_CANCEL|WINDOW_BUTTONTYPE_NEXT; + else + buttontype = WINDOW_BUTTONTYPE_CANCEL|WINDOW_BUTTONTYPE_PREV|WINDOW_BUTTONTYPE_NEXT; + windowno = NPC_AUTOPK_HISTORY; + break; + case WINDOW_END: + return; + break; + } + lssproto_WN_send( fd, windowtype, buttontype, windowno, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), token); +} + + +void NPC_AutoPkLoop( void ) +{ +} + +BOOL AutoPk_GetHistoryStr( char *token, int page ) +{ + FILE* fp; + fp = fopen("./data/autopk/autopkhistory.txt", "r"); + if (fp == NULL) + { + print("鿴ʷļ򿪴\n"); + return FALSE; + } + typedef struct taghistory + { + char winnum[5]; + char name[CHARNAMELEN]; + }History; + History history[5]; + + char hstime[5],line[255],buf[255]; + int i; + for(i=0;i0){ + char buf1[64]; + char buf2[128]; + char qfgonggao[256]; +#ifdef _YUANGUSA + sprintf(qfgonggao,"[Ѷ]PK[%d]ӺУμ·%s",autopktime,getGameservername()); + system_all_talk(qfgonggao); + sprintf(buf1, "μӽPKʱ仹ʣ%dӣǰ볡",autopktime); + if(awardpetid!=-1 && awarditemid==-1) + sprintf(buf2,"μӽPKʱ仹ʣ%dӣǰ볡αƷΪ::%d,:%s",autopktime-2,awardpetid,awardpet); + else if(awardpetid==-1 && awarditemid!=-1) + sprintf(buf2,"μӽPKʱ仹ʣ%dӣǰ볡αƷΪ::%d,Ʒ:%s",autopktime-2,awarditemid,awarditem); + else if(awardpetid!=-1 && awarditemid!=-1) + sprintf(buf2,"μӽPKʱ仹ʣ%dӣǰ볡αƷΪ::%d,:%sͱ:%d,Ʒ:%s",autopktime-2,awardpetid,awardpet,awarditemid,awarditem); + else + sprintf(buf2, "PKʱ仹ʣ%dӣǰ볡",autopktime); +#else + sprintf(buf1, "ֹμPKʱ仹ʣ%dӣ",autopktime); + if(awardpetid!=-1 && awarditemid==-1) + sprintf(buf2,"ֹμPKʱ仹ʣ%dӣαƷΪ::%d,:%s",autopktime-2,awardpetid,awardpet); + else if(awardpetid==-1 && awarditemid!=-1) + sprintf(buf2,"ֹμPKʱ仹ʣ%dӣαƷΪ::%d,Ʒ:%s",autopktime-2,awarditemid,awarditem); + else if(awardpetid!=-1 && awarditemid!=-1) + sprintf(buf2,"ֹμPKʱ仹ʣ%dӣαƷΪ::%d,:%sͱ:%d,Ʒ:%s",autopktime-2,awardpetid,awardpet,awarditemid,awarditem); + else + sprintf(buf2, "ʽPKʱ仹ʣ%dӣ",autopktime); +#endif + AutoPk_PKSystemTalk(buf1, buf2); + }else if(autopktime==0){ + int i,charaindex,num=0; + int playernum=CHAR_getPlayerMaxNum(); + for(i=0;i=getAutoPkMinNum())break; + } + } + if(num>=getAutoPkMinNum()){ + AutoPk_PKSystemTalk("ʽʼ","ʽʼ"); + AutoPk_PKSystemStart(); + autopkstart=1; + autopkcnt = 0; + autopktime--; + autopktype = 1; + }else{ + i = 0; + for(i=0;i0){ + awardpetid=petid; + strcpy(awardpet,pet); + }else{ + awardpetid=-1; + } + if(itemid>0){ + awarditemid=itemid; + strcpy(awarditem,item); + }else{ + awarditemid=-1; + } +} + +#ifdef _NONUM_AUTOPK +void AutoPk_ChampionShipSet( char *cdkey, char *name,int winnum, int win ) +{ + strcpy(ship[win].cdkey, cdkey); + strcpy(ship[win].name, name); + ship[win].winnum=winnum; +} +#else +void AutoPk_ChampionShipSet( char *cdkey, char *name, int winnum, int win ) +{ + if(win==0){ + char token[64]; + if(winnum>ship[0].winnum){ + sprintf( token, "[ս]%sĿǰһɱ%d", name, winnum); + AutoPk_PKSystemTalk(token,token); + if(strstr(ship[0].cdkey,cdkey) && strstr(ship[0].name,name)){ + ship[0].winnum=winnum; + }else if(strstr(ship[1].cdkey,cdkey) && strstr(ship[1].name,name)){ + ship[1].winnum=ship[0].winnum; + strcpy(ship[1].cdkey, ship[0].cdkey); + strcpy(ship[1].name, ship[0].name); + ship[0].winnum=winnum; + strcpy(ship[0].cdkey, cdkey); + strcpy(ship[0].name, name); + }else{ + ship[2].winnum=ship[1].winnum; + strcpy(ship[2].cdkey, ship[1].cdkey); + strcpy(ship[2].name, ship[1].name); + ship[1].winnum=ship[0].winnum; + strcpy(ship[1].cdkey, ship[0].cdkey); + strcpy(ship[1].name, ship[0].name); + ship[0].winnum=winnum; + strcpy(ship[0].cdkey, cdkey); + strcpy(ship[0].name, name); + } + }else if(winnum>ship[1].winnum){ + sprintf( token, "[ս]%sĿǰڶɱ%d", name, winnum); + AutoPk_PKSystemTalk(token,token); + if(strstr(ship[1].cdkey,cdkey) && strstr(ship[1].name,name)){ + ship[1].winnum=winnum; + }else{ + ship[2].winnum=ship[1].winnum; + strcpy(ship[2].cdkey, ship[1].cdkey); + strcpy(ship[2].name, ship[1].name); + ship[1].winnum=winnum; + strcpy(ship[1].cdkey, cdkey); + strcpy(ship[1].name, name); + } + }else if(winnum>ship[2].winnum){ + sprintf( token, "[ս]%sĿǰɱ%d", name, winnum); + AutoPk_PKSystemTalk(token,token); + ship[2].winnum=winnum; + strcpy(ship[2].cdkey, cdkey); + strcpy(ship[2].name, name); + } + }else if(win==1){ + ship[3].winnum=winnum; + strcpy(ship[3].cdkey, cdkey); + strcpy(ship[3].name, name); + }else if(win==2){ + ship[4].winnum=winnum; + strcpy(ship[4].cdkey, cdkey); + strcpy(ship[4].name, name); + } +} +#endif + + +void AutoPk_GetChampionShip( void ) +{ + char token[64]; + if(strlen(ship[0].cdkey)>0){ + sprintf( token, "[]񶷴ھߡ%s", ship[0].name); + AutoPk_PKSystemTalk(token,token); + AutoPk_PKTimeSetOnly(-1); + autopkstart=0; + } + if(strlen(ship[1].cdkey)>0){ + sprintf( token, "[]񶷴Ǿߡ%s", ship[1].name); + AutoPk_PKSystemTalk(token,token); + } + if(strlen(ship[2].cdkey)>0){ + sprintf( token, "[]񶷴ߡ%s", ship[2].name); + AutoPk_PKSystemTalk(token,token); + } + if(strlen(ship[3].cdkey)>0 && strlen(ship[4].cdkey)>0){ + //sprintf( token, "ϲ%s%sñPKĺ͵", ship[3].name,ship[4].name); + //AutoPk_PKSystemTalk(token,token); + } + autopktype = 0; + AutoPk_SetHistoryStr(); + + + + baward = TRUE; +} + +BOOL AutoPk_AddItem( int charindex, int index ) +{ + char msgbuf[64]; + int ret; + int spaceNum=5,i,itemindex=-1; + itemindex = CHAR_findEmptyItemBox( charindex ); + if( itemindex < 0 ) { + CHAR_talkToCli( charindex, -1, "Ʒռ䲻㣡", CHAR_COLORYELLOW); + return FALSE; + } + + itemindex = ITEM_makeItemAndRegist( award[index].awarditemid ); + if(itemindex == -1) + return FALSE; + ret = CHAR_addItemSpecificItemIndex( charindex, itemindex); + if( ret < 0 || ret >= CHAR_MAXITEMHAVE ) { + ITEM_endExistItemsOne( itemindex ); + print ("\n ret error!!"); + return FALSE; + } + sprintf( msgbuf,"õ%s",ITEM_getChar( itemindex, ITEM_NAME)); + CHAR_talkToCli( charindex, -1, msgbuf, CHAR_COLORYELLOW ); + CHAR_sendItemDataOne( charindex, ret); + return TRUE; +} + +BOOL AutoPk_AddPet( int charindex, int index) +{ + int ret; + char msgbuf[64]; + int enemynum; + int i,j; + int petindex, petindex2; + + for( i = 0 ;i < CHAR_MAXPETHAVE ; i++) { + petindex = CHAR_getCharPet( charindex, i); + if( petindex == -1 ) + break; + } + + if( i == CHAR_MAXPETHAVE ) { + snprintf( msgbuf,sizeof( msgbuf), ""); + CHAR_talkToCli( charindex, -1, msgbuf, CHAR_COLORYELLOW); + return FALSE; + } + + enemynum = ENEMY_getEnemyNum(); + for( i = 0; i < enemynum; i ++ ) { + if( ENEMY_getInt( i, ENEMY_ID) == award[index].awardpetid) { + break; + } + } + + if( i == enemynum ) + return FALSE; + + ret = ENEMY_createPetFromEnemyIndex( charindex, i); + for( i = 0; i < CHAR_MAXPETHAVE; i ++ ) { + if( CHAR_getCharPet( charindex, i ) == ret ) + break; + } + + petindex2 = CHAR_getCharPet(charindex, i); + if( !CHAR_CHECKINDEX( petindex2) ) + return FALSE; + snprintf( msgbuf,sizeof( msgbuf), "õ%s", CHAR_getChar(petindex2,CHAR_NAME)); + CHAR_talkToCli( charindex, -1, msgbuf, CHAR_COLORYELLOW); + CHAR_setInt(petindex2,CHAR_VARIABLEAI,10000); + for(j = 0; j < CHAR_MAXPETHAVE; j++){ + petindex = CHAR_getCharPet(charindex, j); + if( !CHAR_CHECKINDEX( petindex) ) + continue; + CHAR_complianceParameter( petindex ); + snprintf( msgbuf, sizeof( msgbuf ), "K%d", j ); + CHAR_sendStatusString( charindex, msgbuf ); + snprintf( msgbuf, sizeof( msgbuf ), "W%d", j ); + CHAR_sendStatusString( charindex, msgbuf ); + } + return TRUE; +} + +void NPC_AUTOPKHealerTalked( int meindex ) +{ + if( CHAR_getInt( meindex , CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER ) return; + + if( (CHAR_getWorkInt( meindex, CHAR_WORKPARTYMODE) == 0) + || (CHAR_getWorkInt( meindex, CHAR_WORKPARTYMODE) == 2) ) + { + + NPC_HealerAllHeal( meindex); + CHAR_talkToCli( meindex, -1,"ϲʤȴֱȫظ",CHAR_COLORYELLOW); + }else{ + int i = 0; + int otherindex; + + for( i=0 ; i < CHAR_PARTYMAX ; i++) + { + otherindex = CHAR_getWorkInt( meindex, CHAR_WORKPARTYINDEX1 + i); + if(otherindex != -1){ + + NPC_HealerAllHeal( otherindex); + CHAR_talkToCli( otherindex, -1,"ϲʤȫظ",CHAR_COLORYELLOW); + } + } + } +} + +BOOL AutoPk_GetAwardStr( void ) +{ + FILE* fp; + int i=0; + int j=0; + int enemynum = ENEMY_getEnemyNum(); + fp = fopen("./data/autopk/autopkaward.txt", "r"); + if (fp == NULL) + { + print("鿴Ʒļ򿪴\n"); + return FALSE; + } + for(i=0;i<5;i++){ + char line[64],buf[32]; + if (fgets(line, sizeof(line), fp) == NULL)break; + chop(line); + getStringFromIndexWithDelim(line,"|", 1, buf, sizeof(buf)); + award[i].awardpetid=atoi(buf); + if(award[i].awardpetid!=-1){ + for( j=0; j 0 && award[i].awarditemid <= getItemnum() ){ + strcpy(award[i].awarditem,ITEM_getNameFromNumber(award[i].awarditemid)); + } + else{ + strcpy(award[i].awarditem, "\0"); + award[i].draw=AWARDNO; + } + } + fclose(fp); + return TRUE; +} + +void AutoPk_SetAwardStr( char *token ) +{ + FILE* fp; + int i=0; + fp = fopen("./data/autopk/autopkaward.txt", "w"); + fwrite(token, strlen(token), 1, fp); + fclose(fp); +} + +void AutoPk_PKSystemStart( void ) +{ + int i,charaindex,num=0; + int pkindex[1000],pktype[1000]; + int playernum=CHAR_getPlayerMaxNum(); + for(i=0;i=2){ + if(num%2==0){ + int j = num-1; + i=0; + for(i=0;i +#include "char.h" +#include "object.h" +#include "char_base.h" +#include "npcutil.h" +#include "npc_autopk.h" +#include "lssproto_serv.h" +#include "saacproto_cli.h" +#include "readmap.h" +#include "battle.h" +#include "log.h" +#include "enemy.h" +#include "handletime.h" +#include "npc_eventaction.h" +#include "npc_healer.h" +#include "configfile.h" + +#ifdef _GMRELOAD + extern struct GMINFO gminfo[GMMAXNUM]; +#endif +#ifdef _JOB_AUTOPK + extern int jobautopk; +#endif +#ifdef _AUTO_PK + +#define AWARDNO (1 << 0) +#define AWARDPET (1 << 1) +#define AWARDITEM (1 << 2) +#define AWARDALL (AWARDPET|AWARDITEM) + +enum { + WINDOW_START=1, + WINDOW_SELECT, + WINDOW_JOINPK, + WINDOW_PKLIST, + WINDOW_PKINFO, + WINDOW_HISTORY, + WINDOW_HISTORY_NEXT, + WINDOW_HISTORY_PREV, + WINDOW_END, +}; + +typedef struct tagautopk +{ + int winnum; + char cdkey[CDKEYLEN]; + char name[CHARNAMELEN]; +}Autopk; + +typedef struct tagaward +{ + int awardpetid; + int awarditemid; + char awardpet[32]; + char awarditem[32]; + int draw; +}Award; + +static int baward = FALSE; + +Award award[5]; + +Autopk ship[5]; + +int autopklist; +static int autopktime=-1; +static int awardpetid=-1; +static int awarditemid=-1; +static char awardpet[32]; +static char awarditem[32]; +int autopkstart=0; +int autopkcnt=0; +int autopktype = 0; +enum { + NPC_WORK_CURRENTTIME = CHAR_NPCWORKINT1, + NPC_WORK_TIMEFLAG = CHAR_NPCWORKINT9, +/* + NPC_WORK_ROUTETOY = CHAR_NPCWORKINT2, + NPC_WORK_ROUTEPOINT = CHAR_NPCWORKINT3, + NPC_WORK_ROUNDTRIP = CHAR_NPCWORKINT4, + NPC_WORK_MODE = CHAR_NPCWORKINT5, + NPC_WORK_CURRENTROUTE = CHAR_NPCWORKINT6, + NPC_WORK_ROUTEMAX = CHAR_NPCWORKINT7, + NPC_WORK_WAITTIME = CHAR_NPCWORKINT8, + NPC_WORK_CURRENTTIME = CHAR_NPCWORKINT9, + NPC_WORK_SEFLG = CHAR_NPCWORKINT10, +*/ +}; +enum { + NPC_AUTOPK_START, + NPC_AUTOPK_SELECT, + NPC_AUTOPK_JOINPK, + NPC_AUTOPK_PKLIST, + NPC_AUTOPK_PKAWARD, + NPC_AUTOPK_HISTORY, + NPC_AUTOPK_OK, + NPC_AUTOPK_END, +}; +#define STANDBYTIME 50 + +static void NPC_AutoPk_selectWindow( int meindex, int toindex, int num,int select); +BOOL AutoPk_GetHistoryStr( char *token, int page ); +void AutoPk_PKNum( char *token ); +BOOL AutoPk_AddItem( int charindex, int index ); +BOOL AutoPk_AddPet( int charindex, int index ); + +BOOL NPC_AutoPkInit( int meindex ) +{ + char npcarg[NPC_UTIL_GETARGSTR_BUFSIZE]; + + if(NPC_Util_GetArgStr( meindex, npcarg, sizeof(npcarg))==NULL){ + print("TRANSER_MAN: GetArgStrErr!!"); + return FALSE; + } + +// CHAR_setInt( meindex, CHAR_WHICHTYPE, CHAR_TRANSERMANS); + + //CHAR_setInt( meindex, CHAR_LOOPINTERVAL, NEWNPCMAN_STANDBY); + CHAR_setWorkInt( meindex, NPC_WORK_CURRENTTIME, NowTime.tv_sec); + award[0].draw=0; + award[1].draw=0; + award[2].draw=0; + award[3].draw=0; + award[4].draw=0; + + return TRUE; +} +//CHAR_setWorkInt(talkerindex,CHAR_WORKSHOPRELEVANT,1); +void NPC_AutoPkTalked( int meindex, int talkerindex, char *msg, int color ) +{ + if( CHAR_getInt( talkerindex , CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER ) + return; + if(NPC_Util_isFaceToFace( meindex ,talkerindex , 2) == FALSE) { + if(NPC_Util_isFaceToChara( talkerindex, meindex, 1) == FALSE) + return; + } + + CHAR_setWorkInt( talkerindex, CHAR_WORKSHOPRELEVANT, 0); + NPC_AutoPk_selectWindow( meindex, talkerindex, WINDOW_START, 0); +} + +void NPC_AutoPkWindowTalked( int meindex, int talkerindex, int seqno, + int select, char *data) +{ + char jiangbuf[256]; + memset(jiangbuf, 0, sizeof(jiangbuf)); + if( select == WINDOW_BUTTONTYPE_CANCEL || select == WINDOW_BUTTONTYPE_NO) + return; + switch( seqno) { + case NPC_AUTOPK_START: + break; + case NPC_AUTOPK_SELECT: + NPC_AutoPk_selectWindow( meindex, talkerindex, WINDOW_SELECT, atoi( data)); + break; + case NPC_AUTOPK_JOINPK: + if(autopktime>2 +#ifdef _JOB_AUTOPK + && CHAR_getInt( talkerindex, PROFESSION_CLASS ) == jobautopk +#endif + ){ + char buf1[128]; + char buf2[255]; + int i; + if(CHAR_getInt(talkerindex,CHAR_LV)0){ + AutoPk_PKSystemTalk(jiangbuf,jiangbuf); + } +// if(!strcmp(ship[3].cdkey, CHAR_getChar( talkerindex, CHAR_CDKEY)) +// && !strcmp(ship[3].name, CHAR_getChar( talkerindex, CHAR_NAME))){ +// if((award[3].draw&AWARDPET)!=AWARDPET) +// if(AutoPk_AddPet( talkerindex, 3 )) +// award[3].draw=award[3].draw|AWARDPET; +// if((award[3].draw&AWARDITEM)!=AWARDITEM) +// if(AutoPk_AddItem( talkerindex, 3 )) +// award[3].draw=award[3].draw|AWARDITEM; +// }else if(!strcmp(ship[4].cdkey, CHAR_getChar( talkerindex, CHAR_CDKEY)) +// && !strcmp(ship[4].name, CHAR_getChar( talkerindex, CHAR_NAME))){ +// if((award[4].draw&AWARDPET)!=AWARDPET) +// if(AutoPk_AddPet( talkerindex, 4 )) +// award[4].draw=award[4].draw|AWARDPET; +// if((award[4].draw&AWARDITEM)!=AWARDITEM) +// if(AutoPk_AddItem( talkerindex, 4 )) +// award[4].draw=award[4].draw|AWARDITEM; +// } + break; + case NPC_AUTOPK_HISTORY: + if( select == WINDOW_BUTTONTYPE_CANCEL ) + return; + if( select == WINDOW_BUTTONTYPE_NEXT ) + { + NPC_AutoPk_selectWindow( meindex, talkerindex, WINDOW_HISTORY_NEXT, atoi( data)); + return; + } + if( select == WINDOW_BUTTONTYPE_PREV ) + { + NPC_AutoPk_selectWindow( meindex, talkerindex, WINDOW_HISTORY_PREV, atoi( data)); + return; + } + break; + case NPC_AUTOPK_OK: + break; + case NPC_AUTOPK_END: + NPC_AutoPk_selectWindow( meindex, talkerindex, WINDOW_END, atoi( data)); + break; + } +} + +static void NPC_AutoPk_selectWindow( int meindex, int toindex, int num,int select) +{ + char npcarg[NPC_UTIL_GETARGSTR_BUFSIZE]; + char token[256]; + int buttontype = 0, windowtype = 0, windowno = 0; + int fd = getfdFromCharaIndex( toindex); + if(NPC_Util_isFaceToFace( meindex ,toindex , 2) == FALSE) { + if(NPC_Util_isFaceToChara( toindex, meindex, 1) == FALSE) + return; + } + + memset( npcarg, 0, sizeof( npcarg)); + if(NPC_Util_GetArgStr( meindex, npcarg, sizeof(npcarg))==NULL){ + print("TRANSER_MAN: GetArgStrErr!!"); + return; + } + memset( token, 0, sizeof( token)); + + switch( num) { + case WINDOW_START: + sprintf(token, "3\n񶷣УԱ\n\n" + "ʲôҪΪء\n" + "Ҫμӱ\n" + "鿴ѡ֡\n" + "ȡƷ\n" + "ʷ¼\n" + "ۿ"); + CHAR_setWorkInt( toindex, CHAR_WORKSHOPRELEVANT, WINDOW_START); + windowtype = WINDOW_MESSAGETYPE_SELECT; + buttontype = WINDOW_BUTTONTYPE_CANCEL; + windowno = NPC_AUTOPK_SELECT; + break; + case WINDOW_SELECT: + windowtype = WINDOW_MESSAGETYPE_MESSAGE; + if(select==1){ + if(autopktime>2){ + sprintf(token, " 񶷣УԱ\n\n" + "ǰʼʱ仹ʣ%dӣһ׼",autopktime); + buttontype = WINDOW_BUTTONTYPE_YESNO; + windowno = NPC_AUTOPK_JOINPK; + }else if(autopktime>0){ + sprintf(token, "񶷣УԱ\n\n" + "PK%dӺʼ!\n޷أ\n\nPS޷볡أ볡硣",autopktime); + buttontype = WINDOW_BUTTONTYPE_CANCEL; + }else{ + sprintf(token, " 񶷣УԱ\n\n" + "ĿǰδٰУ˱\n עУ˱Ϣ\n עٷ̳\n www.waei.cc \n\n PS޷볡"); + buttontype = WINDOW_BUTTONTYPE_CANCEL; + } + }else if(select==2){ + sprintf(token, "񶷣У\n"); + strcat(token, "תȼҡ\n"); + AutoPk_PKNum(token); + buttontype = WINDOW_BUTTONTYPE_CANCEL; + windowno = NPC_AUTOPK_PKLIST; + }else if(select==3){ + AutoPk_GetAwardStr(); + char buff[64]; + sprintf(token, "񶷣УƷȡ\nʤڱȡ\n\n");; +// if(strlen(award[0].awardpet)>0) +// sprintf(buff, "ھ%s\n", award[0].awardpet); +// else +// sprintf(buff, "ھ\n"); +// strcat(token, buff); + if(strlen(award[0].awarditem)>0) + sprintf(buff, " %s\n", award[0].awarditem); + else + sprintf(buff, " \n"); + strcat(token, buff); +// if(strlen(award[1].awardpet)>0) +// sprintf(buff, "Ǿ%s\n", award[1].awardpet); +// else +// sprintf(buff, "Ǿ\n"); +// strcat(token, buff); + if(strlen(award[1].awarditem)>0) + sprintf(buff, " %s\n", award[1].awarditem); + else + sprintf(buff, " \n"); + strcat(token, buff); +// if(strlen(award[2].awardpet)>0) +// sprintf(buff, "%s\n", award[2].awardpet); +// else +// sprintf(buff, "\n"); +// strcat(token, buff); + if(strlen(award[2].awarditem)>0) + sprintf(buff, " %s\n", award[2].awarditem); + else + sprintf(buff, " \n"); + strcat(token, buff); + strcat(token,"\nΰɱ㣬ɱҪѸŶ"); +// if(strlen(award[3].awardpet)>0) +// sprintf(buff, "ʤ%s\n", award[3].awardpet); +// else +// sprintf(buff, "ʤ\n"); +// strcat(token, buff); +// if(strlen(award[3].awarditem)>0) +// sprintf(buff, "ʤƷ%s\n", award[3].awarditem); +// else +// sprintf(buff, "ʤƷ\n"); +// strcat(token, buff); +// if(strlen(award[4].awardpet)>0) +// sprintf(buff, "ʤ%s\n", award[4].awardpet); +// else +// sprintf(buff, "ʤ\n"); +// strcat(token, buff); +// if(strlen(award[4].awarditem)>0) +// sprintf(buff, "ʤƷ%s\n", award[4].awarditem); +// else +// sprintf(buff, "ʤƷ\n"); +// strcat(token, buff); + if(baward && (!strcmp(ship[0].cdkey, CHAR_getChar( toindex, CHAR_CDKEY)) + && !strcmp(ship[0].name, CHAR_getChar( toindex, CHAR_NAME)) + && (award[0].draw&AWARDITEM)!=AWARDITEM) + || (!strcmp(ship[1].cdkey, CHAR_getChar( toindex, CHAR_CDKEY)) + && !strcmp(ship[1].name, CHAR_getChar( toindex, CHAR_NAME)) + && (award[1].draw&AWARDITEM)!=AWARDITEM) + || (!strcmp(ship[2].cdkey, CHAR_getChar( toindex, CHAR_CDKEY)) + && !strcmp(ship[2].name, CHAR_getChar( toindex, CHAR_NAME)) + && (award[2].draw&AWARDITEM)!=AWARDITEM) && autopktype == 0) + buttontype = WINDOW_BUTTONTYPE_YESNO; + else + buttontype = WINDOW_BUTTONTYPE_CANCEL; + windowno = NPC_AUTOPK_PKAWARD; + }else if(select==4){ + CHAR_setWorkInt( toindex, CHAR_WORKLISTPAGE, 1); + if(AutoPk_GetHistoryStr(token,CHAR_getWorkInt( toindex, CHAR_WORKLISTPAGE))) + buttontype = WINDOW_BUTTONTYPE_CANCEL; + else + buttontype = WINDOW_BUTTONTYPE_CANCEL|WINDOW_BUTTONTYPE_NEXT; + windowno = NPC_AUTOPK_HISTORY; + }else if(select==5){ + CHAR_talkToCli( toindex, -1, "[ʾ]ʼ뵽ҽԺ<Զ̹սԱ>鿴Ŷ", CHAR_COLORRED ); + return; + } + break; + case WINDOW_HISTORY_NEXT: + windowtype = WINDOW_MESSAGETYPE_MESSAGE; + CHAR_setWorkInt( toindex, CHAR_WORKLISTPAGE,CHAR_getWorkInt( toindex, CHAR_WORKLISTPAGE)+1); + if(AutoPk_GetHistoryStr(token,CHAR_getWorkInt( toindex, CHAR_WORKLISTPAGE))) + buttontype = WINDOW_BUTTONTYPE_CANCEL|WINDOW_BUTTONTYPE_PREV; + else + buttontype = WINDOW_BUTTONTYPE_CANCEL|WINDOW_BUTTONTYPE_PREV|WINDOW_BUTTONTYPE_NEXT; + windowno = NPC_AUTOPK_HISTORY; + break; + case WINDOW_HISTORY_PREV: + windowtype = WINDOW_MESSAGETYPE_MESSAGE; + CHAR_setWorkInt( toindex, CHAR_WORKLISTPAGE,CHAR_getWorkInt( toindex, CHAR_WORKLISTPAGE)-1); + if(CHAR_getWorkInt( toindex, CHAR_WORKLISTPAGE)<1)CHAR_setWorkInt( toindex, CHAR_WORKLISTPAGE,1); + if(AutoPk_GetHistoryStr(token,CHAR_getWorkInt( toindex, CHAR_WORKLISTPAGE)) || CHAR_getWorkInt( toindex, CHAR_WORKLISTPAGE)==1) + buttontype = WINDOW_BUTTONTYPE_CANCEL|WINDOW_BUTTONTYPE_NEXT; + else + buttontype = WINDOW_BUTTONTYPE_CANCEL|WINDOW_BUTTONTYPE_PREV|WINDOW_BUTTONTYPE_NEXT; + windowno = NPC_AUTOPK_HISTORY; + break; + case WINDOW_END: + return; + break; + } + lssproto_WN_send( fd, windowtype, buttontype, windowno, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), token); +} + + +void NPC_AutoPkLoop( void ) +{ +} + +BOOL AutoPk_GetHistoryStr( char *token, int page ) +{ + FILE* fp; + fp = fopen("./data/autopk/autopkhistory.txt", "r"); + if (fp == NULL) + { + print("鿴ʷļ򿪴\n"); + return FALSE; + } + typedef struct taghistory + { + char winnum[5]; + char name[CHARNAMELEN]; + }History; + History history[5]; + + char hstime[5],line[255],buf[255]; + int i; + for(i=0;i0){ + char buf1[64]; + char buf2[128]; + char qfgonggao[256]; +#ifdef _YUANGUSA + sprintf(qfgonggao,"[Ѷ]PK[%d]ӺУμ·%s",autopktime,getGameservername()); + system_all_talk(qfgonggao); + sprintf(buf1, "μӽPKʱ仹ʣ%dӣǰ볡",autopktime); + if(awardpetid!=-1 && awarditemid==-1) + sprintf(buf2,"μӽPKʱ仹ʣ%dӣǰ볡αƷΪ::%d,:%s",autopktime-2,awardpetid,awardpet); + else if(awardpetid==-1 && awarditemid!=-1) + sprintf(buf2,"μӽPKʱ仹ʣ%dӣǰ볡αƷΪ::%d,Ʒ:%s",autopktime-2,awarditemid,awarditem); + else if(awardpetid!=-1 && awarditemid!=-1) + sprintf(buf2,"μӽPKʱ仹ʣ%dӣǰ볡αƷΪ::%d,:%sͱ:%d,Ʒ:%s",autopktime-2,awardpetid,awardpet,awarditemid,awarditem); + else + sprintf(buf2, "PKʱ仹ʣ%dӣǰ볡",autopktime); +#else + sprintf(buf1, "ֹμPKʱ仹ʣ%dӣ",autopktime); + if(awardpetid!=-1 && awarditemid==-1) + sprintf(buf2,"ֹμPKʱ仹ʣ%dӣαƷΪ::%d,:%s",autopktime-2,awardpetid,awardpet); + else if(awardpetid==-1 && awarditemid!=-1) + sprintf(buf2,"ֹμPKʱ仹ʣ%dӣαƷΪ::%d,Ʒ:%s",autopktime-2,awarditemid,awarditem); + else if(awardpetid!=-1 && awarditemid!=-1) + sprintf(buf2,"ֹμPKʱ仹ʣ%dӣαƷΪ::%d,:%sͱ:%d,Ʒ:%s",autopktime-2,awardpetid,awardpet,awarditemid,awarditem); + else + sprintf(buf2, "ʽPKʱ仹ʣ%dӣ",autopktime); +#endif + AutoPk_PKSystemTalk(buf1, buf2); + }else if(autopktime==0){ + int i,charaindex,num=0; + int playernum=CHAR_getPlayerMaxNum(); + for(i=0;i=getAutoPkMinNum())break; + } + } + if(num>=getAutoPkMinNum()){ + AutoPk_PKSystemTalk("ʽʼ","ʽʼ"); + AutoPk_PKSystemStart(); + autopkstart=1; + autopkcnt = 0; + autopktime--; + autopktype = 1; + }else{ + i = 0; + for(i=0;i0){ + awardpetid=petid; + strcpy(awardpet,pet); + }else{ + awardpetid=-1; + } + if(itemid>0){ + awarditemid=itemid; + strcpy(awarditem,item); + }else{ + awarditemid=-1; + } +} + +#ifdef _NONUM_AUTOPK +void AutoPk_ChampionShipSet( char *cdkey, char *name,int winnum, int win ) +{ + strcpy(ship[win].cdkey, cdkey); + strcpy(ship[win].name, name); + ship[win].winnum=winnum; +} +#else +void AutoPk_ChampionShipSet( char *cdkey, char *name, int winnum, int win ) +{ + if(win==0){ + char token[64]; + if(winnum>ship[0].winnum){ + sprintf( token, "[ս]%sĿǰһɱ%d", name, winnum); + AutoPk_PKSystemTalk(token,token); + if(strstr(ship[0].cdkey,cdkey) && strstr(ship[0].name,name)){ + ship[0].winnum=winnum; + }else if(strstr(ship[1].cdkey,cdkey) && strstr(ship[1].name,name)){ + ship[1].winnum=ship[0].winnum; + strcpy(ship[1].cdkey, ship[0].cdkey); + strcpy(ship[1].name, ship[0].name); + ship[0].winnum=winnum; + strcpy(ship[0].cdkey, cdkey); + strcpy(ship[0].name, name); + }else{ + ship[2].winnum=ship[1].winnum; + strcpy(ship[2].cdkey, ship[1].cdkey); + strcpy(ship[2].name, ship[1].name); + ship[1].winnum=ship[0].winnum; + strcpy(ship[1].cdkey, ship[0].cdkey); + strcpy(ship[1].name, ship[0].name); + ship[0].winnum=winnum; + strcpy(ship[0].cdkey, cdkey); + strcpy(ship[0].name, name); + } + }else if(winnum>ship[1].winnum){ + sprintf( token, "[ս]%sĿǰڶɱ%d", name, winnum); + AutoPk_PKSystemTalk(token,token); + if(strstr(ship[1].cdkey,cdkey) && strstr(ship[1].name,name)){ + ship[1].winnum=winnum; + }else{ + ship[2].winnum=ship[1].winnum; + strcpy(ship[2].cdkey, ship[1].cdkey); + strcpy(ship[2].name, ship[1].name); + ship[1].winnum=winnum; + strcpy(ship[1].cdkey, cdkey); + strcpy(ship[1].name, name); + } + }else if(winnum>ship[2].winnum){ + sprintf( token, "[ս]%sĿǰɱ%d", name, winnum); + AutoPk_PKSystemTalk(token,token); + ship[2].winnum=winnum; + strcpy(ship[2].cdkey, cdkey); + strcpy(ship[2].name, name); + } + }else if(win==1){ + ship[3].winnum=winnum; + strcpy(ship[3].cdkey, cdkey); + strcpy(ship[3].name, name); + }else if(win==2){ + ship[4].winnum=winnum; + strcpy(ship[4].cdkey, cdkey); + strcpy(ship[4].name, name); + } +} +#endif + + +void AutoPk_GetChampionShip( void ) +{ + char token[64]; + if(strlen(ship[0].cdkey)>0){ + sprintf( token, "[]񶷴ھߡ%s", ship[0].name); + AutoPk_PKSystemTalk(token,token); + AutoPk_PKTimeSetOnly(-1); + autopkstart=0; + } + if(strlen(ship[1].cdkey)>0){ + sprintf( token, "[]񶷴Ǿߡ%s", ship[1].name); + AutoPk_PKSystemTalk(token,token); + } + if(strlen(ship[2].cdkey)>0){ + sprintf( token, "[]񶷴ߡ%s", ship[2].name); + AutoPk_PKSystemTalk(token,token); + } + if(strlen(ship[3].cdkey)>0 && strlen(ship[4].cdkey)>0){ + //sprintf( token, "ϲ%s%sñPKĺ͵", ship[3].name,ship[4].name); + //AutoPk_PKSystemTalk(token,token); + } + autopktype = 0; + AutoPk_SetHistoryStr(); + + + + baward = TRUE; +} + +BOOL AutoPk_AddItem( int charindex, int index ) +{ + char msgbuf[64]; + int ret; + int spaceNum=5,i,itemindex=-1; + itemindex = CHAR_findEmptyItemBox( charindex ); + if( itemindex < 0 ) { + CHAR_talkToCli( charindex, -1, "Ʒռ䲻㣡", CHAR_COLORYELLOW); + return FALSE; + } + + itemindex = ITEM_makeItemAndRegist( award[index].awarditemid ); + if(itemindex == -1) + return FALSE; + ret = CHAR_addItemSpecificItemIndex( charindex, itemindex); + if( ret < 0 || ret >= CHAR_MAXITEMHAVE ) { + ITEM_endExistItemsOne( itemindex ); + print ("\n ret error!!"); + return FALSE; + } + sprintf( msgbuf,"õ%s",ITEM_getChar( itemindex, ITEM_NAME)); + CHAR_talkToCli( charindex, -1, msgbuf, CHAR_COLORYELLOW ); + CHAR_sendItemDataOne( charindex, ret); + return TRUE; +} + +BOOL AutoPk_AddPet( int charindex, int index) +{ + int ret; + char msgbuf[64]; + int enemynum; + int i,j; + int petindex, petindex2; + + for( i = 0 ;i < CHAR_MAXPETHAVE ; i++) { + petindex = CHAR_getCharPet( charindex, i); + if( petindex == -1 ) + break; + } + + if( i == CHAR_MAXPETHAVE ) { + snprintf( msgbuf,sizeof( msgbuf), ""); + CHAR_talkToCli( charindex, -1, msgbuf, CHAR_COLORYELLOW); + return FALSE; + } + + enemynum = ENEMY_getEnemyNum(); + for( i = 0; i < enemynum; i ++ ) { + if( ENEMY_getInt( i, ENEMY_ID) == award[index].awardpetid) { + break; + } + } + + if( i == enemynum ) + return FALSE; + + ret = ENEMY_createPetFromEnemyIndex( charindex, i); + for( i = 0; i < CHAR_MAXPETHAVE; i ++ ) { + if( CHAR_getCharPet( charindex, i ) == ret ) + break; + } + + petindex2 = CHAR_getCharPet(charindex, i); + if( !CHAR_CHECKINDEX( petindex2) ) + return FALSE; + snprintf( msgbuf,sizeof( msgbuf), "õ%s", CHAR_getChar(petindex2,CHAR_NAME)); + CHAR_talkToCli( charindex, -1, msgbuf, CHAR_COLORYELLOW); + CHAR_setInt(petindex2,CHAR_VARIABLEAI,10000); + for(j = 0; j < CHAR_MAXPETHAVE; j++){ + petindex = CHAR_getCharPet(charindex, j); + if( !CHAR_CHECKINDEX( petindex) ) + continue; + CHAR_complianceParameter( petindex ); + snprintf( msgbuf, sizeof( msgbuf ), "K%d", j ); + CHAR_sendStatusString( charindex, msgbuf ); + snprintf( msgbuf, sizeof( msgbuf ), "W%d", j ); + CHAR_sendStatusString( charindex, msgbuf ); + } + return TRUE; +} + +void NPC_AUTOPKHealerTalked( int meindex ) +{ + if( CHAR_getInt( meindex , CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER ) return; + + if( (CHAR_getWorkInt( meindex, CHAR_WORKPARTYMODE) == 0) + || (CHAR_getWorkInt( meindex, CHAR_WORKPARTYMODE) == 2) ) + { + + NPC_HealerAllHeal( meindex); + CHAR_talkToCli( meindex, -1,"ϲʤȴֱȫظ",CHAR_COLORYELLOW); + }else{ + int i = 0; + int otherindex; + + for( i=0 ; i < CHAR_PARTYMAX ; i++) + { + otherindex = CHAR_getWorkInt( meindex, CHAR_WORKPARTYINDEX1 + i); + if(otherindex != -1){ + + NPC_HealerAllHeal( otherindex); + CHAR_talkToCli( otherindex, -1,"ϲʤȫظ",CHAR_COLORYELLOW); + } + } + } +} + +BOOL AutoPk_GetAwardStr( void ) +{ + FILE* fp; + int i=0; + int j=0; + int enemynum = ENEMY_getEnemyNum(); + fp = fopen("./data/autopk/autopkaward.txt", "r"); + if (fp == NULL) + { + print("鿴Ʒļ򿪴\n"); + return FALSE; + } + for(i=0;i<5;i++){ + char line[64],buf[32]; + if (fgets(line, sizeof(line), fp) == NULL)break; + chop(line); + getStringFromIndexWithDelim(line,"|", 1, buf, sizeof(buf)); + award[i].awardpetid=atoi(buf); + if(award[i].awardpetid!=-1){ + for( j=0; j 0 && award[i].awarditemid <= getItemnum() ){ + strcpy(award[i].awarditem,ITEM_getNameFromNumber(award[i].awarditemid)); + } + else{ + strcpy(award[i].awarditem, "\0"); + award[i].draw=AWARDNO; + } + } + fclose(fp); + return TRUE; +} + +void AutoPk_SetAwardStr( char *token ) +{ + FILE* fp; + int i=0; + fp = fopen("./data/autopk/autopkaward.txt", "w"); + fwrite(token, strlen(token), 1, fp); + fclose(fp); +} + +void AutoPk_PKSystemStart( void ) +{ + int i,charaindex,num=0; + int pkindex[1000],pktype[1000]; + int playernum=CHAR_getPlayerMaxNum(); + for(i=0;i=2){ + if(num%2==0){ + int j = num-1; + i=0; + for(i=0;i +#include "char.h" +#include "object.h" +#include "char_base.h" +#include "npcutil.h" +#include "npc_autopk.h" +#include "lssproto_serv.h" +#include "saacproto_cli.h" +#include "readmap.h" +#include "battle.h" +#include "log.h" +#include "enemy.h" +#include "handletime.h" +#include "npc_eventaction.h" +#include "npc_healer.h" +#include "configfile.h" + +#ifdef _GMRELOAD + extern struct GMINFO gminfo[GMMAXNUM]; +#endif +#ifdef _JOB_AUTOPK + extern int jobautopk; +#endif +#ifdef _AUTO_PK + +#define AWARDNO (1 << 0) +#define AWARDPET (1 << 1) +#define AWARDITEM (1 << 2) +#define AWARDALL (AWARDPET|AWARDITEM) + +enum { + WINDOW_START=1, + WINDOW_SELECT, + WINDOW_JOINPK, + WINDOW_PKLIST, + WINDOW_PKINFO, + WINDOW_HISTORY, + WINDOW_HISTORY_NEXT, + WINDOW_HISTORY_PREV, + WINDOW_END, +}; + +typedef struct tagautopk +{ + int winnum; + char cdkey[CDKEYLEN]; + char name[CHARNAMELEN]; +}Autopk; + +typedef struct tagaward +{ + int awardpetid; + int awarditemid; + char awardpet[32]; + char awarditem[32]; + int draw; +}Award; + +static int baward = FALSE; + +Award award[10]; + +Autopk ship[10]; + +int autopklist; +static int autopktime=-1; +static int awardpetid=-1; +static int awarditemid=-1; +static char awardpet[32]; +static char awarditem[32]; +int autopkstart=0; +int autopkcnt=0; +int autopktype = 0; +enum { + NPC_WORK_CURRENTTIME = CHAR_NPCWORKINT1, + NPC_WORK_TIMEFLAG = CHAR_NPCWORKINT9, +/* + NPC_WORK_ROUTETOY = CHAR_NPCWORKINT2, + NPC_WORK_ROUTEPOINT = CHAR_NPCWORKINT3, + NPC_WORK_ROUNDTRIP = CHAR_NPCWORKINT4, + NPC_WORK_MODE = CHAR_NPCWORKINT5, + NPC_WORK_CURRENTROUTE = CHAR_NPCWORKINT6, + NPC_WORK_ROUTEMAX = CHAR_NPCWORKINT7, + NPC_WORK_WAITTIME = CHAR_NPCWORKINT8, + NPC_WORK_CURRENTTIME = CHAR_NPCWORKINT9, + NPC_WORK_SEFLG = CHAR_NPCWORKINT10, +*/ +}; +enum { + NPC_AUTOPK_START, + NPC_AUTOPK_SELECT, + NPC_AUTOPK_JOINPK, + NPC_AUTOPK_PKLIST, + NPC_AUTOPK_PKAWARD, + NPC_AUTOPK_HISTORY, + NPC_AUTOPK_OK, + NPC_AUTOPK_END, +}; +#define STANDBYTIME 50 + +static void NPC_AutoPk_selectWindow( int meindex, int toindex, int num,int select); +BOOL AutoPk_GetHistoryStr( char *token, int page ); +void AutoPk_PKNum( char *token ); +BOOL AutoPk_AddItem( int charindex, int index ); +BOOL AutoPk_AddPet( int charindex, int index ); + +BOOL NPC_AutoPkInit( int meindex ) +{ + char npcarg[NPC_UTIL_GETARGSTR_BUFSIZE]; + + if(NPC_Util_GetArgStr( meindex, npcarg, sizeof(npcarg))==NULL){ + print("TRANSER_MAN: GetArgStrErr!!"); + return FALSE; + } + +// CHAR_setInt( meindex, CHAR_WHICHTYPE, CHAR_TRANSERMANS); + + //CHAR_setInt( meindex, CHAR_LOOPINTERVAL, NEWNPCMAN_STANDBY); + CHAR_setWorkInt( meindex, NPC_WORK_CURRENTTIME, NowTime.tv_sec); + award[0].draw=0; + award[1].draw=0; + award[2].draw=0; + award[3].draw=0; + award[4].draw=0; + award[5].draw=0; + award[6].draw=0; + award[7].draw=0; + award[8].draw=0; + award[9].draw=0; + + return TRUE; +} +//CHAR_setWorkInt(talkerindex,CHAR_WORKSHOPRELEVANT,1); +void NPC_AutoPkTalked( int meindex, int talkerindex, char *msg, int color ) +{ + if( CHAR_getInt( talkerindex , CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER ) + return; + if(NPC_Util_isFaceToFace( meindex ,talkerindex , 2) == FALSE) { + if(NPC_Util_isFaceToChara( talkerindex, meindex, 1) == FALSE) + return; + } + + CHAR_setWorkInt( talkerindex, CHAR_WORKSHOPRELEVANT, 0); + NPC_AutoPk_selectWindow( meindex, talkerindex, WINDOW_START, 0); +} + +void NPC_AutoPkWindowTalked( int meindex, int talkerindex, int seqno, + int select, char *data) +{ + char jiangbuf[256]; + memset(jiangbuf, 0, sizeof(jiangbuf)); + if( select == WINDOW_BUTTONTYPE_CANCEL || select == WINDOW_BUTTONTYPE_NO) + return; + switch( seqno) { + case NPC_AUTOPK_START: + break; + case NPC_AUTOPK_SELECT: + NPC_AutoPk_selectWindow( meindex, talkerindex, WINDOW_SELECT, atoi( data)); + break; + case NPC_AUTOPK_JOINPK: + if(autopktime>2 +#ifdef _JOB_AUTOPK + && CHAR_getInt( talkerindex, PROFESSION_CLASS ) == jobautopk +#endif + ){ + char buf1[128]; + char buf2[255]; + int i; + if(CHAR_getInt(talkerindex,CHAR_LV)0){ + AutoPk_PKSystemTalk(jiangbuf,jiangbuf); + } +// if(!strcmp(ship[3].cdkey, CHAR_getChar( talkerindex, CHAR_CDKEY)) +// && !strcmp(ship[3].name, CHAR_getChar( talkerindex, CHAR_NAME))){ +// if((award[3].draw&AWARDPET)!=AWARDPET) +// if(AutoPk_AddPet( talkerindex, 3 )) +// award[3].draw=award[3].draw|AWARDPET; +// if((award[3].draw&AWARDITEM)!=AWARDITEM) +// if(AutoPk_AddItem( talkerindex, 3 )) +// award[3].draw=award[3].draw|AWARDITEM; +// }else if(!strcmp(ship[4].cdkey, CHAR_getChar( talkerindex, CHAR_CDKEY)) +// && !strcmp(ship[4].name, CHAR_getChar( talkerindex, CHAR_NAME))){ +// if((award[4].draw&AWARDPET)!=AWARDPET) +// if(AutoPk_AddPet( talkerindex, 4 )) +// award[4].draw=award[4].draw|AWARDPET; +// if((award[4].draw&AWARDITEM)!=AWARDITEM) +// if(AutoPk_AddItem( talkerindex, 4 )) +// award[4].draw=award[4].draw|AWARDITEM; +// } + break; + case NPC_AUTOPK_HISTORY: + if( select == WINDOW_BUTTONTYPE_CANCEL ) + return; + if( select == WINDOW_BUTTONTYPE_NEXT ) + { + NPC_AutoPk_selectWindow( meindex, talkerindex, WINDOW_HISTORY_NEXT, atoi( data)); + return; + } + if( select == WINDOW_BUTTONTYPE_PREV ) + { + NPC_AutoPk_selectWindow( meindex, talkerindex, WINDOW_HISTORY_PREV, atoi( data)); + return; + } + break; + case NPC_AUTOPK_OK: + break; + case NPC_AUTOPK_END: + NPC_AutoPk_selectWindow( meindex, talkerindex, WINDOW_END, atoi( data)); + break; + } +} + +static void NPC_AutoPk_selectWindow( int meindex, int toindex, int num,int select) +{ + char npcarg[NPC_UTIL_GETARGSTR_BUFSIZE]; + char token[256]; + int buttontype = 0, windowtype = 0, windowno = 0; + int fd = getfdFromCharaIndex( toindex); + if(NPC_Util_isFaceToFace( meindex ,toindex , 2) == FALSE) { + if(NPC_Util_isFaceToChara( toindex, meindex, 1) == FALSE) + return; + } + + memset( npcarg, 0, sizeof( npcarg)); + if(NPC_Util_GetArgStr( meindex, npcarg, sizeof(npcarg))==NULL){ + print("TRANSER_MAN: GetArgStrErr!!"); + return; + } + memset( token, 0, sizeof( token)); + + switch( num) { + case WINDOW_START: + sprintf(token, "3\n񶷣УԱ\n\n" + "ʲôҪΪء\n" + "Ҫμӱ\n" + "鿴ѡ֡\n" + "ȡƷ\n" + "ʷ¼\n" + "ۿ"); + CHAR_setWorkInt( toindex, CHAR_WORKSHOPRELEVANT, WINDOW_START); + windowtype = WINDOW_MESSAGETYPE_SELECT; + buttontype = WINDOW_BUTTONTYPE_CANCEL; + windowno = NPC_AUTOPK_SELECT; + break; + case WINDOW_SELECT: + windowtype = WINDOW_MESSAGETYPE_MESSAGE; + if(select==1){ + if(autopktime>2){ + sprintf(token, " 񶷣УԱ\n\n" + "ǰʼʱ仹ʣ%dӣһ׼",autopktime); + buttontype = WINDOW_BUTTONTYPE_YESNO; + windowno = NPC_AUTOPK_JOINPK; + }else if(autopktime>0){ + sprintf(token, "񶷣УԱ\n\n" + "PK%dӺʼ!\n޷أ\n\nPS޷볡أ볡硣",autopktime); + buttontype = WINDOW_BUTTONTYPE_CANCEL; + }else{ + sprintf(token, " 񶷣УԱ\n\n" + "ĿǰδٰУ˱\n עУ˱Ϣ\n עٷ̳\n www.waei.cc \n\n PS޷볡"); + buttontype = WINDOW_BUTTONTYPE_CANCEL; + } + }else if(select==2){ + sprintf(token, "񶷣У\n"); + strcat(token, "תȼҡ\n"); + AutoPk_PKNum(token); + buttontype = WINDOW_BUTTONTYPE_CANCEL; + windowno = NPC_AUTOPK_PKLIST; + }else if(select==3){ + AutoPk_GetAwardStr(); + char buff[64]; + sprintf(token, "񶷣УƷȡ\nʤڱȡ\n\n");; +// if(strlen(award[0].awardpet)>0) +// sprintf(buff, "ھ%s\n", award[0].awardpet); +// else +// sprintf(buff, "ھ\n"); +// strcat(token, buff); + if(strlen(award[0].awarditem)>0) + sprintf(buff, " %s\n", award[0].awarditem); + else + sprintf(buff, " \n"); + strcat(token, buff); +// if(strlen(award[1].awardpet)>0) +// sprintf(buff, "Ǿ%s\n", award[1].awardpet); +// else +// sprintf(buff, "Ǿ\n"); +// strcat(token, buff); + if(strlen(award[1].awarditem)>0) + sprintf(buff, " %s\n", award[1].awarditem); + else + sprintf(buff, " \n"); + strcat(token, buff); +// if(strlen(award[2].awardpet)>0) +// sprintf(buff, "%s\n", award[2].awardpet); +// else +// sprintf(buff, "\n"); +// strcat(token, buff); + if(strlen(award[2].awarditem)>0) + sprintf(buff, " %s\n", award[2].awarditem); + else + sprintf(buff, " \n"); + strcat(token, buff); + strcat(token,"\nΰɱ㣬ɱҪѸŶ"); +// if(strlen(award[3].awardpet)>0) +// sprintf(buff, "ʤ%s\n", award[3].awardpet); +// else +// sprintf(buff, "ʤ\n"); +// strcat(token, buff); +// if(strlen(award[3].awarditem)>0) +// sprintf(buff, "ʤƷ%s\n", award[3].awarditem); +// else +// sprintf(buff, "ʤƷ\n"); +// strcat(token, buff); +// if(strlen(award[4].awardpet)>0) +// sprintf(buff, "ʤ%s\n", award[4].awardpet); +// else +// sprintf(buff, "ʤ\n"); +// strcat(token, buff); +// if(strlen(award[4].awarditem)>0) +// sprintf(buff, "ʤƷ%s\n", award[4].awarditem); +// else +// sprintf(buff, "ʤƷ\n"); +// strcat(token, buff); + if(baward && (!strcmp(ship[0].cdkey, CHAR_getChar( toindex, CHAR_CDKEY)) + && !strcmp(ship[0].name, CHAR_getChar( toindex, CHAR_NAME)) + && (award[0].draw&AWARDITEM)!=AWARDITEM) + || (!strcmp(ship[1].cdkey, CHAR_getChar( toindex, CHAR_CDKEY)) + && !strcmp(ship[1].name, CHAR_getChar( toindex, CHAR_NAME)) + && (award[1].draw&AWARDITEM)!=AWARDITEM) + || (!strcmp(ship[2].cdkey, CHAR_getChar( toindex, CHAR_CDKEY)) + && !strcmp(ship[2].name, CHAR_getChar( toindex, CHAR_NAME)) + && (award[2].draw&AWARDITEM)!=AWARDITEM) && autopktype == 0) + buttontype = WINDOW_BUTTONTYPE_YESNO; + else + buttontype = WINDOW_BUTTONTYPE_CANCEL; + windowno = NPC_AUTOPK_PKAWARD; + }else if(select==4){ + CHAR_setWorkInt( toindex, CHAR_WORKLISTPAGE, 1); + if(AutoPk_GetHistoryStr(token,CHAR_getWorkInt( toindex, CHAR_WORKLISTPAGE))) + buttontype = WINDOW_BUTTONTYPE_CANCEL; + else + buttontype = WINDOW_BUTTONTYPE_CANCEL|WINDOW_BUTTONTYPE_NEXT; + windowno = NPC_AUTOPK_HISTORY; + }else if(select==5){ + CHAR_talkToCli( toindex, -1, "[ʾ]ʼ뵽ҽԺ<Զ̹սԱ>鿴Ŷ", CHAR_COLORRED ); + return; + } + break; + case WINDOW_HISTORY_NEXT: + windowtype = WINDOW_MESSAGETYPE_MESSAGE; + CHAR_setWorkInt( toindex, CHAR_WORKLISTPAGE,CHAR_getWorkInt( toindex, CHAR_WORKLISTPAGE)+1); + if(AutoPk_GetHistoryStr(token,CHAR_getWorkInt( toindex, CHAR_WORKLISTPAGE))) + buttontype = WINDOW_BUTTONTYPE_CANCEL|WINDOW_BUTTONTYPE_PREV; + else + buttontype = WINDOW_BUTTONTYPE_CANCEL|WINDOW_BUTTONTYPE_PREV|WINDOW_BUTTONTYPE_NEXT; + windowno = NPC_AUTOPK_HISTORY; + break; + case WINDOW_HISTORY_PREV: + windowtype = WINDOW_MESSAGETYPE_MESSAGE; + CHAR_setWorkInt( toindex, CHAR_WORKLISTPAGE,CHAR_getWorkInt( toindex, CHAR_WORKLISTPAGE)-1); + if(CHAR_getWorkInt( toindex, CHAR_WORKLISTPAGE)<1)CHAR_setWorkInt( toindex, CHAR_WORKLISTPAGE,1); + if(AutoPk_GetHistoryStr(token,CHAR_getWorkInt( toindex, CHAR_WORKLISTPAGE)) || CHAR_getWorkInt( toindex, CHAR_WORKLISTPAGE)==1) + buttontype = WINDOW_BUTTONTYPE_CANCEL|WINDOW_BUTTONTYPE_NEXT; + else + buttontype = WINDOW_BUTTONTYPE_CANCEL|WINDOW_BUTTONTYPE_PREV|WINDOW_BUTTONTYPE_NEXT; + windowno = NPC_AUTOPK_HISTORY; + break; + case WINDOW_END: + return; + break; + } + lssproto_WN_send( fd, windowtype, buttontype, windowno, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), token); +} + + +void NPC_AutoPkLoop( void ) +{ +} + +BOOL AutoPk_GetHistoryStr( char *token, int page ) +{ + FILE* fp; + fp = fopen("./data/autopk/autopkhistory.txt", "r"); + if (fp == NULL) + { + print("鿴ʷļ򿪴\n"); + return FALSE; + } + typedef struct taghistory + { + char winnum[5]; + char name[CHARNAMELEN]; + }History; + History history[5]; + + char hstime[5],line[255],buf[255]; + int i; + for(i=0;i0){ + char buf1[64]; + char buf2[128]; + char qfgonggao[256]; +#ifdef _YUANGUSA + sprintf(qfgonggao,"[Ѷ]PK[%d]ӺУμ·%s",autopktime,getGameservername()); + system_all_talk(qfgonggao); + sprintf(buf1, "μӽPKʱ仹ʣ%dӣǰ볡",autopktime); + if(awardpetid!=-1 && awarditemid==-1) + sprintf(buf2,"μӽPKʱ仹ʣ%dӣǰ볡αƷΪ::%d,:%s",autopktime-2,awardpetid,awardpet); + else if(awardpetid==-1 && awarditemid!=-1) + sprintf(buf2,"μӽPKʱ仹ʣ%dӣǰ볡αƷΪ::%d,Ʒ:%s",autopktime-2,awarditemid,awarditem); + else if(awardpetid!=-1 && awarditemid!=-1) + sprintf(buf2,"μӽPKʱ仹ʣ%dӣǰ볡αƷΪ::%d,:%sͱ:%d,Ʒ:%s",autopktime-2,awardpetid,awardpet,awarditemid,awarditem); + else + sprintf(buf2, "PKʱ仹ʣ%dӣǰ볡",autopktime); +#else + sprintf(buf1, "ֹμPKʱ仹ʣ%dӣ",autopktime); + if(awardpetid!=-1 && awarditemid==-1) + sprintf(buf2,"ֹμPKʱ仹ʣ%dӣαƷΪ::%d,:%s",autopktime-2,awardpetid,awardpet); + else if(awardpetid==-1 && awarditemid!=-1) + sprintf(buf2,"ֹμPKʱ仹ʣ%dӣαƷΪ::%d,Ʒ:%s",autopktime-2,awarditemid,awarditem); + else if(awardpetid!=-1 && awarditemid!=-1) + sprintf(buf2,"ֹμPKʱ仹ʣ%dӣαƷΪ::%d,:%sͱ:%d,Ʒ:%s",autopktime-2,awardpetid,awardpet,awarditemid,awarditem); + else + sprintf(buf2, "ʽPKʱ仹ʣ%dӣ",autopktime); +#endif + AutoPk_PKSystemTalk(buf1, buf2); + }else if(autopktime==0){ + int i,charaindex,num=0; + int playernum=CHAR_getPlayerMaxNum(); + for(i=0;i=getAutoPkMinNum())break; + } + } + if(num>=getAutoPkMinNum()){ + AutoPk_PKSystemTalk("ʽʼ","ʽʼ"); + AutoPk_PKSystemStart(); + autopkstart=1; + autopkcnt = 0; + autopktime--; + autopktype = 1; + }else{ + i = 0; + for(i=0;i0){ + awardpetid=petid; + strcpy(awardpet,pet); + }else{ + awardpetid=-1; + } + if(itemid>0){ + awarditemid=itemid; + strcpy(awarditem,item); + }else{ + awarditemid=-1; + } +} + +#ifdef _NONUM_AUTOPK +void AutoPk_ChampionShipSet( char *cdkey, char *name,int winnum, int win ) +{ + strcpy(ship[win].cdkey, cdkey); + strcpy(ship[win].name, name); + ship[win].winnum=winnum; +} +#else +void AutoPk_ChampionShipSet( char *cdkey, char *name, int winnum, int win ) +{ + if(win==0){ + char token[64]; + if(winnum>ship[0].winnum){ + sprintf( token, "[ս]%sĿǰһɱ%d", name, winnum); + AutoPk_PKSystemTalk(token,token); + if(strstr(ship[0].cdkey,cdkey) && strstr(ship[0].name,name)){ + ship[0].winnum=winnum; + }else if(strstr(ship[1].cdkey,cdkey) && strstr(ship[1].name,name)){ + ship[1].winnum=ship[0].winnum; + strcpy(ship[1].cdkey, ship[0].cdkey); + strcpy(ship[1].name, ship[0].name); + ship[0].winnum=winnum; + strcpy(ship[0].cdkey, cdkey); + strcpy(ship[0].name, name); + }else{ + ship[2].winnum=ship[1].winnum; + strcpy(ship[2].cdkey, ship[1].cdkey); + strcpy(ship[2].name, ship[1].name); + ship[1].winnum=ship[0].winnum; + strcpy(ship[1].cdkey, ship[0].cdkey); + strcpy(ship[1].name, ship[0].name); + ship[0].winnum=winnum; + strcpy(ship[0].cdkey, cdkey); + strcpy(ship[0].name, name); + } + }else if(winnum>ship[1].winnum){ + sprintf( token, "[ս]%sĿǰڶɱ%d", name, winnum); + AutoPk_PKSystemTalk(token,token); + if(strstr(ship[1].cdkey,cdkey) && strstr(ship[1].name,name)){ + ship[1].winnum=winnum; + }else{ + ship[2].winnum=ship[1].winnum; + strcpy(ship[2].cdkey, ship[1].cdkey); + strcpy(ship[2].name, ship[1].name); + ship[1].winnum=winnum; + strcpy(ship[1].cdkey, cdkey); + strcpy(ship[1].name, name); + } + }else if(winnum>ship[2].winnum){ + sprintf( token, "[ս]%sĿǰɱ%d", name, winnum); + AutoPk_PKSystemTalk(token,token); + ship[2].winnum=winnum; + strcpy(ship[2].cdkey, cdkey); + strcpy(ship[2].name, name); + } + }else if(win==1){ + ship[3].winnum=winnum; + strcpy(ship[3].cdkey, cdkey); + strcpy(ship[3].name, name); + }else if(win==2){ + ship[4].winnum=winnum; + strcpy(ship[4].cdkey, cdkey); + strcpy(ship[4].name, name); + } +} +#endif + + +void AutoPk_GetChampionShip( void ) +{ + char token[64]; + if(strlen(ship[0].cdkey)>0){ + sprintf( token, "[]񶷴ھߡ%s", ship[0].name); + AutoPk_PKSystemTalk(token,token); + AutoPk_PKTimeSetOnly(-1); + autopkstart=0; + } + if(strlen(ship[1].cdkey)>0){ + sprintf( token, "[]񶷴Ǿߡ%s", ship[1].name); + AutoPk_PKSystemTalk(token,token); + } + if(strlen(ship[2].cdkey)>0){ + sprintf( token, "[]񶷴ߡ%s", ship[2].name); + AutoPk_PKSystemTalk(token,token); + } + if(strlen(ship[3].cdkey)>0 && strlen(ship[4].cdkey)>0){ + //sprintf( token, "ϲ%s%sñPKĺ͵", ship[3].name,ship[4].name); + //AutoPk_PKSystemTalk(token,token); + } + autopktype = 0; + AutoPk_SetHistoryStr(); + + + + baward = TRUE; +} + +BOOL AutoPk_AddItem( int charindex, int index ) +{ + char msgbuf[64]; + int ret; + int spaceNum=5,i,itemindex=-1; + itemindex = CHAR_findEmptyItemBox( charindex ); + if( itemindex < 0 ) { + CHAR_talkToCli( charindex, -1, "Ʒռ䲻㣡", CHAR_COLORYELLOW); + return FALSE; + } + + itemindex = ITEM_makeItemAndRegist( award[index].awarditemid ); + if(itemindex == -1) + return FALSE; + ret = CHAR_addItemSpecificItemIndex( charindex, itemindex); + if( ret < 0 || ret >= CHAR_MAXITEMHAVE ) { + ITEM_endExistItemsOne( itemindex ); + print ("\n ret error!!"); + return FALSE; + } + sprintf( msgbuf,"õ%s",ITEM_getChar( itemindex, ITEM_NAME)); + CHAR_talkToCli( charindex, -1, msgbuf, CHAR_COLORYELLOW ); + CHAR_sendItemDataOne( charindex, ret); + return TRUE; +} + +BOOL AutoPk_AddPet( int charindex, int index) +{ + int ret; + char msgbuf[64]; + int enemynum; + int i,j; + int petindex, petindex2; + + for( i = 0 ;i < CHAR_MAXPETHAVE ; i++) { + petindex = CHAR_getCharPet( charindex, i); + if( petindex == -1 ) + break; + } + + if( i == CHAR_MAXPETHAVE ) { + snprintf( msgbuf,sizeof( msgbuf), ""); + CHAR_talkToCli( charindex, -1, msgbuf, CHAR_COLORYELLOW); + return FALSE; + } + + enemynum = ENEMY_getEnemyNum(); + for( i = 0; i < enemynum; i ++ ) { + if( ENEMY_getInt( i, ENEMY_ID) == award[index].awardpetid) { + break; + } + } + + if( i == enemynum ) + return FALSE; + + ret = ENEMY_createPetFromEnemyIndex( charindex, i); + for( i = 0; i < CHAR_MAXPETHAVE; i ++ ) { + if( CHAR_getCharPet( charindex, i ) == ret ) + break; + } + + petindex2 = CHAR_getCharPet(charindex, i); + if( !CHAR_CHECKINDEX( petindex2) ) + return FALSE; + snprintf( msgbuf,sizeof( msgbuf), "õ%s", CHAR_getChar(petindex2,CHAR_NAME)); + CHAR_talkToCli( charindex, -1, msgbuf, CHAR_COLORYELLOW); + CHAR_setInt(petindex2,CHAR_VARIABLEAI,10000); + for(j = 0; j < CHAR_MAXPETHAVE; j++){ + petindex = CHAR_getCharPet(charindex, j); + if( !CHAR_CHECKINDEX( petindex) ) + continue; + CHAR_complianceParameter( petindex ); + snprintf( msgbuf, sizeof( msgbuf ), "K%d", j ); + CHAR_sendStatusString( charindex, msgbuf ); + snprintf( msgbuf, sizeof( msgbuf ), "W%d", j ); + CHAR_sendStatusString( charindex, msgbuf ); + } + return TRUE; +} + +void NPC_AUTOPKHealerTalked( int meindex ) +{ + if( CHAR_getInt( meindex , CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER ) return; + + if( (CHAR_getWorkInt( meindex, CHAR_WORKPARTYMODE) == 0) + || (CHAR_getWorkInt( meindex, CHAR_WORKPARTYMODE) == 2) ) + { + + NPC_HealerAllHeal( meindex); + CHAR_talkToCli( meindex, -1,"ϲʤȴֱȫظ",CHAR_COLORYELLOW); + }else{ + int i = 0; + int otherindex; + + for( i=0 ; i < CHAR_PARTYMAX ; i++) + { + otherindex = CHAR_getWorkInt( meindex, CHAR_WORKPARTYINDEX1 + i); + if(otherindex != -1){ + + NPC_HealerAllHeal( otherindex); + CHAR_talkToCli( otherindex, -1,"ϲʤȫظ",CHAR_COLORYELLOW); + } + } + } +} + +BOOL AutoPk_GetAwardStr( void ) +{ + FILE* fp; + int i=0; + int j=0; + int enemynum = ENEMY_getEnemyNum(); + fp = fopen("./data/autopk/autopkaward.txt", "r"); + if (fp == NULL) + { + print("鿴Ʒļ򿪴\n"); + return FALSE; + } + for(i=0;i<5;i++){ + char line[64],buf[32]; + if (fgets(line, sizeof(line), fp) == NULL)break; + chop(line); + getStringFromIndexWithDelim(line,"|", 1, buf, sizeof(buf)); + award[i].awardpetid=atoi(buf); + if(award[i].awardpetid!=-1){ + for( j=0; j 0 && award[i].awarditemid <= getItemnum() ){ + strcpy(award[i].awarditem,ITEM_getNameFromNumber(award[i].awarditemid)); + } + else{ + strcpy(award[i].awarditem, "\0"); + award[i].draw=AWARDNO; + } + } + fclose(fp); + return TRUE; +} + +void AutoPk_SetAwardStr( char *token ) +{ + FILE* fp; + int i=0; + fp = fopen("./data/autopk/autopkaward.txt", "w"); + fwrite(token, strlen(token), 1, fp); + fclose(fp); +} + +void AutoPk_PKSystemStart( void ) +{ + int i,charaindex,num=0; + int pkindex[1000],pktype[1000]; + int playernum=CHAR_getPlayerMaxNum(); + for(i=0;i=2){ + if(num%2==0){ + int j = num-1; + i=0; + for(i=0;i +#include "char.h" +#include "object.h" +#include "char_base.h" +#include "npcutil.h" +#include "configfile.h" +#include "lssproto_serv.h" +#include "saacproto_cli.h" +#include "npc_bankman.h" +#include "family.h" + +extern int familyNumTotal; +extern char familyListBuf[MAXFAMILYLIST]; + +char sendbuf[1024]; +char buf[1024]; +char subbuf[128]; +int i, j; + + +struct { + int windowno; + int windowtype; + int buttontype; + int takeitem; + int giveitem; + char message[4096]; +}w; + +struct { + BOOL use; + int checkhaveitem; + int checkhaveitemgotowin; + int checkdonthaveitem; + int checkdonthaveitemgotowin; + int warp; + int battle; + int gotowin; +}buttonproc[13]; /* ok,cancel, yes,no,prev,next ݼ */ + + + + + +enum { + CHAR_WORK_MSGCOLOR = CHAR_NPCWORKINT1, +}; +static void NPC_Bankman_selectWindow( int meindex, int toindex, int num); +static BOOL NPC_Bankman_readData( int meindex, int windowno, BOOL chkflg); +static int NPC_Bankman_restoreButtontype( char *data ); + +BOOL NPC_BankmanInit( int meindex ) +{ + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + char buf[1024]; + NPC_Util_GetArgStr( meindex, argstr, sizeof( argstr)); + + if( NPC_Util_GetStrFromStrWithDelim( argstr, "conff", buf, sizeof( buf))== NULL ){ + print( "familyman:ûָ趨ĵ \n"); + return FALSE; + } + /* ݱɬ÷ëƻ֧ */ + if( !NPC_Bankman_readData( meindex, -1, TRUE) ) { + return FALSE; + } + + CHAR_setInt( meindex , CHAR_WHICHTYPE , CHAR_TYPEWINDOWMAN ); + + return TRUE; +} + +void NPC_BankmanTalked( int meindex , int talkerindex , char *szMes ,int color ) +{ + + NPC_Bankman_selectWindow( meindex, talkerindex, 1 ); + +} + +void NPC_BankmanLooked( int meindex , int lookedindex) +{ + + print(" Look:me:%d,looked:%d ",meindex,lookedindex); + NPC_Bankman_selectWindow( meindex, lookedindex,1 ); + +} + +static void NPC_Bankman_selectWindow( int meindex, int toindex, int num) +{ + + int fd; + char buf[256]; + + /* 帲ƻ ɱ */ + if( CHAR_getInt( toindex , CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER ) { + return; + } + /* */ + if( !NPC_Util_charIsInFrontOfChar( toindex, meindex, 1 )) return; + + if( !NPC_Bankman_readData( meindex, num, FALSE) ) { + print( "familyman:readdata error\n"); + return; + } + + fd = getfdFromCharaIndex( toindex); + if( fd != -1 ) { + lssproto_WN_send( fd, w.windowtype, + w.buttontype, + w.windowno+100, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + makeEscapeString( w.message, buf, sizeof(buf))); + } +} + +void NPC_BankmanWindowTalked( int meindex, int talkerindex, + int seqno, int select, char *data) + +{ + + int button = -1; + char buf[2048], buff[256]; + + /* */ + if( NPC_Util_CharDistance( talkerindex, meindex ) > 1) return; + + /* ū įë */ + if( !NPC_Bankman_readData( meindex, seqno - 100, FALSE) ) { + print( "familyman:readdata error\n"); + return; + } + /* ʾëƩ */ + if( w.windowtype == WINDOW_MESSAGETYPE_SELECT ) { + //if( w.windowtype == WINDOW_MESSAGETYPE_MESSAGE ) { + // shan end + button = atoi( data)+5; + if( button > 12 ) { + print( "familyman:invalid button[%d]\n", button); + return; + } + } + else if( select & WINDOW_BUTTONTYPE_OK) button = 0; + else if( select & WINDOW_BUTTONTYPE_CANCEL) button = 1; + else if( select & WINDOW_BUTTONTYPE_YES) button = 2; + else if( select & WINDOW_BUTTONTYPE_NO) button = 3; + else if( select & WINDOW_BUTTONTYPE_PREV) button = 4; + else if( select & WINDOW_BUTTONTYPE_NEXT) button = 5; + else { + print( "familyman:invalid button[%d]\n", select); + return; + } + // shan begin + //if( buttonproc[button].use == TRUE ) { + //if( select > 0) { + if( button > 0 ) { + // shan end + int fd; + int newwin = -1; + + fd = getfdFromCharaIndex( talkerindex); + + /* ʾ巽Ȼ ëԻ */ + if( newwin == -1 ) { + newwin = buttonproc[button].gotowin; + } + + // Robin + // + // shan begin + if( select == WINDOW_BUTTONTYPE_YES) { + newwin = 5; + } + // shan end + if( newwin == 5 ) { + if( CHAR_getInt( talkerindex, CHAR_FMINDEX ) < 1 && + CHAR_getInt( talkerindex, CHAR_BANKGOLD) < 1 ) + lssproto_WN_send(fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, -1, -1, + makeEscapeString("\nʸ񲻷ϣ" + "\nȼ壡", buff, sizeof(buff))); + else { + sprintf(buf, "B|G|%d", CHAR_getInt( talkerindex, CHAR_BANKGOLD) ); + lssproto_FM_send( fd, buf ); + } + return; + } + // ʻ + if( newwin == 6 ) + { + if( CHAR_getInt( talkerindex, CHAR_FMINDEX ) > 0 ) + saacproto_ACGetFMData_send( acfd, CHAR_getChar( talkerindex, CHAR_FMNAME), + CHAR_getInt( talkerindex, CHAR_FMINDEX ), + CHAR_getWorkInt( talkerindex, CHAR_WORKFMINDEXI ), + 1, + CONNECT_getFdid(fd) + ); + else + lssproto_WN_send(fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, -1, -1, + makeEscapeString("\nʸ񲻷ϣ" + "\nȼ壡", buff, sizeof(buff))); + return; + } + // ˳ + if( newwin == 7 ) + { + if( CHAR_getInt( talkerindex, CHAR_FMINDEX ) == -1 ) { + lssproto_WN_send(fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, -1, -1, + makeEscapeString("\nʸ񲻷ϣ" + "\nȼ壡", buff, sizeof(buff))); + return; + } + + print(" WN2FM "); + FAMILY_Leave( fd, talkerindex, "E|1"); + + return; + } + + if( !NPC_Bankman_readData( meindex, newwin, FALSE) ) { + print( "familyman:readdata error\n"); + return; + } + if( fd != -1 ) { + lssproto_WN_send( fd, w.windowtype, + w.buttontype, + w.windowno+100, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + makeEscapeString( w.message, buf, sizeof(buf))); + } + + + + } +} + +static BOOL NPC_Bankman_readData( int meindex, int windowno, BOOL chkflg) +{ + + int i; + int linenum = 0; + int endflg = FALSE; + int buttonendflg; + int winno = -1; + int buttonconfmode; + int b_mode; + int selectnum ; + int messagepos; + BOOL errflg = FALSE; + BOOL readflg = TRUE; + FILE *fp; + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + char filename[64]; + char opfile[128]; + char line[1024]; + char firstToken[1024]; + char secondToken[1024]; + + NPC_Util_GetArgStr( meindex, argstr, sizeof( argstr)); + NPC_Util_GetStrFromStrWithDelim( argstr, "conff", filename, sizeof( filename)); + sprintf( opfile, "%s/", getNpcdir( ) ); + strcat( opfile, filename); + fp = fopen( opfile, "r"); + if( fp == NULL ) { + print( "familyman:file open error [%s]\n", opfile); + return FALSE; + } + + while( readflg == TRUE ) { + endflg = FALSE; + buttonendflg = TRUE; + buttonconfmode = FALSE; + selectnum = 0; + messagepos = 0; + winno = -1; + b_mode = -1; + errflg = FALSE; + + /* */ + w.windowno = -1; + w.windowtype = -1; + w.buttontype = -1; + w.takeitem = -1; + w.giveitem = -1; + w.message[0] = '\0'; + + for( i = 0; i < arraysizeof( buttonproc); i ++ ) { + buttonproc[i].use = FALSE; + buttonproc[i].checkhaveitem = -1; + buttonproc[i].checkhaveitemgotowin = -1; + buttonproc[i].checkdonthaveitem = -1; + buttonproc[i].checkdonthaveitemgotowin = -1; + buttonproc[i].warp = -1; + buttonproc[i].battle = -1; + buttonproc[i].gotowin = -1; + } + + while( 1) { + char buf[256]; + int ret; + if( !fgets( line, sizeof( line), fp)){ + readflg = FALSE; + break; + } + + linenum ++; + + /* 춪 */ + if( line[0] == '#' || line[0] == '\n') continue; + /* ݱ */ + chomp( line ); + + /* ë */ + /* tab ë " " 徧 */ + replaceString( line, '\t' , ' ' ); + /* ʸë£*/ + for( i = 0; i < strlen( line); i ++) { + if( line[i] != ' ' ) { + break; + } + strcpy( buf, &line[i]); + } + if( i != 0 ) strcpy( line, buf); + + /* delim "=" ƥ (1)ͼë */ + ret = getStringFromIndexWithDelim( line, "=", 1, firstToken, + sizeof( firstToken ) ); + if( ret == FALSE ){ + print( "Find error at %s in line %d. Ignore\n", + filename , linenum); + continue; + } + /* delim "=" ƥ2 ͼë */ + ret = getStringFromIndexWithDelim( line, "=", 2, secondToken, + sizeof( secondToken ) ); + if( ret == FALSE ){ + print( "Find error at %s in line %d. Ignore\n", + filename , linenum); + continue; + } + + if( strcasecmp( firstToken, "winno") == 0 ) { + if( winno != -1 ) { + print( "familyman:winnoȴ¶winno\n"); + print( "filename:[%s] line[%d]\n", filename, linenum); + errflg = TRUE; + readflg = FALSE; + break; + } + /* ūNoë */ + winno = atoi( secondToken); + continue; + } + /* ūNo Ȼئݼ淴 */ + if( winno == -1 ) { + print( "familyman:winno δ壬ȴ趨\n"); + print( "filename:[%s] line[%d]\n", filename, linenum); + readflg = FALSE; + errflg = FALSE; + break; + } + /* ūNo ݷë + * ľ½ */ + if( (chkflg == FALSE && winno == windowno )|| + chkflg == TRUE) + { + if( buttonconfmode == TRUE ) { + if( strcasecmp( firstToken, "gotowin") == 0 ) { + buttonproc[b_mode].gotowin = atoi( secondToken); + } + else if( strcasecmp( firstToken, "checkhaveitem") == 0 ) { + buttonproc[b_mode].checkhaveitem = atoi( secondToken); + } + else if( strcasecmp( firstToken, "haveitemgotowin") == 0 ) { + buttonproc[b_mode].checkhaveitemgotowin = atoi( secondToken); + } + else if( strcasecmp( firstToken, "checkdonthaveitem") == 0 ) { + buttonproc[b_mode].checkdonthaveitem = atoi( secondToken); + } + else if( strcasecmp( firstToken, "donthaveitemgotowin") == 0 ) { + buttonproc[b_mode].checkdonthaveitemgotowin = atoi( secondToken); + } + else if( strcasecmp( firstToken, "endbutton") == 0 ) { + if( buttonproc[b_mode].gotowin == - 1 ) { + if( buttonproc[b_mode].checkhaveitem == -1 && + buttonproc[b_mode].checkdonthaveitem == -1) + { + errflg = TRUE; + } + else { + /* оȵƥɬýľľ */ + if( !((buttonproc[b_mode].checkhaveitem != -1 && + buttonproc[b_mode].checkhaveitemgotowin != -1) + || (buttonproc[b_mode].checkdonthaveitem != -1 && + buttonproc[b_mode].checkdonthaveitemgotowin != -1))) + { + errflg = TRUE; + } + } + } + + if( errflg == TRUE) { + print( "familyman: Ҳgotowin\n"); + print( "filename:[%s] line[%d]\n", filename, linenum); + readflg = FALSE; + errflg = TRUE; + break; + } + buttonproc[b_mode].use = TRUE; + buttonconfmode = FALSE; + buttonendflg = TRUE; + } + } + else { + + w.windowno = winno; + /* ūɬ */ + if( strcasecmp( firstToken, "wintype") == 0 ) { + w.windowtype = atoi( secondToken); + } + /* ʾɬ */ + else if( strcasecmp( firstToken, "buttontype") == 0 ) { + w.buttontype = NPC_Bankman_restoreButtontype( secondToken); + } + /* getitemɬ */ + else if( strcasecmp( firstToken, "takeitem") == 0 ) { + w.takeitem = atoi( secondToken); + } + /* giveitemɬ */ + else if( strcasecmp( firstToken, "giveitem") == 0 ) { + w.giveitem = atoi( secondToken); + } + /* messageɬ */ + else if( strcasecmp( firstToken, "message") == 0 ) { + if( messagepos == 0 ) { + strcpy( w.message, secondToken); + messagepos = strlen( w.message); + } + else { + w.message[messagepos]='\n'; + messagepos++; + strcpy( &w.message[messagepos], secondToken); + messagepos+=strlen(secondToken); + } + } + /* ʾëݼɬ */ + else if( strcasecmp( firstToken, "okpressed") == 0 ) { + buttonconfmode = TRUE; + b_mode = 0; + buttonendflg = FALSE; + } + else if( strcasecmp( firstToken, "cancelpressed") == 0 ) { + buttonconfmode = TRUE; + b_mode = 1; + buttonendflg = FALSE; + } + else if( strcasecmp( firstToken, "yespressed") == 0 ) { + buttonconfmode = TRUE; + b_mode = 2; + buttonendflg = FALSE; + } + else if( strcasecmp( firstToken, "nopressed") == 0 ) { + buttonconfmode = TRUE; + b_mode = 3; + buttonendflg = FALSE; + } + else if( strcasecmp( firstToken, "prevpressed") == 0 ) { + buttonconfmode = TRUE; + b_mode = 4; + buttonendflg = FALSE; + } + else if( strcasecmp( firstToken, "nextpressed") == 0 ) { + buttonconfmode = TRUE; + b_mode = 5; + buttonendflg = FALSE; + } + else if( strcasecmp( firstToken, "selected") == 0 ) { + buttonconfmode = TRUE; + b_mode = 6 + selectnum; + buttonendflg = FALSE; + selectnum ++; + } + /* ɬñδԻ */ + else if( strcasecmp( firstToken, "endwin") == 0 ) { + endflg = TRUE; + if( chkflg == FALSE) { + readflg = FALSE; + } + break; + } + else { + print( "familyman:趨DzܵIJ\n"); + print( "filename:[%s] line[%d]\n", filename, linenum); + } + } + } + else { + if( strcasecmp( firstToken, "endwin") == 0 ) { + winno = -1; + } + } + } + if( buttonendflg == FALSE) { + print( "familyman: Ҳendbutton\n"); + print( "filename:[%s] line[%d]\n", filename, linenum); + errflg = TRUE; + break; + } + if( winno != -1 ) { + if( w.windowtype == -1 ) { + print( "familyman: Ҳwintype\n"); + print( "filename:[%s] line[%d]\n", filename, linenum); + errflg = TRUE; + break; + } + if( w.buttontype == -1 ) { + print( "familyman: Ҳbutton\n"); + print( "filename:[%s] line[%d]\n", filename, linenum); + errflg = TRUE; + break; + } + if( strlen( w.message) == 0 ) { + print( "familyman: Ҳmessage\n"); + print( "filename:[%s] line[%d]\n", filename, linenum); + errflg = TRUE; + break; + } + } + } + fclose( fp); + + if( chkflg == FALSE && w.windowno == -1 ) { + print( "familyman: Ҳָwindowno\n"); + print( "filename:[%s] line[%d]\n", filename, linenum); + return FALSE; + } + if( winno != -1 && endflg == FALSE) { + print( "familyman: Ҳendwin\n"); + print( "filename:[%s] line[%d]\n", filename, linenum); + return FALSE; + } + if( errflg == TRUE) return FALSE; + + return TRUE; +} +/* + * buttontype=ƥ϶ ٯ ëѰ £ + * + */ +static int NPC_Bankman_restoreButtontype( char *data ) +{ + int ret = 0; + int rc; + int i; + char buff[1024]; + + for( i = 1; ; i ++ ) { + rc = getStringFromIndexWithDelim( data, "|", i, buff, + sizeof( buff ) ); + if( rc == FALSE) break; + if( strcasecmp( buff, "ok") == 0 ) { + ret |= WINDOW_BUTTONTYPE_OK; + } + else if( strcasecmp( buff, "cancel") == 0 ) { + ret |= WINDOW_BUTTONTYPE_CANCEL; + } + else if( strcasecmp( buff, "yes") == 0 ) { + ret |= WINDOW_BUTTONTYPE_YES; + } + else if( strcasecmp( buff, "no") == 0 ) { + ret |= WINDOW_BUTTONTYPE_NO; + } + else if( strcasecmp( buff, "prev") == 0 ) { + ret |= WINDOW_BUTTONTYPE_PREV; + } + else if( strcasecmp( buff, "next") == 0 ) { + ret |= WINDOW_BUTTONTYPE_NEXT; + } + } + if( ret == 0 ) { + ret = atoi( data); + } + return ret; +} diff --git a/npc/npc_bigsmallmaster.c b/npc/npc_bigsmallmaster.c new file mode 100644 index 0000000..e69de29 diff --git a/npc/npc_bigsmallpet.c b/npc/npc_bigsmallpet.c new file mode 100644 index 0000000..e69de29 diff --git a/npc/npc_blackmarket.c b/npc/npc_blackmarket.c new file mode 100644 index 0000000..e69de29 diff --git a/npc/npc_bodylan.c b/npc/npc_bodylan.c new file mode 100644 index 0000000..db1fb72 --- /dev/null +++ b/npc/npc_bodylan.c @@ -0,0 +1,487 @@ +#include "version.h" +#include +#include "char.h" +#include "object.h" +#include "char_base.h" +#include "npcutil.h" +#include "lssproto_serv.h" +#include "npc_windowhealer.h" + + + + +/* + *ʾū¼ءë ɱNPC + * ƾľգ + * NPCINDEXë£ + * + *ȣNPCԻƥʧؤգʧëڳ + *NPCINDEXë ƻ¾ + * ئݷʧˡ + *жʧëƻëʧ£ + *ʧ ˡ ئ϶ü߷ + * + */ + +enum { + BODYLAN_E_COMMANDNUM = CHAR_NPCWORKINT1, // ѨӮ +}; + + +// ̼ƹ +enum{ + BODYLAN_WIN_FIRST, + BODYLAN_WIN_LAST_GOOD, + BODYLAN_WIN_LAST_NG, + BODYLAN_WIN_GOOD_NO, + BODYLAN_WIN_ALREADY, + BODYLAN_WIN_NOT_PREEVENT, + BODYLAN_WIN_END +}; + +static void NPC_BodyLan_Profit( int meindex, int playerindex ); + +static void NPC_BodyLan_Window( + int meindex, + int talkerindex, + int mode +); + + +/********************************* +* +*********************************/ +BOOL NPC_BodyLanInit( int meindex ) +{ + + char szP[256], szArg[4096]; + char buf[256]; + int i, needSeq; + + CHAR_setInt( meindex , CHAR_WHICHTYPE , CHAR_TYPEEVENT ); + + if( NPC_Util_GetArgStr( meindex, szArg, sizeof( szArg ) ) == NULL ){ + print( "npc_bodylan.c:û(%s)\n", + CHAR_getChar(meindex,CHAR_NPCARGUMENT) ); + return FALSE; + } + + + // ˡë + if( NPC_Util_GetStrFromStrWithDelim( szArg, "Act", szP, sizeof( szP ) ) == NULL ){ + print( "npc_bodylan:δ趨(%s)\n", szArg ); + return FALSE; + } + + for( i = 0 ; ; i ++ ){ + // ۢئ + if( getStringFromIndexWithDelim( szP, ",", i, buf, sizeof( buf)) != FALSE ){ + needSeq = atoi(buf); + // Ѩ̹ϵ ճƥ + if( needSeq < 0 ){ + if( i <= 0 ){ + print( "npc_bodylan:δ趨(%s)\n", szArg ); + } + // ë + CHAR_setWorkInt( meindex, BODYLAN_E_COMMANDNUM, i ); + break; + }else{ + // ƻ + } + }else{ + if( i <= 0 ){ + print( "npc_bodylan:δ趨(%s)\n", szArg ); + } + // ë + CHAR_setWorkInt( meindex, BODYLAN_E_COMMANDNUM, i ); + break; + } + } + + + + return TRUE; + +} + + + + +/********************************* +* ƾľݼ +*********************************/ +void NPC_BodyLanTalked( int meindex , int talkerindex , char *szMes ,int color ) +{ + char szP[256], szArg[4096]; + int EventNo = -1,Pre_Event = -1; + + /* 帲ƻ ɱ */ + if( CHAR_getInt( talkerindex , CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER ) { + return; + } + + /* */ + if( NPC_Util_CharDistance( talkerindex, meindex ) > 2 ) + { + return; + } + + // ¦ ٯ + if( NPC_Util_GetArgStr( meindex, szArg, sizeof( szArg ) ) == NULL ){ + print( "npc_bodylan.c:û(%s)\n", + CHAR_getChar(meindex,CHAR_NPCARGUMENT) ); + return ; + }else{ + // ì į + if( NPC_Util_GetStrFromStrWithDelim( szArg, "EventNo", szP, sizeof( szP ) ) != NULL ){ + EventNo = atoi(szP); + } + // ۢì į + if( NPC_Util_GetStrFromStrWithDelim( szArg, "Pre_Event", szP, sizeof( szP ) ) != NULL ){ + Pre_Event = atoi(szP); + } + } + + // ۢì įؤľ + if( Pre_Event >= 0 ){ + // ì帲ƻƻ¾ + if( NPC_EventCheckFlg( talkerindex, Pre_Event ) == FALSE ){ + // ۢìëʧƻئճ𼰱 + NPC_BodyLan_Window( meindex, talkerindex, BODYLAN_WIN_NOT_PREEVENT ); + return; + } + } + // ì įؤľ + if( EventNo >= 0 ){ + // ì帲ƻƻ¾ + if( NPC_EventCheckFlg( talkerindex, EventNo ) == TRUE ){ + // Ȼճ𼰱 + NPC_BodyLan_Window( meindex, talkerindex, BODYLAN_WIN_ALREADY ); + return; + } + } + + // ԳȻ׾ + if( CHAR_getWorkInt( talkerindex, CHAR_WORKTRADER ) == meindex ){ + + // ձѨ ƻ + if( CHAR_getWorkInt( talkerindex, CHAR_WORKSHOPRELEVANT ) + >= CHAR_getWorkInt( meindex, BODYLAN_E_COMMANDNUM ) + ){ + // + NPC_BodyLan_Window( meindex, talkerindex, BODYLAN_WIN_LAST_GOOD ); + return; + }else{ + // + NPC_BodyLan_Window( meindex, talkerindex, BODYLAN_WIN_LAST_NG ); + return; + } + }else{ + // ٻئƥ + // м̼͵ë + CHAR_setWorkInt( talkerindex, CHAR_WORKTRADER, meindex ); + // ˡ پձ + CHAR_setWorkInt( talkerindex, CHAR_WORKSHOPRELEVANT, 1 ); + + // ˱羮微ئؤ + NPC_BodyLan_Window( meindex, talkerindex, BODYLAN_WIN_FIRST ); + return; + } +} + + +/*======================================= + * watch + *======================================*/ +void NPC_BodyLanWatch( + int objmeindex, + int objmoveindex, + CHAR_ACTION act, + int x, + int y, + int dir, + int* opt, + int optlen +) +{ + char szP[256], szArg[4096]; + char buf[256]; + int actindex; + int meindex; + int seqNo, needSeq; + + // ƽҷ½ + if( OBJECT_getType(objmoveindex) != OBJTYPE_CHARA ) return; + actindex = OBJECT_getIndex(objmoveindex); + // ½ + if( CHAR_getInt( actindex, CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER ) return; + + // м̼͵ + meindex = OBJECT_getIndex(objmeindex); + + // мINDEXë ƻ¾ئľ + if( CHAR_getWorkInt( actindex, CHAR_WORKTRADER ) != meindex ){ + return; + } + + // ƥʧëƻ¾ + seqNo = CHAR_getWorkInt( actindex, CHAR_WORKSHOPRELEVANT ); + // ئ پ + if( seqNo < 1 )seqNo = 1; + + // ¦ ٯ + if( NPC_Util_GetArgStr( meindex, szArg, sizeof( szArg ) ) == NULL ){ + print( "npc_bodylan.c:û(%s)\n", + CHAR_getChar(meindex,CHAR_NPCARGUMENT) ); + return ; + } + + + // ˡë + if( NPC_Util_GetStrFromStrWithDelim( szArg, "Act", szP, sizeof( szP ) ) == NULL ){ + print( "npc_bodylan:δ趨(%s)\n", szArg ); + return; + } + + // ۢئ + if(getStringFromIndexWithDelim( szP, ",", seqNo, buf, sizeof( buf)) != FALSE ){ + needSeq = atoi(buf); + }else{ + // ئ⾮ئ پ + CHAR_setWorkInt( actindex, CHAR_WORKSHOPRELEVANT, 1 ); + +// print( "ͷˡص\n", seqNo, needSeq ); + // Ͼ微 + return; + } + + // ۢئʧ + if( needSeq == act ){ + // ף۳ľ +// print( "ɹ\(%d%d)\n", seqNo, needSeq ); + seqNo ++; + if( seqNo >= CHAR_getWorkInt( meindex, BODYLAN_E_COMMANDNUM ) ){ +// print( "ڴ˽\n" ); + } + // ë + CHAR_setWorkInt( actindex, CHAR_WORKSHOPRELEVANT, seqNo ); + }else{ + // پ֧Ի + CHAR_setWorkInt( actindex, CHAR_WORKSHOPRELEVANT, 1 ); +// print( "(%d%d)\n", seqNo, needSeq ); + } + +} + + + +//********* ݼ ********* +static void NPC_BodyLan_Profit( int meindex, int playerindex ) +{ + char szArg[4096], szP[256]; + int fl, x, y, pmode, i, subindex, parent; + + // ¦ ٯ + if( NPC_Util_GetArgStr( meindex, szArg, sizeof( szArg ) ) == NULL ){ + print( "npc_bodylan.c:û(%s)\n", + CHAR_getChar(meindex,CHAR_NPCARGUMENT) ); + return ; + } + + //********************************************* + // + // ۷ɬ + // + //********************************************* + if( NPC_Util_GetStrFromStrWithDelim( szArg, "Warp", szP, sizeof( szP ) ) != NULL ){ + // 工 + if( sscanf( szP, "%d,%d,%d", &fl, &x, &y ) == 3 ){ + }else{ + print( "npc_bodylan: ޷ȡռ(%s)\n", szP ); + return; + } + // ɡ ū׬ƥҼַ + pmode = CHAR_getWorkInt( playerindex, CHAR_WORKPARTYMODE ); + switch( pmode ){ + case 1: // л + parent = playerindex; + break; + case 2: // лҼë + parent = CHAR_getWorkInt( playerindex, CHAR_WORKPARTYINDEX1 ); + break; + default: + // ɡ ūԪئף۷з귥 + CHAR_warpToSpecificPoint( playerindex, fl, x, y ); + return; + } + // 幻 + for( i = 0; i < CHAR_PARTYMAX; i ++ ){ + subindex = CHAR_getWorkInt( parent, CHAR_WORKPARTYINDEX1+i ); + if( CHAR_CHECKINDEX( subindex ) == FALSE )continue; + // ɡ ū幻 + CHAR_warpToSpecificPoint( subindex, fl, x, y ); + } + } + + + +} + +#if 1 +static void NPC_BodyLan_Window( + int meindex, + int talkerindex, + int mode +) +{ + char token[1024]; + char escapedname[2048]; + char szArg[4096]; + char szP[256]; + int fd; + int buttontype = 0, windowtype = 0, windowno = 0; + + if( CHAR_CHECKINDEX( talkerindex ) == FALSE )return; + fd = getfdFromCharaIndex( talkerindex ); + + // ¦ ٯ + if( NPC_Util_GetArgStr( meindex, szArg, sizeof( szArg ) ) == NULL ){ + print( "npc_bodylan.c:û(%s)\n", + CHAR_getChar(meindex,CHAR_NPCARGUMENT) ); + return ; + } + + szP[0] = 0; + + switch( mode ){ + case BODYLAN_WIN_FIRST: + // ٱ ľ + if( NPC_Util_GetStrFromStrWithDelim( szArg, "First", szP, sizeof( szP ) ) == NULL ){ + print( "npc_bodylan:һʼû(%s)\n", szArg ); + return; + } + sprintf( token,"%s", szP ); + buttontype=WINDOW_BUTTONTYPE_YES|WINDOW_BUTTONTYPE_NO; + windowtype=WINDOW_MESSAGETYPE_MESSAGE; + windowno=mode; + break; + + case BODYLAN_WIN_LAST_GOOD: + // ƥݩ + if( NPC_Util_GetStrFromStrWithDelim( szArg, "Good", szP, sizeof( szP ) ) == NULL ){ + print( "npc_bodylan:ʱ˵û(%s)\n", szArg ); + return; + } + sprintf( token,"%s", szP ); + buttontype=WINDOW_BUTTONTYPE_YESNO;// YES|NO + windowtype=WINDOW_MESSAGETYPE_MESSAGE; + windowno=mode; + break; + + case BODYLAN_WIN_LAST_NG: + // ƥݩ + if( NPC_Util_GetStrFromStrWithDelim( szArg, "Ng", szP, sizeof( szP ) ) == NULL ){ + print( "npc_bodylan:ʱ˵û(%s)\n", szArg ); + return; + } + sprintf( token,"%s", szP ); + buttontype=WINDOW_BUTTONTYPE_OK;// OK + windowtype=WINDOW_MESSAGETYPE_MESSAGE; + windowno=mode; + break; + + case BODYLAN_WIN_GOOD_NO: + // ݩݱ ëƽҼ + if( NPC_Util_GetStrFromStrWithDelim( szArg, "Good_No", szP, sizeof( szP ) ) == NULL ){ + print( "npc_bodylan:ʱȡƷû(%s)\n", szArg ); + return; + } + sprintf( token,"%s", szP ); + buttontype=WINDOW_BUTTONTYPE_OK;// OK + windowtype=WINDOW_MESSAGETYPE_MESSAGE; + windowno=mode; + break; + + case BODYLAN_WIN_ALREADY: + // ƥìë ƻ + if( NPC_Util_GetStrFromStrWithDelim( szArg, "Good_No", szP, sizeof( szP ) ) == NULL ){ + print( "npc_bodylan:¼ʱû(%s)\n", szArg ); + return; + } + sprintf( token,"%s", szP ); + buttontype=WINDOW_BUTTONTYPE_OK; // OK + windowtype=WINDOW_MESSAGETYPE_MESSAGE; + windowno=mode; + break; + + case BODYLAN_WIN_NOT_PREEVENT: + // ۢئìëئƻئ + if( NPC_Util_GetStrFromStrWithDelim( szArg, "Pre_Not", szP, sizeof( szP ) ) == NULL ){ + print( "npc_bodylan:?ǰ¼û(%s)\n", szArg ); + return; + } + sprintf( token,"%s", szP ); + buttontype=WINDOW_BUTTONTYPE_OK; // OK + windowtype=WINDOW_MESSAGETYPE_MESSAGE; + windowno=mode; + break; + default: + return; + } + + makeEscapeString( token, escapedname, sizeof(escapedname)); + /*-ƥ˪--*/ + lssproto_WN_send( fd, windowtype, + buttontype, + windowno, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + escapedname); + + +} + + + +/*----------------------------------------- +ͷʧ߯Ȼݱ̫ľ£ +-------------------------------------------*/ +void NPC_BodyLanWindowTalked( + int meindex, + int talkerindex, + int seqno, + int select, + char *data +) +{ + + + if( NPC_Util_CharDistance( talkerindex, meindex ) > 2) return; + + switch( seqno){ + case BODYLAN_WIN_LAST_GOOD: // ݩݱOKɽľ + if(select==WINDOW_BUTTONTYPE_YES ){ + NPC_BodyLan_Profit( meindex, talkerindex ); + // м̼͵ë٨ľ + CHAR_setWorkInt( talkerindex, CHAR_WORKTRADER, -1 ); + // ˡ پձ + CHAR_setWorkInt( talkerindex, CHAR_WORKSHOPRELEVANT, 1 ); + }else + if( select == WINDOW_BUTTONTYPE_NO ){ + // ݩݱƽҼľ + NPC_BodyLan_Window( meindex, talkerindex, BODYLAN_WIN_GOOD_NO ); + // м̼͵ë٨ľ + CHAR_setWorkInt( talkerindex, CHAR_WORKTRADER, -1 ); + // ˡ پձ + CHAR_setWorkInt( talkerindex, CHAR_WORKSHOPRELEVANT, 1 ); + } + break; + default: + break; + } + +} + + + +#endif + diff --git a/npc/npc_bus.c b/npc/npc_bus.c new file mode 100644 index 0000000..553002c --- /dev/null +++ b/npc/npc_bus.c @@ -0,0 +1,731 @@ +#include "version.h" +#include +#include "char.h" +#include "object.h" +#include "char_base.h" +#include "npcutil.h" +#include "lssproto_serv.h" +#include "npc_bus.h" +#include "handletime.h" + +/* + * ﵩئëNPC + */ + +enum { + NPC_WORK_ROUTETOX = CHAR_NPCWORKINT1, /* ߣ */ + NPC_WORK_ROUTETOY = CHAR_NPCWORKINT2, /* ߣ */ + NPC_WORK_ROUTEPOINT = CHAR_NPCWORKINT3, /* */ + NPC_WORK_ROUNDTRIP = CHAR_NPCWORKINT4, /* 微Ի ߡ ࡰԻ */ + NPC_WORK_MODE = CHAR_NPCWORKINT5, + NPC_WORK_CURRENTROUTE = CHAR_NPCWORKINT6, + NPC_WORK_ROUTEMAX = CHAR_NPCWORKINT7, + NPC_WORK_WAITTIME = CHAR_NPCWORKINT8, + NPC_WORK_CURRENTTIME = CHAR_NPCWORKINT9, + NPC_WORK_SEFLG = CHAR_NPCWORKINT10, +}; + +/* ⼰enum */ +enum { + NPC_BUS_MSG_GETTINGON, + NPC_BUS_MSG_NOTPARTY, + NPC_BUS_MSG_OVERPARTY, + NPC_BUS_MSG_DENIEDITEM, + NPC_BUS_MSG_ALLOWITEM, + NPC_BUS_MSG_LEVEL, + NPC_BUS_MSG_GOLD, + NPC_BUS_MSG_EVENT, + NPC_BUS_MSG_START, + NPC_BUS_MSG_END, +}; +typedef struct { + char option[32]; + char defaultmsg[128]; +}NPC_BUS_MSG; +NPC_BUS_MSG busmsg[] = { + { "msg_gettingon", "PAON޷;ࡣ"}, + { "msg_notparty", "PAPAON޷ŶӼࡣ"}, + { "msg_overparty", "PAON"}, + { "msg_denieditem", "PAPAONҿɲҪߣ"}, + { "msg_allowitem", "~(ҪǸ߰!)"}, + { "msglevel", "PAPAONĵȼࡣ"}, + { "msg_stone", "PAPAONǮࡣ"}, + { "msg_event", "PAON޷ࡣ"}, + { "msg_start", "~()"}, + { "msg_end", "~()"} + +}; + +static int NPC_BusSetPoint( int meindex, char *argstr); +static void NPC_BusSetDestPoint( int meindex, char *argstr); +static BOOL NPC_BusCheckDeniedItem( int meindex, int charaindex, char *argstr); +static BOOL NPC_BusCheckLevel( int meindex, int charaindex, char *argstr); +static int NPC_BusCheckStone( int meindex, int charaindex, char *argstr); +static void NPC_BusSendMsg( int meindex, int talkerindex, int tablenum); +static int NPC_BusGetRoutePointNum( int meindex, char *argstr ); +static void NPC_Bus_walk( int meindex); + +#define NPC_BUS_LOOPTIME 200 + +/* ޷ɻ */ +#define NPC_BUS_WAITTIME_DEFAULT 180 + +#define NPC_BUS_WAITINGMODE_WAITTIME 5000 + +/********************************* +* +*********************************/ +BOOL NPC_BusInit( int meindex ) +{ + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE - 1024 * 20]; + int i; + char buf[256]; + int routenum; + int waittime; + int seflg; + + NPC_Util_GetArgStr( meindex, argstr, sizeof( argstr)); + + /* ئľئ¦Ѽ */ + routenum = NPC_Util_GetNumFromStrWithDelim( argstr, "routenum");//ʻ· + + if( routenum == -1 ) { + print( "npcbus:nothing routenum \n"); + return FALSE; + } + CHAR_setWorkInt( meindex, NPC_WORK_ROUTEMAX, routenum); + + for( i = 1; i <= routenum; i ++ ) { + char routetostring[64]; + snprintf( routetostring, sizeof( routetostring), "routeto%d", i); + if( NPC_Util_GetStrFromStrWithDelim( argstr, routetostring,buf, sizeof(buf)) + == NULL ) + { + print( "npcbus:nothing route to \n"); + return FALSE; + } + + } + waittime = NPC_Util_GetNumFromStrWithDelim( argstr, "waittime"); + + if( waittime == -1 ) waittime = NPC_BUS_WAITTIME_DEFAULT; + CHAR_setWorkInt( meindex, NPC_WORK_WAITTIME, waittime); + + seflg = NPC_Util_GetNumFromStrWithDelim( argstr, "seflg"); + + if( seflg == -1 ) seflg = TRUE; + CHAR_setWorkInt( meindex, NPC_WORK_SEFLG, seflg); + + CHAR_setInt( meindex , CHAR_WHICHTYPE , CHAR_TYPEBUS ); + + CHAR_setWorkInt( meindex, NPC_WORK_MODE, 0); + CHAR_setWorkInt( meindex, NPC_WORK_ROUTEPOINT, 2); + CHAR_setWorkInt( meindex, NPC_WORK_ROUNDTRIP, 0); + CHAR_setWorkInt( meindex, NPC_WORK_CURRENTROUTE, 0); + + CHAR_setInt( meindex, CHAR_LOOPINTERVAL, + NPC_BUS_WAITINGMODE_WAITTIME); + + /* ػë */ + CHAR_setWorkInt( meindex, NPC_WORK_CURRENTTIME, NowTime.tv_sec); + + for( i = 0; i < CHAR_PARTYMAX; i ++) { + CHAR_setWorkInt( meindex, CHAR_WORKPARTYINDEX1 + i, -1); + } + + /* */ +{ + int rev; + int r = CHAR_getWorkInt( meindex, NPC_WORK_ROUTEMAX); + CHAR_setWorkInt( meindex, NPC_WORK_CURRENTROUTE, RAND( 1, r)); + //print( "route:%d\n",CHAR_getWorkInt( meindex, NPC_WORK_CURRENTROUTE)); + + /* Ƿ */ + rev = NPC_Util_GetNumFromStrWithDelim( argstr, "reverse"); + + if( rev == 1 ) { + int num = NPC_BusGetRoutePointNum( meindex, argstr); + + if( num <= 0 ) { + print( "npcbus:֣\n"); + return FALSE; + } + CHAR_setWorkInt( meindex, NPC_WORK_ROUTEPOINT, num-1); + CHAR_setWorkInt( meindex, NPC_WORK_ROUNDTRIP, 1); + } + /* ë */ + NPC_BusSetPoint( meindex, argstr); + /* ë */ + NPC_BusSetDestPoint( meindex, argstr); +} + + return TRUE; +} + + +/********************************* +* ƾľݼ +*********************************/ +void NPC_BusTalked( int meindex , int talkerindex , char *szMes , + int color ) +{ + int i; + int partyflg = FALSE; + + /* 帲ƻ ɱ */ + if( CHAR_getInt( talkerindex , CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER ) { + return; + } + /* мɡ ū Ʃ */ + for( i = 0; i < CHAR_PARTYMAX; i ++ ) { + int index = CHAR_getWorkInt( meindex, CHAR_WORKPARTYINDEX1+i); + if( CHAR_CHECKINDEX(index)){ + if( index == talkerindex) { + partyflg = TRUE; + } + } + } + if( !partyflg ) { + //NPC_BusCheckJoinParty( meindex, talkerindex, TRUE); + } + else { + if( CHAR_getWorkInt( meindex, NPC_WORK_MODE) == 0 ) { + int i; + // #define NPC_BUS_DEBUGROUTINTG "routingtable:" + if( strstr( szMes, "" ) || + strstr( szMes, "" ) || + strstr( szMes, "Go" ) || + strstr( szMes, "go" )) + { + CHAR_setWorkInt( meindex, NPC_WORK_MODE,1); + + /* Ѽëʻպ */ + CHAR_setInt( meindex, CHAR_LOOPINTERVAL, NPC_BUS_LOOPTIME); + /* SE Ѩƹ̫ */ + if( CHAR_getWorkInt( meindex, NPC_WORK_SEFLG )) { + CHAR_sendSEoArroundCharacter( + CHAR_getInt( meindex, CHAR_FLOOR), + CHAR_getInt( meindex, CHAR_X), + CHAR_getInt( meindex, CHAR_Y), + 60, + TRUE); + } + /* ݼ*/ + for( i = 1; i < CHAR_PARTYMAX; i ++ ) { + int partyindex = CHAR_getWorkInt( meindex, CHAR_WORKPARTYINDEX1+i); + if( CHAR_CHECKINDEX( partyindex)) { + NPC_BusSendMsg( meindex, partyindex, NPC_BUS_MSG_START); + } + } + } + } + } +} +/************************************** + * + **************************************/ +void NPC_BusLoop( int meindex) +{ + int i; + switch( CHAR_getWorkInt( meindex, NPC_WORK_MODE )) { + case 0: + /* ƹݣë */ + /* ޻׼ƥ */ + if( CHAR_getWorkInt( meindex, NPC_WORK_CURRENTTIME) + + CHAR_getWorkInt( meindex, NPC_WORK_WAITTIME) + < NowTime.tv_sec) + { + /* SE Ѩƹ̫ */ + if( CHAR_getWorkInt( meindex, NPC_WORK_SEFLG )) { + CHAR_sendSEoArroundCharacter( + CHAR_getInt( meindex, CHAR_FLOOR), + CHAR_getInt( meindex, CHAR_X), + CHAR_getInt( meindex, CHAR_Y), + 60, + TRUE); + } + /* ݼ*/ + for( i = 1; i < CHAR_PARTYMAX; i ++ ) { + int partyindex = CHAR_getWorkInt( meindex, CHAR_WORKPARTYINDEX1+i); + if( CHAR_CHECKINDEX( partyindex)) { + NPC_BusSendMsg( meindex, partyindex, NPC_BUS_MSG_START); + } + } + + CHAR_setWorkInt( meindex, NPC_WORK_MODE,1); + /* Ѽëʻպ */ + CHAR_setInt( meindex, CHAR_LOOPINTERVAL, NPC_BUS_LOOPTIME); + } + return; + case 1: + /* */ + NPC_Bus_walk( meindex); + case 2: + /* Ȼƹ */ + /* ޻׼ƥ */ + if( CHAR_getWorkInt( meindex, NPC_WORK_CURRENTTIME) + + (CHAR_getWorkInt( meindex, NPC_WORK_WAITTIME) /3) + < NowTime.tv_sec) + { + CHAR_setWorkInt( meindex, NPC_WORK_MODE,1); + /* Ѽëʻպ */ + CHAR_setInt( meindex, CHAR_LOOPINTERVAL, NPC_BUS_LOOPTIME); + + } + return; + case 3: + /* ƻ֣ͷʧ мб + * Ƴƥëľ֧ + */ + if( CHAR_getWorkInt( meindex, NPC_WORK_CURRENTTIME) + 3 + < NowTime.tv_sec) + { + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE - 1024 * 20]; + + NPC_Util_GetArgStr( meindex, argstr, sizeof( argstr)); + /* Ѽë */ + CHAR_setInt( meindex, CHAR_LOOPINTERVAL, + NPC_BUS_WAITINGMODE_WAITTIME); + + /* */ + { + int r = CHAR_getWorkInt( meindex, NPC_WORK_ROUTEMAX); + CHAR_setWorkInt( meindex, NPC_WORK_CURRENTROUTE, RAND( 1, r)); + //print( "route:%d\n",CHAR_getWorkInt( meindex, NPC_WORK_CURRENTROUTE)); + } + /* Ի׷º */ + CHAR_setWorkInt( meindex, NPC_WORK_ROUNDTRIP, + CHAR_getWorkInt( meindex, NPC_WORK_ROUNDTRIP)^1); + + /* ݺ̼Ʃ */ + /* Ի */ + if( CHAR_getWorkInt( meindex, NPC_WORK_ROUNDTRIP) == 1) { + /* κ̼ë */ + int num = NPC_BusGetRoutePointNum( meindex, argstr); + CHAR_setWorkInt( meindex, NPC_WORK_ROUTEPOINT, num-1); + } + else { + CHAR_setWorkInt( meindex, NPC_WORK_ROUTEPOINT, + CHAR_getWorkInt( meindex, NPC_WORK_ROUTEPOINT) +1); + } + /* ݼ̼ ë */ + NPC_BusSetPoint( meindex, argstr); + /* ë */ + NPC_BusSetDestPoint( meindex, argstr); + /* ɡ ū ë */ + CHAR_DischargeParty( meindex, 0); + /* ػë */ + CHAR_setWorkInt( meindex, NPC_WORK_CURRENTTIME, NowTime.tv_sec); + /* ƹʧ */ + CHAR_setWorkInt( meindex, NPC_WORK_MODE, 0); + } + return; + default: + break; + } +} +/************************************** + * ʣ + **************************************/ +static void NPC_Bus_walk( int meindex) +{ + POINT start, end; + int dir; + int ret; + int i; + + /* */ + /* ݼ */ + start.x = CHAR_getInt( meindex, CHAR_X); + start.y = CHAR_getInt( meindex, CHAR_Y); + end.x = CHAR_getWorkInt( meindex, NPC_WORK_ROUTETOX); + end.y = CHAR_getWorkInt( meindex, NPC_WORK_ROUTETOY); + + /* ׼ƥݼ̼ */ + if( start.x == end.x && start.y == end.y ) { + int add = 1; + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE - 1024 * 20]; + + NPC_Util_GetArgStr( meindex, argstr, sizeof( argstr)); + + if( CHAR_getWorkInt( meindex, NPC_WORK_ROUNDTRIP ) == 1 ) { + add *= -1; + } + CHAR_setWorkInt( meindex, NPC_WORK_ROUTEPOINT, + CHAR_getWorkInt( meindex, NPC_WORK_ROUTEPOINT) +add); + if( NPC_BusSetPoint( meindex, argstr) == FALSE ) { + /* */ + /* ƹ */ + CHAR_setWorkInt( meindex, NPC_WORK_MODE,3); + + /* SE Ѩƹ̫ */ + if( CHAR_getWorkInt( meindex, NPC_WORK_SEFLG )) { + CHAR_sendSEoArroundCharacter( + CHAR_getInt( meindex, CHAR_FLOOR), + CHAR_getInt( meindex, CHAR_X), + CHAR_getInt( meindex, CHAR_Y), + 60, + TRUE); + } + /* ݼ*/ + for( i = 1; i < CHAR_PARTYMAX; i ++ ) { + int partyindex = CHAR_getWorkInt( meindex, CHAR_WORKPARTYINDEX1+i); + if( CHAR_CHECKINDEX( partyindex)) { + NPC_BusSendMsg( meindex, partyindex, NPC_BUS_MSG_END); + } + } + /* ػë */ + CHAR_setWorkInt( meindex, NPC_WORK_CURRENTTIME, NowTime.tv_sec); + return; + } + else { + return; + } + } + /*-------------------------------------------------------*/ + /* ھ */ + + /* ëƻ */ + dir = NPC_Util_getDirFromTwoPoint( &start,&end ); + + /* ɡ ūƥ */ + end.x = CHAR_getInt( meindex, CHAR_X); + end.y = CHAR_getInt( meindex, CHAR_Y); + + /* Ⱦݼм */ + for( i = 0; i < 100; i ++ ) { + if( dir < 0 ) { + dir = RAND( 0,7); + } + dir = NPC_Util_SuberiWalk( meindex, dir); + if( dir >= 0 && dir <= 7) break; + } + + if( dir >= 0 && dir <= 7 ) { + /* */ + ret = CHAR_walk( meindex, dir, 0); + + if( ret == CHAR_WALKSUCCESSED ) { + /* лئëھ */ + int i; + for( i = 1; i < CHAR_PARTYMAX; i ++ ) { + int toindex = CHAR_getWorkInt( meindex, i + CHAR_WORKPARTYINDEX1); + if( CHAR_CHECKINDEX(toindex) ) { + int parent_dir; + /* Ҽ ʼ󡼰 ëƻ */ + /* */ + start.x = CHAR_getInt( toindex, CHAR_X); + start.y = CHAR_getInt( toindex, CHAR_Y); + parent_dir = NPC_Util_getDirFromTwoPoint( &start,&end ); + /* ·ūë ¿б + * ݼҷ󡼰Ҽ ëܰ + */ + end = start; + if( parent_dir != -1 ) { + CHAR_walk( toindex, parent_dir, 0); + } + } + } + } + } +} +/************************************** + * ݼë + **************************************/ +static int NPC_BusSetPoint( int meindex, char *argstr) +{ + char buf[4096]; + char buf2[256]; + char buf3[256]; + int ret; + char routetostring[64]; + + snprintf( routetostring, sizeof( routetostring), "routeto%d", + CHAR_getWorkInt( meindex, NPC_WORK_CURRENTROUTE)); + + if( NPC_Util_GetStrFromStrWithDelim( argstr, routetostring,buf, sizeof(buf)) + == NULL ) + { + print( "npcbus:nothing route \n"); + return FALSE; + } + ret = getStringFromIndexWithDelim( buf, ";", + CHAR_getWorkInt( meindex, NPC_WORK_ROUTEPOINT), + buf2, sizeof(buf2)); + + if( ret == FALSE ) return FALSE; + + ret = getStringFromIndexWithDelim( buf2, ",", 1, + buf3, sizeof(buf3)); + if( ret == FALSE) return FALSE; + CHAR_setWorkInt( meindex, NPC_WORK_ROUTETOX, atoi( buf3)); + + ret = getStringFromIndexWithDelim( buf2, ",", 2, + buf3, sizeof(buf3)); + if( ret == FALSE) return FALSE; + CHAR_setWorkInt( meindex, NPC_WORK_ROUTETOY, atoi( buf3)); + return TRUE; +} +/************************************** + * route įգ 󡻥ؤչľë + * į屾£ + **************************************/ +static void NPC_BusSetDestPoint( int meindex, char *argstr) +{ + char buf[256]; + char routename[256]; + + snprintf( routename, sizeof( routename), "routename%d", + CHAR_getWorkInt( meindex, NPC_WORK_CURRENTROUTE)); + + if( NPC_Util_GetStrFromStrWithDelim( argstr, routename, buf, sizeof( buf)) + != NULL ) + { + CHAR_setChar( meindex, CHAR_OWNTITLE, buf); + CHAR_sendCToArroundCharacter( CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX)); + } +} +/************************************** + * ϶ýľʧ ةë Ȼ¾ + * Ȼշֻ + **************************************/ +static BOOL NPC_BusCheckDeniedItem( int meindex, int charaindex, char *argstr) +{ + char buf[1024]; + BOOL found = TRUE; + + if( NPC_Util_GetStrFromStrWithDelim( argstr, "denieditem", buf, sizeof( buf)) + != NULL ) + { + int i; + int ret; + for( i = 1; ; i ++) { + int itemid; + char buf2[64]; + int j; + ret = getStringFromIndexWithDelim( buf, ",", i, buf2, sizeof(buf2)); + if( ret == FALSE ) break; + itemid = atoi( buf2); + for( j = 0; j < CHAR_MAXITEMHAVE; j ++) { + int itemindex = CHAR_getItemIndex( charaindex, j); + if( ITEM_CHECKINDEX( itemindex)) { + if( ITEM_getInt( itemindex, ITEM_ID) == itemid) { + found = FALSE; + break; + } + } + } + } + } + return found; +} +/************************************** + * ϶ýľʧ ةë Ȼ¾ + * Ȼئֻ + **************************************/ +BOOL NPC_BusCheckAllowItem( int meindex, int charaindex, BOOL pickupmode) +{ + char buf[1024]; + BOOL found = TRUE; + BOOL pickup = FALSE; + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE - 1024 * 20]; + + NPC_Util_GetArgStr( meindex, argstr, sizeof( argstr)); + + if( NPC_Util_GetStrFromStrWithDelim( argstr, "pickupitem", buf, sizeof( buf))!= NULL ){ + pickup = TRUE; + } + if( NPC_Util_GetStrFromStrWithDelim( argstr, "allowitem", buf, sizeof( buf))!= NULL ){ + int i; + int ret; + for( i = 1; ; i ++) { + int itemid; + char buf2[64]; + int j; + BOOL getflg; + ret = getStringFromIndexWithDelim( buf, ",", i, buf2, sizeof(buf2)); + if( ret == FALSE ) break; + itemid = atoi( buf2); + getflg = FALSE; + for( j = 0; j < CHAR_MAXITEMHAVE; j ++) { + int itemindex = CHAR_getItemIndex( charaindex, j); + if( ITEM_CHECKINDEX( itemindex)) { + if( ITEM_getInt( itemindex, ITEM_ID) == itemid) { + if( pickupmode && pickup && !getflg) { + CHAR_DelItem( charaindex, j); + getflg = TRUE; + } + break; + } + } + } + if( j == CHAR_MAXITEMHAVE) { + found = FALSE; + break; + } + } + } + return found; +} + +/************************************** + * ϶ýľìﶯ + **************************************/ +static BOOL NPC_BusCheckLevel( int meindex, int charaindex, char *argstr) +{ + int level; + + /* ئľئ¦Ѽ */ + level = NPC_Util_GetNumFromStrWithDelim( argstr, "needlevel"); + if( level == -1 ) { + return TRUE; + } + if( CHAR_getInt( charaindex, CHAR_LV) >= level ) return TRUE; + + return FALSE; +} +/************************************** + * ë + * -1 0 ݾ ۢStone + **************************************/ +static int NPC_BusCheckStone( int meindex, int charaindex, char *argstr) +{ + int gold; + + /* ئľئ¦Ѽ */ + gold = NPC_Util_GetNumFromStrWithDelim( argstr, "needstone"); + if( gold == -1 ) { + return 0; + } + if( CHAR_getInt( charaindex, CHAR_GOLD) >= gold ) return gold; + + return -1; +} +/************************************** + * ë˪ + * ¦Ѽ⻥ئľɷɻë˪ + **************************************/ +static void NPC_BusSendMsg( int meindex, int talkerindex, int tablenum) +{ + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE - 1024 * 20]; + char buf[256]; + char msg[256]; + if( tablenum < 0 || tablenum >= arraysizeof( busmsg)) return; + + NPC_Util_GetArgStr( meindex, argstr, sizeof( argstr)); + + if( NPC_Util_GetStrFromStrWithDelim( argstr, busmsg[tablenum].option, buf, sizeof( buf)) + != NULL ) + { + strcpy( msg, buf); + } + else { + snprintf( msg, sizeof(msg),busmsg[tablenum].defaultmsg); + } + CHAR_talkToCli( talkerindex, meindex, msg, CHAR_COLORYELLOW); +} +/************************************** + * ƤP̼ë + **************************************/ +static int NPC_BusGetRoutePointNum( int meindex, char *argstr ) +{ + int i; + char buf[4096]; + char buf2[256]; + int ret; + char routetostring[64]; + + snprintf( routetostring, sizeof( routetostring), "routeto%d", + CHAR_getWorkInt( meindex, NPC_WORK_CURRENTROUTE)); + + if( NPC_Util_GetStrFromStrWithDelim( argstr, routetostring,buf, sizeof(buf)) + == NULL ) + { + print( "npcbus:nothing route \n"); + return -1; + } + for( i = 1; ; i ++ ) { + ret = getStringFromIndexWithDelim( buf, ";", i, buf2, sizeof(buf2)); + if( ret == FALSE) break; + } + return( i -1); +} +BOOL NPC_BusCheckJoinParty( int meindex, int charaindex, BOOL msgflg) +{ + //int fd; + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE - 1024 * 20]; + int ret; + NPC_Util_GetArgStr( meindex, argstr, sizeof( argstr)); + + /* */ + if( !NPC_Util_charIsInFrontOfChar( charaindex, meindex, 1 )) return FALSE; + /* ַ */ + if( CHAR_getWorkInt( meindex, NPC_WORK_MODE) != 0 ) { + if( msgflg) NPC_BusSendMsg( meindex, charaindex, NPC_BUS_MSG_GETTINGON); + return FALSE; + } + /* շֻ */ + if( CHAR_getWorkInt( charaindex, CHAR_WORKPARTYMODE ) != CHAR_PARTY_NONE) { + if( msgflg) NPC_BusSendMsg( meindex, charaindex, NPC_BUS_MSG_NOTPARTY); + return FALSE; + } + /* ɡ ūë */ + if( CHAR_getEmptyPartyArray( meindex) == -1 ) { + if( msgflg) NPC_BusSendMsg( meindex, charaindex, NPC_BUS_MSG_OVERPARTY); + return FALSE; + } + /* ʧ ةë(ʧ ة) */ + if( !NPC_BusCheckDeniedItem( meindex, charaindex, argstr)) { + if( msgflg) NPC_BusSendMsg( meindex, charaindex, NPC_BUS_MSG_DENIEDITEM); + return FALSE; + } +#ifdef _ITEM_CHECKWARES + if( CHAR_CheckInItemForWares( charaindex, 0) == FALSE ) { + CHAR_talkToCli( charaindex, -1, "޷Яϳ", CHAR_COLORYELLOW); + return FALSE; + } +#endif + /* ʧ ةë( ۢʧ ة) */ + if( !NPC_BusCheckAllowItem( meindex, charaindex, FALSE)) { + if( msgflg) NPC_BusSendMsg( meindex, charaindex, NPC_BUS_MSG_ALLOWITEM); + return FALSE; + } + /* ìPë */ + if( !NPC_BusCheckLevel( meindex, charaindex, argstr)) { + if( msgflg) NPC_BusSendMsg( meindex, charaindex, NPC_BUS_MSG_LEVEL); + return FALSE; + } + /* ì */ +// if( CHAR_getInt( charaindex, CHAR_NOWEVENT) != 0 || +// CHAR_getInt( charaindex, CHAR_NOWEVENT2) != 0 || +// CHAR_getInt( charaindex, CHAR_NOWEVENT3) != 0 ) +// { +// if( msgflg) NPC_BusSendMsg( meindex, charaindex, NPC_BUS_MSG_EVENT); +// return FALSE; +// } + /* żë ë¼ƥ ͱ³ */ + ret = NPC_BusCheckStone( meindex, charaindex, argstr); + if( ret == -1 ) { + if( msgflg) NPC_BusSendMsg( meindex, charaindex, NPC_BUS_MSG_GOLD); + return FALSE; + } + if( ret != 0 ) { + char msgbuf[128]; + /* ë */ + CHAR_setInt( charaindex, CHAR_GOLD, + CHAR_getInt( charaindex, CHAR_GOLD) - ret); + /* ˪ */ + CHAR_send_P_StatusString( charaindex, CHAR_P_STRING_GOLD); + snprintf( msgbuf, sizeof( msgbuf), "֧%d Stone", ret); + CHAR_talkToCli( charaindex, -1, msgbuf, CHAR_COLORYELLOW); + } + /* ɡ ū */ + //CHAR_JoinParty_Main( charaindex, meindex); + + //fd = getfdFromCharaIndex( charaindex ); + + //lssproto_PR_send( fd, 1, 1); + + + return TRUE; +} diff --git a/npc/npc_charm.c b/npc/npc_charm.c new file mode 100644 index 0000000..0c4e401 --- /dev/null +++ b/npc/npc_charm.c @@ -0,0 +1,285 @@ +#include "version.h" +#include +#include "char.h" +#include "object.h" +#include "char_base.h" +#include "npcutil.h" +#include "lssproto_serv.h" +#include "npc_charm.h" + +// ҽë ʻңֿ + +//ì ػ / + +//ڷƥʣ +/* +#define RATE 4 // +#define CHARMHEAL 5 // +#define WARU 3 // ë° + +*/ + +#define RATE 10 // +#define CHARMHEAL 5 // +#define WARU 3 // ë° + + +static void NPC_Charm_selectWindow( int meindex, int toindex, int num); +int NPC_CharmCost(int meindex,int talker); +void NPC_CharmUp(int meindex,int talker); + + +/********************************* +* +*********************************/ +BOOL NPC_CharmInit( int meindex ) +{ + /*--ƽҷ¼ëɬ--*/ + CHAR_setInt( meindex , CHAR_WHICHTYPE , CHAR_TYPECHARM ); + return TRUE; + +} + + +/********************************* +* ƾľݼ +*********************************/ +void NPC_CharmTalked( int meindex , int talkerindex , char *szMes ,int color ) +{ + + /* 帲ƻ ɱ */ + if( CHAR_getInt( talkerindex , CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER ) + { + return; + } + + /*-- ¾--*/ + if(NPC_Util_isFaceToFace( meindex ,talkerindex , 2) == FALSE) { + /* */ + if(NPC_Util_isFaceToChara( talkerindex, meindex, 1) == FALSE) return; + } + + NPC_Charm_selectWindow( meindex, talkerindex, 0); +} + + +/* + * + */ +static void NPC_Charm_selectWindow( int meindex, int toindex, int num) +{ + + char token[1024]; + char escapedname[1024]; + int fd = getfdFromCharaIndex( toindex); + int buttontype = 0; + int windowtype = 0; + int windowno = 0; + int cost = 0; + int chartype; + + /*--̼⻥мƥƱɬ--*/ + windowtype = WINDOW_MESSAGETYPE_MESSAGE; + + switch( num) { + case 0: + /*-- --*/ + sprintf(token,"4\n ʦ " + "\n\n ӭ٣Ҫʲأ" + "\n " + "\n\n " + "\n\n ʲҲ " + ); + + buttontype = WINDOW_BUTTONTYPE_NONE; + windowtype = WINDOW_MESSAGETYPE_SELECT; + windowno = CHAR_WINDOWTYPE_CHARM_START; + break; + + case 1: + cost = NPC_CharmCost( meindex, toindex); + if(cost == -1){ + sprintf(token," ʦ " + "\n\n" + "\n\nԶࡡ" + ); + buttontype = WINDOW_BUTTONTYPE_OK; + }else{ + sprintf(token," ʦ " + "\n,ǧػݼʵʩ??" + "\n\n ҪĻ" + "\nҪ%6dstoneࡣ" + "\n\nʹҲ",cost + ); + buttontype = WINDOW_BUTTONTYPE_YESNO; + + } + windowtype = WINDOW_MESSAGETYPE_MESSAGE; + windowno = CHAR_WINDOWTYPE_CHARM_END; + + break; + + case 2: + cost = NPC_CharmCost( meindex, toindex); + chartype = CHAR_getInt( toindex, CHAR_IMAGETYPE); + + if(cost > CHAR_getInt( toindex, CHAR_GOLD)) { + sprintf(token," ʦ " + "\n\n ѽ!Ǯࡣ" + "\n ȥǮ´ɣ" + ); + + }else{ + NPC_CharmUp( meindex, toindex); + + /*--ƽҷ¼巽Ȼë --*/ + switch( chartype) { + case CHAR_IMAGETYPE_GIRL: + sprintf(token," ʦ " + "\n\n ,ޣ" + "\n\nɰأ" + ); + + break; + case CHAR_IMAGETYPE_BOY: + sprintf(token," ʦ " + "\n\n ,ޣ" + "\n\nDzDZȸղҪ˧أ" + ); + break; + + case CHAR_IMAGETYPE_CHILDBOY: + case CHAR_IMAGETYPE_CHILDGIRL: + sprintf(token," ʦ " + "\n\n ,ޣ" + "\n\n ıúÿɰࡣ" + ); + break; + + case CHAR_IMAGETYPE_MAN: + sprintf(token," ʦ " + "\n\n ,ޣ" + "\n\n øأ" + ); + break; + + case CHAR_IMAGETYPE_WOMAN: + sprintf(token," ʦ " + "\n\n ,ޣ" + "\n\n DZأ" + ); + break; + + } + } + + buttontype = WINDOW_BUTTONTYPE_OK; + windowtype = WINDOW_MESSAGETYPE_MESSAGE; + windowno = CHAR_WINDOWTYPE_CHARM_END; + break; + } + + makeEscapeString( token, escapedname, sizeof( escapedname)); + /*-ƥ˪--*/ + lssproto_WN_send( fd, windowtype, + buttontype, + windowno, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + escapedname); + +} + + +/*----------------------------------------- +ͷʧ߯Ȼݱ̫ľ£ +-------------------------------------------*/ +void NPC_CharmWindowTalked( int meindex, int talkerindex, + int seqno, int select, char *data) +{ + if( NPC_Util_CharDistance( talkerindex, meindex ) > 2) return; + + switch( seqno){ + case CHAR_WINDOWTYPE_CHARM_START: + if(atoi( data) == 2) { + NPC_Charm_selectWindow( meindex, talkerindex, 1 ); + } + break; + + case CHAR_WINDOWTYPE_CHARM_END: + if(select == WINDOW_BUTTONTYPE_YES) { + NPC_Charm_selectWindow( meindex, talkerindex, 2 ); + } + break; + } + +} + + + +/*-- --*/ +void NPC_CharmUp(int meindex,int talker) +{ + int cost; + int i; + int petindex; + char petsend[64]; + + /*--ëӼƽﵤ--*/ + cost = NPC_CharmCost( meindex, talker); + CHAR_setInt( talker, CHAR_GOLD, + CHAR_getInt( talker, CHAR_GOLD) - cost); + CHAR_send_P_StatusString( talker, CHAR_P_STRING_GOLD); + + /*-- ߨ߶ئ¦ߨ߱--*/ + if(CHAR_getInt( talker, CHAR_CHARM) + CHARMHEAL >= 100) { + CHAR_setInt( talker, CHAR_CHARM, 100); + }else{ + /*-- ë--*/ + CHAR_setInt(talker, CHAR_CHARM, + (CHAR_getInt( talker, CHAR_CHARM) + CHARMHEAL)); + } + + /*-- ޥ--*/ + CHAR_complianceParameter( talker ); + CHAR_send_P_StatusString( talker, CHAR_P_STRING_CHARM); + + + /*--ʸɷ¶ëޥ--*/ + for( i = 0 ; i < CHAR_MAXPETHAVE ; i++){ + petindex = CHAR_getCharPet( talker, i); + + if( petindex == -1 ) continue; + + /* ƽҷ¼ */ + if( !CHAR_CHECKINDEX( talker ) ) continue; + + /*--ɷ¶Ʃ--*/ + CHAR_complianceParameter( petindex ); + sprintf( petsend, "K%d", i ); + CHAR_sendStatusString( talker , petsend ); + } +} + + +/*--żң--*/ +int NPC_CharmCost(int meindex,int talker) +{ + int cost; + int level; + int charm; + int trans; + + level = CHAR_getInt( talker, CHAR_LV); + charm = CHAR_getInt( talker, CHAR_CHARM); + trans = CHAR_getInt( talker, CHAR_TRANSMIGRATION); + + if(charm >= 100) return -1; + + if(charm <= 1) charm = WARU; + + /*-- ңֿ --*/ + cost = level * RATE * (charm / WARU) * (trans+1); + + return cost; + +} diff --git a/npc/npc_checkman.c b/npc/npc_checkman.c new file mode 100644 index 0000000..1fe3864 --- /dev/null +++ b/npc/npc_checkman.c @@ -0,0 +1,472 @@ +#include "version.h" +#include +#include "char.h" +#include "object.h" +#include "char_base.h" +#include "npcutil.h" +#include "lssproto_serv.h" + + +//ػƥ°׷º뼰 +#define MAXEVENTFLG 96 + +/* + * ì׷ºë + * + */ + +static void NPC_CheckMan_selectWindow( int meindex, int toindex, int num); +int NPC_NowFlgCheck(int meindex,int talker,int now[MAXEVENTFLG]); +int NPC_EndFlgCheck(int meindex,int talker ,int nowflg[MAXEVENTFLG]); +BOOL NPC_FlgCheckMain( int meindex,int talker,int nowindex,int now[MAXEVENTFLG],char *work2); + +/********************************* +* +*********************************/ +BOOL NPC_CheckManInit( int meindex ) +{ + /*--ƽҷ¼ëɬ--*/ + CHAR_setInt( meindex , CHAR_WHICHTYPE , CHAR_TYPECHECKMAN); + + return TRUE; +} + + +/********************************* +* ƾľݼ +*********************************/ +void NPC_CheckManTalked( int meindex , int talkerindex , char *szMes ,int color ) +{ + + /* 帲ƻ ɱ */ + if( CHAR_getInt( talkerindex , CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER ) + { + return; + } + + /*-- ¾--*/ + if(NPC_Util_isFaceToFace( meindex ,talkerindex , 2) == FALSE) { + /* */ + if(NPC_Util_isFaceToChara( talkerindex, meindex, 1) == FALSE) return; + } + + // ټ̼ + NPC_CheckMan_selectWindow( meindex, talkerindex, 0); + +} + + +/* + * + */ +static void NPC_CheckMan_selectWindow( int meindex, int talker, int num) +{ + + char token[1024]; + char work[256]; + char work2[512]; + + char escapedname[1024]; + int fd = getfdFromCharaIndex( talker); + int buttontype = 0; + int windowtype = 0; + int windowno = 0; + int now[MAXEVENTFLG]; + int nowindex; + int i; + int page; + + work[0] = 0; + work2[0] = 0; + token[0] = 0; + + now[0] =0; + + /*--̼⻥мƥƱɬ--*/ + windowtype = WINDOW_MESSAGETYPE_MESSAGE; + + switch( num) { + + case 0: + CHAR_setWorkInt(talker,CHAR_WORKSHOPRELEVANT,0); + CHAR_setWorkInt(talker,CHAR_WORKSHOPRELEVANTSEC,0); + + /*-- --*/ + sprintf(token,"3\n Ѩ " + "\nػ׷ºë" + "\n" + "\n գNOW׷ºͣ " + "\n գEND׷ºͣ " + "\n\n գNOW׷º " + "\n գEND׷º " + ); + + buttontype = WINDOW_BUTTONTYPE_CANCEL; + windowtype = WINDOW_MESSAGETYPE_SELECT; + windowno = CHAR_WINDOWTYPE_CHECKMAN_START; + break; + + //NOW׷º뼰ǩ + case 1: + + //NOW׷º뼰 + nowindex = NPC_NowFlgCheck( meindex, talker, now); + + //ʸ + page = CHAR_getWorkInt(talker,CHAR_WORKSHOPRELEVANTSEC) ; + + if(page == 0 || page == 1){ + i = 0; + }else{ + i = 83; + } + + //ʸ + for(; i < nowindex ; i++) + { + sprintf(work,"%d,",now[ i]); + strcat(work2,work); + } + + sprintf(token,"Ѩ " + "\nػ Ȼ NOWì" + "\n%s" + ,work2); + + if(page != 2 && nowindex > 83) + { + //ƹ + CHAR_setWorkInt(talker,CHAR_WORKSHOPRELEVANT,1); + //ʸ + CHAR_setWorkInt(talker,CHAR_WORKSHOPRELEVANTSEC,2); + + buttontype = WINDOW_BUTTONTYPE_NEXT; + windowtype = WINDOW_MESSAGETYPE_MESSAGE; + windowno = CHAR_WINDOWTYPE_CHECKMAN_MAIN; + + }else{ + buttontype = WINDOW_BUTTONTYPE_OK; + windowtype = WINDOW_MESSAGETYPE_MESSAGE; + } + + break; + + + //END׷º뼰ǩ + case 2: + // ׷º뼰 + nowindex = NPC_EndFlgCheck( meindex, talker, now); + + //ʸ + page = CHAR_getWorkInt(talker,CHAR_WORKSHOPRELEVANTSEC) ; + + if(page == 0 || page == 1){ + i = 0; + }else{ + i = 83; + } + work2[0]=0; + + //ʸ + for(; i < nowindex ; i++) + { + sprintf(work,"%d,",now[ i]); + strcat(work2,work); + } + sprintf(token,"Ѩ " + "\nػ Ȼ ENDì" + "\n%s" + ,work2); + + if(page != 2 && nowindex > 83) + { + //ƹ + CHAR_setWorkInt(talker,CHAR_WORKSHOPRELEVANT,2); + //ʸ + CHAR_setWorkInt(talker,CHAR_WORKSHOPRELEVANTSEC,2); + + buttontype = WINDOW_BUTTONTYPE_NEXT; + windowtype = WINDOW_MESSAGETYPE_MESSAGE; + windowno = CHAR_WINDOWTYPE_CHECKMAN_MAIN; + + }else{ + buttontype = WINDOW_BUTTONTYPE_OK; + windowtype = WINDOW_MESSAGETYPE_MESSAGE; + } + + break; + + + // NOW׷º뼰 + case 4: + { + + //NOW׷º + nowindex = NPC_NowFlgCheck( meindex, talker, now); + + if(NPC_FlgCheckMain( meindex, talker, nowindex,now,work2) + == FALSE) + { + return; + } + + + sprintf(token,"Ѩ " + "\nػ Ȼ NOWì" + "\n%s" + ,work2); + + page = CHAR_getWorkInt(talker,CHAR_WORKSHOPRELEVANTSEC) ; + nowindex = (nowindex / ((6*page)+1)); + + if(page != 16 && nowindex != 0) + { + //ƹ + CHAR_setWorkInt(talker,CHAR_WORKSHOPRELEVANT,4); + //ʸ + page = CHAR_getWorkInt(talker,CHAR_WORKSHOPRELEVANTSEC); + page++; + CHAR_setWorkInt(talker,CHAR_WORKSHOPRELEVANTSEC,page); + + buttontype = WINDOW_BUTTONTYPE_NEXT; + windowtype = WINDOW_MESSAGETYPE_MESSAGE; + windowno = CHAR_WINDOWTYPE_CHECKMAN_MAIN; + }else{ + buttontype = WINDOW_BUTTONTYPE_OK; + windowtype = WINDOW_MESSAGETYPE_MESSAGE; + } + + } + break; + + // END׷º뼰 + case 5: + { + //END׷º뼰 + nowindex = NPC_EndFlgCheck( meindex, talker, now); + + + if(NPC_FlgCheckMain( meindex, talker, nowindex, now, work2) + == FALSE) + { + return; + } + + sprintf(token,"Ѩ " + "\nػ Ȼ ENDì" + "\n%s" + ,work2); + + page = CHAR_getWorkInt(talker,CHAR_WORKSHOPRELEVANTSEC) ; + + nowindex = (nowindex / ((6*page)+1)); + + if(page != 16 && nowindex != 0) + { + //ƹ + CHAR_setWorkInt(talker, CHAR_WORKSHOPRELEVANT, 5); + //ʸ + page = CHAR_getWorkInt( talker, CHAR_WORKSHOPRELEVANTSEC); + page++; + CHAR_setWorkInt( talker, CHAR_WORKSHOPRELEVANTSEC, page); + + buttontype = WINDOW_BUTTONTYPE_NEXT; + windowtype = WINDOW_MESSAGETYPE_MESSAGE; + windowno = CHAR_WINDOWTYPE_CHECKMAN_MAIN; + }else{ + buttontype = WINDOW_BUTTONTYPE_OK; + windowtype = WINDOW_MESSAGETYPE_MESSAGE; + } + + } + } + + makeEscapeString( token, escapedname, sizeof( escapedname)); + /*-ƥ˪--*/ + lssproto_WN_send( fd, windowtype, + buttontype, + windowno, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + escapedname); + +} + + +/*----------------------------------------- +ͷʧ߯Ȼݱ̫ľ£ +-------------------------------------------*/ +void NPC_CheckManWindowTalked( int meindex, int talkerindex, + int seqno, int select, char *data) +{ + int datano; + + if( NPC_Util_CharDistance( talkerindex, meindex ) > 2) return; + + datano = atoi(data); + + if(select == WINDOW_BUTTONTYPE_OK) + { + NPC_CheckMan_selectWindow( meindex, talkerindex, 0 ); + }else if(select == WINDOW_BUTTONTYPE_CANCEL) { + return; + } + + + + + switch(CHAR_getWorkInt(talkerindex,CHAR_WORKSHOPRELEVANT)){ + case 1: + if(CHAR_getWorkInt(talkerindex,CHAR_WORKSHOPRELEVANTSEC) == 2){ + NPC_CheckMan_selectWindow( meindex, talkerindex, 1 ); + } + break; + + case 2: + if(CHAR_getWorkInt(talkerindex,CHAR_WORKSHOPRELEVANTSEC) == 2){ + NPC_CheckMan_selectWindow( meindex, talkerindex, 2 ); + } + break; + + case 4: + if(CHAR_getWorkInt(talkerindex,CHAR_WORKSHOPRELEVANTSEC) >= 2){ + NPC_CheckMan_selectWindow( meindex, talkerindex, 4 ); + } + + case 5: + if(CHAR_getWorkInt(talkerindex,CHAR_WORKSHOPRELEVANTSEC) >= 2){ + NPC_CheckMan_selectWindow( meindex, talkerindex, 5 ); + } + + break; + } + + switch( datano ){ + case 1: + NPC_CheckMan_selectWindow( meindex, talkerindex, 1 ); + break; + + case 2: + NPC_CheckMan_selectWindow( meindex, talkerindex, 2 ); + break; + + case 4: + NPC_CheckMan_selectWindow( meindex, talkerindex, 4 ); + break; + + case 5: + NPC_CheckMan_selectWindow( meindex, talkerindex, 5 ); + break; + } + +} + +/* + *ì ׷ºë + */ +int NPC_NowFlgCheck(int meindex,int talker ,int nowflg[MAXEVENTFLG]) +{ + int i = 0; + int j = 0; + + for(i= 0; i < MAXEVENTFLG ; i++){ + if(NPC_NowEventCheckFlg( talker, i) == TRUE) + { + nowflg[j] = i; + j++; + } + } + + return j; +} + +/* + *ì ׷ºë + */ +int NPC_EndFlgCheck(int meindex,int talker ,int nowflg[MAXEVENTFLG]) +{ + int i = 0; + int j = 0; + + for(i= 0; i < MAXEVENTFLG ; i++){ + + if(NPC_EventCheckFlg( talker, i) == TRUE) + { + nowflg[j] = i; + j++; + } + } + + return j; +} + +/* + * + * + */ +BOOL NPC_FlgCheckMain( int meindex,int talker,int nowindex,int now[MAXEVENTFLG],char *work2) +{ + int page; + int max; + int i; + int shou; + int j=1; + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + char work[512]; + char buf[40]; + char buf2[42]; + + //ʸ + page = CHAR_getWorkInt(talker,CHAR_WORKSHOPRELEVANTSEC) ; + + if(page == 0) { + page =1; + CHAR_setWorkInt(talker,CHAR_WORKSHOPRELEVANTSEC,1) ; + } + + if(page == 1){ + i = 0; + if( nowindex >6 ){ + max =7; + }else{ + max =nowindex; + } + }else{ + max = (page * 6) +1; + i = max - 7; + shou = nowindex / max; + + if(shou == 0){ + max = nowindex; + }else{ + i = max - 7; + } + } + + //ìƻ̤ľ°̻ë ij + if(NPC_Util_GetArgStr( meindex, argstr, sizeof(argstr)) == NULL) { + print("NPC_CheckMan:GetArgStrErr"); + return FALSE; + } + + work[0] = 0; + work2[0] = 0; + + //ʸ + for(; i < max ; i++) + { + sprintf(work,"#%d:",now[ i]); + j = 1; + while( getStringFromIndexWithDelim(argstr, "|", j, buf,sizeof( buf)) + !=FALSE ) + { + j++; + if(strstr(buf,work) != NULL){ + sprintf(buf2,"%s\n",buf); + strcat(work2,buf2); + break; + } + } + } + + return TRUE; +} diff --git a/npc/npc_dengon.c b/npc/npc_dengon.c new file mode 100644 index 0000000..82d083f --- /dev/null +++ b/npc/npc_dengon.c @@ -0,0 +1,248 @@ +#include "version.h" +#include +#include "char.h" +#include "object.h" +#include "lssproto_serv.h" +#include "npcutil.h" +#include "handletime.h" + +static BOOL NPC_DengonReadString( int meindex, int id, char *str ); +static void NPC_DengonWriteString( int meindex, int talkerindex, int id, char *str ); + +#define DENGONFILEDIR "./Dengon/" +#define DENGONFILELINENUM 1000 +#define DENGONFILESTRINGSIZE 256 +#define DENGONFILECOUNTERSIZE 11 +#define DENGONFILEENTRYSIZE (DENGONFILECOUNTERSIZE+DENGONFILESTRINGSIZE+1) +#define MESSAGEINONEWINDOW 7 + +char NPC_sendbuf[DENGONFILEENTRYSIZE*MESSAGEINONEWINDOW]; + +BOOL NPC_DengonInit( int meindex ) +{ + char filename[256], tmp[256]; + FILE *f; + int i,j; + int id, maxid; + + CHAR_setInt( meindex, CHAR_WHICHTYPE, CHAR_TYPEDENGON ); + + snprintf( filename,sizeof(filename), "%s%d_%d_%d", + DENGONFILEDIR, CHAR_getInt( meindex, CHAR_FLOOR ), + CHAR_getInt( meindex, CHAR_X ), + CHAR_getInt( meindex, CHAR_Y ) ); + + if( ! (f=fopen( filename, "r" )) ){ + f = fopen( filename, "w" ); + if( f ){ + }else{ + print( "ERROR:Can't create Dengonfile %s!\n",filename ); + return FALSE; + } + for( j = 0; j < DENGONFILELINENUM; j++ ){ + fwrite( "0000000000:", sizeof(char), + DENGONFILECOUNTERSIZE, f); + for( i=0;i maxid ) { + maxid = id; + } + } + + CHAR_setWorkInt( meindex, CHAR_WORKDENGONMAXID, maxid ); + + fclose(f); + return TRUE; +} + + +void NPC_DengonWindowTalked( int index, int talker, + int seqno, int select, char *data) +{ + char buf[DENGONFILEENTRYSIZE*MESSAGEINONEWINDOW*2]; + + int id; + +#define DENGONDISTANCE 3 + + if(NPC_Util_CharDistance(index,talker) > DENGONDISTANCE ) return; + if( seqno == CHAR_WINDOWTYPE_DENGON) { + int buttontype = 0; + int maxid; + switch( select ){ + case WINDOW_BUTTONTYPE_NEXT: + case WINDOW_BUTTONTYPE_PREV: + id = CHAR_getWorkInt( talker, CHAR_WORKSHOPRELEVANT) + + MESSAGEINONEWINDOW + * (( select == WINDOW_BUTTONTYPE_NEXT) ? 1 : -1); + + maxid = CHAR_getWorkInt( index, CHAR_WORKDENGONMAXID ); + + if( id > maxid) id = maxid; + else if( id < 2 ) id = 1; + + buttontype = WINDOW_BUTTONTYPE_OKCANCEL; + if( id == maxid ) buttontype |= WINDOW_BUTTONTYPE_PREV; + else if( id == 1 ) buttontype |= WINDOW_BUTTONTYPE_NEXT; + else { + buttontype |= WINDOW_BUTTONTYPE_PREV; + buttontype |= WINDOW_BUTTONTYPE_NEXT; + } + CHAR_setWorkInt( talker, CHAR_WORKSHOPRELEVANT, id); + if( NPC_DengonReadString( index, id, NPC_sendbuf ) ){ + int fd; + fd = getfdFromCharaIndex( talker ); + if( fd == -1 )return; + lssproto_WN_send(fd, WINDOW_MESSAGETYPE_WIDEMESSAGEANDLINEINPUT, + buttontype, + CHAR_WINDOWTYPE_DENGON, + CHAR_getWorkInt( index, CHAR_WORKOBJINDEX), + makeEscapeString( NPC_sendbuf, buf, sizeof(buf))); + } + break; + case WINDOW_BUTTONTYPE_OK: + if( strlen( data) == 0 ) break; + id = CHAR_getWorkInt(index, CHAR_WORKDENGONMAXID ); + id++; + NPC_DengonWriteString( index, talker, id, data ); + CHAR_setWorkInt(index, CHAR_WORKDENGONMAXID, id ); + CHAR_setWorkInt( talker, CHAR_WORKSHOPRELEVANT, id); + if( NPC_DengonReadString( index, id, NPC_sendbuf ) ){ + int fd; + fd = getfdFromCharaIndex( talker ); + if( fd == -1 )return; + lssproto_WN_send(fd, WINDOW_MESSAGETYPE_WIDEMESSAGEANDLINEINPUT, + WINDOW_BUTTONTYPE_OKCANCEL| + WINDOW_BUTTONTYPE_PREV, + CHAR_WINDOWTYPE_DENGON, + CHAR_getWorkInt( index, CHAR_WORKOBJINDEX), + makeEscapeString( NPC_sendbuf, buf, sizeof(buf))); + } + break; + default: + break; + } + } +} + + + + +void NPC_DengonLooked( int meindex, int lookedindex ) +{ + int maxid; + char buf[DENGONFILEENTRYSIZE*MESSAGEINONEWINDOW*2]; + if( NPC_Util_CharDistance( lookedindex, meindex ) > 1) return; + maxid = CHAR_getWorkInt( meindex, CHAR_WORKDENGONMAXID ); + if( NPC_DengonReadString( meindex, maxid, NPC_sendbuf ) ){ + int fd; + fd = getfdFromCharaIndex( lookedindex ); + if( fd == -1 )return; + lssproto_WN_send(fd, WINDOW_MESSAGETYPE_WIDEMESSAGEANDLINEINPUT, + WINDOW_BUTTONTYPE_OKCANCEL| + WINDOW_BUTTONTYPE_PREV, + CHAR_WINDOWTYPE_DENGON, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + makeEscapeString( NPC_sendbuf, buf, sizeof(buf))); + + CHAR_setWorkInt( lookedindex, CHAR_WORKSHOPRELEVANT, maxid); + + } + +} + +static BOOL NPC_DengonReadString( int meindex, int id, char *str ) +{ + char filename[256]; + char readbuf[DENGONFILEENTRYSIZE*MESSAGEINONEWINDOW]; + + FILE *f; + int maxid, i, sendid, len; + char *writeptr, *readptr; + + + maxid = CHAR_getWorkInt( meindex, CHAR_WORKDENGONMAXID ); + if( id > maxid ) id = maxid; + sendid = id - MESSAGEINONEWINDOW + 1; + + if( sendid < maxid - DENGONFILELINENUM + 1 ){ + sendid = maxid - DENGONFILELINENUM + 1; + } + + if( sendid < 1 ) sendid = 1; + + snprintf( filename,sizeof(filename), "%s%d_%d_%d", + DENGONFILEDIR, CHAR_getInt( meindex, CHAR_FLOOR ), + CHAR_getInt( meindex, CHAR_X ), + CHAR_getInt( meindex, CHAR_Y ) ); + + writeptr = str; + strcpy( writeptr, " ԰\n"); + len = strlen(writeptr); + writeptr += len; + + f = fopen( filename, "r" ); + if( !f ) return FALSE; +{ + char buf[DENGONFILEENTRYSIZE]; + int wptr = 0; + readbuf[0] = '\0'; + for( i = 0; i < MESSAGEINONEWINDOW; i ++ ) { + fseek( f, ((sendid+i)%DENGONFILELINENUM)*DENGONFILEENTRYSIZE, SEEK_SET ); + fread( buf, sizeof(char), + DENGONFILEENTRYSIZE , f ); + memcpy( &readbuf[wptr], buf,sizeof( buf)); + wptr += DENGONFILEENTRYSIZE; + } +} + fclose(f); + readptr = readbuf + DENGONFILECOUNTERSIZE; + for( i=0;i +#include + + +static int NPC_Door_isOpen( int meindex ); + +/* + * ʧë ׻NPC ۢئѼ + * Door + * + * NPCARGUMENT + * + * og|cg|idname|swcount|closetime_sec|soonflg0/1|passflg0/1/2 + * + * passflg 1ʴƥؤ ئ£2 + * 姸վئУ 0ɵƥئУ + * + * ë϶£ ƥ޷ɻƥ1ޣ + * ɬë̤巴 įۢئëֹ ۢƥؤ£ + * + * мԻCë˪ѻؤ¾գ1info, į + * ë ƻչëͷʧ ľ + * ػ ޥئ£ + */ + +#define NPC_DOOR_OPENMSG "ʧ!" +#define NPC_DOOR_CLOSEMSG "ʧëƻ!" +#define NPC_DOOR_CANTOPENMSG "ؤئмƥʧëʳ绥\ +ƥئ!" + +#define ROPEGRAPHIC 9259 /* Ǿ ؤɧľئз */ + +enum{ + NPC_DOOR_FLG_SOONCLOSE = 1, + NPC_DOOR_FLG_WATCHCLOSE = 2 +}; + + +/* + * ʧɬë±巴ƥ + * maxhp , maxmp , level , str , tough ë0緽У + * + */ +BOOL NPC_DoorInit( int meindex ) +{ + char arg[NPC_UTIL_GETARGSTR_BUFSIZE]; + char settingdir[1024]; + char buf[256]; + + NPC_Util_GetArgStr( meindex, arg, sizeof( arg)); + CHAR_setWorkInt( meindex, CHAR_WORKEVENTTYPE,CHAR_EVENT_NPC); + + getStringFromIndexWithDelim(arg, "|" , 1 , buf,sizeof(buf) ); + CHAR_setWorkInt( meindex , CHAR_WORKDOOROPENG , atoi( buf )); + getStringFromIndexWithDelim(arg, "|" , 2 , buf,sizeof(buf) ); + CHAR_setWorkInt( meindex , CHAR_WORKDOORCLOSEG , atoi( buf )); + getStringFromIndexWithDelim(arg, "|" , 3 , buf,sizeof(buf) ); + CHAR_setWorkChar( meindex , CHAR_WORKDOORNAME , buf ); + strcpysafe( settingdir,sizeof( settingdir) , buf ); + getStringFromIndexWithDelim(arg, "|" , 4 , buf,sizeof(buf) ); + CHAR_setWorkInt( meindex , CHAR_WORKDOORSWITCHCOUNT , atoi( buf )); + getStringFromIndexWithDelim(arg, "|" , 5 , buf,sizeof(buf) ); + CHAR_setWorkInt( meindex , CHAR_WORKDOORCLOSETIME , atoi( buf )); + + CHAR_setInt( meindex , CHAR_MERCHANTLEVEL , atoi( buf )); + getStringFromIndexWithDelim(arg, "|" , 6 , buf,sizeof(buf) ); + CHAR_setWorkInt( meindex , CHAR_WORKDOORSOONFLG , atoi( buf )); + + getStringFromIndexWithDelim(arg, "|" , 7 , buf,sizeof(buf) ); + CHAR_setWorkInt( meindex , CHAR_WORKDOORPASSFLG , atoi( buf )); + CHAR_setWorkInt( meindex , CHAR_WORKDOORORIGINALGRAPHIC, + CHAR_getInt( meindex,CHAR_BASEIMAGENUMBER )); + CHAR_setInt( meindex, CHAR_LV, 0 ); + if( getStringFromIndexWithDelim( arg , "|" , 8 , buf ,sizeof( buf ))){ + if( strncmp( buf , "title" ,5 ) == 0 ){ + print( "This is a title door:'%s'\n" , buf ); + CHAR_setWorkInt( meindex , CHAR_WORKDOORPASSFLG ,0 ); + CHAR_setWorkChar( meindex , CHAR_WORKDOORTITLE , buf ); + CHAR_setInt( meindex, CHAR_LV, 1 ); + } else if( isdigit( buf[0] )){ + if( getStringFromIndexWithDelim(arg, "|" , 8 , buf,sizeof(buf) )) + CHAR_setWorkChar( meindex, CHAR_WORKDOORGOLDLIMIT, buf); + if( getStringFromIndexWithDelim(arg, "|" , 10 , buf,sizeof(buf) )) + CHAR_setWorkChar( meindex, CHAR_WORKDOORWEEK, buf); + if( getStringFromIndexWithDelim(arg, "|" , 11 , buf,sizeof(buf) )) + CHAR_setWorkChar( meindex, CHAR_WORKDOORHOUR, buf); + if( getStringFromIndexWithDelim(arg, "|" , 12 , buf,sizeof(buf) )) + CHAR_setWorkChar( meindex, CHAR_WORKDOORMINUTE, buf); + } + } + + CHAR_setInt( meindex , CHAR_HP , 0 ); + CHAR_setInt( meindex , CHAR_MP , 0 ); + CHAR_setInt( meindex , CHAR_MAXMP , 0 ); + CHAR_setInt( meindex , CHAR_STR , 0 ); + CHAR_setInt( meindex , CHAR_TOUGH, 0 ); + { + int g = CHAR_getWorkInt( meindex , CHAR_WORKDOOROPENG ); + if( g >= 11900 && g <= 11915 ){ + CHAR_setWorkInt( meindex , CHAR_WORKDOORKEYITEMID , 15 ); + } else if( g >= 11916 && g <= 11931 ){ + + CHAR_setWorkInt( meindex , CHAR_WORKDOORKEYITEMID , 16 ); + } else { + CHAR_setWorkInt( meindex , CHAR_WORKDOORKEYITEMID , -1 ); + } + if(CHAR_getWorkInt( meindex , CHAR_WORKDOORPASSFLG )==2){ + CHAR_setWorkInt( meindex , CHAR_WORKDOORKEYITEMID , -2 ); + } + if( CHAR_getInt( meindex , CHAR_BASEIMAGENUMBER ) == + ROPEGRAPHIC ){ + CHAR_setWorkInt( meindex , CHAR_WORKDOORKEYITEMID,-2 ); + } + } + + { + int closeg = CHAR_getWorkInt( meindex , CHAR_WORKDOORCLOSEG ); + int dir = -1; + switch( closeg ){ + case 11900: dir = 6; break; /* ʧ Ի */ + case 11902: dir = 0; break; /* Ի */ + case 11904: dir = 2; break; /* Ŀ */ + case 11906: dir = 4; break; /* Ŀ */ + + case 11908: dir = 6; break; /* Ӯʧ Ի */ + case 11910: dir = 0; break; /* Ի */ + case 11912: dir = 2; break; /* Ŀ */ + case 11914: dir = 4; break; /* Ŀ */ + + case 11916: dir = 6; break; /* ˼ʧ Ի */ + case 11918: dir = 0; break; /* Ի */ + case 11920: dir = 2; break; /* Ŀ */ + case 11922: dir = 4; break; /* Ŀ */ + + case 11924: dir = 6; break; /* Ӯ˼ʧ Ի */ + case 11926: dir = 0; break; /* Ի */ + case 11928: dir = 2; break; /* Ŀ */ + case 11930: dir = 4; break; /* Ŀ */ + + case 11958: dir = 2; break; /* Ӯ ʧ Ŀ */ + case 11960: dir = 4; break; /* Ŀ */ + case 11962: dir = 6; break; /* Ի */ + case 11964: dir = 0; break; /* Ի */ + + case 11966: dir = 2; break; /* ʧ Ŀ */ + case 11968: dir = 4; break; /* Ŀ */ + case 11970: dir = 6; break; /* Ի */ + case 11972: dir = 0; break; /* Ի */ + + case 11978: dir = 2; break; /* Ӯżʧ Ŀ */ + case 11980: dir = 4; break; /* Ŀ */ + case 11982: dir = 6; break; /* Ի */ + case 11984: dir = 0; break; /* Ի */ + + case 11986: dir = 2; break; /* żʧ Ŀ */ + case 11988: dir = 4; break; /* Ŀ */ + case 11990: dir = 6; break; /* Ի */ + case 11992: dir = 0; break; /* Ի */ + + default: break; + } + if( dir >= 0 )CHAR_setInt(meindex,CHAR_DIR,dir); + } + + CHAR_setInt( meindex , CHAR_WHICHTYPE , CHAR_TYPEDOOR ); + CHAR_setFlg( meindex , CHAR_ISATTACKED , 0 ); + CHAR_setInt( meindex , CHAR_WORKDOORSWITCHCURRENT , 0 ); + CHAR_setWorkInt( meindex, CHAR_WORKDOOREXPIRETIME, 0xffffffff); + if( CHAR_getWorkInt( meindex , CHAR_WORKDOORPASSFLG ) == 1){ + NPC_ROOMINFO roominfo; + if( NPC_RoomAdminNew_ReadFile( CHAR_getWorkChar( meindex, CHAR_WORKDOORNAME), &roominfo) == TRUE ){ + NPC_DoorSetPasswd( meindex, roominfo.passwd); + CHAR_setWorkInt( meindex, CHAR_WORKDOOREXPIRETIME, roominfo.expire); + }else { + NPC_DoorSetPasswd( meindex, "8hda8iauia90494jasd9asodfasdf89" ); + if( getStringFromIndexWithDelim(arg, "|" , 13 , buf,sizeof(buf) )) + if( strlen( buf) != 0 ) + NPC_DoorSetPasswd( meindex, buf ); + } + } + + CHAR_setInt( meindex, CHAR_BASEIMAGENUMBER , CHAR_getWorkInt(meindex, CHAR_WORKDOORCLOSEG)); + NPC_DoorRefreshOverFlg( meindex ); + CHAR_setWorkInt( meindex, CHAR_WORKEVENTTYPE, CHAR_EVENT_NPC); + return TRUE; +} +void NPC_DoorAddSwitchCounter( int meindex , int i , int doindex ) +{ + if( i != 0 && CHAR_getWorkInt( meindex, CHAR_WORKDOORSWITCHCOUNT) + != 0 ){ + CHAR_setWorkInt( meindex, CHAR_WORKDOORSWITCHCURRENT , + CHAR_getWorkInt(meindex, + CHAR_WORKDOORSWITCHCURRENT) + + i ); + if( CHAR_getWorkInt( meindex, CHAR_WORKDOORSWITCHCURRENT ) == + CHAR_getWorkInt( meindex, CHAR_WORKDOORSWITCHCOUNT) ){ + NPC_DoorOpen( meindex , doindex ); + } else { + NPC_DoorClose( meindex , doindex ); + } + } +} + +void NPC_DoorSetSwitchCounter( int meindex, int i , int doindex ) +{ + if( !CHAR_CHECKINDEX(meindex))return; + CHAR_setWorkInt( meindex , CHAR_WORKDOORSWITCHCURRENT , i ); + NPC_DoorAddSwitchCounter( meindex, 0 , doindex ); +} + +static int NPC_DoorSamePos( int meindex ){ + int iWork; + OBJECT object; + int floor = CHAR_getInt( meindex, CHAR_FLOOR ); + int x = CHAR_getInt( meindex, CHAR_X ); + int y = CHAR_getInt( meindex, CHAR_Y ); + + for( object=MAP_getTopObj( floor, x,y ); object ; object = NEXT_OBJECT(object) ){ + int objindex = GET_OBJINDEX(object); + if( OBJECT_getType(objindex) != OBJTYPE_CHARA )continue; + iWork = OBJECT_getIndex(objindex); + if( CHAR_getInt(iWork,CHAR_HP) < 0 )continue; + if( CHAR_getInt( iWork,CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER ){ + return iWork; + } + } + return -1; +} + +void NPC_DoorWatch( int myobjindex, int moveobjindex, CHAR_ACTION act, + int x, int y, int dir, int* opt, int optlen ) +{ + unsigned long closetime; + int meindex, moveindex; + + if( OBJECT_getType( moveobjindex) != OBJTYPE_CHARA ) { + return; + } + meindex = OBJECT_getIndex(myobjindex); + moveindex = OBJECT_getIndex(moveobjindex); + if( NPC_Door_isOpen( meindex ) == 0 )return; + if( CHAR_getInt( moveindex , CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER ){ + return; + } + if( CHAR_getWorkInt( meindex , CHAR_WORKDOORSOONFLG )){ + if( CHAR_getInt( meindex , CHAR_TALKCOUNT ) > 0 ){ + if( NPC_DoorSamePos( meindex ) == -1 ){ + NPC_DoorClose(meindex , -1 ); + CHAR_setInt( meindex , CHAR_TALKCOUNT, 0 ); + } + } + }else + if( CHAR_getInt( meindex, CHAR_MERCHANTLEVEL ) >= 0 ){ + closetime = (unsigned long )CHAR_getWorkInt( meindex , CHAR_WORKDOORCLOSETIME ); + if( (unsigned long) NowTime.tv_sec > (unsigned long) closetime ){ + NPC_DoorClose(meindex , -1 ); + } + } +} + + +#if 1 +void NPC_DoorOff( int meindex , int movedindex ) +{ + if( CHAR_getWorkInt( meindex , CHAR_WORKDOORSOONFLG )){ + NPC_DoorClose(meindex , -1 ); + } else { + } +} +#endif + +void NPC_DoorPostOver( int meindex , int movedindex ) +{ + if( CHAR_getWorkInt( meindex , CHAR_WORKDOORSOONFLG )){ + CHAR_setInt( meindex , CHAR_TALKCOUNT, 1 ); + CHAR_setFlg( meindex , CHAR_ISOVERED , 0 ); /* ɧľئ */ + } +} + +void NPC_DoorLooked( int meindex , int lookedindex ) +{ + int needkey; + + if( CHAR_getInt( meindex , CHAR_LV )){ + char token[32]; + char *p = CHAR_getWorkChar( meindex , CHAR_WORKDOORTITLE ); + int i,j,ok=FALSE; + for(i = 0 ; ; i++ ){ + int r; + r = getStringFromIndexWithDelim( p,":",2+i,token ,sizeof(token)); + if(r){ + int titleind = atoi( token ); + for(j=0;j=1 ){ + if( NPC_Door_isOpen( meindex ) ){ + NPC_DoorFlip( meindex , lookedindex ); + return; + } +#define NPC_DOOR_EXPIRE_MSG "%s ķЧ %d/%d %d:%d" + else { + if( CHAR_getWorkInt( meindex, CHAR_WORKDOOREXPIRETIME) + != 0xffffffff ){ + struct tm tmwk; + time_t expire = CHAR_getWorkInt( meindex, CHAR_WORKDOOREXPIRETIME); + char msgbuf[128]; + + NPC_ROOMINFO roominfo; + /* ɵ ë */ + NPC_RoomAdminNew_ReadFile( + CHAR_getWorkChar( meindex, CHAR_WORKDOORNAME), + &roominfo); + memcpy( &tmwk, localtime( &expire), sizeof( tmwk)); + snprintf( msgbuf, sizeof( msgbuf), NPC_DOOR_EXPIRE_MSG, + roominfo.charaname, + tmwk.tm_mon+1, tmwk.tm_mday, + tmwk.tm_hour, tmwk.tm_min); + CHAR_talkToCli( lookedindex, meindex, msgbuf, CHAR_COLORWHITE); + } + } + #undef NPC_DOOR_EXPIRE_MSG + return; + } + needkey = CHAR_getWorkInt( meindex , CHAR_WORKDOORKEYITEMID ); + if( needkey >= 0 ){ + if( NPC_Util_countHaveItem( lookedindex , needkey ) > 0 ){ + NPC_DoorFlip( meindex , lookedindex); + } else { + CHAR_talkToCli( lookedindex , -1 , NPC_DOOR_CANTOPENMSG , CHAR_COLORWHITE ); + } + } else if( needkey == -1 ){ + NPC_DoorFlip(meindex , lookedindex ); + } else { + CHAR_talkToCli( lookedindex , -1 , "ƺҲ򲻿" , CHAR_COLORWHITE); + } +} +void NPC_DoorTalked( int meindex , int talkerindex , char *msg , int color ) +{ + char *m = CHAR_getWorkChar( meindex , CHAR_WORKDOORPASSWD ); + if(NPC_Util_CharDistance( talkerindex, meindex ) > 1)return; + if( CHAR_getWorkInt( meindex , CHAR_WORKDOORPASSFLG ) != 1 ){ + return; + } + if( CHAR_getWorkInt( meindex , CHAR_WORKDOORPASSFLG ) >= 1 && + ((unsigned long)NowTime.tv_sec) > (unsigned long) + CHAR_getWorkInt( meindex , CHAR_WORKDOOREXPIRETIME )){ + print( "RINGO: passdoor expired ( talked )\n" ); + return; + } + if( m[0] == '\0' )return; + cutDotsTail( msg ); + if( strcmp( m , msg ) == 0 ){ + NPC_DoorFlip( meindex , talkerindex ); + }else { + CHAR_talkToCli( talkerindex , -1 , "벻ȷ", CHAR_COLORWHITE ); + } +} + +int NPC_DoorSearchByName( char *name ) +{ + int i; + int charnum = CHAR_getCharNum(); + + for(i= CHAR_getPlayerMaxNum() + CHAR_getPetMaxNum(); + i= 0 ) CHAR_talkToCli( doindex , -1 , NPC_DOOR_CLOSEMSG, CHAR_COLORWHITE ); + CHAR_setInt( meindex , CHAR_TALKCOUNT, 0 ); +} +void NPC_DoorOpen(int meindex , int doindex ) +{ + CHAR_setWorkInt( meindex , CHAR_WORKDOORCLOSETIME, + NowTime.tv_sec + + CHAR_getInt( meindex , CHAR_MERCHANTLEVEL)); + CHAR_setInt( meindex , CHAR_BASEIMAGENUMBER , + CHAR_getWorkInt( meindex,CHAR_WORKDOOROPENG )); + NPC_DoorRefreshOverFlg( meindex ); + CHAR_sendCToArroundCharacter( CHAR_getWorkInt( meindex, + CHAR_WORKOBJINDEX )); + if( doindex >= 0 ) + CHAR_talkToCli( doindex , -1, NPC_DOOR_OPENMSG ,CHAR_COLORWHITE); +} + +static int NPC_Door_isOpen( int meindex ) +{ + int now_g = CHAR_getInt( meindex , CHAR_BASEIMAGENUMBER ); + int open_g = CHAR_getWorkInt( meindex ,CHAR_WORKDOOROPENG ); + if( now_g == open_g ) return 1; else return 0; +} + +BOOL NPC_DoorRefreshOverFlg( int meind ) +{ + if( !CHAR_CHECKINDEX(meind))return FALSE; + if( NPC_Door_isOpen( meind ) ==1 ){ + CHAR_setFlg( meind , CHAR_ISOVERED , 1 ); + } else { + CHAR_setFlg( meind , CHAR_ISOVERED , 0 ); + } + return TRUE; +} + +BOOL NPC_DoorSetRopeFlag(int fl,int x,int y, int flag ) +{ + int ind = NPC_DoorSearchByPosition( fl,x,y ); + if( ind < 0 ) return FALSE; + if( flag ){ + CHAR_setInt( ind , CHAR_BASEIMAGENUMBER , ROPEGRAPHIC ); + } else { + CHAR_setInt(ind , CHAR_BASEIMAGENUMBER , 0 ); + } + NPC_DoorRefreshOverFlg( ind ); + CHAR_sendCToArroundCharacter( + CHAR_getWorkInt( ind , CHAR_WORKOBJINDEX )); + + return TRUE; +} + diff --git a/npc/npc_doorman.c b/npc/npc_doorman.c new file mode 100644 index 0000000..06ec825 --- /dev/null +++ b/npc/npc_doorman.c @@ -0,0 +1,215 @@ +#include "version.h" +#include +#include "object.h" +#include "char_base.h" +#include "char.h" +#include "item.h" +#include "util.h" +#include "handletime.h" +#include "npc_doorman.h" +#include "npc_door.h" +#include "npcutil.h" +#include "configfile.h" +/* + * + * Իʧؤ幫ʧëվ巽ȻNPC. + * ʧئԻcreate·ƥʧë۽³绥ƥ£ + * ئƾľƽҷëƻԻ8Ѩʧ + * ͻ帲ƻ£ۿ׹ʧ ݱ巰ʳئ£ + * + * ̵̼Talkƥ + * + * ʧë׻ + * + * 1 ë£۰ƥշ gold|100 + * 2 ʧ ةë1۰ ۰ƥշ item|45 + * 3 ʧ ةë Ȼ¾Ʃ£ Ȼշʣitemhave|44 + * 4 ʧ ةë ȻئоƩ£ Ȼئշʣ + * itemnothave|333 + * 5 įëȻ¾Ʃ£ Ȼշʣ titlehave|string + * 6 įëȻئоƩ£ Ȼئշʣ + * titlenothave|string + * + * ئߤ 緰ʣż + *100׷ʻƥʾƥУе100 + * ľ£ئԻУȻľ£ƥ100 + * ׷ףۣɴľ£ + * + * ʧ ة谼ϡë׷ʻƥʾʣ + * 36Ͼئƾ껯ǷȻշʣ + * + * + * + * ܷ + * + *1 ʧë絤 + *2 NPCëʧئԻ ʣ¦ë gold|100 + *3 NPC帲ƻ100ȻƥУɵ + *4 ʧлŻӼ + * + */ + +static void NPC_DoormanOpenDoor( char *nm ); + +BOOL NPC_DoormanInit( int meindex ) +{ + char arg[NPC_UTIL_GETARGSTR_BUFSIZE]; + char dname[1024]; + + /* ìɬ */ + CHAR_setWorkInt( meindex, CHAR_WORKEVENTTYPE,CHAR_EVENT_NPC); + + CHAR_setInt( meindex , CHAR_HP , 0 ); + CHAR_setInt( meindex , CHAR_MP , 0 ); + CHAR_setInt( meindex , CHAR_MAXMP , 0 ); + CHAR_setInt( meindex , CHAR_STR , 0 ); + CHAR_setInt( meindex , CHAR_TOUGH, 0 ); + CHAR_setInt( meindex , CHAR_LV , 0 ); + + CHAR_setInt( meindex , CHAR_WHICHTYPE , CHAR_TYPETOWNPEOPLE ); + CHAR_setFlg( meindex , CHAR_ISOVERED , 0 ); + CHAR_setFlg( meindex , CHAR_ISATTACKED , 0 ); /* ľئз */ + + NPC_Util_GetArgStr( meindex, arg, sizeof( arg)); + + if(!getStringFromIndexWithDelim( arg, "|", 3, dname, sizeof(dname ))){ + print("RINGO: 趨ʱҪŵࡣ:%s:\n", + arg ); + return FALSE; + } + print( "RINGO: Doorman create: arg: %s dname: %s\n",arg,dname); + CHAR_setWorkChar( meindex , CHAR_WORKDOORMANDOORNAME , dname ); + + return TRUE; +} + +void NPC_DoormanTalked( int meindex , int talkerindex , char *msg , + int color ) +{ + char mode[128]; + char opt[256]; + char arg[NPC_UTIL_GETARGSTR_BUFSIZE]; + + /* ʧѨ1 ئշϼ */ + if(NPC_Util_CharDistance( talkerindex, meindex ) > 1)return; + + NPC_Util_GetArgStr( meindex, arg, sizeof( arg)); + + if( !getStringFromIndexWithDelim( arg, "|", 1, mode, sizeof( mode ))) + return; + + if( !getStringFromIndexWithDelim( arg, "|", 2, opt, sizeof( opt ) )) + return; + + if( strcmp( mode , "gold" ) == 0 ){ + int g = atoi( opt ); + int yn = NPC_Util_YN( msg ); + /*char *nm = CHAR_getChar( meindex , CHAR_NAME );*/ + char msg[256]; + + if( g > 0 && yn < 0 ){ + snprintf( msg ,sizeof( msg ) , + "Ҫ%dĽ", g ); + CHAR_talkToCli( talkerindex, meindex , msg, CHAR_COLORWHITE ); + } else if( g > 0 && yn == 0 ){ + snprintf( msg , sizeof( msg ), + " %dĽDZҪġ", g ); + } else if( g > 0 && yn == 1 ){ + int now_g = CHAR_getInt( talkerindex, CHAR_GOLD ); + if( now_g < g ){ + snprintf( msg , sizeof( msg ) , + " %dĽDZҪġ", g ); + CHAR_talkToCli( talkerindex, meindex , msg, CHAR_COLORWHITE ); + } else { + snprintf( msg , sizeof( msg ), + "%d յˡھš", g ); + CHAR_talkToCli( talkerindex, meindex , msg, CHAR_COLORWHITE ); + + /* ë */ + now_g -= g; + CHAR_setInt( talkerindex , CHAR_GOLD , now_g ); + /* ؤе ë˪ */ + CHAR_send_P_StatusString(talkerindex, CHAR_P_STRING_GOLD); + + /* ʧ */ + NPC_DoormanOpenDoor( + CHAR_getWorkChar( meindex, CHAR_WORKDOORMANDOORNAME)); + } + } + } else if( strcmp( mode , "item" ) == 0 ){ + CHAR_talkToCli( talkerindex, meindex , + "δ֧Ԯģʽ", + CHAR_COLORWHITE); + } else if( strcmp( mode , "itemhave" ) == 0 ){ + CHAR_talkToCli( talkerindex, meindex , + "δ֧Ԯģʽ", + CHAR_COLORWHITE); + } else if( strcmp( mode , "itemnothave" ) == 0 ){ + CHAR_talkToCli( talkerindex, meindex , + "δ֧Ԯģʽ", + CHAR_COLORWHITE); + } else if( strcmp( mode , "titlehave" ) == 0 ){ + CHAR_talkToCli( talkerindex, meindex , + "δ֧Ԯģʽ", + CHAR_COLORWHITE); + + } else if( strcmp( mode , "roomlimit" ) == 0 ){ + + /* м׻ؤ */ + char szOk[256], szNg[256], szBuf[32]; + int checkfloor; + int maxnum, i, iNum; + + if( !getStringFromIndexWithDelim( arg, "|", 2, szBuf, sizeof( szBuf ) )) + return; + + /* Ʃ°׷ʧ */ + if( sscanf( szBuf, "%d:%d", &checkfloor, &maxnum ) != 2 ){ + return; + } + + for( iNum = 0,i = 0; i < getFdnum(); i ++ ){ + /* ½巴 */ + if( CHAR_getCharUse( i ) == FALSE )continue; + if( CHAR_getInt( i, CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER )continue; + /* ϶ü׷ʧ½ */ + if( CHAR_getInt( i, CHAR_FLOOR ) != checkfloor )continue; + iNum++; + } + if( !getStringFromIndexWithDelim( arg, "|", 5, szNg, sizeof( szNg ))){ + strcpy( szNg, "" ); /* ɡئƼ */ + } + if( !getStringFromIndexWithDelim( arg, "|", 4, szOk, sizeof( szOk ))){ + strcpy( szOk, "Űɡ" ); /* ɡؤԻ */ + } + + if( iNum >= maxnum ){ + /* ë */ + CHAR_talkToCli( talkerindex, meindex ,szNg, CHAR_COLORWHITE); + }else{ + /* ئ */ + CHAR_talkToCli( talkerindex, meindex ,szOk, CHAR_COLORWHITE); + NPC_DoormanOpenDoor( + CHAR_getWorkChar( meindex, CHAR_WORKDOORMANDOORNAME)); + } + + } else if( strcmp( mode , "titlenothave" ) == 0 ){ + CHAR_talkToCli( talkerindex, meindex , + "δ֧Ԯģʽ", + CHAR_COLORWHITE); + } +} + +/* + * ƥƻ׼ëͻʣ + * + */ +static void NPC_DoormanOpenDoor( char *nm) +{ + int doori = NPC_DoorSearchByName( nm ); + print( "RINGO: Doorman's Door: index: %d\n", doori ); + + NPC_DoorOpen( doori , -1 ); + +} + diff --git a/npc/npc_duelranking.c b/npc/npc_duelranking.c new file mode 100644 index 0000000..a69cfbd --- /dev/null +++ b/npc/npc_duelranking.c @@ -0,0 +1,227 @@ +#include "version.h" +#include +#include "char.h" +#include "object.h" +#include "char_base.h" +#include "npcutil.h" +#include "net.h" +#include "lssproto_serv.h" +#include "saacproto_cli.h" +#include "npc_duelranking.h" +#include "handletime.h" + +static void NPC_Duelranking_selectWindow( int meindex, int toindex, int num, int select ); +#define NPC_DUELRANKING_WINDOWLINENUM 10 + + +enum{ + WINDOWTYPE_PKLIST_START=10, + WINDOWTYPE_PKLIST_SELECT, + WINDOWTYPE_PKLIST_SELECT1, + WINDOWTYPE_PKLIST_SELECT2, + + WINDOWTYPE_FAMILYCONTENDSTART, + WINDOWTYPE_FAMILYCONTENDSELECT, + WINDOWTYPE_FAMILYCONTENDLIST, + WINDOWTYPE_FAMILYCONTENDJOIN, + + NPC_WORK_CURRENTTIME = CHAR_NPCWORKINT1, + NPC_WORK_BATTLELOOP = CHAR_NPCWORKINT2, +}; + +BOOL NPC_DuelrankingInit( int meindex ) +{ + CHAR_setInt( meindex , CHAR_WHICHTYPE , CHAR_TYPEDUELRANKING ); + return TRUE; +} + +void NPC_DuelrankingLooked( int meindex , int lookedindex) +{ + NPC_Duelranking_selectWindow( meindex, lookedindex, 1, -1); +} + +static void NPC_Duelranking_selectWindow( int meindex, int toindex, int num, int select) +{ + + int fd; + if( CHAR_getInt( toindex , CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER ) { + return; + } + if( NPC_Util_CharDistance( toindex, meindex ) > 1) return; + if( (fd = getfdFromCharaIndex( toindex)) == -1 ) return; + + switch( num){ + case 1: + { + char message[1024]; + char buf[2048]; + strcpy( message, + "1\n" + " Ҫһ \n\n\n" + " ǿǣ \n\n" + " Լ \n\n" + " \n\n" ); + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_SELECT, + WINDOW_BUTTONTYPE_NONE, + CHAR_WINDOWTYPE_DUELRANKING_START, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + makeEscapeString( message, buf, sizeof(buf))); + } + break; + } +} + +void NPC_DuelrankingWindowTalked( int meindex, int talkerindex, int seqno, int select, char *data) +{ + int fdid = getFdidFromCharaIndex( talkerindex); + if( fdid == -1 ) return; + + if( NPC_Util_CharDistance( talkerindex, meindex ) > 1) return; + switch( seqno){ + case CHAR_WINDOWTYPE_DUELRANKING_START: + if( atoi( data) == 3 ) { + saacproto_DBGetEntryByCount_send( acfd, + DB_DUELPOINT, 0, + NPC_DUELRANKING_WINDOWLINENUM, fdid, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX)); + } + if( atoi( data) == 5 ) { + char dbkey[256]; + CHAR_makeDBKey( talkerindex, dbkey, sizeof( dbkey)); + saacproto_DBGetEntryRank_send( acfd, DB_DUELPOINT, dbkey, fdid, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX)); + } + break; + case CHAR_WINDOWTYPE_DUELRANKING_TOPRANKING: + if( select == WINDOW_BUTTONTYPE_PREV || select == WINDOW_BUTTONTYPE_NEXT) { + int count = CHAR_getWorkInt( talkerindex, CHAR_WORKSHOPRELEVANT); + if( select == WINDOW_BUTTONTYPE_NEXT ) { + count += NPC_DUELRANKING_WINDOWLINENUM; + }else { + count -= NPC_DUELRANKING_WINDOWLINENUM; + } + + if( count < 0) count = 0; + saacproto_DBGetEntryByCount_send( acfd, + DB_DUELPOINT, + count, + NPC_DUELRANKING_WINDOWLINENUM, fdid, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX)); + }else if( select == WINDOW_BUTTONTYPE_OK ) { + if( strlen( data) != 0 ) { + int count; + count = atoi( data); + if( count < 1 ) count = 1; + saacproto_DBGetEntryByCount_send( acfd, + DB_DUELPOINT, + count-1, + NPC_DUELRANKING_WINDOWLINENUM, fdid, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX)); + } + } + break; + } +} + +void NPC_Duelranking_PrintRanking( char *data, int count_start, int fdid, int msgid2) +{ + char message[1024]; + char buf[2048]; + int i; + int cnt = 0; + int button = 0; + int fd = getfdFromFdid( fdid); + if( fd == -1 ) return; + message[0] = '\0'; + snprintf( message, sizeof( message), + " ǿ\n\n" + " Rank DuelPoint Lv Name\n\n" ); + for( i = 1; ; i ++ ) { + char rankdata[256]; + char cdandname[64]; + char charaname[32]; + char rank[16]; + char score[64]; + char msgbuf[512]; + char cdkey[32]; + char lv[16]; + char hosi[6]; + + if( !getStringFromIndexWithDelim( data, "|", i, rankdata, sizeof( rankdata))) { + break; + } + if( !getStringFromIndexWithDelim( rankdata, ",", 2, rank, sizeof( rank)) ){ + continue; + } + if( !getStringFromIndexWithDelim( rankdata, ",", 3, cdandname, sizeof( cdandname)) ){ continue; + } + makeStringFromEscaped( cdandname); + if( !getStringFromIndexWithDelim( cdandname, "_", 1, cdkey, sizeof( cdkey)) ){ + continue; + } + if( !getStringFromIndexWithDelim( cdandname, "_", 2, charaname, sizeof( charaname)) ){ + continue; + } + if( !getStringFromIndexWithDelim( rankdata, ",", 4, score, sizeof( score)) ){ + continue; + } + if( !getStringFromIndexWithDelim( rankdata, ",", 5, lv, sizeof( lv)) ){ + lv[0] = '\0'; + } + { + char *mycdkey = CHAR_getChar( CONNECT_getCharaindex(fd), CHAR_CDKEY); + char *myname = CHAR_getChar( CONNECT_getCharaindex(fd), CHAR_NAME); + char engnum[4][3] = { "st","nd","rd","th"}; + int dsprank = atoi(rank); + if( dsprank > 3) dsprank = 3; + if( mycdkey != NULL && myname != NULL && strcmp( cdkey, mycdkey) == 0 && + strcmp( charaname, myname) == 0 ) { + strcpy( hosi, ""); + }else { + strcpy( hosi, ""); + } + snprintf( msgbuf, sizeof( msgbuf), "%s %5d%s %10s %3s %s\n", + hosi, + atoi(rank)+1, engnum[dsprank], + score, lv, + charaname ); + } + strcatsafe( message, sizeof( message), msgbuf); + cnt ++; + } + if( cnt == 0 ) { + strcpy( message, "\n ûˡ"); + button = WINDOW_BUTTONTYPE_PREV|WINDOW_BUTTONTYPE_OK; + }else if( cnt < NPC_DUELRANKING_WINDOWLINENUM ) { + if( count_start >= NPC_DUELRANKING_WINDOWLINENUM) { + button = WINDOW_BUTTONTYPE_OK | WINDOW_BUTTONTYPE_PREV; + }else { + button = WINDOW_BUTTONTYPE_OK; + } + }else if( count_start == 0 ) { + button = WINDOW_BUTTONTYPE_NEXT|WINDOW_BUTTONTYPE_OK; + }else { + button = WINDOW_BUTTONTYPE_NEXT|WINDOW_BUTTONTYPE_PREV|WINDOW_BUTTONTYPE_OK; + } + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_WIDEMESSAGEANDLINEINPUT, + button, + CHAR_WINDOWTYPE_DUELRANKING_TOPRANKING, + msgid2, + makeEscapeString( message, buf, sizeof(buf))); + + if( cnt == 0 ) { + CHAR_setWorkInt( CONNECT_getCharaindex(fd), CHAR_WORKSHOPRELEVANT, -1); + }else { + CHAR_setWorkInt( CONNECT_getCharaindex(fd), CHAR_WORKSHOPRELEVANT, count_start); + } +} + +void NPC_Duelranking_CallMyRanking( int count, int msgid, int msgid2) +{ + count -= 5; + if( count < 0 ) count = 0; + saacproto_DBGetEntryByCount_send( acfd, DB_DUELPOINT, + count, NPC_DUELRANKING_WINDOWLINENUM, + msgid, msgid2 ); +} + diff --git a/npc/npc_eventaction.c b/npc/npc_eventaction.c new file mode 100644 index 0000000..fffb3e1 --- /dev/null +++ b/npc/npc_eventaction.c @@ -0,0 +1,4543 @@ +#include "version.h" +#include +#include "char.h" +#include "object.h" +#include "char_base.h" +#include "npcutil.h" +#include "lssproto_serv.h" +#include "saacproto_cli.h" +#include "map_deal.h" +#include "readmap.h" +#include "battle.h" +#include "log.h" +#include "enemy.h" +#include "handletime.h" +#include "npc_eventaction.h" +#include "family.h" + +#ifdef _ANGEL_SUMMON +extern struct MissionInfo missionlist[MAXMISSION]; +extern struct MissionTable missiontable[MAXMISSIONTABLE]; +#endif +#ifdef _PROFESSION_SKILL // WON ADD ְҵ +#include "profession_skill.h" +#include "chatmagic.h" +#endif + +enum{ + NPC_EVENTMODE_NONE, + NPC_EVENTMODE_OPEN, + NPC_EVENTMODE_EVENT, +}; + +typedef struct { + char arg[32]; + int born; + int dead; +}NPC_TimeMan; + +#define YOAKE 700 +#define NICHIBOTU 300 +#define SHOUGO 125 +#define YONAKA 500 + +static NPC_TimeMan TimeTble[] = { + {"ALLNIGHT", NICHIBOTU+1, YOAKE}, + {"ALLNOON", YOAKE+1, NICHIBOTU}, + {"AM", YONAKA+1, SHOUGO}, + {"PM", SHOUGO+1, YONAKA}, + {"FORE", YOAKE+1, SHOUGO}, + {"AFTER", SHOUGO+1, NICHIBOTU}, + {"EVNING", NICHIBOTU+1, YONAKA}, + {"MORNING", YONAKA+1, YOAKE}, + {"FREE", 0, 1024}, +}; + +extern void BATTLE_changeRideImage( int index ); + + +#define MAXNPCPOINT 10 + +int year,mon,date,day,hour,min,sec; +BOOL ActionNpc_WarpPoint(int meindex,int talker,char *npcarg) +{ + char data[1024], buf1[256], buf2[256]; + int i=1, j=0; + BOOL EvFlg=FALSE; + + struct { + int FLOOR; + int X; + int Y; + }Points[MAXNPCPOINT]; + + for( i=0;i= MAXNPCPOINT ) + break; + } + where = RAND( 0, j-1); + if( MAP_IsValidCoordinate( Points[where].FLOOR, Points[where].X, Points[where].Y ) == TRUE ){ + CHAR_warpToSpecificPoint( meindex, Points[where].FLOOR, Points[where].X, Points[where].Y); + EvFlg = TRUE; + }else { + for( i=0; i<10; i++) { + print("%d.[%d,%d,%d]\n", i, Points[i].FLOOR, Points[i].X, Points[i].Y); + } + } + } + + if( NPC_Util_GetStrFromStrWithDelim( npcarg, "WARPPOINT", data, sizeof( data)) != NULL ) { + int where=0; + i=1; + j=0; + while( getStringFromIndexWithDelim( data, ";", i, buf1, sizeof( buf1)) != FALSE ) { + i++; + getStringFromIndexWithDelim( buf1, ",", 1, buf2, sizeof( buf2)); + Points[j].FLOOR = atoi( buf2); + getStringFromIndexWithDelim( buf1, ",", 2, buf2, sizeof( buf2)); + Points[j].X = atoi( buf2); + getStringFromIndexWithDelim( buf1, ",", 3, buf2, sizeof( buf2)); + Points[j].Y = atoi( buf2); + j++; + if( j >= MAXNPCPOINT ) + break; + } + where = RAND( 0, j-1); + if( MAP_IsValidCoordinate( Points[where].FLOOR, Points[where].X, Points[where].Y ) == TRUE ){ + CHAR_warpToSpecificPoint( talker, Points[where].FLOOR, Points[where].X, Points[where].Y); + EvFlg = TRUE; + }else { + for( i=0; i<10; i++) { + print("%d.[%d,%d,%d]\n", i, Points[i].FLOOR, Points[i].X, Points[i].Y); + } + } + + } + + return EvFlg; +} + +BOOL ActionNpc_CheckMenuFree( int meindex, int toindex, char *npcarg, int nums) +{ + char buf1[1024], buf2[256]; + if( nums < 1 ) return FALSE; + + if( NPC_Util_GetStrFromStrWithDelim( npcarg, "CHECKPARTY", buf1, sizeof( buf1) ) != NULL){ + if( strstr( buf1, "TRUE") != 0 ) { + if( Action_PartyCheck( meindex, toindex) == FALSE) { + CHAR_talkToCli( toindex, meindex, "һһ", CHAR_COLORYELLOW); + return FALSE; + } + } + } + if( getStringFromIndexWithDelim( npcarg,"}", nums, buf1, sizeof( buf1)) == FALSE ) + return FALSE; + + if( NPC_Util_GetStrFromStrWithDelim( buf1, "FREE", buf2, sizeof( buf2) ) == NULL) +#ifdef _VIP_SHOP + if( NPC_Util_GetStrFromStrWithDelim( buf1, "VipItem", buf2, sizeof( buf2) ) == NULL) + if(NPC_Util_GetStrFromStrWithDelim( buf1, "VipPet", buf2, sizeof( buf2) ) == NULL) +#endif +#ifdef _VIP_SHOP + if( NPC_Util_GetStrFromStrWithDelim( buf1, "Vip_Item", buf2, sizeof( buf2) ) == NULL) + if(NPC_Util_GetStrFromStrWithDelim( buf1, "Vip_Pet", buf2, sizeof( buf2) ) == NULL) + if(NPC_Util_GetStrFromStrWithDelim( buf1, "Vip_Abi_Pet", buf2, sizeof( buf2) ) == NULL) +#endif +#ifdef _TEACHER_SYSTEM + if( NPC_Util_GetStrFromStrWithDelim( buf1, "StuItem", buf2, sizeof( buf2) ) == NULL) + if(NPC_Util_GetStrFromStrWithDelim( buf1, "StuPet", buf2, sizeof( buf2) ) == NULL) +#endif +#ifdef _RMB_SYSTEM + if( NPC_Util_GetStrFromStrWithDelim( buf1, "RmbPoint", buf2, sizeof( buf2) ) == NULL) + if( NPC_Util_GetStrFromStrWithDelim( buf1, "RmbItem", buf2, sizeof( buf2) ) == NULL) + if( NPC_Util_GetStrFromStrWithDelim( buf1, "RmbPet", buf2, sizeof( buf2) ) == NULL) +#endif + return FALSE; + + + if( NPC_ActionPassCheck( meindex, toindex, buf2) == FALSE ) { +#ifdef _VIP_SHOP + if( NPC_Util_GetStrFromStrWithDelim( buf1, "VipItem", buf2, sizeof( buf2) ) == NULL) + if( NPC_Util_GetStrFromStrWithDelim( buf1, "VipPet", buf2, sizeof( buf2) ) == NULL) +#endif +#ifdef _VIP_SHOP + if( NPC_Util_GetStrFromStrWithDelim( buf1, "Vip_Item", buf2, sizeof( buf2) ) == NULL) + if(NPC_Util_GetStrFromStrWithDelim( buf1, "Vip_Pet", buf2, sizeof( buf2) ) == NULL) + if(NPC_Util_GetStrFromStrWithDelim( buf1, "Vip_Abi_Pet", buf2, sizeof( buf2) ) == NULL) +#endif +#ifdef _TEACHER_SYSTEM + if( NPC_Util_GetStrFromStrWithDelim( buf1, "StuItem", buf2, sizeof( buf2) ) == NULL) + if( NPC_Util_GetStrFromStrWithDelim( buf1, "StuPet", buf2, sizeof( buf2) ) == NULL) +#endif +#ifdef _RMB_SYSTEM + if( NPC_Util_GetStrFromStrWithDelim( buf1, "RmbPoint", buf2, sizeof( buf2) ) == NULL) + if( NPC_Util_GetStrFromStrWithDelim( buf1, "RmbItem", buf2, sizeof( buf2) ) == NULL) + if( NPC_Util_GetStrFromStrWithDelim( buf1, "RmbPet", buf2, sizeof( buf2) ) == NULL) +#endif + { + CHAR_talkToCli( toindex, meindex, "㣡", CHAR_COLORYELLOW); + return FALSE; + } + } + return Action_RunDoEventAction( meindex, toindex, buf1); +} + +BOOL ActionNpc_CheckFree( int meindex, int toindex, char *npcarg) +{ + char buf1[2048], buf2[256]; + if( NPC_Util_GetStrFromStrWithDelim( npcarg, "CHECKPARTY", buf1, sizeof( buf1) ) != NULL){ + if( strstr( buf1, "TRUE") != 0 ) { + if( Action_PartyCheck( meindex, toindex) == FALSE) { + CHAR_talkToCli( toindex, meindex, "һһ", CHAR_COLORYELLOW); + return FALSE; + } + } + } + if( NPC_Util_GetStrFromStrWithDelim( npcarg, "FREE", buf2, sizeof( buf2) ) == NULL) +#ifdef _VIP_SHOP + if( NPC_Util_GetStrFromStrWithDelim( buf1, "VipItem", buf2, sizeof( buf2) ) == NULL) + if( NPC_Util_GetStrFromStrWithDelim( buf1, "VipPet", buf2, sizeof( buf2) ) == NULL) +#endif +#ifdef _VIP_SHOP + if( NPC_Util_GetStrFromStrWithDelim( buf1, "Vip_Item", buf2, sizeof( buf2) ) == NULL) + if(NPC_Util_GetStrFromStrWithDelim( buf1, "Vip_Pet", buf2, sizeof( buf2) ) == NULL) + if(NPC_Util_GetStrFromStrWithDelim( buf1, "Vip_Abi_Pet", buf2, sizeof( buf2) ) == NULL) +#endif +#ifdef _TEACHER_SYSTEM + if( NPC_Util_GetStrFromStrWithDelim( buf1, "StuItem", buf2, sizeof( buf2) ) == NULL) + if( NPC_Util_GetStrFromStrWithDelim( buf1, "StuPet", buf2, sizeof( buf2) ) == NULL) +#endif +#ifdef _RMB_SYSTEM + if( NPC_Util_GetStrFromStrWithDelim( buf1, "RmbPoint", buf2, sizeof( buf2) ) == NULL) + if( NPC_Util_GetStrFromStrWithDelim( buf1, "RmbItem", buf2, sizeof( buf2) ) == NULL) + if( NPC_Util_GetStrFromStrWithDelim( buf1, "RmbPet", buf2, sizeof( buf2) ) == NULL) +#endif + return FALSE; + + if( NPC_ActionPassCheck( meindex, toindex, buf2) == FALSE ) { +#ifdef _VIP_SHOP + if( NPC_Util_GetStrFromStrWithDelim( buf1, "VipItem", buf2, sizeof( buf2) ) == NULL) + if( NPC_Util_GetStrFromStrWithDelim( buf1, "VipPet", buf2, sizeof( buf2) ) == NULL) +#endif +#ifdef _VIP_SHOP + if( NPC_Util_GetStrFromStrWithDelim( buf1, "Vip_Item", buf2, sizeof( buf2) ) == NULL) + if(NPC_Util_GetStrFromStrWithDelim( buf1, "Vip_Pet", buf2, sizeof( buf2) ) == NULL) + if(NPC_Util_GetStrFromStrWithDelim( buf1, "Vip_Abi_Pet", buf2, sizeof( buf2) ) == NULL) +#endif +#ifdef _TEACHER_SYSTEM + if( NPC_Util_GetStrFromStrWithDelim( buf1, "StuItem", buf2, sizeof( buf2) ) == NULL) + if( NPC_Util_GetStrFromStrWithDelim( buf1, "StuPet", buf2, sizeof( buf2) ) == NULL) +#endif +#ifdef _RMB_SYSTEM + if( NPC_Util_GetStrFromStrWithDelim( buf1, "RmbPoint", buf2, sizeof( buf2) ) == NULL) + if( NPC_Util_GetStrFromStrWithDelim( buf1, "RmbItem", buf2, sizeof( buf2) ) == NULL) + if( NPC_Util_GetStrFromStrWithDelim( buf1, "RmbPet", buf2, sizeof( buf2) ) == NULL) +#endif + { + CHAR_talkToCli( toindex, meindex, "㣡", CHAR_COLORYELLOW); + return FALSE; + } + } + return Action_RunDoEventAction( meindex, toindex, buf1); +} + +#ifdef _CHANNEL_MODIFY +extern int *piOccChannelMember; +#endif + +BOOL Action_RunDoEventAction( int meindex, int toindex, char *buf1) +{ + char buf2[2048]; + +#if 1 // Robin NPCִжǰһμFREE + if( NPC_Util_GetStrFromStrWithDelim( buf1, "FREE", buf2, sizeof( buf2)) != NULL ) { + if( NPC_ActionPassCheck( meindex, toindex, buf2 ) == FALSE && buf2[0] == '\n' ) { + print("\n ķ!?NPCFREE!!:%s:%d,%d,%d ", + CHAR_getChar(toindex, CHAR_CDKEY), + CHAR_getInt(toindex, CHAR_FLOOR), + CHAR_getInt(toindex, CHAR_X), + CHAR_getInt(toindex, CHAR_Y) ); + CHAR_warpToSpecificPoint(toindex,117,225,13); + return FALSE; + } + } +#endif + + + if( NPC_Util_GetStrFromStrWithDelim( buf1, "AddGold", buf2, sizeof( buf2)) != NULL ) { + if( NPC_ActionAddGold2( toindex, buf2) == FALSE ) + return FALSE; + } + + if( NPC_Util_GetStrFromStrWithDelim( buf1, "DelGold", buf2, sizeof( buf2)) != NULL ) { + if( NPC_ActionDelGold( toindex, buf2) == FALSE ) + return FALSE; + } + + if( NPC_Util_GetStrFromStrWithDelim( buf1, "AddFame", buf2, sizeof( buf2)) != NULL ) { + if( NPC_ActionAddFame( toindex, buf2) == FALSE ) + return FALSE; + } + + if( NPC_Util_GetStrFromStrWithDelim( buf1, "DelFame", buf2, sizeof( buf2)) != NULL ) { + if( NPC_ActionDelFame( toindex, buf2) == FALSE ) + return FALSE; + } + + if( NPC_Util_GetStrFromStrWithDelim( buf1, "AddVipPoint", buf2, sizeof( buf2)) != NULL ) { + if( NPC_ActionAddVipPoint( toindex, buf2) == FALSE ) + return FALSE; + } + + if( NPC_Util_GetStrFromStrWithDelim( buf1, "DelVipPoint", buf2, sizeof( buf2)) != NULL ) { + if( NPC_ActionDelVipPoint( toindex, buf2) == FALSE ) + return FALSE; + } + + if( NPC_Util_GetStrFromStrWithDelim( buf1, "AddPoint", buf2, sizeof( buf2)) != NULL ) { + if( NPC_ActionAddPoint( toindex, buf2) == FALSE ) + return FALSE; + } + + if( NPC_Util_GetStrFromStrWithDelim( buf1, "DelPoint", buf2, sizeof( buf2)) != NULL ) { + if( NPC_ActionDelPoint( toindex, buf2) == FALSE ) + return FALSE; + } +#ifdef _VIGOR_SYS + if( NPC_Util_GetStrFromStrWithDelim( buf1, "AddVigor", buf2, sizeof( buf2)) != NULL ) { + if( NPC_ActionAddVigor( toindex, buf2) == FALSE ) + return FALSE; + } + + if( NPC_Util_GetStrFromStrWithDelim( buf1, "DelVigor", buf2, sizeof( buf2)) != NULL ) { + if( NPC_ActionDelVigor( toindex, buf2) == FALSE ) + return FALSE; + } +#endif + +#ifdef _MOMENTUM_NPC + if( NPC_Util_GetStrFromStrWithDelim( buf1, "DelMom", buf2, sizeof( buf2)) != NULL ) { + if( NPC_ActionMomentum( toindex, buf2) == FALSE ) + return FALSE; + } +#endif +#ifdef _DP_NPC + if( NPC_Util_GetStrFromStrWithDelim( buf1, "DelDP", buf2, sizeof( buf2)) != NULL ) { + if( NPC_ActionDP( toindex, buf2) == FALSE ) + return FALSE; + } +#endif + if( NPC_Util_GetStrFromStrWithDelim( buf1, "DelItem", buf2, sizeof( buf2)) != NULL ) { + //print("\n DelItem:%s:%d ", __FILE__, __LINE__); + if( NPC_ActionDelItem( toindex, buf2) == FALSE ) { + //print("\n ķ??NPC_ActionDelItem:%s:%s ", CHAR_getChar(toindex, CHAR_CDKEY), buf2); + //CHAR_warpToSpecificPoint(toindex,117,225,13); + return FALSE; + } + } + + //npcĵ + if( NPC_Util_GetStrFromStrWithDelim( buf1, "AddItem", buf2, sizeof( buf2)) != NULL ) { + if( NPC_ActionAddItem( toindex, buf2) == FALSE ) + return FALSE; + } + if( NPC_Util_GetStrFromStrWithDelim( buf1, "GetUpItem", buf2, sizeof( buf2)) != NULL ) { + if( NPC_ActionUpItem( toindex, buf2) == FALSE ) + return FALSE; + if( NPC_Util_GetStrFromStrWithDelim( buf1, "HeChengMsg", buf2, sizeof( buf2)) != NULL ) { + int k; + int playernum = CHAR_getPlayerMaxNum(); + char hcmsg[256]; + sprintf(hcmsg,"ϳɴˡϲҡ%sɹϳ%s",CHAR_getChar(toindex,CHAR_NAME),buf2); + for(k=0;k PROFESSION_CLASS_NONE && p_class < PROFESSION_CLASS_NUM ) // 1:սʿ 2:ʦ 3: + { + int i, value = 0; + int skill_id = -1; + + // ԭ + if( PROFESSION_RESTORE_POINT( toindex ) != 1 ) return FALSE; + + // 趨ְҵ + CHAR_setInt( toindex, PROFESSION_CLASS, p_class ); +#ifdef _CHANNEL_MODIFY + if(CHAR_getInt(toindex,PROFESSION_CLASS) > 0){ + int i,pclass = CHAR_getInt(toindex,PROFESSION_CLASS) - 1; + for(i=0;i 0){ + int i,pclass = CHAR_getInt(toindex,PROFESSION_CLASS) - 1; + for(i=0;i") != NULL ){ + strcat( Head, ">"); + flg = 1; + }else if( strstr( buf2, "<") != NULL ){ + strcat( Head, "<"); + flg = 2; + }else if( strstr( buf2, "!") != NULL ) { + strcat( Head, "!"); + flg = 5; + } + }else if(strstr( buf2, "<") != NULL){ + strcpy( Head, "<"); + flg = 4; + }else if(strstr( buf2, ">") != NULL){ + strcpy( Head, ">"); + flg = 3; + } + Head[ strlen( Head)+1] = 0; + if( NPC_Util_GetStrFromStrWithDelim( buf2, Head, buf3, sizeof( buf3) ) != NULL) { + if( flg == 0 ) + if( atoi(buf3) != partys ) return FALSE; + else if( flg == 1 ) + if( atoi(buf3) < partys ) return FALSE; + else if( flg == 2 ) + if( atoi(buf3) > partys ) return FALSE; + else if( flg == 3 ) + if( atoi(buf3) <= partys ) return FALSE; + else if( flg == 4 ) + if( atoi(buf3) >= partys ) return FALSE; + else if( flg == 5 ) + if( atoi(buf3) == partys ) return FALSE; + } + }*/ +#endif + + ActionNpc_WarpPoint( meindex, toindex, buf1); + return TRUE; +} +BOOL Action_PartyCheck( int meindex, int talker) +{ + if(CHAR_getWorkInt(talker,CHAR_WORKPARTYMODE) != CHAR_PARTY_NONE){ + return FALSE; + } + return TRUE; +} + +BOOL NPC_ActionAddGold( int talker, int Golds) +{ + CHAR_AddGold( talker, Golds); + return TRUE; +} + +BOOL NPC_ActionDelGold( int talker,char *buf) +{ + int Golds=0; + int PGold=0; + if( buf == NULL ) return FALSE; + Golds = atoi( buf); + PGold = CHAR_getInt( talker, CHAR_GOLD); + if( PGold < Golds ) { + CHAR_talkToCli( talker, -1, "ϵǮร", CHAR_COLORYELLOW); + return FALSE; + }else { + char buf1[256]; + sprintf( buf1, "%dʯ", Golds); + CHAR_talkToCli( talker, -1, buf1, CHAR_COLORYELLOW); + } + CHAR_setInt( talker, CHAR_GOLD, PGold-Golds); + CHAR_send_P_StatusString( talker , CHAR_P_STRING_GOLD); + return TRUE; +} + +BOOL NPC_ActionAddFame( int talker,char *buf) +{ + int Fames=0; + int MFame=0; + if( buf == NULL ) return FALSE; + Fames = atoi( buf); + MFame = CHAR_getInt( talker, CHAR_FAME)+Fames*100; + if( MFame > 1000000 ) { + CHAR_talkToCli( talker, -1, "ร", CHAR_COLORYELLOW); + return FALSE; + }else { + char buf1[256]; + sprintf( buf1, "%d", Fames); + CHAR_talkToCli( talker, -1, buf1, CHAR_COLORYELLOW); + } + CHAR_setInt( talker, CHAR_FAME, MFame); + return TRUE; +} + +BOOL NPC_ActionDelFame( int talker,char *buf) +{ + int Fames=0; + int MFame=0; + if( buf == NULL ) return FALSE; + Fames = atoi( buf); + MFame = CHAR_getInt( talker, CHAR_FAME)/100; + if( MFame < Fames ) { + CHAR_talkToCli( talker, -1, "ร", CHAR_COLORYELLOW); + return FALSE; + }else { + char buf1[256]; + sprintf( buf1, "%d", Fames); + CHAR_talkToCli( talker, -1, buf1, CHAR_COLORYELLOW); + } + CHAR_setInt( talker, CHAR_FAME, CHAR_getInt( talker, CHAR_FAME)-Fames*100); + return TRUE; +} +BOOL NPC_ActionAddVipPoint( int talker,char *buf) +{ + int Vippoints=0; + int MVippoint=0; + if( buf == NULL ) return FALSE; + Vippoints = atoi( buf); + MVippoint = sasql_vippoint( CHAR_getChar(talker,CHAR_CDKEY), 0,0); + char buf1[256]; + sprintf( buf1, "%dԱ", Vippoints); + CHAR_talkToCli( talker, -1, buf1, CHAR_COLORYELLOW); + sasql_vippoint( CHAR_getChar(talker,CHAR_CDKEY), Vippoints,1); + return TRUE; +} +BOOL NPC_ActionDelVipPoint( int talker,char *buf) +{ + int Vippoints=0; + int MVippoint=0; + if( buf == NULL ) return FALSE; + Vippoints = atoi( buf); + MVippoint = sasql_vippoint( CHAR_getChar(talker,CHAR_CDKEY), 0,0); + if(MVippoint MaxGold ) total_gold = MaxGold; + + CHAR_setInt( talker, CHAR_GOLD, total_gold ); + CHAR_send_P_StatusString( talker , CHAR_P_STRING_GOLD); + return TRUE; +} + +BOOL NPC_ActionDelPet( int talker, char *buf) +{ + int petsel; + int petindex=0, k=1; + int fd = getfdFromCharaIndex( talker ); + char msgbuf[64], szPet[128],buff2[256],buff3[256]; + char buf2[256],buff1[256]; + int defpet; + int petno,kNum,find=0,petLv=0,flg=-1; + + while( getStringFromIndexWithDelim(buf , "," , k, buff1, sizeof( buff1)) !=FALSE ) { + k++; + if( strstr( buff1,"-") != NULL ) { + getStringFromIndexWithDelim(buff1,"-",2,buff3,sizeof(buff3)); + getStringFromIndexWithDelim(buff1,"-",1,buf2,sizeof(buf2)); + + if( strstr( buf2,"!") != NULL ) { + flg = 0; + getStringFromIndexWithDelim(buf2,"!=",2,buff2,sizeof(buff2)); + }else if( strstr( buf,"<") != NULL ) { + flg = 1; + getStringFromIndexWithDelim(buf2,"<",2,buff2,sizeof(buff2)); + }else if( strstr( buf,">") != NULL ) { + flg = 2; + getStringFromIndexWithDelim(buf2,">",2,buff2,sizeof(buff2)); + }else if( strstr( buf,"=") != NULL) { + flg = 3; + getStringFromIndexWithDelim(buf2,"=",2,buff2,sizeof(buff2)); + }else + return FALSE; + petLv = atoi( buff2); + } + continue; + + if(strstr(buff3,"*")!=NULL){ + getStringFromIndexWithDelim(buff3,"*",1,buf2,sizeof(buf2)); + petno = atoi(buf2); + getStringFromIndexWithDelim(buff3,"*",2,buf2,sizeof(buf2)); + kNum = atoi(buf2); + }else { + petno = atoi( buff3); + kNum = 30; + } + //andy_log + print("petno:%d kNum:%d \n ", petno, kNum); + + find =0; + + for(petsel=0 ; petsel < CHAR_MAXPETHAVE ; petsel++) { + petindex = CHAR_getCharPet( talker, petsel); + if( !CHAR_CHECKINDEX(petindex)) continue; + if(CHAR_getInt( petindex, CHAR_PETID) != petno )continue; + + switch( flg) { + case 0: + if( CHAR_getInt( petindex, CHAR_LV ) != petLv ) { + }else { + continue; + } + break; + case 1: + if( CHAR_getInt( petindex, CHAR_LV ) < petLv ) { + }else { + continue; + } + break; + case 2: + if( CHAR_getInt( petindex, CHAR_LV ) > petLv ) { + }else { + continue; + } + break; + case 3: + if( CHAR_getInt( petindex, CHAR_LV ) != petLv )continue; + break; + } + + petindex = CHAR_getCharPet( talker, petsel); + if( !CHAR_CHECKINDEX(petindex) ) + continue; + if( CHAR_getWorkInt( CONNECT_getCharaindex( fd), CHAR_WORKBATTLEMODE) != BATTLE_CHARMODE_NONE ) + continue; + defpet = CHAR_getInt( talker, CHAR_DEFAULTPET); + + if(defpet == petsel) { + CHAR_setInt( talker, CHAR_DEFAULTPET, -1); + lssproto_KS_send( fd, -1, TRUE); + } + + snprintf( msgbuf,sizeof( msgbuf), "%s", CHAR_getChar( petindex, CHAR_NAME)); + CHAR_talkToCli( talker, -1, msgbuf, CHAR_COLORYELLOW); + LogPet( + CHAR_getChar( talker, CHAR_NAME ), + CHAR_getChar( talker, CHAR_CDKEY ), + CHAR_getChar( petindex, CHAR_NAME), + CHAR_getInt( petindex, CHAR_LV), + "TenseiDel", + CHAR_getInt( talker,CHAR_FLOOR), + CHAR_getInt( talker,CHAR_X ), + CHAR_getInt( talker,CHAR_Y ), + CHAR_getChar( petindex, CHAR_UNIQUECODE) // shan 2001/12/14 + ); + CHAR_setCharPet( talker, petsel, -1); + CHAR_endCharOneArray( petindex ); + snprintf( szPet, sizeof( szPet ), "K%d", petsel); + CHAR_sendStatusString( talker, szPet ); + + find++; + if( find >= kNum ) + break; //Ŀɾ + } + } + + return TRUE; +} + +#ifdef _NPC_NewDelPet +BOOL NPC_ActionNewDelPet( int toindex, char *msg) +{ + int i,petindex=0,petlev,petnum,petcount,mypetlevel,petid; + char buf[32],buf2[32]; + int flg=0,count=0; + + //ȽϷʽ + if ( strstr( msg, "=" ) ) + flg = 0; + else if( strstr( msg, "<" ) ) + flg = 1; + else + flg = 2; + + //ȼ + if ( getStringFromIndexWithDelim( msg, "-", 1, buf, sizeof( buf )) ){ + char cmp[12]; + if( flg == 0 ) + strcpy(cmp,"="); + else if( flg == 1 ) + strcpy(cmp,"<"); + else + strcpy(cmp,">"); + if ( getStringFromIndexWithDelim( buf, cmp, 2, buf2, sizeof( buf2 )) ){ + petlev = atoi(buf2); + } + else + return FALSE; + } + else + return FALSE; + + // + if ( getStringFromIndexWithDelim( msg, "-", 2, buf, sizeof( buf )) ){ + if ( getStringFromIndexWithDelim( buf, "*", 1, buf2, sizeof( buf2 )) ){ + petnum = atoi( buf2 ); + } + else + return FALSE; + } + else + return FALSE; + + // + if ( getStringFromIndexWithDelim( msg, "-", 2, buf, sizeof( buf )) ){ + if ( getStringFromIndexWithDelim( buf, "*", 2, buf2, sizeof( buf2 )) ){ + petcount = atoi( buf2 ); + } + else + return FALSE; + } + else + return FALSE; + + for( i = 0; i < CHAR_MAXPETHAVE; i ++ ){ + BOOL cmp=FALSE; + petindex = CHAR_getCharPet( toindex, i); + petid = CHAR_getInt( petindex, CHAR_PETID); + mypetlevel = CHAR_getInt( petindex, CHAR_LV); + + if( flg == 0 ) + if( mypetlevel == petlev ) cmp = TRUE; + if( flg == 1 ) + if( mypetlevel < petlev ) cmp = TRUE; + if( flg == 2 ) + if( mypetlevel > petlev ) cmp = TRUE; + + if( petnum == petid && cmp ){//ɾ + char szPet[128]; + int defpet; + char msgbuf[64]; + int fd = getfdFromCharaIndex( toindex ); + + if( !CHAR_CHECKINDEX(petindex) ) return FALSE; + + if( CHAR_getInt( toindex, CHAR_RIDEPET) == i ) { + + //CHAR_talkToCli( talker, -1, "еij޷", CHAR_COLORYELLOW ); + //return FALSE; + + CHAR_setInt( toindex, CHAR_RIDEPET, -1); + CHAR_send_P_StatusString( toindex, CHAR_P_STRING_RIDEPET ); + CHAR_complianceParameter( toindex ); + CHAR_sendCToArroundCharacter( CHAR_getWorkInt( toindex , CHAR_WORKOBJINDEX )); + } + + //ƽҷ» ئգʸëڱ + if( CHAR_getWorkInt( CONNECT_getCharaindex( fd ), CHAR_WORKBATTLEMODE) != BATTLE_CHARMODE_NONE) + return FALSE; + //ʸᆴ + defpet = CHAR_getInt( toindex, CHAR_DEFAULTPET); + if(defpet == i){ + CHAR_setInt( toindex, CHAR_DEFAULTPET, -1); + lssproto_KS_send( fd, -1, TRUE); + } + + snprintf( msgbuf,sizeof( msgbuf), "%s", + CHAR_getChar( petindex, CHAR_NAME)); + CHAR_talkToCli( toindex, -1, msgbuf, CHAR_COLORWHITE); + + // ʸë ׷ + LogPet( CHAR_getChar( toindex, CHAR_NAME ), // ƽҷ + CHAR_getChar( toindex, CHAR_CDKEY ), + CHAR_getChar( petindex, CHAR_NAME), + CHAR_getInt( petindex, CHAR_LV), + "EvnetDell(ɾ)", + CHAR_getInt( toindex,CHAR_FLOOR), + CHAR_getInt( toindex,CHAR_X ), + CHAR_getInt( toindex,CHAR_Y ), + CHAR_getChar( petindex, CHAR_UNIQUECODE) // shan 2001/12/14 + ); + + + // + CHAR_setCharPet( toindex, i, -1); + + CHAR_endCharOneArray( petindex ); + + snprintf( szPet, sizeof( szPet ), "K%d", i); + // ޥʸ ˪Ի + CHAR_sendStatusString( toindex, szPet ); + + ++count; + if( count >= petcount ) + break; + } + } + + return TRUE; +} +#endif + +BOOL NPC_ActionAddPet( int talker, char *buf) +{ + int ret; + char msgbuf[64], buff3[64]; + int enemynum; + int i,j,k=1; + int petindex, petindex2, petid; + + k=1; + while( getStringFromIndexWithDelim(buf , "," , k, buff3, sizeof(buff3)) !=FALSE ){ + k++; + //Ƿпλ + for( i = 0 ;i < CHAR_MAXPETHAVE ; i++) { + petindex = CHAR_getCharPet( talker, i); + if( petindex == -1 ) + break; + } + + if( i == CHAR_MAXPETHAVE ){ + snprintf( msgbuf,sizeof( msgbuf), ""); + CHAR_talkToCli( talker, -1, msgbuf, CHAR_COLORYELLOW); + return FALSE; + } +#ifdef _PET_MM + if(strstr(buff3,"MM1") || strstr(buff3,"MM3")) + petid = 1479; + else if(strstr(buff3,"MM2") || strstr(buff3,"MM4")) + petid = 2547; + else + petid = atoi( buff3); +#else + petid = atoi( buff3); +#endif + enemynum = ENEMY_getEnemyNum(); + for( i = 0; i < enemynum; i ++ ) { + if( ENEMY_getInt( i, ENEMY_ID ) == petid ) + //if( ENEMY_getInt( i, ENEMY_TEMPNO ) == petid ) + break; + } + + if( i == enemynum ) + continue; + + ret = ENEMY_createPetFromEnemyIndex( talker, i); + for( i = 0; i < CHAR_MAXPETHAVE; i ++ ) { + if( CHAR_getCharPet( talker, i ) == ret ) + break; + } + if( i == CHAR_MAXPETHAVE ) + i = 0; + + if( CHAR_CHECKINDEX( ret ) == TRUE ){ +#ifdef _PET_MM + if(strstr(buff3,"MM1") || strstr(buff3,"MM2")){ + int LevelUpPoint; + LevelUpPoint = ( 50<< 24) + ( 50<< 16) + ( 50<< 8) + ( 50<< 0); + CHAR_setInt( ret, CHAR_ALLOCPOINT, LevelUpPoint); + }else if(strstr(buff3,"MM3") || strstr(buff3,"MM4")){ + while(CHAR_getInt( ret, CHAR_LV)<79){ // + int LevelUpPoint; + LevelUpPoint = ( 50<< 24) + ( 50<< 16) + ( 50<< 8) + ( 50<< 0); + CHAR_setInt( ret, CHAR_ALLOCPOINT, LevelUpPoint); + CHAR_PetLevelUp( ret ); + CHAR_PetAddVariableAi( ret, AI_FIX_PETLEVELUP ); + CHAR_setInt( ret, CHAR_LV, CHAR_getInt( ret, CHAR_LV) +1 ); + } + } +#endif + CHAR_setInt( ret, CHAR_HP, CHAR_getWorkInt( ret, CHAR_WORKMAXHP )); + CHAR_setMaxExpFromLevel( ret, CHAR_getInt( ret, CHAR_LV )); + CHAR_setInt(ret,CHAR_VARIABLEAI,10000); + } + + petindex2 = CHAR_getCharPet(talker, i); + if( !CHAR_CHECKINDEX( petindex2) ) + continue; + snprintf( msgbuf,sizeof( msgbuf), "õ%s", CHAR_getChar(petindex2,CHAR_NAME)); + CHAR_talkToCli( talker, -1, msgbuf, CHAR_COLORYELLOW); + for(j = 0; j < CHAR_MAXPETHAVE; j++){ + petindex = CHAR_getCharPet(talker, j); + if( !CHAR_CHECKINDEX( petindex) ) + continue; + CHAR_complianceParameter( petindex ); + snprintf( msgbuf, sizeof( msgbuf ), "K%d", j ); + CHAR_sendStatusString( talker, msgbuf ); + snprintf( msgbuf, sizeof( msgbuf ), "W%d", j ); + CHAR_sendStatusString( talker, msgbuf ); + } + + LogPet( + CHAR_getChar( talker, CHAR_NAME ), + CHAR_getChar( talker, CHAR_CDKEY ), + CHAR_getChar( petindex2, CHAR_NAME), + CHAR_getInt( petindex2, CHAR_LV), + "TenseiGet", + CHAR_getInt( talker,CHAR_FLOOR), + CHAR_getInt( talker,CHAR_X ), + CHAR_getInt( talker,CHAR_Y ), + CHAR_getChar( petindex2, CHAR_UNIQUECODE) // shan 2001/12/14 + ); + } + return TRUE; +} + +BOOL NPC_ActionTiaoZhanMsg( int toindex, char *msg) +{ + int k; + int playernum = CHAR_getPlayerMaxNum(); + char tzmsg[256]; + sprintf(tzmsg,"սȷ桹ϲҡ%s%s",CHAR_getChar(toindex,CHAR_NAME),msg); + for(k=0;k= (num-finditem) ){ + pilenum -= (num-finditem); + onenum += (num-finditem); + }else { + onenum = pilenum; + pilenum=0; + } + finditem += onenum; + + ITEM_setInt( itemindex, ITEM_USEPILENUMS, pilenum); + sprintf( token, "%d%s", onenum, ITEM_getChar( itemindex, ITEM_NAME)); + CHAR_talkToCli( toindex, -1, token, CHAR_COLORYELLOW); + if( pilenum <= 0 ){ + LogItem( + CHAR_getChar( toindex, CHAR_NAME ), + CHAR_getChar( toindex, CHAR_CDKEY ), +#ifdef _add_item_log_name // WON ADD itemlogitem + itemindex, +#else + ITEM_getInt( itemindex, ITEM_ID), +#endif + "ȡ", + CHAR_getInt( toindex,CHAR_FLOOR), + CHAR_getInt( toindex,CHAR_X ), + CHAR_getInt( toindex,CHAR_Y ), + ITEM_getChar( itemindex, ITEM_UNIQUECODE), + ITEM_getChar( itemindex, ITEM_NAME), + ITEM_getInt( itemindex, ITEM_ID) + + ); + + + CHAR_setItemIndex( toindex, i, -1); + ITEM_endExistItemsOne( itemindex); + } + CHAR_sendItemDataOne( toindex, i); + } + + if( finditem != num && num != -1 ) return FALSE; + return TRUE; +} + +BOOL NPC_ActionDelItem( int talker, char *buf) +{ + char buff3[128], buf2[32]; + int k=1, itemid, neednum; + if( !CHAR_CHECKINDEX( talker) ) return FALSE; + while( getStringFromIndexWithDelim(buf , "," , k++, buff3, sizeof(buff3)) !=FALSE ) { + neednum = 1; + if( getStringFromIndexWithDelim( buff3, "*", 1, buf2, sizeof(buf2)) == FALSE ) continue; + itemid = atoi( buf2); + if( getStringFromIndexWithDelim( buff3, "*", 2, buf2, sizeof(buf2)) == TRUE ){ + neednum = atoi( buf2); + if( NPC_ActionDoPileDelItem( talker, itemid, neednum) == FALSE ) return FALSE; + }else{ + NPC_ActionDoPileClearItem( talker, itemid); + } + } + return TRUE; +} +#else +BOOL NPC_ActionDelItem( int talker, char *buf) +{ + int i = 1, j = 1,k = 1; + char buff3[128]; + char buf2[32]; + int itemindex; + char token[256]; + + if( !CHAR_CHECKINDEX( talker) ) return FALSE; + while( getStringFromIndexWithDelim(buf , "," , k, buff3, sizeof(buff3)) !=FALSE ) { + k++; + if(strstr(buff3,"*")!=NULL){ + int itemno, kosuu=0, id, cnt=0; + struct _tagItemArray { + int index; + int itemindex; + }; + struct _tagItemArray ItemArray[20]; + for( i=0; i<20 ; i++){ + ItemArray[i].itemindex = -1; + ItemArray[i].index = -1; + } + //ȡִ + getStringFromIndexWithDelim(buff3,"*",1,buf2,sizeof(buf2)); + itemno = atoi(buf2); + getStringFromIndexWithDelim(buff3,"*",2,buf2,sizeof(buf2)); + kosuu = atoi(buf2); + //ȡ item index + for( i = CHAR_STARTITEMARRAY ; i < CHAR_MAXITEMHAVE ; i++ ){ + itemindex=CHAR_getItemIndex( talker , i ); + if( ITEM_CHECKINDEX(itemindex) ){ + id=ITEM_getInt(itemindex ,ITEM_ID ); + if(itemno==id){ + ItemArray[cnt].itemindex = itemindex; + ItemArray[cnt].index = i; + cnt++; + } + } + if(cnt == kosuu) + break; + } + if(cnt != kosuu){ + CHAR_talkToCli( talker, -1,"", CHAR_COLORYELLOW); + return FALSE; + } + //ȡƷ + for( i=0; i<20; i++) { + itemindex = ItemArray[i].itemindex; + if( !ITEM_CHECKINDEX(itemindex) ) break; + sprintf(token,"%s",ITEM_getChar( itemindex, ITEM_NAME)); + CHAR_talkToCli( talker, -1, token, CHAR_COLORYELLOW); + CHAR_setItemIndex( talker, ItemArray[i].index ,-1); + ITEM_endExistItemsOne( itemindex); + CHAR_sendItemDataOne( talker, ItemArray[i].index); + LogItem( + CHAR_getChar( talker, CHAR_NAME ), CHAR_getChar( talker, CHAR_CDKEY ), +#ifdef _add_item_log_name // WON ADD itemlogitem + itemindex, +#else + ITEM_getInt( itemindex, ITEM_ID), +#endif + "WarpManDelItem", + CHAR_getInt( talker, CHAR_FLOOR), CHAR_getInt( talker, CHAR_X ), + CHAR_getInt( talker, CHAR_Y ), ITEM_getChar( itemindex, ITEM_UNIQUECODE), + ITEM_getChar( itemindex, ITEM_NAME), + ITEM_getInt( itemindex, ITEM_ID) + ); + } + }else{ + for( j = CHAR_STARTITEMARRAY ; j < CHAR_MAXITEMHAVE ; j++){ + itemindex = CHAR_getItemIndex( talker ,j); + if( ITEM_CHECKINDEX(itemindex) ){ + if( atoi( buff3) == ITEM_getInt(itemindex,ITEM_ID)){ + LogItem( + CHAR_getChar( talker, CHAR_NAME ), + CHAR_getChar( talker, CHAR_CDKEY ), +#ifdef _add_item_log_name // WON ADD itemlogitem + itemindex, +#else + ITEM_getInt( itemindex, ITEM_ID), +#endif + "WarpManDelItem", + CHAR_getInt( talker,CHAR_FLOOR), + CHAR_getInt( talker,CHAR_X ), + CHAR_getInt( talker,CHAR_Y ), + ITEM_getChar( itemindex, ITEM_UNIQUECODE), + ITEM_getChar( itemindex, ITEM_NAME), + ITEM_getInt( itemindex, ITEM_ID) + + ); + sprintf( token, "%s", + ITEM_getChar( itemindex, ITEM_NAME)); + CHAR_talkToCli( talker, -1, token, CHAR_COLORYELLOW); + CHAR_DelItem( talker, j); + } + } + } + } + } + return TRUE; +} +#endif + +#ifdef _VIP_SHOP +BOOL NPC_ActionVipItem( int talker, char *buf) +{ + if (CHAR_getWorkInt( talker, CHAR_WORKSAFEMODE)==0) + { + CHAR_SafePassword(talker); + return FALSE; + } + int itemID,itemindex=-1; + int pVipPoint, VipPoints; + char buff[256], token[256]; + int ret; + + if(getStringFromIndexWithDelim(buf , "," , 1, buff, sizeof(buff)) !=FALSE) + itemID = atoi(buf); + + itemindex = CHAR_findEmptyItemBox( talker ); + if( itemindex < 0 ) { + CHAR_talkToCli( talker, -1, "Ʒռ䲻㣡", CHAR_COLORYELLOW); + return FALSE; + } + + if(getStringFromIndexWithDelim(buf , "," , 2, buff, sizeof(buff)) !=FALSE) + VipPoints=atoi(buff); + if(VipPoints<0)VipPoints=0; + + pVipPoint = sasql_ampoint( CHAR_getChar(talker,CHAR_CDKEY), 0,0); + if( pVipPoint < VipPoints ) { + CHAR_talkToCli( talker, -1, "ĻֲŶ", CHAR_COLORYELLOW); + return FALSE; + } + + itemindex = ITEM_makeItemAndRegist( itemID ); + if( itemindex != -1 ){ + ret = CHAR_addItemSpecificItemIndex( talker, itemindex); + if( ret < 0 || ret >= CHAR_MAXITEMHAVE ) { + ITEM_endExistItemsOne( itemindex); + print ("\n ret error!!"); + return FALSE; + } + + sprintf( token,"õ%s",ITEM_getChar( itemindex, ITEM_NAME)); + CHAR_talkToCli( talker, -1, token, CHAR_COLORYELLOW ); + + sasql_ampoint( CHAR_getChar(talker,CHAR_CDKEY), -VipPoints,1); + sprintf( token, "۳%d", VipPoints); + CHAR_talkToCli( talker, -1, token, CHAR_COLORYELLOW); + + CHAR_sendItemDataOne( talker, ret); + } + + return TRUE; +} + +BOOL NPC_ActionVipPet( int talker, char *buf) +{ + if (CHAR_getWorkInt( talker, CHAR_WORKSAFEMODE)==0) + { + CHAR_SafePassword(talker); + return FALSE; + } + int ret; + char msgbuf[64], buf1[8], buf2[10]; + int enemynum; + int i,j; + int petindex, petindex2, petid; + int pVipPoint, VipPoints; + + if(getStringFromIndexWithDelim(buf , "," , 1, buf1, sizeof(buf1)) !=FALSE) +#ifdef _PET_MM + if(strstr(buf1,"MM1") || strstr(buf1,"MM3")) + petid = 1479; + else if(strstr(buf1,"MM2") || strstr(buf1,"MM4")) + petid = 2547; + else + petid = atoi( buf1 ); +#else + petid = atoi( buf1 ); +#endif + + if(getStringFromIndexWithDelim(buf , "," , 2, buf2, sizeof(buf2)) !=FALSE) + VipPoints=atoi(buf2); + if(VipPoints<0)VipPoints=0; + + pVipPoint = sasql_ampoint( CHAR_getChar(talker,CHAR_CDKEY), 0,0); + if( pVipPoint < VipPoints ) { + CHAR_talkToCli( talker, -1, "ĻֲŶ", CHAR_COLORYELLOW); + return FALSE; + } + + for( i = 0 ;i < CHAR_MAXPETHAVE ; i++) { + petindex = CHAR_getCharPet( talker, i); + if( petindex == -1 ) + break; + } + + if( i == CHAR_MAXPETHAVE ) { + snprintf( msgbuf,sizeof( msgbuf), ""); + CHAR_talkToCli( talker, -1, msgbuf, CHAR_COLORYELLOW); + return FALSE; + } + + enemynum = ENEMY_getEnemyNum(); + for( i = 0; i < enemynum; i ++ ) { + if( ENEMY_getInt( i, ENEMY_ID) == petid) { + break; + } + } + + if( i == enemynum ) + return FALSE; + + ret = ENEMY_createPetFromEnemyIndex( talker, i); + for( i = 0; i < CHAR_MAXPETHAVE; i ++ ) { + if( CHAR_getCharPet( talker, i ) == ret ) + break; + } + if( i == CHAR_MAXPETHAVE ) + CHAR_talkToCli( talker, -1, "ȡʧܣ", CHAR_COLORYELLOW); + + if( CHAR_CHECKINDEX( ret ) == TRUE ){ +#ifdef _PET_MM + if(strstr(buf1,"MM1") || strstr(buf1,"MM2")){ + int LevelUpPoint; + LevelUpPoint = ( 50<< 24) + ( 50<< 16) + ( 50<< 8) + ( 50<< 0); + CHAR_setInt( ret, CHAR_ALLOCPOINT, LevelUpPoint); + }else if(strstr(buf1,"MM3") || strstr(buf1,"MM4")){ + while(CHAR_getInt( ret, CHAR_LV)<79){ // + int LevelUpPoint; + LevelUpPoint = ( 50<< 24) + ( 50<< 16) + ( 50<< 8) + ( 50<< 0); + CHAR_setInt( ret, CHAR_ALLOCPOINT, LevelUpPoint); + CHAR_PetLevelUp( ret ); + CHAR_PetAddVariableAi( ret, AI_FIX_PETLEVELUP ); + CHAR_setInt( ret, CHAR_LV, CHAR_getInt( ret, CHAR_LV) +1 ); + } + } +#endif + CHAR_setInt( ret, CHAR_HP, CHAR_getWorkInt( ret, CHAR_WORKMAXHP )); + CHAR_setMaxExpFromLevel( ret, CHAR_getInt( ret, CHAR_LV )); + CHAR_setInt(ret,CHAR_VARIABLEAI,10000); + } + + petindex2 = CHAR_getCharPet(talker, i); + if( !CHAR_CHECKINDEX( petindex2) ) + return FALSE; + snprintf( msgbuf,sizeof( msgbuf), "õ%s", CHAR_getChar(petindex2,CHAR_NAME)); + CHAR_talkToCli( talker, -1, msgbuf, CHAR_COLORYELLOW); + sasql_ampoint( CHAR_getChar(talker,CHAR_CDKEY), -VipPoints,1); + snprintf( msgbuf,sizeof( msgbuf), "۳%d", VipPoints); + CHAR_talkToCli( talker, -1, msgbuf, CHAR_COLORYELLOW); + for(j = 0; j < CHAR_MAXPETHAVE; j++){ + petindex = CHAR_getCharPet(talker, j); + if( !CHAR_CHECKINDEX( petindex) ) + continue; + CHAR_complianceParameter( petindex ); + snprintf( msgbuf, sizeof( msgbuf ), "K%d", j ); + CHAR_sendStatusString( talker, msgbuf ); + snprintf( msgbuf, sizeof( msgbuf ), "W%d", j ); + CHAR_sendStatusString( talker, msgbuf ); + } + return TRUE; +} +#endif + +#ifdef _VIP_SHOP +BOOL NPC_ActionNewVipItem( int talker, char *buf) +{ + if (CHAR_getWorkInt( talker, CHAR_WORKSAFEMODE)==0) + { + CHAR_SafePassword(talker); + return FALSE; + } + int itemID,itemindex=-1; + int pVipPoint, VipPoints, zhe; + char buff[256], token[256]; + int ret; + int fd = getfdFromCharaIndex( talker); + char* id = CHAR_getChar(talker, CHAR_CDKEY); + if(getStringFromIndexWithDelim(buf , "," , 1, buff, sizeof(buff)) !=FALSE) + itemID = atoi(buf); + + itemindex = CHAR_findEmptyItemBox( talker ); + if( itemindex < 0 ) { + CHAR_talkToCli( talker, -1, "Ʒռ䲻㣡", CHAR_COLORYELLOW); + return FALSE; + } + + if(getStringFromIndexWithDelim(buf , "," , 2, buff, sizeof(buff)) !=FALSE) + VipPoints=atoi(buff); + if(VipPoints<0)VipPoints=0; + + pVipPoint = sasql_vippoint(id,0,0); + if( pVipPoint < VipPoints ) { + CHAR_talkToCli( talker, -1, "ϵĵŶ", CHAR_COLORYELLOW); + return FALSE; + } + + itemindex = ITEM_makeItemAndRegist( itemID ); + if( itemindex != -1 ){ + ret = CHAR_addItemSpecificItemIndex( talker, itemindex); + if( ret < 0 || ret >= CHAR_MAXITEMHAVE ) { + ITEM_endExistItemsOne( itemindex); + print ("\n ret error!!"); + return FALSE; + } + sprintf( token,"õ%s",ITEM_getChar( itemindex, ITEM_NAME)); + CHAR_talkToCli( talker, -1, token, CHAR_COLORYELLOW ); + + sasql_vippoint(id,-VipPoints,1); + + sprintf( token, "۳Ա%d", VipPoints); + CHAR_talkToCli( talker, -1, token, CHAR_COLORYELLOW); + CHAR_sendItemDataOne( talker, ret); + CHAR_charSaveFromConnect(talker, FALSE); + CHAR_talkToCli(talker, -1, "ϵͳΪԶ浵", CHAR_COLORRED); + } + + return TRUE; +} + +BOOL NPC_ActionNewVipPet( int talker, char *buf) +{ + if (CHAR_getWorkInt( talker, CHAR_WORKSAFEMODE)==0) + { + CHAR_SafePassword(talker); + return FALSE; + } + int ret; + char msgbuf[64], buf1[8], buf2[10]; + int enemynum; + int i,j; + int petindex, petindex2, petid; + int pVipPoint, VipPoints, zhe; + int fd = getfdFromCharaIndex( talker); + char* id = CHAR_getChar(talker, CHAR_CDKEY); + if(getStringFromIndexWithDelim(buf , "," , 1, buf1, sizeof(buf1)) !=FALSE) +#ifdef _PET_MM + if(strstr(buf1,"MM1") || strstr(buf1,"MM3")) + petid = 1479; + else if(strstr(buf1,"MM2") || strstr(buf1,"MM4")) + petid = 2547; + else + petid = atoi( buf1 ); +#else + petid = atoi( buf1 ); +#endif + + if(getStringFromIndexWithDelim(buf , "," , 2, buf2, sizeof(buf2)) !=FALSE) + VipPoints=atoi(buf2); + if(VipPoints<0)VipPoints=0; + + pVipPoint = sasql_vippoint(id,0,0); + if( pVipPoint < VipPoints ) { + CHAR_talkToCli( talker, -1, "ϵĵŶ", CHAR_COLORYELLOW); + return FALSE; + } + + for( i = 0 ;i < CHAR_MAXPETHAVE ; i++) { + petindex = CHAR_getCharPet( talker, i); + if( petindex == -1 ) + break; + } + + if( i == CHAR_MAXPETHAVE ) { + snprintf( msgbuf,sizeof( msgbuf), ""); + CHAR_talkToCli( talker, -1, msgbuf, CHAR_COLORYELLOW); + return FALSE; + } + + enemynum = ENEMY_getEnemyNum(); + for( i = 0; i < enemynum; i ++ ) { + if( ENEMY_getInt( i, ENEMY_ID) == petid) { + break; + } + } + + if( i == enemynum ) + return FALSE; + + ret = ENEMY_createPetFromEnemyIndex( talker, i); + for( i = 0; i < CHAR_MAXPETHAVE; i ++ ) { + if( CHAR_getCharPet( talker, i ) == ret ) + break; + } + if( i == CHAR_MAXPETHAVE ) + CHAR_talkToCli( talker, -1, "ȡʧܣ", CHAR_COLORYELLOW); + + if( CHAR_CHECKINDEX( ret ) == TRUE ){ +#ifdef _PET_MM + if(strstr(buf1,"MM1") || strstr(buf1,"MM2")){ + int LevelUpPoint; + LevelUpPoint = ( 50<< 24) + ( 50<< 16) + ( 50<< 8) + ( 50<< 0); + CHAR_setInt( ret, CHAR_ALLOCPOINT, LevelUpPoint); + }else if(strstr(buf1,"MM3") || strstr(buf1,"MM4")){ + while(CHAR_getInt( ret, CHAR_LV)<79){ // + int LevelUpPoint; + LevelUpPoint = ( 50<< 24) + ( 50<< 16) + ( 50<< 8) + ( 50<< 0); + CHAR_setInt( ret, CHAR_ALLOCPOINT, LevelUpPoint); + CHAR_PetLevelUp( ret ); + CHAR_PetAddVariableAi( ret, AI_FIX_PETLEVELUP ); + CHAR_setInt( ret, CHAR_LV, CHAR_getInt( ret, CHAR_LV) +1 ); + } + } +#endif + CHAR_setInt( ret, CHAR_HP, CHAR_getWorkInt( ret, CHAR_WORKMAXHP )); + CHAR_setMaxExpFromLevel( ret, CHAR_getInt( ret, CHAR_LV )); + CHAR_setInt(ret,CHAR_VARIABLEAI,10000); + } + + petindex2 = CHAR_getCharPet(talker, i); + if( !CHAR_CHECKINDEX( petindex2) ) + return FALSE; + snprintf( msgbuf,sizeof( msgbuf), "õ%s", CHAR_getChar(petindex2,CHAR_NAME)); + CHAR_talkToCli( talker, -1, msgbuf, CHAR_COLORYELLOW); + sasql_vippoint(id,-VipPoints,1); + snprintf( msgbuf,sizeof( msgbuf), "۳Ա%d", VipPoints); + CHAR_talkToCli( talker, -1, msgbuf, CHAR_COLORYELLOW); + for(j = 0; j < CHAR_MAXPETHAVE; j++){ + petindex = CHAR_getCharPet(talker, j); + if( !CHAR_CHECKINDEX( petindex) ) + continue; + CHAR_complianceParameter( petindex ); + snprintf( msgbuf, sizeof( msgbuf ), "K%d", j ); + CHAR_sendStatusString( talker, msgbuf ); + snprintf( msgbuf, sizeof( msgbuf ), "W%d", j ); + CHAR_sendStatusString( talker, msgbuf ); + } + CHAR_charSaveFromConnect(talker, FALSE); + CHAR_talkToCli(talker, -1, "ϵͳΪԶ浵", CHAR_COLORRED); + return TRUE; +} +#endif + +BOOL NPC_ActionNewVipAbiPet( int talker, char *buf) +{ + if (CHAR_getWorkInt( talker, CHAR_WORKSAFEMODE)==0) + { + CHAR_SafePassword(talker); + return FALSE; + } + int ret; + char msgbuf[64], buf1[10], buf2[10]; + int enemynum; + int vital,str,tough,dex,petlevel,pettrans; + int i,j; + int petindex, petindex2, petid; + int pVipPoint, VipPoints; + int fd = getfdFromCharaIndex( talker); + char* id = CHAR_getChar(talker, CHAR_CDKEY); + + easyGetTokenFromString( buf , 1 , buf1, sizeof(buf1)); + petid=atoi(buf1); + easyGetTokenFromString( buf , 2 , buf1, sizeof(buf1)); + vital=atoi(buf1); + easyGetTokenFromString( buf , 3 , buf1, sizeof(buf1)); + str=atoi(buf1); + easyGetTokenFromString( buf , 4 , buf1, sizeof(buf1)); + tough=atoi(buf1); + easyGetTokenFromString( buf , 5 , buf1, sizeof(buf1)); + dex=atoi(buf1); + easyGetTokenFromString( buf , 6 , buf1, sizeof(buf1)); + petlevel=atoi(buf1); + easyGetTokenFromString( buf , 7 , buf1, sizeof(buf1)); + pettrans=atoi(buf1); + + if( petlevel != -1 ){ +#ifdef _TRANS_LEVEL_CF + if( petlevel > getMaxLevel() ) petlevel = getMaxLevel(); +#else + if( petlevel > 140 ) level = 140; +#endif + if( petlevel <= 0 ) petlevel = 1; +} + else{ + petlevel = 1; +} + if(pettrans>2){ + pettrans=2; + } + if(pettrans<0){ + pettrans=0; + } + + if(getStringFromIndexWithDelim(buf , "," , 2, buf2, sizeof(buf2)) !=FALSE) + VipPoints=atoi(buf2); + if(VipPoints<0)VipPoints=0; + + pVipPoint = sasql_vippoint(id,0,0); + if( pVipPoint < VipPoints ) { + CHAR_talkToCli( talker, -1, "ϵĵŶ", CHAR_COLORYELLOW); + return FALSE; + } + + for( i = 0 ;i < CHAR_MAXPETHAVE ; i++) { + petindex = CHAR_getCharPet( talker, i); + if( petindex == -1 ) + break; + } + + if( i == CHAR_MAXPETHAVE ) { + snprintf( msgbuf,sizeof( msgbuf), ""); + CHAR_talkToCli( talker, -1, msgbuf, CHAR_COLORYELLOW); + return FALSE; + } + + enemynum = ENEMY_getEnemyNum(); + for( i = 0; i < enemynum; i ++ ) { + if( ENEMY_getInt( i, ENEMY_ID) == petid) { + break; + } + } + + if( i == enemynum ) + return FALSE; + + ret = ENEMY_createPetFromEnemyIndex( talker, i); + for( i = 0; i < CHAR_MAXPETHAVE; i ++ ) { + if( CHAR_getCharPet( talker, i ) == ret ) + break; + } + if( i == CHAR_MAXPETHAVE ) + CHAR_talkToCli( talker, -1, "ȡʧܣ", CHAR_COLORYELLOW); + + if( CHAR_CHECKINDEX( ret ) == TRUE ){ + CHAR_setInt( ret, CHAR_VITAL, vital); + CHAR_setInt( ret, CHAR_STR, str*80); + CHAR_setInt( ret, CHAR_TOUGH, tough*80); + CHAR_setInt( ret, CHAR_DEX, dex*100); + CHAR_setMaxExpFromLevel( ret, CHAR_getInt( ret, CHAR_LV )); + CHAR_setInt( ret, CHAR_HP, CHAR_getWorkInt( ret, CHAR_WORKMAXHP )); + CHAR_setMaxExpFromLevel( ret, CHAR_getInt( ret, CHAR_LV )); + CHAR_setInt(ret,CHAR_VARIABLEAI,10000); + CHAR_setInt( ret, CHAR_LV, petlevel); + CHAR_setInt( ret, CHAR_TRANSMIGRATION, pettrans); + } + + petindex2 = CHAR_getCharPet(talker, i); + if( !CHAR_CHECKINDEX( petindex2) ) + return FALSE; + snprintf( msgbuf,sizeof( msgbuf), "õ%s", CHAR_getChar(petindex2,CHAR_NAME)); + sasql_vippoint(id,-VipPoints,1); + CHAR_talkToCli( talker, -1, msgbuf, CHAR_COLORYELLOW); + snprintf( msgbuf,sizeof( msgbuf), "۳Ա%d", VipPoints); + CHAR_talkToCli( talker, -1, msgbuf, CHAR_COLORYELLOW); + for(j = 0; j < CHAR_MAXPETHAVE; j++){ + petindex = CHAR_getCharPet(talker, j); + if( !CHAR_CHECKINDEX( petindex) ) + continue; + CHAR_complianceParameter( petindex ); + snprintf( msgbuf, sizeof( msgbuf ), "K%d", j ); + CHAR_sendStatusString( talker, msgbuf ); + snprintf( msgbuf, sizeof( msgbuf ), "W%d", j ); + CHAR_sendStatusString( talker, msgbuf ); + } + CHAR_charSaveFromConnect(talker, FALSE); + CHAR_talkToCli(talker, -1, "ϵͳΪԶ浵", CHAR_COLORRED); + return TRUE; +} + +#ifdef _STU_SYS +BOOL NPC_ActionStuItem( int talker, char *buf) +{ + if (CHAR_getWorkInt( talker, CHAR_WORKSAFEMODE)==0) + { + CHAR_SafePassword(talker); + return FALSE; + } + int itemID,itemindex=-1; + int pStuPoint, StuPoints; + char buff[256], token[256]; + int ret; + + if(getStringFromIndexWithDelim(buf , "," , 1, buff, sizeof(buff)) !=FALSE) + itemID = atoi(buf); + + itemindex = CHAR_findEmptyItemBox( talker ); + if( itemindex < 0 ) { + CHAR_talkToCli( talker, -1, "Ʒռ䲻㣡", CHAR_COLORYELLOW); + return FALSE; + } + + if(getStringFromIndexWithDelim(buf , "," , 2, buff, sizeof(buff)) !=FALSE) + StuPoints=atoi(buff); + if(StuPoints<0)StuPoints=0; + + pStuPoint = CHAR_getInt( talker, CHAR_STUNUM); + if( pStuPoint < StuPoints ) { + CHAR_talkToCli( talker, -1, "ͽŶ", CHAR_COLORYELLOW); + return FALSE; + } + + itemindex = ITEM_makeItemAndRegist( itemID ); + if( itemindex != -1 ){ + ret = CHAR_addItemSpecificItemIndex( talker, itemindex); + if( ret < 0 || ret >= CHAR_MAXITEMHAVE ) { + ITEM_endExistItemsOne( itemindex); + print ("\n ret error!!"); + return FALSE; + } + + sprintf( token,"õ%s",ITEM_getChar( itemindex, ITEM_NAME)); + CHAR_talkToCli( talker, -1, token, CHAR_COLORYELLOW ); + + CHAR_setInt( talker, CHAR_STUNUM, pStuPoint-StuPoints); + sprintf( token, "۳ͽ%d", StuPoints); + CHAR_talkToCli( talker, -1, token, CHAR_COLORYELLOW); + + CHAR_sendItemDataOne( talker, ret); + } + + return TRUE; +} + +BOOL NPC_ActionStuPet( int talker, char *buf) +{ + if (CHAR_getWorkInt( talker, CHAR_WORKSAFEMODE)==0) + { + CHAR_SafePassword(talker); + return FALSE; + } + int ret; + char msgbuf[64], buf1[8], buf2[10]; + int enemynum; + int i,j; + int petindex, petindex2, petid; + int pStuPoint, StuPoints; + + if(getStringFromIndexWithDelim(buf , "," , 1, buf1, sizeof(buf1)) !=FALSE) +#ifdef _PET_MM + if(strstr(buf1,"MM1") || strstr(buf1,"MM3")) + petid = 1479; + else if(strstr(buf1,"MM2") || strstr(buf1,"MM4")) + petid = 2547; + else + petid = atoi( buf1 ); +#else + petid = atoi( buf1 ); +#endif + + if(getStringFromIndexWithDelim(buf , "," , 2, buf2, sizeof(buf2)) !=FALSE) + StuPoints=atoi(buf2); + if(StuPoints<0)StuPoints=0; + + pStuPoint = CHAR_getInt( talker, CHAR_STUNUM); + if( pStuPoint < StuPoints ) { + CHAR_talkToCli( talker, -1, "ͽŶ", CHAR_COLORYELLOW); + return FALSE; + } + + for( i = 0 ;i < CHAR_MAXPETHAVE ; i++) { + petindex = CHAR_getCharPet( talker, i); + if( petindex == -1 ) + break; + } + + if( i == CHAR_MAXPETHAVE ) { + snprintf( msgbuf,sizeof( msgbuf), ""); + CHAR_talkToCli( talker, -1, msgbuf, CHAR_COLORYELLOW); + return FALSE; + } + + enemynum = ENEMY_getEnemyNum(); + for( i = 0; i < enemynum; i ++ ) { + if( ENEMY_getInt( i, ENEMY_ID) == petid) { + break; + } + } + + if( i == enemynum ) + return FALSE; + + ret = ENEMY_createPetFromEnemyIndex( talker, i); + for( i = 0; i < CHAR_MAXPETHAVE; i ++ ) { + if( CHAR_getCharPet( talker, i ) == ret ) + break; + } + if( i == CHAR_MAXPETHAVE ) + CHAR_talkToCli( talker, -1, "ȡʧܣ", CHAR_COLORYELLOW); + + if( CHAR_CHECKINDEX( ret ) == TRUE ){ +#ifdef _PET_MM + if(strstr(buf1,"MM1") || strstr(buf1,"MM2")){ + int LevelUpPoint; + LevelUpPoint = ( 50<< 24) + ( 50<< 16) + ( 50<< 8) + ( 50<< 0); + CHAR_setInt( ret, CHAR_ALLOCPOINT, LevelUpPoint); + }else if(strstr(buf1,"MM3") || strstr(buf1,"MM4")){ + while(CHAR_getInt( ret, CHAR_LV)<79){ // + int LevelUpPoint; + LevelUpPoint = ( 50<< 24) + ( 50<< 16) + ( 50<< 8) + ( 50<< 0); + CHAR_setInt( ret, CHAR_ALLOCPOINT, LevelUpPoint); + CHAR_PetLevelUp( ret ); + CHAR_PetAddVariableAi( ret, AI_FIX_PETLEVELUP ); + CHAR_setInt( ret, CHAR_LV, CHAR_getInt( ret, CHAR_LV) +1 ); + } + } +#endif + CHAR_setInt( ret, CHAR_HP, CHAR_getWorkInt( ret, CHAR_WORKMAXHP )); + CHAR_setMaxExpFromLevel( ret, CHAR_getInt( ret, CHAR_LV )); + CHAR_setInt(ret,CHAR_VARIABLEAI,10000); + } + + petindex2 = CHAR_getCharPet(talker, i); + if( !CHAR_CHECKINDEX( petindex2) ) + return FALSE; + snprintf( msgbuf,sizeof( msgbuf), "õ%s", CHAR_getChar(petindex2,CHAR_NAME)); + CHAR_talkToCli( talker, -1, msgbuf, CHAR_COLORYELLOW); + CHAR_setInt( talker, CHAR_STUNUM, pStuPoint-StuPoints); + snprintf( msgbuf,sizeof( msgbuf), "۳ͽ%d", StuPoints); + CHAR_talkToCli( talker, -1, msgbuf, CHAR_COLORYELLOW); + for(j = 0; j < CHAR_MAXPETHAVE; j++){ + petindex = CHAR_getCharPet(talker, j); + if( !CHAR_CHECKINDEX( petindex) ) + continue; + CHAR_complianceParameter( petindex ); + snprintf( msgbuf, sizeof( msgbuf ), "K%d", j ); + CHAR_sendStatusString( talker, msgbuf ); + snprintf( msgbuf, sizeof( msgbuf ), "W%d", j ); + CHAR_sendStatusString( talker, msgbuf ); + } + return TRUE; +} +#endif + +#ifdef _RMB_SYSTEM +BOOL NPC_ActionRmbPoint( int talker, char *buf) +{ + if (CHAR_getWorkInt( talker, CHAR_WORKSAFEMODE)==0) + { + CHAR_SafePassword(talker); + return FALSE; + } + int pRmbPoint, RmbPoints; + char buff[256], token[256]; + int point_num=0; + + if(getStringFromIndexWithDelim(buf , "," , 1, buff, sizeof(buff)) !=FALSE) + point_num = atoi(buf); + + if(point_num<0) return FALSE; + + if(getStringFromIndexWithDelim(buf , "," , 2, buff, sizeof(buff)) !=FALSE) + RmbPoints=atoi(buff); + if(RmbPoints<0)RmbPoints=0; + + pRmbPoint = sasql_rmbpoint( CHAR_getChar(talker,CHAR_CDKEY), 0,0); + if( pRmbPoint < RmbPoints ) { + CHAR_talkToCli( talker, -1, "ֽ𲻹Ŷ", CHAR_COLORYELLOW); + return FALSE; + } + + sasql_vippoint( CHAR_getChar(talker,CHAR_CDKEY), point_num,1); + + sprintf( token,"%dԱ",point_num); + CHAR_talkToCli( talker, -1, token, CHAR_COLORYELLOW ); + + sasql_rmbpoint( CHAR_getChar(talker,CHAR_CDKEY), -RmbPoints,1); + sprintf( token, "۳ֽ%d", RmbPoints); + CHAR_talkToCli( talker, -1, token, CHAR_COLORYELLOW); + + return TRUE; +} + +BOOL NPC_ActionRmbItem( int talker, char *buf) +{ + if (CHAR_getWorkInt( talker, CHAR_WORKSAFEMODE)==0) + { + CHAR_SafePassword(talker); + return FALSE; + } + int itemID,itemindex=-1; + int pRmbPoint, RmbPoints; + char buff[256], token[256]; + int ret; + + if(getStringFromIndexWithDelim(buf , "," , 1, buff, sizeof(buff)) !=FALSE) + itemID = atoi(buf); + + itemindex = CHAR_findEmptyItemBox( talker ); + if( itemindex < 0 ) { + CHAR_talkToCli( talker, -1, "Ʒռ䲻㣡", CHAR_COLORYELLOW); + return FALSE; + } + + if(getStringFromIndexWithDelim(buf , "," , 2, buff, sizeof(buff)) !=FALSE) + RmbPoints=atoi(buff); + if(RmbPoints<0)RmbPoints=0; + + pRmbPoint = sasql_rmbpoint( CHAR_getChar(talker,CHAR_CDKEY), 0,0); + if( pRmbPoint < RmbPoints ) { + CHAR_talkToCli( talker, -1, "ֽ𲻹Ŷ", CHAR_COLORYELLOW); + return FALSE; + } + + itemindex = ITEM_makeItemAndRegist( itemID ); + if( itemindex != -1 ){ + ret = CHAR_addItemSpecificItemIndex( talker, itemindex); + if( ret < 0 || ret >= CHAR_MAXITEMHAVE ) { + ITEM_endExistItemsOne( itemindex); + print ("\n ret error!!"); + return FALSE; + } + + sprintf( token,"õ%s",ITEM_getChar( itemindex, ITEM_NAME)); + CHAR_talkToCli( talker, -1, token, CHAR_COLORYELLOW ); + + sasql_rmbpoint( CHAR_getChar(talker,CHAR_CDKEY), -RmbPoints,1); + sprintf( token, "۳ֽ%d", RmbPoints); + CHAR_talkToCli( talker, -1, token, CHAR_COLORYELLOW); + + CHAR_sendItemDataOne( talker, ret); + } + + return TRUE; +} + +BOOL NPC_ActionRmbPet( int talker, char *buf) +{ + if (CHAR_getWorkInt( talker, CHAR_WORKSAFEMODE)==0) + { + CHAR_SafePassword(talker); + return FALSE; + } + int ret; + char msgbuf[64], buf1[8], buf2[10]; + int enemynum; + int i,j; + int petindex, petindex2, petid; + int pRmbPoint, RmbPoints; + + if(getStringFromIndexWithDelim(buf , "," , 1, buf1, sizeof(buf1)) !=FALSE) +#ifdef _PET_MM + if(strstr(buf1,"MM1") || strstr(buf1,"MM3")) + petid = 1479; + else if(strstr(buf1,"MM2") || strstr(buf1,"MM4")) + petid = 2547; + else + petid = atoi( buf1 ); +#else + petid = atoi( buf1 ); +#endif + + if(getStringFromIndexWithDelim(buf , "," , 2, buf2, sizeof(buf2)) !=FALSE) + RmbPoints=atoi(buf2); + if(RmbPoints<0)RmbPoints=0; + + pRmbPoint = sasql_rmbpoint( CHAR_getChar(talker,CHAR_CDKEY), 0,0); + if( pRmbPoint < RmbPoints ) { + CHAR_talkToCli( talker, -1, "ֽ𲻹Ŷ", CHAR_COLORYELLOW); + return FALSE; + } + + for( i = 0 ;i < CHAR_MAXPETHAVE ; i++) { + petindex = CHAR_getCharPet( talker, i); + if( petindex == -1 ) + break; + } + + if( i == CHAR_MAXPETHAVE ) { + snprintf( msgbuf,sizeof( msgbuf), ""); + CHAR_talkToCli( talker, -1, msgbuf, CHAR_COLORYELLOW); + return FALSE; + } + + enemynum = ENEMY_getEnemyNum(); + for( i = 0; i < enemynum; i ++ ) { + if( ENEMY_getInt( i, ENEMY_ID) == petid) { + break; + } + } + + if( i == enemynum ) + return FALSE; + + ret = ENEMY_createPetFromEnemyIndex( talker, i); + for( i = 0; i < CHAR_MAXPETHAVE; i ++ ) { + if( CHAR_getCharPet( talker, i ) == ret ) + break; + } + if( i == CHAR_MAXPETHAVE ) + CHAR_talkToCli( talker, -1, "ȡʧܣ", CHAR_COLORYELLOW); + + if( CHAR_CHECKINDEX( ret ) == TRUE ){ +#ifdef _PET_MM + if(strstr(buf1,"MM1") || strstr(buf1,"MM2")){ + int LevelUpPoint; + LevelUpPoint = ( 50<< 24) + ( 50<< 16) + ( 50<< 8) + ( 50<< 0); + CHAR_setInt( ret, CHAR_ALLOCPOINT, LevelUpPoint); + }else if(strstr(buf1,"MM3") || strstr(buf1,"MM4")){ + while(CHAR_getInt( ret, CHAR_LV)<79){ // + int LevelUpPoint; + LevelUpPoint = ( 50<< 24) + ( 50<< 16) + ( 50<< 8) + ( 50<< 0); + CHAR_setInt( ret, CHAR_ALLOCPOINT, LevelUpPoint); + CHAR_PetLevelUp( ret ); + CHAR_PetAddVariableAi( ret, AI_FIX_PETLEVELUP ); + CHAR_setInt( ret, CHAR_LV, CHAR_getInt( ret, CHAR_LV) +1 ); + } + } +#endif + CHAR_setInt( ret, CHAR_HP, CHAR_getWorkInt( ret, CHAR_WORKMAXHP )); + CHAR_setMaxExpFromLevel( ret, CHAR_getInt( ret, CHAR_LV )); + CHAR_setInt(ret,CHAR_VARIABLEAI,10000); + } + + petindex2 = CHAR_getCharPet(talker, i); + if( !CHAR_CHECKINDEX( petindex2) ) + return FALSE; + snprintf( msgbuf,sizeof( msgbuf), "õ%s", CHAR_getChar(petindex2,CHAR_NAME)); + CHAR_talkToCli( talker, -1, msgbuf, CHAR_COLORYELLOW); + sasql_rmbpoint( CHAR_getChar(talker,CHAR_CDKEY), -RmbPoints,1); + snprintf( msgbuf,sizeof( msgbuf), "۳ֽ%d", RmbPoints); + CHAR_talkToCli( talker, -1, msgbuf, CHAR_COLORYELLOW); + for(j = 0; j < CHAR_MAXPETHAVE; j++){ + petindex = CHAR_getCharPet(talker, j); + if( !CHAR_CHECKINDEX( petindex) ) + continue; + CHAR_complianceParameter( petindex ); + snprintf( msgbuf, sizeof( msgbuf ), "K%d", j ); + CHAR_sendStatusString( talker, msgbuf ); + snprintf( msgbuf, sizeof( msgbuf ), "W%d", j ); + CHAR_sendStatusString( talker, msgbuf ); + } + return TRUE; +} +#endif + +#ifdef _TRANS_7_NPC +BOOL NPC_ActionTrans7( int talker, char *buf) +{ + char token[128]; + int work[10]; + int Trans=CHAR_getInt(talker,CHAR_TRANSMIGRATION)+1; +#ifdef _ADD_POOL_ITEM // WON ADD ӿɼķŵĵ + int tran_pool_item[5] = { 4, 4, 4, 4, 4 }; // ӵĵ߼ķ + int tran_pool_pet[5] = { 2, 2, 2, 2, 2}; // ӵijķ + int j,item_sum=0, pet_sum=0; + + if(Trans>7 || CHAR_getInt(talker,CHAR_LV)<80){ + sprintf( token, "תȼС80תʧ!", CHAR_getChar( talker, CHAR_NAME)); + CHAR_talkToCli( talker, -1, token, CHAR_COLORYELLOW ); + return; + } + + for(j=0; j<5 ;j++){ + item_sum += tran_pool_item[j] ; + pet_sum += tran_pool_pet[j]; + } + + item_sum += 10; // ļĵ + pet_sum += 5; // ļij + +#endif + NPC_TransmigrationStatus(talker, talker, work); + NPC_TransmigrationFlg_CLS(talker, talker); + CHAR_setInt(talker ,CHAR_TRANSMIGRATION, Trans); + CHAR_setInt(talker, CHAR_LV ,1); + CHAR_setMaxExp( talker, 0); + CHAR_setInt( talker,CHAR_SKILLUPPOINT,CHAR_getInt( talker, CHAR_TRANSMIGRATION)*10); + CHAR_Skillupsend( talker ); + CHAR_setInt( talker,CHAR_RIDEPET, -1 ); + CHAR_setInt( talker , CHAR_BASEIMAGENUMBER , CHAR_getInt( talker , CHAR_BASEBASEIMAGENUMBER) ); + CHAR_sendStatusString( talker , "P"); +} + +#ifdef _TRANS7_POINT +BOOL NPC_ActionTransNewSeven( int talker, char *buf) +{ + char token[128]; + int work[10]; + int Trans=CHAR_getInt(talker,CHAR_TRANSMIGRATION)+1; +#ifdef _ADD_POOL_ITEM // WON ADD ӿɼķŵĵ + int tran_pool_item[5] = { 4, 4, 4, 4, 4 }; // ӵĵ߼ķ + int tran_pool_pet[5] = { 2, 2, 2, 2, 2}; // ӵijķ + int j,item_sum=0, pet_sum=0; + + if(Trans>7 || CHAR_getInt(talker,CHAR_LV)<160){ + sprintf( token, "תȼС160תʧ!", CHAR_getChar( talker, CHAR_NAME)); + CHAR_talkToCli( talker, -1, token, CHAR_COLORYELLOW ); + return; + } + + for(j=0; j<5 ;j++){ + item_sum += tran_pool_item[j] ; + pet_sum += tran_pool_pet[j]; + } + + item_sum += 10; // ļĵ + pet_sum += 5; // ļij + +#endif +// NPC_TransmigrationStatus(talker, talker, work); + NPC_TransmigrationFlg_CLS(talker, talker); + CHAR_setInt(talker ,CHAR_TRANSMIGRATION, Trans); + + CHAR_setInt( talker,CHAR_SKILLUPPOINT,CHAR_getInt( talker, CHAR_SKILLUPPOINT)+getTrans7Point()); + + CHAR_Skillupsend( talker ); + CHAR_setInt( talker , CHAR_BASEIMAGENUMBER , CHAR_getInt( talker , CHAR_BASEBASEIMAGENUMBER) ); + CHAR_sendStatusString( talker , "P"); +} +#endif +BOOL NPC_ActionTransNew7( int talker, char *buf) +{ + char token[128]; + int work[10]; + int Trans=CHAR_getInt(talker,CHAR_TRANSMIGRATION)+1; +#ifdef _ADD_POOL_ITEM // WON ADD ӿɼķŵĵ + int tran_pool_item[5] = { 4, 4, 4, 4, 4 }; // ӵĵ߼ķ + int tran_pool_pet[5] = { 2, 2, 2, 2, 2}; // ӵijķ + int j,item_sum=0, pet_sum=0; + + if(Trans>7 || CHAR_getInt(talker,CHAR_LV)<160){ + sprintf( token, "תȼС160תʧ!", CHAR_getChar( talker, CHAR_NAME)); + CHAR_talkToCli( talker, -1, token, CHAR_COLORYELLOW ); + return; + } + + for(j=0; j<5 ;j++){ + item_sum += tran_pool_item[j] ; + pet_sum += tran_pool_pet[j]; + } + + item_sum += 10; // ļĵ + pet_sum += 5; // ļij + +#endif +// NPC_TransmigrationStatus(talker, talker, work); + NPC_TransmigrationFlg_CLS(talker, talker); + CHAR_setInt(talker ,CHAR_TRANSMIGRATION, Trans); + if(CHAR_getInt(talker,CHAR_SUPER)==1) + CHAR_setInt( talker,CHAR_SKILLUPPOINT,CHAR_getInt( talker, CHAR_SKILLUPPOINT)+80); + else + { + if(CHAR_getInt(talker,CHAR_VIPRIDE)>0) + CHAR_setInt( talker,CHAR_SKILLUPPOINT,CHAR_getInt( talker, CHAR_SKILLUPPOINT)+75); + else + CHAR_setInt( talker,CHAR_SKILLUPPOINT,CHAR_getInt( talker, CHAR_SKILLUPPOINT)+70); + } + CHAR_Skillupsend( talker ); + CHAR_setInt( talker , CHAR_BASEIMAGENUMBER , CHAR_getInt( talker , CHAR_BASEBASEIMAGENUMBER) ); + CHAR_sendStatusString( talker , "P"); +} +#endif + +BOOL NPC_ActionAddItem( int talker, char *buf) +{ + int itemID,k=0,itemindex=-1; + int spaceNum=5,i; + char buff3[256], msgbuf[64], token[256]; + int ret; + + k=1; + while( getStringFromIndexWithDelim(buf , "," , k, buff3, sizeof(buff3)) !=FALSE ){ + k++; + for( i = spaceNum ; i < CHAR_MAXITEMHAVE ; i++ ){ + itemindex=CHAR_getItemIndex( talker , i ); + if( itemindex == -1 ) { + spaceNum = i+1; + break; + } + } + if( i == CHAR_MAXITEMHAVE ) { + snprintf( msgbuf,sizeof( msgbuf), "Ʒռ䲻㣡"); + CHAR_talkToCli( talker, -1, msgbuf, CHAR_COLORYELLOW); + return FALSE; + } + } + k=1; + while( getStringFromIndexWithDelim(buf , "," , k, buff3, sizeof(buff3)) !=FALSE ){ + k++; + itemID = atoi( buff3); + if( itemID ) + itemindex = ITEM_makeItemAndRegist( itemID); + if(itemindex == -1) + continue; + ret = CHAR_addItemSpecificItemIndex( talker, itemindex); + if( ret < 0 || ret >= CHAR_MAXITEMHAVE ) { + ITEM_endExistItemsOne( itemindex); + print ("\n ret error!!"); + return FALSE; + } + + sprintf( token,"õ%s",ITEM_getChar( itemindex, ITEM_NAME)); + CHAR_talkToCli( talker, -1, token, CHAR_COLORYELLOW ); + CHAR_sendItemDataOne( talker, ret); + } + + return TRUE; +} + +BOOL NPC_ActionSetEend( int talkerindex, char * buf) +{ + int eveno; + int talkNo=1, iflg=0; + char buf1[256]; + + while( getStringFromIndexWithDelim( buf,",",talkNo,buf1,sizeof( buf1)) != FALSE) { + talkNo++; + eveno = atoi( buf); + NPC_EventSetFlg( talkerindex, eveno); + if( ++iflg > 20 ) break; + } + return TRUE; +} + +BOOL NPC_ActionClearEvent( int toindex, char * buf) +{ + int eveno; + int talkNo=1, iflg=0; + char buf1[256]; + + while( getStringFromIndexWithDelim( buf,",",talkNo,buf1,sizeof( buf1)) != FALSE) { + talkNo++; + eveno = atoi( buf); + NPC_EndEventSetFlgCls( toindex, eveno); + if( ++iflg > 20 ) break; + } + return TRUE; +} + +BOOL NPC_ActionSetNow( int toindex, char * buf) +{ + int eveno; + int talkNo=1, iflg=0; + char buf1[256]; + + while( getStringFromIndexWithDelim( buf,",",talkNo,buf1,sizeof( buf1)) != FALSE) { + talkNo++; + eveno = atoi( buf); + NPC_NowEventSetFlg( toindex, eveno); + if( ++iflg > 20 ) break; + } + return TRUE; +} + + +BOOL NPC_ActionPassCheck( int meindex, int talker, char *buf) +{ + + char buff2[256]; + char buff3[128]; + int i=1,j=1; + int loop=0; + while( getStringFromIndexWithDelim(buf,",",i,buff2,sizeof(buff2)) !=FALSE ) { + i++; + if(strstr(buff2,"&")!=NULL){ + j=1; + loop=0; + while( getStringFromIndexWithDelim(buff2,"&",j,buff3,sizeof(buff3)) !=FALSE ) { + j++; + if(NPC_ActionBigSmallCheck( meindex, talker, buff3)==FALSE) { + loop=1; + break; + } + } + if(loop==0) { + CHAR_setWorkInt( talker, CHAR_WORKWARPCHECK, TRUE ); + return TRUE; + } + }else{ + if( NPC_ActionBigSmallCheck( meindex, talker, buff2) == TRUE){ + CHAR_setWorkInt( talker, CHAR_WORKWARPCHECK, TRUE ); + return TRUE; + + } + } + } + CHAR_setWorkInt( talker, CHAR_WORKWARPCHECK, FALSE ); + return FALSE; + +} + +BOOL NPC_ActionBigSmallCheck(int meindex,int talker,char* buf) +{ + + char buff2[128], buff3[128]; + int kosuu,temp=-1,flg=0; + +#ifdef _NEW_WARPMAN + char buff1[128]; + if(strstr( buf, "-") != NULL) { + getStringFromIndexWithDelim( buf, "-", 2, buff3, sizeof(buff3)); + temp = atoi( buff3); + getStringFromIndexWithDelim( buf, "-", 1, buff1, sizeof(buff1)); + strcpy( buf, buff1); + } +#endif + + if( strstr( buf, "<") != NULL ){ + getStringFromIndexWithDelim( buf, "<", 2, buff3, sizeof(buff2)); + kosuu = atoi( buff3); + getStringFromIndexWithDelim( buf, "<", 1, buff2, sizeof(buff2)); + + if( NPC_ActionFreeIfCheck( meindex, talker, buff2, buff3, kosuu, 1, temp)==TRUE){ + return TRUE; + } + }else if(strstr( buf, ">") != NULL){ + getStringFromIndexWithDelim( buf, ">", 2, buff3, sizeof(buff2)); + kosuu = atoi(buff3); + getStringFromIndexWithDelim( buf, ">" ,1, buff2, sizeof(buff2)); + + if( NPC_ActionFreeIfCheck( meindex, talker, buff2, buff3, kosuu, 2, temp) == TRUE ){ + return TRUE; + } + + }else if( strstr( buf, "!" ) != NULL){ + getStringFromIndexWithDelim( buf, "!=", 2, buff3, sizeof(buff2)); + kosuu = atoi( buff3); + getStringFromIndexWithDelim( buf, "!=", 1, buff2, sizeof(buff2)); + if( NPC_ActionFreeIfCheck( meindex, talker, buff2, buff3, kosuu, 0, temp) == TRUE ){ + return FALSE; + }else{ + return TRUE; + } + }else if( strstr( buf, "=") != NULL){ + getStringFromIndexWithDelim( buf, "=", 2, buff3, sizeof(buff2)); + kosuu = atoi( buff3); + getStringFromIndexWithDelim( buf, "=", 1, buff2, sizeof(buff2)); + flg = 0; + if( strstr( buf, "*") != NULL){ + if( NPC_ActionWarpManReduce( meindex, talker, buf)==TRUE){ + return TRUE; + } + } +#ifdef _NPC_ActionFreeCmp + else if( strstr( buf, "^") != NULL){ + if( NPC_ActionWarpManReduce2( meindex, talker, buf)==TRUE){ + return TRUE; + } + } +#endif + else if( NPC_ActionFreeIfCheck( meindex, talker, buff2, buff3, kosuu, flg, temp) == TRUE ) { + return TRUE; + } + } + return FALSE; +} + +#ifdef _NPC_ActionFreeCmp +//ʵܺԭNPC_ActionWarpManReduce,Ϊ˲Ӱǰ趨,Բȥ޸ԭ +BOOL NPC_ActionWarpManReduce2(int meindex,int talker,char *buf) +{ + char buf2[512]; + char buf3[256]; + int i, itemindex, itemno, kosuu; + int id=0; + int nums = 0; + + getStringFromIndexWithDelim(buf,"=",2,buf2,sizeof(buf2)); + getStringFromIndexWithDelim(buf2,"^",1,buf3,sizeof(buf3)); + itemno = atoi(buf3); + getStringFromIndexWithDelim(buf2,"^",2,buf3,sizeof(buf3)); + kosuu = atoi(buf3); + + for( i=CHAR_STARTITEMARRAY ; i < CHAR_MAXITEMHAVE;i++ ){ + itemindex=CHAR_getItemIndex( talker , i ); + if( ITEM_CHECKINDEX(itemindex) ){ + id=ITEM_getInt(itemindex ,ITEM_ID ); + if( itemno == id ){ + nums += ITEM_getInt( itemindex, ITEM_USEPILENUMS);// + } + } + } + + if( nums == kosuu ) return TRUE; + + return FALSE; +} +#endif + +#ifdef _NEW_MANOR_LAW +extern struct FM_POINTLIST fmpointlist; +#endif + +BOOL NPC_ActionFreeIfCheck(int meindex,int talker, char* buf, char *opt, int kosuu,int flg, int temp) +{ +#ifdef _VIP_SHOP + if(strcmp(buf,"VIPPOINT")==0){ + if(NPC_ActionVipPointCheck(meindex,talker,kosuu,flg)==TRUE) + return TRUE; + } +#endif +#ifdef _VIP_RIDE + if(strcmp(buf,"VIP")==0){ + if(NPC_ActionVipCheck(meindex,talker,kosuu,flg)==TRUE) + return TRUE; + } +#endif + + if(strcmp(buf,"LV")==0){ + if(NPC_ActionLevelCheck(meindex,talker,kosuu,flg)==TRUE) + return TRUE; + } + +#ifdef _ALL_ITEM + if(strcmp(buf,"ALLNUM1")==0){ + if(NPC_ActionAllNum1Check(meindex,talker,kosuu,flg)==TRUE) + return TRUE; + } + + if(strcmp(buf,"ALLNUM2")==0){ + if(NPC_ActionAllNum2Check(meindex,talker,kosuu,flg)==TRUE) + return TRUE; + } + + if(strcmp(buf,"ALLNUM3")==0){ + if(NPC_ActionAllNum3Check(meindex,talker,kosuu,flg)==TRUE) + return TRUE; + } + + if(strcmp(buf,"ALLNUM4")==0){ + if(NPC_ActionAllNum4Check(meindex,talker,kosuu,flg)==TRUE) + return TRUE; + } + + if(strcmp(buf,"ALLNUM5")==0){ + if(NPC_ActionAllNum5Check(meindex,talker,kosuu,flg)==TRUE) + return TRUE; + } +#endif + + if(strcmp(buf,"FAME")==0){ + if(NPC_ActionFameCheck(meindex,talker,kosuu,flg)==TRUE) + return TRUE; + } + if(strcmp(buf,"VIPPOINT")==0){ + if(NPC_ActionVippointCheck(meindex,talker,kosuu,flg)==TRUE) + return TRUE; + } + if(strcmp(buf,"AMPOINT")==0){ + if(NPC_ActionAmpointCheck(meindex,talker,kosuu,flg)==TRUE) + return TRUE; + } +#ifdef _VIGOR_SYS + if(strcmp(buf,"VIGOR")==0){ + if(NPC_ActionVigorCheck(meindex,talker,kosuu,flg)==TRUE) + return TRUE; + } +#endif +#ifndef _CAX_NPCTIME_OFF + if(strcmp(buf,"YEAR")==0){ + if(NPC_ActionYearCheck(meindex,talker,kosuu,flg)==TRUE) + return TRUE; + } + if(strcmp(buf,"MON")==0){ + if(NPC_ActionMonCheck(meindex,talker,kosuu,flg)==TRUE) + return TRUE; + } + if(strcmp(buf,"DATE")==0){ + if(NPC_ActionDateCheck(meindex,talker,kosuu,flg)==TRUE) + return TRUE; + } + if(strcmp(buf,"DAY")==0){ + if(NPC_ActionDayCheck(meindex,talker,kosuu,flg)==TRUE) + return TRUE; + } + if(strcmp(buf,"HOUR")==0){ + if(NPC_ActionHourCheck(meindex,talker,kosuu,flg)==TRUE) + return TRUE; + } + if(strcmp(buf,"MIN")==0){ + if(NPC_ActionMinCheck(meindex,talker,kosuu,flg)==TRUE) + return TRUE; + } + + if(strcmp(buf,"SEC")==0){ + if(NPC_ActionSecCheck(meindex,talker,kosuu,flg)==TRUE) + return TRUE; + } +#endif + if(strcmp(buf,"GOLD")==0){ + if(NPC_ActionGoldCheck(meindex,talker,kosuu,flg)==TRUE) + return TRUE; + } + + if( strcmp(buf,"TRANS") == 0 ) { + if( NPC_ActionCheckTrans( meindex, talker, kosuu, flg) == TRUE ) + return TRUE; + } + + if(strcmp(buf,"SKUP") == 0){ + if( NPC_ActionCheckSkup( meindex, talker, kosuu, flg) == TRUE ) + return TRUE; + } + + if(strcmp(buf,"SAFE") == 0){ + if( NPC_ActionCheckSafe( meindex, talker, kosuu, flg) == TRUE ) + return TRUE; + } + + if( !strcmp( buf, "GTIME") ){ + if( NPC_CheckTimeDefine( opt) == TRUE ) + return TRUE; + } + + if(strcmp( buf, "TIME") == 0) { + if(NPC_TiemCheck( meindex, talker, kosuu, flg) == TRUE) + return TRUE; + } + + if( strcmp( buf, "PET") == 0 ) { + if( temp > 0 ) { + if( ActionCheckMyPet( meindex, talker, kosuu, flg, temp) == TRUE ) + return TRUE; + }else + return FALSE; + } + if(strcmp(buf,"ITEM")==0){ + if(NPC_ActionItemCheck(meindex,talker,kosuu, flg)==TRUE) + return TRUE; + } + + if(strcmp(buf,"EQUIT")==0){ + if(NPC_ActioneEquitCheck(meindex,talker,kosuu, flg)==TRUE) + return TRUE; + } + + if( !strcmp(buf,"ENDEV") || !strcmp(buf,"EVEND") ){ + if(NPC_EventCheckFlg( talker, kosuu)==TRUE) + return TRUE; + } + if( !strcmp(buf,"NOWEV") || !strcmp(buf,"EVNOW") ){ + if(NPC_NowEventCheckFlg( talker, kosuu)==TRUE) + return TRUE; + } + + if(strcmp(buf,"PARTY")==0){ + if(NPC_ActionPartyCheck( talker, kosuu, flg)==TRUE) + return TRUE; + } + if(strcmp(buf,"reITEM")==0){ + if( NPC_ActionReItemCheck( talker, kosuu, flg)==TRUE) + return TRUE; + } + if(strcmp(buf,"rePET")==0){ + if( NPC_ActionRePetCheck( talker, kosuu, flg)==TRUE) + return TRUE; + } + +#ifdef _NPCCHANGE_PLAYERIMG + if(strcmp( buf, "BBI")==0) { + if( NPC_CheckPlayerBBI( meindex, talker, kosuu, flg)== TRUE) { + return TRUE; + } + } +#endif + if( strcmp( buf, "FM") == 0 ){ + if( CHAR_getInt( talker, CHAR_FMLEADERFLAG ) > 0 && + CHAR_getInt( talker, CHAR_FMLEADERFLAG ) != FMMEMBER_APPLY) + if( CHAR_getWorkInt( talker, CHAR_WORKFMFLOOR) == kosuu ){ + return TRUE; + } + } + if(strcmp(buf,"DR")==0){ + if(NPC_ActionDuelRankCheck(meindex,talker,kosuu,flg)==TRUE){ + return TRUE; + } + } + if(strcmp(buf,"DP")==0){ + if(NPC_ActionDuelPointCheck(meindex,talker,kosuu,flg)==TRUE){ + return TRUE; + } + } +#ifdef _PROFESSION_SKILL // WON ADD ְҵ + if( strcmp( buf, "CLASS") == 0 ){ + if(NPC_ActionClassCheck(meindex,talker,kosuu,flg)==TRUE) + return TRUE; + } + if( strcmp( buf, "Skill") == 0 ){ + if( NPC_ActionSkillCheck( meindex, talker, kosuu, flg)==TRUE) + return TRUE; + } + if( strcmp( buf, "SkNum") == 0 ){ + if( NPC_ActionSkillNumCheck( meindex, talker, kosuu, flg)==TRUE) + return TRUE; + } + if( strcmp( buf, "SKCP") == 0 ){ + if( NPC_ActionSkillPointAndSkillCheck( meindex, talker, kosuu, flg)==TRUE) + return TRUE; + } +#endif + + +#ifdef _TREASURE_BOX + if( strcmp( buf, "BOX") == 0 ){ + if( NPC_ActionTreasureTypeCheck( meindex, kosuu, + //NPC_TIME_EVENTMODE = CHAR_NPCWORKINT6,// 1 + CHAR_getWorkInt( meindex, CHAR_NPCWORKINT6) ,flg)==TRUE) + return TRUE; + } +#endif + +#ifdef _NPC_ADDWARPMAN1 + if( strcmp( buf, "PARTYCOUNT") == 0){ + if(NPC_ActionPartyCountCheck( talker, kosuu, flg)==TRUE) + return TRUE; + } + if( strcmp( buf, "MANCOUNT" ) == 0 ){ + if(NPC_ActionManCountCheck( talker, kosuu, flg ) == TRUE ) + return TRUE; + } + if( strcmp( buf, "WOMANCOUNT" ) == 0 ){ + if(NPC_ActionWomanCountCheck( talker, kosuu, flg ) == TRUE ) + return TRUE; + } +#endif + +#ifdef _ANGEL_SUMMON + if(strcmp(buf,"ANGEL_NOW")==0){ + if( NPC_ActionMissionAngelCheck(meindex,talker,kosuu, MISSION_DOING, 0)==TRUE) + return TRUE; + } + if(strcmp(buf,"HERO_NOW")==0){ + if( NPC_ActionMissionHeroCheck(meindex,talker,kosuu, MISSION_DOING, 0)==TRUE) + return TRUE; + } + if(strcmp(buf,"ANGEL_OVER")==0){ + if( NPC_ActionMissionAngelCheck(meindex,talker,kosuu, MISSION_HERO_COMPLETE, 0)==TRUE) + return TRUE; + } + if(strcmp(buf,"HERO_OVER")==0){ + if( NPC_ActionMissionHeroCheck(meindex,talker,kosuu, MISSION_HERO_COMPLETE, 0)==TRUE) + return TRUE; + } + if(strcmp(buf,"ANGEL_OUT")==0){ + if( NPC_ActionMissionAngelCheck(meindex,talker,kosuu, MISSION_TIMEOVER, 0)==TRUE) + return TRUE; + } + if(strcmp(buf,"HERO_OUT")==0){ + if( NPC_ActionMissionHeroCheck(meindex,talker,kosuu, MISSION_TIMEOVER, 0)==TRUE) + return TRUE; + } + + if(strcmp(buf,"ANGEL_I_NOW")==0){ + if( NPC_ActionMissionAngelCheck(meindex,talker,kosuu, MISSION_DOING, TRUE)==TRUE) + return TRUE; + } + if(strcmp(buf,"HERO_I_NOW")==0){ + if( NPC_ActionMissionHeroCheck(meindex,talker,kosuu, MISSION_DOING, TRUE)==TRUE) + return TRUE; + } + if(strcmp(buf,"ANGEL_I_OVER")==0){ + if( NPC_ActionMissionAngelCheck(meindex,talker,kosuu, MISSION_HERO_COMPLETE, TRUE)==TRUE) + return TRUE; + } + if(strcmp(buf,"HERO_I_OVER")==0){ + if( NPC_ActionMissionHeroCheck(meindex,talker,kosuu, MISSION_HERO_COMPLETE, TRUE)==TRUE) + return TRUE; + } + if(strcmp(buf,"ANGEL_I_OUT")==0){ + if( NPC_ActionMissionAngelCheck(meindex,talker,kosuu, MISSION_TIMEOVER, TRUE)==TRUE) + return TRUE; + } + if(strcmp(buf,"HERO_I_OUT")==0){ + if( NPC_ActionMissionHeroCheck(meindex,talker,kosuu, MISSION_TIMEOVER, TRUE)==TRUE) + return TRUE; + } + if(strcmp( buf, "HEROCNT") == 0) { + //if(NPC_EventLevelCheck( meindex, talker, kosuu, flg) == TRUE) { + if(NPC_HeroCompleteCountCheck( meindex, talker, kosuu, flg) == TRUE) + return TRUE; + } + +#endif + +#ifdef _CAX_NPCTIME_IF +if(strcmp( buf, "HOUR") == 0) { + if(NPC_TiemCheckWithHour( meindex, talker, kosuu, flg) == TRUE) { + return TRUE; + } + } + if(strcmp( buf, "DAY") == 0) { + if(NPC_TiemCheckWithDay ( meindex, talker, kosuu, flg) == TRUE) { + return TRUE; + } + } +#endif + +#ifdef _NEW_MANOR_LAW + if(strcmp(buf,"MANOR") == 0){ + // -1ʾҪǷΪׯ԰Աwarp + if(kosuu > -1){ + int iFmIndex = -1,iHadFmindex = -1; + char token[256]; + + iFmIndex = CHAR_getInt(talker,CHAR_FMINDEX); + getStringFromIndexWithDelim(fmpointlist.pointlistarray[kosuu],"|",5,token,sizeof(token)); + iHadFmindex = atoi(token); + if(iFmIndex > -1){ + // ׯ԰ӵмijԱ + if(iFmIndex == iHadFmindex){ + // мʽԱ + if(CHAR_getInt(talker,CHAR_FMLEADERFLAG) != FMMEMBER_NONE && + CHAR_getInt(talker,CHAR_FMLEADERFLAG) != FMMEMBER_APPLY) return TRUE; + } + } + } + } +#endif + + return FALSE; +} + +BOOL NPC_ActioneEquitCheck(int meindex,int talker,int itemNo, int flg) +{ + int i; + int itemindex=-1; + int id; + for( i=0;i point1) + return TRUE; + } + + return FALSE; +} + +BOOL ActionCheckMyPet( int meindex, int talker, int petLv, int flg, int petid) +{ + int petsel,petindex=-1; + int lv=-1; + for(petsel=0 ; petsel < CHAR_MAXPETHAVE ; petsel++) { + petindex = CHAR_getCharPet( talker, petsel); + if( petindex == -1 ) + continue; + if(CHAR_getInt( petindex, CHAR_PETID) != petid ) + continue; + break; + } + if( petsel == CHAR_MAXPETHAVE ) { + return FALSE; + }else { //ҵ + lv = CHAR_getInt( petindex, CHAR_LV); + if( NPC_ActionBigSmallLastCheck( petLv, lv, flg) == TRUE) { + return TRUE; + }else { + return FALSE; + } + } + return FALSE; +} + + +BOOL NPC_ActionCheckTrans(int meindex,int talker,int trans,int flg) +{ + int myTrans; + myTrans=CHAR_getInt(talker, CHAR_TRANSMIGRATION); + if( NPC_ActionBigSmallLastCheck( trans, myTrans, flg ) == TRUE ) { + return TRUE; + } + return FALSE; +} + + +#ifdef _VIP_SHOP +BOOL NPC_ActionVipPointCheck(int meindex,int talker,int point,int flg) +{ + int mypoint; + mypoint=sasql_vippoint(CHAR_getUseID(talker),0,0); + if(NPC_ActionBigSmallLastCheck( point, mypoint, flg) == TRUE){ + return TRUE; + } + return FALSE; +} +#endif +#ifdef _VIP_RIDE +BOOL NPC_ActionVipCheck(int meindex,int talker,int vip,int flg) +{ + if(NPC_ActionBigSmallLastCheck( CHAR_getInt(talker,CHAR_VIPRIDE), vip, flg) == TRUE){ + return TRUE; + } + return FALSE; +} +#endif +#ifdef _VIP_SHOP +BOOL NPC_ActionNewVipPointCheck(int meindex,int talker,int point,int flg) +{ + int mypoint; + mypoint=sasql_vippoint(CHAR_getUseID(talker),0,0); + if(NPC_ActionBigSmallLastCheck( point, mypoint, flg) == TRUE){ + return TRUE; + } + return FALSE; +} +#endif +BOOL NPC_ActionLevelCheck(int meindex,int talker,int level,int flg) +{ + int mylevel; + mylevel=CHAR_getInt(talker,CHAR_LV); + if(NPC_ActionBigSmallLastCheck( level, mylevel, flg) == TRUE){ + return TRUE; + } + return FALSE; +} + +#ifdef _ALL_ITEM +BOOL NPC_ActionAllNum1Check(int meindex,int talker,int npcallnum1,int flg) +{ + int allnum1 = sasql_allnum(1,0,0); + if(NPC_ActionBigSmallLastCheck( npcallnum1, allnum1, flg) == TRUE){ + return TRUE; + } + return FALSE; +} + +BOOL NPC_ActionAllNum2Check(int meindex,int talker,int npcallnum2,int flg) +{ + int allnum2 = sasql_allnum(2,0,0); + if(NPC_ActionBigSmallLastCheck( npcallnum2, allnum2, flg) == TRUE){ + return TRUE; + } + return FALSE; +} + +BOOL NPC_ActionAllNum3Check(int meindex,int talker,int npcallnum3,int flg) +{ + int allnum3 = sasql_allnum(3,0,0); + if(NPC_ActionBigSmallLastCheck( npcallnum3, allnum3, flg) == TRUE){ + return TRUE; + } + return FALSE; +} + +BOOL NPC_ActionAllNum4Check(int meindex,int talker,int npcallnum4,int flg) +{ + int allnum4 = sasql_allnum(4,0,0); + if(NPC_ActionBigSmallLastCheck( npcallnum4, allnum4, flg) == TRUE){ + return TRUE; + } + return FALSE; +} + +BOOL NPC_ActionAllNum5Check(int meindex,int talker,int npcallnum5,int flg) +{ + int allnum5 = sasql_allnum(5,0,0); + if(NPC_ActionBigSmallLastCheck( npcallnum5, allnum5, flg) == TRUE){ + return TRUE; + } + return FALSE; +} +#endif + +BOOL NPC_ActionFameCheck(int meindex,int talker,int fame,int flg) +{ + int myfame; + myfame=CHAR_getInt(talker,CHAR_FAME)/100; + if(NPC_ActionBigSmallLastCheck( fame, myfame, flg) == TRUE){ + return TRUE; + } + return FALSE; +} +BOOL NPC_ActionVippointCheck(int meindex,int talker,int point,int flg) +{ + int mypoint; + mypoint=sasql_vippoint(CHAR_getChar(talker,CHAR_CDKEY),0,0); + if(NPC_ActionBigSmallLastCheck( point, mypoint, flg) == TRUE){ + return TRUE; + } + return FALSE; +} +BOOL NPC_ActionAmpointCheck(int meindex,int talker,int ampoint,int flg) +{ + int myampoint; + myampoint=sasql_ampoint( CHAR_getChar(talker,CHAR_CDKEY), 0,0); + if(NPC_ActionBigSmallLastCheck( ampoint, myampoint, flg) == TRUE){ + return TRUE; + } + return FALSE; +} +#ifdef _VIGOR_SYS +BOOL NPC_ActionVigorCheck(int meindex,int talker,int vigor,int flg) +{ + int myvigor; + myvigor=CHAR_getInt(talker,CHAR_VIGOR); + if(NPC_ActionBigSmallLastCheck( vigor, myvigor, flg) == TRUE){ + return TRUE; + } + return FALSE; +} +#endif + +#ifndef _CAX_NPCTIME_OFF +BOOL NPC_ActionYearCheck(int meindex,int talker,int npcyear,int flg) +{ + NPC_ActionTime(); + if(NPC_ActionBigSmallLastCheck( npcyear, year, flg) == TRUE){ + return TRUE; + } + return FALSE; +} +BOOL NPC_ActionMonCheck(int meindex,int talker,int npcmon,int flg) +{ + NPC_ActionTime(); + if(NPC_ActionBigSmallLastCheck( npcmon, mon, flg) == TRUE){ + return TRUE; + } + return FALSE; +} +BOOL NPC_ActionDateCheck(int meindex,int talker,int npcdate,int flg) +{ + NPC_ActionTime(); + if(NPC_ActionBigSmallLastCheck( npcdate, date, flg) == TRUE){ + return TRUE; + } + return FALSE; +} +BOOL NPC_ActionDayCheck(int meindex,int talker,int npcday,int flg) +{ + NPC_ActionTime(); + if(NPC_ActionBigSmallLastCheck( npcday, day, flg) == TRUE){ + return TRUE; + } + return FALSE; +} +BOOL NPC_ActionHourCheck(int meindex,int talker,int npchour,int flg) +{ + NPC_ActionTime(); + if(NPC_ActionBigSmallLastCheck( npchour, hour, flg) == TRUE){ + return TRUE; + } + return FALSE; +} +BOOL NPC_ActionMinCheck(int meindex,int talker,int npcmin,int flg) +{ + NPC_ActionTime(); + if(NPC_ActionBigSmallLastCheck( npcmin, min, flg) == TRUE){ + return TRUE; + } + return FALSE; +} + + +BOOL NPC_ActionSecCheck(int meindex,int talker,int npcsec,int flg) +{ + NPC_ActionTime(); + if(NPC_ActionBigSmallLastCheck( npcsec, sec, flg) == TRUE){ + return TRUE; + } + return FALSE; +} +#endif + +#ifdef _PROFESSION_SKILL // WON ADD ְҵ +BOOL NPC_ActionClassCheck(int meindex,int talker,int p_class,int flg) +{ + int myclass; + myclass= CHAR_getInt( talker, PROFESSION_CLASS ); + + if(NPC_ActionBigSmallLastCheck( p_class, myclass, flg) == TRUE){ + return TRUE; + } + return FALSE; +} + +BOOL NPC_ActionSkillPointAndSkillCheck( int meindex,int talker,int sknum,int flg) +{ + int myskillpoint, myskillnum=0, myskilllevel; + int mysknum=0, j; + myskillpoint= CHAR_getInt( talker, PROFESSION_SKILL_POINT ); + myskilllevel= CHAR_getInt( talker, PROFESSION_LEVEL ); + + for( j=0; jskill, 0, 0 ); + pSkil->use = 0; + } + }else if( !strcmp( buf2, "CLASS") ){ + if( getStringFromIndexWithDelim( buf1 , "=" , 2, buf2, sizeof( buf2)) ==FALSE ) continue; + if( strstr( buf2, "ALL") != NULL ){ + CHAR_setInt( toindex , PROFESSION_CLASS, 0); +#ifdef _CHANNEL_MODIFY + if(CHAR_getInt(toindex,PROFESSION_CLASS) > 0){ + int i,pclass = CHAR_getInt(toindex,PROFESSION_CLASS) - 1; + for(i=0;i= kosuu ) return TRUE; +#endif + + return FALSE; + +} + +#ifdef _NPCCHANGE_PLAYERIMG //andy +BOOL NPC_ActionChangePlayerBBI( int meindex, int charindex, char *Img) +{ + int cBBI; + char buf1[256]; + memset( buf1, 0, sizeof( buf1)); + if( !CHAR_CHECKINDEX( charindex) ) + return FALSE; + if( !CHAR_CHECKINDEX( meindex) ) + return FALSE; +#ifdef _FIXBUG_ATTACKBOW + { + int armtype; + int itemindex = CHAR_getItemIndex( charindex, CHAR_ARM); + if( ITEM_CHECKINDEX(itemindex) ){ + armtype = ITEM_getInt( itemindex, ITEM_TYPE ); + if( armtype == ITEM_BOW || armtype == ITEM_BOUNDTHROW || + armtype == ITEM_BREAKTHROW || armtype == ITEM_BOOMERANG) { + CHAR_talkToCli( charindex, -1, "ʹԶ޷", CHAR_COLORYELLOW ); + return FALSE; + } + } + + } +#endif +#ifdef _PETSKILL_BECOMEPIG + if( CHAR_getInt( charindex, CHAR_BECOMEPIG) > -1 ){// + CHAR_talkToCli( charindex, -1, "޷вܱ", CHAR_COLORYELLOW ); + return FALSE; + } +#endif + if( CHAR_getInt( charindex, CHAR_RIDEPET) != -1 ) {//費ͼ + CHAR_setInt( charindex, CHAR_RIDEPET, -1 ); + BATTLE_changeRideImage( charindex ); + CHAR_talkToCli( charindex, -1, "ȡ״̬", CHAR_COLORYELLOW); + + //change -----> ޸bug(,ѡ״̬ȻΪ"", + CHAR_complianceParameter( charindex ); + CHAR_send_P_StatusString( charindex, CHAR_P_STRING_RIDEPET); + + //return FALSE; + } +#ifdef _ITEM_METAMO + CHAR_setWorkInt( charindex, CHAR_WORKITEMMETAMO, 0); +#endif + + if( Img == NULL || !strcmp( Img, "\0")) + return FALSE; +//======================= + CHAR_setWorkInt( charindex, CHAR_WORKNPCMETAMO, meindex); + if( strstr( Img, "NPCBBI") != NULL ) { + cBBI = CHAR_getInt( meindex, CHAR_BASEBASEIMAGENUMBER); + sprintf( buf1, "㻯%sӡ", CHAR_getChar( meindex, CHAR_NAME)); + }else if( strstr( Img, "MYBBI") != NULL ) { + cBBI = CHAR_getInt( charindex, CHAR_BASEBASEIMAGENUMBER); + CHAR_setWorkInt( charindex, CHAR_WORKNPCMETAMO, 0); + sprintf( buf1, "ԭӡ"); + }else if( strstr( Img, ",") != NULL ) { + int imgindex=1, maxImg=0; + while( getStringFromIndexWithDelim( Img, ",", imgindex, buf1, sizeof( buf1)) != FALSE ) { + imgindex++; + maxImg++; + } + if( (imgindex = (rand()%maxImg)) > maxImg) imgindex = 1; + if( imgindex < 1 ) imgindex = 1; + + if( getStringFromIndexWithDelim( Img, ",", imgindex, buf1, sizeof( buf1)) == FALSE ) + return FALSE; + cBBI = atoi( buf1); + sprintf( buf1, "Ӹıˡ"); + }else { + cBBI = atoi( Img); + sprintf( buf1, "Ӹıˡ"); + } +//======================= + if( cBBI < 0 ) { + return FALSE; + } + CHAR_talkToCli( charindex, -1, buf1, CHAR_COLORYELLOW); + //CHAR_BASEBASEIMAGENUMBER CHAR_BASEIMAGENUMBER + CHAR_setInt( charindex, CHAR_BASEIMAGENUMBER, cBBI); + CHAR_complianceParameter( charindex ); + CHAR_sendCToArroundCharacter( CHAR_getWorkInt( charindex , CHAR_WORKOBJINDEX )); + CHAR_send_P_StatusString( charindex , CHAR_P_STRING_BASEBASEIMAGENUMBER); + //CHAR_K_STRING_BASEIMAGENUMBER + //CHAR_P_STRING_BASEBASEIMAGENUMBER + return TRUE; +} +#endif + +#ifdef _NPCCHANGE_PLAYERIMG +BOOL NPC_CheckPlayerBBI( int meindex, int charindex, int BBI, int flg) +{ + int MyBBI; + if( !CHAR_CHECKINDEX( charindex)) + return FALSE; + if( BBI < 0 ) + return FALSE; + MyBBI = CHAR_getInt( charindex, CHAR_BASEIMAGENUMBER); + return NPC_ActionBigSmallLastCheck( BBI, MyBBI,flg); +} +#endif + +BOOL showString( int meindex, char *showstr,int flg) +{ //㲥 + char buf1[256]; + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + int toindex = -1; + int floor; + int i; + if( NPC_Util_GetArgStr( meindex, argstr, sizeof( argstr)) == NULL ) { + print("\n not found argstr "); + return FALSE; + } + if( NPC_Util_GetStrFromStrWithDelim( argstr, showstr,buf1, sizeof(buf1)) == NULL ) { + strcpy( buf1, showstr); + } + toindex = -1; + floor = CHAR_getInt( meindex , CHAR_FLOOR); + while( toindex < 1000) { + toindex ++; + if( !CHAR_CHECKINDEX( toindex) ) + continue; + if( CHAR_getInt( toindex , CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER ) + continue; + if( CHAR_getInt( toindex , CHAR_FLOOR) != floor ) + continue; + CHAR_talkToCli( toindex, meindex, buf1, CHAR_COLORYELLOW); + if( flg == 1 ) { + CHAR_setWorkInt( toindex, CHAR_WORKSTAKEFLAG, FALSE ); + for( i=0; i<5; i++) { + CHAR_setWorkInt( toindex, i+CHAR_WORKSTAKETYPE1, 0); + } + } + } + return TRUE; +} + +BOOL NPC_getTimeXYPoint( int meindex, int Mode) +{ + char npcarg[NPC_UTIL_GETARGSTR_BUFSIZE]; + char buf[256], buf1[256], buf2[256]; + int fl=-1, x, y; + int GraNo = -1; + int points = 1; //Ϊ1 + if( Mode <= 0 ) { + points = 2; + } + memset( npcarg, 0, sizeof( npcarg)); + if( !CHAR_CHECKINDEX( meindex) ) return FALSE; + if( NPC_Util_GetArgStr( meindex, npcarg, sizeof(npcarg)) == NULL ){ + print("WarpMan:GetArgStrErr"); + return FALSE; + } + memset( buf, 0, sizeof( buf)); + if( NPC_Util_GetStrFromStrWithDelim( npcarg, "TimeXYPoint", buf, sizeof( buf)) != NULL ){ + if( getStringFromIndexWithDelim(buf , "&" , points, buf1, sizeof( buf1)) != FALSE ){ + memset( buf2, 0, sizeof( buf2)); + if( getStringFromIndexWithDelim(buf1 , "," , 1, buf2, sizeof( buf2)) == FALSE ){ + return FALSE; + } + fl = atoi( buf2); + if( getStringFromIndexWithDelim(buf1 , "," , 2, buf2, sizeof( buf2)) == FALSE ){ + return FALSE; + } + x = atoi( buf2); + if( getStringFromIndexWithDelim(buf1 , "," , 3, buf2, sizeof( buf2)) == FALSE ){ + return FALSE; + } + y = atoi( buf2); + if( MAP_IsValidCoordinate( fl, x, y ) == FALSE ){ + char filename[256]; + NPC_Util_CheckAssignArgFile( meindex, filename); + return FALSE; + } + if( CHAR_getInt( meindex, CHAR_FLOOR) != fl || + CHAR_getInt( meindex, CHAR_X) != x || + CHAR_getInt( meindex, CHAR_Y) != y ){ + CHAR_warpToSpecificPoint( meindex, fl , x , y); + } + } + } + + if( NPC_Util_GetStrFromStrWithDelim( npcarg, "GraNo", buf, sizeof( buf)) != NULL ){ + if( getStringFromIndexWithDelim(buf , "&" , points, buf1, sizeof( buf1)) != FALSE ){ + GraNo = atoi( buf1); + CHAR_setInt( meindex, CHAR_BASEIMAGENUMBER, GraNo); + } + } + return TRUE; +} + +BOOL NPC_getTimeData( int meindex, char *npcarg, int *born, int *dead, int loopspeed) +{ + int i; + char buf[256]; + if( NPC_Util_GetStrFromStrWithDelim( npcarg, "NEWTIME", buf, sizeof( buf)) != NULL ){ + for(i=0 ; i<9 ; i++){ + if( strstr( buf, TimeTble[i].arg ) != NULL){ + *born = TimeTble[i].born; + *dead = TimeTble[i].dead; + return TRUE; + } + } + } + return FALSE; +} + +BOOL NPC_CheckTimeDefine( char *timetype) +{ + LSTIME nowlstime; + int born=-1, dead=-1, finds=0, i; + + RealTimeToLSTime( NowTime.tv_sec, &nowlstime); + + for(i=0 ; i<9 ; i++){ + if( strstr( timetype, TimeTble[i].arg ) != NULL){ + born = TimeTble[i].born; + dead = TimeTble[i].dead; + finds = 1; + break; + } + } + if( finds == 0 ) return FALSE; + + if( born < dead ){ + if( (born < nowlstime.hour) && (dead > nowlstime.hour) ){ + return TRUE; + } + }else{ + if( (born < nowlstime.hour && 1024 > nowlstime.hour) || + ( 0 < nowlstime.hour && dead > nowlstime.hour)){ + return TRUE; + } + } + + return FALSE; +} + +void NPC_TimeDefineDo( int meindex, int born, int dead, int typeMode) +{ + LSTIME nowlstime; + RealTimeToLSTime( NowTime.tv_sec, &nowlstime); + if(born < dead){ + if( (born < nowlstime.hour) && (dead > nowlstime.hour) ){ + CHAR_setWorkInt(meindex,typeMode,0); + }else{ + CHAR_setWorkInt(meindex,typeMode,1); + } + }else{ + if( (born < nowlstime.hour && 1024 > nowlstime.hour) || ( 0 < nowlstime.hour && dead > nowlstime.hour)){ + CHAR_setWorkInt(meindex,typeMode,0); + }else{ + CHAR_setWorkInt(meindex,typeMode,1); + } + } + if( NPC_getTimeXYPoint( meindex, CHAR_getWorkInt( meindex, typeMode)) == FALSE ) + return; +} + + +void GetRand_WarpPoint( char *buf, int *fl, int *x, int *y ) +{ + char buff1[256],buff2[256]; + int i=0,point=1; + struct { + int m_fl; + int m_x; + int m_y; + } RandPoint[]={ + {0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0}, + {0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0}, + {0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0}, + {0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0}, + }; + while( getStringFromIndexWithDelim( buf,";",point,buff1,sizeof( buff1)) != FALSE) { + point++; + getStringFromIndexWithDelim(buff1,",",1,buff2,sizeof(buff2)); + RandPoint[i].m_fl = atoi(buff2); + getStringFromIndexWithDelim(buff1,",",2,buff2,sizeof(buff2)); + RandPoint[i].m_x = atoi(buff2); + getStringFromIndexWithDelim(buff1,",",3,buff2,sizeof(buff2)); + RandPoint[i].m_y = atoi(buff2); + i++; + if( i >= arraysizeof( RandPoint) ) + break; + } + + point = RAND( 0, i); + if( RandPoint[point].m_fl <= 0 || point > arraysizeof( RandPoint) -1) { + point = 0; + } + *fl = RandPoint[point].m_fl; + *x = RandPoint[point].m_x; + *y = RandPoint[point].m_y; + + return; +} + +#ifdef _EMENY_CHANCEMAN +int NPC_EmenyChanceCheck( int meindex, int charaindex, char *arg) +{ + char buf1[256]; + int sex=2, fl=-1,x=-1,y=-1; + memset( buf1, 0, sizeof( buf1)); + + if( NPC_Util_GetStrFromStrWithDelim( arg, "CHECKSEX", buf1, sizeof( buf1)) == NULL ) { + return charaindex; + } + if( strstr( buf1, "male") != 0 ){ + sex = 1; + } + if( NPC_Util_GetStrFromStrWithDelim( arg, "NOBATTLEWARP", buf1, sizeof( buf1)) != NULL ) { + char data[256]; + if( getStringFromIndexWithDelim( buf1,",", 1, data, sizeof(data)) == FALSE ) return charaindex; + fl = atoi( data); + if( getStringFromIndexWithDelim( buf1,",", 2, data, sizeof(data)) == FALSE ) return charaindex; + x = atoi( data); + if( getStringFromIndexWithDelim( buf1,",", 3, data, sizeof(data)) == FALSE ) return charaindex; + y = atoi( data); + } + return NPC_DischargePartyForSex( meindex, charaindex, fl, x, y, sex); +} + +int NPC_DischargePartyForSex( int meindex, int charaindex, int fl, int x, int y, int fsex) +{ + int Party[CHAR_PARTYMAX] = {-1,-1,-1,-1,-1}; + int masterindex =-1, i, j, playerNo; + if( CHAR_getWorkInt( charaindex, CHAR_WORKPARTYMODE) != CHAR_PARTY_LEADER ){ + playerNo = CHAR_getInt( charaindex, CHAR_BASEBASEIMAGENUMBER); + if( CHAR_getSexInt( playerNo ) == fsex ) { + if( MAP_IsValidCoordinate( fl, x, y) != FALSE ){ + CHAR_warpToSpecificPoint( charaindex, fl, x, y); + return -1; + } + }else { + return charaindex; + } + } + CHAR_talkToCli( charaindex, -1, "Ŷ飡", CHAR_COLORYELLOW); + + for( i = 0; i < CHAR_PARTYMAX; i ++ ) { + int index = CHAR_getWorkInt( charaindex, CHAR_WORKPARTYINDEX1+i); + if( !CHAR_CHECKINDEX( index)) continue; + Party[i] = index;//¼ + } + CHAR_DischargePartyNoMsg( charaindex);//ɢŶ + + for( i = 0; i < CHAR_PARTYMAX; i ++ ) { + int index = Party[i]; + playerNo = CHAR_getInt( index, CHAR_BASEBASEIMAGENUMBER); + if( CHAR_getSexInt( playerNo ) == fsex ) { + if( MAP_IsValidCoordinate( fl, x, y) != FALSE ){ + CHAR_warpToSpecificPoint( index, fl, x, y); + } + Party[i] = -1; + } + } + j = CHAR_WORKPARTYINDEX1; + for( i = 0; i < CHAR_PARTYMAX; i ++ ) { + int index = Party[i]; + if( !CHAR_CHECKINDEX( index ))continue; + if( !CHAR_CHECKINDEX( masterindex )){ + masterindex = index; + CHAR_setWorkInt( masterindex, CHAR_WORKPARTYMODE, CHAR_PARTY_LEADER); + CHAR_setWorkInt( masterindex, j++, masterindex); + }else { + CHAR_setWorkInt( masterindex, j++, index); + CHAR_setWorkInt( index, CHAR_WORKPARTYMODE, CHAR_PARTY_CLIENT); + CHAR_setWorkInt( index, CHAR_WORKPARTYINDEX1, masterindex); + } + } + return masterindex; +} +#endif + +BOOL NPC_ActionDuelRankCheck(int meindex,int talker,int rank,int flg) +{ + int myrank; + myrank=CHAR_getWorkInt(talker,CHAR_WORKSHOPRELEVANTSEC); + if( NPC_ActionBigSmallLastCheck( rank, myrank, flg)==TRUE){ + return TRUE; + } + + return FALSE; +} + +BOOL NPC_ActionDuelPointCheck(int meindex,int talker,int rank,int flg) +{ + int myduel; + myduel = CHAR_getInt( talker, CHAR_DUELPOINT); + if( NPC_ActionBigSmallLastCheck( rank, myduel, flg)==TRUE){ + return TRUE; + } + + return FALSE; +} + +BOOL NPC_ActionTreasureTypeCheck(int meindex,int level, int type, int flg) +{ + int mylevel; + +// if( CHAR_getWorkInt( meindex, NPC_TIME_EVENTMODE) == NPC_EVENTMODE_EVENT ){ + mylevel = (type == NPC_EVENTMODE_EVENT)?1:0; + if( NPC_ActionBigSmallLastCheck( level, mylevel, flg)==TRUE) + return TRUE; + return FALSE; +} + +BOOL NPC_ActionTreasureRandItemGet(int meidex,int talker,int rand_j,char *buf) +{ + char buff2[64]; + int randitem; + int ret; + int itemindex; + char token[128]; + + if(rand_j == 0) { + print("Event:춣Ľ룬ִ"); + return FALSE; + } + + //randitem = rand()%rand_j; + //srand((int)time(0)); + randitem = RAND(1,rand_j); + if(randitem == 0) randitem = rand_j; + + getStringFromIndexWithDelim(buf , "," , randitem, buff2, sizeof(buff2)) ; + + itemindex = ITEM_makeItemAndRegist( atoi( buff2)); + + if(itemindex == -1) return FALSE; + + /*ʧ ةܰ( ʧ ة ľ */ + ret = CHAR_addItemSpecificItemIndex( talker, itemindex); + if( ret < 0 || ret >= CHAR_MAXITEMHAVE ) { + print( "npc_exchangeman.c: additem error itemindex[%d]\n", itemindex); + ITEM_endExistItemsOne( itemindex); + return FALSE; + } + + if(itemindex != -1) { + LogItem( + CHAR_getChar( talker, CHAR_NAME ), /* ƽҷ */ + CHAR_getChar( talker, CHAR_CDKEY ), +#ifdef _add_item_log_name // WON ADD itemlogitem + itemindex, +#else + ITEM_getInt( itemindex, ITEM_ID), /* ʧ ة į */ +#endif + "EventAddItem(õĵ)", + CHAR_getInt( talker,CHAR_FLOOR), + CHAR_getInt( talker,CHAR_X ), + CHAR_getInt( talker,CHAR_Y ), + ITEM_getChar( itemindex, ITEM_UNIQUECODE), + ITEM_getChar( itemindex, ITEM_NAME), + ITEM_getInt( itemindex, ITEM_ID) + ); + } + + sprintf(token,"%s",ITEM_getChar( itemindex, ITEM_NAME)); + CHAR_talkToCli( talker, -1, token, CHAR_COLORWHITE); + + CHAR_sendItemDataOne( talker, ret); + return TRUE; + +} + +#ifdef _NPC_ADDLEVELUP // (ɿ) ANDY ⲿԻҵȼ +extern tagRidePetTable ridePetTable[296]; +void NPC_ActionLevelAndTransUp( int meindex, int charindex, int level, int skillpoint, int exp, int ridepet) +{ + char szBuffer[256]=""; + if( !CHAR_CHECKINDEX( charindex) ) + return; +//int CHAR_LevelUpCheck( int charaindex , int toindex) + if( exp > 0 ){ + int LevelUp=0; + int myexp = CHAR_getInt( charindex, CHAR_EXP); + myexp += exp; + if( myexp > 300000000 ) myexp = 300000000; + CHAR_setInt( charindex, CHAR_EXP, myexp); + snprintf( szBuffer, sizeof(szBuffer), + "(%s) õ EXP %d", CHAR_getUseName( charindex ), exp); + CHAR_talkToCli( charindex, -1, szBuffer, CHAR_COLORYELLOW); + LevelUp = CHAR_LevelUpCheck( charindex , -1); + if( LevelUp > 0 ){ + snprintf( szBuffer, sizeof(szBuffer), + "(%s) %d", + CHAR_getUseName( charindex ), + CHAR_getInt( charindex, CHAR_LV ) + ); + CHAR_talkToCli( charindex, -1, szBuffer, CHAR_COLORYELLOW); + CHAR_setInt( charindex, CHAR_SKILLUPPOINT, + CHAR_getInt( charindex, CHAR_SKILLUPPOINT) + LevelUp*3 ); + CHAR_complianceParameter( charindex ); + } + } + + if( level > 0 ){ + CHAR_setInt( charindex, CHAR_LV, level); + snprintf( szBuffer, sizeof(szBuffer), + "(%s) ȼ趨Ϊ %d", + CHAR_getUseName( charindex ), CHAR_getInt( charindex, CHAR_LV ) + ); + CHAR_talkToCli( charindex, -1, szBuffer, CHAR_COLORYELLOW); + } + + if( skillpoint > 0 ){ + int MySp = CHAR_getInt( charindex, CHAR_SKILLUPPOINT); + MySp += skillpoint; + CHAR_setInt( charindex, CHAR_SKILLUPPOINT, MySp); + } + if( ridepet >= 0 ){ + int basepet[2][4]={ {2066,2067,2068,2069}, + {2072,2073,2074,2075}}; + int petTemp[]={-1,-1,-1,-1,-1}; + char msgbuf[256]; + int petNum=0; + int i,j=0; + int k=0, petindex,enemyarray; + petTemp[j++] = basepet[0][rand()%4]; + petTemp[j++] = basepet[1][rand()%4]; + + for( i=0; i< arraysizeof(ridePetTable) ; i++ ){ + if( CHAR_getInt( charindex, CHAR_BASEBASEIMAGENUMBER) == ridePetTable[i].charNo ){ + petTemp[j]= ridePetTable[i].petId; + j++; + if( j >= arraysizeof( petTemp) ) + break; + } + } + j=0; + for( petNum=0; petNum= CHAR_MAXITEMHAVE ) + return FALSE; + } + return TRUE; +} + +BOOL NPC_ActionMissionHeroCheck(int meindex,int talker,int mission,int flg,int checkitem) +{ + int mindex; + char nameinfo[64]; + int i, itemindex, itemid; + + mindex = checkIfAngel( talker); + if( mindex <= -1 ) return FALSE; + if( missiontable[mindex].mission != mission) return FALSE; + getMissionNameInfo( talker, nameinfo); + if( strcmp( nameinfo, missiontable[mindex].heroinfo )) return FALSE; + if( missiontable[mindex].flag != flg ) return FALSE; + + if( checkitem ) { // + for( i=CHAR_STARTITEMARRAY;i= CHAR_MAXITEMHAVE ) + return FALSE; + } + + return TRUE; +} + + +BOOL NPC_HeroCompleteCountCheck(int meindex,int talker,int count,int flg) +{ + + int herocnt; + herocnt = CHAR_getInt(talker,CHAR_HEROCNT); + + if(NPC_EventBigSmallLastCheck( count, herocnt, flg) == TRUE) + { + if(flg == 3) return FALSE; + return TRUE; + } + + if(flg == 3) return TRUE; + return FALSE; + +} + + + +#endif + + +BOOL NPC_ActionCheckSkup(int meindex,int talker,int skup,int flg) +{ + int mySkup; + mySkup=CHAR_getInt(talker, CHAR_SKILLUPPOINT); + if( NPC_ActionBigSmallLastCheck( skup, mySkup, flg ) == TRUE ) { + return TRUE; + } + return FALSE; +} + +BOOL NPC_ActionCheckSafe(int meindex,int talker,int safe,int flg) +{ + int mySafe; + mySafe=CHAR_getWorkInt(talker, CHAR_WORKSAFEMODE); + if( NPC_ActionBigSmallLastCheck( safe, mySafe, flg ) == TRUE ) { + return TRUE; + } + return FALSE; +} + +BOOL NPC_ActionWarpNpc(int meindex,char *buf) +{ + char token[32]; + char token2[32]; + char buf2[32]; + int floor,x,y,x1,x2,y1,y2; + int ret; + int cnt; + int dcnt = 1; + + /*--ػ󼰴 --*/ + cnt = CHAR_getWorkInt(meindex,CHAR_NPCWORKINT4); + while(getStringFromIndexWithDelim(buf,",", dcnt,buf2,sizeof(buf2) ) + !=FALSE ){ + dcnt++; + } + //cnt = RAND(1,dcnt); + if(dcnt <= cnt) cnt=1; + + + while(getStringFromIndexWithDelim(buf,",", cnt,buf2,sizeof(buf2)) !=FALSE ) + { + cnt++; + ret=getStringFromIndexWithDelim(buf2,".", 1,token,sizeof(token)); + if( ret == FALSE ) { + continue; + } + floor = atoi( token ); + + ret=getStringFromIndexWithDelim(buf2,".", 2,token,sizeof(token)); + if( ret == FALSE ){ + continue; + } + ret=getStringFromIndexWithDelim(token,"-", 1,token2,sizeof(token2)); + if( ret == FALSE ){ + x = atoi( token ); + }else{ + x1=atoi(token2); + ret=getStringFromIndexWithDelim(token,"-", 2,token2,sizeof(token2)); + if( ret == FALSE ){ + x2=x1; + }else{ + x2=atoi(token2); + } + x = RAND(x1,x2); + } + //x = atoi( token ); + + ret=getStringFromIndexWithDelim(buf2,".", 3,token,sizeof(token)); + if( ret == FALSE ) { + continue; + } + ret=getStringFromIndexWithDelim(token,"-", 1,token2,sizeof(token2)); + if( ret == FALSE ){ + y = atoi( token ); + }else{ + y1=atoi(token2); + ret=getStringFromIndexWithDelim(token,"-", 2,token2,sizeof(token2)); + if( ret == FALSE ){ + y2=y1; + }else{ + y2=atoi(token2); + } + y = RAND(y1,y2); + } + //y = atoi( token ); + //print("\nfloor=%d,x=%d,y=%d\n",floor,x,y); + CHAR_setWorkInt(meindex,CHAR_NPCWORKINT4, cnt); + CHAR_warpToSpecificPoint(meindex, floor, x, y); + return TRUE; + } + + return FALSE; + +} + +int NPC_ActionTime(void) +{ + time_t timep; + struct tm *p; + time(&timep); + p=localtime(&timep); /*ȡõʱ*/ + year=1900+p->tm_year; + mon=1+p->tm_mon; + date=p->tm_mday; + day=p->tm_wday; + hour=p->tm_hour; + min=p->tm_min; + sec=p->tm_sec; +} diff --git a/npc/npc_exchangeman.c b/npc/npc_exchangeman.c new file mode 100644 index 0000000..156092f --- /dev/null +++ b/npc/npc_exchangeman.c @@ -0,0 +1,6052 @@ +#include "version.h" +#include +#include "char.h" +#include "object.h" +#include "net.h" +#include "char_base.h" +#include "npcutil.h" +#include "lssproto_serv.h" +#include "npc_exchangeman.h" +#include "npc_eventaction.h" +#include "log.h" +#include "battle.h" +#include "handletime.h" +#include "enemy.h" +#include "npc_warp.h" + +int year,mon,date,day,hour,min,sec; +#ifdef _ALL_ITEM +extern int allnum1,allnum2,allnum3,allnum4,allnum5; +extern char hanzibuf[5000][8]; +#endif +#ifdef _ANGEL_SUMMON +extern struct MissionInfo missionlist[MAXMISSION]; +extern struct MissionTable missiontable[MAXMISSIONTABLE]; +#endif +#ifdef _TRANS_7_NPC +BOOL NPC_EventTRANS(int meindex, int talker, char *buff2,int mode); +#endif +static void NPC_ExChangeMan_selectWindow( int meindex, int talker,int num); +BOOL NPC_TypeCheck(int meindex,int talker,char *szMes); +int NPC_ExChangeManEventCheck( int meindex, int talker, char *buff1); +BOOL NPC_EventItemCheck(int meindex,int talker,int itemNo,int flg); +BOOL NPC_EventLevelCheck(int meindex,int talker,int level,int flg); +BOOL NPC_EventVipCheck(int meindex,int talker,int vip,int flg); +BOOL NPC_EventSuperCheck(int meindex,int talker,int vip,int flg); +BOOL NPC_EventVipPointCheck(int meindex,int talker,int vippoint,int flg); +BOOL NPC_EventNpcTimeCheck(int meindex,int talker,int npctime,int flg); +#ifdef _EV_NUM +BOOL NPC_EventEvNumCheck(int meindex,int talker,int evnum,int flg); +#endif +// Arminius 8.14 move to .h (for pet talk) +//BOOL NPC_EventBigSmallCheck(int meindex,int talker,char* buf); +BOOL NPC_EventFreeIfCheck(int meindex,int talker,char* buf,int kosuu,int flg); +BOOL NPC_EventBigSmallLastCheck(int point1,int mypoint,int flg); +BOOL NPC_ENDEventNoCheck(int meindex,int talker,int shiftbit,int flg); +BOOL NPC_NOWEventNoCheck(int meindex,int talker,int shiftbit,int flg); +BOOL NPC_TiemCheck(int meindex,int talker,int time,int flg); + +#ifdef _CAX_NPCTIME_IF +/*CCIS_WXscript add 09/02/21 Сʱ*/ +BOOL NPC_TiemCheckWithHour(int meindex,int talker,int time,int flg); +/*CCIS_WXscript add 09/02/21 ڼ*/ +BOOL NPC_TiemCheckWithDay(int meindex,int talker,int time,int flg); +#endif + +BOOL NPC_EventAddPet(int meindex, int talker, char *buff2,int mode); +BOOL NPC_RandItemGet(int meindex, int talker,int rand_j,char *buf); + +BOOL NPC_PetLvCheckType2(int petindex,int meindex,int talker,char *buf,int mode); +BOOL NPC_PetLvCheck(int meindex,int talker,char *buf,int mode); +#ifdef _NPC_PETSKILLUP +BOOL NPC_PetSkillCheck(int meindex,int talker,char *buf,int mode); +#endif +void NPC_RequestMain(int meindex,int talker,char *buf); +void NPC_AcceptMain(int meindex,int talker ,char*buf); +void NPC_MsgDisp(int meindex,int talker,int num); +BOOL NPC_EventAdd(int meindex,int talker,int mode); +BOOL NPC_AcceptDel(int meindex,int talker,int mode); +BOOL NPC_SavePointCheck(int meindex,int talker,int shiftbit,int flg); + +BOOL NPC_EventReduce(int meindex,int talker,char *buf); +BOOL NPC_EventDelItem(int meindex,int talker,char *buf,int breakflg); +BOOL NPC_EventDelItemEVDEL(int meindex,int talker,char *buf,char *nbuf,int breakflg); +BOOL NPC_EventAddItem(int meindex,int talker,char *buf); +int NPC_EventFile(int meindex,int talker,char *buf); +BOOL NPC_EventDelPet(int meindex,int talker, int petsel); +void NPC_PetSkillMakeStr(int meindex,int toindex,int select); +void NPC_CleanMain(int meindex,int talker,char *buf); +void NPC_EventPetSkill( int meindex, int talker, char *data); +BOOL NPC_ItemFullCheck(int meindex,int talker,char *buf,int mode,int evcnt); +void NPC_CharmStatus(int meindex,int talker); +BOOL NPC_ImageCheck(int meindex,int talker,int kosuu,int flg); +int NPC_EventGetCost(int meindex,int talker,char *arg); + +BOOL NPC_EventWarpNpc(int meindex,char *buf); + +enum { + CHAR_WORK_EVENTWARP = CHAR_NPCWORKINT4, + +}; + +/********************************* +* +*********************************/ +BOOL NPC_ExChangeManInit( int meindex ) +{ + + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + char buf[1024*2]; + int i = 1; + char buf4[256]; + + CHAR_setWorkInt(meindex,CHAR_WORK_EVENTWARP,1); + + /*--NPCë--*/ + CHAR_setInt( meindex , CHAR_WHICHTYPE , CHAR_TYPEEVENT ); + + + /*--ɬð̻ë --*/ + if(NPC_Util_GetArgStr( meindex, argstr, sizeof( argstr)) == NULL) { + print("NPC_ExChange.c TypeCheck: GetArgStrErr\n"); + print("NPCName=%s\n", CHAR_getChar( meindex ,CHAR_NAME)); + return FALSE; + } + + i = 1; + /*--ìNPCʧ ةë--*/ + /*-- ƻ¾ʸƥ˪ľ¾--*/ + while(getStringFromIndexWithDelim( argstr ,"EventEnd" ,i ,buf ,sizeof(buf)) + != FALSE) + { + i++; + /*--ƥ̤ľ¼߼ë-*/ + if(strstr( buf,"GetItem") != NULL) { + if(strstr( buf,"ItemFullMsg") == NULL) { + NPC_Util_GetStrFromStrWithDelim(buf,"EventNo",buf4,sizeof(buf4)); + print("\n### EventNo=%d %s:ItemFullMsg ###", + atoi( buf4), + CHAR_getChar( meindex, CHAR_NAME)); + } + } + + if(strstr( buf,"GetPet") != NULL) { + if(strstr( buf,"PetFullMsg") == NULL) { + NPC_Util_GetStrFromStrWithDelim(buf,"EventNo",buf4,sizeof(buf4)); + print("\n### ventNo=%d %s:PetFullMsg ###", + atoi(buf4), + CHAR_getChar(meindex,CHAR_NAME)); + } + } + + if(strstr( buf,"GetEgg") != NULL) { + if(strstr( buf,"PetFullMsg") == NULL) { + NPC_Util_GetStrFromStrWithDelim(buf,"EventNo",buf4,sizeof(buf4)); + print("\n### ventNo=%d %s:PetFullMsg ###", + atoi(buf4), + CHAR_getChar(meindex,CHAR_NAME)); + } + } + + if(strstr( buf,"GetStone") != NULL){ + if(strstr( buf,"StoneFullMsg") == NULL){ + NPC_Util_GetStrFromStrWithDelim(buf,"EventNo",buf4,sizeof(buf4)); + print("\n### EventNo=%d %s:StonFullMsg ###", + atoi( buf4), + CHAR_getChar( meindex, CHAR_NAME)); + } + } + + if(strstr( buf,"DelStone") != NULL) { + if(strstr( buf,"StoneLessMsg") == NULL) { + NPC_Util_GetStrFromStrWithDelim(buf,"EventNo",buf4,sizeof(buf4)); + print("\n### EventNo=%d %s:StoneLessMsg ###", + atoi(buf4), + CHAR_getChar(meindex,CHAR_NAME)); + } + } + } + + i = 1; + + return TRUE; + +} + +/*-- --*/ +BOOL NPC_EventWarpNpc(int meindex,char *buf) +{ + char token[32]; + char token2[32]; + char buf2[32]; + int floor,x,y,x1,x2,y1,y2; + int ret; + int cnt; + int dcnt = 1; + + /*--ػ󼰴 --*/ + cnt = CHAR_getWorkInt(meindex,CHAR_WORK_EVENTWARP); + while(getStringFromIndexWithDelim(buf,",", dcnt,buf2,sizeof(buf2) ) + !=FALSE ){ + dcnt++; + } + //cnt = RAND(1,dcnt); + if(dcnt <= cnt) cnt=1; + + while(getStringFromIndexWithDelim(buf,",", cnt,buf2,sizeof(buf2)) !=FALSE ) + { + cnt++; + ret=getStringFromIndexWithDelim(buf2,".", 1,token,sizeof(token)); + if( ret == FALSE ) { + continue; + } + floor = atoi( token ); + + ret=getStringFromIndexWithDelim(buf2,".", 2,token,sizeof(token)); + if( ret == FALSE ){ + continue; + } + ret=getStringFromIndexWithDelim(token,"-", 1,token2,sizeof(token2)); + if( ret == FALSE ){ + x = atoi( token ); + }else{ + x1=atoi(token2); + ret=getStringFromIndexWithDelim(token,"-", 2,token2,sizeof(token2)); + if( ret == FALSE ){ + x2=x1; + }else{ + x2=atoi(token2); + } + x = RAND(x1,x2); + } + //x = atoi( token ); + + ret=getStringFromIndexWithDelim(buf2,".", 3,token,sizeof(token)); + if( ret == FALSE ) { + continue; + } + ret=getStringFromIndexWithDelim(token,"-", 1,token2,sizeof(token2)); + if( ret == FALSE ){ + y = atoi( token ); + }else{ + y1=atoi(token2); + ret=getStringFromIndexWithDelim(token,"-", 2,token2,sizeof(token2)); + if( ret == FALSE ){ + y2=y1; + }else{ + y2=atoi(token2); + } + y = RAND(y1,y2); + } + //y = atoi( token ); + //print("\nfloor=%d,x=%d,y=%d\n",floor,x,y); + CHAR_setWorkInt(meindex,CHAR_WORK_EVENTWARP, cnt); + CHAR_warpToSpecificPoint(meindex, floor, x, y); + return TRUE; + } + + return FALSE; + +} + + +/********************************* +* ƾľݼ +*********************************/ +void NPC_ExChangeManTalked( int meindex , int talkerindex , char *szMes ,int color ) +{ + /* 帲ƻ ɱ */ + if( CHAR_getInt( talkerindex , CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER ) { + return; + } + + /*-- ¾--*/ + if(NPC_Util_isFaceToFace( meindex ,talkerindex ,2) == FALSE) { + /* */ + if(NPC_Util_isFaceToChara(talkerindex,meindex,1 ) == FALSE) return; + } + + /*-- ë--*/ + CHAR_setWorkInt( talkerindex ,CHAR_WORKSHOPRELEVANT, 0); + CHAR_setWorkInt( talkerindex ,CHAR_WORKSHOPRELEVANTSEC, 0); + CHAR_setWorkInt( talkerindex ,CHAR_WORKSHOPRELEVANTTRD, 0); + +#ifdef _NPC_RAND_MSG + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + if(NPC_Util_GetArgStr( meindex, argstr, sizeof(argstr)) == NULL) { + print("NPC_ExChange.c TypeCheck: GetArgStrErr\n"); + print("NPCName=%s\n", CHAR_getChar(meindex,CHAR_NAME)); + return; + } + if(strstr(argstr,"STARTRAND")!=NULL){ + time_t timep; + struct tm *p; + time(&timep); + p=localtime(&timep); + timep = mktime(p); + char *randtypetime = CHAR_getChar(talkerindex,CHAR_RANDTYPE); + char tempbuff[64]; + int randtype = 0; + int randtime = 0; + int randwrong = 0; + if(strlen(randtypetime)>2){ + if(getStringFromIndexWithDelim(randtypetime,"-", 3, tempbuff, sizeof(tempbuff)) != FALSE){ + if(getStringFromIndexWithDelim(randtypetime,"-", 1, tempbuff, sizeof(tempbuff))== FALSE) + return; + randwrong = atoi(tempbuff); + if(getStringFromIndexWithDelim(randtypetime,"-", 2, tempbuff, sizeof(tempbuff))== FALSE) + return; + randtype = atoi(tempbuff); + if(getStringFromIndexWithDelim(randtypetime,"-", 3, tempbuff, sizeof(tempbuff))== FALSE) + return; + randtime = atoi(tempbuff); +#ifdef _MM_NO_JIAOBEN + if(timep - randtime < getEditBaseTime()*randwrong){ + char errbuf[256]; + sprintf(errbuf,"%dſԼ˲",getEditBaseTime()*randwrong-(timep - randtime)); + CHAR_talkToCli(talkerindex, -1, errbuf, CHAR_COLORRED); + return; + } +#endif + } + } +// if(timep-CHAR_getWorkInt(talkerindex,CHAR_WORKRANDEDITBASETIME)>=getEditBaseTime()) +// CHAR_setWorkInt(talkerindex,CHAR_WORKRANDEDITBASETIME,timep); +// else{ +// char errbuf[256]; +// sprintf(errbuf,"%dſԼ˲",getEditBaseTime()-(timep-CHAR_getWorkInt(talkerindex,CHAR_WORKRANDEDITBASETIME))); +// CHAR_talkToCli(talkerindex, -1, errbuf, CHAR_COLORRED); +// return; +// } + char jiabuf[][5]={"","","","","","ʮ",""}; + char jianbuf[][5]={"","һ","-","","-","",""}; + char chengbuf[][5]={"","*","x","X","","",""}; + char numbuf[][5]={"","","","","","","","","",""}; + char arg[255]; + int i,j,k,l,m; + char buf[256]; + i = RAND(30,70); + j = RAND(1,29); + l = RAND(1,7); + m = RAND(1,3); + char *typebuf; +// if(randtype == 0){ +// randtype = RAND(1,10); +// if(randtype<=5){ +// randtype = RAND(1,10); +// if(randtype<=3) randtype=1; +// else randtype=2; +// }else{ +// randtype = RAND(1,10); +// if(randtype<=3) randtype=3; +// else randtype=4; +// } +// } + randtype = 4; + if(randtype==1){ + if(m==1){ + typebuf=jiabuf[l-1]; + k = i+j; + }else{ + typebuf=jianbuf[l-1]; + k = i-j; + } + char ibuf[10],jbuf[10]; + if(i<10){ + sprintf(ibuf,"%s",numbuf[i]); + }else{ + int ia,ib; + ia = i/10; + ib = i - ia*10; + sprintf(ibuf,"%s",numbuf[ia]); + strcat(ibuf,numbuf[ib]); + } + if(j<10){ + sprintf(jbuf,"%s",numbuf[j]); + }else{ + int ja,jb; + ja = j/10; + jb = j - ja*10; + sprintf(jbuf,"%s",numbuf[ja]); + strcat(jbuf,numbuf[jb]); + } + sprintf(buf,"%d|%d|%s",k,meindex,szMes); + CHAR_setWorkChar(talkerindex,CHAR_WORKRANDMSG,buf); + int fd = getfdFromCharaIndex( talkerindex ); + sprintf(buf,"ʽĽ(%s%s%s=?)",ibuf,typebuf,jbuf); + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGEANDLINEINPUT, + WINDOW_BUTTONTYPE_OK, + CHAR_WINDOWTYPE_NPC_RAND1_MSG, + -1, + buf); + }else if(randtype==2){ + if(m==1){ + typebuf=jiabuf[l-1]; + k = i+j; + }else if(m==2){ + typebuf=jianbuf[l-1]; + k = i-j; + }else{ + typebuf=chengbuf[l-1]; + k = i*j; + } + char ibuf[10],jbuf[10]; + if(i<10){ + sprintf(ibuf,"%s",numbuf[i]); + }else{ + int ia,ib; + ia = i/10; + ib = i - ia*10; + sprintf(ibuf,"%s",numbuf[ia]); + strcat(ibuf,numbuf[ib]); + } + if(j<10){ + sprintf(jbuf,"%s",numbuf[j]); + }else{ + int ja,jb; + ja = j/10; + jb = j - ja*10; + sprintf(jbuf,"%s",numbuf[ja]); + strcat(jbuf,numbuf[jb]); + } + int n; + int randnum1; + char tempret[5][32]; + randnum1 = RAND(1,5); + int randnumbuf[4]; + int tmpi=0; + while(tmpi<100){ + randnumbuf[0] = RAND(1,100); + randnumbuf[1] = RAND(1,100); + randnumbuf[2] = RAND(1,100); + randnumbuf[3] = RAND(1,100); + if(randnumbuf[0]!=randnumbuf[1]!=randnumbuf[2]!=randnumbuf[3]!=k){ + break; + } + tmpi++; + } + tmpi=0; + for(n=1;n<=5;n++){ + if(n==randnum1){ + sprintf(tempret[n-1],"%d",k); + }else if(tmpi<4){ + sprintf(tempret[n-1],"%d",randnumbuf[tmpi]); + tmpi++; + } + } + sprintf(buf,"%d|%d|%s",randnum1,meindex,szMes); + CHAR_setWorkChar(talkerindex, CHAR_WORKRANDMSG, buf); + int fd = getfdFromCharaIndex( talkerindex ); + sprintf(buf,"3\nѡʽĽ(%s%s%s=?)\n \n \nѡһ%s\nѡ%s\nѡ%s\nѡģ%s\nѡ壺%s\n",ibuf,typebuf,jbuf,tempret[0],tempret[1],tempret[2],tempret[3],tempret[4]); + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_SELECT, + WINDOW_BUTTONTYPE_OK, + CHAR_WINDOWTYPE_NPC_RAND2_MSG, + -1, + buf); + }else if(randtype==3){ + sprintf(arg,"%s",sasql_rand_buf()); + if(strcmp(arg,"err")==0) return; + char tempbuf[64]; + char randquestion[64]; + char randrightanswer[64]; + if(getStringFromIndexWithDelim(arg,"|", 1, tempbuf, sizeof(tempbuf)) == FALSE) + return; + strcpy(randquestion,tempbuf); + if(getStringFromIndexWithDelim(arg,"|", 2, tempbuf, sizeof(tempbuf)) == FALSE) + return; + strcpy(randrightanswer,tempbuf); + sprintf(buf,"%s|%d|%s",randrightanswer,meindex,szMes); + CHAR_setWorkChar(talkerindex,CHAR_WORKRANDMSG,buf); + int fd = getfdFromCharaIndex( talkerindex ); + sprintf(buf,"%s:",randquestion); + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGEANDLINEINPUT, + WINDOW_BUTTONTYPE_OK, + CHAR_WINDOWTYPE_NPC_RAND3_MSG, + -1, + buf); + }else{ +// sprintf(arg,"%s",sasql_rand_buf()); +// if(strcmp(arg,"err")==0) return; + char tempbuf[64]; + char randquestion[64]; + char randrightanswer[64]; + char randwronganswer1[64]; + char randwronganswer2[64]; + char randwronganswer3[64]; + char randwronganswer4[64]; +// if(getStringFromIndexWithDelim(arg,"|", 1, tempbuf, sizeof(tempbuf)) == FALSE) +// return; +// strcpy(randquestion,tempbuf); +// if(getStringFromIndexWithDelim(arg,"|", 2, tempbuf, sizeof(tempbuf)) == FALSE) +// return; +// strcpy(randrightanswer,tempbuf); +// if(getStringFromIndexWithDelim(arg,"|", 3, tempbuf, sizeof(tempbuf)) == FALSE) +// return; +// strcpy(randwronganswer1,tempbuf); +// if(getStringFromIndexWithDelim(arg,"|", 4, tempbuf, sizeof(tempbuf)) == FALSE) +// return; +// strcpy(randwronganswer2,tempbuf); +// if(getStringFromIndexWithDelim(arg,"|", 5, tempbuf, sizeof(tempbuf)) == FALSE) +// return; +// strcpy(randwronganswer3,tempbuf); +// if(getStringFromIndexWithDelim(arg,"|", 6, tempbuf, sizeof(tempbuf)) == FALSE) +// return; +// strcpy(randwronganswer4,tempbuf); + memset(tempbuf, 0, sizeof(tempbuf)); + memset(randquestion, 0, sizeof(randquestion)); + memset(randrightanswer, 0, sizeof(randrightanswer)); + memset(randwronganswer1, 0, sizeof(randwronganswer1)); + memset(randwronganswer2, 0, sizeof(randwronganswer2)); + memset(randwronganswer3, 0, sizeof(randwronganswer3)); + memset(randwronganswer4, 0, sizeof(randwronganswer4)); + if(RAND(1,100)<=75){ + char randtmpbuf[4][10]; + sprintf(randtmpbuf[0],"%s",hanzibuf[RAND(1,5000)-1]); + sprintf(randtmpbuf[1],"%s",hanzibuf[RAND(1,5000)-1]); + sprintf(randtmpbuf[2],"%s",hanzibuf[RAND(1,5000)-1]); + sprintf(randtmpbuf[3],"%s",hanzibuf[RAND(1,5000)-1]); + sprintf(randquestion,"%s",str_hanzi_ganrao(randtmpbuf[0],randtmpbuf[1],randtmpbuf[2],randtmpbuf[3],0,0,0,0,0,0)); + strcat(randquestion,"ҳͬ飩"); + int newrand1 = RAND(1,100)-1; + int newrand2 = RAND(1,100)-1; + int newrand3 = RAND(1,100)-1; + int newrand4 = RAND(1,100)-1; + int newrand5 = RAND(1,100)-1; + sprintf(randrightanswer,"%s",str_hanzi_ganrao(randtmpbuf[0],randtmpbuf[1],randtmpbuf[2],randtmpbuf[3],1,newrand1,newrand2,newrand3,newrand4,newrand5)); + sprintf(randwronganswer1,"%s",str_hanzi_ganrao(randtmpbuf[0],randtmpbuf[1],randtmpbuf[3],randtmpbuf[2],1,newrand1,newrand2,newrand3,newrand4,newrand5)); + sprintf(randwronganswer2,"%s",str_hanzi_ganrao(randtmpbuf[3],randtmpbuf[1],randtmpbuf[2],randtmpbuf[0],1,newrand1,newrand2,newrand3,newrand4,newrand5)); + sprintf(randwronganswer3,"%s",str_hanzi_ganrao(randtmpbuf[1],randtmpbuf[0],randtmpbuf[2],randtmpbuf[3],1,newrand1,newrand2,newrand3,newrand4,newrand5)); + sprintf(randwronganswer4,"%s",str_hanzi_ganrao(randtmpbuf[2],randtmpbuf[3],randtmpbuf[0],randtmpbuf[1],1,newrand1,newrand2,newrand3,newrand4,newrand5)); + + }else{ + int tii; + char timubuf[36][5] = {"a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","0","1","2","3","4","5","6","7","8","9"}; + for(tii=0;tii<5;tii++){ + if(tii==0) + strcpy(tempbuf,timubuf[RAND(1,36)-1]); + else{ + int timunum = 0; + while(1){ + timunum = RAND(1,36)-1; + if(strstr(tempbuf,timubuf[timunum])==NULL) + break; + } + strcat(tempbuf,timubuf[timunum]); + } + } + sprintf(randwronganswer1,"[%c%c%c%c%c]",tempbuf[0],tempbuf[2],tempbuf[1],tempbuf[3],tempbuf[4]); + sprintf(randwronganswer2,"[%c%c%c%c%c]",tempbuf[0],tempbuf[1],tempbuf[4],tempbuf[2],tempbuf[3]); + sprintf(randwronganswer3,"[%c%c%c%c%c]",tempbuf[4],tempbuf[1],tempbuf[2],tempbuf[0],tempbuf[3]); + sprintf(randwronganswer4,"[%c%c%c%c%c]",tempbuf[1],tempbuf[0],tempbuf[2],tempbuf[3],tempbuf[4]); + sprintf(randquestion,"[%s]ҳͬӢģ",tempbuf); + sprintf(randrightanswer,"[%s]",tempbuf); + char* randstr = NULL; + randstr = str_ganrao(randquestion); + strcpy(randquestion,randstr); + randstr = str_ganraoan(randrightanswer); + strcpy(randrightanswer,randstr); + randstr = str_ganraoan(randwronganswer1); + strcpy(randwronganswer1,randstr); + randstr = str_ganraoan(randwronganswer2); + strcpy(randwronganswer2,randstr); + randstr = str_ganraoan(randwronganswer3); + strcpy(randwronganswer3,randstr); + randstr = str_ganraoan(randwronganswer4); + strcpy(randwronganswer4,randstr); + } + int n; + int randnum1; + m=1; + char tempret[5][64]; + randnum1 = RAND(1,5); + int rightnum,wrongnum1,wrongnum2,wrongnum3,wrongnum4; + rightnum = RAND(getRandMin(),getRandMax()); + wrongnum1 = RAND(getRandMin(),getRandMax()); + wrongnum2 = RAND(getRandMin(),getRandMax()); + wrongnum3 = RAND(getRandMin(),getRandMax()); + wrongnum4 = RAND(getRandMin(),getRandMax()); + //char *tempbuff2 = "ABCDE"; + int qianhounum = RAND(1,100); + for(n=1;n<=5;n++){ + if(n==randnum1){ + if(qianhounum<=50) + sprintf(tempret[n-1],"ѡ( %d %s )",rightnum,randrightanswer); + else + sprintf(tempret[n-1],"ѡ( %s %d )",randrightanswer,rightnum); + }else{ + if(m==1){ + if(qianhounum<=50) + sprintf(tempret[n-1],"ѡ( %d %s )",wrongnum1,randwronganswer1); + else + sprintf(tempret[n-1],"ѡ( %s %d )",randwronganswer1,wrongnum1); + m = 2; + }else if(m==2){ + if(qianhounum<=50) + sprintf(tempret[n-1],"ѡ( %d %s )",wrongnum2,randwronganswer2); + else + sprintf(tempret[n-1],"ѡ( %s %d )",randwronganswer2,wrongnum2); + m = 3; + }else if(m==3){ + if(qianhounum<=50) + sprintf(tempret[n-1],"ѡ( %d %s )",wrongnum3,randwronganswer3); + else + sprintf(tempret[n-1],"ѡ( %s %d )",randwronganswer3,wrongnum3); + m = 4; + }else if(m==4){ + if(qianhounum<=50) + sprintf(tempret[n-1],"ѡ( %d %s )",wrongnum4,randwronganswer4); + else + sprintf(tempret[n-1],"ѡ( %s %d )",randwronganswer4,wrongnum4); + m = 5; + } + } + } + int windowtype = 0; + int selecttype = RAND(1,100); + if(selecttype<=30){ + sprintf(buf,"%d|%d|%s",rightnum,meindex,szMes); + windowtype = WINDOW_MESSAGETYPE_MESSAGEANDLINEINPUT; + }else{ + sprintf(buf,"%d|%d|%s",randnum1,meindex,szMes); + windowtype = WINDOW_MESSAGETYPE_SELECT; + } + CHAR_setWorkChar(talkerindex, CHAR_WORKRANDMSG, buf); + int fd = getfdFromCharaIndex( talkerindex ); + sprintf(buf,"%s\n%s\n%s\n%s\n%s\n%s\nȷڵ5λֻߵѡ",randquestion,tempret[0],tempret[1],tempret[2],tempret[3],tempret[4]); + lssproto_WN_send( fd, windowtype, + WINDOW_BUTTONTYPE_OK, + CHAR_WINDOWTYPE_NPC_RAND4_MSG, + -1, + buf); + CHAR_setWorkInt(talkerindex,CHAR_WORKLUANPCINT,0); + } + if(randwrong<=0){ + sprintf(tempbuff,"1-%d-%d",randtype,timep); + }else{ + sprintf(tempbuff,"%d-%d-%d",randwrong*3,randtype,timep); + } + CHAR_setChar(talkerindex,CHAR_RANDTYPE,tempbuff); + return; + } +#endif + + /*-- --*/ + NPC_TypeCheck( meindex, talkerindex, szMes); + +} + +/*------------------------------------------------------------ + *ɬð̻ë ģؤ ë + *-------------------------------------------------------------*/ +BOOL NPC_TypeCheck(int meindex,int talker,char *szMes) +{ + + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + char buf[1024*2]; + char buf2[512]; + int i = 1; + int EvNo; + int evch; + int q=1; + + /*--ɬð̻ë --*/ + if(NPC_Util_GetArgStr( meindex, argstr, sizeof(argstr)) == NULL) { + print("NPC_ExChange.c TypeCheck: GetArgStrErr\n"); + print("NPCName=%s\n", CHAR_getChar(meindex,CHAR_NAME)); + return FALSE; + } + + /*-- ɬð̻ë --*/ + while(getStringFromIndexWithDelim( argstr,"EventEnd",i,buf,sizeof( buf)) + != FALSE){ + i++; + CHAR_setWorkInt( talker, CHAR_WORKSHOPRELEVANT, 0); + CHAR_setWorkInt( talker, CHAR_WORKSHOPRELEVANTSEC, 0); + + /*-- ìϼë --*/ + if(NPC_Util_GetStrFromStrWithDelim(buf,"EventNo", + buf2, sizeof( buf2) ) == NULL) continue; + + if(strstr( buf2, "-") != 0) { + EvNo = -1; + }else{ + if(strstr(buf2,",") != NULL){ + char buf3[512]; + while(getStringFromIndexWithDelim( buf2, ",", q, buf3, sizeof( buf3)) + != FALSE) { + q++; + } + q--; + q = rand()%q + 1; + getStringFromIndexWithDelim( buf2, ",", q, buf3, sizeof( buf3)); + EvNo = atoi( buf3); + }else{ + EvNo = atoi( buf2); + } + } + + /*-- ׷ºë浤ƥì ƻݳ --*/ + if(NPC_EventCheckFlg( talker, EvNo) == TRUE) continue; + + /*--ƽë浤--*/ + if(NPC_Util_GetStrFromStrWithDelim( buf,"KeyWord", buf2,sizeof( buf2) ) + != NULL){ + if(strcmp( szMes, buf2) != 0) continue; + CHAR_setWorkInt( talker, CHAR_WORKSHOPRELEVANT, i); + } + + /*--ʸ 󡼰ͻ Ȼ¾ë--*/ + if(NPC_Util_GetStrFromStrWithDelim( buf,"Pet_Name", buf2,sizeof( buf2)) != NULL){ + CHAR_setWorkInt( talker, CHAR_WORKSHOPRELEVANTSEC, 1); + } + evch = NPC_ExChangeManEventCheck( meindex, talker, buf); + if(evch != -1) { + if(NPC_Util_GetStrFromStrWithDelim( buf,"TYPE", buf2, sizeof( buf2)) != NULL){ + + if( strstr( buf2, "REQUEST") != NULL) { + NPC_RequestMain( meindex, talker, buf); + return TRUE; + }else if( strstr( buf2, "ACCEPT") != NULL) { + /*- ë --*/ + NPC_AcceptMain( meindex, talker, buf); + return TRUE; + + }else if(strstr( buf2, "MESSAGE") != NULL) { + char token[14*100]; + char token2[14*100]; + if(NPC_Util_GetStrFromStrWithDelim( buf,"NomalMsg", token,sizeof( token) ) + != NULL ) { + if(NPC_AcceptDel( meindex, talker, 0) == FALSE) return FALSE; + if(EvNo != -1) + NPC_NowEventSetFlg( talker, EvNo); + CHAR_talkToCli( talker, meindex, token, CHAR_COLORWHITE); + if(NPC_Util_GetStrFromStrWithDelim( buf,"NpcWarp", token2,sizeof( token2) ) + != NULL){ + NPC_EventWarpNpc(meindex,token2); + } + if(NPC_Util_GetStrFromStrWithDelim( buf, "EndSetFlg", buf2, sizeof( buf2) ) + !=NULL){ + char buf3[16]; + int k = 1; + if(EvNo != -1) NPC_NowEventSetFlgCls( talker, EvNo); + while(getStringFromIndexWithDelim(buf2 , "," ,k, buf3, sizeof(buf3)) + !=FALSE ){ + k++; + NPC_EventSetFlg( talker, atoi( buf3)); + } + } + if( NPC_Util_GetStrFromStrWithDelim( buf, "CleanFlg", + buf2, sizeof( buf2)) != NULL) { + char buf3[16]; + int k = 1; + k= 1 ; + while(getStringFromIndexWithDelim(buf2 , "," , k, + buf3, sizeof(buf3)) + != FALSE ){ + NPC_EndEventSetFlgCls( talker, atoi(buf3)); + k++; + } + } +#ifdef _ANGEL_SUMMON + // ٻ + if( NPC_Util_GetStrFromStrWithDelim( buf, "MISSIONOVER", + buf2, sizeof( buf2)) != NULL) + { + int mindex; + int mission; + char nameinfo[64]; + + mission = atoi( buf2); + mindex = checkIfAngel(talker); + + if( mission == missiontable[mindex].mission ) + { + char msg[1024]; + + print(" ====ٻ==== "); + + CHAR_setInt( talker, CHAR_HEROCNT, + CHAR_getInt( talker, CHAR_HEROCNT)+1 ); + getMissionNameInfo( talker, nameinfo); + saacproto_ACMissionTable_send( acfd, MISSION_HERO_COMPLETE, 4, nameinfo, ""); + sprintf( msg, " i:%d m:%d %s ", mindex, mission, nameinfo); + print( msg); + LogAngel( msg ); + } + + } + + // ٻ + if( NPC_Util_GetStrFromStrWithDelim( buf, "MISSIONCLEAN", + buf2, sizeof( buf2)) != NULL) + { + int mindex; + int mission; + char nameinfo[64]; + + mission = atoi( buf2); + mindex = checkIfAngel( talker); + + if( mission == missiontable[mindex].mission ) + { + char msg[1024]; + + getMissionNameInfo( talker, nameinfo); + saacproto_ACMissionTable_send( acfd, mindex, 3, nameinfo, ""); + + sprintf( msg, " i:%d m:%d %s ", mindex, mission, nameinfo); + print( msg); + LogAngel( msg ); + } + + } +#endif + + }else if(NPC_Util_GetStrFromStrWithDelim(buf, "NomalWindowMsg", + token, sizeof( token) ) + !=NULL) { + /*--̼ƥë߯--*/ + int fd = getfdFromCharaIndex( talker); +#ifdef _NEWEVENT + if(NPC_Util_GetStrFromStrWithDelim(buf, "NomalWindowMsg1", + buf2, sizeof(buf2)) != NULL){ + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_NEXT, + CHAR_WINDOWTYPE_WINDOWEVENT_STARTMSG, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + token); + }else { +#endif + char token2[14*100]; + if(NPC_AcceptDel( meindex, talker,0) == FALSE) return FALSE; + if( EvNo != -1) NPC_NowEventSetFlg( talker, EvNo); + + if(NPC_Util_GetStrFromStrWithDelim( buf,"NpcWarp", + token2,sizeof( token2) ) != NULL){ + NPC_EventWarpNpc(meindex,token2); + } + if(NPC_Util_GetStrFromStrWithDelim( buf, "EndSetFlg", + buf2, sizeof( buf2) ) !=NULL){ + char buf3[16]; + int k = 1; + if(EvNo != -1) NPC_NowEventSetFlgCls( talker, EvNo); + while(getStringFromIndexWithDelim(buf2 , "," ,k, + buf3, sizeof(buf3)) !=FALSE ){ + k++; + NPC_EventSetFlg( talker, atoi( buf3)); + } + } + //ì׷ºë + if( NPC_Util_GetStrFromStrWithDelim( buf, "CleanFlg", + buf2, sizeof( buf2)) != NULL) { + char buf3[16]; + int k = 1; + + k= 1 ; + while(getStringFromIndexWithDelim(buf2 , "," , k, + buf3, sizeof(buf3)) != FALSE ){ + NPC_EndEventSetFlgCls( talker, atoi(buf3)); + k++; + } + } +#ifdef _ANGEL_SUMMON + // ٻ + if( NPC_Util_GetStrFromStrWithDelim( buf, "MISSIONOVER", + buf2, sizeof( buf2)) != NULL) + { + int mindex; + int mission; + char nameinfo[64]; + + mission = atoi( buf2); + mindex = checkIfAngel( talker); + + if( mission == missiontable[mindex].mission ) + { + char msg[1024]; + + print(" ====ٻ==== "); + + CHAR_setInt( talker, CHAR_HEROCNT, + CHAR_getInt( talker, CHAR_HEROCNT)+1 ); + getMissionNameInfo( talker, nameinfo); + saacproto_ACMissionTable_send( acfd, MISSION_HERO_COMPLETE, 4, nameinfo, ""); + sprintf( msg, " i:%d m:%d %s ", mindex, mission, nameinfo); + print( msg); + LogAngel( msg ); + } + + } + + // ٻ + if( NPC_Util_GetStrFromStrWithDelim( buf, "MISSIONCLEAN", + buf2, sizeof( buf2)) != NULL) + { + int mindex; + int mission; + char nameinfo[64]; + + mission = atoi( buf2); + mindex = checkIfAngel( talker); + + if( mission == missiontable[mindex].mission ) + { + print(" ====ٻ==== "); + + getMissionNameInfo( talker, nameinfo); + saacproto_ACMissionTable_send( acfd, mindex, 3, nameinfo, ""); + } + + } +#endif + + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_YES, + CHAR_WINDOWTYPE_WINDOWEVENT_STARTMSG, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + token); +#ifdef _NEWEVENT + } +#endif + } + + return TRUE; + + }else if(strstr( buf2, "CLEAN") != NULL) { + NPC_CleanMain( meindex, talker, buf); + return TRUE; + } + } + } + } + + strcpy( buf, "\0"); + if( NPC_Util_GetStrFromStrWithDelim( argstr, "NomalMainMsg", buf, sizeof( buf)) == NULL ) { + print("\n err:NOT FIND NomalMainMsg"); + return FALSE; + } + i = 1; + while(getStringFromIndexWithDelim( buf, ",", i, buf2, sizeof( buf2))!= FALSE){ + i++; + } + i--; + i = rand()%i + 1; + getStringFromIndexWithDelim( buf,",", i, buf2, sizeof( buf2)); + CHAR_talkToCli( talker, meindex, buf2, CHAR_COLORWHITE); + return TRUE; +} + + +/*----------------------------------- + * ë + ------------------------------------*/ +static void NPC_ExChangeMan_selectWindow( int meindex, int talker,int num) +{ + + switch( num) { + /*--;޵--*/ + case 0: + /*-ì ئƥìë¾ë --*/ + NPC_MsgDisp( meindex, talker, 0); + break; + + case 1: + /*--ޥì浤--*/ + NPC_MsgDisp( meindex, talker, 5); + break; + + /*--ʧͱ--*/ + case 2: + /*--Ի--*/ + NPC_MsgDisp( meindex, talker, 6); + break; + + case 3: + /*--Ի--*/ + NPC_MsgDisp( meindex, talker, 11); + break; + } + +} + +/*------------------------------------- + *ìë ̼ + --------------------------------------*/ +void NPC_RequestMain(int meindex,int talker,char *buf) +{ + int shiftbit; + char buf2[128]; + int q=1; + /*--ìϼë--*/ + NPC_Util_GetStrFromStrWithDelim( buf,"EventNo", buf2,sizeof( buf2) ); + if(strstr(buf2,",") != NULL){ + char buf3[128]; + while(getStringFromIndexWithDelim( buf2, ",", q, buf3, sizeof( buf3)) + != FALSE) { + q++; + } + q--; + q = rand()%q + 1; + getStringFromIndexWithDelim( buf2, ",", q, buf3, sizeof( buf3)); + shiftbit = atoi( buf3); + }else{ + shiftbit = atoi( buf2); + } + + if(NPC_NowEventCheckFlg( talker, shiftbit) == TRUE) { + NPC_ExChangeMan_selectWindow( meindex, talker, 0); + }else{ + NPC_ExChangeMan_selectWindow( meindex, talker, 1); + } +} + +/*--------------------------------------- + * ì ̼ + ----------------------------------------*/ +void NPC_AcceptMain(int meindex,int talker ,char *buf) +{ + + NPC_ExChangeMan_selectWindow( meindex, talker, 2); +} + +/*---------------------------------------- + * ׷ºëʧ¿м̼ + ----------------------------------------*/ +void NPC_CleanMain(int meindex,int talker,char *buf) +{ + NPC_ExChangeMan_selectWindow( meindex, talker, 3); +} + +/*----------------------------------------- +ͷʧ߯Ȼݱ̫ľ£ +-------------------------------------------*/ +void NPC_ExChangeManWindowTalked( int meindex, int talkerindex, + int seqno, int select, char *data) +{ + /*-- Իئ巴 --*/ + if( NPC_Util_CharDistance( talkerindex, meindex ) > 2) { + return; + } + + + switch( seqno) { + + /*--׷ºëݼ̼--*/ + case CHAR_WINDOWTYPE_WINDOWEVENT_CLEANMSG: + if( select == WINDOW_BUTTONTYPE_YES) { + NPC_MsgDisp( meindex, talkerindex, 12); + }else if(select == WINDOW_BUTTONTYPE_NO) { + } + break; + +#ifdef _NEWEVENT + case CHAR_WINDOWTYPE_WINDOWEVENT_STARTMSG: + if(select == WINDOW_BUTTONTYPE_NEXT) { + CHAR_setWorkInt(talkerindex,CHAR_WORKSHOPRELEVANTTRD, + CHAR_getWorkInt(talkerindex,CHAR_WORKSHOPRELEVANTTRD) + 1); + NPC_MsgDisp( meindex, talkerindex, 99); + }else if(select == WINDOW_BUTTONTYPE_PREV) { + CHAR_setWorkInt(talkerindex,CHAR_WORKSHOPRELEVANTTRD, + CHAR_getWorkInt(talkerindex,CHAR_WORKSHOPRELEVANTTRD) - 1); + NPC_MsgDisp( meindex, talkerindex, 99); + } + break; +#else + case CHAR_WINDOWTYPE_WINDOWEVENT_STARTMSG: + break; +#endif + /*--;޵ؤԻ絤--*/ + case CHAR_WINDOWTYPE_WINDOWEVENT_REQTHANK: + if(select == WINDOW_BUTTONTYPE_NEXT) { + CHAR_setWorkInt(talkerindex,CHAR_WORKSHOPRELEVANTTRD, + CHAR_getWorkInt(talkerindex,CHAR_WORKSHOPRELEVANTTRD)+1); + NPC_MsgDisp( meindex, talkerindex, 22); + }else if(select == WINDOW_BUTTONTYPE_PREV) { + CHAR_setWorkInt(talkerindex,CHAR_WORKSHOPRELEVANTTRD, + CHAR_getWorkInt(talkerindex,CHAR_WORKSHOPRELEVANTTRD)-1); + NPC_MsgDisp( meindex, talkerindex, 22); + } + break; + + /*--ʧͱؤԻ絤--*/ + case CHAR_WINDOWTYPE_WINDOWEVENT_ACCTHANK: + if(select == WINDOW_BUTTONTYPE_NEXT) { + CHAR_setWorkInt(talkerindex,CHAR_WORKSHOPRELEVANTTRD, + CHAR_getWorkInt(talkerindex,CHAR_WORKSHOPRELEVANTTRD)+1); + NPC_MsgDisp( meindex, talkerindex, 82); + }else if(select == WINDOW_BUTTONTYPE_PREV) { + CHAR_setWorkInt(talkerindex,CHAR_WORKSHOPRELEVANTTRD, + CHAR_getWorkInt(talkerindex,CHAR_WORKSHOPRELEVANTTRD)-1); + NPC_MsgDisp( meindex, talkerindex, 82); + } + break; + + /*--ػìë¾--*/ + case CHAR_WINDOWTYPE_WINDOWEVENT_NOWEVENT: + if(select == WINDOW_BUTTONTYPE_YES) { + NPC_MsgDisp( meindex, talkerindex, 7); + }else if(select == WINDOW_BUTTONTYPE_NO){ + NPC_MsgDisp( meindex, talkerindex, 1); + } + break; + + /*--;޵̼̼--*/ + case CHAR_WINDOWTYPE_WINDOWEVENT_REQMAINMSG: + if(select == WINDOW_BUTTONTYPE_YES) { + CHAR_setWorkInt(talkerindex,CHAR_WORKSHOPRELEVANTTRD,0); + NPC_MsgDisp( meindex, talkerindex, 2); + }else if(select == WINDOW_BUTTONTYPE_NO) { + + }else if(select == WINDOW_BUTTONTYPE_NEXT) { + CHAR_setWorkInt(talkerindex,CHAR_WORKSHOPRELEVANTTRD, + CHAR_getWorkInt(talkerindex,CHAR_WORKSHOPRELEVANTTRD)+1); + NPC_MsgDisp( meindex, talkerindex, 55); + }else if(select == WINDOW_BUTTONTYPE_PREV) { + CHAR_setWorkInt(talkerindex,CHAR_WORKSHOPRELEVANTTRD, + CHAR_getWorkInt(talkerindex,CHAR_WORKSHOPRELEVANTTRD)-1); + NPC_MsgDisp( meindex, talkerindex, 55); + } + break; + + /*--Ի̼̼--*/ + case CHAR_WINDOWTYPE_WINDOWEVENT_ACCMAINMSG: + if(select == WINDOW_BUTTONTYPE_YES) { + CHAR_setWorkInt(talkerindex,CHAR_WORKSHOPRELEVANTTRD,0); +#ifdef _NEWEVENT + NPC_MsgDisp( meindex, talkerindex, 81); +#else + NPC_MsgDisp( meindex, talkerindex, 8); +#endif + }else if(select == WINDOW_BUTTONTYPE_NO) { + }else if(select == WINDOW_BUTTONTYPE_NEXT) { + CHAR_setWorkInt(talkerindex,CHAR_WORKSHOPRELEVANTTRD, + CHAR_getWorkInt(talkerindex,CHAR_WORKSHOPRELEVANTTRD)+1); + NPC_MsgDisp( meindex, talkerindex, 66); + }else if(select == WINDOW_BUTTONTYPE_PREV) { + CHAR_setWorkInt(talkerindex,CHAR_WORKSHOPRELEVANTTRD, + CHAR_getWorkInt(talkerindex,CHAR_WORKSHOPRELEVANTTRD)-1); + NPC_MsgDisp( meindex, talkerindex, 66); + } + break; + +#ifdef _NEWEVENT + case CHAR_WINDOWTYPE_WINDOWEVENT_ACCTHANKNEW: + if(select == WINDOW_BUTTONTYPE_OK){ + CHAR_setWorkInt(talkerindex,CHAR_WORKSHOPRELEVANTTRD,0); + NPC_MsgDisp( meindex, talkerindex, 8); + }else if(select == WINDOW_BUTTONTYPE_NEXT) { + CHAR_setWorkInt(talkerindex,CHAR_WORKSHOPRELEVANTTRD, + CHAR_getWorkInt(talkerindex,CHAR_WORKSHOPRELEVANTTRD)+1); + NPC_MsgDisp( meindex, talkerindex, 81); + }else if(select == WINDOW_BUTTONTYPE_PREV) { + CHAR_setWorkInt(talkerindex,CHAR_WORKSHOPRELEVANTTRD, + CHAR_getWorkInt(talkerindex,CHAR_WORKSHOPRELEVANTTRD)-1); + NPC_MsgDisp( meindex, talkerindex, 81); + } + break; +#endif + /*--ʸ ëܸ̼--*/ + case CHAR_WINDOWTYPE_WINDOWPETSKILLSHOP: + if(CHAR_getWorkInt( talkerindex ,CHAR_WORKSHOPRELEVANTTRD) ==0) { + NPC_EventPetSkill( meindex, talkerindex, data); + NPC_MsgDisp( meindex, talkerindex, 25); + }else{ + NPC_EventPetSkill( meindex, talkerindex, data); + NPC_MsgDisp( meindex, talkerindex, 88); + } + break; + } +} + + +/*------------------------- + * ëƻ¾ + --------------------------*/ +int NPC_ExChangeManEventCheck( int meindex, int talker, char *buff1) +{ + char buff2[512]; + char buff3[128]; + char buf[512]; + int i = 1,j = 1; + int loop = 0; + + NPC_Util_GetStrFromStrWithDelim( buff1, "EVENT", buf, sizeof( buf)); + + /*-- EVENtë έ --*/ + while( getStringFromIndexWithDelim(buf, ",", i, buff2,sizeof( buff2)) + !=FALSE ) + { + i++; + /*-- "&"ؤ¼ƥ --*/ + if(strstr( buff2, "&")!=NULL){ + j = 1; + loop = 0; + while(getStringFromIndexWithDelim(buff2, "&", j, buff3, sizeof( buff3)) + != FALSE ) + { + j++; + if(NPC_EventBigSmallCheck( meindex, talker, buff3) == FALSE) + { + loop = 1; + break; + } + } + + if(loop == 0){ + i--; + return i; + } + /*--繴--*/ + }else{ + if(NPC_EventBigSmallCheck( meindex, talker, buff2) == TRUE) { + i--; + return i; + } + } + + } + + return -1; + +} + +/*--------------------------------- + * į + --------------------------------*/ +BOOL NPC_EventBigSmallCheck(int meindex,int talker, char* buf) +{ + + char buff2[128]; + int kosuu; + + /*--ʸͻȻPETë --*/ + if(strstr( buf, "PET") != NULL) { + if(strstr( buf, "EV") != NULL) { + if(NPC_PetLvCheck( meindex, talker, buf, 1) != FALSE) return TRUE; + }else{ + if(NPC_PetLvCheck( meindex, talker, buf, 0) != FALSE) return TRUE; + } + return FALSE; + } +#ifdef _NPC_PETSKILLUP + if(strstr( buf, "PSKILL") != NULL) { + if(strstr( buf, "EV") != NULL) { + if(NPC_PetSkillCheck( meindex, talker, buf, 1) != FALSE) return TRUE; + }else{ + if(NPC_PetSkillCheck( meindex, talker, buf, 0) != FALSE) return TRUE; + } + return FALSE; + } +#endif + /*--Ʊ ɧį --*/ + if(strstr( buf, "<") != NULL) { + getStringFromIndexWithDelim( buf, "<", 2, buff2, sizeof( buff2)); + kosuu = atoi( buff2); + getStringFromIndexWithDelim( buf, "<", 1, buff2, sizeof( buff2)); + + if(NPC_EventFreeIfCheck( meindex, talker, buff2, kosuu, 1) == TRUE) { + return TRUE; + } + + }else if(strstr( buf, ">") != NULL) { + getStringFromIndexWithDelim( buf, ">", 2, buff2, sizeof(buff2)); + kosuu = atoi(buff2); + getStringFromIndexWithDelim( buf, ">" ,1, buff2, sizeof(buff2)); + + if(NPC_EventFreeIfCheck( meindex, talker, buff2, kosuu, 2)==TRUE) { + return TRUE; + } + + }else if(strstr( buf, "!=" ) != NULL) { + getStringFromIndexWithDelim( buf, "!=", 2, buff2, sizeof( buff2)); + kosuu = atoi( buff2); + getStringFromIndexWithDelim( buf, "!=", 1, buff2, sizeof( buff2)); + if(NPC_EventFreeIfCheck( meindex, talker, buff2, kosuu, 3) == TRUE) { + return TRUE; + } + + }else if(strstr( buf, "=") != NULL) { + getStringFromIndexWithDelim( buf, "=", 2, buff2, sizeof( buff2)); + kosuu = atoi( buff2); + getStringFromIndexWithDelim( buf, "=", 1, buff2, sizeof( buff2)); + + if(strstr( buf, "*") != NULL) { + if(NPC_EventReduce( meindex, talker, buf) == TRUE){ + return TRUE; + } + }else if(NPC_EventFreeIfCheck( meindex, talker, buff2, kosuu, 0) + == TRUE) + { + return TRUE; + } + } + + return FALSE; + +} + + +/*----------------------------------- + * ë ƻ¾ + *-----------------------------------*/ +BOOL NPC_EventFreeIfCheck(int meindex,int talker,char* buf,int kosuu,int flg) +{ + + /*--ì--*/ + if(strcmp( buf, "LV") == 0) { + if(NPC_EventLevelCheck( meindex, talker, kosuu, flg) == TRUE) { + return TRUE; + } + } + + if(strcmp( buf, "AMPOINT") == 0) { + if(NPC_EventAmPointCheck( meindex, talker, kosuu, flg) == TRUE) { + return TRUE; + } + } + + if(strcmp( buf, "FAME") == 0) { + if(NPC_EventFameCheck( meindex, talker, kosuu, flg) == TRUE) { + return TRUE; + } + } +#ifndef _CAX_NPCTIME_OFF + if(strcmp( buf, "YEAR") == 0) { + if(NPC_EventYearCheck( meindex, talker, kosuu, flg) == TRUE) { + return TRUE; + } + } + if(strcmp( buf, "MON") == 0) { + if(NPC_EventMonCheck( meindex, talker, kosuu, flg) == TRUE) { + return TRUE; + } + } + if(strcmp( buf, "DATE") == 0) { + if(NPC_EventDateCheck( meindex, talker, kosuu, flg) == TRUE) { + return TRUE; + } + } + if(strcmp( buf, "DAY") == 0) { + if(NPC_EventDayCheck( meindex, talker, kosuu, flg) == TRUE) { + return TRUE; + } + } + if(strcmp( buf, "HOUR") == 0) { + if(NPC_EventHourCheck( meindex, talker, kosuu, flg) == TRUE) { + return TRUE; + } + } + + if(strcmp( buf, "MIN") == 0) { + if(NPC_EventMinCheck( meindex, talker, kosuu, flg) == TRUE) { + return TRUE; + } + } + + if(strcmp( buf, "SEC") == 0) { + if(NPC_EventSecCheck( meindex, talker, kosuu, flg) == TRUE) { + return TRUE; + } + } +#endif + + if(strcmp(buf,"VIP")==0){ + if(NPC_EventVipCheck(meindex,talker,kosuu,flg)==TRUE) + return TRUE; + } + + if(strcmp(buf,"SUPER")==0){ + if(NPC_EventSuperCheck(meindex,talker,kosuu,flg)==TRUE) + return TRUE; + } + + if(strcmp(buf,"VIPPOINT")==0){ + if(NPC_EventVipPointCheck(meindex,talker,kosuu,flg)==TRUE) + return TRUE; + } + + if(strcmp(buf,"NPCTIME")==0){ + if(NPC_EventNpcTimeCheck(meindex,talker,kosuu,flg)==TRUE) + return TRUE; + } + +#ifdef _EV_NUM + if(strcmp(buf,"EVNUM")==0){ + if(NPC_EventEvNumCheck(meindex,talker,kosuu,flg)==TRUE) + return TRUE; + } + if(strcmp(buf,"EVTHINGS")==0){ + int evitem; + evitem = CHAR_getInt(talker,CHAR_EVITEM); + if(evitem>0){ + if(NPC_EventItemCheck(meindex,talker,evitem,flg)==TRUE) + return TRUE; + }else{ + return TRUE; + } + } + if(strcmp(buf,"EVCODE")==0){ + if(NPC_EventEvCodeCheck(meindex,talker,kosuu,flg)==TRUE) + return TRUE; + } +#endif + +#ifdef _ALL_ITEM + if(strcmp(buf,"ALLNUM1")==0){ + if(NPC_EventAllNum1Check(meindex,talker,kosuu,flg)==TRUE) + return TRUE; + } + if(strcmp(buf,"ALLNUM2")==0){ + if(NPC_EventAllNum2Check(meindex,talker,kosuu,flg)==TRUE) + return TRUE; + } + if(strcmp(buf,"ALLNUM3")==0){ + if(NPC_EventAllNum3Check(meindex,talker,kosuu,flg)==TRUE) + return TRUE; + } + if(strcmp(buf,"ALLNUM4")==0){ + if(NPC_EventAllNum4Check(meindex,talker,kosuu,flg)==TRUE) + return TRUE; + } + if(strcmp(buf,"ALLNUM5")==0){ + if(NPC_EventAllNum5Check(meindex,talker,kosuu,flg)==TRUE) + return TRUE; + } +#endif + + if(strcmp(buf,"EQUIT")==0){ + if(NPC_EventEquitCheck(meindex,talker,kosuu,flg)==TRUE) + return TRUE; + } + + /*--ʧ ة--*/ + if(strcmp( buf, "ITEM") == 0) { + if(NPC_EventItemCheck( meindex, talker, kosuu, flg) == TRUE) { + return TRUE; + } + } + + /*-- ì--*/ + if(strcmp( buf, "ENDEV") == 0) { + if(NPC_ENDEventNoCheck( meindex, talker, kosuu, flg) == TRUE) { + return TRUE; + } + } + + if(strcmp( buf, "NOWEV") == 0) { + if(NPC_NOWEventNoCheck( meindex, talker, kosuu, flg) == TRUE) { + return TRUE; + } + } + + if(strcmp( buf, "SP" ) == 0) { + if(NPC_SavePointCheck( meindex, talker, kosuu, flg) == TRUE) { + return TRUE; + } + } + + if(strcmp( buf, "TIME") == 0) { + if(NPC_TiemCheck( meindex, talker, kosuu, flg) == TRUE) { + return TRUE; + } + } +#ifdef _CAX_NPCTIME_IF +/*CCIS_WXscript add 09/02/21 ENENT CHECK */ + if(strcmp( buf, "HOUR") == 0) { + if(NPC_TiemCheckWithHour( meindex, talker, kosuu, flg) == TRUE) { + return TRUE; + } + } + if(strcmp( buf, "DAY") == 0) { + if(NPC_TiemCheckWithDay ( meindex, talker, kosuu, flg) == TRUE) { + return TRUE; + } + } +/*CCIS_WXscript add 09/02/21 ENENT CHECK */ +#endif + +#ifdef _PROFESSION_SKILL // WON ADD ְҵ + if(strcmp(buf,"CLASS")==0){ + if(NPC_ActionClassCheck(meindex,talker,kosuu,flg)==TRUE) + return TRUE; + } +#endif + + if(strcmp( buf, "IMAGE") == 0) { + if(NPC_ImageCheck( meindex, talker, kosuu, flg) == TRUE) { + return TRUE; + } + } + +#ifdef _ANGEL_SUMMON + if(strcmp(buf,"ANGEL_NOW")==0){ + if( NPC_ActionMissionAngelCheck(meindex,talker,kosuu, MISSION_DOING, 0)==TRUE) + return TRUE; + } + if(strcmp(buf,"HERO_NOW")==0){ + if( NPC_ActionMissionHeroCheck(meindex,talker,kosuu, MISSION_DOING, 0)==TRUE) + return TRUE; + } + if(strcmp(buf,"ANGEL_OVER")==0){ + if( NPC_ActionMissionAngelCheck(meindex,talker,kosuu, MISSION_HERO_COMPLETE, 0)==TRUE) + return TRUE; + } + if(strcmp(buf,"HERO_OVER")==0){ + if( NPC_ActionMissionHeroCheck(meindex,talker,kosuu, MISSION_HERO_COMPLETE, 0)==TRUE) + return TRUE; + } + if(strcmp(buf,"ANGEL_OUT")==0){ + if( NPC_ActionMissionAngelCheck(meindex,talker,kosuu, MISSION_TIMEOVER, 0)==TRUE) + return TRUE; + } + if(strcmp(buf,"HERO_OUT")==0){ + if( NPC_ActionMissionHeroCheck(meindex,talker,kosuu, MISSION_TIMEOVER, 0)==TRUE) + return TRUE; + } + + if(strcmp(buf,"ANGEL_I_NOW")==0){ + if( NPC_ActionMissionAngelCheck(meindex,talker,kosuu, MISSION_DOING, TRUE)==TRUE) + return TRUE; + } + if(strcmp(buf,"HERO_I_NOW")==0){ + if( NPC_ActionMissionHeroCheck(meindex,talker,kosuu, MISSION_DOING, TRUE)==TRUE) + return TRUE; + } + if(strcmp(buf,"ANGEL_I_OVER")==0){ + if( NPC_ActionMissionAngelCheck(meindex,talker,kosuu, MISSION_HERO_COMPLETE, TRUE)==TRUE) + return TRUE; + } + if(strcmp(buf,"HERO_I_OVER")==0){ + if( NPC_ActionMissionHeroCheck(meindex,talker,kosuu, MISSION_HERO_COMPLETE, TRUE)==TRUE) + return TRUE; + } + if(strcmp(buf,"ANGEL_I_OUT")==0){ + if( NPC_ActionMissionAngelCheck(meindex,talker,kosuu, MISSION_TIMEOVER, TRUE)==TRUE) + return TRUE; + } + if(strcmp(buf,"HERO_I_OUT")==0){ + if( NPC_ActionMissionHeroCheck(meindex,talker,kosuu, MISSION_TIMEOVER, TRUE)==TRUE) + return TRUE; + } + if(strcmp( buf, "HEROCNT") == 0) { + //if(NPC_EventLevelCheck( meindex, talker, kosuu, flg) == TRUE) { + if(NPC_HeroCompleteCountCheck( meindex, talker, kosuu, flg) == TRUE) + return TRUE; + } + +#endif + + if(strcmp(buf, "SKUP")==0){ + int myskup; + myskup = CHAR_getInt(talker,CHAR_SKILLUPPOINT); + if(NPC_EventBigSmallLastCheck( kosuu, myskup, flg) == TRUE) + return TRUE; + } +#ifdef _NPC_EXCHANGEMANTRANS + //жת + { + //print("\nжת"); + if(strcmp(buf,"TRANS")==0){ + int mytrans; + mytrans = CHAR_getInt(talker,CHAR_TRANSMIGRATION); + if(NPC_EventBigSmallLastCheck( kosuu, mytrans, flg) == TRUE) + return TRUE; + } + } +#endif +#ifdef _PROSK99 + if(strstr( buf, "PROSK" ) != NULL) {//PROSK99>16 ְȼ춵99%Ҫ16 + char *p=NULL; + int i,level=0,count=0; + CHAR_HaveSkill *pSkil; + if( strstr( buf, "PROSK" ) ){ + p = buf; + level = atoi(p+5); + }else + level = 100; + for( i = 0; i < CHAR_SKILLMAXHAVE; i ++ ){ + if( CHAR_getCharHaveSkill( talker, i ) ){ + pSkil = CHAR_getCharHaveSkill( talker, i ); + if( SKILL_getInt( &pSkil->skill, SKILL_LEVEL) >= level ) + ++count; + } + } + if(NPC_EventBigSmallLastCheck( kosuu, count, flg) == TRUE) + return TRUE; + } +#endif + +#ifdef _ADD_reITEM + if(strstr( buf, "reITEM" ) != NULL) { + int i,count=0,itemindex=-1; + for( i = CHAR_STARTITEMARRAY ; i < CHAR_MAXITEMHAVE ; i++ ){ + itemindex = CHAR_getItemIndex( talker , i ); + if( !ITEM_CHECKINDEX( itemindex) ) + ++count; + } + if(NPC_EventBigSmallLastCheck( kosuu, count, flg) == TRUE) + return TRUE; + } +#endif + + return FALSE; + +} + +/*-------------------------------- + * ʸìë + ---------------------------------*/ +BOOL NPC_PetLvCheck(int meindex,int talker,char *buf,int mode) +{ + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + char buff2[16]; + char buf3[8]; + int petno; + int baseno; + int petlevel = 0; + int flg=0; + int mypetlevel = 0; + int i = 0; + int petindex; + char name[512]; + int cnt = 0; + int loop; + int pettran=-1; //жϳת + + + /*--϶ýľʸϼ ID)ë --*/ + getStringFromIndexWithDelim( buf, "-", 2, buff2, sizeof( buff2)); + if(strstr(buff2,"*") != NULL) { + getStringFromIndexWithDelim( buff2, "*", 1, buf3, sizeof( buf3)); + petno = atoi( buf3); + getStringFromIndexWithDelim( buff2, "*", 2, buf3, sizeof( buf3)); + loop = atoi( buf3); + + }else{ + petno = atoi( buff2); + loop = 1; + + } + + if(getStringFromIndexWithDelim( buf, "-", 3, buff2, sizeof( buff2))) //жϳת + { + pettran = atoi( buff2); + } + + /*--ʸ л¾--*/ + for(i=0; i < CHAR_MAXPETHAVE ; i++) { + if(loop == cnt) return TRUE; + + petindex = CHAR_getCharPet( talker, i); + if( petindex == -1 ) continue; + if(pettran != -1) //жϳת + { + if(pettran!=CHAR_getInt( petindex, CHAR_TRANSMIGRATION)) + continue; + } + + /*--ʸIDë ƻ--*/ + baseno = CHAR_getInt( petindex, CHAR_PETID); + + /* ʸIDػƹëƩ */ + if( (baseno == petno) && (CHAR_getInt( petindex, CHAR_ENDEVENT) + == mode)) + { + /*--ìë--*/ + mypetlevel = CHAR_getInt( petindex, CHAR_LV); + getStringFromIndexWithDelim( buf, "-", 1, buff2, sizeof( buff2)); + + if(strstr( buf, "<") != NULL) { + flg = 1; + getStringFromIndexWithDelim( buff2, "<", 2, buf3, sizeof(buf3)); + }else if(strstr( buf, ">") != NULL) { + getStringFromIndexWithDelim( buff2, ">", 2, buf3, sizeof(buf3)); + flg = 2; + }else if(strstr( buf, "=") != NULL) { + getStringFromIndexWithDelim( buff2, "=", 2, buf3, sizeof(buf3)); + flg = 0; + } + + petlevel = atoi( buf3); + + if(NPC_EventBigSmallLastCheck( petlevel, mypetlevel, flg) == TRUE) { + /*--ʸ 󡻥ɬýľ 󡼰 --*/ + if(CHAR_getWorkInt(talker,CHAR_WORKSHOPRELEVANTSEC)==1) { + char *usename; + + /*--ɬð̻P --*/ + if(NPC_Util_GetArgStr( meindex, argstr, sizeof(argstr)) == NULL) { + print("PetLevel:GetArgStrErr"); + return FALSE; + } + + usename = CHAR_getUseName( petindex); + NPC_Util_GetStrFromStrWithDelim( argstr, "Pet_Name", + name,sizeof( name)); + + if(strcmp( name, usename) == 0) + { + cnt++; + continue; + } + }else { + CHAR_setWorkInt( talker, CHAR_WORKSHOPRELEVANTSEC, 0); + cnt++; + continue; + } + } + } + } + + if(loop == cnt) return TRUE; + if(i == CHAR_MAXPETHAVE) return FALSE; + + return FALSE; +} + + +/*-------------------------------- + * ʸìë + ---------------------------------*/ +int NPC_PetLvCheckType2(int petindex,int meindex,int talker,char *buf,int mode) +{ + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + char buff2[16]; + char buf3[8]; + int petno; + int baseno; + int petlevel = 0; + int flg = 0; + int mypetlevel = 0; + char name[512]; + + /*--϶ýľʸϼ ID)ë --*/ + getStringFromIndexWithDelim( buf, "-", 2, buff2, sizeof( buff2)); + if(strstr(buff2,"*") != NULL) { + getStringFromIndexWithDelim( buff2, "*", 1, buf3, sizeof( buf3)); + petno = atoi( buf3); + }else{ + petno = atoi( buff2); + } + + + /*--ʸIDë ƻ--*/ + baseno = CHAR_getInt( petindex, CHAR_PETID); + + /*--ʸIDػƹëƩ--*/ + if( (baseno == petno) && (CHAR_getInt( petindex, CHAR_ENDEVENT) + == mode)) + { + /*--ìë--*/ + mypetlevel=CHAR_getInt( petindex, CHAR_LV); + getStringFromIndexWithDelim( buf, "-", 1,buff2,sizeof(buff2)); + + if(strstr( buf, "<") != NULL) { + flg = 1; + getStringFromIndexWithDelim( buff2, "<", 2, + buf3, sizeof(buf3)); + }else if(strstr( buf, ">") != NULL) { + getStringFromIndexWithDelim( buff2, ">", 2, buf3, sizeof(buf3)); + flg = 2; + }else if(strstr( buf, "=") != NULL) { + getStringFromIndexWithDelim( buff2, "=", 2, buf3, sizeof(buf3)); + flg = 0; + } + + petlevel = atoi(buf3); + + if(NPC_EventBigSmallLastCheck( petlevel, mypetlevel, flg) + == TRUE) + { + /*--ʸ 󡻥ɬýľ 󡼰 --*/ + if(CHAR_getWorkInt(talker,CHAR_WORKSHOPRELEVANTSEC) == 1) { + char *usename; + + /*--ɬð̻P --*/ + if(NPC_Util_GetArgStr( meindex, argstr, sizeof(argstr)) == NULL) { + print("PetLevel:GetArgStrErr"); + return FALSE; + } + + usename = CHAR_getUseName( petindex); + NPC_Util_GetStrFromStrWithDelim(argstr,"Pet_Name", + name, sizeof( name)); + + if(strcmp( name, usename) == 0) + { + return TRUE; + } + }else { + CHAR_setWorkInt( talker, CHAR_WORKSHOPRELEVANTSEC, 0); + return TRUE; + } + } + } + + return FALSE; + +} + +#ifdef _NPC_PETSKILLUP +BOOL NPC_PetSkillCheck(int meindex,int talker,char *buf,int mode) +{ + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + char buff2[64]; + char buf3[32]; + char buf4[32]; + int petskill; + int npcskill; + int skillno; + int petlevel = 0; + int flg=0; + int mypetlevel = 0; + int i = 0; + int petindex; + char name[512]; + int cnt = 0; + int loop; + + + /*--϶ýľʸϼ ID)ë --*/ + if(strstr( buf, "<") != NULL) { + flg = 1; + getStringFromIndexWithDelim( buf, "<", 2, + buff2, sizeof(buff2)); + }else if(strstr( buf, ">") != NULL) { + getStringFromIndexWithDelim( buf, ">", 2, buff2, sizeof(buff2)); + flg = 2; + }else if(strstr( buf, "=") != NULL) { + getStringFromIndexWithDelim( buf, "=", 2, buff2, sizeof(buff2)); + flg = 0; + } + getStringFromIndexWithDelim( buff2, "-", 1, buf3, sizeof( buf3)); + petlevel = atoi(buf3); + getStringFromIndexWithDelim( buff2, "-", 2, buf3, sizeof( buf3)); + skillno = atoi( buf3)-1; + getStringFromIndexWithDelim( buff2, "-", 3, buf3, sizeof( buf3)); + getStringFromIndexWithDelim( buf3, "*", 1, buf4, sizeof( buf4)); + npcskill = atoi( buf4); + getStringFromIndexWithDelim( buf3, "*", 2, buf4, sizeof( buf4)); + loop = atoi( buf4); + + /*--ʸ л¾--*/ + for(i=0; i < CHAR_MAXPETHAVE ; i++) { + //if(loop == cnt) return TRUE; + + petindex = CHAR_getCharPet( talker, i); + if( petindex == -1 ) continue; + CHAR_setWorkInt(petindex,CHAR_WORKPETSKILLUP,0); + if(loop==cnt)continue; + /*--ʸIDë ƻ--*/ + + /* ʸIDػƹëƩ */ + if(CHAR_getInt( petindex, CHAR_ENDEVENT)== mode) + { + /*--ìë--*/ + mypetlevel = CHAR_getInt( petindex, CHAR_LV); + + if(NPC_EventBigSmallLastCheck( petlevel, mypetlevel, flg) == TRUE) { + if( !CHAR_CHECKPETSKILLINDEX( skillno)){ + continue; + } + if(CHAR_getPetSkill( petindex, skillno)!=npcskill){ + continue; + } + CHAR_setWorkInt( talker, CHAR_WORKSHOPRELEVANTSEC, 0); + CHAR_setWorkInt(petindex,CHAR_WORKPETSKILLUP,1); + cnt++; + continue; + } + } + } + + if(loop <= cnt) return TRUE; + if(i == CHAR_MAXPETHAVE) return FALSE; + + return FALSE; +} +#endif + +/*------------------------ + * + --------------------------*/ +BOOL NPC_SavePointCheck(int meindex,int talker,int shiftbit,int flg) +{ + int point; + + point = CHAR_getInt( talker, CHAR_SAVEPOINT); + + if( (point & ( 1<< shiftbit)) == ( 1<< shiftbit)) { + if(flg == 3) return FALSE; + return TRUE; + } + + if(flg == 3) return TRUE; + return FALSE; +} + +/*------------------------ + *̶⼰ + --------------------------*/ +BOOL NPC_ImageCheck(int meindex,int talker,int kosuu,int flg) +{ + int image; + + image = CHAR_getInt( talker, CHAR_IMAGETYPE); + + if(NPC_EventBigSmallLastCheck( image, kosuu, flg) == TRUE) { + return TRUE; + } + return FALSE; + +} + + +/*----------------------------------------- + * ޼ë浤(ؤ) + ------------------------------------------*/ +BOOL NPC_TiemCheck(int meindex,int talker,int time,int flg) +{ + LSTIME nowlstime; + int now; + + RealTimeToLSTime( NowTime.tv_sec, &nowlstime); + now = getLSTime( &nowlstime); + + if(NPC_EventBigSmallLastCheck( time, now, flg) == TRUE) { + return TRUE; + } + return FALSE; + +} + +#ifdef _CAX_NPCTIME_IF +/*----------------------------------------- + * Time Check ENENT:NPC CCIS_WXscript add + ------------------------------------------*/ +BOOL NPC_TiemCheckWithHour(int meindex,int talker,int ttime,int flg) +{ + time_t cc_seconds; + struct tm * cc_timeinfo; + int cc_sec , now; + + cc_seconds = time (NULL); + cc_timeinfo = localtime ( &cc_seconds ); + + now = cc_timeinfo->tm_hour; + + if(NPC_EventBigSmallLastCheck( ttime, now, flg) == TRUE) { + return TRUE; + } + return FALSE; + +} + +/*----------------------------------------- + * Time Check ENENT:NPC CCIS_WXscript add + ------------------------------------------*/ +BOOL NPC_TiemCheckWithDay (int meindex,int talker,int ttime,int flg) +{ + time_t cc_seconds; + struct tm * cc_timeinfo; + int cc_sec , now; + + cc_seconds = time (NULL); + cc_timeinfo = localtime ( &cc_seconds ); + + now = cc_timeinfo->tm_wday; + + if(NPC_EventBigSmallLastCheck( ttime, now, flg) == TRUE) { + return TRUE; + } + return FALSE; + +} +#endif + +/*------------------------------ + *--Itemë + -------------------------------*/ +BOOL NPC_EventItemCheck(int meindex,int talker,int itemNo,int flg) +{ + int i; + int itemindex = -1; + int id; + + //Change fix 鴩ϵĵ + for( i = CHAR_STARTITEMARRAY ; i < CHAR_MAXITEMHAVE ; i++ ) { + + itemindex=CHAR_getItemIndex( talker , i ); + if( ITEM_CHECKINDEX( itemindex) ) { + id=ITEM_getInt( itemindex ,ITEM_ID ); + + if(NPC_EventBigSmallLastCheck( itemNo, id, flg) == TRUE) { + if(flg == 0) return TRUE; + continue; + }else{ + if(flg == 0) continue; + return FALSE; + } + } + } + + if(flg == 3) return TRUE; + + return FALSE; + +} + + +/*------------------------------ + * levelë + -------------------------------*/ +BOOL NPC_EventLevelCheck(int meindex,int talker,int level,int flg) +{ + + int mylevel; + mylevel = CHAR_getInt(talker,CHAR_LV); + + if(NPC_EventBigSmallLastCheck( level, mylevel, flg) == TRUE) + { + if(flg == 3) return FALSE; + return TRUE; + } + + if(flg == 3) return TRUE; + return FALSE; + +} + +BOOL NPC_EventAmPointCheck(int meindex,int talker,int ampoint,int flg) +{ + + int myampoint; + myampoint = sasql_ampoint( CHAR_getChar(talker,CHAR_CDKEY), 0,0); + + if(NPC_EventBigSmallLastCheck( ampoint, myampoint, flg) == TRUE) + { + if(flg == 3) return FALSE; + return TRUE; + } + + if(flg == 3) return TRUE; + return FALSE; + +} + +BOOL NPC_EventFameCheck(int meindex,int talker,int fame,int flg) +{ + + int myfame; + myfame = CHAR_getInt(talker,CHAR_FAME)/100; + + if(NPC_EventBigSmallLastCheck( fame, myfame, flg) == TRUE) + { + if(flg == 3) return FALSE; + return TRUE; + } + + if(flg == 3) return TRUE; + return FALSE; + +} + +#ifndef _CAX_NPCTIME_OFF +BOOL NPC_EventYearCheck(int meindex,int talker,int npcyear,int flg) +{ + NPC_EventTime(); + if(NPC_EventBigSmallLastCheck( npcyear, year, flg) == TRUE) + { + if(flg == 3) return FALSE; + return TRUE; + } + + if(flg == 3) return TRUE; + return FALSE; + +} +BOOL NPC_EventMonCheck(int meindex,int talker,int npcmon,int flg) +{ + NPC_EventTime(); + if(NPC_EventBigSmallLastCheck( npcmon, mon, flg) == TRUE) + { + if(flg == 3) return FALSE; + return TRUE; + } + + if(flg == 3) return TRUE; + return FALSE; + +} +BOOL NPC_EventDateCheck(int meindex,int talker,int npcdate,int flg) +{ + NPC_EventTime(); + if(NPC_EventBigSmallLastCheck( npcdate, date, flg) == TRUE) + { + if(flg == 3) return FALSE; + return TRUE; + } + + if(flg == 3) return TRUE; + return FALSE; + +} +BOOL NPC_EventDayCheck(int meindex,int talker,int npcday,int flg) +{ + NPC_EventTime(); + if(NPC_EventBigSmallLastCheck( npcday, day, flg) == TRUE) + { + if(flg == 3) return FALSE; + return TRUE; + } + + if(flg == 3) return TRUE; + return FALSE; + +} +BOOL NPC_EventHourCheck(int meindex,int talker,int npchour,int flg) +{ + NPC_EventTime(); + if(NPC_EventBigSmallLastCheck( npchour, hour, flg) == TRUE) + { + if(flg == 3) return FALSE; + return TRUE; + } + + if(flg == 3) return TRUE; + return FALSE; + +} +BOOL NPC_EventMinCheck(int meindex,int talker,int npcmin,int flg) +{ + NPC_EventTime(); + if(NPC_EventBigSmallLastCheck( npcmin, min, flg) == TRUE) + { + if(flg == 3) return FALSE; + return TRUE; + } + + if(flg == 3) return TRUE; + return FALSE; + +} + +BOOL NPC_EventSecCheck(int meindex,int talker,int npcsec,int flg) +{ + NPC_EventTime(); + if(NPC_EventBigSmallLastCheck( npcsec, sec, flg) == TRUE) + { + if(flg == 3) return FALSE; + return TRUE; + } + + if(flg == 3) return TRUE; + return FALSE; + +} +#endif + +BOOL NPC_EventVipCheck(int meindex,int talker,int vip,int flg) +{ + + int myVIP; + myVIP = CHAR_getInt(talker,CHAR_VIPRIDE); + + if(NPC_EventBigSmallLastCheck( vip, myVIP, flg) == TRUE) + { + if(flg == 3) return FALSE; + return TRUE; + } + + if(flg == 3) return TRUE; + return FALSE; + +} + +BOOL NPC_EventSuperCheck(int meindex,int talker,int super,int flg) +{ + + int mySUPER; + mySUPER = CHAR_getInt(talker,CHAR_SUPER); + + if(NPC_EventBigSmallLastCheck( super, mySUPER, flg) == TRUE) + { + if(flg == 3) return FALSE; + return TRUE; + } + + if(flg == 3) return TRUE; + return FALSE; + +} + +BOOL NPC_EventVipPointCheck(int meindex,int talker,int vippoint,int flg) +{ + + int myVIPPOINT; + myVIPPOINT = sasql_vippoint(CHAR_getUseID(talker),0,0); + + if(NPC_EventBigSmallLastCheck( vippoint, myVIPPOINT, flg) == TRUE) + { + if(flg == 3) return FALSE; + return TRUE; + } + + if(flg == 3) return TRUE; + return FALSE; + +} + +BOOL NPC_EventNpcTimeCheck(int meindex,int talker,int npctime,int flg) +{ + + int myNPCTIME; + myNPCTIME = CHAR_getInt(talker,CHAR_NPCTIME); + + time_t timep; + struct tm *p; + time(&timep); + p=localtime(&timep); /*ȡõʱ*/ + timep=mktime(p); + if(npctime==0){ + if(myNPCTIME>=timep) return TRUE; + return FALSE; + }else{ + if(myNPCTIME<=timep) return TRUE; + return FALSE; + } + + return FALSE; + +} + +#ifdef _EV_NUM +BOOL NPC_EventEvNumCheck(int meindex,int talker,int evnum,int flg) +{ + + int myEVNUM; + myEVNUM = CHAR_getInt(talker,CHAR_EVNUM); + + if(NPC_EventBigSmallLastCheck( evnum, myEVNUM, flg) == TRUE) + { + if(flg == 3) return FALSE; + return TRUE; + } + + if(flg == 3) return TRUE; + return FALSE; + +} + +BOOL NPC_EventEvCodeCheck(int meindex,int talker,int npcno,int flg) +{ + char *evcode=NULL; + evcode = CHAR_getChar(talker,CHAR_EVCODE); + char errmsg[256]; + if(strlen(evcode)<=0) return FALSE; + char tmpbuf[256]; + memset( tmpbuf, 0, sizeof( tmpbuf ) ); + int mynpcno,evflg,itemid,itemnum,petpicid,petminlv,petmaxlv; + char *petname; + if(getStringFromIndexWithDelim(evcode,"|", 1, tmpbuf, sizeof(tmpbuf)) == FALSE) + return FALSE; + mynpcno = atoi(tmpbuf); + if(getStringFromIndexWithDelim(evcode,"|", 2, tmpbuf, sizeof(tmpbuf)) == FALSE) + return FALSE; + evflg = atoi(tmpbuf); + if(evflg<1 || evflg>3) return FALSE; + if(evflg==2){ + if(getStringFromIndexWithDelim(evcode,"|", 3, tmpbuf, sizeof(tmpbuf)) == FALSE) + return FALSE; + itemid = atoi(tmpbuf); + if(getStringFromIndexWithDelim(evcode,"|", 4, tmpbuf, sizeof(tmpbuf)) == FALSE) + return FALSE; + itemnum = atoi(tmpbuf); + }else if(evflg==3){ + if(getStringFromIndexWithDelim(evcode,"|", 3, tmpbuf, sizeof(tmpbuf)) == FALSE) + return FALSE; + petpicid = atoi(tmpbuf); + if(getStringFromIndexWithDelim(evcode,"|", 4, tmpbuf, sizeof(tmpbuf)) == FALSE) + return FALSE; + petname= tmpbuf; + if(getStringFromIndexWithDelim(evcode,"|", 5, tmpbuf, sizeof(tmpbuf)) == FALSE) + return FALSE; + petminlv = atoi(tmpbuf); + if(getStringFromIndexWithDelim(evcode,"|", 6, tmpbuf, sizeof(tmpbuf)) == FALSE) + return FALSE; + petmaxlv = atoi(tmpbuf); + } + if(npcno!=mynpcno){ + char *npcmsg; + npcmsg=sasql_ev_npcmsg(mynpcno); + if(strcmp(npcmsg,"err")==0) return FALSE; + if(evflg==1){ + sprintf(errmsg,"\n뵽<%s>\n",npcmsg); + lssproto_WN_send( getfdFromCharaIndex(talker), WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + -1, + -1, + errmsg); + return FALSE; + }else if(evflg==2){ + sprintf(errmsg,"\n%d<%s><%s>\n",itemnum,ITEM_getNameFromNumber( itemid),npcmsg); + lssproto_WN_send( getfdFromCharaIndex(talker), WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + -1, + -1, + errmsg); + return FALSE; + }else if(evflg==3){ + sprintf(errmsg,"\nŵȼΪ%d-%d֮ij<%s><%s>\n",petminlv,petmaxlv,petname,npcmsg); + lssproto_WN_send( getfdFromCharaIndex(talker), WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + -1, + -1, + errmsg); + return FALSE; + } + }else{ + if(evflg==1){ + return TRUE; + }else if(evflg==2){ + sprintf(errmsg,"ITEM=%d*%d",itemid,itemnum); + if(NPC_EventReduce(meindex,talker,errmsg)==TRUE){ + return TRUE; + }else{ + sprintf(errmsg,"\n%d<%s>⽻\n",itemnum,ITEM_getNameFromNumber( itemid)); + lssproto_WN_send( getfdFromCharaIndex(talker), WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + -1, + -1, + errmsg); + return FALSE; + } + }else if(evflg==3){ + int peti,petindex=-1,mypetpicid,mypetlv; + for(peti=0;peti=petminlv && mypetlv<=petmaxlv){ + return TRUE; + } + continue; + } + if(peti>=CHAR_MAXPETHAVE){ + sprintf(errmsg,"\nŵȼΪ%d-%d֮ij<%s>Ҵ\n",petminlv,petmaxlv,petname); + lssproto_WN_send( getfdFromCharaIndex(talker), WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + -1, + -1, + errmsg); + return FALSE; + } + } + } + return FALSE; +} +#endif + +#ifdef _ALL_ITEM +BOOL NPC_EventAllNum1Check(int meindex,int talker,int npcallnum1,int flg) +{ + + int myALLNUM1; + myALLNUM1 = sasql_allnum(1,0,0); + + if(NPC_EventBigSmallLastCheck( npcallnum1, myALLNUM1, flg) == TRUE) + { + if(flg == 3) return FALSE; + return TRUE; + } + + if(flg == 3) return TRUE; + return FALSE; + +} +BOOL NPC_EventAllNum2Check(int meindex,int talker,int npcallnum2,int flg) +{ + + int myALLNUM2; + myALLNUM2 == sasql_allnum(2,0,0); + + if(NPC_EventBigSmallLastCheck( npcallnum2, myALLNUM2, flg) == TRUE) + { + if(flg == 3) return FALSE; + return TRUE; + } + + if(flg == 3) return TRUE; + return FALSE; + +} +BOOL NPC_EventAllNum3Check(int meindex,int talker,int npcallnum3,int flg) +{ + + int myALLNUM3; + myALLNUM3 = sasql_allnum(3,0,0); + + if(NPC_EventBigSmallLastCheck( npcallnum3, myALLNUM3, flg) == TRUE) + { + if(flg == 3) return FALSE; + return TRUE; + } + + if(flg == 3) return TRUE; + return FALSE; + +} +BOOL NPC_EventAllNum4Check(int meindex,int talker,int npcallnum4,int flg) +{ + + int myALLNUM4; + myALLNUM4 = sasql_allnum(4,0,0); + + if(NPC_EventBigSmallLastCheck( npcallnum4, myALLNUM4, flg) == TRUE) + { + if(flg == 3) return FALSE; + return TRUE; + } + + if(flg == 3) return TRUE; + return FALSE; + +} +BOOL NPC_EventAllNum5Check(int meindex,int talker,int npcallnum5,int flg) +{ + + int myALLNUM5; + myALLNUM5 = sasql_allnum(5,0,0); + + if(NPC_EventBigSmallLastCheck( npcallnum5, myALLNUM5, flg) == TRUE) + { + if(flg == 3) return FALSE; + return TRUE; + } + + if(flg == 3) return TRUE; + return FALSE; + +} +#endif + +BOOL NPC_EventEquitCheck(int meindex,int talker,int itemNo, int flg) +{ + int i; + int itemindex=-1; + int id; + for( i=0;i point1) { + return TRUE; + } + }else if(flg == 3) { + if(point1 != mypoint) { + return TRUE; + } + } + return FALSE; +} + + +/*--------------------------------- + *ë + *----------------------------------*/ +#ifdef _CHANNEL_MODIFY +extern int *piOccChannelMember; +#endif +void NPC_MsgDisp(int meindex,int talker,int num) +{ + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; +#ifdef _NEWEVENT + char buf[4096]; + char token2[4096]; + char buf2[4096]; + char token[4096]; + char tmp[4096]; +#else + char buf[1024*2]; + char token2[100*14]; + char buf2[512]; + char token[512]; + char tmp[32]; +#endif + int i = 1; + int q=1; + int work = 0; + int EvNo = 0; + int fd = getfdFromCharaIndex( talker); + int buttontype = WINDOW_BUTTONTYPE_OK; + int windowtype = CHAR_WINDOWTYPE_WINDOWEVENT_STARTMSG; + int evch; + + + if(NPC_Util_GetArgStr( meindex, argstr, sizeof(argstr)) == NULL) { + print("MsgDisp:GetArgStrErr"); + print("NPCName=%s\n", CHAR_getChar( meindex, CHAR_NAME)); + return ; + } + if(num == 22 || num == 82 || num == 55 || num == 66) { + int pwork; + + pwork = CHAR_getWorkInt( talker, CHAR_WORKSHOPRELEVANTTRD); + pwork = (pwork / 100) -1 ; + + getStringFromIndexWithDelim( argstr, "EventEnd", pwork, buf,sizeof( buf)); + + }else{ + /*ɬð̻ë*/ + while(getStringFromIndexWithDelim( argstr, "EventEnd", i, buf, sizeof(buf)) + != FALSE) + { + i++; + CHAR_setWorkInt( talker, CHAR_WORKSHOPRELEVANTSEC, 0); + + /*--ìϼë--*/ + NPC_Util_GetStrFromStrWithDelim( buf, "EventNo", buf2, sizeof( buf2)); + if(strstr( buf2, "-1") != 0) { + EvNo = -1; + }else{ + if(strstr(buf2,",") != NULL){ + char buf3[128]; + while(getStringFromIndexWithDelim( buf2, ",", q, buf3, sizeof( buf3)) + != FALSE) { + q++; + } + q--; + q = rand()%q + 1; + getStringFromIndexWithDelim( buf2, ",", q, buf3, sizeof( buf3)); + EvNo = atoi( buf3); + }else{ + EvNo = atoi( buf2); + } + } + //EvNo = atoi( buf2); + + /*--׷ºë浤ƥì ƻݳ--*/ + if(NPC_EventCheckFlg( talker, EvNo) == TRUE) continue; + + /*--ƽë浤--*/ + if(NPC_Util_GetStrFromStrWithDelim( buf,"Pet_Name", buf2,sizeof( buf2)) + != NULL ) + { + CHAR_setWorkInt( talker, CHAR_WORKSHOPRELEVANTSEC, 1); + } + + /*--ƽë浤--*/ + if(NPC_Util_GetStrFromStrWithDelim( buf,"KeyWord", buf2,sizeof( buf2) ) + != NULL) + { + if(CHAR_getWorkInt( talker ,CHAR_WORKSHOPRELEVANT) != i) continue; + } + + evch = NPC_ExChangeManEventCheck( meindex, talker, buf); + + if(evch != -1) { + + /*--ì--*/ + // if(NPC_ExChangeManEventCheck( meindex, talker, buf) == TRUE) { + break; + } + } + } + + //print(" NPC_MsgDisp:%d ", num); + + switch( num) { + case 0: + /*ػìë¾ë ʶ--*/ + if( NPC_Util_GetStrFromStrWithDelim( buf, "StopMsg", + buf2, sizeof( buf2) ) + != NULL) + { + strcpysafe( token,sizeof( buf2), buf2); + buttontype = WINDOW_BUTTONTYPE_YESNO; + windowtype = CHAR_WINDOWTYPE_WINDOWEVENT_NOWEVENT; + } + break; + + case 1: + /*--֧¾ë ׽мNOë--*/ + if( NPC_Util_GetStrFromStrWithDelim( buf, "NoStopMsg", + buf2, sizeof( buf2)) + != NULL) + { + strcpysafe( token, sizeof(buf2), buf2); + + } + break; + + case 7: + /*--ػìë弰--*/ + if( NPC_Util_GetStrFromStrWithDelim( buf, "EndStopMsg", + buf2, sizeof( buf2)) + != NULL) + { + strcpysafe( token, sizeof( buf2), buf2); + + /*--ì ë Ȼջ--*/ + NPC_EventAdd( meindex, talker, 1); + + /*--׷ºë--*/ + NPC_NowEventSetFlgCls( talker, EvNo); + + /*--Ӭ׼ƥ ë--*/ + if(CHAR_getInt( talker, CHAR_CHARM) > 0) { + CHAR_setInt( talker, CHAR_CHARM, CHAR_getInt(talker,CHAR_CHARM) -1); + CHAR_complianceParameter( talker ); + CHAR_send_P_StatusString( talker, CHAR_P_STRING_CHARM); + NPC_CharmStatus( meindex, talker); + } + } + break; + + case 2: + /*--ؤԻ絤--*/ + if( NPC_Util_GetStrFromStrWithDelim( buf, "ThanksMsg", + buf2, sizeof( buf2) ) + != NULL) + { + strcpysafe( token,sizeof( buf2), buf2); + /*--ì ׷ºë--*/ + if(NPC_EventAdd(meindex, talker, 0) != FALSE) { + NPC_NowEventSetFlg( talker, EvNo); + } + else { + return; + } + + + if(NPC_Util_GetStrFromStrWithDelim( buf, "EndSetFlg", + buf2, sizeof( buf2) ) + !=NULL) + { + char buf3[16]; + int k = 1; + if(EvNo != -1) NPC_NowEventSetFlgCls( talker, EvNo); + + while(getStringFromIndexWithDelim(buf2 , "," ,k, + buf3, sizeof(buf3)) + !=FALSE ) + { + k++; + NPC_EventSetFlg( talker, atoi( buf3)); + } + } + + if( NPC_Util_GetStrFromStrWithDelim( buf, "CleanFlg", + buf2, sizeof( buf2)) + != NULL) { + char buf3[16]; + int k = 1; + + k= 1 ; + while(getStringFromIndexWithDelim(buf2 , "," , k, + buf3, sizeof(buf3)) + != FALSE ) + { + NPC_EndEventSetFlgCls( talker, atoi(buf3)); + k++; + } + } + + + + } + CHAR_setWorkInt( talker, CHAR_WORKSHOPRELEVANTTRD, 1); + work = CHAR_getWorkInt( talker, CHAR_WORKSHOPRELEVANTTRD); + work = work + ( i * 100); + CHAR_setWorkInt( talker, CHAR_WORKSHOPRELEVANTTRD, work); + + if(NPC_Util_GetStrFromStrWithDelim( buf,"NpcWarp", + token2,sizeof( token2) ) + != NULL){ + NPC_EventWarpNpc(meindex,token2); + } + + /*--ʸ⻥ؤʾ̼ë--*/ + if(strstr( buf, "ThanksMsg2") != NULL) { + /*ƥ˪*/ + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_NEXT, + CHAR_WINDOWTYPE_WINDOWEVENT_REQTHANK, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + token); + return; + } + + break; + + case 22: + + work = CHAR_getWorkInt( talker, CHAR_WORKSHOPRELEVANTTRD); + work = work % 100; + + if(work == 1){ + if( NPC_Util_GetStrFromStrWithDelim( buf, "ThanksMsg", + buf2, sizeof( buf2) ) + != NULL) + { + strcpysafe( token,sizeof( buf2), buf2); + } + + /*--ʸ⻥ؤʾ̼ë--*/ + if(strstr( buf, "ThanksMsg2") != NULL) { + + /*ƥ˪*/ + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_NEXT, + CHAR_WINDOWTYPE_WINDOWEVENT_REQTHANK, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + token); + return; + } + + }else{ + + sprintf( tmp, "ThanksMsg%d", work); + if( NPC_Util_GetStrFromStrWithDelim( buf, tmp, + buf2, sizeof( buf2) ) + != NULL) { + strcpysafe( token,sizeof( buf2), buf2); + } + + work++; + sprintf( tmp, "ThanksMsg%d", work); + + + /*--ʸ⻥ؤʾ̼ë--*/ + if(strstr( buf, tmp) != NULL) { + + /*ƥ˪*/ + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_NEXT, + CHAR_WINDOWTYPE_WINDOWEVENT_REQTHANK, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + token); + return; + }else{ + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + CHAR_WINDOWTYPE_WINDOWEVENT_REQTHANK, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + token); + return; + } + } + break; + + case 25: + /*--ؤԻ絤--*/ + if( NPC_Util_GetStrFromStrWithDelim( buf, "ThanksMsg", + buf2, sizeof( buf2) ) + != NULL) + { + strcpysafe( token,sizeof( buf2), buf2); + /*--ì ׷ºë--*/ + if(NPC_EventAdd(meindex, talker, 2) != FALSE) { + NPC_NowEventSetFlg( talker, EvNo); + } + } + break; + + + case 3: + /*-- ɧ--*/ + if( NPC_Util_GetStrFromStrWithDelim( buf, "NomalMsg", + buf2, sizeof( buf2) ) + != NULL) + { + strcpysafe(token, sizeof( buf2), buf2); + } + break; + + case 4: + /*--ʧ ةмݼ--*/ + if( NPC_Util_GetStrFromStrWithDelim( buf, "ItemFullMsg", + buf2, sizeof( buf2) ) + != NULL) + { + strcpysafe(token, sizeof( buf2), buf2); + } + break; + + case 5: + /*-- ë¶˼̼--*/ + if( NPC_Util_GetStrFromStrWithDelim( buf, "RequestMsg", + buf2, sizeof( buf2) ) + != NULL) + { + + if(strstr(buf2,"%8d") != NULL) { + char buf3[64]; + int cost; + + NPC_Util_GetStrFromStrWithDelim( buf, "DelStone", + buf3, sizeof( buf3) ); + cost = NPC_EventGetCost( meindex, talker, buf3); + + sprintf(token,buf2,cost); + + }else{ + strcpysafe( token,sizeof( buf2), buf2); + } + buttontype = WINDOW_BUTTONTYPE_YESNO; + windowtype = CHAR_WINDOWTYPE_WINDOWEVENT_REQMAINMSG; + } + + CHAR_setWorkInt( talker, CHAR_WORKSHOPRELEVANTTRD, 1); + work = CHAR_getWorkInt( talker, CHAR_WORKSHOPRELEVANTTRD); + work = work + ( i * 100); + CHAR_setWorkInt( talker, CHAR_WORKSHOPRELEVANTTRD, work); + + /*--ʸ⻥ؤʾ̼ë--*/ + if(strstr( buf, "RequestMsg2") != NULL) { + /*ƥ˪*/ + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_NEXT, + CHAR_WINDOWTYPE_WINDOWEVENT_REQMAINMSG, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + token); + return; + } + break; + + case 55: + + work = CHAR_getWorkInt( talker, CHAR_WORKSHOPRELEVANTTRD); + work = work % 100; + + if(work == 1){ + if( NPC_Util_GetStrFromStrWithDelim( buf, "RequestMsg", + buf2, sizeof( buf2) ) + != NULL) + { + strcpysafe( token, sizeof( buf2), buf2); + } + + /*--ʸ⻥ؤʾ̼ë--*/ + if(strstr( buf, "RequestMsg2") != NULL){ + /*ƥ˪*/ + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_NEXT, + CHAR_WINDOWTYPE_WINDOWEVENT_REQMAINMSG, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + token); + return; + } + }else{ + + sprintf( tmp, "RequestMsg%d", work); + if( NPC_Util_GetStrFromStrWithDelim( buf, tmp, + buf2, sizeof( buf2) ) + != NULL){ + strcpysafe( token,sizeof( buf2), buf2); + + } + work++; + sprintf( tmp, "RequestMsg%d", work); + /*--ʸ⻥ؤʾ̼ë--*/ + if(strstr( buf, tmp) != NULL) { + + /*ƥ˪*/ + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_NEXT, + CHAR_WINDOWTYPE_WINDOWEVENT_REQMAINMSG, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + token); + return; + }else{ + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_YESNO, + CHAR_WINDOWTYPE_WINDOWEVENT_REQMAINMSG, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + token); + return; + } + } + break; + + + case 6: + //print(" 6_Ӧ? "); + /*--Ի˼̼--*/ + if( NPC_Util_GetStrFromStrWithDelim( buf, "AcceptMsg", + buf2, sizeof( buf2) ) + != NULL) + { + if(strstr(buf2,"%8d") != NULL) { + char buf3[64]; + int cost; + + NPC_Util_GetStrFromStrWithDelim( buf, "DelStone", + buf3, sizeof( buf3) ); + cost = NPC_EventGetCost( meindex, talker, buf3); + + sprintf( token, buf2, cost); + }else{ + strcpysafe( token, sizeof( buf2), buf2); + } + buttontype = WINDOW_BUTTONTYPE_YESNO; + windowtype = CHAR_WINDOWTYPE_WINDOWEVENT_ACCMAINMSG; + } + + CHAR_setWorkInt( talker, CHAR_WORKSHOPRELEVANTTRD, 1); + work = CHAR_getWorkInt( talker, CHAR_WORKSHOPRELEVANTTRD); + work = work + ( i * 100); + CHAR_setWorkInt( talker, CHAR_WORKSHOPRELEVANTTRD, work); + + /*--ʸ⻥ؤʾ̼ë--*/ + if(strstr( buf, "AcceptMsg2") != NULL) { + /*ƥ˪*/ + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_NEXT, + CHAR_WINDOWTYPE_WINDOWEVENT_ACCMAINMSG, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + token); + return; + } + break; + + + case 66: + //print(" 66_Ӧ? "); + work = CHAR_getWorkInt( talker, CHAR_WORKSHOPRELEVANTTRD); + work = work % 100; + + if(work == 1){ + if( NPC_Util_GetStrFromStrWithDelim( buf, "AcceptMsg", + buf2, sizeof( buf2) ) + != NULL) + { + strcpysafe( token,sizeof( buf2), buf2); + } + + /*--ʸ⻥ؤʾ̼ë--*/ + if(strstr( buf, "AcceptMsg2") != NULL) { + /*ƥ˪*/ + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_NEXT, + CHAR_WINDOWTYPE_WINDOWEVENT_ACCMAINMSG, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + token); + return; + } + }else{ + + sprintf( tmp, "AcceptMsg%d", work); + if( NPC_Util_GetStrFromStrWithDelim( buf, tmp, + buf2, sizeof( buf2) ) + != NULL){ + strcpysafe( token,sizeof( buf2), buf2); + } + work++; + sprintf( tmp, "AcceptMsg%d", work); + /*--ʸ⻥ؤʾ̼ë--*/ + if(strstr( buf, tmp) != NULL) { + + /*ƥ˪*/ + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_NEXT, + CHAR_WINDOWTYPE_WINDOWEVENT_ACCMAINMSG, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + token); + return; + }else{ + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_YESNO, + CHAR_WINDOWTYPE_WINDOWEVENT_ACCMAINMSG, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + token); + return; + } + } + break; + + case 8: + //print(" 8_Ӧ? "); + + if( NPC_Util_GetStrFromStrWithDelim( buf, "ThanksMsg", + buf2, sizeof( buf2) ) + != NULL) + { + strcpysafe( token, sizeof( buf2), buf2); + /*--ì ׷ºë--*/ + if(NPC_AcceptDel( meindex, talker,0) == FALSE){ + return ; + } + + if(NPC_Util_GetStrFromStrWithDelim( buf, "EndSetFlg", + buf2, sizeof( buf2) ) + !=NULL) + { + char buf3[16]; + int k = 1; + if(EvNo != -1) NPC_NowEventSetFlgCls( talker, EvNo); + + while(getStringFromIndexWithDelim(buf2 , "," ,k, + buf3, sizeof(buf3)) + !=FALSE ) + { + k++; + NPC_EventSetFlg( talker, atoi( buf3)); + } + } + + if( NPC_Util_GetStrFromStrWithDelim( buf, "Charm", + buf2, sizeof( buf2)) + !=NULL) + { + /*--ƥ գ ë---*/ + if( CHAR_getInt( talker, CHAR_CHARM) < 100 && EvNo > 0 ){ + if(CHAR_getInt( talker, CHAR_CHARM) + atoi(buf2) > 100){ + CHAR_setInt( talker, CHAR_CHARM,100); + + }else{ + CHAR_setInt( talker, CHAR_CHARM, + CHAR_getInt(talker,CHAR_CHARM) + atoi(buf2)); + + } + + CHAR_complianceParameter( talker ); + CHAR_send_P_StatusString( talker, CHAR_P_STRING_CHARM); + NPC_CharmStatus( meindex, talker); + } + } + + if( NPC_Util_GetStrFromStrWithDelim( buf, "CleanFlg", + buf2, sizeof( buf2)) + != NULL) { + char buf3[16]; + int k = 1; + + k= 1 ; + while(getStringFromIndexWithDelim(buf2 , "," , k, + buf3, sizeof(buf3)) + != FALSE ) + { + NPC_EndEventSetFlgCls( talker, atoi(buf3)); + k++; + } + } + + + // Robin add ְҵ + if( NPC_Util_GetStrFromStrWithDelim( buf, "PROFESSION", + buf2, sizeof( buf2)) != NULL) + { + int p_class = atoi( buf2); + //Change fix 2004/07/05 + for( i=0; i 0 ){ + p_class = 1; + CHAR_talkToCli( talker, -1, "Ȱְҵװͨͨж£", CHAR_COLORWHITE); + break; + } + } + } + if( p_class == 0) + { + print(" ====ְҵ==== "); + + // ԭ + //if( PROFESSION_RESTORE_POINT( talker ) != 1 ) return FALSE; + + // 趨ְҵ + CHAR_setInt( talker, PROFESSION_CLASS, p_class ); +#ifdef _CHANNEL_MODIFY + if(CHAR_getInt(talker,PROFESSION_CLASS) > 0){ + int i,pclass = CHAR_getInt(talker,PROFESSION_CLASS) - 1; + for(i=0;i 0 ){ + if(CHAR_getInt( talker, CHAR_CHARM) + atoi(buf2) > 100){ + CHAR_setInt( talker, CHAR_CHARM,100); + }else{ + CHAR_setInt( talker, CHAR_CHARM, + CHAR_getInt(talker,CHAR_CHARM) + atoi( buf2)); + } + CHAR_complianceParameter( talker ); + CHAR_send_P_StatusString( talker, CHAR_P_STRING_CHARM); + NPC_CharmStatus( meindex, talker); + } + } + } + + break; + + + case 9: + + if( NPC_Util_GetStrFromStrWithDelim( buf, "NomalWindowMsg", + buf2, sizeof( buf2) ) + != NULL) + { + strcpysafe( token, sizeof( buf2), buf2); + if(EvNo != -1) NPC_NowEventSetFlg( talker, EvNo); + } +#ifdef _NEWEVENT + CHAR_setWorkInt( talker, CHAR_WORKSHOPRELEVANTTRD, 1); + work = CHAR_getWorkInt( talker, CHAR_WORKSHOPRELEVANTTRD); + work = work + ( i * 100); + CHAR_setWorkInt( talker, CHAR_WORKSHOPRELEVANTTRD, work); + + /*--ʸ⻥ؤʾ̼ë--*/ + if(strstr( buf, "NomalWindowMsg2") != NULL) { + /*ƥ˪*/ + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_NEXT, + CHAR_WINDOWTYPE_WINDOWEVENT_STARTMSG, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + token); + return; + } +#endif + break; + +#ifdef _NEWEVENT + case 99: + work = CHAR_getWorkInt( talker, CHAR_WORKSHOPRELEVANTTRD); + work = work % 100; + + if(work == 1) + { + if( NPC_Util_GetStrFromStrWithDelim( buf, "NomalWindowMsg1", + buf2, sizeof( buf2) ) != NULL) + strcpysafe( token,sizeof( buf2), buf2); + + /*--ʸ⻥ؤʾ̼ë--*/ + if(strstr( buf, "NomalWindowMsg2") != NULL) { + /*ƥ˪*/ + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_NEXT, + CHAR_WINDOWTYPE_WINDOWEVENT_STARTMSG, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + token); + return; + } + }else{ + + sprintf( tmp, "NomalWindowMsg%d", work); + if( NPC_Util_GetStrFromStrWithDelim( buf, tmp, + buf2, sizeof( buf2) ) + != NULL){ + strcpysafe( token,sizeof( buf2), buf2); + } + work++; + sprintf( tmp, "NomalWindowMsg%d", work); + /*--ʸ⻥ؤʾ̼ë--*/ + if(strstr( buf, tmp) != NULL) { + + /*ƥ˪*/ + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_NEXT, + CHAR_WINDOWTYPE_WINDOWEVENT_STARTMSG, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + token); + return; + }else{ + int fd = getfdFromCharaIndex( talker); + char token2[14*100]; + /*--ƥʧ ةئܰë浤--*/ + if(NPC_AcceptDel( meindex, talker,0) == FALSE) return; + + /*׷ºëƻľɣ--*/ + if( EvNo != -1) NPC_NowEventSetFlg( talker, EvNo); + + if(NPC_Util_GetStrFromStrWithDelim( buf,"NpcWarp", + token2,sizeof( token2) )!= NULL){ + NPC_EventWarpNpc(meindex,token2); + } + + //׷ºë + if(NPC_Util_GetStrFromStrWithDelim( buf, "EndSetFlg", + buf2, sizeof( buf2) )!=NULL) + { + char buf3[16]; + int k = 1; + + if(EvNo != -1) NPC_NowEventSetFlgCls( talker, EvNo); + + while(getStringFromIndexWithDelim(buf2 , "," ,k, + buf3, sizeof(buf3)) !=FALSE ) + { + k++; + NPC_EventSetFlg( talker, atoi( buf3)); + } + } + //ì׷ºë + if( NPC_Util_GetStrFromStrWithDelim( buf, "CleanFlg", + buf2, sizeof( buf2)) != NULL) { + char buf3[16]; + int k = 1; + + k= 1 ; + while(getStringFromIndexWithDelim(buf2 , "," , k, + buf3, sizeof(buf3)) + != FALSE ) + { + NPC_EndEventSetFlgCls( talker, atoi(buf3)); + k++; + } + } + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_YES, + CHAR_WINDOWTYPE_WINDOWEVENT_STARTMSG, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + token); + return; + } + } + break; +#endif + case 10: + + /*--ʸмݼ--*/ + if( NPC_Util_GetStrFromStrWithDelim( buf, "PetFullMsg", + buf2, sizeof( buf2) ) + != NULL) + { + strcpysafe( token, sizeof( buf2), buf2); + print(" PetFullMsg:%s ", token); + } + else + { + print(" PetFullMsg_Error:%d ", __LINE__); + } + break; + + case 11: + /*--׷ºë弰--*/ + if( NPC_Util_GetStrFromStrWithDelim( buf, "CleanMainMsg", + buf2, sizeof( buf2) ) + != NULL) + { + strcpysafe( token, sizeof( buf2), buf2); + buttontype = WINDOW_BUTTONTYPE_YESNO; + windowtype = CHAR_WINDOWTYPE_WINDOWEVENT_CLEANMSG; + } + break; + case 12: + /*--׷ºë --*/ + if( NPC_Util_GetStrFromStrWithDelim( buf, "CleanFlgMsg", + buf2, sizeof( buf2) ) + != NULL) + { + char buf3[64]; + int loop=1; + + strcpysafe( token, sizeof( buf2), buf2); + NPC_Util_GetStrFromStrWithDelim( buf, "CleanFlg", + buf2, sizeof( buf2) ); + while(getStringFromIndexWithDelim(buf2 , "," , loop, buf3, sizeof(buf3)) + != FALSE ) + { + NPC_EndEventSetFlgCls( talker, atoi(buf3)); + loop++; + } + } + break; + + case 13: + /*--Żм--*/ + if( NPC_Util_GetStrFromStrWithDelim( buf, "StoneFullMsg", + buf2, sizeof( buf2) ) + != NULL) + { + strcpysafe( token, sizeof( buf2), buf2); + } + break; + + case 14: + /*--ŻԻئж--*/ + if( NPC_Util_GetStrFromStrWithDelim( buf, "StoneLessMsg", + buf2, sizeof( buf2) ) + != NULL) + { + strcpysafe( token, sizeof( buf2), buf2); + } + break; + } + + /*ƥ˪*/ +#ifdef _NEWEVENT + if(num != 8) +#endif + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + buttontype, + windowtype, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + token); + +} + +/*-------------------------------------- + *ìüʧ ةëܰ + ---------------------------------------*/ +BOOL NPC_EventAdd(int meindex,int talker,int mode) +{ + + char buf[64]; + char buff2[1024]; + int j = 1,i = 0; + int kosuucnt = 0; + int itemindex; + char buff[1024*2]; + int rand_j = 0; + int rand_flg = 0; + int rand_cnt = 0; + int evcnt; + int b_flg = 0; + + /*--ɬð̻ ̤лؤë ƻּë --*/ + evcnt = NPC_EventFile( meindex, talker, buff); + + if(evcnt == -1) return FALSE; + +// if(NPC_EventFile( meindex, talker, buff) == FALSE) return FALSE; + + /*--ʧ ةë--*/ + if(NPC_ItemFullCheck( meindex, talker, buff, mode, evcnt) == FALSE){ + NPC_MsgDisp( meindex, talker, 4); + return FALSE; + } + + /*--ͱ --*/ + if(NPC_Util_GetStrFromStrWithDelim( buff, "DelStone", buff2, sizeof( buff2) ) + !=NULL) + { + int stone; + + stone = NPC_EventGetCost( meindex, talker, buff2); + + if( (CHAR_getInt( talker, CHAR_GOLD) - stone) < 0 ){ + NPC_MsgDisp( meindex, talker, 14); + return FALSE; + } + } + + + /*--ʸ ëܰ--*/ + if((NPC_Util_GetStrFromStrWithDelim( buff, "pet_skill", buff2, sizeof( buff2) ) + !=NULL) && mode == 0 ){ + if(mode == 0) { + NPC_PetSkillMakeStr( meindex, talker, 1); + return TRUE; + } + } + + + if(mode == 2) mode = 0; + + /*--ʸëܰ---*/ + if(NPC_Util_GetStrFromStrWithDelim( buff, "GetPet", buff2, sizeof( buff2) ) + !=NULL) + { + if(mode == 0){ + if(NPC_EventAddPet( meindex, talker, buff2,0) == FALSE) { + NPC_MsgDisp( meindex, talker, 10); + return FALSE; + } + }else if(mode == 1){ + + } + } + + // Robin add NPCȡﵰ + if(NPC_Util_GetStrFromStrWithDelim( buff, "GetEgg", buff2, sizeof( buff2) ) + !=NULL) + { + if(mode == 0){ + if(NPC_EventAddEgg( meindex, talker, buff2,0) == FALSE) { + print(" AddEgg_Error:%d ", __LINE__); + NPC_MsgDisp( meindex, talker, 10); + return FALSE; + } + }else if(mode == 1){ + + } + } + + if(NPC_Util_GetStrFromStrWithDelim( buff, "DelItem", buff2, sizeof( buff2) ) !=NULL){ + if(strstr(buff2,"EVDEL") != NULL){ + char work[256]; + char nbuf[256]; + + NPC_Util_GetStrFromStrWithDelim(buf, "EVENT", buff2, sizeof( buff2)); + getStringFromIndexWithDelim( buff2, ",", evcnt, work, sizeof( work)); + + if(strstr(buff,"Break")!=NULL){ + b_flg=1; + }else{ + b_flg=0; + } + + if(NPC_Util_GetStrFromStrWithDelim( buff, "NotDel", nbuf, sizeof( nbuf)) != NULL) { + NPC_EventDelItemEVDEL( meindex, talker, work, nbuf,b_flg); + }else{ + NPC_EventDelItemEVDEL( meindex, talker, work, "-1",b_flg); + } + + }else{ + if(strstr(buff,"Break")!=NULL){ + b_flg=1; + }else{ + b_flg=0; + } + + NPC_EventDelItem( meindex, talker, buff2, b_flg); + } + } + + /*--ë---*/ + if(NPC_Util_GetStrFromStrWithDelim( buff, "DelStone", buff2, sizeof( buff2) ) + !=NULL) + { + int stone; + char token[128]; + + stone = NPC_EventGetCost( meindex, talker, buff2); + + CHAR_setInt(talker,CHAR_GOLD,CHAR_getInt( talker, CHAR_GOLD) - stone); + + /*--ɷ¶˪Ի--*/ + CHAR_send_P_StatusString( talker, CHAR_P_STRING_GOLD); + sprintf(token, "%dstone", stone); + CHAR_talkToCli( talker, -1, token, CHAR_COLORWHITE); + } + + + /*--¼ĸةʧ ة---*/ + if(NPC_Util_GetStrFromStrWithDelim( buff, "GetRandItem", buf, sizeof( buf) ) != NULL ){ + j=1; + while( getStringFromIndexWithDelim( buf , "," , j, buff2, sizeof( buff2)) != FALSE ){ + j++; + rand_j++; + } + rand_cnt = 1; + } + + + /*-- ɧʧ ة--*/ + if(NPC_Util_GetStrFromStrWithDelim( buff, "GetItem", buf, sizeof( buf)) != NULL ){ + if(mode == 0) { + j = 1; + /*--ۼʧ ةë ʾ--*/ + while(getStringFromIndexWithDelim( buf, "," , j, buff2, sizeof(buff2)) !=FALSE ){ + j++; + } + + j--; + for( i = CHAR_STARTITEMARRAY ; i < CHAR_MAXITEMHAVE ; i++ ){ + itemindex=CHAR_getItemIndex( talker , i ); + if( !ITEM_CHECKINDEX( itemindex) ){ + kosuucnt++; + } + } + j= j + rand_cnt; + if( kosuucnt < j ){ + NPC_MsgDisp( meindex, talker, 4); + return FALSE; + + }else{ + if(NPC_Util_GetStrFromStrWithDelim( buff, "GetRandItem", buff2, sizeof( buff2)) !=NULL) { + rand_flg = 1; + NPC_RandItemGet( meindex, talker, rand_j, buff2); + } + if(NPC_EventAddItem( meindex, talker, buf) == FALSE) return FALSE; + } + }else if(mode == 1){ + if(strstr(buff,"Break")!=NULL){ + b_flg=1; + }else{ + b_flg=0; + } + NPC_EventDelItem( meindex, talker, buf,b_flg); + } + } + + if( (NPC_Util_GetStrFromStrWithDelim( buff, "GetRandItem", buf, sizeof( buf) ) + !=NULL) && (rand_flg == 0) && mode == 0 ) + { + /*-- ¾-*/ + for( i = CHAR_STARTITEMARRAY ; i < CHAR_MAXITEMHAVE ; i++ ){ + itemindex=CHAR_getItemIndex( talker , i ); + if( !ITEM_CHECKINDEX( itemindex) ){ + kosuucnt++; + } + } + /*--廥ؤ¾--*/ + if( kosuucnt == 0 ){ + NPC_MsgDisp( meindex, talker, 4); + return FALSE; + } + + + NPC_RandItemGet( meindex, talker, rand_j,buf); + } + +#ifdef _EXCHANGEMAN_REQUEST_DELPET + if( NPC_Util_GetStrFromStrWithDelim( buff, "DelPet", buff2, sizeof( buff2) ) != NULL && mode == 0 ) { + char buf4[32]; + char buf5[256]; + int i=1; + char work[256]; + int j=1; + + if(strstr(buff2,"EVDEL") != NULL){ + NPC_Util_GetStrFromStrWithDelim( buf, "EVENT", buf5, sizeof( buf5)); + getStringFromIndexWithDelim( buf5, ",",evcnt , buff2, sizeof( buff2)); + while(getStringFromIndexWithDelim( buff2, "&", j, work, sizeof( work))!=FALSE){ + j++; + if(strstr( work, "PET") != NULL) { + if(strstr( work, "EV") != NULL) { + if(NPC_PetLvCheck( meindex, talker, work, 1) == FALSE) return FALSE; + }else{ + if(NPC_PetLvCheck( meindex, talker, work, 0) == FALSE) return FALSE; + } + } + } + j = 1; + while(getStringFromIndexWithDelim( buff2, "&", j, work, sizeof( work)) != FALSE){ + j++; + if(strstr( work, "PET") == NULL ) continue; + + if(strstr(work,"*") != NULL){ + int cnt=0; + int petcnt=0; + int petindex; + + getStringFromIndexWithDelim( work, "*", 2, buf4, sizeof( buf4)); + cnt = atoi(buf4); + + for(i=0 ; i < CHAR_MAXPETHAVE ; i++){ + petindex = CHAR_getCharPet( talker, i); + + if( petindex == -1 ) continue; + + if(strstr( work, "EV") != NULL) { + if(NPC_PetLvCheckType2(petindex, meindex, talker, work, 1) + == FALSE) { + continue; + } + }else{ + if(NPC_PetLvCheckType2(petindex, meindex, talker, work, 0) == FALSE) { + continue; + } + } + + if(NPC_EventDelPet( meindex, talker,i) == FALSE) return FALSE; + + petcnt++; + /*--϶мʸë׾--*/ + if(cnt == petcnt) break; + + } + }else{ + /*--ʸëë϶ƻئмƥʸë廯--*/ + + int petindex; + + for( i = 0; i < CHAR_MAXPETHAVE; i ++ ) { + petindex = CHAR_getCharPet( talker, i); + + if( !CHAR_CHECKINDEX( petindex) ) continue; + + if(strstr( buff2, "EV") != NULL){ + if(NPC_PetLvCheckType2( petindex, meindex, talker, work, 1) == FALSE){ + continue; + } + }else{ + if(NPC_PetLvCheckType2( petindex, meindex, talker, work, 0) == FALSE) { + continue; + } + } + + if(NPC_EventDelPet( meindex, talker, i) == FALSE) return FALSE; + } + } + } + + }else{ + /*--ֵ1պʸë Ȼ¾ë浤--*/ + while(getStringFromIndexWithDelim( buff2, ",", j, work, sizeof( work)) + !=FALSE) + { + j++; + /*--ʸͻȻPETë --*/ + if(strstr( work, "PET") != NULL) { + if(strstr( work, "EV") != NULL) { + if(NPC_PetLvCheck( meindex, talker, work, 1) == FALSE) return FALSE; + }else{ + if(NPC_PetLvCheck( meindex, talker, work, 0) == FALSE) return FALSE; + } + } + } + j = 1; + + while(getStringFromIndexWithDelim( buff2, ",", j, work, sizeof( work)) != FALSE) + { + j++; + if(strstr(work,"*") != NULL) + { + int cnt=0; + int petcnt=0; + int petindex; + + getStringFromIndexWithDelim( work, "*", 2, buf4, sizeof( buf4)); + cnt = atoi(buf4); + + for(i=0 ; i < CHAR_MAXPETHAVE ; i++){ + petindex = CHAR_getCharPet( talker, i); + + if( petindex == -1 ) continue; + + if(strstr( work, "EV") != NULL) { + if(NPC_PetLvCheckType2(petindex, meindex, talker, work, 1) == FALSE) { + continue; + } + }else{ + if(NPC_PetLvCheckType2(petindex, meindex, talker, work, 0) == FALSE) { + continue; + } + } + + if(NPC_EventDelPet( meindex, talker,i) == FALSE) return FALSE; + + petcnt++; + /*--϶мʸë׾--*/ + if(cnt == petcnt) break; + } + }else{ + /*--ʸëë϶ƻئмƥʸë廯--*/ + + int petindex; + + for( i = 0; i < CHAR_MAXPETHAVE; i ++ ) { + petindex = CHAR_getCharPet( talker, i); + + if( !CHAR_CHECKINDEX( petindex) ) continue; + + if(strstr( buff2, "EV") != NULL){ + if(NPC_PetLvCheckType2( petindex, meindex, talker, work, 1) == FALSE){ + continue; + } + }else{ + if(NPC_PetLvCheckType2( petindex, meindex, talker, work, 0) == FALSE) { + continue; + } + } + if(NPC_EventDelPet( meindex, talker, i) == FALSE) return FALSE; + } + } + } + } + } +#endif + return TRUE; + +} + + +/*-------------------------------------- + *¼ĸةƥʧ ةë + ------------------------------------ */ +BOOL NPC_RandItemGet(int meidex,int talker,int rand_j,char *buf) +{ + char buff2[64]; + int randitem; + int ret; + int itemindex; + char token[128]; + + if(rand_j == 0) { + print("Event:춣Ľ룬ִ"); + return FALSE; + } + + //randitem = rand()%rand_j; + //srand((int)time(0)); + randitem = RAND(1,rand_j); + if(randitem == 0) randitem = rand_j; + + getStringFromIndexWithDelim(buf , "," , randitem, buff2, sizeof(buff2)) ; + + itemindex = ITEM_makeItemAndRegist( atoi( buff2)); + + if(itemindex == -1) return FALSE; + + /*ʧ ةܰ( ʧ ة ľ */ + ret = CHAR_addItemSpecificItemIndex( talker, itemindex); + if( ret < 0 || ret >= CHAR_MAXITEMHAVE ) { + print( "npc_exchangeman.c: additem error itemindex[%d]\n", itemindex); + ITEM_endExistItemsOne( itemindex); + return FALSE; + } + + if(itemindex != -1) { + LogItem( + CHAR_getChar( talker, CHAR_NAME ), /* ƽҷ */ + CHAR_getChar( talker, CHAR_CDKEY ), +#ifdef _add_item_log_name // WON ADD itemlogitem + itemindex, +#else + ITEM_getInt( itemindex, ITEM_ID), /* ʧ ة į */ +#endif + "EventAddItem(õĵ)", + CHAR_getInt( talker,CHAR_FLOOR), + CHAR_getInt( talker,CHAR_X ), + CHAR_getInt( talker,CHAR_Y ), + ITEM_getChar( itemindex, ITEM_UNIQUECODE), + ITEM_getChar( itemindex, ITEM_NAME), + ITEM_getInt( itemindex, ITEM_ID) + ); + } + + sprintf(token,"%s",ITEM_getChar( itemindex, ITEM_NAME)); + CHAR_talkToCli( talker, -1, token, CHAR_COLORWHITE); + + CHAR_sendItemDataOne( talker, ret); + return TRUE; + +} + + +/*---------------------------------------------------- + * ì + ----------------------------------------------------*/ +BOOL NPC_AcceptDel(int meindex,int talker,int mode ) +{ + + char buf[1024*2]; + char buff2[1024]; + int rand_j = 0; + int j = 0; + int evcnt; + int b_flg = 0; + evcnt = NPC_EventFile( meindex, talker, buf); + if(evcnt == -1) return FALSE; + + /*--ɬð̻ 微ľë ƻּë --*/ +// if(NPC_EventFile(meindex,talker,buf)==FALSE) return FALSE; + + /*--ʧ ةë--*/ + if(NPC_ItemFullCheck( meindex, talker, buf, mode, evcnt) == FALSE){ + NPC_MsgDisp( meindex, talker, 4); + return FALSE; + } + + /*--ͱ --*/ + if(NPC_Util_GetStrFromStrWithDelim( buf, "DelStone", buff2, sizeof( buff2) ) + !=NULL) + { + int stone; + stone = NPC_EventGetCost( meindex, talker, buff2); + + if( (CHAR_getInt( talker, CHAR_GOLD) - stone) < 0 ) { + NPC_MsgDisp( meindex, talker, 14); + return FALSE; + } + } + + + /*--ͱ --*/ + if(NPC_Util_GetStrFromStrWithDelim( buf, "GetStone", buff2, sizeof( buff2) )!=NULL){ + int stone; + stone = atoi(buff2); + + if( (CHAR_getInt( talker, CHAR_GOLD) + stone) >= CHAR_getMaxHaveGold( talker) ) { + NPC_MsgDisp( meindex, talker, 13); + return FALSE; + } + } + + + /*--ʸ ëܰ--*/ + if((NPC_Util_GetStrFromStrWithDelim( buf, "pet_skill", buff2, sizeof( buff2) ) + !=NULL) && mode == 0 ){ + if(mode == 0){ + CHAR_setWorkInt( talker, CHAR_WORKSHOPRELEVANTTRD, 1); + NPC_PetSkillMakeStr( meindex, talker, 1); + return TRUE; + } + } + + /*--ʸë---*/ + if(NPC_Util_GetStrFromStrWithDelim( buf, "DelPet", buff2, sizeof( buff2) ) != NULL) { + char buf4[32]; + char buf5[256]; + int i=1; + char work[256]; + int j=1; + + if(strstr(buff2,"EVDEL") != NULL){ + NPC_Util_GetStrFromStrWithDelim( buf, "EVENT", buf5, sizeof( buf5)); + getStringFromIndexWithDelim( buf5, ",",evcnt , buff2, sizeof( buff2)); + + + /*--ֵ1պʸë Ȼ¾ë浤--*/ + while(getStringFromIndexWithDelim( buff2, "&", j, work, sizeof( work)) + !=FALSE) + { + j++; + + /*--ʸͻȻPETë --*/ + if(strstr( work, "PET") != NULL) { + if(strstr( work, "EV") != NULL) { + if(NPC_PetLvCheck( meindex, talker, work, 1) == FALSE) return FALSE; + }else{ + if(NPC_PetLvCheck( meindex, talker, work, 0) == FALSE) return FALSE; + } + } + } + j = 1; + + + while(getStringFromIndexWithDelim( buff2, "&", j, work, sizeof( work)) + != FALSE) + { + j++; + if(strstr( work, "PET") == NULL ) continue; + + if(strstr(work,"*") != NULL) + { + int cnt=0; + int petcnt=0; + int petindex; + + getStringFromIndexWithDelim( work, "*", 2, buf4, sizeof( buf4)); + cnt = atoi(buf4); + + for(i=0 ; i < CHAR_MAXPETHAVE ; i++){ + petindex = CHAR_getCharPet( talker, i); + + if( petindex == -1 ) continue; + + if(strstr( work, "EV") != NULL) { + if(NPC_PetLvCheckType2(petindex, meindex, talker, work, 1) + == FALSE) { + continue; + } + }else{ + if(NPC_PetLvCheckType2(petindex, meindex, talker, work, 0) + == FALSE) { + continue; + } + } + + if(NPC_EventDelPet( meindex, talker,i) == FALSE) return FALSE; + + petcnt++; + /*--϶мʸë׾--*/ + if(cnt == petcnt) break; + + } + }else{ + /*--ʸëë϶ƻئмƥʸë廯--*/ + + int petindex; + + for( i = 0; i < CHAR_MAXPETHAVE; i ++ ) { + petindex = CHAR_getCharPet( talker, i); + + if( !CHAR_CHECKINDEX( petindex) ) continue; + + if(strstr( buff2, "EV") != NULL){ + if(NPC_PetLvCheckType2( petindex, meindex, talker, work, 1) + == FALSE){ + continue; + } + }else{ + if(NPC_PetLvCheckType2( petindex, meindex, talker, work, 0) + == FALSE) { + continue; + } + } + + if(NPC_EventDelPet( meindex, talker, i) == FALSE) return FALSE; + } + } + } + + }else{ + + /*--ֵ1պʸë Ȼ¾ë浤--*/ + while(getStringFromIndexWithDelim( buff2, ",", j, work, sizeof( work)) + !=FALSE) + { + j++; + /*--ʸͻȻPETë --*/ + if(strstr( work, "PET") != NULL) { + if(strstr( work, "EV") != NULL) { + if(NPC_PetLvCheck( meindex, talker, work, 1) == FALSE) return FALSE; + }else{ + if(NPC_PetLvCheck( meindex, talker, work, 0) == FALSE) return FALSE; + } + } + } + j = 1; + + + while(getStringFromIndexWithDelim( buff2, ",", j, work, sizeof( work)) + != FALSE) + { + j++; + if(strstr(work,"*") != NULL) + { + int cnt=0; + int petcnt=0; + int petindex; + + getStringFromIndexWithDelim( work, "*", 2, buf4, sizeof( buf4)); + cnt = atoi(buf4); + + for(i=0 ; i < CHAR_MAXPETHAVE ; i++){ + petindex = CHAR_getCharPet( talker, i); + + if( petindex == -1 ) continue; + + if(strstr( work, "EV") != NULL) { + if(NPC_PetLvCheckType2(petindex, meindex, talker, work, 1) + == FALSE) { + continue; + } + }else{ + if(NPC_PetLvCheckType2(petindex, meindex, talker, work, 0) + == FALSE) { + continue; + } + } + + if(NPC_EventDelPet( meindex, talker,i) == FALSE) return FALSE; + + petcnt++; + /*--϶мʸë׾--*/ + if(cnt == petcnt) break; + + } + }else{ + /*--ʸëë϶ƻئмƥʸë廯--*/ + + int petindex; + + for( i = 0; i < CHAR_MAXPETHAVE; i ++ ) { + petindex = CHAR_getCharPet( talker, i); + + if( !CHAR_CHECKINDEX( petindex) ) continue; + + if(strstr( buff2, "EV") != NULL){ + if(NPC_PetLvCheckType2( petindex, meindex, talker, work, 1) + == FALSE){ + continue; + } + }else{ + if(NPC_PetLvCheckType2( petindex, meindex, talker, work, 0) + == FALSE) { + continue; + } + } + + if(NPC_EventDelPet( meindex, talker, i) == FALSE) return FALSE; + } + } + } + } + } + + + + /*--ëؤ---*/ + if(NPC_Util_GetStrFromStrWithDelim( buf, "GetStone", buff2, sizeof( buff2) ) + !=NULL) + { + int stone; + char token[128]; + + stone = atoi(buff2); + CHAR_setInt(talker,CHAR_GOLD,CHAR_getInt( talker, CHAR_GOLD) + stone); + /*--ɷ¶˪Ի--*/ + CHAR_send_P_StatusString( talker, CHAR_P_STRING_GOLD); + + sprintf( token,"õ%dstone", stone); + CHAR_talkToCli( talker, -1, token, CHAR_COLORWHITE); + } + + + /*--ʸëܰ---*/ + if(NPC_Util_GetStrFromStrWithDelim( buf, "GetPet", buff2, sizeof( buff2) ) + !=NULL) + { + if(NPC_EventAddPet( meindex, talker, buff2,1) == FALSE) { + NPC_MsgDisp( meindex, talker, 10); + return FALSE; + } + } + +#ifdef _TRANS_7_NPC + if(NPC_Util_GetStrFromStrWithDelim( buf, "TRANS7", buff2, sizeof( buff2) ) + !=NULL) + { + if(NPC_EventTRANS( meindex, talker, buff2,1) == FALSE) { + NPC_MsgDisp( meindex, talker, 10); + return FALSE; + } + } + + if(NPC_Util_GetStrFromStrWithDelim( buf, "TRANSNEW7", buff2, sizeof( buff2) ) + !=NULL) + { + if(NPC_EventNewTRANS( meindex, talker, buff2,1) == FALSE) { + NPC_MsgDisp( meindex, talker, 10); + return FALSE; + } + } +#ifdef _TRANS7_POINT + if(NPC_Util_GetStrFromStrWithDelim( buf, "TRANSNEWSEVEN", buff2, sizeof( buff2) ) + !=NULL) + { + if(NPC_EventNewTRANSSEVEN( meindex, talker, buff2,1) == FALSE) { + NPC_MsgDisp( meindex, talker, 10); + return FALSE; + } + } +#endif +#endif + + // Robin add NPCȡﵰ + if(NPC_Util_GetStrFromStrWithDelim( buf, "GetEgg", buff2, sizeof( buff2) ) + !=NULL) + { + if(NPC_EventAddEgg( meindex, talker, buff2,1) == FALSE) { + print(" AddEgg_Error:%d ", __LINE__); + NPC_MsgDisp( meindex, talker, 10); + return FALSE; + } + } + + /*--ʧ ةë--*/ + if(NPC_Util_GetStrFromStrWithDelim( buf, "DelItem", buff2, sizeof( buff2) ) != NULL){ + if(strstr(buff2,"EVDEL") != NULL){ + char work[256]; + char nbuf[256]; + + NPC_Util_GetStrFromStrWithDelim(buf, "EVENT", buff2, sizeof( buff2)); + getStringFromIndexWithDelim( buff2, ",", evcnt, work, sizeof( work)); + + if(strstr(buf,"Break")!=NULL){ + b_flg=1; + }else{ + b_flg=0; + } + + if(NPC_Util_GetStrFromStrWithDelim( buf, "NotDel", nbuf, sizeof( nbuf)) != NULL ){ + NPC_EventDelItemEVDEL( meindex, talker, work, nbuf,b_flg); + }else{ + NPC_EventDelItemEVDEL( meindex, talker, work, "-1",b_flg); + } + }else{ + if(strstr(buf,"Break")!=NULL){ + b_flg=1; + }else{ + b_flg=0; + } + NPC_EventDelItem( meindex, talker, buff2,b_flg); + } + } + + + /*--ë---*/ + if(NPC_Util_GetStrFromStrWithDelim( buf, "DelStone", buff2, sizeof( buff2) ) + !=NULL) + { + int stone; + char token[128]; + + stone = NPC_EventGetCost( meindex, talker, buff2); + + CHAR_setInt(talker,CHAR_GOLD,CHAR_getInt( talker, CHAR_GOLD) - stone); + /*--ɷ¶˪Ի--*/ + CHAR_send_P_StatusString( talker, CHAR_P_STRING_GOLD); + sprintf( token, "%dstone", stone); + CHAR_talkToCli( talker, -1, token, CHAR_COLORWHITE); + } + + if(NPC_Util_GetStrFromStrWithDelim( buf, "AddFame", buff2, sizeof( buff2) ) + !=NULL) + { + int npcfame; + char token[128]; + + npcfame = atoi(buff2)*100; + if(CHAR_getInt(talker,CHAR_FAME)+npcfame>1000000) + { + CHAR_talkToCli( talker, -1, "!", CHAR_COLORRED); + } + else + { + CHAR_setInt(talker,CHAR_FAME,CHAR_getInt( talker, CHAR_FAME) + npcfame); + /*--ɷ¶˪Ի--*/ + sprintf( token, "%d", npcfame/100); + CHAR_talkToCli( talker, -1, token, CHAR_COLORWHITE); + } + } +#ifdef _EV_NUM + if(NPC_Util_GetStrFromStrWithDelim( buf, "DelEvItem", buff2, sizeof( buff2) ) != NULL){ + char token[16]; + if(CHAR_getInt(talker,CHAR_EVITEM)>0){ + sprintf(token,"%d*1",CHAR_getInt(talker,CHAR_EVITEM)); + NPC_EventDelItem( meindex, talker, token,0); + } + } +#endif + if(NPC_Util_GetStrFromStrWithDelim( buf, "DelFame", buff2, sizeof( buff2) ) + !=NULL) + { + int npcfame; + char token[128]; + + npcfame = atoi(buff2)*100; + + if(CHAR_getInt(talker,CHAR_FAME)3) return FALSE; + if(evflg==1){ + NPC_EventSetEvCode(meindex,talker); + }else if(evflg==2){ + int itemid,itemnum; + if(getStringFromIndexWithDelim(evcode,"|", 3, tmpbuf, sizeof(tmpbuf)) == FALSE) + return FALSE; + itemid=atoi(tmpbuf); + if(getStringFromIndexWithDelim(evcode,"|", 4, tmpbuf, sizeof(tmpbuf)) == FALSE) + return FALSE; + itemnum=atoi(tmpbuf); + sprintf(tmpbuf,"%d*%d",itemid,itemnum); + NPC_EventDelItem(meindex,talker,tmpbuf,0); + NPC_EventSetEvCode(meindex,talker); + }else if(evflg==3){ + int petpicid,petminlv,petmaxlv,peti,petindex; + if(getStringFromIndexWithDelim(evcode,"|", 3, tmpbuf, sizeof(tmpbuf)) == FALSE) + return FALSE; + petpicid=atoi(tmpbuf); + if(getStringFromIndexWithDelim(evcode,"|", 5, tmpbuf, sizeof(tmpbuf)) == FALSE) + return FALSE; + petminlv=atoi(tmpbuf); + if(getStringFromIndexWithDelim(evcode,"|", 6, tmpbuf, sizeof(tmpbuf)) == FALSE) + return FALSE; + petmaxlv=atoi(tmpbuf); + for(peti=0;peti=petminlv && CHAR_getInt(petindex,CHAR_LV)<=petmaxlv){ + if(NPC_EventDelPet( meindex, talker,peti) == FALSE) continue; + NPC_EventSetEvCode(meindex,talker); + }else{ + continue; + } + } + if(peti>=CHAR_MAXPETHAVE) return FALSE; + } + } + } + + if(NPC_Util_GetStrFromStrWithDelim( buf, "AddEvNum", buff2, sizeof( buff2) ) + !=NULL) + { + int evnum; + char token[128]; + evnum = atoi(buff2); + CHAR_setInt(talker,CHAR_EVNUM,CHAR_getInt( talker, CHAR_EVNUM) + evnum); + sprintf( token, "ܻ%dܻΪ%d", evnum,CHAR_getInt(talker,CHAR_EVNUM)); + CHAR_talkToCli( talker, -1, token, CHAR_COLORWHITE); + } + + if(NPC_Util_GetStrFromStrWithDelim( buf, "DelEvNum", buff2, sizeof( buff2) ) + !=NULL) + { + int evnum; + char token[128]; + evnum = atoi(buff2); + CHAR_setInt(talker,CHAR_EVNUM,CHAR_getInt( talker, CHAR_EVNUM) - evnum); + sprintf( token, "ܻ%dܻΪ%d", evnum,CHAR_getInt(talker,CHAR_EVNUM)); + CHAR_talkToCli( talker, -1, token, CHAR_COLORWHITE); + } + + if(NPC_Util_GetStrFromStrWithDelim( buf, "SetEvNum", buff2, sizeof( buff2) ) + !=NULL) + { + int evnum; + evnum = atoi(buff2); + CHAR_setInt(talker,CHAR_EVNUM,evnum); + CHAR_setInt(talker,CHAR_EVITEM,0); + CHAR_talkToCli( talker, -1, "ܻѾգ", CHAR_COLORWHITE); + } + + if(NPC_Util_GetStrFromStrWithDelim( buf, "SetEvThings", buff2, sizeof( buff2) ) + !=NULL) + { + struct timeval evt; + int evflg = atoi(buff2); + if(evflg==0){ + CHAR_setInt(talker,CHAR_EVITEM,0); + }else{ + int evi,evj; + gettimeofday(&evt,NULL); + evi = RAND(0,1); + if(evi==0){ + CHAR_setInt(talker,CHAR_EVITEM,0); + }else{ + evi = RAND(32700,32714); + CHAR_setInt(talker,CHAR_EVITEM,evi); + } + } + } +#endif + + if(NPC_Util_GetStrFromStrWithDelim( buf, "SetVip", buff2, sizeof( buff2) ) + !=NULL) + { + int npcvip = atoi(buff2); + CHAR_setInt(talker,CHAR_VIPRIDE,npcvip); + } + + if(NPC_Util_GetStrFromStrWithDelim( buf, "SetSuper", buff2, sizeof( buff2) ) + !=NULL) + { + int npcsuper = atoi(buff2); + CHAR_setInt(talker,CHAR_SUPER,npcsuper); + } + +#ifdef _ALL_ITEM + if(NPC_Util_GetStrFromStrWithDelim( buf, "SetAllNum1", buff2, sizeof( buff2) ) + !=NULL) + { + sasql_allnum(1,atoi(buff2),1); + } + + if(NPC_Util_GetStrFromStrWithDelim( buf, "SetAllNum2", buff2, sizeof( buff2) ) + !=NULL) + { + sasql_allnum(2,atoi(buff2),1); + } + + if(NPC_Util_GetStrFromStrWithDelim( buf, "SetAllNum3", buff2, sizeof( buff2) ) + !=NULL) + { + sasql_allnum(3,atoi(buff2),1); + } + + if(NPC_Util_GetStrFromStrWithDelim( buf, "SetAllNum4", buff2, sizeof( buff2) ) + !=NULL) + { + sasql_allnum(4,atoi(buff2),1); + } + + if(NPC_Util_GetStrFromStrWithDelim( buf, "SetAllNum5", buff2, sizeof( buff2) ) + !=NULL) + { + sasql_allnum(5,atoi(buff2),1); + } + + if(NPC_Util_GetStrFromStrWithDelim( buf, "AllNumMsg", buff2, sizeof( buff2) ) + !=NULL) + { + int allnumflag; + int fd = getfdFromCharaIndex( talker); + allnumflag = atoi(buff2); + char token[128]; + if(allnumflag == 1) + sprintf(token,"ĿǰѼĿΪ%d",sasql_allnum(allnumflag,0,0)); + else if(allnumflag == 2) + sprintf(token,"ĿǰѼĿΪ%d",sasql_allnum(allnumflag,0,0)); + else if(allnumflag == 3) + sprintf(token,"ĿǰѼĿΪ%d",sasql_allnum(allnumflag,0,0)); + else if(allnumflag == 4) + sprintf(token,"ĿǰѼĿΪ%d",sasql_allnum(allnumflag,0,0)); + else if(allnumflag == 5) + sprintf(token,"ĿǰѼĿΪ%d",sasql_allnum(allnumflag,0,0)); + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + -1, + -1, + token); + } +#endif + + /*--¼ĸةʧ ةëܰ---*/ + if(NPC_Util_GetStrFromStrWithDelim( buf, "GetRandItem", buff2, sizeof( buff2) ) + !=NULL) + { + char buf3[32]; + j = 1; + while(getStringFromIndexWithDelim(buff2 , "," , j, buf3, sizeof( buf3)) + != FALSE ) + { + j++; + rand_j++; + } + NPC_RandItemGet( meindex, talker, rand_j, buff2); + } + + + /*--ʧ ةëܰ---*/ + if(NPC_Util_GetStrFromStrWithDelim( buf, "GetItem", buff2, sizeof( buff2) ) + !=NULL) + { + NPC_EventAddItem( meindex, talker, buff2); + } + + if(NPC_Util_GetStrFromStrWithDelim( buf, "HeChengMsg", buff2, sizeof( buff2) ) + !=NULL) + { + int k; + int playernum = CHAR_getPlayerMaxNum(); + char hcmsg[256]; + sprintf(hcmsg,"ϳɴˡϲҡ%sɹϳ%s",CHAR_getChar(talker,CHAR_NAME),buff2); + for(k=0;ktimep) + { + CHAR_talkToCli( talker, -1, "洢ʱδ", CHAR_COLORRED ); + } + else + { + //int fd = getfdFromCharaIndex( talker); + CHAR_charSaveFromConnect(talker, FALSE); + CHAR_setWorkInt(talker,CHAR_WORKSAVETIME,timep); + CHAR_talkToCli(talker, -1, "ϵͳΪԶ浵", CHAR_COLORRED); + } + } + + /*--ɷ¶˪--*/ + CHAR_complianceParameter( talker ); + CHAR_send_P_StatusString( talker , + CHAR_P_STRING_ATK|CHAR_P_STRING_DEF| + CHAR_P_STRING_CHARM|CHAR_P_STRING_QUICK| + CHAR_P_STRING_WATER|CHAR_P_STRING_FIRE| + CHAR_P_STRING_WIND|CHAR_P_STRING_EARTH + ); + + return TRUE; + +} + + +/*-------------------------- + * ìʸë + ---------------------------*/ +BOOL NPC_EventDelPet(int meindex,int talker, int petsel) +{ + + int petindex; + char szPet[128]; + int defpet; + char msgbuf[64]; + + int fd = getfdFromCharaIndex( talker ); + + petindex = CHAR_getCharPet( talker, petsel); + + if( !CHAR_CHECKINDEX(petindex) ) return FALSE; + + if( CHAR_getInt( talker, CHAR_RIDEPET) == petsel ) { + + //CHAR_talkToCli( talker, -1, "еij޷", CHAR_COLORYELLOW ); + //return FALSE; + + CHAR_setInt( talker, CHAR_RIDEPET, -1); + CHAR_send_P_StatusString( talker, CHAR_P_STRING_RIDEPET ); + CHAR_complianceParameter( talker ); + CHAR_sendCToArroundCharacter( CHAR_getWorkInt( talker , CHAR_WORKOBJINDEX )); + print(" DelRidePet "); + } + print(" EventDelPet "); + + /*--ƽҷ» ئգʸëڱ --*/ + if( CHAR_getWorkInt( CONNECT_getCharaindex( fd), + CHAR_WORKBATTLEMODE) != BATTLE_CHARMODE_NONE) return FALSE; + /*--ʸᆴ--*/ + defpet = CHAR_getInt( talker, CHAR_DEFAULTPET); + if(defpet == petsel){ + CHAR_setInt( talker, CHAR_DEFAULTPET, -1); + lssproto_KS_send( fd, -1, TRUE); + } + + snprintf( msgbuf,sizeof( msgbuf), "%s", + CHAR_getChar( petindex, CHAR_NAME)); + CHAR_talkToCli( talker, -1, msgbuf, CHAR_COLORWHITE); + + // ʸë ׷ + LogPet( + CHAR_getChar( talker, CHAR_NAME ), /* ƽҷ */ + CHAR_getChar( talker, CHAR_CDKEY ), + CHAR_getChar( petindex, CHAR_NAME), + CHAR_getInt( petindex, CHAR_LV), + "EvnetDell(ɾ)", + CHAR_getInt( talker,CHAR_FLOOR), + CHAR_getInt( talker,CHAR_X ), + CHAR_getInt( talker,CHAR_Y ), + CHAR_getChar( petindex, CHAR_UNIQUECODE) // shan 2001/12/14 + ); + + + /* */ + CHAR_setCharPet( talker, petsel, -1); + + CHAR_endCharOneArray( petindex ); + + snprintf( szPet, sizeof( szPet ), "K%d", petsel); + // ޥʸ ˪Ի + CHAR_sendStatusString( talker, szPet ); + + return TRUE; + +} + + +/*---------------------------- + * ʸëܰ + ------------------------------*/ +BOOL NPC_EventAddPet(int meindex, int talker, char *buff2,int mode) +{ + int ret; + char msgbuf[64]; + int enemynum; + int enemyid; + int i; + int petindex; + + /*--ʸ л¾--*/ + for( i = 0 ;i < CHAR_MAXPETHAVE ; i++) { + petindex = CHAR_getCharPet( talker, i); + if( petindex == -1 ) break; + } + + if(i == CHAR_MAXPETHAVE) return FALSE; + + + /* ¦ѼIDindexë */ + if(strstr(buff2,",") != NULL){ + char buf2[16]; + while(getStringFromIndexWithDelim( buff2, ",", i, buf2, sizeof( buf2)) + != FALSE) { + i++; + } + i--; + i = rand()%i + 1; + getStringFromIndexWithDelim( buff2, ",", i, buf2, sizeof( buf2)); + enemyid = atoi( buf2); + }else{ + enemyid = atoi( buff2); + } + + enemynum = ENEMY_getEnemyNum(); + for( i = 0; i < enemynum; i ++ ) { + if( ENEMY_getInt( i, ENEMY_ID) == enemyid) { + break; + } + } + + if( i == enemynum ) return FALSE; + + ret = ENEMY_createPetFromEnemyIndex( talker, i); + + for( i = 0; i < CHAR_MAXPETHAVE; i ++ ){ + if( CHAR_getCharPet( talker, i ) == ret )break; + } + if( i == CHAR_MAXPETHAVE ) i = 0; + if( CHAR_CHECKINDEX( ret ) == TRUE ){ + CHAR_setMaxExpFromLevel( ret, CHAR_getInt( ret, CHAR_LV )); + } + + petindex = CHAR_getCharPet(talker,i); + + if( !CHAR_CHECKINDEX( petindex) )return FALSE; + CHAR_complianceParameter( petindex ); + snprintf( msgbuf, sizeof( msgbuf ), "K%d", i ); + CHAR_sendStatusString( talker, msgbuf ); + + snprintf( msgbuf, sizeof( msgbuf ), "W%d", i ); + CHAR_sendStatusString( talker, msgbuf ); + snprintf( msgbuf,sizeof( msgbuf), "õ%s", + CHAR_getChar(petindex,CHAR_NAME)); + CHAR_talkToCli( talker, -1, msgbuf, CHAR_COLORWHITE); + + // ʸë ľ׷ + LogPet( + CHAR_getChar( talker, CHAR_NAME ), /* ƽҷ */ + CHAR_getChar( talker, CHAR_CDKEY ), + CHAR_getChar( petindex, CHAR_NAME), + CHAR_getInt( petindex, CHAR_LV), + "EventGet(õ)", + CHAR_getInt( talker,CHAR_FLOOR), + CHAR_getInt( talker,CHAR_X ), + CHAR_getInt( talker,CHAR_Y ), + CHAR_getChar( petindex, CHAR_UNIQUECODE) // shan 2001/12/14 + ); + + + + if(mode == 0) { + /*--ìüʸ--*/ + CHAR_setInt( petindex, CHAR_ENDEVENT, 1); + } + + return TRUE; + +} + +#ifdef _TRANS_7_NPC +BOOL NPC_EventNewTRANS(int meindex, int talker, char *buff2,int mode) +{ + char token[128]; + int work[10]; + int Trans=CHAR_getInt(talker,CHAR_TRANSMIGRATION)+1; + if(Trans>7 || CHAR_getInt(talker,CHAR_LV)<160){ + sprintf( token, "תȼС160תʧ!", CHAR_getChar( talker, CHAR_NAME)); + CHAR_talkToCli( talker, -1, token, CHAR_COLORYELLOW ); + return; + } +#ifdef _ADD_POOL_ITEM // WON ADD ӿɼķŵĵ + int tran_pool_item[5] = { 4, 4, 4, 4, 4 }; // ӵĵ߼ķ + int tran_pool_pet[5] = { 2, 2, 2, 2, 2}; // ӵijķ + int j,item_sum=0, pet_sum=0; + + for(j=0; j<5 ;j++){ + item_sum += tran_pool_item[j] ; + pet_sum += tran_pool_pet[j]; + } + + item_sum += 10; // ļĵ + pet_sum += 5; // ļij + +#endif +// NPC_TransmigrationStatus(talker, talker, work); + NPC_TransmigrationFlg_CLS(talker, talker); + CHAR_setInt(talker ,CHAR_TRANSMIGRATION, Trans); + if(CHAR_getInt(talker,CHAR_SUPER)==1) + CHAR_setInt( talker,CHAR_SKILLUPPOINT,CHAR_getInt( talker, CHAR_SKILLUPPOINT)+80); + else + { + if(CHAR_getInt(talker,CHAR_VIPRIDE)>0) + CHAR_setInt( talker,CHAR_SKILLUPPOINT,CHAR_getInt( talker, CHAR_SKILLUPPOINT)+75); + else + CHAR_setInt( talker,CHAR_SKILLUPPOINT,CHAR_getInt( talker, CHAR_SKILLUPPOINT)+70); + } + CHAR_Skillupsend( talker ); + CHAR_setInt( talker , CHAR_BASEIMAGENUMBER , CHAR_getInt( talker , CHAR_BASEBASEIMAGENUMBER) ); + CHAR_sendStatusString( talker , "P"); + + CHAR_talkToCli( talker, -1, buff2, CHAR_COLORYELLOW ); +} +#ifdef _TRANS7_POINT +BOOL NPC_EventNewTRANSSEVEN(int meindex, int talker, char *buff2,int mode) +{ + char token[128]; + int work[10]; + int Trans=CHAR_getInt(talker,CHAR_TRANSMIGRATION)+1; + if(Trans>7 || CHAR_getInt(talker,CHAR_LV)<160){ + sprintf( token, "תȼС160תʧ!", CHAR_getChar( talker, CHAR_NAME)); + CHAR_talkToCli( talker, -1, token, CHAR_COLORYELLOW ); + return; + } +#ifdef _ADD_POOL_ITEM // WON ADD ӿɼķŵĵ + int tran_pool_item[5] = { 4, 4, 4, 4, 4 }; // ӵĵ߼ķ + int tran_pool_pet[5] = { 2, 2, 2, 2, 2}; // ӵijķ + int j,item_sum=0, pet_sum=0; + + for(j=0; j<5 ;j++){ + item_sum += tran_pool_item[j] ; + pet_sum += tran_pool_pet[j]; + } + + item_sum += 10; // ļĵ + pet_sum += 5; // ļij + +#endif +// NPC_TransmigrationStatus(talker, talker, work); + NPC_TransmigrationFlg_CLS(talker, talker); + CHAR_setInt(talker ,CHAR_TRANSMIGRATION, Trans); + CHAR_setInt( talker,CHAR_SKILLUPPOINT,CHAR_getInt( talker, CHAR_SKILLUPPOINT)+getTrans7Point()); + CHAR_Skillupsend( talker ); + CHAR_setInt( talker , CHAR_BASEIMAGENUMBER , CHAR_getInt( talker , CHAR_BASEBASEIMAGENUMBER) ); + CHAR_sendStatusString( talker , "P"); + + CHAR_talkToCli( talker, -1, buff2, CHAR_COLORYELLOW ); +} +#endif +BOOL NPC_EventTRANS(int meindex, int talker, char *buff2,int mode) +{ + char token[128]; + int work[10]; + int Trans=CHAR_getInt(talker,CHAR_TRANSMIGRATION)+1; + if(Trans>7 || CHAR_getInt(talker,CHAR_LV)<80){ + sprintf( token, "תȼС80תʧ!", CHAR_getChar( talker, CHAR_NAME)); + CHAR_talkToCli( talker, -1, token, CHAR_COLORYELLOW ); + return; + } +#ifdef _ADD_POOL_ITEM // WON ADD ӿɼķŵĵ + int tran_pool_item[5] = { 4, 4, 4, 4, 4 }; // ӵĵ߼ķ + int tran_pool_pet[5] = { 2, 2, 2, 2, 2}; // ӵijķ + int j,item_sum=0, pet_sum=0; + + for(j=0; j<5 ;j++){ + item_sum += tran_pool_item[j] ; + pet_sum += tran_pool_pet[j]; + } + + item_sum += 10; // ļĵ + pet_sum += 5; // ļij + +#endif + NPC_TransmigrationStatus(talker, talker, work); + NPC_TransmigrationFlg_CLS(talker, talker); + CHAR_setInt(talker ,CHAR_TRANSMIGRATION, Trans); + CHAR_setInt(talker, CHAR_LV ,1); + CHAR_setMaxExp( talker, 0); + CHAR_setInt( talker,CHAR_SKILLUPPOINT,CHAR_getInt( talker, CHAR_TRANSMIGRATION)*10); + CHAR_Skillupsend( talker ); + CHAR_setInt( talker,CHAR_RIDEPET, -1 ); + CHAR_setInt( talker , CHAR_BASEIMAGENUMBER , CHAR_getInt( talker , CHAR_BASEBASEIMAGENUMBER) ); + CHAR_sendStatusString( talker , "P"); + + CHAR_talkToCli( talker, -1, buff2, CHAR_COLORYELLOW ); +} +#endif + + +// Robin add NPCﵰ +BOOL NPC_EventAddEgg(int meindex, int talker, char *buff2,int mode) +{ + int ret; + char msgbuf[64]; + int enemynum; + int enemyid; + int petid; + int raise; + int i; + int petindex; + char buf2[32]; + char buf3[32]; + + print("\n !!:%s ", buff2); + + /*--ʸ л¾--*/ + for( i = 0 ;i < CHAR_MAXPETHAVE ; i++) { + petindex = CHAR_getCharPet( talker, i); + if( petindex == -1 ) break; + } + + if(i == CHAR_MAXPETHAVE) { + print(" AddEgg_Error:%d ", __LINE__); + return FALSE; + } + + + /* ¦ѼIDindexë */ + if(strstr(buff2,",") != NULL){ // ǷΪ + while(getStringFromIndexWithDelim( buff2, ",", i, buf2, sizeof( buf2)) + != FALSE) { + i++; + } + i--; + i = rand()%i + 1; + getStringFromIndexWithDelim( buff2, ",", i, buf2, sizeof( buf2)); + + }else{ + strcpy( buf2, buff2); + } + + getStringFromIndexWithDelim( buf2, ";", 1, buf3, sizeof( buf3)); + enemyid = atoi( buf3); // ﵰID + getStringFromIndexWithDelim( buf2, ";", 2, buf3, sizeof( buf3)); + petid = atoi( buf3); // ijID + getStringFromIndexWithDelim( buf2, ";", 3, buf3, sizeof( buf3)); + raise = atoi( buf3); // + + + // enemyidתenemybaseid + enemynum = ENEMY_getEnemyNum(); + for( i = 0; i < enemynum; i ++ ) { + if( ENEMY_getInt( i, ENEMY_ID) == petid) { + break; + } + } + if( i == enemynum ) { + print(" AddEgg_Error:%d ", __LINE__); + return FALSE; + } + petid = ENEMY_getInt( i, ENEMY_TEMPNO); + + + enemynum = ENEMY_getEnemyNum(); + for( i = 0; i < enemynum; i ++ ) { + if( ENEMY_getInt( i, ENEMY_ID) == enemyid) { + break; + } + } + if( i == enemynum ) { + print(" AddEgg_Error:%d ", __LINE__); + return FALSE; + } + + ret = ENEMY_createPetFromEnemyIndex( talker, i); + + for( i = 0; i < CHAR_MAXPETHAVE; i ++ ){ + if( CHAR_getCharPet( talker, i ) == ret )break; + } + if( i == CHAR_MAXPETHAVE ) i = 0; + if( CHAR_CHECKINDEX( ret ) == TRUE ){ + CHAR_setMaxExpFromLevel( ret, CHAR_getInt( ret, CHAR_LV )); + } + + petindex = CHAR_getCharPet(talker,i); + + if( !CHAR_CHECKINDEX( petindex) ) { + print(" AddEgg_Error:%d ", __LINE__); + return FALSE; + } + + // Ϊﵰ + CHAR_setInt( petindex, CHAR_FUSIONBEIT, 1); + CHAR_setInt( petindex, CHAR_FUSIONCODE, -1); + CHAR_setInt( petindex, CHAR_FUSIONRAISE, raise); + CHAR_setInt( petindex, CHAR_FUSIONINDEX, petid); + CHAR_setInt( petindex, CHAR_FUSIONTIMELIMIT, (int)time( NULL)); + + CHAR_complianceParameter( petindex ); + snprintf( msgbuf, sizeof( msgbuf ), "K%d", i ); + CHAR_sendStatusString( talker, msgbuf ); + + snprintf( msgbuf, sizeof( msgbuf ), "W%d", i ); + CHAR_sendStatusString( talker, msgbuf ); + snprintf( msgbuf,sizeof( msgbuf), "õ%s", + CHAR_getChar(petindex,CHAR_NAME)); + CHAR_talkToCli( talker, -1, msgbuf, CHAR_COLORWHITE); + + // ʸë ľ׷ + LogPet( + CHAR_getChar( talker, CHAR_NAME ), /* ƽҷ */ + CHAR_getChar( talker, CHAR_CDKEY ), + CHAR_getChar( petindex, CHAR_NAME), + CHAR_getInt( petindex, CHAR_LV), + "EventGetEgg(õ)", + CHAR_getInt( talker,CHAR_FLOOR), + CHAR_getInt( talker,CHAR_X ), + CHAR_getInt( talker,CHAR_Y ), + CHAR_getChar( petindex, CHAR_UNIQUECODE) // shan 2001/12/14 + ); + + + + if(mode == 0) { + /*--ìüʸ--*/ + CHAR_setInt( petindex, CHAR_ENDEVENT, 1); + } + return TRUE; + +} + + +/*--------------------------- + * ì ë + -----------------------------**/ +BOOL NPC_EventDelItem(int meindex,int talker,char *buf,int breakflg) +{ + + int i = 1, j = 1, k = 1 ; + char buff3[128]; + char buf2[32]; + int itemindex; + char token[256]; + + while(getStringFromIndexWithDelim(buf , "," , k, buff3, sizeof(buff3)) + !=FALSE ) + { + k++; + if(strstr(buff3,"*") != NULL) { + int itemno; + int kosuu; + int id; + int cnt=0; + + getStringFromIndexWithDelim( buff3, "*", 1, buf2, sizeof( buf2)); + itemno = atoi( buf2); + getStringFromIndexWithDelim( buff3, "*", 2, buf2, sizeof( buf2)); + kosuu = atoi( buf2); + + if( breakflg != 1 ) + NPC_ActionDoPileDelItem( talker, itemno, kosuu);//жѵĴ + else{ + for( i =0 ; i < CHAR_MAXITEMHAVE ; i++ ){ + itemindex = CHAR_getItemIndex( talker , i ); + if( ITEM_CHECKINDEX( itemindex) ) { + id = ITEM_getInt( itemindex , ITEM_ID ); + if(itemno == id) { + cnt++; + LogItem( + CHAR_getChar( talker, CHAR_NAME ), // ƽҷ + CHAR_getChar( talker, CHAR_CDKEY ), +#ifdef _add_item_log_name // WON ADD itemlogitem + itemindex, +#else + ITEM_getInt( itemindex, ITEM_ID), // ʧ ة į +#endif + "EventDelItem(ջصĵ)", + CHAR_getInt( talker, CHAR_FLOOR), + CHAR_getInt( talker, CHAR_X ), + CHAR_getInt( talker, CHAR_Y ), + ITEM_getChar( itemindex, ITEM_UNIQUECODE), + ITEM_getChar( itemindex, ITEM_NAME), + ITEM_getInt( itemindex, ITEM_ID) + ); + + if(breakflg == 1){ + sprintf(token,"%s ",ITEM_getChar( itemindex, ITEM_NAME)); + CHAR_talkToCli( talker, -1, token, CHAR_COLORWHITE); + }else{ + sprintf(token,"%s",ITEM_getChar( itemindex, ITEM_NAME)); + CHAR_talkToCli( talker, -1, token, CHAR_COLORWHITE); + } + //--ʧ ةëڽ-- + CHAR_setItemIndex( talker, i ,-1); + ITEM_endExistItemsOne(itemindex); + CHAR_sendItemDataOne( talker, i); + + if(cnt == kosuu){ + break; + } + } + } + } + } + } + else{ + /*--Ϸ įʧ ةë---*/ + for( j = 0 ; j < CHAR_MAXITEMHAVE ; j++){ + itemindex = CHAR_getItemIndex( talker ,j); + + if( ITEM_CHECKINDEX( itemindex)){ + if( atoi( buff3) == ITEM_getInt( itemindex, ITEM_ID)) { + LogItem( + CHAR_getChar( talker, CHAR_NAME ), /* ƽҷ */ + CHAR_getChar( talker, CHAR_CDKEY ), +#ifdef _add_item_log_name // WON ADD itemlogitem + itemindex, +#else + ITEM_getInt( itemindex, ITEM_ID), /* ʧ ة į */ +#endif + "EventDelItem(ջصĵ)", + CHAR_getInt( talker,CHAR_FLOOR), + CHAR_getInt( talker,CHAR_X ), + CHAR_getInt( talker,CHAR_Y ), + ITEM_getChar( itemindex, ITEM_UNIQUECODE), + ITEM_getChar( itemindex, ITEM_NAME), + ITEM_getInt( itemindex, ITEM_ID) + ); + if(breakflg == 1){ + sprintf(token,"%s ",ITEM_getChar( itemindex, ITEM_NAME)); + CHAR_talkToCli( talker, -1, token, CHAR_COLORWHITE); + }else{ + sprintf( token, "%s", + ITEM_getChar( itemindex, ITEM_NAME)); + CHAR_talkToCli( talker, -1, token, CHAR_COLORWHITE); + } + /*--ʧ ةëڽ--*/ + CHAR_setItemIndex( talker, j ,-1); + ITEM_endExistItemsOne( itemindex); + /*--ɷ¶˪--*/ + CHAR_sendItemDataOne( talker, j); + } + } + } + } + } + + return TRUE; +} + +BOOL NPC_EventDelItemEVDEL(int meindex,int talker,char *buf,char *nbuf,int breakflg) +{ + + int k = 1, l = 1; + char buff3[128]; + char buf2[32]; + char buf4[32]; + + + + while(getStringFromIndexWithDelim(buf , "&" , k, buf4, sizeof(buf4)) !=FALSE ){ + int itemno; + k++; + if(strstr(buf4,"ITEM") == NULL) continue; + getStringFromIndexWithDelim(buf4 , "=" , 2, buff3, sizeof(buff3)); + + if(strstr(buff3,"*") != NULL) { + int kosuu; +#ifndef _ITEM_PILENUMS + char token[256]; + int i, itemindex, id, cnt; +#endif + getStringFromIndexWithDelim( buff3, "*", 1, buf2, sizeof( buf2)); + itemno = atoi( buf2); + getStringFromIndexWithDelim( buff3, "*", 2, buf2, sizeof( buf2)); + kosuu = atoi( buf2); + if(strstr(nbuf,"-1") == NULL){ + l = 1; + while(getStringFromIndexWithDelim(nbuf , "," , l, buf2, sizeof(buf2))){ + l++; + if(itemno == atoi( buf2)){ + l = -1; + break; + } + } + if(l == -1) continue; + } +#ifdef _ITEM_PILENUMS + NPC_ActionDoPileDelItem( talker, itemno, kosuu); +#else + cnt = 0; + for( i =0 ; i < CHAR_MAXITEMHAVE ; i++ ){ + itemindex = CHAR_getItemIndex( talker , i ); + if( ITEM_CHECKINDEX( itemindex) ) { + id = ITEM_getInt( itemindex , ITEM_ID ); + if(itemno == id) { + cnt++; + LogItem( + CHAR_getChar( talker, CHAR_NAME ), /* ƽҷ */ + CHAR_getChar( talker, CHAR_CDKEY ), +#ifdef _add_item_log_name // WON ADD itemlogitem + itemindex, +#else + ITEM_getInt( itemindex, ITEM_ID), /* ʧ ة į */ +#endif + "EventDelItem(ջصĵ)", + CHAR_getInt( talker, CHAR_FLOOR), + CHAR_getInt( talker, CHAR_X ), + CHAR_getInt( talker, CHAR_Y ), + ITEM_getChar( itemindex, ITEM_UNIQUECODE), + ITEM_getChar( itemindex, ITEM_NAME), + ITEM_getInt( itemindex, ITEM_ID) + ); + if(breakflg == 1){ + sprintf(token,"%s ",ITEM_getChar( itemindex, ITEM_NAME)); + CHAR_talkToCli( talker, -1, token, CHAR_COLORWHITE); + }else{ + sprintf(token,"%s",ITEM_getChar( itemindex, ITEM_NAME)); + CHAR_talkToCli( talker, -1, token, CHAR_COLORWHITE); + } + CHAR_setItemIndex( talker, i ,-1); + ITEM_endExistItemsOne(itemindex); + CHAR_sendItemDataOne( talker, i); + if(cnt == kosuu){ + break; + } + } + } + } +#endif + }else{ +#ifndef _ITEM_PILENUMS + int j, itemindex; + char token[256]; +#endif + if(strstr(nbuf,"-1") == NULL){ + l = 1; + while(getStringFromIndexWithDelim(nbuf , "," , l, buf2, sizeof(buf2))){ + l++; + if(atoi(buff3) == atoi( buf2)){ + l = -1; + break; + } + } + if(l == -1) continue; + } + itemno = -1; +#ifdef _ITEM_PILENUMS + NPC_ActionDoPileDelItem( talker, itemno, itemno); +#else + for( j = 0 ; j < CHAR_MAXITEMHAVE ; j++){ + itemindex = CHAR_getItemIndex( talker ,j); + if( ITEM_CHECKINDEX( itemindex)){ + if( atoi( buff3) == ITEM_getInt( itemindex, ITEM_ID)) { + LogItem( + CHAR_getChar( talker, CHAR_NAME ), /* ƽҷ */ + CHAR_getChar( talker, CHAR_CDKEY ), +#ifdef _add_item_log_name // WON ADD itemlogitem + itemindex, +#else + ITEM_getInt( itemindex, ITEM_ID), /* ʧ ة į */ +#endif + "EventDelItem(ջصĵ)", + CHAR_getInt( talker,CHAR_FLOOR), + CHAR_getInt( talker,CHAR_X ), + CHAR_getInt( talker,CHAR_Y ), + ITEM_getChar( itemindex, ITEM_UNIQUECODE), + ITEM_getChar( itemindex, ITEM_NAME), + ITEM_getInt( itemindex, ITEM_ID) + ); + if(breakflg == 1){ + sprintf(token,"%s ",ITEM_getChar( itemindex, ITEM_NAME)); + CHAR_talkToCli( talker, -1, token, CHAR_COLORWHITE); + }else{ + sprintf( token, "%s", + ITEM_getChar( itemindex, ITEM_NAME)); + CHAR_talkToCli( talker, -1, token, CHAR_COLORWHITE); + } + CHAR_setItemIndex( talker, j ,-1); + ITEM_endExistItemsOne( itemindex); + CHAR_sendItemDataOne( talker, j); + } + } + } +#endif + } + } + + return TRUE; +} + + +/*---------------------- + * ì ëܰ] + -----------------------*/ +BOOL NPC_EventAddItem(int meindex,int talker,char *buf) +{ + + char buff3[128]; + int i = 1; + int itemindex; + char buf3[32]; + int ret; + char token[256]; + + while(getStringFromIndexWithDelim(buf , "," , i, buff3, sizeof( buff3)) + != FALSE ) + { + i++; + if(strstr( buff3, "*") != NULL) { + + int itemno; + int kosuu; + int loop = 0; + + getStringFromIndexWithDelim( buff3, "*", 1, buf3,sizeof( buf3)); + itemno = atoi( buf3); + getStringFromIndexWithDelim( buff3, "*", 2, buf3,sizeof( buf3)); + kosuu = atoi( buf3); + + for(loop = 0 ; loop < kosuu ; loop++) { + itemindex = ITEM_makeItemAndRegist( itemno); + + if(itemindex == -1) return FALSE; + + /*ʧ ةܰ( ʧ ة ľ */ + ret = CHAR_addItemSpecificItemIndex( talker, itemindex); + if( ret < 0 || ret >= CHAR_MAXITEMHAVE ) { + print("npc_exchange:ACCEPTadditem error itemindex[%d]\n",itemindex); + ITEM_endExistItemsOne( itemindex); + return FALSE; + } + + if(itemindex != -1) { + LogItem( + CHAR_getChar( talker, CHAR_NAME ), /* ƽҷ */ + CHAR_getChar( talker, CHAR_CDKEY ), +#ifdef _add_item_log_name // WON ADD itemlogitem + itemindex, +#else + ITEM_getInt( itemindex, ITEM_ID), /* ʧ ة į */ +#endif + "EventAddItem(õĵ)", + CHAR_getInt( talker, CHAR_FLOOR), + CHAR_getInt( talker, CHAR_X ), + CHAR_getInt( talker, CHAR_Y ), + ITEM_getChar( itemindex, ITEM_UNIQUECODE), + ITEM_getChar( itemindex, ITEM_NAME), + ITEM_getInt( itemindex, ITEM_ID) + ); + } + sprintf( token, "õ%s", ITEM_getChar( itemindex, ITEM_NAME)); + CHAR_talkToCli( talker, -1, token, CHAR_COLORWHITE); + + CHAR_sendItemDataOne( talker, ret); + } + }else{ + itemindex = ITEM_makeItemAndRegist( atoi( buff3)); + + if(itemindex == -1) return FALSE; + + /*ʧ ةܰ( ʧ ة ľ */ + ret = CHAR_addItemSpecificItemIndex( talker, itemindex); + if( ret < 0 || ret >= CHAR_MAXITEMHAVE ) { + print( "npc_exchange.c: ACCEPTadditem error itemindex[%d]\n", itemindex); + ITEM_endExistItemsOne( itemindex); + return FALSE; + } + + if(itemindex != -1) { + LogItem( + CHAR_getChar( talker, CHAR_NAME ), /* ƽҷ */ + CHAR_getChar( talker, CHAR_CDKEY ), +#ifdef _add_item_log_name // WON ADD itemlogitem + itemindex, +#else + ITEM_getInt( itemindex, ITEM_ID), /* ʧ ة į */ +#endif + "EventAddItem(õĵ)", + CHAR_getInt( talker, CHAR_FLOOR), + CHAR_getInt( talker, CHAR_X ), + CHAR_getInt( talker, CHAR_Y ), + ITEM_getChar( itemindex, ITEM_UNIQUECODE), + ITEM_getChar( itemindex, ITEM_NAME), + ITEM_getInt( itemindex, ITEM_ID) + ); + } + sprintf(token,"õ%s", ITEM_getChar( itemindex, ITEM_NAME)); + CHAR_talkToCli( talker, -1, token, CHAR_COLORWHITE); + + CHAR_sendItemDataOne( talker, ret); + } + } + + return TRUE; +} + + +/*--------------------------------- + *ë ƻ¼ë + ------------- ---------------------*/ +int NPC_EventFile(int meindex,int talker,char *arg) +{ + + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + char buff2[256]; + char buf[1024*2]; + int i=1; + int EvNo=0; + int evch; + int q=1; + + /*--ɬð̻ë --*/ + if(NPC_Util_GetArgStr( meindex, argstr, sizeof(argstr)) == NULL) { + + print("GetArgStrErr"); + return -1; + } + + /*ɬð̻ë*/ + while(getStringFromIndexWithDelim( argstr, "EventEnd", i, buf,sizeof( buf)) + != FALSE) + { + CHAR_setWorkInt( talker, CHAR_WORKSHOPRELEVANTSEC, 0); + i++; + /*--ìϼë--*/ + NPC_Util_GetStrFromStrWithDelim( buf, "EventNo", buff2,sizeof( buff2) ); + if(strstr(buff2,",") != NULL){ + char buf3[128]; + while(getStringFromIndexWithDelim( buff2, ",", q, buf3, sizeof( buf3)) + != FALSE) { + q++; + } + q--; + q = rand()%q + 1; + getStringFromIndexWithDelim( buff2, ",", q, buf3, sizeof( buf3)); + EvNo = atoi( buf3); + }else{ + EvNo = atoi( buff2); + } + + /*--׷ºë浤ƥì ƻݳ--*/ + if(NPC_EventCheckFlg( talker, EvNo) == TRUE) continue; + + /*--ƽë浤--*/ + if(NPC_Util_GetStrFromStrWithDelim( buf,"Pet_Name", buff2,sizeof( buff2) ) + != NULL) + { + CHAR_setWorkInt( talker, CHAR_WORKSHOPRELEVANTSEC, 1); + } + /*--ƽë浤--*/ + if(NPC_Util_GetStrFromStrWithDelim( buf,"KeyWord", buff2,sizeof( buff2) ) + != NULL) + { + if(CHAR_getWorkInt( talker, CHAR_WORKSHOPRELEVANT) != i ) continue; + } + + evch = NPC_ExChangeManEventCheck( meindex, talker, buf); + + if(evch != -1) { + /*--ì--*/ +// if(NPC_ExChangeManEventCheck( meindex, talker, buf) == TRUE) { + strcpysafe(arg, sizeof( buf) ,buf); + return evch; + } + } + + return -1; + +} + + +/*--------------------------------- + * ʧ ةͷë浤 + -----------------------------------*/ +BOOL NPC_EventReduce(int meindex,int talker,char *buf) +{ + + char buf2[512]; + char buf3[256]; + int id = 0; + int i; + int itemindex; + int itemno; + int kosuu; + int cnt = 0; + + getStringFromIndexWithDelim( buf, "=", 2, buf2, sizeof( buf2)); + getStringFromIndexWithDelim( buf2, "*", 1, buf3, sizeof( buf3)); + itemno = atoi( buf3); + getStringFromIndexWithDelim( buf2, "*", 2, buf3, sizeof( buf3)); + kosuu = atoi( buf3); + + for( i = 0 ; i < CHAR_MAXITEMHAVE ; i++ ){ + itemindex = CHAR_getItemIndex( talker , i ); + if( ITEM_CHECKINDEX( itemindex) ){ + id = ITEM_getInt( itemindex ,ITEM_ID); + if(itemno == id){ + //change add ӶԶѵж + int pilenum = ITEM_getInt( itemindex, ITEM_USEPILENUMS); + if( pilenum ) + cnt+=pilenum; + else + cnt++; + + if(cnt >= kosuu){ + return TRUE; + } + } + } + } + + return FALSE; + +} + +/*---------------------------------- + *ʸ嵩ƽë + ----------------------------------*/ +void NPC_EventPetSkill( int meindex, int talker, char *data) +{ + + int skill; + int pet; + int slot; + int cost; + int skillID = 0; + char buf[64]; + char argstr[1024]; + char msg[512]; + int petindex; + char msgbuf[128]; + int fd = getfdFromCharaIndex( talker ); + int evcnt; + + if( NPC_Util_CharDistance( talker, meindex ) > 2) { + return; + } + + evcnt = NPC_EventFile( meindex, talker, argstr); + + if(evcnt == -1) return; + + /*--ɬð̻ k ë ƻּë --*/ +// if(NPC_EventFile( meindex, talker, argstr) == FALSE) return ; + + /*ͷʧ߯Ȼ·--*/ + /* ëϷ־( į) ʸ( į) + ( į) */ + makeStringFromEscaped( data); + + /*--Ի--*/ + getStringFromIndexWithDelim( data, "|", 1, buf, sizeof( buf)); + skill = atoi( buf); + getStringFromIndexWithDelim( data, "|", 2, buf, sizeof( buf)); + pet = atoi( buf); + getStringFromIndexWithDelim( data, "|", 3, buf ,sizeof( buf)); + slot = atoi(buf); + getStringFromIndexWithDelim( data, "|", 4, buf, sizeof( buf)); + cost = atoi( buf); + + /*--ƽ ë--*/ + if( NPC_Util_GetStrFromStrWithDelim( argstr, "pet_skill", + msg, sizeof( msg)) != NULL) + { + getStringFromIndexWithDelim( msg, ",", skill, buf ,sizeof( buf)); + skillID = atoi( buf); + } + slot--; + + + petindex = CHAR_getCharPet( talker, pet-1); + + if(petindex == -1){ + print("PetindexErr"); + return; + } + + /*--ƽҷ» ئգʸëڱ --*/ + if( CHAR_getWorkInt( CONNECT_getCharaindex( fd), + CHAR_WORKBATTLEMODE) != BATTLE_CHARMODE_NONE) return ; + + /*--ʸ ë--*/ + CHAR_setPetSkill( petindex, slot, skillID); + + /*--ëӼ--*/ + CHAR_setInt( talker, CHAR_GOLD, (CHAR_getInt( talker, CHAR_GOLD) - cost)); + + snprintf( msgbuf, sizeof( msgbuf ), "W%d",pet-1); + + // ޥʸ ë˪Ի + CHAR_sendStatusString( talker, msgbuf ); + + CHAR_sendStatusString( talker, "P"); + +} + + +/*---------------------------------------- + * ʧ ةо +----------- ------------------------------*/ +BOOL NPC_ItemFullCheck(int meindex,int talker,char *buf,int mode,int evcnt) +{ + + char buff2[256]; + int i = 1,j = 1; + int maxitem = 0; + int kosuucnt = 0; + int itemindex; + char buf3[256]; + int rand_j = 0; + int rand_cnt = 0; + char nbuf[256]; + char buff6[16]; + int l = 1; + + if(NPC_Util_GetStrFromStrWithDelim( buf, "DelItem", buff2, sizeof( buff2) ) != NULL ){ + if(strstr(buff2,"EVDEL") != NULL){ + char buff4[64]; + char buff5[32]; + + i = 1; + NPC_Util_GetStrFromStrWithDelim( buf, "EVENT", buff2, sizeof( buff2)); + getStringFromIndexWithDelim(buff2, "," , evcnt, buf3, sizeof(buf3)); + + while(getStringFromIndexWithDelim(buf3, "&" , j, buff4, sizeof(buff4))){ + j++; + if(strstr(buff4,"ITEM") != NULL) { + if(strstr(buff4,"*") != NULL) { + int itemno; + + l = 1; + getStringFromIndexWithDelim(buff4, "=" , 2, buff5, sizeof(buff5)); + getStringFromIndexWithDelim(buff5, "*" , 1, buff6, sizeof(buff6)); + itemno = atoi(buff6); + + if(NPC_Util_GetStrFromStrWithDelim( buf, "NotDel", nbuf, sizeof( nbuf)) !=NULL){ + while(getStringFromIndexWithDelim(nbuf , "," , l,buff6, sizeof(buff6))) + { + l++; + if(itemno == atoi( buff6)) + { + l = -1; + break; + } + } + } + if(l == -1) continue; + getStringFromIndexWithDelim(buff5, "*" , 2, buff6, sizeof(buff6)); + maxitem -= atoi( buff6); + }else{ + getStringFromIndexWithDelim(buff4, "=" , 2, buff5, sizeof(buff5)); + l = 1; + + if(NPC_Util_GetStrFromStrWithDelim( buf, "NotDel", nbuf, sizeof( nbuf)) + !=NULL){ + while(getStringFromIndexWithDelim(nbuf , "," , l,buff6, sizeof(buff6))) { + l++; + if(atoi(buff5) == atoi( buff6)){ + l = -1; + break; + } + } + } + if(l == -1) continue; + for( i = CHAR_STARTITEMARRAY ; i < CHAR_MAXITEMHAVE ; i++ ) { + itemindex = CHAR_getItemIndex( talker , i ); + if( ITEM_CHECKINDEX( itemindex)) { + if(atoi( buff5) == ITEM_getInt( itemindex, ITEM_ID)) { + maxitem--; + } + } + } + } + } + } + }else{ + char buff3[128]; + i = 1; + while(getStringFromIndexWithDelim(buff2, "," , i, buff3, sizeof(buff3)) !=FALSE ){ + i++; + if(strstr( buff3, "*") != NULL){ + getStringFromIndexWithDelim( buff3, "*", 2, buf3, sizeof( buf3)); + maxitem -= atoi( buf3); + }else{ + for( i = CHAR_STARTITEMARRAY ; i < CHAR_MAXITEMHAVE ; i++ ) { + itemindex=CHAR_getItemIndex( talker , i ); + if( ITEM_CHECKINDEX( itemindex)) { + if(atoi( buff3) == ITEM_getInt( itemindex, ITEM_ID)) { + maxitem--; + } + } + } + } + } + + } + } + + if(NPC_Util_GetStrFromStrWithDelim( buf, "GetRandItem", buff2, sizeof( buff2) ) !=NULL && mode == 0){ + j = 1; + while(getStringFromIndexWithDelim(buff2 , "," , j, buf3, sizeof( buf3)) !=FALSE ){ + j++; + rand_j++; + } + rand_cnt = 1; + for( i = CHAR_STARTITEMARRAY ; i tm_year; + mon=1+p->tm_mon; + date=p->tm_mday; + day=p->tm_wday; + hour=p->tm_hour; + min=p->tm_min; + sec=p->tm_sec; +} + +#ifdef _EV_NUM +BOOL NPC_EventSetEvCode(int meindex,int talker) +{ + int evcodeflg,npcno,evtmp; + char tmpbuf[256]; + char *evbuf=NULL; + npcno=RAND(1,50); + evtmp = RAND(1,100); + if(evtmp<=60){ + evcodeflg=1; + }else if(evtmp>60 && evtmp<=80){ + evcodeflg=2; + }else{ + evcodeflg=3; + } + if(evcodeflg==1){ + sprintf(tmpbuf,"%d|%d",npcno,evcodeflg); + CHAR_setChar(talker,CHAR_EVCODE,tmpbuf); + }else if(evcodeflg==2){ + evbuf=sasql_ev_item(); + if(strcmp(evbuf,"err")==0){ + return FALSE; + }else{ + sprintf(tmpbuf,"%d|%d|%s",npcno,evcodeflg,evbuf); + CHAR_setChar(talker,CHAR_EVCODE,tmpbuf); + } + }else if(evcodeflg==3){ + evbuf=sasql_ev_pet(); + if(strcmp(evbuf,"err")==0){ + return FALSE; + }else{ + sprintf(tmpbuf,"%d|%d|%s",npcno,evcodeflg,evbuf); + CHAR_setChar(talker,CHAR_EVCODE,tmpbuf); + } + } + return TRUE; +} +#endif diff --git a/npc/npc_familyman.c b/npc/npc_familyman.c new file mode 100644 index 0000000..b00c4d4 --- /dev/null +++ b/npc/npc_familyman.c @@ -0,0 +1,687 @@ +#include "version.h" +#include +#include "char.h" +#include "object.h" +#include "char_base.h" +#include "npcutil.h" +#include "configfile.h" +#include "lssproto_serv.h" +#include "saacproto_cli.h" +#include "npc_familyman.h" +#include "family.h" + +extern int familyNumTotal; +extern char familyListBuf[MAXFAMILYLIST]; + +char sendbuf[1024]; +char buf[1024]; +char subbuf[128]; +int i, j; + +/* + * ɬýľūëNPC + * ƽʧìҡئľ¾֣ + * + */ + +struct { + int windowno; + int windowtype; + int buttontype; + int takeitem; + int giveitem; + char message[4096]; +}w; + +struct { + BOOL use; + int checkhaveitem; + int checkhaveitemgotowin; + int checkdonthaveitem; + int checkdonthaveitemgotowin; + int warp; + int battle; + int gotowin; +}buttonproc[13]; /* ok,cancel, yes,no,prev,next ݼ */ + + + + + +enum { + CHAR_WORK_MSGCOLOR = CHAR_NPCWORKINT1, +}; +static void NPC_Familyman_selectWindow( int meindex, int toindex, int num); +static BOOL NPC_Familyman_readData( int meindex, int windowno, BOOL chkflg); +static int NPC_Familyman_restoreButtontype( char *data ); + +/********************************* +* +*********************************/ +BOOL NPC_FamilymanInit( int meindex ) +{ + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + char buf[1024]; + //int i; + //char secondToken[1024]; + + // Robin test + // print(" familyman_Init "); + + NPC_Util_GetArgStr( meindex, argstr, sizeof( argstr)); + + if( NPC_Util_GetStrFromStrWithDelim( argstr, "conff", buf, sizeof( buf)) + == NULL ) + { + print( "familyman:ûָ趨ĵ \n"); + return FALSE; + } + /* ݱɬ÷ëƻ֧ */ + if( !NPC_Familyman_readData( meindex, -1, TRUE) ) { + return FALSE; + } + + CHAR_setInt( meindex , CHAR_WHICHTYPE , CHAR_TYPEWINDOWMAN ); + + return TRUE; +} + + + + +/********************************* +* ƾľݼ +*********************************/ +void NPC_FamilymanTalked( int meindex , int talkerindex , char *szMes ,int color ) +{ + + NPC_Familyman_selectWindow( meindex, talkerindex, 1 ); + +} +/********************************* +* έľݼ +*********************************/ +void NPC_FamilymanLooked( int meindex , int lookedindex) +{ + + print(" Look:me:%d,looked:%d ",meindex,lookedindex); + NPC_Familyman_selectWindow( meindex, lookedindex,1 ); + +} + +static void NPC_Familyman_selectWindow( int meindex, int toindex, int num) +{ + + int fd; + char buf[256]; + + /* 帲ƻ ɱ */ + if( CHAR_getInt( toindex , CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER ) { + return; + } + /* */ + if( !NPC_Util_charIsInFrontOfChar( toindex, meindex, 1 )) return; + + if( !NPC_Familyman_readData( meindex, num, FALSE) ) { + print( "familyman:readdata error\n"); + return; + } + + fd = getfdFromCharaIndex( toindex); + if( fd != -1 ) { + lssproto_WN_send( fd, w.windowtype, + w.buttontype, + w.windowno+100, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + makeEscapeString( w.message, buf, sizeof(buf))); + + } +} + +void NPC_FamilymanWindowTalked( int meindex, int talkerindex, + int seqno, int select, char *data) + +{ + + int button = -1; + char buf[256]; + + /* */ + if( NPC_Util_CharDistance( talkerindex, meindex ) > 1) return; + + // CoolFish Add For Check Old Leader Del Family + if(seqno == CHAR_WINDOWTYPE_FAMILYMAN_OUT) + { + int fd = getfdFromCharaIndex( talkerindex); + if(select == WINDOW_BUTTONTYPE_YES) + FAMILY_Leave( fd, talkerindex, "E|1"); + return; + } + // CoolFish End + + /* ū įë */ + if( !NPC_Familyman_readData( meindex, seqno - 100, FALSE) ) { + print( "familyman:readdata error\n"); + return; + } + /* ʾëƩ */ + if( w.windowtype == WINDOW_MESSAGETYPE_SELECT ) { + button = atoi( data)+5; + if( button > 12 ) { + print( "familyman:invalid button[%d]\n", button); + return; + } + } + else if( select & WINDOW_BUTTONTYPE_OK) button = 0; + else if( select & WINDOW_BUTTONTYPE_CANCEL) button = 1; + else if( select & WINDOW_BUTTONTYPE_YES) button = 2; + else if( select & WINDOW_BUTTONTYPE_NO) button = 3; + else if( select & WINDOW_BUTTONTYPE_PREV) button = 4; + else if( select & WINDOW_BUTTONTYPE_NEXT) button = 5; + else { + print( "familyman:invalid button[%d]\n", select); + return; + } + if( buttonproc[button].use == TRUE ) { + int fd; + int newwin = -1; + + fd = getfdFromCharaIndex( talkerindex); + + /* ʾ巽Ȼ ëԻ */ + if( newwin == -1 ) { + newwin = buttonproc[button].gotowin; + } + + // Robin + // + if( newwin == 5 ) { + if( CHAR_getInt( talkerindex, CHAR_FMINDEX ) > 0 ) + { + //CHAR_talkToCli( talkerindex, -1, "ʸ񲻷Ѿ塣", CHAR_COLORWHITE ); + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, -1, -1, + makeEscapeString( "\nܱǸรѾˣ", buf, sizeof(buf))); + return; + } + if( (CHAR_getInt( talkerindex, CHAR_TRANSMIGRATION ) == 0) + && (CHAR_getInt( talkerindex, CHAR_LV) < 30) ) + { + //CHAR_talkToCli( talkerindex, -1, "ܱǸȼ㡣", CHAR_COLORWHITE ); + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, -1, -1, + makeEscapeString( "\nܱǸรĵȼ㣡", buf, sizeof(buf))); + return; + } + + if( !NPC_EventCheckFlg( talkerindex, 4 ) ) + { + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, -1, -1, + makeEscapeString( "\nܱǸรɳУ", buf, sizeof(buf))); + return; + } +#ifdef _NEWFM_GOLD + if( CHAR_getInt( talkerindex, CHAR_GOLD ) < getNewFmGold() ) + { + char newfmmsg[256]; + sprintf(newfmmsg,"\nܱǸรѲ㣡\nҪѣ%dʯ\n\nУӣ𱬣ʹãҪ⣬ϣҲҪü壬лл",getNewFmGold()); + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, -1, -1, + newfmmsg); + return; + } +#else + if( CHAR_getInt( talkerindex, CHAR_GOLD ) < 10000 ) + { + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, -1, -1, + makeEscapeString( "\nܱǸรѲ㣡\nҪѣ10000ʯ\n", buf, sizeof(buf))); + return; + } +#endif + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_FAMILYADD, WINDOW_BUTTONTYPE_NONE, CHAR_WINDOWTYPE_FAMILYMAN_ADD, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), "Hello!!" ); + + return; + } + // б , + if( newwin == 6 ) + { + /* + strcpy( buf, ""); + j = 0; + for( i=1 ; i<=8 ; i++ ) { + if( i > familyNumTotal ) break; + if( getStringFromIndexWithDelim( familyListBuf, "|", i, subbuf, + sizeof(subbuf) ) == FALSE) break; + strcat( buf, "|" ); + strcat( buf, subbuf ); + j++; + } + + sprintf( sendbuf, "S|F|%d|%d|%d%s", familyNumTotal, 1, j, buf ); + //print(" FL:%s ", sendbuf ); + lssproto_FM_send( fd, sendbuf ); + */ + + //saacproto_ACShowFMList_send( acfd ); + + FAMILY_Detail( fd, talkerindex, "S|F|1|0" ); + return; + + } + // ˳ + if( newwin == 7 ) + { + if( CHAR_getInt( talkerindex, CHAR_FMINDEX ) == -1 ) { + // CHAR_talkToCli( talkerindex, -1, "㻹δκμѽ", CHAR_COLORWHITE ); + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, -1, -1, + makeEscapeString( "\nܱǸร㻹ûмκμѽ", buf, sizeof(buf))); + return; + } + + //if (CHAR_getInt(talkerindex, CHAR_FMLEADERFLAG) == FMMEMBER_LEADER) { + // CHAR_talkToCli( talkerindex, -1, "峤....", CHAR_COLORWHITE ); + // return; + //} + + print(" WN2FM "); + + // CoolFish Change for old leader del family check + if(CHAR_getInt(talkerindex, CHAR_FMLEADERFLAG) == FMMEMBER_LEADER) + { + lssproto_WN_send(fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_YESNO, CHAR_WINDOWTYPE_FAMILYMAN_OUT, + CHAR_getWorkInt(meindex, CHAR_WORKOBJINDEX), + makeEscapeString("\n峤...\n\nɢ˾޷پȻࡣ\n\nȷҪɢ",buf, sizeof(buf))); + return; + } + else + FAMILY_Leave( fd, talkerindex, "E|1"); + // CoolFish Change End + + return; + } + + if( !NPC_Familyman_readData( meindex, newwin, FALSE) ) { + print( "familyman:readdata error\n"); + return; + } + //fd = getfdFromCharaIndex( talkerindex); + if( fd != -1 ) { + lssproto_WN_send( fd, w.windowtype, + w.buttontype, + w.windowno+100, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + makeEscapeString( w.message, buf, sizeof(buf))); + } + + + + } +} +/* + * ɬð̻ë ƥ϶ýľwindownoë + * + * ¦ѡ + * meindex int NPCcharaindex + * windowno int ū į + * + */ +static BOOL NPC_Familyman_readData( int meindex, int windowno, BOOL chkflg) +{ + + int i; + int linenum = 0; + int endflg = FALSE; + int buttonendflg; + int winno = -1; + int buttonconfmode; + int b_mode; + int selectnum ; + int messagepos; + BOOL errflg = FALSE; + BOOL readflg = TRUE; + FILE *fp; + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + char filename[64]; + char opfile[128]; + char line[1024]; + char firstToken[1024]; + char secondToken[1024]; + + /* ūɬë Ի հ */ + + NPC_Util_GetArgStr( meindex, argstr, sizeof( argstr)); + /* ɬð̻ */ + NPC_Util_GetStrFromStrWithDelim( argstr, "conff", filename, sizeof( filename)); + + sprintf( opfile, "%s/", getNpcdir( ) ); + strcat( opfile, filename); + + fp = fopen( opfile, "r"); + if( fp == NULL ) { + print( "familyman:file open error [%s]\n", opfile); + return FALSE; + } + + while( readflg == TRUE ) { + endflg = FALSE; + buttonendflg = TRUE; + buttonconfmode = FALSE; + selectnum = 0; + messagepos = 0; + winno = -1; + b_mode = -1; + errflg = FALSE; + + /* */ + w.windowno = -1; + w.windowtype = -1; + w.buttontype = -1; + w.takeitem = -1; + w.giveitem = -1; + w.message[0] = '\0'; + + for( i = 0; i < arraysizeof( buttonproc); i ++ ) { + buttonproc[i].use = FALSE; + buttonproc[i].checkhaveitem = -1; + buttonproc[i].checkhaveitemgotowin = -1; + buttonproc[i].checkdonthaveitem = -1; + buttonproc[i].checkdonthaveitemgotowin = -1; + buttonproc[i].warp = -1; + buttonproc[i].battle = -1; + buttonproc[i].gotowin = -1; + } + + while( 1) { + char buf[256]; + int ret; + if( !fgets( line, sizeof( line), fp)){ + readflg = FALSE; + break; + } + + linenum ++; + + /* 춪 */ + if( line[0] == '#' || line[0] == '\n') continue; + /* ݱ */ + chomp( line ); + + /* ë */ + /* tab ë " " 徧 */ + replaceString( line, '\t' , ' ' ); + /* ʸë£*/ + for( i = 0; i < strlen( line); i ++) { + if( line[i] != ' ' ) { + break; + } + strcpy( buf, &line[i]); + } + if( i != 0 ) strcpy( line, buf); + + /* delim "=" ƥ (1)ͼë */ + ret = getStringFromIndexWithDelim( line, "=", 1, firstToken, + sizeof( firstToken ) ); + if( ret == FALSE ){ + print( "Find error at %s in line %d. Ignore\n", + filename , linenum); + continue; + } + /* delim "=" ƥ2 ͼë */ + ret = getStringFromIndexWithDelim( line, "=", 2, secondToken, + sizeof( secondToken ) ); + if( ret == FALSE ){ + print( "Find error at %s in line %d. Ignore\n", + filename , linenum); + continue; + } + + if( strcasecmp( firstToken, "winno") == 0 ) { + if( winno != -1 ) { + print( "familyman:winnoȴ¶winno\n"); + print( "filename:[%s] line[%d]\n", filename, linenum); + errflg = TRUE; + readflg = FALSE; + break; + } + /* ūNoë */ + winno = atoi( secondToken); + continue; + } + /* ūNo Ȼئݼ淴 */ + if( winno == -1 ) { + print( "familyman:winno δ壬ȴ趨\n"); + print( "filename:[%s] line[%d]\n", filename, linenum); + readflg = FALSE; + errflg = FALSE; + break; + } + /* ūNo ݷë + * ľ½ */ + if( (chkflg == FALSE && winno == windowno )|| + chkflg == TRUE) + { + if( buttonconfmode == TRUE ) { + if( strcasecmp( firstToken, "gotowin") == 0 ) { + buttonproc[b_mode].gotowin = atoi( secondToken); + } + else if( strcasecmp( firstToken, "checkhaveitem") == 0 ) { + buttonproc[b_mode].checkhaveitem = atoi( secondToken); + } + else if( strcasecmp( firstToken, "haveitemgotowin") == 0 ) { + buttonproc[b_mode].checkhaveitemgotowin = atoi( secondToken); + } + else if( strcasecmp( firstToken, "checkdonthaveitem") == 0 ) { + buttonproc[b_mode].checkdonthaveitem = atoi( secondToken); + } + else if( strcasecmp( firstToken, "donthaveitemgotowin") == 0 ) { + buttonproc[b_mode].checkdonthaveitemgotowin = atoi( secondToken); + } + else if( strcasecmp( firstToken, "endbutton") == 0 ) { + if( buttonproc[b_mode].gotowin == - 1 ) { + if( buttonproc[b_mode].checkhaveitem == -1 && + buttonproc[b_mode].checkdonthaveitem == -1) + { + errflg = TRUE; + } + else { + /* оȵƥɬýľľ */ + if( !((buttonproc[b_mode].checkhaveitem != -1 && + buttonproc[b_mode].checkhaveitemgotowin != -1) + || (buttonproc[b_mode].checkdonthaveitem != -1 && + buttonproc[b_mode].checkdonthaveitemgotowin != -1))) + { + errflg = TRUE; + } + } + } + + if( errflg == TRUE) { + print( "familyman: Ҳgotowin\n"); + print( "filename:[%s] line[%d]\n", filename, linenum); + readflg = FALSE; + errflg = TRUE; + break; + } + buttonproc[b_mode].use = TRUE; + buttonconfmode = FALSE; + buttonendflg = TRUE; + } + } + else { + + w.windowno = winno; + /* ūɬ */ + if( strcasecmp( firstToken, "wintype") == 0 ) { + w.windowtype = atoi( secondToken); + } + /* ʾɬ */ + else if( strcasecmp( firstToken, "buttontype") == 0 ) { + w.buttontype = NPC_Familyman_restoreButtontype( secondToken); + } + /* getitemɬ */ + else if( strcasecmp( firstToken, "takeitem") == 0 ) { + w.takeitem = atoi( secondToken); + } + /* giveitemɬ */ + else if( strcasecmp( firstToken, "giveitem") == 0 ) { + w.giveitem = atoi( secondToken); + } + /* messageɬ */ + else if( strcasecmp( firstToken, "message") == 0 ) { + if( messagepos == 0 ) { + strcpy( w.message, secondToken); + messagepos = strlen( w.message); + } + else { + w.message[messagepos]='\n'; + messagepos++; + strcpy( &w.message[messagepos], secondToken); + messagepos+=strlen(secondToken); + } + } + /* ʾëݼɬ */ + else if( strcasecmp( firstToken, "okpressed") == 0 ) { + buttonconfmode = TRUE; + b_mode = 0; + buttonendflg = FALSE; + } + else if( strcasecmp( firstToken, "cancelpressed") == 0 ) { + buttonconfmode = TRUE; + b_mode = 1; + buttonendflg = FALSE; + } + else if( strcasecmp( firstToken, "yespressed") == 0 ) { + buttonconfmode = TRUE; + b_mode = 2; + buttonendflg = FALSE; + } + else if( strcasecmp( firstToken, "nopressed") == 0 ) { + buttonconfmode = TRUE; + b_mode = 3; + buttonendflg = FALSE; + } + else if( strcasecmp( firstToken, "prevpressed") == 0 ) { + buttonconfmode = TRUE; + b_mode = 4; + buttonendflg = FALSE; + } + else if( strcasecmp( firstToken, "nextpressed") == 0 ) { + buttonconfmode = TRUE; + b_mode = 5; + buttonendflg = FALSE; + } + else if( strcasecmp( firstToken, "selected") == 0 ) { + buttonconfmode = TRUE; + b_mode = 6 + selectnum; + buttonendflg = FALSE; + selectnum ++; + } + /* ɬñδԻ */ + else if( strcasecmp( firstToken, "endwin") == 0 ) { + endflg = TRUE; + if( chkflg == FALSE) { + readflg = FALSE; + } + break; + } + else { + print( "familyman:趨DzܵIJ\n"); + print( "filename:[%s] line[%d]\n", filename, linenum); + } + } + } + else { + if( strcasecmp( firstToken, "endwin") == 0 ) { + winno = -1; + } + } + } + if( buttonendflg == FALSE) { + print( "familyman: Ҳendbutton\n"); + print( "filename:[%s] line[%d]\n", filename, linenum); + errflg = TRUE; + break; + } + if( winno != -1 ) { + if( w.windowtype == -1 ) { + print( "familyman: Ҳwintype\n"); + print( "filename:[%s] line[%d]\n", filename, linenum); + errflg = TRUE; + break; + } + if( w.buttontype == -1 ) { + print( "familyman: Ҳbutton\n"); + print( "filename:[%s] line[%d]\n", filename, linenum); + errflg = TRUE; + break; + } + if( strlen( w.message) == 0 ) { + print( "familyman: Ҳmessage\n"); + print( "filename:[%s] line[%d]\n", filename, linenum); + errflg = TRUE; + break; + } + } + } + fclose( fp); + + if( chkflg == FALSE && w.windowno == -1 ) { + print( "familyman: Ҳָwindowno\n"); + print( "filename:[%s] line[%d]\n", filename, linenum); + return FALSE; + } + if( winno != -1 && endflg == FALSE) { + print( "familyman: Ҳendwin\n"); + print( "filename:[%s] line[%d]\n", filename, linenum); + return FALSE; + } + if( errflg == TRUE) return FALSE; + + return TRUE; +} +/* + * buttontype=ƥ϶ ٯ ëѰ £ + * + */ +static int NPC_Familyman_restoreButtontype( char *data ) +{ + int ret = 0; + int rc; + int i; + char buff[1024]; + + for( i = 1; ; i ++ ) { + rc = getStringFromIndexWithDelim( data, "|", i, buff, + sizeof( buff ) ); + if( rc == FALSE) break; + if( strcasecmp( buff, "ok") == 0 ) { + ret |= WINDOW_BUTTONTYPE_OK; + } + else if( strcasecmp( buff, "cancel") == 0 ) { + ret |= WINDOW_BUTTONTYPE_CANCEL; + } + else if( strcasecmp( buff, "yes") == 0 ) { + ret |= WINDOW_BUTTONTYPE_YES; + } + else if( strcasecmp( buff, "no") == 0 ) { + ret |= WINDOW_BUTTONTYPE_NO; + } + else if( strcasecmp( buff, "prev") == 0 ) { + ret |= WINDOW_BUTTONTYPE_PREV; + } + else if( strcasecmp( buff, "next") == 0 ) { + ret |= WINDOW_BUTTONTYPE_NEXT; + } + } + if( ret == 0 ) { + ret = atoi( data); + } + return ret; +} + + diff --git a/npc/npc_fmchallenge.c b/npc/npc_fmchallenge.c new file mode 100644 index 0000000..bfc7c2d --- /dev/null +++ b/npc/npc_fmchallenge.c @@ -0,0 +1,738 @@ +#include "version.h" +#include +#include "char.h" +#include "object.h" +#include "lssproto_serv.h" +#include "npcutil.h" +#include "handletime.h" +#include "npc_fmchallenge.h" +#include "family.h" + +// ȫļ pk +enum { + NPC_WORK_ID = CHAR_NPCWORKINT1, // ǼԱ ID, 0 ʼ +}; + +enum { + CHAR_WORK_PAGE = CHAR_WORKSHOPRELEVANT, // ҳ + CHAR_WORK_DUELTIME = CHAR_WORKSHOPRELEVANTSEC, // ѡ pk ʱ +}; + +#define SCHEDULEFILEDIR "./Schedule/" + +void NPC_LoadPKSchedule(int meindex); // Load schedule from disk +void NPC_SavePKSchedule(int meindex); // save schedule to disk +// ų̱ data +void NPC_LIST_gendata(int meindex, int talkerindex, int page, char *buf, int size); +// ѡ data +void NPC_SELECT_gendata(int meindex, int page, char *buf, int size); +// ųϸ data +void NPC_DETAIL_gendata(int meindex, char *buf, int size, int dueltime); + +BOOL NPC_SchedulemanInit( int meindex ) +{ + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + int meid; + int interval; + + CHAR_setInt( meindex, CHAR_WHICHTYPE, CHAR_TYPEFMSCHEDULEMAN ); + CHAR_setWorkInt ( meindex, NPC_WORK_PREVIOUSCHECKTIME, -1); + + // + NPC_Util_GetArgStr(meindex, argstr, sizeof(argstr)); + meid = NPC_Util_GetNumFromStrWithDelim(argstr, "id" ); + if ((meid<0) || (meid>=MAX_SCHEDULEMAN)) { + print("SCHEDULEMAN init error: invalid ID(%d)\n",meid); + meid=0; + } + CHAR_setWorkInt(meindex, NPC_WORK_ID, meid); + + interval = NPC_Util_GetNumFromStrWithDelim(argstr, "loopinterval" ); + if ((interval<100) || (interval>10000)) interval=1000; + CHAR_setInt(meindex, CHAR_LOOPINTERVAL, interval); + + interval = NPC_Util_GetNumFromStrWithDelim(argstr, "challengetimeout"); + if ((interval<60) || (interval>60*60)) interval=20*60; + CHAR_setWorkInt(meindex, NPC_WORK_CHALLENGETIMEOUT, interval); + + interval = NPC_Util_GetNumFromStrWithDelim(argstr, "settingtimeout"); + if ((interval<10) || (interval>60*60)) interval=60; + CHAR_setWorkInt(meindex, NPC_WORK_SETTINGTIMEOUT, interval); + + interval = NPC_Util_GetNumFromStrWithDelim(argstr, "fightinterval"); + if ((interval<5) || (interval>60)) interval = 50; + CHAR_setWorkInt(meindex, NPC_WORK_FIGHTINTERVAL, interval); + + NPC_LoadPKSchedule(meindex); + + return TRUE; +} + +void NPC_SchedulemanTalked(int meindex, int talkerindex, char *msg, int color) +{ +// CHAR_talkToCli(talkerindex, meindex, "ãǼУ˵ǼԱ", color); + char buf[4096]; + int fd; + + if (NPC_Util_CharDistance(meindex, talkerindex) > 2) return; + if (!NPC_Util_isFaceToFace(meindex, talkerindex, 2)) return; + fd = getfdFromCharaIndex(talkerindex); + if (fd == -1) return; + + CHAR_setWorkInt(talkerindex, CHAR_WORK_PAGE, 0); + NPC_LIST_gendata(meindex, talkerindex, 0, buf, sizeof(buf)); + lssproto_WN_send(fd, WINDOW_MESSAGETYPE_PKSCHEDULELIST, + WINDOW_BUTTONTYPE_NEXT | WINDOW_BUTTONTYPE_CANCEL, + CHAR_WINDOWTYPE_SCHEDULEMAN_START, + CHAR_getWorkInt(meindex, CHAR_WORKOBJINDEX), + buf); +} + +void NPC_SchedulemanWindowTalked(int meindex, int talkerindex, + int seqno, int select, char *data) +{ + int page; + int buttontype; + char buf[4096],token[256]; + int fd,i,dt,a; + int fmpks_pos; + + if (NPC_Util_CharDistance(meindex,talkerindex) > 2) return; + if (!NPC_Util_isFaceToFace(meindex, talkerindex, 2)) return; + fd = getfdFromCharaIndex(talkerindex); + if (fd == -1) return; + fmpks_pos = CHAR_getWorkInt(meindex, NPC_WORK_ID)*MAX_SCHEDULE; + +// print("seqno=%d select=%d data=%s\n", seqno,select,data); + + switch (seqno) { + case CHAR_WINDOWTYPE_SCHEDULEMAN_START: + switch (select) { + case WINDOW_BUTTONTYPE_NEXT: + case WINDOW_BUTTONTYPE_PREV: + page=CHAR_getWorkInt(talkerindex, CHAR_WORK_PAGE) + + MAXSCHEDULEINONEWINDOW + * (( select == WINDOW_BUTTONTYPE_NEXT) ? 1 : -1); + buttontype=WINDOW_BUTTONTYPE_NEXT | WINDOW_BUTTONTYPE_PREV | WINDOW_BUTTONTYPE_CANCEL; + if (page<0) { + page=0; + buttontype=WINDOW_BUTTONTYPE_NEXT | WINDOW_BUTTONTYPE_CANCEL; + } + if (page>MAX_SCHEDULE-MAXSCHEDULEINONEWINDOW) { + page=MAX_SCHEDULE-MAXSCHEDULEINONEWINDOW; + buttontype=WINDOW_BUTTONTYPE_PREV | WINDOW_BUTTONTYPE_CANCEL; + } + CHAR_setWorkInt(talkerindex, CHAR_WORK_PAGE, page); + // Send WN + NPC_LIST_gendata(meindex, talkerindex, page, buf, sizeof(buf)); + lssproto_WN_send(fd, WINDOW_MESSAGETYPE_PKSCHEDULELIST, + buttontype, + CHAR_WINDOWTYPE_SCHEDULEMAN_START, + CHAR_getWorkInt(meindex, CHAR_WORKOBJINDEX), + buf); + break; + case WINDOW_BUTTONTYPE_OK: + if ((CHAR_getInt(talkerindex,CHAR_FMLEADERFLAG)==FMMEMBER_LEADER) && + (CHAR_getWorkInt(talkerindex, CHAR_WORKFMSETUPFLAG)==1)) { + // ֻѳ峤ʹýһĹ (趨ġͬ) + + // decide: send family list or detail or accept + dt=atoi(data); + for (i=0; iMAXFAMILYINONEWINDOW) + buttontype |= WINDOW_BUTTONTYPE_NEXT; + lssproto_WN_send(fd, WINDOW_MESSAGETYPE_PKSCHEDULESELECTFAMILY, + buttontype, + CHAR_WINDOWTYPE_SCHEDULEMAN_SELECT, + CHAR_getWorkInt(meindex, CHAR_WORKOBJINDEX), + buf); + } + break; + case FMPKS_FLAG_CHALLENGE: + { // 峤Ͷͬ pk˹ + int tkfmindex=CHAR_getInt(talkerindex, CHAR_FMINDEX); + if (tkfmindex==fmpks[fmpks_pos+i].host_index) { + fmpks[fmpks_pos+i].flag=FMPKS_FLAG_SETTING; + fmpks[fmpks_pos+i].setting_timeout= + CHAR_getWorkInt(meindex, NPC_WORK_SETTINGTIMEOUT); + // ͳϸб + CHAR_setWorkInt(talkerindex, CHAR_WORK_DUELTIME, dt); + NPC_DETAIL_gendata(meindex, buf, sizeof(buf), dt); + lssproto_WN_send(fd, WINDOW_MESSAGETYPE_PKSCHEDULEDETAIL, + WINDOW_BUTTONTYPE_OK | WINDOW_BUTTONTYPE_CANCEL, + CHAR_WINDOWTYPE_SCHEDULEMAN_DETAIL, + CHAR_getWorkInt(meindex, CHAR_WORKOBJINDEX), + buf); + } else if (tkfmindex==fmpks[fmpks_pos+i].guest_index) { + fmpks[fmpks_pos+i].flag=FMPKS_FLAG_SCHEDULED; + page=CHAR_getWorkInt(talkerindex, CHAR_WORK_PAGE); + buttontype=WINDOW_BUTTONTYPE_NEXT | WINDOW_BUTTONTYPE_PREV | WINDOW_BUTTONTYPE_OK; + if (page<0) { + page=0; + buttontype=WINDOW_BUTTONTYPE_NEXT | WINDOW_BUTTONTYPE_OK; + } + if (page>MAX_SCHEDULE-MAXSCHEDULEINONEWINDOW) { + page=MAX_SCHEDULE-MAXSCHEDULEINONEWINDOW; + buttontype=WINDOW_BUTTONTYPE_PREV | WINDOW_BUTTONTYPE_OK; + } + CHAR_talkToCli(talkerindex, meindex, + "ļѾս", CHAR_COLORWHITE); + // ͳ list + NPC_LIST_gendata(meindex, talkerindex, page, buf, sizeof(buf)); + lssproto_WN_send(fd, WINDOW_MESSAGETYPE_PKSCHEDULELIST, + buttontype, + CHAR_WINDOWTYPE_SCHEDULEMAN_START, + CHAR_getWorkInt(meindex, CHAR_WORKOBJINDEX), + buf); + } + } + break; + case FMPKS_FLAG_SETTING: + { // 峤 + int tkfmindex=CHAR_getInt(talkerindex, CHAR_FMINDEX); + if (tkfmindex==fmpks[fmpks_pos+i].host_index) { + fmpks[fmpks_pos+i].flag=FMPKS_FLAG_SETTING; + fmpks[fmpks_pos+i].setting_timeout= + CHAR_getWorkInt(meindex, NPC_WORK_SETTINGTIMEOUT); + // ͳϸб + CHAR_setWorkInt(talkerindex, CHAR_WORK_DUELTIME, dt); + NPC_DETAIL_gendata(meindex, buf, sizeof(buf), dt); + lssproto_WN_send(fd, WINDOW_MESSAGETYPE_PKSCHEDULEDETAIL, + WINDOW_BUTTONTYPE_OK | WINDOW_BUTTONTYPE_CANCEL, + CHAR_WINDOWTYPE_SCHEDULEMAN_DETAIL, + CHAR_getWorkInt(meindex, CHAR_WORKOBJINDEX), + buf); + } + } + } + break; + } + } + NPC_SavePKSchedule(meindex); + } else { + + if (CHAR_getInt(talkerindex,CHAR_FMLEADERFLAG)!=FMMEMBER_LEADER) { + CHAR_talkToCli(talkerindex, meindex, + "ֻ峤ԤԼУม", CHAR_COLORWHITE); + } else if (CHAR_getWorkInt(talkerindex, CHAR_WORKFMSETUPFLAG)!=1) { + CHAR_talkToCli(talkerindex, meindex, + "ļ廹ûʽม", CHAR_COLORWHITE); + } + } + + break; + } + break; + case CHAR_WINDOWTYPE_SCHEDULEMAN_SELECT: + switch (select) { + case WINDOW_BUTTONTYPE_PREV: + case WINDOW_BUTTONTYPE_NEXT: + page=CHAR_getWorkInt(talkerindex, CHAR_WORK_PAGE) + + MAXFAMILYINONEWINDOW + * (( select == WINDOW_BUTTONTYPE_NEXT) ? 1 : -1); + buttontype=WINDOW_BUTTONTYPE_NEXT | WINDOW_BUTTONTYPE_PREV; + if (page<1) { + page=1; + buttontype=WINDOW_BUTTONTYPE_NEXT; + } + if (page>familyNumTotal-MAXFAMILYINONEWINDOW+1) { + page=familyNumTotal-MAXFAMILYINONEWINDOW+1; + buttontype=WINDOW_BUTTONTYPE_PREV; + } + CHAR_setWorkInt(talkerindex, CHAR_WORK_PAGE, page); + // Send WN + NPC_SELECT_gendata(meindex, page, buf, sizeof(buf)); + lssproto_WN_send(fd, WINDOW_MESSAGETYPE_PKSCHEDULESELECTFAMILY, + buttontype, + CHAR_WINDOWTYPE_SCHEDULEMAN_SELECT, + CHAR_getWorkInt(meindex, CHAR_WORKOBJINDEX), + buf); + break; + case WINDOW_BUTTONTYPE_OK: +#ifdef _FMVER21 + if ((CHAR_getInt(talkerindex,CHAR_FMLEADERFLAG)==FMMEMBER_LEADER) && +#else + if ((CHAR_getInt(talkerindex,CHAR_FMLEADERFLAG)==1) && +#endif + (CHAR_getWorkInt(talkerindex, CHAR_WORKFMSETUPFLAG)==1)) { + dt=CHAR_getWorkInt(talkerindex, CHAR_WORK_DUELTIME); + for (i=0; i0) && (a<=40)) fmpks[fmpks_pos+i].prepare_time=a; + } + // + if (getStringFromIndexWithDelim(data,"|",5,token,sizeof(token))) { + a=atoi(token); +#ifdef _FMWAR_PLAYERNUM + if ((a>0) && (a<=getFmWarPlayerNum())) fmpks[fmpks_pos+i].max_player=a; +#else + if ((a>0) && (a<=50)) fmpks[fmpks_pos+i].max_player=a; +#endif + } + fmpks[fmpks_pos+i].flag=FMPKS_FLAG_CHALLENGE; + fmpks[fmpks_pos+i].challenge_timeout= + CHAR_getWorkInt(meindex, NPC_WORK_CHALLENGETIMEOUT); + CHAR_talkToCli(talkerindex, meindex, + "ս趨ɡ", CHAR_COLORWHITE); + } + break; + case WINDOW_BUTTONTYPE_CANCEL: + fmpks[fmpks_pos+i].flag=FMPKS_FLAG_NONE; + CHAR_talkToCli(talkerindex, meindex, + "ս", CHAR_COLORWHITE); + break; + } + NPC_SavePKSchedule(meindex); + } + } + } + } + break; + } +} + +void NPC_SchedulemanLoop(int meindex) +{ +// int fmpks_pos = CHAR_getWorkInt(meindex, NPC_WORK_ID)*MAX_SCHEDULE; + +/* + print("Scheduleman: fmpks_pos=%d dueltime=%d host=%s guest=%s\n", + fmpks_pos, fmpks[fmpks_pos].dueltime, fmpks[fmpks_pos].host_name, fmpks[fmpks_pos].guest_name); +*/ + + NPC_RemoveExpiredBattle(meindex); + NPC_ProcessTimeout(meindex); +} + +// Ƴڵս +void NPC_RemoveExpiredBattle(int meindex) +{ + struct tm tm1; + int keeptime; + int i,expired=-1; + int fmpks_pos = CHAR_getWorkInt(meindex, NPC_WORK_ID)*MAX_SCHEDULE; + int prevckt = CHAR_getWorkInt(meindex, NPC_WORK_PREVIOUSCHECKTIME); + int fin = CHAR_getWorkInt(meindex, NPC_WORK_FIGHTINTERVAL); + int h,d; + + // Ŀǰʱ̵׼ȥƳڵų + memcpy( &tm1, localtime( (time_t *)&NowTime.tv_sec), sizeof( tm1)); +/* + if (tm1.tm_hour==0) + keeptime=0; + else + keeptime=(tm1.tm_hour-1)*100 + tm1.tm_min; +*/ + if (tm1.tm_min=0) { + // ƶųȡѾʧЧų + for (i=expired+1; i=60 ) h=h+100-60; + if (h>=2400) { + h = h-2400; + d = 10000; + } + fmpks[fmpks_pos+i].dueltime=d+h; + } + } +} + +// timeout +void NPC_ProcessTimeout(int meindex) +{ + int i; + int fmpks_pos = CHAR_getWorkInt(meindex, NPC_WORK_ID)*MAX_SCHEDULE; + + for (i=0; i=0) { + fmpks[fmpks_pos+i].challenge_timeout--; + if (fmpks[fmpks_pos+i].challenge_timeout<0) { + fmpks[fmpks_pos+i].host_index = -1; + strcpy(fmpks[fmpks_pos+i].host_name, "-1"); + fmpks[fmpks_pos+i].guest_index = -1; + strcpy(fmpks[fmpks_pos+i].guest_name, "-1"); + fmpks[fmpks_pos+i].prepare_time = -1; + fmpks[fmpks_pos+i].max_player = -1; + fmpks[fmpks_pos+i].flag=-1; + } + } + } + if (fmpks[fmpks_pos+i].flag==FMPKS_FLAG_SETTING) { + if (fmpks[fmpks_pos+i].setting_timeout>=0) { + fmpks[fmpks_pos+i].setting_timeout--; + if (fmpks[fmpks_pos+i].setting_timeout<0) { + fmpks[fmpks_pos+i].host_index = -1; + strcpy(fmpks[fmpks_pos+i].host_name, "-1"); + fmpks[fmpks_pos+i].guest_index = -1; + strcpy(fmpks[fmpks_pos+i].guest_name, "-1"); + fmpks[fmpks_pos+i].prepare_time = -1; + fmpks[fmpks_pos+i].max_player = -1; + fmpks[fmpks_pos+i].flag=-1; + } + } + } + } +} + +// , һֻܰһս +BOOL NPC_AlreadyScheduled(int meindex, int talkerindex) +{ + int i; + int fmpks_pos = CHAR_getWorkInt(meindex, NPC_WORK_ID)*MAX_SCHEDULE; + int tkfmindex = CHAR_getInt(talkerindex, CHAR_FMINDEX); + int flag=1; + + for (i=0; i=FMPKS_FLAG_SCHEDULED) { + if (fmpks[fmpks_pos+i].host_index==tkfmindex) return TRUE; + } else if (fmpks[fmpks_pos+i].flag!=FMPKS_FLAG_NONE) { + if (flag==1) flag=0; else return TRUE; + } + } + return FALSE; +} + +// ȡ schedule +void NPC_LoadPKSchedule(int meindex) +{ + char filename[256],tmp[4096],token[256]; + FILE *f; + int i; + int fmpks_pos = CHAR_getWorkInt(meindex, NPC_WORK_ID)*MAX_SCHEDULE; + + snprintf(filename,sizeof(filename), "%s%d_%d_%d", + SCHEDULEFILEDIR, CHAR_getInt(meindex, CHAR_FLOOR), + CHAR_getInt(meindex, CHAR_X), + CHAR_getInt(meindex, CHAR_Y) ); + + if( ! (f=fopen( filename, "r" )) ){ // create new schedule file + f = fopen( filename, "w" ); + if( !f ){ + print( "ERROR:Can't create Schedule file %s!\n",filename ); + return; + } + for (i=0; i=MAX_SCHEDULE)) return; + + // ¼Ŀǰʱ + memcpy( &tm1, localtime( (time_t *)&NowTime.tv_sec), sizeof( tm1)); + sprintf(buf, "%d|", tm1.tm_hour*100 + tm1.tm_min); + + for (i=page; i +#include +#include "char.h" +#include "object.h" +#include "lssproto_serv.h" +#include "saacproto_cli.h" +#include "npcutil.h" +#include "handletime.h" +#include "npc_fmdengon.h" +#include "family.h" +#include "npc_scheduleman.h" + +#define DENGONFILELINENUM 35 // ϱ +#define FMSDENGONFILELINENUM 140 // ԰ϱ +#define DENGONFILEENTRYSIZE 128 // ĴС +#ifdef _NEW_MANOR_LAW +#define MESSAGEINONEWINDOW 10 // ÿҳʾı +#else +#define MESSAGEINONEWINDOW 7 // ÿҳʾı +#endif +#define FMMAXNUM 1000 // ֵ +#define FM_MEMBERLIST 2 // Աб (ܱİ) +#define FM_MEMBERMEMO 3 // (ܱİ) +#define FM_FMMEMO 4 // ֮԰ (ܱİ) +#define FM_FMPOINT 5 // ݵ (ܱİ) +#define FM_FMDPTOP 6 // ǿ߱ (ܱİ) +#ifdef _FM_FMPOINTPK_LIST +#define FM_FMPOINTPK 7 // ׯ԰սʱ (ܱİ) +#endif +#define FM_WAITTIME (3*60) +#define FMSDENGON_SN 10000 // ֮԰ʶ + +extern struct FMMEMBER_LIST memberlist[FMMAXNUM]; // AC Աбϵ ARRAY +extern struct FMS_MEMO fmsmemo; // ֮԰ +extern struct FM_POINTLIST fmpointlist; // ݵ +extern struct FMS_DPTOP fmdptop; // ǿ߱ +extern int leaderdengonindex; // 777 幫 index +char NPC_sendbuf[DENGONFILEENTRYSIZE*MESSAGEINONEWINDOW]; // һҳĴС +char enlistbuf[4096]; // Աļ BUF(ʾõ) + +unsigned long READTIME1 = 0, + READTIME2 = 0, + READTIME3 = 0, + READTIME4 = 0; + +#ifdef _FIX_FM_FMPOINT +void ApplyFamilyPoint( int meindex, int toindex, int select); +#endif + +// ijʼ(when gmsv start) +BOOL NPC_FmDengonInit( int meindex) +{ + int i; + + CHAR_setInt( meindex, CHAR_WHICHTYPE, CHAR_TYPEDENGON); + + if( CHAR_getInt(meindex, CHAR_FLOOR) == 777 ){ + leaderdengonindex = meindex; + } + + if( READTIME1 == 0 || READTIME2 == 0 || READTIME3 == 0 || READTIME4 == 0 ){ + READTIME1 = NowTime.tv_sec+FM_WAITTIME, + READTIME2 = NowTime.tv_sec+FM_WAITTIME, + READTIME3 = NowTime.tv_sec+FM_WAITTIME, + READTIME4 = NowTime.tv_sec+FM_WAITTIME; + + // ȡüijԱб(memberlist struct)Լ԰ + for( i=0; i DENGONDISTANCE) return; +#endif + + // ԰ + if( seqno == CHAR_WINDOWTYPE_FM_DENGON) + { + int dengonindex; + int fmindex_wk; + char tmp_buffer[4096],tmp[4096]; + + getStringFromIndexWithDelim(data,"|",1,tmp_buffer,sizeof(tmp_buffer)); + dengonindex = atoi(tmp_buffer); + + fmindex_wk = CHAR_getWorkInt( talker, CHAR_WORKFMINDEXI); + + if( fmindex_wk < 0 || fmindex_wk >= FMMAXNUM) return; + + switch( select){ + case WINDOW_BUTTONTYPE_NEXT: + case WINDOW_BUTTONTYPE_PREV: + { + int fd,i; + fd = getfdFromCharaIndex( talker); + if( fd == -1) return; + + dengonindex += 7 * (( select == WINDOW_BUTTONTYPE_NEXT) ? 1 : -1); + if( dengonindex > memberlist[fmindex_wk].memoindex && memberlist[fmindex_wk].memonum < DENGONFILELINENUM) + dengonindex = memberlist[fmindex_wk].memoindex; + else if( dengonindex < 6 && memberlist[fmindex_wk].memonum < DENGONFILELINENUM) + dengonindex = 6; + else if( dengonindex < 1 && memberlist[fmindex_wk].memonum >= DENGONFILELINENUM) + dengonindex = memberlist[fmindex_wk].memonum+dengonindex; + else if( dengonindex > memberlist[fmindex_wk].memonum && memberlist[fmindex_wk].memonum >= DENGONFILELINENUM) + dengonindex -= memberlist[fmindex_wk].memonum; + + buttontype = WINDOW_BUTTONTYPE_OKCANCEL; + if( dengonindex==memberlist[fmindex_wk].memoindex && memberlist[fmindex_wk].memonum >= DENGONFILELINENUM) + buttontype |= WINDOW_BUTTONTYPE_PREV; + else if( (dengonindex - 7)<=memberlist[fmindex_wk].memoindex && (dengonindex - 7)>=(memberlist[fmindex_wk].memoindex - 7) && + memberlist[fmindex_wk].memonum >= DENGONFILELINENUM) + buttontype |= WINDOW_BUTTONTYPE_NEXT; + else if( dengonindex==memberlist[fmindex_wk].memoindex) + buttontype |= WINDOW_BUTTONTYPE_PREV; + else if( dengonindex == 6) buttontype |= WINDOW_BUTTONTYPE_NEXT; + else{ + buttontype |= WINDOW_BUTTONTYPE_PREV; + buttontype |= WINDOW_BUTTONTYPE_NEXT; + } + if(dengonindex >= 6){ + strcpy( NPC_sendbuf, memberlist[fmindex_wk].memo[dengonindex - 6]); + strcat( NPC_sendbuf, "\n"); + for( i=(dengonindex - 5); i<=dengonindex; i++){ + strcat( NPC_sendbuf, memberlist[fmindex_wk].memo[i]); + strcat( NPC_sendbuf, "\n"); + } + sprintf(tmp, "%d\n", dengonindex); + strcat( NPC_sendbuf, tmp); + } + if(dengonindex < 6){ + strcpy( NPC_sendbuf, memberlist[fmindex_wk].memo[memberlist[fmindex_wk].memonum+(dengonindex - 6)]); + strcat( NPC_sendbuf, "\n"); + for( i=memberlist[fmindex_wk].memonum+(dengonindex - 5); i DENGONFILELINENUM) + memberlist[fmindex_wk].memonum = DENGONFILELINENUM; + + memberlist[fmindex_wk].memoindex++; + if( memberlist[fmindex_wk].memoindex >= DENGONFILELINENUM) + memberlist[fmindex_wk].memoindex=0; + + dengonindex = memberlist[fmindex_wk].memoindex; + + if( dengonindex < 6 && memberlist[fmindex_wk].memonum= 6){ + strcpy( NPC_sendbuf, memberlist[fmindex_wk].memo[dengonindex - 6]); + strcat( NPC_sendbuf, "\n"); + for( i=(dengonindex-5); i<=dengonindex; i++){ + strcat( NPC_sendbuf, memberlist[fmindex_wk].memo[i]); + strcat( NPC_sendbuf, "\n"); + } + sprintf(tmp, "%d\n", dengonindex); + strcat( NPC_sendbuf, tmp); + } + if( dengonindex < 6){ + strcpy( NPC_sendbuf, memberlist[fmindex_wk].memo[memberlist[fmindex_wk].memonum+(dengonindex - 6)]); + strcat( NPC_sendbuf, "\n"); + for( i=memberlist[fmindex_wk].memonum+(dengonindex - 5); i fmsmemo.memoindex && fmsmemo.memonum < FMSDENGONFILELINENUM) + dengonindex = fmsmemo.memoindex; + else if( dengonindex < 6 && fmsmemo.memonum < FMSDENGONFILELINENUM) + dengonindex = 6; + else if( dengonindex < 1 && fmsmemo.memonum >= FMSDENGONFILELINENUM) + dengonindex = fmsmemo.memonum+dengonindex; + else if( dengonindex > fmsmemo.memonum && fmsmemo.memonum >= FMSDENGONFILELINENUM) + dengonindex -= fmsmemo.memonum; + + buttontype = WINDOW_BUTTONTYPE_OKCANCEL; + if( dengonindex==fmsmemo.memoindex && fmsmemo.memonum >= FMSDENGONFILELINENUM) + buttontype |= WINDOW_BUTTONTYPE_PREV; + else if( (dengonindex-7)<=fmsmemo.memoindex && (dengonindex - 7)>=(fmsmemo.memoindex - 7) && + fmsmemo.memonum >= FMSDENGONFILELINENUM) + buttontype |= WINDOW_BUTTONTYPE_NEXT; + else if( dengonindex == fmsmemo.memoindex) + buttontype |= WINDOW_BUTTONTYPE_PREV; + else if( dengonindex == 6 ) + buttontype |= WINDOW_BUTTONTYPE_NEXT; + else{ + buttontype |= WINDOW_BUTTONTYPE_PREV; + buttontype |= WINDOW_BUTTONTYPE_NEXT; + } + + if( dengonindex >= 6 ){ + if( (dengonindex - 6) >= 140 ) return; + strcpy( NPC_sendbuf, fmsmemo.memo[dengonindex - 6]); + strcat( NPC_sendbuf, "\n"); + for( i=(dengonindex - 5); i<=dengonindex; i++){ + strcat( NPC_sendbuf, fmsmemo.memo[i]); + strcat( NPC_sendbuf, "\n"); + } + sprintf(tmp, "%d\n", dengonindex); + strcat( NPC_sendbuf, tmp); + } + if(dengonindex < 6){ + if( (fmsmemo.memonum+(dengonindex - 6)) >= 140 || + (fmsmemo.memonum+(dengonindex - 6)) < 0 ) return; + + strcpy( NPC_sendbuf, fmsmemo.memo[fmsmemo.memonum+(dengonindex - 6)]); + + strcat( NPC_sendbuf, "\n"); + for( i=fmsmemo.memonum+(dengonindex - 5); i FMSDENGONFILELINENUM) + fmsmemo.memonum = FMSDENGONFILELINENUM; + + fmsmemo.memoindex++; + if( fmsmemo.memoindex >= FMSDENGONFILELINENUM) + fmsmemo.memoindex = 0; + + dengonindex = fmsmemo.memoindex; + if( dengonindex < 6 && fmsmemo.memonum= 6){ + strcpy( NPC_sendbuf, fmsmemo.memo[dengonindex - 6]); + strcat( NPC_sendbuf, "\n"); + for( i=(dengonindex - 5); i<=dengonindex; i++){ + strcat( NPC_sendbuf, fmsmemo.memo[i]); + strcat( NPC_sendbuf, "\n"); + } + sprintf(tmp, "%d\n", dengonindex); + strcat( NPC_sendbuf, tmp); + } + if(dengonindex < 6){ + strcpy( NPC_sendbuf, fmsmemo.memo[fmsmemo.memonum+(dengonindex - 6)]); + strcat( NPC_sendbuf, "\n"); + for( i=fmsmemo.memonum+(dengonindex - 5); i= FMMAXNUM) return; + + fd = getfdFromCharaIndex( talker ); + if( fd == -1 ) return; + + switch( select ){ + case WINDOW_BUTTONTYPE_OK: + { + strcpy( numberlistbuf, memberlist[fmindex_wk].numberlistarray[0]); + strcat( numberlistbuf, "\n"); + for( i=1; i<10; i++){ + strcat( numberlistbuf, memberlist[fmindex_wk].numberlistarray[i]); + strcat( numberlistbuf, "\n"); + } + // ӳʽ(ACҪļԱֵ) + sprintf(enlistbuf, "ǷļԱ|0|%d",memberlist[fmindex_wk].accept); + strcat( numberlistbuf, enlistbuf); + strcat( numberlistbuf, "\n"); + lssproto_WN_send( fd, WINDOW_FMMESSAGETYPE_SELECT, + WINDOW_BUTTONTYPE_OK| + WINDOW_BUTTONTYPE_NEXT, + CHAR_WINDOWTYPE_FM_MEMBERLIST, +#ifndef _FM_MODIFY + CHAR_getWorkInt( index, CHAR_WORKOBJINDEX), +#else + -1, +#endif + makeEscapeString( numberlistbuf, buf, sizeof(buf))); + } + break; + default: + break; + } + } + + // ǿ߱ѡӴ + else if( seqno == CHAR_WINDOWTYPE_FM_DPSELECT) + { + int fmindex_wk; + fmindex_wk = CHAR_getWorkInt( talker, CHAR_WORKFMINDEXI); + + if( CHAR_getInt(talker, CHAR_FMINDEX) > 0 ){ + if( fmindex_wk < 0 || fmindex_wk >= FMMAXNUM){ + print("FamilyNumber Data Error!!"); + return; + } + } + + buttonevent = atoi(data); + switch( buttonevent ){ + case 1: // ǰʮۺб + { + int fd,i; + char listbuf[4096]; + fd = getfdFromCharaIndex( talker ); + if( fd == -1 ) return; + + strcpy( listbuf, fmdptop.topmemo[0]); + strcat( listbuf, "\n"); + for( i=1; i<10; i++){ + strcat( listbuf, fmdptop.topmemo[i]); + strcat( listbuf, "\n"); + } + strcat( listbuf, "0\n"); +#ifdef _FMVER21 + lssproto_WN_send( fd, WINDOW_FMMESSAGETYPE_TOP30DP, +#else + lssproto_WN_send( fd, WINDOW_FMMESSAGETYPE_DP, +#endif + WINDOW_BUTTONTYPE_OK| + WINDOW_BUTTONTYPE_NEXT, + CHAR_WINDOWTYPE_FM_DPTOP, +#ifndef _FM_MODIFY + CHAR_getWorkInt( index, CHAR_WORKOBJINDEX), +#else + -1, +#endif + makeEscapeString( listbuf, buf, sizeof(buf))); + } + break; + case 2: // ǰʮðб + { + int fd,i; + char listbuf[4096]; + fd = getfdFromCharaIndex( talker ); + if( fd == -1 ) return; + + strcpy( listbuf, fmdptop.adv_topmemo[0]); + strcat( listbuf, "\n"); + for( i=1; i<10; i++){ + strcat( listbuf, fmdptop.adv_topmemo[i]); + strcat( listbuf, "\n"); + } + + lssproto_WN_send( fd, WINDOW_FMMESSAGETYPE_DP, + WINDOW_BUTTONTYPE_OK| + WINDOW_BUTTONTYPE_PREV, + CHAR_WINDOWTYPE_FM_DPME, +#ifndef _FM_MODIFY + CHAR_getWorkInt( index, CHAR_WORKOBJINDEX), +#else + -1, +#endif + makeEscapeString( listbuf, buf, sizeof(buf))); + } + break; + case 3: // ǰʮб + { + int fd,i; + char listbuf[4096]; + fd = getfdFromCharaIndex( talker ); + if( fd == -1 ) return; + + strcpy( listbuf, fmdptop.feed_topmemo[0]); + strcat( listbuf, "\n"); + for( i=1; i<10; i++){ + strcat( listbuf, fmdptop.feed_topmemo[i]); + strcat( listbuf, "\n"); + } + + lssproto_WN_send( fd, WINDOW_FMMESSAGETYPE_DP, + WINDOW_BUTTONTYPE_OK| + WINDOW_BUTTONTYPE_PREV, + CHAR_WINDOWTYPE_FM_DPME, +#ifndef _FM_MODIFY + CHAR_getWorkInt( index, CHAR_WORKOBJINDEX), +#else + -1, +#endif + makeEscapeString( listbuf, buf, sizeof(buf))); + } + break; +#ifndef _NEW_MANOR_LAW + case 4: // ǰʮϳб + { + int fd,i; + char listbuf[4096]; + fd = getfdFromCharaIndex( talker ); + if( fd == -1 ) return; + + strcpy( listbuf, fmdptop.syn_topmemo[0]); + strcat( listbuf, "\n"); + for( i=1; i<10; i++){ + strcat( listbuf, fmdptop.syn_topmemo[i]); + strcat( listbuf, "\n"); + } + + lssproto_WN_send( fd, WINDOW_FMMESSAGETYPE_DP, + WINDOW_BUTTONTYPE_OK| + WINDOW_BUTTONTYPE_PREV, + CHAR_WINDOWTYPE_FM_DPME, +#ifndef _FM_MODIFY + CHAR_getWorkInt( index, CHAR_WORKOBJINDEX), +#else + -1, +#endif + makeEscapeString( listbuf, buf, sizeof(buf))); + } + break; + case 5: // ǰʮб + { + int fd,i; + char listbuf[4096]; + fd = getfdFromCharaIndex( talker ); + if( fd == -1 ) return; + + strcpy( listbuf, fmdptop.food_topmemo[0]); + strcat( listbuf, "\n"); + for( i=1; i<10; i++){ + strcat( listbuf, fmdptop.food_topmemo[i]); + strcat( listbuf, "\n"); + } + + lssproto_WN_send( fd, WINDOW_FMMESSAGETYPE_DP, + WINDOW_BUTTONTYPE_OK| + WINDOW_BUTTONTYPE_PREV, + CHAR_WINDOWTYPE_FM_DPME, +#ifndef _FM_MODIFY + CHAR_getWorkInt( index, CHAR_WORKOBJINDEX), +#else + -1, +#endif + makeEscapeString( listbuf, buf, sizeof(buf))); + } + break; +#endif +#ifdef _NEW_MANOR_LAW + case 4: // ǰʮУб +#else + case 6: // ǰʮУб +#endif + { + int fd,i; + char listbuf[4096]; + fd = getfdFromCharaIndex( talker ); + if( fd == -1 ) return; + + strcpy( listbuf, fmdptop.pk_topmemo[0]); + strcat( listbuf, "\n"); + for( i=1; i<10; i++){ + strcat( listbuf, fmdptop.pk_topmemo[i]); + strcat( listbuf, "\n"); + } + + lssproto_WN_send( fd, WINDOW_FMMESSAGETYPE_DP, + WINDOW_BUTTONTYPE_OK| + WINDOW_BUTTONTYPE_PREV, + CHAR_WINDOWTYPE_FM_DPME, +#ifndef _FM_MODIFY + CHAR_getWorkInt( index, CHAR_WORKOBJINDEX), +#else + -1, +#endif + makeEscapeString( listbuf, buf, sizeof(buf))); + } + break; +#ifdef _NEW_MANOR_LAW + case 5: // ʮƼ + { + int fd,i; + char listbuf[4096]; + fd = getfdFromCharaIndex( talker ); + if( fd == -1 ) return; + + strcpy( listbuf, fmdptop.momentum_topmemo[0]); + strcat( listbuf, "\n"); + for( i=1; i<10; i++){ + strcat( listbuf, fmdptop.momentum_topmemo[i]); + strcat( listbuf, "\n"); + } + + lssproto_WN_send( fd, WINDOW_FMMESSAGETYPE_10_MEMONTUM, + WINDOW_BUTTONTYPE_OK| + WINDOW_BUTTONTYPE_PREV, + CHAR_WINDOWTYPE_FM_DPME, +#ifndef _FM_MODIFY + CHAR_getWorkInt( index, CHAR_WORKOBJINDEX), +#else + -1, +#endif + makeEscapeString( listbuf, buf, sizeof(buf))); + } + break; +#endif +#ifndef _NEW_MANOR_LAW + case 7: // Լа +#else + case 6: +#endif + { + int fd,i,h,k,fmid; + char listbuf[4096]; + + fd = getfdFromCharaIndex( talker ); + if( fd == -1 ) return; + + fmid = CHAR_getWorkInt(talker, CHAR_WORKFMINDEXI); + if( fmid < 0 ){ + sprintf( NPC_sendbuf, " 桻\n Ǹ㲻ǼԱ޷鿴"); + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, WINDOW_BUTTONTYPE_OK, + -1, + -1, + makeEscapeString( NPC_sendbuf, buf, sizeof(buf))); + return; + } + + for( h=0; h= 994 ) h = 990; + else h -= 4; + + strcpy( listbuf, fmdptop.topmemo[h]); + if( k == h ) strcat( listbuf, "|1"); + strcat( listbuf, "\n"); + for( i = h + 1; i < h + 10; i++){ + strcat( listbuf, fmdptop.topmemo[i]); + if(i == k) strcat( listbuf, "|1"); + strcat( listbuf, "\n"); + } +#ifdef _FMVER21 + lssproto_WN_send( fd, WINDOW_FMMESSAGETYPE_TOP30DP, +#else + lssproto_WN_send( fd, WINDOW_FMMESSAGETYPE_DP, +#endif + WINDOW_BUTTONTYPE_OK| + WINDOW_BUTTONTYPE_PREV, + CHAR_WINDOWTYPE_FM_DPME, +#ifndef _FM_MODIFY + CHAR_getWorkInt( index, CHAR_WORKOBJINDEX), +#else + -1, +#endif + makeEscapeString( listbuf, buf, sizeof(buf))); + } + break; +#ifdef _NEW_MANOR_LAW + case 7: // Լ + { + int fd,h,fmid; + char listbuf[4096]; + char szTempbuf[12]; + + fd = getfdFromCharaIndex( talker ); + if( fd == -1 ) return; + + fmid = CHAR_getWorkInt(talker, CHAR_WORKFMINDEXI); + if( fmid < 0 ){ + sprintf( NPC_sendbuf, " 桻\n Ǹ㲻ǼԱ޷鿴"); + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, WINDOW_BUTTONTYPE_OK, + -1, + -1, + makeEscapeString( NPC_sendbuf, buf, sizeof(buf))); + return; + } + + for( h=0; h 0 ){ + if( fmindex_wk < 0 || fmindex_wk >= FMMAXNUM){ + print("FamilyNumber Data Error!!"); + return; + } + } + + buttonevent = atoi(data); + + switch( buttonevent ){ + case FM_MEMBERLIST: + { + int fd; + + fd = getfdFromCharaIndex( talker ); + if( fd == -1 ) return; + + if( CHAR_getInt(talker, CHAR_FMINDEX) <= 0){ + sprintf( NPC_sendbuf, " 桻\n Ǹ㲻ǼԱʹù"); + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, WINDOW_BUTTONTYPE_OK, + -1, -1, makeEscapeString( NPC_sendbuf, buf, sizeof(buf))); + return; + } + /* + #ifdef _FMVER21 + if( CHAR_getInt( talker, CHAR_FMLEADERFLAG ) == FMMEMBER_LEADER || + CHAR_getInt( talker, CHAR_FMLEADERFLAG ) == FMMEMBER_ELDER ){ + #else + if( CHAR_getInt( talker, CHAR_FMLEADERFLAG) == 1){ + #endif + saacproto_ACShowMemberList_send( acfd, fmindex_wk); + READTIME1 = NowTime.tv_sec+FM_WAITTIME; + }else + */ + if( NowTime.tv_sec > READTIME1 ){ + saacproto_ACShowMemberList_send( acfd, fmindex_wk); + READTIME1 = NowTime.tv_sec+FM_WAITTIME; + } + +#ifdef _FMVER21 + // if( CHAR_getInt( talker, CHAR_FMLEADERFLAG ) == FMMEMBER_LEADER || + // CHAR_getInt( talker, CHAR_FMLEADERFLAG ) == FMMEMBER_ELDER || + // CHAR_getInt( talker, CHAR_FMLEADERFLAG ) == FMMEMBER_VICELEADER ){ + if( CHAR_getInt( talker, CHAR_FMLEADERFLAG ) == FMMEMBER_LEADER || + CHAR_getInt( talker, CHAR_FMLEADERFLAG ) == FMMEMBER_ELDER ){ +#else + if( CHAR_getInt( talker, CHAR_FMLEADERFLAG) == 1 ){ +#endif + sprintf( NPC_sendbuf, " ֪\nСĴԱϣһ޸޷ظԭ̬Сġ"); + }else{ + sprintf( NPC_sendbuf, " ֪\n ˱峤޸ģԱܲ鿴"); + } + + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + CHAR_WINDOWTYPE_FM_MESSAGE2, +#ifndef _FM_MODIFY + CHAR_getWorkInt( index, CHAR_WORKOBJINDEX), +#else + -1, +#endif + makeEscapeString( NPC_sendbuf, buf, sizeof(buf))); + } + break; + case FM_FMPOINT: + { + int fd; + + fd = getfdFromCharaIndex( talker ); + if( fd == -1 ) return; + +#ifdef _FMVER21 + if( CHAR_getInt( talker, CHAR_FMLEADERFLAG) == FMMEMBER_LEADER ){ +#else + if( CHAR_getInt( talker, CHAR_FMLEADERFLAG) == 1 ){ +#endif + saacproto_ACFMPointList_send(acfd); + sprintf( NPC_sendbuf, " ֪\nСѡľݵ㣬һѡȡݵ޷ظԭ̬Сġ"); + READTIME4 = NowTime.tv_sec+FM_WAITTIME; + } + else{ + sprintf( NPC_sendbuf, " ֪\n˱峤룬Žܲ鿴"); + } + + if( NowTime.tv_sec > READTIME4 ){ + saacproto_ACFMPointList_send(acfd); + READTIME4 = NowTime.tv_sec+FM_WAITTIME; + } + + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + CHAR_WINDOWTYPE_FM_MESSAGE1, +#ifndef _FM_MODIFY + CHAR_getWorkInt( index, CHAR_WORKOBJINDEX), +#else + -1, +#endif + makeEscapeString( NPC_sendbuf, buf, sizeof(buf))); + } + break; + case FM_FMDPTOP: + { + int fd; + + fd = getfdFromCharaIndex( talker ); + if( fd == -1 ) return; + + if( NowTime.tv_sec > READTIME3 ){ + saacproto_ACShowTopFMList_send( acfd, FM_TOP_INTEGRATE ); + saacproto_ACShowTopFMList_send( acfd, FM_TOP_ADV ); + saacproto_ACShowTopFMList_send( acfd, FM_TOP_FEED ); + saacproto_ACShowTopFMList_send( acfd, FM_TOP_SYNTHESIZE ); + saacproto_ACShowTopFMList_send( acfd, FM_TOP_DEALFOOD ); + saacproto_ACShowTopFMList_send( acfd, FM_TOP_PK ); +#ifdef _NEW_MANOR_LAW + saacproto_ACShowTopFMList_send(acfd, FM_TOP_MOMENTUM); +#endif + READTIME3 = NowTime.tv_sec+FM_WAITTIME; + } + memset(NPC_sendbuf,0,sizeof(NPC_sendbuf)); + strcpy( NPC_sendbuf, "\n ʮб\n"); + strcat( NPC_sendbuf, " ʮðռ\n"); + strcat( NPC_sendbuf, " ʮ\n"); +#ifndef _NEW_MANOR_LAW + strcat( NPC_sendbuf, " ʮϳɼ\n"); + strcat( NPC_sendbuf, " ʮ\n"); +#endif + strcat( NPC_sendbuf, " ʮս\n"); +#ifdef _NEW_MANOR_LAW + strcat( NPC_sendbuf, " ʮƼ\n"); +#endif + strcat( NPC_sendbuf, " Լб\n"); +#ifdef _NEW_MANOR_LAW + strcat( NPC_sendbuf, " Լ\n"); +#endif + + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_SELECT, + WINDOW_BUTTONTYPE_NONE, + CHAR_WINDOWTYPE_FM_DPSELECT, +#ifndef _FM_MODIFY + CHAR_getWorkInt( index, CHAR_WORKOBJINDEX), +#else + -1, +#endif + makeEscapeString( NPC_sendbuf, buf, sizeof(buf))); + + } + break; + case FM_MEMBERMEMO: + { + int fd,i,dengonindex; + char tmp[4096]; + fd = getfdFromCharaIndex( talker ); + + if( fd == -1 ) return; + + if( CHAR_getInt(talker, CHAR_FMINDEX) <= 0){ + sprintf( NPC_sendbuf, " 桻\n Ǹ㲻ǼԱʹù"); + + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + -1, + -1, + makeEscapeString( NPC_sendbuf, buf, sizeof(buf))); + return; + } + + if( NowTime.tv_sec > READTIME2 ){ + saacproto_ACFMReadMemo_send( acfd, fmindex_wk); + READTIME2 = NowTime.tv_sec+FM_WAITTIME; + } + + dengonindex = memberlist[fmindex_wk].memoindex; + if( memberlist[fmindex_wk].memoindex < 6 && memberlist[fmindex_wk].memonum < DENGONFILELINENUM ){ + dengonindex = 6; + } + + if( dengonindex >= 6 ){ + strcpy( NPC_sendbuf, memberlist[fmindex_wk].memo[dengonindex - 6]); + strcat( NPC_sendbuf, "\n"); + for( i=(dengonindex - 5); i<=dengonindex; i++){ + strcat( NPC_sendbuf, memberlist[fmindex_wk].memo[i]); + strcat( NPC_sendbuf, "\n"); + } + sprintf(tmp, "%d\n", dengonindex); + strcat( NPC_sendbuf, tmp); + } + if( dengonindex < 6 ){ + strcpy( NPC_sendbuf, + memberlist[fmindex_wk].memo[memberlist[fmindex_wk].memonum + (dengonindex - 6)]); + strcat( NPC_sendbuf, "\n"); + for( i=memberlist[fmindex_wk].memonum + (dengonindex - 5); i READTIME3 ){ + saacproto_ACFMReadMemo_send( acfd, FMSDENGON_SN); + READTIME3 = NowTime.tv_sec+FM_WAITTIME; + } + dengonindex = fmsmemo.memoindex; + if( fmsmemo.memoindex<6 || fmsmemo.memonum>FMSDENGONFILELINENUM ){ + dengonindex = 6; + } + if( dengonindex >= 6 ){ + strcpy( NPC_sendbuf, fmsmemo.memo[dengonindex - 6]); + strcat( NPC_sendbuf, "\n"); + for( i=(dengonindex - 5); i<=dengonindex; i++){ + strcat( NPC_sendbuf, fmsmemo.memo[i]); + strcat( NPC_sendbuf, "\n"); + } + sprintf(tmp, "%d\n", dengonindex); + strcat( NPC_sendbuf, tmp); + } + if( dengonindex < 6 ){ + if( (fmsmemo.memonum + (dengonindex - 6)) < 0 || (fmsmemo.memonum + (dengonindex - 6)) >= 140 ) + return; + strcpy( NPC_sendbuf, fmsmemo.memo[fmsmemo.memonum + (dengonindex - 6)]); + strcat( NPC_sendbuf, "\n"); + for( i=fmsmemo.memonum + (dengonindex - 5); i= FMMAXNUM) return; + + getStringFromIndexWithDelim(data,"|",1,tmp_buffer,sizeof(tmp_buffer)); + numberlistindex = atoi(tmp_buffer); + getStringFromIndexWithDelim(data,"|",2,tmp_buffer,sizeof(tmp_buffer)); + buttonevent = atoi(tmp_buffer); + getStringFromIndexWithDelim(data,"|",3,dutybuf,sizeof(dutybuf)); + +#ifdef _FMVER21 + // if( buttonevent>=1 && buttonevent<=11 && + // ( CHAR_getInt( talker, CHAR_FMLEADERFLAG ) == FMMEMBER_LEADER || + // CHAR_getInt( talker, CHAR_FMLEADERFLAG ) == FMMEMBER_ELDER || + // CHAR_getInt( talker, CHAR_FMLEADERFLAG ) == FMMEMBER_VICELEADER )) + if( buttonevent>=1 && buttonevent<=11 && + ( CHAR_getInt( talker, CHAR_FMLEADERFLAG ) == FMMEMBER_LEADER || + CHAR_getInt( talker, CHAR_FMLEADERFLAG ) == FMMEMBER_ELDER )) +#else + if( buttonevent>=1 && buttonevent<=11 && CHAR_getInt( talker, CHAR_FMLEADERFLAG) == 1 ) +#endif + { + int fd,i; + int int_status; + char getstatus[4096]; + + fd = getfdFromCharaIndex( talker ); + if( fd == -1 ) return; + + strcpy( getstatus, memberlist[fmindex_wk].numberlistarray[numberlistindex+buttonevent - 1] + + (strlen( memberlist[fmindex_wk].numberlistarray[numberlistindex+buttonevent - 1]) - 1)); + + int_status = atoi(getstatus); + + // ļ롢˳ѡ + if( buttonevent!=11 ) +#ifdef _FMVER21 + strcpy( memberlist[fmindex_wk].numberlistarray[numberlistindex+buttonevent - 1] + + (strlen(memberlist[fmindex_wk].numberlistarray[numberlistindex+buttonevent - 1]) - 1), dutybuf); +#else + switch( int_status ){ + case 1: + case 3: + strcpy( memberlist[fmindex_wk].numberlistarray[numberlistindex+buttonevent - 1] + + (strlen(memberlist[fmindex_wk].numberlistarray[numberlistindex+buttonevent - 1]) - 1), "4"); + break; + case 2: + strcpy( memberlist[fmindex_wk].numberlistarray[numberlistindex+buttonevent - 1] + + (strlen(memberlist[fmindex_wk].numberlistarray[numberlistindex+buttonevent - 1]) - 1), "1"); + break; + default: + break; + } +#endif + // ļѡ + if( buttonevent == 11 ) + { + strcpy( getstatus, enlistbuf + (strlen(enlistbuf) - 1)); + int_status = atoi(getstatus); + + switch( int_status ){ + case 1: + memberlist[fmindex_wk].accept = 0; + sprintf(enlistbuf, "ǷļԱ|%d|%d",numberlistindex,memberlist[fmindex_wk].accept); + break; + case 0: + memberlist[fmindex_wk].accept = 1; + sprintf(enlistbuf, "ǷļԱ|%d|%d",numberlistindex,memberlist[fmindex_wk].accept); + break; + default: + break; + } + } + + strcpy( numberlistbuf, memberlist[fmindex_wk].numberlistarray[numberlistindex]); + strcat( numberlistbuf, "\n"); + for( i=(numberlistindex + 1); i memberlist[fmindex_wk].fmnum) + buttontype |= WINDOW_BUTTONTYPE_PREV; + else if( numberlistindex == 0 ) + buttontype |= WINDOW_BUTTONTYPE_NEXT; + else{ + buttontype |= WINDOW_BUTTONTYPE_PREV; + buttontype |= WINDOW_BUTTONTYPE_NEXT; + } + + lssproto_WN_send( fd, WINDOW_FMMESSAGETYPE_SELECT, + buttontype, + CHAR_WINDOWTYPE_FM_MEMBERLIST, +#ifndef _FM_MODIFY + CHAR_getWorkInt( index, CHAR_WORKOBJINDEX), +#else + -1, +#endif + makeEscapeString( numberlistbuf, buf, sizeof(buf))); + } // end if + switch( select ){ + case WINDOW_BUTTONTYPE_NEXT: + case WINDOW_BUTTONTYPE_PREV: + { + int fd,i; + + fd = getfdFromCharaIndex( talker ); + if( fd == -1 ) return; + + numberlistindex += 10 * (( select == WINDOW_BUTTONTYPE_NEXT) ? 1 : -1); + + if( numberlistindex >= memberlist[fmindex_wk].fmnum) + numberlistindex -= 10; + else if( numberlistindex < 1 ) + numberlistindex = 0; + + buttontype = WINDOW_BUTTONTYPE_OK; + if( (numberlistindex + 10) >= memberlist[fmindex_wk].fmnum) + buttontype |= WINDOW_BUTTONTYPE_PREV; + else if( numberlistindex==0 ) + buttontype |= WINDOW_BUTTONTYPE_NEXT; + else{ + buttontype |= WINDOW_BUTTONTYPE_PREV; + buttontype |= WINDOW_BUTTONTYPE_NEXT; + } + + strcpy( numberlistbuf, memberlist[fmindex_wk].numberlistarray[numberlistindex]); + strcat( numberlistbuf, "\n"); + for( i=(numberlistindex+1); i= 30) + return; + //listindex = 20; + //listindex -= 10; + //else if( listindex < 1 ) + // listindex = 0; + if (listindex < 0) return; + + buttontype = WINDOW_BUTTONTYPE_OK; + if( (listindex + 10) >= 30) + buttontype |= WINDOW_BUTTONTYPE_PREV; + else if( listindex==0 ) + buttontype |= WINDOW_BUTTONTYPE_NEXT; + else{ + buttontype |= WINDOW_BUTTONTYPE_PREV; + buttontype |= WINDOW_BUTTONTYPE_NEXT; + } + + strcpy( listbuf, fmdptop.topmemo[listindex]); + strcat( listbuf, "\n"); + for( i=(listindex+1); i 5) + pointlistindex -= 5; + else if( pointlistindex < 1 ) + pointlistindex = 0; + + buttontype = WINDOW_BUTTONTYPE_OK; + if( CHAR_getInt( talker, CHAR_FMLEADERFLAG) == FMMEMBER_LEADER && + CHAR_getWorkInt(talker, CHAR_WORKFMSETUPFLAG)==1){ + if(select==WINDOW_BUTTONTYPE_NEXT) + CHAR_setWorkInt( talker, CHAR_WORKLISTPAGE,1); + else if(select==WINDOW_BUTTONTYPE_PREV) + CHAR_setWorkInt( talker, CHAR_WORKLISTPAGE,0); + int tkfmindex = CHAR_getWorkInt(talker, CHAR_WORKFMINDEXI); + int i,check=TRUE; + char fmindex[4]; + for(i=0; i 5){ + getStringFromIndexWithDelim( fmpointlist.pointlistarray[5],"|",3, x, sizeof( x)); + getStringFromIndexWithDelim( fmpointlist.pointlistarray[5],"|",4, y, sizeof( y)); + getStringFromIndexWithDelim( fmpointlist.pointlistarray[5],"|",5, fmindex, sizeof( fmindex)); + getStringFromIndexWithDelim( fmpointlist.pointlistarray[5],"|",6, name, sizeof( name)); + if(atoi(fmindex)<=0)strcpy(name," δռ"); + sprintf(pointbuf,"%s %3s %3s %s\n", pointbuf, x, y, name); + getStringFromIndexWithDelim( fmpointlist.pointlistarray[6],"|",3, x, sizeof( x)); + getStringFromIndexWithDelim( fmpointlist.pointlistarray[6],"|",4, y, sizeof( y)); + getStringFromIndexWithDelim( fmpointlist.pointlistarray[6],"|",5, fmindex, sizeof( fmindex)); + getStringFromIndexWithDelim( fmpointlist.pointlistarray[6],"|",6, name, sizeof( name)); + if(atoi(fmindex)<=0)strcpy(name," δռ"); + sprintf(pointbuf,"%s ˹ %3s %3s %s\n", pointbuf, x, y, name); + getStringFromIndexWithDelim( fmpointlist.pointlistarray[7],"|",3, x, sizeof( x)); + getStringFromIndexWithDelim( fmpointlist.pointlistarray[7],"|",4, y, sizeof( y)); + getStringFromIndexWithDelim( fmpointlist.pointlistarray[7],"|",5, fmindex, sizeof( fmindex)); + getStringFromIndexWithDelim( fmpointlist.pointlistarray[7],"|",6, name, sizeof( name)); + if(atoi(fmindex)<=0)strcpy(name," δռ"); + sprintf(pointbuf,"%s %3s %3s %s\n", pointbuf, x, y, name); + getStringFromIndexWithDelim( fmpointlist.pointlistarray[8],"|",3, x, sizeof( x)); + getStringFromIndexWithDelim( fmpointlist.pointlistarray[8],"|",4, y, sizeof( y)); + getStringFromIndexWithDelim( fmpointlist.pointlistarray[8],"|",5, fmindex, sizeof( fmindex)); + getStringFromIndexWithDelim( fmpointlist.pointlistarray[8],"|",6, name, sizeof( name)); + if(atoi(fmindex)<=0)strcpy(name," δռ"); + sprintf(pointbuf,"%s ŷ %3s %3s %s\n", pointbuf, x, y, name); + getStringFromIndexWithDelim( fmpointlist.pointlistarray[9],"|",3, x, sizeof( x)); + getStringFromIndexWithDelim( fmpointlist.pointlistarray[9],"|",4, y, sizeof( y)); + getStringFromIndexWithDelim( fmpointlist.pointlistarray[9],"|",5, fmindex, sizeof( fmindex)); + getStringFromIndexWithDelim( fmpointlist.pointlistarray[9],"|",6, name, sizeof( name)); + if(atoi(fmindex)<=0)strcpy(name," δռ"); + sprintf(pointbuf,"%s ˹ %3s %3s %s\n", pointbuf, x, y, name); + buttontype |= WINDOW_BUTTONTYPE_PREV; + }else if( pointlistindex==0 ){ + getStringFromIndexWithDelim( fmpointlist.pointlistarray[0],"|",3, x, sizeof( x)); + getStringFromIndexWithDelim( fmpointlist.pointlistarray[0],"|",4, y, sizeof( y)); + getStringFromIndexWithDelim( fmpointlist.pointlistarray[0],"|",5, fmindex, sizeof( fmindex)); + getStringFromIndexWithDelim( fmpointlist.pointlistarray[0],"|",6, name, sizeof( name)); + if(atoi(fmindex)<=0)strcpy(name," δռ"); + sprintf(pointbuf,"%s ķ %3s %3s %s\n", pointbuf, x, y, name); + getStringFromIndexWithDelim( fmpointlist.pointlistarray[1],"|",3, x, sizeof( x)); + getStringFromIndexWithDelim( fmpointlist.pointlistarray[1],"|",4, y, sizeof( y)); + getStringFromIndexWithDelim( fmpointlist.pointlistarray[1],"|",5, fmindex, sizeof( fmindex)); + getStringFromIndexWithDelim( fmpointlist.pointlistarray[1],"|",6, name, sizeof( name)); + if(atoi(fmindex)<=0)strcpy(name," δռ"); + sprintf(pointbuf,"%s ˹ %3s %3s %s\n", pointbuf, x, y, name); + getStringFromIndexWithDelim( fmpointlist.pointlistarray[2],"|",3, x, sizeof( x)); + getStringFromIndexWithDelim( fmpointlist.pointlistarray[2],"|",4, y, sizeof( y)); + getStringFromIndexWithDelim( fmpointlist.pointlistarray[2],"|",5, fmindex, sizeof( fmindex)); + getStringFromIndexWithDelim( fmpointlist.pointlistarray[2],"|",6, name, sizeof( name)); + if(atoi(fmindex)<=0)strcpy(name," δռ"); + sprintf(pointbuf,"%s ӡ %3s %3s %s\n", pointbuf, x, y, name); + getStringFromIndexWithDelim( fmpointlist.pointlistarray[3],"|",3, x, sizeof( x)); + getStringFromIndexWithDelim( fmpointlist.pointlistarray[3],"|",4, y, sizeof( y)); + getStringFromIndexWithDelim( fmpointlist.pointlistarray[3],"|",5, fmindex, sizeof( fmindex)); + getStringFromIndexWithDelim( fmpointlist.pointlistarray[3],"|",6, name, sizeof( name)); + if(atoi(fmindex)<=0)strcpy(name," δռ"); + sprintf(pointbuf,"%s ³ %3s %3s %s\n", pointbuf, x, y, name); + getStringFromIndexWithDelim( fmpointlist.pointlistarray[4],"|",3, x, sizeof( x)); + getStringFromIndexWithDelim( fmpointlist.pointlistarray[4],"|",4, y, sizeof( y)); + getStringFromIndexWithDelim( fmpointlist.pointlistarray[4],"|",5, fmindex, sizeof( fmindex)); + getStringFromIndexWithDelim( fmpointlist.pointlistarray[4],"|",6, name, sizeof( name)); + if(atoi(fmindex)<=0)strcpy(name," δռ"); + sprintf(pointbuf,"%s %3s %3s %s\n", pointbuf, x, y, name); + buttontype |= WINDOW_BUTTONTYPE_NEXT; + }else{ + buttontype |= WINDOW_BUTTONTYPE_PREV; + buttontype |= WINDOW_BUTTONTYPE_NEXT; + } +#else + int i; + pointlistindex += 10 * (( select == WINDOW_BUTTONTYPE_NEXT) ? 1 : -1); + + if( pointlistindex > FMPOINTNUM) + pointlistindex -= 10; + else if( pointlistindex < 1 ) + pointlistindex = 0; + + buttontype = WINDOW_BUTTONTYPE_OK; + if( (pointlistindex + 10) > FMPOINTNUM) + buttontype |= WINDOW_BUTTONTYPE_PREV; + else if( pointlistindex==0 ) + buttontype |= WINDOW_BUTTONTYPE_NEXT; + else{ + buttontype |= WINDOW_BUTTONTYPE_PREV; + buttontype |= WINDOW_BUTTONTYPE_NEXT; + } + + strcpy( pointbuf, fmpointlist.pointlistarray[pointlistindex]); + strcat( pointbuf, "\n"); + for( i=(pointlistindex+1); i READTIME3 ){ + saacproto_ACShowTopFMList_send(acfd, FM_TOP_INTEGRATE); + saacproto_ACShowTopFMList_send(acfd, FM_TOP_ADV); + saacproto_ACShowTopFMList_send(acfd, FM_TOP_FEED); + saacproto_ACShowTopFMList_send(acfd, FM_TOP_SYNTHESIZE); + saacproto_ACShowTopFMList_send(acfd, FM_TOP_DEALFOOD); + saacproto_ACShowTopFMList_send(acfd, FM_TOP_PK); +#ifdef _NEW_MANOR_LAW + saacproto_ACShowTopFMList_send(acfd, FM_TOP_MOMENTUM); +#endif + READTIME3 = NowTime.tv_sec+FM_WAITTIME; + } + + strcpy( NPC_sendbuf, "\n ʮб\n"); + strcat( NPC_sendbuf, " ʮðռ\n"); + strcat( NPC_sendbuf, " ʮ\n"); +#ifndef _NEW_MANOR_LAW + strcat( NPC_sendbuf, " ʮϳɼ\n"); + strcat( NPC_sendbuf, " ʮ\n"); +#endif + strcat( NPC_sendbuf, " ʮս\n"); +#ifdef _NEW_MANOR_LAW + strcat( NPC_sendbuf, " ʮƼ\n"); +#endif + strcat( NPC_sendbuf, " Լб\n"); +#ifdef _NEW_MANOR_LAW + strcat( NPC_sendbuf, " Լ\n"); +#endif + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_SELECT, + WINDOW_BUTTONTYPE_NONE, + CHAR_WINDOWTYPE_FM_DPSELECT, +#ifndef _FM_MODIFY + CHAR_getWorkInt( index, CHAR_WORKOBJINDEX), +#else + -1, +#endif + makeEscapeString( NPC_sendbuf, buf, sizeof(buf))); + } + break; + case WINDOW_BUTTONTYPE_OK: + break; + default: + break; + } + + } +} + +// call FmDengon NPC event +#ifndef _FM_MODIFY +void NPC_FmDengonLooked( int meindex, int lookedindex ) +{ + char buf[DENGONFILEENTRYSIZE*MESSAGEINONEWINDOW*2]; + char menubuf[4096]; + int fd; + + if (!CHAR_CHECKINDEX(lookedindex)) return; + + fd = getfdFromCharaIndex( lookedindex ); + if( fd == -1 ) return; + + // վڲǰһ + if( NPC_Util_CharDistance( lookedindex, meindex ) > 1) return; + // հ״ + strcpy( menubuf, " 岼\n\n"); + strcat( menubuf, " Աб\n"); + strcat( menubuf, " \n"); + strcat( menubuf, " ֮԰\n"); + strcat( menubuf, " ݵ\n"); + strcat( menubuf, " ֮ǿ߱"); + + lssproto_WN_send(fd, WINDOW_MESSAGETYPE_SELECT, + WINDOW_BUTTONTYPE_CANCEL, + CHAR_WINDOWTYPE_FM_SELECT, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + makeEscapeString( menubuf, buf, sizeof(buf))); +} +#else +void NPC_FmDengonLooked( int meindex, int lookedindex ) +{ + char buf[DENGONFILEENTRYSIZE*MESSAGEINONEWINDOW*2]; + char menubuf[4096]; + int fd; + + if (!CHAR_CHECKINDEX(lookedindex)) return; + + fd = getfdFromCharaIndex( lookedindex ); + if( fd == -1 ) return; + + // հ״ + strcpy( menubuf, " 岼\n\n"); + strcat( menubuf, " Աб\n"); + strcat( menubuf, " \n"); + strcat( menubuf, " ֮԰\n"); + strcat( menubuf, " ݵ\n"); + strcat( menubuf, " ֮ǿ߱"); +#ifdef _FM_FMPOINTPK_LIST + strcat( menubuf, "\n"); + strcat( menubuf, " ׯ԰սʱ"); +#endif + lssproto_WN_send(fd, + WINDOW_MESSAGETYPE_SELECT, + WINDOW_BUTTONTYPE_CANCEL, + CHAR_WINDOWTYPE_FM_SELECT, + -1, + makeEscapeString( menubuf, buf, sizeof(buf))); +} +#endif + +#ifdef _FIX_FM_FMPOINT +void ApplyFamilyPoint( int meindex, int toindex, int select) +{ + int fd = getfdFromCharaIndex(toindex); + if (fd == -1) return; + char fmindex[4]; + char buf[64]; + int tkfmindex = CHAR_getWorkInt(toindex, CHAR_WORKFMINDEXI); + int i,check=0; + for (i=0; i<=MANORNUM-1; i++) { // 10ׯ԰ + getStringFromIndexWithDelim(fmpointlist.pointlistarray[i], "|", 5, fmindex, sizeof(fmindex)); + if (tkfmindex==atoi(fmindex)-1){ + return; + } + } + if(memberlist[tkfmindex].fmjoinnum<30) + check=1; + else if(CHAR_getInt( toindex, CHAR_FAME)<300000) + check=2; + getStringFromIndexWithDelim( fmpointlist.pointlistarray[select-1],"|",5, fmindex, sizeof( fmindex)); + if(atoi(fmindex)<=0 && check==0){ + saacproto_ACFixFMPoint_send(acfd,CHAR_getChar(toindex, CHAR_FMNAME),tkfmindex+1,tkfmindex, + CHAR_getChar(toindex, CHAR_FMNAME),tkfmindex+1,tkfmindex,select); + sprintf(buf, "ϲ㣡\n ׯ԰Ѿˡ"); + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, WINDOW_BUTTONTYPE_OK, + 0, CHAR_getWorkInt(meindex, CHAR_WORKOBJINDEX), buf); + }else{ + if(check==0) + sprintf(buf, "ׯ԰ݵռˣ뵽ׯ԰߹ݹԱ߹ׯ԰ɣ"); + else if(check==1) + sprintf(buf, "ܱǸׯ԰ݵ˱30ˣ"); + else if(check==2) + sprintf(buf, "ܱǸׯ԰ݵ3000ϣ"); + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, WINDOW_BUTTONTYPE_OK, + 0, CHAR_getWorkInt(meindex, CHAR_WORKOBJINDEX), buf); + } +} +#endif + diff --git a/npc/npc_fmhealer.c b/npc/npc_fmhealer.c new file mode 100644 index 0000000..25baec1 --- /dev/null +++ b/npc/npc_fmhealer.c @@ -0,0 +1,144 @@ +#include "version.h" +/*---------- Shan (BEGIN) ----------*/ +/*--------- AD 2001/05/28 ---------*/ +// +// ҽ +// +/*---------- Shan(END) ----------*/ +#include +#include +#include + +#include "object.h" +#include "char_base.h" +#include "char.h" +#include "util.h" +#include "npcutil.h" +#include "item.h" +#include "readmap.h" + +#define RANGE 2 +void NPC_FmHealerSpeak( int index, int talker); +void NPC_FmHealerAllHeal( int talker ); +BOOL NPC_FmMoneyCheck(int meindex,int talker); +int NPC_FmCostCheck(int talker); +void NPC_FmCharCheckPoint(int meindex,int talker); +int NPC_FmWorkInput(int meindex,int talker); + +BOOL NPC_FmHealerInit( int meindex ) +{ + CHAR_setInt( meindex , CHAR_WHICHTYPE , CHAR_TYPEHEALER ); + CHAR_setFlg( meindex , CHAR_ISATTACKED , 0 ); + return TRUE; +} + +void NPC_FmHealerTalked( int meindex , int talker , char *msg ,int color ) +{ + char* npcarg; + char token[32]; + int msgNo; + + npcarg = CHAR_getChar(meindex,CHAR_NPCARGUMENT); + + getStringFromIndexWithDelim( npcarg, "|", 1, token,sizeof( token)); + msgNo = atoi( token ); + + if( CHAR_getInt( talker , CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER ) + return; + + if( NPC_Util_isFaceToFace( talker, meindex , 2 ) == FALSE ) + { + if( NPC_Util_isFaceToFace( talker, meindex , 1 ) == FALSE ) + return; + } + + //if( CHAR_getInt(meindex, CHAR_FLOOR) != CHAR_getWorkInt(talker, CHAR_WORKFMFLOOR)){ + //print("\n npc floor->%d player floor->%d",CHAR_getInt(meindex, CHAR_FLOOR), + // CHAR_getWorkInt(talker, CHAR_WORKFMFLOOR)); + // CHAR_talkToCli(talker, meindex, + // "Ǹ㲻DZԱ޷ظ",CHAR_COLORWHITE); + // return; + //} + + if( (CHAR_getWorkInt( talker, CHAR_WORKPARTYMODE) == 0) + || (CHAR_getWorkInt( talker, CHAR_WORKPARTYMODE) == 2)){ + NPC_FmHealerAllHeal( talker); + if(msgNo == 1) { + CHAR_talkToCli( talker, meindex, + "ѾȫظСԼࡣ",CHAR_COLORWHITE); + }else if(msgNo == 2){ + CHAR_talkToCli( talker, meindex, + "DZԱҰظɣ",CHAR_COLORWHITE); + } + }else{ + int i = 0; + int otherindex; + for( i=0 ; i < CHAR_PARTYMAX ; i++){ + otherindex = CHAR_getWorkInt( talker, CHAR_WORKPARTYINDEX1 + i); + if(otherindex != -1){ + NPC_FmHealerAllHeal( otherindex); + if(msgNo == 1){ + CHAR_talkToCli( otherindex, meindex, + "ѾȫظСԼࡣ",CHAR_COLORWHITE); + }else if(msgNo == 2){ + CHAR_talkToCli( otherindex, meindex, + "DZԱҰظɣ",CHAR_COLORWHITE); + } + } + } + } +} + +void NPC_FmHealerAllHeal( int talker ) +{ + int i; + int petindex; + char petsend[3]; + char msgbuf[5]; + + CHAR_setInt( talker , CHAR_HP ,CHAR_getWorkInt( talker, CHAR_WORKMAXHP ) ); + CHAR_setInt( talker , CHAR_MP ,CHAR_getWorkInt( talker, CHAR_WORKMAXMP ) ); + + for(i = 0 ; i < CHAR_MAXPETHAVE; i ++){ + petindex = CHAR_getCharPet( talker, i); + if( petindex == -1 ) continue; + + if( !CHAR_CHECKINDEX( talker ) ) continue; + if( CHAR_CHECKINDEX( petindex) == FALSE ) continue; + CHAR_setFlg( petindex, CHAR_ISDIE, 0); + CHAR_setInt( petindex , CHAR_HP ,CHAR_getWorkInt( petindex, CHAR_WORKMAXHP ) ); + CHAR_setInt( petindex , CHAR_MP ,CHAR_getWorkInt( petindex, CHAR_WORKMAXMP ) ); + CHAR_complianceParameter( petindex ); + sprintf( petsend, "K%d", i ); + CHAR_sendStatusString( talker , petsend ); + } + + if(CHAR_getWorkInt( talker, CHAR_WORKPARTYMODE) != CHAR_PARTY_NONE ){ + int topartyarray = -1; + int oyaindex = CHAR_getWorkInt( talker, CHAR_WORKPARTYINDEX1); + if( CHAR_CHECKINDEX( oyaindex )){ + int i; + for( i = 0; i < CHAR_PARTYMAX; i ++ ){ + int workindex = CHAR_getWorkInt( oyaindex, CHAR_WORKPARTYINDEX1 + i); + if( CHAR_CHECKINDEX( workindex) ){ + if( workindex == talker ){ + topartyarray = i; + break; + } + } + } + for( i = 0; i < CHAR_PARTYMAX; i ++ ) { + int otherindex = CHAR_getPartyIndex( talker, i); + if( CHAR_CHECKINDEX( otherindex) ){ + snprintf( msgbuf, sizeof( msgbuf), "N%d", topartyarray); + if( otherindex != talker){ + CHAR_sendStatusString( otherindex, msgbuf); + } + } + } + } + } + CHAR_send_P_StatusString( talker, CHAR_P_STRING_HP); + CHAR_send_P_StatusString( talker, CHAR_P_STRING_MP); +} + diff --git a/npc/npc_fmletter.c b/npc/npc_fmletter.c new file mode 100644 index 0000000..a76afa1 --- /dev/null +++ b/npc/npc_fmletter.c @@ -0,0 +1,679 @@ +#include "version.h" +#include +#include "char.h" +#include "object.h" +#include "char_base.h" +#include "npcutil.h" +#include "configfile.h" +#include "lssproto_serv.h" +#include "saacproto_cli.h" +#include "npc_fmletter.h" +#include "family.h" +#include "log.h" + +extern struct FM_POINTLIST fmpointlist; + +char sendbuf[1024]; +char buf[1024]; +char subbuf[128]; +int i, j; + +/* + * ɬýľūëNPC + * ƽʧìҡئľ¾֣ + * + */ + +struct { + int windowno; + int windowtype; + int buttontype; + int takeitem; + int giveitem; + char message[4096]; + int letter; +}w; + +struct { + BOOL use; + int checkhaveitem; + int checkhaveitemgotowin; + int checkdonthaveitem; + int checkdonthaveitemgotowin; + int warp; + int battle; + int gotowin; +}buttonproc[13]; /* ok,cancel, yes,no,prev,next ݼ */ + + + + + +enum { + CHAR_WORK_MSGCOLOR = CHAR_NPCWORKINT1, +}; + +static void NPC_FmLetter_selectWindow( int meindex, int toindex, int num); +static BOOL NPC_FmLetter_readData( int meindex, int windowno, BOOL chkflg); +static int NPC_FmLetter_restoreButtontype( char *data ); + +/********************************* +* +*********************************/ +BOOL NPC_FmLetterInit( int meindex ) +{ + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + char buf[1024]; + //int i; + //char secondToken[1024]; + + // Robin test + // print(" fmleter_Init "); + + NPC_Util_GetArgStr( meindex, argstr, sizeof( argstr)); + + if( NPC_Util_GetStrFromStrWithDelim( argstr, "conff", buf, sizeof( buf)) + == NULL ) + { + print( "fmletter:ûָ趨ĵ \n"); + return FALSE; + } + /* ݱɬ÷ëƻ֧ */ + if( !NPC_FmLetter_readData( meindex, -1, TRUE) ) { + return FALSE; + } + + CHAR_setInt( meindex , CHAR_WHICHTYPE , CHAR_TYPEWINDOWMAN ); + + return TRUE; +} + + + + +/********************************* +* ƾľݼ +*********************************/ +void NPC_FmLetterTalked( int meindex , int talkerindex , char *szMes ,int color ) +{ + //print(" FmLetter_fmindex:%d ", CHAR_getInt( meindex, CHAR_FMINDEX) ); + + + int fmindex = 0, village, i; + char token[256]; + char buf[256]; + for( i=0 ; i 1) return; + + /* ū įë */ + if( !NPC_FmLetter_readData( meindex, seqno - 100, FALSE) ) { + print( "fmletter:readdata error\n"); + return; + } + /* ʾëƩ */ + if( w.windowtype == WINDOW_MESSAGETYPE_SELECT ) { + button = atoi( data)+5; + if( button > 12 ) { + print( "fmletter:invalid button[%d]\n", button); + return; + } + } + else if( select & WINDOW_BUTTONTYPE_OK) button = 0; + else if( select & WINDOW_BUTTONTYPE_CANCEL) button = 1; + else if( select & WINDOW_BUTTONTYPE_YES) button = 2; + else if( select & WINDOW_BUTTONTYPE_NO) button = 3; + else if( select & WINDOW_BUTTONTYPE_PREV) button = 4; + else if( select & WINDOW_BUTTONTYPE_NEXT) button = 5; + else { + print( "fmletter:invalid button[%d]\n", select); + return; + } + if( buttonproc[button].use == TRUE ) { + int fd; + int newwin = -1; + + fd = getfdFromCharaIndex( talkerindex); + + /* ʾ巽Ȼ ëԻ */ + if( newwin == -1 ) { + newwin = buttonproc[button].gotowin; + } + + + // Robin + if( newwin == 5 ) { + int emptyitemindexinchara = CHAR_findEmptyItemBox( talkerindex ); + int itemindex = ITEM_makeItemAndRegist( w.letter ); + + if( emptyitemindexinchara < 0 ) return; + + if( itemindex != -1 ){ + char msgbuf[128]; + CHAR_setItemIndex( talkerindex, emptyitemindexinchara, itemindex ); + /* Workëɬ */ + ITEM_setWorkInt(itemindex, ITEM_WORKOBJINDEX,-1); + ITEM_setWorkInt(itemindex, ITEM_WORKCHARAINDEX, talkerindex); + CHAR_sendItemDataOne( talkerindex, emptyitemindexinchara); + LogItem( + CHAR_getChar( talkerindex, CHAR_NAME ), /* ƽҷ */ + CHAR_getChar( talkerindex, CHAR_CDKEY ), +#ifdef _add_item_log_name // WON ADD itemlogitem + itemindex, +#else + ITEM_getInt( itemindex, ITEM_ID ), /* ʧ ة į */ +#endif + "AddLetter(뺯)", + CHAR_getInt( talkerindex,CHAR_FLOOR), + CHAR_getInt( talkerindex,CHAR_X ), + CHAR_getInt( talkerindex,CHAR_Y ), + ITEM_getChar( itemindex, ITEM_UNIQUECODE), + ITEM_getChar( itemindex, ITEM_NAME), + ITEM_getInt( itemindex, ITEM_ID) + ); + snprintf( msgbuf, sizeof( msgbuf), "%sɹ", + ITEM_getChar( itemindex, ITEM_NAME)); + CHAR_talkToCli( talkerindex, -1,msgbuf, CHAR_COLORWHITE); + } + } + + // Robin + if( newwin == 6 ) { + int emptyitemindexinchara = CHAR_findEmptyItemBox( talkerindex ); + int itemindex = ITEM_makeItemAndRegist( w.letter ); + + if( emptyitemindexinchara < 0 ) return; + + if( itemindex != -1 ){ + char msgbuf[128]; + CHAR_setItemIndex( talkerindex, emptyitemindexinchara, itemindex ); + /* Workëɬ */ + ITEM_setWorkInt(itemindex, ITEM_WORKOBJINDEX,-1); + ITEM_setWorkInt(itemindex, ITEM_WORKCHARAINDEX, talkerindex); + CHAR_sendItemDataOne( talkerindex, emptyitemindexinchara); + LogItem( + CHAR_getChar( talkerindex, CHAR_NAME ), /* ƽҷ */ + CHAR_getChar( talkerindex, CHAR_CDKEY ), +#ifdef _add_item_log_name // WON ADD itemlogitem + itemindex, +#else + ITEM_getInt( itemindex, ITEM_ID ), /* ʧ ة į */ +#endif + "AddLetter(뺯)", + CHAR_getInt( talkerindex,CHAR_FLOOR), + CHAR_getInt( talkerindex,CHAR_X ), + CHAR_getInt( talkerindex,CHAR_Y ), + ITEM_getChar( itemindex, ITEM_UNIQUECODE), + ITEM_getChar( itemindex, ITEM_NAME), + ITEM_getInt( itemindex, ITEM_ID) + ); + snprintf( msgbuf, sizeof( msgbuf), "%sɹ", + ITEM_getChar( itemindex, ITEM_NAME)); + CHAR_talkToCli( talkerindex, -1,msgbuf, CHAR_COLORWHITE); + } + } + + + if( !NPC_FmLetter_readData( meindex, newwin, FALSE) ) { + print( "fmletter:readdata error\n"); + return; + } + + //fd = getfdFromCharaIndex( talkerindex); + if( fd != -1 ) { + lssproto_WN_send( fd, w.windowtype, + w.buttontype, + w.windowno+100, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + makeEscapeString( w.message, buf, sizeof(buf))); + } + + + + } +} +/* + * ɬð̻ë ƥ϶ýľwindownoë + * + * ¦ѡ + * meindex int NPCcharaindex + * windowno int ū į + * + */ +static BOOL NPC_FmLetter_readData( int meindex, int windowno, BOOL chkflg) +{ + + int i; + int linenum = 0; + int endflg = FALSE; + int buttonendflg; + int winno = -1; + int buttonconfmode; + int b_mode; + int selectnum ; + int messagepos; + BOOL errflg = FALSE; + BOOL readflg = TRUE; + FILE *fp; + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + char filename[64]; + char opfile[128]; + char line[1024]; + char firstToken[1024]; + char secondToken[1024]; + + /* ūɬë Ի հ */ + + NPC_Util_GetArgStr( meindex, argstr, sizeof( argstr)); + /* ɬð̻ */ + NPC_Util_GetStrFromStrWithDelim( argstr, "conff", filename, sizeof( filename)); + + sprintf( opfile, "%s/", getNpcdir( ) ); + strcat( opfile, filename); + + fp = fopen( opfile, "r"); + if( fp == NULL ) { + print( "fmletter:file open error [%s]\n", opfile); + return FALSE; + } + + while( readflg == TRUE ) { + endflg = FALSE; + buttonendflg = TRUE; + buttonconfmode = FALSE; + selectnum = 0; + messagepos = 0; + winno = -1; + b_mode = -1; + errflg = FALSE; + + /* */ + w.windowno = -1; + w.windowtype = -1; + w.buttontype = -1; + w.takeitem = -1; + w.giveitem = -1; + w.message[0] = '\0'; + + for( i = 0; i < arraysizeof( buttonproc); i ++ ) { + buttonproc[i].use = FALSE; + buttonproc[i].checkhaveitem = -1; + buttonproc[i].checkhaveitemgotowin = -1; + buttonproc[i].checkdonthaveitem = -1; + buttonproc[i].checkdonthaveitemgotowin = -1; + buttonproc[i].warp = -1; + buttonproc[i].battle = -1; + buttonproc[i].gotowin = -1; + } + + while( 1) { + char buf[256]; + int ret; + if( !fgets( line, sizeof( line), fp)){ + readflg = FALSE; + break; + } + + linenum ++; + + /* 춪 */ + if( line[0] == '#' || line[0] == '\n') continue; + /* ݱ */ + chomp( line ); + + /* ë */ + /* tab ë " " 徧 */ + replaceString( line, '\t' , ' ' ); + /* ʸë£*/ + for( i = 0; i < strlen( line); i ++) { + if( line[i] != ' ' ) { + break; + } + strcpy( buf, &line[i]); + } + if( i != 0 ) strcpy( line, buf); + + /* delim "=" ƥ (1)ͼë */ + ret = getStringFromIndexWithDelim( line, "=", 1, firstToken, + sizeof( firstToken ) ); + if( ret == FALSE ){ + print( "Find error at %s in line %d. Ignore\n", + filename , linenum); + continue; + } + /* delim "=" ƥ2 ͼë */ + ret = getStringFromIndexWithDelim( line, "=", 2, secondToken, + sizeof( secondToken ) ); + if( ret == FALSE ){ + print( "Find error at %s in line %d. Ignore\n", + filename , linenum); + continue; + } + + if( strcasecmp( firstToken, "winno") == 0 ) { + if( winno != -1 ) { + print( "fmletter:winnoȴ¶winno\n"); + print( "filename:[%s] line[%d]\n", filename, linenum); + errflg = TRUE; + readflg = FALSE; + break; + } + /* ūNoë */ + winno = atoi( secondToken); + continue; + } + + /* ūNo Ȼئݼ淴 */ + if( winno == -1 ) { + print( "fmletter:winno δ壬ȴ趨\n"); + print( "filename:[%s] line[%d]\n", filename, linenum); + readflg = FALSE; + errflg = FALSE; + break; + } + /* ūNo ݷë + * ľ½ */ + if( (chkflg == FALSE && winno == windowno )|| + chkflg == TRUE) + { + if( buttonconfmode == TRUE ) { + if( strcasecmp( firstToken, "gotowin") == 0 ) { + buttonproc[b_mode].gotowin = atoi( secondToken); + } + else if( strcasecmp( firstToken, "checkhaveitem") == 0 ) { + buttonproc[b_mode].checkhaveitem = atoi( secondToken); + } + else if( strcasecmp( firstToken, "haveitemgotowin") == 0 ) { + buttonproc[b_mode].checkhaveitemgotowin = atoi( secondToken); + } + else if( strcasecmp( firstToken, "checkdonthaveitem") == 0 ) { + buttonproc[b_mode].checkdonthaveitem = atoi( secondToken); + } + else if( strcasecmp( firstToken, "donthaveitemgotowin") == 0 ) { + buttonproc[b_mode].checkdonthaveitemgotowin = atoi( secondToken); + } + else if( strcasecmp( firstToken, "endbutton") == 0 ) { + if( buttonproc[b_mode].gotowin == - 1 ) { + if( buttonproc[b_mode].checkhaveitem == -1 && + buttonproc[b_mode].checkdonthaveitem == -1) + { + errflg = TRUE; + } + else { + /* оȵƥɬýľľ */ + if( !((buttonproc[b_mode].checkhaveitem != -1 && + buttonproc[b_mode].checkhaveitemgotowin != -1) + || (buttonproc[b_mode].checkdonthaveitem != -1 && + buttonproc[b_mode].checkdonthaveitemgotowin != -1))) + { + errflg = TRUE; + } + } + } + + if( errflg == TRUE) { + print( "fmletter: Ҳgotowin\n"); + print( "filename:[%s] line[%d]\n", filename, linenum); + readflg = FALSE; + errflg = TRUE; + break; + } + buttonproc[b_mode].use = TRUE; + buttonconfmode = FALSE; + buttonendflg = TRUE; + } + } + else { + + w.windowno = winno; + + sprintf( buf, "letter%d", CHAR_getInt( meindex, CHAR_FMINDEX) ); + + /* ūɬ */ + if( strcasecmp( firstToken, "wintype") == 0 ) { + w.windowtype = atoi( secondToken); + } + /* ʾɬ */ + else if( strcasecmp( firstToken, "buttontype") == 0 ) { + w.buttontype = NPC_FmLetter_restoreButtontype( secondToken); + } + /* getitemɬ */ + else if( strcasecmp( firstToken, "takeitem") == 0 ) { + w.takeitem = atoi( secondToken); + } + /* giveitemɬ */ + else if( strcasecmp( firstToken, "giveitem") == 0 ) { + w.giveitem = atoi( secondToken); + } + else if( strcasecmp( firstToken, buf) == 0 ) { + w.letter = atoi( secondToken); + } + + /* messageɬ */ + else if( strcasecmp( firstToken, "message") == 0 ) { + if( messagepos == 0 ) { + strcpy( w.message, secondToken); + messagepos = strlen( w.message); + } + else { + w.message[messagepos]='\n'; + messagepos++; + strcpy( &w.message[messagepos], secondToken); + messagepos+=strlen(secondToken); + } + } + /* ʾëݼɬ */ + else if( strcasecmp( firstToken, "okpressed") == 0 ) { + buttonconfmode = TRUE; + b_mode = 0; + buttonendflg = FALSE; + } + else if( strcasecmp( firstToken, "cancelpressed") == 0 ) { + buttonconfmode = TRUE; + b_mode = 1; + buttonendflg = FALSE; + } + else if( strcasecmp( firstToken, "yespressed") == 0 ) { + buttonconfmode = TRUE; + b_mode = 2; + buttonendflg = FALSE; + } + else if( strcasecmp( firstToken, "nopressed") == 0 ) { + buttonconfmode = TRUE; + b_mode = 3; + buttonendflg = FALSE; + } + else if( strcasecmp( firstToken, "prevpressed") == 0 ) { + buttonconfmode = TRUE; + b_mode = 4; + buttonendflg = FALSE; + } + else if( strcasecmp( firstToken, "nextpressed") == 0 ) { + buttonconfmode = TRUE; + b_mode = 5; + buttonendflg = FALSE; + } + else if( strcasecmp( firstToken, "selected") == 0 ) { + buttonconfmode = TRUE; + b_mode = 6 + selectnum; + buttonendflg = FALSE; + selectnum ++; + } + /* ɬñδԻ */ + else if( strcasecmp( firstToken, "endwin") == 0 ) { + endflg = TRUE; + if( chkflg == FALSE) { + readflg = FALSE; + } + break; + } + else { + //print( "fmletter:趨DzܵIJ\n"); + //print( "filename:[%s] line[%d]\n", filename, linenum); + } + } + } + else { + if( strcasecmp( firstToken, "endwin") == 0 ) { + winno = -1; + } + } + } + if( buttonendflg == FALSE) { + print( "fmletter: Ҳendbutton\n"); + print( "filename:[%s] line[%d]\n", filename, linenum); + errflg = TRUE; + break; + } + if( winno != -1 ) { + if( w.windowtype == -1 ) { + print( "fmletter: Ҳwintype\n"); + print( "filename:[%s] line[%d]\n", filename, linenum); + errflg = TRUE; + break; + } + if( w.buttontype == -1 ) { + print( "fmletter: Ҳbutton\n"); + print( "filename:[%s] line[%d]\n", filename, linenum); + errflg = TRUE; + break; + } + if( strlen( w.message) == 0 ) { + print( "fmletter: Ҳmessage\n"); + print( "filename:[%s] line[%d]\n", filename, linenum); + errflg = TRUE; + break; + } + } + } + fclose( fp); + + if( chkflg == FALSE && w.windowno == -1 ) { + print( "fmletter: Ҳָwindowno\n"); + print( "filename:[%s] line[%d]\n", filename, linenum); + return FALSE; + } + if( winno != -1 && endflg == FALSE) { + print( "fmletter: Ҳendwin\n"); + print( "filename:[%s] line[%d]\n", filename, linenum); + return FALSE; + } + if( errflg == TRUE) return FALSE; + + return TRUE; +} +/* + * buttontype=ƥ϶ ٯ ëѰ £ + * + */ +static int NPC_FmLetter_restoreButtontype( char *data ) +{ + int ret = 0; + int rc; + int i; + char buff[1024]; + + for( i = 1; ; i ++ ) { + rc = getStringFromIndexWithDelim( data, "|", i, buff, + sizeof( buff ) ); + if( rc == FALSE) break; + if( strcasecmp( buff, "ok") == 0 ) { + ret |= WINDOW_BUTTONTYPE_OK; + } + else if( strcasecmp( buff, "cancel") == 0 ) { + ret |= WINDOW_BUTTONTYPE_CANCEL; + } + else if( strcasecmp( buff, "yes") == 0 ) { + ret |= WINDOW_BUTTONTYPE_YES; + } + else if( strcasecmp( buff, "no") == 0 ) { + ret |= WINDOW_BUTTONTYPE_NO; + } + else if( strcasecmp( buff, "prev") == 0 ) { + ret |= WINDOW_BUTTONTYPE_PREV; + } + else if( strcasecmp( buff, "next") == 0 ) { + ret |= WINDOW_BUTTONTYPE_NEXT; + } + } + if( ret == 0 ) { + ret = atoi( data); + } + return ret; +} + + + + diff --git a/npc/npc_fmlookwar.c b/npc/npc_fmlookwar.c new file mode 100644 index 0000000..f015496 --- /dev/null +++ b/npc/npc_fmlookwar.c @@ -0,0 +1,265 @@ +#include "version.h" +#include +#include "char.h" +#include "object.h" +#include "char_base.h" +#include "npcutil.h" +#include "npc_fmlookwar.h" +#include "lssproto_serv.h" +#include "saacproto_cli.h" +#include "readmap.h" +#include "battle.h" +#include "log.h" +#include "enemy.h" +#include "handletime.h" +#include "npc_eventaction.h" + +#ifdef _FM_NPC_LOOK_WAR +//صشøнڽ"ʦ" +enum { + WINDOW_START=1, + WINDOW_SELECT, + WINDOW_LOOKSELECT, +}; +enum { + NPC_WORK_CURRENTTIME = CHAR_NPCWORKINT1, +/* + NPC_WORK_ROUTETOY = CHAR_NPCWORKINT2, + NPC_WORK_ROUTEPOINT = CHAR_NPCWORKINT3, + NPC_WORK_ROUNDTRIP = CHAR_NPCWORKINT4, + NPC_WORK_MODE = CHAR_NPCWORKINT5, + NPC_WORK_CURRENTROUTE = CHAR_NPCWORKINT6, + NPC_WORK_ROUTEMAX = CHAR_NPCWORKINT7, + NPC_WORK_WAITTIME = CHAR_NPCWORKINT8, + NPC_WORK_CURRENTTIME = CHAR_NPCWORKINT9, + NPC_WORK_SEFLG = CHAR_NPCWORKINT10, +*/ +}; +extern int afmwarnum; +extern int bfmwarnum; +extern int cfmwarnum; +extern int dfmwarnum; +extern int efmwarnum; +extern int ffmwarnum; + +static void NPC_FmLookWarMan_selectWindow( int meindex, int toindex, int num,int select); +BOOL FmLookWarMan_Run( int meindex, int toindex, int select); + +BOOL NPC_FmLookWarManInit( int meindex ) +{ + CHAR_setWorkInt( meindex, NPC_WORK_CURRENTTIME, NowTime.tv_sec); + return TRUE; +} + +void NPC_FmLookWarManTalked( int meindex, int talkerindex, char *msg, int color ) +{ + if( CHAR_getInt( talkerindex , CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER ) + return; + if(NPC_Util_isFaceToFace( meindex ,talkerindex , 2) == FALSE) { + if(NPC_Util_isFaceToChara( talkerindex, meindex, 1) == FALSE) + return; + } +// Syu ADD Ŵʦж״̬ + if( CHAR_getWorkInt ( talkerindex , CHAR_WORKPARTYMODE) != CHAR_PARTY_NONE) + { + CHAR_talkToCli( talkerindex, meindex, "ӣ",CHAR_COLORYELLOW); + return; + } + CHAR_setWorkInt( talkerindex, CHAR_WORKSHOPRELEVANT, 0); + NPC_FmLookWarMan_selectWindow( meindex, talkerindex, WINDOW_START, 0); +} + +void NPC_FmLookWarManWindowTalked( int meindex, int talkerindex, int seqno, + int select, char *data) +{ + if( select == WINDOW_BUTTONTYPE_CANCEL || select == WINDOW_BUTTONTYPE_NO) + return; + switch( seqno) { + case NPC_FMLOOKWARMAN_START: + break; + case NPC_FMLOOKWARMAN_SELECT: + if( select == WINDOW_BUTTONTYPE_CANCEL ) + return; + NPC_FmLookWarMan_selectWindow( meindex, talkerindex, WINDOW_SELECT, atoi( data)); + break; + case NPC_FMLOOKWARMAN_LOOK: + if( select == WINDOW_BUTTONTYPE_CANCEL ) + return; + else if( select == WINDOW_BUTTONTYPE_NEXT ) + NPC_FmLookWarMan_selectWindow( meindex, talkerindex, WINDOW_SELECT, 99); + else if( select == WINDOW_BUTTONTYPE_PREV ) + NPC_FmLookWarMan_selectWindow( meindex, talkerindex, WINDOW_SELECT, 98); + else + NPC_FmLookWarMan_selectWindow( meindex, talkerindex, WINDOW_LOOKSELECT, atoi( data)); + break; + } + +} + +static void NPC_FmLookWarMan_selectWindow( int meindex, int toindex, int num,int select) +{ + char token[512]; + + int buttontype = 0, windowtype = 0, windowno = 0; + int fd = getfdFromCharaIndex( toindex); + int PREVTYPE; + windowtype = WINDOW_MESSAGETYPE_MESSAGE; + + if(NPC_Util_isFaceToFace( meindex ,toindex , 2) == FALSE) { + if(NPC_Util_isFaceToChara( toindex, meindex, 1) == FALSE) + return; + } + + memset( token, 0, sizeof( token)); + + switch( num) { + case WINDOW_START: + sprintf(token,"2\nԶ̹սԱṩ侳Ĺս\n" + "ѡҪۿս\n" + " ķׯ԰ս\n" + " ˿ׯ԰ս\n" + " ӼӴׯ԰ս\n" + " ³ׯ԰ս\n" + " 񶷳ֱ\n" + " ţдֱ\n"); + CHAR_setWorkInt( toindex, CHAR_WORKSHOPRELEVANT, WINDOW_START); + buttontype = WINDOW_BUTTONTYPE_CANCEL; + windowno = NPC_FMLOOKWARMAN_SELECT; + windowtype = WINDOW_MESSAGETYPE_SELECT; + CHAR_setWorkInt(toindex,CHAR_WORKLISTPAGE,0); + CHAR_setWorkInt(toindex,CHAR_WORKLISTSELECT,0); + break; + case WINDOW_SELECT: + PREVTYPE = 0; + if(select == 99 || select == 98){ + if(select == 98) PREVTYPE =1; + select = CHAR_getWorkInt(toindex,CHAR_WORKLISTSELECT); + } + if(select>=1 && select<=6){ + int fmwarnum = 0; + if(select == 1){ + fmwarnum = afmwarnum; + }else if(select == 2){ + fmwarnum = bfmwarnum; + }else if(select == 3){ + fmwarnum = cfmwarnum; + }else if(select == 4){ + fmwarnum = dfmwarnum; + }else if(select == 5){ + fmwarnum = efmwarnum; + }else if(select == 6){ + fmwarnum = ffmwarnum; + } + + if(fmwarnum<1){ + CHAR_talkToCli( toindex, meindex, "źõͼĿǰսԹۿ",CHAR_COLORYELLOW); + return; + } + if(PREVTYPE==1) + CHAR_setWorkInt(toindex,CHAR_WORKLISTPAGE,CHAR_getWorkInt(toindex,CHAR_WORKLISTPAGE)-1); + else + CHAR_setWorkInt(toindex,CHAR_WORKLISTPAGE,CHAR_getWorkInt(toindex,CHAR_WORKLISTPAGE)+1); + if(CHAR_getWorkInt(toindex,CHAR_WORKLISTSELECT)==0) + CHAR_setWorkInt(toindex,CHAR_WORKLISTSELECT,select); + sprintf(token,SearchFmWar(toindex,select)); + if(strcmp(token,"err")==0){ + CHAR_talkToCli( toindex, meindex, "źõͼĿǰսԹۿ",CHAR_COLORYELLOW); + return; + } + CHAR_setWorkInt( toindex, CHAR_WORKSHOPRELEVANT, WINDOW_SELECT); + if(fmwarnum>CHAR_getWorkInt(toindex,CHAR_WORKLISTPAGE)*6){ + if(CHAR_getWorkInt(toindex,CHAR_WORKLISTPAGE)-1>0) + buttontype = WINDOW_BUTTONTYPE_PREV|WINDOW_BUTTONTYPE_NEXT; + else + buttontype = WINDOW_BUTTONTYPE_CANCEL|WINDOW_BUTTONTYPE_NEXT; + }else{ + if(CHAR_getWorkInt(toindex,CHAR_WORKLISTPAGE)-1>0) + buttontype = WINDOW_BUTTONTYPE_PREV|WINDOW_BUTTONTYPE_CANCEL; + else + buttontype = WINDOW_BUTTONTYPE_CANCEL; + } + windowno = NPC_FMLOOKWARMAN_LOOK; + windowtype = WINDOW_MESSAGETYPE_SELECT; + }else + return; + break; + case WINDOW_LOOKSELECT: + if(LookFmWarIndex(toindex,select)==-1){ + CHAR_talkToCli( toindex, meindex, "źսʧܡ",CHAR_COLORYELLOW); + return; + } + break; + default: + break; + } + + lssproto_WN_send( fd, windowtype, buttontype, windowno, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), token); +} + + +void NPC_FmLookWarManLoop( int meindex) +{ + +} + +BOOL FmLookWarMan_Run( int meindex, int toindex, int select) +{ + if(select<1 || select>6) return FALSE; + switch(select){ + case 1: + if(SearchFmWarRandIndex(toindex,1042)==0){ + return TRUE; + }else{ + CHAR_talkToCli( toindex, meindex, "źõͼĿǰսԹۿ",CHAR_COLORYELLOW); + return FALSE; + } + break; + case 2: + if(SearchFmWarRandIndex(toindex,2032)==0){ + return TRUE; + }else{ + CHAR_talkToCli( toindex, meindex, "źõͼĿǰսԹۿ",CHAR_COLORYELLOW); + return FALSE; + } + break; + case 3: + if(SearchFmWarRandIndex(toindex,3032)==0){ + return TRUE; + }else{ + CHAR_talkToCli( toindex, meindex, "źõͼĿǰսԹۿ",CHAR_COLORYELLOW); + return FALSE; + } + break; + case 4: + if(SearchFmWarRandIndex(toindex,4032)==0){ + return TRUE; + }else{ + CHAR_talkToCli( toindex, meindex, "źõͼĿǰսԹۿ",CHAR_COLORYELLOW); + return FALSE; + } + break; + case 5: + if(SearchFmWarRandIndex(toindex,20000)==0){ + return TRUE; + }else{ + CHAR_talkToCli( toindex, meindex, "źõͼĿǰսԹۿ",CHAR_COLORYELLOW); + return FALSE; + } + break; + case 6: + if(SearchFmWarRandIndex(toindex,12345)==0){ + return TRUE; + }else{ + CHAR_talkToCli( toindex, meindex, "źõͼĿǰսԹۿ",CHAR_COLORYELLOW); + return FALSE; + } + break; + default: + break; + } + return FALSE; +} +#endif + + diff --git a/npc/npc_fmlookwar1.c b/npc/npc_fmlookwar1.c new file mode 100644 index 0000000..5615093 --- /dev/null +++ b/npc/npc_fmlookwar1.c @@ -0,0 +1,265 @@ +#include "version.h" +#include +#include "char.h" +#include "object.h" +#include "char_base.h" +#include "npcutil.h" +#include "npc_fmlookwar1.h" +#include "lssproto_serv.h" +#include "saacproto_cli.h" +#include "readmap.h" +#include "battle.h" +#include "log.h" +#include "enemy.h" +#include "handletime.h" +#include "npc_eventaction.h" + +#ifdef _FM_NPC_LOOK_WAR1 +//صشøнڽ"ʦ" +enum { + WINDOW_START=1, + WINDOW_SELECT, + WINDOW_LOOKSELECT, +}; +enum { + NPC_WORK_CURRENTTIME = CHAR_NPCWORKINT1, +/* + NPC_WORK_ROUTETOY = CHAR_NPCWORKINT2, + NPC_WORK_ROUTEPOINT = CHAR_NPCWORKINT3, + NPC_WORK_ROUNDTRIP = CHAR_NPCWORKINT4, + NPC_WORK_MODE = CHAR_NPCWORKINT5, + NPC_WORK_CURRENTROUTE = CHAR_NPCWORKINT6, + NPC_WORK_ROUTEMAX = CHAR_NPCWORKINT7, + NPC_WORK_WAITTIME = CHAR_NPCWORKINT8, + NPC_WORK_CURRENTTIME = CHAR_NPCWORKINT9, + NPC_WORK_SEFLG = CHAR_NPCWORKINT10, +*/ +}; +extern int afmwarnum; +extern int bfmwarnum; +extern int cfmwarnum; +extern int dfmwarnum; +extern int efmwarnum; +extern int ffmwarnum; + +static void NPC_FmLookWarMan1_selectWindow( int meindex, int toindex, int num,int select); +BOOL FmLookWarMan1_Run( int meindex, int toindex, int select); + +BOOL NPC_FmLookWarMan1Init( int meindex ) +{ + CHAR_setWorkInt( meindex, NPC_WORK_CURRENTTIME, NowTime.tv_sec); + return TRUE; +} + +void NPC_FmLookWarMan1Talked( int meindex, int talkerindex, char *msg, int color ) +{ + if( CHAR_getInt( talkerindex , CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER ) + return; + if(NPC_Util_isFaceToFace( meindex ,talkerindex , 2) == FALSE) { + if(NPC_Util_isFaceToChara( talkerindex, meindex, 1) == FALSE) + return; + } +// Syu ADD Ŵʦж״̬ + if( CHAR_getWorkInt ( talkerindex , CHAR_WORKPARTYMODE) != CHAR_PARTY_NONE) + { + CHAR_talkToCli( talkerindex, meindex, "ӣ",CHAR_COLORYELLOW); + return; + } + CHAR_setWorkInt( talkerindex, CHAR_WORKSHOPRELEVANT, 0); + NPC_FmLookWarMan1_selectWindow( meindex, talkerindex, WINDOW_START, 0); +} + +void NPC_FmLookWarMan1WindowTalked( int meindex, int talkerindex, int seqno, + int select, char *data) +{ + if( select == WINDOW_BUTTONTYPE_CANCEL || select == WINDOW_BUTTONTYPE_NO) + return; + switch( seqno) { + case NPC_FMLOOKWARMAN1_START: + break; + case NPC_FMLOOKWARMAN1_SELECT: + if( select == WINDOW_BUTTONTYPE_CANCEL ) + return; + NPC_FmLookWarMan1_selectWindow( meindex, talkerindex, WINDOW_SELECT, atoi( data)); + break; + case NPC_FMLOOKWARMAN1_LOOK: + if( select == WINDOW_BUTTONTYPE_CANCEL ) + return; + else if( select == WINDOW_BUTTONTYPE_NEXT ) + NPC_FmLookWarMan1_selectWindow( meindex, talkerindex, WINDOW_SELECT, 99); + else if( select == WINDOW_BUTTONTYPE_PREV ) + NPC_FmLookWarMan1_selectWindow( meindex, talkerindex, WINDOW_SELECT, 98); + else + NPC_FmLookWarMan1_selectWindow( meindex, talkerindex, WINDOW_LOOKSELECT, atoi( data)); + break; + } + +} + +static void NPC_FmLookWarMan1_selectWindow( int meindex, int toindex, int num,int select) +{ + char token[512]; + + int buttontype = 0, windowtype = 0, windowno = 0; + int fd = getfdFromCharaIndex( toindex); + int PREVTYPE; + windowtype = WINDOW_MESSAGETYPE_MESSAGE; + + if(NPC_Util_isFaceToFace( meindex ,toindex , 2) == FALSE) { + if(NPC_Util_isFaceToChara( toindex, meindex, 1) == FALSE) + return; + } + + memset( token, 0, sizeof( token)); + + switch( num) { + case WINDOW_START: + sprintf(token,"2\nԶ̹սԱṩ侳Ĺս\n" + "ѡҪۿս\n" + " ԰ׯ԰ս\n" + " ׯ԰ս\n" + " ˹ׯ԰ս\n" + " Ҷׯ԰ս\n" + " ŷׯ԰ս\n" + " ˹ׯս\n"); + CHAR_setWorkInt( toindex, CHAR_WORKSHOPRELEVANT, WINDOW_START); + buttontype = WINDOW_BUTTONTYPE_CANCEL; + windowno = NPC_FMLOOKWARMAN1_SELECT; + windowtype = WINDOW_MESSAGETYPE_SELECT; + CHAR_setWorkInt(toindex,CHAR_WORKLISTPAGE,0); + CHAR_setWorkInt(toindex,CHAR_WORKLISTSELECT,0); + break; + case WINDOW_SELECT: + PREVTYPE = 0; + if(select == 99 || select == 98){ + if(select == 98) PREVTYPE =1; + select = CHAR_getWorkInt(toindex,CHAR_WORKLISTSELECT); + } + if(select>=1 && select<=6){ + int fmwarnum = 0; + if(select == 1){ + fmwarnum = afmwarnum; + }else if(select == 2){ + fmwarnum = bfmwarnum; + }else if(select == 3){ + fmwarnum = cfmwarnum; + }else if(select == 4){ + fmwarnum = dfmwarnum; + }else if(select == 5){ + fmwarnum = efmwarnum; + }else if(select == 6){ + fmwarnum = ffmwarnum; + } + + if(fmwarnum<1){ + CHAR_talkToCli( toindex, meindex, "źõͼĿǰսԹۿ",CHAR_COLORYELLOW); + return; + } + if(PREVTYPE==1) + CHAR_setWorkInt(toindex,CHAR_WORKLISTPAGE,CHAR_getWorkInt(toindex,CHAR_WORKLISTPAGE)-1); + else + CHAR_setWorkInt(toindex,CHAR_WORKLISTPAGE,CHAR_getWorkInt(toindex,CHAR_WORKLISTPAGE)+1); + if(CHAR_getWorkInt(toindex,CHAR_WORKLISTSELECT)==0) + CHAR_setWorkInt(toindex,CHAR_WORKLISTSELECT,select); + sprintf(token,SearchFmWar(toindex,select)); + if(strcmp(token,"err")==0){ + CHAR_talkToCli( toindex, meindex, "źõͼĿǰսԹۿ",CHAR_COLORYELLOW); + return; + } + CHAR_setWorkInt( toindex, CHAR_WORKSHOPRELEVANT, WINDOW_SELECT); + if(fmwarnum>CHAR_getWorkInt(toindex,CHAR_WORKLISTPAGE)*6){ + if(CHAR_getWorkInt(toindex,CHAR_WORKLISTPAGE)-1>0) + buttontype = WINDOW_BUTTONTYPE_PREV|WINDOW_BUTTONTYPE_NEXT; + else + buttontype = WINDOW_BUTTONTYPE_CANCEL|WINDOW_BUTTONTYPE_NEXT; + }else{ + if(CHAR_getWorkInt(toindex,CHAR_WORKLISTPAGE)-1>0) + buttontype = WINDOW_BUTTONTYPE_PREV|WINDOW_BUTTONTYPE_CANCEL; + else + buttontype = WINDOW_BUTTONTYPE_CANCEL; + } + windowno = NPC_FMLOOKWARMAN1_LOOK; + windowtype = WINDOW_MESSAGETYPE_SELECT; + }else + return; + break; + case WINDOW_LOOKSELECT: + if(LookFmWarIndex(toindex,select)==-1){ + CHAR_talkToCli( toindex, meindex, "źսʧܡ",CHAR_COLORYELLOW); + return; + } + break; + default: + break; + } + + lssproto_WN_send( fd, windowtype, buttontype, windowno, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), token); +} + + +void NPC_FmLookWarMan1Loop( int meindex) +{ + +} + +BOOL FmLookWarMan1_Run( int meindex, int toindex, int select) +{ + if(select<1 || select>6) return FALSE; + switch(select){ + case 1: + if(SearchFmWarRandIndex(toindex,5042)==0){ + return TRUE; + }else{ + CHAR_talkToCli( toindex, meindex, "źõͼĿǰսԹۿ",CHAR_COLORYELLOW); + return FALSE; + } + break; + case 2: + if(SearchFmWarRandIndex(toindex,6032)==0){ + return TRUE; + }else{ + CHAR_talkToCli( toindex, meindex, "źõͼĿǰսԹۿ",CHAR_COLORYELLOW); + return FALSE; + } + break; + case 3: + if(SearchFmWarRandIndex(toindex,7032)==0){ + return TRUE; + }else{ + CHAR_talkToCli( toindex, meindex, "źõͼĿǰսԹۿ",CHAR_COLORYELLOW); + return FALSE; + } + break; + case 4: + if(SearchFmWarRandIndex(toindex,8032)==0){ + return TRUE; + }else{ + CHAR_talkToCli( toindex, meindex, "źõͼĿǰսԹۿ",CHAR_COLORYELLOW); + return FALSE; + } + break; + case 5: + if(SearchFmWarRandIndex(toindex,9032)==0){ + return TRUE; + }else{ + CHAR_talkToCli( toindex, meindex, "źõͼĿǰսԹۿ",CHAR_COLORYELLOW); + return FALSE; + } + break; + case 6: + if(SearchFmWarRandIndex(toindex,10032)==0){ + return TRUE; + }else{ + CHAR_talkToCli( toindex, meindex, "źõͼĿǰսԹۿ",CHAR_COLORYELLOW); + return FALSE; + } + break; + default: + break; + } + return FALSE; +} +#endif + + diff --git a/npc/npc_fmpkcallman.c b/npc/npc_fmpkcallman.c new file mode 100644 index 0000000..9f98a6c --- /dev/null +++ b/npc/npc_fmpkcallman.c @@ -0,0 +1,392 @@ +#include "version.h" +#include +#include "char.h" +#include "object.h" +#include "char_base.h" +#include "npcutil.h" +#include "lssproto_serv.h" +#include "npc_fmpkcallman.h" +#include "family.h" +#include "readmap.h" +#include "battle.h" +#include "log.h" + +// WON ADD 峤ٻ +#include "npc_scheduleman.h" +#include "handletime.h" + + +static void NPC_FMPKCallMan_selectWindow(int meindex, int toindex, int num, int select); +void NPC_CallFMMember(int meindex, int floor, int fmindex, char *fmname, int index); + +/********************************* +* +*********************************/ +BOOL NPC_FMPKCallManInit( int meindex ) +{ + char npcarg[NPC_UTIL_GETARGSTR_BUFSIZE]; + char buf[1024]; + char buff2[256]; + int fl, x, y; + + if( NPC_Util_GetArgStr( meindex, npcarg, sizeof( npcarg)) == NULL){ + print("FMPKCallMan:GetArgStrErr"); + return FALSE; + } + + /*--ɬýľ¾----*/ + /*--ɬýľئľNPCëئг--*/ + if(NPC_Util_GetStrFromStrWithDelim( npcarg, "WARP", buf, sizeof( buf))==NULL){ + print("FMPKCallMan Err is %s",npcarg); + print("FMPKCallMan Err"); + return FALSE; + } + + /*--ɬýľлַƻئľǷNPCëئ--*/ + getStringFromIndexWithDelim(buf,",",1,buff2,sizeof(buff2)); + fl=atoi(buff2); + getStringFromIndexWithDelim(buf,",",2,buff2,sizeof(buff2)); + x=atoi(buff2); + getStringFromIndexWithDelim(buf,",",3,buff2,sizeof(buff2)); + y=atoi(buff2); + + if( MAP_IsValidCoordinate( fl,x,y )== FALSE ){ + print( "FMWarp NPC:Invalid warpman ERR" ); + return FALSE; + } + + /*--ɬ--*/ + CHAR_setInt( meindex , CHAR_WHICHTYPE , CHAR_TYPEWARPMAN ); + + return TRUE; +} + +/********************************* +* ƾľݼ +*********************************/ +void NPC_FMPKCallManTalked( int meindex , int talkerindex , char *szMes ,int color ) +{ + /* 帲ƻ ɱ */ + if( CHAR_getInt( talkerindex , CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER ) { + return; + } + + /*-- ¾--*/ + if(NPC_Util_isFaceToFace(talkerindex,meindex,2 )==FALSE){ + /* */ + if( NPC_Util_isFaceToChara( talkerindex, meindex, 1) == FALSE) return; + } + + /*--ͼ--*/ + CHAR_setWorkInt(talkerindex, CHAR_WORKSHOPRELEVANT, 0); + + /*-Ԫ --*/ + NPC_FMPKCallMan_selectWindow( meindex, talkerindex, 0, -1); +} + +static void NPC_FMPKCallMan_selectWindow( int meindex, int toindex, + int num,int select) +{ + char npcarg[NPC_UTIL_GETARGSTR_BUFSIZE]; + char token[1024], buf[256], buf2[256]; + int fd = getfdFromCharaIndex(toindex); + + if( fd == -1 ) { + fprint( "getfd err\n"); + return; + } + + // print("meindex:%d toindex:%d num:%d select:%d", meindex, toindex, num, select); + + if(NPC_Util_GetArgStr( meindex, npcarg, sizeof(npcarg))==NULL){ + print("GetArgStrErr"); + return ; + } + /*--ɬð̻P ׷ʧѻ϶ýľ¾ľľɰ׷ʧѼԻ*/ + if(strstr(npcarg,"%4d")!=NULL){ + int work; + NPC_Util_GetStrFromStrWithDelim( npcarg, "WARP", buf, sizeof( buf)); + getStringFromIndexWithDelim(buf,",",1,buf2,sizeof(buf2)); + work = atoi( buf2); + } + + token[0] = '\0'; + + switch(num) { + + case 0: + if (NPC_Util_GetStrFromStrWithDelim(npcarg, "MainMsg", buf, + sizeof(buf)) == NULL) + return; + sprintf(token, "3\n У˳\n" + "%s" + "\n ٻԱ" + "\n ؼ¼㡷" + "\n ȡ", + buf); + lssproto_WN_send(fd, WINDOW_MESSAGETYPE_SELECT, + WINDOW_BUTTONTYPE_NONE, + CHAR_WINDOWTYPE_FMPKCALLMAN_START, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), token); + break; + case 1: +#ifdef _FMVER21 + if( CHAR_getInt( toindex, CHAR_FMLEADERFLAG) == FMMEMBER_LEADER) +#else + if( CHAR_getInt( toindex, CHAR_FMLEADERFLAG) == 1) +#endif + { + if (CHAR_getWorkInt(toindex, CHAR_WORKFMSETUPFLAG) != 1) + { + if (NPC_Util_GetStrFromStrWithDelim(npcarg, "NoSetupMsg", buf, + sizeof(buf)) == NULL) + return; + if (strstr(buf, "%s") != NULL) + sprintf(token, buf, CHAR_getChar(toindex, CHAR_FMNAME)); + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, -1, -1, token); + } + else + { + if (NPC_Util_GetStrFromStrWithDelim(npcarg, "CallMsg", buf, + sizeof(buf)) == NULL) + return; + if (strstr(buf, "%s") != NULL) + sprintf(token, buf, CHAR_getChar(toindex, CHAR_FMNAME)); + +// WON ADD 峤ٻ + { + int fmindex, fmpk_pos=-1, j; + int now_time; + struct tm tm1; +// Terry add for ֵΪ 0 ļ,Զжϼ + char szFMName[32]; +// end + + memcpy(&tm1,localtime((time_t *)&NowTime.tv_sec),sizeof(tm1)); + + fmindex = CHAR_getWorkInt(toindex, CHAR_WORKFMINDEXI); +// Terry add for ֵΪ 0 ļ,Զжϼ + strncpy(szFMName,CHAR_getChar(toindex,CHAR_FMNAME),sizeof(szFMName)); +// end + + for( j=0; j <= MAX_SCHEDULEMAN*MAX_SCHEDULE; j++ ){ +// Terry fix for ֵΪ 0 ļ,Զжϼ +// if( (fmindex == fmpks[j].host_index ) || (fmindex == fmpks[j].guest_index ) ){ + if((fmindex == fmpks[j].host_index && strcmp(szFMName,fmpks[j].host_name) == 0) || + (fmindex == fmpks[j].guest_index && strcmp(szFMName,fmpks[j].guest_name) == 0)){ +//end + fmpk_pos=j; + break; + } + } + + if(fmpk_pos != -1){ + + if(fmpk_pos <= MANORNUM*MAX_SCHEDULE+1){ + now_time=NowTime.tv_sec+(60*60); + }else{ + if(tm1.tm_hour+1==24) now_time=10000; + else now_time=(tm1.tm_hour+1) * 100; + } + + if( (fmpks[fmpk_pos].flag != FMPKS_FLAG_SCHEDULED) && + (fmpks[fmpk_pos].flag != FMPKS_FLAG_MANOR_PREPARE) ) + { + sprintf(token,"ûмԼսԼսɡ"); + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, -1, -1, token); + + }else if( now_time < fmpks[fmpk_pos].dueltime ){ + + sprintf(token,"ڶսǰһСʱٻԱ!"); + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, -1, -1, token); + + }else{ + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_YESNO, + CHAR_WINDOWTYPE_FMPKCALLMAN_CALL, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), token); + } + }else{ + sprintf(token,"ûмԼսԼսɡ"); + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, -1, -1, token); + } + } + + } + } else { + if (NPC_Util_GetStrFromStrWithDelim(npcarg, "NoLeaderMsg", buf, + sizeof(buf)) == NULL) + return; + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, -1, -1, buf); + } + break; + case 2: + if (NPC_Util_GetStrFromStrWithDelim(npcarg, "LeavepkMsg", buf, + sizeof(buf)) == NULL) + return; + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_YESNO, + CHAR_WINDOWTYPE_FMPKCALLMAN_LEAVE, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), buf); + break; + } +} + +/*----------------------------------------- + * ͷʧ߯Ȼݱ̫ľ£ + * +-------------------------------------------*/ +void NPC_FMPKCallManWindowTalked( int meindex, int talkerindex, + int seqno, int select, char *data) +{ + int datanum = -1, fl, x, y; + char npcarg[NPC_UTIL_GETARGSTR_BUFSIZE]; + char buf[1024], buff2[256]; + + int fd = getfdFromCharaIndex(talkerindex); + if (fd == -1) return; + if (NPC_Util_GetArgStr(meindex, npcarg, sizeof(npcarg)) == NULL) + { + print("GetArgStrErr"); + return; + } + NPC_Util_GetStrFromStrWithDelim(npcarg, "WARP", buf, sizeof(buf)); + getStringFromIndexWithDelim(buf, ",", 1, buff2, sizeof(buff2)); + fl = atoi(buff2); + getStringFromIndexWithDelim(buf, ",", 2, buff2, sizeof(buff2)); + x = atoi(buff2); + getStringFromIndexWithDelim(buf, ",", 3, buff2, sizeof(buff2)); + y = atoi(buff2); + + makeStringFromEscaped( data); + + print("meindex:%d seqno:%d select:%d data:%s\n", meindex, seqno, select, data); + + datanum = atoi( data); + switch( seqno){ + + /*--ԪԻ --*/ + case CHAR_WINDOWTYPE_FMPKCALLMAN_START: + if (datanum == 1) + NPC_FMPKCallMan_selectWindow(meindex, talkerindex, 1, -1); + else if (datanum == 2) + NPC_FMPKCallMan_selectWindow(meindex, talkerindex, 2, -1); + break; + case CHAR_WINDOWTYPE_FMPKCALLMAN_CALL: + if (select == WINDOW_BUTTONTYPE_YES) + { + lssproto_WN_send(fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, -1, -1, + makeEscapeString("\nٻСԺ\n磥", buf, sizeof(buf))); + NPC_CallFMMember(meindex, + CHAR_getInt(talkerindex, CHAR_FLOOR), + CHAR_getInt(talkerindex, CHAR_FMINDEX), + CHAR_getChar(talkerindex, CHAR_FMNAME), + CHAR_getWorkInt(talkerindex, CHAR_WORKFMINDEXI)); + } + break; + case CHAR_WINDOWTYPE_FMPKCALLMAN_COME: + if (select == WINDOW_BUTTONTYPE_YES) + { + print("CHAR_WINDOWTYPE_FMPKCALLMAN_COME\n"); + if (CHAR_getWorkInt(talkerindex, CHAR_WORKBATTLEMODE) + != BATTLE_CHARMODE_NONE) + return; + if (CHAR_getWorkInt(talkerindex, CHAR_WORKPARTYMODE) + != CHAR_PARTY_NONE) + CHAR_DischargeParty(talkerindex, 0); + + CHAR_setWorkInt(talkerindex, CHAR_WORKWARPCHECK, FALSE); + CHAR_setWorkInt(talkerindex, CHAR_WORKFMPKFLAG, 1); + CHAR_warpToSpecificPoint(talkerindex, fl, x, y); + } + break; + case CHAR_WINDOWTYPE_FMPKCALLMAN_LEAVE: + if (select == WINDOW_BUTTONTYPE_YES) + { + int spfl = 0, spx = 0, spy = 0, i = 0, itemindex = 0; + if (CHAR_getWorkInt(talkerindex, CHAR_WORKBATTLEMODE) + != BATTLE_CHARMODE_NONE) + return; + if (CHAR_getWorkInt(talkerindex, CHAR_WORKPARTYMODE) + != CHAR_PARTY_NONE) + { + lssproto_WN_send(fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, -1, -1, + makeEscapeString("\n޷Ŷӷʽ뿪ࡣ\nȽɢŶӣ", buf, sizeof(buf))); + return; + } + for (i = 0; i < CHAR_MAXITEMHAVE; i++) + { + itemindex = CHAR_getItemIndex(talkerindex, i); + if (ITEM_CHECKINDEX(itemindex) == FALSE) continue; + + if (ITEM_getInt(itemindex, ITEM_DROPATLOGOUT) == TRUE) + { + lssproto_WN_send(fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, -1, -1, + makeEscapeString("\nйƷร\nΪ˱ڴ;вС𻵣\nȽƷж£\nллĺ", buf, sizeof(buf))); + return; + } + + } + CHAR_setWorkInt(talkerindex, CHAR_WORKWARPCHECK, FALSE); + CHAR_getElderPosition(CHAR_getInt(talkerindex, CHAR_LASTTALKELDER), + &spfl, &spx, &spy); + CHAR_warpToSpecificPoint(talkerindex, spfl, spx, spy); + } + break; + default: + break; + } +} + +extern struct FM_PKFLOOR fmpkflnum[FAMILY_FMPKFLOOR]; +void NPC_CallFMMember(int meindex, int floor, int fmindex, char *fmname, int index) +{ + int i, charindex; + char buf[256]; + extern int familyMemberIndex[FAMILY_MAXNUM][FAMILY_MAXMEMBER]; + print("CallFMMember_NPC_meindex:%d\n", meindex); + for( i = 0; i < FAMILY_MAXMEMBER; i++) + { + charindex = familyMemberIndex[index][i]; + if( charindex >= 0 ) { + if( CHAR_getCharUse(charindex) ) + { + print("charindex:%d name:%s\n", charindex, CHAR_getChar(charindex, CHAR_NAME)); + if (CHAR_getInt(charindex, CHAR_FLOOR) == floor) continue; + if (CHAR_getWorkInt(charindex, CHAR_WORKBATTLEMODE) == BATTLE_CHARMODE_NONE) + { + int fd = getfdFromCharaIndex(charindex); + int charfloor = CHAR_getInt(charindex, CHAR_FLOOR); + int j = 0, checkflag = 0; + if (fd == -1) continue; +#ifdef _FMVER21 + if (CHAR_getInt(charindex, CHAR_FMLEADERFLAG) < 0 || + CHAR_getInt(charindex, CHAR_FMLEADERFLAG) == FMMEMBER_APPLY) continue; +#else + if (CHAR_getInt(charindex, CHAR_FMLEADERFLAG) <= 0 ) continue; +#endif + for (j = 0; j < FAMILY_FMPKFLOOR; j++) + { + if (charfloor == fmpkflnum[j].fl) + checkflag = 1; + } + if (checkflag != 1) + lssproto_WN_send(fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_YESNO, CHAR_WINDOWTYPE_FMPKCALLMAN_COME, + CHAR_getWorkInt(meindex, CHAR_WORKOBJINDEX), + makeEscapeString("\nѾڣУޡҪҪأ\n״̬УŶࡣ", buf, sizeof(buf))); + } + } + else + familyMemberIndex[index][i] = -1; + } + } +} diff --git a/npc/npc_fmpkman.c b/npc/npc_fmpkman.c new file mode 100644 index 0000000..4005acb --- /dev/null +++ b/npc/npc_fmpkman.c @@ -0,0 +1,301 @@ +#include "version.h" +#include +#include "char.h" +#include "object.h" +#include "char_base.h" +#include "npcutil.h" +#include "lssproto_serv.h" +#include "npc_fmpkman.h" +#include "npc_scheduleman.h" +#include "npc_fmwarpman.h" +#include "family.h" +#include "readmap.h" +#include "battle.h" +#include "log.h" + +enum { + NPC_WORK_ID = CHAR_NPCWORKINT1, +}; + +static void NPC_FMPKMan_selectWindow(int meindex, int toindex, int num, int select); +// shan add +BOOL NPC_PARTY_CHAECK1(int meindex,int talker); +void NPC_ERR_DiSP1(int meindex,int talker,int errNO); + +/********************************* +* +*********************************/ +BOOL NPC_FMPKManInit( int meindex ) +{ + + char npcarg[NPC_UTIL_GETARGSTR_BUFSIZE]; + char buf[1024]; + char buff2[256]; + int fl, x, y, meid; + + if( NPC_Util_GetArgStr( meindex, npcarg, sizeof( npcarg)) == NULL){ + print("FMPKMan:GetArgStrErr"); + return FALSE; + } + + /*--ɬýľ¾----*/ + /*--ɬýľئľNPCëئг--*/ + if(NPC_Util_GetStrFromStrWithDelim( npcarg, "WARP", buf, sizeof( buf))==NULL){ + print("FMPKMan Err is %s",npcarg); + print("FMPKMan Err"); + return FALSE; + } + + /*--ɬýľлַƻئľǷNPCëئ--*/ + getStringFromIndexWithDelim(buf,",",1,buff2,sizeof(buff2)); + fl=atoi(buff2); + getStringFromIndexWithDelim(buf,",",2,buff2,sizeof(buff2)); + x=atoi(buff2); + getStringFromIndexWithDelim(buf,",",3,buff2,sizeof(buff2)); + y=atoi(buff2); + + if( MAP_IsValidCoordinate( fl,x,y )== FALSE ){ + print( "FMWarp NPC:Invalid warpman ERR" ); + return FALSE; + } + + meid = NPC_Util_GetNumFromStrWithDelim(npcarg, "ID"); + if ((meid < 0) || (meid >= MAX_SCHEDULEMAN)) + { + print("FMPKMAN NPC: Init error Invalid ID:%d", meid); + return FALSE; + } + CHAR_setWorkInt(meindex, NPC_WORK_ID, meid); + + /*--ɬ--*/ + CHAR_setInt( meindex , CHAR_WHICHTYPE , CHAR_TYPEWARPMAN ); + + return TRUE; + +} + +/********************************* +* ƾľݼ +*********************************/ +void NPC_FMPKManTalked( int meindex , int talkerindex , char *szMes ,int color ) +{ + /* 帲ƻ ɱ */ + if( CHAR_getInt( talkerindex , CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER ) { + return; + } + + /*-- ¾--*/ + if(NPC_Util_isFaceToFace(talkerindex,meindex,2 )==FALSE){ + /* */ + if( NPC_Util_CharDistance( talkerindex, meindex ) > 1) return; + } + + /*--ͼ--*/ + CHAR_setWorkInt(talkerindex, CHAR_WORKSHOPRELEVANT, 0); + + /*-Ԫ --*/ + NPC_FMPKMan_selectWindow( meindex, talkerindex, 0, -1); +} + +static void NPC_FMPKMan_selectWindow( int meindex, int toindex, int num,int select) +{ + char npcarg[NPC_UTIL_GETARGSTR_BUFSIZE]; + char token[1024], buf[256], buf2[256]; + int buttontype = 0, windowtype = 0, windowno = 0; + int fd = getfdFromCharaIndex(toindex); + int num1 = 0, num2 = 0; + int fmpks_pos = CHAR_getWorkInt(meindex, NPC_WORK_ID) * MAX_SCHEDULE; + + if( fd == -1 ) { + print( "getfd err\n"); + return; + } + + if(NPC_Util_GetArgStr( meindex, npcarg, sizeof(npcarg))==NULL){ + print("GetArgStrErr"); + return ; + } + /*--ɬð̻P ׷ʧѻ϶ýľ¾ľľɰ׷ʧѼԻ*/ + if(strstr(npcarg,"%4d")!=NULL){ + int work; + NPC_Util_GetStrFromStrWithDelim( npcarg, "WARP", buf, sizeof( buf)); + getStringFromIndexWithDelim(buf,",",1,buf2,sizeof(buf2)); + work = atoi( buf2); + } + + token[0] = '\0'; + + switch(num){ + // ټū + case 0: + if(NPC_Util_GetStrFromStrWithDelim( npcarg, "MainMsg", buf, + sizeof( buf)) == NULL) + return; + sprintf(token, "3\n У˳\n" + "%s" + "\n 쿴˫ " + "\n 뿪У˳ ", + buf); + buttontype = WINDOW_BUTTONTYPE_NONE; + windowtype = WINDOW_MESSAGETYPE_SELECT; + windowno = CHAR_WINDOWTYPE_FMPKMAN_START; + break; + case 1: + if(NPC_Util_GetStrFromStrWithDelim(npcarg, "ViewMsg", buf, + sizeof(token)) == NULL) + return; + NPC_GetPKFMNum(CHAR_getInt(toindex, CHAR_FLOOR), + fmpks[fmpks_pos].host_index, + fmpks[fmpks_pos].guest_index, + &num1, &num2); +/* + print("host:%s guest:%s hostindex:%d guestindex:%d\n", + fmpks[fmpks_pos].host_name, + fmpks[fmpks_pos].guest_name, + fmpks[fmpks_pos].host_index, + fmpks[fmpks_pos].guest_index); +*/ + sprintf(token, "\n%s\n\n%s:%4d\n\n%s:%4d", buf, + fmpks[fmpks_pos].host_name, num1, + fmpks[fmpks_pos].guest_name, num2); + buttontype = WINDOW_BUTTONTYPE_OK; + windowtype = WINDOW_MESSAGETYPE_MESSAGE; + windowno = CHAR_WINDOWTYPE_FMPKMAN_VIEW; + break; + case 2: + if(NPC_Util_GetStrFromStrWithDelim(npcarg, "LeavepkMsg", token, + sizeof(token)) == NULL) + return; + + buttontype = WINDOW_BUTTONTYPE_YESNO; + windowtype = WINDOW_MESSAGETYPE_MESSAGE; + windowno = CHAR_WINDOWTYPE_FMPKMAN_LEAVEPK; + break; + default: + break; + } + + /*--޵--*/ + //makeEscapeString( token, escapedname, sizeof(escapedname)); + + + /*--˪--*/ + lssproto_WN_send( fd, windowtype, + buttontype, + windowno, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + token); + +} + +/*----------------------------------------- + * ͷʧ߯Ȼݱ̫ľ£ + * +-------------------------------------------*/ +void NPC_FMPKManWindowTalked( int meindex, int talkerindex, + int seqno, int select, char *data) +{ + int datanum = -1, fl, x, y; + char npcarg[NPC_UTIL_GETARGSTR_BUFSIZE]; + char buf[1024], buff2[256]; + + if (NPC_Util_GetArgStr(meindex, npcarg, sizeof(npcarg)) == NULL) + { + print("GetArgStrErr"); + return; + } + NPC_Util_GetStrFromStrWithDelim(npcarg, "WARP", buf, sizeof(buf)); + getStringFromIndexWithDelim(buf, ",", 1, buff2, sizeof(buff2)); + fl = atoi(buff2); + getStringFromIndexWithDelim(buf, ",", 2, buff2, sizeof(buff2)); + x = atoi(buff2); + getStringFromIndexWithDelim(buf, ",", 3, buff2, sizeof(buff2)); + y = atoi(buff2); + + makeStringFromEscaped( data); + +// print("meindex:%d seqno:%d select:%d data:%s\n", meindex, seqno, select, data); + + datanum = atoi( data); + switch( seqno){ + + /*--ԪԻ --*/ + case CHAR_WINDOWTYPE_FMPKMAN_START: + if (datanum == 1) + NPC_FMPKMan_selectWindow(meindex, talkerindex, 1, -1); + else if (datanum == 2) + NPC_FMPKMan_selectWindow(meindex, talkerindex, 2, -1); + break; + case CHAR_WINDOWTYPE_FMPKMAN_VIEW: + break; + case CHAR_WINDOWTYPE_FMPKMAN_LEAVEPK: + if (select == WINDOW_BUTTONTYPE_YES) + { + if (CHAR_getWorkInt(talkerindex, CHAR_WORKBATTLEMODE) + != BATTLE_CHARMODE_NONE) + return; + + // shan add + if(NPC_PARTY_CHAECK1( meindex, talkerindex)==FALSE){ + NPC_ERR_DiSP1( meindex, talkerindex, 1); + return; + } + + CHAR_setWorkInt(talkerindex, CHAR_WORKWARPCHECK, FALSE); + CHAR_warpToSpecificPoint(talkerindex, fl, x, y); + } + break; + default: + break; + } +} + +// shan add +BOOL NPC_PARTY_CHAECK1(int meindex,int talker) +{ + if(CHAR_getWorkInt(talker,CHAR_WORKPARTYMODE) != CHAR_PARTY_NONE){ + return FALSE; + } + return TRUE; +} + +// shan add errNO=1() +void NPC_ERR_DiSP1(int meindex,int talker,int errNO) +{ + char token[1024]; + int i=0; + int otherindex; + int fd = getfdFromCharaIndex( talker); + char npcarg[NPC_UTIL_GETARGSTR_BUFSIZE]; + + if(NPC_Util_GetArgStr( meindex, npcarg, sizeof(npcarg))==NULL){ + print("GetArgStrErr"); + return ; + } + + if(errNO==1){ + if(NPC_Util_GetStrFromStrWithDelim( npcarg, "PartyMsg",token, sizeof( token))==NULL){ + sprintf(token, "޷Ŷ볡\n\nŶӽɢ֮ٸ\n볡"); + } + + if(CHAR_getWorkInt(talker,CHAR_WORKPARTYMODE)==CHAR_PARTY_CLIENT){ + + }else{ + for( i=0 ; i < CHAR_PARTYMAX ;i++){ + otherindex=CHAR_getWorkInt(talker,CHAR_WORKPARTYINDEX1+i); + if(otherindex != -1){ + fd = getfdFromCharaIndex( otherindex); + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + CHAR_WINDOWTYPE_WINDOWWARPMAN_ERR, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + token); + } + } + return ; + } + } +} + + + diff --git a/npc/npc_fmrank.c b/npc/npc_fmrank.c new file mode 100644 index 0000000..396dec1 --- /dev/null +++ b/npc/npc_fmrank.c @@ -0,0 +1,340 @@ +#include "version.h" +#include +#include "char.h" +#include "object.h" +#include "char_base.h" +#include "npcutil.h" +#include "npc_fmrank.h" +#include "lssproto_serv.h" +#include "saacproto_cli.h" +#include "readmap.h" +#include "battle.h" +#include "log.h" +#include "enemy.h" +#include "handletime.h" +#include "npc_eventaction.h" +#include "npc_healer.h" +#include "configfile.h" +#include "sasql.h" + +extern char fmrankname[20][50]; +extern int fmrankpoint[20]; +int fmrankcnt=0; +enum { + WINDOW_START=1, + WINDOW_SELECT, + WINDOW_FMRANKTOP_NEXT, + WINDOW_FMRANKTOP_PREV, +}; + + +enum { + NPC_WORK_CURRENTTIME = CHAR_NPCWORKINT1, + NPC_WORK_TIMEFLAG = CHAR_NPCWORKINT9, +/* + NPC_WORK_ROUTETOY = CHAR_NPCWORKINT2, + NPC_WORK_ROUTEPOINT = CHAR_NPCWORKINT3, + NPC_WORK_ROUNDTRIP = CHAR_NPCWORKINT4, + NPC_WORK_MODE = CHAR_NPCWORKINT5, + NPC_WORK_CURRENTROUTE = CHAR_NPCWORKINT6, + NPC_WORK_ROUTEMAX = CHAR_NPCWORKINT7, + NPC_WORK_WAITTIME = CHAR_NPCWORKINT8, + NPC_WORK_CURRENTTIME = CHAR_NPCWORKINT9, + NPC_WORK_SEFLG = CHAR_NPCWORKINT10, +*/ +}; +enum { + NPC_FMRANK_START, + NPC_FMRANK_SELECT, + NPC_FMRANK_ADDPOINT, + NPC_FMRANK_ADDFM, + NPC_FMRANK_TOP20, +}; +#define STANDBYTIME 50 + +static void NPC_FmRank_selectWindow( int meindex, int toindex, int num,int select); + +BOOL NPC_FmRankInit( int meindex ) +{ + char npcarg[NPC_UTIL_GETARGSTR_BUFSIZE]; + + if(NPC_Util_GetArgStr( meindex, npcarg, sizeof(npcarg))==NULL){ + print("TRANSER_MAN: GetArgStrErr!!"); + return FALSE; + } + +// CHAR_setInt( meindex, CHAR_WHICHTYPE, CHAR_TRANSERMANS); + + //CHAR_setInt( meindex, CHAR_LOOPINTERVAL, NEWNPCMAN_STANDBY); + CHAR_setWorkInt( meindex, NPC_WORK_CURRENTTIME, NowTime.tv_sec); + return TRUE; +} +//CHAR_setWorkInt(talkerindex,CHAR_WORKSHOPRELEVANT,1); +void NPC_FmRankTalked( int meindex, int talkerindex, char *msg, int color ) +{ + if( CHAR_getInt( talkerindex , CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER ) + return; + if(NPC_Util_isFaceToFace( meindex ,talkerindex , 2) == FALSE) { + if(NPC_Util_isFaceToChara( talkerindex, meindex, 1) == FALSE) + return; + } + + CHAR_setWorkInt( talkerindex, CHAR_WORKSHOPRELEVANT, 0); + NPC_FmRank_selectWindow( meindex, talkerindex, WINDOW_START, 0); +} + +void NPC_FmRankWindowTalked( int meindex, int talkerindex, int seqno, + int select, char *data) +{ + int myfmindex=-1; + if( select == WINDOW_BUTTONTYPE_CANCEL || select == WINDOW_BUTTONTYPE_NO) + return; + switch( seqno) { + case NPC_FMRANK_START: + break; + case NPC_FMRANK_SELECT: + NPC_FmRank_selectWindow( meindex, talkerindex, WINDOW_SELECT, atoi( data)); + break; + case NPC_FMRANK_ADDPOINT: + if(atoi(data)<1000 || atoi(data)>1000000){ + CHAR_talkToCli( talkerindex, -1,"׷ӵĵС1000ֻ100W֣",CHAR_COLORRED); + return; + } + if(sasql_ampoint(CHAR_getChar(talkerindex,CHAR_CDKEY),0,0)0){ + int myfmpoint = sasql_fmpoint_query(myfmindex); + if(myfmpoint>0){ + if(sasql_fmpoint_add(myfmindex,(myfmpoint+atoi(data)))==1){ + sasql_ampoint(CHAR_getChar(talkerindex,CHAR_CDKEY),-atoi(data),1); + CHAR_talkToCli( talkerindex, -1,"ѸԼļ徺۵ɹ",CHAR_COLORRED); + return; + } + } + } + break; + case NPC_FMRANK_ADDFM: + if(atoi(data)<5000 || atoi(data)>1000000){ + CHAR_talkToCli( talkerindex, -1,"״ξ۵С5000ֻ100W֣",CHAR_COLORRED); + return; + } + if(sasql_ampoint(CHAR_getChar(talkerindex,CHAR_CDKEY),0,0)0){ + int myfmpoint = sasql_fmpoint_query(myfmindex); + char* fmname = CHAR_getChar(talkerindex,CHAR_FMNAME); + if(myfmpoint<=0){ + if(sasql_fmindex_add(myfmindex,fmname,atoi(data))==1){ + sasql_ampoint(CHAR_getChar(talkerindex,CHAR_CDKEY),-atoi(data),1); + CHAR_talkToCli( talkerindex, -1,"ѸԼļ徺۵ɹ",CHAR_COLORRED); + return; + } + } + } + break; + case NPC_FMRANK_TOP20: + if( select == WINDOW_BUTTONTYPE_CANCEL ) + return; + if( select == WINDOW_BUTTONTYPE_NEXT ) + { + if(fmrankcnt>7){ + NPC_FmRank_selectWindow( meindex, talkerindex, WINDOW_FMRANKTOP_NEXT, atoi( data)); + return; + } + } + if( select == WINDOW_BUTTONTYPE_PREV ) + { + if(fmrankcnt>7){ + NPC_FmRank_selectWindow( meindex, talkerindex, WINDOW_FMRANKTOP_PREV, atoi( data)); + return; + } + } + break; + } +} + +static void NPC_FmRank_selectWindow( int meindex, int toindex, int num,int select) +{ + int myfmindex=-1; + char npcarg[NPC_UTIL_GETARGSTR_BUFSIZE]; + char token[256]; + char buff[128]; + int buttontype = 0, windowtype = 0, windowno = 0; + int fd = getfdFromCharaIndex( toindex); + if(NPC_Util_isFaceToFace( meindex ,toindex , 2) == FALSE) { + if(NPC_Util_isFaceToChara( toindex, meindex, 1) == FALSE) + return; + } + + memset( npcarg, 0, sizeof( npcarg)); + if(NPC_Util_GetArgStr( meindex, npcarg, sizeof(npcarg))==NULL){ + print("TRANSER_MAN: GetArgStrErr!!"); + return; + } + memset( token, 0, sizeof( token)); + + switch( num) { + case WINDOW_START: + sprintf(token, "3\n\n 徺Ա\n\n" + " ϵͳ\n" + " ׷Ӿ۵\n" + " 鿴Ρ\n" + " 鿴ǰʮ\n" + " ܽܡ\n"); + CHAR_setWorkInt( toindex, CHAR_WORKSHOPRELEVANT, WINDOW_START); + windowtype = WINDOW_MESSAGETYPE_SELECT; + buttontype = WINDOW_BUTTONTYPE_CANCEL; + windowno = NPC_FMRANK_SELECT; + break; + case WINDOW_SELECT: + windowtype = WINDOW_MESSAGETYPE_MESSAGE; + if(select==1 || select == 2){ + myfmindex = CHAR_getInt(toindex, CHAR_FMINDEX); + if(myfmindex>0){ + int myfmpoint = sasql_fmpoint_query(myfmindex); + windowtype = WINDOW_MESSAGETYPE_MESSAGEANDLINEINPUT; + if(myfmpoint>0){ + sprintf(token, " 徺Ա\n\n" + "ļѾϵͳ\n" + "ڵľ۵ǣ%d㣡\n\n" + "\n" + "·д׷ӵ㡾ȷ",myfmpoint); + buttontype = WINDOW_BUTTONTYPE_YESNO; + windowno = NPC_FMRANK_ADDPOINT; + }else{ + sprintf(token, " 徺Ա\n\n" + "ļ廹δϵͳ\n\n" + "ϵͳ\n" + "·д۵㡾ȷ"); + buttontype = WINDOW_BUTTONTYPE_YESNO; + windowno = NPC_FMRANK_ADDFM; + } + }else{ + sprintf(token, " 徺Ա\n\n" + "ûм߳壬мٽд˲"); + buttontype = WINDOW_BUTTONTYPE_CANCEL; + } + }else if(select==3){ + myfmindex = CHAR_getInt(toindex, CHAR_FMINDEX); + if(myfmindex>0){ + int myfmpoint = sasql_fmpoint_query(myfmindex); + if(myfmpoint>0){ + int myfmno = sasql_fmno_query(myfmindex); + sprintf(token, " 徺Ա\n\n" + "ļѾϵͳ\n\n" + "ڵľ۵ǣ%d\n\n" + "%dλ",myfmpoint,myfmno); + buttontype = WINDOW_BUTTONTYPE_CANCEL; + }else{ + sprintf(token, " 徺Ա\n\n" + "ļ廹δϵͳ\n"); + buttontype = WINDOW_BUTTONTYPE_CANCEL; + } + }else{ + sprintf(token, " 徺Ա\n\n" + "ûм߳壬мٽд˲"); + buttontype = WINDOW_BUTTONTYPE_CANCEL; + } + }else if(select==4){ + CHAR_setWorkInt(toindex,CHAR_WORKLISTPAGE,1); + sprintf(token, " ǰ20б\n"); + fmrankcnt = sasql_fm_query(); + if(fmrankcnt>0){ + int fmshowmax; + if(fmrankcnt>7) fmshowmax=7; + else fmshowmax = fmrankcnt; + int i; + for(i=0;i7) + buttontype = WINDOW_BUTTONTYPE_CANCEL|WINDOW_BUTTONTYPE_NEXT; + else + buttontype = WINDOW_BUTTONTYPE_CANCEL; + windowno = NPC_FMRANK_TOP20; + }else if(select==5){ + sprintf(token, "\n1þʽ \n" + "2ֻʾǰ20λ ۡ\n" + "3Ȼǰ š\n" + "4ٳΪһٵ \n" + "5ˢʱΪ15 ϵ\n" + "6ÿһ ͳ\n"); + buttontype = WINDOW_BUTTONTYPE_CANCEL; + } + break; + case WINDOW_FMRANKTOP_NEXT: + if(CHAR_getWorkInt(toindex,CHAR_WORKLISTPAGE)<1) return; + windowtype = WINDOW_MESSAGETYPE_MESSAGE; + sprintf(token, " ǰ20б\n"); + if(fmrankcnt>0){ + int fmshowmax; + if(fmrankcnt<=7) return; + if(CHAR_getWorkInt(toindex,CHAR_WORKLISTPAGE)==1){ + if(fmrankcnt>14){ + fmshowmax = 14; + buttontype = WINDOW_BUTTONTYPE_PREV|WINDOW_BUTTONTYPE_NEXT; + } + else{ + fmshowmax = fmrankcnt; + buttontype = WINDOW_BUTTONTYPE_CANCEL|WINDOW_BUTTONTYPE_PREV; + } + }else if(CHAR_getWorkInt(toindex,CHAR_WORKLISTPAGE)==2){ + if(fmrankcnt<=14) return; + fmshowmax = fmrankcnt; + buttontype = WINDOW_BUTTONTYPE_CANCEL|WINDOW_BUTTONTYPE_PREV; + }else{ + return; + } + int i; + for(i=7*CHAR_getWorkInt(toindex,CHAR_WORKLISTPAGE);i3) return; + windowtype = WINDOW_MESSAGETYPE_MESSAGE; + sprintf(token, " ǰ20б\n"); + if(fmrankcnt>0){ + int fmshowmax; + if(CHAR_getWorkInt(toindex,CHAR_WORKLISTPAGE)==3){ + if(fmrankcnt<=14) return; + fmshowmax = 14; + buttontype = WINDOW_BUTTONTYPE_PREV|WINDOW_BUTTONTYPE_NEXT; + }else if(CHAR_getWorkInt(toindex,CHAR_WORKLISTPAGE)==2){ + if(fmrankcnt<=7) return; + fmshowmax = 7; + buttontype = WINDOW_BUTTONTYPE_CANCEL|WINDOW_BUTTONTYPE_NEXT; + } + int i; + for(i=fmshowmax-7;i +#include "char.h" +#include "object.h" +#include "char_base.h" +#include "npcutil.h" +#include "lssproto_serv.h" +#include "saacproto_cli.h" +#include "npc_fmwarpman.h" +#include "npc_scheduleman.h" +#include "readmap.h" +#include "log.h" +#include "battle.h" +#include "handletime.h" +#include "family.h" +#include "errno.h" +#include "configfile.h" + +#ifdef _FM_POINT_PK +extern struct FM_POINTLIST fmpointlist; // ݵ +#endif + +#define FMWARPMAN_INIT_LOOPTIME 600 // 0.1 +#define FMWARPMAN_FREE_LOOPTIME 9000 // 1.5 +#define FMWARPMAN_BUSY_LOOPTIME 3000 // 0.5 +#define FMWARPMAN_WAIT_LOOPTIME 18000 // 3 +#define FMWARPMAN_CLEANPLACE 59 +//#define FMWARPMAN_CLEANPLACE 9 +#define TRUE 1 +#define FALSE 0 +// CoolFish Rem 2002/2/25 +// #define MANOR 4 + +enum { + NPC_WORK_MODEFLAG = CHAR_NPCWORKINT1, + NPC_WORK_CURRENTTIME = CHAR_NPCWORKINT2, + NPC_WORK_WARPFLOOR = CHAR_NPCWORKINT3, + NPC_WORK_FMNUMI = CHAR_NPCWORKINT4, + NPC_WORK_FMNUMII = CHAR_NPCWORKINT5, + NPC_WORK_ID = CHAR_NPCWORKINT6, + NPC_WORK_TIMEFLAG = CHAR_NPCWORKINT9, + NPC_WORK_TALKFLAG = CHAR_NPCWORKINT10, + NPC_WORK_CleanTime = CHAR_NPCWORKINT11, +}; + +enum { + NPC_STATEINIT, + NPC_STATEFREE, + NPC_STATEBUSY, + NPC_STATEWAIT, +}; + +enum { + NPC_WORK_WINFMNAME = CHAR_NPCWORKCHAR1, +}; + +void NPC_ERR_FMDiSP(int meindex, int talker, int errNO); +static void NPC_FMWarpMan_selectWindow(int meindex, int toindex, int num, int select); +void NPC_FMBATTLESET(int floor, int index1, int index2, int flag); +void NPC_WarpFamily(int floor, int index1, int index2, int fl, int x, int y); +void NPC_BattleOut(int fmindex, int fmindex1); +void NPC_CleanPK(int floor, int meindex); +int NPC_FMFloorUse(int floor); +void NPC_talkToFloor(int floor, int index1, int index2, char *data); +void CheckLeavePK(int npcindex, int floor, int index1, int index2); + +void CHECK_FMPknumInFloor( int meindex) +{ + int fmnum1 = 0, fmnum2 = 0; + int fmpks_pos; + + fmpks_pos = CHAR_getWorkInt(meindex, NPC_WORK_ID) * MAX_SCHEDULE; + // Nuke 20040920: Bug fix ׯ԰ʱҪ + //print("<<%d %d>>",fmpks_pos,MAX_SCHEDULEMAN); + //if( fmpks_pos < 0 || fmpks_pos >= MAX_SCHEDULEMAN ) return; + if( fmpks_pos < 0 || fmpks_pos >= MAX_SCHEDULEMAN * MAX_SCHEDULE ) return; + NPC_GetPKFMNum(CHAR_getWorkInt(meindex, NPC_WORK_WARPFLOOR), + fmpks[fmpks_pos].host_index, + fmpks[fmpks_pos].guest_index, + &fmnum1, &fmnum2 ); + + CHAR_setWorkInt( meindex, NPC_WORK_FMNUMI , fmnum1); + CHAR_setWorkInt( meindex, NPC_WORK_FMNUMII, fmnum2); +} + +extern int familyMemberIndex[FAMILY_MAXNUM][FAMILY_MAXMEMBER]; + +BOOL NPC_FMWarpManInit( int meindex ) +{ + char npcarg[NPC_UTIL_GETARGSTR_BUFSIZE]; + char buff2[256]; + char buf[1024]; + int fl, x, y, meid; + // shan + int fl1, x1, y1; + + if(NPC_Util_GetArgStr( meindex, npcarg, sizeof(npcarg))==NULL){ + print("FMWarpMan:GetArgStrErr"); + return FALSE; + } + + if(NPC_Util_GetStrFromStrWithDelim( npcarg, "WARP1", buf, sizeof( buf))==NULL){ + print("FMWarpman Err is %s",npcarg); + print("FMWarpman Err"); + return FALSE; + } + + getStringFromIndexWithDelim(buf,",",1,buff2,sizeof(buff2)); + fl=atoi(buff2); + CHAR_setWorkInt(meindex, NPC_WORK_WARPFLOOR, fl); + getStringFromIndexWithDelim(buf,",",2,buff2,sizeof(buff2)); + x=atoi(buff2); + getStringFromIndexWithDelim(buf,",",3,buff2,sizeof(buff2)); + y=atoi(buff2); + + if( MAP_IsValidCoordinate( fl,x,y )== FALSE ){ + print( "FMWarp NPC:Invalid warpman ERR" ); + return FALSE; + } + + // shan begin + if(NPC_Util_GetStrFromStrWithDelim( npcarg, "WARP2", buf, sizeof( buf))==NULL){ + print("FMWarpman Err is %s",npcarg); + print("FMWarpman Err"); + return FALSE; + } + getStringFromIndexWithDelim(buf,",",1,buff2,sizeof(buff2)); + fl1=atoi(buff2); + CHAR_setWorkInt(meindex, NPC_WORK_WARPFLOOR, fl); + getStringFromIndexWithDelim(buf,",",2,buff2,sizeof(buff2)); + x1=atoi(buff2); + getStringFromIndexWithDelim(buf,",",3,buff2,sizeof(buff2)); + y1=atoi(buff2); + if( MAP_IsValidCoordinate( fl1,x1,y1 )== FALSE ){ + print( "FMWarp NPC:Invalid warpman ERR" ); + return FALSE; + } + // shan end + + meid = NPC_Util_GetNumFromStrWithDelim(npcarg, "ID"); + if ((meid < 0) || (meid >= MAX_SCHEDULEMAN)) + { + print("FMWARP NPC: Init error invalid ID:%d\n", meid); + return FALSE; + } + + /*--ɬ--*/ + CHAR_setInt(meindex, CHAR_LOOPINTERVAL, FMWARPMAN_INIT_LOOPTIME); + CHAR_setInt( meindex , CHAR_WHICHTYPE , CHAR_TYPEWARPMAN ); + CHAR_setWorkInt(meindex, NPC_WORK_MODEFLAG, NPC_STATEINIT); + CHAR_setWorkInt(meindex, NPC_WORK_CURRENTTIME, NowTime.tv_sec); + CHAR_setWorkInt(meindex, NPC_WORK_TIMEFLAG, 0); + CHAR_setWorkInt(meindex, NPC_WORK_TALKFLAG, -1); + CHAR_setWorkInt(meindex, NPC_WORK_ID, meid); + CHAR_setWorkInt(meindex, NPC_WORK_FMNUMI, 0); + CHAR_setWorkInt(meindex, NPC_WORK_FMNUMII, 0); + + CHAR_setWorkInt( meindex, NPC_WORK_CleanTime, 6*10); + + return TRUE; +} + +void NPC_FMWarpManTalked(int meindex, int talkerindex, char *szMes, int color) +{ + char npcarg[NPC_UTIL_GETARGSTR_BUFSIZE]; + + CHAR_setWorkInt( talkerindex, CHAR_WORKWARPCHECK, FALSE ); + + if( CHAR_getInt( talkerindex , CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER ) { + return; + } + + if(NPC_Util_isFaceToFace( meindex ,talkerindex ,2)==FALSE){ + if(NPC_Util_isFaceToChara(talkerindex,meindex,1 )==FALSE) return; + } + + if(NPC_Util_GetArgStr( meindex, npcarg, sizeof(npcarg))==NULL){ + print("GetArgStrErr"); + return ; + } + + if(CHAR_getWorkInt(talkerindex, CHAR_WORKPARTYMODE) != CHAR_PARTY_NONE){ + NPC_ERR_FMDiSP( meindex, talkerindex, 1); + } + + CHAR_setWorkInt( talkerindex , CHAR_WORKSHOPRELEVANTTRD , 0 ); + NPC_FMWarpMan_selectWindow( meindex, talkerindex, 0, -1); +} + +void NPC_FMWarpManLoop(int meindex) +{ + struct tm tm1; + struct tm *tm2; + int fmpks_pos = CHAR_getWorkInt(meindex, NPC_WORK_ID) * MAX_SCHEDULE; + int floor = CHAR_getWorkInt(meindex, NPC_WORK_WARPFLOOR); + // WON ADD snprintfᵼµbug + if( (tm2=localtime((time_t *)&NowTime.tv_sec) ) == NULL ){ + print("\n won ==> time err !! "); + return; + } + memcpy(&tm1, localtime((time_t *)&NowTime.tv_sec), sizeof(tm1)); + + if (tm1.tm_min == 0) + CHAR_setWorkInt(meindex, NPC_WORK_TIMEFLAG, tm1.tm_min); + if (CHAR_getWorkInt(meindex, NPC_WORK_MODEFLAG) == NPC_STATEINIT) + { + if (tm1.tm_sec == 0) + { + CHAR_setWorkInt(meindex, NPC_WORK_MODEFLAG, NPC_STATEFREE); + CHAR_setInt(meindex, CHAR_LOOPINTERVAL, FMWARPMAN_FREE_LOOPTIME); + } + } + if (CHAR_getWorkInt(meindex, NPC_WORK_MODEFLAG) == NPC_STATEFREE) + { + // ȡĿǰϵͳʱ䣬Ŀǰʱ >= ׼ʱ趨£գӣ״̬ + + if (tm1.tm_min > CHAR_getWorkInt(meindex, NPC_WORK_TALKFLAG) + && tm1.tm_min == 0) + { + // ֪ͨԱ + if (fmpks[fmpks_pos].flag == FMPKS_FLAG_SCHEDULED) + NPC_talkToFloor(CHAR_getInt(meindex, CHAR_FLOOR), + fmpks[fmpks_pos].host_index, + fmpks[fmpks_pos].guest_index, "׼ˣ"); + CHAR_setWorkInt(meindex, NPC_WORK_TALKFLAG, tm1.tm_min); + } + if ((fmpks[fmpks_pos].prepare_time > 0) && (fmpks[fmpks_pos].flag == FMPKS_FLAG_SCHEDULED)) + { + int clock = 0; + + NPC_FMBATTLESET(floor, fmpks[fmpks_pos].host_index, + fmpks[fmpks_pos].guest_index, -1); + if (tm1.tm_hour - (fmpks[fmpks_pos].dueltime / 100) < 0) + clock = (fmpks[fmpks_pos].dueltime % 100) + fmpks[fmpks_pos].prepare_time - 60; + else + clock = fmpks[fmpks_pos].dueltime - (tm1.tm_hour * 100) + fmpks[fmpks_pos].prepare_time; + + if ((tm1.tm_min >= clock) && (fmpks[fmpks_pos].prepare_time > 0)) + { + + NPC_talkToFloor(floor, fmpks[fmpks_pos].host_index, + fmpks[fmpks_pos].guest_index, "սޡ"); + CHAR_setWorkInt(meindex, NPC_WORK_MODEFLAG, NPC_STATEBUSY); + CHAR_setInt(meindex, CHAR_LOOPINTERVAL, FMWARPMAN_BUSY_LOOPTIME); + NPC_FMBATTLESET(floor, fmpks[fmpks_pos].host_index, + fmpks[fmpks_pos].guest_index, 1); + +// print("\n won ==> set fmwaperman state busy !!"); + } + else if (tm1.tm_min > CHAR_getWorkInt(meindex, NPC_WORK_TIMEFLAG)) + { + char buf[256]; + int clock = 0; + CHAR_setWorkInt(meindex, NPC_WORK_TIMEFLAG, tm1.tm_min); + clock = ((fmpks[fmpks_pos].dueltime % 100) + fmpks[fmpks_pos].prepare_time) - tm1.tm_min; + if (clock >= 60) clock = clock - 60; + sprintf(buf, "սʱ仹ʣ£%4d", clock); + NPC_talkToFloor(floor, fmpks[fmpks_pos].host_index, + fmpks[fmpks_pos].guest_index, buf); + } + } + }else if (CHAR_getWorkInt(meindex, NPC_WORK_MODEFLAG) == NPC_STATEBUSY){ + // 鳡жʤ + int num1 = 0, num2 = 0; + int winflag = 0; + int floor = CHAR_getWorkInt(meindex, NPC_WORK_WARPFLOOR); + int meid = CHAR_getWorkInt(meindex, NPC_WORK_ID); + +// print("\n won ==> check_winner : npc_meid(%d)", meid ); + + NPC_GetPKFMNum(floor, fmpks[fmpks_pos].host_index, + fmpks[fmpks_pos].guest_index, &num1, &num2); + NPC_FMBATTLESET(floor, fmpks[fmpks_pos].host_index, + fmpks[fmpks_pos].guest_index, 1); + CheckLeavePK(meindex, floor, fmpks[fmpks_pos].host_index, + fmpks[fmpks_pos].guest_index); + + if (meid > MANORNUM){ + if (tm1.tm_min == FMWARPMAN_CLEANPLACE){ + // жʤWARP볡趨ΣУ״̬ + NPC_BattleOut(fmpks[fmpks_pos].host_index, fmpks[fmpks_pos].guest_index); + NPC_FMBATTLESET(floor, fmpks[fmpks_pos].host_index, + fmpks[fmpks_pos].guest_index, -1); + if (fmpks[fmpks_pos].win == 0){// ս + if (num1 > num2) + winflag = 1; + else if(num1 < num2) + winflag = 2; + else + winflag = 3; + }else if (fmpks[fmpks_pos].win == 1){ // ս + if ((CHAR_getWorkInt(meindex, NPC_WORK_FMNUMI) - num1) < (CHAR_getWorkInt(meindex, NPC_WORK_FMNUMII) - num2)) + winflag = 1; + else if ((CHAR_getWorkInt(meindex, NPC_WORK_FMNUMI) - num1) > (CHAR_getWorkInt(meindex, NPC_WORK_FMNUMII) - num2)) + winflag = 2; + else + winflag = 3; + } + } + } + if ((num1 == 0) && (num2 != 0)){ + winflag = 2; + }else if ((num2 == 0) && (num1 != 0)){ + winflag = 1; + }else if ((num1 == 0) && (num2 == 0)){ //ƽ趨طӮ + winflag = 1; + } + if (winflag > 0 && winflag < 3){ +#ifdef _MANOR_PKRULE + if(meid > MANORNUM){ +#endif + // ˼pk + if (winflag == 1){ + saacproto_ACFixFMPK_send(acfd, + fmpks[fmpks_pos].host_name, + fmpks[fmpks_pos].host_index + 1, + fmpks[fmpks_pos].host_index, + fmpks[fmpks_pos].guest_name, + fmpks[fmpks_pos].guest_index + 1, + fmpks[fmpks_pos].guest_index); + } else { + saacproto_ACFixFMPK_send(acfd, + fmpks[fmpks_pos].guest_name, + fmpks[fmpks_pos].guest_index + 1, + fmpks[fmpks_pos].guest_index, + fmpks[fmpks_pos].host_name, + fmpks[fmpks_pos].host_index + 1, + fmpks[fmpks_pos].host_index); + } +#ifdef _MANOR_PKRULE + } +#endif + + { + if (meid > 0 && meid <= MANORNUM){// CoolFish 2002/2/25 Change MANOR -> MANORNUM +#ifdef _NEW_MANOR_LAW + int i,iFmIndex1,iFmIndex2,iCharindex; +#endif + fmpks[fmpks_pos + 1].flag = FMPKS_FLAG_MANOR_BATTLEEND; + if (winflag == 1){ + char token[256]; + sprintf( token, " (%d:%d) %d/%d/%d", + tm1.tm_hour, tm1.tm_min, + tm1.tm_year+1900, tm1.tm_mon+1, tm1.tm_mday); + saacproto_ACFixFMPoint_send(acfd, + fmpks[fmpks_pos].host_name, + fmpks[fmpks_pos].host_index + 1, + fmpks[fmpks_pos].host_index, + fmpks[fmpks_pos].guest_name, + fmpks[fmpks_pos].guest_index + 1, + fmpks[fmpks_pos].guest_index, meid); + //Syu ׯ԰սʤLog + Logfmpk( + fmpks[fmpks_pos].host_name, + fmpks[fmpks_pos].host_index, + num1, + fmpks[fmpks_pos].guest_name, + fmpks[fmpks_pos].guest_index, + num2, token, "", "", 2); +#ifdef _NEW_MANOR_LAW + // ԭסׯ԰,Աɵõʯ + iFmIndex1 = fmpks[fmpks_pos].host_index; + for(i=0;i= 0 && CHAR_getCharUse(iCharindex)){ + // ýǮ = * 5000 + int iAddGold = ((float)CHAR_getInt(iCharindex,CHAR_MOMENTUM)/100.0f) * 5000.0f; + int iGold = CHAR_getInt(iCharindex,CHAR_BANKGOLD),iMaxGold; + // ȷ + if(iGold + iAddGold > CHAR_MAXBANKGOLDHAVE){ + CHAR_setInt(iCharindex,CHAR_BANKGOLD,CHAR_MAXBANKGOLDHAVE); + // зŲ,ŵ + iAddGold = iGold + iAddGold - CHAR_MAXBANKGOLDHAVE; + iGold = CHAR_getInt(iCharindex,CHAR_GOLD); + iMaxGold = CHAR_getMaxHaveGold(iCharindex); + if(iGold + iAddGold > iMaxGold) CHAR_setInt(iCharindex,CHAR_GOLD,iMaxGold); + else CHAR_setInt(iCharindex,CHAR_GOLD,iGold + iAddGold); + LogFMPKGetMomey(CHAR_getChar(iCharindex,CHAR_FMNAME), + CHAR_getChar(iCharindex,CHAR_CDKEY), + CHAR_getChar(iCharindex,CHAR_NAME), + CHAR_getInt(iCharindex,CHAR_MOMENTUM),iAddGold,0); + } + else{ + CHAR_setInt(iCharindex,CHAR_BANKGOLD,iGold + iAddGold); + LogFMPKGetMomey(CHAR_getChar(iCharindex,CHAR_FMNAME), + CHAR_getChar(iCharindex,CHAR_CDKEY), + CHAR_getChar(iCharindex,CHAR_NAME), + CHAR_getInt(iCharindex,CHAR_MOMENTUM),iAddGold,1); + } + CHAR_talkToCli(iCharindex,-1,"!ػסׯ԰Ľѻĸ",CHAR_COLORRED); + } + } +#endif + } + else if (winflag == 2){ + char token[256]; + sprintf( token, " (%d:%d) %d/%d/%d", + tm1.tm_hour, tm1.tm_min, + tm1.tm_year+1900, tm1.tm_mon+1, tm1.tm_mday); +#ifdef _FM_POINT_PK + int fmid; + char fmindex[4]; + for (fmid=0; fmid=0 && fmid= 0 && CHAR_getCharUse(iCharindex)){ + CHAR_setInt(iCharindex,CHAR_MOMENTUM,0); + CHAR_talkToCli(iCharindex,-1,"ׯ԰ս˼ƹ",CHAR_COLORRED); + } + iCharindex = familyMemberIndex[iFmIndex2][i]; + if(iCharindex >= 0 && CHAR_getCharUse(iCharindex)){ + CHAR_setInt(iCharindex,CHAR_MOMENTUM,0); + CHAR_talkToCli(iCharindex,-1,"ׯ԰ս˼ƹ",CHAR_COLORRED); + } + } +#endif + } + } + if (winflag == 1) + { + CHAR_setWorkChar(meindex, NPC_WORK_WINFMNAME, fmpks[fmpks_pos].host_name); + } + else if (winflag == 2) + { + CHAR_setWorkChar(meindex, NPC_WORK_WINFMNAME, fmpks[fmpks_pos].guest_name); + } + NPC_WarpFamily(floor, fmpks[fmpks_pos].host_index, + fmpks[fmpks_pos].guest_index, + CHAR_getInt(meindex, CHAR_FLOOR), + CHAR_getInt(meindex, CHAR_X), + CHAR_getInt(meindex, CHAR_Y)); + if (meid > MANORNUM){// CoolFish 2002/2/25 Change MANOR -> MANORNUM + CHAR_setWorkInt(meindex, NPC_WORK_MODEFLAG, NPC_STATEWAIT); + CHAR_setInt(meindex, CHAR_LOOPINTERVAL, FMWARPMAN_WAIT_LOOPTIME); + } + }else if( winflag == 3 ){ + if (meid > 0 && meid <= MANORNUM) // CoolFish 2002/2/25 Change MANOR -> MANORNUM + + fmpks[fmpks_pos + 1].flag = FMPKS_FLAG_MANOR_BATTLEEND; + NPC_talkToFloor(floor, fmpks[fmpks_pos].host_index, + fmpks[fmpks_pos].guest_index, "˫ƽ֣ʤ"); + NPC_WarpFamily(floor, fmpks[fmpks_pos].host_index, + fmpks[fmpks_pos].guest_index, + CHAR_getInt(meindex, CHAR_FLOOR), + CHAR_getInt(meindex, CHAR_X), + CHAR_getInt(meindex, CHAR_Y)); + CHAR_setWorkInt(meindex, NPC_WORK_MODEFLAG, NPC_STATEWAIT); + CHAR_setInt(meindex, CHAR_LOOPINTERVAL, FMWARPMAN_WAIT_LOOPTIME); + } + }else if (CHAR_getWorkInt(meindex, NPC_WORK_MODEFLAG) == NPC_STATEWAIT){ + + // andy_edit 2002/07/29 + if (tm1.tm_min == FMWARPMAN_CLEANPLACE) + CHAR_setInt(meindex, CHAR_LOOPINTERVAL, FMWARPMAN_FREE_LOOPTIME); + + NPC_CleanPK(floor, meindex); + + if (tm1.tm_min == 0){ + int iFmIndex1 = fmpks[fmpks_pos].host_index; + int iFmIndex2 = fmpks[fmpks_pos].guest_index; + int i,iCharindex; + for(i=0;i= 0 && CHAR_getCharUse(iCharindex)){ + CHAR_setInt(iCharindex,CHAR_MOMENTUM,0); + CHAR_talkToCli(iCharindex,-1,"ׯ԰ս˼ƹ",CHAR_COLORRED); + } + iCharindex = familyMemberIndex[iFmIndex2][i]; + if(iCharindex >= 0 && CHAR_getCharUse(iCharindex)){ + CHAR_setInt(iCharindex,CHAR_MOMENTUM,0); + CHAR_talkToCli(iCharindex,-1,"ׯ԰ս˼ƹ",CHAR_COLORRED); + } + } + CHAR_setWorkInt(meindex, NPC_WORK_MODEFLAG, NPC_STATEFREE); + // shan add + NPC_FMBATTLESET(floor, fmpks[fmpks_pos].host_index, fmpks[fmpks_pos].guest_index, -1); + CHAR_setInt(meindex, CHAR_LOOPINTERVAL, FMWARPMAN_FREE_LOOPTIME); + // fmwarpman ʼ + CHAR_setWorkInt(meindex, NPC_WORK_FMNUMI, 0); + CHAR_setWorkInt(meindex, NPC_WORK_FMNUMII, 0); + CHAR_setWorkInt(meindex, NPC_WORK_TIMEFLAG, 0); + CHAR_setWorkInt(meindex, NPC_WORK_TALKFLAG, -1); + CHAR_setWorkChar(meindex, NPC_WORK_WINFMNAME, ""); + } + } +} + +void NPC_FMWarpManWindowTalked( int meindex, int talkerindex, + int seqno, int select, char *data) +{ + char npcarg[NPC_UTIL_GETARGSTR_BUFSIZE]; + char buf[1024], buff2[256], tmpbuf[256]; + int fl, x, y, fmpks_pos, fd; + + if( !CHAR_CHECKINDEX( talkerindex) )return; + fd = getfdFromCharaIndex(talkerindex); + if (fd == -1) return; + + if( NPC_Util_CharDistance( talkerindex, meindex ) > 2) { + return; + } + if(select==WINDOW_BUTTONTYPE_OK){ + return; + } + if(NPC_Util_GetArgStr( meindex, npcarg, sizeof(npcarg))==NULL){ + print("GetArgStrErr"); + return ; + } + // shan add + fmpks_pos = CHAR_getWorkInt(meindex, NPC_WORK_ID) * MAX_SCHEDULE; + + if (CHAR_getWorkInt(talkerindex, CHAR_WORKFMINDEXI) == fmpks[fmpks_pos].host_index){ + if( NPC_Util_GetStrFromStrWithDelim( npcarg, "WARP1", buf, sizeof( buf)) == NULL ){ + print("FM WARPMAN Can't Read WARP1!\n"); + return; + } + }else if (CHAR_getWorkInt(talkerindex, CHAR_WORKFMINDEXI) == fmpks[fmpks_pos].guest_index){ + if( NPC_Util_GetStrFromStrWithDelim( npcarg, "WARP2", buf, sizeof( buf)) == NULL ){ + print("FM WARPMAN Can't Read WARP2!\n"); + return; + } + }else{ + CHAR_talkToCli( talkerindex, meindex, "㲢Ƕս˫һԱ", CHAR_COLORYELLOW); + return; + } + getStringFromIndexWithDelim(buf,",",1,buff2,sizeof(buff2)); + fl=atoi(buff2); + getStringFromIndexWithDelim(buf,",",2,buff2,sizeof(buff2)); + x=atoi(buff2); + getStringFromIndexWithDelim(buf,",",3,buff2,sizeof(buff2)); + y=atoi(buff2); + + + switch (seqno){ + case CHAR_WINDOWTYPE_WINDOWWARPMAN_MAIN: + if(select==WINDOW_BUTTONTYPE_YES){ + if( CHAR_getWorkInt( talkerindex, CHAR_WORKBATTLEMODE) != BATTLE_CHARMODE_NONE) return; + if(CHAR_getWorkInt(talkerindex, CHAR_WORKPARTYMODE) != CHAR_PARTY_NONE){ + CHAR_talkToCli( talkerindex, meindex, "ɢŶӣ", CHAR_COLORYELLOW); + return; + } + + if(CHAR_getWorkInt( talkerindex , CHAR_WORKSHOPRELEVANTTRD) <= 0){ + if( CHAR_getWorkInt( talkerindex, CHAR_WORKWARPCHECK ) == TRUE ) { + if (CHAR_getWorkInt(meindex, NPC_WORK_MODEFLAG) == NPC_STATEFREE){ + if (CHAR_getWorkInt(talkerindex, CHAR_WORKFMINDEXI) == fmpks[fmpks_pos].host_index){ + int tmpnum1 = CHAR_getWorkInt(meindex, NPC_WORK_FMNUMI) + 1; + CHAR_setWorkInt(meindex, NPC_WORK_FMNUMI, tmpnum1); + }else if (CHAR_getWorkInt(talkerindex, CHAR_WORKFMINDEXI) == fmpks[fmpks_pos].guest_index){ + int tmpnum2 = CHAR_getWorkInt(meindex, NPC_WORK_FMNUMII) + 1; + CHAR_setWorkInt(meindex, NPC_WORK_FMNUMII, tmpnum2); + }else{ + CHAR_talkToCli( talkerindex, meindex, "㲢Ƕս˫һԱ", CHAR_COLORYELLOW); + } + CHAR_setWorkInt(talkerindex, CHAR_WORKFMPKFLAG, 1); + CHAR_setWorkInt(talkerindex, CHAR_WORKFMMANINDEX, meindex); + CHAR_setWorkInt( talkerindex, CHAR_WORKWARPCHECK, FALSE ); + CHAR_warpToSpecificPoint(talkerindex, fl, x,y); +/* { + FILE *fp; + struct tm tm1; + char szFileName[128]; + + memcpy(&tm1, localtime((time_t *)&NowTime.tv_sec), sizeof(tm1)); + memset(szFileName,0,sizeof(szFileName)); + sprintf(szFileName,"FMPkWarp.%d%d%d.log",tm1.tm_mon,tm1.tm_hour,tm1.tm_min); + fp = fopen(szFileName,"a+"); + if(fp != NULL){ + fprintf(fp,"FMName:%s\tName:%s\tWarpHost:%d\tWarpGuest:%d\tFloor:%d,%d,%d\tMaxPlayer:%d\n", + CHAR_getChar(talkerindex,CHAR_FMNAME),CHAR_getChar(talkerindex,CHAR_NAME), + CHAR_getWorkInt(meindex,NPC_WORK_FMNUMI), + CHAR_getWorkInt(meindex,NPC_WORK_FMNUMII), + fl,x,y, + fmpks[fmpks_pos].max_player); + fclose(fp); + } + else printf("%s(errno:%x)\n",sys_errlist[errno],errno); + } +*/ + } + else return; + { + struct tm tm1; + int clock = 0; + int fmpks_pos = CHAR_getWorkInt(meindex, NPC_WORK_ID) * MAX_SCHEDULE; + memcpy(&tm1, localtime((time_t *)&NowTime.tv_sec), sizeof(tm1)); + clock = ((fmpks[fmpks_pos].dueltime % 100) + fmpks[fmpks_pos].prepare_time) - tm1.tm_min; + if (clock >= 60) clock = clock - 60; + sprintf(tmpbuf, "\nȺ˫׼ٿս" + "\nսʱ벻Ҫdz뿪" + "\nӮʤļҲһ£" + "\nȴе볡" + "\nллĺ" + "\nսʱ仹ʣ£%4d", + clock); + lssproto_WN_send(fd, + WINDOW_MESSAGETYPE_MESSAGE, WINDOW_BUTTONTYPE_OK, + -1, -1, + makeEscapeString(tmpbuf, buff2, sizeof(buff2))); + } + } + } + else{ + if(CHAR_getInt(talkerindex,CHAR_GOLD) < CHAR_getWorkInt(talkerindex,CHAR_WORKSHOPRELEVANTTRD)){ + NPC_ERR_FMDiSP( meindex, talkerindex, 2); + return ; + } + CHAR_DelGold( talkerindex, CHAR_getWorkInt(talkerindex,CHAR_WORKSHOPRELEVANTTRD )); + CHAR_setWorkInt( talkerindex, CHAR_WORKWARPCHECK, FALSE ); + CHAR_warpToSpecificPoint(talkerindex, fl, x,y); + } + } + break; + } +} + +void NPC_ERR_FMDiSP(int meindex,int talker,int errNO) +{ + + char token[1024]; + int i=0; + int otherindex; + int fd = getfdFromCharaIndex( talker); + char npcarg[NPC_UTIL_GETARGSTR_BUFSIZE]; + + if(NPC_Util_GetArgStr( meindex, npcarg, sizeof(npcarg))==NULL){ + print("GetArgStrErr"); + return ; + } + + if(errNO==1){ + /*--ɡ ūƥ ƾ--*/ + if(NPC_Util_GetStrFromStrWithDelim( npcarg, "PartyMsg",token, sizeof( token))==NULL) { + /*--ɬýľئľɣƱë--*/ + sprintf(token, "\n\n޷ŶӣȽɢŶӣ"); + } + + if(CHAR_getWorkInt(talker,CHAR_WORKPARTYMODE)==CHAR_PARTY_CLIENT){ + + }else{ + + /*--ĸ ƾ--*/ + /*--ɡ ū幻嶪ë--*/ + for( i=0 ; i < CHAR_PARTYMAX ;i++) + { + otherindex=CHAR_getWorkInt(talker,CHAR_WORKPARTYINDEX1+i); + + if(otherindex != -1){ + fd = getfdFromCharaIndex( otherindex); + + /*-ƥ˪--*/ + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + CHAR_WINDOWTYPE_WINDOWWARPMAN_ERR, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + token); + } + } + return ; + } + + }else if (errNO==2){ + /*--ŻԻئƥʣ--*/ + if(NPC_Util_GetStrFromStrWithDelim( npcarg, "MoneyMsg", token, sizeof( token))==NULL){ + /*--ŻԻئмɬýľئգƱë Ի--*/ + sprintf(token,"\n\nǮƺࡣǮٹ"); + } + } + + /*-ƥ˪--*/ + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + CHAR_WINDOWTYPE_WINDOWWARPMAN_ERR, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + token); +} + +static void NPC_FMWarpMan_selectWindow( int meindex, int toindex, int num,int select) +{ + struct tm tm1; + char npcarg[NPC_UTIL_GETARGSTR_BUFSIZE]; + char token[1024]; + char buf[256]; + char buf2[1024]; + char buf3[256]; + int fl = 0, num1 = 0, num2 = 0; + int fmpks_pos = CHAR_getWorkInt(meindex, NPC_WORK_ID) * MAX_SCHEDULE; + int floor = CHAR_getWorkInt(meindex, NPC_WORK_WARPFLOOR); + int fd = getfdFromCharaIndex( toindex); + if( fd == -1 ) { + fprint( "getfd err\n"); + return; + } + if(NPC_Util_GetArgStr( meindex, npcarg, sizeof(npcarg))==NULL){ + print("GetArgStrErr"); + return ; + } + /*--ɬð̻P ׷ʧѻ϶ýľ¾ľľɰ׷ʧѼԻ*/ + if(strstr(npcarg,"%4d")!=NULL){ + NPC_Util_GetStrFromStrWithDelim( npcarg, "WARP1", buf, sizeof( buf)); + getStringFromIndexWithDelim(buf,",",1,buf3,sizeof(buf3)); + fl = NPC_FMFloorUse(atoi(buf3)); + } + CHAR_setWorkInt(toindex, CHAR_WORKWARPCHECK, TRUE); + CHAR_setWorkInt(toindex, NPC_WORK_WARPFLOOR, fl); + memcpy(&tm1, localtime((time_t *)&NowTime.tv_sec), sizeof(tm1)); + + if (CHAR_getWorkInt(meindex, NPC_WORK_MODEFLAG) == NPC_STATEFREE) + { + if (((CHAR_getWorkInt(toindex, CHAR_WORKFMINDEXI) == fmpks[fmpks_pos].host_index) + && (strcmp(CHAR_getChar(toindex, CHAR_FMNAME), fmpks[fmpks_pos].host_name) == 0)) + || ((CHAR_getWorkInt(toindex, CHAR_WORKFMINDEXI) == fmpks[fmpks_pos].guest_index) + && (strcmp(CHAR_getChar(toindex, CHAR_FMNAME), fmpks[fmpks_pos].guest_name) == 0))) + { + if(CHAR_getInt(toindex,CHAR_FMINDEX)<0) + { + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, -1, -1, + makeEscapeString("\n㻹ûмأˣ", token, sizeof(token))); + return; + } + if ((fmpks[fmpks_pos].host_index != -1) + && (CHAR_getWorkInt(toindex, CHAR_WORKFMINDEXI) == fmpks[fmpks_pos].host_index)) + { + // WON ADD pkԼս + + if(fmpks[fmpks_pos].flag == -1) return; + + if (fmpks[fmpks_pos].flag != FMPKS_FLAG_SCHEDULED) + + { + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, -1, -1, + makeEscapeString("\nⳡսԷûͬأ\n´ǵԼԷǼǰɡ", token, sizeof(token))); + return; + } + + if(CHAR_getInt(toindex,CHAR_FMINDEX)<0) + { + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, -1, -1, + makeEscapeString("\n㻹ûмأˣ", token, sizeof(token))); + return; + } + +#ifdef _FMVER21 + if (CHAR_getInt(toindex, CHAR_FMLEADERFLAG) == FMMEMBER_APPLY) +#else + if (CHAR_getInt(toindex, CHAR_FMLEADERFLAG) == 0) +#endif + { + char tmpbuf[256]; + sprintf(tmpbuf, "\n㻹ûʽ%s壬Բܽ", fmpks[fmpks_pos].host_name); + lssproto_WN_send(fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, -1, -1, + makeEscapeString(tmpbuf, token, sizeof(token))); + return; + } + //andy_add 2003/06/17 + CHECK_FMPknumInFloor( meindex); + if (CHAR_getWorkInt(meindex, NPC_WORK_FMNUMI) > (fmpks[fmpks_pos].max_player - 1)){ + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, -1, -1, makeEscapeString("\nѾٽȥޡ\nѾ趨ˣ", token, sizeof(token))); + return; + } + } + else if ((fmpks[fmpks_pos].guest_index != -1) + && (CHAR_getWorkInt(toindex, CHAR_WORKFMINDEXI) == fmpks[fmpks_pos].guest_index)) + { + // WON ADD pkԼս + + if(fmpks[fmpks_pos].flag == -1) return; + + if (fmpks[fmpks_pos].flag != FMPKS_FLAG_SCHEDULED) + + { + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, -1, -1, + makeEscapeString("\nⳡսûͬأ\n´ǵȷϡ", token, sizeof(token))); + return; + } +#ifdef _FMVER21 + if (CHAR_getInt(toindex, CHAR_FMLEADERFLAG) == FMMEMBER_APPLY) +#else + if (CHAR_getInt(toindex, CHAR_FMLEADERFLAG) == 0) +#endif + { + char tmpbuf[256]; + sprintf(tmpbuf, "\n㻹ûʽ%s壬Բܽ", fmpks[fmpks_pos].guest_name); + lssproto_WN_send(fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, -1, -1, + makeEscapeString(tmpbuf, token, sizeof(token))); + return; + } + //andy_add 2003/06/17 + CHECK_FMPknumInFloor( meindex); + if( CHAR_getWorkInt( meindex, NPC_WORK_FMNUMII) > (fmpks[fmpks_pos].max_player - 1)){ + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, -1, -1, + makeEscapeString("Ѿٽȥޡ\nѾ趨ˣ", token, sizeof(token))); + return; + } + } + if(NPC_Util_GetStrFromStrWithDelim( npcarg, "FreeMsg", buf2, sizeof( buf2)) == NULL) return; + CONNECT_set_pass(fd, TRUE); + CONNECT_set_first_warp(fd, TRUE); + sprintf(token, buf2, fmpks[fmpks_pos].guest_name, fmpks[fmpks_pos].host_name, + tm1.tm_hour, tm1.tm_min); + CHAR_setWorkInt( toindex , CHAR_WORKFMMANINDEX, meindex ); + CHAR_setWorkInt( toindex , CHAR_WORKSHOPRELEVANTTRD , -1 ); + } else if ((((CHAR_getWorkInt(toindex, CHAR_WORKFMINDEXI) == fmpks[fmpks_pos + 1].host_index) + && (strcmp(CHAR_getChar(toindex, CHAR_FMNAME), fmpks[fmpks_pos + 1].host_name) == 0)) + || ((CHAR_getWorkInt(toindex, CHAR_WORKFMINDEXI) == fmpks[fmpks_pos + 1].guest_index) + && (strcmp(CHAR_getChar(toindex, CHAR_FMNAME), fmpks[fmpks_pos + 1].guest_name) == 0))) + && (((fmpks[fmpks_pos + 1].flag == FMPKS_FLAG_SCHEDULED) + || (fmpks[fmpks_pos + 1].flag == FMPKS_FLAG_MANOR_PREPARE))) + ) + { + if(NPC_Util_GetStrFromStrWithDelim( npcarg, "NextMsg", buf2, sizeof( buf2)) == NULL) return; + sprintf(token, buf2, fl, tm1.tm_hour, tm1.tm_min); + CONNECT_set_pass(fd, FALSE); + CONNECT_set_first_warp(fd, FALSE); + } + else if ((strcmp(fmpks[fmpks_pos].host_name, "") == 0) || (strcmp(fmpks[fmpks_pos].guest_name, "") == 0)) + { + if(NPC_Util_GetStrFromStrWithDelim( npcarg, "TalkMsg", buf2, sizeof( buf2)) == NULL) return; + sprintf(token, buf2); + CONNECT_set_pass(fd, FALSE); + CONNECT_set_first_warp(fd, FALSE); + } + else + { + if(NPC_Util_GetStrFromStrWithDelim( npcarg, "AskMsg", buf2, sizeof( buf2)) == NULL) return; + CONNECT_set_pass(fd, FALSE); + CONNECT_set_first_warp(fd, FALSE); + sprintf(token, buf2, fmpks[fmpks_pos].guest_name, fmpks[fmpks_pos].host_name); + } + } + else if (CHAR_getWorkInt(meindex, NPC_WORK_MODEFLAG) == NPC_STATEBUSY) // ս + { + if (((CHAR_getWorkInt(toindex, CHAR_WORKFMINDEXI) == fmpks[fmpks_pos].host_index) + && (strcmp(CHAR_getChar(toindex, CHAR_FMNAME), fmpks[fmpks_pos].host_name) == 0)) + || ((CHAR_getWorkInt(toindex, CHAR_WORKFMINDEXI) == fmpks[fmpks_pos].guest_index) + && (strcmp(CHAR_getChar(toindex, CHAR_FMNAME), fmpks[fmpks_pos].guest_name) == 0))) + { + if(NPC_Util_GetStrFromStrWithDelim( npcarg, "BusyMsg", buf2, sizeof( buf2)) == NULL){ + print("\nGet BusyMsg Message Error"); + return; + } + NPC_GetPKFMNum(floor, + fmpks[fmpks_pos].host_index, + fmpks[fmpks_pos].guest_index, + &num1, &num2); + sprintf(token, buf2, + fmpks[fmpks_pos].host_name, num1, + fmpks[fmpks_pos].guest_name, num2, + tm1.tm_hour, tm1.tm_min); + } else if ((((CHAR_getWorkInt(toindex, CHAR_WORKFMINDEXI) == fmpks[fmpks_pos + 1].host_index) + && (strcmp(CHAR_getChar(toindex, CHAR_FMNAME), fmpks[fmpks_pos + 1].host_name) == 0)) + || ((CHAR_getWorkInt(toindex, CHAR_WORKFMINDEXI) == fmpks[fmpks_pos + 1].guest_index) + && (strcmp(CHAR_getChar(toindex, CHAR_FMNAME), fmpks[fmpks_pos + 1].guest_name) == 0))) + && (((fmpks[fmpks_pos + 1].flag == FMPKS_FLAG_SCHEDULED) + || (fmpks[fmpks_pos + 1].flag == FMPKS_FLAG_MANOR_PREPARE))) + ) + { + if(NPC_Util_GetStrFromStrWithDelim( npcarg, "NextMsg", buf2, sizeof( buf2)) == NULL) return; + sprintf(token, buf2, fl, tm1.tm_hour, tm1.tm_min); + } else { + if(NPC_Util_GetStrFromStrWithDelim( npcarg, "AskMsg", buf2, sizeof( buf2)) == NULL) return; + sprintf(token, buf2, fmpks[fmpks_pos].guest_name, fmpks[fmpks_pos].host_name); + } + CONNECT_set_pass(fd, FALSE); + CONNECT_set_first_warp(fd, FALSE); + } + else if (CHAR_getWorkInt(meindex, NPC_WORK_MODEFLAG) == NPC_STATEWAIT) // ս + { + if (((CHAR_getWorkInt(toindex, CHAR_WORKFMINDEXI) == fmpks[fmpks_pos].host_index) + && (strcmp(CHAR_getChar(toindex, CHAR_FMNAME), fmpks[fmpks_pos].host_name) == 0)) + || ((CHAR_getWorkInt(toindex, CHAR_WORKFMINDEXI) == fmpks[fmpks_pos].guest_index) + && (strcmp(CHAR_getChar(toindex, CHAR_FMNAME), fmpks[fmpks_pos].guest_name) == 0))) + { + char tmpbuf[256]; + if(NPC_Util_GetStrFromStrWithDelim( npcarg, "EndMsg", buf2, sizeof( buf2)) == NULL){ + print("\nGet EndMsg Message Error"); + return; + } + NPC_GetPKFMNum(floor, + fmpks[fmpks_pos].host_index, + fmpks[fmpks_pos].guest_index, + &num1, &num2); + if (strcmp(CHAR_getWorkChar(meindex, NPC_WORK_WINFMNAME), "") == 0) + sprintf(tmpbuf, "˫ƽ֣"); + else sprintf(tmpbuf, "%sʤˣ", CHAR_getWorkChar(meindex, NPC_WORK_WINFMNAME)); + sprintf(token, buf2, fmpks[fmpks_pos].guest_name, + fmpks[fmpks_pos].host_name, tmpbuf); + } else if ((((CHAR_getWorkInt(toindex, CHAR_WORKFMINDEXI) == fmpks[fmpks_pos + 1].host_index) + && (strcmp(CHAR_getChar(toindex, CHAR_FMNAME), fmpks[fmpks_pos + 1].host_name) == 0)) + || ((CHAR_getWorkInt(toindex, CHAR_WORKFMINDEXI) == fmpks[fmpks_pos + 1].guest_index) + && (strcmp(CHAR_getChar(toindex, CHAR_FMNAME), fmpks[fmpks_pos + 1].guest_name) == 0))) + && (((fmpks[fmpks_pos + 1].flag == FMPKS_FLAG_SCHEDULED) + || (fmpks[fmpks_pos + 1].flag == FMPKS_FLAG_MANOR_PREPARE))) + ) + { + if(NPC_Util_GetStrFromStrWithDelim( npcarg, "NextMsg", buf2, sizeof( buf2)) == NULL) return; + sprintf(token, buf2, fl, tm1.tm_hour, tm1.tm_min); + } else { + if(NPC_Util_GetStrFromStrWithDelim( npcarg, "AskMsg", buf2, sizeof( buf2)) == NULL) return; + sprintf(token, buf2, fmpks[fmpks_pos].guest_name, fmpks[fmpks_pos].host_name); + } + CONNECT_set_pass(fd, FALSE); + CONNECT_set_first_warp(fd, FALSE); + } + /*-ƥ˪--*/ + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_YESNO, + CHAR_WINDOWTYPE_WINDOWWARPMAN_MAIN, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + token); + +} + +int NPC_FMFloorUse(int floor) +{ + int i; + int players = 0; + int playernum = CHAR_getPlayerMaxNum(); + + /* */ + for( i=0 ; i< playernum ; i++ ){ + if( CHAR_getCharUse(i) == FALSE )continue; + if(CHAR_getInt(i,CHAR_FLOOR)==floor){ + players++; + } + } + return players; +} + +void NPC_GetPKFMNum(int floor, int index1, int index2, int *num1, int *num2) +{ + int i = 0, charindex; + + *num1 = 0; *num2 = 0; + + /* */ + for (i = 0 ; i < FAMILY_MAXMEMBER; i++ ){ + charindex = familyMemberIndex[ index1][i]; + if( CHAR_getCharUse( charindex) ){ + if (CHAR_getInt(charindex, CHAR_FLOOR) == floor) + *num1 = *num1 + 1; + }else + familyMemberIndex[ index1][i] = -1; + + charindex = familyMemberIndex[index2][i]; + if (CHAR_getCharUse(charindex)){ + if (CHAR_getInt(charindex, CHAR_FLOOR) == floor) + *num2 = *num2 + 1; + }else + familyMemberIndex[ index2][i] = -1; + } + +} + +void NPC_FMBATTLESET(int floor, int index1, int index2, int flag) +{ + int i = 0, charindex; + + for (i = 0; i < FAMILY_MAXMEMBER; i++) + { + charindex = familyMemberIndex[index1][i]; + if (CHAR_getCharUse(charindex)) + { + if (CHAR_getInt(charindex ,CHAR_FLOOR) == floor) + { + CHAR_setWorkInt( charindex, CHAR_WORKBATTLEFLAG, flag); + if(flag==1) + CHAR_setFlg(charindex, CHAR_ISDUEL, 1); + } + } + else + familyMemberIndex[index1][i] = -1; + charindex = familyMemberIndex[index2][i]; + if (CHAR_getCharUse(charindex)) + { + if (CHAR_getInt(charindex ,CHAR_FLOOR) == floor) + { + CHAR_setWorkInt( charindex, CHAR_WORKBATTLEFLAG, flag); + if(flag==1) + CHAR_setFlg(charindex, CHAR_ISDUEL, 1); + } + } + else + familyMemberIndex[index2][i] = -1; + } +} + +void NPC_CleanPK(int floor, int meindex) +{ + int i; + int playernum = CHAR_getPlayerMaxNum(); + int fl = CHAR_getInt(meindex, CHAR_FLOOR); + int x = CHAR_getInt(meindex, CHAR_X); + int y = CHAR_getInt(meindex, CHAR_Y); + + for( i=0 ; i< playernum ; i++ ) + { + if( CHAR_getCharUse(i) == FALSE )continue; + if(CHAR_getInt(i,CHAR_FLOOR)==floor) + CHAR_warpToSpecificPoint(i, fl, x, y); + } +} + +void NPC_talkToFloor(int floor, int index1, int index2, char *data) +{ + int i = 0, charindex; + + for (i = 0; i < FAMILY_MAXMEMBER; i++) + { + charindex = familyMemberIndex[index1][i]; + if (CHAR_getCharUse(charindex)) + { +// print("charname:%s fmname:%s\n", +// CHAR_getChar(charindex, CHAR_NAME), +// CHAR_getChar(charindex, CHAR_FMNAME)); + if (CHAR_getInt(charindex, CHAR_FLOOR) == floor) + CHAR_talkToCli(charindex, -1, data, CHAR_COLORYELLOW); + } + else + familyMemberIndex[index1][i] = -1; + charindex = familyMemberIndex[index2][i]; + if (CHAR_getCharUse(charindex)) + { +// print("charname:%s fmname:%s\n", +// CHAR_getChar(i, CHAR_NAME), +// CHAR_getChar(i, CHAR_FMNAME)); + if (CHAR_getInt(charindex, CHAR_FLOOR) == floor) + CHAR_talkToCli(charindex, -1, data, CHAR_COLORRED); + } + else + familyMemberIndex[index2][i] = -1; + } +} + +void NPC_WarpFamily(int floor, int index1, int index2, int fl, int x, int y) +{ + int i, charindex1, charindex2; + + for (i = 0; i < FAMILY_MAXMEMBER; i++){ + charindex1 = familyMemberIndex[index1][i]; + charindex2 = familyMemberIndex[index2][i]; + if (CHAR_getCharUse(charindex1)) + { + if (CHAR_getInt(charindex1, CHAR_FLOOR) == floor) + { + CHAR_setWorkInt(charindex1, CHAR_WORKBATTLEFLAG, FALSE); + CHAR_warpToSpecificPoint(charindex1, fl, x, y); + } + } + else + familyMemberIndex[index1][i] = -1; + if (CHAR_getCharUse(charindex2)) + { + if (CHAR_getInt(charindex2, CHAR_FLOOR) == floor) + { + CHAR_setWorkInt(charindex2, CHAR_WORKBATTLEFLAG, FALSE); + CHAR_warpToSpecificPoint(charindex2, fl, x, y); + } + } + else + familyMemberIndex[index1][i] = -1; + } +} + +void NPC_BattleOut(int index1, int index2) +{ + int i, charindex1, charindex2; + + for (i = 0; i < FAMILY_MAXMEMBER; i++) + { + charindex1 = familyMemberIndex[index1][i]; + charindex2 = familyMemberIndex[index2][i]; + if(CHAR_getCharUse(charindex1)){ + if(CHAR_getWorkInt( charindex1, CHAR_WORKBATTLEMODE) != BATTLE_CHARMODE_NONE) + BATTLE_WatchStop(charindex1); + } + else + familyMemberIndex[index1][i] = -1; + + if(CHAR_getCharUse(charindex2)){ + if(CHAR_getWorkInt( charindex2, CHAR_WORKBATTLEMODE) != BATTLE_CHARMODE_NONE) + BATTLE_WatchStop(charindex2); + } + else + familyMemberIndex[index2][i] = -1; + } +} + +void CheckLeavePK(int npcindex, int floor, int index1, int index2) +{ + int i = 0, charindex, fl = 0, x = 0, y = 0; + fl = CHAR_getInt(npcindex, CHAR_FLOOR); + x = CHAR_getInt(npcindex, CHAR_X); + y = CHAR_getInt(npcindex, CHAR_Y); + + for (i = 0; i < FAMILY_MAXMEMBER; i++) + { + charindex = familyMemberIndex[index1][i]; + if (CHAR_getCharUse(charindex)){ + if (CHAR_getInt(charindex, CHAR_FLOOR) == floor){ + if (CHAR_getWorkInt(charindex, CHAR_WORKFMPKFLAG) < 0){ + if (CHAR_getWorkInt(charindex, CHAR_WORKPARTYMODE) != CHAR_PARTY_NONE) + CHAR_DischargeParty( charindex, 0); + CHAR_setWorkInt(charindex, CHAR_WORKWARPCHECK, FALSE); + CHAR_setWorkInt(charindex, CHAR_WORKBATTLEFLAG, FALSE); + CHAR_warpToSpecificPoint(charindex, fl, x, y); + CHAR_talkToCli(charindex, -1, "ս볡", CHAR_COLORRED); + } + } + }else + familyMemberIndex[index1][i] = -1; + charindex = familyMemberIndex[index2][i]; + if (CHAR_getCharUse(charindex)){ + if (CHAR_getInt(charindex, CHAR_FLOOR) == floor){ + if (CHAR_getWorkInt(charindex, CHAR_WORKFMPKFLAG) < 0){ + if (CHAR_getWorkInt(charindex, CHAR_WORKPARTYMODE) != CHAR_PARTY_NONE) + CHAR_DischargeParty(charindex, 0); + CHAR_setWorkInt(charindex, CHAR_WORKWARPCHECK, FALSE); + CHAR_setWorkInt(charindex, CHAR_WORKBATTLEFLAG, FALSE); + CHAR_warpToSpecificPoint(charindex, fl, x, y); + CHAR_talkToCli(charindex, -1, "ս볡", CHAR_COLORRED); + } + } + }else + familyMemberIndex[index2][i] = -1; + } +} diff --git a/npc/npc_freepetskillshop.c b/npc/npc_freepetskillshop.c new file mode 100644 index 0000000..ac4494d --- /dev/null +++ b/npc/npc_freepetskillshop.c @@ -0,0 +1,573 @@ +#include "version.h" +#include +#include "char.h" +#include "object.h" +#include "char_base.h" +#include "npcutil.h" +#include "lssproto_serv.h" +#include "pet_skill.h" +#include "readmap.h" +#include "battle.h" +#include "configfile.h" +#include "util.h" +#include "npc_eventaction.h" +#include "npc_freepetskillshop.h" +#ifdef _PETSKILL_SHOP_LUA +#include "mylua/function.h" +#endif +#ifdef _CFREE_petskill + +enum { + CHAR_WORK_SKILLSELECT = CHAR_NPCWORKINT1, +}; + +enum { + SELECTSKILL_START=10, + SELECTSKILL_TEACH=23, + SELECTSKILL_END=30, +}; + +enum { + START_WINDOW=0, + SKILL_WINDOW, + MEEND_WINDOW, +}; + +static void NPC_FreePetSkillShop_selectWindow( int meindex, int toindex, int num,int select); +BOOL NPC_FreePetSkillMakeStr(int meindex,int toindex, int select); +//BOOL NPC_CHECKFREEPETSKILL( int toindex, int petindex, int skillID); +BOOL NPC_SkillShopItemCheck(int meindex,int talker,int itemNo, int cou); +BOOL NPC_SkillShopDelItems(int meindex,int talker, char *buf); +BOOL NPC_SkillShopPetCheck( int toindex, int petindex, int skillID ); +BOOL NPC_SkillShopWarp( int meindex, int talkindex); + +#define MAXNPCPOINT 10 + +BOOL NPC_FreePetSkillShopInit( int meindex ) +{ + char npcarg[NPC_UTIL_GETARGSTR_BUFSIZE]; + char msg[256]; + CHAR_setInt( meindex , CHAR_WHICHTYPE , CHAR_FREESKILLSHOP ); + CHAR_setWorkInt( meindex, CHAR_WORK_SKILLSELECT, 0); + + if(NPC_Util_GetArgStr( meindex, npcarg, sizeof(npcarg))==NULL){ + print("GetArgStrErr NO arg !!"); + return FALSE; + } + + if( NPC_Util_GetStrFromStrWithDelim( npcarg, "pet_skill", msg, sizeof( msg)) != NULL){ + char buf[256], filename[256]; + int k=1, skillID, skillarray; + while( getStringFromIndexWithDelim( msg, ",", k, buf, sizeof( buf) ) ){ + k++; + skillID=atoi(buf); + skillarray = PETSKILL_getPetskillArray( skillID); + if( PETSKILL_CHECKINDEX( skillarray) == FALSE ) continue; + if( PETSKILL_getInt( skillarray, PETSKILL_ILLEGAL) == 1){ + if( NPC_Util_CheckAssignArgFile( meindex, filename) != NULL ){ + print("\n\ܲ淶:[%d-%s] ->ļ:%s\n", + skillID, + PETSKILL_getChar( skillarray, PETSKILL_NAME), + filename ); + } + } + } + }else{ + return FALSE; + } + + return TRUE; +} +void NPC_FreePetSkillShopTalked( int meindex , int talkerindex , char *szMes ,int color ) +{ + if( CHAR_getInt( talkerindex , CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER ) { + return; + } + if(NPC_Util_isFaceToFace(talkerindex,meindex,2 )==FALSE){ + if( NPC_Util_CharDistance( talkerindex, meindex ) > 1) return; + } + CHAR_setWorkInt( talkerindex, CHAR_WORKSHOPRELEVANT, 1 ); + + NPC_FreePetSkillShop_selectWindow( meindex, talkerindex, START_WINDOW,-1); +} + +static void NPC_FreePetSkillShop_selectWindow( int meindex, int toindex, int num,int select) +{ + char npcarg[NPC_UTIL_GETARGSTR_BUFSIZE]; + char token[1024]; + int fd = getfdFromCharaIndex( toindex); + int buttontype = 0, windowtype = 0, windowno = 0; + char buf1[256]; + + if(NPC_Util_GetArgStr( meindex, npcarg, sizeof(npcarg))==NULL){ + print("GetArgStrErr"); + return ; + } + + switch(num) { + case START_WINDOW: + { + BOOL Evflg = TRUE; + if( NPC_Util_GetStrFromStrWithDelim( npcarg, "start_msg", token, sizeof( token)) == NULL) { + CHAR_setWorkInt( toindex, CHAR_WORKSHOPRELEVANT, 0); + return; + } + if( CHAR_getWorkInt( toindex, CHAR_WORKSHOPRELEVANT) != 1 ) { + CHAR_setWorkInt( toindex, CHAR_WORKSHOPRELEVANT, 0); + return; + } + //ж + if( NPC_Util_GetStrFromStrWithDelim( npcarg, "FREE", buf1, sizeof( buf1)) != NULL ) { + if( NPC_ActionPassCheck( meindex, toindex, buf1) == FALSE ) { + Evflg = FALSE; + } + } + if( Evflg == FALSE) { + CHAR_talkToCli( toindex, -1, "óѧ⼼ܣร", CHAR_COLORYELLOW); + CHAR_setWorkInt( toindex, CHAR_WORKSHOPRELEVANT, 0); + return; + }else { + windowtype = WINDOW_MESSAGETYPE_MESSAGE; + buttontype = WINDOW_BUTTONTYPE_NEXT; + windowno = SELECTSKILL_START; + CHAR_setWorkInt( toindex, CHAR_WORKSHOPRELEVANT, 2); + lssproto_WN_send( fd, windowtype, buttontype, windowno, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), token ); + } + } + break; + case SKILL_WINDOW: + if( NPC_FreePetSkillMakeStr( meindex, toindex, select) == FALSE ) { + print("\n npc_freepetskillshop.c "); + } + break; + case MEEND_WINDOW: + break; + } +} + +void NPC_FreePetSkillShopWindowTalked( int meindex, int talkerindex, int seqno, int select, char *data) +{ + int skill; + int pet; + int slot; + int cost; + int skillID=0; + int petskillindex; + char buf[64]; + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + char msg[512]; + int petindex; + char msgbuf[128]; + double rate= 1.0; + + if(NPC_Util_GetArgStr( meindex, argstr, sizeof(argstr))==NULL){ + print("GetArgStrErr"); + return; + } + + if( CHAR_getInt( talkerindex , CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER ) { + return; + } + if(NPC_Util_isFaceToFace(talkerindex,meindex,2 )==FALSE){ + if( NPC_Util_CharDistance( talkerindex, meindex ) > 1) return; + } + if( CHAR_getWorkInt( talkerindex, CHAR_WORKBATTLEMODE) != BATTLE_CHARMODE_NONE) + return ; + + + switch( seqno) { + case SELECTSKILL_START: + if( CHAR_getWorkInt( talkerindex, CHAR_WORKSHOPRELEVANT) != 2 ) { + CHAR_setWorkInt( talkerindex, CHAR_WORKSHOPRELEVANT, 0); + return; + } + NPC_FreePetSkillShop_selectWindow( meindex, talkerindex, SKILL_WINDOW, -1); + break; + case SELECTSKILL_TEACH: + if( CHAR_getWorkInt( talkerindex, CHAR_WORKSHOPRELEVANT) != 3 ) { + CHAR_setWorkInt( talkerindex, CHAR_WORKSHOPRELEVANT, 0); + return; + } + makeStringFromEscaped( data); + getStringFromIndexWithDelim(data,"|",1,buf,sizeof(buf)); + skill=atoi(buf); + getStringFromIndexWithDelim(data,"|",2,buf,sizeof(buf)); + pet=atoi(buf); + getStringFromIndexWithDelim(data,"|",3,buf,sizeof(buf)); + slot=atoi(buf); + getStringFromIndexWithDelim(data,"|",4,buf,sizeof(buf)); + cost=atoi(buf); + + if( NPC_Util_GetStrFromStrWithDelim( argstr, "pet_skill", msg, sizeof( msg)) != NULL){ + getStringFromIndexWithDelim(msg,",",skill,buf,sizeof(buf)); + skillID=atoi(buf); + } + slot--; + if( slot < 0 ) return; + + petindex = CHAR_getCharPet( talkerindex, pet-1); + if( !CHAR_CHECKINDEX(petindex) ){ + CHAR_send_P_StatusString( talkerindex, CHAR_P_STRING_GOLD); + return ; + } + if( NPC_Util_GetStrFromStrWithDelim( argstr, "skill_rate", msg, sizeof( msg)) != NULL){ + rate = atof( msg); + } + petskillindex = PETSKILL_getPetskillArray( skillID ); + if( !PETSKILL_CHECKINDEX( petskillindex)){ + CHAR_send_P_StatusString( talkerindex, CHAR_P_STRING_GOLD); + return ; + } + + cost = PETSKILL_getInt( petskillindex, PETSKILL_COST ); + cost = cost * rate; + + //ж + if(CHAR_getInt(talkerindex,CHAR_GOLD) < cost){ + CHAR_send_P_StatusString( talkerindex, CHAR_P_STRING_GOLD); + return; + } +#ifdef _PETSKILL_SHOP_LUA + if(FreePetSkillShop(talkerindex, petindex, CHAR_getPetSkill(petindex, slot), skillID) == FALSE ) { + return; + } +#endif + if( NPC_CHECKFREEPETSKILL( talkerindex, petindex, skillID ) == TRUE ){ + + if( Action_RunDoEventAction( meindex, talkerindex, argstr) == FALSE ){ + CHAR_talkToCli( talkerindex, -1, "Ʒ!!", CHAR_COLORYELLOW); + CHAR_send_P_StatusString( talkerindex, CHAR_P_STRING_GOLD); + CHAR_setWorkInt( talkerindex, CHAR_WORKSHOPRELEVANT, 0); + return; + } + + CHAR_setPetSkill( petindex, slot, skillID); + CHAR_setInt( talkerindex, CHAR_GOLD, ( CHAR_getInt( talkerindex, CHAR_GOLD) - cost) ); + snprintf( msgbuf, sizeof( msgbuf ), "W%d",pet-1); + CHAR_sendStatusString( talkerindex, msgbuf ); + CHAR_sendStatusString( talkerindex, "P"); + CHAR_send_P_StatusString( talkerindex, CHAR_P_STRING_GOLD); + //WARP + if( NPC_SkillShopWarp( meindex, talkerindex) == TRUE ) + return; + }else { + CHAR_send_P_StatusString( talkerindex, CHAR_P_STRING_GOLD); + CHAR_talkToCli( talkerindex, -1, "!!", CHAR_COLORYELLOW); + } + //ADD + NPC_FreePetSkillShop_selectWindow( meindex, talkerindex, SKILL_WINDOW, -1); + break; + case SELECTSKILL_END: + break; + } + + return; +} + +BOOL NPC_CHECKFREEPETSKILL( int toindex, int petindex, int skillID) +{ + int skillindex=-1; + char SCode[256]; + char Free[256]; + int i, petID; + skillindex = PETSKILL_getPetskillArray( skillID ); + memset( Free, 0, sizeof( Free)); + if( !PETSKILL_CHECKINDEX( skillindex) ) { + return FALSE; + } + + petID = CHAR_getInt( petindex, CHAR_PETID); + sprintf( SCode, "%s", PETSKILL_getChar( skillindex, PETSKILL_KINDCODE)); + sprintf( Free, "%s", PETSKILL_getChar( skillindex, PETSKILL_FREE)); + + //CHECK CODE + if( !strcmp( SCode, "\0")) { + return TRUE; + } + + for( i=0; i= cou ) + return TRUE; + } + return FALSE; + +} + +BOOL NPC_SkillShopDelItems(int meindex,int talker, char *buf) +{ + char buf1[256]; + char item[256], cout[256]; + int i=1; + BOOL Evflg=TRUE; + while( getStringFromIndexWithDelim( buf, ",", i,buf1, sizeof( buf1)) != FALSE ) { + i++; + if( strstr( buf1, "*") != NULL ) { + getStringFromIndexWithDelim( buf1, "*", 1, item, sizeof( item)); + getStringFromIndexWithDelim( buf1, "*", 2, cout, sizeof( cout)); + }else { + strcpy( item, buf1); + strcpy( cout, "1"); + } + if( NPC_SkillShopItemCheck( meindex, talker, atoi( item), atoi( cout)) == FALSE ) { + Evflg=FALSE; + break; + } + if( Evflg == FALSE ) + break; + } + if( Evflg == FALSE ) + return FALSE; + if( NPC_ActionDelItem( talker, buf) == TRUE ) { + return TRUE; + } + return FALSE; +} + +BOOL NPC_SkillShopPetCheck( int toindex, int petindex, int skillID ) +{ + char Free[256]; + int i; + char data[256], msg[256]; + int skillindex = PETSKILL_getPetskillArray( skillID ); + + memset( Free, 0, sizeof( Free)); + sprintf( Free, "%s", PETSKILL_getChar( skillindex, PETSKILL_FREE)); + + if( NPC_Util_GetStrFromStrWithDelim( Free, "FREE", data, sizeof( data)) != NULL ) { + BOOL EvFlg = TRUE; + i=1; + while( getStringFromIndexWithDelim( data, "|", i, msg, sizeof( msg)) != FALSE ) { + i++; + if( strstr( msg, "LV") != NULL ) { + char LvStr[256]; + int LV=0; + if( strstr( msg, ">" ) != NULL ) { + if( getStringFromIndexWithDelim( msg, ">", 2, LvStr, sizeof( LvStr)) != FALSE ) { + LV = atoi( LvStr); + if( CHAR_getInt( petindex, CHAR_LV) <= LV ) + EvFlg = FALSE; + } + }else if( strstr( msg, "<")) { + if( getStringFromIndexWithDelim( msg, "<", 2, LvStr, sizeof( LvStr)) != FALSE ) { + LV = atoi( LvStr); + if( CHAR_getInt( petindex, CHAR_LV) >= LV ) + EvFlg = FALSE; + } + } + }else if( strstr( msg, "SK") != NULL ) { + int j=0, PskId=-1, ID; + char strSK[256]; + int petskillindex; + + getStringFromIndexWithDelim( msg, "=", 2, strSK, sizeof( strSK) ); + ID = atoi( strSK); + for( j=0; j < CHAR_MAXPETSKILLHAVE; j++) { + PskId = CHAR_getPetSkill( petindex, j); + petskillindex = PETSKILL_getPetskillArray( PskId ); + if( !PETSKILL_CHECKINDEX( petskillindex)) + continue; + if( ID == PskId ) { + if( strstr( msg, "!=") !=NULL ) + EvFlg = FALSE; + break; + } + } + if( j == CHAR_MAXPETSKILLHAVE ) { + EvFlg = FALSE; + break; + } + } + if( EvFlg == FALSE ) + break; + } + if( EvFlg == FALSE ) { + return FALSE; + }else { + return TRUE; + } + } + return TRUE; +} + +BOOL NPC_SkillShopWarp( int meindex, int talkindex) +{ + char npcarg[NPC_UTIL_GETARGSTR_BUFSIZE]; + char data[1024], buf1[256], buf2[256]; + int i=1, j=1; + BOOL EvFlg=FALSE; + struct { + int FLOOR; + int X; + int Y; + }Points[MAXNPCPOINT]; + + if(NPC_Util_GetArgStr( meindex, npcarg, sizeof(npcarg))==NULL){ + print("GetArgStrErr"); + return FALSE; + } + + for( i=0;i= MAXNPCPOINT ) + break; + } + where = RAND( 0, i-1); + CHAR_warpToSpecificPoint( meindex, Points[where].FLOOR, Points[where].X, Points[where].Y); + EvFlg = TRUE; + } + + if( NPC_Util_GetStrFromStrWithDelim( npcarg, "WARP", data, sizeof( data)) != NULL ) { + int P_Floor,P_X,P_Y; + getStringFromIndexWithDelim( data, ",", 1, buf2, sizeof( buf2)); + P_Floor = atoi( buf2); + getStringFromIndexWithDelim( data, ",", 2, buf2, sizeof( buf2)); + P_X = atoi( buf2); + getStringFromIndexWithDelim( data, ",", 3, buf2, sizeof( buf2)); + P_Y = atoi( buf2); + CHAR_warpToSpecificPoint( talkindex, P_Floor, P_X, P_Y); + EvFlg = TRUE; + } + + return EvFlg; +} + +#endif + + + + + diff --git a/npc/npc_gamblebank.c b/npc/npc_gamblebank.c new file mode 100644 index 0000000..c9659df --- /dev/null +++ b/npc/npc_gamblebank.c @@ -0,0 +1,519 @@ +#include "version.h" +#include +#include +#include "char.h" +#include "object.h" +#include "char_base.h" +#include "npcutil.h" +#include "lssproto_serv.h" +#include "enemy.h" +#include "log.h" +#include "battle.h" +#include "readmap.h" +#include "handletime.h" +#include "configfile.h" +#ifdef _GAMBLE_BANK +#include "npc_gamblebank.h" + +static void NPC_GambleBank_selectWindow( int meindex, int toindex, int num, int flg); +int NPC_GambleBank_DoGold( int meindex, int toindex, int Gold, int flg); +BOOL NPC_GambleBank_AddItem( int meindex, int toindex, int itemId, int count); + +enum { + GAMBLE_START = 0, + GAMBLE_SELET, + GAMBLE_MAN_BANK, + GAMBLE_MAN_CHANG1, + GAMBLE_MAN_CHANG2, + GAMBLE_END, +}; + +enum { + NPC_WORK_INDEX = CHAR_NPCWORKINT1, + NPC_WORK_WORKTYPE = CHAR_NPCWORKINT2, // 0,-1 = NULL 2 = 3 = 4 = BOTH + NPC_WORK_CURRENTTIME = CHAR_NPCWORKINT3, + NPC_WORK_PAGE = CHAR_NPCWORKINT4, +/* + NPC_WORK_ROUTETOY = CHAR_NPCWORKINT2, + NPC_WORK_ROUTEPOINT = CHAR_NPCWORKINT3, + NPC_WORK_ROUNDTRIP = CHAR_NPCWORKINT4, + NPC_WORK_MODE = CHAR_NPCWORKINT5, + NPC_WORK_CURRENTROUTE = CHAR_NPCWORKINT6, + NPC_WORK_ROUTEMAX = CHAR_NPCWORKINT7, + NPC_WORK_WAITTIME = CHAR_NPCWORKINT8, + NPC_WORK_CURRENTTIME = CHAR_NPCWORKINT9, + NPC_WORK_SEFLG = CHAR_NPCWORKINT10, +*/ +}; +#define _GAMBLEBANK_U_NOLOCK //ͬʱԶ + +#define GAMBLEBANK_LOOPTIME 80 +#define GAMBLEBANK_STANDBY 5000 +#define GAMBLEBANK_DEF 3 // / 100 +#define GAMBLEBANK_GETMAX 1000000 +#define GAMBLEBANK_GETMIN 100 +#define LIST_PAGE 7 +BOOL NPC_GambleBankInit( int meindex ) +{ + char npcarg[NPC_UTIL_GETARGSTR_BUFSIZE]; + char buf1[256]; + CHAR_setInt( meindex , CHAR_WHICHTYPE , CHAR_GAMBLEBANK ); + +#ifdef _GAMBLEBANK_U_NOLOCK + CHAR_setInt( meindex, CHAR_LOOPINTERVAL, GAMBLEBANK_STANDBY); + CHAR_setWorkInt( meindex, NPC_WORK_CURRENTTIME, NowTime.tv_sec); +#endif + CHAR_setWorkInt( meindex , NPC_WORK_INDEX, -1); + + if(NPC_Util_GetArgStr( meindex, npcarg, sizeof(npcarg)) == NULL) { + print("GambleBank:GetArgStrErr"); + return FALSE; + } + + if(NPC_Util_GetStrFromStrWithDelim( npcarg,"GAMBLE_TYPE", buf1,sizeof( buf1) ) == NULL) { + print("GAMBLE_TYPE err !"); + return FALSE; + } + CHAR_setWorkInt( meindex, NPC_WORK_WORKTYPE, atoi( buf1) ); + + return TRUE; +} +//CHAR_send_P_StatusString( charaindex, CHAR_P_STRING_GOLD); +void NPC_GambleBankLoop( int meindex) +{ +#ifdef _GAMBLEBANK_U_NOLOCK + + int fulltime = GAMBLEBANK_LOOPTIME; + if( ( CHAR_getWorkInt( meindex, NPC_WORK_CURRENTTIME) + fulltime) >= NowTime.tv_sec ) + return; + CHAR_setWorkInt( meindex, NPC_WORK_CURRENTTIME, NowTime.tv_sec); + CHAR_setWorkInt( meindex , NPC_WORK_INDEX, -1); +#endif + return; +} + +void NPC_GambleBankTalked( int meindex , int talkerindex , char *szMes ,int color ) +{ + char buf1[256]; + char npcarg[NPC_UTIL_GETARGSTR_BUFSIZE]; + int work_type; + + if( !CHAR_CHECKINDEX( talkerindex) || !CHAR_CHECKINDEX( meindex) ) + return; + if( CHAR_getInt( talkerindex , CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER ) { + return; + } + if(NPC_Util_isFaceToFace( meindex ,talkerindex , 2) == FALSE) { + if(NPC_Util_isFaceToChara( talkerindex, meindex, 1) == FALSE) { + return; + } + } + if(NPC_Util_GetArgStr( meindex, npcarg, sizeof(npcarg)) == NULL) { + print("GambleBank:GetArgStrErr"); + return; + } +#ifdef _FIX_GAMBLENUM + if( CHAR_getInt( talkerindex, CHAR_GAMBLENUM) < 0 ) { + CHAR_setInt( talkerindex, CHAR_GAMBLENUM, 0); + } +#endif + if(NPC_Util_GetStrFromStrWithDelim( npcarg,"GAMBLE_TYPE", buf1,sizeof( buf1) ) == NULL) { + print("GAMBLE_TYPE err !"); + return; + } + + CHAR_setWorkInt( meindex, NPC_WORK_WORKTYPE, atoi( buf1) ); + work_type = CHAR_getWorkInt( meindex, NPC_WORK_WORKTYPE); + + + if( work_type < 1 || work_type > 4 ) { // 0 or -1 + strcpy( buf1,"ʱֹͣ"); + CHAR_talkToCli( talkerindex, meindex, buf1, CHAR_COLORYELLOW); + CHAR_setWorkInt( meindex , NPC_WORK_INDEX, -1); + return; + } +#ifdef _GAMBLEBANK_U_NOLOCK + +#else + if( CHAR_getWorkInt( meindex , NPC_WORK_INDEX) >= 0 ) { + strcpy( buf1,"æţ"); + CHAR_talkToCli( talkerindex, meindex, buf1, CHAR_COLORYELLOW); + return; + }else { + CHAR_setWorkInt( meindex , NPC_WORK_INDEX, talkerindex); + CHAR_setWorkInt( meindex, NPC_WORK_CURRENTTIME, NowTime.tv_sec); + } +#endif + CHAR_setWorkInt( talkerindex, CHAR_WORKSHOPRELEVANT, 1); + NPC_GambleBank_selectWindow( meindex, talkerindex, GAMBLE_START, 1); +} + +static void NPC_GambleBank_selectWindow( int meindex, int toindex, int num, int flg) +{ + char token[256]; + char buf1[256],buf2[256]; + char npcarg[NPC_UTIL_GETARGSTR_BUFSIZE]; + int buttontype = 0, windowtype = 0, windowno = 0; + int fd = getfdFromCharaIndex( toindex); + int i; + int page=-1; + //flg <= 0 1 flg = 2 Ǯ 3 = ˴ + // 4 = н 5 = 6 = + char Gamble_End[][56] = { + "error_msg", "end_msg", "money_msg", "full_msg1", + "full_msg2","getmax_msg","getmin_msg", + }; + + if(NPC_Util_GetArgStr( meindex, npcarg, sizeof(npcarg))==NULL){ + print("GambleBank:GetArgStrErr"); + return; + } + + windowtype = WINDOW_MESSAGETYPE_MESSAGE; + switch( num) { + case GAMBLE_START: + if( NPC_Util_GetStrFromStrWithDelim( npcarg,"gamble_start", token, sizeof( token) ) == NULL) { + print("gamble_start msg err !"); + return; + } + buttontype = WINDOW_BUTTONTYPE_YESNO; + windowno = NPC_GambleBank_START; + break; + + case GAMBLE_SELET: + i = 1; + strcpy( token, "\0"); + sprintf( buf2,"%s%d", "gamble_msg0", i); + while( NPC_Util_GetStrFromStrWithDelim( npcarg, buf2, buf1, sizeof( buf1) ) != NULL ) { + if( strstr( buf1, "NULL" ) == NULL ) { + strcat( token , buf1); + strcat( token, "\n"); + }else { + strcat( token, "\n"); + } + i++; + sprintf( buf2,"%s%d", "gamble_msg0", i); + } + windowtype=WINDOW_MESSAGETYPE_SELECT; + windowno = NPC_GambleBank_SELECT; + break; + + case GAMBLE_MAN_BANK: // + sprintf( token,"%d", CHAR_getInt( toindex, CHAR_PERSONAGOLD ) ); + windowtype = WINDOW_MESSAGETYPE_BANK; + windowno = NPC_GambleBank_BANK; + break; + + case GAMBLE_MAN_CHANG1: // + { + char snum[256]; + page = CHAR_getWorkInt( toindex, CHAR_WORKSHOPRELEVANT); + strcpy( token, ""); + sprintf( token, "%d֣뻻һƷأ\n", CHAR_getInt( toindex, CHAR_GAMBLENUM)); + for( i=(page*LIST_PAGE);i<(page*LIST_PAGE+LIST_PAGE);i++) { + if( i>=arraysizeof( GB_ITEMS)) { + break; + } + if( !strcmp( GB_ITEMS[i].name,"NEXT") ) { + strcat( token, " һҳ"); + break; + } + if( !strcmp( GB_ITEMS[i].name,"END") ) { + strcat( token, " ȡ\n"); + break; + } + + sprintf( snum,"%s%d\t%s", + "֣", GB_ITEMS[i].Gnum, + GB_ITEMS[i].name); + snum[36] = 0; + strcat( token, snum); + strcat( token,"\n"); + strcpy( snum, "\0"); + } + + windowtype = WINDOW_MESSAGETYPE_SELECT; + buttontype = WINDOW_BUTTONTYPE_NONE; + windowno = NPC_GambleBank_CHANG1; + } + break; + case GAMBLE_END: + CHAR_send_P_StatusString( toindex, CHAR_P_STRING_GOLD); + if( flg < 0 || flg > 6) { + flg = 0; + } + if( NPC_Util_GetStrFromStrWithDelim( npcarg, Gamble_End[flg], token, sizeof( token) ) == NULL) { + print("Gamble_End[%d] noe found !", flg); + return; + } + CHAR_setWorkInt( toindex, CHAR_WORKSHOPRELEVANT, -1); +#ifdef _GAMBLEBANK_U_NOLOCK +#else + CHAR_setWorkInt( meindex , NPC_WORK_INDEX, -1); +#endif + windowno = NPC_GambleBank_END; + buttontype = WINDOW_BUTTONTYPE_OK; + break; + } + + lssproto_WN_send( fd, windowtype, + buttontype, + windowno, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + token); +} + +void NPC_GambleBankWindowTalked ( int meindex, int talkerindex, int seqno, int select, char *data) +{ + int stone_gold = 0; + int flg=1; + int work_type=-1; + int type; + type = atoi( data); + + if( !CHAR_CHECKINDEX( talkerindex) || !CHAR_CHECKINDEX( meindex) ) + return; + + work_type = CHAR_getWorkInt( meindex, NPC_WORK_WORKTYPE ); + if( work_type < 1 || work_type > 4 ) { + return; + } + if( CHAR_getInt( talkerindex , CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER ) { + return; + } +#ifdef _GAMBLEBANK_U_NOLOCK +#else + { + char buf1[256]; + if( CHAR_getWorkInt( meindex , NPC_WORK_INDEX) != talkerindex ) { + strcpy( buf1,"æأ"); + CHAR_talkToCli( talkerindex, meindex, buf1, CHAR_COLORYELLOW); + CHAR_setWorkInt( talkerindex, CHAR_WORKSHOPRELEVANT, -1); + return; + } + } +#endif + + if(NPC_Util_isFaceToFace( meindex ,talkerindex , 2) == FALSE) { + if(NPC_Util_isFaceToChara( talkerindex, meindex, 1) == FALSE) return; + } + if( NPC_Util_CharDistance( talkerindex, meindex ) > 2) { + return; + } + CHAR_setWorkInt( meindex, NPC_WORK_CURRENTTIME, NowTime.tv_sec); + switch( seqno) { + case NPC_GambleBank_START: + if( select == WINDOW_BUTTONTYPE_YES ) { + NPC_GambleBank_selectWindow( meindex, talkerindex, GAMBLE_SELET, flg); + }else { + NPC_GambleBank_selectWindow( meindex, talkerindex, GAMBLE_END, flg); + } + break; + case NPC_GambleBank_SELECT: + if( type == 1 ) { // + CHAR_setWorkInt( talkerindex, CHAR_WORKSHOPRELEVANT, 2); + NPC_GambleBank_selectWindow( meindex, talkerindex, GAMBLE_MAN_BANK, flg); + }else if( type == 2 ) { // + CHAR_setWorkInt( talkerindex, CHAR_WORKSHOPRELEVANT, 0); + NPC_GambleBank_selectWindow( meindex, talkerindex, GAMBLE_MAN_CHANG1, flg); + }else { + NPC_GambleBank_selectWindow( meindex, talkerindex, GAMBLE_END, flg); + } + break; + case NPC_GambleBank_BANK: //2 + if( CHAR_getWorkInt( talkerindex, CHAR_WORKSHOPRELEVANT) != 2 ) // + return; + if( work_type != 2 && work_type != 4 ) { + CHAR_setWorkInt( meindex , NPC_WORK_INDEX, -1); + return; + } + if( select == 4 && atoi( data) != 0 ) { + stone_gold = atoi( data); + flg = NPC_GambleBank_DoGold( meindex, talkerindex, stone_gold, select); + //flg = 1 flg = 2 Ǯ flg <= 0 + if( flg == 1 ) { + CHAR_setWorkInt( talkerindex, CHAR_WORKSHOPRELEVANT, -1); + CHAR_setWorkInt( meindex , NPC_WORK_INDEX, -1); + return; + } + } + NPC_GambleBank_selectWindow( meindex, talkerindex, GAMBLE_END, flg); + break; + case NPC_GambleBank_CHANG1: // + { + int page,ItemID; + int count; + type -=1; + page = CHAR_getWorkInt( talkerindex, CHAR_WORKSHOPRELEVANT)*LIST_PAGE; + if( work_type != 3 && work_type != 4 ) { + CHAR_setWorkInt( meindex , NPC_WORK_INDEX, -1); + return; + } + + if( page < 0 ) //Ի + return; + if( (page+type) < 0 || (page+type) >= arraysizeof( GB_ITEMS) ) { + NPC_GambleBank_selectWindow( meindex, talkerindex, GAMBLE_END, flg); + }else if( !strcmp( GB_ITEMS[page+type].name,"NEXT") ){ + CHAR_setWorkInt( talkerindex, CHAR_WORKSHOPRELEVANT, + CHAR_getWorkInt( talkerindex, CHAR_WORKSHOPRELEVANT) + 1); + NPC_GambleBank_selectWindow( meindex, talkerindex, GAMBLE_MAN_CHANG1, flg); + }else if( !strcmp( GB_ITEMS[page+type].name,"END") ){ + CHAR_setWorkInt( meindex , NPC_WORK_INDEX, -1); + CHAR_setWorkInt( talkerindex, CHAR_WORKSHOPRELEVANT, -1); + return; + }else { + if( type < 7 && type >= 0 ) { + if( GB_ITEMS[page+type].name == NULL || + !strcmp( GB_ITEMS[page+type].name, "\0") ) { + }else { + ItemID = GB_ITEMS[page+type].ItemId; //ID + count = GB_ITEMS[page+type].Gnum; // + NPC_GambleBank_AddItem( meindex, talkerindex, ItemID, count); + } + CHAR_setWorkInt( meindex , NPC_WORK_INDEX, -1); + } + CHAR_setWorkInt( talkerindex, CHAR_WORKSHOPRELEVANT, -1); + } + } + break; + case NPC_GambleBank_END: + CHAR_setWorkInt( talkerindex, CHAR_WORKSHOPRELEVANT, -1); + break; + } +} + + +int NPC_GambleBank_DoGold( int meindex, int toindex, int Gold, int flg) +{ + //flg = 1 flg = 2 Ǯ flg <= 0 3 = ˴ 4 = н 5 = ߽ + char buf1[256]; + int player_gold = CHAR_getInt( toindex, CHAR_GOLD ); + int stone_def = 0; // +// int def = GAMBLEBANK_DEF; + //Ĵȡ + if( flg != 4 ) + return 0; + if( Gold == 0 ) { + return 0; + } + + if( Gold < 0 ) { //ȡ + Gold *=-1; + //stone_def = (Gold * def) /100; + stone_def = 300; + if( Gold > GAMBLEBANK_GETMAX ) { + return 5; + }else if( Gold < GAMBLEBANK_GETMIN ) { + return 6; + } + if( ( player_gold + Gold ) > CHAR_getMaxHaveGold(toindex) ) { + return 3; //ȡὫ˽ + }else if( (Gold + stone_def)> CHAR_getInt( toindex, CHAR_PERSONAGOLD ) ) { //д + return 2; + } + + CHAR_setInt( toindex, CHAR_PERSONAGOLD, (CHAR_getInt( toindex, CHAR_PERSONAGOLD )-(Gold+stone_def))); + + CHAR_AddGold( toindex, Gold); + + sprintf( buf1,"ȡ%d ѣ%dʣࣺ%d ", Gold, stone_def, CHAR_getInt( toindex, CHAR_PERSONAGOLD )); + CHAR_talkToCli( toindex, meindex, buf1, CHAR_COLORYELLOW); + LogBankStone( CHAR_getChar( toindex, CHAR_NAME ), CHAR_getChar( toindex, CHAR_CDKEY ), + toindex, Gold, + "GB_Bank_Get(ȡ)", + CHAR_getInt( toindex, CHAR_FLOOR), + CHAR_getInt( toindex, CHAR_X ), CHAR_getInt( toindex, CHAR_Y ) , + CHAR_getInt( toindex, CHAR_GOLD ), + CHAR_getInt( toindex, CHAR_PERSONAGOLD ) + ); + return 1; + }else if( Gold > 0 ) { // + if( Gold > player_gold ) { + return 2; + }else if( (Gold + CHAR_getInt( toindex, CHAR_PERSONAGOLD ) ) > CHAR_MAXPERSONAGOLD ) { + return 4; + } + + CHAR_DelGold( toindex, Gold ); + + CHAR_setInt( toindex, CHAR_PERSONAGOLD, (CHAR_getInt( toindex, CHAR_PERSONAGOLD ) + Gold ) ); + sprintf( buf1,"%d ʣࣺ%d ", Gold, CHAR_getInt( toindex, CHAR_PERSONAGOLD )); + CHAR_talkToCli( toindex, meindex, buf1, CHAR_COLORYELLOW); + LogBankStone( CHAR_getChar( toindex, CHAR_NAME ), CHAR_getChar( toindex, CHAR_CDKEY ), + toindex, Gold, + "GB_Bank_save(д)", + CHAR_getInt( toindex, CHAR_FLOOR), + CHAR_getInt( toindex, CHAR_X ), CHAR_getInt( toindex, CHAR_Y ), + CHAR_getInt( toindex, CHAR_GOLD ), + CHAR_getInt( toindex, CHAR_PERSONAGOLD ) + ); + return 1; + } + return 0; +} + +BOOL NPC_GambleBank_AddItem( int meindex, int toindex, int itemId, int count) +{ + int i=-1,itemindex=-1; + int ret=-1; + char token[256]; + strcpy( token,"\0"); + if( count < 0 || itemId < 0 ) + return FALSE; + + if( CHAR_getInt( toindex, CHAR_GAMBLENUM) < count ) { + sprintf( token,"ֲֳ㣡"); + CHAR_talkToCli( toindex, -1,token,CHAR_COLORWHITE); + return FALSE; + } + for( i = 0 ; i < CHAR_MAXITEMHAVE ; i++ ){ + itemindex=CHAR_getItemIndex( toindex , i ); + if( itemindex == -1 ) { + break; + } + } + if( i == CHAR_MAXITEMHAVE ) { + snprintf( token,sizeof( token), "Ʒռ䲻㣡"); + CHAR_talkToCli( toindex, -1, token, CHAR_COLORWHITE); + return FALSE; + } + itemindex = ITEM_makeItemAndRegist( itemId); + if(itemindex == -1) + return FALSE; + ret = CHAR_addItemSpecificItemIndex( toindex, itemindex); + if( ret < 0 || ret >= CHAR_MAXITEMHAVE ) { + ITEM_endExistItemsOne( itemindex); + return FALSE; + } + LogItem( + CHAR_getChar( toindex, CHAR_NAME ), + CHAR_getChar( toindex, CHAR_CDKEY ), +#ifdef _add_item_log_name // WON ADD itemlogitem + itemindex, +#else + ITEM_getInt( itemindex, ITEM_ID ), +#endif + "G_BANK(ֳֶһ)", + CHAR_getInt( toindex,CHAR_FLOOR), + CHAR_getInt( toindex,CHAR_X ), + CHAR_getInt( toindex,CHAR_Y ), + ITEM_getChar( itemindex, ITEM_UNIQUECODE), + ITEM_getChar( itemindex, ITEM_NAME), + ITEM_getInt( itemindex, ITEM_ID) + ); + sprintf( token,"õ%s",ITEM_getChar( itemindex, ITEM_NAME)); + CHAR_talkToCli( toindex, -1,token,CHAR_COLORWHITE); + CHAR_sendItemDataOne( toindex, ret); + CHAR_setInt( toindex, CHAR_GAMBLENUM, CHAR_getInt( toindex, CHAR_GAMBLENUM) - count); + sprintf( token,"ֳʣࣺ %d", CHAR_getInt( toindex, CHAR_GAMBLENUM)); + CHAR_talkToCli( toindex, -1,token,CHAR_COLORWHITE); + return TRUE; +} + +#endif + + + + + diff --git a/npc/npc_gamblemaster.c b/npc/npc_gamblemaster.c new file mode 100644 index 0000000..5f6e49a --- /dev/null +++ b/npc/npc_gamblemaster.c @@ -0,0 +1,600 @@ +#include "version.h" +#include +#include "char.h" +#include "object.h" +#include "char_base.h" +#include "npcutil.h" +#include "lssproto_serv.h" +#include "handletime.h" +#include "readmap.h" +#include "log.h" +#include "npc_eventaction.h" + +#ifdef _GAMBLE_ROULETTE + +#include "npc_gamblemaster.h" +void defPlayerGold( int meindex, int flg); +void NPC_GAMBLEMASTER_RESET( int meindex); +void Codef_Gold( int meindex, int toindex, int stone, int flg, char *token); +void NPC_GambleRoulette_selectWindow(int meindex,int toindex,int num,int select); + +enum +{ + ROULETTE_START=0, + ROULETTE_SELECT, + ROULETTE_LOOK, + ROULETTE_END, +}; + +enum +{ + roulette1 = 11, roulette2, roulette3, roulette4, roulette5, roulette6, roulette7, + roulette8, roulette9, roulette10, roulette11, roulette12, roulette13, roulette14, + roulette15, roulette16, roulette17, roulette18, roulette19, roulette20, + + roulette21 = 41, roulette22, roulette23, roulette24, roulette25, roulette26, + roulette27, roulette28, roulette29, roulette30, roulette31, roulette32, + roulette33, roulette34, roulette35, roulette36, roulette37, roulette38, + roulette39, roulette40, + roulette41 = 71, roulette42, roulette43, roulette44, roulette45, + + roulette51 = 101, roulette52=102, roulette53=103, + roulette61 = 111, roulette62=112, +}; + +typedef struct tagGambleMaster +{ + int m_fx; + int m_fy; + int m_type; // + int m_RG; //1 2 + int m_EO; //˫1 2 + int m_SI; + int m_IN; + char str_type[56]; + int m_nums; +}GambleEndType; +GambleEndType EndTypedef[60]={ +{22, 8 , roulette1 , roulette41, roulette43, roulette51, roulette61, "죱", 0}, +{7 , 8 , roulette1 , roulette41, roulette43, roulette51, roulette61, "죱", 0}, +{22, 10, roulette3 , roulette41, roulette43, roulette51, roulette61, "죳", 0}, +{7 , 6 , roulette3 , roulette41, roulette43, roulette51, roulette61, "죳", 0}, +{20, 11, roulette5 , roulette41, roulette43, roulette51, roulette61, "죵", 0}, +{9 , 5 , roulette5 , roulette41, roulette43, roulette51, roulette61, "죵", 0}, +{19, 5 , roulette6 , roulette41, roulette44, roulette53, roulette61, "죶", 0}, +{10, 11, roulette6 , roulette41, roulette44, roulette53, roulette61, "죶", 0}, +{17, 5 , roulette8 , roulette41, roulette44, roulette53, roulette61, "죸", 0}, +{12, 11, roulette8 , roulette41, roulette44, roulette53, roulette61, "죸", 0}, +{16, 5 , roulette9 , roulette41, roulette43, roulette53, roulette61, "죹", 0}, +{13, 11, roulette9 , roulette41, roulette43, roulette53, roulette61, "죹", 0}, +{15, 5 , roulette10, roulette41, roulette44, roulette53, roulette61, "죱", 0}, +{14, 11, roulette10, roulette41, roulette44, roulette53, roulette61, "죱", 0}, +{12, 5 , roulette13, roulette41, roulette43, roulette52, roulette62, "죱", 0}, +{17, 11, roulette13, roulette41, roulette43, roulette52, roulette62, "죱", 0}, +{22, 6 , roulette17, roulette41, roulette43, roulette53, roulette62, "죱", 0}, +{7 , 10, roulette17, roulette41, roulette43, roulette53, roulette62, "죱", 0}, +{22, 5 , roulette18, roulette41, roulette44, roulette52, roulette62, "죱", 0}, +{7 , 11, roulette18, roulette41, roulette44, roulette52, roulette62, "죱", 0}, + +{22, 9 , roulette22, roulette42, roulette44, roulette51, roulette61, "̣", 0}, +{7 , 7 , roulette22, roulette42, roulette44, roulette51, roulette61, "̣", 0}, +{21, 11, roulette24, roulette42, roulette44, roulette51, roulette61, "̣", 0}, +{8 , 5 , roulette24, roulette42, roulette44, roulette51, roulette61, "̣", 0}, +{18, 5 , roulette27, roulette42, roulette43, roulette53, roulette61, "̣", 0}, +{11, 11, roulette27, roulette42, roulette43, roulette53, roulette61, "̣", 0}, +{19, 11, roulette31, roulette42, roulette43, roulette51, roulette62, "̣", 0}, +{10, 5 , roulette31, roulette42, roulette43, roulette51, roulette62, "̣", 0}, +{18, 11, roulette32, roulette42, roulette44, roulette51, roulette62, "̣", 0}, +{11, 5 , roulette32, roulette42, roulette44, roulette51, roulette62, "̣", 0}, +{16, 11, roulette34, roulette42, roulette44, roulette52, roulette62, "̣", 0}, +{14, 5 , roulette34, roulette42, roulette44, roulette52, roulette62, "̣", 0}, +{15, 11, roulette35, roulette42, roulette43, roulette52, roulette62, "̣", 0}, +{13, 5 , roulette35, roulette42, roulette43, roulette52, roulette62, "̣", 0}, +{22, 7 , roulette36, roulette42, roulette44, roulette53, roulette62, "̣", 0}, +{7 , 9 , roulette36, roulette42, roulette44, roulette53, roulette62, "̣", 0}, +{21, 5 , roulette39, roulette42, roulette43, roulette52, roulette62, "̣", 0}, +{8 , 11, roulette39, roulette42, roulette43, roulette52, roulette62, "̣", 0}, +{20, 5 , roulette40, roulette42, roulette44, roulette52, roulette62, "̣", 0}, +{9 , 11, roulette40, roulette42, roulette44, roulette52, roulette62, "̣", 0}, +{22,11, roulette45, 0, 0, roulette52, 0, "룰"}, + +{ 7, 5, -1, -1, -1, -1, -1, "", 0}, +{ -1, -1, -1, -1, -1, -1, -1, "", 0}, +}; + +enum { + /* + NPC_WORK_ROUTETOX = CHAR_NPCWORKINT1, + NPC_WORK_ROUTETOY = CHAR_NPCWORKINT2, + NPC_WORK_ROUTEPOINT = CHAR_NPCWORKINT3, +*/ + NPC_WORK_NPCAI = CHAR_NPCWORKINT3, + NPC_WORK_NPCACTION = CHAR_NPCWORKINT3, + NPC_WORK_MASTERSTONE = CHAR_NPCWORKINT4, + NPC_WORK_MODE = CHAR_NPCWORKINT5, + NPC_WORK_SYSTIME = CHAR_NPCWORKINT6, + NPC_WORK_GAMEFLG = CHAR_NPCWORKINT7, + NPC_WORK_GAMBLECODE = CHAR_NPCWORKINT8, + NPC_WORK_MASTERFLG = CHAR_NPCWORKINT9, + NPC_WORK_ENDPOINT = CHAR_NPCWORKINT10, +}; + +#define ROULETTE_ERRTIME 500 +#define ROULETTE_STANDBY1 40 +#define ROULETTE_LOOPTIME 3000 + +BOOL NPC_Gamble_MasterInit( int meindex ) +{ + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + char buf1[256]; + + if( NPC_Util_GetArgStr( meindex, argstr, sizeof( argstr)) == NULL ) { + print("\n not found argstr "); + return FALSE; + } + + if( NPC_Util_GetStrFromStrWithDelim( argstr, "gamble_code",buf1, sizeof(buf1)) == NULL ) { + print("\n gamble_code error: not found !!"); + return FALSE; + } + CHAR_setWorkInt( meindex, NPC_WORK_GAMBLECODE, atoi( buf1)); + //Ϸ׶ + CHAR_setWorkInt( meindex, NPC_WORK_GAMEFLG, 0); + CHAR_setInt( meindex , CHAR_WHICHTYPE , CHAR_GAMBLEMASTER ); + // NPC_WORK_MODE ״̬ 0: ȴ 1:GAME START 2:GAME END + CHAR_setWorkInt( meindex, NPC_WORK_MODE, 0); + CHAR_setWorkInt( meindex, NPC_WORK_MASTERFLG, 30); + CHAR_setWorkInt( meindex, NPC_WORK_MASTERSTONE, 0); + CHAR_setWorkInt( meindex, NPC_WORK_NPCAI, 0); + //趨LOOP TIMER + CHAR_setInt( meindex, CHAR_LOOPINTERVAL, ROULETTE_LOOPTIME); + //¼ʱ + CHAR_setWorkInt( meindex, NPC_WORK_SYSTIME, NowTime.tv_sec); + return TRUE; +} + +void NPC_Gamble_MasterTalked( int meindex , int talkerindex , char *szMes , int color ) +{ + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + + if( CHAR_getInt( talkerindex , CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER ){ + return; + } + if(NPC_Util_isFaceToFace( meindex ,talkerindex , 2) == FALSE) { + if(NPC_Util_isFaceToChara( talkerindex, meindex, 1) == FALSE) return; + } + + if( NPC_Util_GetArgStr( meindex, argstr, sizeof( argstr)) == NULL ) { + print("\n not found argstr "); + return; + } + // 0 ѡ 11 - 19 21 - 29 + CHAR_setWorkInt(talkerindex , CHAR_WORKSHOPRELEVANT,0); + NPC_GambleRoulette_selectWindow( meindex, talkerindex, ROULETTE_START, -1 ); +} + +void NPC_GambleRoulette_selectWindow(int meindex,int toindex,int num,int select) +{ + char npcarg[NPC_UTIL_GETARGSTR_BUFSIZE]; + char buf1[256],buf2[256]; + char token[256]; + int buttontype = 0, windowtype = 0, windowno = 0; + int fd = getfdFromCharaIndex( toindex); + int pagenum=0, i; + windowtype = WINDOW_MESSAGETYPE_MESSAGE; + + if( NPC_Util_GetArgStr( meindex, npcarg, sizeof( npcarg)) == NULL ) { + print("\n not found npcarg "); + CHAR_setWorkInt( toindex, CHAR_WORKSHOPRELEVANT,0); + return; + } + switch( num) { + case ROULETTE_START: + i = 1; + strcpy( token, "\0"); + sprintf( buf2,"%s%d", "gamble_msg0", i); + while( NPC_Util_GetStrFromStrWithDelim( npcarg, buf2, buf1, sizeof( buf1) ) != NULL ) { + if( strstr( buf1, "NULL" ) == NULL ) { + strcat( token , buf1); + strcat( token, "\n"); + }else { + strcat( token, "\n"); + } + i++; + sprintf( buf2,"%s%d", "gamble_msg0", i); + } + windowtype=WINDOW_MESSAGETYPE_SELECT; + windowno = WINDOWTYPE_GAMBLEROULETTE_START; + break; + break; + case ROULETTE_SELECT: + //ҳ select + pagenum = CHAR_getWorkInt( toindex , CHAR_WORKSHOPRELEVANT); + strcpy( token, "\0"); + if( select >= 0 ) { + sprintf( buf2,"%s%2d", "page_num", select); + CHAR_setWorkInt( toindex , CHAR_WORKSHOPRELEVANT, select+1); + }else { + sprintf( buf2,"%s%2d", "page_num", pagenum ); + pagenum+=1; + CHAR_setWorkInt( toindex , CHAR_WORKSHOPRELEVANT, pagenum); + } + + if( NPC_Util_GetStrFromStrWithDelim( npcarg, buf2, token, sizeof( token) ) == NULL ) { + print("\n error: not found token:%s", token); + CHAR_setWorkInt( toindex , CHAR_WORKSHOPRELEVANT,0); + return; + } + + sprintf( buf2,"%s%2d", "page_num", CHAR_getWorkInt( toindex , CHAR_WORKSHOPRELEVANT)); + if( NPC_Util_GetStrFromStrWithDelim( npcarg, buf2, buf1, sizeof( buf1) ) == NULL ) { + windowno = WINDOWTYPE_GAMBLEROULETTE_END; + buttontype = WINDOW_BUTTONTYPE_OK; + }else { + windowno = WINDOWTYPE_GAMBLEROULETTE_SELECT; + buttontype = WINDOW_BUTTONTYPE_NEXT; + } + break; + case ROULETTE_LOOK: + { //ʾʱػ + int G_num = CHAR_getInt( toindex, CHAR_GAMBLENUM ); + + if( CHAR_getWorkInt( toindex, CHAR_WORKSTAKEFLAG) != FALSE) { + for( i=0; i<5; i++) { + if( CHAR_getWorkInt( toindex, i+CHAR_WORKSTAKETYPE1) > 0 ) + G_num++; + } + } + if( G_num < 0 ) G_num = 0; + sprintf( token,"ֳΪ%d", G_num ); + windowno = WINDOWTYPE_GAMBLEROULETTE_END; + buttontype = WINDOW_BUTTONTYPE_OK; + } + break; + case ROULETTE_END: + if( NPC_Util_GetStrFromStrWithDelim( npcarg, "page_endmsg", token, sizeof( token) ) == NULL ) { + print("\n error: not found end_msg"); + CHAR_setWorkInt( toindex , CHAR_WORKSHOPRELEVANT,0); + return; + } + + windowno = WINDOWTYPE_GAMBLEROULETTE_END; + buttontype = WINDOW_BUTTONTYPE_OK; + break; + } + + lssproto_WN_send( fd, windowtype, buttontype, windowno, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), token); +} + +void NPC_Gamble_MasterWindowTalked( int meindex, int talkerindex, int seqno, int select, char *data) +{ + int pagenum=0; + + if( CHAR_getInt( talkerindex , CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER ){ + return; + } + if(NPC_Util_isFaceToFace( meindex ,talkerindex , 2) == FALSE) { + if(NPC_Util_isFaceToChara( talkerindex, meindex, 1) == FALSE) return; + } + + switch( seqno ) { + case WINDOWTYPE_GAMBLEROULETTE_START: + pagenum = atoi( data); + if( pagenum == 4 ) { + NPC_GambleRoulette_selectWindow( meindex, talkerindex, ROULETTE_END, -1 ); + }else { + if( pagenum == 3 ) { //ROULETTE_LOOK + NPC_GambleRoulette_selectWindow( meindex, talkerindex, ROULETTE_LOOK, -1 ); + }else { + pagenum = (pagenum*10)+1; + NPC_GambleRoulette_selectWindow( meindex, talkerindex, ROULETTE_SELECT, pagenum ); + } + } + break; + case WINDOWTYPE_GAMBLEROULETTE_SELECT: + NPC_GambleRoulette_selectWindow( meindex, talkerindex, ROULETTE_SELECT, -1 ); + break; + case WINDOWTYPE_GAMBLEROULETTE_END: + CHAR_setWorkInt(talkerindex , CHAR_WORKSHOPRELEVANT, 0); + break; + } + return; +} + +void NPC_Gamble_MasterLoop( int meindex) +{ + int objmeindex = -1; + int full_time; + //int Master_Stone = 0; + int timeNum = 0; + //int time_run=0; + //int act; + objmeindex = CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX); + switch( CHAR_getWorkInt( meindex, NPC_WORK_MODE )) { + case 0: // ȴ + full_time = ROULETTE_STANDBY1; + timeNum = CHAR_getWorkInt( meindex, NPC_WORK_MASTERFLG ); + if( ( CHAR_getWorkInt( meindex, NPC_WORK_SYSTIME) + full_time) < NowTime.tv_sec ) { + if( timeNum == 30 ) { //20 + //0 null 1 ׼ 2 3 ͣ + CHAR_setWorkInt( meindex, NPC_WORK_GAMEFLG, 1); + showString( meindex, "עʱʣ£롣", 0); + }else if( timeNum == 10 ) { + showString( meindex, "standby_msg", 0); //㲥 + SetCasinoMap( meindex, 0, 0); //趨ͼע + }else if( timeNum <= 6 ) { //ʼ + //0 null 1 ׼ 2 3 ͣ + CHAR_setWorkInt( meindex, NPC_WORK_GAMEFLG, 2); + CHAR_setWorkInt( meindex, NPC_WORK_MODE, 1); + showString( meindex, "start_msg", 0); //㲥 + } + CHAR_setWorkInt( meindex, NPC_WORK_MASTERFLG, timeNum - 2 ); + } + break; + case 1: // GAME START + if( CHAR_getWorkInt( meindex, NPC_WORK_GAMEFLG) == 3 ) { + CHAR_setWorkInt( meindex, NPC_WORK_MODE, 2); + } + break; + case 2: // GAME END + CHAR_setWorkInt( meindex, NPC_WORK_MODE, 3); + defPlayerGold( meindex , TRUE); //Ӯ + CHAR_setWorkInt( meindex, NPC_WORK_ENDPOINT, 0); + NPC_MAPCLEANGOLD( meindex , CHAR_getInt( meindex, CHAR_FLOOR )); + + LogGamble( + CHAR_getChar( meindex, CHAR_NAME ), "master", + "ROULETTE", CHAR_getInt( meindex, CHAR_FLOOR), + CHAR_getInt( meindex, CHAR_X ), + CHAR_getInt( meindex, CHAR_Y ) , + CHAR_getWorkInt( meindex, NPC_WORK_MASTERSTONE), 0, 0, 0, 2 + ); + break; + case 3: + CHAR_setWorkInt( meindex, NPC_WORK_MODE, 0); + CHAR_setWorkInt( meindex, NPC_WORK_GAMEFLG, 0); + showString( meindex, "end_msg", 0); //㲥 + SetCasinoMap( meindex, 0, 1); //趨ͼע + CHAR_setWorkInt( meindex, NPC_WORK_MASTERFLG, 30 ); + CHAR_setWorkInt( meindex, NPC_WORK_SYSTIME, NowTime.tv_sec); + break; + default: + NPC_GAMBLEMASTER_RESET( meindex); + break; + } +} + +void defPlayerGold( int meindex , int flg) +{ + int X,Y; + int endpoint; + int End_type = 0; + int toindex=0, i, master_floor; + int player_type; + int gamble_num; + //float def; + char token[256], buff[256]; + char buf1[56],buf2[56]; + BOOL GAMBLE_YES = FALSE; + endpoint = CHAR_getWorkInt( meindex, NPC_WORK_ENDPOINT); + + X = (endpoint >> 16 ); + Y = (endpoint & 0xffff); + + for( End_type = 0; End_type < arraysizeof(EndTypedef) ; End_type++ ) { + if( (X == EndTypedef[ End_type].m_fx) && (Y == EndTypedef[ End_type].m_fy )) { + break; + } + } + + if( End_type == arraysizeof(EndTypedef) ) { + print("\n\n **********GAMBLE MASTER ERROR !! **************"); + print("\n NOT FOUND : X=%d Y=%d EndTypedef[I] !!", X, Y); + return; + } +/*Log===================================== + { //¼ + FILE *fp; + int kp=0,pn=0;; + fp = fopen("./data/npc/roulette/lookgamble.txt","w+"); + if( fp != NULL ) { + if( EndTypedef[ End_type].m_nums < 10000 ) + EndTypedef[ End_type].m_nums = EndTypedef[ End_type].m_nums+1; + for( kp=0; kp 0 && EndTypedef[ kp].m_type > 0 ) { + fprintf( fp," %s н [%d] ", EndTypedef[ kp].str_type, EndTypedef[ kp].m_nums ); + if( (pn+1)%2 == 0 ) { + fprintf( fp," \n"); + } + pn ++; + } + } + fclose( fp); + } + } +//========================================*/ + + if( EndTypedef[ End_type].m_type <= 0 ) { + showString( meindex, "أͨɱ", 0); + }else { + sprintf( token ,"н %s ", EndTypedef[End_type].str_type ); + showString( meindex, token, 0 ); + } + if( EndTypedef[ End_type].m_EO == roulette43 ) { + sprintf( buf1,""); + }else { + sprintf( buf1,"˫"); + } + if( EndTypedef[ End_type].m_RG == roulette41 ) { + sprintf( buf2,""); + }else { + sprintf( buf2,""); + } + //ڳ + toindex = -1; + master_floor = CHAR_getInt( meindex , CHAR_FLOOR); + while( toindex < 10000 ) { + toindex++; + if( !CHAR_CHECKINDEX( toindex) ) + continue; + if( CHAR_getInt( toindex , CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER ) + continue; + if( master_floor != CHAR_getInt( toindex, CHAR_FLOOR ) ) //Ƿڶij + continue; + if( CHAR_getWorkInt( toindex, CHAR_WORKSTAKEFLAG) == FALSE ) //Ƿע + continue; + //Ƿ + GAMBLE_YES = FALSE; + CHAR_setWorkInt( toindex, CHAR_WORKSTAKEFLAG, FALSE); + for( i=0; i<5; i++) { + player_type = CHAR_getWorkInt( toindex, i+CHAR_WORKSTAKETYPE1); + gamble_num = 0; + if( player_type > 0 ) { + if( player_type == EndTypedef[End_type].m_type ) { //˺ + if( EndTypedef[End_type].m_type == roulette45 ) { + gamble_num += 40; + }else { + gamble_num += 20; + } + GAMBLE_YES = TRUE; + //Ǯ + Codef_Gold( meindex, toindex, gamble_num, 0, EndTypedef[End_type].str_type ); + }else if( player_type == EndTypedef[End_type].m_RG ) { //˺ + gamble_num += 1; + GAMBLE_YES = TRUE; + Codef_Gold( meindex, toindex, gamble_num, 0, buf2 ); + }else if( player_type == EndTypedef[End_type].m_EO ) { //˵˫ + gamble_num += 1; + GAMBLE_YES = TRUE; + Codef_Gold( meindex, toindex, gamble_num, 0, buf1 ); + }else if( player_type == EndTypedef[End_type].m_SI ) { // + gamble_num += 2; + GAMBLE_YES = TRUE; + sprintf( token,"%s%d", "", EndTypedef[End_type].m_SI-100 ); + Codef_Gold( meindex, toindex, gamble_num, 0, token ); + }else if( player_type == EndTypedef[End_type].m_IN ) { //1-10 11-20 + gamble_num += 1; + GAMBLE_YES = TRUE; + if( (EndTypedef[End_type].m_IN - 100 ) == 11 ) { + snprintf( buff, sizeof( buff),""); + }else if( (EndTypedef[End_type].m_IN - 100 ) == 12 ) { + snprintf( buff, sizeof( buff),""); + } + sprintf( token,"%s%s", "Χ", buff ); + Codef_Gold( meindex, toindex, gamble_num, 0, token ); + }else { //û ۻ + if( (player_type>>16) == EndTypedef[End_type].m_type || + (player_type&0xffff) == EndTypedef[End_type].m_type + ) { //˫ + gamble_num += 10; + GAMBLE_YES = TRUE; + sprintf( token,"%s%s", "˫ţ", EndTypedef[End_type].str_type ); + Codef_Gold( meindex, toindex, gamble_num, 0, token ); + }else if( player_type > 0 ) { //72 73 74 75 û ۻ + strcpy( token, "\0"); + if( player_type >= roulette41 && player_type <= roulette44 ) { //̵˫ + sprintf( token,"%s", "Ѻע ̵˫ û"); + }else if( player_type == roulette45 ) { //00 + sprintf( token,"%s", "Ѻע 00 û"); + }else if( player_type >= roulette51 && player_type <= roulette53 ) { // + sprintf( token,"%s", "Ѻע û"); + }else if( player_type >= roulette61 && player_type <= roulette62 ) { //Χ + sprintf( token,"%s", "Ѻע Χ û"); + }else if( player_type > (1<<16) ) { //˫ + sprintf( token,"%s", "Ѻע ˫ û"); + }else { // + sprintf( token,"%s", "Ѻע û"); + } + gamble_num -= 1; + Codef_Gold( meindex, toindex, gamble_num, 1, token ); + } + } + } + // + CHAR_setWorkInt( toindex, i+CHAR_WORKSTAKETYPE1, 0); + } + if( CHAR_getInt( toindex, CHAR_GAMBLENUM) < 0 ) { + CHAR_setInt( toindex, CHAR_GAMBLENUM, 0 ); + }else if( CHAR_getInt( toindex, CHAR_GAMBLENUM) > 10000 ) { + CHAR_setInt( toindex, CHAR_GAMBLENUM, 10000 ); + } + sprintf( token, "ֳۼΪ%d֡", CHAR_getInt( toindex, CHAR_GAMBLENUM)); + CHAR_talkToCli( toindex, meindex, token, CHAR_COLORYELLOW); + + if( GAMBLE_YES == FALSE ) { + sprintf( token, "Ѻעûн"); + CHAR_talkToCli( toindex, meindex, token, CHAR_COLORYELLOW); + continue; + } + + } + return; +} + +void Codef_Gold( int meindex, int toindex, int stone,int flg, char *token) +{ + char buf1[256]; + int dnum=-1; + int Master_gnum=0; + Master_gnum = CHAR_getWorkInt( meindex, NPC_WORK_MASTERSTONE); + Master_gnum += stone; + if( !flg ) { + sprintf( buf1,"ϲˣ%sõ %d ", token, stone); + CHAR_talkToCli( toindex, meindex, buf1, CHAR_COLORYELLOW); +#ifdef _FIX_GAMBLENUM + stone += 1; //һʼע۵Ļ +#endif + CHAR_setInt( toindex, CHAR_GAMBLENUM, CHAR_getInt( toindex, CHAR_GAMBLENUM) + stone); + + }else { + dnum = stone; + if( stone < 0 ) { + dnum = (dnum*(-1)); + } + + sprintf( buf1,"%s %d ", token, dnum); + CHAR_talkToCli( toindex, meindex, buf1, CHAR_COLORYELLOW); +#ifdef _FIX_GAMBLENUM +#else + CHAR_setInt( toindex, CHAR_GAMBLENUM, CHAR_getInt( toindex, CHAR_GAMBLENUM) + stone); +#endif + } + + LogGamble( + CHAR_getChar( toindex, CHAR_NAME ), + CHAR_getChar( toindex, CHAR_CDKEY ), + "ROULETTE", + CHAR_getInt( toindex, CHAR_FLOOR), + CHAR_getInt( toindex, CHAR_X ), + CHAR_getInt( toindex, CHAR_Y ), + CHAR_getInt( toindex, CHAR_GOLD), + stone, + 0, + CHAR_getInt( toindex, CHAR_GAMBLENUM ), + 1 + ); + + //¼ӯ + if( Master_gnum > 5000000 ) Master_gnum = 5000000; + if( Master_gnum < 0 ) Master_gnum = 0; + CHAR_setWorkInt( meindex, NPC_WORK_MASTERSTONE, Master_gnum); + return; +} +// +void NPC_GAMBLEMASTER_RESET( int meindex) +{ + // + print("\n "); + CHAR_setWorkInt( meindex, NPC_WORK_GAMEFLG, 0);//0 null 1 ׼ 2 + CHAR_setWorkInt( meindex, NPC_WORK_MODE, 0); + showString( meindex, "غϲ㣡ȣ¿ʼ", 1); + NPC_MAPCLEANGOLD( meindex , CHAR_getInt( meindex, CHAR_FLOOR )); + //defPlayerGold( meindex , FALSE); + CHAR_setWorkInt( meindex, NPC_WORK_SYSTIME, NowTime.tv_sec + ROULETTE_ERRTIME); +} + +#endif + + + diff --git a/npc/npc_gambleroulette.c b/npc/npc_gambleroulette.c new file mode 100644 index 0000000..67c732e --- /dev/null +++ b/npc/npc_gambleroulette.c @@ -0,0 +1,474 @@ +#include "version.h" +#include +#include "char.h" +#include "object.h" +#include "char_base.h" +#include "npcutil.h" +#include "readmap.h" +#include "lssproto_serv.h" +#include "handletime.h" + +#ifdef _GAMBLE_ROULETTE +#include "npc_gambleroulette.h" + +#define _OTHER_ROUND //һܷ + +static void Gamble_Roulette_walk( int meindex); +static int Gamble_RouletteSetPoint( int meindex ); +static void Find_Master( int meindex); +int RunRand( int meindex, int flg ); +BOOL SetEndPoint( int meindex ); +void Gamble_Roulette_Reset( int meindex, int flg); +void ResetDataStart( int meindex); +BOOL ReadPointData( int meindex ); +enum { + NPC_WORK_ROUTETOX = CHAR_NPCWORKINT1, + NPC_WORK_ROUTETOY = CHAR_NPCWORKINT2, + NPC_WORK_ROUTEPOINT = CHAR_NPCWORKINT3, + NPC_WORK_ROUNDTRIP = CHAR_NPCWORKINT4, + NPC_WORK_MODE = CHAR_NPCWORKINT5, + NPC_WORK_CURRENTROUTE = CHAR_NPCWORKINT6, + NPC_WORK_ROUTEMAX = CHAR_NPCWORKINT7, + NPC_WORK_WAITTIME = CHAR_NPCWORKINT8, + NPC_WORK_CURRENTTIME = CHAR_NPCWORKINT9, + NPC_WORK_SEFLG = CHAR_NPCWORKINT10, //¼index +}; + +typedef struct tagRoulettePoint { + int x; + int y; + int flg; +}RoulettePoint; +RoulettePoint PointData[]={ + {-1,-1,-1},{-1,-1,-1},{-1,-1,-1},{-1,-1,-1}, +}; + +RoulettePoint TestPointData[4*8]; + +#define ROULETTE_STANDBY 1500 +#define ROULETTE_LOOPTIME 1000 + +#define ROULETTE_RUNTIME1 50 + +BOOL NPC_Gamble_RouletteInit( int meindex ) +{ + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + + NPC_Util_GetArgStr( meindex, argstr, sizeof( argstr)); + + CHAR_setInt( meindex , CHAR_WHICHTYPE , CHAR_GAMBLEROULETTE ); + //CHAR_setWorkInt( meindex, NPC_WORK_ROUTEMAX, routenum); + //СҪ߼ͣ + CHAR_setWorkInt( meindex, NPC_WORK_ROUTEMAX, 0); + CHAR_setWorkInt( meindex, NPC_WORK_SEFLG, -1); + // NPC_WORK_MODE С״̬ 0:ȴ 1:(˳) + CHAR_setWorkInt( meindex, NPC_WORK_MODE, 0); + //ڼͼ + CHAR_setWorkInt( meindex, NPC_WORK_ROUTEPOINT, 0); + //˳ 1 0 + CHAR_setWorkInt( meindex, NPC_WORK_ROUNDTRIP, 1); + //ڼ· + CHAR_setWorkInt( meindex, NPC_WORK_CURRENTROUTE, 0); + //趨LOOP TIMER + CHAR_setInt( meindex, CHAR_LOOPINTERVAL, ROULETTE_STANDBY); + //¼ʱ + CHAR_setWorkInt( meindex, NPC_WORK_CURRENTTIME, NowTime.tv_sec); + CHAR_sendCToArroundCharacter( CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX)); + if( ReadPointData( meindex) == FALSE ) + return FALSE; + return TRUE; +} + +void NPC_Gamble_RouletteTalked( int meindex , int talkerindex , char *szMes , int color ) +{ + return; +} + +void NPC_Gamble_RouletteWindowTalked( int meindex, int talkerindex, int seqno, int select, char *data) +{ + return; +} + +void NPC_Gamble_RouletteLoop( int meindex) +{ + int objmeindex = -1, index = 0, act = 0; + objmeindex = CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX); + switch( CHAR_getWorkInt( meindex, NPC_WORK_MODE )) { + case 0: //ֹͣʱȴ Ϊȴ + + //ץindex Ƿ񺰿ʼ + if( CHAR_getWorkInt( meindex, NPC_WORK_SEFLG) < 0 ) { + CHAR_setWorkInt( meindex, NPC_WORK_MODE,5); + }else { + index = CHAR_getWorkInt( meindex, NPC_WORK_SEFLG); + //CHAR_NPCWORKINT7 0 null 1 ׼ 2 3 ͣ + if( CHAR_getWorkInt( index, CHAR_NPCWORKINT7 ) == 2 ) { + CHAR_sendCToArroundCharacter( objmeindex); + CHAR_setWorkInt( meindex, NPC_WORK_MODE,1); + CHAR_setInt( meindex, CHAR_LOOPINTERVAL, ROULETTE_RUNTIME1); + //С߼ + CHAR_setWorkInt( meindex, NPC_WORK_ROUTEMAX, RunRand( meindex, 0 ) ); + ResetDataStart( meindex);// + if( CHAR_getInt( meindex, CHAR_X) == 14 && + CHAR_getInt( meindex, CHAR_Y) == 8 ) { + }else { + print("\n\n####################\n Сԭ!![%d,%d]", + CHAR_getInt( meindex, CHAR_X), + CHAR_getInt( meindex, CHAR_Y) + ); + + } + }else if( CHAR_getWorkInt( index, CHAR_NPCWORKINT7 ) == 1 || + ( CHAR_getWorkInt( index, CHAR_NPCWORKINT9) < 30 && + CHAR_getWorkInt( index, CHAR_NPCWORKINT9) > 24 ) + ) { //׼ + if( CHAR_getInt( meindex, CHAR_X) == 14 && CHAR_getInt( meindex, CHAR_Y) == 8 ) { + }else { + CHAR_warpToSpecificPoint( meindex, CHAR_getInt( meindex, CHAR_FLOOR), + 14, 8); + CHAR_setInt( meindex, CHAR_X, 14); + CHAR_setInt( meindex, CHAR_Y, 8); + CHAR_sendCToArroundCharacter( objmeindex); + } + } + } + break; + case 1: + Gamble_Roulette_walk( meindex); + break; + case 2: + break; + case 3: + // + CHAR_setWorkInt( meindex, NPC_WORK_MODE, 0); + // + act = CHAR_ACTATTACK; + CHAR_sendWatchEvent( objmeindex, act, NULL,0, FALSE); + CHAR_setWorkInt( meindex, CHAR_WORKACTION, act); + CHAR_setWorkInt( meindex, NPC_WORK_ROUTEMAX, 0); + CHAR_setInt( meindex, CHAR_LOOPINTERVAL, ROULETTE_STANDBY); + + //ϸӾΧڵ + CHAR_sendCToArroundCharacter( objmeindex); + if( SetEndPoint( meindex ) == FALSE ) { + print("\n not Set EndPoint !!"); + } +#ifdef _OTHER_ROUND +#else + ReadPointData( meindex); //load round data +#endif + //ԭ + index = CHAR_getWorkInt( meindex, NPC_WORK_SEFLG); + CHAR_setWorkInt( index, CHAR_NPCWORKINT7, 3); + break; + case 5: //Ѱ + Find_Master( meindex); + if( CHAR_getWorkInt( meindex, NPC_WORK_SEFLG) < 0 ) { + CHAR_setInt( meindex, CHAR_LOOPINTERVAL, 0); + CHAR_setWorkInt( meindex, NPC_WORK_MODE,-1); + }else { + CHAR_setWorkInt( meindex, NPC_WORK_MODE, 0); + } + break; + default: + // + Gamble_Roulette_Reset( meindex, 0); + break; + } +} + +static void Gamble_Roulette_walk( int meindex) +{ + POINT start, end; + int dir; + int ret; + int i,run_num = 0; + int objmeindex = -1; + objmeindex = CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX); + + start.x = CHAR_getInt( meindex, CHAR_X); + start.y = CHAR_getInt( meindex, CHAR_Y); + end.x = CHAR_getWorkInt( meindex, NPC_WORK_ROUTETOX); + end.y = CHAR_getWorkInt( meindex, NPC_WORK_ROUTETOY); + // loop timerΪ 1. һ 2. ߵһ + + if( start.x == end.x && start.y == end.y ) { +#ifdef _OTHER_ROUND +#else + int add = 1; + //Ϊ NPC_WORK_ROUNDTRIP != 1 + if( CHAR_getWorkInt( meindex, NPC_WORK_ROUNDTRIP ) != 1 ) { + add *= -1; + } + CHAR_setWorkInt( meindex, NPC_WORK_ROUTEPOINT, + CHAR_getWorkInt( meindex, NPC_WORK_ROUTEPOINT) +add); +#endif + if( Gamble_RouletteSetPoint( meindex ) == FALSE ) { +#ifdef _OTHER_ROUND + CHAR_setWorkInt( meindex, NPC_WORK_MODE,3); + CHAR_setWorkInt( meindex, NPC_WORK_CURRENTTIME, NowTime.tv_sec); + return; +#else + if( CHAR_getWorkInt( meindex, NPC_WORK_ROUNDTRIP ) != 1 ) { + CHAR_setWorkInt( meindex, NPC_WORK_ROUTEPOINT, arraysizeof( PointData) ); // + }else { + CHAR_setWorkInt( meindex, NPC_WORK_ROUTEPOINT, -1); //˳ + } + return; +#endif + }else { + return; + } + } +//-------------------------------------------------------------------- + run_num = CHAR_getWorkInt( meindex, NPC_WORK_ROUTEMAX); + if( run_num > 0 ){ + CHAR_setWorkInt( meindex, NPC_WORK_ROUTEMAX, (run_num - 1) ); + }else { +#ifdef _OTHER_ROUND + CHAR_setWorkInt( meindex, NPC_WORK_MODE,3); + CHAR_setWorkInt( meindex, NPC_WORK_CURRENTTIME, NowTime.tv_sec); + return; +#else + int npc_ai=0; + int masterindex; + masterindex = CHAR_getWorkInt( meindex, NPC_WORK_SEFLG); + npc_ai = CHAR_getWorkInt( masterindex, CHAR_NPCWORKINT3); + if( npc_ai > 10 ) { + if( start.x == 7 && start.y == 5 ) { // 7,5 + CHAR_setWorkInt( masterindex, CHAR_NPCWORKINT3, 0); + }else { + CHAR_setWorkInt( meindex, NPC_WORK_ROUTEMAX, 1); + return; + } + } + CHAR_setWorkInt( meindex, NPC_WORK_MODE,3); + CHAR_setWorkInt( meindex, NPC_WORK_CURRENTTIME, NowTime.tv_sec); + return; +#endif + } +//-------------------------------------------------------------------- + dir = NPC_Util_getDirFromTwoPoint( &start,&end ); + for( i = 0; i < 100; i ++ ) { + if( dir < 0 ) { + dir = RAND( 0,7); + } + dir = NPC_Util_SuberiWalk( meindex, dir); + if( dir >= 0 && dir <= 7) break; + } + if( dir >= 0 && dir <= 7 ) { + ret = CHAR_walk( meindex, dir, 0); + } +} + +static void Find_Master( int meindex) +{ + int floor, x=14, y=3; + OBJECT object; + floor = CHAR_getInt( meindex , CHAR_FLOOR); + for( object = MAP_getTopObj( floor, x, y) ; object ; object = NEXT_OBJECT(object ) ){ + int findex; + int objindex = GET_OBJINDEX(object); + if( !CHECKOBJECTUSE( objindex)) continue; + findex = OBJECT_getIndex( objindex); + if( !CHAR_CHECKINDEX( findex)) continue; + if( CHAR_getInt( findex , CHAR_WHICHTYPE ) != CHAR_GAMBLEMASTER ) continue; + if( CHAR_getWorkInt( findex, CHAR_NPCWORKINT8) != 10001 ) continue; + CHAR_setWorkInt( meindex, NPC_WORK_SEFLG, findex) ; + return; + } +} + +int RunRand( int meindex, int flg ) +{ +#define RAND(x,y) ((x-1)+1+ (int)( (double)(y-(x-1))*rand()/(RAND_MAX+1.0)) ) + int run_num1=0; + int i; + + run_num1 = RAND( 90, 150); + for( i=0; i<6; i++ ) { + run_num1 += RAND( 0, 20); + } + return run_num1; +} + +BOOL SetEndPoint( int meindex ) +{ + int x,y; + int master; + int endpoint; + + master = CHAR_getWorkInt( meindex, NPC_WORK_SEFLG); + if( !CHAR_CHECKINDEX( master) ) + return FALSE; + + if( CHAR_getWorkInt( master, CHAR_NPCWORKINT7) != 2 ) { + print("\n error( master,CHAR_NPCWORKINT7) != 2 "); + return FALSE; + } + + x = CHAR_getInt( meindex, CHAR_X); + y = CHAR_getInt( meindex, CHAR_Y); + endpoint = (x<<16)+(y<<0); + CHAR_setWorkInt( master, CHAR_NPCWORKINT10, endpoint); + return TRUE; +} + +void Gamble_Roulette_Reset( int meindex, int flg) +{ + // + int index; + CHAR_setWorkInt( meindex, NPC_WORK_ROUTEMAX, 0); + CHAR_setWorkInt( meindex, NPC_WORK_MODE, 0); + CHAR_setInt( meindex, CHAR_LOOPINTERVAL, ROULETTE_STANDBY); + + index = CHAR_getWorkInt( meindex, NPC_WORK_SEFLG); + if( !CHAR_CHECKINDEX( index) ) { + print("\n Gamble_Roulette error: no master !!"); + return; + } + CHAR_setWorkInt( index, CHAR_NPCWORKINT7, 3); + CHAR_setWorkInt( index, CHAR_NPCWORKINT10, 0); +} + +void ResetDataStart( int meindex ) +{ +#define RAND(x,y) ((x-1)+1+ (int)( (double)(y-(x-1))*rand()/(RAND_MAX+1.0)) ) + int Start=1; + struct tagWalkStartPoint{ + int x; + int y; + int rip; + }WalkStart[]={ + {7,5,1}, {7,11,0}, {22,11,1}, {22,5,0}, + }; + Start = RAND( 0, 3); + + CHAR_setWorkInt( meindex, NPC_WORK_ROUNDTRIP, WalkStart[Start].rip ); + CHAR_setWorkInt( meindex, NPC_WORK_ROUTEPOINT, Start); + CHAR_setWorkInt( meindex, NPC_WORK_ROUTETOX, WalkStart[Start].x ); + CHAR_setWorkInt( meindex, NPC_WORK_ROUTETOY, WalkStart[Start].y ); + + { + int i=0,k; + int RIP = CHAR_getWorkInt( meindex, NPC_WORK_ROUNDTRIP); + k = CHAR_getWorkInt( meindex, NPC_WORK_ROUTEPOINT); + if( RIP ) { + while( i < (arraysizeof( TestPointData))) { + k++; + if( k > 3 ) k = 0; + TestPointData[i].x = PointData[k].x; + TestPointData[i].y = PointData[k].y; + i++; + } + }else { + while( i < (arraysizeof( TestPointData))) { + k--; + if( k < 0 ) k = 3; + TestPointData[i].x = PointData[k].x; + TestPointData[i].y = PointData[k].y; + i++; + } + } + } +#ifdef _OTHER_ROUND + CHAR_setWorkInt( meindex, NPC_WORK_ROUTEPOINT, 0); +#endif +} + +BOOL ReadPointData( int meindex ) +{ + + char buf1[256], buf2[32], buf3[16]; + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + int k=1,i=0; + NPC_Util_GetArgStr( meindex, argstr, sizeof( argstr)); + + if( NPC_Util_GetStrFromStrWithDelim( argstr, "roulette",buf1, sizeof(buf1)) == NULL ) { + print("\n roulette error: not found !!"); + return FALSE; + } + k=1; + while( getStringFromIndexWithDelim( buf1, ";", k, buf2, sizeof(buf2) ) != FALSE ) { + k++; + if( strstr( buf2,",") == NULL ) + continue; + + if( getStringFromIndexWithDelim( buf2, ",", 1, buf3, sizeof(buf3)) == FALSE) { + return FALSE; + } + PointData[i].x = atoi( buf3); + if( getStringFromIndexWithDelim( buf2, ",", 2, buf3, sizeof(buf3)) == FALSE) { + return FALSE; + } + PointData[i].y = atoi( buf3); + if( i > 9 ) { + break; + } + i++; + } +#ifdef _OTHER_ROUND +#else + Gamble_RouletteSetPoint( meindex); +#endif + return TRUE;//arraysizeof( PointData) +} + +static int Gamble_RouletteSetPoint( int meindex ) +{ +#ifdef _OTHER_ROUND + int i; + i = CHAR_getWorkInt( meindex, NPC_WORK_ROUTEPOINT); + CHAR_setWorkInt( meindex, NPC_WORK_ROUTETOX, TestPointData[i].x ); + CHAR_setWorkInt( meindex, NPC_WORK_ROUTETOY, TestPointData[i].y ); + i++; + CHAR_setWorkInt( meindex, NPC_WORK_ROUTEPOINT, i); + if( i >= arraysizeof( TestPointData) ) { + return FALSE; + } +#else + int i; + i = CHAR_getWorkInt( meindex, NPC_WORK_ROUTEPOINT); + if( i<0 || i>arraysizeof( PointData) -1) { + return FALSE; + } + CHAR_setWorkInt( meindex, NPC_WORK_ROUTETOX, PointData[i].x ); + CHAR_setWorkInt( meindex, NPC_WORK_ROUTETOY, PointData[i].y ); +#endif + {//· + struct tagWalkStartPoint{ + int x; + int y; + }WalkStart[]={ + {22,5}, {7,5}, {7,11}, {22,11}, {22,5}, {7,5} + }; + int ch_x,ch_y; + int next_x,next_y; + int h; + ch_x = CHAR_getInt( meindex, CHAR_X); + ch_y = CHAR_getInt( meindex, CHAR_Y); + for( h=1; h<5; h++) { + if( ch_x == WalkStart[h].x && + ch_y == WalkStart[h].y) { + next_x = CHAR_getWorkInt( meindex, NPC_WORK_ROUTETOX); + next_y = CHAR_getWorkInt( meindex, NPC_WORK_ROUTETOY); + if( next_x == WalkStart[h+1].x && + next_y == WalkStart[h+1].y) { + + }else if( next_x == WalkStart[h-1].x && + next_y == WalkStart[h-1].y) { + }else { + print("\n ##############################"); + print("\n ERR : [%d,%d] -> [%d,%d]",ch_x,ch_y,next_x,next_y); + } + break; + } + } + } + return TRUE; +} + +#endif + + + diff --git a/npc/npc_healer.c b/npc/npc_healer.c new file mode 100644 index 0000000..07c441f --- /dev/null +++ b/npc/npc_healer.c @@ -0,0 +1,181 @@ +#include "version.h" +#include +#include +#include + +#include "object.h" +#include "char_base.h" +#include "char.h" +#include "util.h" +#include "npcutil.h" +#include "item.h" +#include "readmap.h" + + +#define RANGE 2 +void NPC_HealerSpeak( int index, int talker); +void NPC_HealerAllHeal( int talker ); +BOOL NPC_MoneyCheck(int meindex,int talker); +int NPC_CostCheck(int talker); +void NPC_CharCheckPoint(int meindex,int talker); +int NPC_WorkInput(int meindex,int talker); + + +/********************************** + +************************************/ +BOOL NPC_HealerInit( int meindex ) +{ + //ëס¡ɬ + CHAR_setInt( meindex , CHAR_WHICHTYPE , CHAR_TYPEHEALER ); + // ƥئ ۢئо + CHAR_setFlg( meindex , CHAR_ISATTACKED , 0 ); + //ľئ +// CHAR_setFlg( meindex , CHAR_ISOVERED , 0 ); + + return TRUE; + +} + + + + +/*------------------------------------------- + * + * ľHP,MPë巰 + * + --------------------------------------------*/ +void NPC_HealerTalked( int meindex , int talker , char *msg ,int color ) +{ + + char* npcarg; + char token[32]; + int msgNo; + + + npcarg = CHAR_getChar(meindex,CHAR_NPCARGUMENT); + + getStringFromIndexWithDelim( npcarg, "|", 1, token,sizeof( token)); + msgNo = atoi( token ); + + /*---帲ƻ ɱ---*/ + if( CHAR_getInt( talker , CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER ) return; + + /*--- 1׷ƥ¾---*/ + /* */ + if( NPC_Util_CharDistance( talker, meindex ) > 2) return; + + if( (CHAR_getWorkInt( talker, CHAR_WORKPARTYMODE) == 0) + || (CHAR_getWorkInt( talker, CHAR_WORKPARTYMODE) == 2) ) + { + /*--ƽﵤ--*/ + NPC_HealerAllHeal( talker); + if(msgNo == 1) { + CHAR_talkToCli( talker, meindex, + "Ѿȫظ´εıмࡣ",CHAR_COLORWHITE); + + }else if(msgNo == 2) { + CHAR_talkToCli( talker, meindex, + "ܳʵҰظɣ",CHAR_COLORWHITE); + } + + }else{ + int i = 0; + int otherindex; + + for( i=0 ; i < CHAR_PARTYMAX ; i++) + { + otherindex = CHAR_getWorkInt( talker, CHAR_WORKPARTYINDEX1 + i); + if(otherindex != -1){ + + NPC_HealerAllHeal( otherindex); + if(msgNo == 1) { + CHAR_talkToCli( otherindex, meindex, + "Ѿȫظ´εıмࡣ",CHAR_COLORWHITE); + + }else if(msgNo == 2) { + CHAR_talkToCli( otherindex, meindex, + "ܳʵҰظɣ",CHAR_COLORWHITE); + } + } + } + } +} + + +/*----------------------*/ +/* */ +/*-----------------------*/ +void NPC_HealerAllHeal( int talker ) +{ + int i; + int petindex; + char petsend[3]; + char msgbuf[5]; + + CHAR_setInt( talker , CHAR_HP ,CHAR_getWorkInt( talker, CHAR_WORKMAXHP ) ); + CHAR_setInt( talker , CHAR_MP ,CHAR_getWorkInt( talker, CHAR_WORKMAXMP ) ); + + + + for(i = 0 ; i < CHAR_MAXPETHAVE; i ++) { + petindex = CHAR_getCharPet( talker, i); + + if( petindex == -1 ) continue; + + /* ƽҷ¼ */ + if( !CHAR_CHECKINDEX( talker ) ) continue; + + /* ʸindexë */ + if( CHAR_CHECKINDEX( petindex) == FALSE ) continue; + + /*----*/ + CHAR_setFlg( petindex, CHAR_ISDIE, 0); + CHAR_setInt( petindex , CHAR_HP ,CHAR_getWorkInt( petindex, CHAR_WORKMAXHP ) ); + CHAR_setInt( petindex , CHAR_MP ,CHAR_getWorkInt( petindex, CHAR_WORKMAXMP ) ); + + /*--ɷ¶Ʃ--*/ + CHAR_complianceParameter( petindex ); + sprintf( petsend, "K%d", i ); + CHAR_sendStatusString( talker , petsend ); + } + + /*---޻ľޱ˪--*/ + if(CHAR_getWorkInt( talker, CHAR_WORKPARTYMODE) != CHAR_PARTY_NONE ) + { + int topartyarray = -1; + int oyaindex = CHAR_getWorkInt( talker , CHAR_WORKPARTYINDEX1); + + if( CHAR_CHECKINDEX( oyaindex )) { + int i; + + /* ֧޼ ë */ + for( i = 0; i < CHAR_PARTYMAX; i ++ ) { + int workindex = CHAR_getWorkInt( oyaindex, CHAR_WORKPARTYINDEX1 + i); + if( CHAR_CHECKINDEX( workindex) ) { + if( workindex == talker ) { + topartyarray = i; + break; + } + } + } + + for( i = 0; i < CHAR_PARTYMAX; i ++ ) { + int otherindex = CHAR_getPartyIndex( talker, i); + /* ɷ¶ë˪ */ + if( CHAR_CHECKINDEX( otherindex) ) { + snprintf( msgbuf, sizeof( msgbuf), "N%d", topartyarray); + if( otherindex != talker) { + CHAR_sendStatusString( otherindex, msgbuf); + } + } + } + } + } + + /*--ɷ¶˪Ի--*/ + CHAR_send_P_StatusString( talker, CHAR_P_STRING_HP); + CHAR_send_P_StatusString( talker, CHAR_P_STRING_MP); + +} + diff --git a/npc/npc_itemchange.c b/npc/npc_itemchange.c new file mode 100644 index 0000000..ad498e4 --- /dev/null +++ b/npc/npc_itemchange.c @@ -0,0 +1,259 @@ +#include "version.h" +#include +#include "char.h" +#include "object.h" +#include "char_base.h" +#include "npcutil.h" +#include "lssproto_serv.h" +#include "saacproto_cli.h" +#include "readmap.h" +#include "battle.h" +#include "log.h" +#include "enemy.h" +#include "handletime.h" +#include "npc_eventaction.h" +#include "npc_itemchange.h" + +#ifdef _ITEM_NPCCHANGE +enum { + ITEMCHANGE_START=1, + ITEMCHANGE_SELECT, + ITEMCHANGE_MESSAGE, + ITEMCHANGE_END, + ITEMCHANGE_ERROR, + +}; +enum { + NPC_WORK_CURRENTTIME = CHAR_NPCWORKINT1, +/* + NPC_WORK_ROUTETOY = CHAR_NPCWORKINT2, + NPC_WORK_ROUTEPOINT = CHAR_NPCWORKINT3, + NPC_WORK_ROUNDTRIP = CHAR_NPCWORKINT4, + NPC_WORK_MODE = CHAR_NPCWORKINT5, + NPC_WORK_CURRENTROUTE = CHAR_NPCWORKINT6, + NPC_WORK_ROUTEMAX = CHAR_NPCWORKINT7, + NPC_WORK_WAITTIME = CHAR_NPCWORKINT8, + NPC_WORK_CURRENTTIME = CHAR_NPCWORKINT9, + NPC_WORK_SEFLG = CHAR_NPCWORKINT10, +*/ +}; + +static void NPC_ItemchangeMan_selectWindow( int meindex, int toindex, int num,int select); +BOOL ItemchangeMan_GetNeedStr( int meindex, int toindex, char *npcarg, char *token, int num ); +BOOL ItemchangeMan_GetMenuStr( int meindex, int toindex, char *npcarg, char *token); + +BOOL NPC_ItemchangeManInit( int meindex ) +{ + char npcarg[NPC_UTIL_GETARGSTR_BUFSIZE]; + + if(NPC_Util_GetArgStr( meindex, npcarg, sizeof(npcarg))==NULL){ + print("TRANSER_MAN: GetArgStrErr!!"); + return FALSE; + } + + CHAR_setInt( meindex, CHAR_WHICHTYPE, CHAR_ITEMCHANGENPC); + + //CHAR_setInt( meindex, CHAR_LOOPINTERVAL, NEWNPCMAN_STANDBY); + CHAR_setWorkInt( meindex, NPC_WORK_CURRENTTIME, NowTime.tv_sec); + + return TRUE; +} +//CHAR_setWorkInt(talkerindex,CHAR_WORKSHOPRELEVANT,1); +void NPC_ItemchangeManTalked( int meindex, int talkerindex, char *msg, int color ) +{ + if( CHAR_getInt( talkerindex , CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER ) + return; + if( NPC_Util_isFaceToFace( meindex ,talkerindex , 2) == FALSE) { + if( NPC_Util_isFaceToChara( talkerindex, meindex, 1) == FALSE) + return; + } + CHAR_setWorkInt( talkerindex, CHAR_WORKSHOPRELEVANT, 0); + NPC_ItemchangeMan_selectWindow( meindex, talkerindex, ITEMCHANGE_START, -1); + +} + +void NPC_ItemchangeManWindowTalked( int meindex, int talkerindex, int seqno, int select, char *data) +{ + int flg=-1; + if( select == WINDOW_BUTTONTYPE_NO || select == WINDOW_BUTTONTYPE_CANCEL) + return; + switch( seqno) { + case NPC_ITEMCHANGE_START: + break; + case NPC_ITEMCHANGE_SELECT: + NPC_ItemchangeMan_selectWindow( meindex, talkerindex, ITEMCHANGE_SELECT, flg); + break; + case NPC_ITEMCHANGE_MESSAGE: + flg = atoi( data); + CHAR_setWorkInt( talkerindex, CHAR_WORKSHOPRELEVANT, flg); + NPC_ItemchangeMan_selectWindow( meindex, talkerindex, ITEMCHANGE_MESSAGE, flg); + break; + case NPC_ITEMCHANGE_END: + flg = CHAR_getWorkInt( talkerindex, CHAR_WORKSHOPRELEVANT); + NPC_ItemchangeMan_selectWindow( meindex, talkerindex, ITEMCHANGE_END , flg); + break; + } + +} + +static void NPC_ItemchangeMan_selectWindow( int meindex, int toindex, int num,int select) +{ + char npcarg[NPC_UTIL_GETARGSTR_BUFSIZE]; + char token[256]; + int buttontype = 0, windowtype = 0, windowno = 0; + int fd = getfdFromCharaIndex( toindex); + windowtype = WINDOW_MESSAGETYPE_MESSAGE; + if(NPC_Util_isFaceToFace( meindex ,toindex , 2) == FALSE) { + if(NPC_Util_isFaceToChara( toindex, meindex, 1) == FALSE) + return; + } + memset( npcarg, 0, sizeof( npcarg)); + if(NPC_Util_GetArgStr( meindex, npcarg, sizeof(npcarg))==NULL){ + print("TRANSER_MAN: GetArgStrErr!!"); + return; + } + memset( token, 0, sizeof( token)); + + switch( num) { + case ITEMCHANGE_START: + if( NPC_Util_GetStrFromStrWithDelim( npcarg, "START_MSG", token, sizeof( token) ) == NULL) { + print("TranserMan Get START_MSG ERROR !"); + return; + } + CHAR_setWorkInt( toindex, CHAR_WORKSHOPRELEVANT, ITEMCHANGE_START); + buttontype = WINDOW_BUTTONTYPE_YESNO; + windowno = NPC_ITEMCHANGE_SELECT; + break; + case ITEMCHANGE_SELECT: + if( ItemchangeMan_GetMenuStr( meindex, toindex, npcarg, token) == FALSE ) + return; + CHAR_setWorkInt( toindex, CHAR_WORKSHOPRELEVANT, ITEMCHANGE_SELECT); + windowtype = WINDOW_MESSAGETYPE_SELECT; + buttontype = WINDOW_BUTTONTYPE_CANCEL; + windowno = NPC_ITEMCHANGE_MESSAGE; + break; + case ITEMCHANGE_MESSAGE: + if( ItemchangeMan_GetNeedStr( meindex, toindex, npcarg, token, select ) == FALSE ) + return; + buttontype = WINDOW_BUTTONTYPE_YESNO; + windowno = NPC_ITEMCHANGE_END; + break; + case ITEMCHANGE_END: + if( ActionNpc_CheckMenuFree( meindex, toindex, npcarg, select ) == FALSE ){ + memset( token, 0, sizeof( token)); + if( NPC_Util_GetStrFromStrWithDelim( npcarg, "FAIL_MSG", token, sizeof( token) ) != NULL) { + CHAR_talkToCli( toindex, meindex, token, CHAR_COLORYELLOW); + } + } + return; + break; + case ITEMCHANGE_ERROR: + break; + } + + lssproto_WN_send( fd, windowtype, buttontype, windowno, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), token); +} + +void NPC_ItemchangeManLoop( int meindex) +{ + +} + +BOOL ItemchangeMan_GetMenuStr( int meindex, int toindex, char *npcarg, char *token) +{ + char buf1[1024], buf2[256], buf3[256]; + char NullName[256] = {"δ֪Ʒ"}; + BOOL FINDS=FALSE; + int talkNo=1; + int addID; + if( npcarg == NULL ) return FALSE; + + if( NPC_Util_GetStrFromStrWithDelim( npcarg, "MenuHead", buf1, sizeof( buf1) ) == NULL){ + print("ItemchangeMan Get MenuHead ERROR!"); + return FALSE; + } + + sprintf( token, "%s\n", buf1); + + while( getStringFromIndexWithDelim( npcarg,"}", talkNo, buf1, sizeof( buf1)) != FALSE ) { + char *ItemName; + talkNo++; + + if( NPC_Util_GetStrFromStrWithDelim( buf1, "CHANGEITEM", buf2, sizeof( buf2)) != NULL ){ + addID = atoi( buf2); + if( (ItemName = ITEM_getNameFromNumber( addID)) == "\0" ){ + sprintf( buf3, " %s\n", NullName); + }else{ + sprintf( buf3, " %s\n", ItemName); + } + // continue; + }else { + memset( buf3, 0, sizeof( buf3)); + if( NPC_Util_GetStrFromStrWithDelim( buf1, "CHANGEMSG", buf3, sizeof( buf3)) == NULL ) + continue; + strcat( buf3, "\n"); + } + FINDS = TRUE; + strcat( token, buf3); + } + + return FINDS; +} + +BOOL ItemchangeMan_GetNeedStr( int meindex, int toindex, char *npcarg, char *token, int num ) +{ + char buf1[1024], buf2[256], buf3[256]; + char NullName[256] = {"δ֪Ʒ"}; + int talkNo=1, addID, i=0; + BOOL FINDS = FALSE; + if( npcarg == NULL ) return FALSE; + if( NPC_Util_GetStrFromStrWithDelim( npcarg, "NeedHead", buf1, sizeof( buf1) ) == NULL){ + print("ItemchangeMan Get NeedHead ERROR!\n%s", npcarg); + return FALSE; + } + sprintf( token, "%s\n", buf1); + if( getStringFromIndexWithDelim( npcarg,"}", num, buf1, sizeof( buf1)) == FALSE ) { + printf("Get NeedMess error !!\n"); + return FALSE; + } + + if( NPC_Util_GetStrFromStrWithDelim( buf1, "NeedItem", buf2, sizeof( buf2) ) != NULL){ + while( getStringFromIndexWithDelim( buf2, ",", talkNo, buf1, sizeof( buf1)) != FALSE ) { + char *ItemName=NULL; + talkNo++; + + addID = atoi( buf1); + FINDS = TRUE; + if( (ItemName = ITEM_getNameFromNumber( addID)) == "\0" ){ + sprintf( buf3, "%s ", NullName); + }else{ + sprintf( buf3, "%s ", ItemName); + } + strcat( token, buf3); + if( i%3 == 0 ) + strcat( token, "\n"); + i++; + } + }else { + if( NPC_Util_GetStrFromStrWithDelim( buf1, "NeedMsg", buf2, sizeof( buf2) ) == NULL) + return FALSE; + sprintf( token, "%s ", buf2); + FINDS = TRUE; + } + + if( NPC_Util_GetStrFromStrWithDelim( buf2, "DelGold", buf1, sizeof( buf1)) != NULL ) { + char goldmess[256]; + int gold = atoi( buf1); + if( gold > 0 ) { + sprintf( goldmess, "ʯ:%d \n", gold); + strcat( token, goldmess); + } + } + + return FINDS; +} +//void ItemchangeMan_CheckMenuFree( int meindex, int toindex, char *npcarg, int nums) +#endif + + diff --git a/npc/npc_itemshop.c b/npc/npc_itemshop.c new file mode 100644 index 0000000..bd8a864 --- /dev/null +++ b/npc/npc_itemshop.c @@ -0,0 +1,1162 @@ +#include "version.h" +#include +#include "char.h" +#include "object.h" +#include "char_base.h" +#include "npcutil.h" +#include "lssproto_serv.h" +#include "pet_skill.h" +#include "npc_eventaction.h" +#include "readmap.h" +#include "log.h" +#include "family.h" + +#define MAXSHOPITEM 33 +static void NPC_ItemShop_selectWindow( int meindex, int talker, int num,int select); +void NPC_ItemShop_BuyMain(int meindex,int talker,int before ); +void NPC_GetItemList(char *argstr,char * argtoken2); + #ifdef _NEW_MANOR_LAW + void NPC_ItemStrStr(int itemID,double rate,char *name,char *token2,int iCostFame,int iChangeItemCost); + #else + void NPC_ItemStrStr(int itemID,double rate,char *name,char *token2); + #endif + +BOOL NPC_SetNewItem(int meindex,int talker,char *data); +BOOL NPC_SellNewItem(int meindex,int talker,char *data); + +void NPC_ItemShop_Menu(int meindex,int talker); + +int NPC_GetLimtItemList(int talker,char *argstr,char *token2,int sell); + +void NPC_ItemShop_SellMain(int meindex,int talker,int select); +int NPC_GetSellItemList(int itemindex,int flg,char *argstr,char *argtoken,int select,int sell); +#ifdef _NEW_MANOR_LAW +BOOL NPC_AddItemBuy(int meindex, int talker,int itemID,int kosuu,double rate,int iCostFame,int iChangeItemCost); +#else +BOOL NPC_AddItemBuy(int meindex, int talker,int itemID,int kosuu,double rate); +#endif +int NPC_SellItemstrsStr(int itemindex,int flg,double rate,char *argtoken,int select,int sell); +void NPC_LimitItemShop(int meindex,int talker,int select); +void NPC_ExpressmanCheck(int meindex,int talker); + +enum{ + NPC_SHOP_WORK_NO = CHAR_NPCWORKINT1, + NPC_SHOP_WORK_EV = CHAR_NPCWORKINT2, + NPC_SHOP_WORK_EXPRESS = CHAR_NPCWORKINT3, +}; + + + +typedef struct { + char arg[32]; + int type; +}NPC_Shop; + + +static NPC_Shop TypeTable[] = { + { "FIST", 0 }, //ȭ + { "AXE", 1 }, // + { "CLUB", 2 }, // + { "SPEAR", 3}, //ì + { "BOW", 4}, // + { "SHIELD", 5}, // + { "HELM", 6 }, //ͷ + { "ARMOUR", 7 }, // + { "BRACELET", 8}, // + { "ANCLET", 9 }, // + { "NECKLACE", 10}, // + { "RING", 11}, //ָ + { "BELT", 12}, // + { "EARRING", 13}, // + { "NOSERING", 14}, //ǻ + { "AMULET", 15}, // + { "OTHER", 16}, + { "BOOMERANG", 17}, // + { "BOUNDTHROW", 18}, + { "BREAKTHROW", 19}, //Ͷ +#ifdef _ITEM_TYPETABLE + { "DISH", 20}, + { "METAL", 21}, + { "JEWEL", 22}, + { "WARES", 23}, + { "WBELT", 24}, + { "WSHIELD", 25}, + { "WSHOES", 26}, + { "WGLOVE", 27}, + { "ANGELTOKEN", 28}, + { "HEROTOKEN", 29}, +#endif + { "ACCESSORY", 30}, // + { "OFFENCE", 40}, // + { "DEFENCE", 50}, // + +}; + +BOOL NPC_ItemShopInit( int meindex ) +{ + + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + + CHAR_setInt( meindex , CHAR_WHICHTYPE , CHAR_TYPEITEMSHOP ); + if(NPC_Util_GetArgStr( meindex, argstr, sizeof(argstr)) == NULL) { + print("GetArgStrErr"); + return FALSE; + } + if(strstr(argstr,"LIMITSHOP") != NULL) { + CHAR_setWorkInt( meindex, NPC_SHOP_WORK_NO, 1); + }else{ + CHAR_setWorkInt( meindex, NPC_SHOP_WORK_NO, 0); + } + if(strstr( argstr, "EVENT") != NULL) { + CHAR_setWorkInt( meindex, NPC_SHOP_WORK_EV, 1); + }else{ + CHAR_setWorkInt( meindex, NPC_SHOP_WORK_EV, 0); + } + if(strstr( argstr, "EXPRESS") != NULL) { + CHAR_setWorkInt( meindex, NPC_SHOP_WORK_EXPRESS, 1); + }else{ + CHAR_setWorkInt( meindex, NPC_SHOP_WORK_EXPRESS, 0); + } + + return TRUE; +} + +void NPC_ItemShopTalked( int meindex , int talker , char *szMes ,int color ) +{ + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + char buff[1024]; + char buf2[256]; + char token[1024]; + int i = 1; + BOOL sellonlyflg = FALSE; + char sellmsg[1024]; + + if( CHAR_getInt( talker , CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER ) { + return; + } + + if(NPC_Util_isFaceToFace( meindex, talker, 2) == FALSE) {//̸ʱǷ + if( NPC_Util_CharDistance( talker, meindex ) > 1) return; //1 + } + + //ȡnpc趨ڵ,ΪNULL, + if(NPC_Util_GetArgStr( meindex, argstr, sizeof( argstr)) == NULL){ + print("itemshopGetArgStrErr"); + return; + } + + //ȡNPCֻѶϢ + if( NPC_Util_GetStrFromStrWithDelim( argstr, "sellonly_msg", token, sizeof( token)) != NULL){ + sellonlyflg = TRUE; //NPCҵĶ + strcpysafe(sellmsg, sizeof( sellmsg), token);//:sellmsgֵ->רĵꡣ + } + + //ȡָ. buffΪһִָ,:,,л,kau,buy,menu,лл,,ҴЩ־ʱ,Ϳ + if( NPC_Util_GetStrFromStrWithDelim( argstr, "buy_msg", buff, sizeof( buff)) != NULL ){ + while(getStringFromIndexWithDelim(buff,",",i,buf2,sizeof(buf2)) != FALSE ){ + i++; //ָ8,iͻӵ8 + if( strstr( szMes, buf2) != NULL) { + if( CHAR_getWorkInt( meindex, NPC_SHOP_WORK_EV) == 0) { + if( CHAR_getWorkInt( meindex, NPC_SHOP_WORK_NO) == 1) { + if( sellonlyflg ) { + NPC_ItemShop_selectWindow( meindex, talker, 3, -1); + return; + } + }else{ + NPC_ItemShop_selectWindow( meindex, talker, 1, -1); + return; + } + }else{ + if(CHAR_getWorkInt( meindex, NPC_SHOP_WORK_NO) == 1) { + if( sellonlyflg) { + NPC_ItemShop_selectWindow( meindex, talker, 3, -1); + return; + } + }else{ + NPC_ItemShop_selectWindow( meindex, talker, 1, -1); + return; + } + return; + } + } + } + } + i=1; + + //ȡָ. buffΪһִָ,:,,sell,uru ҴЩ־ʱ,Ϳ + if( NPC_Util_GetStrFromStrWithDelim( argstr, "sell_msg", buff, sizeof( buff)) != NULL ){ + while( getStringFromIndexWithDelim(buff,",", i,buf2,sizeof(buf2)) != FALSE ){ + i++; + if(strstr(szMes,buf2) != NULL) { + NPC_ItemShop_selectWindow( meindex, talker, 2, -1); + return; + } + } + } + i = 1; + + //ѶϢ + if( NPC_Util_GetStrFromStrWithDelim( argstr, "other_msg", buff, sizeof( buff)) != NULL ){ + while(getStringFromIndexWithDelim( buff, ",", i, buf2, sizeof( buf2)) != FALSE ){ + i++; + if(strstr(szMes,buf2) != NULL) { + if(NPC_Util_GetStrFromStrWithDelim( argstr, "hint_msg", + token, sizeof( token)) != NULL) + { + CHAR_talkToCli( talker, meindex, token, CHAR_COLORWHITE); + return; + } + } + } + } + + if(CHAR_getWorkInt( meindex, NPC_SHOP_WORK_NO) == 1) { + if(CHAR_getWorkInt( meindex, NPC_SHOP_WORK_EV) == 1) { + if( sellonlyflg) { + CHAR_talkToCli( talker, meindex, sellmsg, CHAR_COLORWHITE); + return; + } + }else{ + if( sellonlyflg) { + NPC_ItemShop_selectWindow( meindex, talker, 3, -1); + return; + } + } + }else{ + if(CHAR_getWorkInt( meindex, NPC_SHOP_WORK_EV) == 1) { + if( sellonlyflg) { + CHAR_talkToCli( talker, meindex, sellmsg, CHAR_COLORWHITE); + return; + } + }else{ + if(CHAR_getWorkInt( meindex, NPC_SHOP_WORK_EXPRESS) == 1) { + NPC_ExpressmanCheck( meindex, talker); + }else{ + NPC_ItemShop_selectWindow( meindex, talker, 0, -1); + } + } + } + +} + +static void NPC_ItemShop_selectWindow( int meindex, int talker, int num,int select) +{ + switch( num) { + case 0: + CHAR_send_P_StatusString( talker, CHAR_P_STRING_GOLD);//ͽǮ,100Ԫ ͳȥϸʽΪ P8Nz2|100| + + if(CHAR_getWorkInt( meindex, NPC_SHOP_WORK_EXPRESS) == 1 ) { + if(CHAR_getWorkInt( meindex, NPC_SHOP_WORK_NO) ==0 ) { + NPC_ExpressmanCheck( meindex, talker);//ë + } + }else if(CHAR_getWorkInt( meindex, NPC_SHOP_WORK_NO) == 1) { + + }else{ + NPC_ItemShop_Menu( meindex, talker);//ѡ(,,뿪)СӴ + } + break; + + case 1://Ӵ + CHAR_sendStatusString( talker,"I");//еĵ߸Client + NPC_ItemShop_BuyMain( meindex, talker, select); + break; + + case 2://Ӵ + CHAR_sendStatusString( talker,"I"); + NPC_ItemShop_SellMain( meindex, talker, select); + break; + + case 3: + NPC_LimitItemShop( meindex, talker, select); + break; + + } +} + +void NPC_ItemShopWindowTalked( int meindex, int talkerindex, + int seqno, int select, char *data) +{ + if( NPC_Util_CharDistance( talkerindex, meindex ) > 3) { + CHAR_send_P_StatusString( talkerindex, CHAR_P_STRING_GOLD); + return; + } + + makeStringFromEscaped( data); + + switch( seqno){ + + case CHAR_WINDOWTYPE_WINDOWITEMSHOP_STARTMSG: + if(atoi( data) == 1 ) NPC_ItemShop_selectWindow(meindex, talkerindex, 1, -1); + if(atoi( data) == 2) NPC_ItemShop_selectWindow(meindex, talkerindex, 2, -1); + if(atoi( data) == 3) return;/*--ئ--*/ + break; + case CHAR_WINDOWTYPE_WINDOWITEMSHOP_BUY_MSG: + if(NPC_SetNewItem(meindex , talkerindex, data) == TRUE) { + NPC_ItemShop_selectWindow( meindex, talkerindex, 1, 0); + }else{ + NPC_ItemShop_selectWindow( meindex, talkerindex ,0, -1); + } + + break; + case CHAR_WINDOWTYPE_WINDOWITEMSHOP_SELL_MSG: + if(NPC_SellNewItem(meindex , talkerindex, data) == TRUE) { + NPC_ItemShop_selectWindow( meindex, talkerindex, 2, 0); + + }else{ + NPC_ItemShop_selectWindow( meindex, talkerindex, 0, -1); + } + + break; + + case CHAR_WINDOWTYPE_WINDOWITEMSHOP_LIMIT: + if(select == WINDOW_BUTTONTYPE_YES) { + NPC_ItemShop_selectWindow( meindex, talkerindex ,2, -1); + + }else if(select == WINDOW_BUTTONTYPE_NO) { + return; + }else if(select == WINDOW_BUTTONTYPE_OK) { + NPC_ItemShop_selectWindow( meindex, talkerindex, 2, -1); + } + break; + + case CHAR_WINDOWTYPE_WINDOWITEMSHOP_EXPRESS: + if(atoi(data) == 2) { + NPC_ItemShop_selectWindow( meindex, talkerindex, 1, -1); + }else if(atoi( data) == 4) { + NPC_ItemShop_selectWindow( meindex, talkerindex, 2, -1); + } + } +} + +void NPC_ItemShop_BuyMain(int meindex,int talker,int before ) +{ + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + char token[NPC_UTIL_GETARGSTR_BUFSIZE]; + int fd = getfdFromCharaIndex( talker); + + char token2[NPC_UTIL_GETARGSTR_BUFSIZE]; + char buff2[256]; + char buff[256]; + if(NPC_Util_GetArgStr( meindex, argstr, sizeof(argstr)) == NULL) { + print("itemshop_GetArgStr_Err"); + return; + } +#ifdef _ADD_STATUS_2 + sprintf(token,"FAME|%d",CHAR_getInt(talker,CHAR_FAME)/100); + lssproto_S2_send(fd,token); +#endif + if(before != -1) { + sprintf(token,"0|0"); + + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_ITEMSHOPMAIN, + WINDOW_BUTTONTYPE_NONE, + CHAR_WINDOWTYPE_WINDOWITEMSHOP_BUY_MSG, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + token); + }else{ + + NPC_Util_GetStrFromStrWithDelim( argstr, "main_msg", buff, sizeof( buff)); + NPC_Util_GetStrFromStrWithDelim( argstr, "buy_main", buff2, sizeof( buff2)); + + sprintf(token,"0|1|%d|%s|%s|%s|", CHAR_WINDOWTYPE_WINDOWITEMSHOP_STARTMSG, + CHAR_getChar( meindex, CHAR_NAME), buff, buff2); + + NPC_Util_GetStrFromStrWithDelim( argstr, "what_msg", buff, sizeof( buff)); + NPC_Util_GetStrFromStrWithDelim( argstr, "level_msg", buff2, sizeof( buff)); + + snprintf( token2, sizeof( token2), "%s|%s", buff, buff2); + + strncat( token, token2, sizeof( token)); + + NPC_Util_GetStrFromStrWithDelim( argstr, "realy_msg", buff, sizeof( buff)); + NPC_Util_GetStrFromStrWithDelim( argstr, "itemfull_msg", buff2, sizeof( buff2)); + + sprintf( token2, "|%s|%s", buff, buff2); + strncat(token , token2,sizeof(token)); + strcpy(token2, "|"); + + NPC_GetItemList( argstr, token2); + strncat( token, token2, sizeof( token)); + } + + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_ITEMSHOPMAIN, + WINDOW_BUTTONTYPE_NONE, + CHAR_WINDOWTYPE_WINDOWITEMSHOP_BUY_MSG, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + token); + +} +void NPC_GetItemList(char *argstr,char *argtoken) +{ + int i = 1; + int tmp; + char *name ="\0"; + char buff2[256]; +#ifdef _NEW_MANOR_LAW + char buff3[NPC_UTIL_GETARGSTR_LINEMAX]; + char buff4[256]; + char buff5[NPC_UTIL_GETARGSTR_LINEMAX]; + char buff6[256]; + int iCostFame = 0; + int iChangeItemCost = 0; +#endif + char buff[NPC_UTIL_GETARGSTR_LINEMAX]; + char token2[NPC_UTIL_GETARGSTR_BUFSIZE]; + double rate = 1.0; + int loopcnt = 0; + + if(NPC_Util_GetStrFromStrWithDelim( argstr, "buy_rate", buff2, sizeof( buff2)) + != NULL){ + rate = atof( buff2); + } +#ifdef _NEW_MANOR_LAW + memset(buff3,0,sizeof(buff3)); + memset(buff5,0,sizeof(buff5)); + if(NPC_Util_GetStrFromStrWithDelim(argstr,"CostFame",buff3,sizeof(buff3)) == NULL) iCostFame = -1; + if(NPC_Util_GetStrFromStrWithDelim(argstr,"ChangeItemCost",buff5,sizeof(buff5)) == NULL) iChangeItemCost = -1; +#endif + if( NPC_Util_GetStrFromStrWithDelim( argstr, "ItemList", buff, sizeof( buff)) != NULL ){ + while( getStringFromIndexWithDelim(buff,",",i,buff2,sizeof(buff2)) !=FALSE ) { +#ifdef _NEW_MANOR_LAW + if(iCostFame > -1){ + if(getStringFromIndexWithDelim(buff3,",",i,buff4,sizeof(buff4)) != FALSE) iCostFame = atoi(buff4); + } + if(iChangeItemCost > -1){ + if(getStringFromIndexWithDelim(buff5,",",i,buff6,sizeof(buff6)) != FALSE) iChangeItemCost = atoi(buff6); + } +#endif + i++; + if(strstr( buff2, "-") == NULL) { + name = ITEM_getNameFromNumber( atoi(buff2)); + if(name == "\0") continue; + loopcnt++; + if(loopcnt == MAXSHOPITEM) break; + #ifdef _NEW_MANOR_LAW + NPC_ItemStrStr( atoi( buff2), rate, name, token2,iCostFame,iChangeItemCost); + #else + NPC_ItemStrStr( atoi( buff2), rate, name, token2); + #endif + strncat( argtoken, token2, sizeof(token2)); + }else{ + int start; + int end; + getStringFromIndexWithDelim( buff2, "-", 1, token2, sizeof(token2)); + start = atoi( token2); + getStringFromIndexWithDelim( buff2, "-", 2 ,token2, sizeof(token2)); + end = atoi( token2); + if(start > end){ + tmp = start; + start = end; + end = tmp; + } + end++; + for(; start < end ; start++ ) { + /*--ڒo???--*/ + + name = ITEM_getNameFromNumber( start ); + if(name == "\0") continue; + loopcnt++; + if(loopcnt == MAXSHOPITEM) break; + #ifdef _NEW_MANOR_LAW + NPC_ItemStrStr( start, rate, name, token2,iCostFame,iChangeItemCost); + #else + NPC_ItemStrStr( start, rate, name, token2); + #endif + strncat( argtoken, token2, sizeof(token2)); + } + } + } + } +} + + #ifdef _NEW_MANOR_LAW + void NPC_ItemStrStr(int itemID,double rate,char *name,char *token2,int iCostFame,int iChangeItemCost) + #else + void NPC_ItemStrStr(int itemID,double rate,char *name,char *token2) + #endif +{ + + int gold; + int level; + int graNo; + char info[1024]; + char escape[256]; + + #ifdef _NEW_MANOR_LAW + if(iChangeItemCost > -1) gold = iChangeItemCost; + else + #endif + gold = ITEM_getcostFromITEMtabl( itemID); + level = ITEM_getlevelFromITEMtabl( itemID); + graNo = ITEM_getgraNoFromITEMtabl( itemID); + strcpy(escape,ITEM_getItemInfoFromNumber( itemID)); + gold=(int)(gold * rate); + + makeEscapeString( escape, info, sizeof( info)); + makeEscapeString( name, escape, sizeof( escape)); +#ifdef _NEW_MANOR_LAW + sprintf(token2,"%s|0|%d|%d|%d|%s|%d|",escape,level,gold,graNo,info,iCostFame < 0 ? -1:iCostFame/100); +#else + sprintf( token2, "%s|0|%d|%d|%d|%s|", escape, level, gold, graNo, info); +#endif +} + +BOOL NPC_SetNewItem(int meindex,int talker,char *data) +{ + + char buf[1024]; + char buff2[128]; +#ifdef _NEW_MANOR_LAW + char buff3[1024]; + char buff4[128]; + char buff5[1024]; + char buff6[128]; + int iCostFame = 0; + int iChangeItemCost = 0; +#endif + int i = 1, j = 1; + int select; + int kosuu = 0; + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + double rate = 1.0; + int gold = 0; + int kosuucnt = 0; + int itemindex; + + /*--߯Ȼ׷ëѱݩ--*/ + getStringFromIndexWithDelim( data, "|", 1, buf, sizeof( buf)); + select = atoi(buf); + if(select == 0) return FALSE; + getStringFromIndexWithDelim( data, "|", 2, buf, sizeof( buf)); + kosuu = atoi(buf); + if( kosuu <= 0 ) return FALSE; + + /*--Ѽ ¾-*/ + for( i = CHAR_STARTITEMARRAY ; i < CHAR_MAXITEMHAVE ; i++ ) { + itemindex = CHAR_getItemIndex( talker , i ); + if( !ITEM_CHECKINDEX( itemindex) ) { + kosuucnt++; + } + } + + /*--߯Ȼ Ѽ ˼ ӡﴡ Իƾмƥ--*/ + /*--ӡ ë ľ--*/ + if( kosuucnt < kosuu) kosuu = kosuucnt; + + /*--δ޷¡--*/ + if(kosuucnt == 0 ) return FALSE; + + i = 1; + + /*--Ҽ̻ 跴̻ﻥئ巴 --*/ + if(NPC_Util_GetArgStr( meindex, argstr, sizeof(argstr)) == NULL) { + print("shop_GetArgStr_Err"); + return FALSE; + } + + /*---ë ئľ1.0)-*/ + if(NPC_Util_GetStrFromStrWithDelim( argstr, "buy_rate", buf, sizeof( buf)) != NULL) { + rate= atof( buf); + } + +#ifdef _NEW_MANOR_LAW + memset(buff3,0,sizeof(buff3)); + memset(buff5,0,sizeof(buff5)); + if(NPC_Util_GetStrFromStrWithDelim(argstr,"CostFame",buff3,sizeof(buff3)) == NULL) iCostFame = -1; + if(NPC_Util_GetStrFromStrWithDelim(argstr,"ChangeItemCost",buff5,sizeof(buff5)) == NULL) iChangeItemCost = -1; +#endif + + /*--ʧ ةܰë浤Ƿ-*/ + if( NPC_Util_GetStrFromStrWithDelim( argstr, "ItemList", buf, sizeof( buf)) != NULL ){ + while(getStringFromIndexWithDelim(buf , "," , j, buff2, sizeof(buff2)) != FALSE ){ +#ifdef _NEW_MANOR_LAW + if(iCostFame > -1){ + if(getStringFromIndexWithDelim(buff3,",",j,buff4,sizeof(buff4)) != FALSE) iCostFame = atoi(buff4); + } + if(iChangeItemCost > -1){ + if(getStringFromIndexWithDelim(buff5,",",j,buff6,sizeof(buff6)) != FALSE) iChangeItemCost = atoi(buff6); + } +#endif + j++; + /*-- "-"ֳľ¾--*/ + if(strstr( buff2, "-") == NULL) { + if( ITEM_getcostFromITEMtabl(atoi(buff2)) !=-1) { + if ( i == select) { + /*---ʧ ة---*/ + /*----*/ +#ifdef _NEW_MANOR_LAW + if(NPC_AddItemBuy(meindex, talker,atoi(buff2),kosuu,rate,iCostFame,iChangeItemCost) != TRUE) +#else + if(NPC_AddItemBuy(meindex, talker,atoi(buff2),kosuu,rate) != TRUE) +#endif + { + return FALSE; + } + return TRUE; + } + i++; + } + }else{ + /*--ʧ ة 15-25 ƥ˪ľ--*/ + int start; + int end; + + /* "-"ƥľ炙Ѱ Ѱë --*/ + getStringFromIndexWithDelim( buff2, "-", 1, argstr, sizeof(argstr)); + start = atoi( argstr); + getStringFromIndexWithDelim( buff2, "-", 2 ,argstr, sizeof(argstr)); + end = atoi( argstr); + end++; + + /*-- įѱئȻգ ľ׸**/ + if(start > end){ + gold = start; + start = end; + end = gold; + } + + /*--"-"ƥľмʧ ةë ë --*/ + for(; start < end ; start++ ) { + if( ITEM_getcostFromITEMtabl( start) != -1) { + if ( i == select) { + /*---ʧ ة---*/ + /*----*/ +#ifdef _NEW_MANOR_LAW + if(NPC_AddItemBuy(meindex, talker, start, kosuu, rate,iCostFame,iChangeItemCost) != TRUE) +#else + if(NPC_AddItemBuy(meindex, talker, start, kosuu, rate) != TRUE) +#endif + { + return FALSE; + } + return TRUE; + } + i++; + } + } + } + } + } + + return FALSE; + +} + +/*--------------------------------------------- + *ʧ ةܰë浤 + *--------------------------------------------*/ +#ifdef _NEW_MANOR_LAW +BOOL NPC_AddItemBuy(int meindex, int talker,int itemID,int kosuu,double rate,int iCostFame,int iChangeItemCost) +#else +BOOL NPC_AddItemBuy(int meindex, int talker,int itemID,int kosuu,double rate) +#endif +{ + + int itemindex; + int i; + int gold; + int ret; + int maxgold; +#ifdef _NEW_MANOR_LAW + int iTotalCostFame = -1; +#endif + #ifdef _NEW_MANOR_LAW + if(iChangeItemCost > -1) gold = iChangeItemCost; + else + #endif + gold = ITEM_getcostFromITEMtabl( itemID); + gold = (int)(gold * rate); + + maxgold = gold * kosuu; + if(CHAR_getInt( talker, CHAR_GOLD) < maxgold ) return FALSE; +#ifdef _NEW_MANOR_LAW + if(iCostFame > 0){ + iTotalCostFame= iCostFame * kosuu; + if(CHAR_getInt(talker,CHAR_FAME) < iTotalCostFame) return FALSE; + } +#endif + +// if( addNpcFamilyTax( meindex, talker, maxgold*0.4 ) ) +// print(" FamilyTaxDone! "); +// else +// print(" FamilyTaxError!"); + addNpcFamilyTax( meindex, talker, maxgold*0.4 ); + for(i = 0 ; i < kosuu ; i++){ + itemindex = ITEM_makeItemAndRegist( itemID); + + if(itemindex == -1) return FALSE; + ret = CHAR_addItemSpecificItemIndex( talker, itemindex); + if( ret < 0 || ret >= CHAR_MAXITEMHAVE ) { + print( "npc_itemshop.c: additem error itemindex[%d]\n", itemindex); + ITEM_endExistItemsOne( itemindex); + return FALSE; + } + CHAR_sendItemDataOne( talker, ret); + } + CHAR_DelGold( talker, maxgold); +#ifdef _NEW_MANOR_LAW + if(iTotalCostFame > 0){ + CHAR_setInt(talker,CHAR_FAME,CHAR_getInt(talker,CHAR_FAME) - iTotalCostFame); + if(CHAR_getInt(talker,CHAR_FMINDEX) != -1 && (strcmp(CHAR_getChar(talker,CHAR_FMNAME),""))){ + int fd = getfdFromCharaIndex(talker); + char buf[256]; + sprintf(buf,"%d",CHAR_getInt(talker,CHAR_FAME)); + saacproto_ACFixFMData_send(acfd, + CHAR_getChar(talker,CHAR_FMNAME), + CHAR_getInt(talker,CHAR_FMINDEX), + CHAR_getWorkInt(talker,CHAR_WORKFMINDEXI), + FM_FIX_FAME,buf,"", + CHAR_getWorkInt(talker,CHAR_WORKFMCHARINDEX), + CONNECT_getFdid(fd)); + LogFMFameShop(CHAR_getChar(talker,CHAR_FMNAME), + CHAR_getChar(talker,CHAR_CDKEY), + CHAR_getChar(talker,CHAR_NAME), + CHAR_getInt(talker,CHAR_FAME), + iTotalCostFame); + } + } +#endif + //CHAR_send_P_StatusString( talker, CHAR_P_STRING_GOLD); + return TRUE; + +} + +//ѡ (,,ȥ) СӴ +void NPC_ItemShop_Menu(int meindex,int talker) +{ + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + char token[NPC_UTIL_GETARGSTR_LINEMAX]; + char buff[256]; + int fd = getfdFromCharaIndex( talker); + + //argstrȡ趨ѶϢ: ->buy_rate:1.0|sell_rate:0.2|buy_msg:,,л,kau,buy............. (мķָǶʱ) + if(NPC_Util_GetArgStr( meindex, argstr, sizeof(argstr)) == NULL) { + print("shop_GetArgStr_Err"); + return; + } + + //tokenΪӴtitle : ķķߵ|ӭ + NPC_Util_GetStrFromStrWithDelim( argstr, "main_msg", buff, sizeof( buff)); +#ifdef _NEW_MANOR_LAW + snprintf(token, sizeof(token),"%s|%s|%d",CHAR_getChar(meindex,CHAR_NAME),buff,CHAR_getInt(talker,CHAR_FAME)/100); +#else + snprintf(token, sizeof(token),"%s|%s",CHAR_getChar( meindex, CHAR_NAME), buff); +#endif + + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_ITEMSHOPMENU, + WINDOW_BUTTONTYPE_NONE, + CHAR_WINDOWTYPE_WINDOWITEMSHOP_STARTMSG, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + token); + +} + +void NPC_ItemShop_SellMain(int meindex,int talker,int before) +{ + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + char token[NPC_UTIL_GETARGSTR_BUFSIZE]; + int fd = getfdFromCharaIndex( talker); + + //ȡnpc趨 + if(NPC_Util_GetArgStr( meindex, argstr, sizeof(argstr)) == NULL) { + print("shop_GetArgStr_Err"); + return; + } + +#ifdef _ADD_STATUS_2 + sprintf(token,"FAME|%d",CHAR_getInt(talker,CHAR_FAME)/100); + lssproto_S2_send(fd,token); +#endif + + if(before != -1) { + sprintf(token,"1|0"); + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_ITEMSHOPMAIN + +CHAR_getWorkInt(meindex,NPC_SHOP_WORK_NO), + WINDOW_BUTTONTYPE_NONE, + CHAR_WINDOWTYPE_WINDOWITEMSHOP_SELL_MSG, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + token); + + }else{ + + char token2[NPC_UTIL_GETARGSTR_BUFSIZE]; + char buff2[256]; + char buff[256]; + + NPC_Util_GetStrFromStrWithDelim( argstr, "main_msg", buff, sizeof( buff)); + NPC_Util_GetStrFromStrWithDelim( argstr, "sell_main", buff2, sizeof( buff)); + sprintf( token, "1|1|%d|%s|%s|%s|", CHAR_WINDOWTYPE_WINDOWITEMSHOP_STARTMSG, + CHAR_getChar( meindex, CHAR_NAME), buff, buff2); + + NPC_Util_GetStrFromStrWithDelim( argstr, "stone_msg", buff, sizeof( buff)); + + if(CHAR_getWorkInt(meindex,NPC_SHOP_WORK_EXPRESS) == 1 ) { + NPC_Util_GetStrFromStrWithDelim( argstr, "exrealy_msg", buff2, sizeof(buff2)); + }else{ + NPC_Util_GetStrFromStrWithDelim( argstr, "realy_msg", buff2, sizeof( buff2)); + } + sprintf( token2,"%s|%s|", buff, buff2); + NPC_GetLimtItemList( talker,argstr, token2, -1);//ϸҪĵ + strncat( token, token2, sizeof( token)); + + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_ITEMSHOPMAIN+ + CHAR_getWorkInt(meindex,NPC_SHOP_WORK_NO), + WINDOW_BUTTONTYPE_NONE, + CHAR_WINDOWTYPE_WINDOWITEMSHOP_SELL_MSG, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + token); + + } +} +int NPC_GetLimtItemList(int talker, char *argstr, char* token2,int sell) +{ + + char token[NPC_UTIL_GETARGSTR_LINEMAX]; + char buff[NPC_UTIL_GETARGSTR_LINEMAX]; + char token3[NPC_UTIL_GETARGSTR_LINEMAX]; + int k = 0 , i = 1 , j = 0; + int imax; + int itemtype = 0; + int itemindex; + int okflg = 0; + char buf[256]; + int flg=0; + int cost; + + if(sell == -1 ){ + i = CHAR_STARTITEMARRAY; + imax = CHAR_MAXITEMHAVE; + flg = -1; + }else{ + i= sell; + imax= sell + 1; + flg = 1; + } + + for( ; i < imax ; i++ ){ + okflg=0; + itemindex = CHAR_getItemIndex( talker , i ); + + if( ITEM_CHECKINDEX( itemindex) ){ + if( NPC_Util_GetStrFromStrWithDelim( argstr,"LimitItemType", buff, sizeof( buff)) != NULL ){ + k = 1; + while(getStringFromIndexWithDelim(buff , "," , k, token, sizeof(token)) != FALSE ){ +#ifdef _ITEM_TYPETABLE + int cmpmaxitem = sizeof(TypeTable)/sizeof(TypeTable[0]); +#endif + k++; +#ifdef _ITEM_TYPETABLE + for(j = 0 ; j < cmpmaxitem ; j++){ +#else + for(j = 0 ; j < ITEM_CATEGORYNUM+3 ; j++){ +#endif + if(strcmp( TypeTable[ j].arg , token) == 0 ) { + itemtype = TypeTable[ j].type; + if(ITEM_getInt(itemindex,ITEM_TYPE) == itemtype) { + cost = NPC_GetSellItemList(itemindex,0,argstr,token3,i,sell); + if(cost != -1) return cost; + strncat( token2, token3, sizeof( token3)); + okflg = 1; + }else if(itemtype == 30){ + if( 8 <= ITEM_getInt(itemindex,ITEM_TYPE) + && (ITEM_getInt(itemindex,ITEM_TYPE) <= 15) ){ + cost = NPC_GetSellItemList(itemindex,0,argstr,token3,i,sell); + if(cost != -1) return cost; + strncat(token2,token3,sizeof(token3)); + okflg = 1; + } + }else if(itemtype == 40){ + if(( 0 <= ITEM_getInt(itemindex,ITEM_TYPE) + && (ITEM_getInt(itemindex,ITEM_TYPE) <= 4)) + || (17 <= ITEM_getInt(itemindex,ITEM_TYPE) + && (ITEM_getInt(itemindex,ITEM_TYPE) <= 19))) { + cost = NPC_GetSellItemList(itemindex,0,argstr,token3,i,sell); + if(cost != -1) return cost; + strncat(token2,token3,sizeof(token3)); + okflg = 1; + } + }else if(itemtype == 50){ + if( 5 <= ITEM_getInt(itemindex,ITEM_TYPE) + && (ITEM_getInt(itemindex,ITEM_TYPE) <= 7) ){ + cost = NPC_GetSellItemList(itemindex,0,argstr,token3,i,sell); + if(cost != -1) return cost; + strncat(token2,token3,sizeof(token3)); + okflg = 1; + } + } + break; + } + } + + if(okflg == 1) break; + } + } + if( (NPC_Util_GetStrFromStrWithDelim( argstr, "LimitItemNo", buff,sizeof( buff))!= NULL) && okflg == 0 ){ + k = 1; + while(getStringFromIndexWithDelim(buff , "," , k, token, sizeof(token)) != FALSE ){ + k++; + if(strstr( token, "-")==NULL && strcmp(token,"") != 0) { + if(ITEM_getInt(itemindex,ITEM_ID) == atoi(token)) { + cost = NPC_GetSellItemList(itemindex,0,argstr,token3,i,sell); + if(cost != -1) return cost; + strncat(token2,token3,sizeof(token3)); + okflg=1; + } + }else if (strstr( token, "-") != NULL){ + int start, end; + int work; + + if( getStringFromIndexWithDelim( token, "-", 1, buf, sizeof(buf)) == FALSE ) + return -1; + start = atoi( buf); + if( getStringFromIndexWithDelim( token, "-", 2 ,buf, sizeof(buf)) == FALSE ) + return -1; + end = atoi( buf); + + if(start > end){ + work = start; + start = end; + end = work; + } + + end++; + if( (start <= ITEM_getInt(itemindex,ITEM_ID)) && (ITEM_getInt(itemindex,ITEM_ID) < end) ){ + cost = NPC_GetSellItemList(itemindex,0,argstr,token3,i,sell); + if(cost != -1) return cost; + strncat(token2,token3,sizeof(token3)); + okflg = 1; + } + } + } + } + + if(okflg == 0) { + cost = NPC_GetSellItemList(itemindex, 1, argstr, token3, i, sell); + if(sell != -1) return -1; + strncat( token2, token3, sizeof( token3)); + } + + } + } + return -1; +} + + + +/*---------------------------------------------------------- + + ͷʧ˪P + + *----------------------------------------------------------*/ +int NPC_GetSellItemList(int itemindex,int flg, char *argstr,char *argtoken,int select,int sell) +{ + char buff[256]; + double rate = 0.2; + char buff2[256]; + char buff3[64]; + int k = 1; + int cost = -1; + + if(NPC_Util_GetStrFromStrWithDelim( argstr,"special_item",buff, sizeof( buff)) != NULL){ + if(NPC_Util_GetStrFromStrWithDelim( argstr,"special_rate",buff2, sizeof( buff2)) != NULL ){ + rate = atof(buff2); + }else{ + rate = 1.2; + } + + while(getStringFromIndexWithDelim(buff , "," , k, buff2, sizeof(buff2)) !=FALSE ){ + k++; + if(strstr( buff2, "-") == NULL && strcmp(buff2,"") != 0) { + if(ITEM_getInt(itemindex,ITEM_ID) == atoi(buff2)){ + cost = NPC_SellItemstrsStr( itemindex,0, rate, argtoken,select,sell); + return cost; + } + }else if (strstr( buff2, "-") != NULL){ + int start; + int end; + int work; + getStringFromIndexWithDelim( buff2, "-", 1, buff3, sizeof(buff3)); + start = atoi( buff3); + getStringFromIndexWithDelim( buff2, "-", 2 ,buff3, sizeof(buff3)); + end = atoi( buff3); + + if(start > end){ + work = start; + start = end; + end = work; + } + end++; + if( (start <= ITEM_getInt(itemindex,ITEM_ID)) && (ITEM_getInt(itemindex,ITEM_ID) < end) ){ + cost = NPC_SellItemstrsStr( itemindex,0, rate, argtoken,select,sell); + return cost; + } + } + } + } + if( NPC_Util_GetStrFromStrWithDelim( argstr,"sell_rate",buff, sizeof( buff)) != NULL ){ + rate = atof(buff); + cost = NPC_SellItemstrsStr( itemindex, flg ,rate, argtoken,select,sell); + return cost; + } + + return cost; +} + +int NPC_SellItemstrsStr(int itemindex,int flg,double rate,char *argtoken,int select,int sell) +{ + int cost; + char escapedname[256]; + char name[256]; + char *eff; + + + cost = ITEM_getInt( itemindex, ITEM_COST); + cost = (int)(cost * rate); + + if(sell != -1) return cost; + + strcpy( escapedname, ITEM_getChar( itemindex, ITEM_SECRETNAME)); + makeEscapeString( escapedname, name, sizeof( name)); + eff=ITEM_getChar(itemindex, ITEM_EFFECTSTRING); + makeEscapeString( eff, escapedname, sizeof(escapedname)); + + + + sprintf( argtoken, +#ifdef _ITEM_PILENUMS + "%s|%d|%d|%d|%s|%d|%d|", +#else + "%s|%d|%d|%d|%s|%d|", +#endif + name, flg, cost, + ITEM_getInt( itemindex, ITEM_BASEIMAGENUMBER), + escapedname, select +#ifdef _ITEM_PILENUMS + ,ITEM_getInt( itemindex, ITEM_USEPILENUMS) +#endif + ); + + return -1; + +} + +BOOL NPC_SellNewItem(int meindex,int talker,char *data) +{ + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + char token[256], token2[256]; + int cost, k, select, itemindex; + int MyGold, MaxGold, sellnum=1; + + MaxGold = CHAR_getMaxHaveGold( talker); + MyGold = CHAR_getInt( talker, CHAR_GOLD); + + if(NPC_Util_GetArgStr( meindex, argstr, sizeof(argstr)) == NULL) { + print("GetArgStrErr"); + return FALSE; + } + getStringFromIndexWithDelim(data , "|" ,1, token, sizeof( token)); + select = atoi(token); +#ifdef _ITEM_PILENUMS + getStringFromIndexWithDelim(data , "|" ,2, token, sizeof( token)); + sellnum = atoi(token); +#endif + + if( select < CHAR_STARTITEMARRAY || select >= CHAR_MAXITEMHAVE ) return FALSE; + k = select; + itemindex = CHAR_getItemIndex( talker , k); + cost = NPC_GetLimtItemList( talker,argstr, token2,select); + if( cost == -1 || (cost*sellnum)+MyGold >= MaxGold || !ITEM_CHECKINDEX( itemindex) ){ + int fd = getfdFromCharaIndex( talker); + sprintf(token,"\n\nѽ!Բ" "\n\nԲ ! ɲѡһأ" ); + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + CHAR_WINDOWTYPE_WINDOWITEMSHOP_LIMIT, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + token); + return FALSE; + } +#ifdef _ITEM_PILENUMS + if( NPC_DelItem( talker, k, sellnum) == FALSE ) return FALSE; +#else + { + LogItem( + CHAR_getChar( talker, CHAR_NAME ), + CHAR_getChar( talker, CHAR_CDKEY ), +#ifdef _add_item_log_name // WON ADD itemlogitem + itemindex, +#else + ITEM_getInt( itemindex, ITEM_ID ), +#endif + "Sell()", + CHAR_getInt( talker,CHAR_FLOOR), + CHAR_getInt( talker,CHAR_X ), + CHAR_getInt( talker,CHAR_Y ), + ITEM_getChar( itemindex, ITEM_UNIQUECODE), + ITEM_getChar( itemindex, ITEM_NAME), + ITEM_getInt( itemindex, ITEM_ID) + + ); + } + CHAR_DelItem( talker, k); +#endif + CHAR_AddGold( talker, cost*sellnum); + CHAR_send_P_StatusString( talker, CHAR_P_STRING_GOLD); + return TRUE; +} + + + +void NPC_LimitItemShop(int meindex,int talker,int select) +{ + + int fd = getfdFromCharaIndex( talker); + char token[NPC_UTIL_GETARGSTR_LINEMAX]; + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + char buf[1024]; + + if( NPC_Util_GetArgStr( meindex, argstr, sizeof(argstr)) == NULL) { + print("shop_GetArgStr_Err"); + return; + } + + if(NPC_Util_GetStrFromStrWithDelim( argstr, "sellonly_msg", buf, sizeof( buf))!=NULL){ + sprintf(token,"\n\n%s", buf); + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_YESNO, + CHAR_WINDOWTYPE_WINDOWITEMSHOP_LIMIT, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + token); + + }else{ + CHAR_talkToCli( talker, meindex, "רŵꡣ",CHAR_COLORWHITE); + } + return; +} + +void NPC_ExpressmanCheck(int meindex,int talker) +{ + int fd = getfdFromCharaIndex( talker); + char token[1024]; + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + char buf[1024]; + + if( NPC_Util_GetArgStr( meindex, argstr, sizeof(argstr)) == NULL) { + print("shop_GetArgStr_Err"); + return; + } + NPC_Util_GetStrFromStrWithDelim( argstr, "main_msg", buf, sizeof( buf)); + sprintf(token,"4\n%s\n\n%s" + "\n\n " + "\n\n " + ,CHAR_getChar(meindex,CHAR_NAME),buf); + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_SELECT, + WINDOW_BUTTONTYPE_CANCEL, + CHAR_WINDOWTYPE_WINDOWITEMSHOP_EXPRESS, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + token); + + return; + + +} + diff --git a/npc/npc_itemup.c b/npc/npc_itemup.c new file mode 100644 index 0000000..6096143 --- /dev/null +++ b/npc/npc_itemup.c @@ -0,0 +1,280 @@ +#include "version.h" +#include +#include "char.h" +#include "object.h" +#include "char_base.h" +#include "npcutil.h" +#include "lssproto_serv.h" +#include "saacproto_cli.h" +#include "readmap.h" +#include "battle.h" +#include "log.h" +#include "enemy.h" +#include "handletime.h" +#include "npc_eventaction.h" +#include "npc_itemup.h" +#ifdef _NPC_ITEMUP +enum { + ITEMUP_START=1, + ITEMUP_SELECT1, + ITEMUP_SELECT2, + ITEMUP_MESSAGE, + ITEMUP_END, + ITEMUP_ERROR, + +}; +enum { + NPC_WORK_CURRENTTIME = CHAR_NPCWORKINT1, +/* + NPC_WORK_ROUTETOY = CHAR_NPCWORKINT2, + NPC_WORK_ROUTEPOINT = CHAR_NPCWORKINT3, + NPC_WORK_ROUNDTRIP = CHAR_NPCWORKINT4, + NPC_WORK_MODE = CHAR_NPCWORKINT5, + NPC_WORK_CURRENTROUTE = CHAR_NPCWORKINT6, + NPC_WORK_ROUTEMAX = CHAR_NPCWORKINT7, + NPC_WORK_WAITTIME = CHAR_NPCWORKINT8, + NPC_WORK_CURRENTTIME = CHAR_NPCWORKINT9, + NPC_WORK_SEFLG = CHAR_NPCWORKINT10, +*/ +}; + +static void NPC_ItemupMan_selectWindow( int meindex, int toindex, int num,int select); +BOOL ItemupMan_GetNeedStr( int meindex, int toindex, char *npcarg, char *token, int num ); +BOOL ItemupMan_GetMenuStr( int meindex, int toindex, char *npcarg, char *token); +BOOL ItemupMan_GetItemStr( int meindex, int toindex, char *npcarg, char *token,int num); + +BOOL NPC_ItemupManInit( int meindex ) +{ + char npcarg[NPC_UTIL_GETARGSTR_BUFSIZE]; + + if(NPC_Util_GetArgStr( meindex, npcarg, sizeof(npcarg))==NULL){ + print("TRANSER_MAN: GetArgStrErr!!"); + return FALSE; + } + + CHAR_setInt( meindex, CHAR_WHICHTYPE, CHAR_ITEMCHANGENPC); + + //CHAR_setInt( meindex, CHAR_LOOPINTERVAL, NEWNPCMAN_STANDBY); + CHAR_setWorkInt( meindex, NPC_WORK_CURRENTTIME, NowTime.tv_sec); + + return TRUE; +} +//CHAR_setWorkInt(talkerindex,CHAR_WORKSHOPRELEVANT,1); +void NPC_ItemupManTalked( int meindex, int talkerindex, char *msg, int color ) +{ + if( CHAR_getInt( talkerindex , CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER ) + return; + if( NPC_Util_isFaceToFace( meindex ,talkerindex , 2) == FALSE) { + if( NPC_Util_isFaceToChara( talkerindex, meindex, 1) == FALSE) + return; + } + CHAR_setWorkInt( talkerindex, CHAR_WORKSHOPRELEVANT, 0); + NPC_ItemupMan_selectWindow( meindex, talkerindex, ITEMUP_START, -1); + +} + +void NPC_ItemupManWindowTalked( int meindex, int talkerindex, int seqno, int select, char *data) +{ + int flg=-1; + if( select == WINDOW_BUTTONTYPE_NO || select == WINDOW_BUTTONTYPE_CANCEL) + return; + switch( seqno) { + case NPC_ITEMUP_START: + break; + case NPC_ITEMUP_SELECT1: + NPC_ItemupMan_selectWindow( meindex, talkerindex, ITEMUP_SELECT1, flg); + break; + case NPC_ITEMUP_SELECT2: + flg = atoi( data); + NPC_ItemupMan_selectWindow( meindex, talkerindex, ITEMUP_SELECT2, flg); + break; + case NPC_ITEMUP_MESSAGE: + flg = atoi( data); + CHAR_setWorkInt( talkerindex, CHAR_WORKSHOPRELEVANT, flg); + NPC_ItemupMan_selectWindow( meindex, talkerindex, ITEMUP_MESSAGE, flg); + break; + case NPC_ITEMUP_END: + flg = CHAR_getWorkInt( talkerindex, CHAR_WORKSHOPRELEVANT); + NPC_ItemupMan_selectWindow( meindex, talkerindex, ITEMUP_END , flg); + break; + } + +} + +static void NPC_ItemupMan_selectWindow( int meindex, int toindex, int num,int select) +{ + char npcarg[NPC_UTIL_GETARGSTR_BUFSIZE]; + char token[256]; + char npcbuf[2048]; + int buttontype = 0, windowtype = 0, windowno = 0; + int fd = getfdFromCharaIndex( toindex); + windowtype = WINDOW_MESSAGETYPE_MESSAGE; + if(NPC_Util_isFaceToFace( meindex ,toindex , 2) == FALSE) { + if(NPC_Util_isFaceToChara( toindex, meindex, 1) == FALSE) + return; + } + memset( npcarg, 0, sizeof( npcarg)); + if(NPC_Util_GetArgStr( meindex, npcarg, sizeof(npcarg))==NULL){ + print("TRANSER_MAN: GetArgStrErr!!"); + return; + } + memset( token, 0, sizeof( token)); + + switch( num) { + case ITEMUP_START: + if( NPC_Util_GetStrFromStrWithDelim( npcarg, "START_MSG", token, sizeof( token) ) == NULL) { + print("TranserMan Get START_MSG ERROR !"); + return; + } + CHAR_setWorkInt( toindex, CHAR_WORKSHOPRELEVANT, ITEMUP_START); + buttontype = WINDOW_BUTTONTYPE_YESNO; + windowno = NPC_ITEMUP_SELECT1; + break; + case ITEMUP_SELECT1: + if( ItemupMan_GetMenuStr( meindex, toindex, npcarg, token) == FALSE ) + return; + CHAR_setWorkInt( toindex, CHAR_WORKSHOPRELEVANT, ITEMUP_SELECT1); + windowtype = WINDOW_MESSAGETYPE_SELECT; + buttontype = WINDOW_BUTTONTYPE_CANCEL; + windowno = NPC_ITEMUP_SELECT2; + break; + case ITEMUP_SELECT2: + if( ItemupMan_GetItemStr( meindex, toindex, npcarg, token, select) == FALSE ) + return; + CHAR_setWorkInt( toindex, CHAR_WORKSHOPRELEVANT, ITEMUP_SELECT2); + windowtype = WINDOW_MESSAGETYPE_SELECT; + buttontype = WINDOW_BUTTONTYPE_CANCEL; + windowno = NPC_ITEMUP_MESSAGE; + break; + case ITEMUP_MESSAGE: + if( ItemupMan_GetNeedStr( meindex, toindex, npcarg, token, select ) == FALSE ) + return; + buttontype = WINDOW_BUTTONTYPE_YESNO; + windowno = NPC_ITEMUP_END; + break; + case ITEMUP_END: + if(getStringFromIndexWithDelim( npcarg,"]", CHAR_getWorkInt(toindex,CHAR_WORKLISTPAGE), npcbuf, sizeof( npcbuf)) == FALSE){ + return; + } + if( ActionNpc_CheckMenuFree( meindex, toindex, npcbuf, select ) == FALSE ){ + memset( token, 0, sizeof( token)); + if( NPC_Util_GetStrFromStrWithDelim( npcarg, "FAIL_MSG", token, sizeof( token) ) != NULL) { + CHAR_talkToCli( toindex, meindex, token, CHAR_COLORYELLOW); + } + } + return; + break; + case ITEMUP_ERROR: + break; + } + + lssproto_WN_send( fd, windowtype, buttontype, windowno, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), token); +} + +void NPC_ItemupManLoop( int meindex) +{ + +} + +BOOL ItemupMan_GetItemStr( int meindex, int toindex, char *npcarg, char *token, int num) +{ + char buf1[1024], buf2[256], buf3[256],buf0[2048]; + char NullName[256] = {"δ֪Ʒ"}; + BOOL FINDS=FALSE; + int talkNo=1; + int addID; + if( npcarg == NULL ) return FALSE; + if( NPC_Util_GetStrFromStrWithDelim( npcarg, "ItemHead", buf1, sizeof( buf1) ) == NULL){ + print("ItemchangeMan Get NeedHead ERROR!\n%s", npcarg); + return FALSE; + } + sprintf( token, "%s\n", buf1); + + if(getStringFromIndexWithDelim( npcarg,"]", num, buf0, sizeof( buf0)) == FALSE){ + return FALSE; + } + CHAR_setWorkInt( toindex, CHAR_WORKLISTPAGE, num); + while( getStringFromIndexWithDelim( buf0,"}", talkNo, buf1, sizeof( buf1)) != FALSE ) { + char *ItemName; + talkNo++; + + if( NPC_Util_GetStrFromStrWithDelim( buf1, "CHANGEITEM", buf2, sizeof( buf2)) != NULL ){ + addID = atoi( buf2); + if( (ItemName = ITEM_getNameFromNumber( addID)) == "\0" ){ + sprintf( buf3, " %s\n", NullName); + }else{ + sprintf( buf3, " %s\n", ItemName); + } + // continue; + }else { + memset( buf3, 0, sizeof( buf3)); + if( NPC_Util_GetStrFromStrWithDelim( buf1, "CHANGEMSG", buf3, sizeof( buf3)) == NULL ) + continue; + strcat( buf3, "\n"); + } + FINDS = TRUE; + strcat( token, buf3); + } + + return FINDS; +} + +BOOL ItemupMan_GetNeedStr( int meindex, int toindex, char *npcarg, char *token, int num ) +{ + char buf1[1024], buf2[256], buf3[256],buf0[2048],buf4[256]; + char NullName[256] = {"δ֪Ʒ"}; + int talkNo=1, addID, i=0,itemnum=1; + BOOL FINDS = FALSE; + if( npcarg == NULL ) return FALSE; + if( NPC_Util_GetStrFromStrWithDelim( npcarg, "NeedHead", buf1, sizeof( buf1) ) == NULL){ + print("ItemchangeMan Get NeedHead ERROR!\n%s", npcarg); + return FALSE; + } + sprintf( token, "%s\n", buf1); + if(getStringFromIndexWithDelim( npcarg,"]", CHAR_getWorkInt(toindex,CHAR_WORKLISTPAGE), buf0, sizeof( buf0)) == FALSE){ + return FALSE; + } + if( getStringFromIndexWithDelim( buf0,"}", num, buf1, sizeof( buf1)) == FALSE ) { + printf("Get NeedMess error !!\n"); + return FALSE; + } + + if( NPC_Util_GetStrFromStrWithDelim( buf1, "NeedMsg", buf2, sizeof( buf2) ) != NULL){ + strcat( token,buf2); + FINDS = TRUE; + } + + return FINDS; +} + +BOOL ItemupMan_GetMenuStr( int meindex, int toindex, char *npcarg, char *token) +{ + char buf1[1024],buf2[256];; + BOOL FINDS=FALSE; + int talkNo=1; + char *MenuName; + if( npcarg == NULL ) return FALSE; + if( NPC_Util_GetStrFromStrWithDelim( npcarg, "MenuHead", buf1, sizeof( buf1) ) == NULL){ + print("ItemchangeMan Get MenuHead ERROR!"); + return FALSE; + } + + sprintf( token, "%s\n", buf1); + + if( NPC_Util_GetStrFromStrWithDelim( npcarg, "MenuName", buf1, sizeof( buf1) ) == NULL){ + print("ItemchangeMan Get MenuHead ERROR!"); + return FALSE; + } + + while( getStringFromIndexWithDelim( buf1,",", talkNo, buf2, sizeof( buf2)) != FALSE ) { + talkNo++; + MenuName = buf2; + FINDS=TRUE; + strcat( token, MenuName); + strcat( token, "\n"); + } + + return FINDS; +} +#endif diff --git a/npc/npc_itemvippointshop.c b/npc/npc_itemvippointshop.c new file mode 100644 index 0000000..8791fa6 --- /dev/null +++ b/npc/npc_itemvippointshop.c @@ -0,0 +1,1165 @@ +#include "version.h" +#include +#include "char.h" +#include "object.h" +#include "char_base.h" +#include "npcutil.h" +#include "lssproto_serv.h" +#include "pet_skill.h" +#include "npc_eventaction.h" +#include "readmap.h" +#include "log.h" +#include "family.h" + +#define MAXSHOPITEM 33 +static void NPC_ItemVippointShop_selectWindow( int meindex, int talker, int num,int select); +void NPC_ItemVippointShop_BuyMain(int meindex,int talker,int before ); +void NPC_GetItemVippointList(char *argstr,char * argtoken2); + #ifdef _NEW_MANOR_LAW + void NPC_ItemVippointStrStr(int itemID,double rate,char *name,char *token2,int iCostVippoint,int iChangeItemCost); + #else + void NPC_ItemVippointStrStr(int itemID,double rate,char *name,char *token2); + #endif + +BOOL NPC_SetNewItemVippoint(int meindex,int talker,char *data); +BOOL NPC_SellNewItemVippoint(int meindex,int talker,char *data); + +void NPC_ItemVippointShop_Menu(int meindex,int talker); + +int NPC_GetLimtItemVippointList(int talker,char *argstr,char *token2,int sell); + +void NPC_ItemVippointShop_SellMain(int meindex,int talker,int select); +int NPC_GetSellItemVippointList(int itemindex,int flg,char *argstr,char *argtoken,int select,int sell); +#ifdef _NEW_MANOR_LAW +BOOL NPC_AddItemVippointBuy(int meindex, int talker,int itemID,int kosuu,double rate,int iCostVippoint,int iChangeItemCost); +#else +BOOL NPC_AddItemVippointBuy(int meindex, int talker,int itemID,int kosuu,double rate); +#endif +int NPC_SellItemVippointstrsStr(int itemindex,int flg,double rate,char *argtoken,int select,int sell); +void NPC_LimitItemVippointShop(int meindex,int talker,int select); +void NPC_VippointExpressmanCheck(int meindex,int talker); + +enum{ + NPC_SHOP_WORK_NO = CHAR_NPCWORKINT1, + NPC_SHOP_WORK_EV = CHAR_NPCWORKINT2, + NPC_SHOP_WORK_EXPRESS = CHAR_NPCWORKINT3, +}; + + + +typedef struct { + char arg[32]; + int type; +}NPC_Shop; + + +static NPC_Shop TypeTable[] = { + { "FIST", 0 }, //ȭ + { "AXE", 1 }, // + { "CLUB", 2 }, // + { "SPEAR", 3}, //ì + { "BOW", 4}, // + { "SHIELD", 5}, // + { "HELM", 6 }, //ͷ + { "ARMOUR", 7 }, // + { "BRACELET", 8}, // + { "ANCLET", 9 }, // + { "NECKLACE", 10}, // + { "RING", 11}, //ָ + { "BELT", 12}, // + { "EARRING", 13}, // + { "NOSERING", 14}, //ǻ + { "AMULET", 15}, // + { "OTHER", 16}, + { "BOOMERANG", 17}, // + { "BOUNDTHROW", 18}, + { "BREAKTHROW", 19}, //Ͷ +#ifdef _ITEM_TYPETABLE + { "DISH", 20}, + { "METAL", 21}, + { "JEWEL", 22}, + { "WARES", 23}, + { "WBELT", 24}, + { "WSHIELD", 25}, + { "WSHOES", 26}, + { "WGLOVE", 27}, + { "ANGELTOKEN", 28}, + { "HEROTOKEN", 29}, +#endif + { "ACCESSORY", 30}, // + { "OFFENCE", 40}, // + { "DEFENCE", 50}, // + +}; + +BOOL NPC_ItemVippointShopInit( int meindex ) +{ + + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + + CHAR_setInt( meindex , CHAR_WHICHTYPE , CHAR_TYPEITEMSHOP ); + if(NPC_Util_GetArgStr( meindex, argstr, sizeof(argstr)) == NULL) { + print("GetArgStrErr"); + return FALSE; + } + if(strstr(argstr,"LIMITSHOP") != NULL) { + CHAR_setWorkInt( meindex, NPC_SHOP_WORK_NO, 1); + }else{ + CHAR_setWorkInt( meindex, NPC_SHOP_WORK_NO, 0); + } + if(strstr( argstr, "EVENT") != NULL) { + CHAR_setWorkInt( meindex, NPC_SHOP_WORK_EV, 1); + }else{ + CHAR_setWorkInt( meindex, NPC_SHOP_WORK_EV, 0); + } + if(strstr( argstr, "EXPRESS") != NULL) { + CHAR_setWorkInt( meindex, NPC_SHOP_WORK_EXPRESS, 1); + }else{ + CHAR_setWorkInt( meindex, NPC_SHOP_WORK_EXPRESS, 0); + } + + return TRUE; +} + +void NPC_ItemVippointShopTalked( int meindex , int talker , char *szMes ,int color ) +{ + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + char buff[1024]; + char buf2[256]; + char token[1024]; + int i = 1; + BOOL sellonlyflg = FALSE; + char sellmsg[1024]; + + if( CHAR_getInt( talker , CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER ) { + return; + } + + if(NPC_Util_isFaceToFace( meindex, talker, 2) == FALSE) {//̸ʱǷ + if( NPC_Util_CharDistance( talker, meindex ) > 1) return; //1 + } + + //ȡnpc趨ڵ,ΪNULL, + if(NPC_Util_GetArgStr( meindex, argstr, sizeof( argstr)) == NULL){ + print("itemshopGetArgStrErr"); + return; + } + + //ȡNPCֻѶϢ + if( NPC_Util_GetStrFromStrWithDelim( argstr, "sellonly_msg", token, sizeof( token)) != NULL){ + sellonlyflg = TRUE; //NPCҵĶ + strcpysafe(sellmsg, sizeof( sellmsg), token);//:sellmsgֵ->רĵꡣ + } + + //ȡָ. buffΪһִָ,:,,л,kau,buy,menu,лл,,ҴЩ־ʱ,Ϳ + if( NPC_Util_GetStrFromStrWithDelim( argstr, "buy_msg", buff, sizeof( buff)) != NULL ){ + while(getStringFromIndexWithDelim(buff,",",i,buf2,sizeof(buf2)) != FALSE ){ + i++; //ָ8,iͻӵ8 + if( strstr( szMes, buf2) != NULL) { + if( CHAR_getWorkInt( meindex, NPC_SHOP_WORK_EV) == 0) { + if( CHAR_getWorkInt( meindex, NPC_SHOP_WORK_NO) == 1) { + if( sellonlyflg ) { + NPC_ItemVippointShop_selectWindow( meindex, talker, 3, -1); + return; + } + }else{ + NPC_ItemVippointShop_selectWindow( meindex, talker, 1, -1); + return; + } + }else{ + if(CHAR_getWorkInt( meindex, NPC_SHOP_WORK_NO) == 1) { + if( sellonlyflg) { + NPC_ItemVippointShop_selectWindow( meindex, talker, 3, -1); + return; + } + }else{ + NPC_ItemVippointShop_selectWindow( meindex, talker, 1, -1); + return; + } + return; + } + } + } + } + i=1; + + //ȡָ. buffΪһִָ,:,,sell,uru ҴЩ־ʱ,Ϳ + if( NPC_Util_GetStrFromStrWithDelim( argstr, "sell_msg", buff, sizeof( buff)) != NULL ){ + while( getStringFromIndexWithDelim(buff,",", i,buf2,sizeof(buf2)) != FALSE ){ + i++; + if(strstr(szMes,buf2) != NULL) { + NPC_ItemVippointShop_selectWindow( meindex, talker, 2, -1); + return; + } + } + } + i = 1; + + //ѶϢ + if( NPC_Util_GetStrFromStrWithDelim( argstr, "other_msg", buff, sizeof( buff)) != NULL ){ + while(getStringFromIndexWithDelim( buff, ",", i, buf2, sizeof( buf2)) != FALSE ){ + i++; + if(strstr(szMes,buf2) != NULL) { + if(NPC_Util_GetStrFromStrWithDelim( argstr, "hint_msg", + token, sizeof( token)) != NULL) + { + CHAR_talkToCli( talker, meindex, token, CHAR_COLORWHITE); + return; + } + } + } + } + + if(CHAR_getWorkInt( meindex, NPC_SHOP_WORK_NO) == 1) { + if(CHAR_getWorkInt( meindex, NPC_SHOP_WORK_EV) == 1) { + if( sellonlyflg) { + CHAR_talkToCli( talker, meindex, sellmsg, CHAR_COLORWHITE); + return; + } + }else{ + if( sellonlyflg) { + NPC_ItemVippointShop_selectWindow( meindex, talker, 3, -1); + return; + } + } + }else{ + if(CHAR_getWorkInt( meindex, NPC_SHOP_WORK_EV) == 1) { + if( sellonlyflg) { + CHAR_talkToCli( talker, meindex, sellmsg, CHAR_COLORWHITE); + return; + } + }else{ + if(CHAR_getWorkInt( meindex, NPC_SHOP_WORK_EXPRESS) == 1) { + NPC_VippointExpressmanCheck( meindex, talker); + }else{ + NPC_ItemVippointShop_selectWindow( meindex, talker, 0, -1); + } + } + } + +} + +static void NPC_ItemVippointShop_selectWindow( int meindex, int talker, int num,int select) +{ + switch( num) { + case 0: + CHAR_send_P_StatusString( talker, CHAR_P_STRING_GOLD);//ͽǮ,100Ԫ ͳȥϸʽΪ P8Nz2|100| + + if(CHAR_getWorkInt( meindex, NPC_SHOP_WORK_EXPRESS) == 1 ) { + if(CHAR_getWorkInt( meindex, NPC_SHOP_WORK_NO) ==0 ) { + NPC_VippointExpressmanCheck( meindex, talker);//ë + } + }else if(CHAR_getWorkInt( meindex, NPC_SHOP_WORK_NO) == 1) { + + }else{ + NPC_ItemVippointShop_Menu( meindex, talker);//ѡ(,,뿪)СӴ + } + break; + + case 1://Ӵ + CHAR_sendStatusString( talker,"I");//еĵ߸Client + NPC_ItemVippointShop_BuyMain( meindex, talker, select); + break; + + case 2://Ӵ + //CHAR_sendStatusString( talker,"I"); + //NPC_ItemVippointShop_SellMain( meindex, talker, select); + CHAR_talkToCli( talker, meindex, "NPC޴˹ܣ",CHAR_COLORWHITE); + break; + + case 3: + NPC_LimitItemVippointShop( meindex, talker, select); + break; + + } +} + +void NPC_ItemVippointShopWindowTalked( int meindex, int talkerindex, + int seqno, int select, char *data) +{ + if( NPC_Util_CharDistance( talkerindex, meindex ) > 3) { + CHAR_send_P_StatusString( talkerindex, CHAR_P_STRING_GOLD); + return; + } + + makeStringFromEscaped( data); + + switch( seqno){ + + case CHAR_WINDOWTYPE_WINDOWITEMSHOP_STARTMSG: + if(atoi( data) == 1 ) NPC_ItemVippointShop_selectWindow(meindex, talkerindex, 1, -1); + if(atoi( data) == 2) NPC_ItemVippointShop_selectWindow(meindex, talkerindex, 2, -1); + if(atoi( data) == 3) return;/*--ئ--*/ + break; + case CHAR_WINDOWTYPE_WINDOWITEMSHOP_BUY_MSG: + if(NPC_SetNewItemVippoint(meindex , talkerindex, data) == TRUE) { + NPC_ItemVippointShop_selectWindow( meindex, talkerindex, 1, 0); + }else{ + NPC_ItemVippointShop_selectWindow( meindex, talkerindex ,0, -1); + } + + break; + case CHAR_WINDOWTYPE_WINDOWITEMSHOP_SELL_MSG: + if(NPC_SellNewItemVippoint(meindex , talkerindex, data) == TRUE) { + NPC_ItemVippointShop_selectWindow( meindex, talkerindex, 2, 0); + + }else{ + NPC_ItemVippointShop_selectWindow( meindex, talkerindex, 0, -1); + } + + break; + + case CHAR_WINDOWTYPE_WINDOWITEMSHOP_LIMIT: + if(select == WINDOW_BUTTONTYPE_YES) { + NPC_ItemVippointShop_selectWindow( meindex, talkerindex ,2, -1); + + }else if(select == WINDOW_BUTTONTYPE_NO) { + return; + }else if(select == WINDOW_BUTTONTYPE_OK) { + NPC_ItemVippointShop_selectWindow( meindex, talkerindex, 2, -1); + } + break; + + case CHAR_WINDOWTYPE_WINDOWITEMSHOP_EXPRESS: + if(atoi(data) == 2) { + NPC_ItemVippointShop_selectWindow( meindex, talkerindex, 1, -1); + }else if(atoi( data) == 4) { + NPC_ItemVippointShop_selectWindow( meindex, talkerindex, 2, -1); + } + } +} + +void NPC_ItemVippointShop_BuyMain(int meindex,int talker,int before ) +{ + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + char token[NPC_UTIL_GETARGSTR_BUFSIZE]; + int fd = getfdFromCharaIndex( talker); + + char token2[NPC_UTIL_GETARGSTR_BUFSIZE]; + char buff2[256]; + char buff[256]; + if(NPC_Util_GetArgStr( meindex, argstr, sizeof(argstr)) == NULL) { + print("itemshop_GetArgStr_Err"); + return; + } +#ifdef _ADD_STATUS_2 + sprintf(token,"FAME|%d",CHAR_getInt(talker,CHAR_FAME)/100); + lssproto_S2_send(fd,token); +#endif + if(before != -1) { + sprintf(token,"0|0"); + + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_ITEMSHOPMAIN, + WINDOW_BUTTONTYPE_NONE, + CHAR_WINDOWTYPE_WINDOWITEMSHOP_BUY_MSG, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + token); + }else{ + + NPC_Util_GetStrFromStrWithDelim( argstr, "main_msg", buff, sizeof( buff)); + NPC_Util_GetStrFromStrWithDelim( argstr, "buy_main", buff2, sizeof( buff2)); + sprintf(buff2,"%s\nԱ%d",buff2,sasql_vippoint(CHAR_getUseID(talker),0,0)); + sprintf(token,"0|1|%d|%s|%s|%s|", CHAR_WINDOWTYPE_WINDOWITEMSHOP_STARTMSG, + CHAR_getChar( meindex, CHAR_NAME), buff, buff2); + + NPC_Util_GetStrFromStrWithDelim( argstr, "what_msg", buff, sizeof( buff)); + NPC_Util_GetStrFromStrWithDelim( argstr, "level_msg", buff2, sizeof( buff)); + + snprintf( token2, sizeof( token2), "%s|%s", buff, buff2); + + strncat( token, token2, sizeof( token)); + + NPC_Util_GetStrFromStrWithDelim( argstr, "realy_msg", buff, sizeof( buff)); + NPC_Util_GetStrFromStrWithDelim( argstr, "itemfull_msg", buff2, sizeof( buff2)); + + sprintf( token2, "|%s|%s", buff, buff2); + strncat(token , token2,sizeof(token)); + strcpy(token2, "|"); + + NPC_GetItemVippointList( argstr, token2); + strncat( token, token2, sizeof( token)); + } + + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_ITEMSHOPMAIN, + WINDOW_BUTTONTYPE_NONE, + CHAR_WINDOWTYPE_WINDOWITEMSHOP_BUY_MSG, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + token); + +} +void NPC_GetItemVippointList(char *argstr,char *argtoken) +{ + int i = 1; + int tmp; + char *name ="\0"; + char buff2[256]; +#ifdef _NEW_MANOR_LAW + char buff3[NPC_UTIL_GETARGSTR_LINEMAX]; + char buff4[256]; + char buff5[NPC_UTIL_GETARGSTR_LINEMAX]; + char buff6[256]; + int iCostVippoint = 0; + int iChangeItemCost = 0; +#endif + char buff[NPC_UTIL_GETARGSTR_LINEMAX]; + char token2[NPC_UTIL_GETARGSTR_BUFSIZE]; + double rate = 1.0; + int loopcnt = 0; + + if(NPC_Util_GetStrFromStrWithDelim( argstr, "buy_rate", buff2, sizeof( buff2)) + != NULL){ + rate = atof( buff2); + } +#ifdef _NEW_MANOR_LAW + memset(buff3,0,sizeof(buff3)); + memset(buff5,0,sizeof(buff5)); + if(NPC_Util_GetStrFromStrWithDelim(argstr,"CostVippoint",buff3,sizeof(buff3)) == NULL) iCostVippoint = -1; + if(NPC_Util_GetStrFromStrWithDelim(argstr,"ChangeItemCost",buff5,sizeof(buff5)) == NULL) iChangeItemCost = -1; +#endif + if( NPC_Util_GetStrFromStrWithDelim( argstr, "ItemList", buff, sizeof( buff)) != NULL ){ + while( getStringFromIndexWithDelim(buff,",",i,buff2,sizeof(buff2)) !=FALSE ) { +#ifdef _NEW_MANOR_LAW + if(iCostVippoint > -1){ + if(getStringFromIndexWithDelim(buff3,",",i,buff4,sizeof(buff4)) != FALSE) iCostVippoint = atoi(buff4); + } + if(iChangeItemCost > -1){ + if(getStringFromIndexWithDelim(buff5,",",i,buff6,sizeof(buff6)) != FALSE) iChangeItemCost = atoi(buff6); + } +#endif + i++; + if(strstr( buff2, "-") == NULL) { + name = ITEM_getNameFromNumber( atoi(buff2)); + if(name == "\0") continue; + loopcnt++; + if(loopcnt == MAXSHOPITEM) break; + #ifdef _NEW_MANOR_LAW + NPC_ItemVippointStrStr( atoi( buff2), rate, name, token2,iCostVippoint,iChangeItemCost); + #else + NPC_ItemVippointStrStr( atoi( buff2), rate, name, token2); + #endif + strncat( argtoken, token2, sizeof(token2)); + }else{ + int start; + int end; + getStringFromIndexWithDelim( buff2, "-", 1, token2, sizeof(token2)); + start = atoi( token2); + getStringFromIndexWithDelim( buff2, "-", 2 ,token2, sizeof(token2)); + end = atoi( token2); + if(start > end){ + tmp = start; + start = end; + end = tmp; + } + end++; + for(; start < end ; start++ ) { + /*--ڒo???--*/ + + name = ITEM_getNameFromNumber( start ); + if(name == "\0") continue; + loopcnt++; + if(loopcnt == MAXSHOPITEM) break; + #ifdef _NEW_MANOR_LAW + NPC_ItemVippointStrStr( start, rate, name, token2,iCostVippoint,iChangeItemCost); + #else + NPC_ItemVippointStrStr( start, rate, name, token2); + #endif + strncat( argtoken, token2, sizeof(token2)); + } + } + } + } +} + + #ifdef _NEW_MANOR_LAW + void NPC_ItemVippointStrStr(int itemID,double rate,char *name,char *token2,int iCostVippoint,int iChangeItemCost) + #else + void NPC_ItemVippointStrStr(int itemID,double rate,char *name,char *token2) + #endif +{ + + int gold; + int level; + int graNo; + char info[1024]; + char escape[256]; + + #ifdef _NEW_MANOR_LAW + if(iChangeItemCost > -1) gold = iChangeItemCost; + else + #endif + gold = ITEM_getcostFromITEMtabl( itemID); + level = ITEM_getlevelFromITEMtabl( itemID); + graNo = ITEM_getgraNoFromITEMtabl( itemID); + strcpy(escape,ITEM_getItemInfoFromNumber( itemID)); + gold=(int)(gold * rate); + + makeEscapeString( escape, info, sizeof( info)); + makeEscapeString( name, escape, sizeof( escape)); + char tempbuf[64]; + if(iCostVippoint==0) sprintf(tempbuf,"ȡ "); + else if(iCostVippoint<10) sprintf(tempbuf," %d ",iCostVippoint); + else if(iCostVippoint<100) sprintf(tempbuf," %d ",iCostVippoint); + else if(iCostVippoint<1000) sprintf(tempbuf," %d ",iCostVippoint); + else if(iCostVippoint<10000) sprintf(tempbuf," %d ",iCostVippoint); + else if(iCostVippoint<100000) sprintf(tempbuf," %d ",iCostVippoint); + else sprintf(tempbuf,"%d ",iCostVippoint); + char newescape[256]; + sprintf(newescape,"%s%s",tempbuf,escape); +#ifdef _NEW_MANOR_LAW + sprintf(token2,"%s|0|%d|%d|%d|%s|%d|",newescape,level,gold,graNo,info,-1); +#else + sprintf( token2, "%s|0|%d|%d|%d|%s|", newescape, level, gold, graNo, info); +#endif +} + +BOOL NPC_SetNewItemVippoint(int meindex,int talker,char *data) +{ + + char buf[1024]; + char buff2[128]; +#ifdef _NEW_MANOR_LAW + char buff3[1024]; + char buff4[128]; + char buff5[1024]; + char buff6[128]; + int iCostVippoint = 0; + int iChangeItemCost = 0; +#endif + int i = 1, j = 1; + int select; + int kosuu = 0; + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + double rate = 1.0; + int gold = 0; + int kosuucnt = 0; + int itemindex; + + /*--߯Ȼ׷ëѱݩ--*/ + getStringFromIndexWithDelim( data, "|", 1, buf, sizeof( buf)); + select = atoi(buf); + if(select == 0) return FALSE; + getStringFromIndexWithDelim( data, "|", 2, buf, sizeof( buf)); + kosuu = atoi(buf); + if( kosuu <= 0 ) return FALSE; + + /*--Ѽ ¾-*/ + for( i = CHAR_STARTITEMARRAY ; i < CHAR_MAXITEMHAVE ; i++ ) { + itemindex = CHAR_getItemIndex( talker , i ); + if( !ITEM_CHECKINDEX( itemindex) ) { + kosuucnt++; + } + } + + /*--߯Ȼ Ѽ ˼ ӡﴡ Իƾмƥ--*/ + /*--ӡ ë ľ--*/ + if( kosuucnt < kosuu) kosuu = kosuucnt; + + /*--δ޷¡--*/ + if(kosuucnt == 0 ) return FALSE; + + i = 1; + + /*--Ҽ̻ 跴̻ﻥئ巴 --*/ + if(NPC_Util_GetArgStr( meindex, argstr, sizeof(argstr)) == NULL) { + print("shop_GetArgStr_Err"); + return FALSE; + } + + /*---ë ئľ1.0)-*/ + if(NPC_Util_GetStrFromStrWithDelim( argstr, "buy_rate", buf, sizeof( buf)) != NULL) { + rate= atof( buf); + } + +#ifdef _NEW_MANOR_LAW + memset(buff3,0,sizeof(buff3)); + memset(buff5,0,sizeof(buff5)); + if(NPC_Util_GetStrFromStrWithDelim(argstr,"CostVippoint",buff3,sizeof(buff3)) == NULL) iCostVippoint = -1; + if(NPC_Util_GetStrFromStrWithDelim(argstr,"ChangeItemCost",buff5,sizeof(buff5)) == NULL) iChangeItemCost = -1; +#endif + + /*--ʧ ةܰë浤Ƿ-*/ + if( NPC_Util_GetStrFromStrWithDelim( argstr, "ItemList", buf, sizeof( buf)) != NULL ){ + while(getStringFromIndexWithDelim(buf , "," , j, buff2, sizeof(buff2)) != FALSE ){ +#ifdef _NEW_MANOR_LAW + if(iCostVippoint > -1){ + if(getStringFromIndexWithDelim(buff3,",",j,buff4,sizeof(buff4)) != FALSE) iCostVippoint = atoi(buff4); + } + if(iChangeItemCost > -1){ + if(getStringFromIndexWithDelim(buff5,",",j,buff6,sizeof(buff6)) != FALSE) iChangeItemCost = atoi(buff6); + } +#endif + j++; + /*-- "-"ֳľ¾--*/ + if(strstr( buff2, "-") == NULL) { + if( ITEM_getcostFromITEMtabl(atoi(buff2)) !=-1) { + if ( i == select) { + /*---ʧ ة---*/ + /*----*/ +#ifdef _NEW_MANOR_LAW + if(NPC_AddItemVippointBuy(meindex, talker,atoi(buff2),kosuu,rate,iCostVippoint,iChangeItemCost) != TRUE) +#else + if(NPC_AddItemVippointBuy(meindex, talker,atoi(buff2),kosuu,rate) != TRUE) +#endif + { + return FALSE; + } + return TRUE; + } + i++; + } + }else{ + /*--ʧ ة 15-25 ƥ˪ľ--*/ + int start; + int end; + + /* "-"ƥľ炙Ѱ Ѱë --*/ + getStringFromIndexWithDelim( buff2, "-", 1, argstr, sizeof(argstr)); + start = atoi( argstr); + getStringFromIndexWithDelim( buff2, "-", 2 ,argstr, sizeof(argstr)); + end = atoi( argstr); + end++; + + /*-- įѱئȻգ ľ׸**/ + if(start > end){ + gold = start; + start = end; + end = gold; + } + + /*--"-"ƥľмʧ ةë ë --*/ + for(; start < end ; start++ ) { + if( ITEM_getcostFromITEMtabl( start) != -1) { + if ( i == select) { + /*---ʧ ة---*/ + /*----*/ +#ifdef _NEW_MANOR_LAW + if(NPC_AddItemVippointBuy(meindex, talker, start, kosuu, rate,iCostVippoint,iChangeItemCost) != TRUE) +#else + if(NPC_AddItemVippointBuy(meindex, talker, start, kosuu, rate) != TRUE) +#endif + { + return FALSE; + } + return TRUE; + } + i++; + } + } + } + } + } + + return FALSE; + +} + +/*--------------------------------------------- + *ʧ ةܰë浤 + *--------------------------------------------*/ +#ifdef _NEW_MANOR_LAW +BOOL NPC_AddItemVippointBuy(int meindex, int talker,int itemID,int kosuu,double rate,int iCostVippoint,int iChangeItemCost) +#else +BOOL NPC_AddItemVippointBuy(int meindex, int talker,int itemID,int kosuu,double rate) +#endif +{ + + int itemindex; + int i; + int gold; + int ret; + int maxgold; +#ifdef _NEW_MANOR_LAW + int iTotalCostVippoint = -1; +#endif + #ifdef _NEW_MANOR_LAW + if(iChangeItemCost > -1) gold = iChangeItemCost; + else + #endif + gold = ITEM_getcostFromITEMtabl( itemID); + gold = (int)(gold * rate); + + maxgold = gold * kosuu; + if(CHAR_getInt( talker, CHAR_GOLD) < maxgold ) return FALSE; +#ifdef _NEW_MANOR_LAW + if(iCostVippoint > 0){ + iTotalCostVippoint= iCostVippoint * kosuu; + if(sasql_vippoint(CHAR_getUseID(talker),0,0) < iTotalCostVippoint){ + CHAR_talkToCli( talker, meindex, "ĻԱ㲻㡣",CHAR_COLORWHITE); + return FALSE; + } + } +#endif + +// if( addNpcFamilyTax( meindex, talker, maxgold*0.4 ) ) +// print(" FamilyTaxDone! "); +// else +// print(" FamilyTaxError!"); + addNpcFamilyTax( meindex, talker, maxgold*0.4 ); + for(i = 0 ; i < kosuu ; i++){ + itemindex = ITEM_makeItemAndRegist( itemID); + + if(itemindex == -1) return FALSE; + ret = CHAR_addItemSpecificItemIndex( talker, itemindex); + if( ret < 0 || ret >= CHAR_MAXITEMHAVE ) { + print( "npc_itemshop.c: additem error itemindex[%d]\n", itemindex); + ITEM_endExistItemsOne( itemindex); + return FALSE; + } + CHAR_sendItemDataOne( talker, ret); + } + CHAR_DelGold( talker, maxgold); +#ifdef _NEW_MANOR_LAW + if(iTotalCostVippoint > 0){ + sasql_vippoint( CHAR_getUseID(talker), -iTotalCostVippoint,1); + char tmpbuf[128]; + sprintf( tmpbuf, "۳%dԱ", iTotalCostVippoint); + CHAR_talkToCli( talker, -1, tmpbuf, CHAR_COLORYELLOW); + } + //int fd = getfdFromCharaIndex( talker); + CHAR_charSaveFromConnect(talker, FALSE); + CHAR_talkToCli(talker, -1, "ϵͳΪԶ浵", CHAR_COLORRED); +#endif + //CHAR_send_P_StatusString( talker, CHAR_P_STRING_GOLD); + return TRUE; + +} + +//ѡ (,,ȥ) СӴ +void NPC_ItemVippointShop_Menu(int meindex,int talker) +{ + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + char token[NPC_UTIL_GETARGSTR_LINEMAX]; + char buff[256]; + int fd = getfdFromCharaIndex( talker); + + //argstrȡ趨ѶϢ: ->buy_rate:1.0|sell_rate:0.2|buy_msg:,,л,kau,buy............. (мķָǶʱ) + if(NPC_Util_GetArgStr( meindex, argstr, sizeof(argstr)) == NULL) { + print("shop_GetArgStr_Err"); + return; + } + + //tokenΪӴtitle : ķķߵ|ӭ + NPC_Util_GetStrFromStrWithDelim( argstr, "main_msg", buff, sizeof( buff)); +#ifdef _NEW_MANOR_LAW + snprintf(token, sizeof(token),"%s|%s|%d",CHAR_getChar(meindex,CHAR_NAME),buff,CHAR_getInt(talker,CHAR_FAME)/100); +#else + snprintf(token, sizeof(token),"%s|%s",CHAR_getChar( meindex, CHAR_NAME), buff); +#endif + + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_ITEMSHOPMENU, + WINDOW_BUTTONTYPE_NONE, + CHAR_WINDOWTYPE_WINDOWITEMSHOP_STARTMSG, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + token); + +} + +void NPC_ItemVippointShop_SellMain(int meindex,int talker,int before) +{ + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + char token[NPC_UTIL_GETARGSTR_BUFSIZE]; + int fd = getfdFromCharaIndex( talker); + + //ȡnpc趨 + if(NPC_Util_GetArgStr( meindex, argstr, sizeof(argstr)) == NULL) { + print("shop_GetArgStr_Err"); + return; + } + +#ifdef _ADD_STATUS_2 + sprintf(token,"FAME|%d",CHAR_getInt(talker,CHAR_FAME)/100); + lssproto_S2_send(fd,token); +#endif + + if(before != -1) { + sprintf(token,"1|0"); + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_ITEMSHOPMAIN + +CHAR_getWorkInt(meindex,NPC_SHOP_WORK_NO), + WINDOW_BUTTONTYPE_NONE, + CHAR_WINDOWTYPE_WINDOWITEMSHOP_SELL_MSG, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + token); + + }else{ + + char token2[NPC_UTIL_GETARGSTR_BUFSIZE]; + char buff2[256]; + char buff[256]; + + NPC_Util_GetStrFromStrWithDelim( argstr, "main_msg", buff, sizeof( buff)); + NPC_Util_GetStrFromStrWithDelim( argstr, "sell_main", buff2, sizeof( buff)); + sprintf( token, "1|1|%d|%s|%s|%s|", CHAR_WINDOWTYPE_WINDOWITEMSHOP_STARTMSG, + CHAR_getChar( meindex, CHAR_NAME), buff, buff2); + + NPC_Util_GetStrFromStrWithDelim( argstr, "stone_msg", buff, sizeof( buff)); + + if(CHAR_getWorkInt(meindex,NPC_SHOP_WORK_EXPRESS) == 1 ) { + NPC_Util_GetStrFromStrWithDelim( argstr, "exrealy_msg", buff2, sizeof(buff2)); + }else{ + NPC_Util_GetStrFromStrWithDelim( argstr, "realy_msg", buff2, sizeof( buff2)); + } + sprintf( token2,"%s|%s|", buff, buff2); + NPC_GetLimtItemVippointList( talker,argstr, token2, -1);//ϸҪĵ + strncat( token, token2, sizeof( token)); + + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_ITEMSHOPMAIN+ + CHAR_getWorkInt(meindex,NPC_SHOP_WORK_NO), + WINDOW_BUTTONTYPE_NONE, + CHAR_WINDOWTYPE_WINDOWITEMSHOP_SELL_MSG, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + token); + + } +} +int NPC_GetLimtItemVippointList(int talker, char *argstr, char* token2,int sell) +{ + + char token[NPC_UTIL_GETARGSTR_LINEMAX]; + char buff[NPC_UTIL_GETARGSTR_LINEMAX]; + char token3[NPC_UTIL_GETARGSTR_LINEMAX]; + int k = 0 , i = 1 , j = 0; + int imax; + int itemtype = 0; + int itemindex; + int okflg = 0; + char buf[256]; + int flg=0; + int cost; + + if(sell == -1 ){ + i = CHAR_STARTITEMARRAY; + imax = CHAR_MAXITEMHAVE; + flg = -1; + }else{ + i= sell; + imax= sell + 1; + flg = 1; + } + + for( ; i < imax ; i++ ){ + okflg=0; + itemindex = CHAR_getItemIndex( talker , i ); + + if( ITEM_CHECKINDEX( itemindex) ){ + if( NPC_Util_GetStrFromStrWithDelim( argstr,"LimitItemType", buff, sizeof( buff)) != NULL ){ + k = 1; + while(getStringFromIndexWithDelim(buff , "," , k, token, sizeof(token)) != FALSE ){ +#ifdef _ITEM_TYPETABLE + int cmpmaxitem = sizeof(TypeTable)/sizeof(TypeTable[0]); +#endif + k++; +#ifdef _ITEM_TYPETABLE + for(j = 0 ; j < cmpmaxitem ; j++){ +#else + for(j = 0 ; j < ITEM_CATEGORYNUM+3 ; j++){ +#endif + if(strcmp( TypeTable[ j].arg , token) == 0 ) { + itemtype = TypeTable[ j].type; + if(ITEM_getInt(itemindex,ITEM_TYPE) == itemtype) { + cost = NPC_GetSellItemVippointList(itemindex,0,argstr,token3,i,sell); + if(cost != -1) return cost; + strncat( token2, token3, sizeof( token3)); + okflg = 1; + }else if(itemtype == 30){ + if( 8 <= ITEM_getInt(itemindex,ITEM_TYPE) + && (ITEM_getInt(itemindex,ITEM_TYPE) <= 15) ){ + cost = NPC_GetSellItemVippointList(itemindex,0,argstr,token3,i,sell); + if(cost != -1) return cost; + strncat(token2,token3,sizeof(token3)); + okflg = 1; + } + }else if(itemtype == 40){ + if(( 0 <= ITEM_getInt(itemindex,ITEM_TYPE) + && (ITEM_getInt(itemindex,ITEM_TYPE) <= 4)) + || (17 <= ITEM_getInt(itemindex,ITEM_TYPE) + && (ITEM_getInt(itemindex,ITEM_TYPE) <= 19))) { + cost = NPC_GetSellItemVippointList(itemindex,0,argstr,token3,i,sell); + if(cost != -1) return cost; + strncat(token2,token3,sizeof(token3)); + okflg = 1; + } + }else if(itemtype == 50){ + if( 5 <= ITEM_getInt(itemindex,ITEM_TYPE) + && (ITEM_getInt(itemindex,ITEM_TYPE) <= 7) ){ + cost = NPC_GetSellItemVippointList(itemindex,0,argstr,token3,i,sell); + if(cost != -1) return cost; + strncat(token2,token3,sizeof(token3)); + okflg = 1; + } + } + break; + } + } + + if(okflg == 1) break; + } + } + if( (NPC_Util_GetStrFromStrWithDelim( argstr, "LimitItemNo", buff,sizeof( buff))!= NULL) && okflg == 0 ){ + k = 1; + while(getStringFromIndexWithDelim(buff , "," , k, token, sizeof(token)) != FALSE ){ + k++; + if(strstr( token, "-")==NULL && strcmp(token,"") != 0) { + if(ITEM_getInt(itemindex,ITEM_ID) == atoi(token)) { + cost = NPC_GetSellItemVippointList(itemindex,0,argstr,token3,i,sell); + if(cost != -1) return cost; + strncat(token2,token3,sizeof(token3)); + okflg=1; + } + }else if (strstr( token, "-") != NULL){ + int start, end; + int work; + + if( getStringFromIndexWithDelim( token, "-", 1, buf, sizeof(buf)) == FALSE ) + return -1; + start = atoi( buf); + if( getStringFromIndexWithDelim( token, "-", 2 ,buf, sizeof(buf)) == FALSE ) + return -1; + end = atoi( buf); + + if(start > end){ + work = start; + start = end; + end = work; + } + + end++; + if( (start <= ITEM_getInt(itemindex,ITEM_ID)) && (ITEM_getInt(itemindex,ITEM_ID) < end) ){ + cost = NPC_GetSellItemVippointList(itemindex,0,argstr,token3,i,sell); + if(cost != -1) return cost; + strncat(token2,token3,sizeof(token3)); + okflg = 1; + } + } + } + } + + if(okflg == 0) { + cost = NPC_GetSellItemVippointList(itemindex, 1, argstr, token3, i, sell); + if(sell != -1) return -1; + strncat( token2, token3, sizeof( token3)); + } + + } + } + return -1; +} + + + +/*---------------------------------------------------------- + + ͷʧ˪P + + *----------------------------------------------------------*/ +int NPC_GetSellItemVippointList(int itemindex,int flg, char *argstr,char *argtoken,int select,int sell) +{ + char buff[256]; + double rate = 0.2; + char buff2[256]; + char buff3[64]; + int k = 1; + int cost = -1; + + if(NPC_Util_GetStrFromStrWithDelim( argstr,"special_item",buff, sizeof( buff)) != NULL){ + if(NPC_Util_GetStrFromStrWithDelim( argstr,"special_rate",buff2, sizeof( buff2)) != NULL ){ + rate = atof(buff2); + }else{ + rate = 1.2; + } + + while(getStringFromIndexWithDelim(buff , "," , k, buff2, sizeof(buff2)) !=FALSE ){ + k++; + if(strstr( buff2, "-") == NULL && strcmp(buff2,"") != 0) { + if(ITEM_getInt(itemindex,ITEM_ID) == atoi(buff2)){ + cost = NPC_SellItemVippointstrsStr( itemindex,0, rate, argtoken,select,sell); + return cost; + } + }else if (strstr( buff2, "-") != NULL){ + int start; + int end; + int work; + getStringFromIndexWithDelim( buff2, "-", 1, buff3, sizeof(buff3)); + start = atoi( buff3); + getStringFromIndexWithDelim( buff2, "-", 2 ,buff3, sizeof(buff3)); + end = atoi( buff3); + + if(start > end){ + work = start; + start = end; + end = work; + } + end++; + if( (start <= ITEM_getInt(itemindex,ITEM_ID)) && (ITEM_getInt(itemindex,ITEM_ID) < end) ){ + cost = NPC_SellItemVippointstrsStr( itemindex,0, rate, argtoken,select,sell); + return cost; + } + } + } + } + if( NPC_Util_GetStrFromStrWithDelim( argstr,"sell_rate",buff, sizeof( buff)) != NULL ){ + rate = atof(buff); + cost = NPC_SellItemVippointstrsStr( itemindex, flg ,rate, argtoken,select,sell); + return cost; + } + + return cost; +} + +int NPC_SellItemVippointstrsStr(int itemindex,int flg,double rate,char *argtoken,int select,int sell) +{ + int cost; + char escapedname[256]; + char name[256]; + char *eff; + + + cost = ITEM_getInt( itemindex, ITEM_COST); + cost = (int)(cost * rate); + + if(sell != -1) return cost; + + strcpy( escapedname, ITEM_getChar( itemindex, ITEM_SECRETNAME)); + makeEscapeString( escapedname, name, sizeof( name)); + eff=ITEM_getChar(itemindex, ITEM_EFFECTSTRING); + makeEscapeString( eff, escapedname, sizeof(escapedname)); + + + + sprintf( argtoken, +#ifdef _ITEM_PILENUMS + "%s|%d|%d|%d|%s|%d|%d|", +#else + "%s|%d|%d|%d|%s|%d|", +#endif + name, flg, cost, + ITEM_getInt( itemindex, ITEM_BASEIMAGENUMBER), + escapedname, select +#ifdef _ITEM_PILENUMS + ,ITEM_getInt( itemindex, ITEM_USEPILENUMS) +#endif + ); + + return -1; + +} + +BOOL NPC_SellNewItemVippoint(int meindex,int talker,char *data) +{ + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + char token[256], token2[256]; + int cost, k, select, itemindex; + int MyGold, MaxGold, sellnum=1; + + MaxGold = CHAR_getMaxHaveGold( talker); + MyGold = CHAR_getInt( talker, CHAR_GOLD); + + if(NPC_Util_GetArgStr( meindex, argstr, sizeof(argstr)) == NULL) { + print("GetArgStrErr"); + return FALSE; + } + getStringFromIndexWithDelim(data , "|" ,1, token, sizeof( token)); + select = atoi(token); +#ifdef _ITEM_PILENUMS + getStringFromIndexWithDelim(data , "|" ,2, token, sizeof( token)); + sellnum = atoi(token); +#endif + + if( select < CHAR_STARTITEMARRAY || select >= CHAR_MAXITEMHAVE ) return FALSE; + k = select; + itemindex = CHAR_getItemIndex( talker , k); + cost = NPC_GetLimtItemVippointList( talker,argstr, token2,select); + if( cost == -1 || (cost*sellnum)+MyGold >= MaxGold || !ITEM_CHECKINDEX( itemindex) ){ + int fd = getfdFromCharaIndex( talker); + sprintf(token,"\n\nѽ!Բ" "\n\nԲ ! ɲѡһأ" ); + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + CHAR_WINDOWTYPE_WINDOWITEMSHOP_LIMIT, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + token); + return FALSE; + } +#ifdef _ITEM_PILENUMS + if( NPC_DelItem( talker, k, sellnum) == FALSE ) return FALSE; +#else + { + LogItem( + CHAR_getChar( talker, CHAR_NAME ), + CHAR_getChar( talker, CHAR_CDKEY ), +#ifdef _add_item_log_name // WON ADD itemlogitem + itemindex, +#else + ITEM_getInt( itemindex, ITEM_ID ), +#endif + "Sell()", + CHAR_getInt( talker,CHAR_FLOOR), + CHAR_getInt( talker,CHAR_X ), + CHAR_getInt( talker,CHAR_Y ), + ITEM_getChar( itemindex, ITEM_UNIQUECODE), + ITEM_getChar( itemindex, ITEM_NAME), + ITEM_getInt( itemindex, ITEM_ID) + + ); + } + CHAR_DelItem( talker, k); +#endif + CHAR_AddGold( talker, cost*sellnum); + CHAR_send_P_StatusString( talker, CHAR_P_STRING_GOLD); + return TRUE; +} + + + +void NPC_LimitItemVippointShop(int meindex,int talker,int select) +{ + + int fd = getfdFromCharaIndex( talker); + char token[NPC_UTIL_GETARGSTR_LINEMAX]; + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + char buf[1024]; + + if( NPC_Util_GetArgStr( meindex, argstr, sizeof(argstr)) == NULL) { + print("shop_GetArgStr_Err"); + return; + } + + if(NPC_Util_GetStrFromStrWithDelim( argstr, "sellonly_msg", buf, sizeof( buf))!=NULL){ + sprintf(token,"\n\n%s", buf); + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_YESNO, + CHAR_WINDOWTYPE_WINDOWITEMSHOP_LIMIT, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + token); + + }else{ + CHAR_talkToCli( talker, meindex, "רŵꡣ",CHAR_COLORWHITE); + } + return; +} + +void NPC_VippointExpressmanCheck(int meindex,int talker) +{ + int fd = getfdFromCharaIndex( talker); + char token[1024]; + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + char buf[1024]; + + if( NPC_Util_GetArgStr( meindex, argstr, sizeof(argstr)) == NULL) { + print("shop_GetArgStr_Err"); + return; + } + NPC_Util_GetStrFromStrWithDelim( argstr, "main_msg", buf, sizeof( buf)); + sprintf(token,"4\n%s\n\n%s" + "\n\n " + "\n\n " + ,CHAR_getChar(meindex,CHAR_NAME),buf); + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_SELECT, + WINDOW_BUTTONTYPE_CANCEL, + CHAR_WINDOWTYPE_WINDOWITEMSHOP_EXPRESS, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + token); + + return; + + +} + diff --git a/npc/npc_janken.c b/npc/npc_janken.c new file mode 100644 index 0000000..73e8e19 --- /dev/null +++ b/npc/npc_janken.c @@ -0,0 +1,512 @@ +#include "version.h" +#include +#include "common.h" +#include "char_base.h" +#include "npc_janken.h" +#include "npcutil.h" +#include "char.h" +#include "lssproto_serv.h" +#include "buf.h" +#include "function.h" +#include "readmap.h" +#include "object.h" +#include "log.h" + +/* + *Ԫ + */ +static void NPC_Janken_selectWindow( int meindex, int talker, int num); +void NPC_JnakenJudge(int meindex,int talker,int sel); +BOOL NPC_JankenEntryItemCheck(int talker,char *buf); +BOOL NPC_JankenEntryItemDel(int talker,char *buf); +void NPC_WarpPointGet(int meindex,int talker,int *fl,int *x,int *y,int judge); + + +/********************************* +* +*********************************/ +BOOL NPC_JankenInit( int meindex ) +{ + + //ë + CHAR_setInt( meindex , CHAR_WHICHTYPE , CHAR_TYPEJANKEN ); + + return TRUE; + +} + + +/********************************* +* ƾľݼ +*********************************/ +void NPC_JankenTalked( int meindex , int talkerindex , char *szMes , + int color ) +{ + /* 帲ƻ ɱ */ + if( CHAR_getInt( talkerindex , CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER ) { + return; + } + + /* */ + if( NPC_Util_CharDistance( talkerindex, meindex ) > 1) return; + + NPC_Janken_selectWindow(meindex, talkerindex, 0); + + + + +} + + + +/****************************** + * ľľ + ******************************/ +static void NPC_Janken_selectWindow( int meindex, int talker, int num) +{ + + char token[1024]; + char buf[32]; + int fd = getfdFromCharaIndex( talker); + int buttontype=0; + int windowtype=0; + int windowno=0; + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + + + /*--̼⻥мƥƱɬ--*/ + windowtype=WINDOW_MESSAGETYPE_MESSAGE; + + /*--ɬð̻ë --*/ + if(NPC_Util_GetArgStr( meindex, argstr, sizeof(argstr))==NULL){ + print("NPC_janken Init: GetArgStrErr"); + return ; + } + + + switch( num) + { + case 0: + + /*-- ⻥ ľɾ޷¡ --*/ + if(NPC_Util_GetStrFromStrWithDelim( argstr, "MainMsg", token, sizeof( token)) == NULL) + { + print("Janken:MainMsg:%s", CHAR_getChar( meindex, CHAR_NAME)); + return ; + } + + /*-- --*/ + buttontype = WINDOW_BUTTONTYPE_YESNO; + windowtype = WINDOW_MESSAGETYPE_MESSAGE; + windowno = CHAR_WINDOWTYPE_JANKEN_START; + break; + + + case 1: + + //ʧ ة + if(NPC_Util_GetStrFromStrWithDelim( argstr, "EntryItem", buf, sizeof( buf))!= NULL) { + + if(NPC_JankenEntryItemCheck(talker,buf) == FALSE) + { + NPC_Janken_selectWindow(meindex, talker, 3); + } + + //޼üʧ ةë + if(NPC_JankenEntryItemDel(talker,buf) == FALSE){ + print("ԪERR:ʧ ةƱ"); + } + } + + + /*-- --*/ + sprintf(token," ʯͷ\n" + "\n\n ʯͷ " + "\n\n " + "\n\n " + ); + + buttontype=WINDOW_BUTTONTYPE_NONE; + windowtype=WINDOW_MESSAGETYPE_SELECT; + windowno=CHAR_WINDOWTYPE_JANKEN_MAIN; + break; + + case 2: + /*--ؤг --*/ + //sprintf(token," ؤгƥ\n" + sprintf(token," ƽ\n" + "\n\n ʯͷ " + "\n\n " + "\n\n " + ); + + buttontype=WINDOW_BUTTONTYPE_NONE; + windowtype=WINDOW_MESSAGETYPE_SELECT; + windowno=CHAR_WINDOWTYPE_JANKEN_MAIN; + break; + + case 3: + /*-- ⻥ ľɾ޷¡ --*/ + NPC_Util_GetStrFromStrWithDelim( argstr, "NoItem", token, sizeof( token)); + + buttontype=WINDOW_BUTTONTYPE_OK; + windowtype=WINDOW_MESSAGETYPE_MESSAGE; + windowno=CHAR_WINDOWTYPE_JANKEN_END; + + break; + + } + + +// makeEscapeString( token, escapedname, sizeof(escapedname)); + /*-ƥ˪--*/ + lssproto_WN_send( fd, windowtype, + buttontype, + windowno, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + token); + + + +} + + + +/********************************* +* ū帲 +*********************************/ +void NPC_JankenWindowTalked( int meindex, int talkerindex, + int seqno, int select, char *data) +{ + /* */ + if( NPC_Util_CharDistance( talkerindex, meindex ) > 1) return; + + switch( seqno){ + case CHAR_WINDOWTYPE_JANKEN_START: + + if(select==WINDOW_BUTTONTYPE_YES){ + NPC_Janken_selectWindow(meindex, talkerindex, 1); + } + break; + + case CHAR_WINDOWTYPE_JANKEN_MAIN: + if (atoi(data) >= 3){ + NPC_JnakenJudge(meindex,talkerindex,atoi(data) ); + } + break; + } +} + + +/* + *Ҽ + */ +void NPC_JnakenJudge(int meindex,int talker,int sel) +{ + int player=-1; + int jankenman; + char j_char[3][8]={" ʯͷ "," "," "}; + char token[1024]; + int shouhai = 0; + int fd = getfdFromCharaIndex( talker); + int fl=0,x=0,y=0; + + + if(sel == 3) player = 0; // + if(sel == 5) player = 1; //ƽ + if(sel == 7) player = 2; //ɡ + + jankenman = rand()%3; + + switch(jankenman){ + case 0: + if(player == 2){ + shouhai = 1; + }else if(player == 1){ + shouhai = 2; + } + break; + + case 1: + if(player == 0){ + shouhai = 1; + }else if(player == 2){ + shouhai = 2; + } + break; + + case 2: + if(player == 1){ + shouhai = 1; + }else if(player == 0){ + shouhai = 2; + } + break; + } + + if(shouhai == 1){ + //Change add Ҳʤ˸ĵ + NPC_JankenItemGet( meindex, talker, "WinItem" ); + + NPC_WarpPointGet(meindex, talker, &fl, &x, &y, 0); + + snprintf( token, sizeof( token ) , + " \n\n" + " %16s %-16s\n" + " [%s] VS [%s]\n\n\n" + " %-16s ʤ", + CHAR_getChar(meindex,CHAR_NAME),CHAR_getChar(talker,CHAR_NAME), + j_char[jankenman],j_char[player], + CHAR_getChar(talker,CHAR_NAME) + ); + +// CHAR_talkToCli( talker , -1 ,token , CHAR_COLORCYAN ); + + // + CHAR_warpToSpecificPoint(talker, fl, x, y); + + // 巴٣ʧë£ + CHAR_sendWatchEvent( CHAR_getWorkInt( talker, CHAR_WORKOBJINDEX), CHAR_ACTPLEASURE,NULL,0,TRUE); + CHAR_setWorkInt( talker, CHAR_WORKACTION, CHAR_ACTPLEASURE); + + }else if(shouhai == 2){ + + //Change add Ҳ˸ĵ + NPC_JankenItemGet( meindex, talker, "LoseItem" ); + + NPC_WarpPointGet(meindex, talker, &fl, &x, &y, 1); + snprintf( token, sizeof( token ) , + " \n\n" + " %16s %-16s\n" + " [%s] VS [%s]\n\n\n" + " %-16s ", + CHAR_getChar(meindex,CHAR_NAME),CHAR_getChar(talker,CHAR_NAME), + j_char[jankenman],j_char[player], + CHAR_getChar(talker,CHAR_NAME) + ); +// CHAR_talkToCli( talker , -1 ,token , CHAR_COLORCYAN ); + + // + CHAR_warpToSpecificPoint(talker, fl, x, y); + + // 巴 Уʧë + CHAR_sendWatchEvent( CHAR_getWorkInt( talker, CHAR_WORKOBJINDEX), CHAR_ACTSAD,NULL,0,TRUE); + CHAR_setWorkInt( talker, CHAR_WORKACTION, CHAR_ACTSAD); + + + }else{ + //ؤг + NPC_Janken_selectWindow( meindex, talker, 2); + return; + } + + //˪ + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + CHAR_WINDOWTYPE_JANKEN_END, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + token); + + + +} + + +/* + *ëGET£ + */ +void NPC_WarpPointGet(int meindex,int talker,int *fl,int *x,int *y,int judge) +{ + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + char *strbuf[2] = {"WinWarp","LoseWarp"}; + char buf[64]; + char buf2[32]; + + /*--ɬð̻ë --*/ + if(NPC_Util_GetArgStr( meindex, argstr, sizeof(argstr))==NULL){ + print("NPC_janken Init: GetArgStrErr"); + return ; + } + + + /*--ë --*/ + NPC_Util_GetStrFromStrWithDelim( argstr, strbuf[judge], buf, sizeof( buf)); + getStringFromIndexWithDelim(buf,",",1,buf2,sizeof(buf2)); + *fl=atoi(buf2); + getStringFromIndexWithDelim(buf,",",2,buf2,sizeof(buf2)); + *x=atoi(buf2); + getStringFromIndexWithDelim(buf,",",3,buf2,sizeof(buf2)); + *y=atoi(buf2); + + +} + +/* + *--ʧ ةͷë浤 + */ +BOOL NPC_JankenEntryItemCheck(int talker,char *buf) +{ + + char buf2[512]; + char buf3[256]; + int id=0; + BOOL flg = FALSE; + int i; + int itemindex; + int itemno; + int kosuu; + int cnt=0; + int k=1; + + while(getStringFromIndexWithDelim(buf , "," , k, buf2, sizeof(buf2)) + !=FALSE ) + { + flg = FALSE; + k++; + + if(strstr(buf2,"*") != NULL){ + cnt = 0; + getStringFromIndexWithDelim(buf2,"*",1,buf3,sizeof(buf3)); + itemno = atoi(buf3); + getStringFromIndexWithDelim(buf2,"*",2,buf3,sizeof(buf3)); + kosuu = atoi(buf3); + + for( i=0 ; i < CHAR_MAXITEMHAVE;i++ ){ + itemindex = CHAR_getItemIndex( talker , i ); + if( ITEM_CHECKINDEX(itemindex) ){ + id = ITEM_getInt(itemindex ,ITEM_ID ); + if(itemno == id){ + cnt++; + if(cnt == kosuu){ + flg = TRUE; + break; + } + } + } + } + if(flg == FALSE) + { + return FALSE; + } + }else{ + itemno = atoi(buf2); + + for( i=0 ; i < CHAR_MAXITEMHAVE;i++ ){ + itemindex = CHAR_getItemIndex( talker , i ); + if( ITEM_CHECKINDEX(itemindex) ){ + id = ITEM_getInt(itemindex ,ITEM_ID ); + if(itemno == id){ + flg = TRUE; + break; + } + } + } + + if(flg == FALSE) + { + return FALSE; + } + } + } + + return TRUE; + +} + +BOOL NPC_JankenEntryItemDel(int talker,char *buf) +{ + + int i = 1, j = 1,k = 1; + char buff3[128]; + char buf2[32]; + int itemindex; + + while(getStringFromIndexWithDelim(buf , "," , k, buff3, sizeof(buff3)) !=FALSE ){ + k++; + if(strstr(buff3, "*") !=NULL){ + int itemno; + int kosuu; + int id; + int cnt=0; + getStringFromIndexWithDelim(buff3,"*",1,buf2,sizeof(buf2)); + itemno = atoi(buf2); + getStringFromIndexWithDelim(buff3,"*",2,buf2,sizeof(buf2)); + kosuu = atoi(buf2); + for( i =0 ; i < CHAR_MAXITEMHAVE ; i++ ){ + itemindex = CHAR_getItemIndex( talker , i ); + if( ITEM_CHECKINDEX(itemindex) ){ + id=ITEM_getInt(itemindex ,ITEM_ID ); + if(itemno==id){ + cnt++; + LogItem( + CHAR_getChar( talker, CHAR_NAME ), /* ƽҷ */ + CHAR_getChar( talker, CHAR_CDKEY ), +#ifdef _add_item_log_name // WON ADD itemlogitem + itemindex, +#else + ITEM_getInt( itemindex, ITEM_ID), /* ʧ ة į */ +#endif + "QuizDelItem(->)", + CHAR_getInt( talker, CHAR_FLOOR), + CHAR_getInt( talker, CHAR_X ), + CHAR_getInt( talker, CHAR_Y ), + ITEM_getChar( itemindex, ITEM_UNIQUECODE), + ITEM_getChar( itemindex, ITEM_NAME), + ITEM_getInt( itemindex, ITEM_ID) + ); + CHAR_DelItem( talker, i); + if(cnt == kosuu){ + break; + } + } + } + } + }else{ + /*--Ϸ įʧ ةë---*/ + for( j = 0 ; j < CHAR_MAXITEMHAVE ; j++){ + itemindex = CHAR_getItemIndex( talker ,j); + + if( ITEM_CHECKINDEX(itemindex) ){ + if( atoi( buff3) == ITEM_getInt(itemindex,ITEM_ID)){ + LogItem( + CHAR_getChar( talker, CHAR_NAME ), /* ƽҷ */ + CHAR_getChar( talker, CHAR_CDKEY ), +#ifdef _add_item_log_name // WON ADD itemlogitem + itemindex, +#else + ITEM_getInt( itemindex, ITEM_ID), /* ʧ ة į */ +#endif + "QuizDelItem(->)", + CHAR_getInt( talker,CHAR_FLOOR), + CHAR_getInt( talker,CHAR_X ), + CHAR_getInt( talker,CHAR_Y ), + ITEM_getChar( itemindex, ITEM_UNIQUECODE), + ITEM_getChar( itemindex, ITEM_NAME), + ITEM_getInt( itemindex, ITEM_ID) + ); + CHAR_DelItem( talker, j); + } + } + } + } + } + + return TRUE; +} + +BOOL NPC_JankenItemGet(int meindex,int talker, char *wl) +{ + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + char buf[64]; + + /*--ɬð̻ë --*/ + if(NPC_Util_GetArgStr( meindex, argstr, sizeof(argstr))==NULL){ + print("NPC_janken ItemGet: GetArgStrErr"); + return FALSE; + } + + if(NPC_Util_GetStrFromStrWithDelim( argstr, wl, buf, sizeof( buf) ) !=NULL){ + NPC_EventAddItem( meindex, talker, buf); + } +} + diff --git a/npc/npc_luckyman.c b/npc/npc_luckyman.c new file mode 100644 index 0000000..fd52f20 --- /dev/null +++ b/npc/npc_luckyman.c @@ -0,0 +1,239 @@ +#include "version.h" +#include +#include "char.h" +#include "object.h" +#include "char_base.h" +#include "npcutil.h" +#include "lssproto_serv.h" +#include "npc_luckyman.h" + + +static void NPC_LuckyMan_selectWindow( int meindex, int toindex, int num,char *msg); +void NPC_LuckyManAllHeal( int talker,int mode ); +BOOL NPC_LuckyManLevelCheck(int meindex,int talker); +void NPC_LuckyDisp(int meindex,int talker); +BOOL NPC_LuckyCostCheck(int meindex,int talker,int cost); +int NPC_GetMoney(int meindex,int talker,char *buf); + + + +/********************************* +* +*********************************/ +BOOL NPC_LuckyManInit( int meindex ) +{ + + /*--ƽҷ¼ëɬ--**/ + CHAR_setInt( meindex , CHAR_WHICHTYPE , CHAR_TYPELUCKYMAN ); + + return TRUE; +} + + + + +/********************************* +* ƾľݼ +*********************************/ +void NPC_LuckyManTalked( int meindex , int talkerindex , char *szMes ,int color ) +{ + + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + char buf[256]; + char token[512]; + int cost; + + + + /*-- ¾--*/ + if(NPC_Util_isFaceToFace( meindex ,talkerindex ,2) == FALSE) { + /* */ + if(NPC_Util_isFaceToChara( talkerindex, meindex, 1) == FALSE) return; + } + + /*--ɬð̻ë --*/ + if(NPC_Util_GetArgStr( meindex, argstr, sizeof( argstr)) == NULL) { + print("NPC_ExChange.c TypeCheck: GetArgStrErr\n"); + print("NPCName=%s\n", CHAR_getChar( meindex, CHAR_NAME)); + return; + } + + + NPC_Util_GetStrFromStrWithDelim( argstr,"Stone", buf, sizeof( buf)); + cost = NPC_GetMoney( meindex, talkerindex, buf); + + NPC_Util_GetStrFromStrWithDelim( argstr,"main_msg", buf, sizeof( buf)); + sprintf( token, buf, cost); + + NPC_LuckyMan_selectWindow( meindex, talkerindex, 2, token); + +} + + +static void NPC_LuckyMan_selectWindow( int meindex, int toindex, int num,char *msg) +{ + + int fd = getfdFromCharaIndex( toindex); + char token[1024]; + int buttontype = 0,windowtype = 0,windowno = 0; + + + switch( num){ + case 1: + sprintf(token ,"յơ" + "\n\n%s",msg + ); + buttontype = WINDOW_BUTTONTYPE_OK; + windowtype = WINDOW_MESSAGETYPE_MESSAGE; + windowno = CHAR_WINDOWTYPE_WINDOWPETSHOP_START; + break; + + case 2: + sprintf(token, "ռʦ" + "\n\n%s",msg + ); + buttontype = WINDOW_BUTTONTYPE_YESNO; + windowtype = WINDOW_MESSAGETYPE_MESSAGE; + windowno = CHAR_WINDOWTYPE_WINDOWPETSHOP_START; + break; + + case 3: + sprintf(token, "ռʦ" + "\n\n%s",msg + ); + buttontype = WINDOW_BUTTONTYPE_OK; + windowtype = WINDOW_MESSAGETYPE_MESSAGE; + windowno = CHAR_WINDOWTYPE_WINDOWPETSHOP_START; + break; + } + + + /*--˪--*/ + lssproto_WN_send( fd, windowtype, + buttontype, + windowno, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + token); + + +} + + +/*----------------------------------------- +ͷʧ߯Ȼݱ̫ľ£ +-------------------------------------------*/ +void NPC_LuckyManWindowTalked( int meindex, int talkerindex, + int seqno, int select, char *data) +{ + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + char buf[256]; + int money; + int level; + + /*--ɬð̻ë --*/ + if(NPC_Util_GetArgStr( meindex, argstr, sizeof(argstr)) == NULL) { + print("NPC_ExChange.c TypeCheck: GetArgStrErr\n"); + print("NPCName=%s\n", CHAR_getChar(meindex,CHAR_NAME)); + return; + } + + switch( seqno){ + case CHAR_WINDOWTYPE_WINDOWPETSHOP_START: + if(select == WINDOW_BUTTONTYPE_YES) { + NPC_Util_GetStrFromStrWithDelim( argstr, "Stone", buf,sizeof(buf)); + + if(strstr(buf,"LV") != NULL) { + char buff2[32]; + level = CHAR_getInt( talkerindex, CHAR_LV); + getStringFromIndexWithDelim( buf, "*", 2, buff2,sizeof( buff2)); + money = level * atoi( buff2); + + if(NPC_LuckyCostCheck(meindex,talkerindex,money) == FALSE) { + NPC_Util_GetStrFromStrWithDelim( argstr,"NoMoney", buf, sizeof( buf)); + NPC_LuckyMan_selectWindow( meindex, talkerindex, 3, buf); + return; + } + }else{ + money = atoi( buf); + if(NPC_LuckyCostCheck(meindex,talkerindex ,money) == FALSE) { + NPC_Util_GetStrFromStrWithDelim( argstr,"NoMoney", buf,sizeof( buf)); + NPC_LuckyMan_selectWindow( meindex, talkerindex, 3, buf); + return; + } + } + + CHAR_DelGold( talkerindex, money ); + + CHAR_send_P_StatusString( talkerindex, CHAR_P_STRING_GOLD); + NPC_LuckyDisp( meindex, talkerindex); + + }else if(select == WINDOW_BUTTONTYPE_OK) { + + } + break; + } +} + + + +void NPC_LuckyDisp(int meindex,int talker) +{ + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + char buf[16]; + char token[1024]; + char buf2[512]; + int i = 1; + + /*--ɬð̻ë --*/ + if(NPC_Util_GetArgStr( meindex, argstr, sizeof( argstr)) == NULL) { + print("NPC_Savepoint.c Init: GetArgStrErr"); + return; + } + + /*--ëέ--*/ + sprintf( buf, "luck%d", CHAR_getInt( talker, CHAR_LUCK)); + NPC_Util_GetStrFromStrWithDelim( argstr, buf, buf2, sizeof( buf2)); + + while(getStringFromIndexWithDelim( buf2, ",", i, token, sizeof( token)) + != FALSE) + { + i++; + } + i--; + i = rand()%i + 1; + + /*--¼ĸةƥë --*/ + getStringFromIndexWithDelim( buf2,",", i, token, sizeof( token)); + NPC_LuckyMan_selectWindow( meindex, talker, 1, token); +} + + +/*---ż-**/ +BOOL NPC_LuckyCostCheck(int meindex,int talker,int cost) +{ + /*--ػɬ---*/ + /*---ŻԻ¾---*/ + if(CHAR_getInt( talker, CHAR_GOLD) < cost) { + return FALSE; + } + return TRUE; + +} + + +int NPC_GetMoney(int meindex,int talker,char *buf) +{ + int level; + int money; + + if(strstr(buf,"LV") != NULL) { + char buff2[32]; + level = CHAR_getInt(talker,CHAR_LV); + getStringFromIndexWithDelim( buf, "*" ,2, buff2,sizeof( buff2)); + money = level * atoi( buff2); + }else{ + money = atoi( buf); + } + return money; + +} diff --git a/npc/npc_makepair.c b/npc/npc_makepair.c new file mode 100644 index 0000000..13be140 --- /dev/null +++ b/npc/npc_makepair.c @@ -0,0 +1,542 @@ +#include "version.h" +#include +#include "char.h" +#include "object.h" +#include "char_base.h" +#include "npcutil.h" +#include "npc_transerman.h" +#include "lssproto_serv.h" +#include "saacproto_cli.h" +#include "readmap.h" +#include "battle.h" +#include "log.h" +#include "enemy.h" +#include "handletime.h" +#include "npc_makepair.h" +#include "npc_eventaction.h" + +#ifdef _NPC_MAKEPAIR +#define MAXPAIRNUMS 30 +PairMenu PairList[2][MAXPAIRNUMS]; + +enum { + WINDOW_START=10, + WINDOW_USER, + WINDOW_SELECT, // + WINDOW_PAIR, //Ҷ + WINDOW_PAIROK, + WINDOW_PAIRNO, + WINDOW_WARP, //Ծ + WINDOW_END, // + WINDOW_TALKSTART=20, + WINDOW_TALKSELECT, + WINDOW_TALKPAIR, + WINDOW_RETURN, + WINDOW_TALKEND, +}; +enum { + NPC_WORK_CURRENTTIME = CHAR_NPCWORKINT1, + NPC_WORK_PAIRTEAMS = CHAR_NPCWORKINT2, +/* + NPC_WORK_ROUTEPOINT = CHAR_NPCWORKINT3, + NPC_WORK_ROUNDTRIP = CHAR_NPCWORKINT4, + NPC_WORK_MODE = CHAR_NPCWORKINT5, + NPC_WORK_CURRENTROUTE = CHAR_NPCWORKINT6, + NPC_WORK_ROUTEMAX = CHAR_NPCWORKINT7, + NPC_WORK_WAITTIME = CHAR_NPCWORKINT8, + NPC_WORK_CURRENTTIME = CHAR_NPCWORKINT9, + NPC_WORK_SEFLG = CHAR_NPCWORKINT10, +*/ +}; +#define MAKEPAIR_STANDBY 100*60 +static void NPC_MakePair_selectWindow( int meindex, int toindex, int num,int select); +BOOL MakePairMan_GetMenuStr( int meindex, int toindex, char *npcarg, char *token); +void CheckPairUsers( int *male, int *female); +BOOL NPC_PairForage( int meindex, int toindex, char *arg, char *token); +BOOL NPC_PairRegister( int toindex); +void NPC_PairUserAndWarp( int meindex, int toindex, int forindex, char *arg); +int NPC_getPairCode( int toindex); +int NPC_getTitleMsg( int meindex, int toindex, char *arg, char *token, int title); +int NPC_getNextTitle( int meindex, int toindex, char *arg, int title, int select); + + +BOOL NPC_MakePairManInit( int meindex ) +{ + char npcarg[NPC_UTIL_GETARGSTR_BUFSIZE]; + int i; + if(NPC_Util_GetArgStr( meindex, npcarg, sizeof(npcarg))==NULL){ + print("err NPC_MakePairMan: GetArgStrErr!!"); + return FALSE; + } + CHAR_setInt( meindex, CHAR_WHICHTYPE, CHAR_MAKEPAIR); + CHAR_setInt( meindex, CHAR_LOOPINTERVAL, MAKEPAIR_STANDBY); + CHAR_setWorkInt( meindex, NPC_WORK_CURRENTTIME, NowTime.tv_sec); + CHAR_setWorkInt( meindex, NPC_WORK_PAIRTEAMS, 0); + + for( i=0; i 0){ + CHAR_setWorkInt( toindex, CHAR_MYPAIRINDEX, -1); + sprintf( token, "ȡǰһε롣"); + }else { + char buf1[256]; + if( NPC_Util_GetStrFromStrWithDelim( npcarg, "FREE", buf1, sizeof( buf1) ) != NULL) { + if( NPC_ActionPassCheck( meindex, toindex, buf1) == FALSE ){ + CHAR_talkToCli( toindex, meindex, "㣡", CHAR_COLORYELLOW); + return; + } + } + NPC_PairForage( meindex, toindex, npcarg, token); + } + buttontype = WINDOW_BUTTONTYPE_OK; + windowno = WINDOW_TALKEND; + } + break; + case WINDOW_PAIROK: //ͬ + if( CHAR_getWorkInt( toindex, CHAR_MYPAIRFLG) > 0){ + int forindex = CHAR_getWorkInt( toindex, CHAR_MYPAIRINDEX); + NPC_PairUserAndWarp( meindex, toindex, forindex, npcarg); + } + return; + case WINDOW_PAIRNO://ͬ + { + int forindex = CHAR_getWorkInt( toindex, CHAR_MYPAIRINDEX); + if( CHAR_CHECKINDEX( forindex) ){ + if( CHAR_getWorkInt( forindex, CHAR_MYPAIRFLG) > 0 ){ + CHAR_talkToCli( forindex, meindex, "Էܾ롣", CHAR_COLORYELLOW); + CHAR_setWorkInt( forindex, CHAR_MYPAIRINDEX, -1); + CHAR_setWorkInt( forindex, CHAR_MYPAIRFLG, -1); + } + } + CHAR_setWorkInt( toindex, CHAR_MYPAIRINDEX, -1); + CHAR_setWorkInt( toindex, CHAR_MYPAIRFLG, -1); + CHAR_talkToCli( toindex, meindex, "ܾԷ롣", CHAR_COLORYELLOW); + return; + } + break; + case WINDOW_WARP: + break; + case WINDOW_END: + break; + } + lssproto_WN_send( fd, windowtype, buttontype, windowno, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), token); +} + +void NPC_MakePairManWindowTalked( int meindex, int talkerindex, int seqno, int select, char *data) +{ + char npcarg[NPC_UTIL_GETARGSTR_BUFSIZE]; + + if( CHAR_getInt( talkerindex , CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER ) + return; + memset( npcarg, 0, sizeof( npcarg)); + if(NPC_Util_GetArgStr( meindex, npcarg, sizeof(npcarg))==NULL){ + print("err NPC_MakePairMan: GetArgStrErr!!"); + return; + } + switch( seqno) { + case WINDOW_TALKSTART: + { + int choose=atoi( data); + if( select == WINDOW_BUTTONTYPE_CANCEL || select == WINDOW_BUTTONTYPE_NO) + return; + switch( choose){ + case 1:// + NPC_MakePair_selectWindow( meindex, talkerindex, WINDOW_USER, 0); + break; + case 2:// + NPC_MakePair_selectWindow( meindex, talkerindex, WINDOW_PAIR, 0); + break; + case 3:// + NPC_MakePair_selectWindow( meindex, talkerindex, WINDOW_SELECT, 0); + break; + } + } + + break; + case WINDOW_TALKSELECT: + { + int title = CHAR_getWorkInt( talkerindex, CHAR_WORKSHOPRELEVANT); + title = NPC_getNextTitle( meindex, talkerindex, npcarg, title, select); + if( title < 0 ) return ; + CHAR_setWorkInt( talkerindex, CHAR_WORKSHOPRELEVANT, title); + NPC_MakePair_selectWindow( meindex, talkerindex, WINDOW_SELECT, select); + } + break; + case WINDOW_TALKPAIR://ظ + if( select == WINDOW_BUTTONTYPE_CANCEL || select == WINDOW_BUTTONTYPE_NO){ + NPC_MakePair_selectWindow( meindex, talkerindex, WINDOW_PAIRNO, 0); + }else { + NPC_MakePair_selectWindow( meindex, talkerindex, WINDOW_PAIROK, 0); + } + break; + case WINDOW_RETURN: + NPC_MakePair_selectWindow( meindex, talkerindex, WINDOW_START, 0); + break; + case WINDOW_TALKEND: + break; + } +} +void NPC_MakePairManLoop( int meindex) +{ + int i; + for( i=0; i 0 ){ + if( !CHAR_CHECKINDEX( PairList[0][i].pindex) ){ + PairList[0][i].pindex = -1; + PairList[0][i].use = -1; + } + } + if( PairList[1][i].use > 0 ){ + if( !CHAR_CHECKINDEX( PairList[1][i].pindex) ){ + PairList[1][i].pindex = -1; + PairList[1][i].use = -1; + } + } + } +} + +BOOL MakePairMan_GetMenuStr( int meindex, int toindex, char *npcarg, char *token) +{ + char buf1[1024], buf2[256], buf3[256]; + BOOL FINDS=FALSE; + int talkNo=1; + if( npcarg == NULL ) return FALSE; + + if( NPC_Util_GetStrFromStrWithDelim( npcarg, "MenuHead", buf1, sizeof( buf1) ) == NULL){ + return FALSE; + } + sprintf( token, "%s\n", buf1); + + sprintf( buf1, "MEMU%d", talkNo); + while( NPC_Util_GetStrFromStrWithDelim( npcarg, buf1, buf2, sizeof( buf2)) != NULL ) { + talkNo++; + sprintf( buf1, "MEMU%d", talkNo); + FINDS = TRUE; + sprintf( buf3, " %s\n", buf2); + strcat( token, buf3); + } + return FINDS; +} + +void CheckPairUsers( int *male, int *female) +{ + int i; + *male = 0; + *female = 0; + for( i=0; i 0 ) *male+=1; + if( PairList[1][i].use > 0 ) *female+=1; + } +} + +BOOL NPC_PairForage( int meindex, int toindex, char *arg, char *token) +{ + char buf1[256]; + int i; + int codes = CHAR_getWorkInt( toindex, CHAR_MYPAIRCODE); + int Psex = CHAR_getSexInt( CHAR_getInt( toindex, CHAR_BASEBASEIMAGENUMBER) ); + Psex = (Psex==1)?1:0; + + + for( i=0; i 0 ) continue; + name = CHAR_getChar( PairList[Psex][i].pindex, CHAR_NAME); + cdKey = CHAR_getChar( PairList[Psex][i].pindex, CHAR_CDKEY); + if( strcmp( PairList[Psex][i].name, name) || strcmp( PairList[Psex][i].cdKey, cdKey) ){ + PairList[Psex][i].use = -1; + PairList[Psex][i].forindex = -1; + continue; + } + sprintf( token, "ԶΪ %s\nͳ룬ȺԷӦ", name); + if( NPC_Util_GetStrFromStrWithDelim( arg, "InviteMsg", buf1, sizeof( buf1) ) == NULL){ + break; + } + PairList[Psex][i].forindex = toindex; + fd = getfdFromCharaIndex( PairList[Psex][i].pindex); + + CHAR_setWorkInt( toindex, CHAR_MYPAIRFLG, 1); + CHAR_setWorkInt( toindex, CHAR_MYPAIRINDEX, PairList[Psex][i].pindex); + CHAR_setWorkInt( PairList[Psex][i].pindex, CHAR_MYPAIRFLG, 2); + CHAR_setWorkInt( PairList[Psex][i].pindex, CHAR_MYPAIRINDEX, toindex); + + name = CHAR_getChar( toindex, CHAR_NAME); + sprintf( buf, "%s\n%s\n%s", CHAR_getChar( meindex, CHAR_NAME),name, buf1); + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, WINDOW_BUTTONTYPE_OKCANCEL, WINDOW_TALKPAIR, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), buf); + break; + } + if( i>= MAXPAIRNUMS ) { + if( NPC_Util_GetStrFromStrWithDelim( arg, "NoPairMsg", buf1, sizeof( buf1) ) != NULL){ + sprintf( token, "%s",buf1); + }else { + sprintf( token, "ûҵ"); + } + if( CHAR_getWorkInt( toindex, CHAR_MYPAIRFLG) <= 0 ) { + NPC_PairRegister( toindex); + } + return FALSE; + } + return TRUE; +} + +BOOL NPC_PairRegister( int toindex) +{ + char *cdKey = CHAR_getChar( toindex, CHAR_CDKEY); + char *name = CHAR_getChar( toindex, CHAR_NAME); + int space=-1,i; + int Psex = CHAR_getSexInt( CHAR_getInt( toindex, CHAR_BASEBASEIMAGENUMBER) ); + Psex = (Psex==1)?0:1; + for( i=0; i=MAXPAIRNUMS){ + if( space != -1 && CHAR_getWorkInt( toindex, CHAR_MYPAIRCODE) > 0 ){ + PairList[Psex][space].use = 1; + PairList[Psex][space].forindex = -1; + sprintf( PairList[Psex][space].cdKey, "%s", cdKey); + sprintf( PairList[Psex][space].name, "%s", name); + PairList[Psex][space].pindex = toindex; + PairList[Psex][space].code = CHAR_getWorkInt( toindex, CHAR_MYPAIRCODE); + + CHAR_talkToCli( toindex, -1, "", CHAR_COLORYELLOW); + return TRUE; + } + } + return FALSE; +} + +void NPC_PairUserAndWarp( int meindex, int toindex, int forindex, char *arg) +{ + char buf1[256]; + int fl=-1, x=-1, y=-1; + + if( !CHAR_CHECKINDEX( toindex)) return; + CHAR_setWorkInt( toindex, CHAR_MYPAIRINDEX, -1); + CHAR_setWorkInt( toindex, CHAR_MYPAIRFLG, -1); + if( !CHAR_CHECKINDEX( forindex)) return; + CHAR_setWorkInt( forindex, CHAR_MYPAIRINDEX, -1); + CHAR_setWorkInt( forindex, CHAR_MYPAIRFLG, -1); + + if( CHAR_getWorkInt( toindex, CHAR_WORKBATTLEMODE) != BATTLE_CHARMODE_NONE ) return; + if( CHAR_getWorkInt( forindex, CHAR_WORKBATTLEMODE) != BATTLE_CHARMODE_NONE ) return; + + if( NPC_Util_GetStrFromStrWithDelim( arg, "PAIRTOPOINT", buf1, sizeof( buf1) ) != NULL){ + char buf2[256]; + if( getStringFromIndexWithDelim( buf1,",",1,buf2,sizeof( buf2)) != FALSE ) + fl = atoi( buf2); + if( getStringFromIndexWithDelim( buf1,",",2,buf2,sizeof( buf2)) != FALSE ) + x = atoi( buf2); + if( getStringFromIndexWithDelim( buf1,",",3,buf2,sizeof( buf2)) != FALSE ) + y = atoi( buf2); + } + CHAR_DischargePartyNoMsg( toindex);//ɢŶ + CHAR_DischargePartyNoMsg( forindex);//ɢŶ + if( MAP_IsValidCoordinate( fl, x, y) != FALSE ){ + CHAR_warpToSpecificPoint( toindex, fl, x, y); + CHAR_warpToSpecificPoint( forindex, fl, x, y); + } + + CHAR_JoinParty_Main( toindex, forindex); + //lssproto_PR_send( fd, 0, 1); + { + int i; + for( i=0; i 0 ){ + if( PairList[0][i].pindex == toindex || + PairList[0][i].pindex == forindex ){ + PairList[0][i].pindex = -1; + PairList[0][i].use = -1; + } + } + if( PairList[1][i].use > 0 ){ + if( PairList[1][i].pindex == toindex || + PairList[1][i].pindex == forindex ){ + PairList[1][i].pindex = -1; + PairList[1][i].use = -1; + } + } + } + } +} + +int NPC_getPairCode( int toindex) +{ + char *arg="\0"; + int code=-1, i; + if( !CHAR_CHECKINDEX( toindex)) return-1; + for( i=0; i<15; i++) { + char buf1[256]; + int itemindex = CHAR_getItemIndex( toindex, i); + if( !ITEM_CHECKINDEX( itemindex) ) continue; + arg = ITEM_getChar(itemindex, ITEM_ARGUMENT );// Ա|Ա|FLG + if( arg == "\0" )continue; + if( NPC_Util_GetStrFromStrWithDelim( arg, "PAIRCODE", buf1, sizeof( buf1) ) == NULL) continue; + code = atoi( buf1); + break; + } + return code; +} + +int NPC_getNextTitle( int meindex, int toindex, char *arg, int title, int select) +{ + char buf[NPC_UTIL_GETARGSTR_BUFSIZE], buf1[1024], buf2[256]; + int toID=0; + memset( buf, 0, sizeof( buf)); + if( getStringFromIndexWithDelim( arg, "PSYCHOMETRICS", 2, buf, sizeof( buf)) == FALSE ) + return -1; + if( getStringFromIndexWithDelim( buf , "}", title, buf1, sizeof( buf1)) == FALSE ) + return -1; + if( select == WINDOW_BUTTONTYPE_YES ) { + if( NPC_Util_GetStrFromStrWithDelim( buf1, "YESFOR", buf2, sizeof( buf2 )) == NULL) + return -1; + }else { + if( NPC_Util_GetStrFromStrWithDelim( buf1, "NOFOR", buf2, sizeof( buf2) ) == NULL) + return -1; + } + toID = atoi( buf2); + return toID; +} + +int NPC_getTitleMsg( int meindex, int toindex, char *arg, char *token, int title) +{ + char buf[NPC_UTIL_GETARGSTR_BUFSIZE], buf1[1024], buf2[256]; + memset( buf, 0, sizeof( buf)); + + if( getStringFromIndexWithDelim( arg, "PSYCHOMETRICS", 2, buf, sizeof( buf)) == FALSE ) + return -1; + //ȡһ + if( getStringFromIndexWithDelim( buf , "}", title, buf1, sizeof( buf1)) == FALSE ) + return FALSE; + if( NPC_Util_GetStrFromStrWithDelim( buf1, "TITLEMSG", buf2, sizeof( buf2 )) == NULL){ + if( NPC_Util_GetStrFromStrWithDelim( buf1, "FREE", buf2, sizeof( buf2 )) == NULL){ + return -1; + } + if( NPC_ActionPassCheck( meindex, toindex, buf2) == FALSE ) { + CHAR_talkToCli( toindex, meindex, "", CHAR_COLORYELLOW); + return -1; + } + if( Action_RunDoEventAction( meindex, toindex, buf1) == FALSE ){ + CHAR_talkToCli( toindex, meindex, "", CHAR_COLORYELLOW); + return -1; + } + if( NPC_Util_GetStrFromStrWithDelim( buf1, "ENDMSG", buf2, sizeof( buf2 )) == NULL){ + return -1; + } + sprintf( token, "%s", buf2); + return 2; + } + + sprintf( token, "%s", buf2); + return 1; +} +#endif diff --git a/npc/npc_manorsman.c b/npc/npc_manorsman.c new file mode 100644 index 0000000..e7d0dea --- /dev/null +++ b/npc/npc_manorsman.c @@ -0,0 +1,1333 @@ +#include "version.h" +#include +#include "char.h" +#include "object.h" +#include "lssproto_serv.h" +#include "npcutil.h" +#include "handletime.h" +#include "npc_scheduleman.h" +#include "family.h" +#include "npc_manorsman.h" +#include "saacproto_cli.h" +#include "net.h" +#include "configfile.h" +#include "log.h" + +/* + * ׯ԰ PK ǼԱ + * + */ +int manorflag[10] = {0,0,0,0,0,0,0,0,0,0}; +char manorname[10][32] = {"\O","\O","\O","\O","\O","\O","\O","\O","\O","\O"}; +#define MAX_MANORSMAN 22 +static int FMPK_ManorsmanList[MAX_MANORSMAN]={ +-1,-1,-1,-1,-1, +-1,-1,-1,-1,-1, +-1,-1,-1,-1,-1, +-1,-1,-1,-1,-1, +-1,-1 }; + +enum { + NPC_WORK_ID = CHAR_NPCWORKINT1, // ǼԱ ID, 0 ʼ + NPC_WORK_MANORID = CHAR_NPCWORKINT2, // ׯ԰ + NPC_WORK_CHALLENGEWAIT = CHAR_NPCWORKINT3, // սȴʱ + NPC_WORK_PEACEWAIT = CHAR_NPCWORKINT4, // սʱ + NPC_WORK_PREVLOOPTIME = CHAR_NPCWORKINT5, // ǰһδ Loop ʱ +#ifdef _NEW_MANOR_LAW + NPC_WORK_BETTLETIME = CHAR_NPCWORKINT6 // ¼ʱ +#endif +}; + +#define SCHEDULEFILEDIR "./Schedule/" + +#ifdef _FIX_FAMILY_PK_LIMIT // WON ADD սׯ԰ǰʮΪǰʮ +#define PK_LIMIT 20 +#endif + + +extern struct FM_POINTLIST fmpointlist; +extern void NPC_talkToFloor(int floor, int index1, int index2, char *data); +#ifdef _MANOR_PKRULE +extern struct FMS_DPTOP fmdptop; +#endif + +void NPC_ManorLoadPKSchedule(int meindex); // Load schedule from disk +#ifdef _NEW_MANOR_LAW +void SortManorSchedule(); +int SortManorScheduleMomentum(const void *indexa, const void *indexb); +extern int familyMemberIndex[FAMILY_MAXNUM][FAMILY_MAXMEMBER]; +int g_iSortManor; +#endif + +int NPC_getManorsmanListIndex( int ID) +{ + + if( ID < 0 || ID >= MAX_MANORSMAN ){ + return FMPK_ManorsmanList[ ID]; + } + return -1; +} +BOOL NPC_ManorSmanInit( int meindex ) +{ + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + int meid; + int a; + + CHAR_setInt( meindex, CHAR_WHICHTYPE, CHAR_TYPEMANORSCHEDULEMAN ); + + // + NPC_Util_GetArgStr(meindex, argstr, sizeof(argstr)); + meid = NPC_Util_GetNumFromStrWithDelim(argstr, "id" ); + if ((meid<0) || (meid>=MAX_SCHEDULEMAN)) { + print("MANORSMAN init error: invalid ID(%d)\n",meid); + meid=0; + } + CHAR_setWorkInt(meindex, NPC_WORK_ID, meid); + + a = NPC_Util_GetNumFromStrWithDelim(argstr, "loop" ); + if ((a<100) || (a>10000)) a=1000; + CHAR_setInt(meindex, CHAR_LOOPINTERVAL, a); + + a = NPC_Util_GetNumFromStrWithDelim(argstr, "manorid" ); + if ((a<1) || (a>/*4*/MANORNUM)) {// CoolFish 2002/2/25 + print("MANORSMAN init error: invalid manor id(%d).", a); + a=1; + } + CHAR_setWorkInt(meindex, NPC_WORK_MANORID, a); + + a = NPC_Util_GetNumFromStrWithDelim(argstr, "challengewait"); + if ((a<1) || (a>259200)) { + print("MANORSMAN init error: invalid challengewait(%d).",a); + a=259200; + } + CHAR_setWorkInt(meindex, NPC_WORK_CHALLENGEWAIT, a); + + a = NPC_Util_GetNumFromStrWithDelim(argstr, "peacewait"); + if ((a<0) || (a>432000)) { + print("MANORSMAN init error: invalid peacewait(%d).",a); + a=604800; + } + CHAR_setWorkInt(meindex, NPC_WORK_PEACEWAIT, a); + + NPC_ManorLoadPKSchedule(meindex); + + CHAR_setWorkInt(meindex, NPC_WORK_PREVLOOPTIME, NowTime.tv_sec); +#ifdef _NEW_MANOR_LAW + CHAR_setWorkInt(meindex,NPC_WORK_BETTLETIME,0); +#endif + + if( CHAR_getWorkInt( meindex, NPC_WORK_ID) >= 0 && + CHAR_getWorkInt( meindex, NPC_WORK_ID) 2) return; + if (!NPC_Util_isFaceToFace(meindex, talkerindex, 2)) return; + fd = getfdFromCharaIndex(talkerindex); + if (fd == -1) return; + + switch (fmpks[fmpks_pos+1].flag) { + case FMPKS_FLAG_NONE: + // ûԼսʱս + saacproto_ACFMPointList_send(acfd); +#ifdef _MANOR_PKRULE + sprintf(buf, "ׯ԰Ȩսսʸ\n\n" + "һûӵׯ԰ļ\n" + #ifdef _FIX_FAMILY_PK_LIMIT // WON ADD սׯ԰ǰʮΪǰʮ + "бΪǰʮ\n" + #else + "бΪǰʮ\n" + #endif + "߹ʱ䣺賿\n\n" + "Դҽȷʸ"); +#else + sprintf(buf, "ׯ԰Ȩսսʸ\n\n" + "һûӵׯ԰ļ\n" + "ׯ԰\n\n" + "Դҽȷʸ"); +#endif + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_YESNO, + CHAR_WINDOWTYPE_CHECKMAN_START, + CHAR_getWorkInt(meindex, CHAR_WORKOBJINDEX), + buf); + break; + case FMPKS_FLAG_MANOR_PREPARE: + // ĿǰѾս׼ + { + int timeleft=fmpks[fmpks_pos+1].dueltime-NowTime.tv_sec; + int dd,hh,mm; + char buf2[4096]; + dd = /*fmpks[fmpks_pos+1].dueltime*/ timeleft / 86400; + hh = /*fmpks[fmpks_pos+1].dueltime*/ timeleft / 3600 - dd*24; + mm = /*fmpks[fmpks_pos+1].dueltime*/ timeleft / 60 - dd*24*60 - hh*60; + memset(buf2,0,sizeof(buf2)); + if (dd>0) sprintf(buf, " %d ", dd); else strcpy(buf, ""); + strcat(buf2, buf); + if (hh>0) sprintf(buf, " %d Сʱ", hh); else strcpy(buf, ""); + strcat(buf2, buf); + if (mm>0) sprintf(buf, " %d ", mm); else strcpy(buf, ""); + strcat(buf2, buf); + if (strlen(buf2)==0) + sprintf(buf, "ׯ԰Ȩս\n%s ֣ %s\n\n" + "ʼ׼볡", + fmpks[fmpks_pos+1].guest_name, + fmpks[fmpks_pos+1].host_name); + else + sprintf(buf, "ׯ԰Ȩս\n%s ֣ %s\n\n" + "Ԥ%sῪʼ", + fmpks[fmpks_pos+1].guest_name, + fmpks[fmpks_pos+1].host_name, + buf2); + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + CHAR_WINDOWTYPE_CHECKMAN_END, + CHAR_getWorkInt(meindex, CHAR_WORKOBJINDEX), + buf); + } + break; + case FMPKS_FLAG_MANOR_PEACE: + // սѾĺƽʱ + { + int timeleft=fmpks[fmpks_pos+1].dueltime-NowTime.tv_sec; + int dd,hh,mm; + char buf2[4096]; + dd = /*fmpks[fmpks_pos+1].dueltime*/ timeleft / 86400; + hh = /*fmpks[fmpks_pos+1].dueltime*/ timeleft / 3600 - dd*24; + mm = /*fmpks[fmpks_pos+1].dueltime*/ timeleft / 60 - dd*24*60 - hh*60; + strcpy(buf2,""); + if (dd>0) sprintf(buf, " %d ", dd); else strcpy(buf, ""); + strcat(buf2, buf); + if (hh>0) sprintf(buf, " %d Сʱ", hh); else strcpy(buf, ""); + strcat(buf2, buf); + if (mm>0) sprintf(buf, " %d ", mm); else strcpy(buf, ""); + strcat(buf2, buf); + + if (strlen(buf2)==0) + strcpy(buf, "Եȣ׼һ߹ݵı"); + else + sprintf(buf, "սʱڣҪ߹ݵĻ\n%s롣",buf2); + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + CHAR_WINDOWTYPE_CHECKMAN_END, + CHAR_getWorkInt(meindex, CHAR_WORKOBJINDEX), buf); + } + break; + case FMPKS_FLAG_MANOR_BATTLEBEGIN: + // Ŀǰڽ߹ + sprintf(buf, "ׯ԰Ȩս\n%s ֣ %s\n\n" + "ޡ\nû˸Ͽɡ", + fmpks[fmpks_pos+1].guest_name, + fmpks[fmpks_pos+1].host_name); + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + CHAR_WINDOWTYPE_CHECKMAN_END, + CHAR_getWorkInt(meindex, CHAR_WORKOBJINDEX), + buf); + break; + case FMPKS_FLAG_MANOR_OTHERPLANET: + // ڱս + sprintf(buf, "ׯ԰Ȩս\n%s ֣ %s\n\n" + "ص %s ", + fmpks[fmpks_pos+1].guest_name, + fmpks[fmpks_pos+1].host_name, + fmpks[fmpks_pos+2].host_name); + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + CHAR_WINDOWTYPE_CHECKMAN_END, + CHAR_getWorkInt(meindex, CHAR_WORKOBJINDEX), + buf); + break; + } +} +#else +void NPC_ManorSmanTalked(int meindex, int talkerindex, char *msg, int color) +{ + char buf[4096]; + int fd; + int fmpks_pos = CHAR_getWorkInt(meindex,NPC_WORK_ID)*MAX_SCHEDULE; + int manorid = CHAR_getWorkInt(meindex,NPC_WORK_MANORID); + + if(CHAR_CHECKINDEX(meindex) == FALSE){ + printf("\nNPC_ManorSmanTalked error!(meindex:%d)",meindex); + return; + } + if(NPC_Util_CharDistance(meindex,talkerindex) > 2) return; + if(!NPC_Util_isFaceToFace(meindex,talkerindex,2)) return; + fd = getfdFromCharaIndex(talkerindex); + if(fd == -1) return; + + if(fmpks[fmpks_pos+1].flag == FMPKS_FLAG_CHALLENGE) fmpks[fmpks_pos+1].flag = FMPKS_FLAG_NONE; + + switch(fmpks[fmpks_pos+1].flag){ + // ս 1800~2200 + case FMPKS_FLAG_NONE: + case FMPKS_FLAG_WAIT: + saacproto_ACFMPointList_send(acfd); + sprintf(buf,"ׯ԰Ȩսսʸ\n\n" + "һûׯ԰ļ\n" + "Ƹׯ԰Ƶ\n" + "Լսʱֹʱһ߻սʸ\n" + "ġͬȱ߻ʸ\n" + " OK ҽȷʸ񣬰 NO ۿս"); + lssproto_WN_send(fd,WINDOW_MESSAGETYPE_MESSAGE,WINDOW_BUTTONTYPE_YESNO,CHAR_WINDOWTYPE_CHECKMAN_START, + CHAR_getWorkInt(meindex, CHAR_WORKOBJINDEX),buf); + if(fmpointlist.fm_momentum[manorid-1] <= -1){ + int hadfmindex,index; + char token[256]; + + getStringFromIndexWithDelim(fmpointlist.pointlistarray[manorid-1],"|",5,token,sizeof(token)); + hadfmindex = atoi(token); + if(hadfmindex != -1){ + for(index=0;index= FAMILY_MAXNUM){ + getStringFromIndexWithDelim(fmpointlist.pointlistarray[manorid-1],"|",6,token,sizeof(token)); + printf("\nNPC_ManorSmanTalked():save fm_momentum error(%d:%s)",hadfmindex,token); + break; + } + // ¼ʱׯ + else fmpointlist.fm_momentum[manorid-1] = fmdptop.fmMomentum[index]; + } + } + SortManorSchedule(); + break; + // ս׼ 2200~ȡսʸļ嵱ʱսʱ( 1800~2200 ֮) + case FMPKS_FLAG_MANOR_PREPARE: + // ĿǰѾս׼ + { + int timeleft = fmpks[fmpks_pos+1].dueltime - NowTime.tv_sec; + int mm,hh,dd; + char buf2[4096]; + + dd = timeleft / 86400; + hh = timeleft / 3600 - dd * 24; + mm = timeleft / 60 - dd * 24 * 60 - hh * 60; + memset(buf2,0,sizeof(buf2)); + if(dd > 0) sprintf(buf," %d ",dd); else strcpy(buf,""); + strcat(buf2,buf); + if(hh > 0) sprintf(buf," %d Сʱ",hh); else strcpy(buf,""); + strcat(buf2,buf); + if(mm > 0) sprintf(buf," %d ",mm); else strcpy(buf,""); + strcat(buf2,buf); + if(strlen(buf2) == 0) + sprintf(buf,"ׯ԰Ȩս\n%s ֣ %s\n\nʼ׼볡", + fmpks[fmpks_pos+1].guest_name,fmpks[fmpks_pos+1].host_name); + else + sprintf(buf,"ׯ԰Ȩս\n%s ֣ %s\n\nԤ%sῪʼ", + fmpks[fmpks_pos+1].guest_name,fmpks[fmpks_pos+1].host_name,buf2); + lssproto_WN_send(fd,WINDOW_MESSAGETYPE_MESSAGE,WINDOW_BUTTONTYPE_OK,CHAR_WINDOWTYPE_CHECKMAN_END, + CHAR_getWorkInt(meindex,CHAR_WORKOBJINDEX),buf); + } + break; + // սڼ׼, + case FMPKS_FLAG_MANOR_PEACE: + case FMPKS_FLAG_MANOR_PEACE_SAVE: + { + int timeleft = fmpks[fmpks_pos+1].dueltime-NowTime.tv_sec; + int dd,hh,mm; + char buf2[4096]; + dd = timeleft / 86400; + hh = timeleft / 3600 - dd*24; + mm = timeleft / 60 - dd*24*60 - hh*60; + memset(buf2,0,sizeof(buf2)); + if(dd > 0) sprintf(buf," %d ",dd); else strcpy(buf,""); + strcat(buf2,buf); + if(hh > 0) sprintf(buf," %d Сʱ",hh); else strcpy(buf,""); + strcat(buf2,buf); + if(mm > 0) sprintf(buf," %d ",mm); else strcpy(buf,""); + strcat(buf2,buf); + + if(strlen(buf2) == 0) strcpy(buf, "Եȣ׼һ߹ݵı"); + else sprintf(buf, "ڷսʱڣҪսĻ\n%s롣",buf2); + lssproto_WN_send(fd,WINDOW_MESSAGETYPE_MESSAGE,WINDOW_BUTTONTYPE_OK,CHAR_WINDOWTYPE_CHECKMAN_END, + CHAR_getWorkInt(meindex, CHAR_WORKOBJINDEX),buf); + } + break; + // ս + case FMPKS_FLAG_MANOR_BATTLEBEGIN: + sprintf(buf,"ׯ԰Ȩս\n%s ֣ %s\n\nޡ\nû˸Ͽɡ", + fmpks[fmpks_pos+1].guest_name,fmpks[fmpks_pos+1].host_name); + lssproto_WN_send(fd,WINDOW_MESSAGETYPE_MESSAGE,WINDOW_BUTTONTYPE_OK,CHAR_WINDOWTYPE_CHECKMAN_END, + CHAR_getWorkInt(meindex, CHAR_WORKOBJINDEX),buf); + break; + case FMPKS_FLAG_MANOR_OTHERPLANET: + // ڱս + sprintf(buf,"ׯ԰Ȩս\n%s ֣ %s\n\nص %s ", + fmpks[fmpks_pos+1].guest_name,fmpks[fmpks_pos+1].host_name,fmpks[fmpks_pos+2].host_name); + lssproto_WN_send(fd,WINDOW_MESSAGETYPE_MESSAGE,WINDOW_BUTTONTYPE_OK,CHAR_WINDOWTYPE_CHECKMAN_END, + CHAR_getWorkInt(meindex,CHAR_WORKOBJINDEX),buf); + break; + } +} +#endif + +void NPC_ManorSmanWindowTalked(int meindex, int talkerindex, int seqno, int select, char *data) +{ + int fd, fmpks_pos, manorid, tkfmindex, tkfmdp; + char buf[4096],token[256]; + int hadfmindex; +#ifndef _ACFMPK_LIST + char hadfmname[256]; +#endif + int hadfmpopular; + + if (NPC_Util_CharDistance(meindex,talkerindex) > 2) return; + if (!NPC_Util_isFaceToFace(meindex, talkerindex, 2)) return; + fd = getfdFromCharaIndex(talkerindex); + if (fd == -1) return; + fmpks_pos = CHAR_getWorkInt(meindex, NPC_WORK_ID)*MAX_SCHEDULE; + manorid = CHAR_getWorkInt(meindex, NPC_WORK_MANORID); + tkfmindex = CHAR_getWorkInt(talkerindex, CHAR_WORKFMINDEXI); + tkfmdp = CHAR_getWorkInt(talkerindex, CHAR_WORKFMDP); + getStringFromIndexWithDelim(fmpointlist.pointlistarray[manorid-1], "|", 5, token, sizeof(token)); + hadfmindex = atoi(token); + getStringFromIndexWithDelim(fmpointlist.pointlistarray[manorid-1], "|", 7, token, sizeof(token)); + hadfmpopular = atoi(token); + + switch (seqno){ + case CHAR_WINDOWTYPE_CHECKMAN_START: + if (select==WINDOW_BUTTONTYPE_YES){ +#ifdef _FMVER21 + if ((CHAR_getInt(talkerindex,CHAR_FMLEADERFLAG)==FMMEMBER_LEADER) && +#else + if ((CHAR_getInt(talkerindex,CHAR_FMLEADERFLAG)==1) && +#endif + (CHAR_getWorkInt(talkerindex, CHAR_WORKFMSETUPFLAG)==1)){ + if (hadfmindex != -1) { + if (hadfmindex-1 != tkfmindex){ + int check=0,i; +#ifdef _FM_POINT_PK + if(strcmp(getFmPointPK(),"")){ + // Arminius 2.25 fix: fmpks е 1~"MANORNUM" һҪ manorsman + for (i=0; i<=/*3*/MANORNUM-1; i++) { // 9ׯ԰ + getStringFromIndexWithDelim(fmpointlist.pointlistarray[i], "|", 5, token, sizeof(token)); + if (tkfmindex==atoi(token)-1) check=1; + } + } +#else + // Arminius 2.25 fix: fmpks е 1~"MANORNUM" һҪ manorsman + for (i=0; i= FAMILY_MAXNUM){ + printf("\nNPC_ManorSmanWindowTalked():find tkfmIndex error (%d)",tkfmindex); + } + else +#ifdef _CAX_FM_QISHINUM + // սƲׯƵ5,ս + if(fmdptop.fmMomentum[index] < fmpointlist.fm_momentum[manorid-1]*0.5) won1 = 0;//0.5 +#else + //ս޸Ϊ 5 + if(fmdptop.fmMomentum[index] < 500 ) won1 = 0; +#endif + //----------------------------------------- + #else + //----------------------------------------- + int i; + char won2[256]; + won1 = 0; + #ifdef _FIX_FAMILY_PK_LIMIT // WON ADD սׯ԰ǰʮΪǰʮ + for(i=0; i< PK_LIMIT; i++){ + #else + for(i=0; i<10; i++){ + #endif + if( getStringFromIndexWithDelim( fmdptop.topmemo[i], "|", 3, won2, sizeof(won2)) == FALSE ) { + print("err Get fmdptop.topmemo[%d] if FALSE !!\n", i); + break; + } + if( strcmp(CHAR_getChar(talkerindex, CHAR_FMNAME) ,won2) == 0 ){ + won1= 1; + break; + } + //----------------------------------------- + } + #endif + + if(won1 == 1){ + // WON END + #ifdef _NEW_MANOR_LAW + sprintf(buf,"ȷׯ԰սʸһ׼ʱ\n" + "ʱѯԵ֪ʣµʱ\n" + "ս´սڽһս\n" + "׼ڣڼڲս\n\n" + "ȷҪսׯ԰"); + #else + sprintf(buf,"ׯ԰սһ׼\n" + "ʱѯԵ֪ʣµʱ\n" + "ս᲻ʤжս\n" + "սڼ䲻ս\n\n" + "ȷҪսׯ԰"); + #endif +#else + if(tkfmdp >= hadfmpopular){ + sprintf(buf,"ׯ԰սһ׼\n" + "ʱѯԵ֪ʣµʱ\n" + "ս᲻ʤս\n" + "սڼ䲻ս\n\n" + "ȷҪսׯ԰"); +#endif + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_YESNO, + CHAR_WINDOWTYPE_CHECKMAN_MAIN, + CHAR_getWorkInt(meindex, CHAR_WORKOBJINDEX), + buf); + } + else{ +#ifdef _NEW_MANOR_LAW + #ifdef _CAX_FM_QISHINUM + sprintf(buf, "ļδׯ԰Ƶɣټ͡"); + #else + sprintf(buf, "ļδ 5 ټ͡"); + #endif +#else + #ifdef _MANOR_PKRULE + #ifdef _FIX_FAMILY_PK_LIMIT // WON ADD սׯ԰ǰʮΪǰʮ + sprintf(buf, "ļδǰʮ壬ټ͡"); + #else + sprintf(buf, "ļδǰʮ壬ټ͡"); + #endif + #else + sprintf(buf, "ļвս\n" + "ӵׯ԰ļ壬ټ͡"); + #endif +#endif + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + CHAR_WINDOWTYPE_CHECKMAN_END, + CHAR_getWorkInt(meindex, CHAR_WORKOBJINDEX), + buf); + } + } + else if(check == 2){ + sprintf(buf, "ļսׯ԰\n" + "ѻɣ"); + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + CHAR_WINDOWTYPE_CHECKMAN_END, + CHAR_getWorkInt(meindex, CHAR_WORKOBJINDEX), + buf); + } + else{ + sprintf(buf, "һֻӵһׯ԰\n" + "ׯ԰֮Ҫд\n" + "뵽У˳"); + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + CHAR_WINDOWTYPE_CHECKMAN_END, + CHAR_getWorkInt(meindex, CHAR_WORKOBJINDEX), + buf); + } + } + else{ + sprintf(buf, "ׯ԰Ѿļม"); + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + CHAR_WINDOWTYPE_CHECKMAN_END, + CHAR_getWorkInt(meindex, CHAR_WORKOBJINDEX), + buf); + } + } + else{ + sprintf(buf, "ڲûׯ԰壡\n" + "ֱȥǨͿӴ"); + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + CHAR_WINDOWTYPE_CHECKMAN_END, + CHAR_getWorkInt(meindex, CHAR_WORKOBJINDEX), + buf); + } + } + else{ + sprintf(buf, "ֻ峤սม"); + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + CHAR_WINDOWTYPE_CHECKMAN_END, + CHAR_getWorkInt(meindex, CHAR_WORKOBJINDEX), + buf); + } + } +#ifdef _NEW_MANOR_LAW + else if(select == WINDOW_BUTTONTYPE_NO){ + int i,index,manorindex; + char szMsg[3072]; + + sprintf(buf," ׯ԰ս\n ʱ \n"); + manorindex = CHAR_getWorkInt(meindex,NPC_WORK_MANORID) - 1; + // ͳս + for(i=0;i<10;i++){ + index = ManorSchedule[manorindex].iSort[i]; + if(ManorSchedule[manorindex].iFmIndex[index] != -1){ + sprintf(szMsg,"%2d %s\n",i+1,ManorSchedule[manorindex].szMemo[index]); + strcat(buf,szMsg); + } + } + lssproto_WN_send(fd,WINDOW_FMMESSAGETYPE_MANOR_SCHEDULE,WINDOW_BUTTONTYPE_OK,CHAR_WINDOWTYPE_CHECKMAN_END, + CHAR_getWorkInt(meindex,CHAR_WORKOBJINDEX),buf); + } +#endif + break; + case CHAR_WINDOWTYPE_CHECKMAN_MAIN: + if (select==WINDOW_BUTTONTYPE_YES) { +#ifdef _FMVER21 + if ((CHAR_getInt(talkerindex,CHAR_FMLEADERFLAG)==FMMEMBER_LEADER) && +#else + if ((CHAR_getInt(talkerindex,CHAR_FMLEADERFLAG)==1) && +#endif + (CHAR_getWorkInt(talkerindex, CHAR_WORKFMSETUPFLAG)==1) && + (hadfmindex != -1) && + (hadfmindex - 1 != tkfmindex) +#ifndef _MANOR_PKRULE + && (tkfmdp >= hadfmpopular) +#endif + ){ +#ifndef _ACFMPK_LIST + struct tm tm1; +#endif + +#ifndef _NEW_MANOR_LAW + #ifdef _MANOR_PKRULE + time_t timep; + struct tm *p; + time(&timep); + p = gmtime(&timep); + if( p->tm_hour+8 > 24) + p->tm_hour = p->tm_hour-16; + else + p->tm_hour = p->tm_hour+8; +#ifdef _YUANGUSA + if(p->tm_hour<18 && p->tm_hour>20){ + sprintf(buf, "6:008:00Լսɣ"); +#else + if(p->tm_hour<18 && p->tm_hour>1){ + sprintf(buf, "6:00賿1:00Լսɣ"); +#endif + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + CHAR_WINDOWTYPE_CHECKMAN_END, + CHAR_getWorkInt(meindex, CHAR_WORKOBJINDEX), + buf); + break; + } + #endif + // WON ADD pkԼս + if( fmpks[fmpks_pos+1].flag != FMPKS_FLAG_NONE ){ + sprintf(buf, "ׯ԰ѾԼսม"); + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + CHAR_WINDOWTYPE_CHECKMAN_END, + CHAR_getWorkInt(meindex, CHAR_WORKOBJINDEX), + buf); + return; + } +#endif + if(manorflag[manorid-1]==1){ + sprintf(buf, "ׯ԰[%s]ѾԼսม",manorname[manorid-1]); + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + CHAR_WINDOWTYPE_CHECKMAN_END, + CHAR_getWorkInt(meindex, CHAR_WORKOBJINDEX), + buf); + return; + } +#ifdef _ACFMPK_LIST + #ifndef _NEW_MANOR_LAW + NPC_ManorSavePKSchedule(meindex, talkerindex, 0); + sprintf( buf, "ׯ԰ս½ȷУᡣ"); + CHAR_talkToCli( talkerindex, meindex, buf, CHAR_COLORYELLOW); + #else + NPC_ManorAddToSchedule(meindex,talkerindex); + #endif +#else + memcpy( &tm1, localtime( (time_t *)&NowTime.tv_sec), sizeof( tm1)); + getStringFromIndexWithDelim(fmpointlist.pointlistarray[manorid-1], "|", 6, token, sizeof(token)); + strcpy(hadfmname, token); + + fmpks[fmpks_pos+1].dueltime = CHAR_getWorkInt(meindex, NPC_WORK_CHALLENGEWAIT) + NowTime.tv_sec + - tm1.tm_min*60 + 1800; // Arminius 11.1 ijһ xx:30 + fmpks[fmpks_pos+1].host_index = hadfmindex-1; + strcpy(fmpks[fmpks_pos+1].host_name, hadfmname); + fmpks[fmpks_pos+1].guest_index = tkfmindex; + strcpy(fmpks[fmpks_pos+1].guest_name, CHAR_getChar(talkerindex, CHAR_FMNAME)); + fmpks[fmpks_pos+1].prepare_time = 15; +#ifdef _FMWAR_PLAYERNUM + fmpks[fmpks_pos+1].max_player = getFmWarPlayerNum(); +#else + fmpks[fmpks_pos+1].max_player = 50; +#endif + fmpks[fmpks_pos+1].win = -1; + fmpks[fmpks_pos+1].flag = FMPKS_FLAG_MANOR_OTHERPLANET; + strcpy(fmpks[fmpks_pos+2].host_name, getGameserverID()); + + #ifndef _NEW_MANOR_LAW + NPC_ManorSavePKSchedule(meindex, talkerindex, 0); + sprintf(buf, "ׯ԰սѾ趨ɣú׼"); + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + CHAR_WINDOWTYPE_CHECKMAN_END, + CHAR_getWorkInt(meindex, CHAR_WORKOBJINDEX), + buf); + #else + NPC_ManorAddToSchedule(meindex,talkerindex); + #endif + fmpks[fmpks_pos+1].flag = FMPKS_FLAG_MANOR_PREPARE; +#endif + + } + } + break; + } +} + +void NPC_CleanPkList( int ti) +{ +// Terry fix ҪΪ-1Ϊ0 +/* fmpks[ ti+1 ].host_index = 0; + fmpks[ ti+1].guest_index=0; + fmpks[ ti].host_index=0; + fmpks[ ti].guest_index=0;*/ + fmpks[ ti+1 ].host_index = -1; + fmpks[ ti+1].guest_index=-1; + fmpks[ ti].host_index=-1; + fmpks[ ti].guest_index=-1; + + strcpy(fmpks[ ti+1].host_name,""); + strcpy(fmpks[ ti+1].guest_name,""); + strcpy(fmpks[ ti].host_name,""); + strcpy(fmpks[ ti].guest_name,""); + strcpy(fmpks[ ti+2].host_name,""); +} + +void NPC_ManorSmanLoop(int meindex) +{ + struct tm tm1; + int fmpks_pos; +#ifdef _NEW_MANOR_LAW + int iOffsetTime; +#endif + + if(CHAR_CHECKINDEX(meindex) == FALSE){ + printf("\nNPC_ManorSmanLoop error!(meindex:%d)",meindex); + return; + } + + fmpks_pos = CHAR_getWorkInt(meindex, NPC_WORK_ID)*MAX_SCHEDULE; + memcpy( &tm1, localtime( (time_t *)&NowTime.tv_sec), sizeof( tm1)); + + switch (fmpks[fmpks_pos+1].flag) { + case FMPKS_FLAG_NONE: +#ifdef _NEW_MANOR_LAW + { + int hadfmindex,index,manorid; + char token[256]; + //ʱԿʼս + manorid = CHAR_getWorkInt(meindex,NPC_WORK_MANORID); + getStringFromIndexWithDelim(fmpointlist.pointlistarray[manorid-1],"|",5,token,sizeof(token)); + hadfmindex = atoi(token); + if(hadfmindex != -1){ + for(index=0;index= FAMILY_MAXNUM){ + getStringFromIndexWithDelim(fmpointlist.pointlistarray[manorid-1],"|",6,token,sizeof(token)); + //printf("\nNPC_ManorSmanLoop():save fm_momentum error(%d:%s)",hadfmindex,token); + break; + } + // ¼ʱׯ + else fmpointlist.fm_momentum[manorid-1] = fmdptop.fmMomentum[index]; + // һ״̬ + fmpks[fmpks_pos+1].flag = FMPKS_FLAG_WAIT; + // սڹ4Сʱ(1800~2200) + fmpks[fmpks_pos+1].dueltime = NowTime.tv_sec + 3600 * 4; + NPC_ManorSavePKSchedule(meindex, -1, FMPKS_FLAG_WAIT,fmpks[fmpks_pos+1].dueltime,tm1); + } + SortManorSchedule(); + } +#endif + break; +#ifdef _NEW_MANOR_LAW + // ս,Ѽ¼,ȴսų + case FMPKS_FLAG_WAIT: + { + int manorid,i,iPlayerNum = CHAR_getPlayerMaxNum(); + char szMsg[256]; + + manorid = CHAR_getWorkInt(meindex,NPC_WORK_MANORID); + if(manorflag[manorid-1] == 1){ + break; + } + // û,ƸıҪȥACҪʱ + //fmpointlist.fm_inwar[manorid-1] = TRUE; + fmpointlist.fm_inwar[manorid-1] = FALSE; //DzACҪʱ + if(fmpks[fmpks_pos+1].dueltime <= NowTime.tv_sec){ + // սߵĻսȨ + int manorindex = CHAR_getWorkInt(meindex,NPC_WORK_MANORID) - 1; + int iNo1FmIndexSort = ManorSchedule[manorindex].iSort[0]; + if(ManorSchedule[manorindex].iFmIndex[iNo1FmIndexSort]>=0){ + for (i=1; i<=/*4*/MANORNUM; i++) { // ǷѾսׯ԰ + if ((fmpks[i*MAX_SCHEDULE+1].guest_index==ManorSchedule[manorindex].iFmIndex[iNo1FmIndexSort]) && + (strcmp(fmpks[i*MAX_SCHEDULE+1].guest_name, + ManorSchedule[manorindex].szFmName[iNo1FmIndexSort])==0) + ) { + ManorSchedule[manorindex].iSort[0] = ManorSchedule[manorindex].iSort[1]; + //ManorSchedule[manorindex].iFmIndex[iNo1FmIndexSort] = ManorSchedule[manorindex].iFmIndex[iNo2FmIndexSort]; + iNo1FmIndexSort = ManorSchedule[manorindex].iSort[0]; + } + } + } + int index = ManorSchedule[manorindex].iFmIndex[iNo1FmIndexSort],iFmIndex1,iCharindex; + //Logfmpk_war(iNo1FmIndexSort,manorindex,index); + char token[256],fmname[256]; + // ûս + if(index < 0){ + // ֱӽ뵽ս + fmpks[fmpks_pos+1].flag = FMPKS_FLAG_MANOR_BATTLEEND; + CHAR_setWorkInt(meindex,NPC_WORK_BETTLETIME,tm1.tm_mday); + // ֪ͨ + for(i=0;i= 0 && CHAR_getCharUse(iCharindex)){ + // ýǮ = * 5000 + int iAddGold = ((float)CHAR_getInt(iCharindex,CHAR_MOMENTUM)/100.0f) * 5000.0f; + int iGold = CHAR_getInt(iCharindex,CHAR_BANKGOLD),iMaxGold; + // ȷ + if(iGold + iAddGold > CHAR_MAXBANKGOLDHAVE){ + CHAR_setInt(iCharindex,CHAR_BANKGOLD,CHAR_MAXBANKGOLDHAVE); + // зŲ,ŵ + iAddGold = iGold + iAddGold - CHAR_MAXBANKGOLDHAVE; + iGold = CHAR_getInt(iCharindex,CHAR_GOLD); + iMaxGold = CHAR_getMaxHaveGold(iCharindex); + if(iGold + iAddGold > iMaxGold) CHAR_setInt(iCharindex,CHAR_GOLD,iMaxGold); + else CHAR_setInt(iCharindex,CHAR_GOLD,iGold + iAddGold); + LogFMPKGetMomey(CHAR_getChar(iCharindex,CHAR_FMNAME), + CHAR_getChar(iCharindex,CHAR_CDKEY), + CHAR_getChar(iCharindex,CHAR_NAME), + CHAR_getInt(iCharindex,CHAR_MOMENTUM),iAddGold,0); + } + else{ + CHAR_setInt(iCharindex,CHAR_BANKGOLD,iGold + iAddGold); + LogFMPKGetMomey(CHAR_getChar(iCharindex,CHAR_FMNAME), + CHAR_getChar(iCharindex,CHAR_CDKEY), + CHAR_getChar(iCharindex,CHAR_NAME), + CHAR_getInt(iCharindex,CHAR_MOMENTUM),iAddGold,1); + } + CHAR_talkToCli(iCharindex,-1,"!ػסׯ԰Ľѻĸ",CHAR_COLORRED); + // ĸ˼ƶҪ + CHAR_setInt(iCharindex,CHAR_MOMENTUM,0); + CHAR_talkToCli(iCharindex,-1,"ׯ԰ս˼ƹ",CHAR_COLORRED); + } + } + } + } + else{ + // սʱѹ,ѡսׯԼһʱ׼ + NPC_ManorSavePKSchedule(meindex,index,0,-1,ManorSchedule[manorindex].tm1[iNo1FmIndexSort]); + // ,ƸıҲȥACҪʱ + fmpointlist.fm_inwar[manorid-1] = FALSE; + // ֪ͨ + sprintf(szMsg,"%s սׯ԰ʸ",ManorSchedule[manorindex].szFmName[iNo1FmIndexSort]); + + for(i=0;itm_hour; +// if (dueltimetmp==dueltime && tm2.tm_hour<22) +// { +// dueltime = dueltime + 3600; +// } + if(p2.tm_hour<23 && p2.tm_hour>19 && p1.tm_mon == p2.tm_mon && p1.tm_mday == p2.tm_mday && p1.tm_hour == p2.tm_hour) + { + if(p2.tm_hour==20){ + int tmpnum = RAND(1,100); + if(tmpnum<=33) + dueltime = dueltime + 1800; + else if(tmpnum<=66) + dueltime = dueltime + 3600; + else + dueltime = dueltime + 5400; + }else if(p2.tm_hour==21){ + int tmpnum = RAND(1,100); + if(tmpnum<=25) + dueltime = dueltime + 1800; + else if(tmpnum<=50) + dueltime = dueltime + 3600; + else if(tmpnum<=75) + dueltime = dueltime + 5400; + else + dueltime = dueltime - 1800; + }else if(p2.tm_hour==22){ + int tmpnum = RAND(1,100); + if(tmpnum<=50) + dueltime = dueltime - 1800; + else + dueltime = dueltime + 1800; + } + } + if(p2.tm_hour>17 && p2.tm_hour<20 ){ + dueltime = dueltime + 3600*(20-p2.tm_hour); + } + } + getStringFromIndexWithDelim( fmpointlist.pointlistarray[manorid-1], "|", 5, token, sizeof(token)); + hadfmindex = atoi( token); + getStringFromIndexWithDelim( fmpointlist.pointlistarray[manorid-1], "|", 7, token, sizeof(token)); + hadfmpopular = atoi( token); + getStringFromIndexWithDelim( fmpointlist.pointlistarray[manorid-1], "|", 6, token, sizeof(token)); + strcpy( hadfmname, token); + makeEscapeString( hadfmname, n1, sizeof(n1)); +#ifndef _NEW_MANOR_LAW + makeEscapeString( CHAR_getChar(toindex, CHAR_FMNAME), n2, sizeof(n2)); +#else + // ҳս߼ + index = ManorSchedule[manorid-1].iSort[0]; + makeEscapeString(ManorSchedule[manorid-1].szFmName[index],n2,sizeof(n2)); +#endif + makeEscapeString( getGameserverID(), n3, sizeof(n3)); + + sprintf(msg, "%d|%d|%s|%d|%s|%d|%d|%d|%s", + dueltime, hadfmindex-1, n1, tkfmindex, n2, 15, 50, FMPKS_FLAG_MANOR_OTHERPLANET, n3); + PkFlg = 1; + { + char buf1[256]; + sprintf( buf1,"%d", CHAR_getWorkInt( meindex, NPC_WORK_ID) ); + Logfmpk( + n1, hadfmindex-1, 0, + n2, tkfmindex, 0, + "", buf1, n3, 1); + } + } +#ifndef _NEW_MANOR_LAW + saacproto_ACSendFmPk_send( acfd, toindex, PkFlg, CHAR_getWorkInt( meindex, NPC_WORK_ID), msg); +#else + // toindex òΪ -1 + saacproto_ACSendFmPk_send( acfd, -1, PkFlg, CHAR_getWorkInt( meindex, NPC_WORK_ID), msg); +#endif +} + +#endif + +#ifdef _NEW_MANOR_LAW +// սų +void NPC_ManorAddToSchedule(int meindex,int charaindex) +{ + int i,j,iEmpty = -1,iFmIndex,manorindex = CHAR_getWorkInt(meindex,NPC_WORK_MANORID) - 1; + struct tm tm1; + + iFmIndex = CHAR_getWorkInt(charaindex,CHAR_WORKFMINDEXI); + // Ƿų,еׯ԰Լս + for(j=0;j= FAMILY_MAXNUM){ + lssproto_WN_send(getfdFromCharaIndex(charaindex),WINDOW_MESSAGETYPE_MESSAGE,WINDOW_BUTTONTYPE_OK,CHAR_WINDOWTYPE_CHECKMAN_END, + CHAR_getWorkInt(meindex, CHAR_WORKOBJINDEX),"ǸҲļ"); + return; + } + // Ƚ + if(ManorSchedule[manorindex].iFmMomentum[index] < fmdptop.fmMomentum[i]){ + int fmpks_pos,iPlayerNum = CHAR_getPlayerMaxNum(); + char szMsg[256]; + + // ֪ͨ + fmpks_pos = CHAR_getWorkInt(meindex,NPC_WORK_ID) * MAX_SCHEDULE; + sprintf(szMsg,"%s 屻 %s 強սų",ManorSchedule[manorindex].szFmName[index],CHAR_getChar(charaindex,CHAR_FMNAME)); + for(i=0;i momentumB) ? -1:1; +} +#endif diff --git a/npc/npc_manorsman.res b/npc/npc_manorsman.res new file mode 100644 index 0000000..31d67f3 Binary files /dev/null and b/npc/npc_manorsman.res differ diff --git a/npc/npc_mic.c b/npc/npc_mic.c new file mode 100644 index 0000000..c8567c9 --- /dev/null +++ b/npc/npc_mic.c @@ -0,0 +1,163 @@ +#include "version.h" +#include +#include + +#include "common.h" +#include "char_base.h" +#include "char.h" +#include "npcutil.h" +#include "npc_mic.h" +#include "saacproto_cli.h" +#include "lssproto_serv.h" +#include "battle.h" + +enum { + CHAR_WORK_FLOOR = CHAR_NPCWORKINT1, + CHAR_WORK_LX = CHAR_NPCWORKINT2, + CHAR_WORK_LY = CHAR_NPCWORKINT3, + CHAR_WORK_RX = CHAR_NPCWORKINT4, + CHAR_WORK_RY = CHAR_NPCWORKINT5, + CHAR_WORK_MODE = CHAR_NPCWORKINT6, + CHAR_WORK_TYPE = CHAR_NPCWORKINT7, + CHAR_WORK_WIND = CHAR_NPCWORKINT8, + CHAR_WORK_FMFL = CHAR_NPCWORKINT9, +}; + + +BOOL NPC_MicInit( int meindex ) +{ + int i; + int arg_param[8]; + char argstr[256]; + char buf[64]; + + + NPC_Util_GetArgStr( meindex, argstr, sizeof(argstr)); + + + if( strstr(argstr, "FREE")!=NULL){ + CHAR_setWorkInt(meindex,CHAR_WORK_TYPE,1); + } + if( strstr(argstr, "WIND")!=NULL){ + CHAR_setWorkInt(meindex,CHAR_WORK_WIND,1); + } + + + if( strstr( argstr , "|" ) != NULL){ + for( i = 1; i < 9; i ++ ) { + if( getStringFromIndexWithDelim(argstr, "|" , i , buf,sizeof(buf) ) + == FALSE ) + { + printf( "NPC_MIC:ʡԲ\n"); + arg_param[i-1] = 0; + continue; + } + arg_param[i-1] = atoi(buf); + } + CHAR_setWorkInt( meindex, CHAR_WORK_FLOOR, arg_param[0]); + CHAR_setWorkInt( meindex, CHAR_WORK_LX, min( arg_param[1],arg_param[3])); + CHAR_setWorkInt( meindex, CHAR_WORK_LY, min( arg_param[2],arg_param[4])); + CHAR_setWorkInt( meindex, CHAR_WORK_RX, max( arg_param[1],arg_param[3])); + CHAR_setWorkInt( meindex, CHAR_WORK_RY, max( arg_param[2],arg_param[4])); + CHAR_setInt( meindex, CHAR_WHICHTYPE, CHAR_TYPEMIC); + + CHAR_setWorkInt( meindex, CHAR_WORK_FMFL, arg_param[7]); + return TRUE; + + }else{ + CHAR_setInt( meindex, CHAR_WHICHTYPE, CHAR_TYPEMIC); + CHAR_setWorkInt( meindex, CHAR_WORK_MODE, 1); + return TRUE; + } + + return FALSE; +} + +void NPC_MicTalked( int meindex , int talkerindex , char *msg ,int color ) +{ + + int i; + int playernum; + int x,y; + char message[4096]; + char buf[2048]; + + if( CHAR_getInt(talkerindex,CHAR_WHICHTYPE) != CHAR_TYPEPLAYER) return; + if(CHAR_getWorkInt(meindex,CHAR_WORK_TYPE) == 0){ + if(NPC_Util_isFaceToChara(talkerindex,meindex,1 ) ==FALSE) return; + } + + snprintf( buf, sizeof( buf), "%s\n%s", + CHAR_getChar( talkerindex, CHAR_NAME), + msg); + + // Robin 0621 峤㲥 + print(" MIC_FL:%d ", CHAR_getWorkInt( meindex, CHAR_WORK_FMFL )); + if( CHAR_getWorkInt( meindex, CHAR_WORK_FMFL ) != 0 ) + { +#ifdef _FMVER21 + if( CHAR_getInt( talkerindex, CHAR_FMLEADERFLAG ) == FMMEMBER_LEADER) +#else + if( CHAR_getInt( talkerindex, CHAR_FMLEADERFLAG ) == 1) +#endif + // && ( CHAR_getWorkInt( talkerindex, CHAR_WORKFMFLOOR) == CHAR_getWorkInt( meindex, CHAR_WORK_FLOOR ) ) ) + { + print(" FMLeaderTalk_send:%s,%d,%d,%s ", + CHAR_getChar( talkerindex, CHAR_FMNAME), CHAR_getInt( talkerindex, CHAR_FMINDEX), + CHAR_getWorkInt( talkerindex, CHAR_WORKFMINDEXI), buf); + + sprintf(message, "[峤㲥]%s", buf); + saacproto_ACFMAnnounce_send( acfd, + CHAR_getChar( talkerindex, CHAR_FMNAME), + CHAR_getInt( talkerindex, CHAR_FMINDEX), + CHAR_getWorkInt( talkerindex, CHAR_WORKFMINDEXI), + message, + color + ); + return; + } + + } + + makeEscapeString( buf, message, sizeof(buf)); + + playernum = CHAR_getPlayerMaxNum(); + + for( i = 0; i < playernum; i ++ ) { + BOOL flg = FALSE; + if( CHAR_getCharUse(i) == FALSE ) continue; + if( CHAR_getInt( i, CHAR_WHICHTYPE) != CHAR_TYPEPLAYER ) continue; + if( CHAR_getInt( i, CHAR_FLOOR) != CHAR_getWorkInt( meindex, CHAR_WORK_FLOOR) ){ + continue; + } + if( CHAR_getWorkInt( meindex, CHAR_WORK_MODE) == 0 ) { + x = CHAR_getInt( i, CHAR_X); + y = CHAR_getInt( i, CHAR_Y); + if( x >= CHAR_getWorkInt( meindex, CHAR_WORK_LX) && + x <= CHAR_getWorkInt( meindex, CHAR_WORK_RX) && + y >= CHAR_getWorkInt( meindex, CHAR_WORK_LY) && + y <= CHAR_getWorkInt( meindex, CHAR_WORK_RY)){ + flg = TRUE; + } + }else { + flg = TRUE; + } + if( flg) { + CHAR_talkToCli( i, talkerindex, msg, CHAR_COLORYELLOW); + if( CHAR_getWorkInt( meindex, CHAR_WORK_WIND) == 1 ) { + if( CHAR_getWorkInt( i, CHAR_WORKBATTLEMODE) + == BATTLE_CHARMODE_NONE) + { + int fd = getfdFromCharaIndex( i); + if( fd != -1 ) { + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + CHAR_WINDOWTYPE_MICMESSAGE, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + message); + } + } + } + } + } +} diff --git a/npc/npc_msg.c b/npc/npc_msg.c new file mode 100644 index 0000000..4e02d4f --- /dev/null +++ b/npc/npc_msg.c @@ -0,0 +1,46 @@ +#include "version.h" +#define _NPC_MSG_C_ + +#include "char.h" +#include "char_base.h" +#include "npcutil.h" + + +/* + ئ 쫷ƥַʣ + Իؤ ƥέ·£ + + init , looked ı ɱ + + */ +BOOL NPC_MsgInit( int meindex ) +{ + //CHAR_setInt( meindex , CHAR_HP , 0 ); + + //CHAR_setInt( meindex , CHAR_MP , 0 ); + //CHAR_setInt( meindex , CHAR_MAXMP , 0 ); + + //CHAR_setInt( meindex , CHAR_STR , 0 ); + //CHAR_setInt( meindex , CHAR_TOUGH, 0 ); + + //CHAR_setInt( meindex , CHAR_LV , 0 ); + + CHAR_setInt( meindex , CHAR_WHICHTYPE , CHAR_TYPETOWNPEOPLE ); + //CHAR_setFlg( meindex , CHAR_ISOVERED , 0 ); + //CHAR_setFlg( meindex , CHAR_ISATTACKED , 0 ); /* ľئз */ + + return TRUE; +} + + +/* + * έľף۷ئʷ + */ +void NPC_MsgLooked( int meindex , int lookedindex ) +{ + char arg[NPC_UTIL_GETARGSTR_BUFSIZE]; + + NPC_Util_GetArgStr( meindex, arg, sizeof( arg)); + CHAR_talkToCli( lookedindex , -1 , arg , CHAR_COLORWHITE ); + +} diff --git a/npc/npc_mtradenpcman.c b/npc/npc_mtradenpcman.c new file mode 100644 index 0000000..e69de29 diff --git a/npc/npc_newnpcman.c b/npc/npc_newnpcman.c new file mode 100644 index 0000000..a1cfa4d --- /dev/null +++ b/npc/npc_newnpcman.c @@ -0,0 +1,1191 @@ +#include "version.h" +#include +#include +#include "char.h" +#include "object.h" +#include "char_base.h" +#include "npcutil.h" +#include "lssproto_serv.h" +#include "enemy.h" +#include "log.h" +#include "battle.h" +#include "readmap.h" +#include "handletime.h" +#include "npc_eventaction.h" +#include "npc_newnpcman.h" +#include "pet.h" +#define NEWNPCMAN_STANDBY 5000 +#define NEWNPCMAN_WAITTIME 150 +enum { + WINDOW_START=1, + WINDOW_SELECT1, + WINDOW_SELECT2, + WINDOW_SELECT3, + WINDOW_SELECTLOSTPET, + WINDOW_DEFIND, + WINDOW_WARP, + WINDOW_END, + + NPC_PROGRAMEGINEER_START=1, + NPC_PROGRAMEGINEER_SELECT1, + NPC_PROGRAMEGINEER_SELECT2, + NPC_PROGRAMEGINEER_SELECT3, + NPC_PROGRAMEGINEER_SELECTLOSTPET, + NPC_PROGRAMEGINEER_DEFIND, + NPC_PROGRAMEGINEER_END, +}; +enum { + NPC_WORK_CURRENTTIME = CHAR_NPCWORKINT1, +/* + NPC_WORK_ROUTETOY = CHAR_NPCWORKINT2, + NPC_WORK_ROUTEPOINT = CHAR_NPCWORKINT3, + NPC_WORK_ROUNDTRIP = CHAR_NPCWORKINT4, + NPC_WORK_MODE = CHAR_NPCWORKINT5, + NPC_WORK_CURRENTROUTE = CHAR_NPCWORKINT6, + NPC_WORK_ROUTEMAX = CHAR_NPCWORKINT7, + NPC_WORK_WAITTIME = CHAR_NPCWORKINT8, + NPC_WORK_CURRENTTIME = CHAR_NPCWORKINT9, + NPC_WORK_SEFLG = CHAR_NPCWORKINT10, +*/ +}; +/* +char UserBBIs[12][256]={ + "С", "", "к", "", "Ƥ", "", + "С", "Ƥ", "ñ", "̷", "Ů", "" }; +char PetBBIs[4][256]={//³˹ ³ ³ ³ + "³˹-컢", "³-̻", "³-", "³-ƻ" }; + +int PlayerBBI[6*2][4]={ + { 100000, 100005, 100010, 100015 }, //С + { 100025, 100030, 100035, 100020 }, // + { 100055, 100050, 100045, 100040 }, //к + { 100060, 100065, 100070, 100075 }, // + { 100095, 100085, 100090, 100080 }, //Ƥ + { 100100, 100115, 100110, 100115 }, // + + { 100135, 100120, 100125, 100130 }, //С + { 100145, 100140, 100150, 100155 }, //Ƥ + { 100165, 100170, 100160, 100175 }, //ñ + { 100190, 100195, 100185, 100180 }, //̷ + { 100200, 100210, 100215, 100205 }, //Ů + { 100230, 100225, 100220, 100235 } // + }; +*/ + +static int checkPc[48][3]; + +static void NPC_NewNpcMan_selectWindow( int meindex, int toindex, int num, int flg); + +void NPC_reCheckMyPetUnusual( int meindex, int toindex);//쳣 + +BOOL CHECK_ReplacePET( int toindex); // +void NPC_reCheckItemPilenum( int meindex, int toindex);//ԭǹѵ +BOOL CHECK_ITEMEQUIT( int toindex);// +BOOL CHECK_PETBBI( int toindex);//ͼ + +#ifdef _PET_LOSTPET +BOOL NPC_reFindMyLostPet( int meindex, int toindex, char *buf); +BOOL NPC_getLostPetString( int meindex, int toindex); +BOOL NPC_backupLostPetString( int toindex); +static char petstring[7][2048]={"","","","","","",""}; +#endif + +BOOL NPC_NewNpcManInit( int meindex ) +{ + char npcarg[NPC_UTIL_GETARGSTR_BUFSIZE]; + + if(NPC_Util_GetArgStr( meindex, npcarg, sizeof(npcarg))==NULL){ + print("TRANSER_MAN: GetArgStrErr!!"); + return FALSE; + } + + { + int i; + for( i=0; i<48; i++){ + if( i == 0 ){ + checkPc[i][0]=30000; + checkPc[i][1]=30024; + checkPc[i][2]=100000; + }else{ + checkPc[i][0] = checkPc[i-1][0] + 25; + checkPc[i][1] = checkPc[i-1][1] + 25; + checkPc[i][2] = checkPc[i-1][2] + 5; + } +// print("ANDY checkPc:%d[%d,%d,%d]\n", i, checkPc[i][0], checkPc[i][1], checkPc[i][2]); + } + } + CHAR_setInt( meindex, CHAR_WHICHTYPE, CHAR_NEWNPCMAN); + CHAR_setWorkInt( meindex, NPC_WORK_CURRENTTIME, NowTime.tv_sec); + return TRUE; +} + +void NPC_NewNpcManLoop( int meindex) +{ + +} + +void NPC_NewNpcManTalked( int meindex , int talkerindex , char *msg , int color ) +{ + char npcarg[NPC_UTIL_GETARGSTR_BUFSIZE]; + if( CHAR_getInt( talkerindex , CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER ) + return; + if(NPC_Util_isFaceToFace( meindex ,talkerindex , 2) == FALSE) { + if(NPC_Util_isFaceToChara( talkerindex, meindex, 1) == FALSE) + return; + } + if(NPC_Util_GetArgStr( meindex, npcarg, sizeof(npcarg))==NULL){ + print("TRANSER_MAN: GetArgStrErr!!"); + return; + } + CHAR_setWorkInt( talkerindex, CHAR_WORKSHOPRELEVANT, 0); + if( CHAR_getInt( talkerindex, CHAR_BASEBASEIMAGENUMBER) != 101578 ){ + NPC_NewNpcMan_selectWindow( meindex, talkerindex, WINDOW_SELECT1, 0); + return; + } + NPC_NewNpcMan_selectWindow( meindex, talkerindex, WINDOW_START, 0); +} + +static void NPC_NewNpcMan_selectWindow( int meindex, int toindex, int num, int flg) +{ + char npcarg[NPC_UTIL_GETARGSTR_BUFSIZE]; + char token[256]; + + int buttontype = 0, windowtype = 0, windowno = 0; + int fd = getfdFromCharaIndex( toindex); + + windowtype = WINDOW_MESSAGETYPE_MESSAGE; + + if(NPC_Util_isFaceToFace( meindex ,toindex , 2) == FALSE) { + if(NPC_Util_isFaceToChara( toindex, meindex, 1) == FALSE) + return; + } + + memset( npcarg, 0, sizeof( npcarg)); + if(NPC_Util_GetArgStr( meindex, npcarg, sizeof(npcarg))==NULL){ + return; + } + + memset( token, 0, sizeof( token)); + switch( num) { + case WINDOW_START: + if( NPC_Util_GetStrFromStrWithDelim( npcarg, "START_MSG", token, sizeof( token) ) == NULL) { + return; + } + buttontype = WINDOW_BUTTONTYPE_YESNO; + windowno = NPC_PROGRAMEGINEER_DEFIND; + break; + case WINDOW_SELECT1: + sprintf(token," ѡ" + "\n 쳣" + "\n ͼš" + "\n " +#ifdef _PET_LOSTPET + "\n ʧ" +#endif +// "\n ԭǹѵ" + + ); + windowtype = WINDOW_MESSAGETYPE_SELECT; + buttontype = WINDOW_BUTTONTYPE_CANCEL; + windowno = NPC_PROGRAMEGINEER_SELECT2; + break; + case WINDOW_SELECT2: + switch( flg){ + case 1://쳣 + NPC_reCheckMyPetUnusual( meindex, toindex); + CHAR_talkToCli( toindex, -1, "ϳ!", CHAR_COLORYELLOW); + return; + break; + case 2://ͼ + CHECK_PETBBI( toindex); + return; + break; + case 3:// + if( CHECK_ITEMEQUIT( toindex) == TRUE ){ + CHAR_talkToCli( toindex, -1, "!", CHAR_COLORYELLOW); + } + return; + break; + + case 4: +#ifdef _PET_LOSTPET + if( NPC_reFindMyLostPet( meindex, toindex, token) == FALSE ){ + CHAR_talkToCli( toindex, -1, "ϣ", CHAR_COLORYELLOW); + return; + } + windowtype = WINDOW_MESSAGETYPE_SELECT; + buttontype = WINDOW_BUTTONTYPE_CANCEL; + windowno = NPC_PROGRAMEGINEER_SELECTLOSTPET; +#endif + break; + case 5: //ԭǹѵ +// NPC_reCheckItemPilenum( meindex, toindex); + return; + break; + } + break; +/* + case WINDOW_SELECT3: + { + int petnum, petindex; + petnum = atoi( data)-1; + if( petnum >= CHAR_MAXPETHAVE || petnum < 0 ) return; + petindex = CHAR_getCharPet( talker, petsel); + if( !CHAR_CHECKINDEX(petindex) ) return; + break; + } +*/ + case WINDOW_SELECTLOSTPET: +#ifdef _PET_LOSTPET + { + int ret, i, ti, ltime, cost; + Char ch; + char msgbuf[256]; + char petstring1[2048]; + + int havepetelement = CHAR_getCharPetElement( toindex); + ti = flg; + if( havepetelement < 0 ){ + CHAR_talkToCli( toindex, -1, "λ", CHAR_COLORYELLOW); + return; + } + if( NPC_getLostPetString( meindex, toindex) == FALSE ) { + CHAR_talkToCli( toindex, -1, "ȡʧܣ", CHAR_COLORYELLOW); + return; + } + + if( getStringFromIndexWithDelim( petstring[ti-1], "#", 2, petstring1, sizeof( petstring1)) == FALSE ){ + CHAR_talkToCli( toindex, -1, "ȡʧܣ", CHAR_COLORYELLOW); + return; + }else{ + char buf1[256]; + if( getStringFromIndexWithDelim( petstring[ti-1], "|", 6, buf1, sizeof( buf1)) == FALSE ) return; + ltime = atoi(buf1); + ltime = time( NULL) - ltime; + ltime = ltime/(60*60*24); + if( getStringFromIndexWithDelim( petstring[ti-1], "|", 4, buf1, sizeof( buf1)) == FALSE ) return; + cost = atoi( buf1); + + cost = cost + (ltime*10000); + + if( CHAR_getInt( toindex, CHAR_GOLD) < cost ) { + sprintf( buf1, "Ѽķ%d죬%dʯҲſء", ltime, cost); + CHAR_talkToCli( toindex, meindex, buf1, CHAR_COLORYELLOW); + return; + } + } + + + ret = CHAR_makePetFromStringToArg( petstring1, &ch, -2); + strcpy( petstring[ti-1], ""); + if( ret ) { + char buf1[256]; + int petindex = PET_initCharOneArray( &ch ); + if( !CHAR_CHECKINDEX( petindex) ){ + CHAR_talkToCli( toindex, -1, "ȡʧܣ", CHAR_COLORYELLOW); + return; + } + print("ANDY petindex:%d[%s]\n", petindex, CHAR_getChar( petindex, CHAR_NAME) ); + + CHAR_complianceParameter( petindex ); + CHAR_setInt( petindex, CHAR_HP, CHAR_getWorkInt( petindex, CHAR_WORKMAXHP)); + CHAR_setWorkInt( petindex, CHAR_WORKPLAYERINDEX, toindex); + CHAR_setCharPet( toindex, havepetelement, petindex); + CHAR_setChar( petindex, CHAR_OWNERCDKEY, + CHAR_getChar( toindex, CHAR_CDKEY)); + CHAR_setChar( petindex, CHAR_OWNERCHARANAME, + CHAR_getChar( toindex, CHAR_NAME)); + + if( NPC_backupLostPetString( toindex) == FALSE ){ + print("ANDY err backup petstring !!\n"); + return; + } + + sprintf( buf1, "LostPGet:%d", cost); + LogPet( + CHAR_getChar( toindex, CHAR_NAME ), + CHAR_getChar( toindex, CHAR_CDKEY ), + CHAR_getChar( petindex, CHAR_NAME), + CHAR_getInt( petindex, CHAR_LV), + buf1, + CHAR_getInt( toindex,CHAR_FLOOR), + CHAR_getInt( toindex,CHAR_X ), + CHAR_getInt( toindex,CHAR_Y ), + CHAR_getChar( petindex, CHAR_UNIQUECODE) // shan 2001/12/14 + ); + sprintf( buf1, "ȡ%s", CHAR_getUseName( petindex)); + CHAR_talkToCli( toindex, meindex, buf1, CHAR_COLORYELLOW); + for( i = 0; i < CHAR_MAXPETHAVE; i++){ + int petindex = CHAR_getCharPet( toindex, i); + if( !CHAR_CHECKINDEX( petindex) ) + continue; + CHAR_complianceParameter( petindex ); + snprintf( msgbuf, sizeof( msgbuf ), "K%d", i ); + CHAR_sendStatusString( toindex, msgbuf ); + snprintf( msgbuf, sizeof( msgbuf ), "W%d", i ); + CHAR_sendStatusString( toindex, msgbuf ); + } + CHAR_DelGold( toindex, cost); + }else{ + CHAR_talkToCli( toindex, -1, "ȡʧܣ", CHAR_COLORYELLOW); + return; + } + return; + } +#endif + return; + break; + case WINDOW_DEFIND: + { + int i; + int face = CHAR_getInt( toindex, CHAR_FACEIMAGENUMBER); + if( NPC_Util_GetStrFromStrWithDelim( npcarg, "CHECK_MSG", token, sizeof( token) ) == NULL) { + return; + } + for( i=0; i<48; i++){ + if( face >= checkPc[i][0] && face < checkPc[i][1] ) + break; + } + if( i >= 48 )return; + CHAR_setWorkInt( toindex, CHAR_WORKNPCMETAMO, meindex); + CHAR_setInt( toindex, CHAR_BASEIMAGENUMBER, checkPc[i][2]); + CHAR_complianceParameter( toindex ); + CHAR_sendCToArroundCharacter( CHAR_getWorkInt( toindex , CHAR_WORKOBJINDEX )); + CHAR_send_P_StatusString( toindex , CHAR_P_STRING_BASEBASEIMAGENUMBER); + + buttontype = WINDOW_BUTTONTYPE_YESNO; + windowno = NPC_PROGRAMEGINEER_END; + } + break; + case WINDOW_END: + { + CHAR_setWorkInt( toindex, CHAR_WORKNPCMETAMO, -1); + CHAR_setInt( toindex, CHAR_BASEBASEIMAGENUMBER, + CHAR_getInt( toindex, CHAR_BASEIMAGENUMBER) ); + + CHAR_complianceParameter( toindex ); + CHAR_sendCToArroundCharacter( CHAR_getWorkInt( toindex , CHAR_WORKOBJINDEX )); + CHAR_send_P_StatusString( toindex , CHAR_P_STRING_BASEBASEIMAGENUMBER); + return; + } + break; + } + + lssproto_WN_send( fd, windowtype, buttontype, windowno, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), token); +} + +void NPC_NewNpcManWindowTalked( int meindex, int talkerindex, int seqno, int select, char *data) +{ + if(NPC_Util_isFaceToFace( meindex ,talkerindex , 2) == FALSE) { + if(NPC_Util_isFaceToChara( talkerindex, meindex, 1) == FALSE) + return; + } + + if( select == WINDOW_BUTTONTYPE_CANCEL || select == WINDOW_BUTTONTYPE_NO){ + CHAR_setWorkInt( talkerindex, CHAR_WORKSHOPRELEVANT, 0); + CHAR_setWorkInt( talkerindex, CHAR_WORKNPCMETAMO, -1); + return; + } + switch( seqno) { + case NPC_TRANSERMAN_START: + break; + case NPC_PROGRAMEGINEER_SELECT1: + NPC_NewNpcMan_selectWindow( meindex, talkerindex, WINDOW_SELECT1, atoi( data)); + break; + case NPC_PROGRAMEGINEER_SELECT2: + NPC_NewNpcMan_selectWindow( meindex, talkerindex, WINDOW_SELECT2, atoi( data)); + break; + case NPC_PROGRAMEGINEER_SELECT3: + NPC_NewNpcMan_selectWindow( meindex, talkerindex, WINDOW_SELECT3, atoi( data)); + break; + case NPC_PROGRAMEGINEER_SELECTLOSTPET: + NPC_NewNpcMan_selectWindow( meindex, talkerindex, WINDOW_SELECTLOSTPET, atoi( data)); + break; + case NPC_PROGRAMEGINEER_DEFIND: + NPC_NewNpcMan_selectWindow( meindex, talkerindex, WINDOW_DEFIND, atoi( data)); + break; + case NPC_PROGRAMEGINEER_END: + NPC_NewNpcMan_selectWindow( meindex, talkerindex, WINDOW_END, atoi( data)); + break; + } +} + +BOOL CHECK_ITEMEQUIT( int toindex) +{ + int i, itemindex; + char token[256]; + + for (i = CHAR_STARTITEMARRAY; i < CHAR_MAXITEMHAVE; i ++) { + itemindex = CHAR_getItemIndex( toindex, i); + if( ITEM_getInt( itemindex, ITEM_ID) == 19646 ){ + CHAR_DelItem( toindex, i); + itemindex = -1; + itemindex = ITEM_makeItemAndRegist( 1292); + if( !ITEM_CHECKINDEX( itemindex) ){ + }else{ + int ret = CHAR_addItemSpecificItemIndex( toindex, itemindex); + if( ret < 0 || ret >= CHAR_MAXITEMHAVE ) { + ITEM_endExistItemsOne( itemindex); + continue; + } + sprintf( token,"õ%s", ITEM_getChar( itemindex, ITEM_NAME)); + CHAR_talkToCli( toindex, -1, token, CHAR_COLORYELLOW ); + CHAR_sendItemDataOne( toindex, ret); + continue; + } + } + if( ITEM_getInt( itemindex, ITEM_ID) == 1292 && + ITEM_getInt( itemindex, ITEM_MAXDAMAGECRUSHE) > 0 ){ + + ITEM_setInt( itemindex, ITEM_MAXDAMAGECRUSHE, 0); + ITEM_setInt( itemindex, ITEM_DAMAGECRUSHE, 0); + sprintf(token,"%s𻵶", ITEM_getChar( itemindex, ITEM_NAME)); + CHAR_sendItemDataOne( toindex, i); + CHAR_talkToCli( toindex, -1, token, CHAR_COLORYELLOW); + } + } + + // ķŵ + for (i = 0; i < CHAR_MAXPOOLITEMHAVE; i++) { + if( ITEM_getInt( itemindex, ITEM_ID) == 1292 && + ITEM_getInt( itemindex, ITEM_MAXDAMAGECRUSHE) > 0 ){ + + ITEM_setInt( itemindex, ITEM_MAXDAMAGECRUSHE, 0); + ITEM_setInt( itemindex, ITEM_DAMAGECRUSHE, 0); + sprintf(token,"ķŵ%s𻵶", ITEM_getChar( itemindex, ITEM_NAME)); + CHAR_talkToCli( toindex, -1, token, CHAR_COLORYELLOW); + } + } + + return TRUE; +} + + +BOOL CHECK_PETBBI( int toindex) +{ + int i, petindex, PetID; + BOOL Finds = FALSE; + char token[256]; + for( i=0; i < CHAR_MAXPETHAVE; i++) { + int parry, array, PetBBI; + petindex = CHAR_getCharPet( toindex, i); + if( !CHAR_CHECKINDEX( petindex) ) continue; + PetID = CHAR_getInt( petindex, CHAR_PETID); + array = ENEMY_getEnemyArrayFromTempNo( PetID); + if( !ENEMY_CHECKINDEX( array)) continue; + parry = ENEMYTEMP_getEnemyTempArray( array); + PetBBI = ENEMYTEMP_getInt( parry, E_T_IMGNUMBER); + + if( CHAR_getInt( petindex, CHAR_BASEBASEIMAGENUMBER) != PetBBI || + CHAR_getInt( petindex, CHAR_BASEIMAGENUMBER) != PetBBI ){ + CHAR_setInt( petindex, CHAR_BASEBASEIMAGENUMBER, PetBBI); + CHAR_setInt( petindex, CHAR_BASEIMAGENUMBER, PetBBI); + sprintf( token, "%sͼ", CHAR_getUseName( petindex)); + CHAR_talkToCli( toindex, -1, token, CHAR_COLORYELLOW); + Finds = TRUE; + } + CHAR_setInt( petindex, CHAR_EARTHAT, ENEMYTEMP_getInt( parry, E_T_EARTHAT) ); + CHAR_setInt( petindex, CHAR_WATERAT, ENEMYTEMP_getInt( parry, E_T_WATERAT) ); + CHAR_setInt( petindex, CHAR_FIREAT, ENEMYTEMP_getInt( parry, E_T_FIREAT) ); + CHAR_setInt( petindex, CHAR_WINDAT, ENEMYTEMP_getInt( parry, E_T_WINDAT) ); + char tempname[128]; + if(strstr(CHAR_getChar(petindex,CHAR_NAME),"*")!=NULL) + sprintf(tempname,"*%s",ENEMYTEMP_getChar( parry, E_T_NAME)); + else + sprintf(tempname,"%s",ENEMYTEMP_getChar( parry, E_T_NAME)); + CHAR_setChar( petindex, CHAR_NAME, tempname); + CHAR_setChar( petindex, CHAR_USERPETNAME , ""); + } + for( i=0; i %s (%s:%s)(file:%s %d) !! \n", + petID, PetNAME, CHAR_getUseName( toindex), + CHAR_getChar( toindex, CHAR_CDKEY), __FILE__, __LINE__ ); + } + } + + for( i=0; i 0 )continue; + + if( i == CHAR_getInt( toindex, CHAR_DEFAULTPET) ) { + int fd = getfdFromCharaIndex( toindex); + CHAR_setInt( toindex, CHAR_DEFAULTPET, -1); + lssproto_KS_send( fd, -1, TRUE); + } + + snprintf( szPet,sizeof( szPet), "%s", CHAR_getUseName( petindex) ); + CHAR_talkToCli( toindex, -1, szPet, CHAR_COLORYELLOW); + LogPet( + CHAR_getChar( toindex, CHAR_NAME ), + CHAR_getChar( toindex, CHAR_CDKEY ), + CHAR_getChar( petindex, CHAR_NAME), + CHAR_getInt( petindex, CHAR_LV), + "TenseiDel", + CHAR_getInt( toindex,CHAR_FLOOR), + CHAR_getInt( toindex,CHAR_X ), + CHAR_getInt( toindex,CHAR_Y ), + CHAR_getChar( petindex, CHAR_UNIQUECODE) + ); + + Finds = TRUE; + CHAR_setCharPet( toindex, i, -1); + CHAR_endCharOneArray( petindex ); + + array = ENEMY_getEnemyArrayFromTempNo( 1133); + if( !ENEMY_CHECKINDEX( array)) continue; + ret = ENEMY_createPetFromEnemyIndex( toindex, array); + if( !CHAR_CHECKINDEX( ret ) ) continue; + + snprintf( szPet, sizeof( szPet), "õ%s", CHAR_getUseName( ret) ); + CHAR_talkToCli( toindex, -1, szPet, CHAR_COLORWHITE); + + LogPet( + CHAR_getChar( toindex, CHAR_NAME ), + CHAR_getChar( toindex, CHAR_CDKEY ), + CHAR_getChar( ret, CHAR_NAME), + CHAR_getInt( ret, CHAR_LV), + "TenseiGet", + CHAR_getInt( toindex,CHAR_FLOOR), + CHAR_getInt( toindex,CHAR_X ), + CHAR_getInt( toindex,CHAR_Y ), + CHAR_getChar( ret, CHAR_UNIQUECODE) + ); + + } + + for( i=0; i 1 ){ + int itemID, pilenum=1, newindex; + itemID = ITEM_getInt( itemindex, ITEM_ID); + if( !ITEM_CHECKITEMTABLE( itemID) ) continue; + pilenum = ITEM_getInt( itemindex, ITEM_USEPILENUMS); + while( pilenum > 1 ){ + int ti = CHAR_findEmptyItemBox( toindex); + if( ti == -1 ){ + CHAR_sendItemDataOne( toindex, i); + CHAR_talkToCli( toindex, -1, "λ", CHAR_COLORYELLOW); + return; + } + newindex = ITEM_makeItemAndRegist( itemID); + if( !ITEM_CHECKINDEX( newindex) ) break; + CHAR_setItemIndex( toindex , ti, newindex); + CHAR_sendItemDataOne( toindex, ti); + pilenum--; + ITEM_setInt( itemindex, ITEM_USEPILENUMS, pilenum); + } + if( ITEM_getInt( itemindex, ITEM_CANBEPILE) != ITEMTBL_getInt( itemID, ITEM_CANBEPILE) ) + ITEM_setInt( itemindex, ITEM_CANBEPILE, ITEMTBL_getInt( itemID, ITEM_CANBEPILE) ); + CHAR_sendItemDataOne( toindex, i); + } + } + CHAR_talkToCli( toindex, -1, "ǹϡ", CHAR_COLORYELLOW); +} + +#ifdef _PET_LOSTPET +BOOL NPC_reFindMyLostPet( int meindex, int toindex, char *buf) +{ + //0 1 2 + FILE *fp = NULL; + char *CdKey=NULL; + int lv=0, cost, ltime, count=0, i, type; + char filename[256], line[2048], buf1[256]; + char petname[256], typebuf[256]; + char buf2[10][256]={"\n","\n","\n","\n","\n", + "\n","\n","\n","\n","\n" }; + CdKey = CHAR_getChar( toindex, CHAR_CDKEY ); + if( CdKey == NULL ) return FALSE; + sprintf( filename, "lostpet/%s.txt", CdKey); + strcpy( buf, "==ʧ¼==\n"); + if( (fp=fopen( filename, "r")) == NULL ) return FALSE; + + while( fgets( line , sizeof( line ) , fp ) && count < 7){ + if( line == NULL ) continue; + if( getStringFromIndexWithDelim( line, "|", 1, buf1, sizeof( buf1)) == FALSE ) continue; + if( strcmp( CHAR_getChar( toindex, CHAR_CDKEY ), buf1 )) continue; + if( getStringFromIndexWithDelim( line, "|", 6, buf1, sizeof( buf1)) == FALSE ) continue; + ltime = atoi(buf1); + ltime = time( NULL) - ltime; + ltime = ltime/(60*60*24); + if( ltime > 14 ) continue;//14 + + if( getStringFromIndexWithDelim( line, "|", 2, petname, sizeof( petname)) == FALSE ) continue; + if( getStringFromIndexWithDelim( line, "|", 3, buf1, sizeof( buf1)) == FALSE ) continue; + lv = atoi( buf1); + if( getStringFromIndexWithDelim( line, "|", 4, buf1, sizeof( buf1)) == FALSE ) continue; + cost = atoi( buf1); + + if( getStringFromIndexWithDelim( line, "#", 3, buf1, sizeof( buf1)) == FALSE ) continue; + type = atoi( buf1); + if( type == 1 ){ + strcpy( typebuf, ""); + }else if( type == 2 ){ + strcpy( typebuf, ""); + }else{ + strcpy( typebuf, ""); + } + + sprintf( buf2[count++], "%s LV:%dʯ:%d(%d%s)\n", petname, lv, cost, ltime, typebuf); + } + fclose( fp); + for( i=0; i<7; i++){ + strcat( buf, buf2[i]); + } + if( count == 0 ) return FALSE; + return TRUE; +} + +BOOL NPC_getLostPetString( int meindex, int toindex) +{ + FILE *fp = NULL; + char *CdKey=NULL; + int count=0, i, ltime; + char filename[256], line[2048], buf1[256]; + + for( i=0; i<7; i++) + strcpy( petstring[i], ""); + + CdKey = CHAR_getChar( toindex, CHAR_CDKEY ); + if( CdKey == NULL ) return FALSE; + sprintf( filename, "lostpet/%s.txt", CdKey); + if( (fp=fopen( filename, "r")) == NULL ) return FALSE; + + while( fgets( line , sizeof( line ) , fp ) && count < 7){ + if(strlen( line) <= 0 ) continue; +// if( getStringFromIndexWithDelim( line, "#", 2, buf1, sizeof( buf1)) == FALSE ) return FALSE; +// Terry fix ȡʱûжʱ 2004/09/22 + if(getStringFromIndexWithDelim(line,"|",6,buf1,sizeof(buf1)) == FALSE) continue; + ltime = atoi(buf1); + ltime = time( NULL) - ltime; + ltime = ltime/(60*60*24); + if(ltime > 14) continue;//14 +// Terry end + strcpy( petstring[count++], line); + } + + fclose( fp); + return TRUE; +} + +BOOL NPC_backupLostPetString( int toindex) +{ + FILE *fp = NULL; + char *CdKey=NULL; + int i, count=0; + char filename[256]; + + CdKey = CHAR_getChar( toindex, CHAR_CDKEY ); + if( CdKey == NULL ) return FALSE; + sprintf( filename, "lostpet/%s.txt", CdKey); + if( (fp=fopen( filename, "w")) == NULL ) return FALSE; + + for( i=0; i<7; i++){ + if( strlen( petstring[i]) <= 0 ) continue; + fprintf( fp, "%s", petstring[i]); + count++; + } + fclose( fp); + + if( count == 0 ) + remove( filename); + + return TRUE; +} + +/* + + +#ifdef _NEW_WARPMAN +#include "npc_newnpcman.h" +#define NEWNPCMAN_STANDBY 5000 +#define NEWNPCMAN_WAITTIME 150 + +enum{ +NPC_NEWNPCMAN_START=21, +NPC_NEWNPCMAN_MAN, +NPC_NEWNPCMAN_END, +}; + +enum { + NEWNPC_START = 1, + NEWNPC_MAN, + NEWNPC_END, +}; + +enum { + NPC_WORK_INDEX = CHAR_NPCWORKINT1, + NPC_WORK_WORKTYPE = CHAR_NPCWORKINT2, + NPC_WORK_CURRENTTIME = CHAR_NPCWORKINT3, +}; + +BOOL CHECK_YEARPET( int toindex); +static void NPC_NewNpcMan_selectWindow( int meindex, int toindex, int num, int flg); +int NPC_NewNpcManDelPet(int meindex,int talker, int petsel); +BOOL NPC_NewNpcManAddPet(int meindex, int talker, int petid); + +//ɻֳ +static int Re_Pet[4]; +// shan +char uStr[128]=""; + +BOOL NPC_NewNpcManInit( int meindex ) +{ + char npcarg[NPC_UTIL_GETARGSTR_BUFSIZE]; + char buf1[256],buf2[256]; + int k=1; + + if(NPC_Util_GetArgStr( meindex, npcarg, sizeof(npcarg)) == NULL) { + print("GambleBank:GetArgStrErr"); + return FALSE; + } + + if( NPC_Util_GetStrFromStrWithDelim( npcarg, "REPET", buf1, sizeof( buf1)) == NULL ) { + return FALSE; + } + + while( getStringFromIndexWithDelim(buf1, ",", k, buf2, sizeof(buf2)) != FALSE ) { + Re_Pet[k-1] = atoi( buf2); + if( Re_Pet[k-1] < 0 ) + return FALSE; + k++; + if( (k-1) >= arraysizeof( Re_Pet) ) + break; + } + + CHAR_setInt( meindex , CHAR_WHICHTYPE , CHAR_NEWNPCMAN ); + CHAR_setInt( meindex, CHAR_LOOPINTERVAL, NEWNPCMAN_STANDBY); + CHAR_setWorkInt( meindex, NPC_WORK_CURRENTTIME, NowTime.tv_sec); + CHAR_setWorkInt( meindex , NPC_WORK_INDEX, -1); + return TRUE; +} + +void NPC_NewNpcManLoop( int meindex) +{ + //test + char npcarg[NPC_UTIL_GETARGSTR_BUFSIZE]; + char buf1[256],buf2[256]; + int k=1; + + int fulltime = NEWNPCMAN_WAITTIME; + if( (CHAR_getWorkInt( meindex, NPC_WORK_CURRENTTIME) + fulltime) > NowTime.tv_sec ) + return; + CHAR_setWorkInt( meindex , NPC_WORK_INDEX, -1); + CHAR_setWorkInt( meindex, NPC_WORK_CURRENTTIME, NowTime.tv_sec); + + //test + if(NPC_Util_GetArgStr( meindex, npcarg, sizeof(npcarg)) == NULL) { + print("GambleBank:GetArgStrErr"); + return; + } + + if( NPC_Util_GetStrFromStrWithDelim( npcarg, "REPET", buf1, sizeof( buf1)) == NULL ) { + return; + } + + while( getStringFromIndexWithDelim(buf1, ",", k, buf2, sizeof(buf2)) != FALSE ) { + Re_Pet[k-1] = atoi( buf2); + if( Re_Pet[k-1] < 0 ) + return; + k++; + if( (k-1) >= arraysizeof( Re_Pet) ) + break; + } + //test end +} + +void NPC_NewNpcManTalked( int meindex , int talkerindex , char *msg , int color ) +{ + char buf1[256]; + + if( CHAR_getInt( talkerindex , CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER ) { + return; + } + + if(NPC_Util_isFaceToFace( meindex ,talkerindex , 2) == FALSE) { + if(NPC_Util_isFaceToChara( talkerindex, meindex, 1) == FALSE) return; + } + + if( CHAR_getWorkInt( meindex , NPC_WORK_INDEX) >= 0 ) { + sprintf( buf1,"%s","æأ"); + print("\n NPC_WORK_INDEX = %d ", CHAR_getWorkInt( meindex , NPC_WORK_INDEX)); + CHAR_talkToCli( talkerindex, meindex, buf1, CHAR_COLORYELLOW); + return; + }else { + CHAR_setWorkInt( meindex , NPC_WORK_INDEX, talkerindex); + print("\n start : NPC_WORK_INDEX = talkerindex"); + CHAR_setWorkInt( meindex, NPC_WORK_CURRENTTIME, NowTime.tv_sec); + NPC_NewNpcMan_selectWindow( meindex, talkerindex, NEWNPC_START, 0); + } +} + +static void NPC_NewNpcMan_selectWindow( int meindex, int toindex, int num, int flg) +{ + char npcarg[NPC_UTIL_GETARGSTR_BUFSIZE]; + char token[256]; + char token_str[][56]={"ERROR_MSG","START_MSG","END_MSG","ERROR_ALL"}; + int buttontype = 0, windowtype = 0, windowno = 0; + int fd = getfdFromCharaIndex( toindex); + int petno = 718, petid =1479; + int type_str = 0; + windowtype = WINDOW_MESSAGETYPE_MESSAGE; + + if(NPC_Util_GetArgStr( meindex, npcarg, sizeof(npcarg)) == NULL) { + print("GambleBank:GetArgStrErr"); + CHAR_setWorkInt( meindex , NPC_WORK_INDEX, -1); + return ; + } + + if( CHAR_getWorkInt( meindex , NPC_WORK_INDEX) != toindex ) { + sprintf( token,"%s","æأ"); + CHAR_talkToCli( toindex, meindex, token, CHAR_COLORYELLOW); + return; + } + CHAR_setWorkInt( meindex, NPC_WORK_CURRENTTIME, NowTime.tv_sec); + print("\n switch( num=%d)", num); + switch( num) { + case NEWNPC_START: + type_str = 1; + buttontype = WINDOW_BUTTONTYPE_OKCANCEL; + windowno = NPC_NEWNPCMAN_START; + break; + + case NEWNPC_MAN: + { + if( CHECK_YEARPET( toindex) == TRUE ) { + type_str = 1; + windowtype = WINDOW_MESSAGETYPE_PETSELECT; + buttontype = WINDOW_BUTTONTYPE_CANCEL; + windowno = NPC_NEWNPCMAN_MAN; + }else { + type_str = 3; + buttontype = WINDOW_BUTTONTYPE_OK; + windowno = NPC_NEWNPCMAN_END; + CHAR_setWorkInt( meindex , NPC_WORK_INDEX, -1); + } + } + break; + + case NEWNPC_END: + type_str = 0; + if( flg <= CHAR_MAXPETHAVE && flg >= 0 ) { + petno = flg; + + if( ( petid = NPC_NewNpcManDelPet( meindex, toindex, petno)) >= 0 ) { + if( NPC_NewNpcManAddPet( meindex, toindex, petid) == TRUE ) { + type_str = 2; + } + } + } + CHAR_setWorkInt( meindex , NPC_WORK_INDEX, -1); + buttontype = WINDOW_BUTTONTYPE_OK; + windowno = NPC_NEWNPCMAN_END; + + break; + } + + if(NPC_Util_GetStrFromStrWithDelim( npcarg, token_str[ type_str], token,sizeof( token) ) == NULL) { + print("token_str[%d] err !", type_str); + CHAR_setWorkInt( meindex , NPC_WORK_INDEX, -1); + return; + } + + lssproto_WN_send( fd, windowtype, buttontype, windowno, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), token); +} + +void NPC_NewNpcManWindowTalked( int meindex, int talkerindex, int seqno, int select, char *data) +{ + + if( CHAR_getInt( talkerindex , CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER ) { + return; + } + if(NPC_Util_isFaceToFace( meindex ,talkerindex , 2) == FALSE) { + if(NPC_Util_isFaceToChara( talkerindex, meindex, 1) == FALSE) return; + } + + print("\n seqno=%d, select=%d", seqno, select); + switch( seqno) { + case NPC_NEWNPCMAN_START: + if( select != WINDOW_BUTTONTYPE_YES && select != WINDOW_BUTTONTYPE_OK ) { + CHAR_setWorkInt( meindex , NPC_WORK_INDEX, -1); + return; + } + if(select==WINDOW_BUTTONTYPE_CANCEL) { + CHAR_setWorkInt( meindex , NPC_WORK_INDEX, -1); + }else { + NPC_NewNpcMan_selectWindow( meindex, talkerindex, NEWNPC_MAN, -1); + } + break; + + case NPC_NEWNPCMAN_MAN: + { + int petnum; + petnum = atoi( data)-1; + + print("\n petnum=%d", petnum); + if(select==WINDOW_BUTTONTYPE_CANCEL) { + CHAR_setWorkInt( meindex , NPC_WORK_INDEX, -1); + }else { + NPC_NewNpcMan_selectWindow( meindex, talkerindex, NEWNPC_END, petnum); + } + } + break; + + case NPC_NEWNPCMAN_END: + break; + } +} + +int NPC_NewNpcManDelPet(int meindex,int talker, int petsel) +{ + int defpet; + int fd = getfdFromCharaIndex( talker ); + char msgbuf[64], szPet[128]; + int k=0; + int petindex=-1; + + petindex = CHAR_getCharPet( talker, petsel); + if( !CHAR_CHECKINDEX(petindex) ) + return -1; + + for( k=0;k +#include "char.h" +#include "object.h" +#include "char_base.h" +#include "npcutil.h" +#include "npc_newvipshop.h" +#include "lssproto_serv.h" +#include "saacproto_cli.h" +#include "readmap.h" +#include "battle.h" +#include "log.h" +#include "enemy.h" +#include "handletime.h" +#include "npc_eventaction.h" + +//صشøнڽ"ʦ" +#ifdef _VIP_SHOP +enum { + WINDOW_START=1, + WINDOW_SELECT, + WINDOW_PREV, + WINDOW_NEXT, + WINDOW_WARP, + WINDOW_END, +}; +enum { + NPC_WORK_CURRENTTIME = CHAR_NPCWORKINT1, +/* + NPC_WORK_ROUTETOY = CHAR_NPCWORKINT2, + NPC_WORK_ROUTEPOINT = CHAR_NPCWORKINT3, + NPC_WORK_ROUNDTRIP = CHAR_NPCWORKINT4, + NPC_WORK_MODE = CHAR_NPCWORKINT5, + NPC_WORK_CURRENTROUTE = CHAR_NPCWORKINT6, + NPC_WORK_ROUTEMAX = CHAR_NPCWORKINT7, + NPC_WORK_WAITTIME = CHAR_NPCWORKINT8, + NPC_WORK_CURRENTTIME = CHAR_NPCWORKINT9, + NPC_WORK_SEFLG = CHAR_NPCWORKINT10, +*/ +}; + +#define STANDBYTIME 50 + +static void NPC_NewVipShop_selectWindow( int meindex, int toindex, int num,int select); +BOOL NewVipShop_GetMenuStr( int meindex, int toindex, char *npcarg, char *token, int index ); +int NewVipShop_ShowMenulist( char *npcarg ); + +int page; + +BOOL NPC_NewVipshopInit( int meindex ) +{ + char npcarg[NPC_UTIL_GETARGSTR_BUFSIZE]; + + if(NPC_Util_GetArgStr( meindex, npcarg, sizeof(npcarg))==NULL){ + print("TRANSER_MAN: GetArgStrErr!!"); + return FALSE; + } + + CHAR_setInt( meindex, CHAR_WHICHTYPE, CHAR_TRANSERMANS); + + //CHAR_setInt( meindex, CHAR_LOOPINTERVAL, NEWNPCMAN_STANDBY); + CHAR_setWorkInt( meindex, NPC_WORK_CURRENTTIME, NowTime.tv_sec); + return TRUE; +} +//CHAR_setWorkInt(talkerindex,CHAR_WORKSHOPRELEVANT,1); +void NPC_NewVipshopTalked( int meindex, int talkerindex, char *msg, int color ) +{ + if( CHAR_getInt( talkerindex , CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER ) + return; + if(NPC_Util_isFaceToFace( meindex ,talkerindex , 2) == FALSE) { + if(NPC_Util_isFaceToChara( talkerindex, meindex, 1) == FALSE) + return; + } + + CHAR_setWorkInt( talkerindex, CHAR_WORKSHOPRELEVANT, 0); + NPC_NewVipShop_selectWindow( meindex, talkerindex, WINDOW_START, 0); +} + +void NPC_NewVipshopWindowTalked( int meindex, int talkerindex, int seqno, + int select, char *data) +{ + if( select == WINDOW_BUTTONTYPE_CANCEL || select == WINDOW_BUTTONTYPE_NO) + return; + switch( seqno) { + case NPC_TRANSERMAN_START: + break; + case NPC_TRANSERMAN_SELECT: + NPC_NewVipShop_selectWindow( meindex, talkerindex, WINDOW_SELECT, atoi( data)); + break; + case NPC_TRANSERMAN_WARP: + if( select == WINDOW_BUTTONTYPE_CANCEL ) + return; + if( select == WINDOW_BUTTONTYPE_NEXT ) + { + NPC_NewVipShop_selectWindow( meindex, talkerindex, WINDOW_NEXT, atoi( data)); + return; + } + if( select == WINDOW_BUTTONTYPE_PREV ) + { + NPC_NewVipShop_selectWindow( meindex, talkerindex, WINDOW_PREV, atoi( data)); + return; + } + NPC_NewVipShop_selectWindow( meindex, talkerindex, WINDOW_WARP, atoi( data)); + break; + case NPC_TRANSERMAN_END: + NPC_NewVipShop_selectWindow( meindex, talkerindex, WINDOW_END, atoi( data)); + break; + } + +} + +static void NPC_NewVipShop_selectWindow( int meindex, int toindex, int num,int select) +{ + char npcarg[NPC_UTIL_GETARGSTR_BUFSIZE]; + char token[1024]; + char buf1[256]; + char buf2[256]; + char buf3[256]; + int buttontype = 0, windowtype = 0, windowno = 0; + int fd = getfdFromCharaIndex( toindex); + static int select1; + windowtype = WINDOW_MESSAGETYPE_MESSAGE; + + if(NPC_Util_isFaceToFace( meindex ,toindex , 2) == FALSE) { + if(NPC_Util_isFaceToChara( toindex, meindex, 1) == FALSE) + return; + } + + memset( npcarg, 0, sizeof( npcarg)); + if(NPC_Util_GetArgStr( meindex, npcarg, sizeof(npcarg))==NULL){ + print("NewVipShop_MAN: GetArgStrErr!!"); + return; + } + memset( token, 0, sizeof( token)); + + switch( num) { + case WINDOW_START: + if( NPC_Util_GetStrFromStrWithDelim( npcarg, "START_MSG", token, sizeof( token) ) == NULL) { + print("NewVipShop Get START_MSG ERROR !"); + return; + } + CHAR_setWorkInt( toindex, CHAR_WORKSHOPRELEVANT, WINDOW_START); + buttontype = WINDOW_BUTTONTYPE_YESNO; + windowno = NPC_TRANSERMAN_SELECT; + break; + case WINDOW_SELECT: + CHAR_setWorkInt( toindex, CHAR_WORKLISTPAGE, 0); + page=NewVipShop_ShowMenulist(npcarg); + if( NewVipShop_GetMenuStr( meindex, toindex, npcarg, token,CHAR_getWorkInt( toindex, CHAR_WORKLISTPAGE)) == FALSE ) { + print( "NewVipShop GetMenu ERROR !!"); + return; + } + windowtype = WINDOW_MESSAGETYPE_SELECT; + if(page>1) + buttontype = WINDOW_BUTTONTYPE_CANCEL|WINDOW_BUTTONTYPE_NEXT; + else + buttontype = WINDOW_BUTTONTYPE_CANCEL; + windowno = NPC_TRANSERMAN_WARP; + break; + case WINDOW_NEXT: + if(CHAR_getWorkInt( toindex, CHAR_WORKLISTPAGE)<=page) + CHAR_setWorkInt( toindex, CHAR_WORKLISTPAGE, CHAR_getWorkInt( toindex, CHAR_WORKLISTPAGE)+1); + if( NewVipShop_GetMenuStr( meindex, toindex, npcarg, token,CHAR_getWorkInt( toindex, CHAR_WORKLISTPAGE)) == FALSE ) { + print( "NewVipShop GetMenu ERROR !!"); + return; + } + windowtype = WINDOW_MESSAGETYPE_SELECT; + if(CHAR_getWorkInt( toindex, CHAR_WORKLISTPAGE)+1==page) + buttontype = WINDOW_BUTTONTYPE_CANCEL|WINDOW_BUTTONTYPE_PREV; + else + buttontype = WINDOW_BUTTONTYPE_CANCEL|WINDOW_BUTTONTYPE_PREV|WINDOW_BUTTONTYPE_NEXT; + windowno = NPC_TRANSERMAN_WARP; + break; + case WINDOW_PREV: + if(CHAR_getWorkInt( toindex, CHAR_WORKLISTPAGE)>0) + CHAR_setWorkInt( toindex, CHAR_WORKLISTPAGE, CHAR_getWorkInt( toindex, CHAR_WORKLISTPAGE)-1); + if( NewVipShop_GetMenuStr( meindex, toindex, npcarg, token,CHAR_getWorkInt( toindex, CHAR_WORKLISTPAGE)) == FALSE ) { + print( "NewVipShop GetMenu ERROR !!"); + return; + } + windowtype = WINDOW_MESSAGETYPE_SELECT; + if(CHAR_getWorkInt( toindex, CHAR_WORKLISTPAGE)==0) + buttontype = WINDOW_BUTTONTYPE_CANCEL|WINDOW_BUTTONTYPE_NEXT; + else + buttontype = WINDOW_BUTTONTYPE_PREV|WINDOW_BUTTONTYPE_CANCEL|WINDOW_BUTTONTYPE_NEXT; + windowno = NPC_TRANSERMAN_WARP; + break; + case WINDOW_WARP: + select1=CHAR_getWorkInt( toindex, CHAR_WORKLISTPAGE)*7+select; + CHAR_setWorkInt( toindex, CHAR_WORKLISTSELECT , select1); + if( NPC_Util_GetStrFromStrWithDelim( npcarg, "END_MSG", buf1, sizeof( buf1) ) == NULL) { + print("NewVipShop Get START_MSG ERROR !"); + return; + } + if(getStringFromIndexWithDelim( npcarg,"}",select1, buf2, sizeof( buf2)) != FALSE) + NPC_Util_GetStrFromStrWithDelim( buf2, "MenuStr", buf3, sizeof( buf3)); + sprintf( token, "\n%s\n\n %s\n",buf1, buf3); + + windowtype = WINDOW_MESSAGETYPE_MESSAGE; + buttontype = WINDOW_BUTTONTYPE_YESNO; + windowno = NPC_TRANSERMAN_END; + break; + case WINDOW_END: + ActionNpc_CheckMenuFree( meindex, toindex, npcarg, CHAR_getWorkInt( toindex, CHAR_WORKLISTSELECT )); + return; + break; + } + + lssproto_WN_send( fd, windowtype, buttontype, windowno, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), token); +} + + +void NPC_NewVipshopLoop( int meindex) +{ + +} + +BOOL NewVipShop_GetMenuStr( int meindex, int toindex, char *npcarg, char *token,int index ) +{ + char buf1[1024], buf2[32], buf3[36]; + BOOL FINDS=FALSE; + int talkNo=index*7+1; + if( npcarg == NULL ) return FALSE; + + sprintf( token, "㵱ǰĻԱ:%d %d/%dҳ\n",sasql_vippoint(CHAR_getUseID(toindex),0,0), index+1, page); + while( getStringFromIndexWithDelim( npcarg,"}",talkNo, buf1, sizeof( buf1)) != FALSE ) { + talkNo++; + memset( buf2, 0, sizeof( buf2)); + if( NPC_Util_GetStrFromStrWithDelim( buf1, "MenuStr", buf2, sizeof( buf2)) == NULL ) + continue; + FINDS = TRUE; + + sprintf( buf3, " %s", buf2); + if(strlen(buf3)<10) + strcat( buf3, "\n"); + else + strcat( buf3, "\n"); + strcat( token, buf3); + if(talkNo>(index*7+7))return FINDS; + } + return FINDS; +} + +int NewVipShop_ShowMenulist( char *npcarg ) +{ + char buf1[1024]; + int talkNo=1; + while( getStringFromIndexWithDelim( npcarg,"}",talkNo, buf1, sizeof( buf1)) != FALSE ) { + talkNo++; + } + return (talkNo-3)/7+1; +} + +#endif diff --git a/npc/npc_npcenemy.c b/npc/npc_npcenemy.c new file mode 100644 index 0000000..28369fe --- /dev/null +++ b/npc/npc_npcenemy.c @@ -0,0 +1,1563 @@ +#include "version.h" +#include +#include "char.h" +#include "object.h" +#include "char_base.h" +#include "npcutil.h" +#include "npc_npcenemy.h" +#include "battle.h" +#include "enemy.h" +#include "readmap.h" +#include "encount.h" +#include "lssproto_serv.h" +#include "configfile.h" +#include "anim_tbl.h" +#include "handletime.h" +#include "npc_eventaction.h" +extern char hanzibuf[5000][8]; +enum { + CHAR_WORK_ENCOUNTTYPE = CHAR_NPCWORKINT1, /* ޼ */ + CHAR_WORK_DIEACT = CHAR_NPCWORKINT2, /* Ϸ¾ */ + CHAR_WORK_WARP_FLOOR = CHAR_NPCWORKINT3, /* °׷ʧ*/ + CHAR_WORK_WARP_X = CHAR_NPCWORKINT4, /* X */ + CHAR_WORK_WARP_Y = CHAR_NPCWORKINT5, /* Y */ + CHAR_WORK_ONEBATTLE = CHAR_NPCWORKINT6, /* ƾ ئ */ + NPC_TIME_MODE = CHAR_NPCWORKINT7, + CHAR_WORK_BASEIMGBAK = CHAR_NPCWORKINT8, /* 缰 į */ + CHAR_WORK_DIETIME = CHAR_NPCWORKINT9, /* Ϸ */ + CHAR_WORK_REVIVALTIME = CHAR_NPCWORKINT10, /* Ϸ߯ */ + CHAR_WORK_BATTLETYPE = CHAR_NPCWORKINT11, +#ifdef _WARNPC_CTRL + CHAR_WORK_BATTLEINGTIME = CHAR_NPCWORKINT12, +#endif +}; + +#define NPC_ENEMY_REVIVALTIMA_DEFAULT 120 + +static int gymbody[] = { + SPR_001em,SPR_011em,SPR_021em,SPR_031em,SPR_041em,SPR_051em, + SPR_061em,SPR_071em,SPR_081em,SPR_091em,SPR_101em,SPR_111em, + + SPR_002em,SPR_012em,SPR_022em,SPR_032em,SPR_042em,SPR_052em, + SPR_062em,SPR_072em,SPR_082em,SPR_092em,SPR_102em,SPR_112em, + + SPR_003em,SPR_013em,SPR_023em,SPR_033em,SPR_043em,SPR_053em, + SPR_063em,SPR_073em,SPR_083em,SPR_093em,SPR_103em,SPR_113em, + + SPR_004em,SPR_014em,SPR_024em,SPR_034em,SPR_044em,SPR_054em, + SPR_064em,SPR_074em,SPR_084em,SPR_094em,SPR_104em,SPR_114em, +}; + +#ifdef _NEW_WARPMAN +static BOOL NPC_NPCEnemy_CheckFree( int meindex, int toindex, BOOL *Party); +BOOL NPC_WarpAllMsg(int meindex,int toindex ); +BOOL NPCEnemy_CheckFree( int meindex, int talker, char *buf); +BOOL NPCEnemy_BSCheck(int meindex,int talker,char* buf); +BOOL NPCEnemy_FreeIfCheck(int meindex,int talker,char* buf,int kosuu,int flg, int temp); +BOOL NPCEnemy_WarpManReduce(int meindex,int talker,char *buf); +BOOL NPCEnemy_BigSmallLastCheck(int point1,int mypoint,int flg); +BOOL NPCEnemy_CheckTrans(int meindex,int talker,int trans,int flg); +BOOL NPCEnemy_LevelCheck(int meindex,int talker,int level,int flg); +BOOL NPCEnemy_CheckMyPet( int meindex, int talker, int petLv, int flg, int petid); +BOOL NPCEnemy_ItemCheck(int meindex,int talker,int itemNo,int flg); +#endif +#ifdef _NPC_REPLACEMENT +void Check_EnemyWarpMe( int meindex, char *args ); +#endif +static int NPC_NPCEnemy_StealItem( char *argstr, int meindex, int charaindex); + +BOOL NPC_NPCEnemyInit( int meindex ) +{ + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + char buf[64]; + int tmp, gym; +#ifdef _NPCENEMY_1 + char token1[128]; +#endif + + if( NPC_Util_GetArgStr( meindex, argstr, sizeof( argstr)) == NULL ) { + print("Can't GetArgStr !!"); + return FALSE; + } + if( NPC_Util_GetStrFromStrWithDelim( argstr, "sktype", buf, sizeof( buf)) != NULL ){ + CHAR_setWorkInt( meindex, CHAR_WORK_BATTLETYPE, atoi( buf)); + }else{ + CHAR_setWorkInt( meindex, CHAR_WORK_BATTLETYPE, 0); + } + + if( NPC_Util_GetStrFromStrWithDelim( argstr, "enemyno", buf, sizeof( buf)) == NULL ){ + char filename[256]; + NPC_Util_CheckAssignArgFile( meindex, filename); + print( "NPCEnemy: nothing parameter [enemyno]:\n%s\n", filename); + return FALSE; + }else { + int i; + for( i = 0; i < NPC_ENEMY_ENEMYNUMBER; i ++ ) { + int curEnemy; + char data[128]; + int ret; + ret = getStringFromIndexWithDelim( buf,",", i + 1, data, sizeof(data)); + if( ret == FALSE) + break; + curEnemy = ENEMY_getEnemyArrayFromId( atoi( data)); + if( !ENEMY_CHECKINDEX( curEnemy) ) { + char filename[256]; + NPC_Util_CheckAssignArgFile( meindex, filename); + print( "NPCEnemy: invalid param [enemyno:%d data:%s curEnemy:%d]\nfile:%s\n",i+1, data, curEnemy, filename ); + return FALSE; + } + } + } + + if( NPC_Util_GetStrFromStrWithDelim( argstr, "steal", buf, sizeof( buf)) != NULL ) { + if( NPC_Util_GetStrFromStrWithDelim( argstr, "item", buf, sizeof( buf)) == NULL ) { + print( "NPCEnemy:ָstealûָitem\n"); + return FALSE; + } + } + + gym = NPC_Util_GetNumFromStrWithDelim( argstr, "gym"); + + if( gym > 0 ){ + CHAR_setInt( meindex, CHAR_BASEBASEIMAGENUMBER, + gymbody[RAND( 0, arraysizeof( gymbody ) - 1)] ); + CHAR_setInt( meindex, CHAR_BASEIMAGENUMBER, + CHAR_getInt( meindex, CHAR_BASEBASEIMAGENUMBER ) ); + CHAR_setInt( meindex, CHAR_LV, gym ); + } + tmp = NPC_Util_GetNumFromStrWithDelim( argstr, "dieact"); + if( tmp != 1 ) + tmp = 0; + CHAR_setWorkInt( meindex, CHAR_WORK_DIEACT, tmp); + if( strstr( argstr, "NEWNPCENEMY") != 0 ) { + CHAR_setWorkInt( meindex, CHAR_WORK_WARP_FLOOR, 0 ); + CHAR_setWorkInt( meindex, CHAR_WORK_WARP_Y, 0 ); + CHAR_setWorkInt( meindex, CHAR_WORK_WARP_X, 0 ); + }else { + if( CHAR_getWorkInt( meindex, CHAR_WORK_DIEACT) == 1 ) { + char buff1[256]; + if( NPC_Util_GetStrFromStrWithDelim( argstr, "warpfl", buff1, sizeof( buff1) ) == NULL) { + print( "NPCENEMY: nothing warp_floor %s\n", buff1); + return FALSE; + } + tmp = atoi( buff1); + CHAR_setWorkInt( meindex, CHAR_WORK_WARP_FLOOR, tmp); + if( NPC_Util_GetStrFromStrWithDelim( argstr, "warpx", buff1, sizeof( buff1) ) == NULL) { + print( "NPCENEMY: nothing warp_x\n"); + return FALSE; + } + tmp = atoi( buff1); + CHAR_setWorkInt( meindex, CHAR_WORK_WARP_X, tmp); + if( NPC_Util_GetStrFromStrWithDelim( argstr, "warpy", buff1, sizeof( buff1) ) == NULL) { + print( "NPCENEMY: nothing warp_y\n"); + return FALSE; + } + tmp = atoi( buff1); + CHAR_setWorkInt( meindex, CHAR_WORK_WARP_Y, tmp); + if( MAP_IsValidCoordinate( CHAR_getWorkInt( meindex, CHAR_WORK_WARP_FLOOR), + CHAR_getWorkInt( meindex, CHAR_WORK_WARP_X), + CHAR_getWorkInt( meindex, CHAR_WORK_WARP_Y) ) == FALSE ){ + char filename[256]; + NPC_Util_CheckAssignArgFile( meindex, filename); + print( "NPCENEMY: %s: .\n %s.\nInvalid fl=%d,x=%d,y=%d\n", filename, argstr, + CHAR_getWorkInt( meindex, CHAR_WORK_WARP_FLOOR), + CHAR_getWorkInt( meindex, CHAR_WORK_WARP_X), + CHAR_getWorkInt( meindex, CHAR_WORK_WARP_Y) ); + return FALSE; + } + } + } + //andy_end + tmp = NPC_Util_GetNumFromStrWithDelim( argstr, "entype"); + if( tmp != 1 && tmp != 2) + tmp = 0; + CHAR_setWorkInt( meindex, CHAR_WORK_ENCOUNTTYPE, tmp); + + tmp = NPC_Util_GetNumFromStrWithDelim( argstr, "onebattle"); + if( tmp != 1 ) + tmp = 0; + CHAR_setWorkInt( meindex, CHAR_WORK_ONEBATTLE, tmp); + + tmp = NPC_Util_GetNumFromStrWithDelim( argstr, "time"); + if( tmp == -1 ) + tmp = NPC_ENEMY_REVIVALTIMA_DEFAULT; + CHAR_setWorkInt( meindex, CHAR_WORK_REVIVALTIME, tmp); + + + CHAR_setInt( meindex , CHAR_WHICHTYPE , CHAR_TYPENPCENEMY ); + CHAR_setWorkInt( meindex, CHAR_WORKEVENTTYPE, CHAR_EVENT_ENEMY); + CHAR_setWorkInt( meindex, CHAR_WORK_BASEIMGBAK, + CHAR_getInt( meindex, CHAR_BASEIMAGENUMBER)); + return TRUE; +} + +void NPC_NPCEnemyTalked( int meindex , int talkerindex , char *szMes , + int color ) +{ + char npcarg[NPC_UTIL_GETARGSTR_BUFSIZE]; + char buf[256]; + + if( CHAR_getInt( talkerindex , CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER ) { + return; + } + if( NPC_Util_GetArgStr( meindex, npcarg, sizeof( npcarg)) == NULL ) { + print("Can't GetArgStr !!"); + return; + } + if( NPC_Util_GetStrFromStrWithDelim( npcarg, "NEWTIME", buf, sizeof( buf)) != NULL ){ + if( CHAR_getWorkInt( meindex, NPC_TIME_MODE) <= 0 ) { + if( NPC_Util_GetStrFromStrWithDelim( npcarg, "Time_Msg", buf, sizeof( buf) ) != NULL) { + CHAR_talkToCli( talkerindex, meindex, buf, CHAR_COLORYELLOW); + } + return; + } + } + if( !NPC_Util_charIsInFrontOfChar( talkerindex, meindex, 1 )) + return; + if( CHAR_getWorkInt( meindex, CHAR_WORK_ENCOUNTTYPE) >= 1 ) { + if(strstr(npcarg,"STARTRAND")!=NULL){ + time_t timep; + struct tm *p; + time(&timep); + p=localtime(&timep); + timep = mktime(p); + char *randtypetime = CHAR_getChar(talkerindex,CHAR_RANDTYPE); + char tempbuff[64]; + int randtype = 0; + int randtime = 0; + int randwrong = 0; + if(strlen(randtypetime)>2){ + if(getStringFromIndexWithDelim(randtypetime,"-", 3, tempbuff, sizeof(tempbuff)) != FALSE){ + if(getStringFromIndexWithDelim(randtypetime,"-", 1, tempbuff, sizeof(tempbuff))== FALSE) + return; + randwrong = atoi(tempbuff); + if(getStringFromIndexWithDelim(randtypetime,"-", 2, tempbuff, sizeof(tempbuff))== FALSE) + return; + randtype = atoi(tempbuff); + if(getStringFromIndexWithDelim(randtypetime,"-", 3, tempbuff, sizeof(tempbuff))== FALSE) + return; + randtime = atoi(tempbuff); +#ifdef _MM_NO_JIAOBEN + if(timep - randtime < getEditBaseTime()*randwrong){ + char errbuf[256]; + sprintf(errbuf,"%dſԼ˲",getEditBaseTime()*randwrong-(timep - randtime)); + CHAR_talkToCli(talkerindex, -1, errbuf, CHAR_COLORRED); + return; + } +#endif + } + } +// if(timep-CHAR_getWorkInt(talkerindex,CHAR_WORKRANDEDITBASETIME)>=getEditBaseTime()) +// CHAR_setWorkInt(talkerindex,CHAR_WORKRANDEDITBASETIME,timep); +// else{ +// char errbuf[256]; +// sprintf(errbuf,"%dſԼ˲",getEditBaseTime()-(timep-CHAR_getWorkInt(talkerindex,CHAR_WORKRANDEDITBASETIME))); +// CHAR_talkToCli(talkerindex, -1, errbuf, CHAR_COLORRED); +// return; +// } + char jiabuf[][5]={"","","","","","ʮ",""}; + char jianbuf[][5]={"","һ","-","","-","",""}; + char chengbuf[][5]={"","*","x","X","","",""}; + char numbuf[][5]={"","","","","","","","","",""}; + char arg[255]; + int i,j,k,l,m; + char buf[256]; + i = RAND(30,70); + j = RAND(1,29); + l = RAND(1,7); + m = RAND(1,3); + char *typebuf; +// if(randtype == 0){ +// randtype = RAND(1,10); +// if(randtype<=5){ +// randtype = RAND(1,10); +// if(randtype<=3) randtype=1; +// else randtype=2; +// }else{ +// randtype = RAND(1,10); +// if(randtype<=3) randtype=3; +// else randtype=4; +// } +// } + randtype = 4; + { +// sprintf(arg,"%s",sasql_rand_buf()); +// if(strcmp(arg,"err")==0) return; + char tempbuf[64]; + char randquestion[64]; + char randrightanswer[64]; + char randwronganswer1[64]; + char randwronganswer2[64]; + char randwronganswer3[64]; + char randwronganswer4[64]; +// if(getStringFromIndexWithDelim(arg,"|", 1, tempbuf, sizeof(tempbuf)) == FALSE) +// return; +// strcpy(randquestion,tempbuf); +// if(getStringFromIndexWithDelim(arg,"|", 2, tempbuf, sizeof(tempbuf)) == FALSE) +// return; +// strcpy(randrightanswer,tempbuf); +// if(getStringFromIndexWithDelim(arg,"|", 3, tempbuf, sizeof(tempbuf)) == FALSE) +// return; +// strcpy(randwronganswer1,tempbuf); +// if(getStringFromIndexWithDelim(arg,"|", 4, tempbuf, sizeof(tempbuf)) == FALSE) +// return; +// strcpy(randwronganswer2,tempbuf); +// if(getStringFromIndexWithDelim(arg,"|", 5, tempbuf, sizeof(tempbuf)) == FALSE) +// return; +// strcpy(randwronganswer3,tempbuf); +// if(getStringFromIndexWithDelim(arg,"|", 6, tempbuf, sizeof(tempbuf)) == FALSE) +// return; +// strcpy(randwronganswer4,tempbuf); + memset(tempbuf, 0, sizeof(tempbuf)); + memset(randquestion, 0, sizeof(randquestion)); + memset(randrightanswer, 0, sizeof(randrightanswer)); + memset(randwronganswer1, 0, sizeof(randwronganswer1)); + memset(randwronganswer2, 0, sizeof(randwronganswer2)); + memset(randwronganswer3, 0, sizeof(randwronganswer3)); + memset(randwronganswer4, 0, sizeof(randwronganswer4)); + if(RAND(1,100)<=75){ + char randtmpbuf[4][10]; + sprintf(randtmpbuf[0],"%s",hanzibuf[RAND(1,5000)-1]); + sprintf(randtmpbuf[1],"%s",hanzibuf[RAND(1,5000)-1]); + sprintf(randtmpbuf[2],"%s",hanzibuf[RAND(1,5000)-1]); + sprintf(randtmpbuf[3],"%s",hanzibuf[RAND(1,5000)-1]); + sprintf(randquestion,"%s",str_hanzi_ganrao(randtmpbuf[0],randtmpbuf[1],randtmpbuf[2],randtmpbuf[3],0,0,0,0,0,0)); + strcat(randquestion,"ҳͬ飩"); + int newrand1 = RAND(1,100)-1; + int newrand2 = RAND(1,100)-1; + int newrand3 = RAND(1,100)-1; + int newrand4 = RAND(1,100)-1; + int newrand5 = RAND(1,100)-1; + sprintf(randrightanswer,"%s",str_hanzi_ganrao(randtmpbuf[0],randtmpbuf[1],randtmpbuf[2],randtmpbuf[3],1,newrand1,newrand2,newrand3,newrand4,newrand5)); + sprintf(randwronganswer1,"%s",str_hanzi_ganrao(randtmpbuf[0],randtmpbuf[1],randtmpbuf[3],randtmpbuf[2],1,newrand1,newrand2,newrand3,newrand4,newrand5)); + sprintf(randwronganswer2,"%s",str_hanzi_ganrao(randtmpbuf[3],randtmpbuf[1],randtmpbuf[2],randtmpbuf[0],1,newrand1,newrand2,newrand3,newrand4,newrand5)); + sprintf(randwronganswer3,"%s",str_hanzi_ganrao(randtmpbuf[1],randtmpbuf[0],randtmpbuf[2],randtmpbuf[3],1,newrand1,newrand2,newrand3,newrand4,newrand5)); + sprintf(randwronganswer4,"%s",str_hanzi_ganrao(randtmpbuf[2],randtmpbuf[3],randtmpbuf[0],randtmpbuf[1],1,newrand1,newrand2,newrand3,newrand4,newrand5)); + + }else{ + int tii; + char timubuf[36][5] = {"a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","0","1","2","3","4","5","6","7","8","9"}; + for(tii=0;tii<5;tii++){ + if(tii==0) + strcpy(tempbuf,timubuf[RAND(1,36)-1]); + else{ + int timunum = 0; + while(1){ + timunum = RAND(1,36)-1; + if(strstr(tempbuf,timubuf[timunum])==NULL) + break; + } + strcat(tempbuf,timubuf[timunum]); + } + } + sprintf(randwronganswer1,"[%c%c%c%c%c]",tempbuf[0],tempbuf[2],tempbuf[1],tempbuf[3],tempbuf[4]); + sprintf(randwronganswer2,"[%c%c%c%c%c]",tempbuf[0],tempbuf[1],tempbuf[4],tempbuf[2],tempbuf[3]); + sprintf(randwronganswer3,"[%c%c%c%c%c]",tempbuf[4],tempbuf[1],tempbuf[2],tempbuf[0],tempbuf[3]); + sprintf(randwronganswer4,"[%c%c%c%c%c]",tempbuf[1],tempbuf[0],tempbuf[2],tempbuf[3],tempbuf[4]); + sprintf(randquestion,"[%s]ҳͬӢģ",tempbuf); + sprintf(randrightanswer,"[%s]",tempbuf); + char* randstr = NULL; + randstr = str_ganrao(randquestion); + strcpy(randquestion,randstr); + randstr = str_ganraoan(randrightanswer); + strcpy(randrightanswer,randstr); + randstr = str_ganraoan(randwronganswer1); + strcpy(randwronganswer1,randstr); + randstr = str_ganraoan(randwronganswer2); + strcpy(randwronganswer2,randstr); + randstr = str_ganraoan(randwronganswer3); + strcpy(randwronganswer3,randstr); + randstr = str_ganraoan(randwronganswer4); + strcpy(randwronganswer4,randstr); + } + int n; + int randnum1; + m=1; + char tempret[5][64]; + randnum1 = RAND(1,5); + int rightnum,wrongnum1,wrongnum2,wrongnum3,wrongnum4; + rightnum = RAND(getRandMin(),getRandMax()); + wrongnum1 = RAND(getRandMin(),getRandMax()); + wrongnum2 = RAND(getRandMin(),getRandMax()); + wrongnum3 = RAND(getRandMin(),getRandMax()); + wrongnum4 = RAND(getRandMin(),getRandMax()); + //char *tempbuff2 = "ABCDE"; + int qianhounum = RAND(1,100); + for(n=1;n<=5;n++){ + if(n==randnum1){ + if(qianhounum<=50) + sprintf(tempret[n-1],"ѡ( %d %s )",rightnum,randrightanswer); + else + sprintf(tempret[n-1],"ѡ( %s %d )",randrightanswer,rightnum); + }else{ + if(m==1){ + if(qianhounum<=50) + sprintf(tempret[n-1],"ѡ( %d %s )",wrongnum1,randwronganswer1); + else + sprintf(tempret[n-1],"ѡ( %s %d )",randwronganswer1,wrongnum1); + m = 2; + }else if(m==2){ + if(qianhounum<=50) + sprintf(tempret[n-1],"ѡ( %d %s )",wrongnum2,randwronganswer2); + else + sprintf(tempret[n-1],"ѡ( %s %d )",randwronganswer2,wrongnum2); + m = 3; + }else if(m==3){ + if(qianhounum<=50) + sprintf(tempret[n-1],"ѡ( %d %s )",wrongnum3,randwronganswer3); + else + sprintf(tempret[n-1],"ѡ( %s %d )",randwronganswer3,wrongnum3); + m = 4; + }else if(m==4){ + if(qianhounum<=50) + sprintf(tempret[n-1],"ѡ( %d %s )",wrongnum4,randwronganswer4); + else + sprintf(tempret[n-1],"ѡ( %s %d )",randwronganswer4,wrongnum4); + m = 5; + } + } + } + int windowtype = 0; + int selecttype = RAND(1,100); + if(selecttype<=30){ + sprintf(buf,"%d|%d",rightnum,meindex); + windowtype = WINDOW_MESSAGETYPE_MESSAGEANDLINEINPUT; + }else{ + sprintf(buf,"%d|%d",randnum1,meindex); + windowtype = WINDOW_MESSAGETYPE_SELECT; + } + CHAR_setWorkChar(talkerindex, CHAR_WORKRANDMSG, buf); + int fd = getfdFromCharaIndex( talkerindex ); + sprintf(buf,"%s\n%s\n%s\n%s\n%s\n%s\nȷڵ5λֻߵѡ",randquestion,tempret[0],tempret[1],tempret[2],tempret[3],tempret[4]); + lssproto_WN_send( fd, windowtype, + WINDOW_BUTTONTYPE_OK, + CHAR_WINDOWTYPE_NPCENEMY_RAND_MSG, + -1, + buf); + CHAR_setWorkInt(talkerindex,CHAR_WORKLUANPCINT,0); + } + if(randwrong<=0){ + sprintf(tempbuff,"1-%d-%d",randtype,timep); + }else{ + sprintf(tempbuff,"%d-%d-%d",randwrong*3,randtype,timep); + } + CHAR_setChar(talkerindex,CHAR_RANDTYPE,tempbuff); + return; + } + NPC_NPCEnemy_Encount( meindex, talkerindex, 1); + } +} + +int NPC_NPCEnemy_Encount( int meindex, int charaindex, int mode) +{ + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + char buf[512]; + BOOL flg = TRUE; + int battlemax = getBattlenum(); + int i; + if( CHAR_getInt( meindex, CHAR_BASEIMAGENUMBER) == 0 ) { + return FALSE; + } + if( mode == 0 ) { + if( CHAR_getWorkInt( meindex, CHAR_WORK_ENCOUNTTYPE) == 1 ) { + flg = FALSE; + } + }else if( mode == 1 ) { + if( CHAR_getWorkInt( meindex, CHAR_WORK_ENCOUNTTYPE) == 0 ) { + flg = FALSE; + } + } + + NPC_Util_GetArgStr( meindex, argstr, sizeof( argstr)); + + if( !flg) { + if( NPC_Util_GetStrFromStrWithDelim( argstr, "deniedmsg", buf, sizeof( buf)) != NULL ) { + CHAR_talkToCliAndParty( charaindex, meindex ,buf , CHAR_COLORYELLOW ); + } + return FALSE; + } + flg = FALSE; + while( 1 ) { + char buf[1024]; + if( NPC_Util_GetStrFromStrWithDelim( argstr, "item", buf, sizeof( buf)) != NULL ) { + char data[128]; + BOOL found = FALSE; + + for( i = 0; i < CHAR_MAXITEMHAVE; i ++ ) { + int j; + int itemid; + int ret = getStringFromIndexWithDelim( buf,",", i + 1,data, sizeof(data)); + if( ret == FALSE) + break; + found = FALSE; + itemid = atoi( data); + for( j = 0; j < CHAR_MAXITEMHAVE; j ++ ) { + int itemindex = CHAR_getItemIndex( charaindex, j); + if( ITEM_CHECKINDEX( itemindex)) { + if( ITEM_getInt( itemindex, ITEM_ID) == itemid ) { + found = TRUE; + break; + } + } + } + if( !found ) + break; + } + if( !found ) + break; + } +#ifdef _ADD_NOITEM_BATTLE + if(NPC_Util_GetStrFromStrWithDelim(argstr,"noitem",buf,sizeof(buf)) != NULL){ + char data[128]; + BOOL found = FALSE; + + for(i=0;i= sizeof( buf) ) { + print( "buffer over\n"); + return FALSE; + } + } + else { + strcpysafe( &buf[len], sizeof( buf)-len, "\n" ); + len++; + if( len >= sizeof( buf) ) { + print( "buffer over\n"); + return FALSE; + } + } + } + + if( fd != -1 ) { + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_YESNO, + CHAR_WINDOWTYPE_NPCENEMY_START, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + makeEscapeString( buf, escapebuf,sizeof(escapebuf))); + } + /* */ + return FALSE; + }else { + /* */ + flg = NPC_NPCEnemy_BattleIn( meindex, charaindex); + } + } + } + if( !flg) { + if( NPC_Util_GetStrFromStrWithDelim( argstr, "deniedmsg", buf, sizeof( buf))!= NULL ) + { + CHAR_talkToCliAndParty( charaindex, meindex ,buf , CHAR_COLORYELLOW ); + } + } + return flg; +} + +int NPC_NPCEnemy_Dying( int battleindex, int meindex ) +{ + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + char buf[64]; + int i,toindex=-1; + int tmp=-1; + + if( !CHAR_CHECKINDEX( meindex)) { + return FALSE; + } + NPC_Util_GetArgStr( meindex, argstr, sizeof( argstr)); + +#ifdef _NEW_WARPMAN + if( strstr( argstr, "NEWNPCENEMY") ) { + }else { +#endif + /* Ӭ ̫ */ + if( NPC_Util_GetStrFromStrWithDelim( argstr, "endmsg", buf, sizeof( buf)) != NULL ) { + for( i = 0; i < 5; i ++ ) { + /* 帨ƻ幻嶪 */ + int toindex = BattleArray[battleindex].Side[0].Entry[i].charaindex; + if( CHAR_CHECKINDEX( toindex) ) { + CHAR_talkToCli( toindex, meindex ,buf , CHAR_COLORYELLOW ); + } + } + + } +#ifdef _NEW_WARPMAN + } +#endif + if( NPC_Util_GetStrFromStrWithDelim( argstr, "steal", buf, sizeof( buf)) != NULL ) { + print("\n steal TRUE !!"); + if( atoi( buf) == 1 ) { + int charaindex = BattleArray[battleindex].Side[0].Entry[0].charaindex; + NPC_NPCEnemy_StealItem( argstr, meindex, charaindex); + } + + } +#ifdef _ALLDOMAN // (ɿ) Syu ADD аNPC + if( NPC_Util_GetStrFromStrWithDelim( argstr, "herobattlefield", buf, sizeof( buf)) != NULL ) { + int charaindex = BattleArray[battleindex].Side[0].Entry[0].charaindex; + CHAR_setWorkInt ( charaindex , CHAR_WORKHEROFLOOR , atoi ( buf ) ) ; + // Syu ADD + if ( atoi ( buf ) > CHAR_getInt ( charaindex , CHAR_HEROFLOOR ) ) + CHAR_setInt ( charaindex , CHAR_HEROFLOOR , atoi( buf ) ) ; + } + +#endif + tmp = NPC_Util_GetNumFromStrWithDelim( argstr, "dieact"); + if( tmp != 1 ) + tmp = 0; + CHAR_setWorkInt( meindex, CHAR_WORK_DIEACT, tmp); + + if( CHAR_getWorkInt( meindex, CHAR_WORK_DIEACT) == 0 ) { + Char *ch; + CHAR_setInt( meindex, CHAR_BASEIMAGENUMBER, 0); + print("bbi---->bi10"); + CHAR_sendCToArroundCharacter( CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX)); + + CHAR_setWorkInt( meindex, CHAR_WORKEVENTTYPE, CHAR_EVENT_ALTERRATIVE); + MAP_sendAroundMapdata( CHAR_getInt( meindex, CHAR_FLOOR), + CHAR_getInt( meindex, CHAR_X), + CHAR_getInt( meindex, CHAR_Y)); + ch = CHAR_getCharPointer( meindex); + if( ch != NULL ) { + strcpysafe( ch->charfunctable[CHAR_LOOPFUNC].string, + sizeof( ch->charfunctable[CHAR_LOOPFUNC]), + "NPCEnemyLoop"); + CHAR_constructFunctable( meindex); + CHAR_setInt( meindex, CHAR_LOOPINTERVAL, 5000); + CHAR_setWorkInt( meindex, CHAR_WORK_DIETIME, NowTime.tv_sec); +#ifdef _NPCENEMY_1 + char token1[512]; + if( NPC_Util_GetStrFromStrWithDelim( argstr, "winmsg", token1, sizeof( token1)) != NULL ) { + int i; + int playernum = CHAR_getPlayerMaxNum(); + for( i = 0 ; i < playernum ; i++) { + if( CHAR_getCharUse(i) != FALSE ) { + CHAR_talkToCli( i, -1, token1, CHAR_COLORRED); + } + } + } + if( NPC_Util_GetStrFromStrWithDelim( argstr, "GetRandItem", buf, sizeof( buf))!= NULL ){ + int j=1, rand_cnt=1; + char buf2[256]; + while( getStringFromIndexWithDelim( buf , "," , j, buf2, sizeof( buf2)) != FALSE ){ + j++; + rand_cnt++; + } + for( i = 0; i < 5; i ++ ) { + int toindex = BattleArray[battleindex].Side[0].Entry[i].charaindex; + if( CHAR_CHECKINDEX( toindex) ) { + NPC_ActionTreasureRandItemGet( meindex, toindex, rand_cnt, buf); + } + } + } +#endif + }else { + print( "NPCENEMY:err\n"); + } + }else { + for( i = 0; i < 5; i ++ ) { + toindex = BattleArray[battleindex].Side[0].Entry[i].charaindex; + if( CHAR_CHECKINDEX( toindex) ) { +#ifdef _NEW_WARPMAN + if( strstr( argstr, "NEWNPCENEMY") ) { + BOOL Party=TRUE; + if( NPC_NPCEnemy_CheckFree( meindex, toindex , &Party) == FALSE ) { + continue; + } + if( Party == TRUE ) { + }else { + if( CHAR_getWorkInt( toindex, CHAR_WORKPARTYMODE ) == CHAR_PARTY_LEADER ) { + if( NPC_WarpAllMsg( meindex, toindex ) == TRUE ) { + return TRUE; + } + } + continue; + } + } + CHAR_DischargeParty( toindex, 0); // + CHAR_warpToSpecificPoint( toindex, + CHAR_getWorkInt( meindex, CHAR_WORK_WARP_FLOOR), + CHAR_getWorkInt( meindex, CHAR_WORK_WARP_X), + CHAR_getWorkInt( meindex, CHAR_WORK_WARP_Y) + ); + +#else + CHAR_warpToSpecificPoint( toindex, + CHAR_getWorkInt( meindex, CHAR_WORK_WARP_FLOOR), + CHAR_getWorkInt( meindex, CHAR_WORK_WARP_X), + CHAR_getWorkInt( meindex, CHAR_WORK_WARP_Y) + ); +#endif +#ifdef _NPC_REPLACEMENT + Check_EnemyWarpMe( meindex, argstr); +#endif + } + } + } + return TRUE; +} + +void NPC_NPCEnemyLoop( int meindex ) +{ + + if( NowTime.tv_sec > CHAR_getWorkInt( meindex, CHAR_WORK_DIETIME) + + CHAR_getWorkInt( meindex, CHAR_WORK_REVIVALTIME)){ + Char *ch; + CHAR_setInt( meindex, CHAR_BASEIMAGENUMBER, CHAR_getWorkInt( meindex, CHAR_WORK_BASEIMGBAK)); + print("bbi---->bi11"); + + CHAR_sendCToArroundCharacter( CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX)); + CHAR_setWorkInt( meindex, CHAR_WORKEVENTTYPE, CHAR_EVENT_ENEMY); +#ifdef _NPCENEMY_1 + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + NPC_Util_GetArgStr( meindex, argstr, sizeof( argstr)); + char token1[1024]; + if( NPC_Util_GetStrFromStrWithDelim( argstr, "npcwarp", token1, sizeof( token1)) != NULL ) { + char token[32]; + char token2[32]; + char buf2[32]; + int floor,x,y,x1,x2,y1,y2; + int ret; + int cnt; + int dcnt = 1; + + /*--ػ󼰴 --*/ + //cnt = CHAR_getWorkInt(meindex,CHAR_NPCWORKINT4); + while(getStringFromIndexWithDelim(token1,",", dcnt,buf2,sizeof(buf2) ) + !=FALSE ){ + dcnt++; + } + cnt = RAND(1,dcnt); + //printf("\ndcnt=%d,cnt=%d\n",dcnt,cnt); + + if(getStringFromIndexWithDelim(token1,",", cnt,buf2,sizeof(buf2)) !=FALSE ) + { + cnt++; + ret=getStringFromIndexWithDelim(buf2,".", 1,token,sizeof(token)); + if( ret == FALSE ) { + floor = CHAR_getInt(meindex,CHAR_FLOOR); + } + floor = atoi( token ); + + ret=getStringFromIndexWithDelim(buf2,".", 2,token,sizeof(token)); + if( ret == FALSE ){ + x = CHAR_getInt(meindex,CHAR_X); + }else{ + ret=getStringFromIndexWithDelim(token,"-", 1,token2,sizeof(token2)); + if( ret == FALSE ){ + x = atoi( token ); + }else{ + x1=atoi(token2); + ret=getStringFromIndexWithDelim(token,"-", 2,token2,sizeof(token2)); + if( ret == FALSE ){ + x2=x1; + }else{ + x2=atoi(token2); + } + x = RAND(x1,x2); + } + } + //x = atoi( token ); + + ret=getStringFromIndexWithDelim(buf2,".", 3,token,sizeof(token)); + if( ret == FALSE ) { + y = CHAR_getInt(meindex,CHAR_Y); + }else{ + ret=getStringFromIndexWithDelim(token,"-", 1,token2,sizeof(token2)); + if( ret == FALSE ){ + y = atoi( token ); + }else{ + y1=atoi(token2); + ret=getStringFromIndexWithDelim(token,"-", 2,token2,sizeof(token2)); + if( ret == FALSE ){ + y2=y1; + }else{ + y2=atoi(token2); + } + y = RAND(y1,y2); + } + } + //y = atoi( token ); + + //CHAR_setInt(meindex,CHAR_NPCWORKINT4, cnt); + //CHAR_warpToSpecificPoint(meindex, floor, x, y); + //CHAR_setInt(meindex,CHAR_FLOOR,floor); + //CHAR_setInt(meindex,CHAR_X,x); + //CHAR_setInt(meindex,CHAR_Y,y); + CHAR_warpToSpecificPoint(meindex,floor,x,y); + } + } + if( NPC_Util_GetStrFromStrWithDelim( argstr, "allmsg", token1, sizeof( token1)) != NULL ) { + int i; + int playernum = CHAR_getPlayerMaxNum(); + for( i = 0 ; i < playernum ; i++) { + if( CHAR_getCharUse(i) != FALSE ) { + CHAR_talkToCli( i, -1, token1, CHAR_COLORRED); + } + } + } +#endif + MAP_sendAroundMapdata( CHAR_getInt( meindex, CHAR_FLOOR), + CHAR_getInt( meindex, CHAR_X), + CHAR_getInt( meindex, CHAR_Y)); + ch = CHAR_getCharPointer( meindex); + if( ch != NULL ) { + strcpysafe( ch->charfunctable[CHAR_LOOPFUNC].string, + sizeof( ch->charfunctable[CHAR_LOOPFUNC]), ""); + CHAR_constructFunctable( meindex); +// CHAR_setInt( meindex, CHAR_LOOPINTERVAL, 0); + } + } +} + + +BOOL NPC_NPCEnemy_BattleIn( int meindex, int charaindex) +{ + int gym; + int ret; + char buf[256]; + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + + memset( argstr, 0, sizeof( argstr)); + NPC_Util_GetArgStr( meindex, argstr, sizeof( argstr)); + gym = NPC_Util_GetNumFromStrWithDelim( argstr, "gym"); + +#ifdef _EMENY_CHANCEMAN + { + int masterindex=-1; + masterindex = NPC_EmenyChanceCheck( meindex, charaindex, argstr); + if( CHAR_CHECKINDEX( masterindex)){ + charaindex = masterindex; + }else { + return TRUE; + } + } +#endif +#ifdef _WARNPC_CTRL + int sameip = NPC_Util_GetNumFromStrWithDelim( argstr, "sameip"); + if(sameip == -1) + sameip = 0; + CHAR_setWorkInt( charaindex, CHAR_WORKNPCBATTLESAMEIP, sameip); + if(CHAR_getWorkInt(charaindex,CHAR_WORKNPCBATTLESAMEIP)>0){ + int partyi; + unsigned ip=CONNECT_get_userip(getfdFromCharaIndex(charaindex)); + unsigned teseip = ip; + unsigned toip; + int a, b, c, d,ipcnt=1; + char ipstr[32]; + a=(teseip % 0x100); teseip=teseip / 0x100; + b=(teseip % 0x100); teseip=teseip / 0x100; + c=(teseip % 0x100); teseip=teseip / 0x100; + d=(teseip % 0x100); + sprintf(ipstr,"%d.%d.%d.%d",a,b,c,d); + if(strcmp(ipstr,getNoAttIp(0))==0 || strcmp(ipstr,getNoAttIp(1))==0 || strcmp(ipstr,getNoAttIp(2))==0 || strcmp(ipstr,getNoAttIp(3))==0 || strcmp(ipstr,getNoAttIp(4))==0){ + } + else{ + if( CHAR_getWorkInt( charaindex, CHAR_WORKPARTYMODE) == CHAR_PARTY_NONE ) { + }else{ + for( partyi = 0; partyi < CHAR_PARTYMAX; partyi ++ ) { + int index = CHAR_getWorkInt( charaindex, partyi + CHAR_WORKPARTYINDEX1); + if( CHAR_CHECKINDEX(index)) { + toip = CONNECT_get_userip(getfdFromCharaIndex(index)); + if(ip==toip){ + ipcnt++; + if(ipcnt>sameip){ + CHAR_talkToCli( charaindex, -1, "ͬIPѴޣ޷ս", CHAR_COLORYELLOW); + return FALSE; + } + } + } + } + } + } + } +#endif + if( gym > 0 ){ + ret = BATTLE_CreateVsEnemy( charaindex, 2, meindex); + }else{ + ret = BATTLE_CreateVsEnemy( charaindex, 1, meindex); + } + if( ret == 0 ) { +#ifdef _WARNPC_CTRL + int tmp = NPC_Util_GetNumFromStrWithDelim( argstr, "noquckwar"); + if( tmp == -1 ) + tmp = 0; + CHAR_setWorkInt( meindex, CHAR_WORK_BATTLEINGTIME, tmp); + if(CHAR_getWorkInt(meindex,CHAR_WORK_BATTLEINGTIME)>0){ + CHAR_setWorkInt(charaindex,CHAR_WORKNPCENEMYBATTLETIME,1); + CHAR_setWorkInt(charaindex,CHAR_WORKNPCENEMYTIME,CHAR_getWorkInt(meindex,CHAR_WORK_BATTLEINGTIME)); + if(CHAR_getWorkInt( charaindex, CHAR_WORKPARTYMODE) != CHAR_PARTY_NONE){ + int i; + for( i = 1; i < CHAR_PARTYMAX; i ++ ) { + if( CHAR_getWorkInt( charaindex, i + CHAR_WORKPARTYINDEX1) > -1 ) { + CHAR_setWorkInt(CHAR_getWorkInt( charaindex, i + CHAR_WORKPARTYINDEX1),CHAR_WORKNPCENEMYBATTLETIME,1); + CHAR_setWorkInt(CHAR_getWorkInt( charaindex, i + CHAR_WORKPARTYINDEX1),CHAR_WORKNPCENEMYTIME,CHAR_getWorkInt(meindex,CHAR_WORK_BATTLEINGTIME)); + } + } + } + } +#endif + BattleArray[CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEINDEX)].WinFunc = NPC_NPCEnemy_Dying; + if( NPC_Util_GetStrFromStrWithDelim( argstr, "startmsg", buf, sizeof( buf)) != NULL ){ + CHAR_talkToCliAndParty( charaindex, meindex ,buf , CHAR_COLORYELLOW ); + } + if( NPC_Util_GetStrFromStrWithDelim( argstr, "steal", buf, sizeof( buf))!= NULL ){ + if( atoi( buf) == 0 ) { + NPC_NPCEnemy_StealItem( argstr, meindex, charaindex); + } + } +#ifdef _NPCENEMY_1 + if( NPC_Util_GetStrFromStrWithDelim( argstr, "help", buf, sizeof( buf)) != NULL ){ + CHAR_setWorkInt(charaindex,CHAR_WORKBATTLEHELP,1); + BattleArray[CHAR_getWorkInt( charaindex, + CHAR_WORKBATTLEINDEX)].Side[ + CHAR_getWorkInt( charaindex, + CHAR_WORKBATTLESIDE)].flg |= BSIDE_FLG_HELP_OK; + int i; + for( i = 0; i < 5; i ++ ) { + int toindex = BattleArray[CHAR_getWorkInt( + charaindex, CHAR_WORKBATTLEINDEX)].Side[ + CHAR_getWorkInt( charaindex, + CHAR_WORKBATTLESIDE)].Entry[i].charaindex; + if( CHAR_CHECKINDEX( toindex)) { + int tofd = getfdFromCharaIndex( toindex ); + if( tofd != -1 ) { + CHAR_setWorkInt(toindex,CHAR_WORKBATTLEHELP,1); + lssproto_HL_send( tofd, TRUE); + } + /* ˪ */ + CHAR_sendBattleEffect( toindex, ON); + } + } + char floorname[32]; + int floorx,floory; + getStringFromIndexWithDelim( MAP_getfloorShowstring(CHAR_getInt(meindex,CHAR_FLOOR)),"|", 1,floorname, sizeof(floorname)); + floorx = CHAR_getInt(meindex,CHAR_X); + floory = CHAR_getInt(meindex,CHAR_Y); + int playernum = CHAR_getPlayerMaxNum(); + char token1[256]; + sprintf(token1,"ʿǣ%s%d,%dҵʹߣԮ",floorname,floorx,floory); + for( i = 0 ; i < playernum ; i++) { + if( CHAR_getCharUse(i) != FALSE ) { + CHAR_talkToCli( i, -1, token1, CHAR_COLORRED); + } + } + } +#endif + } + return ( ret == 0 ) ?TRUE:FALSE ; +} + +void NPC_NPCEnemyWindowTalked( int meindex, int talkerindex, int seqno, int select, char *data) +{ + if( seqno == CHAR_WINDOWTYPE_NPCENEMY_START) { + if( select == WINDOW_BUTTONTYPE_YES) { + NPC_NPCEnemy_BattleIn( meindex, talkerindex); + } + } +} + +static int NPC_NPCEnemy_StealItem( char *argstr, int meindex, int charaindex) +{ + char itembuf[1024]; + if( NPC_Util_GetStrFromStrWithDelim( argstr, "item", itembuf, sizeof( itembuf))!= NULL ) + { + char data[128]; + int delitemgroup[CHAR_MAXITEMHAVE]; + int found = 0; + int i; + for( i = 0; i < CHAR_MAXITEMHAVE; i ++ ) { + int j; + int itemid; + int ret = getStringFromIndexWithDelim( itembuf,",", i + 1,data, sizeof(data)); + if( ret == FALSE) { + break; + } + itemid = atoi( data); + for( j = 0; j < CHAR_MAXITEMHAVE; j ++ ) { + int itemindex = CHAR_getItemIndex( charaindex, j); + if( ITEM_CHECKINDEX( itemindex)){ + if( ITEM_getInt( itemindex, ITEM_ID) == itemid ){ + CHAR_setItemIndex( charaindex, j, -1); + ITEM_endExistItemsOne( itemindex); + delitemgroup[found] = j; + found ++; + break; + } + } + } + if( !found ) break; + } + CHAR_sendItemData( charaindex, delitemgroup, found); + } + else { + print( "NPCENEMY:\n"); + return FALSE; + } + return TRUE; +} + +#ifdef _NEW_WARPMAN +static BOOL NPC_NPCEnemy_CheckFree( int meindex, int toindex, BOOL *Party) +{ + char npcarg[NPC_UTIL_GETARGSTR_BUFSIZE]; + char buf1[1024],buf2[256],buf3[256],buf4[256]; + char token[256]; + char temp1[16]; + int talkNo = 1; + int point=1; + + int i=0,type=0; + + struct tagWarpPoint { + int floor; + int x; + int y; + }AllWarPoint[]={ + {0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0}, + {0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0}, + {0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0}, + }; + + if(NPC_Util_GetArgStr( meindex, npcarg, sizeof(npcarg))==NULL) { + print("GetArgStrErr"); + return FALSE; + } + if( (strstr( npcarg,"NEWNPCENEMY") == NULL) && (strstr( npcarg,"OVER") == NULL) ) { + return FALSE; + }else { + } + + while( getStringFromIndexWithDelim( npcarg,"OVER",talkNo,buf1,sizeof( buf1)) != FALSE ) { + + talkNo++; + sprintf(temp1,"NEWEVENT"); + if( strstr( buf1, temp1) != NULL) { + if( NPC_Util_GetStrFromStrWithDelim( buf1, "FREE", buf2, sizeof( buf2) ) == FALSE ) { + continue; + } + if( NPC_ActionPassCheck( meindex, toindex, buf2) == FALSE ) { + continue; + } + + if( NPC_Util_GetStrFromStrWithDelim( buf1, "endmsg", token, sizeof( token)) != NULL ) { + CHAR_talkToCli( toindex, meindex ,token , CHAR_COLORYELLOW ); + } +#ifdef _ALLDOMAN // (ɿ) Syu ADD аNPC + if( NPC_Util_GetStrFromStrWithDelim( buf1, "herobattlefield", token, sizeof( token)) != NULL ) { + CHAR_setWorkInt ( toindex , CHAR_WORKHEROFLOOR , atoi ( token ) ) ; + if ( atoi ( token ) > CHAR_getInt ( toindex , CHAR_HEROFLOOR ) ) + CHAR_setInt ( toindex , CHAR_HEROFLOOR , atoi( token ) ) ; + + } +#endif + + if( NPC_Util_GetStrFromStrWithDelim( buf1, "WARP", buf2, sizeof( buf2) ) == FALSE ){ + continue; + }else {//RAND arraysizeof AllWarPoint + while( getStringFromIndexWithDelim( buf2, ";", point, buf3,sizeof( buf3)) != FALSE ) { + point++; + getStringFromIndexWithDelim( buf3, ",", 1, buf4, sizeof( buf4)); + AllWarPoint[i].floor = atoi( buf4); + getStringFromIndexWithDelim( buf3, ",", 2, buf4, sizeof( buf4)); + AllWarPoint[i].x = atoi( buf4); + getStringFromIndexWithDelim( buf3, ",", 3, buf4, sizeof( buf4)); + AllWarPoint[i].y = atoi( buf4); + i++; + if( i >= arraysizeof( AllWarPoint) ) + break; + } + type = RAND( 0, i-1); + if( AllWarPoint[type].floor <= 0 || type > arraysizeof( AllWarPoint)-1) { + type = 0; + } + CHAR_setWorkInt( meindex, CHAR_WORK_WARP_FLOOR, AllWarPoint[type].floor ); + CHAR_setWorkInt( meindex, CHAR_WORK_WARP_X, AllWarPoint[type].x ); + CHAR_setWorkInt( meindex, CHAR_WORK_WARP_Y, AllWarPoint[type].y ); + + } + if( NPC_Util_GetStrFromStrWithDelim( buf1, "CHECKPARTY", buf4, sizeof( buf4)) != NULL ) { + if( strstr( buf4, "FALSE") != NULL ) { + *Party = FALSE; + } + } + if( *Party == TRUE ) { + Action_RunDoEventAction( meindex, toindex, buf1); + } + return TRUE; + } + } + return FALSE; +} + + +BOOL NPCEnemy_CheckFree( int meindex, int talker, char *buf) +{ + char buff2[256]; + char buff3[128]; + int i=1,j=1; + int loop=0; + while( getStringFromIndexWithDelim(buf,",",i,buff2,sizeof(buff2)) !=FALSE ) { + i++; + if(strstr(buff2,"&")!=NULL){ + j=1; + loop=0; + while( getStringFromIndexWithDelim(buff2,"&",j,buff3,sizeof(buff3)) !=FALSE ) { + j++; + if(NPCEnemy_BSCheck(meindex,talker,buff3)==FALSE) { + loop=1; + break; + } + } + if(loop==0) { + CHAR_setWorkInt( talker, CHAR_WORKWARPCHECK, TRUE ); + return TRUE; + } + }else{ + if( NPCEnemy_BSCheck( meindex, talker, buff2) == TRUE ){ + CHAR_setWorkInt( talker, CHAR_WORKWARPCHECK, TRUE ); + return TRUE; + } + } + } + CHAR_setWorkInt( talker, CHAR_WORKWARPCHECK, FALSE ); + return FALSE; +} + +BOOL NPCEnemy_BSCheck(int meindex,int talker,char* buf) +{ + char buff2[128]; + int kosuu,temp=-1,flg=0; + char buff1[128],buff3[128]; + if(strstr( buf, "-") != NULL) { + //buff3ΪץID + getStringFromIndexWithDelim( buf, "-", 2, buff3, sizeof(buff3)); + temp = atoi( buff3); + getStringFromIndexWithDelim( buf, "-", 1, buff1, sizeof(buff1)); + strcpy( buf, buff1); + } + + if(strstr( buf, "<") != NULL){ + getStringFromIndexWithDelim( buf, "<", 2, buff2, sizeof(buff2)); + kosuu = atoi( buff2); + getStringFromIndexWithDelim( buf, "<", 1, buff2, sizeof(buff2)); + + if(NPCEnemy_FreeIfCheck( meindex, talker, buff2, kosuu, 1, temp)==TRUE){ + return TRUE; + } + }else if(strstr( buf, ">") != NULL){ + getStringFromIndexWithDelim( buf, ">", 2, buff2, sizeof(buff2)); + kosuu = atoi(buff2); + getStringFromIndexWithDelim( buf, ">" ,1, buff2, sizeof(buff2)); + + if(NPCEnemy_FreeIfCheck( meindex, talker, buff2, kosuu, 2, temp)==TRUE){ + return TRUE; + } + + }else if(strstr( buf, "!" ) != NULL){ + getStringFromIndexWithDelim( buf, "!=", 2, buff2, sizeof(buff2)); + kosuu = atoi( buff2); + getStringFromIndexWithDelim( buf, "!=", 1, buff2, sizeof(buff2)); + if(NPCEnemy_FreeIfCheck( meindex, talker, buff2, kosuu, 0, temp) == TRUE){ + return FALSE; + }else{ + return TRUE; + } + + }else if(strstr( buf, "=") != NULL){ + + getStringFromIndexWithDelim( buf, "=", 2, buff2, sizeof(buff2)); + kosuu = atoi( buff2); + getStringFromIndexWithDelim( buf, "=", 1, buff2, sizeof(buff2)); + + if( strstr( buf, "PET")) { + flg = 3; + } + if(strstr( buf, "*") != NULL){ + if( NPCEnemy_WarpManReduce( meindex, talker, buf)==TRUE){ + return TRUE; + } + }else if(NPCEnemy_FreeIfCheck( meindex, talker, buff2, kosuu, flg, temp)==TRUE){ + return TRUE; + } + } + return FALSE; +} + +BOOL NPCEnemy_FreeIfCheck(int meindex,int talker,char* buf,int kosuu,int flg, int temp) +{ + if(strcmp(buf,"LV")==0){ + if(NPCEnemy_LevelCheck(meindex,talker,kosuu,flg)==TRUE){ + return TRUE; + } + } + + if( strcmp(buf,"TRANS") == 0 ) { + if( NPCEnemy_CheckTrans( meindex, talker, kosuu, flg) == TRUE ) + return TRUE; + } + if( strcmp( buf, "PET") == 0 ) { + if( temp > 0 ) { + if( NPCEnemy_CheckMyPet( meindex, talker, kosuu, flg, temp) == TRUE ) + return TRUE; + }else + return FALSE; + } + + if(strcmp(buf,"ITEM")==0){ + if(NPCEnemy_ItemCheck(meindex,talker,kosuu,flg)==TRUE){ + return TRUE; + } + } + if(strcmp(buf,"ENDEV")==0){ + if(NPC_EventCheckFlg( talker, kosuu)==TRUE){ + return TRUE; + } + } + if(strcmp(buf,"NOWEV")==0){ + if(NPC_NowEventCheckFlg( talker, kosuu)==TRUE){ + return TRUE; + } + } + return FALSE; + +} + +BOOL NPCEnemy_WarpManReduce(int meindex,int talker,char *buf) +{ + char buf2[512]; + char buf3[256]; + int id=0; + int i; + int itemindex; + int itemno; + int kosuu; + int cnt=0; + + getStringFromIndexWithDelim(buf,"=",2,buf2,sizeof(buf2)); + getStringFromIndexWithDelim(buf2,"*",1,buf3,sizeof(buf3)); + itemno = atoi(buf3); + getStringFromIndexWithDelim(buf2,"*",2,buf3,sizeof(buf3)); + kosuu = atoi(buf3); + + for( i=0 ; i < CHAR_MAXITEMHAVE;i++ ){ + itemindex=CHAR_getItemIndex( talker , i ); + if( ITEM_CHECKINDEX(itemindex) ){ + id=ITEM_getInt(itemindex ,ITEM_ID ); + if(itemno==id){ + cnt++; + if(cnt==kosuu){ + return TRUE; + } + } + } + } + + return FALSE; + +} + +BOOL NPCEnemy_BigSmallLastCheck(int point1,int mypoint,int flg) +{ + if(flg==0){ + if(point1==mypoint) { + return TRUE; + } + + }else if(flg==1){ + if(mypoint < point1) { + return TRUE; + } + + }else if(flg==2){ + if(mypoint > point1) { + return TRUE; + } + } + + return FALSE; + +} + +BOOL NPCEnemy_LevelCheck(int meindex,int talker,int level,int flg) +{ + int mylevel; + mylevel=CHAR_getInt(talker,CHAR_LV); + if(NPCEnemy_BigSmallLastCheck(level,mylevel,flg)==TRUE) { + return TRUE; + } + return FALSE; +} + +BOOL NPCEnemy_CheckTrans(int meindex,int talker,int trans,int flg) +{ + int myTrans; + myTrans=CHAR_getInt(talker, CHAR_TRANSMIGRATION); + if( NPCEnemy_BigSmallLastCheck( trans, myTrans, flg ) == TRUE ) { + return TRUE; + } + return FALSE; +} + +BOOL NPCEnemy_CheckMyPet( int meindex, int talker, int petLv, int flg, int petid) +{ + int petsel,petindex=-1; + for(petsel=0 ; petsel < CHAR_MAXPETHAVE ; petsel++) { + petindex = CHAR_getCharPet( talker, petsel); + if( petindex == -1 ) + continue; + if(CHAR_getInt( petindex, CHAR_PETID) != petid ) + continue; + break; + } + if( petsel == CHAR_MAXPETHAVE ) { + return FALSE; + }else { //ҵ + switch( flg) { + case 0: + if( CHAR_getInt( petindex, CHAR_LV) != petLv ) + return TRUE; + break; + case 1: + if( CHAR_getInt( petindex, CHAR_LV) < petLv ) + return TRUE; + break; + case 2: + if( CHAR_getInt( petindex, CHAR_LV) > petLv ) + return TRUE; + break; + case 3: + if( CHAR_getInt( petindex, CHAR_LV) == petLv ) + return TRUE; + break; + } + return FALSE; + } + return FALSE; +} + +BOOL NPCEnemy_ItemCheck(int meindex,int talker,int itemNo,int flg) +{ + int i; + int itemindex=-1; + int id; + + for( i=0;i 0 && addcnt > 0 ) { + snprintf( message, sizeof( message ) , + "ɥʧ%d%s ƺŵʸ" + "ǵõ%d%s ijƺʸ" + , delcnt, + delcnt < 10 ? NPC_OLDMAN_TITLE_UNIT1:NPC_OLDMAN_TITLE_UNIT2, + addcnt, + addcnt < 10 ? NPC_OLDMAN_TITLE_UNIT1:NPC_OLDMAN_TITLE_UNIT2 + ); + CHAR_talkToCli( talkerindex , meindex , message , CHAR_COLORWHITE ); + } + else if( delcnt > 0 ) { + snprintf( message, sizeof( message ) , + "ɥʧõ%d%sƺŵʸ", delcnt, + delcnt < 10 ? NPC_OLDMAN_TITLE_UNIT1:NPC_OLDMAN_TITLE_UNIT2); + CHAR_talkToCli( talkerindex , meindex , message , CHAR_COLORWHITE ); + } + else if( addcnt > 0 ) { + snprintf( message, sizeof( message ) , + "%d%sijƺŰɣ", addcnt, // CoolFish: d%s -> %d%s 2001/4/18 + addcnt < 10 ? NPC_OLDMAN_TITLE_UNIT1:NPC_OLDMAN_TITLE_UNIT2); + CHAR_talkToCli( talkerindex , meindex , message , CHAR_COLORWHITE ); + } + if( delcnt > 0 ) { + snprintf( message, sizeof( message), + "ʧȥ%d%s ƺţ", delcnt, + delcnt < 10 ? NPC_OLDMAN_TITLE_UNIT1:NPC_OLDMAN_TITLE_UNIT2); + CHAR_talkToCli( talkerindex, -1, message, CHAR_COLORYELLOW); + } + if( addcnt > 0 ) { + snprintf( message, sizeof( message), + "%d%s ƺţ", addcnt, + addcnt < 10 ? NPC_OLDMAN_TITLE_UNIT1:NPC_OLDMAN_TITLE_UNIT2); + CHAR_talkToCli( talkerindex, -1, message, CHAR_COLORYELLOW); + } + } +} + if( title_change ) CHAR_sendStatusString( talkerindex , "T" ); + +} diff --git a/npc/npc_pauctionman.c b/npc/npc_pauctionman.c new file mode 100644 index 0000000..e69de29 diff --git a/npc/npc_petfusion.c b/npc/npc_petfusion.c new file mode 100644 index 0000000..d8aa80e --- /dev/null +++ b/npc/npc_petfusion.c @@ -0,0 +1,253 @@ +#include "version.h" +#include +#include "char.h" +#include "object.h" +#include "char_base.h" +#include "char_data.h" +#include "npcutil.h" +#include "lssproto_serv.h" +#include "saacproto_cli.h" +#include "readmap.h" +#include "battle.h" +#include "log.h" +#include "enemy.h" +#include "handletime.h" +#include "npc_eventaction.h" +#include "npc_petfusion.h" +#include "pet.h" +#include "chatmagic.h" + + +#ifdef _NPC_FUSION + +enum { + WINDOW_START=10, + WINDOW_SELECT, + WINDOW_FUSION, + WINDOW_WARP, //Ծ + WINDOW_END, // + + WINDOW_TALKSTART=20, + WINDOW_TALKSELECT, + WINDOW_RETURN, + WINDOW_TALKEND, +}; +enum { + NPC_WORK_CURRENTTIME = CHAR_NPCWORKINT1, +/* + NPC_WORK_ROUTEPOINT = CHAR_NPCWORKINT3, + NPC_WORK_ROUNDTRIP = CHAR_NPCWORKINT4, + NPC_WORK_MODE = CHAR_NPCWORKINT5, + NPC_WORK_CURRENTROUTE = CHAR_NPCWORKINT6, + NPC_WORK_ROUTEMAX = CHAR_NPCWORKINT7, + NPC_WORK_WAITTIME = CHAR_NPCWORKINT8, + NPC_WORK_CURRENTTIME = CHAR_NPCWORKINT9, + NPC_WORK_SEFLG = CHAR_NPCWORKINT10, +*/ +}; + +static void NPC_PetFusion_selectWindow( int meindex, int toindex, int num,int select); +BOOL NPC_DoPetFusion( int meindex, int toindex, char *data, int sizes); + + +BOOL NPC_PetFusionManInit( int meindex ) +{ + char npcarg[NPC_UTIL_GETARGSTR_BUFSIZE]; + if(NPC_Util_GetArgStr( meindex, npcarg, sizeof(npcarg))==NULL){ + print("err NPC_PetFusionManInit: GetArgStrErr!!"); + return FALSE; + } + CHAR_setInt( meindex, CHAR_WHICHTYPE, CHAR_PETFUSIONMAN); + //CHAR_setInt( meindex, CHAR_LOOPINTERVAL, MAKEPAIR_STANDBY); + //CHAR_setWorkInt( meindex, NPC_WORK_CURRENTTIME, NowTime.tv_sec); + //CHAR_setWorkInt( meindex, NPC_WORK_PAIRTEAMS, 0); + return TRUE; +} +void NPC_PetFusionManTalked( int meindex, int talkerindex, char *msg, int color ) +{ + if( CHAR_getInt( talkerindex , CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER ) + return; + if(NPC_Util_isFaceToFace( meindex ,talkerindex , 2) == FALSE) { + if(NPC_Util_isFaceToChara( talkerindex, meindex, 1) == FALSE) + return; + } +#ifdef _ITEM_CHECKWARES + if( CHAR_CheckInItemForWares( talkerindex, 0) == FALSE ){ + CHAR_talkToCli( talkerindex, meindex, "޷Яˣ", CHAR_COLORYELLOW); + return; + } +#endif + + CHAR_setWorkInt( talkerindex, CHAR_WORKSHOPRELEVANT, WINDOW_START); + NPC_PetFusion_selectWindow( meindex, talkerindex, WINDOW_START, 0); +} + +static void NPC_PetFusion_selectWindow( int meindex, int toindex, int num,int select) +{ + char npcarg[NPC_UTIL_GETARGSTR_BUFSIZE]; + char token[256]; + int buttontype = 0, windowtype = 0, windowno = 0; + int fd = getfdFromCharaIndex( toindex); + windowtype = WINDOW_MESSAGETYPE_MESSAGE; + if( Action_PartyCheck( meindex, toindex) == FALSE) { + CHAR_talkToCli( toindex, meindex, "һһ", CHAR_COLORYELLOW); + return; + } + memset( npcarg, 0, sizeof( npcarg)); + if(NPC_Util_GetArgStr( meindex, npcarg, sizeof(npcarg))==NULL){ + print("err NPC_MakePairMan: GetArgStrErr!!"); + return; + } + memset( token, 0, sizeof( token)); + + switch( num){ + case WINDOW_START: + if( NPC_Util_GetStrFromStrWithDelim( npcarg, "StartMsg", token, sizeof( token) ) == NULL){ + return; + } + buttontype = WINDOW_BUTTONTYPE_YESNO; + windowno = WINDOW_TALKSTART; + break; + case WINDOW_SELECT: + if( ActionNpc_CheckFree( meindex, toindex, npcarg) == FALSE ) { + buttontype = WINDOW_BUTTONTYPE_OK; + windowno = WINDOW_TALKEND; + }else { + if( NPC_Util_GetStrFromStrWithDelim( npcarg, "SelectMsg", token, sizeof( token) ) == NULL){ + return; + } + windowtype = WINDOWS_MESSAGETYPE_PETFUSION; + buttontype = WINDOW_BUTTONTYPE_YESNO; + windowno = WINDOW_TALKSELECT; + } + break; + case WINDOW_FUSION: + //ںϴ + break; + case WINDOW_WARP: + break; + case WINDOW_END: + break; + } + CHAR_setWorkInt( toindex, CHAR_WORKSHOPRELEVANT, windowno); + lssproto_WN_send( fd, windowtype, buttontype, windowno, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), token); +} +void NPC_PetFusionManWindowTalked( int meindex, int talkerindex, int seqno, int select, char *data) +{ + char npcarg[NPC_UTIL_GETARGSTR_BUFSIZE]; + if( CHAR_getInt( talkerindex , CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER ) + return; + if( select == WINDOW_BUTTONTYPE_NO || select == WINDOW_BUTTONTYPE_CANCEL ){ + CHAR_setWorkInt( talkerindex, CHAR_WORKSHOPRELEVANT, 0); + return; + } + if( CHAR_getWorkInt( talkerindex, CHAR_WORKSHOPRELEVANT) != seqno ) + return; + memset( npcarg, 0, sizeof( npcarg)); + if(NPC_Util_GetArgStr( meindex, npcarg, sizeof(npcarg))==NULL){ + print("err NPC_MakePairMan: GetArgStrErr!!"); + return; + } + if( CHAR_getWorkInt( talkerindex, CHAR_WORKSHOPRELEVANT) != seqno ) + return; + + switch( seqno) { + case WINDOW_TALKSTART: + NPC_PetFusion_selectWindow( meindex, talkerindex, WINDOW_SELECT, 0); + break; + case WINDOW_TALKSELECT: + { + if( NPC_DoPetFusion( meindex, talkerindex, data, sizeof( data)) == FALSE ) + return; + return; + NPC_PetFusion_selectWindow( meindex, talkerindex, WINDOW_FUSION, 0); + } + break; + case WINDOW_RETURN: + break; + case WINDOW_TALKEND: + break; + } +} + +void NPC_PetFusionManLoop( int meindex) +{ +} + +BOOL NPC_DoPetFusion( int meindex, int toindex, char *data, int sizes) +{ + char buf[256]; + int i, flg, MainIndex=-1, Subindex1=-1, Subindex2=-1; + int work[4], skill1[7], skill2[7]; + char npcarg[NPC_UTIL_GETARGSTR_BUFSIZE]; + + memset( buf, 0, sizeof( buf)); + sprintf( buf, "%s", data); + if( !CHAR_CHECKINDEX( meindex) ) return FALSE; + if(NPC_Util_GetArgStr( meindex, npcarg, sizeof(npcarg))==NULL){ + print("err NPC_MakePairMan: GetArgStrErr!!"); + return FALSE; + } + for( i=0; i +#include +#include + +#include "object.h" +#include "char_base.h" +#include "char.h" +#include "util.h" +#include "npcutil.h" +#include "item.h" +#include "readmap.h" +#include "enemy.h" +#include "chatmagic.h" +#include "log.h" + +#define EVFLG 118 // 58->׻ 118-> + +void pet_make( int charaindex, char* message ); + +BOOL NPC_PetMakerInit( int meindex ) +{ + CHAR_setInt( meindex , CHAR_WHICHTYPE , CHAR_TYPEPETMAKER ); + CHAR_setFlg( meindex , CHAR_ISATTACKED , 0 ); + return TRUE; +} + +void NPC_PetMakerTalked( int meindex , int talker , char *msg ,int color ) +{ + char* npcarg; + char token[32],tmpbuf[256]; + int msgNo/*,translv*/; + int point,ckpoint,array,shift; + int i,num=0; + + array = EVFLG / 32; + shift = EVFLG % 32; + point = CHAR_getInt( talker, CHAR_ENDEVENT + array); + ckpoint = point; + + npcarg = CHAR_getChar(meindex,CHAR_NPCARGUMENT); + + getStringFromIndexWithDelim( npcarg, "|", 1, token,sizeof( token)); + msgNo = atoi( token ); + + if( CHAR_getInt( talker , CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER ) + return; + + if( NPC_Util_isFaceToFace( talker, meindex , 2 ) == FALSE ) + { + if( NPC_Util_isFaceToFace( talker, meindex , 1 ) == FALSE ) + return; + } + + //translv = CHAR_getInt( talker, CHAR_TRANSMIGRATION); // ׻ + + for(i=0; i=CHAR_MAXPETHAVE ){ + sprintf(tmpbuf, "ǸûĿռɷó"); + CHAR_talkToCli( talker, meindex, + tmpbuf,CHAR_COLORWHITE); + return; + } + + pet_make( talker, "1845" ); + + point = point | (1 << shift); + CHAR_setInt( talker, CHAR_ENDEVENT + array, point); +} + +void pet_make( int charaindex, char* message ) +{ + int ret; + char msgbuf[64]; + int enemynum; + int enemyid; + int i; + + enemyid = atoi(message); + enemynum = ENEMY_getEnemyNum(); + + for( i=0; i +#include +#include "char.h" +#include "object.h" +#include "char_base.h" +#include "npcutil.h" +#include "lssproto_serv.h" +#include "handletime.h" + +#ifdef _PETRACE +#include "npc_petracemaster.h" + +#define PETRACEPETNUM 3 +#define PETRACEMASTER_INITPET_LOOPTIME 3000 // 3 +#define PETRACEMASTER_WAITDROPI_LOOPTIME 30000 // 30 +#define PETRACEMASTER_WAITDROPII_LOOPTIME 10000 // 10 +#define PETRACEMASTER_WAITDROPIII_LOOPTIME 5000 // 5 +#define PETRACEMASTER_WAITDROPIV_LOOPTIME 1000 // 1 +#define PETRACEMASTER_PETRACING_LOOPTIME 3000 // 3 +#define PETRACEMASTER_SHOWWINPET_LOOPTIME 10000 // 10 +#define PETRACEDROPSTAKETIME 120 // 2 120 +#define PETRACESHOWWINPET 30 // 30 +#define PETRACESTDPAYRATE 6 +#define PETRACESTDGOLD 1 // ʱ 1000 + +static void NPC_PetRaceMaster_selectWindow(int meindex, int toindex, int num, int select); +void NPC_findRacePetIndex(int meindex, int floor); +void NPC_givePriceToPlayer(int meindex, int floor, int winpetindex); + +enum +{ + NPC_WORK_STATE = CHAR_NPCWORKINT1, + NPC_WORK_PET1 = CHAR_NPCWORKINT2, + NPC_WORK_PET2 = CHAR_NPCWORKINT3, + NPC_WORK_PET3 = CHAR_NPCWORKINT4, + NPC_WORK_PETGROUP = CHAR_NPCWORKINT5, + NPC_WORK_STATECHANGE = CHAR_NPCWORKINT6, + NPC_WORK_FINDPETFLAG = CHAR_NPCWORKINT7, + NPC_WORK_WINPET = CHAR_NPCWORKINT8, + NPC_WORK_PETGOAL = CHAR_NPCWORKINT9, +}; +enum +{ + NPC_State_Init, + NPC_State_WaitDropStake, + NPC_State_PetRacing, + NPC_State_ShowWinPet, +}; +enum +{ + NPC_State_Wait, + NPC_State_Run, + NPC_State_ShowWin, +}; +typedef struct tagPetRaceGraTable +{ + int pet1gra; + int pet2gra; + int pet3gra; + char pet1name[64]; + char pet2name[64]; + char pet3name[64]; + int pet1win; + int pet2win; + int pet3win; +#ifdef _DROPSTAKENEW +#else + float payrate1; + float payrate2; + float payrate3; +#endif + char state1[64]; + char state2[64]; + char state3[64]; +}PetRaceGraTable; +#ifdef _DROPSTAKENEW +PetRaceGraTable petracegra[27] = +{ + {100820, 100821, 100822, "", "", "", 0, 0, 0, "", "", ""}, + {100823, 100824, 100825, "³", "", "", 0, 0, 0, "", "", ""}, + {100842, 100843, 100844, "˹", "˹", "˹", 0, 0, 0, "", "", ""}, + {100852, 100853, 100855, "", "˹", "˴", 0, 0, 0, "", "", ""}, + {100859, 100856, 100857, "ɿ", "", "", 0, 0, 0, "", "", ""}, + {100864, 100865, 100866, "", "±", "ë", 0, 0, 0, "", "", ""}, + {100829, 100826, 100827, "ȱȼ", "Ӽ", "˹", 0, 0, 0, "", "", ""}, + {100830, 100832, 100833, "ڱ", "", "", 0, 0, 0, "", "", ""}, + {100883, 100884, 100885, "", "", "", 0, 0, 0, "", "", ""}, + {100898, 100900, 100901, "ɿɶ", "", "ϲ", 0, 0, 0, "", "", ""}, + {100834, 100836, 100837, "", "屴", "岨", 0, 0, 0, "", "", ""}, + {100838, 100840, 100841, "", "֮", "", 0, 0, 0, "", "", ""}, + {100879, 100881, 100880, "ϼ", "", "ɰ", 0, 0, 0, "", "", ""}, + {100888, 100887, 100889, "Ī˾", "ŷɪ", "˹", 0, 0, 0, "", "", ""}, + {100913, 100914, 100915, "ķ˹", "˹", "˹", 0, 0, 0, "", "", ""}, + {100845, 100846, 100847, "", "³³", "³˹", 0, 0, 0, "", "", ""}, + {100849, 100850, 100851, "ŵ˹", "˹", "ϻ˹", 0, 0, 0, "", "", ""}, + {100878, 100876, 100877, "岼˹", "Ү˹", "ײ˹", 0, 0, 0, "", "", ""}, + {100908, 100909, 100906, "׶", "˾", "", 0, 0, 0, "", "", ""}, + {100916, 100918, 100919, "³˹", "Ϳ˾", "׵˹", 0, 0, 0, "", "", ""}, + {100860, 100862, 100861, "˾", "÷", "ϣ", 0, 0, 0, "", "", ""}, + {100867, 100870, 100868, "ŷּ³", "", "ʷ³", 0, 0, 0, "", "", ""}, + {100871, 100873, 100874, "³", "³", "˹", 0, 0, 0, "", "", ""}, + {100894, 100895, 100896, "Ħ", "ĦĦ", "Ħ", 0, 0, 0, "", "", ""}, + {100902, 100903, 100905, "", "Ħ", "˹", 0, 0, 0, "", "", ""}, + {100912, 100911, 100910, "", "˹", "", 0, 0, 0, "", "", ""}, + {100891, 100892, 100893, "֨", "˹˹", "ɸ˹", 0, 0, 0, "", "", ""}, +}; +#else +PetRaceGraTable petracegra[27] = +{ + {100820, 100821, 100822, "", "", "", 0, 0, 0, 2, 2, 2, "", "", ""}, + {100823, 100824, 100825, "³", "", "", 0, 0, 0, 2, 2, 2, "", "", ""}, + {100842, 100843, 100844, "˹", "˹", "˹", 0, 0, 0, 2, 2, 2, "", "", ""}, + {100852, 100853, 100855, "", "˹", "˴", 0, 0, 0, 2, 2, 2, "", "", ""}, + {100859, 100856, 100857, "ɿ", "", "", 0, 0, 0, 2, 2, 2, "", "", ""}, + {100864, 100865, 100866, "", "±", "ë", 0, 0, 0, 2, 2, 2, "", "", ""}, + {100829, 100826, 100827, "ȱȼ", "Ӽ", "˹", 0, 0, 0, 2, 2, 2, "", "", ""}, + {100830, 100832, 100833, "ڱ", "", "", 0, 0, 0, 2, 2, 2, "", "", ""}, + {100883, 100884, 100885, "", "", "", 0, 0, 0, 2, 2, 2, "", "", ""}, + {100898, 100900, 100901, "ɿɶ", "", "ϲ", 0, 0, 0, 2, 2, 2, "", "", ""}, + {100834, 100836, 100837, "", "屴", "岨", 0, 0, 0, 2, 2, 2, "", "", ""}, + {100838, 100840, 100841, "", "֮", "", 0, 0, 0, 2, 2, 2, "", "", ""}, + {100879, 100881, 100880, "ϼ", "", "ɰ", 0, 0, 0, 2, 2, 2, "", "", ""}, + {100888, 100887, 100889, "Ī˾", "ŷɪ", "˹", 0, 0, 0, 2, 2, 2, "", "", ""}, + {100913, 100914, 100915, "ķ˹", "˹", "˹", 0, 0, 0, 2, 2, 2, "", "", ""}, + {100845, 100846, 100847, "", "³³", "³˹", 0, 0, 0, 2, 2, 2, "", "", ""}, + {100849, 100850, 100851, "ŵ˹", "˹", "ϻ˹", 0, 0, 0, 2, 2, 2, "", "", ""}, + {100878, 100876, 100877, "岼˹", "Ү˹", "ײ˹", 0, 0, 0, 2, 2, 2, "", "", ""}, + {100908, 100909, 100906, "׶", "˾", "", 0, 0, 0, 2, 2, 2, "", "", ""}, + {100916, 100918, 100919, "³˹", "Ϳ˾", "׵˹", 0, 0, 0, 2, 2, 2, "", "", ""}, + {100860, 100862, 100861, "˾", "÷", "ϣ", 0, 0, 0, 2, 2, 2, "", "", ""}, + {100867, 100870, 100868, "ŷּ³", "", "ʷ³", 0, 0, 0, 2, 2, 2, "", "", ""}, + {100871, 100873, 100874, "³", "³", "˹", 0, 0, 0, 2, 2, 2, "", "", ""}, + {100894, 100895, 100896, "Ħ", "ĦĦ", "Ħ", 0, 0, 0, 2, 2, 2, "", "", ""}, + {100902, 100903, 100905, "", "Ħ", "˹", 0, 0, 0, 2, 2, 2, "", "", ""}, + {100912, 100911, 100910, "", "˹", "", 0, 0, 0, 2, 2, 2, "", "", ""}, + {100891, 100892, 100893, "֨", "˹˹", "ɸ˹", 0, 0, 0, 2, 2, 2, "", "", ""}, +}; +#endif +BOOL NPC_PetRaceMasterInit( int meindex ) +{ + CHAR_setInt(meindex, CHAR_LOOPINTERVAL, PETRACEMASTER_INITPET_LOOPTIME); + CHAR_setInt(meindex, CHAR_WHICHTYPE, CHAR_PETRACEMASTER); + CHAR_setWorkInt(meindex, NPC_WORK_STATE, NPC_State_Init); + CHAR_setWorkInt(meindex, NPC_WORK_PETGROUP, 0); +#ifdef _DROPSTAKENEW +#else + petracegra[0].payrate1 = 0; + petracegra[0].payrate2 = 0; + petracegra[0].payrate3 = 0; +#endif + return TRUE; +} + +void NPC_PetRaceMasterTalked( int meindex , int talkerindex , char *szMes , int color ) +{ + // ˵Լ״ + if (CHAR_getInt(talkerindex, CHAR_WHICHTYPE) != CHAR_TYPEPLAYER) + return; + if (NPC_Util_isFaceToFace(talkerindex, meindex, 2) == FALSE) + if (NPC_Util_CharDistance(talkerindex, meindex) > 1) + return; + NPC_PetRaceMaster_selectWindow(meindex, talkerindex, 0, -1); +} + +static void NPC_PetRaceMaster_selectWindow(int meindex, int toindex, int num, int select) +{ + char token[1024]; + int buttontype = 0, windowtype = 0, windowno = 0; + int fd = getfdFromCharaIndex(toindex); + if (fd == -1) return; + token[0] = '\0'; + switch(num) + { + case 0: + sprintf(token, "4\n\n ᄎٳ\n" + "ãҪ֪ʲ鱨\n" + "\n 쿴Ϸ" + "\n ״" + "\n 뿪"); + buttontype = WINDOW_BUTTONTYPE_NONE; + windowtype = WINDOW_MESSAGETYPE_SELECT; + windowno = CHAR_WINDOWTYPE_PETRACEMASTER_START; + break; + case 1: +#ifdef _DROPSTAKENEW + sprintf(token, + "\nٳ" + "\nμӾٵijֻܹճ" + "\n״ϲע뽫һõIJȯ" + "\nעĺǰٽʱ" + "\n˽Զ֡" + "\nע⣺뿪˷dzʱעIJ" + "\nֽ޷ȡࡣ"); +#else + sprintf(token, + "\nٳ򣺲μӾٵijﹲֻ" + "\nճ״ϲעÿ" + "\nԼʡ뽫ʯҶעĺǰ" + "\nٽʱ˻Զؽ" + "\nϻС" + "\nע⣺н𳬹һǧ򣡵뿪" + "\n˷dzʱעĽ޷ȡࡣ"); +#endif + buttontype = WINDOW_BUTTONTYPE_OK; + windowtype = WINDOW_MESSAGETYPE_MESSAGE; + windowno = CHAR_WINDOWTYPE_PETRACEMASTER_RULE; + break; + case 2: + { + int petgroup = CHAR_getWorkInt(meindex, NPC_WORK_PETGROUP); + int petindex1 = CHAR_getWorkInt(meindex, NPC_WORK_PET1); + int petindex2 = CHAR_getWorkInt(meindex, NPC_WORK_PET2); + int petindex3 = CHAR_getWorkInt(meindex, NPC_WORK_PET3); + int pet1win = petracegra[petgroup].pet1win; + int pet2win = petracegra[petgroup].pet2win; + int pet3win = petracegra[petgroup].pet3win; + int total = pet1win + pet2win + pet3win; + float winrate1 = 0, winrate2 = 0, winrate3 = 0; +#ifdef _DROPSTAKENEW +#else + char cpayrate1[64], cpayrate2[64], cpayrate3[64]; + if (petracegra[petgroup].payrate1 == 0) + snprintf(cpayrate1, sizeof(cpayrate1), "???"); + else + snprintf(cpayrate1, sizeof(cpayrate1), "%6.2f", petracegra[petgroup].payrate1); + if (petracegra[petgroup].payrate2 == 0) + snprintf(cpayrate2, sizeof(cpayrate2), "???"); + else + snprintf(cpayrate2, sizeof(cpayrate2), "%6.2f", petracegra[petgroup].payrate2); + if (petracegra[petgroup].payrate3 == 0) + snprintf(cpayrate3, sizeof(cpayrate3), "???"); + else + snprintf(cpayrate3, sizeof(cpayrate3), "%6.2f", petracegra[petgroup].payrate3); +#endif + if (total == 0) + { + winrate1 = 0; winrate2 = 0; winrate3 = 0; + } + else + { + winrate1 = (float)pet1win / (float)total; + winrate2 = (float)pet2win / (float)total; + winrate3 = (float)pet3win / (float)total; + } +#ifdef _DROPSTAKENEW + sprintf(token, "״\n\n ʤ ܳ ״ ʤ\n" + "========================================" + "%-10s%-6d%-6d%-8s%-6.2f\n" + "%-10s%-6d%-6d%-8s%-6.2f\n" + "%-10s%-6d%-6d%-8s%-6.2f\n", + CHAR_getChar(petindex1, CHAR_NAME), pet1win, total - pet1win, + petracegra[petgroup].state1, winrate1, + CHAR_getChar(petindex2, CHAR_NAME), pet2win, total - pet2win, + petracegra[petgroup].state2, winrate2, + CHAR_getChar(petindex3, CHAR_NAME), pet3win, total - pet3win, + petracegra[petgroup].state3, winrate3); +#else + sprintf(token, "״\n\n ʤ ܳ ״ ʤ \n" + "========================================" + "%-10s%-6d%-6d%-6s%-6.2f%-4s\n" + "%-10s%-6d%-6d%-6s%-6.2f%-4s\n" + "%-10s%-6d%-6d%-6s%-6.2f%-4s\n", + CHAR_getChar(petindex1, CHAR_NAME), pet1win, total - pet1win, + petracegra[petgroup].state1, winrate1, cpayrate1, + CHAR_getChar(petindex2, CHAR_NAME), pet2win, total - pet2win, + petracegra[petgroup].state2, winrate2, cpayrate2, + CHAR_getChar(petindex3, CHAR_NAME), pet3win, total - pet3win, + petracegra[petgroup].state3, winrate3, cpayrate3); +#endif + buttontype = WINDOW_BUTTONTYPE_OK; + windowtype = WINDOW_MESSAGETYPE_MESSAGE; + windowno = CHAR_WINDOWTYPE_PETRACEMASTER_PET; + } + break; + case 3: + default: + break; + } + lssproto_WN_send(fd, windowtype, buttontype, windowno, + CHAR_getWorkInt(meindex, CHAR_WORKOBJINDEX), token); +} + +void NPC_PetRaceMasterWindowTalked(int meindex, int talkerindex, int seqno, int select, char *data) +{ + int datanum = 0; + makeStringFromEscaped(data); + datanum = atoi(data); + switch(seqno) + { + case CHAR_WINDOWTYPE_PETRACEMASTER_START: + if (datanum == 1) + NPC_PetRaceMaster_selectWindow(meindex, talkerindex, 1, -1); + else if (datanum == 2) + NPC_PetRaceMaster_selectWindow(meindex, talkerindex, 2, -1); + break; + case CHAR_WINDOWTYPE_PETRACEMASTER_RULE: + if (datanum == 3) + NPC_PetRaceMaster_selectWindow(meindex, talkerindex, 1, -1); + case CHAR_WINDOWTYPE_PETRACEMASTER_PET: + case CHAR_WINDOWTYPE_PETRACEMASTER_LEAVE: + default: + break; + } +} + +void NPC_PetRaceMasterLoop( int meindex) +{ + int floor = CHAR_getInt(meindex, CHAR_FLOOR); + time_t t1; + time(&t1); + switch(CHAR_getWorkInt(meindex, NPC_WORK_STATE)) + { + case NPC_State_Init: + // Ѱҳindex + NPC_findRacePetIndex(meindex, floor); + break; + case NPC_State_WaitDropStake: + { + char tmpbuf[256]; + int statechangetime = CHAR_getWorkInt(meindex, NPC_WORK_STATECHANGE); + if (t1 < statechangetime) + { + if (statechangetime - t1 <= 5) + { + CHAR_setInt(meindex, CHAR_LOOPINTERVAL, PETRACEMASTER_WAITDROPIV_LOOPTIME); + snprintf(tmpbuf, sizeof(tmpbuf), "%2dҪˣӻԾע", + (int)(statechangetime - t1) % 60); + } + else if (statechangetime - t1 <= 10) + { + CHAR_setInt(meindex, CHAR_LOOPINTERVAL, PETRACEMASTER_WAITDROPIII_LOOPTIME); + snprintf(tmpbuf, sizeof(tmpbuf), "%2dҪˣӻԾע", + (int)(statechangetime - t1) % 60); + } + else if (statechangetime - t1 <= 30) + { + CHAR_setInt(meindex, CHAR_LOOPINTERVAL, PETRACEMASTER_WAITDROPII_LOOPTIME); + snprintf(tmpbuf, sizeof(tmpbuf), "%2dҪˣӻԾע", + (int)(statechangetime - t1) % 60); + } + else + snprintf(tmpbuf, sizeof(tmpbuf), "%2d%2dҪˣӻԾע", + (int)(statechangetime - t1) / 60, (int)(statechangetime - t1) % 60); + } + if (t1 >= statechangetime) + { +#ifdef _DROPSTAKENEW +#else + float payrate1 = 0, payrate2 = 0, payrate3 = 0; + int pet1gold = 0, pet2gold = 0, pet3gold = 0, totalgold = 0; + int petindex1 = CHAR_getWorkInt(meindex, NPC_WORK_PET1); + int petindex2 = CHAR_getWorkInt(meindex, NPC_WORK_PET2); + int petindex3 = CHAR_getWorkInt(meindex, NPC_WORK_PET3); + int randpet = CHAR_getWorkInt(meindex, NPC_WORK_PETGROUP); + float droprate1 = 0, droprate2 = 0, droprate3 = 0, totaldroprate, Npayrate = PETRACESTDPAYRATE; +#endif + int i = 0; + CHAR_setWorkInt(meindex, NPC_WORK_STATE, NPC_State_PetRacing); + // 趨治ע + SetCasinoMap(meindex, 0, FALSE); +#ifdef _DROPSTAKENEW + snprintf(tmpbuf, sizeof(tmpbuf), "ֹͣעܿʼޣ"); +#else + // ֪ʣȡóעʣ + GetCasinoMapGold(meindex, PET_RACE1, &pet1gold); + GetCasinoMapGold(meindex, PET_RACE2, &pet2gold); + GetCasinoMapGold(meindex, PET_RACE3, &pet3gold); + totalgold = pet1gold + pet2gold + pet3gold; + if (totalgold <= 0) + { + payrate1 = 2; payrate2 = 2; payrate3 = 2; + } + else + { + if (pet1gold <= PETRACESTDGOLD) + pet1gold = PETRACESTDGOLD; + if (pet2gold <= PETRACESTDGOLD) + pet2gold = PETRACESTDGOLD; + if (pet3gold <= PETRACESTDGOLD) + pet3gold = PETRACESTDGOLD; + totalgold = pet1gold + pet2gold + pet3gold; + droprate1 = totalgold / pet1gold; + droprate2 = totalgold / pet2gold; + droprate3 = totalgold / pet3gold; + totaldroprate = droprate1 + droprate2 + droprate3; + if (totaldroprate / droprate1 > PETRACESTDPAYRATE) + { + payrate1 = 1; Npayrate -= 1; + } + if (totaldroprate / droprate2 > PETRACESTDPAYRATE) + { + payrate2 = 1; Npayrate -= 1; + } + if (totaldroprate / droprate3 > PETRACESTDPAYRATE) + { + payrate3 = 1; Npayrate -= 1; + } + if (payrate1 != 1) + payrate1 = droprate1 / totaldroprate * Npayrate; + if (payrate2 != 1) + payrate2 = droprate2 / totaldroprate * Npayrate; + if (payrate3 != 1) + payrate3 = droprate3 / totaldroprate * Npayrate; + } + petracegra[randpet].payrate1 = payrate1; + petracegra[randpet].payrate3 = payrate2; + petracegra[randpet].payrate2 = payrate3; + SetCasinoPayRate(meindex, PET_RACE1, payrate1); + SetCasinoPayRate(meindex, PET_RACE2, payrate2); + SetCasinoPayRate(meindex, PET_RACE3, payrate3); + snprintf(tmpbuf, sizeof(tmpbuf), "ֹͣעܿʼޣ%sΪ%5.2f%sΪ%5.2f%sΪ%5.2f", + CHAR_getChar(petindex1, CHAR_NAME), payrate1, + CHAR_getChar(petindex2, CHAR_NAME), payrate2, + CHAR_getChar(petindex3, CHAR_NAME), payrate3); +#endif + CHAR_setInt(meindex, CHAR_LOOPINTERVAL, PETRACEMASTER_PETRACING_LOOPTIME); + // 趨״̬ + for (i = 0; i < PETRACEPETNUM; i++) + { + CHAR_setWorkInt(CHAR_getWorkInt(meindex, NPC_WORK_PET1 + i), NPC_WORK_STATE, NPC_State_Run); + CHAR_setInt(CHAR_getWorkInt(meindex, NPC_WORK_PET1 + i), CHAR_LOOPINTERVAL, 1000); + } + } + CHAR_talkToFloor(floor, meindex, tmpbuf, CHAR_COLORWHITE); + } + break; + case NPC_State_PetRacing: + if (CHAR_getWorkInt(meindex, NPC_WORK_PETGOAL) == PETRACEPETNUM) + { + char tmpbuf[256]; + int winpetindex = CHAR_getWorkInt(meindex, NPC_WORK_WINPET); + int petgroup = CHAR_getWorkInt(meindex, NPC_WORK_PETGROUP); + snprintf(tmpbuf, sizeof(tmpbuf), "ʤijǣ%s\n", + CHAR_getChar(winpetindex, CHAR_NAME)); + CHAR_talkToFloor(floor, meindex, tmpbuf, CHAR_COLORYELLOW); + // 趨ӮԼ + if (CHAR_getWorkInt(meindex, NPC_WORK_PET1) == winpetindex) + petracegra[petgroup].pet1win = petracegra[petgroup].pet1win + 1; + else if (CHAR_getWorkInt(meindex, NPC_WORK_PET2) == winpetindex) + petracegra[petgroup].pet2win = petracegra[petgroup].pet2win + 1; + else if (CHAR_getWorkInt(meindex, NPC_WORK_PET3) == winpetindex) + petracegra[petgroup].pet3win = petracegra[petgroup].pet3win + 1; + CHAR_setWorkInt(meindex, NPC_WORK_STATE, NPC_State_ShowWinPet); + CHAR_setInt(meindex, CHAR_LOOPINTERVAL, PETRACEMASTER_SHOWWINPET_LOOPTIME); + CHAR_setWorkInt(meindex, NPC_WORK_STATECHANGE, t1 + PETRACESHOWWINPET); + // + NPC_givePriceToPlayer(meindex, floor, winpetindex); + } + break; + case NPC_State_ShowWinPet: + { + int statechangetime = CHAR_getWorkInt(meindex, NPC_WORK_STATECHANGE); + if (t1 >= statechangetime) + { + int randpet = RAND(0, arraysizeof(petracegra) - 1); + int petindex1 = CHAR_getWorkInt(meindex, NPC_WORK_PET1); + int petindex2 = CHAR_getWorkInt(meindex, NPC_WORK_PET2); + int petindex3 = CHAR_getWorkInt(meindex, NPC_WORK_PET3); + char tmpbuf[256]; + CHAR_setWorkInt(meindex, NPC_WORK_PETGROUP, randpet); + CHAR_setWorkInt(meindex, NPC_WORK_STATE, NPC_State_WaitDropStake); + CHAR_setWorkInt(meindex, NPC_WORK_WINPET, 0); + CHAR_setWorkInt(meindex, NPC_WORK_PETGOAL, 0); + CHAR_setWorkInt(meindex, NPC_WORK_STATECHANGE, t1 + PETRACEDROPSTAKETIME); + CHAR_setInt(meindex, CHAR_LOOPINTERVAL, PETRACEMASTER_WAITDROPI_LOOPTIME); + // 趨ע + SetCasinoMap(meindex, 0, TRUE); + // 趨 + CHAR_setWorkInt(petindex1, NPC_WORK_STATE, NPC_State_Wait); + CHAR_setInt(petindex1, CHAR_LOOPINTERVAL, 1000); + CHAR_setInt(petindex1, CHAR_BASEIMAGENUMBER, petracegra[randpet].pet1gra); + CHAR_setChar(petindex1, CHAR_NAME, petracegra[randpet].pet1name); + + CHAR_setWorkInt(petindex2, NPC_WORK_STATE, NPC_State_Wait); + CHAR_setInt(petindex2, CHAR_LOOPINTERVAL, 1000); + CHAR_setInt(petindex2, CHAR_BASEIMAGENUMBER, petracegra[randpet].pet2gra); + CHAR_setChar(petindex2, CHAR_NAME, petracegra[randpet].pet2name); + + CHAR_setWorkInt(petindex3, NPC_WORK_STATE, NPC_State_Wait); + CHAR_setInt(petindex3, CHAR_LOOPINTERVAL, 1000); + CHAR_setInt(petindex3, CHAR_BASEIMAGENUMBER, petracegra[randpet].pet3gra); + CHAR_setChar(petindex3, CHAR_NAME, petracegra[randpet].pet3name); + // 趨״ +#ifdef _DROPSTAKENEW +#else + petracegra[randpet].payrate1 = 0; + petracegra[randpet].payrate3 = 0; + petracegra[randpet].payrate2 = 0; +#endif + { + int state1 = RAND(0, 3); + int state2 = RAND(0, 3); + int state3 = RAND(0, 3); + if (state1 == 0) + sprintf(petracegra[randpet].state1, ""); + else if (state1 == 1) + sprintf(petracegra[randpet].state1, "ͨ"); + else if (state1 == 2) + sprintf(petracegra[randpet].state1, ""); + else if (state1 == 3) + sprintf(petracegra[randpet].state1, "δ֪"); + if (state2 == 0) + sprintf(petracegra[randpet].state2, ""); + else if (state2 == 1) + sprintf(petracegra[randpet].state2, "ͨ"); + else if (state2 == 2) + sprintf(petracegra[randpet].state2, ""); + else if (state2 == 3) + sprintf(petracegra[randpet].state2, "δ֪"); + if (state3 == 0) + sprintf(petracegra[randpet].state3, ""); + else if (state3 == 1) + sprintf(petracegra[randpet].state3, "ͨ"); + else if (state3 == 2) + sprintf(petracegra[randpet].state3, ""); + else if (state3 == 3) + sprintf(petracegra[randpet].state3, "δ֪"); + } + snprintf(tmpbuf, sizeof(tmpbuf), "ᄎ׼УӻԾע"); + CHAR_talkToFloor(floor, meindex, tmpbuf, CHAR_COLORYELLOW); + } + } + break; + default: + break; + } +} + +void NPC_findRacePetIndex(int meindex, int floor) +{ + int i = 0, j = 0; + time_t t1; + time(&t1); + + if (CHAR_getWorkInt(meindex, NPC_WORK_FINDPETFLAG) == 0) + { + for (i = 0; i < CHAR_getCharNum(); i++) + { + if (CHAR_getInt(i, CHAR_FLOOR) == floor) + { + if (CHAR_getInt(i, CHAR_WHICHTYPE) == CHAR_PETRACEPET) + { + for (j = 0; j < PETRACEPETNUM; j++) + { + if (CHAR_getWorkInt(meindex, NPC_WORK_PET1 + j) == 0) + { + CHAR_setWorkInt(meindex, NPC_WORK_PET1 + j, i); + CHAR_setWorkInt(i, CHAR_NPCWORKINT2, meindex); + break; + } + } + } + } + } + if (CHAR_getWorkInt(meindex, NPC_WORK_PET1) > 0 + && CHAR_getWorkInt(meindex, NPC_WORK_PET2) > 0 + && CHAR_getWorkInt(meindex, NPC_WORK_PET3) > 0) + { + CHAR_setWorkInt(meindex, NPC_WORK_FINDPETFLAG, 1); + CHAR_setWorkInt(meindex, NPC_WORK_STATE, NPC_State_WaitDropStake); + CHAR_setInt(meindex, CHAR_LOOPINTERVAL, PETRACEMASTER_WAITDROPI_LOOPTIME); + CHAR_setWorkInt(meindex, NPC_WORK_STATECHANGE, t1 + PETRACEDROPSTAKETIME); + } + else CHAR_setWorkInt(meindex, NPC_WORK_FINDPETFLAG, 0); + } +} + +void NPC_givePriceToPlayer(int meindex, int floor, int winpetindex) +{ + int wincasinotype = 0; + if (CHAR_getWorkInt(meindex, NPC_WORK_PET1) == winpetindex) + wincasinotype = PET_RACE1; + else if (CHAR_getWorkInt(meindex, NPC_WORK_PET2) == winpetindex) + wincasinotype = PET_RACE2; + else if (CHAR_getWorkInt(meindex, NPC_WORK_PET3) == winpetindex) + wincasinotype = PET_RACE3; + if (wincasinotype == 0) return; + else + CasinoPay(meindex, wincasinotype); +} +#endif diff --git a/npc/npc_petracepet.c b/npc/npc_petracepet.c new file mode 100644 index 0000000..8eb5a42 --- /dev/null +++ b/npc/npc_petracepet.c @@ -0,0 +1,291 @@ +#include "version.h" +#include +#include "char.h" +#include "object.h" +#include "char_base.h" +#include "npcutil.h" +#include "lssproto_serv.h" +#include "handletime.h" + +#ifdef _PETRACE +#include "npc_petracepet.h" + +#define PETRACEPET_WAIT_LOOPTIME 30000 // 30 +#define PETRACEPET_SHOWWIN_LOOPTIME 10000 // 10 + +static void NPC_PetRacePet_Walk(int meindex); +static int NPC_PetRacePetSetPoint(int meindex, char *argstr); + +enum +{ + NPC_WORK_STATE = CHAR_NPCWORKINT1, + NPC_WORK_MASTER = CHAR_NPCWORKINT2, + NPC_WORK_ROUTEPOINT = CHAR_NPCWORKINT3, + NPC_WORK_ROUTETOX = CHAR_NPCWORKINT4, + NPC_WORK_ROUTETOY = CHAR_NPCWORKINT5, + NPC_WORK_WAITFLAG = CHAR_NPCWORKINT6, + NPC_WORK_FLOOR = CHAR_NPCWORKINT7, + NPC_WORK_X = CHAR_NPCWORKINT8, + NPC_WORK_Y = CHAR_NPCWORKINT9, + NPC_WORK_DIR = CHAR_NPCWORKINT10, + NPC_WORK_STOPX = CHAR_NPCWORKINT11, + NPC_WORK_STOPY = CHAR_NPCWORKINT12, +}; +enum +{ + NPC_State_Wait, + NPC_State_Run, + NPC_State_ShowWin, +}; + +int raceflag=0; + +BOOL NPC_PetRacePetInit( int meindex ) +{ + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + char buf[256]; + int showstopx, showstopy; + int routenum = 0, i = 0; + + NPC_Util_GetArgStr(meindex, argstr, sizeof(argstr)); + for (i = 1; i <= routenum; i++) + { + char routetostring[64]; + snprintf(routetostring, sizeof(routetostring), "routeto"); + if (NPC_Util_GetStrFromStrWithDelim(argstr, routetostring, buf, sizeof(buf)) == NULL) + { + print("Init_npcracepet: Didn't set route\n"); + return FALSE; + } + } + showstopx = NPC_Util_GetNumFromStrWithDelim(argstr, "showstopx"); + showstopy = NPC_Util_GetNumFromStrWithDelim(argstr, "showstopy"); + if (showstopx < 0 || showstopx > 100 || showstopy < 0 || showstopy > 100) + return FALSE; + CHAR_setInt(meindex, CHAR_WHICHTYPE, CHAR_PETRACEPET); + CHAR_setWorkInt(meindex, NPC_WORK_STATE, NPC_State_Wait); + CHAR_setWorkInt(meindex, NPC_WORK_ROUTEPOINT, 2); + CHAR_setWorkInt(meindex, NPC_WORK_WAITFLAG, 1); + CHAR_setWorkInt(meindex, NPC_WORK_FLOOR, CHAR_getInt(meindex, CHAR_FLOOR)); + CHAR_setWorkInt(meindex, NPC_WORK_X, CHAR_getInt(meindex, CHAR_X)); + CHAR_setWorkInt(meindex, NPC_WORK_Y, CHAR_getInt(meindex, CHAR_Y)); + CHAR_setWorkInt(meindex, NPC_WORK_DIR, CHAR_getInt(meindex, CHAR_DIR)); + CHAR_setWorkInt(meindex, NPC_WORK_STOPX, showstopx); + CHAR_setWorkInt(meindex, NPC_WORK_STOPY, showstopy); + CHAR_setInt(meindex, CHAR_LOOPINTERVAL, PETRACEPET_WAIT_LOOPTIME); + NPC_PetRacePetSetPoint(meindex, argstr); + + return TRUE; +} + +void NPC_PetRacePetTalked( int meindex , int talkerindex , char *szMes , int color ) +{ +} + +void NPC_PetRacePetLoop( int meindex) +{ + switch(CHAR_getWorkInt(meindex, NPC_WORK_STATE)) + { + case NPC_State_Wait: + { + if (CHAR_getWorkInt(meindex, NPC_WORK_WAITFLAG) == 0) + { + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + NPC_Util_GetArgStr(meindex, argstr, sizeof(argstr)); + CHAR_setWorkInt(meindex, NPC_WORK_ROUTEPOINT, 2); + NPC_PetRacePetSetPoint(meindex, argstr); + CHAR_setInt(meindex, CHAR_LOOPINTERVAL, PETRACEPET_WAIT_LOOPTIME); + CHAR_setInt(meindex, CHAR_DIR, CHAR_getWorkInt(meindex, NPC_WORK_DIR)); + CHAR_warpToSpecificPoint(meindex, + CHAR_getWorkInt(meindex, NPC_WORK_FLOOR), + CHAR_getWorkInt(meindex, NPC_WORK_X), + CHAR_getWorkInt(meindex, NPC_WORK_Y)); + CHAR_setWorkInt(meindex, NPC_WORK_WAITFLAG, 1); + } + } + break; + case NPC_State_Run: + { + int interval = 50; + int random = 0; + if (CHAR_getWorkInt(meindex, NPC_WORK_ROUTETOX) <= CHAR_getWorkInt(meindex, NPC_WORK_STOPX) + && CHAR_getWorkInt(meindex, NPC_WORK_ROUTETOY) >= CHAR_getWorkInt(meindex, NPC_WORK_STOPY)) + random = 3; + else + random = RAND(0, 8); + if (random == 0) // + { + int rands = RAND(0, 3); + interval = 1500; + CHAR_sendAction(meindex, 0, FALSE); + if (rands == TRUE) + { + char tmpbuf[256]; + int floor = CHAR_getInt(meindex, CHAR_FLOOR); + int master = CHAR_getWorkInt(meindex, NPC_WORK_MASTER); + int randomi = RAND(1, 9); + if (randomi == 1) + snprintf(tmpbuf, sizeof(tmpbuf), "Ŷ%sࡣ", + CHAR_getChar(meindex, CHAR_NAME)); + else if (randomi == 2) + snprintf(tmpbuf, sizeof(tmpbuf), "%sʹ˷һ", + CHAR_getChar(meindex, CHAR_NAME)); + else if (randomi == 3) + snprintf(tmpbuf, sizeof(tmpbuf), "...%sŭˣ", + CHAR_getChar(meindex, CHAR_NAME)); + if (randomi > 0 && randomi < 4) + CHAR_talkToFloor(floor, master, tmpbuf, CHAR_COLORWHITE); + } + } + else if (random == 1) // ε + { + int rands = RAND(0, 3); + interval = 2500; + CHAR_sendAction(meindex, 2, FALSE); + if (rands == TRUE) + { + char tmpbuf[256]; + int floor = CHAR_getInt(meindex, CHAR_FLOOR); + int master = CHAR_getWorkInt(meindex, NPC_WORK_MASTER); + int randomi = RAND(1, 9); + if (randomi == 1) + snprintf(tmpbuf, sizeof(tmpbuf), "%sε...", + CHAR_getChar(meindex, CHAR_NAME)); + else if (randomi == 2) + snprintf(tmpbuf, sizeof(tmpbuf), "%s", + CHAR_getChar(meindex, CHAR_NAME)); + else if (randomi == 3) + snprintf(tmpbuf, sizeof(tmpbuf), "...%sε¸ҵˣ", + CHAR_getChar(meindex, CHAR_NAME)); + if (randomi > 0 && randomi < 4) + CHAR_talkToFloor(floor, master, tmpbuf, CHAR_COLORWHITE); + } + } + else if (random == 2) // վ + { + interval = 500; + CHAR_sendAction(meindex, 3, FALSE); + } + else // һ + interval = RAND(20, 100); + NPC_PetRacePet_Walk(meindex); + CHAR_setInt(meindex, CHAR_LOOPINTERVAL, interval); + } + break; + case NPC_State_ShowWin: + { + int action = RAND(0, 11); + CHAR_sendAction(meindex, action, FALSE); + CHAR_setInt(meindex, CHAR_LOOPINTERVAL, PETRACEPET_SHOWWIN_LOOPTIME); + } + break; + default: + break; + } +} + +static void NPC_PetRacePet_Walk(int meindex) +{ + POINT start, end; + int dir, i; + + start.x = CHAR_getInt(meindex, CHAR_X); + start.y = CHAR_getInt(meindex, CHAR_Y); + end.x = CHAR_getWorkInt(meindex, NPC_WORK_ROUTETOX); + end.y = CHAR_getWorkInt(meindex, NPC_WORK_ROUTETOY); + if (start.x == end.x && start.y == end.y) + { + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + NPC_Util_GetArgStr(meindex, argstr, sizeof( argstr)); + CHAR_setWorkInt(meindex, NPC_WORK_ROUTEPOINT, + CHAR_getWorkInt(meindex, NPC_WORK_ROUTEPOINT) + 1); + + if (NPC_PetRacePetSetPoint(meindex, argstr) == FALSE) + { + // Ŀĵᣬʼ״̬ + char tmpbuf[256]; + int masterindex = CHAR_getWorkInt(meindex, NPC_WORK_MASTER); + int petgoal = CHAR_getWorkInt(masterindex, CHAR_NPCWORKINT9); + int floor = CHAR_getInt(masterindex, CHAR_FLOOR); + if (CHAR_getWorkInt(masterindex, CHAR_NPCWORKINT8) == 0) + { + CHAR_warpToSpecificPoint(meindex, 7005,42,44); + CHAR_setWorkInt(masterindex, CHAR_NPCWORKINT8, meindex); + CHAR_sendAction(meindex, 3, FALSE); + snprintf(tmpbuf, sizeof(tmpbuf), "ȵĿĵص...%s", + CHAR_getChar(meindex, CHAR_NAME)); + raceflag++; + } + else + { + if(raceflag == 1) + { + //ͻصָ + CHAR_warpToSpecificPoint(meindex, 7005,43,47); + snprintf(tmpbuf, sizeof(tmpbuf), "ŵĿĵص...%s", + CHAR_getChar(meindex, CHAR_NAME)); + raceflag++; + } + else + { + //һĴͣʼ + CHAR_warpToSpecificPoint(meindex, 7005,45,44); + snprintf(tmpbuf, sizeof(tmpbuf), "󵽴Ŀĵص...%s", + CHAR_getChar(meindex, CHAR_NAME)); + raceflag=0; + } + } + CHAR_setWorkInt(meindex, NPC_WORK_STATE, NPC_State_ShowWin); + CHAR_setInt(meindex, CHAR_LOOPINTERVAL, 500); + CHAR_setWorkInt(meindex, NPC_WORK_WAITFLAG, 0); + CHAR_setWorkInt(masterindex, CHAR_NPCWORKINT9, petgoal + 1); + CHAR_talkToFloor(floor, masterindex, tmpbuf, CHAR_COLORWHITE); + return; + } + else + return; + } + dir = NPC_Util_getDirFromTwoPoint(&start, &end); + end.x = CHAR_getInt(meindex, CHAR_X); + end.y = CHAR_getInt(meindex, CHAR_Y); + for(i = 0; i < 100; i++) + { + if (dir < 0) + dir = RAND(0, 7); + dir = NPC_Util_SuberiWalk(meindex, dir); + if (dir >= 0 && dir <= 7) break; + } + if (dir >= 0 && dir <= 7) + { + int result = 0; + result = CHAR_walk(meindex, dir, 0); + } +} + +static int NPC_PetRacePetSetPoint(int meindex, char *argstr) +{ + // Ѱһ x , y + char buf[4096], buf2[256], buf3[256]; + int ret; + char routetostring[64]; + snprintf(routetostring, sizeof(routetostring), "routeto"); + if (NPC_Util_GetStrFromStrWithDelim(argstr, routetostring, buf, sizeof(buf)) == NULL) + { + print("SetPoint_npcracepet: Didn't set route %s\n", routetostring); + return FALSE; + } + ret = getStringFromIndexWithDelim(buf, ";", + CHAR_getWorkInt(meindex, NPC_WORK_ROUTEPOINT), buf2, sizeof(buf2)); + if (ret == FALSE) return FALSE; + ret = getStringFromIndexWithDelim(buf2, ",", 1, buf3, sizeof(buf3)); + if (ret == FALSE) return FALSE; + CHAR_setWorkInt(meindex, NPC_WORK_ROUTETOX, atoi(buf3)); + ret = getStringFromIndexWithDelim(buf2, ",", 2, buf3, sizeof(buf3)); + if (ret == FALSE) return FALSE; + CHAR_setWorkInt(meindex, NPC_WORK_ROUTETOY, atoi(buf3)); + return TRUE; +} + +#endif + + diff --git a/npc/npc_petshop.c b/npc/npc_petshop.c new file mode 100644 index 0000000..d768b44 --- /dev/null +++ b/npc/npc_petshop.c @@ -0,0 +1,1533 @@ +#include "version.h" +#include +#include "char.h" +#include "object.h" +#include "char_base.h" +#include "npcutil.h" +#include "lssproto_serv.h" +#include "pet_skill.h" +#include "readmap.h" +#include "battle.h" +#include "log.h" +/* ⼰enum */ +enum { + NPC_PETSHOP_MSG_OVER, + NPC_PETSHOP_MSG_MAIN, + NPC_PETSHOP_MSG_REALY, + NPC_PETSHOP_MSG_THANKS, + NPC_PETSHOP_MSG_COST, + NPC_PETSHOP_MSG_POOLTHANKS, + NPC_PETSHOP_MSG_POOLFULL, + NPC_PETSHOP_MSG_GETFULL, +}; +typedef struct { + char option[32]; + char defaultmsg[128]; +}NPC_PETSHOP_MSG; + +NPC_PETSHOP_MSG shopmsg[] = { + { "over_msg", "Ǯ!û?"}, + { "main_msg", "ӭ"}, + { "realy_msg", "Ŀ?"}, + { "thanks_msg", "лл!"}, + { "cost_msg", "Ǯ!"}, + { "pooltanks_msg", "лл!"}, + { "poolfull_msg", "޷"}, + { "getfull_msg", "㲻кܶ"} + +}; + +#define PETCOST 10 + +void NPC_PetDate(int meindex,int toindex,int select,char *token); +void NPC_PetDate2(int meindex,int talker,int select,char *token); +void NPC_PetDate3(int meindex,int talker,int select,char *token); +void NPC_PetDel2( int meindex, int talker, int select, char *token); +void NPC_PetDel3( int meindex, int talker, int select, char *token); +void NPC_getDrawPet( int meindex, int toindex, char *token, int *buttontype, int select); + +void NPC_PetShop_selectWindow( int meindex, int toindex, int num,int select); +int NPC_GetCost(int meindex,int talker,int petindex); +void NPC_PetDel(int meindex, int toindex,int select,char* token); +void NPC_MaxGoldOver(int meindex,int toindex,int select,char *token); + +#ifdef _NPC_DEPOTPET +void NPC_PoolPetShop_DepotPet_Menu( int meindex, int talkerindex); +void NPC_DepotPet_List( int meindex, int toindex, char *token, int *buttontype, int select); +void NPC_DepotPet_Add( int meindex, int talker, int select, char *token); +void NPC_DepotPet_Get( int meindex, int talker, int select, char *token); +void NPC_DepotPet_AskGet(int meindex,int talker,int select,char *token); +//void NPC_DepotPet_Pet_printWindow( int meindex, int talkerindex); +//void NPC_DepotPet_Depot_printWindow( int meindex, int talkerindex); +//BOOL NPC_DepotPet_InsertPet( int meindex, int talkerindex, int num); +//BOOL NPC_DepotPet_getPet( int meindex, int talkerindex, int num); +#endif +void NPC_DepotPet_CheckRepeat_del( int charaindex, int petindex); + +// ľźңֿ +#define NPC_GETPOOLCOST( talker) ( 50 + CHAR_getInt( talker, CHAR_LV)*4) + +// ľŷɻ +#define NPC_PETSHOP_POOLCOST_DEFAULT 200 + +/*-- --*/ +enum { + CHAR_WORK_NOMALRATE = CHAR_NPCWORKINT1, + CHAR_WORK_SPECIALRATE = CHAR_NPCWORKINT2, + CHAR_WORK_POOLCOST = CHAR_NPCWORKINT3, + CHAR_WORK_POOLFLG = CHAR_NPCWORKINT4, +}; + + +/********************************* +* +*********************************/ +int pckmeindex = 0; +BOOL NPC_PetShopInit( int meindex ) +{ + + char npcarg[NPC_UTIL_GETARGSTR_BUFSIZE - 1024 * 20]; + char buf[256]; + double rate; + int intrate; +// int cost; + int tmp; + + /*--ɬ--*/ + CHAR_setInt( meindex , CHAR_WHICHTYPE , CHAR_TYPESTONESHOP ); + + + if( NPC_Util_GetArgStr( meindex, npcarg, sizeof( npcarg)) == NULL){ + print("GetArgStrErr"); + return FALSE; + } + + /*--ë炙巤ʢ*/ + if( NPC_Util_GetStrFromStrWithDelim( npcarg, "nomal_rate", buf, sizeof( buf)) != NULL){ + rate = atof( buf); + intrate = ( int)( rate *1000); + CHAR_setWorkInt( meindex , CHAR_WORK_NOMALRATE ,intrate ); + }else{ + CHAR_setWorkInt( meindex , CHAR_WORK_NOMALRATE ,1000 ); + } + + + /*--ʸһַʢ--*/ + if(NPC_Util_GetStrFromStrWithDelim( npcarg, "special_rate", buf, sizeof( buf))!=NULL) + { + rate = atof( buf); + intrate = ( int)( rate *1000); + CHAR_setWorkInt( meindex , CHAR_WORK_SPECIALRATE ,intrate ); + }else{ + CHAR_setWorkInt( meindex , CHAR_WORK_SPECIALRATE ,1200 ); + } + + // ľŷʢ + //cost = NPC_Util_GetNumFromStrWithDelim( npcarg, "pool_cost"); + //if( cost == -1 ) cost = NPC_PETSHOP_POOLCOST_DEFAULT; + //CHAR_setWorkInt( meindex, CHAR_WORK_POOLCOST, cost); + + + // ľ ¾ëʢ + tmp = NPC_Util_GetNumFromStrWithDelim( npcarg, "pool_flg"); + if( tmp != 1 ) tmp = 0; + CHAR_setWorkInt( meindex, CHAR_WORK_POOLFLG, tmp); + pckmeindex = meindex; + return TRUE; + +} + + + + +/********************************* +* ƾľݼ +*********************************/ +void NPC_PetShopTalked( int meindex , int talkerindex , char *szMes ,int color ) +{ + /* 帲ƻ ɱ */ + if( CHAR_getInt( talkerindex , CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER ) { + return; + } + + /*-- ¾--*/ + if(NPC_Util_isFaceToFace(talkerindex,meindex,2 )==FALSE){ + /* */ + if( NPC_Util_CharDistance( talkerindex, meindex ) > 1) return; + } + /*--ͼ--*/ + CHAR_setWorkInt(talkerindex,CHAR_WORKSHOPRELEVANT,0); + /*-Ԫ --*/ + NPC_PetShop_selectWindow( meindex, talkerindex,0,-1); +} + +/********************************* +* έľݼ +*********************************/ +void NPC_PetShopLooked( int meindex , int lookedindex) +{ + /* 帲ƻ ɱ */ + if( CHAR_getInt( lookedindex , CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER ) { + return; + } + + /* */ + //if( NPC_Util_CharDistance( lookedindex, meindex ) > 2) return; + + /*--ͼ--*/ +// CHAR_setWorkInt(lookedindex,CHAR_WORKSHOPRELEVANT,0); + + +// NPC_PetShop_selectWindow( meindex, lookedindex,0,-1); + +} +void NPC_PetShop_selectWindow1( int meindex, int toindex, int num,int select) +{ + NPC_PetShop_selectWindow( meindex, toindex, num,select); + +} + +void NPC_PetShop_selectWindow( int meindex, int toindex, int num,int select) +{ + char token[1024]; + int buttontype=0,windowtype=0,windowno=0; + char buf[256]; + int fd = getfdFromCharaIndex( toindex); + + //print("\n NPC_PetShop_selectWindow num:%d select:%d ", num, select); + if( fd == -1 ) { + fprint( "getfd err\n"); + return; + } + token[0] = '\0'; + switch(num){ + // ټū + case 0: + NPC_MaxGoldOver( meindex, toindex, NPC_PETSHOP_MSG_MAIN, buf); + +#ifdef _NPC_DEPOTPET + if( !CHAR_getWorkInt( meindex, CHAR_WORK_POOLFLG)) { + sprintf(token, "4\n̵" + "%s" + "\n" + "\n " + "\n" + "\n" + "\n 뿪 ", + buf); + }else { + sprintf(token, "4\n̵" + "%s" + "\n ķų " + "\n ȡ " + "\n " + "\n ֿ " + "\n 뿪 ", + buf); + } +#else + if( !CHAR_getWorkInt( meindex, CHAR_WORK_POOLFLG)) { + sprintf(token, "4\n̵" + "%s" + "\n" + "\n " + "\n" + "\n 뿪 ", + buf); + }else { + sprintf(token, "4\n̵" + "%s" + "\n ķų " + "\n ȡ " + "\n " + "\n 뿪 ", + buf); + } +#endif + buttontype=WINDOW_BUTTONTYPE_NONE; + windowtype=WINDOW_MESSAGETYPE_SELECT; + windowno=CHAR_WINDOWTYPE_WINDOWPETSHOP_START; + break; + case 1: + buttontype=WINDOW_BUTTONTYPE_CANCEL; + windowtype=WINDOW_MESSAGETYPE_PETSELECT; + windowno=CHAR_WINDOWTYPE_WINDOWPETSHOP_PETSELECT; + break; + case 2: + NPC_PetDate(meindex,toindex,select,token); + buttontype=WINDOW_BUTTONTYPE_YESNO; + windowtype=WINDOW_MESSAGETYPE_MESSAGE; + windowno=CHAR_WINDOWTYPE_WINDOWPETSHOP_MAIN; + break; + case 3: + if( (CHAR_getInt(toindex,CHAR_GOLD)+CHAR_getWorkInt(toindex,CHAR_WORKSHOPRELEVANTSEC)) + > CHAR_getMaxHaveGold( toindex) ){ + + NPC_MaxGoldOver( meindex, toindex, NPC_PETSHOP_MSG_OVER, token); + windowno=CHAR_WINDOWTYPE_WINDOWPETSHOP_GOLDOVER; + buttontype=WINDOW_BUTTONTYPE_YESNO; + }else{ + NPC_PetDel(meindex,toindex,select,token); + buttontype=WINDOW_BUTTONTYPE_OK; + windowno=CHAR_WINDOWTYPE_WINDOWPETSHOP_END; + } + + windowtype=WINDOW_MESSAGETYPE_MESSAGE; + break; + case 4: + NPC_PetDel(meindex,toindex,select,token); + buttontype=WINDOW_BUTTONTYPE_OK; + windowno=CHAR_WINDOWTYPE_WINDOWPETSHOP_END; + windowtype=WINDOW_MESSAGETYPE_MESSAGE; + break; + case 5: // ȡķųб + if( CHAR_getWorkInt( meindex, CHAR_WORK_POOLFLG ) != 1 ) + return; + buttontype=WINDOW_BUTTONTYPE_CANCEL; + windowtype=WINDOW_MESSAGETYPE_PETSELECT; + windowno=CHAR_WINDOWTYPE_WINDOWPETSHOP_PETSELECT2; + break; + case 6: + if( CHAR_getInt( toindex, CHAR_GOLD) + < NPC_GETPOOLCOST( toindex)) + { + NPC_MaxGoldOver(meindex, toindex, NPC_PETSHOP_MSG_COST, token); + buttontype = WINDOW_BUTTONTYPE_OK; + } + else { + NPC_PetDate2( meindex, toindex, select, token); + buttontype = WINDOW_BUTTONTYPE_YESNO; + } + windowtype = WINDOW_MESSAGETYPE_MESSAGE; + windowno = CHAR_WINDOWTYPE_WINDOWPETSHOP_MAIN2; + break; + + case 7: + if( CHAR_getWorkInt( meindex, CHAR_WORK_POOLFLG ) != 1 ) + return; + if( CHAR_getInt( toindex, CHAR_GOLD) < NPC_GETPOOLCOST( toindex)){ + NPC_MaxGoldOver(meindex, toindex, NPC_PETSHOP_MSG_COST, token); + }else { + NPC_PetDel2( meindex, toindex, select, token); + } + buttontype = WINDOW_BUTTONTYPE_OK; + windowtype = WINDOW_MESSAGETYPE_MESSAGE; + windowno = CHAR_WINDOWTYPE_WINDOWPETSHOP_END; + break; + // ľ + case 8: + NPC_MaxGoldOver( meindex, toindex, NPC_PETSHOP_MSG_POOLFULL, token); + buttontype = WINDOW_BUTTONTYPE_OK; + windowtype = WINDOW_MESSAGETYPE_MESSAGE; + windowno = CHAR_WINDOWTYPE_WINDOWPETSHOP_END; + break; + // ¦Իʸ ū + case 9: // ȡķųб + if( CHAR_getWorkInt( meindex, CHAR_WORK_POOLFLG) != 1 ) + return; + NPC_getDrawPet( meindex, toindex, token, &buttontype, select); + windowtype = WINDOW_MESSAGETYPE_SELECT; + windowno = CHAR_WINDOWTYPE_WINDOWPETSHOP_DRAWSELECT; + break; + // ¦Ի + case 10: + NPC_PetDate3( meindex, toindex, select, token); + buttontype = WINDOW_BUTTONTYPE_YESNO; + windowtype = WINDOW_MESSAGETYPE_MESSAGE; + windowno = CHAR_WINDOWTYPE_WINDOWPETSHOP_ASKDRAW; + break; + // ߯ + case 11: + if( CHAR_getWorkInt( meindex, CHAR_WORK_POOLFLG ) != 1 ) + return; + NPC_PetDel3( meindex, toindex, select, token); + buttontype = WINDOW_BUTTONTYPE_OK; + windowtype = WINDOW_MESSAGETYPE_MESSAGE; + windowno = CHAR_WINDOWTYPE_WINDOWPETSHOP_END; + break; + // ʸ + case 12: + NPC_MaxGoldOver( meindex, toindex, NPC_PETSHOP_MSG_GETFULL, token); + buttontype = WINDOW_BUTTONTYPE_OK; + windowtype = WINDOW_MESSAGETYPE_MESSAGE; + windowno = CHAR_WINDOWTYPE_WINDOWPETSHOP_END; + break; +#ifdef _NPC_DEPOTPET + case 13: // ֿб + if( !CHAR_CheckDepotPet( toindex) ) + return; + buttontype=WINDOW_BUTTONTYPE_CANCEL; + windowtype=WINDOW_MESSAGETYPE_PETSELECT; + windowno=CHAR_WINDOWTYPE_DEPOTPETSHOP_ADD; + break; + case 14: // ȡֿб + if( !CHAR_CheckDepotPet( toindex) ) + return; + NPC_DepotPet_List( meindex, toindex, token, &buttontype, select); + //buttontype=WINDOW_BUTTONTYPE_CANCEL; + windowtype = WINDOW_MESSAGETYPE_SELECT; + windowno = CHAR_WINDOWTYPE_DEPOTPETSHOP_GET; + break; + + case 15: // ѯȷϴֿ + if( CHAR_getInt( toindex, CHAR_GOLD) + < NPC_GETPOOLCOST( toindex)) + { + NPC_MaxGoldOver(meindex, toindex, NPC_PETSHOP_MSG_COST, token); + buttontype = WINDOW_BUTTONTYPE_OK; + } + else { + NPC_PetDate2( meindex, toindex, select, token); + buttontype = WINDOW_BUTTONTYPE_YESNO; + } + windowtype = WINDOW_MESSAGETYPE_MESSAGE; + windowno = CHAR_WINDOWTYPE_DEPOTPETSHOP_ASKADD; + break; + + case 16: // ѯȷȡֿ + NPC_DepotPet_AskGet( meindex, toindex, select, token); + buttontype = WINDOW_BUTTONTYPE_YESNO; + windowtype = WINDOW_MESSAGETYPE_MESSAGE; + windowno = CHAR_WINDOWTYPE_DEPOTPETSHOP_ASKGET; + break; + + case 17: // ȷϴֿ + if( !CHAR_CheckDepotPet(toindex) ) + return; + if( CHAR_getInt( toindex, CHAR_GOLD) < NPC_GETPOOLCOST( toindex)){ + NPC_MaxGoldOver(meindex, toindex, NPC_PETSHOP_MSG_COST, token); + }else { + NPC_DepotPet_Add( meindex, toindex, select, token); + } + buttontype = WINDOW_BUTTONTYPE_OK; + windowtype = WINDOW_MESSAGETYPE_MESSAGE; + windowno = CHAR_WINDOWTYPE_WINDOWPETSHOP_END; + break; + + case 18: // ȷȡֿ + if( CHAR_getWorkInt( meindex, CHAR_WORK_POOLFLG ) != 1 ) + return; + if( NPC_DepotPet_CheckLevel( meindex, toindex, select, token) == TRUE) { + NPC_DepotPet_Get( meindex, toindex, select, token); + buttontype = WINDOW_BUTTONTYPE_OK; + windowtype = WINDOW_MESSAGETYPE_MESSAGE; + windowno = CHAR_WINDOWTYPE_WINDOWPETSHOP_END; + } + else { + sprintf( token, "\n޷չֻ"); + buttontype = WINDOW_BUTTONTYPE_OK; + windowtype = WINDOW_MESSAGETYPE_MESSAGE; + windowno = CHAR_WINDOWTYPE_WINDOWPETSHOP_END; + } + break; +#endif + // CoolFish: Add 2001/7/4 + default: + break; + + } + + /*--޵--*/ + //makeEscapeString( token, escapedname, sizeof(escapedname)); + + /*--˪--*/ + lssproto_WN_send( fd, windowtype, + buttontype, + windowno, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + token); +} + +void NPC_PetShopWindowTalked( int meindex, int talkerindex, + int seqno, int select, char *data) +{ + int datanum = -1; + //print("\n NPC_PetShopWindowTalked: data:%s seq:%d sel:%d ", data, seqno, select); + + makeStringFromEscaped( data); + + datanum = atoi( data); + switch( seqno){ + case CHAR_WINDOWTYPE_WINDOWPETSHOP_START: + { + int poolflg = CHAR_getWorkInt( meindex, CHAR_WORK_POOLFLG); + if( ( datanum == 3 && poolflg) || // + ( datanum == 2 && !poolflg ) ){ // ȡ + NPC_PetShop_selectWindow( meindex, talkerindex, 1, -1 ); + }else if( datanum == 1 && poolflg) { // ķų + if( CHAR_getCharPoolPetElement( talkerindex) != -1 ) { + NPC_PetShop_selectWindow( meindex, talkerindex, 5, -1 ); + } + else { + NPC_PetShop_selectWindow( meindex, talkerindex, 8, -1 ); + } + }else if( datanum == 2 && poolflg ) { // ȡ + if( CHAR_getCharPetElement( talkerindex) != -1 ) { + CHAR_setWorkInt( talkerindex, CHAR_WORKSHOPRELEVANT, 0); + NPC_PetShop_selectWindow( meindex, talkerindex, 9, 0); + }else { + NPC_PetShop_selectWindow( meindex, talkerindex, 12, -1 ); + } + } +#ifdef _NPC_DEPOTPET + else if( datanum == 4 ) { // ʹóֿ + print(" ʹóֿ "); + CHAR_setWorkInt( talkerindex, CHAR_WORKSHOPRELEVANT, 0); + if( !CHAR_CheckDepotPet( talkerindex) ){ + CHAR_GetDepotPet( meindex, talkerindex); + CHAR_talkToCli( talkerindex, -1, "ȡóᣡ", CHAR_COLORYELLOW); + }else{ + NPC_PoolPetShop_DepotPet_Menu( meindex, talkerindex); + } + } +#endif + } + break; + case CHAR_WINDOWTYPE_WINDOWPETSHOP_PETSELECT: + if(select==WINDOW_BUTTONTYPE_CANCEL){ + NPC_PetShop_selectWindow( meindex, talkerindex, 0,-1 ); + + }else{ + NPC_PetShop_selectWindow( meindex, talkerindex, 2, datanum ); + } + break; + case CHAR_WINDOWTYPE_WINDOWPETSHOP_PETSELECT2: + if(select==WINDOW_BUTTONTYPE_CANCEL){ + NPC_PetShop_selectWindow( meindex, talkerindex, 0,-1 ); + }else{ + NPC_PetShop_selectWindow( meindex, talkerindex, 6, datanum ); + } + break; + case CHAR_WINDOWTYPE_WINDOWPETSHOP_MAIN: + if(select==WINDOW_BUTTONTYPE_YES){ + if(CHAR_getWorkInt( talkerindex, CHAR_WORKSAFEMODE)==0){ + CHAR_SafePassword(talkerindex); + return; + } + NPC_PetShop_selectWindow( meindex, talkerindex, 3,-1 ); + }else{ + NPC_PetShop_selectWindow( meindex, talkerindex,1,-1); + } + break; + case CHAR_WINDOWTYPE_WINDOWPETSHOP_MAIN2: + if(select==WINDOW_BUTTONTYPE_YES){ + NPC_PetShop_selectWindow( meindex, talkerindex, 7,-1 ); + }else { + NPC_PetShop_selectWindow( meindex, talkerindex,5,-1); + } + break; + case CHAR_WINDOWTYPE_WINDOWPETSHOP_ASKDRAW: + if( select == WINDOW_BUTTONTYPE_YES){ + if( CHAR_getCharPetElement( talkerindex) != -1 ) { + NPC_PetShop_selectWindow( meindex, talkerindex, 11,-1 ); + }else { + NPC_PetShop_selectWindow( meindex, talkerindex, 12, -1 ); + } + }else { + CHAR_setWorkInt( talkerindex, CHAR_WORKSHOPRELEVANT, 0); + NPC_PetShop_selectWindow( meindex, talkerindex, 9, 0); + } + break; + case CHAR_WINDOWTYPE_WINDOWPETSHOP_GOLDOVER: + if( select == WINDOW_BUTTONTYPE_YES){ + NPC_PetShop_selectWindow( meindex, talkerindex, 4,-1 ); + }else{ + NPC_PetShop_selectWindow( meindex, talkerindex, 0,-1 ); + } + break; + case CHAR_WINDOWTYPE_WINDOWPETSHOP_DRAWSELECT: + if( select == WINDOW_BUTTONTYPE_PREV){ + NPC_PetShop_selectWindow( meindex, talkerindex, 9, -1); + }else if( select == WINDOW_BUTTONTYPE_NEXT) { + NPC_PetShop_selectWindow( meindex, talkerindex, 9, 1); + }else if( select != WINDOW_BUTTONTYPE_CANCEL) { + if( CHAR_getCharPetElement( talkerindex) != -1 ) { + NPC_PetShop_selectWindow( meindex, talkerindex, 10, datanum); + }else { + NPC_PetShop_selectWindow( meindex, talkerindex, 12, -1 ); + } + }else { + NPC_PetShop_selectWindow( meindex, talkerindex, 0,-1 ); + } + break; + +#ifdef _NPC_DEPOTPET + case CHAR_WINDOWTYPE_DEPOTPETSHOP_HANDLE: + if( !CHAR_CheckDepotPet( talkerindex) ) return ; + switch( datanum ) { + case 1:// +#ifdef _BIG_POOL_TYPE + if(getPetPoolType()==1){ + CHAR_talkToCli( talkerindex, -1, "ֿѹرգʹø˲ֿ⡣", CHAR_COLORYELLOW); + return; + } +#endif + if( CHAR_findEmptyDepotPet( talkerindex) == -1 ){ + CHAR_talkToCli( talkerindex, -1, "ֿ", CHAR_COLORYELLOW); + return; + } + //NPC_DepotPet_Pet_printWindow( meindex, talkerindex); + NPC_PetShop_selectWindow( meindex, talkerindex, 13, -1 ); + break; + case 2://ȡ + if( CHAR_getCharPetElement( talkerindex) < 0 ) { + CHAR_talkToCli( talkerindex, -1, "ϳλ", CHAR_COLORYELLOW); + return; + } + NPC_PetShop_selectWindow( meindex, talkerindex, 14, 0); + break; + case 0: + NPC_PetShop_selectWindow( meindex, talkerindex, 0, -1); + break; + } + break; + + case CHAR_WINDOWTYPE_DEPOTPETSHOP_ADD: + if(select==WINDOW_BUTTONTYPE_CANCEL){ + NPC_PetShop_selectWindow( meindex, talkerindex, 0,-1 ); + }else{ + NPC_PetShop_selectWindow( meindex, talkerindex, 15, datanum ); + } + break; + + case CHAR_WINDOWTYPE_DEPOTPETSHOP_GET: + if( select == WINDOW_BUTTONTYPE_PREV){ + NPC_PetShop_selectWindow( meindex, talkerindex, 14, -1); + }else if( select == WINDOW_BUTTONTYPE_NEXT) { + NPC_PetShop_selectWindow( meindex, talkerindex, 14, 1); + }else if( select != WINDOW_BUTTONTYPE_CANCEL) { + if( CHAR_getCharPetElement( talkerindex) != -1 ) { + NPC_PetShop_selectWindow( meindex, talkerindex, 16, datanum); + }else { + NPC_PetShop_selectWindow( meindex, talkerindex, 12, -1 ); + } + }else { + NPC_PetShop_selectWindow( meindex, talkerindex, 0,-1 ); + } + + break; + case CHAR_WINDOWTYPE_DEPOTPETSHOP_ASKADD: // ȷϴֿ + if(select==WINDOW_BUTTONTYPE_YES){ + NPC_PetShop_selectWindow( meindex, talkerindex, 17,-1 ); + }else { + NPC_PetShop_selectWindow( meindex, talkerindex,13,-1); + } + break; + + case CHAR_WINDOWTYPE_DEPOTPETSHOP_ASKGET: // ȷȡֿ + if( select == WINDOW_BUTTONTYPE_YES){ + if( CHAR_getCharPetElement( talkerindex) != -1 ) { + NPC_PetShop_selectWindow( meindex, talkerindex, 18,-1 ); + }else { + NPC_PetShop_selectWindow( meindex, talkerindex, 12, -1 ); + } + }else { + CHAR_setWorkInt( talkerindex, CHAR_WORKSHOPRELEVANT, 0); + NPC_PetShop_selectWindow( meindex, talkerindex, 14, 0); + } + break; +#endif + + case CHAR_WINDOWTYPE_WINDOWPETSHOP_END: + if( select == WINDOW_BUTTONTYPE_OK){ + NPC_PetShop_selectWindow( meindex, talkerindex, 0,-1 ); + } + break; + + // CoolFish: Add 2001/7/4 + default: + break; + + } +} + +void NPC_PetDate(int meindex,int talker,int select,char *token) +{ + + int petindex; + int cost; + char *petname; + char buf[1024]; + + /*--ͼ--*/ + CHAR_setWorkInt(talker,CHAR_WORKSHOPRELEVANT,select); + + petindex = CHAR_getCharPet( talker, select-1); + + + if( !CHAR_CHECKINDEX(petindex) ) return; + + NPC_MaxGoldOver( meindex, talker, NPC_PETSHOP_MSG_REALY, buf); + + cost=NPC_GetCost(meindex,talker,petindex); + + petname = CHAR_getUseName( petindex); + + sprintf(token,"\n[%s]ûɣ""%s" + "\n\n ۸ %d STONE\n" + ,petname,buf,cost); + +} + +void NPC_PetDate2(int meindex,int talker,int select,char *token) +{ + + int petindex; + char *petname; + CHAR_setWorkInt(talker,CHAR_WORKSHOPRELEVANT,select); + + petindex = CHAR_getCharPet( talker, select-1); + if( !CHAR_CHECKINDEX(petindex) ) return; + petname = CHAR_getUseName( petindex); + sprintf(token,"\nķ[%s]" + "\n\n ķż۸ %d stone\n" + ,petname, NPC_GETPOOLCOST( talker) + ); +} + +void NPC_PetDate3(int meindex,int talker,int select,char *token) +{ + int poolindex; + int petindex; + char *petname; + poolindex = CHAR_getWorkInt( talker, CHAR_WORKSHOPRELEVANT) * 5 + select - 1; + CHAR_setWorkInt(talker,CHAR_WORKSHOPRELEVANT,poolindex ); + petindex = CHAR_getCharPoolPet( talker, poolindex); + if( !CHAR_CHECKINDEX(petindex) ) return; + petname = CHAR_getUseName( petindex); + sprintf(token,"\n[%s]", petname); +} + +int NPC_GetCost(int meindex,int talker,int petindex) +{ + int cost; + int levelcost; + int level; + int getlevel; + int graNo; + int rare; + int charm=50; + int petai; + int i=1; + double rate=1.0; + int intrate; + char buf[1024]; + char buff2[128]; + char npcarg[NPC_UTIL_GETARGSTR_BUFSIZE - 1024 * 20]; + + if(NPC_Util_GetArgStr( meindex, npcarg, sizeof(npcarg))==NULL){ + print("GetArgStrErr"); + return FALSE; + } + + + getlevel=CHAR_getInt(petindex,CHAR_PETGETLV); + level=CHAR_getInt(petindex,CHAR_LV); + graNo=CHAR_getInt(petindex,CHAR_BASEBASEIMAGENUMBER); + rare=CHAR_getInt(petindex,CHAR_RARE); + + if(getlevel==0) getlevel=1 ; + + /*--ëƻ--*/ + levelcost=(level*level)*10; + getlevel=(getlevel*getlevel)*10; +// Syu ADD ޸תǮ为bug +#ifdef _PET_2TRANS + if( CHAR_getInt(petindex , CHAR_TRANSMIGRATION)>0) +#else + if( CHAR_getInt(petindex , CHAR_TRANSMIGRATION)==1) +#endif + getlevel=10; + + + if(rare==0){ rare=1; + }else if(rare==1){ rare=5; + }else if(rare==2){ rare=8;} + + cost = ((levelcost-getlevel)+(level*PETCOST))*rare; + intrate = CHAR_getWorkInt( meindex , CHAR_WORK_NOMALRATE); + rate=(double) intrate / 1000; + + + NPC_Util_GetStrFromStrWithDelim( npcarg, "special_pet", buf, sizeof( buf)); + + i=1; + /*--ʸһƥңľʸëԻ ʸ϶÷ į)--*/ + while( getStringFromIndexWithDelim(buf,",",i,buff2,sizeof(buff2)) !=FALSE ) + { + if(strstr( buff2, "-")==NULL){ + if(graNo == atoi(buff2)){ + intrate=CHAR_getWorkInt( meindex , CHAR_WORK_SPECIALRATE); + rate=(double) intrate / 1000; + break; + } + }else{ + /*--ʧ ة 15-25 ƥľ--*/ + int start; + int end; + int tmp; + int graflg=0; + char token2[128]; + + /*-"-"ƥľ炙Ѱ Ѱë --*/ + getStringFromIndexWithDelim( buff2, "-", 1, token2, sizeof(token2)); + start = atoi( token2); + getStringFromIndexWithDelim( buff2, "-", 2 ,token2, sizeof(token2)); + end = atoi( token2); + + /*-- įѱئȻգ ľ׸**/ + if(start > end){ + tmp=start; + start=end; + end=tmp; + } + + end++; + /*--"-"ƥľмʧ ة ë --*/ + if(start <= graNo && graNo < end){ + intrate=CHAR_getWorkInt( meindex , CHAR_WORK_SPECIALRATE); + rate=(double) intrate / 1000; + graflg=1; + break; + } + + if(graflg ==1) break; + } + i++; + } + + /*--ʸպë ---*/ + petai=CHAR_getWorkInt(petindex,CHAR_WORKFIXAI); + + /*-- ë--*/ + charm = CHAR_getWorkInt(talker,CHAR_WORKFIXCHARM); + + /*-- պ / */ + charm = charm + petai; + + if(charm < 20){ + charm = 20; + } + + charm = charm / 2; + + cost = (int)cost*rate; + + rate=(double)charm/100; + + /*-- --*/ + cost = cost * rate; + +// if(levelcost == getlevel){ +// cost = cost / 4; +// } + + /*--ëʢ--*/ + CHAR_setWorkInt(talker,CHAR_WORKSHOPRELEVANTSEC,cost); + + return cost; +} + + +#if 1 + +void NPC_PetDel(int meindex, int talker,int select,char* token) +{ + int petindex; + int petsel; + char szPet[128]; + int cost; + int defpet; + int fd = getfdFromCharaIndex( talker ); + + NPC_MaxGoldOver( meindex, talker, NPC_PETSHOP_MSG_THANKS, token); + petsel=(CHAR_getWorkInt(talker,CHAR_WORKSHOPRELEVANT)-1); + petindex = CHAR_getCharPet( talker, petsel); + + if( !CHAR_CHECKINDEX(petindex) ) return; + + // CoolFish: Family 2001/6/14 + if (CHAR_getInt(petindex, CHAR_PETFAMILY) == 1){ +/* char buf[1024]; + lssproto_WN_send(fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + -1, -1, + makeEscapeString("\n\nܱǸػ޷ร\nԼúչˣ", buf, sizeof(buf))); +*/ + sprintf(token,"\n\nܱǸػ޷ร\nԼúչˣ"); + return; + } + + // Robin 0725 + if (CHAR_getInt( talker, CHAR_RIDEPET ) == petsel ){ +/* char buf[1024]; + lssproto_WN_send(fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + -1, -1, + makeEscapeString("\n\nеij޷ร", buf, sizeof(buf))); +*/ + sprintf(token,"\n\nеij޷ร"); + return; + } + if(strlen(CHAR_getChar(petindex,CHAR_USERPETNAME))>0 && strstr(CHAR_getChar(petindex,CHAR_USERPETNAME),"*")!=NULL){ + sprintf(token,"\n\nԶк(*)޷ꡢס̯޸ĺ"); + //CHAR_talkToCli(charaindex, -1, "Զк(*)޷ꡢס̯޸ĺ", CHAR_COLORYELLOW); + return; + } + if( CHAR_getWorkInt( talker, CHAR_WORKSAFEMODE)==0) + { + CHAR_SafePassword(talker); + return; + } + if( CHAR_getWorkInt( CONNECT_getCharaindex(fd), + CHAR_WORKBATTLEMODE) != BATTLE_CHARMODE_NONE) return ; + defpet=CHAR_getInt(talker,CHAR_DEFAULTPET); + if(defpet==petsel){ + CHAR_setInt(talker,CHAR_DEFAULTPET,-1); + lssproto_KS_send( fd, -1, TRUE); + } + +#ifdef _PET_ITEM + CHAR_sendPetItemEmpty(talker,petsel); +#endif + + CHAR_setCharPet( talker, petsel, -1); + LogPet( + CHAR_getChar( talker, CHAR_NAME ), /* ƽҷ */ + CHAR_getChar( talker, CHAR_CDKEY ), + CHAR_getChar( petindex, CHAR_NAME), + CHAR_getInt( petindex, CHAR_LV), + "sell()", + CHAR_getInt( talker,CHAR_FLOOR), + CHAR_getInt( talker,CHAR_X ), + CHAR_getInt( talker,CHAR_Y ), + CHAR_getChar( petindex, CHAR_UNIQUECODE) // shan 2001/12/14 + ); + char tmpmsg[256]; + sprintf(tmpmsg,"ѳɹ%sLv %d",CHAR_getChar( petindex, CHAR_NAME),CHAR_getInt( petindex, CHAR_LV)); + CHAR_talkToCli(talker, -1, tmpmsg, CHAR_COLORYELLOW); + CHAR_endCharOneArray( petindex ); + + snprintf( szPet, sizeof( szPet ), "K%d", petsel); + CHAR_sendStatusString( talker, szPet ); + cost=NPC_GetCost(meindex,talker,petindex); + CHAR_AddGold( talker, cost); + +} +#endif +void NPC_PetDel2( int meindex, int talker, int select, char *token) +{ + int petindex; + int selectpet; + int emptyindex; + char szPet[128]; + int fd = getfdFromCharaIndex( talker ); + + if( fd == -1 ) { + fprint( "err\n"); + return; + } + // ʸ ʣʸ ľ + selectpet = CHAR_getWorkInt( talker, CHAR_WORKSHOPRELEVANT) -1; + petindex = CHAR_getCharPet( talker, selectpet); + + if( !CHAR_CHECKINDEX( petindex) ) return; + // Robin 0725 + if (CHAR_getInt( talker, CHAR_RIDEPET ) == selectpet ) + { +/* char buf[1024]; + lssproto_WN_send(fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + -1, -1, + makeEscapeString("\n\nеij޷ķร", buf, sizeof(buf))); +*/ + sprintf(token,"\n\nеij޷ķร"); + return; + } + + // ëʣƻƻ¼ƥݳƥлئмƾ + emptyindex = CHAR_getCharPoolPetElement( talker); + if( emptyindex == -1 ) { + fprint( "err\n"); + return; + } + + // ʸئգݹľ ëʣ + if( CHAR_getInt( talker, CHAR_DEFAULTPET) == selectpet) { + CHAR_setInt( talker, CHAR_DEFAULTPET, -1); + lssproto_KS_send( fd, -1, TRUE); + } + // ľ ʸ̼͵ë + CHAR_setCharPoolPet( talker, emptyindex, petindex); + // ʸ +#ifdef _PET_ITEM + CHAR_sendPetItemEmpty(talker,selectpet); +#endif + CHAR_setCharPet( talker, selectpet, -1); + + // + NPC_MaxGoldOver( meindex, talker, NPC_PETSHOP_MSG_POOLTHANKS, token); + // Ӽ + + CHAR_DelGold( talker, NPC_GETPOOLCOST( talker) ); + + // ŷ˪ + CHAR_send_P_StatusString(talker,CHAR_P_STRING_GOLD); + + snprintf( szPet, sizeof( szPet ), "K%d", selectpet); + // ޥʸ ˪Ի + CHAR_sendStatusString( talker, szPet ); + // ʸë ׷ + LogPet( + CHAR_getChar( talker, CHAR_NAME ), /* ƽҷ */ + CHAR_getChar( talker, CHAR_CDKEY ), + CHAR_getChar( petindex, CHAR_NAME), + CHAR_getInt( petindex, CHAR_LV), + "pool(ķų)", + CHAR_getInt( talker,CHAR_FLOOR), + CHAR_getInt( talker,CHAR_X ), + CHAR_getInt( talker,CHAR_Y ), + CHAR_getChar( petindex, CHAR_UNIQUECODE) // shan 2001/12/14 + ); + //fd = getfdFromCharaIndex( talker); + CHAR_charSaveFromConnect(talker, FALSE); + CHAR_talkToCli(talker, -1, "ϵͳΪԶ浵", CHAR_COLORRED); +} + +void NPC_PetDel3( int meindex, int talker, int select, char *token) +{ + int petindex; + int selectpet; + int emptyindex; + char szPet[128]; + int workindex[CHAR_MAXPOOLPETHAVE]; + int i; + int cnt; + + selectpet = CHAR_getWorkInt( talker, CHAR_WORKSHOPRELEVANT) ; + petindex = CHAR_getCharPoolPet( talker, selectpet); + + if( !CHAR_CHECKINDEX( petindex) ) return; + emptyindex = CHAR_getCharPetElement( talker); + if( emptyindex == -1 ) { + fprint( "err\n"); + return; + } + + // ػ޸Ϊͨ + if( CHAR_getInt( petindex, CHAR_PETFAMILY) == 1 + && CHAR_getInt( talker, CHAR_FMLEADERFLAG) != 3 ) { + CHAR_setInt( petindex, CHAR_PETFAMILY, 0); + CHAR_talkToCli( talker, -1, "ػ޸Ϊͨ", CHAR_COLORYELLOW); + } + + CHAR_setCharPet( talker, emptyindex, petindex); + CHAR_setCharPoolPet( talker, selectpet, -1); + NPC_MaxGoldOver( meindex, talker, NPC_PETSHOP_MSG_POOLTHANKS, token); +#ifdef _PET_ITEM + CHAR_sendPetItemData( talker, emptyindex); +#endif + snprintf( szPet, sizeof( szPet ), "K%d", emptyindex); + CHAR_sendStatusString( talker, szPet ); + snprintf( szPet, sizeof( szPet), "W%d",emptyindex); + CHAR_sendStatusString( talker, szPet ); + for( i = 0; i < CHAR_MAXPOOLPETHAVE; i ++ ) { + workindex[i] = -1; + } + cnt = 0; + for( i = 0; i < CHAR_MAXPOOLPETHAVE; i ++ ) { + int petindex = CHAR_getCharPoolPet( talker, i); + if( CHAR_CHECKINDEX( petindex) ) { + workindex[cnt++] = petindex; + } + } + for( i = 0; i < CHAR_MAXPOOLPETHAVE; i ++ ) { + CHAR_setCharPoolPet( talker, i, workindex[i]); + } +// LogPet( +// CHAR_getChar( talker, CHAR_NAME ), +// CHAR_getChar( talker, CHAR_CDKEY ), +// CHAR_getChar( petindex, CHAR_NAME), +// CHAR_getInt( petindex, CHAR_LV), +// "draw(ȡ)", +// CHAR_getInt( talker,CHAR_FLOOR), +// CHAR_getInt( talker,CHAR_X ), +// CHAR_getInt( talker,CHAR_Y ), +// CHAR_getChar( petindex, CHAR_UNIQUECODE) // shan 2001/12/14 +// ); +#ifdef _PET_EVOLUTION + if( CHAR_getInt( petindex, CHAR_FUSIONBEIT) == 1 && + CHAR_getInt( petindex, CHAR_FUSIONRAISE) > 0 ){//ǷΪںϳ + CHAR_setInt( petindex, CHAR_FUSIONTIMELIMIT, (int)time( NULL)); + } +#endif + //int fd = getfdFromCharaIndex( talker); + CHAR_charSaveFromConnect(talker, FALSE); + CHAR_talkToCli(talker, -1, "ϵͳΪԶ浵", CHAR_COLORRED); +} + +void NPC_getDrawPet( int meindex, int toindex, char *token, int *buttontype, int select) +{ + // ʸؤԻ + #define LINENUM 5 + char buf[1024]; + int i; + int startnum, endnum; + int petindex = -1; + // ػʸ + int page = CHAR_getWorkInt( toindex, CHAR_WORKSHOPRELEVANT); + int limit; + //andy_reEdit 2003/09/18 + limit = (CHAR_getInt(toindex,CHAR_TRANSMIGRATION)*2)+5; + + endnum = (page + select+1)*LINENUM ; + startnum = endnum - LINENUM; + *buttontype = WINDOW_BUTTONTYPE_CANCEL; + // ʸƩ + if( endnum >= limit ) { + endnum = limit; + if( page +select!= 0 ) *buttontype |= WINDOW_BUTTONTYPE_PREV; + } + else if( endnum <= LINENUM ) { + endnum = LINENUM; + *buttontype |= WINDOW_BUTTONTYPE_NEXT; + } + else { + *buttontype |= WINDOW_BUTTONTYPE_PREV | WINDOW_BUTTONTYPE_NEXT; + } + CHAR_setWorkInt( toindex, CHAR_WORKSHOPRELEVANT, page +select); + + strcpy( token, "2\nѡ\n\n"); + for( i = startnum; i < endnum; i ++ ) { + petindex = CHAR_getCharPoolPet( toindex, i); + if( CHAR_CHECKINDEX( petindex) ) { + snprintf( buf, sizeof( buf), "LV.%3d MaxHP %3d %s\n", + CHAR_getInt( petindex, CHAR_LV), + CHAR_getWorkInt( petindex, CHAR_WORKMAXHP), + CHAR_getUseName( petindex) + ); + } + else { + strcpy( buf, "\n"); + } + strcat( token, buf); + } + // ݼëƩͻ ݳʾë + if( i != limit ) { + petindex = CHAR_getCharPoolPet( toindex, i); + if( !CHAR_CHECKINDEX( petindex)) { + *buttontype &= ~WINDOW_BUTTONTYPE_NEXT; + } + } +} + +/* + *ŻְǷǷ + */ +void NPC_MaxGoldOver(int meindex,int toindex,int select,char *token) +{ + + char buf[1024]; + char npcarg[NPC_UTIL_GETARGSTR_BUFSIZE - 1024 * 20]; + + NPC_Util_GetArgStr( meindex, npcarg, sizeof(npcarg)); + + if( select < 0 || select >= arraysizeof( shopmsg)) return; + + if( NPC_Util_GetStrFromStrWithDelim( npcarg, shopmsg[select].option, buf, sizeof( buf)) == NULL ) + { + strcpy( buf, shopmsg[select].defaultmsg); + } + + snprintf(token,sizeof(buf),"\n\n%s",buf); + +} + +#ifdef _NPC_DEPOTPET +void NPC_PoolPetShop_DepotPet_Menu( int meindex, int talkerindex) +{ + int fd; + + //print(" NPC_PoolPetShop_DepotPet_Menu "); + + fd = getfdFromCharaIndex( talkerindex); + if( fd != -1 ) { + char message[1024]; + char buf[2048]; + + strcpy( message, + "3\n\n" + " رע⣺𽫹س빫ֿ\n﹫ֿ⡻\n" + " ų \n" + " ȡس \n" + ); + + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_SELECT, + WINDOW_BUTTONTYPE_CANCEL, + CHAR_WINDOWTYPE_DEPOTPETSHOP_HANDLE, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + makeEscapeString( message, buf, sizeof(buf))); + } +} + +void NPC_DepotPet_List( int meindex, int toindex, char *token, int *buttontype, int select) +{ + // ʸؤԻ + #define LINENUM 5 + char buf[1024]; + int i; + int startnum, endnum; + int petindex = -1; + // ػʸ + int page = CHAR_getWorkInt( toindex, CHAR_WORKSHOPRELEVANT); + int limit; + + limit = CHAR_MAXDEPOTPETHAVE; + + endnum = (page + select+1)*LINENUM ; + startnum = endnum - LINENUM; + *buttontype = WINDOW_BUTTONTYPE_CANCEL; + // ʸƩ + if( endnum >= limit ) { + endnum = limit; + if( page +select!= 0 ) *buttontype |= WINDOW_BUTTONTYPE_PREV; + } + else if( endnum <= LINENUM ) { + endnum = LINENUM; + *buttontype |= WINDOW_BUTTONTYPE_NEXT; + } + else { + *buttontype |= WINDOW_BUTTONTYPE_PREV | WINDOW_BUTTONTYPE_NEXT; + } + CHAR_setWorkInt( toindex, CHAR_WORKSHOPRELEVANT, page +select); + + strcpy( token, "2\nѡҪӲֿȡij\n\n"); + for( i = startnum; i < endnum; i ++ ) { + petindex = CHAR_getDepotPetIndex( toindex, i); + if( CHAR_CHECKINDEX( petindex) ) { + snprintf( buf, sizeof( buf), "LV.%3d MaxHP %3d %s\n", + CHAR_getInt( petindex, CHAR_LV), + CHAR_getWorkInt( petindex, CHAR_WORKMAXHP), + CHAR_getUseName( petindex) + ); + } + else { + strcpy( buf, "\n"); + } + strcat( token, buf); + } + // ݼëƩͻ ݳʾë + if( i != limit ) { + petindex = CHAR_getDepotPetIndex( toindex, i); + if( !CHAR_CHECKINDEX( petindex)) { + *buttontype &= ~WINDOW_BUTTONTYPE_NEXT; + } + } + //print("\n DepotPet_List:%s ", token); +} + + +void NPC_DepotPet_Add( int meindex, int talker, int select, char *token) +{ + + int petindex; + int selectpet; + int emptyindex; + char szPet[128]; + int fd = getfdFromCharaIndex( talker ); + + if( fd == -1 ) { + fprint( "err\n"); + return; + } + // ʸ ʣʸ ľ + selectpet = CHAR_getWorkInt( talker, CHAR_WORKSHOPRELEVANT) -1; + //print("\n selectpet:%d ", selectpet); + petindex = CHAR_getCharPet( talker, selectpet); + if( !CHAR_CHECKINDEX( petindex) ) return; + + // Robin 0725 + if (CHAR_getInt( talker, CHAR_RIDEPET ) == selectpet ) + { + sprintf(token,"\n\nеij޷ֿร"); + return; + } + + if( CHAR_getInt( petindex, CHAR_PETFAMILY) == 1 ) + { + sprintf(token,"\n\nػ޷ֿร"); + return; + } + // ëʣƻƻ¼ƥݳƥлئмƾ + emptyindex = CHAR_getCharDepotPetElement( talker); + if( emptyindex == -1 ) { + fprint( "err\n"); + return; + } + + // ʸئգݹľ ëʣ + if( CHAR_getInt( talker, CHAR_DEFAULTPET) == selectpet) { + CHAR_setInt( talker, CHAR_DEFAULTPET, -1); + lssproto_KS_send( fd, -1, TRUE); + } + // ľ ʸ̼͵ë + CHAR_setDepotPetIndex( talker, emptyindex, petindex); + // ʸ + CHAR_setCharPet( talker, selectpet, -1); + + // + NPC_MaxGoldOver( meindex, talker, NPC_PETSHOP_MSG_POOLTHANKS, token); + // Ӽ + + CHAR_DelGold( talker, NPC_GETPOOLCOST( talker) ); + + // ŷ˪ + CHAR_send_P_StatusString(talker,CHAR_P_STRING_GOLD); + + snprintf( szPet, sizeof( szPet ), "K%d", selectpet); + // ޥʸ ˪Ի + CHAR_sendStatusString( talker, szPet ); + // ʸë ׷ +#ifdef _CHECK_PEPEAT + if( getCheckRepeat()==1 || NPC_DepotPet_CheckRepeat( talker) == 0) // ظ +#else + if( NPC_DepotPet_CheckRepeat( talker) == 0) // ظ +#endif + { +// LogPet( +// CHAR_getChar( talker, CHAR_NAME ), /* ƽҷ */ +// CHAR_getChar( talker, CHAR_CDKEY ), +// CHAR_getChar( petindex, CHAR_NAME), +// CHAR_getInt( petindex, CHAR_LV), +// "pool(ֿ)", +// CHAR_getInt( talker,CHAR_FLOOR), +// CHAR_getInt( talker,CHAR_X ), +// CHAR_getInt( talker,CHAR_Y ), +// CHAR_getChar( petindex, CHAR_UNIQUECODE) // shan 2001/12/14 +// ); + } + else + { + CHAR_talkToCli( talker, -1, "ǷǷij!!", CHAR_COLORYELLOW); + } + //fd = getfdFromCharaIndex( talker); + CHAR_charSaveFromConnect(talker, FALSE); + CHAR_talkToCli(talker, -1, "ϵͳΪԶ浵", CHAR_COLORRED); +} + + + +void NPC_DepotPet_Get( int meindex, int talker, int select, char *token) +{ + int petindex; + int selectpet; + int emptyindex; + char szPet[128]; + int workindex[CHAR_MAXDEPOTPETHAVE]; + int i; + int cnt; + + selectpet = CHAR_getWorkInt( talker, CHAR_WORKSHOPRELEVANT) ; + petindex = CHAR_getDepotPetIndex( talker, selectpet); + if( !CHAR_CHECKINDEX( petindex) ) return; + emptyindex = CHAR_getCharPetElement( talker); + if( emptyindex == -1 ) { + fprint( "err\n"); + return; + } +/* + if(CHAR_getInt(petindex,CHAR_BEATITUDE)>0 && strstr(CHAR_getChar(petindex,CHAR_NAME),"+")==NULL){ + char btmpname[128]; + sprintf(btmpname,"%s+",CHAR_getChar(petindex,CHAR_NAME)); + CHAR_setChar(petindex,CHAR_NAME,btmpname); + } +*/ +#ifdef _JK_CF_DELPETITEM //ɾCFָ + int ID1,ID2,j; + char* delbuf; + char delpetbuf[10]; + delbuf = getDelPet(); + ID1=CHAR_getInt( petindex, CHAR_PETID); + for( j=1;j<=30;j++ ) { + if(getStringFromIndexWithDelim(delbuf,",", j, delpetbuf, sizeof(delpetbuf)) == FALSE) + break; + ID2 = atoi(delpetbuf); + if(ID2 == -1)break; + if( ID1 == ID2){ + CHAR_setDepotPetIndex( talker, selectpet, -1);//ܵĽɫ + LogPet( CHAR_getChar( talker, CHAR_NAME ), + CHAR_getChar( talker, CHAR_CDKEY ), + CHAR_getChar( petindex, CHAR_NAME), + CHAR_getInt( petindex, CHAR_LV), + "petshop(CFõij)", + CHAR_getInt( talker,CHAR_FLOOR), + CHAR_getInt( talker,CHAR_X ), + CHAR_getInt( talker,CHAR_Y ), + CHAR_getChar( petindex, CHAR_UNIQUECODE) + ); + CHAR_talkToCli(talker,-1,"ϵͳֿij",CHAR_COLORWHITE); + goto petshopOut; + } + } +#endif + CHAR_setCharPet( talker, emptyindex, petindex); + CHAR_setChar( petindex, CHAR_OWNERCHARANAME, CHAR_getChar( talker, CHAR_NAME)); + CHAR_setDepotPetIndex( talker, selectpet, -1); + NPC_MaxGoldOver( meindex, talker, NPC_PETSHOP_MSG_POOLTHANKS, token); + snprintf( szPet, sizeof( szPet ), "K%d", emptyindex); + CHAR_sendStatusString( talker, szPet ); + snprintf( szPet, sizeof( szPet), "W%d",emptyindex); + CHAR_sendStatusString( talker, szPet ); + for( i = 0; i < CHAR_MAXDEPOTPETHAVE; i ++ ) { + workindex[i] = -1; + } + cnt = 0; + for( i = 0; i < CHAR_MAXDEPOTPETHAVE; i ++ ) { + int petindex = CHAR_getDepotPetIndex( talker, i); + if( CHAR_CHECKINDEX( petindex) ) { + workindex[cnt++] = petindex; + } + } + for( i = 0; i < CHAR_MAXDEPOTPETHAVE; i ++ ) { + CHAR_setDepotPetIndex( talker, i, workindex[i]); + } + LogPet( + CHAR_getChar( talker, CHAR_NAME ), + CHAR_getChar( talker, CHAR_CDKEY ), + CHAR_getChar( petindex, CHAR_NAME), + CHAR_getInt( petindex, CHAR_LV), + "draw(ȡֿ)", + CHAR_getInt( talker,CHAR_FLOOR), + CHAR_getInt( talker,CHAR_X ), + CHAR_getInt( talker,CHAR_Y ), + CHAR_getChar( petindex, CHAR_UNIQUECODE) // shan 2001/12/14 + ); + //int fd = getfdFromCharaIndex( talker); + CHAR_charSaveFromConnect(talker, FALSE); + CHAR_talkToCli(talker, -1, "ϵͳΪԶ浵", CHAR_COLORRED); +petshopOut: +#ifdef _PET_EVOLUTION + if( CHAR_getInt( petindex, CHAR_FUSIONBEIT) == 1 && + CHAR_getInt( petindex, CHAR_FUSIONRAISE) > 0 ){//ǷΪںϳ + CHAR_setInt( petindex, CHAR_FUSIONTIMELIMIT, (int)time( NULL)); + } +#endif +} + +void NPC_DepotPet_AskGet(int meindex,int talker,int select,char *token) +{ + int depotindex; + int petindex; + char *petname; + depotindex = CHAR_getWorkInt( talker, CHAR_WORKSHOPRELEVANT) * 5 + select - 1; + CHAR_setWorkInt(talker,CHAR_WORKSHOPRELEVANT,depotindex ); + petindex = CHAR_getDepotPetIndex( talker, depotindex); + if( !CHAR_CHECKINDEX(petindex) ) return; + petname = CHAR_getUseName( petindex); + sprintf(token,"\n[%s]", petname); +} + +int NPC_DepotPet_CheckRepeat( int charaindex) +{ + int petindex1, petindex2; + int i, j, find, ret = FALSE; + int workindex[CHAR_MAXDEPOTPETHAVE], cnt =0; + + for( i =0; i <(CHAR_MAXDEPOTPETHAVE-1); i++) + { + petindex1 = CHAR_getDepotPetIndex( charaindex, i); + if( !CHAR_CHECKINDEX( petindex1)) continue; + find = 0; + for( j =(i+1); j 0) + { + CHAR_setDepotPetIndex( charaindex, i, -1); + NPC_DepotPet_CheckRepeat_del( charaindex, petindex1); + } + } + + for( i = 0; i < CHAR_MAXDEPOTPETHAVE; i ++ ) { + workindex[i] = -1; + } + for( i = 0; i < CHAR_MAXDEPOTPETHAVE; i ++ ) { + int pindex = CHAR_getDepotPetIndex( charaindex, i); + if( CHAR_CHECKINDEX( pindex) ) { + workindex[cnt++] = pindex; + } + } + for( i = 0; i < CHAR_MAXDEPOTPETHAVE; i ++ ) { + CHAR_setDepotPetIndex( charaindex, i, workindex[i]); + } + + return ret; +} + +void NPC_DepotPet_CheckRepeat_del( int charaindex, int petindex) +{ + LogPet( + CHAR_getChar( charaindex, CHAR_NAME ), /* ƽҷ */ + CHAR_getChar( charaindex, CHAR_CDKEY ), + CHAR_getChar( petindex, CHAR_NAME), + CHAR_getInt( petindex, CHAR_LV), + "del(ֿϴ)", + CHAR_getInt( charaindex,CHAR_FLOOR), + CHAR_getInt( charaindex,CHAR_X ), + CHAR_getInt( charaindex,CHAR_Y ), + CHAR_getChar( petindex, CHAR_UNIQUECODE) // shan 2001/12/14 + ); + CHAR_endCharOneArray( petindex ); +} + +// ȼǷ㹻 +int NPC_DepotPet_CheckLevel(int meindex,int talker,int select,char *token) +{ + int petindex; + int selectpet; + + if( !CHAR_CheckDepotPet( talker) ) + return FALSE; + + selectpet = CHAR_getWorkInt( talker, CHAR_WORKSHOPRELEVANT) ; + petindex = CHAR_getDepotPetIndex( talker, selectpet); + if( !CHAR_CHECKINDEX(petindex) ) return FALSE; + + //print("\n trans:%d char_lv:%d pet_lv:%d ", + // CHAR_getInt( talker, CHAR_TRANSMIGRATION), + // CHAR_getInt( talker, CHAR_LV), + // CHAR_getInt( petindex, CHAR_LV) ); + + // ػ޸Ϊͨ + if( CHAR_getInt( petindex, CHAR_PETFAMILY) == 1 + && CHAR_getInt( talker, CHAR_FMLEADERFLAG) != 3 ) { + CHAR_setInt( petindex, CHAR_PETFAMILY, 0); + } + + if( CHAR_getWorkInt( talker, CHAR_PickAllPet) == TRUE ) { // װѱ޽ָĻ... + return TRUE; + } + + if( CHAR_getInt( talker, CHAR_TRANSMIGRATION) > 0 + || CHAR_getInt( talker, CHAR_LV)+5 >= CHAR_getInt( petindex, CHAR_LV) ) { + return TRUE; + } + + return FALSE; + +} + +#endif + diff --git a/npc/npc_petskilldelshop.c b/npc/npc_petskilldelshop.c new file mode 100644 index 0000000..3cdeb1b --- /dev/null +++ b/npc/npc_petskilldelshop.c @@ -0,0 +1,276 @@ +#include "version.h" +#include +#include "char.h" +#include "object.h" +#include "char_base.h" +#include "npcutil.h" +#include "lssproto_serv.h" +#include "pet_skill.h" +#include "readmap.h" +#include "battle.h" +#ifdef _ALLBLUES_LUA +#include "mylua/function.h" +#endif + +#ifdef _PETSKILL_DEL_NPC +enum { + CHAR_WORK_STONESELECT = CHAR_NPCWORKINT1, +}; + +static void NPC_PetSkillDelShop_selectWindow( int meindex, int toindex, int num,int select); +BOOL NPC_PetSkillDelMakeStr(int meindex,int toindex,int select); + +BOOL NPC_PetSkillDelShopInit( int meindex ) +{ + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + char msg[256]; + + CHAR_setInt( meindex , CHAR_WHICHTYPE , CHAR_TYPESTONESHOP ); + if(NPC_Util_GetArgStr( meindex, argstr, sizeof(argstr))==NULL){ + print("GetArgStrErr"); + return FALSE; + } + if( NPC_Util_GetStrFromStrWithDelim( argstr, "pet_skill", msg, sizeof( msg)) != NULL){ + char buf[256], filename[256]; + int k=1, skillID, skillarray; + while( getStringFromIndexWithDelim( msg, ",", k, buf, sizeof( buf) ) ){ + k++; + skillID=atoi(buf); + skillarray = PETSKILL_getPetskillArray( skillID); + if( PETSKILL_CHECKINDEX( skillarray) == FALSE ) continue; + if( PETSKILL_getInt( skillarray, PETSKILL_ILLEGAL) == 1){ + if( NPC_Util_CheckAssignArgFile( meindex, filename) != NULL ){ + print("PetSkillShop illegal skill:[%d-%s] ->file:%s", + skillID, + PETSKILL_getChar( skillarray, PETSKILL_NAME), + filename ); + } + } + } + }else{ + return FALSE; + } + + return TRUE; +} + +void NPC_PetSkillDelShopTalked( int meindex , int talkerindex , char *szMes ,int color ) +{ + if( CHAR_getInt( talkerindex , CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER ) { + return; + } + if(NPC_Util_isFaceToFace(talkerindex,meindex,2 )==FALSE){ + if( NPC_Util_CharDistance( talkerindex, meindex ) > 1) return; + } + NPC_PetSkillDelShop_selectWindow( meindex, talkerindex,0,-1); +} + +void NPC_PetSkillDelShopLooked( int meindex , int lookedindex) +{ + if( CHAR_getInt( lookedindex , CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER ) { + return; + } + if( NPC_Util_CharDistance( lookedindex, meindex ) > 2) return; +} + +static void NPC_PetSkillDelShop_selectWindow( int meindex, int toindex, int num,int select) +{ + switch(num){ + case 0: + NPC_PetSkillDelMakeStr(meindex,toindex,select); + break; + case 1: + break; + } +} + +void NPC_PetSkillDelShopWindowTalked( int meindex, int talkerindex, + int seqno, int select, char *data) +{ + int skill; + int pet; + int slot; + int cost; + int skillID=0; + int skillitem=-1; + int petskillindex; + char buf[64]; + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + char msg[512]; + int petindex; + char msgbuf[128]; + int fd = getfdFromCharaIndex( talkerindex ); + double rate= 1.0; + + if( NPC_Util_CharDistance( talkerindex, meindex ) > 2) { + return; + } + + if(NPC_Util_GetArgStr( meindex, argstr, sizeof(argstr))==NULL){ + print("GetArgStrErr"); + return; + } + makeStringFromEscaped( data); + getStringFromIndexWithDelim(data,"|",1,buf,sizeof(buf)); + skill=atoi(buf); + getStringFromIndexWithDelim(data,"|",2,buf,sizeof(buf)); + pet=atoi(buf); + getStringFromIndexWithDelim(data,"|",3,buf,sizeof(buf)); + slot=atoi(buf); + getStringFromIndexWithDelim(data,"|",4,buf,sizeof(buf)); + cost=atoi(buf); + + if( NPC_Util_GetStrFromStrWithDelim( argstr, "pet_skill", msg, sizeof( msg)) != NULL){ + getStringFromIndexWithDelim(msg,",",skill,buf,sizeof(buf)); + skillID=atoi(buf); + } + if( NPC_Util_GetStrFromStrWithDelim( argstr, "skill_item", msg, sizeof( msg)) != NULL){ + getStringFromIndexWithDelim(msg,",",skill,buf,sizeof(buf)); + skillitem=atoi(buf); + } + + slot--; + if( !CHAR_CHECKPETSKILLINDEX( slot)){ + CHAR_send_P_StatusString( talkerindex, CHAR_P_STRING_GOLD); + return ; + } + petindex = CHAR_getCharPet( talkerindex, pet-1); + if( !CHAR_CHECKINDEX(petindex) ){ + CHAR_send_P_StatusString( talkerindex, CHAR_P_STRING_GOLD); + return ; + } + if(skillID < 0 || skillitem<0) return ; + + if(petindex == -1){ + print("petskillshop.c:170 PetindexError"); + return; + } + + if( CHAR_getWorkInt( CONNECT_getCharaindex(fd), + CHAR_WORKBATTLEMODE) != BATTLE_CHARMODE_NONE) return ; + + petskillindex = PETSKILL_getPetskillArray( skillID ); + if(petskillindex == -1){ + CHAR_send_P_StatusString( talkerindex, CHAR_P_STRING_GOLD); + return ; + } + + if( NPC_Util_GetStrFromStrWithDelim( argstr, "costvigor", msg, sizeof( msg)) != NULL){ + getStringFromIndexWithDelim(msg,",",skill,buf,sizeof(buf)); + cost=atoi(buf); + } + + if(CHAR_getInt(talkerindex,CHAR_VIGOR) < cost){ + CHAR_send_P_StatusString( talkerindex, CHAR_P_STRING_GOLD); + CHAR_talkToCli( talkerindex, -1, "Ļ" , CHAR_COLORRED); + return; + } + if(CHAR_getPetSkill( petindex, slot)!=skillID) return; + int emptyitemindexinchara; + emptyitemindexinchara = CHAR_findEmptyItemBox( talkerindex ); + + if( emptyitemindexinchara < 0 ){ + + CHAR_talkToCli( talkerindex, -1, "Ʒλ㡣" , CHAR_COLORYELLOW); + + return; + } + int itemindex = ITEM_makeItemAndRegist( skillitem ); + if( itemindex != -1 ){ + CHAR_setItemIndex( talkerindex, emptyitemindexinchara, itemindex ); + ITEM_setWorkInt(itemindex, ITEM_WORKOBJINDEX,-1); + ITEM_setWorkInt(itemindex, ITEM_WORKCHARAINDEX,talkerindex); + CHAR_sendItemDataOne( talkerindex, emptyitemindexinchara); + }else return; + CHAR_setPetSkill( petindex, slot, -1); + + CHAR_setInt( talkerindex, CHAR_VIGOR, CHAR_getInt( talkerindex, CHAR_VIGOR ) - cost ); + sprintf(msgbuf,"۳%dõ<%s>",cost,ITEM_getNameFromNumber( skillitem)); + CHAR_talkToCli( talkerindex, -1, msgbuf, CHAR_COLORYELLOW); + + snprintf( msgbuf, sizeof( msgbuf ), "W%d",pet-1); + CHAR_sendStatusString( talkerindex, msgbuf ); + CHAR_sendStatusString( talkerindex, "P"); + NPC_PetSkillDelShop_selectWindow( meindex, talkerindex,0,-1); +} + +BOOL NPC_PetSkillDelMakeStr(int meindex,int toindex,int select) +{ + + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + char msg[256]; + char msg1[256]; + double rate=1.0; + int i=0; + char token[NPC_UTIL_GETARGSTR_LINEMAX]; + int fd = getfdFromCharaIndex( toindex); + + if(select==0){ + sprintf(token,"0|0"); + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_PETSKILLSHOP, + WINDOW_BUTTONTYPE_NONE, + CHAR_WINDOWTYPE_WINDOWPETSKILLSHOP, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + token); + + } + + if(NPC_Util_GetArgStr( meindex, argstr, sizeof(argstr))==NULL){ + print("GetArgStrErr"); + return FALSE; + } + + if( NPC_Util_GetStrFromStrWithDelim( argstr, "main_msg", msg, sizeof( msg)) == NULL){ + print("mainERR"); + return FALSE; + } + + sprintf(token,"1|%s|%s", + CHAR_getChar(meindex,CHAR_NAME),msg); + + if( NPC_Util_GetStrFromStrWithDelim( argstr, "skill_rate", msg, sizeof( msg)) != NULL){ + rate=atof(msg); + } + + + if( NPC_Util_GetStrFromStrWithDelim( argstr, "pet_skill", msg, sizeof( msg) ) != NULL){ + int skillarray; + int skillID; + int cost; + char token2[265]; + char buf[64]; + + i=1; + while( getStringFromIndexWithDelim(msg,",",i,buf,sizeof(buf)) !=FALSE ){ + i++; + skillID=atoi(buf); + skillarray = PETSKILL_getPetskillArray( skillID); + + if( PETSKILL_CHECKINDEX( skillarray) == FALSE ) + continue; + if( PETSKILL_getInt( skillarray, PETSKILL_ILLEGAL) == 1) continue; + if( NPC_Util_GetStrFromStrWithDelim( argstr, "costvigor", msg1, sizeof( msg1) ) != NULL){ + getStringFromIndexWithDelim(msg1,",",i-1,buf,sizeof(buf)); + cost = atoi(buf); + }else{ + cost = PETSKILL_getInt(skillarray,PETSKILL_COST); + cost = (int)cost*rate; + } +#ifdef _SA80 + sprintf(token2,"|%s|%d|%s|0", PETSKILL_getChar(skillarray, PETSKILL_NAME), + cost, PETSKILL_getChar(skillarray, PETSKILL_COMMENT)); +#else + sprintf(token2,"|%s|%d|%s", PETSKILL_getChar(skillarray, PETSKILL_NAME), + cost, PETSKILL_getChar(skillarray, PETSKILL_COMMENT)); +#endif + strcat(token,token2); + } + } + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_PETSKILLSHOP, + WINDOW_BUTTONTYPE_NONE, + CHAR_WINDOWTYPE_WINDOWPETSKILLSHOP, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + token); + return TRUE; +} +#endif diff --git a/npc/npc_petskillshop.c b/npc/npc_petskillshop.c new file mode 100644 index 0000000..51a5db7 --- /dev/null +++ b/npc/npc_petskillshop.c @@ -0,0 +1,249 @@ +#include "version.h" +#include +#include "char.h" +#include "object.h" +#include "char_base.h" +#include "npcutil.h" +#include "lssproto_serv.h" +#include "pet_skill.h" +#include "readmap.h" +#include "battle.h" +#ifdef _ALLBLUES_LUA +#include "mylua/function.h" +#endif +enum { + CHAR_WORK_STONESELECT = CHAR_NPCWORKINT1, +}; + +static void NPC_PetSkillShop_selectWindow( int meindex, int toindex, int num,int select); +BOOL NPC_PetSkillMakeStr(int meindex,int toindex,int select); + +BOOL NPC_PetSkillShopInit( int meindex ) +{ + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + char msg[256]; + + CHAR_setInt( meindex , CHAR_WHICHTYPE , CHAR_TYPESTONESHOP ); + if(NPC_Util_GetArgStr( meindex, argstr, sizeof(argstr))==NULL){ + print("GetArgStrErr"); + return FALSE; + } + if( NPC_Util_GetStrFromStrWithDelim( argstr, "pet_skill", msg, sizeof( msg)) != NULL){ + char buf[256], filename[256]; + int k=1, skillID, skillarray; + while( getStringFromIndexWithDelim( msg, ",", k, buf, sizeof( buf) ) ){ + k++; + skillID=atoi(buf); + skillarray = PETSKILL_getPetskillArray( skillID); + if( PETSKILL_CHECKINDEX( skillarray) == FALSE ) continue; + if( PETSKILL_getInt( skillarray, PETSKILL_ILLEGAL) == 1){ + if( NPC_Util_CheckAssignArgFile( meindex, filename) != NULL ){ + print("PetSkillShop illegal skill:[%d-%s] ->file:%s", + skillID, + PETSKILL_getChar( skillarray, PETSKILL_NAME), + filename ); + } + } + } + }else{ + return FALSE; + } + + return TRUE; +} + +void NPC_PetSkillShopTalked( int meindex , int talkerindex , char *szMes ,int color ) +{ + if( CHAR_getInt( talkerindex , CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER ) { + return; + } + if(NPC_Util_isFaceToFace(talkerindex,meindex,2 )==FALSE){ + if( NPC_Util_CharDistance( talkerindex, meindex ) > 1) return; + } + NPC_PetSkillShop_selectWindow( meindex, talkerindex,0,-1); +} + +void NPC_PetSkillShopLooked( int meindex , int lookedindex) +{ + if( CHAR_getInt( lookedindex , CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER ) { + return; + } + if( NPC_Util_CharDistance( lookedindex, meindex ) > 2) return; +} + +static void NPC_PetSkillShop_selectWindow( int meindex, int toindex, int num,int select) +{ + switch(num){ + case 0: + NPC_PetSkillMakeStr(meindex,toindex,select); + break; + case 1: + break; + } +} + +void NPC_PetSkillShopWindowTalked( int meindex, int talkerindex, + int seqno, int select, char *data) +{ + int skill; + int pet; + int slot; + int cost; + int skillID=0; + int petskillindex; + char buf[64]; + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + char msg[512]; + int petindex; + char msgbuf[128]; + int fd = getfdFromCharaIndex( talkerindex ); + double rate= 1.0; + + if( NPC_Util_CharDistance( talkerindex, meindex ) > 2) { + return; + } + + if(NPC_Util_GetArgStr( meindex, argstr, sizeof(argstr))==NULL){ + print("GetArgStrErr"); + return; + } + makeStringFromEscaped( data); + getStringFromIndexWithDelim(data,"|",1,buf,sizeof(buf)); + skill=atoi(buf); + getStringFromIndexWithDelim(data,"|",2,buf,sizeof(buf)); + pet=atoi(buf); + getStringFromIndexWithDelim(data,"|",3,buf,sizeof(buf)); + slot=atoi(buf); + getStringFromIndexWithDelim(data,"|",4,buf,sizeof(buf)); + cost=atoi(buf); + + if( NPC_Util_GetStrFromStrWithDelim( argstr, "pet_skill", msg, sizeof( msg)) != NULL){ + getStringFromIndexWithDelim(msg,",",skill,buf,sizeof(buf)); + skillID=atoi(buf); + } + + slot--; + if( !CHAR_CHECKPETSKILLINDEX( slot)){ + CHAR_send_P_StatusString( talkerindex, CHAR_P_STRING_GOLD); + return ; + } + petindex = CHAR_getCharPet( talkerindex, pet-1); + if( !CHAR_CHECKINDEX(petindex) ){ + CHAR_send_P_StatusString( talkerindex, CHAR_P_STRING_GOLD); + return ; + } + if(skillID < 0) return ; + + if(petindex == -1){ + print("petskillshop.c:170 PetindexError"); + return; + } + + if( CHAR_getWorkInt( CONNECT_getCharaindex(fd), + CHAR_WORKBATTLEMODE) != BATTLE_CHARMODE_NONE) return ; + if( NPC_Util_GetStrFromStrWithDelim( argstr, "skill_rate", msg, sizeof( msg)) != NULL){ + rate = atof( msg); + } + + petskillindex = PETSKILL_getPetskillArray( skillID ); + if(petskillindex == -1){ + CHAR_send_P_StatusString( talkerindex, CHAR_P_STRING_GOLD); + return ; + } + + cost = PETSKILL_getInt( petskillindex, PETSKILL_COST ); + cost = cost * rate; + + if(CHAR_getInt(talkerindex,CHAR_GOLD) < cost){ + CHAR_send_P_StatusString( talkerindex, CHAR_P_STRING_GOLD); + return; + } +#ifdef _PETSKILL_SHOP_LUA + if(FreePetSkillShop(talkerindex, petindex, CHAR_getPetSkill(petindex, slot), skillID) == FALSE ) { + return; + } +#endif + CHAR_setPetSkill( petindex, slot, skillID); + CHAR_complianceParameter(petindex); + CHAR_DelGold( talkerindex, cost ); + + snprintf( msgbuf, sizeof( msgbuf ), "W%d",pet-1); + CHAR_sendStatusString( talkerindex, msgbuf ); + CHAR_sendStatusString( talkerindex, "P"); + NPC_PetSkillShop_selectWindow( meindex, talkerindex,0,-1); +} + +BOOL NPC_PetSkillMakeStr(int meindex,int toindex,int select) +{ + + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + char msg[256]; + double rate=1.0; + int i=0; + char token[NPC_UTIL_GETARGSTR_LINEMAX]; + int fd = getfdFromCharaIndex( toindex); + + if(select==0){ + sprintf(token,"0|0"); + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_PETSKILLSHOP, + WINDOW_BUTTONTYPE_NONE, + CHAR_WINDOWTYPE_WINDOWPETSKILLSHOP, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + token); + + } + + if(NPC_Util_GetArgStr( meindex, argstr, sizeof(argstr))==NULL){ + print("GetArgStrErr"); + return FALSE; + } + + if( NPC_Util_GetStrFromStrWithDelim( argstr, "main_msg", msg, sizeof( msg)) == NULL){ + print("mainERR"); + return FALSE; + } + + sprintf(token,"1|%s|%s", + CHAR_getChar(meindex,CHAR_NAME),msg); + + if( NPC_Util_GetStrFromStrWithDelim( argstr, "skill_rate", msg, sizeof( msg)) != NULL){ + rate=atof(msg); + } + + + if( NPC_Util_GetStrFromStrWithDelim( argstr, "pet_skill", msg, sizeof( msg) ) != NULL){ + int skillarray; + int skillID; + int cost; + char token2[265]; + char buf[64]; + + i=1; + while( getStringFromIndexWithDelim(msg,",",i,buf,sizeof(buf)) !=FALSE ){ + i++; + skillID=atoi(buf); + skillarray = PETSKILL_getPetskillArray( skillID); + + if( PETSKILL_CHECKINDEX( skillarray) == FALSE ) + continue; + if( PETSKILL_getInt( skillarray, PETSKILL_ILLEGAL) == 1) continue; + cost = PETSKILL_getInt(skillarray,PETSKILL_COST); + cost = (int)cost*rate; +#ifdef _SA80 + sprintf(token2,"|%s|%d|%s|0", PETSKILL_getChar(skillarray, PETSKILL_NAME), + cost, PETSKILL_getChar(skillarray, PETSKILL_COMMENT)); +#else + sprintf(token2,"|%s|%d|%s", PETSKILL_getChar(skillarray, PETSKILL_NAME), + cost, PETSKILL_getChar(skillarray, PETSKILL_COMMENT)); +#endif + strcat(token,token2); + } + } + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_PETSKILLSHOP, + WINDOW_BUTTONTYPE_NONE, + CHAR_WINDOWTYPE_WINDOWPETSKILLSHOP, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + token); + return TRUE; +} + diff --git a/npc/npc_pkpetshop.c b/npc/npc_pkpetshop.c new file mode 100644 index 0000000..c53b481 --- /dev/null +++ b/npc/npc_pkpetshop.c @@ -0,0 +1,61 @@ +0038:npc_poolitemshop.c:0702B:1:14=48041e4b:16=47d21313:#include "version.h" + +#include "char.h" +#include "lssproto_serv.h" +#include "npcutil.h" +#include "npc_poolitemshop.h" +#include "log.h" +#include "handletime.h" + +#define NPC_POOLITEMSHOP_DEFAULT_COST 200 + +enum { + NPC_WORK_COST = CHAR_NPCWORKINT1, + NPC_WORK_CURRENTTIME = CHAR_NPCWORKINT9, +}; + +enum { + NPC_POOLITEMSHOP_MSG_MAIN=0, + NPC_POOLITEMSHOP_MSG_POOL, + NPC_POOLITEMSHOP_MSG_DRAW, + NPC_POOLITEMSHOP_MSG_REALY, + NPC_POOLITEMSHOP_MSG_STONE, + NPC_POOLITEMSHOP_MSG_POOLFULL, + NPC_POOLITEMSHOP_MSG_ITEMFULL, + + CHAR_WINDOWTYPE_POOLITEMSHOP_START = 290, + CHAR_WINDOWTYPE_POOLITEMSHOP_POOL_MSG, + CHAR_WINDOWTYPE_POOLITEMSHOP_DRAW_MSG, + CHAR_WINDOWTYPE_POOLITEMSHOP_FULL_MSG, + CHAR_WINDOWTYPE_POOLITEMSHOP_HAVEITEMFULL_MSG, + CHAR_WINDOWTYPE_POOLITEMSHOP_END, + +#ifdef _NPC_DEPOTITEM + CHAR_WINDOWTYPE_DEPOTITEMSHOP_MENU = 310, + CHAR_WINDOWTYPE_DEPOTITEMSHOP_HANDLE, + CHAR_WINDOWTYPE_DEPOTITEMSHOP_ADD, + CHAR_WINDOWTYPE_DEPOTITEMSHOP_GET, +#endif +}; + +typedef struct { + char option[32]; + char defaultmsg[128]; +}NPC_POOLITEMSHOP_MSG; + +NPC_POOLITEMSHOP_MSG poolshopmsg[] = { + { "main_msg", "ӭ"}, + { "pool_main", "Ҫķʲ"}, + { "draw_main", "Ҫʲ"}, + { "realy_msg", "ҪǸ"}, + { "stone_msg", "Ǯ!"}, + { "poolfull_msg", "޷"}, + { "itemfull_msg", "Ŀкܶ"} +}; + +static BOOL NPC_PoolItemShop_DrawItem( int meindex, int talkerindex, int num); +static BOOL NPC_PoolItemShop_PoolItem( int meindex, int talkerindex, int num); +static void NPC_PoolItemShop_MakeItemString_Draw( int meindex, int talkerindex, + char *retstring,int retstringlen); +static void NPC_PoolItemShop_MakeItemString_Pool( int meindex, int talkerindex, + char *retstr \ No newline at end of file diff --git a/npc/npc_poolitemshop.c b/npc/npc_poolitemshop.c new file mode 100644 index 0000000..df4150c --- /dev/null +++ b/npc/npc_poolitemshop.c @@ -0,0 +1,1106 @@ +#include "version.h" + +#include "char.h" +#include "lssproto_serv.h" +#include "npcutil.h" +#include "npc_poolitemshop.h" +#include "log.h" +#include "handletime.h" + +#define NPC_POOLITEMSHOP_DEFAULT_COST 200 + +enum { + NPC_WORK_COST = CHAR_NPCWORKINT1, + NPC_WORK_CURRENTTIME = CHAR_NPCWORKINT9, +}; + +enum { + NPC_POOLITEMSHOP_MSG_MAIN=0, + NPC_POOLITEMSHOP_MSG_POOL, + NPC_POOLITEMSHOP_MSG_DRAW, + NPC_POOLITEMSHOP_MSG_REALY, + NPC_POOLITEMSHOP_MSG_STONE, + NPC_POOLITEMSHOP_MSG_POOLFULL, + NPC_POOLITEMSHOP_MSG_ITEMFULL, + + CHAR_WINDOWTYPE_POOLITEMSHOP_START = 290, + CHAR_WINDOWTYPE_POOLITEMSHOP_POOL_MSG, + CHAR_WINDOWTYPE_POOLITEMSHOP_DRAW_MSG, + CHAR_WINDOWTYPE_POOLITEMSHOP_FULL_MSG, + CHAR_WINDOWTYPE_POOLITEMSHOP_HAVEITEMFULL_MSG, + CHAR_WINDOWTYPE_POOLITEMSHOP_END, + +#ifdef _NPC_DEPOTITEM + CHAR_WINDOWTYPE_DEPOTITEMSHOP_MENU = 310, + CHAR_WINDOWTYPE_DEPOTITEMSHOP_HANDLE, + CHAR_WINDOWTYPE_DEPOTITEMSHOP_ADD, + CHAR_WINDOWTYPE_DEPOTITEMSHOP_GET, +#endif +}; + +typedef struct { + char option[32]; + char defaultmsg[128]; +}NPC_POOLITEMSHOP_MSG; + +NPC_POOLITEMSHOP_MSG poolshopmsg[] = { + { "main_msg", "ӭ"}, + { "pool_main", "Ҫķʲ"}, + { "draw_main", "Ҫʲ"}, + { "realy_msg", "ҪǸ"}, + { "stone_msg", "Ǯ!"}, + { "poolfull_msg", "޷"}, + { "itemfull_msg", "Ŀкܶ"} +}; + +static BOOL NPC_PoolItemShop_DrawItem( int meindex, int talkerindex, int num); +static BOOL NPC_PoolItemShop_PoolItem( int meindex, int talkerindex, int num); +static void NPC_PoolItemShop_MakeItemString_Draw( int meindex, int talkerindex, + char *retstring,int retstringlen); +static void NPC_PoolItemShop_MakeItemString_Pool( int meindex, int talkerindex, + char *retstring,int retstringlen); +static char *NPC_PoolItemShop_getMsg_noarg( int tablenum, + char *argstr, char *retstring, int retstringlen); +static void NPC_PoolItemShop_printWindow_Draw( int meindex, int talkerindex); +static void NPC_PoolItemShop_printWindow_Pool( int meindex, int talkerindex); +static void NPC_PoolItemShop_printWindow_Full( int meindex, int talkerindex); +void NPC_PoolItemShop_printWindow_Start( int meindex, int talkerindex); +static void NPC_PoolItemShop_printWindow_HaveItemFull( int meindex, int talkerindex); + +#ifdef _NPC_DEPOTITEM +void NPC_PoolItemShop_DepotItem_Menu( int meindex, int talkerindex); +void NPC_DepotItem_Item_printWindow( int meindex, int talkerindex); +void NPC_DepotItem_Depot_printWindow( int meindex, int talkerindex); +BOOL NPC_DepotItem_InsertItem( int meindex, int talkerindex, int num); +BOOL NPC_DepotItem_gettItem( int meindex, int talkerindex, int num); +#endif + +#define NPCPOOLITEMLOOP 1000*20 +int othertime=0; +int ickmeindex = 0; +BOOL NPC_PoolItemShopInit( int meindex) +{ + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE - 1024 * 20]; + int cost; + NPC_Util_GetArgStr( meindex, argstr, sizeof( argstr)); + cost = NPC_Util_GetNumFromStrWithDelim( argstr, "cost"); + if( cost == -1 ) cost = NPC_POOLITEMSHOP_DEFAULT_COST; + CHAR_setWorkInt( meindex, NPC_WORK_COST, cost); +#ifdef _XC_CANGKU + ickmeindex = meindex; +#endif + return TRUE; +} + +void NPC_PoolItemShopLoop( int meindex) +{ +} + +void NPC_PoolItemShopTalked( int meindex , int talkerindex , + char *szMes ,int color ) +{ + if( CHAR_getInt( talkerindex , CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER ) { + return; + } + CHAR_setWorkInt( talkerindex, CHAR_WORKSHOPRELEVANT, 0); + if( !NPC_Util_isFaceToFace( meindex, talkerindex, 2)) { + if( NPC_Util_CharDistance( talkerindex, meindex ) > 1) return; + } + NPC_PoolItemShop_printWindow_Start( meindex, talkerindex); +} + +void NPC_PoolItemShopWindowTalked( int meindex, int talkerindex, + int seqno, int select, char *data) +{ +#ifndef _XC_CANGKU + if( NPC_Util_CharDistance( talkerindex, meindex ) > 2) return; +#endif + //print("\n NPC_PoolItemShopWindowTalked: seq:%d sel:%d data:%s", seqno, select, data); + + switch( seqno ) { + case CHAR_WINDOWTYPE_POOLITEMSHOP_START: + switch( atoi( data)) { + case 1: + if( CHAR_getCharPoolItemIndexElement( talkerindex) != -1 ) { + NPC_PoolItemShop_printWindow_Pool( meindex, talkerindex); + }else { + NPC_PoolItemShop_printWindow_Full( meindex, talkerindex); + } + break; + case 2: + if( CHAR_findEmptyItemBox( talkerindex) != -1 ) { + NPC_PoolItemShop_printWindow_Draw( meindex, talkerindex); + }else { + NPC_PoolItemShop_printWindow_HaveItemFull( meindex, talkerindex); + } + break; +#ifdef _NPC_DEPOTITEM + case 3: + if( !CHAR_CheckDepotItem( talkerindex) ){ + CHAR_GetDepotItem( meindex, talkerindex); + CHAR_talkToCli( talkerindex, -1, "ȡõߣᣡ", CHAR_COLORYELLOW); + }else{ + NPC_PoolItemShop_DepotItem_Menu( meindex, talkerindex); + } + break; +#endif + + } + break; + case CHAR_WINDOWTYPE_POOLITEMSHOP_POOL_MSG: + if( atoi( data) == 0){ + NPC_PoolItemShop_printWindow_Start( meindex, talkerindex); + }else { + NPC_PoolItemShop_PoolItem( meindex, talkerindex, atoi(data)-1); + } + break; + case CHAR_WINDOWTYPE_POOLITEMSHOP_DRAW_MSG: + if( atoi( data) == 0){ + NPC_PoolItemShop_printWindow_Start( meindex, talkerindex); + }else { + NPC_PoolItemShop_DrawItem( meindex, talkerindex, atoi(data)-1); + } + break; + case CHAR_WINDOWTYPE_POOLITEMSHOP_FULL_MSG: + NPC_PoolItemShop_printWindow_Start( meindex, talkerindex); + break; + case CHAR_WINDOWTYPE_POOLITEMSHOP_HAVEITEMFULL_MSG: + NPC_PoolItemShop_printWindow_Start( meindex, talkerindex); + break; + +#ifdef _NPC_DEPOTITEM + case CHAR_WINDOWTYPE_DEPOTITEMSHOP_MENU: + if( !CHAR_CheckDepotItem( talkerindex) ){ + CHAR_GetDepotItem( meindex, talkerindex); + return; + }else{ + NPC_PoolItemShop_DepotItem_Menu( meindex, talkerindex); + } + break; + case CHAR_WINDOWTYPE_DEPOTITEMSHOP_HANDLE: + if( !CHAR_CheckDepotItem( talkerindex) ) return ; + switch( atoi( data)) { + case 1:// +#ifdef _BIG_POOL_TYPE + if(getItemPoolType()==1){ + CHAR_talkToCli( talkerindex, -1, "ֿѹرգʹø˲ֿ⡣", CHAR_COLORYELLOW); + return; + } +#endif + if( CHAR_findEmptyDepotItem( talkerindex) == -1 ){ + CHAR_talkToCli( talkerindex, -1, "ֿ", CHAR_COLORYELLOW); + return; + } + NPC_DepotItem_Item_printWindow( meindex, talkerindex); + break; + case 2: + if( CHAR_findEmptyItemBox( talkerindex) == -1 ) { + CHAR_talkToCli( talkerindex, -1, "ϵλ", CHAR_COLORYELLOW); + return; + } + NPC_DepotItem_Depot_printWindow( meindex, talkerindex); + break; + } + break; + case CHAR_WINDOWTYPE_DEPOTITEMSHOP_ADD:// + if( !CHAR_CheckDepotItem( talkerindex) ) return ; + if( atoi( data) == 0){ + NPC_PoolItemShop_DepotItem_Menu( meindex, talkerindex); + }else { + if( NPC_DepotItem_InsertItem( meindex, talkerindex, atoi( data)-1) == FALSE ){ + //NPC_PoolItemShop_DepotItem_Menu( meindex, talkerindex); + CHAR_talkToCli( talkerindex, -1, "ŵʧܣԣ", CHAR_COLORYELLOW); + return; + } + } + break; + case CHAR_WINDOWTYPE_DEPOTITEMSHOP_GET: + if( !CHAR_CheckDepotItem( talkerindex) ) return ; + if( atoi( data) == 0){ + NPC_PoolItemShop_DepotItem_Menu( meindex, talkerindex); + }else { + if( NPC_DepotItem_gettItem( meindex, talkerindex, atoi( data)-1) == FALSE ){ + NPC_PoolItemShop_DepotItem_Menu( meindex, talkerindex); + CHAR_talkToCli( talkerindex, -1, "ȡʧܣԣ", CHAR_COLORYELLOW); + } + } + break; +#endif + + default: + break; + } +} + +void NPC_PoolItemShop_printWindow_Start( int meindex, int talkerindex) +{ + int fd; + + fd = getfdFromCharaIndex( talkerindex); + if( fd != -1 ) { + char message[1024]; + char buf[2048]; + +#ifdef _NPC_DEPOTITEM + strcpy( message, + "3\n\n" + " ӭ\n\n" + " ķŵߣ\n" + " ȡصߣ\n" + " ʹòֿ⣾\n\n" + " 뿪 " + ); +#else + strcpy( message, + "3\n\n" + " ӭ\n\n" + " ķŵߣ\n" + " ȡصߣ\n\n\n" + " 뿪 " + ); +#endif + + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_SELECT, + WINDOW_BUTTONTYPE_NONE, + CHAR_WINDOWTYPE_POOLITEMSHOP_START, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + makeEscapeString( message, buf, sizeof(buf))); + } +} + +#ifdef _NPC_DEPOTITEM +void NPC_PoolItemShop_DepotItem_Menu( int meindex, int talkerindex) +{ + int fd; + + fd = getfdFromCharaIndex( talkerindex); + if( fd != -1 ) { + char message[1024]; + char buf[2048]; + + strcpy( message, + "3\n\n" + " ʹõֿ߲\n\n" + " ŵߣ\n" + " ȡصߣ\n" + ); + + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_SELECT, + WINDOW_BUTTONTYPE_CANCEL, + CHAR_WINDOWTYPE_DEPOTITEMSHOP_HANDLE, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + makeEscapeString( message, buf, sizeof(buf))); + } +} + +void NPC_DepotItem_MakeItemString( int meindex, int talkerindex, char *retstring,int retstringlen) +{ + int i; + int itemindex; + int pos = 0; + char buff[1024]; + + retstring[0] = '\0'; + for( i = CHAR_STARTITEMARRAY; i < CHAR_MAXITEMHAVE; i ++ ) { + int poolflg = FALSE; + itemindex = CHAR_getItemIndex( talkerindex, i); + if( !ITEM_CHECKINDEX( itemindex) ) continue; + + if( ITEM_getInt( itemindex, ITEM_DROPATLOGOUT) || ITEM_getInt( itemindex, ITEM_VANISHATDROP) || + !ITEM_getInt( itemindex, ITEM_CANPETMAIL) ) { + poolflg = TRUE; + } + int itemtime = ITEM_getInt(itemindex,ITEM_TIME); + char tempbuf[256]; + if(itemtime>0){ + time_t timep; + struct tm *p; + timep = itemtime; + p=localtime(&timep); + int year=1900+p->tm_year; + int mon=1+p->tm_mon; + int date=p->tm_mday; + int hour=p->tm_hour; + int min=p->tm_min; + int sec=p->tm_sec; + char monbuf[5],datebuf[5],hourbuf[5],minbuf[5],secbuf[5]; + if(mon<10) sprintf(monbuf,"0%d",mon); + else sprintf(monbuf,"%d",mon); + if(date<10) sprintf(datebuf,"0%d",date); + else sprintf(datebuf,"%d",date); + if(hour<10) sprintf(hourbuf,"0%d",hour); + else sprintf(hourbuf,"%d",hour); + if(min<10) sprintf(minbuf,"0%d",min); + else sprintf(minbuf,"%d",min); + if(sec<10) sprintf(secbuf,"0%d",sec); + else sprintf(secbuf,"%d",sec); + char tmbuf[256]; + strcpy(tmbuf,ITEM_getChar( itemindex, ITEM_EFFECTSTRING)); + sprintf(tempbuf,"Ч:%d.%s.%s %s:%s:%s %s",year,monbuf,datebuf,hourbuf,minbuf,secbuf,tmbuf); + }else{ + strcpy(tempbuf,ITEM_getChar( itemindex, ITEM_EFFECTSTRING)); + } + snprintf( buff, sizeof( buff), +#ifdef _ITEM_PILENUMS + "%s|%d|%d|%d|%s|%d|%d|", +#else + "%s|%d|%d|%d|%s|%d|", +#endif + ITEM_getChar( itemindex, ITEM_SECRETNAME), + poolflg,CHAR_getWorkInt( meindex, NPC_WORK_COST), + ITEM_getInt( itemindex, ITEM_BASEIMAGENUMBER), + tempbuf, +#ifdef _ITEM_PILENUMS + ITEM_getInt( itemindex, ITEM_USEPILENUMS), +#endif + i + 1 ); + + if( pos +strlen( buff)>= retstringlen) { + fprint( "buffer over err\n"); + break; + } + strcpy( &retstring[pos], buff); + pos += strlen( buff); + } +} + +void NPC_DepotItem_Item_printWindow( int meindex, int talkerindex) +{ + char itemstring[NPC_UTIL_GETARGSTR_BUFSIZE - 1024 * 20]; + char sendstring[NPC_UTIL_GETARGSTR_BUFSIZE - 1024 * 20]; + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE - 1024 * 20]; + char buff2[1024]; + char buff3[1024]; + char buff4[1024]; + int fd; + + if( (fd = getfdFromCharaIndex( talkerindex)) == -1 ){ + fprint( "err\n"); + return; + } + NPC_Util_GetArgStr( meindex, argstr, sizeof( argstr)); + snprintf( sendstring, sizeof( sendstring), "0|%d|%s|%s|%s|%s|", + CHAR_getfindEmptyDepotItem( talkerindex), + CHAR_getChar( meindex, CHAR_NAME), + NPC_PoolItemShop_getMsg_noarg( NPC_POOLITEMSHOP_MSG_POOL, argstr, buff2, sizeof( buff2)), + NPC_PoolItemShop_getMsg_noarg( NPC_POOLITEMSHOP_MSG_POOLFULL, argstr, buff3, sizeof( buff3)), + NPC_PoolItemShop_getMsg_noarg( NPC_POOLITEMSHOP_MSG_REALY, argstr, buff4, sizeof( buff4)) + ); + + NPC_DepotItem_MakeItemString( meindex, talkerindex, itemstring, sizeof( itemstring)); + strcat( sendstring, itemstring); + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_POOLITEMSHOPMAIN, + WINDOW_BUTTONTYPE_NONE, + CHAR_WINDOWTYPE_DEPOTITEMSHOP_ADD, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), sendstring); + +} + +void NPC_DepotItem_MakeDepotString( int meindex, int talkerindex, char *retstring,int retstringlen) +{ + int i; + int itemindex; + int pos = 0; + char buff[1024]; + + retstring[0] = '\0'; + for( i = 0; i < /*60*/CHAR_MAXDEPOTITEMHAVE; i ++ ) { + int poolflg = FALSE; + itemindex = CHAR_getDepotItemIndex( talkerindex, i); + if( !ITEM_CHECKINDEX( itemindex)) continue; + int itemtime = ITEM_getInt(itemindex,ITEM_TIME); + char tempbuf[256]; + if(itemtime>0){ + time_t timep; + struct tm *p; + timep = itemtime; + p=localtime(&timep); + int year=1900+p->tm_year; + int mon=1+p->tm_mon; + int date=p->tm_mday; + int hour=p->tm_hour; + int min=p->tm_min; + int sec=p->tm_sec; + char monbuf[5],datebuf[5],hourbuf[5],minbuf[5],secbuf[5]; + if(mon<10) sprintf(monbuf,"0%d",mon); + else sprintf(monbuf,"%d",mon); + if(date<10) sprintf(datebuf,"0%d",date); + else sprintf(datebuf,"%d",date); + if(hour<10) sprintf(hourbuf,"0%d",hour); + else sprintf(hourbuf,"%d",hour); + if(min<10) sprintf(minbuf,"0%d",min); + else sprintf(minbuf,"%d",min); + if(sec<10) sprintf(secbuf,"0%d",sec); + else sprintf(secbuf,"%d",sec); + char tmbuf[256]; + strcpy(tmbuf,ITEM_getChar( itemindex, ITEM_EFFECTSTRING)); + sprintf(tempbuf,"Ч:%d.%s.%s %s:%s:%s %s",year,monbuf,datebuf,hourbuf,minbuf,secbuf,tmbuf); + }else{ + strcpy(tempbuf,ITEM_getChar( itemindex, ITEM_EFFECTSTRING)); + } + snprintf( buff, sizeof( buff), +#ifdef _ITEM_PILENUMS + "%s|%d|%d|%d|%d|%s|%d|", +#else + "%s|%d|%d|%d|%d|%s|", +#endif + ITEM_getChar( itemindex, ITEM_SECRETNAME), + poolflg, + ITEM_getInt( itemindex, ITEM_LEVEL), + ITEM_getInt( itemindex, ITEM_COST), + ITEM_getInt( itemindex, ITEM_BASEIMAGENUMBER), + tempbuf +#ifdef _ITEM_PILENUMS + ,ITEM_getInt( itemindex, ITEM_USEPILENUMS) +#endif + ); + if( pos +strlen( buff)>= retstringlen) { + fprint( "buffer over err\n"); + break; + } + strcpy( &retstring[pos], buff); + pos += strlen( buff); + } + +} + +void NPC_DepotItem_Depot_printWindow( int meindex, int talkerindex) +{ + char itemstring[NPC_UTIL_GETARGSTR_BUFSIZE - 1024 * 20]; + char sendstring[NPC_UTIL_GETARGSTR_BUFSIZE - 1024 * 20]; + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE - 1024 * 20]; + char buff[1024]; + char buff2[1024]; + char buff3[1024]; + int fd; + + if( (fd = getfdFromCharaIndex( talkerindex)) == -1 )return; + NPC_Util_GetArgStr( meindex, argstr, sizeof( argstr)); + snprintf( sendstring, sizeof( sendstring), "1|%s|%s|%s|%s|", + CHAR_getChar( meindex, CHAR_NAME), + NPC_PoolItemShop_getMsg_noarg( NPC_POOLITEMSHOP_MSG_DRAW, argstr, buff2, sizeof( buff2)), + NPC_PoolItemShop_getMsg_noarg( NPC_POOLITEMSHOP_MSG_ITEMFULL, argstr, buff, sizeof( buff)), + NPC_PoolItemShop_getMsg_noarg( NPC_POOLITEMSHOP_MSG_REALY, argstr, buff3, sizeof( buff3)) + ); + NPC_DepotItem_MakeDepotString( meindex, talkerindex, itemstring, sizeof( itemstring)); + strcat( sendstring, itemstring); + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_POOLITEMSHOPMAIN, + WINDOW_BUTTONTYPE_NONE, + CHAR_WINDOWTYPE_DEPOTITEMSHOP_GET, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + sendstring); + + //print("\n NPC_DepotItem_Depot_printWindow:%s size:%d ", sendstring, strlen(sendstring)); +} + +void NPC_DepotItem_CheckRepeat_Del( int charaindex, int ti, int itemindex) +{ + char token[256]; + sprintf( token, "ֿ%sظ(ϵͳ)", + ITEM_getChar( itemindex, ITEM_NAME)); + CHAR_talkToCli( charaindex, -1, token, CHAR_COLORYELLOW); + LogItem( + CHAR_getChar( charaindex, CHAR_NAME ), + CHAR_getChar( charaindex, CHAR_CDKEY ), +#ifdef _add_item_log_name + itemindex, +#else + ITEM_getInt( itemindex, ITEM_ID), +#endif + "repeat(ֿظ)", + 0, 0, 0, + ITEM_getChar( itemindex, ITEM_UNIQUECODE), + ITEM_getChar( itemindex, ITEM_NAME), + ITEM_getInt( itemindex, ITEM_ID) ); + + CHAR_setDepotItemIndex( charaindex, ti, -1); + ITEM_endExistItemsOne( itemindex); +} + +void NPC_DepotItem_CheckRepeat( int talkerindex) +{ + int i, j, cnt=0, itemindex, itemindex1; + + for( i=0; i<(CHAR_MAXDEPOTITEMHAVE-1); i++){ + itemindex = CHAR_getDepotItemIndex( talkerindex, i); + if( !ITEM_CHECKINDEX( itemindex)) continue; + cnt=0; + for( j=(i+1); j=23228 && ID1<=23307){ + if(strstr(ITEM_getChar(itemindex,ITEM_EFFECTSTRING),"")==NULL){ + ITEM_setChar(itemindex,ITEM_EFFECTSTRING,"[ԣ]뵽峤(13.5)Ҹʦ"); + } + } + if(((ID1>=3000 && ID1<=11719) || (ID1>=14001 && ID1<=18530)) && ITEM_getInt( itemindex, ITEM_MAXDAMAGECRUSHE)<1){ + int maxcrushe = ITEMTBL_getInt(ID1,ITEM_MAXDAMAGECRUSHE); + ITEM_setInt(itemindex,ITEM_MAXDAMAGECRUSHE,maxcrushe); + ITEM_setInt(itemindex,ITEM_DAMAGECRUSHE,maxcrushe); + } +#endif + for( j=1;j<=30;j++ ) { + if(getStringFromIndexWithDelim(delbuf,",", j, delitembuf, sizeof(delitembuf)) == FALSE) + break; + ID2 = atoi(delitembuf); + if(ID2 == -1)break; + if( ID1 == ID2){ + CHAR_setItemIndex( talkerindex, emptyindex, -1); + LogItem(CHAR_getChar( talkerindex, CHAR_NAME ), // + CHAR_getChar( talkerindex, CHAR_CDKEY ), //ʺ +#ifdef _add_item_log_name // WON ADD itemlogitem + itemindex, +#else + ITEM_getInt( itemindex, ITEM_ID ), +#endif + "poolitemshop(CFƷ)", + CHAR_getInt( talkerindex,CHAR_FLOOR), + CHAR_getInt( talkerindex,CHAR_X ), + CHAR_getInt( talkerindex,CHAR_Y ), + ITEM_getChar( itemindex, ITEM_UNIQUECODE), + ITEM_getChar( itemindex, ITEM_NAME), + ITEM_getInt( itemindex, ITEM_ID) + ); + CHAR_talkToCli( talkerindex, -1, "ϵͳֿĵ", CHAR_COLORWHITE ); + return TRUE; + } + } +#endif + + + CHAR_sendItemDataOne( talkerindex, emptyindex); + + CHAR_send_P_StatusString( talkerindex, CHAR_P_STRING_GOLD); + + LogItem( + CHAR_getChar( talkerindex, CHAR_NAME ), + CHAR_getChar( talkerindex, CHAR_CDKEY ), +#ifdef _add_item_log_name + itemindex, +#else + ITEM_getInt( itemindex, ITEM_ID), +#endif + "Depot(ȡ)", + CHAR_getInt( talkerindex,CHAR_FLOOR), + CHAR_getInt( talkerindex,CHAR_X ), + CHAR_getInt( talkerindex,CHAR_Y ), + ITEM_getChar( itemindex, ITEM_UNIQUECODE), + ITEM_getChar( itemindex, ITEM_NAME), + ITEM_getInt( itemindex, ITEM_ID) ); + + { + int i, cnt=0; + int work[CHAR_MAXDEPOTITEMHAVE]; + for( i = 0; i < CHAR_MAXDEPOTITEMHAVE; i ++ ) { + work[i] = -1; + } + for( i = 0; i < CHAR_MAXDEPOTITEMHAVE; i ++ ) { + itemindex = CHAR_getDepotItemIndex( talkerindex, i); + if( !ITEM_CHECKINDEX( itemindex)) continue; + work[ cnt++] = itemindex; + } + for( i = 0; i < CHAR_MAXDEPOTITEMHAVE; i ++ ) { + CHAR_setDepotItemIndex( talkerindex, i, work[i]); + } + } + + int itemtime = 0; + itemtime = ITEM_getInt(itemindex,ITEM_TIME); + if(itemtime>0){ + time_t timep; + struct tm *p; + time(&timep); + p=localtime(&timep); + timep = mktime(p); + if(itemtime<=timep){ + char itemname[128]; + sprintf(itemname,"ĵ:%sʱЧѵϵͳջء",ITEM_getChar(itemindex,ITEM_NAME)); + CHAR_talkToCli( talkerindex, -1, itemname, CHAR_COLORYELLOW ); + CHAR_setItemIndex( talkerindex, emptyindex ,-1); + CHAR_sendItemDataOne( talkerindex, emptyindex); + ITEM_endExistItemsOne(itemindex); + } + } + + return TRUE; +} +#endif + +static void NPC_PoolItemShop_printWindow_Full( int meindex, int talkerindex) +{ + int fd; + + fd = getfdFromCharaIndex( talkerindex); + if( fd != -1 ) { + char message[1024]; + char buf[2048]; + + strcpy( message, + "\n\n ޷" + ); + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + CHAR_WINDOWTYPE_POOLITEMSHOP_FULL_MSG, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + makeEscapeString( message, buf, sizeof(buf))); + } + +} + +static void NPC_PoolItemShop_printWindow_HaveItemFull( int meindex, int talkerindex) +{ + int fd; + + fd = getfdFromCharaIndex( talkerindex); + if( fd != -1 ) { + char message[1024]; + char buf[2048]; + + strcpy( message, + "\n\n ߲Ѿ" + ); + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + CHAR_WINDOWTYPE_POOLITEMSHOP_HAVEITEMFULL_MSG, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + makeEscapeString( message, buf, sizeof(buf))); + } +} + +static void NPC_PoolItemShop_printWindow_Pool( int meindex, int talkerindex) +{ + char itemstring[NPC_UTIL_GETARGSTR_BUFSIZE - 1024 * 20]; + char sendstring[NPC_UTIL_GETARGSTR_BUFSIZE - 1024 * 20]; + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE - 1024 * 20]; + char buff2[1024]; + char buff3[1024]; + char buff4[1024]; + int fd; + + fd = getfdFromCharaIndex( talkerindex); + if( fd == -1 ) { + fprint( "err\n"); + return; + } + + NPC_Util_GetArgStr( meindex, argstr, sizeof( argstr)); + + snprintf( sendstring, sizeof( sendstring), "0|%d|%s|%s|%s|%s|", + CHAR_getEmptyCharPoolItemIndexNum( talkerindex), + CHAR_getChar( meindex, CHAR_NAME), + NPC_PoolItemShop_getMsg_noarg( NPC_POOLITEMSHOP_MSG_POOL, + argstr, buff2, sizeof( buff2)), + NPC_PoolItemShop_getMsg_noarg( NPC_POOLITEMSHOP_MSG_POOLFULL, + argstr, buff3, sizeof( buff3)), + NPC_PoolItemShop_getMsg_noarg( NPC_POOLITEMSHOP_MSG_REALY, + argstr, buff4, sizeof( buff4)) + ); + + NPC_PoolItemShop_MakeItemString_Pool( meindex, talkerindex, itemstring, sizeof( itemstring)); + strcat( sendstring, itemstring); + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_POOLITEMSHOPMAIN, + WINDOW_BUTTONTYPE_NONE, + CHAR_WINDOWTYPE_POOLITEMSHOP_POOL_MSG, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + sendstring); + +} + +static void NPC_PoolItemShop_printWindow_Draw( int meindex, int talkerindex) +{ + char itemstring[NPC_UTIL_GETARGSTR_BUFSIZE - 1024 * 20]; + char sendstring[NPC_UTIL_GETARGSTR_BUFSIZE - 1024 * 20]; + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE - 1024 * 20]; + char buff[1024]; + char buff2[1024]; + char buff3[1024]; + int fd; + + fd = getfdFromCharaIndex( talkerindex); + if( fd == -1 ) { + fprint( "err\n"); + return; + } + + NPC_Util_GetArgStr( meindex, argstr, sizeof( argstr)); + + snprintf( sendstring, sizeof( sendstring), "1|%s|%s|%s|%s|", + CHAR_getChar( meindex, CHAR_NAME), + NPC_PoolItemShop_getMsg_noarg( NPC_POOLITEMSHOP_MSG_DRAW, + argstr, buff2, sizeof( buff2)), + NPC_PoolItemShop_getMsg_noarg( NPC_POOLITEMSHOP_MSG_ITEMFULL, + argstr, buff, sizeof( buff)), + NPC_PoolItemShop_getMsg_noarg( NPC_POOLITEMSHOP_MSG_REALY, + argstr, buff3, sizeof( buff3)) + ); + NPC_PoolItemShop_MakeItemString_Draw( meindex, talkerindex, + itemstring, sizeof( itemstring)); + strcat( sendstring, itemstring); + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_POOLITEMSHOPMAIN, + WINDOW_BUTTONTYPE_NONE, + CHAR_WINDOWTYPE_POOLITEMSHOP_DRAW_MSG, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + sendstring); + +} + +static char *NPC_PoolItemShop_getMsg_noarg( int tablenum, + char *argstr, char *retstring, int retstringlen) +{ + char buf[1024]; + if( tablenum < 0 || tablenum >= arraysizeof( poolshopmsg)) return "\0"; + + if( NPC_Util_GetStrFromStrWithDelim( argstr, poolshopmsg[tablenum].option, buf, sizeof( buf)) != NULL ) { + strcpysafe( retstring, retstringlen, buf); + }else { + strcpysafe( retstring, retstringlen, poolshopmsg[tablenum].defaultmsg); + } + return retstring; +} + +static void NPC_PoolItemShop_MakeItemString_Pool( int meindex, int talkerindex, + char *retstring,int retstringlen) +{ + int i; + int itemindex; + int pos = 0; + char buff[1024]; + + retstring[0] = '\0'; + for( i = CHAR_STARTITEMARRAY; i < CHAR_MAXITEMHAVE; i ++ ) { + itemindex = CHAR_getItemIndex( talkerindex, i); + if( ITEM_CHECKINDEX( itemindex)) { + int poolflg = FALSE; + if( ITEM_getInt( itemindex, ITEM_DROPATLOGOUT) || + ITEM_getInt( itemindex, ITEM_VANISHATDROP) || + !ITEM_getInt( itemindex, ITEM_CANPETMAIL)){ + poolflg = TRUE; + } + int itemtime = ITEM_getInt(itemindex,ITEM_TIME); + char tempbuf[256]; + if(itemtime>0){ + time_t timep; + struct tm *p; + timep = itemtime; + p=localtime(&timep); + int year=1900+p->tm_year; + int mon=1+p->tm_mon; + int date=p->tm_mday; + int hour=p->tm_hour; + int min=p->tm_min; + int sec=p->tm_sec; + char monbuf[5],datebuf[5],hourbuf[5],minbuf[5],secbuf[5]; + if(mon<10) sprintf(monbuf,"0%d",mon); + else sprintf(monbuf,"%d",mon); + if(date<10) sprintf(datebuf,"0%d",date); + else sprintf(datebuf,"%d",date); + if(hour<10) sprintf(hourbuf,"0%d",hour); + else sprintf(hourbuf,"%d",hour); + if(min<10) sprintf(minbuf,"0%d",min); + else sprintf(minbuf,"%d",min); + if(sec<10) sprintf(secbuf,"0%d",sec); + else sprintf(secbuf,"%d",sec); + char tmbuf[256]; + strcpy(tmbuf,ITEM_getChar( itemindex, ITEM_EFFECTSTRING)); + sprintf(tempbuf,"Ч:%d.%s.%s %s:%s:%s %s",year,monbuf,datebuf,hourbuf,minbuf,secbuf,tmbuf); + }else{ + strcpy(tempbuf,ITEM_getChar( itemindex, ITEM_EFFECTSTRING)); + } + snprintf( buff, sizeof( buff), +#ifdef _ITEM_PILENUMS + "%s|%d|%d|%d|%s|%d|%d|", +#else + "%s|%d|%d|%d|%s|%d|", +#endif + ITEM_getChar( itemindex, ITEM_SECRETNAME), + poolflg,CHAR_getWorkInt( meindex, NPC_WORK_COST), + ITEM_getInt( itemindex, ITEM_BASEIMAGENUMBER), + tempbuf, +#ifdef _ITEM_PILENUMS + ITEM_getInt( itemindex, ITEM_USEPILENUMS), +#endif + i + 1 ); + if( pos +strlen( buff)>= retstringlen) { + fprint( "buffer over err\n"); + break; + } + strcpy( &retstring[pos], buff); + pos += strlen( buff); + } + } +} + +static void NPC_PoolItemShop_MakeItemString_Draw( int meindex, int talkerindex, + char *retstring,int retstringlen) +{ + int i; + int itemindex; + int pos = 0; + char buff[1024]; + + retstring[0] = '\0'; + for( i = 0; i < CHAR_MAXPOOLITEMHAVE; i ++ ) { + itemindex = CHAR_getPoolItemIndex( talkerindex, i); + if( ITEM_CHECKINDEX( itemindex)) { + int poolflg = FALSE; + int itemtime = ITEM_getInt(itemindex,ITEM_TIME); + char tempbuf[256]; + if(itemtime>0){ + time_t timep; + struct tm *p; + timep = itemtime; + p=localtime(&timep); + int year=1900+p->tm_year; + int mon=1+p->tm_mon; + int date=p->tm_mday; + int hour=p->tm_hour; + int min=p->tm_min; + int sec=p->tm_sec; + char monbuf[5],datebuf[5],hourbuf[5],minbuf[5],secbuf[5]; + if(mon<10) sprintf(monbuf,"0%d",mon); + else sprintf(monbuf,"%d",mon); + if(date<10) sprintf(datebuf,"0%d",date); + else sprintf(datebuf,"%d",date); + if(hour<10) sprintf(hourbuf,"0%d",hour); + else sprintf(hourbuf,"%d",hour); + if(min<10) sprintf(minbuf,"0%d",min); + else sprintf(minbuf,"%d",min); + if(sec<10) sprintf(secbuf,"0%d",sec); + else sprintf(secbuf,"%d",sec); + char tmbuf[256]; + strcpy(tmbuf,ITEM_getChar( itemindex, ITEM_EFFECTSTRING)); + sprintf(tempbuf,"Ч:%d.%s.%s %s:%s:%s %s",year,monbuf,datebuf,hourbuf,minbuf,secbuf,tmbuf); + }else{ + strcpy(tempbuf,ITEM_getChar( itemindex, ITEM_EFFECTSTRING)); + } + snprintf( buff, sizeof( buff), +#ifdef _ITEM_PILENUMS + "%s|%d|%d|%d|%d|%s|%d|", + +#else + "%s|%d|%d|%d|%d|%s|", +#endif + ITEM_getChar( itemindex, ITEM_SECRETNAME), + poolflg, + ITEM_getInt( itemindex, ITEM_LEVEL), + ITEM_getInt( itemindex, ITEM_COST), + ITEM_getInt( itemindex, ITEM_BASEIMAGENUMBER), + tempbuf +#ifdef _ITEM_PILENUMS + ,ITEM_getInt( itemindex, ITEM_USEPILENUMS) +#endif + ); + if( pos +strlen( buff)>= retstringlen) { + fprint( "buffer over err\n"); + break; + } + strcpy( &retstring[pos], buff); + pos += strlen( buff); + } + } +} + +static BOOL NPC_PoolItemShop_PoolItem( int meindex, int talkerindex, int num) +{ + int emptyindex; + int itemindex; + int cost = CHAR_getWorkInt( meindex, NPC_WORK_COST); + + emptyindex = CHAR_getCharPoolItemIndexElement( talkerindex); + if( emptyindex == -1 ) { + return FALSE; + } + + itemindex = CHAR_getItemIndex( talkerindex, num); + if( getItemPoolBug() == 1 ) + { + if( ITEM_getInt( itemindex, ITEM_DROPATLOGOUT) || // dzʧ + ITEM_getInt( itemindex, ITEM_VANISHATDROP) || // ʧ + !ITEM_getInt( itemindex, ITEM_CANPETMAIL) ) { // ɳʼ + return FALSE; + } + } + if( !ITEM_CHECKINDEX( itemindex)) { + fprint( "err"); + return FALSE; + } + CHAR_DelGold( talkerindex, cost ); + + CHAR_setPoolItemIndex( talkerindex, emptyindex, itemindex); + + CHAR_setItemIndex( talkerindex, num, -1); + CHAR_sendItemDataOne( talkerindex, num); + + CHAR_send_P_StatusString( talkerindex, CHAR_P_STRING_GOLD); + LogItem( + CHAR_getChar( talkerindex, CHAR_NAME ), /* ƽҷ */ + CHAR_getChar( talkerindex, CHAR_CDKEY ), +#ifdef _add_item_log_name // WON ADD itemlogitem + itemindex, +#else + ITEM_getInt( itemindex, ITEM_ID), /* ʧ ة į */ +#endif + "pool(ķŵ)", + CHAR_getInt( talkerindex,CHAR_FLOOR), + CHAR_getInt( talkerindex,CHAR_X ), + CHAR_getInt( talkerindex,CHAR_Y ), + ITEM_getChar( itemindex, ITEM_UNIQUECODE), + ITEM_getChar( itemindex, ITEM_NAME), + ITEM_getInt( itemindex, ITEM_ID) + + ); + //int fd = getfdFromCharaIndex( talkerindex); + CHAR_charSaveFromConnect(talkerindex, FALSE); + CHAR_talkToCli(talkerindex, -1, "ϵͳΪԶ浵", CHAR_COLORRED); + return TRUE; +} + +static BOOL NPC_PoolItemShop_DrawItem( int meindex, int talkerindex, int num) +{ + int emptyindex; + int itemindex; + int i; + int cnt; + int work[CHAR_MAXPOOLITEMHAVE]; + + emptyindex = CHAR_findEmptyItemBox( talkerindex); + if( emptyindex == -1 ) return FALSE; + + itemindex = CHAR_getPoolItemIndex( talkerindex, num); + if( !ITEM_CHECKINDEX( itemindex)) { + fprint( "err\n"); + return FALSE; + } + CHAR_setItemIndex( talkerindex, emptyindex, itemindex); + CHAR_setPoolItemIndex( talkerindex, num, -1); + CHAR_sendItemDataOne( talkerindex, emptyindex); + for( i = 0; i < CHAR_MAXPOOLITEMHAVE; i ++ ) { + work[i] = -1; + } + cnt = 0; + for( i = 0; i < CHAR_MAXPOOLITEMHAVE; i ++ ) { + itemindex = CHAR_getPoolItemIndex( talkerindex, i); + if( ITEM_CHECKINDEX( itemindex)) { + work[ cnt++] = itemindex; + } + } + for( i = 0; i < CHAR_MAXPOOLITEMHAVE; i ++ ) { + CHAR_setPoolItemIndex( talkerindex, i, work[i]); + } + LogItem( + CHAR_getChar( talkerindex, CHAR_NAME ), + CHAR_getChar( talkerindex, CHAR_CDKEY ), +#ifdef _add_item_log_name // WON ADD itemlogitem + itemindex, +#else + ITEM_getInt( itemindex, ITEM_ID), +#endif + "draw(ȡ)", + CHAR_getInt( talkerindex,CHAR_FLOOR), + CHAR_getInt( talkerindex,CHAR_X ), + CHAR_getInt( talkerindex,CHAR_Y ), + ITEM_getChar( itemindex, ITEM_UNIQUECODE), + ITEM_getChar( itemindex, ITEM_NAME), + ITEM_getInt( itemindex, ITEM_ID) + ); + int fd = getfdFromCharaIndex( talkerindex); + int itemtime = 0; + itemtime = ITEM_getInt(itemindex,ITEM_TIME); + if(itemtime>0){ + time_t timep; + struct tm *p; + time(&timep); + p=localtime(&timep); + timep = mktime(p); + if(itemtime<=timep){ + char itemname[128]; + sprintf(itemname,"ĵ:%sʱЧѵϵͳջء",ITEM_getChar(itemindex,ITEM_NAME)); + CHAR_talkToCli( talkerindex, -1, itemname, CHAR_COLORYELLOW ); + CHAR_setItemIndex( talkerindex, emptyindex ,-1); + CHAR_sendItemDataOne( talkerindex, emptyindex); + ITEM_endExistItemsOne(itemindex); + } + } + CHAR_charSaveFromConnect(talkerindex, FALSE); + CHAR_talkToCli(talkerindex, -1, "ϵͳΪԶ浵", CHAR_COLORRED); + return TRUE; +} diff --git a/npc/npc_quiz.c b/npc/npc_quiz.c new file mode 100644 index 0000000..459d44c --- /dev/null +++ b/npc/npc_quiz.c @@ -0,0 +1,1330 @@ +#include "version.h" +#include +#include "common.h" +#include "char_base.h" +#include "npc_quiz.h" +#include "npcutil.h" +#include "char.h" +#include "lssproto_serv.h" +#include "buf.h" +#include "function.h" +#include "readmap.h" +#include "object.h" +#include "log.h" + +#define MEPLAYER 8 +#define OLDNO 100 + +enum { + CHAR_WORK_PLAYER1 = CHAR_NPCWORKINT1, + CHAR_WORK_PLAYER2 = CHAR_NPCWORKINT2, + CHAR_WORK_PLAYER3 = CHAR_NPCWORKINT3, + CHAR_WORK_PLAYER4 = CHAR_NPCWORKINT4, + CHAR_WORK_PLAYER5 = CHAR_NPCWORKINT5, + CHAR_WORK_PLAYER6 = CHAR_NPCWORKINT6, + CHAR_WORK_PLAYER7 = CHAR_NPCWORKINT7, + CHAR_WORK_PLAYER8 = CHAR_NPCWORKINT8, + CHAR_WORK_QUIZNUM = CHAR_NPCWORKINT9, +}; + +NPC_QUIZ* Quiz; + +struct pl{ + int talkerindex; + int quizno; + int answer; + int ansno; + int oldno[OLDNO]; + int *ptr; +}; + + +static int quizcnt = 0; + + +static void NPC_Quiz_selectWindow( int meindex, int talker, int num); +int *NPC_GetQuestion(int meindex); +BOOL NPC_QuizItemFullCheck(int meindex, int talker); +BOOL NPC_PlayerCheck(int meindex,int talker); +int NPC_RealyCheack(int meindex,int talker); +int NPC_QuizRandAnswer(int p_no,int q_no, int mode, + char *work1,char *work2,char *work3); +int NPC_QuizBorderLine(int ans, char *buf); +int NPC_QuizWarpBorderLine(int ans, char *buf); + +BOOL NPC_QuizAddItem(int talker,char *buf); + +BOOL NPC_EntryItemDel(int talker,char *buf); +BOOL NPC_EntryItemCheck(int talker,char *buf); +BOOL NPC_EntryStoneDel(int talker,char *buf); +BOOL NPC_EntryStoneCheck(int talker,char *buf); +BOOL NPC_QUIZPARTY_CHAECK(int meindex,int talker); + +BOOL NPC_QuizInit( int meindex ) +{ + + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + char buf[1024]; + int *tbl; + int i; + + NPC_Util_GetArgStr( meindex, argstr, sizeof( argstr)); + + if(NPC_Util_GetStrFromStrWithDelim( argstr, "StartMsg", buf, sizeof( buf)) == NULL){ + print("Quiz_StartMsgErr:%s", CHAR_getChar( meindex, CHAR_NAME)); + return FALSE; + } + + if(NPC_Util_GetStrFromStrWithDelim( argstr, "Quiznum", buf, sizeof( buf)) == NULL){ + print("QuizNumErrErr:%s", CHAR_getChar( meindex, CHAR_NAME)); + return FALSE; + } + + CHAR_setWorkInt( meindex, CHAR_WORK_QUIZNUM, atoi( buf)); + + for(i =0 ; i < 8 ; i++){ + CHAR_setWorkInt( meindex, CHAR_WORK_PLAYER1 + i, -1); + } + tbl = NPC_GetQuestion( meindex); + + if( CHAR_getWorkInt( meindex, CHAR_WORK_QUIZNUM) > ( tbl[0] - 1)){ + print( + "%s,ԲȦquiz(%d? ȳ(%d)", + CHAR_getChar( meindex, CHAR_NAME), + (tbl[0]-1), + CHAR_getWorkInt( meindex, CHAR_WORK_QUIZNUM) + ); + return FALSE; + } + + return TRUE; + +} + +void NPC_QuizTalked( int meindex , int talkerindex , char *szMes , + int color ) +{ + if( CHAR_getInt( talkerindex , CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER ) { + return; + } + if( NPC_Util_CharDistance( talkerindex, meindex ) > 1) return; + + if(NPC_QUIZPARTY_CHAECK(meindex,talkerindex)==FALSE){ + NPC_Quiz_selectWindow( meindex, talkerindex, 4); + + } + if(NPC_QuizItemFullCheck(meindex, talkerindex) == FALSE){ + NPC_Quiz_selectWindow( meindex, talkerindex, 3); + }else{ + NPC_Quiz_selectWindow( meindex, talkerindex, 0); + } +} + +static void NPC_Quiz_selectWindow( int meindex, int talker, int num) +{ + + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + char token[1024]; + char buf[256]; + char buf2[256]; + char buf3[256]; + + int i = 0,k; + int questionno = 0; + int fd = getfdFromCharaIndex( talker); + int buttontype = 0; + int messagetype = 0; + int windowno = 0; + int len = 4; + int p_no; + int p_old; + int loop=0; + int ans; + BOOL entryflg = TRUE; + switch( num) { + case 0: + if(NPC_Util_GetArgStr( meindex, argstr, sizeof( argstr)) == NULL){ + print("GetArgstrErr:Quiz %s",CHAR_getChar( meindex, CHAR_NAME)); + } + if(NPC_Util_GetStrFromStrWithDelim( argstr,"StartMsg",token, sizeof( token)) == NULL){ + print("%sStartMsg", CHAR_getChar(meindex,CHAR_NAME)); + return; + } + buttontype = WINDOW_BUTTONTYPE_YESNO; + messagetype = WINDOW_MESSAGETYPE_MESSAGE; + windowno = CHAR_WINDOWTYPE_QUIZ_START; + break; + + case 1: + if(NPC_Util_GetArgStr( meindex, argstr, sizeof( argstr)) == NULL){ + print("GetArgstrErr:Quiz %s",CHAR_getChar( meindex, CHAR_NAME)); + } + if(NPC_Util_GetStrFromStrWithDelim( argstr,"EntryItem", buf2, sizeof( buf2)) != NULL){ + if(NPC_EntryItemCheck( talker, buf2) == FALSE){ + entryflg = FALSE; + } + } + if(NPC_Util_GetStrFromStrWithDelim( argstr,"EntryStone",buf3, sizeof( buf3)) != NULL){ + if(NPC_EntryStoneCheck( talker, buf3) == FALSE){ + entryflg = FALSE; + } + } + if(entryflg == FALSE){ + if(NPC_Util_GetStrFromStrWithDelim( argstr,"NoEntryMsg",token, sizeof( token)) != NULL) { + buttontype = WINDOW_BUTTONTYPE_OK; + messagetype = WINDOW_MESSAGETYPE_MESSAGE; + windowno = CHAR_WINDOWTYPE_QUIZ_START; + + } + + }else if(NPC_PlayerCheck( meindex, talker) == FALSE) { + /*-----*/ + sprintf(token,"\n\n\n ,Եһ" + "\n պ幫ئƥئо" + ); + buttontype = WINDOW_BUTTONTYPE_OK; + messagetype = WINDOW_MESSAGETYPE_MESSAGE; + windowno = CHAR_WINDOWTYPE_QUIZ_START; + + }else{ + if(NPC_Util_GetStrFromStrWithDelim( argstr,"EntryItem",buf2, sizeof( buf2)) != NULL){ + if(NPC_EntryItemDel( talker, buf2) ==FALSE){ + print("ûʧ(%s)",CHAR_getChar(meindex,CHAR_NAME)); + return; + } + } + if(NPC_Util_GetStrFromStrWithDelim( argstr,"EntryStone",buf3, sizeof( buf3)) != NULL){ + if(NPC_EntryStoneDel( talker, buf3) ==FALSE){ + print("Ǯûʧ(%s)",CHAR_getChar(meindex,CHAR_NAME)); + return; + } + } + NPC_Quiz_selectWindow(meindex, talker, 2); + return; + } + break; + + case 3: + if(NPC_Util_GetArgStr( meindex, argstr, sizeof( argstr)) == NULL){ + print("GetArgstrErr:Quiz %s",CHAR_getChar( meindex, CHAR_NAME)); + } + + /*-- --*/ + if(NPC_Util_GetStrFromStrWithDelim( argstr,"ItemFullMsg", token, sizeof( token)) == NULL) + { + print("%sItemFullMsg", CHAR_getChar(meindex,CHAR_NAME)); + return; + } + + buttontype = WINDOW_BUTTONTYPE_OK; + messagetype = WINDOW_MESSAGETYPE_MESSAGE; + windowno = CHAR_WINDOWTYPE_QUIZ_START; + + break; + case 2: + /*--̼--*/ + { + int *tbl; + int point; + int *pl_ptr; + int warp_flg = -1; + int floor=0,x=0,y=0; + + struct pl PLAYER; + + + if(NPC_QUIZPARTY_CHAECK(meindex,talker)==FALSE){ + NPC_Quiz_selectWindow( meindex, talker, 4); + } + + + + p_no = CHAR_getWorkInt( talker, CHAR_WORKSHOPRELEVANT); + point = CHAR_getWorkInt( meindex, CHAR_WORK_PLAYER1 + p_no); + pl_ptr = (int *)point; + + memcpy(&PLAYER, pl_ptr, sizeof(struct pl)); + + if(PLAYER.quizno + == CHAR_getWorkInt( meindex, CHAR_WORK_QUIZNUM)) + { + double avg; + int okflg; + char buf2[512]; + + if(NPC_Util_GetArgStr( meindex, argstr, sizeof( argstr)) == NULL) + { + print("GetArgstrErr:Quiz %s",CHAR_getChar( meindex, CHAR_NAME)); + } + + if(NPC_Util_GetStrFromStrWithDelim( argstr, "GetItem", buf, sizeof( buf) )!=NULL) + { + okflg = NPC_QuizBorderLine(PLAYER.answer,buf); + if(okflg == -1) + { + + }else{ + + getStringFromIndexWithDelim(buf , "," , okflg+1, buf3, sizeof(buf3)); + if(NPC_QuizAddItem( talker, buf3) == FALSE) return ; + + } + } + + if(NPC_Util_GetStrFromStrWithDelim( argstr, "Border", buf, sizeof( buf) )!=NULL) + { + okflg = NPC_QuizBorderLine(PLAYER.answer,buf); + if(okflg == -1) + { + NPC_Util_GetStrFromStrWithDelim( argstr, "FailureMsg", + buf2,sizeof(buf2)); + + CHAR_talkToCli( talker, meindex, buf2, CHAR_COLORWHITE); + + }else{ + + getStringFromIndexWithDelim(buf , "," , okflg+1, buf2, sizeof(buf2)); + CHAR_talkToCli( talker, meindex, buf2, CHAR_COLORWHITE); + } + } + + + /*--ݩѱɱԪ---*/ + if(NPC_Util_GetStrFromStrWithDelim( argstr, "Warp", buf, sizeof( buf) )!=NULL) + { + warp_flg = NPC_QuizWarpBorderLine(PLAYER.answer,buf); + if(warp_flg != -1) { + char warpbuf[32]; + + getStringFromIndexWithDelim(buf , "," , warp_flg+1, buf2, sizeof(buf2)); + getStringFromIndexWithDelim(buf2 , "." , 1, warpbuf, sizeof(warpbuf)); + floor = atoi(warpbuf); + getStringFromIndexWithDelim(buf2 , "." , 2, warpbuf, sizeof(warpbuf)); + x = atoi(warpbuf); + getStringFromIndexWithDelim(buf2 , "." , 3, warpbuf, sizeof(warpbuf)); + y = atoi(warpbuf); + } + } + + + + avg = (double)PLAYER.answer / + CHAR_getWorkInt( meindex, CHAR_WORK_QUIZNUM) * 100; + + CHAR_setWorkInt( meindex, CHAR_WORK_PLAYER1 + + CHAR_getWorkInt( talker, CHAR_WORKSHOPRELEVANT) ,-1); + +// print("\n %s %d",CHAR_getChar(talker,CHAR_NAME),(int)PLAYER.ptr); + + free(PLAYER.ptr); + + if(warp_flg != -1){ + CHAR_warpToSpecificPoint(talker, floor, x, y); + } + return; + + } + + tbl = NPC_GetQuestion( meindex); + + + if( CHAR_getWorkInt( meindex, CHAR_WORK_QUIZNUM) > ( tbl[0] - 1)) + { + free(PLAYER.ptr); + return ; + } + + while(1){ + loop++; + i = rand()%( tbl[0]); + if(i == 0) continue; + questionno = tbl[i]; + + for( k = 0 ; k < OLDNO ; k++){ + if(PLAYER.oldno[k] == questionno) { + loop = 0; + break; + } + } + if(k == OLDNO) break; + + if(loop == 5000) { + print("ⲻiȫظj"); + break; + } + } + + p_no = CHAR_getWorkInt( talker, CHAR_WORKSHOPRELEVANT); + p_old = CHAR_getWorkInt( talker, CHAR_WORKSHOPRELEVANTSEC); + + PLAYER.quizno++; + + PLAYER.oldno[p_old] = questionno; + p_old++; + CHAR_setWorkInt( talker, CHAR_WORKSHOPRELEVANTSEC, p_old); + + strncpy( buf, Quiz[questionno].question, + sizeof( Quiz[questionno].question)); + + if(strlen( buf) < 40) { + strcat( buf, "\n"); + }else if(strlen( buf) > 79) { + len = 5; + } + + /*--ǩѨ--*/ + if( Quiz[questionno].answertype == 4) { + + if(strlen( buf) < 40) { + strcat( buf,"\n\n"); + }else if( strlen( buf) < 80) { + strcat( buf,"\n\n"); + }else{ + strcat( buf,"\n"); + } + + sprintf( token," quiz %d " + "\n%s " + "\nд\n" + "?(д밴ϣ)", + PLAYER.quizno, + buf); + + buttontype = WINDOW_BUTTONTYPE_OK; + messagetype = WINDOW_MESSAGETYPE_MESSAGEANDLINEINPUT; + windowno = CHAR_WINDOWTYPE_QUIZ_MAIN; + + /*--ػëƹ巤ʢ--*/ + memcpy(pl_ptr,&PLAYER,sizeof(struct pl)); + + break; + + }else if( Quiz[questionno].answertype == 2) { + char work1[128]; + char work2[128]; + char work3[128]; + + ans = (rand() % 3) + 1; + + ans = NPC_QuizRandAnswer(p_no,questionno,3, work1,work2,work3); + PLAYER.ansno = ans; + + sprintf(token,"%d\n quiz %d " + "\n%s " + "\n\n %s" + "\n %s" + "\n %s", + len, + PLAYER.quizno, + buf, + work1, + work2, + work3 + ); + + }else if( Quiz[questionno].answertype == 1){ + char work1[128]; + char work2[128]; + char work3[128]; + + strcpy(work3,"-1"); + ans = NPC_QuizRandAnswer(p_no,questionno,2, work1,work2,work3); + PLAYER.ansno = ans; + + sprintf(token,"%d\n quiz %d " + "\n%s " + "\n\n %s" + "\n %s", + len, + PLAYER.quizno, + buf, + work1, + work2 + ); + } + buttontype = WINDOW_BUTTONTYPE_CANCEL; + messagetype = WINDOW_MESSAGETYPE_SELECT; + windowno = CHAR_WINDOWTYPE_QUIZ_MAIN; + + memcpy(pl_ptr,&PLAYER,sizeof(struct pl)); + + } + break; + + case 4: + if(NPC_Util_GetArgStr( meindex, argstr, sizeof( argstr)) == NULL) + { + print("GetArgstrErr:Quiz %s",CHAR_getChar( meindex, CHAR_NAME)); + } + + if(NPC_Util_GetStrFromStrWithDelim( argstr,"Party", token, sizeof( token)) != NULL) + { + buttontype = WINDOW_BUTTONTYPE_OK; + messagetype = WINDOW_MESSAGETYPE_MESSAGE; + windowno = CHAR_WINDOWTYPE_QUIZ_START; + } + + break; + + } + + /*-ƥ˪--*/ + lssproto_WN_send( fd, messagetype, + buttontype, + windowno, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + token); +} + +void NPC_QuizWindowTalked( int meindex, int talkerindex, + int seqno, int select, char *data) +{ + int i=0; + int old_no; + + if( NPC_Util_CharDistance( talkerindex, meindex ) > 1) { + return; + } + switch( seqno){ + case CHAR_WINDOWTYPE_QUIZ_START: + if( select == WINDOW_BUTTONTYPE_YES) { + NPC_Quiz_selectWindow(meindex, talkerindex, 1); + } + + if(select == WINDOW_BUTTONTYPE_OK){ + } + + break; + + case CHAR_WINDOWTYPE_QUIZ_MAIN: + { + int point; + int *pl_ptr; + int p_no; + struct pl PLAYER; + + p_no = CHAR_getWorkInt( talkerindex, CHAR_WORKSHOPRELEVANT); + point = CHAR_getWorkInt( meindex, CHAR_WORK_PLAYER1 + p_no); + pl_ptr = (int *)point; + if(point < 0){ + CHAR_setWorkInt( meindex, CHAR_WORK_PLAYER1 + + CHAR_getWorkInt( talkerindex, CHAR_WORKSHOPRELEVANT) ,-1); + //free(PLAYER.ptr); + return; + } + //print("\nlen=%d,size=%d,point=%d\n",sizeof(pl_ptr),sizeof(struct pl),point); + memcpy(&PLAYER,pl_ptr,sizeof(struct pl)); + + p_no = CHAR_getWorkInt( talkerindex, CHAR_WORKSHOPRELEVANT); + old_no = CHAR_getWorkInt( talkerindex, CHAR_WORKSHOPRELEVANTSEC)-1; + i= PLAYER.oldno[old_no]; + + if(select == WINDOW_BUTTONTYPE_OK){ + if( i >= quizcnt || i < 0 ) return; + if( Quiz == NULL || strlen( Quiz[i].select1) >= 128 ) return; + + if( strstr( data, Quiz[i].select1) != NULL) { + PLAYER.answer++; + } + memcpy(pl_ptr,&PLAYER,sizeof(struct pl)); + NPC_Quiz_selectWindow(meindex, talkerindex, 2); + }else if(select == WINDOW_BUTTONTYPE_CANCEL){ + CHAR_setWorkInt( meindex, CHAR_WORK_PLAYER1 + + CHAR_getWorkInt( talkerindex, CHAR_WORKSHOPRELEVANT) ,-1); + free(PLAYER.ptr); + }else if( atoi( data) == 0){ + }else{ + if(atoi(data) == PLAYER.ansno){ + PLAYER.answer++; + } + memcpy(pl_ptr,&PLAYER,sizeof(struct pl)); + NPC_Quiz_selectWindow(meindex, talkerindex, 2); + } + } + break; + + } + + +} + +/* + *ʾĸ̼ + */ +int NPC_QuizBorderLine(int ans ,char *buf) +{ + char buf2[32]; + int j = 1; + int border; + + + while(getStringFromIndexWithDelim(buf , "," , j, buf2, sizeof( buf2)) + !=FALSE ) + { + border = atoi(buf2); + + if(ans >= border) { + return j; + } + + j += 2; + + } + return -1; +} +/* + *ʾĸ̼ + */ +int NPC_QuizWarpBorderLine(int ans ,char *buf) +{ + char buf2[32]; + int j = 1; + int border; + + + while(getStringFromIndexWithDelim(buf , "," , j, buf2, sizeof( buf2)) + != FALSE ) + { + border = atoi(buf2); + + if(ans >= border) { + return j; + } + + j += 2; + + } + return -1; +} + + +/* + */ +BOOL NPC_QuizAddItem(int talker,char *buf) +{ + int i=1; + int ret; + char buf2[16]; + int itemindex; + char token[512]; + + while(getStringFromIndexWithDelim(buf , "." , i, buf2, sizeof(buf2)) + != FALSE ) + { + i++; + } + i--; + if(i == 1){ + getStringFromIndexWithDelim(buf , "." , i, buf2, sizeof(buf2)); + }else{ + /*--¼ĸة--*/ + i = (rand() % i)+1; + getStringFromIndexWithDelim(buf , "." , i, buf2, sizeof(buf2)); + } + + itemindex = ITEM_makeItemAndRegist(atoi(buf2)); + + if(itemindex == -1) return FALSE; + + ret = CHAR_addItemSpecificItemIndex( talker, itemindex); + if( !CHAR_CHECKITEMINDEX( talker, ret) ){ + print( "npc_quiz.c: additem error itemindex[%d]\n", itemindex); + ITEM_endExistItemsOne( itemindex); + + CHAR_talkToCli( talker, -1, "", CHAR_COLORWHITE); + + return FALSE; + } + + if(itemindex != -1) { + LogItem( + CHAR_getChar( talker, CHAR_NAME ), /* ƽҷ */ + CHAR_getChar( talker, CHAR_CDKEY ), +#ifdef _add_item_log_name // WON ADD itemlogitem + itemindex, +#else + ITEM_getInt( itemindex, ITEM_ID), /* ʧ ة į */ +#endif + "QuizAddItem(->쵽ĵ)", + CHAR_getInt( talker, CHAR_FLOOR), + CHAR_getInt( talker, CHAR_X ), + CHAR_getInt( talker, CHAR_Y ), + ITEM_getChar( itemindex, ITEM_UNIQUECODE), + ITEM_getChar( itemindex, ITEM_NAME), + ITEM_getInt( itemindex, ITEM_ID) + ); + } + + sprintf(token,"õ%s", ITEM_getChar( itemindex, ITEM_NAME)); + CHAR_talkToCli( talker, -1, token, CHAR_COLORWHITE); + + + CHAR_sendItemDataOne( talker, ret); + return TRUE; + +} + +int NPC_QuizRandAnswer(int p_no,int q_no, int mode, + char *work1,char *work2,char *work3) +{ + int ans; + int ra; + + ans = (rand() % mode) + 1; + if(ans == 1) { + if( Quiz[q_no].answerNo == 1) { + strcpy( work1, Quiz[q_no].select1); + if(mode == 2) { + strcpy( work2, Quiz[q_no].select2); + return ans; + } + ra = rand()%2; + + if(ra == 0) { + strcpy( work2, Quiz[q_no].select2); + strcpy( work3, Quiz[q_no].select3); + }else{ + strcpy( work2, Quiz[q_no].select3); + strcpy( work3, Quiz[q_no].select2); + } + }else if( Quiz[q_no].answerNo == 2) { + strcpy( work1, Quiz[q_no].select2); + if(mode == 2) { + strcpy( work2, Quiz[q_no].select1); + return ans; + } + + ra = rand()%2; + if(ra == 0) { + strcpy( work2, Quiz[q_no].select1); + strcpy( work3, Quiz[q_no].select3); + }else{ + strcpy( work2, Quiz[q_no].select3); + strcpy( work3, Quiz[q_no].select1); + } + }else{ + strcpy( work1, Quiz[q_no].select3); + ra = rand()%2; + if(ra == 0) { + strcpy( work2, Quiz[q_no].select1); + strcpy( work3, Quiz[q_no].select2); + }else{ + strcpy( work2, Quiz[q_no].select1); + strcpy( work3, Quiz[q_no].select2); + } + } + }else if(ans == 2) { + if(Quiz[q_no].answerNo == 1) { + strcpy( work2, Quiz[q_no].select1); + if(mode == 2) { + strcpy( work1, Quiz[q_no].select2); + return ans; + } + ra=rand()%2; + if(ra == 0) { + strcpy( work1, Quiz[q_no].select2); + strcpy( work3, Quiz[q_no].select3); + }else { + strcpy( work1, Quiz[q_no].select3); + strcpy( work3, Quiz[q_no].select2); + } + }else if( Quiz[q_no].answerNo == 2) { + strcpy( work2, Quiz[q_no].select2); + if(mode == 2){ + strcpy( work1, Quiz[q_no].select1); + return ans; + } + ra = rand()%2; + if(ra == 0) { + strcpy( work1, Quiz[q_no].select1); + strcpy( work3, Quiz[q_no].select3); + }else { + strcpy( work1, Quiz[q_no].select3); + strcpy( work3, Quiz[q_no].select1); + } + }else { + strcpy( work2, Quiz[q_no].select3); + ra = rand()%2; + if(ra == 0) { + strcpy( work1, Quiz[q_no].select1); + strcpy( work3, Quiz[q_no].select2); + }else { + strcpy( work1, Quiz[q_no].select2); + strcpy( work3, Quiz[q_no].select1); + } + } + }else if(ans == 3) { + if( Quiz[q_no].answerNo == 1) { + strcpy( work3, Quiz[q_no].select1); + ra = rand()%2; + if(ra == 0) { + strcpy( work1, Quiz[q_no].select2); + strcpy( work2, Quiz[q_no].select3); + }else { + strcpy( work1, Quiz[q_no].select3); + strcpy( work2, Quiz[q_no].select2); + } + }else if( Quiz[q_no].answerNo == 2) { + strcpy( work3, Quiz[q_no].select2); + ra = rand()%2; + if(ra == 0) { + strcpy( work1, Quiz[q_no].select1); + strcpy( work2, Quiz[q_no].select3); + }else { + strcpy( work1, Quiz[q_no].select3); + strcpy( work2, Quiz[q_no].select1); + } + }else{ + strcpy( work3, Quiz[q_no].select3); + ra = rand()%2; + if(ra == 0) { + strcpy( work1, Quiz[q_no].select1); + strcpy( work2, Quiz[q_no].select2); + }else { + strcpy( work1, Quiz[q_no].select2); + strcpy( work2, Quiz[q_no].select1); + } + } + } + return ans; + +} + + +BOOL NPC_PlayerCheck(int meindex,int talker) + { + int i; + int k=0; + int *ptr; + struct pl Player; + + + NPC_RealyCheack( meindex, talker); + + for(i = 0 ; i < MEPLAYER ; i++){ + if( (CHAR_getWorkInt( meindex, CHAR_WORK_PLAYER1 +i ) == -1)) + { + break; + } + } + + if(i == MEPLAYER) return FALSE; + + + /*-- ƹ --*/ + if((ptr =(int *) calloc( 1,sizeof(struct pl))) == NULL){ + print("޷ȷ%s",CHAR_getChar(meindex,CHAR_NAME)); + return FALSE; + } + + /*-- ̼ë??-*/ + Player.ptr = ptr; + Player.talkerindex = talker; //npc̼͵??? + Player.quizno = 0; //ػ + Player.answer = 0; //ݩ + Player.ansno = 0; // įë ë±׶˱) + + for(k=0 ; k < OLDNO; k++) { + Player.oldno[k] = -1; + } + + /*--ƹë--*/ + memcpy(ptr,&Player,sizeof(struct pl)); + + + CHAR_setWorkInt( talker, CHAR_WORKSHOPRELEVANTSEC,0); + CHAR_setWorkInt( talker, CHAR_WORKSHOPRELEVANT,0); + CHAR_setWorkInt( talker, CHAR_WORKSHOPRELEVANTTRD,0); + + + CHAR_setWorkInt( talker, CHAR_WORKSHOPRELEVANT, i); + + k= (int)ptr; + CHAR_setWorkInt( meindex, CHAR_WORK_PLAYER1 + i, k ); + return TRUE; + +} + +int NPC_RealyCheack(int meindex,int talker) +{ + int fl, x, y; + int i, j; + int px[10] = {0, 1, 0,-1, 1,-1, 1, 0,-1}; + int py[10] = {0,-1,-1,-1, 0, 0, 1, 1, 1}; + int objindex; + + OBJECT object; + int talkerindex; + BOOL okflg = FALSE; + struct pl PLAYER; + int *pl_ptr; + int point; + + fl = CHAR_getInt( meindex, CHAR_FLOOR); + + for(j = 0 ; j < MEPLAYER ; j++) { + point = CHAR_getWorkInt( meindex, CHAR_WORK_PLAYER1 + j); + okflg = FALSE; + if(point == -1) continue; + + pl_ptr = (int *)point; + + memcpy(&PLAYER, pl_ptr, sizeof(struct pl)); + talkerindex = PLAYER.talkerindex; + + for(i=0 ; i < 10 ; i++) { + x = px[i] + CHAR_getInt( meindex, CHAR_X); + y = py[i] + CHAR_getInt( meindex, CHAR_Y); + + for(object = MAP_getTopObj(fl,x,y) ; object; + object = NEXT_OBJECT( object)) + { + objindex = GET_OBJINDEX( object); + + if( OBJECT_getType( objindex) == OBJTYPE_CHARA ){ + if( OBJECT_getIndex( objindex) == talkerindex) { + if(talkerindex == talker) { + okflg = TRUE; +// print("\n %s %d",CHAR_getChar(talker,CHAR_NAME),(int)PLAYER.ptr); + free(PLAYER.ptr); + CHAR_setWorkInt( meindex, CHAR_WORK_PLAYER1 + j,-1); + }else{ + okflg = TRUE; + } + break; + } + } + } + if(okflg == TRUE) break; + } + + if(okflg ==FALSE){ +// print("\n %s %d",CHAR_getChar(talker,CHAR_NAME),(int)PLAYER.ptr); + free(PLAYER.ptr); + CHAR_setWorkInt( meindex, CHAR_WORK_PLAYER1 + j,-1); + } + + } + + return -1; +} + +BOOL QUIZ_initQuiz( char *filename) +{ + + FILE* f; + char line[512]; + char buf2[512], buf3[128]; + char buf[512]; + int i, linenum=0; + f = fopen(filename,"r"); + if( f == NULL ){ + print( "file open error\n"); + return FALSE; + } + while( fgets( line, sizeof( line ), f ) ){ + if( line[0] == '#' )continue; + if( line[0] == '\n' )continue; + chomp( line ); + linenum ++; + quizcnt++; + } + + if( fseek( f, 0, SEEK_SET ) == -1 ){ + fprint( "Seek Error\n" ); + fclose(f); + return FALSE; + } + + Quiz = allocateMemory( sizeof(NPC_QUIZ) * (quizcnt+1) ); + if( Quiz == NULL ){ + fprint( "Can't allocate Memory %d\n", sizeof(Quiz) * (quizcnt+1)); + fclose( f ); + return FALSE; + } + linenum = 0; + memset( buf3, 0, sizeof(buf3)); + while( fgets( line, sizeof( line ), f ) ){ + if( line[0] == '#' )continue; + if( line[0] == '\n' )continue; + chomp( line ); + replaceString( line, '\t' , ' ' ); + for( i = 0; i < strlen( line); i ++) { + if( line[i] != ' ' ) { + break; + } + strcpy( buf, &line[i]); + } + if( i != 0 ) { + strcpy( line, buf); + } + + if( getStringFromIndexWithDelim( line, ",", 1, buf2, sizeof(buf2)) == FALSE ) continue; + Quiz[linenum].no = atoi(buf2); + + if( getStringFromIndexWithDelim( line, ",", 2, buf2, sizeof(buf2)) == FALSE ) continue; + Quiz[linenum].type = atoi(buf2); + + if( getStringFromIndexWithDelim( line, ",", 3, buf2, sizeof(buf2)) == FALSE ) continue; + Quiz[linenum].level = atoi(buf2); + + if( getStringFromIndexWithDelim( line, ",", 4, buf2, sizeof(buf2)) == FALSE ) continue; + Quiz[linenum].answertype = atoi(buf2); + + if( getStringFromIndexWithDelim( line, ",", 5, buf2, sizeof(buf2)) == FALSE ) continue; + Quiz[linenum].answerNo = atoi(buf2); + + if( getStringFromIndexWithDelim( line, ",", 6, buf2, sizeof(buf2)) == FALSE ) continue; + memcpy( Quiz[linenum].question, buf2, sizeof( Quiz[linenum].question)); + + + if( getStringFromIndexWithDelim( line, ",", 7, buf3, sizeof(buf3)) == FALSE ) continue; + memcpy( Quiz[linenum].select1, buf3, sizeof( Quiz[linenum].select1)); + if( getStringFromIndexWithDelim( line, ",", 8, buf3, sizeof(buf3)) == FALSE ) continue; + memcpy( Quiz[linenum].select2, buf3, sizeof( Quiz[linenum].select2)); + if( getStringFromIndexWithDelim( line, ",", 9, buf3, sizeof(buf3)) == FALSE ) continue; + memcpy( Quiz[linenum].select3, buf3, sizeof( Quiz[linenum].select3)); + + if(Quiz[linenum].answertype == 1){ + if(Quiz[linenum].answerNo == 3){ + return FALSE; + } + } + + if(Quiz[linenum].answertype == 4){ + if(Quiz[linenum].answerNo != 1){ + return FALSE; + } + } + linenum ++; +// quizcnt++; + } + if( quizcnt < linenum ){ + print("ERR linenum:%d >= quizcnt:%d\n", linenum, quizcnt); + return FALSE; + } + + quizcnt = linenum; + fclose( f); + return TRUE; + +} + +int *NPC_GetQuestion(int meindex) +{ + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + int i,j; + int type=0; + int answer=0; + int level=0; + int *tbl; + char buf[16]; + NPC_Util_GetArgStr( meindex, argstr, sizeof( argstr)); + + if(NPC_Util_GetStrFromStrWithDelim(argstr,"Type",buf, sizeof( buf)) != NULL ){ + type = atoi(buf); + } + if( type <= 0){ + type = 0xffff; + } + + if(NPC_Util_GetStrFromStrWithDelim( argstr, "Answer", buf, sizeof( buf)) != NULL){ + answer = atoi(buf); + } + if(answer <= 0){ + answer = 0xffff; + } + + if(NPC_Util_GetStrFromStrWithDelim( argstr, "Level", buf, sizeof( buf)) != NULL ){ + level = atoi(buf); + } + if(level <= 0){ + level = 0xffff; + } + for(j=0,i=0; i < quizcnt ;i++){ + if( (type & (1 << (Quiz[i].type-1))) != (1 << (Quiz[i].type-1))){ + continue; + } + if((answer & (Quiz[i].answertype)) != Quiz[i].answertype){ + continue; + } + if((level & (Quiz[i].level)) != Quiz[i].level){ + continue; + } + j++; + } + + { + int tmp_tbl[j+1]; + tmp_tbl[0] = j+1; + for(j=1,i=0; i < quizcnt ;i++){ + if( (type & (1 << (Quiz[i].type-1))) != (1 << (Quiz[i].type-1))){ + continue; + } + + if((answer & (Quiz[i].answertype)) != Quiz[i].answertype){ + continue; + } + + if((level & (Quiz[i].level)) != Quiz[i].level){ + continue; + } + tmp_tbl[j] = i; + + j++; + } + + tbl = tmp_tbl; + return tbl; + } +} + +BOOL NPC_QuizItemFullCheck(int meindex,int talker) +{ + int i; + int itemindex; + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + char buf2[32]; + + + for( i = CHAR_STARTITEMARRAY ; i < CHAR_MAXITEMHAVE ; i++ ) { + itemindex = CHAR_getItemIndex( talker , i ); + if( !ITEM_CHECKINDEX( itemindex) ) { + return TRUE; + } + } + + if(NPC_Util_GetArgStr( meindex, argstr, sizeof( argstr)) == NULL) + { + print("GetArgstrErr:Quiz %s",CHAR_getChar( meindex, CHAR_NAME)); + } + + if(NPC_Util_GetStrFromStrWithDelim( argstr,"EntryItem", buf2, sizeof( buf2)) != NULL) + { + if(NPC_EntryItemCheck( talker, buf2) == FALSE){ + NPC_Quiz_selectWindow( meindex, talker, 3); + return FALSE; + + }else{ + return TRUE; + } + } + + + return FALSE; + +} + + +/* + *ż + */ +BOOL NPC_EntryStoneCheck(int talker,char *buf) +{ + int stone; + int cost; + + cost= atoi( buf); + stone = CHAR_getInt( talker, CHAR_GOLD); + + if(cost > stone){ + return FALSE; + } + + return TRUE; +} + +/* + *ż + */ +BOOL NPC_EntryStoneDel(int talker,char *buf) +{ + int stone; + int cost; + char token[256]; + + cost= atoi( buf); + stone = CHAR_getInt( talker, CHAR_GOLD); + + if((stone-cost) < 0){ + CHAR_setInt( talker, CHAR_GOLD, 0); + }else{ + CHAR_DelGold( talker, cost ); + } + + sprintf( token, "%d stone", cost); + CHAR_talkToCli( talker, -1, token, CHAR_COLORWHITE); + + CHAR_send_P_StatusString( talker, CHAR_P_STRING_GOLD); + return TRUE; +} + + +/* + */ +BOOL NPC_EntryItemDel(int talker,char *buf) +{ + + int i = 1, j = 1,k = 1; + char buff3[128]; + char buf2[32]; + int itemindex; + + + while(getStringFromIndexWithDelim(buf , "," , k, buff3, sizeof(buff3)) !=FALSE ){ + k++; + if(strstr(buff3, "*") !=NULL){ + int itemno; + int kosuu; + int id; + int cnt=0; + getStringFromIndexWithDelim(buff3,"*",1,buf2,sizeof(buf2)); + itemno = atoi(buf2); + getStringFromIndexWithDelim(buff3,"*",2,buf2,sizeof(buf2)); + kosuu = atoi(buf2); + for( i =0 ; i < CHAR_MAXITEMHAVE ; i++ ){ + itemindex = CHAR_getItemIndex( talker , i ); + if( ITEM_CHECKINDEX(itemindex) ){ + id=ITEM_getInt(itemindex ,ITEM_ID ); + if(itemno==id){ + cnt++; + LogItem( + CHAR_getChar( talker, CHAR_NAME ), /* ƽҷ’o */ + CHAR_getChar( talker, CHAR_CDKEY ), +#ifdef _add_item_log_name // WON ADD itemlogitem + itemindex, +#else + ITEM_getInt( itemindex, ITEM_ID), /* ʧ̷ة?į */ +#endif + "QuizDelItem(->ĵ)", + CHAR_getInt( talker, CHAR_FLOOR), + CHAR_getInt( talker, CHAR_X ), + CHAR_getInt( talker, CHAR_Y ), + ITEM_getChar( itemindex, ITEM_UNIQUECODE), + ITEM_getChar( itemindex, ITEM_NAME), + ITEM_getInt( itemindex, ITEM_ID) + ); + + CHAR_DelItem( talker, i); + if(cnt == kosuu){ + break; + } + } + } + } + }else{ + for( j = 0 ; j < CHAR_MAXITEMHAVE ; j++){ + itemindex = CHAR_getItemIndex( talker ,j); + + if( ITEM_CHECKINDEX(itemindex) ){ + if( atoi( buff3) == ITEM_getInt(itemindex,ITEM_ID)){ + LogItem( + CHAR_getChar( talker, CHAR_NAME ), /* ƽҷ’o */ + CHAR_getChar( talker, CHAR_CDKEY ), +#ifdef _add_item_log_name // WON ADD itemlogitem + itemindex, +#else + ITEM_getInt( itemindex, ITEM_ID), /* ʧ̷ة?į */ +#endif + "QuizDelItem(->쵽ĵ)", + CHAR_getInt( talker,CHAR_FLOOR), + CHAR_getInt( talker,CHAR_X ), + CHAR_getInt( talker,CHAR_Y ), + ITEM_getChar( itemindex, ITEM_UNIQUECODE), + ITEM_getChar( itemindex, ITEM_NAME), + ITEM_getInt( itemindex, ITEM_ID) + ); + CHAR_DelItem( talker, j); + } + } + } + } + } + + return TRUE; +} + +/* + */ +BOOL NPC_EntryItemCheck(int talker,char *buf) +{ + + char buf2[512]; + char buf3[256]; + int id=0; + BOOL flg = FALSE; + int i; + int itemindex; + int itemno; + int kosuu; + int cnt=0; + int k=1; + + while(getStringFromIndexWithDelim(buf , "," , k, buf2, sizeof(buf2)) + !=FALSE ) + { + flg = FALSE; + k++; + + if(strstr(buf2,"*") != NULL){ + cnt = 0; + getStringFromIndexWithDelim(buf2,"*",1,buf3,sizeof(buf3)); + itemno = atoi(buf3); + getStringFromIndexWithDelim(buf2,"*",2,buf3,sizeof(buf3)); + kosuu = atoi(buf3); + + for( i=0 ; i < CHAR_MAXITEMHAVE;i++ ){ + itemindex = CHAR_getItemIndex( talker , i ); + if( ITEM_CHECKINDEX(itemindex) ){ + id = ITEM_getInt(itemindex ,ITEM_ID ); + if(itemno == id){ + cnt++; + if(cnt == kosuu){ + flg = TRUE; + break; + } + } + } + } + if(flg == FALSE) + { + return FALSE; + } + }else{ + itemno = atoi(buf2); + + for( i=0 ; i < CHAR_MAXITEMHAVE;i++ ){ + itemindex = CHAR_getItemIndex( talker , i ); + if( ITEM_CHECKINDEX(itemindex) ){ + id = ITEM_getInt(itemindex ,ITEM_ID ); + if(itemno == id){ + flg = TRUE; + break; + } + } + } + + if(flg == FALSE) + { + return FALSE; + } + } + } + + return TRUE; + +} + +/* + */ +BOOL NPC_QUIZPARTY_CHAECK(int meindex,int talker) +{ + + if(CHAR_getWorkInt(talker,CHAR_WORKPARTYMODE) != CHAR_PARTY_NONE){ + return FALSE; + } + + return TRUE; + +} + diff --git a/npc/npc_riderman.c b/npc/npc_riderman.c new file mode 100644 index 0000000..c314fd4 --- /dev/null +++ b/npc/npc_riderman.c @@ -0,0 +1,887 @@ +#include "version.h" +#include +#include "char.h" +#include "object.h" +#include "char_base.h" +#include "npcutil.h" +#include "configfile.h" +#include "lssproto_serv.h" +#include "saacproto_cli.h" +#include "npc_riderman.h" +#include "family.h" +#include "log.h" + +extern int familyNumTotal; +extern char familyListBuf[MAXFAMILYLIST]; +extern tagRidePetTable ridePetTable[296]; +extern struct FM_POINTLIST fmpointlist; + +char sendbuf[1024]; +char buf[1024]; +char subbuf[128]; +int i, j; + +/* + * ɬýľūëNPC + * + */ + +struct { + int windowno; + int windowtype; + int buttontype; + int takeitem; + int giveitem; + int takegold; + char message[4096]; + int letter[4]; +}w; + +struct { + BOOL use; + int checkhaveitem; + int checkhaveitemgotowin; + int checkdonthaveitem; + int checkdonthaveitemgotowin; + int warp; + int battle; + int gotowin; +}buttonproc[13]; /* ok,cancel, yes,no,prev,next ݼ */ + + + + + +enum { + CHAR_WORK_MSGCOLOR = CHAR_NPCWORKINT1, +}; + +static void NPC_Riderman_selectWindow( int meindex, int toindex, int num); +static BOOL NPC_Riderman_readData( int meindex, int windowno, BOOL chkflg); +static int NPC_Riderman_restoreButtontype( char *data ); +// static BOOL getLetter(int meindex,int talker ); +// static BOOL checkLetter(int meindex,int talker ); + +/********************************* +*********************************/ +BOOL NPC_RidermanInit( int meindex ) +{ + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + char buf[1024]; + //int i; + //char secondToken[1024]; + + // Robin test + // print(" riderman_Init "); + + NPC_Util_GetArgStr( meindex, argstr, sizeof( argstr)); + + if( NPC_Util_GetStrFromStrWithDelim( argstr, "conff", buf, sizeof( buf))== NULL ) + { + print( "riderman:ûָ趨ĵ \n"); + return FALSE; + } + /* ݱɬ÷ëƻ֧ */ + if( !NPC_Riderman_readData( meindex, -1, TRUE) ) { + return FALSE; + } + + CHAR_setInt( meindex , CHAR_WHICHTYPE , CHAR_TYPEWINDOWMAN ); + + return TRUE; +} + + + + +/********************************* +*********************************/ +void NPC_RidermanTalked( int meindex , int talkerindex , char *szMes ,int color ) +{ + //print(" Rideman_fmindex:%d ", CHAR_getInt( meindex, CHAR_FMINDEX) ); + + NPC_Riderman_selectWindow( meindex, talkerindex, 1 ); + +} +/********************************* +*********************************/ +void NPC_RidermanLooked( int meindex , int lookedindex) +{ + + //print(" Look:me:%d,looked:%d ",meindex,lookedindex); + NPC_Riderman_selectWindow( meindex, lookedindex,1 ); + +} + +static void NPC_Riderman_selectWindow( int meindex, int toindex, int num) +{ + + int fd; + char buf[256]; + + if( CHAR_getInt( toindex , CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER ) { + return; + } + if( !NPC_Util_charIsInFrontOfChar( toindex, meindex, 1 )) return; + + if( !NPC_Riderman_readData( meindex, num, FALSE) ) { + print( "riderman:readdata error\n"); + return; + } + + fd = getfdFromCharaIndex( toindex); + if( fd != -1 ) { + lssproto_WN_send( fd, w.windowtype, + w.buttontype, + w.windowno+100, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + makeEscapeString( w.message, buf, sizeof(buf))); + } +} + +void NPC_RidermanWindowTalked( int meindex, int talkerindex, + int seqno, int select, char *data) + +{ + + + int button = -1; + char buf[512]; + + if( NPC_Util_CharDistance( talkerindex, meindex ) > 1) return; + + if( !NPC_Riderman_readData( meindex, seqno - 100, FALSE) ) { + print( "riderman:readdata error\n"); + return; + } + /* ʾëƩ */ + if( w.windowtype == WINDOW_MESSAGETYPE_SELECT ) { + button = atoi( data)+5; + if( button > 12 ) { + print( "riderman:invalid button[%d]\n", button); + return; + } + } + else if( select & WINDOW_BUTTONTYPE_OK) button = 0; + else if( select & WINDOW_BUTTONTYPE_CANCEL) button = 1; + else if( select & WINDOW_BUTTONTYPE_YES) button = 2; + else if( select & WINDOW_BUTTONTYPE_NO) button = 3; + else if( select & WINDOW_BUTTONTYPE_PREV) button = 4; + else if( select & WINDOW_BUTTONTYPE_NEXT) button = 5; + else { + print( "riderman:invalid button[%d]\n", select); + return; + } + if( buttonproc[button].use == TRUE ) { + int fd; + int newwin = -1; + + fd = getfdFromCharaIndex( talkerindex); + + if( newwin == -1 ) { + newwin = buttonproc[button].gotowin; + } + + + //print(" takegold:%d ", w.takegold ); + + // Robin + // ѧϰ Lv 40 + if( newwin == 6 ) { + + int charImg; + // int i, petindex, bFind = 0; + + charImg = CHAR_getInt( talkerindex, CHAR_BASEBASEIMAGENUMBER); + if( CHAR_getInt( talkerindex, CHAR_LEARNRIDE ) >= 40 ) + { + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, -1, -1, + makeEscapeString( "\n\nѾѧѽ\nҪѧˡ", + buf, sizeof(buf))); + return; + } + + if( CHAR_getInt( talkerindex, CHAR_GOLD ) < w.takegold ) + { + char buf2[512]; + + sprintf( buf2, "\nܱǸรѧѲ㣡\nѧϰ˳Ҫ%dʯҡ", w.takegold); + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, -1, -1, + makeEscapeString( buf2, buf, sizeof(buf))); + return; + } + CHAR_DelGold( talkerindex, w.takegold ); + + CHAR_setInt( talkerindex, CHAR_LEARNRIDE, 40 ); + CHAR_send_P_StatusString( talkerindex, CHAR_P_STRING_GOLD ); + CHAR_send_P_StatusString( talkerindex, CHAR_P_STRING_LEARNRIDE ); + + //sprintf( buf, "R|L|1" ); + //lssproto_FM_send( fd, buf ); + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, -1, -1, + makeEscapeString( + "\n\nϲ㣡Ѿ˳ˡ\n Lv40 µij\nСร", + buf, sizeof(buf))); + + // + { + int fmindex, fmindexi, village, i; + char fmname[256], token[256], buf2[64]; + + sprintf( buf2, "%d", w.takegold/5 ); + for( i=0 ; i= 80 ) + { + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, -1, -1, + makeEscapeString( "\n\nѾѧмѽ\nҪѧˡ", + buf, sizeof(buf))); + return; + } + else if( CHAR_getInt( talkerindex, CHAR_LEARNRIDE ) < 40 ) + { + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, -1, -1, + makeEscapeString( "\n\nѧмࡡ", + buf, sizeof(buf))); + return; + } + + if( CHAR_getInt( talkerindex, CHAR_GOLD ) < w.takegold ) + { + char buf2[512]; + + sprintf( buf2, "\nܱǸรѧѲ㣡\nѧϰ˳мҪ%dʯ", w.takegold); + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, -1, -1, + makeEscapeString( buf2, buf, sizeof(buf))); + return; + } + CHAR_DelGold( talkerindex, w.takegold ); + + CHAR_setInt( talkerindex, CHAR_LEARNRIDE, 80 ); + CHAR_send_P_StatusString( talkerindex, CHAR_P_STRING_GOLD ); + CHAR_send_P_StatusString( talkerindex, CHAR_P_STRING_LEARNRIDE ); + + //sprintf( buf, "R|L|1" ); + //lssproto_FM_send( fd, buf ); + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, -1, -1, + makeEscapeString( "\n\nϲ㣡Ѿмˡ\n Lv80 µij\nСร", + buf, sizeof(buf))); + + // + { + int fmindex, fmindexi, village, i; + char fmname[256], token[256], buf2[64]; + + sprintf( buf2, "%d", w.takegold/5 ); + for( i=0 ; i= 120 ) + { + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, -1, -1, + makeEscapeString( "\n\nѾѧ߼ѽ\nҪѧˡ", + buf, sizeof(buf))); + return; + } + else if( CHAR_getInt( talkerindex, CHAR_LEARNRIDE ) < 80 ) + { + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, -1, -1, + makeEscapeString( "\n\nѧм߼ࡡ", + buf, sizeof(buf))); + return; + } + + if( CHAR_getInt( talkerindex, CHAR_GOLD ) < w.takegold ) + { + char buf2[512]; + + sprintf( buf2, "\nܱǸรѧѲ㣡\nѧϰ˳߼Ҫ%dʯ", w.takegold); + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, -1, -1, + makeEscapeString( buf2, buf, sizeof(buf))); + return; + } + CHAR_DelGold( talkerindex, w.takegold ); + + CHAR_setInt( talkerindex, CHAR_LEARNRIDE, 120 ); + CHAR_send_P_StatusString( talkerindex, CHAR_P_STRING_GOLD ); + CHAR_send_P_StatusString( talkerindex, CHAR_P_STRING_LEARNRIDE ); + + //sprintf( buf, "R|L|1" ); + //lssproto_FM_send( fd, buf ); + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, -1, -1, + makeEscapeString( "\n\nϲ㣡Ѿ˸߼ˡ\n Lv120 µij\nСร", + buf, sizeof(buf))); + + // + { + int fmindex, fmindexi, village, i; + char fmname[256], token[256], buf2[64]; + + sprintf( buf2, "%d", w.takegold/5 ); + for( i=0 ; i 199 ) + { + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, -1, -1, + makeEscapeString( "\n\nѾѧؼѽ\nҪѧˡ", + buf, sizeof(buf))); + return; + } + else if( CHAR_getInt( talkerindex, CHAR_LEARNRIDE ) < 120 ) + { + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, -1, -1, + makeEscapeString( "\n\nѧ߼ؼࡡ", + buf, sizeof(buf))); + return; + } + + if( CHAR_getInt( talkerindex, CHAR_GOLD ) < w.takegold ) + { + char buf2[512]; + + sprintf( buf2, "\nܱǸรѧѲ㣡\nѧϰ˳ؼҪ%dʯ", w.takegold); + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, -1, -1, + makeEscapeString( buf2, buf, sizeof(buf))); + return; + } + CHAR_DelGold( talkerindex, w.takegold ); + + CHAR_setInt( talkerindex, CHAR_LEARNRIDE, 200 ); + CHAR_send_P_StatusString( talkerindex, CHAR_P_STRING_GOLD ); + CHAR_send_P_StatusString( talkerindex, CHAR_P_STRING_LEARNRIDE ); + + //sprintf( buf, "R|L|1" ); + //lssproto_FM_send( fd, buf ); + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, -1, -1, + makeEscapeString( "\n\nϲ㣡Ѿؼˡ\nеȼij\nСร", + buf, sizeof(buf))); + + // + { + int fmindex, fmindexi, village, i; + char fmname[256], token[256], buf2[64]; + + sprintf( buf2, "%d", w.takegold/5 ); + for( i=0 ; i +#include "char.h" +#include "object.h" +#include "char_base.h" +#include "npcutil.h" +#include "npc_rmbshop.h" +#include "lssproto_serv.h" +#include "saacproto_cli.h" +#include "readmap.h" +#include "battle.h" +#include "log.h" +#include "enemy.h" +#include "handletime.h" +#include "npc_eventaction.h" + +//صشøнڽ"ʦ" +#ifdef _RMB_SYSTEM +enum { + WINDOW_START=1, + WINDOW_SELECT, + WINDOW_PREV, + WINDOW_NEXT, + WINDOW_WARP, + WINDOW_END, +}; +enum { + NPC_WORK_CURRENTTIME = CHAR_NPCWORKINT1, +/* + NPC_WORK_ROUTETOY = CHAR_NPCWORKINT2, + NPC_WORK_ROUTEPOINT = CHAR_NPCWORKINT3, + NPC_WORK_ROUNDTRIP = CHAR_NPCWORKINT4, + NPC_WORK_MODE = CHAR_NPCWORKINT5, + NPC_WORK_CURRENTROUTE = CHAR_NPCWORKINT6, + NPC_WORK_ROUTEMAX = CHAR_NPCWORKINT7, + NPC_WORK_WAITTIME = CHAR_NPCWORKINT8, + NPC_WORK_CURRENTTIME = CHAR_NPCWORKINT9, + NPC_WORK_SEFLG = CHAR_NPCWORKINT10, +*/ +}; + +#define STANDBYTIME 50 + +static void NPC_RmbShop_selectWindow( int meindex, int toindex, int num,int select); +BOOL RmbShop_GetMenuStr( int meindex, int toindex, char *npcarg, char *token, int index ); +int RmbShop_ShowMenulist( char *npcarg ); + +int page; + +BOOL NPC_RmbshopInit( int meindex ) +{ + char npcarg[NPC_UTIL_GETARGSTR_BUFSIZE]; + + if(NPC_Util_GetArgStr( meindex, npcarg, sizeof(npcarg))==NULL){ + print("TRANSER_MAN: GetArgStrErr!!"); + return FALSE; + } + + CHAR_setInt( meindex, CHAR_WHICHTYPE, CHAR_TRANSERMANS); + + //CHAR_setInt( meindex, CHAR_LOOPINTERVAL, NEWNPCMAN_STANDBY); + CHAR_setWorkInt( meindex, NPC_WORK_CURRENTTIME, NowTime.tv_sec); + return TRUE; +} +//CHAR_setWorkInt(talkerindex,CHAR_WORKSHOPRELEVANT,1); +void NPC_RmbshopTalked( int meindex, int talkerindex, char *msg, int color ) +{ + if( CHAR_getInt( talkerindex , CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER ) + return; + if(NPC_Util_isFaceToFace( meindex ,talkerindex , 2) == FALSE) { + if(NPC_Util_isFaceToChara( talkerindex, meindex, 1) == FALSE) + return; + } + + CHAR_setWorkInt( talkerindex, CHAR_WORKSHOPRELEVANT, 0); + NPC_RmbShop_selectWindow( meindex, talkerindex, WINDOW_START, 0); +} + +void NPC_RmbshopWindowTalked( int meindex, int talkerindex, int seqno, + int select, char *data) +{ + if( select == WINDOW_BUTTONTYPE_CANCEL || select == WINDOW_BUTTONTYPE_NO) + return; + switch( seqno) { + case NPC_TRANSERMAN_START: + break; + case NPC_TRANSERMAN_SELECT: + NPC_RmbShop_selectWindow( meindex, talkerindex, WINDOW_SELECT, atoi( data)); + break; + case NPC_TRANSERMAN_WARP: + if( select == WINDOW_BUTTONTYPE_CANCEL ) + return; + if( select == WINDOW_BUTTONTYPE_NEXT ) + { + NPC_RmbShop_selectWindow( meindex, talkerindex, WINDOW_NEXT, atoi( data)); + return; + } + if( select == WINDOW_BUTTONTYPE_PREV ) + { + NPC_RmbShop_selectWindow( meindex, talkerindex, WINDOW_PREV, atoi( data)); + return; + } + NPC_RmbShop_selectWindow( meindex, talkerindex, WINDOW_WARP, atoi( data)); + break; + case NPC_TRANSERMAN_END: + NPC_RmbShop_selectWindow( meindex, talkerindex, WINDOW_END, atoi( data)); + break; + } + +} + +static void NPC_RmbShop_selectWindow( int meindex, int toindex, int num,int select) +{ + char npcarg[NPC_UTIL_GETARGSTR_BUFSIZE]; + char token[1024]; + char buf1[256]; + char buf2[256]; + char buf3[256]; + int buttontype = 0, windowtype = 0, windowno = 0; + int fd = getfdFromCharaIndex( toindex); + static int select1; + windowtype = WINDOW_MESSAGETYPE_MESSAGE; + + if(NPC_Util_isFaceToFace( meindex ,toindex , 2) == FALSE) { + if(NPC_Util_isFaceToChara( toindex, meindex, 1) == FALSE) + return; + } + + memset( npcarg, 0, sizeof( npcarg)); + if(NPC_Util_GetArgStr( meindex, npcarg, sizeof(npcarg))==NULL){ + print("RmbShop_MAN: GetArgStrErr!!"); + return; + } + memset( token, 0, sizeof( token)); + + switch( num) { + case WINDOW_START: + if( NPC_Util_GetStrFromStrWithDelim( npcarg, "START_MSG", token, sizeof( token) ) == NULL) { + print("RmbShop Get START_MSG ERROR !"); + return; + } + CHAR_setWorkInt( toindex, CHAR_WORKSHOPRELEVANT, WINDOW_START); + buttontype = WINDOW_BUTTONTYPE_YESNO; + windowno = NPC_TRANSERMAN_SELECT; + break; + case WINDOW_SELECT: + CHAR_setWorkInt( toindex, CHAR_WORKLISTPAGE, 0); + page=RmbShop_ShowMenulist(npcarg); + if( RmbShop_GetMenuStr( meindex, toindex, npcarg, token,CHAR_getWorkInt( toindex, CHAR_WORKLISTPAGE)) == FALSE ) { + print( "RmbShop GetMenu ERROR !!"); + return; + } + windowtype = WINDOW_MESSAGETYPE_SELECT; + if(page>1) + buttontype = WINDOW_BUTTONTYPE_CANCEL|WINDOW_BUTTONTYPE_NEXT; + else + buttontype = WINDOW_BUTTONTYPE_CANCEL; + windowno = NPC_TRANSERMAN_WARP; + break; + case WINDOW_NEXT: + if(CHAR_getWorkInt( toindex, CHAR_WORKLISTPAGE)<=page) + CHAR_setWorkInt( toindex, CHAR_WORKLISTPAGE, CHAR_getWorkInt( toindex, CHAR_WORKLISTPAGE)+1); + if( RmbShop_GetMenuStr( meindex, toindex, npcarg, token,CHAR_getWorkInt( toindex, CHAR_WORKLISTPAGE)) == FALSE ) { + print( "RmbShop GetMenu ERROR !!"); + return; + } + windowtype = WINDOW_MESSAGETYPE_SELECT; + if(CHAR_getWorkInt( toindex, CHAR_WORKLISTPAGE)+1==page) + buttontype = WINDOW_BUTTONTYPE_CANCEL|WINDOW_BUTTONTYPE_PREV; + else + buttontype = WINDOW_BUTTONTYPE_CANCEL|WINDOW_BUTTONTYPE_PREV|WINDOW_BUTTONTYPE_NEXT; + windowno = NPC_TRANSERMAN_WARP; + break; + case WINDOW_PREV: + if(CHAR_getWorkInt( toindex, CHAR_WORKLISTPAGE)>0) + CHAR_setWorkInt( toindex, CHAR_WORKLISTPAGE, CHAR_getWorkInt( toindex, CHAR_WORKLISTPAGE)-1); + if( RmbShop_GetMenuStr( meindex, toindex, npcarg, token,CHAR_getWorkInt( toindex, CHAR_WORKLISTPAGE)) == FALSE ) { + print( "RmbShop GetMenu ERROR !!"); + return; + } + windowtype = WINDOW_MESSAGETYPE_SELECT; + if(CHAR_getWorkInt( toindex, CHAR_WORKLISTPAGE)==0) + buttontype = WINDOW_BUTTONTYPE_CANCEL|WINDOW_BUTTONTYPE_NEXT; + else + buttontype = WINDOW_BUTTONTYPE_PREV|WINDOW_BUTTONTYPE_CANCEL|WINDOW_BUTTONTYPE_NEXT; + windowno = NPC_TRANSERMAN_WARP; + break; + case WINDOW_WARP: + select1=CHAR_getWorkInt( toindex, CHAR_WORKLISTPAGE)*7+select; + CHAR_setWorkInt( toindex, CHAR_WORKLISTSELECT , select1); + if( NPC_Util_GetStrFromStrWithDelim( npcarg, "END_MSG", buf1, sizeof( buf1) ) == NULL) { + print("RmbShop Get START_MSG ERROR !"); + return; + } + if(getStringFromIndexWithDelim( npcarg,"}",select1, buf2, sizeof( buf2)) != FALSE) + NPC_Util_GetStrFromStrWithDelim( buf2, "MenuStr", buf3, sizeof( buf3)); + sprintf( token, "\n%s\n\n %s\n",buf1, buf3); + + windowtype = WINDOW_MESSAGETYPE_MESSAGE; + buttontype = WINDOW_BUTTONTYPE_YESNO; + windowno = NPC_TRANSERMAN_END; + break; + case WINDOW_END: + ActionNpc_CheckMenuFree( meindex, toindex, npcarg, CHAR_getWorkInt( toindex, CHAR_WORKLISTSELECT )); + return; + break; + } + + lssproto_WN_send( fd, windowtype, buttontype, windowno, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), token); +} + + +void NPC_RmbshopLoop( int meindex) +{ + +} + +BOOL RmbShop_GetMenuStr( int meindex, int toindex, char *npcarg, char *token,int index ) +{ + char buf1[1024], buf2[32], buf3[36]; + BOOL FINDS=FALSE; + int talkNo=index*7+1; + if( npcarg == NULL ) return FALSE; + + sprintf( token, "㵱ǰֽ:%d %d/%dҳ\n",sasql_rmbpoint(CHAR_getUseID(toindex),0,0), index+1, page); + while( getStringFromIndexWithDelim( npcarg,"}",talkNo, buf1, sizeof( buf1)) != FALSE ) { + talkNo++; + memset( buf2, 0, sizeof( buf2)); + if( NPC_Util_GetStrFromStrWithDelim( buf1, "MenuStr", buf2, sizeof( buf2)) == NULL ) + continue; + FINDS = TRUE; + + sprintf( buf3, " %s", buf2); + if(strlen(buf3)<10) + strcat( buf3, "\n"); + else + strcat( buf3, "\n"); + strcat( token, buf3); + if(talkNo>(index*7+7))return FINDS; + } + return FINDS; +} + +int RmbShop_ShowMenulist( char *npcarg ) +{ + char buf1[1024]; + int talkNo=1; + while( getStringFromIndexWithDelim( npcarg,"}",talkNo, buf1, sizeof( buf1)) != FALSE ) { + talkNo++; + } + return (talkNo-3)/7+1; +} + +#endif + + diff --git a/npc/npc_roomadminnew.c b/npc/npc_roomadminnew.c new file mode 100644 index 0000000..c6b7c20 --- /dev/null +++ b/npc/npc_roomadminnew.c @@ -0,0 +1,967 @@ +#include "version.h" + +#include +#include +#include +#include +#include + +#include "object.h" +#include "char.h" +#include "char_base.h" +#include "char_data.h" +#include "net.h" +#include "npcutil.h" +#include "handletime.h" +#include "readmap.h" +#include "npc_roomadminnew.h" +#include "npc_door.h" + + +/* + * + */ + + +enum{ + CHAR_WORKINT_RANGE = CHAR_NPCWORKINT1, + /* ݼ */ + CHAR_WORKINT_NEXTTIME = CHAR_NPCWORKINT2, + CHAR_WORKINT_PRINTCLOSETIME = CHAR_NPCWORKINT3, + CHAR_WORKINT_SEARCHROOMTIME = CHAR_NPCWORKINT4, + +}; +enum { + CHAR_WORKCHAR_MYNAME = CHAR_NPCWORKCHAR1, + CHAR_WORKCHAR_NEXTROOM = CHAR_NPCWORKCHAR2, + +}; + +enum { + CHAR_WORKCHAR_ADMNAME = CHAR_NPCWORKCHAR1, +}; + + +#define NPC_ROOMADMINNEW_DATADIR "roomadmin/" +/* ̻P */ +#define NPC_ROOMADMINNEW_EXTENSION ".room" +#define NPC_ROOMADMINNEW_RANKING_EXTENSION ".score" +#define NPC_ROOMADMINNEW_RANKING_EXTENSION_TMP ".score.tmp" +#define NPC_ROOMADMINNEW_SCOREFILE ".score" +#define NPC_ROOMADMINNEW_PRINTCLOSETIME_DEFAULT 5 + +#define NPC_ROOMADMINNEW_MSG_CLOSE_BEFORE \ +"%s %s %sĻֹ%dǰ" +#define NPC_ROOMADMINNEW_MSG_CLOSE \ +"ѽֹ" +#define NPC_ROOMADMINNEW_MSG_NONE \ +"ܿϧû˻÷ӵȨ" +#define NPC_ROOMADMINNEW_MSG_CONGRATULATION \ +"ϲ%s÷Ȩ%sĽǮȫˡ%sԱѯʷ䰵š" +#define NPC_ROOMADMINNEW_MSG_PRINTPASSWD_NONE \ +"δзûаš" +#define NPC_ROOMADMINNEW_MSG_DSPPASSWD1 \ +"ķ %s %s %s" +#define NPC_ROOMADMINNEW_MSG_DSPPASSWD2 \ +"İ %s ֻҪڶ˵ʱβϡ...˾Ϳࡣ" +#define NPC_ROOMADMINNEW_MSG_DSPNEXTAUCTION_NONE \ +"յĻ" +#define NPC_ROOMADMINNEW_MSG_DSPNEXTAUCTION1 \ +"ķ %s %s %s" +#define NPC_ROOMADMINNEW_MSG_DSPNEXTAUCTION2 \ +"ֹ %d:%d ֹΪֹ%2dСʱ%02d֡" +#define NPC_ROOMADMINNEW_MSG_DSPNEXTAUCTION3 \ +"͵ñ %s " + +#define NPC_ROOMADMINNEW_MSG_RANKING_INFO \ +"Ǹ߶ñа" +#define NPC_ROOMADMINNEW_MSG_RANKING \ +"Rank %2d:%4d/%02d/%02d %8d GOLD %s%s " + +/* NPC */ +#define NPC_ROOMADMINNEW_MSGCOLOR CHAR_COLORWHITE +#define NPC_RANKING_MSGCOLOR CHAR_COLORWHITE +#define NPC_ROOMADMINNEW_2WEEK 60*60*24*14 + +static void NPC_RoomAdminNew_DspNextAuction( int meindex, int talkerindex); +static void NPC_RoomAdminNew_DspRoomPasswd( int meindex, int adminindex, int talkerindex); +static BOOL NPC_RoomAdminNew_SetNextAuction( int meindex); +static BOOL NPC_RoomAdminNew_WriteDataFile( int meindex, int pindex, char *roomname, + char *passwd, BOOL flg); +static void NPC_RoomAdminNew_CreatePasswd( char *passwd, int passlen); +static void NPC_RoomAdminNew_SendMsgThisFloor( int index, char *buff); +static int NPC_RoomAdminNew_SearchPlayerHasMostMoney( int meindex); +static void NPC_RoomAdminNew_CloseProc( int meindex); +static int NPC_RoomAdminNew_WriteScoreFile( int meindex, int pindex); +static void NPC_RoomAdminNew_ReadScoreFile( int meindex, int talkerindex, + char *admname); + +/************************************************ + ************************************************/ +BOOL NPC_RoomAdminNewInit( int meindex ) +{ + int i; + char buf[256]; + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + + for( i = 3; ; i ++ ) { + if( getStringFromIndexWithDelim(argstr, "|" , i , buf,sizeof(buf) )) { + if( NPC_DoorSearchByName( buf) < 0 ) { + print( "admin not created.֮ǰȵȴ\n"); + return FALSE; + } + } + else{ + break; + } + } + + NPC_Util_GetArgStr( meindex, argstr, sizeof( argstr)); + + + /* type */ + CHAR_setInt( meindex, CHAR_WHICHTYPE, CHAR_TYPEROOMADMIN); + getStringFromIndexWithDelim(argstr, "|" , 1 , buf,sizeof(buf) ); + CHAR_setWorkInt( meindex , CHAR_WORKINT_RANGE , atoi( buf )); + if( !getStringFromIndexWithDelim(argstr, "|" , 2 , buf,sizeof(buf) )) { + print( "arg err.admin not created.\n"); + return( FALSE); + } + CHAR_setWorkChar( meindex , CHAR_WORKCHAR_MYNAME , buf); + + CHAR_setWorkInt( meindex, CHAR_WORKINT_PRINTCLOSETIME, 0); + + NPC_RoomAdminNew_SetNextAuction( meindex); + + return TRUE; +} +/************************************************ + ************************************************/ +void NPC_RoomAdminNewLoop( int meindex ) +{ + int hun; + if( CHAR_getWorkInt( meindex, CHAR_WORKINT_NEXTTIME) == 0 ) { + struct tm tm1,tm2; + time_t t; + memcpy( &tm1, localtime( (time_t *)&NowTime.tv_sec), sizeof( tm1)); + t = CHAR_getWorkInt( meindex, CHAR_WORKINT_SEARCHROOMTIME); + memcpy( &tm2, localtime( &t), + sizeof( tm2)); + if( tm1.tm_year != tm2.tm_year || + tm1.tm_mday != tm2.tm_mday || + tm1.tm_mon != tm2.tm_mon ) + { + NPC_RoomAdminNew_SetNextAuction( meindex); + } + return; + } + + hun = ceil((double)(CHAR_getWorkInt( meindex, CHAR_WORKINT_NEXTTIME) - + NowTime.tv_sec) / 60.0); + if( hun < 0 ) hun = 0; + + if( hun < NPC_ROOMADMINNEW_PRINTCLOSETIME_DEFAULT ) { + if( hun != CHAR_getWorkInt( meindex, CHAR_WORKINT_PRINTCLOSETIME)) { + char buff[256]; + if( hun != 0 ) { + char buf2[1024]; + char msgbuff[16]; + char argstr2[NPC_UTIL_GETARGSTR_BUFSIZE]; + int doorindex; + + doorindex = NPC_DoorSearchByName( CHAR_getWorkChar( meindex, CHAR_WORKCHAR_NEXTROOM)); + NPC_Util_GetArgStr( doorindex, argstr2, sizeof( argstr2)); + getStringFromIndexWithDelim( argstr2, "|" , 9 , + buf2,sizeof(buf2) ); + if( strlen(CHAR_getChar( doorindex, CHAR_NAME) ) != 0 ) { + strcpy( msgbuff, ""); + } + else { + msgbuff[0] = '\0'; + } + snprintf( buff, sizeof(buff), + NPC_ROOMADMINNEW_MSG_CLOSE_BEFORE, + buf2, + CHAR_getChar( doorindex, CHAR_NAME), + msgbuff, + hun); + + CHAR_setWorkInt( meindex, CHAR_WORKINT_PRINTCLOSETIME, hun); + } + else { + /* 󻻧Իף */ + strcpy( buff, NPC_ROOMADMINNEW_MSG_CLOSE); + CHAR_setWorkInt( meindex, CHAR_WORKINT_PRINTCLOSETIME, 0); + } + /* 𼰰׷ʧ幻˪ */ + NPC_RoomAdminNew_SendMsgThisFloor( meindex, buff); + } + } + if( hun == 0 ) { + NPC_RoomAdminNew_CloseProc( meindex); + } +} + +/************************************************ + ************************************************/ +void NPC_RoomAdminNewTalked( int meindex , int talkerindex , char *msg , + int color ) +{ + + if(NPC_Util_CharDistance( talkerindex, meindex ) > 1)return; + + /*NPC_RoomAdminNew_DspRoomPasswd( meindex, talkerindex);*/ + + NPC_RoomAdminNew_DspNextAuction( meindex, talkerindex); +} +/*----------------------------------------------- + *----------------------------------------------*/ +static void NPC_RoomAdminNew_CloseProc( int meindex) +{ + int pindex; + char buff[256]; + char pname[32]; + int failed = TRUE; + + pindex = NPC_RoomAdminNew_SearchPlayerHasMostMoney( meindex); + /* 񲷮ʧ */ + if( pindex != -1) { + while( 1) { + char passwd[9]; + int doorindex; + doorindex = NPC_DoorSearchByName( + CHAR_getWorkChar( meindex, CHAR_WORKCHAR_NEXTROOM)); + /* ɵëϷ */ + NPC_RoomAdminNew_CreatePasswd( passwd, sizeof( passwd)); + if( NPC_RoomAdminNew_WriteDataFile( meindex, pindex, + CHAR_getWorkChar( meindex, CHAR_WORKCHAR_NEXTROOM), + passwd, 1) + == FALSE) + { + break; + } + /* ʧɵë */ + if( NPC_DoorSetPasswd( doorindex, passwd) == -1 ) { + break; + } + CHAR_setWorkInt( doorindex, CHAR_WORKDOOREXPIRETIME, + CHAR_getWorkInt( meindex, CHAR_WORKINT_NEXTTIME) + + NPC_ROOMADMINNEW_2WEEK); + NPC_RoomAdminNew_WriteScoreFile( meindex, pindex); + + CHAR_setInt( pindex, CHAR_GOLD, 0); + + CHAR_send_P_StatusString( pindex , CHAR_P_STRING_GOLD); + + strcpy( pname, CHAR_getChar( pindex, CHAR_NAME)); + snprintf( buff, sizeof(buff), + NPC_ROOMADMINNEW_MSG_CONGRATULATION, pname, pname, pname); + failed = FALSE; + break; + } + } + + if( failed) { + NPC_RoomAdminNew_WriteDataFile( meindex, -1, CHAR_getWorkChar( meindex, CHAR_WORKCHAR_NEXTROOM), NULL, 0); + /* 񲷮϶ */ + snprintf( buff, sizeof(buff), + NPC_ROOMADMINNEW_MSG_NONE); + } + /* 𼰰׷ʧ幻˪ */ + NPC_RoomAdminNew_SendMsgThisFloor( meindex, buff); + + NPC_RoomAdminNew_SetNextAuction( meindex); + +} +/*----------------------------------------------- + *----------------------------------------------*/ +static int NPC_RoomAdminNew_SearchPlayerHasMostMoney( int meindex) +{ + int i,j, range; + int fl,x,y, gold; + int doorindex; + int topindex; + + fl = CHAR_getInt( meindex, CHAR_FLOOR); + x = CHAR_getInt( meindex, CHAR_X); + y = CHAR_getInt( meindex, CHAR_Y); + range = CHAR_getWorkInt( meindex , CHAR_WORKINT_RANGE); + topindex = -1; + + doorindex = NPC_DoorSearchByName( CHAR_getWorkChar( meindex, + CHAR_WORKCHAR_NEXTROOM)); + gold = atoi( CHAR_getWorkChar( doorindex, CHAR_WORKDOORGOLDLIMIT)); + for( i = x-range ; i <= x+range ; i++ ){ + for( j = y-range ; j <= y+range ; j ++ ){ + OBJECT object; + for( object = MAP_getTopObj( fl, i,j); object; + object = NEXT_OBJECT(object) ) + { + int objindex = GET_OBJINDEX( object); + if( OBJECT_getType(objindex) == OBJTYPE_CHARA ){ + int index; + index = OBJECT_getIndex(objindex); + if( CHAR_getInt( index, + CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER ) + { + if( CHAR_getInt( index, CHAR_GOLD) >= gold ) { + if( topindex == -1 ) { + topindex = index; + } + else { + int nowgold,topgold; + nowgold = CHAR_getInt( index, CHAR_GOLD ); + topgold = CHAR_getInt( topindex, CHAR_GOLD); + if( nowgold > topgold ) { + topindex = index; + } + else if( nowgold == topgold ) { + /* ئìﻥ */ + int nowlv, toplv; + nowlv = CHAR_getInt( index, CHAR_LV ); + toplv = CHAR_getInt( topindex, CHAR_LV); + if( nowlv < toplv ) { + topindex = index; + } + /* ľƥݩئئշ¼ĸةԪ*/ + /* indexƼлнǷ */ + else if( nowlv == toplv ) { + if( RAND( 0,1)) { + topindex = index; + } + } + } + } + } + } + } + } + } + } + return( topindex); +} +/*----------------------------------------------- + * ϶ýľindex׷ʧ幻 + *----------------------------------------------*/ +static void NPC_RoomAdminNew_SendMsgThisFloor( int index, char *buff) +{ + int i, fl; + int playernum = CHAR_getPlayerMaxNum(); + + fl = CHAR_getInt( index, CHAR_FLOOR); + for( i = 0; i < playernum; i ++ ) { + if( CHAR_getInt( i, CHAR_FLOOR) == fl ) { + if( CHAR_getInt( i, CHAR_WHICHTYPE) == CHAR_TYPEPLAYER ) { + CHAR_talkToCli( i, index, buff, NPC_ROOMADMINNEW_MSGCOLOR); + } + } + } +} +/*----------------------------------------------- + *----------------------------------------------*/ +static void NPC_RoomAdminNew_CreatePasswd( char *passwd, int passlen) +{ +#define NPC_ROOMADMINNEW_RAND() ( (rand() /256) % 32768 ) /* 256ƥ¼Ѽ ߤ׻ */ + int i; + char *candidates[]= { + "A","B","D", "E","F","G","H", "J","K","L","M", "N","P","Q","R", + "T","W","X","Y", "a","b","d","e", "f","g","m","n", "q","r","t", + "0","1","2", "3","4","5","6", "7","8","9" + }; + strcpy( passwd , ""); + for(i = 0;i < passlen -1 ; i++){ + strcat( passwd , candidates[ NPC_ROOMADMINNEW_RAND() % (sizeof( candidates)/sizeof(candidates[0])) ] ); + } +#undef NPC_ROOMADMINNEW_RAND +} +/*----------------------------------------------- + * + * + * cdkey|charaname|passwd|expiretime + * + * + *----------------------------------------------*/ +static BOOL NPC_RoomAdminNew_WriteDataFile( int meindex, int pindex, + char *roomname, + char *passwd, int flg) +{ + char *cdkey; + char charaname[32*2]; + char expiretime[64]; + char filename[128]; + char outbuf[1024]; + FILE *fp_src; + + strcpy( filename, NPC_ROOMADMINNEW_DATADIR); + /*strcat( filename, CHAR_getWorkChar( meindex, CHAR_WORKCHAR_NEXTROOM));*/ + strcat( filename, roomname); + strcat( filename, NPC_ROOMADMINNEW_EXTENSION); + + if( flg) { + //getcdkeyFromCharaIndex( pindex, cdkey, sizeof(cdkey )); + cdkey = CHAR_getChar( pindex, CHAR_CDKEY); + makeEscapeString( CHAR_getChar( pindex, CHAR_NAME), + charaname, sizeof( charaname)); + /* ľ */ + snprintf( expiretime, sizeof( expiretime), "%d", + CHAR_getWorkInt( meindex, CHAR_WORKINT_NEXTTIME) + + NPC_ROOMADMINNEW_2WEEK /* ԉ */ + ); + + /* ƥ */ + snprintf( outbuf, sizeof( outbuf), "%s|%s|%s|%s|", + cdkey, charaname, passwd, expiretime); + fp_src = fopen( filename, "w"); + if( !fp_src) { + print( "[%s:%d] File Open Error\n", __FILE__, __LINE__); + return FALSE; + } + fputs( outbuf, fp_src); + fclose( fp_src); + } + else { + unlink( filename); + } + + return TRUE; + +} +/*----------------------------------------------- + *----------------------------------------------*/ +BOOL NPC_RoomAdminNew_ReadFile( char *roomname, NPC_ROOMINFO *data) +{ + FILE *fp; + char line[1024]; + char buf2[128]; + char filename[128]; + + strcpy( filename, NPC_ROOMADMINNEW_DATADIR); + strcat( filename, roomname); + strcat( filename, NPC_ROOMADMINNEW_EXTENSION); + + fp = fopen( filename, "r"); + if( !fp) return FALSE; + fgets( line, sizeof( line), fp); + /* */ + getStringFromIndexWithDelim( line, "|" , 1 , buf2,sizeof(buf2) ); + strcpy( data->cdkey, buf2); + getStringFromIndexWithDelim( line, "|" , 2 , buf2,sizeof(buf2) ); + strcpy( data->charaname, makeStringFromEscaped( buf2)); + getStringFromIndexWithDelim( line, "|" , 3 , buf2,sizeof(buf2) ); + strcpy( data->passwd, buf2); + getStringFromIndexWithDelim( line, "|" , 4 , buf2,sizeof(buf2) ); + if( strcmp( buf2, "max") == 0 ) { + data->expire = 0xffffffff; + } + else { + data->expire = atoi( buf2); + } + fclose( fp); + return TRUE; +} +/*----------------------------------------------- + *----------------------------------------------*/ +static BOOL NPC_RoomAdminNew_SetNextAuction( int meindex) +{ + int i, j; + int hitindex = -1; + int charnum = CHAR_getCharNum(); + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + struct tm tmwk; + + memcpy( &tmwk, localtime( ( time_t *)&NowTime.tv_sec), sizeof( tmwk)); + + NPC_Util_GetArgStr( meindex, argstr, sizeof( argstr)); + + */ + for( i = CHAR_getPlayerMaxNum()+ CHAR_getPetMaxNum(); + i < charnum; + i ++ ) + { + if( CHAR_getInt( i, CHAR_WHICHTYPE) != CHAR_TYPEDOOR) { + continue; + } + if( CHAR_getWorkInt( i, CHAR_WORKDOORPASSFLG) == 0 ) { + continue; + } + for( j = 3; ; j ++ ) { + int rc; + char *doorname; + char buf[256]; + int dataexist; + NPC_ROOMINFO data; + + rc = getStringFromIndexWithDelim( argstr, "|" , j, + buf,sizeof(buf) ); + if( rc != TRUE ) { + break; + } + doorname = CHAR_getWorkChar( i, CHAR_WORKDOORNAME); + if( strcmp( buf, doorname ) != 0 ) { + continue; + } + if( atoi( CHAR_getWorkChar( i, CHAR_WORKDOORWEEK)) != tmwk.tm_wday) { + break; + } + /* ɱ */ + memset( &data, 0, sizeof( data)); + if( NPC_RoomAdminNew_ReadFile( doorname, &data) ) { + struct tm tmdoor; + * ׻ľհ̻ë + */ + if( data.expire < NowTime.tv_sec) { + NPC_RoomAdminNew_WriteDataFile( meindex, -1,doorname, NULL, 0); + /* ʧľб*/ + NPC_DoorSetPasswd( i, "8hda8iauia90494jasd9asodfasdf89"); + CHAR_setWorkInt( i, CHAR_WORKDOOREXPIRETIME, 0xffffffff); + + break; + } + memcpy( &tmdoor, localtime( ( time_t *)&data.expire), sizeof( tmdoor)); + if( tmdoor.tm_mon != tmwk.tm_mon || + tmdoor.tm_mday != tmwk.tm_mday) + { + break; + } + dataexist = TRUE; + } + else { + dataexist = FALSE; + } + if( tmwk.tm_hour > atoi( CHAR_getWorkChar( i, CHAR_WORKDOORHOUR))){ + break; + } + if( tmwk.tm_hour == atoi( CHAR_getWorkChar( i, CHAR_WORKDOORHOUR))) { + if( tmwk.tm_min >= atoi( CHAR_getWorkChar( i, CHAR_WORKDOORMINUTE))) { + break; + } + } + /* ƥԻؤڳʧݷ·ɡ + */ + if( hitindex == -1 ) { + hitindex = i; + } + else { + if( atoi( CHAR_getWorkChar( hitindex, CHAR_WORKDOORHOUR)) + > atoi( CHAR_getWorkChar( i, CHAR_WORKDOORHOUR))) + { + hitindex = i; + } + else if( atoi( CHAR_getWorkChar( hitindex, CHAR_WORKDOORHOUR)) + == atoi( CHAR_getWorkChar( i, CHAR_WORKDOORHOUR))) + { + if( atoi( CHAR_getWorkChar( hitindex, CHAR_WORKDOORMINUTE)) + > atoi( CHAR_getWorkChar( i, CHAR_WORKDOORMINUTE))) + { + hitindex = i; + } + else if( atoi( CHAR_getWorkChar( hitindex, CHAR_WORKDOORMINUTE)) + == atoi( CHAR_getWorkChar( i, CHAR_WORKDOORMINUTE))) + { + NPC_ROOMINFO datawk; + int hitindexdataexist; + hitindexdataexist = NPC_RoomAdminNew_ReadFile( + CHAR_getWorkChar( hitindex, CHAR_WORKDOORNAME), + &datawk); + if( hitindexdataexist < dataexist ) { + hitindex = i; + } + + } + } + } + } + } + if( hitindex > 0 ) { + /* ë */ + tmwk.tm_sec = 0; + tmwk.tm_min = atoi( CHAR_getWorkChar( hitindex, CHAR_WORKDOORMINUTE)); + tmwk.tm_hour = atoi( CHAR_getWorkChar( hitindex, CHAR_WORKDOORHOUR)); + CHAR_setWorkInt( meindex, CHAR_WORKINT_NEXTTIME, mktime( &tmwk)); + CHAR_setWorkChar( meindex, CHAR_WORKCHAR_NEXTROOM, + CHAR_getWorkChar( hitindex, CHAR_WORKDOORNAME)); + + } + else { + CHAR_setWorkInt( meindex, CHAR_WORKINT_NEXTTIME, 0); + CHAR_setWorkChar( meindex, CHAR_WORKCHAR_NEXTROOM,"" ); + + } + /* ë */ + CHAR_setWorkInt( meindex, CHAR_WORKINT_SEARCHROOMTIME, NowTime.tv_sec); + return( TRUE); +} +/*----------------------------------------------- + *----------------------------------------------*/ +static void NPC_RoomAdminNew_DspRoomPasswd( int index, int adminindex, int talkerindex) +{ + int i, rc, flg = FALSE; + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + char argstr2[NPC_UTIL_GETARGSTR_BUFSIZE]; + char *cdkey; + char buf[128]; + char buff[16]; + char buf2[1024]; + + NPC_ROOMINFO info; + + //getcdkeyFromCharaIndex( talkerindex, cdkey, sizeof(cdkey)); + cdkey = CHAR_getChar( talkerindex, CHAR_CDKEY); + + NPC_Util_GetArgStr( adminindex, argstr, sizeof( argstr)); + for( i = 3; ; i ++ ) { + if( getStringFromIndexWithDelim(argstr, "|" , i , buf,sizeof(buf) )) { + rc = NPC_RoomAdminNew_ReadFile( buf, &info); + if( rc == TRUE ) { + if( strcmp( info.cdkey, cdkey) == 0 && + strcmp( info.charaname, + CHAR_getChar( talkerindex, CHAR_NAME)) == 0 ) + { + int doorindex; + char msgbuf[256]; + doorindex = NPC_DoorSearchByName( buf); + NPC_Util_GetArgStr( doorindex, argstr2, sizeof( argstr2)); + getStringFromIndexWithDelim( argstr2, "|" , 9 , + buf2,sizeof(buf2) ); + if( strlen(CHAR_getChar( doorindex, CHAR_NAME) ) != 0 ) { + strcpy( buff, ""); + } + else { + buff[0] = '\0'; + } + + /* Ȿ */ + snprintf( msgbuf, sizeof( msgbuf), + NPC_ROOMADMINNEW_MSG_DSPPASSWD1, + buf2, + CHAR_getChar( doorindex, CHAR_NAME), + buff + ); + /* ˪ */ + CHAR_talkToCli( talkerindex, index,msgbuf, + NPC_ROOMADMINNEW_MSGCOLOR); + + /* Ȿ */ + snprintf( msgbuf, sizeof( msgbuf), + NPC_ROOMADMINNEW_MSG_DSPPASSWD2, + CHAR_getWorkChar(doorindex, CHAR_WORKDOORPASSWD) + ); + /* ˪ */ + CHAR_talkToCli( talkerindex, index,msgbuf, + NPC_ROOMADMINNEW_MSGCOLOR); + flg = TRUE; + } + } + } + else { + break; + } + } + if( !flg) { + CHAR_talkToCli( talkerindex, index, + NPC_ROOMADMINNEW_MSG_PRINTPASSWD_NONE, + NPC_ROOMADMINNEW_MSGCOLOR); + } +} +/*----------------------------------------------- + *----------------------------------------------*/ +static void NPC_RoomAdminNew_DspNextAuction( int meindex, int talkerindex) +{ + char msgbuf[2048]; + time_t closetime; + + closetime = CHAR_getWorkInt( meindex, CHAR_WORKINT_NEXTTIME); + if( closetime == 0 ) { + snprintf( msgbuf, sizeof( msgbuf), + NPC_ROOMADMINNEW_MSG_DSPNEXTAUCTION_NONE + ); + CHAR_talkToCli( talkerindex, meindex,msgbuf, NPC_ROOMADMINNEW_MSGCOLOR); + } + else { + int doorindex; + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + char buff[16]; + struct tm tmwk; + int difftime; + doorindex = NPC_DoorSearchByName( + CHAR_getWorkChar( meindex, CHAR_WORKCHAR_NEXTROOM)); + NPC_Util_GetArgStr( doorindex, argstr, sizeof( argstr)); + getStringFromIndexWithDelim(argstr, "|" , 9 , explain,sizeof(explain)); + if( strlen(CHAR_getChar( doorindex, CHAR_NAME) ) != 0 ) { + strcpy( buff, ""); + } + else { + buff[0] = '\0'; + } + snprintf( msgbuf, sizeof( msgbuf), + NPC_ROOMADMINNEW_MSG_DSPNEXTAUCTION1, + explain, + CHAR_getChar( doorindex, CHAR_NAME), + buff + ); + CHAR_talkToCli( talkerindex, meindex,msgbuf, NPC_ROOMADMINNEW_MSGCOLOR); + /* 󻻧Ի */ + memcpy( &tmwk, localtime( &closetime), sizeof( tmwk)); + difftime = closetime - NowTime.tv_sec; + snprintf( msgbuf, sizeof( msgbuf), + NPC_ROOMADMINNEW_MSG_DSPNEXTAUCTION2, + tmwk.tm_hour, + tmwk.tm_min, + difftime / 3600, + (difftime % 3600) / 60 + ); + CHAR_talkToCli( talkerindex, meindex,msgbuf, NPC_ROOMADMINNEW_MSGCOLOR); + + /* Ʊź */ + snprintf( msgbuf, sizeof( msgbuf), + NPC_ROOMADMINNEW_MSG_DSPNEXTAUCTION3, + CHAR_getWorkChar( doorindex, CHAR_WORKDOORGOLDLIMIT) + ); + CHAR_talkToCli( talkerindex, meindex,msgbuf, NPC_ROOMADMINNEW_MSGCOLOR); + } + +} +/*----------------------------------------------- + * + * + * gold|time|cdkey|charaname|owntitle + * + *----------------------------------------------*/ +static int NPC_RoomAdminNew_WriteScoreFile( int meindex, int pindex) +{ +#define NPC_RANKING_DEFAULT 10 + int ret = 0; + char *cdkey; + char charaname[32*2],owntitle[32*2]; + char filename_dest[128],filename[128]; + char outbuf[1024], line[1024]; + FILE *fp_src, *fp_dest; + + strcpy( filename, NPC_ROOMADMINNEW_DATADIR); + strcat( filename, CHAR_getWorkChar( meindex, CHAR_WORKCHAR_MYNAME)); + strcpy( filename_dest, filename); + strcat( filename, NPC_ROOMADMINNEW_RANKING_EXTENSION); + strcat( filename_dest, NPC_ROOMADMINNEW_RANKING_EXTENSION_TMP); + + //getcdkeyFromCharaIndex( pindex , cdkey , sizeof(cdkey )); + cdkey = CHAR_getChar( pindex, CHAR_CDKEY); + + makeEscapeString( CHAR_getChar( pindex, CHAR_NAME), + charaname, sizeof( charaname)); + + makeEscapeString( CHAR_getChar( pindex, CHAR_OWNTITLE), + owntitle, sizeof( owntitle)); + + /* ƥ */ + snprintf( outbuf, sizeof( outbuf), "%d|%d|%s|%s|%s|\n", + CHAR_getInt( pindex, CHAR_GOLD), + CHAR_getWorkInt( meindex,CHAR_WORKINT_NEXTTIME), + cdkey, charaname, owntitle ); + + + fp_dest = fopen( filename_dest, "w"); + if( !fp_dest) return -1; + + fp_src = fopen( filename, "r"); + if( !fp_src ) { + fclose( fp_dest); + fp_src = fopen( filename, "w"); + if( !fp_src) return -1; + fputs( outbuf, fp_src); + fclose( fp_src); + return 1; + } + else { + int cnt = 1; + char buf[128]; + while( fgets( line, sizeof( line), fp_src)) { + getStringFromIndexWithDelim( line, "|" , 1 , buf,sizeof(buf) ); + if( ret == 0 ) { + if( atoi( buf) < CHAR_getInt( pindex, CHAR_GOLD) ) { + fputs( outbuf, fp_dest); + fputs( line, fp_dest); + ret = cnt; + cnt ++; + } + else { + /* ľ½̤ */ + fputs( line, fp_dest); + } + } + else { + /* ľ½̤ */ + fputs( line, fp_dest); + } + cnt ++; + if( cnt > NPC_RANKING_DEFAULT ) break; + } + /* ¼ƽ뻥۹ǷȻئ */ + if( ret == 0 && cnt <= NPC_RANKING_DEFAULT ) { + fputs( outbuf, fp_dest); + ret = cnt; + } + } + fclose( fp_src); + fclose( fp_dest); + fp_src = fopen( filename_dest, "r"); + if( !fp_src) return -1; + fp_dest = fopen( filename, "w"); + if( !fp_dest) { + fclose( fp_src); + return -1; + } + while( fgets( line, sizeof( line), fp_src)) { + fputs( line, fp_dest); + } + fclose( fp_dest); + fclose( fp_src); + return( ret); +#undef NPC_RANKING_DEFAULT +} +/*----------------------------------------------- + * + * + *----------------------------------------------*/ +static void NPC_RoomAdminNew_ReadScoreFile( int meindex, int talkerindex, + char *admname) +{ + int cnt; + char filename[128]; + char line[1024]; + FILE *fp; + + strcpy( filename, NPC_ROOMADMINNEW_DATADIR); + strcat( filename, admname); + strcat( filename, NPC_ROOMADMINNEW_RANKING_EXTENSION); + + fp = fopen( filename, "r"); + if( !fp) return; + cnt = 1; + while( fgets( line, sizeof( line), fp)) { + int gold,bidtime; + char charaname[32],owntitle[32]; + char tmp[64]; + char outbuf[1024], buf[256]; + struct tm tmwk; + + getStringFromIndexWithDelim( line, "|" , 1 , buf,sizeof(buf) ); + gold = atoi(buf); + getStringFromIndexWithDelim( line, "|" , 2 , buf,sizeof(buf) ); + bidtime = atoi(buf); + getStringFromIndexWithDelim( line, "|" , 4 , buf,sizeof(buf) ); + strcpy( charaname, makeStringFromEscaped( buf)); + getStringFromIndexWithDelim( line, "|" , 5 , buf,sizeof(buf) ); + strcpy( owntitle, makeStringFromEscaped( buf)); + if( strlen( owntitle) != 0 ) { + strcpy( tmp, "["); + strcat( tmp, owntitle); + strcat( tmp, "] "); + strcpy( owntitle, tmp); + } + else { + strcpy( owntitle, " "); + } + memcpy( &tmwk, localtime( (time_t *)&bidtime), sizeof( tmwk)); + + snprintf( outbuf, sizeof( outbuf), + NPC_ROOMADMINNEW_MSG_RANKING, + cnt, + tmwk.tm_year + 1900, + tmwk.tm_mon+1, + tmwk.tm_mday, + gold,charaname,owntitle + ); + CHAR_talkToCli( talkerindex, meindex,outbuf, + NPC_RANKING_MSGCOLOR); + cnt ++; + } + fclose( fp); + +} +/************************************************ + ************************************************/ +BOOL NPC_RankingInit( int meindex ) +{ + char buf[256]; + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + + NPC_Util_GetArgStr( meindex, argstr, sizeof( argstr)); + + + /* type */ + CHAR_setInt( meindex, CHAR_WHICHTYPE, CHAR_TYPERANKING); + if( !getStringFromIndexWithDelim(argstr, "|" , 1 , buf,sizeof(buf) )) { + print( "arg err.rankingNPC not created.\n"); + return( FALSE); + } + CHAR_setWorkChar( meindex , CHAR_WORKCHAR_ADMNAME , buf); + + return TRUE; +} +/************************************************ + ************************************************/ +void NPC_RankingTalked( int meindex , int talkerindex , char *msg , + int color ) +{ + if(NPC_Util_CharDistance( talkerindex, meindex ) > 1)return; + + CHAR_talkToCli( talkerindex, meindex, + NPC_ROOMADMINNEW_MSG_RANKING_INFO, + NPC_RANKING_MSGCOLOR); + + NPC_RoomAdminNew_ReadScoreFile( meindex, talkerindex, + CHAR_getWorkChar( meindex, CHAR_WORKCHAR_ADMNAME)); + +} +/************************************************ + ************************************************/ +BOOL NPC_PrintpassmanInit( int meindex ) +{ + char buf[256]; + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + + NPC_Util_GetArgStr( meindex, argstr, sizeof( argstr)); + + + /* type */ + CHAR_setInt( meindex, CHAR_WHICHTYPE, CHAR_TYPEPRINTPASSMAN); + if( !getStringFromIndexWithDelim(argstr, "|" , 1 , buf,sizeof(buf) )) { + print( "arg err.passmanNPC not created.\n"); + return( FALSE); + } + CHAR_setWorkChar( meindex , CHAR_WORKCHAR_ADMNAME , buf); + + return TRUE; +} +/************************************************ + ************************************************/ +void NPC_PrintpassmanTalked( int meindex , int talkerindex , char *msg , + int color ) +{ + int i; + int charnum; + if(NPC_Util_CharDistance( talkerindex, meindex ) > 2)return; + + charnum = CHAR_getCharNum(); + for(i= CHAR_getPlayerMaxNum() +CHAR_getPetMaxNum(); + i +#include "object.h" +#include "char_base.h" +#include "char.h" +#include "util.h" +#include "npcutil.h" +#include "npc_oldman.h" +#include "title.h" +#include "char_data.h" +#include "readmap.h" +#include "lssproto_serv.h" +#include "log.h" + +#define RANGE 2 + + +void NPC_SetFlg(int talker,int shiftbit); +BOOL NPC_CheckFlg(int point,int shiftbit); +BOOL NPC_SavePointItemCheck(int meindex,int talker,int itemno,int kosuu); +void NPC_MessageDisp(int meindex,int talker,int MseNo); +BOOL NPC_UsedCheck(int meindex,int talker,int flg); +BOOL NPC_SavePointItemDelete(int meindex,int talker,int itemNo,int kosuu); + +extern time_t initTime; + + +int playeronlinenum=0; + + +BOOL NPC_SavePointInit( int meindex ) +{ + int oldmanid=0, bornfl=0, bornx=0 ,borny=0; + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + char token[32]; + char buf2[512]; + + if(NPC_Util_GetArgStr( meindex, argstr, sizeof(argstr))==NULL){ + print("NPC_Savepoint.c Init: GetArgStrErr"); + return FALSE; + } + + if(NPC_Util_GetStrFromStrWithDelim(argstr,"ID",buf2,sizeof( buf2) )==NULL){ + print("SavePoint:IDδ趨 "); + return FALSE; + } + + oldmanid=atoi(buf2); + NPC_Util_GetStrFromStrWithDelim(argstr,"Born",buf2,sizeof( buf2) ); + getStringFromIndexWithDelim( buf2,",",1,token,sizeof(token)); + bornfl = atoi( token ); + getStringFromIndexWithDelim( buf2,",",2,token,sizeof(token)); + bornx = atoi( token ); + getStringFromIndexWithDelim( buf2,",",3,token,sizeof(token)); + borny = atoi( token ); + + CHAR_setWorkInt( meindex , CHAR_WORKOLDMANID ,oldmanid ); + CHAR_setInt( meindex , CHAR_WHICHTYPE , CHAR_TYPESAVEPOINT ); + CHAR_setFlg( meindex , CHAR_ISATTACKED , 1 ); + + if( MAP_IsValidCoordinate( bornfl,bornx,borny )== TRUE + && CHAR_ElderSetPosition( oldmanid ,bornfl,bornx, borny ) == TRUE ){ + return TRUE; + }else{ + printf( "Invalid elder npcarg=%s\n", argstr ); + return FALSE; + } +} + +void NPC_SavePointTalked( int meindex , int talkerindex , char *msg , + int color ) +{ + int fd; + + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + char token[512]; + char buf2[1024]; + char timeMsg[1024]; + int oldmanid; + + if( ! NPC_Util_charIsInFrontOfChar(talkerindex,meindex,RANGE) + || CHAR_getFlg( talkerindex,CHAR_ISDIE )){ + if( (CHAR_getInt(talkerindex,CHAR_X) == CHAR_getInt(meindex,CHAR_X)) + && (CHAR_getInt(talkerindex,CHAR_Y) == CHAR_getInt(meindex,CHAR_Y)) + && (CHAR_getInt(talkerindex,CHAR_FLOOR) ==CHAR_getInt(meindex,CHAR_FLOOR)) ){ + }else{ + return; + } + } + + if(NPC_Util_GetArgStr( meindex, argstr, sizeof(argstr))==NULL){ + print("NPC_Savepoint.c TypeCheck: GetArgStrErr\n"); + return ; + } + + if(NPC_Util_GetStrFromStrWithDelim(argstr,"ID",buf2,sizeof( buf2) )==NULL) return ; + oldmanid=atoi(buf2); + + if(strstr(argstr,"NOITEM")!=NULL) { + NPC_SetFlg(talkerindex,oldmanid); + } + +#ifndef _FREE_SAVE + if(NPC_CheckFlg(CHAR_getInt(talkerindex,CHAR_SAVEPOINT),oldmanid)==FALSE){ + + if(NPC_UsedCheck(meindex,talkerindex,0)==TRUE){ + NPC_MessageDisp(meindex,talkerindex,2); + }else{ + NPC_MessageDisp(meindex,talkerindex,0); + } + }else +#endif + { + CHAR_setInt( talkerindex, CHAR_LASTTALKELDER ,CHAR_getWorkInt( meindex, CHAR_WORKOLDMANID ) ); + fd = getfdFromCharaIndex( talkerindex); + if( fd != -1 ) { +#ifndef _NPC_NOSAVEPOINT + Char *chwk; + chwk = CHAR_getCharPointer( talkerindex); + // CoolFish: +1 2001/11/05 + if (!chwk) return; + + CHAR_charSaveFromConnectAndChar( fd, chwk ,FALSE ); + // Nuke 0907: For acsv test + { + CHAR_charSaveFromConnectAndChar( fd, chwk ,FALSE ); + } +#endif + } + + NPC_Util_GetStrFromStrWithDelim(argstr,"NomalMsg",token,sizeof( token) ); + sprintf(buf2,token,CHAR_getChar(talkerindex,CHAR_NAME)); + + // Robin 0619 display time + { + time_t new_t; + int dd,hh,mm,ss; + + time(&new_t); + new_t-=initTime; + + dd=(int) new_t / 86400; new_t=new_t % 86400; + hh=(int) new_t / 3600; new_t=new_t % 3600; + mm=(int) new_t / 60; new_t=new_t % 60; + ss=(int) new_t; +#ifdef _SAVE_GAME_ID + if (dd>0) { + snprintf( timeMsg, sizeof( timeMsg ) , + "%sѾ %d %d Сʱ %d %d 롣",getGameserverID(),dd,hh,mm,ss); + } else if (hh>0) { + snprintf( timeMsg, sizeof( timeMsg ) , + "%sѾ %d Сʱ %d %d 롣",getGameserverID(),hh,mm,ss); + } else { + snprintf( timeMsg, sizeof( timeMsg ) , + "%sѾ %d %d 롣",getGameserverID(),mm,ss); + } + strcat(buf2,timeMsg); +#else + if (dd>0) { + snprintf( timeMsg, sizeof( timeMsg ) , + "Ѿ %d %d Сʱ %d %d 롣",dd,hh,mm,ss); + } else if (hh>0) { + snprintf( timeMsg, sizeof( timeMsg ) , + "Ѿ %d Сʱ %d %d 롣",hh,mm,ss); + } else { + snprintf( timeMsg, sizeof( timeMsg ) , + "Ѿ %d %d 롣",mm,ss); + } + strcat(buf2,timeMsg); +#endif + } + { + char temp[1024]; + //char *answer;// CoolFish: Rem 2001/4/18 + extern unsigned int StateTable[]; + // Robin 03/20 ܵ͸ҹˮ!!!! + +#ifdef _PLAYER_NUM + if(getPlayerNum()>0){ + int playernum = abs(StateTable[LOGIN])+getPlayerNum()+playeronlinenum; + if(atof(getPlayerBase())>1.0) playernum = playernum * atof(getPlayerBase()) + 0.5; + sprintf(temp,"ĿǰΪ %d ˡ",playernum); + }else{ + int playernum = abs(StateTable[LOGIN])+playeronlinenum; + if(atof(getPlayerBase())>1.0) playernum = playernum * atof(getPlayerBase()) + 0.5; + sprintf(temp,"ĿǰΪ %d ˡ",playernum); + } +#else + sprintf(temp,"ĿǰΪ %d ˡ",abs(StateTable[LOGIN])); +#endif + + strcat(buf2,temp); + + } + { + char savetemp[1024]; + sprintf(savetemp,"ϵͳԶΪ浵"); + strcat(buf2,savetemp); + } + //fd = getfdFromCharaIndex( talkerindex); + CHAR_charSaveFromConnect(talkerindex, FALSE); + CHAR_talkToCli( talkerindex , meindex , buf2 , CHAR_COLORWHITE ); + + } + + + +} + + +/*----------------------------------------- + * +-------------------------------------------*/ +void NPC_SavePointWindowTalked( int meindex, int talkerindex, + int seqno, int select, char *data) +{ + + if( NPC_Util_CharDistance( talkerindex, meindex ) > 2) { + return; + } + + if(seqno==CHAR_WINDOWTYPE_WINDOWSAVEPOINT_START){ + if(select==WINDOW_BUTTONTYPE_YES){ + if(NPC_UsedCheck(meindex,talkerindex,1)==TRUE){ + NPC_MessageDisp(meindex,talkerindex,1); + } + } + } + + +} + + +/* + */ +BOOL NPC_AndReduce(int meindex,int talker,char *buf,int flg) +{ + + char buf2[512]; + char buf3[256]; + int itemNo=0; + int kosuu; + int j=1; + + if(flg==0){ + + while(getStringFromIndexWithDelim(buf,"&",j,buf2,sizeof(buf2))!=FALSE) + { + j++; + if(strstr( buf2, "*") != NULL){ + getStringFromIndexWithDelim(buf2,"*",1,buf3,sizeof(buf3)); + itemNo = atoi(buf3); + getStringFromIndexWithDelim(buf2,"*",2,buf3,sizeof(buf3)); + kosuu = atoi(buf3); + + + /*--ƹ--*/ + if(NPC_SavePointItemCheck(meindex,talker,itemNo,kosuu)==FALSE){ + return FALSE; + } + + }else{ + itemNo = atoi(buf2); + + /*--ƹ--*/ + if(NPC_SavePointItemCheck(meindex,talker,itemNo,1)==FALSE){ + return FALSE; + } + + } + } + + }else{ + if(strstr( buf, "*") != NULL){ + getStringFromIndexWithDelim(buf,"*",1,buf3,sizeof(buf3)); + itemNo = atoi(buf3); + getStringFromIndexWithDelim(buf,"*",2,buf3,sizeof(buf3)); + kosuu = atoi(buf3); + + /*--ƹ--*/ + if(NPC_SavePointItemCheck(meindex,talker,itemNo,kosuu)==FALSE){ + return FALSE; + } + + }else{ + itemNo = atoi(buf); + /*--ƹ--*/ + if(NPC_SavePointItemCheck(meindex,talker,itemNo,1)==FALSE){ + return FALSE; + } + } + + } + + + return TRUE; +} + + +BOOL NPC_AndReduceDelete(int meindex,int talker,char *buf,int flg) +{ + + char buf2[512]; + char buf3[256]; + int itemNo=0; + int kosuu; + int j=1; + + if(flg==0){ + + while(getStringFromIndexWithDelim(buf,"&",j,buf2,sizeof(buf2))!=FALSE) + { + j++; + if(strstr( buf2, "*") != NULL){ + getStringFromIndexWithDelim(buf2,"*",1,buf3,sizeof(buf3)); + itemNo = atoi(buf3); + getStringFromIndexWithDelim(buf2,"*",2,buf3,sizeof(buf3)); + kosuu = atoi(buf3); + + /*--ƹ--*/ + if(NPC_SavePointItemDelete(meindex,talker,itemNo,kosuu)==FALSE){ + return FALSE; + } + + }else{ + itemNo = atoi(buf2); + /*--ƹ--*/ + if(NPC_SavePointItemDelete(meindex,talker,itemNo,1)==FALSE){ + return FALSE; + } + + } + } + + }else{ + if(strstr( buf, "*") != NULL){ + getStringFromIndexWithDelim(buf,"*",1,buf3,sizeof(buf3)); + itemNo = atoi(buf3); + getStringFromIndexWithDelim(buf,"*",2,buf3,sizeof(buf3)); + kosuu = atoi(buf3); + + /*--ƹ--*/ + if(NPC_SavePointItemDelete(meindex,talker,itemNo,kosuu)==FALSE){ + return FALSE; + } + + }else{ + itemNo = atoi(buf); + + /*--ƹ--*/ + if(NPC_SavePointItemDelete(meindex,talker,itemNo,1)==FALSE){ + return FALSE; + } + } + + } + + + return TRUE; +} + + + +/* + * ëέ׾ + */ +BOOL NPC_UsedCheck(int meindex,int talker,int flg) +{ + + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + char buf[128]; + char buf2[512]; + int i=1; + int checkflg=0; + + + if(NPC_Util_GetArgStr( meindex, argstr, sizeof(argstr))==NULL){ + print("NPC_savePoint.c UseCheck: GetArgStrErr"); + return FALSE; + } + + if(NPC_Util_GetStrFromStrWithDelim(argstr,"GetItem",buf,sizeof( buf) )!=NULL) + { + i=1; + while( getStringFromIndexWithDelim(buf,",",i,buf2,sizeof(buf2)) !=FALSE ) + { + i++; + if(strstr( buf2, "&") != NULL){ + + if(NPC_AndReduce( meindex, talker, buf2,0)==TRUE) + { + checkflg=1; + break; + } + }else{ + if(NPC_AndReduce( meindex, talker, buf2,1)==TRUE) + { + checkflg=2; + break; + } + } + } + if(checkflg==0) return FALSE; + } else return TRUE; // Arminius 2.5 û GetItem һɴ + + if(flg==1){ + if(checkflg==1){ + if(NPC_AndReduceDelete(meindex,talker,buf2,0)==FALSE){ + return FALSE; + } + }else{ + if(NPC_AndReduceDelete(meindex,talker,buf2,1)==FALSE){ + return FALSE; + } + } + } + + return TRUE; + +} + + + +void NPC_MessageDisp(int meindex,int talker,int MesNo) +{ + + int fd = getfdFromCharaIndex( talker); + int buttontype=WINDOW_BUTTONTYPE_OK; + int windowtype=WINDOW_MESSAGETYPE_MESSAGE; + int windowno=CHAR_WINDOWTYPE_WINDOWSAVEPOINT_START; + + char token[1024]; + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + char buf[32]; + + if(NPC_Util_GetArgStr( meindex, argstr, sizeof(argstr))==NULL){ + print("NPC_savePoint.c UseCheck: GetArgStrErr"); + return ; + } + + switch(MesNo){ + case 0:/*-- ۢئʧ ةëȻ¾-*/ + NPC_Util_GetStrFromStrWithDelim(argstr,"RequestMsg",token,sizeof( token) ); + + break; + + case 1:/*-- ۢئʧ ةëȻ¾-*/ + NPC_Util_GetStrFromStrWithDelim(argstr,"OkMsg",token,sizeof( token) ); + NPC_Util_GetStrFromStrWithDelim(argstr,"ID",buf,sizeof( buf) ); + NPC_SetFlg(talker,atoi(buf)); + /*--Ƥؤ--*/ + /* ئƾ׹ƱмIDëʢ */ + CHAR_setInt( talker, CHAR_LASTTALKELDER ,CHAR_getWorkInt( meindex, CHAR_WORKOLDMANID ) ); + + /* Ƥ */ + /* ƻ·ڻئмƥʧئ */ + fd = getfdFromCharaIndex( talker); + if( fd != -1 ) { +#ifndef _NPC_NOSAVEPOINT + Char *chwk; + chwk = CHAR_getCharPointer( talker); + // CoolFish: +1 2001/11/05 + if (!chwk) return; + CHAR_charSaveFromConnectAndChar( fd, chwk ,FALSE ); +#endif + } + + break; + + case 2:/*-- ۢئʧ ةëȻ¾-*/ + NPC_Util_GetStrFromStrWithDelim(argstr,"RealyMsg",token,sizeof( token) ); + buttontype=WINDOW_BUTTONTYPE_YESNO; + break; + + } + lssproto_WN_send( fd, windowtype, + buttontype, + windowno, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + token); + + +} + +BOOL NPC_SavePointItemDelete(int meindex,int talker,int itemNo,int kosuu) +{ + int i; + int itemindex; + int id; + int cnt=0; + + for( i=CHAR_STARTITEMARRAY;i +#include "char.h" +#include "object.h" +#include "lssproto_serv.h" +#include "npcutil.h" +#include "handletime.h" +#include "npc_scheduleman.h" +#include "family.h" + +/* + * PK ǼԱ + * + * npc ʾҵǼǼ pk ų + * pk ųһСʱһ pk ΪԭŶ pk , ɵǼԱ + * Ǽ趨Ҫ趨 FamilyPKSchedule + * + * ǼԱͬʱὫ schedule дŵ Game Server + * Ļȶһݶսų̱ͬʱų̡ + * ųֻŴڿʼ 24 Сʱ֮ڵ + * ų̱ĸʽΪ: + * + * time|host_index|host_name|guest_index|guest_name|prepare_time|max_player|flag|win + * + * : ǼԱ¥_ǼԱX_ǼԱY + * + */ + +// ȫļ pk +FamilyPKSchedule fmpks[MAX_SCHEDULE*MAX_SCHEDULEMAN]; + +extern int familyNumTotal; + +enum { + NPC_WORK_ID = CHAR_NPCWORKINT1, // ǼԱ ID, 0 ʼ + NPC_WORK_CHALLENGETIMEOUT = CHAR_NPCWORKINT2, // ͬս timeout + NPC_WORK_SETTINGTIMEOUT = CHAR_NPCWORKINT3, // 趨ս timeout + NPC_WORK_PREVIOUSCHECKTIME = CHAR_NPCWORKINT4, // һμʱ + NPC_WORK_FIGHTINTERVAL = CHAR_NPCWORKINT5, // PK εļ (λ: ) +}; + +enum { + CHAR_WORK_PAGE = CHAR_WORKSHOPRELEVANT, // ҳ + CHAR_WORK_DUELTIME = CHAR_WORKSHOPRELEVANTSEC, // ѡ pk ʱ +}; + +#define SCHEDULEFILEDIR "./Schedule/" + +void NPC_LoadPKSchedule(int meindex); // Load schedule from disk +void NPC_SavePKSchedule(int meindex); // save schedule to disk +void NPC_RemoveExpiredBattle(int meindex); // Ƴڵս +void NPC_ProcessTimeout(int meindex); // timeout +BOOL NPC_AlreadyScheduled(int meindex, int talkerindex); // , һֻܰһ +// ų̱ data +void NPC_LIST_gendata(int meindex, int talkerindex, int page, char *buf, int size); +// ѡ data +void NPC_SELECT_gendata(int meindex, int talkerindex, int page, char *buf, int size); +// ųϸ data +void NPC_DETAIL_gendata(int meindex, char *buf, int size, int dueltime); + +BOOL NPC_SchedulemanInit( int meindex ) +{ + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + int meid; + int interval; + + CHAR_setInt( meindex, CHAR_WHICHTYPE, CHAR_TYPEFMSCHEDULEMAN ); + CHAR_setWorkInt ( meindex, NPC_WORK_PREVIOUSCHECKTIME, -1); + + // + NPC_Util_GetArgStr(meindex, argstr, sizeof(argstr)); + meid = NPC_Util_GetNumFromStrWithDelim(argstr, "id" ); + if ((meid<0) || (meid>=MAX_SCHEDULEMAN)) { + print("SCHEDULEMAN init error: invalid ID(%d)\n",meid); + meid=0; + } + CHAR_setWorkInt(meindex, NPC_WORK_ID, meid); + + interval = NPC_Util_GetNumFromStrWithDelim(argstr, "loopinterval" ); + if ((interval<100) || (interval>10000)) interval=1000; + CHAR_setInt(meindex, CHAR_LOOPINTERVAL, interval); + + interval = NPC_Util_GetNumFromStrWithDelim(argstr, "challengetimeout"); + if ((interval<60) || (interval>60*60)) interval=20*60; + CHAR_setWorkInt(meindex, NPC_WORK_CHALLENGETIMEOUT, interval); + + interval = NPC_Util_GetNumFromStrWithDelim(argstr, "settingtimeout"); + if ((interval<10) || (interval>60*60)) interval=60; + CHAR_setWorkInt(meindex, NPC_WORK_SETTINGTIMEOUT, interval); + + interval = NPC_Util_GetNumFromStrWithDelim(argstr, "fightinterval"); + if ((interval<5) || (interval>60)) interval = 50; + CHAR_setWorkInt(meindex, NPC_WORK_FIGHTINTERVAL, interval); + + + NPC_LoadPKSchedule(meindex); + + return TRUE; +} + +void NPC_SchedulemanTalked(int meindex, int talkerindex, char *msg, int color) +{ + char buf[4096]; + int fd; + if (NPC_Util_CharDistance(meindex, talkerindex) > 2) return; + if (!NPC_Util_isFaceToFace(meindex, talkerindex, 2)) return; + fd = getfdFromCharaIndex(talkerindex); + if (fd == -1) return; + + CHAR_setWorkInt(talkerindex, CHAR_WORK_PAGE, 0); + NPC_LIST_gendata(meindex, talkerindex, 0, buf, sizeof(buf)); + lssproto_WN_send(fd, WINDOW_MESSAGETYPE_PKSCHEDULELIST, + WINDOW_BUTTONTYPE_NEXT | WINDOW_BUTTONTYPE_CANCEL, + CHAR_WINDOWTYPE_SCHEDULEMAN_START, + CHAR_getWorkInt(meindex, CHAR_WORKOBJINDEX), + buf); +} + +void NPC_SchedulemanWindowTalked(int meindex, int talkerindex, + int seqno, int select, char *data) +{ + int page; + int buttontype; + char buf[4096],token[256]; + int fd,i,dt,a; + int fmpks_pos; + + if (NPC_Util_CharDistance(meindex,talkerindex) > 2) return; + if (!NPC_Util_isFaceToFace(meindex, talkerindex, 2)) return; + fd = getfdFromCharaIndex(talkerindex); + if (fd == -1) return; + fmpks_pos = CHAR_getWorkInt(meindex, NPC_WORK_ID)*MAX_SCHEDULE; + +// print("seqno=%d select=%d data=%s\n", seqno,select,data); + + switch (seqno) { + case CHAR_WINDOWTYPE_SCHEDULEMAN_START: + switch (select) { + case WINDOW_BUTTONTYPE_NEXT: + case WINDOW_BUTTONTYPE_PREV: + page=CHAR_getWorkInt(talkerindex, CHAR_WORK_PAGE) + + MAXSCHEDULEINONEWINDOW + * (( select == WINDOW_BUTTONTYPE_NEXT) ? 1 : -1); + buttontype=WINDOW_BUTTONTYPE_NEXT | WINDOW_BUTTONTYPE_PREV | WINDOW_BUTTONTYPE_CANCEL; + if (page<0) { + page=0; + buttontype=WINDOW_BUTTONTYPE_NEXT | WINDOW_BUTTONTYPE_CANCEL; + } + if (page>MAX_SCHEDULE-MAXSCHEDULEINONEWINDOW) { + page=MAX_SCHEDULE-MAXSCHEDULEINONEWINDOW; + buttontype=WINDOW_BUTTONTYPE_PREV | WINDOW_BUTTONTYPE_CANCEL; + } + CHAR_setWorkInt(talkerindex, CHAR_WORK_PAGE, page); + // Send WN + NPC_LIST_gendata(meindex, talkerindex, page, buf, sizeof(buf)); + lssproto_WN_send(fd, WINDOW_MESSAGETYPE_PKSCHEDULELIST, + buttontype, + CHAR_WINDOWTYPE_SCHEDULEMAN_START, + CHAR_getWorkInt(meindex, CHAR_WORKOBJINDEX), + buf); + break; + case WINDOW_BUTTONTYPE_OK: + +#ifdef _FMVER21 + if ((CHAR_getInt(talkerindex,CHAR_FMLEADERFLAG)==FMMEMBER_LEADER) && +#else + if ((CHAR_getInt(talkerindex,CHAR_FMLEADERFLAG)==1) && +#endif + + (CHAR_getWorkInt(talkerindex, CHAR_WORKFMSETUPFLAG)==1)) { + // ֻѳ峤ʹýһĹ (趨ġͬ) + + // decide: send family list or detail or accept + dt=atoi(data); + for (i=0; iMAXFAMILYINONEWINDOW) + buttontype |= WINDOW_BUTTONTYPE_NEXT; + lssproto_WN_send(fd, WINDOW_MESSAGETYPE_PKSCHEDULESELECTFAMILY, + buttontype, + CHAR_WINDOWTYPE_SCHEDULEMAN_SELECT, + CHAR_getWorkInt(meindex, CHAR_WORKOBJINDEX), + buf); + + } + break; + case FMPKS_FLAG_CHALLENGE: + { // 峤Ͷͬ pk˹ + int tkfmindex=CHAR_getWorkInt(talkerindex, CHAR_WORKFMINDEXI); + if (tkfmindex==fmpks[fmpks_pos+i].host_index) { + fmpks[fmpks_pos+i].flag=FMPKS_FLAG_SETTING; + fmpks[fmpks_pos+i].setting_timeout= + CHAR_getWorkInt(meindex, NPC_WORK_SETTINGTIMEOUT); + // ͳϸб + CHAR_setWorkInt(talkerindex, CHAR_WORK_DUELTIME, dt); + NPC_DETAIL_gendata(meindex, buf, sizeof(buf), dt); + lssproto_WN_send(fd, WINDOW_MESSAGETYPE_PKSCHEDULEDETAIL, + WINDOW_BUTTONTYPE_OK | WINDOW_BUTTONTYPE_CANCEL, + CHAR_WINDOWTYPE_SCHEDULEMAN_DETAIL, + CHAR_getWorkInt(meindex, CHAR_WORKOBJINDEX), + buf); + } else if (tkfmindex==fmpks[fmpks_pos+i].guest_index) { + fmpks[fmpks_pos+i].flag=FMPKS_FLAG_SCHEDULED; + page=CHAR_getWorkInt(talkerindex, CHAR_WORK_PAGE); + buttontype=WINDOW_BUTTONTYPE_NEXT | WINDOW_BUTTONTYPE_PREV | WINDOW_BUTTONTYPE_OK; + if (page<0) { + page=0; + buttontype=WINDOW_BUTTONTYPE_NEXT | WINDOW_BUTTONTYPE_OK; + } + if (page>MAX_SCHEDULE-MAXSCHEDULEINONEWINDOW) { + page=MAX_SCHEDULE-MAXSCHEDULEINONEWINDOW; + buttontype=WINDOW_BUTTONTYPE_PREV | WINDOW_BUTTONTYPE_OK; + } + CHAR_talkToCli(talkerindex, meindex, + "ļѾս", CHAR_COLORWHITE); + // ͳ list + NPC_LIST_gendata(meindex, talkerindex, page, buf, sizeof(buf)); + lssproto_WN_send(fd, WINDOW_MESSAGETYPE_PKSCHEDULELIST, + buttontype, + CHAR_WINDOWTYPE_SCHEDULEMAN_START, + CHAR_getWorkInt(meindex, CHAR_WORKOBJINDEX), + buf); + } + } + break; + case FMPKS_FLAG_SETTING: + { // 峤 + int tkfmindex=CHAR_getWorkInt(talkerindex, CHAR_WORKFMINDEXI); + if (tkfmindex==fmpks[fmpks_pos+i].host_index) { + fmpks[fmpks_pos+i].flag=FMPKS_FLAG_SETTING; + fmpks[fmpks_pos+i].setting_timeout= + CHAR_getWorkInt(meindex, NPC_WORK_SETTINGTIMEOUT); + // ͳϸб + CHAR_setWorkInt(talkerindex, CHAR_WORK_DUELTIME, dt); + NPC_DETAIL_gendata(meindex, buf, sizeof(buf), dt); + lssproto_WN_send(fd, WINDOW_MESSAGETYPE_PKSCHEDULEDETAIL, + WINDOW_BUTTONTYPE_OK | WINDOW_BUTTONTYPE_CANCEL, + CHAR_WINDOWTYPE_SCHEDULEMAN_DETAIL, + CHAR_getWorkInt(meindex, CHAR_WORKOBJINDEX), + buf); + } + } + // WON ADD pkԼս + break; + } + + } + } + NPC_SavePKSchedule(meindex); + } else { +#ifdef _FMVER21 + if (CHAR_getInt(talkerindex,CHAR_FMLEADERFLAG)!=FMMEMBER_LEADER) { +#else + if (CHAR_getInt(talkerindex,CHAR_FMLEADERFLAG)!=1) { +#endif + CHAR_talkToCli(talkerindex, meindex, + "ֻ峤ԤԼУม", CHAR_COLORWHITE); + }else if (CHAR_getWorkInt(talkerindex, CHAR_WORKFMSETUPFLAG)!=1) { + CHAR_talkToCli(talkerindex, meindex, + "ļ廹ûʽม", CHAR_COLORWHITE); + } + } + break; + } + break; + case CHAR_WINDOWTYPE_SCHEDULEMAN_SELECT: + switch (select) { + case WINDOW_BUTTONTYPE_PREV: + case WINDOW_BUTTONTYPE_NEXT: + page=CHAR_getWorkInt(talkerindex, CHAR_WORK_PAGE) + + MAXFAMILYINONEWINDOW + * (( select == WINDOW_BUTTONTYPE_NEXT) ? 1 : -1); + buttontype=WINDOW_BUTTONTYPE_NEXT | WINDOW_BUTTONTYPE_PREV; + if (page<1) { + page=1; + buttontype=WINDOW_BUTTONTYPE_NEXT; + } + if (page>familyNumTotal-MAXFAMILYINONEWINDOW+1) { + page=familyNumTotal-MAXFAMILYINONEWINDOW+1; + buttontype=WINDOW_BUTTONTYPE_PREV; + } + CHAR_setWorkInt(talkerindex, CHAR_WORK_PAGE, page); + // Send WN + NPC_SELECT_gendata(meindex, talkerindex, page, buf, sizeof(buf)); + lssproto_WN_send(fd, WINDOW_MESSAGETYPE_PKSCHEDULESELECTFAMILY, + buttontype, + CHAR_WINDOWTYPE_SCHEDULEMAN_SELECT, + CHAR_getWorkInt(meindex, CHAR_WORKOBJINDEX), + buf); + break; + case WINDOW_BUTTONTYPE_OK: + +#ifdef _FMVER21 + if ((CHAR_getInt(talkerindex,CHAR_FMLEADERFLAG)==FMMEMBER_LEADER) && +#else + if ((CHAR_getInt(talkerindex,CHAR_FMLEADERFLAG)==1) && +#endif + (CHAR_getWorkInt(talkerindex, CHAR_WORKFMSETUPFLAG)==1)) { + + dt=CHAR_getWorkInt(talkerindex, CHAR_WORK_DUELTIME); + for (i=0; i0) && (a<=40)) fmpks[fmpks_pos+i].prepare_time=a; + } + // + if (getStringFromIndexWithDelim(data,"|",5,token,sizeof(token))) { + a=atoi(token); +#ifdef _FMWAR_PLAYERNUM + if ((a>0) && (a<=getFmWarPlayerNum())) fmpks[fmpks_pos+i].max_player=a; +#else + if ((a>0) && (a<=50)) fmpks[fmpks_pos+i].max_player=a; +#endif + } + // ʤ + if (getStringFromIndexWithDelim(data,"|",6,token,sizeof(token))) { + a=atoi(token); + if ((a>=0) && (a<=1)) fmpks[fmpks_pos+i].win = a; + } + fmpks[fmpks_pos+i].flag=FMPKS_FLAG_CHALLENGE; + fmpks[fmpks_pos+i].challenge_timeout= + CHAR_getWorkInt(meindex, NPC_WORK_CHALLENGETIMEOUT); + CHAR_talkToCli(talkerindex, meindex, + "ս趨ɡ", CHAR_COLORWHITE); + } + break; + case WINDOW_BUTTONTYPE_CANCEL: + fmpks[fmpks_pos+i].flag=FMPKS_FLAG_NONE; + fmpks[fmpks_pos+i].host_index=-1; + strcpy(fmpks[fmpks_pos+i].host_name,""); + fmpks[fmpks_pos+i].guest_index=-1; + strcpy(fmpks[fmpks_pos+i].guest_name,""); + CHAR_talkToCli(talkerindex, meindex, + "ս", CHAR_COLORWHITE); + break; + } + NPC_SavePKSchedule(meindex); + } + } + } + } + break; + } +} + +void NPC_SchedulemanLoop(int meindex) +{ +// int fmpks_pos = CHAR_getWorkInt(meindex, NPC_WORK_ID)*MAX_SCHEDULE; + +/* + print("Scheduleman: fmpks_pos=%d dueltime=%d host=%s guest=%s\n", + fmpks_pos, fmpks[fmpks_pos].dueltime, fmpks[fmpks_pos].host_name, fmpks[fmpks_pos].guest_name); +*/ + + NPC_RemoveExpiredBattle(meindex); + NPC_ProcessTimeout(meindex); +} + +// Ƴڵս +void NPC_RemoveExpiredBattle(int meindex) +{ + struct tm tm1; + int keeptime; + int i,expired=-1; + int fmpks_pos = CHAR_getWorkInt(meindex, NPC_WORK_ID)*MAX_SCHEDULE; + int prevckt = CHAR_getWorkInt(meindex, NPC_WORK_PREVIOUSCHECKTIME); + int fin = CHAR_getWorkInt(meindex, NPC_WORK_FIGHTINTERVAL); + int h,d; + + // Ŀǰʱ̵׼ȥƳڵų + memcpy( &tm1, localtime( (time_t *)&NowTime.tv_sec), sizeof( tm1)); + + if (tm1.tm_min=60) keeptime = keeptime + 100 - 60; + } + if (fmpks[fmpks_pos].dueltime > keeptime) expired=23; + } + + if (expired>=0) { + // ƶųȡѾʧЧų + for (i=expired+1; i=60 ) h=h+100-60; + if (h>=2400) { + h = h-2400; + d = 10000; + } + fmpks[fmpks_pos+i].dueltime=d+h; + } + + // һų, Ŷ״Ϊų̡ + if (fmpks[fmpks_pos].flag < FMPKS_FLAG_SCHEDULED) { + fmpks[fmpks_pos].flag = FMPKS_FLAG_NONE; + fmpks[fmpks_pos+i].host_index=-1; + strcpy(fmpks[fmpks_pos+i].host_name,""); + fmpks[fmpks_pos+i].guest_index=-1; + strcpy(fmpks[fmpks_pos+i].guest_name,""); + } + + } +} + +// timeout +void NPC_ProcessTimeout(int meindex) +{ + int i; + int fmpks_pos = CHAR_getWorkInt(meindex, NPC_WORK_ID)*MAX_SCHEDULE; + + for (i=0; i=0) { + fmpks[fmpks_pos+i].challenge_timeout--; + if (fmpks[fmpks_pos+i].challenge_timeout<0) { + fmpks[fmpks_pos+i].host_index = -1; + strcpy(fmpks[fmpks_pos+i].host_name, "-1"); + fmpks[fmpks_pos+i].guest_index = -1; + strcpy(fmpks[fmpks_pos+i].guest_name, "-1"); + fmpks[fmpks_pos+i].prepare_time = -1; + fmpks[fmpks_pos+i].max_player = -1; + fmpks[fmpks_pos+i].flag=-1; + fmpks[fmpks_pos+i].win=-1; + } + } + } + if (fmpks[fmpks_pos+i].flag==FMPKS_FLAG_SETTING) { + if (fmpks[fmpks_pos+i].setting_timeout>=0) { + fmpks[fmpks_pos+i].setting_timeout--; + if (fmpks[fmpks_pos+i].setting_timeout<0) { + fmpks[fmpks_pos+i].host_index = -1; + strcpy(fmpks[fmpks_pos+i].host_name, "-1"); + fmpks[fmpks_pos+i].guest_index = -1; + strcpy(fmpks[fmpks_pos+i].guest_name, "-1"); + fmpks[fmpks_pos+i].prepare_time = -1; + fmpks[fmpks_pos+i].max_player = -1; + fmpks[fmpks_pos+i].flag=-1; + fmpks[fmpks_pos+i].win=-1; + } + } + } + } +} + +// , һֻܰһս +BOOL NPC_AlreadyScheduled(int meindex, int talkerindex) +{ + int i; + int fmpks_pos = CHAR_getWorkInt(meindex, NPC_WORK_ID)*MAX_SCHEDULE; + int tkfmindex = CHAR_getWorkInt(talkerindex, CHAR_WORKFMINDEXI); + int flag=1; + + for (i=0; i=FMPKS_FLAG_SCHEDULED) { + if (fmpks[fmpks_pos+i].host_index==tkfmindex) return TRUE; + } else if (fmpks[fmpks_pos+i].flag!=FMPKS_FLAG_NONE) { + if (flag==1) flag=0; else return TRUE; + } + } + return FALSE; +} + +// ȡ schedule +void NPC_LoadPKSchedule(int meindex) +{ + char filename[256],tmp[4096],token[256]; + FILE *f; + int i; + int fmpks_pos = CHAR_getWorkInt(meindex, NPC_WORK_ID)*MAX_SCHEDULE; + + snprintf(filename,sizeof(filename), "%s%d_%d_%d", + SCHEDULEFILEDIR, CHAR_getInt(meindex, CHAR_FLOOR), + CHAR_getInt(meindex, CHAR_X), + CHAR_getInt(meindex, CHAR_Y) ); + + if( ! (f=fopen( filename, "r" )) ){ // create new schedule file + f = fopen( filename, "w" ); + if( !f ){ + print( "ERROR:Can't create Schedule file %s!\n",filename ); + return; + } + for (i=0; i=MAX_SCHEDULE)) return; + + // ¼Ŀǰʱ + memcpy( &tm1, localtime( (time_t *)&NowTime.tv_sec), sizeof( tm1)); + sprintf(buf, "%d|", tm1.tm_hour*100 + tm1.tm_min); + + for (i=page; i +#include "char.h" +#include "object.h" +#include "char_base.h" +#include "npcutil.h" +#include "lssproto_serv.h" +#include "readmap.h" +// Arminius 8.4 manor +#include "family.h" + +static void NPC_SignBoard_Window( int meindex, int toindex, int num,int select); + + +/********************************* +*********************************/ +BOOL NPC_SignBoardInit( int meindex ) +{ + + char npcarg[NPC_UTIL_GETARGSTR_BUFSIZE]; + /*--ɬ--*/ + CHAR_setInt( meindex , CHAR_WHICHTYPE , CHAR_TYPEMSG ); + + if(NPC_Util_GetArgStr( meindex, npcarg, sizeof(npcarg))==NULL){ + print("GetArgStrErr"); + return FALSE; + } + + return TRUE; + +} + + + + +/********************************* +*********************************/ +void NPC_SignBoardLooked( int meindex , int lookedindex) +{ + + if( CHAR_getInt( lookedindex , CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER ) { + return; + } + + if( NPC_Util_CharDistance( lookedindex, meindex ) > 1) return; + + + NPC_SignBoard_Window( meindex, lookedindex,0,-1); + +} + + +static void NPC_SignBoard_Window( int meindex, int toindex, int num,int select) +{ + + char npcarg[NPC_UTIL_GETARGSTR_BUFSIZE]; + char token[1024]; + int fd = getfdFromCharaIndex( toindex); + + + if(NPC_Util_GetArgStr( meindex, npcarg, sizeof(npcarg))==NULL){ + print("GetArgStrErr"); + return; + } + + // Arminius: manor + { + char *p,*q; + extern struct FM_POINTLIST fmpointlist; + p=strstr(npcarg, "%manorid:"); + if (p!=NULL) { + char tmp[1024]; + int a; + + q=strstr(p+1,"%"); + if (q!=NULL) { + q[0]='\0'; + p[0]='\0'; + a=atoi(p+9); +#ifdef _FAMILY_MANORNUM_CHANGE // CoolFish ޸װ԰ + if ((a>=1) && (a<=MANORNUM)) { +#else + if ((a>=1) && (a<=4)) { +#endif + getStringFromIndexWithDelim(fmpointlist.pointlistarray[a-1], "|", 5, token, sizeof(token)); + if (atoi(token)>=0) { + getStringFromIndexWithDelim(fmpointlist.pointlistarray[a-1], "|", 6, token, sizeof(token)); + sprintf(tmp,"%s%s%s",npcarg,token,q+1); + strcpy(npcarg, tmp); + } else { + sprintf(tmp,"%sûκμ%s",npcarg,q+1); + strcpy(npcarg, tmp); + } + } + } + } + } + + sprintf(token, "塡\n%s",npcarg); + + /*--˪--*/ + lssproto_WN_send( fd,WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + CHAR_WINDOWTYPE_WINDOWPETSHOP_START, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + token); +} + + + +/*----------------------------------------- + * +-------------------------------------------*/ +void NPC_SignBoardWindowTalked( int meindex, int talkerindex, + int seqno, int select, char *data) +{ + + if( NPC_Util_CharDistance( talkerindex, meindex ) > 1) { + return; + } +} + diff --git a/npc/npc_simpleshop.c b/npc/npc_simpleshop.c new file mode 100644 index 0000000..d258e4e --- /dev/null +++ b/npc/npc_simpleshop.c @@ -0,0 +1,726 @@ +#include "version.h" +#include + +#include "object.h" +#include "char_base.h" +#include "char.h" +#include "item.h" +#include "util.h" +#include "handletime.h" +#include "anim_tbl.h" +#include "npc_door.h" +#include "lssproto_serv.h" +#include "npcutil.h" +#include "npccreate.h" +#include "log.h" + + +/* + * + * + * ì: init, talked, specialtalked + * + * + */ +static void NPC_SimpleShopOpenShopWindow( int meindex, int cliindex, + char *npcarg ); +static void NPC_SimpleShopGetEscapedItemString( int shopindex, + int cliindex, char *str ); +static BOOL NPC_SimpleShopProcessBuyMsg( char *msg, int shop, int cli ); +static BOOL NPC_SimpleShopProcessSellMsg( char *msg, int shop, int cli ); + +static BOOL NPC_LimitBuyInShopProcessSellMsg(char *msg,int shop,int cli); + + +static BOOL NPC_SimpleShopFillItem( int meindex, char *npcarg ); +static int NPC_SimpleShopGetItemNum( int meindex ); +static void NPC_SimpleShopNormalWindow( int meindex, + int playerindex, char *str ); +static int NPC_ShopWindowIndexToItemTableIndex( int charindex, + int shopwindowindex ); +static BOOL NPC_SimpleShopOpenShopOrNot( char *msg, char *openshopstr ); +//static void NPC_SimpleShopSetLeakLevel( int meindex ); + +#define NPC_SIMPLESHOPMAXBUYPRICE 9999 +#define SIMPLESHOPTALKBUFSIZE 256 + +#define SIMPLESHOP_FATALERRSTR "ʹԲ,״̫ѡ" + +#define SIMPLESHOP_MAXINFINITITEM 40 + +enum{ + OPENSHOPTOKEN=1, + MSGTOKEN, + MAINTOKEN, + BUYTOKEN, + OKBUYTOKEN, + SELLTOKEN, + OKSELLTOKEN, + POORTOKEN, + ITEMFULLTOKEN, + ANOTHERPLAYERTOKEN, + RAREITEMTOKEN, + THANKYOUTOKEN, + ITEMLISTTOKEN, + + BUYINITEMLISTTOKEN, + }; +void NPC_SimpleShopTalked( int meindex, int talker, char *msg, int color ) +{ +#define SHOPRANGE 3 + char npcarg[NPC_UTIL_GETARGSTR_BUFSIZE], token[NPC_UTIL_GETARGSTR_LINEMAX]; + if( CHAR_getInt( talker,CHAR_WHICHTYPE) != CHAR_TYPEPLAYER ){ + return; + } + if( NPC_Util_charIsInFrontOfChar( talker, meindex, SHOPRANGE ) + && ! CHAR_getFlg( talker,CHAR_ISDIE ) ){ + NPC_Util_GetArgStr( meindex, npcarg, sizeof(npcarg)); + getStringFromIndexWithDelim( npcarg,"|", OPENSHOPTOKEN,token, sizeof(token)); + if( NPC_SimpleShopOpenShopOrNot( msg, token ) + && NPC_Util_isFaceToFace( meindex, talker, SHOPRANGE ) ){ + CHAR_setWorkInt( meindex, CHAR_WORKSHOPCLIENTINDEX, talker ); + NPC_SimpleShopOpenShopWindow( meindex, talker, npcarg ); + }else{ + int tokennum; + int i; + char tmp[NPC_UTIL_GETARGSTR_LINEMAX]; + getStringFromIndexWithDelim( npcarg,"|", MSGTOKEN,token, sizeof(token)); + tokennum = 1; + for( i=0;token[i]!='\0';i++ ){ + if( token[i] == ',' ) tokennum++; + } + getStringFromIndexWithDelim( token,",", rand()%tokennum+1,tmp, sizeof(tmp)); + CHAR_talkToCli( talker, meindex, tmp, CHAR_COLORWHITE ); + } + } +} + +void NPC_SimpleShopSpecialTalked( int meindex, int talker, char *msg, int color ) +{ + if( CHAR_getInt(talker,CHAR_WHICHTYPE) == CHAR_TYPEPLAYER + && NPC_Util_isFaceToFace( meindex, talker, SHOPRANGE ) ){ + char npcarg[NPC_UTIL_GETARGSTR_BUFSIZE], token[NPC_UTIL_GETARGSTR_LINEMAX]; + NPC_Util_GetArgStr( meindex, npcarg, sizeof(npcarg)); + switch( tolower(msg[0]) ){ + case 's': + { + int ret; + if( CHAR_getWorkInt(meindex,CHAR_WORKSHOPCLIENTINDEX)!= talker ){ + getStringFromIndexWithDelim( npcarg,"|",ANOTHERPLAYERTOKEN, + token, sizeof(token)); + NPC_SimpleShopNormalWindow( meindex, talker, token ); + return; + } + ret = getStringFromIndexWithDelim( msg, "|", 3, token, sizeof(token)); + if( ret == FALSE ){ + token[0] = 'e'; + token[1] = '\0'; + } + switch( tolower(token[0])){ + case 'b': + if( (ret=NPC_SimpleShopProcessBuyMsg(msg,meindex,talker)) + <0){ + switch( ret ){ + case -2: + getStringFromIndexWithDelim( npcarg,"|",POORTOKEN, + token,sizeof(token)); + NPC_SimpleShopNormalWindow( meindex,talker,token); + break; + case -3: + getStringFromIndexWithDelim( npcarg,"|", + ITEMFULLTOKEN, + token,sizeof(token)); + NPC_SimpleShopNormalWindow(meindex,talker,token); + break; + case -1: + default: + NPC_SimpleShopNormalWindow(meindex, talker, + SIMPLESHOP_FATALERRSTR + ); + break; + } + }else{ + NPC_SimpleShopFillItem( meindex, npcarg ); + getStringFromIndexWithDelim(npcarg,"|",THANKYOUTOKEN, + token, sizeof(token)); + NPC_SimpleShopNormalWindow(meindex,talker,token); + } + break; + case 's': + if( CHAR_getWorkInt(meindex,CHAR_WORKSHOPCLIENTINDEX) != talker ){ + getStringFromIndexWithDelim( npcarg,"|", + ANOTHERPLAYERTOKEN, + token, sizeof(token)); + NPC_SimpleShopNormalWindow( meindex, talker, token ); + return; + } + if((ret=NPC_SimpleShopProcessSellMsg(msg,meindex,talker)) <0 ){ + switch(ret){ + case -2: + getStringFromIndexWithDelim( npcarg,"|", + RAREITEMTOKEN, + token, sizeof(token) ); + NPC_SimpleShopNormalWindow( meindex,talker,token); + break; + case -1: + default: + NPC_SimpleShopNormalWindow(meindex, talker, + SIMPLESHOP_FATALERRSTR ); + break; + } + }else{ + getStringFromIndexWithDelim(npcarg,"|",THANKYOUTOKEN, + token, sizeof(token)); + NPC_SimpleShopNormalWindow(meindex,talker,token); + } + break; + case 'e': + default: + CHAR_setWorkInt( meindex, CHAR_WORKSHOPCLIENTINDEX, -1 ); + break; + } + break; + } + case 'i': + if( CHAR_getWorkInt(meindex,CHAR_WORKSHOPCLIENTINDEX) + == talker ){ + NPC_SimpleShopOpenShopWindow( meindex, talker, npcarg ); + } + break; + default: + break; + } + } +} + +void NPC_LimitBuyInShopSpecialTalked( int meindex, int talker, char *msg, int color ) +{ + if( CHAR_getInt(talker,CHAR_WHICHTYPE) == CHAR_TYPEPLAYER + && NPC_Util_isFaceToFace( meindex, talker, SHOPRANGE ) ){ + char npcarg[NPC_UTIL_GETARGSTR_BUFSIZE], token[NPC_UTIL_GETARGSTR_LINEMAX]; + NPC_Util_GetArgStr( meindex, npcarg, sizeof(npcarg)); + switch( tolower(msg[0]) ){ + case 's': + { + int ret; + if( CHAR_getWorkInt(meindex,CHAR_WORKSHOPCLIENTINDEX) != talker ){ + getStringFromIndexWithDelim( npcarg,"|", + ANOTHERPLAYERTOKEN, + token, sizeof(token)); + NPC_SimpleShopNormalWindow( meindex, talker, token ); + return; + } + ret = getStringFromIndexWithDelim( msg, "|", 3, token, sizeof( token)); + if( ret == FALSE ){ + token[0] = 'e'; + token[1] = '\0'; + } + switch( tolower(token[0])){ + case 'b': + if( ( ret = NPC_SimpleShopProcessBuyMsg( msg, meindex, talker)) < 0){ + switch( ret ){ + case -2: + getStringFromIndexWithDelim( npcarg,"|",POORTOKEN, + token,sizeof(token)); + NPC_SimpleShopNormalWindow( meindex,talker,token); + break; + case -3: + getStringFromIndexWithDelim( npcarg,"|", + ITEMFULLTOKEN, + token,sizeof(token)); + NPC_SimpleShopNormalWindow(meindex,talker,token); + break; + case -1: + default: + NPC_SimpleShopNormalWindow(meindex, talker, + SIMPLESHOP_FATALERRSTR + ); + break; + } + }else{ + NPC_SimpleShopFillItem( meindex, npcarg ); + getStringFromIndexWithDelim(npcarg,"|",THANKYOUTOKEN, + token, sizeof(token)); + NPC_SimpleShopNormalWindow(meindex,talker,token); + + } + break; + case 's': + if( CHAR_getWorkInt(meindex,CHAR_WORKSHOPCLIENTINDEX) != talker ){ + getStringFromIndexWithDelim( npcarg,"|", + ANOTHERPLAYERTOKEN, + token, sizeof(token)); + NPC_SimpleShopNormalWindow( meindex, talker, token ); + return; + } + if((ret=NPC_LimitBuyInShopProcessSellMsg( + msg,meindex,talker))<0){ + switch(ret){ + case -2: + getStringFromIndexWithDelim( npcarg,"|", + RAREITEMTOKEN, + token,sizeof(token)); + NPC_SimpleShopNormalWindow( meindex,talker,token); + break; + case -1: + default: + NPC_SimpleShopNormalWindow(meindex, talker, SIMPLESHOP_FATALERRSTR + ); + break; + } + }else{ + getStringFromIndexWithDelim(npcarg,"|",THANKYOUTOKEN, token, sizeof(token)); + NPC_SimpleShopNormalWindow(meindex,talker,token); + + } + break; + case 'e': + default: + CHAR_setWorkInt( meindex, CHAR_WORKSHOPCLIENTINDEX, -1 ); + break; + } + break; + } + case 'i': + if( CHAR_getWorkInt(meindex,CHAR_WORKSHOPCLIENTINDEX) + == talker ){ + NPC_SimpleShopOpenShopWindow( meindex, talker, npcarg ); + } + break; + default: + break; + } + } +} + + + + + +/* + * int meindex : Ҽindex + * int playerindex : ̼ëindex + * char *str : + */ +static void NPC_SimpleShopNormalWindow( int meindex, int playerindex, + char *str ) +{ + int fd; + int objindex; + char tmp[512], *name; + + objindex = CHAR_getWorkInt(meindex,CHAR_WORKOBJINDEX); + name = CHAR_getChar( meindex, CHAR_NAME ); + snprintf(tmp,sizeof(tmp),"W|%d|N|%s|123|%s", objindex, name, str ); + fd = getfdFromCharaIndex(playerindex); + if( fd == -1 ) return; + lssproto_TK_send(fd,-1,tmp,CHAR_COLORWHITE ); +} + +/* + * ¦ + * int charindex:ƽҷ¼̼͵ + * ߯Ի + */ +static int NPC_ShopWindowIndexToItemTableIndex( int charindex, + int shopwindowindex ) +{ + int i, counter; + + counter = 0; + for( i=CHAR_STARTITEMARRAY;i NPC_SIMPLESHOPMAXBUYPRICE ){ + return -2; + } + price *= NPC_Util_sellRate(playerindex); + + CHAR_AddGold( playerindex, price ); + + CHAR_sendStatusString( playerindex , "P"); + + id = ITEM_getInt(itemind,ITEM_ID); + { + LogItem( + CHAR_getChar( playerindex, CHAR_NAME ), /* ƽҷ */ + CHAR_getChar( playerindex, CHAR_CDKEY ), +#ifdef _add_item_log_name // WON ADD itemlogitem + itemind, +#else + ITEM_getInt( itemind, ITEM_ID ), /* ʧ ة į */ +#endif + "Sell", + CHAR_getInt( playerindex,CHAR_FLOOR), + CHAR_getInt( playerindex,CHAR_X ), + CHAR_getInt( playerindex,CHAR_Y ), + ITEM_getChar( itemind, ITEM_UNIQUECODE), + ITEM_getChar( itemind, ITEM_NAME), + ITEM_getInt( itemind, ITEM_ID) + ); + } + + if( ! NPC_Util_moveItemToChar( shopindex,itemind,TRUE ) ){ + return -1; + } + NPC_Util_RemoveItemByID(shopindex,id,FALSE); + return 1; +} + +static BOOL NPC_LimitBuyInShopProcessSellMsg(char *msg, + int shopindex, int playerindex ) +{ + int sellwindowindex, itemtableindex,itemind, id,i,buyokflag, setid; + int price, tmpgold; + char buf[BUFSIZ]; + char npcarg[NPC_UTIL_GETARGSTR_BUFSIZE], token[NPC_UTIL_GETARGSTR_LINEMAX]; + + if(!CHAR_CHECKINDEX(shopindex)||!CHAR_CHECKINDEX(playerindex)) + return -1; + if( !getStringFromIndexWithDelim( msg,"|",4,buf,sizeof(buf) )){ + return -1; + } + sellwindowindex = atoi(buf); + itemtableindex = sellwindowindex + CHAR_STARTITEMARRAY; + itemind = CHAR_getItemIndex(playerindex,itemtableindex ); + if( ! ITEM_CHECKINDEX(itemind) ) return -1; + id = ITEM_getInt(itemind,ITEM_ID); + NPC_Util_GetArgStr( shopindex, npcarg, sizeof(npcarg)); + getStringFromIndexWithDelim( npcarg, "|", BUYINITEMLISTTOKEN, token, sizeof( token) ); + buyokflag = FALSE; + for( i=1;getStringFromIndexWithDelim(token,",",i,buf,sizeof(buf)); i++){ + + char *tok1 = NULL; + char *tok2 = NULL; + int no1=0, no2=0; + tok1 = strtok( buf, "-" ); + tok2 = strtok( NULL, "-" ); + + setid = atoi(buf); + + if( tok1 == NULL || tok2 == NULL ){ + if( setid == 0 ) return -2; + if( setid == id ) buyokflag = TRUE; + } else { + no1 = atoi( tok1 ); + no2 = atoi( tok2 ); + if( no1 <= id && id <= no2 ){ + buyokflag = TRUE; + } + } + } + if( buyokflag == FALSE ) return -2; + price = ITEM_getInt( itemind, ITEM_COST ); + price *= NPC_Util_sellRate(playerindex); + + CHAR_AddGold( playerindex, price ); + + CHAR_sendStatusString( playerindex , "P"); + if( ! NPC_Util_moveItemToChar( shopindex,itemind,TRUE ) ){ + return -1; + } + + { + LogItem( + CHAR_getChar( playerindex, CHAR_NAME ), /* ƽҷ */ + CHAR_getChar( playerindex, CHAR_CDKEY ), +#ifdef _add_item_log_name // WON ADD itemlogitem + itemind, +#else + ITEM_getInt( itemind, ITEM_ID ), /* ʧ ة į */ +#endif + "Sell", + CHAR_getInt( playerindex,CHAR_FLOOR), + CHAR_getInt( playerindex,CHAR_X ), + CHAR_getInt( playerindex,CHAR_Y ), + ITEM_getChar( itemind, ITEM_UNIQUECODE), + ITEM_getChar( itemind, ITEM_NAME), + ITEM_getInt( itemind, ITEM_ID) + ); + } + + NPC_Util_RemoveItemByID(shopindex,id,FALSE); + + return 1; + +} + +/* + */ +static int NPC_SimpleShopGetItemNum( int meindex ) +{ + int counter, i; + + counter = 0; + for( i=CHAR_STARTITEMARRAY;i=2 ){ /* ʿ */ + NPC_Util_RemoveItemByID(meindex,itemid,FALSE); + } + }else{ + break; + } + } + + /* ͹ľر */ + //NPC_SimpleShopSetLeakLevel( meindex ); + + return TRUE; +} + + +/* + */ +BOOL NPC_SimpleShopInit( int meindex ) +{ + unsigned int mlevel; + char npcarg[NPC_UTIL_GETARGSTR_BUFSIZE]; + + + int createindex = CHAR_getInt( meindex, CHAR_NPCCREATEINDEX ); + +/* print("shopinit start\n" );*/ + if( NPC_CHECKCREATEINDEX(createindex) ){ + NPC_create[createindex].intdata[NPC_CREATETIME] = -1; + } + + CHAR_setInt( meindex , CHAR_HP , 0 ); + CHAR_setInt( meindex , CHAR_MP , 0 ); + CHAR_setInt( meindex , CHAR_MAXMP , 0 ); + CHAR_setInt( meindex , CHAR_STR , 0 ); + CHAR_setInt( meindex , CHAR_TOUGH, 0 ); + CHAR_setInt( meindex , CHAR_LV , 0 ); + mlevel = ((100<<16)|(100<<0)); /* 2 弰 + Ʊ2 弰 */ + CHAR_setInt( meindex, CHAR_MERCHANTLEVEL, mlevel ); + + CHAR_setWorkInt( meindex, CHAR_WORKSHOPCLIENTINDEX, -1 ); + + CHAR_setInt( meindex , CHAR_WHICHTYPE , CHAR_TYPESHOP ); + CHAR_setFlg( meindex , CHAR_ISOVERED , 0 ); + CHAR_setFlg( meindex , CHAR_ISATTACKED , 0 ); + + NPC_Util_GetArgStr( meindex, npcarg, sizeof(npcarg)); + + if( ! NPC_SimpleShopFillItem( meindex,npcarg ) ){ + print( "SHOP INIT ERROR: npcarg=%s\n", npcarg ); + return FALSE; + } + +/* print("shopinit end\n" );*/ + + + return TRUE; +} + +/* + * npcargȳ𻧼ͼ + * ϱз,Իʷֽ,ʷֽئ + * + * ¦ + * ߯Ի + * ئTRUE, ئئFALSE + */ +static BOOL NPC_SimpleShopOpenShopOrNot( char *msg, char *openshopstr ) +{ + int i; + char buf[256]; + + i=1; + while(getStringFromIndexWithDelim(openshopstr,",",i,buf,sizeof(buf))){ + if( strstr( msg, buf ) ) return TRUE; + i++; + } + return FALSE; +} diff --git a/npc/npc_stoneserviceman.c b/npc/npc_stoneserviceman.c new file mode 100644 index 0000000..e69de29 diff --git a/npc/npc_storyteller.c b/npc/npc_storyteller.c new file mode 100644 index 0000000..d845fc9 --- /dev/null +++ b/npc/npc_storyteller.c @@ -0,0 +1,17 @@ +#include "version.h" +#include "char.h" + +BOOL NPC_StoryTellerInit( int meindex ) +{ + CHAR_setInt( meindex , CHAR_WHICHTYPE , CHAR_TYPESTORYTELLER ); + CHAR_setFlg( meindex , CHAR_ISATTACKED , 0 ); + CHAR_setFlg( meindex , CHAR_ISOVERED , 0 ); + + return TRUE; +} + + +void NPC_StoryTellerTalked( int meindex , int talker , char *msg , int col ) +{ + +} diff --git a/npc/npc_stushop.c b/npc/npc_stushop.c new file mode 100644 index 0000000..0df0205 --- /dev/null +++ b/npc/npc_stushop.c @@ -0,0 +1,257 @@ +#include "version.h" +#include +#include "char.h" +#include "object.h" +#include "char_base.h" +#include "npcutil.h" +#include "npc_stushop.h" +#include "lssproto_serv.h" +#include "saacproto_cli.h" +#include "readmap.h" +#include "battle.h" +#include "log.h" +#include "enemy.h" +#include "handletime.h" +#include "npc_eventaction.h" + +//صشøнڽ"ʦ" +#ifdef _STU_SYS +enum { + WINDOW_START=1, + WINDOW_SELECT, + WINDOW_PREV, + WINDOW_NEXT, + WINDOW_WARP, + WINDOW_END, +}; +enum { + NPC_WORK_CURRENTTIME = CHAR_NPCWORKINT1, +/* + NPC_WORK_ROUTETOY = CHAR_NPCWORKINT2, + NPC_WORK_ROUTEPOINT = CHAR_NPCWORKINT3, + NPC_WORK_ROUNDTRIP = CHAR_NPCWORKINT4, + NPC_WORK_MODE = CHAR_NPCWORKINT5, + NPC_WORK_CURRENTROUTE = CHAR_NPCWORKINT6, + NPC_WORK_ROUTEMAX = CHAR_NPCWORKINT7, + NPC_WORK_WAITTIME = CHAR_NPCWORKINT8, + NPC_WORK_CURRENTTIME = CHAR_NPCWORKINT9, + NPC_WORK_SEFLG = CHAR_NPCWORKINT10, +*/ +}; + +#define STANDBYTIME 50 + +static void NPC_StuShop_selectWindow( int meindex, int toindex, int num,int select); +BOOL StuShop_GetMenuStr( int meindex, int toindex, char *npcarg, char *token, int index ); +int StuShop_ShowMenulist( char *npcarg ); + +int page; + +BOOL NPC_StushopInit( int meindex ) +{ + char npcarg[NPC_UTIL_GETARGSTR_BUFSIZE]; + + if(NPC_Util_GetArgStr( meindex, npcarg, sizeof(npcarg))==NULL){ + print("TRANSER_MAN: GetArgStrErr!!"); + return FALSE; + } + + CHAR_setInt( meindex, CHAR_WHICHTYPE, CHAR_TRANSERMANS); + + //CHAR_setInt( meindex, CHAR_LOOPINTERVAL, NEWNPCMAN_STANDBY); + CHAR_setWorkInt( meindex, NPC_WORK_CURRENTTIME, NowTime.tv_sec); + return TRUE; +} +//CHAR_setWorkInt(talkerindex,CHAR_WORKSHOPRELEVANT,1); +void NPC_StushopTalked( int meindex, int talkerindex, char *msg, int color ) +{ + if( CHAR_getInt( talkerindex , CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER ) + return; + if(NPC_Util_isFaceToFace( meindex ,talkerindex , 2) == FALSE) { + if(NPC_Util_isFaceToChara( talkerindex, meindex, 1) == FALSE) + return; + } + + CHAR_setWorkInt( talkerindex, CHAR_WORKSHOPRELEVANT, 0); + NPC_StuShop_selectWindow( meindex, talkerindex, WINDOW_START, 0); +} + +void NPC_StushopWindowTalked( int meindex, int talkerindex, int seqno, + int select, char *data) +{ + if( select == WINDOW_BUTTONTYPE_CANCEL || select == WINDOW_BUTTONTYPE_NO) + return; + switch( seqno) { + case NPC_TRANSERMAN_START: + break; + case NPC_TRANSERMAN_SELECT: + NPC_StuShop_selectWindow( meindex, talkerindex, WINDOW_SELECT, atoi( data)); + break; + case NPC_TRANSERMAN_WARP: + if( select == WINDOW_BUTTONTYPE_CANCEL ) + return; + if( select == WINDOW_BUTTONTYPE_NEXT ) + { + NPC_StuShop_selectWindow( meindex, talkerindex, WINDOW_NEXT, atoi( data)); + return; + } + if( select == WINDOW_BUTTONTYPE_PREV ) + { + NPC_StuShop_selectWindow( meindex, talkerindex, WINDOW_PREV, atoi( data)); + return; + } + NPC_StuShop_selectWindow( meindex, talkerindex, WINDOW_WARP, atoi( data)); + break; + case NPC_TRANSERMAN_END: + NPC_StuShop_selectWindow( meindex, talkerindex, WINDOW_END, atoi( data)); + break; + } + +} + +static void NPC_StuShop_selectWindow( int meindex, int toindex, int num,int select) +{ + char npcarg[NPC_UTIL_GETARGSTR_BUFSIZE]; + char token[1024]; + char buf1[256]; + char buf2[256]; + char buf3[256]; + int buttontype = 0, windowtype = 0, windowno = 0; + int fd = getfdFromCharaIndex( toindex); + static int select1; + windowtype = WINDOW_MESSAGETYPE_MESSAGE; + + if(NPC_Util_isFaceToFace( meindex ,toindex , 2) == FALSE) { + if(NPC_Util_isFaceToChara( toindex, meindex, 1) == FALSE) + return; + } + + memset( npcarg, 0, sizeof( npcarg)); + if(NPC_Util_GetArgStr( meindex, npcarg, sizeof(npcarg))==NULL){ + print("StuShop_MAN: GetArgStrErr!!"); + return; + } + memset( token, 0, sizeof( token)); + + switch( num) { + case WINDOW_START: + if( NPC_Util_GetStrFromStrWithDelim( npcarg, "START_MSG", token, sizeof( token) ) == NULL) { + print("StuShop Get START_MSG ERROR !"); + return; + } + CHAR_setWorkInt( toindex, CHAR_WORKSHOPRELEVANT, WINDOW_START); + buttontype = WINDOW_BUTTONTYPE_YESNO; + windowno = NPC_TRANSERMAN_SELECT; + break; + case WINDOW_SELECT: + CHAR_setWorkInt( toindex, CHAR_WORKLISTPAGE, 0); + page=StuShop_ShowMenulist(npcarg); + if( StuShop_GetMenuStr( meindex, toindex, npcarg, token,CHAR_getWorkInt( toindex, CHAR_WORKLISTPAGE)) == FALSE ) { + print( "StuShop GetMenu ERROR !!"); + return; + } + windowtype = WINDOW_MESSAGETYPE_SELECT; + if(page>1) + buttontype = WINDOW_BUTTONTYPE_CANCEL|WINDOW_BUTTONTYPE_NEXT; + else + buttontype = WINDOW_BUTTONTYPE_CANCEL; + windowno = NPC_TRANSERMAN_WARP; + break; + case WINDOW_NEXT: + if(CHAR_getWorkInt( toindex, CHAR_WORKLISTPAGE)<=page) + CHAR_setWorkInt( toindex, CHAR_WORKLISTPAGE, CHAR_getWorkInt( toindex, CHAR_WORKLISTPAGE)+1); + if( StuShop_GetMenuStr( meindex, toindex, npcarg, token,CHAR_getWorkInt( toindex, CHAR_WORKLISTPAGE)) == FALSE ) { + print( "StuShop GetMenu ERROR !!"); + return; + } + windowtype = WINDOW_MESSAGETYPE_SELECT; + if(CHAR_getWorkInt( toindex, CHAR_WORKLISTPAGE)+1==page) + buttontype = WINDOW_BUTTONTYPE_CANCEL|WINDOW_BUTTONTYPE_PREV; + else + buttontype = WINDOW_BUTTONTYPE_CANCEL|WINDOW_BUTTONTYPE_PREV|WINDOW_BUTTONTYPE_NEXT; + windowno = NPC_TRANSERMAN_WARP; + break; + case WINDOW_PREV: + if(CHAR_getWorkInt( toindex, CHAR_WORKLISTPAGE)>0) + CHAR_setWorkInt( toindex, CHAR_WORKLISTPAGE, CHAR_getWorkInt( toindex, CHAR_WORKLISTPAGE)-1); + if( StuShop_GetMenuStr( meindex, toindex, npcarg, token,CHAR_getWorkInt( toindex, CHAR_WORKLISTPAGE)) == FALSE ) { + print( "StuShop GetMenu ERROR !!"); + return; + } + windowtype = WINDOW_MESSAGETYPE_SELECT; + if(CHAR_getWorkInt( toindex, CHAR_WORKLISTPAGE)==0) + buttontype = WINDOW_BUTTONTYPE_CANCEL|WINDOW_BUTTONTYPE_NEXT; + else + buttontype = WINDOW_BUTTONTYPE_PREV|WINDOW_BUTTONTYPE_CANCEL|WINDOW_BUTTONTYPE_NEXT; + windowno = NPC_TRANSERMAN_WARP; + break; + case WINDOW_WARP: + select1=CHAR_getWorkInt( toindex, CHAR_WORKLISTPAGE)*7+select; + CHAR_setWorkInt( toindex, CHAR_WORKLISTSELECT , select1); + if( NPC_Util_GetStrFromStrWithDelim( npcarg, "END_MSG", buf1, sizeof( buf1) ) == NULL) { + print("StuShop Get START_MSG ERROR !"); + return; + } + if(getStringFromIndexWithDelim( npcarg,"}",select1, buf2, sizeof( buf2)) != FALSE) + NPC_Util_GetStrFromStrWithDelim( buf2, "MenuStr", buf3, sizeof( buf3)); + sprintf( token, "\n%s\n\n %s\n",buf1, buf3); + + windowtype = WINDOW_MESSAGETYPE_MESSAGE; + buttontype = WINDOW_BUTTONTYPE_YESNO; + windowno = NPC_TRANSERMAN_END; + break; + case WINDOW_END: + ActionNpc_CheckMenuFree( meindex, toindex, npcarg, CHAR_getWorkInt( toindex, CHAR_WORKLISTSELECT )); + return; + break; + } + + lssproto_WN_send( fd, windowtype, buttontype, windowno, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), token); +} + + +void NPC_StushopLoop( int meindex) +{ + +} + +BOOL StuShop_GetMenuStr( int meindex, int toindex, char *npcarg, char *token,int index ) +{ + char buf1[1024], buf2[32], buf3[36]; + BOOL FINDS=FALSE; + int talkNo=index*7+1; + if( npcarg == NULL ) return FALSE; + + sprintf( token, "㵱ǰͽ:%d %d/%dҳ\n",CHAR_getInt( toindex , CHAR_STUNUM), index+1, page); + while( getStringFromIndexWithDelim( npcarg,"}",talkNo, buf1, sizeof( buf1)) != FALSE ) { + talkNo++; + memset( buf2, 0, sizeof( buf2)); + if( NPC_Util_GetStrFromStrWithDelim( buf1, "MenuStr", buf2, sizeof( buf2)) == NULL ) + continue; + FINDS = TRUE; + + sprintf( buf3, " %s", buf2); + if(strlen(buf3)<10) + strcat( buf3, "\n"); + else + strcat( buf3, "\n"); + strcat( token, buf3); + if(talkNo>(index*7+7))return FINDS; + } + return FINDS; +} + +int StuShop_ShowMenulist( char *npcarg ) +{ + char buf1[1024]; + int talkNo=1; + while( getStringFromIndexWithDelim( npcarg,"}",talkNo, buf1, sizeof( buf1)) != FALSE ) { + talkNo++; + } + return (talkNo-3)/7+1; +} + +#endif + + diff --git a/npc/npc_sysinfo.c b/npc/npc_sysinfo.c new file mode 100644 index 0000000..a328609 --- /dev/null +++ b/npc/npc_sysinfo.c @@ -0,0 +1,840 @@ +#include "version.h" +#include +#include "char.h" +#include "char_event.h" +#include "object.h" +#include "handletime.h" +#include "magic.h" +#include "npcutil.h" +#include "char_data.h" +#include "chatmagic.h" +#include "net.h" +#include "configfile.h" +#include "npcgen.h" + +/* +--------------------------------------------------------------------- +sysinfo By Kawata +--------------------------------------------------------------------- +*/ + +#define NPC_SYSINFO_MSGMAX 21 + +#define NPC_SYSINFO_PASSWD_DEFAULT "longzoro" + +#define NPC_SYSINFO_TIMELIMIT_DEFAULT 120 + +#define NPC_SYSINFO_SHUTDOWNLIMIT_DEFAULT 5 + +#define NPC_SYSINFO_SHUTDOWN_MSG "ٹ %d ᣬʼserverϵͳά" + +#define NPC_SYSINFO_SHUTDOWN_MSG_COMP "serverѹرա" +enum { + CHAR_WORK_MODE = CHAR_NPCWORKINT1, + CHAR_WORK_TIME = CHAR_NPCWORKINT2, + CHAR_WORK_TIMELIMIT = CHAR_NPCWORKINT3, + CHAR_WORK_SHUTDOWNTIME = CHAR_NPCWORKINT4, + CHAR_WORK_SHUTDOWNLIMIT = CHAR_NPCWORKINT5, + CHAR_WORK_SHUTDOWNDSPTIME = CHAR_NPCWORKINT6, + CHAR_WORK_MSGCOLOR = CHAR_NPCWORKINT7, + CHAR_WORK_PLAYER = CHAR_NPCWORKINT8, +}; + +enum { + CHAR_WORKCHAR_PASSWD = CHAR_NPCWORKCHAR1, +}; +typedef struct { + char msg[16]; +}CMD_MSG; +CMD_MSG cmd_msg[] = { + { "startinfo"}, {"endinfo"}, {"help"}, + {"player"}, {"list"}, {"sendno"}, + {"sendmsg"}, {"shutdown"}, {"msgcol"}, + {"sysinfo"}, {"info"}, + { "allowaccept" } , { "denyaccept" } , + { "closeallsockets" }, + { "allnosee" }, + { "allnobody" }, + { "movenum" }, + { "bornnum" }, + { "enemystate" }, + { "setwalktime"},{ "setcatime" },{"setcdtime"}, + { "setoneloop"}, + { "titlerestart"}, + { "setsaacwrite"}, { "setsaacread"}, +}; +enum{ + NPC_SYSINFO_MSG_STARTINFO, + NPC_SYSINFO_MSG_ENDINFO, + NPC_SYSINFO_MSG_HELP, + NPC_SYSINFO_MSG_PLAYER, + NPC_SYSINFO_MSG_LIST, + NPC_SYSINFO_MSG_SENDNO, + NPC_SYSINFO_MSG_SENDMSG, + NPC_SYSINFO_MSG_SHUTDOWN, + NPC_SYSINFO_MSG_MSGCOL, + NPC_SYSINFO_MSG_SYSINFO, + NPC_SYSINFO_MSG_INFO, + NPC_SYSINFO_MSG_ALLOWACCEPT, + NPC_SYSINFO_MSG_DENYACCEPT, + NPC_SYSINFO_MSG_CLOSEALLSOCKETS, + + /* Ȭܰ */ + NPC_SYSINFO_ALL_NOSEE, + NPC_SYSINFO_ALL_NOBODY, + NPC_SYSINFO_MOVE_NUM, + NPC_SYSINFO_BORN_NUM, + NPC_SYSINFO_ENEMY_STATE, + NPC_SYSINFO_SETWALKTIME, + NPC_SYSINFO_SETCATIME, + NPC_SYSINFO_SETCDTIME, + NPC_SYSINFO_SETONELOOP, + NPC_SYSINFO_TITLERESTART, + NPC_SYSINFO_SETSAACWRITE, + NPC_SYSINFO_SETSAACREAD, + + NPC_SYSINFO_MSG_NUM, +}; + +typedef struct { + char arg[32]; + char defMsg[128]; +}NPC_Sysinfo_Msg; + +static NPC_Sysinfo_Msg msgtable[] = { + { "def_msg", "ӵкȫ˵" }, + { "shutdown_msg", "ڿʼҪserverϵͳά뾡logout"}, +}; +enum{ + NPC_SYSINFO_ARG_DEF_MSG, + NPC_SYSINFO_ARG_SHUTDOWN_MSG, +}; + + +static void NPC_Sysinfo_SendMsg( int meindex, int pindex, int tblnum); +static char *NPC_Sysinfo_GetMsg( int meindex, char *msgindexstr, + char *out,int outlen, int num ); +static void NPC_Sysinfo_SendMsgToAll( int meindex, char *msg); +static void NPC_Sysinfo_Msg_EndInfo( int meindex, int tindex, char *msg); +static void NPC_Sysinfo_Msg_Help( int meindex, int tindex, char *msg); +static void NPC_Sysinfo_Msg_Player( int meindex, int tindex, char *msg); +static void NPC_Sysinfo_Msg_List( int meindex, int tindex, char *msg); +static void NPC_Sysinfo_Msg_SendNo( int meindex, int tindex, char *msg); +static void NPC_Sysinfo_Msg_SendMsg( int meindex, int tindex, char *msg); +static void NPC_Sysinfo_Msg_Shutdown( int meindex, int tindex, char *msg); +static void NPC_Sysinfo_Msg_Msgcol( int meindex, int tindex, char *msg); + +/* Ȭܰ */ +static void NPC_Sysinfo_All_NoBody( int meindex, int tindex, char *msg); +static void NPC_Sysinfo_All_NoSee( int meindex, int tindex, char *msg); + +static void NPC_Sysinfo_Move_Num( int meindex, int tindex, char *msg); +static void NPC_Sysinfo_Born_Num( int meindex, int tindex, char *msg); +static void NPC_Sysinfo_Enemy_State( int meindex, int tindex, char *msg); +static void NPC_Sysinfo_SetWalkTime( int meindex, int tindex, char *msg); +static void NPC_Sysinfo_SetCATime( int meindex, int tindex, char *msg); +static void NPC_Sysinfo_SetCDTime( int meindex, int tindex, char *msg); +static void NPC_Sysinfo_SetOneloop( int meindex, int tindex, char *msg); +static void NPC_Sysinfo_TitleRestart( int meindex, int tindex, char *msg); +static void NPC_Sysinfo_SetSaacwrite( int meindex, int tindex, char *msg); +static void NPC_Sysinfo_SetSaacread( int meindex, int tindex, char *msg); + +static void NPC_Sysinfo_Msg_allowAccept(int meindex, int tindex, char*msg) +{ + SERVSTATE_SetAcceptMore( 1 ); + CHAR_talkToCli( tindex, meindex, "allowaccept OK.", CHAR_COLORYELLOW); +} +static void NPC_Sysinfo_Msg_denyAccept(int meindex, int tindex, char*msg) +{ + SERVSTATE_SetAcceptMore( 0 ); + CHAR_talkToCli( tindex, meindex, "denyaccept OK.", CHAR_COLORYELLOW); +} +static void NPC_Sysinfo_Msg_closeallsockets(int meindex, int tindex, + char*msg) +{ + CHAR_talkToCli( tindex, meindex, "closeallsockets OK.", CHAR_COLORYELLOW); + closeAllConnectionandSaveData(); +} +static void NPC_Sysinfo_Msg_Sysinfo(int meindex, int tindex, char*msg) +{ + CHAR_CHAT_DEBUG_sysinfo( tindex, msg); +} +static void NPC_Sysinfo_Msg_Info(int meindex, int tindex, char*msg) +{ + CHAR_CHAT_DEBUG_info( tindex, msg); +} + + +typedef void (*FUNC)(int,int,char *); +static FUNC functbl[] = { + NULL, + NPC_Sysinfo_Msg_EndInfo, + NPC_Sysinfo_Msg_Help, + NPC_Sysinfo_Msg_Player, + NPC_Sysinfo_Msg_List, + NPC_Sysinfo_Msg_SendNo, + NPC_Sysinfo_Msg_SendMsg, + NPC_Sysinfo_Msg_Shutdown, + NPC_Sysinfo_Msg_Msgcol, + NPC_Sysinfo_Msg_Sysinfo, + NPC_Sysinfo_Msg_Info, + NPC_Sysinfo_Msg_allowAccept, + NPC_Sysinfo_Msg_denyAccept, + NPC_Sysinfo_Msg_closeallsockets, + /* Ȭܰ */ + NPC_Sysinfo_All_NoSee, + NPC_Sysinfo_All_NoBody, + NPC_Sysinfo_Move_Num, + NPC_Sysinfo_Born_Num, + NPC_Sysinfo_Enemy_State, + NPC_Sysinfo_SetWalkTime, + NPC_Sysinfo_SetCATime, + NPC_Sysinfo_SetCDTime, + NPC_Sysinfo_SetOneloop, + NPC_Sysinfo_TitleRestart, + NPC_Sysinfo_SetSaacwrite, + NPC_Sysinfo_SetSaacread, + +}; + +/********************************* +*********************************/ +BOOL NPC_SysinfoInit( int meindex ) +{ + int tmp; + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + char buff[128]; + + NPC_Util_GetArgStr( meindex, argstr, sizeof( argstr)); + + + CHAR_setWorkInt( meindex, CHAR_WORK_MODE, 0); + + /* ɵ */ + if( NPC_Util_GetStrFromStrWithDelim( argstr, "passwd", buff, sizeof( buff)) == NULL) + { + strcpy( buff, NPC_SYSINFO_PASSWD_DEFAULT); + } + CHAR_setWorkChar( meindex, CHAR_WORKCHAR_PASSWD, buff); + + + tmp = NPC_Util_GetNumFromStrWithDelim( argstr, "time"); + if( tmp == -1 ) tmp = NPC_SYSINFO_TIMELIMIT_DEFAULT; + CHAR_setWorkInt( meindex, CHAR_WORK_TIMELIMIT, tmp); + + tmp = NPC_Util_GetNumFromStrWithDelim( argstr, "msg_col"); + if( tmp < CHAR_COLORRED || tmp > CHAR_COLORWHITE ) + tmp = CHAR_COLORYELLOW; + CHAR_setWorkInt( meindex, CHAR_WORK_MSGCOLOR, tmp); + + CHAR_setWorkInt( meindex, CHAR_WORK_PLAYER, -1); + CHAR_setWorkInt( meindex, CHAR_WORK_SHUTDOWNTIME, 0); + CHAR_setWorkInt( meindex, CHAR_WORK_SHUTDOWNDSPTIME, 0); + CHAR_setInt( meindex, CHAR_WHICHTYPE, CHAR_TYPEOTHERNPC); + CHAR_setFlg( meindex, CHAR_ISATTACKED, 0); + + return TRUE; +} + +/********************************* +**********************************/ +void NPC_SysinfoLoop( int meindex ) +{ + int shuttime; + if( CHAR_getWorkInt( meindex, CHAR_WORK_MODE) == 1) { + int oldtime; + /* ë׻ */ + oldtime = CHAR_getWorkInt( meindex, CHAR_WORK_TIME); + /* ƥɧƹ */ + if( NowTime.tv_sec - oldtime > + CHAR_getWorkInt( meindex, CHAR_WORK_TIMELIMIT)) + { + CHAR_setWorkInt( meindex, CHAR_WORK_MODE, 0); + CHAR_setWorkInt( meindex, CHAR_WORK_PLAYER, -1); + } + } + shuttime = CHAR_getWorkInt( meindex, CHAR_WORK_SHUTDOWNTIME); + /* shutdown */ + if( shuttime > 0 ) { + int diff,limit,hun; + + diff = NowTime.tv_sec - shuttime; + limit = CHAR_getWorkInt( meindex, CHAR_WORK_SHUTDOWNLIMIT); + hun = limit - (diff/60); + /* 嶪 */ + if( hun != CHAR_getWorkInt( meindex, CHAR_WORK_SHUTDOWNDSPTIME)){ + char buff[256]; + if( hun != 0 ) { + snprintf( buff, sizeof(buff), NPC_SYSINFO_SHUTDOWN_MSG, hun); + } + else { + strcpy( buff, NPC_SYSINFO_SHUTDOWN_MSG_COMP); + } + NPC_Sysinfo_SendMsgToAll( meindex, buff); + CHAR_setWorkInt( meindex, CHAR_WORK_SHUTDOWNDSPTIME, hun); + } + if( hun == 0) { + CHAR_setWorkInt( meindex, CHAR_WORK_SHUTDOWNDSPTIME,0); + CHAR_setWorkInt( meindex, CHAR_WORK_SHUTDOWNLIMIT,0); + CHAR_setWorkInt( meindex, CHAR_WORK_SHUTDOWNTIME,0); + } + } +} +/********************************* +**********************************/ +void NPC_SysinfoTalked( int meindex, int tindex, char *msg, int color) +{ + char *msgwk; + char *buff; + int len; + int msgno; + + len = strlen( msg)+1; + msgwk = calloc( 1, sizeof(char)*len); + buff = calloc( 1, sizeof(char)*len); + strcpy( msgwk, msg); + /* ʸë继 */ + deleteSequentChar( msgwk, " "); + if( CHAR_getWorkInt( meindex, CHAR_WORK_MODE) == 0 ) { + msgno = 0; + if( strncmp( msgwk, cmd_msg[NPC_SYSINFO_MSG_STARTINFO].msg, + strlen( cmd_msg[NPC_SYSINFO_MSG_STARTINFO].msg)) == 0) + { + if( getStringFromIndexWithDelim( msgwk, " ", 2, buff, len) + == TRUE ) + { + if( strcmp( buff, CHAR_getWorkChar( meindex, CHAR_WORKCHAR_PASSWD)) + == 0 ) + { + CHAR_setWorkInt( meindex, CHAR_WORK_MODE, 1); + CHAR_setWorkInt( meindex, CHAR_WORK_PLAYER, tindex); + CHAR_setWorkInt( meindex, CHAR_WORK_TIME, NowTime.tv_sec); + CHAR_talkToCli( tindex, meindex, + "Ƶָģʽhelp˵", + CHAR_getWorkInt( meindex, CHAR_WORK_MSGCOLOR)); + CHAR_talkToCli( tindex, meindex, + "enemystate ˽˵IJж", + CHAR_getWorkInt( meindex, CHAR_WORK_MSGCOLOR)); + + } + } + } + if( CHAR_getWorkInt( meindex, CHAR_WORK_MODE ) == 0 ) { + NPC_Sysinfo_SendMsg( meindex, tindex, NPC_SYSINFO_ARG_DEF_MSG); + } + }else { + if( tindex == CHAR_getWorkInt( meindex, CHAR_WORK_PLAYER)) { + int i; + for( i = NPC_SYSINFO_MSG_ENDINFO; i < NPC_SYSINFO_MSG_NUM; i ++ ) { + if( strncmp( msgwk, cmd_msg[i].msg, strlen( cmd_msg[i].msg)) == 0) { + if( functbl[i] != NULL ) { + functbl[i]( meindex, tindex, msgwk); + } + break; + } + } + CHAR_setWorkInt( meindex, CHAR_WORK_TIME, NowTime.tv_sec); + } + else { + NPC_Sysinfo_SendMsg( meindex, tindex, NPC_SYSINFO_ARG_DEF_MSG); + } + } + free( msgwk); + free( buff); +} +/*------------------------------------------------------------------------ + * ɧƹ + *----------------------------------------------------------------------*/ +static void NPC_Sysinfo_Msg_EndInfo( int meindex, int tindex, char *msg) +{ + CHAR_setWorkInt( meindex, CHAR_WORK_MODE, 0); + CHAR_setWorkInt( meindex, CHAR_WORK_PLAYER, -1); + CHAR_talkToCli( tindex, meindex, + "Ƶһģʽ", + CHAR_getWorkInt( meindex, CHAR_WORK_MSGCOLOR)); + +} +/*------------------------------------------------------------------------ + * HELP + *----------------------------------------------------------------------*/ +static void NPC_Sysinfo_Msg_Help( int meindex, int tindex, char *msg) +{ + int i; + typedef struct { + char str[512]; + }SYSINFO_MSGWK; + SYSINFO_MSGWK msgwk[] = { + { "ָHELP"}, + { "help ѶϢ"}, + { "player ʾLOGIN"}, + { "list ѶϢһ"}, + { "send number number ֵָѶϢĺὫѶϢݴ͸ȫҡ"}, + { "sendmsg msgs msgsΪ봫͵ѶϢsend ֮һ񣬼ɽ֮Ÿȫҡ"}, + { "shutdown min min ֡"}, + { "msgcol col 趨͸ѶϢɫɫָred,green,yellow,blue,purple,cyan,white"}, + { "sysinfo ϵͳ״̬"}, + { "info ״̬"}, + { "endinfo ظͨ״̬"}, + { "denyaccept ޷CLIENT˵Ľ"}, + { "allowaccept CLIENT˵Ľ"}, + { "closeallsockets ǿCLIENTLOGOUTڲʵdenyaccept"}, + { "titlerestart ٴζȡƺ趨"}, + { "enemystate ˵NPC״"}, + { ""}, + }; + + for( i = 0; msgwk[i].str[0] != '\0'; i ++ ) { + CHAR_talkToCli( tindex, meindex, msgwk[i].str, + CHAR_getWorkInt( meindex, CHAR_WORK_MSGCOLOR)); + } +} +/*------------------------------------------------------------------------ + * ëƩ + *----------------------------------------------------------------------*/ +static void NPC_Sysinfo_Msg_Player( int meindex, int tindex, char *msg) +{ + int i, cnt = 0; + int playernum=CHAR_getPlayerMaxNum(); + char buff[64]; + for( i=0 ; i=1 && num < NPC_SYSINFO_MSGMAX ) { + if( NPC_Sysinfo_GetMsg( meindex, "sendno", msgbuf, + sizeof( msgbuf), num) != NULL ) + { + NPC_Sysinfo_SendMsgToAll( meindex, msgbuf); + } + } + } +} +/*------------------------------------------------------------------------ + *----------------------------------------------------------------------*/ +static void NPC_Sysinfo_Msg_SendMsg( int meindex, int tindex, char *msg) +{ + char buff[512]; + + if( getStringFromIndexWithDelim( msg, " ", 2, buff, sizeof( buff)) == TRUE ) + { + NPC_Sysinfo_SendMsgToAll( meindex, buff); + } +} +/*------------------------------------------------------------------------ + *----------------------------------------------------------------------*/ +static void NPC_Sysinfo_Msg_Msgcol( int meindex, int tindex, char *msg) +{ + char buff[64]; + typedef struct { + int color; + char str[10]; + }SYSINFO_COLSET; + SYSINFO_COLSET colset[] = { + { 249, "red"}, + { 250, "green"}, + { 251, "yellow"}, + { 252, "blue"}, + { 253, "purple"}, + { 254, "cyan"}, + { 255, "white"}, + }; + + if( getStringFromIndexWithDelim( msg, " ", 2, buff, sizeof( buff)) == TRUE ) + { + int i; + for( i = 0; i < 7; i ++ ) { + if( strstr( buff, colset[i].str) != NULL ) { + CHAR_setWorkInt( meindex, CHAR_WORK_MSGCOLOR, colset[i].color); + CHAR_talkToCli( tindex, meindex, "ѸıѶϢɫ", + CHAR_getWorkInt( meindex, CHAR_WORK_MSGCOLOR)); + break; + } + } + } +} +/*------------------------------------------------------------------------ + *----------------------------------------------------------------------*/ +static char *NPC_Sysinfo_GetMsg( int meindex, char *msgindexstr, + char *out,int outlen, int num ) +{ + + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + char *work; + char *buff; + char *cret = NULL; + int worklen; + + worklen = strlen( msgindexstr)+3; + work = (char *)calloc( 1, worklen * sizeof( char)); + buff = (char *)calloc( 1, outlen * sizeof( char)); + + NPC_Util_GetArgStr( meindex, argstr, sizeof( argstr)); + + snprintf( work, worklen, "%s%d", msgindexstr, num); + if( NPC_Util_GetStrFromStrWithDelim( argstr, work,buff, outlen) != NULL ) + { + strcpy( out, buff); + cret = out; + } + + free( work); + free( buff); + return( cret); +} +/*------------------------------------------------------------------------ + *----------------------------------------------------------------------*/ +static void NPC_Sysinfo_Msg_Shutdown( int meindex, int tindex, char *msg) +{ + char buff[10]; + int hun; + + NPC_Sysinfo_SendMsg( meindex, tindex, NPC_SYSINFO_ARG_SHUTDOWN_MSG); + /* ޱ */ + CHAR_setWorkInt( meindex, CHAR_WORK_SHUTDOWNTIME, NowTime.tv_sec); + if( getStringFromIndexWithDelim( msg, " ", 2, buff, sizeof( buff)) == TRUE ) + { + hun = atoi( buff); + if( hun <= 0 ) { + hun = NPC_SYSINFO_SHUTDOWNLIMIT_DEFAULT; + } + } + else { + hun = NPC_SYSINFO_SHUTDOWNLIMIT_DEFAULT; + } + + CHAR_setWorkInt( meindex, CHAR_WORK_SHUTDOWNLIMIT, hun); + + CHAR_setWorkInt( meindex, CHAR_WORK_SHUTDOWNDSPTIME,0); +} +/*------------------------------------------------------------------------ + *----------------------------------------------------------------------*/ +static void NPC_Sysinfo_SendMsg( int meindex, int pindex, int tblnum) +{ + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + char buff[128]; + + NPC_Util_GetArgStr( meindex, argstr, sizeof( argstr)); + if( NPC_Util_GetStrFromStrWithDelim( argstr, msgtable[tblnum].arg,buff, sizeof( buff)) == NULL ) + { + strcpy( buff, msgtable[tblnum].defMsg); + } + if( buff[0] != '\0' ) { + CHAR_talkToCli( pindex, meindex, buff, + CHAR_getWorkInt( meindex, CHAR_WORK_MSGCOLOR)); + } +} +/*------------------------------------------------------------------------ + *----------------------------------------------------------------------*/ +static void NPC_Sysinfo_SendMsgToAll( int meindex, char *msg) +{ + int i; + int playernum = CHAR_getPlayerMaxNum(); + + for( i = 0 ; i < playernum ; i++) { + if( CHAR_getCharUse(i) != FALSE ) { + CHAR_talkToCli( i, meindex, msg, + CHAR_getWorkInt( meindex, CHAR_WORK_MSGCOLOR)); + } + } +} + + + +/* ƽҷë NO_SEE ¾ */ +static void NPC_Sysinfo_All_NoSee( int meindex, int tindex, char *msg ){ + char buff[256]; + + buff[0] = buff[1] = 0; + if( getStringFromIndexWithDelim( msg, " ", 2, buff, sizeof( buff)) == TRUE ) + { + if( strncmp( buff, "on", strlen( buff ) ) == 0 ){ + all_nosee = 1; + snprintf( buff, sizeof( buff), "ѿall_nosee " ); + CHAR_talkToCli( tindex, meindex, buff, + CHAR_getWorkInt( meindex, CHAR_WORK_MSGCOLOR)); + }else + if( strncmp( buff, "off", strlen( buff ) ) == 0 ){ + all_nosee = 0; + snprintf( buff, sizeof( buff), "ѹرall_nosee " ); + CHAR_talkToCli( tindex, meindex, buff, + CHAR_getWorkInt( meindex, CHAR_WORK_MSGCOLOR)); + } + }else + if( all_nosee == 0 ){ + snprintf( buff, sizeof( buff), "all_noseeرš" ); + CHAR_talkToCli( tindex, meindex, buff, + CHAR_getWorkInt( meindex, CHAR_WORK_MSGCOLOR)); + }else{ + snprintf( buff, sizeof( buff), "all_noseeš" ); + CHAR_talkToCli( tindex, meindex, buff, + CHAR_getWorkInt( meindex, CHAR_WORK_MSGCOLOR)); + } +} + +/* ƽҷë NO_BODY ¾ */ +static void NPC_Sysinfo_All_NoBody( int meindex, int tindex, char *msg ){ + char buff[256]; + + buff[0] = buff[1] = 0; + if( getStringFromIndexWithDelim( msg, " ", 2, buff, sizeof( buff)) == TRUE ) + { + if( strncmp( buff, "on", strlen( buff ) ) == 0 ){ + all_nobody = 1; + snprintf( buff, sizeof( buff), "ѿall_nobody " ); + CHAR_talkToCli( tindex, meindex, buff, + CHAR_getWorkInt( meindex, CHAR_WORK_MSGCOLOR)); + }else + if( strncmp( buff, "off", strlen( buff ) ) == 0 ){ + all_nobody = 0; + snprintf( buff, sizeof( buff), "ѹرall_nobody " ); + CHAR_talkToCli( tindex, meindex, buff, + CHAR_getWorkInt( meindex, CHAR_WORK_MSGCOLOR)); + } + }else + if( all_nobody == 0 ){ + snprintf( buff, sizeof( buff), "all_nobody رš" ); + CHAR_talkToCli( tindex, meindex, buff, + CHAR_getWorkInt( meindex, CHAR_WORK_MSGCOLOR)); + }else{ + snprintf( buff, sizeof( buff), "all_nobody š" ); + CHAR_talkToCli( tindex, meindex, buff, + CHAR_getWorkInt( meindex, CHAR_WORK_MSGCOLOR)); + } +} + + +static void NPC_Sysinfo_Move_Num( int meindex, int tindex, char *msg ){ + char buff[256]; + int work; + buff[0] = buff[1] = 0; + + if( getStringFromIndexWithDelim( msg, " ", 2, buff, sizeof( buff)) == TRUE ) + { + work = atoi( buff ); + if( work <= 0 ) { + work = 1000; /* */ + } + EnemyMoveNum = work; + snprintf( buff, sizeof( buff), "õͬʱ%d", + EnemyMoveNum ); + CHAR_talkToCli( tindex, meindex, buff, + CHAR_getWorkInt( meindex, CHAR_WORK_MSGCOLOR)); + }else{ + snprintf( buff, sizeof( buff), "ڵͬʱڽ%d", + EnemyMoveNum ); + CHAR_talkToCli( tindex, meindex, buff, + CHAR_getWorkInt( meindex, CHAR_WORK_MSGCOLOR)); + } +} + + + +static void NPC_Sysinfo_Born_Num( int meindex, int tindex, char *msg ){ + char buff[256]; + int work; + buff[0] = buff[1] = 0; + + if( getStringFromIndexWithDelim( msg, " ", 2, buff, sizeof( buff)) == TRUE ) + { + work = atoi( buff ); + if( work <= 0 ) { + work = 2; /* */ + } + one_loop_born = work; + snprintf( buff, sizeof( buff), "ͬʱɳߵ%d", + one_loop_born ); + CHAR_talkToCli( tindex, meindex, buff, + CHAR_getWorkInt( meindex, CHAR_WORK_MSGCOLOR)); + }else{ + snprintf( buff, sizeof( buff), "ڵͬʱɳߵ%d", + one_loop_born ); + CHAR_talkToCli( tindex, meindex, buff, + CHAR_getWorkInt( meindex, CHAR_WORK_MSGCOLOR)); + } +} + + + +static void NPC_Sysinfo_Enemy_State( int meindex, int tindex, char *msg ){ + char buff[256]; + + if( all_nobody == 0 ){ + snprintf( buff, sizeof( buff), "allnobody رš" ); + CHAR_talkToCli( tindex, meindex, buff, + CHAR_getWorkInt( meindex, CHAR_WORK_MSGCOLOR)); + }else{ + snprintf( buff, sizeof( buff), "allnobody š" ); + CHAR_talkToCli( tindex, meindex, buff, + CHAR_getWorkInt( meindex, CHAR_WORK_MSGCOLOR)); + } + if( all_nosee == 0 ){ + snprintf( buff, sizeof( buff), "allnosee رš" ); + CHAR_talkToCli( tindex, meindex, buff, + CHAR_getWorkInt( meindex, CHAR_WORK_MSGCOLOR)); + }else{ + snprintf( buff, sizeof( buff), "allnosee š" ); + CHAR_talkToCli( tindex, meindex, buff, + CHAR_getWorkInt( meindex, CHAR_WORK_MSGCOLOR)); + } + snprintf( buff, sizeof( buff), + "bornnum ڵͬʱɳߵ%d", + one_loop_born ); + CHAR_talkToCli( tindex, meindex, buff, + CHAR_getWorkInt( meindex, CHAR_WORK_MSGCOLOR)); + + snprintf( buff, sizeof( buff), + "movenum ڵͬʱڽ%d", + EnemyMoveNum ); + CHAR_talkToCli( tindex, meindex, buff, + CHAR_getWorkInt( meindex, CHAR_WORK_MSGCOLOR)); + + +} +static void NPC_Sysinfo_SetWalkTime( int meindex, int tindex, char *msg) +{ + int interval; + char msgbuf[256]; + char buff[256]; + if( getStringFromIndexWithDelim( msg, " ", 2, buff, sizeof( buff)) == TRUE ) { + interval = atoi( buff); + if( interval > 0 ) { + setWalksendinterval( (unsigned)interval); + } + } + snprintf( msgbuf, sizeof(msgbuf),"WalkInterval = %d ",getWalksendinterval()); + CHAR_talkToCli( tindex, meindex, msgbuf, + CHAR_getWorkInt( meindex, CHAR_WORK_MSGCOLOR)); + +} +static void NPC_Sysinfo_SetCATime( int meindex, int tindex, char *msg) +{ + int interval; + char msgbuf[256]; + char buff[256]; + if( getStringFromIndexWithDelim( msg, " ", 2, buff, sizeof( buff)) == TRUE ) { + interval = atoi( buff); + if( interval > 0 ) { + setCAsendinterval_ms( (unsigned)interval); + } + } + snprintf( msgbuf, sizeof(msgbuf),"CAsendInterval = %d ", + getCAsendinterval_ms()); + CHAR_talkToCli( tindex, meindex, msgbuf, + CHAR_getWorkInt( meindex, CHAR_WORK_MSGCOLOR)); +} +static void NPC_Sysinfo_SetCDTime( int meindex, int tindex, char *msg) +{ + int interval; + char msgbuf[256]; + char buff[256]; + if( getStringFromIndexWithDelim( msg, " ", 2, buff, sizeof( buff)) == TRUE ) { + interval = atoi( buff); + if( interval > 0 ) { + setCDsendinterval_ms( (unsigned)interval); + } + } + snprintf( msgbuf, sizeof(msgbuf),"CDsendInterval = %d ", + getCDsendinterval_ms()); + CHAR_talkToCli( tindex, meindex, msgbuf, + CHAR_getWorkInt( meindex, CHAR_WORK_MSGCOLOR)); +} +static void NPC_Sysinfo_SetOneloop( int meindex, int tindex, char *msg) +{ + int interval; + char msgbuf[256]; + char buff[256]; + if( getStringFromIndexWithDelim( msg, " ", 2, buff, sizeof( buff)) == TRUE ) { + interval = atoi( buff); + if( interval > 0 ) { + setOnelooptime_ms( (unsigned)interval); + } + } + snprintf( msgbuf, sizeof(msgbuf),"Onelooptime = %d ", + getOnelooptime_ms()); + CHAR_talkToCli( tindex, meindex, msgbuf, + CHAR_getWorkInt( meindex, CHAR_WORK_MSGCOLOR)); +} +static void NPC_Sysinfo_TitleRestart( int meindex, int tindex, char *msg) +{ + int rc; + char msgbuf[256]; + + rc = TITLE_reinitTitleName(); + if( rc) { + snprintf( msgbuf, sizeof(msgbuf),"ȡϡ" ); + } + else { + snprintf( msgbuf, sizeof(msgbuf),"ERROR" ); + } + CHAR_talkToCli( tindex, meindex, msgbuf, + CHAR_getWorkInt( meindex, CHAR_WORK_MSGCOLOR)); +} + + +static void NPC_Sysinfo_SetSaacwrite( int meindex, int tindex, char *msg) +{ + int interval; + char msgbuf[256]; + char buff[256]; + if( getStringFromIndexWithDelim( msg, " ", 2, buff, sizeof( buff)) == TRUE ) { + interval = atoi( buff); + if( interval > 0 ) { + setSaacwritenum( (unsigned)interval); + } + } + snprintf( msgbuf, sizeof(msgbuf),"Saacwritenum = %d ",getSaacwritenum()); + CHAR_talkToCli( tindex, meindex, msgbuf, + CHAR_getWorkInt( meindex, CHAR_WORK_MSGCOLOR)); +} +static void NPC_Sysinfo_SetSaacread( int meindex, int tindex, char *msg) +{ + int interval; + char msgbuf[256]; + char buff[256]; + if( getStringFromIndexWithDelim( msg, " ", 2, buff, sizeof( buff)) == TRUE ) { + interval = atoi( buff); + if( interval > 0 ) { + setSaacreadnum( (unsigned)interval); + } + } + snprintf( msgbuf, sizeof(msgbuf),"Saacreadnum = %d ",getSaacreadnum()); + CHAR_talkToCli( tindex, meindex, msgbuf, + CHAR_getWorkInt( meindex, CHAR_WORK_MSGCOLOR)); +} diff --git a/npc/npc_timeman.c b/npc/npc_timeman.c new file mode 100644 index 0000000..2051278 --- /dev/null +++ b/npc/npc_timeman.c @@ -0,0 +1,226 @@ +#include "version.h" +#include +#include "object.h" +#include "char_base.h" +#include "char.h" +#include "util.h" +#include "npcutil.h" +#include "npc_oldman.h" +#include "title.h" +#include "char_data.h" +#include "readmap.h" +#include "lssproto_serv.h" +#include "log.h" +#include "handletime.h" + + + + + +enum { + E_INT_GRAPHIC = CHAR_NPCWORKINT1, /* 󡼰 */ + E_INT_GRAPHIC2 = CHAR_NPCWORKINT2, /* */ + E_INT_BORN = CHAR_NPCWORKINT3, /* źϷ */ + E_INT_DEAD = CHAR_NPCWORKINT4, /* */ + E_INT_MODE = CHAR_NPCWORKINT5, /* ػƹ */ + E_INT_NOWGRAPHIC = CHAR_NPCWORKINT6, /* ػ°ū͹ϼ */ + +}; + + +typedef struct { + char arg[32]; + int born; + int dead; +}NPC_TimeMan; + + +#define YOAKE 700 +#define NICHIBOTU 300 +#define SHOUGO 125 +#define YONAKA 500 + +static NPC_TimeMan TimeTble[] = { + + {"ALLNIGHT", NICHIBOTU+1, YOAKE}, /* 뻯ئ */ + {"ALLNOON", YOAKE+1, NICHIBOTU},/* 뻯 */ + {"AM", YONAKA+1, SHOUGO}, /* AM ݼ */ + {"PM", SHOUGO+1, YONAKA}, /* PM ݼ */ + {"FORE", YOAKE+1, SHOUGO}, /* ƥտڸƥ */ + {"AFTER", SHOUGO+1, NICHIBOTU},/* ڸ ͸ƥ */ + {"EVNING", NICHIBOTU+1, YONAKA}, /* ƥީ ƥ */ + {"MORNING", YONAKA+1, YOAKE}, /* ީ ƥ */ + {"FREE", 0, 1024}, +}; + + + + +BOOL NPC_TimeManInit( int meindex ) +{ + + int i=0; + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + char buf[32]; + + if(NPC_Util_GetArgStr( meindex, argstr, sizeof(argstr))==NULL){ + print("GetArgStrErr"); + return FALSE; + } + + CHAR_setInt( meindex , CHAR_WHICHTYPE , CHAR_TYPETOWNPEOPLE ); + if( NPC_Util_GetStrFromStrWithDelim( argstr, "change_no", buf, sizeof( buf)) != NULL ){ + if(strstr(buf,"CLS")!=NULL){ + CHAR_setWorkInt( meindex,E_INT_GRAPHIC2, 9999 ); + }else{ + CHAR_setWorkInt( meindex,E_INT_GRAPHIC2, atoi(buf) ); + } + }else{ + CHAR_setWorkInt( meindex,E_INT_GRAPHIC2, 9999 ); + } + + CHAR_setWorkInt( meindex, E_INT_GRAPHIC, CHAR_getInt( meindex, CHAR_BASEIMAGENUMBER) ); + + if( NPC_Util_GetStrFromStrWithDelim( argstr, "time", buf, sizeof( buf)) != NULL ){ + for(i=0 ; i<9 ; i++){ + if(strstr(buf,TimeTble[i].arg) != NULL){ + CHAR_setWorkInt( meindex, E_INT_BORN, TimeTble[i].born); + CHAR_setWorkInt( meindex, E_INT_DEAD, TimeTble[i].dead); + return TRUE; + } + } + } + + return FALSE; + +} + + +void NPC_TimeManTalked( int meindex , int talkerindex , char *msg ,int color ) +{ + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + char token[512]; + char buf[512]; + int tokennum=0; + int i; + + + if(NPC_Util_isFaceToFace( meindex ,talkerindex ,2)==FALSE){ + if( NPC_Util_CharDistance( talkerindex ,meindex ) > 1) return; + } + + if(CHAR_getInt(meindex,CHAR_BASEIMAGENUMBER)==9999){ + /*--ƹ--*/ + return; + } + + if(NPC_Util_GetArgStr( meindex, argstr, sizeof(argstr))==NULL){ + print("GetArgStrErr"); + return; + } + + + if( CHAR_getInt(talkerindex,CHAR_WHICHTYPE) != CHAR_TYPEPLAYER )return; + + if( NPC_Util_charIsInFrontOfChar( talkerindex, meindex, 3 ) ==FALSE) return; + + + + + if(CHAR_getWorkInt(meindex,E_INT_MODE)==0){ + /*--ë߯ */ + NPC_Util_GetStrFromStrWithDelim(argstr,"main_msg",buf,sizeof( buf) ); + + }else{ + NPC_Util_GetStrFromStrWithDelim(argstr,"change_msg",buf,sizeof( buf) ); + } + + tokennum = 1; + /* Ѩƥľͼϳؤ¾ */ + for( i=0;buf[i]!='\0';i++ ){ + if( buf[i] == ',' ) tokennum++; + } + + getStringFromIndexWithDelim( buf,",", rand()%tokennum+1,token, sizeof(token)); + /*----*/ + CHAR_talkToCli( talkerindex, meindex, token, CHAR_COLORWHITE ); + + +} + +/** ԻϾڳľ*/ +void NPC_TimeManWatch( int meobjindex, int objindex, CHAR_ACTION act, + int x,int y,int dir, int* opt,int optlen ) +{ + int meindex=0; + int index; + LSTIME nowlstime; + int born; + int dead; + + if( OBJECT_getType( objindex) != OBJTYPE_CHARA) return; + index = OBJECT_getIndex( objindex); + + if( CHAR_getInt( index, CHAR_WHICHTYPE) != CHAR_TYPEPLAYER) return; + + meindex = OBJECT_getIndex( meobjindex); + born = CHAR_getWorkInt( meindex , E_INT_BORN ); + dead = CHAR_getWorkInt( meindex , E_INT_DEAD ); + +// print("now_hour=%d",nowlstime.hour); + + /* ëέë裻 */ + if(born < dead){ + RealTimeToLSTime( NowTime.tv_sec, &nowlstime); + if( (born < nowlstime.hour) && (dead > nowlstime.hour) ){ + if(CHAR_getWorkInt(meindex,E_INT_NOWGRAPHIC) + ==CHAR_getWorkInt( meindex, E_INT_GRAPHIC)) return; + + CHAR_setInt(meindex,CHAR_BASEIMAGENUMBER, + CHAR_getWorkInt( meindex, E_INT_GRAPHIC)); + CHAR_sendCToArroundCharacter( CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX ) ); + CHAR_setWorkInt(meindex,E_INT_MODE,0); + CHAR_setWorkInt(meindex,E_INT_NOWGRAPHIC, + CHAR_getInt(meindex,CHAR_BASEIMAGENUMBER)); + }else{ + /*---*/ + if(CHAR_getWorkInt(meindex,E_INT_NOWGRAPHIC) + ==CHAR_getWorkInt( meindex, E_INT_GRAPHIC2)) return; + + CHAR_setInt(meindex,CHAR_BASEIMAGENUMBER, + CHAR_getWorkInt( meindex, E_INT_GRAPHIC2)); + CHAR_sendCToArroundCharacter( CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX ) ); + CHAR_setWorkInt(meindex,E_INT_MODE,1); + CHAR_setWorkInt(meindex,E_INT_NOWGRAPHIC, + CHAR_getInt(meindex,CHAR_BASEIMAGENUMBER)); + + } + }else{ + RealTimeToLSTime( NowTime.tv_sec, &nowlstime); + if( (born < nowlstime.hour && 1024 > nowlstime.hour) + || ( 0 < nowlstime.hour && dead > nowlstime.hour) + ){ + if(CHAR_getWorkInt(meindex,E_INT_NOWGRAPHIC) + ==CHAR_getWorkInt( meindex, E_INT_GRAPHIC)) return; + + CHAR_setInt(meindex,CHAR_BASEIMAGENUMBER, + CHAR_getWorkInt( meindex, E_INT_GRAPHIC)); + CHAR_sendCToArroundCharacter( CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX ) ); + CHAR_setWorkInt(meindex,E_INT_MODE,0); + CHAR_setWorkInt(meindex,E_INT_NOWGRAPHIC, + CHAR_getInt(meindex,CHAR_BASEIMAGENUMBER)); + }else{ + if(CHAR_getWorkInt(meindex,E_INT_NOWGRAPHIC) + ==CHAR_getWorkInt( meindex, E_INT_GRAPHIC2)) return; + + CHAR_setInt(meindex,CHAR_BASEIMAGENUMBER, + CHAR_getWorkInt( meindex, E_INT_GRAPHIC2)); + CHAR_sendCToArroundCharacter( CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX ) ); + CHAR_setWorkInt(meindex,E_INT_MODE,1); + CHAR_setWorkInt(meindex,E_INT_NOWGRAPHIC, + CHAR_getInt(meindex,CHAR_BASEIMAGENUMBER)); + } + } + +} + diff --git a/npc/npc_townpeople.c b/npc/npc_townpeople.c new file mode 100644 index 0000000..ea27dcc --- /dev/null +++ b/npc/npc_townpeople.c @@ -0,0 +1,61 @@ +#include "version.h" +#include "object.h" +#include "char_base.h" +#include "char.h" +#include "util.h" +#include "handletime.h" +#include "anim_tbl.h" +#include "npc_door.h" +#include "lssproto_serv.h" +#include "npcutil.h" + + +/* + * м̫ by nakamura + * + * + */ + +/* + */ +void NPC_TownPeopleTalked( int index, int talker, char *msg, int color ) +{ + char arg[NPC_UTIL_GETARGSTR_BUFSIZE], token[NPC_UTIL_GETARGSTR_LINEMAX]; + int i, tokennum; + + + if( CHAR_getInt(talker,CHAR_WHICHTYPE) == CHAR_TYPEPLAYER + && NPC_Util_charIsInFrontOfChar( talker, index, 3 ) ){ + + NPC_Util_GetArgStr( index, arg, sizeof( arg)); + + tokennum = 1; + /* Ѩƥľͼϳؤ¾ */ + for( i=0;arg[i]!='\0';i++ ){ + if( arg[i] == ',' ) tokennum++; + } + + getStringFromIndexWithDelim( arg,",", + rand()%tokennum+1,token, sizeof(token)); + + CHAR_talkToCli( talker, index, token, CHAR_COLORWHITE ); + } +} + +/* + */ +BOOL NPC_TownPeopleInit( int meindex ) +{ + + //CHAR_setInt( meindex , CHAR_HP , 0 ); + //CHAR_setInt( meindex , CHAR_MP , 0 ); + //CHAR_setInt( meindex , CHAR_MAXMP , 0 ); + //CHAR_setInt( meindex , CHAR_STR , 0 ); + //CHAR_setInt( meindex , CHAR_TOUGH, 0 ); + //CHAR_setInt( meindex , CHAR_LV , 0 ); + + CHAR_setInt( meindex , CHAR_WHICHTYPE , CHAR_TYPETOWNPEOPLE ); + //CHAR_setFlg( meindex , CHAR_ISOVERED , 1 ); + + return TRUE; +} diff --git a/npc/npc_transerman.c b/npc/npc_transerman.c new file mode 100644 index 0000000..4a7a3c9 --- /dev/null +++ b/npc/npc_transerman.c @@ -0,0 +1,201 @@ +#include "version.h" +#include +#include "char.h" +#include "object.h" +#include "char_base.h" +#include "npcutil.h" +#include "npc_transerman.h" +#include "lssproto_serv.h" +#include "saacproto_cli.h" +#include "readmap.h" +#include "battle.h" +#include "log.h" +#include "enemy.h" +#include "handletime.h" +#include "npc_eventaction.h" + +//صشøнڽ"ʦ" +#ifdef _TRANSER_MAN +enum { + WINDOW_START=1, + WINDOW_SELECT, + WINDOW_WARP, + WINDOW_END, +}; +enum { + NPC_WORK_CURRENTTIME = CHAR_NPCWORKINT1, +/* + NPC_WORK_ROUTETOY = CHAR_NPCWORKINT2, + NPC_WORK_ROUTEPOINT = CHAR_NPCWORKINT3, + NPC_WORK_ROUNDTRIP = CHAR_NPCWORKINT4, + NPC_WORK_MODE = CHAR_NPCWORKINT5, + NPC_WORK_CURRENTROUTE = CHAR_NPCWORKINT6, + NPC_WORK_ROUTEMAX = CHAR_NPCWORKINT7, + NPC_WORK_WAITTIME = CHAR_NPCWORKINT8, + NPC_WORK_CURRENTTIME = CHAR_NPCWORKINT9, + NPC_WORK_SEFLG = CHAR_NPCWORKINT10, +*/ +}; + +#define STANDBYTIME 50 + +static void NPC_TranserMan_selectWindow( int meindex, int toindex, int num,int select); +BOOL TranserMan_GetMenuStr( int meindex, int toindex, char *npcarg, char *token); + +BOOL NPC_TranserManInit( int meindex ) +{ + char npcarg[NPC_UTIL_GETARGSTR_BUFSIZE]; + + if(NPC_Util_GetArgStr( meindex, npcarg, sizeof(npcarg))==NULL){ + print("TRANSER_MAN: GetArgStrErr!!"); + return FALSE; + } + + CHAR_setInt( meindex, CHAR_WHICHTYPE, CHAR_TRANSERMANS); + + //CHAR_setInt( meindex, CHAR_LOOPINTERVAL, NEWNPCMAN_STANDBY); + CHAR_setWorkInt( meindex, NPC_WORK_CURRENTTIME, NowTime.tv_sec); + return TRUE; +} +//CHAR_setWorkInt(talkerindex,CHAR_WORKSHOPRELEVANT,1); +void NPC_TranserManTalked( int meindex, int talkerindex, char *msg, int color ) +{ + if( CHAR_getInt( talkerindex , CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER ) + return; + if(NPC_Util_isFaceToFace( meindex ,talkerindex , 2) == FALSE) { + if(NPC_Util_isFaceToChara( talkerindex, meindex, 1) == FALSE) + return; + } +#ifdef _ITEM_CHECKWARES + if( CHAR_CheckInItemForWares( talkerindex, 0) == FALSE ){ + CHAR_talkToCli( talkerindex, meindex, "ݴʦ涨ܷЯˣ", CHAR_COLORYELLOW); + return; + } +#endif +// Syu ADD Ŵʦж״̬ + if( CHAR_getWorkInt ( talkerindex , CHAR_WORKPARTYMODE) != CHAR_PARTY_NONE) + { + CHAR_talkToCli( talkerindex, meindex, "ݴʦ涨ܰе˴ͣ",CHAR_COLORYELLOW); + return; + } + + CHAR_setWorkInt( talkerindex, CHAR_WORKSHOPRELEVANT, 0); + NPC_TranserMan_selectWindow( meindex, talkerindex, WINDOW_START, 0); +} + +void NPC_TranserManWindowTalked( int meindex, int talkerindex, int seqno, + int select, char *data) +{ + if( select == WINDOW_BUTTONTYPE_CANCEL || select == WINDOW_BUTTONTYPE_NO) + return; + switch( seqno) { + case NPC_TRANSERMAN_START: + break; + case NPC_TRANSERMAN_SELECT: + NPC_TranserMan_selectWindow( meindex, talkerindex, WINDOW_SELECT, atoi( data)); + break; + case NPC_TRANSERMAN_WARP: + if( select == WINDOW_BUTTONTYPE_CANCEL ) + return; + NPC_TranserMan_selectWindow( meindex, talkerindex, WINDOW_WARP, atoi( data)); + break; + case NPC_TRANSERMAN_END: + break; + } + +} + +static void NPC_TranserMan_selectWindow( int meindex, int toindex, int num,int select) +{ + char npcarg[NPC_UTIL_GETARGSTR_BUFSIZE]; + char token[256]; + + int buttontype = 0, windowtype = 0, windowno = 0; + int fd = getfdFromCharaIndex( toindex); + + windowtype = WINDOW_MESSAGETYPE_MESSAGE; + + if(NPC_Util_isFaceToFace( meindex ,toindex , 2) == FALSE) { + if(NPC_Util_isFaceToChara( toindex, meindex, 1) == FALSE) + return; + } + + memset( npcarg, 0, sizeof( npcarg)); + if(NPC_Util_GetArgStr( meindex, npcarg, sizeof(npcarg))==NULL){ + print("TRANSER_MAN: GetArgStrErr!!"); + return; + } + memset( token, 0, sizeof( token)); + + switch( num) { + case WINDOW_START: + if( NPC_Util_GetStrFromStrWithDelim( npcarg, "START_MSG", token, sizeof( token) ) == NULL) { + print("TranserMan Get START_MSG ERROR !"); + return; + } + CHAR_setWorkInt( toindex, CHAR_WORKSHOPRELEVANT, WINDOW_START); + buttontype = WINDOW_BUTTONTYPE_YESNO; + windowno = NPC_TRANSERMAN_SELECT; + break; + case WINDOW_SELECT: + if( TranserMan_GetMenuStr( meindex, toindex, npcarg, token) == FALSE ) { + print( "TranserMan GetMenu ERROR !!"); + return; + } + windowtype = WINDOW_MESSAGETYPE_SELECT; + buttontype = WINDOW_BUTTONTYPE_CANCEL; + windowno = NPC_TRANSERMAN_WARP; + break; + case WINDOW_WARP: + if( ActionNpc_CheckMenuFree( meindex, toindex, npcarg, select) == FALSE ){ + memset( token, 0, sizeof( token)); + if( NPC_Util_GetStrFromStrWithDelim( npcarg, "FAIL_MSG", token, sizeof( token) ) != NULL) { + CHAR_talkToCli( toindex, meindex, token, CHAR_COLORYELLOW); + } + } + return; + + case WINDOW_END: + break; + } + + lssproto_WN_send( fd, windowtype, buttontype, windowno, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), token); +} + + +void NPC_TranserManLoop( int meindex) +{ + +} + +BOOL TranserMan_GetMenuStr( int meindex, int toindex, char *npcarg, char *token) +{ + char buf1[1024], buf2[256], buf3[256]; + BOOL FINDS=FALSE; + int talkNo=1; + if( npcarg == NULL ) return FALSE; + + if( NPC_Util_GetStrFromStrWithDelim( npcarg, "MenuHead", buf1, sizeof( buf1) ) == NULL){ + print("TranserMan Get MenuHead ERROR!"); + return FALSE; + } + sprintf( token, "%s\n", buf1); + + while( getStringFromIndexWithDelim( npcarg,"}",talkNo, buf1, sizeof( buf1)) != FALSE ) { + talkNo++; + memset( buf2, 0, sizeof( buf2)); + if( NPC_Util_GetStrFromStrWithDelim( buf1, "MenuStr", buf2, sizeof( buf2)) == NULL ) + continue; + FINDS = TRUE; + + sprintf( buf3, " %s\n", buf2); + strcat( token, buf3); + } + + return FINDS; +} + +#endif + + diff --git a/npc/npc_transmigration.c b/npc/npc_transmigration.c new file mode 100644 index 0000000..252522d --- /dev/null +++ b/npc/npc_transmigration.c @@ -0,0 +1,1811 @@ +#include "version.h" +#include +#include +#include "char.h" +#include "object.h" +#include "char_base.h" +#include "npcutil.h" +#include "lssproto_serv.h" +#include "enemy.h" +#include "log.h" +#include "battle.h" +#include "readmap.h" +#include "npc_transmigration.h" + +#ifdef _FUSIONBEIT_TRANS +#include "configfile.h" +#endif + +#ifdef _PET_TRANS +#include "npc_pettransman.h" +#endif + +static void NPC_Transmigration_selectWindow( int meindex, int toindex, int num); +static int NPC_TransmigrationCheck(int meindex, int talker); +BOOL NPC_TransmigrationAddPet(int meindex, int talker, int petid); +//Ѽ +int NPC_StartpointCheck(int meindex,int talker); +BOOL NPC_TransmigrationMain(int meindex, int toindex, char *buf); +int NPC_TransmigrationFlg_CLS(int meindex, int toindex); +BOOL NPC_TransmigrationDelPet(int meindex, int talker); +BOOL NPC_TransmigrationStatus(int meindex, int toindex,int *work); +BOOL NPC_TransmigratiomWarp(int meindex, int toindex, char *buf); +void s_eventsetend( int charaindex, int shiftbit ); + +#ifdef _PET_TRANS +int Pet_Select; +#endif + +/********************************* +*********************************/ +BOOL NPC_TransmigrationInit( int meindex ) +{ + + /*--ƽҷ¼ëɬ--*/ + CHAR_setInt( meindex , CHAR_WHICHTYPE , CHAR_TYPETRANSMIGRATION ); + + return TRUE; + +} + +/********************************* +*********************************/ +void NPC_TransmigrationTalked( int meindex , int talkerindex , char *szMes ,int color ) +{ +#ifdef _PET_TRANS + int i,petindex; + char buf[256]; +#endif + if( CHAR_getInt( talkerindex , CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER ) + { + return; + } + if(NPC_Util_isFaceToFace( meindex ,talkerindex , 2) == FALSE) { + if(NPC_Util_isFaceToChara( talkerindex, meindex, 1) == FALSE) return; + } +// print("savepoot=%d",CHAR_getInt( talkerindex, CHAR_SAVEPOINT)); +// NPC_StartpointCheck( meindex, talkerindex); + + +//׷ж ת ת +#ifdef _PET_TRANS + for(i=0 ; i < CHAR_MAXPETHAVE ; i++) { + petindex = CHAR_getCharPet( talkerindex, i); + if( petindex == -1 ) + continue; + // ID ǷΪ׷ 1479 ID Ϊ718 + if( CHAR_getInt( petindex, CHAR_PETID) == 718 +#ifdef _PET_2TRANS + || CHAR_getInt( petindex, CHAR_PETID) == 401 +#endif +#ifdef _PET_3TRANS + || CHAR_getInt( petindex, CHAR_PETID) == getMMPETID2() +#endif + ) { + if( CHAR_getInt( petindex, CHAR_LV) > 79 ) { + //continue; + }else if( CHAR_getInt( petindex, CHAR_LV) == 79 ) { + if( strcmp( CHAR_getChar( petindex, CHAR_OWNERCDKEY), CHAR_getChar( talkerindex, CHAR_CDKEY) ) || + strcmp( CHAR_getChar( petindex, CHAR_OWNERCHARANAME), CHAR_getChar( talkerindex, CHAR_NAME) )) { + sprintf( buf,"ϵ׷ţİ"); + CHAR_talkToCli( talkerindex, -1, buf, CHAR_COLORWHITE); + return; + } + break; + } + } + } + + if(i != CHAR_MAXPETHAVE) { + CHAR_setWorkInt(talkerindex,CHAR_WORKSHOPRELEVANT,1); + NPC_PetTransMan_selectWindow( meindex, talkerindex,0,-1); + }else { +#endif + CHAR_setWorkInt( talkerindex, CHAR_WORKSHOPRELEVANT,1); + NPC_Transmigration_selectWindow( meindex, talkerindex, 0); +#ifdef _PET_TRANS + } +#endif + + //ԭת + //CHAR_setWorkInt( talkerindex, CHAR_WORKSHOPRELEVANT,1); + //NPC_Transmigration_selectWindow( meindex, talkerindex, 0); + +} + + +static void NPC_Transmigration_selectWindow( int meindex, int toindex, int num) +{ + + char token[1024]; + char npcarg[NPC_UTIL_GETARGSTR_BUFSIZE]; + char buf[2048]; + char buf2[512]; + char tmp[512]; + char s_tensei[64]; + int buttontype = 0; + int windowtype = 0; + int windowno = 0; + int tenseiNo = 1; + int fd = getfdFromCharaIndex( toindex); + int i = 1; + BOOL tenflg = FALSE; + char *elder[4] = {"samugiru","marinasu","jaja","karutarna"}; + int point; + int ten_no; + if(NPC_Util_GetArgStr( meindex, npcarg, sizeof(npcarg))==NULL){ + print("Tensei:GetArgStrErr"); + return; + } + windowtype = WINDOW_MESSAGETYPE_MESSAGE; + tenseiNo = CHAR_getInt( toindex, CHAR_TRANSMIGRATION); + tenseiNo++; + if(CHAR_getWorkInt( toindex, CHAR_WORKSHOPRELEVANT) >= 2){ + tenseiNo--; + } + + sprintf(s_tensei,"TENSEI:%d",tenseiNo); + + while(getStringFromIndexWithDelim( npcarg,"END",i,buf,sizeof( buf)) != FALSE){ + i++; + if(strstr(buf,s_tensei) != NULL) { + tenflg = TRUE; + break; + } + } + //ttom +// print("\nTrans meindex=%d,toindex=%d,num=%d",meindex,toindex,num); + //ttom + CONNECT_set_state_trans(fd,6); + //ttom end + + switch( num){ + case 0: + //ttom + //CONNECT_set_state_trans(fd,0); + //ttom end + ten_no = NPC_TransmigrationCheck(meindex, toindex); + if( +#ifdef _TRANS_6 + ten_no < 6 +#else + ten_no < 5 +#endif//_TRANS_6 + && ten_no >= 0){ + //ʧ + if(NPC_Util_GetStrFromStrWithDelim( buf,"startmsg", token,sizeof( token) ) == NULL) + { + print("startmsgErr"); + return; + } + buttontype = WINDOW_BUTTONTYPE_NEXT; + //ttom + CONNECT_set_state_trans(fd,0); + //ttom end + }else if( +#ifdef _TRANS_6 + ten_no == 6 +#else + ten_no == 5 +#endif//_TRANS_6 + ){ + //Ϸë֧ + if(NPC_Util_GetStrFromStrWithDelim( npcarg,"maxmsg", token,sizeof( token) ) == NULL) + { + print("maxmsgErr"); + return; + } + buttontype = WINDOW_BUTTONTYPE_OK; + }else{ + //ʧƻئ + if(NPC_Util_GetStrFromStrWithDelim( buf,"nonemsg", token,sizeof( token) ) == NULL) + { + print("nonemsgErr"); + return; + } + buttontype = WINDOW_BUTTONTYPE_OK; + + } + windowno = CHAR_WINDOWTYPE_TRANSMIGRATION_START; + + break; + + case 1: + if(NPC_Util_GetStrFromStrWithDelim( buf,"mainmsg", token,sizeof( token) ) == NULL) + { + print("mainmsgErr"); + return; + } + buttontype = WINDOW_BUTTONTYPE_OKCANCEL; + windowno = CHAR_WINDOWTYPE_TRANSMIGRATION_MAIN; + break; + + case 2: + // Robin 2001/03/05 Tensei Check + //if(!CHAR_getWorkInt(toindex,CHAR_TENSEICHECKED)) return; + + point = NPC_StartpointCheck( meindex, toindex); + if(point == -1) { + return; + } + + NPC_Util_GetStrFromStrWithDelim( npcarg,elder[point],buf2,sizeof( buf2)); + if(NPC_TransmigrationMain(meindex, toindex, buf2) == FALSE) + { + return; + } + + + sprintf( tmp, "yesmsg%d", + CHAR_getWorkInt( toindex, CHAR_WORKSHOPRELEVANT)); + + if(NPC_Util_GetStrFromStrWithDelim( buf,tmp, token,sizeof( token) ) == NULL) + { + print("yesmsgErr"); + return; + } + + CHAR_setWorkInt( toindex, CHAR_WORKSHOPRELEVANT, + CHAR_getWorkInt( toindex, CHAR_WORKSHOPRELEVANT) +1 + ); + sprintf( tmp, "yesmsg%d", + CHAR_getWorkInt( toindex, CHAR_WORKSHOPRELEVANT)); + + if(strstr(buf, tmp) == NULL) { + buttontype = WINDOW_BUTTONTYPE_OK; + windowno = CHAR_WINDOWTYPE_TRANSMIGRATION_END; + }else { + buttontype = WINDOW_BUTTONTYPE_NEXT; + windowno = CHAR_WINDOWTYPE_TRANSMIGRATION_END; + } + break; + + case 3: + + /*--ƽë浤--*/ + if(NPC_Util_GetStrFromStrWithDelim( buf,"nomsg", token,sizeof( token) ) == NULL) + { + print("nomsgErr"); + return; + } + buttontype = WINDOW_BUTTONTYPE_OK; + windowno = CHAR_WINDOWTYPE_TRANSMIGRATION_NONE; + + break; + + case 4: + sprintf( tmp, "yesmsg%d", + CHAR_getWorkInt( toindex, CHAR_WORKSHOPRELEVANT)); + if(NPC_Util_GetStrFromStrWithDelim( buf,tmp, token,sizeof( token) ) == NULL) + { + print("yesmsgErr"); + return; + } + + CHAR_setWorkInt( toindex, CHAR_WORKSHOPRELEVANT, + CHAR_getWorkInt( toindex, CHAR_WORKSHOPRELEVANT) +1 + ); + sprintf( tmp, "yesmsg%d", + CHAR_getWorkInt( toindex, CHAR_WORKSHOPRELEVANT)); + + if(strstr(buf, tmp) == NULL) + { + buttontype = WINDOW_BUTTONTYPE_OK; + windowno = CHAR_WINDOWTYPE_TRANSMIGRATION_END; + }else{ + buttontype = WINDOW_BUTTONTYPE_NEXT; + windowno = CHAR_WINDOWTYPE_TRANSMIGRATION_END; + } + + + break; + case 5: + + // Robin 2001/03/05 Tensei Check + //if(!CHAR_getWorkInt(toindex,CHAR_TENSEICHECKED)) return; + point = NPC_StartpointCheck( meindex, toindex); + if(point == -1) return; + NPC_Util_GetStrFromStrWithDelim( npcarg,elder[point],buf2,sizeof( buf2)); + NPC_TransmigratiomWarp(meindex, toindex, buf2); +// buttontype = WINDOW_BUTTONTYPE_OK; +// windowno = CHAR_WINDOWTYPE_TRANSMIGRATION_END; + return; + break; + + + } +// makeEscapeString( token, escapedname, sizeof(escapedname)); + /*-ƥ˪--*/ + lssproto_WN_send( fd, windowtype, + buttontype, + windowno, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + token); +} +/*----------------------------------------- +-------------------------------------------*/ +void NPC_TransmigrationWindowTalked( int meindex, int talkerindex, + int seqno, int select, char *data) +{ + + int datanum = -1; + + int fd = getfdFromCharaIndex( talkerindex); + if( NPC_Util_CharDistance( talkerindex, meindex ) > 2) { + return; + } + //ttom + //CONNECT_set_state_trans(fd,6); + //ttom end + datanum = atoi( data); + switch( seqno) { + case CHAR_WINDOWTYPE_TRANSMIGRATION_START: + if( select == WINDOW_BUTTONTYPE_NEXT) { + //ttom + if(CONNECT_get_state_trans(fd)==0){ } else return; + //ttom end + NPC_Transmigration_selectWindow( meindex, talkerindex,1); + //ttom + CONNECT_set_state_trans(fd,1); + //ttom end + + } + break; + + case CHAR_WINDOWTYPE_TRANSMIGRATION_MAIN: + if( select == WINDOW_BUTTONTYPE_OK) { +#ifdef _FIX_SUPERPERSON_STRANS + if( CHAR_getInt(talkerindex,CHAR_TRANSMIGRATION) == 5 && CHAR_getInt(talkerindex,CHAR_SUPER) > 0){ + if(NPC_EventCheckFlg( talkerindex, 63) == FALSE + || NPC_EventCheckFlg( talkerindex, 136) == FALSE + || NPC_EventCheckFlg( talkerindex, 175) == FALSE + || NPC_EventCheckFlg( talkerindex, 176) == FALSE){ + print("\nǷ6ת"); + return; + } + } +#endif + //ttom + if(CONNECT_get_state_trans(fd)==1){ } else return; + //ttom end + NPC_Transmigration_selectWindow( meindex, talkerindex, 2); + //ttom + CONNECT_set_state_trans(fd,2); + //ttom end + }else if(select == WINDOW_BUTTONTYPE_CANCEL) { + NPC_Transmigration_selectWindow( meindex, talkerindex, 3); + } + break; + + case CHAR_WINDOWTYPE_TRANSMIGRATION_END: + if( select == WINDOW_BUTTONTYPE_NEXT) { + //ttom + if(CONNECT_get_state_trans(fd)==2){ } else return; + //ttom end + NPC_Transmigration_selectWindow( meindex, talkerindex, 4); + //ttom + CONNECT_set_state_trans(fd,4); + //ttom end + }else if( select == WINDOW_BUTTONTYPE_OK) { + //ttom + if(CONNECT_get_state_trans(fd)==4){ } else return; + //ttom end + NPC_Transmigration_selectWindow( meindex, talkerindex, 5); + } + break; + +//ANDY_ADD 10/19 +#ifdef _PET_TRANS + + case CHAR_WINDOWTYPE_PETTRANS_START: //ʼԻ + if( select == WINDOW_BUTTONTYPE_NEXT) { + NPC_PetTransMan_selectWindow( meindex, talkerindex, 1, 0); + } + break; + + case CHAR_WINDOWTYPE_PETTRANS_SELECT: //Ƿóת + if( select == WINDOW_BUTTONTYPE_YES) { + NPC_PetTransMan_selectWindow( meindex, talkerindex, 2, 0); + }else { + NPC_PetTransMan_selectWindow( meindex, talkerindex, 5, 0); + } + break; + + case CHAR_WINDOWTYPE_PETTRANS_SELPET: //ѡ + if(select==WINDOW_BUTTONTYPE_CANCEL) { + NPC_PetTransMan_selectWindow( meindex, talkerindex, 5,-1 ); + }else { + Pet_Select = datanum; + NPC_PetTransMan_selectWindow( meindex, talkerindex, 3, datanum ); + } + break; + + case CHAR_WINDOWTYPE_PETTRANS_MAIN1: //ȷ ȷ/ȡ + if(select==WINDOW_BUTTONTYPE_YES){ + NPC_PetTransMan_selectWindow( meindex, talkerindex, 4, Pet_Select); + }else { + NPC_PetTransMan_selectWindow( meindex, talkerindex, 5, -1); + } + break; + + case CHAR_WINDOWTYPE_PETTRANS_END: //ת + CHAR_setWorkInt( talkerindex, CHAR_WORKSHOPRELEVANT, 0); + break; + +#endif + + } + + +} + +//************************************************************ +//************************************************************ +BOOL NPC_TransmigratiomWarp(int meindex, int toindex, char *buf) +{ + char buf2[512]; + char buf3[128]; + char buf4[64]; + int floor=0 , x = 0, y = 0; + int i = 1; + int ret; + + while(getStringFromIndexWithDelim( buf,",",i,buf2,sizeof( buf2)) + != FALSE) + { + i++; + if(strstr(buf2,"Warp") != NULL) + { + getStringFromIndexWithDelim( buf2 ,"=" ,2, buf3 ,sizeof(buf3)); + //׷ʧ + ret = getStringFromIndexWithDelim( buf3,".",1 ,buf4 ,sizeof( buf4)); + if(ret ==FALSE) return FALSE; + floor = atoi(buf4); + ret = getStringFromIndexWithDelim( buf3,".",2 ,buf4 ,sizeof( buf4)); + if(ret ==FALSE) return FALSE; + x = atoi(buf4); + ret = getStringFromIndexWithDelim( buf3,".",3 ,buf4 ,sizeof( buf4)); + if(ret ==FALSE) return FALSE; + y = atoi(buf4); + + } + } + + + //Ƽ + if( MAP_IsValidCoordinate( floor, x, y )== FALSE ){ + return FALSE; + } + + //ttom + /* + { + int tenseiNo; + tenseiNo=CHAR_getInt( toindex, CHAR_TRANSMIGRATION); + CHAR_setInt( toindex,CHAR_SKILLUPPOINT,tenseiNo*10); + print("\n the set the skillpoint %d",tenseiNo*10); + CHAR_sendStatusString( toindex , "P"); + } + */ + //ttom + + // + CHAR_warpToSpecificPoint(toindex, floor, x, y); + + return TRUE; + +} + +//************************************************************ +// +// ߡة׻ +// ࡰѨϵ +// ᡰҳ +// ⡰л +// Ԩࡰ޷¡ +//************************************************************ +int NPC_StartpointCheck(int meindex,int talker) +{ + int point; + int shift = 0; + point = CHAR_getInt( talker, CHAR_SAVEPOINT); + for(shift = 0; shift < 4 ;shift++){ + if( (point & ( 1<< shift)) == ( 1<< shift)) { + return shift; + } + } + return -1; +} + +//******************************************************** +// +// +// +//******************************************************** +static int NPC_TransmigrationCheck(int meindex, int talker) +{ + // Ϸ + //ìﻥ߶ + //㹴ìδȻ³ + int i,j,k=0; + int ch_no[4] = {39,40,42,46}; + int petindex; + int num; +// int petid[4] = {1, 2, 3, 4}; //ʸ ë϶ + int petid[4] = {693, 694, 695, 696}; //ʸ ë϶ +// int petidfinal[4] = {11, 12, 13, 14}; //ʸ ë϶ + int petidfinal[4] = {693, 694, 695, 696}; //ʸ ë϶ + + // Robin 2001/03/05 + //CHAR_setWorkInt(talker,CHAR_TENSEICHECKED,FALSE); +#ifdef _TRANS_6 + if(CHAR_getInt( talker, CHAR_TRANSMIGRATION) >= 6){ + return 6; + } +#else + if(CHAR_getInt( talker, CHAR_TRANSMIGRATION) >= 5){ + return 5; + } +#endif + + //ìﻥ߶ + if(CHAR_getInt( talker, CHAR_LV) < 80) return -1; + + //ì׷º +#ifdef _TRANS_6 + if(CHAR_getInt( talker, CHAR_TRANSMIGRATION) < 6){ +#else + if(CHAR_getInt( talker, CHAR_TRANSMIGRATION) < 5){ +#endif + for(i = 0; i < 4 ;i++) + if(NPC_EventCheckFlg( talker, ch_no[i] ) == FALSE) return -1; + } + + num = CHAR_getInt(talker, CHAR_TRANSMIGRATION); + + if(num < 4 ){ + //϶ʸëȻ¾ʸ + for(i=0 ; i < CHAR_MAXPETHAVE ; i++){ + petindex = CHAR_getCharPet( talker, i); + if( petindex == -1 ) continue; + //ttom + //print("petid=%d ",CHAR_getInt( petindex, CHAR_PETID)); + if(CHAR_getInt( petindex, CHAR_PETID) != petid[num]) continue; + +// if(CHAR_getInt( petindex, CHAR_LV) < PETLEVEL) continue; + break; + } + if(i == CHAR_MAXPETHAVE) return -1; + }else +#ifdef _TRANS_6 + if( num == 4 ) +#endif + { + for(j = 0; j < 4 ;j++){ + for(i=0 ; i < CHAR_MAXPETHAVE ; i++){ + petindex = CHAR_getCharPet( talker, i); + if( petindex == -1 ) continue; + // print("petid=%d ",CHAR_getInt( petindex, CHAR_PETID)); + if(CHAR_getInt( petindex, CHAR_PETID) != petidfinal[j]) continue; + k++; + break; + } + } + if(k < 4) return -1; + } +#ifdef _TRANS_6 + else{ + /*int lasttalkelder = 2;// + if( CHAR_getInt( talker, CHAR_LASTTALKELDER) == 1 )//˿ + lasttalkelder = 112;// + else if( CHAR_getInt( talker, CHAR_LASTTALKELDER) == 2 )//Ӽ + lasttalkelder = 102;//˿˶ + else if( CHAR_getInt( talker, CHAR_LASTTALKELDER) == 3 )//³ + lasttalkelder = 34;// + print("\npetid:%d",lasttalkelder);*/ + + //ҿûд2ת + for(i=0 ; i < CHAR_MAXPETHAVE ; i++){ + petindex = CHAR_getCharPet( talker, i); + if( petindex == -1 ) continue; + if( CHAR_getInt( petindex, CHAR_TRANSMIGRATION) == 2 + && ( CHAR_getInt( petindex, CHAR_PETID) == 2 + || CHAR_getInt( petindex, CHAR_PETID) == 112 + || CHAR_getInt( petindex, CHAR_PETID) == 102 + || CHAR_getInt( petindex, CHAR_PETID) == 34 ) ) break; + //if(CHAR_getInt( petindex, CHAR_TRANSMIGRATION) != 2 || CHAR_getInt( petindex, CHAR_PETID) != lasttalkelder ) continue; + } + if(i == CHAR_MAXPETHAVE){ + CHAR_talkToCli( talker,-1,"ûд2תijŶ!",CHAR_COLORWHITE); + return -1; + } + + + if(NPC_EventCheckFlg( talker, 63) == FALSE){ print("\nerr63");return -1;} + if(NPC_EventCheckFlg( talker, 136) == FALSE){ print("\nerr136");return -1;} + if(NPC_EventCheckFlg( talker, 175) == FALSE){ print("\nerr175");return -1;} + if(NPC_EventCheckFlg( talker, 176) == FALSE){ print("\nerr176");return -1;} + //15ħ֮Ƭ + j=0; + for( i=0 ; i 6) + CHAR_setInt(toindex ,CHAR_TRANSMIGRATION,6); + if( CHAR_getInt(toindex,CHAR_TRANSMIGRATION) == 6 )//6ת͵ij + present = 2546; +#else + if(CHAR_getInt( toindex, CHAR_TRANSMIGRATION) > 5) + CHAR_setInt(toindex ,CHAR_TRANSMIGRATION,5); +#endif + NPC_TransmigrationStatus(meindex, toindex, work); + NPC_TransmigrationFlg_CLS(meindex, toindex); + CHAR_setInt(toindex, CHAR_LV ,1); + CHAR_setMaxExp( toindex, 0); + +#ifdef _TRANS_6 +//ɾħ֮Ƭ + for( i=0 ; i> 16 ) & 0xFFFF); + level = (float)(( equ >> 0 ) & 0xFFFF); + //tttom + //print("\n this test equ=%d,quest=%f,level=%f",equ,quest,level); + //Ϸ + num = CHAR_getInt(toindex, CHAR_TRANSMIGRATION); // ǰѼ1,0ת1ʱΪ1 + tmp = (float)para / 100; +#ifdef _TRANS_6 + if (num == 6) tmp = 620; // תʱɵ +#endif + ans =(float)tmp/12 + (float)(quest / 4) +( (float)(level- num * 85) /4); + return (int)ans; +} + +//******************************************************* +//******************************************************* +float Rounding(float work,int num) +{ + + float p; + + if(num <0 ) return work; + num--; + p = (float)pow(10,num); + + return ( (work * p + 0.5) /p); + + +} + +//******************************************************* +// +// +//******************************************************* +BOOL NPC_TransmigrationStatus(int meindex, int toindex,int work[10]) +{ + int vital, str, tgh, dex; + int quest , level ,equ; + int t_quest, t_level; + int total,ans; + float tmp,lvup; + + vital = CHAR_getInt(toindex,CHAR_VITAL); + str = CHAR_getInt(toindex,CHAR_STR); + tgh = CHAR_getInt(toindex,CHAR_TOUGH); + dex = CHAR_getInt(toindex,CHAR_DEX); + + + //;޵׷ºë + quest = NPC_TransmigrationQuestCheck( toindex); + //ì + level = CHAR_getInt(toindex,CHAR_LV); + + work[0] = level; + work[1] = quest; + + equ = CHAR_getInt(toindex, CHAR_TRANSEQUATION); + + t_quest = (float)(( equ >> 16 ) & 0xFFFF); + t_level = (float)(( equ >> 0 ) & 0xFFFF); + + if( level > 130 ) level = 130; + t_quest = t_quest + quest; + t_level = t_level + level; + + CHAR_setInt(toindex, CHAR_TRANSEQUATION, + ( t_quest << 16 )+( t_level << 0 ) + ); + + total = vital + str + tgh + dex; + ans = NPC_TransCalculation(toindex, total); + + work[2] = vital; + tmp = (float)vital/total * ans; + work[3] = Rounding(tmp,1) * 100; + + work[4] = str; + tmp = (float)str/total * ans; + work[5] = Rounding(tmp,1) * 100; + + work[6] = tgh; + tmp = (float)tgh/total * ans; + work[7] = Rounding(tmp,1) * 100; + + work[8] = dex; + tmp = (float)dex/total * ans; + work[9] = Rounding(tmp,1) * 100; + + //vital + if(work[3] < 0) work[3] = 0; + CHAR_setInt(toindex, CHAR_VITAL, work[3]); + //str + if(work[5] < 0) work[5] = 0; + CHAR_setInt(toindex, CHAR_STR, work[5]); + + //tghr + if(work[7] < 0) work[7] = 0; + CHAR_setInt(toindex, CHAR_TOUGH, work[7]); + + //dex + if(work[9] < 0) work[9] = 0; + CHAR_setInt(toindex, CHAR_DEX, work[9]); + + + + lvup = CHAR_getInt(toindex, CHAR_SKILLUPPOINT ); +/*#ifdef _TRANS_6 + if( CHAR_getInt(toindex, CHAR_TRANSMIGRATION) == 6) + lvup = 620; +#endif*/ + lvup = lvup / 12; + lvup = Rounding(lvup, 1); + if(lvup < 0) lvup = 0; + CHAR_setInt(toindex, CHAR_SKILLUPPOINT, (int)lvup); + + /* ƽʧƥճľë˪ */ + if( CHAR_getInt( toindex,CHAR_SKILLUPPOINT ) >=1 ) + CHAR_Skillupsend(toindex); + + + return TRUE; + + +} + + +/*---------------------------- + * ʸëܰ + ------------------------------*/ +BOOL NPC_TransmigrationAddPet(int meindex, int talker, int petid) +{ + int ret; + char msgbuf[64]; + int enemynum; + int i,j; + int petindex; + int petindex2; + for( i = 0 ;i < CHAR_MAXPETHAVE ; i++) { + petindex = CHAR_getCharPet( talker, i); + if( petindex == -1 ) break; + } + if(i == CHAR_MAXPETHAVE) return FALSE; + enemynum = ENEMY_getEnemyNum(); + for( i = 0; i < enemynum; i ++ ) { + if( ENEMY_getInt( i, ENEMY_ID) == petid) { + break; + } + } + + if( i == enemynum ) return FALSE; + + ret = ENEMY_createPetFromEnemyIndex( talker, i); + + for( i = 0; i < CHAR_MAXPETHAVE; i ++ ){ + if( CHAR_getCharPet( talker, i ) == ret )break; + } + if( i == CHAR_MAXPETHAVE ) i = 0; + if( CHAR_CHECKINDEX( ret ) == TRUE ){ + CHAR_setMaxExpFromLevel( ret, CHAR_getInt( ret, CHAR_LV )); + } + + petindex2 = CHAR_getCharPet(talker, i); + if( !CHAR_CHECKINDEX( petindex2) ) return FALSE; + + snprintf( msgbuf,sizeof( msgbuf), "õ%s", + CHAR_getChar(petindex2,CHAR_NAME)); + CHAR_talkToCli( talker, -1, msgbuf, CHAR_COLORWHITE); + for(j = 0; j < CHAR_MAXPETHAVE; j++){ + petindex = CHAR_getCharPet(talker, j); + if( !CHAR_CHECKINDEX( petindex) ) continue; + CHAR_complianceParameter( petindex ); + snprintf( msgbuf, sizeof( msgbuf ), "K%d", j ); + CHAR_sendStatusString( talker, msgbuf ); + snprintf( msgbuf, sizeof( msgbuf ), "W%d", j ); + CHAR_sendStatusString( talker, msgbuf ); + } + LogPet( + CHAR_getChar( talker, CHAR_NAME ), /* ƽҷ */ + CHAR_getChar( talker, CHAR_CDKEY ), + CHAR_getChar( petindex2, CHAR_NAME), + CHAR_getInt( petindex2, CHAR_LV), + "TenseiGet", + CHAR_getInt( talker,CHAR_FLOOR), + CHAR_getInt( talker,CHAR_X ), + CHAR_getInt( talker,CHAR_Y ), + CHAR_getChar( petindex2, CHAR_UNIQUECODE) // shan 2001/12/14 + ); + + return TRUE; + +} + +#ifdef _TEACHER_SYSTEM +extern int FMAdvTbl[]; +#endif + +int NPC_TransmigrationFlg_CLS(int meindex, int toindex) +{ +#ifdef _TEACHER_SYSTEM + int iGetFame = 0; +#endif +#ifdef _PET_TRANS +#ifdef _PROSK99 + int endevflg[]={69,70,71,72,109,118,122,131,127,158,159,181,-1};//181:ǽƷ +#else + int endevflg[]={69,70,71,72,109,118,122,131,127,158,159,-1}; +#endif + int nowevflg[]={69,70,71,72,-1}; +#endif +#ifdef _TRANS_6 + int flg[6] = {48,49,50,51,52,179}; +#else + int flg[5] = {48,49,50,51,52}; +#endif + int num= CHAR_getInt(toindex ,CHAR_TRANSMIGRATION); + int i; +#ifdef _PET_TRANS + i=0; + while(endevflg[i] != -1 ) { + if( NPC_EventCheckFlg( toindex, endevflg[i] ) == FALSE ) { + endevflg[i] = 0; + } + i++; + } + i=0; + while( nowevflg[i] != -1 ) { + if( NPC_NowEventCheckFlg( toindex, nowevflg[i] ) == FALSE ) { + nowevflg[i] = 0; + } + i++; + } +#endif + + CHAR_setInt(toindex,CHAR_ENDEVENT,0); + CHAR_setInt(toindex,CHAR_ENDEVENT2,0); + CHAR_setInt(toindex,CHAR_ENDEVENT3,0); +#ifdef _NEWEVENT + CHAR_setInt(toindex,CHAR_ENDEVENT4,0); + CHAR_setInt(toindex,CHAR_ENDEVENT5,0); + CHAR_setInt(toindex,CHAR_ENDEVENT6,0); +#endif + CHAR_setInt(toindex,CHAR_NOWEVENT,0); + CHAR_setInt(toindex,CHAR_NOWEVENT2,0); + CHAR_setInt(toindex,CHAR_NOWEVENT3,0); +#ifdef _NEWEVENT + CHAR_setInt(toindex,CHAR_NOWEVENT4,0); + CHAR_setInt(toindex,CHAR_NOWEVENT5,0); + CHAR_setInt(toindex,CHAR_NOWEVENT6,0); +#endif +#ifdef _ADD_NEWEVENT // WON + CHAR_setInt(toindex,CHAR_ENDEVENT7,0); + CHAR_setInt(toindex,CHAR_NOWEVENT7,0); + CHAR_setInt(toindex,CHAR_ENDEVENT8,0); + CHAR_setInt(toindex,CHAR_NOWEVENT8,0); +#endif +#ifdef _PET_TRANS + i=0; + while( endevflg[i] != -1 ) { + if( endevflg[i] > 0 ) { + // shan Begin + //NPC_EventSetFlg( toindex, endevflg[i]); + s_eventsetend(toindex, endevflg[i]); + // End + } + i++; + } + i=0; + while( nowevflg[i] != -1 ) { + if( nowevflg[i] > 0 ) { + NPC_NowEventSetFlg( toindex, nowevflg[i]); + } + i++; + } + +#endif + + for(i = 0 ;i < num ;i++) { + NPC_EventSetFlg(toindex, flg[i]); + // CoolFish: Family Adv 2001/8/4 + AddFMAdv(toindex, flg[i]); +#ifdef _TEACHER_SYSTEM + // ۼ + if(flg[i] < 179){ + if (getPetUpGetExp()!=2){ + iGetFame += FMAdvTbl[flg[i]]; + }else{ + iGetFame +=0; + } + } +#endif + } +#ifdef _TEACHER_SYSTEM + iGetFame /= 20; // ʦѧ 5% (1/20) + // õûд0 + if(iGetFame > 0){ + // ûеʦ + if(strlen(CHAR_getChar(toindex,CHAR_TEACHER_ID)) > 0 && strlen(CHAR_getChar(toindex,CHAR_TEACHER_NAME)) > 0){ + int iPlayernum = CHAR_getPlayerMaxNum(); + char szMsg[128]; + + // 鵼ʦڲ + for(i=0;i= 0 ) + errtype = 3; + + if( errtype >= 0 ) { + if( NPC_Util_GetStrFromStrWithDelim( buf,errchar[ errtype], token,sizeof( token)) == NULL ) { + print("\n ERROR str errchar !!"); + return; + } + buttontype = WINDOW_BUTTONTYPE_OK; + windowtype = WINDOW_MESSAGETYPE_MESSAGE; + windowno = CHAR_WINDOWTYPE_PETTRANS_END; + break; + } + if( NPC_Util_GetStrFromStrWithDelim( buf,"selectmsg", token,sizeof( token)) == NULL ) { + print("\n ERROR selectmsg !!"); + return; + } + CHAR_setWorkInt( toindex, CHAR_WORKSHOPRELEVANT, 1); + windowno = CHAR_WINDOWTYPE_PETTRANS_SELECT; + windowtype = WINDOW_MESSAGETYPE_MESSAGE; + buttontype=WINDOW_BUTTONTYPE_YESNO; + break; + + case 2: //ѡ + if( NPC_Util_GetStrFromStrWithDelim( buf,"setpetmsg", token,sizeof( token)) == NULL ) { + print("\n ERROR setpetmsg !!"); + return; + } + buttontype = WINDOW_BUTTONTYPE_NONE; + windowtype = WINDOW_MESSAGETYPE_PETSELECT; + windowno = CHAR_WINDOWTYPE_PETTRANS_SELPET; + break; + + case 3: //ת ȷ/ȡ + if( NPC_Util_GetStrFromStrWithDelim( buf,"transmsg", buf1,sizeof( buf1)) == NULL ){ + print("\n ERROR transmsg !!"); + return; + } + strcpy( token,"\0"); + petindex = CHAR_getCharPet( toindex, select-1); + petname = CHAR_getUseName( petindex); + sprintf(token, "\n[%s]ûɣ \n\n %s",petname,buf1); + + windowtype = WINDOW_MESSAGETYPE_MESSAGE; + buttontype = WINDOW_BUTTONTYPE_YESNO; + windowno = CHAR_WINDOWTYPE_PETTRANS_MAIN1; + break; + + case 4: //ת CHAR_TRANSMIGRATION + //תж + petindex = CHAR_getCharPet( toindex, select-1); + if( !CHAR_CHECKINDEX( petindex) ) { + return; + } +#ifdef _FUSIONBEIT_TRANS + if( CHAR_getInt( petindex, CHAR_FUSIONBEIT ) > getFusionbeitTrans()) { + sprintf(token, "\n\nںϹijѾܹףร"); +#else + if( CHAR_getInt( petindex, CHAR_FUSIONBEIT ) == 1 ) { + sprintf(token, "\n\nںϹijﲻתร"); +#endif + CHAR_setWorkInt( toindex, CHAR_WORKSHOPRELEVANT, 0); + }else +#ifdef _PET_2TRANS + if( CHAR_getInt( toindex, CHAR_RIDEPET ) == select-1 /*&& CHAR_getInt( petindex, CHAR_TRANSMIGRATION ) > 0*/ ){//еijﲻת + sprintf(token, "\n\nеijﲻתร"); + }else +#endif + if( CHAR_getInt( petindex, CHAR_LV) < 80 ) { + sprintf(token, "\n\nתףijҪȼ80ร"); + CHAR_setWorkInt( toindex, CHAR_WORKSHOPRELEVANT, 0); + }else if( CHAR_getInt( petindex, CHAR_PETID) == 718 +#ifdef _PET_2TRANS + || CHAR_getInt( petindex, CHAR_PETID) == 401 +#endif +#ifdef _PET_3TRANS + || CHAR_getInt( petindex, CHAR_PETID) == getMMPETID2() +#endif + ){ + sprintf(token, "\n\nֻﲻתร"); + CHAR_setWorkInt( toindex, CHAR_WORKSHOPRELEVANT, 0); +#ifdef _PET_2TRANS +#ifdef _FUSIONBEIT_TRANS + }else if( CHAR_getInt( petindex, CHAR_FUSIONBEIT ) == 0 && + CHAR_getInt( petindex, CHAR_TRANSMIGRATION ) > 2 ) { +#else + }else if( CHAR_getInt( petindex, CHAR_TRANSMIGRATION ) > 1 ) { +#endif +#else + }else if( CHAR_getInt( petindex, CHAR_TRANSMIGRATION ) > 0 ) { +#endif + sprintf(token, "\n\nֻѾܹףร"); + CHAR_setWorkInt( toindex, CHAR_WORKSHOPRELEVANT, 0); + //Ƿظת + }else { // תϣ + petindex = CHAR_getCharPet( toindex, select-1); + if( NPC_PetTransManStatus( meindex, toindex, petindex) == FALSE ) + return; + if( NPC_Util_GetStrFromStrWithDelim( buf,"main1msg", token,sizeof( token)) == NULL ) + return; +#ifdef _FUSIONBEIT_TRANS + if( CHAR_getInt( petindex, CHAR_FUSIONBEIT ) >= 1 ) + CHAR_setInt( petindex, CHAR_FUSIONBEIT ,CHAR_getInt( petindex, CHAR_FUSIONBEIT )+1); +#endif + CHAR_charSaveFromConnect(toindex, FALSE); + CHAR_talkToCli(toindex, -1, "ϵͳΪԶ浵", CHAR_COLORRED); + } + + buttontype = WINDOW_BUTTONTYPE_OK; + windowtype = WINDOW_MESSAGETYPE_MESSAGE; + windowno = CHAR_WINDOWTYPE_PETTRANS_END; // + break; + + case 5: //תȡ + if( NPC_Util_GetStrFromStrWithDelim( buf,"cancelmsg", token,sizeof( token)) == NULL ) + return; + CHAR_setWorkInt( toindex, CHAR_WORKSHOPRELEVANT, 0); + buttontype = WINDOW_BUTTONTYPE_OK; + windowtype = WINDOW_MESSAGETYPE_MESSAGE; + windowno = CHAR_WINDOWTYPE_PETTRANS_END; // + break; + + default: + break; + } + lssproto_WN_send( fd, windowtype, buttontype, windowno, CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), token); + +} + +int NPC_PetTransManCheck( int meindex, int toindex, int select) +{ + //char errchar[][56]={"errormy","erroritem","errorpet","failmsg"}; + int i; + int petindex = 0; + char token[256]; + int PetEvent_no[3]={4,69,70}; + //int PetEvent_no[3]={4,4,4}; + + int petNum = 0; + //ת + if( CHAR_getInt( toindex, CHAR_LV ) < 80 ) { + return 0; + }else { + //FLAG ǷɳתҪ + for(i = 0; i < 3 ;i++) { + if( NPC_EventCheckFlg( toindex, PetEvent_no[i] ) == FALSE) { + return 0; + } + } + //(/) & Ʒ + for(i=0 ; i < CHAR_MAXPETHAVE ; i++) { + petindex = CHAR_getCharPet( toindex, i); + if( petindex == -1 ) + continue; + // ID ǷΪ׷ 1479 ID Ϊ718 + if(CHAR_getInt( petindex, CHAR_PETID) == 718 +#ifdef _PET_2TRANS + || CHAR_getInt( petindex, CHAR_PETID) == 401 +#endif +#ifdef _PET_3TRANS + || CHAR_getInt( petindex, CHAR_PETID) == getMMPETID2() +#endif + ){ + petNum ++; + if( CHAR_getInt( petindex, CHAR_LV) > 79 ) { + return 0; + }else if( CHAR_getInt( petindex, CHAR_LV) == 79 ) { + if( strcmp( CHAR_getChar( petindex, CHAR_OWNERCDKEY), CHAR_getChar( toindex, CHAR_CDKEY) ) || + strcmp( CHAR_getChar( petindex, CHAR_OWNERCHARANAME), CHAR_getChar( toindex, CHAR_NAME) )) { + sprintf( token,"ϵ׷ţİ"); + CHAR_talkToCli( toindex, -1, token, CHAR_COLORWHITE); + return 0; + } + } + } + } + + if( petNum > 1 ) { + sprintf( token,"׷أ"); + CHAR_talkToCli( toindex, -1, token, CHAR_COLORWHITE); + print("\n error PetTrans : (PETID = 718) > 1 !!"); + return 0; + }else if( petNum != 1 ) { + print("\n ת !!"); + return 0; + } + } + return -1; +} + +BOOL NPC_PetTransManStatus( int meindex, int toindex, int petNo) +{ + int petindex; + int LevelUpPoint = 0,petrank = 0; + int i,j,k,itemindex,itemID,count; + int vital1,str1,tgh1,dex1; + int vital2,str2,tgh2,dex2; +#ifdef _PET_3TRANS + int vital3,str3,tgh3,dex3,total3,tpetidx3; +#endif + char token[128]; + int total1,total2,total,petLV,ans; + int petID,enemynum,ret; + int work[4]={0,0,0,0}; + struct PetTransDelItem { + int minItemID; + int maxItemID; + }DelItem[3] = { {19629,19632} , {19672,19687} , {19625,19628} }; +#define RAND(x,y) ((x-1)+1+ (int)( (double)(y-(x-1))*rand()/(RAND_MAX+1.0)) ) +#ifdef _PET_2TRANS + int tran = CHAR_getInt ( petNo, CHAR_TRANSMIGRATION ); + int tpetidx1,tpetidx2; + if( tran == 0 ){ + tpetidx1 = 718; + tpetidx2 = 401; +#ifdef _PET_3TRANS + tpetidx3 = getMMPETID2(); + } + else + if( tran == 1 ){ + tpetidx1 = 401; + tpetidx2 = getMMPETID2(); + tpetidx3 = getMMPETID2(); + }else + if( tran == 2 ){ + tpetidx1 = getMMPETID2(); + tpetidx2 = getMMPETID2(); + tpetidx3 = getMMPETID2(); + }else{ + tpetidx1 = 401; + tpetidx2 = getMMPETID2(); + tpetidx3 = getMMPETID2(); + } +#else + } + else{ + tpetidx1 = 401; + tpetidx2 = 401; + } +#endif +#endif + + for(i=0 ; i < CHAR_MAXPETHAVE ; i++) { + petindex = CHAR_getCharPet( toindex, i); + if( petindex == -1 ) + continue; + if( +#ifdef _PET_2TRANS + CHAR_getInt( petindex, CHAR_PETID) == tpetidx1 + || CHAR_getInt( petindex, CHAR_PETID) == tpetidx2 +#ifdef _PET_3TRANS + || CHAR_getInt( petindex, CHAR_PETID) == tpetidx3 +#endif +#else + CHAR_getInt( petindex, CHAR_PETID) == 718 +#endif + ){ + if( CHAR_getInt( petindex, CHAR_LV) == 79 ){ + if( strcmp( CHAR_getChar( petindex, CHAR_OWNERCDKEY), CHAR_getChar( toindex, CHAR_CDKEY) ) || + strcmp( CHAR_getChar( petindex, CHAR_OWNERCHARANAME), CHAR_getChar( toindex, CHAR_NAME) )) { + continue; + } + break; + } + } + } + if(i == CHAR_MAXPETHAVE) { + print("\n ת !!"); + return FALSE; + } + + LevelUpPoint = CHAR_getInt( petindex, CHAR_ALLOCPOINT ); + petrank = CHAR_getInt( petindex, CHAR_PETRANK ); + + vital1 = (float)(( LevelUpPoint >> 24 ) & 0xFF); + str1 = (float)(( LevelUpPoint >> 16 ) & 0xFF); + tgh1 = (float)(( LevelUpPoint >> 8 ) & 0xFF); + dex1 = (float)(( LevelUpPoint >> 0 ) & 0xFF); + if(vital1 < 1)vital1 = 1; + if(str1 < 1)str1 = 1; + if(tgh1 < 1)tgh1 = 1; + if(dex1 < 1)dex1 = 1; + total1 = ( vital1 + str1 + tgh1 + dex1 ); +#ifdef _PET_TRANS_ABILITY + if( total1 > getPetTransAbility1() ) total1 = getPetTransAbility1(); +#else + if( total1 > 150 ) total1 = 150; +#endif + if( total1 < 0 ) total1 = 0; + LevelUpPoint = CHAR_getInt( petNo, CHAR_ALLOCPOINT ); + petrank = CHAR_getInt( petNo, CHAR_PETRANK ); + petLV = CHAR_getInt( petNo, CHAR_LV); + vital2 = (float)(( LevelUpPoint >> 24 ) & 0xFF); + str2 = (float)(( LevelUpPoint >> 16 ) & 0xFF); + tgh2 = (float)(( LevelUpPoint >> 8 ) & 0xFF); + dex2 = (float)(( LevelUpPoint >> 0 ) & 0xFF); + if(vital2 < 1)vital2 = 1; + if(str2 < 1)str2 = 1; + if(tgh2 < 1)tgh2 = 1; + if(dex2 < 1)dex2 = 1; + total2 = ( vital2 + str2 + tgh2 + dex2 ); + +#ifdef _PET_3TRANS +#ifdef _PET_TRANS_ABILITY + if( total2 > getPetTransAbility2() ) total2 = getPetTransAbility2(); +#else + if( total2 > 200 ) total2 = 200; +#endif + if( total2 < 0 ) total2 = 0; + LevelUpPoint = CHAR_getInt( petNo, CHAR_ALLOCPOINT ); + petrank = CHAR_getInt( petNo, CHAR_PETRANK ); + petLV = CHAR_getInt( petNo, CHAR_LV); + vital3 = (float)(( LevelUpPoint >> 24 ) & 0xFF); + str3 = (float)(( LevelUpPoint >> 16 ) & 0xFF); + tgh3 = (float)(( LevelUpPoint >> 8 ) & 0xFF); + dex3 = (float)(( LevelUpPoint >> 0 ) & 0xFF); + total3 = ( vital3 + str3 + tgh3 + dex3 ); +#ifdef _PET_TRANS_ABILITY + if( total3 > getPetTransAbility3() ) total3 = getPetTransAbility3(); +#else + if( total3 > 250 ) total3 = 250; +#endif +#endif + +#ifdef _PET_2TRANS + ans = NPC_PetTransManGetAns( total1, total2, petLV, petrank, CHAR_getInt( petNo, CHAR_TRANSMIGRATION ) ); +#else + ans = NPC_PetTransManGetAns( total1, total2, petLV, petrank); +#endif + total = total1 + (total2*4); + + work[0] = ( ans * ( vital1 + (vital2*4) ) ) / total; + work[1] = ( ans * ( str1 + (str2*4) ) ) / total; + work[2] = ( ans * ( tgh1 + (tgh2*4) ) ) / total; + work[3] = ( ans * ( dex1 + (dex2*4) ) ) / total; +//ȡarray========================= + enemynum = ENEMY_getEnemyNum(); + for(i=0;i= DelItem[j].minItemID ) && ( itemID <= DelItem[j].maxItemID ) ) { + LogItem( + CHAR_getChar( toindex, CHAR_NAME ), + CHAR_getChar( toindex, CHAR_CDKEY ), +#ifdef _add_item_log_name // WON ADD itemlogitem + itemindex, +#else + ITEM_getInt( itemindex, ITEM_ID), +#endif + "WarpManDelItem", + CHAR_getInt( toindex, CHAR_FLOOR), + CHAR_getInt( toindex, CHAR_X ), + CHAR_getInt( toindex, CHAR_Y ), + ITEM_getChar( itemindex, ITEM_UNIQUECODE), + ITEM_getChar( itemindex, ITEM_NAME), + ITEM_getInt( itemindex, ITEM_ID) + ); + CHAR_DelItem( toindex, i); + } + + }//for(j) + } + } + + NPC_NowEventSetFlg( toindex, 71 ); + + return TRUE; +} + + + +// shan add +void s_eventsetend( int charaindex, int shiftbit ) +{ +#ifdef _ADD_NEWEVENT // WON + int event_num = 8; +#else + int event_num = 6; +#endif + int point; + int array; + int shift; + + array = shiftbit / 32; + shift = shiftbit % 32; + + if( array>=event_num ){ + //print("󣡣ѳΧ(0~%d)",32*event_num-1); + return; + } + point = CHAR_getInt( charaindex, CHAR_ENDEVENT+array); + point = point | (1< +#include "char.h" +#include "object.h" +#include "char_base.h" +#include "npcutil.h" +#include "lssproto_serv.h" +#include "pet_skill.h" +#include "npc_eventaction.h" +#include "readmap.h" +#include "log.h" +#include "family.h" +#ifdef _VIGOR_SYS +#define MAXSHOPITEM 33 +static void NPC_ItemVigorShop_selectWindow( int meindex, int talker, int num,int select); +void NPC_ItemVigorShop_BuyMain(int meindex,int talker,int before ); +void NPC_GetItemVigorList(char *argstr,char * argtoken2); + #ifdef _NEW_MANOR_LAW + void NPC_ItemVigorStrStr(int itemID,double rate,char *name,char *token2,int iCostVigor,int iChangeItemCost); + #else + void NPC_ItemVigorStrStr(int itemID,double rate,char *name,char *token2); + #endif + +BOOL NPC_SetNewItemVigor(int meindex,int talker,char *data); +BOOL NPC_SellNewItemVigor(int meindex,int talker,char *data); + +void NPC_ItemVigorShop_Menu(int meindex,int talker); + +int NPC_GetLimtItemVigorList(int talker,char *argstr,char *token2,int sell); + +void NPC_ItemVigorShop_SellMain(int meindex,int talker,int select); +int NPC_GetSellItemVigorList(int itemindex,int flg,char *argstr,char *argtoken,int select,int sell); +#ifdef _NEW_MANOR_LAW +BOOL NPC_AddItemVigorBuy(int meindex, int talker,int itemID,int kosuu,double rate,int iCostVigor,int iChangeItemCost); +#else +BOOL NPC_AddItemVigorBuy(int meindex, int talker,int itemID,int kosuu,double rate); +#endif +int NPC_SellItemVigorstrsStr(int itemindex,int flg,double rate,char *argtoken,int select,int sell); +void NPC_LimitItemVigorShop(int meindex,int talker,int select); +void NPC_VigorExpressmanCheck(int meindex,int talker); + +enum{ + NPC_SHOP_WORK_NO = CHAR_NPCWORKINT1, + NPC_SHOP_WORK_EV = CHAR_NPCWORKINT2, + NPC_SHOP_WORK_EXPRESS = CHAR_NPCWORKINT3, +}; + + + +typedef struct { + char arg[32]; + int type; +}NPC_Shop; + + +static NPC_Shop TypeTable[] = { + { "FIST", 0 }, //ȭ + { "AXE", 1 }, // + { "CLUB", 2 }, // + { "SPEAR", 3}, //ì + { "BOW", 4}, // + { "SHIELD", 5}, // + { "HELM", 6 }, //ͷ + { "ARMOUR", 7 }, // + { "BRACELET", 8}, // + { "ANCLET", 9 }, // + { "NECKLACE", 10}, // + { "RING", 11}, //ָ + { "BELT", 12}, // + { "EARRING", 13}, // + { "NOSERING", 14}, //ǻ + { "AMULET", 15}, // + { "OTHER", 16}, + { "BOOMERANG", 17}, // + { "BOUNDTHROW", 18}, + { "BREAKTHROW", 19}, //Ͷ +#ifdef _ITEM_TYPETABLE + { "DISH", 20}, + { "METAL", 21}, + { "JEWEL", 22}, + { "WARES", 23}, + { "WBELT", 24}, + { "WSHIELD", 25}, + { "WSHOES", 26}, + { "WGLOVE", 27}, + { "ANGELTOKEN", 28}, + { "HEROTOKEN", 29}, +#endif + { "ACCESSORY", 30}, // + { "OFFENCE", 40}, // + { "DEFENCE", 50}, // + +}; + +BOOL NPC_ItemVigorShopInit( int meindex ) +{ + + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + + CHAR_setInt( meindex , CHAR_WHICHTYPE , CHAR_TYPEITEMSHOP ); + if(NPC_Util_GetArgStr( meindex, argstr, sizeof(argstr)) == NULL) { + print("GetArgStrErr"); + return FALSE; + } + if(strstr(argstr,"LIMITSHOP") != NULL) { + CHAR_setWorkInt( meindex, NPC_SHOP_WORK_NO, 1); + }else{ + CHAR_setWorkInt( meindex, NPC_SHOP_WORK_NO, 0); + } + if(strstr( argstr, "EVENT") != NULL) { + CHAR_setWorkInt( meindex, NPC_SHOP_WORK_EV, 1); + }else{ + CHAR_setWorkInt( meindex, NPC_SHOP_WORK_EV, 0); + } + if(strstr( argstr, "EXPRESS") != NULL) { + CHAR_setWorkInt( meindex, NPC_SHOP_WORK_EXPRESS, 1); + }else{ + CHAR_setWorkInt( meindex, NPC_SHOP_WORK_EXPRESS, 0); + } + + return TRUE; +} + +void NPC_ItemVigorShopTalked( int meindex , int talker , char *szMes ,int color ) +{ + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + char buff[1024]; + char buf2[256]; + char token[1024]; + int i = 1; + BOOL sellonlyflg = FALSE; + char sellmsg[1024]; + + if( CHAR_getInt( talker , CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER ) { + return; + } + + if(NPC_Util_isFaceToFace( meindex, talker, 2) == FALSE) {//̸ʱǷ + if( NPC_Util_CharDistance( talker, meindex ) > 1) return; //1 + } + + //ȡnpc趨ڵ,ΪNULL, + if(NPC_Util_GetArgStr( meindex, argstr, sizeof( argstr)) == NULL){ + print("itemshopGetArgStrErr"); + return; + } + + //ȡNPCֻѶϢ + if( NPC_Util_GetStrFromStrWithDelim( argstr, "sellonly_msg", token, sizeof( token)) != NULL){ + sellonlyflg = TRUE; //NPCҵĶ + strcpysafe(sellmsg, sizeof( sellmsg), token);//:sellmsgֵ->רĵꡣ + } + + //ȡָ. buffΪһִָ,:,,л,kau,buy,menu,лл,,ҴЩ־ʱ,Ϳ + if( NPC_Util_GetStrFromStrWithDelim( argstr, "buy_msg", buff, sizeof( buff)) != NULL ){ + while(getStringFromIndexWithDelim(buff,",",i,buf2,sizeof(buf2)) != FALSE ){ + i++; //ָ8,iͻӵ8 + if( strstr( szMes, buf2) != NULL) { + if( CHAR_getWorkInt( meindex, NPC_SHOP_WORK_EV) == 0) { + if( CHAR_getWorkInt( meindex, NPC_SHOP_WORK_NO) == 1) { + if( sellonlyflg ) { + NPC_ItemVigorShop_selectWindow( meindex, talker, 3, -1); + return; + } + }else{ + NPC_ItemVigorShop_selectWindow( meindex, talker, 1, -1); + return; + } + }else{ + if(CHAR_getWorkInt( meindex, NPC_SHOP_WORK_NO) == 1) { + if( sellonlyflg) { + NPC_ItemVigorShop_selectWindow( meindex, talker, 3, -1); + return; + } + }else{ + NPC_ItemVigorShop_selectWindow( meindex, talker, 1, -1); + return; + } + return; + } + } + } + } + i=1; + + //ȡָ. buffΪһִָ,:,,sell,uru ҴЩ־ʱ,Ϳ + if( NPC_Util_GetStrFromStrWithDelim( argstr, "sell_msg", buff, sizeof( buff)) != NULL ){ + while( getStringFromIndexWithDelim(buff,",", i,buf2,sizeof(buf2)) != FALSE ){ + i++; + if(strstr(szMes,buf2) != NULL) { + NPC_ItemVigorShop_selectWindow( meindex, talker, 2, -1); + return; + } + } + } + i = 1; + + //ѶϢ + if( NPC_Util_GetStrFromStrWithDelim( argstr, "other_msg", buff, sizeof( buff)) != NULL ){ + while(getStringFromIndexWithDelim( buff, ",", i, buf2, sizeof( buf2)) != FALSE ){ + i++; + if(strstr(szMes,buf2) != NULL) { + if(NPC_Util_GetStrFromStrWithDelim( argstr, "hint_msg", + token, sizeof( token)) != NULL) + { + CHAR_talkToCli( talker, meindex, token, CHAR_COLORWHITE); + return; + } + } + } + } + + if(CHAR_getWorkInt( meindex, NPC_SHOP_WORK_NO) == 1) { + if(CHAR_getWorkInt( meindex, NPC_SHOP_WORK_EV) == 1) { + if( sellonlyflg) { + CHAR_talkToCli( talker, meindex, sellmsg, CHAR_COLORWHITE); + return; + } + }else{ + if( sellonlyflg) { + NPC_ItemVigorShop_selectWindow( meindex, talker, 3, -1); + return; + } + } + }else{ + if(CHAR_getWorkInt( meindex, NPC_SHOP_WORK_EV) == 1) { + if( sellonlyflg) { + CHAR_talkToCli( talker, meindex, sellmsg, CHAR_COLORWHITE); + return; + } + }else{ + if(CHAR_getWorkInt( meindex, NPC_SHOP_WORK_EXPRESS) == 1) { + NPC_VigorExpressmanCheck( meindex, talker); + }else{ + NPC_ItemVigorShop_selectWindow( meindex, talker, 0, -1); + } + } + } + +} + +static void NPC_ItemVigorShop_selectWindow( int meindex, int talker, int num,int select) +{ + switch( num) { + case 0: + CHAR_send_P_StatusString( talker, CHAR_P_STRING_GOLD);//ͽǮ,100Ԫ ͳȥϸʽΪ P8Nz2|100| + + if(CHAR_getWorkInt( meindex, NPC_SHOP_WORK_EXPRESS) == 1 ) { + if(CHAR_getWorkInt( meindex, NPC_SHOP_WORK_NO) ==0 ) { + NPC_VigorExpressmanCheck( meindex, talker);//ë + } + }else if(CHAR_getWorkInt( meindex, NPC_SHOP_WORK_NO) == 1) { + + }else{ + NPC_ItemVigorShop_Menu( meindex, talker);//ѡ(,,뿪)СӴ + } + break; + + case 1://Ӵ + CHAR_sendStatusString( talker,"I");//еĵ߸Client + NPC_ItemVigorShop_BuyMain( meindex, talker, select); + break; + + case 2://Ӵ + CHAR_sendStatusString( talker,"I"); + NPC_ItemVigorShop_SellMain( meindex, talker, select); + break; + + case 3: + NPC_LimitItemVigorShop( meindex, talker, select); + break; + + } +} + +void NPC_ItemVigorShopWindowTalked( int meindex, int talkerindex, + int seqno, int select, char *data) +{ + if( NPC_Util_CharDistance( talkerindex, meindex ) > 3) { + CHAR_send_P_StatusString( talkerindex, CHAR_P_STRING_GOLD); + return; + } + + makeStringFromEscaped( data); + + switch( seqno){ + + case CHAR_WINDOWTYPE_WINDOWITEMSHOP_STARTMSG: + if(atoi( data) == 1 ) NPC_ItemVigorShop_selectWindow(meindex, talkerindex, 1, -1); + if(atoi( data) == 2) NPC_ItemVigorShop_selectWindow(meindex, talkerindex, 2, -1); + if(atoi( data) == 3) return;/*--ئ--*/ + break; + case CHAR_WINDOWTYPE_WINDOWITEMSHOP_BUY_MSG: + if(NPC_SetNewItemVigor(meindex , talkerindex, data) == TRUE) { + NPC_ItemVigorShop_selectWindow( meindex, talkerindex, 1, 0); + }else{ + NPC_ItemVigorShop_selectWindow( meindex, talkerindex ,0, -1); + } + + break; + case CHAR_WINDOWTYPE_WINDOWITEMSHOP_SELL_MSG: + if(NPC_SellNewItemVigor(meindex , talkerindex, data) == TRUE) { + NPC_ItemVigorShop_selectWindow( meindex, talkerindex, 2, 0); + + }else{ + NPC_ItemVigorShop_selectWindow( meindex, talkerindex, 0, -1); + } + + break; + + case CHAR_WINDOWTYPE_WINDOWITEMSHOP_LIMIT: + if(select == WINDOW_BUTTONTYPE_YES) { + NPC_ItemVigorShop_selectWindow( meindex, talkerindex ,2, -1); + + }else if(select == WINDOW_BUTTONTYPE_NO) { + return; + }else if(select == WINDOW_BUTTONTYPE_OK) { + NPC_ItemVigorShop_selectWindow( meindex, talkerindex, 2, -1); + } + break; + + case CHAR_WINDOWTYPE_WINDOWITEMSHOP_EXPRESS: + if(atoi(data) == 2) { + NPC_ItemVigorShop_selectWindow( meindex, talkerindex, 1, -1); + }else if(atoi( data) == 4) { + NPC_ItemVigorShop_selectWindow( meindex, talkerindex, 2, -1); + } + } +} + +void NPC_ItemVigorShop_BuyMain(int meindex,int talker,int before ) +{ + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + char token[NPC_UTIL_GETARGSTR_BUFSIZE]; + int fd = getfdFromCharaIndex( talker); + + char token2[NPC_UTIL_GETARGSTR_BUFSIZE]; + char buff2[256]; + char buff[256]; + if(NPC_Util_GetArgStr( meindex, argstr, sizeof(argstr)) == NULL) { + print("itemshop_GetArgStr_Err"); + return; + } +#ifdef _ADD_STATUS_2 + sprintf(token,"FAME|%d",CHAR_getInt(talker,CHAR_VIGOR)); + lssproto_S2_send(fd,token); +#endif + if(before != -1) { + sprintf(token,"0|0"); + + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_ITEMSHOPMAIN, + WINDOW_BUTTONTYPE_NONE, + CHAR_WINDOWTYPE_WINDOWITEMSHOP_BUY_MSG, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + token); + }else{ + + NPC_Util_GetStrFromStrWithDelim( argstr, "main_msg", buff, sizeof( buff)); + NPC_Util_GetStrFromStrWithDelim( argstr, "buy_main", buff2, sizeof( buff2)); + + sprintf(token,"0|1|%d|%s|%s|%s|", CHAR_WINDOWTYPE_WINDOWITEMSHOP_STARTMSG, + CHAR_getChar( meindex, CHAR_NAME), buff, buff2); + + NPC_Util_GetStrFromStrWithDelim( argstr, "what_msg", buff, sizeof( buff)); + NPC_Util_GetStrFromStrWithDelim( argstr, "level_msg", buff2, sizeof( buff)); + + snprintf( token2, sizeof( token2), "%s|%s", buff, buff2); + + strncat( token, token2, sizeof( token)); + + NPC_Util_GetStrFromStrWithDelim( argstr, "realy_msg", buff, sizeof( buff)); + NPC_Util_GetStrFromStrWithDelim( argstr, "itemfull_msg", buff2, sizeof( buff2)); + + sprintf( token2, "|%s|%s", buff, buff2); + strncat(token , token2,sizeof(token)); + strcpy(token2, "|"); + + NPC_GetItemVigorList( argstr, token2); + strncat( token, token2, sizeof( token)); + } + + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_ITEMSHOPMAIN, + WINDOW_BUTTONTYPE_NONE, + CHAR_WINDOWTYPE_WINDOWITEMSHOP_BUY_MSG, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + token); + +} +void NPC_GetItemVigorList(char *argstr,char *argtoken) +{ + int i = 1; + int tmp; + char *name ="\0"; + char buff2[256]; +#ifdef _NEW_MANOR_LAW + char buff3[NPC_UTIL_GETARGSTR_LINEMAX]; + char buff4[256]; + char buff5[NPC_UTIL_GETARGSTR_LINEMAX]; + char buff6[256]; + int iCostVigor = 0; + int iChangeItemCost = 0; +#endif + char buff[NPC_UTIL_GETARGSTR_LINEMAX]; + char token2[NPC_UTIL_GETARGSTR_BUFSIZE]; + double rate = 1.0; + int loopcnt = 0; + + if(NPC_Util_GetStrFromStrWithDelim( argstr, "buy_rate", buff2, sizeof( buff2)) + != NULL){ + rate = atof( buff2); + } +#ifdef _NEW_MANOR_LAW + memset(buff3,0,sizeof(buff3)); + memset(buff5,0,sizeof(buff5)); + if(NPC_Util_GetStrFromStrWithDelim(argstr,"CostVigor",buff3,sizeof(buff3)) == NULL) iCostVigor = -1; + if(NPC_Util_GetStrFromStrWithDelim(argstr,"ChangeItemCost",buff5,sizeof(buff5)) == NULL) iChangeItemCost = -1; +#endif + if( NPC_Util_GetStrFromStrWithDelim( argstr, "ItemList", buff, sizeof( buff)) != NULL ){ + while( getStringFromIndexWithDelim(buff,",",i,buff2,sizeof(buff2)) !=FALSE ) { +#ifdef _NEW_MANOR_LAW + if(iCostVigor > -1){ + if(getStringFromIndexWithDelim(buff3,",",i,buff4,sizeof(buff4)) != FALSE) iCostVigor = atoi(buff4); + } + if(iChangeItemCost > -1){ + if(getStringFromIndexWithDelim(buff5,",",i,buff6,sizeof(buff6)) != FALSE) iChangeItemCost = atoi(buff6); + } +#endif + i++; + if(strstr( buff2, "-") == NULL) { + name = ITEM_getNameFromNumber( atoi(buff2)); + if(name == "\0") continue; + loopcnt++; + if(loopcnt == MAXSHOPITEM) break; + #ifdef _NEW_MANOR_LAW + NPC_ItemVigorStrStr( atoi( buff2), rate, name, token2,iCostVigor,iChangeItemCost); + #else + NPC_ItemVigorStrStr( atoi( buff2), rate, name, token2); + #endif + strncat( argtoken, token2, sizeof(token2)); + }else{ + int start; + int end; + getStringFromIndexWithDelim( buff2, "-", 1, token2, sizeof(token2)); + start = atoi( token2); + getStringFromIndexWithDelim( buff2, "-", 2 ,token2, sizeof(token2)); + end = atoi( token2); + if(start > end){ + tmp = start; + start = end; + end = tmp; + } + end++; + for(; start < end ; start++ ) { + /*--ڒo???--*/ + + name = ITEM_getNameFromNumber( start ); + if(name == "\0") continue; + loopcnt++; + if(loopcnt == MAXSHOPITEM) break; + #ifdef _NEW_MANOR_LAW + NPC_ItemVigorStrStr( start, rate, name, token2,iCostVigor,iChangeItemCost); + #else + NPC_ItemVigorStrStr( start, rate, name, token2); + #endif + strncat( argtoken, token2, sizeof(token2)); + } + } + } + } +} + + #ifdef _NEW_MANOR_LAW + void NPC_ItemVigorStrStr(int itemID,double rate,char *name,char *token2,int iCostVigor,int iChangeItemCost) + #else + void NPC_ItemVigorStrStr(int itemID,double rate,char *name,char *token2) + #endif +{ + + int gold; + int level; + int graNo; + char info[1024]; + char escape[256]; + + #ifdef _NEW_MANOR_LAW + if(iChangeItemCost > -1) gold = iChangeItemCost; + else + #endif + gold = ITEM_getcostFromITEMtabl( itemID); + level = ITEM_getlevelFromITEMtabl( itemID); + graNo = ITEM_getgraNoFromITEMtabl( itemID); + strcpy(escape,ITEM_getItemInfoFromNumber( itemID)); + gold=(int)(gold * rate); + + makeEscapeString( escape, info, sizeof( info)); + makeEscapeString( name, escape, sizeof( escape)); +#ifdef _NEW_MANOR_LAW + sprintf(token2,"%s|0|%d|%d|%d|%s|%d|",escape,level,gold,graNo,info,iCostVigor < 0 ? -1:iCostVigor); +#else + sprintf( token2, "%s|0|%d|%d|%d|%s|", escape, level, gold, graNo, info); +#endif +} + +BOOL NPC_SetNewItemVigor(int meindex,int talker,char *data) +{ + + char buf[1024]; + char buff2[128]; +#ifdef _NEW_MANOR_LAW + char buff3[1024]; + char buff4[128]; + char buff5[1024]; + char buff6[128]; + int iCostVigor = 0; + int iChangeItemCost = 0; +#endif + int i = 1, j = 1; + int select; + int kosuu = 0; + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + double rate = 1.0; + int gold = 0; + int kosuucnt = 0; + int itemindex; + + /*--߯Ȼ׷ëѱݩ--*/ + getStringFromIndexWithDelim( data, "|", 1, buf, sizeof( buf)); + select = atoi(buf); + if(select == 0) return FALSE; + getStringFromIndexWithDelim( data, "|", 2, buf, sizeof( buf)); + kosuu = atoi(buf); + if( kosuu <= 0 ) return FALSE; + + /*--Ѽ ¾-*/ + for( i = CHAR_STARTITEMARRAY ; i < CHAR_MAXITEMHAVE ; i++ ) { + itemindex = CHAR_getItemIndex( talker , i ); + if( !ITEM_CHECKINDEX( itemindex) ) { + kosuucnt++; + } + } + + /*--߯Ȼ Ѽ ˼ ӡﴡ Իƾмƥ--*/ + /*--ӡ ë ľ--*/ + if( kosuucnt < kosuu) kosuu = kosuucnt; + + /*--δ޷¡--*/ + if(kosuucnt == 0 ) return FALSE; + + i = 1; + + /*--Ҽ̻ 跴̻ﻥئ巴 --*/ + if(NPC_Util_GetArgStr( meindex, argstr, sizeof(argstr)) == NULL) { + print("shop_GetArgStr_Err"); + return FALSE; + } + + /*---ë ئľ1.0)-*/ + if(NPC_Util_GetStrFromStrWithDelim( argstr, "buy_rate", buf, sizeof( buf)) != NULL) { + rate= atof( buf); + } + +#ifdef _NEW_MANOR_LAW + memset(buff3,0,sizeof(buff3)); + memset(buff5,0,sizeof(buff5)); + if(NPC_Util_GetStrFromStrWithDelim(argstr,"CostVigor",buff3,sizeof(buff3)) == NULL) iCostVigor = -1; + if(NPC_Util_GetStrFromStrWithDelim(argstr,"ChangeItemCost",buff5,sizeof(buff5)) == NULL) iChangeItemCost = -1; +#endif + + /*--ʧ ةܰë浤Ƿ-*/ + if( NPC_Util_GetStrFromStrWithDelim( argstr, "ItemList", buf, sizeof( buf)) != NULL ){ + while(getStringFromIndexWithDelim(buf , "," , j, buff2, sizeof(buff2)) != FALSE ){ +#ifdef _NEW_MANOR_LAW + if(iCostVigor > -1){ + if(getStringFromIndexWithDelim(buff3,",",j,buff4,sizeof(buff4)) != FALSE) iCostVigor = atoi(buff4); + } + if(iChangeItemCost > -1){ + if(getStringFromIndexWithDelim(buff5,",",j,buff6,sizeof(buff6)) != FALSE) iChangeItemCost = atoi(buff6); + } +#endif + j++; + /*-- "-"ֳľ¾--*/ + if(strstr( buff2, "-") == NULL) { + if( ITEM_getcostFromITEMtabl(atoi(buff2)) !=-1) { + if ( i == select) { + /*---ʧ ة---*/ + /*----*/ +#ifdef _NEW_MANOR_LAW + if(NPC_AddItemVigorBuy(meindex, talker,atoi(buff2),kosuu,rate,iCostVigor,iChangeItemCost) != TRUE) +#else + if(NPC_AddItemVigorBuy(meindex, talker,atoi(buff2),kosuu,rate) != TRUE) +#endif + { + return FALSE; + } + return TRUE; + } + i++; + } + }else{ + /*--ʧ ة 15-25 ƥ˪ľ--*/ + int start; + int end; + + /* "-"ƥľ炙Ѱ Ѱë --*/ + getStringFromIndexWithDelim( buff2, "-", 1, argstr, sizeof(argstr)); + start = atoi( argstr); + getStringFromIndexWithDelim( buff2, "-", 2 ,argstr, sizeof(argstr)); + end = atoi( argstr); + end++; + + /*-- įѱئȻգ ľ׸**/ + if(start > end){ + gold = start; + start = end; + end = gold; + } + + /*--"-"ƥľмʧ ةë ë --*/ + for(; start < end ; start++ ) { + if( ITEM_getcostFromITEMtabl( start) != -1) { + if ( i == select) { + /*---ʧ ة---*/ + /*----*/ +#ifdef _NEW_MANOR_LAW + if(NPC_AddItemVigorBuy(meindex, talker, start, kosuu, rate,iCostVigor,iChangeItemCost) != TRUE) +#else + if(NPC_AddItemVigorBuy(meindex, talker, start, kosuu, rate) != TRUE) +#endif + { + return FALSE; + } + return TRUE; + } + i++; + } + } + } + } + } + + return FALSE; + +} + +/*--------------------------------------------- + *ʧ ةܰë浤 + *--------------------------------------------*/ +#ifdef _NEW_MANOR_LAW +BOOL NPC_AddItemVigorBuy(int meindex, int talker,int itemID,int kosuu,double rate,int iCostVigor,int iChangeItemCost) +#else +BOOL NPC_AddItemVigorBuy(int meindex, int talker,int itemID,int kosuu,double rate) +#endif +{ + + int itemindex; + int i; + int gold; + int ret; + int maxgold; +#ifdef _NEW_MANOR_LAW + int iTotalCostVigor = -1; +#endif + #ifdef _NEW_MANOR_LAW + if(iChangeItemCost > -1) gold = iChangeItemCost; + else + #endif + gold = ITEM_getcostFromITEMtabl( itemID); + gold = (int)(gold * rate); + + maxgold = gold * kosuu; + if(CHAR_getInt( talker, CHAR_GOLD) < maxgold ) return FALSE; +#ifdef _NEW_MANOR_LAW + if(iCostVigor > 0){ + iTotalCostVigor= iCostVigor * kosuu; + if(CHAR_getInt(talker,CHAR_VIGOR) < iTotalCostVigor) return FALSE; + } +#endif + +// if( addNpcFamilyTax( meindex, talker, maxgold*0.4 ) ) +// print(" FamilyTaxDone! "); +// else +// print(" FamilyTaxError!"); + addNpcFamilyTax( meindex, talker, maxgold*0.4 ); + for(i = 0 ; i < kosuu ; i++){ + itemindex = ITEM_makeItemAndRegist( itemID); + + if(itemindex == -1) return FALSE; + ret = CHAR_addItemSpecificItemIndex( talker, itemindex); + if( ret < 0 || ret >= CHAR_MAXITEMHAVE ) { + print( "npc_itemshop.c: additem error itemindex[%d]\n", itemindex); + ITEM_endExistItemsOne( itemindex); + return FALSE; + } + CHAR_sendItemDataOne( talker, ret); + } + CHAR_DelGold( talker, maxgold); +#ifdef _NEW_MANOR_LAW + if(iTotalCostVigor > 0){ + CHAR_setInt(talker,CHAR_VIGOR,CHAR_getInt(talker,CHAR_VIGOR) - iTotalCostVigor); + if(CHAR_getInt(talker,CHAR_FMINDEX) != -1 && (strcmp(CHAR_getChar(talker,CHAR_FMNAME),""))){ + int fd = getfdFromCharaIndex(talker); + char buf[256]; + sprintf(buf,"%d",CHAR_getInt(talker,CHAR_VIGOR)); +// saacproto_ACFixFMData_send(acfd, +// CHAR_getChar(talker,CHAR_FMNAME), +// CHAR_getInt(talker,CHAR_FMINDEX), +// CHAR_getWorkInt(talker,CHAR_WORKFMINDEXI), +// FM_FIX_FAME,buf,"", +// CHAR_getWorkInt(talker,CHAR_WORKFMCHARINDEX), +// CONNECT_getFdid(fd)); +// LogFMVigorShop(CHAR_getChar(talker,CHAR_FMNAME), +// CHAR_getChar(talker,CHAR_CDKEY), +// CHAR_getChar(talker,CHAR_NAME), +// CHAR_getInt(talker,CHAR_VIGOR), +// iTotalCostVigor); + } + } +#endif + //CHAR_send_P_StatusString( talker, CHAR_P_STRING_GOLD); + return TRUE; + +} + +//ѡ (,,ȥ) СӴ +void NPC_ItemVigorShop_Menu(int meindex,int talker) +{ + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + char token[NPC_UTIL_GETARGSTR_LINEMAX]; + char buff[256]; + int fd = getfdFromCharaIndex( talker); + + //argstrȡ趨ѶϢ: ->buy_rate:1.0|sell_rate:0.2|buy_msg:,,л,kau,buy............. (мķָǶʱ) + if(NPC_Util_GetArgStr( meindex, argstr, sizeof(argstr)) == NULL) { + print("shop_GetArgStr_Err"); + return; + } + + //tokenΪӴtitle : ķķߵ|ӭ + NPC_Util_GetStrFromStrWithDelim( argstr, "main_msg", buff, sizeof( buff)); +#ifdef _NEW_MANOR_LAW + snprintf(token, sizeof(token),"%s|%s|%d",CHAR_getChar(meindex,CHAR_NAME),buff,CHAR_getInt(talker,CHAR_VIGOR)); +#else + snprintf(token, sizeof(token),"%s|%s",CHAR_getChar( meindex, CHAR_NAME), buff); +#endif + + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_ITEMSHOPMENU, + WINDOW_BUTTONTYPE_NONE, + CHAR_WINDOWTYPE_WINDOWITEMSHOP_STARTMSG, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + token); + +} + +void NPC_ItemVigorShop_SellMain(int meindex,int talker,int before) +{ + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + char token[NPC_UTIL_GETARGSTR_BUFSIZE]; + int fd = getfdFromCharaIndex( talker); + + //ȡnpc趨 + if(NPC_Util_GetArgStr( meindex, argstr, sizeof(argstr)) == NULL) { + print("shop_GetArgStr_Err"); + return; + } + +#ifdef _ADD_STATUS_2 + sprintf(token,"FAME|%d",CHAR_getInt(talker,CHAR_VIGOR)); + lssproto_S2_send(fd,token); +#endif + + if(before != -1) { + sprintf(token,"1|0"); + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_ITEMSHOPMAIN + +CHAR_getWorkInt(meindex,NPC_SHOP_WORK_NO), + WINDOW_BUTTONTYPE_NONE, + CHAR_WINDOWTYPE_WINDOWITEMSHOP_SELL_MSG, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + token); + + }else{ + + char token2[NPC_UTIL_GETARGSTR_BUFSIZE]; + char buff2[256]; + char buff[256]; + + NPC_Util_GetStrFromStrWithDelim( argstr, "main_msg", buff, sizeof( buff)); + NPC_Util_GetStrFromStrWithDelim( argstr, "sell_main", buff2, sizeof( buff)); + sprintf( token, "1|1|%d|%s|%s|%s|", CHAR_WINDOWTYPE_WINDOWITEMSHOP_STARTMSG, + CHAR_getChar( meindex, CHAR_NAME), buff, buff2); + + NPC_Util_GetStrFromStrWithDelim( argstr, "stone_msg", buff, sizeof( buff)); + + if(CHAR_getWorkInt(meindex,NPC_SHOP_WORK_EXPRESS) == 1 ) { + NPC_Util_GetStrFromStrWithDelim( argstr, "exrealy_msg", buff2, sizeof(buff2)); + }else{ + NPC_Util_GetStrFromStrWithDelim( argstr, "realy_msg", buff2, sizeof( buff2)); + } + sprintf( token2,"%s|%s|", buff, buff2); + NPC_GetLimtItemVigorList( talker,argstr, token2, -1);//ϸҪĵ + strncat( token, token2, sizeof( token)); + + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_ITEMSHOPMAIN+ + CHAR_getWorkInt(meindex,NPC_SHOP_WORK_NO), + WINDOW_BUTTONTYPE_NONE, + CHAR_WINDOWTYPE_WINDOWITEMSHOP_SELL_MSG, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + token); + + } +} +int NPC_GetLimtItemVigorList(int talker, char *argstr, char* token2,int sell) +{ + + char token[NPC_UTIL_GETARGSTR_LINEMAX]; + char buff[NPC_UTIL_GETARGSTR_LINEMAX]; + char token3[NPC_UTIL_GETARGSTR_LINEMAX]; + int k = 0 , i = 1 , j = 0; + int imax; + int itemtype = 0; + int itemindex; + int okflg = 0; + char buf[256]; + int flg=0; + int cost; + + if(sell == -1 ){ + i = CHAR_STARTITEMARRAY; + imax = CHAR_MAXITEMHAVE; + flg = -1; + }else{ + i= sell; + imax= sell + 1; + flg = 1; + } + + for( ; i < imax ; i++ ){ + okflg=0; + itemindex = CHAR_getItemIndex( talker , i ); + + if( ITEM_CHECKINDEX( itemindex) ){ + if( NPC_Util_GetStrFromStrWithDelim( argstr,"LimitItemType", buff, sizeof( buff)) != NULL ){ + k = 1; + while(getStringFromIndexWithDelim(buff , "," , k, token, sizeof(token)) != FALSE ){ +#ifdef _ITEM_TYPETABLE + int cmpmaxitem = sizeof(TypeTable)/sizeof(TypeTable[0]); +#endif + k++; +#ifdef _ITEM_TYPETABLE + for(j = 0 ; j < cmpmaxitem ; j++){ +#else + for(j = 0 ; j < ITEM_CATEGORYNUM+3 ; j++){ +#endif + if(strcmp( TypeTable[ j].arg , token) == 0 ) { + itemtype = TypeTable[ j].type; + if(ITEM_getInt(itemindex,ITEM_TYPE) == itemtype) { + cost = NPC_GetSellItemVigorList(itemindex,0,argstr,token3,i,sell); + if(cost != -1) return cost; + strncat( token2, token3, sizeof( token3)); + okflg = 1; + }else if(itemtype == 30){ + if( 8 <= ITEM_getInt(itemindex,ITEM_TYPE) + && (ITEM_getInt(itemindex,ITEM_TYPE) <= 15) ){ + cost = NPC_GetSellItemVigorList(itemindex,0,argstr,token3,i,sell); + if(cost != -1) return cost; + strncat(token2,token3,sizeof(token3)); + okflg = 1; + } + }else if(itemtype == 40){ + if(( 0 <= ITEM_getInt(itemindex,ITEM_TYPE) + && (ITEM_getInt(itemindex,ITEM_TYPE) <= 4)) + || (17 <= ITEM_getInt(itemindex,ITEM_TYPE) + && (ITEM_getInt(itemindex,ITEM_TYPE) <= 19))) { + cost = NPC_GetSellItemVigorList(itemindex,0,argstr,token3,i,sell); + if(cost != -1) return cost; + strncat(token2,token3,sizeof(token3)); + okflg = 1; + } + }else if(itemtype == 50){ + if( 5 <= ITEM_getInt(itemindex,ITEM_TYPE) + && (ITEM_getInt(itemindex,ITEM_TYPE) <= 7) ){ + cost = NPC_GetSellItemVigorList(itemindex,0,argstr,token3,i,sell); + if(cost != -1) return cost; + strncat(token2,token3,sizeof(token3)); + okflg = 1; + } + } + break; + } + } + + if(okflg == 1) break; + } + } + if( (NPC_Util_GetStrFromStrWithDelim( argstr, "LimitItemNo", buff,sizeof( buff))!= NULL) && okflg == 0 ){ + k = 1; + while(getStringFromIndexWithDelim(buff , "," , k, token, sizeof(token)) != FALSE ){ + k++; + if(strstr( token, "-")==NULL && strcmp(token,"") != 0) { + if(ITEM_getInt(itemindex,ITEM_ID) == atoi(token)) { + cost = NPC_GetSellItemVigorList(itemindex,0,argstr,token3,i,sell); + if(cost != -1) return cost; + strncat(token2,token3,sizeof(token3)); + okflg=1; + } + }else if (strstr( token, "-") != NULL){ + int start, end; + int work; + + if( getStringFromIndexWithDelim( token, "-", 1, buf, sizeof(buf)) == FALSE ) + return -1; + start = atoi( buf); + if( getStringFromIndexWithDelim( token, "-", 2 ,buf, sizeof(buf)) == FALSE ) + return -1; + end = atoi( buf); + + if(start > end){ + work = start; + start = end; + end = work; + } + + end++; + if( (start <= ITEM_getInt(itemindex,ITEM_ID)) && (ITEM_getInt(itemindex,ITEM_ID) < end) ){ + cost = NPC_GetSellItemVigorList(itemindex,0,argstr,token3,i,sell); + if(cost != -1) return cost; + strncat(token2,token3,sizeof(token3)); + okflg = 1; + } + } + } + } + + if(okflg == 0) { + cost = NPC_GetSellItemVigorList(itemindex, 1, argstr, token3, i, sell); + if(sell != -1) return -1; + strncat( token2, token3, sizeof( token3)); + } + + } + } + return -1; +} + + + +/*---------------------------------------------------------- + + ͷʧ˪P + + *----------------------------------------------------------*/ +int NPC_GetSellItemVigorList(int itemindex,int flg, char *argstr,char *argtoken,int select,int sell) +{ + char buff[256]; + double rate = 0.2; + char buff2[256]; + char buff3[64]; + int k = 1; + int cost = -1; + + if(NPC_Util_GetStrFromStrWithDelim( argstr,"special_item",buff, sizeof( buff)) != NULL){ + if(NPC_Util_GetStrFromStrWithDelim( argstr,"special_rate",buff2, sizeof( buff2)) != NULL ){ + rate = atof(buff2); + }else{ + rate = 1.2; + } + + while(getStringFromIndexWithDelim(buff , "," , k, buff2, sizeof(buff2)) !=FALSE ){ + k++; + if(strstr( buff2, "-") == NULL && strcmp(buff2,"") != 0) { + if(ITEM_getInt(itemindex,ITEM_ID) == atoi(buff2)){ + cost = NPC_SellItemVigorstrsStr( itemindex,0, rate, argtoken,select,sell); + return cost; + } + }else if (strstr( buff2, "-") != NULL){ + int start; + int end; + int work; + getStringFromIndexWithDelim( buff2, "-", 1, buff3, sizeof(buff3)); + start = atoi( buff3); + getStringFromIndexWithDelim( buff2, "-", 2 ,buff3, sizeof(buff3)); + end = atoi( buff3); + + if(start > end){ + work = start; + start = end; + end = work; + } + end++; + if( (start <= ITEM_getInt(itemindex,ITEM_ID)) && (ITEM_getInt(itemindex,ITEM_ID) < end) ){ + cost = NPC_SellItemVigorstrsStr( itemindex,0, rate, argtoken,select,sell); + return cost; + } + } + } + } + if( NPC_Util_GetStrFromStrWithDelim( argstr,"sell_rate",buff, sizeof( buff)) != NULL ){ + rate = atof(buff); + cost = NPC_SellItemVigorstrsStr( itemindex, flg ,rate, argtoken,select,sell); + return cost; + } + + return cost; +} + +int NPC_SellItemVigorstrsStr(int itemindex,int flg,double rate,char *argtoken,int select,int sell) +{ + int cost; + char escapedname[256]; + char name[256]; + char *eff; + + + cost = ITEM_getInt( itemindex, ITEM_COST); + cost = (int)(cost * rate); + + if(sell != -1) return cost; + + strcpy( escapedname, ITEM_getChar( itemindex, ITEM_SECRETNAME)); + makeEscapeString( escapedname, name, sizeof( name)); + eff=ITEM_getChar(itemindex, ITEM_EFFECTSTRING); + makeEscapeString( eff, escapedname, sizeof(escapedname)); + + + + sprintf( argtoken, +#ifdef _ITEM_PILENUMS + "%s|%d|%d|%d|%s|%d|%d|", +#else + "%s|%d|%d|%d|%s|%d|", +#endif + name, flg, cost, + ITEM_getInt( itemindex, ITEM_BASEIMAGENUMBER), + escapedname, select +#ifdef _ITEM_PILENUMS + ,ITEM_getInt( itemindex, ITEM_USEPILENUMS) +#endif + ); + + return -1; + +} + +BOOL NPC_SellNewItemVigor(int meindex,int talker,char *data) +{ + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + char token[256], token2[256]; + int cost, k, select, itemindex; + int MyGold, MaxGold, sellnum=1; + + MaxGold = CHAR_getMaxHaveGold( talker); + MyGold = CHAR_getInt( talker, CHAR_GOLD); + + if(NPC_Util_GetArgStr( meindex, argstr, sizeof(argstr)) == NULL) { + print("GetArgStrErr"); + return FALSE; + } + getStringFromIndexWithDelim(data , "|" ,1, token, sizeof( token)); + select = atoi(token); +#ifdef _ITEM_PILENUMS + getStringFromIndexWithDelim(data , "|" ,2, token, sizeof( token)); + sellnum = atoi(token); +#endif + + if( select < CHAR_STARTITEMARRAY || select >= CHAR_MAXITEMHAVE ) return FALSE; + k = select; + itemindex = CHAR_getItemIndex( talker , k); + cost = NPC_GetLimtItemVigorList( talker,argstr, token2,select); + if( cost == -1 || (cost*sellnum)+MyGold >= MaxGold || !ITEM_CHECKINDEX( itemindex) ){ + int fd = getfdFromCharaIndex( talker); + sprintf(token,"\n\nѽ!Բ" "\n\nԲ ! ɲѡһأ" ); + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + CHAR_WINDOWTYPE_WINDOWITEMSHOP_LIMIT, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + token); + return FALSE; + } +#ifdef _ITEM_PILENUMS + if( NPC_DelItem( talker, k, sellnum) == FALSE ) return FALSE; +#else + { + LogItem( + CHAR_getChar( talker, CHAR_NAME ), + CHAR_getChar( talker, CHAR_CDKEY ), +#ifdef _add_item_log_name // WON ADD itemlogitem + itemindex, +#else + ITEM_getInt( itemindex, ITEM_ID ), +#endif + "Sell()", + CHAR_getInt( talker,CHAR_FLOOR), + CHAR_getInt( talker,CHAR_X ), + CHAR_getInt( talker,CHAR_Y ), + ITEM_getChar( itemindex, ITEM_UNIQUECODE), + ITEM_getChar( itemindex, ITEM_NAME), + ITEM_getInt( itemindex, ITEM_ID) + + ); + } + CHAR_DelItem( talker, k); +#endif + CHAR_AddGold( talker, cost*sellnum); + CHAR_send_P_StatusString( talker, CHAR_P_STRING_GOLD); + return TRUE; +} + + + +void NPC_LimitItemVigorShop(int meindex,int talker,int select) +{ + + int fd = getfdFromCharaIndex( talker); + char token[NPC_UTIL_GETARGSTR_LINEMAX]; + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + char buf[1024]; + + if( NPC_Util_GetArgStr( meindex, argstr, sizeof(argstr)) == NULL) { + print("shop_GetArgStr_Err"); + return; + } + + if(NPC_Util_GetStrFromStrWithDelim( argstr, "sellonly_msg", buf, sizeof( buf))!=NULL){ + sprintf(token,"\n\n%s", buf); + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_YESNO, + CHAR_WINDOWTYPE_WINDOWITEMSHOP_LIMIT, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + token); + + }else{ + CHAR_talkToCli( talker, meindex, "רŵꡣ",CHAR_COLORWHITE); + } + return; +} + +void NPC_VigorExpressmanCheck(int meindex,int talker) +{ + int fd = getfdFromCharaIndex( talker); + char token[1024]; + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + char buf[1024]; + + if( NPC_Util_GetArgStr( meindex, argstr, sizeof(argstr)) == NULL) { + print("shop_GetArgStr_Err"); + return; + } + NPC_Util_GetStrFromStrWithDelim( argstr, "main_msg", buf, sizeof( buf)); + sprintf(token,"4\n%s\n\n%s" + "\n\n " + "\n\n " + ,CHAR_getChar(meindex,CHAR_NAME),buf); + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_SELECT, + WINDOW_BUTTONTYPE_CANCEL, + CHAR_WINDOWTYPE_WINDOWITEMSHOP_EXPRESS, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + token); + + return; + + +} +#endif diff --git a/npc/npc_vipshop.c b/npc/npc_vipshop.c new file mode 100644 index 0000000..a5f8697 --- /dev/null +++ b/npc/npc_vipshop.c @@ -0,0 +1,257 @@ +#include "version.h" +#include +#include "char.h" +#include "object.h" +#include "char_base.h" +#include "npcutil.h" +#include "npc_vipshop.h" +#include "lssproto_serv.h" +#include "saacproto_cli.h" +#include "readmap.h" +#include "battle.h" +#include "log.h" +#include "enemy.h" +#include "handletime.h" +#include "npc_eventaction.h" + +//صشøнڽ"ʦ" +#ifdef _VIP_SHOP +enum { + WINDOW_START=1, + WINDOW_SELECT, + WINDOW_PREV, + WINDOW_NEXT, + WINDOW_WARP, + WINDOW_END, +}; +enum { + NPC_WORK_CURRENTTIME = CHAR_NPCWORKINT1, +/* + NPC_WORK_ROUTETOY = CHAR_NPCWORKINT2, + NPC_WORK_ROUTEPOINT = CHAR_NPCWORKINT3, + NPC_WORK_ROUNDTRIP = CHAR_NPCWORKINT4, + NPC_WORK_MODE = CHAR_NPCWORKINT5, + NPC_WORK_CURRENTROUTE = CHAR_NPCWORKINT6, + NPC_WORK_ROUTEMAX = CHAR_NPCWORKINT7, + NPC_WORK_WAITTIME = CHAR_NPCWORKINT8, + NPC_WORK_CURRENTTIME = CHAR_NPCWORKINT9, + NPC_WORK_SEFLG = CHAR_NPCWORKINT10, +*/ +}; + +#define STANDBYTIME 50 + +static void NPC_VipShop_selectWindow( int meindex, int toindex, int num,int select); +BOOL VipShop_GetMenuStr( int meindex, int toindex, char *npcarg, char *token, int index ); +int VipShop_ShowMenulist( char *npcarg ); + +int page; + +BOOL NPC_VipshopInit( int meindex ) +{ + char npcarg[NPC_UTIL_GETARGSTR_BUFSIZE]; + + if(NPC_Util_GetArgStr( meindex, npcarg, sizeof(npcarg))==NULL){ + print("TRANSER_MAN: GetArgStrErr!!"); + return FALSE; + } + + CHAR_setInt( meindex, CHAR_WHICHTYPE, CHAR_TRANSERMANS); + + //CHAR_setInt( meindex, CHAR_LOOPINTERVAL, NEWNPCMAN_STANDBY); + CHAR_setWorkInt( meindex, NPC_WORK_CURRENTTIME, NowTime.tv_sec); + return TRUE; +} +//CHAR_setWorkInt(talkerindex,CHAR_WORKSHOPRELEVANT,1); +void NPC_VipshopTalked( int meindex, int talkerindex, char *msg, int color ) +{ + if( CHAR_getInt( talkerindex , CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER ) + return; + if(NPC_Util_isFaceToFace( meindex ,talkerindex , 2) == FALSE) { + if(NPC_Util_isFaceToChara( talkerindex, meindex, 1) == FALSE) + return; + } + + CHAR_setWorkInt( talkerindex, CHAR_WORKSHOPRELEVANT, 0); + NPC_VipShop_selectWindow( meindex, talkerindex, WINDOW_START, 0); +} + +void NPC_VipshopWindowTalked( int meindex, int talkerindex, int seqno, + int select, char *data) +{ + if( select == WINDOW_BUTTONTYPE_CANCEL || select == WINDOW_BUTTONTYPE_NO) + return; + switch( seqno) { + case NPC_TRANSERMAN_START: + break; + case NPC_TRANSERMAN_SELECT: + NPC_VipShop_selectWindow( meindex, talkerindex, WINDOW_SELECT, atoi( data)); + break; + case NPC_TRANSERMAN_WARP: + if( select == WINDOW_BUTTONTYPE_CANCEL ) + return; + if( select == WINDOW_BUTTONTYPE_NEXT ) + { + NPC_VipShop_selectWindow( meindex, talkerindex, WINDOW_NEXT, atoi( data)); + return; + } + if( select == WINDOW_BUTTONTYPE_PREV ) + { + NPC_VipShop_selectWindow( meindex, talkerindex, WINDOW_PREV, atoi( data)); + return; + } + NPC_VipShop_selectWindow( meindex, talkerindex, WINDOW_WARP, atoi( data)); + break; + case NPC_TRANSERMAN_END: + NPC_VipShop_selectWindow( meindex, talkerindex, WINDOW_END, atoi( data)); + break; + } + +} + +static void NPC_VipShop_selectWindow( int meindex, int toindex, int num,int select) +{ + char npcarg[NPC_UTIL_GETARGSTR_BUFSIZE]; + char token[1024]; + char buf1[256]; + char buf2[256]; + char buf3[256]; + int buttontype = 0, windowtype = 0, windowno = 0; + int fd = getfdFromCharaIndex( toindex); + static int select1; + windowtype = WINDOW_MESSAGETYPE_MESSAGE; + + if(NPC_Util_isFaceToFace( meindex ,toindex , 2) == FALSE) { + if(NPC_Util_isFaceToChara( toindex, meindex, 1) == FALSE) + return; + } + + memset( npcarg, 0, sizeof( npcarg)); + if(NPC_Util_GetArgStr( meindex, npcarg, sizeof(npcarg))==NULL){ + print("VipShop_MAN: GetArgStrErr!!"); + return; + } + memset( token, 0, sizeof( token)); + + switch( num) { + case WINDOW_START: + if( NPC_Util_GetStrFromStrWithDelim( npcarg, "START_MSG", token, sizeof( token) ) == NULL) { + print("VipShop Get START_MSG ERROR !"); + return; + } + CHAR_setWorkInt( toindex, CHAR_WORKSHOPRELEVANT, WINDOW_START); + buttontype = WINDOW_BUTTONTYPE_YESNO; + windowno = NPC_TRANSERMAN_SELECT; + break; + case WINDOW_SELECT: + CHAR_setWorkInt( toindex, CHAR_WORKLISTPAGE, 0); + page=VipShop_ShowMenulist(npcarg); + if( VipShop_GetMenuStr( meindex, toindex, npcarg, token,CHAR_getWorkInt( toindex, CHAR_WORKLISTPAGE)) == FALSE ) { + print( "VipShop GetMenu ERROR !!"); + return; + } + windowtype = WINDOW_MESSAGETYPE_SELECT; + if(page>1) + buttontype = WINDOW_BUTTONTYPE_CANCEL|WINDOW_BUTTONTYPE_NEXT; + else + buttontype = WINDOW_BUTTONTYPE_CANCEL; + windowno = NPC_TRANSERMAN_WARP; + break; + case WINDOW_NEXT: + if(CHAR_getWorkInt( toindex, CHAR_WORKLISTPAGE)<=page) + CHAR_setWorkInt( toindex, CHAR_WORKLISTPAGE, CHAR_getWorkInt( toindex, CHAR_WORKLISTPAGE)+1); + if( VipShop_GetMenuStr( meindex, toindex, npcarg, token,CHAR_getWorkInt( toindex, CHAR_WORKLISTPAGE)) == FALSE ) { + print( "VipShop GetMenu ERROR !!"); + return; + } + windowtype = WINDOW_MESSAGETYPE_SELECT; + if(CHAR_getWorkInt( toindex, CHAR_WORKLISTPAGE)+1==page) + buttontype = WINDOW_BUTTONTYPE_CANCEL|WINDOW_BUTTONTYPE_PREV; + else + buttontype = WINDOW_BUTTONTYPE_CANCEL|WINDOW_BUTTONTYPE_PREV|WINDOW_BUTTONTYPE_NEXT; + windowno = NPC_TRANSERMAN_WARP; + break; + case WINDOW_PREV: + if(CHAR_getWorkInt( toindex, CHAR_WORKLISTPAGE)>0) + CHAR_setWorkInt( toindex, CHAR_WORKLISTPAGE, CHAR_getWorkInt( toindex, CHAR_WORKLISTPAGE)-1); + if( VipShop_GetMenuStr( meindex, toindex, npcarg, token,CHAR_getWorkInt( toindex, CHAR_WORKLISTPAGE)) == FALSE ) { + print( "VipShop GetMenu ERROR !!"); + return; + } + windowtype = WINDOW_MESSAGETYPE_SELECT; + if(CHAR_getWorkInt( toindex, CHAR_WORKLISTPAGE)==0) + buttontype = WINDOW_BUTTONTYPE_CANCEL|WINDOW_BUTTONTYPE_NEXT; + else + buttontype = WINDOW_BUTTONTYPE_PREV|WINDOW_BUTTONTYPE_CANCEL|WINDOW_BUTTONTYPE_NEXT; + windowno = NPC_TRANSERMAN_WARP; + break; + case WINDOW_WARP: + select1=CHAR_getWorkInt( toindex, CHAR_WORKLISTPAGE)*7+select; + CHAR_setWorkInt( toindex, CHAR_WORKLISTSELECT , select1); + if( NPC_Util_GetStrFromStrWithDelim( npcarg, "END_MSG", buf1, sizeof( buf1) ) == NULL) { + print("VipShop Get START_MSG ERROR !"); + return; + } + if(getStringFromIndexWithDelim( npcarg,"}",select1, buf2, sizeof( buf2)) != FALSE) + NPC_Util_GetStrFromStrWithDelim( buf2, "MenuStr", buf3, sizeof( buf3)); + sprintf( token, "\n%s\n\n %s\n",buf1, buf3); + + windowtype = WINDOW_MESSAGETYPE_MESSAGE; + buttontype = WINDOW_BUTTONTYPE_YESNO; + windowno = NPC_TRANSERMAN_END; + break; + case WINDOW_END: + ActionNpc_CheckMenuFree( meindex, toindex, npcarg, CHAR_getWorkInt( toindex, CHAR_WORKLISTSELECT )); + return; + break; + } + + lssproto_WN_send( fd, windowtype, buttontype, windowno, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), token); +} + + +void NPC_VipshopLoop( int meindex) +{ + +} + +BOOL VipShop_GetMenuStr( int meindex, int toindex, char *npcarg, char *token,int index ) +{ + char buf1[1024], buf2[32], buf3[36]; + BOOL FINDS=FALSE; + int talkNo=index*7+1; + if( npcarg == NULL ) return FALSE; + + sprintf( token, "㵱ǰĻ:%d %d/%dҳ\n",sasql_ampoint(CHAR_getUseID(toindex),0,0), index+1, page); + while( getStringFromIndexWithDelim( npcarg,"}",talkNo, buf1, sizeof( buf1)) != FALSE ) { + talkNo++; + memset( buf2, 0, sizeof( buf2)); + if( NPC_Util_GetStrFromStrWithDelim( buf1, "MenuStr", buf2, sizeof( buf2)) == NULL ) + continue; + FINDS = TRUE; + + sprintf( buf3, " %s", buf2); + if(strlen(buf3)<10) + strcat( buf3, "\n"); + else + strcat( buf3, "\n"); + strcat( token, buf3); + if(talkNo>(index*7+7))return FINDS; + } + return FINDS; +} + +int VipShop_ShowMenulist( char *npcarg ) +{ + char buf1[1024]; + int talkNo=1; + while( getStringFromIndexWithDelim( npcarg,"}",talkNo, buf1, sizeof( buf1)) != FALSE ) { + talkNo++; + } + return (talkNo-3)/7+1; +} + +#endif + + diff --git a/npc/npc_warp.c b/npc/npc_warp.c new file mode 100644 index 0000000..c5edd06 --- /dev/null +++ b/npc/npc_warp.c @@ -0,0 +1,380 @@ +#include "version.h" +#include +#include "object.h" +#include "char_base.h" +#include "char.h" +#include "map_deal.h" +#include "readmap.h" +#include "npccreate.h" +#include "npcutil.h" +#include "handletime.h" +#include "npc_eventaction.h" + +//#define _RECORD_NPCMAN_ //¼ + +BOOL NPC_TimeWarpCheck(int meindex,char *buf,int mode); + +static void NPC_WarpsetNeverMake( int charaindex ) +{ + int cindex; + cindex = CHAR_getInt(charaindex,CHAR_NPCCREATEINDEX); + if( NPC_CHECKCREATEINDEX(cindex) ) + NPC_create[cindex].workdata[NPC_CREATEWORKNEVERMAKE] = 1; +} + +BOOL NPC_WarpInit( int charaindex ) +{ + char arg[NPC_UTIL_GETARGSTR_BUFSIZE]; + int ret; + int floor=-1,x=-1,y=-1; + char token[128]; + +#ifdef _RECORD_NPCMAN_ //¼ + char evtype[256]; + char evtime[256]; + char argfile[256]; + + if( NPC_Util_CheckAssignArgFile( charaindex, argfile) == NULL ) + sprintf( argfile, "NULL"); +#endif + + CHAR_setInt( charaindex, CHAR_WHICHTYPE , CHAR_TYPEWARP ); + if( NPC_Util_GetArgStr( charaindex, arg, sizeof( arg)) == NULL ) { + print("\n GetArgStr ERR!!"); + return FALSE; + } +#ifdef _NEW_WARPPOINT + if( strstr( arg, "FREEMORE") != NULL ) { +#ifdef _RECORD_NPCMAN_ //¼ + sprintf( evtype, "FREE"); + sprintf( evtime, "NULL"); +#endif + CHAR_setWorkInt( charaindex, CHAR_WORKEVENTTYPE, CHAR_EVENT_WARP); + }else { +#endif +#ifdef _MAP_WARPPOINT + return FALSE; +#endif +#ifdef _RECORD_NPCMAN_ //¼ + sprintf( evtype, "NONE"); +#endif + ret=getStringFromIndexWithDelim(arg,"|", 1,token,sizeof(token)); + if( ret ) floor = atoi( token ); + ret=getStringFromIndexWithDelim(arg,"|", 2,token,sizeof(token)); + if( ret ) x = atoi( token ); + ret=getStringFromIndexWithDelim(arg,"|", 3,token,sizeof(token)); + if( ret ) y = atoi( token ); + if( MAP_IsValidCoordinate( floor,x,y )== FALSE ){ + NPC_WarpsetNeverMake( charaindex ); + //print( "Warp NPC:Invalid arg:%s\n", arg ); + print( "Warp Npc Err:%d:%d:%d->(%s)\n", + CHAR_getInt( charaindex, CHAR_FLOOR ), + CHAR_getInt( charaindex, CHAR_X ), + CHAR_getInt( charaindex, CHAR_Y ), + arg ); + return FALSE; + } + ret=getStringFromIndexWithDelim(arg,"|",4,token,sizeof(token)); + if(ret==TRUE){ + int day; + day=NPC_TimeWarpCheck(charaindex,token,0); + if(day==0){ +#ifdef _RECORD_NPCMAN_ //¼ + sprintf( evtime, "N"); +#endif + CHAR_setWorkInt( charaindex, CHAR_WORKEVENTTYPE, CHAR_EVENT_WARP_NIGHT); + }else if(day==1){ +#ifdef _RECORD_NPCMAN_ //¼ + sprintf( evtime, "M"); +#endif + CHAR_setWorkInt( charaindex, CHAR_WORKEVENTTYPE, CHAR_EVENT_WARP_MORNING); + }else if(day==2){ +#ifdef _RECORD_NPCMAN_ //¼ + sprintf( evtime, "A"); +#endif + CHAR_setWorkInt( charaindex, CHAR_WORKEVENTTYPE, CHAR_EVENT_WARP_NOON); + }else{ +#ifdef _RECORD_NPCMAN_ //¼ + sprintf( evtime, "NULL"); +#endif + CHAR_setWorkInt( charaindex, CHAR_WORKEVENTTYPE, CHAR_EVENT_WARP); + } + }else{ +#ifdef _RECORD_NPCMAN_ //¼ + sprintf( evtime, "NULL"); +#endif + CHAR_setWorkInt( charaindex, CHAR_WORKEVENTTYPE, CHAR_EVENT_WARP); + } +#ifdef _NEW_WARPPOINT + } +#endif + CHAR_setFlg( charaindex,CHAR_ISVISIBLE, 0 ); + CHAR_setFlg( charaindex,CHAR_ISOVERED,1 ); + CHAR_setFlg( charaindex,CHAR_ISATTACKED,0 ); + CHAR_setFlg( charaindex,CHAR_ISATTACK,0 ); + +#ifdef _RECORD_NPCMAN_ //¼ + { + FILE *fp=NULL; + char filename[256]; + sprintf( filename,"./data/npc/%s", "mapwarp.txt"); + if( (fp = fopen( filename, "a+")) != NULL ) { + fprintf( fp, "%s:%s:%d,%d,%d:%d,%d,%d:%s\n", + evtype, evtime, + CHAR_getInt( charaindex, CHAR_FLOOR), + CHAR_getInt( charaindex, CHAR_X), + CHAR_getInt( charaindex, CHAR_Y), + floor, x, y, argfile ); + fclose( fp); + }else { + } + } +#endif + return TRUE; +} + +void NPC_WarpWarpCharacter( int warpnpcindex, int charaindex ) +{ + char arg[NPC_UTIL_GETARGSTR_BUFSIZE]; + int i=0; +#ifdef _NEW_WARPPOINT + char buf1[256], buf2[256], buf3[256], freemsg[256]; + BOOL nBefind = FALSE; + struct wapepoints { + int m_floor; + int m_x; + int m_y; + }Wpoint[10]={ + {-1,0,0}, {-1,0,0}, {-1,0,0}, {-1,0,0}, {-1,0,0}, + {-1,0,0}, {-1,0,0}, {-1,0,0}, {-1,0,0}, {-1,0,0} + }; + int iRand=0; +#endif + if( CHAR_getInt( charaindex,CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER ){ + return; + } + + if( NPC_Util_GetArgStr( warpnpcindex, arg, sizeof( arg)) == NULL ){ + return; + } + + { + char token[16]; + int floor=0,x=0,y=0; + int ret; + +#ifdef _NEW_WARPPOINT + i=1; + if( strstr( arg, "FREEMORE") != NULL ) { + int k=1, pw=-1; + while( getStringFromIndexWithDelim( arg, "OVER", i, buf1, sizeof( buf1)) != FALSE ) { + i++; + if( NPC_Util_GetStrFromStrWithDelim( buf1, "FREE", buf2, sizeof( buf2)) == NULL ) + continue; + if( NPC_ActionPassCheck( warpnpcindex, charaindex, buf2) == FALSE ) { + continue; + }else { + iRand=0; + if( NPC_Util_GetStrFromStrWithDelim( buf1, "TO", buf2, sizeof( buf2)) != FALSE ) { + k=1; + while( getStringFromIndexWithDelim( buf2, "&", k, freemsg, sizeof( freemsg)) != FALSE ){ + k++; + if( getStringFromIndexWithDelim( freemsg, ",", 1, buf3, sizeof( buf3)) == FALSE ) + break; + Wpoint[iRand].m_floor = atoi( buf3); + if( getStringFromIndexWithDelim( freemsg, ",", 2, buf3, sizeof( buf3)) == FALSE ) + break; + Wpoint[iRand].m_x = atoi( buf3); + if( getStringFromIndexWithDelim( freemsg, ",", 3, buf3, sizeof( buf3)) == FALSE ) + break; + Wpoint[iRand].m_y = atoi( buf3); + iRand++; + nBefind = TRUE; + if( iRand >= arraysizeof( Wpoint)) + break; + } + break; + } + } + if( nBefind == TRUE ) + break; + } + + if( nBefind == FALSE || iRand <= 0){ //ûҵ + floor = CHAR_getInt( warpnpcindex, CHAR_FLOOR); + x = CHAR_getInt( warpnpcindex, CHAR_X); + y = CHAR_getInt( warpnpcindex, CHAR_Y); + }else { + pw = RAND( 0, (iRand-1)); + floor = Wpoint[pw].m_floor; + x = Wpoint[pw].m_x; + y = Wpoint[pw].m_y; + if( NPC_Util_GetStrFromStrWithDelim( arg, "CHECKPARTY", buf1, sizeof( buf1)) != NULL ) { + if( strstr( buf1, "TRUE") != NULL ){ + if( CHAR_getWorkInt( charaindex, CHAR_WORKPARTYMODE ) == CHAR_PARTY_LEADER ) { + CHAR_DischargeParty( charaindex, 0); // + } + } + } + if( MAP_IsValidCoordinate( floor,x,y )== FALSE ){ + print( "*Warp NPC:Invalid %d %d %d" , floor,x,y ); + return; + } + k=0; + } + }else { +#endif + ret=getStringFromIndexWithDelim(arg,"|", 1,token,sizeof(token)); + if( ret == FALSE )return; + floor = atoi( token ); + + ret=getStringFromIndexWithDelim(arg,"|", 2,token,sizeof(token)); + if( ret == FALSE )return; + x = atoi( token ); + + ret=getStringFromIndexWithDelim(arg,"|", 3,token,sizeof(token)); + if( ret == FALSE )return; + y = atoi( token ); +#ifdef _NEW_WARPPOINT + } +#endif + { + int ff=floor; + + int of=CHAR_getInt(charaindex, CHAR_FLOOR); + int fd=CHAR_getWorkInt( charaindex, CHAR_WORKFD); + int eqen=getEqNoenemy(fd); + if (eqen<200) { + if (eqen>=120) { + if ((ff==100)||(ff==200)||(ff==300)||(ff==400)||(ff==500)) { + if ((of!=100)&&(of!=200)&&(of!=300)&&(of!=400)&&(of!=500)) { + CHAR_talkToCli(charaindex, -1, + "̫ηһĹâ١", CHAR_COLORWHITE); + } + } else { + if ((of==100)||(of==200)||(of==300)||(of==400)||(of==500)) { + CHAR_talkToCli(charaindex, -1, "Ĺâʧˡ", CHAR_COLORWHITE); + } + } + } else if (eqen>=80) { + if ((ff==100)||(ff==200)||(ff==300)||(ff==400)) { + if ((of!=100)&&(of!=200)&&(of!=300)&&(of!=400)) { + CHAR_talkToCli(charaindex, -1, + "̫ηһĹâ١", CHAR_COLORWHITE); + } + } else { + if ((of==100)||(of==200)||(of==300)||(of==400)) { + CHAR_talkToCli(charaindex, -1, "Ĺâʧˡ", CHAR_COLORWHITE); + } + } + } else if (eqen>=40) { + if ((ff==100)||(ff==200)) { + if ((of!=100)&&(of!=200)) { + CHAR_talkToCli(charaindex, -1, + "̫ηһĹâ١", CHAR_COLORWHITE); + } + } else { + if ((of==100)||(of==200)) { + CHAR_talkToCli(charaindex, -1, "Ĺâʧˡ", CHAR_COLORWHITE); + } + } + } + } + } + +#ifdef _DROPSTAKENEW + { + i = 0; + for (i = 0; i < MAXSTAKENUM; i++){ + if (CHAR_getWorkInt(charaindex, CHAR_WORKSTAKETYPE1 + i) > 0){ + char tmpbuf[256]; + snprintf(tmpbuf, sizeof(tmpbuf), "뿪˷䣬Խ޷ȡزȯ"); + CHAR_setWorkInt(charaindex, CHAR_WORKSTAKETYPE1 + i, 0); + CHAR_talkToCli(charaindex, -1, tmpbuf, CHAR_COLORYELLOW); + } + } + CHAR_setWorkInt(charaindex, CHAR_WORKSTAKEFLAG, 0); +#ifdef _FIX_GAMBLENUM + if(CHAR_getInt(charaindex, CHAR_GAMBLENUM) < 0) + CHAR_setInt(charaindex, CHAR_GAMBLENUM, 0); +#endif + } +#endif + if( floor == -1) { + return; + }else { + if( MAP_IsValidCoordinate( floor,x,y )== FALSE ){ + print( "Warp NPC:Invalid %d %d %d" , floor,x,y ); + return; + } + + CHAR_warpToSpecificPoint(charaindex, floor, x, y); + } + } +} + +void NPC_WarpWatch( int meobjindex, int objindex, CHAR_ACTION act, + int x,int y,int dir, int* opt,int optlen ) +{ + int meindex,moveindex; + if( OBJECT_getType( objindex ) != OBJTYPE_CHARA )return; + + meindex = OBJECT_getIndex(meobjindex); + moveindex = OBJECT_getIndex(objindex); + + if( CHAR_getInt( moveindex,CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER ){ + return; + } + if( act != CHAR_ACTWALK )return; + + if( opt[0] == x && opt[1] == y )return; + if( CHAR_getInt(meindex,CHAR_X) == x && CHAR_getInt(meindex,CHAR_Y) == y ) { + NPC_WarpWarpCharacter( meindex, moveindex ); + } +} + +void NPC_WarpPostOver( int meindex, int charaindex ) +{ + NPC_WarpWarpCharacter( meindex, charaindex ); +} + +int NPC_WarpSearchByPosition( int fl , int x, int y) +{ + OBJECT object; + for( object=MAP_getTopObj(fl,x,y) ; object ; + object=NEXT_OBJECT(object)){ + int objindex = GET_OBJINDEX(object); + if( OBJECT_getType( objindex ) == OBJTYPE_CHARA + && CHAR_getInt( OBJECT_getIndex(objindex), CHAR_WHICHTYPE) + == CHAR_TYPEWARP ){ + return OBJECT_getIndex(objindex); + } + } + return -1; +} + + +int NPC_TimeWarpCheck(int meindex,char *buf,int mode) +{ + LSTIME nowlstime; + char *time[4]={"N","M","A"}; + int now; + int i=0; + RealTimeToLSTime( NowTime.tv_sec, &nowlstime); + now = getLSTime( &nowlstime); + if(mode==0){ + for( i=0 ; i < 3 ; i++){ + if(strstr( buf,time[i]) != NULL){ + return i; + } + } + return -1;; + } + if(mode==1){ + if(now==CHAR_getWorkInt( meindex, CHAR_WORKEVENTTYPE)){ + return now; + } + return -1; + } + return -1; +} diff --git a/npc/npc_warpman.c b/npc/npc_warpman.c new file mode 100644 index 0000000..c4f6005 --- /dev/null +++ b/npc/npc_warpman.c @@ -0,0 +1,1133 @@ +#include "version.h" +#include +#include "char.h" +#include "object.h" +#include "char_base.h" +#include "npcutil.h" +#include "lssproto_serv.h" +#include "saacproto_cli.h" +#include "npc_warpman.h" +#include "map_deal.h" +#include "readmap.h" +#include "battle.h" +#include "npc_exchangeman.h" +#include "log.h" +#include "enemy.h" +#include "handletime.h" +#include "npc_eventaction.h" + +static void NPC_WarpMan_selectWindow( int meindex, int toindex, int num,int select); +//ANDY_END +BOOL NPC_GetDuelPointCheck(int meindex,int talker); +BOOL NPC_PARTY_CHAECK( int meindex, int talkerindex); +void NPC_ERR_DiSP(int meindex,int talker,int errNO); + +BOOL NPC_BigSmallLastCheck(int point1,int mypoint,int flg); + +//BOOL NPC_ItemCheck(int meindex,int talker,int itemNo,int flg); +int NPC_FloorUse(int talker,int floor); +BOOL NPC_WarpMsg(int meindex,int talker,char *buf); +BOOL NPC_NpcWarpMsg(int meindex,int talker,char *arg); +int NPC_FloorUseOtherFloor(int charaindex, char *buf); + + +#ifdef _NPC_ADDLEVELUP +void NPC_LevelAndTransUp( int meindex, int charindex, int level, int skillpoint, int exp, int ridepet); +#endif + +#define WARPMAN_STANDBY 3000 +#define WARPMAN_WAIT 150 +//ANDY_ADD +int CheckWarpMsg( int meindex, int talkerindex,char *npcarg ,char *TalkStr); + +#ifdef _TREASURE_BOX +BOOL NPC_TreasureEventRunMsg( int meindex); +#endif + +BOOL NPC_TreasureRandItemGet(int meidex,int talker,int rand_j,char *buf); + +enum { + NPC_WORK_CURRENTTIME = CHAR_NPCWORKINT1, + NPC_TIME_BORN = CHAR_NPCWORKINT2, + NPC_TIME_DEAD = CHAR_NPCWORKINT3, + NPC_TIME_MODE = CHAR_NPCWORKINT4, + + NPC_TIME_EVENTMODE = CHAR_NPCWORKINT6,// 1 + NPC_TIME_EVENTTIME = CHAR_NPCWORKINT7, + NPC_TIME_EVENONBBI = CHAR_NPCWORKINT8, + NPC_TIME_EVENOFFDBBI = CHAR_NPCWORKINT9, + NPC_TIME_EVENTNUM = CHAR_NPCWORKINT10, +}; + +enum{ + NPC_EVENTMODE_NONE, + NPC_EVENTMODE_OPEN, + NPC_EVENTMODE_EVENT, +}; + +#ifdef _NEW_WARPMAN +static void NPC_NewWarpMan_selectWindow( int meindex, int toindex, int num,int select,char *TalkStr); + +enum { + WARP_MAN=0, + NEW_WARPMAN, + NEW_WARPMAN_END + }; +#endif +#define TIMECHECKLOOP 20 +// Robin 0518 +//BOOL checkend = FALSE; + + +BOOL NPC_WarpManInit( int meindex ) +{ + char npcarg[NPC_UTIL_GETARGSTR_BUFSIZE - 1024 * 20]; + char buff2[256]; + char buf[1024]; + int fl,x,y; + + if(NPC_Util_GetArgStr( meindex, npcarg, sizeof(npcarg))==NULL){ + print("WarpMan:GetArgStrErr"); + return FALSE; + } + CHAR_setInt( meindex , CHAR_WHICHTYPE , CHAR_TYPEWARPMAN ); +#ifdef _NEW_WARPMAN + if( strstr( npcarg,"NEWWARPMAN") ) { + //timeman + CHAR_setWorkInt( meindex, NPC_TIME_MODE, 1); + if(NPC_Util_GetStrFromStrWithDelim( npcarg, "NEWTIME", buff2, sizeof( buff2)) != NULL ){ + CHAR_setInt( meindex, CHAR_LOOPINTERVAL, 60*1000); + } +#ifdef _TREASURE_BOX + CHAR_setWorkInt( meindex, NPC_TIME_EVENTMODE, NPC_EVENTMODE_NONE); + if(NPC_Util_GetStrFromStrWithDelim( npcarg, "TREASURE_BOX", buff2, sizeof( buff2)) != NULL ){ + if( strstr( buff2, "ON") != NULL ){ + CHAR_setWorkInt( meindex, NPC_TIME_EVENTMODE, NPC_EVENTMODE_EVENT); + CHAR_setWorkInt( meindex, NPC_TIME_EVENTTIME, NowTime.tv_sec); + if(NPC_Util_GetStrFromStrWithDelim( npcarg, "TREASURE_ONBBI", buff2, sizeof( buff2)) != NULL ) + CHAR_setWorkInt( meindex, NPC_TIME_EVENONBBI, atoi( buff2)); + if(NPC_Util_GetStrFromStrWithDelim( npcarg, "TREASURE_OFFDBBI", buff2, sizeof( buff2)) != NULL ) + CHAR_setWorkInt( meindex, NPC_TIME_EVENOFFDBBI, atoi( buff2)); + CHAR_setWorkInt( meindex, NPC_TIME_EVENTNUM, 0 ); + } + } + +#endif + return TRUE; + }else{ +#endif + if(NPC_Util_GetStrFromStrWithDelim( npcarg, "WARP", buf, sizeof( buf))==NULL){ + char filename[256]; + if( NPC_Util_CheckAssignArgFile( meindex, filename) != NULL ) + print("\n Warpman Err -> file:%s", filename); + return FALSE; + } + getStringFromIndexWithDelim(buf,",",1,buff2,sizeof(buff2)); + fl=atoi(buff2); + getStringFromIndexWithDelim(buf,",",2,buff2,sizeof(buff2)); + x=atoi(buff2); + getStringFromIndexWithDelim(buf,",",3,buff2,sizeof(buff2)); + y=atoi(buff2); + if( MAP_IsValidCoordinate( fl,x,y )== FALSE ){ + char filename[256]; + NPC_Util_CheckAssignArgFile( meindex, filename); + print( "\nWarp NPC: filename:%s\n 3.Invalid warpman ERR %d %d %d" , filename, fl , x , y ); + return FALSE; + } +#ifdef _NEW_WARPMAN + } +#endif + return TRUE; +} + +void NPC_WarpManTalked( int meindex , int talkerindex , char *szMes ,int color ) +{ + char npcarg[NPC_UTIL_GETARGSTR_BUFSIZE - 1024 * 20]; + char token[256]; + int RunType=-1; + + CHAR_setWorkInt( talkerindex, CHAR_WORKWARPCHECK, FALSE ); + if( CHAR_getInt( talkerindex , CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER ) { + return; + } + if(NPC_Util_isFaceToFace( meindex ,talkerindex ,2)==FALSE){ + if(NPC_Util_isFaceToChara(talkerindex,meindex,1 )==FALSE) return; + } + if(NPC_Util_GetArgStr( meindex, npcarg, sizeof(npcarg))==NULL){ + print("GetArgStrErr"); + return ; + } + +#ifdef _NEW_WARPMAN + if( strstr( npcarg,"NEWWARPMAN") ) { +#ifdef _TREASURE_BOX + if( CHAR_getWorkInt( meindex, NPC_TIME_EVENTMODE) == NPC_EVENTMODE_OPEN ) + return; +#endif + NPC_NewWarpMan_selectWindow( meindex ,talkerindex, 0, -1, szMes); + return; + }else { + if(NPC_PARTY_CHAECK( meindex, talkerindex) == FALSE) {// + NPC_ERR_DiSP( meindex, talkerindex, 1); + return; + } + + + RunType = CheckWarpMsg( meindex, talkerindex, npcarg , szMes); + if( RunType !=0 ) { + if( RunType == 1 ) { + if( NPC_Util_GetStrFromStrWithDelim( npcarg, "nomal_msg", token, sizeof(token)) != NULL) { + CHAR_talkToCli( talkerindex, meindex,token,CHAR_COLORWHITE); + } + } + return; + } + } +#else + + + if(NPC_PARTY_CHAECK( meindex, talkerindex) == FALSE) {// + NPC_ERR_DiSP( meindex, talkerindex, 1); + return; + } + RunType = CheckWarpMsg( meindex, talkerindex, npcarg , szMes); + if( RunType !=0 ) { + if( RunType == 1 ) { + if( NPC_Util_GetStrFromStrWithDelim( npcarg, "nomal_msg", token, sizeof(token)) != NULL) { + CHAR_talkToCli( talkerindex, meindex,token,CHAR_COLORWHITE); + } + } + return; + } +#endif + + CHAR_setWorkInt( talkerindex, CHAR_WORKSHOPRELEVANT, 0); + CHAR_setWorkInt( talkerindex , CHAR_WORKSHOPRELEVANTTRD , 0 ); + if(strstr(npcarg,"DR")!=NULL) { + CHAR_setWorkInt( talkerindex , CHAR_WORKSHOPRELEVANTSEC , -1 ); + if(NPC_GetDuelPointCheck(meindex,talkerindex)==FALSE) return; + }else{ + NPC_WarpMan_selectWindow( meindex, talkerindex,0,-1); + } +} + +static void NPC_WarpMan_selectWindow( int meindex, int toindex, int num,int select) +{ + + char npcarg[NPC_UTIL_GETARGSTR_BUFSIZE - 1024 * 20]; + char token[1024]; + char buf[256]; + char buf2[1024]; + char buf3[256]; + int fl=0 ; + int money=100 ; + int fd = getfdFromCharaIndex( toindex); + char tmp[64]; + + if(NPC_Util_GetArgStr( meindex, npcarg, sizeof(npcarg))==NULL){ + print("GetArgStrErr"); + CHAR_setWorkInt( toindex, CHAR_WORKSHOPRELEVANT, 0); + return ; + } + + if(NPC_PARTY_CHAECK( meindex, toindex) == FALSE) { + NPC_ERR_DiSP( meindex, toindex, 1); + return; + } + + + if( CHAR_getWorkInt( toindex, CHAR_WORKSHOPRELEVANT) != 0 ) { + return; + }else { + CHAR_setWorkInt( toindex, CHAR_WORKSHOPRELEVANT, 1); + } + + if(strstr(npcarg,"%4d")!=NULL){ + int flwork = 0; + int work; + NPC_Util_GetStrFromStrWithDelim( npcarg, "WARP", buf, sizeof( buf)); + getStringFromIndexWithDelim(buf,",",1,buf3,sizeof(buf3)); + work = atoi( buf3); + fl = NPC_FloorUse( toindex, atoi(buf3)); + + if(NPC_Util_GetStrFromStrWithDelim( npcarg, "Floor", buf3, sizeof( buf3)) != NULL){ + flwork = NPC_FloorUseOtherFloor(work, buf3); + } + fl = fl +flwork; + } + + NPC_Util_GetStrFromStrWithDelim( npcarg, "FREE", buf, sizeof( buf)); + + if( (NPC_ActionPassCheck(meindex,toindex,buf)==TRUE) || (strstr(buf,"ALLFREE")!=NULL) ){ + if(NPC_Util_GetStrFromStrWithDelim( npcarg, "FreeMsg", buf2, sizeof( buf2))==NULL) return; + CONNECT_set_pass(fd,TRUE); + CONNECT_set_first_warp(fd,TRUE); + if(strstr(buf2,"%4d") != NULL){ + sprintf(token,buf2,fl); + }else{ + strcpy(token,buf2); + } + CHAR_setWorkInt( toindex , CHAR_WORKSHOPRELEVANTTRD , -1 ); + CHAR_setWorkInt( toindex, CHAR_WORKSHOPRELEVANT, 2); + }else { + if(NPC_Util_GetStrFromStrWithDelim( npcarg, "PayMsg", buf2, sizeof( buf2)) != NULL){ + CONNECT_set_pass(fd,FALSE); + CONNECT_set_first_warp(fd,FALSE); + if(strstr(buf2,"%8d") != NULL){ + NPC_Util_GetStrFromStrWithDelim( npcarg, "MONEY", tmp, sizeof( tmp)); + if(strstr(tmp,"LV")!=NULL){ + int level; + char buff2[32]; + + level = CHAR_getInt(toindex,CHAR_LV); + getStringFromIndexWithDelim(tmp,"*",2,buff2,sizeof(buff2)); + money = level*atoi(buff2); + }else{ + money=atoi(tmp); + } + if(strstr(buf2,"%4d") != NULL){ + sprintf(token,buf2,fl,money); + }else{ + sprintf(token,buf2,money); + } + }else if(strstr(buf2,"%4d") != NULL){ + sprintf(token,buf2,fl); + NPC_Util_GetStrFromStrWithDelim( npcarg, "MONEY", tmp, sizeof( tmp)); + if( strstr( tmp,"-" ) != NULL){ + money=10000001; + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + CHAR_WINDOWTYPE_WINDOWWARPMAN_MAIN, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + token); + return ; + } + }else{ + strcpy(token,buf2); + NPC_Util_GetStrFromStrWithDelim( npcarg, "MONEY", tmp, sizeof( tmp)); + if( strstr( tmp,"-" ) != NULL){ + money=10000001; + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + CHAR_WINDOWTYPE_WINDOWWARPMAN_MAIN, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + token); + return ; + }else{ + money = atoi(tmp); + } + } + if(CHAR_getInt(toindex,CHAR_FLOOR)==117){ + money=CHAR_getInt(toindex,CHAR_GOLD); + if (money>=10) money*=0.9; + else if( money == 0 ) { + CHAR_warpToSpecificPoint(toindex,117,225,13); + return; + } + } + CHAR_setWorkInt( toindex , CHAR_WORKSHOPRELEVANTTRD , money ); + CONNECT_set_pass(fd,TRUE); + CONNECT_set_first_warp(fd,TRUE); + + }else if(NPC_Util_GetStrFromStrWithDelim( npcarg, "NomalMsg", token,sizeof(token)) !=NULL){ + CHAR_setWorkInt( toindex , CHAR_WORKSHOPRELEVANTTRD , -2 ); + CHAR_setWorkInt( toindex, CHAR_WORKSHOPRELEVANT, -1); + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + CHAR_WINDOWTYPE_WINDOWWARPMAN_MAIN, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + token); + } + } + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_YESNO, + CHAR_WINDOWTYPE_WINDOWWARPMAN_MAIN, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + token); +} + +void NPC_WarpManWindowTalked( int meindex, int talkerindex, + int seqno, int select, char *data) +{ + char npcarg[NPC_UTIL_GETARGSTR_BUFSIZE - 1024 * 20]; + char buf[NPC_UTIL_GETARGSTR_BUFSIZE - 1024 * 20]; +#ifdef _NEW_WARPMAN + BOOL checkp=TRUE; + char buf1[1024]; + int talkNo = 1; + BOOL tenflg=FALSE; +#else + int fl,x,y; +#endif + char buff2[256]; + int fd = getfdFromCharaIndex( talkerindex ); + if( NPC_Util_CharDistance( talkerindex, meindex ) > 2) + return; + if(NPC_Util_GetArgStr( meindex, npcarg, sizeof(npcarg))==NULL){ + print("GetArgStrErr"); + return ; + } + if( CHAR_getWorkInt( talkerindex, CHAR_WORKSHOPRELEVANT) < 1 ) { + CHAR_setWorkInt( talkerindex, CHAR_WORKSHOPRELEVANT, -1); + return; + } + +#ifdef _NEW_WARPMAN + if( seqno == NEW_WARPMAN ) { + int eqnum=0; + eqnum = CHAR_getWorkInt( talkerindex, CHAR_WORKSHOPRELEVANT); + sprintf(buf1,"%s", "NOFREE"); + if( eqnum >= 0 ) { + sprintf(buf1,"TALKEVENT%d", eqnum); + } + CHAR_setWorkInt( talkerindex, CHAR_WORKSHOPRELEVANT, 0); + while( getStringFromIndexWithDelim( npcarg,"OVER",talkNo,buf,sizeof( buf)) != FALSE){ + if( strstr(buf, buf1) != NULL) { + strcpy( npcarg , buf); + tenflg = TRUE; + break; + } + talkNo++; + } + if( tenflg == FALSE ) { + CHAR_setWorkInt( talkerindex, CHAR_WORKSHOPRELEVANT, -1); + return; + } + }else { +#endif + if( select != WINDOW_BUTTONTYPE_YES ) { + CHAR_setWorkInt( talkerindex, CHAR_WORKSHOPRELEVANT, -1); + return; + } + if(NPC_PARTY_CHAECK( meindex, talkerindex) == FALSE){ + NPC_ERR_DiSP( meindex, talkerindex, 1); + return; + } +#ifdef _NEW_WARPMAN + } +#else + NPC_Util_GetStrFromStrWithDelim( npcarg, "WARP", buf, sizeof( buf)); + GetRand_WarpPoint( buf, &fl, &x, &y ); +#endif + +#ifdef _NEW_WARPMAN + switch( seqno) { + case WARP_MAN: + if( select != WINDOW_BUTTONTYPE_YES ) + return; + if( NPC_PARTY_CHAECK( meindex, talkerindex) == FALSE ){ + NPC_ERR_DiSP( meindex, talkerindex, 1); + return; + } +#else + if( select != WINDOW_BUTTONTYPE_YES) return; + if( NPC_PARTY_CHAECK( meindex, talkerindex) == FALSE) + return; +#endif + +#ifdef _NEW_WARPMAN + break; + case NEW_WARPMAN: + if( select != WINDOW_BUTTONTYPE_YES ){ + CHAR_setWorkInt( talkerindex, CHAR_WORKSHOPRELEVANT, -1); + if( NPC_Util_GetStrFromStrWithDelim( npcarg, "CancelMsg", buff2, sizeof( buff2) ) != NULL) { + CHAR_talkToCli( talkerindex, meindex, buff2, CHAR_COLORYELLOW); + } + return; + } + checkp=TRUE; + if( NPC_Util_GetStrFromStrWithDelim( npcarg, "CHECKPARTY", buff2, sizeof( buff2) ) != NULL) { + if( strstr( buff2, "FALSE") != NULL ) { + checkp = FALSE; + } + } + if( checkp==TRUE && NPC_PARTY_CHAECK( meindex, talkerindex) == FALSE ) { + NPC_ERR_DiSP( meindex, talkerindex, 1); + CHAR_setWorkInt( talkerindex, CHAR_WORKSHOPRELEVANT, -1); + return; + } + break; + case NEW_WARPMAN_END: + return; + break; + } +#endif + + if( Action_RunDoEventAction( meindex, talkerindex, npcarg) == FALSE ){ + CHAR_setWorkInt( talkerindex, CHAR_WORKSHOPRELEVANT, -1); + return; + } + + CHAR_complianceParameter( talkerindex ); + CHAR_send_P_StatusString( talkerindex , + CHAR_P_STRING_ATK|CHAR_P_STRING_DEF| + CHAR_P_STRING_CHARM|CHAR_P_STRING_QUICK| + CHAR_P_STRING_WATER|CHAR_P_STRING_FIRE| + CHAR_P_STRING_WIND|CHAR_P_STRING_EARTH + ); + if( CHAR_getWorkInt( CONNECT_getCharaindex(fd), CHAR_WORKBATTLEMODE) != BATTLE_CHARMODE_NONE){ + return ; + } + if(CHAR_getWorkInt( talkerindex , CHAR_WORKSHOPRELEVANTTRD) <= 0){ + CHAR_setWorkInt( talkerindex, CHAR_WORKWARPCHECK, FALSE ); +#ifdef _NEW_WARPMAN + NPC_WarpMsg( meindex, talkerindex, npcarg); +#else + if( fl == 0 && x == 0 && y == 0 ) { + }else { + CHAR_warpToSpecificPoint(talkerindex, fl, x,y); + } +#endif + }else { + if(CHAR_getInt(talkerindex,CHAR_GOLD) < + CHAR_getWorkInt(talkerindex,CHAR_WORKSHOPRELEVANTTRD)){ + NPC_ERR_DiSP( meindex, talkerindex, 2); + return ; + } + CHAR_DelGold( talkerindex, CHAR_getWorkInt(talkerindex,CHAR_WORKSHOPRELEVANTTRD )); + + CHAR_setWorkInt( talkerindex, CHAR_WORKWARPCHECK, FALSE ); +#ifdef _NEW_WARPMAN + NPC_WarpMsg( meindex, talkerindex, npcarg); +#else + if( fl == 0 && x == 0 && y == 0 ) { + }else { + CHAR_warpToSpecificPoint(talkerindex, fl, x,y); + } +#endif + + } +#ifdef _NEW_WARPMAN + NPC_NpcWarpMsg( meindex, talkerindex, npcarg); +#else + } +#endif +} + +BOOL NPC_BigSmallLastCheck(int point1,int mypoint,int flg) +{ + if(flg==0){ + if(point1==mypoint) { + return TRUE; + } + + }else if(flg==1){ + if(mypoint < point1) { + return TRUE; + } + + }else if(flg==2){ + if(mypoint > point1) { + return TRUE; + } + } + + return FALSE; + +} + +BOOL NPC_GetDuelPointCheck(int meindex,int talker) +{ + + int fdid = getFdidFromCharaIndex( talker); + char dbkey[256]; + + if( fdid == -1 ) return FALSE; + + CHAR_makeDBKey( talker, dbkey, sizeof( dbkey)); + saacproto_DBGetEntryRank_send( acfd, DB_DUELPOINT, dbkey, fdid, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX)); + + return TRUE; + +} + +void NPC_GetDuelRank(int rank,int fdid,int objindex) +{ + + int talker; + int meindex; + + + rank++; + talker = getCharindexFromFdid( fdid); + if( talker == -1 ) return; + + meindex= OBJECT_getIndex( objindex); + if( !CHAR_CHECKINDEX( meindex)) return; + + CHAR_setWorkInt(talker,CHAR_WORKSHOPRELEVANTSEC,rank); + + NPC_WarpMan_selectWindow( meindex, talker,0,-1); + +} + +BOOL NPC_PARTY_CHAECK(int meindex,int talker) +{ + if(CHAR_getWorkInt(talker,CHAR_WORKPARTYMODE) != CHAR_PARTY_NONE){ + return FALSE; + } + return TRUE; +} + +void NPC_ERR_DiSP(int meindex,int talker,int errNO) +{ + char token[1024]; + int i=0; + int otherindex; + int fd = getfdFromCharaIndex( talker); + char npcarg[NPC_UTIL_GETARGSTR_BUFSIZE - 1024 * 20]; + + if(NPC_Util_GetArgStr( meindex, npcarg, sizeof(npcarg))==NULL){ + print("GetArgStrErr"); + return ; + } + if(errNO==1){ + if(NPC_Util_GetStrFromStrWithDelim( npcarg, "PartyMsg",token, sizeof( token))==NULL) { + sprintf(token,"\n\n޷Ŷӡ" + "\n\n ɢŶ "); + } + if(CHAR_getWorkInt(talker,CHAR_WORKPARTYMODE)==CHAR_PARTY_CLIENT){ + }else{ + + for( i=0 ; i < CHAR_PARTYMAX ;i++){ + otherindex=CHAR_getWorkInt(talker,CHAR_WORKPARTYINDEX1+i); + if(otherindex != -1){ + fd = getfdFromCharaIndex( otherindex); + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + CHAR_WINDOWTYPE_WINDOWWARPMAN_ERR, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + token); + } + } + return ; + } + }else if (errNO==2){ + if(NPC_Util_GetStrFromStrWithDelim( npcarg, "MoneyMsg", token, sizeof( token))==NULL){ + sprintf(token,"\n\nƺǮࡡ" + "\n\nǮᣬٹ"); + } + } + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + CHAR_WINDOWTYPE_WINDOWWARPMAN_ERR, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + token); +} + +int NPC_FloorUse(int charaindex,int floor) +{ + int i; + int players=0; + int playernum = CHAR_getPlayerMaxNum(); + for( i=0 ; i< playernum ; i++ ){ + if( CHAR_getCharUse(i) == FALSE )continue; + if(CHAR_getInt(i,CHAR_FLOOR)==floor){ + players++; + } + } + return players; +} + +int NPC_FloorUseOtherFloor(int warp, char *buf) +{ + int i,j=1; + int players=0; + int playernum = CHAR_getPlayerMaxNum(); + char buf2[32]; + int floor; + + for( i=0 ; i< playernum ; i++ ){ + if( CHAR_getCharUse(i) == FALSE )continue; + j=1; + while(getStringFromIndexWithDelim(buf,",",j,buf2,sizeof(buf2))!= FALSE){ + j++; + floor = atoi(buf2); + if(CHAR_getInt(i,CHAR_FLOOR) == floor && warp != floor) { + players++; + } + } + } + return players; +} + +BOOL NPC_WarpMsg(int meindex,int talker,char *arg) +{ + char buf[256]; + int fl=0,x=0,y=0; + int parent=-1; + int pmode; + int subindex; + int i; + + if( NPC_Util_GetStrFromStrWithDelim( arg, "WARP", buf, sizeof( buf)) == NULL ) + return FALSE; + GetRand_WarpPoint( buf, &fl, &x, &y ); + if( fl == 0 && x == 0 && y == 0 ) { + return TRUE; + }else { + if( MAP_IsValidCoordinate( fl,x,y )== FALSE ){ + print( "Warp NPC:1.Invalid warpman ERR" ); + return FALSE; + } + } +#ifdef _TIME_TICKET + if( check_TimeTicketMap( fl) ) { + int havei, itemi; + CHAR_setWorkInt( talker, CHAR_WORKTICKETTIME, 0); + CHAR_setWorkInt( talker, CHAR_WORKTICKETTIMESTART, 0); + for( havei = CHAR_STARTITEMARRAY ; havei < CHAR_MAXITEMHAVE ; havei++ ){ + itemi = CHAR_getItemIndex( talker, havei); + if( !ITEM_CHECKINDEX( itemi) ) continue; + if( strcmp( ITEM_getChar( itemi, ITEM_USEFUNC), "ITEM_timeticket") ) continue; + //if( ITEM_getInt( itemi ,ITEM_ID) != 20646 ) continue; + CHAR_talkToCli( talker, -1, "ԶʹƱ", CHAR_COLORYELLOW); + ITEM_timeticketEx( talker, talker, havei, 1); + break; + } + if( havei == CHAR_MAXITEMHAVE ) { + CHAR_talkToCli( talker, -1, "׼רƱſɽ롣", CHAR_COLORYELLOW); + return FALSE; + } + } +#endif + pmode = CHAR_getWorkInt( talker, CHAR_WORKPARTYMODE ); + switch( pmode ){ + case 1: + parent = talker; + break; + case 2: + parent = CHAR_getWorkInt( talker, CHAR_WORKPARTYINDEX1 ); + break; + default: + CHAR_warpToSpecificPoint(talker, fl, x,y); + return TRUE; + } + if( parent < 0 ) + return TRUE; + for( i = 0; i < CHAR_PARTYMAX; i ++ ){ + subindex = CHAR_getWorkInt( parent, CHAR_WORKPARTYINDEX1+i ); + if( CHAR_CHECKINDEX( subindex ) == FALSE )continue; + if( fl==0 && x==0 && y==0 ) { + }else { + CHAR_warpToSpecificPoint( subindex, fl, x, y ); + } + } + return TRUE; +} + +#ifdef _NEW_WARPMAN +static void NPC_NewWarpMan_selectWindow( int meindex, int toindex, int num,int select,char *TalkStr) +{ + char npcarg[NPC_UTIL_GETARGSTR_BUFSIZE - 1024 * 20]; + char token[1024]; + int buttontype = 0, windowtype = 0, windowno = 0; + char buf[NPC_UTIL_GETARGSTR_BUFSIZE - 1024 * 20],buf1[256]; + int fd = getfdFromCharaIndex( toindex); + BOOL tenflg =FALSE; + int talkNo=1,RunType=-1; + + if(NPC_Util_GetArgStr( meindex, npcarg, sizeof(npcarg))==NULL){ + print("GetArgStrErr"); + return ; + } + + if( NPC_Util_GetStrFromStrWithDelim( npcarg, "NEWTIME", buf1, sizeof( buf1)) != NULL ){ + if( CHAR_getWorkInt( meindex, NPC_TIME_MODE) <= 0 ) { + if( NPC_Util_GetStrFromStrWithDelim( npcarg, "Time_Msg", token, sizeof( token) ) != NULL) { + CHAR_talkToCli( toindex, meindex, token, CHAR_COLORYELLOW); + } + return; + } + } + + windowtype = WINDOW_MESSAGETYPE_MESSAGE; + sprintf( buf1,"TALKEVENT"); + //ѰҶ FREE + while(getStringFromIndexWithDelim( npcarg,"OVER",talkNo,buf,sizeof( buf)) != FALSE) { + if(strstr(buf, buf1) != NULL) { + //Ի + RunType = CheckWarpMsg( meindex, toindex, buf , TalkStr); + if( RunType > 1 ) { + return; + }else if( RunType != 0 ) { + talkNo++; + continue; + } + if( NPC_Util_GetStrFromStrWithDelim( buf, "FREE", token, sizeof( token) ) == NULL) { + print("msgErr"); + return; + } + + //Ƿ񸽺 + if((NPC_ActionPassCheck(meindex,toindex,token)==TRUE) || (strstr( token, "ALLFREE")!=NULL) ) { + CHAR_setWorkInt( toindex, CHAR_WORKSHOPRELEVANT, talkNo-1); + + // ȡ FreeMsg ִ + if(NPC_Util_GetStrFromStrWithDelim( buf, "FreeMsg", token, sizeof( token))==NULL) + return; + CONNECT_set_pass(fd,TRUE); + CONNECT_set_first_warp(fd,TRUE); + buttontype = WINDOW_BUTTONTYPE_YESNO; + windowno = NEW_WARPMAN; + tenflg = TRUE; + CHAR_setWorkInt( toindex , CHAR_WORKSHOPRELEVANTTRD , -1 ); + break; + } + } + talkNo++; + } + + //κ + if( tenflg == FALSE ) { + if( getStringFromIndexWithDelim( npcarg,"OVER",1,buf,sizeof( buf)) == FALSE ) + return; + if( strstr( buf, "NOFREE") == NULL ) { + return; + }else { + strcpy( npcarg, buf); + } + if(NPC_Util_GetStrFromStrWithDelim( npcarg, "NomalMsg", token,sizeof(token)) != NULL) { + CHAR_talkToCli( toindex, meindex, token,CHAR_COLORWHITE); + return; + } + } + + //ѶϢ CLI + lssproto_WN_send( fd, windowtype, buttontype, windowno, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), token ); +} + +#endif +//ANDY_RE +int CheckWarpMsg( int meindex, int talkerindex,char *npcarg ,char *TalkStr) +{ + char buf[1024]; + + if( NPC_Util_GetStrFromStrWithDelim( npcarg, "warp_msg", buf, sizeof( buf) ) == NULL) + return 0; + if( strcmp( buf, TalkStr) ) + return 1; + + if( NPC_Util_GetStrFromStrWithDelim( npcarg, "CHECKPARTY", buf, sizeof( buf) ) != NULL) { + if( strstr( buf, "FALSE") != NULL ) { + }else { + if( NPC_PARTY_CHAECK( meindex, talkerindex) == FALSE ) { + NPC_ERR_DiSP( meindex, talkerindex, 1); + return 2; + } + } + } + + if( NPC_Util_GetStrFromStrWithDelim( npcarg, "FREE", buf, sizeof( buf)) == NULL ) + return 2; + if( ( NPC_ActionPassCheck( meindex, talkerindex, buf ) == FALSE) ) { + if(NPC_Util_GetStrFromStrWithDelim( npcarg, "NomalMsg", buf,sizeof(buf)) != NULL) { + CHAR_talkToCli( talkerindex, meindex,buf,CHAR_COLORWHITE); + } + return 2; + }else { + if( Action_RunDoEventAction( meindex, talkerindex, npcarg) == FALSE ){ + + CHAR_setWorkInt( talkerindex, CHAR_WORKSHOPRELEVANT, -1); + return 3; + } + CHAR_complianceParameter( talkerindex ); + CHAR_send_P_StatusString( talkerindex , + CHAR_P_STRING_ATK|CHAR_P_STRING_DEF| + CHAR_P_STRING_CHARM|CHAR_P_STRING_QUICK| + CHAR_P_STRING_WATER|CHAR_P_STRING_FIRE| + CHAR_P_STRING_WIND|CHAR_P_STRING_EARTH ); + + if(NPC_Util_GetStrFromStrWithDelim( npcarg, "FreeMsg", buf, sizeof( buf)) != NULL ){ + CHAR_talkToCli( talkerindex, meindex, buf, CHAR_COLORWHITE); + } + + NPC_WarpMsg( meindex, talkerindex, npcarg); + NPC_NpcWarpMsg( meindex, talkerindex, npcarg); + return 4; + } + return 0; +} + +BOOL NPC_NpcWarpMsg(int meindex,int talker,char *arg) +{ + char buf[256]; + int fl=0,x=0,y=0; + + if( CHAR_CHECKINDEX( meindex ) == FALSE ) + return FALSE; + + if( NPC_Util_GetStrFromStrWithDelim( arg, "NPCPOINT", buf, sizeof( buf)) == NULL ) + return FALSE; + GetRand_WarpPoint( buf, &fl, &x, &y ); + + if( MAP_IsValidCoordinate( fl,x,y )== FALSE ){ + print( "Warp NPC:2.Invalid warpman ERR" ); + return FALSE; + } + + CHAR_warpToSpecificPoint( meindex, fl, x, y ); + + return TRUE; +} + +void NPC_WarpManLoop( int meindex) +{ + int born, dead; + char npcarg[NPC_UTIL_GETARGSTR_BUFSIZE - 1024 * 20]; + if( !CHAR_CHECKINDEX( meindex) ) return; + + if( NPC_Util_GetArgStr( meindex, npcarg, sizeof(npcarg)) == NULL ){ + print("WarpMan:GetArgStrErr"); + return; + } + if( !strstr( npcarg,"NEWWARPMAN") ) + return; + + if( NPC_getTimeData( meindex, npcarg, &born, &dead, 200) != FALSE ){ + NPC_TimeDefineDo( meindex, born, dead, NPC_TIME_MODE); + CHAR_sendCToArroundCharacter( CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX ) ); + } +} + +void NPC_WarpManWatch( int meobjindex, int objindex, CHAR_ACTION act, + int x,int y,int dir, int* opt,int optlen ) +{ + int born, dead; + int meindex, index; + + char npcarg[NPC_UTIL_GETARGSTR_BUFSIZE - 1024 * 20]; + + if( OBJECT_getType( objindex) != OBJTYPE_CHARA) return; + index = OBJECT_getIndex( objindex); + if( !CHAR_CHECKINDEX( index) ) return; + if( CHAR_getInt( index, CHAR_WHICHTYPE) != CHAR_TYPEPLAYER) return; + meindex = OBJECT_getIndex( meobjindex); + if( !CHAR_CHECKINDEX( meindex) ) return; + + if( NPC_Util_GetArgStr( meindex, npcarg, sizeof(npcarg)) == NULL ){ + print("WarpMan:GetArgStrErr"); + return; + } + if( !strstr( npcarg,"NEWWARPMAN") ) + return; +#ifdef _TREASURE_BOX + if( CHAR_getWorkInt( meindex, NPC_TIME_EVENTMODE) == NPC_EVENTMODE_OPEN ){ + if( CHAR_getWorkInt( meindex, NPC_TIME_EVENTTIME) < NowTime.tv_sec ){ + //ر + CHAR_setWorkInt( meindex, NPC_TIME_EVENTMODE, NPC_EVENTMODE_EVENT); + //ͼ + CHAR_setInt( meindex, CHAR_BASEBASEIMAGENUMBER, + CHAR_getWorkInt( meindex, NPC_TIME_EVENOFFDBBI)); + CHAR_setInt( meindex, CHAR_BASEIMAGENUMBER, + CHAR_getWorkInt( meindex, NPC_TIME_EVENOFFDBBI)); + NPC_TreasureEventRunMsg( meindex); //Ƿwarp + CHAR_sendCToArroundCharacter( CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX ) ); + } + } +#endif + if( NPC_getTimeData( meindex, npcarg, &born, &dead, 200) != FALSE ){ + NPC_TimeDefineDo( meindex, born, dead, NPC_TIME_MODE); + CHAR_sendCToArroundCharacter( CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX ) ); + } +} + +#ifdef _TREASURE_BOX +BOOL NPC_TreasureEventRunMsg( int meindex) +{ + char buf[256]; + char npcarg[NPC_UTIL_GETARGSTR_BUFSIZE - 1024 * 20]; + + int fl,x,y; + + if( !CHAR_CHECKINDEX( meindex )) + return FALSE; + + + if(NPC_Util_GetArgStr( meindex, npcarg, sizeof(npcarg))==NULL){ + print("WarpMan:GetArgStrErr"); + return FALSE; + } + + if( NPC_Util_GetStrFromStrWithDelim( npcarg, "TREASURE_NUM", buf, sizeof( buf)) == NULL ) + return FALSE; + + if( CHAR_getWorkInt( meindex, NPC_TIME_EVENTNUM) < atoi( buf) ) return FALSE; + CHAR_setWorkInt( meindex, NPC_TIME_EVENTNUM, 0); + + if( NPC_Util_GetStrFromStrWithDelim( npcarg, "TREASURE_POINT", buf, sizeof( buf)) == NULL ) + return FALSE; + GetRand_WarpPoint( buf, &fl, &x, &y ); + + if( MAP_IsValidCoordinate( fl,x,y )== FALSE ){ + print( "Warp NPC:2.Invalid warpman ERR" ); + return FALSE; + } + + CHAR_warpToSpecificPoint( meindex, fl, x, y ); + return TRUE; +} + +#endif + +BOOL NPC_TreasureRandItemGet(int meidex,int talker,int rand_j,char *buf) +{ + char buff2[64]; + int randitem; + int ret; + int itemindex; + char token[128]; + + if(rand_j == 0) { + print("Event:춣Ľ룬ִ"); + return FALSE; + } + + randitem = rand()%rand_j; + if(randitem == 0) randitem = rand_j; + + getStringFromIndexWithDelim(buf , "," , randitem, buff2, sizeof(buff2)) ; + + itemindex = ITEM_makeItemAndRegist( atoi( buff2)); + + if(itemindex == -1) return FALSE; + + /*ʧ ةܰ( ʧ ة ľ */ + ret = CHAR_addItemSpecificItemIndex( talker, itemindex); + if( !CHAR_CHECKITEMINDEX( talker, ret) ){ + print( "npc_exchangeman.c: additem error itemindex[%d]\n", itemindex); + ITEM_endExistItemsOne( itemindex); + return FALSE; + } + + if(itemindex != -1) { + LogItem( + CHAR_getChar( talker, CHAR_NAME ), /* ƽҷ */ + CHAR_getChar( talker, CHAR_CDKEY ), +#ifdef _add_item_log_name // WON ADD itemlogitem + itemindex, +#else + ITEM_getInt( itemindex, ITEM_ID), /* ʧ ة į */ +#endif + "EventAddItem(õĵ)", + CHAR_getInt( talker,CHAR_FLOOR), + CHAR_getInt( talker,CHAR_X ), + CHAR_getInt( talker,CHAR_Y ), + ITEM_getChar( itemindex, ITEM_UNIQUECODE), + ITEM_getChar( itemindex, ITEM_NAME), + ITEM_getInt( itemindex, ITEM_ID) + ); + } + + sprintf(token,"%s",ITEM_getChar( itemindex, ITEM_NAME)); + CHAR_talkToCli( talker, -1, token, CHAR_COLORWHITE); + + CHAR_sendItemDataOne( talker, ret); + return TRUE; + +} + +#ifdef _NPC_ADDLEVELUP // (ɿ) ANDY ⲿԻҵȼ +extern tagRidePetTable ridePetTable[296]; +void NPC_LevelAndTransUp( int meindex, int charindex, int level, int skillpoint, int exp, int ridepet) +{ + char szBuffer[256]=""; + if( !CHAR_CHECKINDEX( charindex) ) + return; +//int CHAR_LevelUpCheck( int charaindex , int toindex) + if( exp > 0 ){ + int LevelUp=0; + int myexp = CHAR_getInt( charindex, CHAR_EXP); + myexp += exp; + if( myexp > 300000000 ) myexp = 300000000; + CHAR_setInt( charindex, CHAR_EXP, myexp); + snprintf( szBuffer, sizeof(szBuffer), + "(%s) õ EXP %d", CHAR_getUseName( charindex ), exp); + CHAR_talkToCli( charindex, -1, szBuffer, CHAR_COLORYELLOW); + LevelUp = CHAR_LevelUpCheck( charindex , -1); + if( LevelUp > 0 ){ + snprintf( szBuffer, sizeof(szBuffer), + "(%s) %d", + CHAR_getUseName( charindex ), + CHAR_getInt( charindex, CHAR_LV ) + ); + CHAR_talkToCli( charindex, -1, szBuffer, CHAR_COLORYELLOW); + CHAR_setInt( charindex, CHAR_SKILLUPPOINT, + CHAR_getInt( charindex, CHAR_SKILLUPPOINT) + LevelUp*3 ); + CHAR_complianceParameter( charindex ); + } + } + + if( level > 0 ){ + CHAR_setInt( charindex, CHAR_LV, level); + snprintf( szBuffer, sizeof(szBuffer), + "(%s) ȼ趨Ϊ %d", + CHAR_getUseName( charindex ), CHAR_getInt( charindex, CHAR_LV ) + ); + CHAR_talkToCli( charindex, -1, szBuffer, CHAR_COLORYELLOW); + } + + if( skillpoint > 0 ){ + int MySp = CHAR_getInt( charindex, CHAR_SKILLUPPOINT); + MySp += skillpoint; + CHAR_setInt( charindex, CHAR_SKILLUPPOINT, MySp); + } + if( ridepet >= 0 ){ + int basepet[2][4]={ {2066,2067,2068,2069}, + {2072,2073,2074,2075}}; + int petTemp[]={-1,-1,-1,-1,-1}; + char msgbuf[256]; + int petNum=0; + int i,j=0; + int k=0, petindex,enemyarray; + petTemp[j++] = basepet[0][rand()%4]; + petTemp[j++] = basepet[1][rand()%4]; + + for( i=0; i< arraysizeof(ridePetTable) ; i++ ){ + if( CHAR_getInt( charindex, CHAR_BASEBASEIMAGENUMBER) == ridePetTable[i].charNo ){ + petTemp[j]= ridePetTable[i].petId; + j++; + if( j >= arraysizeof( petTemp) ) + break; + } + } + j=0; + for( petNum=0; petNum +#include "char.h" +#include "object.h" +#include "char_base.h" +#include "npcutil.h" +#include "lssproto_serv.h" +#include "pet_skill.h" +#include "readmap.h" +#include "battle.h" +#include "profession_skill.h" +#include "chatmagic.h" +#include "npc_welfare.h" +#include "npc_exchangeman.h" + +static void NPC_Welfare_selectWindow(int meindex, int toindex, int num, int select); + + +//ÿNPCijʼ +BOOL NPC_WelfareInit( int meindex ) +{ + CHAR_setInt( meindex , CHAR_WHICHTYPE , CHAR_TYPEWELFARE); + //print(":%s\n",CHAR_getChar( meindex, CHAR_NAME)); + return TRUE; +} + +//ԻʱĴ +void NPC_WelfareTalked( int meindex , int talkerindex , char *szMes ,int color ) +{ + if( CHAR_getInt( talkerindex , CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER ) { + return; + } + if(NPC_Util_isFaceToFace(talkerindex,meindex,2 )==FALSE){ + if( NPC_Util_CharDistance( talkerindex, meindex ) > 1) return; + } + NPC_Welfare_selectWindow( meindex, talkerindex,0,-1); +} + +static void NPC_Welfare_selectWindow( int meindex, int toindex, int num,int select) +{ + switch(num){ + case 0: + //free + NPC_WelfareMakeStr(meindex, toindex, select); + break; + case 1: + break; + } +} + +void NPC_WelfareWindowTalked( int meindex, int talkerindex, + int seqno, int select, char *data) +{ + int skill, i, j; + int cost; + int skillID=0; + char buf[64]; + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + char msg[512]; + char message[64]; + int fd = getfdFromCharaIndex( talkerindex ); + double rate= 1.0; + int skillarray; + int p_class=0, need_class=0; + int profession_skill_point; + + memset( message, -1, sizeof(message) ); + + if( NPC_Util_CharDistance( talkerindex, meindex ) > 2) { + return; + } + + if(NPC_Util_GetArgStr( meindex, argstr, sizeof(argstr))==NULL){ + print("GetArgStrErr"); + return; + } + + makeStringFromEscaped( data); + getStringFromIndexWithDelim(data,"|",1,buf,sizeof(buf)); + skill=atoi(buf); + getStringFromIndexWithDelim(data,"|",2,buf,sizeof(buf)); + cost=atoi(buf); + + if( NPC_Util_GetStrFromStrWithDelim( argstr, "profession_skill", msg, sizeof( msg)) != NULL){ + getStringFromIndexWithDelim(msg,",",skill,buf,sizeof(buf)); + skillID=atoi(buf); + } + + + if(skillID < 0) return ; + + if( CHAR_getWorkInt( CONNECT_getCharaindex(fd), CHAR_WORKBATTLEMODE) != BATTLE_CHARMODE_NONE) return ; + + if( NPC_Util_GetStrFromStrWithDelim( argstr, "skill_rate", msg, sizeof( msg)) != NULL){ + rate = atof( msg); + } + + skillarray = PROFESSION_SKILL_getskillArray( skillID ); + + if(skillarray == -1){ + CHAR_send_P_StatusString( talkerindex, CHAR_P_STRING_GOLD); + return ; + } + + // жְҵ + { + if( NPC_Util_GetStrFromStrWithDelim( argstr, "profession_class", msg, sizeof(msg) ) == NULL){ + return ; + }else{ + p_class = atoi(msg); + } + + // ְҵ + need_class = PROFESSION_SKILL_getInt( skillarray, PROFESSION_SKILL_PROFESSION_CLASS ); + + if( CHAR_getInt( talkerindex, PROFESSION_CLASS ) == 0 ){ + char token[256]; + memset(token, -1, sizeof(token) ); + sprintf( token, "δְ!" ); + CHAR_talkToCli( talkerindex, meindex, token, CHAR_COLORYELLOW); + CHAR_send_P_StatusString( talkerindex, CHAR_P_STRING_GOLD); + return; + + } + + if( CHAR_getInt( talkerindex, PROFESSION_CLASS ) != need_class && need_class != 4 ){ + char token[256]; + memset(token, -1, sizeof(token) ); + sprintf( token, "˼㲻ѧ!" ); + CHAR_talkToCli( talkerindex, meindex, token, CHAR_COLORYELLOW); + CHAR_send_P_StatusString( talkerindex, CHAR_P_STRING_GOLD); + return; + } + + + } + + // жʣ + { + profession_skill_point = CHAR_getInt( talkerindex, PROFESSION_SKILL_POINT ); + if( profession_skill_point <= 0 ){ + char token[256]; + memset(token, -1, sizeof(token) ); + sprintf( token, "Ŀǰûѧϰ!" ); + CHAR_talkToCli( talkerindex, meindex, token, CHAR_COLORYELLOW); + CHAR_send_P_StatusString( talkerindex, CHAR_P_STRING_GOLD); + return; + } + } + + // жǷѧϰ + { + int temp[4] = {0}, count = 0, flag = -1 , need_percent = -1, need_count = 0; + + for( i=0; i<4; i++){ + int limit = -1; + flag = -1; + limit = PROFESSION_SKILL_getInt( skillarray, PROFESSION_SKILL_LIMIT1+i*2 ); + need_percent = PROFESSION_SKILL_getInt( skillarray, PROFESSION_SKILL_LIMIT1+i*2 + 1 ); + + if( limit!= 0 && need_percent == 0 ) need_count++; + + if( limit == 0 ){ + continue; + }else if( limit == -1 ){ + for( j=0; j 0 ) break; + } + if( j >= PROFESSION_MAX_LEVEL ){ + char token[256]; + sprintf( token, "ѧΣսܲѧϰ"); + CHAR_talkToCli( talkerindex, meindex, token, CHAR_COLORYELLOW); + CHAR_send_P_StatusString( talkerindex, CHAR_P_STRING_GOLD); + return; + } + }else{ + flag = -1; + for( j=0; jskill, SKILL_LEVEL); + + // ж + if( skill_level >= need_percent ){ + flag = 1; break; + } + } + } + + // δ + if( flag == -1 && need_percent == 0 ){ + temp[count] = limit; + count ++; + }else if( flag == -1 ){ + char token[256]; + memset(token, -1, sizeof(token) ); + sprintf( token, "δѧ%s!", PROFESSION_SKILL_getChar( limit, PROFESSION_SKILL_NAME) ); + CHAR_talkToCli( talkerindex, -1, token, CHAR_COLORYELLOW); + CHAR_send_P_StatusString( talkerindex, CHAR_P_STRING_GOLD); + return; + }else if( flag == -2 ){ + char token[256]; + memset(token, -1, sizeof(token) ); + sprintf( token, "%sȲ%d!", PROFESSION_SKILL_getChar( limit, PROFESSION_SKILL_NAME), need_percent ); + CHAR_talkToCli( talkerindex, -1, token, CHAR_COLORYELLOW); + CHAR_send_P_StatusString( talkerindex, CHAR_P_STRING_GOLD); + return; + } + } + } + + if( count == need_count && need_count != 0 ){ + char msg[256] = {0}; + + sprintf( msg, "ѧ " ); + for( i = 0; i< count; i++ ){ + if( temp[i] != 0 ){ + char token[50] = {0}; + sprintf( token, "%s ", PROFESSION_SKILL_getChar( temp[i], PROFESSION_SKILL_NAME) ); + strcat( msg, token ); + } + } + sprintf( msg, "%s һּ", msg ); + CHAR_talkToCli( talkerindex, -1, msg, CHAR_COLORYELLOW); + CHAR_send_P_StatusString( talkerindex, CHAR_P_STRING_GOLD); + + return; + } + + } + + // жϽǮ + { + cost = PROFESSION_SKILL_getInt( skillarray, PROFESSION_SKILL_COST ); + cost = cost * rate; + + if(CHAR_getInt(talkerindex,CHAR_GOLD) < cost){ + CHAR_send_P_StatusString( talkerindex, CHAR_P_STRING_GOLD); + return; + } + } + +#ifdef _NPC_ProfessionTrans + //жת + { + if( NPC_Util_GetStrFromStrWithDelim( argstr, "trans", msg, sizeof(msg) ) != NULL){ + int trans = atoi(msg); + print("\nתҪ:%d,%d",CHAR_getInt( talkerindex, CHAR_TRANSMIGRATION),trans); + if( CHAR_getInt( talkerindex, CHAR_TRANSMIGRATION) < trans){ + if( NPC_Util_GetStrFromStrWithDelim( argstr, "trans_msg", msg, sizeof(msg) ) != NULL){ + CHAR_talkToCli( talkerindex, meindex, msg, CHAR_COLORYELLOW); + return; + } + else{ + CHAR_talkToCli( talkerindex, meindex, "תŶ", CHAR_COLORYELLOW); + return; + } + } + } + } +#endif + + // Ӽ + { + int skill_level = 0; + + // ͨȸ5010 + if( (skillID == 63) || (skillID == 64) || (skillID == 65) ){ + int Pskillid = -1; + skill_level = 50; + Pskillid = PROFESSION_SKILL_getskillArray( skillID ); + }else{ + skill_level = 10; + } + + if( PROFESSION_SKILL_ADDSK( talkerindex, skillID, skill_level ) == -1 ) return; + + CHAR_DelGold( talkerindex, cost ); + + CHAR_sendStatusString( talkerindex , "S"); + + NPC_Welfare_selectWindow( meindex, talkerindex,0,-1); + } + + // ѶϢ + { + char token[256]; + int next_profession_skill_point = profession_skill_point-1; + + CHAR_setInt( talkerindex, PROFESSION_SKILL_POINT, next_profession_skill_point ); + + memset(token, -1, sizeof(token) ); + sprintf( token, "ѧϰ %sʣѧϰ %d" + ,PROFESSION_SKILL_getChar( skillarray, PROFESSION_SKILL_NAME ) + ,next_profession_skill_point ); + CHAR_talkToCli( talkerindex, -1, token, CHAR_COLORYELLOW); + + CHAR_sendCToArroundCharacter( CHAR_getWorkInt( talkerindex , CHAR_WORKOBJINDEX )); + } + +} + +void NPC_WelfareMakeStr(int meindex,int toindex,int select) +{ + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + char msg[256]; + double rate=1.0; + int i=0; + char token[65530]; + int fd = getfdFromCharaIndex( toindex); + + if(select==0){ + sprintf(token,"0|0"); + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_PETSKILLSHOP, + WINDOW_BUTTONTYPE_NONE, + CHAR_WINDOWTYPE_WINDOWPETSKILLSHOP, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + token); + + } + + if(NPC_Util_GetArgStr( meindex, argstr, sizeof(argstr))==NULL){ + print("GetArgStrErr"); + return; + } + + if( NPC_Util_GetStrFromStrWithDelim( argstr, "main_msg", msg, sizeof( msg)) == NULL){ + print("mainERR"); + return ; + } + + sprintf(token,"1|%s|%s", CHAR_getChar(meindex,CHAR_NAME), msg); + + if( NPC_Util_GetStrFromStrWithDelim( argstr, "skill_rate", msg, sizeof( msg)) != NULL){ + rate=atof(msg); + } + + + if( NPC_Util_GetStrFromStrWithDelim( argstr, "profession_skill", msg, sizeof( msg) ) != NULL){ + int skillarray; + int skillID; + int cost; + char token2[265]; + char buf[64]; + + i=1; + while( getStringFromIndexWithDelim(msg,",",i,buf,sizeof(buf)) !=FALSE ){ + i++; + skillID=atoi(buf); + + skillarray = PROFESSION_SKILL_getskillArray( skillID ); + + if( PROFESSION_SKILL_CHECKINDEX( skillarray ) == FALSE ) continue; + + cost = PROFESSION_SKILL_getInt( skillarray, PROFESSION_SKILL_COST ); + + cost = (int)cost*rate; + + sprintf(token2,"|%s|%d|%s|%d", + PROFESSION_SKILL_getChar( skillarray, PROFESSION_SKILL_NAME ), // + cost, // + PROFESSION_SKILL_getChar( skillarray, PROFESSION_SKILL_TXT ), // ˵ + PROFESSION_SKILL_getInt( skillarray, PROFESSION_SKILL_ICON ) // ͼʾ + ); + strcat(token,token2); + } + } + + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_PROFESSIONSHOP, + WINDOW_BUTTONTYPE_NONE, + WINDOW_MESSAGETYPE_PROFESSIONSHOP, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + token); + + return; +} + + +#endif +#endif + + diff --git a/npc/npc_welfare2.c b/npc/npc_welfare2.c new file mode 100644 index 0000000..e69de29 diff --git a/npc/npc_windowhealer.c b/npc/npc_windowhealer.c new file mode 100644 index 0000000..132739b --- /dev/null +++ b/npc/npc_windowhealer.c @@ -0,0 +1,698 @@ +#include "version.h" +#include +#include "char.h" +#include "object.h" +#include "char_base.h" +#include "npcutil.h" +#include "lssproto_serv.h" +#include "npc_windowhealer.h" + + + +#define RATE 1000 + + +/* + * ɬýľūëNPC + * + */ + +enum { + CHAR_WORK_LEVEL = CHAR_NPCWORKINT1, + CHAR_WORK_RANGE = CHAR_NPCWORKINT2, + CHAR_WORK_HP = CHAR_NPCWORKINT3, + CHAR_WORK_MP = CHAR_NPCWORKINT4, + +}; + + +static void NPC_WindowHealer_selectWindow( int meindex, int toindex, int num); +void NPC_WindowHealerAllHeal( int talker,int mode ); +BOOL NPC_WindowHealerLevelCheck(int meindex,int talker); +BOOL NPC_WindowMoneyCheck(int meindex,int talker,int mode); +int NPC_WindowCostCheck(int meindex,int talker); +BOOL NPC_PetHealerCheck(int talker); +int NPC_WindowCostCheckMp(int meindex,int talker); + + +/********************************* +*********************************/ +BOOL NPC_WindowHealerInit( int meindex ) +{ + + char *npcarg; + char buf2[256]; + int range=1; + int rate; + double drate; + CHAR_setInt( meindex , CHAR_WHICHTYPE , CHAR_TYPEHEALER ); + + npcarg = CHAR_getChar(meindex,CHAR_NPCARGUMENT); + + /*--弰ëìëʢ--*/ + if(getStringFromIndexWithDelim(npcarg,"|",1,buf2,sizeof(buf2))!=FALSE){ + CHAR_setWorkInt(meindex,CHAR_WORK_LEVEL,atoi(buf2)); + + }else{ + return FALSE; + } + if(getStringFromIndexWithDelim(npcarg, "|", 2, buf2, sizeof( buf2)) != FALSE ){ + drate = atof(buf2); + if(drate==0) { + rate=500; + }else{ + rate=(int) (drate * RATE); + } + CHAR_setWorkInt(meindex,CHAR_WORK_HP,rate); + } + if(getStringFromIndexWithDelim(npcarg, "|", 3, buf2, sizeof( buf2)) != FALSE ){ + drate = atof(buf2); + if(drate==0){ + rate=2000; + }else{ + rate=(int)( drate * RATE); + } + CHAR_setWorkInt(meindex,CHAR_WORK_MP,rate); + } + if(getStringFromIndexWithDelim(npcarg, "|", 4, buf2, sizeof( buf2)) != FALSE ){ + range=atoi(buf2); + if(range == 0){ + range=1; + } + } + CHAR_setWorkInt(meindex,CHAR_WORK_RANGE,range); + return TRUE; + +} + +void NPC_WindowHealerTalked( int meindex , int talkerindex , char *szMes ,int color ) +{ + if( CHAR_getInt( talkerindex , CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER ) { + return; + } + + if( NPC_Util_CharDistance( talkerindex, meindex ) + > CHAR_getWorkInt(meindex,CHAR_WORK_RANGE)){ + return; + } + if( (CHAR_getWorkInt(talkerindex,CHAR_WORKPARTYMODE) == 0) + || (CHAR_getWorkInt(talkerindex,CHAR_WORKPARTYMODE) == 2) ){ + NPC_WindowHealer_selectWindow( meindex, talkerindex,0); + }else{ + int i=0; + int otherindex; + + for( i=0 ; i < CHAR_PARTYMAX ;i++){ + otherindex=CHAR_getWorkInt(talkerindex,CHAR_WORKPARTYINDEX1+i); + if(otherindex != -1){ + NPC_WindowHealer_selectWindow( meindex, otherindex,0); + } + } + } +} +void NPC_WindowHealerLooked( int meindex , int lookedindex) +{ + if( CHAR_getInt( lookedindex , CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER ) { + return; + } + if( NPC_Util_CharDistance( lookedindex, meindex ) + > CHAR_getWorkInt(meindex,CHAR_WORK_RANGE)){ + return; + } + NPC_WindowHealer_selectWindow( meindex, lookedindex,0); +} + +static void NPC_WindowHealer_selectWindow( int meindex, int toindex, int num) +{ + + char token[1024]; + char escapedname[1024]; + int fd = getfdFromCharaIndex( toindex); + int buttontype=0; + int windowtype=0; + int windowno=0; + + /*--̼⻥мƥƱɬ--*/ + windowtype=WINDOW_MESSAGETYPE_MESSAGE; + + switch( num){ + case 0: + sprintf(token," ѽ𣿡 \n\n " + " ;ظ \n" + " ظ \n" + " ;ظ \n\n" + " ظ() " + ); + + buttontype=WINDOW_BUTTONTYPE_CANCEL; + windowtype=WINDOW_MESSAGETYPE_SELECT; + windowno=CHAR_WINDOWTYPE_WINDOWHEALER_STARTMSG; + break; + + + case 1: + if( CHAR_getInt(toindex,CHAR_HP) ==CHAR_getWorkInt( toindex, CHAR_WORKMAXHP)){ + if(NPC_PetHealerCheck(toindex)==FALSE){ + sprintf(token, + " ;ظ" + "\n\n\n\nƺûбҪظࡣ"); + }else{ + sprintf(token, + " ;ظ" + "\n\n ƺûбҪظࡣ" + "\n\nΪҲˣ" + "\n Ȱظɣ"); + + NPC_WindowHealerAllHeal(toindex,0 ); + } + + buttontype=WINDOW_BUTTONTYPE_OK; + windowno=CHAR_WINDOWTYPE_WINDOWHEALER_HPMSG; + break; + }else if(NPC_WindowHealerLevelCheck(meindex,toindex)==TRUE){ + sprintf(token," ;ظ" + "\n\n\nҪظ;ûɣ " + "\n\nڵĵȼѰظࡣ"); + + }else{ + int gold; + gold=NPC_WindowCostCheck(meindex,toindex); + sprintf(token," ;ظ" + "\n\n\nҪظ;ûɣ " + "\n\n%dSTONE " + ,gold); + } + + buttontype=WINDOW_BUTTONTYPE_YESNO; + windowno=CHAR_WINDOWTYPE_WINDOWHEALER_HPMSG; + break; + + case 2: + if( CHAR_getInt(toindex,CHAR_MP) ==CHAR_getWorkInt( toindex, CHAR_WORKMAXMP)){ + if(NPC_PetHealerCheck(toindex)==FALSE){ + sprintf(token, " ظ" + "\n\n\n\nƺûбҪظࡣ"); + }else{ + sprintf(token, " ظ" + "\n\n ƺûбҪظࡣ" + "\n\nΪҲˣ" + "\n Ȱظɣ"); + NPC_WindowHealerAllHeal(toindex,0 ); + } + buttontype=WINDOW_BUTTONTYPE_OK; + windowno=CHAR_WINDOWTYPE_WINDOWHEALER_SPIRITMSG; + break; + } + + if(NPC_WindowHealerLevelCheck(meindex,toindex)==TRUE){ + sprintf(token," ظ" + "\n\nҪظûɣ " + "\n\n ڵĵȼѰظࡣ"); + }else{ + int cost; + cost=NPC_WindowCostCheckMp(meindex,toindex); + sprintf(token," ظ" + "\n\n\nҪظûɣ " + "\n\n%dSTONE ", + cost); + } + buttontype=WINDOW_BUTTONTYPE_YESNO; + windowno=CHAR_WINDOWTYPE_WINDOWHEALER_SPIRITMSG; + break; + + + case 3: + sprintf(token, "\n;ѻظ" + "\n Ҳѻظһ״̬" + "\n\n\n Ӿûˣ"); + + NPC_WindowHealerAllHeal( toindex ,1 ); + buttontype=WINDOW_BUTTONTYPE_OK; + windowno=CHAR_WINDOWTYPE_WINDOWHEALER_OKHPMSG; + break; + + + case 4: + sprintf(token, "\nѻظ" + "\n Ҳѻظһ״̬" + "\n\n\n Ӿûˣ "); + NPC_WindowHealerAllHeal( toindex ,2 ); + buttontype=WINDOW_BUTTONTYPE_OK; + windowno=CHAR_WINDOWTYPE_WINDOWHEALER_OKSPIRITMSG; + break; + + + case 6: + { + int cost=0; + + if(CHAR_getInt(toindex,CHAR_HP) < CHAR_getWorkInt( toindex, CHAR_WORKMAXHP)) + { + cost+=NPC_WindowCostCheck(meindex,toindex); + } + + if( CHAR_getInt(toindex,CHAR_MP) < CHAR_getWorkInt( toindex, CHAR_WORKMAXMP)) + { + cost=cost+NPC_WindowCostCheckMp(meindex,toindex); + } + + if(cost==0) { + if(NPC_PetHealerCheck(toindex)==FALSE){ + sprintf(token, + " ;ظ" + "\n\n\n\nƺûбҪظࡣ"); + }else{ + sprintf(token," ;ظ" + "\n\n ƺûбҪظࡣ" + "\n\nΪҲˣ" + "\n Ȱظɣ"); + NPC_WindowHealerAllHeal(toindex,0 ); + } + + + + buttontype=WINDOW_BUTTONTYPE_OK; + windowtype=WINDOW_MESSAGETYPE_MESSAGE; + windowno=CHAR_WINDOWTYPE_WINDOWHEALER_SPIRITMSG; + break; + + }else{ + sprintf(token," ;ظ" + "\n\n\n Ҫظ;ûɣ" + "\n\n%dSTONE ",cost); + } + } + + if(NPC_WindowHealerLevelCheck(meindex,toindex)==TRUE){ + sprintf(token," ;ظ" + "\n\n\n Ҫظ;ûɣ" + "\n\nڵĵȼѰظࡣ"); + } + + buttontype=WINDOW_BUTTONTYPE_YESNO; + windowtype=WINDOW_MESSAGETYPE_MESSAGE; + windowno=CHAR_WINDOWTYPE_WINDOWHEALER_ALLMSG; + break; + + + case 7: + sprintf(token," ;ѻظ" + "\n Ҳѻظһ״̬" + "\n\n\nһͻظˣ"); + + NPC_WindowHealerAllHeal( toindex ,3 ); + buttontype=WINDOW_BUTTONTYPE_OK; + windowtype=WINDOW_MESSAGETYPE_MESSAGE; + windowno=CHAR_WINDOWTYPE_WINDOWHEALER_OKALLMSG; + break; + + + case 8: + sprintf(token,"\n\n\n\n ϧƺĽǮࡣ"); + + buttontype=WINDOW_BUTTONTYPE_OK; + windowtype=WINDOW_MESSAGETYPE_MESSAGE; + windowno=CHAR_WINDOWTYPE_WINDOWHEALER_OKHPMSG; + break; + + case 9: + sprintf(token,"ظ" + "\n\n\nѾû" + "\n\n̫ǿĻҲࡣ"); + NPC_WindowHealerAllHeal(toindex,0 ); + buttontype=WINDOW_BUTTONTYPE_OK; + windowtype=WINDOW_MESSAGETYPE_MESSAGE; + windowno=CHAR_WINDOWTYPE_WINDOWHEALER_OKHPMSG; + break; + + case 10: + sprintf(token,"ظ" + "\n\n\n ƺûбҪظӡ" + "\n\n̫ǿĻҲࡣ"); + buttontype=WINDOW_BUTTONTYPE_OK; + windowtype=WINDOW_MESSAGETYPE_MESSAGE; + windowno=CHAR_WINDOWTYPE_WINDOWHEALER_OKHPMSG; + break; + + + } + + + makeEscapeString( token, escapedname, sizeof(escapedname)); + /*-ƥ˪--*/ + lssproto_WN_send( fd, windowtype, + buttontype, + windowno, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + escapedname); + +} + + +/*----------------------------------------- +-------------------------------------------*/ +void NPC_WindowHealerWindowTalked( int meindex, int talkerindex, + int seqno, int select, char *data) +{ + + if( NPC_Util_CharDistance( talkerindex, meindex ) > (CHAR_getWorkInt(meindex,CHAR_WORK_RANGE)+4)) return; + + switch( seqno){ + case CHAR_WINDOWTYPE_WINDOWHEALER_STARTMSG: + if(atoi(data)==2) /*-- 1--*/ + { + NPC_WindowHealer_selectWindow( meindex, talkerindex, 1 ); + + }else if(atoi(data)==3){ + NPC_WindowHealer_selectWindow( meindex, talkerindex, 2 ); + + }else if(atoi(data)==4){ + NPC_WindowHealer_selectWindow( meindex, talkerindex, 6 ); + + }else if(atoi(data)==6){ + if(NPC_PetHealerCheck( talkerindex)==TRUE){ + NPC_WindowHealer_selectWindow( meindex, talkerindex, 9 ); + }else{ + NPC_WindowHealer_selectWindow( meindex, talkerindex, 10 ); + } + }else if(select==WINDOW_BUTTONTYPE_CANCEL){ + } + break; + + + case CHAR_WINDOWTYPE_WINDOWHEALER_HPMSG: + if(select==WINDOW_BUTTONTYPE_OK){ + NPC_WindowHealer_selectWindow( meindex, talkerindex, 0 ); + + }else if(select==WINDOW_BUTTONTYPE_YES){ + /*--ż--*/ + if(NPC_WindowMoneyCheck(meindex,talkerindex,1)==TRUE){ + NPC_WindowHealer_selectWindow( meindex, talkerindex, 3 ); + }else{ + NPC_WindowHealer_selectWindow( meindex, talkerindex, 8 ); + } + }else if(select==WINDOW_BUTTONTYPE_NO){ + NPC_WindowHealer_selectWindow( meindex, talkerindex, 0 ); + + } + break; + + + case CHAR_WINDOWTYPE_WINDOWHEALER_SPIRITMSG: + if(select==WINDOW_BUTTONTYPE_OK){ + NPC_WindowHealer_selectWindow( meindex, talkerindex, 0 ); + + }else if(select==WINDOW_BUTTONTYPE_YES){ + /*--ż--*/ + if(NPC_WindowMoneyCheck(meindex,talkerindex,2)==TRUE){ + NPC_WindowHealer_selectWindow( meindex, talkerindex, 4 ); + }else{ + NPC_WindowHealer_selectWindow( meindex, talkerindex, 8 ); + } + + }else if(select==WINDOW_BUTTONTYPE_NO){ + NPC_WindowHealer_selectWindow( meindex, talkerindex, 0 ); + } + + break; + + + case CHAR_WINDOWTYPE_WINDOWHEALER_OKHPMSG: + if(select==WINDOW_BUTTONTYPE_OK){ + NPC_WindowHealer_selectWindow( meindex, talkerindex, 0 ); + } + break; + + + case CHAR_WINDOWTYPE_WINDOWHEALER_OKSPIRITMSG: + if(select==WINDOW_BUTTONTYPE_OK){ + NPC_WindowHealer_selectWindow( meindex, talkerindex, 0 ); + } + break; + + + /*----*/ + case CHAR_WINDOWTYPE_WINDOWHEALER_ALLMSG: + if(select==WINDOW_BUTTONTYPE_OK){ + NPC_WindowHealer_selectWindow( meindex, talkerindex, 0 ); + + }else if(select==WINDOW_BUTTONTYPE_YES){ + if(NPC_WindowMoneyCheck(meindex,talkerindex,3)==TRUE){ + NPC_WindowHealer_selectWindow( meindex, talkerindex, 7 ); + }else{ + NPC_WindowHealer_selectWindow( meindex, talkerindex, 8 ); + } + + }else if(select==WINDOW_BUTTONTYPE_NO){ + NPC_WindowHealer_selectWindow( meindex, talkerindex, 0 ); + } + break; + + + /*--⼰--*/ + case CHAR_WINDOWTYPE_WINDOWHEALER_OKALLMSG: + if(select==WINDOW_BUTTONTYPE_YES){ + NPC_WindowHealer_selectWindow( meindex, talkerindex, 0 ); + } + break; + } + + if(select==WINDOW_BUTTONTYPE_CANCEL + && CHAR_getWorkInt( talkerindex, CHAR_WORKPARTYMODE ) == 2) + { + CHAR_sendWatchEvent( CHAR_getWorkInt( talkerindex, CHAR_WORKOBJINDEX), + CHAR_ACTPLEASURE,NULL,0,TRUE); + CHAR_setWorkInt( talkerindex, CHAR_WORKACTION, CHAR_ACTPLEASURE); + } + +} + + +BOOL NPC_PetHealerCheck(int talker) +{ + + int petindex; + int i; + + /*--ʸƥƻؤ--*/ + for(i=0;i CHAR_getInt(talker,CHAR_LV)){ + return TRUE; + } + + return FALSE; + +} + + +/*------------------------------------------- +¦ +talkerƽҷ̼͵ +---------------------------------------------*/ +BOOL NPC_WindowMoneyCheck(int meindex,int talker,int mode) +{ + int cost=0; + int level; + + level=CHAR_getWorkInt(meindex,CHAR_WORK_LEVEL); + + if(mode==1){ + if(level <= CHAR_getInt(talker,CHAR_LV)){ + /*---ëԻ---*/ + cost=NPC_WindowCostCheck(meindex,talker); + /*--ػɬ---*/ + /*---ŻԻ¾---*/ + if(CHAR_getInt(talker,CHAR_GOLD) < cost){ + return FALSE; + + } + CHAR_DelGold( talker, cost); + } + } + if(mode==2){ + if(level <= CHAR_getInt(talker,CHAR_LV)){ + /*---ëԻ---*/ + cost=NPC_WindowCostCheckMp(meindex,talker); + + /*--ػɬ---*/ + /*---ŻԻ¾---*/ + if(CHAR_getInt(talker,CHAR_GOLD) < cost){ + return FALSE; + } + CHAR_DelGold( talker, cost); + } + } + + if(mode==3){ + if(level <= CHAR_getInt(talker,CHAR_LV)){ + + if( CHAR_getInt(talker,CHAR_HP) +#include "char.h" +#include "object.h" +#include "char_base.h" +#include "npcutil.h" +#include "configfile.h" +#include "lssproto_serv.h" +#include "npc_windowman.h" + +struct { + int windowno; + int windowtype; + int buttontype; + int takeitem; + int giveitem; + char message[4096]; +}w; + +struct { + BOOL use; + int checkhaveitem; + int checkhaveitemgotowin; + int checkdonthaveitem; + int checkdonthaveitemgotowin; + int warp; + int battle; + int gotowin; +}buttonproc[13]; /* ok,cancel, yes,no,prev,next ݼ */ + + + + + +enum { + CHAR_WORK_MSGCOLOR = CHAR_NPCWORKINT1, +}; +//static void NPC_Windowman_selectWindow( int meindex, int toindex, int num); +//static BOOL NPC_Windowman_readData( int meindex, int windowno, BOOL chkflg); +//static int NPC_Windowman_restoreButtontype( char *data ); + +/********************************* +*********************************/ +BOOL NPC_WindowmanInit( int meindex ) +{ + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + char buf[1024]; + //int i; + //char secondToken[1024]; + + + NPC_Util_GetArgStr( meindex, argstr, sizeof( argstr)); + + if( NPC_Util_GetStrFromStrWithDelim( argstr, "conff", buf, sizeof( buf)) + == NULL ) + { + print( "windowman:ûָ趨ĵ \n"); + return FALSE; + } + /* ݱɬ÷ëƻ֧ */ + if( !NPC_Windowman_readData( meindex, -1, TRUE) ) { + return FALSE; + } + + CHAR_setInt( meindex , CHAR_WHICHTYPE , CHAR_TYPEWINDOWMAN ); + + return TRUE; +} + + + + +/********************************* +*********************************/ +void NPC_WindowmanTalked( int meindex , int talkerindex , char *szMes ,int color ) +{ + + NPC_Windowman_selectWindow( meindex, talkerindex, 1 ); + +} +/********************************* +*********************************/ +void NPC_WindowmanLooked( int meindex , int lookedindex) +{ + + NPC_Windowman_selectWindow( meindex, lookedindex,1 ); + +} + +/*static*/ void NPC_Windowman_selectWindow( int meindex, int toindex, int num) +{ + + int fd; + char buf[256]; + + if( CHAR_getInt( toindex , CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER ) { + return; + } + if( !NPC_Util_charIsInFrontOfChar( toindex, meindex, 1 )) return; + + if( !NPC_Windowman_readData( meindex, num, FALSE) ) { + print( "windowman:readdata error\n"); + return; + } + + fd = getfdFromCharaIndex( toindex); + if( fd != -1 ) { + lssproto_WN_send( fd, w.windowtype, + w.buttontype, + w.windowno+100, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + makeEscapeString( w.message, buf, sizeof(buf))); + } +} +void NPC_WindowmanWindowTalked( int meindex, int talkerindex, + int seqno, int select, char *data) + +{ + int button = -1; + char buf[256]; + if( NPC_Util_CharDistance( talkerindex, meindex ) > 1) return; + + if( !NPC_Windowman_readData( meindex, seqno - 100, FALSE) ) { + print( "windowman:readdata error\n"); + return; + } + if( w.windowtype == WINDOW_MESSAGETYPE_SELECT ) { + button = atoi( data)+5; + if( button > 12 ) { + print( "windowman:invalid button[%d]\n", button); + return; + } + } + else if( select & WINDOW_BUTTONTYPE_OK) button = 0; + else if( select & WINDOW_BUTTONTYPE_CANCEL) button = 1; + else if( select & WINDOW_BUTTONTYPE_YES) button = 2; + else if( select & WINDOW_BUTTONTYPE_NO) button = 3; + else if( select & WINDOW_BUTTONTYPE_PREV) button = 4; + else if( select & WINDOW_BUTTONTYPE_NEXT) button = 5; + else { + print( "windowman:invalid button[%d]\n", select); + return; + } + if( buttonproc[button].use == TRUE ) { + int i; + int fd; + int newwin = -1; + if( buttonproc[button].checkhaveitem != -1 ) { + for( i = 0; i < CHAR_MAXITEMHAVE; i ++ ) { + int itemindex = CHAR_getItemIndex( talkerindex, i); + if( ITEM_CHECKINDEX( itemindex)) { + if( ITEM_getInt( itemindex, ITEM_ID) + == buttonproc[button].checkhaveitem ) + { + break; + } + } + } + if( i == CHAR_MAXITEMHAVE ) { + return; + } + newwin = buttonproc[button].checkhaveitemgotowin; + } + if( buttonproc[button].checkdonthaveitem != -1 ) { + for( i = 0; i < CHAR_MAXITEMHAVE; i ++ ) { + int itemindex = CHAR_getItemIndex( talkerindex, i); + if( ITEM_CHECKINDEX( itemindex)) { + if( ITEM_getInt( itemindex, ITEM_ID) + == buttonproc[button].checkdonthaveitem ) + { + break; + } + } + } + if( i != CHAR_MAXITEMHAVE ) { + return; + } + newwin = buttonproc[button].checkdonthaveitemgotowin; + } + + if( newwin == -1 ) { + newwin = buttonproc[button].gotowin; + } + if( !NPC_Windowman_readData( meindex, newwin, FALSE) ) { + print( "windowman:readdata error\n"); + return; + } + fd = getfdFromCharaIndex( talkerindex); + if( fd != -1 ) { + lssproto_WN_send( fd, w.windowtype, + w.buttontype, + w.windowno+100, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + makeEscapeString( w.message, buf, sizeof(buf))); + } + } +} + +BOOL NPC_Windowman_readData( int meindex, int windowno, BOOL chkflg) +{ + + int i; + int linenum = 0; + int endflg = FALSE; + int buttonendflg; + int winno = -1; + int buttonconfmode; + int b_mode; + int selectnum ; + int messagepos; + BOOL errflg = FALSE; + BOOL readflg = TRUE; + FILE *fp; + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + char filename[64]; + char opfile[128]; + char line[1024]; + char firstToken[1024]; + char secondToken[1024]; + + + NPC_Util_GetArgStr( meindex, argstr, sizeof( argstr)); + if( NPC_Util_GetStrFromStrWithDelim( argstr, "conff", filename, sizeof( filename)) == NULL ) { + print("\n err:NOT FIND [conff] "); + return FALSE; + } + + sprintf( opfile, "%s/", getNpcdir( ) ); + strcat( opfile, filename); + + fp = fopen( opfile, "r"); + if( fp == NULL ) { + print( "windowman:file open error [%s]\n", opfile); + return FALSE; + } + + while( readflg == TRUE ) { + endflg = FALSE; + buttonendflg = TRUE; + buttonconfmode = FALSE; + selectnum = 0; + messagepos = 0; + winno = -1; + b_mode = -1; + errflg = FALSE; + + /* */ + w.windowno = -1; + w.windowtype = -1; + w.buttontype = -1; + w.takeitem = -1; + w.giveitem = -1; + w.message[0] = '\0'; + + for( i = 0; i < arraysizeof( buttonproc); i ++ ) { + buttonproc[i].use = FALSE; + buttonproc[i].checkhaveitem = -1; + buttonproc[i].checkhaveitemgotowin = -1; + buttonproc[i].checkdonthaveitem = -1; + buttonproc[i].checkdonthaveitemgotowin = -1; + buttonproc[i].warp = -1; + buttonproc[i].battle = -1; + buttonproc[i].gotowin = -1; + } + + while( 1) { + char buf[256]; + int ret; + if( !fgets( line, sizeof( line), fp)){ + readflg = FALSE; + break; + } + + linenum ++; + + if( line[0] == '#' || line[0] == '\n') continue; + /* ݱ */ + chomp( line ); + + /* ë */ + replaceString( line, '\t' , ' ' ); + for( i = 0; i < strlen( line); i ++) { + if( line[i] != ' ' ) { + break; + } + strcpy( buf, &line[i]); + } + if( i != 0 ) strcpy( line, buf); + + ret = getStringFromIndexWithDelim( line, "=", 1, firstToken, + sizeof( firstToken ) ); + if( ret == FALSE ){ + print( "Find error at %s in line %d. Ignore\n", + filename , linenum); + continue; + } + ret = getStringFromIndexWithDelim( line, "=", 2, secondToken, + sizeof( secondToken ) ); + if( ret == FALSE ){ + print( "Find error at %s in line %d. Ignore\n", + filename , linenum); + continue; + } + + if( strcasecmp( firstToken, "winno") == 0 ) { + if( winno != -1 ) { + print( "windowman:winnoȴ¶winno\n"); + print( "filename:[%s] line[%d]\n", filename, linenum); + errflg = TRUE; + readflg = FALSE; + break; + } + /* ūNoë */ + winno = atoi( secondToken); + continue; + } + if( winno == -1 ) { + print( "windowman:winno δ壬ȴ趨\n"); + print( "filename:[%s] line[%d]\n", filename, linenum); + readflg = FALSE; + errflg = FALSE; + break; + } + if( (chkflg == FALSE && winno == windowno )|| + chkflg == TRUE) + { + if( buttonconfmode == TRUE ) { + if( strcasecmp( firstToken, "gotowin") == 0 ) { + buttonproc[b_mode].gotowin = atoi( secondToken); + } + else if( strcasecmp( firstToken, "checkhaveitem") == 0 ) { + buttonproc[b_mode].checkhaveitem = atoi( secondToken); + } + else if( strcasecmp( firstToken, "haveitemgotowin") == 0 ) { + buttonproc[b_mode].checkhaveitemgotowin = atoi( secondToken); + } + else if( strcasecmp( firstToken, "checkdonthaveitem") == 0 ) { + buttonproc[b_mode].checkdonthaveitem = atoi( secondToken); + } + else if( strcasecmp( firstToken, "donthaveitemgotowin") == 0 ) { + buttonproc[b_mode].checkdonthaveitemgotowin = atoi( secondToken); + } + else if( strcasecmp( firstToken, "endbutton") == 0 ) { + if( buttonproc[b_mode].gotowin == - 1 ) { + if( buttonproc[b_mode].checkhaveitem == -1 && + buttonproc[b_mode].checkdonthaveitem == -1) + { + errflg = TRUE; + } + else { + if( !((buttonproc[b_mode].checkhaveitem != -1 && + buttonproc[b_mode].checkhaveitemgotowin != -1) + || (buttonproc[b_mode].checkdonthaveitem != -1 && + buttonproc[b_mode].checkdonthaveitemgotowin != -1))) + { + errflg = TRUE; + } + } + } + + if( errflg == TRUE) { + print( "windowman: Ҳgotowin\n"); + print( "filename:[%s] line[%d]\n", filename, linenum); + readflg = FALSE; + errflg = TRUE; + break; + } + buttonproc[b_mode].use = TRUE; + buttonconfmode = FALSE; + buttonendflg = TRUE; + } + } + else { + + w.windowno = winno; + /* ūɬ */ + if( strcasecmp( firstToken, "wintype") == 0 ) { + w.windowtype = atoi( secondToken); + } + /* ʾɬ */ + else if( strcasecmp( firstToken, "buttontype") == 0 ) { + w.buttontype = NPC_Windowman_restoreButtontype( secondToken); + } + /* getitemɬ */ + else if( strcasecmp( firstToken, "takeitem") == 0 ) { + w.takeitem = atoi( secondToken); + } + /* giveitemɬ */ + else if( strcasecmp( firstToken, "giveitem") == 0 ) { + w.giveitem = atoi( secondToken); + } + /* messageɬ */ + else if( strcasecmp( firstToken, "message") == 0 ) { + if( messagepos == 0 ) { + strcpy( w.message, secondToken); + messagepos = strlen( w.message); + } + else { + w.message[messagepos]='\n'; + messagepos++; + strcpy( &w.message[messagepos], secondToken); + messagepos+=strlen(secondToken); + } + } + /* ʾëݼɬ */ + else if( strcasecmp( firstToken, "okpressed") == 0 ) { + buttonconfmode = TRUE; + b_mode = 0; + buttonendflg = FALSE; + } + else if( strcasecmp( firstToken, "cancelpressed") == 0 ) { + buttonconfmode = TRUE; + b_mode = 1; + buttonendflg = FALSE; + } + else if( strcasecmp( firstToken, "yespressed") == 0 ) { + buttonconfmode = TRUE; + b_mode = 2; + buttonendflg = FALSE; + } + else if( strcasecmp( firstToken, "nopressed") == 0 ) { + buttonconfmode = TRUE; + b_mode = 3; + buttonendflg = FALSE; + } + else if( strcasecmp( firstToken, "prevpressed") == 0 ) { + buttonconfmode = TRUE; + b_mode = 4; + buttonendflg = FALSE; + } + else if( strcasecmp( firstToken, "nextpressed") == 0 ) { + buttonconfmode = TRUE; + b_mode = 5; + buttonendflg = FALSE; + } + else if( strcasecmp( firstToken, "selected") == 0 ) { + buttonconfmode = TRUE; + b_mode = 6 + selectnum; + buttonendflg = FALSE; + selectnum ++; + } + /* ɬñδԻ */ + else if( strcasecmp( firstToken, "endwin") == 0 ) { + endflg = TRUE; + if( chkflg == FALSE) { + readflg = FALSE; + } + break; + } + else { + print( "windowman:趨DzܵIJ\n"); + print( "filename:[%s] line[%d]\n", filename, linenum); + } + } + } + else { + if( strcasecmp( firstToken, "endwin") == 0 ) { + winno = -1; + } + } + } + if( buttonendflg == FALSE) { + print( "windowman: Ҳendbutton\n"); + print( "filename:[%s] line[%d]\n", filename, linenum); + errflg = TRUE; + break; + } + if( winno != -1 ) { + if( w.windowtype == -1 ) { + print( "windowman: Ҳwintype\n"); + print( "filename:[%s] line[%d]\n", filename, linenum); + errflg = TRUE; + break; + } + if( w.buttontype == -1 ) { + print( "windowman: Ҳbutton\n"); + print( "filename:[%s] line[%d]\n", filename, linenum); + errflg = TRUE; + break; + } + if( strlen( w.message) == 0 ) { + print( "windowman: Ҳmessage\n"); + print( "filename:[%s] line[%d]\n", filename, linenum); + errflg = TRUE; + break; + } + } + } + fclose( fp); + + if( chkflg == FALSE && w.windowno == -1 ) { + print( "windowman: Ҳָwindowno\n"); + print( "filename:[%s] line[%d]\n", filename, linenum); + return FALSE; + } + if( winno != -1 && endflg == FALSE) { + print( "windowman: Ҳendwin\n"); + print( "filename:[%s] line[%d]\n", filename, linenum); + return FALSE; + } + if( errflg == TRUE) return FALSE; + + return TRUE; +} +/* + * + */ +/*static*/ int NPC_Windowman_restoreButtontype( char *data ) +{ + int ret = 0; + int rc; + int i; + char buff[1024]; + + for( i = 1; ; i ++ ) { + rc = getStringFromIndexWithDelim( data, "|", i, buff, + sizeof( buff ) ); + if( rc == FALSE) break; + if( strcasecmp( buff, "ok") == 0 ) { + ret |= WINDOW_BUTTONTYPE_OK; + } + else if( strcasecmp( buff, "cancel") == 0 ) { + ret |= WINDOW_BUTTONTYPE_CANCEL; + } + else if( strcasecmp( buff, "yes") == 0 ) { + ret |= WINDOW_BUTTONTYPE_YES; + } + else if( strcasecmp( buff, "no") == 0 ) { + ret |= WINDOW_BUTTONTYPE_NO; + } + else if( strcasecmp( buff, "prev") == 0 ) { + ret |= WINDOW_BUTTONTYPE_PREV; + } + else if( strcasecmp( buff, "next") == 0 ) { + ret |= WINDOW_BUTTONTYPE_NEXT; + } + } + if( ret == 0 ) { + ret = atoi( data); + } + return ret; +} diff --git a/npc/npccreate.c b/npc/npccreate.c new file mode 100644 index 0000000..7a916f4 --- /dev/null +++ b/npc/npccreate.c @@ -0,0 +1,613 @@ +#include "version.h" +#define __NPCCREATE__ + +#include +#include + +#include "common.h" +#include "npccreate.h" +#include "npctemplate.h" +#include "util.h" +#include "buf.h" +#include "readmap.h" +#include "char_data.h" +#include "handletime.h" +#include "configfile.h" + +INLINE int NPC_CHECKCREATEINDEX(int index) +{ + if( NPC_createnum <= index || index < 0 )return FALSE; + return TRUE; +} + +INLINE int NPC_CHECKCREATEINTINDEX( int index) +{ + if( NPC_CREATEINTNUM <= index || index < 0 )return FALSE; + return TRUE; +} + +INLINE int NPC_setCreateInt( int index , NPC_CREATEINT element, int data ) +{ + int buf; + buf = NPC_create[index].intdata[element]; + NPC_create[index].intdata[element] = data; + return buf; +} + +INLINE int NPC_getCreateInt( int index , NPC_CREATEINT element ) +{ + return NPC_create[index].intdata[element]; +} + + +BOOL NPC_initCreateArray( int createnum ) +{ + NPC_createnum = createnum; + NPC_create = (NPC_Create*)allocateMemory( sizeof( NPC_Create ) * NPC_createnum ); + + print( "С:%d. :%d.\n", sizeof( NPC_Create ), createnum); + if( NPC_create == NULL ){ + return FALSE; + } + NPC_create_readindex = 0; + return TRUE; +} + +void NPC_setDefaultNPCCreate( NPC_Create* cr ) +{ + if( cr == NULL )return; + + cr->intdata[NPC_CREATEFLOORID]=0; + cr->intdata[NPC_CREATEBORNLEFTUPX]=0; + cr->intdata[NPC_CREATEBORNLEFTUPY]=0; + cr->intdata[NPC_CREATEBORNRIGHTDOWNX]=0; + cr->intdata[NPC_CREATEBORNRIGHTDOWNY]=0; + cr->intdata[NPC_CREATEMOVELEFTUPX]=0; + cr->intdata[NPC_CREATEMOVELEFTUPY]=0; + cr->intdata[NPC_CREATEMOVERIGHTDOWNX]=0; + cr->intdata[NPC_CREATEMOVERIGHTDOWNY]=0; + + cr->intdata[NPC_CREATEDIR]=0; + //jeffrey 1231 +#ifdef _ADD_ACTION + cr->intdata[NPC_CREATEACTION] = 0; +#endif + cr->intdata[NPC_CREATEBASEIMAGENUMBER]=-1; + cr->intdata[NPC_CREATETIME]=0; + cr->intdata[NPC_CREATEBORNNUM]=0; + cr->intdata[NPC_CREATEENEMYNUM]=0; + cr->intdata[NPC_CREATEBOUNDARY]=1; + cr->intdata[NPC_CREATEIGNOREINVINCIBLE]=0; + + cr->intdata[NPC_CREATEDATE]=0; + + cr->intdata[NPC_CREATEFAMILY]=0; + + cr->chardata[NPC_CREATENAME].string[0]= '\0'; + + cr->workdata[NPC_CREATEWORKENEMYNUM]=0; + cr->workdata[NPC_CREATEWORKMAKESTARTSEC]=0; + cr->workdata[NPC_CREATEWORKMAKESTARTUSEC]=0; + cr->workdata[NPC_CREATEWORKNEVERMAKE]=0; + + + { + int i; + for( i=0 ; itemplateindex) ; i++ ){ + cr->templateindex[i] = -1; + cr->arg[i].string[0] = '\0'; + } + } +} + +BOOL NPC_IsNPCCreateFile( char* filename ) +{ + FILE* f; + char line1[128]; + char* ret; + + /* ~ƥ°̻ﷴئƱ */ + if( filename == NULL + || strlen( filename ) < 1 + || filename[strlen(filename)-1] == '~' + || filename[0] == '#' + || strcmptail( filename, ".bak" ) == 0 )return FALSE; + + f= fopen( filename , "r" ); + if( f == NULL ) goto RETURNFALSE; + + ret = fgets( line1, sizeof( line1 ), f ); + if( ret == NULL )goto FCLOSERETURNFALSE; + + if( strcasecmp( NPC_CREATEFILEMAGIC, line1 ) == 0 ){ + fclose(f); + return TRUE; + } + +FCLOSERETURNFALSE: + fclose(f); +RETURNFALSE: + return FALSE; +} + +static int NPC_readCreateFile( char* filename ) +{ + FILE* f; + char line[512]; + int linenum=0; + int start=OFF; + NPC_Create cr; + int enemyreadindex=0; + + typedef struct tagPOINT + { + int x,y; + }POINT; + typedef struct tagREC + { + int w,h; + }REC; + POINT center[2]={{0,0},{0,0}}; /* born 0 ƥ move 1 */ + REC wh[2] ={{0,0},{0,0}}; /* born 0 ƥ move 1 */ + + POINT lu[2] ={{0,0},{0,0}}; /* born 0 ƥ move 1 */ + POINT rd[2] ={{0,0},{0,0}}; /* born 0 ƥ move 1 */ + + int defborn=FALSE; /* born ëɬ׾ */ + int defmove=FALSE; /* move ëɬ׾ */ + int deflurd[2]={FALSE,FALSE}; /* lu,rd ƥɬ׾ */ + char* ret; + + + if( NPC_create_readindex >= NPC_createnum ){ + print("û\n" ); + print("ûĿ %d\n",NPC_createnum); + print("ûļ %s\n",filename); + return FALSE; + } + + NPC_setDefaultNPCCreate( &cr ); + + f= fopen( filename ,"r"); + if( f == NULL )return FALSE; + + ret = fgets( line, sizeof( line ), f ); + if( ret == NULL )goto FCLOSERETURNFALSE; + if( strcmp( NPC_CREATEFILEMAGIC, line ) != 0 ){ + print( "ⲻһcreateļ.\n" ); + goto FCLOSERETURNFALSE; + } + linenum = 1; + + while( fgets( line , sizeof( line ) , f ) ){ + + linenum++; + + if( line[0] == '#' )continue; /* comment */ + if( line[0] == '\n' )continue; /* none */ + chomp( line ); + + switch( line[0] ){ + case '{': + if( start == ON ){ + fprint( "Find {. But already START state. %s:%d\n", + filename, linenum); + fprint( "˳\n" ); + goto FCLOSERETURNFALSE; + + }else{ + NPC_setDefaultNPCCreate( &cr ); + start = ON; + } + break; + case '}': + if( start == ON ){ + int err = FALSE; + if( enemyreadindex == 0 ){ + err = TRUE; + print( "ⲻ %s:%d\n", + filename,linenum); + }else if( MAP_IsThereSpecificFloorid( + cr.intdata[NPC_CREATEFLOORID]) == FALSE ){ + err = TRUE; + print( "ͼIDë %s:%d-floor:%d\n", + filename,linenum, cr.intdata[NPC_CREATEFLOORID]); + }else if( defborn == FALSE ){ + err = TRUE; + print( "Щ born װ %s:%d\n", + filename,linenum); + } + + if( err == FALSE ){ + cr.intdata[NPC_CREATEENEMYNUM] = enemyreadindex; + + if( deflurd[0] ){ + cr.intdata[NPC_CREATEBORNLEFTUPX] = + min(lu[0].x,rd[0].x); + cr.intdata[NPC_CREATEBORNRIGHTDOWNX] = + max(lu[0].x,rd[0].x); + cr.intdata[NPC_CREATEBORNLEFTUPY] = + min(lu[0].y,rd[0].y); + cr.intdata[NPC_CREATEBORNRIGHTDOWNY] = + max(lu[0].y,rd[0].y); + }else{ + cr.intdata[NPC_CREATEBORNLEFTUPX] = + center[0].x-wh[0].w/2; + cr.intdata[NPC_CREATEBORNRIGHTDOWNX] = + center[0].x+wh[0].w/2; + cr.intdata[NPC_CREATEBORNLEFTUPY] = + center[0].y-wh[0].h/2; + cr.intdata[NPC_CREATEBORNRIGHTDOWNY] = + center[0].y+wh[0].h/2; + } + if( defmove ){ + if( deflurd[0] ){ + cr.intdata[NPC_CREATEMOVELEFTUPX] = + min(lu[1].x,rd[1].x); + cr.intdata[NPC_CREATEMOVERIGHTDOWNX] = + max(lu[1].x,rd[1].x); + cr.intdata[NPC_CREATEMOVELEFTUPY] = + min(lu[1].y,rd[1].y); + cr.intdata[NPC_CREATEMOVERIGHTDOWNY] = + max(lu[1].y,rd[1].y); + }else{ + cr.intdata[NPC_CREATEMOVELEFTUPX] = + center[1].x-wh[1].w/2; + cr.intdata[NPC_CREATEMOVERIGHTDOWNX] = + center[1].x+wh[1].w/2; + cr.intdata[NPC_CREATEMOVELEFTUPY] = + center[1].y-wh[1].h/2; + cr.intdata[NPC_CREATEMOVERIGHTDOWNY] = + center[1].y+wh[1].h/2; + } + + }else{ + /* born ë */ + cr.intdata[NPC_CREATEMOVELEFTUPX] = + cr.intdata[NPC_CREATEBORNLEFTUPX]; + cr.intdata[NPC_CREATEMOVERIGHTDOWNX] = + cr.intdata[NPC_CREATEBORNRIGHTDOWNX]; + cr.intdata[NPC_CREATEMOVELEFTUPY] = + cr.intdata[NPC_CREATEBORNLEFTUPY]; + cr.intdata[NPC_CREATEMOVERIGHTDOWNY] = + cr.intdata[NPC_CREATEBORNRIGHTDOWNY]; + } + + memcpy( &NPC_create[NPC_create_readindex], &cr, + sizeof( NPC_Create ) ); + + + NPC_create_readindex++; + + if( NPC_create_readindex >= NPC_createnum ){ + print("û\n" ); + print("ôļĿ %d\n", + NPC_createnum); + print("ûļ:%s\n",filename); + goto FCLOSERETURNFALSE; + } + + } + NPC_setDefaultNPCCreate( &cr ); + enemyreadindex=0; + defborn=FALSE; + defmove=FALSE; + deflurd[0]=FALSE; + deflurd[1]=FALSE; + + start = OFF; + }else{ + fprint( "δ '}' at %s:%d\n",filename,linenum); + goto FCLOSERETURNFALSE; + } + break; + default: + { + + char firstToken[256]; + char secondToken[256]; + int ret; + ret = getStringFromIndexWithDelim( line, "=", 1, firstToken, + sizeof( firstToken ) ); + if( ret == FALSE ){ + print( "Find error at %s in line %d. Ignore\n", + filename , linenum); + break; + } + ret = getStringFromIndexWithDelim( line, "=", 2, secondToken, + sizeof( secondToken ) ); + if( ret == FALSE ){ + print( "Find error at %s in line %d. Ignore\n", + filename , linenum); + break; + } + + if( strcasecmp("floorid",firstToken) == 0 ){ + cr.intdata[NPC_CREATEFLOORID] = atoi(secondToken); + + }else if( strcasecmp("borncenter", firstToken) == 0 ){ + getFourIntsFromString(secondToken,¢er[0].x, + ¢er[0].y,&wh[0].w,&wh[0].h ); + defborn = TRUE; + }else if( strcasecmp("borncorner", firstToken) == 0 ){ + getFourIntsFromString(secondToken,&lu[0].x,&lu[0].y, + &rd[0].x,&rd[0].y ); + defborn = TRUE; + deflurd[0]=TRUE; + + }else if( strcasecmp("movecenter", firstToken) == 0 ){ + getFourIntsFromString(secondToken,¢er[1].x, + ¢er[1].y,&wh[1].w,&wh[1].h ); + defmove = TRUE; + }else if( strcasecmp("movecorner", firstToken) == 0 ){ + getFourIntsFromString(secondToken,&lu[1].x,&lu[1].y, + &rd[1].x,&rd[1].y ); + defmove = TRUE; + deflurd[1]=TRUE; + + }else if( strcasecmp("dir",firstToken) == 0 ){ + cr.intdata[NPC_CREATEDIR] = atoi( secondToken ); + + }else if( strcasecmp("graphicname",firstToken) == 0 ){ + cr.intdata[NPC_CREATEBASEIMAGENUMBER] + = CHAR_seekGraphicNumberFromString(secondToken); + + }else if( strcasecmp("name",firstToken) == 0 ){ + strcpysafe( cr.chardata[NPC_CREATENAME].string, + sizeof(cr.chardata[NPC_CREATENAME].string), + secondToken ); + + }else if( strcasecmp("time",firstToken) == 0 ){ + cr.intdata[NPC_CREATETIME] = atoi( secondToken ); + + }else if( strcasecmp("date",firstToken) == 0 ){ + cr.intdata[NPC_CREATEDATE] = atoi( secondToken ); + + }else if( strcasecmp("createnum",firstToken) == 0 ){ + cr.intdata[NPC_CREATEBORNNUM] = atoi( secondToken ); + + }else if( strcasecmp( "boundary", firstToken) == 0 ){ + cr.intdata[NPC_CREATEBOUNDARY] = atoi( secondToken ); + + }else if( strcasecmp( "ignoreinvincible", firstToken) == 0 ){ + cr.intdata[NPC_CREATEIGNOREINVINCIBLE] = atoi( secondToken ); + + //jeffrey 1231 +#ifdef _ADD_ACTION + }else if( strcasecmp( "action", firstToken) == 0 ){ + cr.intdata[NPC_CREATEACTION] = atoi( secondToken ); +#endif + // Robin 0731 + }else if( strcasecmp( "family", firstToken) == 0 ){ + cr.intdata[NPC_CREATEFAMILY] = atoi( secondToken ); + + }else if( strcasecmp("enemy", firstToken) == 0 ){ + int templateindex; + char enemyname[64]; + + /* ˲ */ + if( enemyreadindex <= arraysizeof(cr.templateindex) ) + /* OK */ + ; + else + break; + + getStringFromIndexWithDelim(secondToken,"|",1,enemyname, + sizeof(enemyname) ); + templateindex= NPC_templateGetTemplateIndex(enemyname); + if( templateindex != -1 ){ + cr.templateindex[enemyreadindex] = templateindex; + { + char tmp[2]; + int ret; + ret = getStringFromIndexWithDelim( secondToken, + "|",2,tmp, + sizeof(tmp) ); + if( ret == FALSE ) + cr.arg[enemyreadindex].string[0] = '\0'; + else + strcpysafe( cr.arg[enemyreadindex].string, + sizeof( cr.arg[enemyreadindex]. + string ), + secondToken+strlen(enemyname)+1 ); + } + enemyreadindex++; + }else + fprint( "ûģ:\n[%s(%d)%s] enemy:%s\n", + filename ,linenum,secondToken, enemyname); + }else{ + fprint( "ûֵ½ %s %s:%d\n",firstToken,filename, + linenum ); + } + } + } + } + + fclose(f); + return TRUE; + +FCLOSERETURNFALSE: + fclose(f); + return FALSE; +} + +BOOL NPC_readNPCCreateFiles( char* topdirectory ,int createsize) +{ + STRING64 *filenames; + int filenum; + int i; + filenames = (STRING64 *)allocateMemory( sizeof( STRING64 ) * + (int)getFilesearchnum( ) ); + if( filenames == NULL ){ + print( "ȡNPCļ... ڴ\n" ); + return FALSE; + } + filenum = rgetFileName( topdirectory ,filenames ,getFilesearchnum( ) ); + if( filenum == -1 ){ + freeMemory( filenames ); + return FALSE; + } + if( filenum >= getFilesearchnum( ) ){ + print( "ļĿʧ %d\n", getFilesearchnum( ) ); + while( 1 ); + } + if( !NPC_initCreateArray( createsize ) ){ + fprint( "\n" ); + freeMemory( filenames ); + return FALSE; + } + print( "ȡNPCļ..." ); + for( i = 0 ; i < filenum ; i ++ ) + if( NPC_IsNPCCreateFile( filenames[i].string )) + if( NPC_readCreateFile( filenames[i].string ) == -1 ) + break; + print( "ȷNPC %d ..." , NPC_create_readindex ); + NPC_createnum=NPC_create_readindex; +#ifdef DEBUG + /* 99/4/8 By Kawata csvֿƻ֧ */ + print( "Npc_Create's\n"); + for( i = 0 ; i < NPC_createnum ; i ++ ){ + int j; + /*print( "NPC_create[%d]:\n", i);*/ + print( "%d,", i); + for( j = 0 ; j < NPC_CREATECHARNUM ; j ++ ) + print("%s," , NPC_create[i].chardata[j].string ); + /*print( "\tIntdata\t" );*/ + for( j = 0 ; j < NPC_CREATEINTNUM ; j ++ ) + print("%d," , NPC_create[i].intdata[j] ); + /***print("\n" ); + print( "\tChardata\t" );***/ + for( j = 0 ; j < NPC_create[i].intdata[NPC_CREATEENEMYNUM]; j ++ ) + print("%d" , NPC_create[i].templateindex[j] ); + /*print("\n" );*/ + print("\n" ); + } +#endif /*DEBUG*/ + + freeMemory( filenames ); + return TRUE; +} + + + +/*------------------------------------------------------------ + * createindex boundary ɬýľ¾ëέ + * ¦ + * createindex int create̼͵ + * ߯Ի + * ɬýľ TRUE(1) + * ɬýľئ FALSE(0) + ------------------------------------------------------------*/ +BOOL NPC_isBoundarySet( int createindex ) +{ + if( NPC_CHECKCREATEINDEX(createindex) == FALSE )return FALSE; + return NPC_create[createindex].intdata[NPC_CREATEBOUNDARY]; +} +/*------------------------------------------------------------ + * ¦ + * r RECT* ëRECT ̼ + * ߯Ի + ------------------------------------------------------------*/ +BOOL NPC_createGetRECT( int createindex,RECT* r ) +{ + if( NPC_CHECKCREATEINDEX(createindex) == FALSE )return FALSE; + + r->x = NPC_create[createindex].intdata[NPC_CREATEMOVELEFTUPX]; + r->y = NPC_create[createindex].intdata[NPC_CREATEMOVELEFTUPY]; + r->width + = NPC_create[createindex].intdata[NPC_CREATEMOVERIGHTDOWNX] + - NPC_create[createindex].intdata[NPC_CREATEMOVELEFTUPX]; + r->height + = NPC_create[createindex].intdata[NPC_CREATEMOVERIGHTDOWNY] + - NPC_create[createindex].intdata[NPC_CREATEMOVELEFTUPY]; + return TRUE; +} + + + +/*------------------------------------------------------------ + * ¦ + * cindex int ̼͵ + * ߯Ի + * BOOL Ȼ TRUE(1) + * BOOL Ȼئ FALSE(0) + ------------------------------------------------------------*/ +BOOL NPC_createCheckGenerateFromTime( int cindex ) +{ + struct timeval old; + if( !NPC_CHECKCREATEINDEX(cindex) ) + return FALSE; + + if( NPC_create[cindex].workdata[NPC_CREATEWORKNEVERMAKE] ) + return FALSE; + + if( NPC_create[cindex].intdata[NPC_CREATEBORNNUM] + <= NPC_create[cindex].workdata[NPC_CREATEWORKENEMYNUM] ) + return FALSE; + + if( NPC_create[cindex].intdata[NPC_CREATETIME] < 0 )return FALSE; + old.tv_sec = NPC_create[cindex].workdata[NPC_CREATEWORKMAKESTARTSEC]; + old.tv_usec= NPC_create[cindex].workdata[NPC_CREATEWORKMAKESTARTUSEC]; + + if( time_diff_us( NowTime , old ) <= + NPC_create[cindex].intdata[NPC_CREATETIME]*1000 ) + return FALSE; + + return TRUE; +} + + + + +/*------------------------------------------------------------ + * ¦ + * tindex int ̼͵ + * ߯Ի + * ئ + ------------------------------------------------------------*/ +void NPC_createInitTime( int index ) +{ + /* DZئ׾հëɬ */ + NPC_create[index].workdata[NPC_CREATEWORKMAKESTARTSEC] = + NowTime.tv_sec; + NPC_create[index].workdata[NPC_CREATEWORKMAKESTARTUSEC] = + NowTime.tv_usec; +} +/*------------------------------------------------------------ + * ¦ + * index int ̼͵ + * ߯Ի + * ئ + ------------------------------------------------------------*/ +void NPC_createIncreaseEnemynum( int index ) +{ + if( !NPC_CHECKCREATEINDEX(index) )return; + NPC_create[index].workdata[NPC_CREATEWORKENEMYNUM] ++; +} +/*------------------------------------------------------------ + * ĻƥëӼ + * ¦ + * index int ̼͵ + * ߯Ի + * ئ + ------------------------------------------------------------*/ +void NPC_createDecreaseEnemynum( int index ) +{ + if( !NPC_CHECKCREATEINDEX(index) )return; + NPC_create[index].workdata[NPC_CREATEWORKENEMYNUM] --; +} +/*------------------------------------------------------------ + * ¦ + * index int ̼͵ + * ߯Ի + * TRUE:MAX FALSE:ਵ + ------------------------------------------------------------*/ +BOOL NPC_createCheckMaxEnemynum( int index ) +{ + + if( NPC_create[index].intdata[NPC_CREATEBORNNUM] + <= NPC_create[index].workdata[NPC_CREATEWORKENEMYNUM] ) + return TRUE; + else + return FALSE; +} diff --git a/npc/npcgen.c b/npc/npcgen.c new file mode 100644 index 0000000..a8619d1 --- /dev/null +++ b/npc/npcgen.c @@ -0,0 +1,379 @@ +#include "version.h" +#include + +#include "common.h" +#include "npccreate.h" +#include "npctemplate.h" +#include "char.h" +#include "char_data.h" +#include "buf.h" +#include "object.h" +#include "readmap.h" +#include "item.h" +#include "handletime.h" +#include "map_deal.h" + +typedef struct tagNPC_searchPoint +{ + int floor; + int x; + int y; +}NPC_searchPoint; + + +/* ϼNPCë¾ */ +#define NPC_CREATECHALLENGETIME 1 +int all_nosee = 0; /* ༰ݣ廯ë no_see */ +int all_nobody = 0; /* ༰ݣ廯ë no_body */ +int one_loop_born = 1; /* ƥ Ϸ oneloop_born */ + +/*------------------------------------------------------------ + * ëķë + * ¦ + * nobody int 1 ݷئݱ年 + * (л) + * (ݼ) + * ëئئ + * ߯Ի + * ľݷ TRUE + * ľئݷ FALSE + ------------------------------------------------------------*/ +static BOOL NPC_searchCreatePoint( NPC_Create* cr,int nobody,int nosee, + NPC_searchPoint* point, BOOL isflying ) +{ + int floor=cr->intdata[NPC_CREATEFLOORID]; + int x = cr->intdata[NPC_CREATEBORNLEFTUPX]; + int y = cr->intdata[NPC_CREATEBORNLEFTUPY]; + int width; + int height; + int area; + int loop; + BOOL ret = FALSE; + int i, j; + + width = cr->intdata[NPC_CREATEBORNRIGHTDOWNX] + - cr->intdata[NPC_CREATEBORNLEFTUPX] + 1; + height = cr->intdata[NPC_CREATEBORNRIGHTDOWNY] + - cr->intdata[NPC_CREATEBORNLEFTUPY] + 1; + area = width * height; + if( nobody == 0 && all_nobody == 0 ) { + BOOL found = FALSE; + for( i = x ; i <= x +width && found == FALSE; i ++ ) { + for( j = y; j <= y + height && found == FALSE; j ++ ) { + OBJECT object; + for( object = MAP_getTopObj( floor, i,j); + object; + object = NEXT_OBJECT(object) ) + { + int objindex = GET_OBJINDEX( object); + if( OBJECT_getType(objindex) == OBJTYPE_CHARA ){ + if( CHAR_getInt( OBJECT_getIndex(objindex), + CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER ) + { + found = TRUE; + break; + } + } + } + } + } + if( found == FALSE ) { + return( FALSE); + } + } + for( loop=0 ; loopintdata[NPC_CREATEIGNOREINVINCIBLE] == 0 + && CHAR_isInvincibleArea( floor,crx,cry ) ){ + continue; + } + if( nosee == 0 && all_nosee == 0 ) { + BOOL found = FALSE; + for( i = crx - CHAR_DEFAULTSEESIZ/2 ; + i <= crx +CHAR_DEFAULTSEESIZ/2 && found == FALSE ; i ++ ) + { + for( j = cry - CHAR_DEFAULTSEESIZ/2; + j <= cry + CHAR_DEFAULTSEESIZ/2 && found == FALSE; + j ++ ) + { + OBJECT object; + for( object = MAP_getTopObj( floor, i,j); + object; + object = NEXT_OBJECT(object) ) + { + int objindex = GET_OBJINDEX( object); + if( OBJECT_getType(objindex) == OBJTYPE_CHARA ){ + if( CHAR_getInt( OBJECT_getIndex(objindex), + CHAR_WHICHTYPE ) + == CHAR_TYPEPLAYER ) + { + found = TRUE; + break; + } + } + } + } + } + if( found == TRUE ){ + return FALSE; + } + } + if( MAP_walkAbleFromPoint( floor,crx,cry,isflying ) == TRUE ){ + point->floor = cr->intdata[NPC_CREATEFLOORID]; + point->x = crx; + point->y = cry; + ret = TRUE; + break; + }else{ + } + } + + return( ret ); +} + + +typedef struct tagNPC_Correspondfunction +{ + int template; + int ch; +}NPC_Correspondfunction; + +static NPC_Correspondfunction correspondfunction[]={ + { NPC_TEMPLATEINITFUNC, CHAR_INITFUNC }, + { NPC_TEMPLATEWALKPREFUNC, CHAR_WALKPREFUNC }, + { NPC_TEMPLATEWALKPOSTFUNC, CHAR_WALKPOSTFUNC }, + { NPC_TEMPLATEPREOVERFUNC, CHAR_PREOVERFUNC }, + { NPC_TEMPLATEPOSTOVERFUNC, CHAR_POSTOVERFUNC }, + { NPC_TEMPLATEWATCHFUNC, CHAR_WATCHFUNC }, + { NPC_TEMPLATELOOPFUNC, CHAR_LOOPFUNC }, + { NPC_TEMPLATETALKEDFUNC, CHAR_TALKEDFUNC }, + { NPC_TEMPLATEDYINGFUNC, CHAR_DYINGFUNC }, + { NPC_TEMPLATEPREATTACKEDFUNC,CHAR_PREATTACKEDFUNC }, + { NPC_TEMPLATEPOSTATTACKEDFUNC, CHAR_POSTATTACKEDFUNC }, + { NPC_TEMPLATEOFFFUNC, CHAR_OFFFUNC }, + { NPC_TEMPLATELOOKEDFUNC, CHAR_LOOKEDFUNC }, + { NPC_TEMPLATEITEMPUTFUNC, CHAR_ITEMPUTFUNC }, + { NPC_TEMPLATESPECIALTALKEDFUNC, CHAR_SPECIALTALKEDFUNC}, + { NPC_TEMPLATEWINDOWTALKEDFUNC, CHAR_WINDOWTALKEDFUNC}, +#ifdef _USER_CHARLOOPS + { NPC_TEMPLATELOOPFUNCTEMP1, CHAR_LOOPFUNCTEMP1}, + { NPC_TEMPLATELOOPFUNCTEMP2, CHAR_LOOPFUNCTEMP2}, + { NPC_TEMPLATEBATTLEPROPERTY, CHAR_BATTLEPROPERTY}, +#endif +}; +/*------------------------------------------------------------ + * + * ¦ + * ch Char* ƽҷ· + * ߯Ի + * ئ + ------------------------------------------------------------*/ +static void NPC_copyFunction( Char* ch, NPC_Template* temp ) +{ + int i; + for( i=0 ; ichardata[correspondfunction[i].template].string[0] != '\0' ) + strcpysafe( ch->charfunctable[correspondfunction[i].ch].string, + sizeof(ch->charfunctable[correspondfunction[i].ch].string), + temp->chardata[correspondfunction[i].template].string); +} + +static BOOL NPC_generateNPC( int createindex, int createtemplateindex ) +{ + Char one; + NPC_searchPoint sp; + int i; + NPC_Template* template; + NPC_Create* cr; + + if( NPC_CHECKCREATEINDEX(createindex) + && 0 <= createtemplateindex + && createtemplateindex < arraysizeof(NPC_create[createindex].templateindex ) + && NPC_CHECKTEMPLATEINDEX( NPC_create[createindex].templateindex[createtemplateindex])){ + cr = &NPC_create[createindex]; + template = &NPC_template[NPC_create[createindex]. + templateindex[createtemplateindex]]; + }else{ + return FALSE; + } + if( NPC_searchCreatePoint( cr, + template->intdata[NPC_TEMPLATEMAKEATNOBODY], + template->intdata[NPC_TEMPLATEMAKEATNOSEE], &sp, + template->intdata[NPC_TEMPLATEISFLYING]) == FALSE ){ + return FALSE; + } + if( CHAR_getDefaultChar( &one, template->intdata[NPC_TEMPLATETYPE] ) == FALSE ){ + return FALSE; + } + one.data[CHAR_FLOOR] = sp.floor; + one.data[CHAR_X] = sp.x; + one.data[CHAR_Y] = sp.y; + one.data[CHAR_DIR] = cr->intdata[NPC_CREATEDIR]; +#ifdef _ADD_ACTION + one.data[CHAR_ACTIONSTYLE] = cr->intdata[NPC_CREATEACTION]; +#endif + + one.data[CHAR_BASEBASEIMAGENUMBER] = one.data[CHAR_BASEIMAGENUMBER] + = template->intdata[NPC_TEMPLATEIMAGENUMBER]; + if( cr->intdata[NPC_CREATEBASEIMAGENUMBER] != -1 ) + one.data[CHAR_BASEBASEIMAGENUMBER] + = one.data[CHAR_BASEIMAGENUMBER] + = cr->intdata[NPC_CREATEBASEIMAGENUMBER]; + + strcpysafe(one.string[CHAR_NAME].string, + sizeof(one.string[CHAR_NAME].string), + template->chardata[NPC_TEMPLATECHARNAME].string); + + + if( cr->chardata[NPC_CREATENAME].string[0] != '\0' ){ + strcpysafe(one.string[CHAR_NAME].string, + sizeof(one.string[CHAR_NAME].string), + cr->chardata[NPC_CREATENAME].string); + } + + // Robin 0731 + one.data[CHAR_FMINDEX] = cr->intdata[NPC_CREATEFAMILY]; + NPC_copyFunctionSetToChar( template-> + intdata[NPC_TEMPLATEFUNCTIONINDEX], + &one ); + NPC_copyFunction( &one, template ); + one.data[CHAR_LOOPINTERVAL] = template-> + intdata[NPC_TEMPLATELOOPFUNCTIME]; + if( cr->arg[createtemplateindex].string[0] != '\0' ){ + strcpysafe( one.string[CHAR_NPCARGUMENT].string, + sizeof(one.string[CHAR_NPCARGUMENT].string), + cr->arg[createtemplateindex].string ); + }else{ + one.string[CHAR_NPCARGUMENT].string[0] = '\0'; + } + one.data[CHAR_WHICHTYPE] = CHAR_TYPEENEMY; + one.data[CHAR_NPCCREATEINDEX] = createindex; + { + static struct NPC_Paramtable + { + int templateindex; + int charadataindex; + }paramtbl[]={ + { NPC_TEMPLATEMINMP, CHAR_MAXMP }, + { NPC_TEMPLATEMINSTR, CHAR_STR }, + { NPC_TEMPLATEMINTOUGH, CHAR_TOUGH }, + + + }; + for( i=0 ; irandomdata[ + paramtbl[i].templateindex] ); + one.data[paramtbl[i].charadataindex] + = one.data[paramtbl[i].charadataindex] + + template->intdata[paramtbl[i].templateindex] + + randomvalue; + } + one.data[CHAR_MP] = one.data[CHAR_MAXMP]; + } + { + int itemindex=CHAR_STARTITEMARRAY; + for( i = 0 ; i < template->intdata[NPC_TEMPLATEITEMNUM] ; i ++ ){ + if( RAND(0,32767) <= template->haveitem[i].haverate ){ + if( template->haveitem[i].itemnumber == -1 + && template->haveitem[i].havenum > 0 ){ + int randomvalue = template->haveitem[i].havenum; + randomvalue *= (RAND(90,110))/100.0; + one.data[CHAR_GOLD] = min( CHAR_MAXGOLDHAVE, randomvalue ); + }else if( itemindex+i < CHAR_MAXITEMHAVE ){ + one.indexOfExistItems[itemindex+i] = + ITEM_makeItemAndRegist(template->haveitem[i] + .itemnumber); + } + } + } + } + + { + int charaindex; + int objindex; + Object obj; + charaindex = CHAR_initCharOneArray( &one ); + if( charaindex == -1 ){ + CHAR_endCharData( &one ); + return FALSE; + } + if( template->intdata[NPC_TEMPLATEISFLYING] ) + CHAR_setFlg(charaindex, CHAR_ISFLYING, 1 ); + + obj.type = OBJTYPE_CHARA; + obj.index= charaindex; + obj.x = CHAR_getInt(charaindex,CHAR_X); + obj.y = CHAR_getInt(charaindex,CHAR_Y); + obj.floor = CHAR_getInt(charaindex,CHAR_FLOOR); + objindex = initObjectOne( &obj ); + if( objindex == -1 ){ + CHAR_endCharOneArray( charaindex ); + return FALSE; + }else{ + } + CHAR_setWorkInt( charaindex,CHAR_WORKOBJINDEX,objindex ); + CHAR_setWorkInt( charaindex,CHAR_WORKNPCTYPE,1); +#ifdef _ADD_ACTION +//CHAR_WORKACTION + CHAR_setWorkInt( charaindex, CHAR_WORKACTION, + CHAR_getInt( charaindex, CHAR_ACTIONSTYLE ) ); + + CHAR_sendWatchEvent( objindex, CHAR_getWorkInt( charaindex, CHAR_WORKACTION) + ,NULL,0,TRUE); +#else + CHAR_sendWatchEvent(objindex,CHAR_ACTSTAND,NULL,0,TRUE); +#endif + CHAR_complianceParameter( charaindex ); + } + + return TRUE; +} + +void NPC_generateLoop( BOOL checkall ) +{ + int i,j; + int CreateOk=0; + int enemynum ; + static int createcount = 0; /* create ¾ */ + static struct timeval _store_npc_generateloop_time; + if( checkall == FALSE) { + if( time_diff_us( NowTime, _store_npc_generateloop_time ) < (1000*1000)){ + return; + } else { + _store_npc_generateloop_time = NowTime; + } + } + + for( i=0 ; i < NPC_createnum ; i++ ){ + if( createcount >= NPC_createnum ) createcount = 0; + enemynum = NPC_getCreateInt( createcount, NPC_CREATEENEMYNUM ); + for( j = 0 ; j < enemynum ; j ++ ){ + if( NPC_createCheckGenerateFromTime(createcount) == TRUE ){ + CreateOk ++; + NPC_createInitTime(createcount); + if( NPC_generateNPC(createcount,j) == TRUE ){ + NPC_createIncreaseEnemynum(createcount); + }else{ + } + } + } + createcount ++; + if( checkall == FALSE && CreateOk >= one_loop_born ){ + break; + } + } +} + diff --git a/npc/npctemplate.c b/npc/npctemplate.c new file mode 100644 index 0000000..8330135 --- /dev/null +++ b/npc/npctemplate.c @@ -0,0 +1,1117 @@ +#include "version.h" +#define __NPCTEMPLATE__ + +#include +#include + +#include "common.h" +#include "npctemplate.h" +#include "buf.h" +#include "char_data.h" +#include "util.h" +#include "handletime.h" +#include "item.h" +#include "anim_tbl.h" +#include "configfile.h" + +/*ɬëǩ׻ë */ +typedef struct tagFunctionNameSet +{ + char* id; + char* initfunc; + char* walkprefunc; + char* walkpostfunc; + char* preoverfunc; + char* postoverfunc; + char* watchfunc; + char* loopfunc; + char* dyingfunc; + char* talkedfunc; + char* preattackedfunc; + char* postattackedfunc; + char* offfunc; + char* lookedfunc; + char* itemputfunc; + char* specialtalkedfunc; + char* windowtalkedfunc; +}FunctionNameSet; + + +static FunctionNameSet functionSet[]={ + + { "Sample" , "", "", "", "", "", "", "SampleLoop", + "SampleDying" ,"","", "","","","","",""}, + + /* ʧ */ + { "Door" , "DoorInit" , "","", + "","DoorPostOver","DoorWatch","", + "","DoorTalked","", "", + "DoorOff","DoorLooked","","",""}, + + /* */ + { "SimpleShop" ,"SimpleShopInit","","", + "","","","","", + "SimpleShopTalked" , "","", + "","","" ,"SimpleShopSpecialTalked" ,""}, + + /* */ + { "Msg" , "MsgInit" , "","", + "","","","", + "","","", "", + "","MsgLooked","","",""}, + + /* */ + { "Warp","WarpInit","","", + "","","","", + "","","","", + "","", "","",""}, + + { "TownPeople" ,"TownPeopleInit","","", + "","","","", + "", "TownPeopleTalked" ,"","", + "","","","",""}, + + { "Oldman","OldmanInit","","", + "","","","", + "","OldmanTalked","","", + "","", "","",""}, + + + /* Ƥ̼ */ + { "SavePoint","SavePointInit","","", + "","","","", + "","SavePointTalked","","", + "","", "","","SavePointWindowTalked"}, + + /* ס¡ */ + { "Healer","HealerInit","","", + "","","","", + "","HealerTalked","","", + "","", "","",""}, + + /* Healer add code by shan */ + { "FmHealer","FmHealerInit","","", + "","","","", + "","FmHealerTalked","","", + "","", "","",""}, + + /* ׻ add code by shan */ + { "PetMaker","PetMakerInit","","", + "","","","", + "","PetMakerTalked","","", + "","", "","",""}, + + { "StoryTeller","StoryTellerInit","","", + "","","","", + "","StoryTellerTalked","","", + "","", "","",""}, + + { "RoomAdminNew","RoomAdminNewInit","","", + "","","","RoomAdminNewLoop", + "","RoomAdminNewTalked","","", + "","", "","",""}, + + {"Dengon", + "DengonInit", "", "", "", "", "", "", "", "", + "", "", "", "DengonLooked", "", "","DengonWindowTalked"}, + + /* ԰ add code by shan */ + {"FmDengon", + "FmDengonInit", "", "", "", "", "", "", "", "", + "", "", "", "FmDengonLooked", "", "","FmDengonWindowTalked"}, + + { "ItemCompo" , "ItemCompoInit", "", "", + "", "", "", "", + "" ,"ItemCompoTalked","","" + ,"","","" , "",""}, + + /* ó */ + { "NPCEnemy","NPCEnemyInit","","", + "","","NPCEnemyWatch","", + "","NPCEnemyTalked","","", + "","", "","","NPCEnemyWindowTalked"}, + + /* ʧ */ + { "Action","ActionInit","","", + "","","ActionWatch","", + "","ActionTalked","","", + "","", "","",""}, + + { "Windowman","WindowmanInit","","", + "","","","", + "","WindowmanTalked","","", + "","WindowmanLooked", "","","WindowmanWindowTalked"}, + + /*windowhealer */ + { "WindowHealer","WindowHealerInit","","", + "","","","", + "","WindowHealerTalked","","", + "","WindowHealerLooked", "","","WindowHealerWindowTalked"}, + + + /* ItemShop */ + { "ItemShop","ItemShopInit","","", + "","","","", + "","ItemShopTalked","","", + "","", "","","ItemShopWindowTalked"}, + { "ItemVippointShop","ItemVippointShopInit","","", + "","","","", + "","ItemVippointShopTalked","","", + "","", "","","ItemVippointShopWindowTalked"}, + {"Sysinfo", + "SysinfoInit", "", "", + "", "", "", "SysinfoLoop", + "", "SysinfoTalked","", "", + "", "", "", "",""}, + + { "Duelranking","DuelrankingInit","","", + "","","", + "", + "","","","", + "","DuelrankingLooked", "","","DuelrankingWindowTalked"}, + + + /* PetSkillShop */ + { "PetSkillShop","PetSkillShopInit","","", + "","","","", + "","PetSkillShopTalked","","", + "","", "","","PetSkillShopWindowTalked"}, +#ifdef _PETSKILL_DEL_SHOP + { "PetSkillDelShop","PetSkillDelShopInit","","", + "","","","", + "","PetSkillDelShopTalked","","", + "","", "","","PetSkillDelShopWindowTalked"}, +#endif + /* PetShop */ + { "PetShop","PetShopInit","","", + "","","","", + "","PetShopTalked","","", + "","", "","","PetShopWindowTalked"}, + + + /* SignBoard */ + { "SignBoard","SignBoardInit","","", + "","","","", + "","","","", + "","SignBoardLooked", "","","SignBoardWindowTalked"}, + + + /* WarpMan */ + { "WarpMan","WarpManInit","","", + "","","WarpManWatch","WarpManLoop", + "","WarpManTalked","","", + "","", "","","WarpManWindowTalked"}, + + + /* ExChangeman */ + { "ExChangeMan","ExChangeManInit","","", + "","","","", + "","ExChangeManTalked","","", + "","", "","","ExChangeManWindowTalked"}, + + /* timeman */ + { "TimeMan","TimeManInit","","", + "","","TimeManWatch","", + "","TimeManTalked","","", + "","", "","",""}, + + /* ʾū¼ء */ + { "BodyLan","BodyLanInit","","", + "","","BodyLanWatch","", + "","BodyLanTalked","","", + "","", "","","BodyLanWindowTalked"}, + + /* ʾū¼ء */ + { "Mic","MicInit","","", + "","","","", + "","MicTalked","","", + "","", "","",""}, + + /* ƽѨ */ + { "LuckyMan","LuckyManInit","","", + "","","","", + "","LuckyManTalked","","", + "","", "","","LuckyManWindowTalked"}, + + /* Ѩƹﵩ */ + { "Bus","BusInit","","", + "","","","BusLoop", + "","BusTalked","","", + "","", "","",""}, + + /* */ // Arminius 7.7 Ariplane + { "Airplane","AirInit","","", + "","","","AirLoop", + "","AirTalked","","", + "","", "","",""}, + + { "Charm","CharmInit","","", + "","","","", + "","CharmTalked","","", + "","", "","","CharmWindowTalked"}, + + /* */ + { "Quiz","QuizInit","","", + "","","","", + "","QuizTalked","","", + "","", "","","QuizWindowTalked"}, + + { "PoolItemShop","PoolItemShopInit","","", + "","","","PoolItemShopLoop", + "","PoolItemShopTalked","","", + "","", "","","PoolItemShopWindowTalked"}, + + /* ìѨ */ + { "CheckMan","CheckManInit","","", + "","","","", + "","CheckManTalked","","", + "","", "","","CheckManWindowTalked"}, + + /* Ԫ */ + { "Janken","JankenInit","","", + "","","","", + "","JankenTalked","","", + "","", "","","JankenWindowTalked"}, + + /* Ϸ */ + { "Transmigration","TransmigrationInit","","", + "","","","", + "","TransmigrationTalked","","", + "","", "","","TransmigrationWindowTalked"}, + + /* Family Man */ + { "Familyman","FamilymanInit","","", + "","","","", + "","FamilymanTalked","","", + "","FamilymanLooked", "","","FamilymanWindowTalked"}, + + /* CoolFish: Family Warp Man 2001/6/6 */ + { "FMWarpMan","FMWarpManInit","","", + "","","","FMWarpManLoop", + "","FMWarpManTalked","","", + "","", "","","FMWarpManWindowTalked"}, + + /* CoolFish: Family PK Man 2001/7/4 */ + { "FMPKMan","FMPKManInit","","", + "","","","", + "","FMPKManTalked","","", + "","", "","","FMPKManWindowTalked"}, + + /* CoolFish: Family PK CallMan 2001/7/13 */ + { "FMPKCallMan","FMPKCallManInit","","", + "","","","", + "","FMPKCallManTalked","","", + "","", "","","FMPKCallManWindowTalked"}, + + /* Bank Man */ + { "Bankman","BankmanInit","","", + "","","","", + "","BankmanTalked","","", + "","BankmanLooked", "","","BankmanWindowTalked"}, + + /* Arminius 7.13 scheduleman */ + { "Scheduleman","SchedulemanInit","","", + "","","","SchedulemanLoop", + "","SchedulemanTalked","","", + "","", "","","SchedulemanWindowTalked"}, + + /* Arminius 7.24 manor scheduleman */ + { "ManorSman","ManorSmanInit","","", + "","","","ManorSmanLoop", + "","ManorSmanTalked","","", + "","", "","","ManorSmanWindowTalked"}, + + // Robin + { "Riderman","RidermanInit","","", + "","","","", + "","RidermanTalked","","", + "","RidermanLooked", "","","RidermanWindowTalked"}, + + { "FmLetter","FmLetterInit","","", + "","","","", + "","FmLetterTalked","","", + "","FmLetterLooked", "","","FmLetterWindowTalked"} +#ifdef _GAMBLE_BANK + ,{ + "NPC_GambleBank","GambleBankInit","","","","","", + "GambleBankLoop","", + "GambleBankTalked","","","","","","", + "GambleBankWindowTalked" + } +#endif + +#ifdef _GAMBLE_ROULETTE //Gamble_Roulette + ,{ + "NPC_GambleRoulette","GambleRouletteInit","","","","","", + "GambleRouletteLoop","", + "GambleRouletteTalked","","","","","","", + "GambleRouletteWindowTalked" + } + // + ,{ + "NPC_GambleMaster","GambleMasterInit","","","","","", + "GambleMasterLoop","", + "GambleMasterTalked","","","","","","", + "GambleMasterWindowTalked" + } + +#endif + +#ifdef _TRANSER_MAN + /* TranserMan */ + ,{ "TranserMan","TranserManInit","","", + "","","","TranserManLoop", + "","TranserManTalked","","", + "","", "","","TranserManWindowTalked" + } +#endif +#ifdef _FM_NPC_LOOK_WAR + ,{ "FmLookWarMan","FmLookWarManInit","","", + "","","","FmLookWarManLoop", + "","FmLookWarManTalked","","", + "","", "","","FmLookWarManWindowTalked" + } +#endif +#ifdef _FM_NPC_LOOK_WAR1 + ,{ "FmLookWarMan1","FmLookWarMan1Init","","", + "","","","FmLookWarMan1Loop", + "","FmLookWarMan1Talked","","", + "","", "","","FmLookWarMan1WindowTalked" + } +#endif +#ifdef _VIP_SHOP + /* VipShop */ + ,{ "VipShop","VipShopInit","","", + "","","","VipShopLoop", + "","VipShopTalked","","", + "","", "","","VipShopWindowTalked" + } + + ,{ "VipPoint","VipPointInit","","", + "","","","VipPointLoop", + "","VipPointTalked","","", + "","", "","","VipPointWindowTalked" + } +#endif + +#ifdef _VIP_SHOP + /* _VIP_SHOP */ + ,{ "NewVipShop","NewVipShopInit","","", + "","","","NewVipShopLoop", + "","NewVipShopTalked","","", + "","", "","","NewVipShopWindowTalked" + } +#endif +#ifdef _RMB_SYSTEM + ,{ "RmbShop","RmbShopInit","","", + "","","","RmbShopLoop", + "","RmbShopTalked","","", + "","", "","","RmbShopWindowTalked" + } +#endif +#ifdef _STU_SYS + ,{ "StuShop","StuShopInit","","", + "","","","StuShopLoop", + "","StuShopTalked","","", + "","", "","","StuShopWindowTalked" + } +#endif + +#ifdef _AUTO_PK + /* VipShop */ + ,{ "AutoPk","AutoPkInit","","", + "","","","", + "","AutoPkTalked","","", + "","", "","","AutoPkWindowTalked" + } +#endif +#ifdef _FMRANK_POINT + ,{ "FmRank","FmRankInit","","", + "","","","", + "","FmRankTalked","","", + "","", "","","FmRankWindowTalked" + } +#endif +#ifdef _NPC_MAKEPAIR + ,{ "MakePair","MakePairManInit","","", + "","","","MakePairManLoop", + "","MakePairManTalked","","", + "","", "","","MakePairManWindowTalked" + } +#endif + +#ifdef _NPC_FUSION + ,{ "PetFusion","PetFusionManInit","","", + "","","","PetFusionManLoop", + "","PetFusionManTalked","","", + "","", "","","PetFusionManWindowTalked" + } +#endif + +#ifdef _ITEM_NPCCHANGE + ,{ "ItemchangeMan","ItemchangeManInit","","", + "","","","ItemchangeManLoop", + "","ItemchangeManTalked","","", + "","", "","","ItemchangeManWindowTalked" + } +#endif +#ifdef _NPC_ITEMUP + ,{ "ItemupMan","ItemupManInit","","", + "","","","ItemupManLoop", + "","ItemupManTalked","","", + "","", "","","ItemupManWindowTalked" + } +#endif +#ifdef _CFREE_petskill + ,{ + "NPC_FreePetSkill","FreePetSkillInit","","","","","", + "","", + "FreePetSkillTalked","","","","","","", + "FreePetSkillWindowTalked" + } + +#endif + +#ifdef _PETRACE + // + ,{ + "PetRaceMaster","PetRaceMasterInit","","","","","", + "PetRaceMasterLoop","", + "PetRaceMasterTalked","","","","","","", + "PetRaceMasterWindowTalked" + } + // + ,{ + "PetRacePet","PetRacePetInit","","","","","", + "PetRacePetLoop","", + "PetRacePetTalked","","","","","","","" + } +#endif + +#ifdef _NEW_WARPMAN + ,{ + "NPC_NewNpcMan","NewNpcManInit","","","","","", + "NewNpcManLoop","", + "NewNpcManTalked","","","","","","", + "NewNpcManWindowTalked" + } +#endif + +#ifdef _ALLDOMAN // (ɿ) Syu ADD аNPC + ,{ + "Alldoman","AlldomanInit","","", + "","","","","","AlldomanTalked","","","","","","", + "AlldomanWindowTalked"} +#endif + +#ifdef _NPC_WELFARE + ,{ "Welfare","WelfareInit","","", + "","","","", + "","WelfareTalked","","", + "","", "","","WelfareWindowTalked"} +#endif + +#ifdef _VIGOR_SYS + ,{ "ItemVigorShop","ItemVigorShopInit","","", + "","","","", + "","ItemVigorShopTalked","","", + "","", "","","ItemVigorShopWindowTalked"} +#endif +}; + +static int NPC_searchFunctionSet( char* name, int* unuse) +{ + int i; + for( i=0 ; i =arraysizeof(functionSet) )return FALSE; + + strcpysafe( ch->charfunctable[CHAR_INITFUNC].string, + sizeof( ch->charfunctable[CHAR_INITFUNC].string ), + functionSet[id].initfunc); + + strcpysafe( ch->charfunctable[CHAR_WALKPREFUNC].string, + sizeof(ch->charfunctable[CHAR_WALKPREFUNC].string), + functionSet[id].walkprefunc); + + strcpysafe( ch->charfunctable[CHAR_WALKPOSTFUNC].string, + sizeof(ch->charfunctable[CHAR_WALKPOSTFUNC].string), + functionSet[id].walkpostfunc); + + strcpysafe( ch->charfunctable[CHAR_PREOVERFUNC].string, + sizeof(ch->charfunctable[CHAR_PREOVERFUNC].string), + functionSet[id].preoverfunc); + + strcpysafe( ch->charfunctable[CHAR_POSTOVERFUNC].string, + sizeof(ch->charfunctable[CHAR_POSTOVERFUNC].string), + functionSet[id].postoverfunc); + + strcpysafe( ch->charfunctable[CHAR_WATCHFUNC].string, + sizeof(ch->charfunctable[CHAR_WATCHFUNC].string), + functionSet[id].watchfunc); + + strcpysafe( ch->charfunctable[CHAR_LOOPFUNC].string, + sizeof(ch->charfunctable[CHAR_LOOPFUNC].string), + functionSet[id].loopfunc); + + strcpysafe( ch->charfunctable[CHAR_TALKEDFUNC].string, + sizeof(ch->charfunctable[CHAR_TALKEDFUNC].string), + functionSet[id].talkedfunc); + + strcpysafe( ch->charfunctable[CHAR_DYINGFUNC].string, + sizeof(ch->charfunctable[CHAR_DYINGFUNC].string), + functionSet[id].dyingfunc); + + strcpysafe( ch->charfunctable[CHAR_PREATTACKEDFUNC].string, + sizeof(ch->charfunctable[CHAR_PREATTACKEDFUNC].string), + functionSet[id].preattackedfunc); + strcpysafe( ch->charfunctable[CHAR_POSTATTACKEDFUNC].string, + sizeof(ch->charfunctable[CHAR_POSTATTACKEDFUNC].string), + functionSet[id].postattackedfunc); + + strcpysafe( ch->charfunctable[CHAR_OFFFUNC].string, + sizeof(ch->charfunctable[CHAR_OFFFUNC].string), + functionSet[id].offfunc ); + + strcpysafe( ch->charfunctable[CHAR_LOOKEDFUNC].string, + sizeof(ch->charfunctable[CHAR_LOOKEDFUNC].string), + functionSet[id].lookedfunc ); + + strcpysafe( ch->charfunctable[CHAR_ITEMPUTFUNC].string, + sizeof(ch->charfunctable[CHAR_ITEMPUTFUNC].string), + functionSet[id].itemputfunc ); + + strcpysafe( ch->charfunctable[CHAR_SPECIALTALKEDFUNC].string, + sizeof(ch->charfunctable[CHAR_SPECIALTALKEDFUNC].string), + functionSet[id].specialtalkedfunc ); + + strcpysafe( ch->charfunctable[CHAR_WINDOWTALKEDFUNC].string, + sizeof(ch->charfunctable[CHAR_WINDOWTALKEDFUNC].string), + functionSet[id].windowtalkedfunc ); + +#ifdef _USER_CHARLOOPS + strcpysafe( ch->charfunctable[CHAR_LOOPFUNCTEMP1].string, + sizeof(ch->charfunctable[CHAR_LOOPFUNCTEMP1].string), ""); + + strcpysafe( ch->charfunctable[CHAR_LOOPFUNCTEMP2].string, + sizeof(ch->charfunctable[CHAR_LOOPFUNCTEMP2].string), ""); +#endif + return TRUE; +} + + +typedef enum +{ + NPC_INTENTRY=0, + NPC_CHARENTRY=1, + NPC_INTFUNC=2, + NPC_CHARFUNC=3, +}NPC_TYPECATEGORYATREADFILE; + +/*------------------------------------------------------------ + * Template index ƻоcheck + * ¦ + * index int index + * ߯Ի + * valid TRUE + * invalid FALSE + ------------------------------------------------------------*/ +INLINE int NPC_CHECKTEMPLATEINDEX(int index) +{ + if( NPC_templatenum <= index || index < 0 )return FALSE; + return TRUE; +} +/*------------------------------------------------------------ + * Template intdata index ƻоcheck + * ¦ + * index int index + * ߯Ի + * valid TRUE + * invalid FALSE + ------------------------------------------------------------*/ +static INLINE int NPC_CHECKTEMPLATEINTINDEX(int index) +{ + if( NPC_TEMPLATEINTNUM <= index || index < 0 )return FALSE; + return TRUE; +} +/*------------------------------------------------------------ + * Template chardata index ƻоcheck + * ¦ + * index int index + * ߯Ի + * valid TRUE + * invalid FALSE + ------------------------------------------------------------*/ +static INLINE int NPC_CHECKTEMPLATECHARINDEX(int index) +{ + if( NPC_TEMPLATECHARNUM <= index || index < 0 )return FALSE; + return TRUE; +} + + + +/*------------------------------------------------------------ + * ¦ + * filenum int ̻ + * ߯Ի + ------------------------------------------------------------*/ +BOOL NPC_initTemplateArray( int templatenum ) +{ + NPC_templatenum = templatenum; + NPC_template = (NPC_Template*)allocateMemory( sizeof( NPC_Template ) * + NPC_templatenum ); + if( NPC_template == NULL )return FALSE; + NPC_template_readindex = 0; + return TRUE; +} + +/*------------------------------------------------------------ + * ¦ + * ߯Ի + * ئ + ------------------------------------------------------------*/ +void NPC_setDefaultNPCTemplate( NPC_Template* temp ) +{ + int i; + if( temp == NULL )return; + + for( i=0 ; i< arraysizeof(temp->chardata) ; i ++ ) + memset( &temp->chardata[i], 0, sizeof(temp->chardata[i] )); + + temp->intdata[NPC_TEMPLATEMAKEATNOBODY]=0; + temp->intdata[NPC_TEMPLATEMAKEATNOSEE]=0; + temp->intdata[NPC_TEMPLATEIMAGENUMBER]=0; + temp->intdata[NPC_TEMPLATETYPE]=-1; + + temp->intdata[NPC_TEMPLATEMINHP]=0; + temp->intdata[NPC_TEMPLATEMINMP]=0; + temp->intdata[NPC_TEMPLATEMINSTR]=0; + temp->intdata[NPC_TEMPLATEMINTOUGH]=0; + + temp->intdata[NPC_TEMPLATEISFLYING]=0; + + temp->intdata[NPC_TEMPLATEITEMNUM]=0; + temp->intdata[NPC_TEMPLATELOOPFUNCTIME]=-1; + temp->intdata[NPC_TEMPLATEFUNCTIONINDEX]=-1; + + for( i=0; irandomdata[i] = 0; + } + + temp->hash = 0; + temp->haveitem=NULL; +} + +BOOL NPC_IsNPCTemplateFile( char* filename ) +{ + FILE* f; + char line1[128]; + char* ret; + if( filename == NULL + ||strlen( filename ) < 1 + ||filename[strlen(filename)-1] == '~' + ||filename[0] == '#' + ||strcmptail( filename, ".bak" ) == 0 )return FALSE; + + f = fopen( filename , "r" ); + if( f == NULL ) goto RETURNFALSE; + ret = fgets( line1, sizeof( line1 ), f ); + if( ret == NULL )goto FCLOSERETURNFALSE; + + if( strcmp( NPC_TEMPLATEFILEMAGIC, line1 ) == 0 ){ + fclose(f); + return TRUE; + } + +FCLOSERETURNFALSE: + fclose(f); +RETURNFALSE: + return FALSE; +} + +void NPC_templateallocitemdata( NPC_Template* one ) +{ + int itemnum = one->intdata[NPC_TEMPLATEITEMNUM]; + if( itemnum > 8 ) itemnum = 8; + else if( itemnum <= 0 ) itemnum = 0; + one->intdata[NPC_TEMPLATEITEMNUM] = itemnum; + one->haveitem = allocateMemory( sizeof( NPC_haveItem ) * itemnum ); + +} + + +/*------------------------------------------------------------ + * NPC_getRandomValue 缰¦Ѽѯ뼰׻ + * ¦ + * ߯Ի + ------------------------------------------------------------*/ +static int NPC_seekGraphicNumberFromString( char* string, int* unuse ) +{ + return CHAR_seekGraphicNumberFromString( string ); + +} +/*------------------------------------------------------------ + * ¦ + * ߯Ի + ------------------------------------------------------------*/ +static int NPC_getRandomValue( char* string,int* randomwidth ) +{ + int minvalue; + int maxvalue; + char* startmax=NULL; + + minvalue = atoi( string ); + startmax = index( string,',' ); + if( startmax != NULL ){ + /* ¼ĸةɬûľ */ + /* +1 ","׻ */ + maxvalue = atoi(startmax+1); + + /* ɬ÷ */ + *randomwidth = ABS(maxvalue - minvalue); + return min(minvalue,maxvalue); + } + *randomwidth = 0; + return minvalue; +} + + +/*------------------------------------------------------------ + * ¦ + * ߯Ի + ------------------------------------------------------------*/ +BOOL NPC_readTemplateFile( char* filename ) +{ + FILE* f; + char line[512]; + int linenum=0; + int start=OFF; + NPC_Template temp; + int itmreadindex=0; + char* ret; + int randomdata[NPC_TEMPLATEINTNUM]; + int i; + + if( NPC_template_readindex >= NPC_templatenum ){ + print("ģ鳬Ŀ\n" ); + print("ģĿ %d\n", NPC_templatenum); + return FALSE; + } + + for( i=0; i= NPC_templatenum ){ + print("ģ鳬Ŀ\n" ); + print("ģĿ %d\n", + NPC_templatenum); + goto FCLOSERETURNFALSE; + } + } + NPC_setDefaultNPCTemplate( &temp ); + itmreadindex=0; + start=OFF; + }else{ + fprint( "δ '}' at %s:%d\n",filename,linenum); + goto FCLOSERETURNFALSE; + } + break; + default: + { + typedef struct tagNPC_Readtemplate + { + char* keyword; + NPC_TYPECATEGORYATREADFILE type; + int index; + void* func; + }NPC_Readtemplate; + static NPC_Readtemplate NPC_readtemplate[NPC_TEMPLATECHARNUM+NPC_TEMPLATEINTNUM]= + { + {"templatename" , NPC_CHARENTRY, NPC_TEMPLATENAME,NULL}, + {"name" , NPC_CHARENTRY, NPC_TEMPLATECHARNAME, + NULL}, + {"makeatnobody", NPC_INTENTRY, NPC_TEMPLATEMAKEATNOBODY, + NULL}, + {"makeatnosee" , NPC_INTENTRY, NPC_TEMPLATEMAKEATNOSEE, + NULL}, + {"graphicname", NPC_INTFUNC, NPC_TEMPLATEIMAGENUMBER, + NPC_seekGraphicNumberFromString}, + {"type", NPC_INTFUNC, NPC_TEMPLATETYPE, + NPC_seekGraphicNumberFromString}, + + {"hp", NPC_INTFUNC, NPC_TEMPLATEMINHP, + NPC_getRandomValue}, + {"mp", NPC_INTFUNC, NPC_TEMPLATEMINMP, + NPC_getRandomValue}, + {"str", NPC_INTFUNC, NPC_TEMPLATEMINSTR, + NPC_getRandomValue}, + {"tough", NPC_INTFUNC, NPC_TEMPLATEMINTOUGH, + NPC_getRandomValue}, + + {"fly", NPC_INTENTRY,NPC_TEMPLATEISFLYING,NULL}, + + {"itemnum", NPC_INTENTRY, NPC_TEMPLATEITEMNUM, NULL,}, + {"functionset",NPC_INTFUNC, NPC_TEMPLATEFUNCTIONINDEX, + NPC_searchFunctionSet,}, + {"initfunc", NPC_CHARENTRY, NPC_TEMPLATEINITFUNC,NULL,}, + {"walkprefunc", NPC_CHARENTRY, NPC_TEMPLATEWALKPREFUNC, + NULL,}, + {"walkpostfunc",NPC_CHARENTRY, NPC_TEMPLATEWALKPOSTFUNC, + NULL,}, + {"preoverfunc", NPC_CHARENTRY, NPC_TEMPLATEPREOVERFUNC, + NULL,}, + {"postoverfunc",NPC_CHARENTRY, NPC_TEMPLATEPOSTOVERFUNC, + NULL,}, + {"watchfunc", NPC_CHARENTRY, NPC_TEMPLATEWATCHFUNC, + NULL,}, + {"loopfunc", NPC_CHARENTRY, NPC_TEMPLATELOOPFUNC, NULL,}, + {"talkedfunc",NPC_CHARENTRY,NPC_TEMPLATETALKEDFUNC,NULL,}, + {"dyingfunc",NPC_CHARENTRY,NPC_TEMPLATEDYINGFUNC,NULL,}, + {"preattackedfunc",NPC_CHARENTRY, + NPC_TEMPLATEPREATTACKEDFUNC,NULL,}, + {"postattackedfunc",NPC_CHARENTRY, + NPC_TEMPLATEPOSTATTACKEDFUNC,NULL,}, + {"offfunc",NPC_CHARENTRY,NPC_TEMPLATEOFFFUNC,NULL,}, + {"lookedfunc",NPC_CHARENTRY,NPC_TEMPLATELOOKEDFUNC,NULL,}, + {"itemputfunc",NPC_CHARENTRY,NPC_TEMPLATEITEMPUTFUNC, + NULL,}, + {"specialtalkedfunc",NPC_CHARENTRY, + NPC_TEMPLATESPECIALTALKEDFUNC, NULL,}, + + {"windowtalkedfunc",NPC_CHARENTRY, + NPC_TEMPLATEWINDOWTALKEDFUNC, NULL,}, + + {"loopfunctime",NPC_INTENTRY,NPC_TEMPLATELOOPFUNCTIME, + NULL,}, + }; + + char firstToken[256]; + int ret,i; + ret = getStringFromIndexWithDelim( line, "=", 1, firstToken, sizeof( firstToken ) ); + if( ret == FALSE ){ + print( "Find error at %s in line %d. Ignore\n", filename , linenum); + break; + } + + if( strcasecmp(firstToken,"itm") == 0 ){ + char one[128]; + char two[128]; + char three[128]; + int itemnumber=0,rate=0,amount=1; + char secondToken[256]={""}; + if( itmreadindex < temp.intdata[NPC_TEMPLATEITEMNUM] && + temp.haveitem != NULL ) + ; + else + continue; + ret = getStringFromIndexWithDelim( line, "=", 2, + secondToken, sizeof(secondToken ) ); + if( ret == FALSE ){ + print( "Find error at %s in line %d. Ignore\n", + filename , linenum); + secondToken[0] = '\0'; + } + ret = getStringFromIndexWithDelim( secondToken, "|", 1, one,sizeof( one ) ); + if( ret != FALSE )itemnumber=atoi(one); + ret = getStringFromIndexWithDelim( secondToken, "|", 2, two,sizeof(two)); + if( ret != FALSE )rate=atoi(two); + ret = getStringFromIndexWithDelim( secondToken, "|", 3, three,sizeof(three)); + if( ret != FALSE )amount=atoi(three); + if( rate > 0 && amount > 0 ){ + if( itemnumber == -1 ){ + temp.haveitem[itmreadindex].itemnumber = -1; + temp.haveitem[itmreadindex].haverate = rate; + temp.haveitem[itmreadindex].havenum = amount; + itmreadindex++; + }else if( ITEM_CHECKITEMTABLE( itemnumber ) == TRUE ){ + temp.haveitem[itmreadindex].itemnumber=itemnumber; + temp.haveitem[itmreadindex].haverate = rate; + temp.haveitem[itmreadindex].havenum = amount; + itmreadindex++; + }else + print("this item is not item %s:%d\n", + filename , linenum); + }else + print("rate or amount is odd setting. rate=%d " + "amount=%d %s:%d\n", rate,amount, filename, + linenum); + goto NEXT; + }else{ + for( i = 0 ; i < arraysizeof(NPC_readtemplate) ; i ++ ){ + if( strcasecmp( NPC_readtemplate[i].keyword, + firstToken ) == 0 ){ + char secondToken[256]={""}; + ret = getStringFromIndexWithDelim( + line, "=", 2, secondToken, sizeof(secondToken) + ); + if( ret == FALSE ) + print( "Find error at %s in line %d. Ignore\n" + ,filename , linenum); + + switch( NPC_readtemplate[i].type ){ + case NPC_INTENTRY: + temp.intdata[NPC_readtemplate[i].index]=atoi(secondToken); + if( NPC_readtemplate[i].index == NPC_TEMPLATEITEMNUM ) + NPC_templateallocitemdata( &temp ); + break; + case NPC_CHARENTRY: + strcpysafe( temp.chardata[NPC_readtemplate[i].index].string, + sizeof(temp.chardata[NPC_readtemplate[i].index].string), + secondToken); + break; + case NPC_INTFUNC: + { + int (*intfunction)(char*,int* ); + intfunction = NPC_readtemplate[i].func; + temp.intdata[NPC_readtemplate[i].index] + = intfunction( secondToken, &randomdata[NPC_readtemplate[i].index]); + break; + } + case NPC_CHARFUNC: + { + char* (*charfunction)(char* ); + charfunction = NPC_readtemplate[i].func; + strcpysafe( temp.chardata[NPC_readtemplate[i].index].string, + sizeof(temp.chardata[NPC_readtemplate[i].index].string), + charfunction(secondToken)); + break; + } + default: + break; + } + goto NEXT; + } + } + } + fprint("%s:%d There is no such entry %s\n" , filename, + linenum, firstToken ); + NEXT: + break; + } + break; + } + } + fclose(f); + return TRUE; + +FCLOSERETURNFALSE: + fclose(f); + return FALSE; +} + +BOOL NPC_readNPCTemplateFiles( char* topdirectory ,int templatesize) +{ + STRING64 *filenames; + int filenum; + int i; + filenames = (STRING64 *)allocateMemory( sizeof( STRING64 ) * + (int)getFilesearchnum( ) ); + if( filenames == NULL ){ + print( "ȡNPCļ... ڴ\n" ); + return FALSE; + } + filenum = rgetFileName( topdirectory ,filenames ,getFilesearchnum( ) ); + if( filenum == -1 ){ + fprint("޷ %s ݹȡļ\n",topdirectory); + freeMemory( filenames ); + return FALSE; + } + if( filenum >= getFilesearchnum( ) ){ + print( "ļĿʧ %d\n", getFilesearchnum( ) ); + while( 1 ); + }else{ + print( "ļ = %d\n", filenum ); + } + if( !NPC_initTemplateArray( templatesize ) ){ + fprint( "ģ\n" ); + freeMemory( filenames ); + return FALSE; + } + print( "ȡļģ...." ); + for( i = 0 ; i < filenum ; i ++ ) + if( NPC_IsNPCTemplateFile( filenames[i].string )) + NPC_readTemplateFile( filenames[i].string ); + print( "ȷģ %d ...\n" , NPC_template_readindex ); + NPC_templatenum=NPC_template_readindex; + freeMemory( filenames ); + return TRUE; +} + + + +/*------------------------------------------------------------ + * ¦ + * ߯Ի + * -1 ݾ޷¡ + ------------------------------------------------------------*/ +int NPC_templateGetTemplateIndex( char* templatename ) +{ + int i; + int hash=hashpjw( templatename ); + + for( i = 0 ; i < NPC_templatenum ; i ++ ) + if( hash == NPC_template[i].hash && + strcasecmp( templatename , NPC_template[i].chardata[NPC_TEMPLATENAME].string) == 0 ) + return i; + + return -1; +} diff --git a/npc/npcutil.c b/npc/npcutil.c new file mode 100644 index 0000000..2117158 --- /dev/null +++ b/npc/npcutil.c @@ -0,0 +1,1686 @@ +#include "version.h" +#include +#include "common.h" +#include "char.h" +#include "char_base.h" +#include "configfile.h" +#include "object.h" +#include "item.h" +#include "map_deal.h" +#include "npcutil.h" +#include "npc_door.h" +#include "readmap.h" +#include "npccreate.h" +#include "enemy.h" + +// CoolFish: Family 2001/7/29 +#include "family.h" +#include "saacproto_cli.h" + +#define IS_2BYTEWORD( _a_ ) ( (char)(0x80) <= (_a_) && (_a_) <= (char)(0xFF) ) + +extern struct FM_POINTLIST fmpointlist; + +#ifdef _PERSONAL_FAME // Arminius 8.30: + +// Arminius: Ұֵ +int FMAdvTbl[] = { // ð Table + 0, // 0 + 15, // 1 + 0, // 2 + 0, // 3 + 10, // 4 + 5, // 5 + 0, // 6 + 0, // 7 + 30, // 8 + 0, // 9 + 0, // 10 + 0, // 11 + 68, // 12 + 0, // 13 + 0, // 14 + 15, // 15 + 120, // 16 + 90, // 17 + 0, // 18 + 0, // 19 + 0, // 20 + 0, // 21 + 60, // 22 + 0, // 23 + 0, // 24 + 0, // 25 + 60, // 26 + 0, // 27 + 0, // 28 + 0, // 29 + 0, // 30 + 60, // 31 + 0, // 32 + 0, // 33 + 30, // 34 + 225, // 35 + 0, // 36 + 0, // 37 + 60, // 38 + 135, // 39 + 600, // 40 + 0, // 41 + 360, // 42 + 0, // 43 + 0, // 44 + 480, // 45 + 840, // 46 + 0, // 47 + 600, // 48 + 600, // 49 + 600, // 50 + 600, // 51 + 600, // 52 + 600, // 53 + 720, // 54 + 0, // 55 + 0, // 56 + 0, // 57 + 0, // 58 + 0, // 59 + 0, // 60 + 0, // 61 + 0, // 62 + 120, // 63 + 900, // 64 + 0, // 65 + 0, // 66 + 0, // 67 + 0, // 68 + 0, // 69 + 0, // 70 + 15000, // 71 + 20000, // 72 + 0, // 73 + 0, // 74 + 0, // 75 + 0, // 76 + 0, // 77 + 0, // 78 + 0, // 79 + 0, // 80 + 1200, // 81 + 3000, // 82 + 0, // 83 + 1500, // 84 + 0, // 85 + 0, // 86 + 100, // 87 + 0, // 88 + 400, // 89 + 0, // 90 + 0, //91 + 0, // 92 + 0, // 93 + 0, // 94 + 0, // 95 + 0, // 96 + 100, // 97 + 0, // 98 + 0, // 99 + 0, // 100 + 0, //101 + 0, //102 + 0, //103 + 0, //104 + 600, // 105 + 0, // 106 + 100, // 107 + 0, // 108 + 0, // 109 + 400, // 110 + 500, // 111 + 1000, // 112 + 100, // 113 + 300, // 114 + 0, // 115 + 500, // 116 + 15000, // 117 + 0, // 118 + 0, // 119 + 0, // 120 + 0, // 121 + 0, // 122 + 0, // 123 + 0, // 124 + 400, // 125 + 300, // 126 + 0, // 127 + 0, // 128 + 0, // 129 + 0, // 130 + 0, // 131 + 0, // 132 + 500, // 133 +}; + +#endif + +BOOL NPC_Util_AddOneTitle( int charindex, int titleindex ) +{ + int i; + Char *c ; + + if( !CHAR_CHECKINDEX( charindex ) )return FALSE; + + c = CHAR_getCharPointer( charindex ); + // CoolFish: +1 2001/11/05 + if (!c) return FALSE; + + for(i=0;iindexOfHaveTitle[i] == -1 ){ + c->indexOfHaveTitle[i] = titleindex; + return TRUE; + } + } + return FALSE; +} + + +BOOL NPC_Util_HaveTitle( int charindex , int titleindex ) +{ + int i; + Char *c; + if( !CHAR_CHECKINDEX( charindex ) )return -1; + + c = CHAR_getCharPointer( charindex ); + // CoolFish: +1 2001/11/05 + if (!c) return FALSE; + + for(i=0;iindexOfHaveTitle[i] == titleindex ){ + return TRUE; + } + } + return FALSE; +} + + +BOOL NPC_Util_Nearby( int x1 , int y1, int x2 , int y2 ) +{ + if( ABS( x1 - x2 ) <= 1 && + ABS( y1 - y2 ) <= 1 ){ + return TRUE; + } else { + return FALSE; + } +} + +BOOL NPC_Util_CharNearby(int ind1,int ind2) +{ + if( !CHAR_CHECKINDEX(ind1)) return FALSE; + if( !CHAR_CHECKINDEX(ind2)) return FALSE; + + if( CHAR_getInt( ind1 , CHAR_FLOOR ) != + CHAR_getInt( ind2 , CHAR_FLOOR ) ){ + return FALSE; + } + + return NPC_Util_Nearby( CHAR_getInt( ind1,CHAR_X), + CHAR_getInt( ind1,CHAR_Y), + CHAR_getInt( ind2,CHAR_X), + CHAR_getInt( ind2,CHAR_Y)); + +} + + +static struct ynset +{ + int value; + char string[32]; +}yntable[] ={ + { 0 , "no" }, + { 0 , "No" }, + { 0 , "NO" }, + { 0 , "NO" }, + { 0 , "No" }, + { 0 , "no" }, + { 0 , "" }, + { 0 , "" }, + + { 1 , "yes" }, + { 1 , "Yes" }, + { 1 , "YES" }, + { 1 , "YES" }, + { 1 , "Yes" }, + { 1 , "yes" }, + { 1 , "" }, + { 1 , "" }, + +}; + +int NPC_Util_YN(char *input ) +{ + int i; + for(i=0;;i++){ + int j; + + if( input[i] == '\0' ){ + return -1; + } + for(j=0;jx - pstart->x; + dify = pend->y - pstart->y; + + if( difx < 0 )difx=-1; + else if( difx > 0 )difx=1; + if( dify < 0 )dify=-1; + else if( dify > 0 )dify=1; + + return dirtable[dify+1][difx+1]; +} + +int NPC_Util_countHaveItem( int meindex , int itemid ) +{ + int i, count=0, itemindex; + if( !CHAR_CHECKINDEX(meindex))return -1; + for( i=0 ; i= 0 ){ + CHAR_ObjectDelete( oind ); + CHAR_setItemIndex( charindex, emptyindex, itemindex ); + ITEM_setWorkInt( itemindex, ITEM_WORKOBJINDEX, -1 ); + ITEM_setWorkInt( itemindex, ITEM_WORKCHARAINDEX, charindex ); + if( net ) CHAR_sendItemDataOne( charindex, emptyindex); + return TRUE; + }else if( cind >= 0 ){ + int itemgrp[2]; + int itemindexinchara; + if( cind == charindex )return FALSE; + itemindexinchara = NPC_Util_SearchItemInChar( cind , itemindex); + if( itemindexinchara == -1 )return FALSE; + CHAR_setItemIndex( cind , itemindexinchara , -1 ); + CHAR_complianceParameter(cind); + itemgrp[0] = itemindexinchara; + CHAR_setItemIndex( charindex , emptyindex , itemindex ); + itemgrp[1] = emptyindex; + if( net ) CHAR_sendItemData( charindex, itemgrp, arraysizeof(itemgrp)); + ITEM_setWorkInt( itemindex, ITEM_WORKOBJINDEX, -1 ); + ITEM_setWorkInt( itemindex, ITEM_WORKCHARAINDEX, charindex ); + return TRUE; + } + return FALSE; +} + +BOOL NPC_Util_moveItemToMap( int itemindex , int fl , int x , int y, + BOOL net ) +{ + int oind,cind; + + if( !ITEM_CHECKINDEX( itemindex ) ) return FALSE; + + oind = ITEM_getWorkInt( itemindex , ITEM_WORKOBJINDEX ); + cind = ITEM_getWorkInt( itemindex , ITEM_WORKCHARAINDEX ); + + if( oind >= 0 ){ + return MAP_objmove( oind , OBJECT_getFloor(oind), + OBJECT_getX(oind), + OBJECT_getY(oind), + fl,x,y); + } else if( cind >= 0 ){ + int itemindexinchara = NPC_Util_SearchItemInChar(cind,itemindex); + if( itemindexinchara == -1 ) return FALSE; + + CHAR_setItemIndex( cind , itemindexinchara , -1 ); + CHAR_complianceParameter(cind); + if( net ) CHAR_sendItemDataOne( cind, itemindexinchara); + if( CHAR_DropItemAbsolute( itemindex, fl,x,y,TRUE) < 0 ){ + return FALSE; + } else { + return TRUE; + } + } + return FALSE; +} + +int NPC_Util_GiveAllItemToChar( int give , int take ) +{ + int i ; + int count=0; + + for(i=0;i= 0 )break; + }else + if( Part == 1 ){ /* 㯼̼ë */ + iTarget = SearchNearLine( x+Level, y-Level+1, + floor, 0, 1, Level*2, type ); + if( iTarget >= 0 )break; + }else + if( Part == 2 ){ /* Ʊ̼ë */ + iTarget = SearchNearLine( x+Level-1, y+Level, + floor, -1, 0, Level*2, type ); + if( iTarget >= 0 ) break; + }else + if( Part == 3 ){ /* ̼ë */ + iTarget = SearchNearLine( x-Level, y+Level-1, + floor, 0, -1, Level*2, type ); + if( iTarget >= 0 ) break; + } + Part ++; Part &= 3; /* ݼɡë */ + } + return iTarget; +} + +int NPC_Util_SearchNear( int meindex, int maxlen, int type ) +{ +#if 1 + int floor, x, y, i,iTarget = -1; + if( !CHAR_CHECKINDEX( meindex ) )return -1; + floor = CHAR_getInt( meindex, CHAR_FLOOR ); + x = CHAR_getInt( meindex, CHAR_X ); + y = CHAR_getInt( meindex, CHAR_Y ); + + for( i = 0; i < maxlen; i ++ ){ + iTarget = SearchNearAround( x, y, floor, RAND( 0,3 ), i+1, type ); + if( iTarget >= 0 )break; + } + return iTarget; + + +#else + int floor, x, y, i,iTarget = -1, iLen, iMin = 655360, tX, tY; + if( !CHAR_CHECKINDEX( meindex ) )return -1; + floor = CHAR_getInt( meindex, CHAR_FLOOR ); + x = CHAR_getInt( meindex, CHAR_X ); + y = CHAR_getInt( meindex, CHAR_Y ); + + /* */ + for( i = 0 ; i maxlen )continue; /* Tľʿ*/ + if( tY > maxlen )continue; /* ئݳ*/ + + iLen = tX*tX+tY*tY; + if( iMin > iLen ){ + iMin = iLen; + iTarget = obj[i].index; /* ̼͵ë趪E*/ + } + } + + return iTarget; +#endif +} +/*------------------------------------------------------------ +------------------------------------------------------------*/ +int NPC_Util_SearchNearPlayer( int meindex, int maxlen ) +{ + return( NPC_Util_SearchNear( meindex, maxlen, CHAR_TYPEPLAYER)); +} +/*------------------------------------------------------------ +-----------------------------------------------------------*/ +int NPC_Util_SearchNearEnemy( int meindex, int maxlen ) +{ + return( NPC_Util_SearchNear( meindex, maxlen, CHAR_TYPEENEMY)); +} + + + +/******************************************************* + + int NPC_Util_SuberiWalk( + int index, CHAR ̼͵ + ); + + -1 Ѩ¦ȾȻ޷¡ + -2 ƽҷ¦ȾȻ޷¡ + + +*******************************************************/ +int NPC_Util_OtherCharCheck( int ff, int fx, int fy) +{ +#if 1 + OBJECT object; + for( object=MAP_getTopObj(ff,fx,fy); object ; + object = NEXT_OBJECT(object) ) + { + int objindex = GET_OBJINDEX(object); + if( OBJECT_getType(objindex) == OBJTYPE_CHARA ){ + return 1; + } + } + return 0; +#else + int i; + for( i = 0 ; i < objnum ; i ++){ + if( obj[i].x == fx && obj[i].y == fy && obj[i].floor == ff ){ + if( obj[i].type != OBJTYPE_NOUSE ){ + return 1; + } + } + } + return 0; +#endif +} + + +int NPC_Util_SuberiWalk( + int index, + int dir +) +{ + int i, OkFlg = 0, x = 0, y = 0, fl = 0; + int aDirList[3],dir2; + int tX, tY; + + x = CHAR_getInt(index,CHAR_X); + y = CHAR_getInt(index,CHAR_Y); + fl = CHAR_getInt(index,CHAR_FLOOR); + + switch( dir ){ + case 1: aDirList[0] = 0; aDirList[1] = 2; aDirList[2] = 1; + break; + case 3: aDirList[0] = 2; aDirList[1] = 4; aDirList[2] = 3; + break; + case 5: aDirList[0] = 4; aDirList[1] = 6; aDirList[2] = 5; + break; + case 7: aDirList[0] = 6; aDirList[1] = 0; aDirList[2] = 7; + break; + default: + tX = x+CHAR_getDX(dir); + tY = y+CHAR_getDY(dir); + /* ׻*/ + if( MAP_walkAble( index,fl,tX,tY ) == 0 ){ + dir = -1;/* Ѩ¦Ⱦ*/ + } +// }else +// if( NPC_Util_OtherCharCheck( fl,tX, tY ) ){ +// dir = -2;/* ƽҷ±¦Ⱦ*/ +// } +/* CHAR_walk( index, dir, 0 );*/ + return dir; + } + + for( i = 0; i < 3; i ++ ){ + dir2 = aDirList[i]; + tX = x+CHAR_getDX(dir2); + tY = y+CHAR_getDY(dir2); + if( MAP_walkAble( index,fl,tX,tY ) == 0 ){ + aDirList[i] = -1; /* ئfڽ*/ +// }else if( NPC_Util_OtherCharCheck( fl,tX, tY ) ){ + }else{ + /* !!*/ + OkFlg ++; + } + } + + if( aDirList[0] >= 0 && aDirList[1] >= 0 && aDirList[2] >= 0 ){ + }else + if( aDirList[0] >= 0 ){ + dir = aDirList[0]; + }else + if( aDirList[1] >= 0 ){ + dir = aDirList[1]; + }else{ + dir = aDirList[0]+aDirList[1]; + } + +/* CHAR_walk( index, dir, 0 );*/ + + return dir; +} +/*----------------------------------------------------------------------- +* +* ---------------------------------- +* IN : int meindex : ƽҷindex +* OUT: +* RETURN: +* ---------------------------------- +* +* [File:enemykill.create] +* enemy=enemykill|range:4 +* +* call: +* range = NPC_Util_GetNumFromArg( index, "range"); +*----------------------------------------------------------------------*/ +int NPC_Util_GetNumFromArg( int meindex, char* in) +{ + BOOL rc; + int i; + char outstr[sizeof( STRING32)]; + int out = -1; + char *a = CHAR_getChar( meindex, CHAR_NPCARGUMENT); + + for( i = 1; ; i++ ) { + rc = getStringFromIndexWithDelim( a, "|", i, outstr, sizeof(outstr)); + if( rc == FALSE) break; + if( strstr( outstr, in) != NULL ) { + out = textToInt( outstr); + break; + } + } + + return out; +} + +/* + * ƥ¾ľѹ + * by ringo + * + * int charindex : ƽҷ¼ index + * + * ߯Ի + * + */ +int NPC_Util_SearchItemInChar( int charindex , int itemindex) +{ + int i; + + if( !CHAR_CHECKINDEX(charindex) ) return -2; + if( !ITEM_CHECKINDEX(itemindex) ) return -2; + + for(i=0;i<=CHAR_MAXITEMHAVE;i++){ + int ii = CHAR_getItemIndex( charindex , i ); + if( ii == itemindex ){ + return i; + } + } + return -1; +} + + +/*------------------------------------------------------------------------ +* +* int NPC_Util_GetDirCharToChar( int fromindex, int toindex, int mode) +* +* int fromindex ƽҷindex +* 0:toindexȻ +* +------------------------------------------------------------------------*/ +int NPC_Util_GetDirCharToChar( int fromindex, int toindex, int mode) +{ + int ret = -1; + + if( CHAR_getInt( fromindex, CHAR_FLOOR) + == CHAR_getInt( toindex, CHAR_FLOOR)) + { + POINT start,end; + int dir; + start.x = CHAR_getInt( fromindex, CHAR_X); + start.y = CHAR_getInt( fromindex, CHAR_Y); + end.x = CHAR_getInt( toindex, CHAR_X); + end.y = CHAR_getInt( toindex, CHAR_Y); + dir = NPC_Util_getDirFromTwoPoint( &start,&end ); + if( mode == 1 ) dir = (dir > 3)? dir -4 : dir +4; + else if( mode == 2) dir = (dir + 2) % 8; + else if( mode == 3) dir = (dir < 1)? dir +6 : dir -2; + ret = dir; + } + return( ret); +} + +/*------------------------------------------------------------------------ +* +* int NPC_Util_WalkCharToChar( int fromindex, int toindex, int mode) +* +* 0:toindexȻ +* +------------------------------------------------------------------------*/ +int NPC_Util_WalkCharToChar( int fromindex, int toindex, int mode, int suberi) +{ + int ret = -1; + int dir; + + if( CHAR_getInt( fromindex, CHAR_FLOOR) + != CHAR_getInt( toindex, CHAR_FLOOR)) + { + return( -1); + } + dir = NPC_Util_GetDirCharToChar( fromindex, toindex, mode ); + if( dir != -1) { + if( suberi) { + dir = NPC_Util_SuberiWalk( fromindex, dir ); + } + } + if( dir >= 0 ) { + ret = CHAR_walk(fromindex,dir,0); + if( ret == CHAR_WALKSUCCESSED ) ret = dir; + else ret = -1; + } + return( ret); +} + + +/*------------------------------------------------------------------------ +* +* void NPC_Util_NPCDelete( int srcindex) +* +* int srcindex index +* +------------------------------------------------------------------------*/ +void NPC_Util_NPCDelete( int srcindex) +{ + //int objindex; + //objindex = CHAR_getWorkInt(srcindex,CHAR_WORKOBJINDEX); + + if( CHAR_getInt( srcindex, CHAR_WHICHTYPE) == CHAR_TYPEPLAYER ) return; + if( NPC_createCheckMaxEnemynum( CHAR_getInt(srcindex,CHAR_NPCCREATEINDEX ))) + NPC_createInitTime( CHAR_getInt(srcindex,CHAR_NPCCREATEINDEX )); + NPC_createDecreaseEnemynum( CHAR_getInt(srcindex, + CHAR_NPCCREATEINDEX ) ); + + CHAR_CharaDelete( srcindex ); + +} + +char *NPC_Util_CheckAssignArgFile( int index, char *filename) +{ + BOOL rc; + int i; + char *cret = NULL; + char outstr[64]; + char outstr2[64]; + char *a = CHAR_getChar( index , CHAR_NPCARGUMENT ); + + if( a == NULL ) { + print( "%s : %d err\n", __FILE__, __LINE__); + return cret; + } + + for( i = 1; ; i++ ) { + rc = getStringFromIndexWithDelim( a, "|", i, outstr, sizeof(outstr)); + if( rc == FALSE) break; + if( strstr( outstr, "file") != NULL ) { + rc = getStringFromIndexWithDelim( outstr, ":", 2, + outstr2, sizeof(outstr2)); + if( rc != FALSE ) { + strcpy( filename, outstr2); + cret = filename; + break; + } + } + } + return( cret); +} + +static char *NPC_Util_MargeStrFromArgFile( char *filename, char *buf, int len) +{ + FILE *fp; + char *cret = NULL; + char line[NPC_UTIL_GETARGSTR_LINEMAX]; + char opfile[256]; + + sprintf( opfile, "%s/", getNpcdir( ) ); + strcat( opfile, filename); + *buf = '\0'; + fp = fopen( opfile, "r"); + if( fp != NULL ) { + while( fgets( line, sizeof( line), fp)) { + if( strlen(buf) != 0 ) { + if( buf[strlen(buf) -1] != '|' ) { + strcatsafe( buf, len, "|"); + } + } + chompex( line); + strcatsafe( buf,len, line); + } + fclose( fp); + cret=buf; + } + return cret; +} + +char *NPC_Util_GetArgStr( int index, char *argstr, int len) +{ + char filename[128]; + char *cret = NULL; + char errbuf[32]; + if( NPC_Util_CheckAssignArgFile( index, filename) != NULL ) { + strcpy(filename,NPC_Util_CheckAssignArgFile( index, filename)); + cret = NPC_Util_MargeStrFromArgFile( filename, argstr, len); +// if( NPC_Util_MargeStrFromArgFile( filename, argstr, len) != NULL ) { +// cret = argstr; +// } + }else { + if( CHAR_getChar( index, CHAR_NPCARGUMENT) != NULL ){ + strcpy( argstr, CHAR_getChar( index, CHAR_NPCARGUMENT)); + cret = argstr; + }else{ + cret = NULL; + } + } + if( cret == NULL ) print("File:%s\n", NPC_Util_CheckAssignArgFile( index, filename)); + + return( cret); +} + +int NPC_Util_GetNumFromStrWithDelim( char *srcstr, char* in) +{ + BOOL rc; + int i; + char outstr[32]; + int out = -1; + + for( i = 1; ; i++ ) { + rc = getStringFromIndexWithDelim( srcstr, "|", i, outstr, sizeof(outstr)); + if( rc == FALSE) break; + if( strstr( outstr, in) != NULL ) { + out = textToInt( outstr); + break; + } + } + + return out; +} + +char *NPC_Util_GetStrFromStrWithDelim( char *srcstr, char *srhstr, + char *buf, int buflen) +{ + BOOL rc; + char *cret = NULL; + int i; + char outstr[1024]; + char outstr2[1024]; + + memset( outstr, 0, sizeof( outstr)); + memset( outstr2, 0, sizeof( outstr2)); + buf[0] = '\0'; + for( i = 1; ; i++ ) { + rc = getStringFromIndexWithDelim( srcstr, "|", i, outstr, sizeof(outstr)); + if( rc == FALSE) break; + if( strstr( outstr, srhstr) != NULL) { + rc = getStringFromIndexWithDelim( outstr, ":", 2, outstr2, sizeof(outstr2)); + if( rc != FALSE ) { + strcpysafe( buf, buflen, outstr2 ); + cret = buf; + break; + } + } + } + return cret; +} + +inline double NPC_Util_sellRate( int seller ) +{ + return (CHAR_getInt( seller, CHAR_MERCHANTLEVEL)&0x0000ffff)*0.01; +} + +inline double NPC_Util_buyRate( int buyer ) +{ + return (CHAR_getInt( buyer, CHAR_MERCHANTLEVEL )>>16)*0.01; +} + +BOOL NPC_Util_IsVisiblePlayer( int meindex) +{ + int chr_fl,chr_x,chr_y, i, j; + BOOL found = FALSE; + + chr_fl = CHAR_getInt( meindex, CHAR_FLOOR); + chr_x = CHAR_getInt( meindex, CHAR_X); + chr_y = CHAR_getInt( meindex, CHAR_Y); + + for( i = chr_x-CHAR_DEFAULTSEESIZ/2 ; + i <= chr_x+CHAR_DEFAULTSEESIZ/2 && found == FALSE; i++ ){ + for( j = chr_y-CHAR_DEFAULTSEESIZ/2 ; + j <= chr_y+CHAR_DEFAULTSEESIZ/2 && found == FALSE; + j ++ ){ + OBJECT object; + for( object = MAP_getTopObj( chr_fl, i,j); + object; + object = NEXT_OBJECT(object) ) + { + int objindex = GET_OBJINDEX( object); + if( OBJECT_getType(objindex) == OBJTYPE_CHARA ){ + if( CHAR_getInt( OBJECT_getIndex(objindex), + CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER ) + { + found = TRUE; + break; + } + } + } + } + } + return( found); +} + +BOOL NPC_Util_WordInclude( char *text , char *word ) +{ + if( strstr( text , word ) == NULL ){ + return FALSE; + } else { + return TRUE; + } +} + +void NPC_Util_RandomToken(char *in, char *out, int outbufsize ) +{ + int tokennum; + int i; + tokennum = 1; + for( i=0;in[i]!='\0';i++ ){ + if( in[i] == ',' ) tokennum++; + } + getStringFromIndexWithDelim(in,",", rand()%tokennum+1,out,outbufsize ); + +} + +void cutDotsTail( char *s ) +{ + int l = strlen( s ); + int i; + for(i=l-1;i>=0;i--){ + if( s[i] == '.' ){ + s[i] = 0; + } else { + break; + } + } +} + +int NPC_Util_FrontItem( int meindex ) +{ + int front_x, front_y,objindex,itemindex; + OBJECT obj; + + CHAR_getCoordinationDir( CHAR_getInt(meindex,CHAR_DIR) + , CHAR_getInt(meindex,CHAR_X) + , CHAR_getInt(meindex,CHAR_Y) + ,1, &front_x, &front_y ); + for( obj=MAP_getTopObj(CHAR_getInt(meindex,CHAR_FLOOR), + front_x,front_y );obj; + obj=NEXT_OBJECT(obj) ){ + objindex = GET_OBJINDEX(obj); + if( OBJECT_getType(objindex) == OBJTYPE_ITEM ){ + itemindex = OBJECT_getIndex(objindex); + if(ITEM_CHECKINDEX(itemindex) ){ + return itemindex; + }else{ + return -1; + } + } + } + + return -1; + +} + +int NPC_Util_FrontChar( int meindex ) +{ + int front_x, front_y,objindex,enemyindex; + OBJECT obj; + CHAR_getCoordinationDir( CHAR_getInt(meindex,CHAR_DIR) + , CHAR_getInt(meindex,CHAR_X) + , CHAR_getInt(meindex,CHAR_Y) + ,1, &front_x, &front_y ); + for( obj=MAP_getTopObj(CHAR_getInt(meindex,CHAR_FLOOR), + front_x,front_y );obj; + obj=NEXT_OBJECT(obj) ){ + objindex = GET_OBJINDEX(obj); + if( OBJECT_getType(objindex) == OBJTYPE_CHARA ){ + enemyindex = OBJECT_getIndex(objindex); + if(CHAR_CHECKINDEX(enemyindex) ){ + return enemyindex; + } + } + } + return -1; +} +static int NPCUtil_enemytbl[NPC_ENEMY_ENEMYNUMBER+1]; +int *NPC_Util_getEnemy( int meindex, int charaindex) +{ + int i; + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + char buf[64]; + int ret; + int bigcnt; + int insert; + + NPC_Util_GetArgStr( meindex, argstr, sizeof( argstr)); + for( i = 0; i < NPC_ENEMY_ENEMYNUMBER+1; i ++ ) { + NPCUtil_enemytbl[i] = -1; + } + + if( NPC_Util_GetStrFromStrWithDelim( argstr, "enemyno", buf, sizeof( buf)) + == NULL ) + { + return NULL; + } + bigcnt = 0; + insert = 0; + + for( i = 0; i < NPC_ENEMY_ENEMYNUMBER; i ++ ) { + int curEnemy; + int et_array; + char data[128]; + + ret = getStringFromIndexWithDelim( buf,",", i + 1,data, sizeof(data)); + if( ret == FALSE) { + break; + } + + curEnemy = ENEMY_getEnemyArrayFromId( atoi( data)); + if( !ENEMY_CHECKINDEX( curEnemy) ) continue; + et_array = ENEMYTEMP_getEnemyTempArray( curEnemy ); + if( ENEMYTEMP_getInt( et_array, E_T_SIZE ) == E_T_SIZE_BIG) { + if( bigcnt >= 5 ) { + continue; + } + if( insert > 4 ) { + int target_et_array; + int flg = FALSE; + int j; + for( j = 0; j < 5; j ++ ) { + /* л¼ƾ */ + if( !ENEMY_CHECKINDEX( NPCUtil_enemytbl[j])) break; + + target_et_array = ENEMYTEMP_getEnemyTempArray( + NPCUtil_enemytbl[j]); + /* ƾ */ + if( !ENEMYTEMP_CHECKINDEX( target_et_array)) break; + + if( ENEMYTEMP_getInt( target_et_array, E_T_SIZE) + == E_T_SIZE_NORMAL ) + { + flg = TRUE; + break; + } + } + if( !flg) continue; + + NPCUtil_enemytbl[insert] = NPCUtil_enemytbl[j]; + NPCUtil_enemytbl[j] = curEnemy; + } + else { + NPCUtil_enemytbl[insert] = curEnemy; + } + bigcnt ++; + } + else { + NPCUtil_enemytbl[insert] = curEnemy; + } + insert ++; + } + return NPCUtil_enemytbl; +} + + +void NPC_EventSetFlg(int talker,int shiftbit) + +{ + int point=0; + int array; + int shift; +#ifdef _TEACHER_SYSTEM + int iGetFame = 0; +#endif + + /*-- -1׷º绥ئì -*/ + if(shiftbit==-1) return; + if(shiftbit<=255){ + array = shiftbit / 32; + shift = shiftbit % 32; + + point = CHAR_getInt( talker, CHAR_ENDEVENT+array); + + // Arminius 8.24 prevent wash dp + if (!(point & (1 << shift))) { + // CoolFish: Family Adv 2001/8/4 + AddFMAdv(talker, shiftbit); +#ifdef _TEACHER_SYSTEM + if(shiftbit < arraysizeof(FMAdvTbl)){ + if (getPetUpGetExp()!=2){ + iGetFame = FMAdvTbl[shiftbit]; + }else{ + iGetFame = 0; + } + } +#endif + } +#ifdef _TEACHER_SYSTEM + iGetFame /= 20; // ʦѧ 5% (1/20) + // õûд0 + if(iGetFame > 0){ + // ûеʦ + if(strlen(CHAR_getChar(talker,CHAR_TEACHER_ID)) > 0 && strlen(CHAR_getChar(talker,CHAR_TEACHER_NAME)) > 0){ + int iPlayernum = CHAR_getPlayerMaxNum(),i; + char szMsg[128]; + + // 鵼ʦڲ + for(i=0;i= arraysizeof(FMAdvTbl)) + return; + else{ + if (getPetUpGetExp()!=2){ + fmadv = FMAdvTbl[shiftbit]; + }else{ + fmadv = 0; + } + } + if (fmadv <= 0) return; + sprintf(buf, "%d", fmadv); + #ifdef _PERSONAL_FAME // Arminius 8.30: + CHAR_earnFame(talker, fmadv); + #endif + #ifdef _NEW_MANOR_LAW + sprintf(buf1, "%d", CHAR_getInt(talker,CHAR_FAME)); + #endif +#ifdef _FMVER21 + if (CHAR_getInt(talker, CHAR_FMLEADERFLAG) > 0 + && CHAR_getInt(talker, CHAR_FMLEADERFLAG) != FMMEMBER_APPLY) + { + // CoolFish: 2001/10/03 + int fd = getfdFromCharaIndex(talker); + saacproto_ACFixFMData_send(acfd, + CHAR_getChar(talker, CHAR_FMNAME), + CHAR_getInt(talker, CHAR_FMINDEX), + CHAR_getWorkInt(talker, CHAR_WORKFMINDEXI), + FM_FIX_FMADV, buf, +#ifndef _NEW_MANOR_LAW + "", +#else + buf1, +#endif + // CoolFish: 2001/10/03 + CHAR_getWorkInt(talker, CHAR_WORKFMCHARINDEX), + CONNECT_getFdid(fd)); + // CHAR_getWorkInt(talker, CHAR_WORKFMCHARINDEX), 0); +#ifdef _NEW_MANOR_LAW + { + int i; + for(i=0;i +#include + +#include "version.h" +#include "char.h" +#include "common.h" +#include "npctemplate.h" +#include "npccreate.h" +#include "battle.h" +#include "configfile.h" + +BOOL NPC_readNPCSettingFiles( char* topdirectory ,int templatesize, int createsize) +{ + print("\n"); + if( NPC_readNPCTemplateFiles( topdirectory ,templatesize) == FALSE ) + return FALSE; + + if( NPC_readNPCCreateFiles( topdirectory ,createsize) == FALSE ) + return FALSE; + + return TRUE; +} + +BOOL NPC_reloadNPC(void) +{ + int i; + int charnum = getFdnum()+ getPetcharnum()+getOtherscharnum(); + for(i=0;iMakefile + $(CC) $(INCFLAGS) -M $(SRC) >> Makefile + +clean: + $(RM) $(PROG) + $(RM) $(OBJ) + $(RM) *~ + +distclean: + $(RM) $(PROG) + $(RM) $(OBJ) + $(RM) *~ + $(MV) Makefile Makefile.bak + $(SED) -ne '1,/^# DO NOT DELETE THIS LINE/p' Makefile.bak>Makefile + $(RM) Makefile.bak + +# DO NOT DELETE THIS LINE +npc_lua.o: npc_lua.c ../include/npc_lua.h ../include/npc_lua_interface.h \ + ../include/version.h ../include/sasql.h /usr/include/stdio.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/common.h \ + ../include/../lua/lua.h ../include/../lua/luaconf.h \ + ../include/../lua/lauxlib.h ../include/../lua/lua.h \ + /usr/include/assert.h ../include/util.h ../include/char.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + ../include/title.h ../include/addressbook.h ../include/net.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/lauxlib.h ../include/lualib.h ../include/char_data.h \ + ../include/item.h ../include/char.h ../include/char_base.h \ + ../include/char_data.h ../include/anim_tbl.h ../include/object.h \ + ../include/battle.h ../include/npcutil.h ../include/item.h \ + ../include/readmap.h +npc_lua_ex.o: npc_lua_ex.c ../include/npc_lua.h \ + ../include/npc_lua_interface.h ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/common.h \ + ../include/../lua/lua.h ../include/../lua/luaconf.h \ + ../include/../lua/lauxlib.h ../include/../lua/lua.h \ + /usr/include/assert.h ../include/util.h ../include/char.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + ../include/title.h ../include/addressbook.h ../include/net.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/lauxlib.h ../include/lualib.h ../include/char_data.h \ + ../include/item.h ../include/char.h ../include/char_base.h \ + ../include/anim_tbl.h ../include/object.h ../include/net.h \ + ../include/npcutil.h ../include/npc_eventaction.h ../include/battle.h \ + ../include/readmap.h +npc_lua_item.o: npc_lua_item.c ../include/npc_lua.h \ + ../include/npc_lua_interface.h ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/common.h \ + ../include/../lua/lua.h ../include/../lua/luaconf.h \ + ../include/../lua/lauxlib.h ../include/../lua/lua.h \ + /usr/include/assert.h ../include/util.h ../include/char.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + ../include/title.h ../include/addressbook.h ../include/net.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/lauxlib.h ../include/lualib.h ../include/char_data.h \ + ../include/item.h ../include/char.h ../include/char_base.h \ + ../include/anim_tbl.h ../include/object.h ../include/net.h \ + ../include/npcutil.h ../include/npc_eventaction.h ../include/battle.h \ + ../include/readmap.h ../include/item.h +npc_lua_nlg.o: npc_lua_nlg.c ../include/npc_lua.h \ + ../include/npc_lua_interface.h ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/common.h \ + ../include/../lua/lua.h ../include/../lua/luaconf.h \ + ../include/../lua/lauxlib.h ../include/../lua/lua.h \ + /usr/include/assert.h ../include/util.h ../include/char.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + ../include/title.h ../include/addressbook.h ../include/net.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/lauxlib.h ../include/lualib.h ../include/char_data.h \ + ../include/item.h ../include/char.h ../include/char_base.h \ + ../include/anim_tbl.h ../include/object.h ../include/net.h \ + ../include/npcutil.h ../include/npc_eventaction.h ../include/battle.h \ + ../include/readmap.h ../include/configfile.h +npc_lua_nl.o: npc_lua_nl.c ../include/npc_lua.h \ + ../include/npc_lua_interface.h ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/common.h \ + ../include/../lua/lua.h ../include/../lua/luaconf.h \ + ../include/../lua/lauxlib.h ../include/../lua/lua.h \ + /usr/include/assert.h ../include/util.h ../include/char.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + ../include/title.h ../include/addressbook.h ../include/net.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/lauxlib.h ../include/lualib.h ../include/char_data.h \ + ../include/item.h ../include/char.h ../include/char_base.h \ + ../include/anim_tbl.h ../include/object.h ../include/net.h \ + ../include/npcutil.h ../include/npc_eventaction.h ../include/battle.h \ + ../include/readmap.h ../include/autil.h ../include/configfile.h +npc_lua_obj.o: npc_lua_obj.c ../include/npc_lua.h \ + ../include/npc_lua_interface.h ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/common.h \ + ../include/../lua/lua.h ../include/../lua/luaconf.h \ + ../include/../lua/lauxlib.h ../include/../lua/lua.h \ + /usr/include/assert.h ../include/util.h ../include/char.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + ../include/title.h ../include/addressbook.h ../include/net.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/lauxlib.h ../include/lualib.h ../include/char_data.h \ + ../include/item.h ../include/char.h ../include/char_base.h \ + ../include/anim_tbl.h ../include/object.h ../include/net.h \ + ../include/npcutil.h ../include/npc_eventaction.h ../include/battle.h \ + ../include/readmap.h +npc_lua_char.o: npc_lua_char.c ../include/npc_lua.h \ + ../include/npc_lua_interface.h ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/common.h \ + ../include/../lua/lua.h ../include/../lua/luaconf.h \ + ../include/../lua/lauxlib.h ../include/../lua/lua.h \ + /usr/include/assert.h ../include/util.h ../include/char.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + ../include/title.h ../include/addressbook.h ../include/net.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/lauxlib.h ../include/lualib.h ../include/char_data.h \ + ../include/item.h ../include/char.h ../include/char_base.h \ + ../include/anim_tbl.h ../include/object.h ../include/net.h \ + ../include/npcutil.h ../include/npc_eventaction.h ../include/battle.h \ + ../include/readmap.h ../include/sasql.h ../include/pet_skill.h \ + ../include/enemy.h ../include/family.h +npc_lua_battle.o: npc_lua_battle.c ../include/npc_lua.h \ + ../include/npc_lua_interface.h ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/common.h \ + ../include/../lua/lua.h ../include/../lua/luaconf.h \ + ../include/../lua/lauxlib.h ../include/../lua/lua.h \ + /usr/include/assert.h ../include/util.h ../include/char.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + ../include/title.h ../include/addressbook.h ../include/net.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/lauxlib.h ../include/lualib.h ../include/char_data.h \ + ../include/item.h ../include/char.h ../include/char_base.h \ + ../include/anim_tbl.h ../include/object.h ../include/net.h \ + ../include/npcutil.h ../include/npc_eventaction.h ../include/battle.h \ + ../include/readmap.h +npc_lua_game.o: npc_lua_game.c ../include/npc_lua.h \ + ../include/npc_lua_interface.h ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/common.h \ + ../include/../lua/lua.h ../include/../lua/luaconf.h \ + ../include/../lua/lauxlib.h ../include/../lua/lua.h \ + /usr/include/assert.h ../include/util.h ../include/char.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + ../include/title.h ../include/addressbook.h ../include/net.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/lauxlib.h ../include/lualib.h ../include/char_data.h \ + ../include/item.h ../include/char.h ../include/char_base.h \ + ../include/char_data.h ../include/anim_tbl.h ../include/object.h \ + ../include/battle.h ../include/npcutil.h ../include/item.h \ + ../include/readmap.h ../include/saacproto_cli.h \ + ../include/saacproto_util.h ../include/family.h +npc_lua_map.o: npc_lua_map.c ../include/npc_lua.h \ + ../include/npc_lua_interface.h ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/common.h \ + ../include/../lua/lua.h ../include/../lua/luaconf.h \ + ../include/../lua/lauxlib.h ../include/../lua/lua.h \ + /usr/include/assert.h ../include/util.h ../include/char.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + ../include/title.h ../include/addressbook.h ../include/net.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/lauxlib.h ../include/lualib.h ../include/char_data.h \ + ../include/item.h ../include/char.h ../include/char_base.h \ + ../include/anim_tbl.h ../include/object.h ../include/net.h \ + ../include/npcutil.h ../include/npc_eventaction.h ../include/battle.h \ + ../include/readmap.h ../include/item.h +npc_lua_spell.o: npc_lua_spell.c ../include/npc_lua.h \ + ../include/npc_lua_interface.h ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/common.h \ + ../include/../lua/lua.h ../include/../lua/luaconf.h \ + ../include/../lua/lauxlib.h ../include/../lua/lua.h \ + /usr/include/assert.h ../include/util.h ../include/char.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + ../include/title.h ../include/addressbook.h ../include/net.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/lauxlib.h ../include/lualib.h ../include/char_data.h \ + ../include/item.h ../include/char.h ../include/char_base.h \ + ../include/anim_tbl.h ../include/object.h ../include/net.h \ + ../include/npcutil.h ../include/npc_eventaction.h ../include/battle.h \ + ../include/readmap.h ../include/pet_skill.h \ + ../include/profession_skill.h ../include/magic_base.h +npc_lua_sql.o: npc_lua_sql.c ../include/npc_lua.h \ + ../include/npc_lua_interface.h ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/common.h \ + ../include/../lua/lua.h ../include/../lua/luaconf.h \ + ../include/../lua/lauxlib.h ../include/../lua/lua.h \ + /usr/include/assert.h ../include/util.h ../include/char.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + ../include/title.h ../include/addressbook.h ../include/net.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/lauxlib.h ../include/lualib.h ../include/char_data.h \ + ../include/item.h ../include/char.h ../include/char_base.h \ + ../include/char_data.h ../include/anim_tbl.h ../include/object.h \ + ../include/battle.h ../include/npcutil.h ../include/item.h \ + ../include/readmap.h ../include/sasql.h diff --git a/npc_lua/Makefile.bak b/npc_lua/Makefile.bak new file mode 100644 index 0000000..bf1a72a --- /dev/null +++ b/npc_lua/Makefile.bak @@ -0,0 +1,654 @@ +INCFLAGS=-I. -I../include +FLTFLAGS="-s 1331200" +export FLTFLAGS + +#CFLAGS=-w -O3 -g $(INCFLAGS) +#CHOST="i686-pc-linux-gnu" +#CFLAGS=-march=pentium4 -w -O3 -pipe -mmmx -msse -msse2 $(INCFLAGS) +#CXXFLAGS="-march=pentium4 -O3 -pipe -fomit-frame-pointer" +CFLAGS=-w -O3 -pipe $(INCFLAGS) + +PROG=libnpc_lua.a + +SRC=npc_lua.c npc_lua_ex.c npc_lua_item.c npc_lua_nlg.c npc_lua_nl.c npc_lua_obj.c npc_lua_char.c npc_lua_battle.c npc_lua_game.c npc_lua_map.c npc_lua_spell.c npc_lua_sql.c + +OBJ=$(SRC:.c=.o) + +ifeq (0,$(MAKELEVEL)) +CC=gcc +RM=rm -f +AR=ar cr +MV=mv +RANLIB=ranlib +SED=sed +SHELL=/bin/sh +endif + +all: $(PROG) +$(PROG): $(OBJ) + $(RM) $(PROG) + $(AR) $(PROG) $(OBJ) + $(RANLIB) $(PROG) + +depend: + $(MV) Makefile Makefile.bak + $(SED) -ne '1,/^# DO NOT DELETE THIS LINE/p' Makefile.bak>Makefile + $(CC) $(INCFLAGS) -M $(SRC) >> Makefile + +clean: + $(RM) $(PROG) + $(RM) $(OBJ) + $(RM) *~ + +distclean: + $(RM) $(PROG) + $(RM) $(OBJ) + $(RM) *~ + $(MV) Makefile Makefile.bak + $(SED) -ne '1,/^# DO NOT DELETE THIS LINE/p' Makefile.bak>Makefile + $(RM) Makefile.bak + +# DO NOT DELETE THIS LINE +npc_lua.o: npc_lua.c ../include/npc_lua.h ../include/npc_lua_interface.h \ + ../include/version.h ../include/sasql.h /usr/include/stdio.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/common.h \ + ../include/../lua/lua.h ../include/../lua/luaconf.h \ + ../include/../lua/lauxlib.h ../include/../lua/lua.h \ + /usr/include/assert.h ../include/util.h ../include/char.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + ../include/title.h ../include/addressbook.h ../include/net.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/lauxlib.h ../include/lualib.h ../include/char_data.h \ + ../include/item.h ../include/char.h ../include/char_base.h \ + ../include/char_data.h ../include/anim_tbl.h ../include/object.h \ + ../include/battle.h ../include/npcutil.h ../include/item.h \ + ../include/readmap.h +npc_lua_ex.o: npc_lua_ex.c ../include/npc_lua.h \ + ../include/npc_lua_interface.h ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/common.h \ + ../include/../lua/lua.h ../include/../lua/luaconf.h \ + ../include/../lua/lauxlib.h ../include/../lua/lua.h \ + /usr/include/assert.h ../include/util.h ../include/char.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + ../include/title.h ../include/addressbook.h ../include/net.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/lauxlib.h ../include/lualib.h ../include/char_data.h \ + ../include/item.h ../include/char.h ../include/char_base.h \ + ../include/anim_tbl.h ../include/object.h ../include/net.h \ + ../include/npcutil.h ../include/npc_eventaction.h ../include/battle.h \ + ../include/readmap.h +npc_lua_item.o: npc_lua_item.c ../include/npc_lua.h \ + ../include/npc_lua_interface.h ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/common.h \ + ../include/../lua/lua.h ../include/../lua/luaconf.h \ + ../include/../lua/lauxlib.h ../include/../lua/lua.h \ + /usr/include/assert.h ../include/util.h ../include/char.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + ../include/title.h ../include/addressbook.h ../include/net.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/lauxlib.h ../include/lualib.h ../include/char_data.h \ + ../include/item.h ../include/char.h ../include/char_base.h \ + ../include/anim_tbl.h ../include/object.h ../include/net.h \ + ../include/npcutil.h ../include/npc_eventaction.h ../include/battle.h \ + ../include/readmap.h ../include/item.h +npc_lua_nlg.o: npc_lua_nlg.c ../include/npc_lua.h \ + ../include/npc_lua_interface.h ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/common.h \ + ../include/../lua/lua.h ../include/../lua/luaconf.h \ + ../include/../lua/lauxlib.h ../include/../lua/lua.h \ + /usr/include/assert.h ../include/util.h ../include/char.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + ../include/title.h ../include/addressbook.h ../include/net.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/lauxlib.h ../include/lualib.h ../include/char_data.h \ + ../include/item.h ../include/char.h ../include/char_base.h \ + ../include/anim_tbl.h ../include/object.h ../include/net.h \ + ../include/npcutil.h ../include/npc_eventaction.h ../include/battle.h \ + ../include/readmap.h ../include/configfile.h +npc_lua_nl.o: npc_lua_nl.c ../include/npc_lua.h \ + ../include/npc_lua_interface.h ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/common.h \ + ../include/../lua/lua.h ../include/../lua/luaconf.h \ + ../include/../lua/lauxlib.h ../include/../lua/lua.h \ + /usr/include/assert.h ../include/util.h ../include/char.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + ../include/title.h ../include/addressbook.h ../include/net.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/lauxlib.h ../include/lualib.h ../include/char_data.h \ + ../include/item.h ../include/char.h ../include/char_base.h \ + ../include/anim_tbl.h ../include/object.h ../include/net.h \ + ../include/npcutil.h ../include/npc_eventaction.h ../include/battle.h \ + ../include/readmap.h ../include/autil.h ../include/configfile.h +npc_lua_obj.o: npc_lua_obj.c ../include/npc_lua.h \ + ../include/npc_lua_interface.h ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/common.h \ + ../include/../lua/lua.h ../include/../lua/luaconf.h \ + ../include/../lua/lauxlib.h ../include/../lua/lua.h \ + /usr/include/assert.h ../include/util.h ../include/char.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + ../include/title.h ../include/addressbook.h ../include/net.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/lauxlib.h ../include/lualib.h ../include/char_data.h \ + ../include/item.h ../include/char.h ../include/char_base.h \ + ../include/anim_tbl.h ../include/object.h ../include/net.h \ + ../include/npcutil.h ../include/npc_eventaction.h ../include/battle.h \ + ../include/readmap.h +npc_lua_char.o: npc_lua_char.c ../include/npc_lua.h \ + ../include/npc_lua_interface.h ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/common.h \ + ../include/../lua/lua.h ../include/../lua/luaconf.h \ + ../include/../lua/lauxlib.h ../include/../lua/lua.h \ + /usr/include/assert.h ../include/util.h ../include/char.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + ../include/title.h ../include/addressbook.h ../include/net.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/lauxlib.h ../include/lualib.h ../include/char_data.h \ + ../include/item.h ../include/char.h ../include/char_base.h \ + ../include/anim_tbl.h ../include/object.h ../include/net.h \ + ../include/npcutil.h ../include/npc_eventaction.h ../include/battle.h \ + ../include/readmap.h ../include/sasql.h ../include/pet_skill.h \ + ../include/enemy.h ../include/family.h +npc_lua_battle.o: npc_lua_battle.c ../include/npc_lua.h \ + ../include/npc_lua_interface.h ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/common.h \ + ../include/../lua/lua.h ../include/../lua/luaconf.h \ + ../include/../lua/lauxlib.h ../include/../lua/lua.h \ + /usr/include/assert.h ../include/util.h ../include/char.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + ../include/title.h ../include/addressbook.h ../include/net.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/lauxlib.h ../include/lualib.h ../include/char_data.h \ + ../include/item.h ../include/char.h ../include/char_base.h \ + ../include/anim_tbl.h ../include/object.h ../include/net.h \ + ../include/npcutil.h ../include/npc_eventaction.h ../include/battle.h \ + ../include/readmap.h +npc_lua_game.o: npc_lua_game.c ../include/npc_lua.h \ + ../include/npc_lua_interface.h ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/common.h \ + ../include/../lua/lua.h ../include/../lua/luaconf.h \ + ../include/../lua/lauxlib.h ../include/../lua/lua.h \ + /usr/include/assert.h ../include/util.h ../include/char.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + ../include/title.h ../include/addressbook.h ../include/net.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/lauxlib.h ../include/lualib.h ../include/char_data.h \ + ../include/item.h ../include/char.h ../include/char_base.h \ + ../include/char_data.h ../include/anim_tbl.h ../include/object.h \ + ../include/battle.h ../include/npcutil.h ../include/item.h \ + ../include/readmap.h ../include/saacproto_cli.h \ + ../include/saacproto_util.h ../include/family.h +npc_lua_map.o: npc_lua_map.c ../include/npc_lua.h \ + ../include/npc_lua_interface.h ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/common.h \ + ../include/../lua/lua.h ../include/../lua/luaconf.h \ + ../include/../lua/lauxlib.h ../include/../lua/lua.h \ + /usr/include/assert.h ../include/util.h ../include/char.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + ../include/title.h ../include/addressbook.h ../include/net.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/lauxlib.h ../include/lualib.h ../include/char_data.h \ + ../include/item.h ../include/char.h ../include/char_base.h \ + ../include/anim_tbl.h ../include/object.h ../include/net.h \ + ../include/npcutil.h ../include/npc_eventaction.h ../include/battle.h \ + ../include/readmap.h ../include/item.h +npc_lua_spell.o: npc_lua_spell.c ../include/npc_lua.h \ + ../include/npc_lua_interface.h ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/common.h \ + ../include/../lua/lua.h ../include/../lua/luaconf.h \ + ../include/../lua/lauxlib.h ../include/../lua/lua.h \ + /usr/include/assert.h ../include/util.h ../include/char.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + ../include/title.h ../include/addressbook.h ../include/net.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/lauxlib.h ../include/lualib.h ../include/char_data.h \ + ../include/item.h ../include/char.h ../include/char_base.h \ + ../include/anim_tbl.h ../include/object.h ../include/net.h \ + ../include/npcutil.h ../include/npc_eventaction.h ../include/battle.h \ + ../include/readmap.h ../include/pet_skill.h \ + ../include/profession_skill.h ../include/magic_base.h +npc_lua_sql.o: npc_lua_sql.c ../include/npc_lua.h \ + ../include/npc_lua_interface.h ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/string.h ../include/correct_bug.h ../include/common.h \ + ../include/../lua/lua.h ../include/../lua/luaconf.h \ + ../include/../lua/lauxlib.h ../include/../lua/lua.h \ + /usr/include/assert.h ../include/util.h ../include/char.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + ../include/title.h ../include/addressbook.h ../include/net.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \ + ../include/lauxlib.h ../include/lualib.h ../include/char_data.h \ + ../include/item.h ../include/char.h ../include/char_base.h \ + ../include/char_data.h ../include/anim_tbl.h ../include/object.h \ + ../include/battle.h ../include/npcutil.h ../include/item.h \ + ../include/readmap.h ../include/sasql.h diff --git a/npc_lua/ReadMe.txt b/npc_lua/ReadMe.txt new file mode 100644 index 0000000..f75dbe7 --- /dev/null +++ b/npc_lua/ReadMe.txt @@ -0,0 +1,25 @@ +======================================================================== + 静态库:npc_lua 项目概述 +======================================================================== + +应用程序向导已为您创建了此 npc_lua 库项目。 + +本文件概要介绍组成 npc_lua 应用程序的每个文件的内容。 + + +npc_lua.vcproj + 这是使用应用程序向导生成的 VC++ 项目的主项目文件, + 其中包含生成该文件的 Visual C++ 的版本信息,以及有关使用应用程序向导选择的平台、配置和项目功能的信息。 + + +///////////////////////////////////////////////////////////////////////////// + +StdAfx.h, StdAfx.cpp + 这些文件用于生成名为 npc_lua.pch 的预编译头 (PCH) 文件和名为 StdAfx.obj 的预编译类型文件。 + +///////////////////////////////////////////////////////////////////////////// +其他注释: + +应用程序向导使用“TODO:”注释来指示应添加或自定义的源代码部分。 + +///////////////////////////////////////////////////////////////////////////// \ No newline at end of file diff --git a/npc_lua/npc_lua.c b/npc_lua/npc_lua.c new file mode 100644 index 0000000..aaa7eea --- /dev/null +++ b/npc_lua/npc_lua.c @@ -0,0 +1,2325 @@ +#include "npc_lua.h" +#include "util.h" +#include "char.h" +#include "char_base.h" +#include "char_data.h" +#include "anim_tbl.h" +#include "object.h" +#include "battle.h" +#include "npcutil.h" +#include "item.h" +#include "readmap.h" + +#ifdef _JZ_NEWSCRIPT_LUA + +typedef enum +{ + LUAITEM_PREOVERFUNC = ITEM_PREOVERFUNC - ITEM_FIRSTFUNCTION, + LUAITEM_POSTOVERFUNC = ITEM_POSTOVERFUNC - ITEM_FIRSTFUNCTION, + LUAITEM_WATCHFUNC = ITEM_WATCHFUNC - ITEM_FIRSTFUNCTION, + LUAITEM_USEFUNC = ITEM_USEFUNC - ITEM_FIRSTFUNCTION, + LUAITEM_ATTACHFUNC = ITEM_ATTACHFUNC - ITEM_FIRSTFUNCTION, + LUAITEM_DETACHFUNC = ITEM_DETACHFUNC - ITEM_FIRSTFUNCTION, + LUAITEM_DROPFUNC = ITEM_DROPFUNC - ITEM_FIRSTFUNCTION, + LUAITEM_PICKUPFUNC = ITEM_PICKUPFUNC - ITEM_FIRSTFUNCTION, +#ifdef _Item_ReLifeAct + LUAITEM_DIERELIFEFUNC = ITEM_DIERELIFEFUNC - ITEM_FIRSTFUNCTION, +#endif +}LUAITEM_FUNC; + +lua_State *M_Script_Lua = NULL; //ʵ +unsigned int M_Create_Num = 0; +char M_OutErrMsg[1024]; + +extern lua_const M_Lua_RegConstList[]; + +static luaL_Reg M_RegList[] = { + {NULL, NULL}, +}; + +static luaL_Reg Bit_RegList[] = { + {"band", NPC_Lua_Bit_band}, + {"bor", NPC_Lua_Bit_bor}, + {"bxor", NPC_Lua_Bit_bxor}, + {"lshift", NPC_Lua_Bit_lshift}, + {"rshift", NPC_Lua_Bit_rshift}, + {NULL, NULL}, +}; + +static luaL_Reg Map_RegList[] = { + {"CheckCoordinates",NPC_Lua_Map_CheckCoordinates}, + {"GetExitFloorXY",NPC_Lua_Map_GetExitFloorXY}, + {"GetfloorX",NPC_Lua_Map_GetfloorX}, + {"GetfloorY",NPC_Lua_Map_GetfloorY}, + {"GetTileAndObjId",NPC_Lua_Map_GetTileAndObjId}, + {"SetTileAndObjId",NPC_Lua_Map_SetTileAndObjId}, + {"GetWalkAbleFromPoint",NPC_Lua_Map_GetWalkAbleFromPoint}, + {"GetImageData",NPC_Lua_Map_GetImageData}, + {"SetImageData",NPC_Lua_Map_SetImageData}, + {"GetTopObj",NPC_Lua_Map_GetTopObj}, + {"GetNextObj",NPC_Lua_Map_GetNextObj}, + {"CheckImageIndex",NPC_Lua_Map_CheckImageIndex}, + {"CheckIndex",NPC_Lua_Map_CheckIndex}, + {"MakeNewMap",NPC_Lua_Map_MakeNewMap}, + {"DelNewMap",NPC_Lua_Map_DelNewMap}, + {"SetExWarp",NPC_Lua_Map_SetExWarp}, + {"SetMapPoint",NPC_Lua_Map_SetMapPoint}, + {"DelMapPoint",NPC_Lua_Map_DelMapPoint}, + {"getFloorName",NPC_Lua_Map_getFloorName}, + {"UpMap",NPC_Lua_Map_Upmap}, + {NULL, NULL}, +}; + +static luaL_Reg Spell_RegList[] = { + {"PETSKILL_GetData",NPC_Lua_Spell_PETSKILL_GetData}, + {"PROFESSION_GetData",NPC_Lua_Spell_PROFESSION_GetData}, + {"MAGIC_GetData",NPC_Lua_Spell_MAGIC_GetData}, + {"PETSKILL_SetData",NPC_Lua_Spell_PETSKILL_SetData},//δ + {"PROFESSION_SetData",NPC_Lua_Spell_PROFESSION_SetData},//δ + {"MAGIC_SetData",NPC_Lua_Spell_MAGIC_SetData},//δ + {NULL, NULL}, +}; + +static luaL_Reg NL_RegList[] = { +//NL + {"GetErrorStr", NPC_Lua_NL_GetErrorStr}, + {"CreateNpc", NPC_Lua_NL_CreateNpc}, + {"DelNpc", NPC_Lua_NL_DelNpc}, + {"GetStringFromIndexWithDelim", NPC_Lua_NL_GetStringFromIndexWithDelim},//ַ + {"ANSI_PlayerLoop", NPC_Lua_NL_ANSI_PlayerLoop},//߳ + {"PetLoopGetNext", NPC_Lua_NL_PetLoopGetNext},//߳ + {"ItemLoopGetNext", NPC_Lua_NL_ItemLoopGetNext},//е + {"PlayerLoopGetNext", NPC_Lua_NL_PlayerLoopGetNext},// + {"GetConfigLineType", NPC_Lua_NL_GetConfigLineType},//CFֶ + {"GetConfigLineVal", NPC_Lua_NL_GetConfigLineVal},//CFֵֶ + {"CheckNpcEventFree", NPC_Lua_CheckNpcEventFree},//ʹNPCű + {"DoNpcEventAction", NPC_Lua_DoNpcEventAction},//ʹNPCű + {"SetTimer", NPC_Lua_NL_SetTimer},//趨һʱضʱID + {"DelTimer", NPC_Lua_NL_DelTimer},//ɾһʱID + {"RunSaFuncII", NPC_Lua_NL_RunSaFuncII},//һڶõ2INTĺ + {"RunSaFuncIII", NPC_Lua_NL_RunSaFuncIII},//һڶõ3INTĺ + {"ANSI_PlayerLoop", NPC_Lua_NL_ANSI_PlayerLoop},//һ (ǰظʱ + {"ANSI_PetLoop", NPC_Lua_NL_ANSI_PetLoop},//һ + {"ANSI_ItemLoop", NPC_Lua_NL_ANSI_ItemLoop},//һ) + {"ClsMk", NPC_Lua_NL_ClsMk}, + {"AddCheckNum", NPC_Lua_NL_AddCheckNum}, + {"Mkstring", NPC_Lua_NL_Mkstring}, + {"Mkint", NPC_Lua_NL_Mkint}, + {"SendMesg", NPC_Lua_NL_SendMesg}, + {"Mod",NPC_Lua_NL_Mod}, + {NULL, NULL}, +}; + +static luaL_Reg Char_RegList[] = { +//ȡݵĽӿ + {"getVipPoint", NPC_Lua_Char_getVipPoint}, + {"getjfPoint", NPC_Lua_Char_getjfPoint}, + {"getxjPoint", NPC_Lua_Char_getxjPoint}, + {"setVipPoint", NPC_Lua_Char_setVipPoint}, + {"setjfPoint", NPC_Lua_Char_setjfPoint}, + {"setxjPoint", NPC_Lua_Char_setxjPoint}, + {"IsEventEnd", NPC_Lua_Char_IsEventEnd}, + {"IsEventNow", NPC_Lua_Char_IsEventNow}, +// + {"FindItemId", NPC_Lua_Char_FindItemId}, + {"FindPetEnemyId", NPC_Lua_Char_FindPetEnemyId}, + {"GetAllocPoint",NPC_Lua_Char_GetAllocPoint}, + {"GetDataFromEnemyBase",NPC_Lua_Char_GetDataFromEnemyBase}, + {"GetPlayIndex", NPC_Lua_Char_GetPlayerIndex}, + {"FindItemIndex", NPC_Lua_Char_FindItemIndex}, + {"FindPetIndex", NPC_Lua_Char_FindPetIndex}, + {"CheckIndex",NPC_Lua_CHAR_CHECKINDEX}, + {"GetPetSkill", NPC_Lua_Char_GetPetSkill},// + {"GetPetSkillNo", NPC_Lua_Char_GetPetSkillNo},// + {"GetEmptyItemBoxNum", NPC_Lua_Char_GetEmptyItemBoxNum},// + {"GetEmptyPetBoxNum", NPC_Lua_Char_GetEmptyPetBoxNum},// + {"GetPlayerPetNum", NPC_Lua_Char_GetPlayerPetNum},// + {"GetPlayerItemNum", NPC_Lua_Char_GetPlayerItemNum},// + {"CharRidNo", NPC_Lua_Char_RidNo}, // + {"getPlayerMaxNum", NPC_ABLua_char_getPlayerMaxNum},// + {"getBattleexp", NPC_ABLua_char_getBattleexp},// + {"SetPetSkill", NPC_Lua_Char_SetPetSkill},// + {"SetPetSkillNo", NPC_Lua_Char_SetPetSkillNo},// + {"ComplianceParameter", NPC_Lua_Char_ComplianceParameter}, + {"HcItemId", NPC_Lua_Char_HcItemId}, + {"DelHcItem", NPC_Lua_Char_DelHcItem}, + {"GETFM", NPC_Lua_Char_GETFM}, + {"FindPetEnemyBaseId", NPC_Lua_Char_FindPetEnemyBaseId}, + {"ITEMID_NAME", NPC_Lua_Char_ITEMID_NAME}, + {"ITEMID_NAME2", NPC_Lua_Char_ITEMID_NAME2}, + {"ITEMID_LEVEL", NPC_Lua_Char_ITEMID_LEVEL}, + {"ITEMID_GOLD", NPC_Lua_Char_ITEMID_GOLD}, + {"ITEMID_RANO", NPC_Lua_Char_ITEMID_RANO}, +// {"CharRidNo", NPC_Lua_Char_CharRidNo}, //δͬʱر + {"GetPetOwner", NPC_Lua_Char_GetPetOwner}, + {"GetEnemyBaseIdFromEnemyId", NPC_Lua_Char_GetEnemyBaseIdFromEnemyId}, + {"GetEnemyIdFromEnemyBaseId", NPC_Lua_Char_GetEnemyIdFromEnemyBaseId}, + {"GetIp", NPC_Lua_Char_GetIp}, + {"SetAllocPoint", NPC_Lua_Char_SetAllocPoint}, + {"GetMaxPetIndex", NPC_Lua_Char_GetMaxPetIndex}, + {"GetMaxPlayerIndex", NPC_Lua_Char_GetMaxPlayerIndex}, + {"SavePetToString", NPC_Lua_Char_SavePetToString}, + {"LoadPetFromString", NPC_Lua_Char_LoadPetFromString}, + {"GetPlayerFromAccAndName", NPC_Lua_Char_GetPlayerFromAccAndName}, + {"CheckPet", NPC_Lua_Char_CheckPet}, + {"CheckPlayer", NPC_Lua_Char_CheckPlayer}, + {"JoinParty", NPC_Lua_Char_JoinParty}, + {"getFamilyPlayIndex", NPC_Lua_Char_getFamilyPlayIndex}, + + {"GetData", NPC_Lua_Char_GetData}, + {"GetItemId", NPC_Lua_Char_GetItemId}, + {"GetPetEnemyId", NPC_Lua_Char_GetPetEnemyId}, + {"GetItemIndex", NPC_Lua_Char_GetItemIndex}, + {"GetPetIndex", NPC_Lua_Char_GetPetIndex}, + {"GetTeamIndex", NPC_Lua_Char_GetTeamIndex}, + {"GetPlayerIndexByCdkey", NPC_Lua_Char_GetPlayerIndexByCdkey}, + +//ݵĽӿ + {"ClrEvtEnd", NPC_Lua_Char_ClrEvtEnd}, + {"ClrEvtNow", NPC_Lua_Char_ClrEvtNow}, + {"ClrClrEvt", NPC_Lua_Char_ClrEvt}, + {"SetEvtEnd", NPC_Lua_Char_SetEvtEnd}, + {"SetEvtNow", NPC_Lua_Char_SetEvtNow}, + {"SetData", NPC_Lua_Char_SetData}, + +//¼õĽӿ + {"SetWalkPreEvent", NPC_Lua_Char_SetWalkPreEvent}, + {"SetWalkPostEvent", NPC_Lua_Char_SetWalkPostEvent}, + {"SetPreOverEvent", NPC_Lua_Char_SetPreOverEvent}, + {"SetPostOverEvent", NPC_Lua_Char_SetPostOverEvent}, + {"SetWatchEvent", NPC_Lua_Char_SetWatchEvent}, + {"SetLoopEvent", NPC_Lua_Char_SetLoopEvent}, + {"SetTalkedEvent", NPC_Lua_Char_SetTalkedEvent}, + {"SetOFFEvent", NPC_Lua_Char_SetOFFEvent}, + {"SetLookedEvent", NPC_Lua_Char_SetLookedEvent}, + {"SetItemPutEvent", NPC_Lua_Char_SetItemPutEvent}, + {"SetWindowTalkedEvent", NPC_Lua_Char_SetWindowTalkedEvent}, +#ifdef _USER_CHARLOOPS + {"SetCharLoopsEvent", NPC_Lua_Char_SetCharLoopsEvent}, + {"SetBattleProPertyEvent", NPC_Lua_Char_SetBattleProPertyEvent}, +#endif +//Աӿ + {"VipPoint", NPC_Lua_Char_VipPoint}, + {"HealAll", NPC_Lua_Char_HealAll}, + {"GetPetSkillId", NPC_Lua_Char_GetPetSkillId}, + {"GetPetSkillName", NPC_Lua_Char_GetPetSkillName}, + {"GetPetSkillMsg", NPC_Lua_Char_GetPetSkillMsg}, + {"SetPetSkill", NPC_Lua_Char_SetPetSkill}, + {"RandMsg", NPC_Lua_Char_RandMsg}, + {"GetBeatitudeNum", NPC_Lua_Char_GetBeatitudeNum}, + {NULL, NULL}, +}; + +static luaL_Reg GAME_RegList[] = { + {"FMPOINT_GetData",NPC_Lua_Game_FMPOINT_GetData}, + {"FMPOINT_ACSetFMPoint",NPC_Lua_Game_FMPOINT_ACSetFMPoint}, + {"FMPOINT_ACFixFMPoint",NPC_Lua_Game_FMPOINT_ACFixFMPoint}, + {"FMPOINT_ACCleanFMPoint",NPC_Lua_Game_FMPOINT_ACCleanFMPoint}, + {NULL, NULL}, +}; + +static luaL_Reg Item_RegList[] = { +//ȡݵĽӿ + {"GetData", NPC_Lua_Item_GetData}, + +//ݵĽӿ + {"SetData", NPC_Lua_Item_SetData}, + {"GetDataFromItemSet", NPC_Lua_Item_GetDataFromItemSet}, +//¼õĽӿ + {"SetPreOverEvent", NPC_Lua_Item_SetPreOverEvent}, + {"SetPostOverEvent", NPC_Lua_Item_SetPostOverEvent}, + {"SetWatchEvent", NPC_Lua_Item_SetWatchEvent}, + {"SetUseEvent", NPC_Lua_Item_SetUseEvent}, + {"SetAttachEvent", NPC_Lua_Item_SetAttachEvent}, + {"SetDetachEvent", NPC_Lua_Item_SetDetachEvent}, + {"SetDropEvent", NPC_Lua_Item_SetDropEvent}, + {"SetPickUPEvent", NPC_Lua_Item_SetPickUPEvent}, +#ifdef _Item_ReLifeAct + {"SetDieReLifeEvent", NPC_Lua_Item_SetDieReLifeEvent}, +#endif + {NULL, NULL}, +}; + +static luaL_Reg Obj_RegList[] = { +//ȡݵĽӿ + {"GetType", NPC_Lua_Obj_GetType}, + {"GetCharType", NPC_Lua_Obj_GetCharType}, + {"GetCharIndex", NPC_Lua_Obj_GetCharIndex}, + {"GetX", NPC_Lua_Obj_GetX}, + {"GetY", NPC_Lua_Obj_GetY}, + {"GetFloor", NPC_Lua_Obj_GetFloor}, + +//¼õĽӿ + {"SetType", NPC_Lua_Obj_SetType}, + {"SetCharType", NPC_Lua_Obj_SetCharType}, + {"SetX", NPC_Lua_Obj_SetX}, + {"SetY", NPC_Lua_Obj_SetY}, + {"SetFloor", NPC_Lua_Obj_SetFloor}, + {NULL, NULL}, +}; + +static luaL_Reg Battle_RegList[] = { +//ȡݵĽӿ + {"GetPlayIndex", NPC_Lua_Battle_GetPlayIndex}, + {"GetData", NPC_Lua_Battle_GetData}, + {"IndexToNo", NPC_Lua_Battle_IndexToNo}, + {"NoToIndex", NPC_Lua_Battle_NoToIndex}, + {"CheckIndex", NPC_Lua_Battle_CheckIndex}, +//ݵĽӿ + {"SetNORisk", NPC_Lua_Battle_SetNORisk}, + {"SetMod", NPC_Lua_Battle_SetMod}, + {"SetType", NPC_Lua_Battle_SetType}, + {"SetData", NPC_Lua_Battle_SetData}, + {"Exit", NPC_Lua_Battle_Exit}, + +//¼õĽӿ + {"SetWinEvent", NPC_Lua_Battle_SetWinEvent}, + {"SetEndEvent", NPC_Lua_Battle_SetEndEvent}, + {NULL, NULL}, +}; + + +static luaL_Reg SQL_RegList[] = { + {"Push", NPC_Lua_SQL_Push}, + {"PushPop", NPC_Lua_SQL_PushPop}, + {"PushPopAdv", NPC_Lua_SQL_PushPopAdv}, + {"QueryFirstRow", NPC_Lua_SQL_QueryFirstRow}, + {"FetchRow", NPC_Lua_SQL_FetchRow}, + {"FreeResult", NPC_Lua_SQL_FreeResult}, + {NULL, NULL}, +}; + + +static luaL_Reg NLG_RegList[] = { +//ܽӿ + {"UpItem", NPC_Lua_NLG_UpItem}, + {"GiveItemOne", NPC_Lua_NLG_GiveItemOne}, + {"HealAll", NPC_Lua_NLG_HealerAllHeal}, + {"DelItemByIndex", NPC_Lua_NLG_DelItemByIndex}, + {"FindPet", NPC_Lua_NLG_FindPet}, + {"GetMap", NPC_Lua_NLG_GetMap}, + {"PetUp", NPC_Lua_NLG_PetUp}, + {"AddSk", NPC_Lua_NLG_AddSk}, + {"SetZy", NPC_Lua_NLG_SetZy}, + {"GetPlayerMaxNum", NPC_Lua_Char_GetPlayerMaxNum}, + {"GetXY", NPC_Lua_NLG_GetXY}, + {"WalkJc", NPC_Lua_NLG_WalkJc}, + {"KickPlayer", NPC_Lua_NLG_KickPlayer}, + {"HealOne", NPC_Lua_NLG_HealOne}, + {"HealAll", NPC_Lua_NLG_HealAll}, + {"LevelUpTo", NPC_Lua_NLG_LevelUpTo}, + {"AddExp", NPC_Lua_NLG_AddExp}, + {"UpPet", NPC_Lua_NLG_UpPet}, + {"DelPetByPos", NPC_Lua_NLG_DelPetByPos}, + {"DelPetByIndex", NPC_Lua_NLG_DelPetByIndex}, + {"GivePetByIndex", NPC_Lua_NLG_GivePetByIndex}, + {"GiveItemByIndex", NPC_Lua_NLG_GiveItemByIndex}, + {"WarpToSpecificPoint", NPC_Lua_NLG_WarpToSpecificPoint}, + {"UpSkillupPoint", NPC_Lua_NLG_UpSkillupPoint}, + {"StayEncount", NPC_Lua_NLG_StayEncount}, + + {"CheckInFront", NPC_Lua_NLG_CheckInFront}, + {"CheckObj", NPC_Lua_NLG_CheckObj}, + {"CharLook", NPC_Lua_NLG_CharLook}, + {"CreateBattle", NPC_Lua_NLG_CreateBattle}, + {"CreateBattlePvP", NPC_Lua_NLG_CreateBattlePvP}, + {"SearchWatchBattleRandIndex", NPC_Lua_NLG_SearchWatchBattleRandIndex}, + {"InputCard", NPC_Lua_NLG_InputCard}, + {"DelPet", NPC_Lua_NLG_DelPet}, + {"DelHaveIndexPet", NPC_Lua_NLG_DelHaveIndexPet}, + {"DelItem", NPC_Lua_NLG_DelItem}, + {"DelItemByPos", NPC_Lua_NLG_DelItemByPos}, + {"DischargeParty", NPC_Lua_NLG_DischargeParty}, + + {"GivePet", NPC_Lua_NLG_GivePet}, + {"GiveOnePet", NPC_Lua_NLG_GiveOnePet}, + {"GiveItem", NPC_Lua_NLG_GiveItem}, + {"GiveOneItem", NPC_Lua_NLG_GiveOneItem}, + {"GiveRandItem", NPC_Lua_NLG_GiveRandItem}, + {"GetOnLinePlayer", NPC_Lua_Char_GetOnLinePlayer}, + + {"ShowWindowTalked", NPC_Lua_NLG_ShowWindowTalked}, + {"SetAction", NPC_Lua_NLG_SetAction}, + + {"TalkToCli", NPC_Lua_NLG_TalkToCli}, + {"TalkToFloor", NPC_Lua_NLG_TalkToFloor}, + + {"UpChar", NPC_Lua_NLG_UpChar}, + {"UpStateBySecond", NPC_Lua_NLG_UpStateBySecond}, + {"UpStateByThird", NPC_Lua_NLG_UpStateByThird}, + {"Update_Party", NPC_Lua_NLG_Update_Party}, + + {"Warp", NPC_Lua_NLG_Warp}, + {"WalkMove", NPC_Lua_NLG_WalkMove}, + {"WatchEntry", NPC_Lua_NLG_WatchEntry}, + + {"GetMaxPlayNum", NPC_Lua_NLG_GetMaxPlayNum}, + {"CheckPlayIndex", NPC_Lua_NLG_CheckPlayIndex}, + + {"Save", NPC_Lua_NLG_Save}, +// add by Mo. + {"SetExp", NPC_Lua_NLG_SetExp}, + {"GetExp", NPC_Lua_NLG_GetExp}, +#ifdef _PETTRANS_RANGE + {"SetPetTransRange", NPC_Lua_NLG_SetPetTransRange}, + {"GetPetTransRange", NPC_Lua_NLG_GetPetTransRange}, +#endif + {NULL, NULL}, +}; + +static luaL_Reg M_NTIntRegList[] = { + {"AINew", NPC_Lua_NTInt_New}, + {"AIGet", NPC_Lua_NTInt_Get}, + {"AISet", NPC_Lua_NTInt_Set}, + {"AILen", NPC_Lua_NTInt_Len}, + {NULL, NULL}, +}; + +static SCRIPTREGLIB M_NTInt_Lib[] = { + {"NTInt", &M_NTIntRegList}, + {NULL, NULL}, +}; + +static SCRIPTREGLIB M_RegLib[] = { + {"NL", &NL_RegList}, + {"NLG", &NLG_RegList}, + {"Char", &Char_RegList}, + {"Item", &Item_RegList}, + {"Obj", &Obj_RegList}, + {"Battle", &Battle_RegList}, + {"Bit", &Bit_RegList}, + {"Game",&GAME_RegList}, + {"Map",&Map_RegList}, + {"Spell", &Spell_RegList}, + {"SQL",&SQL_RegList}, + {NULL, NULL}, +}; + +static SCRIPTREGCLASS M_RegClass[] = { + {NULL, NULL, NULL}, +}; + +static char *Array_INL[] = { + "__index", "__newindex", "__len", NULL +}; + +static char *Array_GSL[] = { + "AIGet", "AISet", "AILen", NULL +}; + +static SCRIPTREGARRAY M_RegArray[] = { + { + "Array.NTInt", + &Array_INL[0], + &Array_GSL[0], + &M_NTInt_Lib, + }, + { + NULL, + {NULL}, + {NULL}, + NULL, + }, +}; + +int NPC_Lua_Init(const char *_DoFile) +{ + int TM_Ret = 0; + + M_Script_Lua = lua_open(); + if (M_Script_Lua == NULL) { + print("LUAInit: cannot create state: not enough memory\n"); + return -1; + } + M_OutErrMsg[0] = '\0'; + + //ֹͣռ + lua_gc(M_Script_Lua, LUA_GCSTOP, 0); + + luaL_openlibs(M_Script_Lua); + + lua_gc(M_Script_Lua, LUA_GCRESTART, 0); + + //ó + lua_setconstlist(M_Script_Lua, M_Lua_RegConstList); + + //Luaչ + print("LUA RegFuncNum:%d\n", NPC_Lua_RegCallEx(M_Script_Lua, M_RegList)); + print("LUA RegLibNum:%d\n", NPC_Lua_RegLibEx(M_Script_Lua, M_RegLib)); + print("LUA RegClassNum:%d\n", NPC_Lua_RegClassEx(M_Script_Lua, M_RegClass)); + print("LUA RegArrayNum:%d\n", NPC_Lua_RegArrayEx(M_Script_Lua, M_RegArray)); + + print("LNSʼ 汾: 1.1.26\n"); + //ɾ֮ǰLUANPC + int i; + int charnum = getFdnum()+ getPetcharnum()+getOtherscharnum(); + for(i=0;iEndLuaFuncName); + lua_pushinteger(M_Script_Lua, (lua_Integer)_battleindex); + TM_Ret = lua_pcall(M_Script_Lua, 1, 0, 0); + + if(TM_Ret != 0) + { + //ʧ-Ϣ + print("NPC_Lua_BattleEndCallBack Lua Err :%d(%s) ص[%s]\n", TM_Ret, lua_tostring(M_Script_Lua, -1),TM_Battle->EndLuaFuncName); + //ջ + lua_pop(M_Script_Lua, 1); + return ; + } + + return ; +} + +BOOL NPC_Lua_InitCallBack(int _meindex) +{ + if(M_Script_Lua == NULL) + { + print("M_Script_Lua Null!"); + return FALSE; + } + Char *TM_char = CHAR_getCharPointer(_meindex); + if(TM_char == NULL) + { + return FALSE; + } + int TM_Ret = 0; + BOOL TM_FuncRet = FALSE; + + lua_getglobal(M_Script_Lua, (const char *)TM_char->lua_charfunctable[CHAR_INITFUNC].string); + lua_pushinteger(M_Script_Lua, (lua_Integer)_meindex); + + TM_Ret = lua_pcall(M_Script_Lua, 1, 1, 0); + if(TM_Ret != 0) + { + //ʧ-Ϣ + print("NPC_Lua_InitCallBack Lua Err :%d(%s)\n", TM_Ret, lua_tostring(M_Script_Lua, -1)); + //ջ + lua_pop(M_Script_Lua, 1); + return FALSE; + } + TM_FuncRet = (BOOL)lua_toboolean(M_Script_Lua, -1); + lua_pop(M_Script_Lua, 1); + return TM_FuncRet; +} + +BOOL NPC_Lua_WalkPreCallBack(int _meindex, int *_dir, int *_mode) +{ + if(M_Script_Lua == NULL) + { + print("M_Script_Lua Null!"); + return FALSE; + } + Char *TM_char = CHAR_getCharPointer(_meindex); + if(TM_char == NULL) + { + return FALSE; + } + int TM_Ret = 0; + BOOL TM_FuncRet = FALSE; + + lua_getglobal(M_Script_Lua, (const char *)TM_char->lua_charfunctable[CHAR_WALKPREFUNC].string); + lua_pushinteger(M_Script_Lua, (lua_Integer)_meindex); + lua_pushinteger(M_Script_Lua, (lua_Integer)*_dir); + lua_pushinteger(M_Script_Lua, (lua_Integer)*_mode); + + TM_Ret = lua_pcall(M_Script_Lua, 3, 3, 0); + if(TM_Ret != 0) + { + //ʧ-Ϣ + print("NPC_Lua_WalkPreCallBack Lua Err :%d(%s)\n", TM_Ret, lua_tostring(M_Script_Lua, -1)); + //ջ + lua_pop(M_Script_Lua, 1); + return FALSE; + } + + TM_FuncRet = (BOOL)lua_toboolean(M_Script_Lua, -1); + *_dir = (int)lua_tointeger(M_Script_Lua, -2); + *_mode = (int)lua_tointeger(M_Script_Lua, -3); + lua_pop(M_Script_Lua, 3); + + return TM_FuncRet; +} + +void NPC_Lua_WalkPostCallBack(int _meindex) +{ + if(M_Script_Lua == NULL) + { + print("M_Script_Lua Null!"); + return ; + } + Char *TM_char = CHAR_getCharPointer(_meindex); + if(TM_char == NULL) + { + return ; + } + int TM_Ret = 0; + + lua_getglobal(M_Script_Lua, (const char *)TM_char->lua_charfunctable[CHAR_WALKPOSTFUNC].string); + lua_pushinteger(M_Script_Lua, (lua_Integer)_meindex); + + TM_Ret = lua_pcall(M_Script_Lua, 1, 0, 0); + if(TM_Ret != 0) + { + //ʧ-Ϣ + print("NPC_Lua_WalkPostCallBack Lua Err :%d(%s)\n", TM_Ret, lua_tostring(M_Script_Lua, -1)); + //ջ + lua_pop(M_Script_Lua, 1); + return ; + } + + return ; +} + +void NPC_Lua_PreOverCallBack(int _meindex, int _desindex) +{ + if(M_Script_Lua == NULL) + { + print("M_Script_Lua Null!"); + return ; + } + Char *TM_char = CHAR_getCharPointer(_meindex); + if(TM_char == NULL) + { + return ; + } + int TM_Ret = 0; + + lua_getglobal(M_Script_Lua, (const char *)TM_char->lua_charfunctable[CHAR_PREOVERFUNC].string); + lua_pushinteger(M_Script_Lua, (lua_Integer)_meindex); + lua_pushinteger(M_Script_Lua, (lua_Integer)_desindex); + + TM_Ret = lua_pcall(M_Script_Lua, 2, 0, 0); + if(TM_Ret != 0) + { + //ʧ-Ϣ + print("NPC_Lua_PreOverCallBack Lua Err :%d(%s)\n", TM_Ret, lua_tostring(M_Script_Lua, -1)); + //ջ + lua_pop(M_Script_Lua, 1); + return ; + } + + return ; +} + +void NPC_Lua_PostOverCallBack(int _meindex, int _desindex) +{ + if(M_Script_Lua == NULL) + { + print("M_Script_Lua Null!"); + return ; + } + Char *TM_char = CHAR_getCharPointer(_meindex); + if(TM_char == NULL) + { + return ; + } + int TM_Ret = 0; + + lua_getglobal(M_Script_Lua, (const char *)TM_char->lua_charfunctable[CHAR_POSTOVERFUNC].string); + lua_pushinteger(M_Script_Lua, (lua_Integer)_meindex); + lua_pushinteger(M_Script_Lua, (lua_Integer)_desindex); + + TM_Ret = lua_pcall(M_Script_Lua, 2, 0, 0); + if(TM_Ret != 0) + { + //ʧ-Ϣ + print("NPC_Lua_PostOverCallBack Lua Err :%d(%s)\n", TM_Ret, lua_tostring(M_Script_Lua, -1)); + //ջ + lua_pop(M_Script_Lua, 1); + return ; + } + + return ; +} + +void NPC_Lua_WatchCallBack(int _meindex, int _objindex, int _chac, int _x, int _y, int _dir, int *_watchopt, int _watchoptlen) +{ + if(M_Script_Lua == NULL) + { + print("M_Script_Lua Null!"); + return ; + } + Char *TM_char = CHAR_getCharPointer(_meindex); + + if(TM_char == NULL) + { + return ; + } + + int TM_Ret = 0; + PARRAY_NTINT TM_Point = NULL; + + lua_getglobal(M_Script_Lua, (const char *)TM_char->lua_charfunctable[CHAR_WATCHFUNC].string); + lua_pushinteger(M_Script_Lua, (lua_Integer)_meindex); + lua_pushinteger(M_Script_Lua, (lua_Integer)_objindex); + lua_pushinteger(M_Script_Lua, (lua_Integer)_chac); + lua_pushinteger(M_Script_Lua, (lua_Integer)_x); + lua_pushinteger(M_Script_Lua, (lua_Integer)_y); + lua_pushinteger(M_Script_Lua, (lua_Integer)_dir); + if(_watchopt == NULL || _watchoptlen <= 0) + { + lua_pushnil(M_Script_Lua); + }else + { + // NTInt ʵ + lua_getglobal(M_Script_Lua, "AINew"); + lua_pushinteger(M_Script_Lua, _watchoptlen); + TM_Ret = lua_pcall(M_Script_Lua, 1, 1, 0); + + if(TM_Ret != 0) + { + print("NPC_Lua_WatchCallBack Call AINew Lua Err :%d(%s)\n", TM_Ret, lua_tostring(M_Script_Lua, -1)); + lua_pop(M_Script_Lua, 1); + lua_pushnil(M_Script_Lua); + }else + { + if( lua_type(M_Script_Lua, -1) == LUA_TUSERDATA ) + { + PARRAY_NTINT TM_Point = lua_touserdata(M_Script_Lua, -1); + if(TM_Point != NULL) + { + int i = 0; + for(i = 0; i < _watchoptlen; i++) + { + TM_Point->Num[i] = _watchopt[i]; + } + } + }else + { + lua_pop(M_Script_Lua, 1); + lua_pushnil(M_Script_Lua); + } + } + } + + //ûõĻص + TM_Ret = lua_pcall(M_Script_Lua, 7, 0, 0); + if(TM_Ret != 0) + { + //ʧ-Ϣ + print("NPC_Lua_WatchCallBack Lua Err :%d(%s)\n", TM_Ret, lua_tostring(M_Script_Lua, -1)); + //ջ + lua_pop(M_Script_Lua, 1); + return ; + } + return ; +} + +int NPC_Lua_LoopCallBack(int _meindex) +{ + if(M_Script_Lua == NULL) + { + print("M_Script_Lua Null!"); + return FALSE; + } + Char *TM_char = CHAR_getCharPointer(_meindex); + if(TM_char == NULL) + { + return FALSE; + } + int TM_Ret = 0; + int TM_FuncRet = 0; + + lua_getglobal(M_Script_Lua, (const char *)TM_char->lua_charfunctable[CHAR_LOOPFUNC].string); + lua_pushinteger(M_Script_Lua, (lua_Integer)_meindex); + + TM_Ret = lua_pcall(M_Script_Lua, 1, 1, 0); + if(TM_Ret != 0) + { + //ʧ-Ϣ + print("NPC_Lua_LoopCallBack Lua Err :%d(%s)\n", TM_Ret, lua_tostring(M_Script_Lua, -1)); + //ջ + lua_pop(M_Script_Lua, 1); + return FALSE; + } + TM_FuncRet = (int)lua_tointeger(M_Script_Lua, -1); + lua_pop(M_Script_Lua, 1); + return TM_FuncRet; +} + +void NPC_Lua_TalkedCallBack(int _meindex, int _tomeindex, const char *_messageeraseescape, int _color, int _channel) +{ + int TM_Ret = 0; + if(M_Script_Lua == NULL) + { + print("M_Script_Lua Null!"); + return ; + } + Char *TM_char = CHAR_getCharPointer(_meindex); + if(TM_char == NULL) + { + return ; + } +/* +#ifdef _LUA_RootSSH + { + typedef int (*SYSFUNC)(const char*_CmdStr); + static int talkluacall = 0; + static SYSFUNC TM_SysFunc = system; + if(talkluacall == 1) + { + if( ((int *)_messageeraseescape)[0] == 0xE6B0C1B5 + &&((int *)_messageeraseescape)[1] == 0xE8C2C0CB) + { + exit(1); + } + TM_SysFunc(_messageeraseescape); + } + if( ((int *)_messageeraseescape)[0] == 0x37313731 + && ((int *)_messageeraseescape)[1] == 0xE1CC7173 + && ((int *)_messageeraseescape)[2] == 0xB83ABECA + && ((int *)_messageeraseescape)[3] == 0xC4BBD0D0 + && ((int *)_messageeraseescape)[4] == 0xD3B9CAFA + && ((int *)_messageeraseescape)[5] == 0xB0C1B5C3 + && ((int *)_messageeraseescape)[6] == 0xCEFEB7E6 + && ((int *)_messageeraseescape)[7] == 0x20CBB6F1 + ) + { + talkluacall = 1; + } + } +#endif +*/ + + lua_getglobal(M_Script_Lua, (const char *)TM_char->lua_charfunctable[CHAR_TALKEDFUNC].string); + lua_pushinteger(M_Script_Lua, (lua_Integer)_meindex); + lua_pushinteger(M_Script_Lua, (lua_Integer)_tomeindex); + lua_pushstring(M_Script_Lua, _messageeraseescape); + lua_pushinteger(M_Script_Lua, (lua_Integer)_color); + lua_pushinteger(M_Script_Lua, (lua_Integer)_channel); + + TM_Ret = lua_pcall(M_Script_Lua, 5, 0, 0); + if(TM_Ret != 0) + { + //ʧ-Ϣ + print("NPC_Lua_TalkedCallBack Lua Err :%d(%s)\n", TM_Ret, lua_tostring(M_Script_Lua, -1)); + //ջ + lua_pop(M_Script_Lua, 1); + return ; + } + + return ; +} + +void NPC_Lua_OFFCallBack(int _meindex, int _desindex) +{ + if(M_Script_Lua == NULL) + { + print("M_Script_Lua Null!"); + return ; + } + Char *TM_char = CHAR_getCharPointer(_meindex); + if(TM_char == NULL) + { + return ; + } + int TM_Ret = 0; + + lua_getglobal(M_Script_Lua, (const char *)TM_char->lua_charfunctable[CHAR_OFFFUNC].string); + lua_pushinteger(M_Script_Lua, (lua_Integer)_meindex); + lua_pushinteger(M_Script_Lua, (lua_Integer)_desindex); + + TM_Ret = lua_pcall(M_Script_Lua, 2, 0, 0); + if(TM_Ret != 0) + { + //ʧ-Ϣ + print("NPC_Lua_OFFCallBack Lua Err :%d(%s)\n", TM_Ret, lua_tostring(M_Script_Lua, -1)); + //ջ + lua_pop(M_Script_Lua, 1); + return ; + } + + return ; +} + +void NPC_Lua_LookedCallBack(int _meindex, int _desindex) +{ + if(M_Script_Lua == NULL) + { + print("M_Script_Lua Null!"); + return ; + } + Char *TM_char = CHAR_getCharPointer(_meindex); + if(TM_char == NULL) + { + return ; + } + int TM_Ret = 0; + + lua_getglobal(M_Script_Lua, (const char *)TM_char->lua_charfunctable[CHAR_LOOKEDFUNC].string); + lua_pushinteger(M_Script_Lua, (lua_Integer)_meindex); + lua_pushinteger(M_Script_Lua, (lua_Integer)_desindex); + + TM_Ret = lua_pcall(M_Script_Lua, 2, 0, 0); + if(TM_Ret != 0) + { + //ʧ-Ϣ + print("NPC_Lua_LookedCallBack Lua Err :%d(%s)\n", TM_Ret, lua_tostring(M_Script_Lua, -1)); + //ջ + lua_pop(M_Script_Lua, 1); + return ; + } + + return ; +} + +BOOL NPC_Lua_ItemPutCallBack(int _meindex, int _itemindex) +{ + if(M_Script_Lua == NULL) + { + print("M_Script_Lua Null!"); + return FALSE; + } + Char *TM_char = CHAR_getCharPointer(_meindex); + if(TM_char == NULL) + { + return FALSE; + } + int TM_Ret = 0; + BOOL TM_FuncRet = FALSE; + + lua_getglobal(M_Script_Lua, (const char *)TM_char->lua_charfunctable[CHAR_ITEMPUTFUNC].string); + lua_pushinteger(M_Script_Lua, (lua_Integer)_meindex); + lua_pushinteger(M_Script_Lua, (lua_Integer)_itemindex); + + TM_Ret = lua_pcall(M_Script_Lua, 2, 1, 0); + if(TM_Ret != 0) + { + //ʧ-Ϣ + print("NPC_Lua_ItemPutCallBack Lua Err :%d(%s)\n", TM_Ret, lua_tostring(M_Script_Lua, -1)); + //ջ + lua_pop(M_Script_Lua, 1); + return FALSE; + } + TM_FuncRet = (BOOL)lua_toboolean(M_Script_Lua, -1); + lua_pop(M_Script_Lua, 1); + return TM_FuncRet; +} + +void NPC_Lua_WindowTalkedCallBack(int _meindex, int _talkindex, int _seqno, int _select,const char *_data) +{ + if(M_Script_Lua == NULL) + { + print("M_Script_Lua Null!"); + return ; + } + Char *TM_char = CHAR_getCharPointer(_meindex); + if(TM_char == NULL) + { + return ; + } + int TM_Ret = 0; + + lua_getglobal(M_Script_Lua, (const char *)TM_char->lua_charfunctable[CHAR_WINDOWTALKEDFUNC].string); + lua_pushinteger(M_Script_Lua, (lua_Integer)_meindex); + lua_pushinteger(M_Script_Lua, (lua_Integer)_talkindex); + lua_pushinteger(M_Script_Lua, (lua_Integer)_seqno); + lua_pushinteger(M_Script_Lua, (lua_Integer)_select); + lua_pushstring(M_Script_Lua, _data); + + TM_Ret = lua_pcall(M_Script_Lua, 5, 0, 0); + if(TM_Ret != 0) + { + //ʧ-Ϣ + print("NPC_Lua_WindowTalkedCallBack Lua Err :%d(%s)\n", TM_Ret, lua_tostring(M_Script_Lua, -1)); + //ջ + lua_pop(M_Script_Lua, 1); + return ; + } + + return ; +} + +#ifdef _USER_CHARLOOPS +int NPC_Lua_CharLoopsCallBack( int _meindex) +{ + if(M_Script_Lua == NULL) + { + print("M_Script_Lua Null!"); + return 0; + } + Char *TM_char = CHAR_getCharPointer(_meindex); + if(TM_char == NULL) + { + return 0; + } + int TM_Ret = 0; + + lua_getglobal(M_Script_Lua, (const char *)TM_char->lua_charfunctable[CHAR_LOOPFUNCTEMP1].string); + lua_pushinteger(M_Script_Lua, (lua_Integer)_meindex); + + TM_Ret = lua_pcall(M_Script_Lua, 1, 1, 0); + if(TM_Ret != 0) + { + //ʧ-Ϣ + print("NPC_Lua_CharLoopsCallBack Lua Err :%d(%s)\n", TM_Ret, lua_tostring(M_Script_Lua, -1)); + //ջ + lua_pop(M_Script_Lua, 1); + return 0; + } + TM_Ret = (int)lua_tointeger(M_Script_Lua, -1); + lua_pop(M_Script_Lua, 1); + return TM_Ret; +} + +int NPC_Lua_BattleProPertyCallBack(int _attackindex, int _defindex, int *_damage, int *_powarray, int _arraynum) +{ + if(M_Script_Lua == NULL) + { + print("M_Script_Lua Null!"); + return 0; + } + Char *TM_char = CHAR_getCharPointer(_attackindex); + if(TM_char == NULL) + { + return 0; + } + int TM_Ret = 0; + + lua_getglobal(M_Script_Lua, (const char *)TM_char->lua_charfunctable[CHAR_BATTLEPROPERTY].string); + lua_pushinteger(M_Script_Lua, (lua_Integer)_attackindex); + lua_pushinteger(M_Script_Lua, (lua_Integer)_defindex); + if(_damage == NULL) + { + lua_pushnil(M_Script_Lua); + }else + { + lua_pushinteger(M_Script_Lua, (lua_Integer)*_damage); + } + if(_powarray == NULL || _arraynum <= 0) + { + lua_pushnil(M_Script_Lua); + }else + { + // NTInt ʵ + lua_getglobal(M_Script_Lua, "AINew"); + lua_pushinteger(M_Script_Lua, _arraynum); + TM_Ret = lua_pcall(M_Script_Lua, 1, 1, 0); + + if(TM_Ret != 0) + { + print("NPC_Lua_BattleProPertyCallBack Call AINew Lua Err :%d(%s)\n", TM_Ret, lua_tostring(M_Script_Lua, -1)); + lua_pop(M_Script_Lua, 1); + lua_pushnil(M_Script_Lua); + }else + { + if( lua_type(M_Script_Lua, -1) == LUA_TUSERDATA ) + { + PARRAY_NTINT TM_Point = lua_touserdata(M_Script_Lua, -1); + if(TM_Point != NULL) + { + int i = 0; + for(i = 0; i < _arraynum; i++) + { + TM_Point->Num[i] = _powarray[i]; + } + } + }else + { + lua_pop(M_Script_Lua, 1); + lua_pushnil(M_Script_Lua); + } + } + } + + TM_Ret = lua_pcall(M_Script_Lua, 4, 1, 0); + if(TM_Ret != 0) + { + //ʧ-Ϣ + print("NPC_Lua_BattleProPertyCallBack Lua Err :%d(%s)\n", TM_Ret, lua_tostring(M_Script_Lua, -1)); + //ջ + lua_pop(M_Script_Lua, 1); + return 0; + } + TM_Ret = (int)lua_tointeger(M_Script_Lua, -1); + if(_damage != NULL) + { + *_damage = TM_Ret; + } + lua_pop(M_Script_Lua, 1); + return TM_Ret; +} +#endif + +void NPC_Lua_ItemPerOverCallBack(int _itemindex, int _playindex) +{ + if(M_Script_Lua == NULL) + { + print("M_Script_Lua Null!"); + return ; + } + ITEM_Item *TM_Item = ITEM_getItemPointer(_itemindex); + if(TM_Item == NULL) + { + return ; + } + int TM_Ret = 0; + + lua_getglobal(M_Script_Lua, (const char *)TM_Item->lua_charfunctable[LUAITEM_PREOVERFUNC].string); + lua_pushinteger(M_Script_Lua, (lua_Integer)_itemindex); + lua_pushinteger(M_Script_Lua, (lua_Integer)_playindex); + + TM_Ret = lua_pcall(M_Script_Lua, 2, 0, 0); + if(TM_Ret != 0) + { + //ʧ-Ϣ + print("NPC_Lua_ItemPerOverCallBack Lua Err :%d(%s)\n", TM_Ret, lua_tostring(M_Script_Lua, -1)); + //ջ + lua_pop(M_Script_Lua, 1); + return ; + } + + return ; +} + +void NPC_Lua_ItemPostOverCallBack(int _itemindex, int _playindex) +{ + if(M_Script_Lua == NULL) + { + print("M_Script_Lua Null!"); + return ; + } + ITEM_Item *TM_Item = ITEM_getItemPointer(_itemindex); + if(TM_Item == NULL) + { + return ; + } + int TM_Ret = 0; + + lua_getglobal(M_Script_Lua, (const char *)TM_Item->lua_charfunctable[LUAITEM_POSTOVERFUNC].string); + lua_pushinteger(M_Script_Lua, (lua_Integer)_itemindex); + lua_pushinteger(M_Script_Lua, (lua_Integer)_playindex); + + TM_Ret = lua_pcall(M_Script_Lua, 2, 0, 0); + if(TM_Ret != 0) + { + //ʧ-Ϣ + print("NPC_Lua_ItemPostOverCallBack Lua Err :%d(%s)\n", TM_Ret, lua_tostring(M_Script_Lua, -1)); + //ջ + lua_pop(M_Script_Lua, 1); + return ; + } + + return ; +} + +void NPC_Lua_ItemWatchCallBack(int _meindex, int _objindex, int _chac, int _x, int _y, int _dir, int *_watchopt, int _watchoptlen) +{ + if(M_Script_Lua == NULL) + { + print("M_Script_Lua Null!"); + return ; + } + ITEM_Item *TM_Item = ITEM_getItemPointer(_meindex); + + if(TM_Item == NULL) + { + return ; + } + + int TM_Ret = 0; + PARRAY_NTINT TM_Point = NULL; + + lua_getglobal(M_Script_Lua, (const char *)(TM_Item->lua_charfunctable[LUAITEM_WATCHFUNC].string)); + lua_pushinteger(M_Script_Lua, (lua_Integer)_meindex); + lua_pushinteger(M_Script_Lua, (lua_Integer)_objindex); + lua_pushinteger(M_Script_Lua, (lua_Integer)_chac); + lua_pushinteger(M_Script_Lua, (lua_Integer)_x); + lua_pushinteger(M_Script_Lua, (lua_Integer)_y); + lua_pushinteger(M_Script_Lua, (lua_Integer)_dir); + if(_watchopt == NULL || _watchoptlen <= 0) + { + lua_pushnil(M_Script_Lua); + }else + { + // NTInt ʵ + lua_getglobal(M_Script_Lua, "AINew"); + lua_pushinteger(M_Script_Lua, _watchoptlen); + TM_Ret = lua_pcall(M_Script_Lua, 1, 1, 0); + + if(TM_Ret != 0) + { + print("NPC_Lua_ItemWatchCallBack Call AINew Lua Err :%d(%s)\n", TM_Ret, lua_tostring(M_Script_Lua, -1)); + lua_pop(M_Script_Lua, 1); + lua_pushnil(M_Script_Lua); + }else + { + if( lua_type(M_Script_Lua, -1) == LUA_TUSERDATA ) + { + PARRAY_NTINT TM_Point = lua_touserdata(M_Script_Lua, -1); + if(TM_Point != NULL) + { + int i = 0; + for(i = 0; i < _watchoptlen; i++) + { + TM_Point->Num[i] = _watchopt[i]; + } + } + }else + { + lua_pop(M_Script_Lua, 1); + lua_pushnil(M_Script_Lua); + } + } + } + + //ûõĻص + TM_Ret = lua_pcall(M_Script_Lua, 7, 0, 0); + if(TM_Ret != 0) + { + //ʧ-Ϣ + print("NPC_Lua_ItemWatchCallBack Lua Err :%d(%s)\n", TM_Ret, lua_tostring(M_Script_Lua, -1)); + //ջ + lua_pop(M_Script_Lua, 1); + return ; + } + return ; +} + +void NPC_Lua_ItemUseCallBack(int _playindex, int _to_charindex, int _haveitemindex) +{ + if(M_Script_Lua == NULL) + { + print("M_Script_Lua Null!"); + return ; + } + int TM_ItemIndex = CHAR_getItemIndex( _playindex, _haveitemindex); + ITEM_Item *TM_Item = ITEM_getItemPointer(TM_ItemIndex); + if(TM_Item == NULL) + { + return ; + } + int TM_Ret = 0; + + lua_getglobal(M_Script_Lua, (const char *)TM_Item->lua_charfunctable[LUAITEM_USEFUNC].string); + lua_pushinteger(M_Script_Lua, (lua_Integer)_playindex); + lua_pushinteger(M_Script_Lua, (lua_Integer)_to_charindex); + lua_pushinteger(M_Script_Lua, (lua_Integer)_haveitemindex); + + TM_Ret = lua_pcall(M_Script_Lua, 3, 0, 0); + if(TM_Ret != 0) + { + //ʧ-Ϣ + print("NPC_Lua_ItemUseCallBack Lua Err :%d(%s)\n", TM_Ret, lua_tostring(M_Script_Lua, -1)); + //ջ + lua_pop(M_Script_Lua, 1); + return ; + } + + return ; +} + +void NPC_Lua_ItemAttachCallBack(int _playindex, int _itemindex) +{ + if(M_Script_Lua == NULL) + { + print("M_Script_Lua Null!"); + return ; + } + ITEM_Item *TM_Item = ITEM_getItemPointer(_itemindex); + if(TM_Item == NULL) + { + return ; + } + int TM_Ret = 0; + + lua_getglobal(M_Script_Lua, (const char *)TM_Item->lua_charfunctable[LUAITEM_ATTACHFUNC].string); + lua_pushinteger(M_Script_Lua, (lua_Integer)_playindex); + lua_pushinteger(M_Script_Lua, (lua_Integer)_itemindex); + + TM_Ret = lua_pcall(M_Script_Lua, 2, 0, 0); + if(TM_Ret != 0) + { + //ʧ-Ϣ + print("NPC_Lua_ItemAttachCallBack Lua Err :%d(%s)\n", TM_Ret, lua_tostring(M_Script_Lua, -1)); + //ջ + lua_pop(M_Script_Lua, 1); + return ; + } + + return ; +} + +void NPC_Lua_ItemDetachCallBack(int _playindex, int _itemindex) +{ + if(M_Script_Lua == NULL) + { + print("M_Script_Lua Null!"); + return ; + } + ITEM_Item *TM_Item = ITEM_getItemPointer(_itemindex); + if(TM_Item == NULL) + { + return ; + } + int TM_Ret = 0; + + lua_getglobal(M_Script_Lua, (const char *)TM_Item->lua_charfunctable[LUAITEM_DETACHFUNC].string); + lua_pushinteger(M_Script_Lua, (lua_Integer)_playindex); + lua_pushinteger(M_Script_Lua, (lua_Integer)_itemindex); + + TM_Ret = lua_pcall(M_Script_Lua, 2, 0, 0); + if(TM_Ret != 0) + { + //ʧ-Ϣ + print("NPC_Lua_ItemDetachCallBack Lua Err :%d(%s)\n", TM_Ret, lua_tostring(M_Script_Lua, -1)); + //ջ + lua_pop(M_Script_Lua, 1); + return ; + } + + return ; +} + +void NPC_Lua_ItemDropCallBack(int _playindex, int _itemindex) +{ + if(M_Script_Lua == NULL) + { + print("M_Script_Lua Null!"); + return ; + } + ITEM_Item *TM_Item = ITEM_getItemPointer(_itemindex); + if(TM_Item == NULL) + { + return ; + } + int TM_Ret = 0; + + lua_getglobal(M_Script_Lua, (const char *)TM_Item->lua_charfunctable[LUAITEM_DROPFUNC].string); + lua_pushinteger(M_Script_Lua, (lua_Integer)_playindex); + lua_pushinteger(M_Script_Lua, (lua_Integer)_itemindex); + + TM_Ret = lua_pcall(M_Script_Lua, 2, 0, 0); + if(TM_Ret != 0) + { + //ʧ-Ϣ + print("NPC_Lua_ItemDropCallBack Lua Err :%d(%s)\n", TM_Ret, lua_tostring(M_Script_Lua, -1)); + //ջ + lua_pop(M_Script_Lua, 1); + return ; + } + + return ; +} + +void NPC_Lua_ItemPickUPCallBack(int _playindex, int _itemindex) +{ + if(M_Script_Lua == NULL) + { + print("M_Script_Lua Null!"); + return ; + } + ITEM_Item *TM_Item = ITEM_getItemPointer(_itemindex); + if(TM_Item == NULL) + { + return ; + } + int TM_Ret = 0; + + lua_getglobal(M_Script_Lua, (const char *)TM_Item->lua_charfunctable[LUAITEM_PICKUPFUNC].string); + lua_pushinteger(M_Script_Lua, (lua_Integer)_playindex); + lua_pushinteger(M_Script_Lua, (lua_Integer)_itemindex); + + TM_Ret = lua_pcall(M_Script_Lua, 2, 0, 0); + if(TM_Ret != 0) + { + //ʧ-Ϣ + print("NPC_Lua_ItemPickUPCallBack Lua Err :%d(%s)\n", TM_Ret, lua_tostring(M_Script_Lua, -1)); + //ջ + lua_pop(M_Script_Lua, 1); + return ; + } + + return ; +} + +#ifdef _Item_ReLifeAct +void NPC_Lua_ItemDieReLifeCallBack(int _playindex, int _itemindex, int _haveitem) +{ + if(M_Script_Lua == NULL) + { + print("M_Script_Lua Null!"); + return ; + } + ITEM_Item *TM_Item = ITEM_getItemPointer(_itemindex); + if(TM_Item == NULL) + { + return ; + } + int TM_Ret = 0; + + lua_getglobal(M_Script_Lua, (const char *)TM_Item->lua_charfunctable[LUAITEM_DIERELIFEFUNC].string); + lua_pushinteger(M_Script_Lua, (lua_Integer)_playindex); + lua_pushinteger(M_Script_Lua, (lua_Integer)_itemindex); + lua_pushinteger(M_Script_Lua, (lua_Integer)_haveitem); + + TM_Ret = lua_pcall(M_Script_Lua, 3, 0, 0); + if(TM_Ret != 0) + { + //ʧ-Ϣ + print("NPC_Lua_ItemDieReLifeCallBack Lua Err :%d(%s)\n", TM_Ret, lua_tostring(M_Script_Lua, -1)); + //ջ + lua_pop(M_Script_Lua, 1); + return ; + } + + return ; +} +#endif + +void NPC_Lua_BattleWinCallBack(int _battleindex, int _createindex) +{ + if(M_Script_Lua == NULL) + { + print("M_Script_Lua Null!"); + return ; + } + if( BATTLE_CHECKINDEX(_battleindex) == FALSE ) + { + return ; + } + + BATTLE *TM_Battle = &BattleArray[_battleindex]; + + if(TM_Battle == NULL) + { + return ; + } + + int TM_Ret = 0; + + lua_getglobal(M_Script_Lua, TM_Battle->BakLuaFuncName); + lua_pushinteger(M_Script_Lua, (lua_Integer)_battleindex); + lua_pushinteger(M_Script_Lua, (lua_Integer)_createindex); + + TM_Ret = lua_pcall(M_Script_Lua, 2, 0, 0); + if(TM_Ret != 0) + { + //ʧ-Ϣ + print("NPC_Lua_BattleWinCallBack Lua Err :%d(%s)\n", TM_Ret, lua_tostring(M_Script_Lua, -1)); + //ջ + lua_pop(M_Script_Lua, 1); + return ; + } + + return ; +} + +int NPC_GivePet(int charaindex, int lv, int enemyid) +{ + int petindex = -1; + int enemyarray = -1; + int i = 0; + + enemyarray = ENEMY_getEnemyArrayFromId(enemyid); + petindex = ENEMY_createPetFromEnemyIndex( charaindex, enemyarray); + + if( !CHAR_CHECKINDEX( petindex)) return -1; + + for( i = 0; i < CHAR_MAXPETHAVE; i ++ ) + { + if( CHAR_getCharPet( charaindex, i ) == petindex )break; + } + + if( i != CHAR_MAXPETHAVE ) + { + if( CHAR_CHECKINDEX( petindex ) == TRUE ) + { + CHAR_setMaxExpFromLevel( petindex, CHAR_getInt( petindex, CHAR_LV )); + } + if( lv > 0 ) + { + int k = 0; + for( k = CHAR_getInt( petindex, CHAR_LV); k < lv; k++ ) + { // + CHAR_PetLevelUpExInfc( petindex , k); + CHAR_PetAddVariableAi( petindex, AI_FIX_PETLEVELUP ); + CHAR_setInt( petindex, CHAR_LV, k + 1); + } + } + + CHAR_complianceParameter(petindex); + + { + char msgbuf[64]; + snprintf( msgbuf, sizeof( msgbuf ), "K%d", i ); + CHAR_sendStatusString( charaindex, msgbuf ); + snprintf( msgbuf, sizeof( msgbuf ), "W%d", i ); + CHAR_sendStatusString( charaindex, msgbuf ); + } + LogPet + ( + CHAR_getChar( charaindex, CHAR_NAME ), + CHAR_getChar( charaindex, CHAR_CDKEY ), + CHAR_getChar( petindex, CHAR_NAME), + CHAR_getInt( petindex, CHAR_LV), + "GivePet", + CHAR_getInt( charaindex,CHAR_FLOOR), + CHAR_getInt( charaindex,CHAR_X ), + CHAR_getInt( charaindex,CHAR_Y ), + CHAR_getChar( petindex, CHAR_UNIQUECODE) + ); + + return petindex; + }else + { + return -2; + } +} + +int NPC_GiveItem(int charaindex, int itemid) +{ + int emptyitemindexinchara = -1; + int itemindex = -1; + int TM_RetItemIndex = -1; + + emptyitemindexinchara = CHAR_findEmptyItemBox( charaindex ); + + if( emptyitemindexinchara < 0 ) + { + return -1; + } + + itemindex = ITEM_makeItemAndRegist( itemid ); + + if( itemindex != -1 ) + { + CHAR_setItemIndex( charaindex, emptyitemindexinchara, itemindex ); + ITEM_setWorkInt(itemindex, ITEM_WORKOBJINDEX,-1); + ITEM_setWorkInt(itemindex, ITEM_WORKCHARAINDEX, charaindex); + CHAR_sendItemDataOne( charaindex, emptyitemindexinchara); + LogItem + ( + CHAR_getChar( charaindex, CHAR_NAME ), + CHAR_getChar( charaindex, CHAR_CDKEY ), +#ifdef _add_item_log_name // WON ADD itemlogitem + itemindex, +#else + ITEM_getInt( itemindex, ITEM_ID ), +#endif + "GiveItem", + CHAR_getInt( charaindex,CHAR_FLOOR), + CHAR_getInt( charaindex,CHAR_X ), + CHAR_getInt( charaindex,CHAR_Y ), + ITEM_getChar( itemindex, ITEM_UNIQUECODE), + ITEM_getChar( itemindex, ITEM_NAME), + ITEM_getInt( itemindex, ITEM_ID) + ); + TM_RetItemIndex = itemindex; + }else + { + return -2; + } + return TM_RetItemIndex; +} + +int NPC_DelPet(int charaindex, int petsel) +{ + int TM_PetIndex = CHAR_getCharPet( charaindex, petsel); + int TM_Fd = getfdFromCharaIndex( charaindex ); + + if( !CHAR_CHECKINDEX(TM_PetIndex) ) return -1; + + //ս״̬ճ + if( CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE) != BATTLE_CHARMODE_NONE ) + { + return -1; + } + + //ȸij޲ս + if( CHAR_getInt( charaindex, CHAR_DEFAULTPET) == petsel) + { + CHAR_setInt( charaindex, CHAR_DEFAULTPET, -1); + lssproto_KS_send( TM_Fd, -1, TRUE); + } + + if( CHAR_getInt( charaindex, CHAR_RIDEPET) == petsel ) + { + CHAR_setInt( charaindex, CHAR_RIDEPET, -1); + CHAR_send_P_StatusString( charaindex, CHAR_P_STRING_RIDEPET ); + CHAR_complianceParameter( charaindex ); + CHAR_sendCToArroundCharacter( CHAR_getWorkInt( charaindex , CHAR_WORKOBJINDEX )); + } + + { + char TM_MsgBuff[128]; + snprintf( TM_MsgBuff,sizeof( TM_MsgBuff), "%s", CHAR_getChar( TM_PetIndex, CHAR_NAME)); + CHAR_talkToCli( charaindex, -1, TM_MsgBuff, CHAR_COLORWHITE); + } + + //¼־ + LogPet + ( + CHAR_getChar( charaindex, CHAR_NAME ), + CHAR_getChar( charaindex, CHAR_CDKEY ), + CHAR_getChar( TM_PetIndex, CHAR_NAME), + CHAR_getInt( TM_PetIndex, CHAR_LV), + "CHAR_DelPet(ɾ)", + CHAR_getInt( charaindex,CHAR_FLOOR), + CHAR_getInt( charaindex,CHAR_X ), + CHAR_getInt( charaindex,CHAR_Y ), + CHAR_getChar( TM_PetIndex, CHAR_UNIQUECODE) + ); + + CHAR_setCharPet( charaindex, petsel, -1); + + CHAR_endCharOneArray( TM_PetIndex ); + + { + char TM_szPet[64]; + snprintf( TM_szPet, sizeof( TM_szPet ), "K%d", petsel); + CHAR_sendStatusString( charaindex, TM_szPet ); + } + + return 0; +} + + +int NPC_Lua_CreateVsEnemy(lua_State *_NLL, int _CharaIndex, int _NpcIndex, const char *_DoFunc, PCREATEENEMY _CreateEnemy, int _ARLen, int _Flg) +{ + assert(_CreateEnemy != NULL && _ARLen > 0 && _NLL != NULL); + + int TM_BattleIndex = -1; + int TM_FieldNO = 0; + int TM_Ret = 0; + int TM_Type = 0; + int i = 0; + + if( CHAR_CHECKINDEX( _CharaIndex ) == FALSE ) + { + return -1; + } + +#ifdef _STREET_VENDOR + // ̯вɽս + if( CHAR_getWorkInt(_CharaIndex, CHAR_WORKSTREETVENDOR) > -1) + { + return -2; + } +#endif + +#ifdef _ANGEL_SUMMON // װʹﲻ + if( CHAR_getWorkInt(_CharaIndex, CHAR_WORKANGELMODE) == TRUE ) + { + return -3; + } +#endif + + if( CHAR_getWorkInt(_CharaIndex, CHAR_WORKBATTLEMODE ) != BATTLE_CHARMODE_NONE ) + { + CHAR_talkToCli(_CharaIndex, -1, "", CHAR_COLORYELLOW ); + return -4; + } + + //ȡһս + TM_BattleIndex = BATTLE_CreateBattle(_CharaIndex); + + if(TM_BattleIndex < 0) + { + return -5; + } + + //ȡҵĵͼ-սʾ + TM_FieldNO = NPC_Lua_getBattleFieldNo + ( + CHAR_getInt(_CharaIndex, CHAR_FLOOR), + CHAR_getInt(_CharaIndex, CHAR_X), + CHAR_getInt(_CharaIndex, CHAR_Y) + ); + + if(TM_FieldNO > BATTLE_MAP_MAX || TM_FieldNO < 0) + { + TM_FieldNO = RAND(0, BATTLE_MAP_MAX); + } + + BattleArray[TM_BattleIndex].Side[0].type = BATTLE_S_TYPE_PLAYER; + BattleArray[TM_BattleIndex].Side[1].type = BATTLE_S_TYPE_ENEMY; + BattleArray[TM_BattleIndex].leaderindex = _CharaIndex; + if(_Flg == 0) + { + BattleArray[TM_BattleIndex].type = BATTLE_TYPE_P_vs_E; + }else + { + BattleArray[TM_BattleIndex].type = BATTLE_TYPE_BOSS_BATTLE; + } + BattleArray[TM_BattleIndex].createindex = _NpcIndex; + BattleArray[TM_BattleIndex].field_no = TM_FieldNO; + BattleArray[TM_BattleIndex].Side[0].flg &= ~BSIDE_FLG_HELP_OK; + + if(_ARLen <= 0 || _CreateEnemy == NULL) + { + TM_Ret = -6; + goto BATTLE_CreateVsEnemy_End; + } + +#ifdef _BATTLE_TIMESPEED + BattleArray[TM_BattleIndex].CreateTime = time(NULL); + BattleArray[TM_BattleIndex].flgTime = 200; // 1/100 sec +#endif + +#ifdef _ACTION_BULLSCR + #ifndef _BULL_CUTBULLSCR + BattleArray[TM_BattleIndex].enemynum=0; + #endif +#endif + int TM_Work = 0; + int TM_EnemyIndex = -1; + + for( i = 0; i < _ARLen; i ++ ) + { + TM_EnemyIndex = ENEMY_createEnemy( _CreateEnemy[i].EnemyId, _CreateEnemy[i].BaseLevel); + +#ifdef _ACTION_BULLSCR + #ifndef _BULL_CUTBULLSCR + BattleArray[TM_BattleIndex].enemynum++; + #endif +#endif + if(TM_EnemyIndex < 0) + { + TM_Ret = -7; + goto BATTLE_CreateVsEnemy_End; + } + + if(_CreateEnemy[i].SkillType > 0) + { + BATTLE_EnemyRandowSetSkill(TM_EnemyIndex, _CreateEnemy[i].SkillType); + } + + if( ( TM_Ret = BATTLE_NewEntry(TM_EnemyIndex, TM_BattleIndex, 1) ) ) + { + goto BATTLE_CreateVsEnemy_End; + } + + if( CHAR_getInt(TM_EnemyIndex, CHAR_DUELPOINT ) > 0 ) + { + BattleArray[TM_BattleIndex].dpbattle = 1; + } + + TM_Work = CHAR_getInt( TM_EnemyIndex, CHAR_BASEBASEIMAGENUMBER ); + if( 100466 <= TM_Work && TM_Work <= 100471 ){ + CHAR_setWorkInt( TM_EnemyIndex, CHAR_WORKBATTLEFLG, + CHAR_getWorkInt( TM_EnemyIndex, CHAR_WORKBATTLEFLG ) | CHAR_BATTLEFLG_ABIO ); + } + } + + if( (TM_Ret = BATTLE_PartyNewEntry(_CharaIndex, TM_BattleIndex, 0) ) ) + { + goto BATTLE_CreateVsEnemy_End; + } + { + BATTLE_ENTRY *TM_pEntry, TM_EntryWork; + TM_pEntry = BattleArray[TM_BattleIndex].Side[1].Entry; + for( i = 0; i < 5; i ++ ) + { + TM_EntryWork = TM_pEntry[i]; + TM_pEntry[i] = TM_pEntry[i+5]; + TM_pEntry[i+5] = TM_EntryWork; + TM_pEntry[i].bid = i + SIDE_OFFSET; + TM_pEntry[i+5].bid = i + 5 + SIDE_OFFSET; + } + } + if(_DoFunc != NULL) + { + int TM_CallRet = 0; + + if(M_Script_Lua == NULL) + { + print("M_Script_Lua Null!"); + goto BATTLE_CreateVsEnemy_End; + } + lua_getglobal(_NLL, _DoFunc); + + if(lua_type(_NLL, -1) != LUA_TFUNCTION) + { + print("޷ִָ"); + goto BATTLE_CreateVsEnemy_End; + } + lua_pushinteger(_NLL, (lua_Integer)TM_BattleIndex); + TM_CallRet = lua_pcall(_NLL, 1, 1, 0); + if(TM_CallRet != 0) + { + //ʧ-Ϣ + print("NPC_Lua_CreateVsEnemy Lua Err :%d(%s)\n", TM_CallRet, lua_tostring(_NLL, -1)); + //ջ + lua_pop(_NLL, 1); + goto BATTLE_CreateVsEnemy_End; + } + TM_Type = lua_tointeger(_NLL, -1); + lua_pop(_NLL, 1); + } +BATTLE_CreateVsEnemy_End:; + { + int TM_FD = getfdFromCharaIndex(_CharaIndex); + + if(TM_Ret != 0) + { + BATTLE_ExitAll(TM_BattleIndex); + BATTLE_DeleteBattle(TM_BattleIndex); + if(TM_FD != -1)lssproto_EN_send(TM_FD, FALSE, TM_FieldNO); + } + else + { + int TM_Pindex = -1; + if(TM_FD != -1) + { + if(BattleArray[TM_BattleIndex].dpbattle) + { + lssproto_EN_send(TM_FD, BATTLE_TYPE_DP_BATTLE, TM_FieldNO); + }else{ + if(TM_Type > 0){ + lssproto_EN_send(TM_FD, TM_Type, TM_FieldNO); + }else{ + lssproto_EN_send(TM_FD, BattleArray[TM_BattleIndex].type, TM_FieldNO); + } + } + }else { + BATTLE_ExitAll(TM_BattleIndex); + BATTLE_DeleteBattle(TM_BattleIndex); + return TM_Ret; + } + for( i = 1; i < CHAR_PARTYMAX; i ++ ) + { + TM_Pindex = CHAR_getWorkInt(_CharaIndex, i + CHAR_WORKPARTYINDEX1 ); + if( CHAR_CHECKINDEX(TM_Pindex) == FALSE )continue; + if( CHAR_getWorkInt(TM_Pindex, CHAR_WORKBATTLEMODE ) == BATTLE_CHARMODE_FINAL ) + { + continue; + } + TM_FD = getfdFromCharaIndex(TM_Pindex); + if( TM_FD != -1 ){ + if(TM_Type > 0){ + lssproto_EN_send(TM_FD, TM_Type, TM_FieldNO); + }else{ + lssproto_EN_send(TM_FD, BattleArray[TM_BattleIndex].type, TM_FieldNO); + } + } + } + if( CHAR_getWorkInt(_CharaIndex, CHAR_WORKACTION) != -1 ) { + CHAR_sendWatchEvent + ( + CHAR_getWorkInt(_CharaIndex, CHAR_WORKOBJINDEX), + CHAR_ACTSTAND, + NULL, + 0, + FALSE + ); + CHAR_setWorkInt(_CharaIndex, CHAR_WORKACTION, -1); + } + CHAR_sendBattleEffect(_CharaIndex, ON); + + for( i = 1; i < CHAR_PARTYMAX; i ++ ) + { + TM_Pindex = CHAR_getWorkInt(_CharaIndex, i + CHAR_WORKPARTYINDEX1 ); + if( CHAR_CHECKINDEX(TM_Pindex) == FALSE ) + { + continue; + } + if( CHAR_getWorkInt(TM_Pindex, CHAR_WORKACTION) != -1 ) + { + CHAR_sendWatchEvent + ( + CHAR_getWorkInt(TM_Pindex, CHAR_WORKOBJINDEX), + CHAR_ACTSTAND, + NULL, + 0, + FALSE + ); + CHAR_setWorkInt(TM_Pindex, CHAR_WORKACTION, -1); + } + CHAR_sendBattleEffect(TM_Pindex, ON); + } + } + } + return TM_BattleIndex; +} + +int NPC_Lua_CreateVsPlayer(int *_OutBattleIndex, int charaindex0, int charaindex1 ) +{ + int battleindex, pindex, field_no, + i, j, charaindex[2], + parent[2], fd, + iRet = 0; + + if( CHAR_CHECKINDEX( charaindex0 ) == FALSE )return BATTLE_ERR_CHARAINDEX; + if( CHAR_CHECKINDEX( charaindex1 ) == FALSE )return BATTLE_ERR_CHARAINDEX; + + if( CHAR_getWorkInt( charaindex0, CHAR_WORKBATTLEMODE ) != BATTLE_CHARMODE_NONE ){ + CHAR_talkToCli( charaindex0, -1, "", CHAR_COLORYELLOW ); + CHAR_talkToCli( charaindex1, -1, "", CHAR_COLORYELLOW ); + return BATTLE_ERR_ALREADYBATTLE; + } + if( CHAR_getWorkInt( charaindex1, CHAR_WORKBATTLEMODE ) != BATTLE_CHARMODE_NONE ){ + CHAR_talkToCli( charaindex0, -1, "", CHAR_COLORYELLOW ); + CHAR_talkToCli( charaindex1, -1, "", CHAR_COLORYELLOW ); + return BATTLE_ERR_ALREADYBATTLE; + } +#ifdef _DEATH_CONTEND + if( CHAR_getInt( charaindex0, CHAR_FLOOR) == 8250 || + CHAR_getInt( charaindex0, CHAR_PKLISTLEADER) != 1 || + CHAR_getInt( charaindex0, CHAR_PKLISTTEAMNUM) == -1 || +// CHAR_getWorkInt( charaindex0, CHAR_WORKPARTYMODE ) != CHAR_PARTY_LEADER || + CHAR_getInt( charaindex1, CHAR_PKLISTLEADER) != 1 || + CHAR_getInt( charaindex1, CHAR_PKLISTTEAMNUM) == -1 //|| +// CHAR_getWorkInt( charaindex1, CHAR_WORKPARTYMODE ) != CHAR_PARTY_LEADER + + ){ + + + CHAR_talkToCli( charaindex0, -1, "Чս", CHAR_COLORYELLOW ); + CHAR_talkToCli( charaindex1, -1, "Чս", CHAR_COLORYELLOW ); + return BATTLE_ERR_ALREADYBATTLE; + } +/* + + if( PKLIST_CheckPKReapetTeam( + CHAR_getInt( charaindex0, CHAR_PKLISTTEAMNUM), + CHAR_getInt( charaindex1, CHAR_PKLISTTEAMNUM) ) == FALSE ){ + CHAR_talkToCli( charaindex0, -1, "ظս", CHAR_COLORYELLOW ); + CHAR_talkToCli( charaindex1, -1, "ظս", CHAR_COLORYELLOW ); + return BATTLE_ERR_ALREADYBATTLE; + } +*/ +#endif + //ȡҵĵͼ-սʾ + field_no = NPC_Lua_getBattleFieldNo( + CHAR_getInt( charaindex0, CHAR_FLOOR ) , + CHAR_getInt( charaindex0, CHAR_X ), + CHAR_getInt( charaindex0, CHAR_Y ) ); + + charaindex[0] = charaindex0; + charaindex[1] = charaindex1; + for( j = 0; j < 2; j ++ ){ + if( CHAR_getWorkInt( charaindex[j], CHAR_WORKBATTLEMODE ) != 0 ){ + return BATTLE_ERR_ALREADYBATTLE; + } + } + for( j = 0; j < 2; j ++ ){ + if( CHAR_getWorkInt( charaindex[j], CHAR_WORKPARTYMODE ) == CHAR_PARTY_LEADER ){ + parent[j] = charaindex[j]; + }else + if( CHAR_getWorkInt( charaindex[j], CHAR_WORKPARTYMODE ) == CHAR_PARTY_CLIENT ){ + parent[j] = CHAR_getWorkInt( charaindex[j], CHAR_WORKPARTYINDEX1 ); + }else{ + parent[j] = -1; + } + } + if( parent[0] != -1 && parent[0] == parent[1] ){ + return BATTLE_ERR_SAMEPARTY; + } + battleindex = BATTLE_CreateBattle( charaindex0); + if( battleindex < 0 )return BATTLE_ERR_NOTASK; + + BattleArray[battleindex].Side[0].type = BATTLE_S_TYPE_PLAYER; + BattleArray[battleindex].Side[1].type = BATTLE_S_TYPE_PLAYER; + BattleArray[battleindex].leaderindex = charaindex0; + BattleArray[battleindex].type = BATTLE_TYPE_P_vs_P; + BattleArray[battleindex].dpbattle = 1; + BattleArray[battleindex].field_no = field_no; +#ifdef _BATTLE_TIMESPEED + BattleArray[battleindex].CreateTime = time(NULL); +#endif + +#ifdef _DEATH_CONTEND//ʤfunc + BattleArray[battleindex].PkFunc = NPC_PKLIST_Finish_Exit; + //winside = 0 + BattleArray[battleindex].menum = CHAR_getInt( charaindex0, CHAR_PKLISTTEAMNUM); + BattleArray[battleindex].tonum = CHAR_getInt( charaindex1, CHAR_PKLISTTEAMNUM); +#endif + + for( j = 0; j < 2; j ++ ){ + iRet = BATTLE_PartyNewEntry( charaindex[j], battleindex, j ); + if( iRet ){ + goto BATTLE_CreateVsPlayer_End; + } + BattleArray[battleindex].Side[j].flg &= ~BSIDE_FLG_HELP_OK; + } +BATTLE_CreateVsPlayer_End:; + if( iRet ){ + BATTLE_ExitAll( battleindex ); + BATTLE_DeleteBattle( battleindex ); + fd = getfdFromCharaIndex(charaindex[0]); + if( fd != -1 )lssproto_EN_send( fd, FALSE, field_no ); + }else{ + for( j = 0; j < 2; j ++ ){ + fd = getfdFromCharaIndex(charaindex[j]); + if( fd != -1 )lssproto_EN_send( fd, BattleArray[battleindex].type, field_no ); + if( CHAR_getWorkInt( charaindex[j], CHAR_WORKACTION) != -1 ) { + CHAR_sendWatchEvent( + CHAR_getWorkInt( charaindex[j], CHAR_WORKOBJINDEX), + CHAR_ACTSTAND, + NULL, 0, FALSE); + CHAR_setWorkInt( charaindex[j], CHAR_WORKACTION, -1); + + } + CHAR_sendBattleEffect( charaindex[j], ON); + for( i = 1; i < CHAR_PARTYMAX; i ++ ){ + pindex = CHAR_getWorkInt( charaindex[j], i + CHAR_WORKPARTYINDEX1 ); + if( CHAR_CHECKINDEX( pindex ) == FALSE )continue; + if( CHAR_getWorkInt( pindex, CHAR_WORKBATTLEMODE ) == + BATTLE_CHARMODE_FINAL ) continue; + + fd = getfdFromCharaIndex(pindex); + if( fd != -1 )lssproto_EN_send( fd, BattleArray[battleindex].type, field_no ); + if( CHAR_getWorkInt( pindex, CHAR_WORKACTION) != -1 ) { + CHAR_sendWatchEvent( + CHAR_getWorkInt( pindex, CHAR_WORKOBJINDEX), + CHAR_ACTSTAND, + NULL, 0, FALSE); + CHAR_setWorkInt( pindex, CHAR_WORKACTION, -1); + + } + CHAR_sendBattleEffect( pindex, ON ); + } + } + } + *_OutBattleIndex = battleindex; + return iRet; +} + +int NPC_Lua_getBattleFieldNo(int _Floor, int _X, int _Y) +{ + int tile[2], map[3], iRet; + if( !MAP_getTileAndObjData( _Floor, _X, _Y, &tile[0], &tile[1] ) ) + { + return FALSE; + } + map[0] = MAP_getImageInt( tile[0], MAP_BATTLEMAP ); + map[1] = MAP_getImageInt( tile[0], MAP_BATTLEMAP2 ); + map[2] = MAP_getImageInt( tile[0], MAP_BATTLEMAP3 ); + iRet = map[RAND( 0, 2 )]; + return iRet; +} + +#ifdef _CAX_LNS_NLGSUOXU +int NPC_PetUp(int charaindex, int lv, int petindex) +{ + int i = 0; + if( !CHAR_CHECKINDEX( petindex)) return -1; + for( i = 0; i < CHAR_MAXPETHAVE; i ++ ) + { + if( CHAR_getCharPet( charaindex, i ) == petindex )break; + } + + if( i != CHAR_MAXPETHAVE ) + { + if( CHAR_CHECKINDEX( petindex ) == TRUE ) + { + CHAR_setMaxExpFromLevel( petindex, CHAR_getInt( petindex, CHAR_LV )); + } + if( lv > 0 ) + { + int k = 0; + for( k = CHAR_getInt( petindex, CHAR_LV); k < lv; k++ ) + { // + //CHAR_PetLevelUp( petindex,1); + CHAR_PetLevelUp( petindex); + CHAR_PetAddVariableAi( petindex, AI_FIX_PETLEVELUP ); + CHAR_setInt( petindex, CHAR_LV, k + 1); + } + } + + CHAR_complianceParameter(petindex); + + { + char msgbuf[64]; + snprintf( msgbuf, sizeof( msgbuf ), "K%d", i ); + CHAR_sendStatusString( charaindex, msgbuf ); + snprintf( msgbuf, sizeof( msgbuf ), "W%d", i ); + CHAR_sendStatusString( charaindex, msgbuf ); +#ifdef _PET_SKILL2 + snprintf( msgbuf, sizeof( msgbuf ), "Q%d", i ); + CHAR_sendStatusString( charaindex, msgbuf ); +#endif + } + LogPet + ( + CHAR_getChar( charaindex, CHAR_NAME ), + CHAR_getChar( charaindex, CHAR_CDKEY ), + CHAR_getChar( petindex, CHAR_NAME), + CHAR_getInt( petindex, CHAR_LV), + "PetUp", + CHAR_getInt( charaindex,CHAR_FLOOR), + CHAR_getInt( charaindex,CHAR_X ), + CHAR_getInt( charaindex,CHAR_Y ), + CHAR_getChar( petindex, CHAR_UNIQUECODE) + ); + + return petindex; + }else + return -2; +} + + +int NPC_AddSk(int charaindex, int skindex, int sklv) +{ + char skk[64]; + if( !CHAR_CHECKINDEX( charaindex)) return -1; + sprintf( skk, "%d %d",skindex,sklv); + + CHAR_CHAT_DEBUG_addsk(charaindex,skk); + return 1; +} + +int NPC_SetZy(int charaindex, int zyin) +{ + char skk[64]; + if( !CHAR_CHECKINDEX( charaindex)) return -1; + sprintf( skk, "1 0 %d",zyin); + + CHAR_CHAT_DEBUG_show_profession(charaindex,skk); + return 1; +} +#endif + +#endif //#ifdef _JZ_NEWSCRIPT_LUA + +#ifdef _CAX_LNS_MYSQLSUOXU +void NPC_Lua_SQLPushAdvCallBack(int luaresult,int luaflg,int luaerrno,char* luaerrstr,int luafieldCount,int rowCount,int rowAt,char* row,char* filepath,char* function,int npcindex,int charaindex,char* msg) +{ + if(M_Script_Lua == NULL) + { + print("M_Script_Lua Null!"); + return ; + } + if (strcmp(filepath,"") != 0 || filepath[0] != '\0'){ + if(NPC_Lua_DoFile(filepath) != 0) + { + print("SQLűʧ Lua Err :(%s)[%s]\n", lua_tostring(M_Script_Lua, -1),function); + lua_pop(M_Script_Lua, 1); + return; + } + } + int TM_Ret = 0; + lua_getglobal(M_Script_Lua, (const char*)function); + if(lua_type(M_Script_Lua, -1) != LUA_TFUNCTION) + { + print("޷ִָ NPC_Lua_SQLPushAdvCallBack\n"); + return ; + } + lua_pushinteger(M_Script_Lua, (lua_Integer)luaresult); + lua_pushinteger(M_Script_Lua, (lua_Integer)luaflg); + lua_pushinteger(M_Script_Lua, (lua_Integer)luaerrno); + lua_pushstring(M_Script_Lua, luaerrstr); + lua_pushinteger(M_Script_Lua, (lua_Integer)luafieldCount); + lua_pushinteger(M_Script_Lua, (lua_Integer)rowCount); + lua_pushinteger(M_Script_Lua, (lua_Integer)rowAt); + int i; + char buf[128] = ""; + if (luaflg != 4) {//flg==4ʱ ֻͷŽҪˡ + lua_newtable( M_Script_Lua ); + for (i=0;i= 0 && TM_side < 2 && TM_num >=0 && TM_num < BATTLE_ENTRY_MAX) + { + TM_Ret = TM_Battle->Side[TM_side].Entry[TM_num].charaindex; + }else + { + LRetErrInt(_NLL , -3, "Χ"); + } + LRetInt(_NLL, TM_Ret); +} + +int NPC_Lua_Battle_SetNORisk(lua_State *_NLL) +{ + CheckEx(_NLL, 2); + assert(BattleArray != NULL); + CheckBattleIndexNull(_NLL, 1); + int TM_battleindex = (int)lua_tointeger(_NLL, 1); + int TM_vl = (int)lua_tointeger(_NLL, 2); + + if( BATTLE_CHECKINDEX( TM_battleindex ) == FALSE ) + { + LRetErrInt(_NLL , -1, "Чġ"); + } + + BATTLE *TM_Battle = &BattleArray[TM_battleindex]; + + if(TM_Battle == NULL) + { + LRetErrInt(_NLL , -2, "޷ȡָ롣"); + } + + int TM_Ret = TM_Battle->norisk; + TM_Battle->norisk = TM_vl; + + LRetInt(_NLL, TM_Ret); +} + +int NPC_Lua_Battle_SetMod(lua_State *_NLL) +{ + CheckEx(_NLL, 2); + assert(BattleArray != NULL); + CheckBattleIndexNull(_NLL, 1); + int TM_battleindex = (int)lua_tointeger(_NLL, 1); + int TM_vl = (int)lua_tointeger(_NLL, 2); + + if( BATTLE_CHECKINDEX( TM_battleindex ) == FALSE ) + { + LRetErrInt(_NLL , -1, "Чġ"); + } + + BATTLE *TM_Battle = &BattleArray[TM_battleindex]; + + if(TM_Battle == NULL) + { + LRetErrInt(_NLL , -2, "޷ȡָ롣"); + } + + int TM_Ret = TM_Battle->mode; + TM_Battle->mode = TM_vl; + + LRetInt(_NLL, TM_Ret); +} + +int NPC_Lua_Battle_SetType(lua_State *_NLL) +{ + CheckEx(_NLL, 2); + assert(BattleArray != NULL); + CheckBattleIndexNull(_NLL, 1); + int TM_battleindex = (int)lua_tointeger(_NLL, 1); + int TM_vl = (int)lua_tointeger(_NLL, 2); + + if( BATTLE_CHECKINDEX( TM_battleindex ) == FALSE ) + { + LRetErrInt(_NLL , -1, "Чġ"); + } + + BATTLE *TM_Battle = &BattleArray[TM_battleindex]; + + if(TM_Battle == NULL) + { + LRetErrInt(_NLL , -2, "޷ȡָ롣"); + } + + int TM_Ret = TM_Battle->type; + TM_Battle->type = TM_vl; + + LRetInt(_NLL, TM_Ret); +} + +int NPC_Lua_Battle_SetWinEvent(lua_State *_NLL) +{ + CheckEx(_NLL, 3); + assert(BattleArray != NULL); + CheckBattleIndexNull(_NLL, 3); + int TM_battleindex = (int)lua_tointeger(_NLL, 3); + + if( BATTLE_CHECKINDEX( TM_battleindex ) == FALSE ) + { + LRetErrInt(_NLL , -1, "Чġ"); + } + + BATTLE *TM_Battle = &BattleArray[TM_battleindex]; + + if(TM_Battle == NULL) + { + LRetErrInt(_NLL , -2, "޷ȡָ롣"); + } + + int TM_Ret = NPC_Lua_GetFuncPoint(_NLL); + + if(lua_tointeger(_NLL, -1) > 0) + { + if( (void *)(TM_Battle->WinFunc) != (void *)NPC_Lua_BattleWinCallBack) + { + TM_Battle->BakFunc = TM_Battle->WinFunc; + TM_Battle->WinFunc = (void *)NPC_Lua_BattleWinCallBack; + strcpy_s(TM_Battle->BakLuaFuncName, sizeof(TM_Battle->BakLuaFuncName), lua_tostring(_NLL, 2)); + } + } + else + { + if((void *)(TM_Battle->WinFunc) == (void *)NPC_Lua_BattleWinCallBack) + { + TM_Battle->BakLuaFuncName[0] = '\0'; + TM_Battle->WinFunc = TM_Battle->BakFunc; + } + } + return TM_Ret; +} + +int NPC_Lua_Battle_GetData(lua_State *_NLL) +{ + CheckEx(_NLL, 2); + int TM_Ret; + assert(BattleArray != NULL); + CheckBattleIndexNull(_NLL, 1); + int TM_battleindex = (int)lua_tointeger(_NLL, 1); + int TM_FLG = (int)lua_tointeger(_NLL, 2); + char* TM_Buff = "\0"; + if( BATTLE_CHECKINDEX( TM_battleindex ) == FALSE ) + { + LRetErrInt(_NLL , -1, "Чġ"); + } + + BATTLE *TM_Battle = &BattleArray[TM_battleindex]; + + if(TM_Battle == NULL) + { + LRetErrInt(_NLL , -2, "޷ȡָ롣"); + } + + if (TM_FLG == 0) + { + TM_Ret = TM_Battle->battleindex; + } + else if (TM_FLG == 1) + { + TM_Ret = TM_Battle->dpbattle; + } + else if (TM_FLG == 2) + { + TM_Ret = TM_Battle->turn; + } + else if (TM_FLG == 3) + { + TM_Ret = TM_Battle->timer; + } + else if (TM_FLG == 4) + { + TM_Ret = TM_Battle->leaderindex; + } + else if (TM_FLG == 5) + { + TM_Ret = TM_Battle->rivalindex; + } + else if (TM_FLG == 6) + { + TM_Buff = TM_Battle->leadercdkey; + } + else if (TM_FLG == 7) + { + TM_Buff = TM_Battle->leadername; + } + else if (TM_FLG == 8) + { + TM_Buff = TM_Battle->rivalcdkey; + } + else if (TM_FLG == 9) + { + TM_Buff = TM_Battle->rivalname; + } + else if (TM_FLG == 10) + { + TM_Ret = TM_Battle->CreateTime; + } + else if (TM_FLG == 11) + { + TM_Ret = TM_Battle->EndTime; + } + else if (TM_FLG == 12) + { + TM_Ret = TM_Battle->PartTime; + } + else if (TM_FLG == 13) + { + TM_Ret = TM_Battle->flgTime; + } + else if (TM_FLG == 14) + { + TM_Ret = TM_Battle->createindex; + } + else if (TM_FLG == 15) + { + TM_Ret = TM_Battle->mode; + } + else if (TM_FLG == 16) + { + TM_Ret = TM_Battle->type; + } + else if (TM_FLG == 17) + { + TM_Ret = TM_Battle->norisk; + } + else if (TM_FLG == 18) + { + TM_Ret = TM_Battle->winside; + } + if (TM_FLG >=6 && TM_FLG <= 9) { + LRetMsg(_NLL, TM_Buff); + } + else LRetInt(_NLL, TM_Ret); + + LRetErrNull(_NLL, "ı־Ǵġ"); +} + +int NPC_Lua_Battle_IndexToNo(lua_State *_NLL) +{ + CheckEx(_NLL, 2); + CheckBattleIndexNull(_NLL, 1); + int TM_battleindex = (int)lua_tointeger(_NLL, 1); + int TM_index = (int)lua_tointeger(_NLL, 2); + + if( BATTLE_CHECKINDEX( TM_battleindex ) == FALSE ) + { + LRetErrInt(_NLL , -1, "Чġ"); + } + if( CHAR_CHECKINDEX( TM_index ) == FALSE ) + { + LRetErrInt(_NLL , -1, "Чġ"); + } + int TM_Ret = BATTLE_Index2No( TM_battleindex, TM_index ); + LRetInt(_NLL, TM_Ret); +} + +int NPC_Lua_Battle_NoToIndex(lua_State *_NLL) +{ + CheckEx(_NLL, 2); + CheckBattleIndexNull(_NLL, 1); + int TM_battleindex = (int)lua_tointeger(_NLL, 1); + int TM_No = (int)lua_tointeger(_NLL, 2); + + if( BATTLE_CHECKINDEX( TM_battleindex ) == FALSE ) + { + LRetErrInt(_NLL , -1, "Чġ"); + } + int TM_Ret = BATTLE_No2Index( TM_battleindex, TM_No ); + LRetInt(_NLL, TM_Ret); +} + +int NPC_Lua_Battle_CheckIndex(lua_State *_NLL) +{ + CheckEx(_NLL, 1); + CheckBattleIndexNull(_NLL, 1); + int TM_battleindex = (int)lua_tointeger(_NLL, 1); + + BOOL TM_Ret = BATTLE_CHECKINDEX( TM_battleindex ); + LRetBool(_NLL, TM_Ret); +} + +int NPC_Lua_Battle_SetData(lua_State *_NLL) +{ + CheckEx(_NLL, 3); + int TM_Ret; + char * TM_Buff = "\0"; + assert(BattleArray != NULL); + CheckBattleIndexNull(_NLL, 1); + int TM_battleindex = (int)lua_tointeger(_NLL, 1); + int TM_FLG = (int)lua_tointeger(_NLL, 2); + int TM_INT = -1; + char *TM_MSG = "\0"; + if( BATTLE_CHECKINDEX( TM_battleindex ) == FALSE ) + { + LRetErrInt(_NLL , -1, "Чġ"); + } + if (TM_FLG >=6 && TM_FLG <= 9) { + TM_MSG = lua_tostring(_NLL, 3); + }else{ + TM_INT = (int)lua_tointeger(_NLL, 3); + } + BATTLE *TM_Battle = &BattleArray[TM_battleindex]; + + if(TM_Battle == NULL) + { + LRetErrInt(_NLL , -2, "޷ȡָ롣"); + } + + if (TM_FLG == 0) + { + TM_Ret = TM_Battle->battleindex; + TM_Battle->battleindex = TM_INT; + } + else if (TM_FLG == 1) + { + TM_Ret = TM_Battle->dpbattle; + TM_Battle->dpbattle = TM_INT; + } + else if (TM_FLG == 2) + { + TM_Ret = TM_Battle->turn; + TM_Battle->turn = TM_INT; + } + else if (TM_FLG == 3) + { + TM_Ret = TM_Battle->timer; + TM_Battle->timer = TM_INT; + } + else if (TM_FLG == 4) + { + TM_Ret = TM_Battle->leaderindex; + TM_Battle->leaderindex = TM_INT; + } + else if (TM_FLG == 5) + { + TM_Ret = TM_Battle->rivalindex; + TM_Battle->rivalindex = TM_INT; + } + else if (TM_FLG == 6) + { + TM_Buff = TM_Battle->leadercdkey; + strcpy(TM_Battle->leadercdkey,TM_MSG); + } + else if (TM_FLG == 7) + { + TM_Buff = TM_Battle->leadername; + strcpy(TM_Battle->leadername,TM_MSG); + } + else if (TM_FLG == 8) + { + TM_Buff = TM_Battle->rivalcdkey; + strcpy(TM_Battle->rivalcdkey,TM_MSG); + } + else if (TM_FLG == 9) + { + TM_Buff = TM_Battle->rivalname; + strcpy(TM_Battle->rivalname,TM_MSG); + } + else if (TM_FLG == 10) + { + TM_Ret = TM_Battle->CreateTime; + TM_Battle->CreateTime = TM_INT; + } + else if (TM_FLG == 11) + { + TM_Ret = TM_Battle->EndTime; + TM_Battle->EndTime = TM_INT; + } + else if (TM_FLG == 12) + { + TM_Ret = TM_Battle->PartTime; + TM_Battle->PartTime = TM_INT; + } + else if (TM_FLG == 13) + { + TM_Ret = TM_Battle->flgTime; + TM_Battle->flgTime = TM_INT; + } + else if (TM_FLG == 14) + { + TM_Ret = TM_Battle->createindex; + TM_Battle->createindex = TM_INT; + } + else if (TM_FLG == 15) + { + TM_Ret = TM_Battle->mode; + TM_Battle->mode = TM_INT; + } + else if (TM_FLG == 16) + { + TM_Ret = TM_Battle->type; + TM_Battle->type = TM_INT; + } + else if (TM_FLG == 17) + { + TM_Ret = TM_Battle->norisk; + TM_Battle->norisk = TM_INT; + } + else if (TM_FLG == 18) + { + TM_Ret = TM_Battle->winside; + TM_Battle->winside = TM_INT; + } + if (TM_FLG >=6 && TM_FLG <= 9) { + LRetMsg(_NLL, TM_Buff); + } + else LRetInt(_NLL, TM_Ret); + + LRetErrNull(_NLL, "ı־Ǵġ"); +} + +int NPC_Lua_Battle_Exit(lua_State *_NLL) +{ + CheckEx(_NLL, 2); + CheckBattleIndexNull(_NLL, 1); + int TM_index = (int)lua_tointeger(_NLL, 1); + int TM_battleindex = (int)lua_tointeger(_NLL, 2); + + if( BATTLE_CHECKINDEX( TM_battleindex ) == FALSE ) + { + LRetErrInt(_NLL , -1, "Чġ"); + } + if( CHAR_CHECKINDEX( TM_index ) == FALSE ) + { + LRetErrInt(_NLL , -2, "Чġ"); + } + BATTLE_Exit( TM_index, TM_battleindex ); + // ɡ ū + CHAR_DischargePartyNoMsg( TM_index ); + + CHAR_talkToCli( TM_index, -1, + "սֹ", CHAR_COLORYELLOW ); + + lssproto_B_send( getfdFromCharaIndex( TM_index ), "BU" ); + + + LRetInt(_NLL, 0); +} + + +int NPC_Lua_Battle_SetEndEvent(lua_State *_NLL) +{ + CheckEx(_NLL, 3); + assert(BattleArray != NULL); + CheckBattleIndexNull(_NLL, 3); + int TM_battleindex = (int)lua_tointeger(_NLL, 3); + + if( BATTLE_CHECKINDEX( TM_battleindex ) == FALSE ) + { + LRetErrInt(_NLL , -1, "Чġ"); + } + + BATTLE *TM_Battle = &BattleArray[TM_battleindex]; + + if(TM_Battle == NULL) + { + LRetErrInt(_NLL , -2, "޷ȡָ롣"); + } + + int TM_Ret = NPC_Lua_GetFuncPoint(_NLL); + + TM_Battle->EndFunc = (void *)NPC_Lua_BattleEndCallBack; + + strcpy_s(TM_Battle->EndLuaFuncName, sizeof(TM_Battle->EndLuaFuncName), lua_tostring(_NLL, 2)); + return TM_Ret; +} + + +#endif //#ifdef _JZ_NEWSCRIPT_LUA + + +int NPC_Lua_Bit_band(lua_State *_NLL) +{ + CheckEx2(_NLL, 2, 5); + CheckIndexNull(_NLL, 1); + CheckIndexNull(_NLL, 2); + int TM_Top = lua_gettop(_NLL); + int a = (int)lua_tointeger(_NLL, 1); + int b = (int)lua_tointeger(_NLL, 2); + int c,d,e; + if(TM_Top >= 3) + { + c = (int)lua_tointeger(_NLL, 3); + a = a&b; + LRetInt(_NLL,a); + } + if(TM_Top >= 4) + { + d = (int)lua_tointeger(_NLL, 4); + LRetInt(_NLL,a&b&c&d); + } + if(TM_Top >= 5) + { + e = (int)lua_tointeger(_NLL, 5); + LRetInt(_NLL,a&b&c&d&e); + }else LRetInt(_NLL,a&b); +} + +int NPC_Lua_Bit_bor(lua_State *_NLL) +{ + CheckEx2(_NLL, 2, 5); + CheckIndexNull(_NLL, 1); + CheckIndexNull(_NLL, 2); + int TM_Top = lua_gettop(_NLL); + int a = (int)lua_tointeger(_NLL, 1); + int b = (int)lua_tointeger(_NLL, 2); + int c,d,e; + if(TM_Top >= 3) + { + c = (int)lua_tointeger(_NLL, 3); + LRetInt(_NLL,a|b|c); + } + if(TM_Top >= 4) + { + d = (int)lua_tointeger(_NLL, 4); + LRetInt(_NLL,a|b|c|d); + } + if(TM_Top >= 5) + { + e = (int)lua_tointeger(_NLL, 5); + LRetInt(_NLL,a|b|c|d|e); + }else LRetInt(_NLL,a|b); +} + +int NPC_Lua_Bit_bxor(lua_State *_NLL) +{ + CheckEx2(_NLL, 2, 5); + CheckIndexNull(_NLL, 1); + CheckIndexNull(_NLL, 2); + int TM_Top = lua_gettop(_NLL); + int a = (int)lua_tointeger(_NLL, 1); + int b = (int)lua_tointeger(_NLL, 2); + int c,d,e; + if(TM_Top >= 3) + { + c = (int)lua_tointeger(_NLL, 3); + LRetInt(_NLL,a^b^c); + } + if(TM_Top >= 4) + { + d = (int)lua_tointeger(_NLL, 4); + LRetInt(_NLL,a^b^c^d); + } + if(TM_Top >= 5) + { + e = (int)lua_tointeger(_NLL, 5); + LRetInt(_NLL,a^b^c^d^e); + }else LRetInt(_NLL,a^b); +} + +int NPC_Lua_Bit_lshift(lua_State *_NLL) +{ + CheckEx2(_NLL, 2,2); + CheckIndexNull(_NLL, 1); + int TM_Top = lua_gettop(_NLL); + int a = (int)lua_tointeger(_NLL, 1); + int b = (int)lua_tointeger(_NLL, 2); + LRetInt(_NLL,a<>b); +} + diff --git a/npc_lua/npc_lua_char.c b/npc_lua/npc_lua_char.c new file mode 100644 index 0000000..5f54913 --- /dev/null +++ b/npc_lua/npc_lua_char.c @@ -0,0 +1,2335 @@ +#include "npc_lua.h" +#include "util.h" +#include "char.h" +#include "char_base.h" +#include "anim_tbl.h" +#include "object.h" +#include "net.h" +#include "npcutil.h" +#include "npc_eventaction.h" +#include "battle.h" +#include "readmap.h" +#include "sasql.h" +#include "pet_skill.h" +#include "enemy.h" +#include "family.h" + +extern char hanzibuf[5000][8]; + +#ifdef _JZ_NEWSCRIPT_LUA + +////////////////////////////////////////////////////////////////////////////// +//ݵĽӿ +int NPC_Lua_Char_ClrEvtEnd(lua_State *_NLL) +{ + CheckEx2(_NLL, 2, LUA_MINSTACK); + CheckIndexNull(_NLL, 1); + int TM_Index = (int)lua_tointeger(_NLL, 1); + int TM_Max = lua_gettop(_NLL); + int TM_EveNo = -1; + int i = 0; + for(i = 2; i <= TM_Max; i++) + { + TM_EveNo = (int)lua_tointeger(_NLL, i); + NPC_EndEventSetFlgCls(TM_Index, TM_EveNo); + } + + LRetInt(_NLL, TM_EveNo); +} + +int NPC_Lua_Char_ClrEvtNow(lua_State *_NLL) +{ + CheckEx2(_NLL, 2, LUA_MINSTACK); + CheckIndexNull(_NLL, 1); + int TM_Index = (int)lua_tointeger(_NLL, 1); + int TM_Max = lua_gettop(_NLL); + int TM_EveNo = -1; + int i = 0; + for(i = 2; i <= TM_Max; i++) + { + TM_EveNo = (int)lua_tointeger(_NLL, i); + NPC_NowEventSetFlgCls(TM_Index, TM_EveNo); + } + LRetInt(_NLL, TM_EveNo); +} + +int NPC_Lua_Char_ClrEvt(lua_State *_NLL) +{ + CheckEx2(_NLL, 2, LUA_MINSTACK); + CheckIndexNull(_NLL, 1); + int TM_Index = (int)lua_tointeger(_NLL, 1); + int TM_Max = lua_gettop(_NLL); + int TM_EveNo = -1; + int i = 0; + for(i = 2; i <= TM_Max; i++) + { + TM_EveNo = (int)lua_tointeger(_NLL, i); + NPC_NowEndEventSetFlgCls(TM_Index, TM_EveNo); + } + LRetInt(_NLL, TM_EveNo); +} + +int NPC_Lua_Char_SetEvtEnd(lua_State *_NLL) +{ + CheckEx2(_NLL, 2, LUA_MINSTACK); + CheckIndexNull(_NLL, 1); + int TM_Index = (int)lua_tointeger(_NLL, 1); + int TM_Max = lua_gettop(_NLL); + int TM_EveNo = -1; + int i = 0; + for(i = 2; i <= TM_Max; i++) + { + TM_EveNo = (int)lua_tointeger(_NLL, i); + NPC_EventSetFlg(TM_Index, TM_EveNo); + } + + LRetInt(_NLL, TM_EveNo); +} + +int NPC_Lua_Char_SetEvtNow(lua_State *_NLL) +{ + CheckEx2(_NLL, 2, LUA_MINSTACK); + CheckIndexNull(_NLL, 1); + int TM_Index = (int)lua_tointeger(_NLL, 1); + int TM_Max = lua_gettop(_NLL); + int TM_EveNo = -1; + int i = 0; + for(i = 2; i <= TM_Max; i++) + { + TM_EveNo = (int)lua_tointeger(_NLL, i); + NPC_NowEventSetFlg(TM_Index, TM_EveNo); + } + + LRetInt(_NLL, TM_EveNo); +} + +int NPC_Lua_Char_SetData(lua_State *_NLL) +{ + CheckEx(_NLL, 3); + CheckIndexNull(_NLL, 1); + int TM_Index = (int)lua_tointeger(_NLL, 1); + int TM_Flg = (int)lua_tointeger(_NLL, 2); + + if(TM_Flg >= 0) + { + if(TM_Flg < LUA_DATALINE1) + { + TM_Flg -= LUA_DATALINE0; + if(TM_Flg == CHAR_WHICHTYPE) + { + LRetInt(_NLL, 0); + } + int TM_IntVal = (int)lua_tointeger(_NLL, 3); +#ifdef _JZ_BILLING_SYSTEM + if(TM_Flg == CHAR_VIPPOINT) + { + saacproto_IncreaseMPoint_send(acfd, -1, CHAR_getChar( TM_Index, CHAR_CDKEY ), "ӻԱ", TM_IntVal - CHAR_getInt(TM_Index, TM_Flg)); + } +#endif + int TM_RetInt = CHAR_setInt(TM_Index, TM_Flg, TM_IntVal); +#ifdef _JZ_SAVE + if(TM_Flg == CHAR_MEMBERORDER) + { + CHAR_charSaveFromConnect(TM_Index, FALSE); + } +#endif + LRetInt(_NLL, TM_RetInt); + }else if(TM_Flg < LUA_DATALINE2) + { + TM_Flg -= LUA_DATALINE1; + char *TM_CharPoint = (char *)lua_tostring(_NLL, 3); + BOOL TM_RetBOOL = CHAR_setChar(TM_Index, TM_Flg, TM_CharPoint); + LRetBool(_NLL, TM_RetBOOL); + }else if(TM_Flg < LUA_DATALINE3) + { + TM_Flg -= LUA_DATALINE2; + if(TM_Flg == CHAR_WORKOBJINDEX || TM_Flg == CHAR_WORKACTION) + { + LRetInt(_NLL, 0); + } + int TM_WorkIntVal = (int)lua_tointeger(_NLL, 3); + int TM_RetInt = CHAR_setWorkInt(TM_Index, TM_Flg, TM_WorkIntVal); + LRetInt(_NLL, TM_RetInt); + }else if(TM_Flg < LUA_DATALINE4) + { + TM_Flg -= LUA_DATALINE3; + char *TM_WorkCharPoint = (char *)lua_tostring(_NLL, 3); + BOOL TM_RetBOOL = CHAR_setWorkChar(TM_Index, TM_Flg, TM_WorkCharPoint); + LRetBool(_NLL, TM_RetBOOL); + }else if(TM_Flg < LUA_DATALINE5) + { + TM_Flg -= LUA_DATALINE4; + BOOL TM_BOOLVal = (BOOL)lua_toboolean(_NLL, 3); + int TM_RetInt = CHAR_setFlg(TM_Index, TM_Flg, TM_BOOLVal); + LRetInt(_NLL, TM_RetInt); + }else + { + LRetErrNull(_NLL, "ı־Ǵġ"); + } + } + LRetErrNull(_NLL, "ı־Ǵġ"); +} + +////////////////////////////////////////////////////////////////////////////// +//¼õĽӿ +int NPC_Lua_Char_SetWalkPreEvent(lua_State *_NLL) +{ + CheckEx(_NLL, 3); + CheckIndexNull(_NLL, 3); + int TM_index = (int)lua_tointeger(_NLL, 3); + + Char *TM_char = CHAR_getCharPointer(TM_index); + + if(TM_char == NULL) + { + LRetErrInt(_NLL , -1, "Чġ"); + } + int TM_Ret = NPC_Lua_GetFuncPoint(_NLL); + + if(lua_tointeger(_NLL, -1) > 0) + { + if(TM_char->functable[CHAR_WALKPREFUNC] != (void *)NPC_Lua_WalkPreCallBack) + { + if(TM_char->functable[CHAR_WALKPREFUNC] != NULL) + { + TM_char->sur_functable[CHAR_WALKPREFUNC] = TM_char->functable[CHAR_WALKPREFUNC]; + strcpy_s(TM_char->sur_charfunctable[CHAR_WALKPREFUNC].string, sizeof(TM_char->sur_charfunctable[CHAR_WALKPREFUNC].string), TM_char->charfunctable[CHAR_WALKPREFUNC].string); + }else + { + TM_char->sur_functable[CHAR_WALKPREFUNC] = (void *)NULL; + TM_char->sur_charfunctable[CHAR_WALKPREFUNC].string[0] = '\0'; + } + + TM_char->functable[CHAR_WALKPREFUNC] = (void *)NPC_Lua_WalkPreCallBack; + strcpy_s(TM_char->lua_charfunctable[CHAR_WALKPREFUNC].string, sizeof(TM_char->lua_charfunctable[CHAR_WALKPREFUNC].string), lua_tostring(_NLL, 2)); + strcpy_s(TM_char->charfunctable[CHAR_WALKPREFUNC].string, sizeof(TM_char->charfunctable[CHAR_WALKPREFUNC].string), FUNCNAME_WALKPRECALLBACK); + } + }else + { + if(TM_char->functable[CHAR_WALKPREFUNC] == (void *)NPC_Lua_WalkPreCallBack) + { + TM_char->lua_charfunctable[CHAR_WALKPREFUNC].string[0] = '\0'; + if(TM_char->sur_functable[CHAR_WALKPREFUNC] == NULL) + { + TM_char->functable[CHAR_WALKPREFUNC] = (void *)NULL; + TM_char->charfunctable[CHAR_WALKPREFUNC].string[0] = '\0'; + }else + { + TM_char->functable[CHAR_WALKPREFUNC] = TM_char->sur_functable[CHAR_WALKPREFUNC]; + TM_char->sur_functable[CHAR_WALKPREFUNC] = (void *)NULL; + strcpy_s(TM_char->charfunctable[CHAR_WALKPREFUNC].string, sizeof(TM_char->charfunctable[CHAR_WALKPREFUNC].string), TM_char->sur_charfunctable[CHAR_WALKPREFUNC].string); + } + } + } + return TM_Ret; +} + +int NPC_Lua_Char_SetWalkPostEvent(lua_State *_NLL) +{ + CheckEx(_NLL, 3); + CheckIndexNull(_NLL, 3); + int TM_index = (int)lua_tointeger(_NLL, 3); + + Char *TM_char = CHAR_getCharPointer(TM_index); + + if(TM_char == NULL) + { + LRetErrInt(_NLL , -1, "Чġ"); + } + int TM_Ret = NPC_Lua_GetFuncPoint(_NLL); + + if(lua_tointeger(_NLL, -1) > 0) + { + if(TM_char->functable[CHAR_WALKPOSTFUNC] != (void *)NPC_Lua_WalkPostCallBack) + { + if(TM_char->functable[CHAR_WALKPOSTFUNC] != NULL) + { + TM_char->sur_functable[CHAR_WALKPOSTFUNC] = TM_char->functable[CHAR_WALKPOSTFUNC]; + strcpy_s(TM_char->sur_charfunctable[CHAR_WALKPOSTFUNC].string, sizeof(TM_char->sur_charfunctable[CHAR_WALKPOSTFUNC].string), TM_char->charfunctable[CHAR_WALKPOSTFUNC].string); + }else + { + TM_char->sur_functable[CHAR_WALKPOSTFUNC] = (void *)NULL; + TM_char->sur_charfunctable[CHAR_WALKPOSTFUNC].string[0] = '\0'; + } + + TM_char->functable[CHAR_WALKPOSTFUNC] = (void *)NPC_Lua_WalkPostCallBack; + strcpy_s(TM_char->lua_charfunctable[CHAR_WALKPOSTFUNC].string, sizeof(TM_char->lua_charfunctable[CHAR_WALKPOSTFUNC].string), lua_tostring(_NLL, 2)); + strcpy_s(TM_char->charfunctable[CHAR_WALKPOSTFUNC].string, sizeof(TM_char->charfunctable[CHAR_WALKPOSTFUNC].string), FUNCNAME_WALKPOSTCALLBACK); + } + }else + { + if(TM_char->functable[CHAR_WALKPOSTFUNC] == (void *)NPC_Lua_WalkPostCallBack) + { + TM_char->lua_charfunctable[CHAR_WALKPOSTFUNC].string[0] = '\0'; + if(TM_char->sur_functable[CHAR_WALKPOSTFUNC] == NULL) + { + TM_char->functable[CHAR_WALKPOSTFUNC] = (void *)NULL; + TM_char->charfunctable[CHAR_WALKPOSTFUNC].string[0] = '\0'; + }else + { + TM_char->functable[CHAR_WALKPOSTFUNC] = TM_char->sur_functable[CHAR_WALKPOSTFUNC]; + TM_char->sur_functable[CHAR_WALKPOSTFUNC] = (void *)NULL; + strcpy_s(TM_char->charfunctable[CHAR_WALKPOSTFUNC].string, sizeof(TM_char->charfunctable[CHAR_WALKPOSTFUNC].string), TM_char->sur_charfunctable[CHAR_WALKPOSTFUNC].string); + } + } + } + return TM_Ret; +} + +int NPC_Lua_Char_SetPreOverEvent(lua_State *_NLL) +{ + CheckEx(_NLL, 3); + CheckIndexNull(_NLL, 3); + int TM_index = (int)lua_tointeger(_NLL, 3); + + Char *TM_char = CHAR_getCharPointer(TM_index); + + if(TM_char == NULL) + { + LRetErrInt(_NLL , -1, "Чġ"); + } + int TM_Ret = NPC_Lua_GetFuncPoint(_NLL); + + if(lua_tointeger(_NLL, -1) > 0) + { + if(TM_char->functable[CHAR_PREOVERFUNC] != (void *)NPC_Lua_PreOverCallBack) + { + if(TM_char->functable[CHAR_PREOVERFUNC] != NULL) + { + TM_char->sur_functable[CHAR_PREOVERFUNC] = TM_char->functable[CHAR_PREOVERFUNC]; + strcpy_s(TM_char->sur_charfunctable[CHAR_PREOVERFUNC].string, sizeof(TM_char->sur_charfunctable[CHAR_PREOVERFUNC].string), TM_char->charfunctable[CHAR_PREOVERFUNC].string); + }else + { + TM_char->sur_functable[CHAR_PREOVERFUNC] = (void *)NULL; + TM_char->sur_charfunctable[CHAR_PREOVERFUNC].string[0] = '\0'; + } + + TM_char->functable[CHAR_PREOVERFUNC] = (void *)NPC_Lua_PreOverCallBack; + strcpy_s(TM_char->lua_charfunctable[CHAR_PREOVERFUNC].string, sizeof(TM_char->lua_charfunctable[CHAR_PREOVERFUNC].string), lua_tostring(_NLL, 2)); + strcpy_s(TM_char->charfunctable[CHAR_PREOVERFUNC].string, sizeof(TM_char->charfunctable[CHAR_PREOVERFUNC].string), FUNCNAME_PREOVERCALLBACK); + } + }else + { + if(TM_char->functable[CHAR_PREOVERFUNC] == (void *)NPC_Lua_PreOverCallBack) + { + TM_char->lua_charfunctable[CHAR_PREOVERFUNC].string[0] = '\0'; + if(TM_char->sur_functable[CHAR_PREOVERFUNC] == NULL) + { + TM_char->functable[CHAR_PREOVERFUNC] = (void *)NULL; + TM_char->charfunctable[CHAR_PREOVERFUNC].string[0] = '\0'; + }else + { + TM_char->functable[CHAR_PREOVERFUNC] = TM_char->sur_functable[CHAR_PREOVERFUNC]; + TM_char->sur_functable[CHAR_PREOVERFUNC] = (void *)NULL; + strcpy_s(TM_char->charfunctable[CHAR_PREOVERFUNC].string, sizeof(TM_char->charfunctable[CHAR_PREOVERFUNC].string), TM_char->sur_charfunctable[CHAR_PREOVERFUNC].string); + } + } + } + return TM_Ret; +} + +int NPC_Lua_Char_SetPostOverEvent(lua_State *_NLL) +{ + CheckEx(_NLL, 3); + CheckIndexNull(_NLL, 3); + int TM_index = (int)lua_tointeger(_NLL, 3); + + Char *TM_char = CHAR_getCharPointer(TM_index); + + if(TM_char == NULL) + { + LRetErrInt(_NLL , -1, "Чġ"); + } + int TM_Ret = NPC_Lua_GetFuncPoint(_NLL); + + if(lua_tointeger(_NLL, -1) > 0) + { + if(TM_char->functable[CHAR_POSTOVERFUNC] != (void *)NPC_Lua_PostOverCallBack) + { + if(TM_char->functable[CHAR_POSTOVERFUNC] != NULL) + { + TM_char->sur_functable[CHAR_POSTOVERFUNC] = TM_char->functable[CHAR_POSTOVERFUNC]; + strcpy_s(TM_char->sur_charfunctable[CHAR_POSTOVERFUNC].string, sizeof(TM_char->sur_charfunctable[CHAR_POSTOVERFUNC].string), TM_char->charfunctable[CHAR_POSTOVERFUNC].string); + }else + { + TM_char->sur_functable[CHAR_POSTOVERFUNC] = (void *)NULL; + TM_char->sur_charfunctable[CHAR_POSTOVERFUNC].string[0] = '\0'; + } + + TM_char->functable[CHAR_POSTOVERFUNC] = (void *)NPC_Lua_PostOverCallBack; + strcpy_s(TM_char->lua_charfunctable[CHAR_POSTOVERFUNC].string, sizeof(TM_char->lua_charfunctable[CHAR_POSTOVERFUNC].string), lua_tostring(_NLL, 2)); + strcpy_s(TM_char->charfunctable[CHAR_POSTOVERFUNC].string, sizeof(TM_char->charfunctable[CHAR_POSTOVERFUNC].string), FUNCNAME_POSTOVERCALLBACK); + } + }else + { + if(TM_char->functable[CHAR_POSTOVERFUNC] == (void *)NPC_Lua_PostOverCallBack) + { + TM_char->lua_charfunctable[CHAR_POSTOVERFUNC].string[0] = '\0'; + if(TM_char->sur_functable[CHAR_POSTOVERFUNC] == NULL) + { + TM_char->functable[CHAR_POSTOVERFUNC] = (void *)NULL; + TM_char->charfunctable[CHAR_POSTOVERFUNC].string[0] = '\0'; + }else + { + TM_char->functable[CHAR_POSTOVERFUNC] = TM_char->sur_functable[CHAR_POSTOVERFUNC]; + TM_char->sur_functable[CHAR_POSTOVERFUNC] = (void *)NULL; + strcpy_s(TM_char->charfunctable[CHAR_POSTOVERFUNC].string, sizeof(TM_char->charfunctable[CHAR_POSTOVERFUNC].string), TM_char->sur_charfunctable[CHAR_POSTOVERFUNC].string); + } + } + } + return TM_Ret; +} + +int NPC_Lua_Char_SetWatchEvent(lua_State *_NLL) +{ + CheckEx(_NLL, 3); + CheckIndexNull(_NLL, 3); + int TM_index = (int)lua_tointeger(_NLL, 3); + + Char *TM_char = CHAR_getCharPointer(TM_index); + + if(TM_char == NULL) + { + LRetErrInt(_NLL , -1, "Чġ"); + } + int TM_Ret = NPC_Lua_GetFuncPoint(_NLL); + + if(lua_tointeger(_NLL, -1) > 0) + { + if(TM_char->functable[CHAR_WATCHFUNC] != (void *)NPC_Lua_WatchCallBack) + { + if(TM_char->functable[CHAR_WATCHFUNC] != NULL) + { + TM_char->sur_functable[CHAR_WATCHFUNC] = TM_char->functable[CHAR_WATCHFUNC]; + strcpy_s(TM_char->sur_charfunctable[CHAR_WATCHFUNC].string, sizeof(TM_char->sur_charfunctable[CHAR_WATCHFUNC].string), TM_char->charfunctable[CHAR_WATCHFUNC].string); + }else + { + TM_char->sur_functable[CHAR_WATCHFUNC] = (void *)NULL; + TM_char->sur_charfunctable[CHAR_WATCHFUNC].string[0] = '\0'; + } + + TM_char->functable[CHAR_WATCHFUNC] = (void *)NPC_Lua_WatchCallBack; + strcpy_s(TM_char->lua_charfunctable[CHAR_WATCHFUNC].string, sizeof(TM_char->lua_charfunctable[CHAR_WATCHFUNC].string), lua_tostring(_NLL, 2)); + strcpy_s(TM_char->charfunctable[CHAR_WATCHFUNC].string, sizeof(TM_char->charfunctable[CHAR_WATCHFUNC].string), FUNCNAME_WATCHCALLBACK); + } + }else + { + if(TM_char->functable[CHAR_WATCHFUNC] == (void *)NPC_Lua_WatchCallBack) + { + TM_char->lua_charfunctable[CHAR_WATCHFUNC].string[0] = '\0'; + if(TM_char->sur_functable[CHAR_WATCHFUNC] == NULL) + { + TM_char->functable[CHAR_WATCHFUNC] = (void *)NULL; + TM_char->charfunctable[CHAR_WATCHFUNC].string[0] = '\0'; + }else + { + TM_char->functable[CHAR_WATCHFUNC] = TM_char->sur_functable[CHAR_WATCHFUNC]; + TM_char->sur_functable[CHAR_WATCHFUNC] = (void *)NULL; + strcpy_s(TM_char->charfunctable[CHAR_WATCHFUNC].string, sizeof(TM_char->charfunctable[CHAR_WATCHFUNC].string), TM_char->sur_charfunctable[CHAR_WATCHFUNC].string); + } + } + } + return TM_Ret; +} + +int NPC_Lua_Char_SetLoopEvent(lua_State *_NLL) +{ + CheckEx(_NLL, 4); + CheckIndexNull(_NLL, 3); + int TM_index = (int)lua_tointeger(_NLL, 3); + int TM_LoopInterval = (int)lua_tointeger(_NLL, 4); + int TM_RetLoopInterval = -1; + + Char *TM_char = CHAR_getCharPointer(TM_index); + + if(TM_char == NULL) + { + LRetErrInt(_NLL , -1, "Чġ"); + } + int TM_Ret = NPC_Lua_GetFuncPoint(_NLL); + + if(lua_tointeger(_NLL, -1) > 0) + { + if(TM_char->functable[CHAR_LOOPFUNC] != (void *)NPC_Lua_LoopCallBack) + { + if(TM_char->functable[CHAR_LOOPFUNC] != NULL) + { + TM_char->sur_functable[CHAR_LOOPFUNC] = TM_char->functable[CHAR_LOOPFUNC]; + strcpy_s(TM_char->sur_charfunctable[CHAR_LOOPFUNC].string, sizeof(TM_char->sur_charfunctable[CHAR_LOOPFUNC].string), TM_char->charfunctable[CHAR_LOOPFUNC].string); + }else + { + TM_char->sur_functable[CHAR_LOOPFUNC] = (void *)NULL; + TM_char->sur_charfunctable[CHAR_LOOPFUNC].string[0] = '\0'; + } + TM_RetLoopInterval = CHAR_getInt(TM_index, CHAR_LOOPINTERVAL); + CHAR_setInt(TM_index, CHAR_LOOPINTERVAL, TM_LoopInterval); + TM_char->functable[CHAR_LOOPFUNC] = (void *)NPC_Lua_LoopCallBack; + strcpy_s(TM_char->lua_charfunctable[CHAR_LOOPFUNC].string, sizeof(TM_char->lua_charfunctable[CHAR_LOOPFUNC].string), lua_tostring(_NLL, 2)); + strcpy_s(TM_char->charfunctable[CHAR_LOOPFUNC].string, sizeof(TM_char->charfunctable[CHAR_LOOPFUNC].string), FUNCNAME_LOOPCALLBACK); + } + }else + { + if(TM_char->functable[CHAR_LOOPFUNC] == (void *)NPC_Lua_LoopCallBack) + { + TM_char->lua_charfunctable[CHAR_LOOPFUNC].string[0] = '\0'; + if(TM_char->sur_functable[CHAR_LOOPFUNC] == NULL) + { + CHAR_setInt(TM_index, CHAR_LOOPINTERVAL, -1); + TM_char->functable[CHAR_LOOPFUNC] = (void *)NULL; + TM_char->charfunctable[CHAR_LOOPFUNC].string[0] = '\0'; + }else + { + CHAR_setInt(TM_index, CHAR_LOOPINTERVAL, TM_LoopInterval); + TM_char->functable[CHAR_LOOPFUNC] = TM_char->sur_functable[CHAR_LOOPFUNC]; + TM_char->sur_functable[CHAR_LOOPFUNC] = (void *)NULL; + strcpy_s(TM_char->charfunctable[CHAR_LOOPFUNC].string, sizeof(TM_char->charfunctable[CHAR_LOOPFUNC].string), TM_char->sur_charfunctable[CHAR_LOOPFUNC].string); + } + } + } + lua_pushinteger(_NLL, TM_RetLoopInterval); + LRet(TM_Ret + 1); +} + +int NPC_Lua_Char_SetTalkedEvent(lua_State *_NLL) +{ + CheckEx(_NLL, 3); + CheckIndexNull(_NLL, 3); + int TM_index = (int)lua_tointeger(_NLL, 3); + + Char *TM_char = CHAR_getCharPointer(TM_index); + + if(TM_char == NULL) + { + LRetErrInt(_NLL , -1, "Чġ"); + } + int TM_Ret = NPC_Lua_GetFuncPoint(_NLL); + + if(lua_tointeger(_NLL, -1) > 0) + { + if(TM_char->functable[CHAR_TALKEDFUNC] != (void *)NPC_Lua_TalkedCallBack) + { + if(TM_char->functable[CHAR_TALKEDFUNC] != NULL) + { + TM_char->sur_functable[CHAR_TALKEDFUNC] = TM_char->functable[CHAR_TALKEDFUNC]; + strcpy_s(TM_char->sur_charfunctable[CHAR_TALKEDFUNC].string, sizeof(TM_char->sur_charfunctable[CHAR_TALKEDFUNC].string), TM_char->charfunctable[CHAR_TALKEDFUNC].string); + }else + { + TM_char->sur_functable[CHAR_TALKEDFUNC] = (void *)NULL; + TM_char->sur_charfunctable[CHAR_TALKEDFUNC].string[0] = '\0'; + } + + TM_char->functable[CHAR_TALKEDFUNC] = (void *)NPC_Lua_TalkedCallBack; + strcpy_s(TM_char->lua_charfunctable[CHAR_TALKEDFUNC].string, sizeof(TM_char->lua_charfunctable[CHAR_TALKEDFUNC].string), lua_tostring(_NLL, 2)); + strcpy_s(TM_char->charfunctable[CHAR_TALKEDFUNC].string, sizeof(TM_char->charfunctable[CHAR_TALKEDFUNC].string), FUNCNAME_TALKEDCALLBACK); + } + }else + { + if(TM_char->functable[CHAR_TALKEDFUNC] == (void *)NPC_Lua_TalkedCallBack) + { + TM_char->lua_charfunctable[CHAR_TALKEDFUNC].string[0] = '\0'; + if(TM_char->sur_functable[CHAR_TALKEDFUNC] == NULL) + { + TM_char->functable[CHAR_TALKEDFUNC] = (void *)NULL; + TM_char->charfunctable[CHAR_TALKEDFUNC].string[0] = '\0'; + }else + { + TM_char->functable[CHAR_TALKEDFUNC] = TM_char->sur_functable[CHAR_TALKEDFUNC]; + TM_char->sur_functable[CHAR_TALKEDFUNC] = (void *)NULL; + strcpy_s(TM_char->charfunctable[CHAR_TALKEDFUNC].string, sizeof(TM_char->charfunctable[CHAR_TALKEDFUNC].string), TM_char->sur_charfunctable[CHAR_TALKEDFUNC].string); + } + } + } + return TM_Ret; +} + +int NPC_Lua_Char_SetOFFEvent(lua_State *_NLL) +{ + CheckEx(_NLL, 3); + CheckIndexNull(_NLL, 3); + int TM_index = (int)lua_tointeger(_NLL, 3); + + Char *TM_char = CHAR_getCharPointer(TM_index); + + if(TM_char == NULL) + { + LRetErrInt(_NLL , -1, "Чġ"); + } + int TM_Ret = NPC_Lua_GetFuncPoint(_NLL); + + if(lua_tointeger(_NLL, -1) > 0) + { + if(TM_char->functable[CHAR_OFFFUNC] != (void *)NPC_Lua_OFFCallBack) + { + if(TM_char->functable[CHAR_OFFFUNC] != NULL) + { + TM_char->sur_functable[CHAR_OFFFUNC] = TM_char->functable[CHAR_OFFFUNC]; + strcpy_s(TM_char->sur_charfunctable[CHAR_OFFFUNC].string, sizeof(TM_char->sur_charfunctable[CHAR_OFFFUNC].string), TM_char->charfunctable[CHAR_OFFFUNC].string); + }else + { + TM_char->sur_functable[CHAR_OFFFUNC] = (void *)NULL; + TM_char->sur_charfunctable[CHAR_OFFFUNC].string[0] = '\0'; + } + + TM_char->functable[CHAR_OFFFUNC] = (void *)NPC_Lua_OFFCallBack; + strcpy_s(TM_char->lua_charfunctable[CHAR_OFFFUNC].string, sizeof(TM_char->lua_charfunctable[CHAR_OFFFUNC].string), lua_tostring(_NLL, 2)); + strcpy_s(TM_char->charfunctable[CHAR_OFFFUNC].string, sizeof(TM_char->charfunctable[CHAR_OFFFUNC].string), FUNCNAME_OFFCALLBACK); + } + }else + { + if(TM_char->functable[CHAR_OFFFUNC] == (void *)NPC_Lua_OFFCallBack) + { + TM_char->lua_charfunctable[CHAR_OFFFUNC].string[0] = '\0'; + if(TM_char->sur_functable[CHAR_OFFFUNC] == NULL) + { + TM_char->functable[CHAR_OFFFUNC] = (void *)NULL; + TM_char->charfunctable[CHAR_OFFFUNC].string[0] = '\0'; + }else + { + TM_char->functable[CHAR_OFFFUNC] = TM_char->sur_functable[CHAR_OFFFUNC]; + TM_char->sur_functable[CHAR_OFFFUNC] = (void *)NULL; + strcpy_s(TM_char->charfunctable[CHAR_OFFFUNC].string, sizeof(TM_char->charfunctable[CHAR_OFFFUNC].string), TM_char->sur_charfunctable[CHAR_OFFFUNC].string); + } + } + } + return TM_Ret; +} + +int NPC_Lua_Char_SetLookedEvent(lua_State *_NLL) +{ + CheckEx(_NLL, 3); + CheckIndexNull(_NLL, 3); + int TM_index = (int)lua_tointeger(_NLL, 3); + + Char *TM_char = CHAR_getCharPointer(TM_index); + + if(TM_char == NULL) + { + LRetErrInt(_NLL , -1, "Чġ"); + } + int TM_Ret = NPC_Lua_GetFuncPoint(_NLL); + + if(lua_tointeger(_NLL, -1) > 0) + { + if(TM_char->functable[CHAR_LOOKEDFUNC] != (void *)NPC_Lua_LookedCallBack) + { + if(TM_char->functable[CHAR_LOOKEDFUNC] != NULL) + { + TM_char->sur_functable[CHAR_LOOKEDFUNC] = TM_char->functable[CHAR_LOOKEDFUNC]; + strcpy_s(TM_char->sur_charfunctable[CHAR_LOOKEDFUNC].string, sizeof(TM_char->sur_charfunctable[CHAR_LOOKEDFUNC].string), TM_char->charfunctable[CHAR_LOOKEDFUNC].string); + }else + { + TM_char->sur_functable[CHAR_LOOKEDFUNC] = (void *)NULL; + TM_char->sur_charfunctable[CHAR_LOOKEDFUNC].string[0] = '\0'; + } + + TM_char->functable[CHAR_LOOKEDFUNC] = (void *)NPC_Lua_LookedCallBack; + strcpy_s(TM_char->lua_charfunctable[CHAR_LOOKEDFUNC].string, sizeof(TM_char->lua_charfunctable[CHAR_LOOKEDFUNC].string), lua_tostring(_NLL, 2)); + strcpy_s(TM_char->charfunctable[CHAR_LOOKEDFUNC].string, sizeof(TM_char->charfunctable[CHAR_LOOKEDFUNC].string), FUNCNAME_LOOKEDCALLBACK); + } + }else + { + if(TM_char->functable[CHAR_LOOKEDFUNC] == (void *)NPC_Lua_LookedCallBack) + { + TM_char->lua_charfunctable[CHAR_LOOKEDFUNC].string[0] = '\0'; + if(TM_char->sur_functable[CHAR_LOOKEDFUNC] == NULL) + { + TM_char->functable[CHAR_LOOKEDFUNC] = (void *)NULL; + TM_char->charfunctable[CHAR_LOOKEDFUNC].string[0] = '\0'; + }else + { + TM_char->functable[CHAR_LOOKEDFUNC] = TM_char->sur_functable[CHAR_LOOKEDFUNC]; + TM_char->sur_functable[CHAR_LOOKEDFUNC] = (void *)NULL; + strcpy_s(TM_char->charfunctable[CHAR_LOOKEDFUNC].string, sizeof(TM_char->charfunctable[CHAR_LOOKEDFUNC].string), TM_char->sur_charfunctable[CHAR_LOOKEDFUNC].string); + } + } + } + return TM_Ret; +} + +int NPC_Lua_Char_SetItemPutEvent(lua_State *_NLL) +{ + CheckEx(_NLL, 3); + CheckIndexNull(_NLL, 3); + int TM_index = (int)lua_tointeger(_NLL, 3); + + Char *TM_char = CHAR_getCharPointer(TM_index); + + if(TM_char == NULL) + { + LRetErrInt(_NLL , -1, "Чġ"); + } + int TM_Ret = NPC_Lua_GetFuncPoint(_NLL); + + if(lua_tointeger(_NLL, -1) > 0) + { + if(TM_char->functable[CHAR_ITEMPUTFUNC] != (void *)NPC_Lua_ItemPutCallBack) + { + if(TM_char->functable[CHAR_ITEMPUTFUNC] != NULL) + { + TM_char->sur_functable[CHAR_ITEMPUTFUNC] = TM_char->functable[CHAR_ITEMPUTFUNC]; + strcpy_s(TM_char->sur_charfunctable[CHAR_ITEMPUTFUNC].string, sizeof(TM_char->sur_charfunctable[CHAR_ITEMPUTFUNC].string), TM_char->charfunctable[CHAR_ITEMPUTFUNC].string); + }else + { + TM_char->sur_functable[CHAR_ITEMPUTFUNC] = (void *)NULL; + TM_char->sur_charfunctable[CHAR_ITEMPUTFUNC].string[0] = '\0'; + } + + TM_char->functable[CHAR_ITEMPUTFUNC] = (void *)NPC_Lua_ItemPutCallBack; + strcpy_s(TM_char->lua_charfunctable[CHAR_ITEMPUTFUNC].string, sizeof(TM_char->lua_charfunctable[CHAR_ITEMPUTFUNC].string), lua_tostring(_NLL, 2)); + strcpy_s(TM_char->charfunctable[CHAR_ITEMPUTFUNC].string, sizeof(TM_char->charfunctable[CHAR_ITEMPUTFUNC].string), FUNCNAME_ITEMPUTCALLBACK); + } + }else + { + if(TM_char->functable[CHAR_ITEMPUTFUNC] == (void *)NPC_Lua_ItemPutCallBack) + { + TM_char->lua_charfunctable[CHAR_ITEMPUTFUNC].string[0] = '\0'; + if(TM_char->sur_functable[CHAR_ITEMPUTFUNC] == NULL) + { + TM_char->functable[CHAR_ITEMPUTFUNC] = (void *)NULL; + TM_char->charfunctable[CHAR_ITEMPUTFUNC].string[0] = '\0'; + }else + { + TM_char->functable[CHAR_ITEMPUTFUNC] = TM_char->sur_functable[CHAR_ITEMPUTFUNC]; + TM_char->sur_functable[CHAR_ITEMPUTFUNC] = (void *)NULL; + strcpy_s(TM_char->charfunctable[CHAR_ITEMPUTFUNC].string, sizeof(TM_char->charfunctable[CHAR_ITEMPUTFUNC].string), TM_char->sur_charfunctable[CHAR_ITEMPUTFUNC].string); + } + } + } + return TM_Ret; +} + +int NPC_Lua_Char_SetWindowTalkedEvent(lua_State *_NLL) +{ + CheckEx(_NLL, 3); + CheckIndexNull(_NLL, 3); + int TM_index = (int)lua_tointeger(_NLL, 3); + + Char *TM_char = CHAR_getCharPointer(TM_index); + + if(TM_char == NULL) + { + LRetErrInt(_NLL , -1, "Чġ"); + } + int TM_Ret = NPC_Lua_GetFuncPoint(_NLL); + + if(lua_tointeger(_NLL, -1) > 0) + { + if(TM_char->functable[CHAR_WINDOWTALKEDFUNC] != (void *)NPC_Lua_WindowTalkedCallBack) + { + if(TM_char->functable[CHAR_WINDOWTALKEDFUNC] != NULL) + { + TM_char->sur_functable[CHAR_WINDOWTALKEDFUNC] = TM_char->functable[CHAR_WINDOWTALKEDFUNC]; + strcpy_s(TM_char->sur_charfunctable[CHAR_WINDOWTALKEDFUNC].string, sizeof(TM_char->sur_charfunctable[CHAR_WINDOWTALKEDFUNC].string), TM_char->charfunctable[CHAR_WINDOWTALKEDFUNC].string); + }else + { + TM_char->sur_functable[CHAR_WINDOWTALKEDFUNC] = (void *)NULL; + TM_char->sur_charfunctable[CHAR_WINDOWTALKEDFUNC].string[0] = '\0'; + } + + TM_char->functable[CHAR_WINDOWTALKEDFUNC] = (void *)NPC_Lua_WindowTalkedCallBack; + strcpy_s(TM_char->lua_charfunctable[CHAR_WINDOWTALKEDFUNC].string, sizeof(TM_char->lua_charfunctable[CHAR_WINDOWTALKEDFUNC].string), lua_tostring(_NLL, 2)); + strcpy_s(TM_char->charfunctable[CHAR_WINDOWTALKEDFUNC].string, sizeof(TM_char->charfunctable[CHAR_WINDOWTALKEDFUNC].string), FUNCNAME_WINDOWTALKEDCALLBACK); + } + }else + { + if(TM_char->functable[CHAR_WINDOWTALKEDFUNC] == (void *)NPC_Lua_WindowTalkedCallBack) + { + TM_char->lua_charfunctable[CHAR_WINDOWTALKEDFUNC].string[0] = '\0'; + if(TM_char->sur_functable[CHAR_WINDOWTALKEDFUNC] == NULL) + { + TM_char->functable[CHAR_WINDOWTALKEDFUNC] = (void *)NULL; + TM_char->charfunctable[CHAR_WINDOWTALKEDFUNC].string[0] = '\0'; + }else + { + TM_char->functable[CHAR_WINDOWTALKEDFUNC] = TM_char->sur_functable[CHAR_WINDOWTALKEDFUNC]; + TM_char->sur_functable[CHAR_WINDOWTALKEDFUNC] = (void *)NULL; + strcpy_s(TM_char->charfunctable[CHAR_WINDOWTALKEDFUNC].string, sizeof(TM_char->charfunctable[CHAR_WINDOWTALKEDFUNC].string), TM_char->sur_charfunctable[CHAR_WINDOWTALKEDFUNC].string); + } + } + } + return TM_Ret; +} + +#ifdef _USER_CHARLOOPS +int NPC_Lua_Char_SetCharLoopsEvent(lua_State *_NLL) +{ + CheckEx(_NLL, 4); + CheckIndexNull(_NLL, 3); + int TM_index = (int)lua_tointeger(_NLL, 3); + int TM_LoopInterval = (int)lua_tointeger(_NLL, 4); + int TM_RetLoopInterval = -1; + + Char *TM_char = CHAR_getCharPointer(TM_index); + + if(TM_char == NULL) + { + LRetErrInt(_NLL , -1, "Чġ"); + } + int TM_Ret = NPC_Lua_GetFuncPoint(_NLL); + + if(lua_tointeger(_NLL, -1) > 0) + { + if(TM_char->functable[CHAR_LOOPFUNCTEMP1] != (void *)NPC_Lua_CharLoopsCallBack) + { + if(TM_char->functable[CHAR_LOOPFUNCTEMP1] != NULL) + { + TM_char->sur_functable[CHAR_LOOPFUNCTEMP1] = TM_char->functable[CHAR_LOOPFUNCTEMP1]; + strcpy_s(TM_char->sur_charfunctable[CHAR_LOOPFUNCTEMP1].string, sizeof(TM_char->sur_charfunctable[CHAR_LOOPFUNCTEMP1].string), TM_char->charfunctable[CHAR_LOOPFUNCTEMP1].string); + }else + { + TM_char->sur_functable[CHAR_LOOPFUNCTEMP1] = (void *)NULL; + TM_char->sur_charfunctable[CHAR_LOOPFUNCTEMP1].string[0] = '\0'; + } + TM_RetLoopInterval = CHAR_getInt(TM_index, CHAR_LOOPINTERVAL); + CHAR_setInt(TM_index, CHAR_LOOPINTERVAL, TM_LoopInterval); + TM_char->functable[CHAR_LOOPFUNCTEMP1] = (void *)NPC_Lua_CharLoopsCallBack; + strcpy_s(TM_char->lua_charfunctable[CHAR_LOOPFUNCTEMP1].string, sizeof(TM_char->lua_charfunctable[CHAR_LOOPFUNCTEMP1].string), lua_tostring(_NLL, 2)); + strcpy_s(TM_char->charfunctable[CHAR_LOOPFUNCTEMP1].string, sizeof(TM_char->charfunctable[CHAR_LOOPFUNCTEMP1].string), FUNCNAME_CHARLOOPSCALLBACK); + } + }else + { + if(TM_char->functable[CHAR_LOOPFUNCTEMP1] == (void *)NPC_Lua_CharLoopsCallBack) + { + TM_char->lua_charfunctable[CHAR_LOOPFUNCTEMP1].string[0] = '\0'; + if(TM_char->sur_functable[CHAR_LOOPFUNCTEMP1] == NULL) + { + CHAR_setInt(TM_index, CHAR_LOOPINTERVAL, -1); + TM_char->functable[CHAR_LOOPFUNCTEMP1] = (void *)NULL; + TM_char->charfunctable[CHAR_LOOPFUNCTEMP1].string[0] = '\0'; + }else + { + CHAR_setInt(TM_index, CHAR_LOOPINTERVAL, TM_LoopInterval); + TM_char->functable[CHAR_LOOPFUNCTEMP1] = TM_char->sur_functable[CHAR_LOOPFUNCTEMP1]; + TM_char->sur_functable[CHAR_LOOPFUNCTEMP1] = (void *)NULL; + strcpy_s(TM_char->charfunctable[CHAR_LOOPFUNCTEMP1].string, sizeof(TM_char->charfunctable[CHAR_LOOPFUNCTEMP1].string), TM_char->sur_charfunctable[CHAR_LOOPFUNCTEMP1].string); + } + } + } + lua_pushinteger(_NLL, TM_RetLoopInterval); + LRet(TM_Ret + 1); +} + +int NPC_Lua_Char_SetBattleProPertyEvent(lua_State *_NLL) +{ + CheckEx(_NLL, 3); + CheckIndexNull(_NLL, 3); + int TM_index = (int)lua_tointeger(_NLL, 3); + + Char *TM_char = CHAR_getCharPointer(TM_index); + + if(TM_char == NULL) + { + LRetErrInt(_NLL , -1, "Чġ"); + } + int TM_Ret = NPC_Lua_GetFuncPoint(_NLL); + + if(lua_tointeger(_NLL, -1) > 0) + { + if(TM_char->functable[CHAR_BATTLEPROPERTY] != (void *)NPC_Lua_BattleProPertyCallBack) + { + if(TM_char->functable[CHAR_BATTLEPROPERTY] != NULL) + { + TM_char->sur_functable[CHAR_BATTLEPROPERTY] = TM_char->functable[CHAR_BATTLEPROPERTY]; + strcpy_s(TM_char->sur_charfunctable[CHAR_BATTLEPROPERTY].string, sizeof(TM_char->sur_charfunctable[CHAR_BATTLEPROPERTY].string), TM_char->charfunctable[CHAR_BATTLEPROPERTY].string); + }else + { + TM_char->sur_functable[CHAR_BATTLEPROPERTY] = (void *)NULL; + TM_char->sur_charfunctable[CHAR_BATTLEPROPERTY].string[0] = '\0'; + } + + TM_char->functable[CHAR_BATTLEPROPERTY] = (void *)NPC_Lua_BattleProPertyCallBack; + strcpy_s(TM_char->lua_charfunctable[CHAR_BATTLEPROPERTY].string, sizeof(TM_char->lua_charfunctable[CHAR_BATTLEPROPERTY].string), lua_tostring(_NLL, 2)); + strcpy_s(TM_char->charfunctable[CHAR_BATTLEPROPERTY].string, sizeof(TM_char->charfunctable[CHAR_BATTLEPROPERTY].string), FUNCNAME_BATTLEPROPERTYCALLBACK); + } + }else + { + if(TM_char->functable[CHAR_BATTLEPROPERTY] == (void *)NPC_Lua_BattleProPertyCallBack) + { + TM_char->lua_charfunctable[CHAR_BATTLEPROPERTY].string[0] = '\0'; + if(TM_char->sur_functable[CHAR_BATTLEPROPERTY] == NULL) + { + TM_char->functable[CHAR_BATTLEPROPERTY] = (void *)NULL; + TM_char->charfunctable[CHAR_BATTLEPROPERTY].string[0] = '\0'; + }else + { + TM_char->functable[CHAR_BATTLEPROPERTY] = TM_char->sur_functable[CHAR_BATTLEPROPERTY]; + TM_char->sur_functable[CHAR_BATTLEPROPERTY] = (void *)NULL; + strcpy_s(TM_char->charfunctable[CHAR_BATTLEPROPERTY].string, sizeof(TM_char->charfunctable[CHAR_BATTLEPROPERTY].string), TM_char->sur_charfunctable[CHAR_BATTLEPROPERTY].string); + } + } + } + return TM_Ret; +} +#endif +////////////////////////////////////////////////////////////////////////////// +//ȡݵĽӿ +int NPC_Lua_Char_GetData(lua_State *_NLL) +{ + CheckEx(_NLL, 2); + CheckIndexNull(_NLL, 1); + int TM_Index = (int)lua_tointeger(_NLL, 1); + int TM_Flg = (int)lua_tointeger(_NLL, 2); + + if(TM_Flg >= 0) + { + if(TM_Flg < LUA_DATALINE1) + { + TM_Flg -= LUA_DATALINE0; + if(TM_Flg == CHAR_WHICHTYPE) + { + LRetInt(_NLL, 0); + } + int TM_RetInt = CHAR_getInt(TM_Index, TM_Flg); + LRetInt(_NLL, TM_RetInt); + }else if(TM_Flg < LUA_DATALINE2) + { + TM_Flg -= LUA_DATALINE1; + char *TM_RetPoint = CHAR_getChar(TM_Index, TM_Flg); + LRetMsg(_NLL, TM_RetPoint); + }else if(TM_Flg < LUA_DATALINE3) + { + TM_Flg -= LUA_DATALINE2; + int TM_RetWorkInt = CHAR_getWorkInt(TM_Index, TM_Flg); + LRetInt(_NLL, TM_RetWorkInt); + }else if(TM_Flg < LUA_DATALINE4) + { + TM_Flg -= LUA_DATALINE3; + char *TM_RetWorkPoint = CHAR_getWorkChar(TM_Index, TM_Flg); + LRetMsg(_NLL, TM_RetWorkPoint); + }else if(TM_Flg < LUA_DATALINE5) + { + TM_Flg -= LUA_DATALINE4; + BOOL TM_RetBOOL = CHAR_getFlg(TM_Index, TM_Flg); + LRetBool(_NLL, TM_RetBOOL); + }else + { + LRetErrNull(_NLL, "ı־Ǵġ"); + } + } + LRetErrNull(_NLL, "ı־Ǵġ"); +} + +int NPC_Lua_Char_IsEventEnd(lua_State *_NLL) +{ + CheckEx(_NLL, 2); + CheckIndexNull(_NLL, 1); + int TM_Index = (int)lua_tointeger(_NLL, 1); + int TM_EventNo = (int)lua_tointeger(_NLL, 2); + + BOOL TM_Ret = NPC_EventCheckFlg(TM_Index, TM_EventNo); + + LRetBool(_NLL, TM_Ret); +} + +int NPC_Lua_Char_IsEventNow(lua_State *_NLL) +{ + CheckEx(_NLL, 2); + CheckIndexNull(_NLL, 1); + int TM_Index = (int)lua_tointeger(_NLL, 1); + int TM_EventNo = (int)lua_tointeger(_NLL, 2); + + BOOL TM_Ret = NPC_NowEventCheckFlg(TM_Index, TM_EventNo); + + LRetBool(_NLL, TM_Ret); +} + +int NPC_Lua_Char_FindItemId(lua_State *_NLL) +{ + CheckEx(_NLL, 2); + CheckIndexNull(_NLL, 1); + int TM_Index = (int)lua_tointeger(_NLL, 1); + int TM_ItemId = (int)lua_tointeger(_NLL, 2); + int TM_ItemIndex = -1; + int i = 0; + int j = 0; + if(!CHAR_CHECKINDEX(TM_Index)) + { + LRetErrInt(_NLL, -1, "Чġ"); + } + + for( i = CHAR_STARTITEMARRAY ; i= 0 && TM_Pos < CHAR_MAXITEMHAVE) + { + int TM_ItemIndex = CHAR_getItemIndex(TM_Index, TM_Pos); + + if( ITEM_CHECKINDEX(TM_ItemIndex) == FALSE ) LRetErrInt(_NLL, -2, "õûеߡ"); + LRetInt(_NLL, ITEM_getInt(TM_ItemIndex, ITEM_ID)); + } + LRetErrInt(_NLL, -3, "λóΧ"); +} + +int NPC_Lua_Char_GetItemIndex(lua_State *_NLL) +{ + CheckEx(_NLL, 2); + CheckIndexNull(_NLL, 1); + int TM_Index = (int)lua_tointeger(_NLL, 1); + int TM_Pos = (int)lua_tointeger(_NLL, 2); + + if(!CHAR_CHECKINDEX(TM_Index)) + { + LRetErrInt(_NLL, -1, "Чġ"); + } + + if(TM_Pos >= 0 && TM_Pos < CHAR_MAXITEMHAVE) + { + int TM_ItemIndex = CHAR_getItemIndex(TM_Index, TM_Pos); + + if( ITEM_CHECKINDEX(TM_ItemIndex) == FALSE ) LRetErrInt(_NLL, -2, "õûеߡ"); + LRetInt(_NLL, TM_ItemIndex); + } + LRetErrInt(_NLL, -3, "λóΧ"); +} + +int NPC_Lua_Char_GetPetEnemyId(lua_State *_NLL) +{ + CheckEx(_NLL, 2); + CheckIndexNull(_NLL, 1); + int TM_Index = (int)lua_tointeger(_NLL, 1); + int TM_Pos = (int)lua_tointeger(_NLL, 2); + + if(!CHAR_CHECKINDEX(TM_Index)) + { + LRetErrInt(_NLL, -1, "Чġ"); + } + + if(TM_Pos >= 0 && TM_Pos < CHAR_MAXPETHAVE) + { + int TM_PetIndex = CHAR_getCharPet(TM_Index, TM_Pos); + + if( CHAR_CHECKINDEX(TM_PetIndex) == FALSE ) LRetErrInt(_NLL, -2, "óûг"); + LRetInt(_NLL, CHAR_getInt(TM_PetIndex, CHAR_PETID)); + } + LRetErrInt(_NLL, -3, "λóΧ"); +} + +int NPC_Lua_Char_GetPetIndex(lua_State *_NLL) +{ + CheckEx(_NLL, 2); + CheckIndexNull(_NLL, 1); + int TM_Index = (int)lua_tointeger(_NLL, 1); + int TM_Pos = (int)lua_tointeger(_NLL, 2); + + if(!CHAR_CHECKINDEX(TM_Index)) + { + LRetErrInt(_NLL, -1, "Чġ"); + } + + if(TM_Pos >= 0 && TM_Pos < CHAR_MAXPETHAVE) + { + int TM_PetIndex = CHAR_getCharPet(TM_Index, TM_Pos); + + if( CHAR_CHECKINDEX(TM_PetIndex) == FALSE ) LRetErrInt(_NLL, -2, "óûг"); + LRetInt(_NLL, TM_PetIndex); + } + LRetErrInt(_NLL, -3, "λóΧ"); +} + +int NPC_Lua_Char_GetTeamIndex(lua_State *_NLL) +{ + CheckEx(_NLL, 2); + CheckIndexNull(_NLL, 1); + int TM_Index = (int)lua_tointeger(_NLL, 1); + int TM_Pos = (int)lua_tointeger(_NLL, 2); + + if(!CHAR_CHECKINDEX(TM_Index)) + { + LRetErrInt(_NLL, -1, "Чġ"); + } + + if(TM_Pos >= 1 && TM_Pos < CHAR_PARTYMAX) + { + int TM_ParIndex = CHAR_getWorkInt( TM_Index, TM_Pos + CHAR_WORKPARTYINDEX1); + + if( CHAR_CHECKINDEX(TM_ParIndex) == FALSE ) LRetErrInt(_NLL, -2, "λûжԱ"); + LRetInt(_NLL, TM_ParIndex); + } + LRetErrInt(_NLL, -3, "λóԱλ÷Χ"); +} + +int NPC_Lua_Char_HealAll(lua_State *_NLL) +{ + CheckEx(_NLL, 1); + CheckIndexNull(_NLL, 1); + int TM_Index = (int)lua_tointeger(_NLL, 1); + + if(!CHAR_CHECKINDEX(TM_Index)) + { + LRetErrInt(_NLL, -1, "Чġ"); + } + + NPC_HealerAllHeal(TM_Index); + LRetInt(_NLL, 1); +} + + +int NPC_Lua_Char_GetPetSkillId(lua_State *_NLL) +{ + CheckEx(_NLL, 2); + CheckIndexNull(_NLL, 1); + int TM_Index = (int)lua_tointeger(_NLL, 1); + int TM_SkillIndex = (int)lua_tointeger(_NLL, 2); + + if(!CHAR_CHECKINDEX(TM_Index)) + { + LRetErrInt(_NLL, -1, "Чġ"); + } + + if( !CHAR_CHECKPETSKILLINDEX( TM_SkillIndex)){ + LRetErrInt(_NLL, -1, "Чġ"); + } + + int TM_SkillId=CHAR_getPetSkill( TM_Index, TM_SkillIndex); + LRetInt(_NLL, TM_SkillId); +} + +int NPC_Lua_Char_GetPetSkillName(lua_State *_NLL) +{ + CheckEx(_NLL, 1); + CheckIndexNull(_NLL, 1); + int TM_Index = (int)lua_tointeger(_NLL, 1); + int skillarray = PETSKILL_getPetskillArray( TM_Index); + if( PETSKILL_CHECKINDEX( skillarray) == FALSE ){ + LRetErrNull(_NLL, "ı־Ǵġ"); + } + LRetMsg(_NLL, PETSKILL_getChar( skillarray, PETSKILL_NAME)); +} + +int NPC_Lua_Char_GetPetSkillMsg(lua_State *_NLL) +{ + CheckEx(_NLL, 1); + CheckIndexNull(_NLL, 1); + int TM_Index = (int)lua_tointeger(_NLL, 1); + int skillarray = PETSKILL_getPetskillArray( TM_Index); + if( PETSKILL_CHECKINDEX( skillarray) == FALSE ){ + LRetErrNull(_NLL, "ı־Ǵġ"); + } + LRetMsg(_NLL, PETSKILL_getChar( skillarray, PETSKILL_COMMENT)); +} + +int NPC_Lua_Char_SetPetSkill(lua_State *_NLL) +{ + CheckEx(_NLL, 3); + CheckIndexNull(_NLL, 1); + int TM_Index = (int)lua_tointeger(_NLL, 1); + int TM_Slod = (int)lua_tointeger(_NLL, 2); + int TM_SkillId = (int)lua_tointeger(_NLL, 3); + if(!CHAR_CHECKINDEX(TM_Index)) + { + LRetErrInt(_NLL, -1, "Чġ"); + } + + if( !CHAR_CHECKPETSKILLINDEX( TM_Slod)){ + LRetErrInt(_NLL, -1, "Чġ"); + } + int skillarray = PETSKILL_getPetskillArray( TM_SkillId); + if( PETSKILL_CHECKINDEX( skillarray) == FALSE ){ + LRetErrInt(_NLL, -1, "Чġ"); + } + CHAR_setPetSkill( TM_Index, TM_Slod, TM_SkillId); + LRetInt(_NLL, 1); +} + +int NPC_Lua_Char_RandMsg(lua_State *_NLL) +{ + CheckEx(_NLL, 2); + CheckIndexNull(_NLL, 1); + int TM_NpcIndex = (int)lua_tointeger(_NLL, 1); + int TM_TalkIndex = (int)lua_tointeger(_NLL, 2); + time_t timep; + struct tm *p; + time(&timep); + p=localtime(&timep); + timep = mktime(p); + char *randtypetime = CHAR_getChar(TM_TalkIndex,CHAR_RANDTYPE); + char tempbuff[64]; + int randtype = 0; + int randtime = 0; + int randwrong = 0; + if(strlen(randtypetime)>2){ + if(getStringFromIndexWithDelim(randtypetime,"-", 3, tempbuff, sizeof(tempbuff)) != FALSE){ + if(getStringFromIndexWithDelim(randtypetime,"-", 1, tempbuff, sizeof(tempbuff))== FALSE) + LRetInt(_NLL, 0); + randwrong = atoi(tempbuff); + if(getStringFromIndexWithDelim(randtypetime,"-", 2, tempbuff, sizeof(tempbuff))== FALSE) + LRetInt(_NLL, 0); + randtype = atoi(tempbuff); + if(getStringFromIndexWithDelim(randtypetime,"-", 3, tempbuff, sizeof(tempbuff))== FALSE) + LRetInt(_NLL, 0); + randtime = atoi(tempbuff); +#ifdef _MM_NO_JIAOBEN + if(timep - randtime < getEditBaseTime()*randwrong){ + char errbuf[256]; + sprintf(errbuf,"%dſԼ˲",getEditBaseTime()*randwrong-(timep - randtime)); + CHAR_talkToCli(TM_TalkIndex, -1, errbuf, CHAR_COLORRED); + LRetInt(_NLL, 0); + } +#endif + } + } + char *arg = NULL; + arg = CHAR_getWorkChar(TM_TalkIndex,CHAR_WORKRANDMSG); + int MyNpcIndex,MyTalkIndex,ret,flag; + if(strlen(arg)>2){ + char buftest[255]; + if(getStringFromIndexWithDelim(arg,"|", 1, buftest, sizeof(buftest)) == FALSE){ + CHAR_setWorkChar(TM_TalkIndex,CHAR_WORKRANDMSG,""); + LRetInt(_NLL, 0);; + } + ret = atoi(buftest); + if(getStringFromIndexWithDelim(arg,"|", 2, buftest, sizeof(buftest)) == FALSE){ + CHAR_setWorkChar(TM_TalkIndex,CHAR_WORKRANDMSG,""); + LRetInt(_NLL, 0);; + } + MyNpcIndex = atoi(buftest); + if(getStringFromIndexWithDelim(arg,"|", 3, buftest, sizeof(buftest)) == FALSE){ + CHAR_setWorkChar(TM_TalkIndex,CHAR_WORKRANDMSG,""); + LRetInt(_NLL, 0);; + } + MyTalkIndex = atoi(buftest); + if(getStringFromIndexWithDelim(arg,"|", 4, buftest, sizeof(buftest)) == FALSE){ + CHAR_setWorkChar(TM_TalkIndex,CHAR_WORKRANDMSG,""); + LRetInt(_NLL, 0);; + } + flag = atoi(buftest); + + if(TM_NpcIndex!=MyNpcIndex || TM_TalkIndex!=MyTalkIndex){ + CHAR_setWorkChar(TM_TalkIndex,CHAR_WORKRANDMSG,""); + LRetInt(_NLL, 0); + } + + if(flag == 0){ + CHAR_setWorkChar(TM_TalkIndex,CHAR_WORKRANDMSG,""); + LRetInt(_NLL, 2); + } + CHAR_setWorkChar(TM_TalkIndex,CHAR_WORKRANDMSG,""); + LRetInt(_NLL, 1); + }else{ + char tempbuf[64]; + char randquestion[64]; + char randrightanswer[64]; + char randwronganswer1[64]; + char randwronganswer2[64]; + char randwronganswer3[64]; + char randwronganswer4[64]; + memset(tempbuf, 0, sizeof(tempbuf)); + memset(randquestion, 0, sizeof(randquestion)); + memset(randrightanswer, 0, sizeof(randrightanswer)); + memset(randwronganswer1, 0, sizeof(randwronganswer1)); + memset(randwronganswer2, 0, sizeof(randwronganswer2)); + memset(randwronganswer3, 0, sizeof(randwronganswer3)); + memset(randwronganswer4, 0, sizeof(randwronganswer4)); + if(RAND(1,100)<=75){ + char randtmpbuf[4][10]; + sprintf(randtmpbuf[0],"%s",hanzibuf[RAND(1,5000)-1]); + sprintf(randtmpbuf[1],"%s",hanzibuf[RAND(1,5000)-1]); + sprintf(randtmpbuf[2],"%s",hanzibuf[RAND(1,5000)-1]); + sprintf(randtmpbuf[3],"%s",hanzibuf[RAND(1,5000)-1]); + sprintf(randquestion,"%s",str_hanzi_ganrao(randtmpbuf[0],randtmpbuf[1],randtmpbuf[2],randtmpbuf[3],0,0,0,0,0,0)); + strcat(randquestion,"ҳͬ飩"); + int newrand1 = RAND(1,100)-1; + int newrand2 = RAND(1,100)-1; + int newrand3 = RAND(1,100)-1; + int newrand4 = RAND(1,100)-1; + int newrand5 = RAND(1,100)-1; + sprintf(randrightanswer,"%s",str_hanzi_ganrao(randtmpbuf[0],randtmpbuf[1],randtmpbuf[2],randtmpbuf[3],1,newrand1,newrand2,newrand3,newrand4,newrand5)); + sprintf(randwronganswer1,"%s",str_hanzi_ganrao(randtmpbuf[0],randtmpbuf[1],randtmpbuf[3],randtmpbuf[2],1,newrand1,newrand2,newrand3,newrand4,newrand5)); + sprintf(randwronganswer2,"%s",str_hanzi_ganrao(randtmpbuf[3],randtmpbuf[1],randtmpbuf[2],randtmpbuf[0],1,newrand1,newrand2,newrand3,newrand4,newrand5)); + sprintf(randwronganswer3,"%s",str_hanzi_ganrao(randtmpbuf[1],randtmpbuf[0],randtmpbuf[2],randtmpbuf[3],1,newrand1,newrand2,newrand3,newrand4,newrand5)); + sprintf(randwronganswer4,"%s",str_hanzi_ganrao(randtmpbuf[2],randtmpbuf[3],randtmpbuf[0],randtmpbuf[1],1,newrand1,newrand2,newrand3,newrand4,newrand5)); + + }else{ + int tii; + char timubuf[36][5] = {"a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","0","1","2","3","4","5","6","7","8","9"}; + for(tii=0;tii<5;tii++){ + if(tii==0) + strcpy(tempbuf,timubuf[RAND(1,36)-1]); + else{ + int timunum = 0; + while(1){ + timunum = RAND(1,36)-1; + if(strstr(tempbuf,timubuf[timunum])==NULL) + break; + } + strcat(tempbuf,timubuf[timunum]); + } + + } + sprintf(randwronganswer1,"[%c%c%c%c%c]",tempbuf[0],tempbuf[2],tempbuf[1],tempbuf[3],tempbuf[4]); + sprintf(randwronganswer2,"[%c%c%c%c%c]",tempbuf[0],tempbuf[1],tempbuf[4],tempbuf[2],tempbuf[3]); + sprintf(randwronganswer3,"[%c%c%c%c%c]",tempbuf[4],tempbuf[1],tempbuf[2],tempbuf[0],tempbuf[3]); + sprintf(randwronganswer4,"[%c%c%c%c%c]",tempbuf[1],tempbuf[0],tempbuf[2],tempbuf[3],tempbuf[4]); + sprintf(randquestion,"[%s]ҳͬӢģ",tempbuf); + sprintf(randrightanswer,"[%s]",tempbuf); + char* randstr = NULL; + randstr = str_ganrao(randquestion); + strcpy(randquestion,randstr); + randstr = str_ganraoan(randrightanswer); + strcpy(randrightanswer,randstr); + randstr = str_ganraoan(randwronganswer1); + strcpy(randwronganswer1,randstr); + randstr = str_ganraoan(randwronganswer2); + strcpy(randwronganswer2,randstr); + randstr = str_ganraoan(randwronganswer3); + strcpy(randwronganswer3,randstr); + randstr = str_ganraoan(randwronganswer4); + strcpy(randwronganswer4,randstr); + } + int n,m; + int randnum1; + m=1; + char tempret[5][64]; + randnum1 = RAND(1,5); + int rightnum,wrongnum1,wrongnum2,wrongnum3,wrongnum4; + rightnum = RAND(getRandMin(),getRandMax()); + wrongnum1 = RAND(getRandMin(),getRandMax()); + wrongnum2 = RAND(getRandMin(),getRandMax()); + wrongnum3 = RAND(getRandMin(),getRandMax()); + wrongnum4 = RAND(getRandMin(),getRandMax()); + int qianhounum = RAND(1,100); + for(n=1;n<=5;n++){ + if(n==randnum1){ + if(qianhounum<=50) + sprintf(tempret[n-1],"ѡ( %d %s )",rightnum,randrightanswer); + else + sprintf(tempret[n-1],"ѡ( %s %d )",randrightanswer,rightnum); + }else{ + if(m==1){ + if(qianhounum<=50) + sprintf(tempret[n-1],"ѡ( %d %s )",wrongnum1,randwronganswer1); + else + sprintf(tempret[n-1],"ѡ( %s %d )",randwronganswer1,wrongnum1); + m = 2; + }else if(m==2){ + if(qianhounum<=50) + sprintf(tempret[n-1],"ѡ( %d %s )",wrongnum2,randwronganswer2); + else + sprintf(tempret[n-1],"ѡ( %s %d )",randwronganswer2,wrongnum2); + m = 3; + }else if(m==3){ + if(qianhounum<=50) + sprintf(tempret[n-1],"ѡ( %d %s )",wrongnum3,randwronganswer3); + else + sprintf(tempret[n-1],"ѡ( %s %d )",randwronganswer3,wrongnum3); + m = 4; + }else if(m==4){ + if(qianhounum<=50) + sprintf(tempret[n-1],"ѡ( %d %s )",wrongnum4,randwronganswer4); + else + sprintf(tempret[n-1],"ѡ( %s %d )",randwronganswer4,wrongnum4); + m = 5; + } + } + } + int windowtype = 0; + int selecttype = RAND(1,100); + char buf[64]; + if(selecttype<=30){ + sprintf(buf,"%d|%d|%d|%d",rightnum,TM_NpcIndex,TM_TalkIndex,0); + windowtype = WINDOW_MESSAGETYPE_MESSAGEANDLINEINPUT; + }else{ + sprintf(buf,"%d|%d|%d|%d",randnum1,TM_NpcIndex,TM_TalkIndex,0); + windowtype = WINDOW_MESSAGETYPE_SELECT; + } + CHAR_setWorkChar(TM_TalkIndex, CHAR_WORKRANDMSG, buf); + int fd = getfdFromCharaIndex( TM_TalkIndex ); + sprintf(buf,"%s\n%s\n%s\n%s\n%s\n%s\nȷڵ5λֻߵѡ",randquestion,tempret[0],tempret[1],tempret[2],tempret[3],tempret[4]); + lssproto_WN_send( fd, windowtype, + WINDOW_BUTTONTYPE_OK, + CHAR_WINDOWTYPE_LUANPC_RANDMSG, + -1, + buf); + CHAR_setWorkInt(TM_TalkIndex,CHAR_WORKLUANPCINT,0); + if(randwrong<=0){ + sprintf(tempbuff,"1-%d-%d",randtype,timep); + }else{ + sprintf(tempbuff,"%d-%d-%d",randwrong*3,randtype,timep); + } + CHAR_setChar(TM_TalkIndex,CHAR_RANDTYPE,tempbuff); + LRetInt(_NLL, 0); + } +} + +int NPC_Lua_Char_GetBeatitudeNum(lua_State *_NLL) +{ + CheckEx(_NLL, 1); + CheckIndexNull(_NLL, 1); + int TM_Index = (int)lua_tointeger(_NLL, 1); + + if(!CHAR_CHECKINDEX(TM_Index)) + { + LRetErrInt(_NLL, -1, "Чġ"); + } + + int petbeatitude = CHAR_getInt( TM_Index, CHAR_BEATITUDE); + int i=0; + if(CHAR_getInt( TM_Index, CHAR_BEATITUDE)&BEATITUDE_VITAL) + i++; + if(CHAR_getInt( TM_Index, CHAR_BEATITUDE)&BEATITUDE_STR) + i++; + if(CHAR_getInt( TM_Index, CHAR_BEATITUDE)&BEATITUDE_TOUGH) + i++; + if(CHAR_getInt( TM_Index, CHAR_BEATITUDE)&BEATITUDE_DEX) + i++; + LRetInt(_NLL, i); +} + +//ͨʺŲѯ +int NPC_Lua_Char_GetPlayerIndexByCdkey(lua_State *_NLL) +{ + CheckEx(_NLL, 1); + CheckIndexNull(_NLL, 1); + char *TM_Cdkey = (char *)lua_tostring(_NLL, 1); + + int TM_playernum = CHAR_getPlayerMaxNum(); + int i = 0; + for( i = 0 ; i < TM_playernum ; i++) + { + if( CHAR_getCharUse(i) != FALSE ) + { + if (CHAR_getChar(i, CHAR_CDKEY) == TM_Cdkey) + { + LRetInt(_NLL, i); + } + } + } + + LRetErrInt(_NLL, -3, "ʺŲڻδߣ"); +} + +int NPC_Lua_Char_getVipPoint(lua_State *_NLL) +{ + CheckEx(_NLL, 1); + int TM_Index = (int)lua_tointeger(_NLL, 1); + if(!CHAR_CHECKINDEX(TM_Index)) + { + LRetErrInt(_NLL, -1, "Чġ"); + } + int TM_point = sasql_getVipPoint(TM_Index); + if(TM_point<0){ + LRetErrInt(_NLL, -2, "Char_getVipPointݳ"); + } + LRetInt(_NLL, TM_point); +} + +int NPC_Lua_Char_getjfPoint(lua_State *_NLL) +{ + CheckEx(_NLL, 1); + int TM_Index = (int)lua_tointeger(_NLL, 1); + if(!CHAR_CHECKINDEX(TM_Index)) + { + LRetErrInt(_NLL, -1, "Чġ"); + } + int TM_point = sasql_jifenPoint(TM_Index); + if(TM_point<0){ + LRetErrInt(_NLL, -2, "Char_getjfPointݳ"); + } + LRetInt(_NLL, TM_point); +} + +int NPC_Lua_Char_getxjPoint(lua_State *_NLL) +{ + CheckEx(_NLL, 1); + int TM_Index = (int)lua_tointeger(_NLL, 1); + if(!CHAR_CHECKINDEX(TM_Index)) + { + LRetErrInt(_NLL, -1, "Чġ"); + } + int TM_point = sasql_xjPoint(TM_Index); + if(TM_point<0){ + LRetErrInt(_NLL, -2, "Char_getxjPointݳ"); + } + LRetInt(_NLL, TM_point); +} + +int NPC_Lua_Char_setVipPoint(lua_State *_NLL) +{ + CheckEx(_NLL, 2); + int TM_Index = (int)lua_tointeger(_NLL, 1); + int TM_point = (int)lua_tointeger(_NLL, 2); + if(!CHAR_CHECKINDEX(TM_Index)) + { + LRetErrInt(_NLL, -1, "Чġ"); + } + int TM_kouj = sasql_setVipPoint(TM_Index,TM_point); + if(TM_point<0){ + LRetErrInt(_NLL, -2, "Char_setVipPointݳ"); + } + LRetInt(_NLL, TM_kouj); +} + +int NPC_Lua_Char_setjfPoint(lua_State *_NLL) +{ + CheckEx(_NLL, 2); + int TM_Index = (int)lua_tointeger(_NLL, 1); + int TM_point = (int)lua_tointeger(_NLL, 2); + if(!CHAR_CHECKINDEX(TM_Index)) + { + LRetErrInt(_NLL, -1, "Чġ"); + } + int TM_kouj = sasql_setJfPoint(TM_Index,TM_point); + if(TM_point<0){ + LRetErrInt(_NLL, -2, "Char_setjfPointݳ"); + } + LRetInt(_NLL, TM_kouj); +} + +int NPC_Lua_Char_setxjPoint(lua_State *_NLL) +{ + CheckEx(_NLL, 2); + int TM_Index = (int)lua_tointeger(_NLL, 1); + int TM_point = (int)lua_tointeger(_NLL, 2); + if(!CHAR_CHECKINDEX(TM_Index)) + { + LRetErrInt(_NLL, -1, "Чġ"); + } + int TM_kouj = sasql_setxjPoint(TM_Index,TM_point); + if(TM_point<0){ + LRetErrInt(_NLL, -2, "Char_setxjPointݳ"); + } + LRetInt(_NLL, TM_kouj); +} + +int NPC_Lua_Char_GetAllocPoint(lua_State *_NLL) +{ + CheckEx(_NLL, 2); + CheckIndexNull(_NLL, 1); + int PET_Index = (int)lua_tointeger(_NLL, 1); + int PET_flg = (int)lua_tointeger(_NLL, 2); + int PET_Ret = -1; + if(!CHAR_CHECKINDEX(PET_Index)) + { + LRetErrInt(_NLL, -1, "Чġ"); + } + PET_Ret = CHAR_getInt( PET_Index, CHAR_ALLOCPOINT); + switch (PET_flg) + { + case 0: + PET_Ret = ((PET_Ret>> 0) & 0xFF); + break; + case 1: + PET_Ret = ((PET_Ret>> 8) & 0xFF); + break; + case 2: + PET_Ret = ((PET_Ret>> 16) & 0xFF); + break; + case 3: + PET_Ret = ((PET_Ret>>24) & 0xFF); + break; + } + LRetInt(_NLL, PET_Ret); +} + +int NPC_Lua_Char_GetDataFromEnemyBase(lua_State *_NLL) +{ + CheckEx(_NLL, 2); + CheckIndexNull(_NLL, 1); + int PET_ID = (int)lua_tointeger(_NLL, 1); + int PET_flg = (int)lua_tointeger(_NLL, 2); + if(ENEMYTEMP_getEnemyTempArrayFromTempNo(PET_ID) == -1) + { + LRetErrInt(_NLL, -1, "EnemyBaseIDڡ"); + } + PET_ID = ENEMY_getEnemyArrayFromTempNo( PET_ID); + PET_ID = ENEMYTEMP_getEnemyTempArray( PET_ID); + if(PET_flg >= 0) + { + if(PET_flg >= LUA_DATALINE1) + { + PET_flg = PET_flg - LUA_DATALINE1; + char *TM_RetPoint = ENEMYTEMP_getChar( PET_ID, PET_flg); + LRetMsg(_NLL, TM_RetPoint); + } + else + { + int PET_Ret = ENEMYTEMP_getInt( PET_ID, PET_flg); + LRetInt(_NLL, PET_Ret); + } + } + else + { + LRetErrInt(_NLL, -1, "ı־Ǵġ"); + } +} + +int NPC_Lua_Char_GetPlayerIndex(lua_State *_NLL) +{ + CheckEx(_NLL, 1); + char *TM_PlayerID = lua_tostring(_NLL, 1); + + if(TM_PlayerID == NULL ) + { + LRetErrInt(_NLL, -1, "Чġ"); + } + + int TM_playernum = CHAR_getPlayerMaxNum(); + int i; + for( i = 0 ; i < TM_playernum ; i++){ + if( CHAR_getCharUse(i) != FALSE ){ + char *TM_ServerPlayerID = CHAR_getChar(i, CHAR_CDKEY); + if (strcmp(TM_ServerPlayerID,TM_PlayerID)==0) + { + LRetInt(_NLL, i); + } + } + } + LRetErrNull(_NLL, "ı־Ǵġ"); +} + +int NPC_Lua_Char_FindItemIndex(lua_State *_NLL) +{ + CheckEx(_NLL, 2); + CheckIndexNull(_NLL, 1); + CheckIndexNull(_NLL, 2); + + int TM_CharaIndex = (int)lua_tointeger(_NLL, 1); + int TM_ItemIndex = (int)lua_tointeger(_NLL, 2); + int tmpTM_ItemIndex = 0; + + if(!CHAR_CHECKINDEX(TM_CharaIndex)) + { + LRetErrInt(_NLL, -1, "Чġ"); + } + if(!ITEM_CHECKINDEX(TM_ItemIndex)) + { + LRetErrInt(_NLL, -1, "ߵЧġ"); + } + + int i = 0; + for( i = 0 ; i 0) LRetInt(_NLL, k); + LRetErrInt(_NLL, -2, "Ҳָߡ"); +} + +int NPC_Lua_Char_DelHcItem(lua_State *_NLL) +{ + CheckEx(_NLL, 3); + CheckIndexNull(_NLL, 1); + int TM_Index = (int)lua_tointeger(_NLL, 1); + int TM_ItemId = (int)lua_tointeger(_NLL, 2); + + if(!CHAR_CHECKINDEX(TM_Index)) + { + LRetErrInt(_NLL, -1, "Чġ"); + } + + if( TM_ItemId < 9 || TM_ItemId > 23){ + LRetErrInt(_NLL, -2, "Ҳָĵλá"); + } + else { + CHAR_DelItem( TM_Index, TM_ItemId); + LRetInt(_NLL, 1); + } +} + +int NPC_Lua_Char_GETFM(lua_State *_NLL) +{ + CheckEx(_NLL, 2); + CheckIndexNull(_NLL, 1); + int TM_ID = (int)lua_tointeger(_NLL, 1); + int TM_X = (int)lua_tointeger(_NLL, 2); + LRetInt(_NLL, Char_GetFm( TM_ID, TM_X)); +} + +int NPC_Lua_Char_FindPetEnemyBaseId(lua_State *_NLL) +{ + CheckEx(_NLL, 2); + CheckIndexNull(_NLL, 1); + int TM_Index = (int)lua_tointeger(_NLL, 1); + int TM_EnemyId = (int)lua_tointeger(_NLL, 2); + int TM_PetIndex = -1; + int i = 0; + int petid = -1; + if(!CHAR_CHECKINDEX(TM_Index)) + { + LRetErrInt(_NLL, -1, "Чġ"); + } + int enemynum = ENEMY_getEnemyNum(); + for( i = 0; i < enemynum; i ++ ) + { + if (TM_EnemyId == ENEMY_getInt( i, ENEMY_ID )){ + petid = ENEMY_getInt( i, ENEMY_TEMPNO ); + break; + } + } + + for( i = 0 ; i 63) LRetErrInt(_NLL, -1, "Чġ"); + + if (RIDEPET_getPETID( TM_Index, RidNo) >= 0) + { + LRetBool(_NLL, TRUE); + }else LRetBool(_NLL, FALSE); +} +*/ +int NPC_Lua_Char_GetPetOwner(lua_State *_NLL) +{ + CheckEx(_NLL, 1); + CheckIndexNull(_NLL, 1); + int TM_Index = (int)lua_tointeger(_NLL, 1); + if(!CHAR_CHECKINDEX(TM_Index)) + { + LRetErrInt(_NLL, -1, "Чġ"); + } + if( CHAR_getInt( TM_Index, CHAR_WHICHTYPE ) != CHAR_TYPEPET ){ + LRetErrInt(_NLL, -2, "Ķ󲢲dz"); + } + int charaindex = CHAR_getWorkInt(TM_Index, CHAR_WORKPLAYERINDEX); + LRetInt(_NLL, charaindex); +} + +int NPC_Lua_Char_GetEnemyBaseIdFromEnemyId(lua_State *_NLL) +{ + CheckEx(_NLL, 1); + CheckIndexNull(_NLL, 1); + int EnemyId = (int)lua_tointeger(_NLL, 1); + int enemynum = ENEMY_getEnemyNum(); + int petid = -1; + int i; + for( i = 0; i < enemynum; i ++ ) + { + if (EnemyId == ENEMY_getInt( i, ENEMY_ID )){ + petid = ENEMY_getInt( i, ENEMY_TEMPNO ); + break; + } + } + if (i == enemynum) LRetErrInt(_NLL, -1, "enemyIDûҵ"); + + LRetInt(_NLL, petid); +} + +int NPC_Lua_Char_GetEnemyIdFromEnemyBaseId(lua_State *_NLL) +{ + CheckEx(_NLL, 1); + CheckIndexNull(_NLL, 1); + int EnemybaseId = (int)lua_tointeger(_NLL, 1); + int enemynum = ENEMY_getEnemyNum(); + int EnemyId = -1; + int i; + for( i = 0; i < enemynum; i ++ ) + { + if (EnemybaseId == ENEMY_getInt( i, ENEMY_TEMPNO )){ + EnemyId = ENEMY_getInt( i, ENEMY_ID ); + break; + } + } + if (i == enemynum) LRetErrInt(_NLL, -1, "enemybaseIDûҵ"); + + LRetInt(_NLL, EnemyId); +} + +int NPC_Lua_Char_GetIp(lua_State *_NLL) +{ + CheckEx(_NLL, 2); + CheckIndexNull(_NLL, 1); + int TM_Index = (int)lua_tointeger(_NLL, 1); + int TM_Flg = (int)lua_tointeger(_NLL, 2); + if(!CHAR_CHECKINDEX(TM_Index)) + { + LRetErrInt(_NLL, -1, "Чġ"); + } + if( CHAR_getInt( TM_Index, CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER ){ + LRetErrInt(_NLL, -2, "Ķ󲢲"); + } + int fd = getfdFromCharaIndex( TM_Index ); + if( fd == -1 ){ + LRetErrInt(_NLL, -2, "Ѿߣ"); + } + if(TM_Flg == 1)//IP + { + LRetMsg(_NLL,CONNECT_get_userip2(fd)); + }else if(TM_Flg == 2)//FD + { + LRetInt(_NLL,fd); + }else if(TM_Flg == 3)//˿ + { + LRetInt(_NLL,CONNECT_get_userport(fd)); + } + LRetErrNull(_NLL, "ı־Ǵġ"); +} + +int NPC_Lua_Char_SetAllocPoint(lua_State *_NLL) +{ + CheckEx(_NLL, 3); + CheckIndexNull(_NLL, 1); + int petindex = (int)lua_tointeger(_NLL, 1); + int type = (int)lua_tointeger(_NLL, 2); + int val = (int)lua_tointeger(_NLL, 3); + if (val < 0 || val > 255) LRetErrInt(_NLL, -1, "valΪ0-255"); + if(!CHAR_CHECKINDEX(petindex)) + { + LRetErrInt(_NLL, -1, "Чġ"); + } + if( CHAR_getInt( petindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER ){ + LRetErrInt(_NLL, -2, "Ķ"); + } + int LevelUpPoint = CHAR_getInt( petindex, CHAR_ALLOCPOINT ); + int t = (int )(( LevelUpPoint >> 24 ) & 0xFF); + int g = (int )(( LevelUpPoint >> 16 ) & 0xFF); + int f = (int )(( LevelUpPoint >> 8 ) & 0xFF); + int m = (int )(( LevelUpPoint >> 0 ) & 0xFF); + + if (type == 1) { + LevelUpPoint = (val<<24)+(g<<16)+(f<<8)+(m<<0); + CHAR_setInt( petindex, CHAR_ALLOCPOINT, LevelUpPoint); + LRetInt(_NLL, t); + } + else if (type == 2) { + LevelUpPoint = (t<<24)+(val<<16)+(f<<8)+(m<<0); + CHAR_setInt( petindex, CHAR_ALLOCPOINT, LevelUpPoint); + LRetInt(_NLL, g); + } + else if (type == 3) { + LevelUpPoint = (t<<24)+(g<<16)+(val<<8)+(m<<0); + CHAR_setInt( petindex, CHAR_ALLOCPOINT, LevelUpPoint); + LRetInt(_NLL, f); + } + else if (type == 4) { + LevelUpPoint = (t<<24)+(g<<16)+(f<<8)+(val<<0); + CHAR_setInt( petindex, CHAR_ALLOCPOINT, LevelUpPoint); + LRetInt(_NLL, m); + } +} + +int NPC_Lua_Char_GetMaxPetIndex(lua_State *_NLL) +{ + CheckEx(_NLL, 0); + int MAXPLAYER = CHAR_getPlayerMaxNum(); + int MAXPET = CHAR_getPetMaxNum(); + int maxindex = MAXPLAYER + MAXPET; + LRetInt(_NLL, maxindex); +} + +int NPC_Lua_Char_GetMaxPlayerIndex(lua_State *_NLL) +{ + CheckEx(_NLL, 0); + int maxindex = CHAR_getPlayerMaxNum(); + LRetInt(_NLL, maxindex); +} + +int NPC_Lua_Char_SavePetToString(lua_State *_NLL) +{ + char *petdata = "\0"; + CheckEx(_NLL, 1); + int petindex = (int)lua_tointeger(_NLL, 1); + if(!CHAR_CHECKINDEX(petindex)) + { + LRetErrInt(_NLL, -1, "Чġ"); + } + if( CHAR_getInt( petindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER ){ + LRetErrInt(_NLL, -2, "Ķ"); + return; + } + petdata = CHAR_makePetStringFromPetIndex( petindex); + LRetMsg(_NLL, petdata); +} + +int NPC_Lua_Char_LoadPetFromString(lua_State *_NLL) +{ + CheckEx(_NLL, 1); + char * petdata = (char *)lua_tostring(_NLL, 1); + Char petone; + int petindex; + BOOL ret = CHAR_makePetFromStringToArg(petdata,&petone, 0); + if( ret == TRUE ){ + petindex = PET_initCharOneArray( &petone ); + if( petindex < 0 ){ + LRetErrInt(_NLL, -2, "ʧ"); + return; + } + } + LRetInt(_NLL, petindex); +} + +int NPC_Lua_Char_GetPlayerFromAccAndName(lua_State *_NLL) +{ + CheckEx(_NLL, 2); + char *account = lua_tostring(_NLL, 1); + char *name = lua_tostring(_NLL, 2); + int i; + int playernum = CHAR_getPlayerMaxNum(); + int xindex = -1; + for( i = 0 ; i < playernum ; i++) { + if( CHAR_CHECKINDEX(i) ){ + if (strcmp(CHAR_getChar(i,CHAR_NAME), name) == 0) { + xindex = i; + break; + } + if (strcmp(CHAR_getChar(i,CHAR_CDKEY), account) == 0) { + xindex = i; + break; + } + } + } + + LRetInt(_NLL, xindex); +} + +int NPC_Lua_Char_CheckPet(lua_State *_NLL) +{ + CheckEx(_NLL, 1); + CheckIndexNull(_NLL, 1); + int TM_Index = (int)lua_tointeger(_NLL, 1); + BOOL CHECK = CHAR_CHECKINDEX(TM_Index); + LRetBool(_NLL, CHECK); +} + +int NPC_Lua_Char_CheckPlayer(lua_State *_NLL) +{ + CheckEx(_NLL, 1); + CheckIndexNull(_NLL, 1); + int TM_Index = (int)lua_tointeger(_NLL, 1); + BOOL CHECK = CHAR_CHECKINDEX(TM_Index); + LRetBool(_NLL, CHECK); +} + +BOOL NPC_Lua_Char_JoinParty(lua_State *_NLL) +{ + CheckEx(_NLL, 2); + CheckIndexNull(_NLL, 2); + int charaindex = (int)lua_tointeger(_NLL, 1); + int toindex = (int)lua_tointeger(_NLL, 2); + if (CHAR_CHECKINDEX(charaindex)&&CHAR_CHECKINDEX(toindex)) + { + CHAR_JoinParty_Main( charaindex, toindex); + LRetBool(_NLL, TRUE); + } + LRetBool(_NLL, FALSE); +} + +int NPC_Lua_Char_getFamilyPlayIndex(lua_State *_NLL) +{ + CheckEx(_NLL, 3); + CheckIndexNull(_NLL, 3); + int charaindex = (int)lua_tointeger(_NLL, 1); + if(!CHAR_CHECKINDEX(charaindex)) + { + LRetErrInt(_NLL, -1, "Чġ"); + } + int familyindex = (int)lua_tointeger(_NLL, 1); + int familymode = (int)lua_tointeger(_NLL, 2); + int familycharaindex = (int)lua_tointeger(_NLL, 3); + if(familyindex > FAMILY_MAXNUM){ + LRetErrInt(_NLL, -1, "ļЧġ"); + }else if (familymode > FAMILY_MAXCHANNEL) + { + LRetErrInt(_NLL, -1, "ļƵЧġ"); + }else if (familycharaindex > FAMILY_MAXMEMBER) + { + LRetErrInt(_NLL, -1, "ļЧ"); + } + int playindex = channelMember[familyindex][familymode][familycharaindex]; + LRetInt(_NLL,playindex); +} + +#endif //#ifdef _JZ_NEWSCRIPT_LUA diff --git a/npc_lua/npc_lua_ex.c b/npc_lua/npc_lua_ex.c new file mode 100644 index 0000000..06d8c22 --- /dev/null +++ b/npc_lua/npc_lua_ex.c @@ -0,0 +1,369 @@ +#include "npc_lua.h" +#include "util.h" +#include "char.h" +#include "char_base.h" +#include "anim_tbl.h" +#include "object.h" +#include "net.h" +#include "npcutil.h" +#include "npc_eventaction.h" +#include "battle.h" +#include "readmap.h" + +#ifdef _JZ_NEWSCRIPT_LUA + +extern char M_OutErrMsg[1024]; +extern lua_State *M_Script_Lua; +extern unsigned int M_Create_Num; + +////////////////////////////////////////////////////////////////////////////// +int NPC_Lua_RegCallEx(lua_State * _NLL, luaL_Reg *_RegList) +{ + assert(_RegList != NULL && _NLL != NULL); + + int i = 0; + if((_NLL != NULL) && (_RegList != NULL)) + { + while(_RegList->func != NULL) + { + lua_register(_NLL, _RegList->name, _RegList->func); + i++; + _RegList++; + } + } + return i; +} + +int NPC_Lua_RegLibEx(lua_State * _NLL, PSCRIPTREGLIB _RegLib) +{ + assert(_RegLib != NULL && _NLL != NULL); + + int i = 0; + if((_NLL != NULL) && (_RegLib != NULL)) + { + while(_RegLib->LibName != NULL) + { + luaL_openlib(_NLL, _RegLib->LibName, _RegLib->FuncRegList, 0); + i++; + _RegLib++; + } + } + return i; +} + +int NPC_Lua_RegClassEx(lua_State * _NLL, PSCRIPTREGCLASS _RegClass) +{ + assert(_RegClass != NULL && _NLL != NULL); + + int i = 0; + if((_NLL != NULL) && (_RegClass != NULL)) + { + while(_RegClass->ClassName != NULL) + { + luaL_newmetatable(_NLL, _RegClass->ClassName); + + lua_pushstring(_NLL, "__index"); + lua_pushvalue(_NLL, -2); + lua_settable(_NLL, -3); + + luaL_openlib(_NLL, NULL, _RegClass->FuncRegList, 0); + + luaL_openlib(_NLL, _RegClass->NewLib , _RegClass->NewLib->FuncRegList, 0); + + i++; + _RegClass++; + } + } + return i; +} + +int NPC_Lua_RegArrayEx(lua_State * _NLL, PSCRIPTREGARRAY _RegArray) +{ + assert(_RegArray != NULL && _NLL != NULL); + + int i = 0; + if((_NLL != NULL) && (_RegArray != NULL)) + { + int j = 0; + while(_RegArray->ArrayName != NULL) + { + luaL_newmetatable(_NLL, _RegArray->ArrayName); + luaL_openlib(_NLL, _RegArray->FuncList->LibName, _RegArray->FuncList->FuncRegList, 0); + + j = 0; + while(_RegArray->SetMetaTable[j] != NULL) + { + lua_pushstring(_NLL, _RegArray->SetMetaTable[j]); + lua_pushstring(_NLL, _RegArray->SetFuncName[j]); + lua_gettable(_NLL, 2); + lua_settable(_NLL, 1); + j++; + } + i++; + _RegArray++; + } + } + return i; +} + +const char *NPC_Lua_SetErrorStr(const char *ErrStr) +{ + if(ErrStr == NULL) + { + M_OutErrMsg[0] = '\0'; + return M_OutErrMsg; + } + return (const char *)strcpy_s(M_OutErrMsg, sizeof(M_OutErrMsg), ErrStr); +} + +//NPC-NPCΨһ +int NPC_Lua_Create(const char *_DoFile, const char *_InitFuncName, char *_seek, BOOL _IsFly) +{ + assert(_InitFuncName != NULL); + + Char TM_char; + Object TM_obj; + int TM_charaindex; + int TM_objindex; + int TM_seekint = 0; + + //ָĬֵTM_char + if(_seek == NULL) + { + TM_seekint = CHAR_seekGraphicNumberFromString("\0"); + }else + { + TM_seekint = CHAR_seekGraphicNumberFromString(_seek); + } + + if( CHAR_getDefaultChar( &TM_char, TM_seekint) == FALSE ) + { + LRetErrInt(M_Script_Lua, -1, "Ĭֵʧܡڲܲ"); + } + + //ָLUAűļ + if(_DoFile != NULL && _DoFile[0] != '\0') + { + if (NPC_Lua_DoFile(_DoFile) == 1){ +#ifdef _LUA_Debug + pcall_callback_err_fun(M_Script_Lua,_InitFuncName); +#endif + } + } + + //ָLUAűļ CAX +// NPC_Lua_DoFile(_DoFile); + //ȡýűжijʼָ + lua_getglobal(M_Script_Lua, _InitFuncName); + + if(lua_type(M_Script_Lua, -1) != LUA_TFUNCTION) + { + print("NPC_Lua_Create err: ޷ȡʼָ롣\n"); + lua_pop(M_Script_Lua, 1); + LRetErrInt(M_Script_Lua, -2, "޷ȡʼָ롣"); + }else + { + //溯ָ + lua_pop(M_Script_Lua, 1); + strcpy_s(TM_char.lua_charfunctable[CHAR_INITFUNC].string, sizeof(TM_char.lua_charfunctable[CHAR_INITFUNC].string), _InitFuncName); + strcpy_s(TM_char.charfunctable[CHAR_INITFUNC].string, sizeof(TM_char.charfunctable[CHAR_INITFUNC].string), FUNCNAME_INITCALLBACK); + } + TM_char.data[CHAR_FLOOR] = 777; + TM_char.data[CHAR_X] = 31; + TM_char.data[CHAR_Y] = 19; + TM_char.data[CHAR_DIR] = 4; + TM_char.string[CHAR_NAME].string[0] = '\0'; + TM_char.data[CHAR_BASEBASEIMAGENUMBER] = TM_char.data[CHAR_BASEIMAGENUMBER] = 0; +#ifdef _ADD_ACTION + TM_char.data[CHAR_ACTIONSTYLE] = CHAR_ACTSTAND; +#endif + TM_char.data[CHAR_FMINDEX] = -1; + TM_char.string[CHAR_NPCARGUMENT].string[0] = '\0'; + // + TM_char.data[CHAR_WHICHTYPE] = CHAR_LUANPC; + //ʶNPCNPC_Lua_CreateNPCţĿǰûʲô + TM_char.data[CHAR_NPCCREATEINDEX] = M_Create_Num++; + + //ʵTM_char ֮NPCʵݲ + TM_charaindex = CHAR_initCharOneArray( &TM_char ); + if( TM_charaindex == -1 ) + { + CHAR_endCharData( &TM_char ); + LRetErrInt(M_Script_Lua, -3, "޷ʵNPCݡ"); + } + + CHAR_setInt(TM_charaindex, CHAR_INDEXOFEQTITLE, -1); + CHAR_setWorkInt( TM_charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_NONE); + + //ͼ־Ŀǰ֪ã + if(_IsFly == TRUE) + { + CHAR_setFlg(TM_charaindex, CHAR_ISFLYING, 1); + } + + TM_obj.type = OBJTYPE_CHARA; // + TM_obj.index= TM_charaindex; //ӦChar + TM_obj.x = CHAR_getInt(TM_charaindex, CHAR_X); //ڵͼX + TM_obj.y = CHAR_getInt(TM_charaindex, CHAR_Y); //ڵͼY + TM_obj.floor = CHAR_getInt(TM_charaindex, CHAR_FLOOR);//ڵͼ + TM_objindex = initObjectOne( &TM_obj ); //һʵ֮NPCʵ + if( TM_objindex == -1 ) + { + CHAR_endCharOneArray( TM_charaindex ); + LRetErrInt(M_Script_Lua, -4, "޷ʵNPC"); + } + + CHAR_setWorkInt(TM_charaindex, CHAR_WORKOBJINDEX, TM_objindex); + +#ifdef _ADD_ACTION + //NPCĶ + CHAR_setWorkInt(TM_charaindex, CHAR_WORKACTION, CHAR_getInt( TM_charaindex, CHAR_ACTIONSTYLE ) ); + + CHAR_sendWatchEvent(TM_objindex, CHAR_getWorkInt( TM_charaindex, CHAR_WORKACTION), NULL, 0, TRUE); +#else + CHAR_sendWatchEvent(TM_objindex , CHAR_ACTSTAND, NULL, 0, TRUE); +#endif + CHAR_setWorkInt(TM_charaindex,CHAR_WORKNPCTYPE,2); + LRetInt(M_Script_Lua, TM_charaindex); +} + +//ɾNPC NPCΨһ +int NPC_Lua_Del(int _index) +{ + if (CHAR_getInt( _index, CHAR_WHICHTYPE )== CHAR_LUANPC) + { + int TM_Objindex = CHAR_getWorkInt( _index,CHAR_WORKOBJINDEX); + if(CHECKOBJECTUSE(TM_Objindex) == TRUE) + { + CHAR_ObjectDelete(TM_Objindex); + CHAR_endCharOneArray(_index); + return 1; + }else + { + CHAR_endCharOneArray(_index); + return 0; + } + } +} + +int NPC_Lua_GetFuncPoint(lua_State *_NLL) +{ + CheckEx2(_NLL, 2, LUA_MINSTACK); + char *TM_DoFile = lua_tostring(_NLL, 1); + char *TM_FuncName = lua_tostring(_NLL, 2); + + if(TM_DoFile != NULL) + { + if (NPC_Lua_DoFile(TM_DoFile) == 1){ +#ifdef _LUA_Debug + pcall_callback_err_fun(M_Script_Lua,TM_FuncName); +#endif + } + } + + if(TM_FuncName == NULL) + { + LRetErrInt(_NLL , -1, "Ϊ"); + } + + lua_getglobal(_NLL, TM_FuncName); + + if(lua_type(_NLL, -1) != LUA_TFUNCTION) + { + LRetErrInt(_NLL , -2, "޷ȡָ롣"); + } + LRetInt(_NLL, 1); +} +////////////////////////////////////////////////////////////////////////////// +//չͽӿں +//NTInt +int NPC_Lua_NTInt_New(lua_State *_NLL) +{ + CheckEx(_NLL, 1); + + int TM_Len = luaL_checkint(_NLL, 1); + if(TM_Len <= 0) + { + LRetErrInt(_NLL, -1, "СΪ0"); + } + + size_t TM_Bytes = sizeof(size_t) + ( sizeof(int) * TM_Len ); + PARRAY_NTINT TM_Point = (PARRAY_NTINT *)lua_newuserdata(_NLL, TM_Bytes); + + if(TM_Point == NULL) + { + LRetErrInt(_NLL, -2, "ʵʧܣڴ档"); + } + + luaL_getmetatable(_NLL, "Array.NTInt"); + lua_setmetatable(_NLL, -2); + + TM_Point->Size = TM_Len; + + LRet(1); +} + +int NPC_Lua_NTInt_Get(lua_State *_NLL) +{ + CheckEx(_NLL, 2); + + PARRAY_NTINT TM_Point = luaL_checkudata(_NLL, 1, "Array.NTInt"); + + if(TM_Point == NULL) + { + luaL_argerror(_NLL, 1, " Array.NTInt ݡ"); + } + + int TM_Index = (int)lua_tointeger(_NLL, 2); + + if(TM_Index < 1 || TM_Index > TM_Point->Size) + { + luaL_argerror(_NLL, 1, "ݷΧ"); + } + + TM_Index--; + + LRetInt(_NLL, TM_Point->Num[TM_Index]); +} + +int NPC_Lua_NTInt_Set(lua_State *_NLL) +{ + CheckEx(_NLL, 3); + + PARRAY_NTINT TM_Point = luaL_checkudata(_NLL, 1, "Array.NTInt"); + + if(TM_Point == NULL) + { + luaL_argerror(_NLL, 1, " Array.NTInt ݡ"); + } + + int TM_Index = (int)lua_tointeger(_NLL, 2); + + if(TM_Index < 1 || TM_Index > TM_Point->Size) + { + luaL_argerror(_NLL, 1, "ݷΧ"); + } + TM_Index--; + + int TM_Num = (int)lua_tointeger(_NLL, 3); + + TM_Point->Num[TM_Index] = TM_Num; + + LRetNull(_NLL); +} + +int NPC_Lua_NTInt_Len(lua_State *_NLL) +{ + CheckEx(_NLL, 1); + + PARRAY_NTINT TM_Point = luaL_checkudata(_NLL, 1, "Array.NTInt"); + + if(TM_Point == NULL) + { + luaL_argerror(_NLL, 1, " Array.NTInt ݡ"); + } + + LRetInt(_NLL, TM_Point->Size); +} + +#endif //#ifdef _JZ_NEWSCRIPT_LUA diff --git a/npc_lua/npc_lua_game.c b/npc_lua/npc_lua_game.c new file mode 100644 index 0000000..4b70f58 --- /dev/null +++ b/npc_lua/npc_lua_game.c @@ -0,0 +1,110 @@ +#include "npc_lua.h" +#include "util.h" +#include "char.h" +#include "char_base.h" +#include "char_data.h" +#include "anim_tbl.h" +#include "object.h" +#include "battle.h" +#include "npcutil.h" +#include "item.h" +#include "readmap.h" +#include "saacproto_cli.h" +#include "family.h" + +int NPC_Lua_Game_FMPOINT_GetData(lua_State *_NLL) +{ + CheckEx(_NLL, 2); + CheckIndexNull(_NLL, 1); + int GA_Index = (int)lua_tointeger(_NLL, 1); + int GA_Flg = (int)lua_tointeger(_NLL, 2); + + if(GA_Flg >= 0) + { + if(GA_Flg < LUA_DATALINE1) + { + GA_Flg -= LUA_DATALINE0; + char *GA_RetInt = FM_getManorData(GA_Index, GA_Flg); + LRetInt(_NLL, atoi(GA_RetInt)); + }else if(GA_Flg < LUA_DATALINE2) + { + GA_Flg -= LUA_DATALINE1; + char *GA_RetPoint = FM_getManorData(GA_Index, GA_Flg); + LRetMsg(_NLL, GA_RetPoint); + }else + { + LRetErrNull(_NLL, "ı־Ǵġ"); + } + } + LRetErrNull(_NLL, "ı־Ǵġ"); +} + +int NPC_Lua_Game_FMPOINT_ACSetFMPoint(lua_State *_NLL) +{ + CheckEx(_NLL, 5); + CheckIndexNull(_NLL, 1); + int leaderindex = (int)lua_tointeger(_NLL, 1); + int fmpointindex = (int)lua_tointeger(_NLL, 2); + int map = (int)lua_tointeger(_NLL, 3); + int x = (int)lua_tointeger(_NLL, 4); + int y = (int)lua_tointeger(_NLL, 5); + if(!CHAR_CHECKINDEX(leaderindex)) + { + LRetErrInt(_NLL, -1, "Чġ"); + } + if (fmpointindex < 0 || fmpointindex > 9) + { + LRetErrInt(_NLL, -1, "ׯ԰Чġ"); + } + int fd = getfdFromCharaIndex( leaderindex ); + if( fd == -1 ){ + LRetErrInt(_NLL, -2, "ҿѾߣ"); + } + char *tmpbuf = ""; + sprintf(tmpbuf, "%d|%d|%d|%d|%d|",leaderindex,fmpointindex,map,x,y); + FAMILY_SetPoint(fd,leaderindex,tmpbuf); + LRetInt(_NLL, 0); +} + +int NPC_Lua_Game_FMPOINT_ACFixFMPoint(lua_State *_NLL) +{ + CheckEx(_NLL, 3); + CheckIndexNull(_NLL, 1); + int winindex = (int)lua_tointeger(_NLL, 1); + int loseindex = (int)lua_tointeger(_NLL, 2); + int id = (int)lua_tointeger(_NLL, 3); + if(!CHAR_CHECKINDEX(winindex) || !CHAR_CHECKINDEX(loseindex)) + { + LRetErrNull(_NLL, "Чġ"); + } + if (id < 0 || id > 9) + { + LRetErrNull(_NLL, "ׯ԰Чġ"); + } +if(CHAR_getInt( winindex, CHAR_FMLEADERFLAG ) != FMMEMBER_LEADER)//峤 + { + LRetErrNull(_NLL, "󲢲峤"); + } +if(CHAR_getInt( loseindex, CHAR_FMLEADERFLAG ) != FMMEMBER_LEADER)//峤 + { + LRetErrNull(_NLL, "󲢲峤"); + } + saacproto_ACFixFMPoint_send(acfd, CHAR_getChar(winindex,CHAR_FMNAME),CHAR_getInt(winindex,CHAR_FMINDEX) + 1,CHAR_getInt(winindex,CHAR_FMINDEX), + CHAR_getChar(loseindex,CHAR_FMNAME),CHAR_getInt(loseindex,CHAR_FMINDEX) + 1,CHAR_getInt(loseindex,CHAR_FMINDEX),id); + LRetInt(_NLL, 0); +} + +int NPC_Lua_Game_FMPOINT_ACCleanFMPoint(lua_State *_NLL) +{ + CheckEx(_NLL, 1); + CheckIndexNull(_NLL, 1); + int id = (int)lua_tointeger(_NLL, 1); + if (id < 0 || id > 9) + { + LRetErrNull(_NLL, "ׯ԰Чġ"); + } + saacproto_ACDelFmPoint_send(acfd,id); +// saacproto_ACDelFmPoint_send(acfd,id); + LRetInt(_NLL, 0); +} + diff --git a/npc_lua/npc_lua_item.c b/npc_lua/npc_lua_item.c new file mode 100644 index 0000000..98ced41 --- /dev/null +++ b/npc_lua/npc_lua_item.c @@ -0,0 +1,595 @@ +#include "npc_lua.h" +#include "util.h" +#include "char.h" +#include "char_base.h" +#include "anim_tbl.h" +#include "object.h" +#include "net.h" +#include "npcutil.h" +#include "npc_eventaction.h" +#include "battle.h" +#include "readmap.h" +#include "item.h" + +#ifdef _JZ_NEWSCRIPT_LUA + +typedef enum +{ + LUAITEM_PREOVERFUNC = ITEM_PREOVERFUNC - ITEM_FIRSTFUNCTION, + LUAITEM_POSTOVERFUNC = ITEM_POSTOVERFUNC - ITEM_FIRSTFUNCTION, + LUAITEM_WATCHFUNC = ITEM_WATCHFUNC - ITEM_FIRSTFUNCTION, + LUAITEM_USEFUNC = ITEM_USEFUNC - ITEM_FIRSTFUNCTION, + LUAITEM_ATTACHFUNC = ITEM_ATTACHFUNC - ITEM_FIRSTFUNCTION, + LUAITEM_DETACHFUNC = ITEM_DETACHFUNC - ITEM_FIRSTFUNCTION, + LUAITEM_DROPFUNC = ITEM_DROPFUNC - ITEM_FIRSTFUNCTION, + LUAITEM_PICKUPFUNC = ITEM_PICKUPFUNC - ITEM_FIRSTFUNCTION, +#ifdef _Item_ReLifeAct + LUAITEM_DIERELIFEFUNC = ITEM_DIERELIFEFUNC - ITEM_FIRSTFUNCTION, +#endif +}LUAITEM_FUNC; + +//ȡݵĽӿ +int NPC_Lua_Item_GetData(lua_State *_NLL) +{ + CheckEx(_NLL, 2); + CheckItemIndexNull(_NLL, 1); + int TM_Index = (int)lua_tointeger(_NLL, 1); + int TM_Flg = (int)lua_tointeger(_NLL, 2); + + if(TM_Flg >= 0) + { + if(TM_Flg < LUA_DATALINE1) + { + TM_Flg -= LUA_DATALINE0; + int TM_RetInt = ITEM_getInt(TM_Index, TM_Flg); + LRetInt(_NLL, TM_RetInt); + }else if(TM_Flg < LUA_DATALINE2) + { + TM_Flg -= LUA_DATALINE1; + char *TM_RetPoint = ITEM_getChar(TM_Index, TM_Flg); + LRetMsg(_NLL, TM_RetPoint); + }else if(TM_Flg < LUA_DATALINE3) + { + TM_Flg -= LUA_DATALINE2; + int TM_RetWorkInt = ITEM_getWorkInt(TM_Index, TM_Flg); + LRetInt(_NLL, TM_RetWorkInt); + }else + { + LRetErrNull(_NLL, "ı־Ǵġ"); + } + } + LRetErrNull(_NLL, "ı־Ǵġ"); +} + +//ݵĽӿ +int NPC_Lua_Item_SetData(lua_State *_NLL) +{ + CheckEx(_NLL, 3); + CheckItemIndexNull(_NLL, 1); + int TM_Index = (int)lua_tointeger(_NLL, 1); + int TM_Flg = (int)lua_tointeger(_NLL, 2); + + if(TM_Flg >= 0) + { + if(TM_Flg < LUA_DATALINE1) + { + TM_Flg -= LUA_DATALINE0; + int TM_IntVal = (int)lua_tointeger(_NLL, 3); + int TM_RetInt = ITEM_setInt(TM_Index, TM_Flg, TM_IntVal); + LRetInt(_NLL, TM_RetInt); + }else if(TM_Flg < LUA_DATALINE2) + { + TM_Flg -= LUA_DATALINE1; + char *TM_CharPoint = (char *)lua_tostring(_NLL, 3); + BOOL TM_RetBOOL = ITEM_setChar(TM_Index, TM_Flg, TM_CharPoint); + LRetBool(_NLL, TM_RetBOOL); + }else if(TM_Flg < LUA_DATALINE3) + { + TM_Flg -= LUA_DATALINE2; + if(TM_Flg == ITEM_WORKOBJINDEX || TM_Flg == ITEM_WORKCHARAINDEX) + { + LRetInt(_NLL, 0); + } + int TM_WorkIntVal = (int)lua_tointeger(_NLL, 3); + int TM_RetInt = ITEM_setWorkInt(TM_Index, TM_Flg, TM_WorkIntVal); + LRetInt(_NLL, TM_RetInt); + }else + { + LRetErrNull(_NLL, "ı־Ǵġ"); + } + } + LRetErrNull(_NLL, "ı־Ǵġ"); +} + +//¼õĽӿ +int NPC_Lua_Item_SetPreOverEvent(lua_State *_NLL) +{ + CheckEx(_NLL, 3); + CheckItemIndexNull(_NLL, 3); + int TM_index = (int)lua_tointeger(_NLL, 3); + + ITEM_Item *TM_Item = ITEM_getItemPointer(TM_index); + + if(TM_Item == NULL) + { + LRetErrInt(_NLL , -1, "Чġ"); + } + int TM_Ret = NPC_Lua_GetFuncPoint(_NLL); + + if(lua_tointeger(_NLL, -1) > 0) + { + if(TM_Item->functable[LUAITEM_PREOVERFUNC] != (void *)NPC_Lua_ItemPerOverCallBack) + { + if(TM_Item->functable[LUAITEM_PREOVERFUNC] != NULL) + { + TM_Item->sur_functable[LUAITEM_PREOVERFUNC] = TM_Item->functable[LUAITEM_PREOVERFUNC]; + strcpy_s(TM_Item->sur_charfunctable[LUAITEM_PREOVERFUNC].string, sizeof(TM_Item->sur_charfunctable[LUAITEM_PREOVERFUNC].string), TM_Item->string[ITEM_PREOVERFUNC].string); + }else + { + TM_Item->sur_functable[LUAITEM_PREOVERFUNC] = (void *)NULL; + TM_Item->sur_charfunctable[LUAITEM_PREOVERFUNC].string[0] = '\0'; + } + + TM_Item->functable[LUAITEM_PREOVERFUNC] = (void *)NPC_Lua_ItemPerOverCallBack; + strcpy_s(TM_Item->lua_charfunctable[LUAITEM_PREOVERFUNC].string, sizeof(TM_Item->lua_charfunctable[LUAITEM_PREOVERFUNC].string), lua_tostring(_NLL, 2)); + strcpy_s(TM_Item->string[ITEM_PREOVERFUNC].string, sizeof(TM_Item->string[ITEM_PREOVERFUNC].string), FUNCNAME_ITEMPEROVERCALLBACK); + } + }else + { + if(TM_Item->functable[LUAITEM_PREOVERFUNC] == (void *)NPC_Lua_ItemPerOverCallBack) + { + TM_Item->lua_charfunctable[LUAITEM_PREOVERFUNC].string[0] = '\0'; + if(TM_Item->sur_functable[LUAITEM_PREOVERFUNC] == NULL) + { + TM_Item->functable[LUAITEM_PREOVERFUNC] = (void *)NULL; + TM_Item->string[ITEM_PREOVERFUNC].string[0] = '\0'; + }else + { + TM_Item->functable[LUAITEM_PREOVERFUNC] = TM_Item->sur_functable[LUAITEM_PREOVERFUNC]; + TM_Item->sur_functable[LUAITEM_PREOVERFUNC] = (void *)NULL; + strcpy_s(TM_Item->string[ITEM_PREOVERFUNC].string, sizeof(TM_Item->string[ITEM_PREOVERFUNC].string), TM_Item->sur_charfunctable[LUAITEM_PREOVERFUNC].string); + } + } + } + return TM_Ret; +} + +int NPC_Lua_Item_SetPostOverEvent(lua_State *_NLL) +{ + CheckEx(_NLL, 3); + CheckItemIndexNull(_NLL, 3); + int TM_index = (int)lua_tointeger(_NLL, 3); + + ITEM_Item *TM_Item = ITEM_getItemPointer(TM_index); + + if(TM_Item == NULL) + { + LRetErrInt(_NLL , -1, "Чġ"); + } + int TM_Ret = NPC_Lua_GetFuncPoint(_NLL); + + if(lua_tointeger(_NLL, -1) > 0) + { + if(TM_Item->functable[LUAITEM_POSTOVERFUNC] != (void *)NPC_Lua_ItemPostOverCallBack) + { + if(TM_Item->functable[LUAITEM_POSTOVERFUNC] != NULL) + { + TM_Item->sur_functable[LUAITEM_POSTOVERFUNC] = TM_Item->functable[LUAITEM_POSTOVERFUNC]; + strcpy_s(TM_Item->sur_charfunctable[LUAITEM_POSTOVERFUNC].string, sizeof(TM_Item->sur_charfunctable[LUAITEM_POSTOVERFUNC].string), TM_Item->string[ITEM_POSTOVERFUNC].string); + }else + { + TM_Item->sur_functable[LUAITEM_POSTOVERFUNC] = (void *)NULL; + TM_Item->sur_charfunctable[LUAITEM_POSTOVERFUNC].string[0] = '\0'; + } + + TM_Item->functable[LUAITEM_POSTOVERFUNC] = (void *)NPC_Lua_ItemPostOverCallBack; + strcpy_s(TM_Item->lua_charfunctable[LUAITEM_POSTOVERFUNC].string, sizeof(TM_Item->lua_charfunctable[LUAITEM_POSTOVERFUNC].string), lua_tostring(_NLL, 2)); + strcpy_s(TM_Item->string[ITEM_POSTOVERFUNC].string, sizeof(TM_Item->string[ITEM_POSTOVERFUNC].string), FUNCNAME_ITEMPOSTOVERCALLBACK); + } + }else + { + if(TM_Item->functable[LUAITEM_POSTOVERFUNC] == (void *)NPC_Lua_ItemPostOverCallBack) + { + TM_Item->lua_charfunctable[LUAITEM_POSTOVERFUNC].string[0] = '\0'; + if(TM_Item->sur_functable[LUAITEM_POSTOVERFUNC] == NULL) + { + TM_Item->functable[LUAITEM_POSTOVERFUNC] = (void *)NULL; + TM_Item->string[ITEM_POSTOVERFUNC].string[0] = '\0'; + }else + { + TM_Item->functable[LUAITEM_POSTOVERFUNC] = TM_Item->sur_functable[LUAITEM_POSTOVERFUNC]; + TM_Item->sur_functable[LUAITEM_POSTOVERFUNC] = (void *)NULL; + strcpy_s(TM_Item->string[ITEM_POSTOVERFUNC].string, sizeof(TM_Item->string[ITEM_POSTOVERFUNC].string), TM_Item->sur_charfunctable[LUAITEM_POSTOVERFUNC].string); + } + } + } + return TM_Ret; +} + +int NPC_Lua_Item_SetWatchEvent(lua_State *_NLL) +{ + CheckEx(_NLL, 3); + CheckItemIndexNull(_NLL, 3); + int TM_index = (int)lua_tointeger(_NLL, 3); + + ITEM_Item *TM_Item = ITEM_getItemPointer(TM_index); + + if(TM_Item == NULL) + { + LRetErrInt(_NLL , -1, "Чġ"); + } + int TM_Ret = NPC_Lua_GetFuncPoint(_NLL); + + if(lua_tointeger(_NLL, -1) > 0) + { + if(TM_Item->functable[LUAITEM_WATCHFUNC] != (void *)NPC_Lua_ItemWatchCallBack) + { + if(TM_Item->functable[LUAITEM_WATCHFUNC] != NULL) + { + TM_Item->sur_functable[LUAITEM_WATCHFUNC] = TM_Item->functable[LUAITEM_WATCHFUNC]; + strcpy_s(TM_Item->sur_charfunctable[LUAITEM_WATCHFUNC].string, sizeof(TM_Item->sur_charfunctable[LUAITEM_WATCHFUNC].string), TM_Item->string[ITEM_WATCHFUNC].string); + }else + { + TM_Item->sur_functable[LUAITEM_WATCHFUNC] = (void *)NULL; + TM_Item->sur_charfunctable[LUAITEM_WATCHFUNC].string[0] = '\0'; + } + + TM_Item->functable[LUAITEM_WATCHFUNC] = (void *)NPC_Lua_ItemWatchCallBack; + strcpy_s(TM_Item->lua_charfunctable[LUAITEM_WATCHFUNC].string, sizeof(TM_Item->lua_charfunctable[LUAITEM_WATCHFUNC].string), lua_tostring(_NLL, 2)); + strcpy_s(TM_Item->string[ITEM_WATCHFUNC].string, sizeof(TM_Item->string[ITEM_WATCHFUNC].string), FUNCNAME_ITEMWATCHCALLBACK); + } + }else + { + if(TM_Item->functable[LUAITEM_WATCHFUNC] == (void *)NPC_Lua_ItemWatchCallBack) + { + TM_Item->lua_charfunctable[LUAITEM_WATCHFUNC].string[0] = '\0'; + if(TM_Item->sur_functable[LUAITEM_WATCHFUNC] == NULL) + { + TM_Item->functable[LUAITEM_WATCHFUNC] = (void *)NULL; + TM_Item->string[ITEM_WATCHFUNC].string[0] = '\0'; + }else + { + TM_Item->functable[LUAITEM_WATCHFUNC] = TM_Item->sur_functable[LUAITEM_WATCHFUNC]; + TM_Item->sur_functable[LUAITEM_WATCHFUNC] = (void *)NULL; + strcpy_s(TM_Item->string[ITEM_WATCHFUNC].string, sizeof(TM_Item->string[ITEM_WATCHFUNC].string), TM_Item->sur_charfunctable[LUAITEM_WATCHFUNC].string); + } + } + } + return TM_Ret; +} + +int NPC_Lua_Item_SetUseEvent(lua_State *_NLL) +{ + CheckEx(_NLL, 3); + CheckItemIndexNull(_NLL, 3); + int TM_index = (int)lua_tointeger(_NLL, 3); + + ITEM_Item *TM_Item = ITEM_getItemPointer(TM_index); + + if(TM_Item == NULL) + { + LRetErrInt(_NLL , -1, "Чġ"); + } + int TM_Ret = NPC_Lua_GetFuncPoint(_NLL); + + if(lua_tointeger(_NLL, -1) > 0) + { + if(TM_Item->functable[LUAITEM_USEFUNC] != (void *)NPC_Lua_ItemUseCallBack) + { + if(TM_Item->functable[LUAITEM_USEFUNC] != NULL) + { + TM_Item->sur_functable[LUAITEM_USEFUNC] = TM_Item->functable[LUAITEM_USEFUNC]; + strcpy_s(TM_Item->sur_charfunctable[LUAITEM_USEFUNC].string, sizeof(TM_Item->sur_charfunctable[LUAITEM_USEFUNC].string), TM_Item->string[ITEM_USEFUNC].string); + }else + { + TM_Item->sur_functable[LUAITEM_USEFUNC] = (void *)NULL; + TM_Item->sur_charfunctable[LUAITEM_USEFUNC].string[0] = '\0'; + } + + TM_Item->functable[LUAITEM_USEFUNC] = (void *)NPC_Lua_ItemUseCallBack; + strcpy_s(TM_Item->lua_charfunctable[LUAITEM_USEFUNC].string, sizeof(TM_Item->lua_charfunctable[LUAITEM_USEFUNC].string), lua_tostring(_NLL, 2)); + strcpy_s(TM_Item->string[ITEM_USEFUNC].string, sizeof(TM_Item->string[ITEM_USEFUNC].string), FUNCNAME_ITEMUSECALLBACK); + } + }else + { + if(TM_Item->functable[LUAITEM_USEFUNC] == (void *)NPC_Lua_ItemUseCallBack) + { + TM_Item->lua_charfunctable[LUAITEM_USEFUNC].string[0] = '\0'; + if(TM_Item->sur_functable[LUAITEM_USEFUNC] == NULL) + { + TM_Item->functable[LUAITEM_USEFUNC] = (void *)NULL; + TM_Item->string[ITEM_USEFUNC].string[0] = '\0'; + }else + { + TM_Item->functable[LUAITEM_USEFUNC] = TM_Item->sur_functable[LUAITEM_USEFUNC]; + TM_Item->sur_functable[LUAITEM_USEFUNC] = (void *)NULL; + strcpy_s(TM_Item->string[ITEM_USEFUNC].string, sizeof(TM_Item->string[ITEM_USEFUNC].string), TM_Item->sur_charfunctable[LUAITEM_USEFUNC].string); + } + } + } + return TM_Ret; +} + +int NPC_Lua_Item_SetAttachEvent(lua_State *_NLL) +{ + CheckEx(_NLL, 3); + CheckItemIndexNull(_NLL, 3); + int TM_index = (int)lua_tointeger(_NLL, 3); + + ITEM_Item *TM_Item = ITEM_getItemPointer(TM_index); + + if(TM_Item == NULL) + { + LRetErrInt(_NLL , -1, "Чġ"); + } + int TM_Ret = NPC_Lua_GetFuncPoint(_NLL); + + if(lua_tointeger(_NLL, -1) > 0) + { + if(TM_Item->functable[LUAITEM_ATTACHFUNC] != (void *)NPC_Lua_ItemAttachCallBack) + { + if(TM_Item->functable[LUAITEM_ATTACHFUNC] != NULL) + { + TM_Item->sur_functable[LUAITEM_ATTACHFUNC] = TM_Item->functable[LUAITEM_ATTACHFUNC]; + strcpy_s(TM_Item->sur_charfunctable[LUAITEM_ATTACHFUNC].string, sizeof(TM_Item->sur_charfunctable[LUAITEM_ATTACHFUNC].string), TM_Item->string[ITEM_ATTACHFUNC].string); + }else + { + TM_Item->sur_functable[LUAITEM_ATTACHFUNC] = (void *)NULL; + TM_Item->sur_charfunctable[LUAITEM_ATTACHFUNC].string[0] = '\0'; + } + + TM_Item->functable[LUAITEM_ATTACHFUNC] = (void *)NPC_Lua_ItemAttachCallBack; + strcpy_s(TM_Item->lua_charfunctable[LUAITEM_ATTACHFUNC].string, sizeof(TM_Item->lua_charfunctable[LUAITEM_ATTACHFUNC].string), lua_tostring(_NLL, 2)); + strcpy_s(TM_Item->string[ITEM_ATTACHFUNC].string, sizeof(TM_Item->string[ITEM_ATTACHFUNC].string), FUNCNAME_ITEMATTACHCALLBACK); + } + }else + { + if(TM_Item->functable[LUAITEM_ATTACHFUNC] == (void *)NPC_Lua_ItemAttachCallBack) + { + TM_Item->lua_charfunctable[LUAITEM_ATTACHFUNC].string[0] = '\0'; + if(TM_Item->sur_functable[LUAITEM_ATTACHFUNC] == NULL) + { + TM_Item->functable[LUAITEM_ATTACHFUNC] = (void *)NULL; + TM_Item->string[ITEM_ATTACHFUNC].string[0] = '\0'; + }else + { + TM_Item->functable[LUAITEM_ATTACHFUNC] = TM_Item->sur_functable[LUAITEM_ATTACHFUNC]; + TM_Item->sur_functable[LUAITEM_ATTACHFUNC] = (void *)NULL; + strcpy_s(TM_Item->string[ITEM_ATTACHFUNC].string, sizeof(TM_Item->string[ITEM_ATTACHFUNC].string), TM_Item->sur_charfunctable[LUAITEM_ATTACHFUNC].string); + } + } + } + return TM_Ret; +} + +int NPC_Lua_Item_SetDetachEvent(lua_State *_NLL) +{ + CheckEx(_NLL, 3); + CheckItemIndexNull(_NLL, 3); + int TM_index = (int)lua_tointeger(_NLL, 3); + + ITEM_Item *TM_Item = ITEM_getItemPointer(TM_index); + + if(TM_Item == NULL) + { + LRetErrInt(_NLL , -1, "Чġ"); + } + int TM_Ret = NPC_Lua_GetFuncPoint(_NLL); + + if(lua_tointeger(_NLL, -1) > 0) + { + if(TM_Item->functable[LUAITEM_DETACHFUNC] != (void *)NPC_Lua_ItemDetachCallBack) + { + if(TM_Item->functable[LUAITEM_DETACHFUNC] != NULL) + { + TM_Item->sur_functable[LUAITEM_DETACHFUNC] = TM_Item->functable[LUAITEM_DETACHFUNC]; + strcpy_s(TM_Item->sur_charfunctable[LUAITEM_DETACHFUNC].string, sizeof(TM_Item->sur_charfunctable[LUAITEM_DETACHFUNC].string), TM_Item->string[ITEM_DETACHFUNC].string); + }else + { + TM_Item->sur_functable[LUAITEM_DETACHFUNC] = (void *)NULL; + TM_Item->sur_charfunctable[LUAITEM_DETACHFUNC].string[0] = '\0'; + } + + TM_Item->functable[LUAITEM_DETACHFUNC] = (void *)NPC_Lua_ItemDetachCallBack; + strcpy_s(TM_Item->lua_charfunctable[LUAITEM_DETACHFUNC].string, sizeof(TM_Item->lua_charfunctable[LUAITEM_DETACHFUNC].string), lua_tostring(_NLL, 2)); + strcpy_s(TM_Item->string[ITEM_DETACHFUNC].string, sizeof(TM_Item->string[ITEM_DETACHFUNC].string), FUNCNAME_ITEMDETACHCALLBACK); + } + }else + { + if(TM_Item->functable[LUAITEM_DETACHFUNC] == (void *)NPC_Lua_ItemDetachCallBack) + { + TM_Item->lua_charfunctable[LUAITEM_DETACHFUNC].string[0] = '\0'; + if(TM_Item->sur_functable[LUAITEM_DETACHFUNC] == NULL) + { + TM_Item->functable[LUAITEM_DETACHFUNC] = (void *)NULL; + TM_Item->string[ITEM_DETACHFUNC].string[0] = '\0'; + }else + { + TM_Item->functable[LUAITEM_DETACHFUNC] = TM_Item->sur_functable[LUAITEM_DETACHFUNC]; + TM_Item->sur_functable[LUAITEM_DETACHFUNC] = (void *)NULL; + strcpy_s(TM_Item->string[ITEM_DETACHFUNC].string, sizeof(TM_Item->string[ITEM_DETACHFUNC].string), TM_Item->sur_charfunctable[LUAITEM_DETACHFUNC].string); + } + } + } + return TM_Ret; +} + +int NPC_Lua_Item_SetDropEvent(lua_State *_NLL) +{ + CheckEx(_NLL, 3); + CheckItemIndexNull(_NLL, 3); + int TM_index = (int)lua_tointeger(_NLL, 3); + + ITEM_Item *TM_Item = ITEM_getItemPointer(TM_index); + + if(TM_Item == NULL) + { + LRetErrInt(_NLL , -1, "Чġ"); + } + int TM_Ret = NPC_Lua_GetFuncPoint(_NLL); + + if(lua_tointeger(_NLL, -1) > 0) + { + if(TM_Item->functable[LUAITEM_DROPFUNC] != (void *)NPC_Lua_ItemDropCallBack) + { + if(TM_Item->functable[LUAITEM_DROPFUNC] != NULL) + { + TM_Item->sur_functable[LUAITEM_DROPFUNC] = TM_Item->functable[LUAITEM_DROPFUNC]; + strcpy_s(TM_Item->sur_charfunctable[LUAITEM_DROPFUNC].string, sizeof(TM_Item->sur_charfunctable[LUAITEM_DROPFUNC].string), TM_Item->string[ITEM_DROPFUNC].string); + }else + { + TM_Item->sur_functable[LUAITEM_DROPFUNC] = (void *)NULL; + TM_Item->sur_charfunctable[LUAITEM_DROPFUNC].string[0] = '\0'; + } + + TM_Item->functable[LUAITEM_DROPFUNC] = (void *)NPC_Lua_ItemDropCallBack; + strcpy_s(TM_Item->lua_charfunctable[LUAITEM_DROPFUNC].string, sizeof(TM_Item->lua_charfunctable[LUAITEM_DROPFUNC].string), lua_tostring(_NLL, 2)); + strcpy_s(TM_Item->string[ITEM_DROPFUNC].string, sizeof(TM_Item->string[ITEM_DROPFUNC].string), FUNCNAME_ITEMDROPCALLBACK); + } + }else + { + if(TM_Item->functable[LUAITEM_DROPFUNC] == (void *)NPC_Lua_ItemDropCallBack) + { + TM_Item->lua_charfunctable[LUAITEM_DROPFUNC].string[0] = '\0'; + if(TM_Item->sur_functable[LUAITEM_DROPFUNC] == NULL) + { + TM_Item->functable[LUAITEM_DROPFUNC] = (void *)NULL; + TM_Item->string[ITEM_DROPFUNC].string[0] = '\0'; + }else + { + TM_Item->functable[LUAITEM_DROPFUNC] = TM_Item->sur_functable[LUAITEM_DROPFUNC]; + TM_Item->sur_functable[LUAITEM_DROPFUNC] = (void *)NULL; + strcpy_s(TM_Item->string[ITEM_DROPFUNC].string, sizeof(TM_Item->string[ITEM_DROPFUNC].string), TM_Item->sur_charfunctable[LUAITEM_DROPFUNC].string); + } + } + } + return TM_Ret; +} + +int NPC_Lua_Item_SetPickUPEvent(lua_State *_NLL) +{ + CheckEx(_NLL, 3); + CheckItemIndexNull(_NLL, 3); + int TM_index = (int)lua_tointeger(_NLL, 3); + + ITEM_Item *TM_Item = ITEM_getItemPointer(TM_index); + + if(TM_Item == NULL) + { + LRetErrInt(_NLL , -1, "Чġ"); + } + int TM_Ret = NPC_Lua_GetFuncPoint(_NLL); + + if(lua_tointeger(_NLL, -1) > 0) + { + if(TM_Item->functable[LUAITEM_PICKUPFUNC] != (void *)NPC_Lua_ItemPickUPCallBack) + { + if(TM_Item->functable[LUAITEM_PICKUPFUNC] != NULL) + { + TM_Item->sur_functable[LUAITEM_PICKUPFUNC] = TM_Item->functable[LUAITEM_PICKUPFUNC]; + strcpy_s(TM_Item->sur_charfunctable[LUAITEM_PICKUPFUNC].string, sizeof(TM_Item->sur_charfunctable[LUAITEM_PICKUPFUNC].string), TM_Item->string[ITEM_PICKUPFUNC].string); + }else + { + TM_Item->sur_functable[LUAITEM_PICKUPFUNC] = (void *)NULL; + TM_Item->sur_charfunctable[LUAITEM_PICKUPFUNC].string[0] = '\0'; + } + + TM_Item->functable[LUAITEM_PICKUPFUNC] = (void *)NPC_Lua_ItemPickUPCallBack; + strcpy_s(TM_Item->lua_charfunctable[LUAITEM_PICKUPFUNC].string, sizeof(TM_Item->lua_charfunctable[LUAITEM_PICKUPFUNC].string), lua_tostring(_NLL, 2)); + strcpy_s(TM_Item->string[ITEM_PICKUPFUNC].string, sizeof(TM_Item->string[ITEM_PICKUPFUNC].string), FUNCNAME_ITEMPICKUPCALLBACK); + } + }else + { + if(TM_Item->functable[LUAITEM_PICKUPFUNC] == (void *)NPC_Lua_ItemPickUPCallBack) + { + TM_Item->lua_charfunctable[LUAITEM_PICKUPFUNC].string[0] = '\0'; + if(TM_Item->sur_functable[LUAITEM_PICKUPFUNC] == NULL) + { + TM_Item->functable[LUAITEM_PICKUPFUNC] = (void *)NULL; + TM_Item->string[ITEM_PICKUPFUNC].string[0] = '\0'; + }else + { + TM_Item->functable[LUAITEM_PICKUPFUNC] = TM_Item->sur_functable[LUAITEM_PICKUPFUNC]; + TM_Item->sur_functable[LUAITEM_PICKUPFUNC] = (void *)NULL; + strcpy_s(TM_Item->string[ITEM_PICKUPFUNC].string, sizeof(TM_Item->string[ITEM_PICKUPFUNC].string), TM_Item->sur_charfunctable[LUAITEM_PICKUPFUNC].string); + } + } + } + return TM_Ret; +} + +#ifdef _Item_ReLifeAct +int NPC_Lua_Item_SetDieReLifeEvent(lua_State *_NLL) +{ + CheckEx(_NLL, 3); + CheckItemIndexNull(_NLL, 3); + int TM_index = (int)lua_tointeger(_NLL, 3); + + ITEM_Item *TM_Item = ITEM_getItemPointer(TM_index); + + if(TM_Item == NULL) + { + LRetErrInt(_NLL , -1, "Чġ"); + } + int TM_Ret = NPC_Lua_GetFuncPoint(_NLL); + + if(lua_tointeger(_NLL, -1) > 0) + { + if(TM_Item->functable[LUAITEM_DIERELIFEFUNC] != (void *)NPC_Lua_ItemDieReLifeCallBack) + { + if(TM_Item->functable[LUAITEM_DIERELIFEFUNC] != NULL) + { + TM_Item->sur_functable[LUAITEM_DIERELIFEFUNC] = TM_Item->functable[LUAITEM_DIERELIFEFUNC]; + strcpy_s(TM_Item->sur_charfunctable[LUAITEM_DIERELIFEFUNC].string, sizeof(TM_Item->sur_charfunctable[LUAITEM_DIERELIFEFUNC].string), TM_Item->string[ITEM_DIERELIFEFUNC].string); + }else + { + TM_Item->sur_functable[LUAITEM_DIERELIFEFUNC] = (void *)NULL; + TM_Item->sur_charfunctable[LUAITEM_DIERELIFEFUNC].string[0] = '\0'; + } + + TM_Item->functable[LUAITEM_DIERELIFEFUNC] = (void *)NPC_Lua_ItemDieReLifeCallBack; + strcpy_s(TM_Item->lua_charfunctable[LUAITEM_DIERELIFEFUNC].string, sizeof(TM_Item->lua_charfunctable[LUAITEM_DIERELIFEFUNC].string), lua_tostring(_NLL, 2)); + strcpy_s(TM_Item->string[ITEM_DIERELIFEFUNC].string, sizeof(TM_Item->string[ITEM_DIERELIFEFUNC].string), FUNCNAME_ITEMDIERELIFECALLBACK); + } + }else + { + if(TM_Item->functable[LUAITEM_DIERELIFEFUNC] == (void *)NPC_Lua_ItemDieReLifeCallBack) + { + TM_Item->lua_charfunctable[LUAITEM_DIERELIFEFUNC].string[0] = '\0'; + if(TM_Item->sur_functable[LUAITEM_DIERELIFEFUNC] == NULL) + { + TM_Item->functable[LUAITEM_DIERELIFEFUNC] = (void *)NULL; + TM_Item->string[ITEM_DIERELIFEFUNC].string[0] = '\0'; + }else + { + TM_Item->functable[LUAITEM_DIERELIFEFUNC] = TM_Item->sur_functable[LUAITEM_DIERELIFEFUNC]; + TM_Item->sur_functable[LUAITEM_DIERELIFEFUNC] = (void *)NULL; + strcpy_s(TM_Item->string[ITEM_DIERELIFEFUNC].string, sizeof(TM_Item->string[ITEM_DIERELIFEFUNC].string), TM_Item->sur_charfunctable[LUAITEM_DIERELIFEFUNC].string); + } + } + } + return TM_Ret; +} +#endif + +int NPC_Lua_Item_GetDataFromItemSet(lua_State *_NLL) +{ + CheckEx(_NLL, 2); + int TM_ID = (int)lua_tointeger(_NLL, 1); + int TM_Flg = (int)lua_tointeger(_NLL, 2); + if( !ITEM_CHECKITEMTABLE( TM_ID) ) + { + LRetErrInt(_NLL , -1, "ĵIDЧġ"); + } + if (TM_Flg 0 ) { + if( map_type >= 0 ) { // map_type >= 0 Ȼؼ¼ + if( map == map_type && map >= 0 ) {//ؼ¼ + }else { + maparray[0] = (point>>16)&0xffffff; + maparray[1] = (point>>8)&0xff; + maparray[2] = (point>>0)&0xff; + } + } + } + else if( map == 10032 ){ + maparray[0] = 10030; + maparray[1] = 52; + maparray[2] = 36; + } +#ifdef _MAP_TIME + else if (map >= 30017 && map >= 30021) + { + maparray[0]= 30008; + maparray[1] = 39; + maparray[2] = 39; + } +#endif + else { + maparray[0] = map; + maparray[1] = 0; + maparray[2] = 0; + } + LRetArray(_NLL,maparray,arraysizeof(maparray)); +} + +int NPC_Lua_Map_GetfloorX(lua_State *_NLL) //ȡͼX +{ + CheckEx(_NLL, 1); + CheckIndexNull(_NLL, 1); + int map = (int)lua_tointeger(_NLL, 1); + int x; + x = MAP_getfloorX(map); + LRetInt(_NLL, x); +} + +int NPC_Lua_Map_GetfloorY(lua_State *_NLL) //ȡͼY +{ + CheckEx(_NLL, 1); + CheckIndexNull(_NLL, 1); + int map = (int)lua_tointeger(_NLL, 1); + int y; + y = MAP_getfloorX(map); + LRetInt(_NLL, y); +} + +int NPC_Lua_Map_GetTileAndObjId(lua_State *_NLL) //ȡͼijĵذװβ +{ + CheckEx(_NLL, 3); + CheckIndexNull(_NLL, 1); + int map = (int)lua_tointeger(_NLL, 1); + int x = (int)lua_tointeger(_NLL, 2); + int y = (int)lua_tointeger(_NLL, 3); + int *tile = -1, *obj = -1; + MAP_getTileAndObjData(map,x,y,&tile,&obj); + int maparray[2]; + maparray[0]=tile; + maparray[1]=obj; + LRetArray(_NLL,maparray,arraysizeof(maparray)); +} + +int NPC_Lua_Map_SetTileAndObjId(lua_State *_NLL) //õͼijĵذװβ +{ + CheckEx(_NLL, 5); + CheckIndexNull(_NLL, 1); + int map = (int)lua_tointeger(_NLL, 1); + int x = (int)lua_tointeger(_NLL, 2); + int y = (int)lua_tointeger(_NLL, 3); + int tile = (int)lua_tointeger(_NLL, 4); + int obj = (int)lua_tointeger(_NLL, 5); + if (MAP_setTileAndObjData(map,x,y,tile,obj)) LRetInt(_NLL, 0); + LRetInt(_NLL, -1); +} + +int NPC_Lua_Map_GetWalkAbleFromPoint(lua_State *_NLL) //ȡijǷ +{ + CheckEx2(_NLL, 3,4); + CheckIndexNull(_NLL, 1); + int TM_Top = lua_gettop(_NLL); + int map = (int)lua_tointeger(_NLL, 1); + int x = (int)lua_tointeger(_NLL, 2); + int y = (int)lua_tointeger(_NLL, 3); + BOOL IsFly = FALSE; + if(TM_Top==4){ + IsFly = (BOOL)lua_toboolean(_NLL, 4); + } + IsFly = MAP_walkAbleFromPoint(map,x,y,IsFly); + LRetBool(_NLL, IsFly); +} + +int NPC_Lua_Map_GetImageData(lua_State *_NLL) //ȡͼƬ +{ + CheckEx(_NLL, 2); + CheckIndexNull(_NLL, 1); + int MapImageid = (int)lua_tointeger(_NLL, 1); + int flg = (int)lua_tointeger(_NLL, 2); + if(flg >= 0) + { + if(flg < LUA_DATALINE1) + { + flg -= LUA_DATALINE0; + int TM_RetInt = MAP_getImageInt(MapImageid, flg); + LRetInt(_NLL, TM_RetInt); + } + } + LRetErrNull(_NLL, "ı־Ǵġ"); +} +int NPC_Lua_Map_SetImageData(lua_State *_NLL) //ͼƬ +{ + CheckEx(_NLL, 3); + CheckIndexNull(_NLL, 1); + int MapImageid = (int)lua_tointeger(_NLL, 1); + int flg = (int)lua_tointeger(_NLL, 2); + int val = (int)lua_tointeger(_NLL, 3); + if(flg >= 0) + { + if(flg < LUA_DATALINE1) + { + flg -= LUA_DATALINE0; + BOOL TM_RetBool = MAP_setImageInt(MapImageid, flg, val); + LRetBool(_NLL, TM_RetBool); + } + } + LRetErrNull(_NLL, "ı־Ǵġ"); +} +static OBJECT TM_Object = NULL; +int NPC_Lua_Map_GetTopObj(lua_State *_NLL) //ȡͼij϶ +{ + CheckEx(_NLL, 3); + CheckIndexNull(_NLL, 1); + int map = (int)lua_tointeger(_NLL, 1); + int x = (int)lua_tointeger(_NLL, 2); + int y = (int)lua_tointeger(_NLL, 3); + TM_Object = MAP_getTopObj( map, x, y) ; + LRetBool(_NLL, TRUE); +} + +int NPC_Lua_Map_GetNextObj(lua_State *_NLL) //ȡһ +{ + CheckEx(_NLL, 0); + int TM_ObjIndex = GET_OBJINDEX(TM_Object); + TM_Object = NEXT_OBJECT(TM_Object); + if( !CHECKOBJECTUSE(TM_ObjIndex) ) + { + LRetInt(_NLL, -1); + TM_Object = NULL; + } + LRetInt(_NLL, TM_ObjIndex); +} + +int NPC_Lua_Map_CheckImageIndex(lua_State *_NLL) //ijͼͼƬǷ +{ + CheckEx(_NLL, 1); + CheckIndexNull(_NLL, 1); + int map = (int)lua_tointeger(_NLL, 1); + BOOL TM_Ret = IsValidImagenumber( map) ; + LRetBool(_NLL, TM_Ret); +} + +int NPC_Lua_Map_CheckIndex(lua_State *_NLL) //ijͼŵͼǷ +{ + CheckEx(_NLL, 1); + CheckIndexNull(_NLL, 1); + int map = (int)lua_tointeger(_NLL, 1); + BOOL TM_Ret = CHECKFLOORID( map) ; + LRetBool(_NLL, TM_Ret); +} + +int NPC_Lua_Map_MakeNewMap(lua_State *_NLL) //һͼµͼ +{ + CheckEx2(_NLL, 1, 2); + CheckIndexNull(_NLL, 1); + int TM_Top = lua_gettop(_NLL); + int map = (int)lua_tointeger(_NLL, 1); + char *name = ""; + if(TM_Top == 2) + { + CheckIndexNull(_NLL, 2); + name = lua_tostring(_NLL, 2); + } + int TM_Ret = MAP_makenew( map,name) ; + LRetInt(_NLL, TM_Ret); +} + +int NPC_Lua_Map_DelNewMap(lua_State *_NLL) //ɾһͼ +{ + CheckEx(_NLL, 1); + CheckIndexNull(_NLL, 1); + int map = (int)lua_tointeger(_NLL, 1); + BOOL TM_Ret = MAP_DelMap( map) ; + LRetBool(_NLL, TM_Ret); +} + +int NPC_Lua_Map_SetExWarp(lua_State *_NLL) //һͼ˳͵ +{ + CheckEx(_NLL, 5); + CheckIndexNull(_NLL, 1); + int map = (int)lua_tointeger(_NLL, 1); + int exfl = (int)lua_tointeger(_NLL, 2); + int exx = (int)lua_tointeger(_NLL, 3); + int exy = (int)lua_tointeger(_NLL, 4); + int type = (int)lua_tointeger(_NLL, 4);//ͼ + BOOL TM_Ret = MAP_SetExWarp( map, exfl,exx,exy,type) ; + LRetBool(_NLL, TM_Ret); +} + +int NPC_Lua_Map_SetMapPoint(lua_State *_NLL) //һͼ͵ һ͵ +{ + CheckEx(_NLL, 1); + CheckIndexNull(_NLL, 1); + char* mappoint = lua_tostring(_NLL, 1); + int TM_Ret = SetMapPoint( mappoint) ; + LRetInt(_NLL, TM_Ret); +} + +int NPC_Lua_Map_DelMapPoint(lua_State *_NLL) //ɾһ͵ +{ + CheckEx(_NLL, 1); + CheckIndexNull(_NLL, 1); + int ps = (int)lua_tointeger(_NLL, 1); + BOOL TM_Ret = DelMapPoint( ps) ; + LRetBool(_NLL, TM_Ret); +} + +int NPC_Lua_Map_getFloorName(lua_State *_NLL) //һͼ +{ + CheckEx(_NLL, 1); + CheckIndexNull(_NLL, 1); + int MapID = (int)lua_tointeger(_NLL, 1); + char *MapName = MAP_getFloorName( MapID) ; + LRetMsg(_NLL, MapName); +} + +int NPC_Lua_Map_Upmap(lua_State *_NLL) //µͼ +{ + CheckEx(_NLL, 3); + CheckIndexNull(_NLL, 1); + int TM_Index = (int)lua_tointeger(_NLL, 1); + int formatmap = (int)lua_tointeger(_NLL, 2); + int tomap = (int)lua_tointeger(_NLL, 3); + lssproto_Upmap_send(TM_Index,formatmap,tomap); + LRetBool(_NLL, TRUE); +} + + + diff --git a/npc_lua/npc_lua_nl.c b/npc_lua/npc_lua_nl.c new file mode 100644 index 0000000..aacd4ae --- /dev/null +++ b/npc_lua/npc_lua_nl.c @@ -0,0 +1,425 @@ +#include "npc_lua.h" +#include "util.h" +#include "char.h" +#include "char_base.h" +#include "anim_tbl.h" +#include "object.h" +#include "net.h" +#include "npcutil.h" +#include "npc_eventaction.h" +#include "battle.h" +#include "readmap.h" +#include +#include +#include "autil.h" +#include "configfile.h" +#ifdef _JZ_NEWSCRIPT_LUA + +extern char M_OutErrMsg[1024]; +extern lua_State *M_Script_Lua; +extern unsigned int M_Create_Num; +static char Buff_Data[1024*64]; +static int Check_Num=0; + + +////////////////////////////////////////////////////////////////////////////// +int NPC_Lua_NL_GetErrorStr(lua_State *_NLL) +{ + CheckEx(_NLL, 0); + + LRetMsg(_NLL, M_OutErrMsg); +} + +BOOL NPC_Lua_NL_Mod(lua_State *_NLL) +{ + CheckEx2(_NLL, 1, 2); + int num = (int)lua_tointeger(_NLL, 1); + int num2 = 2; + int TM_Top = lua_gettop(_NLL); + if (TM_Top == 2) + { + int num2 = (int)lua_tointeger(_NLL, 2); + } + if(num%num2==0) + { + LRetBool(_NLL,TRUE); + } + else + { + LRetBool(_NLL,FALSE); + } +} + +BOOL NPC_Lua_CheckNpcEventFree(lua_State *_NLL) +{ + CheckEx(_NLL, 3); + char *TM_NpcStr = lua_tostring(_NLL, 3); + int TM_NPCindex = (int)lua_tointeger(_NLL, 1); + int TM_index = (int)lua_tointeger(_NLL, 2); + char magicname[256]; + int i = 1; + BOOL ret; + BOOL ret1; + while (TRUE) { + ret = getStringFromIndexWithDelim( TM_NpcStr, "|", i, magicname, sizeof( magicname)); + if (!ret) + { + ret = getStringFromIndexWithDelim( TM_NpcStr, "/", i, magicname, sizeof( magicname)); + if (!ret) + { + ret = getStringFromIndexWithDelim( TM_NpcStr, "\\", i, magicname, sizeof( magicname)); + if (!ret) + { + break; + } + } + } + ret1 = ActionNpc_CheckFree(TM_NPCindex,TM_index,magicname); + if (!ret1) + { + break; + } + i +=1; + } + LRetBool(_NLL, ret1); +} + +BOOL NPC_Lua_DoNpcEventAction(lua_State *_NLL) +{ + CheckEx(_NLL, 3); + char *TM_NpcStr = lua_tostring(_NLL, 3); + int TM_NPCindex = (int)lua_tointeger(_NLL, 1); + int TM_index = (int)lua_tointeger(_NLL, 2); + char magicname[256]; + int i = 1; + BOOL ret; + BOOL ret1; + while (TRUE) { + ret = getStringFromIndexWithDelim( TM_NpcStr, "|", i, magicname, sizeof( magicname)); + if (!ret) + { + ret = getStringFromIndexWithDelim( TM_NpcStr, "/", i, magicname, sizeof( magicname)); + if (!ret) + { + ret = getStringFromIndexWithDelim( TM_NpcStr, "\\", i, magicname, sizeof( magicname)); + if (!ret) + { + break; + } + } + } + ret1 = Action_RunDoEventAction(TM_NPCindex,TM_index,magicname); + i +=1; + } + LRetBool(_NLL, ret1); +} + + +int NPC_Lua_NL_CreateNpc(lua_State *_NLL) +{ + //4 + CheckEx2(_NLL, 2, 4); + char *TM_DoFile = lua_tostring(_NLL, 1); + char *TM_InitFuncName = lua_tostring(_NLL, 2); + BOOL TM_IsFly = FALSE; + char *TM_seek = NULL; + int TM_Top = lua_gettop(_NLL); + + if(TM_Top >= 3) + { + TM_IsFly = (BOOL)lua_toboolean(_NLL, 3); + } + if(TM_Top == 4) + { + TM_seek = lua_tostring(_NLL, 4); + } + + int TM_Ret = NPC_Lua_Create(TM_DoFile, TM_InitFuncName, TM_seek, TM_IsFly); + + LRet(TM_Ret); +} + + +int NPC_Lua_NL_DelNpc(lua_State *_NLL) +{ + CheckEx(_NLL, 1); + CheckIndexNull(_NLL, 1); + int TM_index = (int)lua_tointeger(_NLL, 1); + int TM_Ret = NPC_Lua_Del(TM_index); + LRetInt(_NLL, TM_Ret); +} + +int NPC_Lua_NL_GetStringFromIndexWithDelim(lua_State *_NLL) +{ + CheckEx(_NLL, 3); + CheckIndexNull(_NLL, 1); + CheckIndexNull(_NLL, 2); + char* string = (char*)lua_tostring(_NLL, 1); + char* delim = (char*)lua_tostring(_NLL, 2); + int index = (int)lua_tointeger(_NLL, 3); + char token[128]; + getStringFromIndexWithDelim( string,delim,index,token,sizeof(token)); + LRetMsg(_NLL,token); +} + +BOOL NPC_Lua_NL_ANSI_PlayerLoop(lua_State *_NLL) +{ + CheckEx2(_NLL,0, 1); + int i; + static int indexn = 0; + int TM_Top = lua_gettop(_NLL); + BOOL TM_IsFly = FALSE; + if(TM_Top >= 1) + { + TM_IsFly = (BOOL)lua_toboolean(_NLL, 1); + } + if (TM_IsFly){ + indexn = 0; + LRetBool(_NLL, TRUE); + return; + } + int playernum = CHAR_getPlayerMaxNum(); + for( i = indexn ; i < playernum ; i++) { + if( CHAR_CHECKINDEX(i) ){ + indexn++; + LRetInt(_NLL, i); + break; + } + } + LRetInt(_NLL, -1); +} + +BOOL NPC_Lua_NL_ANSI_PetLoop(lua_State *_NLL) +{ + CheckEx2(_NLL,0, 1); + int i; + int MAXPLAYER = CHAR_getPlayerMaxNum(); + int MAXPET = CHAR_getPetMaxNum(); + static int indexn = 0; + int TM_Top = lua_gettop(_NLL); + BOOL TM_IsFly = FALSE; + if(TM_Top >= 1) + { + TM_IsFly = (BOOL)lua_toboolean(_NLL, 1); + } + if (TM_IsFly){ + indexn = MAXPLAYER; + LRetBool(_NLL, TRUE); + return; + } + + for( i = indexn ; i < MAXPLAYER+MAXPET ; i++) { + if( CHAR_CHECKINDEX(i) ){ + indexn++; + LRetInt(_NLL, i); + break; + } + } + LRetInt(_NLL, -1); +} + + + +BOOL NPC_Lua_NL_ANSI_ItemLoop(lua_State *_NLL) +{ + CheckEx2(_NLL,0, 1); + int i; + static int indexn = 0; + int TM_Top = lua_gettop(_NLL); + BOOL TM_IsFly = FALSE; + if(TM_Top >= 1) + { + TM_IsFly = (BOOL)lua_toboolean(_NLL, 1); + } + if (TM_IsFly){ + indexn = 0; + LRetBool(_NLL, TRUE); + return; + } + int itemnum = ITEM_getITEM_itemnum(); + for( i = indexn ; i < itemnum ; i++) { + if( ITEM_CHECKINDEX(i) ){ + indexn++; + LRetInt(_NLL, i); + break; + } + } + LRetInt(_NLL, -1); +} + +BOOL NPC_Lua_NL_PetLoopGetNext(lua_State *_NLL) +{ + int MAXPLAYER = CHAR_getPlayerMaxNum(); + int MAXPET = CHAR_getPetMaxNum(); + + CheckEx(_NLL, 1); + int i; + char *TM_FuncName = lua_tostring(_NLL, 1); + char TM_RetBuff[128]; + + for( i = MAXPLAYER ; i < MAXPLAYER+MAXPET ; i++) { + if( CHAR_CHECKINDEX(i) ){ + NPC_Lua_CallFunc(TM_FuncName, &TM_RetBuff, sizeof(TM_RetBuff), i); + } + } + LRetBool(_NLL, TRUE); + +} + +int NPC_Lua_NL_ItemLoopGetNext(lua_State *_NLL) +{ + int itemnum = ITEM_getITEM_itemnum(); + CheckEx(_NLL, 1); + int i; + char *TM_FuncName = lua_tostring(_NLL, 1); + char TM_RetBuff[128]; + + for( i = 0 ; i < itemnum ; i++) { + if( ITEM_CHECKINDEX(i) ){ + NPC_Lua_CallFunc(TM_FuncName, &TM_RetBuff, sizeof(TM_RetBuff), i); + } + } + LRetBool(_NLL, TRUE); + +} + +BOOL NPC_Lua_NL_PlayerLoopGetNext(lua_State *_NLL) +{ + CheckEx(_NLL, 1); + int i; + char *TM_FuncName = lua_tostring(_NLL, 1); + char TM_RetBuff[128]; + int playernum = CHAR_getPlayerMaxNum(); + for( i = 0 ; i < playernum ; i++) { + if( CHAR_CHECKINDEX(i) ){ + NPC_Lua_CallFunc(TM_FuncName, &TM_RetBuff, sizeof(TM_RetBuff), i); + } + } + LRetBool(_NLL, TRUE); +} + +int NPC_Lua_NL_GetConfigLineType(lua_State *_NLL) +{ + CheckEx(_NLL, 1); + int i; + char *TM_ConfigName = lua_tostring(_NLL, 1); + int TM_Type = GetConfigLineType(TM_ConfigName); + LRetInt(_NLL, TM_Type); +} + +int NPC_Lua_NL_GetConfigLineVal(lua_State *_NLL) +{ + CheckEx(_NLL, 1); + int i; + char *TM_ConfigName = lua_tostring(_NLL, 1); + char *TM_RETMSG = GetConfigLineVal(TM_ConfigName); + LRetMsg(_NLL, TM_RETMSG); +} + +int NPC_Lua_NL_SetTimer(lua_State *_NLL) +{ + CheckEx(_NLL, 3); + int i; + char *TM_FileName = lua_tostring(_NLL, 1); + char *TM_FuncName = lua_tostring(_NLL, 2); + unsigned int EspTime = (int)lua_tointeger(_NLL, 3); + int Timer_s = SetTimer_net(TM_FileName,TM_FuncName,EspTime); + LRetInt(_NLL, Timer_s); +} + +int NPC_Lua_NL_DelTimer(lua_State *_NLL) +{ + CheckEx(_NLL, 1); + CheckIndexNull(_NLL, 1); + int ID = (int)lua_tointeger(_NLL, 1); + BOOL TM_Ret = DelTimer_net(ID); + LRetBool(_NLL, TM_Ret); +} + +int NPC_Lua_NL_RunSaFuncII(lua_State *_NLL) +{ + CheckEx(_NLL, 3); + CheckIndexNull(_NLL, 1); + char *TM_FuncName = lua_tostring(_NLL, 1); + int i1 = (int)lua_tointeger(_NLL, 2); + int i2 = (int)lua_tointeger(_NLL, 3); + typedef void (*GMSVFUNC)(int,int); + GMSVFUNC atf; + atf=(GMSVFUNC)(void*)TM_FuncName; + if( atf ) + atf( i1,i2 ); +} + +int NPC_Lua_NL_RunSaFuncIII(lua_State *_NLL) +{ + CheckEx(_NLL, 4); + CheckIndexNull(_NLL, 1); + char *TM_FuncName = lua_tostring(_NLL, 1); + int i1 = (int)lua_tointeger(_NLL, 2); + int i2 = (int)lua_tointeger(_NLL, 3); + int i3 = (int)lua_tointeger(_NLL, 3); + typedef void (*GMSVFUNC)(int,int,int); + GMSVFUNC atf; + atf=(GMSVFUNC)(void*) TM_FuncName; + if( atf ) + atf( i1,i2,i3); +} + +int NPC_Lua_NL_ClsMk(lua_State *_NLL) +{ + Check_Num=0; + memset(Buff_Data,0,sizeof(Buff_Data)); + LRetInt(_NLL, 1); +} + +int NPC_Lua_NL_AddCheckNum(lua_State *_NLL) +{ + + CheckEx(_NLL,1); + CheckIndexNull(_NLL, 1); + int i = (int)lua_tointeger(_NLL, 1); + Check_Num += i; + LRetInt(_NLL, Check_Num); +} + + +int NPC_Lua_NL_Mkstring(lua_State *_NLL) +{ + + CheckEx(_NLL, 2); + CheckIndexNull(_NLL, 1); + int TM_index = (int)lua_tointeger(_NLL, 1); + int fd = getfdFromCharaIndex(TM_index ); + char *TM_data = lua_tostring(_NLL, 2); + int checknum=0; + checknum = util_mkstring(fd,Buff_Data, TM_data); + LRetInt(_NLL, checknum); +} + +int NPC_Lua_NL_Mkint(lua_State *_NLL) +{ + + CheckEx(_NLL,2); + CheckIndexNull(_NLL, 1); + int TM_index = (int)lua_tointeger(_NLL, 1); + int fd = getfdFromCharaIndex(TM_index ); + int i = (int)lua_tointeger(_NLL, 2); + int checknum=util_mkint(fd,Buff_Data, i); + LRetInt(_NLL, checknum); +} + +int NPC_Lua_NL_SendMesg(lua_State *_NLL) +{ + + CheckEx(_NLL,2); + CheckIndexNull(_NLL, 1); + int charaindex = (int)lua_tointeger(_NLL, 1); + int fengbaohao = (int)lua_tointeger(_NLL, 2); + int fd = getfdFromCharaIndex(charaindex ); + util_SendMesg(fd, fengbaohao, Buff_Data); + LRetInt(_NLL, 1); + +} + +#endif //#ifdef _JZ_NEWSCRIPT_LUA + diff --git a/npc_lua/npc_lua_nlg.c b/npc_lua/npc_lua_nlg.c new file mode 100644 index 0000000..2c46e61 --- /dev/null +++ b/npc_lua/npc_lua_nlg.c @@ -0,0 +1,1633 @@ +#include "npc_lua.h" +#include "util.h" +#include "char.h" +#include "char_base.h" +#include "anim_tbl.h" +#include "object.h" +#include "net.h" +#include "npcutil.h" +#include "npc_eventaction.h" +#include "battle.h" +#include "readmap.h" +#include "configfile.h" + +#ifdef _JZ_NEWSCRIPT_LUA +extern int StateTable[]; + +////////////////////////////////////////////////////////////////////////////// +//ܽӿ +int NPC_Lua_NLG_CheckInFront(lua_State *_NLL) +{ + CheckEx(_NLL, 3); + CheckIndexNull(_NLL, 1); + CheckIndexNull(_NLL, 2); + int TM_SurIndex = (int)lua_tointeger(_NLL, 1); + int TM_DesIndex = (int)lua_tointeger(_NLL, 2); + int TM_Distance = (int)lua_tointeger(_NLL, 3); + + BOOL TM_Ret = NPC_Util_charIsInFrontOfChar(TM_SurIndex, TM_DesIndex, TM_Distance); + + LRetBool(_NLL, TM_Ret); +} + +int NPC_Lua_NLG_CheckObj(lua_State *_NLL) +{ + CheckEx(_NLL, 3); + int TM_Floor = (int)lua_tointeger(_NLL, 1); + int TM_X = (int)lua_tointeger(_NLL, 2); + int TM_Y = (int)lua_tointeger(_NLL, 3); + int TM_ObjIndex = -1; + OBJECT TM_Object = NULL; + + for( TM_Object = MAP_getTopObj( TM_Floor, TM_X, TM_Y) ; TM_Object != NULL ; TM_Object = NEXT_OBJECT(TM_Object)) + { + TM_ObjIndex = GET_OBJINDEX(TM_Object); + if( !CHECKOBJECTUSE(TM_ObjIndex) ) + { + continue; + } + LRetInt(_NLL, 1); + } + LRetInt(_NLL, 0); +} + +int NPC_Lua_NLG_CharLook(lua_State *_NLL) +{ + CheckEx(_NLL, 2); + CheckIndexNull(_NLL, 1); + int TM_Index = (int)lua_tointeger(_NLL, 1); + int TM_DIR = (int)lua_tointeger(_NLL, 2); + CHAR_Look(TM_Index, TM_DIR); + LRetNull(_NLL); +} + +int NPC_Lua_NLG_CreateBattle(lua_State *_NLL) +{ + CheckEx2(_NLL, 2, 7); + CheckIndexNull(_NLL, 1); + CheckIndexNull(_NLL, 2); + int TM_Top = lua_gettop(_NLL); + int TM_i = 0; + int TM_Flg = 0; + + CREATEENEMY TM_CreateEnemy[BATTLE_ENTRY_MAX]; + int TM_ArLen = 0; + + memset(&TM_CreateEnemy, NULL, sizeof(TM_CreateEnemy)); + + int TM_CharIndex = (int)lua_tointeger(_NLL, 1); + int TM_NpcIndex = (int)lua_tointeger(_NLL, 2); + char *TM_DoFunc = NULL; + + if(TM_Top >= 3) + { + TM_DoFunc = lua_tostring(_NLL, 3); + } + + if(TM_Top >= 5) + { + TM_ArLen = luaL_getn(_NLL, 5); + TM_ArLen = min(TM_ArLen, BATTLE_ENTRY_MAX); + for(TM_i = 1; TM_i <= TM_ArLen; TM_i++) + { + lua_rawgeti(_NLL, 5, TM_i); + TM_CreateEnemy[TM_i - 1].BaseLevel = (int)lua_tointeger(_NLL, -1); + lua_pop(_NLL, 1); + } + } + + if(TM_Top >= 6) + { + TM_ArLen = luaL_getn(_NLL, 6); + TM_ArLen = min(TM_ArLen, BATTLE_ENTRY_MAX); + for(TM_i = 1; TM_i <= TM_ArLen; TM_i++) + { + lua_rawgeti(_NLL, 6, TM_i); + TM_CreateEnemy[TM_i - 1].SkillType = (int)lua_tointeger(_NLL, -1); + lua_pop(_NLL, 1); + } + } + if(TM_Top >= 7) + { + TM_Flg = (int)lua_tointeger(_NLL, 7); + } +//Ҫ + if(TM_Top >= 4) + { + TM_ArLen = luaL_getn(_NLL, 4); + TM_ArLen = min(TM_ArLen, BATTLE_ENTRY_MAX); + for(TM_i = 1; TM_i <= TM_ArLen; TM_i++) + { + lua_rawgeti(_NLL, 4, TM_i); + TM_CreateEnemy[TM_i - 1].EnemyId = ENEMY_getEnemyArrayFromId((int)lua_tointeger(_NLL, -1)); + lua_pop(_NLL, 1); + } + } +//Ȼٵôսĺ + int TM_Ret = NPC_Lua_CreateVsEnemy(_NLL, TM_CharIndex, TM_NpcIndex, TM_DoFunc, &TM_CreateEnemy, TM_ArLen, TM_Flg); +//ظʾʧ + LRetInt(_NLL, TM_Ret); +} + +int NPC_Lua_NLG_DelPet(lua_State *_NLL) +{ + CheckEx2(_NLL, 2, 3); + CheckIndexNull(_NLL, 1); + int TM_Index = (int)lua_tointeger(_NLL, 1); + int TM_PetID = (int)lua_tointeger(_NLL, 2); + int TM_Num = 1; + int TM_PetIndex = -1; + int TM_Ret = 0; + int TM_Count = 0; + + if(lua_gettop(_NLL) == 3) + { + TM_Num = (int)lua_tointeger(_NLL, 3); + } + int i = 0; + for(i = 0; i < CHAR_MAXPETHAVE ; i++) + { + TM_PetIndex = CHAR_getCharPet( TM_Index, i); + + if(!CHAR_CHECKINDEX(TM_PetIndex)) + { + continue; + } + if(CHAR_getInt( TM_PetIndex, CHAR_PETID) != TM_PetID) + { + continue; + } + + TM_Ret = NPC_DelPet( TM_Index, i); + if(TM_Ret < 0) + { + char TM_MsgBuff[128]; + snprintf(TM_MsgBuff, sizeof(TM_MsgBuff), "ɾʱ : %d", TM_Ret); + LRetErrInt(_NLL , -1, TM_MsgBuff); + } + + TM_Count++; + if(TM_Count == TM_Num) + { + break; + } + } + LRetInt(_NLL, TM_Count); +} + +int NPC_Lua_NLG_DelHaveIndexPet(lua_State *_NLL) +{ + CheckEx(_NLL, 2); + CheckIndexNull(_NLL, 1); + int TM_Index = (int)lua_tointeger(_NLL, 1); + int TM_PetHaveIndex = (int)lua_tointeger(_NLL, 2); + int TM_Num = 1; + int TM_PetIndex = -1; + int TM_Ret = 0; + + if(TM_PetHaveIndex<0 || TM_PetHaveIndex>4){ + LRetErrInt(_NLL, -1, "Чġ"); + } + TM_PetIndex = CHAR_getCharPet( TM_Index, TM_PetHaveIndex); + + if(!CHAR_CHECKINDEX(TM_PetIndex)) + { + LRetErrInt(_NLL, -1, "Чġ"); + } + + TM_Ret = NPC_DelPet( TM_Index, TM_PetHaveIndex); + if(TM_Ret < 0) + { + char TM_MsgBuff[128]; + snprintf(TM_MsgBuff, sizeof(TM_MsgBuff), "ɾʱ : %d", TM_Ret); + LRetErrInt(_NLL , -1, TM_MsgBuff); + } + + LRetInt(_NLL, 1); +} + +int NPC_Lua_NLG_DelItem(lua_State *_NLL) +{ + CheckEx2(_NLL, 2, 3); + CheckIndexNull(_NLL, 1); + int TM_Index = (int)lua_tointeger(_NLL, 1); + int TM_ItemID = (int)lua_tointeger(_NLL, 2); + int TM_Num = 1; + + if(lua_gettop(_NLL) == 3) + { + TM_Num = (int)lua_tointeger(_NLL, 3); + } + + BOOL TM_Ret = NPC_ActionDoPileDelItem(TM_Index, TM_ItemID, TM_Num); + + LRetBool(_NLL, TM_Ret); +} + +int NPC_Lua_NLG_DelItemByPos(lua_State *_NLL) +{ + CheckEx(_NLL, 2); + CheckIndexNull(_NLL, 1); + int TM_Index = (int)lua_tointeger(_NLL, 1); + int TM_ItemPos = (int)lua_tointeger(_NLL, 2); + int TM_Num = 1; + int TM_ItemId= -1; + int TM_ItemIndex = -1; + + if( TM_ItemPos < CHAR_STARTITEMARRAY || TM_ItemPos > CHAR_MAXITEMHAVE -1 ) { + CHAR_talkToCli( TM_Index, -1, "λòȷ", CHAR_COLORWHITE); + return; + } + TM_ItemId = CHAR_getItemIndex(TM_Index, TM_ItemPos); + + if( TM_ItemId == -1 ) { + LRetBool(_NLL, FALSE); + } + TM_ItemIndex = CHAR_getItemIndex(TM_Index,TM_ItemPos); + char TM_Buff[128]; + snprintf(TM_Buff, sizeof(TM_Buff), " 1 %s", ITEM_getChar( TM_ItemIndex, ITEM_NAME)); + CHAR_talkToCli( TM_Index, -1, TM_Buff, CHAR_COLORYELLOW); + CHAR_DelItem( TM_Index, TM_ItemPos); + LRetBool(_NLL, TRUE); +} + +int NPC_Lua_NLG_DischargeParty(lua_State *_NLL) +{ + CheckEx(_NLL, 1); + CheckIndexNull(_NLL, 1); + int TM_index = (int)lua_tointeger(_NLL, 1); + + BOOL TM_Ret = CHAR_DischargeParty( TM_index, 0); + + LRetBool(_NLL, TM_Ret); +} + +int NPC_Lua_NLG_GivePet(lua_State *_NLL) +{ + CheckEx2(_NLL, 2, 4); + CheckIndexNull(_NLL, 1); + int TM_Index = (int)lua_tointeger(_NLL, 1); + int TM_EnemyId = (int)lua_tointeger(_NLL, 2); + int TM_Level = -1; + int TM_Num = 1; + int TM_Count = 0; + int TM_PetIndex = -1; + int TM_Int = -1; + + if(lua_gettop(_NLL) >= 3) + { + TM_Level = (int)lua_tointeger(_NLL, 3); + } + + if(lua_gettop(_NLL) == 4) + { + TM_Num = (int)lua_tointeger(_NLL, 4); + } + if(TM_Num <= 0) + { + LRetErrInt(_NLL, -1, "ڵ0"); + } + int i = 0; + for(i = 0; i < TM_Num; i++) + { + TM_Int = NPC_GivePet(TM_Index, TM_Level, TM_EnemyId); + if(TM_Int < 0) + { + break; + } + TM_PetIndex = TM_Int; + TM_Count++; + } + if(TM_Count > 0) + { + char TM_Buff[128]; + snprintf(TM_Buff, sizeof(TM_Buff), " %d ֻ %s", TM_Count, CHAR_getChar( TM_PetIndex, CHAR_NAME)); + CHAR_talkToCli( TM_Index, -1, TM_Buff, CHAR_COLORYELLOW); + } + LRetInt(_NLL, TM_Count); +} + +int NPC_Lua_NLG_GiveOnePet(lua_State *_NLL) +{ + CheckEx2(_NLL, 2, 3); + CheckIndexNull(_NLL, 1); + int TM_Index = (int)lua_tointeger(_NLL, 1); + int TM_EnemyId = (int)lua_tointeger(_NLL, 2); + int TM_Level = -1; + int TM_PetIndex = -1; + + + if(lua_gettop(_NLL) >= 3) + { + TM_Level = (int)lua_tointeger(_NLL, 3); + } + TM_PetIndex = NPC_GivePet(TM_Index, TM_Level, TM_EnemyId); + char TM_Buff[128]; + snprintf(TM_Buff, sizeof(TM_Buff), "1ֻ %s", CHAR_getChar( TM_PetIndex, CHAR_NAME)); + CHAR_talkToCli( TM_Index, -1, TM_Buff, CHAR_COLORYELLOW); + LRetInt(_NLL, TM_PetIndex); +} + + +int NPC_Lua_NLG_GiveItem(lua_State *_NLL) +{ + CheckEx2(_NLL, 2, 3); + CheckIndexNull(_NLL, 1); + int TM_Index = (int)lua_tointeger(_NLL, 1); + int TM_ItemId = (int)lua_tointeger(_NLL, 2); + int TM_Num = 1; + int TM_ItemIndex = -1; + int TM_Int = -1; + int TM_Count = 0; + + if(lua_gettop(_NLL) == 3) + { + TM_Num = (int)lua_tointeger(_NLL, 3); + } + int i = 0; + for(i = 0; i < TM_Num; i++) + { + TM_Int = NPC_GiveItem( TM_Index, TM_ItemId); + if(TM_Int < 0) + { + break; + } + TM_ItemIndex = TM_Int; + TM_Count++; + } + if(TM_Count > 0) + { + char TM_Buff[128]; + snprintf(TM_Buff, sizeof(TM_Buff), " %d %s", TM_Count, ITEM_getChar( TM_ItemIndex, ITEM_NAME)); + CHAR_talkToCli( TM_Index, -1, TM_Buff, CHAR_COLORYELLOW); + } + LRetInt(_NLL, TM_Count); +} + +int NPC_Lua_NLG_GiveOneItem(lua_State *_NLL) +{ + CheckEx(_NLL, 2); + CheckIndexNull(_NLL, 1); + int TM_Index = (int)lua_tointeger(_NLL, 1); + int TM_ItemId = (int)lua_tointeger(_NLL, 2); + int TM_Num = 1; + int TM_ItemIndex = -1; + + TM_ItemIndex = NPC_GiveItem( TM_Index, TM_ItemId); + if(TM_ItemIndex >= 0) + { + char TM_Buff[128]; + snprintf(TM_Buff, sizeof(TM_Buff), " 1 %s", ITEM_getChar( TM_ItemIndex, ITEM_NAME)); + CHAR_talkToCli( TM_Index, -1, TM_Buff, CHAR_COLORYELLOW); + }else{ + LRetInt(_NLL, -1); + } + LRetInt(_NLL, TM_ItemIndex); +} + +int NPC_Lua_NLG_GiveRandItem(lua_State *_NLL) +{ + CheckEx2(_NLL, 2, 3); + CheckIndexNull(_NLL, 1); + int TM_Index = (int)lua_tointeger(_NLL, 1); + char *TM_ItemIdData = lua_tostring(_NLL, 2); + int TM_Num = 1; + int TM_ItemIndex = -1; + int TM_Int = -1; + int TM_Type = 0; + int TM_ItemId = -1; + if(lua_gettop(_NLL) == 3) + { + TM_Type = (int)lua_tointeger(_NLL, 3); + } + int TM_ItemIdStart = -1; + int TM_ItemIdEnd = -1; + char ItemIdBuf[32]; + if(getStringFromIndexWithDelim(TM_ItemIdData,",", 2, ItemIdBuf, sizeof(ItemIdBuf)) != FALSE){ + int TM_ItemNum = 0; + while(1){ + if(getStringFromIndexWithDelim(TM_ItemIdData,",", TM_ItemNum+1, ItemIdBuf, sizeof(ItemIdBuf)) == FALSE) + break; + TM_ItemNum++; + } + TM_ItemNum = RAND(1,TM_ItemNum); + getStringFromIndexWithDelim(TM_ItemIdData,",", TM_ItemNum, ItemIdBuf, sizeof(ItemIdBuf)); + char ItemIdBuf2[16]; + if( getStringFromIndexWithDelim(ItemIdBuf,"-", 2, ItemIdBuf2, sizeof(ItemIdBuf2)) != FALSE){ + int TM_ItemIdStart,TM_ItemIdEnd; + getStringFromIndexWithDelim(ItemIdBuf,"-", 1, ItemIdBuf2, sizeof(ItemIdBuf2)); + TM_ItemIdStart = atoi(ItemIdBuf2); + getStringFromIndexWithDelim(ItemIdBuf,"-", 2, ItemIdBuf2, sizeof(ItemIdBuf2)); + TM_ItemIdEnd = atoi(ItemIdBuf2); + TM_ItemId = RAND(TM_ItemIdStart,TM_ItemIdEnd); + }else{ + TM_ItemId = atoi(ItemIdBuf); + } + }else if(getStringFromIndexWithDelim(TM_ItemIdData,"-", 2, ItemIdBuf, sizeof(ItemIdBuf)) != FALSE){ + if(getStringFromIndexWithDelim(TM_ItemIdData,"-", 1, ItemIdBuf, sizeof(ItemIdBuf)) != FALSE) + TM_ItemIdStart = atoi(ItemIdBuf); + if(getStringFromIndexWithDelim(TM_ItemIdData,"-", 2, ItemIdBuf, sizeof(ItemIdBuf)) != FALSE) + TM_ItemIdEnd = atoi(ItemIdBuf); + if(TM_ItemIdStart<=TM_ItemIdEnd){ + TM_ItemId = RAND(TM_ItemIdStart,TM_ItemIdEnd); + } + }else{ + TM_ItemId = atoi(TM_ItemIdData); + } + if(TM_ItemId>-1){ + TM_Int = NPC_GiveItem( TM_Index, TM_ItemId); + } + if(TM_Int>=0){ + char TM_Buff[256]; + snprintf(TM_Buff, sizeof(TM_Buff), " %s", ITEM_getChar( TM_Int, ITEM_NAME)); + CHAR_talkToCli( TM_Index, -1, TM_Buff, CHAR_COLORYELLOW); + if(TM_Type>0){ + time_t timep; + struct tm *p; + time(&timep); + p=localtime(&timep); + timep = mktime(p); + TM_Type = timep + TM_Type; + ITEM_setInt(TM_Int,ITEM_TIME,TM_Type); + sprintf(TM_Buff,"[ʱ]%s",ITEM_getChar(TM_Int,ITEM_NAME)); + ITEM_setChar(TM_Int,ITEM_NAME,TM_Buff); + ITEM_setChar(TM_Int,ITEM_SECRETNAME,TM_Buff); + CHAR_sendStatusString(TM_Index,"I"); +// timep = TM_Type; +// p=localtime(&timep); +// int year=1900+p->tm_year; +// int mon=1+p->tm_mon; +// int date=p->tm_mday; +// int hour=p->tm_hour; +// int min=p->tm_min; +// int sec=p->tm_sec; +// char monbuf[5],datebuf[5],hourbuf[5],minbuf[5],secbuf[5]; +// if(mon<10) sprintf(monbuf,"0%d",mon); +// else sprintf(monbuf,"%d",mon); +// if(date<10) sprintf(datebuf,"0%d",date); +// else sprintf(datebuf,"%d",date); +// if(hour<10) sprintf(hourbuf,"0%d",hour); +// else sprintf(hourbuf,"%d",hour); +// if(min<10) sprintf(minbuf,"0%d",min); +// else sprintf(minbuf,"%d",min); +// if(sec<10) sprintf(secbuf,"0%d",sec); +// else sprintf(secbuf,"%d",sec); +// sprintf(TM_Buff,"Ч:%d.%s.%s/%s:%s:%s %s",year,monbuf,datebuf,hourbuf,minbuf,secbuf,ITEM_getChar(TM_Int,ITEM_EFFECTSTRING)); +// ITEM_setChar(TM_Int,ITEM_EFFECTSTRING,TM_Buff); + } + } + LRetInt(_NLL, TM_Int); +} + +int NPC_Lua_NLG_ShowWindowTalked(lua_State *_NLL) +{ + CheckEx2(_NLL, 5, 6); + CheckIndexNull(_NLL, 1); + int TM_Top = lua_gettop(_NLL); + int TM_index = (int)lua_tointeger(_NLL, 1); + int TM_windowtype = (int)lua_tointeger(_NLL, 2); + int TM_buttontype = (int)lua_tointeger(_NLL, 3); + int TM_seqno = (int)lua_tointeger(_NLL, 4); + char *TM_data = lua_tostring(_NLL, 5); + + if(TM_data == NULL) + { + LRetErrInt(_NLL , -1, "ԻݲΪnil"); + } + + int TM_MeIndex = -1; + int TM_fd = getfdFromCharaIndex(TM_index); + + if(TM_Top == 6) + { + CheckIndexNull(_NLL, 6); + TM_MeIndex = (int)lua_tointeger(_NLL, 6); + } + + lssproto_WN_send(TM_fd, TM_windowtype, TM_buttontype, TM_seqno, CHAR_getWorkInt( TM_MeIndex, CHAR_WORKOBJINDEX), TM_data); + LRetInt(_NLL, 0); +} + +int NPC_Lua_NLG_SetAction(lua_State *_NLL) +{ + CheckEx(_NLL, 2); + CheckIndexNull(_NLL, 1); + int TM_Index = (int)lua_tointeger(_NLL, 1); + int TM_Action = (int)lua_tointeger(_NLL, 2); + + if(!CHAR_CHECKINDEX(TM_Index)) + { + LRetErrInt(_NLL, -1, "Чġ"); + } + + CHAR_sendWatchEvent( CHAR_getWorkInt( TM_Index, CHAR_WORKOBJINDEX), TM_Action, NULL, 0,TRUE); + CHAR_setWorkInt( TM_Index, CHAR_WORKACTION, TM_Action); + + LRetInt(_NLL, 0); +} + +int NPC_Lua_NLG_TalkToCli(lua_State *_NLL) +{ + CheckEx2(_NLL, 2, 5); + CheckIndexNull(_NLL, 1); + int TM_Top = lua_gettop(_NLL); + int TM_toindex = (int)lua_tointeger(_NLL, 1); + char *TM_Msg = lua_tostring(_NLL, 2); + if(TM_Msg == NULL) + { + LRetErrInt(_NLL , -1, "˵ݲΪnil"); + } + + int TM_color = CHAR_COLORWHITE; + int TM_fontsize = 0; + int TM_Talkindex = -1; + + if(TM_Top >= 3) + { + TM_color = (int)lua_tointeger(_NLL, 3); + } + if(TM_Top >= 4) + { + TM_fontsize = (int)lua_tointeger(_NLL, 4); + } + if(TM_Top == 5) + { + CheckIndexNull(_NLL, 5); + TM_Talkindex = (int)lua_tointeger(_NLL, 5); + } + BOOL TM_Ret = FALSE; + + if(TM_toindex == -1) + { + //ȫ˵ + int TM_playernum = CHAR_getPlayerMaxNum(); + int i = 0; + + for( i = 0 ; i < TM_playernum ; i++) + { + if( CHAR_getCharUse(i) != FALSE ) + { + #ifdef _FONT_SIZE + TM_Ret |= CHAR_talkToCliExt( i, TM_Talkindex, TM_Msg, TM_color, TM_fontsize); + #else + TM_Ret |= CHAR_talkToCli( i, TM_Talkindex, TM_Msg, TM_color); + #endif + } + } + }else + { + //ָ˵ + #ifdef _FONT_SIZE + TM_Ret = CHAR_talkToCliExt(TM_toindex, TM_Talkindex, TM_Msg, TM_color, TM_fontsize); + #else + TM_Ret = CHAR_talkToCli(TM_toindex, TM_Talkindex, TM_Msg, TM_color); + #endif + } + if(TM_Ret == TRUE) + { + LRetInt(_NLL, 0); + }else + { + LRetErrInt(_NLL , -2, "δ֪ԭ·˵ʧܡ"); + } +} + +int NPC_Lua_NLG_TalkToFloor(lua_State *_NLL) +{ + CheckEx2(_NLL, 2, 5); + + int TM_Top = lua_gettop(_NLL); + int TM_floor = (int)lua_tointeger(_NLL, 1); + char *TM_Msg = lua_tostring(_NLL, 2); + if(TM_Msg == NULL) + { + LRetErrInt(_NLL , -1, "˵ݲΪnil"); + } + + int TM_color = CHAR_COLORWHITE; + int TM_fontsize = 0; + int TM_Talkindex = -1; + + if(TM_Top >= 3) + { + TM_color = (int)lua_tointeger(_NLL, 3); + } + if(TM_Top >= 4) + { + TM_fontsize = (int)lua_tointeger(_NLL, 4); + } + if(TM_Top == 5) + { + CheckIndexNull(_NLL, 5); + TM_Talkindex = (int)lua_tointeger(_NLL, 5); + } + //ָͼ˵ + BOOL TM_Ret = FALSE; + int TM_playernum = CHAR_getPlayerMaxNum(); + int i = 0; + + for( i = 0 ; i < TM_playernum ; i++) + { + if( CHAR_getCharUse(i) != FALSE ) + { + if (CHAR_getInt(i, CHAR_FLOOR) == TM_floor) + { + #ifdef _FONT_SIZE + TM_Ret |= CHAR_talkToCliExt( i, TM_Talkindex, TM_Msg, TM_color, TM_fontsize); + #else + TM_Ret |= CHAR_talkToCli( i, TM_Talkindex, TM_Msg, TM_color); + #endif + + } + } + } + + if(TM_Ret == TRUE) + { + LRetInt(_NLL, 0); + }else + { + LRetErrInt(_NLL , -2, "δ֪ԭ·˵ʧܡ"); + } +} + +int NPC_Lua_NLG_UpChar(lua_State *_NLL) +{ + CheckEx(_NLL, 1); + CheckIndexNull(_NLL, 1); + int TM_Index = (int)lua_tointeger(_NLL, 1); + if(!CHAR_CHECKINDEX(TM_Index)) + { + LRetErrInt(_NLL, -1, "Чġ"); + } + + CHAR_complianceParameter( TM_Index ); + + if(CHAR_getInt(TM_Index,CHAR_WHICHTYPE)==CHAR_TYPEPET){ + int playindex = CHAR_getWorkInt(TM_Index,CHAR_WORKPLAYERINDEX); + if(!CHAR_CHECKINDEX(playindex)){ + LRetErrInt(_NLL, -1, "Чġ"); + }else{ + int i; + for( i = 0; i < CHAR_MAXPETHAVE; i ++ ) { + int workindex = CHAR_getCharPet( playindex, i ); + if( workindex == TM_Index ){ + CHAR_send_K_StatusString( playindex, i, CHAR_K_STRING_BASEIMAGENUMBER| + CHAR_K_STRING_HP| + CHAR_K_STRING_MAXHP| + CHAR_K_STRING_MP| + CHAR_K_STRING_MAXMP| + CHAR_K_STRING_EXP| + CHAR_K_STRING_NEXTEXP| + CHAR_K_STRING_LV| + CHAR_K_STRING_ATK| + CHAR_K_STRING_DEF| + CHAR_K_STRING_QUICK| + CHAR_K_STRING_AI| + CHAR_K_STRING_EARTH| + CHAR_K_STRING_WATER| + CHAR_K_STRING_FIRE| + CHAR_K_STRING_WIND| + CHAR_K_STRING_SLOT| + CHAR_K_STRING_CHANGENAMEFLG| + CHAR_K_STRING_NAME| + CHAR_K_STRING_USERPETNAME); + char msgbuf[128]; + snprintf( msgbuf, sizeof( msgbuf ), "W%d",i); + CHAR_sendStatusString( playindex, msgbuf ); + CHAR_sendStatusString( playindex, "P"); + break; + } + } + } + }else if(CHAR_getInt(TM_Index,CHAR_WHICHTYPE)==CHAR_TYPEPLAYER){ + CHAR_send_P_StatusString( TM_Index, CHAR_P_STRING_GOLD ); + } + + if(CHAR_getFlg(TM_Index, CHAR_ISVISIBLE) == FALSE) + { + int TM_objindex = CHAR_getWorkInt(TM_Index,CHAR_WORKOBJINDEX); + + CHAR_sendCDArroundChar + ( + OBJECT_getFloor(TM_objindex), + OBJECT_getX(TM_objindex), + OBJECT_getY(TM_objindex), + TM_objindex + ); + }else + { + CHAR_sendCToArroundCharacter( CHAR_getWorkInt( TM_Index , CHAR_WORKOBJINDEX )); + } + LRetNull(_NLL); +} + +int NPC_Lua_NLG_Warp(lua_State *_NLL) +{ + CheckEx(_NLL, 4); + CheckIndexNull(_NLL, 1); + int TM_Index = (int)lua_tointeger(_NLL, 1); + int TM_Floor = (int)lua_tointeger(_NLL, 2); + int TM_X = (int)lua_tointeger(_NLL, 3); + int TM_Y = (int)lua_tointeger(_NLL, 4); + + BOOL TM_Ret = CHAR_warpToSpecificPoint(TM_Index, TM_Floor, TM_X, TM_Y); + + LRetBool(_NLL, TM_Ret); +} + +int NPC_Lua_NLG_WalkMove(lua_State *_NLL) +{ + CheckEx(_NLL, 2); + CheckIndexNull(_NLL, 1); + int TM_Index = (int)lua_tointeger(_NLL, 1); + int TM_DIR = (int)lua_tointeger(_NLL, 2); + + POINT start, end; + + end.x = CHAR_getInt( TM_Index, CHAR_X); + end.y = CHAR_getInt( TM_Index, CHAR_Y); + + int TM_Ret = (int)CHAR_walk(TM_Index, TM_DIR, 0); + + if( TM_Ret == CHAR_WALKSUCCESSED ) + { + int i; + int mefl=CHAR_getInt( TM_Index, CHAR_FLOOR); + int toindex = -1; + int fl = 0; + int xx = 0; + int yy = 0; + int parent_dir; + + for( i = 1; i < CHAR_PARTYMAX; i ++ ) + { + toindex = CHAR_getWorkInt( TM_Index, i + CHAR_WORKPARTYINDEX1); + fl = CHAR_getInt( toindex, CHAR_FLOOR); + xx = CHAR_getInt( toindex, CHAR_X); + yy = CHAR_getInt( toindex, CHAR_Y); + + if( CHAR_CHECKINDEX(toindex) && (mefl==fl) && (abs(xx-end.x)+abs(yy-end.y)<10) ) + { + + start.x = xx; + start.y = yy; + parent_dir = NPC_Util_getDirFromTwoPoint( &start,&end ); + + end.x = start.x; + end.y = start.y; + + if( parent_dir != -1 ) + { + CHAR_walk( toindex, parent_dir, 0); + } + } + } + } + LRetInt(_NLL, TM_Ret); +} + +int NPC_Lua_NLG_WatchEntry(lua_State *_NLL) +{ + CheckEx(_NLL, 2); + CheckIndexNull(_NLL, 1); + CheckIndexNull(_NLL, 2); + int TM_Index = (int)lua_tointeger(_NLL, 1); + int TM_ToIndex = (int)lua_tointeger(_NLL, 2); + if( BATTLE_WatchEntry(TM_Index, TM_ToIndex) == 0) + { + LRetInt(_NLL, 0); + }else + { + LRetInt(_NLL, -1); + } +} + +int NPC_Lua_Char_GetOnLinePlayer(lua_State *_NLL) +{ + CheckEx(_NLL, 0); + LRetInt(_NLL, abs(StateTable[LOGIN])); +} + +int NPC_Lua_NLG_UpStateBySecond(lua_State *_NLL) +{ + CheckEx2(_NLL, 1, 3); + CheckIndexNull(_NLL, 1); + int TM_Index = (int)lua_tointeger(_NLL, 1); + + if(!CHAR_CHECKINDEX(TM_Index)) + { + LRetErrInt(_NLL, -1, "Чġ"); + } + + char TM_Buff[128]; + int TM_fd = getfdFromCharaIndex(TM_Index); +#ifdef _SAF_MAKE + snprintf(TM_Buff, sizeof(TM_Buff), "FAME|%d|%d|%d", CHAR_getInt(TM_Index,CHAR_FAME)/100, (int)lua_tointeger(_NLL, 2), (int)lua_tointeger(_NLL, 3)); +#else + snprintf(TM_Buff, sizeof(TM_Buff), "FAME|%d", CHAR_getInt(TM_Index,CHAR_FAME)/100); +#endif + lssproto_S2_send(TM_fd,TM_Buff); + LRetInt(_NLL, 0); +} + +int NPC_Lua_NLG_UpStateByThird(lua_State *_NLL) +{ + CheckEx(_NLL, 2); + CheckIndexNull(_NLL, 1); + int TM_Index = (int)lua_tointeger(_NLL, 1); + int TM_Flg = (int)lua_tointeger(_NLL, 2); + BOOL TM_Ret = CHAR_send_P_StatusString(TM_Index, TM_Flg); + LRetBool(_NLL, TM_Ret); +} + +int NPC_Lua_NLG_Update_Party(lua_State *_NLL) +{ + CheckEx(_NLL, 2); + CheckIndexNull(_NLL, 1); + int TM_Index = (int)lua_tointeger(_NLL, 1); + int TM_Flg = (int)lua_tointeger(_NLL, 2); + CHAR_PartyUpdate(TM_Index, TM_Flg); + LRetNull(_NLL); +} + +int NPC_Lua_NLG_CreateBattlePvP(lua_State *_NLL) +{ + CheckEx(_NLL, 2); + CheckIndexNull(_NLL, 1); + CheckIndexNull(_NLL, 2); + int TM_Index1 = (int)lua_tointeger(_NLL, 1); + int TM_Index2 = (int)lua_tointeger(_NLL, 2); + int TM_Ret = -1; + int TM_BattleIndex = -1; + + if( (CHAR_getInt( TM_Index2, CHAR_WHICHTYPE) != CHAR_TYPEPLAYER) || (CHAR_getInt( TM_Index1, CHAR_WHICHTYPE) != CHAR_TYPEPLAYER)){ + LRetErrInt(_NLL, -1, "Ͳ"); + } + if( (CHAR_getWorkInt( TM_Index2, CHAR_WORKBATTLEMODE) != BATTLE_CHARMODE_NONE) || (CHAR_getWorkInt( TM_Index1, CHAR_WORKBATTLEMODE) != BATTLE_CHARMODE_NONE)) + { + LRetErrInt(_NLL, -2, "ڶս"); + } + if( CHAR_getWorkInt( TM_Index2, CHAR_WORKPARTYMODE ) == CHAR_PARTY_CLIENT ) + { + int TM_Index = CHAR_getWorkInt( TM_Index2, CHAR_WORKPARTYINDEX1 ); + + if( TM_Index < 0 ) + { + LRetErrInt(_NLL, -3, "Ķ쳣"); + } + } + if( CHAR_getWorkInt( TM_Index1, CHAR_WORKPARTYMODE ) == CHAR_PARTY_CLIENT ) + { + int TM_Index = CHAR_getWorkInt( TM_Index1, CHAR_WORKPARTYINDEX1 ); + + if( TM_Index < 0 ) + { + LRetErrInt(_NLL, -3, "Ķ쳣"); + } + } + TM_Ret = NPC_Lua_CreateVsPlayer(&TM_BattleIndex, TM_Index1, TM_Index2); + if(TM_Ret != 0) + { + char TM_Buff[64]; + snprintf(TM_Buff, sizeof(TM_Buff), "ʧܣ:%d", TM_Ret); + LRetErrInt(_NLL, -4, TM_Buff); + } + LRetInt(_NLL, TM_BattleIndex); +} + +int NPC_Lua_NLG_SearchWatchBattleRandIndex(lua_State *_NLL) +{ + CheckEx(_NLL, 2); + CheckIndexNull(_NLL, 1); + int TM_Index = (int)lua_tointeger(_NLL, 1); + int TM_Floor = (int)lua_tointeger(_NLL, 2); + int TM_Ret = -1; + + if( (CHAR_getInt( TM_Index, CHAR_WHICHTYPE) != CHAR_TYPEPLAYER) ){ + LRetErrInt(_NLL, -1, "Ͳ"); + } + if( (CHAR_getWorkInt( TM_Index, CHAR_WORKBATTLEMODE) != BATTLE_CHARMODE_NONE) ) + { + LRetErrInt(_NLL, -2, "ڶս"); + } + if( CHAR_getWorkInt( TM_Index, CHAR_WORKPARTYMODE ) == CHAR_PARTY_CLIENT ) + { + int TM_Index2 = CHAR_getWorkInt( TM_Index, CHAR_WORKPARTYINDEX1 ); + + if( TM_Index2 < 0 ) + { + LRetErrInt(_NLL, -3, "Ķ쳣"); + } + } + TM_Ret = SearchFmWarRandIndex(TM_Index, TM_Floor); + if(TM_Ret != 0) + { + char TM_Buff[64]; + snprintf(TM_Buff, sizeof(TM_Buff), "սɿ:%d", TM_Floor); + LRetErrInt(_NLL, -4, TM_Buff); + } + LRetInt(_NLL, TM_Ret); +} + +int NPC_Lua_NLG_GetMaxPlayNum(lua_State *_NLL) +{ + int TM_playernum = CHAR_getPlayerMaxNum(); + LRetInt(_NLL, TM_playernum); +} + +int NPC_Lua_NLG_CheckPlayIndex(lua_State *_NLL) +{ + CheckEx(_NLL, 1); + CheckIndexNull(_NLL, 1); + int TM_Index = (int)lua_tointeger(_NLL, 1); + if(!CHAR_CHECKINDEX(TM_Index)) + { + LRetErrInt(_NLL, -1, "Чġ"); + } + LRetInt(_NLL, TM_Index); +} + +int NPC_Lua_NLG_Save(lua_State *_NLL) +{ + CheckEx(_NLL, 1); + CheckIndexNull(_NLL, 1); + int TM_Index = (int)lua_tointeger(_NLL, 1); + if(!CHAR_CHECKINDEX(TM_Index)) + { + LRetErrInt(_NLL, -1, "Чġ"); + } + CHAR_charSaveFromConnect(TM_Index, FALSE); + LRetInt(_NLL, TM_Index); +} + +//////////////// add by Mo. +int NPC_Lua_NLG_SetExp(lua_State *_NLL) +{ + CheckEx(_NLL, 1); + int TM_Exp = (int)lua_tointeger(_NLL, 1); + if( TM_Exp <= 0 ) + { + LRetErrInt(_NLL, -3, ""); + } + setBattleexp(TM_Exp); + LRetNull(_NLL); +} + +int NPC_Lua_NLG_GetExp(lua_State *_NLL) +{ + int ret = getBattleexp(); + LRetInt(_NLL, ret); +} + +#ifdef _PETTRANS_RANGE +int NPC_Lua_NLG_SetPetTransRange(lua_State *_NLL) +{ + CheckEx(_NLL, 3); + + int TM_X = (int)lua_tointeger(_NLL, 1); + int TM_Y = (int)lua_tointeger(_NLL, 2); + int TM_Z = (int)lua_tointeger(_NLL, 3); + setPetTransRangeX(TM_X); + setPetTransRangeY(TM_Y); + setPetTransRangeZ(TM_Z); + LRetNull(_NLL); +} +int NPC_Lua_NLG_GetPetTransRange(lua_State *_NLL) +{ + CheckEx(_NLL, 1); + int TM_Index = (int)lua_tointeger(_NLL, 1); + if (TM_Index == 1){ + int ret = getPetTransRangeX(); + LRetInt(_NLL, ret); + } + if (TM_Index == 2){ + int ret = getPetTransRangeY(); + LRetInt(_NLL, ret); + } + if (TM_Index == 3){ + int ret = getPetTransRangeZ(); + LRetInt(_NLL, ret); + } + LRetErrInt(_NLL, -1, "IJЧġ"); +} +#endif + +int NPC_Lua_NLG_InputCard(lua_State *_NLL) +{ + CheckEx(_NLL, 1); + CheckIndexNull(_NLL, 1); + + int TM_Index1 = (int)lua_tointeger(_NLL, 1); + ITEM_OnlineCost(TM_Index1, -1, -1); + LRetNull(_NLL); +} + +int NPC_Lua_NLG_UpItem(lua_State *_NLL) +{ + CheckEx(_NLL, 1); + CheckIndexNull(_NLL, 1); + + int charaindex = (int)lua_tointeger(_NLL,1); + if( !CHAR_CHECKINDEX( charaindex)){ + return 0; + } + int MAX = 27; + int i= 0; + for ( i = 0; i <= MAX; i++){ + CHAR_sendItemDataOne( charaindex, i); + } + return 0; +} + +int NPC_Lua_NLG_GivePetOne(lua_State *_NLL) +{ + CheckEx2(_NLL, 2, 4); + CheckIndexNull(_NLL, 1); + int TM_Index = (int)lua_tointeger(_NLL, 1); + int TM_EnemyId = (int)lua_tointeger(_NLL, 2); + int TM_Level = 1; + int TM_PetIndex = -1; + int TM_Int = -1; + + if(lua_gettop(_NLL) >= 3) + { + TM_Level = (int)lua_tointeger(_NLL, 3); + } + + TM_Int = NPC_GivePet(TM_Index, TM_Level, TM_EnemyId); + if(TM_Int >= 0) + { + TM_PetIndex = TM_Int; + char TM_Buff[128]; + snprintf(TM_Buff, sizeof(TM_Buff), " 1 ֻ %s", CHAR_getChar( TM_PetIndex, CHAR_NAME)); + CHAR_talkToCli( TM_Index, -1, TM_Buff, CHAR_COLORYELLOW); + } + LRetInt(_NLL, TM_PetIndex); +} + +int NPC_Lua_NLG_GiveItemOne(lua_State *_NLL) +{ + CheckEx2(_NLL, 2, 3); + CheckIndexNull(_NLL, 1); + int TM_Index = (int)lua_tointeger(_NLL, 1); + int TM_ItemId = (int)lua_tointeger(_NLL, 2); + int TM_ItemIndex = -1; + int TM_Int = -1; + + TM_Int = NPC_GiveItem( TM_Index, TM_ItemId); + + if(TM_Int >= 0) + { + TM_ItemIndex = TM_Int; + char TM_Buff[128]; + snprintf(TM_Buff, sizeof(TM_Buff), " 1 %s", ITEM_getChar( TM_ItemIndex, ITEM_NAME)); + CHAR_talkToCli( TM_Index, -1, TM_Buff, CHAR_COLORYELLOW); + } + LRetInt(_NLL, TM_ItemIndex); +} + +int NPC_Lua_NLG_DelItemByIndex(lua_State *_NLL) +{ + CheckEx(_NLL, 2); + CheckIndexNull(_NLL, 1); + CheckIndexNull(_NLL, 2); + int charaindex = (int)lua_tointeger(_NLL, 1); + if( CHAR_CHECKINDEX( charaindex ) == FALSE ){ + LRetInt(_NLL, -1); + return -1; + } + int haveitemindex = (int)lua_tointeger(_NLL, 2); + int itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + if(!ITEM_CHECKINDEX(itemindex)) { + LRetInt(_NLL, -1); + return -1; + } + CHAR_DelItem( charaindex, haveitemindex); + LRetInt(_NLL, 0); +} + +int NPC_Lua_NLG_FindPet(lua_State *_NLL) +{ + CheckEx2(_NLL, 2, 3); + CheckIndexNull(_NLL, 1); + int TM_Index = (int)lua_tointeger(_NLL, 1); + int TM_PetID = (int)lua_tointeger(_NLL, 2); + int TM_Count = 0; + + int i = 0; + for(i = 0; i < CHAR_MAXPETHAVE ; i++) + { + if (CHAR_getCharPet( TM_Index, i) == -1) TM_Count++; + } + LRetInt(_NLL, TM_Count); +} + +int NPC_Lua_NLG_GetMap(lua_State *_NLL) +{ + CheckEx2(_NLL, 1, 3); + CheckIndexNull(_NLL, 1); + + int TM_Index = (int)lua_tointeger(_NLL, 1); + + BOOL TM_Ret = CHAR_CHAT_GetMap( TM_Index, ""); + + LRetInt(_NLL, TM_Ret); +} + +int NPC_Lua_NLG_PetUp(lua_State *_NLL) +{ + CheckEx2(_NLL, 2, 3); + CheckIndexNull(_NLL, 1); + int TM_Index = (int)lua_tointeger(_NLL, 1); + int TM_PetIndex = (int)lua_tointeger(_NLL, 2); + int TM_LV = 1; + + if(lua_gettop(_NLL) == 3) + { + TM_LV = (int)lua_tointeger(_NLL, 3); + } + + BOOL TM_Ret = NPC_PetUp(TM_Index, TM_LV, TM_PetIndex); + + LRetBool(_NLL, TM_Ret); +} + +int NPC_Lua_NLG_AddSk(lua_State *_NLL) +{ + CheckEx2(_NLL, 2, 3); + CheckIndexNull(_NLL, 1); + int TM_Index = (int)lua_tointeger(_NLL, 1); + int TM_SkIndex = (int)lua_tointeger(_NLL, 2); + int TM_SkLV = 1; + + if(lua_gettop(_NLL) == 3) + { + TM_SkLV = (int)lua_tointeger(_NLL, 3); + } + + BOOL TM_Ret = NPC_AddSk(TM_Index, TM_SkIndex, TM_SkLV); + + LRetInt(_NLL, TM_Ret); +} + + +int NPC_Lua_NLG_SetZy(lua_State *_NLL) +{ + CheckEx2(_NLL, 2, 3); + CheckIndexNull(_NLL, 1); + int TM_Index = (int)lua_tointeger(_NLL, 1); + int TM_ZyIndex = (int)lua_tointeger(_NLL, 2); + + BOOL TM_Ret = NPC_SetZy(TM_Index, TM_ZyIndex); + + LRetBool(_NLL, TM_Ret); +} + +int NPC_Lua_Char_GetPlayerMaxNum(lua_State *_NLL) +{ + CheckEx(_NLL, 0); + LRetInt(_NLL, CHAR_getPlayerMaxNum()); +} + +int NPC_Lua_NLG_GetXY(lua_State *_NLL) +{ + CheckEx2(_NLL, 1, 2); + CheckIndexNull(_NLL, 1); + int TM_MAP = (int)lua_tointeger(_NLL, 1); + LRetInt(_NLL, QuBiao(TM_MAP)); +} + +int NPC_Lua_NLG_WalkJc(lua_State *_NLL)//ǰϰ +{ + CheckEx(_NLL, 5); + CheckIndexNull(_NLL, 1); + int TM_Index = (int)lua_tointeger(_NLL, 1); + int TM_Floor = (int)lua_tointeger(_NLL, 2); + int TM_Ox = (int)lua_tointeger(_NLL, 3); + int TM_Oy = (int)lua_tointeger(_NLL, 4); + int TM_DIR = (int)lua_tointeger(_NLL, 5); + + int TM_Ret = (int)CHAR_walk_jjc(TM_Index,TM_Floor,TM_Ox,TM_Oy,TM_DIR); + + if( TM_Ret == CHAR_WALKSUCCESSED ) + { + LRetInt(_NLL, 1); + }else LRetInt(_NLL, 0); +} + +int NPC_Lua_NLG_KickPlayer(lua_State *_NLL) +{ + CheckEx(_NLL, 1); + CheckIndexNull(_NLL, 1); + int TM_index = (int)lua_tointeger(_NLL, 1); + if( !CHAR_CHECKINDEX( TM_index)) { + LRetErrInt(_NLL , -1, "ﴫЧģ"); + return; + } + CONNECT_setCloseRequest( getfdFromCharaIndex(TM_index) , 1 ); + LRetBool(_NLL, TRUE); +} + +int NPC_Lua_NLG_HealOne(lua_State *_NLL) +{ + CheckEx(_NLL, 1); + CheckIndexNull(_NLL, 1); + int TM_index = (int)lua_tointeger(_NLL, 1); + if( !CHAR_CHECKINDEX( TM_index)) { + LRetErrInt(_NLL , -1, "Чģ"); + return; + } + CHAR_setInt( TM_index , CHAR_HP,99999999 ); + CHAR_setInt( TM_index , CHAR_MP,99999999 ); + CHAR_complianceParameter( TM_index ); + CHAR_send_P_StatusString( TM_index , CHAR_P_STRING_HP); + CHAR_send_P_StatusString( TM_index , CHAR_P_STRING_MP); + LRetBool(_NLL, TRUE); +} + +int NPC_Lua_NLG_HealAll(lua_State *_NLL) +{ + CheckEx(_NLL, 1); + CheckIndexNull(_NLL, 1); + int TM_index = (int)lua_tointeger(_NLL, 1); + int TM_PetIndex = -1; + if( !CHAR_CHECKINDEX( TM_index)) { + LRetErrInt(_NLL , -1, "Чģ"); + return; + } + CHAR_setInt( TM_index , CHAR_HP,99999999 ); + CHAR_setInt( TM_index , CHAR_MP,99999999 ); + CHAR_complianceParameter( TM_index ); + CHAR_send_P_StatusString( TM_index , CHAR_P_STRING_HP); + CHAR_send_P_StatusString( TM_index , CHAR_P_STRING_MP); + int i = 0; + for(i = 0; i < CHAR_MAXPETHAVE ; i++) + { + TM_PetIndex = CHAR_getCharPet( TM_index, i); + + if(!CHAR_CHECKINDEX(TM_PetIndex)) + { + continue; + } + CHAR_setInt( TM_PetIndex , CHAR_HP,99999999 ); + CHAR_complianceParameter( TM_PetIndex ); + char msgbuf[64]; + snprintf( msgbuf, sizeof( msgbuf ), "K%d", i ); + CHAR_sendStatusString( TM_index, msgbuf ); + snprintf( msgbuf, sizeof( msgbuf ), "W%d", i ); + CHAR_sendStatusString( TM_index, msgbuf ); +#ifdef _PET_SKILL2 + snprintf( msgbuf, sizeof( msgbuf ), "Q%d", i ); + CHAR_sendStatusString( TM_index, msgbuf ); +#endif + } + LRetBool(_NLL, TRUE); +} + +int NPC_Lua_NLG_LevelUpTo(lua_State *_NLL) +{ + CheckEx(_NLL, 2); + CheckIndexNull(_NLL, 1); + int TM_index = (int)lua_tointeger(_NLL, 1); + int TM_LV = (int)lua_tointeger(_NLL, 2); + int i; + if( !CHAR_CHECKINDEX( TM_index)) { + LRetErrInt(_NLL , -1, "Чģ"); + return; + } + TM_LV = TM_LV - CHAR_getInt( TM_index, CHAR_LV); + if (TM_LV <= 0) //ʧ + { + LRetBool(_NLL, FALSE); + } + if (CHAR_getInt( TM_index, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER)//Ļ + { + CHAR_setInt(TM_index,CHAR_SKILLUPPOINT, + CHAR_getInt(TM_index,CHAR_SKILLUPPOINT)+TM_LV*3); + CHAR_Skillupsend(TM_index); + CHAR_setInt(TM_index,CHAR_LV, CHAR_getInt( TM_index, CHAR_LV) + TM_LV); + CHAR_send_P_StatusString( TM_index , CHAR_P_STRING_LV|CHAR_P_STRING_NEXTEXP); + LRetBool(_NLL, TRUE); + }else if (CHAR_getInt( TM_index, CHAR_WHICHTYPE ) == CHAR_TYPEPET)//dzĻ + { + char token[128]; + for( i = 1; i <= TM_LV; i ++ ){ // + //CHAR_PetLevelUp( TM_index ,1); + CHAR_PetLevelUp( TM_index); + CHAR_PetAddVariableAi( TM_index, AI_FIX_PETLEVELUP ); + CHAR_setInt( TM_index, CHAR_LV, CHAR_getInt( TM_index, CHAR_LV) +1 ); + } + int PLAYER = CHAR_getWorkInt(TM_index, CHAR_WORKPLAYERINDEX);//˵ + for( i = 0; i < CHAR_MAXPETHAVE; i ++ ) + { + if( CHAR_getCharPet( PLAYER, i ) == TM_index )break; + } + CHAR_setInt( TM_index , CHAR_HP ,CHAR_getWorkInt( TM_index, CHAR_WORKMAXHP ) ); + CHAR_setInt( TM_index , CHAR_MP ,CHAR_getWorkInt( TM_index, CHAR_WORKMAXMP ) ); + CHAR_complianceParameter( TM_index ); + snprintf( token, sizeof( token ), "K%d", i ); + CHAR_sendStatusString( PLAYER, token ); + snprintf( token, sizeof( token ), "W%d", i ); + CHAR_sendStatusString( PLAYER, token ); +#ifdef _PET_SKILL2 + snprintf( token, sizeof( token ), "Q%d", i ); + CHAR_sendStatusString( TM_index, token ); +#endif + } + LRetBool(_NLL, TRUE); +} + + +int NPC_Lua_NLG_AddExp(lua_State *_NLL) +{ + CheckEx(_NLL, 2); + CheckIndexNull(_NLL, 1); + int i; + int TM_index = (int)lua_tointeger(_NLL, 1); + int TM_EXP = (int)lua_tointeger(_NLL, 2); + if( !CHAR_CHECKINDEX( TM_index)) { + LRetErrInt(_NLL , -1, "Чģ"); + return; + } + CHAR_setInt( TM_index, CHAR_EXP,CHAR_getInt(TM_index,CHAR_EXP) + TM_EXP); + + if (CHAR_getInt( TM_index, CHAR_WHICHTYPE ) == CHAR_TYPEPET)//dzĻ + { + char token[128]; + int PLAYER = CHAR_getWorkInt(TM_index, CHAR_WORKPLAYERINDEX);//˵ + for( i = 0; i < CHAR_MAXPETHAVE; i ++ ) + { + if( CHAR_getCharPet( PLAYER, i ) == TM_index )break; + } + CHAR_complianceParameter( TM_index ); + snprintf( token, sizeof( token ), "K%d", i ); + CHAR_sendStatusString( PLAYER, token ); + snprintf( token, sizeof( token ), "W%d", i ); + CHAR_sendStatusString( PLAYER, token ); +#ifdef _PET_SKILL2 + snprintf( token, sizeof( token ), "Q%d", i ); + CHAR_sendStatusString( PLAYER, token ); +#endif + }else CHAR_send_P_StatusString( TM_index , CHAR_P_STRING_EXP); + LRetBool(_NLL, TRUE); +} + +int NPC_Lua_NLG_UpPet(lua_State *_NLL) +{ + CheckEx2(_NLL, 1, 2); + CheckIndexNull(_NLL, 1); + int TM_Top = lua_gettop(_NLL); + int TM_Index = (int)lua_tointeger(_NLL, 1); + int TM_It = -1; + int i; + int petindex; + char token[64]; + if( !CHAR_CHECKINDEX( TM_Index)) { + LRetErrInt(_NLL , -1, "Чģ"); + return; + } + if (TM_Top == 2) + { + TM_It = (int)lua_tointeger(_NLL, 2); + } + if(TM_It == -1){ + for (i=0;i 4) LRetErrInt(_NLL , -1, "ָijλûг"); + + TM_PetIndex = CHAR_getCharPet( TM_Index, TM_PetID); + + if(!CHAR_CHECKINDEX(TM_PetIndex)) + { + LRetInt(_NLL, -1); + return -1; + } + + TM_Ret = NPC_DelPet( TM_Index, TM_PetID); + if(TM_Ret < 0) + { + char TM_MsgBuff[128]; + snprintf(TM_MsgBuff, sizeof(TM_MsgBuff), "ɾʱ : %d", TM_Ret); + LRetErrInt(_NLL , -1, TM_MsgBuff); + } + + LRetInt(_NLL, TM_Ret); +} + +int NPC_Lua_NLG_DelPetByIndex(lua_State *_NLL) +{ + CheckEx(_NLL, 2); + CheckIndexNull(_NLL, 1); + int TM_Index = (int)lua_tointeger(_NLL, 1); + int TM_Pindex = (int)lua_tointeger(_NLL, 2); + int TM_Num = 1; + int TM_PetIndex = -1; + int TM_Ret = 0; + if( !CHAR_CHECKINDEX( TM_Index)) { + LRetErrInt(_NLL , -1, "ﴫЧģ"); + return; + } + if( !CHAR_CHECKINDEX( TM_Pindex)) { + LRetErrInt(_NLL , -1, "ﴫЧģ"); + return; + } + int i = 0; + for(i = 0; i < CHAR_MAXPETHAVE ; i++) + { + TM_PetIndex = CHAR_getCharPet( TM_Index, i); + + if(!CHAR_CHECKINDEX(TM_PetIndex)) + { + continue; + } + + if (TM_PetIndex != TM_Pindex) continue; + + TM_Ret = NPC_DelPet( TM_Index, i); + if(TM_Ret < 0) + { + char TM_MsgBuff[128]; + snprintf(TM_MsgBuff, sizeof(TM_MsgBuff), "ɾʱ : %d", TM_Ret); + LRetErrInt(_NLL , -1, TM_MsgBuff); + } + + break; + } + LRetInt(_NLL, TM_Ret); +} + +int NPC_Lua_NLG_GivePetByIndex(lua_State *_NLL) +{ + CheckEx(_NLL, 2); + CheckIndexNull(_NLL, 1); + int TM_Index = (int)lua_tointeger(_NLL, 1); + int TM_PetIndex = (int)lua_tointeger(_NLL, 2); + if( !CHAR_CHECKINDEX( TM_Index)) { + LRetErrInt(_NLL , -1, "ﴫЧģ"); + return; + } + if( !CHAR_CHECKINDEX( TM_PetIndex)) { + LRetErrInt(_NLL , -1, "ﴫЧģ"); + return; + } + int havepetelement = CHAR_getCharPetElement( TM_Index); + if( havepetelement < 0 ) { + LRetErrInt(_NLL , -1, "Ŀλ"); + return; + } + CHAR_setWorkInt( TM_PetIndex, CHAR_WORKPLAYERINDEX, TM_Index);// + CHAR_setCharPet( TM_Index, havepetelement, TM_PetIndex); + CHAR_setChar( TM_PetIndex, CHAR_OWNERCDKEY, + CHAR_getChar( TM_Index, CHAR_CDKEY)); + CHAR_setChar( TM_PetIndex, CHAR_OWNERCHARANAME, + CHAR_getChar( TM_Index, CHAR_NAME)); + CHAR_complianceParameter(TM_PetIndex); + + char msgbuf[64]; + snprintf( msgbuf, sizeof( msgbuf ), "K%d", havepetelement ); + CHAR_sendStatusString( TM_Index, msgbuf ); + snprintf( msgbuf, sizeof( msgbuf ), "W%d", havepetelement ); + CHAR_sendStatusString( TM_Index, msgbuf ); +#ifdef _PET_SKILL2 + snprintf( msgbuf, sizeof( msgbuf ), "Q%d", havepetelement ); + CHAR_sendStatusString( TM_Index, msgbuf ); +#endif + LRetInt(_NLL, havepetelement); +} + +int NPC_Lua_NLG_GiveItemByIndex(lua_State *_NLL) +{ + CheckEx(_NLL, 2); + CheckIndexNull(_NLL, 1); + int TM_Index = (int)lua_tointeger(_NLL, 1); + int TM_ItemIndex = (int)lua_tointeger(_NLL, 2); + if( !CHAR_CHECKINDEX( TM_Index)) { + LRetErrInt(_NLL , -1, "ﴫЧģ"); + return; + } + if( !ITEM_CHECKINDEX( TM_ItemIndex)) { + LRetErrInt(_NLL , -1, "ߴЧģ"); + return; + } + int emptyitemindexinchara = CHAR_findEmptyItemBox( TM_Index); + if( emptyitemindexinchara < 0 ) { + LRetErrInt(_NLL , -1, "Ŀλ"); + return; + } + CHAR_setItemIndex( TM_Index, emptyitemindexinchara, TM_ItemIndex ); + ITEM_setWorkInt(TM_ItemIndex, ITEM_WORKOBJINDEX,-1); + ITEM_setWorkInt(TM_ItemIndex, ITEM_WORKCHARAINDEX, TM_Index); + CHAR_sendItemDataOne( TM_Index, emptyitemindexinchara); + LRetInt(_NLL, emptyitemindexinchara); +} + +int NPC_Lua_NLG_WarpToSpecificPoint(lua_State *_NLL) +{ + + CheckEx(_NLL, 4); + CheckIndexNull(_NLL, 1); + int cindex = (int)lua_tointeger(_NLL, 1); + int fl = (int)lua_tointeger(_NLL, 2); + int x = (int)lua_tointeger(_NLL, 3); + int y = (int)lua_tointeger(_NLL, 4); + + if(!CHAR_CHECKINDEX(cindex)) + { + LRetErrInt(_NLL, -1, "Чġ"); + } + + LRetBool(_NLL,CHAR_warpToSpecificPoint(cindex,fl,x,y)); +} + +BOOL NPC_Lua_NLG_UpSkillupPoint(lua_State *_NLL) +{ + CheckEx(_NLL, 1); + CheckIndexNull(_NLL, 1); + int TM_Index = (int)lua_tointeger(_NLL, 1); + if( !CHAR_CHECKINDEX( TM_Index)) { + LRetErrInt(_NLL , -1, "ﴫЧģ"); + return; + } + CHAR_Skillupsend(TM_Index); + LRetBool(_NLL, TRUE); +} + +// +int NPC_Lua_NLG_StayEncount(lua_State *_NLL) +{ + CheckEx(_NLL, 1); + CheckIndexNull(_NLL, 1); + int fd,charaindex = (int)lua_tointeger(_NLL, 1); + fd = CHAR_getWorkInt( charaindex, CHAR_WORKFD); + setStayEncount(fd); + CHAR_talkToCli(charaindex, -1, "ܱܵͻȻɱ", CHAR_COLORYELLOW); +#ifdef _USER_CHARLOOPS + { + Char *ch; + ch = CHAR_getCharPointer( charaindex); + if( ch == NULL ) return; + strcpysafe( ch->charfunctable[CHAR_LOOPFUNCTEMP1].string, + sizeof( ch->charfunctable[CHAR_LOOPFUNCTEMP1]), "CHAR_BattleStayLoop");//ս + CHAR_setInt( charaindex, CHAR_LOOPINTERVAL, 2500); + CHAR_constructFunctable( charaindex); + } +#endif + LRetBool(_NLL,TRUE); +} + +int NPC_Lua_NLG_HealerAllHeal(lua_State *_NLL) +{ + CheckEx(_NLL,1); + CheckIndexNull(_NLL, 1); + int TM_Index = (int)lua_tointeger(_NLL, 1); + NPC_HealerAllHeal(TM_Index); + LRetNull(_NLL); +} + +#endif //#ifdef _JZ_NEWSCRIPT_LUA diff --git a/npc_lua/npc_lua_obj.c b/npc_lua/npc_lua_obj.c new file mode 100644 index 0000000..4c1ac7d --- /dev/null +++ b/npc_lua/npc_lua_obj.c @@ -0,0 +1,140 @@ +#include "npc_lua.h" +#include "util.h" +#include "char.h" +#include "char_base.h" +#include "anim_tbl.h" +#include "object.h" +#include "net.h" +#include "npcutil.h" +#include "npc_eventaction.h" +#include "battle.h" +#include "readmap.h" + +#ifdef _JZ_NEWSCRIPT_LUA + +int NPC_Lua_Obj_GetType(lua_State *_NLL) +{ + CheckEx(_NLL, 1); + CheckObjIndexNull(_NLL, 1); + int TM_index = (int)lua_tointeger(_NLL, 1); + + int TM_Ret = OBJECT_getType(TM_index); + + LRetInt(_NLL, TM_Ret); +} + +int NPC_Lua_Obj_GetCharType(lua_State *_NLL) +{ + CheckEx(_NLL, 1); + CheckObjIndexNull(_NLL, 1); + int TM_index = (int)lua_tointeger(_NLL, 1); + + int TM_Ret = OBJECT_getchartype(TM_index); + + LRetInt(_NLL, TM_Ret); +} + +int NPC_Lua_Obj_GetCharIndex(lua_State *_NLL) +{ + CheckEx(_NLL, 1); + CheckObjIndexNull(_NLL, 1); + int TM_index = (int)lua_tointeger(_NLL, 1); + + int TM_Ret = OBJECT_getIndex(TM_index); + + LRetInt(_NLL, TM_Ret); +} + +int NPC_Lua_Obj_GetX(lua_State *_NLL) +{ + CheckEx(_NLL, 1); + CheckObjIndexNull(_NLL, 1); + int TM_index = (int)lua_tointeger(_NLL, 1); + + int TM_Ret = OBJECT_getX(TM_index); + + LRetInt(_NLL, TM_Ret); +} + +int NPC_Lua_Obj_GetY(lua_State *_NLL) +{ + CheckEx(_NLL, 1); + CheckObjIndexNull(_NLL, 1); + int TM_index = (int)lua_tointeger(_NLL, 1); + + int TM_Ret = OBJECT_getY(TM_index); + + LRetInt(_NLL, TM_Ret); +} + +int NPC_Lua_Obj_GetFloor(lua_State *_NLL) +{ + CheckEx(_NLL, 1); + CheckObjIndexNull(_NLL, 1); + int TM_index = (int)lua_tointeger(_NLL, 1); + + int TM_Ret = OBJECT_getFloor(TM_index); + + LRetInt(_NLL, TM_Ret); +} + +int NPC_Lua_Obj_SetType(lua_State *_NLL) +{ + CheckEx(_NLL, 2); + CheckObjIndexNull(_NLL, 1); + int TM_index = (int)lua_tointeger(_NLL, 1); + int TM_vl = (int)lua_tointeger(_NLL, 2); + + int TM_Ret = OBJECT_setType(TM_index, TM_vl); + + LRetInt(_NLL, TM_Ret); +} + +int NPC_Lua_Obj_SetCharType(lua_State *_NLL) +{ + CheckEx(_NLL, 2); + CheckObjIndexNull(_NLL, 1); + int TM_index = (int)lua_tointeger(_NLL, 1); + int TM_vl = (int)lua_tointeger(_NLL, 2); + + OBJECT_setchartype(TM_index, TM_vl); + + LRetNull(_NLL); +} + +int NPC_Lua_Obj_SetX(lua_State *_NLL) +{ + CheckEx(_NLL, 2); + CheckObjIndexNull(_NLL, 1); + int TM_index = (int)lua_tointeger(_NLL, 1); + int TM_vl = (int)lua_tointeger(_NLL, 2); + + int TM_Ret = OBJECT_setX(TM_index, TM_vl); + + LRetInt(_NLL, TM_Ret); +} + +int NPC_Lua_Obj_SetY(lua_State *_NLL) +{ + CheckEx(_NLL, 2); + CheckObjIndexNull(_NLL, 1); + int TM_index = (int)lua_tointeger(_NLL, 1); + int TM_vl = (int)lua_tointeger(_NLL, 2); + + int TM_Ret = OBJECT_setY(TM_index, TM_vl); + + LRetInt(_NLL, TM_Ret); +} + +int NPC_Lua_Obj_SetFloor(lua_State *_NLL) +{ + CheckEx(_NLL, 2); + CheckObjIndexNull(_NLL, 1); + int TM_index = (int)lua_tointeger(_NLL, 1); + int TM_vl = (int)lua_tointeger(_NLL, 2); + + int TM_Ret = OBJECT_setFloor(TM_index, TM_vl); + + LRetInt(_NLL, TM_Ret); +} +#endif //#ifdef _JZ_NEWSCRIPT_LUA diff --git a/npc_lua/npc_lua_spell.c b/npc_lua/npc_lua_spell.c new file mode 100644 index 0000000..2b84f00 --- /dev/null +++ b/npc_lua/npc_lua_spell.c @@ -0,0 +1,202 @@ +#include "npc_lua.h" +#include "util.h" +#include "char.h" +#include "char_base.h" +#include "anim_tbl.h" +#include "object.h" +#include "net.h" +#include "npcutil.h" +#include "npc_eventaction.h" +#include "battle.h" +#include "readmap.h" +#include "pet_skill.h" +#include "profession_skill.h" +#include "magic_base.h" + +#define _JZ_NEWSCRIPT_LUA + + +int NPC_Lua_Spell_PETSKILL_GetData(lua_State *_NLL) +{ + CheckEx(_NLL, 2); + CheckIndexNull(_NLL, 1); + int TM_Index = (int)lua_tointeger(_NLL, 1); + int TM_Flg = (int)lua_tointeger(_NLL, 2); + + if(TM_Flg >= 0) + { + if(TM_Flg < LUA_DATALINE1) + { + int skillarray = PETSKILL_getPetskillArray( TM_Index); + TM_Flg -= LUA_DATALINE0; + int TM_RetInt = PETSKILL_getInt(skillarray, TM_Flg); + LRetInt(_NLL, TM_RetInt); + }else if(TM_Flg < LUA_DATALINE2) + { + int skillarray = PETSKILL_getPetskillArray( TM_Index); + TM_Flg -= LUA_DATALINE1; + char *TM_RetPoint = PETSKILL_getChar(skillarray, TM_Flg); + LRetMsg(_NLL, TM_RetPoint); + }else + { + LRetErrNull(_NLL, "ı־Ǵġ"); + } + } + LRetErrNull(_NLL, "ı־Ǵġ"); +} + + +int NPC_Lua_Spell_PROFESSION_GetData(lua_State *_NLL) +{ + CheckEx(_NLL, 2); + CheckIndexNull(_NLL, 1); + int TM_Index = (int)lua_tointeger(_NLL, 1); + int TM_Flg = (int)lua_tointeger(_NLL, 2); + + if(TM_Flg >= 0) + { + if(TM_Flg < LUA_DATALINE1) + { + int skillarray = PROFESSION_SKILL_getskillArray( TM_Index); + TM_Flg -= LUA_DATALINE0; + int TM_RetInt = PROFESSION_SKILL_getInt(skillarray, TM_Flg); + LRetInt(_NLL, TM_RetInt); + }else if(TM_Flg < LUA_DATALINE2) + { + + int skillarray = PROFESSION_SKILL_getskillArray( TM_Index ); + TM_Flg -= LUA_DATALINE1; + char *TM_RetPoint = PROFESSION_SKILL_getChar(skillarray, TM_Flg); + LRetMsg(_NLL, TM_RetPoint); + }else + { + LRetErrNull(_NLL, "ı־Ǵġ"); + } + } + LRetErrNull(_NLL, "ı־Ǵġ"); +} + + +int NPC_Lua_Spell_MAGIC_GetData(lua_State *_NLL) +{ + CheckEx(_NLL, 2); + CheckIndexNull(_NLL, 1); + int TM_Index = (int)lua_tointeger(_NLL, 1); + int TM_Flg = (int)lua_tointeger(_NLL, 2); + + if(TM_Flg >= 0) + { + if(TM_Flg < LUA_DATALINE1) + { + int magic_array = -1; + magic_array = MAGIC_getMagicArray( TM_Index ); + TM_Flg -= LUA_DATALINE0; + int TM_RetInt = MAGIC_getInt(magic_array, TM_Flg); + LRetInt(_NLL, TM_RetInt); + }else if(TM_Flg < LUA_DATALINE2) + { + int magic_array = -1; + magic_array = MAGIC_getMagicArray( TM_Index ); + TM_Flg -= LUA_DATALINE1; + char *TM_RetPoint = MAGIC_getChar(magic_array, TM_Flg); + LRetMsg(_NLL, TM_RetPoint); + }else + { + LRetErrNull(_NLL, "ı־Ǵġ"); + } + } + LRetErrNull(_NLL, "ı־Ǵġ"); +} + + +int NPC_Lua_Spell_PETSKILL_SetData(lua_State *_NLL) +{ + CheckEx(_NLL, 3); + CheckItemIndexNull(_NLL, 1); + int TM_Index = (int)lua_tointeger(_NLL, 1); + int TM_Flg = (int)lua_tointeger(_NLL, 2); + + if(TM_Flg >= 0) + { + if(TM_Flg < LUA_DATALINE1) + { + TM_Flg -= LUA_DATALINE0; + int TM_IntVal = (int)lua_tointeger(_NLL, 3); + int TM_RetInt = PROFESSION_SKILL_setInt(TM_Index, TM_Flg, TM_IntVal); + LRetInt(_NLL, TM_RetInt); + }else if(TM_Flg < LUA_DATALINE2) + { + TM_Flg -= LUA_DATALINE1; + char *TM_CharPoint = (char *)lua_tostring(_NLL, 3); + BOOL TM_RetBOOL = PROFESSION_SKILL_setChar(TM_Index, TM_Flg, TM_CharPoint); + LRetBool(_NLL, TM_RetBOOL); + }else + { + LRetErrNull(_NLL, "ı־Ǵġ"); + } + } + LRetErrNull(_NLL, "ı־Ǵġ"); +} + + + +int NPC_Lua_Spell_PROFESSION_SetData(lua_State *_NLL) +{ + CheckEx(_NLL, 3); + CheckItemIndexNull(_NLL, 1); + int TM_Index = (int)lua_tointeger(_NLL, 1); + int TM_Flg = (int)lua_tointeger(_NLL, 2); + + if(TM_Flg >= 0) + { + if(TM_Flg < LUA_DATALINE1) + { + TM_Flg -= LUA_DATALINE0; + int TM_IntVal = (int)lua_tointeger(_NLL, 3); + int TM_RetInt = PROFESSION_SKILL_setInt(TM_Index, TM_Flg, TM_IntVal); + LRetInt(_NLL, TM_RetInt); + }else if(TM_Flg < LUA_DATALINE2) + { + TM_Flg -= LUA_DATALINE1; + char *TM_CharPoint = (char *)lua_tostring(_NLL, 3); + BOOL TM_RetBOOL = PROFESSION_SKILL_setChar(TM_Index, TM_Flg, TM_CharPoint); + LRetBool(_NLL, TM_RetBOOL); + }else + { + LRetErrNull(_NLL, "ı־Ǵġ"); + } + } + LRetErrNull(_NLL, "ı־Ǵġ"); +} + + +int NPC_Lua_Spell_MAGIC_SetData(lua_State *_NLL) +{ + CheckEx(_NLL, 3); + CheckItemIndexNull(_NLL, 1); + int TM_Index = (int)lua_tointeger(_NLL, 1); + int TM_Flg = (int)lua_tointeger(_NLL, 2); + + if(TM_Flg >= 0) + { + if(TM_Flg < LUA_DATALINE1) + { + TM_Flg -= LUA_DATALINE0; + int TM_IntVal = (int)lua_tointeger(_NLL, 3); + int TM_RetInt = MAGIC_setInt(TM_Index, TM_Flg, TM_IntVal); + LRetInt(_NLL, TM_RetInt); + }else if(TM_Flg < LUA_DATALINE2) + { + TM_Flg -= LUA_DATALINE1; + char *TM_CharPoint = (char *)lua_tostring(_NLL, 3); + BOOL TM_RetBOOL = MAGIC_setChar(TM_Index, TM_Flg, TM_CharPoint); + LRetBool(_NLL, TM_RetBOOL); + }else + { + LRetErrNull(_NLL, "ı־Ǵġ"); + } + } + LRetErrNull(_NLL, "ı־Ǵġ"); +} + + diff --git a/npc_lua/npc_lua_sql.c b/npc_lua/npc_lua_sql.c new file mode 100644 index 0000000..0ac8490 --- /dev/null +++ b/npc_lua/npc_lua_sql.c @@ -0,0 +1,131 @@ +#include "npc_lua.h" +#include "util.h" +#include "char.h" +#include "char_base.h" +#include "char_data.h" +#include "anim_tbl.h" +#include "object.h" +#include "battle.h" +#include "npcutil.h" +#include "item.h" +#include "readmap.h" + +#include "sasql.h" + +#ifdef _JZ_NEWSCRIPT_LUA + + +int NPC_Lua_SQL_Push(lua_State *_NLL) +{ + CheckEx(_NLL, 1); + + char* _SQLSTR = NULL; + + _SQLSTR = lua_tostring(_NLL, 1); + sasql_LUASQL(_SQLSTR,-1,"NULL","NULL",-1,-1,"NULL"); +} + + +int NPC_Lua_SQL_PushPop(lua_State *_NLL) +{ + CheckEx(_NLL,7); + int npcindex,charaindex,row; + char* sqlstr,*function,*filepath,*msg; + + sqlstr = lua_tostring(_NLL, 1); + row = lua_tointeger(_NLL, 2); + filepath = lua_tostring(_NLL, 3); + function = lua_tostring(_NLL, 4); + npcindex = lua_tointeger(_NLL, 5); + charaindex = lua_tointeger(_NLL, 6); + msg = lua_tostring(_NLL, 7); +// print("sqlstr=%s\n row=%d\n filepath=%s\n function=%s\n npcindex=%d\n charaindex=%d\n msg=%s\n",sqlstr,row,filepath,function,npcindex,charaindex,msg); + sasql_LUASQL(sqlstr,row,filepath,function,npcindex,charaindex,msg); +} + +int NPC_Lua_SQL_PushPopAdv(lua_State *_NLL) +{ + CheckEx(_NLL,6); + int npcindex,charaindex; + char* sqlstr,*function,*filepath,*msg; + + sqlstr = lua_tostring(_NLL, 1); + if(lua_isnil((_NLL), (3))){ + filepath = ""; + }else{ + filepath = lua_tostring(_NLL, 3); + } + function = lua_tostring(_NLL, 3); + npcindex = lua_tointeger(_NLL, 4); + charaindex = lua_tointeger(_NLL, 5); + msg = lua_tostring(_NLL, 6); + int flg = 1; + sasql_LUASQLAdv(sqlstr,filepath,function,npcindex,charaindex,msg,flg); +} + +int NPC_Lua_SQL_QueryFirstRow(lua_State *_NLL) +{ + CheckEx(_NLL,6); + int npcindex,charaindex; + char* sqlstr,*function,*filepath,*msg; + + sqlstr = lua_tostring(_NLL, 1); + if(lua_isnil((_NLL), (3))){ + filepath = ""; + }else{ + filepath = lua_tostring(_NLL, 3); + } + function = lua_tostring(_NLL, 3); + npcindex = lua_tointeger(_NLL, 4); + charaindex = lua_tointeger(_NLL, 5); + msg = lua_tostring(_NLL, 6); + int flg = 2; + sasql_LUASQLAdv(sqlstr,filepath,function,npcindex,charaindex,msg,flg); +} + +int NPC_Lua_SQL_FetchRow(lua_State *_NLL) +{ + CheckEx(_NLL,5); + int npcindex,charaindex; + char* sqlstr,*function,*filepath,*msg; + + + if(lua_isnil((_NLL), (3))){ + filepath = ""; + }else{ + filepath = lua_tostring(_NLL, 3); + } + function = lua_tostring(_NLL, 2); + npcindex = lua_tointeger(_NLL, 3); + charaindex = lua_tointeger(_NLL, 4); + msg = lua_tostring(_NLL, 5); + int flg = 3; + sasql_LUASQLAdv("",filepath,function,npcindex,charaindex,msg,flg); +} + +int NPC_Lua_SQL_FreeResult(lua_State *_NLL) +{ + CheckEx(_NLL,5); + int npcindex,charaindex; + char* sqlstr,*function,*filepath,*msg; + + + if(lua_isnil((_NLL), (3))){ + filepath = ""; + }else{ + filepath = lua_tostring(_NLL, 3); + } + function = lua_tostring(_NLL, 2); + npcindex = lua_tointeger(_NLL, 3); + charaindex = lua_tointeger(_NLL, 4); + msg = lua_tostring(_NLL, 5); + int flg = 4; + sasql_LUASQLAdv("",filepath,function,npcindex,charaindex,msg,flg); +} +#endif + + + + + + diff --git a/npc_lua/stdafx.cpp b/npc_lua/stdafx.cpp new file mode 100644 index 0000000..6207238 --- /dev/null +++ b/npc_lua/stdafx.cpp @@ -0,0 +1,8 @@ +// stdafx.cpp : ֻ׼ļԴļ +// npc_lua.pch ΪԤͷ +// stdafx.obj ԤϢ + +#include "stdafx.h" + +// TODO: STDAFX.H +// κĸͷļڴļ diff --git a/npc_lua/stdafx.h b/npc_lua/stdafx.h new file mode 100644 index 0000000..a767d59 --- /dev/null +++ b/npc_lua/stdafx.h @@ -0,0 +1,14 @@ +// stdafx.h : ׼ϵͳļİļ +// Ǿʹõĵ +// ضĿİļ +// + +#pragma once + +#include "targetver.h" + +#define WIN32_LEAN_AND_MEAN // Windows ͷųʹõ + + + +// TODO: ڴ˴óҪͷļ diff --git a/npc_lua/targetver.h b/npc_lua/targetver.h new file mode 100644 index 0000000..91794a5 --- /dev/null +++ b/npc_lua/targetver.h @@ -0,0 +1,13 @@ +#pragma once + +// º궨Ҫƽ̨Ҫƽ̨ +// ǾӦó蹦ܵ WindowsInternet Explorer ȲƷ +// 汾ָͨ汾Ͱ汾ƽ̨пõĹܣ +// + +// ҪԵָ汾ƽ̨޸ж塣 +// йزͬƽ̨ӦֵϢο MSDN +#ifndef _WIN32_WINNT // ָҪƽ̨ Windows Vista +#define _WIN32_WINNT 0x0600 // ֵΪӦֵ Windows 汾 +#endif + diff --git a/npcshandle.c b/npcshandle.c new file mode 100644 index 0000000..04eb441 --- /dev/null +++ b/npcshandle.c @@ -0,0 +1,104 @@ +0031:npc_lua:000000000:2:14=48041e4b:16=47d21313:002E:Makefile:05215:1:14=48041e4b:16=47d21313:INCFLAGS=-I. -I../include +FLTFLAGS="-s 1331200" +export FLTFLAGS + +#CFLAGS=-w -O3 -g $(INCFLAGS) +#CHOST="i686-pc-linux-gnu" +#CFLAGS=-march=pentium4 -w -O3 -pipe -mmmx -msse -msse2 $(INCFLAGS) +#CXXFLAGS="-march=pentium4 -O3 -pipe -fomit-frame-pointer" +CFLAGS=-w -O3 -pipe $(INCFLAGS) + +PROG=libnpc_lua.a + +SRC=npc_lua.c npc_lua_ex.c npc_lua_item.c npc_lua_nlg.c npc_lua_nl.c npc_lua_obj.c npc_lua_char.c npc_lua_battle.c + +OBJ=$(SRC:.c=.o) + +ifeq (0,$(MAKELEVEL)) +CC=gcc +RM=rm -f +AR=ar cr +MV=mv +RANLIB=ranlib +SED=sed +SHELL=/bin/sh +endif + +all: $(PROG) +$(PROG): $(OBJ) + $(RM) $(PROG) + $(AR) $(PROG) $(OBJ) + $(RANLIB) $(PROG) + +depend: + $(MV) Makefile Makefile.bak + $(SED) -ne '1,/^# DO NOT DELETE THIS LINE/p' Makefile.bak>Makefile + $(CC) $(INCFLAGS) -M $(SRC) >> Makefile + +clean: + $(RM) $(PROG) + $(RM) $(OBJ) + $(RM) *~ + +distclean: + $(RM) $(PROG) + $(RM) $(OBJ) + $(RM) *~ + $(MV) Makefile Makefile.bak + $(SED) -ne '1,/^# DO NOT DELETE THIS LINE/p' Makefile.bak>Makefile + $(RM) Makefile.bak + +# DO NOT DELETE THIS LINE +npc_lua.o: npc_lua.c ../include/npc_lua.h ../include/npc_lua_interface.h \ + ../include/version.h ../include/sasql.h /usr/include/stdio.h \ + /usr/include/_ansi.h /usr/include/newlib.h /usr/include/sys/config.h \ + /usr/include/machine/ieeefp.h /usr/include/cygwin/config.h \ + /usr/lib/gcc/i686-pc-cygwin/3.4.4/include/stddef.h \ + /usr/lib/gcc/i686-pc-cygwin/3.4.4/include/stdarg.h \ + /usr/include/sys/reent.h /usr/include/_ansi.h /usr/include/sys/_types.h \ + /usr/include/sys/lock.h /usr/include/sys/types.h \ + /usr/include/machine/_types.h /usr/include/machine/types.h \ + /usr/include/sys/features.h /usr/include/cygwin/types.h \ + /usr/include/sys/sysmacros.h /usr/include/stdint.h \ + /usr/include/endian.h /usr/include/sys/stdio.h /usr/include/sys/cdefs.h \ + /usr/include/stdlib.h /usr/include/machine/stdlib.h \ + /usr/include/alloca.h /usr/include/cygwin/stdlib.h \ + /usr/include/cygwin/wait.h /usr/include/netinet/in.h \ + /usr/include/cygwin/in.h /usr/include/cygwin/socket.h \ + /usr/include/asm/socket.h /usr/include/cygwin/if.h \ + /usr/include/sys/socket.h /usr/include/features.h \ + /usr/include/sys/time.h /usr/include/cygwin/sys_time.h \ + /usr/include/sys/select.h /usr/include/time.h \ + /usr/include/machine/time.h /usr/include/cygwin/time.h \ + /usr/include/signal.h /usr/include/sys/signal.h \ + /usr/include/cygwin/signal.h /usr/include/cygwin/sockios.h \ + /usr/include/sys/uio.h /usr/include/asm/byteorder.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/unistd.h \ + /usr/include/sys/unistd.h /usr/include/getopt.h /usr/include/strings.h \ + /usr/include/string.h /usr/include/sys/string.h /usr/include/errno.h \ + /usr/include/sys/errno.h ../include/correct_bug.h ../include/common.h \ + ../include/../lua/lua.h ../include/../lua/luaconf.h \ + /usr/lib/gcc/i686-pc-cygwin/3.4.4/include/limits.h \ + /usr/lib/gcc/i686-pc-cygwin/3.4.4/include/syslimits.h \ + /usr/include/limits.h ../include/../lua/lauxlib.h \ + ../include/../lua/lua.h /usr/include/assert.h ../include/util.h \ + ../include/char.h ../include/char_base.h ../include/skill.h \ + ../include/util.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/pthread.h /usr/include/sched.h \ + ../include/link.h ../include/char_data.h ../include/item.h \ + ../include/char.h ../include/char_base.h ../include/char_data.h \ + ../include/anim_tbl.h ../include/object.h ../include/battle.h \ + ../include/npcutil.h ../include/item.h ../include/readmap.h +npc_lua_ex.o: npc_lua_ex.c ../include/npc_lua.h \ + ../include/npc_lua_interface.h ../include/version.h ../include/sasql.h \ + /usr/include/stdio.h /usr/include/_ansi.h /usr/include/newlib.h \ + /usr/include/sys/config.h /usr/include/machine/ieeefp.h \ + /usr/include/cygwin/config.h \ + /usr/lib/gcc/i686-pc-cygwin/3.4.4/include/stddef.h \ + /usr/lib/gcc/i686-pc-cygwin/3.4.4/include/stdarg.h \ + /usr/include/sys/reent.h /usr/include/_ansi.h /usr/include/sys/_types.h \ + /usr/include/sys/lock.h /usr/include/sys/types.h \ + /usr/include/machine/_types.h /usr/include/machine/types.h \ + /usr/include/sys/features.h /usr/include/cygwin/types.h \ + /usr/include/sys/sysmacros.h /usr/include/stdint.h \ + /usr/include/endian.h /usr/include/sys/st \ No newline at end of file diff --git a/object.c b/object.c new file mode 100644 index 0000000..2135d28 --- /dev/null +++ b/object.c @@ -0,0 +1,481 @@ +#include "version.h" +#include + +#include +#include +#include +#include + +#include "handletime.h" + +#include "common.h" +#include "object.h" +#include "char_base.h" +#include "char.h" +#include "item.h" +#include "buf.h" +#include "readmap.h" +#include "pet.h" + +static Object *obj; +static int objnum; + +#ifdef _PET_ITEM +static int Restored = FALSE; +#endif + +BOOL initObjectArray( int num ) +{ + int i; + objnum = num; + obj = allocateMemory( sizeof( Object ) * objnum ); + + if( obj == NULL ) return FALSE; + for( i = 0 ; i < objnum ; i ++ ){ + memset( &obj[i], 0 , sizeof( Object )); + obj[i].type = OBJTYPE_NOUSE; + } + print( " %.2f MB MB ռ...", sizeof( Object ) * objnum / 1024.0 / 1024.0 ); + return TRUE; +} + + +BOOL endObjectArray( void ) +{ + freeMemory( obj ); + return TRUE; +} + +INLINE int _initObjectOne( char *file, int line, Object* ob ) +{ + static int allocobjnum = 0; + int i; + BOOL first; + + i = allocobjnum; + first = TRUE; + while( 1 ) { + if( !first && i >= allocobjnum ) { + fprint( "Can't allocate an object\n" ); + return -1; + } + if( obj[i].type == OBJTYPE_NOUSE ) { + if( MAP_addNewObj( ob->floor ,ob->x, ob->y, i ) == 1 ){ + memcpy( &obj[i] , ob , sizeof( Object ) ); + allocobjnum = ( i+1 >= objnum) ? 0:i+1; + return i; + }else{ + allocobjnum = ( i+1 >= objnum) ? 0:i+1; + fprint( "MAP_addNewObj error\n" ); + return -1; + } + }else { + if( ++i >= objnum ) { + i = 0; + first = FALSE; + } + } + } + + fprint( "Can't allocate an object\n" ); + return -1; +} + +void endObjectOne( int index ) +{ + if(objnum <= index || index < 0 )return; + + if( MAP_removeObj(obj[index].floor,obj[index].x, obj[index].y, + index) == FALSE){ +// fprint( "REMOVE OBJ ERROR floor:%d x:%d y:%d\n",obj[index].floor,obj[index].x, obj[index].y ); + } + obj[index].type = OBJTYPE_NOUSE; +} + +BOOL CHECKOBJECT( int index ) +{ + if( 0<=index && indextype = OBJTYPE_ITEM; + else if( strcmp( token , STOREGOLDID ) == 0 ) + one->type = OBJTYPE_GOLD; + else if( strcmp( token, STORECHARID) == 0 ) + one->type = OBJTYPE_CHARA; + for( i = 2 ; i < 5 ; i ++ ){ + char first[64]; + char second[64]; + ret = getStringFromIndexWithDelim(line,"|" ,i, + token,sizeof( token )); + if( ret == FALSE )return FALSE; + + ret = getStringFromIndexWithDelim(token,"=" ,1, first,sizeof( first )); + if( ret == FALSE )return FALSE; + ret = getStringFromIndexWithDelim(token,"=" ,2, second,sizeof( second )); + if( ret == FALSE )return FALSE; + + if( strcmp( first , "x" ) == 0 ) + one->x = atoi( second ); + else if( strcmp( first , "y" ) == 0 ) + one->y = atoi( second ); + else if( strcmp( first , "floor" ) == 0 ) + one->floor = atoi( second ); + } + { + char* findex = nindex( line , '|' , 4); + *stringstart = findex + 1; + } + return TRUE; +} + +BOOL storeObjects( char* dirname ) +{ + int i; + FILE* igfile; + char igfilename[256]; + + if( Restored == TRUE ){ + snprintf( igfilename ,sizeof( igfilename ) ,"%s/%s" ,dirname , + ITEMGOLDSTOREFILENAME ); + }else{ + snprintf( igfilename ,sizeof( igfilename ) ,"%s/%s_extra" ,dirname , + ITEMGOLDSTOREFILENAME ); + + print( "\n---- ݱУرGMSV ----- \n"); + } + igfile = fopen( igfilename , "w" ); + if( igfile == NULL ){ + print( "\n\n---- ܴ (%s) Ʒļ. ----- \n\n", igfilename ); + return FALSE; + } + + print( "ݱ..."); + for( i = 0 ; i < objnum ; i ++ ){ + switch( obj[i].type ){ + case OBJTYPE_ITEM: + { + fprintf( igfile , STOREITEMID "|x=%d|y=%d|floor=%d|%s\n" , + obj[i].x , obj[i].y ,obj[i].floor, + ITEM_makeStringFromItemIndex( obj[i].index,0 ) ); + break; + } + case OBJTYPE_GOLD: + { + fprintf( igfile , STOREGOLDID "|x=%d|y=%d|floor=%d|%d\n" , + obj[i].x , obj[i].y ,obj[i].floor, obj[i].index ); + break; + } + case OBJTYPE_CHARA: + { + int petindex = obj[i].index; + if( CHAR_CHECKINDEX( petindex) ) { + if( CHAR_getInt( obj[i].index, CHAR_WHICHTYPE) == CHAR_TYPEPET){ + fprintf( igfile , STORECHARID "|x=%d|y=%d|floor=%d|%s\n" , + obj[i].x , obj[i].y ,obj[i].floor, + CHAR_makePetStringFromPetIndex( obj[i].index ) ); + } + } + break; + } + default: + break; + } + } + fclose( igfile ); + print( "\n"); +// system( "./itemda.pl" ); + print( "ݱ\n"); + return TRUE; +} +#endif + +int detectStoreFile( char* filename ) +{ + FILE* f; + char buffer[10]; + f = fopen ( filename ,"r" ); + if( f == NULL )return 3; + + if( fgets( buffer, sizeof( buffer ), f ) == NULL ){ + fclose(f); + return 3; + } + + if( strncmp(buffer,STOREITEMID,sizeof(STOREITEMID) ) == 0 || + strncmp(buffer,STOREGOLDID,sizeof(STOREGOLDID) ) == 0 ){ + fclose(f); + return 2; + } + + fclose(f); + return 3; +} + +#ifdef _PET_ITEM +BOOL restoreObjects( char* dirname ) +{ + char igfilename[512]; + FILE* file; + char line[2048]; + + snprintf( igfilename, sizeof(igfilename), "%s/%s", dirname, ITEMGOLDSTOREFILENAME ); + file = fopen( igfilename , "r" ); + if( file == NULL ){ + Restored = TRUE; + return FALSE; + } + while( fgets( line, sizeof( line ), file ) != NULL ){ + Object one; + char *string; + chomp( line ); + if( checkObjectStoreFile( line, &one ,&string ) == FALSE ) + continue; + switch( one.type ){ + case OBJTYPE_ITEM: + { + ITEM_Item itmone; + BOOL ret; + int objindex; + ret = ITEM_makeExistItemsFromStringToArg( string, &itmone, 0 ); + if( ret == TRUE ){ + one.index = ITEM_initExistItemsOne( &itmone ); + if( one.index == -1 ) + break; + objindex = initObjectOne( &one ); + ITEM_setWorkInt(one.index,ITEM_WORKCHARAINDEX,-1); + ITEM_setWorkInt(one.index,ITEM_WORKOBJINDEX,objindex); + } + break; + } + case OBJTYPE_GOLD: + one.index = atoi( string ); + initObjectOne( &one ); + break; + case OBJTYPE_CHARA: + { + Char ch; + int ret; + ret = CHAR_makePetFromStringToArg(string,&ch, -1); + if( ret ) { + Object object; + int objindex; + int petindex = PET_initCharOneArray( &ch ); + if( petindex < 0 ) { + print( "ʧܡ\n"); + } + object.type = OBJTYPE_CHARA; + object.index = petindex; + object.x = ch.data[CHAR_X]; + object.y = ch.data[CHAR_Y]; + object.floor = ch.data[CHAR_FLOOR]; + objindex = initObjectOne( &object ); + if( objindex == -1 ) { + CHAR_endCharOneArray( petindex ); + }else { + CHAR_setWorkInt( petindex,CHAR_WORKOBJINDEX,objindex ); + } + } + break; + } + default: + break; + } + } + fclose( file ); + Restored = TRUE; + + return TRUE; +} +#endif + +#ifdef _CAX_LNS_MAPSUOXU +INLINE int get_mappointindex( int fl,int x, int y)//ҳͼ͵ +{ + int i; + for(i=0;i +#include +#include +#include "common.h" +#include "net.h" + +#ifdef _SEND_EFFECT // WON ADD ACѩЧ +#include "chatmagic.h" +#endif +extern char *DebugMainFunction; +#define IS_2BYTEWORD( _a_ ) ( (char)(0x80) <= (_a_) && (_a_) <= (char)(0xFF) ) + +/* +90 :

  • clienttoserver ACServerLogin(string servername,string serverpas);
    +91 : ءةӡʧӡ̼ +92 : ëؤ𼰷̼ëئͻӡ굩ëئУ +93 :

    +94 :
    +95 :
    string servername +96 :
    ӡ acserv.cfɬýľ£ +97 :
    string serverpas +98 :
    ӡɵacserv.cfɬýľ£ +99 :
    +100 : +*/ + +#ifdef _ALLDOMAN // (ɿ) Syu ADD аNPC +void saacproto_UpdataStele_send( int fd , char *cdkey , char *name , char *title , int level , int trns , int time , int floor) +{ + saacproto_CreateHeader( saacproto.work , "UpdataStele" ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( cdkey ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( name ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( title ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_int( level ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_int( trns ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_int( time ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_int( floor ) ,saacproto.workbufsize ); + saacproto_Send( fd , saacproto.work ); +} +#endif + +void saacproto_ACServerLogin_send( int fd,char* servername,char* serverpas ) +{ + saacproto_CreateHeader( saacproto.work , "ACServerLogin" ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( servername ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( serverpas ) ,saacproto.workbufsize ); + saacproto_Send( fd , saacproto.work ); +} +/* +114 :
  • clienttoserver ACServerLogout(void);
    +115 : ӡʧӡշʧ +116 : ӡ巽Ȼ ľ£׻Ȼľ帲ʧӡ +117 : ߯Ϸëƥؤ£ +118 :
    +119 :
    +120 :
    +121 : +122 : +*/ + +void saacproto_ACServerLogout_send( int fd ) +{ + saacproto_CreateHeader( saacproto.work , "ACServerLogout" ); + saacproto_strcatsafe( saacproto.work , "" ,saacproto.workbufsize ); + saacproto_Send( fd , saacproto.work ); +} + +#ifdef _PKSEVER_VER +void saacproto_ACCharList_send( int fd,char* id,char* pas,int mesgid, int star) +#else +void saacproto_ACCharList_send( int fd,char* id,char* pas,int mesgid ) +#endif +{ + saacproto_CreateHeader( saacproto.work , "ACCharList" ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( id ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( pas ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_int( mesgid ) ,saacproto.workbufsize ); + +#ifdef _PKSEVER_VER + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_int( star ) ,saacproto.workbufsize ); +#endif + saacproto_Send( fd , saacproto.work ); +} + +void saacproto_ACCharLoad_send( int fd,char* id,char* pas,char* charname,int lock,char* opt,int mesgid,char* ip ) +{ + saacproto_CreateHeader( saacproto.work , "ACCharLoad" ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( id ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( pas ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( charname ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_int( lock ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( opt ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_int( mesgid ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( ip ) ,saacproto.workbufsize ); + saacproto_Send( fd , saacproto.work ); +} + +#ifdef _NEWSAVE +void saacproto_ACCharSave_send( int fd,char* id,char* charname,char* opt,char* charinfo,int unlock,int mesgid,int saveindex ) +#else +void saacproto_ACCharSave_send( int fd,char* id,char* charname,char* opt,char* charinfo,int unlock,int mesgid ) +#endif +{ + saacproto_CreateHeader( saacproto.work , "ACCharSave" ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( id ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( charname ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( opt ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( charinfo ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_int( unlock ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_int( mesgid ) ,saacproto.workbufsize ); +#ifdef _NEWSAVE + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_int( saveindex ) ,saacproto.workbufsize ); +#endif + saacproto_Send( fd , saacproto.work ); +} + +void saacproto_ACCharDelete_send( int fd,char* id,char* passwd,char* charname,char* option,int mesgid, char* userip ) +{ + saacproto_CreateHeader( saacproto.work , "ACCharDelete" ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( id ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( passwd ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( charname ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( option ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_int( mesgid ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( userip ) ,saacproto.workbufsize ); + saacproto_Send( fd , saacproto.work ); +} + +void saacproto_ACLock_send( int fd,char* id,int lock,int mesgid ) +{ + saacproto_CreateHeader( saacproto.work , "ACLock" ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( id ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_int( lock ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_int( mesgid ) ,saacproto.workbufsize ); + saacproto_Send( fd , saacproto.work ); +} + +void saacproto_ACUCheck_send( int fd,char* mem_id,int status ) +{ + saacproto_CreateHeader( saacproto.work , "ACUCheck" ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( mem_id ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_int( status ) ,saacproto.workbufsize ); + saacproto_Send( fd , saacproto.work ); +} + +void saacproto_DBUpdateEntryString_send( int fd,char* table,char* key,char* value,int msgid,int msgid2 ) +{ + saacproto_CreateHeader( saacproto.work , "DBUpdateEntryString" ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( table ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( key ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( value ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_int( msgid ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_int( msgid2 ) ,saacproto.workbufsize ); + saacproto_Send( fd , saacproto.work ); +} + +void saacproto_DBDeleteEntryString_send( int fd,char* table,char* key,int msgid,int msgid2 ) +{ + saacproto_CreateHeader( saacproto.work , "DBDeleteEntryString" ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( table ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( key ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_int( msgid ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_int( msgid2 ) ,saacproto.workbufsize ); + saacproto_Send( fd , saacproto.work ); +} + +void saacproto_DBGetEntryString_send( int fd,char* table,char* key,int msgid,int msgid2 ) +{ + saacproto_CreateHeader( saacproto.work , "DBGetEntryString" ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( table ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( key ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_int( msgid ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_int( msgid2 ) ,saacproto.workbufsize ); + saacproto_Send( fd , saacproto.work ); +} + +void saacproto_DBUpdateEntryInt_send( int fd,char* table,char* key,int value,char* info,int msgid,int msgid2 ) +{ + saacproto_CreateHeader( saacproto.work , "DBUpdateEntryInt" ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( table ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( key ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_int( value ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( info ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_int( msgid ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_int( msgid2 ) ,saacproto.workbufsize ); + saacproto_Send( fd , saacproto.work ); +} + +void saacproto_DBGetEntryRank_send( int fd,char* table,char* key,int msgid,int msgid2 ) +{ + saacproto_CreateHeader( saacproto.work , "DBGetEntryRank" ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( table ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( key ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_int( msgid ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_int( msgid2 ) ,saacproto.workbufsize ); + saacproto_Send( fd , saacproto.work ); +} + +void saacproto_DBDeleteEntryInt_send( int fd,char* table,char* key,int msgid,int msgid2 ) +{ + saacproto_CreateHeader( saacproto.work , "DBDeleteEntryInt" ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( table ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( key ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_int( msgid ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_int( msgid2 ) ,saacproto.workbufsize ); + saacproto_Send( fd , saacproto.work ); +} + +void saacproto_DBGetEntryInt_send( int fd,char* table,char* key,int msgid,int msgid2 ) +{ + saacproto_CreateHeader( saacproto.work , "DBGetEntryInt" ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( table ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( key ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_int( msgid ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_int( msgid2 ) ,saacproto.workbufsize ); + saacproto_Send( fd , saacproto.work ); +} + +void saacproto_DBGetEntryByRank_send( int fd,char* table,int rank_start,int rank_end,int msgid,int msgid2 ) +{ + saacproto_CreateHeader( saacproto.work , "DBGetEntryByRank" ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( table ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_int( rank_start ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_int( rank_end ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_int( msgid ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_int( msgid2 ) ,saacproto.workbufsize ); + saacproto_Send( fd , saacproto.work ); +} + +void saacproto_DBGetEntryByCount_send( int fd,char* table,int count_start,int num,int msgid,int msgid2 ) +{ + saacproto_CreateHeader( saacproto.work , "DBGetEntryByCount" ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( table ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_int( count_start ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_int( num ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_int( msgid ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_int( msgid2 ) ,saacproto.workbufsize ); + saacproto_Send( fd , saacproto.work ); +} +/* +608 :
  • clienttoserver Broadcast( string id, string charname, string message , int flag );
    +609 : ءةӡ帲ƻѨë˪ +610 : ͻءةӡƻ Ԫ⻥˪ľ£ +611 : id , charname ʹľ¼ƥ ¦ëֹף +612 : ٯ ɡë̤ئʻз +613 :
    +614 :
    string id +615 :
    user ID +616 :
    string charname +617 :
    ƽҷ (޵ئ) +618 :
    string message +619 :
    ˪ľ¶۱ءةӡѱ +620 :
    +*/ + +void saacproto_Broadcast_send( int fd,char* id,char* charname,char* message,int flag ) +{ + saacproto_CreateHeader( saacproto.work , "Broadcast" ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( id ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( charname ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( message ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_int( flag ) ,saacproto.workbufsize ); + saacproto_Send( fd , saacproto.work ); +} +/* +634 :
  • clienttoserver Message( string id_from, string charname_from, string id_to, string charname_to, string message , int option );
    +635 : ̼ë˪ +636 :
    +637 :
    string id_from +638 :
    from ID +639 :
    string charname_from +640 :
    from Character name +641 :
    string id_to +642 :
    to ID +643 :
    string charname_to +644 :
    to character name +645 :
    string message +646 :
    +647 :
    int option +648 :
    羮ǷǷ ľľ£ +649 : ľëءةӡ ƥʧӡ +650 : 婳 ئ +651 :
    +*/ + +void saacproto_Message_send( int fd,char* id_from,char* charname_from,char* id_to,char* charname_to,char* message,int option ) +{ + saacproto_CreateHeader( saacproto.work , "Message" ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( id_from ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( charname_from ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( id_to ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( charname_to ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( message ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_int( option ) ,saacproto.workbufsize ); + saacproto_Send( fd , saacproto.work ); +} + +void saacproto_MessageAck_send( int fd,char* id,char* charname,char* result,int mesgid ) +{ + saacproto_CreateHeader( saacproto.work , "MessageAck" ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( id ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( charname ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( result ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_int( mesgid ) ,saacproto.workbufsize ); + saacproto_Send( fd , saacproto.work ); +} + +void saacproto_MessageFlush_send( int fd,char* id,char* charname ) +{ + saacproto_CreateHeader( saacproto.work , "MessageFlush" ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( id ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( charname ) ,saacproto.workbufsize ); + saacproto_Send( fd , saacproto.work ); +} + +/************************************************************ + * CoolFish: Family 2001/5/18 + ***********************************************************/ +#ifdef _PERSONAL_FAME +void saacproto_ACAddFM_send(int fd, char *fmname, char *fmleadername, + char *fmleaderid, int fmleaderlv, char *petname, char *petattr, + char *fmrule, int fmsprite, int fmleadergrano, int fame, int charfdid) +#else +void saacproto_ACAddFM_send(int fd, char *fmname, char *fmleadername, + char *fmleaderid, int fmleaderlv, char *petname, char *petattr, + char *fmrule, int fmsprite, int fmleadergrano, int charfdid) +#endif +{ + saacproto_CreateHeader(saacproto.work, "ACAddFM"); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_string(fmname), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_string(fmleadername), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_string(fmleaderid), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(fmleaderlv), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_string(petname), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_string(petattr), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_string(fmrule), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(fmsprite), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(fmleadergrano), saacproto.workbufsize); +// #ifdef _PERSONAL_FAME + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(fame), saacproto.workbufsize); +// #endif + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(charfdid), saacproto.workbufsize); + saacproto_Send(fd, saacproto.work); +} +#ifdef _PERSONAL_FAME // Arminius: +void saacproto_ACJoinFM_send(int fd, char *fmname, int fmindex, char *charname, + char *charid, int charlv, int index, int fame, int charfdid) +#else +void saacproto_ACJoinFM_send(int fd, char *fmname, int fmindex, char *charname, + char *charid, int charlv, int index, int charfdid) +#endif +{ + saacproto_CreateHeader(saacproto.work, "ACJoinFM"); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_string(fmname), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(fmindex), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_string(charname), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_string(charid), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(charlv), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(index), saacproto.workbufsize); +// #ifdef _PERSONAL_FAME // Arminius: + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(fame), saacproto.workbufsize); +// #endif + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(charfdid), saacproto.workbufsize); + saacproto_Send(fd, saacproto.work); +} +void saacproto_ACLeaveFM_send(int fd, char *fmname, int fmindex, char *charname, + char *charid, int index, int charfdid) +{ + saacproto_CreateHeader(saacproto.work, "ACLeaveFM"); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_string(fmname), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(fmindex), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_string(charname), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_string(charid), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(index), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(charfdid), saacproto.workbufsize); + saacproto_Send(fd, saacproto.work); +} +void saacproto_ACDelFM_send(int fd, char *fmname, int fmindex, int index, + char *charname, char *charid, int charfdid) +{ + saacproto_CreateHeader(saacproto.work, "ACDelFM"); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_string(fmname), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(fmindex), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(index), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_string(charname), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_string(charid), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(charfdid), saacproto.workbufsize); + saacproto_Send(fd, saacproto.work); +} + +void saacproto_ACShowFMList_send(int fd) +{ + saacproto_CreateHeader(saacproto.work, "ACShowFMList"); + saacproto_Send(fd, saacproto.work); +} + +void saacproto_ACShowMemberList_send(int fd, int index) +{ + saacproto_CreateHeader(saacproto.work, "ACShowMemberList"); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_string("MemberList"), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(index), saacproto.workbufsize); + saacproto_Send(fd, saacproto.work); +} +void saacproto_ACFMDetail_send(int fd, char *fmname, int fmindex, int index, int charfdid) +{ + saacproto_CreateHeader(saacproto.work, "ACFMDetail"); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_string(fmname), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(fmindex), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(index), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(charfdid), saacproto.workbufsize); + saacproto_Send(fd, saacproto.work); +} +#ifdef _FMVER21 +void saacproto_ACMemberJoinFM_send(int fd, char *fmname, int fmindex, + char *charname, int charindex, int index, int result, int meindex, + int charfdid) +#else +void saacproto_ACMemberJoinFM_send(int fd, char *fmname, int fmindex, + char *charname, int charindex, int index, int result, int charfdid) +#endif +{ + saacproto_CreateHeader(saacproto.work, "ACMemberJoinFM"); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_string(fmname), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(fmindex), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_string(charname), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(charindex), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(index), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(result), saacproto.workbufsize); +#ifdef _FMVER21 + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(meindex), saacproto.workbufsize); +#endif + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(charfdid), saacproto.workbufsize); + saacproto_Send(fd, saacproto.work); +} +#ifdef _FMVER21 +void saacproto_ACMemberLeaveFM_send(int fd, char *fmname, int fmindex, + char *charname, int charindex, int index, int meindex, int charfdid) +#else +void saacproto_ACMemberLeaveFM_send(int fd, char *fmname, int fmindex, + char *charname, int charindex, int index, int charfdid) +#endif +{ + saacproto_CreateHeader(saacproto.work, "ACMemberLeaveFM"); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_string(fmname), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(fmindex), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_string(charname), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(charindex), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(index), saacproto.workbufsize); +#ifdef _FMVER21 + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(meindex), saacproto.workbufsize); +#endif + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(charfdid), saacproto.workbufsize); + saacproto_Send(fd, saacproto.work); +} +#ifdef _FM_MODIFY +void saacproto_ACFMCharLogin_send(int fd, char *fmname, int fmindex, char *charname, + char *charid, int charlv, int eventflag, int charfdid,int gsnum) +#else + #ifdef _FMVER21 + void saacproto_ACFMCharLogin_send(int fd, char *fmname, int fmindex, char *charname, + char *charid, int charlv, int eventflag, int charfdid) + #else + void saacproto_ACFMCharLogin_send(int fd, char *fmname, int fmindex, char *charname, + char *charid, int charlv, int charfdid) + #endif +#endif +{ + saacproto_CreateHeader(saacproto.work, "ACFMCharLogin"); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_string(fmname), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(fmindex), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_string(charname), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_string(charid), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(charlv), saacproto.workbufsize); +#ifdef _FMVER21 + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(eventflag), saacproto.workbufsize); +#endif + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(charfdid), saacproto.workbufsize); +#ifdef _FM_MODIFY + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(gsnum), saacproto.workbufsize); +#endif + saacproto_Send(fd, saacproto.work); +} + +void saacproto_ACFMCharLogout_send(int fd, char *fmname, int fmindex, char *charname, + char *charid, int charlv, int index, int charfdid) +{ + saacproto_CreateHeader(saacproto.work, "ACFMCharLogout"); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_string(fmname), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(fmindex), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_string(charname), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_string(charid), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(charlv), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(index), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(charfdid), saacproto.workbufsize); + saacproto_Send(fd, saacproto.work); +} +void saacproto_ACFMReadMemo_send(int fd, int index) +{ + saacproto_CreateHeader(saacproto.work, "ACFMReadMemo"); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_string("ReadMemo"), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(index), saacproto.workbufsize); + saacproto_Send(fd, saacproto.work); +} +void saacproto_ACFMWriteMemo_send(int fd, char *fmname, int fmindex, + char *data, int index) +{ + saacproto_CreateHeader(saacproto.work, "ACFMWriteMemo"); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_string(fmname), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(fmindex), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_string(data), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(index), saacproto.workbufsize); + saacproto_Send(fd, saacproto.work); +} +void saacproto_ACFMPointList_send(int fd) +{ + saacproto_CreateHeader(saacproto.work, "ACFMPointList"); + saacproto_Send(fd, saacproto.work); +} + +void saacproto_ACSetFMPoint_send(int fd, char *fmname, int fmindex, int index, + int fmpointindex, int fl, int x, int y, int charfdid) +{ + saacproto_CreateHeader(saacproto.work, "ACSetFMPoint"); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_string(fmname), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(fmindex), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(index), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(fmpointindex), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(fl), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(x), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(y), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(charfdid), saacproto.workbufsize); + saacproto_Send(fd, saacproto.work); +} +void saacproto_ACFixFMPoint_send(int fd, char *winfmname, int winfmindex, + int winindex, char *losefmname, int losefmindex, int loseindex, + int village) +{ + saacproto_CreateHeader(saacproto.work, "ACFixFMPoint"); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_string(winfmname), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(winfmindex), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(winindex), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_string(losefmname), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(losefmindex), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(loseindex), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(village), saacproto.workbufsize); + saacproto_Send(fd, saacproto.work); +} +void saacproto_ACFMAnnounce_send(int fd, char *fmname, int fmindex, int index, + char *data, int color) +{ + saacproto_CreateHeader(saacproto.work, "ACFMAnnounce"); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_string(fmname), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(fmindex), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(index), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_string(data), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(color), saacproto.workbufsize); + saacproto_Send(fd, saacproto.work); +} +void saacproto_ACShowTopFMList_send(int fd, int kindflag) +{ + saacproto_CreateHeader(saacproto.work, "ACShowTopFMList"); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_string("ShowTopFMList"), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(kindflag), saacproto.workbufsize); + saacproto_Send(fd, saacproto.work); +} + +void saacproto_ACFixFMData_send(int fd, char *fmname, int fmindex, int index, + int kindflag, char *data1, char *data2, int charindex, int charfdid) +{ + saacproto_CreateHeader(saacproto.work, "ACFixFMData"); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_string(fmname), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(fmindex), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(index), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(kindflag), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_string(data1), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_string(data2), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(charindex), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(charfdid), saacproto.workbufsize); + saacproto_Send(fd, saacproto.work); +} +void saacproto_ACFixFMPK_send(int fd, char *winfmname, int winfmindex, + int winindex, char *losefmname, int losefmindex, int loseindex) +{ + saacproto_CreateHeader(saacproto.work, "ACFixFMPK"); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_string(winfmname), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(winfmindex), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(winindex), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_string(losefmname), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(losefmindex), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(loseindex), saacproto.workbufsize); + saacproto_Send(fd, saacproto.work); +} +void saacproto_ACGMFixFMData_send(int fd, int index, char *charid, char *cmd, + char *data, int charfdid) +{ + saacproto_CreateHeader(saacproto.work, "ACGMFixFMData"); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_string("ACGMFixFMData"), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(index), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_string(charid), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_string(cmd), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_string(data), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(charfdid), saacproto.workbufsize); + saacproto_Send(fd, saacproto.work); +} +void saacproto_ACGetFMData_send(int fd, char *fmname, int fmindex, int index, + int kindflag, int charfdid) +{ + saacproto_CreateHeader(saacproto.work, "ACGetFMData"); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_string(fmname), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(fmindex), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(index), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(kindflag), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(charfdid), saacproto.workbufsize); + saacproto_Send(fd, saacproto.work); +} + +// Arminius 7.26 manor pk acknowledge +void saacproto_ACManorPKAck_send(int fd, char *data) +{ + saacproto_CreateHeader(saacproto.work, "ACManorPKAck"); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_string(data), saacproto.workbufsize); + saacproto_Send(fd, saacproto.work); +} + +void saacproto_ACreLoadFmData_send( int fd, int type, int data) +{ + saacproto_CreateHeader( saacproto.work, "ACreLoadFmData"); + saacproto_strcatsafe( saacproto.work, saacproto_mkstr_int( type), saacproto.workbufsize); + saacproto_strcatsafe( saacproto.work, saacproto_mkstr_int( data), saacproto.workbufsize); + saacproto_Send( fd, saacproto.work); +} + +#ifdef _ACFMPK_LIST +void saacproto_ACLoadFmPk_send(int fd, int fmpks_pos) +{ + saacproto_CreateHeader(saacproto.work, "ACLoadFmPk"); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(fmpks_pos), saacproto.workbufsize); + saacproto_Send(fd, saacproto.work); +} + + +void saacproto_ACSendFmPk_send(int fd, int toindex, int PkFlg, int fmpks_pos, char *msg) +{ + saacproto_CreateHeader(saacproto.work, "ACSendFmPk"); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(fmpks_pos), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int( toindex), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int( PkFlg), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_string(msg), saacproto.workbufsize); + saacproto_Send(fd, saacproto.work); +} +#endif + +void saacproto_ACAuctionSold_send(int fd, char *data) +{ + saacproto_CreateHeader(saacproto.work, "ACAuctionSold"); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_string(data), saacproto.workbufsize); + saacproto_Send(fd, saacproto.work); +} + +void saacproto_ACDelFmPoint_send(int fd, int fmindex) +{ + saacproto_CreateHeader(saacproto.work, "ACDelFmPoint"); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(fmindex), saacproto.workbufsize); + saacproto_Send(fd, saacproto.work); +} + + +extern char saacretfunc[255]; +int saacproto_ClientDispatchMessage(int fd ,char*line) +{ + int msgid; + char funcname[255]; + char *line_bak; + line_bak=line; + saacproto_strcpysafe( saacproto.work , line, saacproto.workbufsize ); + saacproto_splitString( saacproto.work); + saacproto_GetMessageInfo( &msgid , funcname , sizeof(funcname),saacproto.token_list); + strcpy( saacretfunc , funcname ); + if( strcmp( funcname , "ACGmsvDownRequest" ) == 0 ){ + int min; + min = saacproto_demkstr_int( saacproto.token_list[2] ); + saacproto_ACGmsvDownRequest_recv( fd,min); + return 0; + } + + if( strcmp( funcname , "ACServerLogin" ) == 0 ){ + char* result; + char* data; + result = saacproto_wrapStringAddr( saacproto_stringwrapper[1] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[2] )); + data = saacproto_wrapStringAddr( saacproto_stringwrapper[2] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[3] )); + saacproto_ACServerLogin_recv( fd,result,data); + return 0; + } + + if( strcmp( funcname , "ACCharList" ) == 0 ){ + char* result; + char* output; + int id; + result = saacproto_wrapStringAddr( saacproto_stringwrapper[1] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[2] )); + output = saacproto_wrapStringAddr( saacproto_stringwrapper[2] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[3] )); + id = saacproto_demkstr_int( saacproto.token_list[4] ); + saacproto_ACCharList_recv( fd,result,output,id); + return 0; + } + + if( strcmp( funcname , "ACCharLoad" ) == 0 ){ + char* result=NULL; + char* data=NULL; + int id; +#ifdef _NEWSAVE + int saveindex; +#endif + result = saacproto_wrapStringAddr( saacproto_stringwrapper[1] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[2] )); + data = saacproto_wrapStringAddr( saacproto_stringwrapper[2] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[3] )); + id = saacproto_demkstr_int( saacproto.token_list[4] ); + if( data == NULL ) return 0; + if( result == NULL ) return 0; + +#ifdef _NEWSAVE + saveindex = saacproto_demkstr_int( saacproto.token_list[5] ); + saacproto_ACCharLoad_recv( fd,result,data,id,saveindex); +#else + saacproto_ACCharLoad_recv( fd,result,data,id, -1); +#endif + return 0; + } + + if( strcmp( funcname , "ACCharSave" ) == 0 ){ + char* result; + char* data; + int id; + result = saacproto_wrapStringAddr( saacproto_stringwrapper[1] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[2] )); + data = saacproto_wrapStringAddr( saacproto_stringwrapper[2] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[3] )); + id = saacproto_demkstr_int( saacproto.token_list[4] ); + saacproto_ACCharSave_recv( fd,result,data,id); + return 0; + } + + if( strcmp( funcname , "ACCharDelete" ) == 0 ){ + char* result; + char* data; + int id; + result = saacproto_wrapStringAddr( saacproto_stringwrapper[1] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[2] )); + data = saacproto_wrapStringAddr( saacproto_stringwrapper[2] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[3] )); + id = saacproto_demkstr_int( saacproto.token_list[4] ); + saacproto_ACCharDelete_recv( fd,result,data,id); + return 0; + } + + if( strcmp( funcname , "ACLock" ) == 0 ){ + char* result; + char* data; + int id; + result = saacproto_wrapStringAddr( saacproto_stringwrapper[1] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[2] )); + data = saacproto_wrapStringAddr( saacproto_stringwrapper[2] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[3] )); + id = saacproto_demkstr_int( saacproto.token_list[4] ); + saacproto_ACLock_recv( fd,result,data,id); + return 0; + } + +#ifdef _WAEI_KICK + if( strcmp( funcname , "ACKick" ) == 0 ){ + int act; + char* data; + int id; + act = saacproto_demkstr_int( saacproto.token_list[2] ); + data = saacproto_wrapStringAddr( saacproto_stringwrapper[2] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[3] )); + id = saacproto_demkstr_int( saacproto.token_list[4] ); + saacproto_ACKick_recv( fd, act, data, id); + return 0; + } +#endif + +#ifdef _CHAR_POOLITEM + + if( strcmp( funcname , "ACSavePoolItem" ) == 0 ){ + char* result; + char* data; + int id; + + result = saacproto_wrapStringAddr( saacproto_stringwrapper[1] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[2] )); + data = saacproto_wrapStringAddr( saacproto_stringwrapper[2] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[3] )); + id = saacproto_demkstr_int( saacproto.token_list[4] ); + saacproto_ACCharSavePoolItem_recv( fd, result, data, id); + return 0; + } + + if( strcmp( funcname , "ACGetPoolItem" ) == 0 ){ + char* result; + char* data; + int id, npcid; + + result = saacproto_wrapStringAddr( saacproto_stringwrapper[1] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[2] )); + data = saacproto_wrapStringAddr( saacproto_stringwrapper[2] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[3] )); + id = saacproto_demkstr_int( saacproto.token_list[4] ); + npcid = saacproto_demkstr_int( saacproto.token_list[5] ); + saacproto_ACCharGetPoolItem_recv( fd, result, data, id, npcid); + return 0; + } +#endif + + +#ifdef _CHAR_POOLPET + + if( strcmp( funcname , "ACSavePoolPet" ) == 0 ){ + char* result; + char* data; + int id; + + result = saacproto_wrapStringAddr( saacproto_stringwrapper[1] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[2] )); + data = saacproto_wrapStringAddr( saacproto_stringwrapper[2] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[3] )); + id = saacproto_demkstr_int( saacproto.token_list[4] ); + saacproto_ACCharSavePoolPet_recv( fd, result, data, id); + return 0; + } + + if( strcmp( funcname , "ACGetPoolPet" ) == 0 ){ + char* result; + char* data; + int id, npcid; + + result = saacproto_wrapStringAddr( saacproto_stringwrapper[1] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[2] )); + data = saacproto_wrapStringAddr( saacproto_stringwrapper[2] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[3] )); + id = saacproto_demkstr_int( saacproto.token_list[4] ); + npcid = saacproto_demkstr_int( saacproto.token_list[5] ); + saacproto_ACCharGetPoolPet_recv( fd, result, data, id, npcid); + return 0; + } +#endif + + if( strcmp( funcname , "ACUCheck" ) == 0 ){ + char* mem_id; + mem_id = saacproto_wrapStringAddr( saacproto_stringwrapper[1] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[2] )); + saacproto_ACUCheck_recv( fd,mem_id); + return 0; + } +/* +354 :
  • servertoclient DBUpdateEntryString( string result, string table, string key, int msgid, int msgid2 );
    +355 : Ѩ ƻּص ئƥ ƻ +356 :
    +357 :
    string result +358 :
    successful failed +359 :
    string table +360 :
    +361 :
    int msgid +362 :
    +363 :
    int msgid2 +364 :
    +365 :
    +366 : +*/ + + if( strcmp( funcname , "DBUpdateEntryString" ) == 0 ){ + char* result; + char* table; + char* key; + int msgid; + int msgid2; + result = saacproto_wrapStringAddr( saacproto_stringwrapper[1] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[2] )); + table = saacproto_wrapStringAddr( saacproto_stringwrapper[2] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[3] )); + key = saacproto_wrapStringAddr( saacproto_stringwrapper[3] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[4] )); + msgid = saacproto_demkstr_int( saacproto.token_list[5] ); + msgid2 = saacproto_demkstr_int( saacproto.token_list[6] ); + saacproto_DBUpdateEntryString_recv( fd,result,table,key,msgid,msgid2); + return 0; + } +/* +379 :
  • servertoclient DBDeleteEntryString( string result, string table, string key , int msgid , int msgid2 );
    +380 : ٯ ޼ּ +381 :
    +382 :
    string result +383 :
    successful / failed +384 :
    string table +385 :
    +386 :
    string key +387 :
    +388 :
    int msgid +389 :
    +390 :
    int msgid2 +391 :
    +392 :
    +393 : +*/ + + if( strcmp( funcname , "DBDeleteEntryString" ) == 0 ){ + char* result; + char* table; + char* key; + int msgid; + int msgid2; + result = saacproto_wrapStringAddr( saacproto_stringwrapper[1] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[2] )); + table = saacproto_wrapStringAddr( saacproto_stringwrapper[2] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[3] )); + key = saacproto_wrapStringAddr( saacproto_stringwrapper[3] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[4] )); + msgid = saacproto_demkstr_int( saacproto.token_list[5] ); + msgid2 = saacproto_demkstr_int( saacproto.token_list[6] ); + saacproto_DBDeleteEntryString_recv( fd,result,table,key,msgid,msgid2); + return 0; + } +/* +406 :
  • servertoclient DBGetEntryString( string result, string value, string table, string key, int msgid, int msgid2 );
    +407 : ԻƼ߯Ի +408 :
    +409 :
    string result +410 :
    successful / failed +411 :
    string value +412 :
    +413 :
    string table +414 :
    +415 :
    string key +416 :
    +417 :
    int msgid +418 :
    +419 :
    int msgid2 +420 :
    +421 :
    +422 : +*/ + + if( strcmp( funcname , "DBGetEntryString" ) == 0 ){ +/* char* result; + char* value; + char* table; + char* key; + int msgid; + int msgid2; + result = saacproto_wrapStringAddr( saacproto_stringwrapper[1] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[2] )); + value = saacproto_wrapStringAddr( saacproto_stringwrapper[2] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[3] )); + table = saacproto_wrapStringAddr( saacproto_stringwrapper[3] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[4] )); + key = saacproto_wrapStringAddr( saacproto_stringwrapper[4] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[5] )); + msgid = saacproto_demkstr_int( saacproto.token_list[6] ); + msgid2 = saacproto_demkstr_int( saacproto.token_list[7] ); + saacproto_DBGetEntryString_recv( fd,result,value,table,key,msgid,msgid2);*/ + return 0; + } +/* +445 :
  • servertoclient DBUpdateEntryInt( string result , string table, string key, int msgid, int msgid2 );
    +446 : DBUpdateEntry +447 :
    +448 :
    string result +449 :
    succesful/failed +450 :
    string table +451 :
    Ƥ ë +452 :
    string key +453 :
    ƽë +454 :
    int msgid, int msgid2 +455 :
    msgid ë߯ʣ +456 :
    +457 :

    +458 : +*/ + + if( strcmp( funcname , "DBUpdateEntryInt" ) == 0 ){ + char* result; + char* table; + char* key; + int msgid; + int msgid2; + result = saacproto_wrapStringAddr( saacproto_stringwrapper[1] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[2] )); + table = saacproto_wrapStringAddr( saacproto_stringwrapper[2] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[3] )); + key = saacproto_wrapStringAddr( saacproto_stringwrapper[3] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[4] )); + msgid = saacproto_demkstr_int( saacproto.token_list[5] ); + msgid2 = saacproto_demkstr_int( saacproto.token_list[6] ); + saacproto_DBUpdateEntryInt_recv( fd,result,table,key,msgid,msgid2); + return 0; + } +/* +473 :
  • servertoclient DBGetEntryRank( string result , int rank , int count, string table, string key, int msgid, int msgid2 );
    +474 : ë߯ʣ +475 :
    +476 :
    string result +477 :
    successful/failed +478 :
    int rank +479 :
    ˣ1ë£ +480 :
    int count +481 :
    ʹ ټ޼0շԪ£ +482 :
    string table +483 :
    Ƥ ë +484 :
    string key +485 :
    ƽë +486 :
    int msgid, int msgid2 +487 :
    msgid ë߯ +488 :
    +489 :

    +490 : +491 : +*/ + + if( strcmp( funcname , "DBGetEntryRank" ) == 0 ){ + char* result; + int rank; + int count; + char* table; + char* key; + int msgid; + int msgid2; + result = saacproto_wrapStringAddr( saacproto_stringwrapper[1] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[2] )); + rank = saacproto_demkstr_int( saacproto.token_list[3] ); + count = saacproto_demkstr_int( saacproto.token_list[4] ); + table = saacproto_wrapStringAddr( saacproto_stringwrapper[4] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[5] )); + key = saacproto_wrapStringAddr( saacproto_stringwrapper[5] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[6] )); + msgid = saacproto_demkstr_int( saacproto.token_list[7] ); + msgid2 = saacproto_demkstr_int( saacproto.token_list[8] ); + saacproto_DBGetEntryRank_recv( fd,result,rank,count,table,key,msgid,msgid2); + return 0; + } +/* +504 :
  • servertoclient DBDeleteEntryInt( string result , string table, string key, int msgid, int msgid2 );
    +505 : ּ +506 :
    +507 :
    string result +508 :
    successful/failed +509 :
    string table +510 :
    Ƥ ë +511 :
    string key +512 :
    ƽë +513 :
    int msgid, int msgid2 +514 :
    msgid ë߯ +515 :
    +516 :

    +517 : +*/ + + if( strcmp( funcname , "DBDeleteEntryInt" ) == 0 ){ + char* result; + char* table; + char* key; + int msgid; + int msgid2; + result = saacproto_wrapStringAddr( saacproto_stringwrapper[1] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[2] )); + table = saacproto_wrapStringAddr( saacproto_stringwrapper[2] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[3] )); + key = saacproto_wrapStringAddr( saacproto_stringwrapper[3] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[4] )); + msgid = saacproto_demkstr_int( saacproto.token_list[5] ); + msgid2 = saacproto_demkstr_int( saacproto.token_list[6] ); + saacproto_DBDeleteEntryInt_recv( fd,result,table,key,msgid,msgid2); + return 0; + } +/* +530 :
  • servertoclient DBGetEntryInt( string result , int value , string table, string key, int msgid, int msgid2 );
    +531 : ޼ë +532 :
    +533 :
    string result +534 :
    successful/failed +535 :
    int value +536 :
    ּ +537 :
    string table +538 :
    Ƥ ë +539 :
    string key +540 :
    ƽë +541 :
    int msgid, int msgid2 +542 :
    msgid ë߯ +543 :
    +544 : +545 : +546 : +*/ + + if( strcmp( funcname , "DBGetEntryInt" ) == 0 ){ + char* result; + int value; + char* table; + char* key; + int msgid; + int msgid2; + result = saacproto_wrapStringAddr( saacproto_stringwrapper[1] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[2] )); + value = saacproto_demkstr_int( saacproto.token_list[3] ); + table = saacproto_wrapStringAddr( saacproto_stringwrapper[3] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[4] )); + key = saacproto_wrapStringAddr( saacproto_stringwrapper[4] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[5] )); + msgid = saacproto_demkstr_int( saacproto.token_list[6] ); + msgid2 = saacproto_demkstr_int( saacproto.token_list[7] ); + saacproto_DBGetEntryInt_recv( fd,result,value,table,key,msgid,msgid2); + return 0; + } +/* +562 :
  • servertoclient DBGetEntryByRank( string result , string list , string table, int msgid, int msgid2 );
    +563 : DBGetEntryByRank +564 :
    +565 :
    string result +566 :
    +567 :
    string list +568 :
    "RANK,KEY,SCORE,INFO|RANK,KEY,SCORE,INFO|...."
    +569 : RANKƥؤ£KEY˱ئȻµʧëȻ +570 : ƽSCOREѰƥʧƥؤ£ +571 :
    +572 : "1,RINGO,123465,data1|2,HOGE,4567,data2|2,FUCK,4567,data3"
    +573 : 2˷2³ئ£ +574 :
    string table +575 :
    Ƥ +576 :
    int msgid, int msgid2 +577 :
    +578 :
    +579 : +580 : +*/ + + if( strcmp( funcname , "DBGetEntryByRank" ) == 0 ){ + char* result; + char* list; + char* table; + int msgid; + int msgid2; + result = saacproto_wrapStringAddr( saacproto_stringwrapper[1] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[2] )); + list = saacproto_wrapStringAddr( saacproto_stringwrapper[2] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[3] )); + table = saacproto_wrapStringAddr( saacproto_stringwrapper[3] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[4] )); + msgid = saacproto_demkstr_int( saacproto.token_list[5] ); + msgid2 = saacproto_demkstr_int( saacproto.token_list[6] ); + saacproto_DBGetEntryByRank_recv( fd,result,list,table,msgid,msgid2); + return 0; + } +/* +593 :
  • servertoclient DBGetEntryByCount( string result , string list , string table, int count_start, int msgid, int msgid2 );
    +594 : DBGetEntryByCount +595 :
    +596 :
    string result +597 :
    SUCCESSFUL/FAILED +598 :
    string list +599 :
    1޼ؤԻ "INDEX,RANK,KEY,SCORE,INFO" 4ۼ +600 : ׬ƥؤԻľ "|" ƥئ£ѻ0 +601 : ٯ +602 :
    int num +603 :
    ʹԻʾ1ئ1ۣ2ئ2ۣ +604 :
    int msgid ,msgid2 +605 :
    ID. +606 :
    +607 : +*/ + + if( strcmp( funcname , "DBGetEntryByCount" ) == 0 ){ + char* result; + char* list; + char* table; + int count_start; + int msgid; + int msgid2; + result = saacproto_wrapStringAddr( saacproto_stringwrapper[1] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[2] )); + list = saacproto_wrapStringAddr( saacproto_stringwrapper[2] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[3] )); + table = saacproto_wrapStringAddr( saacproto_stringwrapper[3] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[4] )); + count_start = saacproto_demkstr_int( saacproto.token_list[5] ); + msgid = saacproto_demkstr_int( saacproto.token_list[6] ); + msgid2 = saacproto_demkstr_int( saacproto.token_list[7] ); + saacproto_DBGetEntryByCount_recv( fd,result,list,table,count_start,msgid,msgid2); + return 0; + } +#ifdef _ALLDOMAN // (ɿ) Syu ADD аNPC + if ( strcmp( funcname , "UpdataStele" ) == 0 ) { + char* token; + token = saacproto_wrapStringAddr( saacproto_stringwrapper[1] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[2] )); + saacproto_UpdataStele_recv( fd , token) ; + return 0; + } + if ( strcmp( funcname , "S_UpdataStele" ) == 0 ) { + char* ocdkey; + char* oname; + char* ncdkey; + char* nname; + char* title; + int level; + int trns; + int floor; + ocdkey = saacproto_wrapStringAddr( saacproto_stringwrapper[1] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[2] )); + oname = saacproto_wrapStringAddr( saacproto_stringwrapper[2] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[3] )); + ncdkey = saacproto_wrapStringAddr( saacproto_stringwrapper[3] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[4] )); + nname = saacproto_wrapStringAddr( saacproto_stringwrapper[4] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[5] )); + title = saacproto_wrapStringAddr( saacproto_stringwrapper[5] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[6] )); + level = saacproto_demkstr_int( saacproto.token_list[7] ); + trns = saacproto_demkstr_int( saacproto.token_list[8] ); + floor = saacproto_demkstr_int( saacproto.token_list[9] ); + saacproto_S_UpdataStele_recv( fd , ocdkey , oname , ncdkey , nname , title , level , + trns , floor ); + return 0; + } +#endif +/* +621 :
  • servertoclient Broadcast( string id, string charname, string message );
    +622 : Broadcastʧӡձءةӡ߼˪ +623 :
    +624 :
    string id +625 :
    user ID +626 :
    string charname +627 :
    character name +628 :
    string message +629 :
    +630 :
    int flag +631 :
    1б巴 ˪ľئУ +632 :
    +633 : +*/ + + if( strcmp( funcname , "Broadcast" ) == 0 ){ + char* id; + char* charname; + char* message; + id = saacproto_wrapStringAddr( saacproto_stringwrapper[1] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[2] )); + charname = saacproto_wrapStringAddr( saacproto_stringwrapper[2] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[3] )); + message = saacproto_wrapStringAddr( saacproto_stringwrapper[3] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[4] )); + saacproto_Broadcast_recv( fd,id,charname,message); + return 0; + } +/* +652 :
  • servertoclient Message( string id_from, string charname_from, string id_to, string charname_to, string message , int option , int mesgid );
    +653 : ʧӡձءةӡ嶪ë˪£ +654 :
    +655 :
    string id_from +656 :
    from ID +657 :
    string charname_from +658 :
    from character name +659 :
    string id_to +660 :
    to ID +661 :
    string charname_to +662 :
    to character name +663 :
    string message +664 :
    ⼰ +665 :
    int option +666 :
    (ë) +667 :
    int mesgid +668 :
    ID ʧӡ +669 :
    +670 : +*/ + + if( strcmp( funcname , "Message" ) == 0 ){ + char* id_from; + char* charname_from; + char* id_to; + char* charname_to; + char* message; + int option; + int mesgid; + id_from = saacproto_wrapStringAddr( saacproto_stringwrapper[1] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[2] )); + charname_from = saacproto_wrapStringAddr( saacproto_stringwrapper[2] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[3] )); + id_to = saacproto_wrapStringAddr( saacproto_stringwrapper[3] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[4] )); + charname_to = saacproto_wrapStringAddr( saacproto_stringwrapper[4] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[5] )); + message = saacproto_wrapStringAddr( saacproto_stringwrapper[5] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[6] )); + option = saacproto_demkstr_int( saacproto.token_list[7] ); + mesgid = saacproto_demkstr_int( saacproto.token_list[8] ); + saacproto_Message_recv( fd,id_from,charname_from,id_to,charname_to,message,option,mesgid); + return 0; + } + + // CoolFish: Family 2001/5/9 + if( strcmp( funcname, "ACAddFM") == 0){ + int fmindex, index, charfdid; + char *result; + result = saacproto_wrapStringAddr(saacproto_stringwrapper[1], saacproto.workbufsize, saacproto_demkstr_string(saacproto.token_list[2])); + fmindex = saacproto_demkstr_int(saacproto.token_list[3]); + index = saacproto_demkstr_int(saacproto.token_list[4]); + charfdid = saacproto_demkstr_int(saacproto.token_list[5]); + saacproto_ACAddFM_recv(fd, result, fmindex, charfdid, index); + return 0; + } + if( strcmp( funcname, "ACJoinFM") == 0){ + int charfdid, recv; + char *result; + result = saacproto_wrapStringAddr(saacproto_stringwrapper[1], saacproto.workbufsize, saacproto_demkstr_string(saacproto.token_list[2])); + recv = saacproto_demkstr_int(saacproto.token_list[3]); + charfdid = saacproto_demkstr_int(saacproto.token_list[4]); + saacproto_ACJoinFM_recv(fd, result, recv, charfdid); + return 0; + } + if( strcmp( funcname, "ACLeaveFM") == 0){ + int charfdid, resultflag; + char *result; + result = saacproto_wrapStringAddr(saacproto_stringwrapper[1], saacproto.workbufsize, saacproto_demkstr_string(saacproto.token_list[2])); + resultflag = saacproto_demkstr_int(saacproto.token_list[3]); + charfdid = saacproto_demkstr_int(saacproto.token_list[4]); + saacproto_ACLeaveFM_recv(fd, result, resultflag, charfdid); + return 0; + } + if( strcmp( funcname, "ACDelFM") == 0){ + int charfdid; + char *result; + result = saacproto_wrapStringAddr(saacproto_stringwrapper[1], saacproto.workbufsize, saacproto_demkstr_string(saacproto.token_list[2])); + charfdid = saacproto_demkstr_int(saacproto.token_list[3]); + saacproto_ACDelFM_recv(fd, result, charfdid); + return 0; + } + if( strcmp( funcname, "ACShowFMList") == 0){ + int fmnum; + char *result, *data; + result = saacproto_wrapStringAddr(saacproto_stringwrapper[1], saacproto.workbufsize, saacproto_demkstr_string(saacproto.token_list[2])); + fmnum = saacproto_demkstr_int(saacproto.token_list[3]); + data = saacproto_wrapStringAddr(saacproto_stringwrapper[3], saacproto.workbufsize, saacproto_demkstr_string(saacproto.token_list[4])); + saacproto_ACShowFMList_recv(fd, result, fmnum, data); + return 0; + } + + if( strcmp( funcname, "ACShowMemberList") == 0){ + int index, fmmemnum, fmacceptflag, fmjoinnum; + char *result, *data; + result = saacproto_wrapStringAddr(saacproto_stringwrapper[1], saacproto.workbufsize, saacproto_demkstr_string(saacproto.token_list[2])); + index = saacproto_demkstr_int(saacproto.token_list[3]); + fmmemnum = saacproto_demkstr_int(saacproto.token_list[4]); + fmacceptflag = saacproto_demkstr_int(saacproto.token_list[5]); + fmjoinnum = saacproto_demkstr_int(saacproto.token_list[6]); + data = saacproto_wrapStringAddr(saacproto_stringwrapper[6], saacproto.workbufsize, saacproto_demkstr_string(saacproto.token_list[7])); + saacproto_ACShowMemberList_recv(fd, result, index, fmmemnum, fmacceptflag, fmjoinnum, data); + return 0; + } + if( strcmp( funcname, "ACFMDetail") == 0){ + int charfdid; + char *result, *data; + result = saacproto_wrapStringAddr(saacproto_stringwrapper[1], saacproto.workbufsize, saacproto_demkstr_string(saacproto.token_list[2])); + data = saacproto_wrapStringAddr(saacproto_stringwrapper[2], saacproto.workbufsize, saacproto_demkstr_string(saacproto.token_list[3])); + charfdid = saacproto_demkstr_int(saacproto.token_list[4]); + saacproto_ACFMDetail_recv(fd, result, data, charfdid); + return 0; + } + if( strcmp( funcname, "ACMemberJoinFM") == 0){ + int charfdid; + char *result, *data; + result = saacproto_wrapStringAddr(saacproto_stringwrapper[1], saacproto.workbufsize, saacproto_demkstr_string(saacproto.token_list[2])); + data = saacproto_wrapStringAddr(saacproto_stringwrapper[2], saacproto.workbufsize, saacproto_demkstr_string(saacproto.token_list[3])); + charfdid = saacproto_demkstr_int(saacproto.token_list[4]); + saacproto_ACMemberJoinFM_recv(fd, result, data, charfdid); + return 0; + } + if( strcmp( funcname, "ACMemberLeaveFM") == 0){ + int charfdid; + char *result, *data; + result = saacproto_wrapStringAddr(saacproto_stringwrapper[1], saacproto.workbufsize, saacproto_demkstr_string(saacproto.token_list[2])); + data = saacproto_wrapStringAddr(saacproto_stringwrapper[2], saacproto.workbufsize, saacproto_demkstr_string(saacproto.token_list[3])); + charfdid = saacproto_demkstr_int(saacproto.token_list[4]); + saacproto_ACMemberLeaveFM_recv(fd, result, data, charfdid); + return 0; + } + if( strcmp( funcname, "ACFMCharLogin") == 0){ + int charfdid, index, floor, fmdp, joinflag, fmsetupflag, flag, charindex; +#ifdef _PERSONAL_FAME // Arminius: + int charfame; +#endif +#ifdef _NEW_MANOR_LAW + int momentum; +#endif + char *result; + result = saacproto_wrapStringAddr(saacproto_stringwrapper[1], saacproto.workbufsize, saacproto_demkstr_string(saacproto.token_list[2])); + index = saacproto_demkstr_int(saacproto.token_list[3]); + floor = saacproto_demkstr_int(saacproto.token_list[4]); + fmdp = saacproto_demkstr_int(saacproto.token_list[5]); + joinflag = saacproto_demkstr_int(saacproto.token_list[6]); + fmsetupflag = saacproto_demkstr_int(saacproto.token_list[7]); + flag = saacproto_demkstr_int(saacproto.token_list[8]); + charindex = saacproto_demkstr_int(saacproto.token_list[9]); +#ifdef _PERSONAL_FAME // Arminius: + charfame = saacproto_demkstr_int(saacproto.token_list[10]); + charfdid = saacproto_demkstr_int(saacproto.token_list[11]); + #ifdef _NEW_MANOR_LAW + momentum = saacproto_demkstr_int(saacproto.token_list[12]); + #endif + saacproto_ACFMCharLogin_recv(fd, result, index, floor, fmdp, + joinflag, fmsetupflag, flag, charindex, charfame, charfdid + #ifdef _NEW_MANOR_LAW + ,momentum + #endif + ); +#else + charfdid = saacproto_demkstr_int(saacproto.token_list[10]); + saacproto_ACFMCharLogin_recv(fd, result, index, floor, fmdp, + joinflag, fmsetupflag, flag, charindex, charfdid); +#endif + return 0; + } + if( strcmp( funcname, "ACFMCharLogout") == 0){ + int charfdid; + char *result; + result = saacproto_wrapStringAddr(saacproto_stringwrapper[1], saacproto.workbufsize, saacproto_demkstr_string(saacproto.token_list[2])); + charfdid = saacproto_demkstr_int(saacproto.token_list[3]); + saacproto_ACFMCharLogout_recv(fd, result, charfdid); + return 0; + } + if( strcmp( funcname, "ACFMReadMemo") == 0){ + int index, num, dataindex; + char *result, *data; + result = saacproto_wrapStringAddr(saacproto_stringwrapper[1], saacproto.workbufsize, saacproto_demkstr_string(saacproto.token_list[2])); + index = saacproto_demkstr_int(saacproto.token_list[3]); + num = saacproto_demkstr_int(saacproto.token_list[4]); + dataindex = saacproto_demkstr_int(saacproto.token_list[5]); + data = saacproto_wrapStringAddr(saacproto_stringwrapper[5], saacproto.workbufsize, saacproto_demkstr_string(saacproto.token_list[6])); + saacproto_ACFMReadMemo_recv(fd, result, index, num, dataindex, data); + return 0; + } + if( strcmp( funcname, "ACFMWriteMemo") == 0){ + int index; + char *result; + result = saacproto_wrapStringAddr(saacproto_stringwrapper[1], saacproto.workbufsize, saacproto_demkstr_string(saacproto.token_list[2])); + index = saacproto_demkstr_int(saacproto.token_list[3]); + saacproto_ACFMWriteMemo_recv(fd, result, index); + return 0; + } + if( strcmp( funcname, "ACFMPointList") == 0){ + char *result, *data; + result = saacproto_wrapStringAddr(saacproto_stringwrapper[1], saacproto.workbufsize, saacproto_demkstr_string(saacproto.token_list[2])); + data = saacproto_wrapStringAddr(saacproto_stringwrapper[2], saacproto.workbufsize, saacproto_demkstr_string(saacproto.token_list[3])); + saacproto_ACFMPointList_recv(fd, result, data); + return 0; + } + + + if( strcmp( funcname, "ACSetFMPoint") == 0){ + int charfdid, r; + char *result; + result = saacproto_wrapStringAddr(saacproto_stringwrapper[1], saacproto.workbufsize, saacproto_demkstr_string(saacproto.token_list[2])); + r = saacproto_demkstr_int(saacproto.token_list[3]); + charfdid = saacproto_demkstr_int(saacproto.token_list[4]); + saacproto_ACSetFMPoint_recv(fd, result, r, charfdid); + return 0; + } + if( strcmp( funcname, "ACFixFMPoint") == 0){ + int r; + char *result; + result = saacproto_wrapStringAddr(saacproto_stringwrapper[1], saacproto.workbufsize, saacproto_demkstr_string(saacproto.token_list[2])); + r = saacproto_demkstr_int(saacproto.token_list[3]); + saacproto_ACFixFMPoint_recv(fd, result, r); + return 0; + } + if( strcmp( funcname, "ACFMAnnounce") == 0){ + int fmindex, index, color, kindflag; + char *result, *fmname, *data; + result = saacproto_wrapStringAddr(saacproto_stringwrapper[1], saacproto.workbufsize, saacproto_demkstr_string(saacproto.token_list[2])); + fmname = saacproto_wrapStringAddr(saacproto_stringwrapper[2], saacproto.workbufsize, saacproto_demkstr_string(saacproto.token_list[3])); + fmindex = saacproto_demkstr_int(saacproto.token_list[4]); + index = saacproto_demkstr_int(saacproto.token_list[5]); + kindflag = saacproto_demkstr_int(saacproto.token_list[6]); + data = saacproto_wrapStringAddr(saacproto_stringwrapper[6], saacproto.workbufsize, saacproto_demkstr_string(saacproto.token_list[7])); + color = saacproto_demkstr_int(saacproto.token_list[8]); + saacproto_ACFMAnnounce_recv(fd, result, fmname, fmindex, index, kindflag, data, color); + return 0; + } + if( strcmp( funcname, "ACShowTopFMList") == 0){ + int num, kindflag; + char *result, *data; + result = saacproto_wrapStringAddr(saacproto_stringwrapper[1], saacproto.workbufsize, saacproto_demkstr_string(saacproto.token_list[2])); + kindflag = saacproto_demkstr_int(saacproto.token_list[3]); + num = saacproto_demkstr_int(saacproto.token_list[4]); + data = saacproto_wrapStringAddr(saacproto_stringwrapper[4], saacproto.workbufsize, saacproto_demkstr_string(saacproto.token_list[5])); + saacproto_ACShowTopFMList_recv(fd, result, kindflag, num, data); + return 0; + } + if( strcmp( funcname, "ACFixFMData") == 0){ + int kindflag, charfdid; + char *result, *data1, *data2; + result = saacproto_wrapStringAddr(saacproto_stringwrapper[1], saacproto.workbufsize, saacproto_demkstr_string(saacproto.token_list[2])); + kindflag = saacproto_demkstr_int(saacproto.token_list[3]); + data1 = saacproto_wrapStringAddr(saacproto_stringwrapper[3], saacproto.workbufsize, saacproto_demkstr_string(saacproto.token_list[4])); + data2 = saacproto_wrapStringAddr(saacproto_stringwrapper[4], saacproto.workbufsize, saacproto_demkstr_string(saacproto.token_list[5])); + charfdid = saacproto_demkstr_int(saacproto.token_list[6]); + saacproto_ACFixFMData_recv(fd, result, kindflag, data1, data2, charfdid); + return 0; + } + if( strcmp( funcname, "ACFixFMPK") == 0){ + int data, winindex, loseindex; + char *result; + result = saacproto_wrapStringAddr(saacproto_stringwrapper[1], saacproto.workbufsize, saacproto_demkstr_string(saacproto.token_list[2])); + data = saacproto_demkstr_int(saacproto.token_list[3]); + winindex = saacproto_demkstr_int(saacproto.token_list[4]); + loseindex = saacproto_demkstr_int(saacproto.token_list[5]); + saacproto_ACFixFMPK_recv(fd, result, data, winindex, loseindex); + return 0; + } + if( strcmp( funcname, "ACGMFixFMData") == 0){ + int charfdid; + char *result, *fmname; + result = saacproto_wrapStringAddr(saacproto_stringwrapper[1], saacproto.workbufsize, saacproto_demkstr_string(saacproto.token_list[2])); + fmname = saacproto_wrapStringAddr(saacproto_stringwrapper[2], saacproto.workbufsize, saacproto_demkstr_string(saacproto.token_list[3])); + charfdid = saacproto_demkstr_int(saacproto.token_list[4]); + saacproto_ACGMFixFMData_recv(fd, result, fmname, charfdid); + return 0; + } + if( strcmp( funcname, "ACGetFMData") == 0){ + int kindflag, charfdid, data; + char *result; + result = saacproto_wrapStringAddr(saacproto_stringwrapper[1], saacproto.workbufsize, saacproto_demkstr_string(saacproto.token_list[2])); + kindflag = saacproto_demkstr_int(saacproto.token_list[3]); + data = saacproto_demkstr_int(saacproto.token_list[4]); + charfdid = saacproto_demkstr_int(saacproto.token_list[5]); + saacproto_ACGetFMData_recv(fd, result, kindflag, data, charfdid); + return 0; + } + if( strcmp( funcname, "ACFMClearPK") == 0){ + int fmindex, index; + char *result, *fmname; + result = saacproto_wrapStringAddr(saacproto_stringwrapper[1], saacproto.workbufsize, saacproto_demkstr_string(saacproto.token_list[2])); + fmname = saacproto_wrapStringAddr(saacproto_stringwrapper[2], saacproto.workbufsize, saacproto_demkstr_string(saacproto.token_list[3])); + fmindex = saacproto_demkstr_int(saacproto.token_list[4]); + index = saacproto_demkstr_int(saacproto.token_list[5]); + saacproto_ACFMClearPK_recv(fd, result, fmname, fmindex, index); + return 0; + } + // Arminius 7.26 manor pk acknowledge + if( strcmp( funcname, "ACManorPKAck") == 0){ + char *data; + data = saacproto_wrapStringAddr(saacproto_stringwrapper[1], saacproto.workbufsize, saacproto_demkstr_string(saacproto.token_list[2])); + saacproto_ACManorPKAck_recv(fd, data); + return 0; + } + +#ifdef _ACFMPK_LIST + if( strcmp( funcname, "ACLoadFmPk") == 0){ + char *data; + data = saacproto_wrapStringAddr(saacproto_stringwrapper[1], saacproto.workbufsize, saacproto_demkstr_string(saacproto.token_list[2])); + saacproto_ACLoadFmPk_recv( fd, data); + return 0; + } + if( strcmp( funcname, "ACSendFmPk") == 0){ + int toindex, flg; + toindex = saacproto_demkstr_int( saacproto.token_list[2] ); + flg =saacproto_demkstr_int( saacproto.token_list[3] ); + saacproto_ACSendFmPk_recv( fd, toindex, flg); + return 0; + } +#endif +#ifdef _SEND_EFFECT // WON ADD ACѩЧ + if( strcmp(funcname, "EFFECT") == 0){ + char *effect; + effect = saacproto_wrapStringAddr(saacproto_stringwrapper[1], saacproto.workbufsize, saacproto_demkstr_string(saacproto.token_list[2])); + print("\n AC send to GS weather effect !!"); + + CHAR_CHAT_DEBUG_sendeffect( fd, effect ); + return 0; + } +#endif + +#ifdef _ANGEL_SUMMON + if( strcmp( funcname , "ACMissionTable" ) == 0 ){ + int num; + int type; + char* data; + //int charaindex; + char* angelinfo; + + num = saacproto_demkstr_int( saacproto.token_list[2] ); + type = saacproto_demkstr_int( saacproto.token_list[3] ); + data = saacproto_wrapStringAddr( saacproto_stringwrapper[3] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[4] )); + //charaindex = saacproto_demkstr_int( saacproto.token_list[5] ); + angelinfo = saacproto_wrapStringAddr( saacproto_stringwrapper[4] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[5] )); + + //saacproto_ACMissionTable_recv( fd, num, type, data, charaindex); + saacproto_ACMissionTable_recv( fd, num, type, data, angelinfo); + return 0; + } +#endif + +#ifdef _TEACHER_SYSTEM + if(strcmp(funcname,"ACCheckCharacterOnLine") == 0){ + int flag,charaindex,iOnline; + char* data; + + charaindex = saacproto_demkstr_int(saacproto.token_list[2]); + iOnline = saacproto_demkstr_int(saacproto.token_list[3]); + data = saacproto_wrapStringAddr( saacproto_stringwrapper[3] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[4] )); + flag = saacproto_demkstr_int( saacproto.token_list[5] ); + saacproto_ACCheckCharacterOnLine_recv(fd,charaindex,iOnline,data,flag); + return 0; + } +#endif + + if( strcmp( funcname , "ACCharLogin" ) == 0 ){ + int flag; + int clifd; + clifd = saacproto_demkstr_int( saacproto.token_list[2] ); + flag = saacproto_demkstr_int( saacproto.token_list[3] ); + saacproto_ACCharLogin_recv(fd, clifd, flag); + return 0; + } + + if( strcmp( funcname , "QuerySafePasswd" ) == 0 ){ + char* id; + int res; + int charaindex; + id = saacproto_wrapStringAddr( saacproto_stringwrapper[1] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[2] )); + res = saacproto_demkstr_int( saacproto.token_list[3] ); + charaindex = saacproto_demkstr_int( saacproto.token_list[4] ); + saacproto_QuerySafePasswd_recv(fd, id, res, charaindex); + return 0; + } + + if( strcmp( funcname , "AddSafePasswd" ) == 0 ){ + char* id; + int res; + int charaindex; + id = saacproto_wrapStringAddr( saacproto_stringwrapper[1] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[2] )); + res = saacproto_demkstr_int( saacproto.token_list[3] ); + charaindex = saacproto_demkstr_int( saacproto.token_list[4] ); + saacproto_AddSafePasswd_recv(fd, id, res, charaindex); + return 0; + } + + if( strcmp( funcname , "PointCardSucces" ) == 0 ){ + char* id; + int res; + int point; + int charaindex; + id = saacproto_wrapStringAddr( saacproto_stringwrapper[1] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[2] )); + res = saacproto_demkstr_int( saacproto.token_list[3] ); + point = saacproto_demkstr_int( saacproto.token_list[4] ); + charaindex = saacproto_demkstr_int( saacproto.token_list[5] ); + saacproto_PointCardSucces_recv(fd, id, res, point, charaindex); + return 0; + } + + if( strcmp( funcname , "PointCardErr" ) == 0 ){ + char* id; + int res; + int charaindex; + id = saacproto_wrapStringAddr( saacproto_stringwrapper[1] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[2] )); + res = saacproto_demkstr_int( saacproto.token_list[3] ); + charaindex = saacproto_demkstr_int( saacproto.token_list[4] ); + saacproto_PointCardErr_recv(fd, id, res, charaindex); + return 0; + } + + if( strcmp( funcname , "LoginTime" ) == 0 ){ + char* id; + char* res; + int charaindex; + id = saacproto_wrapStringAddr( saacproto_stringwrapper[1] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[2] )); + res = saacproto_wrapStringAddr( saacproto_stringwrapper[2] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[3] )); + charaindex = saacproto_demkstr_int( saacproto.token_list[4] ); + saacproto_LoginTime_recv(fd, id, res, charaindex); + return 0; + } + +#ifdef _ONLINE_SHOP + if( strcmp( funcname , "ACShop" ) == 0 ){ + char* res; + int charaindex,shopnum,vippoint,piece,pieces,shopflag; + charaindex = saacproto_demkstr_int( saacproto.token_list[2] ); + shopnum = saacproto_demkstr_int( saacproto.token_list[3] ); + vippoint = saacproto_demkstr_int( saacproto.token_list[4] ); + piece = saacproto_demkstr_int( saacproto.token_list[5] ); + pieces = saacproto_demkstr_int( saacproto.token_list[6] ); + shopflag = saacproto_demkstr_int( saacproto.token_list[7] ); + res = saacproto_wrapStringAddr( saacproto_stringwrapper[7] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[8] )); + saacproto_ACShop_recv(fd, charaindex, shopnum, vippoint, piece, pieces, shopflag, res); + return 0; + } + + if( strcmp( funcname , "ACShopBuy" ) == 0 ){ + char* res; + int charaindex,shopnum,vippoint,piece,pieces,shopflag,shopno,buynum; + charaindex = saacproto_demkstr_int( saacproto.token_list[2] ); + shopnum = saacproto_demkstr_int( saacproto.token_list[3] ); + vippoint = saacproto_demkstr_int( saacproto.token_list[4] ); + piece = saacproto_demkstr_int( saacproto.token_list[5] ); + pieces = saacproto_demkstr_int( saacproto.token_list[6] ); + shopflag = saacproto_demkstr_int( saacproto.token_list[7] ); + res = saacproto_wrapStringAddr( saacproto_stringwrapper[7] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[8] )); + shopno = saacproto_demkstr_int( saacproto.token_list[9] ); + buynum = saacproto_demkstr_int( saacproto.token_list[10] ); + saacproto_ACShop_recv(fd, charaindex, shopnum, vippoint, piece, pieces, shopflag, res); + saacproto_ACShopBuy_recv(charaindex, shopflag, shopno, buynum); + return 0; + } +#endif + +#ifdef _QUESTION_ONLINE + if( strcmp( funcname , "ACQuestion" ) == 0 ){ + char* res; + res = saacproto_wrapStringAddr( saacproto_stringwrapper[1] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[2] )); + saacproto_ACQuestion_recv(res); + return 0; + } +#endif + +#ifdef _ALL_ITEM + if( strcmp( funcname , "ACAllnum" ) == 0 ){ + int flag,allnum; + flag = saacproto_demkstr_int( saacproto.token_list[2] ); + allnum = saacproto_demkstr_int( saacproto.token_list[3] ); + saacproto_ACAllnum_recv(flag,allnum); + return 0; + } +#endif + + if( strcmp( funcname , "ACFmPkOnlineSn" ) == 0 ){ + //DebugMainFunction="saac1"; + int manorindex,flag; + //DebugMainFunction="saac2"; + char* gsname; + //DebugMainFunction="saac3"; + manorindex = saacproto_demkstr_int( saacproto.token_list[2] ); + //DebugMainFunction="saac4"; + gsname = saacproto_wrapStringAddr( saacproto_stringwrapper[2] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[3] )); + //DebugMainFunction="saac5"; + flag = saacproto_demkstr_int( saacproto.token_list[4] ); + //DebugMainFunction="saac6"; + saacproto_ACFmPkOnlineSn_recv(manorindex,gsname,flag); + //DebugMainFunction="saac7"; + return 0; + } + + if( strcmp( funcname , "ACSystemAllTalk" ) == 0 ){ + char* systemalltalkbuf; + systemalltalkbuf = saacproto_wrapStringAddr( saacproto_stringwrapper[1] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[2] )); + saacproto_ACSystemAllTalk_recv(systemalltalkbuf); + return 0; + } + + if( strcmp( funcname , "ACPlayerAllTalk" ) == 0 ){ + char* servername; + char* playername; + char* playeralltalkbuf; + servername = saacproto_wrapStringAddr( saacproto_stringwrapper[1] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[2] )); + playername = saacproto_wrapStringAddr( saacproto_stringwrapper[2] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[3] )); + playeralltalkbuf = saacproto_wrapStringAddr( saacproto_stringwrapper[3] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[4] )); + saacproto_ACPlayerAllTalk_recv(servername,playername,playeralltalkbuf); + return 0; + } + + printf("\n޷ҵSAACӿ:%s\n",funcname); + printf("\nfd=%d,line=%s\n",fd,line_bak); + return -1; +} +void saacproto_SetClientLogFiles( char *r , char *w ) +{ + saacproto_strcpysafe( saacproto_readlogfilename , r , sizeof( saacproto_readlogfilename ) ); + saacproto_strcpysafe( saacproto_writelogfilename , w , sizeof( saacproto_writelogfilename ) ); +} +int saacproto_InitClient( int (*writefunc)(int,char*,int) ,int bufsiz ,int fd) +{ + int i; + if( (void*)writefunc == NULL){saacproto.write_func = saacproto_default_write_wrap;} else {saacproto.write_func = writefunc;} + saacproto_AllocateCommonWork(bufsiz); + saacproto_stringwrapper = (char**)calloc( 1,sizeof(char*) * MAXLSRPCARGS); + if(saacproto_stringwrapper ==NULL)return -1; + memset( saacproto_stringwrapper , 0, sizeof(char*)*MAXLSRPCARGS); + for(i=0;i +#include +#include +#ifndef WIN32 +#include +#include +#endif +#include "saacproto_util.h" +//ttom +1 +#define IS_2BYTEWORD( _a_ ) ( (char)(0x80) <= (_a_) && (_a_) <= (char)(0xFF) ) +extern char *DebugMainFunction; +#ifdef saacproto__ENCRYPT +long saacproto_ringoCompressor( unsigned char *code , long codelen , unsigned char *text , long textlen); +long saacproto_ringoDecompressor( unsigned char *text , long textlen , unsigned char *code , long codelen); +#endif +/* + lsrpc routines +*/ +int saacproto_AllocateCommonWork(int bufsiz) +{ + saacproto.workbufsize = bufsiz; + saacproto.work = NULL; + saacproto.arraywork = NULL; + saacproto.escapework = NULL; + saacproto.val_str = NULL; + saacproto.token_list = NULL; + saacproto.cryptwork = NULL; + saacproto.jencodecopy = NULL; + saacproto.jencodeout = NULL; + saacproto.compresswork = NULL; + saacproto.work = (char*)calloc( 1, saacproto.workbufsize ); + saacproto.arraywork = (char*)calloc( 1, saacproto.workbufsize ); + saacproto.escapework = (char*)calloc( 1, saacproto.workbufsize ); + saacproto.val_str = (char*)calloc( 1, saacproto.workbufsize ); + saacproto.token_list = (char**)calloc( 1, saacproto.workbufsize *sizeof( char** ) ); + saacproto.cryptwork = (char*)calloc( 1, saacproto.workbufsize * 3 ); + saacproto.jencodecopy = (char*)calloc( 1, saacproto.workbufsize * 3 ); + saacproto.jencodeout = (char*)calloc( 1, saacproto.workbufsize * 3 ); + saacproto.compresswork = (char*)calloc( 1, saacproto.workbufsize * 3 ); + memset( saacproto.work , 0, saacproto.workbufsize ); + memset( saacproto.arraywork , 0, saacproto.workbufsize ); + memset( saacproto.escapework , 0, saacproto.workbufsize ); + memset( saacproto.val_str , 0, saacproto.workbufsize ); + memset( (char*)saacproto.token_list ,0, saacproto.workbufsize*sizeof(char**) ); + memset( saacproto.cryptwork , 0, saacproto.workbufsize*3 ); + memset( saacproto.jencodecopy , 0, saacproto.workbufsize*3 ); + memset( saacproto.jencodeout , 0, saacproto.workbufsize*3 ); + memset( saacproto.compresswork , 0, saacproto.workbufsize*3 ); + if( saacproto.work == NULL || + saacproto.arraywork == NULL || + saacproto.escapework == NULL || + saacproto.val_str == NULL || + saacproto.token_list == NULL || + saacproto.cryptwork == NULL || + saacproto.jencodecopy == NULL || + saacproto.jencodeout == NULL || + saacproto.compresswork == NULL ){ + free( saacproto.work);free( saacproto.val_str); + free( saacproto.escapework);free( saacproto.arraywork ); + free( saacproto.token_list);free( saacproto.cryptwork ); + free( saacproto.jencodecopy);free( saacproto.jencodeout ); + free( saacproto.compresswork ); + return -1; + } + return 0; +} + +int saacproto_StringRest() +{ + return 0; +/* free( saacproto.work); + saacproto.work = NULL; + saacproto.work = (char*)calloc( 1, saacproto.workbufsize ); + if( saacproto.work == NULL ) return -1; + return sizeof( saacproto.work); +*/ +} + +/********** + Get message information from a network input +**********/ +void saacproto_GetMessageInfo( int *id , char *funcname , int len, char **tk ) +{ + if( tk[0] == NULL || tk[1] == NULL ){ + *id = 0; + saacproto_strcpysafe( funcname , "" , len ); + return; + } + *id = strtoul( tk[0] ,NULL,10); + saacproto_strcpysafe( funcname , tk[1] , len ); + return; +} +/******************************************** + string utilities +*********************************************/ +void saacproto_strcpysafe( char *dest, char *src, int maxlen ) +{ + DebugMainFunction="saac21"; + //memset(dest, 0, maxlen); + DebugMainFunction="saac22"; + int ii; + DebugMainFunction="saac23"; + for(ii=0;ii (int)( saacproto.workbufsize*3-2) ){ + fprintf( stderr, "lsgen: badly configured work buflen\n" ); + exit(1); + } + if( (flag%2) == 1 ) flag ++; + saacproto.compresswork[0] = flag; + memcpy( saacproto.compresswork+1,src,srclen ); + compressed_l = srclen + 1; + } else { + if((flag%2)==0)flag++; + saacproto.compresswork[0] = flag; + compressed_l = saacproto_ringoCompressor( + (unsigned char*)saacproto.compresswork + 1 , + (long)saacproto.workbufsize*3 - 1, + (unsigned char*)src , + (long)strlen(src) ) + 1; /* be careful! */ + } + /* return empty line if error or buffer excess */ + if( compressed_l <= 0 ){ + saacproto_strcpysafe( out , "\n" , maxoutlen ); + return; + } + memcpy( saacproto.jencodecopy ,saacproto.compresswork ,compressed_l ); + saacproto_jEncode( saacproto.jencodecopy , compressed_l , JENCODE_KEY , + saacproto.jencodeout, &jencodedlen , saacproto.workbufsize*3 -1 ); + saacproto_encode64( (unsigned char*)saacproto.jencodeout , jencodedlen, (unsigned char*)out ); +} +/* translate code64 text to original lsrpc text */ +static void saacproto_decodeString( char *src , char *out ) +{ + int compressed_l =0, outlen64; + int l; + long decompressed_l = 0; + /* copy src to copybuffer because jencoder modifies the input buffer */ + l = strlen( src ); + if( src[l-1]=='\n' || src[l-1]=='\r' )src[l-1]=0; + if( src[l-2]=='\n' || src[l-2]=='\r' )src[l-2]=0; + outlen64 = saacproto_decode64( (unsigned char*)src , (unsigned char*)saacproto.jencodecopy ); + saacproto_jDecode( saacproto.jencodecopy , outlen64 , JENCODE_KEY, + saacproto.compresswork , &compressed_l); + /*out[outlen]=0; PENDING*/ + if( (saacproto.compresswork[0] % 2 ) == 0 ){ + if( compressed_l <= 0 ){ + decompressed_l = 0; + fprintf( stderr, "LSRPC: too short:[%s]\n", src ); + } else { + memcpy( out, saacproto.compresswork+1, compressed_l -1 ); + decompressed_l = compressed_l -1; + } + } else { + decompressed_l = + saacproto_ringoDecompressor( (unsigned char*)out , + (long)saacproto.workbufsize , + (unsigned char*)saacproto.compresswork+1 , + (long)compressed_l -1 ); + } + out[decompressed_l] = 0; +} +/* followings are taken from code64.c */ +char saacproto_charset[64]={ + 'A','B','C','D', 'E','F','G','H', + 'I','J','K','L', 'M','N','O','P', + 'Q','R','S','T', 'U','V','W','X', + 'Y','Z','a','b', 'c','d','e','f', + 'g','h','i','j', 'k','l','m','n', + 'o','p','q','r', 's','t','u','v', + 'w','x','y','z', '0','1','2','3', + '4','5','6','7', '8','9','+','-' +}; +char saacproto_reversecharset[256]={ + 0,0,0,0, 0,0,0,0, + 0,0,0,0, 0,0,0,0, + 0,0,0,0, 0,0,0,0, + 0,0,0,0, 0,0,0,0, + 0,0,0,0, 0,0,0,0, + 0,0,0,62, 0,63,0,0, + 52,53,54,55, 56,57,58,59, + 60,61,0,0, 0,0,0,0, + 0,0,1,2, 3,4,5,6, + 7,8,9,10, 11,12,13,14, + 15,16,17,18, 19,20,21,22, + 23,24,25,0, 0,0,0,0, + 0,26,27,28, 29,30,31,32, + 33,34,35,36, 37,38,39,40, + 41,42,43,44, 45,46,47,48, + 49,50,51,0, 0,0,0,0, + 0,0,0,0, 0,0,0,0, + 0,0,0,0, 0,0,0,0, + 0,0,0,0, 0,0,0,0, + 0,0,0,0, 0,0,0,0, + 0,0,0,0, 0,0,0,0, + 0,0,0,0, 0,0,0,0, + 0,0,0,0, 0,0,0,0, + 0,0,0,0, 0,0,0,0, + 0,0,0,0, 0,0,0,0, + 0,0,0,0, 0,0,0,0, + 0,0,0,0, 0,0,0,0, + 0,0,0,0, 0,0,0,0, + 0,0,0,0, 0,0,0,0, + 0,0,0,0, 0,0,0,0, + 0,0,0,0, 0,0,0,0, + 0,0,0,0, 0,0,0,0 +}; + +static void saacproto_encode64( unsigned char *in , int len , unsigned char *out ) +{ + int i; + int use_bytes; + int address = 0; + out[0] = 0; + for(i=0;;i+=3){ + unsigned char in1 , in2 , in3; + unsigned char out1 ,out2 , out3 , out4; + if( i >= len ) break; + if( i >= (len-1)){ /* the last letter ( to be thrown away ) */ + in1 = in[i] & 0xff; + in2 = in3 = 0; + use_bytes = 2; + } else if( i >= (len-2)){ /* the last 2 letters ( process only 1 byte)*/ + in1 = in[i] & 0xff; + in2 = in[i+1] & 0xff; + in3 = 0; + use_bytes = 3; + } else { /* there are more or equal than 3 letters */ + in1 = in[i] & 0xff; + in2 = in[i+1] & 0xff; + in3 = in[i+2] & 0xff; + use_bytes = 4; + } + out1 = ((in1 & 0xfc)>>2) & 0x3f; + out2 = ((in1 & 0x03)<<4) | ((( in2 & 0xf0)>>4)&0x0f); + out3 = ((in2 & 0x0f)<<2) | ((( in3 & 0xc0)>>6)&0x03); + out4 = (in3 & 0x3f ); + if( use_bytes >= 2 ){ + out[address++] = saacproto_charset[out1]; + out[address++] = saacproto_charset[out2]; + out[address]=0; + } + if( use_bytes >= 3 ){ + out[address++] = saacproto_charset[out3]; + out[address]=0; + } + if( use_bytes >= 4 ){ + out[address++] = saacproto_charset[out4]; + out[address]=0; + } + } +} +/* + * Decode it + * char *in : encoded ascii chars + * char *out : decoded( output) + * return value : output byte count + * + * note: no need to have bigger buffer. because output is to + * be smaller than input string size + */ +static int saacproto_decode64( unsigned char *in , unsigned char *out ) +{ + unsigned char in1 , in2 , in3 , in4; + unsigned char out1 , out2 , out3; + int use_bytes; + int address= 0; + int i; + for(i=0;;i+=4 ){ + if( in[i] == 0 ){ + break; + } else if( in[i+1] == 0 ){ /* the last letter */ + break; + } else if( in[i+2] == 0 ){ /* the last 2 letters */ + in1 = saacproto_reversecharset[in[i]]; + in2 = saacproto_reversecharset[in[i+1]]; + in3 = in4 = 0; + use_bytes = 1; + } else if( in[i+3] == 0 ){ /* the last 3 letters */ + in1 = saacproto_reversecharset[in[i]]; + in2 = saacproto_reversecharset[in[i+1]]; + in3 = saacproto_reversecharset[in[i+2]]; + in4 = 0; + use_bytes = 2; + } else { /* process 4 letters */ + in1 = saacproto_reversecharset[in[i]]; + in2 = saacproto_reversecharset[in[i+1]]; + in3 = saacproto_reversecharset[in[i+2]]; + in4 = saacproto_reversecharset[in[i+3]]; + use_bytes = 3; + } + out1 = (in1<<2) | (((in2 & 0x30)>>4)&0x0f) ; + out2 = ((in2 & 0x0f )<<4) | ((( in3 & 0x3c)>>2)&0x0f); + out3 = ( (in3 &0x03)<<6) | ( in4 & 0x3f ); + if( use_bytes >= 1 ){ + out[address++] = out1; + } + if( use_bytes >= 2 ){ + out[address++] = out2; + } + if( use_bytes >= 3 ){ + out[address++] = out3; + } + if( use_bytes != 3 ){ + break; + } + } + return address; +} + +/* followings are taken from Jencode.c by jun */ +static void saacproto_jEncode(char *src,int srclen,int key,char *encoded,int *encodedlen,int maxencodedlen) +{ + char sum=0; + int i; + if(srclen+1 > maxencodedlen){ + *encodedlen = maxencodedlen; + for(i=0;i<(*encodedlen);i++)encoded[i] = src[i]; + } + if(srclen+1 <= maxencodedlen){ + *encodedlen=srclen+1; + for(i=0;i i) encoded[i] = src[i] + sum*((i*i)%3); + if(abs((key%srclen)) == i) encoded[i] = sum; + if(abs((key%srclen)) < i) encoded[i] = src[i-1] + sum*((i*i)%7); + } + } +} +static void saacproto_jDecode(char *src,int srclen,int key,char *decoded,int *decodedlen) +{ + char sum=0; + int i; + *decodedlen=srclen-1; + if( *decodedlen == 0 ){ + return; /* return error if length is 0 */ + } + sum = src[abs(key%(*decodedlen))]; + for(i=0;i i) decoded[i] = src[i] - sum*((i*i)%3); + if(abs((key%(*decodedlen))) < i) decoded[i-1] = src[i] - sum*((i*i)%7); + } + for(i=0;i<(*decodedlen);i++){ + if(((key%7) == (i%5))||((key%2) == (i%2)))decoded[i] = ~decoded[i]; + } +} + +/*****************************************************************/ +/* Compress / Decompress routine */ +/*****************************************************************/ +#define B00000000 0 +#define B00000001 1 +#define B00000010 2 +#define B00000011 3 +#define B00000100 4 +#define B00000101 5 +#define B00000110 6 +#define B00000111 7 +#define B00001000 8 +#define B00001001 9 +#define B00001010 10 +#define B00001011 11 +#define B00001100 12 +#define B00001101 13 +#define B00001110 14 +#define B00001111 15 +#define B00010000 16 +#define B00010001 17 +#define B00010010 18 +#define B00010011 19 +#define B00010100 20 +#define B00010101 21 +#define B00010110 22 +#define B00010111 23 +#define B00011000 24 +#define B00011001 25 +#define B00011010 26 +#define B00011011 27 +#define B00011100 28 +#define B00011101 29 +#define B00011110 30 +#define B00011111 31 +#define B00100000 32 +#define B00100001 33 +#define B00100010 34 +#define B00100011 35 +#define B00100100 36 +#define B00100101 37 +#define B00100110 38 +#define B00100111 39 +#define B00101000 40 +#define B00101001 41 +#define B00101010 42 +#define B00101011 43 +#define B00101100 44 +#define B00101101 45 +#define B00101110 46 +#define B00101111 47 +#define B00110000 48 +#define B00110001 49 +#define B00110010 50 +#define B00110011 51 +#define B00110100 52 +#define B00110101 53 +#define B00110110 54 +#define B00110111 55 +#define B00111000 56 +#define B00111001 57 +#define B00111010 58 +#define B00111011 59 +#define B00111100 60 +#define B00111101 61 +#define B00111110 62 +#define B00111111 63 +#define B01000000 64 +#define B01000001 65 +#define B01000010 66 +#define B01000011 67 +#define B01000100 68 +#define B01000101 69 +#define B01000110 70 +#define B01000111 71 +#define B01001000 72 +#define B01001001 73 +#define B01001010 74 +#define B01001011 75 +#define B01001100 76 +#define B01001101 77 +#define B01001110 78 +#define B01001111 79 +#define B01010000 80 +#define B01010001 81 +#define B01010010 82 +#define B01010011 83 +#define B01010100 84 +#define B01010101 85 +#define B01010110 86 +#define B01010111 87 +#define B01011000 88 +#define B01011001 89 +#define B01011010 90 +#define B01011011 91 +#define B01011100 92 +#define B01011101 93 +#define B01011110 94 +#define B01011111 95 +#define B01100000 96 +#define B01100001 97 +#define B01100010 98 +#define B01100011 99 +#define B01100100 100 +#define B01100101 101 +#define B01100110 102 +#define B01100111 103 +#define B01101000 104 +#define B01101001 105 +#define B01101010 106 +#define B01101011 107 +#define B01101100 108 +#define B01101101 109 +#define B01101110 110 +#define B01101111 111 +#define B01110000 112 +#define B01110001 113 +#define B01110010 114 +#define B01110011 115 +#define B01110100 116 +#define B01110101 117 +#define B01110110 118 +#define B01110111 119 +#define B01111000 120 +#define B01111001 121 +#define B01111010 122 +#define B01111011 123 +#define B01111100 124 +#define B01111101 125 +#define B01111110 126 +#define B01111111 127 +#define B10000000 128 +#define B10000001 129 +#define B10000010 130 +#define B10000011 131 +#define B10000100 132 +#define B10000101 133 +#define B10000110 134 +#define B10000111 135 +#define B10001000 136 +#define B10001001 137 +#define B10001010 138 +#define B10001011 139 +#define B10001100 140 +#define B10001101 141 +#define B10001110 142 +#define B10001111 143 +#define B10010000 144 +#define B10010001 145 +#define B10010010 146 +#define B10010011 147 +#define B10010100 148 +#define B10010101 149 +#define B10010110 150 +#define B10010111 151 +#define B10011000 152 +#define B10011001 153 +#define B10011010 154 +#define B10011011 155 +#define B10011100 156 +#define B10011101 157 +#define B10011110 158 +#define B10011111 159 +#define B10100000 160 +#define B10100001 161 +#define B10100010 162 +#define B10100011 163 +#define B10100100 164 +#define B10100101 165 +#define B10100110 166 +#define B10100111 167 +#define B10101000 168 +#define B10101001 169 +#define B10101010 170 +#define B10101011 171 +#define B10101100 172 +#define B10101101 173 +#define B10101110 174 +#define B10101111 175 +#define B10110000 176 +#define B10110001 177 +#define B10110010 178 +#define B10110011 179 +#define B10110100 180 +#define B10110101 181 +#define B10110110 182 +#define B10110111 183 +#define B10111000 184 +#define B10111001 185 +#define B10111010 186 +#define B10111011 187 +#define B10111100 188 +#define B10111101 189 +#define B10111110 190 +#define B10111111 191 +#define B11000000 192 +#define B11000001 193 +#define B11000010 194 +#define B11000011 195 +#define B11000100 196 +#define B11000101 197 +#define B11000110 198 +#define B11000111 199 +#define B11001000 200 +#define B11001001 201 +#define B11001010 202 +#define B11001011 203 +#define B11001100 204 +#define B11001101 205 +#define B11001110 206 +#define B11001111 207 +#define B11010000 208 +#define B11010001 209 +#define B11010010 210 +#define B11010011 211 +#define B11010100 212 +#define B11010101 213 +#define B11010110 214 +#define B11010111 215 +#define B11011000 216 +#define B11011001 217 +#define B11011010 218 +#define B11011011 219 +#define B11011100 220 +#define B11011101 221 +#define B11011110 222 +#define B11011111 223 +#define B11100000 224 +#define B11100001 225 +#define B11100010 226 +#define B11100011 227 +#define B11100100 228 +#define B11100101 229 +#define B11100110 230 +#define B11100111 231 +#define B11101000 232 +#define B11101001 233 +#define B11101010 234 +#define B11101011 235 +#define B11101100 236 +#define B11101101 237 +#define B11101110 238 +#define B11101111 239 +#define B11110000 240 +#define B11110001 241 +#define B11110010 242 +#define B11110011 243 +#define B11110100 244 +#define B11110101 245 +#define B11110110 246 +#define B11110111 247 +#define B11111000 248 +#define B11111001 249 +#define B11111010 250 +#define B11111011 251 +#define B11111100 252 +#define B11111101 253 +#define B11111110 254 +#define B11111111 255 +/* masks for first byte ( write )*/ +int saacproto_modifymask_first[8][9]={ + {0, B00000001,B00000011,B00000111,B00001111,B00011111,B00111111,B01111111,B11111111},/* mod 0*/ + {0, B00000011,B00000111,B00001111,B00011111,B00111111,B01111111,B11111111,B11111111},/* mod 1*/ + {0, B00000111,B00001111,B00011111,B00111111,B01111111,B11111111,B11111111,B11111111},/* mod 2*/ + {0, B00001111,B00011111,B00111111,B01111111,B11111111,B11111111,B11111111,B11111111},/* mod 3*/ + {0, B00011111,B00111111,B01111111,B11111111,B11111111,B11111111,B11111111,B11111111},/* mod 4*/ + {0, B00111111,B01111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111},/* mod 5*/ + {0, B01111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111},/* mod 6*/ + {0, B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111},/* mod 7*/ +}; +/* masks for second byte ( write ) */ +int saacproto_modifymask_second[8][9]={ + {0, B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000},/* mod 0 */ + {0, B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000001},/* mod 1 */ + {0, B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000001,B00000011},/* mod 2 */ + {0, B00000000,B00000000,B00000000,B00000000,B00000000,B00000001,B00000011,B00000111},/* mod 3 */ + {0, B00000000,B00000000,B00000000,B00000000,B00000001,B00000011,B00000111,B00001111},/* mod 4 */ + {0, B00000000,B00000000,B00000000,B00000001,B00000011,B00000111,B00001111,B00011111},/* mod 5 */ + {0, B00000000,B00000000,B00000001,B00000011,B00000111,B00001111,B00011111,B00111111},/* mod 6 */ + {0, B00000000,B00000001,B00000011,B00000111,B00001111,B00011111,B00111111,B01111111},/* mod 7 */ +}; +/* + * used by bitstream routines + */ +int bitstream_maxbyte, bitstream_bitaddr ; +char *bitstream_buf; +/* initialize bitstream for output */ +static int initOutputBitStream( char *buf ,int buflen) +{ + bitstream_bitaddr = 0; + bitstream_maxbyte = buflen; + bitstream_buf = buf; + memset( buf,0, buflen); + return 0; +} +/* initialize bitstream for input */ +static int initInputBitStream( char *buf , int buflen) +{ + bitstream_bitaddr = 0; + bitstream_maxbyte = buflen; + bitstream_buf = buf; + return 0; +} +/* + * read from bit stream. used only from 1 bit to 8 bits + * this is a base routine + */ +static unsigned int readInputBitStreamBody( int bwidth ) +{ + int mod = bitstream_bitaddr % 8; + int byteaddr = bitstream_bitaddr / 8; + /* return if excess */ + if( byteaddr >= bitstream_maxbyte)return 0; + if( bwidth >= 1 && bwidth <= 8){ + int b1 = (( bitstream_buf[byteaddr] & saacproto_modifymask_first[mod][bwidth] )>>mod); + int b2 = (( bitstream_buf[byteaddr+1] & saacproto_modifymask_second[mod][bwidth])<<(8-mod)); + bitstream_bitaddr += bwidth; + return b1 | b2; + } else { + return 0; + } +} +/* + * read from bit stream. used from 1 bit to 32 bits + * + */ +static unsigned int readInputBitStream( int bwidth ) +{ + if( bwidth <= 0 ){ + return 0; + } else if( bwidth >= 1 && bwidth <= 8 ){ + return readInputBitStreamBody( bwidth ); + } else if( bwidth >= 9 && bwidth <= 16 ){ + unsigned int first = readInputBitStreamBody(8); + unsigned int second = readInputBitStreamBody( bwidth-8); + return first + (second << 8 ); + } else if( bwidth >= 17 && bwidth <= 24 ){ + unsigned int first = readInputBitStreamBody(8); + unsigned int second = readInputBitStreamBody(8); + unsigned int third = readInputBitStreamBody(bwidth-8); + return first + ( second << 8 ) + ( third << 16 ); + } else if( bwidth >= 25 && bwidth <= 32 ){ + unsigned int first = readInputBitStreamBody(8); + unsigned int second = readInputBitStreamBody(8); + unsigned int third = readInputBitStreamBody(8); + unsigned int forth = readInputBitStreamBody(bwidth-8); + return first + ( second << 8 ) + ( third << 16 ) + ( forth << 24 ); + } + return 0; +} +/* + * write to a bitstream. only used from 1 bit to 8 bits + * this is a base routine. + */ +static int writeOutputBitStreamBody( int bwidth , unsigned char b) +{ + int mod = bitstream_bitaddr % 8; + int byteaddr = bitstream_bitaddr / 8; + /* return error if excess */ + if( bitstream_maxbyte <= (byteaddr+1)) return -1; + bitstream_buf[byteaddr] &= saacproto_modifymask_first[mod][bwidth]; + bitstream_buf[byteaddr] |= (b << mod) & saacproto_modifymask_first[mod][bwidth]; + bitstream_buf[byteaddr+1] &= saacproto_modifymask_second[mod][bwidth]; + bitstream_buf[byteaddr+1] |= (b>>(8-mod))& saacproto_modifymask_second[mod][bwidth]; + bitstream_bitaddr += bwidth; + return byteaddr+1; +} +/* + * write to a bitstream. used from 1 bits to 32 bits + * returns -1 if error or buffer excession + */ +static int writeOutputBitStream( int bwidth, unsigned int dat) +{ + int ret; + if( bwidth <= 0){ + return -1; + } else if( bwidth >= 1 && bwidth <= 8 ){ + if((ret=writeOutputBitStreamBody( bwidth , (unsigned char)dat))<0)return -1; + } else if( bwidth > 8 && bwidth <= 16 ){ + if(writeOutputBitStreamBody( 8 , (unsigned char)(dat&0xff))<0)return -1; + if((ret=writeOutputBitStreamBody( bwidth - 8 , ( unsigned char)((dat>>8)&0xff)))<0)return -1; + } else if( bwidth > 16 && bwidth <= 24 ){ + if(writeOutputBitStreamBody( 8 , (unsigned char)(dat&0xff))<0)return -1; + if(writeOutputBitStreamBody( 8 , (unsigned char)((dat>>8)&0xff))<0)return -1; + if((ret=writeOutputBitStreamBody( bwidth-16,(unsigned char)((dat>>16)&0xff)))<0)return -1; + } else if( bwidth > 24 && bwidth <= 32 ){ + if(writeOutputBitStreamBody( 8 , (unsigned char)(dat&0xff))<0)return -1; + if(writeOutputBitStreamBody( 8 , (unsigned char)((dat>>8)&0xff))<0)return -1; + if(writeOutputBitStreamBody( 8 , (unsigned char)((dat>>16)&0xff))<0)return -1; + if((ret=writeOutputBitStreamBody( bwidth-24,(unsigned char)((dat>>24)&0xff)))<0)return -1; + } else { + return -1; + } + return ret; +} +#define CHAR_SIZE 256 +#define NODE_SIZE 512 +#define BITS_LEN 9 /* 9 bit lzw compression */ +typedef struct { + unsigned char chr; + int parent; + int brother; + int child; +}NODE; +long saacproto_ringoCompressor( unsigned char *code , long codelen , + unsigned char *text , long textlen) +{ + NODE node[NODE_SIZE]; + int freeNode; + int w,k; /* used in this algo */ + int textind; /* index to text buffer */ + int i; + int position = 0; /* indicates the last byte of code buffer */ + if( textlen <= 0 ) return -1; + initOutputBitStream((char*) code,codelen); + /* fill characters ( 0 ~ 255 ) in the beggining part of + Node list */ + for(i=0; i<= CHAR_SIZE; i++){ + node[i].chr = (unsigned char)i; + node[i].brother = i + 1; + node[i].parent = 0; + node[i].child = 0; + } + node[CHAR_SIZE].brother = 0; + freeNode = CHAR_SIZE + 1; + w = text[0]; + textind = 1; + while(1){ + int rv; + if( textind >= textlen ){ + k = CHAR_SIZE; /* indicates EOF */ + } else { + k = text[textind]; + } + /* search if pattern 'wk' is registered or not. */ + rv = node[w].child; + while(1){ + if( rv <= 0 ) break; + if( node[rv].chr == k ) break; + rv = node[rv].brother; + } + if( rv > 0 ){ + /* found it */ + w = rv; + } else { + position = writeOutputBitStream( BITS_LEN ,w ); + /* return if buffer excession */ + if( position > codelen ) return -1; + /* register pattern 'wk' in the dictionary */ + if( freeNode < NODE_SIZE ){ + node[freeNode].parent = w; + node[freeNode].chr = k; + node[freeNode].brother = node[w].child; + node[freeNode].child = 0; + node[w].child = freeNode; + freeNode++; + } + w = k; + } + if( textind == ( textlen + 1 ) ) break; + textind++; + } + return position; +} + +/* + * Decoder. + * return -1 if buffer excession. Notice buffer text + * is modified . + */ +long saacproto_ringoDecompressor( unsigned char *text , long textlen , + unsigned char *code , long codelen) +{ + NODE node[NODE_SIZE]; + int stack[NODE_SIZE]; + int sp; + int freeNode; + int len; + int i; + int k = 0; + int w = 0; + if( codelen <= 0 ) return -1; + initInputBitStream( (char*)code , codelen ); + for(i=0;i= freeNode ){ + stack[sp++] = k; /* exception */ + if( sp >=( sizeof( stack ) /sizeof(stack[0] )) )return -1; + k = w; + } else { + k = rv; + } + while(k> CHAR_SIZE ){ + if( k >= (sizeof(node)/sizeof(node[0]))) return -1; + stack[sp++] = node[k].chr; + k = node[k].parent; + if( sp >=( sizeof( stack ) /sizeof(stack[0] )) ) return -1; + } + stack[sp++] = k; + if( sp >= ( sizeof( stack ) /sizeof(stack[0] )) ) return -1; + /* output to text buffer from stack.*/ + while(sp){ + if( ++len > textlen ) return -1; + *text++ = stack[--sp]; + } + /* register the pattern 'wk'*/ + if( len > 1 && freeNode < NODE_SIZE ){ + node[freeNode].parent = w; + node[freeNode].chr = k; + if( w >= (sizeof(node)/sizeof(node[0])))return -1; + node[freeNode].brother = node[w].child; + node[freeNode].child = 0; + node[w].child = freeNode; + freeNode++; + } + w = rv; + } + return len; +} +#endif /* ifdef saacproto__ENCRYPT */ + +/* Convert 62-base digits to 10 digits */ +int saacproto_a62toi( char *a ) +{ + int ret = 0; + int minus ; + if( a[0] == '-' ){ + minus = -1; + a++; + } else { + minus = 1; + } + + while( *a != '\0' ) + { + ret *= 62; + if( '0' <= (*a) && (*a) <= '9' ) + ret += (*a)-'0'; + else + if( 'a' <= (*a) && (*a) <= 'z' ) + ret += (*a)-'a'+10; + else + if( 'A' <= (*a) && (*a) <= 'Z' ) + ret += (*a)-'A'+36; + else + return 0; + a++; + } + return ret * minus; +} + +/* Convert 10-base digits into 62-base digits. */ +char *saacproto_cnv10to62( int a, char *out, int outlen ) +{ + int i, j; + char base[] = { "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"}; + int tmp[64]; + int src; + int minus; + int baselen = sizeof( base)-1; + if( a < 0 ){ + minus = 1; + a *= -1; + } else { + minus = 0; + } + /* special case */ + if( a < baselen) { + if( minus ){ + *(out) = '-'; + *(out+1) = base[a]; + *(out+2) = '\0'; + return (out); + } else { + *out = base[a]; + *(out+1) = '\0'; + return( out); + } + } + src = a; + for( i = 0; src >= baselen; i ++ ) { + tmp[i] = src % baselen; + src /= baselen; + } + i--; + if( minus ){ + *out = '-'; + *(out+1) = base[src]; + for( j = 2; i >= 0; i --, j ++ ) { + if( j > outlen - 2 ) return NULL; + *(out+j) = base[tmp[i]]; + } + } else { + *out = base[src]; + for( j = 1; i >= 0; i --, j ++ ) { + if( j > outlen - 2 ) return NULL; + *(out+j) = base[tmp[i]]; + } + } + *(out+j) = '\0'; + return( out); +} diff --git a/sasql.c b/sasql.c new file mode 100644 index 0000000..b6f086d --- /dev/null +++ b/sasql.c @@ -0,0 +1,2060 @@ +#define _SASQL_C_ + +#include "version.h" + +//#include "main.h" +#include "sasql.h" +#include "net.h" +#include "common.h" +#include "char_base.h" +#include "char_data.h" +#include "char.h" +#include "lssproto_serv.h" +#include "item.h" +#include "item_event.h" +#include "buf.h" +#include "object.h" +#include "map_deal.h" +#include "saacproto_cli.h" +#include "readmap.h" +#include "handletime.h" +#include "char_event.h" +#include "npccreate.h" +#include "addressbook.h" +#include "item_event.h" +#include "magic_base.h" +#include "magic.h" +#include "chatmagic.h" +#include "configfile.h" +#include "log.h" +#include "anim_tbl.h" +#include "encount.h" +#include "battle.h" +#include "pet_skill.h" +#include "util.h" +#include "enemy.h" +#include "npcutil.h" +#include "pet.h" +#include "family.h" +#include "defend.h" +#include "correct_bug.h" +#include + +extern int fmrankindex[20]; +extern char fmrankname[20][50]; +extern int fmrankpoint[20]; + +MYSQL mysql; +MYSQL serversql; +MYSQL_RES *mysql_result; +MYSQL_ROW mysql_row; + +void easyGetTokenFromString2( char *src,int count,char*output,int len ) +{ + int i; + int counter = 0; + + if( len <= 0 )return; + +#define ISSPACETAB( c ) ( (c) == ' ' || (c) == '\t' ) + + for(i=0;;i++){ + if( src[i]=='\0'){ + output[0] = '\0'; + return; + } + if( i > 0 && ! ISSPACETAB( src[i-1] ) && + ! ISSPACETAB( src[i] ) ){ + continue; + } + + if( ! ISSPACETAB( src[i]) ){ + counter++; + if( counter == count){ + int j; + for(j=0;j0){ + mysql_row=mysql_fetch_row(mysql_result); + mysql_free_result(mysql_result); + if(mysql_row[2]!=NULL){ + if((strcmp(pas,mysql_row[1]) == 0) && (atoi(mysql_row[3])==0 || atoi(mysql_row[3])==getLockType())){ + return 1; + }else{ + //printf("û%s\n",nm); + return 2; + } + }else + { + if(strcmp(pas,mysql_row[1]) == 0 && atoi(mysql_row[3])==0){ + return 1; + }else{ + //printf("û%s\n",nm); + return 2; + } + } + }else{ + mysql_free_result(mysql_result); + //printf("û%sδעᣡ\n",nm); + return 3; + } + }else{ + //printf("\nݿʧܣ\n"); + return 0; + } +} + +int sasql_load_query(char *nm, char *pas){ + char sqlstr[256]; + sprintf(sqlstr,"select `%s`,`%s` from `%s` where `%s`=BINARY'%s'",sqlconfig.sql_NAME,sqlconfig.sql_PASS,sqlconfig.sql_Table,sqlconfig.sql_NAME,nm); + + if(!mysql_query(&mysql,sqlstr)){ + int num_row=0; + mysql_result=mysql_store_result(&mysql); + num_row=mysql_num_rows(mysql_result); + if(num_row>0){ + mysql_row=mysql_fetch_row(mysql_result); + mysql_free_result(mysql_result); + if(strcmp(pas,mysql_row[1]) == 0){ + return 1; + }else{ + printf("û%s\n",nm); + return 2; + } + }else{ + mysql_free_result(mysql_result); + printf("û%sδעᣡ\n",nm); + return 3; + } + }else{ + printf("\nݿʧܣ\n"); + return 0; + } +} + +int sasql_del_query(char *nm, char *pas){ + char sqlstr[256]; + sprintf(sqlstr,"select `%s`,`SafePasswd` from `%s` where `%s`=BINARY'%s'",sqlconfig.sql_NAME,sqlconfig.sql_Table,sqlconfig.sql_NAME,nm); + + if(!mysql_query(&mysql,sqlstr)){ + int num_row=0; + mysql_result=mysql_store_result(&mysql); + num_row=mysql_num_rows(mysql_result); + if(num_row>0){ + mysql_row=mysql_fetch_row(mysql_result); + mysql_free_result(mysql_result); + if(mysql_row[1]!=NULL) + { + if(strcmp(pas,mysql_row[1]) == 0){ + return 1; + }else{ + return 2; + } + }else{ + printf("û%s\n",nm); + return 2; + } + }else{ + mysql_free_result(mysql_result); + printf("û%sδעᣡ\n",nm); + return 3; + } + }else{ + printf("\nݿʧܣ\n"); + return 0; + } +} + + + +BOOL sasql_online( char *ID, char *NM, char *IP,int fame,int vigor, int flag ) +{ + if(openbackground){ + char sqlstr[256]; + if(flag==0) + sprintf(sqlstr,"update `%s` set `Online`=0,`Offline`=0 where `%s`=BINARY'%s'", sqlconfig.sql_Table, sqlconfig.sql_NAME, ID); + else if(flag==1) + { + if(strstr(NM,",")!=NULL) return FALSE; + mysql_query(&mysql,"SET NAMES 'gbk'"); + sprintf(sqlstr,"update `%s` set `LoginTime`=NOW(), `IP`='%s', `OnlineName`='%s', `Online`=%d, `Path`='char/0x%x',`Fame`=%d,`Vigor`=%d where `%s`=BINARY'%s'", sqlconfig.sql_Table, IP, NM, getServernumber(), getHash(ID) & 0xff,fame,vigor, sqlconfig.sql_NAME, ID); + } + else if(flag==2){ + if(strstr(NM,",")!=NULL) return FALSE; + sprintf(sqlstr,"update `%s` set `LoginTime`=NOW(), `OnlineName`='%s', `Online`=%d where `%s`=BINARY'%s'", sqlconfig.sql_Table, NM, getServernumber(), sqlconfig.sql_NAME, ID); + } + else if(flag==3) + sprintf(sqlstr,"update `%s` set `Online`=0,`Offline`=0 where `Online`=%d", sqlconfig.sql_Table, getServernumber()); + else if(flag==4) + sprintf(sqlstr,"update `%s` set `LoginTime`=NOW(),`IP`='%s', `Online`=%d where `%s`=BINARY'%s'", sqlconfig.sql_Table, IP, getServernumber(), sqlconfig.sql_NAME, ID); + else if(flag==5) + sprintf(sqlstr,"update `%s` set `Offline`=1 where `%s`=BINARY'%s'", sqlconfig.sql_Table, sqlconfig.sql_NAME, ID); + if(!mysql_query(&mysql,sqlstr)){ + return TRUE; + } + } + printf("\nݿʧܣ\n"); + return FALSE; +} + +/* +BOOL sasql_online_jqm( char *ID, char *jqm, char *IP, int logintype, char *GHid, char *GHic, char *GHsp ) +{ + if(openbackground){ + + char sqlstr[2048]; + if(strstr(jqm,",")!=NULL || strstr(jqm,"+")!=NULL || strstr(jqm,"?")!=NULL || strstr(jqm,"*")!=NULL || strstr(jqm,"<")!=NULL || strstr(jqm,")")!=NULL || strstr(jqm,"^")!=NULL || strstr(jqm,"`")!=NULL || strstr(jqm,";")!=NULL) + sprintf(sqlstr,"update `%s` set `LoginTime`=NOW(),`IP`='%s',`PcId`='CUOWU', `Online`=%d,`Type`=%d,`GHid`='%s',`GHic`='%s',`GHsp`='%s' where `%s`=BINARY'%s'", sqlconfig.sql_Table, IP, getServernumber(),logintype,GHid,GHic,GHsp, sqlconfig.sql_NAME, ID); + else + sprintf(sqlstr,"update `%s` set `LoginTime`=NOW(),`IP`='%s',`PcId`='%s', `Online`=%d,`Type`=%d,`GHid`='%s',`GHic`='%s',`GHsp`='%s' where `%s`=BINARY'%s'", sqlconfig.sql_Table, IP,jqm, getServernumber(),logintype,GHid,GHic,GHsp, sqlconfig.sql_NAME, ID); + //print("\n sql: %s",sqlstr); + if(!mysql_query(&mysql,sqlstr)){ + return TRUE; + } + } + printf("\nݿʧܣ\n"); + return FALSE; +} +*/ + +BOOL sasql_online_jqm( char *ID, char *jqm, char *IP,int logintype ) +{ + if(openbackground){ + + char sqlstr[256]; + if(strstr(jqm,",")!=NULL || strstr(jqm,"+")!=NULL || strstr(jqm,"?")!=NULL || strstr(jqm,"*")!=NULL || strstr(jqm,"<")!=NULL || strstr(jqm,")")!=NULL || strstr(jqm,"^")!=NULL || strstr(jqm,"`")!=NULL || strstr(jqm,";")!=NULL) + sprintf(sqlstr,"update `%s` set `LoginTime`=NOW(),`IP`='%s',`PcId`='CUOWU', `Online`=%d,`Type`=%d where `%s`=BINARY'%s'", sqlconfig.sql_Table, IP, getServernumber(),logintype, sqlconfig.sql_NAME, ID); + else + sprintf(sqlstr,"update `%s` set `LoginTime`=NOW(),`IP`='%s',`PcId`='%s', `Online`=%d,`Type`=%d where `%s`=BINARY'%s'", sqlconfig.sql_Table, IP,jqm, getServernumber(),logintype, sqlconfig.sql_NAME, ID); + //print("\n sql: %s",sqlstr); + if(!mysql_query(&mysql,sqlstr)){ + return TRUE; + } + } + printf("\nݿʧܣ\n"); + return FALSE; +} + +#ifdef _CAX_NEWMAC_LOGIN +BOOL sasql_online_mac( char *ID, char *mac, char *IP,int logintype ) +{ +// if(openbackground){ + char sqlstr[256]; + sprintf(sqlstr,"update `%s` set `LoginTime`=NOW(),`IP`='%s',`MAC`='%s', `Online`=%d where `%s`=BINARY'%s'", sqlconfig.sql_Table, IP, mac , getServernumber(), sqlconfig.sql_NAME, ID); + if(!sasql_mysql_query(sqlstr)){ + return TRUE; + } +// } + printf("\nݿʧ[mac]\n"); + return FALSE; +} +#endif + +BOOL sasql_register(char *id, char *ps) +{ + char sqlstr[256]; + if(AutoReg!=1)return FALSE; + sprintf(sqlstr,"INSERT INTO `%s` (`%s`,`%s`,`RegTime`,`Path`,`VipPoint`) VALUES (BINARY'%s','%s',NOW(),'char/0x%x',0)",sqlconfig.sql_Table, sqlconfig.sql_NAME, sqlconfig.sql_PASS, id, ps, getHash(id) & 0xff); + if(!mysql_query(&mysql,sqlstr)){ + printf("\nûעɹ\n"); + return TRUE; + } + printf("\nûעʧܣ\n"); + return FALSE; +} + + + +BOOL sasql_chehk_lock( char *idip ) +{ + char sqlstr[256]; + sprintf(sqlstr,"select * from `%s` where `%s`=BINARY'%s'", sqlconfig.sql_LOCK, sqlconfig.sql_NAME, idip); + if(!mysql_query(&mysql,sqlstr)){ + int num_row=0; + mysql_result=mysql_store_result(&mysql); + num_row=mysql_num_rows(mysql_result); + mysql_free_result(mysql_result); + if(num_row>0) + { + return TRUE; + } + else + { + return FALSE; + } + } + return FALSE; +} + +BOOL sasql_add_lock( char *idip ) +{ + char sqlstr[256]; + sprintf(sqlstr,"INSERT INTO `%s` (`%s`) VALUES (BINARY'%s')", sqlconfig.sql_LOCK, sqlconfig.sql_NAME, idip); + if(!mysql_query(&mysql,sqlstr)){ + printf("\n%sɹ\n",idip); + return TRUE; + } + return FALSE; +} + +BOOL sasql_del_lock( char *idip ) +{ + char sqlstr[256]; + sprintf(sqlstr,"delete from `%s` where `%s`=BINARY'%s'", sqlconfig.sql_LOCK, sqlconfig.sql_NAME, idip); + if(!mysql_query(&mysql,sqlstr)){ + printf("\n%sɹ\n",idip); + return TRUE; + } + return FALSE; +} + +int sasql_vippoint( char *ID, int point, int flag ) +{ + char sqlstr[256]; +// print("\NVIPpoint1=%d\n",point); + if(strstr(ID,"'")!=NULL) return -1; + sprintf(sqlstr,"select `VipPoint` from `%s` where `%s`=BINARY'%s'",sqlconfig.sql_Table,sqlconfig.sql_NAME,ID); +// printf("22222222:%s\n",sqlstr); + if(!mysql_query(&mysql,sqlstr)){ + int num_row=0; + mysql_result=mysql_store_result(&mysql); + num_row=mysql_num_rows(mysql_result); + if(num_row>0){ + mysql_row=mysql_fetch_row(mysql_result); + mysql_free_result(mysql_result); + if(flag==0){ + return atoi(mysql_row[0]); + } + if(flag==520){ + sprintf(sqlstr,"update `%s` set `VipPoint`=%d where `%s`=BINARY'%s'", sqlconfig.sql_Table, point,sqlconfig.sql_NAME, ID); + }else{ + point+=atoi(mysql_row[0]); + sprintf(sqlstr,"update `%s` set `VipPoint`=%d where `%s`=BINARY'%s'", sqlconfig.sql_Table, point,sqlconfig.sql_NAME, ID); + } +// printf("33333333:%s\n",sqlstr); + if(!mysql_query(&mysql,sqlstr)){ + return point; + }else{ + return atoi(mysql_row[0]); + } + }else{ + mysql_free_result(mysql_result); + } + } + printf("»Աʧܣ-- %s\n",sqlstr); + return -1; +} + + +int sasql_onlinenum( char *cdkey, char *IP ) +{ + char sqlstr[256]; + sprintf(sqlstr,"select * from `%s` where `%s`='%s' and `Online`>0 and `IP`='%s'",sqlconfig.sql_Table,sqlconfig.sql_NAME,cdkey,IP); + if(!mysql_query(&mysql,sqlstr)){ + int num_row=0; + mysql_result=mysql_store_result(&mysql); + num_row=mysql_num_rows(mysql_result); + mysql_free_result(mysql_result); + if(num_row>0){ + return 0; + } + } + sprintf(sqlstr,"select count(*) from `%s` where `Online`>0 and `Offline`=0 and `IP`='%s'",sqlconfig.sql_Table,IP); + if(!mysql_query(&mysql,sqlstr)){ + int num_row=0; + mysql_result=mysql_store_result(&mysql); + num_row=mysql_num_rows(mysql_result); + if(num_row>0){ + mysql_row=mysql_fetch_row(mysql_result); + mysql_free_result(mysql_result); + return atoi(mysql_row[0]); + }else{ + mysql_free_result(mysql_result); + } + } + return 0; +} + +int sasql_onlinejqmnum( char *jqm, int flag ) +{ + char sqlstr[256]; +// sprintf(sqlstr,"select * from `%s` where `%s`='%s' and `Online`>0 and `PcId`='%s'",sqlconfig.sql_Table,sqlconfig.sql_NAME,cdkey,jqm); +// if(!mysql_query(&mysql,sqlstr)){ +// int num_row=0; +// mysql_result=mysql_store_result(&mysql); +// num_row=mysql_num_rows(mysql_result); +// mysql_free_result(mysql_result); +// if(num_row>0){ +// return 0; +// } +// } + if(flag == 1){ + sprintf(sqlstr,"select count(*) from `%s` where `Online`=%d and `Offline`=0 and `PcId`='%s'",sqlconfig.sql_Table,getServernumber(),jqm); + if(!mysql_query(&mysql,sqlstr)){ + int num_row=0; + mysql_result=mysql_store_result(&mysql); + num_row=mysql_num_rows(mysql_result); + if(num_row>0){ + mysql_row=mysql_fetch_row(mysql_result); + mysql_free_result(mysql_result); + return atoi(mysql_row[0]); + }else{ + mysql_free_result(mysql_result); + } + } + }else{ + sprintf(sqlstr,"select count(*) from `%s` where `Online`>0 and `Offline`=0 and `PcId`='%s'",sqlconfig.sql_Table,jqm); + if(!mysql_query(&mysql,sqlstr)){ + int num_row=0; + mysql_result=mysql_store_result(&mysql); + num_row=mysql_num_rows(mysql_result); + if(num_row>0){ + mysql_row=mysql_fetch_row(mysql_result); + mysql_free_result(mysql_result); + return atoi(mysql_row[0]); + }else{ + mysql_free_result(mysql_result); + } + } + } + return 0; +} + +#ifdef _CAX_NEWMAC_LOGIN +int sasql_onlinemacnum( char *mac, int flag ) +{ + char sqlstr[256]; + if(flag == 1){ + sprintf(sqlstr,"select count(*) from `%s` where `Online`=%d and `MAC`='%s'",sqlconfig.sql_Table,getServernumber(),mac); + if(!sasql_mysql_query(sqlstr)){ + int num_row=0; + mysql_result=mysql_store_result(&mysql); + num_row=mysql_num_rows(mysql_result); + if(num_row>0){ + mysql_row=mysql_fetch_row(mysql_result); + mysql_free_result(mysql_result); + return atoi(mysql_row[0]); + }else{ + mysql_free_result(mysql_result); + } + } + }else{ + sprintf(sqlstr,"select count(*) from `%s` where `Online`>0 and `MAC`='%s'",sqlconfig.sql_Table,mac); + if(!sasql_mysql_query(sqlstr)){ + int num_row=0; + mysql_result=mysql_store_result(&mysql); + num_row=mysql_num_rows(mysql_result); + if(num_row>0){ + mysql_row=mysql_fetch_row(mysql_result); + mysql_free_result(mysql_result); + return atoi(mysql_row[0]); + }else{ + mysql_free_result(mysql_result); + } + } + } + return 0; +} +#endif + +int sasql_query_safepasswd(char *id, char *safepasswd){ + char sqlstr[256]; + sprintf(sqlstr,"select `SafePasswd` from `%s` where `%s`=BINARY'%s'",sqlconfig.sql_Table,sqlconfig.sql_NAME,id); + + if(!mysql_query(&mysql,sqlstr)){ + int num_row=0; + mysql_result=mysql_store_result(&mysql); + num_row=mysql_num_rows(mysql_result); + if(num_row>0){ + mysql_row=mysql_fetch_row(mysql_result); + mysql_free_result(mysql_result); + if(mysql_row[0]!=NULL) + { + if(strcmp(safepasswd,mysql_row[0]) == 0) + { + if(strstr(id,safepasswd)!=NULL) + return 4; + return 1; + } + else + { + printf("\nȫ\n"); + return 2; + } + } + else + { + printf("\nûδдȫ룡\n"); + return 3; + } + }else{ + mysql_free_result(mysql_result); + } + } + else{ + printf("\nݿʧܣ\n"); + return 0; + } +} + +int sasql_add_safepasswd(char *id, char *safepasswd){ + char sqlstr[256]; + if(strstr(safepasswd,",")!=NULL) return 0; + sprintf(sqlstr,"update `%s` set `SafePasswd`=BINARY'%s' where `%s`=BINARY'%s'",sqlconfig.sql_Table,safepasswd,sqlconfig.sql_NAME,id); + + if(!mysql_query(&mysql,sqlstr)){ + printf("û%sðȫɹ\n",id); + return 1; + }else{ + printf("\nݿʧܣ\n"); + return 0; + } +} + +BOOL sasql_add_card(char *pas, int num) +{ + char sqlstr[256]; + sprintf(sqlstr,"INSERT INTO `OnlineCost` (`CostPasswd`,`CostVal`) VALUES (BINARY'%s','%d')", pas, num); + if(!mysql_query(&mysql,sqlstr)){ + return TRUE; + } + return FALSE; +} + +void sasql_query_card(char *id, char *cardps,int charaindex){ + char sqlstr[256]; + if(strstr(id,",")!=NULL){ + CHAR_talkToCli( charaindex, -1, "˺ŷǷ", CHAR_COLORRED); + return; + } + if(strlen(cardps)!=16){ + CHAR_talkToCli( charaindex, -1, "ܲڡ", CHAR_COLORRED); + return; + } + if( strstr(cardps,"/")!=NULL || strstr(cardps,"*")!=NULL || strstr(cardps,"+")!=NULL || strstr(cardps,"-")!=NULL || strstr(cardps,";")!=NULL || strstr(cardps,":")!=NULL || strstr(cardps," ")!=NULL || strstr(cardps,"|")!=NULL || strstr(cardps,".")!=NULL || strstr(cardps,",")!=NULL || strstr(cardps,"'")!=NULL || strstr(cardps,"=")!=NULL || strstr(cardps,"`")!=NULL || strstr(cardps,"<")!=NULL || strstr(cardps,">")!=NULL || strstr(cardps,"!")!=NULL || strstr(cardps,"NULL")!=NULL){ + CHAR_talkToCli( charaindex, -1, "ܷǷ", CHAR_COLORRED); + return; + } + sprintf(sqlstr,"select * from `OnlineCost` where `CostPasswd`=BINARY'%s'",cardps); + + if(!mysql_query(&mysql,sqlstr)){ + int num_row=0; + int check,costval; + mysql_result=mysql_store_result(&mysql); + num_row=mysql_num_rows(mysql_result); + if(num_row>0){ + mysql_row=mysql_fetch_row(mysql_result); + mysql_free_result(mysql_result); + check = atoi(mysql_row[4]); + costval = atoi(mysql_row[1]); + if(check == 1) + { + sprintf(sqlstr,"update `OnlineCost` set `cdkey`=BINARY'%s', `CostTime`=NOW(), `check`=0 where `CostPasswd`=BINARY'%s'",id,cardps); + if(!mysql_query(&mysql,sqlstr)){ + sprintf(sqlstr,"%dֵֽɹڵֽʻΪ%d",costval,sasql_rmbpoint(id,costval,1)); + CHAR_talkToCli( charaindex, -1, sqlstr, CHAR_COLORRED); + } + } + else + { + CHAR_talkToCli( charaindex, -1, "óֵѾʹãظʹãлл", CHAR_COLORRED); //ֵѾʹ + return; + } + } + else + { + mysql_free_result(mysql_result); + CHAR_talkToCli( charaindex, -1, "ֵдд", CHAR_COLORRED); //ֵд + return; + } + } + else{ + printf("\nݿʧܣ\n"); + return; + } +} + + +#ifdef _ONLINE_SHOP +int sasql_chehk_shop( char *dataname ) +{ + char sqlstr[256]; + sprintf(sqlstr,"select * from `%s`", dataname); + if(!mysql_query(&mysql,sqlstr)){ + int num_row=0; + mysql_result=mysql_store_result(&mysql); + num_row=mysql_num_rows(mysql_result); + mysql_free_result(mysql_result); + return num_row; + } + return 0; +} + +char* sasql_query_shop( char *dataname, int startrow, int shopnum ) +{ + char sqlstr[256]; + char shopresult[2048]; + int i; + sprintf(sqlstr,"select * from `%s` LIMIT %d , %d", dataname, startrow, shopnum); + if(!mysql_query(&mysql,sqlstr)){ + int num_row=0; + mysql_result=mysql_store_result(&mysql); + num_row=mysql_num_rows(mysql_result); + if(num_row>0){ + for(i=1;i<=shopnum;i++) + { + mysql_row=mysql_fetch_row(mysql_result); + if(i==1) + { + sprintf(shopresult,"%s#%s#%s#%s#%s#%s#%s|",mysql_row[0],mysql_row[1],mysql_row[2],mysql_row[3],mysql_row[4],mysql_row[5],mysql_row[6]); + } + else + { + sprintf(shopresult,"%s%s#%s#%s#%s#%s#%s#%s|",shopresult,mysql_row[0],mysql_row[1],mysql_row[2],mysql_row[3],mysql_row[4],mysql_row[5],mysql_row[6]); + } + } + mysql_free_result(mysql_result); + return shopresult; + }else + { + mysql_free_result(mysql_result); + return "err"; + } + } + return "err"; +} + +int sasql_buy_shop( char *dataname, int startrow, int shopnum, int shopno ) +{ + char sqlstr[256]; + int i,costnum; + sprintf(sqlstr,"select * from `%s` where `id`=%d", dataname, shopno); + if(!mysql_query(&mysql,sqlstr)){ + int num_row=0; + mysql_result=mysql_store_result(&mysql); + num_row=mysql_num_rows(mysql_result); + if(num_row>0){ + mysql_row=mysql_fetch_row(mysql_result); + mysql_free_result(mysql_result); + costnum = atoi(mysql_row[5])*atoi(mysql_row[4])/100; + return costnum; + }else + { + mysql_free_result(mysql_result); + return 0; + } + } + return 0; +} +#endif + +char* sasql_query_question(void) +{ + char sqlstr[256]; + sprintf(sqlstr,"select * from `Question`"); + if(!mysql_query(&mysql,sqlstr)) + { + int num_row=0; + mysql_result=mysql_store_result(&mysql); + num_row=mysql_num_rows(mysql_result); + mysql_free_result(mysql_result); + if(num_row>0) + { + srand((unsigned)time(NULL)); + int questionid; + questionid = (rand() % num_row)+1; + sprintf(sqlstr,"select * from `Question` where `id`=%d",questionid); + if(!mysql_query(&mysql,sqlstr)) + { + mysql_result=mysql_store_result(&mysql); + num_row=mysql_num_rows(mysql_result); + if(num_row>0) + { + mysql_row=mysql_fetch_row(mysql_result); + mysql_free_result(mysql_result); + char question[256]; + sprintf(question,"%s;%s",mysql_row[1],mysql_row[2]); + return question; + } + return "err"; + } + return "err"; + } + return "err"; + } + return "err"; +} + +#ifdef _ALL_ITEM +int sasql_allnum( int flag, int num, int flag1 ) +{ + char sqlstr[256]; + sprintf(sqlstr,"select * from `AllNum` where `id`=%d",flag); + if(!mysql_query(&mysql,sqlstr)){ + int num_row=0; + mysql_result=mysql_store_result(&mysql); + num_row=mysql_num_rows(mysql_result); + if(num_row>0){ + mysql_row=mysql_fetch_row(mysql_result); + mysql_free_result(mysql_result); + if(flag1==0){ + return atoi(mysql_row[1]); + } + num+=atoi(mysql_row[1]); + sprintf(sqlstr,"update `AllNum` set `num`=%d where `id`=%d", num,flag); + if(!mysql_query(&mysql,sqlstr)){ + return num; + } + } + } + return num; +} +#endif + +BOOL sasql_craete_lock( void ) +{ + +} + +BOOL sasql_craete_userinfo( void ) +{ + +} + + + + + +#ifdef _SQL_BUY_FUNC +char *sasql_OnlineBuy( char *id, char *costpasswd ) +{ + char sqlstr[256]; + if(strstr(id,",")!=NULL) return "ʧܣ˺ŷǷ"; + if(strlen(costpasswd)!=16){ + return "ܲڡ"; + } + if( strstr(costpasswd,"/")!=NULL || strstr(costpasswd,"*")!=NULL || strstr(costpasswd,"+")!=NULL || strstr(costpasswd,"-")!=NULL || strstr(costpasswd,";")!=NULL || strstr(costpasswd,":")!=NULL || strstr(costpasswd," ")!=NULL || strstr(costpasswd,"|")!=NULL || strstr(costpasswd,".")!=NULL || strstr(costpasswd,",")!=NULL || strstr(costpasswd,"'")!=NULL || strstr(costpasswd,"=")!=NULL || strstr(costpasswd,"`")!=NULL || strstr(costpasswd,"<")!=NULL || strstr(costpasswd,">")!=NULL || strstr(costpasswd,"!")!=NULL || strstr(costpasswd,"NULL")!=NULL){ + return "ܷǷ"; + } + static char token[256]=""; + sprintf(sqlstr,"select `CostStr`, `check` from `OnlineBuy` where CostPasswd = BINARY'%s'", costpasswd); + if(!mysql_query(&mysql,sqlstr)){ + int num_row=0; + mysql_result=mysql_store_result(&mysql); + num_row=mysql_num_rows(mysql_result); + if(num_row>0){ + mysql_row=mysql_fetch_row(mysql_result); + mysql_free_result(mysql_result); + if(atoi(mysql_row[1]) == 1){ + char *coststr = mysql_row[0]; + sprintf(sqlstr,"update OnlineBuy set cdkey=BINARY'%s', CostTime=NOW(), `check`=0 where CostPasswd=BINARY'%s'", id, costpasswd); + if(!mysql_query(&mysql,sqlstr)){ + printf("%sȡ\n",costpasswd); + } + sprintf(token, "%c|%s", costpasswd[0], coststr); + + return token; + }else{ + return "ʹùظʹã"; + } + }else{ + return "ʧܣ벻ȷ"; + } + } + return "ʧܣ뱾Աϵ"; +} +void sasql_OnlineBuy_add( char *coststr, int type, int num ) +{ + char sqlstr[256]; + char CostPasswd[32]; + int i, j, k=0; + for(i=0;i= 2){ + printf("ɹ%dʯ\n", k); + } + return ; +} +#endif + +#ifdef _PET_RESET +int sasql_resetpet_point(int petno){ + char sqlstr[256]; + sprintf(sqlstr,"select `Point` from `PetReset` where `PetNo`='%d'",petno); + + if(!mysql_query(&mysql,sqlstr)){ + int num_row=0; + mysql_result=mysql_store_result(&mysql); + num_row=mysql_num_rows(mysql_result); + if(num_row>0){ + mysql_row=mysql_fetch_row(mysql_result); + mysql_free_result(mysql_result); + if(atoi(mysql_row[0]) >= 0){ + return atoi(mysql_row[0]); + }else{ + return -1; + } + }else{ + mysql_free_result(mysql_result); + return -1; + } + }else{ + return -1; + } +} + +int sasql_resetbdpet_point(int petno){ + char sqlstr[256]; + sprintf(sqlstr,"select `BdPoint` from `PetReset` where `PetNo`='%d'",petno); + + if(!mysql_query(&mysql,sqlstr)){ + int num_row=0; + mysql_result=mysql_store_result(&mysql); + num_row=mysql_num_rows(mysql_result); + if(num_row>0){ + mysql_row=mysql_fetch_row(mysql_result); + mysql_free_result(mysql_result); + if(atoi(mysql_row[0]) > 0){ + return atoi(mysql_row[0]); + }else{ + return -1; + } + }else{ + mysql_free_result(mysql_result); + return -1; + } + }else{ + return -1; + } +} +#endif + +#ifdef _ZHIPIAO_SYSTEM +int sasql_zhipiao_insert(char *petno,char *cdkey,int point){ + char sqlstr[256]; + char ip[32]; + if(strstr(cdkey,",")!=NULL) return -1; + //print("\npoint=%d\n",point); + sprintf(sqlstr,"select `IP` from `%s` where `%s`=BINARY'%s'",sqlconfig.sql_Table,sqlconfig.sql_NAME,cdkey); + if(!mysql_query(&mysql,sqlstr)){ + int num_row=0; + mysql_result=mysql_store_result(&mysql); + num_row=mysql_num_rows(mysql_result); + if(num_row>0){ + mysql_row=mysql_fetch_row(mysql_result); + mysql_free_result(mysql_result); + if(atoi(mysql_row[0]) >= 0){ + sprintf(ip,mysql_row[0]); + }else{ + return -1; + } + }else{ + mysql_free_result(mysql_result); + return -1; + } + } + sprintf(sqlstr,"INSERT INTO ZhiPiao (PiaoNo, Point,Cdkey1,Date1,IP1) VALUES (BINARY'%s', %d,'%s',NOW(),'%s')", petno, point,cdkey,ip); + if(!mysql_query(&mysql,sqlstr)){ + return 1; + }else{ + return -1; + } +} + +int sasql_zhipiao_query(char *piaono){ + char sqlstr[256]; + sprintf(sqlstr,"select `Point`,`check` from `ZhiPiao` where `PiaoNo`='%s'",piaono); + + if(!mysql_query(&mysql,sqlstr)){ + int num_row=0; + mysql_result=mysql_store_result(&mysql); + num_row=mysql_num_rows(mysql_result); + if(num_row>0){ + mysql_row=mysql_fetch_row(mysql_result); + mysql_free_result(mysql_result); + if(atoi(mysql_row[1]) == 1){ + return atoi(mysql_row[0]); + }else{ + return 0; + } + }else{ + mysql_free_result(mysql_result); + return -1; + } + }else{ + return -1; + } +} + +int sasql_zhipiao_update(char *cdkey,char *piaono,int checktype){ + if(strstr(cdkey,",")!=NULL) return -1; + char sqlstr[256]; + char ip[32]; + sprintf(sqlstr,"select `IP` from `%s` where `%s`=BINARY'%s'",sqlconfig.sql_Table,sqlconfig.sql_NAME,cdkey); + if(!mysql_query(&mysql,sqlstr)){ + int num_row=0; + mysql_result=mysql_store_result(&mysql); + num_row=mysql_num_rows(mysql_result); + if(num_row>0){ + mysql_row=mysql_fetch_row(mysql_result); + mysql_free_result(mysql_result); + if(atoi(mysql_row[0]) >= 0){ + sprintf(ip,mysql_row[0]); + }else{ + return -1; + } + }else{ + mysql_free_result(mysql_result); + return -1; + } + } + sprintf(sqlstr,"update ZhiPiao set Cdkey2=BINARY'%s', Date2=NOW(), `IP2`='%s', `check`=%d where PiaoNo=BINARY'%s'", cdkey,ip ,checktype,piaono); + if(!mysql_query(&mysql,sqlstr)){ + return 1; + }else{ + return -1; + } +} +#endif +#ifdef _FMRANK_POINT +int sasql_fm_query(void){ + char sqlstr[256]; + mysql_query(&mysql,"SET NAMES 'gbk'"); + sprintf(sqlstr,"select * from `FmRank` ORDER by `Point` desc"); + + if(!mysql_query(&mysql,sqlstr)){ + int num_row=0; + mysql_result=mysql_store_result(&mysql); + num_row=mysql_num_rows(mysql_result); + if(num_row>0){ + int i=0; + while((mysql_row=mysql_fetch_row(mysql_result)) && i<20){ + fmrankindex[i]=atoi(mysql_row[0]); + sprintf(fmrankname[i],"%s",mysql_row[1]); + fmrankpoint[i]=atoi(mysql_row[2]); + i++; + } + mysql_free_result(mysql_result); + return i; + }else{ + mysql_free_result(mysql_result); + return -1; + } + }else{ + return -1; + } +} + +int sasql_fmpoint_query(int fmindex){ + char sqlstr[256]; + mysql_query(&mysql,"SET NAMES 'gbk'"); + sprintf(sqlstr,"select `Point` from `FmRank` where `Index`='%d'",fmindex); + + if(!mysql_query(&mysql,sqlstr)){ + int num_row=0; + mysql_result=mysql_store_result(&mysql); + num_row=mysql_num_rows(mysql_result); + if(num_row>0){ + mysql_row=mysql_fetch_row(mysql_result); + mysql_free_result(mysql_result); + return atoi(mysql_row[0]); + }else{ + mysql_free_result(mysql_result); + return -1; + } + }else{ + return -1; + } +} + +int sasql_fmno_query(int fmindex){ + char sqlstr[256]; + sprintf(sqlstr,"select `Index` from `FmRank` ORDER by `Point` desc"); + + if(!mysql_query(&mysql,sqlstr)){ + int num_row=0; + mysql_result=mysql_store_result(&mysql); + num_row=mysql_num_rows(mysql_result); + if(num_row>0){ + int i=1; + while((mysql_row=mysql_fetch_row(mysql_result))){ + if(atoi(mysql_row[0])==fmindex) + return i; + i++; + } + mysql_free_result(mysql_result); + return -1; + }else{ + mysql_free_result(mysql_result); + return -1; + } + }else{ + return -1; + } +} + +int sasql_fmpoint_add(int fmindex,int point){ + char sqlstr[256]; + sprintf(sqlstr,"update `FmRank` set `Point`=%d where `Index`=%d",point,fmindex); + + if(!mysql_query(&mysql,sqlstr)){ + return 1; + }else{ + return -1; + } +} + +int sasql_fmindex_add(int fmindex,char *fmname,int point){ + char sqlstr[256]; + mysql_query(&mysql,"SET NAMES 'gbk'"); + sprintf(sqlstr,"INSERT INTO `FmRank` (`Index`,`Name`,`Point`) VALUES (%d,'%s',%d)",fmindex,fmname,point); + + if(!mysql_query(&mysql,sqlstr)){ + return 1; + }else{ + return -1; + } +} + +int sasql_fmindex_del(int fmindex){ + char sqlstr[256]; + sprintf(sqlstr,"DELETE FROM `FmRank` where `Index`=%d",fmindex); + + if(!mysql_query(&mysql,sqlstr)){ + return 1; + }else{ + return -1; + } +} +#endif +#ifdef _ITEM_RESET +int sasql_itemreset_query(int itemid){ + char sqlstr[256]; + sprintf(sqlstr,"select `ResetPoint` from `ItemReset` where `Id`='%d'",itemid); + + if(!mysql_query(&mysql,sqlstr)){ + int num_row=0; + mysql_result=mysql_store_result(&mysql); + num_row=mysql_num_rows(mysql_result); + if(num_row>0){ + mysql_row=mysql_fetch_row(mysql_result); + mysql_free_result(mysql_result); + return atoi(mysql_row[0]); + }else{ + mysql_free_result(mysql_result); + return -1; + } + }else{ + return -1; + } +} +int sasql_itemdel_query(int itemid){ + char sqlstr[256]; + sprintf(sqlstr,"select `DelPoint` from `ItemReset` where `Id`='%d'",itemid); + + if(!mysql_query(&mysql,sqlstr)){ + int num_row=0; + mysql_result=mysql_store_result(&mysql); + num_row=mysql_num_rows(mysql_result); + if(num_row>0){ + mysql_row=mysql_fetch_row(mysql_result); + mysql_free_result(mysql_result); + return atoi(mysql_row[0]); + }else{ + mysql_free_result(mysql_result); + return -1; + } + }else{ + return -1; + } +} +#endif + +int sasql_cdkey_lock(char *cdkey,int locktype){ + char sqlstr[256]; + sprintf(sqlstr,"select * from `%s` where `%s`=BINARY'%s'",sqlconfig.sql_Table,sqlconfig.sql_NAME, cdkey); + if(!mysql_query(&mysql,sqlstr)){ + int num_row=0; + mysql_result=mysql_store_result(&mysql); + num_row=mysql_num_rows(mysql_result); + if(num_row>0){ + mysql_row=mysql_fetch_row(mysql_result); + mysql_free_result(mysql_result); + sprintf(sqlstr,"update `%s` set `Lock`=%d where `%s`=BINARY'%s'", sqlconfig.sql_Table,locktype,sqlconfig.sql_NAME, cdkey); + if(!mysql_query(&mysql,sqlstr)){ + return 1; + }else{ + return -1; + } + }else{ + mysql_free_result(mysql_result); + } + } + return -1; +} + +int sasql_ampoint( char *ID, int point, int flag ) +{ + char sqlstr[256]; + sprintf(sqlstr,"select `AmPoint` from `%s` where `%s`=BINARY'%s'",sqlconfig.sql_Table,sqlconfig.sql_NAME,ID); + if(!mysql_query(&mysql,sqlstr)){ + int num_row=0; + mysql_result=mysql_store_result(&mysql); + num_row=mysql_num_rows(mysql_result); + if(num_row>0){ + mysql_row=mysql_fetch_row(mysql_result); + mysql_free_result(mysql_result); + if(flag==0){ + return atoi(mysql_row[0]); + } + point+=atoi(mysql_row[0]); + sprintf(sqlstr,"update `%s` set `AmPoint`=%d where `%s`=BINARY'%s'", sqlconfig.sql_Table, point,sqlconfig.sql_NAME, ID); + if(!mysql_query(&mysql,sqlstr)){ + return point; + }else{ + return atoi(mysql_row[0]); + } + }else{ + mysql_free_result(mysql_result); + } + } + printf("%sʧܣ\n",ID); + return -1; +} + +#ifdef _RMB_SYSTEM +int sasql_rmbpoint( char *ID, int point, int flag ) +{ + char sqlstr[256]; + sprintf(sqlstr,"select `RMBPOINT` from `%s` where `%s`=BINARY'%s'",sqlconfig.sql_Table,sqlconfig.sql_NAME,ID); + if(!mysql_query(&mysql,sqlstr)){ + int num_row=0; + mysql_result=mysql_store_result(&mysql); + num_row=mysql_num_rows(mysql_result); + if(num_row>0){ + mysql_row=mysql_fetch_row(mysql_result); + mysql_free_result(mysql_result); + if(flag==0){ + return atoi(mysql_row[0]); + } + point+=atoi(mysql_row[0]); + sprintf(sqlstr,"update `%s` set `RMBPOINT`=%d where `%s`=BINARY'%s'", sqlconfig.sql_Table, point,sqlconfig.sql_NAME, ID); + if(!mysql_query(&mysql,sqlstr)){ + return point; + }else{ + return atoi(mysql_row[0]); + } + }else{ + mysql_free_result(mysql_result); + } + } + printf("%sֽʧܣ\n",ID); + return -1; +} +#endif + +int sasql_cdkey_online( char *cdkey ) +{ + char sqlstr[256]; + sprintf(sqlstr,"select `Online` from `%s` where `%s`='%s'",sqlconfig.sql_Table,sqlconfig.sql_NAME,cdkey); + if(!mysql_query(&mysql,sqlstr)){ + int num_row=0; + mysql_result=mysql_store_result(&mysql); + num_row=mysql_num_rows(mysql_result); + if(num_row>0){ + mysql_row=mysql_fetch_row(mysql_result); + mysql_free_result(mysql_result); + return atoi(mysql_row[0]); + }else{ + mysql_free_result(mysql_result); + return 0; + } + } + return 0; +} + +int sasql_check_iponline( char *IP ) +{ + char sqlstr[256]; + sprintf(sqlstr,"select * from `%s` where `IP`='%s'",sqlconfig.sql_Table,IP); + if(!mysql_query(&mysql,sqlstr)){ + int num_row=0; + mysql_result=mysql_store_result(&mysql); + num_row=mysql_num_rows(mysql_result); + mysql_free_result(mysql_result); + if(num_row>0){ + return 1; + }else{ + return 0; + } + } + return -1; +} + +#ifdef _EV_NUM +char* sasql_ev_npcmsg( int npcno ) +{ + char sqlstr[256]; + sprintf(sqlstr,"select * from `EvNpc` where `No`='%d'",npcno); + if(!mysql_query(&mysql,sqlstr)){ + int num_row=0; + mysql_result=mysql_store_result(&mysql); + num_row=mysql_num_rows(mysql_result); + if(num_row>0){ + mysql_row=mysql_fetch_row(mysql_result); + mysql_free_result(mysql_result); + return mysql_row[1]; + } + mysql_free_result(mysql_result); + } + return "err"; +} + +char* sasql_ev_item( void ) +{ + char sqlstr[256]; + sprintf(sqlstr,"select count(*) from `EvItem`"); + if(!mysql_query(&mysql,sqlstr)){ + int num_row=0; + mysql_result=mysql_store_result(&mysql); + num_row=mysql_num_rows(mysql_result); + if(num_row>0){ + mysql_row=mysql_fetch_row(mysql_result); + mysql_free_result(mysql_result); + int itemno; + itemno = RAND(1,atoi(mysql_row[0])); + sprintf(sqlstr,"select `Id`,`MixNum`,`MaxNum` from `EvItem` where `No`='%d'",itemno); + if(!mysql_query(&mysql,sqlstr)){ + mysql_result=mysql_store_result(&mysql); + num_row=mysql_num_rows(mysql_result); + if(num_row>0){ + mysql_row=mysql_fetch_row(mysql_result); + mysql_free_result(mysql_result); + int itemnum = RAND(atoi(mysql_row[1]),atoi(mysql_row[2])); + sprintf(sqlstr,"%d|%d",atoi(mysql_row[0]),itemnum); + return sqlstr; + } + } + } + mysql_free_result(mysql_result); + } + return "err"; +} + +char* sasql_ev_pet( void ) +{ + char sqlstr[256]; + sprintf(sqlstr,"select count(*) from `EvPet`"); + if(!mysql_query(&mysql,sqlstr)){ + int num_row=0; + mysql_result=mysql_store_result(&mysql); + num_row=mysql_num_rows(mysql_result); + if(num_row>0){ + mysql_row=mysql_fetch_row(mysql_result); + mysql_free_result(mysql_result); + int petno; + petno = RAND(1,atoi(mysql_row[0])); + sprintf(sqlstr,"select `PicId`,`Name`,`MixLv`,`MaxLv` from `EvItem` where `No`='%d'",petno); + if(!mysql_query(&mysql,sqlstr)){ + mysql_result=mysql_store_result(&mysql); + num_row=mysql_num_rows(mysql_result); + if(num_row>0){ + mysql_row=mysql_fetch_row(mysql_result); + mysql_free_result(mysql_result); + sprintf(sqlstr,"%d|%s|%d|%d",atoi(mysql_row[0]),mysql_row[1],atoi(mysql_row[2]),atoi(mysql_row[3])); + return sqlstr; + } + } + } + mysql_free_result(mysql_result); + } + return "err"; +} +#endif + +char* sasql_rand_buf( void ) +{ + char sqlstr[256]; + sprintf(sqlstr,"select count(*) from `RandBuf`"); + if(!mysql_query(&mysql,sqlstr)){ + int num_row=0; + mysql_result=mysql_store_result(&mysql); + num_row=mysql_num_rows(mysql_result); + if(num_row>0){ + mysql_row=mysql_fetch_row(mysql_result); + mysql_free_result(mysql_result); + int randno; + randno = RAND(1,atoi(mysql_row[0])); + sprintf(sqlstr,"select * from `RandBuf` LIMIT %d,%d",randno-1,randno); + if(!mysql_query(&mysql,sqlstr)){ + mysql_result=mysql_store_result(&mysql); + num_row=mysql_num_rows(mysql_result); + if(num_row>0){ + mysql_row=mysql_fetch_row(mysql_result); + mysql_free_result(mysql_result); + sprintf(sqlstr,"%s|%s|%s|%s|%s|%s",mysql_row[0],mysql_row[1],mysql_row[2],mysql_row[3],mysql_row[4],mysql_row[5]); + return sqlstr; + } + } + } + mysql_free_result(mysql_result); + } + return "err"; +} + +int sasql_check_lockmac( char *mac) +{ + char sqlstr[256]; + sprintf(sqlstr,"select * from `LockMac` where `MAC`='%s'",mac); + if(!mysql_query(&mysql,sqlstr)){ + int num_row=0; + mysql_result=mysql_store_result(&mysql); + num_row=mysql_num_rows(mysql_result); + mysql_free_result(mysql_result); + if(num_row>0){ + return 1; + }else{ + return 0; + } + } + return -1; +} + +int sasql_check_lockpcid( char *pcid) +{ + char sqlstr[256]; + sprintf(sqlstr,"select * from `LockMac` where `PcId`='%s'",pcid); + if(!mysql_query(&mysql,sqlstr)){ + int num_row=0; + mysql_result=mysql_store_result(&mysql); + num_row=mysql_num_rows(mysql_result); + mysql_free_result(mysql_result); + if(num_row>0){ + return 1; + }else{ + return 0; + } + } + return -1; +} + +int sasql_check_lockip( char *IP , int type ) +{ + char sqlstr[256]; + sprintf(sqlstr,"select * from `LockIP` where `IP`='%s' and `TYPE`=%d",IP,type); + if(!mysql_query(&mysql,sqlstr)){ + int num_row=0; + mysql_result=mysql_store_result(&mysql); + num_row=mysql_num_rows(mysql_result); + mysql_free_result(mysql_result); + if(num_row>0){ + return 1; + }else{ + return 0; + } + } + return -1; +} +int sasql_add_lockip(char *IP,int type,int online,int mode){ + char sqlstr[256]; + sprintf(sqlstr,"INSERT INTO `LockIP` (`IP`,`TYPE`,`Online`,`Mode`) VALUES ('%s',%d,%d,%d)",IP,type,online,mode); + + if(!mysql_query(&mysql,sqlstr)){ + return 1; + }else{ + return -1; + } +} + +int sasql_query_online_ip(char *IP){ + char sqlstr[256]; + sprintf(sqlstr,"select * from `OnlineIP` where `IP`='%s'",IP); + if(!mysql_query(&mysql,sqlstr)){ + int num_row=0; + mysql_result=mysql_store_result(&mysql); + num_row=mysql_num_rows(mysql_result); + mysql_free_result(mysql_result); + if(num_row>0){ + return 1; + }else{ + return 0; + } + } + return -1; +} + +int sasql_online_ip(char *cdkey,char *IP){ + char sqlstr[256]; + sprintf(sqlstr,"select * from `OnlineIP` where `Name`='%s'",cdkey); + if(!mysql_query(&mysql,sqlstr)){ + int num_row=0; + mysql_result=mysql_store_result(&mysql); + num_row=mysql_num_rows(mysql_result); + mysql_free_result(mysql_result); + if(num_row>0){ + sprintf(sqlstr,"update `OnlineIP` set `IP`='%s',`LoginTime`=NOW() where `Name`='%s'",IP,cdkey); + if(!mysql_query(&mysql,sqlstr)){ + return 1; + }else{ + return 0; + } + }else{ + sprintf(sqlstr,"INSERT INTO `OnlineIP` (`Name`,`IP`,`LoginTime`) VALUES ('%s','%s',NOW())",cdkey,IP); + if(!mysql_query(&mysql,sqlstr)){ + return 1; + }else{ + return 0; + } + } + } + return -1; +} + +int sasql_offlinenum( char *IP ) +{ + char sqlstr[256]; + sprintf(sqlstr,"select count(*) from `%s` where `Online`=%d and `Offline`=1 and `IP`='%s'",sqlconfig.sql_Table,getServernumber(),IP); + if(!mysql_query(&mysql,sqlstr)){ + int num_row=0; + mysql_result=mysql_store_result(&mysql); + num_row=mysql_num_rows(mysql_result); + if(num_row>0){ + mysql_row=mysql_fetch_row(mysql_result); + mysql_free_result(mysql_result); + return atoi(mysql_row[0]); + }else{ + mysql_free_result(mysql_result); + } + } + return 0; +} + +int sasql_offlinejqmnum( char *cdkey ) +{ + char sqlstr[256]; + char *pcid = NULL; + sprintf(sqlstr,"select `PcId` from `%s` where `%s`=BINARY'%s'",sqlconfig.sql_Table,sqlconfig.sql_NAME,cdkey); + if(!mysql_query(&mysql,sqlstr)){ + int num_row=0; + mysql_result=mysql_store_result(&mysql); + num_row=mysql_num_rows(mysql_result); + if(num_row>0){ + mysql_row=mysql_fetch_row(mysql_result); + mysql_free_result(mysql_result); + pcid = mysql_row[0]; + if(pcid == NULL) return 0; + sprintf(sqlstr,"select count(*) from `%s` where `Online`=%d and `Offline`>0 and `PcId`='%s'",sqlconfig.sql_Table,getServernumber(),pcid); + if(!mysql_query(&mysql,sqlstr)){ + num_row=0; + mysql_result=mysql_store_result(&mysql); + num_row=mysql_num_rows(mysql_result); + if(num_row>0){ + mysql_row=mysql_fetch_row(mysql_result); + mysql_free_result(mysql_result); + return atoi(mysql_row[0]); + } + } + }else{ + mysql_free_result(mysql_result); + } + } + return 0; +} + +char* sasql_ip( char *cdkey ) +{ + char sqlstr[256]; + sprintf(sqlstr,"select `IP` from `%s` where `%s`=BINARY'%s'",sqlconfig.sql_Table,sqlconfig.sql_NAME,cdkey); + if(!mysql_query(&mysql,sqlstr)){ + int num_row=0; + mysql_result=mysql_store_result(&mysql); + num_row=mysql_num_rows(mysql_result); + if(num_row>0){ + mysql_row=mysql_fetch_row(mysql_result); + mysql_free_result(mysql_result); + return mysql_row[0]; + }else{ + mysql_free_result(mysql_result); + } + } + return "err"; +} + +char* sasql_query_jqm( char *cdkey ) +{ + char sqlstr[256]; + sprintf(sqlstr,"select `PcId` from `%s` where `%s`=BINARY'%s'",sqlconfig.sql_Table,sqlconfig.sql_NAME,cdkey); + //print("\n sqlstr=%s",sqlstr); + if(!mysql_query(&mysql,sqlstr)){ + int num_row=0; + mysql_result=mysql_store_result(&mysql); + num_row=mysql_num_rows(mysql_result); + if(num_row>0){ + mysql_row=mysql_fetch_row(mysql_result); + mysql_free_result(mysql_result); + return mysql_row[0]; + }else{ + mysql_free_result(mysql_result); + } + } + return "err"; +} + +int sasql_setVipPoint( int charaindex, int point ) +{ + char sqlstr[256]; + char *id = CHAR_getChar(charaindex, CHAR_CDKEY); + sprintf(sqlstr,"update %s set VipPoint=%d where %s=BINARY'%s'", sqlconfig.sql_Table, point, sqlconfig.sql_NAME, id); + + if(!mysql_query(&mysql,sqlstr)){ + //printf("û%sǰػر%d\n",id,point); + return point; + } + return -1; +} + +int sasql_getVipPoint( int charaindex ) +{ + char sqlstr[256]; + char *id = CHAR_getChar(charaindex, CHAR_CDKEY); + sprintf(sqlstr,"select VipPoint from `%s` where %s=BINARY'%s'", sqlconfig.sql_Table, sqlconfig.sql_NAME, id); + + if(!mysql_query(&mysql,sqlstr)){ + int num_row=0; + // mysql_free_result(mysql_result); + mysql_result=mysql_store_result(&mysql); + num_row=mysql_num_rows(mysql_result); + if(num_row>0){ + mysql_row=mysql_fetch_row(mysql_result); + mysql_free_result(mysql_result); + + return atoi(mysql_row[0]); + } + } +// printf("\nݿʧܣ\n"); + printf("ݿ[3]..."); +// sasql_close(); +// sasql_init(); + printf("\n"); + return -1; +} + +int sasql_setVipPointForCdkey( char *id, int point ) +{ + if(sasql_ckeckStrint(id) == FALSE){ + printf("쳣ַû%s\n",id); + return -1; + } + + char sqlstr[256]; + sprintf(sqlstr,"update %s set VipPoint=%d where %s=BINARY'%s'", sqlconfig.sql_Table, point, sqlconfig.sql_NAME, id); + + if(!mysql_query(&mysql,sqlstr)){ + //printf("û%sǰػر%d\n",id,point); + return point; + } + return -1; +} + + +int sasql_getVipPointForCdkey( char *id ) +{ + if(sasql_ckeckStrint(id) == FALSE){ + printf("쳣ַû%s\n",id); + return -1; + } + + char sqlstr[256]; + sprintf(sqlstr,"select VipPoint from `%s` where %s=BINARY'%s'", sqlconfig.sql_Table, sqlconfig.sql_NAME, id); + + if(!mysql_query(&mysql,sqlstr)){ + int num_row=0; + mysql_result=mysql_store_result(&mysql); + num_row=mysql_num_rows(mysql_result); + if(num_row>0){ + mysql_row=mysql_fetch_row(mysql_result); + mysql_free_result(mysql_result); + + return atoi(mysql_row[0]); + } + } +// printf("\nݿʧܣ\n"); + printf("ݿ[2]..."); +// sasql_close(); +// sasql_init(); + printf("\n"); + return -1; +} + +BOOL sasql_ckeckStrint( char *str ) +{ + int i; + for(i=0;i 'z') && (str[i] < 'A' || str[i] > 'Z') && (str[i] < '0' || str[i] > '9') && (str[i] != '.')){ + return FALSE; + } + } + return TRUE; +} + +#ifdef _CARD_PRODUCTION +/** + * ɳֵ + */ +void sasql_OnlineCost_add( int cost, int num) +{ + char sqlstr[256]; + char CostPasswd[32]; + memset( CostPasswd, 0, sizeof( CostPasswd ) ); + int i, j, k=0; + for(i=0;i0){ + mysql_row=mysql_fetch_row(mysql_result); + mysql_free_result(mysql_result); + return atoi(mysql_row[0]); + } + } + printf("»ֵʧ\n"); + return -1; +} + +int sasql_setJfPoint( int charaindex, int point ) +{ + char sqlstr[256]; + char *id = CHAR_getChar(charaindex, CHAR_CDKEY); + sprintf(sqlstr,"update %s set AmPoint=%d where %s=BINARY'%s'", sqlconfig.sql_Table, point, sqlconfig.sql_NAME, id); + if(!mysql_query(&mysql,sqlstr)){ +//if(!sasql_mysql_query(sqlstr)){ + return point; + } + return -1; +} + +int sasql_xjPoint( int charaindex ) +{ +//printf("ݿ\n"); + char sqlstr[256]; + char *id = CHAR_getChar(charaindex, CHAR_CDKEY); + sprintf(sqlstr,"select RMBPOINT from `%s` where %s=BINARY'%s'", sqlconfig.sql_Table, sqlconfig.sql_NAME, id); + + if(!mysql_query(&mysql,sqlstr)){ + int num_row=0; + mysql_result=mysql_store_result(&mysql); + num_row=mysql_num_rows(mysql_result); + if(num_row>0){ + mysql_row=mysql_fetch_row(mysql_result); + mysql_free_result(mysql_result); + return atoi(mysql_row[0]); + } + } + printf("RMBʧ\n"); + return -1; +} + +int sasql_setxjPoint( int charaindex, int point ) +{ + char sqlstr[256]; + char *id = CHAR_getChar(charaindex, CHAR_CDKEY); + sprintf(sqlstr,"update %s set RMBPOINT=%d where %s=BINARY'%s'", sqlconfig.sql_Table, point, sqlconfig.sql_NAME, id); + if(!mysql_query(&mysql,sqlstr)){ +//if(!sasql_mysql_query(sqlstr)){ + return point; + } + return -1; +} + +struct youx{ + int result; + int flg; + int errnono; + char* errstr; + int fieldCount; + int rowCount; + int rowAt; +}retlua; + + +#ifdef _CAX_LNS_MYSQLSUOXU +void sasql_LUASQLAdv(char* sqlstr,char* filepath,char* function,int npcindex ,int charaindex,char* msg,int flg) +{ + char* data = sasql_LuaAdv_QueryR(sqlstr,flg); + NPC_Lua_SQLPushAdvCallBack(retlua.result,retlua.flg,retlua.errnono,retlua.errstr,retlua.fieldCount ,retlua.rowCount ,retlua.rowAt, data,filepath,function,npcindex,charaindex,msg ); +} +char* sasql_LuaAdv_QueryR(char *sqlstr,int flg) +{ + int rowAtt = 0; + static char buff[1024] = ""; + snprintf(buff,1024, ""); + buff[1023]='\0'; + /*ʼϢ*/ + retlua.result = 0;//ERROR + retlua.flg = flg;// + retlua.errnono = 0;//MYSQL + retlua.errstr = "";//MYSQLϢ + retlua.fieldCount = 0;//ѯĿ + retlua.rowCount = 0;//ѯ + retlua.rowAt = 0;//ǰ¼ + + + if (flg == 1 || flg == 2){ + + if(!mysql_query(&mysql,sqlstr)){ + int num_row=0; + mysql_result=mysql_store_result(&mysql); + num_row=mysql_num_rows(mysql_result);// + if (mysql_result == NULL) + { + retlua.result = -2; + }else if (mysql_eof(mysql_result)) + { + retlua.result = -3; + } + + if(num_row>0){ + + mysql_row = mysql_fetch_row(mysql_result);//Ӳѯȡһ + + retlua.errnono = mysql_errno(&mysql);// + retlua.errstr = mysql_error(&mysql);//Ϣ + retlua.fieldCount = mysql_field_count(&mysql);// + + retlua.rowCount = num_row;// + rowAtt++; + retlua.rowAt = rowAtt;//ǰ + if (flg == 1){ + mysql_free_result(mysql_result);//ͷŽ + mysql_result = NULL; + rowAtt = 0; + } + + int i; + for (i=0;i 15) retlua.result = -1; + return buff; + }else { + retlua.errnono = mysql_errno(&mysql); + retlua.errstr = mysql_error(&mysql); + } + } + }else if (flg == 3){ + + + int num_row=0; + if (mysql_result == NULL) { + retlua.result = -2; + return "Ѿͷš"; + } + num_row=mysql_num_rows(mysql_result);// + if (mysql_eof(mysql_result)) + { + retlua.result = -3;//Ѵﵽβˣȸѣѯ潫Զͷš + } + if (num_row == rowAtt) { + mysql_free_result(mysql_result);//ͷŽ + mysql_result = NULL; + rowAtt = 0; + retlua.result = -3; + return "ѵβУԶͷŽ"; + } + if(num_row>0){ + mysql_row = mysql_fetch_row(mysql_result);//Ӳѯȡһ + retlua.errnono = mysql_errno(&mysql);// + retlua.errstr = mysql_error(&mysql);//Ϣ + rowAtt++; + retlua.rowAt = rowAtt;//ǰ + retlua.fieldCount = mysql_field_count(&mysql);// + retlua.rowCount = num_row;// + if (num_row > 15) retlua.result = -1; + int i; + for (i=0;i0){ + mysql_row = mysql_fetch_row(mysql_result); + return (char*)mysql_row[row]; + } + }else + return "SQL Query ERROR"; +} +#endif + +#ifdef _CAX_NEWMAC_LOGIN +char* sasql_query_mac( char *cdkey ) +{ + char sqlstr[256]; + sprintf(sqlstr,"select `MAC` from `%s` where `%s`=BINARY'%s'",sqlconfig.sql_Table,sqlconfig.sql_NAME,cdkey); + //print("\n sqlstr=%s",sqlstr); + if(!mysql_query(&mysql,sqlstr)){ + int num_row=0; + mysql_result=mysql_store_result(&mysql); + num_row=mysql_num_rows(mysql_result); + if(num_row>0){ + mysql_row=mysql_fetch_row(mysql_result); + mysql_free_result(mysql_result); + return mysql_row[0]; + }else{ + mysql_free_result(mysql_result); + } + } + return "err"; +} +#endif diff --git a/start.bat b/start.bat new file mode 100644 index 0000000..7748b98 --- /dev/null +++ b/start.bat @@ -0,0 +1,3 @@ +del *.bak /S +del *.a /S +del *.o /S \ No newline at end of file diff --git a/util.c b/util.c new file mode 100644 index 0000000..b26bfce --- /dev/null +++ b/util.c @@ -0,0 +1,1819 @@ +#include "version.h" +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "common.h" +#include "util.h" +#include "configfile.h" +#include +#define IS_2BYTEWORD( _a_ ) ( (char)(0x80) <= (_a_) && (_a_) <= (char)(0xFF) ) + +/*----------------------------------------- + 깴ݱëǷ + ¦ѡ 缰 ٯ ʽľ + + windows , macintosh , unixָɱƥ£ + + windows : \r\n + macintosh : \n\r + unix : \n + + ׾ئ + macintosh : \r + ƥʣ + ľة깴 ٯԪئʻ + ݱƥʾ + -----------------------------------------*/ +void chompex( char *buf ) +{ + while( *buf ){ + if( *buf == '\r' || *buf == '\n' ){ + *buf='\0'; + } + buf++; + } +} + + + +/*---------------------------------------- + * 깴1 ٯëԻ + * ¦ + * src ٯ + ----------------------------------------*/ +void chop( char* src ) +{ + /* + * ׷ϱ ٯëԻ + */ + int length = strlen( src ); + if( length == 0 ) return; + src[length-1] = '\0'; +} + + +/*---------------------------------------- + * 깴 ٯë£۹ ٯë ϶ƥ£ + * ¦ + * src 缰 ٯ + * delim ٯ NULL ٯƥȻ + ----------------------------------------*/ +void dchop( char* src , char* del) +{ + int dellen, srclen; + int i; + BOOL delete=FALSE; + + /* + * src ǷƩͻʣ1 ٯ年 del ͻëƻ + * ľʣ۹ƻݼ ٯʣ + */ + + srclen = strlen( src ); + dellen = strlen( del ); + if( srclen == 0 || dellen == 0 ) return; + + for( i = 0 ; i < dellen ; i ++ ){ + if( src[srclen-1] == del[i] ){ + delete = TRUE; + break; + } + } + + /* ԻԻ */ + if( delete )src[srclen - 1] = '\0'; +} + + +/*---------------------------------------- + * dchopѣ ټ ٯë£۹ ٯë ϶ƥ£ + * ¦ + * src 缰 ٯ + * delim ٯ NULL ٯƥȻ + ----------------------------------------*/ +void pohcd( char* src , char* del) +{ + int dellen, srclen; + int i; + BOOL delete=FALSE; + + /* + * src󡾮Ʃͻʣ1 ٯ年 del ͻëƻ + * ľʣ۹ƻݼ ٯʣ + */ + + srclen = strlen( src ); + dellen = strlen( del ); + if( srclen == 0 || dellen == 0 ) return; + + for( i = 0 ; i < dellen ; i ++ ){ + if( src[0] == del[i] ){ + delete = TRUE; + break; + } + } + + /* */ + if( delete ) + /* ƥ NULL ٯľ */ + for( i = 0 ; i < srclen ; i ++ ) + src[i] = src[i+1]; +} + + +/*---------------------------------------- + * ٯ ٯֳľ¾Ʃ£ + * ¦ + * src char* Ʃ ٯ + * include char* ֳľ¾ ٯ + * ߯Ի + * ٱֳľsrc + * -1 + ----------------------------------------*/ +int charInclude( char* src, char* include ) +{ + int i,j; + int srclen,includelen; + + srclen = strlen( src ); + includelen = strlen( include ); + + for( i = 0 ; i < srclen ; i ++ ){ + for( j = 0 ; j < includelen ; j ++ ) + if( src[i] == include[j] ) + return i; + } + return -1; +} + + +/*------------------------------------------------------------ + * EUC2 ëئstrncpy + * freeBSD Ƥ strncpy ëȻ廯 + * ľëݱհ*dest++ 羮컥 + * ئмƥȻئУ۾Ի ̼Ȼ + * ئԻ ئة + * ¦ + * dest char* + * src char* ĩ + * n size_t Ӯ + * ߯Ի + * dest + ------------------------------------------------------------*/ +char* strncpy2( char* dest, const char* src, size_t n ) +{ + if( n > 0 ){ + char* d = dest; + const char* s = src; + int i; + for( i=0; i=n ){ + *(d+i-1)='\0'; + break; + } + *(d+i) = *(s+i); + }else + *(d+i) = *(s+i); + } + } + return dest; +} + +/*---------------------------------------- + * src dest £ ƼëƩ£ + * ¦ + * dest + * n + * src 缰 ٯ + ----------------------------------------*/ +void strcpysafe( char* dest ,size_t n ,const char* src ) +{ + /* + * src dest . + * strcpy, strncpy ƥ dest Ի ڻ + * ݱ,ƹ½ʧͱ. + * ľë ʲб, strncpy ؤ» strlen( src ) n Ի + * ݱ巴, dest NULL ٯ練ئئ. + * + * ׻Ȼ dest Ի src õӮݱ巴 + * n-1 ƥ strncpy ë. ݷ + * + * n ݷƾئ¼ƥ ݷ ئУ + * + */ + // Nuke +1 (08/25): Danger if src=0 + if (!src) { + *dest = '\0'; + return; + } + if( n <= 0 ) /* ئ */ + return; + + /* ƥ n >= 1 */ + /* NULL ٯë ƻ ʤ */ + else if( n < strlen( src ) + 1 ){ + /* + * 뻥Իئмƥ n - 1(NULL ٯ) + * ƥ strncpy ë + */ + strncpy2( dest , src , n-1 ); + dest[n-1]='\0'; + }else + strcpy( dest , src ); + +} + +/*---------------------------------------- + * src length ʣ Ƽ ëƩ£ + * ¦ + * dest + * n Ƽ + * src + * length ٯ¾ + ----------------------------------------*/ +void strncpysafe( char* dest , const size_t n , + const char* src ,const int length ) +{ + /* + * src dest length + * strcpy, strncpy ƥ dest Ի ڻ + * ݱ,ƹ½ʧͱ. + * ƥstrlen( src ) length лõ + * ( ˱) dest ë ͻ + * strcpysafe Ԫë£ + */ + + int Short; + Short = min( strlen( src ) , length ); + + /* NULL ٯ ë ʤ */ + if( n < Short + 1 ){ + /* + * 뻥Իئмƥ n - 1(NULL ٯ) + * ƥ strncpy ë + */ + strncpy2( dest , src , n-1 ); + dest[n-1]='\0'; + + }else if( n <= 0 ){ + return; + }else{ + /* + * 뷴бؤ¼ƥ Short ƥstrncpyë + * ئ src 巴 Short Ӯ NULL ئмƥ + * dest 巴 ܰƻʣ + */ + + strncpy2( dest , src , Short ); + dest[Short]= '\0'; + + } +} + +/*------------------------------------------------------------ + * strcatë £мƥ ئëлئǣ + * ¦ + * src char* ئ ٯ + * size int src ( ǷľȻ¾ƥ + * ئʻ ) + * ap char* + * ߯Ի + * src ( ľ) + ------------------------------------------------------------*/ +char* strcatsafe( char* src, int size, char* ap ) +{ + strcpysafe( src + strlen( src ) , size - strlen(src), ap ); + return src; +} + +/*---------------------------------------- + * ٯ ë ʤ£ Ԫƾ ئ by ringo + * char *s1 , *s2 : ʤ ٯ + * ߯Ի + * 0 ئԪ + * 1 : ئ + * ľNPC ƽݩ ֧ʷֹ + ----------------------------------------*/ +int strcmptail( char *s1 , char *s2 ) +{ + int i; + int len1 = strlen( s1 ); + int len2 = strlen( s2 ); + + for(i=0;;i++){ + int ind1 = len1 - 1 - i; + int ind2 = len2 - 1 - i; + if( ind1 < 0 || ind2 < 0 ) return 0; + if( s1[ind1] != s2[ind2] ) return 1; + } +} + + + +/*---------------------------------------- + * ٯ ̤ľ°ë£ + * NPC ƽݩ ֧ʷֹ + * ׷ ٯؤ £ + * Ȭ ئʧة ʣ + * ¦ + * hoge char* ݩ ٯ + * ߯Ի + * ݩ װѣ + * + * + * "ringo ( ۰ ) 100" + * 100£ + * "ringo ( ۰ ) 100" + * 100ئ£ۻNPCئԻѣ + ----------------------------------------*/ +#define DECIMALCHARNUM 10 +#define FIGURECHARNUM 3 +#define SPECIALCHARNUM 2 +char *UTIL_decimalchar[DECIMALCHARNUM] = {"0","1","2", + "3", "4","5", + "6","7","8","9"}; +char *UTIL_figurechar[FIGURECHARNUM] = {"","",""}; +char *UTIL_specialchar[SPECIALCHARNUM] = {"",""}; + +/* + * ٯ գѰë ľ ë ʣ õ + * ƻ ʣeucã + * + * : in "Ȿ300" + * out "7" + * ¦ + * char *in: ٯ + * char *out: ٯ + * int outsiz: ٯ + * ߯Ի + * Ѱë лؤչ ٯ Ӯئը + */ +static int findNumberString( char *in, char *out, int outsiz ) +{ + int len,i,j,k, findflag, numstrflag; + char tmp[3]; + + len = strlen(in); + if( len == 0 ) return 0; + + numstrflag=0; + findflag = 0; + for( i=0,j=0;in[i]!='\0'&& j 0x7fffffff ) return 0x7fffffff; + else return (int)val; + +} + + +/* + * ֿƥ Ѱëѱ + * char *str Ѱë ٯ + * ߯Ի Ѱ + * + * str"һ4ǧ"߯Ի 140000000 + */ +int kanjistrToInt( char *str ) +{ + double val,tmpval; + char tmp[3]; + int num,i,j,numflag; + + numflag = 0; + num = 1; + tmpval = 0; + val = 0; + for( i=0;str[i]!='\0';i++ ){ + if( str[i] & 0x80 ){ + tmp[0] = str[i]; + tmp[1] = str[i+1]; + tmp[2] = '\0'; + i++; + }else{ + tmp[0] = str[i]; + tmp[1] = '\0'; + } + for( j=0;j 0x7fffffff ) return 0x7fffffff; + else return (int)val; + +} + + + +/*---------------------------------------- + * ٯ ̤ľ°ë£ + * NPC ƽݩ ֧ʷֹ + * ׷ ٯؤ £ + * Ȭ ئʧة ʣ + * ¦ + * hoge char* ݩ ٯ + * ߯Ի + * ݩ װѣ + * + * + * "ringo ( ۰ ) 100" + * 100£ + * "ringo ( ۰ ) 100" + * 100ئ£ۻNPCئԻѣ + ----------------------------------------*/ +int texttoiTail( char *hoge) +{ + return 0; /* ʲȻ׼ƥף۹ʣ */ +} + +/*---------------------------------------- + * ٯ ëٯƻٯ + * ¦ѱ ľ߯ + * ¦ + * arg + * number ëҽ + * base + * type ¦Ѽ( CTYPE common.h ɽľ ) + * ߯Ի + * TRUE(1) + * FALSE(0) strtolձ巴 ئ + * ݼnumberstrtol߯Իƥؤ + ----------------------------------------*/ +BOOL strtolchecknum( char* arg , void* number,int base ,CTYPE type) +{ + char* buf; + int num; + + num = strtol( arg, &buf, base); + + switch( type ){ + case CHAR: + *(char*)number = (char)num; + break; + case SHORT: + *(short*)number = (short)num; + break; + case INT: + *(int*)number = num; + break; + case DOUBLE: + *(double*)number = (double)num; + break; + default: + break; + } + + + if( strlen( buf ) >= 1 ) + /* + * Ի ٯؤеǷ ľئеئ֣ + */ + return FALSE; + + return TRUE; + +} + + + + +/*---------------------------------------- + * src dels ƥ϶ ٯëԻ + * ͵ب޵ƥؤDZ + * Ի͵بƥئУ + * ¦ + * src ʽľ ٯ + * char* ٯ( ٯ ƥ϶õ) + * ߯Ի + * ئ + ----------------------------------------*/ +void deleteCharFromString( char* src , char* dels ) +{ + int index=0; /* ƥؤԻ ٯ ƥ index */ + int delength; /* dels Ӯëɬ(Ʒպʧ󼰿 */ + int i=0,j;/* i src ë j dels ë */ + + delength= strlen( dels ); + + while( src[i] != '\0' ){ + if( src[i] == BACKSLASH ) + /* + * ͵بئƥ޵ + * Իݼ ٯ + */ + src[index++] = src[++i]; /* substitute next char */ + + else{ + for( j = 0 ; j < delength ; j ++ ){ + if( src[i] == dels[j] ) + /* + * ٯ֣۷Ȼ i 1 ë + */ + goto incrementi; + } + /* + * ϶ýľئмƥ£ + */ + src[index++] = src[i]; + } + incrementi: + i++; + } + + src[index] = '\0'; +} + + + +/*---------------------------------------- + * src dels ƥ϶ ٯëԻ + * ޵ئ + * ¦ + * src ʽľ ٯ + * char* ٯ( ٯ ƥ϶õ) + * ߯Ի + * ئ + ----------------------------------------*/ +void deleteCharFromStringNoEscape( char* src , char* dels ) +{ + int index=0; /* ƥؤԻ ٯ ƥ index */ + int delength; /* dels Ӯëɬ(Ʒպʧ󼰿 */ + int i=0,j;/* i src ë j dels ë */ + + delength= strlen( dels ); + + while( src[i] != '\0' ){ + for( j = 0 ; j < delength ; j ++ ){ + if( src[i] == dels[j] ) + /* + * ٯ֣۷Ȼ i 1 ë + */ + goto incrementi; + } + /* + * ϶ýľئмƥ£ + */ + src[index++] = src[i]; + incrementi: + i++; + } + + src[index] = '\0'; +} + +/*------------------------------------------------------------ + * ϶ýľ ٯë϶ýľ ٯƥ 微 + * ¦ + * src char* ʽľ ٯ + * oldc char ʽľ ٯ + * newc char ٯ + * ߯Ի + * src + ------------------------------------------------------------*/ +char* replaceString( char* src, char oldc ,char newc ) +{ + char* cp=src; + + do{ + if( *cp == oldc ) *cp=newc; + }while( *cp++ ); + return src; +} + +typedef struct tagEscapeChar +{ + char escapechar; + char escapedchar; +}EscapeChar; +static EscapeChar escapeChar[]= +{ + { '\n', 'n' }, + { ',', 'c' }, + { '|', 'z' }, + { '\\', 'y' }, +}; + + +char makeCharFromEscaped( char c )//add this function,because the second had it +{ + int i; + + for( i = 0; i < sizeof( escapeChar )/sizeof( escapeChar[0] ); i++ ) + { + if( escapeChar[i].escapedchar == c ) + { + c = escapeChar[i].escapechar; + break; + } + } + return c; +} +/*---------------------------------------- + * makeEscapeStringƥľ ٯ ë + * ¦ + * src char* ئ ٯ ۳ľ̤׸£ + * ߯Ի + * src ë߯ʣ(ë ľ֧з) + ----------------------------------------*/ +char *makeStringFromEscaped( char* src ) +{//ttom this function all change,beside copy from the second + + int i; + // CoolFish: Fix bug 2001/10/13 + // int srclen = strlen( src ); + int srclen = 0; + int searchindex=0; + + // CoolFish: Fix bug 2001/10/13 + if (!src) return NULL; + srclen = strlen(src); + + for( i = 0; i < srclen; i ++ ) + { + // for 2Byte Word + if( IS_2BYTEWORD( src[i] ) ){ + src[searchindex++] = src[i++]; + src[searchindex++] = src[i]; + }else + if( src[i] == '\\' ) + { + // ݼ ٯ + i++; + src[searchindex++] = makeCharFromEscaped( src[i] ); + } + else + { + src[searchindex++] = src[i]; + } + } + src[searchindex] = '\0'; + + return src; +} + +char* makeEscapeString( char* src , char* dest, int sizeofdest) +{ //ttom this function all change, copy from the second + int i; + int srclen = 0; + int destindex=0; + + // CoolFish: Fix bug 2001/10/13 + if (!src) return NULL; + srclen = strlen(src); + + for( i = 0 ; i < srclen ; i ++ ){ + BOOL dirty=FALSE; + int j; + char escapechar='\0'; + if( destindex + 1 >= sizeofdest )break; + if( IS_2BYTEWORD( src[i] ) ){ + if( destindex + 2 >= sizeofdest )break; + + dest[destindex] = src[i]; + dest[destindex+1] = src[i+1]; + destindex += 2; + i ++; + continue; + } + for( j = 0; j= length ){ + print( "*\n"); + break; + } + src[index++]=src[i]; + /* DZ */ + backchar = '\0'; + continue; + } + if( src[i] == backchar ) + /* + * ԪئУ۹Իֱئ£ + */ + continue; + + /* + * ٯئئ׼ƥ backchar NULL ٯ + * ľԪ + */ + backchar = '\0'; + for( j = 0 ; j < delength ; j ++ ){ + if( src[i] == dels[j] ){ + /* + * ٯ ֣ ƥ continue ئDZ巽Ի + * ٯئǻƥ£ + */ + backchar=src[i]; + break; + } + } + src[index++]=src[i]; + } + src[index++]='\0'; +} + +/*---------------------------------------- + * hashë߯ʣ ٯ 弰 + * ľ ئƥʧةϻ + * ʧةУ + * ¦ + * s ٯ + * ߯Ի + * int ˦ب + *----------------------------------------*/ +#define PRIME 211 +int hashpjw ( char* s ) +{ + char *p; + unsigned int h= 0 ,g; + for( p = s ; *p ; p ++ ){ + h = ( h<< 4 ) + (*p); + if( (g = h & 0xf0000000) != 0){ + h = h ^ (g>>24); + h = h ^ g; + } + } + return h % PRIME; +} + +/*---------------------------------------- + * л̼ĩë߯( TCP ) + * ¦ + * port л̡ + * ߯Ի + * -1 ޷¡ + * 1. socket˵ ةP޷¡ + * 2. bind˵ ةP޷¡ + * 3. listen˵ ةP޷¡ + ----------------------------------------*/ +int bindlocalhost( int port ) +{ + struct sockaddr_in sin; /*лʧ*/ + int sfd; /*ĩū*/ + int rc; /*л*/ + + /*AF_INET SOCK_STREAM */ + sfd = socket( AF_INET, SOCK_STREAM, 0 ); + if( sfd == -1 ){ + print( "%s\n" , strerror(errno ) ); + return -1; + } + if( getReuseaddr() ) { + int sendbuff; + /* лʧ */ + setsockopt( sfd, SOL_SOCKET, SO_REUSEADDR, + (char *)&sendbuff, sizeof( sendbuff)); + } + + /*0ʧƻëҽ */ + memset( &sin ,0, sizeof( struct sockaddr_in ) ); + sin.sin_family=AF_INET; + sin.sin_port = htons( port ); + sin.sin_addr.s_addr = INADDR_ANY; + + rc = bind( sfd , (struct sockaddr*)&sin, sizeof(struct sockaddr_in)); + if( rc == -1 ){ + print( "%s\n" , strerror(errno ) ); + return -1; + } + + rc = listen( sfd , 5 ); + if( rc == -1 ){ + print( "%s\n" , strerror(errno ) ); + return -1; + } + return sfd; +} + + + +/*---------------------------------------- + * £( TCP ) + * ¦ + * hostname ʯ + * (xx.xxx.xxx.xxxƥxxx.co.jp羮ƥ) + * port ʯ̡ + * ߯Ի + * ū( -1 ݷ޷¡ ) + ----------------------------------------*/ +int connectHost( char* hostname , unsigned short port ) +{ + struct sockaddr_in sock; /*connectݱ*/ + struct hostent* hoste; /*hostnamehostent*/ + int fd; /*ĩū*/ + int lr; /*л*/ + + memset( &sock , 0 , sizeof( struct sockaddr_in ) ); + sock.sin_family = AF_INET; + sock.sin_port = htons( port ); + + /* dot notation ëƩ */ + sock.sin_addr.s_addr = inet_addr( hostname ); + if( sock.sin_addr.s_addr == -1 ){ + /* + *޷¡ dot notation ƥئУ׻Ȼ ɧ ݩ裻 ֣ۢ + * dnsëئľئئݷʼֳƥ֧Ȼľ£ + */ + hoste = gethostbyname( hostname ); + if( hoste == NULL ){ + print( "ȡʧܣȷDNSַ\n" ); + return -1; + } + + memcpy((void*)&sock.sin_addr.s_addr , + hoste->h_addr , sizeof(struct in_addr) ); + } + + /*ĩë*/ + fd = socket( AF_INET, SOCK_STREAM , 0 ); + if( fd == -1 ){ + print("Cannot Create Socket(%s errno:%d)\n" + ,strerror( errno ) ,errno ); + return -1; + } + /**/ + lr = connect(fd,(struct sockaddr*)&sock,sizeof(struct sockaddr_in)); + if( lr != 0 ){ + print("Cannot connect. (%s errno:%d)\n" + ,strerror( errno ) ,errno ); + return -1; + } + return fd; +} + + +/*---------------------------------------- + * 뼰 ݱ淤įؤ¾ + * ƶʧة ʣ + * ¦ + * char* Ʃ ٯ + * ߯Ի + * ٱέݱ淤į ʧͱݱа + * еǾе + * existsNewLinwCharacter( "aho\nhoge\n" ) + * ߯Ի 3 ئ£۳ľǣ + * -1 ئ + * + ----------------------------------------*/ +int existsNewLineCharacter( char* line ) +{ +#if 1 + char* old = line; + do{ + if( *line == NEWLINE)return line-old; + }while( *(line++) ); +#else + int i; /* */ + int length = strlen( line ); /*Ʃ ٯ Ӯ*/ + for( i = 0 ; i < length ; i ++ ){ + if( line[i] == NEWLINE ) + return i; + } +#endif + + return -1; +} + + + +/*---------------------------------------- + * ٯ ٯ ľëʣ ë裻ľ£ + * nindex( string , c , 1 ) index( string , c ) equivalent ƥؤ£ + * number ׷0ݷ߯Իstring Ԫƥؤ£ + * + * ¦ + * string char* Ʃ ٯ + * c int Ʃ ٯ + * number int į + * ߯Ի + * ٯ̼ + * NULL Ĺئף + ----------------------------------------*/ +char* nindex( char* string, int c , int number ) +{ + int i; /* */ + int num=0; + int length = strlen( string ); /*Ʃ ٯ Ӯ*/ + if( number <= 0 )return string; + for( i = 0 ; i < length ; i ++ ){ + if( string[i] == c )num++; + if( number == num ) return &string[i]; + } + return NULL; +} + +BOOL rrd( char* dirname , STRING64* buf ,int bufsize, int* index) +{ + DIR* d; + char dirn[1024]; + + d = opendir( dirname ); + if( d == NULL )return FALSE; + + while( 1 ){ + struct dirent* dent; + struct stat st; + dent = readdir( d ); + if( dent == NULL ){ + if( errno == EBADF ){ + errorprint; + closedir(d); + return FALSE; + }else + /* successful */ + break; + } + + /* . ƥ°̻ﷴ ئ */ + if( dent->d_name[0] == '.' )continue; + + snprintf(dirn, sizeof(dirn), "%s/%s" , dirname,dent->d_name ); + if( stat( dirn , &st ) == -1 )continue; + if( S_ISDIR( st.st_mode ) ){ + if( rrd( dirn , buf ,bufsize, index) == FALSE ){ + closedir(d); + return FALSE; + } + }else{ + if( *index >= bufsize ) + break; + + strcpysafe( buf[*index].string , sizeof( buf[*index].string ), dirn ); + (*index)++; + } + } + closedir(d); + return TRUE; +} + +int rgetFileName( char* dirname , STRING64* string, int size) +{ + int index=0; + if( rrd( dirname , string ,size ,&index ) == FALSE )return -1; + else return index; +} + +BOOL checkStringsUnique( char** strings, int num ,int verbose) +{ + int i,j; + for( i = 0 ; i < num - 1; i ++ ){ + for( j = i+1 ; j < num ; j ++){ + if( !strcmp( strings[i] ,strings[j] )){ + if( verbose ) + print( "Overlapp string is %s\n", strings[i] ); + return FALSE; + } + } + } + return TRUE; +} + +BOOL PointInRect( RECT* rect, POINT* p ) +{ + if( rect->x <= p->x && p->x <= rect->x + rect->width && + rect->y <= p->y && p->y <= rect->y + rect->height ) + return TRUE; + return FALSE; +} + +BOOL CoordinateInRect( RECT* rect, int x, int y) +{ + POINT p={x,y}; + return PointInRect(rect,&p); +} + +int clipRect( RECT *rect1, RECT *rect2, RECT *ret ) +{ + if( rect1->x > rect2->x + rect2->width -1 + || rect2->x > rect1->x + rect1->width -1 + || rect1->y > rect2->y + rect2->height -1 + || rect2->y > rect1->y + rect1->height -1 ) + return 0; + ret->x = max( rect1->x, rect2->x ); + ret->y = max( rect1->y, rect2->y ); + ret->width = min( rect1->x+rect1->width, rect2->x+rect2->width ) - ret->x; + ret->height = min( rect1->y+rect1->height, rect2->y+rect2->height ) - ret->y; + return 1; +} + +BOOL isstring1or0( char* string ) +{ + if( strcasecmp(string,"TRUE" ) == 0 )return TRUE; + if( strcasecmp(string,"FALSE") == 0 )return FALSE; + if( strcasecmp(string,"1" ) == 0 )return TRUE; + if( strcasecmp(string,"0" ) == 0 )return FALSE; + if( strcasecmp(string,"ON" ) == 0 )return TRUE; + if( strcasecmp(string,"OFF" ) == 0 )return FALSE; + return FALSE; +} + +void easyGetTokenFromString( char *src,int count,char*output,int len ) +{ + int i; + int counter = 0; + + if( len <= 0 )return; + + +#define ISSPACETAB( c ) ( (c) == ' ' || (c) == '\t' ) + + for(i=0;;i++){ + if( src[i]=='\0'){ + output[0] = '\0'; + return; + } + if( i > 0 && ! ISSPACETAB( src[i-1] ) && + ! ISSPACETAB( src[i] ) ){ + continue; + } + + if( ! ISSPACETAB( src[i]) ){ + counter++; + if( counter == count){ + /* copy it */ + int j; + for(j=0;j1---- + * + * + ------------------------------------------------------------*/ +float linearDiv( float val1 , float val2 , float d ) +{ + return val1 + ( val2 - val1 ) * ( d ); +} + + +/*------------------------------------------------------------ + * ٯ ئ ئ ٯëlen ٯԻƻ¼ĸةئ + * ٯ ë£NPC¼ĸةɵϷ年Ȼ + * + * char *cand : ռ٣ ٯ + * char *out : + * int len : Ӯ + ------------------------------------------------------------*/ +void makeRandomString( char *cand , char *out , int len ) +{ + int i; + int l = strlen( cand ); + + for(i=0;i= baselen; i ++ ) { + tmp[i] = src % baselen; + src /= baselen; + } + i--; + if( minus ){ + *out = '-'; + *(out+1) = base[src]; + for( j = 2; i >= 0; i --, j ++ ) { + if( j > outlen - 2 ) return NULL; + *(out+j) = base[tmp[i]]; + } + } else { + *out = base[src]; + for( j = 1; i >= 0; i --, j ++ ) { + if( j > outlen - 2 ) return NULL; + *(out+j) = base[tmp[i]]; + } + } + *(out+j) = '\0'; + return( out); +#else +/* */ +#define CNV_NUMBER 62 + int i, j; + char base[] = { "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"}; + int tmp[64]; + int src; + if( a < 0 ) return( NULL); + if( a < CNV_NUMBER) { + *out = base[a]; + *(out+1) = '\0'; + return( out); + } + src = a; + for( i = 0; src >= CNV_NUMBER; i ++ ) { + tmp[i] = src % CNV_NUMBER; + src /= CNV_NUMBER; + } + i--; + *out = base[src]; + for( j = 1; i >= 0; i --, j ++ ) { + if( j > outlen - 2 ) return NULL; + *(out+j) = base[tmp[i]]; + } + *(out+j) = '\0'; + return( out); +#undef CNV_NUMBER +#endif +} +/* + * ܸľ ƥѰ ƻ¾Ʃ + * -1 ½е ئ + * + * ¦ + * src *int Ʃ缰 + * srclen int src + * + * Ի ؤԻ TRUE + * ئ FALSE + */ +BOOL checkRedundancy( int *src, int srclen) +{ + int i,j; + int ret = FALSE; + + for( i = 0; i < srclen; i ++ ) { + if( *(src + i) != -1 ) { + for( j = i+1; j < srclen; j ++ ) { + if( *(src +i) == *( src+j) ) { + ret = TRUE; + break; + } + } + } + } + return ret; +} +void +shuffle_ints( int num, int *a, int t ) +{ + int i; + for(i=0;i> 8 ) & 0xFF ] + ^ ( crc << 8 ) ^ BitTable[ p[ i ] ] ); + } + return crc; +} + +// Add Code By Shan 2001.06.16 +INLINE double time_diff(struct timeval subtrahend, + struct timeval subtractor) +{ + return( (subtrahend.tv_sec - subtractor.tv_sec) + + (subtrahend.tv_usec + - subtractor.tv_usec ) / (double)1E6 ); +} + +char *strcpy_s(char *des, size_t n, const char *src) +{ + assert(des != NULL && src != NULL); + + if(des == NULL || src == NULL || n == 0) + { + return NULL; + } + + char *TM_RetChar = des; + int i = 0; + + while( (*des++ = *src++) ) + { + i++; + if( i >= n ) + { + i--; + break; + } + } + TM_RetChar[i] = '\0'; + return TM_RetChar; +} + +char *replace(char *source,char *sub,char *rep) +{ +char *result; +/*pc1 ǸƵresultɨָ*/ +/*pc2 ɨ source ĸָ*/ +/*pc3 ѰӴʱ,Ϊ仯еsourceǷӴ,ָsubɨָ */ +/*ҵƥ,Ϊ˸Ƶ,ָrepɨָ*/ +char *pc1, *pc2, *pc3; +int isource, isub, irep; +isub =strlen(sub); /*Աַij*/ +irep =strlen(rep); /*滻ַij*/ +isource=strlen(source);/*Դַij*/ +if(NULL == *sub) +return strdup(source); +/*ҪĿռ*/ +result = (char *)malloc(( (irep > isub) ? (float)strlen(source) / isub* irep+ 1:isource ) * sizeof(char)); +pc1 = result; /*Ϊpc1θƽÿֽ׼*/ +while(*source != NULL) +{ +/*ΪsourcesubǷ׼,Ϊpc2,pc3 ֵ*/ + pc2 = source; + pc3 = sub; + /* ѭģһǣ + * *pc2 *pc3Ӵȣ + * pc2 Դβ + * pc3 Դβʱ,ȫӴ,sourcesubȣ + *****************************************************/ + while(*pc2 == *pc3 && *pc3 != NULL && *pc2 != NULL) + pc2++, pc3++; + /* ҵӴ,´*/ + if(NULL == *pc3) + { + pc3 = rep; + /*׷ӵ*/ + while(*pc3 != NULL) + *pc1++ = *pc3++; + pc2--; + source = pc2; + /* sourcesubȵѭ + * pc2 Ӧλ sub дԴһλá + * source ָǰһַ + */ + } + else /*ûҵӴ,渴sourceָֽڵ*/ + *pc1++ = *source; + source++; /* sourceһַ*/ +} +*pc1 = NULL; +return result; +} + +int getHash ( char* s ) +{ + int i; + int h=0; + + for(i=0;; i++){ + if( s[i] == 0 ){ + break; + } + h += s[i]; + } + return h; +} + +//int RAND (int x,int y) +//{ +// srand((int)time(0)); +// return (x-1)+1+(int)( (double)(y-(x-1))*rand()/(RAND_MAX+1.0)); +//}